Browse Source

重新对药品成分检查,加入分词器,对比药品成分是否禁售。增加冷冻字段。

Guos 14 hours ago
parent
commit
19bfd8f3d8

+ 6 - 5
fs-admin/src/main/java/com/fs/hisStore/controller/FsStoreProductScrmController.java

@@ -71,13 +71,14 @@ public class FsStoreProductScrmController extends BaseController {
     /**
      * 商品关键字检查
      * 只要商品成分的关键字在数据库中存在,就不允许添加商品。
-     * @param keyWords
+     * @param fsStoreProductScrm
      * @return
      */
-    @GetMapping("/selectForbiddenKeywords/{keyWords}")
-    public R selectForbiddenKeywords(@PathVariable("keyWords")String keyWords) {
-        if(org.apache.commons.lang3.StringUtils.isEmpty(keyWords))return R.ok().put("data", true);
-        SelectForbiddenKeywordsVo selectForbiddenKeywordsVo = fsStoreProductService.selectForbiddenKeywords(keyWords);
+    @PostMapping("/selectForbiddenKeywords")
+    public R selectForbiddenKeywords(@RequestBody FsStoreProductScrm fsStoreProductScrm) {
+        if(org.apache.commons.lang3.StringUtils.isEmpty(fsStoreProductScrm.getIngredient()))return R.ok().put("data", true);
+        String ingredient = fsStoreProductScrm.getIngredient();
+        SelectForbiddenKeywordsVo selectForbiddenKeywordsVo = fsStoreProductService.selectForbiddenKeywords(ingredient);
         if(ObjectUtils.isEmpty(selectForbiddenKeywordsVo)){
             return R.ok().put("data", true);
         }else{

+ 1 - 0
fs-admin/src/main/resources/drug.txt

@@ -0,0 +1 @@
+洋地黄毒苷 3 n

+ 6 - 0
fs-service/src/main/java/com/fs/hisStore/domain/FsStoreScrm.java

@@ -505,5 +505,11 @@ public class FsStoreScrm extends BaseEntity {
      **/
     private String foodLicenseBusinessScope;
 
+    /**
+     * 药品经营许可证范围是否包含1.冷冻-2.冷藏-3.冷冻冷藏
+     * drug_scope_has_frozen
+     **/
+    private String drugScopeHasFrozen;
+
 
 }

+ 5 - 1
fs-service/src/main/java/com/fs/hisStore/param/FsStoreScrmInfoParam.java

@@ -286,6 +286,10 @@ public class FsStoreScrmInfoParam extends BaseEntity
      **/
     private String foodLicenseBusinessScope;
 
-
+    /**
+     * 药品经营许可证范围是否包含1.冷冻-2.冷藏-3.冷冻冷藏
+     * drug_scope_has_frozen
+     **/
+    private String drugScopeHasFrozen;
 
 }

+ 24 - 4
fs-service/src/main/java/com/fs/hisStore/util/DrugComponentAnalyzer.java

@@ -1,6 +1,15 @@
 package com.fs.hisStore.util;
 
 import com.huaban.analysis.jieba.JiebaSegmenter;
+import com.huaban.analysis.jieba.WordDictionary;
+import org.apache.commons.io.FileUtils;
+import org.springframework.boot.system.ApplicationHome;
+import org.springframework.core.io.ClassPathResource;
+
+import java.io.File;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Path;
+import java.nio.file.Paths;
 import java.util.*;
 import java.util.stream.Collectors;
 
@@ -13,15 +22,25 @@ public class DrugComponentAnalyzer {
 
     // 禁售成分库(可从数据库/配置文件加载)
     private static final Set<String> FORBIDDEN_COMPONENTS = new HashSet<>(Arrays.asList(
-            "罂粟壳", "吗啡", "海洛因", "可卡因", "芬太尼"
+            "罂粟壳", "吗啡", "海洛因", "可卡因", "芬太尼","罂粟","洋地黄毒苷"
     ));
     // 停用词集合
-    private static Set<String> STOP_WORDS;
+//    private static Set<String> STOP_WORDS = new HashSet<>(Arrays.asList(
+//            "洋地黄毒苷"
+//    ));
 
     // 复用分词器实例(注意:Jieba非线程安全,多线程需每个线程new实例)
     private static final JiebaSegmenter SEGMENTER = new JiebaSegmenter();
 
-
+    static {
+        try{
+            ClassPathResource resource = new ClassPathResource("drug.txt");
+            Path path = resource.getFile().toPath();
+            WordDictionary.getInstance().loadUserDict(path);
+        }catch (Exception e){
+            throw new RuntimeException("加载词典失败", e);
+        }
+    }
 
     /**
      * 拆分药品成分(过滤停用词,仅保留有效成分)
@@ -32,6 +51,7 @@ public class DrugComponentAnalyzer {
         // 第二步:过滤停用词、空字符串、纯数字/单位
         return rawWords.stream()
                 .map(String::trim)
+//                .filter(word -> !STOP_WORDS.contains(word))
                 .filter(word -> !word.isEmpty())
                 .filter(word -> !isNumberOrUnit(word)) // 过滤剂量/单位(如0.5g、mg)
                 .collect(Collectors.toList());
@@ -85,7 +105,7 @@ public class DrugComponentAnalyzer {
 
     public static void main(String[] args) {
         // 测试文本1:含禁售成分
-        String text1 = "本品含对乙酰氨基酚0.5g、罂粟2mg,辅料为淀粉";
+        String text1 = "洋地黄毒苷,左啡诺";
         CheckResult result1 = checkForbiddenComponents(FORBIDDEN_COMPONENTS, text1);
         System.out.println("文本1拆分成分:" + result1.getAllComponents());
         System.out.println("文本1禁售成分:" + result1.getForbiddenComponents());

+ 6 - 0
fs-service/src/main/java/com/fs/hisStore/vo/FsStoreDetailsScrmVo.java

@@ -305,4 +305,10 @@ public class FsStoreDetailsScrmVo extends BaseEntity
      **/
     private String foodLicenseBusinessScope;
 
+    /**
+     * 药品经营许可证范围是否包含1.冷冻-2.冷藏-3.冷冻冷藏
+     * drug_scope_has_frozen
+     **/
+    private String drugScopeHasFrozen;
+
 }

+ 1 - 0
fs-service/src/main/resources/drug.txt

@@ -0,0 +1 @@
+洋地黄毒苷 3 n

+ 5 - 1
fs-service/src/main/resources/mapper/hisStore/FsStoreScrmMapper.xml

@@ -90,6 +90,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="medicalDevice3BusinessScope" column="medical_device3_business_scope" />
         <result property="drugLicenseBusinessScope" column="drug_license_business_scope" />
         <result property="foodLicenseBusinessScope" column="food_license_business_scope" />
+        <result property="drugScopeHasFrozen" column="drug_scope_has_frozen" />
     </resultMap>
 
     <sql id="selectFsStoreVo">
@@ -109,7 +110,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
                is_drug_license_permanent,is_medical_device2_expiry_permanent,is_medical_device3_expiry_permanent,is_food_license_expiry_permanent,is_medical_license_expiry_permanent,
                title_Name_one,title_Name_two,title_Name_three,settlement_agreement_file_name,quality_assurance_agreement_fileName,other_special_qualification_fileName,
                is_effective_permanent1,is_effective_permanent2,is_effective_permanent3,medical_device2_business_scope,medical_device3_business_scope,drug_license_business_scope
-            ,food_license_business_scope
+            ,food_license_business_scope,drug_scope_has_frozen
         from fs_store_scrm
     </sql>
 
@@ -233,6 +234,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="medicalDevice3BusinessScope !=null ">medical_device3_business_scope,</if>
             <if test="drugLicenseBusinessScope !=null ">drug_license_business_scope, </if>
             <if test="foodLicenseBusinessScope !=null ">food_license_business_scope, </if>
+            <if test="drugScopeHasFrozen !=null ">drug_scope_has_frozen, </if>
          </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="cityIds != null">#{cityIds},</if>
@@ -331,6 +333,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="medicalDevice3BusinessScope !=null ">#{medicalDevice3BusinessScope},</if>
             <if test="drugLicenseBusinessScope !=null ">#{drugLicenseBusinessScope}, </if>
             <if test="foodLicenseBusinessScope !=null ">#{foodLicenseBusinessScope}, </if>
+            <if test="drugScopeHasFrozen !=null ">#{drugScopeHasFrozen}, </if>
         </trim>
     </insert>
 
@@ -431,6 +434,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="medicalDevice3BusinessScope !=null ">medical_device3_business_scope = #{medicalDevice3BusinessScope} , </if>
             <if test="drugLicenseBusinessScope !=null ">drug_license_business_scope = #{drugLicenseBusinessScope} , </if>
             <if test="foodLicenseBusinessScope !=null ">food_license_business_scope = #{foodLicenseBusinessScope} , </if>
+            <if test="drugScopeHasFrozen !=null ">drug_scope_has_frozen = #{drugScopeHasFrozen}, </if>
         </trim>
         where store_id = #{storeId}
     </update>

+ 6 - 5
fs-store/src/main/java/com/fs/hisStore/controller/store/FsStoreProductScrmController.java

@@ -57,13 +57,14 @@ public class FsStoreProductScrmController extends BaseController
     /**
      * 商品关键字检查
      * 只要商品关键字在数据库中存在,就不允许添加商品。
-     * @param keyWords
+     * @param fsStoreProductScrm
      * @return
      */
-    @GetMapping("/selectForbiddenKeywords/{keyWords}")
-    public R selectForbiddenKeywords(@PathVariable("keyWords")String keyWords) {
-        if(org.apache.commons.lang3.StringUtils.isEmpty(keyWords))return R.ok().put("data", true);
-        SelectForbiddenKeywordsVo selectForbiddenKeywordsVo = fsStoreProductService.selectForbiddenKeywords(keyWords);
+    @PostMapping("/selectForbiddenKeywords")
+    public R selectForbiddenKeywords(@RequestBody FsStoreProductScrm fsStoreProductScrm) {
+        if(org.apache.commons.lang3.StringUtils.isEmpty(fsStoreProductScrm.getIngredient()))return R.ok().put("data", true);
+        String ingredient = fsStoreProductScrm.getIngredient();
+        SelectForbiddenKeywordsVo selectForbiddenKeywordsVo = fsStoreProductService.selectForbiddenKeywords(ingredient);
         if(ObjectUtils.isEmpty(selectForbiddenKeywordsVo)){
             return R.ok().put("data", true);
         }else{