Commit 722773ac authored by duanruiming's avatar duanruiming

[update] 优化utc远程调用服务

parent 7844f30d
......@@ -85,6 +85,9 @@ public interface UtcFeignCommon {
@PostMapping("/staticInfo/crossSchedules")
JsonViewObject crossSchedules(@RequestBody CrossSchedulesDTO crossSchedulesDTO);
@PostMapping("/staticInfo/crossSchedules")
JsonViewObject crossSchedules(@RequestParam String crossId);
@PostMapping("/manufacturer/list")
JsonViewObject listManufacturerInfo(ManufacturerVO manufacturerPO);
......
......@@ -5,21 +5,17 @@ import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import lombok.RequiredArgsConstructor;
import net.wanji.utc.dt.service.controller.StaticInfoService;
import net.wanji.common.annotation.aspect.AspectLog;
import net.wanji.common.enums.BaseEnum;
import net.wanji.common.framework.rest.JsonViewObject;
import net.wanji.databus.dao.entity.CrossSchedulesPO;
import net.wanji.databus.dto.CrossSchedulesDTO;
import net.wanji.databus.dto.PlanSectionDTO;
import net.wanji.databus.dto.SchemePhaseLightsDTO;
import net.wanji.databus.vo.PlanSectionVO;
import net.wanji.databus.vo.SchemePhaseLightsVO;
import net.wanji.utc.dt.service.controller.StaticInfoService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import javax.ws.rs.core.MediaType;
import java.util.List;
......@@ -65,15 +61,12 @@ public class StaticInfoController {
}
@AspectLog(description = "时间表数据", operationType = BaseEnum.OperationTypeEnum.QUERY)
@PostMapping(value = "/crossSchedules",
produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
@ApiOperation(value = "时间表数据", notes = "时间表数据", response = CrossSchedulesPO.class,
produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
@PostMapping(value = "/crossSchedules", produces = MediaType.APPLICATION_JSON)
@ApiResponses({
@ApiResponse(code = 200, message = "OK", response = CrossSchedulesPO.class)
})
public JsonViewObject crossSchedules(@RequestBody @Validated CrossSchedulesDTO crossSchedulesDTO) throws Exception {
List<CrossSchedulesPO> crossSchedulesPOS = staticInfoService.crossSchedules(crossSchedulesDTO);
public JsonViewObject crossSchedules(@RequestParam String crossId) throws Exception {
List<CrossSchedulesPO> crossSchedulesPOS = staticInfoService.crossSchedules(crossId);
return JsonViewObject.newInstance().success(crossSchedulesPOS);
}
}
......@@ -2,7 +2,6 @@ package net.wanji.utc.dt.service.controller;
import net.wanji.databus.dao.entity.CrossSchedulesPO;
import net.wanji.databus.dto.CrossInfoDTO;
import net.wanji.databus.dto.CrossSchedulesDTO;
import net.wanji.databus.dto.PlanSectionDTO;
import net.wanji.databus.dto.SchemePhaseLightsDTO;
import net.wanji.databus.po.CrossInfoPO;
......@@ -19,6 +18,6 @@ public interface StaticInfoService extends BeanMarkService {
List<PlanSectionVO> planSection(PlanSectionDTO planSectionDTO) throws Exception;
List<CrossSchedulesPO> crossSchedules(CrossSchedulesDTO crossSchedulesDTO) throws Exception;
List<CrossSchedulesPO> crossSchedules(String crossId) throws Exception;
}
......@@ -8,7 +8,6 @@ import net.wanji.common.enums.DateStyle;
import net.wanji.common.utils.tool.DateUtil;
import net.wanji.databus.dao.entity.*;
import net.wanji.databus.dto.CrossInfoDTO;
import net.wanji.databus.dto.CrossSchedulesDTO;
import net.wanji.databus.dto.PlanSectionDTO;
import net.wanji.databus.dto.SchemePhaseLightsDTO;
import net.wanji.databus.po.CrossInfoPO;
......@@ -594,9 +593,7 @@ public class DTStaticInfoServiceImpl implements StaticInfoService {
}
@Override
public List<CrossSchedulesPO> crossSchedules(CrossSchedulesDTO crossSchedulesDTO) throws Exception {
// String crossId = crossSchedulesDTO.getCrossId();
String crossId = "12F7L08J8S0";
public List<CrossSchedulesPO> crossSchedules(String crossId) throws Exception {
CrossInfoPO crossInfoPO = crossInfoCache.getCrossInfoCache().get(crossId);
String message = String.format(Constants.COMMAND_COMMON, Constants.COMMAND_QUERY, Constants.COMMAND_SCHEDULE_CONFIG);
String scheduleSign = Constants.COMMAND_SCHEDULE_CONFIG.concat(Constants.COMMAND_QUERY_REPLY);
......
......@@ -3,7 +3,6 @@ package net.wanji.utc.service.control;
import net.wanji.common.framework.rest.JsonViewObject;
import net.wanji.databus.vo.*;
import net.wanji.utc.po.hk.request.DelBaseConfigPO;
import net.wanji.utc.service.rpc.RpcService;
/**
* 控制指令 service
......@@ -11,7 +10,7 @@ import net.wanji.utc.service.rpc.RpcService;
* @author wuxiaokai
* @date 2022/11/15 14:02:36
*/
public interface ControlCommandService extends RpcService {
public interface ControlCommandService {
/**
* 方案下发
......
package net.wanji.utc.service.rpc;
import net.wanji.common.framework.rest.JsonViewObject;
import net.wanji.utc.util.HttpRestUtil;
import java.util.Map;
import java.util.Objects;
/**
* @author duanruiming
* @date 2023/01/09 9:57
*/
public interface RpcService {
/**
* 远程调用信号机设备
* @param url
* @param headers
* @param param
* @return
*/
default JsonViewObject rpcService(HttpRestUtil httpRestUtil, String url, Map<String, String> headers, String param) {
JsonViewObject jsonViewObject = httpRestUtil.doPost(url, headers, param, JsonViewObject.class);
if (Objects.isNull(jsonViewObject) || jsonViewObject.getCode() != 200) {
return jsonViewObject.fail("远程服务调用异常,url:".concat(url));
}
return jsonViewObject;
}
}
......@@ -2,7 +2,6 @@ package net.wanji.utc.service.runninginfo;
import net.wanji.databus.po.SignalStatusLogPO;
import net.wanji.databus.vo.LightsStatusVO;
import net.wanji.utc.service.rpc.RpcService;
import java.util.List;
......@@ -10,7 +9,7 @@ import java.util.List;
* @author duanruiming
* @date 2023/01/11 17:32
*/
public interface WanJiCommonRunningStatusService extends RpcService {
public interface WanJiCommonRunningStatusService{
/**
* 标准获取路口实时运行状态接口,包括告警数据
* @param crossIdList
......
......@@ -41,6 +41,9 @@ public class WanJiCommonRunningStatusServiceImpl implements WanJiCommonRunningSt
List<SignalStatusLogPO> result = new ArrayList<>();
for (String manufacturerIdCode : set) {
JsonViewObject jsonViewObject = utcFeignClientCache.getUtcFeignClientService(manufacturerIdCode).runningStatusAlarm();
if (Objects.isNull(jsonViewObject) || jsonViewObject.getCode() != 200) {
throw new Exception("获取运行状态、告警数据远程服务调用异常,异常信息" + jsonViewObject.getMessage());
}
result = (List<SignalStatusLogPO>) jsonViewObject.getContent();
}
return result;
......@@ -54,14 +57,13 @@ public class WanJiCommonRunningStatusServiceImpl implements WanJiCommonRunningSt
String manufacturerIdCode = crossInfoCache.getManufacturerCodeByCrossId(crossId);
set.add(manufacturerIdCode);
JsonViewObject jsonViewObject = utcFeignClientCache.getUtcFeignClientService(manufacturerIdCode).lightStatus(crossId);
if (Objects.isNull(jsonViewObject) || jsonViewObject.getCode() != 200) {
throw new Exception("获取灯态数据远程服务调用异常,异常信息" + jsonViewObject.getMessage());
}
ObjectMapper objectMapper = new ObjectMapper();
result = objectMapper.convertValue(jsonViewObject.getContent(), new TypeReference<List<LightsStatusVO>>() {});
}
return result;
}
@Override
public JsonViewObject rpcService(HttpRestUtil httpRestUtil, String url, Map<String, String> headers, String param) {
return WanJiCommonRunningStatusService.super.rpcService(httpRestUtil, url, headers, param);
}
}
......@@ -6,6 +6,8 @@ import net.wanji.databus.dto.CrossSchedulesDTO;
import net.wanji.databus.dto.PlanSectionDTO;
import net.wanji.databus.dto.SchemePhaseLightsDTO;
import net.wanji.databus.po.CrossInfoPO;
import net.wanji.databus.vo.PlanSectionVO;
import net.wanji.databus.vo.SchemePhaseLightsVO;
import java.util.List;
......@@ -19,11 +21,11 @@ public interface StaticInfoService {
void crossSchedules(CrossSchedulesDTO crossSchedulesDTO) throws Exception;
net.wanji.databus.vo.SchemePhaseLightsVO buildSchemePhaseLightsResponse(SchemePhaseLightsDTO schemePhaseLightsDTO);
SchemePhaseLightsVO buildSchemePhaseLightsResponse(SchemePhaseLightsDTO schemePhaseLightsDTO);
net.wanji.databus.vo.PlanSectionVO buildPlanSectionResponse(String crossId);
PlanSectionVO buildPlanSectionResponse(String crossId);
net.wanji.databus.vo.PlanSectionVO buildPlanSectionResponse(String crossId, Integer planNo);
PlanSectionVO buildPlanSectionResponse(String crossId, Integer planNo);
List<CrossSchedulesPO> buildCrossSchedulesResponse(List<String> crossIdList);
}
......@@ -2,15 +2,13 @@ package net.wanji.utc.service.staticinfo;
import net.wanji.databus.dao.entity.CrossSchedulesPO;
import net.wanji.utc.common.Result;
import net.wanji.utc.service.rpc.RpcService;
import java.util.List;
/**
* @author duanruiming
* @date 2023/01/09 9:20
*/
public interface WanJiCommonStaticInfoService extends RpcService {
public interface WanJiCommonStaticInfoService {
/**
* 静态参数,获取万集标准方案数据-方案信息、相位信息、灯组信息
......
......@@ -129,11 +129,12 @@ public class StaticInfoServiceImpl implements StaticInfoService {
hkCrossSchedulesService.crossSchedules(crossIdList);
} else {
if (!CollectionUtils.isEmpty(crossIdList)) {
String crossId = crossIdList.get(0);
CrossInfoPO crossInfoPO = crossInfoMapper.selectByPrimaryKey(crossId);
if (Objects.nonNull(crossInfoPO)) {
String signalIc = crossInfoPO.getCode();
wanjiCommonStaticInfoService.schedules(crossId, signalIc);
for (String crossId : crossIdList) {
CrossInfoPO crossInfoPO = crossInfoMapper.selectByPrimaryKey(crossId);
if (Objects.nonNull(crossInfoPO)) {
String signalIc = crossInfoPO.getCode();
wanjiCommonStaticInfoService.schedules(crossId, signalIc);
}
}
}
}
......
......@@ -52,6 +52,9 @@ public class WanJiCommonStaticInfoServiceImpl implements WanJiCommonStaticInfoSe
CrossIdVO crossIdVO = new CrossIdVO();
crossIdVO.setCrossId(crossId);
JsonViewObject jsonViewObject = utcFeignClientCache.getUtcFeignClientService(manufacturerIdCode).schemePhaseLights(crossIdVO);
if (Objects.isNull(jsonViewObject) || jsonViewObject.getCode() != 200) {
throw new Exception("获取方案数据-方案信息、相位信息、灯组信息远程服务调用异常,异常信息" + jsonViewObject.getMessage());
}
ObjectMapper objectMapper = new ObjectMapper();
SchemePhaseLightsVO content = objectMapper.convertValue(jsonViewObject.getContent(), SchemePhaseLightsVO.class);
List<BaseCrossSchemePO> crossSchemeList = content.getCrossSchemeList();
......@@ -84,9 +87,11 @@ public class WanJiCommonStaticInfoServiceImpl implements WanJiCommonStaticInfoSe
planSectionDTO.setCrossId(crossId);
planSectionDTO.setPlanNo(planNo);
JsonViewObject jsonViewObject = utcFeignClientCache.getUtcFeignClientService(manufacturerIdCode).planSection(planSectionDTO);
if (Objects.isNull(jsonViewObject) || jsonViewObject.getCode() != 200) {
throw new Exception("获取计划数据-计划信息、时段信息远程服务调用异常,异常信息" + jsonViewObject.getMessage());
}
ObjectMapper mapper = new ObjectMapper();
List<PlanSectionVO> content = mapper.convertValue(jsonViewObject.getContent(), new TypeReference<List<PlanSectionVO>>() {
});
List<PlanSectionVO> content = mapper.convertValue(jsonViewObject.getContent(), new TypeReference<List<PlanSectionVO>>() {});
if (!CollectionUtils.isEmpty(content)) {
for (PlanSectionVO planSectionVO : content) {
List<CrossPlanPO> crossPlanPOList = planSectionVO.getCrossPlanPOList();
......@@ -110,15 +115,17 @@ public class WanJiCommonStaticInfoServiceImpl implements WanJiCommonStaticInfoSe
CrossSchedulesDTO crossSchedulesDTO = new CrossSchedulesDTO();
crossSchedulesDTO.setManufacturerCode(manufacturerIdCode);
crossSchedulesDTO.setCrossIdList(Arrays.asList(crossId));
JsonViewObject jsonViewObject = utcFeignClientCache.getUtcFeignClientService(manufacturerIdCode).crossSchedules(crossSchedulesDTO);
JsonViewObject jsonViewObject = utcFeignClientCache.getUtcFeignClientService(manufacturerIdCode).crossSchedules(crossId);
if (Objects.isNull(jsonViewObject) || jsonViewObject.getCode() != 200) {
throw new Exception("获取时间表数据远程服务调用异常,异常信息" + jsonViewObject.getMessage());
}
ObjectMapper mapper = new ObjectMapper();
List<CrossSchedulesPO> content = mapper.convertValue(jsonViewObject.getContent(), new TypeReference<List<CrossSchedulesPO>>() {
});
List<CrossSchedulesPO> content = mapper.convertValue(jsonViewObject.getContent(), new TypeReference<List<CrossSchedulesPO>>() {});
if (Objects.nonNull(content)) {
if (!CollectionUtils.isEmpty(content)) {
crossSchedulesMapper.deleteByCrossId(crossId);
content.forEach(crossSchedulesPO -> {
crossSchedulesMapper.deleteByCrossId(crossId);
crossSchedulesMapper.insertBatch(content);
});
}
......@@ -133,8 +140,4 @@ public class WanJiCommonStaticInfoServiceImpl implements WanJiCommonStaticInfoSe
return paramMap;
}
@Override
public JsonViewObject rpcService(HttpRestUtil httpRestUtil, String url, Map<String, String> headers, String param) {
return WanJiCommonStaticInfoService.super.rpcService(httpRestUtil, url, headers, param);
}
}
spring:
profiles:
active: local
\ No newline at end of file
active: dev
\ No newline at end of file
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