|
@@ -8,6 +8,7 @@ import cn.iocoder.yudao.module.iscs.controller.admin.sop.vo.*;
|
|
|
import cn.iocoder.yudao.module.iscs.dal.dataobject.sop.SopDO;
|
|
import cn.iocoder.yudao.module.iscs.dal.dataobject.sop.SopDO;
|
|
|
import cn.iocoder.yudao.module.iscs.dal.dataobject.sop.SopExecutionPlanDO;
|
|
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.dal.mysql.sop.SopExecutionPlanMapper;
|
|
|
|
|
+import cn.iocoder.yudao.module.iscs.service.holiday.HolidayService;
|
|
|
import cn.iocoder.yudao.module.iscs.utils.SuperDateUtils;
|
|
import cn.iocoder.yudao.module.iscs.utils.SuperDateUtils;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
@@ -33,6 +34,8 @@ public class SopExecutionPlanServiceImpl extends ServiceImpl<SopExecutionPlanMap
|
|
|
private SopExecutionPlanMapper sopExecutionPlanMapper;
|
|
private SopExecutionPlanMapper sopExecutionPlanMapper;
|
|
|
@Resource
|
|
@Resource
|
|
|
private SopService sopService;
|
|
private SopService sopService;
|
|
|
|
|
+ @Resource
|
|
|
|
|
+ private HolidayService holidayService;
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public Long createSopExecutionPlan(SopExecutionPlanSaveReqVO createReqVO) {
|
|
public Long createSopExecutionPlan(SopExecutionPlanSaveReqVO createReqVO) {
|
|
@@ -151,9 +154,10 @@ public class SopExecutionPlanServiceImpl extends ServiceImpl<SopExecutionPlanMap
|
|
|
public SopExecutionPlanRespVO getSopExecutionPlan(Long id) {
|
|
public SopExecutionPlanRespVO getSopExecutionPlan(Long id) {
|
|
|
SopExecutionPlanDO sopExecutionPlanDO = sopExecutionPlanMapper.selectById(id);
|
|
SopExecutionPlanDO sopExecutionPlanDO = sopExecutionPlanMapper.selectById(id);
|
|
|
SopExecutionPlanRespVO bean = BeanUtils.toBean(sopExecutionPlanDO, SopExecutionPlanRespVO.class);
|
|
SopExecutionPlanRespVO bean = BeanUtils.toBean(sopExecutionPlanDO, SopExecutionPlanRespVO.class);
|
|
|
- // sop数据
|
|
|
|
|
|
|
+ // 1.sop数据
|
|
|
SopRespVO sopDetailById = sopService.getSopDetailById(bean.getSopId());
|
|
SopRespVO sopDetailById = sopService.getSopDetailById(bean.getSopId());
|
|
|
ArrayList<SopPreviewDataVO> sopRespVOS = new ArrayList<>();
|
|
ArrayList<SopPreviewDataVO> sopRespVOS = new ArrayList<>();
|
|
|
|
|
+ // 2.准备参数,获取执行日期
|
|
|
Integer count = 10;
|
|
Integer count = 10;
|
|
|
String endDateStr = "9999-12-31";
|
|
String endDateStr = "9999-12-31";
|
|
|
if (StringUtils.isNotBlank(bean.getEndType()) && (bean.getEndType().equals("0") || bean.getEndType().equals("1"))) {
|
|
if (StringUtils.isNotBlank(bean.getEndType()) && (bean.getEndType().equals("0") || bean.getEndType().equals("1"))) {
|
|
@@ -162,86 +166,60 @@ public class SopExecutionPlanServiceImpl extends ServiceImpl<SopExecutionPlanMap
|
|
|
endDateStr = bean.getEndValue();
|
|
endDateStr = bean.getEndValue();
|
|
|
}
|
|
}
|
|
|
if (StringUtils.isNotBlank(bean.getEndType()) && bean.getEndType().equals("2")) {
|
|
if (StringUtils.isNotBlank(bean.getEndType()) && bean.getEndType().equals("2")) {
|
|
|
- // 如果是时间截至和永不截至
|
|
|
|
|
|
|
+ // 如果是次数截至
|
|
|
count = Integer.valueOf(bean.getEndValue());
|
|
count = Integer.valueOf(bean.getEndValue());
|
|
|
endDateStr = "9999-12-31";
|
|
endDateStr = "9999-12-31";
|
|
|
}
|
|
}
|
|
|
|
|
+ // 计算的有效的时间
|
|
|
|
|
+ List<String> days = new ArrayList<>();
|
|
|
// 年
|
|
// 年
|
|
|
if (bean.getFrequencyUnit().equals(0)) {
|
|
if (bean.getFrequencyUnit().equals(0)) {
|
|
|
// 处理年的数据
|
|
// 处理年的数据
|
|
|
String yyyymmdd = SuperDateUtils.getYYYYMMDD();
|
|
String yyyymmdd = SuperDateUtils.getYYYYMMDD();
|
|
|
- List<String> adjacentDatesYearDay = SuperDateUtils.getAdjacentDatesYearDay(
|
|
|
|
|
|
|
+ days = SuperDateUtils.getAdjacentDatesYearDay(
|
|
|
yyyymmdd,
|
|
yyyymmdd,
|
|
|
endDateStr,
|
|
endDateStr,
|
|
|
bean.getFrequency(),
|
|
bean.getFrequency(),
|
|
|
Integer.parseInt(bean.getTimePoint()),
|
|
Integer.parseInt(bean.getTimePoint()),
|
|
|
count);
|
|
count);
|
|
|
- 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)) {
|
|
if (bean.getFrequencyUnit().equals(1)) {
|
|
|
// 处理月的数据
|
|
// 处理月的数据
|
|
|
String yyyymmdd = SuperDateUtils.getYYYYMMDD();
|
|
String yyyymmdd = SuperDateUtils.getYYYYMMDD();
|
|
|
- List<String> adjacentDatesMonthDay = SuperDateUtils.getAdjacentDatesMonthDay(
|
|
|
|
|
|
|
+ days = SuperDateUtils.getAdjacentDatesMonthDay(
|
|
|
yyyymmdd,
|
|
yyyymmdd,
|
|
|
endDateStr,
|
|
endDateStr,
|
|
|
bean.getFrequency(),
|
|
bean.getFrequency(),
|
|
|
Integer.parseInt(bean.getTimePoint()),
|
|
Integer.parseInt(bean.getTimePoint()),
|
|
|
count);
|
|
count);
|
|
|
- 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)) {
|
|
if (bean.getFrequencyUnit().equals(2)) {
|
|
|
// 处理周的数据
|
|
// 处理周的数据
|
|
|
String yyyymmdd = SuperDateUtils.getYYYYMMDD();
|
|
String yyyymmdd = SuperDateUtils.getYYYYMMDD();
|
|
|
- List<String> adjacentDatesByWeekday = SuperDateUtils.getAdjacentDatesByWeekday(
|
|
|
|
|
|
|
+ days = SuperDateUtils.getAdjacentDatesByWeekday(
|
|
|
yyyymmdd,
|
|
yyyymmdd,
|
|
|
endDateStr,
|
|
endDateStr,
|
|
|
bean.getFrequency(),
|
|
bean.getFrequency(),
|
|
|
bean.getTimePoint(),
|
|
bean.getTimePoint(),
|
|
|
count);
|
|
count);
|
|
|
- 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)) {
|
|
if (bean.getFrequencyUnit().equals(3)) {
|
|
|
// 处理天的数据
|
|
// 处理天的数据
|
|
|
String yyyymmdd = SuperDateUtils.getYYYYMMDD();
|
|
String yyyymmdd = SuperDateUtils.getYYYYMMDD();
|
|
|
- List<String> adjacentDatesByDay = SuperDateUtils.getAdjacentDatesByDay(
|
|
|
|
|
|
|
+ days = SuperDateUtils.getAdjacentDatesByDay(
|
|
|
yyyymmdd,
|
|
yyyymmdd,
|
|
|
endDateStr,
|
|
endDateStr,
|
|
|
bean.getFrequency(),
|
|
bean.getFrequency(),
|
|
|
count);
|
|
count);
|
|
|
- for (String s : adjacentDatesByDay) {
|
|
|
|
|
|
|
+ }
|
|
|
|
|
+ // 3.去除日历里面安排的休息日
|
|
|
|
|
+ List<String> workDaysFromDays = holidayService.getWorkDaysFromDays(days);
|
|
|
|
|
+ // 4.获取有效天数的模拟数据
|
|
|
|
|
+ if (!workDaysFromDays.isEmpty()) {
|
|
|
|
|
+ for (String s : workDaysFromDays) {
|
|
|
SopPreviewDataVO sopPreviewDataVO = new SopPreviewDataVO();
|
|
SopPreviewDataVO sopPreviewDataVO = new SopPreviewDataVO();
|
|
|
sopPreviewDataVO.setPlanDay(s);
|
|
sopPreviewDataVO.setPlanDay(s);
|
|
|
sopPreviewDataVO.setStartTime(bean.getStartTime());
|
|
sopPreviewDataVO.setStartTime(bean.getStartTime());
|
|
@@ -251,14 +229,11 @@ public class SopExecutionPlanServiceImpl extends ServiceImpl<SopExecutionPlanMap
|
|
|
sopPreviewDataVO.setSopTypeName(sopDetailById.getSopTypeName());
|
|
sopPreviewDataVO.setSopTypeName(sopDetailById.getSopTypeName());
|
|
|
sopRespVOS.add(sopPreviewDataVO);
|
|
sopRespVOS.add(sopPreviewDataVO);
|
|
|
}
|
|
}
|
|
|
- bean.setPreviewDataList(sopRespVOS);
|
|
|
|
|
}
|
|
}
|
|
|
|
|
+ bean.setPreviewDataList(sopRespVOS);
|
|
|
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()
|