|
|
@@ -3,12 +3,14 @@ package cn.iocoder.yudao.module.pms.service.iotrhdailyreport;
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
import cn.hutool.core.util.ObjUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
+import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
|
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
|
|
import cn.iocoder.yudao.module.pms.controller.admin.iotdevicecategorytemplateattrs.vo.IotDeviceProperty;
|
|
|
import cn.iocoder.yudao.module.pms.controller.admin.iotprojecttask.vo.IotProjectTaskPageReqVO;
|
|
|
import cn.iocoder.yudao.module.pms.controller.admin.iotrhdailyreport.vo.IotRhDailyReportPageReqVO;
|
|
|
import cn.iocoder.yudao.module.pms.controller.admin.iotrhdailyreport.vo.IotRhDailyReportSaveReqVO;
|
|
|
+import cn.iocoder.yudao.module.pms.controller.admin.iotrhdailyreport.vo.IotRhDailyReportStatisticsRespVO;
|
|
|
import cn.iocoder.yudao.module.pms.controller.admin.iotrhdailyreport.vo.IotRhDailyReportStatisticsVO;
|
|
|
import cn.iocoder.yudao.module.pms.controller.admin.vo.IotDevicePageReqVO;
|
|
|
import cn.iocoder.yudao.module.pms.dal.dataobject.IotDeviceDO;
|
|
|
@@ -21,6 +23,7 @@ import cn.iocoder.yudao.module.pms.dal.mysql.iotopeationfill.IotOpeationFillMapp
|
|
|
import cn.iocoder.yudao.module.pms.dal.mysql.iotprojecttask.IotProjectTaskMapper;
|
|
|
import cn.iocoder.yudao.module.pms.dal.mysql.iotrhdailyreport.IotRhDailyReportMapper;
|
|
|
import cn.iocoder.yudao.module.pms.enums.common.FailureAuditStatusEnum;
|
|
|
+import cn.iocoder.yudao.module.system.controller.admin.dept.vo.dept.DeptListReqVO;
|
|
|
import cn.iocoder.yudao.module.system.dal.dataobject.dept.DeptDO;
|
|
|
import cn.iocoder.yudao.module.system.dal.dataobject.dict.DictTypeDO;
|
|
|
import cn.iocoder.yudao.module.system.service.dept.DeptService;
|
|
|
@@ -366,6 +369,92 @@ public class IotRhDailyReportServiceImpl implements IotRhDailyReportService {
|
|
|
return new PageResult<>(page.getRecords(), page.getTotal());
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public List<IotRhDailyReportStatisticsRespVO> statistics(IotRhDailyReportPageReqVO pageReqVO) {
|
|
|
+ List<IotRhDailyReportStatisticsRespVO> result = new ArrayList<>();
|
|
|
+ // 不分页统计所有数据
|
|
|
+ pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
|
|
+ Set<Long> ids = new HashSet<>();
|
|
|
+ if (Objects.nonNull(pageReqVO.getDeptId())) {
|
|
|
+ ids = deptService.getChildDeptIdListFromCache(pageReqVO.getDeptId());
|
|
|
+ // 找到所有子部门对象集合
|
|
|
+
|
|
|
+ ids.add(pageReqVO.getDeptId());
|
|
|
+ pageReqVO.setDeptIds(ids);
|
|
|
+
|
|
|
+ }
|
|
|
+ // 检查contractName不为空但projectIds为空的情况
|
|
|
+ if (StrUtil.isNotBlank(pageReqVO.getContractName()) && (CollUtil.isEmpty(pageReqVO.getProjectIds()))) {
|
|
|
+ return new ArrayList<>();
|
|
|
+ }
|
|
|
+ // 检查taskName不为空但taskIds为空的情况
|
|
|
+ if (StrUtil.isNotBlank(pageReqVO.getTaskName()) && (CollUtil.isEmpty(pageReqVO.getTaskIds()))) {
|
|
|
+ return new ArrayList<>();
|
|
|
+ }
|
|
|
+ IPage<IotRhDailyReportDO> page = iotRhDailyReportMapper.rhReportStatistics(
|
|
|
+ new Page<>(pageReqVO.getPageNo(), pageReqVO.getPageSize()), pageReqVO,
|
|
|
+ pageReqVO.getTaskIds(), pageReqVO.getProjectIds(), ids);
|
|
|
+ List<IotRhDailyReportDO> dailyReports = page.getRecords();
|
|
|
+
|
|
|
+ Map<Long, BigDecimal> cumulativeGasInjectionPair = new HashMap<>();
|
|
|
+ Map<Long, BigDecimal> cumulativeWaterInjectionPair = new HashMap<>();
|
|
|
+ Map<Long, BigDecimal> cumulativePowerConsumptionPair = new HashMap<>();
|
|
|
+ // key项目部id value累计油耗
|
|
|
+ Map<Long, BigDecimal> cumulativeFuelConsumptionPair = new HashMap<>();
|
|
|
+ // 默认显示所有项目部的汇总数据(新疆分公司也展示 下属各项目部的数据)
|
|
|
+ // 点击项目部 显示 下属队伍的数据
|
|
|
+ // 首先判断点击的部门是属于 公司 还是 队伍 如果没有点击任何部门 默认查询所有项目部数据
|
|
|
+ if (ObjUtil.isEmpty(pageReqVO.getDeptId())) {
|
|
|
+ Set<Long> projectDeptIds = new HashSet<>();
|
|
|
+ // key项目部id value项目部名称
|
|
|
+ Map<Long, String> projectDeptPair = new HashMap<>();
|
|
|
+ // key部门id value部门parentId
|
|
|
+ Map<Long, Long> teamProjectIdPair = new HashMap<>();
|
|
|
+
|
|
|
+ // 以项目部为维度统计数据 所有项目部
|
|
|
+ // 找到所有项目部 与 队伍 的对应关系
|
|
|
+ // 查询所有瑞恒的项目部
|
|
|
+ Set<Long> allRhChildDeptIds = deptService.getChildDeptIdListFromCache(157l);
|
|
|
+ DeptListReqVO reqVO = new DeptListReqVO();
|
|
|
+ reqVO.setDeptIds(allRhChildDeptIds);
|
|
|
+ List<DeptDO> depts = deptService.getDeptList(reqVO);
|
|
|
+ depts.forEach(dept -> {
|
|
|
+ if ("2".equals(dept.getType())) {
|
|
|
+ projectDeptIds.add(dept.getId());
|
|
|
+ projectDeptPair.put(dept.getId(), dept.getName());
|
|
|
+ }
|
|
|
+ teamProjectIdPair.put(dept.getId(), dept.getParentId());
|
|
|
+ });
|
|
|
+ if (CollUtil.isNotEmpty(dailyReports)) {
|
|
|
+ dailyReports.forEach(report -> {
|
|
|
+ if (ObjUtil.isNotEmpty(report.getDeptId()) && teamProjectIdPair.containsKey(report.getDeptId())) {
|
|
|
+ Long projectDeptId = teamProjectIdPair.get(report.getDeptId());
|
|
|
+
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ // 判断点击的组织树中的部门类型 类型(公司级1 项目部2 队伍3)
|
|
|
+ DeptDO selectedDept = deptService.getDept(pageReqVO.getDeptId());
|
|
|
+ if ("1".equals(selectedDept.getType())) {
|
|
|
+ // 以项目部为维度汇总数据
|
|
|
+
|
|
|
+ } else if ("2".equals(selectedDept.getType())) {
|
|
|
+ // 以队伍为维度汇总数据
|
|
|
+
|
|
|
+ } else if ("3".equals(selectedDept.getType())) {
|
|
|
+ // 显示单个队伍的汇总数据
|
|
|
+
|
|
|
+ } else {
|
|
|
+ // 点击的部门没有类型 判断部门下的是否包含 项目部类型部门 新疆分公司
|
|
|
+ // 以项目部为维度汇总数据
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public List<IotRhDailyReportStatisticsVO> rhDailyReportStatistics(IotRhDailyReportPageReqVO reqVO) {
|
|
|
if (reqVO.getCreateTime().length == 0) {
|