BatchFeignCallService.java 22.9 KB
Newer Older
刘基明's avatar
刘基明 committed
1 2 3
package com.tanpu.community.service;

import com.google.common.collect.Maps;
刘基明's avatar
刘基明 committed
4
import com.google.common.collect.Sets;
张辰's avatar
张辰 committed
5 6
import com.tanpu.biz.common.enums.RelTypeEnum;
import com.tanpu.biz.common.enums.user.UserLevelEnum;
刘基明's avatar
刘基明 committed
7 8
import com.tanpu.common.api.CommonResp;
import com.tanpu.common.enums.fund.ProductTypeEnum;
刘基明's avatar
刘基明 committed
9
import com.tanpu.common.util.JsonUtil;
刘基明's avatar
刘基明 committed
10 11 12
import com.tanpu.community.api.beans.qo.AttachmentDetailVo;
import com.tanpu.community.api.beans.qo.ThemeContentQo;
import com.tanpu.community.api.beans.qo.ThemeQo;
刘基明's avatar
刘基明 committed
13 14 15
import com.tanpu.community.api.beans.vo.ImagesDTO;
import com.tanpu.community.api.beans.vo.feign.course.CourseSimpleResp;
import com.tanpu.community.api.beans.vo.feign.course.ShortVideoBaseInfoResp;
16
import com.tanpu.community.api.beans.vo.feign.fatools.UserInfoResp;
刘基明's avatar
刘基明 committed
17 18 19
import com.tanpu.community.api.beans.vo.feign.product.FundInfoBaseResp;
import com.tanpu.community.api.beans.vo.feign.product.ProductInfoVO;
import com.tanpu.community.api.beans.vo.feign.zhibo.ZhiboListResp;
刘基明's avatar
刘基明 committed
20
import com.tanpu.community.dao.entity.community.FileRecordEntity;
21
import com.tanpu.community.dao.entity.community.TopicEntity;
刘基明's avatar
刘基明 committed
22
import com.tanpu.community.feign.course.FeignClientForCourse;
刘基明's avatar
刘基明 committed
23 24 25 26 27 28 29
import com.tanpu.community.feign.fatools.FeignClientForFatools;
import com.tanpu.community.feign.product.FeignClientForProducts;
import com.tanpu.community.feign.product.FeignForFund;
import com.tanpu.community.feign.product.FeignForPublicFund;
import com.tanpu.community.feign.tanpuroom.FeignClientForTanpuroom;
import com.tanpu.community.feign.zhibo.FeignClientForZhibo;
import org.springframework.beans.BeanUtils;
张辰's avatar
张辰 committed
30
import org.springframework.beans.factory.annotation.Autowired;
刘基明's avatar
刘基明 committed
31 32
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
33
import org.springframework.util.StringUtils;
刘基明's avatar
刘基明 committed
34 35

import javax.annotation.Resource;
刘基明's avatar
刘基明 committed
36
import java.util.*;
刘基明's avatar
刘基明 committed
37 38
import java.util.stream.Collectors;

刘基明's avatar
刘基明 committed
39 40 41
/**
 * 批量调用Feign查询接口
 */
刘基明's avatar
刘基明 committed
42
@Service
刘基明's avatar
刘基明 committed
43
public class BatchFeignCallService {
刘基明's avatar
刘基明 committed
44 45 46 47 48 49 50 51 52 53 54


    @Resource
    private FeignClientForTanpuroom feignClientForTanpuroom;

    @Resource
    private FeignClientForZhibo feignClientForZhibo;

    @Resource
    private FeignClientForProducts feignForProduct;

刘基明's avatar
刘基明 committed
55 56 57
    @Resource
    private FeignClientForCourse feignForCourse;

刘基明's avatar
刘基明 committed
58 59 60 61 62 63 64 65 66
    @Resource
    private FeignForFund feignForFund;

    @Resource
    private FeignForPublicFund feignForPublicFund;

    @Resource
    private FeignClientForFatools feignClientForFatools;

67
    @Resource
刘基明's avatar
刘基明 committed
68 69
    private OSSFileService ossFileService;

张辰's avatar
张辰 committed
70 71 72
    @Autowired
    private FeignService feignService;

73 74 75
    @Resource
    private TopicService topicService;

刘基明's avatar
刘基明 committed
76

刘基明's avatar
刘基明 committed
77

刘基明's avatar
刘基明 committed
78
    public void getAttachDetail(ThemeQo themeQo) {
刘基明's avatar
刘基明 committed
79 80
        ArrayList<ThemeQo> themeQos = new ArrayList<>();
        themeQos.add(themeQo);
刘基明's avatar
刘基明 committed
81
        getAttachDetailByBatch(themeQos);
刘基明's avatar
刘基明 committed
82 83 84
    }


刘基明's avatar
刘基明 committed
85
    public void getAttachDetailByBatch(List<ThemeQo> themeQos) {
刘基明's avatar
刘基明 committed
86 87 88 89
        // 短视频信息
        Map<String, ShortVideoBaseInfoResp> shortVideoMap = Maps.newHashMap();
        // 课程信息
        Map<String, ShortVideoBaseInfoResp> curriculumMap = Maps.newHashMap();
刘基明's avatar
刘基明 committed
90 91
        // 新课程信息
        Map<String, CourseSimpleResp> courseMap = Maps.newHashMap();
刘基明's avatar
刘基明 committed
92 93 94 95 96
        // 直播信息
        Map<String, ZhiboListResp> zhiboMap = Maps.newHashMap();
        // 设置产品信息
        Map<String, FundInfoBaseResp> fundMap = Maps.newHashMap();
        // 图片信息
刘基明's avatar
刘基明 committed
97
        Map<String, FileRecordEntity> imgMap = Maps.newHashMap();
98 99
        // 话题标题
        Map<String, String> topicMap = Maps.newHashMap();
刘基明's avatar
刘基明 committed
100
        // 图片信息
101
        Map<String, UserInfoResp> userMap = Maps.newHashMap();
刘基明's avatar
刘基明 committed
102
        // 批量查询资源信息
刘基明's avatar
刘基明 committed
103
        this.getResInfo(shortVideoMap, curriculumMap, courseMap, zhiboMap, fundMap, imgMap, topicMap, userMap, themeQos);
刘基明's avatar
刘基明 committed
104
        //逐个装入
刘基明's avatar
刘基明 committed
105
        setResInfo(themeQos, shortVideoMap, curriculumMap, courseMap, zhiboMap, fundMap, imgMap, userMap, topicMap);
刘基明's avatar
刘基明 committed
106 107 108 109 110 111 112 113 114 115 116 117 118 119

    }


    /**
     * 获取资源信息
     *
     * @param shortVideoMap
     * @param curriculumMap
     * @param zhiboMap
     * @param fundMap
     */
    private void getResInfo(Map<String, ShortVideoBaseInfoResp> shortVideoMap,
                            Map<String, ShortVideoBaseInfoResp> curriculumMap,
刘基明's avatar
刘基明 committed
120
                            Map<String, CourseSimpleResp> courseMap,
刘基明's avatar
刘基明 committed
121 122
                            Map<String, ZhiboListResp> zhiboMap,
                            Map<String, FundInfoBaseResp> fundMap,
刘基明's avatar
刘基明 committed
123
                            Map<String, FileRecordEntity> imgMap,
124
                            Map<String, String> topicMap,
125
                            Map<String, UserInfoResp> userMap,
刘基明's avatar
刘基明 committed
126
                            List<ThemeQo> themeQos
127
    ) {
刘基明's avatar
刘基明 committed
128
        // 白名单基金id
刘基明's avatar
刘基明 committed
129
        HashSet<String> tanpuFundIds = Sets.newHashSet();
刘基明's avatar
刘基明 committed
130
        // 私募基金id
刘基明's avatar
刘基明 committed
131
        HashSet<String> fundIds = Sets.newHashSet();
刘基明's avatar
刘基明 committed
132
        // 理财师导入
刘基明's avatar
刘基明 committed
133
        HashSet<String> ifaFundIds = Sets.newHashSet();
刘基明's avatar
刘基明 committed
134
        // 公募基金id
刘基明's avatar
刘基明 committed
135
        HashSet<String> publicFundIds = Sets.newHashSet();
刘基明's avatar
刘基明 committed
136
        // 无净值产品id
刘基明's avatar
刘基明 committed
137
        HashSet<String> notNetFundIds = Sets.newHashSet();
刘基明's avatar
刘基明 committed
138
        // 短视频id
刘基明's avatar
刘基明 committed
139
        HashSet<String> shortVideoIds = Sets.newHashSet();
刘基明's avatar
刘基明 committed
140
        // 直播id
刘基明's avatar
刘基明 committed
141
        HashSet<String> zhiboIds = Sets.newHashSet();
刘基明's avatar
刘基明 committed
142
        // 课程id
刘基明's avatar
刘基明 committed
143
        HashSet<String> curriculumIds = Sets.newHashSet();
刘基明's avatar
刘基明 committed
144
        // 新课程id
刘基明's avatar
刘基明 committed
145
        HashSet<String> courseIds = Sets.newHashSet();
刘基明's avatar
刘基明 committed
146
        // 图片id
刘基明's avatar
刘基明 committed
147
        HashSet<String> imageIds = Sets.newHashSet();
148
        // 话题id
刘基明's avatar
刘基明 committed
149
        HashSet<String> topicIds = Sets.newHashSet();
刘基明's avatar
刘基明 committed
150
        // 用户id
刘基明's avatar
刘基明 committed
151
        HashSet<String> userIds = Sets.newHashSet();
刘基明's avatar
刘基明 committed
152 153
        // 获取关联资源id
        if (themeQos != null) {
刘基明's avatar
刘基明 committed
154
            themeQos.forEach(o -> {
刘基明's avatar
刘基明 committed
155
                userIds.add(o.getAuthorId());
156 157 158 159
                if (o.getTopicId() != null) {
                    topicIds.add(o.getTopicId());
                }
            });
刘基明's avatar
刘基明 committed
160 161

            themeQos.forEach(o -> o.getContent().forEach(c -> {
刘基明's avatar
刘基明 committed
162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185
                        if (c.getType().equals(RelTypeEnum.LIVE.type)) {
                            zhiboIds.add(c.getValue());
                        } else if (c.getType().equals(RelTypeEnum.SHORT_VIDEO.type)) {
                            shortVideoIds.add(c.getValue());
                        } else if (c.getType().equals(RelTypeEnum.FUND.type)) {
                            if (c.getProductType() == ProductTypeEnum.PUBLIC.type) {
                                publicFundIds.add(c.getValue());
                            } else if (c.getProductType() == ProductTypeEnum.PRIVATE.type) {
                                fundIds.add(c.getValue());
                            } else if (c.getProductType() == ProductTypeEnum.TAMP.type) {
                                tanpuFundIds.add(c.getValue());
                            } else if (c.getProductType() == ProductTypeEnum.CUSTOMER_IMPORT.type) {
                                ifaFundIds.add(c.getValue());
                            } else if (c.getProductType() == ProductTypeEnum.NOT_NET_PRODUCT.type) {
                                notNetFundIds.add(c.getValue());
                            }

                        } else if (c.getType().equals(RelTypeEnum.VIDEO.type) || c.getType().equals(RelTypeEnum.AUDIO.type)) {
                            curriculumIds.add(c.getValue());
                        } else if (c.getType().equals(RelTypeEnum.SINGLE_IMG.type)) {
                            imageIds.add(c.getValue());
                        } else if (c.getType().equals(RelTypeEnum.NEW_COURSE_SECTION_AUDIO.type) ||
                                c.getType().equals(RelTypeEnum.NEW_COURSE_SECTION_VIDEO.type)) {
                            courseIds.add(c.getValue());
刘基明's avatar
刘基明 committed
186
                        }
刘基明's avatar
刘基明 committed
187
                    })
刘基明's avatar
刘基明 committed
188
            );
刘基明's avatar
刘基明 committed
189

刘基明's avatar
刘基明 committed
190 191 192
        }
        if (!CollectionUtils.isEmpty(shortVideoIds)) {
            // 短视频列表
张辰's avatar
张辰 committed
193
            List<ShortVideoBaseInfoResp> list = feignService.batchGetShortVideoBaseInfo(setToList(shortVideoIds));
刘基明's avatar
刘基明 committed
194
            shortVideoMap.putAll(list.stream().collect(Collectors.toMap(ShortVideoBaseInfoResp::getSourceId, item -> item,(oldValue,newValue)->oldValue)));
刘基明's avatar
刘基明 committed
195 196 197
        }
        if (!CollectionUtils.isEmpty(curriculumIds)) {
            // 课程列表
198 199
            List<ShortVideoBaseInfoResp> commonResp =
                    feignClientForFatools.getCurriculumByColumnRelId(setToList(curriculumIds));
刘基明's avatar
刘基明 committed
200
            if (commonResp != null && !CollectionUtils.isEmpty(commonResp)) {
刘基明's avatar
刘基明 committed
201
                curriculumMap.putAll(commonResp.stream()
刘基明's avatar
刘基明 committed
202
                        .collect(Collectors.toMap(ShortVideoBaseInfoResp::getColumnRelId, item -> item,(oldValue,newValue)->oldValue)));
刘基明's avatar
刘基明 committed
203 204
            }
        }
刘基明's avatar
刘基明 committed
205 206
        if (!CollectionUtils.isEmpty(courseIds)) {
            // 新版课程列表
张辰's avatar
张辰 committed
207 208
            List<CourseSimpleResp> list = feignService.getCourseSimpleList(setToList(courseIds));
            courseMap.putAll(list.stream().collect(Collectors.toMap(CourseSimpleResp::getCourseId, item -> item,(oldValue,newValue)->oldValue)));
刘基明's avatar
刘基明 committed
209
        }
刘基明's avatar
刘基明 committed
210 211
        if (!CollectionUtils.isEmpty(zhiboIds)) {
            // 直播列表
张辰's avatar
张辰 committed
212
            List<ZhiboListResp> list = feignService.getZhiboSimpleList(setToList(zhiboIds));
刘基明's avatar
刘基明 committed
213
                    feignClientForZhibo.simpleList(setToList(zhiboIds));
张辰's avatar
张辰 committed
214
            zhiboMap.putAll(list.stream().collect(Collectors.toMap(ZhiboListResp::getId, item -> item,(oldValue,newValue)->oldValue)));
刘基明's avatar
刘基明 committed
215 216
        }
        if (!CollectionUtils.isEmpty(imageIds)) {
刘基明's avatar
刘基明 committed
217
            // 查询图片
刘基明's avatar
刘基明 committed
218 219
            List<FileRecordEntity> fileRecordEntities =
                    ossFileService.queryByIds(setToList(imageIds));
刘基明's avatar
刘基明 committed
220 221
            if (!CollectionUtils.isEmpty(fileRecordEntities)) {
                imgMap.putAll(fileRecordEntities.stream().collect(Collectors
刘基明's avatar
刘基明 committed
222
                        .toMap(FileRecordEntity::getFileId, o -> o)));
刘基明's avatar
刘基明 committed
223
            }
刘基明's avatar
刘基明 committed
224

刘基明's avatar
刘基明 committed
225
        }
226 227
        if (!CollectionUtils.isEmpty(topicIds)) {
            // 查询话题标题
刘基明's avatar
刘基明 committed
228 229
            List<TopicEntity> topicEntities =
                    topicService.queryByIds(setToList(topicIds));
230 231 232 233 234
            if (!CollectionUtils.isEmpty(topicEntities)) {
                topicMap.putAll(topicEntities.stream().collect(Collectors
                        .toMap(TopicEntity::getTopicId, TopicEntity::getTopicTitle)));
            }
        }
刘基明's avatar
刘基明 committed
235 236
        if (!CollectionUtils.isEmpty(userIds)) {
            // 查询用户信息
张辰's avatar
张辰 committed
237
            List<UserInfoResp> queryUsersListNew = feignService.getUserList(setToList(userIds));
刘基明's avatar
刘基明 committed
238
            if (!CollectionUtils.isEmpty(userIds)) {
刘基明's avatar
刘基明 committed
239
                userMap.putAll(queryUsersListNew.stream().collect(Collectors
240
                        .toMap(UserInfoResp::getUserId, o -> o)));
刘基明's avatar
刘基明 committed
241
            }
刘基明's avatar
刘基明 committed
242

刘基明's avatar
刘基明 committed
243
        }
刘基明's avatar
刘基明 committed
244 245 246 247 248 249 250 251 252 253 254
        this.getFundInfo(tanpuFundIds, fundIds, publicFundIds, ifaFundIds, notNetFundIds, fundMap);
    }

    /**
     * 设置产品信息
     *
     * @param tanpuFundIds
     * @param fundIds
     * @param publicFundIds
     * @param fundMap
     */
刘基明's avatar
刘基明 committed
255 256 257 258 259
    private void getFundInfo(Set<String> tanpuFundIds,
                             Set<String> fundIds,
                             Set<String> publicFundIds,
                             Set<String> ifaFundIds,
                             Set<String> notNetFundIds,
刘基明's avatar
刘基明 committed
260 261 262 263 264 265 266 267 268 269 270
                             Map<String, FundInfoBaseResp> fundMap) {
        Map<String, FundInfoBaseResp> tampFundMap = null;
        Map<String, FundInfoBaseResp> privateFundMap = null;
        Map<String, FundInfoBaseResp> publicFundMap = null;
        Map<String, FundInfoBaseResp> ifaFundMap = null;
        Map<String, FundInfoBaseResp> notNetFundMap = null;
        if (!CollectionUtils.isEmpty(tanpuFundIds)) {
//            ProductListReq productListReq = ProductListReq.builder()
//                    .fundIds(Lists.newArrayList(tanpuFundIds))
//                    .build();
            // 探普产品
张辰's avatar
张辰 committed
271 272 273 274 275 276 277
            List<ProductInfoVO> list = feignService.getProductInfoByIds(setToList(tanpuFundIds));
            List<FundInfoBaseResp> fundInfoBaseRespList = list.stream().map(item -> {
                FundInfoBaseResp fundInfoBaseResp = FundInfoBaseResp.builder().build();
                BeanUtils.copyProperties(item, fundInfoBaseResp);
                return fundInfoBaseResp;
            }).collect(Collectors.toList());
            tampFundMap = fundInfoBaseRespList.stream().collect(Collectors.toMap(FundInfoBaseResp::getFundId, item -> item));
刘基明's avatar
刘基明 committed
278 279 280 281 282 283 284 285

            if (tampFundMap != null && tampFundMap.size() > 0) {
                fundMap.putAll(tampFundMap);
            }
        }
        // 私募产品
        if (!CollectionUtils.isEmpty(fundIds)) {
            // 私募产品
张辰's avatar
张辰 committed
286 287 288 289 290 291 292
            List<ProductInfoVO> list = feignService.getFundList(setToList(fundIds));
            List<FundInfoBaseResp> fundInfoBaseRespList = list.stream().map(item -> {
                FundInfoBaseResp fundInfoBaseResp = FundInfoBaseResp.builder().build();
                BeanUtils.copyProperties(item, fundInfoBaseResp);
                return fundInfoBaseResp;
            }).collect(Collectors.toList());
            privateFundMap = fundInfoBaseRespList.stream().collect(Collectors.toMap(FundInfoBaseResp::getFundId, item -> item));
刘基明's avatar
刘基明 committed
293 294 295 296 297 298 299 300

            if (privateFundMap != null && privateFundMap.size() > 0) {
                fundMap.putAll(privateFundMap);
            }
        }

        // 理财师导入产品
        if (!CollectionUtils.isEmpty(ifaFundIds)) {
张辰's avatar
张辰 committed
301 302 303 304 305 306 307 308
            List<ProductInfoVO> list = feignService.getPrivateFundList(setToList(ifaFundIds));
            List<FundInfoBaseResp> fundInfoBaseRespList = list.stream().map(item -> {
                FundInfoBaseResp fundInfoBaseResp = FundInfoBaseResp.builder().build();
                BeanUtils.copyProperties(item, fundInfoBaseResp);
                return fundInfoBaseResp;
            }).collect(Collectors.toList());
            ifaFundMap = fundInfoBaseRespList.stream().collect(Collectors.toMap(FundInfoBaseResp::getFundId, item -> item));

刘基明's avatar
刘基明 committed
309 310 311 312 313 314 315 316

            if (ifaFundMap != null && ifaFundMap.size() > 0) {
                fundMap.putAll(ifaFundMap);
            }
        }

        if (!CollectionUtils.isEmpty(publicFundIds)) {
            // 公募产品
张辰's avatar
张辰 committed
317 318 319 320 321 322 323 324
            List<ProductInfoVO> list = feignService.getPublicFundList(setToList(publicFundIds));
            List<FundInfoBaseResp> fundInfoBaseRespList = list.stream().map(item -> {
                FundInfoBaseResp fundInfoBaseResp = FundInfoBaseResp.builder().build();
                BeanUtils.copyProperties(item, fundInfoBaseResp);
                return fundInfoBaseResp;
            }).collect(Collectors.toList());
            publicFundMap = fundInfoBaseRespList.stream().collect(Collectors.toMap(FundInfoBaseResp::getFundId, item -> item));

刘基明's avatar
刘基明 committed
325 326 327 328 329 330 331
            if (publicFundMap != null && publicFundMap.size() > 0) {
                fundMap.putAll(publicFundMap);
            }
        }

        if (!CollectionUtils.isEmpty(notNetFundIds)) {
            // 无净值产品
刘基明's avatar
刘基明 committed
332 333
            CommonResp<List<ProductInfoVO>> notNetInfoResult =
                    feignForFund.getProductListNotNetInfo(setToList(notNetFundIds));
刘基明's avatar
刘基明 committed
334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353
            if (notNetInfoResult.isSuccess() && !CollectionUtils.isEmpty(notNetInfoResult.getData())) {
                List<FundInfoBaseResp> fundInfoBaseRespList = notNetInfoResult.getData().stream().map(item -> {
                    FundInfoBaseResp fundInfoBaseResp = FundInfoBaseResp.builder().build();
                    BeanUtils.copyProperties(item, fundInfoBaseResp);
                    return fundInfoBaseResp;
                }).collect(Collectors.toList());
                notNetFundMap = fundInfoBaseRespList.stream().collect(Collectors.toMap(FundInfoBaseResp::getFundId, item -> item));
            }
            if (notNetFundMap != null && notNetFundMap.size() > 0) {
                fundMap.putAll(notNetFundMap);
            }
        }
    }

    /**
     * 设置资源信息
     */
    private void setResInfo(List<ThemeQo> themeQos,
                            Map<String, ShortVideoBaseInfoResp> shortVideoMap,
                            Map<String, ShortVideoBaseInfoResp> curriculumMap,
刘基明's avatar
刘基明 committed
354
                            Map<String, CourseSimpleResp> courseMap,
刘基明's avatar
刘基明 committed
355 356
                            Map<String, ZhiboListResp> zhiboMap,
                            Map<String, FundInfoBaseResp> fundMap,
刘基明's avatar
刘基明 committed
357
                            Map<String, FileRecordEntity> imgUrlMap,
358
                            Map<String, UserInfoResp> userMap,
刘基明's avatar
刘基明 committed
359
                            Map<String, String> topicMap) {
刘基明's avatar
刘基明 committed
360
        for (ThemeQo themeQo : themeQos) {
刘基明's avatar
刘基明 committed
361
            if (!StringUtils.isEmpty(themeQo.getTopicId()) && topicMap.containsKey(themeQo.getTopicId())) {
刘基明's avatar
刘基明 committed
362
                //话题标题
363 364
                themeQo.setTopicTitle(topicMap.get(themeQo.getTopicId()));
            }
刘基明's avatar
刘基明 committed
365
            if (!StringUtils.isEmpty(themeQo.getAuthorId()) && userMap.containsKey(themeQo.getAuthorId())) {
刘基明's avatar
刘基明 committed
366
                //用户信息
367
                UserInfoResp userInfo = userMap.get(themeQo.getAuthorId());
刘基明's avatar
刘基明 committed
368
                //昵称头像简介
刘基明's avatar
刘基明 committed
369 370 371
                themeQo.setNickName(userInfo.getNickName());
                themeQo.setUserImg(userInfo.getHeadImageUrl());
                themeQo.setUserIntroduction(userInfo.getIntroduction());
刘基明's avatar
刘基明 committed
372
                //认证标签相关
刘基明's avatar
刘基明 committed
373 374 375 376 377
                themeQo.setUserType(userInfo.getUserType());
                themeQo.setLevelGrade(userInfo.getLevelGrade());
                themeQo.setUserInvestorType(userInfo.getUserInvestorType());
                themeQo.setBelongUserOrgId(userInfo.getBelongUserOrgId());
                themeQo.setBelongUserOrgName(userInfo.getBelongUserOrgName());
刘基明's avatar
刘基明 committed
378 379 380 381 382 383 384 385 386 387 388
                //工作室相关
                themeQo.setWorkshopName(userInfo.getWorkshopName());
                themeQo.setWorkshopStatus(userInfo.getWorkshopStatus());
                themeQo.setWorkshopIntroduction(userInfo.getWorkshopIntroduction());
                //首席投顾
                if (UserLevelEnum.USER_CHIEF_FINANCIAL_ADVISER.getCode() == userInfo.getLevelGrade()
                        && userInfo.getUserInfoNewChief() != null) {
                    themeQo.setNickName(userInfo.getUserInfoNewChief().getUserName());
                    themeQo.setUserImg(userInfo.getUserInfoNewChief().getHeadImageUrl());
                    themeQo.setUserIntroduction(userInfo.getUserInfoNewChief().getPersonalProfile());
                }
刘基明's avatar
刘基明 committed
389
            }
刘基明's avatar
刘基明 committed
390
            if (themeQo.getContent() == null) {
刘基明's avatar
刘基明 committed
391 392
                continue;
            }
刘基明's avatar
刘基明 committed
393 394 395
            for (ThemeContentQo themeContent : themeQo.getContent()) {
                if (themeContent.getType().equals(RelTypeEnum.LIVE.type)) {
                    if (zhiboMap.containsKey(themeContent.getValue())) {
刘基明's avatar
刘基明 committed
396
                        ZhiboListResp zhibo = zhiboMap.get(themeContent.getValue());
刘基明's avatar
刘基明 committed
397 398 399 400 401 402 403 404 405 406 407 408 409
                        themeContent.setDetail(AttachmentDetailVo.builder().zhibo(zhibo).build());
                    }
                } else if (themeContent.getType().equals(RelTypeEnum.SHORT_VIDEO.type)) {
                    if (shortVideoMap.containsKey(themeContent.getValue())) {
                        themeContent.setDetail(AttachmentDetailVo.builder()
                                .shortVideo(shortVideoMap.get(themeContent.getValue())).build());
                    }
                } else if (themeContent.getType().equals(RelTypeEnum.VIDEO.type) ||
                        themeContent.getType().equals(RelTypeEnum.AUDIO.type)) {
                    if (curriculumMap.containsKey(themeContent.getValue())) {
                        themeContent.setDetail(AttachmentDetailVo.builder()
                                .curriculum(curriculumMap.get(themeContent.getValue())).build());
                    }
刘基明's avatar
刘基明 committed
410 411 412 413 414 415
                } else if (themeContent.getType().equals(RelTypeEnum.NEW_COURSE_SECTION_VIDEO.type) ||
                        themeContent.getType().equals(RelTypeEnum.NEW_COURSE_SECTION_AUDIO.type)) {
                    if (courseMap.containsKey(themeContent.getValue())) {
                        themeContent.setDetail(AttachmentDetailVo.builder()
                                .course(courseMap.get(themeContent.getValue())).build());
                    }
刘基明's avatar
刘基明 committed
416 417 418 419 420 421 422 423 424 425
                } else if (themeContent.getType().equals(RelTypeEnum.FUND.type)) {
                    if (fundMap.containsKey(themeContent.getValue())) {
                        FundInfoBaseResp product = fundMap.get(themeContent.getValue());
                        // 推荐语
                        product.setRemark(themeContent.getRemark());
                        // 产品类型
                        product.setProductType(themeContent.getProductType());
                        themeContent.setDetail(AttachmentDetailVo.builder()
                                .product(product).build());
                    }
刘基明's avatar
刘基明 committed
426
                } else if (themeContent.getType().equals(RelTypeEnum.SINGLE_IMG.type)) {
刘基明's avatar
刘基明 committed
427
                    //单图封装到imglist列表中
428
                    if (imgUrlMap.containsKey(themeContent.getValue())) {
刘基明's avatar
刘基明 committed
429 430
                        FileRecordEntity imgEntity = imgUrlMap.get(themeContent.getValue());
                        String extInfo = imgEntity.getExtInfo();
刘基明's avatar
刘基明 committed
431
                        if (!StringUtils.isEmpty(extInfo)) {
刘基明's avatar
刘基明 committed
432 433 434
                            Map<String, Object> extMap = JsonUtil.toMap(extInfo);
                            ImagesDTO imagesDTO = ImagesDTO.builder().imgHeight((Integer) extMap.get("height"))
                                    .imgWidth((Integer) extMap.get("width"))
刘基明's avatar
刘基明 committed
435 436
                                    .remark(imgEntity.getUrl())
                                    .relId(imgEntity.getFileId())
刘基明's avatar
刘基明 committed
437 438 439
                                    .build();
                            themeContent.setImgList(Collections.singletonList(imagesDTO));
                        }
440
                    }
刘基明's avatar
刘基明 committed
441
                } else if (themeContent.getType().equals(RelTypeEnum.MULTIPLE_IMAGE.type)) {
刘基明's avatar
刘基明 committed
442 443 444 445 446 447 448 449 450 451 452 453 454 455
                    //多图写入图片宽高
                    List<ImagesDTO> imgList = themeContent.getImgList();
                    for (ImagesDTO imagesDTO : imgList) {
                        if (imgUrlMap.containsKey(imagesDTO.getRelId())) {
                            FileRecordEntity imgEntity = imgUrlMap.get(themeContent.getValue());
                            String extInfo = imgEntity.getExtInfo();
                            if (!StringUtils.isEmpty(extInfo)) {
                                Map<String, Object> extMap = JsonUtil.toMap(extInfo);
                                imagesDTO.setImgHeight((Integer) extMap.get("height"));
                                imagesDTO.setImgWidth((Integer) extMap.get("width"));
                            }
                        }
                    }

刘基明's avatar
刘基明 committed
456 457
                }
            }
刘基明's avatar
刘基明 committed
458 459 460 461 462 463 464 465 466 467
//            String formerThemeId = themeQo.getFormerThemeId();
//            if (!StringUtils.isEmpty(formerThemeId)) {
//                FormerThemeQo formerTheme = themeQo.getFormerTheme();
//
//                //单个查询详情
////            productService.getAttachDetail(formerTheme);
//
//                FormerThemeQo f = ConvertUtil.themeQo2FormerThemeQo(formerTheme);
//                themeQo.setFormerTheme(f);
//            }
刘基明's avatar
刘基明 committed
468
        }
刘基明's avatar
刘基明 committed
469

刘基明's avatar
刘基明 committed
470 471
    }

刘基明's avatar
刘基明 committed
472 473 474 475 476 477
    private List<String> setToList(Set<String> set) {
        List<String> l = new ArrayList<>();
        l.addAll(set);
        return l;
    }

刘基明's avatar
刘基明 committed
478 479 480 481 482
    //组装被转发主题
    private void buildFormerTheme(ThemeQo themeQo) {

    }

刘基明's avatar
刘基明 committed
483
}