package com.zy.asrs.wms.asrs.service.impl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.zy.asrs.framework.exception.CoolException; import com.zy.asrs.wms.asrs.mapper.CircleRuleMapper; import com.zy.asrs.wms.asrs.entity.CircleRule; import com.zy.asrs.wms.asrs.service.CircleRuleService; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springframework.stereotype.Service; @Service("circleRuleService") public class CircleRuleServiceImpl extends ServiceImpl implements CircleRuleService { @Override public CircleRule getCircleRuleByFlag(String flag) { return this.getOne(new LambdaQueryWrapper().eq(CircleRule::getFlag, flag)); } @Override public Integer getCurrentValueByFlag(String flag) { CircleRule circleRule = this.getOne(new LambdaQueryWrapper().eq(CircleRule::getFlag, flag)); if(circleRule == null){ throw new CoolException("循环策略不存在"); } Integer currentValue = circleRule.getCurrentValue(); Integer startValue = circleRule.getStartValue(); Integer targetValue = circleRule.getTargetValue(); if (currentValue > targetValue) { currentValue = startValue; }else { currentValue += 1; } circleRule.setCurrentValue(currentValue); this.updateById(circleRule); return currentValue; } }