|
|
@@ -829,10 +829,16 @@ public class FsPrescribeServiceImpl implements IFsPrescribeService
|
|
|
fsPrescribe.setPrescribeDoctorSignUrl(fsDoctor.getSignUrl());
|
|
|
|
|
|
//分配在线的随机药师
|
|
|
- FsDoctor fsDrugDoctor = doctorMapper.selectRandomOnlineDoctorForPackage();
|
|
|
- if (fsDrugDoctor==null){
|
|
|
- //兜底情况,如果没有在线的药师就无论在线随机分配
|
|
|
- fsDrugDoctor=doctorMapper.selectPackageFsDoctorType2Ids();
|
|
|
+ List<FsDoctor> onlineDoctors = doctorMapper.selectRandomOnlineDoctorForPackage();
|
|
|
+ FsDoctor fsDrugDoctor = null;
|
|
|
+
|
|
|
+ if (onlineDoctors != null && !onlineDoctors.isEmpty()) {
|
|
|
+ // 有在线药师:应用层随机选一个
|
|
|
+ Collections.shuffle(onlineDoctors);
|
|
|
+ fsDrugDoctor = onlineDoctors.get(0);
|
|
|
+ } else {
|
|
|
+ // 兜底:无在线药师,随机选一个 type=2 的(不管是否在线)
|
|
|
+ fsDrugDoctor = doctorMapper.selectPackageFsDoctorType2Ids();
|
|
|
if (fsDrugDoctor == null) {
|
|
|
log.error("无法分配药师:productType={}, 无可用在线或离线药师", fsPackage.getProductType());
|
|
|
throw new CustomException("当前无可用药师,请稍后再试");
|