| | |
| | | package com.zy.asrs.wcs.core.timer; |
| | | |
| | | 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.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 lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.scheduling.annotation.Scheduled; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | @Slf4j |
| | |
| | | @Autowired |
| | | private TaskService taskService; |
| | | @Autowired |
| | | private TaskLogService taskLogService; |
| | | @Autowired |
| | | private LocService locService; |
| | | |
| | | @Scheduled(cron = "0/1 * * * * ? ") |
| | | @Transactional |
| | | public synchronized void clearCompletedTask() { |
| | | ArrayList<Long> taskSts = new ArrayList<>(); |
| | | taskSts.add(TaskStsType.COMPLETE_INBOUND.sts); |
| | |
| | | for (Task task : tasks) { |
| | | //记录库存信息 |
| | | updateRecordLoc(task); |
| | | //任务转历史档 |
| | | saveTaskLog(task); |
| | | } |
| | | |
| | | } |
| | | |
| | | //更新库存信息 |
| | | private void updateRecordLoc(Task task) { |
| | | @Transactional |
| | | public void updateRecordLoc(Task task) { |
| | | if (task.getRecordLoc().equals("Y")) {//记录库存信息 |
| | | //源库位 => 空库 |
| | | //目标库位 => 在库 |
| | |
| | | } |
| | | } |
| | | |
| | | //更新历史档 |
| | | @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); |
| | | taskLogService.save(taskLog); |
| | | |
| | | //删除源任务 |
| | | taskService.removeById(task.getId()); |
| | | } |
| | | |
| | | } |