| | |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.zy.asrs.wcs.core.entity.Loc; |
| | | import com.zy.asrs.wcs.core.entity.Task; |
| | | import com.zy.asrs.wcs.core.entity.TaskLog; |
| | | import com.zy.asrs.wcs.core.entity.*; |
| | | import com.zy.asrs.wcs.core.model.enums.LocStsType; |
| | | import com.zy.asrs.wcs.core.model.enums.TaskStsType; |
| | | import com.zy.asrs.wcs.core.service.LocService; |
| | | import com.zy.asrs.wcs.core.service.TaskLogService; |
| | | import com.zy.asrs.wcs.core.service.TaskService; |
| | | import com.zy.asrs.wcs.core.service.*; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.scheduling.annotation.Scheduled; |
| | |
| | | private TaskService taskService; |
| | | @Autowired |
| | | private TaskLogService taskLogService; |
| | | @Autowired |
| | | private MotionService motionService; |
| | | @Autowired |
| | | private MotionLogService motionLogService; |
| | | @Autowired |
| | | private LocService locService; |
| | | |
| | |
| | | //更新库存信息 |
| | | @Transactional |
| | | public void updateRecordLoc(Task task) { |
| | | if (task.getRecordLoc() == null) { |
| | | return; |
| | | } |
| | | |
| | | if (task.getRecordLoc().equals("Y")) {//记录库存信息 |
| | | //源库位 => 空库 |
| | | //目标库位 => 在库 |
| | |
| | | locService.updateById(destLoc); |
| | | } |
| | | } else if (task.getRecordLoc().equals("record-dest")) {//只记录目标库位信息 |
| | | //目标库位 => 在库 |
| | | Loc destLoc = locService.selectByLocNo(task.getDestLoc()); |
| | | if (destLoc != null) { |
| | | destLoc.setLocSts(LocStsType.F.val()); |
| | |
| | | @Transactional |
| | | public void saveTaskLog(Task task) { |
| | | //创建历史档 |
| | | Date date = new Date(); |
| | | TaskLog taskLog = new TaskLog(); |
| | | taskLog.setTaskNo(task.getTaskNo()); |
| | | taskLog.setTaskData(JSON.toJSONString(task)); |
| | | taskLog.setCreateTime(date); |
| | | taskLog.setUpdateTime(date); |
| | | taskLog.sync(task); |
| | | taskLog.setUpdateTime(new Date()); |
| | | taskLogService.save(taskLog); |
| | | |
| | | List<Motion> motions = motionService.list(new LambdaQueryWrapper<Motion>().eq(Motion::getTaskNo, task.getTaskNo()).eq(Motion::getHostId, task.getHostId())); |
| | | for (Motion motion : motions) { |
| | | //创建动作历史档 |
| | | MotionLog motionLog = new MotionLog(); |
| | | motionLog.sync(motion); |
| | | motionLog.setUpdateTime(new Date()); |
| | | motionLogService.save(motionLog); |
| | | } |
| | | |
| | | //删除源任务 |
| | | taskService.removeById(task.getId()); |
| | | //删除动作 |
| | | motionService.remove(new LambdaQueryWrapper<Motion>().eq(Motion::getTaskNo, task.getTaskNo()).eq(Motion::getHostId, task.getHostId())); |
| | | } |
| | | |
| | | } |