Quellcode durchsuchen

预览数据生成

小车车 vor 3 Monaten
Ursprung
Commit
a7a9e4d31e

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

@@ -26,7 +26,7 @@ public class SopExecutionPlanPageReqVO extends PageParam {
     private Integer frequency;
 
     @Schema(description = "实行日期点(第30天 / 周一)")
-    private Integer timePoint;
+    private String timePoint;
 
     @Schema(description = "开始时间节点")
     private String startTime;

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

@@ -34,7 +34,7 @@ public class SopExecutionPlanRespVO {
 
     @Schema(description = "实行日期点(第30天 / 周一)", requiredMode = Schema.RequiredMode.REQUIRED)
     @ExcelProperty("实行日期点(第30天 / 周一)")
-    private Integer timePoint;
+    private String timePoint;
 
     @Schema(description = "开始时间节点")
     @ExcelProperty("开始时间节点")
@@ -66,4 +66,7 @@ public class SopExecutionPlanRespVO {
     @ExcelProperty("创建时间")
     private LocalDateTime createTime;
 
+    @Schema(description = "预览数据")
+    private List<SopPreviewDataVO> previewDataList;
+
 }

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

@@ -32,7 +32,7 @@ public class SopExecutionPlanSaveReqVO {
 
     @Schema(description = "实行日期点(第30天 / 周一)", requiredMode = Schema.RequiredMode.REQUIRED)
     @NotNull(message = "实行日期点(第30天 / 周一)不能为空")
-    private Integer timePoint;
+    private String timePoint;
 
     @Schema(description = "计划终止分类")
     private String endType;

+ 34 - 0
yudao-module-iscs/src/main/java/cn/iocoder/yudao/module/iscs/controller/admin/sop/vo/SopPreviewDataVO.java

@@ -0,0 +1,34 @@
+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.Data;
+
+import java.time.LocalDateTime;
+
+@Schema(description = "管理后台 - SOP计划执行 Response VO")
+@Data
+@ExcelIgnoreUnannotated
+public class SopPreviewDataVO {
+
+    @Schema(description = "计划时间")
+    private String planDay;
+
+    @Schema(description = "计划开始时间")
+    private String startTime;
+
+    @Schema(description = "持续时长(小时)")
+    private String duration;
+
+    @Schema(description = "所属区域")
+    private String workstationName;
+
+    @Schema(description = "设备/工艺")
+    private String machineryName;
+
+    @Schema(description = "sop类型")
+    private String sopTypeName;
+
+
+}

+ 4 - 0
yudao-module-iscs/src/main/java/cn/iocoder/yudao/module/iscs/controller/admin/workflow/vo/WorkflowStepExportVO.java

@@ -4,9 +4,12 @@ import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
 import com.alibaba.excel.annotation.ExcelProperty;
 import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.Data;
+import org.springframework.format.annotation.DateTimeFormat;
 
 import java.time.LocalDateTime;
 
+import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
+
 @Schema(description = "管理后台 - 工作流步骤 Response VO")
 @Data
 @ExcelIgnoreUnannotated
@@ -105,6 +108,7 @@ public class WorkflowStepExportVO {
 
     @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
     @ExcelProperty("创建时间")
+    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
     private LocalDateTime createTime;
 
 }

+ 3 - 0
yudao-module-iscs/src/main/java/cn/iocoder/yudao/module/iscs/dal/mysql/sop/SopMapper.java

@@ -10,6 +10,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import org.apache.ibatis.annotations.Delete;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
+import org.springframework.security.core.parameters.P;
 
 import java.util.List;
 
@@ -51,4 +52,6 @@ public interface SopMapper extends BaseMapperX<SopDO> {
     })
     Boolean physicalDeleteByIds(@Param(value = "ids") List<Long> ids);
 
+    SopRespVO getSopDetailById(@Param(value = "id") Long id);
+
 }

+ 86 - 5
yudao-module-iscs/src/main/java/cn/iocoder/yudao/module/iscs/service/sop/SopExecutionPlanServiceImpl.java

@@ -4,18 +4,19 @@ package cn.iocoder.yudao.module.iscs.service.sop;
 import cn.hutool.core.date.DateUtil;
 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.SopExecutionPlanPageReqVO;
-import cn.iocoder.yudao.module.iscs.controller.admin.sop.vo.SopExecutionPlanRespVO;
-import cn.iocoder.yudao.module.iscs.controller.admin.sop.vo.SopExecutionPlanSaveReqVO;
+import cn.iocoder.yudao.module.iscs.controller.admin.sop.vo.*;
 import cn.iocoder.yudao.module.iscs.dal.dataobject.sop.SopExecutionPlanDO;
 import cn.iocoder.yudao.module.iscs.dal.mysql.sop.SopExecutionPlanMapper;
 import cn.iocoder.yudao.module.iscs.utils.SuperDateUtils;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import jakarta.annotation.Resource;
+import org.checkerframework.checker.units.qual.A;
 import org.springframework.stereotype.Service;
 import org.springframework.validation.annotation.Validated;
 
 import javax.xml.crypto.Data;
+import java.time.LocalDate;
+import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
 
@@ -30,6 +31,8 @@ public class SopExecutionPlanServiceImpl extends ServiceImpl<SopExecutionPlanMap
 
     @Resource
     private SopExecutionPlanMapper sopExecutionPlanMapper;
+    @Resource
+    private SopService sopService;
 
     @Override
     public Long createSopExecutionPlan(SopExecutionPlanSaveReqVO createReqVO) {
@@ -66,18 +69,96 @@ public class SopExecutionPlanServiceImpl extends ServiceImpl<SopExecutionPlanMap
     public SopExecutionPlanRespVO getSopExecutionPlan(Long id) {
         SopExecutionPlanDO sopExecutionPlanDO = sopExecutionPlanMapper.selectById(id);
         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,
+                    null,
+                    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,
+                    null,
+                    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,
                     null,
                     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,
+                    null,
+                    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;
     }
 

+ 2 - 0
yudao-module-iscs/src/main/java/cn/iocoder/yudao/module/iscs/service/sop/SopService.java

@@ -59,4 +59,6 @@ public interface SopService extends IService<SopDO> {
 
     void sopEffectiveRules(Long sopId);
 
+    SopRespVO getSopDetailById(Long id);
+
 }

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

@@ -251,4 +251,9 @@ public class SopServiceImpl extends ServiceImpl<SopMapper, SopDO> implements Sop
         }
     }
 
+    @Override
+    public SopRespVO getSopDetailById(Long id) {
+        return sopMapper.getSopDetailById(id);
+    }
+
 }

+ 4 - 4
yudao-module-iscs/src/main/java/cn/iocoder/yudao/module/iscs/utils/SuperDateUtils.java

@@ -351,7 +351,7 @@ public class SuperDateUtils {
 
     /*public static void main(String[] args) {
         // 示例测试:查找2025-07-24之后,每年第250天的日期,最多10个
-        List<String> dates = getAdjacentDatesYearDay("2025-07-24", 2, 206, 10, "2029-07-25");
+        List<String> dates = getAdjacentDatesYearDay("2025-07-24", null, 1, 10, 2);
         System.out.println("结果:" + dates);
         // 预期输出应包含2028-09-07(若250天合法)
     }*/
@@ -371,7 +371,7 @@ public class SuperDateUtils {
      * 生成java帮助类输入开始日期和结束日期,输入频率为月,输入第多少天,输入输出的符合数据个数,输出符合的日期;
      * 如输入开始时间2025-07-24,结束时间2025-12-31,频率为1个月,输入第2日,输入符合数据个数3个,则输出2025-08-02、2025-09-02、2025-10-02;如果输入第31天,如果当前月份没有该日期,则往前推移,2025-07-31,2025-08-31、2025-09-30
      */
-    public static List<LocalDate> getAdjacentDatesMonthDay(String startDateStr, String endDateStr, int frequency, int dayOfMonth, int count) {
+    public static List<String> getAdjacentDatesMonthDay(String startDateStr, String endDateStr, int frequency, int dayOfMonth, int count) {
         LocalDate startDate = LocalDate.parse(startDateStr, YYYYMMDD);
         LocalDate endDate = LocalDate.parse(endDateStr, YYYYMMDD);
 
@@ -382,7 +382,7 @@ public class SuperDateUtils {
             throw new IllegalArgumentException("天数必须大于等于1");
         }
 
-        List<LocalDate> result = new ArrayList<>();
+        List<String> result = new ArrayList<>();
         YearMonth currentMonth = YearMonth.from(startDate);
 
         while (result.size() < count && !currentMonth.isAfter(YearMonth.from(endDate))) {
@@ -394,7 +394,7 @@ public class SuperDateUtils {
 
             // 检查日期是否在有效期内
             if (!candidate.isBefore(startDate) && !candidate.isAfter(endDate)) {
-                result.add(candidate);
+                result.add(candidate.format(YYYYMMDD));
             }
 
             // 增加频率月数

+ 18 - 0
yudao-module-iscs/src/main/resources/mapper/SopMapper.xml

@@ -60,4 +60,22 @@
         GROUP BY s.id
         ORDER BY s.sop_index ASC, s.id DESC
     </select>
+    <select id="getSopDetailById" resultType="cn.iocoder.yudao.module.iscs.controller.admin.sop.vo.SopRespVO">
+        SELECT
+            s.*,
+            wa.workarea_name,
+            w.workstation_name,
+            d.machinery_name,
+            any_value(di.label) as sopTypeName,
+            COUNT( p.id ) AS pointCount
+        FROM
+            isc_sop s
+                LEFT JOIN isc_workarea wa ON wa.id = s.workarea_id
+                LEFT JOIN isc_workstation w ON w.id = s.workstation_id
+                LEFT JOIN system_users u ON u.id = s.creator
+                LEFT JOIN isc_machinery d ON d.id = s.machinery_id
+                LEFT JOIN isc_sop_points p ON p.sop_id = s.id
+                LEFT JOIN system_dict_data di ON di.dict_type = "sop_type" and di.value = s.sop_type
+        where s.id = #{id}
+    </select>
 </mapper>