Commit b7219371 authored by duanruiming's avatar duanruiming

Merge remote-tracking branch 'origin/master'

parents 2b10bafe 5cd5915d
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,16 @@ public class RunningPlanServiceImpl implements RunningPlanService { ...@@ -57,6 +58,16 @@ 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();
if (CollectionUtil.isNotEmpty(deletedSectionIds)) {
baseCrossSectionMapper.deleteByCrossIds(deletedSectionIds);
}
}
}
@Override @Override
public RunningPlanDTO listRunningPlan(CrossIdBO crossIdBO) { public RunningPlanDTO listRunningPlan(CrossIdBO crossIdBO) {
RunningPlanDTO runningPlanDTO = new RunningPlanDTO(); RunningPlanDTO runningPlanDTO = new RunningPlanDTO();
...@@ -244,6 +255,8 @@ public class RunningPlanServiceImpl implements RunningPlanService { ...@@ -244,6 +255,8 @@ 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) {
Integer sectionId = time.getSectionId();
if (ObjectUtil.isEmpty(sectionId)) {
CrossSectionPO crossSectionPO = new CrossSectionPO(); CrossSectionPO crossSectionPO = new CrossSectionPO();
String[] startEndTime = time.getStartEndTime(); String[] startEndTime = time.getStartEndTime();
String startTime = startEndTime[0]; String startTime = startEndTime[0];
...@@ -261,5 +274,8 @@ public class RunningPlanServiceImpl implements RunningPlanService { ...@@ -261,5 +274,8 @@ public class RunningPlanServiceImpl implements RunningPlanService {
crossSectionPO.setControlMode(1); // todo 暂时只有定周期 crossSectionPO.setControlMode(1); // todo 暂时只有定周期
crossSectionPO.setSchemeId(schemeId); crossSectionPO.setSchemeId(schemeId);
baseCrossSectionMapper.insertOne(crossSectionPO); baseCrossSectionMapper.insertOne(crossSectionPO);
} else {
baseCrossSectionMapper.updateOne(sectionId, crossPlanId, schemeId);
}
} }
} }
...@@ -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);
} }
...@@ -4,6 +4,7 @@ import io.swagger.annotations.ApiModelProperty; ...@@ -4,6 +4,7 @@ import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import java.util.ArrayList;
import java.util.List; import java.util.List;
/** /**
...@@ -31,10 +32,14 @@ public class RunningPlanDTO { ...@@ -31,10 +32,14 @@ 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
public static class TimeListElement { public static class TimeListElement {
@ApiModelProperty(value = "时段ID", required = true)
private Integer sectionId;
@ApiModelProperty(value = "开始时间", required = true) @ApiModelProperty(value = "开始时间", required = true)
private String startTime; private String startTime;
@ApiModelProperty(value = "结束时间", required = true) @ApiModelProperty(value = "结束时间", required = true)
......
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
<id column="planNo" property="planNo"/> <id column="planNo" property="planNo"/>
<result column="name" property="name"/> <result column="name" property="name"/>
<collection property="timeList" ofType="net.wanji.databus.dto.RunningPlanDTO$TimeListElement"> <collection property="timeList" ofType="net.wanji.databus.dto.RunningPlanDTO$TimeListElement">
<result column="sectionId" property="sectionId"/>
<result column="startTime" property="startTime"/> <result column="startTime" property="startTime"/>
<result column="endTime" property="endTime"/> <result column="endTime" property="endTime"/>
<result column="schemeName" property="schemeName"/> <result column="schemeName" property="schemeName"/>
...@@ -45,6 +46,7 @@ ...@@ -45,6 +46,7 @@
SELECT SELECT
t1.plan_no as planNo, t1.plan_no as planNo,
t1.name as name, t1.name as name,
t2.id as sectionId,
t2.start_time as startTime, t2.start_time as startTime,
t2.end_time as endTime, t2.end_time as endTime,
t3.name as schemeName t3.name as schemeName
......
...@@ -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