Commit bab761fc authored by hanbing's avatar hanbing

[update] 方案管理-调整时段表更新策略

parent 2f7e915d
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 cn.hutool.core.util.ObjectUtil;
import net.wanji.databus.bo.CrossIdBO; import net.wanji.databus.bo.CrossIdBO;
import net.wanji.databus.dao.entity.*; import net.wanji.databus.dao.entity.*;
import net.wanji.databus.dao.mapper.*; import net.wanji.databus.dao.mapper.*;
...@@ -48,7 +49,7 @@ public class RunningPlanServiceImpl implements RunningPlanService { ...@@ -48,7 +49,7 @@ public class RunningPlanServiceImpl implements RunningPlanService {
String crossId = runningPlanDTO.getCrossId(); String crossId = runningPlanDTO.getCrossId();
// 清空之前计划 // 清空之前计划
baseCrossPlanMapper.deleteByCrossId(crossId); baseCrossPlanMapper.deleteByCrossId(crossId);
baseCrossSectionMapper.deleteByCrossId(crossId); deleteSections(runningPlanDTO);
baseCrossSchedulesMapper.deleteByCrossId(crossId); baseCrossSchedulesMapper.deleteByCrossId(crossId);
baseCrossSchedulesPlanMapper.deleteByCrossId(crossId); baseCrossSchedulesPlanMapper.deleteByCrossId(crossId);
// 保存计划数据 // 保存计划数据
...@@ -57,6 +58,14 @@ public class RunningPlanServiceImpl implements RunningPlanService { ...@@ -57,6 +58,14 @@ public class RunningPlanServiceImpl implements RunningPlanService {
saveCrossSchedules(runningPlanDTO, crossId); saveCrossSchedules(runningPlanDTO, crossId);
} }
private void deleteSections(RunningPlanDTO runningPlanDTO) {
List<RunningPlanDTO.DailyPlanListElement> dailyPlanList = runningPlanDTO.getDailyPlanList();
for (RunningPlanDTO.DailyPlanListElement dailyPlanListElement : dailyPlanList) {
List<Integer> deletedSectionIds = dailyPlanListElement.getDeletedSectionIds();
baseCrossSectionMapper.deleteByCrossIds(deletedSectionIds);
}
}
@Override @Override
public RunningPlanDTO listRunningPlan(CrossIdBO crossIdBO) { public RunningPlanDTO listRunningPlan(CrossIdBO crossIdBO) {
RunningPlanDTO runningPlanDTO = new RunningPlanDTO(); RunningPlanDTO runningPlanDTO = new RunningPlanDTO();
...@@ -244,22 +253,27 @@ public class RunningPlanServiceImpl implements RunningPlanService { ...@@ -244,22 +253,27 @@ public class RunningPlanServiceImpl implements RunningPlanService {
private void updateCrossSection(String crossId, Integer crossPlanId, Integer schemeId, private void updateCrossSection(String crossId, Integer crossPlanId, Integer schemeId,
RunningPlanDTO.TimeListElement time) { RunningPlanDTO.TimeListElement time) {
CrossSectionPO crossSectionPO = new CrossSectionPO(); Integer sectionId = time.getSectionId();
String[] startEndTime = time.getStartEndTime(); if (ObjectUtil.isEmpty(sectionId)) {
String startTime = startEndTime[0]; CrossSectionPO crossSectionPO = new CrossSectionPO();
String endTime = startEndTime[1]; String[] startEndTime = time.getStartEndTime();
String s = startTime + endTime; String startTime = startEndTime[0];
if ("23:59".equals(endTime)) { String endTime = startEndTime[1];
endTime = "24:00"; String s = startTime + endTime;
if ("23:59".equals(endTime)) {
endTime = "24:00";
}
String sectionNo = s.replaceAll(":", "");
crossSectionPO.setSectionNo(sectionNo);
crossSectionPO.setStartTime(startTime);
crossSectionPO.setEndTime(endTime);
crossSectionPO.setCrossId(crossId);
crossSectionPO.setPlanId(crossPlanId);
crossSectionPO.setControlMode(1); // todo 暂时只有定周期
crossSectionPO.setSchemeId(schemeId);
baseCrossSectionMapper.insertOne(crossSectionPO);
} else {
baseCrossSectionMapper.updateOne(sectionId, crossPlanId, schemeId);
} }
String sectionNo = s.replaceAll(":", "");
crossSectionPO.setSectionNo(sectionNo);
crossSectionPO.setStartTime(startTime);
crossSectionPO.setEndTime(endTime);
crossSectionPO.setCrossId(crossId);
crossSectionPO.setPlanId(crossPlanId);
crossSectionPO.setControlMode(1); // todo 暂时只有定周期
crossSectionPO.setSchemeId(schemeId);
baseCrossSectionMapper.insertOne(crossSectionPO);
} }
} }
...@@ -44,4 +44,8 @@ public interface BaseCrossSectionMapper { ...@@ -44,4 +44,8 @@ public interface BaseCrossSectionMapper {
List<CrossSectionPOExt> selectByCrossIdsAndStartTime(String startTime, List<String> crossList); List<CrossSectionPOExt> selectByCrossIdsAndStartTime(String startTime, List<String> crossList);
List<CrossAllSchemesDTO> selectCrossAllSchemes(String crossId); List<CrossAllSchemesDTO> selectCrossAllSchemes(String crossId);
void deleteByCrossIds(List<Integer> ids);
void updateOne(Integer sectionId, Integer crossPlanId, Integer schemeId);
} }
...@@ -32,6 +32,8 @@ public class RunningPlanDTO { ...@@ -32,6 +32,8 @@ public class RunningPlanDTO {
private String name; private String name;
@ApiModelProperty(value = "开始时间结束时间列表", required = true) @ApiModelProperty(value = "开始时间结束时间列表", required = true)
private List<TimeListElement> timeList; private List<TimeListElement> timeList;
@ApiModelProperty(value = "被删除的时段ID", required = true)
private List<Integer> deletedSectionIds = new ArrayList<>();
} }
@NoArgsConstructor @NoArgsConstructor
@Data @Data
...@@ -46,8 +48,6 @@ public class RunningPlanDTO { ...@@ -46,8 +48,6 @@ public class RunningPlanDTO {
private String[] startEndTime; private String[] startEndTime;
@ApiModelProperty(value = "方案名", required = true) @ApiModelProperty(value = "方案名", required = true)
private String schemeName; private String schemeName;
@ApiModelProperty(value = "被删除的时段ID", required = true)
private List<Integer> deletedSectionIds = new ArrayList<>();
} }
@NoArgsConstructor @NoArgsConstructor
......
...@@ -31,12 +31,27 @@ ...@@ -31,12 +31,27 @@
where id = #{sectionId} where id = #{sectionId}
</update> </update>
<update id="updateOne">
update t_base_cross_section
set plan_id = #{crossPlanId} , scheme_id = #{schemeId}
where id = #{sectionId}
</update>
<delete id="deleteByCrossId"> <delete id="deleteByCrossId">
DELETE DELETE
FROM t_base_cross_section FROM t_base_cross_section
WHERE cross_id = #{crossId} WHERE cross_id = #{crossId}
</delete> </delete>
<delete id="deleteByCrossIds">
DELETE
FROM t_base_cross_section
WHERE id in
<foreach collection="ids" item="id" separator="," open="(" close=")">
#{id}
</foreach>
</delete>
<select id="listCrossSectionPO" parameterType="net.wanji.databus.dao.entity.CrossSectionPO" resultMap="BaseResultMap"> <select id="listCrossSectionPO" parameterType="net.wanji.databus.dao.entity.CrossSectionPO" resultMap="BaseResultMap">
select select
<include refid="Base_Column_list"/> <include refid="Base_Column_list"/>
......
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