|
@@ -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<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(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;
|
|
|
}
|
|
|
|
|
|
|
|
@@ -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;
|
|
|
}
|
|
|
|
|
|
}
|