Commit 285d3e4efaa0b45b80d475f20ebbe4bf76c9939e
1 parent
e8e13752
fix(homepage): 修复任务查询逻辑并增加调试日志
- 注释掉检查用户提交记录的NOT EXISTS子查询以解决查询性能问题 - 在任务查询方法中添加详细的请求参数和结果日志记录 - 新增logTaskList工具方法用于输出任务列表详情便于调试 - 优化维护计划明细查询的时间范围筛选条件 - 引入ArrayUtils工具类处理时间数组参数
Showing
3 changed files
with
48 additions
and
5 deletions
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/dal/mysql/maintainplan/MaintainPlanDetailMapper.java
| @@ -3,6 +3,7 @@ package com.zteits.urbanops.module.garden.dal.mysql.maintainplan; | @@ -3,6 +3,7 @@ package com.zteits.urbanops.module.garden.dal.mysql.maintainplan; | ||
| 3 | 3 | ||
| 4 | import com.baomidou.mybatisplus.core.metadata.IPage; | 4 | import com.baomidou.mybatisplus.core.metadata.IPage; |
| 5 | import com.zteits.urbanops.framework.common.pojo.PageResult; | 5 | import com.zteits.urbanops.framework.common.pojo.PageResult; |
| 6 | +import com.zteits.urbanops.framework.common.util.collection.ArrayUtils; | ||
| 6 | import com.zteits.urbanops.framework.mybatis.core.mapper.BaseMapperX; | 7 | import com.zteits.urbanops.framework.mybatis.core.mapper.BaseMapperX; |
| 7 | import com.zteits.urbanops.framework.mybatis.core.query.LambdaQueryWrapperX; | 8 | import com.zteits.urbanops.framework.mybatis.core.query.LambdaQueryWrapperX; |
| 8 | import com.zteits.urbanops.module.garden.controller.admin.maintainplan.vo.MaintainPlanDetailPageReqVO; | 9 | import com.zteits.urbanops.module.garden.controller.admin.maintainplan.vo.MaintainPlanDetailPageReqVO; |
| @@ -33,8 +34,8 @@ public interface MaintainPlanDetailMapper extends BaseMapperX<MaintainPlanDetail | @@ -33,8 +34,8 @@ public interface MaintainPlanDetailMapper extends BaseMapperX<MaintainPlanDetail | ||
| 33 | .eqIfPresent(MaintainPlanDetailDO::getDeptId, reqVO.getDeptId()) | 34 | .eqIfPresent(MaintainPlanDetailDO::getDeptId, reqVO.getDeptId()) |
| 34 | .eqIfPresent(MaintainPlanDetailDO::getRoadId, reqVO.getRoadId()) | 35 | .eqIfPresent(MaintainPlanDetailDO::getRoadId, reqVO.getRoadId()) |
| 35 | .eqIfPresent(MaintainPlanDetailDO::getSortNum, reqVO.getSortNum()) | 36 | .eqIfPresent(MaintainPlanDetailDO::getSortNum, reqVO.getSortNum()) |
| 36 | - .betweenIfPresent(MaintainPlanDetailDO::getBeginTime, reqVO.getBeginTime()) | ||
| 37 | - .betweenIfPresent(MaintainPlanDetailDO::getEndTime, reqVO.getEndTime()) | 37 | + .geIfPresent(MaintainPlanDetailDO::getBeginTime, ArrayUtils.get(reqVO.getBeginTime(), 0)) |
| 38 | + .leIfPresent(MaintainPlanDetailDO::getEndTime, ArrayUtils.get(reqVO.getEndTime(), 0)) | ||
| 38 | .eqIfPresent(MaintainPlanDetailDO::getPlanFinishNum, reqVO.getPlanFinishNum()) | 39 | .eqIfPresent(MaintainPlanDetailDO::getPlanFinishNum, reqVO.getPlanFinishNum()) |
| 39 | .eqIfPresent(MaintainPlanDetailDO::getFinishState, reqVO.getFinishState()) | 40 | .eqIfPresent(MaintainPlanDetailDO::getFinishState, reqVO.getFinishState()) |
| 40 | .likeIfPresent(MaintainPlanDetailDO::getCreatorName, reqVO.getCreatorName()) | 41 | .likeIfPresent(MaintainPlanDetailDO::getCreatorName, reqVO.getCreatorName()) |
| @@ -60,4 +61,4 @@ public interface MaintainPlanDetailMapper extends BaseMapperX<MaintainPlanDetail | @@ -60,4 +61,4 @@ public interface MaintainPlanDetailMapper extends BaseMapperX<MaintainPlanDetail | ||
| 60 | */ | 61 | */ |
| 61 | List<AppMaintainNotFinishPlanDetailRespVO> getMaintainNotFinishPlanCommitDetail(@Param("req") AppMaintainNotFinishPlanDetailReqVO reqVO); | 62 | List<AppMaintainNotFinishPlanDetailRespVO> getMaintainNotFinishPlanCommitDetail(@Param("req") AppMaintainNotFinishPlanDetailReqVO reqVO); |
| 62 | 63 | ||
| 63 | -} | ||
| 64 | \ No newline at end of file | 64 | \ No newline at end of file |
| 65 | +} |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/service/homepage/HomepageSummaryServiceImpl.java
| @@ -429,6 +429,8 @@ public class HomepageSummaryServiceImpl implements HomepageSummaryService{ | @@ -429,6 +429,8 @@ public class HomepageSummaryServiceImpl implements HomepageSummaryService{ | ||
| 429 | 429 | ||
| 430 | @Override | 430 | @Override |
| 431 | public TaskDistanceSortResultVO queryTaskDetailsWithDistance(AppTaskDistanceSortReqVO req) { | 431 | public TaskDistanceSortResultVO queryTaskDetailsWithDistance(AppTaskDistanceSortReqVO req) { |
| 432 | + Log.info("queryTaskDetailsWithDistance: " + JSON.toJSONString(req)); | ||
| 433 | + | ||
| 432 | // 1. 获取当前登录用户信息 | 434 | // 1. 获取当前登录用户信息 |
| 433 | Long userId = SecurityFrameworkUtils.getLoginUserId(); | 435 | Long userId = SecurityFrameworkUtils.getLoginUserId(); |
| 434 | Long deptId = SecurityFrameworkUtils.getDeptId(); | 436 | Long deptId = SecurityFrameworkUtils.getDeptId(); |
| @@ -506,6 +508,7 @@ public class HomepageSummaryServiceImpl implements HomepageSummaryService{ | @@ -506,6 +508,7 @@ public class HomepageSummaryServiceImpl implements HomepageSummaryService{ | ||
| 506 | result.add(sortVo); | 508 | result.add(sortVo); |
| 507 | } | 509 | } |
| 508 | } | 510 | } |
| 511 | + logTaskList("已办SQL原始记录", result); | ||
| 509 | Log.info("返回App参数: " + JSON.toJSONString(result)); | 512 | Log.info("返回App参数: " + JSON.toJSONString(result)); |
| 510 | return result; | 513 | return result; |
| 511 | } | 514 | } |
| @@ -540,6 +543,7 @@ public class HomepageSummaryServiceImpl implements HomepageSummaryService{ | @@ -540,6 +543,7 @@ public class HomepageSummaryServiceImpl implements HomepageSummaryService{ | ||
| 540 | LocalDateTime now = LocalDateTime.now(); | 543 | LocalDateTime now = LocalDateTime.now(); |
| 541 | List<TaskDistanceSortRespVO> allTasks = homepageSummaryMapper | 544 | List<TaskDistanceSortRespVO> allTasks = homepageSummaryMapper |
| 542 | .queryPendingTaskDetailsWithGps(roleIds, userId, deptId, now); | 545 | .queryPendingTaskDetailsWithGps(roleIds, userId, deptId, now); |
| 546 | + logTaskList("待办SQL原始记录(距离排序)", allTasks); | ||
| 543 | 547 | ||
| 544 | // 分离有 GPS 和无 GPS 任务 | 548 | // 分离有 GPS 和无 GPS 任务 |
| 545 | List<TaskDistanceSortRespVO> tasksWithGps = new ArrayList<>(); | 549 | List<TaskDistanceSortRespVO> tasksWithGps = new ArrayList<>(); |
| @@ -660,6 +664,7 @@ public class HomepageSummaryServiceImpl implements HomepageSummaryService{ | @@ -660,6 +664,7 @@ public class HomepageSummaryServiceImpl implements HomepageSummaryService{ | ||
| 660 | 664 | ||
| 661 | @Override | 665 | @Override |
| 662 | public TaskDistanceSortResultVO queryTaskDetailsWithSmartSort(AppTaskSmartSortReqVO req) { | 666 | public TaskDistanceSortResultVO queryTaskDetailsWithSmartSort(AppTaskSmartSortReqVO req) { |
| 667 | + Log.info("queryTaskDetailsWithSmartSort: " + JSON.toJSONString(req)); | ||
| 663 | Long userId = SecurityFrameworkUtils.getLoginUserId(); | 668 | Long userId = SecurityFrameworkUtils.getLoginUserId(); |
| 664 | Long deptId = SecurityFrameworkUtils.getDeptId(); | 669 | Long deptId = SecurityFrameworkUtils.getDeptId(); |
| 665 | 670 | ||
| @@ -706,13 +711,23 @@ public class HomepageSummaryServiceImpl implements HomepageSummaryService{ | @@ -706,13 +711,23 @@ public class HomepageSummaryServiceImpl implements HomepageSummaryService{ | ||
| 706 | } catch (Exception e) { | 711 | } catch (Exception e) { |
| 707 | Log.warn("读取智能排序配置失败", e); | 712 | Log.warn("读取智能排序配置失败", e); |
| 708 | } | 713 | } |
| 714 | + Log.info("智能排序配置: distWeight=" + distWeight + ", effWeight=" + effWeight | ||
| 715 | + + ", threshold=" + threshold + ", clamp=[" + clampMin + "," + clampMax + "]"); | ||
| 709 | 716 | ||
| 710 | // 2. 查询今日待办任务 | 717 | // 2. 查询今日待办任务 |
| 711 | List<TaskDistanceSortRespVO> allTasks = homepageSummaryMapper | 718 | List<TaskDistanceSortRespVO> allTasks = homepageSummaryMapper |
| 712 | .queryPendingTaskDetailsWithGps(roleIds, userId, deptId, LocalDateTime.now()); | 719 | .queryPendingTaskDetailsWithGps(roleIds, userId, deptId, LocalDateTime.now()); |
| 720 | + Log.info("待办任务总数: " + (allTasks != null ? allTasks.size() : 0) + ", userId=" + userId + ", deptId=" + deptId); | ||
| 721 | + logTaskList("待办SQL原始记录(智能排序)", allTasks); | ||
| 713 | 722 | ||
| 714 | // 3. 查询效率矩阵 | 723 | // 3. 查询效率矩阵 |
| 715 | Map<String, UserTaskEfficiencyDO> effMap = loadEfficiencyMap(userId); | 724 | Map<String, UserTaskEfficiencyDO> effMap = loadEfficiencyMap(userId); |
| 725 | + Log.info("效率矩阵条目数: " + effMap.size()); | ||
| 726 | + if (!effMap.isEmpty()) { | ||
| 727 | + effMap.forEach((k, v) -> Log.info(" eff: key=" + k + ", ratio=" + v.getEfficiencyRatio() | ||
| 728 | + + ", userAvg=" + v.getAvgMinutes() + ", teamAvg=" + v.getTeamAvgMinutes() | ||
| 729 | + + ", cnt=" + v.getCompletedCount())); | ||
| 730 | + } | ||
| 716 | 731 | ||
| 717 | // 4. 为每个任务打分 | 732 | // 4. 为每个任务打分 |
| 718 | List<TaskDistanceSortRespVO> tasksWithGps = new ArrayList<>(); | 733 | List<TaskDistanceSortRespVO> tasksWithGps = new ArrayList<>(); |
| @@ -737,10 +752,20 @@ public class HomepageSummaryServiceImpl implements HomepageSummaryService{ | @@ -737,10 +752,20 @@ public class HomepageSummaryServiceImpl implements HomepageSummaryService{ | ||
| 737 | double distScore = Math.max(0, 1 - dist / threshold); | 752 | double distScore = Math.max(0, 1 - dist / threshold); |
| 738 | task.setDistanceScore(Math.round(distScore * 100.0) / 100.0); | 753 | task.setDistanceScore(Math.round(distScore * 100.0) / 100.0); |
| 739 | task.setCompositeScore(Math.round((distWeight * distScore + effWeight * effScore) * 100.0) / 100.0); | 754 | task.setCompositeScore(Math.round((distWeight * distScore + effWeight * effScore) * 100.0) / 100.0); |
| 755 | + Log.info(" score: " + task.getTaskName() + " | dist=" + (int)dist + "m" | ||
| 756 | + + " | distScore=" + task.getDistanceScore() | ||
| 757 | + + " | effScore=" + task.getEfficiencyScore() | ||
| 758 | + + " | eff%=" + task.getEfficiencyPercent() | ||
| 759 | + + " | composite=" + task.getCompositeScore() | ||
| 760 | + + " | type=" + task.getTaskType() + "/" + task.getTaskSubType()); | ||
| 740 | tasksWithGps.add(task); | 761 | tasksWithGps.add(task); |
| 741 | } else { | 762 | } else { |
| 742 | task.setDistanceScore(0.0); | 763 | task.setDistanceScore(0.0); |
| 743 | task.setCompositeScore(Math.round((effWeight * effScore) * 100.0) / 100.0); | 764 | task.setCompositeScore(Math.round((effWeight * effScore) * 100.0) / 100.0); |
| 765 | + Log.info(" score(无GPS): " + task.getTaskName() | ||
| 766 | + + " | effScore=" + task.getEfficiencyScore() | ||
| 767 | + + " | eff%=" + task.getEfficiencyPercent() | ||
| 768 | + + " | type=" + task.getTaskType() + "/" + task.getTaskSubType()); | ||
| 744 | tasksWithoutGps.add(task); | 769 | tasksWithoutGps.add(task); |
| 745 | } | 770 | } |
| 746 | } | 771 | } |
| @@ -833,4 +858,21 @@ public class HomepageSummaryServiceImpl implements HomepageSummaryService{ | @@ -833,4 +858,21 @@ public class HomepageSummaryServiceImpl implements HomepageSummaryService{ | ||
| 833 | if (val < min) return min; | 858 | if (val < min) return min; |
| 834 | return val; | 859 | return val; |
| 835 | } | 860 | } |
| 861 | + | ||
| 862 | + private void logTaskList(String tag, List<TaskDistanceSortRespVO> list) { | ||
| 863 | + if (list == null) { | ||
| 864 | + Log.info(tag + ": null"); | ||
| 865 | + return; | ||
| 866 | + } | ||
| 867 | + Log.info(tag + ": 共" + list.size() + "条"); | ||
| 868 | + for (int i = 0; i < list.size(); i++) { | ||
| 869 | + TaskDistanceSortRespVO t = list.get(i); | ||
| 870 | + Log.info(tag + "[" + i + "] taskName=" + t.getTaskName() | ||
| 871 | + + ", taskType=" + t.getTaskType() | ||
| 872 | + + ", planNo=" + t.getPlanNo() | ||
| 873 | + + ", batchNo=" + t.getBatchNo() | ||
| 874 | + + ", distance=" + t.getDistance() | ||
| 875 | + + ", lat=" + t.getTaskLat() + ", lon=" + t.getTaskLon()); | ||
| 876 | + } | ||
| 877 | + } | ||
| 836 | } | 878 | } |
urbanops-module-garden/src/main/resources/mapper/homepage/HomepageSummaryMapper.xml
| @@ -647,7 +647,7 @@ | @@ -647,7 +647,7 @@ | ||
| 647 | <foreach collection='roleIds' item='roleId' open='(' close=')' separator=','> | 647 | <foreach collection='roleIds' item='roleId' open='(' close=')' separator=','> |
| 648 | #{roleId} | 648 | #{roleId} |
| 649 | </foreach> | 649 | </foreach> |
| 650 | - AND NOT EXISTS (SELECT 1 FROM garden_inspection_plan_commit ic WHERE ic.batch_no = a.batch_no AND ic.user_id = #{userId}) | 650 | +<!-- AND NOT EXISTS (SELECT 1 FROM garden_inspection_plan_commit ic WHERE ic.batch_no = a.batch_no AND ic.user_id = #{userId})--> |
| 651 | AND r.starting_latitude IS NOT NULL AND r.starting_latitude != '' | 651 | AND r.starting_latitude IS NOT NULL AND r.starting_latitude != '' |
| 652 | 652 | ||
| 653 | UNION ALL | 653 | UNION ALL |
| @@ -677,7 +677,7 @@ | @@ -677,7 +677,7 @@ | ||
| 677 | <foreach collection='roleIds' item='roleId' open='(' close=')' separator=','> | 677 | <foreach collection='roleIds' item='roleId' open='(' close=')' separator=','> |
| 678 | #{roleId} | 678 | #{roleId} |
| 679 | </foreach> | 679 | </foreach> |
| 680 | - AND NOT EXISTS (SELECT 1 FROM garden_maintain_plan_commit mc WHERE mc.batch_no = a.batch_no AND mc.user_id = #{userId}) | 680 | +<!-- AND NOT EXISTS (SELECT 1 FROM garden_maintain_plan_commit mc WHERE mc.batch_no = a.batch_no AND mc.user_id = #{userId})--> |
| 681 | AND r.starting_latitude IS NOT NULL AND r.starting_latitude != '' | 681 | AND r.starting_latitude IS NOT NULL AND r.starting_latitude != '' |
| 682 | ) t | 682 | ) t |
| 683 | </select> | 683 | </select> |