Browse Source

Merge remote-tracking branch 'origin/master'

tl 6 months ago
parent
commit
f9f99c4769
17 changed files with 826 additions and 236 deletions
  1. 8 0
      cpp-admin/src/main/java/com/cpp/web/controller/overhaulPlan/OverhaulPlanRecordsController.java
  2. 121 7
      cpp-admin/src/main/java/com/cpp/web/controller/regulation/DqRegulationController.java
  3. 3 2
      cpp-admin/src/main/java/com/cpp/web/controller/reportData/ReportDataController.java
  4. 1 1
      cpp-admin/src/main/java/com/cpp/web/domain/overhaulplan/OverhaulPlan.java
  5. 14 3
      cpp-admin/src/main/java/com/cpp/web/domain/overhaulplan/OverhaulPlanRecords.java
  6. 69 0
      cpp-admin/src/main/java/com/cpp/web/domain/regulation/TempShortRegulation.java
  7. 54 0
      cpp-admin/src/main/java/com/cpp/web/dto/TempShortRegulationDto.java
  8. 17 0
      cpp-admin/src/main/java/com/cpp/web/mapper/regulation/TempShortRegulationMapper.java
  9. 5 0
      cpp-admin/src/main/java/com/cpp/web/service/overhaulplan/OverhaulPlanRecordsService.java
  10. 7 0
      cpp-admin/src/main/java/com/cpp/web/service/overhaulplan/OverhaulPlanService.java
  11. 39 1
      cpp-admin/src/main/java/com/cpp/web/service/overhaulplan/impl/OverhaulPlanRecordsServiceImpl.java
  12. 121 10
      cpp-admin/src/main/java/com/cpp/web/service/overhaulplan/impl/OverhaulPlanServiceImpl.java
  13. 14 0
      cpp-admin/src/main/java/com/cpp/web/service/regulation/TempShortRegulationService.java
  14. 21 0
      cpp-admin/src/main/java/com/cpp/web/service/regulation/impl/TempShortRegulationServiceImpl.java
  15. 106 146
      cpp-ui/src/views/maintenancerelated/overhaulplan/index.vue
  16. 3 37
      cpp-ui/src/views/maintenancerelated/overhaulplanrecords/index.vue
  17. 223 29
      cpp-ui/src/views/regulation/dqRegulation/index.vue

+ 8 - 0
cpp-admin/src/main/java/com/cpp/web/controller/overhaulPlan/OverhaulPlanRecordsController.java

@@ -8,6 +8,8 @@ import io.swagger.annotations.ApiOperation;
 import lombok.RequiredArgsConstructor;
 import org.springframework.web.bind.annotation.*;
 
+import java.util.Date;
+
 
 @RestController
 @RequiredArgsConstructor
@@ -24,4 +26,10 @@ public class OverhaulPlanRecordsController {
         return R.ok(overhaulPlanRecordsService.page(page,overhaulPlanRecordsService.getByStationCode(stationCode)));
     }
 
+    @ApiOperation(value = "通过场站编号查询记录(分页查询)", notes = "通过场站编号查询记录(分页查询)")
+    @GetMapping("/findByStationCodeAndTimeBetween")
+    public R findByStationCodeAndTimeBetween(String stationCode, Long startTime,Long endTime){
+        return R.ok(overhaulPlanRecordsService.findByStationCodeAndTimeBetween(stationCode,new Date(startTime),new Date(endTime)));
+    }
+
 }

+ 121 - 7
cpp-admin/src/main/java/com/cpp/web/controller/regulation/DqRegulationController.java

@@ -1,17 +1,32 @@
 package com.cpp.web.controller.regulation;
 
+import cn.hutool.core.date.DatePattern;
+import cn.hutool.core.date.DateTime;
 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.utils.DateUtils;
+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.station.ElectricField;
 import com.cpp.web.domain.station.ForecastPowerShortTermStation;
 import com.cpp.web.domain.station.WeatherStationStatusData;
+import com.cpp.web.dto.TempShortRegulationDto;
+import com.cpp.web.service.accuracy.AccuracyPassRateService;
+import com.cpp.web.service.regulation.TempShortRegulationService;
+import com.cpp.web.service.station.ElectricFieldService;
 import com.cpp.web.service.station.ForecastPowerShortTermStationService;
 import com.cpp.web.utils.DateTimeUtil;
 import lombok.RequiredArgsConstructor;
+import org.checkerframework.checker.units.qual.A;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
+import java.math.BigDecimal;
 import java.util.*;
 
 
@@ -27,24 +42,123 @@ import java.util.*;
 public class DqRegulationController {
     @Autowired
     ForecastPowerShortTermStationService forecastPowerShortTermStationService;
+    @Autowired
+    AccuracyPassRateService accuracyPassRateService;
+    @Autowired
+    TempShortRegulationService tempShortRegulationService;
+    @Autowired
+    ElectricFieldService electricFieldService;
 
 
     @GetMapping("/queryData")
     public R queryData(String stationCode, Long time) {
         int howLongAgo = DateTimeUtil.getDaysBetweenTwoDate(System.currentTimeMillis(),time);
         // 获取要调整的短期那天的最后时间
-        long eneTime = DateTimeUtil.getDayLastTime(time).getTime();
+        long endTime = DateTimeUtil.getDayLastTime(time).getTime();
 
         // 获取短期上报数据(原始数据)
         Map<String, Object> map = new HashMap<>();
-        List<ForecastPowerShortTermStation> forecastPowerShortTermStationList = forecastPowerShortTermStationService.findByForecastTimeBetweenAndForecastHowLongAgoAndStationCode(time, eneTime, howLongAgo, stationCode);
+        List<ForecastPowerShortTermStation> forecastPowerShortTermStationList = forecastPowerShortTermStationService.findByForecastTimeBetweenAndForecastHowLongAgoAndStationCode(time, endTime, howLongAgo, stationCode);
         if (forecastPowerShortTermStationList.size()>0){
-            forecastPowerShortTermStationList.sort(Comparator.comparing(ForecastPowerShortTermStation::getTime));
-            List list  = new ArrayList();
-            for (ForecastPowerShortTermStation forecastPowerShortTermStation:forecastPowerShortTermStationList){
-                list.add(forecastPowerShortTermStation.getFpValue());
+            Map<Long, BigDecimal> ysShortMap = new HashMap<>();
+            for (ForecastPowerShortTermStation forecastPowerShortTermStation:forecastPowerShortTermStationList) {
+                ysShortMap.putIfAbsent(forecastPowerShortTermStation.getTime().getTime(), forecastPowerShortTermStation.getFpValue());
             }
-            map.put("ysData",list);
+            // 获取前30天的准确率生成参考值
+            Date accuracyEndDate = DateUtil.offsetDay(new Date(), -1);
+            Date accuracyStartDate = DateUtil.offsetDay(new Date(), -30);
+
+            List<AccuracyPassRate> accuracyPassRateList = accuracyPassRateService.findByTimeBetweenAndForecastTypeAndDataSourcesAndAgoAndForecastModelAndStationCode(DateTimeUtil.getDayStartTime(accuracyStartDate.getTime()), DateTimeUtil.getDayLastTime(accuracyEndDate.getTime()), ForecastTypeEnum.dq, DataSourcesEnum.E1, howLongAgo, null, stationCode);
+            double accuracySum = 0;
+            if (accuracyPassRateList.size()>0){
+                for (AccuracyPassRate accuracyPassRate:accuracyPassRateList){
+                    accuracySum = accuracySum + Double.parseDouble(accuracyPassRate.getAccuracy().replaceAll("%", ""));
+                }
+                // 计算获取偏差率
+                accuracySum = 100 - accuracySum / accuracyPassRateList.size();
+            }
+            // 获取调控数据
+            QueryWrapper<TempShortRegulation> tempShortRegulationQueryWrapper = new QueryWrapper<>();
+            tempShortRegulationQueryWrapper.eq("station_code", stationCode);
+            tempShortRegulationQueryWrapper.eq("tk_date", new Date(time));
+            tempShortRegulationQueryWrapper.between("time", new Date(time), new Date(endTime));
+            List<TempShortRegulation> tempShortRegulationList = tempShortRegulationService.list(tempShortRegulationQueryWrapper);
+            List<TempShortRegulationDto> tempList = new ArrayList<>();
+            if (tempShortRegulationList.size()==96){
+                for (TempShortRegulation tempShortRegulation:tempShortRegulationList){
+                    TempShortRegulationDto tempShortRegulationDto = new TempShortRegulationDto();
+                    tempShortRegulationDto.setTime(DateUtils.parseDateToStr("HH:mm",tempShortRegulation.getTime()));
+                    tempShortRegulationDto.setTkDate(tempShortRegulation.getTkDate());
+                    tempShortRegulationDto.setYsValue(tempShortRegulation.getYsValue());
+                    tempShortRegulationDto.setTkValue(tempShortRegulation.getTkValue());
+                    tempShortRegulationDto.setSz(tempShortRegulation.getSz());
+                    tempShortRegulationDto.setXs(tempShortRegulation.getXs());
+                    tempList.add(tempShortRegulationDto);
+                }
+            }
+            // 调控数据
+            List<List<Object>> tkDataList = new ArrayList<>();
+            // 原始短期数据
+            List<BigDecimal> ysList = new ArrayList<>();
+            // 参考上限短期
+            List<BigDecimal> refUpList = new ArrayList<>();
+            // 参考下限短期
+            List<BigDecimal> refDownList = new ArrayList<>();
+            ElectricField electricField = electricFieldService.findByStationCode(stationCode);
+            Long momentTime = 15 * 60 * 1000L;
+            for (Long tempTime = time; tempTime <= endTime; tempTime = tempTime + momentTime) {
+                List<Object> listAfter = new ArrayList<>();
+                listAfter.add(DateUtils.parseDateToStr("HH:mm",new Date(tempTime)));
+                listAfter.add(ysShortMap.get(tempTime));
+                tkDataList.add(listAfter);
+
+                if (ysShortMap.get(tempTime)!=null){
+                    ysList.add(ysShortMap.get(tempTime));
+                    if (accuracySum>0){
+                        // 计算出偏差量
+                        BigDecimal baseValue = ysShortMap.get(tempTime).multiply(new BigDecimal(accuracySum).multiply(new BigDecimal("0.01"))).setScale(2, BigDecimal.ROUND_HALF_UP);
+                        // 在原始数据基础上,生成上下限值。
+                        BigDecimal sx = ysShortMap.get(tempTime).add(baseValue).setScale(2, BigDecimal.ROUND_HALF_UP);
+                        if (sx.compareTo(electricField.getCapacity())==1){
+                            sx = electricField.getCapacity();
+                        }
+                        BigDecimal xx = ysShortMap.get(tempTime).subtract(baseValue).setScale(2, BigDecimal.ROUND_HALF_UP);
+                        if (xx.compareTo(new BigDecimal("0"))==-1){
+                            xx = new BigDecimal("0");
+                        }
+                        refUpList.add(sx);
+                        refDownList.add(xx);
+                    }
+
+                    if (tempShortRegulationList.isEmpty()){
+                        // 使用原始值
+                        TempShortRegulationDto tempShortRegulationDto = new TempShortRegulationDto();
+                        tempShortRegulationDto.setTime(DateUtils.parseDateToStr("HH:mm",new Date(tempTime)));
+                        tempShortRegulationDto.setTkDate(new Date(time));
+                        tempShortRegulationDto.setYsValue(ysShortMap.get(tempTime));
+                        tempShortRegulationDto.setTkValue(ysShortMap.get(tempTime));
+                        tempShortRegulationDto.setSz(new BigDecimal("0"));
+                        tempShortRegulationDto.setXs(new BigDecimal("1"));
+                        tempList.add(tempShortRegulationDto);
+                    }
+                }
+                else{
+                    ysList.add(null);
+                    refUpList.add(null);
+                    refDownList.add(null);
+                    listAfter.add(null);
+                }
+            }
+
+            map.put("ysData",ysList);
+            map.put("refUpData",refUpList);
+            map.put("refDownData",refDownList);
+            map.put("tempShortRegulationList",tempList);
+            map.put("tkDataList",tkDataList);
+
+
+            map.put("electricField",electricField);
+
             return R.ok(map);
         }
         else{

+ 3 - 2
cpp-admin/src/main/java/com/cpp/web/controller/reportData/ReportDataController.java

@@ -117,13 +117,14 @@ public class ReportDataController {
     }
 
     /**
-     *  提取文件名中的时间
+     * 提取文件名中的时间
+     *
      * @param fileName
      * @return
      */
     private static String extractAndParseTimestamp(String fileName) {
         String[] fileNameParts = fileName.split("_");
-        String correctTimestampStr = fileNameParts[1]+fileNameParts[2];
+        String correctTimestampStr = fileNameParts[1] + fileNameParts[2];
         return correctTimestampStr;
     }
 }

+ 1 - 1
cpp-admin/src/main/java/com/cpp/web/domain/overhaulplan/OverhaulPlan.java

@@ -62,7 +62,7 @@ public class OverhaulPlan extends BaseCppEntity {
     private Integer maintenanceQuantity;
 
     /**
-     * 状态:0 待执行 1 执行中 2 已完成
+     *  1 执行中 2 已完成
      */
     @ApiModelProperty(value = "状态")
     private Integer status;

+ 14 - 3
cpp-admin/src/main/java/com/cpp/web/domain/overhaulplan/OverhaulPlanRecords.java

@@ -48,10 +48,21 @@ public class OverhaulPlanRecords extends BaseCppEntity {
     private BigDecimal overhaulCapacity;
 
     /**
-     * 使用数据类
+     * 预测模
      */
-    @ApiModelProperty(value = "使用数据类型")
-    private String dataType;
+    @ApiModelProperty(value = "预测模型")
+    private String forecastModel;
 
 
+    /**
+     * 使用次数
+     */
+    @ApiModelProperty(value = "使用次数")
+    private Integer useNum = 0;
+
+    /**
+     * 更新时间
+     */
+    @ApiModelProperty(value = "更新时间")
+    private Date updateTime;
 }

+ 69 - 0
cpp-admin/src/main/java/com/cpp/web/domain/regulation/TempShortRegulation.java

@@ -0,0 +1,69 @@
+package com.cpp.web.domain.regulation;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.cpp.web.domain.BaseCppEntity;
+import com.fasterxml.jackson.annotation.JsonFormat;
+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 TempShortRegulation extends BaseCppEntity {
+
+
+    /**
+     * 预测时间
+     */
+    @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 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);
+}

+ 54 - 0
cpp-admin/src/main/java/com/cpp/web/dto/TempShortRegulationDto.java

@@ -0,0 +1,54 @@
+package com.cpp.web.dto;
+
+
+import lombok.Data;
+
+import javax.validation.constraints.Digits;
+import java.math.BigDecimal;
+import java.util.Date;
+
+/**
+ * 临时短期调控
+ *
+ * @author tl
+ * @date 2024-09-23 15:28:33
+ */
+@Data
+public class TempShortRegulationDto{
+
+
+    /**
+     * 预测时间
+     */
+    private String time;
+
+    /**
+     * 原始值
+     */
+    @Digits(integer = 10, fraction = 2)
+    private BigDecimal ysValue = new BigDecimal(-99);
+
+    /**
+     * 调控值
+     */
+    @Digits(integer = 10, fraction = 2)
+    private BigDecimal tkValue = new BigDecimal(-99);
+
+
+    /**
+     * 调控日期
+     */
+    private Date tkDate;
+
+    /**
+     * 数值
+     */
+    @Digits(integer = 10, fraction = 2)
+    private BigDecimal sz = new BigDecimal(-99);
+
+    /**
+     * 系数
+     */
+    @Digits(integer = 10, fraction = 2)
+    private BigDecimal xs = new BigDecimal(-99);
+}

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

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

+ 5 - 0
cpp-admin/src/main/java/com/cpp/web/service/overhaulplan/OverhaulPlanRecordsService.java

@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
 import com.cpp.web.domain.overhaulplan.OverhaulPlan;
 import com.cpp.web.domain.overhaulplan.OverhaulPlanRecords;
 
+import java.util.Date;
 import java.util.List;
 
 /**
@@ -17,4 +18,8 @@ public interface OverhaulPlanRecordsService extends IService<OverhaulPlanRecords
 
     QueryWrapper<OverhaulPlanRecords> getByStationCode(String stationCode);
 
+    OverhaulPlanRecords findByStationCodeAndForecastModel(String stationCode, String forecastModel, Date startTime,Date endTime);
+
+    List<OverhaulPlanRecords> findByStationCodeAndTimeBetween(String stationCode,Date startTime,Date endTime);
+
 }

+ 7 - 0
cpp-admin/src/main/java/com/cpp/web/service/overhaulplan/OverhaulPlanService.java

@@ -3,7 +3,10 @@ package com.cpp.web.service.overhaulplan;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.cpp.web.domain.overhaulplan.OverhaulPlan;
+import org.apache.poi.ss.formula.functions.T;
 
+import javax.xml.crypto.Data;
+import java.util.Date;
 import java.util.List;
 
 /**
@@ -20,4 +23,8 @@ public interface OverhaulPlanService extends IService<OverhaulPlan> {
 
     List<OverhaulPlan> findByStationCode(String stationCode);
 
+    List<OverhaulPlan> findByStationCodeAndTimeBetween(Date date,String stationCode);
+
+    <T> List<T>  getCorrectionData(List<T> list);
+
 }

+ 39 - 1
cpp-admin/src/main/java/com/cpp/web/service/overhaulplan/impl/OverhaulPlanRecordsServiceImpl.java

@@ -8,6 +8,9 @@ import com.cpp.web.service.overhaulplan.OverhaulPlanRecordsService;
 import lombok.RequiredArgsConstructor;
 import org.springframework.stereotype.Service;
 
+import java.util.Date;
+import java.util.List;
+
 /**
  * cpp_overhaul_plan_records
  *
@@ -18,12 +21,47 @@ import org.springframework.stereotype.Service;
 @RequiredArgsConstructor
 public class OverhaulPlanRecordsServiceImpl extends ServiceImpl<OverhaulPlanRecordsMapper, OverhaulPlanRecords> implements OverhaulPlanRecordsService {
 
+    private final OverhaulPlanRecordsMapper overhaulPlanRecordsMapper;
     @Override
     public QueryWrapper<OverhaulPlanRecords> getByStationCode(String stationCode) {
         QueryWrapper<OverhaulPlanRecords> wrapper = new QueryWrapper<>();
-        if (!"".equals(stationCode)) {
+        if (null != stationCode && !"".equals(stationCode)) {
             wrapper.eq("station_code", stationCode);
         }
         return wrapper;
     }
+
+    @Override
+    public OverhaulPlanRecords findByStationCodeAndForecastModel(String stationCode, String forecastModel, Date startTime, Date endTime) {
+        QueryWrapper wrapper = new QueryWrapper<>();
+        if (null != stationCode && !"".equals(stationCode)){
+            wrapper.eq("station_code",stationCode);
+        }
+        if (null != forecastModel && !"".equals(forecastModel)){
+            wrapper.eq("forecast_model",forecastModel);
+        }
+        if (null != startTime){
+            wrapper.eq("start_time",startTime);
+        }
+        if (null != endTime){
+            wrapper.eq("end_time",endTime);
+        }
+        OverhaulPlanRecords overhaulPlanRecords = overhaulPlanRecordsMapper.selectOne(wrapper);
+        return overhaulPlanRecords;
+    }
+
+    @Override
+    public List<OverhaulPlanRecords> findByStationCodeAndTimeBetween(String stationCode, Date startTime, Date endTime) {
+        QueryWrapper<OverhaulPlanRecords> wrapper = new QueryWrapper<>();
+        if (null != stationCode && !"".equals(stationCode)){
+            wrapper.eq("station_code",stationCode);
+        }
+        if (null != startTime){
+            wrapper.eq("start_time",startTime);
+        }
+        if (null != endTime){
+            wrapper.eq("end_time",endTime);
+        }
+        return overhaulPlanRecordsMapper.selectList(wrapper);
+    }
 }

+ 121 - 10
cpp-admin/src/main/java/com/cpp/web/service/overhaulplan/impl/OverhaulPlanServiceImpl.java

@@ -3,13 +3,22 @@ package com.cpp.web.service.overhaulplan.impl;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.cpp.web.domain.overhaulplan.OverhaulPlan;
+import com.cpp.web.domain.overhaulplan.OverhaulPlanRecords;
 import com.cpp.web.domain.station.ElectricField;
 import com.cpp.web.mapper.overhaulplan.OverhaulPlanMapper;
+import com.cpp.web.service.overhaulplan.OverhaulPlanRecordsService;
 import com.cpp.web.service.overhaulplan.OverhaulPlanService;
-import io.swagger.models.auth.In;
+import com.cpp.web.service.station.ElectricFieldService;
 import lombok.RequiredArgsConstructor;
+import org.apache.poi.ss.formula.functions.T;
+import org.springframework.security.core.parameters.P;
 import org.springframework.stereotype.Service;
 
+import java.lang.reflect.Field;
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+import java.util.ArrayList;
+import java.util.Date;
 import java.util.List;
 
 /**
@@ -23,8 +32,14 @@ import java.util.List;
 public class OverhaulPlanServiceImpl extends ServiceImpl<OverhaulPlanMapper, OverhaulPlan> implements OverhaulPlanService {
 
     private final OverhaulPlanMapper overhaulPlanMapper;
+
+    private final ElectricFieldService electricFieldService;
+
+    private final OverhaulPlanRecordsService overhaulPlanRecordsService;
+
     /**
-     *  查询所有检修计划
+     * 查询所有检修计划
+     *
      * @return
      */
     @Override
@@ -34,21 +49,22 @@ public class OverhaulPlanServiceImpl extends ServiceImpl<OverhaulPlanMapper, Ove
     }
 
     /**
-     *  根据场站编号查询检修计划信息
+     * 根据场站编号查询检修计划信息
+     *
      * @param stationCode
      * @return
      */
     @Override
     public QueryWrapper<OverhaulPlan> getByStationCode(String stationCode, Integer status) {
         QueryWrapper<OverhaulPlan> wrapper = new QueryWrapper<>();
-        if (null != status){
-            if (!"".equals(stationCode)){
-                wrapper.eq("station_code",stationCode);
-                wrapper.eq("status",status);
+        if (null != status) {
+            if (!"".equals(stationCode)) {
+                wrapper.eq("station_code", stationCode);
+                wrapper.eq("status", status);
             }
-        }else {
-            if (!"".equals(stationCode)){
-                wrapper.eq("station_code",stationCode);
+        } else {
+            if (!"".equals(stationCode)) {
+                wrapper.eq("station_code", stationCode);
             }
         }
         return wrapper;
@@ -59,4 +75,99 @@ public class OverhaulPlanServiceImpl extends ServiceImpl<OverhaulPlanMapper, Ove
         List<OverhaulPlan> overhaulPlanList = overhaulPlanMapper.findBysStationCode(stationCode);
         return overhaulPlanList;
     }
+
+    @Override
+    public List<OverhaulPlan> findByStationCodeAndTimeBetween(Date date, String stationCode) {
+        QueryWrapper<OverhaulPlan> wrapper = new QueryWrapper<>();
+        if (null != date) {
+            wrapper.ge("start_time", date);
+            wrapper.le("end_time", date);
+        }
+        if (null != stationCode && !"".equals(stationCode)) {
+            wrapper.eq("station_code", stationCode);
+        }
+        wrapper.eq("status", 1);
+        return overhaulPlanMapper.selectList(wrapper);
+    }
+
+    /**
+     *  返回修正后数据
+     * @param list
+     * @return
+     * @param <T>
+     */
+    @Override
+    public <T> List<T> getCorrectionData(List<T> list) {
+        List<T> resultList = new ArrayList<>();
+        BigDecimal electricFieldCapacity = BigDecimal.ZERO;
+        for (T tList : list) {
+            try {
+                Class<?> childClass = tList.getClass();
+                Class<?> superClass = childClass.getSuperclass();
+                // 时间
+                Field startTimeField = childClass.getDeclaredField("time");
+                startTimeField.setAccessible(true);
+                Date startTime = (Date) startTimeField.get(tList);
+                // 场站编号
+                Field stationCodeField = superClass.getDeclaredField("stationCode");
+                stationCodeField.setAccessible(true);
+                String stationCode = (String) stationCodeField.get(tList);
+                // 获取场站装机
+                ElectricField electricField = electricFieldService.findByStationCode(stationCode);
+                if (null != electricField) {
+                    electricFieldCapacity = electricField.getCapacity();
+                }
+                // 装机
+                Field capacityField = childClass.getDeclaredField("capacity");
+                capacityField.setAccessible(true);
+                capacityField.set(tList, electricFieldCapacity);
+                // 开机
+                Field openCapcityField = childClass.getDeclaredField("openCapacity");
+                openCapcityField.setAccessible(true);
+                // 预测模型
+                Field forecastModelField = childClass.getDeclaredField("forecastModel");
+                forecastModelField.setAccessible(true);
+                String forecastModel = (String)forecastModelField.get(tList);
+                // 根据时间查询检修计划
+                List<OverhaulPlan> overhaulPlanList = this.findByStationCodeAndTimeBetween(startTime, stationCode);
+                if (overhaulPlanList.size() > 0) {
+                    BigDecimal overCapacity = overhaulPlanList.get(0).getOverhaulCapacity();
+                    openCapcityField.set(tList, electricFieldCapacity.subtract(overCapacity));
+                    // 预测数据
+                    Field fpValueFiled = childClass.getDeclaredField("fpValue");
+                    fpValueFiled.setAccessible(true);
+                    BigDecimal fpValue = (BigDecimal) fpValueFiled.get(tList);
+                    // 开机/装机
+                    BigDecimal ratio = (electricFieldCapacity.subtract(overCapacity)).divide(electricFieldCapacity, 2, RoundingMode.HALF_UP);
+                    fpValueFiled.set(tList, fpValue.multiply(ratio));
+                    // 查询检修记录
+                    OverhaulPlanRecords overhaulPlanRecord = overhaulPlanRecordsService.findByStationCodeAndForecastModel(stationCode,forecastModel,overhaulPlanList.get(0).getStartTime(),overhaulPlanList.get(0).getEndTime());
+                    if (null != overhaulPlanRecord) {
+                        overhaulPlanRecord.setUseNum(overhaulPlanRecord.getUseNum() + 1);
+                        overhaulPlanRecord.setUpdateTime(new Date());
+                        overhaulPlanRecordsService.saveOrUpdate(overhaulPlanRecord);
+                        // 使用次数 +1
+                    }else {
+                        OverhaulPlanRecords overhaulPlanRecords = new OverhaulPlanRecords();
+                        overhaulPlanRecords.setOverhaulCapacity(overhaulPlanList.get(0).getOverhaulCapacity());
+                        overhaulPlanRecords.setStartTime(overhaulPlanList.get(0).getStartTime());
+                        overhaulPlanRecords.setEndTime(overhaulPlanList.get(0).getEndTime());
+                        overhaulPlanRecords.setUseNum(overhaulPlanRecords.getUseNum() + 1);
+                        overhaulPlanRecords.setStationCode(stationCode);
+                        overhaulPlanRecords.setForecastModel(forecastModel);
+                        overhaulPlanRecords.setCreateTime(new Date());
+                        overhaulPlanRecordsService.saveOrUpdate(overhaulPlanRecords);
+                    }
+
+                }else {
+                    // 设置开机为装机
+                    openCapcityField.set(tList,electricFieldCapacity);
+                }
+                resultList.add(tList);
+            } catch (NoSuchFieldException | IllegalAccessException e) {
+                throw new RuntimeException(e);
+            }
+        }
+        return resultList;
+    }
 }

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

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

+ 21 - 0
cpp-admin/src/main/java/com/cpp/web/service/regulation/impl/TempShortRegulationServiceImpl.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.TempShortRegulation;
+import com.cpp.web.mapper.regulation.TempShortRegulationMapper;
+import com.cpp.web.service.regulation.TempShortRegulationService;
+import lombok.RequiredArgsConstructor;
+import org.springframework.stereotype.Service;
+
+
+/**
+ * cpp_electric_field
+ *
+ * @author tl
+ * @date 2024-09-23 15:28:33
+ */
+@Service
+@RequiredArgsConstructor
+public class TempShortRegulationServiceImpl extends ServiceImpl<TempShortRegulationMapper, TempShortRegulation> implements TempShortRegulationService {
+
+}

+ 106 - 146
cpp-ui/src/views/maintenancerelated/overhaulplan/index.vue

@@ -39,16 +39,6 @@
         >新增
         </el-button>
       </el-col>
-      <!--      <el-col :span="1.5">-->
-      <!--        <el-button-->
-      <!--          type="success"-->
-      <!--          plain-->
-      <!--          icon="el-icon-edit"-->
-      <!--          size="mini"-->
-      <!--          @click="handleUpdate"-->
-      <!--        >修改-->
-      <!--        </el-button>-->
-      <!--      </el-col>-->
     </el-row>
 
     <div style="padding-top: 10px">
@@ -74,14 +64,26 @@
         <vxe-table-column field="status" title="状态" :formatter="statusFormatter"></vxe-table-column>
         <vxe-table-column field="isUse" title="是否使用" :formatter="useFormatter"></vxe-table-column>
         <vxe-table-column field="mcTime" title="手动停止时间" :formatter="formatDateTime"></vxe-table-column>
+        <vxe-table-column field="" title="使用详情">
+          <template v-slot="{ row }">
+            <el-button
+              type="text"
+              size="mini"
+              icon="el-icon-chat-dot-round"
+              title="使用详情"
+              @click="showRecords(row)">使用详情
+            </el-button>
+          </template>
+        </vxe-table-column>
         <vxe-table-column field="" title="操作">
           <template v-slot="{ row }">
             <el-button
               v-if="row.status === 1"
-              style="padding: 3px 4px 3px 4px;margin: 2px; color: red; background-color: whitesmoke;"
+              style="padding: 3px 4px 3px 4px;margin: 2px; color: red"
               size="mini"
               icon="el-icon-error"
               title="手动停止"
+              type="text"
               @click="stopOverhaulPlan(row)">废弃
             </el-button>
           </template>
@@ -194,6 +196,41 @@
         </div>
       </div>
     </el-dialog>
+
+    <el-dialog :title="title" :visible.sync="showDetails" :close-on-click-modal="false" width="1000px" height="600px">
+      <div class="dark-el-input dark-el-button">
+        <vxe-table
+          ref="xTable"
+          align="center"
+          class="mytable-style"
+          auto-resize
+          border
+          resizable
+          export-config
+          highlight-current-row
+          show-overflow
+          max-height="700"
+          :data="tableDataDetails.slice((currentPage-1)*pageSize,currentPage*pageSize)">
+          <vxe-table-column field="stationCode" title="场站名称" :formatter="codeChangeName"></vxe-table-column>
+          <vxe-table-column field="startTime" :formatter="formatDateTime" title="检修开始时间"></vxe-table-column>
+          <vxe-table-column field="endTime" :formatter="formatDateTime" title="检修结束时间"></vxe-table-column>
+          <vxe-table-column field="overhaulCapacity" title="检修容量(MW)"></vxe-table-column>
+          <vxe-table-column field="forecastModel" title="预测模型"></vxe-table-column>
+          <vxe-table-column field="useNum" title="使用次数"></vxe-table-column>
+          <vxe-table-column field="updateTime" :formatter="formatDateTime" title="上一次使用时间"></vxe-table-column>
+        </vxe-table>
+        <vxe-pager
+          background
+          :loading="loading"
+          :current-page.sync="currentPage"
+          :page-size.sync="pageSize"
+          :total="totalDetails"
+          @page-change="handlePageChangeDetails"
+          :layouts="['PrevJump', 'PrevPage', 'JumpNumber', 'NextPage', 'NextJump', 'Sizes', 'FullJump', 'Total']">
+        </vxe-pager>
+      </div>
+    </el-dialog>
+
   </div>
 </template>
 
@@ -227,19 +264,17 @@ export default {
       title: "",
       // 是否显示弹出层
       open: false,
-      edit: false,
+      showDetails: false,
       total: 0,
-      sortOrder: 'asc',
+      totalDetails: 0,
       pageSize: 10,
       currentPage: 1,
       stationList: [],
       stationCode: '',
       stationName: undefined,
-      searchForm: {},
       tableData: [],
+      tableDataDetails: [],
       loading: false,
-      modId: '',
-      checkSign: '',
       capacity: null,
       // 表单校验
       rules: {
@@ -273,7 +308,6 @@ export default {
   methods: {
     // 表单重置
     reset() {
-      this.edit = false;
       this.form = {
         stationCode: '',
         name: '',
@@ -297,27 +331,10 @@ export default {
       this.reset();
       this.open = true;
       this.title = "新增检修计划";
-      this.edit = false;
-    },
-    /** 修改按钮操作 */
-    handleUpdate() {
-      this.title = "修改检修计划";
-      this.reset();
-      const _selectData = this.$refs.xTable.getRadioRecord(true)
-      if (_selectData == null) {
-        this.$message({
-          type: 'warning',
-          message: '请选择记录!'
-        });
-        return
-      }
-      this.open = true;
-      this.edit = true;
-      this.form = JSON.parse(JSON.stringify(_selectData))
     },
     // 提交按钮
     async commitChannel() {
-      var checkData=[]
+      var checkData = []
       const param = {
         "stationCode": this.form.stationCode
       }
@@ -342,87 +359,37 @@ export default {
             return
           }
           var timeStartEnd = [this.form.startTime, this.form.endTime]
-          if (this.checkDate(timeStartEnd, checkData, this.edit, this.form)) {
+          if (this.checkDate(timeStartEnd, checkData, this.form)) {
             this.$message.warning('该时间段内已有检修计划!')
             return
           }
-          // if (this.form.id != undefined) {
-          //   // 更新操作
-          //   this.$axios.post('/overhaulplan/updateById', this.form).then((res) => {
-          //     this.$message.success('修改成功')
-          //     this.open = false;
-          //     this.overhualStatus = null
-          //     this.queryByStationCode()
-          //   }).catch((error) => {
-          //   })
-          // } else {
-            // 新增操作
-            this.$axios.post('/overhaulplan/save', this.form).then((res) => {
-              if (res == undefined) {
-                this.$message.success('新增失败')
-              } else {
-                this.$message.success('新增成功')
-                this.overhualStatus = null
-                this.queryByStationCode()
-                this.open = false;
-              }
-            }).catch((error) => {
-            })
-          }
-        // }
+          // 新增操作
+          this.$axios.post('/overhaulplan/save', this.form).then((res) => {
+            if (res == undefined) {
+              this.$message.success('新增失败')
+            } else {
+              this.$message.success('新增成功')
+              this.overhualStatus = null
+              this.queryByStationCode()
+              this.open = false;
+            }
+          }).catch((error) => {
+          })
+        }
       });
     },
-    // /** 删除按钮操作 */
-    // handleDelete() {
-    //   const _selectData = this.$refs.xTable.getRadioRecord(true)
-    //   if (_selectData == null) {
-    //     this.$message({
-    //       type: 'warning',
-    //       message: '请选择记录!'
-    //     });
-    //     return
-    //   }
-    //
-    //   this.$confirm('是否确认删除?', '提示', {
-    //     confirmButtonText: '确定',
-    //     cancelButtonText: '取消',
-    //     type: 'warning'
-    //   }).then(() => {
-    //     this.doDelete(_selectData)
-    //   }).catch(() => {
-    //   });
-    // },
-    /**
-     * 删除提交
-     */
-    // doDelete(row) {
-    //   this.$axios.post('/overhaulplan/remove', row).then((res) => {
-    //     this.$message.success('删除成功!')
-    //     this.dataQuery()
-    //   }).catch((error) => {
-    //   })
-    //   this.loading = false
-    // },
     handlePageChange({currentPage, pageSize}) {
       this.currentPage = currentPage
       this.pageSize = pageSize
       this.queryByStationCode();
     },
-    // dataQuery() {
-    //   this.loading = true
-    //   const param = {
-    //     "currentPage": this.currentPage,
-    //     "pageSize": this.pageSize,
-    //   }
-    //   this.$axios.get('/overhaulplan/getList', {params: param}).then(response => {
-    //     this.tableData = response.data.records
-    //     this.total = response.data.total
-    //     this.loading = false
-    //   }).catch(() => {
-    //     this.loading = false
-    //   })
-    // },
-
+    handlePageChangeDetails({currentPage, pageSize}) {
+      this.currentPage = currentPage
+      if (this.pageSize != pageSize) {
+        this.changePageSize(pageSize)
+      }
+      this.pageSize = pageSize
+    },
     //日期转换器
     formatDateTime(cellValue) {
       if (cellValue.cellValue == null) {
@@ -469,7 +436,7 @@ export default {
         this.loading = false
       })
     },
-    checkDate(v1, v2, v3, v4) {
+    checkDate(v1, v2, v4) {
       let result = false
       const item = ''
       // 修改时所需便利集合
@@ -481,46 +448,26 @@ export default {
         }
         v5.push(v2[i])
       }
-      // 编辑修改
-      if (v3) {
-        for (let i = 0; i < v5.length; i++) {
-          if (v1[0] >= v5[i].startTime && v1[0] <= v5[i].endTime) {
-            result = true
-            break
-          }
-          if (v1[1] >= v5[i].startTime && v1[1] <= v5[i].endTime) {
-            result = true
-            break
-          }
-          if (v1[0] <= v5[i].startTime && v1[1] >= v5[i].endTime) {
-            result = true
-            break
-          }
-          if (v1[0] >= v5[i].startTime && v1[1] <= v5[i].endTime) {
-            result = true
-            break
-          }
+
+      for (let i = 0; i < v2.length; i++) {
+        if (v1[0] >= new Date(v2[i].startTime).getTime() && v1[0] <= new Date(v2[i].endTime).getTime()) {
+          result = true
+          break
         }
-      } else {
-        for (let i = 0; i < v2.length; i++) {
-          if (v1[0] >= new Date(v2[i].startTime).getTime() && v1[0] <= new Date(v2[i].endTime).getTime()) {
-            result = true
-            break
-          }
-          if (v1[1] >= new Date(v2[i].startTime).getTime() && v1[1] <= new Date(v2[i].endTime).getTime()) {
-            result = true
-            break
-          }
-          if (v1[0] <= new Date(v2[i].startTime).getTime() && v1[1] >= new Date(v2[i].endTime).getTime()) {
-            result = true
-            break
-          }
-          if (v1[0] >= new Date(v2[i].startTime).getTime() && v1[1] <= new Date(v2[i].endTime).getTime()) {
-            result = true
-            break
-          }
+        if (v1[1] >= new Date(v2[i].startTime).getTime() && v1[1] <= new Date(v2[i].endTime).getTime()) {
+          result = true
+          break
+        }
+        if (v1[0] <= new Date(v2[i].startTime).getTime() && v1[1] >= new Date(v2[i].endTime).getTime()) {
+          result = true
+          break
+        }
+        if (v1[0] >= new Date(v2[i].startTime).getTime() && v1[1] <= new Date(v2[i].endTime).getTime()) {
+          result = true
+          break
         }
       }
+
       return result
     },
     stopOverhaulPlan(row) {
@@ -532,12 +479,25 @@ export default {
     codeChangeName(row) {
       var codeList = this.stationList
       for (let i = 0; i < codeList.length; i++) {
-        console.log("a" + row.cellValue)
-        console.log("b" + codeList[i].value)
         if (row.cellValue == codeList[i].value) {
           return codeList[i].label
         }
       }
+    },
+    showRecords(row) {
+      this.showDetails = true
+      this.title = '使用记录详情'
+      this.loading = true
+      const param = {
+        "stationCode": this.stationCode,
+        "startTime": Date.parse(row.startTime),
+        "endTime": Date.parse(row.endTime)
+      }
+      this.$axios.get('/overhaulPlanRecords/findByStationCodeAndTimeBetween', {params: param}).then(response => {
+        this.tableDataDetails = response.data
+        this.totalDetails  = response.data.length()
+        this.loading = false
+      })
     }
   }
 }

+ 3 - 37
cpp-ui/src/views/maintenancerelated/overhaulplanrecords/index.vue

@@ -11,44 +11,12 @@
           </el-option>
         </el-select>
       </el-form-item>
-<!--      <el-form-item label="使用状态">-->
-<!--        <el-select v-model="overhualStatus" placeholder="请选择" style="width: 255px" popper-class="cpp-popper" clearable>-->
-<!--          <el-option-->
-<!--            v-for="item in options"-->
-<!--            :key="item.value"-->
-<!--            :label="item.label"-->
-<!--            :value="item.value">-->
-<!--          </el-option>-->
-<!--        </el-select>-->
-<!--      </el-form-item>-->
       <el-form-item>
         <el-button type="primary" size="mini" style="margin-left: 5px" icon="el-icon-search"
                    @click="queryByStationCode">查询
         </el-button>
       </el-form-item>
     </el-form>
-<!--    <el-row :gutter="10" class="mb8">-->
-<!--      <el-col :span="1.5">-->
-<!--        <el-button-->
-<!--          type="primary"-->
-<!--          plain-->
-<!--          icon="el-icon-plus"-->
-<!--          size="mini"-->
-<!--          @click="handleAdd"-->
-<!--        >新增-->
-<!--        </el-button>-->
-<!--      </el-col>-->
-<!--      &lt;!&ndash;      <el-col :span="1.5">&ndash;&gt;-->
-<!--      &lt;!&ndash;        <el-button&ndash;&gt;-->
-<!--      &lt;!&ndash;          type="success"&ndash;&gt;-->
-<!--      &lt;!&ndash;          plain&ndash;&gt;-->
-<!--      &lt;!&ndash;          icon="el-icon-edit"&ndash;&gt;-->
-<!--      &lt;!&ndash;          size="mini"&ndash;&gt;-->
-<!--      &lt;!&ndash;          @click="handleUpdate"&ndash;&gt;-->
-<!--      &lt;!&ndash;        >修改&ndash;&gt;-->
-<!--      &lt;!&ndash;        </el-button>&ndash;&gt;-->
-<!--      &lt;!&ndash;      </el-col>&ndash;&gt;-->
-<!--    </el-row>-->
 
     <div style="padding-top: 10px">
       <vxe-table
@@ -67,7 +35,9 @@
         <vxe-table-column field="startTime" :formatter="formatDateTime" title="检修开始时间"></vxe-table-column>
         <vxe-table-column field="endTime" :formatter="formatDateTime" title="检修结束时间"></vxe-table-column>
         <vxe-table-column field="overhaulCapacity" title="检修容量(MW)"></vxe-table-column>
-        <vxe-table-column field="dataType" title="使用数据类型"></vxe-table-column>
+        <vxe-table-column field="forecastModel" title="预测模型"></vxe-table-column>
+        <vxe-table-column field="useNum" title="使用次数"></vxe-table-column>
+        <vxe-table-column field="updateTime" :formatter="formatDateTime" title="最近一次使用时间"></vxe-table-column>
       </vxe-table>
       <vxe-pager
         background
@@ -84,8 +54,6 @@
 
 
 <script>
-import form from "vxe-table/packages/form";
-
 export default {
   name: 'overhaulPlanRecords',
   data() {
@@ -163,8 +131,6 @@ export default {
     codeChangeName(row){
       var codeList = this.stationList
       for (let i = 0; i < codeList.length; i++) {
-        console.log("a"+ row.cellValue)
-        console.log("b" + codeList[i].value)
         if (row.cellValue == codeList[i].value){
           return codeList[i].label
         }

+ 223 - 29
cpp-ui/src/views/regulation/dqRegulation/index.vue

@@ -21,7 +21,9 @@
           </el-select>
         </el-form-item>
         <el-form-item>
-          <el-button type="primary" size="small" style="margin-left: 5px" icon="el-icon-search" @click="dataQuery">查询</el-button>
+          <el-button type="primary" size="small" style="margin-left: 5px" icon="el-icon-search" @click="dataQuery">
+            查询
+          </el-button>
         </el-form-item>
       </el-form>
     </div>
@@ -40,50 +42,60 @@
 
         <div class="divTable">
           <el-table
-            :data="form"
+            :data="tableData"
             height="550px"
-            border
-            stripe
+
             size="mini"
             style="width: 100%">
             <el-table-column
-              prop="time1"
+              prop="time"
               header-align="center"
               align="center"
-              label="时间">
+              label="时间"
+            >
             </el-table-column>
             <el-table-column
               prop="xs"
               header-align="center"
               align="center"
               label="系数">
+              <template slot-scope="scope">
+                <vxe-input type="number" v-model="scope.row.xs" size="small" style="width:100%" min="0"
+                           placeholder="" @change="setValueByManual(scope.row,scope.$index)"></vxe-input>
+              </template>
             </el-table-column>
             <el-table-column
               prop="sz"
               header-align="center"
               align="center"
               label="数值">
+              <template slot-scope="scope">
+                <vxe-input type="number" v-model="scope.row.sz" size="small" style="width:100%"
+                           placeholder="" @change="setValueByManual(scope.row,scope.$index)"></vxe-input>
+              </template>
             </el-table-column>
             <el-table-column
-              prop="ys"
+              prop="ysValue"
               header-align="center"
               align="center"
               label="原始值">
             </el-table-column>
             <el-table-column
-              :show-overflow-tooltip="true"
-              prop="tk"
+              prop="tkValue"
               header-align="center"
               align="center"
-              label="调控值">
-              <template slot-scope="scope">
-                <vxe-input type="number" v-model="scope.row.data1" size="small" style="width:100%" min="0"
-                           :max="capacity" placeholder=""></vxe-input>
-              </template>
+              label="调控值"
+              :max="capacity"
+              :min="0"
+            >
             </el-table-column>
           </el-table>
         </div>
-
+        <div class="tkBtn">
+          <div class="dark-el-input dark-el-button">
+            <el-button type="primary" size="small" style="margin-left: 5px" @click="tkCommit">调控功率</el-button>
+          </div>
+        </div>
 
       </el-col>
       <el-col :span="17">
@@ -103,14 +115,20 @@ export default {
   name: 'inverterinfo',
   data() {
     return {
+      symbolSize: 8,
+      capacity: '',
+      tkData: [],
+      tableData: [],
       hoursArray: [],
       chart: null,
       form: [],
       dateTime: new Date(new Date().toLocaleDateString()).getTime() + (60 * 60 * 24 * 1000),
       stationList: [],
       stationCode: '',
-      ysDataLine: [],
-      chartOption:{
+      ysData: [],
+      refUpData: [],
+      refDownData: [],
+      chartOption: {
         backgroundColor: 'transparent',
         title: {
           top: 20,
@@ -156,6 +174,7 @@ export default {
           end: 100,
           left: "15%",
           right: "15%",
+          throttle: 50
         }, {
           type: 'inside'
         }],
@@ -168,8 +187,9 @@ export default {
         },
         xAxis: [{
           type: 'category',
-          boundaryGap: false,
-          data: this.hoursArray
+          // boundaryGap: false,
+          axisLine: {onZero: false},
+          // data: this.hoursArray
         }],
         yAxis: [{
           type: 'value',
@@ -208,14 +228,15 @@ export default {
               borderWidth: 12
             }
           },
-          data: this.ysDataLine
+          data: this.ysData
         },
           {
+            id: 'a',
             name: '调控值',
             type: 'line',
             smooth: true,
             symbol: 'circle',
-            symbolSize: 5,
+            symbolSize: 10,
             showSymbol: false,
             connectNulls: true,
             lineStyle: {
@@ -241,7 +262,8 @@ export default {
             showSymbol: false,
             lineStyle: {
               normal: {
-                width: 2
+                width: 2,
+                type: 'dashed'   //设置线条类型
               }
             },
             itemStyle: {
@@ -250,7 +272,7 @@ export default {
                 borderWidth: 12
               }
             },
-            data: []
+            data: this.refUpData
           },
           {
             name: '参考值下限',
@@ -262,7 +284,8 @@ export default {
             showSymbol: false,
             lineStyle: {
               normal: {
-                width: 2
+                width: 2,
+                type: 'dashed'   //设置线条类型
               }
             },
             itemStyle: {
@@ -271,7 +294,7 @@ export default {
                 borderWidth: 12
               }
             },
-            data: []
+            data: this.refDownData
           },
         ]
       }
@@ -286,18 +309,180 @@ export default {
   },
   computed: {},
   methods: {
-    dataQuery(){
+    // 调控列表提交
+    tkCommit() {
+      if (this.tableData.length == 0) {
+        this.$message.warning("调控列表为空,不能进行提交!")
+        return
+      }
+      // 判断系数和数值2个字段是否有为空
+      for (let i = 0; i < this.tableData.length; i++) {
+        console.log(this.tableData[i].xs == '')
+        console.log(this.tableData[i].sz == '')
+        if (this.tableData[i].xs == '' || this.tableData[i].sz == '') {
+          this.$message.warning(this.tableData[i].time + "存在空值,不能进行提交!")
+          return
+        }
+      }
+
+    },
+
+    //通过表格内系数或固定值修改  生成曲线以及最终预测结果
+    setValueByManual(row, index) {
+      if (row.xs !== undefined && row.sz !== undefined) {
+        // 计算调控值
+        row.tkValue = parseFloat((parseFloat(row.ysValue) * parseFloat(row.xs) + parseFloat(row.sz)).toFixed(2))
+        if (row.tkValue < 0) {
+          row.tkValue = 0
+        }
+        if (row.tkValue > this.capacity) {
+          row.tkValue = this.capacity
+        }
+        // 赋值给表格
+        this.tableData[index] = row
+
+
+        // 遍历tableData封装调控曲线数组
+        let tkArray = new Array()
+        for (var i = 0; i < this.tableData.length; i++) {
+          let array = new Array()
+          array.push(this.tableData[i].time)
+          array.push(this.tableData[i].tkValue)
+          tkArray.push(array)
+        }
+        this.tkData = tkArray
+        this.chartOption.series[1].data = this.tkData
+        this.chart.setOption(this.chartOption)
+        //再调用updatePosition
+        this.updatePosition()
+      }
+    },
+    dataQuery() {
       let queryParams = {
         "stationCode": this.stationCode,
         "time": Math.round(this.dateTime),
       }
       this.$axios.get('/dqRegulationController/queryData', {params: queryParams}).then(response => {
-        this.ysDataLine = response.data.ysData
+        this.capacity = response.data.electricField.capacity
+        this.tableData = response.data.tempShortRegulationList
+        this.ysData = response.data.ysData
+        this.refUpData = response.data.refUpData
+        this.refDownData = response.data.refDownData
+        this.tkData = response.data.tkDataList
         this.chart.clear()
-        this.chartOption.series[0].data = this.ysDataLine
+        // this.option.yAxis[0].max = this.capacity
+        this.draData()
+      }).catch(() => {
+        this.tableData = []
+        this.ysData = []
+        this.refUpData = []
+        this.refDownData = []
+        this.tkData = []
+        this.chartOption.series[0].data = this.ysData
+        this.chartOption.series[1].data = this.tkData
+        this.chartOption.series[2].data = this.refUpData
+        this.chartOption.series[3].data = this.refDownData
         this.chart.setOption(this.chartOption)
-       })
+      });
+    },
+    draData() {
+      let this1 = this;
+      this.chartOption.series[0].data = this.ysData
+      this.chartOption.series[1].data = this.tkData
+      this.chartOption.series[2].data = this.refUpData
+      this.chartOption.series[3].data = this.refDownData
+      // let data = this.tkData
+      let myChart = this.chart
+      let cap = this.capacity
+      setTimeout(function () {
+        myChart.setOption({
+          graphic: this1.tkData.map(function (item, dataIndex) {
+            return {
+              type: 'circle',
+              position: myChart.convertToPixel('grid', item),
+              shape: {
+                cx: 0,
+                cy: 0,
+                r: 10
+              },
+              invisible: true,
+              draggable: true,
+              ondrag: function (dx, dy,) {
+                this1.onPointDragging(dataIndex, [item[0], dx.offsetY], cap);
+              },
+              onmousemove: function () {
+                this1.showTooltip(dataIndex);
+              },
+              onmouseout: function () {
+                this1.hideTooltip(dataIndex);
+              },
+              z: 100
+            };
+          })
+        });
+      }, 0);
+      window.addEventListener('resize', this1.updatePosition);
+      myChart.on('dataZoom', this1.updatePosition);
+
+
+      // 拖动曲线后,将数值重新赋值给表格
+      // this.tableData = form1
+      this.chartOption.yAxis[0].max = this.capacity
+
+      myChart.setOption(this.chartOption)
+    },
+    updatePosition() {
+      let this1 = this;
+      let myChart = this.chart
+      myChart.setOption({
+        graphic: this1.tkData.map(function (item, dataIndex) {
+          return {
+            position: myChart.convertToPixel('grid', item)
+          };
+        })
+      });
+    },
+    showTooltip(dataIndex) {
+      let myChart = this.chart
+      myChart.dispatchAction({
+        type: 'showTip',
+        seriesIndex: 0,
+        dataIndex: dataIndex
+      });
+    },
+    hideTooltip(dataIndex) {
+      let myChart = this.chart
+      myChart.dispatchAction({
+        type: 'hideTip'
+      });
+    },
+    onPointDragging(dataIndex, pos, capacity) {
+      let this1 = this;
+      let myChart = this.chart
+      this1.tkData[dataIndex][1] = myChart.convertFromPixel('grid', pos)[1].toFixed(2);
+      if (myChart.convertFromPixel('grid', pos)[1].toFixed(2) > capacity) {
+        this1.tkData[dataIndex][1] = capacity
+      }
+      if (myChart.convertFromPixel('grid', pos)[1].toFixed(2) < 0) {
+        this1.tkData[dataIndex][1] = 0
+      }
+      // 赋值调控值字段
+      this1.tableData[dataIndex].tkValue = this1.tkData[dataIndex][1]
+      // 根据调控值更新表格中数值字段,数值=调控值-(原始值*系数)
+      this1.tableData[dataIndex].sz = (this1.tkData[dataIndex][1] - (this1.tableData[dataIndex].ysValue * this1.tableData[dataIndex].xs)).toFixed(2)
+      // Update data
+      myChart.setOption({
+        series: [
+          {
+            id: 'a',
+            data: this1.tkData,
+          }
+        ]
+      });
+      this.updatePosition()
     },
+
+
     getStationCode() {
       this.$axios({url: '/electricfield/all', method: 'get'}).then(response => {
         this.stationList = response.data
@@ -326,16 +511,25 @@ export default {
   width: 100%;
   text-align: center
 }
+
 .divDescribeBtn {
   position: relative;
   top: 20px; /* 向下移动15px */
   width: 100%;
   text-align: right
 }
+
 .divTable {
   position: relative;
   top: 30px; /* 向下移动15px */
   width: 100%;
   text-align: center
 }
+
+.tkBtn {
+  position: relative;
+  top: 30px; /* 向下移动15px */
+  width: 100%;
+  text-align: center
+}
 </style>