Commit bab761fc authored by hanbing's avatar hanbing

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

parent 2f7e915d
package net.wanji.web.service.scheme.impl;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ObjectUtil;
import net.wanji.databus.bo.CrossIdBO;
import net.wanji.databus.dao.entity.*;
import net.wanji.databus.dao.mapper.*;
......@@ -48,7 +49,7 @@ public class RunningPlanServiceImpl implements RunningPlanService {
String crossId = runningPlanDTO.getCrossId();
// 清空之前计划
baseCrossPlanMapper.deleteByCrossId(crossId);
baseCrossSectionMapper.deleteByCrossId(crossId);
deleteSections(runningPlanDTO);
baseCrossSchedulesMapper.deleteByCrossId(crossId);
baseCrossSchedulesPlanMapper.deleteByCrossId(crossId);
// 保存计划数据
......@@ -57,6 +58,14 @@ public class RunningPlanServiceImpl implements RunningPlanService {
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
public RunningPlanDTO listRunningPlan(CrossIdBO crossIdBO) {
RunningPlanDTO runningPlanDTO = new RunningPlanDTO();
......@@ -244,6 +253,8 @@ public class RunningPlanServiceImpl implements RunningPlanService {
private void updateCrossSection(String crossId, Integer crossPlanId, Integer schemeId,
RunningPlanDTO.TimeListElement time) {
Integer sectionId = time.getSectionId();
if (ObjectUtil.isEmpty(sectionId)) {
CrossSectionPO crossSectionPO = new CrossSectionPO();
String[] startEndTime = time.getStartEndTime();
String startTime = startEndTime[0];
......@@ -261,5 +272,8 @@ public class RunningPlanServiceImpl implements RunningPlanService {
crossSectionPO.setControlMode(1); // todo 暂时只有定周期
crossSectionPO.setSchemeId(schemeId);
baseCrossSectionMapper.insertOne(crossSectionPO);
} else {
baseCrossSectionMapper.updateOne(sectionId, crossPlanId, schemeId);
}
}
}
......@@ -44,4 +44,8 @@ public interface BaseCrossSectionMapper {
List<CrossSectionPOExt> selectByCrossIdsAndStartTime(String startTime, List<String> crossList);
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 {
private String name;
@ApiModelProperty(value = "开始时间结束时间列表", required = true)
private List<TimeListElement> timeList;
@ApiModelProperty(value = "被删除的时段ID", required = true)
private List<Integer> deletedSectionIds = new ArrayList<>();
}
@NoArgsConstructor
@Data
......@@ -46,8 +48,6 @@ public class RunningPlanDTO {
private String[] startEndTime;
@ApiModelProperty(value = "方案名", required = true)
private String schemeName;
@ApiModelProperty(value = "被删除的时段ID", required = true)
private List<Integer> deletedSectionIds = new ArrayList<>();
}
@NoArgsConstructor
......
......@@ -31,12 +31,27 @@
where id = #{sectionId}
</update>
<update id="updateOne">
update t_base_cross_section
set plan_id = #{crossPlanId} , scheme_id = #{schemeId}
where id = #{sectionId}
</update>
<delete id="deleteByCrossId">
DELETE
FROM t_base_cross_section
WHERE cross_id = #{crossId}
</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
<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