Commit b7219371 authored by duanruiming's avatar duanruiming

Merge remote-tracking branch 'origin/master'

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