|
@@ -1,6 +1,7 @@
|
|
|
package cn.iocoder.yudao.module.iscs.service.sop;
|
|
package cn.iocoder.yudao.module.iscs.service.sop;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+import cn.hutool.core.date.LocalDateTimeUtil;
|
|
|
import cn.hutool.core.lang.Assert;
|
|
import cn.hutool.core.lang.Assert;
|
|
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
|
@@ -15,6 +16,7 @@ import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
|
|
|
|
|
|
|
+import java.time.LocalDateTime;
|
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
|
|
@@ -48,6 +50,7 @@ public class SopExecutionPlanServiceImpl extends ServiceImpl<SopExecutionPlanMap
|
|
|
// 插入
|
|
// 插入
|
|
|
sopExecutionPlanMapper.insert(sopExecutionPlan);
|
|
sopExecutionPlanMapper.insert(sopExecutionPlan);
|
|
|
|
|
|
|
|
|
|
+
|
|
|
// 返回
|
|
// 返回
|
|
|
return sopExecutionPlan.getId();
|
|
return sopExecutionPlan.getId();
|
|
|
}
|
|
}
|
|
@@ -55,6 +58,19 @@ public class SopExecutionPlanServiceImpl extends ServiceImpl<SopExecutionPlanMap
|
|
|
@Override
|
|
@Override
|
|
|
public void updateSopExecutionPlan(SopExecutionPlanSaveReqVO updateReqVO) {
|
|
public void updateSopExecutionPlan(SopExecutionPlanSaveReqVO updateReqVO) {
|
|
|
|
|
|
|
|
|
|
+ // 如果执行频率单位、执行频率、执行时间点修改,则重新设置开始时间
|
|
|
|
|
+ SopExecutionPlanDO byId = getById(updateReqVO.getId());
|
|
|
|
|
+ Assert.isFalse(byId == null, "该sop执行计划不存在,不可修改!");
|
|
|
|
|
+ if (!updateReqVO.getFrequencyUnit().equals(byId.getFrequencyUnit()) ||
|
|
|
|
|
+ !updateReqVO.getFrequency().equals(byId.getFrequency()) ||
|
|
|
|
|
+ !updateReqVO.getTimePoint().equals(byId.getTimePoint())) {
|
|
|
|
|
+ // 改动了计划的实质性内容,需要直接修改计划的开始时间
|
|
|
|
|
+ updateReqVO.setCreateTime(LocalDateTime.now());
|
|
|
|
|
+ // 获取新的书简周期
|
|
|
|
|
+ List<String> previewDateList = getPreviewDateList(updateReqVO.getEffectiveTime(), updateReqVO.getFrequencyUnit(), updateReqVO.getFrequency(), updateReqVO.getTimePoint());
|
|
|
|
|
+ updateReqVO.setNextExecutDate(previewDateList.isEmpty() ? "" : previewDateList.get(0));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
// 如果永不截至
|
|
// 如果永不截至
|
|
|
if (StringUtils.isBlank(updateReqVO.getEndType()) || "1".equals(updateReqVO.getEndType())) {
|
|
if (StringUtils.isBlank(updateReqVO.getEndType()) || "1".equals(updateReqVO.getEndType())) {
|
|
|
updateReqVO.setEndValue("9999-12-31");
|
|
updateReqVO.setEndValue("9999-12-31");
|
|
@@ -65,6 +81,58 @@ public class SopExecutionPlanServiceImpl extends ServiceImpl<SopExecutionPlanMap
|
|
|
sopExecutionPlanMapper.updateById(updateObj);
|
|
sopExecutionPlanMapper.updateById(updateObj);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ private List<String> getPreviewDateList(String effectiveTime, Integer frequencyUnit, Integer frequency, String timePoint) {
|
|
|
|
|
+ ArrayList<String> strings = new ArrayList<>();
|
|
|
|
|
+ // 年
|
|
|
|
|
+ if (frequencyUnit.equals(0)) {
|
|
|
|
|
+ // 处理年的数据
|
|
|
|
|
+ String yyyymmdd = StringUtils.isBlank(effectiveTime) ? SuperDateUtils.getYYYYMMDD() : effectiveTime;
|
|
|
|
|
+ List<String> adjacentDatesYearDay = SuperDateUtils.getAdjacentDatesYearDay(
|
|
|
|
|
+ yyyymmdd,
|
|
|
|
|
+ null,
|
|
|
|
|
+ frequency,
|
|
|
|
|
+ Integer.parseInt(timePoint),
|
|
|
|
|
+ 10);
|
|
|
|
|
+ strings.addAll(adjacentDatesYearDay);
|
|
|
|
|
+ }
|
|
|
|
|
+ // 月
|
|
|
|
|
+ if (frequencyUnit.equals(1)) {
|
|
|
|
|
+ // 处理月的数据
|
|
|
|
|
+ String yyyymmdd = StringUtils.isBlank(effectiveTime) ? SuperDateUtils.getYYYYMMDD() : effectiveTime;
|
|
|
|
|
+ List<String> adjacentDatesMonthDay = SuperDateUtils.getAdjacentDatesMonthDay(
|
|
|
|
|
+ yyyymmdd,
|
|
|
|
|
+ null,
|
|
|
|
|
+ frequency,
|
|
|
|
|
+ Integer.parseInt(timePoint),
|
|
|
|
|
+ 10);
|
|
|
|
|
+ strings.addAll(adjacentDatesMonthDay);
|
|
|
|
|
+ }
|
|
|
|
|
+ // 周
|
|
|
|
|
+ if (frequencyUnit.equals(2)) {
|
|
|
|
|
+ // 处理周的数据
|
|
|
|
|
+ String yyyymmdd = StringUtils.isBlank(effectiveTime) ? SuperDateUtils.getYYYYMMDD() : effectiveTime;
|
|
|
|
|
+ List<String> adjacentDatesByWeekday = SuperDateUtils.getAdjacentDatesByWeekday(
|
|
|
|
|
+ yyyymmdd,
|
|
|
|
|
+ null,
|
|
|
|
|
+ frequency,
|
|
|
|
|
+ timePoint,
|
|
|
|
|
+ 10);
|
|
|
|
|
+ strings.addAll(adjacentDatesByWeekday);
|
|
|
|
|
+ }
|
|
|
|
|
+ // 天
|
|
|
|
|
+ if (frequencyUnit.equals(3)) {
|
|
|
|
|
+ // 处理天的数据
|
|
|
|
|
+ String yyyymmdd = StringUtils.isBlank(effectiveTime) ? SuperDateUtils.getYYYYMMDD() : effectiveTime;
|
|
|
|
|
+ List<String> adjacentDatesByDay = SuperDateUtils.getAdjacentDatesByDay(
|
|
|
|
|
+ yyyymmdd,
|
|
|
|
|
+ null,
|
|
|
|
|
+ frequency,
|
|
|
|
|
+ 10);
|
|
|
|
|
+ strings.addAll(adjacentDatesByDay);
|
|
|
|
|
+ }
|
|
|
|
|
+ return strings;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
public void deleteSopExecutionPlan(Long id) {
|
|
public void deleteSopExecutionPlan(Long id) {
|
|
|
// 删除
|
|
// 删除
|
|
@@ -175,6 +243,9 @@ public class SopExecutionPlanServiceImpl extends ServiceImpl<SopExecutionPlanMap
|
|
|
return bean;
|
|
return bean;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
public SopExecutionPlanRespVO selectSopExecutionPlanBySopId(Long sopId) {
|
|
public SopExecutionPlanRespVO selectSopExecutionPlanBySopId(Long sopId) {
|
|
|
SopExecutionPlanDO sopExecutionPlanDO = getOne(Wrappers.<SopExecutionPlanDO>lambdaQuery()
|
|
SopExecutionPlanDO sopExecutionPlanDO = getOne(Wrappers.<SopExecutionPlanDO>lambdaQuery()
|