#
Junjie
2025-02-12 02225bd46c3c4f0d2122c26973f84bbe914eb94d
src/main/java/com/zy/asrs/task/WrkMastScheduler.java
@@ -1,12 +1,20 @@
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;
import com.zy.asrs.entity.WrkMast;
import com.zy.asrs.service.LocMastService;
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.SlaveType;
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;
@@ -27,6 +35,8 @@
    private WrkMastLogService wrkMastLogService;
    @Autowired
    private LocMastService locMastService;
    @Autowired
    private NotifyUtils notifyUtils;
    @Scheduled(cron = "0/1 * * * * ? ")
    @Transactional
@@ -65,6 +75,9 @@
            if (!wrkMastService.deleteById(wrkMast)) {
                log.info("删除工作主档[workNo={}]失败", wrkMast.getWrkNo());
            }
            //上报
            notifyUtils.notify("task", 1, String.valueOf(wrkMast.getWrkNo()), NotifyMsgType.TASK_COMPLETE, JSON.toJSONString(wrkMast));
        }
    }
@@ -105,6 +118,9 @@
            if (!wrkMastService.deleteById(wrkMast)) {
                log.info("删除工作主档[workNo={}]失败", wrkMast.getWrkNo());
            }
            //上报
            notifyUtils.notify("task", 1, String.valueOf(wrkMast.getWrkNo()), NotifyMsgType.TASK_COMPLETE, JSON.toJSONString(wrkMast));
        }
    }
@@ -165,6 +181,9 @@
            if (!wrkMastService.deleteById(wrkMast)) {
                log.info("删除工作主档[workNo={}]失败", wrkMast.getWrkNo());
            }
            //上报
            notifyUtils.notify("task", 1, String.valueOf(wrkMast.getWrkNo()), NotifyMsgType.TASK_COMPLETE, JSON.toJSONString(wrkMast));
        }
    }
@@ -205,6 +224,32 @@
            if (!wrkMastService.deleteById(wrkMast)) {
                log.info("删除工作主档[workNo={}]失败", wrkMast.getWrkNo());
            }
            //上报
            notifyUtils.notify("task", 1, String.valueOf(wrkMast.getWrkNo()), NotifyMsgType.TASK_CHARGE_COMPLETE, JSON.toJSONString(wrkMast));
        }
    }
    @Scheduled(cron = "0/1 * * * * ? ")
    @Transactional
    public void executeCancelTask(){
        List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>().eq("mk", "taskCancel"));
        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_CANCEL, JSON.toJSONString(wrkMast));
        }
    }