Commit 3306671d authored by hanbing's avatar hanbing

方案管理-运行计划,特殊日期和星期可同时存在

parent 386ff6e1
package net.wanji.web.service.scheme.impl; package net.wanji.web.service.scheme.impl;
import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
import net.wanji.web.common.exception.WeekException;
import net.wanji.web.dto.CrossIdDTO; import net.wanji.web.dto.CrossIdDTO;
import net.wanji.web.dto.RunningPlanDTO; import net.wanji.web.dto.RunningPlanDTO;
import net.wanji.web.mapper.scheme.CrossPlanMapper; import net.wanji.web.mapper.scheme.CrossPlanMapper;
...@@ -55,8 +54,6 @@ public class RunningPlanServiceImpl implements RunningPlanService { ...@@ -55,8 +54,6 @@ public class RunningPlanServiceImpl implements RunningPlanService {
@Transactional @Transactional
public void saveRunningPlan(RunningPlanDTO runningPlanDTO) throws ParseException { public void saveRunningPlan(RunningPlanDTO runningPlanDTO) throws ParseException {
String crossId = runningPlanDTO.getCrossId(); String crossId = runningPlanDTO.getCrossId();
// 验证特殊日期
checkSpecialDate(runningPlanDTO);
// 清空之前计划 // 清空之前计划
crossPlanMapper.deleteByCrossId(crossId); crossPlanMapper.deleteByCrossId(crossId);
crossSectionMapper.deleteByCrossId(crossId); crossSectionMapper.deleteByCrossId(crossId);
...@@ -167,15 +164,16 @@ public class RunningPlanServiceImpl implements RunningPlanService { ...@@ -167,15 +164,16 @@ public class RunningPlanServiceImpl implements RunningPlanService {
private void updateCrossSchedulesPlan(String crossId, RunningPlanDTO.ExecListElement schedulesPlan, private void updateCrossSchedulesPlan(String crossId, RunningPlanDTO.ExecListElement schedulesPlan,
Integer crossSchedulesId, Integer planId) throws ParseException { Integer crossSchedulesId, Integer planId) throws ParseException {
List<Integer> week = schedulesPlan.getWeek(); List<Integer> week = schedulesPlan.getWeek();
if (week == null || week.size() == 0) { // 特殊日期 List<String> specialDateList = schedulesPlan.getSpecialDateList();
List<String> specialDateList = schedulesPlan.getSpecialDateList(); if (CollectionUtil.isNotEmpty(specialDateList)) {
for (String date : specialDateList) { for (String date : specialDateList) {
CrossSchedulesPlanPO crossSchedulesPlanPO = initData(crossId, crossSchedulesId, planId); CrossSchedulesPlanPO crossSchedulesPlanPO = initData(crossId, crossSchedulesId, planId);
crossSchedulesPlanPO.setSpecialDate(sdf.parse(date)); crossSchedulesPlanPO.setSpecialDate(sdf.parse(date));
crossSchedulesPlanPO.setWeek(0); crossSchedulesPlanPO.setWeek(0);
crossSchedulesPlanMapper.insertOne(crossSchedulesPlanPO); crossSchedulesPlanMapper.insertOne(crossSchedulesPlanPO);
} }
} else { }
if (CollectionUtil.isNotEmpty(week)) {
for (Integer day : week) { for (Integer day : week) {
CrossSchedulesPlanPO crossSchedulesPlanPO = initData(crossId, crossSchedulesId, planId); CrossSchedulesPlanPO crossSchedulesPlanPO = initData(crossId, crossSchedulesId, planId);
crossSchedulesPlanPO.setSpecialDate(new Date(0)); crossSchedulesPlanPO.setSpecialDate(new Date(0));
...@@ -232,18 +230,4 @@ public class RunningPlanServiceImpl implements RunningPlanService { ...@@ -232,18 +230,4 @@ public class RunningPlanServiceImpl implements RunningPlanService {
crossSectionPO.setSchemeId(schemeId); crossSectionPO.setSchemeId(schemeId);
crossSectionMapper.insertOne(crossSectionPO); crossSectionMapper.insertOne(crossSectionPO);
} }
private static void checkSpecialDate(RunningPlanDTO runningPlanDTO) {
List<RunningPlanDTO.SchedulesPlanListElement> schedulesPlanList = runningPlanDTO.getSchedulesPlanList();
for (RunningPlanDTO.SchedulesPlanListElement schedulesPlan : schedulesPlanList) {
List<RunningPlanDTO.ExecListElement> execList = schedulesPlan.getExecList();
for (RunningPlanDTO.ExecListElement execListElement : execList) {
List<Integer> week = execListElement.getWeek();
List<String> specialDateList = execListElement.getSpecialDateList();
if (CollectionUtil.isNotEmpty(week) && CollectionUtil.isNotEmpty(specialDateList)) {
throw new WeekException("不能同时有星期选择和日期选择");
}
}
}
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment