Browse Source

优化后台计算算法

shilin 1 year ago
parent
commit
6b89085b0b

+ 51 - 4
web/health/src/main/java/com/gyee/health/controller/leaderboard/LeaderboardController.java

@@ -2,9 +2,13 @@ package com.gyee.health.controller.leaderboard;
 
 import com.gyee.health.dto.AjaxResult;
 import com.gyee.health.dto.AjaxStatus;
+import com.gyee.health.init.CacheContext;
+import com.gyee.health.model.auto.ProBasicEquipment;
 import com.gyee.health.model.auto.ProEconCurveFittMonthMain;
 import com.gyee.health.model.auto.ProEconCurveFittingMain;
 import com.gyee.health.model.custom.Tablepar;
+import com.gyee.health.model.vo.ProEconCurveFittMonthMainVo;
+import com.gyee.health.model.vo.ProEconCurveFittingMainVo;
 import com.gyee.health.service.leaderboard.LeaderboardService;
 import com.gyee.health.util.DateUtils;
 import com.gyee.health.util.StringUtils;
@@ -46,9 +50,30 @@ public class LeaderboardController {
         }
 
         if (vos != null && !vos.isEmpty()) {
-            return AjaxResult.successData(AjaxStatus.success.code, vos);
+
+            List<ProEconCurveFittingMainVo> ls=new ArrayList<>();
+            for(ProEconCurveFittingMain vo:vos)
+            {
+                ProEconCurveFittingMainVo po=new ProEconCurveFittingMainVo();
+                po.setId(vo.getId());
+                po.setRecordDate(vo.getRecordDate());
+                po.setDeviationRate1(vo.getDeviationRate1());
+                po.setDeviationRate3(vo.getDeviationRate3());
+                po.setDeviationRate2(vo.getDeviationRate2());
+                po.setWindturbineId(vo.getWindturbineId());
+                po.setMonthDeviationRate(vo.getMonthDeviationRate());
+                po.setStandardDeviationRate(vo.getStandardDeviationRate());
+                po.setYearDeviationRate(vo.getYearDeviationRate());
+                if(CacheContext.wtmap.containsKey(vo.getWindturbineId()))
+                {
+                    ProBasicEquipment wt=CacheContext.wtmap.get(vo.getWindturbineId());
+                    po.setWtCode(wt.getNemCode());
+                }
+                ls.add(po);
+            }
+            return AjaxResult.successData(AjaxStatus.success.code, ls);
         } else {
-            return AjaxResult.successData(AjaxStatus.success.code, vos);
+            return AjaxResult.successData(AjaxStatus.success.code, new ArrayList<ProEconCurveFittingMainVo>());
         }
     }
 
@@ -167,9 +192,31 @@ public class LeaderboardController {
         List<ProEconCurveFittMonthMain> vos= leaderboardService.curvefittingmonthmainList( tablepar, wpId, year, month);
 
         if (vos != null && !vos.isEmpty()) {
-            return AjaxResult.successData(AjaxStatus.success.code, vos);
+
+            List<ProEconCurveFittMonthMainVo> ls=new ArrayList<>();
+            for(ProEconCurveFittMonthMain vo:vos)
+            {
+                ProEconCurveFittMonthMainVo po=new ProEconCurveFittMonthMainVo();
+                po.setId(vo.getId());
+                po.setMonth(vo.getMonth());
+                po.setYear(vo.getYear());
+                po.setDeviationRate1(vo.getDeviationRate1());
+                po.setDeviationRate3(vo.getDeviationRate3());
+                po.setDeviationRate2(vo.getDeviationRate2());
+                po.setWindturbineId(vo.getWindturbineId());
+                po.setMonthDeviationRate(vo.getMonthDeviationRate());
+                po.setStandardDeviationRate(vo.getStandardDeviationRate());
+                po.setYearDeviationRate(vo.getYearDeviationRate());
+                if(CacheContext.wtmap.containsKey(vo.getWindturbineId()))
+                {
+                    ProBasicEquipment wt=CacheContext.wtmap.get(vo.getWindturbineId());
+                    po.setWtCode(wt.getNemCode());
+                }
+                ls.add(po);
+            }
+            return AjaxResult.successData(AjaxStatus.success.code, ls);
         } else {
-            return AjaxResult.successData(AjaxStatus.success.code, vos);
+            return AjaxResult.successData(AjaxStatus.success.code, new ProEconCurveFittMonthMainVo());
         }
     }
 

+ 6 - 2
web/health/src/main/java/com/gyee/health/controller/powersaturation/PowerSaturationAmonutController.java

@@ -42,6 +42,7 @@ public class PowerSaturationAmonutController {
     public AjaxResult powersaturationamonutlist(@RequestBody Tablepar tablepar, String wtId) {
 
         IPage<ProEconWtPowerCurveFitting> vos=null;
+
         if (StringUtils.notEmp(wtId) )
         {
             vos=proEconWtPowerCurveFittingService.getWindturbinecurvefitting(tablepar, wtId);
@@ -74,6 +75,8 @@ public class PowerSaturationAmonutController {
 
             List<ProEconWtPowerCurveFitting> wcls=proEconWtPowerCurveFittingService.getWindturbinepowercurvefittingByWtId(wtId);
 
+
+
             if (!wcls.isEmpty()) {
 //				Collections.sort(wcls, new Comparator<ProEconWtPowerCurveFitting>() {
 //					public int compare(ProEconWtPowerCurveFitting arg0, ProEconWtPowerCurveFitting arg1) {
@@ -103,8 +106,9 @@ public class PowerSaturationAmonutController {
                         vo.setValue2(wc.getActualPower());// 实际拟合功率
                         vo.setValue3(wc.getOptimalPower());// 最优拟合功率
 
-                        if (null != map && StringUtils.notEmp(wc.getSpeed()) && map.containsKey(String.valueOf(wc.getSpeed()))) {
-                            ProBasicModelPowerRd mp = map.get(String.valueOf(wc.getSpeed()));
+
+                        if (null != map && StringUtils.notEmp(wc.getSpeed()) && map.containsKey(wc.getSpeed())) {
+                            ProBasicModelPowerRd mp = map.get(wc.getSpeed());
                             vo.setValue4(mp.getEnsurePower());// 保证功率曲线
                             temp = mp.getEnsurePower();
                         } else {

+ 2 - 2
web/health/src/main/java/com/gyee/health/controller/powersaturation/PowerSaturationController.java

@@ -100,8 +100,8 @@ public class PowerSaturationController {
                         vo.setValue2(wc.getActualPower());// 实际拟合功率
                         vo.setValue3(wc.getOptimalPower());// 最优拟合功率
 
-                        if (null != map && StringUtils.notEmp(wc.getSpeed()) && map.containsKey(String.valueOf(wc.getSpeed()))) {
-                            ProBasicModelPowerRd mp = map.get(String.valueOf(wc.getSpeed()));
+                        if (null != map && StringUtils.notEmp(wc.getSpeed()) && map.containsKey(wc.getSpeed())) {
+                            ProBasicModelPowerRd mp = map.get(wc.getSpeed());
                             vo.setValue4(mp.getEnsurePower());// 保证功率曲线
                             temp = mp.getEnsurePower();
                         } else {

+ 2 - 2
web/health/src/main/java/com/gyee/health/controller/powersaturation/PowerSaturationMonthController.java

@@ -98,8 +98,8 @@ public class PowerSaturationMonthController {
                         vo.setValue2(wc.getActualPower());// 实际拟合功率
                         vo.setValue3(wc.getOptimalPower());// 最优拟合功率
 
-                        if (null != map && StringUtils.notEmp(wc.getSpeed()) && map.containsKey(String.valueOf(wc.getSpeed()))) {
-                            ProBasicModelPowerRd mp = map.get(String.valueOf(wc.getSpeed()));
+                        if (null != map && StringUtils.notEmp(wc.getSpeed()) && map.containsKey(wc.getSpeed())) {
+                            ProBasicModelPowerRd mp = map.get(wc.getSpeed());
                             vo.setValue4(mp.getEnsurePower());// 保证功率曲线
                             temp = mp.getEnsurePower();
                         } else {

+ 67 - 0
web/health/src/main/java/com/gyee/health/model/vo/ProEconCurveFittMonthMainVo.java

@@ -0,0 +1,67 @@
+package com.gyee.health.model.vo;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import lombok.Data;
+
+@Data
+public class ProEconCurveFittMonthMainVo {
+
+
+    /**
+     * 编号
+     */
+    @TableId(value = "ID",type = IdType.ASSIGN_UUID)
+    private String id;
+
+    /**
+     * 风机编号
+     */
+    private String windturbineId;
+
+    /**
+     * 年
+     */
+    private String year;
+
+    /**
+     * 月
+     */
+    private String month;
+
+    /**
+     * 环比
+     */
+    private Double monthDeviationRate;
+
+    /**
+     * 同比
+     */
+    private Double yearDeviationRate;
+
+    /**
+     * 与标杆风机比
+     */
+    private Double standardDeviationRate;
+
+    /**
+     * 实际/最优
+     */
+    private Double deviationRate1;
+
+    /**
+     * 实际/保证
+     */
+    private Double deviationRate2;
+
+    /**
+     * 最优/保证
+     */
+    private Double deviationRate3;
+
+
+    private String wtCode;
+
+
+
+}

+ 64 - 0
web/health/src/main/java/com/gyee/health/model/vo/ProEconCurveFittingMainVo.java

@@ -0,0 +1,64 @@
+package com.gyee.health.model.vo;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import lombok.Data;
+
+import java.util.Date;
+
+@Data
+public class ProEconCurveFittingMainVo {
+
+
+    /**
+     * 编号
+     */
+    @TableId(value = "ID",type = IdType.ASSIGN_UUID)
+    private String id;
+
+    /**
+     * 风机编号
+     */
+    private String windturbineId;
+
+    /**
+     * 环比
+     */
+    private Double monthDeviationRate;
+
+    /**
+     * 同比
+     */
+    private Double yearDeviationRate;
+
+    /**
+     * 与标杆风机比
+     */
+    private Double standardDeviationRate;
+
+    /**
+     * 日期
+     */
+    private Date recordDate;
+
+    /**
+     * 实际/最优
+     */
+    private Double deviationRate1;
+
+    /**
+     * 实际/保证
+     */
+    private Double deviationRate2;
+
+    /**
+     * 最优/保证
+     */
+    private Double deviationRate3;
+
+
+    private String wtCode;
+
+
+
+}

+ 13 - 1
web/health/src/main/java/com/gyee/health/service/auto/impl/ProEconWtCurveFittingServiceImpl.java

@@ -14,6 +14,7 @@ import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
 import java.util.ArrayList;
+import java.util.Calendar;
 import java.util.Date;
 import java.util.List;
 
@@ -74,7 +75,7 @@ public class ProEconWtCurveFittingServiceImpl extends ServiceImpl<ProEconWtCurve
 
         Date endDate= DateUtils.addDays(date,1);
         qw.ge("record_date",date);
-        qw.le("record_date",endDate);
+        qw.lt("record_date",endDate);
 
         list = proEconWtCurveFittingMapper.selectList(qw);
         return list;
@@ -106,6 +107,7 @@ public class ProEconWtCurveFittingServiceImpl extends ServiceImpl<ProEconWtCurve
             qw.orderByAsc("speed");
         }
 
+        qw.in("windturbine_id",wtId);
         Page<ProEconWtCurveFitting> page = new Page<>(tablepar.getPageNum(), tablepar.getPageSize());
         IPage<ProEconWtCurveFitting> pageInfo = proEconWtCurveFittingMapper.selectPage(page, qw);
 
@@ -156,6 +158,16 @@ public class ProEconWtCurveFittingServiceImpl extends ServiceImpl<ProEconWtCurve
             qw.orderByAsc("speed");
         }
 
+        qw.eq("windturbine_id",wtId);
+        qw.ge("record_date",date);
+
+        Calendar c=Calendar.getInstance();
+        c.setTime(date);
+        c.add(Calendar.DAY_OF_MONTH,1);
+        Date end=c.getTime();
+        qw.ge("record_date",date);
+        qw.lt("record_date",end);
+
         Page<ProEconWtCurveFitting> page = new Page<>(tablepar.getPageNum(), tablepar.getPageSize());
         IPage<ProEconWtCurveFitting> pageInfo = proEconWtCurveFittingMapper.selectPage(page, qw);
 

+ 10 - 1
web/health/src/main/java/com/gyee/health/service/auto/impl/ProEconWtPowerCurveFittingServiceImpl.java

@@ -107,6 +107,15 @@ public class ProEconWtPowerCurveFittingServiceImpl extends ServiceImpl<ProEconWt
             qw.orderByAsc("speed");
         }
 
+        qw.eq("windturbine_id",wtId);
+        qw.ge("record_date",date);
+
+        Calendar c=Calendar.getInstance();
+        c.setTime(date);
+        c.add(Calendar.DAY_OF_MONTH,1);
+        Date end=c.getTime();
+        qw.ge("record_date",date);
+        qw.lt("record_date",end);
         Page<ProEconWtPowerCurveFitting> page = new Page<>(tablepar.getPageNum(), tablepar.getPageSize());
         IPage<ProEconWtPowerCurveFitting> pageInfo = proEconWtPowerCurveFittingMapper.selectPage(page, qw);
 
@@ -121,7 +130,7 @@ public class ProEconWtPowerCurveFittingServiceImpl extends ServiceImpl<ProEconWt
 
         QueryWrapper<ProEconWtPowerCurveFitting> qw = new QueryWrapper<>();
 
-
+        qw.eq("windturbine_id",wtId);
 
         if(StringUtils.isNotEmpty(tablepar.getOrderByColumn()))
         {

+ 2 - 2
web/health/src/main/resources/application-jn.properties

@@ -3,8 +3,8 @@ server.port=8172
 
 #\u670D\u52A1\u540D\u79F0
 spring.application.name=health-hb-provider
-#spring.cloud.nacos.discovery.server-addr=10.81.3.155:8848
-spring.cloud.nacos.discovery.server-addr=127.0.0.1:8870
+spring.cloud.nacos.discovery.server-addr=10.81.3.155:8848
+#spring.cloud.nacos.discovery.server-addr=127.0.0.1:8870
 
 #nacos\u7684\u7528\u6237\u540D\u548C\u5BC6\u7801
 spring.cloud.nacos.username=nacos