| | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.zy.acs.manager.manager.entity.Loc; |
| | | import com.zy.acs.manager.manager.entity.Sta; |
| | | import com.zy.acs.manager.manager.entity.Task; |
| | | import com.zy.acs.manager.manager.enums.LocStsType; |
| | | import com.zy.acs.manager.manager.enums.TaskStsType; |
| | | import com.zy.acs.manager.manager.enums.TaskTypeType; |
| | | import com.zy.acs.manager.manager.mapper.LocMapper; |
| | | import com.zy.acs.manager.manager.service.LocService; |
| | | import com.zy.acs.manager.manager.service.StaService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Objects; |
| | | |
| | | @Slf4j |
| | | @Service("locService") |
| | | public class LocServiceImpl extends ServiceImpl<LocMapper, Loc> implements LocService { |
| | | |
| | | @Autowired |
| | | private StaService staService; |
| | | |
| | | @Override |
| | | public Loc selecatByLocNo(String locNo) { |
| | | public Loc selectByLocNo(String locNo) { |
| | | return this.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getLocNo, locNo)); |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | @Override |
| | | public void taskCallBack(Task task) { |
| | | if (null == task) { |
| | | return; |
| | | } |
| | | if (!task.getTaskSts().equals(TaskStsType.PROGRESS.val())) { |
| | | return; |
| | | } |
| | | Date now = new Date(); |
| | | // loc status |
| | | Loc oriLoc = null; |
| | | Loc destLoc = null; |
| | | Sta oriSta = null; |
| | | Sta destSta = null; |
| | | switch (Objects.requireNonNull(TaskTypeType.get(task.getTaskTypeEl()))) { |
| | | case LOC_TO_LOC: |
| | | oriLoc = this.getById(task.getOriLoc()); |
| | | if (oriLoc.getLocSts().equals(LocStsType.PAKOUT.val())) { |
| | | oriLoc.setLocSts(LocStsType.IDLE.val()); |
| | | oriLoc.setUpdateTime(now); |
| | | if (!this.updateById(oriLoc)) { |
| | | log.error("Loc [{}] 库位修改状态失败", task.getOriLoc$()); |
| | | } |
| | | } |
| | | public Loc selectRandOneByLocSts(Long locSts, Integer limit) { |
| | | List<Loc> locList = this.selectRandByLocSts(locSts, limit); |
| | | return locList.stream().findFirst().orElse(null); |
| | | } |
| | | |
| | | destLoc = this.getById(task.getDestLoc()); |
| | | if (destLoc.getLocSts().equals(LocStsType.PAKIN.val())) { |
| | | destLoc.setLocSts(LocStsType.STOCK.val()); |
| | | destLoc.setUpdateTime(now); |
| | | if (!this.updateById(destLoc)) { |
| | | log.error("Loc [{}] 库位修改状态失败", task.getDestLoc$()); |
| | | } |
| | | } |
| | | break; |
| | | case LOC_TO_STA: |
| | | oriLoc = this.getById(task.getOriLoc()); |
| | | if (oriLoc.getLocSts().equals(LocStsType.PAKOUT.val())) { |
| | | oriLoc.setLocSts(LocStsType.IDLE.val()); |
| | | oriLoc.setUpdateTime(now); |
| | | if (!this.updateById(oriLoc)) { |
| | | log.error("Loc [{}] 库位修改状态失败", task.getOriLoc$()); |
| | | } |
| | | } |
| | | break; |
| | | case STA_TO_LOC: |
| | | destLoc = this.getById(task.getDestLoc()); |
| | | if (destLoc.getLocSts().equals(LocStsType.PAKIN.val())) { |
| | | destLoc.setLocSts(LocStsType.STOCK.val()); |
| | | destLoc.setUpdateTime(now); |
| | | if (!this.updateById(destLoc)) { |
| | | log.error("Loc [{}] 库位修改状态失败", task.getDestLoc$()); |
| | | } |
| | | } |
| | | break; |
| | | case STA_TO_STA: |
| | | break; |
| | | case TO_CHARGE: |
| | | case TO_STANDBY: |
| | | case MOVE: |
| | | break; |
| | | default: |
| | | break; |
| | | @Override |
| | | public List<Loc> selectRandByLocSts(Long locSts, Integer limit) { |
| | | if (locSts == null) { |
| | | return null; |
| | | } |
| | | |
| | | return this.baseMapper.selectRandByLocSts(locSts, limit); |
| | | } |
| | | |
| | | } |