Browse Source

插入工作负责人历史记录

wuhb 4 months ago
parent
commit
a285399e3b

+ 80 - 0
ygtx-gxt/src/main/java/com/ygtx/gxt/controller/GxtUserLeaderController.java

@@ -0,0 +1,80 @@
+package com.ygtx.gxt.controller;
+
+import com.github.pagehelper.util.StringUtil;
+import com.ygtx.common.annotation.Log;
+import com.ygtx.common.constant.UserConstants;
+import com.ygtx.common.core.controller.BaseController;
+import com.ygtx.common.core.domain.AjaxResult;
+import com.ygtx.common.core.domain.entity.SysDept;
+import com.ygtx.common.core.domain.entity.SysUser;
+import com.ygtx.common.core.page.TableDataInfo;
+import com.ygtx.common.enums.BusinessType;
+import com.ygtx.common.utils.poi.ExcelUtil;
+import com.ygtx.gxt.domain.*;
+import com.ygtx.gxt.service.*;
+import com.ygtx.system.service.ISysConfigService;
+import com.ygtx.system.service.ISysUserService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
+import io.swagger.annotations.ApiOperation;
+import org.apache.catalina.security.SecurityUtil;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletResponse;
+import java.math.BigDecimal;
+import java.time.LocalDate;
+import java.time.format.DateTimeFormatter;
+import java.util.*;
+import java.util.stream.Collectors;
+
+/**
+ * 工作负责人
+ *
+ * @author ruoyi
+ * @date 2025-11-03
+ */
+@RestController
+@RequestMapping("/gxt/leader")
+@Api(tags = "工作负责人")
+public class GxtUserLeaderController extends BaseController
+{
+
+    @Autowired
+    private ISysUserService userService;
+    @Autowired
+    private IGxtUserOperatorHistoryService gxtUserOperatorHistoryService;
+
+    @GetMapping("/listLeader")
+    public AjaxResult listLeader(SysUser user)
+    {
+        GxtUserOperatorHistory gxtUserOperatorHistory = new GxtUserOperatorHistory();
+        gxtUserOperatorHistory.setOpType(UserConstants.OP_TYPE_LEADER);
+        gxtUserOperatorHistory.setOpUserid(getUserId());
+        List<GxtUserOperatorHistory> gxtUserOperatorHistoryList = gxtUserOperatorHistoryService.selectGxtUserOperatorHistoryList(gxtUserOperatorHistory);
+        List<SysUser> list = userService.selectUserListNoPermi(user);
+        sortSysUser(list, gxtUserOperatorHistoryList);
+        return AjaxResult.success(list);
+    }
+
+    private void sortSysUser(List<SysUser> list, List<GxtUserOperatorHistory> gxtUserOperatorHistoryList){
+        Map<Long, GxtUserOperatorHistory> historyMap = gxtUserOperatorHistoryList.stream()
+                .collect(Collectors.toMap(GxtUserOperatorHistory::getOpUserid, item -> item, (existing, replacement) -> existing, LinkedHashMap::new));
+        List<SysUser> result1 = new ArrayList<>();
+        for(GxtUserOperatorHistory history:gxtUserOperatorHistoryList){
+            for (SysUser sysUser : list) {
+                if (history.getOpLeaderId().equals(sysUser.getUserId())) {
+                    result1.add(sysUser);
+                }
+            }
+        }
+        for (SysUser sysUser : result1) {
+            list.remove(sysUser);
+        }
+//        result1.addAll(list);
+//        list.clear();
+        list.addAll(0, result1);
+    }
+}

+ 1 - 0
ygtx-gxt/src/main/resources/mapper/gxt/GxtUserOperatorHistoryMapper.xml

@@ -35,6 +35,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="opLeaderId != null  and opLeaderId != ''"> and op_leader_id = #{opLeaderId}</if>
             <if test="opLeaderName != null  and opLeaderName != ''"> and op_leader_name like concat('%', #{opLeaderName}, '%')</if>
         </where>
+        order by op_num desc,update_time desc
     </select>
 
     <select id="selectGxtUserOperatorHistoryById" parameterType="Long" resultMap="GxtUserOperatorHistoryResult">

+ 8 - 0
ygtx-ui/src/api/system/user.js

@@ -169,6 +169,14 @@ export function listUserNoPermi(query) {
   })
 }
 
+export function listLeader(query) {
+  return request({
+    url: '/gxt/leader/listLeader',
+    method: 'get',
+    params: query
+  })
+}
+
 export function listNoPermiForPage(query) {
   return request({
     url: '/system/user/listNoPermiForPage',

+ 3 - 3
ygtx-ui/src/views/gxt/gxtOrder/index.vue

@@ -1589,7 +1589,7 @@ import {
   invalidateGxtOrder,
   getExportFields
 } from "@/api/gxt/gxtOrder"
-import {listUser, listUserData, listUserNoPermi} from "@/api/system/user"
+import {listUser, listUserData, listUserNoPermi, listLeader} from "@/api/system/user"
 import {getToken} from "@/utils/auth.js";
 import {getRepairOrder, startRepairOrder} from "@/api/gxt/repairOrder.js";
 import {listEquipment, listMaintenanceCenters, listStationsByMaintenanceCenter} from "@/api/gxt/equipment.js";
@@ -1677,7 +1677,7 @@ const searchTeamLeaderList = async (keyword) => {
 
   teamLeaderLoading.value = true
   try {
-    const response = await listUserNoPermi({
+    const response = await listLeader({
       nickName: keyword,
       // 可以根据需要添加其他搜索条件
       status: '0' // 只搜索启用状态的用户
@@ -1708,7 +1708,7 @@ const loadQuickTeamLeaderList = async () => {
   teamLeaderLoading.value = true
   try {
     // 加载当前部门下的用户列表
-    const response = await listUserNoPermi({
+    const response = await listLeader({
       deptId: -1, // 通过后台配置部门
       status: '0'
     })

+ 2 - 2
ygtx-ui/src/views/gxt/orderMyTodo/index.vue

@@ -1512,7 +1512,7 @@ import {
   restartWorkOrder,
   listMyRate,
 } from "@/api/gxt/orderMine.js";
-import { listUserNoPermi } from "@/api/system/user.js";
+import { listUserNoPermi, listLeader } from "@/api/system/user.js";
 import { listEquipment,listMaintenanceCenters, listStationsByMaintenanceCenter } from "@/api/gxt/equipment.js";
 import { listMisInfo, listWorkPerson } from "@/api/gxt/misInfo.js";
 import preview from '@/components/FileUpload/preview.vue'
@@ -2188,7 +2188,7 @@ const loadQuickTeamLeaderList = async () => {
   teamLeaderLoading.value = true;
   try {
     // 加载当前部门下的用户列表
-    const response = await listUserNoPermi({
+    const response = await listLeader({
       deptId: -1, // 通过后台配置部门
       status: '0'
     });

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

@@ -1889,7 +1889,7 @@ import {
 import { listDept,getDept } from "@/api/system/dept";
 import { listFaultCodes } from "@/api/gxt/faultCodes"
 /*import { listGxtOrder } from "@/api/gxt/gxtOrder";*/
-import {listUser, listUserData, listUserNoPermi} from "@/api/system/user";
+import {listUser, listUserData, listUserNoPermi, listLeader} from "@/api/system/user";
 import EquipmentSelectSingle from "@/components/equipmentSelect/single.vue"
 import { ElMessage, ElMessageBox, ElNotification, ElLoading } from 'element-plus'
 import { listMaintenanceCenters, listStationsByMaintenanceCenter } from "@/api/gxt/equipment"
@@ -2195,7 +2195,7 @@ const searchTeamLeaderList = async (keyword) => {
 
   teamLeaderLoading.value = true
   try {
-    const response = await listUserNoPermi({
+    const response = await listLeader({
       nickName: keyword,
       // 可以根据需要添加其他搜索条件
       status: '0' // 只搜索启用状态的用户
@@ -2226,7 +2226,7 @@ const loadQuickTeamLeaderList = async () => {
   teamLeaderLoading.value = true
   try {
     // 加载当前部门下的用户列表
-    const response = await listUserNoPermi({
+    const response = await listLeader({
       deptId: -1, // 通过后台配置部门
       status: '0'
     })