|
|
@@ -1,8 +1,11 @@
|
|
|
package com.tzld.piaoquan.api.service.contentplatform.impl;
|
|
|
|
|
|
+import com.alibaba.excel.EasyExcel;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.google.common.collect.Lists;
|
|
|
+import com.stuuudy.commons.external.filestorage.enums.EnumFileType;
|
|
|
+import com.stuuudy.commons.external.filestorage.enums.EnumPublicBuckets;
|
|
|
import com.tzld.piaoquan.api.common.enums.ExceptionEnum;
|
|
|
import com.tzld.piaoquan.api.common.enums.contentplatform.*;
|
|
|
import com.tzld.piaoquan.api.common.exception.CommonException;
|
|
|
@@ -19,6 +22,7 @@ import com.tzld.piaoquan.api.model.po.contentplatform.*;
|
|
|
import com.tzld.piaoquan.api.model.vo.GhDetailVo;
|
|
|
import com.tzld.piaoquan.api.model.vo.contentplatform.GzhPlanItemVO;
|
|
|
import com.tzld.piaoquan.api.model.vo.contentplatform.GzhPlanVideoContentItemVO;
|
|
|
+import com.tzld.piaoquan.api.model.vo.contentplatform.QwPlanItemExportVO;
|
|
|
import com.tzld.piaoquan.api.model.vo.contentplatform.QwPlanItemVO;
|
|
|
import com.tzld.piaoquan.api.model.vo.contentplatform.VideoContentItemVO;
|
|
|
import com.tzld.piaoquan.api.service.CgiReplyService;
|
|
|
@@ -27,6 +31,8 @@ import com.tzld.piaoquan.api.service.VideoMultiService;
|
|
|
import com.tzld.piaoquan.api.service.contentplatform.ContentPlatformAccountService;
|
|
|
import com.tzld.piaoquan.api.service.contentplatform.ContentPlatformCooperateAccountService;
|
|
|
import com.tzld.piaoquan.api.service.contentplatform.ContentPlatformPlanService;
|
|
|
+import com.tzld.piaoquan.api.util.AliOssFileTool;
|
|
|
+import com.tzld.piaoquan.api.util.CdnUtil;
|
|
|
import com.tzld.piaoquan.api.util.TitleNormalizer;
|
|
|
import com.tzld.piaoquan.growth.common.common.enums.GhTypeEnum;
|
|
|
import com.tzld.piaoquan.growth.common.common.enums.StrategyStatusEnum;
|
|
|
@@ -35,6 +41,7 @@ import com.tzld.piaoquan.growth.common.model.bo.VideoDetail;
|
|
|
import com.tzld.piaoquan.growth.common.model.po.CgiReplyBucketData;
|
|
|
import com.tzld.piaoquan.growth.common.model.po.GhDetail;
|
|
|
import com.tzld.piaoquan.growth.common.service.MessageAttachmentService;
|
|
|
+import com.tzld.piaoquan.growth.common.utils.DateUtil;
|
|
|
import com.tzld.piaoquan.growth.common.utils.MessageUtil;
|
|
|
import com.tzld.piaoquan.growth.common.utils.RedisUtils;
|
|
|
import com.tzld.piaoquan.growth.common.utils.page.Page;
|
|
|
@@ -48,6 +55,8 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
|
import java.time.LocalDate;
|
|
|
+import java.io.ByteArrayInputStream;
|
|
|
+import java.io.ByteArrayOutputStream;
|
|
|
import java.util.*;
|
|
|
import java.util.concurrent.ExecutorService;
|
|
|
import java.util.concurrent.Executors;
|
|
|
@@ -1444,6 +1453,87 @@ public class ContentPlatformPlanServiceImpl implements ContentPlatformPlanServic
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 企微计划列表导出:
|
|
|
+ * 复用 /qw/list 的过滤条件(type/scene/subChannel/title)与起止日期过滤,
|
|
|
+ * 不传起止日期时默认只导出当天(1天)数据,最多导出 2000 条。
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public String qwPlanExport(QwPlanListParam param) {
|
|
|
+ // 未传日期时,默认仅导出当天数据
|
|
|
+ if (!StringUtils.hasText(param.getStartDate()) && !StringUtils.hasText(param.getEndDate())) {
|
|
|
+ String today = DateUtil.getThatDayDateString();
|
|
|
+ param.setStartDate(today);
|
|
|
+ param.setEndDate(today);
|
|
|
+ } else if (!StringUtils.hasText(param.getStartDate())) {
|
|
|
+ param.setStartDate(param.getEndDate());
|
|
|
+ } else if (!StringUtils.hasText(param.getEndDate())) {
|
|
|
+ param.setEndDate(param.getStartDate());
|
|
|
+ }
|
|
|
+ // 强制分页参数:最多导出 2000 条
|
|
|
+ param.setPageNum(1);
|
|
|
+ param.setPageSize(2000);
|
|
|
+
|
|
|
+ ContentPlatformAccount loginAccount = LoginUserContext.getUser();
|
|
|
+ List<ContentPlatformQwPlan> planList = planMapperExt.getQwPlanList(param,
|
|
|
+ loginAccount.getId(), 0, param.getPageSize());
|
|
|
+ List<QwPlanItemVO> list = buildQwPlanItemVOList(planList);
|
|
|
+ return generateQwPlanExcelFile(list);
|
|
|
+ }
|
|
|
+
|
|
|
+ private String generateQwPlanExcelFile(List<QwPlanItemVO> dataList) {
|
|
|
+ List<QwPlanItemExportVO> list = new ArrayList<>();
|
|
|
+ if (CollectionUtils.isNotEmpty(dataList)) {
|
|
|
+ for (QwPlanItemVO data : dataList) {
|
|
|
+ QwPlanItemExportVO vo = new QwPlanItemExportVO();
|
|
|
+ vo.setType(convertQwPlanTypeText(data.getType()));
|
|
|
+ vo.setScene(convertQwPlanSceneText(data.getScene()));
|
|
|
+ vo.setSubChannel(data.getSubChannel());
|
|
|
+ vo.setTitle(data.getTitle());
|
|
|
+ vo.setCover(data.getShareCover());
|
|
|
+ vo.setPageUrl(data.getPageUrl());
|
|
|
+ if (Objects.nonNull(data.getCreateTimestamp())) {
|
|
|
+ vo.setCreateTime(DateUtil.getDateString(data.getCreateTimestamp(), "yyyy-MM-dd HH:mm:ss"));
|
|
|
+ }
|
|
|
+ list.add(vo);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ list.add(new QwPlanItemExportVO());
|
|
|
+ }
|
|
|
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
|
|
|
+ EasyExcel.write(out, QwPlanItemExportVO.class).sheet("企微计划").doWrite(list);
|
|
|
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(out.toByteArray());
|
|
|
+ String fileName = "企微计划_" + System.currentTimeMillis() + ".xls";
|
|
|
+ AliOssFileTool.saveInPublicReturnHost(byteArrayInputStream, EnumPublicBuckets.PUBBUCKET, fileName, EnumFileType.TEMP_PICTURE);
|
|
|
+ return CdnUtil.DOWNLOAD_CDN_URL_HOST_PICTURE + fileName;
|
|
|
+ }
|
|
|
+
|
|
|
+ private String convertQwPlanTypeText(Integer type) {
|
|
|
+ if (Objects.isNull(type)) {
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+ if (type == 0) {
|
|
|
+ return "自动回复";
|
|
|
+ }
|
|
|
+ if (type == 1) {
|
|
|
+ return "每日推送";
|
|
|
+ }
|
|
|
+ return String.valueOf(type);
|
|
|
+ }
|
|
|
+
|
|
|
+ private String convertQwPlanSceneText(Integer scene) {
|
|
|
+ if (Objects.isNull(scene)) {
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+ if (scene == 0) {
|
|
|
+ return "群发";
|
|
|
+ }
|
|
|
+ if (scene == 1) {
|
|
|
+ return "单发";
|
|
|
+ }
|
|
|
+ return String.valueOf(scene);
|
|
|
+ }
|
|
|
+
|
|
|
private List<QwPlanItemVO> buildQwPlanItemVOList(List<ContentPlatformQwPlan> planList) {
|
|
|
if (CollectionUtils.isEmpty(planList)) {
|
|
|
return null;
|