Commit e713eeef authored by duanruiming's avatar duanruiming

[update] 策略库管理

parent eac82065
package net.wanji.opt.dao.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import net.wanji.opt.synthesis.pojo.StrategyFactoryEntity;
/**
* @author duanruiming
* @date 2024/11/13 13:42
*/
public interface StrategyFactoryMapper extends BaseMapper<StrategyFactoryEntity> {
}
...@@ -9,6 +9,7 @@ import net.wanji.opt.dao.mapper.SynthesisOptimizeLogInfoMapper; ...@@ -9,6 +9,7 @@ import net.wanji.opt.dao.mapper.SynthesisOptimizeLogInfoMapper;
import net.wanji.opt.synthesis.pojo.StrategyControlDataEntity; import net.wanji.opt.synthesis.pojo.StrategyControlDataEntity;
import net.wanji.opt.synthesis.pojo.StrategyControlDetailList; import net.wanji.opt.synthesis.pojo.StrategyControlDetailList;
import net.wanji.opt.synthesis.pojo.StrategyControlVO; import net.wanji.opt.synthesis.pojo.StrategyControlVO;
import net.wanji.opt.synthesis.pojo.StrategyFactoryEntity;
import net.wanji.opt.synthesis.service.StrategyControlService; import net.wanji.opt.synthesis.service.StrategyControlService;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
...@@ -100,4 +101,40 @@ public class StrategyControlController { ...@@ -100,4 +101,40 @@ public class StrategyControlController {
public JsonViewObject strategyPlanSave(@RequestBody @Validated StrategyControlDetailList list) throws Exception { public JsonViewObject strategyPlanSave(@RequestBody @Validated StrategyControlDetailList list) throws Exception {
return strategyControlService.strategyPlanSave(list); return strategyControlService.strategyPlanSave(list);
} }
@ApiOperation(value = "策略库查询列表", notes = "策略库查询列表",
response = JsonViewObject.class,
produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
@GetMapping(value = "/strategyFactoryList")
@ApiResponses({
@ApiResponse(code = 200, message = "OK", response = StrategyFactoryEntity.class),
})
public JsonViewObject strategyFactoryList() throws Exception {
return strategyControlService.strategyFactoryList();
}
@ApiOperation(value = "策略管理计划保存", notes = "策略管理计划列表查询",
response = JsonViewObject.class,
produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
@PostMapping(value = "/strategyFactorySave",
produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
@ApiResponses({
@ApiResponse(code = 200, message = "OK", response = StrategyFactoryEntity.class),
})
public JsonViewObject strategyFactorySave(@RequestBody @Validated StrategyFactoryEntity entity) throws Exception {
return strategyControlService.strategyFactorySave(entity);
}
@ApiOperation(value = "策略管理计划保存", notes = "策略管理计划列表查询",
response = JsonViewObject.class,
produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
@PostMapping(value = "/strategyFactoryDel",
produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
@ApiResponses({
@ApiResponse(code = 200, message = "OK", response = StrategyFactoryEntity.class),
})
public JsonViewObject strategyFactoryDel(@RequestBody Integer id) throws Exception {
return strategyControlService.strategyFactoryDel(id);
}
} }
package net.wanji.opt.synthesis.pojo;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @author duanruiming
* @date 2024/11/13 13:35
*/
@Data
@TableName("t_strategy_factory_info")
@ApiModel(value = "StrategyFactoryEntity", description = "策略库实体")
public class StrategyFactoryEntity {
@ApiModelProperty("自增Id")
@TableId(value = "id", type = IdType.AUTO)
private Integer id;
@ApiModelProperty("场景")
@TableField("scene")
private Integer scene;
@ApiModelProperty("策略")
@TableField("strategy_name")
private String strategyName;
@ApiModelProperty("策略编号")
@TableField("strategy_no")
private String strategyNo;
@ApiModelProperty("算法厂商")
@TableField("company")
private String company;
@ApiModelProperty("备注")
@TableField("mark")
private String mark;
}
...@@ -4,6 +4,7 @@ import net.wanji.common.framework.rest.JsonViewObject; ...@@ -4,6 +4,7 @@ import net.wanji.common.framework.rest.JsonViewObject;
import net.wanji.opt.synthesis.pojo.StrategyControlDataEntity; import net.wanji.opt.synthesis.pojo.StrategyControlDataEntity;
import net.wanji.opt.synthesis.pojo.StrategyControlDetailList; import net.wanji.opt.synthesis.pojo.StrategyControlDetailList;
import net.wanji.opt.synthesis.pojo.StrategyControlVO; import net.wanji.opt.synthesis.pojo.StrategyControlVO;
import net.wanji.opt.synthesis.pojo.StrategyFactoryEntity;
/** /**
* @author duanruiming * @author duanruiming
...@@ -18,4 +19,7 @@ public interface StrategyControlService { ...@@ -18,4 +19,7 @@ public interface StrategyControlService {
JsonViewObject strategyPlanDetail(String crossId) throws Exception; JsonViewObject strategyPlanDetail(String crossId) throws Exception;
JsonViewObject strategyPush(StrategyControlDetailList list) throws Exception; JsonViewObject strategyPush(StrategyControlDetailList list) throws Exception;
JsonViewObject strategyPlanSave(StrategyControlDetailList list) throws Exception; JsonViewObject strategyPlanSave(StrategyControlDetailList list) throws Exception;
JsonViewObject strategyFactoryList() throws Exception;
JsonViewObject strategyFactorySave(StrategyFactoryEntity entity) throws Exception;
JsonViewObject strategyFactoryDel(Integer id) throws Exception;
} }
...@@ -17,6 +17,7 @@ import net.wanji.databus.po.BaseCrossInfoPO; ...@@ -17,6 +17,7 @@ import net.wanji.databus.po.BaseCrossInfoPO;
import net.wanji.feign.service.UtcFeignClients; import net.wanji.feign.service.UtcFeignClients;
import net.wanji.opt.dao.mapper.StrategyControlInfoMapper; import net.wanji.opt.dao.mapper.StrategyControlInfoMapper;
import net.wanji.opt.dao.mapper.StrategyDailyPlanInfoMapper; import net.wanji.opt.dao.mapper.StrategyDailyPlanInfoMapper;
import net.wanji.opt.dao.mapper.StrategyFactoryMapper;
import net.wanji.opt.dao.mapper.StrategyPlanInfoMapper; import net.wanji.opt.dao.mapper.StrategyPlanInfoMapper;
import net.wanji.opt.synthesis.pojo.*; import net.wanji.opt.synthesis.pojo.*;
import net.wanji.opt.synthesis.service.PushStrategyControlService; import net.wanji.opt.synthesis.service.PushStrategyControlService;
...@@ -51,6 +52,8 @@ public class StrategyControlServiceImpl implements StrategyControlService { ...@@ -51,6 +52,8 @@ public class StrategyControlServiceImpl implements StrategyControlService {
private UtcFeignClients utcFeignClients; private UtcFeignClients utcFeignClients;
@Resource @Resource
private BaseCrossInfoMapper baseCrossInfoMapper; private BaseCrossInfoMapper baseCrossInfoMapper;
@Resource
private StrategyFactoryMapper strategyFactoryMapper;
@Override @Override
...@@ -182,7 +185,8 @@ public class StrategyControlServiceImpl implements StrategyControlService { ...@@ -182,7 +185,8 @@ public class StrategyControlServiceImpl implements StrategyControlService {
result.setTime(""); result.setTime("");
} else { } else {
String time = entity.getTime(); String time = entity.getTime();
List<StrategyControlDataVO.TimeTable> timeTables = instance.readValue(time, new TypeReference<List<StrategyControlDataVO.TimeTable>>() {}); List<StrategyControlDataVO.TimeTable> timeTables = instance.readValue(time, new TypeReference<List<StrategyControlDataVO.TimeTable>>() {
});
for (StrategyControlDataVO.TimeTable timeTable : timeTables) { for (StrategyControlDataVO.TimeTable timeTable : timeTables) {
int currentWeek = DateUtil.thisDayOfWeek(); int currentWeek = DateUtil.thisDayOfWeek();
if (currentWeek != timeTable.getWeek()) { if (currentWeek != timeTable.getWeek()) {
...@@ -235,7 +239,8 @@ public class StrategyControlServiceImpl implements StrategyControlService { ...@@ -235,7 +239,8 @@ public class StrategyControlServiceImpl implements StrategyControlService {
executePlan.setStatus(planInfoEntity.getStatus()); executePlan.setStatus(planInfoEntity.getStatus());
executePlan.setType(planInfoEntity.getType()); executePlan.setType(planInfoEntity.getType());
String planDetailsStr = planInfoEntity.getPlanDetails(); String planDetailsStr = planInfoEntity.getPlanDetails();
List<StrategyControlDetailList.ExecutePlan.PlanDetail> planDetails = instance.readValue(planDetailsStr, new TypeReference<List<StrategyControlDetailList.ExecutePlan.PlanDetail>>() {}); List<StrategyControlDetailList.ExecutePlan.PlanDetail> planDetails = instance.readValue(planDetailsStr, new TypeReference<List<StrategyControlDetailList.ExecutePlan.PlanDetail>>() {
});
executePlan.setPlanDetails(planDetails); executePlan.setPlanDetails(planDetails);
executePlans.add(executePlan); executePlans.add(executePlan);
} }
...@@ -250,7 +255,8 @@ public class StrategyControlServiceImpl implements StrategyControlService { ...@@ -250,7 +255,8 @@ public class StrategyControlServiceImpl implements StrategyControlService {
dailyPlan.setCrossId(dailyPlanInfoEntity.getCrossId()); dailyPlan.setCrossId(dailyPlanInfoEntity.getCrossId());
dailyPlan.setDailyPlanId(dailyPlanInfoEntity.getDailyPlanId()); dailyPlan.setDailyPlanId(dailyPlanInfoEntity.getDailyPlanId());
String dailyPlanDetailsStr = dailyPlanInfoEntity.getDailyPlanDetails(); String dailyPlanDetailsStr = dailyPlanInfoEntity.getDailyPlanDetails();
List<StrategyControlDetailList.DailyPlan.DailyPlanDetail> dailyPlanDetails = instance.readValue(dailyPlanDetailsStr, new TypeReference<List<StrategyControlDetailList.DailyPlan.DailyPlanDetail>>() {}); List<StrategyControlDetailList.DailyPlan.DailyPlanDetail> dailyPlanDetails = instance.readValue(dailyPlanDetailsStr, new TypeReference<List<StrategyControlDetailList.DailyPlan.DailyPlanDetail>>() {
});
dailyPlan.setDailyPlanDetails(dailyPlanDetails); dailyPlan.setDailyPlanDetails(dailyPlanDetails);
dailyPlans.add(dailyPlan); dailyPlans.add(dailyPlan);
} }
...@@ -446,4 +452,42 @@ public class StrategyControlServiceImpl implements StrategyControlService { ...@@ -446,4 +452,42 @@ public class StrategyControlServiceImpl implements StrategyControlService {
} }
return null; return null;
} }
@Override
public JsonViewObject strategyFactoryList() throws Exception {
List<StrategyFactoryEntity> strategyFactoryEntities = strategyFactoryMapper.selectList(null);
JsonViewObject jsonViewObject = JsonViewObject.newInstance();
jsonViewObject.success(strategyFactoryEntities);
return jsonViewObject;
}
@Override
public JsonViewObject strategyFactorySave(StrategyFactoryEntity entity) throws Exception {
JsonViewObject jsonViewObject = JsonViewObject.newInstance();
try {
if (Objects.nonNull(entity.getId())) {
strategyFactoryMapper.updateById(entity);
} else {
strategyFactoryMapper.insert(entity);
}
} catch (Exception e) {
log.error("策略库保存失败:{}", e);
jsonViewObject.success("策略库保存失败");
}
return jsonViewObject.success("策略库保存成功");
}
@Override
public JsonViewObject strategyFactoryDel(Integer id) throws Exception {
JsonViewObject jsonViewObject = JsonViewObject.newInstance();
try {
StrategyFactoryEntity strategyFactoryEntity = new StrategyFactoryEntity();
strategyFactoryEntity.setId(id);
strategyFactoryMapper.deleteById(strategyFactoryEntity);
} catch (Exception e) {
log.error("策略库策略删除失败:{}", e);
jsonViewObject.success("策略库策略删除失败");
}
return jsonViewObject.success("策略库删除成功");
}
} }
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="net.wanji.opt.dao.mapper.StrategyFactoryMapper">
</mapper>
\ No newline at end of file
...@@ -52,6 +52,10 @@ public class AbnormalCrossListVO { ...@@ -52,6 +52,10 @@ public class AbnormalCrossListVO {
private Integer isCongestion; private Integer isCongestion;
@ApiModelProperty(value = "拥堵指数") @ApiModelProperty(value = "拥堵指数")
private Double congestionIndex; private Double congestionIndex;
@ApiModelProperty(value = "失衡指数")
private Double unbalanceIndex;
@ApiModelProperty(value = "溢出指数")
private Double spilloverIndex;
@ApiModelProperty(value = "同比", notes = "同比增长率= (本期数 - 同期数) / 同期数 × 100%;同比:取上一周同一时段数据") @ApiModelProperty(value = "同比", notes = "同比增长率= (本期数 - 同期数) / 同期数 × 100%;同比:取上一周同一时段数据")
private Double lastWeekIndex; private Double lastWeekIndex;
@ApiModelProperty(value = "环比", notes = "增长率= (本期数 - 上期数) / 上期数 × 100%;环比:取上一时段数据") @ApiModelProperty(value = "环比", notes = "增长率= (本期数 - 上期数) / 上期数 × 100%;环比:取上一时段数据")
......
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