瀏覽代碼

峰平谷

guoqiang 7 月之前
父節點
當前提交
58762bffe3

+ 23 - 10
jeecg-module-gather/src/main/java/org/jeecg/modules/fpgJob/LeanModelStatistics.java

@@ -15,9 +15,14 @@ import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Component;
 
 import java.text.SimpleDateFormat;
+import java.time.LocalDateTime;
+import java.time.LocalTime;
+import java.util.Calendar;
 import java.util.Date;
 import java.util.List;
 
+import static org.bouncycastle.asn1.x500.style.RFC4519Style.c;
+
 @Slf4j
 @EnableAsync
 @Component
@@ -47,12 +52,12 @@ public class LeanModelStatistics {
         LambdaQueryWrapper<FpgLeanModel> leanmodelQuery = new LambdaQueryWrapper<FpgLeanModel>().eq(FpgLeanModel::getStatus, "1");
         List<FpgLeanModel> fpgLeanModellist = fpgLeanModelService.list(leanmodelQuery);
         log.info("峰平谷模型");
-        //获取当前时间
+        // 获取当前时间
         Date curentDate = new Date();
         //遍历设备集合
         fpgLeanModellist.forEach(fpgLeanModeInfo -> {
             String datestr = "";
-            String classs = "night";
+            String classs = "";
             try {
                 // 统计单位
                 if("hour". equals(fpgLeanModeInfo.getTotalUnit())){ // 小时
@@ -60,23 +65,31 @@ public class LeanModelStatistics {
                 } else if("day". equals(fpgLeanModeInfo.getTotalUnit())){ //
                     datestr = new SimpleDateFormat("dd").format(curentDate);
                 } else if("week". equals(fpgLeanModeInfo.getTotalUnit())){ //
-                    datestr = new SimpleDateFormat("").format(curentDate);
+                    Calendar calendar = Calendar.getInstance();
+                    datestr = String.valueOf(calendar.get(Calendar.WEEK_OF_MONTH));
                 } else if("month". equals(fpgLeanModeInfo.getTotalUnit())){ //
                     datestr = new SimpleDateFormat("MM").format(curentDate);
                 }
                 // 班次处理
                 if(fpgLeanModeInfo.getClassUnit() == 1){ // 开启了班次统计
-                    if("night". equals(fpgLeanModeInfo.getTotalUnit())){ // 夜班
-                        classs = "";
-                    } else if("white". equals(fpgLeanModeInfo.getTotalUnit())){ // 白班
-                        classs = "";
-                    } else if("center". equals(fpgLeanModeInfo.getTotalUnit())){ // 中班
-                        classs = "";
+                    LocalDateTime now = LocalDateTime.now();
+                    LocalDateTime nightStartTime = LocalDateTime.of(now.toLocalDate(), LocalTime.of(0, 0));
+                    LocalDateTime nightEndTime = LocalDateTime.of(now.toLocalDate(), LocalTime.of(8, 0));
+                    LocalDateTime whiteStartTime = LocalDateTime.of(now.toLocalDate(), LocalTime.of(8, 0));
+                    LocalDateTime whiteEndTime = LocalDateTime.of(now.toLocalDate(), LocalTime.of(16, 0));
+                    LocalDateTime centerStartTime = LocalDateTime.of(now.toLocalDate(), LocalTime.of(16, 0));
+                    LocalDateTime centerEndTime = LocalDateTime.of(now.toLocalDate(), LocalTime.of(0, 0));
+                    if(now.isBefore(nightStartTime) && now.isBefore(nightEndTime)){ // 夜班
+                        classs = "night";
+                    } else if(now.isBefore(whiteStartTime) && now.isBefore(whiteEndTime)){ // 白班
+                        classs = "white";
+                    } else if(now.isBefore(centerStartTime) && now.isBefore(centerEndTime)){ // 中班
+                        classs = "center";
                     }
                 }
                 FpgGatherData FpgGatherData = fpgGatherDataService.getById("1836591252581129108");
                 //将点位数据存入mongo中
-                mongoTemplate.insert(new FpgStatiscsModelData(FpgGatherData, fpgLeanModeInfo, datestr,  new SimpleDateFormat("yyyy-MM-dd").format(curentDate), classs, curentDate, curentDate),  fpgLeanModeInfo.getLeanModelCode());
+                mongoTemplate.insert(new FpgStatiscsModelData(FpgGatherData, fpgLeanModeInfo, datestr,  new SimpleDateFormat("yyyy-MM-dd").format(curentDate), classs, curentDate, curentDate),  "leanmodel_" +fpgLeanModeInfo.getLeanModelCode());
             } catch (Exception e) {
                 log.error(e.getMessage());
             } finally {

+ 5 - 1
jeecg-module-gather/src/main/java/org/jeecg/modules/gatherData/entity/FpgStatiscsModelData.java

@@ -138,9 +138,13 @@ public class FpgStatiscsModelData{
             this.flatIngTime = new BigDecimal("0.00");
             this.valleysIngTime = new BigDecimal("0.00");
         }
+        if(fpgLeanModel.getTopsPrice() != null){ // 尖单价电费
+            this.topsPrice = fpgLeanModel.getTopsPrice();
+            this.topsAmount = new BigDecimal("0.00");
+        }
         if(fpgLeanModel.getPeaksPrice() != null){ // 峰单价电费
             this.peaksPrice = fpgLeanModel.getPeaksPrice();
-            this.topsAmount = new BigDecimal("0.00");
+            this.peaksAmount = new BigDecimal("0.00");
         }
         if(fpgLeanModel.getFlatPrice() != null){ // 平单价电费
             this.flatPrice = fpgLeanModel.getFlatPrice();