|
@@ -4,18 +4,22 @@ package com.cpp.web.controller.regulation;
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.cpp.common.core.domain.R;
|
|
|
+import com.cpp.common.core.domain.model.LoginUser;
|
|
|
import com.cpp.common.utils.DateUtils;
|
|
|
+import com.cpp.common.utils.SecurityUtils;
|
|
|
import com.cpp.system.service.ISysConfigService;
|
|
|
import com.cpp.web.domain.accuracy.AccuracyPassRate;
|
|
|
import com.cpp.web.domain.enums.DataSourcesEnum;
|
|
|
import com.cpp.web.domain.enums.ForecastTypeEnum;
|
|
|
import com.cpp.web.domain.regulation.TempShortRegulation;
|
|
|
+import com.cpp.web.domain.regulation.TempShortRegulationDetail;
|
|
|
import com.cpp.web.domain.regulation.TempShortUsual;
|
|
|
import com.cpp.web.domain.regulation.TempShortUsualDetail;
|
|
|
import com.cpp.web.domain.station.ElectricField;
|
|
|
import com.cpp.web.domain.station.ForecastPowerShortTermStation;
|
|
|
import com.cpp.web.dto.TempShortRegulationDto;
|
|
|
import com.cpp.web.service.accuracy.AccuracyPassRateService;
|
|
|
+import com.cpp.web.service.regulation.TempShortRegulationDetailService;
|
|
|
import com.cpp.web.service.regulation.TempShortRegulationService;
|
|
|
import com.cpp.web.service.regulation.TempShortUsualDetailService;
|
|
|
import com.cpp.web.service.regulation.TempShortUsualService;
|
|
@@ -47,6 +51,8 @@ public class DqRegulationController {
|
|
|
@Autowired
|
|
|
TempShortRegulationService tempShortRegulationService;
|
|
|
@Autowired
|
|
|
+ TempShortRegulationDetailService tempShortRegulationDetailService;
|
|
|
+ @Autowired
|
|
|
ElectricFieldService electricFieldService;
|
|
|
@Autowired
|
|
|
TempShortUsualService tempShortUsualService;
|
|
@@ -85,30 +91,30 @@ public class DqRegulationController {
|
|
|
accuracySum = 100 - accuracySum / accuracyPassRateList.size();
|
|
|
}
|
|
|
// 获取调控数据
|
|
|
- QueryWrapper<TempShortRegulation> tempShortRegulationQueryWrapper = new QueryWrapper<>();
|
|
|
- tempShortRegulationQueryWrapper.eq("station_code", stationCode);
|
|
|
- tempShortRegulationQueryWrapper.eq("tk_date", DateTimeUtil.getDayStartTime(System.currentTimeMillis()));
|
|
|
- tempShortRegulationQueryWrapper.eq("forecast_date", new Date(time));
|
|
|
- tempShortRegulationQueryWrapper.between("time", new Date(time), new Date(endTime));
|
|
|
- List<TempShortRegulation> tempShortRegulationList = tempShortRegulationService.list(tempShortRegulationQueryWrapper);
|
|
|
+ QueryWrapper<TempShortRegulationDetail> tempShortRegulationDetailQueryWrapper = new QueryWrapper<>();
|
|
|
+ tempShortRegulationDetailQueryWrapper.eq("station_code", stationCode);
|
|
|
+ tempShortRegulationDetailQueryWrapper.eq("tk_date", DateTimeUtil.getDayStartTime(System.currentTimeMillis()));
|
|
|
+ tempShortRegulationDetailQueryWrapper.eq("forecast_date", new Date(time));
|
|
|
+ tempShortRegulationDetailQueryWrapper.between("time", new Date(time), new Date(endTime));
|
|
|
+ List<TempShortRegulationDetail> tempShortRegulationDetailList = tempShortRegulationDetailService.list(tempShortRegulationDetailQueryWrapper);
|
|
|
List<TempShortRegulationDto> tempList = new ArrayList<>();
|
|
|
- if (tempShortRegulationList.size()==96){
|
|
|
- for (TempShortRegulation tempShortRegulation:tempShortRegulationList){
|
|
|
+ if (tempShortRegulationDetailList.size()==96){
|
|
|
+ for (TempShortRegulationDetail tempShortRegulationDetail:tempShortRegulationDetailList){
|
|
|
TempShortRegulationDto tempShortRegulationDto = new TempShortRegulationDto();
|
|
|
- tempShortRegulationDto.setTime(DateUtils.parseDateToStr("HH:mm",tempShortRegulation.getTime()));
|
|
|
- tempShortRegulationDto.setForecastDate(tempShortRegulation.getForecastDate());
|
|
|
- tempShortRegulationDto.setTkDate(tempShortRegulation.getTkDate());
|
|
|
- tempShortRegulationDto.setYsValue(tempShortRegulation.getYsValue());
|
|
|
- tempShortRegulationDto.setTkValue(tempShortRegulation.getTkValue());
|
|
|
- tempShortRegulationDto.setSz(tempShortRegulation.getSz());
|
|
|
- tempShortRegulationDto.setXs(tempShortRegulation.getXs());
|
|
|
+ tempShortRegulationDto.setTime(DateUtils.parseDateToStr("HH:mm",tempShortRegulationDetail.getTime()));
|
|
|
+ tempShortRegulationDto.setForecastDate(tempShortRegulationDetail.getForecastDate());
|
|
|
+ tempShortRegulationDto.setTkDate(tempShortRegulationDetail.getTkDate());
|
|
|
+ tempShortRegulationDto.setYsValue(tempShortRegulationDetail.getYsValue());
|
|
|
+ tempShortRegulationDto.setTkValue(tempShortRegulationDetail.getTkValue());
|
|
|
+ tempShortRegulationDto.setSz(tempShortRegulationDetail.getSz());
|
|
|
+ tempShortRegulationDto.setXs(tempShortRegulationDetail.getXs());
|
|
|
tempShortRegulationDto.setStationCode(stationCode);
|
|
|
tempList.add(tempShortRegulationDto);
|
|
|
}
|
|
|
}
|
|
|
Map<Long, BigDecimal> tkShortMap = new HashMap<>();
|
|
|
- for (TempShortRegulation tempShortRegulation:tempShortRegulationList) {
|
|
|
- tkShortMap.putIfAbsent(tempShortRegulation.getTime().getTime(), tempShortRegulation.getTkValue());
|
|
|
+ for (TempShortRegulationDetail tempShortRegulationDetail:tempShortRegulationDetailList) {
|
|
|
+ tkShortMap.putIfAbsent(tempShortRegulationDetail.getTime().getTime(), tempShortRegulationDetail.getTkValue());
|
|
|
}
|
|
|
// 调控数据
|
|
|
List<List<Object>> tkDataList = new ArrayList<>();
|
|
@@ -141,7 +147,7 @@ public class DqRegulationController {
|
|
|
refDownList.add(xx);
|
|
|
}
|
|
|
|
|
|
- if (tempShortRegulationList.isEmpty()){
|
|
|
+ if (tempShortRegulationDetailList.isEmpty()){
|
|
|
// 使用原始值
|
|
|
TempShortRegulationDto tempShortRegulationDto = new TempShortRegulationDto();
|
|
|
tempShortRegulationDto.setTime(DateUtils.parseDateToStr("HH:mm",new Date(tempTime)));
|
|
@@ -192,34 +198,52 @@ public class DqRegulationController {
|
|
|
}
|
|
|
@PostMapping("/updateDqRegulation")
|
|
|
public R updateDqRegulation(@RequestBody List<TempShortRegulationDto> tempShortRegulationDtoList) {
|
|
|
- // 先删除调控表中已有的数据
|
|
|
+ // 先删除调控明细表中已有的数据
|
|
|
TempShortRegulationDto tempShortRegulationDto = tempShortRegulationDtoList.get(0);
|
|
|
// 调控的预测日期
|
|
|
Date forecastDate = tempShortRegulationDto.getForecastDate();
|
|
|
Date startTime = DateTimeUtil.getDayStartTime(forecastDate.getTime());
|
|
|
Date endTime = DateTimeUtil.getDayLastTime(forecastDate.getTime());
|
|
|
+ QueryWrapper<TempShortRegulationDetail> tempShortRegulationDetailQueryWrapper = new QueryWrapper<>();
|
|
|
+ tempShortRegulationDetailQueryWrapper.eq("station_code", tempShortRegulationDto.getStationCode());
|
|
|
+ tempShortRegulationDetailQueryWrapper.eq("forecast_date", tempShortRegulationDto.getForecastDate());
|
|
|
+ tempShortRegulationDetailQueryWrapper.eq("tk_date", DateTimeUtil.getDayStartTime(System.currentTimeMillis()));
|
|
|
+ tempShortRegulationDetailQueryWrapper.between("time", startTime, endTime);
|
|
|
+ tempShortRegulationDetailService.remove(tempShortRegulationDetailQueryWrapper);
|
|
|
+ // 删除调控主表
|
|
|
QueryWrapper<TempShortRegulation> tempShortRegulationQueryWrapper = new QueryWrapper<>();
|
|
|
tempShortRegulationQueryWrapper.eq("station_code", tempShortRegulationDto.getStationCode());
|
|
|
tempShortRegulationQueryWrapper.eq("forecast_date", tempShortRegulationDto.getForecastDate());
|
|
|
tempShortRegulationQueryWrapper.eq("tk_date", DateTimeUtil.getDayStartTime(System.currentTimeMillis()));
|
|
|
- tempShortRegulationQueryWrapper.between("time", startTime, endTime);
|
|
|
tempShortRegulationService.remove(tempShortRegulationQueryWrapper);
|
|
|
- // 封装新的调控插入数据
|
|
|
- List<TempShortRegulation> tempShortRegulationList = new ArrayList<>();
|
|
|
+
|
|
|
+
|
|
|
+ // 封装新的调控明细插入数据
|
|
|
+ List<TempShortRegulationDetail> tempShortRegulationDetailList = new ArrayList<>();
|
|
|
+ LoginUser loginUser = SecurityUtils.getLoginUser();
|
|
|
for (TempShortRegulationDto tempShortRegulationDto1 : tempShortRegulationDtoList) {
|
|
|
- TempShortRegulation tempShortRegulation = new TempShortRegulation();
|
|
|
- tempShortRegulation.setStationCode(tempShortRegulationDto1.getStationCode());
|
|
|
- tempShortRegulation.setForecastDate(tempShortRegulationDto1.getForecastDate());
|
|
|
- tempShortRegulation.setTkDate(tempShortRegulationDto1.getTkDate());
|
|
|
+ TempShortRegulationDetail tempShortRegulationDetail = new TempShortRegulationDetail();
|
|
|
+ tempShortRegulationDetail.setStationCode(tempShortRegulationDto1.getStationCode());
|
|
|
+ tempShortRegulationDetail.setForecastDate(tempShortRegulationDto1.getForecastDate());
|
|
|
+ tempShortRegulationDetail.setTkDate(tempShortRegulationDto1.getTkDate());
|
|
|
Date time = DateUtil.parse(DateUtil.format(tempShortRegulationDto1.getForecastDate(),"yyyy-MM-dd")+" "+tempShortRegulationDto1.getTime(), "yyyy-MM-dd HH:mm");
|
|
|
- tempShortRegulation.setTime(time);
|
|
|
- tempShortRegulation.setSz(tempShortRegulationDto1.getSz());
|
|
|
- tempShortRegulation.setXs(tempShortRegulationDto1.getXs());
|
|
|
- tempShortRegulation.setTkValue(tempShortRegulationDto1.getTkValue());
|
|
|
- tempShortRegulation.setYsValue(tempShortRegulationDto1.getYsValue());
|
|
|
- tempShortRegulationList.add(tempShortRegulation);
|
|
|
+ tempShortRegulationDetail.setTime(time);
|
|
|
+ tempShortRegulationDetail.setSz(tempShortRegulationDto1.getSz());
|
|
|
+ tempShortRegulationDetail.setXs(tempShortRegulationDto1.getXs());
|
|
|
+ tempShortRegulationDetail.setTkValue(tempShortRegulationDto1.getTkValue());
|
|
|
+ tempShortRegulationDetail.setYsValue(tempShortRegulationDto1.getYsValue());
|
|
|
+ tempShortRegulationDetail.setCreateBy(loginUser.getUsername());
|
|
|
+ tempShortRegulationDetailList.add(tempShortRegulationDetail);
|
|
|
}
|
|
|
- tempShortRegulationService.saveBatch(tempShortRegulationList);
|
|
|
+ tempShortRegulationDetailService.saveBatch(tempShortRegulationDetailList);
|
|
|
+ // 插入调控主表
|
|
|
+ TempShortRegulation tempShortRegulation = new TempShortRegulation();
|
|
|
+ tempShortRegulation.setStationCode(tempShortRegulationDto.getStationCode());
|
|
|
+ tempShortRegulation.setForecastDate(tempShortRegulationDto.getForecastDate());
|
|
|
+ tempShortRegulation.setTkDate(tempShortRegulationDto.getTkDate());
|
|
|
+ tempShortRegulation.setCreateBy(loginUser.getUsername());
|
|
|
+ tempShortRegulationService.save(tempShortRegulation);
|
|
|
+
|
|
|
return R.ok();
|
|
|
}
|
|
|
|