Просмотр исходного кода

修改处方图片生成条件

cgp 1 день назад
Родитель
Сommit
d9087f3577

+ 6 - 0
fs-service/src/main/java/com/fs/his/domain/FsPrescribeDataScrm.java

@@ -190,4 +190,10 @@ public class FsPrescribeDataScrm extends BaseEntity {
 
     /** 是否制单(0:否,1:是),只有值为0才能被医生修改 */
     private Integer isDocument;
+
+    /** 中医诊断 */
+    private String diagnoseChinese;
+
+    /** 中医医嘱 */
+    private String remarkChinese;
 }

+ 6 - 0
fs-service/src/main/java/com/fs/his/dto/FsPrescribeDataSubmitDto.java

@@ -20,4 +20,10 @@ public class FsPrescribeDataSubmitDto {
     private List<FsPrescribeDrugDataScrm> drugs;  // 药品列表
     private Map<Integer, List<FsPrescribeDrugDataScrm>> mapDrugs;//key为处方类型1西药 2中药,value为药品列表 组合处方就会有两个键值对,否则只有一个
     private Long doctorId;
+
+    /** 中医诊断 */
+    private String diagnoseChinese;
+
+    /** 中医医嘱 */
+    private String remarkChinese;
 }

+ 1 - 1
fs-service/src/main/java/com/fs/his/service/IFsPrescribeDataScrmService.java

@@ -90,7 +90,7 @@ public interface IFsPrescribeDataScrmService
     List<FsPrescribeDataScrmVO> pendingStorePrescribeList(FsPrescribeDataDrugDoctorQueryDto queryDto);
 
     /**
-     * 药师---操作商城处方
+     * 药师---审核商城处方
      * */
     int drugDoctorExecuteScrmPrescribe(FsPrescribeDataDrugDoctorUpdateDto updateDto);
 

+ 15 - 9
fs-service/src/main/java/com/fs/his/service/impl/FsPrescribeDataScrmServiceImpl.java

@@ -150,32 +150,32 @@ public class FsPrescribeDataScrmServiceImpl implements IFsPrescribeDataScrmServi
         return CollectionUtils.isEmpty(list) ? Collections.emptyList() : list;
     }
 
-    // ==================== 医生操作 ====================
+    // 医生拒方
     @Override
     @Transactional(rollbackFor = Exception.class)
     public int doctorRejectScrmPrescribe(FsPrescribeDataDoctorUpdateDto updateDto) {
         if (getPrescribeIsDocument(updateDto.getPrescribeId())){
             throw new CustomException("销售已制单,当前操作不可执行,请刷新后重试!");
         }
+        // 拒方
+        if (StringUtils.isBlank(updateDto.getAuditReason())) {
+            throw new CustomException("拒方原因不能为空");
+        }
+        updateDto.setAuditReason("医生拒方:"+updateDto.getAuditReason());
         // 1. 清除原有基础处方图片
         clearPrescriptionImage(updateDto.getPrescribeId());
-
-        // 2. 更新处方主记录
+        // 2. 更新处方记录
         FsPrescribeDataScrm updatePrescribe = new FsPrescribeDataScrm();
         BeanCopyUtils.copy(updateDto, updatePrescribe);
         updatePrescribe.setDoctorConfirm(-1);
         int updateCount = fsPrescribeDataScrmMapper.updateFsPrescribeDataScrm(updatePrescribe);
-        // 拒方
-        if (StringUtils.isBlank(updateDto.getAuditReason())) {
-            throw new CustomException("拒方原因不能为空");
-        }
         // 更新客户信息表状态为已拒方
         updateCustomerStatus(updateDto.getPrescribeId(), REJECT_PRESCRIBE);
 
         return updateCount;
     }
 
-    // ==================== 药师操作 ====================
+    // 药师---审核商城处方
     @Override
     @Transactional(rollbackFor = Exception.class)
     public int drugDoctorExecuteScrmPrescribe(FsPrescribeDataDrugDoctorUpdateDto updateDto) {
@@ -193,10 +193,13 @@ public class FsPrescribeDataScrmServiceImpl implements IFsPrescribeDataScrmServi
         if (updateDto.getStatus() == 1) {
             // 审核通过 → 异步生成医生+药师签名处方图片任务
             submitPrescribeImageTask(updateDto.getPrescribeId(), 2);
+            // 直接生成医生签名+药师签名处方图片(这里可能会有性能问题)
+            //prescriptionTaskRecordService.prescribeScrmImgYsyTask(updateDto.getPrescribeId(), 2);
             updateCustomerStatus(updateDto.getPrescribeId(), OPEN_PRESCRIBE);
         } else if (updateDto.getStatus() == 2) {
             // 审核不通过 → 清除处方图片,退回状态
             clearPrescriptionImage(updateDto.getPrescribeId());
+            updateDto.setAuditReason("药师审核不通过:"+updateDto.getAuditReason());
             updateDto.setDoctorConfirm(0);//药师审核不通过,处方医生状态回退为"待开方"
             updateCustomerStatus(updateDto.getPrescribeId(), IS_PRESCRIBING);
         }
@@ -288,12 +291,15 @@ public class FsPrescribeDataScrmServiceImpl implements IFsPrescribeDataScrmServi
         if (getPrescribeIsDocument(submitDto.getPrescribeId())){
             throw new CustomException("销售已制单,当前操作不可执行,请刷新后重试!");
         }
-        // 1. 清除原处方图片(如果有
+        // 1. 清除上次生成的处方图片(因为同一处方医生会开多次
         clearPrescriptionImage(submitDto.getPrescribeId());
 
         // 2. 更新处方主表数据
         FsPrescribeDataScrm update = new FsPrescribeDataScrm();
         BeanCopyUtils.copy(submitDto, update);
+        // 显式设置中药字段
+        update.setDiagnoseChinese(submitDto.getDiagnoseChinese());
+        update.setRemarkChinese(submitDto.getRemarkChinese());
         update.setDoctorConfirm(1);  // 确认开方
         update.setStatus(0);  // 待药师审核
         int updateCount = fsPrescribeDataScrmMapper.updateFsPrescribeDataScrm(update);

+ 32 - 3
fs-service/src/main/java/com/fs/his/service/impl/PrescriptionTaskRecordServiceImpl.java

@@ -247,15 +247,44 @@ public class PrescriptionTaskRecordServiceImpl implements PrescriptionTaskRecord
         imgParam.setPatientAge(imgVO.getPatientAge());
         imgParam.setOutpatientId(imgVO.getPrescribeCode());
 
-        if (com.fs.common.utils.StringUtils.isNotBlank(imgVO.getRemark())) {
-            imgParam.setRemark(imgVO.getRemark());
+        // ========== 1. 根据处方类型和药品类型决定使用哪组诊断/医嘱 ==========
+        String diagnoseToUse = imgVO.getDiagnose();      // 默认使用通用字段(即西医)
+        String remarkToUse = imgVO.getRemark();          // 默认使用通用字段(即西医)
+
+        // 判断是否为组合处方(类型3)
+        if (imgVO.getPrescribeType() != null && imgVO.getPrescribeType() == 3) {
+            // 检查当前药品列表是否非空,取第一个药品判断类型(因为此方法按类型分组调用,全组药品类型一致)
+            if (CollectionUtils.isNotEmpty(drugList)) {
+                Integer drugType = drugList.get(0).getDrugType(); // 1-西药,2-中药
+                if (drugType != null && drugType == 2) {
+                    // ---------- 中药部分:优先使用中药专用字段 ----------
+                    if (StringUtils.isNotBlank(imgVO.getDiagnoseChinese())) {
+                        diagnoseToUse = imgVO.getDiagnoseChinese();
+                    }
+                    // 如果中药诊断为空,则降级使用通用诊断(保持兼容性)
+                    // 医嘱同理
+                    if (StringUtils.isNotBlank(imgVO.getRemarkChinese())) {
+                        remarkToUse = imgVO.getRemarkChinese();
+                    }
+                    // 若中药医嘱也为空,则保留通用医嘱或下方默认值
+                }
+                // 西药部分(drugType == 1)则保持 diagnoseToUse / remarkToUse 不变(即通用字段)
+            }
+        }
+        // 对于单一处方(类型1或2),依然使用通用字段,不受影响
+
+        // ========== 2. 设置诊断 ==========
+        imgParam.setDiagnose(diagnoseToUse);
+
+        // ========== 3. 设置医嘱(带默认值兜底) ==========
+        if (StringUtils.isNotBlank(remarkToUse)) {
+            imgParam.setRemark(remarkToUse);
         } else {
             log.error("PrescribeImgYsyTask 处方id:{},缺失医嘱内容", imgVO.getPrescribeId());
             imgParam.setRemark("请按照用药说明书服用药品,如有不适,请及时就医!");
         }
 
         imgParam.setHistoryAllergic(imgVO.getHistoryAllergic());
-        imgParam.setDiagnose(imgVO.getDiagnose());
         imgParam.setPrescribeDrug(convertToPrescribeDrugList(drugList));
 
         // 签名设置(保底默认全部签名)

+ 6 - 0
fs-service/src/main/java/com/fs/his/vo/FsPrescribeDataScrmImgVO.java

@@ -27,4 +27,10 @@ public class FsPrescribeDataScrmImgVO extends FsPrescribeDataScrm {
     /** 药师签名 */
     private String drugDoctorSign;
 
+    /** 中医诊断 */
+    private String diagnoseChinese;
+
+    /** 中医医嘱 */
+    private String remarkChinese;
+
 }

+ 32 - 0
fs-service/src/main/java/com/fs/qw/service/impl/FsCompanyCustomerServiceImpl.java

@@ -10,8 +10,11 @@ import com.fs.common.utils.StringUtils;
 import com.fs.company.domain.CompanyDept;
 import com.fs.company.domain.CompanyUser;
 import com.fs.company.mapper.CompanyDeptMapper;
+import com.fs.company.mapper.CompanyUserMapper;
+import com.fs.his.domain.FsDoctor;
 import com.fs.his.domain.FsImportMember;
 import com.fs.his.domain.FsPrescribeDataScrm;
+import com.fs.his.mapper.FsDoctorMapper;
 import com.fs.his.mapper.FsImportMemberMapper;
 import com.fs.his.mapper.FsPrescribeDataScrmMapper;
 import com.fs.his.service.IFsUserAddressService;
@@ -72,6 +75,12 @@ public class FsCompanyCustomerServiceImpl implements IFsCompanyCustomerService {
     @Autowired
     private IFsUserAddressService fsUserAddressService;
 
+    @Autowired
+    private FsDoctorMapper fsDoctorMapper;
+
+    @Autowired
+    private CompanyUserMapper companyUserMapper;
+
     private static final Set<Integer> ALLOWED_STATUSES =
             Collections.unmodifiableSet(new HashSet<>(Arrays.asList(0, 5, 6))); // 允许操作完善客户信息的状态
 
@@ -94,6 +103,14 @@ public class FsCompanyCustomerServiceImpl implements IFsCompanyCustomerService {
         //批量获取处方信息
         List<FsPrescribeDataScrm> fsPrescribeDataScrms = prescribeDataScrmMapper.selectFsPrescribeDataScrmListByIds(prescriptionIds);
         //TODO 后续可能会在客户信息列表展示商城处方信息
+        //批量获取医生id
+        List<Long> doctorIds = companyCustomers.stream().map(FsCompanyCustomer::getDoctorId).filter(Objects::nonNull).collect(Collectors.toList());
+        //查询医生信息并用Map<Long,String>存起来key为医生id,value为医生名称
+        Map<Long, String> doctorMap = fsDoctorMapper.selectDoctorByIds(doctorIds).stream().collect(Collectors.toMap(FsDoctor::getDoctorId, FsDoctor::getDoctorName));
+        //遍历companyCustomers根据医生id赋值正确医生名字
+        companyCustomers.forEach(customer -> {
+            customer.setDoctorName(doctorMap.get(customer.getDoctorId()));
+        });
         return companyCustomers;
     }
 
@@ -243,6 +260,15 @@ public class FsCompanyCustomerServiceImpl implements IFsCompanyCustomerService {
         fsCompanyCustomer.setCompanyUserId(companyUser.getUserId());
         fsCompanyCustomer.setCompanyUserName(companyUser.getNickName());
         fsCompanyCustomer.setClaimStatus(BigDecimal.ONE.intValue());//已认领
+        //获取销售绑定医生信息
+        companyUser = companyUserMapper.selectCompanyUserById(companyUser.getUserId());
+        if (companyUser==null||companyUser.getDoctorId()==null){
+            throw new CustomException("销售未绑定医生");
+        }
+        //查询医生信息
+        FsDoctor fsDoctor = fsDoctorMapper.selectFsDoctorByDoctorId(companyUser.getDoctorId());
+        fsCompanyCustomer.setDoctorId(fsDoctor.getDoctorId());
+        fsCompanyCustomer.setDoctorName(fsDoctor.getDoctorName());
         return fsCompanyCustomerMapper.updateFsCompanyCustomer(fsCompanyCustomer);
     }
 
@@ -310,7 +336,13 @@ public class FsCompanyCustomerServiceImpl implements IFsCompanyCustomerService {
         if (fsCompanyCustomer == null) {
             return customerInfoVO;
         }
+        //-----------------------组装客户基本信息----------------------------------
         BeanUtils.copyProperties(fsCompanyCustomer, customerInfoVO);
+        //电话号脱敏
+        if (customerInfoVO.getPhone() != null) {
+            customerInfoVO.setPhone(customerInfoVO.getPhone().replaceAll("(\\d{3})\\d*(\\d{4})", "$1****$2"));
+        }
+        //-----------------------开始处理Json问答数据----------------------------------
         String jsonStr = fsCompanyCustomer.getJsonInfo();
         if (StringUtils.isBlank(jsonStr)) {
             return customerInfoVO;

+ 10 - 1
fs-service/src/main/resources/mapper/his/FsPrescribeDataScrmMapper.xml

@@ -65,6 +65,8 @@
         <result property="createBy"                   column="create_by"                   />
         <result property="updateBy"                   column="update_by"                   />
         <result property="updateTime"                 column="update_time"                 />
+        <result property="diagnoseChinese"            column="diagnose_chinese"            />
+        <result property="remarkChinese"              column="remark_chinese"              />
     </resultMap>
 
     <sql id="selectFsPrescribeDataScrmVo">
@@ -78,7 +80,8 @@
                prescribe_code_url, cycle, icd_code, source, doctor_confirm, start_operate_time,
                end_operate_time, operate_second, third_party_user_id, is_send_to_third_party,
                handwrite_collection_id, company_customer_id,
-               food_and_exercise_guidance, healing_area_json, note_taboos, facial_diagnosis,is_document
+               food_and_exercise_guidance, healing_area_json, note_taboos, facial_diagnosis,is_document,
+               diagnose_chinese,remark_chinese
         from fs_prescribe_data_scrm
     </sql>
 
@@ -249,6 +252,8 @@
             <if test="noteTaboos != null">note_taboos,</if>
             <if test="facialDiagnosis != null">facial_diagnosis,</if>
             <if test="isDocument != null">is_document,</if>
+            <if test="diagnoseChinese != null">diagnose_chinese,</if>
+            <if test="remarkChinese != null">remark_chinese,</if>
         </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="prescribeType != null">#{prescribeType},</if>
@@ -307,6 +312,8 @@
             <if test="noteTaboos != null">#{noteTaboos},</if>
             <if test="facialDiagnosis != null">#{facialDiagnosis},</if>
             <if test="isDocument != null">#{isDocument},</if>
+            <if test="diagnoseChinese != null">#{diagnoseChinese},</if>
+            <if test="remarkChinese != null">#{remarkChinese},</if>
         </trim>
     </insert>
 
@@ -369,6 +376,8 @@
             <if test="noteTaboos != null">note_taboos = #{noteTaboos},</if>
             <if test="facialDiagnosis != null">facial_diagnosis = #{facialDiagnosis},</if>
             <if test="isDocument != null">is_document = #{isDocument},</if>
+            <if test="diagnoseChinese != null">diagnose_chinese = #{diagnoseChinese},</if>
+            <if test="remarkChinese != null">remark_chinese = #{remarkChinese},</if>
         </trim>
         where prescribe_id = #{prescribeId}
     </update>