Commit bbf60c16 authored by hanbing's avatar hanbing

方案下发-信号机方案同步

parent eb6a34d0
...@@ -4,8 +4,8 @@ import net.wanji.web.po.scheme.CrossPhaseLightsPO; ...@@ -4,8 +4,8 @@ import net.wanji.web.po.scheme.CrossPhaseLightsPO;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.Set;
/** /**
* 相位灯组关系;(t_base_cross_phase_lights)表数据库访问层 * 相位灯组关系;(t_base_cross_phase_lights)表数据库访问层
...@@ -16,7 +16,7 @@ import java.util.Set; ...@@ -16,7 +16,7 @@ import java.util.Set;
public interface CrossPhaseLightsMapper { public interface CrossPhaseLightsMapper {
void deleteByCrossId(@Param("crossId") String crossId); void deleteByCrossId(@Param("crossId") String crossId);
void insertBatchBySet(@Param("entities") Set<CrossPhaseLightsPO> entities); void insertBatch(@Param("entities") Collection<CrossPhaseLightsPO> entities);
List<CrossPhaseLightsPO> selectByPhaseId(@Param("phaseId") Integer phaseId); List<CrossPhaseLightsPO> selectByPhaseId(@Param("phaseId") Integer phaseId);
......
...@@ -44,4 +44,6 @@ public interface CrossPhaseMapper { ...@@ -44,4 +44,6 @@ public interface CrossPhaseMapper {
Integer selectIdByCrossIdAndPhaseNo(String crossId, String phaseNo); Integer selectIdByCrossIdAndPhaseNo(String crossId, String phaseNo);
void update(CrossPhasePO crossPhasePO); void update(CrossPhasePO crossPhasePO);
void insertBatch(List<CrossPhasePO> crossPhaseList);
} }
...@@ -226,7 +226,8 @@ public class PlanSendServiceImpl implements PlanSendService { ...@@ -226,7 +226,8 @@ public class PlanSendServiceImpl implements PlanSendService {
@Transactional @Transactional
public JsonViewObject syncScheme(CrossIdDTO crossIdDTO) { public JsonViewObject syncScheme(CrossIdDTO crossIdDTO) {
CrossIdVO crossIdVO = new CrossIdVO(); CrossIdVO crossIdVO = new CrossIdVO();
crossIdVO.setCrossId(crossIdDTO.getCrossId()); String crossId = crossIdDTO.getCrossId();
crossIdVO.setCrossId(crossId);
JsonViewObject jsonViewObject = utcFeignClients.schemePhaseLights(crossIdVO); JsonViewObject jsonViewObject = utcFeignClients.schemePhaseLights(crossIdVO);
if (Objects.isNull(jsonViewObject) || jsonViewObject.getCode() != 200) { if (Objects.isNull(jsonViewObject) || jsonViewObject.getCode() != 200) {
return jsonViewObject.fail("信号机静态信息获取-方案信息-UTC服务调用异常"); return jsonViewObject.fail("信号机静态信息获取-方案信息-UTC服务调用异常");
...@@ -240,53 +241,20 @@ public class PlanSendServiceImpl implements PlanSendService { ...@@ -240,53 +241,20 @@ public class PlanSendServiceImpl implements PlanSendService {
return jsonViewObject.fail("信号机方案对象转换结果为空,未更新数据库"); return jsonViewObject.fail("信号机方案对象转换结果为空,未更新数据库");
} }
List<CrossSchemePO> crossSchemeList = schemePhaseLightsVO.getCrossSchemeList(); List<CrossSchemePO> crossSchemeList = schemePhaseLightsVO.getCrossSchemeList();
for (CrossSchemePO crossSchemePO : crossSchemeList) { crossSchemeMapper.deleteByCrossId(crossId);
String crossId = crossSchemePO.getCrossId(); crossSchemeMapper.insertBatch(crossSchemeList);
String schemeNo = crossSchemePO.getSchemeNo();
Integer schemeId = crossSchemeMapper.selectIdByCrossIdAndSchemeNo(crossId, schemeNo);
if (!ObjectUtil.isEmpty(schemeId)) {
// 如果有相同的路口ID和方案号,则更新
crossSchemeMapper.update(crossSchemePO);
} else {
// 否则插入
crossSchemeMapper.insertOne(crossSchemePO);
}
}
List<CrossPhasePO> crossPhaseList = schemePhaseLightsVO.getCrossPhaseList(); List<CrossPhasePO> crossPhaseList = schemePhaseLightsVO.getCrossPhaseList();
for (CrossPhasePO crossPhasePO : crossPhaseList) { crossPhaseMapper.deleteByCrossId(crossId);
String crossId = crossPhasePO.getCrossId(); crossPhaseMapper.insertBatch(crossPhaseList);
String phaseNo = crossPhasePO.getPhaseNo();
Integer phaseId = crossPhaseMapper.selectIdByCrossIdAndPhaseNo(crossId, phaseNo);
if (ObjectUtil.isNotEmpty(phaseId)) {
crossPhaseMapper.update(crossPhasePO);
} else {
crossPhaseMapper.insertOne(crossPhasePO);
}
}
List<CrossLightsPO> crossLightsList = schemePhaseLightsVO.getCrossLightsList(); List<CrossLightsPO> crossLightsList = schemePhaseLightsVO.getCrossLightsList();
for (CrossLightsPO crossLightsPO : crossLightsList) { crossLightsMapper.deleteByCrossId(crossId);
String crossId = crossLightsPO.getCrossId(); crossLightsMapper.insertBatch(crossLightsList);
String lightsNo = crossLightsPO.getLightsNo();
CrossLightsPO crossLightsPO1 = crossLightsMapper.selectByCrossIdAndLedNum(crossId, lightsNo);
if (ObjectUtil.isNotEmpty(crossLightsPO1)) {
crossLightsMapper.update(crossLightsPO);
} else {
crossLightsMapper.insertOne(crossLightsPO);
}
}
List<CrossPhaseLightsPO> crossPhaseLightsPOList = schemePhaseLightsVO.getCrossPhaseLightsPOList(); List<CrossPhaseLightsPO> crossPhaseLightsPOList = schemePhaseLightsVO.getCrossPhaseLightsPOList();
if (crossPhaseLightsPOList != null) { crossPhaseLightsMapper.deleteByCrossId(crossId);
for (CrossPhaseLightsPO crossPhaseLightsPO : crossPhaseLightsPOList) { crossPhaseLightsMapper.insertBatch(crossPhaseLightsPOList);
Integer lightsId = crossPhaseLightsPO.getLightsId();
Integer phaseId = crossPhaseLightsPO.getPhaseId();
String crossId = crossPhaseLightsPO.getCrossId();
Integer id = crossPhaseLightsMapper.selectIdByThreeIds(lightsId, phaseId, crossId);
// 如果数据库中有记录则跳过,无记录则插入
if (ObjectUtil.isEmpty(id)) {
crossPhaseLightsMapper.insertOne(crossPhaseLightsPO);
}
}
}
} }
return jsonViewObject.success(); return jsonViewObject.success();
} }
......
...@@ -664,7 +664,7 @@ public class SchemeConfigServiceImpl implements SchemeConfigService { ...@@ -664,7 +664,7 @@ public class SchemeConfigServiceImpl implements SchemeConfigService {
crossPhaseLightsPOSet.add(crossPhaseLightsPO); crossPhaseLightsPOSet.add(crossPhaseLightsPO);
} }
} }
crossPhaseLightsMapper.insertBatchBySet(crossPhaseLightsPOSet); crossPhaseLightsMapper.insertBatch(crossPhaseLightsPOSet);
} }
private void updateCrossScheme(SaveSchemeConfigDTO saveSchemeConfigDTO) { private void updateCrossScheme(SaveSchemeConfigDTO saveSchemeConfigDTO) {
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
<result property="gmtModified" column="gmt_modified"/> <result property="gmtModified" column="gmt_modified"/>
</resultMap> </resultMap>
<insert id="insertBatchBySet" keyProperty="id" useGeneratedKeys="true"> <insert id="insertBatch" keyProperty="id" useGeneratedKeys="true">
insert into t_base_cross_phase_lights(lights_id,phase_id,cross_id) insert into t_base_cross_phase_lights(lights_id,phase_id,cross_id)
values values
<foreach collection="entities" item="entity" separator=","> <foreach collection="entities" item="entity" separator=",">
......
...@@ -31,6 +31,14 @@ ...@@ -31,6 +31,14 @@
values (#{phaseNo},#{name},#{sort},#{crossId},#{planId},#{ringNo},#{groupNo},#{phaseType},#{controlMode},#{phaseTime},#{greenTime},#{greenFlashTime},#{yellowFlashTime},#{redFlashTime},#{pedFlashTime},#{yellowTime},#{redTime},#{minGreenTime},#{maxGreenTime}) values (#{phaseNo},#{name},#{sort},#{crossId},#{planId},#{ringNo},#{groupNo},#{phaseType},#{controlMode},#{phaseTime},#{greenTime},#{greenFlashTime},#{yellowFlashTime},#{redFlashTime},#{pedFlashTime},#{yellowTime},#{redTime},#{minGreenTime},#{maxGreenTime})
</insert> </insert>
<insert id="insertBatch" keyProperty="id" useGeneratedKeys="true">
insert into t_base_cross_phase(phase_no,name,sort,cross_id,plan_id,ring_no,group_no,phase_type,control_mode,phase_time,green_time,green_flash_time,yellow_flash_time,red_flash_time,ped_flash_time,yellow_time,red_time,min_green_time,max_green_time)
values
<foreach collection="crossPhaseList" item="entity" separator=",">
(#{entity.phaseNo},#{entity.name},#{entity.sort},#{entity.crossId},#{entity.planId},#{entity.ringNo},#{entity.groupNo},#{entity.phaseType},#{entity.controlMode},#{entity.phaseTime},#{entity.greenTime},#{entity.greenFlashTime},#{entity.yellowFlashTime},#{entity.redFlashTime},#{entity.pedFlashTime},#{entity.yellowTime},#{entity.redTime},#{entity.minGreenTime},#{entity.maxGreenTime})
</foreach>
</insert>
<update id="update"> <update id="update">
update t_base_cross_phase update t_base_cross_phase
<set> <set>
......
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