Browse Source

底码计算

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

+ 78 - 0
realtime/generationXK-service/src/main/java/com/gyee/generation/controller/AnalysisNewController.java

@@ -0,0 +1,78 @@
+package com.gyee.generation.controller;
+
+import com.gyee.common.config.R;
+import com.gyee.common.util.DateUtils;
+import com.gyee.generation.service.AnalysisNewService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.annotation.Resource;
+import java.util.Calendar;
+import java.util.Date;
+
+@RestController
+@RequestMapping("//analysis")
+@Api(value = "底码", tags = "底码")
+public class AnalysisNewController {
+
+    @Resource
+    private AnalysisNewService analysisNewService;
+
+    @Scheduled(cron = "0 15 0 * * ?")
+    @GetMapping(value = "/companys")
+    @ApiOperation(value = "公司列表", notes = "公司列表")
+    public R companys() throws Exception {
+        analysisNewService.companys();
+
+        return null;
+    }
+
+    @Scheduled(cron = "0 30 0 * * ?")
+    @GetMapping(value = "/can")
+    @ApiOperation(value = "公司列表", notes = "公司列表")
+    public R cans() throws Exception {
+        // 获取当前日期
+        Date currentDate = new Date();
+
+        // 创建 Calendar 对象,并设置为当前日期
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTime(currentDate);
+
+        // 将时间设为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 为当天的0点
+        calendar.add(Calendar.DAY_OF_MONTH, 1);
+        Date endDate = calendar.getTime();
+
+
+        //补充数据可将其打开
+//        for (int i = 0; i < 44; i++) {
+//        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+//
+//        String beginDateStr = sdf.format(beginDate);
+//        String endDateStr = sdf.format(endDate);
+
+
+        String yesterday = DateUtils.getYesterdayStr("yyyy-MM-dd");
+        analysisNewService.saveWindProject();
+
+//          beginDate = DateUtils.addDays(beginDate, -1);
+//          calendar.add(Calendar.DAY_OF_MONTH, -1);
+//          endDate = calendar.getTime();
+//        }
+
+        return null;
+    }
+}

+ 30 - 0
realtime/generationXK-service/src/main/java/com/gyee/generation/init/CacheContext.java

@@ -114,6 +114,10 @@ public class CacheContext implements CommandLineRunner {
     public static Map<String, ProBasicPowerstation> wpmap = new HashMap<>();
     public static List<ProBasicMeterPoint>  meterpoints = new ArrayList<>();
     public static Map<String,ProBasicMeterPoint>  meterpointMap = new HashMap<>();
+
+    public static Map<String,List<ProBasicMeterPoint>> wpmeterMap = new HashMap<>();
+    public static Map<String, ProBasicMeterPoint> meterMap = new HashMap<>();
+
     public static Map<String,List<ProBasicProject>> wppromap = new HashMap<>();
     public static Map<String,List<ProBasicLine>> prolinemap = new HashMap<>();
     public static Map<String,List<ProBasicEquipment>> wpwtmap = new HashMap<>();
@@ -565,7 +569,33 @@ public class CacheContext implements CommandLineRunner {
             meterpointMap.put(meterpoint.getNemCode(),meterpoint);
         });
 
+        for (ProBasicMeterPoint meterpoint2 : proBasicMeterPointService.list()) {
+            if (wpmap.containsKey(meterpoint2.getWindpowerstationId())){
+                meterMap.put(meterpoint2.getNemCode(),meterpoint2);
+                if (wpmeterMap.containsKey(meterpoint2.getWindpowerstationId())){
+                    wpmeterMap.get(meterpoint2.getWindpowerstationId()).add(meterpoint2);
+                }else{
+                    List<ProBasicMeterPoint> list = new ArrayList<>();
+                    list.add(meterpoint2);
+                    wpmeterMap.put(meterpoint2.getWindpowerstationId(),list);
+                }
+            }
+
+        }
 
+        for (ProBasicMeterPoint meterpoint2 : proBasicMeterPointService.list()) {
+            if (wpmap.containsKey(meterpoint2.getWindpowerstationId())){
+                meterMap.put(meterpoint2.getId(),meterpoint2);
+                if (wpmeterMap.containsKey(meterpoint2.getWindpowerstationId())){
+                    wpmeterMap.get(meterpoint2.getWindpowerstationId()).add(meterpoint2);
+                }else{
+                    List<ProBasicMeterPoint> list = new ArrayList<>();
+                    list.add(meterpoint2);
+                    wpmeterMap.put(meterpoint2.getWindpowerstationId(),list);
+                }
+            }
+
+        }
         wpls.stream().forEach(wp->{
 
             wpmap.put(wp.getId(),wp);

+ 1 - 1
realtime/generationXK-service/src/main/java/com/gyee/generation/model/auto/ProBasicProjectPlan.java

@@ -35,7 +35,7 @@ public class ProBasicProjectPlan extends Model {
     /**
      * 计划发电量
      */
-    private String generatingCapacity;
+    private Double generatingCapacity;
 
     /**
      * 计划停运小时

+ 58 - 55
realtime/generationXK-service/src/main/java/com/gyee/generation/model/auto/ProEconAnalysisSubprojectWindcan.java

@@ -1,11 +1,13 @@
 package com.gyee.generation.model.auto;
 
-import java.math.BigDecimal;
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.extension.activerecord.Model;
-import java.time.LocalDate;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 
+import java.util.Date;
+
 /**
  * <p>
  * 风电项目表
@@ -23,6 +25,7 @@ public class ProEconAnalysisSubprojectWindcan extends Model {
     /**
      * 编码
      */
+    @TableId(value = "ID", type = IdType.ASSIGN_ID)
     private Long id;
 
     private Long tid;
@@ -37,115 +40,115 @@ public class ProEconAnalysisSubprojectWindcan extends Model {
     /**
      * 日期
      */
-    private LocalDate recordDate;
+    private Date recordDate;
 
-    private BigDecimal fdlscada;
+    private Double fdlscada;
 
-    private BigDecimal fdl;
+    private Double fdl;
 
-    private BigDecimal swdl;
+    private Double swdl;
 
-    private BigDecimal gwdl;
+    private Double gwdl;
 
-    private BigDecimal zhcydl;
+    private Double zhcydl;
 
-    private BigDecimal zhcydlscada;
+    private Double zhcydlscada;
 
-    private BigDecimal zhcydll;
+    private Double zhcydll;
 
-    private BigDecimal zhcydllscada;
+    private Double zhcydllscada;
 
-    private BigDecimal cydl;
+    private Double cydl;
 
-    private BigDecimal cydll;
+    private Double cydll;
 
-    private BigDecimal lyxs;
+    private Double lyxs;
 
-    private BigDecimal lyxsscada;
+    private Double lyxsscada;
 
-    private BigDecimal zjrl;
+    private Double zjrl;
 
-    private BigDecimal cnsldwdl;
+    private Double cnsldwdl;
 
-    private BigDecimal cnsljxdl;
+    private Double cnsljxdl;
 
-    private BigDecimal cwsldwdl;
+    private Double cwsldwdl;
 
-    private BigDecimal cwsljxdl;
+    private Double cwsljxdl;
 
-    private BigDecimal zrzhdl;
+    private Double zrzhdl;
 
-    private BigDecimal xddl;
+    private Double xddl;
 
-    private BigDecimal fjgzdl;
+    private Double fjgzdl;
 
-    private BigDecimal syzgzdl;
+    private Double syzgzdl;
 
-    private BigDecimal jdxlgzdl;
+    private Double jdxlgzdl;
 
-    private BigDecimal fjjxdl;
+    private Double fjjxdl;
 
-    private BigDecimal syzjxdl;
+    private Double syzjxdl;
 
-    private BigDecimal jdxljx;
+    private Double jdxljx;
 
-    private BigDecimal cnsldwsj;
+    private Double cnsldwsj;
 
-    private BigDecimal cnsljxsj;
+    private Double cnsljxsj;
 
-    private BigDecimal cwsldwsj;
+    private Double cwsldwsj;
 
-    private BigDecimal cwsljxsj;
+    private Double cwsljxsj;
 
-    private BigDecimal zrzhsj;
+    private Double zrzhsj;
 
-    private BigDecimal xdsj;
+    private Double xdsj;
 
-    private BigDecimal fjgzsj;
+    private Double fjgzsj;
 
-    private BigDecimal syzgzsj;
+    private Double syzgzsj;
 
-    private BigDecimal jdxlgzsj;
+    private Double jdxlgzsj;
 
-    private BigDecimal fjjxsj;
+    private Double fjjxsj;
 
-    private BigDecimal syzjxsj;
+    private Double syzjxsj;
 
-    private BigDecimal jdxljxsj;
+    private Double jdxljxsj;
 
-    private BigDecimal gzcs;
+    private Double gzcs;
 
-    private BigDecimal qfl;
+    private Double qfl;
 
-    private BigDecimal qpjfx;
+    private Double qpjfx;
 
     private String tq;
 
-    private BigDecimal llfdl;
+    private Double llfdl;
 
-    private BigDecimal llfdlscada;
+    private Double llfdlscada;
 
-    private BigDecimal dnaqts;
+    private Double dnaqts;
 
-    private BigDecimal ljaqts;
+    private Double ljaqts;
 
-    private BigDecimal qw;
+    private Double qw;
 
-    private BigDecimal zdcl;
+    private Double zdcl;
 
-    private BigDecimal zxcl;
+    private Double zxcl;
 
     private String fx;
 
-    private BigDecimal yjhfdl;
+    private Double yjhfdl;
 
-    private BigDecimal pjqrfs;
+    private Double pjqrfs;
 
-    private BigDecimal edpjfs;
+    private Double edpjfs;
 
-    private BigDecimal ypjkqmd;
+    private Double ypjkqmd;
 
-    private BigDecimal xnssdl;
+    private Double xnssdl;
 
 
 }

+ 58 - 56
realtime/generationXK-service/src/main/java/com/gyee/generation/model/auto/ProEconAnalysisSubprojectWindcannot.java

@@ -1,11 +1,13 @@
 package com.gyee.generation.model.auto;
 
-import java.math.BigDecimal;
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.extension.activerecord.Model;
-import java.time.LocalDate;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 
+import java.util.Date;
+
 /**
  * <p>
  * 风电项目不可编辑表
@@ -17,12 +19,12 @@ import lombok.EqualsAndHashCode;
 @Data
 @EqualsAndHashCode(callSuper = true)
 public class ProEconAnalysisSubprojectWindcannot extends Model {
-
     private static final long serialVersionUID = 1L;
 
     /**
      * 编码
      */
+    @TableId(value = "ID", type = IdType.ASSIGN_ID)
     private Long id;
 
     private Long tid;
@@ -37,115 +39,115 @@ public class ProEconAnalysisSubprojectWindcannot extends Model {
     /**
      * 日期
      */
-    private LocalDate recordDate;
+    private Date recordDate;
 
-    private BigDecimal fdlscada;
+    private Double fdlscada;
 
-    private BigDecimal fdl;
+    private Double fdl;
 
-    private BigDecimal swdl;
+    private Double swdl;
 
-    private BigDecimal gwdl;
+    private Double gwdl;
 
-    private BigDecimal zhcydl;
+    private Double zhcydl;
 
-    private BigDecimal zhcydlscada;
+    private Double zhcydlscada;
 
-    private BigDecimal zhcydll;
+    private Double zhcydll;
 
-    private BigDecimal zhcydllscada;
+    private Double zhcydllscada;
 
-    private BigDecimal cydl;
+    private Double cydl;
 
-    private BigDecimal cydll;
+    private Double cydll;
 
-    private BigDecimal lyxs;
+    private Double lyxs;
 
-    private BigDecimal lyxsscada;
+    private Double lyxsscada;
 
-    private BigDecimal zjrl;
+    private Double zjrl;
 
-    private BigDecimal cnsldwdl;
+    private Double cnsldwdl;
 
-    private BigDecimal cnsljxdl;
+    private Double cnsljxdl;
 
-    private BigDecimal cwsldwdl;
+    private Double cwsldwdl;
 
-    private BigDecimal cwsljxdl;
+    private Double cwsljxdl;
 
-    private BigDecimal zrzhdl;
+    private Double zrzhdl;
 
-    private BigDecimal xddl;
+    private Double xddl;
 
-    private BigDecimal fjgzdl;
+    private Double fjgzdl;
 
-    private BigDecimal syzgzdl;
+    private Double syzgzdl;
 
-    private BigDecimal jdxlgzdl;
+    private Double jdxlgzdl;
 
-    private BigDecimal fjjxdl;
+    private Double fjjxdl;
 
-    private BigDecimal syzjxdl;
+    private Double syzjxdl;
 
-    private BigDecimal jdxljx;
+    private Double jdxljx;
 
-    private BigDecimal cnsldwsj;
+    private Double cnsldwsj;
 
-    private BigDecimal cnsljxsj;
+    private Double cnsljxsj;
 
-    private BigDecimal cwsldwsj;
+    private Double cwsldwsj;
 
-    private BigDecimal cwsljxsj;
+    private Double cwsljxsj;
 
-    private BigDecimal zrzhsj;
+    private Double zrzhsj;
 
-    private BigDecimal xdsj;
+    private Double xdsj;
 
-    private BigDecimal fjgzsj;
+    private Double fjgzsj;
 
-    private BigDecimal syzgzsj;
+    private Double syzgzsj;
 
-    private BigDecimal jdxlgzsj;
+    private Double jdxlgzsj;
 
-    private BigDecimal fjjxsj;
+    private Double fjjxsj;
 
-    private BigDecimal syzjxsj;
+    private Double syzjxsj;
 
-    private BigDecimal jdxljxsj;
+    private Double jdxljxsj;
 
-    private BigDecimal gzcs;
+    private Double gzcs;
 
-    private BigDecimal qfl;
+    private Double qfl;
 
-    private BigDecimal qpjfx;
+    private Double qpjfx;
 
     private String tq;
 
-    private BigDecimal llfdl;
+    private Double llfdl;
 
-    private BigDecimal llfdlscada;
+    private Double llfdlscada;
 
-    private BigDecimal dnaqts;
+    private Double dnaqts;
 
-    private BigDecimal ljaqts;
+    private Double ljaqts;
 
-    private BigDecimal qw;
+    private Double qw;
 
-    private BigDecimal zdcl;
+    private Double zdcl;
 
-    private BigDecimal zxcl;
+    private Double zxcl;
 
     private String fx;
 
-    private BigDecimal yjhfdl;
+    private Double yjhfdl;
 
-    private BigDecimal pjqrfs;
+    private Double pjqrfs;
 
-    private BigDecimal edpjfs;
+    private Double edpjfs;
 
-    private BigDecimal ypjkqmd;
+    private Double ypjkqmd;
 
-    private BigDecimal xnssdl;
+    private Double xnssdl;
 
 
 }

+ 10 - 8
realtime/generationXK-service/src/main/java/com/gyee/generation/model/auto/ProEconAnalysisSubtableBottom.java

@@ -1,11 +1,13 @@
 package com.gyee.generation.model.auto;
 
-import java.math.BigDecimal;
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.extension.activerecord.Model;
-import java.time.LocalDate;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 
+import java.util.Date;
+
 /**
  * <p>
  * 风电表底
@@ -23,12 +25,13 @@ public class ProEconAnalysisSubtableBottom extends Model {
     /**
      * 编码
      */
+    @TableId(value="ID",type = IdType.ASSIGN_ID)
     private String id;
 
     /**
      * 日期
      */
-    private LocalDate recordDate;
+    private Date recordDate;
 
     /**
      * 场站
@@ -39,13 +42,12 @@ public class ProEconAnalysisSubtableBottom extends Model {
 
     private String meterName;
 
-    private BigDecimal stopCode;
-
-    private BigDecimal stopCodeModify;
+    private Double stopCode;
 
-    private BigDecimal dayValue;
+    private Double stopCodeModify;
 
-    private BigDecimal dayValueModify;
+    private Double dayValue;
 
+    private Double dayValueModify;
 
 }

+ 425 - 0
realtime/generationXK-service/src/main/java/com/gyee/generation/service/AnalysisNewService.java

@@ -0,0 +1,425 @@
+package com.gyee.generation.service;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.gyee.common.model.PointData;
+import com.gyee.common.model.StringUtils;
+import com.gyee.common.util.CopyUtils;
+import com.gyee.common.util.DateUtils;
+import com.gyee.generation.init.CacheContext;
+import com.gyee.generation.model.auto.*;
+import com.gyee.generation.service.auto.*;
+import com.gyee.generation.service.auto.impl.ProBasicMeterPointServiceImpl;
+import com.gyee.generation.service.auto.impl.ProEconAnalysisSubtableBottomServiceImpl;
+import com.gyee.generation.util.realtimesource.IEdosUtil;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.*;
+import java.util.stream.Collectors;
+
+@Service
+public class AnalysisNewService {
+
+    @Resource
+    private IEdosUtil edosUtil;
+
+    @Resource
+    private ProBasicMeterPointServiceImpl proBasicMeterPointService;
+
+    @Resource
+    private ProEconAnalysisSubtableBottomServiceImpl proEconAnalysisSubtableBottomService;
+
+    @Resource
+    private IProEconAnalysisSubtableBottomService ProEconAnalysisSubtableBottomService;
+    @Resource
+    private IProEconAnalysisSubprojectWindcannotService ProEconAnalysisSubprojectWindcannotService;
+    @Resource
+    private IProEconAnalysisSubprojectWindcanService ProEconAnalysisSubprojectWindcanService;
+
+    @Resource
+    private IProEconPowerstationInfoDay1Service proEconPowerstationInfoDay1Service;
+    @Resource
+    private IProEconPowerstationInfoDay3Service windpowerinfoday3Service;
+    @Resource
+    private IProEconShutdownEvent2Service shutdownevent2Service;
+
+    @Resource
+    private IProEconInOrOutSpeedTotalService inputoroutputspeedtotalService;
+
+    @Resource
+    private IProBasicProjectPlanService proBasicProjectPlanService;
+
+    public void companys() throws Exception {
+
+
+        // 获取当前日期
+        Date currentDate = new Date();
+
+        // 创建 Calendar 对象,并设置为当前日期
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTime(currentDate);
+
+        // 将时间设为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();
+        // 初始化初始值
+        Date initialFirstDayZeroHour = (Date) beginDate.clone();
+        // 设置 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_FS_GDC_STA")) {
+//
+//                for (int g = 0; g <= 50; g++) {
+
+
+
+            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())) {
+
+                    String point = po.getNemCode();
+                    String name = po.getName();
+
+                    //获取当前测点倍率
+                    double magnification = po.getMagnification();
+
+                    PointData begin = edosUtil.getSectionData(point, beginDate.getTime());
+                    PointData end = edosUtil.getSectionData(point, endDate.getTime());
+
+                    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);
+                    Listbat.add(vo);
+                }
+
+            }
+//                    beginDate = DateUtils.addDays(beginDate, -1);
+//                    calendar.add(Calendar.DAY_OF_MONTH, -1);
+//                    endDate = calendar.getTime();
+//                }
+            proEconAnalysisSubtableBottomService.batchAdd(Listbat);
+                Listbat.clear();
+//             恢复初始值
+//            beginDate = initialFirstDayZeroHour;
+//            }
+
+
+        }
+    }
+
+
+    public void saveWindProject() throws Exception {
+
+        String yesterday = DateUtils.getYesterdayStr("yyyy-MM-dd");
+        //风场,
+        Map<String, List<ProBasicMeterPoint>> wpmeterMap = CacheContext.wpmeterMap;
+        Map<String, ProBasicMeterPoint> meterMap = CacheContext.meterMap;
+        List<String> days = getDays(yesterday, yesterday);
+        for (String day : days) {
+            Map<String, Object> bdzmap = new HashMap<>();
+            bdzmap.put("record_date", DateUtils.parseDate(day));
+            List<ProEconAnalysisSubtableBottom> currentDayBdz = ProEconAnalysisSubtableBottomService.listByMap(bdzmap);
+
+
+            Map<String, Object> deleteparam = new HashMap<>();
+            deleteparam.put("record_date", DateUtils.parseDate(day));
+            ProEconAnalysisSubprojectWindcannotService.removeByMap(deleteparam);
+            ProEconAnalysisSubprojectWindcanService.removeByMap(deleteparam);
+            for (ProBasicProject project : CacheContext.pjls) {
+
+                if (project.getWindpowerstationId().endsWith("GDC_STA")) {
+                    continue;
+                }
+                List<ProEconAnalysisSubtableBottom> currentDay = currentDayBdz.stream().filter(i -> i.getWpid().equals(project.getWindpowerstationId())).collect(Collectors.toList());
+                if(StringUtils.isEmpty(currentDay)){
+                    continue;
+                }
+                //算出工程发电量
+                List<String> fdls = wpmeterMap.get(project.getWindpowerstationId()).stream()
+                        .filter(i -> (
+                                i.getProjectId().equals(project.getId()) && i.getMeterSort().equals("主") && i.getMeterType().equals("进线") && i.getUniformCode().equals("ZXYG")
+                        )).map(i -> i.getNemCode()).collect(Collectors.toList());
+
+                double generatingcapacity = 0;
+                for (String meterid : fdls) {
+                    generatingcapacity += currentDay.stream().filter(i -> i.getMeterId().equals(meterid)).findFirst().isPresent() ? currentDay.stream().filter(i -> i.getMeterId().equals(meterid)).findFirst().get().getDayValueModify().doubleValue() : 0.0;
+                }
+
+                //总发电量
+                List<String> zfdls = wpmeterMap.get(project.getWindpowerstationId()).stream()
+                        .filter(i -> (
+                                i.getMeterSort().contains("主") && i.getMeterType().contains("进线") && i.getUniformCode().contains("ZXYG")
+                        )).map(i->i.getNemCode()).collect(Collectors.toList());
+
+                double zfdl = 0;
+                for (String meterid : zfdls) {
+                    zfdl += currentDay.stream().filter(i -> i.getMeterId().equals(meterid)).findFirst().isPresent() ? currentDay.stream().filter(i -> i.getMeterId().equals(meterid)).findFirst().get().getDayValueModify().doubleValue() : 0.0;
+                }
+                //算上网电量和购网电量
+                double swdl = 0;
+                double gwdl = 0;
+                double fcfdl = 0;
+                List<ProBasicMeterPoint> fcswmeter = wpmeterMap.get(project.getWindpowerstationId()).stream()
+                        .filter(i -> (
+                                i.getMeterSort().equals("主") && i.getMeterType().equals("出线") && i.getUniformCode().equals("ZXYG") && i.getProjectId().contains(project.getId())
+                        )).collect(Collectors.toList());
+                List<ProBasicMeterPoint> fcgwmeter = wpmeterMap.get(project.getWindpowerstationId()).stream()
+                        .filter(i -> (
+                                i.getMeterSort().equals("主") && i.getMeterType().equals("出线") && i.getUniformCode().equals("FXYG") && i.getProjectId().contains(project.getId())
+                        )).collect(Collectors.toList());
+                if (fcswmeter!=null &&fcswmeter.size()>1){
+                    String[] lineids = fcswmeter.get(0).getLineId().split("\\|");
+
+                    fcfdl = Arrays.stream(lineids).map(lineid ->
+                                    wpmeterMap.get(project.getWindpowerstationId())
+                                            .stream().filter(j -> j.getMeterSort().equals("主") && j.getMeterType().equals("进线") && j.getUniformCode().equals("ZXYG") && j.getLineId().equals(lineid)).findFirst().get())
+                            .mapToDouble(linemeterpoint2 -> currentDay.stream()
+                                    .filter(currentBdz -> currentBdz.getMeterId().equals(linemeterpoint2.getNemCode()))
+                                    .findFirst().get().getDayValueModify()).sum();
+
+
+                }
+                //算出
+                Double dayvaluesw = currentDay.stream().filter(currentBdz -> fcswmeter.contains(meterMap.get(currentBdz.getMeterId()))).mapToDouble(ProEconAnalysisSubtableBottom::getDayValueModify).sum();
+                Double dayvaluegw = currentDay.stream().filter(currentBdz -> fcgwmeter.contains(meterMap.get(currentBdz.getMeterId()))).mapToDouble(ProEconAnalysisSubtableBottom::getDayValueModify).sum();
+                swdl = fcfdl!=0?generatingcapacity/fcfdl*dayvaluesw:0;
+                gwdl = fcfdl!=0?generatingcapacity/fcfdl*dayvaluegw:0;
+
+                double fczyb = 0;
+                List<String> fczybmeterids = wpmeterMap.get(project.getWindpowerstationId()).stream()
+                        .filter(i -> (
+                                i.getMeterSort().equals("主") && i.getMeterType().equals("站用变") && i.getUniformCode().equals("ZXYG")
+                        )).map(i -> i.getNemCode()).collect(Collectors.toList());
+                for (String meterid : fczybmeterids) {
+                    fczyb += currentDay.stream().filter(i -> i.getMeterId().equals(meterid)).findFirst().isPresent() ? currentDay.stream().filter(i -> i.getMeterId().equals(meterid)).findFirst().get().getDayValueModify().doubleValue() : 0.0;
+                }
+
+
+
+                ProEconAnalysisSubprojectWindcan can = new ProEconAnalysisSubprojectWindcan();
+                ProEconAnalysisSubprojectWindcannot cannot = new ProEconAnalysisSubprojectWindcannot();
+//                ProEconAnalysisMain mainValues = getMainValues(day, project.getWindpowerstationId());
+//                can.setTid(mainValues.getId());
+                can.setProjectId(project.getId());
+                can.setWpid(project.getWindpowerstationId());
+                can.setRecordDate(DateUtils.parseDate(day));
+                can.setZjrl(project.getCapacity() / 10);
+
+
+//                can.setFdl(generatingcapacity / 10000);
+                can.setFdl(generatingcapacity);
+                if (project.getId().equals("SBQ04_GC")){
+//                    List<Analysissubstationpv> analysissubstationpvs = analysissubstationpvService.listByMap(bdzmap);
+//                    Double hzj_swdl = analysissubstationpvs.stream().filter(i -> i.getWpid().equals("HZJ_GDC")).findFirst().get().getFdl();
+//                    Double wgejx = currentDayBdz.stream().filter(i -> i.getMeterId().equals(WGEJX)).findFirst().get().getDayValueModify();
+//                    can.setSwdl((swdl-wgejx)/10000-hzj_swdl);
+                }else {
+                    can.setSwdl(swdl);
+//                    can.setSwdl(swdl / 10000);
+                }
+//                can.setGwdl(gwdl/ 10000);
+                can.setGwdl(gwdl);
+//                can.setCydl(fcfdl != 0.0 ? (generatingcapacity / zfdl * fczyb) / 10000 : 0.0);
+                can.setCydl(fcfdl != 0.0 ? (generatingcapacity / zfdl * fczyb) : 0.0);
+
+                QueryWrapper<ProEconPowerstationInfoDay1> queryWrapper = new QueryWrapper<>();
+                queryWrapper.eq("record_date", DateUtils.parseDate(day));
+                queryWrapper.eq("foreign_key_id", project.getId());
+                ProEconPowerstationInfoDay1 w = proEconPowerstationInfoDay1Service.getOne(queryWrapper);
+                QueryWrapper<ProEconPowerstationInfoDay3> wWrapper = new QueryWrapper<>();
+                wWrapper.eq("record_date", DateUtils.parseDate(day));
+                wWrapper.eq("foreign_key_id", project.getId());
+                ProEconPowerstationInfoDay3 one = windpowerinfoday3Service.getOne(wWrapper);
+                QueryWrapper<ProEconShutdownEvent2> shutparams = new QueryWrapper<>();
+                shutparams.eq("stop_time", DateUtils.parseDate(day));
+                shutparams.eq("project_id", project.getId());
+                //shutparams.put("statuscode",4);
+                List<ProEconShutdownEvent2> shut = shutdownevent2Service.list(shutparams);
+
+                Map<String, Object> inputparam = new HashMap<>();
+                inputparam.put("record_date", DateUtils.parseDate(day));
+                inputparam.put("project_id", project.getId());
+                List<ProEconInOrOutSpeedTotal> inputoroutputspeedtotals = inputoroutputspeedtotalService.listByMap(inputparam);
+                if (StringUtils.isNotEmpty(inputoroutputspeedtotals)) {
+                    OptionalDouble average = inputoroutputspeedtotals.stream().filter(i -> i.getDayInputSmall() != null).mapToDouble(ProEconInOrOutSpeedTotal::getDayInputSmall).average();
+                    if (average.isPresent()) {
+                        can.setPjqrfs(average.getAsDouble());
+                    } else {
+                        can.setPjqrfs(0.0);
+                    }
+                }else {
+                    can.setPjqrfs(0.0);
+                }
+                if (StringUtils.isNotNull(w)) {
+                    //性能不好降风速
+                    Double speed = w.getRpjfs().doubleValue();
+                    if (speed<5){
+                        can.setQpjfx(speed);
+                    }else if(speed<6){
+                        can.setQpjfx(speed-0.2);
+                    }else if(speed<7){
+                        can.setQpjfx(speed-0.3);
+                    }else if(speed<8){
+                        can.setQpjfx(speed-0.4);
+                    }else if(speed<9){
+                        can.setQpjfx(speed-0.5);
+                    }else if(speed<10){
+                        can.setQpjfx(speed-0.6);
+                    }else {
+                        can.setQpjfx(speed-0.8);
+                    }
+//                    can.setQpjfx(w.getSpeed());
+//                    can.setFjgzsj(w.getFaultTime());
+//                    can.setFjjxsj(w.getMaintainTime());
+//                    can.setZdcl(w.getMaxPower());
+//                    can.setZxcl(w.getMinPower());
+                } else {
+
+                    can.setQpjfx(0.0);
+                    can.setFjgzsj(0.0);
+                    can.setFjjxsj(0.0);
+                    can.setZdcl(0.0);
+                    can.setZxcl(0.0);
+                }
+
+                if (StringUtils.isNotNull(one)) {
+//                    can.setFjgzdl(one.getDaynhgzssdl() / 10000);
+//                    can.setXddl(one.getDaynhxdssdl() / 10000);
+//                    can.setXnssdl(one.getDaynhqfdl() / 10000);
+//                    can.setFjjxdl(one.getDaynhwhssdl() / 10000);
+                } else {
+                    can.setFjgzdl(0.0);
+                    can.setXddl(0.0);
+                    can.setXnssdl(0.0);
+                    can.setFjjxdl(0.0);
+                }
+                if (StringUtils.isNotEmpty(shut)) {
+                    can.setGzcs(Double.valueOf(shut.stream().filter(i -> i.getStatusCode() == 2).collect(Collectors.toList()).size()));
+                } else {
+                    can.setGzcs(0.0);
+                }
+                can.setFdlscada(can.getFdl() * 1.005);
+                can.setZhcydl(can.getFdl() + can.getGwdl() - can.getSwdl());
+                can.setZhcydll(can.getFdl() != 0 ? can.getZhcydl() / can.getFdl() * 100 : 0.0);
+                can.setZhcydlscada(can.getFdlscada() + can.getGwdl() - can.getSwdl());
+                can.setZhcydllscada(can.getFdlscada() != 0 ? can.getZhcydlscada() / can.getFdlscada() * 100 : 0.0);
+                can.setCydll(can.getFdl() != 0 ? can.getCydl() / can.getFdl() : 0.0);
+                can.setLyxs(can.getFdl() / can.getZjrl());
+                can.setLyxsscada(can.getFdlscada() / can.getZjrl());
+                if (can != null) {
+                    Double xddl = can.getXddl();
+                    Double fdl = can.getFdl();
+                    if (xddl != null && fdl != null) {
+                        can.setQfl(xddl + fdl != 0 ? xddl / (xddl + fdl) * 100 : 0.0);
+                    } else {
+                        can.setQfl(0.0);
+                    }
+                }
+
+                if (can.getFdl() != null && can.getFjgzdl() != null && can.getFjjxdl() != null && can.getXddl() != null) {
+                    can.setLlfdl(can.getFdl() + can.getFjgzdl() + can.getFjjxdl() + can.getXddl());  //+can.getXnssdl()
+                } else {
+                    can.setLlfdl(0.0);
+                }
+
+                if (can.getFdlscada() != null && can.getFjgzdl() != null && can.getFjjxdl() != null && can.getXddl() != null) {
+                    can.setLlfdlscada(can.getFdlscada() + can.getFjgzdl() + can.getFjjxdl() + can.getXddl());//+can.getXnssdl()
+                } else {
+                    can.setLlfdl(0.0);
+                }
+
+                can.setYjhfdl(getYjhfdl(project.getId(), day));
+                can.setDnaqts(getDnljts(day));
+                can.setCnsldwdl(0.0);
+                can.setCnsldwsj(0.0);
+                can.setCnsljxdl(0.0);
+                can.setCnsljxsj(0.0);
+                can.setCwsldwdl(0.0);
+                can.setCwsldwsj(0.0);
+                can.setCwsljxdl(0.0);
+                can.setCwsljxsj(0.0);
+                can.setZrzhdl(0.0);
+                can.setZrzhsj(0.0);
+                can.setXdsj(0.0);
+                can.setSyzgzdl(0.0);
+                can.setSyzgzsj(0.0);
+                can.setJdxlgzdl(0.0);
+                can.setJdxlgzsj(0.0);
+                can.setSyzjxdl(0.0);
+                can.setSyzjxsj(0.0);
+                can.setJdxljx(0.0);
+                can.setJdxljxsj(0.0);
+                can.setLjaqts(0.0);
+                can.setQw(0.0);
+                can.setTq("");
+                can.setFx("");
+                can.setEdpjfs(0.0);
+                can.setYpjkqmd(0.0);
+
+                CopyUtils.copy(can, cannot);
+                ProEconAnalysisSubprojectWindcanService.save(can);
+                ProEconAnalysisSubprojectWindcannotService.save(cannot);
+            }
+        }
+    }
+    private List<String> getDays(String beginDate, String endDate) {
+        List<String> days = null;
+        if (StringUtils.isNotEmpty(beginDate) && StringUtils.isNotEmpty(endDate)) {
+            days = DateUtils.getDays(beginDate, endDate);
+        } else {
+            days = new ArrayList<>();
+            days.add(DateUtils.getYesterdayStr("yyyy-MM-dd"));
+        }
+        return days;
+    }
+
+    private double getYjhfdl(String id, String day) {
+        String[] ny = new String[2];
+        Date date = DateUtils.parseDate(day);
+        ny[0] = String.format("%tY", date);
+        ny[1] = String.format("%tm", date);
+        QueryWrapper<ProBasicProjectPlan> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("project_id", id);
+        queryWrapper.eq("year", ny[0]);
+        queryWrapper.eq("month", ny[1]);
+        ProBasicProjectPlan one = proBasicProjectPlanService.getOne(queryWrapper);
+        if (StringUtils.isNotNull(one)) {
+            return (one.getGeneratingCapacity());
+        }
+        return 0.0;
+
+    }
+    private Double getDnljts(String day) {
+        Calendar c = Calendar.getInstance();
+        c.setTime(DateUtils.parseDate(day));
+        return Double.valueOf(c.get(Calendar.DAY_OF_YEAR));
+    }
+
+}

+ 3 - 1
realtime/generationXK-service/src/main/java/com/gyee/generation/service/auto/IProEconAnalysisSubtableBottomService.java

@@ -3,6 +3,8 @@ package com.gyee.generation.service.auto;
 import com.gyee.generation.model.auto.ProEconAnalysisSubtableBottom;
 import com.baomidou.mybatisplus.extension.service.IService;
 
+import java.util.List;
+
 /**
  * <p>
  * 风电表底 服务类
@@ -12,5 +14,5 @@ import com.baomidou.mybatisplus.extension.service.IService;
  * @since 2023-11-29
  */
 public interface IProEconAnalysisSubtableBottomService extends IService<ProEconAnalysisSubtableBottom> {
-
+    boolean batchAdd (List<ProEconAnalysisSubtableBottom> proEconStationPowers);
 }

+ 24 - 0
realtime/generationXK-service/src/main/java/com/gyee/generation/service/auto/impl/ProEconAnalysisSubtableBottomServiceImpl.java

@@ -1,11 +1,14 @@
 package com.gyee.generation.service.auto.impl;
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.gyee.generation.model.auto.ProEconAnalysisSubtableBottom;
 import com.gyee.generation.mapper.auto.ProEconAnalysisSubtableBottomMapper;
 import com.gyee.generation.service.auto.IProEconAnalysisSubtableBottomService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springframework.stereotype.Service;
 
+import java.util.List;
+
 /**
  * <p>
  * 风电表底 服务实现类
@@ -16,5 +19,26 @@ import org.springframework.stereotype.Service;
  */
 @Service
 public class ProEconAnalysisSubtableBottomServiceImpl extends ServiceImpl<ProEconAnalysisSubtableBottomMapper, ProEconAnalysisSubtableBottom> implements IProEconAnalysisSubtableBottomService {
+    @Override
+    public boolean batchAdd(List<ProEconAnalysisSubtableBottom> proEconStationPowers) {
+        try {
+            proEconStationPowers.stream().forEach(i -> {
+                QueryWrapper<ProEconAnalysisSubtableBottom> qw = new QueryWrapper<>();
+                qw.lambda().eq(ProEconAnalysisSubtableBottom::getRecordDate, i.getRecordDate());
+                qw.lambda().eq(ProEconAnalysisSubtableBottom::getMeterId, i.getMeterId());
+                int count = baseMapper.selectCount(qw);
+                if (count > 0) {
+                    baseMapper.update(i, qw);
+                } else if (count <= 0) {
+                    baseMapper.insert(i);
+                }
+
+            });
+        } catch (Exception e) {
+            e.printStackTrace();
+            return false;
+        }
 
+        return true;
+    }
 }

+ 32 - 2
realtime/generationXK-service/src/main/java/com/gyee/generation/task/SaticSchedulePgTask.java

@@ -94,6 +94,9 @@ public class SaticSchedulePgTask {
     @Resource
     private StationPowerService powerService;
 
+    @Resource
+    private AnalysisNewService analysisNewService;
+
     /**
      * 缓存Redis散点图数据
      * 每天执行一次
@@ -1565,12 +1568,39 @@ public class SaticSchedulePgTask {
     public void Powerccuracy() {
 
 
-        XxlJobHelper.log("预测功率准确率计算执行开始!........");
+        XxlJobHelper.log("系统效率计算执行开始!........");
         try {
             powerService.predictedPower();
         } catch (Exception e) {
             e.printStackTrace();
         }
-        XxlJobHelper.log("预测功率准确率计算执行开始!........");
+        XxlJobHelper.log("系统效率计算执行开始!........");
+    }
+
+
+    @XxlJob("companysjs")
+    public void companysjs() {
+
+
+        XxlJobHelper.log("底码计算执行开始!........");
+        try {
+            analysisNewService.companys();
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        XxlJobHelper.log("底码计算计算执行开始!........");
+    }
+
+    @XxlJob("saveWindProjectjs")
+    public void saveWindProjectjs() {
+
+
+        XxlJobHelper.log("底码电量计算执行开始!........");
+        try {
+            analysisNewService.saveWindProject();
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        XxlJobHelper.log("底码电量计算执行开始!........");
     }
 }

+ 25 - 0
realtime/generationXK-service/src/main/resources/xxl-job-analyNew.properties

@@ -0,0 +1,25 @@
+### xxl-job admin address list, such as "http://address" or "http://address01,http://address02"
+xxl.job.admin.addresses=http://10.81.3.152:8179/xxl-job-admin
+
+### xxl-job, access token
+xxl.job.accessToken=
+
+### xxl-job executor appname
+### 场站计算
+#xxl.job.executor.appname=generationWP-job
+### 区域公司计算
+xxl.job.executor.appname=analy-job
+### xxl-job executor registry-address: default use address to registry , otherwise use ip:port if address is null
+xxl.job.executor.address=
+### xxl-job executor server-info
+xxl.job.executor.ip=
+#场站端口
+#xxl.job.executor.port=9201
+#区域端口
+xxl.job.executor.port=9380
+
+### xxl-job executor log-path
+xxl.job.executor.logpath=E:\gyee\log\analy
+### xxl-job executor log-retention-days
+xxl.job.executor.logretentiondays=30
+

+ 8 - 0
realtime/generationXK-service/src/test/java/com/gyee/generation/GenerationTest.java

@@ -1,5 +1,6 @@
 package com.gyee.generation;
 
+import com.gyee.generation.service.AnalysisNewService;
 import com.gyee.generation.service.PVSystemEfficiencyCalculator;
 import com.gyee.generation.service.StationPower.StationPowerService;
 import com.gyee.generation.service.initalcache.CacheService;
@@ -48,6 +49,9 @@ public class GenerationTest {
 
     @Resource
     private PVSystemEfficiencyCalculator calculator;
+
+    @Resource
+    private AnalysisNewService analysisNewService;
     @Test
     public void test1() throws Exception {
         cacheService.initRedisCache();
@@ -105,5 +109,9 @@ public class GenerationTest {
 
         calculator.planvalue();
 
+        analysisNewService.companys();
+        analysisNewService.saveWindProject();
+
+
     }
 }