Jelajahi Sumber

代码提交优化查询

yjwang 3 hari lalu
induk
melakukan
b67ecef349

+ 1 - 0
fs-doctor-app/src/main/java/com/fs/app/controller/PrescribeController.java

@@ -141,6 +141,7 @@ public class PrescribeController extends  AppBaseController {
                         vo.setAuditReason(order.getReason());
                         vo.setDiagnose(order.getTags());
                         vo.setOrderCode(order.getOrderCode());
+                        vo.setPid(order.getPid().toString());
                         vo.setAuditStatus(order.getAuditStatus());
                         if (order.getAuditTime() != null){
                             vo.setAuditTime(Date.from(order.getAuditTime().atZone(ZoneId.of("Asia/Shanghai")).toInstant()));

+ 2 - 0
fs-service/src/main/java/com/fs/his/param/FsPrescribeListDParam.java

@@ -31,4 +31,6 @@ public class FsPrescribeListDParam extends BaseParam implements Serializable {
      * **/
     private String orderCode;
 
+    private String pid;
+
 }

+ 2 - 0
fs-service/src/main/java/com/fs/his/vo/FsPrescribeListDVO.java

@@ -60,4 +60,6 @@ public class FsPrescribeListDVO implements Serializable {
     private Integer auditStatus;
 
     private String orderCode;
+
+    private String pid;
 }

+ 1 - 1
fs-service/src/main/java/com/fs/hisStore/domain/FsStoreAfterSalesScrm.java

@@ -155,5 +155,5 @@ public class FsStoreAfterSalesScrm extends BaseEntity
     /**
      * 处方编码
      * **/
-    private String serialNo;
+    private String pid;
 }

+ 3 - 3
fs-service/src/main/java/com/fs/hisStore/mapper/FsStoreAfterSalesScrmMapper.java

@@ -88,7 +88,7 @@ public interface FsStoreAfterSalesScrmMapper
 
     @Select({"<script> " +
             "select s.*,o.delivery_status,o.delivery_id,u.phone as user_phone,c.company_name ," +
-            "cu.nick_name as company_user_nick_name ,cu.phonenumber as company_usere_phonenumber,ssc.store_name as storeName,ssc.store_seq as storeSeq,ssc.merchant_id as merchantId,hps.serial_no  " +
+            "cu.nick_name as company_user_nick_name ,cu.phonenumber as company_usere_phonenumber,ssc.store_name as storeName,ssc.store_seq as storeSeq,ssc.merchant_id as merchantId,hps.pid  " +
             "from fs_store_after_sales_scrm s INNER join fs_store_order_scrm o on o.order_code=s.order_code " +
             "left join fs_user u on s.user_id=u.user_id left join company c on c.company_id=s.company_id " +
             "left join company_user cu on cu.user_id=s.company_user_id " +
@@ -122,8 +122,8 @@ public interface FsStoreAfterSalesScrmMapper
             "<if test = 'maps.storeId != null'> " +
             "and o.store_id = #{maps.storeId} " +
             "</if>" +
-            "     <if test=\"maps.serialNo != null and  maps.serialNo !=''\">\n" +
-            "                and hps.serial_no like CONCAT('%',#{maps.serialNo},'%')\n" +
+            "     <if test=\"maps.pid != null and  maps.pid !=''\">\n" +
+            "                and hps.pid like CONCAT('%',#{maps.pid},'%')\n" +
             "            </if> " +
             "<if test = 'maps.deliverySn != null and  maps.deliverySn !=  \"\" '> " +
             " and ( o.delivery_id like concat('%', #{maps.deliverySn}, '%') or s.delivery_sn like concat('%', #{maps.deliverySn}, '%')) " +

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

@@ -129,6 +129,6 @@ public class FsStoreOrderParam extends BaseEntity implements Serializable
     /**
      * 处方单号
      * **/
-    private String serialNo;
+    private String pid;
 
 }

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

@@ -387,9 +387,9 @@ public class FsStoreProductScrmServiceImpl implements IFsStoreProductScrmService
     @Override
     @Transactional
     public R addOrEdit(FsStoreProductAddEditParam param) {
-        ProductAttrCountDto countDto=computedProductCount(param.getValues());
-        FsStoreProductScrm product=new FsStoreProductScrm();
-        BeanUtils.copyProperties(param,product);
+        ProductAttrCountDto countDto = computedProductCount(param.getValues());
+        FsStoreProductScrm product = new FsStoreProductScrm();
+        BeanUtils.copyProperties(param, product);
         product.setPrice(countDto.getMinPrice());
         product.setOtPrice(countDto.getMinOtPrice());
         product.setCost(countDto.getMinCost());
@@ -402,54 +402,86 @@ public class FsStoreProductScrmServiceImpl implements IFsStoreProductScrmService
         product.setIsDrug(param.getIsDrug().toString());
         product.setInstructionManual(param.getInstructionManual());
 
+        List<String> businessExpire = param.getBusinessExpire();
+        if (businessExpire != null && businessExpire.size() >= 2) {
+            product.setBusinessStart(parseLocalDate(businessExpire.get(0)));
+            product.setBusinessEnd(parseLocalDate(businessExpire.get(1)));
+        }
+
+        List<String> licenseExpire = param.getLicenseExpire();
+        if (licenseExpire != null && licenseExpire.size() >= 2) {
+            product.setLicenseStart(parseLocalDate(licenseExpire.get(0)));
+            product.setLicenseEnd(parseLocalDate(licenseExpire.get(1)));
+        }
+
+        List<String> certificateExpire = param.getCertificateExpire();
+        if (certificateExpire != null && certificateExpire.size() >= 2) {
+            product.setCertificateStart(parseLocalDate(certificateExpire.get(0)));
+            product.setCertificateEnd(parseLocalDate(certificateExpire.get(1)));
+        }
+
+        List<String> voucherExpire = param.getVoucherExpire();
+        if (voucherExpire != null && voucherExpire.size() >= 2) {
+            product.setVoucherStart(parseLocalDate(voucherExpire.get(0)));
+            product.setVoucherEnd(parseLocalDate(voucherExpire.get(1)));
+        }
+
+        List<String> gmpAuthExpire = param.getGmpAuthExpire();
+        if (gmpAuthExpire != null && gmpAuthExpire.size() >= 2) {
+            product.setGmpAuthStart(parseLocalDate(gmpAuthExpire.get(0)));
+            product.setGmpAuthEnd(parseLocalDate(gmpAuthExpire.get(1)));
+        }
+
         //获取商品编码
-        if(!param.getValues().isEmpty()){
-            if(param.getValues().get(0).getBarCode() != null){
+        if (!param.getValues().isEmpty()) {
+            if (param.getValues().get(0).getBarCode() != null) {
                 product.setBarCode(param.getValues().get(0).getBarCode());
             }
         }
+
+        product.setBusinessLink(param.getBusinessLink());
         //校验店铺资质信息
         //获取店铺
         FsStoreScrm store = fsStoreScrmService.selectFsStoreByStoreId(product.getStoreId());
-        if(store == null || 1 != store.getStatus()){
+        if (store == null || 1 != store.getStatus()) {
             return R.error("店铺不存在或未启用");
-        }else{
+        } else {
             //验证资质
-            switch (product.getProductType()){
+            switch (product.getProductType()) {
                 case 1://非处方
                     break;
                 case 2://处方
-                    if(StringUtils.isEmpty(store.getDrugLicense()) || "".equals(store.getDrugLicense()) ||  LocalDate.now().isAfter(store.getDrugLicenseExpiryEnd())){
+                    if (StringUtils.isEmpty(store.getDrugLicense()) || "".equals(store.getDrugLicense()) || 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 (StringUtils.isEmpty(store.getFoodLicense()) || "".equals(store.getFoodLicense()) || 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 (StringUtils.isEmpty(store.getMedicalDevice3()) || "".equals(store.getMedicalDevice3()) || LocalDate.now().isAfter(store.getMedicalDevice3ExpiryEnd())) {
                         return R.error("店铺器械资质为空或已过期,请完善后再添加");
                     }
                     break;
                 default:
                     return R.error("商品类型错误");
             }
-            
+
             // 根据经营范围校验商品类型
-//            if (com.fs.common.utils.StringUtils.isNotEmpty(store.getSelectableProductTypes())) {
-//                String productTypeName = getProductTypeName(product.getProductType());
-//                if (com.fs.common.utils.StringUtils.isNotEmpty(productTypeName)) {
-//                    // 直接使用工具类方法校验
-//                    boolean isAllowed = BusinessScopeProductTypeUtil.isProductTypeAllowed(
-//                            store.getSelectableProductTypes(), productTypeName);
-//                    if (!isAllowed) {
-//                        return R.error("该商品类型[" + productTypeName + "]不在店铺经营范围允许的商品类型内,请联系管理员核实经营范围");
-//                    }
-//                }
-//            }
-        }
+            if (com.fs.common.utils.StringUtils.isNotEmpty(store.getSelectableProductTypes())) {
+                String productTypeName = getProductTypeName(product.getCateId());
+                if (com.fs.common.utils.StringUtils.isNotEmpty(productTypeName)) {
+                    // 直接使用工具类方法校验
+//                    boolean isAllowed = BusinessScopeProductTypeUtil.isProductTypeAllowed(store.getSelectableProductTypes(), productTypeName);
+                    boolean isAllowed = validateShopBusinessScope(store.getBusinessScope(), productTypeName);
+                    if (!isAllowed) {
+                        return R.error("该商品类型[" + productTypeName + "]不在店铺经营范围允许的商品类型内,请联系管理员核实经营范围");
+                    }
+                }
+            }
+    }
 
         if("纯正堂".equals(cloudHostProper.getCompanyName())){
             product.setIsAudit("1");

+ 1 - 1
fs-service/src/main/java/com/fs/hisStore/vo/FsStoreAfterSalesVO.java

@@ -116,5 +116,5 @@ public class FsStoreAfterSalesVO implements Serializable
     /**
      * 处方编号
      * **/
-    private String serialNo;
+    private String pid;
 }

+ 1 - 1
fs-service/src/main/java/com/fs/hisStore/vo/FsStoreOrderVO.java

@@ -272,6 +272,6 @@ public class FsStoreOrderVO implements Serializable
     /**
      * 处方单号
      * **/
-    private String serialNo;
+    private String pid;
 
 }

+ 2 - 0
fs-service/src/main/java/com/fs/hospital580/vo/PrescriptionAdminQueryVo.java

@@ -24,4 +24,6 @@ public class PrescriptionAdminQueryVo extends PageRequest {
     private Byte auditStatus;
 
     private String orderCode;
+
+    private String pid;
 }

+ 3 - 3
fs-service/src/main/resources/mapper/hisStore/FsStoreOrderScrmMapper.xml

@@ -1579,7 +1579,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         select o.*,u.phone,u.register_code,u.register_date,u.source, c.company_name ,cu.nick_name as company_user_nick_name ,cu.phonenumber as company_usere_phonenumber
         , csc.name miniProgramName,ssc.store_name,
         ssc.store_seq,
-        ssc.merchant_id,hps.serial_no
+        ssc.merchant_id,hps.pid
         from fs_store_order_scrm o
         left join fs_store_hospital580_prescription_scrm hps on hps.store_order_id = o.id
         left join fs_user u on o.user_id=u.user_id
@@ -1615,8 +1615,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="maps.orderCode != null and  maps.orderCode !=''">
                 and o.order_code like CONCAT('%',#{maps.orderCode},'%')
             </if>
-            <if test="maps.serialNo != null and  maps.serialNo !=''">
-                and hps.serial_no like CONCAT('%',#{maps.serialNo},'%')
+            <if test="maps.pid != null and  maps.pid !=''">
+                and hps.pid like CONCAT('%',#{maps.pid},'%')
             </if>
             <if test="maps.storeId != null">
                 and ssc.store_id = #{maps.storeId}

+ 52 - 0
fs-service/src/main/resources/mapper/hospital580/Hospital580PrescriptionScrmMapper.xml

@@ -98,6 +98,58 @@
         <if test="query.endTime != null and query.endTime != ''">
             AND hps.create_time &lt;= #{query.endTime}
         </if>
+        <if test="query.pid != null and query.pid != ''">
+            AND hps.pid LIKE CONCAT('%', #{query.pid}, '%')
+        </if>
+        ORDER BY hps.create_time DESC
+    </select>
+
+    <select id="getPrescription" resultType="com.fs.hospital580.entity.Hospital580PrescriptionScrmEntity">
+        SELECT
+        hps.*,
+        sos.order_code AS orderCode
+        FROM
+        fs_store_hospital580_prescription_scrm hps
+        LEFT JOIN fs_store_order_scrm sos ON sos.id = hps.store_order_id
+        WHERE
+        1=1
+        <if test="query.doctorId != null">
+            AND hps.audit_apothecary_id = #{query.doctorId}
+        </if>
+        <if test="query.status != null and query.status == 1">
+            AND hps.audit_status = 1
+        </if>
+        <if test="query.doctorDrugId != null">
+            AND hps.doctor_drug_id = #{query.doctorDrugId}
+        </if>
+        <if test="query.type != null">
+            AND hps.type = #{query.type}
+        </if>
+        <if test="query.patientName != null and query.patientName != ''">
+            AND hps.patient_name LIKE CONCAT('%', #{query.patientName}, '%')
+        </if>
+        <if test="query.orderCode != null and query.orderCode != ''">
+            AND sos.order_code LIKE CONCAT('%', #{query.orderCode}, '%')
+        </if>
+        <if test="query.prescribeCode != null and query.prescribeCode != ''">
+            AND hps.prescribe_code = #{query.prescribeCode}
+        </if>
+
+        <if test="query.prescribeType != null">
+            AND hps.prescribe_type = #{query.prescribeType}
+        </if>
+        <if test="query.companyUserId != null">
+            AND hps.company_user_id = #{query.companyUserId}
+        </if>
+        <if test="query.beginTime != null and query.beginTime != ''">
+            AND hps.create_time >= #{query.beginTime}
+        </if>
+        <if test="query.endTime != null and query.endTime != ''">
+            AND hps.create_time &lt;= #{query.endTime}
+        </if>
+        <if test="query.pid != null and query.pid != ''">
+            AND hps.pid LIKE CONCAT('%', #{query.pid}, '%')
+        </if>
         ORDER BY hps.create_time DESC
     </select>
 </mapper>