|
@@ -0,0 +1,65 @@
|
|
|
|
|
+package cn.iocoder.yudao.module.iscs.job;
|
|
|
|
|
+
|
|
|
|
|
+import cn.hutool.core.date.DateUtil;
|
|
|
|
|
+import cn.iocoder.yudao.framework.quartz.core.handler.JobHandler;
|
|
|
|
|
+import cn.iocoder.yudao.framework.tenant.core.aop.TenantIgnore;
|
|
|
|
|
+import cn.iocoder.yudao.module.infra.service.job.JobLogService;
|
|
|
|
|
+import cn.iocoder.yudao.module.iscs.controller.admin.jobticket.vo.JobTicketSaveReqVO;
|
|
|
|
|
+import cn.iocoder.yudao.module.iscs.controller.admin.sop.vo.SopExecutionPlanRespVO;
|
|
|
|
|
+import cn.iocoder.yudao.module.iscs.dal.dataobject.sop.SopDO;
|
|
|
|
|
+import cn.iocoder.yudao.module.iscs.dal.dataobject.sop.SopExecutionPlanDO;
|
|
|
|
|
+import cn.iocoder.yudao.module.iscs.service.jobticket.JobTicketService;
|
|
|
|
|
+import cn.iocoder.yudao.module.iscs.service.sop.SopExecutionPlanService;
|
|
|
|
|
+import cn.iocoder.yudao.module.iscs.service.sop.SopService;
|
|
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
|
|
+import jakarta.annotation.Resource;
|
|
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
|
|
+
|
|
|
|
|
+import java.util.Date;
|
|
|
|
|
+import java.util.List;
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * SOP执行计划任务
|
|
|
|
|
+ *
|
|
|
|
|
+ * @author cgj
|
|
|
|
|
+ */
|
|
|
|
|
+@Slf4j
|
|
|
|
|
+@Component
|
|
|
|
|
+public class SopExecutionPlanJob implements JobHandler {
|
|
|
|
|
+
|
|
|
|
|
+ @Resource
|
|
|
|
|
+ private SopExecutionPlanService sopExecutionPlanService;
|
|
|
|
|
+ @Resource
|
|
|
|
|
+ private SopService sopService;
|
|
|
|
|
+ @Resource
|
|
|
|
|
+ private JobTicketService jobTicketService;
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 查找需要执行的数据,生成作业
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param param 参数
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ @TenantIgnore
|
|
|
|
|
+ public String execute(String param) {
|
|
|
|
|
+ String yyyymmdd = DateUtil.format(new Date(), "yyyy-MM-dd");
|
|
|
|
|
+ SopExecutionPlanRespVO sopExecutionPlanRespVO = new SopExecutionPlanRespVO();
|
|
|
|
|
+ sopExecutionPlanRespVO.setNextExecutDate(yyyymmdd);
|
|
|
|
|
+ List<SopExecutionPlanRespVO> list = sopExecutionPlanService.getList(sopExecutionPlanRespVO);
|
|
|
|
|
+ for (SopExecutionPlanRespVO executionPlanRespVO : list) {
|
|
|
|
|
+ if (executionPlanRespVO.getEnableExecutionPlan() != null && executionPlanRespVO.getEnableExecutionPlan().equals(1)) {
|
|
|
|
|
+ // 开始生成作业
|
|
|
|
|
+ JobTicketSaveReqVO jobTicketSaveReqVO = new JobTicketSaveReqVO();
|
|
|
|
|
+ jobTicketSaveReqVO.setSopId(executionPlanRespVO.getSopId());
|
|
|
|
|
+ jobTicketService.insertJobTicketBySop(jobTicketSaveReqVO);
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return String.format("定时执行清理定时任务日志数量 %s 个", 1);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+}
|