浏览代码

累计注气量调整

lipenghui 2 天之前
父节点
当前提交
316f94a38a

+ 24 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/stat/IotStaticController.java

@@ -1085,6 +1085,30 @@ public class IotStaticController {
 
     }
 
+    @PermitAll
+    @GetMapping("/year/total/gases/{dept}")
+    public CommonResult<ImmutableMap> getYearTotalGases(@PathVariable("dept") String dept) {
+        Set<Long> ids = getDeptIds(dept);
+        //获取近一年的月份
+        List<String> lastYearMonthRanges = getLastYearMonthRanges().stream().map(MonthRange::getYearMonth).collect(Collectors.toList());
+        IotRhDailyReportPageReqVO iotRhDailyReportPageReqVO = new IotRhDailyReportPageReqVO();
+//        iotRhDailyReportPageReqVO.setDeptIds(new ArrayList<>(ids));
+        iotRhDailyReportPageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
+        List<YearTotalGas> yearTotalGases = iotRhDailyReportMapper.selectYearTotalGas(iotRhDailyReportPageReqVO);
+        LinkedList<String> result = new LinkedList<>();
+        lastYearMonthRanges.forEach(lastYearMonthRange -> {
+            YearTotalGas yearTotalGas = yearTotalGases.stream().filter(e -> e.getMonth().equals(lastYearMonthRange)).findAny().orElse(null);
+            if (Objects.isNull(yearTotalGas)) {
+                result.add("0");
+            } else {
+                result.add(NumberUtils.formatNumber(yearTotalGas.getTotalGas()));
+            }
+        });
+        ImmutableMap<String, Serializable> fillResult = ImmutableMap.of("name", "累计注气量~~en**cumulative gas injection", "data", result);
+        return success(ImmutableMap.of("xAxis", lastYearMonthRanges, "series", ImmutableList.of(fillResult)));
+
+    }
+
     @GetMapping("/number")
     @Operation(summary = "获取巡检计划数量")
     @PermitAll

+ 4 - 2
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/dal/mysql/iotrhdailyreport/IotRhDailyReportMapper.java

@@ -6,7 +6,9 @@ import cn.hutool.core.util.StrUtil;
 import cn.iocoder.yudao.framework.common.pojo.PageResult;
 import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
 import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
+import cn.iocoder.yudao.module.pms.controller.admin.iotdevicerunlog.vo.IotDeviceRunLogPageReqVO;
 import cn.iocoder.yudao.module.pms.controller.admin.iotrhdailyreport.vo.IotRhDailyReportPageReqVO;
+import cn.iocoder.yudao.module.pms.controller.admin.stat.vo.YearTotalGas;
 import cn.iocoder.yudao.module.pms.dal.dataobject.iotrhdailyreport.IotRhDailyReportDO;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import org.apache.ibatis.annotations.Mapper;
@@ -25,7 +27,7 @@ import java.util.List;
  */
 @Mapper
 public interface IotRhDailyReportMapper extends BaseMapperX<IotRhDailyReportDO> {
-
+    List<YearTotalGas> selectYearTotalGas(IotRhDailyReportPageReqVO reqVO);
     /**
      * 查询 瑞恒日报列表
      * @param page
@@ -145,4 +147,4 @@ public interface IotRhDailyReportMapper extends BaseMapperX<IotRhDailyReportDO>
                 .last("limit 1"));
     }
 
-}
+}

+ 16 - 1
yudao-module-pms/yudao-module-pms-biz/src/main/resources/mapper/static/iotprojecttask/IotRhDailyReportMapper.xml

@@ -72,6 +72,21 @@
         ORDER BY min_start_date ASC
     </select>
 
+    <select id="selectYearTotalGas" parameterType="cn.iocoder.yudao.module.pms.controller.admin.iotrhdailyreport.vo.IotRhDailyReportPageReqVO"
+            resultType="cn.iocoder.yudao.module.pms.controller.admin.stat.vo.YearTotalGas">
+        SELECT
+        DATE_FORMAT(create_time, '%Y-%m') AS month,
+        SUM(IFNULL(daily_gas_injection, 0)) AS total_gas
+        FROM
+            rq_iot_rh_daily_report a
+        WHERE
+        a.create_time >= DATE_SUB(NOW(), INTERVAL 1 YEAR)
+        GROUP BY
+        month
+        ORDER BY
+        month ASC;
+    </select>
+
     <select id="selectListGrouped" resultMap="BaseResultMap"
             parameterType="cn.iocoder.yudao.module.pms.controller.admin.iotrhdailyreport.vo.IotRhDailyReportPageReqVO">
         SELECT t1.*, g.min_start_date
@@ -179,4 +194,4 @@
             CAST( REGEXP_REPLACE ( d.`name`, '[^0-9]+', '' ) AS UNSIGNED ) ASC;
     </select>
 
-</mapper>
+</mapper>