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;
import net.wanji.opt.synthesis.pojo.StrategyControlDataEntity;
import net.wanji.opt.synthesis.pojo.StrategyControlDetailList;
import net.wanji.opt.synthesis.pojo.StrategyControlVO;
import net.wanji.opt.synthesis.pojo.StrategyFactoryEntity;
import net.wanji.opt.synthesis.service.StrategyControlService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
......@@ -100,4 +101,40 @@ public class StrategyControlController {
public JsonViewObject strategyPlanSave(@RequestBody @Validated StrategyControlDetailList list) throws Exception {
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;
import net.wanji.opt.synthesis.pojo.StrategyControlDataEntity;
import net.wanji.opt.synthesis.pojo.StrategyControlDetailList;
import net.wanji.opt.synthesis.pojo.StrategyControlVO;
import net.wanji.opt.synthesis.pojo.StrategyFactoryEntity;
/**
* @author duanruiming
......@@ -18,4 +19,7 @@ public interface StrategyControlService {
JsonViewObject strategyPlanDetail(String crossId) throws Exception;
JsonViewObject strategyPush(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;
import net.wanji.feign.service.UtcFeignClients;
import net.wanji.opt.dao.mapper.StrategyControlInfoMapper;
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.synthesis.pojo.*;
import net.wanji.opt.synthesis.service.PushStrategyControlService;
......@@ -51,6 +52,8 @@ public class StrategyControlServiceImpl implements StrategyControlService {
private UtcFeignClients utcFeignClients;
@Resource
private BaseCrossInfoMapper baseCrossInfoMapper;
@Resource
private StrategyFactoryMapper strategyFactoryMapper;
@Override
......@@ -182,7 +185,8 @@ public class StrategyControlServiceImpl implements StrategyControlService {
result.setTime("");
} else {
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) {
int currentWeek = DateUtil.thisDayOfWeek();
if (currentWeek != timeTable.getWeek()) {
......@@ -192,7 +196,7 @@ public class StrategyControlServiceImpl implements StrategyControlService {
for (String s : timeList) {
String[] hours = s.split(",");
for (String hour : hours) {
String[] currentHour = hour.split("-");
String[] currentHour = hour.split("-");
String startHour = currentHour[0];
String entHour = currentHour[1];
String format = DateUtil.format(current, "HH:mm");
......@@ -235,7 +239,8 @@ public class StrategyControlServiceImpl implements StrategyControlService {
executePlan.setStatus(planInfoEntity.getStatus());
executePlan.setType(planInfoEntity.getType());
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);
executePlans.add(executePlan);
}
......@@ -250,7 +255,8 @@ public class StrategyControlServiceImpl implements StrategyControlService {
dailyPlan.setCrossId(dailyPlanInfoEntity.getCrossId());
dailyPlan.setDailyPlanId(dailyPlanInfoEntity.getDailyPlanId());
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);
dailyPlans.add(dailyPlan);
}
......@@ -446,4 +452,42 @@ public class StrategyControlServiceImpl implements StrategyControlService {
}
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 {
private Integer isCongestion;
@ApiModelProperty(value = "拥堵指数")
private Double congestionIndex;
@ApiModelProperty(value = "失衡指数")
private Double unbalanceIndex;
@ApiModelProperty(value = "溢出指数")
private Double spilloverIndex;
@ApiModelProperty(value = "同比", notes = "同比增长率= (本期数 - 同期数) / 同期数 × 100%;同比:取上一周同一时段数据")
private Double lastWeekIndex;
@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