feat(workorder): 添加线索事件分页列表功能并优化状态流转
- 修改EventStatusEnum中状态3的流转规则,从[2,4]改为[1,4]
- 在GdClueEventController中添加分页列表接口,支持按状态、时间范围筛选
- 扩展GdClueEventListVO添加拍摄时间、处置人姓名、处置部门名称字段
- 更新GdClueEventMapper添加分页查询方法和参数注释优化
- 完善GdClueEventMapper.xml查询逻辑,添加多条件筛选和关联查询
- 重构GdClueEventServiceImpl实现分页查询,区分管理员和普通用户权限
- 调整统计数据查询逻辑,根据用户角色过滤不同状态的数据
| | |
| | | } |
| | | |
| | | /** |
| | | * 事件表(线索事件) 列表 |
| | | * 事件表(线索事件) 列表(分页) |
| | | */ |
| | | @GetMapping("/list") |
| | | @ApiOperationSupport(order = 2) |
| | | @ApiOperation(value = "列表", notes = "固定过滤本部门,onlyMine=1时仅我的数据") |
| | | public R<List<GdClueEventListVO>> list(@ApiParam(value = "是否仅我的数据,1为是,0为否") |
| | | @ApiOperation(value = "列表(分页)", notes = "固定过滤本部门,onlyMine=1时仅我的数据") |
| | | public R<IPage<GdClueEventListVO>> list(@ApiParam(value = "是否仅我的数据,1为是,0为否") |
| | | @RequestParam(value = "onlyMine", required = false, defaultValue = "0") Integer onlyMine, |
| | | @ApiParam(value = "事件编号关键字") |
| | | @RequestParam(value = "keyword", required = false) String keyword) { |
| | | List<GdClueEventListVO> list = gdClueEventService.listGdClueEventByDept(onlyMine, keyword); |
| | | return R.data(list); |
| | | @RequestParam(value = "keyword", required = false) String keyword, |
| | | @ApiParam(value = "事件状态:0待确认、1处置中、2已退回、3已处置、4已完成") |
| | | @RequestParam(value = "eventStatus", required = false) Integer eventStatus, |
| | | @ApiParam(value = "开始时间(创建时间)") |
| | | @RequestParam(value = "startTime", required = false) String startTime, |
| | | @ApiParam(value = "结束时间(创建时间)") |
| | | @RequestParam(value = "endTime", required = false) String endTime, |
| | | @ApiParam(value = "分页参数") Query query) { |
| | | // 1. 构建分页对象 |
| | | IPage<GdClueEventListVO> pages = Condition.getPage(query); |
| | | |
| | | // 2. 查询分页数据 |
| | | IPage<GdClueEventListVO> result = gdClueEventService.pageGdClueEventByDept( |
| | | pages, onlyMine, keyword, eventStatus, startTime, endTime); |
| | | |
| | | // 3. 返回分页结果 |
| | | return R.data(result); |
| | | } |
| | | |
| | | /** |
| | |
| | | // 2-已退回 -> 0-待确认, 1-处置中 |
| | | STATUS_FLOW_MATRIX.put(2, Arrays.asList(0, 1)); |
| | | // 3-已处置 -> 2-已退回, 4-已完成 |
| | | STATUS_FLOW_MATRIX.put(3, Arrays.asList(2, 4)); |
| | | STATUS_FLOW_MATRIX.put(3, Arrays.asList(1, 4)); |
| | | // 4-已完成 -> 终态,不允许流转 |
| | | STATUS_FLOW_MATRIX.put(4, Arrays.asList()); |
| | | } |
| | |
| | | public static boolean isValidCode(Integer code) { |
| | | return getByCode(code) != null; |
| | | } |
| | | } |
| | | } |
| | |
| | | /** |
| | | * 列表查询(不分页) |
| | | * |
| | | * @param deptId |
| | | * @param userId |
| | | * @param onlyMine |
| | | * @return |
| | | * @param deptId 部门ID |
| | | * @param userId 用户ID |
| | | * @param onlyMine 是否只查询我的工单 |
| | | * @param keyword 事件编号关键字 |
| | | * @param statusList 允许查询的状态列表 |
| | | * @return 事件列表 |
| | | */ |
| | | List<GdClueEventListVO> selectGdClueEventSimpleList(@Param("deptId") Long deptId, @Param("userId") Long userId, |
| | | @Param("onlyMine") Integer onlyMine, @Param("keyword") String keyword); |
| | | @Param("onlyMine") Integer onlyMine, @Param("keyword") String keyword, @Param("statusList") List<Integer> statusList); |
| | | |
| | | /** |
| | | * 列表查询(分页) |
| | | * |
| | | * @param page 分页对象 |
| | | * @param deptId 部门ID |
| | | * @param userId 用户ID |
| | | * @param onlyMine 是否只查询我的工单 |
| | | * @param keyword 事件编号关键字 |
| | | * @param statusList 允许查询的状态列表 |
| | | * @param startTime 开始时间 |
| | | * @param endTime 结束时间 |
| | | * @return 事件列表 |
| | | */ |
| | | List<GdClueEventListVO> selectGdClueEventSimpleList(IPage<GdClueEventListVO> page, @Param("deptId") Long deptId, |
| | | @Param("userId") Long userId, @Param("onlyMine") Integer onlyMine, @Param("keyword") String keyword, |
| | | @Param("statusList") List<Integer> statusList, @Param("startTime") String startTime, |
| | | @Param("endTime") String endTime); |
| | | |
| | | /** |
| | | * 详情查询 |
| | |
| | | /** |
| | | * 数量统计 |
| | | * |
| | | * @param deptId |
| | | * @param userId |
| | | * @return |
| | | * @param deptId 部门ID |
| | | * @param userId 用户ID |
| | | * @param keyword 事件编号关键字 |
| | | * @param statusList 允许查询的状态列表 |
| | | * @return 统计数据 |
| | | */ |
| | | GdClueEventCountVO selectGdClueEventCount(@Param("deptId") Long deptId, @Param("userId") Long userId, |
| | | @Param("keyword") String keyword); |
| | | @Param("keyword") String keyword, @Param("statusList") List<Integer> statusList); |
| | | |
| | | |
| | | /** |
| | |
| | | <result column="geojson" property="geojson"/> |
| | | <result column="attachment_type" property="attachmentType"/> |
| | | <result column="event_name" property="eventName"/> |
| | | <result column="shoot_time" property="shootTime"/> |
| | | <result column="dispose_user_name" property="disposeUserName"/> |
| | | <result column="dispose_dept_name" property="disposeDeptName"/> |
| | | </resultMap> |
| | | |
| | | <resultMap id="gdClueEventCountVoResultMap" type="org.sxkj.gd.workorder.vo.GdClueEventCountVO"> |
| | |
| | | COALESCE(tr.result_url, ce.attach_url) as event_image_url, |
| | | COALESCE(tr.geojson, ce.geojson) as geojson, |
| | | COALESCE(tr.attachment_type, ce.attachment_type) as attachment_type, |
| | | ce.create_time as create_time |
| | | ce.create_time as create_time, |
| | | tr.shoot_time as shoot_time, |
| | | COALESCE(bu.real_name, bu.name) as dispose_user_name, |
| | | bd.dept_name as dispose_dept_name |
| | | from ja_gd_clue_event ce |
| | | left join ja_gd_task_result tr on tr.id::VARCHAR = ce.result_id::VARCHAR and tr.is_deleted = 0 |
| | | left join blade_user bu on bu.id::VARCHAR = ce.dispose_user::VARCHAR and bu.is_deleted = 0 |
| | | left join blade_dept bd on bd.id::VARCHAR = ce.dispose_dept::VARCHAR and bd.is_deleted = 0 |
| | | <include refid="gdClueEventDeptWhere"/> |
| | | and ce.event_status in (1, 3) |
| | | <if test="statusList != null and statusList.size() > 0"> |
| | | and ce.event_status in |
| | | <foreach collection="statusList" item="status" open="(" separator="," close=")"> |
| | | #{status} |
| | | </foreach> |
| | | </if> |
| | | <if test="keyword != null and keyword != ''"> |
| | | and ce.event_num::VARCHAR like concat('%', #{keyword}, '%') |
| | | </if> |
| | | <if test="onlyMine != null and onlyMine == 1"> |
| | | and ce.dispose_user = #{userId} |
| | | </if> |
| | | <if test="startTime != null and startTime != ''"> |
| | | and tr.shoot_time >= #{startTime} |
| | | </if> |
| | | <if test="endTime != null and endTime != ''"> |
| | | and tr.shoot_time <= #{endTime} |
| | | </if> |
| | | order by ce.create_time desc |
| | | </select> |
| | |
| | | COALESCE(sum(case when ce.event_status = 4 then 1 else 0 end), 0) as completed_count |
| | | from ja_gd_clue_event ce |
| | | <include refid="gdClueEventDeptWhere"/> |
| | | and ce.event_status in (0, 1, 2, 3, 4) |
| | | <if test="statusList != null and statusList.size() > 0"> |
| | | and ce.event_status in |
| | | <foreach collection="statusList" item="status" open="(" separator="," close=")"> |
| | | #{status} |
| | | </foreach> |
| | | </if> |
| | | <if test="keyword != null and keyword != ''"> |
| | | and ce.event_num like concat('%', #{keyword}, '%') |
| | | </if> |
| | |
| | | List<GdClueEventListVO> listGdClueEventByDept(Integer onlyMine, String keyword); |
| | | |
| | | /** |
| | | * 列表查询(分页) |
| | | * |
| | | * @param page 分页对象 |
| | | * @param onlyMine 是否仅我的数据 |
| | | * @param keyword 事件编号关键字 |
| | | * @param eventStatus 事件状态 |
| | | * @param startTime 开始时间 |
| | | * @param endTime 结束时间 |
| | | * @return 分页数据 |
| | | */ |
| | | IPage<GdClueEventListVO> pageGdClueEventByDept(IPage<GdClueEventListVO> page, Integer onlyMine, String keyword, |
| | | Integer eventStatus, String startTime, String endTime); |
| | | |
| | | /** |
| | | * 详情查询 |
| | | * |
| | | * @param id |
| | |
| | | |
| | | @Override |
| | | public List<GdClueEventListVO> listGdClueEventByDept(Integer onlyMine, String keyword) { |
| | | Long deptId = Long.valueOf(AuthUtil.getDeptId()); |
| | | Long userId = AuthUtil.getUserId(); |
| | | Integer mine = onlyMine == null ? 0 : onlyMine; |
| | | return baseMapper.selectGdClueEventSimpleList(deptId, userId, mine, keyword); |
| | | // 1. 获取当前用户部门ID和用户ID |
| | | Long deptId = null; |
| | | Long userId = null; |
| | | Integer mine = 0; |
| | | List<Integer> statusList; |
| | | |
| | | // 2. 判断是否为管理员 |
| | | boolean isAdmin = AuthUtil.isAdministrator() || AuthUtil.isAdmin(); |
| | | |
| | | if (!isAdmin) { |
| | | // 非管理员:获取部门ID和用户ID |
| | | deptId = Long.valueOf(AuthUtil.getDeptId()); |
| | | userId = AuthUtil.getUserId(); |
| | | mine = onlyMine == null ? 0 : onlyMine; |
| | | // 非管理员:排除已退回状态(状态2) |
| | | statusList = java.util.Arrays.asList(0, 1, 3, 4); |
| | | } else { |
| | | // 管理员:可以查询所有状态 |
| | | statusList = java.util.Arrays.asList(0, 1, 2, 3, 4); |
| | | } |
| | | |
| | | // 3. 查询事件列表 |
| | | return baseMapper.selectGdClueEventSimpleList(deptId, userId, mine, keyword, statusList); |
| | | } |
| | | |
| | | /** |
| | | * 列表查询(分页) |
| | | * <p> |
| | | * 步骤: |
| | | * 1. 获取当前用户部门ID和用户ID |
| | | * 2. 判断是否为管理员,设置状态列表 |
| | | * 3. 根据事件状态参数调整状态列表 |
| | | * 4. 查询分页数据 |
| | | * </p> |
| | | * |
| | | * @param page 分页对象 |
| | | * @param onlyMine 是否仅我的数据 |
| | | * @param keyword 事件编号关键字 |
| | | * @param eventStatus 事件状态 |
| | | * @param startTime 开始时间 |
| | | * @param endTime 结束时间 |
| | | * @return 分页数据 |
| | | */ |
| | | @Override |
| | | public IPage<GdClueEventListVO> pageGdClueEventByDept(IPage<GdClueEventListVO> page, Integer onlyMine, String keyword, |
| | | Integer eventStatus, String startTime, String endTime) { |
| | | // 1. 获取当前用户部门ID和用户ID |
| | | Long deptId = null; |
| | | Long userId = null; |
| | | Integer mine = 0; |
| | | List<Integer> statusList; |
| | | |
| | | // 2. 判断是否为管理员 |
| | | boolean isAdmin = AuthUtil.isAdministrator() || AuthUtil.isAdmin(); |
| | | |
| | | if (!isAdmin) { |
| | | // 非管理员:获取部门ID和用户ID |
| | | deptId = Long.valueOf(AuthUtil.getDeptId()); |
| | | userId = AuthUtil.getUserId(); |
| | | mine = onlyMine == null ? 0 : onlyMine; |
| | | // 非管理员:排除已退回状态(状态2) |
| | | statusList = java.util.Arrays.asList(0, 1, 3, 4); |
| | | } else { |
| | | // 管理员:可以查询所有状态 |
| | | statusList = java.util.Arrays.asList(0, 1, 2, 3, 4); |
| | | } |
| | | |
| | | // 3. 如果指定了事件状态,优先使用指定的状态 |
| | | if (eventStatus != null) { |
| | | // 检查指定的状态是否在允许的状态列表中 |
| | | if (statusList.contains(eventStatus)) { |
| | | statusList = java.util.Arrays.asList(eventStatus); |
| | | } else { |
| | | // 如果指定的状态不在允许列表中(如非管理员查询状态2),返回空结果 |
| | | statusList = java.util.Collections.emptyList(); |
| | | } |
| | | } |
| | | |
| | | // 4. 查询分页数据 |
| | | return page.setRecords(baseMapper.selectGdClueEventSimpleList(page, deptId, userId, mine, keyword, statusList, startTime, endTime)); |
| | | } |
| | | |
| | | @Override |
| | |
| | | // 1. 获取当前用户部门ID和用户ID |
| | | Long deptId = Long.valueOf(AuthUtil.getDeptId()); |
| | | Long userId = AuthUtil.getUserId(); |
| | | List<Integer> statusList; |
| | | |
| | | // 2. 查询统计数据 |
| | | GdClueEventCountVO countVO = baseMapper.selectGdClueEventCount(deptId, userId, keyword); |
| | | // 2. 判断是否为管理员 |
| | | boolean isAdmin = AuthUtil.isAdministrator() || AuthUtil.isAdmin(); |
| | | |
| | | // 3. 处理空结果,返回默认值 |
| | | if (isAdmin) { |
| | | // 管理员:可以查询所有状态 |
| | | statusList = java.util.Arrays.asList(0, 1, 2, 3, 4); |
| | | } else { |
| | | // 非管理员:排除已退回状态(状态2) |
| | | statusList = java.util.Arrays.asList(0, 1, 3, 4); |
| | | } |
| | | |
| | | // 3. 查询统计数据 |
| | | GdClueEventCountVO countVO = baseMapper.selectGdClueEventCount(deptId, userId, keyword, statusList); |
| | | |
| | | // 4. 处理空结果,返回默认值 |
| | | if (countVO == null) { |
| | | GdClueEventCountVO empty = new GdClueEventCountVO(); |
| | | empty.setTotalCount(0L); |
| | |
| | | return empty; |
| | | } |
| | | |
| | | // 4. 返回统计结果 |
| | | // 5. 返回统计结果 |
| | | return countVO; |
| | | } |
| | | |
| | |
| | | */ |
| | | @ApiModelProperty(value = "事件名称") |
| | | private String eventName; |
| | | |
| | | /** |
| | | * 拍照时间 |
| | | */ |
| | | @ApiModelProperty(value = "拍摄时间") |
| | | private Date shootTime; |
| | | |
| | | /** |
| | | * 处置人姓名 |
| | | */ |
| | | @ApiModelProperty(value = "处置人姓名") |
| | | private String disposeUserName; |
| | | |
| | | /** |
| | | * 处置部门名称 |
| | | */ |
| | | @ApiModelProperty(value = "处置部门名称") |
| | | private String disposeDeptName; |
| | | } |