|
@@ -6,17 +6,16 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.cslg.ppa.common.core.auth.Response;
|
|
|
import com.cslg.ppa.common.exception.ExceptionEnum;
|
|
|
import com.cslg.ppa.common.exception.XiaoShiException;
|
|
|
+import com.cslg.ppa.common.utils.DateUtil;
|
|
|
import com.cslg.ppa.common.utils.FileUtils;
|
|
|
import com.cslg.ppa.dto.*;
|
|
|
import com.cslg.ppa.entity.*;
|
|
|
import com.cslg.ppa.entity.commom.Records;
|
|
|
+import com.cslg.ppa.mapper.ArticleInfoMapper;
|
|
|
import com.cslg.ppa.mapper.AssoReportArticleMapper;
|
|
|
import com.cslg.ppa.mapper.ReportMapper;
|
|
|
import com.cslg.ppa.service.commom.FileManagerService;
|
|
|
-import com.cslg.ppa.vo.ExportReportDetailVO;
|
|
|
-import com.cslg.ppa.vo.ExportReportVO;
|
|
|
-import com.cslg.ppa.vo.SelectAssoReportArticleVO;
|
|
|
-import com.cslg.ppa.vo.SelectReportListVO;
|
|
|
+import com.cslg.ppa.vo.*;
|
|
|
import com.deepoove.poi.XWPFTemplate;
|
|
|
import com.deepoove.poi.config.Configure;
|
|
|
import com.deepoove.poi.config.ConfigureBuilder;
|
|
@@ -58,6 +57,10 @@ public class ReportService extends ServiceImpl<ReportMapper, Report> {
|
|
|
private ReportMapper reportMapper;
|
|
|
@Autowired
|
|
|
private AssoReportArticleMapper assoReportArticleMapper;
|
|
|
+ @Autowired
|
|
|
+ private ArticleInfoMapper articleInfoMapper;
|
|
|
+
|
|
|
+ private static final List<String> SPECIAL_KEYWORDS = Arrays.asList("活动", "研讨", "座谈会", "举办", "举行", "培训", "课堂");
|
|
|
|
|
|
public String selectReportList(SelectReportListDTO vo) {
|
|
|
LambdaQueryWrapper<Report> wrapper = new LambdaQueryWrapper<>();
|
|
@@ -258,6 +261,85 @@ public class ReportService extends ServiceImpl<ReportMapper, Report> {
|
|
|
return fileGuid;
|
|
|
}
|
|
|
|
|
|
+ public String oneClickExport() {
|
|
|
+ OneClickExportDTO vo = new OneClickExportDTO();
|
|
|
+ vo.setBeginTime(DateUtil.getFirstDayOfMonthStr());
|
|
|
+ vo.setEndTime(DateUtil.getLastDayOfMonthStr());
|
|
|
+ List<OneClickExportVO> articleVOS = articleInfoMapper.selectArticleList(vo);
|
|
|
+ List<ExportReportVO> reportVOS = new ArrayList<>();
|
|
|
+ if (!CollectionUtils.isEmpty(articleVOS)) {
|
|
|
+ Map<String, List<OneClickExportVO>> map = articleVOS.stream().collect(Collectors.groupingBy(OneClickExportVO::getCategoryName));
|
|
|
+ if (!CollectionUtils.isEmpty(map)) {
|
|
|
+ for (String key : map.keySet()) {
|
|
|
+ ExportReportVO reportVO = new ExportReportVO();
|
|
|
+ reportVO.setCategoryName(key);
|
|
|
+ List<OneClickExportVO> reportArticleVOS = map.get(key);
|
|
|
+ List<ExportReportDetailVO> detailVOS = new ArrayList<>();
|
|
|
+ if (!CollectionUtils.isEmpty(reportArticleVOS)) {
|
|
|
+ int i = 1;
|
|
|
+ for (OneClickExportVO reportArticleVO : reportArticleVOS) {
|
|
|
+ Integer categoryId = reportArticleVO.getCategoryId();
|
|
|
+ String title = reportArticleVO.getTitle();
|
|
|
+ if (categoryId == 2 && SPECIAL_KEYWORDS.stream().anyMatch(title::contains)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ ExportReportDetailVO detailVO = new ExportReportDetailVO();
|
|
|
+ detailVO.setTitle(i + "、" + title);
|
|
|
+ detailVO.setDigest(reportArticleVO.getDigest());
|
|
|
+ String htmlLink = "<a href='" + reportArticleVO.getArticleUrl() + "'>" + reportArticleVO.getArticleUrl() + "</a>";
|
|
|
+ detailVO.setArticle_url(htmlLink);
|
|
|
+ detailVOS.add(detailVO);
|
|
|
+ i++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ reportVO.setDetailVOS(detailVOS);
|
|
|
+ reportVOS.add(reportVO);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ List<ExportReportDetailVO> list = new ArrayList<>();
|
|
|
+ List<ExportReportDetailVO> list1 = new ArrayList<>();
|
|
|
+ List<ExportReportDetailVO> list2 = new ArrayList<>();
|
|
|
+ List<ExportReportDetailVO> list3 = new ArrayList<>();
|
|
|
+ List<ExportReportDetailVO> list4 = new ArrayList<>();
|
|
|
+ if (!CollectionUtils.isEmpty(reportVOS)) {
|
|
|
+ for (ExportReportVO reportVO : reportVOS) {
|
|
|
+ String categoryName = reportVO.getCategoryName();
|
|
|
+ if (StringUtils.equals(categoryName, "国家知识产权局")) {
|
|
|
+ list.addAll(reportVO.getDetailVOS());
|
|
|
+ } else if (StringUtils.equals(categoryName, "地方相关法律法规")) {
|
|
|
+ list1.addAll(reportVO.getDetailVOS());
|
|
|
+ } else if (StringUtils.equals(categoryName, "判例")) {
|
|
|
+ list2.addAll(reportVO.getDetailVOS());
|
|
|
+ } else if (StringUtils.equals(categoryName, "国外相关资讯")) {
|
|
|
+ list3.addAll(reportVO.getDetailVOS());
|
|
|
+ } else if (StringUtils.equals(categoryName, "行业资讯")) {
|
|
|
+ list4.addAll(reportVO.getDetailVOS());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ map.put("country_list", list);
|
|
|
+ map.put("local_list", list1);
|
|
|
+ map.put("case_list", list2);
|
|
|
+ map.put("foreign_list", list3);
|
|
|
+ map.put("business_list", list4);
|
|
|
+ ReportTemple reportTemplate = reportTempleService.getById(1);
|
|
|
+ String templateFilePath = fileUtils.getPath(reportTemplate.getTemplatePath());
|
|
|
+ String reportName = "";
|
|
|
+ //生成文档
|
|
|
+ String fileGuid = null;
|
|
|
+ try {
|
|
|
+ fileGuid = this.generateReportFile(map, templateFilePath, reportName);
|
|
|
+ //todo 后续添加导出记录
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "导出资讯报告失败");
|
|
|
+ }
|
|
|
+ return fileGuid;
|
|
|
+ }
|
|
|
+
|
|
|
public String generateReportFile(Map<String, Object> map, String templateFilePath, String name) throws Exception {
|
|
|
XWPFTemplate xwpfTemplate = this.getHtmlTemplate(map, templateFilePath);
|
|
|
String fileName = name + ".docx";
|