Commit 3e539f29 authored by duanruiming's avatar duanruiming

[add] 策略管理添加批量删除

parent badad9ef
...@@ -12,9 +12,8 @@ import java.util.Objects; ...@@ -12,9 +12,8 @@ import java.util.Objects;
@Getter @Getter
@AllArgsConstructor @AllArgsConstructor
public enum OptStatusEnum { public enum OptStatusEnum {
ZERO(0, "未优化"), ZERO(0, "正常"),
ONE(1, "优化中"), ONE(1, "优化中");
TWO(2, "优化完");
private Integer code; private Integer code;
private String desc; private String desc;
......
...@@ -130,25 +130,30 @@ public class CrossIndexServiceImpl implements CrossIndexService { ...@@ -130,25 +130,30 @@ public class CrossIndexServiceImpl implements CrossIndexService {
aiOptResultVO.setId(resultEntity.getCrossId()); aiOptResultVO.setId(resultEntity.getCrossId());
aiOptResultVO.setName(resultEntity.getCrossName()); aiOptResultVO.setName(resultEntity.getCrossName());
Integer currentAlgo = resultEntity.getCurrentAlgo(); Integer currentAlgo = resultEntity.getCurrentAlgo();
if (Objects.nonNull(currentAlgo)) {
aiOptResultVO.setStrategy(currentAlgo); aiOptResultVO.setStrategy(currentAlgo);
// 失衡 均衡调控,其他效率提升 // 失衡 均衡调控,其他效率提升
aiOptResultVO.setOptMethod(Objects.equals(1, currentAlgo) ? StrategyControlEnum.ONE.getMethod() : StrategyControlEnum.TWO.getMethod()); aiOptResultVO.setOptMethod(Objects.equals(1, currentAlgo) ? StrategyControlEnum.ONE.getMethod() : StrategyControlEnum.TWO.getMethod());
// 失衡 优化中,15分钟内,优化中,其他,优化完 // 失衡 优化中,15分钟内,优化中,其他,优化完
aiOptResultVO.setOptStatus(OptStatusEnum.TWO.getCode()); aiOptResultVO.setOptStatus(OptStatusEnum.ZERO.getCode());
if (Objects.equals(1, currentAlgo)) {
Date issueTimeDate = resultEntity.getIssueTime(); Date issueTimeDate = resultEntity.getIssueTime();
//Date issueTimeDate = DateUtils.parseDate(issueTime); Integer countDown = Objects.isNull(resultEntity.getCountDown()) ? 0 : resultEntity.getCountDown();
long optTime = issueTimeDate.getTime(); long optTime = issueTimeDate.getTime();
long currentTimeMillis = System.currentTimeMillis(); long currentTimeMillis = System.currentTimeMillis();
long offset = currentTimeMillis - optTime; long offset = (currentTimeMillis - optTime) / 1000;
if (Objects.equals(1, currentAlgo)) {
if (offset <= 15 * 60 * 1000) { if (offset <= 15 * 60 * 1000) {
aiOptResultVO.setOptStatus(OptStatusEnum.ONE.getCode()); aiOptResultVO.setOptStatus(OptStatusEnum.ONE.getCode());
} }
} else {
if (offset <= countDown ) {
aiOptResultVO.setOptStatus(OptStatusEnum.ONE.getCode());
}
} }
aiOptResultVO.setOptStatusName(Objects.equals(1, currentAlgo) ? OptStatusEnum.ONE.getDesc() : OptStatusEnum.TWO.getDesc()); aiOptResultVO.setOptStatusName(OptStatusEnum.getDesc(aiOptResultVO.getOptStatus()));
if (Objects.isNull(currentAlgo)) { } else {
aiOptResultVO.setOptStatus(-1); aiOptResultVO.setOptStatus(OptStatusEnum.ZERO.getCode());
aiOptResultVO.setOptStatusName(OptStatusEnum.ZERO.getDesc()); aiOptResultVO.setOptStatusName(OptStatusEnum.getDesc(aiOptResultVO.getOptStatus()));
} }
results.add(aiOptResultVO); results.add(aiOptResultVO);
} }
......
...@@ -15,6 +15,8 @@ import org.springframework.web.bind.annotation.*; ...@@ -15,6 +15,8 @@ import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MediaType;
import java.util.Arrays;
import java.util.List;
/** /**
* @author duanruiming * @author duanruiming
...@@ -182,6 +184,19 @@ public class StrategyControlController { ...@@ -182,6 +184,19 @@ public class StrategyControlController {
@ApiResponse(code = 200, message = "OK", response = StrategyFactoryEntity.class), @ApiResponse(code = 200, message = "OK", response = StrategyFactoryEntity.class),
}) })
public JsonViewObject strategyFactoryDel(@Param("id") Integer id) throws Exception { public JsonViewObject strategyFactoryDel(@Param("id") Integer id) throws Exception {
return strategyControlService.strategyFactoryDel(id); return strategyControlService.strategyFactoryDel(Arrays.asList(id));
} }
@ApiOperation(value = "策略管理计划批量删除", notes = "策略管理计划批量删除",
response = JsonViewObject.class,
produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
@PostMapping(value = "/strategyFactoryDelList")
@ApiResponses({
@ApiResponse(code = 200, message = "OK", response = StrategyFactoryEntity.class),
})
public JsonViewObject strategyFactoryDelList(@RequestBody List<Integer> ids) throws Exception {
return strategyControlService.strategyFactoryDel(ids);
}
} }
...@@ -3,10 +3,11 @@ package net.wanji.opt.synthesis.service; ...@@ -3,10 +3,11 @@ package net.wanji.opt.synthesis.service;
import net.wanji.common.framework.rest.JsonViewObject; 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.vo.StrategyControlVO;
import net.wanji.opt.synthesis.pojo.StrategyFactoryEntity; import net.wanji.opt.synthesis.pojo.StrategyFactoryEntity;
import net.wanji.opt.synthesis.pojo.vo.StrategyControlVO;
import net.wanji.opt.synthesis.pojo.vo.StrategyFactoryQueryVO; import net.wanji.opt.synthesis.pojo.vo.StrategyFactoryQueryVO;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/** /**
* @author duanruiming * @author duanruiming
...@@ -16,15 +17,24 @@ public interface StrategyControlService { ...@@ -16,15 +17,24 @@ public interface StrategyControlService {
JsonViewObject strategyInfoOperation(StrategyControlVO strategyControlVO) throws Exception; JsonViewObject strategyInfoOperation(StrategyControlVO strategyControlVO) throws Exception;
JsonViewObject strategyInfoPageList(StrategyControlDataEntity entity) throws Exception; JsonViewObject strategyInfoPageList(StrategyControlDataEntity entity) throws Exception;
JsonViewObject crossStrategyInfoList(Integer type) throws Exception; JsonViewObject crossStrategyInfoList(Integer type) throws Exception;
JsonViewObject strategyOptTimes() throws Exception; JsonViewObject strategyOptTimes() throws Exception;
JsonViewObject crossStrategyHistList(Integer strategyType, Integer groupType, Integer resultType) throws Exception; JsonViewObject crossStrategyHistList(Integer strategyType, Integer groupType, Integer resultType) throws Exception;
JsonViewObject crossOptInfoList(Integer type) throws Exception; JsonViewObject crossOptInfoList(Integer type) throws Exception;
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(StrategyFactoryQueryVO vo) throws Exception; JsonViewObject strategyFactoryList(StrategyFactoryQueryVO vo) throws Exception;
JsonViewObject strategyFactorySave(StrategyFactoryEntity entity) throws Exception; JsonViewObject strategyFactorySave(StrategyFactoryEntity entity) throws Exception;
JsonViewObject strategyFactoryDel(Integer id) throws Exception;
JsonViewObject strategyFactoryDel(List<Integer> ids) throws Exception;
} }
...@@ -913,12 +913,12 @@ public class StrategyControlServiceImpl implements StrategyControlService { ...@@ -913,12 +913,12 @@ public class StrategyControlServiceImpl implements StrategyControlService {
} }
@Override @Override
public JsonViewObject strategyFactoryDel(Integer id) throws Exception { public JsonViewObject strategyFactoryDel(List<Integer> ids) throws Exception {
JsonViewObject jsonViewObject = JsonViewObject.newInstance(); JsonViewObject jsonViewObject = JsonViewObject.newInstance();
try { try {
StrategyFactoryEntity strategyFactoryEntity = new StrategyFactoryEntity(); if (!CollectionUtils.isEmpty(ids)) {
strategyFactoryEntity.setId(id); strategyFactoryMapper.deleteBatchIds(ids);
strategyFactoryMapper.deleteById(strategyFactoryEntity); }
} catch (Exception e) { } catch (Exception e) {
log.error("策略库策略删除失败:{}", e); log.error("策略库策略删除失败:{}", e);
jsonViewObject.success("策略库策略删除失败"); jsonViewObject.success("策略库策略删除失败");
......
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