Browse Source

pms 瑞都日报 施工队伍所属设备人员排序靠前

zhangcl 2 days ago
parent
commit
8a3c577c39

+ 16 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/iotrddailyreport/vo/IotRdDailyReportRespVO.java

@@ -251,6 +251,22 @@ public class IotRdDailyReportRespVO {
     @ExcelProperty("工作量属性")
     private List<IotDailyReportAttrsDO> dailyReportAttrs;
 
+    @Schema(description = "搬迁日期", example = "125")
+    @ExcelProperty("搬迁日期")
+    private String relocationDate;
+
+    @Schema(description = "开工日期", example = "125")
+    @ExcelProperty("开工日期")
+    private String commencementDate;
+
+    @Schema(description = "完工日期", example = "125")
+    @ExcelProperty("完工日期")
+    private String completionDate;
+
+    @Schema(description = "施工周期", example = "125")
+    @ExcelProperty("施工周期")
+    private String constructionPeriod;
+
     /**
      * 扩展属性
      */

+ 27 - 1
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/service/IotDeviceServiceImpl.java

@@ -1,6 +1,7 @@
 package cn.iocoder.yudao.module.pms.service;
 
 import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.util.ObjUtil;
 import cn.hutool.core.util.StrUtil;
 import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
 import cn.iocoder.yudao.framework.common.exception.ServiceException;
@@ -543,25 +544,50 @@ public class IotDeviceServiceImpl implements IotDeviceService {
 
     @Override
     public List<IotDeviceDO> getDevicesByDepts(IotDevicePageReqVO reqVO) {
+        if (ObjUtil.isEmpty(reqVO)) {
+            throw new ServiceException(IOT_DEPT_NOT_SELECTED);
+        }
         // 如果 reqVO.getDeptIds 有值 就是根据选择的部门 查询部门下所有设备
         // 考虑到设备调拨的情况 可以修改 成查询所选部门所属公司下所有设备
         if (CollUtil.isEmpty(reqVO.getDeviceIds()) && CollUtil.isEmpty(reqVO.getDeptIds())) {
             throw new ServiceException(IOT_DEPT_NOT_SELECTED);
         }
+        List<IotDeviceDO> rdDevices = new ArrayList<>();
         if (CollUtil.isNotEmpty(reqVO.getDeptIds())) {
             // 查询选择的部门 选择的部门所属的公司 属于 瑞都 163l 则查询所有瑞都下的设备
+            // 但是 所选队伍 下的所有设备 需要显示在列表最上面
             List<Long> deptIds = reqVO.getDeptIds();
             Long randomDeptId = deptIds.get(0);
             // 查询 瑞都下的所有 部门
             Set<Long> childDeptIds = deptService.getChildDeptIdListFromCache(163l);
             if (childDeptIds.contains(randomDeptId)) {
+                // 施工队伍 属于 瑞都 163l 则查询所有瑞都下的设备
                 reqVO.setDeptIds(new ArrayList<>(childDeptIds));
+                // 查询所选施工队伍下所有设备
+                IotDevicePageReqVO rdReqVO = new IotDevicePageReqVO();
+                rdReqVO.setDeptIds(deptIds);
+                rdDevices = iotDeviceMapper.selectSimpleList(rdReqVO, null);
             }
         }
         AtomicReference<List<IotDeviceDO>> devices = new AtomicReference<>(new ArrayList<>());
         // 忽略数据权限
+        List<IotDeviceDO> finalRdDevices = rdDevices;
         DataPermissionUtils.executeIgnore(() -> {
-            devices.set(iotDeviceMapper.selectSimpleList(reqVO, null));
+            List<IotDeviceDO> resultDevices = iotDeviceMapper.selectSimpleList(reqVO, null);
+            devices.set(resultDevices);
+            // 如果瑞都日报任务 将施工队伍所属设备显示到设备列表前面
+            if (CollUtil.isNotEmpty(resultDevices) && CollUtil.isNotEmpty(finalRdDevices)) {
+                // 提取 finalRdDevices 的id集合(快速判断)
+                Set<Long> rdDeviceIds = finalRdDevices.stream()
+                        .map(IotDeviceDO::getId)
+                        .collect(Collectors.toSet());
+
+                // 排序:finalRdDevices 中的元素排前面,保持原有相对顺序
+                resultDevices.sort(Comparator.comparingInt(u -> rdDeviceIds.contains(u.getId()) ? 0 : 1));
+
+                // 更新结果集
+                devices.set(resultDevices);
+            }
         });
         return devices.get();
     }

+ 22 - 1
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/user/AdminUserServiceImpl.java

@@ -54,6 +54,7 @@ import java.io.InputStream;
 import java.time.LocalDateTime;
 import java.util.*;
 import java.util.concurrent.atomic.AtomicReference;
+import java.util.stream.Collectors;
 
 import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
 import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*;
@@ -703,23 +704,43 @@ public class AdminUserServiceImpl implements AdminUserService {
         DeptListReqVO deptListReqVO = new DeptListReqVO();
         deptListReqVO.setDeptIds(reqVO.getDeptIds());
         List<Long> deptIds = new ArrayList<>();
+        // 瑞都施工队伍
+        List<Long> rdDeptIds = new ArrayList<>();
         // 查询 瑞都下的所有 部门
         Set<Long> childDeptIds = deptService.getChildDeptIdListFromCache(163l);
         childDeptIds.add(163l);
         if (childDeptIds.contains(randomDeptId)) {
-            // 瑞都下的部门 队伍
+            // 瑞都下的部门 队伍 施工队伍包含的用户显示到设备列表前面
             deptIds = new ArrayList<>(childDeptIds);
+            rdDeptIds = deptService.selectedDepts(deptListReqVO);
         } else {
             deptIds = deptService.selectedDepts(deptListReqVO);
         }
         if (CollUtil.isNotEmpty(deptIds)) {
             // 查询部门下所有人员
             List<Long> finalDeptIds = deptIds;
+            List<Long> finalRdDeptIds = rdDeptIds;
             DataPermissionUtils.executeIgnore(() -> {
                 List<AdminUserDO> users = userMapper.selectSimpleList(finalDeptIds);
                 if (CollUtil.isNotEmpty(users)) {
                     resultUsers.set(users);
                 }
+                if (childDeptIds.contains(randomDeptId)) {
+                    // 如果是瑞都任务 施工队伍包含的用户显示到设备列表前面
+                    List<AdminUserDO> rdUsers = userMapper.selectSimpleList(finalRdDeptIds);
+                    if (CollUtil.isNotEmpty(users) && CollUtil.isNotEmpty(rdUsers)) {
+                        // 提取rdUsers的id集合(快速判断)
+                        Set<Long> rdUserIds = rdUsers.stream()
+                                .map(AdminUserDO::getId)
+                                .collect(Collectors.toSet());
+
+                        // 排序:rdUsers中的元素排前面,保持原有相对顺序
+                        users.sort(Comparator.comparingInt(u -> rdUserIds.contains(u.getId()) ? 0 : 1));
+
+                        // 更新结果集
+                        resultUsers.set(users);
+                    }
+                }
             });
         }
         return resultUsers.get();