Commit 9a8e6f2a authored by zhoushiguang's avatar zhoushiguang
parents 2240007d 2a2ad463
package net.wanji.web.task;
import lombok.extern.slf4j.Slf4j;
import net.wanji.common.framework.rest.JsonViewObject;
import net.wanji.databus.bo.CrossIdBO;
import net.wanji.databus.dao.mapper.BaseCrossInfoMapper;
import net.wanji.databus.po.BaseCrossInfoPO;
import net.wanji.databus.vo.CrossInfoVO;
import net.wanji.web.service.impl.PlanSendServiceImpl;
import org.apache.commons.collections.CollectionUtils;
import org.joda.time.LocalDateTime;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import java.util.ArrayList;
import java.util.List;
/**
* @author zhouleilei
* 信号机同步任务
* @date 2025/02/18 11:35
*/
//@Component
//@RequiredArgsConstructor
@Slf4j
public class SignalSynchronizationTask {
@Autowired
private BaseCrossInfoMapper baseCrossInfoMapper;
@Autowired
private PlanSendServiceImpl planSendService;
@Scheduled(fixedRate = 1 * 1000)
public void syncSignalStatus() {
log.info("===开始同步,当前时间:{}", LocalDateTime.now());
CrossInfoVO crossInfoVO = new CrossInfoVO();
crossInfoVO.setIsSignal(1);
List<BaseCrossInfoPO> baseCrossInfoPOS = baseCrossInfoMapper.selectAll(crossInfoVO);
List<String> errorCrossIds = new ArrayList<>();
List<String> okCrossIds = new ArrayList<>();
if (CollectionUtils.isNotEmpty(baseCrossInfoPOS)) {
baseCrossInfoPOS.forEach(po -> {
CrossIdBO crossIdBO = new CrossIdBO();
crossIdBO.setCrossId(po.getId());
try {
JsonViewObject jsonViewObject = planSendService.syncScheme(crossIdBO);
if (jsonViewObject.getCode() == 200) {
okCrossIds.add(po.getId());
log.info("路口同步成功,路口号:{},时间:{}",po.getId(),LocalDateTime.now());
} else {
errorCrossIds.add(po.getId());
log.error("路口同步失败路口号:{},时间:{}",po.getId(),LocalDateTime.now());
}
} catch (Exception e) {
throw new RuntimeException(e);
}
});
}
log.info("===同步完成,当前时间:{},成功路口:{},失败路口:{}", LocalDateTime.now(), okCrossIds, errorCrossIds);
System.exit(0);
}
}
utc.service.url=http://173.17.0.1:32000/utc
utc.dt.service.url=http://173.17.0.1:39002/utc-dt
utc.hisense.service.url=http://173.17.0.1:39003/utc-hisense
control.url=http://173.17.0.1:32001/web
ehualu.url=http://173.17.0.1:30015
\ No newline at end of file
utc.service.url=http://192.168.150.1:32000/utc
utc.dt.service.url=http://192.168.150.1:39002/utc-dt
utc.hisense.service.url=http://192.168.150.1:39003/utc-hisense
control.url=http://192.168.150.1:32001/web
ehualu.url=http://192.168.150.1:30015
\ No newline at end of file
......@@ -9,6 +9,7 @@ import net.wanji.opt.synthesis.pojo.StrategyFactoryEntity;
import net.wanji.opt.synthesis.pojo.vo.StrategyControlVO;
import net.wanji.opt.synthesis.pojo.vo.StrategyFactoryQueryVO;
import net.wanji.opt.synthesis.service.StrategyControlService;
import net.wanji.opt.vo.StrategyLockSendVO;
import net.wanji.opt.vo.StrategyNameCrossVO;
import org.apache.ibatis.annotations.Param;
import org.springframework.validation.annotation.Validated;
......@@ -17,6 +18,7 @@ import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.ws.rs.core.MediaType;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
/**
......@@ -153,6 +155,30 @@ public class StrategyControlController {
return strategyControlService.strategyFactoryList(vo);
}
@ApiOperation(value = "策略管理-路口详情-策略锁定", notes = "策略管理-路口详情-策略锁定",
response = JsonViewObject.class,
produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
@PostMapping(value = "/strategyLockSend",
produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
@ApiResponses({
@ApiResponse(code = 200, message = "OK", response = StrategyNameCrossVO.class),
})
public JsonViewObject strategyLockCrossInfo(@RequestBody StrategyLockSendVO strategyLockSendVO) throws Exception {
return strategyControlService.strategyLockSend(strategyLockSendVO);
}
@ApiOperation(value = "策略管理-路口详情-策略恢复", notes = "策略管理-路口详情-策略恢复",
response = JsonViewObject.class,
produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
@PostMapping(value = "/strategyLockRecoverSend",
produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
@ApiResponses({
@ApiResponse(code = 200, message = "OK", response = StrategyNameCrossVO.class),
})
public JsonViewObject strategyLockRecoverSend(@RequestBody StrategyLockSendVO strategyLockSendVO) throws Exception {
return strategyControlService.strategyLockRecoverSend(strategyLockSendVO);
}
@ApiOperation(value = "策略管理-路口详情-优化策略查询", notes = "策略管理-路口详情-优化策略查询",
response = JsonViewObject.class,
produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
......
......@@ -6,6 +6,7 @@ import net.wanji.opt.synthesis.pojo.StrategyControlDetailList;
import net.wanji.opt.synthesis.pojo.StrategyFactoryEntity;
import net.wanji.opt.synthesis.pojo.vo.StrategyControlVO;
import net.wanji.opt.synthesis.pojo.vo.StrategyFactoryQueryVO;
import net.wanji.opt.vo.StrategyLockSendVO;
import java.util.List;
......@@ -39,4 +40,8 @@ public interface StrategyControlService {
JsonViewObject strategyFactoryDel(List<Integer> ids) throws Exception;
JsonViewObject strategyNameCrossInfo(String crossId) throws Exception;
JsonViewObject strategyLockSend(StrategyLockSendVO strategyLockSendVO) throws Exception;
JsonViewObject strategyLockRecoverSend(StrategyLockSendVO strategyLockSendVO) throws Exception;
}
package net.wanji.opt.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @author duanruiming
* @date 2025/02/15 14:51
* @description 策略管理-地图路口详情-策略锁定实体
*/
@Data
@ApiModel(value = "StrategyLockSendVO", description = "策略管理-地图路口详情-策略锁定实体")
public class StrategyLockSendVO {
@ApiModelProperty(name = "路口ID",notes = "")
private String crossId;
@ApiModelProperty(name = "锁定时间",notes = "")
private Double lockTime;
@ApiModelProperty(name = "策略编号",notes = "")
private String strategyNo;
}
......@@ -14,5 +14,12 @@ import java.util.List;
@ApiModel(value = "StrategyNameCrossVO", description = "策略管理-路口详情-优化策略返回实体")
public class StrategyNameCrossVO {
private String currentName;
private List<String> strategyNames;
private String strategyNo;
private List<Detail> details;
@Data
public static class Detail {
private String strategyName;
private String strategyNo;
}
}
......@@ -273,9 +273,18 @@ public class SignalStatusServiceImpl implements SignalStatusService {
log.error("海信灯态推送百度失败:{}", e.getMessage());
}
try {
HisenseLightStatusPojo hisenseLightStatusPojo = hisenseLightStatusPojos.get(0);
String bodyStr = hisenseLightStatusPojo.getBody();
List<HisenseLightStatusPojo.Body> bodies = jackson.readValue(bodyStr, new TypeReference<List<HisenseLightStatusPojo.Body>>() {});
for (HisenseLightStatusPojo.Body body : bodies) {
HisenseLightStatusPojo.ContentBody content = body.getContent();
String crossId = content.getCrossId();
if (StringUtils.equalsIgnoreCase("255136", crossId)) {
OkHttpClientUtil.jsonPost(yiGouUrl, jackson.writeValueAsString(hisenseLightStatusPojos));
}
}
} catch (Exception e) {
log.error("海信灯态推送易购失败:{}", e.getMessage());
log.error("海信灯态推送易购失败:{}", e);
}
}
......
......@@ -806,36 +806,37 @@ public class StaticInfoServiceImpl implements StaticInfoService {
element.addElement(HttpConstants.MESSAGETYPE).setText(HttpConstants.MESSAGETYPE_30);
Element messageContent = (Element) document.selectSingleNode(HttpConstants.SYSTEMSCRIPTION_MESSAGECONTENT);
messageContent.addElement(HttpConstants.SPOT).setText(crossInfoPOExt.getCode());
//获取当前运行的方案号
/*
//获取当前运行的方案号 从灯态中获取
Integer integer = planMap.get(crossSchemeRingsDTO.getCrossId());
/*if (ObjectUtil.isEmpty(integer)){
CoordinationStatus coordinationStatus = crossPlan(crossSchemeRingsDTO.getCrossId());
if (ObjectUtil.isEmpty(coordinationStatus)) {
if (ObjectUtil.isEmpty(integer)){
//获取方案号失败
log.error("请求方案环图前,获取当前运行方案号失败,crossId:{}", crossSchemeRingsDTO.getCrossId());
log.error("请求方案环图前,获取当前运行方案号失败,没有该路口的灯态信息,crossId:{}", crossSchemeRingsDTO.getCrossId());
return null;
} else if ("255".equals(coordinationStatus.getCoordPatternStatus())) {
} else if (255 == integer) {
//黃闪
CrossSchemeRings crossSchemeRings = new CrossSchemeRings();
crossSchemeRings.setSpot(crossSchemeRingsDTO.getCrossId());
crossSchemeRings.setPattern(coordinationStatus.getCoordPatternStatus());
crossSchemeRings.setPattern(String.valueOf(integer));
return crossSchemeRings;
}
integer = Integer.valueOf(coordinationStatus.getCoordPatternStatus());
}*/
if (ObjectUtil.isEmpty(integer)){
messageContent.addElement(HttpConstants.PATTERN).setText(String.valueOf(integer));*/
//获取当前运行的方案号 从海信视图获取
CoordinationStatus coordinationStatus = crossPlan(crossSchemeRingsDTO.getCrossId());
if (ObjectUtil.isEmpty(coordinationStatus)) {
//获取方案号失败
log.error("请求方案环图前,获取当前运行方案号失败,没有该路口的灯态信息,crossId:{}", crossSchemeRingsDTO.getCrossId());
log.error("请求方案环图前,获取当前运行方案号失败,crossId:{}", crossSchemeRingsDTO.getCrossId());
return null;
} else if (255 == integer) {
} else if ("255".equals(coordinationStatus.getCoordPatternStatus())) {
//黃闪
CrossSchemeRings crossSchemeRings = new CrossSchemeRings();
crossSchemeRings.setSpot(crossSchemeRingsDTO.getCrossId());
crossSchemeRings.setPattern(String.valueOf(integer));
crossSchemeRings.setPattern(coordinationStatus.getCoordPatternStatus());
return crossSchemeRings;
}
messageContent.addElement(HttpConstants.PATTERN).setText(coordinationStatus.getCoordPatternStatus());
messageContent.addElement(HttpConstants.PATTERN).setText(String.valueOf(integer));
//给海信发送http请求
String post = OkHttpClientUtil.xmlPost(hisenseUrl, document.asXML());
......
......@@ -6,6 +6,7 @@ import net.wanji.common.utils.tool.StringUtils;
import okhttp3.*;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
/**
* @ClassName OkHttpClient
......@@ -48,7 +49,10 @@ public class OkHttpClientUtil {
return null;
}
// 创建 OkHttpClient 实例
OkHttpClient client = new OkHttpClient();
OkHttpClient client = new OkHttpClient().newBuilder()
.connectTimeout(30, TimeUnit.SECONDS)
.readTimeout(30, TimeUnit.SECONDS)
.build();
// 创建请求体
RequestBody body = RequestBody.create(json, MediaType.get("application/json; charset=utf-8"));
// 创建请求
......@@ -66,7 +70,7 @@ public class OkHttpClientUtil {
}
} catch (Exception e) {
log.error("OkHttpClientUtil远程服务url:{}, 调用异常:{}", url, e.getMessage());
throw new Exception();
throw new Exception(e);
}
return null;
}
......
......@@ -325,8 +325,8 @@ public class SignalStatusTask {
} else {
Integer countDown = null;
if (phaseMap.get(dir) instanceof Map) {
Map<Integer, Integer> turnMap = (Map<Integer, Integer>) phaseMap.get(dir);
countDown = turnMap.get(turn);
Map<String, Integer> turnMap = (Map<String, Integer>) phaseMap.get(dir);
countDown = turnMap.get(String.valueOf(turn));
} else {
countDown = (Integer) phaseMap.get(key);
}
......
package net.wanji.utc.util;
import cn.hutool.core.util.ObjectUtil;
import io.swagger.annotations.ApiModelProperty;
import net.wanji.databus.dao.entity.BaseCrossSchemePO;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;
/**
* @ClassName ApiModelPropertyUtils
* @Description 通过反射打印 属性的注解
* @Author zhouleilei
* @Date 2025/2/12 17:22
*/
public class ApiModelPropertyUtils {
public static void main(String[] args) {
// GreenwaveScenePO areaIndex = new GreenwaveScenePO();
// System.out.println(areaIndex.toString().replaceAll("=null",""));
// 替换为你的类
Class<BaseCrossSchemePO> clazz = BaseCrossSchemePO.class;
List<String> list = new ArrayList<>();
// 遍历所有字段
for (Field field : clazz.getDeclaredFields()) {
// 获取 @ApiModelProperty 注解
ApiModelProperty apiModelProperty = field.getAnnotation(ApiModelProperty.class);
if (apiModelProperty != null) {
System.out.print(field.getName() +"\t");
System.out.println(ObjectUtil.isNotEmpty(apiModelProperty.value())?apiModelProperty.value():apiModelProperty.name());
// list.add(apiModelProperty.value());
// 你可以继续打印其他属性如 notes, required 等
}
}
}
}
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