Commit 8b62f4fa authored by wangyecheng's avatar wangyecheng

策略管理参数配置推送神思

parent b08bf513
package net.wanji.opt.entity.strategy;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.List;
/*
* 调度参数配置推送神思
* */
@Data
@EqualsAndHashCode(callSuper = false)
public class SchedulingParamPush {
//开始参数
private List<StrategySchedulingItem> start;
//停止参数
private List<StrategySchedulingItem> end;
}
package net.wanji.opt.entity.strategy;
import lombok.Data;
import lombok.EqualsAndHashCode;
/*
* 参数配置详情推送神思
* */
@Data
@EqualsAndHashCode(callSuper = false)
public class StrategyParamDetailsPush {
//参数中文名称
private String paramCN;
//参数英文名称
private String paramEN;
//参数数据类型
private String dataType;
//参数描述
private String description;
//参数阈值[1,3]
private String threshold;
//参数值
private String value;
}
package net.wanji.opt.entity.strategy;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.List;
/*
* 参数配置推送神思最外层
* */
@Data
@EqualsAndHashCode(callSuper = false)
public class StrategyParameterPush {
//1-路口;2干线
private int type;
//干线编号
private List<Integer> greenId;
//路口编号
private List<String> crossId;
//策略唯一编号
private String strategyNo;
//策略名称
private String strategyName;
//场景 编号
private Integer scene;
//场景名称
private String method;
//参数配置
private List<StrategyParamDetailsPush> paramDetails;
//策略调度参数启停
private SchedulingParamPush schedulingParam;
}
...@@ -45,6 +45,12 @@ public class StrategyPriorityGroup { ...@@ -45,6 +45,12 @@ public class StrategyPriorityGroup {
//干线 IDs //干线 IDs
private List<Integer> greenIds; private List<Integer> greenIds;
//策略名称 参数配置神思用
private String strategyName;
//场景 参数配置神思用
private String method;
//场景code 参数配置神思用
private Integer scene;
} }
...@@ -42,7 +42,7 @@ public interface StrategyPriorityService extends IService<StrategyPriorityDailyI ...@@ -42,7 +42,7 @@ public interface StrategyPriorityService extends IService<StrategyPriorityDailyI
List<StrategyPriorityDailyInfo> getPlanConfigData(String crossId, Integer greenId,Integer type); List<StrategyPriorityDailyInfo> getPlanConfigData(String crossId, Integer greenId,Integer type);
void saveParamterConfig(StrategyPriorityGroup strategyPriorityGroup) throws JsonProcessingException; void saveParamterConfig(StrategyPriorityGroup strategyPriorityGroup) throws Exception;
List<StrategyParameterConfig> getParamConfigData(String crossId,Integer greenId, Integer type); List<StrategyParameterConfig> getParamConfigData(String crossId,Integer greenId, Integer type);
......
...@@ -333,7 +333,7 @@ import java.util.stream.Collectors; ...@@ -333,7 +333,7 @@ import java.util.stream.Collectors;
* */ * */
@Override @Override
@Transactional @Transactional
public void saveParamterConfig(StrategyPriorityGroup group) throws JsonProcessingException { public void saveParamterConfig(StrategyPriorityGroup group) throws Exception {
try { try {
List<StrategyParameterConfig> savePlanList = new ArrayList<>(); List<StrategyParameterConfig> savePlanList = new ArrayList<>();
...@@ -402,6 +402,10 @@ import java.util.stream.Collectors; ...@@ -402,6 +402,10 @@ import java.util.stream.Collectors;
} }
strategyPriorityMapper.saveParamConfig(savePlanList); strategyPriorityMapper.saveParamConfig(savePlanList);
//组装神思需要的参数配置接口
StrategyParameterPush strategyParameterPush = pushStrategyPriorityParam(group);
//推送神思
//Result result = pushStrategyControlService.StartegyPriorityParameterPush(strategyParameterPush);
}catch (Exception e){ }catch (Exception e){
log.error("{} saveParamterConfig", this.getClass().getSimpleName(), e); log.error("{} saveParamterConfig", this.getClass().getSimpleName(), e);
throw e; throw e;
...@@ -652,4 +656,69 @@ import java.util.stream.Collectors; ...@@ -652,4 +656,69 @@ import java.util.stream.Collectors;
return strategyPriorityPlanPush; return strategyPriorityPlanPush;
} }
/*参数配置神思推送*/
private StrategyParameterPush pushStrategyPriorityParam(StrategyPriorityGroup group) {
//推送神思接口
StrategyParameterPush strategyParameterPush= new StrategyParameterPush();
//类型:1路口 2 干线
Integer type = group.getType();
//路口id
List<String>crossIds=group.getCrossIds();
//干线id
List<Integer>greenIds=group.getGreenIds();
//策略编号
String strategyNo = group.getStrategyNo();
//策略名称
String strategyName = group.getStrategyName();
//场景编号
Integer scene = group.getScene();
//场景名称
String method = group.getMethod();
//1 路口 2干线
if (type==1){
strategyParameterPush.setType(1);
strategyParameterPush.setGreenId(null);
strategyParameterPush.setCrossId(crossIds);
}else {
strategyParameterPush.setType(2);
strategyParameterPush.setGreenId(greenIds);
strategyParameterPush.setCrossId(null);
}
strategyParameterPush.setStrategyNo(strategyNo);
strategyParameterPush.setStrategyName(strategyName);
strategyParameterPush.setScene(scene);
strategyParameterPush.setMethod(method);
//参数详情
List<StrategyParamDetailsPush> strategyParamDetailsList =new ArrayList<>();
//参数详情
List<StrategyPriorityParamter> parameterConfigList = group.getParameterConfigList();
for (StrategyPriorityParamter item:parameterConfigList){
StrategyParamDetailsPush strategyParamDetailsPush = new StrategyParamDetailsPush();
strategyParamDetailsPush.setParamEN(item.getParamEN());
strategyParamDetailsPush.setParamCN(item.getParamCN());
strategyParamDetailsPush.setDescription(item.getDescription());
strategyParamDetailsPush.setDataType(item.getDataType());
strategyParamDetailsPush.setThreshold(item.getThreshold());
strategyParamDetailsPush.setValue(item.getValue());
strategyParamDetailsList.add(strategyParamDetailsPush);
}
strategyParameterPush.setParamDetails(strategyParamDetailsList);
if(type==1){
//取出调度详情
StrategySchedulingParam schedulingParamters = group.getSchedulingParamters();
List<StrategySchedulingItem> start = schedulingParamters.getStart();
List<StrategySchedulingItem> end = schedulingParamters.getEnd();
//组装调度详情
SchedulingParamPush schedulingParamPush = new SchedulingParamPush();
schedulingParamPush.setStart(start);
schedulingParamPush.setEnd(end);
strategyParameterPush.setSchedulingParam(schedulingParamPush);
}else {
strategyParameterPush.setSchedulingParam(null);
}
return strategyParameterPush;
}
} }
package net.wanji.opt.synthesis.service; package net.wanji.opt.synthesis.service;
import net.wanji.opt.entity.strategy.StrategyParameterPush;
import net.wanji.opt.entity.strategy.StrategyPriorityConfigPush; import net.wanji.opt.entity.strategy.StrategyPriorityConfigPush;
import net.wanji.opt.entity.strategy.StrategyPriorityPlanPush; import net.wanji.opt.entity.strategy.StrategyPriorityPlanPush;
import net.wanji.opt.synthesis.pojo.Result; import net.wanji.opt.synthesis.pojo.Result;
...@@ -44,5 +45,13 @@ public interface PushStrategyControlService { ...@@ -44,5 +45,13 @@ public interface PushStrategyControlService {
* @throws Exception * @throws Exception
*/ */
Result StartegyPriorityPlanPush(StrategyPriorityPlanPush req) throws Exception; Result StartegyPriorityPlanPush(StrategyPriorityPlanPush req) throws Exception;
/**
* 策略管理参数配置推送
* @param req
* @return
* @throws Exception
*/
Result StartegyPriorityParameterPush(StrategyParameterPush req) throws Exception;
} }
...@@ -5,6 +5,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; ...@@ -5,6 +5,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import net.wanji.common.tool.resttool.RestTemplateTool; 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.entity.strategy.StrategyParameterPush;
import net.wanji.opt.entity.strategy.StrategyPriorityConfigPush; import net.wanji.opt.entity.strategy.StrategyPriorityConfigPush;
import net.wanji.opt.entity.strategy.StrategyPriorityPlanPush; import net.wanji.opt.entity.strategy.StrategyPriorityPlanPush;
import net.wanji.opt.synthesis.pojo.Result; import net.wanji.opt.synthesis.pojo.Result;
...@@ -106,7 +107,6 @@ public class PushStrategyControlServiceImpl implements PushStrategyControlServic ...@@ -106,7 +107,6 @@ public class PushStrategyControlServiceImpl implements PushStrategyControlServic
System.out.println("req~~"+req); System.out.println("req~~"+req);
// 序列化请求参数 // 序列化请求参数
String jsonReq = mapper.writeValueAsString(req); String jsonReq = mapper.writeValueAsString(req);
System.out.println("请求参数: " + jsonReq);
String resultStr = RestTemplateTool.post(switchUrl, jsonReq); String resultStr = RestTemplateTool.post(switchUrl, jsonReq);
if (StringUtils.isNotBlank(resultStr)) { if (StringUtils.isNotBlank(resultStr)) {
log.info("下发神思策略管理日计划配置推送成功,内容: {}", req); log.info("下发神思策略管理日计划配置推送成功,内容: {}", req);
...@@ -121,4 +121,33 @@ public class PushStrategyControlServiceImpl implements PushStrategyControlServic ...@@ -121,4 +121,33 @@ public class PushStrategyControlServiceImpl implements PushStrategyControlServic
throw new Exception(e); throw new Exception(e);
} }
} }
/**
* 策略管理参数配置推送
* @param req
* @return
* @throws Exception
*/
@Override
public Result StartegyPriorityParameterPush(StrategyParameterPush req) throws Exception {
try {
ObjectMapper mapper = JacksonUtils.getInstance();
System.out.println("req~~"+req);
// 序列化请求参数
String jsonReq = mapper.writeValueAsString(req);
String resultStr = RestTemplateTool.post(switchUrl, jsonReq);
if (StringUtils.isNotBlank(resultStr)) {
log.info("下发神思策略管理参数配置推送成功,内容: {}", req);
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);
}
}
} }
...@@ -392,10 +392,10 @@ ...@@ -392,10 +392,10 @@
SELECT t1.green_id as greenId, t4.name as waveName, t1.cross_id as crossId, SELECT t1.green_id as greenId, t4.name as waveName, t1.cross_id as crossId,
t3.name as crossName,t1.sort, t3.name as crossName,t1.sort,
t2.daily_plan_details as dailyPlanDetails t2.daily_plan_details as dailyPlanDetails
FROM t_greenwave_cross t1 FROM t_greenwave_info t4
LEFT JOIN t_strategy_priority_daily_info t2 on t1.cross_id = t2.cross_id and t2.type=2 LEFT JOIN t_greenwave_cross t1 on t1.green_id = t4.id
LEFT JOIN t_base_cross_info t3 on t1.cross_id = t3.id LEFT JOIN t_strategy_priority_daily_info t2 on t1.cross_id = t2.cross_id and t2.type=2
LEFT JOIN t_greenwave_info t4 on t1.green_id = t4.id LEFT JOIN t_base_cross_info t3 on t1.cross_id = t3.id
</select> </select>
<select id="selectGreenPriorityTable" parameterType="map" resultType="net.wanji.opt.entity.strategy.StrategyPriorityConfig"> <select id="selectGreenPriorityTable" parameterType="map" resultType="net.wanji.opt.entity.strategy.StrategyPriorityConfig">
select select
......
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