Commit 5c1a79a2 authored by duanruiming's avatar duanruiming

[update] 策略库管理路网监测接口

parent e713eeef
......@@ -67,6 +67,18 @@ public class StrategyControlController {
return strategyControlService.crossStrategyInfoList(type);
}
@ApiOperation(value = "路网优化监测", notes = "路网优化监测",
response = JsonViewObject.class,
produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
@GetMapping(value = "/crossOptInfoList")
@ApiResponses({
@ApiResponse(code = 200, message = "OK", response = StrategyControlDataEntity.class),
})
public JsonViewObject crossOptInfoList(@RequestParam Integer type) throws Exception {
return strategyControlService.crossOptInfoList(type);
}
@ApiOperation(value = "策略管理计划详情查询", notes = "策略管理计划详情查询",
response = JsonViewObject.class,
produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
......
......@@ -4,6 +4,7 @@ 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 com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import net.wanji.databus.vo.PageVO;
......@@ -28,9 +29,11 @@ public class StrategyControlDataEntity extends PageVO {
private Integer strategy;
/** value = 开始时间日期 */
@TableField("schedule_start")
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date scheduleStart;
/** value = 结束时间日期 */
@TableField("schedule_end")
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date scheduleEnd;
/** value = 日计划表 */
private String time;
......
package net.wanji.opt.synthesis.pojo;
import lombok.Data;
/**
* @author duanruiming
* @date 2024/11/13 19:31
*/
@Data
public class StrategyControlDataExt extends StrategyControlDataEntity{
private String strategyName;
private String optStatus;
}
......@@ -15,6 +15,7 @@ public interface StrategyControlService {
JsonViewObject strategyInfoPageList(StrategyControlDataEntity entity) throws Exception;
JsonViewObject crossStrategyInfoList(Integer type) throws Exception;
JsonViewObject crossOptInfoList(Integer type) throws Exception;
JsonViewObject strategyPlanDetail(String crossId) throws Exception;
JsonViewObject strategyPush(StrategyControlDetailList list) throws Exception;
......
......@@ -170,6 +170,16 @@ public class StrategyControlServiceImpl implements StrategyControlService {
@Override
public JsonViewObject crossStrategyInfoList(Integer type) throws Exception {
try {
List<StrategyControlDataEntity> results = getCurrentStrateInfoList(type);
return JsonViewObject.newInstance().success(results);
} catch (Exception e) {
log.error("策略控制查询列表:{}", e);
throw new RuntimeException(e);
}
}
private List<StrategyControlDataEntity> getCurrentStrateInfoList(Integer type) throws IllegalAccessException, InvocationTargetException, JsonProcessingException {
ObjectMapper instance = JacksonUtils.getInstance();
LambdaQueryWrapper<StrategyControlDataEntity> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(StrategyControlDataEntity::getBizType, type);
......@@ -215,9 +225,39 @@ public class StrategyControlServiceImpl implements StrategyControlService {
result.setCrossName(baseCrossInfoPO.getName());
results.add(result);
}
return JsonViewObject.newInstance().success(results);
return results;
}
@Override
public JsonViewObject crossOptInfoList(Integer type) throws Exception {
JsonViewObject jsonViewObject = JsonViewObject.newInstance();
try {
List<StrategyControlDataEntity> currentStrateInfoList = getCurrentStrateInfoList(type);
List<StrategyControlDataEntity> currentList = currentStrateInfoList.stream()
.filter(entity -> StringUtils.isNotBlank(entity.getTime())
&& entity.getStatus() == 1).collect(Collectors.toList());
List<StrategyFactoryEntity> strategyFactoryEntities = strategyFactoryMapper.selectList(null);
List<StrategyControlDataExt> strategyControlDataExts = new ArrayList<>();
for (StrategyControlDataEntity strategyControlDataEntity : currentList) {
Integer strategy = strategyControlDataEntity.getStrategy();
StrategyControlDataExt strategyControlDataExt = new StrategyControlDataExt();
BeanUtils.copyProperties(strategyControlDataExt, strategyControlDataEntity);
String strategyName = "";
for (StrategyFactoryEntity strategyFactoryEntity : strategyFactoryEntities) {
if (strategy == strategyFactoryEntity.getScene()) {
strategyName = strategyFactoryEntity.getStrategyName();
}
}
strategyControlDataExt.setStrategyName(strategyName);
strategyControlDataExt.setOptStatus("优化中");
strategyControlDataExts.add(strategyControlDataExt);
}
return jsonViewObject.success(strategyControlDataExts, "路网优化监测查询成功");
} catch (Exception e) {
log.error("路网优化监测查询失败: {}", e);
return jsonViewObject.fail("路网优化监测查询失败");
}
}
@Override
public JsonViewObject strategyPlanDetail(String crossId) throws Exception {
......@@ -285,6 +325,10 @@ public class StrategyControlServiceImpl implements StrategyControlService {
planInfoEntity.setEndTime(plan.getEndTime());
planInfoEntity.setCompany(plan.getCompany());
planInfoEntity.setPlanDetails(mapper.writeValueAsString(plan.getPlanDetails()));
LambdaQueryWrapper<StrategyPlanInfoEntity> planDel = new LambdaQueryWrapper<>();
planDel.eq(StrategyPlanInfoEntity::getCrossId, plan.getCrossId());
planDel.eq(StrategyPlanInfoEntity::getPlanId, plan.getPlanId());
strategyPlanInfoMapper.delete(planDel);
strategyPlanInfoMapper.insert(planInfoEntity);
}
}
......
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