Browse Source

controller,当月每日发电量,日购网电量,日上网电量1

malijun 2 years atrás
parent
commit
48695282c3

+ 1 - 1
electricity/meter/build.gradle

@@ -47,7 +47,7 @@ dependencies {
     implementation("$cloudGroup:spring-cloud-starter-openfeign")
     implementation("cn.hutool:hutool-all:5.8.18")
     implementation("org.springframework.boot:spring-boot-configuration-processor")
-    implementation('org.codehaus.groovy:groovy-all:2.4.15')
+    implementation("org.codehaus.groovy:groovy-all:2.4.1")
 
 }
 

+ 18 - 12
electricity/meter/src/main/java/com/gyee/gaia/meter/controller/MeterController.java

@@ -3,11 +3,13 @@ package com.gyee.gaia.meter.controller;
 import com.gyee.gaia.meter.entity.vo.MeterInfoVO;
 import com.gyee.gaia.meter.entity.vo.Result;
 import com.gyee.gaia.meter.service.meterinfo.GetWindStationInfo;
+import org.springframework.web.bind.annotation.CrossOrigin;
 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.HashMap;
 import java.util.List;
 
 /**
@@ -15,29 +17,33 @@ import java.util.List;
  * Data  : 2023: 05: 21
  **/
 @RestController
-@RequestMapping("/meter")
+@CrossOrigin(origins = "*")
+@RequestMapping("/meterinfo")
 public class MeterController {
     @Resource
     GetWindStationInfo getWindStationInfo;
 
 
+    @GetMapping("")
+    public Result<Object> getMeterInfoFDC1(int id) {
+        if (-1 == id) {
+            // 查询返回总场站当月日发电量,上网电量,购网电量
+            List<MeterInfoVO> meterInfoFDC = getWindStationInfo.getMeterInfoFDC_Day();
 
-    @GetMapping("/fc")
-    public List<MeterInfoVO> getMeterInfoFDC() {
-        //查询返回当月日发电量,上网电量,购网电量
-        return getWindStationInfo.getMeterInfoFDC();
+            //查询返回总场站日发电量,月发电量,年发电量
+            MeterInfoVO meterInfoFDCFDLDayMonthYear = getWindStationInfo.getMeterInfoFDCFDL_DayMonthYear();
 
-    }
 
-    @GetMapping("/fdc")
-    public Result<List<MeterInfoVO>> getMeterInfoFDCAll1() {
-        //查询返回当月日发电量,上网电量,购网电量
-        List<MeterInfoVO> meterInfoFDC = getWindStationInfo.getMeterInfoFDC();
-        return new Result<>(200, "获取数据成功!", meterInfoFDC);
+            HashMap<Object, Object> map = new HashMap<>();
+            map.put("rdlmap",meterInfoFDC);
+            map.put("zdlmap",meterInfoFDCFDLDayMonthYear);
+            return  new Result<>(200, "获取数据成功!", map);
 
+        } else {
+            return null;
+        }
     }
 
 
 
-
 }

+ 12 - 0
electricity/meter/src/main/java/com/gyee/gaia/meter/entity/vo/MeterInfoVO.java

@@ -16,10 +16,22 @@ public class MeterInfoVO {
     //    public BigDecimal rfdl;
 //    public BigDecimal rswdl;
 //    public BigDecimal rgwdl;
+
+    //日发电量
     public BigDecimal value1;
+    //日上网电量
     public BigDecimal value2;
+    //日购网电量
     public BigDecimal value3;
+    //风速
     public BigDecimal speed;
 
+    //总风场日发电量
+    public BigDecimal dayFDL;
+    //总风场月发电量
+    public BigDecimal monthFDL;
+    //总风场年发电量
+    public BigDecimal yearFDL;
+
 
 }

+ 1 - 1
electricity/meter/src/main/java/com/gyee/gaia/meter/service/SaveMeterInfoHistoryMonthYearTest.java

@@ -1310,7 +1310,7 @@ public class SaveMeterInfoHistoryMonthYearTest {
             meterInfoCalculating.setCode(meterPoint.getNemCode());
             //LocalDateTime只显示年月(实际为每月的1号00:00:00)
             meterInfoCalculating.setDate(dateTime1.toLocalDateTime());
-            meterInfoCalculating.setValue(BigDecimal.valueOf(monthValue));
+            meterInfoCalculating.setValue(BigDecimal.valueOf(monthValue).divide(BigDecimal.valueOf(10000),4,RoundingMode.HALF_EVEN));
             meterInfoCalculating.setUpdateTime(LocalDateTime.now());
 
             QueryWrapper<MeterInfoCalculating> queryWrapper = new QueryWrapper<>();

+ 50 - 2
electricity/meter/src/main/java/com/gyee/gaia/meter/service/meterinfo/GetWindStationInfo.java

@@ -25,7 +25,7 @@ public class GetWindStationInfo {
 
     //查询当月天数,返回当月每天的数据,日发电量,日上网电量,日购网电量
 
-    public List<MeterInfoVO> getMeterInfoFDC() {
+    public List<MeterInfoVO> getMeterInfoFDC_Day() {
 
         //当前时间
         DateTime now = DateTime.now();
@@ -58,7 +58,7 @@ public class GetWindStationInfo {
             if (oneSWDL != null) {
                 rswdl = oneSWDL.getValue();
             }
-            if (oneSWDL != null) {
+            if (oneGWDL != null) {
                 rgwdl = oneGWDL.getValue();
             }
 
@@ -76,4 +76,52 @@ public class GetWindStationInfo {
 
         return list;
     }
+
+    public MeterInfoVO getMeterInfoFDCFDL_DayMonthYear() {
+        //当前时间
+        DateTime now = DateTime.now();
+        //当天开始时间
+        DateTime beginOfDay = DateUtil.beginOfDay(now);
+        //当月开始时间
+        DateTime beginOfMonth = DateUtil.beginOfMonth(now);
+        //当年开始时间
+        DateTime beginOfYear = DateUtil.beginOfYear(now);
+        //当月天数
+        int days = DateUtil.dayOfMonth(now);
+
+        //根据时间和code查询风场日发电量,日上网电量
+        MeterInfoCalculating dayFDL = meterInfoCalculatingService.getOne(new QueryWrapper<MeterInfoCalculating>().eq("code", "DL.NX_GD_WINDSTATIONFDL_DAY").eq("date", beginOfDay));
+        MeterInfoCalculating monthFDL = meterInfoCalculatingService.getOne(new QueryWrapper<MeterInfoCalculating>().eq("code", "DL.NX_GD_WINDSTATIONFDL_MONTH").eq("date", beginOfMonth));
+        MeterInfoCalculating yearFDL = meterInfoCalculatingService.getOne(new QueryWrapper<MeterInfoCalculating>().eq("code", "DL.NX_GD_WINDSTATIONFDL_YEAR").eq("date", beginOfYear));
+        MeterInfoCalculating oneSWDL = meterInfoCalculatingService.getOne(new QueryWrapper<MeterInfoCalculating>().eq("code", "DL.NX_GD_WINDSTATIONSWDL_DAY").eq("date", beginOfDay));
+
+
+
+        BigDecimal rfdl = BigDecimal.valueOf(0);
+        BigDecimal yfdl = BigDecimal.valueOf(0);
+        BigDecimal nfdl = BigDecimal.valueOf(0);
+        BigDecimal rswdl = BigDecimal.valueOf(0);
+
+        if (dayFDL != null) {
+            rfdl = dayFDL.getValue();
+        }
+        if (monthFDL != null) {
+            yfdl = monthFDL.getValue();
+        }
+        if (yearFDL != null) {
+            nfdl = yearFDL.getValue();
+        }
+        if (oneSWDL != null) {
+            rswdl = oneSWDL.getValue();
+        }
+
+
+        MeterInfoVO meterInfoVO = new MeterInfoVO();
+        meterInfoVO.setDayFDL(rfdl);
+        meterInfoVO.setMonthFDL(yfdl);
+        meterInfoVO.setYearFDL(nfdl);
+        meterInfoVO.setValue2(rswdl);
+        return meterInfoVO;
+
+    }
 }

+ 2 - 2
electricity/meter/src/main/resources/application.properties

@@ -6,9 +6,9 @@
 adapter.url=http://192.168.1.67:8011/ts
 
 #动态配置开始日期
-start.time=2023-05-01
+start.time=2023-02-01
 #动态配置结束日期
-end.time=2023-05-22
+end.time=2023-03-01
 
 meter.stations=MHS_FDC,NSS_FDC
 

+ 1 - 1
electricity/meter/src/main/resources/bootstrap.yaml

@@ -1,5 +1,5 @@
 server:
-  port: 8021
+  port: 8022
 
 spring:
   application:

+ 12 - 0
electricity/meter/src/main/resources/cross.html

@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html>
+<script type="text/javascript">
+  var xhr = new XMLHttpRequest();
+  xhr.open('GET', 'http://192.168.10.24:8021/meterinfo?id=-1'); // 换为自己的接口地址
+  xhr.send(null);
+  xhr.onload = function(e) {
+    var xhr = e.target;
+    console.log(xhr.responseText);
+  }
+</script>
+</html>