Commit 13a88c79 authored by duanruiming's avatar duanruiming

[update] 策略下发保存优化

parent f5e8be54
...@@ -12,9 +12,10 @@ import net.wanji.common.enums.DateStyle; ...@@ -12,9 +12,10 @@ import net.wanji.common.enums.DateStyle;
import net.wanji.common.framework.Constants; import net.wanji.common.framework.Constants;
import net.wanji.common.framework.rest.JsonViewObject; import net.wanji.common.framework.rest.JsonViewObject;
import net.wanji.common.utils.tool.JacksonUtils; import net.wanji.common.utils.tool.JacksonUtils;
import net.wanji.databus.dao.entity.GreenwaveInfoPO;
import net.wanji.databus.dao.mapper.BaseCrossInfoMapper; import net.wanji.databus.dao.mapper.BaseCrossInfoMapper;
import net.wanji.databus.dao.mapper.GreenwaveInfoMapper;
import net.wanji.databus.po.BaseCrossInfoPO; 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.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.StrategyFactoryMapper;
...@@ -29,6 +30,7 @@ import org.springframework.util.CollectionUtils; ...@@ -29,6 +30,7 @@ import org.springframework.util.CollectionUtils;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -49,11 +51,11 @@ public class StrategyControlServiceImpl implements StrategyControlService { ...@@ -49,11 +51,11 @@ public class StrategyControlServiceImpl implements StrategyControlService {
@Resource @Resource
private StrategyDailyPlanInfoMapper strategyDailyPlanInfoMapper; private StrategyDailyPlanInfoMapper strategyDailyPlanInfoMapper;
@Resource @Resource
private UtcFeignClients utcFeignClients;
@Resource
private BaseCrossInfoMapper baseCrossInfoMapper; private BaseCrossInfoMapper baseCrossInfoMapper;
@Resource @Resource
private StrategyFactoryMapper strategyFactoryMapper; private StrategyFactoryMapper strategyFactoryMapper;
@Resource
private GreenwaveInfoMapper greenwaveInfoMapper;
@Override @Override
...@@ -107,20 +109,8 @@ public class StrategyControlServiceImpl implements StrategyControlService { ...@@ -107,20 +109,8 @@ public class StrategyControlServiceImpl implements StrategyControlService {
List<StrategyControlDataReq> dataReqList = new ArrayList<>(dataList.size()); List<StrategyControlDataReq> dataReqList = new ArrayList<>(dataList.size());
for (StrategyControlDataVO dataVO : dataList) { for (StrategyControlDataVO dataVO : dataList) {
StrategyControlDataReq detailData = new StrategyControlDataReq(); StrategyControlDataReq detailData = new StrategyControlDataReq();
detailData.setBiz_id(dataVO.getBizId());
detailData.setBiz_type(dataVO.getBizType()); detailData.setBiz_type(dataVO.getBizType());
//try {
// if (0 == dataVO.getBizType()) {
// CrossIdBO crossIdBO = new CrossIdBO();
// crossIdBO.setCrossId(dataVO.getBizId());
// JsonViewObject jsonViewObject = utcFeignClients.crossInfoById(crossIdBO);
// Object content = jsonViewObject.getContent();
// CrossInfoPO crossInfoPO = instance.readValue(String.valueOf(content), CrossInfoPO.class);
// detailData.setBiz_id(crossInfoPO.getCode());
// }
//} catch (JsonProcessingException e) {
// detailData.setBiz_id(null);
//}
detailData.setBiz_id("311358");
detailData.setStrategy(dataVO.getStrategy()); detailData.setStrategy(dataVO.getStrategy());
detailData.setSchedule_start(DateUtil.format(dataVO.getScheduleStart(), DateStyle.YYYY_MM_DD_HH_MM_SS.getValue())); detailData.setSchedule_start(DateUtil.format(dataVO.getScheduleStart(), DateStyle.YYYY_MM_DD_HH_MM_SS.getValue()));
detailData.setSchedule_end(DateUtil.format(dataVO.getScheduleEnd(), DateStyle.YYYY_MM_DD_HH_MM_SS.getValue())); detailData.setSchedule_end(DateUtil.format(dataVO.getScheduleEnd(), DateStyle.YYYY_MM_DD_HH_MM_SS.getValue()));
...@@ -179,7 +169,7 @@ public class StrategyControlServiceImpl implements StrategyControlService { ...@@ -179,7 +169,7 @@ public class StrategyControlServiceImpl implements StrategyControlService {
} }
} }
private List<StrategyControlDataEntity> getCurrentStrateInfoList(Integer type) throws IllegalAccessException, InvocationTargetException, JsonProcessingException { private List<StrategyControlDataEntity> getCurrentStrateInfoList(Integer type) throws Exception {
ObjectMapper instance = JacksonUtils.getInstance(); ObjectMapper instance = JacksonUtils.getInstance();
LambdaQueryWrapper<StrategyControlDataEntity> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<StrategyControlDataEntity> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(StrategyControlDataEntity::getBizType, type); queryWrapper.eq(StrategyControlDataEntity::getBizType, type);
...@@ -221,8 +211,14 @@ public class StrategyControlServiceImpl implements StrategyControlService { ...@@ -221,8 +211,14 @@ public class StrategyControlServiceImpl implements StrategyControlService {
} }
} }
} }
BaseCrossInfoPO baseCrossInfoPO = baseCrossInfoMapper.selectById(entity.getBizId()); if (type == 0) {
result.setCrossName(baseCrossInfoPO.getName()); BaseCrossInfoPO baseCrossInfoPO = baseCrossInfoMapper.selectById(entity.getBizId());
result.setCrossName(baseCrossInfoPO.getName());
}
if (type == 1) {
GreenwaveInfoPO greenwaveInfoPO = greenwaveInfoMapper.selectById(Integer.valueOf(entity.getBizId()));
result.setCrossName(greenwaveInfoPO.getName());
}
results.add(result); results.add(result);
} }
return results; return results;
...@@ -233,12 +229,9 @@ public class StrategyControlServiceImpl implements StrategyControlService { ...@@ -233,12 +229,9 @@ public class StrategyControlServiceImpl implements StrategyControlService {
JsonViewObject jsonViewObject = JsonViewObject.newInstance(); JsonViewObject jsonViewObject = JsonViewObject.newInstance();
try { try {
List<StrategyControlDataEntity> currentStrateInfoList = getCurrentStrateInfoList(type); 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<StrategyFactoryEntity> strategyFactoryEntities = strategyFactoryMapper.selectList(null);
List<StrategyControlDataExt> strategyControlDataExts = new ArrayList<>(); List<StrategyControlDataExt> strategyControlDataExts = new ArrayList<>();
for (StrategyControlDataEntity strategyControlDataEntity : currentList) { for (StrategyControlDataEntity strategyControlDataEntity : currentStrateInfoList) {
Integer strategy = strategyControlDataEntity.getStrategy(); Integer strategy = strategyControlDataEntity.getStrategy();
StrategyControlDataExt strategyControlDataExt = new StrategyControlDataExt(); StrategyControlDataExt strategyControlDataExt = new StrategyControlDataExt();
BeanUtils.copyProperties(strategyControlDataExt, strategyControlDataEntity); BeanUtils.copyProperties(strategyControlDataExt, strategyControlDataEntity);
...@@ -249,9 +242,13 @@ public class StrategyControlServiceImpl implements StrategyControlService { ...@@ -249,9 +242,13 @@ public class StrategyControlServiceImpl implements StrategyControlService {
} }
} }
strategyControlDataExt.setStrategyName(strategyName); strategyControlDataExt.setStrategyName(strategyName);
strategyControlDataExt.setOptStatus("优化中"); strategyControlDataExt.setOptStatus("未执行");
if (StringUtils.isNotBlank(strategyControlDataEntity.getTime())) {
strategyControlDataExt.setOptStatus("优化中");
}
strategyControlDataExts.add(strategyControlDataExt); strategyControlDataExts.add(strategyControlDataExt);
} }
strategyControlDataExts.sort(Comparator.comparing(StrategyControlDataExt::getOptStatus));
return jsonViewObject.success(strategyControlDataExts, "路网优化监测查询成功"); return jsonViewObject.success(strategyControlDataExts, "路网优化监测查询成功");
} catch (Exception e) { } catch (Exception e) {
log.error("路网优化监测查询失败: {}", e); log.error("路网优化监测查询失败: {}", e);
...@@ -368,7 +365,7 @@ public class StrategyControlServiceImpl implements StrategyControlService { ...@@ -368,7 +365,7 @@ public class StrategyControlServiceImpl implements StrategyControlService {
planInfoEntity.setCrossId(executePlan.getCrossId()); planInfoEntity.setCrossId(executePlan.getCrossId());
planInfoEntity.setPlanId(executePlan.getPlanId()); planInfoEntity.setPlanId(executePlan.getPlanId());
planInfoEntity.setType(executePlan.getType()); planInfoEntity.setType(executePlan.getType());
planInfoEntity.setCompany("神思"); planInfoEntity.setCompany("A厂商");
planInfoEntity.setStatus(executePlan.getStatus()); planInfoEntity.setStatus(executePlan.getStatus());
planInfoEntity.setStartTime(executePlan.getStartTime()); planInfoEntity.setStartTime(executePlan.getStartTime());
planInfoEntity.setEndTime(executePlan.getEndTime()); planInfoEntity.setEndTime(executePlan.getEndTime());
...@@ -376,7 +373,24 @@ public class StrategyControlServiceImpl implements StrategyControlService { ...@@ -376,7 +373,24 @@ public class StrategyControlServiceImpl implements StrategyControlService {
strategyPlanInfoMapper.insert(planInfoEntity); strategyPlanInfoMapper.insert(planInfoEntity);
StrategyControlVO strategyControlVO = convertDataList(list); StrategyControlVO strategyControlVO = convertDataList(list);
StrategyControlReq req = convertReq(strategyControlVO); StrategyControlReq req = convertReq(strategyControlVO);
log.error(JacksonUtils.getInstance().writeValueAsString(req));
List<StrategyControlDataReq> data = req.getData();
for (StrategyControlDataReq datum : data) {
StrategyControlDataEntity strategyControlDataEntity = new StrategyControlDataEntity();
strategyControlDataEntity.setBizId(datum.getBiz_id());
strategyControlDataEntity.setBizType(datum.getBiz_type());
strategyControlDataEntity.setStrategy(datum.getStrategy());
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
strategyControlDataEntity.setScheduleStart(simpleDateFormat.parse(datum.getSchedule_start()));
strategyControlDataEntity.setScheduleStart(simpleDateFormat.parse(datum.getSchedule_start()));
ObjectMapper instance = JacksonUtils.getInstance();
strategyControlDataEntity.setTime(instance.writeValueAsString(datum.getTime_table()));
strategyControlDataEntity.setFrequency(datum.getStrategy());
strategyControlDataEntity.setStatus(datum.getStatus());
strategyControlInfoMapper.insert(strategyControlDataEntity);
}
log.error("下发神思策略信息详情: {}", JacksonUtils.getInstance().writeValueAsString(req));
//Result result = pushStrategyControlService.push(req); //Result result = pushStrategyControlService.push(req);
Result result = new Result("200", "成功", null); Result result = new Result("200", "成功", null);
if (Objects.nonNull(result)) { if (Objects.nonNull(result)) {
...@@ -447,9 +461,9 @@ public class StrategyControlServiceImpl implements StrategyControlService { ...@@ -447,9 +461,9 @@ public class StrategyControlServiceImpl implements StrategyControlService {
List<StrategyControlDetailList.ExecutePlan.PlanDetail> planDetails = plan.getPlanDetails(); List<StrategyControlDetailList.ExecutePlan.PlanDetail> planDetails = plan.getPlanDetails();
if (!CollectionUtils.isEmpty(planDetails)) { if (!CollectionUtils.isEmpty(planDetails)) {
for (StrategyControlDetailList.ExecutePlan.PlanDetail planDetail : planDetails) { for (StrategyControlDetailList.ExecutePlan.PlanDetail planDetail : planDetails) {
Integer dailyPlanId = planDetail.getDailyPlanId();
List<Integer> weeks = planDetail.getWeeks();
for (StrategyPlanDTO strategyPlanDTO : strategyPlanDTOS) { for (StrategyPlanDTO strategyPlanDTO : strategyPlanDTOS) {
Integer dailyPlanId = planDetail.getDailyPlanId();
List<Integer> weeks = planDetail.getWeeks();
if (dailyPlanId == strategyPlanDTO.getDailyPlanId()) { if (dailyPlanId == strategyPlanDTO.getDailyPlanId()) {
strategyPlanDTO.setPlanId(planId); strategyPlanDTO.setPlanId(planId);
strategyPlanDTO.setStartTime(startTime); strategyPlanDTO.setStartTime(startTime);
...@@ -464,7 +478,7 @@ public class StrategyControlServiceImpl implements StrategyControlService { ...@@ -464,7 +478,7 @@ public class StrategyControlServiceImpl implements StrategyControlService {
} }
} }
List<StrategyControlDataVO> dataList = new ArrayList<>(); List<StrategyControlDataVO> dataList = new ArrayList<>();
for (StrategyPlanDTO strategyPlanDTO : strategyPlanDTOS) { for (StrategyPlanDTO strategyPlanDTO : resultList) {
StrategyControlDataVO dataVO = new StrategyControlDataVO(); StrategyControlDataVO dataVO = new StrategyControlDataVO();
dataVO.setBizId(strategyPlanDTO.getCrossId()); dataVO.setBizId(strategyPlanDTO.getCrossId());
dataVO.setBizType(0); dataVO.setBizType(0);
......
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