Pārlūkot izejas kodu

维修工单调整

ouyj 7 mēneši atpakaļ
vecāks
revīzija
18db67b9e1

+ 11 - 0
ygtx-common/src/main/java/com/ygtx/common/core/domain/entity/SysDept.java

@@ -58,6 +58,9 @@ public class SysDept extends BaseEntity
     /** 子部门 */
     private List<SysDept> children = new ArrayList<SysDept>();
 
+    /** 部门名称(精确查询用) */
+    private String deptNameNoLike;
+
     public Long getDeptId()
     {
         return deptId;
@@ -193,6 +196,14 @@ public class SysDept extends BaseEntity
         this.level = level;
     }
 
+    public String getDeptNameNoLike() {
+        return deptNameNoLike;
+    }
+
+    public void setDeptNameNoLike(String deptNameNoLike) {
+        this.deptNameNoLike = deptNameNoLike;
+    }
+
     @Override
     public String toString() {
         return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)

+ 3 - 3
ygtx-gxt/src/main/java/com/ygtx/gxt/service/impl/GxtEquipmentServiceImpl.java

@@ -303,7 +303,7 @@ public class GxtEquipmentServiceImpl implements IGxtEquipmentService
         // 处理维保中心ID
         if (StringUtils.isNotEmpty(equipment.getMaintenanceCenter())) {
             SysDept dept = new SysDept();
-            dept.setDeptName(equipment.getMaintenanceCenter());
+            dept.setDeptNameNoLike(equipment.getMaintenanceCenter());
             dept.setLevel("2"); // 维保中心层级为2
             List<SysDept> depts = sysDeptService.selectDeptList(dept);
             // 如果只找到一个维保中心,则设置维保中心ID
@@ -315,14 +315,14 @@ public class GxtEquipmentServiceImpl implements IGxtEquipmentService
         // 处理场站ID
         if (StringUtils.isNotEmpty(equipment.getStation())) {
             SysDept dept = new SysDept();
-            dept.setDeptName(equipment.getStation());
+            dept.setDeptNameNoLike(equipment.getStation());
             dept.setLevel("3"); // 场站层级为3
             List<SysDept> deptsA = sysDeptService.selectDeptList(dept);
             // 如果只找到一个场站,则设置场站ID
             if (deptsA != null && deptsA.size() == 1) {
                 equipment.setStationId(deptsA.get(0).getDeptId());
             }else{
-                dept.setDeptName(equipment.getStation());
+                dept.setDeptNameNoLike(equipment.getStation());
                 dept.setLevel("4"); // 场站层级为4
                 List<SysDept> deptsB = sysDeptService.selectDeptList(dept);
                 if (deptsB != null && deptsB.size() == 1) {

+ 3 - 3
ygtx-gxt/src/main/java/com/ygtx/gxt/task/EquipmentSyncTask.java

@@ -139,7 +139,7 @@ public class EquipmentSyncTask {
         // 处理维保中心ID
         if (StringUtils.isNotEmpty(equipment.getMaintenanceCenter())) {
             SysDept dept = new SysDept();
-            dept.setDeptName(equipment.getMaintenanceCenter());
+            dept.setDeptNameNoLike(equipment.getMaintenanceCenter());
             dept.setLevel("2"); // 维保中心层级为2
             List<SysDept> depts = sysDeptService.selectDeptList(dept);
             // 如果只找到一个维保中心,则设置维保中心ID
@@ -151,14 +151,14 @@ public class EquipmentSyncTask {
         // 处理场站ID
         if (StringUtils.isNotEmpty(equipment.getStation())) {
             SysDept dept = new SysDept();
-            dept.setDeptName(equipment.getStation());
+            dept.setDeptNameNoLike(equipment.getStation());
             dept.setLevel("3"); // 场站层级为3
             List<SysDept> deptsA = sysDeptService.selectDeptList(dept);
             // 如果只找到一个场站,则设置场站ID
             if (deptsA != null && deptsA.size() == 1) {
                 equipment.setStationId(deptsA.get(0).getDeptId());
             }else{
-                dept.setDeptName(equipment.getStation());
+                dept.setDeptNameNoLike(equipment.getStation());
                 dept.setLevel("4"); // 场站层级为4
                 List<SysDept> deptsB = sysDeptService.selectDeptList(dept);
                 if (deptsB != null && deptsB.size() == 1) {

+ 3 - 0
ygtx-system/src/main/resources/mapper/system/SysDeptMapper.xml

@@ -40,6 +40,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 		<if test="deptName != null and deptName != ''">
 			AND dept_name like concat('%', #{deptName}, '%')
 		</if>
+		<if test="deptNameNoLike != null and deptNameNoLike != ''">
+			AND dept_name = #{deptNameNoLike}
+		</if>
 		<if test="status != null and status != ''">
 			AND status = #{status}
 		</if>

+ 80 - 7
ygtx-ui/src/views/gxt/repairOrder/index.vue

@@ -1245,7 +1245,7 @@ import {
   finalizeRepairOrder,
   restartRepairOrder
 } from "@/api/gxt/repairOrder";
-import { listDept } from "@/api/system/dept";
+import { listDept,getDept } from "@/api/system/dept";
 import { listFaultCodes } from "@/api/gxt/faultCodes"
 import { listGxtOrder } from "@/api/gxt/gxtOrder";
 import { listUser } from "@/api/system/user";
@@ -1666,6 +1666,59 @@ function handleMaintenanceCenterChange(selectedCenter) {
   }
 }
 
+/**
+ * 根据部门ID获取部门信息,并根据level判断是否需要查找父部门
+ * @param {Number} deptId 部门ID
+ * @returns {Promise<Number>} 返回level为3的部门ID
+ */
+function getDeptAndUserByLevel(deptId) {
+  return new Promise((resolve) => {
+    // 获取部门信息
+    getDeptInfoAndParent(deptId).then(dept => {
+      resolve(dept.deptId);
+    });
+  });
+}
+/**
+ * 递归获取部门信息,查找父部门直到level为3
+ * @param {Number} deptId 部门ID
+ * @returns {Promise<Object>} 返回level为3的部门对象
+ */
+function getDeptInfoAndParent(deptId) {
+  return new Promise((resolve) => {
+    getDept(deptId).then(response => {
+      const dept = response.data;
+      // 如果部门level为3,直接返回
+      if (dept.level === "3") {
+        resolve(dept);
+      } 
+      // 如果有祖先部门,则继续向上查找
+      else if (dept.ancestors) {
+        // 从ancestors中提取父部门ID
+        // ancestors格式类似 "0,100,101,102"
+        const ancestorIds = dept.ancestors.split(',');
+        if (ancestorIds.length <= 1){
+          resolve(dept);
+        }else {
+          const parentDeptId = ancestorIds[ancestorIds.length - 1];  
+          // 递归获取父部门信息
+          getDeptInfoAndParent(parentDeptId).then(parentDept => {
+            resolve(parentDept);
+          });
+        }
+      } 
+      // 其他情况也直接返回
+      else {
+        resolve(dept);
+      }
+    }).catch(error => {
+      // 如果获取部门信息失败,返回null
+      console.error("获取部门信息失败:", error);
+      resolve(null);
+    });
+  });
+}
+
 // 取消按钮
 function cancel() {
   openDialog.value = false
@@ -1930,9 +1983,19 @@ function handleAccept(row) {
     acceptForm.value.pcsStationId = response.data.pcsStationId
     // 根据场站ID查询该场站的用户列表
     if (acceptForm.value.pcsStationId) {
-      listUser({ pageNum: 1, pageSize: 100, deptId: acceptForm.value.pcsStationId }).then(response => {
-        userList.value = response.rows
-        acceptDialogVisible.value = true
+      // 先获取部门信息,判断level是否为4,如果是则查找其父部门直到level为3
+      getDeptAndUserByLevel(acceptForm.value.pcsStationId).then(deptId => {
+        // 确保 deptId 是有效的再调用 listUser
+        if (deptId) {
+          listUser({ pageNum: 1, pageSize: 100, deptId: deptId }).then(response => {
+            userList.value = response.rows
+            acceptDialogVisible.value = true
+          })
+        } else {
+          // 如果没有找到有效的部门ID,仍然打开对话框但给出提示
+          proxy.$modal.msgWarning("未找到有效的部门信息,无法加载用户列表");
+          acceptDialogVisible.value = true
+        }
       })
     } else {
       acceptDialogVisible.value = true
@@ -2256,9 +2319,19 @@ function handleFinalize(row) {
     finalizeForm.value.pcsStationId = response.data.pcsStationId
     // 根据场站ID查询该场站的用户列表
     if (finalizeForm.value.pcsStationId) {
-      listUser({ pageNum: 1, pageSize: 100, deptId: finalizeForm.value.pcsStationId }).then(response => {
-        userList.value = response.rows
-        finalizeDialogVisible.value = true
+      // 先获取部门信息,判断level是否为4,如果是则查找其父部门直到level为3
+      getDeptAndUserByLevel(finalizeForm.value.pcsStationId).then(deptId => {
+        // 确保 deptId 是有效的再调用 listUser
+        if (deptId) {
+          listUser({ pageNum: 1, pageSize: 100, deptId: deptId }).then(response => {
+            userList.value = response.rows
+            finalizeDialogVisible.value = true
+          })
+        } else {
+          // 如果没有找到有效的部门ID,仍然打开对话框但给出提示
+          proxy.$modal.msgWarning("未找到有效的部门信息,无法加载用户列表");
+          finalizeDialogVisible.value = true
+        }
       })
     } else {
       finalizeDialogVisible.value = true