|
@@ -1,20 +1,25 @@
|
|
|
package com.fs.his.service.impl;
|
|
package com.fs.his.service.impl;
|
|
|
|
|
|
|
|
|
|
+import cn.hutool.core.util.IdUtil;
|
|
|
import com.fs.common.BeanCopyUtils;
|
|
import com.fs.common.BeanCopyUtils;
|
|
|
import com.fs.common.exception.CustomException;
|
|
import com.fs.common.exception.CustomException;
|
|
|
import com.fs.common.utils.DateUtils;
|
|
import com.fs.common.utils.DateUtils;
|
|
|
|
|
+import com.fs.common.utils.uuid.UUID;
|
|
|
import com.fs.his.domain.*;
|
|
import com.fs.his.domain.*;
|
|
|
import com.fs.his.dto.*;
|
|
import com.fs.his.dto.*;
|
|
|
import com.fs.his.enums.DoctorTypeEnum;
|
|
import com.fs.his.enums.DoctorTypeEnum;
|
|
|
import com.fs.his.mapper.*;
|
|
import com.fs.his.mapper.*;
|
|
|
import com.fs.his.param.PrescribeXyImgParam;
|
|
import com.fs.his.param.PrescribeXyImgParam;
|
|
|
import com.fs.his.service.IFsPrescribeDataScrmService;
|
|
import com.fs.his.service.IFsPrescribeDataScrmService;
|
|
|
|
|
+import com.fs.his.service.IPollingAssignDoctorService;
|
|
|
import com.fs.his.service.PrescriptionImageService;
|
|
import com.fs.his.service.PrescriptionImageService;
|
|
|
import com.fs.his.vo.DoctorSignVO;
|
|
import com.fs.his.vo.DoctorSignVO;
|
|
|
import com.fs.his.vo.FsPrescribeDataScrmImgVO;
|
|
import com.fs.his.vo.FsPrescribeDataScrmImgVO;
|
|
|
import com.fs.hisStore.domain.FsStoreProductScrm;
|
|
import com.fs.hisStore.domain.FsStoreProductScrm;
|
|
|
import com.fs.hisStore.mapper.FsStoreProductScrmMapper;
|
|
import com.fs.hisStore.mapper.FsStoreProductScrmMapper;
|
|
|
|
|
+import com.fs.qw.domain.FsCompanyCustomer;
|
|
|
import com.fs.qw.mapper.FsCompanyCustomerMapper;
|
|
import com.fs.qw.mapper.FsCompanyCustomerMapper;
|
|
|
|
|
+import com.fs.qw.service.IFsCompanyCustomerService;
|
|
|
import com.fs.qw.vo.FsPrescribeDataScrmVO;
|
|
import com.fs.qw.vo.FsPrescribeDataScrmVO;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
@@ -61,6 +66,12 @@ public class FsPrescribeDataScrmServiceImpl implements IFsPrescribeDataScrmServi
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private ApplicationContext applicationContext;
|
|
private ApplicationContext applicationContext;
|
|
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private IFsCompanyCustomerService companyCustomerService;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private IPollingAssignDoctorService pollingAssignDoctorService;
|
|
|
|
|
+
|
|
|
private IFsPrescribeDataScrmService self() {
|
|
private IFsPrescribeDataScrmService self() {
|
|
|
return applicationContext.getBean(IFsPrescribeDataScrmService.class);
|
|
return applicationContext.getBean(IFsPrescribeDataScrmService.class);
|
|
|
}
|
|
}
|
|
@@ -292,6 +303,75 @@ public class FsPrescribeDataScrmServiceImpl implements IFsPrescribeDataScrmServi
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
|
+ @Transactional
|
|
|
|
|
+ public void generatePrescribeData(Long companyCustomerId) {
|
|
|
|
|
+ FsCompanyCustomer customer = companyCustomerService.selectFsCompanyCustomerById(companyCustomerId);
|
|
|
|
|
+ if (customer == null) {
|
|
|
|
|
+ log.error("未查询到有效客户信息, 客户id:{}", companyCustomerId);
|
|
|
|
|
+ throw new CustomException("未查询到有效客户信息");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (customer.getTemplateId() == null) {
|
|
|
|
|
+ log.error("未查询到有效病例模板信息, 客户id:{}", companyCustomerId);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (customer.getProcessStatus() == 0) {
|
|
|
|
|
+ log.error("客户未完善信息, 客户id:{}", companyCustomerId);
|
|
|
|
|
+ throw new CustomException("客户未完善信息");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (customer.getProcessStatus() != 1) {
|
|
|
|
|
+ log.error("状态错误, 客户id:{}", companyCustomerId);
|
|
|
|
|
+ throw new CustomException("状态错误");
|
|
|
|
|
+ }
|
|
|
|
|
+ FsPrescribeDataScrm data = new FsPrescribeDataScrm();
|
|
|
|
|
+ data.setCompanyCustomerId(companyCustomerId);
|
|
|
|
|
+ // 设置患者信息
|
|
|
|
|
+ // 患者名称
|
|
|
|
|
+ data.setPatientName(customer.getCustomerName());
|
|
|
|
|
+ // 患者年龄
|
|
|
|
|
+ if (customer.getAge() != null) {
|
|
|
|
|
+ data.setPatientAge(customer.getAge().toString());
|
|
|
|
|
+ }
|
|
|
|
|
+ // 患者性别
|
|
|
|
|
+ data.setPatientGender(Integer.valueOf(customer.getSex()));
|
|
|
|
|
+ // 患者手机号
|
|
|
|
|
+ data.setPatientTel(customer.getPhone());
|
|
|
|
|
+ // 处方单号
|
|
|
|
|
+ String prescribeCode= IdUtil.getSnowflake(0, 0).nextIdStr();
|
|
|
|
|
+ data.setPrescribeCode(prescribeCode);
|
|
|
|
|
+ // 医生id
|
|
|
|
|
+ data.setDoctorId(customer.getDoctorId());
|
|
|
|
|
+ data.setStatus(0);
|
|
|
|
|
+ data.setCreateTime(DateUtils.getNowDate());
|
|
|
|
|
+ data.setDoctorConfirm(0);
|
|
|
|
|
+ data.setIsDocument(0);
|
|
|
|
|
+
|
|
|
|
|
+ //分配在线的随机药师
|
|
|
|
|
+ FsDoctor fsDrugDoctor = null;
|
|
|
|
|
+ try {
|
|
|
|
|
+ // 使用新写的轮询服务分配药师,传入处方编号
|
|
|
|
|
+ fsDrugDoctor = pollingAssignDoctorService.getNextPharmacist(prescribeCode);
|
|
|
|
|
+
|
|
|
|
|
+ data.setDrugDoctorId(fsDrugDoctor.getDoctorId());
|
|
|
|
|
+ data.setDrugDoctorSignUrl(fsDrugDoctor.getSignUrl());
|
|
|
|
|
+
|
|
|
|
|
+ log.info("轮询分配药师成功 - 处方号:{}, 药师ID:{}, 药师姓名:{}",
|
|
|
|
|
+ prescribeCode, fsDrugDoctor.getDoctorId(), fsDrugDoctor.getDoctorName());
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ log.error("分配药师失败 - 处方号:{}", prescribeCode, e);
|
|
|
|
|
+ data.setDrugDoctorId(1L);//为了不影响主业务执行设置默认值
|
|
|
|
|
+ }
|
|
|
|
|
+ //出入开方信息
|
|
|
|
|
+ fsPrescribeDataScrmMapper.insertFsPrescribeDataScrm(data);
|
|
|
|
|
+
|
|
|
|
|
+ FsCompanyCustomer mapCustomer = new FsCompanyCustomer();
|
|
|
|
|
+ mapCustomer.setId(companyCustomerId);
|
|
|
|
|
+ mapCustomer.setProcessStatus(2);
|
|
|
|
|
+ mapCustomer.setUpdateTime(DateUtils.getNowDate());
|
|
|
|
|
+
|
|
|
|
|
+ //更新客户信息
|
|
|
|
|
+ companyCustomerMapper.updateFsCompanyCustomer(mapCustomer);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
// ==================== 处方图片生成 ====================
|
|
// ==================== 处方图片生成 ====================
|
|
|
/**
|
|
/**
|
|
|
* 生成处方图片(异步任务调用)
|
|
* 生成处方图片(异步任务调用)
|