From ea1a62ba6484d6c6cb1ca67dcea938a95ba18fc6 Mon Sep 17 00:00:00 2001
From: Pu Zhibing <393733352@qq.com>
Date: 星期一, 26 五月 2025 18:26:26 +0800
Subject: [PATCH] 新增加用户端接口

---
 ruoyi-modules/ruoyi-shop/src/main/java/com/ruoyi/shop/service/impl/task/ShopTaskRecordServiceImpl.java |  165 ++++++++++++++++++++++++++++++++++++++++++++----------
 1 files changed, 134 insertions(+), 31 deletions(-)

diff --git a/ruoyi-modules/ruoyi-shop/src/main/java/com/ruoyi/shop/service/impl/task/ShopTaskRecordServiceImpl.java b/ruoyi-modules/ruoyi-shop/src/main/java/com/ruoyi/shop/service/impl/task/ShopTaskRecordServiceImpl.java
index 2917a4c..ff4827b 100644
--- a/ruoyi-modules/ruoyi-shop/src/main/java/com/ruoyi/shop/service/impl/task/ShopTaskRecordServiceImpl.java
+++ b/ruoyi-modules/ruoyi-shop/src/main/java/com/ruoyi/shop/service/impl/task/ShopTaskRecordServiceImpl.java
@@ -2,22 +2,29 @@
 
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ruoyi.shop.domain.dto.FileDto;
 import com.ruoyi.shop.domain.dto.MgtShopTaskPageDto;
 import com.ruoyi.shop.domain.dto.StaffShopTaskPageDto;
 import com.ruoyi.shop.domain.pojo.task.ShopTaskRecord;
 import com.ruoyi.shop.domain.pojo.task.TaskFile;
 import com.ruoyi.shop.domain.vo.MgtShopTaskRecordPageVo;
+import com.ruoyi.shop.domain.vo.StaffAgencyTaskRecordPageVo;
 import com.ruoyi.shop.domain.vo.StaffMyShopTaskRecordPageVo;
 import com.ruoyi.shop.mapper.task.ShopTaskRecordMapper;
 import com.ruoyi.shop.service.task.ShopTaskRecordService;
 import com.ruoyi.shop.service.task.TaskFileService;
+import com.ruoyi.system.api.domain.poji.sys.SysStaff;
 import com.ruoyi.system.api.domain.poji.sys.SysUser;
+import com.ruoyi.system.api.service.RemoteConfigService;
 import com.ruoyi.system.api.service.RemoteUserService;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
 import java.util.ArrayList;
+import java.util.HashSet;
 import java.util.List;
+import java.util.Map;
+import java.util.function.Function;
 import java.util.stream.Collectors;
 
 /**
@@ -38,7 +45,7 @@
     private TaskFileService taskFileService;
 
     @Resource
-    private RemoteUserService remoteUserService;
+    private RemoteConfigService remoteConfigService;
 
     /**
      * 平台分页获取平台跟进任务
@@ -50,30 +57,62 @@
         if(mgtShopTaskRecordPageVoList!=null&&!mgtShopTaskRecordPageVoList.isEmpty()){
             Long followId;
             List<TaskFile> taskFileList;
-            List<String> picture = new ArrayList<>();
-            List<String> video = new ArrayList<>();
-            List<String> audio = new ArrayList<>();
+            List<FileDto> picture = new ArrayList<>();
+            List<FileDto> video = new ArrayList<>();
+            List<FileDto> audio = new ArrayList<>();
             Long userId;
-            SysUser sysUser;
+            SysStaff sysStaff;
+            HashSet<Long> userIdSet = new HashSet<>();
+            for(MgtShopTaskRecordPageVo mgtShopTaskRecordPageVo : mgtShopTaskRecordPageVoList){
+                userIdSet.add(mgtShopTaskRecordPageVo.getUserId());
+            }
+            List<Long> useIdList = new ArrayList<>(userIdSet);
+            List<SysStaff> sysStaffList = remoteConfigService.listSysStaffByIds(useIdList).getData();
+            Map<Long,SysStaff> sysStaffMap = sysStaffList.stream()
+                    .collect(Collectors.toMap(SysStaff::getUserId, Function.identity()));
             for(MgtShopTaskRecordPageVo mgtShopTaskRecordPageVo : mgtShopTaskRecordPageVoList){
                 //获取任务用户信息
                 userId = mgtShopTaskRecordPageVo.getUserId();
-                sysUser = remoteUserService.getSysUser(userId).getData();
-                mgtShopTaskRecordPageVo.setUserName(sysUser.getNickName());
-                mgtShopTaskRecordPageVo.setUserPicture(sysUser.getAvatar());
+                sysStaff = sysStaffMap.get(userId);
+                if(sysStaff!=null){
+                    mgtShopTaskRecordPageVo.setUserName(sysStaff.getStaffName());
+                    mgtShopTaskRecordPageVo.setUserPicture(sysStaff.getStaffAvatar());
+                    mgtShopTaskRecordPageVo.setUserPosition(sysStaff.getStaffPost());
+                }
                 //获取任务详情文件
                 followId = mgtShopTaskRecordPageVo.getFollowId();
                 taskFileList = taskFileService.listByFollowIdAndFollowType(followId,1);
                 if(taskFileList!=null&&!taskFileList.isEmpty()){
-                    picture = taskFileList.stream().map(k->k.getFileUrl()).collect(Collectors.toList());
+                    picture = taskFileList.stream()
+                            .map(taskFile -> {
+                                FileDto fileDto = new FileDto();
+                                fileDto.setFileName(taskFile.getFileName());
+                                fileDto.setFileUrl(taskFile.getFileUrl());
+                                return fileDto;
+                            })
+                            .collect(Collectors.toList());
                 }
                 taskFileList = taskFileService.listByFollowIdAndFollowType(followId,2);
                 if(taskFileList!=null&&!taskFileList.isEmpty()){
-                    video = taskFileList.stream().map(k->k.getFileUrl()).collect(Collectors.toList());
+                    video = taskFileList.stream()
+                            .map(taskFile -> {
+                                FileDto fileDto = new FileDto();
+                                fileDto.setFileName(taskFile.getFileName());
+                                fileDto.setFileUrl(taskFile.getFileUrl());
+                                return fileDto;
+                            })
+                            .collect(Collectors.toList());
                 }
                 taskFileList = taskFileService.listByFollowIdAndFollowType(followId,3);
                 if(taskFileList!=null&&!taskFileList.isEmpty()){
-                    audio = taskFileList.stream().map(k->k.getFileUrl()).collect(Collectors.toList());
+                    audio = taskFileList.stream()
+                            .map(taskFile -> {
+                                FileDto fileDto = new FileDto();
+                                fileDto.setFileName(taskFile.getFileName());
+                                fileDto.setFileUrl(taskFile.getFileUrl());
+                                return fileDto;
+                            })
+                            .collect(Collectors.toList());
                 }
                 mgtShopTaskRecordPageVo.setPicture(picture);
                 mgtShopTaskRecordPageVo.setVideo(video);
@@ -97,30 +136,62 @@
         if(myShopTaskRecordPageVoList!=null&&!myShopTaskRecordPageVoList.isEmpty()){
             Long followId;
             List<TaskFile> taskFileList;
-            List<String> picture = new ArrayList<>();
-            List<String> video = new ArrayList<>();
-            List<String> audio = new ArrayList<>();
+            List<FileDto> picture = new ArrayList<>();
+            List<FileDto> video = new ArrayList<>();
+            List<FileDto> audio = new ArrayList<>();
             Long userId;
-            SysUser sysUser;
+            SysStaff sysStaff;
+            HashSet<Long> userIdSet = new HashSet<>();
+            for(StaffMyShopTaskRecordPageVo staffMyShopTaskRecordPageVo : myShopTaskRecordPageVoList){
+                userIdSet.add(staffMyShopTaskRecordPageVo.getUserId());
+            }
+            List<Long> useIdList = new ArrayList<>(userIdSet);
+            List<SysStaff> sysStaffList = remoteConfigService.listSysStaffByIds(useIdList).getData();
+            Map<Long,SysStaff> sysStaffMap = sysStaffList.stream()
+                    .collect(Collectors.toMap(SysStaff::getUserId, Function.identity()));
             for(StaffMyShopTaskRecordPageVo staffMyShopTaskRecordPageVo : myShopTaskRecordPageVoList){
                 //获取任务用户信息
                 userId = staffMyShopTaskRecordPageVo.getUserId();
-                sysUser = remoteUserService.getSysUser(userId).getData();
-                staffMyShopTaskRecordPageVo.setUserName(sysUser.getNickName());
-                staffMyShopTaskRecordPageVo.setUserPicture(sysUser.getAvatar());
+                sysStaff = sysStaffMap.get(userId);
+                if(sysStaff!=null){
+                    staffMyShopTaskRecordPageVo.setUserName(sysStaff.getStaffName());
+                    staffMyShopTaskRecordPageVo.setUserPicture(sysStaff.getStaffAvatar());
+                    staffMyShopTaskRecordPageVo.setUserPosition(sysStaff.getStaffPost());
+                }
                 //获取任务详情文件
                 followId = staffMyShopTaskRecordPageVo.getFollowId();
                 taskFileList = taskFileService.listByFollowIdAndFollowType(followId,1);
                 if(taskFileList!=null&&!taskFileList.isEmpty()){
-                    picture = taskFileList.stream().map(k->k.getFileUrl()).collect(Collectors.toList());
+                    picture = taskFileList.stream()
+                            .map(taskFile -> {
+                                FileDto fileDto = new FileDto();
+                                fileDto.setFileName(taskFile.getFileName());
+                                fileDto.setFileUrl(taskFile.getFileUrl());
+                                return fileDto;
+                            })
+                            .collect(Collectors.toList());
                 }
                 taskFileList = taskFileService.listByFollowIdAndFollowType(followId,2);
                 if(taskFileList!=null&&!taskFileList.isEmpty()){
-                    video = taskFileList.stream().map(k->k.getFileUrl()).collect(Collectors.toList());
+                    video = taskFileList.stream()
+                            .map(taskFile -> {
+                                FileDto fileDto = new FileDto();
+                                fileDto.setFileName(taskFile.getFileName());
+                                fileDto.setFileUrl(taskFile.getFileUrl());
+                                return fileDto;
+                            })
+                            .collect(Collectors.toList());
                 }
                 taskFileList = taskFileService.listByFollowIdAndFollowType(followId,3);
                 if(taskFileList!=null&&!taskFileList.isEmpty()){
-                    audio = taskFileList.stream().map(k->k.getFileUrl()).collect(Collectors.toList());
+                    audio = taskFileList.stream()
+                            .map(taskFile -> {
+                                FileDto fileDto = new FileDto();
+                                fileDto.setFileName(taskFile.getFileName());
+                                fileDto.setFileUrl(taskFile.getFileUrl());
+                                return fileDto;
+                            })
+                            .collect(Collectors.toList());
                 }
                 staffMyShopTaskRecordPageVo.setPicture(picture);
                 staffMyShopTaskRecordPageVo.setVideo(video);
@@ -144,30 +215,62 @@
         if(myShopTaskRecordPageVoList!=null&&!myShopTaskRecordPageVoList.isEmpty()){
             Long followId;
             List<TaskFile> taskFileList;
-            List<String> picture = new ArrayList<>();
-            List<String> video = new ArrayList<>();
-            List<String> audio = new ArrayList<>();
+            List<FileDto> picture = new ArrayList<>();
+            List<FileDto> video = new ArrayList<>();
+            List<FileDto> audio = new ArrayList<>();
             Long userId;
-            SysUser sysUser;
+            SysStaff sysStaff;
+            HashSet<Long> userIdSet = new HashSet<>();
+            for(StaffMyShopTaskRecordPageVo staffMyShopTaskRecordPageVo : myShopTaskRecordPageVoList){
+                userIdSet.add(staffMyShopTaskRecordPageVo.getUserId());
+            }
+            List<Long> useIdList = new ArrayList<>(userIdSet);
+            List<SysStaff> sysStaffList = remoteConfigService.listSysStaffByIds(useIdList).getData();
+            Map<Long,SysStaff> sysStaffMap = sysStaffList.stream()
+                    .collect(Collectors.toMap(SysStaff::getUserId, Function.identity()));
             for(StaffMyShopTaskRecordPageVo staffMyShopTaskRecordPageVo : myShopTaskRecordPageVoList){
                 //获取任务用户信息
                 userId = staffMyShopTaskRecordPageVo.getUserId();
-                sysUser = remoteUserService.getSysUser(userId).getData();
-                staffMyShopTaskRecordPageVo.setUserName(sysUser.getNickName());
-                staffMyShopTaskRecordPageVo.setUserPicture(sysUser.getAvatar());
+                sysStaff = sysStaffMap.get(userId);
+                if(sysStaff!=null){
+                    staffMyShopTaskRecordPageVo.setUserName(sysStaff.getStaffName());
+                    staffMyShopTaskRecordPageVo.setUserPicture(sysStaff.getStaffAvatar());
+                    staffMyShopTaskRecordPageVo.setUserPosition(sysStaff.getStaffPost());
+                }
                 //获取任务详情文件
                 followId = staffMyShopTaskRecordPageVo.getFollowId();
                 taskFileList = taskFileService.listByFollowIdAndFollowType(followId,1);
                 if(taskFileList!=null&&!taskFileList.isEmpty()){
-                    picture = taskFileList.stream().map(k->k.getFileUrl()).collect(Collectors.toList());
+                    picture = taskFileList.stream()
+                            .map(taskFile -> {
+                                FileDto fileDto = new FileDto();
+                                fileDto.setFileName(taskFile.getFileName());
+                                fileDto.setFileUrl(taskFile.getFileUrl());
+                                return fileDto;
+                            })
+                            .collect(Collectors.toList());
                 }
                 taskFileList = taskFileService.listByFollowIdAndFollowType(followId,2);
                 if(taskFileList!=null&&!taskFileList.isEmpty()){
-                    video = taskFileList.stream().map(k->k.getFileUrl()).collect(Collectors.toList());
+                    video = taskFileList.stream()
+                            .map(taskFile -> {
+                                FileDto fileDto = new FileDto();
+                                fileDto.setFileName(taskFile.getFileName());
+                                fileDto.setFileUrl(taskFile.getFileUrl());
+                                return fileDto;
+                            })
+                            .collect(Collectors.toList());
                 }
                 taskFileList = taskFileService.listByFollowIdAndFollowType(followId,3);
                 if(taskFileList!=null&&!taskFileList.isEmpty()){
-                    audio = taskFileList.stream().map(k->k.getFileUrl()).collect(Collectors.toList());
+                    audio = taskFileList.stream()
+                            .map(taskFile -> {
+                                FileDto fileDto = new FileDto();
+                                fileDto.setFileName(taskFile.getFileName());
+                                fileDto.setFileUrl(taskFile.getFileUrl());
+                                return fileDto;
+                            })
+                            .collect(Collectors.toList());
                 }
                 staffMyShopTaskRecordPageVo.setPicture(picture);
                 staffMyShopTaskRecordPageVo.setVideo(video);

--
Gitblit v1.7.1