Commit 35590a5b1fdd6614fe8f266d50ea35dc32854918
1 parent
61c9550c
feat(garden): 新增任务距离排序和智能排序功能
- 实现任务按距离排序和班组进度统计功能 - 添加任务智能排序(距离+个人效率加权)功能 - 新增GPS距离计算工具类和相关数据传输对象 - 添加出行速度配置和智能排序权重配置字典类型 - 实现用户任务效率预计算定时任务 - 优化API签名切面注解使用方式 - 添加微信公众号开放平台回调接口免登录配置
Showing
3 changed files
with
21 additions
and
7 deletions
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/job/TaskEfficiencyCalculateJob.java
| 1 | package com.zteits.urbanops.module.garden.job; | 1 | package com.zteits.urbanops.module.garden.job; |
| 2 | 2 | ||
| 3 | +import com.zteits.urbanops.framework.quartz.core.handler.JobHandler; | ||
| 3 | import com.zteits.urbanops.module.garden.dal.dataobject.UserTaskEfficiencyDO; | 4 | import com.zteits.urbanops.module.garden.dal.dataobject.UserTaskEfficiencyDO; |
| 4 | import com.zteits.urbanops.module.garden.dal.mysql.UserTaskEfficiencyMapper; | 5 | import com.zteits.urbanops.module.garden.dal.mysql.UserTaskEfficiencyMapper; |
| 5 | import jakarta.annotation.Resource; | 6 | import jakarta.annotation.Resource; |
| @@ -21,12 +22,13 @@ import java.util.*; | @@ -21,12 +22,13 @@ import java.util.*; | ||
| 21 | */ | 22 | */ |
| 22 | @Slf4j | 23 | @Slf4j |
| 23 | @Component | 24 | @Component |
| 24 | -public class TaskEfficiencyCalculateJob { | 25 | +public class TaskEfficiencyCalculateJob implements JobHandler { |
| 25 | 26 | ||
| 26 | @Resource | 27 | @Resource |
| 27 | private UserTaskEfficiencyMapper userTaskEfficiencyMapper; | 28 | private UserTaskEfficiencyMapper userTaskEfficiencyMapper; |
| 28 | 29 | ||
| 29 | - public void execute() { | 30 | + @Override |
| 31 | + public String execute(String param) { | ||
| 30 | String statPeriod = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy-MM")); | 32 | String statPeriod = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy-MM")); |
| 31 | log.info("TaskEfficiencyCalculateJob start, statPeriod={}", statPeriod); | 33 | log.info("TaskEfficiencyCalculateJob start, statPeriod={}", statPeriod); |
| 32 | try { | 34 | try { |
| @@ -44,7 +46,7 @@ public class TaskEfficiencyCalculateJob { | @@ -44,7 +46,7 @@ public class TaskEfficiencyCalculateJob { | ||
| 44 | 46 | ||
| 45 | if (all.isEmpty()) { | 47 | if (all.isEmpty()) { |
| 46 | log.info("TaskEfficiencyCalculateJob done, no data"); | 48 | log.info("TaskEfficiencyCalculateJob done, no data"); |
| 47 | - return; | 49 | + return "success, no data"; |
| 48 | } | 50 | } |
| 49 | 51 | ||
| 50 | // 4. 计算班组均值 | 52 | // 4. 计算班组均值 |
| @@ -69,8 +71,10 @@ public class TaskEfficiencyCalculateJob { | @@ -69,8 +71,10 @@ public class TaskEfficiencyCalculateJob { | ||
| 69 | } | 71 | } |
| 70 | 72 | ||
| 71 | log.info("TaskEfficiencyCalculateJob done, total={}", all.size()); | 73 | log.info("TaskEfficiencyCalculateJob done, total={}", all.size()); |
| 74 | + return "success, total=" + all.size(); | ||
| 72 | } catch (Exception e) { | 75 | } catch (Exception e) { |
| 73 | log.error("TaskEfficiencyCalculateJob error", e); | 76 | log.error("TaskEfficiencyCalculateJob error", e); |
| 77 | + return "error: " + e.getMessage(); | ||
| 74 | } | 78 | } |
| 75 | } | 79 | } |
| 76 | 80 |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/service/homepage/HomepageSummaryServiceImpl.java
| @@ -634,6 +634,18 @@ public class HomepageSummaryServiceImpl implements HomepageSummaryService{ | @@ -634,6 +634,18 @@ public class HomepageSummaryServiceImpl implements HomepageSummaryService{ | ||
| 634 | public TaskDistanceSortResultVO queryTaskDetailsWithSmartSort(AppTaskSmartSortReqVO req) { | 634 | public TaskDistanceSortResultVO queryTaskDetailsWithSmartSort(AppTaskSmartSortReqVO req) { |
| 635 | Long userId = SecurityFrameworkUtils.getLoginUserId(); | 635 | Long userId = SecurityFrameworkUtils.getLoginUserId(); |
| 636 | Long deptId = SecurityFrameworkUtils.getDeptId(); | 636 | Long deptId = SecurityFrameworkUtils.getDeptId(); |
| 637 | + | ||
| 638 | + // 已办:查询已完成任务,不走智能排序 | ||
| 639 | + if (req.getQueryType() != null && req.getQueryType() == 2) { | ||
| 640 | + List<TaskDistanceSortRespVO> sortedTasks = queryCompletedTasksWithoutGps(userId); | ||
| 641 | + TeamProgressVO teamProgress = buildTeamProgress(userId, deptId); | ||
| 642 | + TaskDistanceSortResultVO result = new TaskDistanceSortResultVO(); | ||
| 643 | + result.setSortedTasks(sortedTasks); | ||
| 644 | + result.setTeamProgress(teamProgress); | ||
| 645 | + result.setTotalPendingTasks(sortedTasks.size()); | ||
| 646 | + return result; | ||
| 647 | + } | ||
| 648 | + | ||
| 637 | List<Long> roleIds = roleApi.getRoleIdsByUserId(userId); | 649 | List<Long> roleIds = roleApi.getRoleIdsByUserId(userId); |
| 638 | 650 | ||
| 639 | // 1. 从字典读取配置 | 651 | // 1. 从字典读取配置 |
urbanops-module-garden/src/main/resources/mapper/UserTaskEfficiencyMapper.xml
| @@ -29,8 +29,7 @@ | @@ -29,8 +29,7 @@ | ||
| 29 | SUM(TIMESTAMPDIFF(MINUTE, d.begin_time, c.finish_time)) AS total_min, | 29 | SUM(TIMESTAMPDIFF(MINUTE, d.begin_time, c.finish_time)) AS total_min, |
| 30 | AVG(TIMESTAMPDIFF(MINUTE, d.begin_time, c.finish_time)) AS avg_min | 30 | AVG(TIMESTAMPDIFF(MINUTE, d.begin_time, c.finish_time)) AS avg_min |
| 31 | FROM garden_inspection_plan_commit c | 31 | FROM garden_inspection_plan_commit c |
| 32 | - INNER JOIN garden_inspection_plan_detail d ON c.batch_no = d.batch_no AND c.user_id = d.user_id | ||
| 33 | - INNER JOIN garden_inspection_plan p ON c.batch_no = p.batch_no | 32 | + INNER JOIN garden_inspection_plan_detail d ON c.batch_no = d.batch_no INNER JOIN garden_inspection_plan p ON c.batch_no = p.batch_no |
| 34 | INNER JOIN system_users u ON c.user_id = u.id | 33 | INNER JOIN system_users u ON c.user_id = u.id |
| 35 | WHERE c.finish_time >= #{beginTime} | 34 | WHERE c.finish_time >= #{beginTime} |
| 36 | AND c.finish_time IS NOT NULL | 35 | AND c.finish_time IS NOT NULL |
| @@ -46,8 +45,7 @@ | @@ -46,8 +45,7 @@ | ||
| 46 | SUM(TIMESTAMPDIFF(MINUTE, d.begin_time, c.finish_time)) AS total_min, | 45 | SUM(TIMESTAMPDIFF(MINUTE, d.begin_time, c.finish_time)) AS total_min, |
| 47 | AVG(TIMESTAMPDIFF(MINUTE, d.begin_time, c.finish_time)) AS avg_min | 46 | AVG(TIMESTAMPDIFF(MINUTE, d.begin_time, c.finish_time)) AS avg_min |
| 48 | FROM garden_maintain_plan_commit c | 47 | FROM garden_maintain_plan_commit c |
| 49 | - INNER JOIN garden_maintain_plan_detail d ON c.batch_no = d.batch_no AND c.user_id = d.user_id | ||
| 50 | - INNER JOIN garden_maintain_plan p ON c.batch_no = p.batch_no | 48 | + INNER JOIN garden_maintain_plan_detail d ON c.batch_no = d.batch_no INNER JOIN garden_maintain_plan p ON c.batch_no = p.batch_no |
| 51 | INNER JOIN system_users u ON c.user_id = u.id | 49 | INNER JOIN system_users u ON c.user_id = u.id |
| 52 | WHERE c.finish_time >= #{beginTime} | 50 | WHERE c.finish_time >= #{beginTime} |
| 53 | AND c.finish_time IS NOT NULL | 51 | AND c.finish_time IS NOT NULL |