浏览代码

pms 瑞恒日报列表 兼容 移动端 多条件查询

zhangcl 1 天之前
父节点
当前提交
e99fb7d2cc

+ 11 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/iotrhdailyreport/IotRhDailyReportController.java

@@ -174,6 +174,17 @@ public class IotRhDailyReportController {
         // 根据查询参数筛选出 符合条件 的记录id 再传入 分页查询
         Set<Long> projectIds = new HashSet<>();
         Set<Long> taskIds = new HashSet<>();
+        // 移动端搜索条件 标识 合同名称 任务井号 ... 移动端兼容:searchKey 不为空时 自动填充未填的 contractName / taskName
+        String searchKey = pageReqVO.getSearchKey();
+        if (StrUtil.isNotBlank(searchKey)) {
+            if (StrUtil.isBlank(pageReqVO.getContractName())) {
+                pageReqVO.setContractName(searchKey);
+            }
+            if (StrUtil.isBlank(pageReqVO.getTaskName())) {
+                pageReqVO.setTaskName(searchKey);
+            }
+        }
+
         if (StrUtil.isNotBlank(pageReqVO.getContractName())) {
             IotProjectInfoPageReqVO reqVO = new IotProjectInfoPageReqVO();
             reqVO.setContractName(pageReqVO.getContractName());

+ 3 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/iotrhdailyreport/vo/IotRhDailyReportPageReqVO.java

@@ -142,4 +142,7 @@ public class IotRhDailyReportPageReqVO extends PageParam {
 
     @Schema(description = "施工区域", example = "一厂")
     private String location;
+
+    @Schema(description = "移动端查询标识", example = "#33 - 一厂")
+    private String searchKey;
 }

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

@@ -967,14 +967,22 @@ public class IotRhDailyReportServiceImpl implements IotRhDailyReportService {
             ids.add(pageReqVO.getDeptId());
             pageReqVO.setDeptIds(ids);
         }
-        // 检查contractName不为空但projectIds为空的情况
-        if (StrUtil.isNotBlank(pageReqVO.getContractName()) && (CollUtil.isEmpty(pageReqVO.getProjectIds()))) {
-            return new PageResult<>(Collections.emptyList(), 0L);
-        }
-        // 检查taskName不为空但taskIds为空的情况
-        if (StrUtil.isNotBlank(pageReqVO.getTaskName()) && (CollUtil.isEmpty(pageReqVO.getTaskIds()))) {
-            return new PageResult<>(Collections.emptyList(), 0L);
+        // searchKey 兼容移动端查询的情况
+        if (StrUtil.isNotBlank(pageReqVO.getSearchKey())) {
+            if (CollUtil.isEmpty(pageReqVO.getProjectIds()) && CollUtil.isEmpty(pageReqVO.getTaskIds())) {
+                return new PageResult<>(Collections.emptyList(), 0L);
+            }
+        } else {
+            // 检查contractName不为空但projectIds为空的情况
+            if (StrUtil.isNotBlank(pageReqVO.getContractName()) && (CollUtil.isEmpty(pageReqVO.getProjectIds()))) {
+                return new PageResult<>(Collections.emptyList(), 0L);
+            }
+            // 检查taskName不为空但taskIds为空的情况
+            if (StrUtil.isNotBlank(pageReqVO.getTaskName()) && (CollUtil.isEmpty(pageReqVO.getTaskIds()))) {
+                return new PageResult<>(Collections.emptyList(), 0L);
+            }
         }
+
         // 时间查询区间内如果包含 未发生的时间段(今年 本季度) 则设置 结束时间为 当前日期
         // 【调用公共方法】矫正未来时间区间
         LocalDateTimeUtils.correctFutureTimeRange(pageReqVO.getCreateTime());

+ 45 - 2
yudao-module-pms/yudao-module-pms-biz/src/main/resources/mapper/static/iotprojecttask/IotRhDailyReportMapper.xml

@@ -173,7 +173,8 @@
             rq_iot_rh_daily_report rdr
         INNER JOIN system_dept d ON d.id = rdr.dept_id
         LEFT JOIN system_dept pd ON pd.id = d.parent_id
-        WHERE
+        <where>
+
             rdr.deleted = 0
         AND rdr.dept_id IS NOT NULL
         <if test="deptIds != null and deptIds.size &gt; 0">
@@ -182,6 +183,7 @@
                 #{key}
             </foreach>
         </if>
+        <!--
         <if test="projectIds != null and projectIds.size &gt; 0">
             AND rdr.project_id IN
             <foreach collection="projectIds" index="index" item="key" open="(" separator="," close=")">
@@ -193,7 +195,7 @@
             <foreach collection="taskIds" index="index" item="key" open="(" separator="," close=")">
                 #{key}
             </foreach>
-        </if>
+        </if> -->
         <if test='reqVO.nonProductFlag != null and reqVO.nonProductFlag == "Y"'>
             AND (rdr.accident_time &gt; 0 OR rdr.repair_time &gt; 0 OR rdr.complexity_time &gt; 0 OR rdr.rectification_time &gt; 0
                      OR rdr.waiting_stop_time &gt; 0 OR rdr.partya_design &gt; 0 OR rdr.partya_prepare &gt; 0
@@ -209,6 +211,47 @@
                 AND rdr.create_time &lt;= #{reqVO.createTime[1]}
             </if>
         </if>
+
+        <choose>
+            <when test="reqVO.searchKey != null and reqVO.searchKey != ''">
+                <!-- 移动端:projectIds 与 taskIds 使用 OR 组合 -->
+                <if test="(projectIds != null and projectIds.size &gt; 0)
+                      or (taskIds != null and taskIds.size &gt; 0)">
+                    AND (
+                    <if test="projectIds != null and projectIds.size &gt; 0">
+                        rdr.project_id IN
+                        <foreach collection="projectIds" item="pid" open="(" separator="," close=")">
+                            #{pid}
+                        </foreach>
+                    </if>
+                    <if test="taskIds != null and taskIds.size &gt; 0">
+                        <if test="projectIds != null and projectIds.size &gt; 0"> OR </if>
+                        rdr.task_id IN
+                        <foreach collection="taskIds" item="tid" open="(" separator="," close=")">
+                            #{tid}
+                        </foreach>
+                    </if>
+                    )
+                </if>
+            </when>
+            <otherwise>
+                <!-- PC 端:projectIds 与 taskIds 使用 AND -->
+                <if test="projectIds != null and projectIds.size &gt; 0">
+                    AND rdr.project_id IN
+                    <foreach collection="projectIds" item="pid" open="(" separator="," close=")">
+                        #{pid}
+                    </foreach>
+                </if>
+                <if test="taskIds != null and taskIds.size &gt; 0">
+                    AND rdr.task_id IN
+                    <foreach collection="taskIds" item="tid" open="(" separator="," close=")">
+                        #{tid}
+                    </foreach>
+                </if>
+            </otherwise>
+        </choose>
+
+        </where>
         ORDER BY
             DATE(rdr.create_time) DESC,
             COALESCE(pd.sort, 999999) ASC,