Commit ec1060a4 authored by duanruiming's avatar duanruiming

[update] 方案管理-方案下发优化

parent 0232bbca
......@@ -4,6 +4,8 @@ import net.wanji.web.po.scheme.CrossSectionPO;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
* 时段基础信息;(t_base_cross_section)表
*
......@@ -16,4 +18,6 @@ public interface CrossSectionMapper {
void insertOne(CrossSectionPO crossSectionPO);
void deleteByCrossId(@Param("crossId") String crossId);
List<CrossSectionPO> listCrossSectionPO(@Param("entity") CrossSectionPO entity);
}
......@@ -43,13 +43,14 @@ public class PlanSendServiceImpl implements PlanSendService {
private final SchemeConfigServiceImpl schemeConfigServiceImpl;
private final CrossSchedulesMapper crossSchedulesMapper;
private final CrossLaneLightsMapper crossLaneLightsMapper;
private final CrossSectionMapper crossSectionMapper;
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
SimpleDateFormat hourMinuteSdf = new SimpleDateFormat("HH:mm");
private Gson gson = new GsonBuilder().setDateFormat("yyyy-MM-dd").create();
public PlanSendServiceImpl(@Qualifier("net.wanji.feign.service.UtcFeignClients") UtcFeignClients utcFeignClients, CrossSchedulesPlanMapper crossSchedulesPlanMapper, CrossPlanMapper crossPlanMapper, CrossSchemeMapper crossSchemeMapper, CrossPhaseMapper crossPhaseMapper, CrossLightsMapper crossLightsMapper, CrossPhaseLightsMapper crossPhaseLightsMapper, RunningPlanServiceImpl runningPlanServiceImpl, SchemeConfigServiceImpl schemeConfigServiceImpl, CrossSchedulesMapper crossSchedulesMapper, CrossLaneLightsMapper crossLaneLightsMapper) {
public PlanSendServiceImpl(@Qualifier("net.wanji.feign.service.UtcFeignClients") UtcFeignClients utcFeignClients, CrossSchedulesPlanMapper crossSchedulesPlanMapper, CrossPlanMapper crossPlanMapper, CrossSchemeMapper crossSchemeMapper, CrossPhaseMapper crossPhaseMapper, CrossLightsMapper crossLightsMapper, CrossPhaseLightsMapper crossPhaseLightsMapper, RunningPlanServiceImpl runningPlanServiceImpl, SchemeConfigServiceImpl schemeConfigServiceImpl, CrossSchedulesMapper crossSchedulesMapper, CrossLaneLightsMapper crossLaneLightsMapper, CrossSectionMapper crossSectionMapper) {
this.utcFeignClients = utcFeignClients;
this.crossSchedulesPlanMapper = crossSchedulesPlanMapper;
this.crossPlanMapper = crossPlanMapper;
......@@ -61,29 +62,75 @@ public class PlanSendServiceImpl implements PlanSendService {
this.schemeConfigServiceImpl = schemeConfigServiceImpl;
this.crossSchedulesMapper = crossSchedulesMapper;
this.crossLaneLightsMapper = crossLaneLightsMapper;
this.crossSectionMapper = crossSectionMapper;
}
@Override
@Transactional
public JsonViewObject scheduleSend(ScheduleIdDTO scheduleIdDTO) {
String crossId = scheduleIdDTO.getCrossId();
Integer scheduleId = scheduleIdDTO.getScheduleId();
ScheduleSendVO scheduleSendVO = new ScheduleSendVO();
scheduleSendVO.setCrossCode(crossId);
// 构造时间表
// 下发调度
List<ScheduleSendVO.Schedule> schedules = buildSchedules(crossId, scheduleIdDTO);
scheduleSendVO.setSchedules(schedules);
// 发送请求
JsonViewObject jsonViewObject = utcFeignClients.scheduleSend(scheduleSendVO);
if (Objects.isNull(jsonViewObject) || jsonViewObject.getCode() != 200) {
return jsonViewObject.fail("信号机方案下发-时间表下发UTC服务调用异常");
return jsonViewObject.fail("信号机方案下发-运行计划下发UTC服务调用异常");
}
// 下发日计划和方案
PlanSendVO planSendVO = getPlanSendVO(crossId, scheduleId);
JsonViewObject planSendResult = utcFeignClients.planSend(planSendVO);
if (Objects.isNull(planSendResult) || planSendResult.getCode() != 200) {
return jsonViewObject.fail("信号机方案下发-日计划下发UTC服务调用异常");
}
// 更新时间表状态为已执行
Integer scheduleId = scheduleIdDTO.getScheduleId();
crossSchedulesMapper.resetStatus(crossId);
crossSchedulesMapper.updateStatus(scheduleId);
return jsonViewObject.success();
}
private PlanSendVO getPlanSendVO(String crossId, Integer scheduleId) {
List<CrossSchedulesPlanPO> crossSchedulesPlanPOList =
crossSchedulesPlanMapper.selectByCrossIdAndSchedulesId(crossId, scheduleId);
Integer planId = crossSchedulesPlanPOList.get(0).getPlanId();
CrossPlanPO crossPlanPO = crossPlanMapper.selectById(planId);
CrossSectionPO crossSectionPO = new CrossSectionPO();
crossSectionPO.setCrossId(crossId);
crossSectionPO.setPlanId(planId);
List<CrossSectionPO> crossSectionPOS = crossSectionMapper.listCrossSectionPO(crossSectionPO);
List<PlanSendVO.Plan.Section> sectionList = new ArrayList<>(crossSectionPOS.size());
for (CrossSectionPO sectionPO : crossSectionPOS) {
Integer schemeId = sectionPO.getSchemeId();
PlanSendVO.Plan.Section section = new PlanSendVO.Plan.Section();
section.setSectionNo(sectionPO.getSectionNo());
section.setPatternNo(String.valueOf(schemeId));
section.setBeginTime(sectionPO.getStartTime());
section.setEndTime(sectionPO.getEndTime());
section.setControlMode(String.valueOf(sectionPO.getControlMode()));
sectionList.add(section);
// 下发日计划中方案
SchemeIdDTO schemeIdDTO = new SchemeIdDTO();
schemeIdDTO.setCrossId(crossId);
schemeIdDTO.setSchemeId(schemeId);
schemeSend(schemeIdDTO);
}
PlanSendVO planSendVO = new PlanSendVO();
planSendVO.setCrossCode(crossId);
PlanSendVO.Plan plan = new PlanSendVO.Plan();
plan.setPlanNo(crossPlanPO.getPlanNo());
plan.setPlanDescribe(crossPlanPO.getName());
plan.setSectionList(sectionList);
planSendVO.setPlanList(Arrays.asList(plan));
return planSendVO;
}
@Override
public JsonViewObject schemeSend(SchemeIdDTO schemeIdDTO) {
String crossId = schemeIdDTO.getCrossId();
......
......@@ -16,15 +16,40 @@
<result property="gmtModified" column="gmt_modified"/>
</resultMap>
<sql id="Base_Column_list">
id, section_no,start_time, end_time, cross_id, plan_id, control_mode, scheme_id,gmt_create, gmt_modified
</sql>
<insert id="insertOne" keyProperty="id" useGeneratedKeys="true">
insert into t_base_cross_section(section_no,start_time,end_time,cross_id,plan_id,control_mode,scheme_id)
values (#{sectionNo},#{startTime},#{endTime},#{crossId},#{planId},#{controlMode},#{schemeId})
insert into t_base_cross_section(section_no, start_time, end_time, cross_id, plan_id, control_mode, scheme_id)
values (#{sectionNo}, #{startTime}, #{endTime}, #{crossId}, #{planId}, #{controlMode}, #{schemeId})
</insert>
<delete id="deleteByCrossId">
DELETE FROM t_base_cross_section
DELETE
FROM t_base_cross_section
WHERE cross_id = #{crossId}
</delete>
<select id="listCrossSectionPO" parameterType="net.wanji.web.po.scheme.CrossSectionPO" resultMap="BaseResultMap">
select
<include refid="Base_Column_list"/>
from t_base_cross_section
<where>
<if test="entity.id != null and entity.id != ''">
and id = #{entity.id}
</if>
<if test="entity.crossId != null and entity.crossId != ''">
and cross_id = #{entity.crossId}
</if>
<if test="entity.planId != null and entity.planId != ''">
and plan_id = #{entity.planId}
</if>
<if test="entity.schemeId != null and entity.schemeId != ''">
and scheme_id = #{entity.schemeId}
</if>
</where>
</select>
</mapper>
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