#
Junjie
3 天以前 517966d4dbed6ef6e5d591720b971af427e6b63a
src/main/java/com/zy/asrs/task/WrkMastScheduler.java
@@ -1,7 +1,6 @@
package com.zy.asrs.task;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.zy.asrs.domain.enums.NotifyMsgType;
import com.zy.asrs.entity.LocMast;
@@ -10,13 +9,9 @@
import com.zy.asrs.service.WrkMastLogService;
import com.zy.asrs.service.WrkMastService;
import com.zy.asrs.utils.NotifyUtils;
import com.zy.common.utils.HttpHandler;
import com.zy.core.enums.LocStsType;
import com.zy.core.enums.SlaveType;
import com.zy.core.enums.WrkIoType;
import com.zy.core.enums.WrkStsType;
import com.zy.system.entity.Config;
import com.zy.system.service.ConfigService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
@@ -62,6 +57,7 @@
            }
            locMast.setLocSts("F");
            locMast.setBarcode(wrkMast.getBarcode());
            locMast.setModiTime(new Date());
            boolean result = locMastService.updateById(locMast);
            if (!result) {
@@ -79,7 +75,7 @@
            }
            //上报
            notifyUtils.notify("task", 1, String.valueOf(wrkMast.getWrkNo()), NotifyMsgType.TASK_COMPLETE, JSON.toJSONString(wrkMast));
            notifyUtils.notify("task", 1, String.valueOf(wrkMast.getWrkNo()), wrkMast.getWmsWrkNo(), NotifyMsgType.TASK_COMPLETE, JSON.toJSONString(wrkMast));
        }
    }
@@ -105,6 +101,7 @@
            }
            locMast.setLocSts("O");
            locMast.setBarcode("");
            locMast.setModiTime(new Date());
            boolean result = locMastService.updateById(locMast);
            if (!result) {
@@ -122,7 +119,7 @@
            }
            //上报
            notifyUtils.notify("task", 1, String.valueOf(wrkMast.getWrkNo()), NotifyMsgType.TASK_COMPLETE, JSON.toJSONString(wrkMast));
            notifyUtils.notify("task", 1, String.valueOf(wrkMast.getWrkNo()), wrkMast.getWmsWrkNo(), NotifyMsgType.TASK_COMPLETE, JSON.toJSONString(wrkMast));
        }
    }
@@ -185,50 +182,7 @@
            }
            //上报
            notifyUtils.notify("task", 1, String.valueOf(wrkMast.getWrkNo()), NotifyMsgType.TASK_COMPLETE, JSON.toJSONString(wrkMast));
        }
    }
    @Scheduled(cron = "0/1 * * * * ? ")
    @Transactional
    public void executeMove(){
        List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>().eq("wrk_sts", WrkStsType.COMPLETE_MOVE.sts));
        if (wrkMasts.isEmpty()) {
            return;
        }
        for (WrkMast wrkMast : wrkMasts) {
            // 保存工作主档历史档
            if (!wrkMastLogService.save(wrkMast.getWrkNo())) {
                log.info("保存工作历史档[workNo={}]失败", wrkMast.getWrkNo());
            }
            // 删除工作主档
            if (!wrkMastService.deleteById(wrkMast)) {
                log.info("删除工作主档[workNo={}]失败", wrkMast.getWrkNo());
            }
        }
    }
    @Scheduled(cron = "0/1 * * * * ? ")
    @Transactional
    public void executeCharge(){
        List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>().eq("wrk_sts", WrkStsType.COMPLETE_CHARGE.sts));
        if (wrkMasts.isEmpty()) {
            return;
        }
        for (WrkMast wrkMast : wrkMasts) {
            // 保存工作主档历史档
            if (!wrkMastLogService.save(wrkMast.getWrkNo())) {
                log.info("保存工作历史档[workNo={}]失败", wrkMast.getWrkNo());
            }
            // 删除工作主档
            if (!wrkMastService.deleteById(wrkMast)) {
                log.info("删除工作主档[workNo={}]失败", wrkMast.getWrkNo());
            }
            //上报
            notifyUtils.notify("task", 1, String.valueOf(wrkMast.getWrkNo()), NotifyMsgType.TASK_CHARGE_COMPLETE, JSON.toJSONString(wrkMast));
            notifyUtils.notify("task", 1, String.valueOf(wrkMast.getWrkNo()), wrkMast.getWmsWrkNo(), NotifyMsgType.TASK_COMPLETE, JSON.toJSONString(wrkMast));
        }
    }
@@ -257,7 +211,7 @@
                locMastService.updateById(locMast);
            } else if (wrkMast.getIoType() == WrkIoType.OUT.id) {
                LocMast locMast = locMastService.queryByLoc(wrkMast.getSourceLocNo());
                locMast.setLocSts(String.valueOf(LocStsType.O));
                locMast.setLocSts(String.valueOf(LocStsType.F));
                locMast.setModiTime(new Date());
                locMastService.updateById(locMast);
            } else if (wrkMast.getIoType() == WrkIoType.LOC_MOVE.id) {
@@ -277,7 +231,7 @@
            }
            //上报
            notifyUtils.notify("task", 1, String.valueOf(wrkMast.getWrkNo()), NotifyMsgType.TASK_CANCEL, JSON.toJSONString(wrkMast));
            notifyUtils.notify("task", 1, String.valueOf(wrkMast.getWrkNo()), wrkMast.getWmsWrkNo(), NotifyMsgType.TASK_CANCEL, JSON.toJSONString(wrkMast));
        }
    }