zero 6 天之前
父節點
當前提交
acf55743da

+ 0 - 4
src/main/java/com/cslg/ppa/entity/ArticleInfo.java

@@ -18,10 +18,6 @@ public class ArticleInfo extends BaseEntity<ArticleInfo> {
     @TableField(value = "digest")
     private String digest;
 
-    //类别 1 国家知识产权局 2 地方相关法律法规 3 判例   4国外相关资讯 5 行业资讯  6其他   11指南针
-    @TableField(value = "category_id")
-    private Integer categoryId;
-
     //来源id
     @TableField(value = "source_id")
     private Integer sourceId;

+ 2 - 0
src/main/java/com/cslg/ppa/mapper/ReportMapper.java

@@ -13,4 +13,6 @@ public interface ReportMapper extends BaseMapper<Report> {
 
     public List<SelectAssoReportArticleVO> selectAssoReportArticleList(@Param("reportId") Integer reportId);
 
+    public List<SelectAssoReportArticleVO> selectExportReportArticleList(@Param("reportId") Integer reportId);
+
 }

+ 7 - 7
src/main/java/com/cslg/ppa/service/CategoryService.java

@@ -11,12 +11,10 @@ import com.cslg.ppa.common.utils.LoginUtils;
 import com.cslg.ppa.dto.CategoryDTO;
 import com.cslg.ppa.dto.CategoryIdDTO;
 import com.cslg.ppa.dto.SelectCategoryListDTO;
-import com.cslg.ppa.entity.ArticleInfo;
-import com.cslg.ppa.entity.BaseEntity;
-import com.cslg.ppa.entity.Category;
-import com.cslg.ppa.entity.SourceInfo;
+import com.cslg.ppa.entity.*;
 import com.cslg.ppa.entity.commom.PersonnelVO;
 import com.cslg.ppa.entity.commom.Records;
+import com.cslg.ppa.mapper.ArticleCategoryRelationMapper;
 import com.cslg.ppa.mapper.ArticleInfoMapper;
 import com.cslg.ppa.mapper.CategoryMapper;
 import com.cslg.ppa.mapper.SourceInfoMapper;
@@ -42,6 +40,8 @@ public class CategoryService extends ServiceImpl<CategoryMapper, Category> {
     private CategoryMapper categoryMapper;
     @Autowired
     private ArticleInfoMapper articleInfoMapper;
+    @Autowired
+    private ArticleCategoryRelationMapper articleCategoryRelationMapper;
 
     public String selectCategoryList(SelectCategoryListDTO vo) {
         Records records = new Records();
@@ -83,9 +83,9 @@ public class CategoryService extends ServiceImpl<CategoryMapper, Category> {
     public void deleteCategory(CategoryIdDTO vo) {
         List<Integer> categoryIds = vo.getCategoryIds();
         if (!CollectionUtils.isEmpty(categoryIds)) {
-            List<ArticleInfo> articleInfos = articleInfoMapper.selectList(new LambdaQueryWrapper<ArticleInfo>()
-                    .in(ArticleInfo::getCategoryId, categoryIds));
-            if (!CollectionUtils.isEmpty(articleInfos)) {
+            List<ArticleCategoryRelation> categoryRelations = articleCategoryRelationMapper.selectList(new LambdaQueryWrapper<ArticleCategoryRelation>()
+                    .in(ArticleCategoryRelation::getCategoryId, categoryIds));
+            if (!CollectionUtils.isEmpty(categoryRelations)) {
                 throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "该类别已在资讯信息中使用");
             }
             categoryMapper.deleteBatchIds(categoryIds);

+ 7 - 1
src/main/java/com/cslg/ppa/service/GetWebArticle/GetCNIPAArticleService.java

@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.cslg.ppa.common.utils.DateUtil;
 import com.cslg.ppa.common.utils.RegexUtil;
 import com.cslg.ppa.dto.GetArticleInfoDTO;
+import com.cslg.ppa.entity.ArticleCategoryRelation;
 import com.cslg.ppa.entity.ArticleInfo;
 import com.cslg.ppa.service.ArticleInfoService;
 import com.cslg.ppa.service.commom.DifyService;
@@ -25,6 +26,7 @@ import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Propagation;
 import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.CollectionUtils;
 
 import java.io.IOException;
 import java.text.SimpleDateFormat;
@@ -226,11 +228,15 @@ public class GetCNIPAArticleService {
             ArticleInfo articleInfo = new ArticleInfo();
             articleInfo.setTitle(title);
             articleInfo.setDigest(condensedAbstract);
-            articleInfo.setCategoryId(1);
             articleInfo.setSourceId(1);
             articleInfo.setPublicTime(date);
             articleInfo.setArticleUrl(articleUrl);
             articleInfo.insert();
+
+            ArticleCategoryRelation relation = new ArticleCategoryRelation();
+            relation.setArticleId(articleInfo.getId());
+            relation.setCategoryId(1);
+            relation.insert();
         } catch (Exception e) {
         }
     }

+ 6 - 1
src/main/java/com/cslg/ppa/service/GetWebArticle/GetWeChatArticleService.java

@@ -6,6 +6,7 @@ import com.cslg.ppa.common.core.base.RedisConf;
 import com.cslg.ppa.common.utils.DateUtil;
 import com.cslg.ppa.common.utils.RedisUtil;
 import com.cslg.ppa.dto.GetArticleInfoDTO;
+import com.cslg.ppa.entity.ArticleCategoryRelation;
 import com.cslg.ppa.entity.ArticleInfo;
 import com.cslg.ppa.entity.SourceInfo;
 import com.cslg.ppa.entity.commom.Article;
@@ -411,11 +412,15 @@ public class GetWeChatArticleService {
                 ArticleInfo articleInfo = new ArticleInfo();
                 articleInfo.setTitle(title);
                 articleInfo.setDigest(condensedAbstract);
-                articleInfo.setCategoryId(categoryId);
                 articleInfo.setSourceId(sourceId);
                 articleInfo.setPublicTime(createTime);
                 articleInfo.setArticleUrl(articleUrl);
                 articleInfo.insert();
+
+                ArticleCategoryRelation relation = new ArticleCategoryRelation();
+                relation.setArticleId(articleInfo.getId());
+                relation.setCategoryId(categoryId);
+                relation.insert();
             }
         } catch (Exception e) {
         }

+ 22 - 5
src/main/java/com/cslg/ppa/service/ReportService.java

@@ -171,8 +171,25 @@ public class ReportService extends ServiceImpl<ReportMapper, Report> {
     public List<SelectAssoReportArticleVO> selectAssoReportArticleList(SelectAssoReportArticleDTO vo) {
         Integer reportId = vo.getReportId();
         List<SelectAssoReportArticleVO> articleVOS = reportMapper.selectAssoReportArticleList(reportId);
-        if (CollectionUtils.isEmpty(articleVOS)) {
-            articleVOS = new ArrayList<>();
+        if (!CollectionUtils.isEmpty(articleVOS)) {
+            for (SelectAssoReportArticleVO articleVO : articleVOS) {
+                // 将逗号分隔的类别ID转换为列表
+                String categoryIdsStr = articleVO.getCategoryIdsStr();
+                if (StringUtils.isNotBlank(categoryIdsStr)) {
+                    List<Integer> categoryIds = Arrays.stream(categoryIdsStr.split(","))
+                            .map(String::trim)
+                            .map(Integer::parseInt)
+                            .collect(Collectors.toList());
+                    articleVO.setCategoryIds(categoryIds);
+                }
+
+                // 将逗号分隔的类别名称转换为列表和格式化字符串
+                String categoryNamesStr = articleVO.getCategoryNamesStr();
+                if (StringUtils.isNotBlank(categoryNamesStr)) {
+                    List<String> categoryNames = Arrays.asList(categoryNamesStr.split(","));
+                    articleVO.setCategoryNames(categoryNames);
+                }
+            }
         }
         return articleVOS;
     }
@@ -242,7 +259,7 @@ public class ReportService extends ServiceImpl<ReportMapper, Report> {
     }
 
     public Map<String, Object> articleReport(Integer reportId) {
-        List<SelectAssoReportArticleVO> articleVOS = reportMapper.selectAssoReportArticleList(reportId);
+        List<SelectAssoReportArticleVO> articleVOS = reportMapper.selectExportReportArticleList(reportId);
         List<ExportReportVO> reportVOS = new ArrayList<>();
         if (!CollectionUtils.isEmpty(articleVOS)) {
             Map<String, List<SelectAssoReportArticleVO>> map = articleVOS.stream().collect(Collectors.groupingBy(SelectAssoReportArticleVO::getCategoryName));
@@ -308,7 +325,7 @@ public class ReportService extends ServiceImpl<ReportMapper, Report> {
     }
 
     public Map<String, Object> articleReport2(Integer reportId) {
-        List<SelectAssoReportArticleVO> articleVOS = reportMapper.selectAssoReportArticleList(reportId);
+        List<SelectAssoReportArticleVO> articleVOS = reportMapper.selectExportReportArticleList(reportId);
         List<ExportReportDetailVO> detailVOS = new ArrayList<>();
         if (!CollectionUtils.isEmpty(articleVOS)) {
             Map<String, List<SelectAssoReportArticleVO>> map = articleVOS.stream().collect(Collectors.groupingBy(SelectAssoReportArticleVO::getCategoryName));
@@ -340,7 +357,7 @@ public class ReportService extends ServiceImpl<ReportMapper, Report> {
     }
 
     public Map<String, Object> articleReport1(Integer reportId) {
-        List<SelectAssoReportArticleVO> articleVOS = reportMapper.selectAssoReportArticleList(reportId);
+        List<SelectAssoReportArticleVO> articleVOS = reportMapper.selectExportReportArticleList(reportId);
         List<ExportReportVO> reportVOS = new ArrayList<>();
         if (!CollectionUtils.isEmpty(articleVOS)) {
             Map<String, List<SelectAssoReportArticleVO>> map = articleVOS.stream().collect(Collectors.groupingBy(SelectAssoReportArticleVO::getCategoryName));

+ 0 - 4
src/main/java/com/cslg/ppa/vo/SelectArticleInfoVO.java

@@ -15,10 +15,6 @@ public class SelectArticleInfoVO {
 
     private String digest;
 
-    private Integer categoryId;
-
-    private String categoryName;
-
     private Integer sourceId;
 
     private String sourceName;

+ 12 - 0
src/main/java/com/cslg/ppa/vo/SelectAssoReportArticleVO.java

@@ -5,6 +5,7 @@ import lombok.Data;
 import org.springframework.format.annotation.DateTimeFormat;
 
 import java.util.Date;
+import java.util.List;
 
 @Data
 public class SelectAssoReportArticleVO {
@@ -36,4 +37,15 @@ public class SelectAssoReportArticleVO {
     private String sourceName;
 
     private String oldContent;
+
+    // 所有关联的类别ID列表
+    private List<Integer> categoryIds;
+
+    // 所有关联的类别名称列表
+    private List<String> categoryNames;
+
+    // 格式化后的类别名称字符串(如:"国家知识产权局, 地方相关法律法规")
+    private String categoryNamesStr;
+
+    private String categoryIdsStr;
 }

+ 2 - 1
src/main/resources/mapper/ArticleInfoMapper.xml

@@ -87,7 +87,8 @@
         si.source_name,
         si.source_type
         from article_info ai
-        left join category ca on ca.id = ai.category_id
+        left join article_category_relation acr ON acr.article_id = ai.id
+        left join category ca ON ca.id = acr.category_id
         left join source_info si on si.id = ai.source_id
         <where>
             <if test="vo.type == 1">

+ 24 - 0
src/main/resources/mapper/ReportMapper.xml

@@ -9,6 +9,30 @@
                ai.title,
                ai.digest,
                ai.old_content,
+               ai.public_time,
+               ai.article_url,
+               ai.source_id,
+               si.source_name,
+               si.source_type,
+               GROUP_CONCAT(acr.category_id) as categoryIdsStr,
+               GROUP_CONCAT(ca.name) as categoryNamesStr
+        from asso_report_article ara
+        left join article_info ai on ai.id = ara.article_id
+        left join article_category_relation acr on acr.article_id = ai.id
+        left join category ca on ca.id = acr.category_id
+        left join source_info si on si.id = ai.source_id
+        where ara.report_id = #{reportId} and ara.if_use = 1
+        group by ai.id
+        order by ai.public_time asc
+    </select>
+
+    <select id="selectExportReportArticleList" resultType="com.cslg.ppa.vo.SelectAssoReportArticleVO">
+        select ara.id as assoId,
+               ara.report_id,
+               ara.article_id,
+               ai.title,
+               ai.digest,
+               ai.old_content,
                acr.category_id,
                ca.name as categoryName,
                ai.public_time,

+ 3 - 20
src/test/java/com/cslg/ppa/PpaApplicationTests.java

@@ -448,24 +448,6 @@ class PpaApplicationTests {
         Files.delete(tempFile.toPath());
     }
 
-    @Test
-    void test11() throws Exception {
-        List<ArticleInfo> list = articleInfoService.list(new LambdaQueryWrapper<ArticleInfo>()
-                .in(ArticleInfo::getCategoryId,Arrays.asList(3,4,5,6))
-                .isNotNull(ArticleInfo::getWxArticleIcon));
-        System.out.println(list.size());
-        if (!CollectionUtils.isEmpty(list)) {
-            for (ArticleInfo articleInfo : list) {
-                if (StringUtils.isNotEmpty(articleInfo.getWxArticleIcon())) {
-                    String guid = getWeChatArticleService.getGuid(articleInfo.getWxArticleIcon());
-                    articleInfo.setWxArticleIcon(guid);
-                    articleInfo.setId(articleInfo.getId());
-                    articleInfo.updateById();
-                }
-            }
-        }
-        System.out.println("----------------");
-    }
 
     @Test
     void getPCTArticle() {
@@ -592,7 +574,7 @@ class PpaApplicationTests {
 
 
         List<ArticleInfo> articleInfos = articleInfoMapper.selectList(new LambdaQueryWrapper<ArticleInfo>()
-                .eq(ArticleInfo::getCategoryId, 2));
+                .eq(ArticleInfo::getSourceId, 2));
         for (ArticleInfo articleInfo : articleInfos) {
             String digest = articleInfo.getDigest();
             String str = null;
@@ -655,7 +637,8 @@ class PpaApplicationTests {
     void test4() {
         SelectArticleInfoDTO vo = new SelectArticleInfoDTO();
 //        final List<SelectArticleInfoVO> selectArticleInfoVOS = articleInfoMapper.selectArticleInfoList(vo);
-        final List<SelectAssoReportArticleVO> selectAssoReportArticleVOS = reportMapper.selectAssoReportArticleList(1);
+        final List<SelectAssoReportArticleVO> selectAssoReportArticleVOS = reportMapper.selectAssoReportArticleList(99);
+        System.out.println(selectAssoReportArticleVOS);
         System.out.println("=============");
     }
 }