From f67945d53b20f6a45ae50b27d74c966eb1355bb4 Mon Sep 17 00:00:00 2001
From: wlzboy <66905212@qq.com>
Date: 星期日, 16 十一月 2025 22:53:54 +0800
Subject: [PATCH] feat: 增加分段GPS计算行程距离
---
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java | 93 ++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 93 insertions(+), 0 deletions(-)
diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java
index 54b605d..f990c3c 100644
--- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java
+++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java
@@ -1,8 +1,10 @@
package com.ruoyi.system.service.impl;
import java.util.ArrayList;
+import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
+import java.util.Set;
import java.util.stream.Collectors;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -335,4 +337,95 @@
{
return getChildList(list, t).size() > 0;
}
+
+ /**
+ * 璁$畻鎸囧畾鐢ㄦ埛鐨勫垎鍏徃鍒楄〃
+ * 閫昏緫锛�
+ * 1. 鏍规嵁鐢ㄦ埛鐨刼aOrderClass鍖归厤鍒嗗叕鍙革紙鏈嶅姟鍗曠紪鐮�/璋冨害鍗曠紪鐮侊級
+ * 2. 闄勫姞鐢ㄦ埛鎵�灞炵殑鍒嗗叕鍙革紙浠巇eptId/ancestors瑙f瀽锛�
+ * 3. 鍘婚噸鍚庤繑鍥�
+ *
+ * @param user 鐢ㄦ埛淇℃伅
+ * @return 鍒嗗叕鍙稿垪琛�
+ */
+ @Override
+ public List<SysDept> computeBranchCompaniesForUser(SysUser user)
+ {
+ List<SysDept> result = new ArrayList<>();
+ Set<Long> seen = new HashSet<>();
+
+ if (user == null) {
+ return result;
+ }
+
+ // 1. 鏍规嵁oaOrderClass鍖归厤鍒嗗叕鍙革紙浼樺寲锛氫竴娆℃煡璇級
+ String orderClass = user.getOaOrderClass();
+ if (StringUtils.isNotEmpty(orderClass))
+ {
+ // 瑙f瀽orderClass涓虹紪鐮佸垪琛�
+ List<String> orderCodes = new ArrayList<>();
+ for (String raw : orderClass.split(",")) {
+ String code = raw.trim();
+ if (!code.isEmpty()) {
+ orderCodes.add(code);
+ }
+ }
+
+ // 涓�娆℃�ф煡璇㈡墍鏈夊尮閰嶇殑鍒嗗叕鍙�
+ if (!orderCodes.isEmpty()) {
+ List<SysDept> matchedDepts = deptMapper.selectBranchCompaniesByOrderCodes(orderCodes);
+ for (SysDept dept : matchedDepts) {
+ if (seen.add(dept.getDeptId())) {
+ result.add(dept);
+ }
+ }
+ }
+ }
+
+ // 2. 闄勫姞璇ョ敤鎴锋墍灞炲垎鍏徃锛堜粠deptId/ancestors瑙f瀽锛�
+ if (user.getDeptId() != null)
+ {
+ SysDept userDept = selectDeptById(user.getDeptId());
+ Long branchCompanyId = null;
+
+ if (userDept != null)
+ {
+ // 鍒ゆ柇鏄惁鏈韩灏辨槸鍒嗗叕鍙�
+ if (userDept.getParentId() != null && userDept.getParentId() == 100L)
+ {
+ branchCompanyId = userDept.getDeptId();
+ }
+ // 鍚﹀垯浠巃ncestors涓煡鎵�
+ else if (userDept.getAncestors() != null && !userDept.getAncestors().isEmpty())
+ {
+ String[] ancestorIds = userDept.getAncestors().split(",");
+ for (int i = 0; i < ancestorIds.length; i++)
+ {
+ // 鎵惧埌100鐨勪笅涓�涓氨鏄垎鍏徃ID
+ if ("100".equals(ancestorIds[i]) && i + 1 < ancestorIds.length)
+ {
+ try {
+ branchCompanyId = Long.parseLong(ancestorIds[i + 1]);
+ } catch (NumberFormatException e) {
+ branchCompanyId = null;
+ }
+ break;
+ }
+ }
+ }
+ }
+
+ // 濡傛灉鎵惧埌浜嗗垎鍏徃ID锛屾坊鍔犲埌缁撴灉涓�
+ if (branchCompanyId != null)
+ {
+ SysDept branchCompany = selectDeptById(branchCompanyId);
+ if (branchCompany != null && seen.add(branchCompany.getDeptId()))
+ {
+ result.add(branchCompany);
+ }
+ }
+ }
+
+ return result;
+ }
}
--
Gitblit v1.9.1