소스 검색

调整作业预览数据bug

车车 3 달 전
부모
커밋
6c68c2c902

+ 2 - 2
yudao-module-iscs/src/main/java/cn/iocoder/yudao/module/iscs/controller/admin/notifyconfig/vo/NotifyConfigPageReqVO.java

@@ -16,8 +16,8 @@ public class NotifyConfigPageReqVO extends PageParam {
     @Schema(description = "sopid")
     private Long sopId;
 
-    @Schema(description = "配置名称", example = "王五")
-    private String name;
+    @Schema(description = "规则", example = "王五")
+    private String rule;
 
     @Schema(description = "通知规则种类(0-计划通知 1-作业通知  2-步骤通知 3-操作通知)", example = "1")
     private Integer type;

+ 7 - 3
yudao-module-iscs/src/main/java/cn/iocoder/yudao/module/iscs/controller/admin/notifyconfig/vo/NotifyConfigRespVO.java

@@ -20,9 +20,13 @@ public class NotifyConfigRespVO {
     @Schema(description = "sopid")
     private Long sopId;
 
-    @Schema(description = "配置名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五")
-    @ExcelProperty("配置名称")
-    private String name;
+    @Schema(description = "规则", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五")
+    @ExcelProperty("规则")
+    private String rule;
+
+    @Schema(description = "规则", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五")
+    @ExcelProperty("规则name")
+    private String ruleName;
 
     @Schema(description = "通知规则种类(0-计划通知 1-作业通知  2-步骤通知 3-操作通知)", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
     @ExcelProperty("通知规则种类(0-计划通知 1-作业通知  2-步骤通知 3-操作通知)")

+ 3 - 3
yudao-module-iscs/src/main/java/cn/iocoder/yudao/module/iscs/controller/admin/notifyconfig/vo/NotifyConfigSaveReqVO.java

@@ -16,9 +16,9 @@ public class NotifyConfigSaveReqVO {
     @NotNull(message = "SOPID不能为空")
     private Long sopId;
 
-    @Schema(description = "配置名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五")
-    @NotEmpty(message = "配置名称不能为空")
-    private String name;
+    @Schema(description = "规则", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五")
+    @NotEmpty(message = "规则")
+    private String rule;
 
     @Schema(description = "通知规则种类(0-计划通知 1-作业通知  2-步骤通知 3-操作通知)", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
     @NotNull(message = "通知规则种类(0-计划通知 1-作业通知  2-步骤通知 3-操作通知)不能为空")

+ 6 - 5
yudao-module-iscs/src/main/java/cn/iocoder/yudao/module/iscs/controller/admin/sop/vo/SopExecutionPlanRespVO.java

@@ -1,11 +1,12 @@
 package cn.iocoder.yudao.module.iscs.controller.admin.sop.vo;
 
+import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
+import com.alibaba.excel.annotation.ExcelProperty;
 import io.swagger.v3.oas.annotations.media.Schema;
-import lombok.*;
-import java.util.*;
-import org.springframework.format.annotation.DateTimeFormat;
+import lombok.Data;
+
 import java.time.LocalDateTime;
-import com.alibaba.excel.annotation.*;
+import java.util.List;
 
 @Schema(description = "管理后台 - SOP计划执行 Response VO")
 @Data
@@ -44,7 +45,7 @@ public class SopExecutionPlanRespVO {
     @ExcelProperty("持续时长(小时)")
     private String duration;
 
-    @Schema(description = "计划终止分类")
+    @Schema(description = "截至方式(0时间 1永不截至 2执行次数)")
     private String endType;
 
     @Schema(description = "计划终止内容")

+ 2 - 2
yudao-module-iscs/src/main/java/cn/iocoder/yudao/module/iscs/dal/dataobject/notifyconfig/NotifyConfigDO.java

@@ -31,9 +31,9 @@ public class NotifyConfigDO extends BaseDO {
      */
     private Long sopId;
     /**
-     * 配置名称
+     * 规则 通知规则种类(0-计划通知 1-作业通知 3-操作通知)时为字典值 / 2-步骤通知 时为数据库对应的isc_sop_workflow_step步骤数据
      */
-    private String name;
+    private String rule;
     /**
      * 通知规则种类(0-计划通知 1-作业通知  2-步骤通知 3-操作通知)
      */

+ 1 - 1
yudao-module-iscs/src/main/java/cn/iocoder/yudao/module/iscs/dal/mysql/notifyconfig/NotifyConfigMapper.java

@@ -23,7 +23,7 @@ public interface NotifyConfigMapper extends BaseMapperX<NotifyConfigDO> {
 
     default PageResult<NotifyConfigDO> selectPage(NotifyConfigPageReqVO reqVO) {
         return selectPage(reqVO, new LambdaQueryWrapperX<NotifyConfigDO>()
-                .likeIfPresent(NotifyConfigDO::getName, reqVO.getName())
+                .likeIfPresent(NotifyConfigDO::getRule, reqVO.getRule())
                 .eqIfPresent(NotifyConfigDO::getType, reqVO.getType())
                 .eqIfPresent(NotifyConfigDO::getNotifyTimeType, reqVO.getNotifyTimeType())
                 .betweenIfPresent(NotifyConfigDO::getNotifyTime, reqVO.getNotifyTime())

+ 9 - 0
yudao-module-iscs/src/main/java/cn/iocoder/yudao/module/iscs/service/notifyconfig/NotifyConfigServiceImpl.java

@@ -7,7 +7,9 @@ import cn.iocoder.yudao.module.iscs.controller.admin.notifyconfig.vo.NotifyConfi
 import cn.iocoder.yudao.module.iscs.controller.admin.notifyconfig.vo.NotifyConfigRespVO;
 import cn.iocoder.yudao.module.iscs.controller.admin.notifyconfig.vo.NotifyConfigSaveReqVO;
 import cn.iocoder.yudao.module.iscs.dal.dataobject.notifyconfig.NotifyConfigDO;
+import cn.iocoder.yudao.module.iscs.dal.dataobject.notifyconfig.NotifyConfigDetailDO;
 import cn.iocoder.yudao.module.iscs.dal.mysql.notifyconfig.NotifyConfigMapper;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import jakarta.annotation.Resource;
@@ -51,7 +53,14 @@ public class NotifyConfigServiceImpl extends ServiceImpl<NotifyConfigMapper, Not
         public void deleteNotifyConfigListByIds(List<Long> ids) {
         // 删除
         notifyConfigMapper.physicalDeleteByIds(ids);
+        // 删除isc_notify_config_detail
+        List<NotifyConfigDetailDO> notifyConfigDetailDOS = notifyConfigDetailService.list(Wrappers.<NotifyConfigDetailDO>lambdaQuery()
+                .eq(NotifyConfigDetailDO::getConfigId, ids));
+        if (!notifyConfigDetailDOS.isEmpty()) {
+            List<Long> idList = notifyConfigDetailDOS.stream().map(NotifyConfigDetailDO::getId).toList();
+            notifyConfigDetailService.deleteNotifyConfigDetailListByIds(idList);
         }
+    }
 
 
     @Override

+ 25 - 104
yudao-module-iscs/src/main/java/cn/iocoder/yudao/module/iscs/service/sop/SopExecutionPlanServiceImpl.java

@@ -88,7 +88,7 @@ public class SopExecutionPlanServiceImpl extends ServiceImpl<SopExecutionPlanMap
             String yyyymmdd = StringUtils.isBlank(effectiveTime) ?  SuperDateUtils.getYYYYMMDD() : effectiveTime;
             List<String> adjacentDatesYearDay = SuperDateUtils.getAdjacentDatesYearDay(
                     yyyymmdd,
-                    null,
+                    "9999-12-31",
                     frequency,
                     Integer.parseInt(timePoint),
                     10);
@@ -100,7 +100,7 @@ public class SopExecutionPlanServiceImpl extends ServiceImpl<SopExecutionPlanMap
             String yyyymmdd = StringUtils.isBlank(effectiveTime) ?  SuperDateUtils.getYYYYMMDD() : effectiveTime;
             List<String> adjacentDatesMonthDay = SuperDateUtils.getAdjacentDatesMonthDay(
                     yyyymmdd,
-                    null,
+                    "9999-12-31",
                     frequency,
                     Integer.parseInt(timePoint),
                     10);
@@ -112,7 +112,7 @@ public class SopExecutionPlanServiceImpl extends ServiceImpl<SopExecutionPlanMap
             String yyyymmdd = StringUtils.isBlank(effectiveTime) ?  SuperDateUtils.getYYYYMMDD() : effectiveTime;
             List<String> adjacentDatesByWeekday = SuperDateUtils.getAdjacentDatesByWeekday(
                     yyyymmdd,
-                    null,
+                    "9999-12-31",
                     frequency,
                     timePoint,
                     10);
@@ -124,7 +124,7 @@ public class SopExecutionPlanServiceImpl extends ServiceImpl<SopExecutionPlanMap
             String yyyymmdd = StringUtils.isBlank(effectiveTime) ?  SuperDateUtils.getYYYYMMDD() : effectiveTime;
             List<String> adjacentDatesByDay = SuperDateUtils.getAdjacentDatesByDay(
                     yyyymmdd,
-                    null,
+                    "9999-12-31",
                     frequency,
                     10);
             strings.addAll(adjacentDatesByDay);
@@ -146,16 +146,28 @@ public class SopExecutionPlanServiceImpl extends ServiceImpl<SopExecutionPlanMap
         // sop数据
         SopRespVO sopDetailById = sopService.getSopDetailById(bean.getSopId());
         ArrayList<SopPreviewDataVO> sopRespVOS = new ArrayList<>();
+        Integer count = 10;
+        String endDateStr = "9999-12-31";
+        if (StringUtils.isNotBlank(bean.getEndType()) && (bean.getEndType().equals("0") || bean.getEndType().equals("1"))) {
+            // 如果是时间截至和永不截至
+            count = 10;
+            endDateStr = bean.getEndValue();
+        }
+        if (StringUtils.isNotBlank(bean.getEndType()) && bean.getEndType().equals("2")) {
+            // 如果是时间截至和永不截至
+            count = Integer.valueOf(bean.getEndValue());
+            endDateStr = "9999-12-31";
+        }
         // 年
         if (bean.getFrequencyUnit().equals(0)) {
             // 处理年的数据
             String yyyymmdd = SuperDateUtils.getYYYYMMDD();
             List<String> adjacentDatesYearDay = SuperDateUtils.getAdjacentDatesYearDay(
                     yyyymmdd,
-                    null,
+                    endDateStr,
                     bean.getFrequency(),
                     Integer.parseInt(bean.getTimePoint()),
-                    10);
+                    count);
             for (String s : adjacentDatesYearDay) {
                 SopPreviewDataVO sopPreviewDataVO = new SopPreviewDataVO();
                 sopPreviewDataVO.setPlanDay(s);
@@ -174,10 +186,10 @@ public class SopExecutionPlanServiceImpl extends ServiceImpl<SopExecutionPlanMap
             String yyyymmdd = SuperDateUtils.getYYYYMMDD();
             List<String> adjacentDatesMonthDay = SuperDateUtils.getAdjacentDatesMonthDay(
                     yyyymmdd,
-                    null,
+                    endDateStr,
                     bean.getFrequency(),
                     Integer.parseInt(bean.getTimePoint()),
-                    10);
+                    count);
             for (String s : adjacentDatesMonthDay) {
                 SopPreviewDataVO sopPreviewDataVO = new SopPreviewDataVO();
                 sopPreviewDataVO.setPlanDay(s);
@@ -196,10 +208,10 @@ public class SopExecutionPlanServiceImpl extends ServiceImpl<SopExecutionPlanMap
             String yyyymmdd = SuperDateUtils.getYYYYMMDD();
             List<String> adjacentDatesByWeekday = SuperDateUtils.getAdjacentDatesByWeekday(
                     yyyymmdd,
-                    null,
+                    endDateStr,
                     bean.getFrequency(),
                     bean.getTimePoint(),
-                    10);
+                    count);
             for (String s : adjacentDatesByWeekday) {
                 SopPreviewDataVO sopPreviewDataVO = new SopPreviewDataVO();
                 sopPreviewDataVO.setPlanDay(s);
@@ -218,9 +230,9 @@ public class SopExecutionPlanServiceImpl extends ServiceImpl<SopExecutionPlanMap
             String yyyymmdd = SuperDateUtils.getYYYYMMDD();
             List<String> adjacentDatesByDay = SuperDateUtils.getAdjacentDatesByDay(
                     yyyymmdd,
-                    null,
+                    endDateStr,
                     bean.getFrequency(),
-                    10);
+                    count);
             for (String s : adjacentDatesByDay) {
                 SopPreviewDataVO sopPreviewDataVO = new SopPreviewDataVO();
                 sopPreviewDataVO.setPlanDay(s);
@@ -248,98 +260,7 @@ public class SopExecutionPlanServiceImpl extends ServiceImpl<SopExecutionPlanMap
         if (sopExecutionPlanDO == null) {
             return null;
         }
-        SopExecutionPlanRespVO bean = BeanUtils.toBean(sopExecutionPlanDO, SopExecutionPlanRespVO.class);
-        // sop数据
-        SopRespVO sopDetailById = sopService.getSopDetailById(bean.getSopId());
-        ArrayList<SopPreviewDataVO> sopRespVOS = new ArrayList<>();
-        // 年
-        if (bean.getFrequencyUnit().equals(0)) {
-            // 处理年的数据
-            String yyyymmdd = SuperDateUtils.getYYYYMMDD();
-            List<String> adjacentDatesYearDay = SuperDateUtils.getAdjacentDatesYearDay(
-                    yyyymmdd,
-                    sopExecutionPlanDO.getEndValue(),
-                    bean.getFrequency(),
-                    Integer.parseInt(bean.getTimePoint()),
-                    10);
-            for (String s : adjacentDatesYearDay) {
-                SopPreviewDataVO sopPreviewDataVO = new SopPreviewDataVO();
-                sopPreviewDataVO.setPlanDay(s);
-                sopPreviewDataVO.setStartTime(bean.getStartTime());
-                sopPreviewDataVO.setDuration(bean.getDuration());
-                sopPreviewDataVO.setWorkstationName(sopDetailById.getWorkstationName());
-                sopPreviewDataVO.setMachineryName(sopDetailById.getMachineryName());
-                sopPreviewDataVO.setSopTypeName(sopDetailById.getSopTypeName());
-                sopRespVOS.add(sopPreviewDataVO);
-            }
-            bean.setPreviewDataList(sopRespVOS);
-        }
-        // 月
-        if (bean.getFrequencyUnit().equals(1)) {
-            // 处理月的数据
-            String yyyymmdd = SuperDateUtils.getYYYYMMDD();
-            List<String> adjacentDatesMonthDay = SuperDateUtils.getAdjacentDatesMonthDay(
-                    yyyymmdd,
-                    sopExecutionPlanDO.getEndValue(),
-                    bean.getFrequency(),
-                    Integer.parseInt(bean.getTimePoint()),
-                    10);
-            for (String s : adjacentDatesMonthDay) {
-                SopPreviewDataVO sopPreviewDataVO = new SopPreviewDataVO();
-                sopPreviewDataVO.setPlanDay(s);
-                sopPreviewDataVO.setStartTime(bean.getStartTime());
-                sopPreviewDataVO.setDuration(bean.getDuration());
-                sopPreviewDataVO.setWorkstationName(sopDetailById.getWorkstationName());
-                sopPreviewDataVO.setMachineryName(sopDetailById.getMachineryName());
-                sopPreviewDataVO.setSopTypeName(sopDetailById.getSopTypeName());
-                sopRespVOS.add(sopPreviewDataVO);
-            }
-            bean.setPreviewDataList(sopRespVOS);
-        }
-        // 周
-        if (bean.getFrequencyUnit().equals(2)) {
-            // 处理周的数据
-            String yyyymmdd = SuperDateUtils.getYYYYMMDD();
-            List<String> adjacentDatesByWeekday = SuperDateUtils.getAdjacentDatesByWeekday(
-                    yyyymmdd,
-                    bean.getEndValue(),
-                    bean.getFrequency(),
-                    bean.getTimePoint(),
-                    10);
-            for (String s : adjacentDatesByWeekday) {
-                SopPreviewDataVO sopPreviewDataVO = new SopPreviewDataVO();
-                sopPreviewDataVO.setPlanDay(s);
-                sopPreviewDataVO.setStartTime(bean.getStartTime());
-                sopPreviewDataVO.setDuration(bean.getDuration());
-                sopPreviewDataVO.setWorkstationName(sopDetailById.getWorkstationName());
-                sopPreviewDataVO.setMachineryName(sopDetailById.getMachineryName());
-                sopPreviewDataVO.setSopTypeName(sopDetailById.getSopTypeName());
-                sopRespVOS.add(sopPreviewDataVO);
-            }
-            bean.setPreviewDataList(sopRespVOS);
-        }
-        // 天
-        if (bean.getFrequencyUnit().equals(3)) {
-            // 处理天的数据
-            String yyyymmdd = SuperDateUtils.getYYYYMMDD();
-            List<String> adjacentDatesByDay = SuperDateUtils.getAdjacentDatesByDay(
-                    yyyymmdd,
-                    sopExecutionPlanDO.getEndValue(),
-                    bean.getFrequency(),
-                    10);
-            for (String s : adjacentDatesByDay) {
-                SopPreviewDataVO sopPreviewDataVO = new SopPreviewDataVO();
-                sopPreviewDataVO.setPlanDay(s);
-                sopPreviewDataVO.setStartTime(bean.getStartTime());
-                sopPreviewDataVO.setDuration(bean.getDuration());
-                sopPreviewDataVO.setWorkstationName(sopDetailById.getWorkstationName());
-                sopPreviewDataVO.setMachineryName(sopDetailById.getMachineryName());
-                sopPreviewDataVO.setSopTypeName(sopDetailById.getSopTypeName());
-                sopRespVOS.add(sopPreviewDataVO);
-            }
-            bean.setPreviewDataList(sopRespVOS);
-        }
-        return bean;
+        return getSopExecutionPlan(sopExecutionPlanDO.getId());
     }
 
     @Override

+ 12 - 0
yudao-module-iscs/src/main/java/cn/iocoder/yudao/module/iscs/service/sop/SopServiceImpl.java

@@ -6,11 +6,13 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult;
 import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
 import cn.iocoder.yudao.module.iscs.controller.admin.sop.vo.*;
 import cn.iocoder.yudao.module.iscs.dal.dataobject.machinerypoints.MachineryPointsDO;
+import cn.iocoder.yudao.module.iscs.dal.dataobject.notifyconfig.NotifyConfigDO;
 import cn.iocoder.yudao.module.iscs.dal.dataobject.sop.*;
 import cn.iocoder.yudao.module.iscs.dal.dataobject.workflow.WorkflowModeDO;
 import cn.iocoder.yudao.module.iscs.dal.dataobject.workflow.WorkflowStepDO;
 import cn.iocoder.yudao.module.iscs.dal.mysql.sop.SopMapper;
 import cn.iocoder.yudao.module.iscs.service.machinerypoints.MachineryPointsService;
+import cn.iocoder.yudao.module.iscs.service.notifyconfig.NotifyConfigService;
 import cn.iocoder.yudao.module.iscs.service.workflow.WorkflowModeService;
 import cn.iocoder.yudao.module.iscs.service.workflow.WorkflowStepService;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
@@ -57,6 +59,9 @@ public class SopServiceImpl extends ServiceImpl<SopMapper, SopDO> implements Sop
     @Lazy
     @Resource
     private SopExecutionPlanService sopExecutionPlanService;
+    @Lazy
+    @Resource
+    private NotifyConfigService notifyConfigService;
 
     @Transactional
     @Override
@@ -253,6 +258,13 @@ public class SopServiceImpl extends ServiceImpl<SopMapper, SopDO> implements Sop
                 List<Long> idList = sopExecutionPlanDOList.stream().map(SopExecutionPlanDO::getId).toList();
                 sopExecutionPlanService.deleteSopExecutionPlanListByIds(idList);
             }
+            // 删除isc_notify_config
+            List<NotifyConfigDO> notifyConfigDOS = notifyConfigService.list(Wrappers.<NotifyConfigDO>lambdaQuery()
+                    .in(NotifyConfigDO::getSopId, ids));
+            if (!notifyConfigDOS.isEmpty()) {
+                List<Long> idList = notifyConfigDOS.stream().map(NotifyConfigDO::getId).toList();
+                notifyConfigService.deleteNotifyConfigListByIds(idList);
+            }
         }
     }
 

+ 11 - 5
yudao-module-iscs/src/main/resources/mapper/NotifyConfigMapper.xml

@@ -12,11 +12,17 @@
     <select id="getNotifyConfigPage"
             resultType="cn.iocoder.yudao.module.iscs.controller.admin.notifyconfig.vo.NotifyConfigRespVO">
         SELECT
-            n.*,
-            w.workstation_name
+        n.*,
+        w.workstation_name,
+        ws.step_title as rule_name
         FROM
-            isc_notify_config n
-                LEFT JOIN isc_workstation w ON w.id = n.workstation_id
-
+        isc_notify_config n
+        LEFT JOIN isc_workstation w ON w.id = n.workstation_id
+        LEFT JOIN isc_sop_workflow_step ws ON ws.id = n.rule and n.type = 3
+        <where>
+            <if test="vo.nextExecutDate != null and vo.nextExecutDate.trim != ''">
+                n.sop_id #{vo.sopId}
+            </if>
+        </where>
     </select>
 </mapper>