Browse Source

增加光照历史值补充功能

wangb@gyee-china.com 1 year ago
parent
commit
79addca719

+ 8 - 0
web/runeconomy-xk/src/main/java/com/gyee/runeconomy/controller/Irradiationinput/IrradiationinputController.java

@@ -29,4 +29,12 @@ public class IrradiationinputController {
           irradiationinputService.getcockpit();
             return AjaxResult.success();
     }
+
+    @GetMapping("/inputsjbc")
+    @ResponseBody
+    @ApiOperation(value = "首页", notes = "首页")
+    public AjaxResult getinformationsjbc() throws Exception {
+        irradiationinputService.getcockpitsjbc();
+        return AjaxResult.success();
+    }
 }

+ 57 - 4
web/runeconomy-xk/src/main/java/com/gyee/runeconomy/service/Irradiationinput/IrradiationinputService.java

@@ -11,10 +11,8 @@ import com.gyee.runeconomy.util.realtimesource.IEdosUtil;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
+import java.text.SimpleDateFormat;
+import java.util.*;
 
 @Service
 public class IrradiationinputService {
@@ -51,4 +49,59 @@ public class IrradiationinputService {
 //            edosUtil.sendMultiPoint(thls);
         }
     }
+
+
+    //数据补充
+    public void getcockpitsjbc() throws Exception {
+
+        List<ProEconIrradiationInput> qwtList = inputService.list();
+        Date currentDate = DateUtils.getCurrentDate();
+        List<String> wpPoints = new ArrayList<>();
+        List<PointData> thls = new ArrayList<>();
+        List<PointData> realData = new ArrayList<>();
+        String Data = "2023-11-16";
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+        Date date = sdf.parse(Data);
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTime(date);
+        calendar.add(Calendar.DAY_OF_MONTH, -1);
+        calendar.set(Calendar.HOUR_OF_DAY, 23);
+        calendar.set(Calendar.MINUTE, 59);
+        calendar.set(Calendar.SECOND, 59);
+
+        Date startTime = calendar.getTime();
+
+        Calendar calendar1 = Calendar.getInstance();
+        calendar1.setTime(date);
+        calendar1.set(Calendar.HOUR_OF_DAY, 23);
+        calendar1.set(Calendar.MINUTE, 59);
+        calendar1.set(Calendar.SECOND, 59);
+
+        Date endTime = calendar1.getTime();
+
+        if (!qwtList.isEmpty() || qwtList.size() >= 1) {
+            for (ProEconIrradiationInput lr : qwtList) {
+//                if (lr.getWindpowerstationId().equals("SXJ_KGDL_YX_GDC_STA")) {
+                    Map<String, Map<String, ProBasicPowerstationPoint>> wppointmap = CacheContext.wppointmap;
+                    Map<String, ProBasicPowerstationPoint> pointMap = wppointmap.get(lr.getWindpowerstationId());
+                    if (pointMap.size() >= 1 || !pointMap.isEmpty()) {
+                        wpPoints.add(pointMap.get(ContantXk.GZYC).getNemCode());
+                        realData.addAll(edosUtil.getHistMatrix(wpPoints, currentDate.getTime() / 1000));
+
+                        List<PointData> ycglls = edosUtil.getHistoryDatasRaw(pointMap.get(ContantXk.GZYC), startTime.getTime() / 1000, endTime.getTime() / 1000);
+
+                        for (PointData data : ycglls) {
+                            data.setEdnaId(lr.getNemCode());
+                            thls.add(data);
+//                        edosUtil.sendSinglePoint(data);
+                        }
+                        realData.clear(); // 清空realData
+                        wpPoints.clear(); // 清空wpPoints,为下一次循环准备
+                    }
+//                }
+            }
+//            edosUtil.sendMultiPoint(thls);
+            edosUtil.updatePoint(thls);
+        }
+    }
 }

+ 4 - 4
web/runeconomy-xk/src/main/java/com/gyee/runeconomy/service/analysis/AnalysisNewService.java

@@ -73,17 +73,17 @@ public class AnalysisNewService {
         // 设置 endDate 为当天的0点
         calendar.add(Calendar.DAY_OF_MONTH, 1);
         Date endDate = calendar.getTime();
-
+        List<ProBasicMeterPoint> meterPoints = proBasicMeterPointService.getBaseMapper().selectList(null);
         List<ProEconAnalysisSubtableBottom> Listbat = new ArrayList<>();
         for (ProBasicPowerstation wp : CacheContext.wpls) {
 //            if (wp.getId().equals("SXJ_KGDL_XWT_FDC_STA")) continue;
 
 ////            补充数据可将其打开
-//            if (wp.getId().equals("SXJ_KGDL_YX_GDC_STA")) {
+//            if (wp.getId().equals("SXJ_KGDL_SY_GDC_STA")) {
 //
-//                for (int g = 0; g <= 56; g++) {
+//                for (int g = 0; g <= 43; g++) {
+
 
-            List<ProBasicMeterPoint> meterPoints = proBasicMeterPointService.getBaseMapper().selectList(null);
 
             List<ProBasicMeterPoint> collect = meterPoints.stream().filter(i -> i.getWindpowerstationId().equals(wp.getId())).collect(Collectors.toList());
             for (ProBasicMeterPoint po : collect) {

+ 12 - 2
web/runeconomy-xk/src/main/java/com/gyee/runeconomy/util/realtimesource/EdosUtil.java

@@ -1519,13 +1519,23 @@ public class EdosUtil implements IEdosUtil {
     @Override
     public void updatePoint(List<PointData> pointls) throws Exception {
         String url = baseURL + "/history/batch";
-        List<JSONObject> writeList = new ArrayList<>();
+        if (pointls.get(0).getEdnaId().startsWith("GF-")) {
+            url = baseURL2 + "/history/batch";
+        }
 
+        List<JSONObject> writeList = new ArrayList<>();
+        List<JSONObject> jsonObjects = new ArrayList<>();
         for (PointData entity : pointls) {
             writeList.add(convertPointData(entity));
         }
         try {
-            String result = restTemplate.postForObject(url, writeList, String.class);
+//            String result = restTemplate.postForObject(url, writeList, String.class);
+
+            for (JSONObject wtt : writeList) {
+                jsonObjects = new ArrayList<>();
+                jsonObjects.add(wtt);
+                String result = restTemplate.postForObject(url, jsonObjects, String.class);
+            }
         } catch (HttpClientErrorException exception) {
             if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
                 return;