Kaynağa Gözat

增加调控短期主表

xusl 6 ay önce
ebeveyn
işleme
1889b48c9e

+ 57 - 33
cpp-admin/src/main/java/com/cpp/web/controller/regulation/DqRegulationController.java

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

+ 9 - 37
cpp-admin/src/main/java/com/cpp/web/domain/regulation/TempShortRegulation.java

@@ -1,5 +1,7 @@
 package com.cpp.web.domain.regulation;
 package com.cpp.web.domain.regulation;
 
 
+import com.baomidou.mybatisplus.annotation.FieldFill;
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableName;
 import com.baomidou.mybatisplus.annotation.TableName;
 import com.cpp.web.domain.BaseCppEntity;
 import com.cpp.web.domain.BaseCppEntity;
 import com.fasterxml.jackson.annotation.JsonFormat;
 import com.fasterxml.jackson.annotation.JsonFormat;
@@ -13,7 +15,7 @@ import java.math.BigDecimal;
 import java.util.Date;
 import java.util.Date;
 
 
 /**
 /**
- * 临时短期调控
+ * 临时短期调控主表
  *
  *
  * @author tl
  * @author tl
  * @date 2024-09-23 15:28:33
  * @date 2024-09-23 15:28:33
@@ -23,51 +25,21 @@ import java.util.Date;
 @EqualsAndHashCode(callSuper = true)
 @EqualsAndHashCode(callSuper = true)
 @ApiModel(value = "cpp_temp_short_regulation")
 @ApiModel(value = "cpp_temp_short_regulation")
 public class TempShortRegulation extends BaseCppEntity {
 public class TempShortRegulation extends BaseCppEntity {
-
-
-    /**
-     * 预测时间
-     */
-    @ApiModelProperty(value = "预测值时间")
-    private Date time;
-
-
     /**
     /**
-     * 原始值
+     * 调控日
      */
      */
-    @ApiModelProperty(value = "原始值")
-    @Digits(integer = 10, fraction = 2)
-    private BigDecimal ysValue = new BigDecimal(-99);
+    @ApiModelProperty(value = "调控日期")
+    private Date tkDate;
 
 
     /**
     /**
-     * 调控值
-     */
-    @ApiModelProperty(value = "调控值")
-    @Digits(integer = 10, fraction = 2)
-    private BigDecimal tkValue = new BigDecimal(-99);
-    /**
      * 调控的预测日期
      * 调控的预测日期
      */
      */
     @ApiModelProperty(value = "调控日期")
     @ApiModelProperty(value = "调控日期")
     private Date forecastDate;
     private Date forecastDate;
 
 
-    /**
-     * 调控日
-     */
-    @ApiModelProperty(value = "调控日期")
-    private Date tkDate;
 
 
-    /**
-     * 数值
-     */
-    @ApiModelProperty(value = "数值")
-    @Digits(integer = 10, fraction = 2)
-    private BigDecimal sz = new BigDecimal(-99);
+    /** 创建者 */
+    @TableField(value = "create_by" , fill = FieldFill.INSERT)
+    private String createBy;
 
 
-    /**
-     * 系数
-     */
-    @ApiModelProperty(value = "系数")
-    @Digits(integer = 10, fraction = 2)
-    private BigDecimal xs = new BigDecimal(-99);
 }
 }

+ 81 - 0
cpp-admin/src/main/java/com/cpp/web/domain/regulation/TempShortRegulationDetail.java

@@ -0,0 +1,81 @@
+package com.cpp.web.domain.regulation;
+
+import com.baomidou.mybatisplus.annotation.FieldFill;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.cpp.web.domain.BaseCppEntity;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import javax.validation.constraints.Digits;
+import java.math.BigDecimal;
+import java.util.Date;
+
+/**
+ * 临时短期调控明细
+ *
+ * @author tl
+ * @date 2024-09-23 15:28:33
+ */
+@Data
+@TableName("cpp_temp_short_regulation")
+@EqualsAndHashCode(callSuper = true)
+@ApiModel(value = "cpp_temp_short_regulation")
+public class TempShortRegulationDetail extends BaseCppEntity {
+
+    @ApiModelProperty(value = "调控表主键ID")
+    private Long regulationId;
+
+    /**
+     * 预测时间
+     */
+    @ApiModelProperty(value = "预测值时间")
+    private Date time;
+
+
+    /**
+     * 原始值
+     */
+    @ApiModelProperty(value = "原始值")
+    @Digits(integer = 10, fraction = 2)
+    private BigDecimal ysValue = new BigDecimal(-99);
+
+    /**
+     * 调控值
+     */
+    @ApiModelProperty(value = "调控值")
+    @Digits(integer = 10, fraction = 2)
+    private BigDecimal tkValue = new BigDecimal(-99);
+    /**
+     * 调控的预测日期
+     */
+    @ApiModelProperty(value = "调控日期")
+    private Date forecastDate;
+
+    /**
+     * 调控日
+     */
+    @ApiModelProperty(value = "调控日期")
+    private Date tkDate;
+
+    /**
+     * 数值
+     */
+    @ApiModelProperty(value = "数值")
+    @Digits(integer = 10, fraction = 2)
+    private BigDecimal sz = new BigDecimal(-99);
+
+    /**
+     * 系数
+     */
+    @ApiModelProperty(value = "系数")
+    @Digits(integer = 10, fraction = 2)
+    private BigDecimal xs = new BigDecimal(-99);
+
+    /** 创建者 */
+    @TableField(value = "create_by" , fill = FieldFill.INSERT)
+    private String createBy;
+
+}

+ 17 - 0
cpp-admin/src/main/java/com/cpp/web/mapper/regulation/TempShortRegulationDetailMapper.java

@@ -0,0 +1,17 @@
+package com.cpp.web.mapper.regulation;
+
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.cpp.web.domain.regulation.TempShortRegulationDetail;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * 临时短期调控明细mapper
+ *
+ * @author xsl
+ * @date 2022-05-11 09:47:21
+ */
+@Mapper
+public interface TempShortRegulationDetailMapper extends BaseMapper<TempShortRegulationDetail> {
+
+}

+ 14 - 0
cpp-admin/src/main/java/com/cpp/web/service/regulation/TempShortRegulationDetailService.java

@@ -0,0 +1,14 @@
+package com.cpp.web.service.regulation;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.cpp.web.domain.regulation.TempShortRegulationDetail;
+
+/**
+ * cpp_electric_field
+ *
+ * @author tl
+ * @date 2024-09-23 15:28:33
+ */
+public interface TempShortRegulationDetailService extends IService<TempShortRegulationDetail> {
+
+}

+ 21 - 0
cpp-admin/src/main/java/com/cpp/web/service/regulation/impl/TempShortRegulationDetailServiceImpl.java

@@ -0,0 +1,21 @@
+package com.cpp.web.service.regulation.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.cpp.web.domain.regulation.TempShortRegulationDetail;
+import com.cpp.web.mapper.regulation.TempShortRegulationDetailMapper;
+import com.cpp.web.service.regulation.TempShortRegulationDetailService;
+import lombok.RequiredArgsConstructor;
+import org.springframework.stereotype.Service;
+
+
+/**
+ * cpp_electric_field
+ *
+ * @author tl
+ * @date 2024-09-23 15:28:33
+ */
+@Service
+@RequiredArgsConstructor
+public class TempShortRegulationDetailServiceImpl extends ServiceImpl<TempShortRegulationDetailMapper, TempShortRegulationDetail> implements TempShortRegulationDetailService {
+
+}