Commit 09820db4 authored by zhoushiguang's avatar zhoushiguang

Merge remote-tracking branch 'origin/master'

parents 60049dc9 f2520cc0
...@@ -48,6 +48,7 @@ public class StrategyControlDetailList { ...@@ -48,6 +48,7 @@ public class StrategyControlDetailList {
@Data @Data
public static class DailyPlanDetail { public static class DailyPlanDetail {
private Integer strategy; private Integer strategy;
private String strategyName;
private List<String> times; private List<String> times;
} }
} }
......
package net.wanji.opt.synthesis.pojo;
import lombok.Data;
import java.util.List;
/**
* @author duanruiming
* @date 2025/01/18 13:46
*/
@Data
public class StrategyControlSwitchReq {
private List<Detail> req;
@Data
public static class Detail {
/**
* 路口干线Id
*/
private String biz_id;
/**
* 类型 0-路口 1-干线
*/
private Integer biz_type;
/**
* 策略类型 0-绿波带 1-失衡 2-溢出 3-空放
*/
private Integer strategy;
/**
* 状态(1=开启,0=停止)
*/
private Integer status;
}
}
...@@ -2,11 +2,26 @@ package net.wanji.opt.synthesis.service; ...@@ -2,11 +2,26 @@ package net.wanji.opt.synthesis.service;
import net.wanji.opt.synthesis.pojo.Result; import net.wanji.opt.synthesis.pojo.Result;
import net.wanji.opt.synthesis.pojo.StrategyControlReq; import net.wanji.opt.synthesis.pojo.StrategyControlReq;
import net.wanji.opt.synthesis.pojo.StrategyControlSwitchReq;
/** /**
* @author duanruiming * @author duanruiming
* @date 2024/11/03 14:06 * @date 2024/11/03 14:06
*/ */
public interface PushStrategyControlService { public interface PushStrategyControlService {
/**
* 策略详情推送
* @param req
* @return
* @throws Exception
*/
Result push(StrategyControlReq req) throws Exception; Result push(StrategyControlReq req) throws Exception;
/**
* 策略控制开关推送
* @param req
* @return
* @throws Exception
*/
Result switchPush(StrategyControlSwitchReq req) throws Exception;
} }
...@@ -6,6 +6,7 @@ import net.wanji.common.tool.resttool.RestTemplateTool; ...@@ -6,6 +6,7 @@ import net.wanji.common.tool.resttool.RestTemplateTool;
import net.wanji.common.utils.tool.JacksonUtils; import net.wanji.common.utils.tool.JacksonUtils;
import net.wanji.opt.synthesis.pojo.Result; import net.wanji.opt.synthesis.pojo.Result;
import net.wanji.opt.synthesis.pojo.StrategyControlReq; import net.wanji.opt.synthesis.pojo.StrategyControlReq;
import net.wanji.opt.synthesis.pojo.StrategyControlSwitchReq;
import net.wanji.opt.synthesis.service.PushStrategyControlService; import net.wanji.opt.synthesis.service.PushStrategyControlService;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
...@@ -21,6 +22,8 @@ public class PushStrategyControlServiceImpl implements PushStrategyControlServic ...@@ -21,6 +22,8 @@ public class PushStrategyControlServiceImpl implements PushStrategyControlServic
@Value("${synthesis.strategyUrl}") @Value("${synthesis.strategyUrl}")
private String url; private String url;
@Value("${synthesis.strategySwitchUrl}")
private String switchUrl;
@Override @Override
public Result push(StrategyControlReq req) throws Exception { public Result push(StrategyControlReq req) throws Exception {
//String url = "http://37.12.182.50:8082/api/traffic/strategy/info"; //String url = "http://37.12.182.50:8082/api/traffic/strategy/info";
...@@ -39,4 +42,23 @@ public class PushStrategyControlServiceImpl implements PushStrategyControlServic ...@@ -39,4 +42,23 @@ public class PushStrategyControlServiceImpl implements PushStrategyControlServic
throw new Exception(e); throw new Exception(e);
} }
} }
@Override
public Result switchPush(StrategyControlSwitchReq req) throws Exception {
String switchUrl = "http://37.12.182.50:8082/api/traffic/strategy/control";
try {
ObjectMapper mapper = JacksonUtils.getInstance();
String resultStr = RestTemplateTool.post(switchUrl, mapper.writeValueAsString(req));
if (StringUtils.isNotBlank(resultStr)) {
Result result = mapper.readValue(resultStr, Result.class);
return result;
} else {
log.error("策略控制开关推送url:{}失败:返回数据异常", switchUrl);
return new Result("500", "服务调用失败", null);
}
} catch (Exception e) {
log.error("策略控制开关推送url:{},失败:{}", switchUrl, e);
throw new Exception(e);
}
}
} }
...@@ -746,8 +746,8 @@ public class StrategyControlServiceImpl implements StrategyControlService { ...@@ -746,8 +746,8 @@ public class StrategyControlServiceImpl implements StrategyControlService {
} }
log.error("下发神思策略信息详情: {}", JacksonUtils.getInstance().writeValueAsString(req)); log.error("下发神思策略信息详情: {}", JacksonUtils.getInstance().writeValueAsString(req));
//Result result = pushStrategyControlService.push(req); Result result = pushStrategyControlService.push(req);
Result result = new Result("200", "成功", null); //Result result = new Result("200", "成功", null);
if (Objects.nonNull(result)) { if (Objects.nonNull(result)) {
JsonViewObject jsonViewObject = JsonViewObject.newInstance(); JsonViewObject jsonViewObject = JsonViewObject.newInstance();
jsonViewObject.setCode(Integer.valueOf(result.getCode())); jsonViewObject.setCode(Integer.valueOf(result.getCode()));
......
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