|
|
@@ -25,6 +25,7 @@ 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.model.vo.contentplatform.XcxPlanItemExportVO;
|
|
|
import com.tzld.piaoquan.api.model.vo.contentplatform.XcxPlanItemVO;
|
|
|
import com.tzld.piaoquan.api.service.CgiReplyService;
|
|
|
import com.tzld.piaoquan.api.service.GhDetailService;
|
|
|
@@ -57,6 +58,7 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
|
import java.time.LocalDate;
|
|
|
+import java.time.ZoneId;
|
|
|
import java.io.ByteArrayInputStream;
|
|
|
import java.io.ByteArrayOutputStream;
|
|
|
import java.util.*;
|
|
|
@@ -2063,6 +2065,57 @@ public class ContentPlatformPlanServiceImpl implements ContentPlatformPlanServic
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 小程序投流计划导出:复用 xcxPlanList 的 filter(audiencePackage/title/时间范围),
|
|
|
+ * 不传时间范围时默认仅导出当天数据,最多导出 2000 条。
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public String xcxPlanExport(XcxPlanListParam param) {
|
|
|
+ // 未传时间窗口时,默认仅导出当天数据(本地时区 00:00 ~ 次日 00:00)
|
|
|
+ if (param.getCreateTimestampStart() == null && param.getCreateTimestampEnd() == null) {
|
|
|
+ ZoneId zone = ZoneId.systemDefault();
|
|
|
+ long startOfToday = LocalDate.now().atStartOfDay(zone).toInstant().toEpochMilli();
|
|
|
+ long startOfTomorrow = LocalDate.now().plusDays(1).atStartOfDay(zone).toInstant().toEpochMilli();
|
|
|
+ param.setCreateTimestampStart(startOfToday);
|
|
|
+ param.setCreateTimestampEnd(startOfTomorrow);
|
|
|
+ }
|
|
|
+ // 强制分页参数:最多导出 2000 条
|
|
|
+ param.setPageNum(1);
|
|
|
+ param.setPageSize(2000);
|
|
|
+
|
|
|
+ ContentPlatformAccount loginAccount = LoginUserContext.getUser();
|
|
|
+ List<ContentPlatformXcxPlan> planList = planMapperExt.getXcxPlanList(param,
|
|
|
+ loginAccount.getId(), 0, param.getPageSize());
|
|
|
+ List<XcxPlanItemVO> list = buildXcxPlanItemVOList(planList);
|
|
|
+ return generateXcxPlanExcelFile(list);
|
|
|
+ }
|
|
|
+
|
|
|
+ private String generateXcxPlanExcelFile(List<XcxPlanItemVO> dataList) {
|
|
|
+ List<XcxPlanItemExportVO> list = new ArrayList<>();
|
|
|
+ if (CollectionUtils.isNotEmpty(dataList)) {
|
|
|
+ for (XcxPlanItemVO data : dataList) {
|
|
|
+ XcxPlanItemExportVO vo = new XcxPlanItemExportVO();
|
|
|
+ vo.setAudiencePackage(data.getAudiencePackage());
|
|
|
+ vo.setTitle(data.getTitle());
|
|
|
+ vo.setCover(data.getShareCover() != null ? data.getShareCover() : data.getCover());
|
|
|
+ vo.setPageUrl(data.getPageUrl());
|
|
|
+ vo.setRemark(data.getRemark());
|
|
|
+ if (Objects.nonNull(data.getCreateTimestamp())) {
|
|
|
+ vo.setCreateTime(DateUtil.getDateString(data.getCreateTimestamp(), "yyyy-MM-dd HH:mm:ss"));
|
|
|
+ }
|
|
|
+ list.add(vo);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ list.add(new XcxPlanItemExportVO());
|
|
|
+ }
|
|
|
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
|
|
|
+ EasyExcel.write(out, XcxPlanItemExportVO.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;
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public List<XcxPlanItemVO> xcxPlanSave(XcxPlanSaveParam param) {
|
|
|
ContentPlatformAccount loginUser = LoginUserContext.getUser();
|