|
@@ -5,13 +5,11 @@ import cn.hutool.core.util.ObjUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
|
|
|
|
+import cn.iocoder.yudao.module.pms.constant.PmsConstants;
|
|
|
import cn.iocoder.yudao.module.pms.controller.admin.iotattachment.vo.IotAttachmentSaveReqVO;
|
|
import cn.iocoder.yudao.module.pms.controller.admin.iotattachment.vo.IotAttachmentSaveReqVO;
|
|
|
import cn.iocoder.yudao.module.pms.controller.admin.iotprojectinfo.vo.IotProjectInfoPageReqVO;
|
|
import cn.iocoder.yudao.module.pms.controller.admin.iotprojectinfo.vo.IotProjectInfoPageReqVO;
|
|
|
import cn.iocoder.yudao.module.pms.controller.admin.iotprojecttask.vo.IotProjectTaskPageReqVO;
|
|
import cn.iocoder.yudao.module.pms.controller.admin.iotprojecttask.vo.IotProjectTaskPageReqVO;
|
|
|
-import cn.iocoder.yudao.module.pms.controller.admin.iotrddailyreport.vo.IotRdDailyReportPageReqVO;
|
|
|
|
|
-import cn.iocoder.yudao.module.pms.controller.admin.iotrddailyreport.vo.IotRdDailyReportSaveReqVO;
|
|
|
|
|
-import cn.iocoder.yudao.module.pms.controller.admin.iotrddailyreport.vo.IotRdDailyReportStatisticsItemVO;
|
|
|
|
|
-import cn.iocoder.yudao.module.pms.controller.admin.iotrddailyreport.vo.IotRdDailyReportStatisticsRespVO;
|
|
|
|
|
|
|
+import cn.iocoder.yudao.module.pms.controller.admin.iotrddailyreport.vo.*;
|
|
|
import cn.iocoder.yudao.module.pms.dal.dataobject.iotattachment.IotAttachmentDO;
|
|
import cn.iocoder.yudao.module.pms.dal.dataobject.iotattachment.IotAttachmentDO;
|
|
|
import cn.iocoder.yudao.module.pms.dal.dataobject.iotprojectinfo.IotProjectInfoDO;
|
|
import cn.iocoder.yudao.module.pms.dal.dataobject.iotprojectinfo.IotProjectInfoDO;
|
|
|
import cn.iocoder.yudao.module.pms.dal.dataobject.iotprojecttask.IotProjectTaskDO;
|
|
import cn.iocoder.yudao.module.pms.dal.dataobject.iotprojecttask.IotProjectTaskDO;
|
|
@@ -23,24 +21,40 @@ import cn.iocoder.yudao.module.pms.dal.mysql.iotprojecttask.IotProjectTaskMapper
|
|
|
import cn.iocoder.yudao.module.pms.dal.mysql.iotrddailyreport.IotRdDailyReportMapper;
|
|
import cn.iocoder.yudao.module.pms.dal.mysql.iotrddailyreport.IotRdDailyReportMapper;
|
|
|
import cn.iocoder.yudao.module.pms.enums.AttachmentCategoryEnum;
|
|
import cn.iocoder.yudao.module.pms.enums.AttachmentCategoryEnum;
|
|
|
import cn.iocoder.yudao.module.pms.enums.AttachmentTypeEnum;
|
|
import cn.iocoder.yudao.module.pms.enums.AttachmentTypeEnum;
|
|
|
|
|
+import cn.iocoder.yudao.module.pms.message.PmsMessage;
|
|
|
import cn.iocoder.yudao.module.supplier.enums.common.SupplierAuditStatusEnum;
|
|
import cn.iocoder.yudao.module.supplier.enums.common.SupplierAuditStatusEnum;
|
|
|
|
|
+import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
|
|
|
|
+import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
|
|
|
import cn.iocoder.yudao.module.system.dal.dataobject.dept.DeptDO;
|
|
import cn.iocoder.yudao.module.system.dal.dataobject.dept.DeptDO;
|
|
|
import cn.iocoder.yudao.module.system.dal.dataobject.dict.DictDataDO;
|
|
import cn.iocoder.yudao.module.system.dal.dataobject.dict.DictDataDO;
|
|
|
|
|
+import cn.iocoder.yudao.module.system.dal.dataobject.permission.RoleDO;
|
|
|
|
|
+import cn.iocoder.yudao.module.system.dal.dataobject.permission.UserRoleDO;
|
|
|
|
|
+import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO;
|
|
|
|
|
+import cn.iocoder.yudao.module.system.dal.mysql.permission.UserRoleMapper;
|
|
|
import cn.iocoder.yudao.module.system.service.dept.DeptService;
|
|
import cn.iocoder.yudao.module.system.service.dept.DeptService;
|
|
|
import cn.iocoder.yudao.module.system.service.dict.DictDataService;
|
|
import cn.iocoder.yudao.module.system.service.dict.DictDataService;
|
|
|
|
|
+import cn.iocoder.yudao.module.system.service.permission.RoleService;
|
|
|
|
|
+import cn.iocoder.yudao.module.system.service.user.AdminUserService;
|
|
|
import com.google.common.collect.ImmutableMap;
|
|
import com.google.common.collect.ImmutableMap;
|
|
|
|
|
+import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
|
|
|
+import java.time.LocalDate;
|
|
|
|
|
+import java.time.LocalDateTime;
|
|
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
|
|
|
+import java.time.temporal.ChronoUnit;
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
|
|
+import java.util.concurrent.CountDownLatch;
|
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
|
|
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
|
|
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
|
|
|
import static cn.iocoder.yudao.module.pms.enums.ErrorCodeConstant.IOT_PROJECT_TASK_NOT_EXISTS;
|
|
import static cn.iocoder.yudao.module.pms.enums.ErrorCodeConstant.IOT_PROJECT_TASK_NOT_EXISTS;
|
|
|
import static cn.iocoder.yudao.module.pms.enums.ErrorCodeConstant.IOT_RD_DAILY_REPORT_NOT_EXISTS;
|
|
import static cn.iocoder.yudao.module.pms.enums.ErrorCodeConstant.IOT_RD_DAILY_REPORT_NOT_EXISTS;
|
|
|
|
|
+import static cn.iocoder.yudao.module.pms.framework.config.MultiThreadConfiguration.PMS_THREAD_POOL_TASK_EXECUTOR;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 瑞都日报 Service 实现类
|
|
* 瑞都日报 Service 实现类
|
|
@@ -63,6 +77,18 @@ public class IotRdDailyReportServiceImpl implements IotRdDailyReportService {
|
|
|
private DictDataService dictDataService;
|
|
private DictDataService dictDataService;
|
|
|
@Resource
|
|
@Resource
|
|
|
private DeptService deptService;
|
|
private DeptService deptService;
|
|
|
|
|
+ @Resource
|
|
|
|
|
+ private AdminUserService adminUserService;
|
|
|
|
|
+ @Resource
|
|
|
|
|
+ private RoleService roleService;
|
|
|
|
|
+ @Resource
|
|
|
|
|
+ private UserRoleMapper userRoleMapper;
|
|
|
|
|
+ @Resource
|
|
|
|
|
+ private AdminUserApi adminUserApi;
|
|
|
|
|
+ @Resource(name = PMS_THREAD_POOL_TASK_EXECUTOR)
|
|
|
|
|
+ private ThreadPoolTaskExecutor pmsThreadPoolTaskExecutor;
|
|
|
|
|
+ @Resource
|
|
|
|
|
+ private PmsMessage pmsMessage;
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public Long createIotRdDailyReport(IotRdDailyReportSaveReqVO createReqVO) {
|
|
public Long createIotRdDailyReport(IotRdDailyReportSaveReqVO createReqVO) {
|
|
@@ -74,9 +100,17 @@ public class IotRdDailyReportServiceImpl implements IotRdDailyReportService {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
- public void updateIotRdDailyReport(IotRdDailyReportSaveReqVO updateReqVO) {
|
|
|
|
|
|
|
+ public IotRdDailyReportDO updateIotRdDailyReport(IotRdDailyReportSaveReqVO updateReqVO) {
|
|
|
// 校验存在
|
|
// 校验存在
|
|
|
- validateIotRdDailyReportExists(updateReqVO.getId());
|
|
|
|
|
|
|
+ IotRdDailyReportDO dailyReport = validateIotRdDailyReportExists(updateReqVO.getId());
|
|
|
|
|
+ // 如果 endTime = 24:00 转换成 23:59:59 否则会引发异常 Parse [2025-11-22 24:00] with format [yyyy-MM-dd HH:mm] error!
|
|
|
|
|
+ String endTime = updateReqVO.getEndTime();
|
|
|
|
|
+ if (StrUtil.isNotBlank(endTime)) {
|
|
|
|
|
+ String[] timeAttr = endTime.split(":");
|
|
|
|
|
+ if ("24".equals(timeAttr[0])) {
|
|
|
|
|
+ updateReqVO.setEndTime("23:59:59");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
// 更新
|
|
// 更新
|
|
|
IotRdDailyReportDO updateObj = BeanUtils.toBean(updateReqVO, IotRdDailyReportDO.class);
|
|
IotRdDailyReportDO updateObj = BeanUtils.toBean(updateReqVO, IotRdDailyReportDO.class);
|
|
|
// 设置 日报填写状态 保存 已完成
|
|
// 设置 日报填写状态 保存 已完成
|
|
@@ -118,6 +152,10 @@ public class IotRdDailyReportServiceImpl implements IotRdDailyReportService {
|
|
|
"type", AttachmentTypeEnum.EXTERNAL_RENTAL.getCode()
|
|
"type", AttachmentTypeEnum.EXTERNAL_RENTAL.getCode()
|
|
|
));
|
|
));
|
|
|
}
|
|
}
|
|
|
|
|
+ updateObj.setReportName(dailyReport.getReportName());
|
|
|
|
|
+ updateObj.setPlatformWell(dailyReport.getPlatformWell());
|
|
|
|
|
+ updateObj.setPlatformGroup(dailyReport.getPlatformGroup());
|
|
|
|
|
+ return updateObj;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -141,9 +179,13 @@ public class IotRdDailyReportServiceImpl implements IotRdDailyReportService {
|
|
|
if (ObjUtil.isNotEmpty(taskId)) {
|
|
if (ObjUtil.isNotEmpty(taskId)) {
|
|
|
// 查找关联的任务 更新任务的 施工状态
|
|
// 查找关联的任务 更新任务的 施工状态
|
|
|
IotProjectTaskDO task = iotProjectTaskMapper.selectById(taskId);
|
|
IotProjectTaskDO task = iotProjectTaskMapper.selectById(taskId);
|
|
|
- task.setStatus(updateReqVO.getRdStatus());
|
|
|
|
|
- task.setRdStatus(updateReqVO.getRdStatus());
|
|
|
|
|
- iotProjectTaskMapper.updateById(task);
|
|
|
|
|
|
|
+ if (!"wg".equals(task.getStatus()) && StrUtil.isNotBlank(task.getRdStatus())) {
|
|
|
|
|
+ // 兼容平台井关联的任务已经完工,没有填报数据,但是关联井没有完工的情况
|
|
|
|
|
+ // 此时没有填写日报数据主井任务不必更新状态
|
|
|
|
|
+ task.setStatus(updateReqVO.getRdStatus());
|
|
|
|
|
+ task.setRdStatus(updateReqVO.getRdStatus());
|
|
|
|
|
+ iotProjectTaskMapper.updateById(task);
|
|
|
|
|
+ }
|
|
|
// 如果是平台井 且 关联井也设置了 施工状态 也要同步更新关联井任务的施工状态
|
|
// 如果是平台井 且 关联井也设置了 施工状态 也要同步更新关联井任务的施工状态
|
|
|
if (1 == platformWell) {
|
|
if (1 == platformWell) {
|
|
|
// key平台井关联井的任务taskId value平台井关联井的任务施工状态数据字典value
|
|
// key平台井关联井的任务taskId value平台井关联井的任务施工状态数据字典value
|
|
@@ -296,12 +338,17 @@ public class IotRdDailyReportServiceImpl implements IotRdDailyReportService {
|
|
|
Map<Long, String> projectPair = new HashMap<>();
|
|
Map<Long, String> projectPair = new HashMap<>();
|
|
|
// key任务id value任务井号
|
|
// key任务id value任务井号
|
|
|
Map<Long, String> taskPair = new HashMap<>();
|
|
Map<Long, String> taskPair = new HashMap<>();
|
|
|
|
|
+ // key任务id value任务施工状态
|
|
|
|
|
+ Map<Long, String> taskStatusPair = new HashMap<>();
|
|
|
// 施工工艺 key字典键值 value字典标签
|
|
// 施工工艺 key字典键值 value字典标签
|
|
|
Map<String, String> techniqueDictPair = new HashMap<>();
|
|
Map<String, String> techniqueDictPair = new HashMap<>();
|
|
|
// key任务id value任务工作量
|
|
// key任务id value任务工作量
|
|
|
Map<Long, BigDecimal> taskWorkloadPair = new HashMap<>();
|
|
Map<Long, BigDecimal> taskWorkloadPair = new HashMap<>();
|
|
|
// key任务id value任务工艺名称
|
|
// key任务id value任务工艺名称
|
|
|
Map<Long, String> taskTechniquePair = new HashMap<>();
|
|
Map<Long, String> taskTechniquePair = new HashMap<>();
|
|
|
|
|
+ // key任务id value任务的施工周期天数
|
|
|
|
|
+ Map<Long, String> taskPeriodPair = new HashMap<>();
|
|
|
|
|
+
|
|
|
if (CollUtil.isNotEmpty(dailyReports)) {
|
|
if (CollUtil.isNotEmpty(dailyReports)) {
|
|
|
// 遍历日报 找到每个日报关联的任务的 施工队伍
|
|
// 遍历日报 找到每个日报关联的任务的 施工队伍
|
|
|
List<Long> taskIds = convertList(dailyReports, IotRdDailyReportDO::getTaskId);
|
|
List<Long> taskIds = convertList(dailyReports, IotRdDailyReportDO::getTaskId);
|
|
@@ -309,6 +356,8 @@ public class IotRdDailyReportServiceImpl implements IotRdDailyReportService {
|
|
|
// 查询所有任务关联的队伍信息 如果任务选择了多个队伍 队伍名称逗号分隔
|
|
// 查询所有任务关联的队伍信息 如果任务选择了多个队伍 队伍名称逗号分隔
|
|
|
// key任务id value任务选择的施工队伍名称集合
|
|
// key任务id value任务选择的施工队伍名称集合
|
|
|
Map<Long, String> taskDeptNamePair = new HashMap<>();
|
|
Map<Long, String> taskDeptNamePair = new HashMap<>();
|
|
|
|
|
+ // key任务id value任务创建时间集合
|
|
|
|
|
+ Map<Long, LocalDateTime> taskCreateTimePair = new HashMap<>();
|
|
|
// key任务id value任务选择的施工队伍对应的项目部名称集合
|
|
// key任务id value任务选择的施工队伍对应的项目部名称集合
|
|
|
Map<Long, String> taskProjectDeptPair = new HashMap<>();
|
|
Map<Long, String> taskProjectDeptPair = new HashMap<>();
|
|
|
IotProjectTaskPageReqVO relatedTaskReqVO = new IotProjectTaskPageReqVO();
|
|
IotProjectTaskPageReqVO relatedTaskReqVO = new IotProjectTaskPageReqVO();
|
|
@@ -363,6 +412,8 @@ public class IotRdDailyReportServiceImpl implements IotRdDailyReportService {
|
|
|
if (CollUtil.isNotEmpty(tasks)) {
|
|
if (CollUtil.isNotEmpty(tasks)) {
|
|
|
tasks.forEach(task -> {
|
|
tasks.forEach(task -> {
|
|
|
taskPair.put(task.getId(), task.getWellName());
|
|
taskPair.put(task.getId(), task.getWellName());
|
|
|
|
|
+ taskStatusPair.put(task.getId(), task.getStatus());
|
|
|
|
|
+ taskCreateTimePair.put(task.getId(), task.getCreateTime());
|
|
|
// 获取所有任务的工作量数据
|
|
// 获取所有任务的工作量数据
|
|
|
taskWorkloadPair.put(task.getId(), new BigDecimal(task.getWorkloadDesign()));
|
|
taskWorkloadPair.put(task.getId(), new BigDecimal(task.getWorkloadDesign()));
|
|
|
if (techniqueDictPair.containsKey(task.getTechnique())) {
|
|
if (techniqueDictPair.containsKey(task.getTechnique())) {
|
|
@@ -371,6 +422,46 @@ public class IotRdDailyReportServiceImpl implements IotRdDailyReportService {
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ // 查询所有日报关联任务的施工周期
|
|
|
|
|
+ List<IotRdDailyReportTaskPeriodVO> taskPeriods = iotRdDailyReportMapper.taskConstructionPeriod();
|
|
|
|
|
+ if (CollUtil.isNotEmpty(taskPeriods)) {
|
|
|
|
|
+ // 定义日期格式化器,匹配"yyyy-MM-dd HH:mm:ss"格式
|
|
|
|
|
+ DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
+ taskPeriods.forEach(period -> {
|
|
|
|
|
+ // 如果 startDate endDate 都存在 计算施工周期天数 考虑到日报审批后才会更新任务状态
|
|
|
|
|
+ // 所以计算任务施工周期时 要筛选出施工完成的任务
|
|
|
|
|
+ String taskStatus = StrUtil.EMPTY;
|
|
|
|
|
+ if (taskStatusPair.containsKey(period.getTaskId())) {
|
|
|
|
|
+ taskStatus = taskStatusPair.get(period.getTaskId());
|
|
|
|
|
+ }
|
|
|
|
|
+ if (StrUtil.isNotBlank(period.getStartDate()) && StrUtil.isNotBlank(period.getEndDate()) && "wg".equals(taskStatus)) {
|
|
|
|
|
+ // 计算 startDate endDate 之间的差值
|
|
|
|
|
+ try {
|
|
|
|
|
+ // 1. 解析日期字符串为LocalDateTime
|
|
|
|
|
+ LocalDateTime startLdt = LocalDateTime.parse(period.getStartDate(), dtf);
|
|
|
|
|
+ LocalDateTime endLdt = LocalDateTime.parse(period.getEndDate(), dtf);
|
|
|
|
|
+
|
|
|
|
|
+ // 2. 截断时分秒,仅保留日期部分
|
|
|
|
|
+ LocalDate startDate = startLdt.toLocalDate();
|
|
|
|
|
+ LocalDate endDate = endLdt.toLocalDate();
|
|
|
|
|
+
|
|
|
|
|
+ // 3. 计算日期差值(天),+1满足「同一天算1天」的规则
|
|
|
|
|
+ long daysDiff = ChronoUnit.DAYS.between(startDate, endDate);
|
|
|
|
|
+ long constructionDays = daysDiff + 1;
|
|
|
|
|
+
|
|
|
|
|
+ // 4. 存入任务-施工周期映射(key=任务ID,value=天数字符串)
|
|
|
|
|
+ taskPeriodPair.put(period.getTaskId(), String.valueOf(constructionDays));
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ // 解析失败时默认周期为1天(可根据业务调整,也可记录日志)
|
|
|
|
|
+ taskPeriodPair.put(period.getTaskId(), "1");
|
|
|
|
|
+ // 可选:添加日志打印
|
|
|
|
|
+ // log.error("解析任务施工周期日期失败,taskId={}, startDate={}, endDate={}", period.getTaskId(), period.getStartDate(), period.getEndDate(), e);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
// 设置 小队 任务已经完成的工作量集合 (按照不同的单位统计任务的不同工作量)
|
|
// 设置 小队 任务已经完成的工作量集合 (按照不同的单位统计任务的不同工作量)
|
|
|
// key任务井id value队伍工作量数据
|
|
// key任务井id value队伍工作量数据
|
|
|
Map<Long, BigDecimal> bridgePlugPair = new HashMap<>();
|
|
Map<Long, BigDecimal> bridgePlugPair = new HashMap<>();
|
|
@@ -385,6 +476,7 @@ public class IotRdDailyReportServiceImpl implements IotRdDailyReportService {
|
|
|
dailyReports.forEach(report -> {
|
|
dailyReports.forEach(report -> {
|
|
|
// 设置每个任务的工作量数据 单位相同的工作量值作合并处理
|
|
// 设置每个任务的工作量数据 单位相同的工作量值作合并处理
|
|
|
List<IotTaskAttrModelProperty> taskAttrs = report.getExtProperty();
|
|
List<IotTaskAttrModelProperty> taskAttrs = report.getExtProperty();
|
|
|
|
|
+ Long taskId = report.getTaskId();
|
|
|
// 暂存不同单位的工作量属性值
|
|
// 暂存不同单位的工作量属性值
|
|
|
BigDecimal tempTotalBridgePlug = BigDecimal.ZERO; // 桥塞(个数)
|
|
BigDecimal tempTotalBridgePlug = BigDecimal.ZERO; // 桥塞(个数)
|
|
|
BigDecimal tempTotalRunCount = BigDecimal.ZERO; // 趟数
|
|
BigDecimal tempTotalRunCount = BigDecimal.ZERO; // 趟数
|
|
@@ -411,8 +503,8 @@ public class IotRdDailyReportServiceImpl implements IotRdDailyReportService {
|
|
|
if ("个数".equals(unit)) {
|
|
if ("个数".equals(unit)) {
|
|
|
// 钻可溶桥塞 钻复合桥塞
|
|
// 钻可溶桥塞 钻复合桥塞
|
|
|
tempTotalBridgePlug = tempTotalBridgePlug.add(actualValue);
|
|
tempTotalBridgePlug = tempTotalBridgePlug.add(actualValue);
|
|
|
- if (bridgePlugPair.containsKey(report.getDeptId())) {
|
|
|
|
|
- BigDecimal tempBridgePlug = bridgePlugPair.get(report.getDeptId());
|
|
|
|
|
|
|
+ if (bridgePlugPair.containsKey(report.getTaskId())) {
|
|
|
|
|
+ BigDecimal tempBridgePlug = bridgePlugPair.get(report.getTaskId());
|
|
|
bridgePlugPair.put(report.getTaskId(), tempTotalBridgePlug.add(tempBridgePlug));
|
|
bridgePlugPair.put(report.getTaskId(), tempTotalBridgePlug.add(tempBridgePlug));
|
|
|
} else {
|
|
} else {
|
|
|
bridgePlugPair.put(report.getTaskId(), tempTotalBridgePlug);
|
|
bridgePlugPair.put(report.getTaskId(), tempTotalBridgePlug);
|
|
@@ -420,8 +512,8 @@ public class IotRdDailyReportServiceImpl implements IotRdDailyReportService {
|
|
|
}
|
|
}
|
|
|
if ("趟数".equals(unit)) {
|
|
if ("趟数".equals(unit)) {
|
|
|
tempTotalRunCount = tempTotalRunCount.add(actualValue);
|
|
tempTotalRunCount = tempTotalRunCount.add(actualValue);
|
|
|
- if (runCountPair.containsKey(report.getDeptId())) {
|
|
|
|
|
- BigDecimal tempRunCount = runCountPair.get(report.getDeptId());
|
|
|
|
|
|
|
+ if (runCountPair.containsKey(report.getTaskId())) {
|
|
|
|
|
+ BigDecimal tempRunCount = runCountPair.get(report.getTaskId());
|
|
|
runCountPair.put(report.getTaskId(), tempTotalRunCount.add(tempRunCount));
|
|
runCountPair.put(report.getTaskId(), tempTotalRunCount.add(tempRunCount));
|
|
|
} else {
|
|
} else {
|
|
|
runCountPair.put(report.getTaskId(), tempTotalRunCount);
|
|
runCountPair.put(report.getTaskId(), tempTotalRunCount);
|
|
@@ -429,8 +521,8 @@ public class IotRdDailyReportServiceImpl implements IotRdDailyReportService {
|
|
|
}
|
|
}
|
|
|
if ("小时".equals(unit)) {
|
|
if ("小时".equals(unit)) {
|
|
|
tempTotalHourCount = tempTotalHourCount.add(actualValue);
|
|
tempTotalHourCount = tempTotalHourCount.add(actualValue);
|
|
|
- if (hourCountPair.containsKey(report.getDeptId())) {
|
|
|
|
|
- BigDecimal tempHourCount = hourCountPair.get(report.getDeptId());
|
|
|
|
|
|
|
+ if (hourCountPair.containsKey(report.getTaskId())) {
|
|
|
|
|
+ BigDecimal tempHourCount = hourCountPair.get(report.getTaskId());
|
|
|
hourCountPair.put(report.getTaskId(), tempTotalHourCount.add(tempHourCount));
|
|
hourCountPair.put(report.getTaskId(), tempTotalHourCount.add(tempHourCount));
|
|
|
} else {
|
|
} else {
|
|
|
hourCountPair.put(report.getTaskId(), tempTotalHourCount);
|
|
hourCountPair.put(report.getTaskId(), tempTotalHourCount);
|
|
@@ -440,8 +532,8 @@ public class IotRdDailyReportServiceImpl implements IotRdDailyReportService {
|
|
|
// 将 actualValue 换算成 H
|
|
// 将 actualValue 换算成 H
|
|
|
BigDecimal hours = actualValue.multiply(new BigDecimal("24"));
|
|
BigDecimal hours = actualValue.multiply(new BigDecimal("24"));
|
|
|
tempTotalHourCount = tempTotalHourCount.add(hours);
|
|
tempTotalHourCount = tempTotalHourCount.add(hours);
|
|
|
- if (hourCountPair.containsKey(report.getDeptId())) {
|
|
|
|
|
- BigDecimal tempHourCount = hourCountPair.get(report.getDeptId());
|
|
|
|
|
|
|
+ if (hourCountPair.containsKey(report.getTaskId())) {
|
|
|
|
|
+ BigDecimal tempHourCount = hourCountPair.get(report.getTaskId());
|
|
|
hourCountPair.put(report.getTaskId(), tempTotalHourCount.add(tempHourCount));
|
|
hourCountPair.put(report.getTaskId(), tempTotalHourCount.add(tempHourCount));
|
|
|
} else {
|
|
} else {
|
|
|
hourCountPair.put(report.getTaskId(), tempTotalHourCount);
|
|
hourCountPair.put(report.getTaskId(), tempTotalHourCount);
|
|
@@ -449,8 +541,8 @@ public class IotRdDailyReportServiceImpl implements IotRdDailyReportService {
|
|
|
}
|
|
}
|
|
|
if ("方".equals(unit)) {
|
|
if ("方".equals(unit)) {
|
|
|
tempTotalWaterVolume = tempTotalWaterVolume.add(actualValue);
|
|
tempTotalWaterVolume = tempTotalWaterVolume.add(actualValue);
|
|
|
- if (waterVolumePair.containsKey(report.getDeptId())) {
|
|
|
|
|
- BigDecimal tempWaterVolume = waterVolumePair.get(report.getDeptId());
|
|
|
|
|
|
|
+ if (waterVolumePair.containsKey(report.getTaskId())) {
|
|
|
|
|
+ BigDecimal tempWaterVolume = waterVolumePair.get(report.getTaskId());
|
|
|
waterVolumePair.put(report.getTaskId(), tempTotalWaterVolume.add(tempWaterVolume));
|
|
waterVolumePair.put(report.getTaskId(), tempTotalWaterVolume.add(tempWaterVolume));
|
|
|
} else {
|
|
} else {
|
|
|
waterVolumePair.put(report.getTaskId(), tempTotalWaterVolume);
|
|
waterVolumePair.put(report.getTaskId(), tempTotalWaterVolume);
|
|
@@ -458,8 +550,8 @@ public class IotRdDailyReportServiceImpl implements IotRdDailyReportService {
|
|
|
}
|
|
}
|
|
|
if ("井数".equals(unit)) {
|
|
if ("井数".equals(unit)) {
|
|
|
tempTotalCumulativeWorkingWell = tempTotalCumulativeWorkingWell.add(actualValue);
|
|
tempTotalCumulativeWorkingWell = tempTotalCumulativeWorkingWell.add(actualValue);
|
|
|
- if (cumulativeWorkingWellPair.containsKey(report.getDeptId())) {
|
|
|
|
|
- BigDecimal tempWorkingWell = cumulativeWorkingWellPair.get(report.getDeptId());
|
|
|
|
|
|
|
+ if (cumulativeWorkingWellPair.containsKey(report.getTaskId())) {
|
|
|
|
|
+ BigDecimal tempWorkingWell = cumulativeWorkingWellPair.get(report.getTaskId());
|
|
|
cumulativeWorkingWellPair.put(report.getTaskId(), tempTotalCumulativeWorkingWell.add(tempWorkingWell));
|
|
cumulativeWorkingWellPair.put(report.getTaskId(), tempTotalCumulativeWorkingWell.add(tempWorkingWell));
|
|
|
} else {
|
|
} else {
|
|
|
cumulativeWorkingWellPair.put(report.getTaskId(), tempTotalCumulativeWorkingWell);
|
|
cumulativeWorkingWellPair.put(report.getTaskId(), tempTotalCumulativeWorkingWell);
|
|
@@ -468,8 +560,8 @@ public class IotRdDailyReportServiceImpl implements IotRdDailyReportService {
|
|
|
if ("段数".equals(unit)) {
|
|
if ("段数".equals(unit)) {
|
|
|
// 累计施工层
|
|
// 累计施工层
|
|
|
tempTotalCumulativeWorkingLayers = tempTotalCumulativeWorkingLayers.add(actualValue);
|
|
tempTotalCumulativeWorkingLayers = tempTotalCumulativeWorkingLayers.add(actualValue);
|
|
|
- if (cumulativeWorkingLayersPair.containsKey(report.getDeptId())) {
|
|
|
|
|
- BigDecimal tempWorkingLayer = cumulativeWorkingLayersPair.get(report.getDeptId());
|
|
|
|
|
|
|
+ if (cumulativeWorkingLayersPair.containsKey(report.getTaskId())) {
|
|
|
|
|
+ BigDecimal tempWorkingLayer = cumulativeWorkingLayersPair.get(report.getTaskId());
|
|
|
cumulativeWorkingLayersPair.put(report.getTaskId(), tempTotalCumulativeWorkingLayers.add(tempWorkingLayer));
|
|
cumulativeWorkingLayersPair.put(report.getTaskId(), tempTotalCumulativeWorkingLayers.add(tempWorkingLayer));
|
|
|
} else {
|
|
} else {
|
|
|
cumulativeWorkingLayersPair.put(report.getTaskId(), tempTotalCumulativeWorkingLayers);
|
|
cumulativeWorkingLayersPair.put(report.getTaskId(), tempTotalCumulativeWorkingLayers);
|
|
@@ -477,17 +569,18 @@ public class IotRdDailyReportServiceImpl implements IotRdDailyReportService {
|
|
|
}
|
|
}
|
|
|
if ("台次".equals(unit) && "当日泵车台次".equals(attr.getName())) {
|
|
if ("台次".equals(unit) && "当日泵车台次".equals(attr.getName())) {
|
|
|
tempTotalPumpTrips = tempTotalPumpTrips.add(actualValue);
|
|
tempTotalPumpTrips = tempTotalPumpTrips.add(actualValue);
|
|
|
- if (pumpTripsPair.containsKey(report.getDeptId())) {
|
|
|
|
|
- BigDecimal tempPumpTrips = pumpTripsPair.get(report.getDeptId());
|
|
|
|
|
|
|
+ if (pumpTripsPair.containsKey(report.getTaskId())) {
|
|
|
|
|
+ BigDecimal tempPumpTrips = pumpTripsPair.get(report.getTaskId());
|
|
|
pumpTripsPair.put(report.getTaskId(), tempTotalPumpTrips.add(tempPumpTrips));
|
|
pumpTripsPair.put(report.getTaskId(), tempTotalPumpTrips.add(tempPumpTrips));
|
|
|
} else {
|
|
} else {
|
|
|
pumpTripsPair.put(report.getTaskId(), tempTotalPumpTrips);
|
|
pumpTripsPair.put(report.getTaskId(), tempTotalPumpTrips);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- if ("台次".equals(unit) && ("当日仪表/混砂".equals(attr.getName()))) {
|
|
|
|
|
|
|
+ if ("台次".equals(unit) && ("当日仪表/混砂".equals(attr.getName())
|
|
|
|
|
+ || "当日混砂".equals(attr.getName()) || "当日仪表".equals(attr.getName()))) {
|
|
|
tempTotalMixSand = tempTotalMixSand.add(actualValue);
|
|
tempTotalMixSand = tempTotalMixSand.add(actualValue);
|
|
|
- if (mixSandPair.containsKey(report.getDeptId())) {
|
|
|
|
|
- BigDecimal tempMixSand = mixSandPair.get(report.getDeptId());
|
|
|
|
|
|
|
+ if (mixSandPair.containsKey(report.getTaskId())) {
|
|
|
|
|
+ BigDecimal tempMixSand = mixSandPair.get(report.getTaskId());
|
|
|
mixSandPair.put(report.getTaskId(), tempTotalMixSand.add(tempMixSand));
|
|
mixSandPair.put(report.getTaskId(), tempTotalMixSand.add(tempMixSand));
|
|
|
} else {
|
|
} else {
|
|
|
mixSandPair.put(report.getTaskId(), tempTotalMixSand);
|
|
mixSandPair.put(report.getTaskId(), tempTotalMixSand);
|
|
@@ -517,9 +610,13 @@ public class IotRdDailyReportServiceImpl implements IotRdDailyReportService {
|
|
|
/* if (teamDeptPair.containsKey(deptId)) {
|
|
/* if (teamDeptPair.containsKey(deptId)) {
|
|
|
uniqueReport.setDeptName(teamDeptPair.get(deptId));
|
|
uniqueReport.setDeptName(teamDeptPair.get(deptId));
|
|
|
} */
|
|
} */
|
|
|
|
|
+ uniqueReport.setTaskId(taskId);
|
|
|
if (taskDeptNamePair.containsKey(taskId)) {
|
|
if (taskDeptNamePair.containsKey(taskId)) {
|
|
|
uniqueReport.setDeptName(taskDeptNamePair.get(taskId));
|
|
uniqueReport.setDeptName(taskDeptNamePair.get(taskId));
|
|
|
}
|
|
}
|
|
|
|
|
+ if (taskCreateTimePair.containsKey(taskId)) {
|
|
|
|
|
+ uniqueReport.setCreateTime(taskCreateTimePair.get(taskId));
|
|
|
|
|
+ }
|
|
|
/* if (teamProjectPair.containsKey(deptId)) {
|
|
/* if (teamProjectPair.containsKey(deptId)) {
|
|
|
Long parentId = teamProjectPair.get(deptId);
|
|
Long parentId = teamProjectPair.get(deptId);
|
|
|
if (projectDeptPair.containsKey(parentId)) {
|
|
if (projectDeptPair.containsKey(parentId)) {
|
|
@@ -535,6 +632,12 @@ public class IotRdDailyReportServiceImpl implements IotRdDailyReportService {
|
|
|
if (taskPair.containsKey(taskId)) {
|
|
if (taskPair.containsKey(taskId)) {
|
|
|
uniqueReport.setWellName(taskPair.get(taskId));
|
|
uniqueReport.setWellName(taskPair.get(taskId));
|
|
|
}
|
|
}
|
|
|
|
|
+ if (taskPeriodPair.containsKey(taskId)) {
|
|
|
|
|
+ uniqueReport.setPeriod(taskPeriodPair.get(taskId));
|
|
|
|
|
+ }
|
|
|
|
|
+ if (taskStatusPair.containsKey(taskId)) {
|
|
|
|
|
+ uniqueReport.setRdStatus(taskStatusPair.get(taskId));
|
|
|
|
|
+ }
|
|
|
if (taskTechniquePair.containsKey(taskId)) {
|
|
if (taskTechniquePair.containsKey(taskId)) {
|
|
|
uniqueReport.setTechniques(taskTechniquePair.get(taskId));
|
|
uniqueReport.setTechniques(taskTechniquePair.get(taskId));
|
|
|
}
|
|
}
|
|
@@ -604,6 +707,13 @@ public class IotRdDailyReportServiceImpl implements IotRdDailyReportService {
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+ // 将 result 集合按照 集合中元素的 属性 创建时间 倒序排列
|
|
|
|
|
+ if (CollUtil.isNotEmpty(result)) {
|
|
|
|
|
+ result.sort(Comparator.comparing(
|
|
|
|
|
+ IotRdDailyReportStatisticsRespVO::getCreateTime,
|
|
|
|
|
+ Comparator.nullsLast(Comparator.reverseOrder())
|
|
|
|
|
+ ));
|
|
|
|
|
+ }
|
|
|
return result;
|
|
return result;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -612,9 +722,118 @@ public class IotRdDailyReportServiceImpl implements IotRdDailyReportService {
|
|
|
if (CollUtil.isEmpty(reports)) {
|
|
if (CollUtil.isEmpty(reports)) {
|
|
|
throw exception(IOT_RD_DAILY_REPORT_NOT_EXISTS);
|
|
throw exception(IOT_RD_DAILY_REPORT_NOT_EXISTS);
|
|
|
}
|
|
}
|
|
|
|
|
+ // 需要发送提醒消息的日报对象
|
|
|
|
|
+ List<IotRdDailyReportDO> tobeSendMsgReports = new ArrayList<>();
|
|
|
|
|
+ // 主井日报
|
|
|
|
|
+ List<IotRdDailyReportDO> mainPlatformReports = new ArrayList<>();
|
|
|
|
|
+ // 关联井日报
|
|
|
|
|
+ List<IotRdDailyReportDO> relatePlatformReports = new ArrayList<>();
|
|
|
reports.forEach(report -> {
|
|
reports.forEach(report -> {
|
|
|
- updateIotRdDailyReport(report);
|
|
|
|
|
|
|
+ IotRdDailyReportDO updatedReport = updateIotRdDailyReport(report);
|
|
|
|
|
+ // 标识当前任务井是 普通井 或 平台井主井 关联的任务审批人发送提醒消息
|
|
|
|
|
+ if (1 == updatedReport.getPlatformWell() || 0 == updatedReport.getPlatformWell()) {
|
|
|
|
|
+ tobeSendMsgReports.add(updatedReport);
|
|
|
|
|
+ }
|
|
|
|
|
+ // 记录关联井集合
|
|
|
|
|
+ if (2 == updatedReport.getPlatformWell()) {
|
|
|
|
|
+ relatePlatformReports.add(updatedReport);
|
|
|
|
|
+ }
|
|
|
|
|
+ // 记录平台井主井集合
|
|
|
|
|
+ if (1 == updatedReport.getPlatformWell()) {
|
|
|
|
|
+ mainPlatformReports.add(updatedReport);
|
|
|
|
|
+ }
|
|
|
});
|
|
});
|
|
|
|
|
+
|
|
|
|
|
+ // 兼容平台井任务 主井任务已经施工完成 但是关联井仍在施工的情况 此时 平台井 下拉列表中 选择不到主井
|
|
|
|
|
+ // 此时应该同步修改主井任务的 填写状态 审批状态
|
|
|
|
|
+ if (CollUtil.isNotEmpty(relatePlatformReports) && CollUtil.isEmpty(mainPlatformReports)) {
|
|
|
|
|
+ // 找到关联井对应的主井 并把 主井 添加到 准备发送消息提醒的集合 tobeSendMsgReports
|
|
|
|
|
+ IotRdDailyReportDO randomRelatedReport = relatePlatformReports.get(0);
|
|
|
|
|
+ String platformGroup = randomRelatedReport.getPlatformGroup();
|
|
|
|
|
+ // 根据 platformGroup 找到主井日报
|
|
|
|
|
+ IotRdDailyReportPageReqVO reqVO = new IotRdDailyReportPageReqVO();
|
|
|
|
|
+ reqVO.setPlatformGroup(platformGroup);
|
|
|
|
|
+ reqVO.setPlatformWell(1);
|
|
|
|
|
+ List<IotRdDailyReportDO> mainWellReports = iotRdDailyReportMapper.dailyReports(reqVO);
|
|
|
|
|
+ if (CollUtil.isNotEmpty(mainWellReports)) {
|
|
|
|
|
+ IotRdDailyReportDO mainWellReport = mainWellReports.get(0);
|
|
|
|
|
+ // 设置 日报审批状态为 审批中 auditStatus = 10
|
|
|
|
|
+ mainWellReport.setAuditStatus(10);
|
|
|
|
|
+ // 设置 日报填写状态 保存 已完成
|
|
|
|
|
+ mainWellReport.setStatus(1);
|
|
|
|
|
+ iotRdDailyReportMapper.updateById(mainWellReport);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 考虑到平台井的情况 只向有审批权限的人发送一次 钉钉提醒及站内信
|
|
|
|
|
+ // 任务为平台井时 只向主井的任务的 填报人所属部门或上级项目部下 有审批权限的人 发送消息提醒
|
|
|
|
|
+ if (CollUtil.isNotEmpty(tobeSendMsgReports)) {
|
|
|
|
|
+ Set<Long> deptIds = new HashSet<>();
|
|
|
|
|
+ IotRdDailyReportDO tobeSendMsgReport = tobeSendMsgReports.get(0);
|
|
|
|
|
+ Long deptId = tobeSendMsgReport.getDeptId();
|
|
|
|
|
+ DeptDO dept = deptService.getDept(deptId);
|
|
|
|
|
+ if (ObjUtil.isNotEmpty(dept)) {
|
|
|
|
|
+ deptIds.add(dept.getId());
|
|
|
|
|
+ String type = dept.getType();
|
|
|
|
|
+ // 类型(公司级1 项目部2 队伍3)
|
|
|
|
|
+ // 如果当前部门是 队伍 查找上级 项目部
|
|
|
|
|
+ if ("3".equals(type)) {
|
|
|
|
|
+ DeptDO projectDept = deptService.getDept(dept.getParentId());
|
|
|
|
|
+ if (ObjUtil.isNotEmpty(projectDept)) {
|
|
|
|
|
+ deptIds.add(projectDept.getId());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ // 查找当前部门及项目下有审批权限的人员 role 项目部日报审批RD
|
|
|
|
|
+ List<AdminUserDO> receivedMsgUsers = adminUserService.getUserListByDeptIds(deptIds);
|
|
|
|
|
+ //
|
|
|
|
|
+ if (CollUtil.isNotEmpty(receivedMsgUsers)) {
|
|
|
|
|
+ Set<Long> userIds = new HashSet<>();
|
|
|
|
|
+ receivedMsgUsers.forEach(user -> {
|
|
|
|
|
+ userIds.add(user.getId());
|
|
|
|
|
+ });
|
|
|
|
|
+ RoleDO role = roleService.getRoleByCode("项目部日报审批RD");
|
|
|
|
|
+ if (ObjUtil.isNotEmpty(role)) {
|
|
|
|
|
+ Set<Long> roleIds = new HashSet<>();
|
|
|
|
|
+ roleIds.add(role.getId());
|
|
|
|
|
+ List<UserRoleDO> userRoles = userRoleMapper.selectListByRoleIds(roleIds);
|
|
|
|
|
+ if (CollUtil.isNotEmpty(userRoles)) {
|
|
|
|
|
+ // 提取有审批角色的所有用户ID(去重+空值过滤)
|
|
|
|
|
+ Set<Long> roleUserIds = userRoles.stream()
|
|
|
|
|
+ .map(UserRoleDO::getUserId)
|
|
|
|
|
+ .filter(Objects::nonNull) // 过滤空userId
|
|
|
|
|
+ .collect(Collectors.toSet());
|
|
|
|
|
+
|
|
|
|
|
+ // 计算两个集合的交集,得到最终目标用户ID
|
|
|
|
|
+ Set<Long> targetUserIds = userIds.stream()
|
|
|
|
|
+ .filter(roleUserIds::contains)
|
|
|
|
|
+ .collect(Collectors.toSet());
|
|
|
|
|
+
|
|
|
|
|
+ // 异步发送 站内信 钉钉消息
|
|
|
|
|
+ if (CollUtil.isNotEmpty(targetUserIds)) {
|
|
|
|
|
+ Map<Long, AdminUserRespDTO> users = adminUserApi.getUserMap(targetUserIds);
|
|
|
|
|
+ // 给多个用户发送 相同 的 提醒消息
|
|
|
|
|
+ if (CollUtil.isNotEmpty(users)) {
|
|
|
|
|
+ CountDownLatch latch = new CountDownLatch(users.size());
|
|
|
|
|
+ users.forEach((userId, user) -> {
|
|
|
|
|
+ pmsThreadPoolTaskExecutor.execute(() -> {
|
|
|
|
|
+ try {
|
|
|
|
|
+ String mobile = user.getMobile();
|
|
|
|
|
+ if (StrUtil.isNotBlank(mobile) && StrUtil.isNotBlank(tobeSendMsgReport.getReportName())) {
|
|
|
|
|
+ pmsMessage.sendMessage(tobeSendMsgReport.getId(), tobeSendMsgReport.getReportName(), PmsConstants.DAILY_REPORT_APPROVAL,
|
|
|
|
|
+ userId, mobile);
|
|
|
|
|
+ }
|
|
|
|
|
+ } finally {
|
|
|
|
|
+ latch.countDown();
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|