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 | 3 | |
| 4 | 4 | import com.baomidou.mybatisplus.core.metadata.IPage; |
| 5 | 5 | import com.zteits.urbanops.framework.common.pojo.PageResult; |
| 6 | +import com.zteits.urbanops.framework.common.util.collection.ArrayUtils; | |
| 6 | 7 | import com.zteits.urbanops.framework.mybatis.core.mapper.BaseMapperX; |
| 7 | 8 | import com.zteits.urbanops.framework.mybatis.core.query.LambdaQueryWrapperX; |
| 8 | 9 | import com.zteits.urbanops.module.garden.controller.admin.maintainplan.vo.MaintainPlanDetailPageReqVO; |
| ... | ... | @@ -33,8 +34,8 @@ public interface MaintainPlanDetailMapper extends BaseMapperX<MaintainPlanDetail |
| 33 | 34 | .eqIfPresent(MaintainPlanDetailDO::getDeptId, reqVO.getDeptId()) |
| 34 | 35 | .eqIfPresent(MaintainPlanDetailDO::getRoadId, reqVO.getRoadId()) |
| 35 | 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 | 39 | .eqIfPresent(MaintainPlanDetailDO::getPlanFinishNum, reqVO.getPlanFinishNum()) |
| 39 | 40 | .eqIfPresent(MaintainPlanDetailDO::getFinishState, reqVO.getFinishState()) |
| 40 | 41 | .likeIfPresent(MaintainPlanDetailDO::getCreatorName, reqVO.getCreatorName()) |
| ... | ... | @@ -60,4 +61,4 @@ public interface MaintainPlanDetailMapper extends BaseMapperX<MaintainPlanDetail |
| 60 | 61 | */ |
| 61 | 62 | List<AppMaintainNotFinishPlanDetailRespVO> getMaintainNotFinishPlanCommitDetail(@Param("req") AppMaintainNotFinishPlanDetailReqVO reqVO); |
| 62 | 63 | |
| 63 | -} | |
| 64 | 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 | 429 | |
| 430 | 430 | @Override |
| 431 | 431 | public TaskDistanceSortResultVO queryTaskDetailsWithDistance(AppTaskDistanceSortReqVO req) { |
| 432 | + Log.info("queryTaskDetailsWithDistance: " + JSON.toJSONString(req)); | |
| 433 | + | |
| 432 | 434 | // 1. 获取当前登录用户信息 |
| 433 | 435 | Long userId = SecurityFrameworkUtils.getLoginUserId(); |
| 434 | 436 | Long deptId = SecurityFrameworkUtils.getDeptId(); |
| ... | ... | @@ -506,6 +508,7 @@ public class HomepageSummaryServiceImpl implements HomepageSummaryService{ |
| 506 | 508 | result.add(sortVo); |
| 507 | 509 | } |
| 508 | 510 | } |
| 511 | + logTaskList("已办SQL原始记录", result); | |
| 509 | 512 | Log.info("返回App参数: " + JSON.toJSONString(result)); |
| 510 | 513 | return result; |
| 511 | 514 | } |
| ... | ... | @@ -540,6 +543,7 @@ public class HomepageSummaryServiceImpl implements HomepageSummaryService{ |
| 540 | 543 | LocalDateTime now = LocalDateTime.now(); |
| 541 | 544 | List<TaskDistanceSortRespVO> allTasks = homepageSummaryMapper |
| 542 | 545 | .queryPendingTaskDetailsWithGps(roleIds, userId, deptId, now); |
| 546 | + logTaskList("待办SQL原始记录(距离排序)", allTasks); | |
| 543 | 547 | |
| 544 | 548 | // 分离有 GPS 和无 GPS 任务 |
| 545 | 549 | List<TaskDistanceSortRespVO> tasksWithGps = new ArrayList<>(); |
| ... | ... | @@ -660,6 +664,7 @@ public class HomepageSummaryServiceImpl implements HomepageSummaryService{ |
| 660 | 664 | |
| 661 | 665 | @Override |
| 662 | 666 | public TaskDistanceSortResultVO queryTaskDetailsWithSmartSort(AppTaskSmartSortReqVO req) { |
| 667 | + Log.info("queryTaskDetailsWithSmartSort: " + JSON.toJSONString(req)); | |
| 663 | 668 | Long userId = SecurityFrameworkUtils.getLoginUserId(); |
| 664 | 669 | Long deptId = SecurityFrameworkUtils.getDeptId(); |
| 665 | 670 | |
| ... | ... | @@ -706,13 +711,23 @@ public class HomepageSummaryServiceImpl implements HomepageSummaryService{ |
| 706 | 711 | } catch (Exception e) { |
| 707 | 712 | Log.warn("读取智能排序配置失败", e); |
| 708 | 713 | } |
| 714 | + Log.info("智能排序配置: distWeight=" + distWeight + ", effWeight=" + effWeight | |
| 715 | + + ", threshold=" + threshold + ", clamp=[" + clampMin + "," + clampMax + "]"); | |
| 709 | 716 | |
| 710 | 717 | // 2. 查询今日待办任务 |
| 711 | 718 | List<TaskDistanceSortRespVO> allTasks = homepageSummaryMapper |
| 712 | 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 | 723 | // 3. 查询效率矩阵 |
| 715 | 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 | 732 | // 4. 为每个任务打分 |
| 718 | 733 | List<TaskDistanceSortRespVO> tasksWithGps = new ArrayList<>(); |
| ... | ... | @@ -737,10 +752,20 @@ public class HomepageSummaryServiceImpl implements HomepageSummaryService{ |
| 737 | 752 | double distScore = Math.max(0, 1 - dist / threshold); |
| 738 | 753 | task.setDistanceScore(Math.round(distScore * 100.0) / 100.0); |
| 739 | 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 | 761 | tasksWithGps.add(task); |
| 741 | 762 | } else { |
| 742 | 763 | task.setDistanceScore(0.0); |
| 743 | 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 | 769 | tasksWithoutGps.add(task); |
| 745 | 770 | } |
| 746 | 771 | } |
| ... | ... | @@ -833,4 +858,21 @@ public class HomepageSummaryServiceImpl implements HomepageSummaryService{ |
| 833 | 858 | if (val < min) return min; |
| 834 | 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 | 647 | <foreach collection='roleIds' item='roleId' open='(' close=')' separator=','> |
| 648 | 648 | #{roleId} |
| 649 | 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 | 651 | AND r.starting_latitude IS NOT NULL AND r.starting_latitude != '' |
| 652 | 652 | |
| 653 | 653 | UNION ALL |
| ... | ... | @@ -677,7 +677,7 @@ |
| 677 | 677 | <foreach collection='roleIds' item='roleId' open='(' close=')' separator=','> |
| 678 | 678 | #{roleId} |
| 679 | 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 | 681 | AND r.starting_latitude IS NOT NULL AND r.starting_latitude != '' |
| 682 | 682 | ) t |
| 683 | 683 | </select> | ... | ... |