puzhibing
2023-12-13 1772afb069b75871572c9c438bbd2bc403f864df
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);