Commit 15230d6d authored by duanruiming's avatar duanruiming

[update] 添加本地配置文件,优化灯态数据解析

parent 4171d22c
...@@ -58,10 +58,11 @@ public class SignalStatusController { ...@@ -58,10 +58,11 @@ public class SignalStatusController {
@ApiResponse(code = 200, message = "OK", response = LightsStatusVO.class) @ApiResponse(code = 200, message = "OK", response = LightsStatusVO.class)
}) })
public JsonViewObject lightStatus() throws Exception { public JsonViewObject lightStatus() throws Exception {
List<LightsStatusVO> lightsStatusVOList = signalStatusService.lightStatus(); // List<LightsStatusVO> lightsStatusVOList = signalStatusService.lightStatus();
List<LightsStatusVO> lightsStatusVOList1 = signalStatusService.lightStatus("12F7L08J8S0");
JsonViewObject jsonViewObject = JsonViewObject.newInstance(); JsonViewObject jsonViewObject = JsonViewObject.newInstance();
return jsonViewObject.success(lightsStatusVOList); return jsonViewObject.success(lightsStatusVOList1);
} }
} }
package net.wanji.utc.service.runninginfo.impl; package net.wanji.utc.service.runninginfo.impl;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import net.wanji.common.framework.rest.JsonViewObject; import net.wanji.common.framework.rest.JsonViewObject;
...@@ -47,14 +49,13 @@ public class WanJiCommonRunningStatusServiceImpl implements WanJiCommonRunningSt ...@@ -47,14 +49,13 @@ public class WanJiCommonRunningStatusServiceImpl implements WanJiCommonRunningSt
@Override @Override
public List<LightsStatusVO> lightsStatus(List<String> crossIdList) throws Exception { public List<LightsStatusVO> lightsStatus(List<String> crossIdList) throws Exception {
Set<String> set = new HashSet<>(); Set<String> set = new HashSet<>();
List<LightsStatusVO> result = new ArrayList<>();
for (String crossId : crossIdList) { for (String crossId : crossIdList) {
String manufacturerIdCode = crossInfoCache.getManufacturerCodeByCrossId(crossId); String manufacturerIdCode = crossInfoCache.getManufacturerCodeByCrossId(crossId);
set.add(manufacturerIdCode); set.add(manufacturerIdCode);
} JsonViewObject jsonViewObject = utcFeignClientCache.getUtcFeignClientService(manufacturerIdCode).lightStatus(crossId);
List<LightsStatusVO> result = new ArrayList<>(); ObjectMapper objectMapper = new ObjectMapper();
for (String manufacturerIdCode : set) { result = objectMapper.convertValue(jsonViewObject.getContent(), new TypeReference<List<LightsStatusVO>>() {});
JsonViewObject jsonViewObject = utcFeignClientCache.getUtcFeignClientService(manufacturerIdCode).lightStatus();
result = (List<LightsStatusVO>) jsonViewObject.getContent();
} }
return result; return result;
} }
......
...@@ -2,7 +2,6 @@ package net.wanji.utc.task; ...@@ -2,7 +2,6 @@ package net.wanji.utc.task;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature; import com.alibaba.fastjson.serializer.SerializerFeature;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import net.wanji.common.framework.rest.JsonViewObject; import net.wanji.common.framework.rest.JsonViewObject;
...@@ -86,7 +85,7 @@ public class SignalStatusTask { ...@@ -86,7 +85,7 @@ public class SignalStatusTask {
} else { } else {
JsonViewObject jsonViewObject = utcDTFeignClients.lightStatus(crossId); JsonViewObject jsonViewObject = utcDTFeignClients.lightStatus(crossId);
ObjectMapper mapper = new ObjectMapper(); ObjectMapper mapper = new ObjectMapper();
lightsStatusVOS = mapper.convertValue(jsonViewObject.getContent(), new TypeReference<List<LightsStatusVO>>() {}); // lightsStatusVOS = mapper.convertValue(jsonViewObject.getContent(), new TypeReference<List<LightsStatusVO>>() {});
} }
long end = System.currentTimeMillis(); long end = System.currentTimeMillis();
log.info("当前路口编号:{},海康返回灯态时间:{}ms", crossId, (end - start)); log.info("当前路口编号:{},海康返回灯态时间:{}ms", crossId, (end - start));
......
spring:
application:
# dubbo启动需要程序名称
name: utc
main:
allow-circular-references: true
cloud:
nacos:
config:
server-addr: 10.102.1.182:8848
file-extension: yaml
group: signal
namespace: signal
username: nacos
password: nacos
\ No newline at end of file
spring: spring:
profiles: profiles:
active: dev active: local
\ No newline at end of file \ 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