wangb@gyee-china.com преди 1 година
родител
ревизия
f17854c37c
променени са 1 файла, в които са добавени 36 реда и са изтрити 42 реда
  1. 36 42
      web/runeconomy-xk/src/main/java/com/gyee/runeconomy/service/analysis/AnalysisNewService.java

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

@@ -52,76 +52,70 @@ public class AnalysisNewService {
     public void companys() throws Exception {
 
 
-// 获取当前日期
+        // 获取当前日期
         Date currentDate = new Date();
 
-// 创建 Calendar 对象,并设置为当前日期
+        // 创建 Calendar 对象,并设置为当前日期
         Calendar calendar = Calendar.getInstance();
         calendar.setTime(currentDate);
 
-// 设置 beginDate 为8月31日0点
-        calendar.set(Calendar.MONTH, Calendar.AUGUST);
-        calendar.set(Calendar.DAY_OF_MONTH, 31);
+        // 将时间设为0点
         calendar.set(Calendar.HOUR_OF_DAY, 0);
         calendar.set(Calendar.MINUTE, 0);
         calendar.set(Calendar.SECOND, 0);
         calendar.set(Calendar.MILLISECOND, 0);
+
+        // 设置 beginDate 为前一天的0点
+        calendar.add(Calendar.DAY_OF_MONTH, -1);
         Date beginDate = calendar.getTime();
 
-// 设置 endDate 为9月1日0点
-        calendar.set(Calendar.MONTH, Calendar.SEPTEMBER);
-        calendar.set(Calendar.DAY_OF_MONTH, 1);
-        calendar.set(Calendar.HOUR_OF_DAY, 0);
-        calendar.set(Calendar.MINUTE, 0);
-        calendar.set(Calendar.SECOND, 0);
-        calendar.set(Calendar.MILLISECOND, 0);
+        // 设置 endDate 为当天的0点
+        calendar.add(Calendar.DAY_OF_MONTH, 1);
         Date endDate = calendar.getTime();
 
-
         List<ProEconAnalysisSubtableBottom> stringList = new ArrayList<>();
         for (ProBasicPowerstation wp : CacheContext.wpls) {
-            if (wp.getId().equals("SXJ_KGDL_GJY_FDC_STA")) {
-                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) {
-                    if (wp.getId().equals(po.getWindpowerstationId())) {
+            List<ProBasicMeterPoint> meterPoints = proBasicMeterPointService.getBaseMapper().selectList(null);
 
-                        String point = po.getNemCode();
-                        String name = po.getName();
+            List<ProBasicMeterPoint> collect = meterPoints.stream().filter(i -> i.getWindpowerstationId().equals(wp.getId())).collect(Collectors.toList());
+            for (ProBasicMeterPoint po : collect) {
+                if (wp.getId().equals(po.getWindpowerstationId())) {
 
-                        //获取当前测点倍率
-                        double magnification = po.getMagnification();
+                    String point = po.getNemCode();
+                    String name = po.getName();
 
-                        PointData begin = edosUtil.getSectionData(point, beginDate.getTime());
-                        PointData end = edosUtil.getSectionData(point, endDate.getTime());
+                    //获取当前测点倍率
+                    double magnification = po.getMagnification();
 
-                        double temp1 = 0.0;
-                        double temp2 = 0.0;
+                    PointData begin = edosUtil.getSectionData(point, beginDate.getTime());
+                    PointData end = edosUtil.getSectionData(point, endDate.getTime());
 
-                        temp1 = begin.getPointValueInDouble();
-                        temp2 = end.getPointValueInDouble();
+                    double temp1 =0.0;
+                    double temp2 =0.0;
 
+                    temp1 = begin.getPointValueInDouble();
+                    temp2 = end.getPointValueInDouble();
 
-                        ProEconAnalysisSubtableBottom vo = new ProEconAnalysisSubtableBottom();
 
-                        vo.setId(StringUtils.getUUID());
-                        vo.setRecordDate(beginDate);
-                        vo.setWpid(wp.getId());
-                        vo.setMeterId(begin.getPointName());
-                        vo.setMeterName(name);
-                        vo.setStopCode(temp2);
-                        vo.setStopCodeModify(temp2);
-                        vo.setDayValue((temp2 - temp1) * magnification);
-                        vo.setDayValueModify((temp2 - temp1) * magnification);
-                        stringList.add(vo);
-                        proEconAnalysisSubtableBottomService.batchAdd(stringList);
-                    }
+                    ProEconAnalysisSubtableBottom vo = new ProEconAnalysisSubtableBottom();
+
+                    vo.setId(StringUtils.getUUID());
+                    vo.setRecordDate(beginDate);
+                    vo.setWpid(wp.getId());
+                    vo.setMeterId(begin.getPointName());
+                    vo.setMeterName(name);
+                    vo.setStopCode(temp2);
+                    vo.setStopCodeModify(temp2);
+                    vo.setDayValue((temp2 - temp1) * magnification);
+                    vo.setDayValueModify((temp2 - temp1) * magnification);
+                    stringList.add(vo);
+                    proEconAnalysisSubtableBottomService.batchAdd(stringList);
                 }
             }
         }
-    }
 
+    }
 
 
     public void saveWindProject(String beginDate, String endDate) throws Exception {