Parcourir la source

Merge remote-tracking branch 'origin/master'

lipenghui il y a 2 jours
Parent
commit
53170c1ae2

+ 2 - 2
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/iotrddailyreport/IotRdDailyReportController.java

@@ -1217,7 +1217,7 @@ public class IotRdDailyReportController {
                             tempTotalMixSand = tempTotalMixSand.add(actualValue);
                             if (groupMixSandPair.containsKey(uniqueKey)) {
                                 BigDecimal tempMixSand = groupMixSandPair.get(uniqueKey);
-                                groupMixSandPair.put(uniqueKey, tempTotalMixSand.add(tempMixSand));
+                                groupMixSandPair.put(uniqueKey, actualValue.add(tempMixSand));
                             } else {
                                 groupMixSandPair.put(uniqueKey, tempTotalMixSand);
                             }
@@ -1760,7 +1760,7 @@ public class IotRdDailyReportController {
                             tempTotalMixSand = tempTotalMixSand.add(actualValue);
                             if (groupMixSandPair.containsKey(uniqueKey)) {
                                 BigDecimal tempMixSand = groupMixSandPair.get(uniqueKey);
-                                groupMixSandPair.put(uniqueKey, tempTotalMixSand.add(tempMixSand));
+                                groupMixSandPair.put(uniqueKey, actualValue.add(tempMixSand));
                             } else {
                                 groupMixSandPair.put(uniqueKey, tempTotalMixSand);
                             }

+ 13 - 11
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/service/iotrddailyreport/IotRdDailyReportServiceImpl.java

@@ -634,7 +634,7 @@ public class IotRdDailyReportServiceImpl implements IotRdDailyReportService {
                             tempTotalMixSand = tempTotalMixSand.add(actualValue);
                             if (mixSandPair.containsKey(report.getTaskId())) {
                                 BigDecimal tempMixSand = mixSandPair.get(report.getTaskId());
-                                mixSandPair.put(report.getTaskId(), tempTotalMixSand.add(tempMixSand));
+                                mixSandPair.put(report.getTaskId(), actualValue.add(tempMixSand));
                             } else {
                                 mixSandPair.put(report.getTaskId(), tempTotalMixSand);
                             }
@@ -738,20 +738,22 @@ public class IotRdDailyReportServiceImpl implements IotRdDailyReportService {
                         item.setWorkload(cumulativeWorkingLayersPair.get(taskId));
                         items.add(item);
                     }
-                    if (pumpTripsPair.containsKey(taskId)) {
+                    if (pumpTripsPair.containsKey(taskId) || mixSandPair.containsKey(taskId)) {
                         // 主压裂车 当日泵车台次
                         IotRdDailyReportStatisticsItemVO item = new IotRdDailyReportStatisticsItemVO();
                         item.setUnit("台次");
-                        item.setWorkload(pumpTripsPair.get(taskId));
+                        BigDecimal tempPumpTrip = pumpTripsPair.get(taskId);
+                        BigDecimal tempMixSand = mixSandPair.get(taskId);
+                        item.setWorkload((ObjUtil.isEmpty(tempPumpTrip)?BigDecimal.ZERO:tempPumpTrip).add(ObjUtil.isEmpty(tempMixSand)?BigDecimal.ZERO:tempMixSand));
                         items.add(item);
                     }
-                    if (mixSandPair.containsKey(taskId)) {
+                    /* if (mixSandPair.containsKey(taskId)) {
                         // 当日仪表/混砂 台次
                         IotRdDailyReportStatisticsItemVO item = new IotRdDailyReportStatisticsItemVO();
                         item.setUnit("台次");
                         item.setWorkload(mixSandPair.get(taskId));
                         items.add(item);
-                    }
+                    } */
                     uniqueReport.setItems(items);
                     result.add(uniqueReport);
                 });
@@ -979,7 +981,7 @@ public class IotRdDailyReportServiceImpl implements IotRdDailyReportService {
                             tempTotalMixSand = tempTotalMixSand.add(actualValue);
                             if (cumulativeMixSandPair.containsKey("cumulativeMixSand")) {
                                 BigDecimal tempMixSand = cumulativeMixSandPair.get("cumulativeMixSand");
-                                cumulativeMixSandPair.put("cumulativeMixSand", tempTotalMixSand.add(tempMixSand));
+                                cumulativeMixSandPair.put("cumulativeMixSand", actualValue.add(tempMixSand));
                             } else {
                                 cumulativeMixSandPair.put("cumulativeMixSand", tempTotalMixSand);
                             }
@@ -1268,7 +1270,7 @@ public class IotRdDailyReportServiceImpl implements IotRdDailyReportService {
                                     tempTotalMixSand = tempTotalMixSand.add(actualValue);
                                     if (cumulativeMixSandPair.containsKey(projectDeptId)) {
                                         BigDecimal tempMixSand = cumulativeMixSandPair.get(projectDeptId);
-                                        cumulativeMixSandPair.put(projectDeptId, tempTotalMixSand.add(tempMixSand));
+                                        cumulativeMixSandPair.put(projectDeptId, actualValue.add(tempMixSand));
                                     } else {
                                         cumulativeMixSandPair.put(projectDeptId, tempTotalMixSand);
                                     }
@@ -1505,7 +1507,7 @@ public class IotRdDailyReportServiceImpl implements IotRdDailyReportService {
                                     tempTotalMixSand = tempTotalMixSand.add(actualValue);
                                     if (cumulativeMixSandPair.containsKey(detailDeptId)) {
                                         BigDecimal tempMixSand = cumulativeMixSandPair.get(detailDeptId);
-                                        cumulativeMixSandPair.put(detailDeptId, tempTotalMixSand.add(tempMixSand));
+                                        cumulativeMixSandPair.put(detailDeptId, actualValue.add(tempMixSand));
                                     } else {
                                         cumulativeMixSandPair.put(detailDeptId, tempTotalMixSand);
                                     }
@@ -1518,7 +1520,7 @@ public class IotRdDailyReportServiceImpl implements IotRdDailyReportService {
         }
 
         // 项目部数据
-        projectDeptPair.forEach((projectDeptId, dept) -> {
+        /* projectDeptPair.forEach((projectDeptId, dept) -> {
             IotRdDailyReportStatisticsRespVO statistics = new IotRdDailyReportStatisticsRespVO();
             statistics.setTeamId(projectDeptId);
             statistics.setProjectDeptName(dept.getName());
@@ -1537,7 +1539,7 @@ public class IotRdDailyReportServiceImpl implements IotRdDailyReportService {
             statistics.setCumulativePumpTrips(cumulativePumpTripsPair.get(projectDeptId));
             statistics.setTotalDailyFuel(cumulativeFuelsPair.get(projectDeptId));
             result.add(statistics);
-        });
+        }); */
 
         // 队伍数据  生成返回的数据列表集合
         teamDeptPair.forEach((teamDeptId, dept) -> {
@@ -1776,7 +1778,7 @@ public class IotRdDailyReportServiceImpl implements IotRdDailyReportService {
                             tempTotalMixSand = tempTotalMixSand.add(actualValue);
                             if (dateMixSandPair.containsKey(reportDateStr)) {
                                 BigDecimal tempMixSand = dateMixSandPair.get(reportDateStr);
-                                dateMixSandPair.put(reportDateStr, tempTotalMixSand.add(tempMixSand));
+                                dateMixSandPair.put(reportDateStr, actualValue.add(tempMixSand));
                             } else {
                                 dateMixSandPair.put(reportDateStr, tempTotalMixSand);
                             }

+ 3 - 2
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/service/iotrhdailyreport/IotRhDailyReportServiceImpl.java

@@ -366,6 +366,8 @@ public class IotRhDailyReportServiceImpl implements IotRhDailyReportService {
             iotRhDailyReportMapper.updateById(iotRhDailyReport);
 
             if (CollUtil.isNotEmpty(teamStatusL)) {
+                // 添加空白日报时 只需要发送填报提醒 不需要发送审批提醒
+                noDeviceTeam.set(true);
                 // 说明队伍下的设备类别为非施工状态,需要向 日报填报人发送 消息提醒
                 Set<Long> targetUserIds = new HashSet<>();
                 targetUserIds.add(Long.valueOf(iotRhDailyReport.getCreator()));
@@ -386,7 +388,6 @@ public class IotRhDailyReportServiceImpl implements IotRhDailyReportService {
                                 String mobile = user.getMobile();
                                 // 没有手机号也发送站内信消息
                                 if (StrUtil.isNotBlank(finalMsgTitle)) {
-                                    noDeviceTeam.set(true);
                                     System.out.println("向日报创建人发送消息");
                                     pmsMessage.sendMessage(iotRhDailyReport.getId(), finalMsgTitle, PmsConstants.RH_DAILY_REPORT,
                                             userId, mobile);
@@ -408,7 +409,7 @@ public class IotRhDailyReportServiceImpl implements IotRhDailyReportService {
         // 只要保存了记录就要发送审批提醒到 提交人对应的项目经理 角色 项目部日报审批RH
         // 根据日报的 deptId 查询上级项目部经理 角色的审批人 发送站内信 钉钉提醒
         // 此时需要判断下当前队伍下有无增压机,如果 ‘当前队伍下无增压机’ 或 ‘增压机的状态不是施工’ 需要新增空白记录 向填报人推送消息。
-        // 暂时添加判断条件 创建人 是 null 的话 不发送 站内信及钉钉消息
+        // 暂时添加判断条件 创建人 是 null 的话 不发送 站内信及钉钉消息 如果已经发送了填报日报的提醒 不需要再发送审批的提醒
         if (StrUtil.isNotBlank(iotRhDailyReport.getCreator()) && !noDeviceTeam.get()) {
             Long parentId = currentDept[0].getParentId();
             if (ObjUtil.isNotEmpty(parentId)) {

+ 75 - 4
yudao-module-pms/yudao-module-pms-biz/src/main/resources/mapper/static/IotOpeationFillMapper.xml

@@ -1255,17 +1255,88 @@
     <select id="selectDevStatusBatch" parameterType="java.util.List"
             resultType="cn.iocoder.yudao.module.pms.dal.dataobject.IotDeviceDO">
         SELECT
-        dept_id, -- 建议返回部门ID,方便后续关联结果
+        dept_id,
         device_status
+        FROM (
+        SELECT
+        d.dept_id,
+        -- 原有优先级判断逻辑,不变
+        CASE
+        WHEN EXISTS (
+        SELECT 1
+        FROM rq_iot_device
+        WHERE dept_id = d.dept_id
+        AND asset_class IN (159, 160)
+        AND deleted = 0
+        ) THEN (
+        SELECT device_status
+        FROM rq_iot_device
+        WHERE dept_id = d.dept_id
+        AND asset_class IN (159, 160)
+        AND deleted = 0
+        AND device_status != 'sg'
+        LIMIT 1
+        )
+        WHEN EXISTS (
+        SELECT 1
+        FROM rq_iot_device
+        WHERE dept_id = d.dept_id
+        AND asset_class = 122
+        AND deleted = 0
+        ) THEN (
+        SELECT device_status
+        FROM rq_iot_device
+        WHERE dept_id = d.dept_id
+        AND asset_class = 122
+        AND deleted = 0
+        AND device_status != 'sg'
+        LIMIT 1
+        )
+        WHEN EXISTS (
+        SELECT 1
+        FROM rq_iot_device
+        WHERE dept_id = d.dept_id
+        AND asset_class IN (157, 158, 191)
+        AND deleted = 0
+        ) THEN (
+        SELECT device_status
+        FROM rq_iot_device
+        WHERE dept_id = d.dept_id
+        AND asset_class IN (157, 158, 191)
+        AND deleted = 0
+        AND device_status != 'sg'
+        LIMIT 1
+        )
+        WHEN EXISTS (
+        SELECT 1
+        FROM rq_iot_device
+        WHERE dept_id = d.dept_id
+        AND asset_class = 106
+        AND deleted = 0
+        ) THEN (
+        SELECT device_status
+        FROM rq_iot_device
+        WHERE dept_id = d.dept_id
+        AND asset_class = 106
+        AND deleted = 0
+        AND device_status != 'sg'
+        LIMIT 1
+        )
+        ELSE NULL
+        END AS device_status
+        FROM (
+        SELECT DISTINCT dept_id
         FROM rq_iot_device
         WHERE dept_id IN
         <foreach collection="teams" item="item" open="(" separator="," close=")">
             #{item.id}
         </foreach>
         AND asset_class IN (159, 160, 122, 106, 157, 158, 191)
-        AND device_status != 'sg'
-        and deleted = 0
-        GROUP BY dept_id -- 确保每个部门只返回1条记录(若多个设备,取任意1条)
+        AND deleted = 0
+        ) AS d
+        ) AS temp
+        -- 核心过滤:仅保留设备状态非NULL的记录,状态为NULL则不返回整条记录
+        WHERE temp.device_status IS NOT NULL -- 确保每个部门只返回1条记录(若多个设备,取任意1条)
         -- 可选:如需指定返回某条设备(如最新/最早),可加排序:
         -- ORDER BY create_time DESC -- 按创建时间倒序(取最新)
     </select>

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

@@ -22,6 +22,7 @@
         <result column="production_status" property="productionStatus" />
         <result column="next_plan" property="nextPlan" />
         <result column="personnel" property="personnel" />
+        <result column="ext_property" property="extProperty" typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler"/>
         <!-- 其他字段映射 -->
         <result column="remark" property="remark" />
         <result column="status" property="status" />