Commit cc934e34 authored by duanruiming's avatar duanruiming

[add] 策略管理添加计划名称

parent 578967b6
...@@ -23,6 +23,7 @@ public class StrategyControlDetailList { ...@@ -23,6 +23,7 @@ public class StrategyControlDetailList {
@Data @Data
public static class ExecutePlan { public static class ExecutePlan {
private String crossId; private String crossId;
private String name;
private Integer type; private Integer type;
private Integer planId; private Integer planId;
private String company; private String company;
...@@ -43,6 +44,7 @@ public class StrategyControlDetailList { ...@@ -43,6 +44,7 @@ public class StrategyControlDetailList {
@Data @Data
public static class DailyPlan { public static class DailyPlan {
private String crossId; private String crossId;
private String name;
private Integer dailyPlanId; private Integer dailyPlanId;
private List<DailyPlanDetail> dailyPlanDetails; private List<DailyPlanDetail> dailyPlanDetails;
......
...@@ -28,4 +28,6 @@ public class StrategyDailyPlanInfoEntity { ...@@ -28,4 +28,6 @@ public class StrategyDailyPlanInfoEntity {
@ApiModelProperty("dailyPlanDetails") @ApiModelProperty("dailyPlanDetails")
@TableField("daily_plan_details") @TableField("daily_plan_details")
private String dailyPlanDetails; private String dailyPlanDetails;
private String name;
} }
...@@ -42,4 +42,6 @@ public class StrategyPlanInfoEntity { ...@@ -42,4 +42,6 @@ public class StrategyPlanInfoEntity {
@ApiModelProperty("planDetails") @ApiModelProperty("planDetails")
@TableField("plan_details") @TableField("plan_details")
private String planDetails; private String planDetails;
private String name;
} }
...@@ -392,26 +392,67 @@ public class StrategyControlServiceImpl implements StrategyControlService { ...@@ -392,26 +392,67 @@ public class StrategyControlServiceImpl implements StrategyControlService {
} }
} }
//@Override
//public JsonViewObject strategyOptTimes() throws Exception {
// String timeUrl = "http://37.12.182.29:15020/decisionPage/MonitorStrategyOptimizationInfo/getData";
// String timeResult = OkHttpClientUtil.get(timeUrl);
// ObjectMapper mapper = JacksonUtils.getInstance();
// StrategyOptTimesVO strategyOptTimesVO = new StrategyOptTimesVO();
// if (StringUtils.isNotBlank(timeResult)) {
// StrategyOptTimesDTO dto = mapper.readValue(timeResult, StrategyOptTimesDTO.class);
// List<StrategyOptTimesDTO.Detail> content = dto.getContent();
// if (!CollectionUtils.isEmpty(content)) {
// Double totalTime = 0.0;
// int count = 0;
// for (StrategyOptTimesDTO.Detail item : content) {
// totalTime += item.getOptimizeTime();
// count += item.getExecuteNum();
// }
// strategyOptTimesVO.setTimes(totalTime.intValue());
// strategyOptTimesVO.setCount(count);
// }
// }
// return JsonViewObject.newInstance().success(strategyOptTimesVO);
//}
@Override @Override
public JsonViewObject strategyOptTimes() throws Exception { public JsonViewObject strategyOptTimes() throws Exception {
String timeUrl = "http://37.12.182.29:15020/decisionPage/MonitorStrategyOptimizationInfo/getData"; LambdaQueryWrapper<StrategyCrossResultEntity> queryWrapper = new LambdaQueryWrapper<>();
String timeResult = OkHttpClientUtil.get(timeUrl);
ObjectMapper mapper = JacksonUtils.getInstance();
StrategyOptTimesVO strategyOptTimesVO = new StrategyOptTimesVO(); StrategyOptTimesVO strategyOptTimesVO = new StrategyOptTimesVO();
if (StringUtils.isNotBlank(timeResult)) { LocalDateTime midNight = DateUtil.getMidNight();
StrategyOptTimesDTO dto = mapper.readValue(timeResult, StrategyOptTimesDTO.class); queryWrapper.ge(StrategyCrossResultEntity::getIssueTime, midNight);
List<StrategyOptTimesDTO.Detail> content = dto.getContent(); queryWrapper.eq(StrategyCrossResultEntity::getResponseCode, 200);
if (!CollectionUtils.isEmpty(content)) { List<StrategyCrossResultEntity> resultEntityList = strategyCrossResultMapper.selectList(queryWrapper);
Double totalTime = 0.0; if (!CollectionUtils.isEmpty(resultEntityList)) {
int count = 0; // 1:绿灯空放 2:失衡 3:溢出
for (StrategyOptTimesDTO.Detail item : content) { int optCount = 0;
totalTime += item.getOptimizeTime(); int optTime = 0;
count += item.getExecuteNum(); Map<Integer, List<StrategyCrossResultEntity>> typeMap = resultEntityList.stream().collect(Collectors.groupingBy(StrategyCrossResultEntity::getCurrentAlgo));
for (Map.Entry<Integer, List<StrategyCrossResultEntity>> entry : typeMap.entrySet()) {
Integer type = entry.getKey();
List<StrategyCrossResultEntity> value = entry.getValue();
optCount = value.size();
for (StrategyCrossResultEntity entity : value) {
if (Objects.equals(1, type)) {
optTime += Math.abs(entity.getExtendTime());
}
if (Objects.equals(2, type)) {
optTime += entity.getDuration();
}
if (Objects.equals(3, type)) {
Integer rtnType = entity.getRtnType();
if (Objects.equals(1, rtnType)) {
optTime += 1;
}
if (Objects.equals(2, rtnType)) {
optTime += Math.abs(entity.getExtendTime());
}
}
} }
strategyOptTimesVO.setTimes(totalTime.intValue());
strategyOptTimesVO.setCount(count);
} }
strategyOptTimesVO.setCount(optCount);
strategyOptTimesVO.setTimes(optTime);
} }
return JsonViewObject.newInstance().success(strategyOptTimesVO); return JsonViewObject.newInstance().success(strategyOptTimesVO);
} }
...@@ -704,6 +745,7 @@ public class StrategyControlServiceImpl implements StrategyControlService { ...@@ -704,6 +745,7 @@ public class StrategyControlServiceImpl implements StrategyControlService {
planInfoEntity.setStartTime(plan.getStartTime()); planInfoEntity.setStartTime(plan.getStartTime());
planInfoEntity.setEndTime(plan.getEndTime()); planInfoEntity.setEndTime(plan.getEndTime());
planInfoEntity.setCompany(plan.getCompany()); planInfoEntity.setCompany(plan.getCompany());
planInfoEntity.setName(plan.getName());
planInfoEntity.setPlanDetails(mapper.writeValueAsString(plan.getPlanDetails())); planInfoEntity.setPlanDetails(mapper.writeValueAsString(plan.getPlanDetails()));
LambdaQueryWrapper<StrategyPlanInfoEntity> planDel = new LambdaQueryWrapper<>(); LambdaQueryWrapper<StrategyPlanInfoEntity> planDel = new LambdaQueryWrapper<>();
planDel.eq(StrategyPlanInfoEntity::getCrossId, plan.getCrossId()); planDel.eq(StrategyPlanInfoEntity::getCrossId, plan.getCrossId());
...@@ -721,6 +763,7 @@ public class StrategyControlServiceImpl implements StrategyControlService { ...@@ -721,6 +763,7 @@ public class StrategyControlServiceImpl implements StrategyControlService {
StrategyDailyPlanInfoEntity dailyPlanInfoEntity = new StrategyDailyPlanInfoEntity(); StrategyDailyPlanInfoEntity dailyPlanInfoEntity = new StrategyDailyPlanInfoEntity();
dailyPlanInfoEntity.setCrossId(crossId); dailyPlanInfoEntity.setCrossId(crossId);
dailyPlanInfoEntity.setDailyPlanId(dailyPlanId); dailyPlanInfoEntity.setDailyPlanId(dailyPlanId);
dailyPlanInfoEntity.setName(dailyPlan.getName());
LambdaQueryWrapper<StrategyDailyPlanInfoEntity> delete = new LambdaQueryWrapper<>(); LambdaQueryWrapper<StrategyDailyPlanInfoEntity> delete = new LambdaQueryWrapper<>();
delete.eq(StrategyDailyPlanInfoEntity::getCrossId, crossId); delete.eq(StrategyDailyPlanInfoEntity::getCrossId, crossId);
delete.eq(StrategyDailyPlanInfoEntity::getDailyPlanId, dailyPlanId); delete.eq(StrategyDailyPlanInfoEntity::getDailyPlanId, dailyPlanId);
......
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