Forráskód Böngészése

益寿缘-优化处方单生成时自动分配在线药师,支持降级兜底

cgp 4 hete
szülő
commit
62cfd58db7

+ 3 - 0
fs-service/src/main/java/com/fs/his/mapper/FsDoctorMapper.java

@@ -180,6 +180,9 @@ public interface FsDoctorMapper
     @Select("select * from fs_doctor where doctor_type=2 and  `status`=1 and is_audit=1 and sign_url is not null and audit_type LIKE CONCAT('%', #{type}, '%')  ORDER BY RAND() LIMIT 1")
     FsDoctor selectPackageFsDoctorType2Ids(Integer type);
 
+    //根据入参类型随机返回一个在线药师
+    FsDoctor selectRandomOnlineDoctorForPackage(@Param("type") Integer type);
+
     @Select("select doctor_id from fs_doctor where doctor_type=1 and  `status`=1 and is_audit=1 and is_agreement_prescribe_doctor=1  and sign_url is not null")
     List<Long>  selectFsDoctorDoctorByPackage();
 

+ 12 - 5
fs-service/src/main/java/com/fs/his/service/impl/FsPrescribeServiceImpl.java

@@ -722,7 +722,6 @@ public class FsPrescribeServiceImpl implements IFsPrescribeService
         if (!productIds.isEmpty()) { // 只有当有 productIds 时才查询
             storeProductIns = fsStoreProductMapper.getStoreProductInProductIds(new ArrayList<>(productIds));
             if (storeProductIns.isEmpty()) {
-                // log.info("根据产品id:{}查询产品信息为空!",storeProductIns); // 修改日志内容
                 log.info("根据产品id列表:{}查询产品信息为空!", productIds);
             }
         }
@@ -824,10 +823,18 @@ public class FsPrescribeServiceImpl implements IFsPrescribeService
         fsPrescribe.setPrescribeDoctorId(fsDoctor.getDoctorId());
         fsPrescribe.setPrescribeDoctorSignUrl(fsDoctor.getSignUrl());
 
-        FsDoctor drug =doctorMapper.selectPackageFsDoctorType2Ids(fsPackage.getProductType());
-
-        fsPrescribe.setDrugDoctorId(drug.getDoctorId());
-        fsPrescribe.setDrugDoctorSignUrl(drug.getSignUrl());
+        //分配在线的随机药师
+        FsDoctor fsDrugDoctor = doctorMapper.selectRandomOnlineDoctorForPackage(fsPackage.getProductType());
+        if (fsDrugDoctor==null){
+            //兜底情况,如果没有在线的药师就无论在线随机分配
+            fsDrugDoctor=doctorMapper.selectPackageFsDoctorType2Ids(fsPackage.getProductType());
+            if (fsDrugDoctor == null) {
+                log.error("无法分配药师:productType={}, 无可用在线或离线药师", fsPackage.getProductType());
+                throw new CustomException("当前无可用药师,请稍后再试");
+            }
+        }
+        fsPrescribe.setDrugDoctorId(fsDrugDoctor.getDoctorId());
+        fsPrescribe.setDrugDoctorSignUrl(fsDrugDoctor.getSignUrl());
 
         int i = fsPrescribeMapper.insertFsPrescribe(fsPrescribe);
         if(i>0){

+ 13 - 0
fs-service/src/main/resources/mapper/his/FsDoctorMapper.xml

@@ -124,6 +124,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             #{doctorId}
         </foreach>
     </select>
+    <select id="selectRandomOnlineDoctorForPackage" resultType="com.fs.his.domain.FsDoctor">
+        SELECT d.*
+        FROM fs_doctor d
+                 INNER JOIN fs_doctor_online_info o ON d.doctor_id = o.doctor_id
+        WHERE d.doctor_type = 2
+          AND d.status = 1
+          AND d.is_audit = 1
+          AND d.sign_url IS NOT NULL
+          AND d.audit_type LIKE CONCAT('%', #{type}, '%')
+          AND o.is_online = 1
+        ORDER BY RAND()
+        LIMIT 1
+    </select>
 
     <insert id="insertFsDoctor" parameterType="FsDoctor" useGeneratedKeys="true" keyProperty="doctorId">
         insert into fs_doctor