Bladeren bron

商品过期提醒sql优化,处理商品新增异常问题

yjwang 1 week geleden
bovenliggende
commit
f08fcf0184

+ 20 - 0
fs-service/src/main/java/com/fs/hisStore/domain/FsStoreProductScrm.java

@@ -543,4 +543,24 @@ public class FsStoreProductScrm extends BaseEntity {
      * 非首营链接
      * **/
     private String businessLink;
+
+    /**
+     * 生产企业营业执照是否长期有效
+     * **/
+    private Byte isBusinessPermanent;
+
+    /**
+     * 生产企业的生产许可证/备案凭证是否长期有效
+     * **/
+    private Byte isLicensePermanent;
+
+    /**
+     * 商品注册证/备案凭证是否长期有效
+     * **/
+    private Byte isCertificatePermanent;
+
+    /**
+     * GMP/GSP认证证书是否长期有效
+     * **/
+    private Byte isGmpAuthPermanent;
 }

+ 21 - 0
fs-service/src/main/java/com/fs/hisStore/param/FsStoreProductAddEditParam.java

@@ -346,4 +346,25 @@ public class FsStoreProductAddEditParam implements Serializable
      * 非首营链接
      * **/
     private String businessLink;
+
+    //加入证书长期按钮
+    /**
+     * 生产企业营业执照是否长期有效
+     * **/
+    private Byte isBusinessPermanent;
+
+    /**
+     * 生产企业的生产许可证/备案凭证是否长期有效
+     * **/
+    private Byte isLicensePermanent;
+
+    /**
+     * 商品注册证/备案凭证是否长期有效
+     * **/
+    private Byte isCertificatePermanent;
+
+    /**
+     * GMP/GSP认证证书是否长期有效
+     * **/
+    private Byte isGmpAuthPermanent;
 }

+ 3 - 3
fs-service/src/main/java/com/fs/hisStore/service/impl/FsStoreProductScrmServiceImpl.java

@@ -451,17 +451,17 @@ public class FsStoreProductScrmServiceImpl implements IFsStoreProductScrmService
                 case 1://非处方
                     break;
                 case 2://处方
-                    if (StringUtils.isEmpty(store.getDrugLicense()) || "".equals(store.getDrugLicense()) || LocalDate.now().isAfter(store.getDrugLicenseExpiryEnd())) {
+                    if (store.getIsDrugLicensePermanent() == 0 && StringUtils.isEmpty(store.getDrugLicense()) || "".equals(store.getDrugLicense()) && (store.getDrugLicenseExpiryEnd() == null ||  LocalDate.now().isAfter(store.getDrugLicenseExpiryEnd()))) {
                         return R.error("店铺药品资质为空或已过期,请完善后再添加");
                     }
                     break;
                 case 3://食品
-                    if (StringUtils.isEmpty(store.getFoodLicense()) || "".equals(store.getFoodLicense()) || LocalDate.now().isAfter(store.getFoodLicenseExpiryEnd())) {
+                    if (store.getIsFoodLicenseExpiryPermanent() == 0 && StringUtils.isEmpty(store.getFoodLicense()) || "".equals(store.getFoodLicense()) && (store.getFoodLicenseExpiryEnd() == null ||  LocalDate.now().isAfter(store.getFoodLicenseExpiryEnd()))) {
                         return R.error("店铺食品资质为空或已过期,请完善后再添加");
                     }
                     break;
                 case 4://器械
-                    if (StringUtils.isEmpty(store.getMedicalDevice3()) || "".equals(store.getMedicalDevice3()) || LocalDate.now().isAfter(store.getMedicalDevice3ExpiryEnd())) {
+                    if (store.getIsMedicalDevice3ExpiryPermanent() == 0 && StringUtils.isEmpty(store.getMedicalDevice3()) || "".equals(store.getMedicalDevice3()) && (store.getMedicalDevice3ExpiryEnd() == null ||  LocalDate.now().isAfter(store.getMedicalDevice3ExpiryEnd()))) {
                         return R.error("店铺器械资质为空或已过期,请完善后再添加");
                     }
                     break;

+ 28 - 21
fs-service/src/main/resources/mapper/hisStore/FsStoreProductScrmMapper.xml

@@ -85,6 +85,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="gmpAuthStart" column="gmp_auth_start"/>
         <result property="gmpAuthEnd" column="gmp_auth_end"/>
         <result property="businessLink" column="business_link"/>
+
+        <result property="isBusinessPermanent" column="is_business_permanent"/>
+        <result property="isLicensePermanent" column="is_license_permanent"/>
+        <result property="isCertificatePermanent" column="is_certificate_permanent"/>
+        <result property="isGmpAuthPermanent" column="is_gmp_auth_permanent"/>
     </resultMap>
 
     <sql id="selectFsStoreProductVo">
@@ -100,7 +105,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
                license, license_start, license_end,
                certificate, certificate_start, certificate_end,
                voucher, voucher_start, voucher_end,
-               gmp_auth, gmp_auth_start, gmp_auth_end,business_link
+               gmp_auth, gmp_auth_start, gmp_auth_end,business_link,
+               is_business_permanent,is_license_permanent,is_certificate_permanent,is_gmp_auth_permanent
                from fs_store_product_scrm
     </sql>
 
@@ -112,7 +118,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
                p.integral, p.product_type, p.prescribe_code, p.prescribe_spec, p.prescribe_factory, p.prescribe_name,
                p.is_display,p.tui_cate_id,p.company_ids,p.is_drug,p.drug_image,p.drug_reg_cert_no,p.common_name,p.dosage_form,
                p.unit_price,p.batch_number,p.mah,p.mah_address,p.manufacturer,p.manufacturer_address,p.indications,p.dosage,
-               p.adverse_reactions,p.contraindications,p.precautions,p.is_audit,p.store_id
+               p.adverse_reactions,p.contraindications,p.precautions,p.is_audit,p.store_id,
+               p.is_business_permanent,p.is_license_permanent,p.is_certificate_permanent,p.is_gmp_auth_permanent
         from fs_store_product_scrm p
         select product_id, video, image, slider_image, product_name, product_info, keyword, bar_code, cate_id, price, vip_price, ot_price, agent_price, postage, unit_name, sort, sales, stock, is_show, is_hot, is_benefit, is_best, is_new, description, create_time, update_time, is_postage, is_del, give_integral, cost, is_good, browse, code_path, temp_id, spec_type, is_integral, integral, product_type, prescribe_code, prescribe_spec, prescribe_factory, prescribe_name, is_display, tui_cate_id, company_ids, store_id, is_drug, drug_image, drug_reg_cert_no, common_name, dosage_form, unit_price, batch_number, mah, mah_address, manufacturer, manufacturer_address, indications, dosage, adverse_reactions, contraindications, precautions, is_audit from fs_store_product_scrm
     </sql>
@@ -298,6 +305,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="gmpAuthStart != null">gmp_auth_start ,</if>
             <if test="gmpAuthEnd != null">gmp_auth_end ,</if>
             <if test="businessLink != null">business_link ,</if>
+
+            <if test="isBusinessPermanent != null">is_business_permanent ,</if>
+            <if test="isLicensePermanent != null">is_license_permanent ,</if>
+            <if test="isCertificatePermanent != null">is_certificate_permanent ,</if>
+            <if test="isGmpAuthPermanent != null">is_gmp_auth_permanent ,</if>
          </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="image != null and image != ''">#{image},</if>
@@ -383,6 +395,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="gmpAuthStart != null">#{gmpAuthStart} ,</if>
             <if test="gmpAuthEnd != null">#{gmpAuthEnd} ,</if>
             <if test="businessLink != null">#{businessLink} ,</if>
+            <if test="isBusinessPermanent != null">#{isBusinessPermanent} ,</if>
+            <if test="isLicensePermanent != null">#{isLicensePermanent} ,</if>
+            <if test="isCertificatePermanent != null">#{isCertificatePermanent} ,</if>
+            <if test="isGmpAuthPermanent != null">#{isGmpAuthPermanent} ,</if>
          </trim>
     </insert>
 
@@ -472,6 +488,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="gmpAuthStart != null">gmp_auth_start = #{gmpAuthStart} ,</if>
             <if test="gmpAuthEnd != null">gmp_auth_end = #{gmpAuthEnd} ,</if>
             <if test="businessLink != null">business_link = #{businessLink} ,</if>
+
+            <if test="isBusinessPermanent != null">is_business_permanent = #{isBusinessPermanent} ,</if>
+            <if test="isLicensePermanent != null">is_license_permanent = #{isLicensePermanent} ,</if>
+            <if test="isCertificatePermanent != null">is_certificate_permanent = #{isCertificatePermanent} ,</if>
+            <if test="isGmpAuthPermanent != null">is_gmp_auth_permanent = #{isGmpAuthPermanent} ,</if>
         </trim>
         where product_id = #{productId}
     </update>
@@ -683,6 +704,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         FROM fs_store_product_scrm
         WHERE business_end IS NOT NULL
           AND business_end &lt;= DATE_ADD(CURDATE(), INTERVAL 15 DAY)
+          AND is_business_permanent != 1
         <if test="storeId != null">AND store_id = #{storeId}</if>
 
         UNION ALL
@@ -700,6 +722,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         FROM fs_store_product_scrm
         WHERE license_end IS NOT NULL
           AND license_end &lt;= DATE_ADD(CURDATE(), INTERVAL 15 DAY)
+          AND is_license_permanent != 1
         <if test="storeId != null">AND store_id = #{storeId}</if>
 
         UNION ALL
@@ -717,32 +740,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         FROM fs_store_product_scrm
         WHERE certificate_end IS NOT NULL
           AND certificate_end &lt;= DATE_ADD(CURDATE(), INTERVAL 15 DAY)
+          AND is_certificate_permanent != 1
         <if test="storeId != null">AND store_id = #{storeId}</if>
 
         UNION ALL
-
-        SELECT
-            CONCAT(
-                    product_name,
-                    '商品的',
-                    '备案证书有效期',
-                    CASE
-                        WHEN voucher_end &lt; CURDATE() THEN '已过期'
-                        ELSE '即将15天内过期'
-                        END
-                ) AS status_text
-        FROM fs_store_product_scrm
-        WHERE voucher_end IS NOT NULL
-          AND voucher_end &lt;= DATE_ADD(CURDATE(), INTERVAL 15 DAY)
-        <if test="storeId != null">AND store_id = #{storeId}</if>
-
-        UNION ALL
-
         SELECT
             CONCAT(
                     product_name,
                     '商品的',
-                    'GMP认证有效期',
+                    'GMP/GSP认证证书有效期',
                     CASE
                         WHEN gmp_auth_end &lt; CURDATE() THEN '已过期'
                         ELSE '即将15天内过期'
@@ -751,6 +757,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         FROM fs_store_product_scrm
         WHERE  gmp_auth_end IS NOT NULL
           AND gmp_auth_end &lt;= DATE_ADD(CURDATE(), INTERVAL 15 DAY)
+          AND is_gmp_auth_permanent != 1
         <if test="storeId != null">AND store_id = #{storeId}</if>
     </select>
     <select id="getDrugExportList" resultType="com.fs.hisStore.vo.FsDrugExportVO">

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

@@ -251,7 +251,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="medicalDevice2 !=null">#{medicalDevice2}, </if>
             <if test="medicalDevice2ExpiryStart !=null ">#{medicalDevice2ExpiryStart}, </if>
             <if test="medicalDevice2ExpiryEnd !=null ">#{medicalDevice2ExpiryEnd}, </if>
-            <if test="medicalDevice3 !=null">#{medical_device3}, </if>
+            <if test="medicalDevice3 !=null">#{medicalDevice3}, </if>
             <if test="medicalDevice3ExpiryStart !=null ">#{medicalDevice3ExpiryStart}, </if>
             <if test="medicalDevice3ExpiryEnd !=null ">#{medicalDevice3ExpiryEnd}, </if>
             <if test="foodLicense !=null">#{foodLicense}, </if>