jiangqs
2023-06-18 c00d0d3bc399b6648145dfd955cedbea90f5f99d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
package com.ruoyi.shop.service.impl.task;
 
 
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.shop.domain.dto.MerAgencyTaskPageDto;
import com.ruoyi.shop.domain.dto.MgtShopTaskPageDto;
import com.ruoyi.shop.domain.pojo.task.AgencyTaskRecord;
import com.ruoyi.shop.domain.pojo.task.TaskFile;
import com.ruoyi.shop.domain.vo.MerAgencyTaskRecordPageVo;
import com.ruoyi.shop.domain.vo.MgtAgencyTaskRecordPageVo;
import com.ruoyi.shop.mapper.task.AgencyTaskRecordMapper;
import com.ruoyi.shop.service.task.AgencyTaskRecordService;
import com.ruoyi.shop.service.task.TaskFileService;
import com.ruoyi.system.api.domain.poji.sys.SysUser;
import com.ruoyi.system.api.service.RemoteUserService;
import org.springframework.stereotype.Service;
 
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
 
/**
 * <p>
 * 会员跟进任务记录 服务实现类
 * </p>
 *
 * @author jqs
 * @since 2023-05-07
 */
@Service
public class AgencyTaskRecordServiceImpl extends ServiceImpl<AgencyTaskRecordMapper, AgencyTaskRecord> implements AgencyTaskRecordService {
 
    @Resource
    private AgencyTaskRecordMapper agencyTaskRecordMapper;
 
    @Resource
    private TaskFileService taskFileService;
 
    @Resource
    private RemoteUserService remoteUserService;
    /**
     *
     * @param page
     * @param merAgencyTaskPageDto
     * @return
     */
    @Override
    public List<MerAgencyTaskRecordPageVo> pageMerAgencyTaskRecord (Page page, MerAgencyTaskPageDto merAgencyTaskPageDto){
        List<MerAgencyTaskRecordPageVo> merAgencyTaskRecordPageVoList = agencyTaskRecordMapper.pageMerAgencyTaskRecord(page, merAgencyTaskPageDto);
        if(merAgencyTaskRecordPageVoList!=null&&!merAgencyTaskRecordPageVoList.isEmpty()){
            Long followId;
            List<TaskFile> taskFileList;
            List<String> picture = new ArrayList<>();
            List<String> video = new ArrayList<>();
            List<String> audio = new ArrayList<>();
            //获取跟进详情文件
            for(MerAgencyTaskRecordPageVo merAgencyTaskRecordPageVo : merAgencyTaskRecordPageVoList){
                followId = merAgencyTaskRecordPageVo.getFollowId();
                taskFileList = taskFileService.listByFollowIdAndFollowType(followId,1);
                if(taskFileList!=null&&!taskFileList.isEmpty()){
                    picture = taskFileList.stream().map(k->k.getFileUrl()).collect(Collectors.toList());
                }
                taskFileList = taskFileService.listByFollowIdAndFollowType(followId,2);
                if(taskFileList!=null&&!taskFileList.isEmpty()){
                    video = taskFileList.stream().map(k->k.getFileUrl()).collect(Collectors.toList());
                }
                taskFileList = taskFileService.listByFollowIdAndFollowType(followId,3);
                if(taskFileList!=null&&!taskFileList.isEmpty()){
                    audio = taskFileList.stream().map(k->k.getFileUrl()).collect(Collectors.toList());
                }
                merAgencyTaskRecordPageVo.setPicture(picture);
                merAgencyTaskRecordPageVo.setVideo(video);
                merAgencyTaskRecordPageVo.setAudio(audio);
            }
        }
        return merAgencyTaskRecordPageVoList;
    }
 
 
    /**
     * 平台分页获取代理商跟进任务
     * @return
     */
    @Override
    public List<MgtAgencyTaskRecordPageVo> pageMgtAgencyFollow(MgtShopTaskPageDto mgtShopTaskPageDto){
        List<MgtAgencyTaskRecordPageVo> mgtAgencyTaskRecordPageVoList = agencyTaskRecordMapper.pageMgtAgencyFollow(mgtShopTaskPageDto);
        if(mgtAgencyTaskRecordPageVoList!=null&&!mgtAgencyTaskRecordPageVoList.isEmpty()){
            Long followId;
            List<TaskFile> taskFileList;
            List<String> picture = new ArrayList<>();
            List<String> video = new ArrayList<>();
            List<String> audio = new ArrayList<>();
            Long userId;
            SysUser sysUser;
            for(MgtAgencyTaskRecordPageVo mgtAgencyTaskRecordPageVo : mgtAgencyTaskRecordPageVoList){
                //获取任务用户信息
                userId = mgtAgencyTaskRecordPageVo.getUserId();
                sysUser = remoteUserService.getSysUser(userId).getData();
                mgtAgencyTaskRecordPageVo.setUserName(sysUser.getNickName());
                mgtAgencyTaskRecordPageVo.setUserPicture(sysUser.getAvatar());
                //获取任务详情文件
                followId = mgtAgencyTaskRecordPageVo.getFollowId();
                taskFileList = taskFileService.listByFollowIdAndFollowType(followId,1);
                if(taskFileList!=null&&!taskFileList.isEmpty()){
                    picture = taskFileList.stream().map(k->k.getFileUrl()).collect(Collectors.toList());
                }
                taskFileList = taskFileService.listByFollowIdAndFollowType(followId,2);
                if(taskFileList!=null&&!taskFileList.isEmpty()){
                    video = taskFileList.stream().map(k->k.getFileUrl()).collect(Collectors.toList());
                }
                taskFileList = taskFileService.listByFollowIdAndFollowType(followId,3);
                if(taskFileList!=null&&!taskFileList.isEmpty()){
                    audio = taskFileList.stream().map(k->k.getFileUrl()).collect(Collectors.toList());
                }
                mgtAgencyTaskRecordPageVo.setPicture(picture);
                mgtAgencyTaskRecordPageVo.setVideo(video);
                mgtAgencyTaskRecordPageVo.setAudio(audio);
            }
        }
        return mgtAgencyTaskRecordPageVoList;
    }
}