| package com.zy.acs.manager.manager.service.impl; | 
|   | 
| 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 lombok.extern.slf4j.Slf4j; | 
| 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 { | 
|   | 
|     @Override | 
|     public Loc selecatByLocNo(String locNo) { | 
|         return this.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getLocNo, locNo)); | 
|     } | 
|   | 
|     @Override | 
|     public List<Map<String, Object>> selectCountGroupByLocSts() { | 
|         return this.baseMapper.selectCountGroupByLocSts(); | 
|     } | 
|   | 
|     @Override | 
|     public List<Map<String, Object>> selectDigitalLocWhichNeedShow() { | 
|         return this.baseMapper.selectDigitalLocWhichNeedShow(); | 
|     } | 
|   | 
|     @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$()); | 
|                     } | 
|                 } | 
|   | 
|                 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; | 
|         } | 
|   | 
|     } | 
|   | 
| } |