|  | @@ -5,7 +5,7 @@ import com.tzld.piaoquan.api.common.enums.ExceptionEnum;
 | 
	
		
			
				|  |  |  import com.tzld.piaoquan.api.common.exception.CommonException;
 | 
	
		
			
				|  |  |  import com.tzld.piaoquan.api.dao.mapper.contentplatform.ContentPlatformGzhPlanMapper;
 | 
	
		
			
				|  |  |  import com.tzld.piaoquan.api.dao.mapper.contentplatform.ContentPlatformGzhPlanVideoMapper;
 | 
	
		
			
				|  |  | -import com.tzld.piaoquan.api.dao.mapper.contentplatform.ContentPlatformQwPlanMapper;
 | 
	
		
			
				|  |  | +import com.tzld.piaoquan.api.dao.mapper.contentplatform.ContentPlatformQwPlanVideoMapper;
 | 
	
		
			
				|  |  |  import com.tzld.piaoquan.api.dao.mapper.contentplatform.ext.ContentPlatformPlanMapperExt;
 | 
	
		
			
				|  |  |  import com.tzld.piaoquan.api.model.config.LoginUserContext;
 | 
	
		
			
				|  |  |  import com.tzld.piaoquan.api.model.param.contentplatform.*;
 | 
	
	
		
			
				|  | @@ -22,6 +22,8 @@ import com.tzld.piaoquan.api.service.contentplatform.ContentPlatformPlanService;
 | 
	
		
			
				|  |  |  import com.tzld.piaoquan.growth.common.common.enums.GhTypeEnum;
 | 
	
		
			
				|  |  |  import com.tzld.piaoquan.growth.common.common.enums.StrategyStatusEnum;
 | 
	
		
			
				|  |  |  import com.tzld.piaoquan.growth.common.model.po.GhDetail;
 | 
	
		
			
				|  |  | +import com.tzld.piaoquan.growth.common.service.MessageAttachmentService;
 | 
	
		
			
				|  |  | +import com.tzld.piaoquan.growth.common.utils.MessageUtil;
 | 
	
		
			
				|  |  |  import com.tzld.piaoquan.growth.common.utils.page.Page;
 | 
	
		
			
				|  |  |  import lombok.extern.slf4j.Slf4j;
 | 
	
		
			
				|  |  |  import org.apache.commons.collections4.CollectionUtils;
 | 
	
	
		
			
				|  | @@ -33,6 +35,7 @@ import java.util.ArrayList;
 | 
	
		
			
				|  |  |  import java.util.List;
 | 
	
		
			
				|  |  |  import java.util.Map;
 | 
	
		
			
				|  |  |  import java.util.Objects;
 | 
	
		
			
				|  |  | +import java.util.function.Function;
 | 
	
		
			
				|  |  |  import java.util.stream.Collectors;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  @Slf4j
 | 
	
	
		
			
				|  | @@ -46,7 +49,7 @@ public class ContentPlatformPlanServiceImpl implements ContentPlatformPlanServic
 | 
	
		
			
				|  |  |      @Autowired
 | 
	
		
			
				|  |  |      private ContentPlatformGzhPlanVideoMapper gzhPlanVideoMapper;
 | 
	
		
			
				|  |  |      @Autowired
 | 
	
		
			
				|  |  | -    private ContentPlatformQwPlanMapper qwPlanMapper;
 | 
	
		
			
				|  |  | +    private ContentPlatformQwPlanVideoMapper qwPlanVideoMapper;
 | 
	
		
			
				|  |  |      @Autowired
 | 
	
		
			
				|  |  |      private ContentPlatformCooperateAccountService cooperateAccountService;
 | 
	
		
			
				|  |  |      @Autowired
 | 
	
	
		
			
				|  | @@ -55,6 +58,8 @@ public class ContentPlatformPlanServiceImpl implements ContentPlatformPlanServic
 | 
	
		
			
				|  |  |      private AigcApiService aigcApiService;
 | 
	
		
			
				|  |  |      @Autowired
 | 
	
		
			
				|  |  |      private ManagerApiService managerApiService;
 | 
	
		
			
				|  |  | +    @Autowired
 | 
	
		
			
				|  |  | +    private MessageAttachmentService messageAttachmentService;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      @Override
 | 
	
		
			
				|  |  |      public Page<GzhPlanItemVO> gzhPlanList(GzhPlanListParam param) {
 | 
	
	
		
			
				|  | @@ -251,6 +256,12 @@ public class ContentPlatformPlanServiceImpl implements ContentPlatformPlanServic
 | 
	
		
			
				|  |  |          return result;
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +    @Override
 | 
	
		
			
				|  |  | +    public List<String> getVideoContentCategoryList() {
 | 
	
		
			
				|  |  | +        String dt = planMapperExt.getVideoMaxDt();
 | 
	
		
			
				|  |  | +        return planMapperExt.getVideoCategoryList(dt);
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |      @Override
 | 
	
		
			
				|  |  |      public List<String> getVideoContentCoverFrameList(VideoContentCoverFrameParam param) {
 | 
	
		
			
				|  |  |          return managerApiService.getCoverImagePaths(param.getVideoId());
 | 
	
	
		
			
				|  | @@ -258,11 +269,73 @@ public class ContentPlatformPlanServiceImpl implements ContentPlatformPlanServic
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      @Override
 | 
	
		
			
				|  |  |      public Page<QwPlanItemVO> qwPlanList(QwPlanListParam param) {
 | 
	
		
			
				|  |  | -        return null;
 | 
	
		
			
				|  |  | +        ContentPlatformAccount loginAccount = LoginUserContext.getUser();
 | 
	
		
			
				|  |  | +        Page<QwPlanItemVO> result = new Page<>(param.getPageNum(), param.getPageSize());
 | 
	
		
			
				|  |  | +        int offset = (param.getPageNum() - 1) * param.getPageSize();
 | 
	
		
			
				|  |  | +        int count = planMapperExt.getQwPlanCount(param, loginAccount.getId());
 | 
	
		
			
				|  |  | +        result.setTotalSize(count);
 | 
	
		
			
				|  |  | +        if (count == 0) {
 | 
	
		
			
				|  |  | +            return result;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        List<ContentPlatformQwPlan> planList = planMapperExt.getQwPlanList(param,
 | 
	
		
			
				|  |  | +                loginAccount.getId(), offset, param.getPageSize());
 | 
	
		
			
				|  |  | +        List<QwPlanItemVO> list = buildQwPlanItemVOList(planList);
 | 
	
		
			
				|  |  | +        result.setObjs(list);
 | 
	
		
			
				|  |  | +        return result;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    private List<QwPlanItemVO> buildQwPlanItemVOList(List<ContentPlatformQwPlan> planList) {
 | 
	
		
			
				|  |  | +        if (CollectionUtils.isEmpty(planList)) {
 | 
	
		
			
				|  |  | +            return null;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        List<Long> planIds = planList.stream().map(ContentPlatformQwPlan::getId).collect(Collectors.toList());
 | 
	
		
			
				|  |  | +        List<ContentPlatformQwPlanVideo> videoList = getQwPlanVideoList(planIds);
 | 
	
		
			
				|  |  | +        Map<Long, ContentPlatformQwPlanVideo> videoMap = videoList.stream()
 | 
	
		
			
				|  |  | +                .collect(Collectors.toMap(ContentPlatformQwPlanVideo::getPlanId, Function.identity()));
 | 
	
		
			
				|  |  | +        List<QwPlanItemVO> result = new ArrayList<>();
 | 
	
		
			
				|  |  | +        for (ContentPlatformQwPlan qwPlan : planList) {
 | 
	
		
			
				|  |  | +            QwPlanItemVO planItemVO = new QwPlanItemVO();
 | 
	
		
			
				|  |  | +            planItemVO.setId(qwPlan.getId());
 | 
	
		
			
				|  |  | +            planItemVO.setType(qwPlan.getType());
 | 
	
		
			
				|  |  | +            planItemVO.setScene(qwPlan.getScene());
 | 
	
		
			
				|  |  | +            planItemVO.setPageUrl(qwPlan.getPageUrl());
 | 
	
		
			
				|  |  | +            planItemVO.setCreateTimestamp(qwPlan.getCreateTimestamp());
 | 
	
		
			
				|  |  | +            ContentPlatformQwPlanVideo videoItem = videoMap.get(qwPlan.getId());
 | 
	
		
			
				|  |  | +            if (Objects.nonNull(videoItem)) {
 | 
	
		
			
				|  |  | +                planItemVO.setTitle(videoItem.getTitle());
 | 
	
		
			
				|  |  | +                planItemVO.setCover(videoItem.getCover());
 | 
	
		
			
				|  |  | +                planItemVO.setVideo(videoItem.getVideo());
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            result.add(planItemVO);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        return result;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    private List<ContentPlatformQwPlanVideo> getQwPlanVideoList(List<Long> planIds) {
 | 
	
		
			
				|  |  | +        ContentPlatformQwPlanVideoExample example = new ContentPlatformQwPlanVideoExample();
 | 
	
		
			
				|  |  | +        example.createCriteria().andPlanIdIn(planIds);
 | 
	
		
			
				|  |  | +        return qwPlanVideoMapper.selectByExample(example);
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      @Override
 | 
	
		
			
				|  |  |      public void qwPlanSave(QwPlanSaveParam param) {
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | +        ContentPlatformAccount loginUser = LoginUserContext.getUser();
 | 
	
		
			
				|  |  | +        Long now = System.currentTimeMillis();
 | 
	
		
			
				|  |  | +        List<ContentPlatformQwPlan> saveList = new ArrayList<>();
 | 
	
		
			
				|  |  | +        for (QwPlanSaveVideoParam videoParam : param.getVideoList()) {
 | 
	
		
			
				|  |  | +            ContentPlatformQwPlan qwPlan = new ContentPlatformQwPlan();
 | 
	
		
			
				|  |  | +            qwPlan.setType(param.getType());
 | 
	
		
			
				|  |  | +            qwPlan.setScene(videoParam.getScene());
 | 
	
		
			
				|  |  | +            String pageUrl = messageAttachmentService.getPage(loginUser.getChannel(), "wxbdd2a2e93d9a6e25",
 | 
	
		
			
				|  |  | +                    "dyyjs", "企微", "社群", "位置X", videoParam.getVideoId());
 | 
	
		
			
				|  |  | +            String rootSourceId = MessageUtil.getRootSourceId(pageUrl);
 | 
	
		
			
				|  |  | +            qwPlan.setPageUrl(pageUrl);
 | 
	
		
			
				|  |  | +            qwPlan.setRootSourceId(rootSourceId);
 | 
	
		
			
				|  |  | +            qwPlan.setCreateAccountId(loginUser.getId());
 | 
	
		
			
				|  |  | +            qwPlan.setCreateTimestamp(now);
 | 
	
		
			
				|  |  | +            saveList.add(qwPlan);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        planMapperExt.batchInsertQwPlan(saveList);
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  }
 |