瀏覽代碼

新增修改

小车车 3 月之前
父節點
當前提交
3dc3439c94

+ 4 - 1
yudao-module-iscs/src/main/java/cn/iocoder/yudao/module/iscs/controller/admin/sop/vo/SopExecutionPlanSaveReqVO.java

@@ -31,12 +31,15 @@ public class SopExecutionPlanSaveReqVO {
     @NotNull(message = "实行日期点(第30天 / 周一)不能为空")
     private String timePoint;
 
-    @Schema(description = "计划终止分类")
+    @Schema(description = "计划终止分类(0时间 1永不截至 2执行次数)")
     private String endType;
 
     @Schema(description = "计划终止内容")
     private String endValue;
 
+    @Schema(description = "计划开始时间")
+    private String startTime;
+
     @Schema(description = "持续时长(小时)")
     private String duration;
 

+ 1 - 1
yudao-module-iscs/src/main/java/cn/iocoder/yudao/module/iscs/dal/dataobject/sop/SopExecutionPlanDO.java

@@ -55,7 +55,7 @@ public class SopExecutionPlanDO extends BaseDO {
      */
     private String duration;
     /**
-     * 计划终止分类
+     * 截至方式(0时间 1永不截至 2执行次数)
      */
     private String endType;
     /**

+ 17 - 1
yudao-module-iscs/src/main/java/cn/iocoder/yudao/module/iscs/service/sop/SopExecutionPlanServiceImpl.java

@@ -11,6 +11,7 @@ import cn.iocoder.yudao.module.iscs.utils.SuperDateUtils;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import jakarta.annotation.Resource;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.stereotype.Service;
 import org.springframework.validation.annotation.Validated;
 
@@ -33,9 +34,18 @@ public class SopExecutionPlanServiceImpl extends ServiceImpl<SopExecutionPlanMap
 
     @Override
     public Long createSopExecutionPlan(SopExecutionPlanSaveReqVO createReqVO) {
+        Assert.notNull(createReqVO.getSopId(), "sopid不可为空!");
+        // 检测如果这个sop已经有了,就不能再有
+        SopExecutionPlanDO sopExecutionPlanDO = getOne(Wrappers.<SopExecutionPlanDO>lambdaQuery()
+                .eq(SopExecutionPlanDO::getSopId, createReqVO.getSopId()));
+        Assert.isFalse(sopExecutionPlanDO != null, "该sop已存在计划!");
 
-        // 插入
         SopExecutionPlanDO sopExecutionPlan = BeanUtils.toBean(createReqVO, SopExecutionPlanDO.class);
+        // 如果永不截至
+        if (StringUtils.isBlank(createReqVO.getEndType()) || "1".equals(createReqVO.getEndType())) {
+            sopExecutionPlan.setEndValue("9999-12-31");
+        }
+        // 插入
         sopExecutionPlanMapper.insert(sopExecutionPlan);
 
         // 返回
@@ -44,6 +54,12 @@ public class SopExecutionPlanServiceImpl extends ServiceImpl<SopExecutionPlanMap
 
     @Override
     public void updateSopExecutionPlan(SopExecutionPlanSaveReqVO updateReqVO) {
+
+        // 如果永不截至
+        if (StringUtils.isBlank(updateReqVO.getEndType()) || "1".equals(updateReqVO.getEndType())) {
+            updateReqVO.setEndValue("9999-12-31");
+        }
+
         // 更新
         SopExecutionPlanDO updateObj = BeanUtils.toBean(updateReqVO, SopExecutionPlanDO.class);
         sopExecutionPlanMapper.updateById(updateObj);