xushili 2 miesięcy temu
rodzic
commit
6ebde132cb

+ 3 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/runner/ServiceGroup.java

@@ -60,6 +60,8 @@ public class ServiceGroup {
     private IPointInfoService pointService;
     @Resource
     private IProEconBrownoutsEvent2Service event2Service;
+    @Resource
+    private IProjectInfoMonthService projectInfoMonthService;
 
     @PostConstruct
     public void init() {
@@ -86,6 +88,7 @@ public class ServiceGroup {
         serviceMap.put(StationInfoHour.class, stationInfoHourService);
         serviceMap.put(PointInfo.class, pointService);
         serviceMap.put(ProEconBrownoutsEvent2.class, event2Service);
+        serviceMap.put(ProjectInfoMonth.class, projectInfoMonthService);
     }
 
     @SuppressWarnings("unchecked")

+ 21 - 9
ruoyi-admin/src/test/java/com/ruoyi/NewTests.java

@@ -402,7 +402,7 @@ public class NewTests {
             task.calcTurbineRFDL(t1, t2);
             //task.calcStationRfdlFj(b1);
             //task.calcHaBbHz(date);
-            //task.calcHaBbHzSs(date, b2);
+            task.calcHaBbHzSs(date, b2);
             //task.calcRYNxdl(b, date);
             //task.calcTurbineJfplFxYxfssBll(date, b2);
 
@@ -482,7 +482,7 @@ public class NewTests {
             //task.calcStationCftfsfxQfxdl(date);
             //task.calcTurbineStateMin(date);
             //task.haxdRecalc(date);
-            //task.calcTurbine5s(begin1, end1, 0.1);
+            task.calcTurbine5s(begin1, end1, 0.1);
 
             //task.calcLineRfdl_ha(date);
             //task.haxdRecalc(date);
@@ -501,18 +501,20 @@ public class NewTests {
 
     @Test
     public void test14() {
-        DateTime start = DateUtil.parse("2025-07-22");
-        DateTime end = DateUtil.parse("2025-07-22");
+        DateTime start = DateUtil.parse("2025-01-01");
+        DateTime stop = DateUtil.parse("2025-11-05");
         //String select4 = SqlUtil.getSelectAvg("qfxdl") + SqlUtil.getSelectSum("rfdl,rfdl_fj,kqmd,hjwd");
-        DateRange range = DateUtil.range(start, end, DateField.DAY_OF_YEAR);
-        for (DateTime date : range) {
-            System.out.println(date);
+        DateRange range = DateUtil.range(start, stop, DateField.DAY_OF_YEAR);
+        for (DateTime begin : range) {
+            System.out.println(begin);
             //List<StationInfoDay> sidR = stationInfoDayService.getDatasByPartSelects(date, DatePart.DAY, select4, "station_id");
             //List<StationInfoDay> sidY = stationInfoDayService.getDatasByPartSelects(date, DatePart.MONTH, select4, "station_id");
 
             //task.calcStationZhcydl(date, DateUtil.endOfDay(date));
-            task.calcHaBbHzSs(date, DateUtil.endOfDay(date));
-            task.calcStationZql(date, DateUtil.endOfDay(date));
+            DateTime end = DateUtil.endOfDay(begin);
+            //task.calcHaBbHzSs(begin, end);
+            //task.calcStationZql(begin, end);
+            task.calcProjectMonthInfo(begin, end);
         }
     }
 
@@ -672,4 +674,14 @@ public class NewTests {
         task2.calcStationKqmdLjTs(begin, end);
         System.out.println();
     }
+    @Test
+    public void test68() {
+        Date date = DateUtil.date();
+        //DateTime yesterday = DateUtil.yesterday();
+        DateTime yesterday = DateUtil.parse("2025-10-31");
+        DateTime begin = DateUtil.beginOfDay(yesterday);
+        DateTime end = DateUtil.endOfDay(yesterday);
+        task.calcProjectMonthInfo(begin, end);
+        System.out.println();
+    }
 }

+ 41 - 0
universal-computing-platform/src/main/java/com/ruoyi/ucp/entity/ProjectInfoMonth.java

@@ -0,0 +1,41 @@
+package com.ruoyi.ucp.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * <p>
+ *
+ * </p>
+ *
+ * @author gfhd
+ * @since 2024-03-05
+ */
+@Data
+@TableName("project_info_month")
+public class ProjectInfoMonth implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @TableId(value = "id", type = IdType.AUTO)
+    private Integer id;
+
+    private String stationId;
+
+    private String ProjectId;
+
+    private Date recordDate;
+
+    private Double bll;
+    private Double jxsc;
+    private Double jxss;
+    private Double gzsc;
+    private Double gzss;
+    private Long gzcs;
+    private Double sbklyl;
+}

+ 8 - 0
universal-computing-platform/src/main/java/com/ruoyi/ucp/entity/StationInfoMonth.java

@@ -32,4 +32,12 @@ public class StationInfoMonth implements Serializable {
     private Double mtbf;
 
     private Double mttr;
+
+    private Double bll;
+    private Double jxsc;
+    private Double jxss;
+    private Double gzsc;
+    private Double gzss;
+    private Long gzcs;
+    private Double sbklyl;
 }

+ 16 - 0
universal-computing-platform/src/main/java/com/ruoyi/ucp/mapper/ProjectInfoMonthMapper.java

@@ -0,0 +1,16 @@
+package com.ruoyi.ucp.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.ruoyi.ucp.entity.ProjectInfoMonth;
+
+/**
+ * <p>
+ * Mapper 接口
+ * </p>
+ *
+ * @author gfhd
+ * @since 2024-03-05
+ */
+public interface ProjectInfoMonthMapper extends BaseMapper<ProjectInfoMonth> {
+
+}

+ 23 - 0
universal-computing-platform/src/main/java/com/ruoyi/ucp/service/IProjectInfoMonthService.java

@@ -0,0 +1,23 @@
+package com.ruoyi.ucp.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.ruoyi.ucp.entity.PointInfo;
+import com.ruoyi.ucp.entity.ProjectInfoMonth;
+
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * <p>
+ * 服务类
+ * </p>
+ *
+ * @author gfhd
+ * @since 2024-03-05
+ */
+public interface IProjectInfoMonthService extends IService<ProjectInfoMonth> {
+    List<ProjectInfoMonth> getInfoByDate(Date date);
+    List<ProjectInfoMonth> getInfoByDate(Date date, List<PointInfo> entity);
+    Map<String, ProjectInfoMonth> getInfoByDateMap(Date date, List<PointInfo> entity);
+}

+ 67 - 0
universal-computing-platform/src/main/java/com/ruoyi/ucp/service/impl/ProjectInfoMonthServiceImpl.java

@@ -0,0 +1,67 @@
+package com.ruoyi.ucp.service.impl;
+
+import cn.hutool.core.collection.CollUtil;
+import com.baomidou.mybatisplus.core.conditions.Wrapper;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ruoyi.common.annotation.DataSource;
+import com.ruoyi.common.enums.DataSourceType;
+import com.ruoyi.ucp.entity.PointInfo;
+import com.ruoyi.ucp.entity.ProjectInfoMonth;
+import com.ruoyi.ucp.mapper.ProjectInfoMonthMapper;
+import com.ruoyi.ucp.service.IProjectInfoMonthService;
+import org.springframework.stereotype.Service;
+
+import java.util.Collection;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.function.Function;
+import java.util.stream.Collectors;
+
+/**
+ * <p>
+ * 服务实现类
+ * </p>
+ *
+ * @author gfhd
+ * @since 2024-03-05
+ */
+@Service
+@DataSource(DataSourceType.SLAVE)
+public class ProjectInfoMonthServiceImpl extends ServiceImpl<ProjectInfoMonthMapper, ProjectInfoMonth> implements IProjectInfoMonthService {
+
+    @Override
+    public boolean saveOrUpdateBatch(Collection<ProjectInfoMonth> entityList) {
+        return super.saveOrUpdateBatch(entityList);
+    }
+
+    @Override
+    public List<ProjectInfoMonth> list(Wrapper<ProjectInfoMonth> queryWrapper) {
+        return super.list(queryWrapper);
+    }
+
+    public List<ProjectInfoMonth> getInfoByDate(Date date) {
+        QueryWrapper<ProjectInfoMonth> wrapper = new QueryWrapper<>();
+        wrapper.eq("record_date", date);
+        return super.list(wrapper);
+    }
+
+    public List<ProjectInfoMonth> getInfoByDate(Date date, List<PointInfo> entity) {
+        List<ProjectInfoMonth> list = getInfoByDate(date);
+        if (CollUtil.isEmpty(list)) {
+            entity.forEach(pi -> {
+                ProjectInfoMonth day = new ProjectInfoMonth();
+                day.setStationId(pi.getStationId());
+                day.setRecordDate(date);
+                list.add(day);
+            });
+        }
+        return list;
+    }
+
+    public Map<String, ProjectInfoMonth> getInfoByDateMap(Date date, List<PointInfo> entity) {
+        List<ProjectInfoMonth> list = getInfoByDate(date, entity);
+        return list.stream().collect(Collectors.toMap(ProjectInfoMonth::getStationId, Function.identity()));
+    }
+}

+ 7 - 3
universal-computing-platform/src/main/java/com/ruoyi/ucp/service/impl/TurbineInfoDayServiceImpl.java

@@ -3,6 +3,8 @@ package com.ruoyi.ucp.service.impl;
 import cn.hutool.core.date.DateTime;
 import com.baomidou.mybatisplus.core.conditions.Wrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.LambdaUtils;
+import com.baomidou.mybatisplus.core.toolkit.StringUtils;
 import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.ruoyi.common.annotation.DataSource;
@@ -70,9 +72,11 @@ public class TurbineInfoDayServiceImpl extends ServiceImpl<TurbineInfoDayMapper,
     public Map<String, TurbineInfoDay> getDatasByPartSelect(Date date, DatePart datePart, String selects, SFunction<TurbineInfoDay, String> groupId) {
         DateTime[] beginEnd = SqlUtil.getBeginEnd(date, datePart);
         QueryWrapper<TurbineInfoDay> wrapper = new QueryWrapper<>();
-        wrapper.select(selects);
-        wrapper.lambda().between(TurbineInfoDay::getRecordDate, beginEnd[0], beginEnd[1])
-                .select(groupId).groupBy(groupId);
+        String s = StringUtils.camelToUnderline(LambdaUtils.extract(groupId).getImplMethodName())
+                .replaceFirst("get_","");
+        wrapper.select(selects + s);
+        wrapper.lambda().between(TurbineInfoDay::getRecordDate, beginEnd[0], beginEnd[1]).groupBy(groupId);
+
         List<TurbineInfoDay> days = super.list(wrapper);
         return days.stream().collect(Collectors.toMap(groupId, Function.identity()));
     }