Commit 849cf846 authored by duanruiming's avatar duanruiming

[update] 万集标准类型优化

parent 982f885a
package net.wanji.utc.service.staticinfo;
import net.wanji.databus.dao.entity.CrossSchedulesPO;
import net.wanji.databus.vo.PlanSectionVO;
import net.wanji.databus.vo.SchemePhaseLightsVO;
import net.wanji.utc.common.Result;
import net.wanji.utc.service.rpc.RpcService;
......@@ -21,7 +19,7 @@ public interface WanJiCommonStaticInfoService extends RpcService {
* @param signalId
* @return
*/
Result<SchemePhaseLightsVO> schemePhaseLights(String crossId, String signalId) throws Exception;
void schemePhaseLights(String crossId, String signalId) throws Exception;
/**
* 静态参数,获取计划数据-计划信息、时段信息
......@@ -30,7 +28,7 @@ public interface WanJiCommonStaticInfoService extends RpcService {
* @param signalId
* @return
*/
Result<PlanSectionVO> planSection(String crossId, String signalId, Integer planNo) throws Exception;
void planSection(String crossId, String signalId, Integer planNo) throws Exception;
/**
* 静态参数,获取时间表数据
......
package net.wanji.utc.service.staticinfo.impl;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import net.wanji.common.framework.rest.JsonViewObject;
......@@ -45,63 +47,61 @@ public class WanJiCommonStaticInfoServiceImpl implements WanJiCommonStaticInfoSe
@Override
public Result<SchemePhaseLightsVO> schemePhaseLights(String crossId, String signalId) throws Exception {
public void schemePhaseLights(String crossId, String signalId) throws Exception {
String manufacturerIdCode = crossInfoCache.getManufacturerCodeByCrossId(crossId);
CrossIdVO crossIdVO = new CrossIdVO();
crossIdVO.setCrossId(crossId);
JsonViewObject jsonViewObject = utcFeignClientCache.getUtcFeignClientService(manufacturerIdCode).schemePhaseLights(crossIdVO);
SchemePhaseLightsVO content = (SchemePhaseLightsVO) jsonViewObject.getContent();
if (Objects.nonNull(content)) {
List<BaseCrossSchemePO> crossSchemeList = content.getCrossSchemeList();
crossSchemeList.forEach(crossSchemePO -> {
crossSchemeMapper.deleteOne(crossId, crossSchemePO.getSchemeNo());
crossSchemeMapper.insertOne(crossSchemePO);
});
List<CrossPhasePO> crossPhaseList = content.getCrossPhaseList();
crossPhaseList.forEach(crossPhasePO -> {
crossPhaseMapper.deleteBatch(crossId, crossPhasePO.getPlanId());
crossPhaseMapper.insertOne(crossPhasePO);
});
ObjectMapper objectMapper = new ObjectMapper();
SchemePhaseLightsVO content = objectMapper.convertValue(jsonViewObject.getContent(), SchemePhaseLightsVO.class);
List<BaseCrossSchemePO> crossSchemeList = content.getCrossSchemeList();
crossSchemeList.forEach(crossSchemePO -> {
crossSchemeMapper.deleteOne(crossId, crossSchemePO.getSchemeNo());
crossSchemeMapper.insertOne(crossSchemePO);
});
List<CrossPhasePO> crossPhaseList = content.getCrossPhaseList();
crossPhaseList.forEach(crossPhasePO -> {
crossPhaseMapper.deleteBatch(crossId, crossPhasePO.getPlanId());
crossPhaseMapper.insertOne(crossPhasePO);
});
List<CrossLightsPO> crossLightsList = content.getCrossLightsList();
crossLightsList.forEach(crossLightsPO -> {
crossLightsMapper.deleteOne(crossId, crossLightsPO.getName());
crossLightsMapper.insertOne(crossLightsPO);
});
List<CrossPhaseLightsPO> crossPhaseLightsPOList = content.getCrossPhaseLightsPOList();
if (!CollectionUtils.isEmpty(crossPhaseLightsPOList)) {
crossPhaseLightsMapper.deleteByCrossId(crossPhaseLightsPOList.get(0).getCrossId());
crossPhaseLightsMapper.insertBatch(crossPhaseLightsPOList);
}
List<CrossLightsPO> crossLightsList = content.getCrossLightsList();
crossLightsList.forEach(crossLightsPO -> {
crossLightsMapper.deleteOne(crossId, crossLightsPO.getName());
crossLightsMapper.insertOne(crossLightsPO);
});
List<CrossPhaseLightsPO> crossPhaseLightsPOList = content.getCrossPhaseLightsPOList();
if (!CollectionUtils.isEmpty(crossPhaseLightsPOList)) {
crossPhaseLightsMapper.deleteByCrossId(crossPhaseLightsPOList.get(0).getCrossId());
crossPhaseLightsMapper.insertBatch(crossPhaseLightsPOList);
}
return Result.success(content);
}
@Override
public Result<PlanSectionVO> planSection(String crossId, String signalId, Integer planNo) throws Exception {
public void planSection(String crossId, String signalId, Integer planNo) throws Exception {
String manufacturerIdCode = crossInfoCache.getManufacturerCodeByCrossId(crossId);
PlanSectionDTO planSectionDTO = new PlanSectionDTO();
planSectionDTO.setCrossId(crossId);
planSectionDTO.setPlanNo(planNo);
JsonViewObject jsonViewObject = utcFeignClientCache.getUtcFeignClientService(manufacturerIdCode).planSection(planSectionDTO);
PlanSectionVO content = (PlanSectionVO) jsonViewObject.getContent();
if (Objects.nonNull(content)) {
if (Objects.nonNull(content)) {
List<CrossPlanPO> crossPlanPOList = content.getCrossPlanPOList();
ObjectMapper mapper = new ObjectMapper();
List<PlanSectionVO> content = mapper.convertValue(jsonViewObject.getContent(), new TypeReference<List<PlanSectionVO>>() {
});
if (!CollectionUtils.isEmpty(content)) {
for (PlanSectionVO planSectionVO : content) {
List<CrossPlanPO> crossPlanPOList = planSectionVO.getCrossPlanPOList();
crossPlanPOList.forEach(crossPlanPO -> {
crossPlanMapper.deleteOne(crossId, Integer.parseInt(crossPlanPO.getPlanNo()));
crossPlanMapper.insertOne(crossPlanPO);
});
List<CrossSectionPO> crossSectionPOList = content.getCrossSectionPOList();
List<CrossSectionPO> crossSectionPOList = planSectionVO.getCrossSectionPOList();
crossSectionPOList.forEach(crossSectionPO -> {
crossSectionMapper.deleteOne(crossId, Integer.parseInt(crossSectionPO.getSectionNo()), null);
crossSectionMapper.insertOne(crossSectionPO);
});
}
}
return Result.success(content);
}
@Override
......@@ -111,7 +111,10 @@ public class WanJiCommonStaticInfoServiceImpl implements WanJiCommonStaticInfoSe
crossSchedulesDTO.setManufacturerCode(manufacturerIdCode);
crossSchedulesDTO.setCrossIdList(Arrays.asList(crossId));
JsonViewObject jsonViewObject = utcFeignClientCache.getUtcFeignClientService(manufacturerIdCode).crossSchedules(crossSchedulesDTO);
List<CrossSchedulesPO> content = (List<CrossSchedulesPO>) jsonViewObject.getContent();
ObjectMapper mapper = new ObjectMapper();
List<CrossSchedulesPO> content = mapper.convertValue(jsonViewObject.getContent(), new TypeReference<List<CrossSchedulesPO>>() {
});
if (Objects.nonNull(content)) {
if (!CollectionUtils.isEmpty(content)) {
content.forEach(crossSchedulesPO -> {
......
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