Просмотр исходного кода

feat(inspection): 巡检任务筛选支持 storeId/recordStatus/checkResult + 6 个字典

yangjingjing 2 дней назад
Родитель
Сommit
5bf3ed909c

+ 10 - 0
ruoyi-modules/ruoyi-risk/src/main/java/org/dromara/risk/domain/bo/RiskInspectionTaskBo.java

@@ -197,4 +197,14 @@ public class RiskInspectionTaskBo extends BaseEntity {
      */
     private String keyword;
 
+    /**
+     * 打卡状态(已打卡/未打卡),用于 PC 端列表过滤
+     */
+    private String recordStatus;
+
+    /**
+     * 打卡结果(正常/异常),用于 PC 端列表过滤
+     */
+    private String checkResult;
+
 }

+ 18 - 0
ruoyi-modules/ruoyi-risk/src/main/java/org/dromara/risk/service/impl/RiskInspectionTaskServiceImpl.java

@@ -130,6 +130,8 @@ public class RiskInspectionTaskServiceImpl implements IRiskInspectionTaskService
         lqw.eq(StringUtils.isNotBlank(bo.getTaskStatus()), RiskInspectionTask::getTaskStatus, bo.getTaskStatus());
         lqw.like(StringUtils.isNotBlank(bo.getTaskName()), RiskInspectionTask::getTaskName, bo.getTaskName());
         lqw.like(StringUtils.isNotBlank(bo.getInspectorName()), RiskInspectionTask::getInspectorName, bo.getInspectorName());
+        // 门店下拉过滤(精确匹配 storeId)
+        lqw.eq(bo.getStoreId() != null, RiskInspectionTask::getStoreId, bo.getStoreId());
         // 关键词搜索
         if (StringUtils.isNotBlank(bo.getKeyword())) {
             lqw.and(w -> w.like(RiskInspectionTask::getTaskName, bo.getKeyword())
@@ -139,6 +141,22 @@ public class RiskInspectionTaskServiceImpl implements IRiskInspectionTaskService
         }
         lqw.between(params.get("beginPlanStartTime") != null && params.get("endPlanStartTime") != null,
             RiskInspectionTask::getPlanStartTime, params.get("beginPlanStartTime"), params.get("endPlanStartTime"));
+        // 打卡状态(已打卡/未打卡) - 走子查询匹配 record 表
+        if ("已打卡".equals(bo.getRecordStatus())) {
+            lqw.inSql(RiskInspectionTask::getId,
+                "SELECT task_id FROM risk_inspection_record WHERE del_flag = '0'");
+        } else if ("未打卡".equals(bo.getRecordStatus())) {
+            lqw.notInSql(RiskInspectionTask::getId,
+                "SELECT task_id FROM risk_inspection_record WHERE del_flag = '0'");
+        }
+        // 打卡结果(正常/异常) - record.result '1'=正常 '0'=异常
+        if ("正常".equals(bo.getCheckResult())) {
+            lqw.inSql(RiskInspectionTask::getId,
+                "SELECT task_id FROM risk_inspection_record WHERE del_flag = '0' AND result = '1'");
+        } else if ("异常".equals(bo.getCheckResult())) {
+            lqw.inSql(RiskInspectionTask::getId,
+                "SELECT task_id FROM risk_inspection_record WHERE del_flag = '0' AND result = '0'");
+        }
         // 默认排序
         lqw.orderByDesc(RiskInspectionTask::getPlanStartTime);
         return lqw;

+ 50 - 0
sql/risk_inspection_dicts.sql

@@ -0,0 +1,50 @@
+-- ============================================================
+-- 巡检相关字典(按 UI 设计稿)
+-- value 一律中文
+-- ============================================================
+
+-- 1) 巡检类型
+INSERT INTO sys_dict_type(dict_id, tenant_id, dict_name, dict_type, create_dept, create_by, create_time, remark) VALUES
+  (12225, '000000', '巡检类型', 'risk_inspection_type', 103, 1, NOW(), '巡检管理-巡检类型下拉');
+INSERT INTO sys_dict_data(dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, create_dept, create_by, create_time, remark) VALUES
+  (1, '园区巡检打卡',     '园区巡检打卡',     'risk_inspection_type', NULL, 'primary', 'N', 103, 1, NOW(), NULL),
+  (2, '门店闭店检查',     '门店闭店检查',     'risk_inspection_type', NULL, 'success', 'N', 103, 1, NOW(), NULL),
+  (3, '打样设施设备检查', '打样设施设备检查', 'risk_inspection_type', NULL, 'warning', 'N', 103, 1, NOW(), NULL);
+
+-- 2) 打卡状态(任务级 - 已/未打卡)
+INSERT INTO sys_dict_type(dict_id, tenant_id, dict_name, dict_type, create_dept, create_by, create_time, remark) VALUES
+  (12226, '000000', '打卡状态', 'risk_inspection_status', 103, 1, NOW(), '巡检管理-打卡状态下拉(已/未打卡)');
+INSERT INTO sys_dict_data(dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, create_dept, create_by, create_time, remark) VALUES
+  (1, '已打卡', '已打卡', 'risk_inspection_status', NULL, 'success', 'N', 103, 1, NOW(), '已有打卡记录'),
+  (2, '未打卡', '未打卡', 'risk_inspection_status', NULL, 'info',    'N', 103, 1, NOW(), '尚无打卡记录');
+
+-- 3) 打卡结果(任务级 - 正常/异常)
+INSERT INTO sys_dict_type(dict_id, tenant_id, dict_name, dict_type, create_dept, create_by, create_time, remark) VALUES
+  (12227, '000000', '打卡结果', 'risk_inspection_result', 103, 1, NOW(), '巡检管理-打卡结果下拉(正常/异常)');
+INSERT INTO sys_dict_data(dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, create_dept, create_by, create_time, remark) VALUES
+  (1, '正常', '正常', 'risk_inspection_result', NULL, 'success', 'N', 103, 1, NOW(), 'record.result = 1'),
+  (2, '异常', '异常', 'risk_inspection_result', NULL, 'danger',  'N', 103, 1, NOW(), 'record.result = 0');
+
+-- 4) 巡检方式(任务级 - 常规/扫码)
+INSERT INTO sys_dict_type(dict_id, tenant_id, dict_name, dict_type, create_dept, create_by, create_time, remark) VALUES
+  (12228, '000000', '巡检方式', 'risk_inspection_method', 103, 1, NOW(), '巡检任务-打卡方式');
+INSERT INTO sys_dict_data(dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, create_dept, create_by, create_time, remark) VALUES
+  (1, '常规', '常规', 'risk_inspection_method', NULL, 'info',    'N', 103, 1, NOW(), NULL),
+  (2, '扫码', '扫码', 'risk_inspection_method', NULL, 'primary', 'N', 103, 1, NOW(), NULL);
+
+-- 5) 巡检周期
+INSERT INTO sys_dict_type(dict_id, tenant_id, dict_name, dict_type, create_dept, create_by, create_time, remark) VALUES
+  (12229, '000000', '巡检周期', 'risk_inspection_cycle', 103, 1, NOW(), '巡检任务-巡检周期');
+INSERT INTO sys_dict_data(dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, create_dept, create_by, create_time, remark) VALUES
+  (1, '每日', '每日', 'risk_inspection_cycle', NULL, 'primary', 'N', 103, 1, NOW(), NULL),
+  (2, '每周', '每周', 'risk_inspection_cycle', NULL, 'success', 'N', 103, 1, NOW(), NULL),
+  (3, '每月', '每月', 'risk_inspection_cycle', NULL, 'warning', 'N', 103, 1, NOW(), NULL);
+
+-- 6) 巡检项类型
+INSERT INTO sys_dict_type(dict_id, tenant_id, dict_name, dict_type, create_dept, create_by, create_time, remark) VALUES
+  (12230, '000000', '巡检项类型', 'risk_inspection_item_type', 103, 1, NOW(), '巡检任务项-类型');
+INSERT INTO sys_dict_data(dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, create_dept, create_by, create_time, remark) VALUES
+  (1, '安全', '安全', 'risk_inspection_item_type', NULL, 'danger',  'N', 103, 1, NOW(), NULL),
+  (2, '卫生', '卫生', 'risk_inspection_item_type', NULL, 'info',    'N', 103, 1, NOW(), NULL),
+  (3, '设备', '设备', 'risk_inspection_item_type', NULL, 'primary', 'N', 103, 1, NOW(), NULL),
+  (4, '其他', '其他', 'risk_inspection_item_type', NULL, 'default', 'N', 103, 1, NOW(), NULL);