|
|
@@ -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;
|
|
|
}
|
|
|
|