Browse Source

“数据填报日报/年报”

yangjunfeng 1 year ago
parent
commit
4d1c030f30

+ 1 - 1
snws-gps/snws-gps-api/src/main/java/com/tofly/pojo/fill/FillMonth.java

@@ -29,7 +29,7 @@ public class FillMonth extends Model<FillMonth> {
     private Date recordTime;
     @ApiModelProperty(hidden = true)
     @TableField(exist = false)
-    private String recordYear;
+    private String scadaTime;
     @ApiModelProperty(value = "上报期号")
     private String issue;
     @ApiModelProperty(value = "联系电话")

+ 19 - 7
snws-gps/snws-gps-boot/src/main/java/com/tofly/gpsboot/controller/fill/FillController.java

@@ -7,7 +7,6 @@ package com.tofly.gpsboot.controller.fill;
 
 import cn.hutool.core.collection.CollUtil;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.tofly.common.core.entity.ResultRespone;
 import com.tofly.common.oauth.exception.ToflyDeniedException;
@@ -20,7 +19,10 @@ import io.swagger.annotations.ApiImplicitParams;
 import io.swagger.annotations.ApiOperation;
 import lombok.AllArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.web.bind.annotation.*;
+
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
 import java.util.Set;
@@ -349,10 +351,15 @@ public class FillController {
     @ApiImplicitParams({
             @ApiImplicitParam(name = "startDate", value = "开始时间 yyyy-MM-dd HH:mm:ss", dataType = "String"),
             @ApiImplicitParam(name = "endDate", value = "结束时间 yyyy-MM-dd HH:mm:ss", dataType = "String"),
-            @ApiImplicitParam(name = "belongSewageId", value = "所属污水厂ID", dataType = "Long")
+            @ApiImplicitParam(name = "belongSewageId", value = "所属污水厂ID(多个用,分隔)", dataType = "String")
     })
-    public ResultRespone<List<FillVo>> getIndexValDay(String startDate, String endDate, Long belongSewageId) {
-        return ResultRespone.success(fillMonthService.getIndexValDay(startDate, endDate, belongSewageId));
+    public ResultRespone<List<FillVo>> getIndexValDay(String startDate, String endDate, String belongSewageId) {
+        List<Long> sewageIds = new ArrayList<>();
+        if (StringUtils.isNotBlank(belongSewageId)) {
+            sewageIds = Arrays.stream(belongSewageId.split(Constant.CSV)).map(s -> Long.parseLong(s.trim()))
+                    .collect(Collectors.toList());
+        }
+        return ResultRespone.success(fillMonthService.getIndexValDay(startDate, endDate, sewageIds));
     }
 
 //    @GetMapping("/getIndexValMonth")
@@ -370,10 +377,15 @@ public class FillController {
     @ApiImplicitParams({
             @ApiImplicitParam(name = "startYear", value = "开始年 yyyy", dataType = "String"),
             @ApiImplicitParam(name = "endYear", value = "结束年 yyyy", dataType = "String"),
-            @ApiImplicitParam(name = "belongSewageId", value = "所属污水厂ID", dataType = "Long")
+            @ApiImplicitParam(name = "belongSewageId", value = "所属污水厂ID(多个用,分隔)", dataType = "String")
     })
-    public ResultRespone<List<FillMonth>> getIndexValYear(String startYear, String endYear, Long belongSewageId) {
-        return ResultRespone.success(fillMonthService.getIndexValYear(startYear, endYear, belongSewageId));
+    public ResultRespone<List<FillMonth>> getIndexValYear(String startYear, String endYear, String belongSewageId) {
+        List<Long> sewageIds = new ArrayList<>();
+        if (StringUtils.isNotBlank(belongSewageId)) {
+            sewageIds = Arrays.stream(belongSewageId.split(Constant.CSV)).map(s -> Long.parseLong(s.trim()))
+                    .collect(Collectors.toList());
+        }
+        return ResultRespone.success(fillMonthService.getIndexValYear(startYear, endYear, sewageIds));
     }
 
 }

+ 4 - 2
snws-gps/snws-gps-boot/src/main/java/com/tofly/gpsboot/mapper/fill/FillMonthMapper.java

@@ -18,10 +18,12 @@ public interface FillMonthMapper extends BaseMapper<FillMonth> {
 
     Page<FillMonth> getFillMonthPage(Page page, @Param("dto") FillMonth fillMonth);
 
-    List<FillVo> getIndexValDay(@Param("startDate") String startDate, @Param("endDate") String endDate, @Param("belongSewageId") Long belongSewageId);
+    List<FillVo> getStationDeptList(@Param("sewageIds") List<Long> sewageIds);
+
+//    List<FillVo> getIndexValDay(@Param("startDate") String startDate, @Param("endDate") String endDate, @Param("belongSewageId") Long belongSewageId);
 
 //    List<FillVo> getIndexValMonth(@Param("startMonth") String startMonth, @Param("endMonth") String endMonth);
 
-    List<FillMonth> getIndexValYear(@Param("startYear") String startYear, @Param("endYear") String endYear, @Param("belongSewageId") Long belongSewageId);
+    List<FillMonth> getIndexValYear(@Param("startYear") String startYear, @Param("endYear") String endYear, @Param("sewageIds") List<Long> sewageIds);
 
 }

+ 2 - 3
snws-gps/snws-gps-boot/src/main/java/com/tofly/gpsboot/service/fill/FillMonthService.java

@@ -9,7 +9,6 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.tofly.pojo.fill.FillMonth;
 import com.tofly.pojo.fill.FillVo;
-import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
 
@@ -33,10 +32,10 @@ public interface FillMonthService extends IService<FillMonth> {
 
     boolean auditFillMonth(Long id,Long auditUserId,String auditNote,String auditState);
 
-    List<FillVo> getIndexValDay(String startDate, String endDate, Long belongSewageId);
+    List<FillVo> getIndexValDay(String startDate, String endDate, List<Long> sewageIds);
 
 //    List<FillVo> getIndexValMonth(String startMonth, String endMonth);
 
-    List<FillMonth> getIndexValYear(String startYear, String endYear, Long belongSewageId);
+    List<FillMonth> getIndexValYear(String startYear, String endYear, List<Long> sewageIds);
 
 }

+ 141 - 8
snws-gps/snws-gps-boot/src/main/java/com/tofly/gpsboot/service/fill/impl/FillMonthServiceImpl.java

@@ -4,7 +4,9 @@
  */
 package com.tofly.gpsboot.service.fill.impl;
 
-import com.alibaba.fastjson.JSON;
+import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.date.DateUtil;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.tofly.api.UserTaskClient;
@@ -14,21 +16,24 @@ import com.tofly.gpsboot.common.system.AuditTypeEnum;
 import com.tofly.gpsboot.common.system.MessageTopicEnum;
 import com.tofly.gpsboot.common.system.UserTaskStateEnumEnum;
 import com.tofly.gpsboot.mapper.fill.FillMonthMapper;
-import com.tofly.gpsboot.service.fill.FillMonthService;
+import com.tofly.gpsboot.service.fill.*;
 import com.tofly.gpsboot.service.mq.IAuditMessageService;
 import com.tofly.gpsboot.service.mq.IReportMessageService;
 import com.tofly.gpsboot.service.paln.CheckhistoryService;
 import com.tofly.gpsboot.util.DateTimeUtil;
-import com.tofly.pojo.fill.FillMonth;
-import com.tofly.pojo.fill.FillVo;
+import com.tofly.pojo.fill.*;
 import com.tofly.pojo.message.Usertask;
 import com.tofly.pojo.plan.dto.ReportAuditDto;
+import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import java.time.LocalDateTime;
+import java.util.ArrayList;
+import java.util.Calendar;
 import java.util.Date;
 import java.util.List;
+import java.util.stream.Collectors;
 
 
 @Service("fillMonthService")
@@ -45,6 +50,21 @@ public class FillMonthServiceImpl extends ServiceImpl<FillMonthMapper, FillMonth
     @Autowired
     private UserTaskClient userTaskClient;
 
+    @Autowired
+    private FillEcService fillEcService;
+
+    @Autowired
+    private FillSludgeDealService fillSludgeDealService;
+
+    @Autowired
+    private FillSludgeTransferService fillSludgeTransferService;
+
+    @Autowired
+    private FillStcService fillStcService;
+
+    @Autowired
+    private FillWaterService fillWaterService;
+
     @Override
     public Page<FillMonth> getFillMonthPage(Page page, FillMonth fillMonth) {
         return baseMapper.getFillMonthPage(page,fillMonth);
@@ -125,8 +145,67 @@ public class FillMonthServiceImpl extends ServiceImpl<FillMonthMapper, FillMonth
     }
 
     @Override
-    public List<FillVo> getIndexValDay(String startDate, String endDate, Long belongSewageId) {
-        return this.baseMapper.getIndexValDay(startDate, endDate, belongSewageId);
+    public List<FillVo> getIndexValDay(String startDate, String endDate, List<Long> sewageIds) {
+        List<Date> dates = findDates(DateUtil.parse(startDate, "yyyy-MM-dd HH:mm:ss"), DateUtil.parse(endDate, "yyyy-MM-dd HH:mm:ss"), 1);
+        List<FillVo> stationDeptList = this.baseMapper.getStationDeptList(sewageIds);
+        List<FillEc> fillEcs = fillEcService.list(new QueryWrapper<FillEc>().lambda()
+                .le(FillEc::getRecordTime, DateUtil.parse(endDate, "yyyy-MM-dd HH:mm:ss"))
+                .ge(FillEc::getRecordTime, DateUtil.parse(startDate, "yyyy-MM-dd HH:mm:ss")));
+        List<FillSludgeDeal> fillSludgeDeals = fillSludgeDealService.list(new QueryWrapper<FillSludgeDeal>().lambda()
+                .le(FillSludgeDeal::getRecordTime, DateUtil.parse(endDate, "yyyy-MM-dd HH:mm:ss"))
+                .ge(FillSludgeDeal::getRecordTime, DateUtil.parse(startDate, "yyyy-MM-dd HH:mm:ss")));
+//        List<FillSludgeTransfer> fillSludgeTransfers = fillSludgeTransferService.list(new QueryWrapper<FillSludgeTransfer>().lambda()
+//                .le(FillSludgeTransfer::getRecordTime, DateUtil.parse(endDate, "yyyy-MM-dd HH:mm:ss"))
+//                .ge(FillSludgeTransfer::getRecordTime, DateUtil.parse(startDate, "yyyy-MM-dd HH:mm:ss")));
+        List<FillStc> fillStcs = fillStcService.list(new QueryWrapper<FillStc>().lambda()
+                .le(FillStc::getRecordTime, DateUtil.parse(endDate, "yyyy-MM-dd HH:mm:ss"))
+                .ge(FillStc::getRecordTime, DateUtil.parse(startDate, "yyyy-MM-dd HH:mm:ss")));
+        List<FillWater> fillWaters = fillWaterService.list(new QueryWrapper<FillWater>().lambda()
+                .le(FillWater::getRecordTime, DateUtil.parse(endDate, "yyyy-MM-dd HH:mm:ss"))
+                .ge(FillWater::getRecordTime, DateUtil.parse(startDate, "yyyy-MM-dd HH:mm:ss")));
+        List<FillVo> res = new ArrayList<>();
+        dates.forEach(info -> stationDeptList.forEach(fillVo -> {
+            FillVo fillVoRes = new FillVo();
+            BeanUtils.copyProperties(fillVo,fillVoRes);
+            fillVoRes.setRecordTime(DateUtil.format(info, "yyyy-MM-dd HH:mm:ss"));
+            if (CollUtil.isNotEmpty(fillEcs)) {
+                List<FillEc> fillEcsFinal = fillEcs.stream().filter(e -> DateUtil.format(e.getRecordTime(), "yyyy-MM-dd HH:mm:ss").equals(DateUtil.format(info, "yyyy-MM-dd HH:mm:ss"))).collect(Collectors.toList());
+                fillVoRes.setElectro(CollUtil.isNotEmpty(fillEcsFinal) ? fillEcsFinal.get(0).getElectro() : "0");
+            }
+            if (CollUtil.isNotEmpty(fillSludgeDeals)) {
+                List<FillSludgeDeal> fillSludgeDealsFinal = fillSludgeDeals.stream().filter(e -> DateUtil.format(e.getRecordTime(), "yyyy-MM-dd HH:mm:ss").equals(DateUtil.format(info, "yyyy-MM-dd HH:mm:ss"))).collect(Collectors.toList());
+                fillVoRes.setDaySludgeDehydration(CollUtil.isNotEmpty(fillSludgeDealsFinal) ? fillSludgeDealsFinal.get(0).getDaySludgeDehydration() : "0");
+                fillVoRes.setDaySludgeTransfer(CollUtil.isNotEmpty(fillSludgeDealsFinal) ? fillSludgeDealsFinal.get(0).getDaySludgeTransfer() : "0");
+                fillVoRes.setSludgeWaterCutRate(CollUtil.isNotEmpty(fillSludgeDealsFinal) ? fillSludgeDealsFinal.get(0).getSludgeWaterCutRate() : "0");
+            }
+//            if (CollUtil.isNotEmpty(fillSludgeTransfers)) {
+//                List<FillSludgeTransfer> fillSludgeTransfersFinal = fillSludgeTransfers.stream().filter(e -> DateUtil.format(e.getRecordTime(), "yyyy-MM-dd HH:mm:ss").equals(DateUtil.format(info, "yyyy-MM-dd HH:mm:ss"))).collect(Collectors.toList());
+//            }
+            if (CollUtil.isNotEmpty(fillStcs)) {
+                List<FillStc> fillStcsFinal = fillStcs.stream().filter(e -> DateUtil.format(e.getRecordTime(), "yyyy-MM-dd HH:mm:ss").equals(DateUtil.format(info, "yyyy-MM-dd HH:mm:ss"))).collect(Collectors.toList());
+                fillVoRes.setDayIntoWater(CollUtil.isNotEmpty(fillStcsFinal) ? fillStcsFinal.get(0).getDayIntoWater() : "0");
+                fillVoRes.setDayOutWater(CollUtil.isNotEmpty(fillStcsFinal) ? fillStcsFinal.get(0).getDayOutWater() : "0");
+            }
+            if (CollUtil.isNotEmpty(fillWaters)) {
+                List<FillWater> fillWatersFinal = fillWaters.stream().filter(e -> DateUtil.format(e.getRecordTime(), "yyyy-MM-dd HH:mm:ss").equals(DateUtil.format(info, "yyyy-MM-dd HH:mm:ss"))).collect(Collectors.toList());
+                fillVoRes.setBod5(CollUtil.isNotEmpty(fillWatersFinal) ? fillWatersFinal.get(0).getBod5() : "0");
+                fillVoRes.setBod5Out(CollUtil.isNotEmpty(fillWatersFinal) ? fillWatersFinal.get(0).getBod5Out() : "0");
+                fillVoRes.setCodCr(CollUtil.isNotEmpty(fillWatersFinal) ? fillWatersFinal.get(0).getCodCr() : "0");
+                fillVoRes.setCodCrOut(CollUtil.isNotEmpty(fillWatersFinal) ? fillWatersFinal.get(0).getCodCrOut() : "0");
+                fillVoRes.setNh3n(CollUtil.isNotEmpty(fillWatersFinal) ? fillWatersFinal.get(0).getNh3n() : "0");
+                fillVoRes.setNh3nOut(CollUtil.isNotEmpty(fillWatersFinal) ? fillWatersFinal.get(0).getNh3nOut() : "0");
+                fillVoRes.setPh(CollUtil.isNotEmpty(fillWatersFinal) ? fillWatersFinal.get(0).getPh() : "0");
+                fillVoRes.setPhOut(CollUtil.isNotEmpty(fillWatersFinal) ? fillWatersFinal.get(0).getPhOut() : "0");
+                fillVoRes.setSs(CollUtil.isNotEmpty(fillWatersFinal) ? fillWatersFinal.get(0).getSs() : "0");
+                fillVoRes.setSsOut(CollUtil.isNotEmpty(fillWatersFinal) ? fillWatersFinal.get(0).getSsOut() : "0");
+                fillVoRes.setTn(CollUtil.isNotEmpty(fillWatersFinal) ? fillWatersFinal.get(0).getTn() : "0");
+                fillVoRes.setTnOut(CollUtil.isNotEmpty(fillWatersFinal) ? fillWatersFinal.get(0).getTnOut() : "0");
+                fillVoRes.setTp(CollUtil.isNotEmpty(fillWatersFinal) ? fillWatersFinal.get(0).getTp() : "0");
+                fillVoRes.setTpOut(CollUtil.isNotEmpty(fillWatersFinal) ? fillWatersFinal.get(0).getTpOut() : "0");
+            }
+            res.add(fillVoRes);
+        }));
+        return res;
     }
 
 //    @Override
@@ -135,8 +214,62 @@ public class FillMonthServiceImpl extends ServiceImpl<FillMonthMapper, FillMonth
 //    }
 
     @Override
-    public List<FillMonth> getIndexValYear(String startYear, String endYear, Long belongSewageId) {
-        return this.baseMapper.getIndexValYear(startYear, endYear, belongSewageId);
+    public List<FillMonth> getIndexValYear(String startYear, String endYear, List<Long> sewageIds) {
+        return this.baseMapper.getIndexValYear(startYear, endYear, sewageIds);
+    }
+
+    /**
+     * 获取日期列表
+     *
+     * @param start 开始时间:2022-01-01 00:00:00
+     * @param end   结束时间:2022-10-01 14:00:00
+     * @param type  统计类型(0小时,1天,2月)
+     * @return
+     */
+    public static List<Date> findDates(Date start, Date end, Integer type) {
+        Calendar s = Calendar.getInstance();
+        s.setTime(start);
+        Calendar e = Calendar.getInstance();
+        e.setTime(end);
+        if (s.get(Calendar.YEAR) == e.get(Calendar.YEAR)
+                && s.get(Calendar.MONTH) == e.get(Calendar.MONTH)
+                && s.get(Calendar.DAY_OF_MONTH) == e.get(Calendar.DAY_OF_MONTH)
+                && s.get(Calendar.HOUR_OF_DAY) == e.get(Calendar.HOUR_OF_DAY)
+                && type == 0) {
+            List<Date> dates = new ArrayList<>();
+            dates.add(start);
+            return dates;
+        }
+        if (s.get(Calendar.YEAR) == e.get(Calendar.YEAR)
+                && s.get(Calendar.MONTH) == e.get(Calendar.MONTH)
+                && s.get(Calendar.DAY_OF_MONTH) == e.get(Calendar.DAY_OF_MONTH)
+                && type == 1) {
+            List<Date> dates = new ArrayList<>();
+            dates.add(start);
+            return dates;
+        }
+        if (s.get(Calendar.YEAR) == e.get(Calendar.YEAR)
+                && s.get(Calendar.MONTH) == e.get(Calendar.MONTH)
+                && type == 2) {
+            List<Date> dates = new ArrayList<>();
+            dates.add(start);
+            return dates;
+        }
+        //结束时间在开始时间之后
+        List<Date> dates = new ArrayList<>();
+        dates.add(s.getTime());
+        while (end.getTime() >= s.getTime().getTime()) {
+            if (type == 0) {
+                s.add(Calendar.HOUR_OF_DAY, 1);
+            } else if (type == 1) {
+                s.add(Calendar.DAY_OF_MONTH, 1);
+            } else if (type == 2) {
+                s.add(Calendar.MONTH, 1);
+            }
+            dates.add(s.getTime());
+        }
+        dates.remove(dates.size() - 1);
+        return dates;
     }
 
 }

+ 67 - 46
snws-gps/snws-gps-boot/src/main/resources/mapper/fill/FillMonthMapper.xml

@@ -159,8 +159,11 @@
         <if test="dto.report != null and dto.report !=''">
             and report = #{dto.report}
         </if>
-        <if test="dto.belongStationId != null">
-            and BELONG_STATION_ID = #{dto.belongStationId}
+        <if test="dto.belongStationId != null and dto.belongStationId != ''  ">
+            AND to_char('BELONG_STATION_ID') in
+            <foreach item="nodeCodestr" collection="dto.belongStationId.split(',')" open="(" separator="," close=")">
+                #{nodeCodestr}
+            </foreach>
         </if>
         <if test="dto.state != null and dto.state !=''">
             and state = #{dto.state}
@@ -173,49 +176,64 @@
         </if>
     </select>
 
-    <select id="getIndexValDay" resultType="com.tofly.pojo.fill.FillVo">
-        select  CONVERT(VARCHAR(100), e.RECORD_TIME, 20) RECORD_TIME,
-                a.BELONG_STATION_ID BELONG_STATION_ID,
-                (select g.DEPT_ID from tf_dept_sewage g where g.SEWAGE_STATION_ID = a.BELONG_STATION_ID) belong_dept_id,
-                (select h.NAME from tf_smpn_department_x h left join tf_dept_sewage g on h.ID = g.DEPT_ID where g.SEWAGE_STATION_ID = a.BELONG_STATION_ID) belong_dept_name,
-                f.name sewage_station_name,
-                ISNULL(a.ELECTRO, 0) ELECTRO,
-                ISNULL(b.DAY_SLUDGE_DEHYDRATION, 0) DAY_SLUDGE_DEHYDRATION,
-                ISNULL(b.DAY_SLUDGE_TRANSFER, 0) DAY_SLUDGE_TRANSFER,
-                ISNULL(b.SLUDGE_WATER_CUT_RATE, 0) SLUDGE_WATER_CUT_RATE,
-                ISNULL(d.DAY_INTO_WATER, 0) DAY_INTO_WATER,
-                ISNULL(d.DAY_OUT_WATER, 0) DAY_OUT_WATER,
-                ISNULL(e.COD_CR, 0) COD_CR,
-                ISNULL(e.BOD5, 0) BOD5,
-                ISNULL(e.NH3N, 0) NH3N,
-                ISNULL(e.SS, 0) SS,
-                ISNULL(e.TN, 0) TN,
-                ISNULL(e.TP, 0) TP,
-                ISNULL(e.PH, 0) PH,
-                ISNULL(e.COD_CR_OUT, 0) COD_CR_OUT,
-                ISNULL(e.BOD5_OUT, 0) BOD5_OUT,
-                ISNULL(e.NH3N_OUT, 0) NH3N_OUT,
-                ISNULL(e.SS_OUT, 0) SS_OUT,
-                ISNULL(e.TN_OUT, 0) TN_OUT,
-                ISNULL(e.TP_OUT, 0) TP_OUT,
-                ISNULL(e.PH_OUT, 0) PH_OUT
-        from tf_fill_water_w e
-        left join tf_fill_sludge_deal_w b on e.BELONG_STATION_ID = b.BELONG_STATION_ID
-        left join tf_fill_sludge_Transfer_w c on e.BELONG_STATION_ID = c.BELONG_STATION_ID
-        left join tf_fill_stc_w d on e.BELONG_STATION_ID = d.BELONG_STATION_ID
-        left join tf_fill_ec_w a on e.BELONG_STATION_ID = a.BELONG_STATION_ID
-        left join tf_ywpn_monitor_stationsiteinfo_w f on f.ID = e.BELONG_STATION_ID
-        WHERE
-            1=1
-        <if test="startDate != null and endDate != null">
-            AND CONVERT(VARCHAR(100), a.RECORD_TIME, 20) between #{startDate} and #{endDate}
-        </if>
-        <if test="belongSewageId != null">
-            AND f.ID = #{belongSewageId}
+    <select id="getStationDeptList" resultType="com.tofly.pojo.fill.FillVo">
+        select a.id belongStationId,a.name sewageStationName,b.id belongDeptId,b.name belongDeptName
+        from tf_ywpn_monitor_stationsiteinfo_w a
+        left join tf_dept_sewage c on a.ID = c.SEWAGE_STATION_ID
+        left join tf_smpn_department_x b on b.id = c.DEPT_ID
+        where  1=1 and a.del_flag = '0'
+        <if test="sewageIds != null">
+            AND a.id in
+            <foreach item="item" index="index" collection="sewageIds" separator="," open="(" close=")">
+                #{item}
+            </foreach>
         </if>
-        ORDER BY RECORD_TIME
+        order by a.id
     </select>
 
+<!--    <select id="getIndexValDay" resultType="com.tofly.pojo.fill.FillVo">-->
+<!--        select  CONVERT(VARCHAR(100), e.RECORD_TIME, 20) RECORD_TIME,-->
+<!--                e.BELONG_STATION_ID BELONG_STATION_ID,-->
+<!--                (select g.DEPT_ID from tf_dept_sewage g where g.SEWAGE_STATION_ID = e.BELONG_STATION_ID) belong_dept_id,-->
+<!--                (select h.NAME from tf_smpn_department_x h left join tf_dept_sewage g on h.ID = g.DEPT_ID where g.SEWAGE_STATION_ID = e.BELONG_STATION_ID) belong_dept_name,-->
+<!--                f.name sewage_station_name,-->
+<!--                ISNULL(a.ELECTRO, 0) ELECTRO,-->
+<!--                ISNULL(b.DAY_SLUDGE_DEHYDRATION, 0) DAY_SLUDGE_DEHYDRATION,-->
+<!--                ISNULL(b.DAY_SLUDGE_TRANSFER, 0) DAY_SLUDGE_TRANSFER,-->
+<!--                ISNULL(b.SLUDGE_WATER_CUT_RATE, 0) SLUDGE_WATER_CUT_RATE,-->
+<!--                ISNULL(d.DAY_INTO_WATER, 0) DAY_INTO_WATER,-->
+<!--                ISNULL(d.DAY_OUT_WATER, 0) DAY_OUT_WATER,-->
+<!--                ISNULL(e.COD_CR, 0) COD_CR,-->
+<!--                ISNULL(e.BOD5, 0) BOD5,-->
+<!--                ISNULL(e.NH3N, 0) NH3N,-->
+<!--                ISNULL(e.SS, 0) SS,-->
+<!--                ISNULL(e.TN, 0) TN,-->
+<!--                ISNULL(e.TP, 0) TP,-->
+<!--                ISNULL(e.PH, 0) PH,-->
+<!--                ISNULL(e.COD_CR_OUT, 0) COD_CR_OUT,-->
+<!--                ISNULL(e.BOD5_OUT, 0) BOD5_OUT,-->
+<!--                ISNULL(e.NH3N_OUT, 0) NH3N_OUT,-->
+<!--                ISNULL(e.SS_OUT, 0) SS_OUT,-->
+<!--                ISNULL(e.TN_OUT, 0) TN_OUT,-->
+<!--                ISNULL(e.TP_OUT, 0) TP_OUT,-->
+<!--                ISNULL(e.PH_OUT, 0) PH_OUT-->
+<!--        from tf_fill_water_w e-->
+<!--        left join tf_fill_sludge_deal_w b on e.BELONG_STATION_ID = b.BELONG_STATION_ID-->
+<!--        left join tf_fill_sludge_Transfer_w c on e.BELONG_STATION_ID = c.BELONG_STATION_ID-->
+<!--        left join tf_fill_stc_w d on e.BELONG_STATION_ID = d.BELONG_STATION_ID-->
+<!--        left join tf_fill_ec_w a on e.BELONG_STATION_ID = a.BELONG_STATION_ID-->
+<!--        left join tf_ywpn_monitor_stationsiteinfo_w f on f.ID = e.BELONG_STATION_ID-->
+<!--        WHERE-->
+<!--            1=1-->
+<!--        <if test="startDate != null and endDate != null">-->
+<!--            AND CONVERT(VARCHAR(100), a.RECORD_TIME, 20) between #{startDate} and #{endDate}-->
+<!--        </if>-->
+<!--        <if test="belongSewageId != null">-->
+<!--            AND f.ID = #{belongSewageId}-->
+<!--        </if>-->
+<!--        ORDER BY RECORD_TIME-->
+<!--    </select>-->
+
 <!--    <select id="getIndexValMonth" resultType="com.tofly.pojo.fill.FillVo">-->
 <!--        select  datename(yyyy,a.RECORD_TIME) + '-' + datename(m,a.RECORD_TIME) RECORD_TIME,-->
 <!--                a.BELONG_STATION_ID BELONG_STATION_ID,-->
@@ -294,7 +312,7 @@
 <!--        ORDER BY RECORD_TIME-->
 <!--    </select>-->
     <select id="getIndexValYear" resultMap="fillMonthMap">
-        select  datename(yyyy,RECORD_TIME) record_Year,
+        select  datename(yyyy,RECORD_TIME) scada_Time,
                 BELONG_STATION_ID,
                 ISNULL(SUM ( convert(decimal(18, 5), MONTH_DEAL_WQ) ), 0) MONTH_DEAL_WQ,
                 case WHEN(ISNULL(COUNT(*), 0)) != 0 THEN round(SUM( convert(decimal(18, 5), MAX_DAY_DEAL_WQ) ) / COUNT(*),2) ELSE 0 END MAX_DAY_DEAL_WQ,
@@ -338,11 +356,14 @@
         <if test="startYear != null and endYear != null">
             AND datename(yyyy,RECORD_TIME) between #{startYear} and #{endYear}
         </if>
-        <if test="belongSewageId != null">
-            AND BELONG_STATION_ID = #{belongSewageId}
+        <if test="sewageIds != null">
+            AND BELONG_STATION_ID in
+            <foreach item="item" index="index" collection="sewageIds" separator="," open="(" close=")">
+                #{item}
+            </foreach>
         </if>
         GROUP BY datename(yyyy,RECORD_TIME), BELONG_STATION_ID
-        ORDER BY record_Year
+        ORDER BY scada_Time
     </select>
 
 </mapper>

+ 17 - 3
snws-monitor/snws-monitor-boot/src/main/java/com/tofly/monitor/handler/device/ScadaHandler.java

@@ -172,7 +172,7 @@ public class ScadaHandler {
      *
      * @param start 开始时间:2022-01-01 00:00:00
      * @param end   结束时间:2022-10-01 14:00:00
-     * @param type  统计类型0天,1月份,2年份
+     * @param type  统计类型(0小时,1天,2月)
      * @return
      */
     public static List<Date> findDates(Date start, Date end, Integer type) {
@@ -180,12 +180,26 @@ public class ScadaHandler {
         s.setTime(start);
         Calendar e = Calendar.getInstance();
         e.setTime(end);
-        if (start.getYear() == end.getYear() && start.getMonth() == end.getMonth() && start.getDay() == end.getDay() && type != 0) {
+        if (s.get(Calendar.YEAR) == e.get(Calendar.YEAR)
+                && s.get(Calendar.MONTH) == e.get(Calendar.MONTH)
+                && s.get(Calendar.DAY_OF_MONTH) == e.get(Calendar.DAY_OF_MONTH)
+                && s.get(Calendar.HOUR_OF_DAY) == e.get(Calendar.HOUR_OF_DAY)
+                && type == 0) {
             List<Date> dates = new ArrayList<>();
             dates.add(start);
             return dates;
         }
-        if (start.getYear() == end.getYear() && start.getMonth() == end.getMonth() && type == 1) {
+        if (s.get(Calendar.YEAR) == e.get(Calendar.YEAR)
+                && s.get(Calendar.MONTH) == e.get(Calendar.MONTH)
+                && s.get(Calendar.DAY_OF_MONTH) == e.get(Calendar.DAY_OF_MONTH)
+                && type == 1) {
+            List<Date> dates = new ArrayList<>();
+            dates.add(start);
+            return dates;
+        }
+        if (s.get(Calendar.YEAR) == e.get(Calendar.YEAR)
+                && s.get(Calendar.MONTH) == e.get(Calendar.MONTH)
+                && type == 2) {
             List<Date> dates = new ArrayList<>();
             dates.add(start);
             return dates;

+ 32 - 34
snws-monitor/snws-monitor-boot/src/main/java/com/tofly/monitor/screenDisplay/service/impl/CustomDisplayServiceImpl.java

@@ -15,6 +15,7 @@ import com.tofly.monitor.screenDisplay.entity.TfDayStatistics;
 import com.tofly.monitor.screenDisplay.entity.dto.IndexNameTypeDto;
 import com.tofly.monitor.screenDisplay.entity.dto.StartEndTimeDto;
 import com.tofly.monitor.screenDisplay.entity.dto.WisdomDisplayDto;
+import com.tofly.monitor.screenDisplay.entity.vo.IndexValCensusVo;
 import com.tofly.monitor.screenDisplay.entity.vo.StationIndexRealValVo;
 import com.tofly.monitor.screenDisplay.entity.vo.StationIndexRealVo;
 import com.tofly.monitor.screenDisplay.entity.vo.StationIndexTotalVo;
@@ -25,9 +26,7 @@ import com.tofly.monitor.service.*;
 import com.tofly.monitor.service.export.ExportCommonCodeService;
 import com.tofly.monitor.util.DateTimeUtil;
 import com.tofly.pojo.*;
-import com.tofly.monitor.screenDisplay.entity.vo.IndexValCensusVo;
 import com.tofly.pojo.vo.MonitorIndexReportVo;
-import com.tofly.pojo.vo.NewValVo;
 import com.tofly.pojo.vo.StationIndexVo;
 import com.tofly.pojo.vo.StationInfoVo;
 import lombok.AllArgsConstructor;
@@ -39,7 +38,6 @@ import javax.servlet.http.HttpServletResponse;
 import java.lang.reflect.Field;
 import java.math.BigDecimal;
 import java.math.RoundingMode;
-import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.time.LocalDateTime;
 import java.util.*;
@@ -468,15 +466,15 @@ public class CustomDisplayServiceImpl implements CustomDisplayService {
                     info.setEnergyWater(0.0);
                     info.setEnergyWaterThousand(0.0);
                     List<TfDayStatistics> dayStatisticsEcFinal = dayStatisticsEc.stream()
-                            .filter(e -> e.getScadaTime().equals(info.getScadaTime())
+                            .filter(e -> DateUtil.parse(e.getScadaTime(),"yyyy-MM-dd").compareTo(DateUtil.parse(info.getScadaTime(),"yyyy-MM-dd")) == 0
                                     && e.getStationId().equals(info.getStationId()))
                             .collect(Collectors.toList());
                     List<TfDayStatistics> dayStatisticsSludgeFinal = dayStatisticsSludge.stream()
-                            .filter(e -> e.getScadaTime().equals(info.getScadaTime())
+                            .filter(e -> DateUtil.parse(e.getScadaTime(),"yyyy-MM-dd").compareTo(DateUtil.parse(info.getScadaTime(),"yyyy-MM-dd")) == 0
                                     && e.getStationId().equals(info.getStationId()))
                             .collect(Collectors.toList());
                     List<TfDayStatistics> dayStatisticsStcFinal = dayStatisticsStc.stream()
-                            .filter(e -> e.getScadaTime().equals(info.getScadaTime())
+                            .filter(e -> DateUtil.parse(e.getScadaTime(),"yyyy-MM-dd").compareTo(DateUtil.parse(info.getScadaTime(),"yyyy-MM-dd")) == 0
                                     && e.getStationId().equals(info.getStationId()))
                             .collect(Collectors.toList());
                     if (CollUtil.isNotEmpty(dayStatisticsEcFinal)) {
@@ -506,33 +504,7 @@ public class CustomDisplayServiceImpl implements CustomDisplayService {
                     info.setEnergyWater(0.0);
                     info.setEnergyWaterThousand(0.0);
                     List<TfDayStatistics> dayStatisticsFinal = monthStatistics.stream()
-                            .filter(e -> e.getScadaTime().equals(info.getScadaTime())
-                                    && e.getStationId().equals(info.getStationId()))
-                            .collect(Collectors.toList());
-                    if (CollUtil.isNotEmpty(dayStatisticsFinal)) {
-                        info.setSewageWater(dayStatisticsFinal.get(0).getSewageWater());
-                        info.setSludgeHandle(dayStatisticsFinal.get(0).getSludgeHandle());
-                        info.setEnergy(dayStatisticsFinal.get(0).getEnergy());
-                    }
-                    if (info.getSewageWater() != null && info.getEnergy() != null && info.getSewageWater() != 0) {
-                        BigDecimal energy = BigDecimal.valueOf(info.getEnergy());
-                        BigDecimal cumulativeFlow = BigDecimal.valueOf(info.getSewageWater());
-                        info.setEnergyWater(energy.divide(cumulativeFlow,4, RoundingMode.HALF_UP).doubleValue());
-                        info.setEnergyWaterThousand(energy.divide(cumulativeFlow,7, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(1000)).doubleValue());
-                    }
-                });
-                break;
-            case "3":// 季
-                list = customDisplayMapper.getIndexValQuarter(wis);
-                List<TfDayStatistics> quarterStatistics = customDisplayMapper.getFillIndexValQuarter(wis);
-                list.forEach(info -> {
-                    info.setEnergy(0.0);
-                    info.setSludgeHandle(0.0);
-                    info.setSewageWater(0.0);
-                    info.setEnergyWater(0.0);
-                    info.setEnergyWaterThousand(0.0);
-                    List<TfDayStatistics> dayStatisticsFinal = quarterStatistics.stream()
-                            .filter(e -> e.getScadaTime().equals(info.getScadaTime())
+                            .filter(e ->DateUtil.parse(e.getScadaTime(),"yyyy-MM").compareTo(DateUtil.parse(info.getScadaTime(),"yyyy-MM")) == 0
                                     && e.getStationId().equals(info.getStationId()))
                             .collect(Collectors.toList());
                     if (CollUtil.isNotEmpty(dayStatisticsFinal)) {
@@ -548,6 +520,32 @@ public class CustomDisplayServiceImpl implements CustomDisplayService {
                     }
                 });
                 break;
+//            case "3":// 季
+//                list = customDisplayMapper.getIndexValQuarter(wis);
+//                List<TfDayStatistics> quarterStatistics = customDisplayMapper.getFillIndexValQuarter(wis);
+//                list.forEach(info -> {
+//                    info.setEnergy(0.0);
+//                    info.setSludgeHandle(0.0);
+//                    info.setSewageWater(0.0);
+//                    info.setEnergyWater(0.0);
+//                    info.setEnergyWaterThousand(0.0);
+//                    List<TfDayStatistics> dayStatisticsFinal = quarterStatistics.stream()
+//                            .filter(e -> DateUtil.parse(e.getScadaTime(),"yyyy-q").compareTo(DateUtil.parse(info.getScadaTime(),"yyyy-q")) == 0
+//                                    && e.getStationId().equals(info.getStationId()))
+//                            .collect(Collectors.toList());
+//                    if (CollUtil.isNotEmpty(dayStatisticsFinal)) {
+//                        info.setSewageWater(dayStatisticsFinal.get(0).getSewageWater());
+//                        info.setSludgeHandle(dayStatisticsFinal.get(0).getSludgeHandle());
+//                        info.setEnergy(dayStatisticsFinal.get(0).getEnergy());
+//                    }
+//                    if (info.getSewageWater() != null && info.getEnergy() != null && info.getSewageWater() != 0) {
+//                        BigDecimal energy = BigDecimal.valueOf(info.getEnergy());
+//                        BigDecimal cumulativeFlow = BigDecimal.valueOf(info.getSewageWater());
+//                        info.setEnergyWater(energy.divide(cumulativeFlow,4, RoundingMode.HALF_UP).doubleValue());
+//                        info.setEnergyWaterThousand(energy.divide(cumulativeFlow,7, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(1000)).doubleValue());
+//                    }
+//                });
+//                break;
             case "4":// 年
                 list = customDisplayMapper.getIndexValYear(wis);
                 List<TfDayStatistics> yearStatistics = customDisplayMapper.getFillIndexValYear(wis);
@@ -558,7 +556,7 @@ public class CustomDisplayServiceImpl implements CustomDisplayService {
                     info.setEnergyWater(0.0);
                     info.setEnergyWaterThousand(0.0);
                     List<TfDayStatistics> dayStatisticsFinal = yearStatistics.stream()
-                            .filter(e -> e.getScadaTime().equals(info.getScadaTime())
+                            .filter(e -> DateUtil.parse(e.getScadaTime(),"yyyy").compareTo(DateUtil.parse(info.getScadaTime(),"yyyy")) == 0
                                     && e.getStationId().equals(info.getStationId()))
                             .collect(Collectors.toList());
                     if (CollUtil.isNotEmpty(dayStatisticsFinal)) {