Parcourir la source

客户信息表增加处方图片展示

cgp il y a 2 jours
Parent
commit
167cd0c777

+ 0 - 2
fs-admin/src/main/java/com/fs/qw/controller/FsCompanyCustomerController.java

@@ -41,8 +41,6 @@ public class FsCompanyCustomerController extends BaseController {
     }
 
 
-
-
     @PreAuthorize("@ss.hasPermi('qw:companyCustomer:export')")
     @Log(title = "客户信息", businessType = BusinessType.EXPORT)
     @GetMapping("/export")

+ 41 - 0
fs-company/src/main/java/com/fs/company/controller/qw/FsCompanyCustomerController.java

@@ -14,10 +14,12 @@ import com.fs.framework.security.LoginUser;
 import com.fs.framework.security.SecurityUtils;
 import com.fs.his.domain.FsDoctorPatient;
 import com.fs.his.domain.FsPrescribe;
+import com.fs.his.domain.FsPrescribeDataScrm;
 import com.fs.his.dto.AddressInfoDTO;
 import com.fs.his.param.CollectionPhoneParam;
 import com.fs.his.param.PrescribePhoneParam;
 import com.fs.his.service.IFsDoctorPatientService;
+import com.fs.his.service.IFsPrescribeDataScrmService;
 import com.fs.his.service.IFsPrescribeService;
 import com.fs.hisStore.param.FsCompanyCustomerOrderParam;
 import com.fs.hisStore.service.IFsUserInformationCollectionService;
@@ -61,6 +63,9 @@ public class FsCompanyCustomerController extends BaseController {
     @Autowired
     private IFsPrescribeService fsPrescribeService;
 
+    @Autowired
+    private IFsPrescribeDataScrmService prescribeDataScrmService;
+
     @Autowired
     private IFsUserInformationCollectionService fsUserInformationCollectionService;
 
@@ -143,6 +148,18 @@ public class FsCompanyCustomerController extends BaseController {
 
     }
 
+    /**
+     * 根据客户信息表id获取关联处方信息
+     * */
+    @GetMapping("/getScrmPrescribeInfo/{id}")
+    public AjaxResult getPrescribeList(@PathVariable Long id) {
+        FsCompanyCustomer fsCompanyCustomer = fsCompanyCustomerService.selectFsCompanyCustomerById(id);
+        if (fsCompanyCustomer!=null&&fsCompanyCustomer.getPrescribeId()!=null){
+            FsPrescribeDataScrm prescribeDataScrm = prescribeDataScrmService.selectFsPrescribeDataScrmByPrescribeId(fsCompanyCustomer.getPrescribeId());
+            return AjaxResult.success(prescribeDataScrm);
+        }
+        return AjaxResult.success("获取处方信息失败");
+    }
     /**
      * 获取客户详情
      */
@@ -332,6 +349,30 @@ public class FsCompanyCustomerController extends BaseController {
         return toAjax( result);
     }
 
+    /**
+     * 修改商城处方表的制单状态
+     * */
+    @PostMapping("/updateScrmPrescriptionDocumentSuccess")
+    public AjaxResult updateScrmPrescriptionDocumentSuccess(@RequestBody FsCompanyCustomer fsCompanyCustomer){
+        LoginUser loginUser = SecurityUtils.getLoginUser();
+        Long companyUserId = loginUser.getUser().getUserId();
+        if (companyUserId == null){
+            throw new CustomException("登录信息已过期,请重新登录");
+        }
+        FsCompanyCustomer companyCustomer = fsCompanyCustomerService.selectFsCompanyCustomerById(fsCompanyCustomer.getId());
+        if (companyCustomer == null){
+            return AjaxResult.error("未找到客户信息");
+        }
+        //重置客户信息表的流程状态为"待开方"
+        companyCustomer.setProcessStatus(1);
+        fsCompanyCustomerService.updateFsCompanyCustomer(companyCustomer);
+        FsPrescribeDataScrm fsPrescribeDataScrm=new FsPrescribeDataScrm();
+        fsPrescribeDataScrm.setPrescribeId(companyCustomer.getPrescribeId());
+        fsPrescribeDataScrm.setIsDocument(1);//1-销售已制单
+        int result=prescribeDataScrmService.updateFsPrescribeDataScrm(fsPrescribeDataScrm);
+        return toAjax( result);
+    }
+
     /**
      * 生成客户信息表制单二维码
      * */

+ 33 - 0
fs-doctor-app/src/main/java/com/fs/app/controller/FsPrescribeDataScrmController.java

@@ -12,7 +12,10 @@ import com.fs.common.utils.poi.ExcelUtil;
 import com.fs.his.domain.FsPrescribeDataScrm;
 import com.fs.his.dto.*;
 import com.fs.his.service.IFsPrescribeDataScrmService;
+import com.fs.his.vo.CustomerQuestionAnswerVO;
 import com.fs.his.vo.DoctorSignVO;
+import com.fs.his.vo.PrescribeScrmDoctorAdviceVO;
+import com.fs.qw.service.IFsCompanyCustomerService;
 import com.fs.qw.vo.FsPrescribeDataScrmVO;
 import com.github.pagehelper.PageHelper;
 import io.jsonwebtoken.Claims;
@@ -36,6 +39,9 @@ public class FsPrescribeDataScrmController extends BaseController
     @Autowired
     private IFsPrescribeDataScrmService fsPrescribeScrmService;
 
+    @Autowired
+    private IFsCompanyCustomerService fsCompanyCustomerService;
+
     @Autowired
     JwtUtils jwtUtils;
 
@@ -110,6 +116,15 @@ public class FsPrescribeDataScrmController extends BaseController
         return getDataTable(list);
     }
 
+    /**
+     * 获取客户问答信息(根据客户信息表id)
+     */
+    @GetMapping("/getCustomerQuestionAnswer/{companyCustomerId}")
+    public AjaxResult getCustomerQuestionAnswer(@PathVariable Long companyCustomerId) {
+        List<CustomerQuestionAnswerVO> list = fsCompanyCustomerService.getCustomerQuestionAnswer(companyCustomerId);
+        return AjaxResult.success(list);
+    }
+
     /**
      * 获取医生、药师签名信息
      * @param doctorIds 医生id和药师id
@@ -121,6 +136,24 @@ public class FsPrescribeDataScrmController extends BaseController
         return AjaxResult.success(signVO);
     }
 
+    /**
+     * 获取医生建议信息(诊断、舌诊、饮食运动建议、治疗方面、禁忌)
+     */
+    @GetMapping("/getDoctorAdvice/{prescribeId}")
+    public AjaxResult getDoctorAdvice(@PathVariable Long prescribeId) {
+        FsPrescribeDataScrm prescribe = fsPrescribeScrmService.selectFsPrescribeDataScrmByPrescribeId(prescribeId);
+        if (prescribe == null) {
+            return AjaxResult.error("处方不存在");
+        }
+        PrescribeScrmDoctorAdviceVO vo = new PrescribeScrmDoctorAdviceVO();
+        vo.setDiagnose(prescribe.getDiagnose());
+        vo.setFacialDiagnosis(prescribe.getFacialDiagnosis());
+        vo.setFoodAndExerciseGuidance(prescribe.getFoodAndExerciseGuidance());
+        vo.setHealingAreaJson(prescribe.getHealingAreaJson());
+        vo.setNoteTaboos(prescribe.getNoteTaboos());
+        return AjaxResult.success(vo);
+    }
+
     /**
      * 商城处方-医生提交建议-开方前的操作
      * */

+ 6 - 0
fs-service/src/main/java/com/fs/his/service/impl/FsPrescribeDataScrmServiceImpl.java

@@ -130,6 +130,9 @@ public class FsPrescribeDataScrmServiceImpl implements IFsPrescribeDataScrmServi
     @Override
     public List<FsPrescribeDataScrmVO> pendingStorePrescribeList(FsPrescribeDataDrugDoctorQueryDto queryDto) {
         List<FsPrescribeDataScrmVO> list = fsPrescribeDataScrmMapper.pendingStorePrescribeList(queryDto);
+        if (CollectionUtils.isEmpty(list)){
+            return Collections.emptyList();
+        }
         //收集处方id集合
         Set<Long> prescribeIds = list.stream().map(FsPrescribeDataScrmVO::getPrescribeId).collect(Collectors.toSet());
         //查询处方药品列表
@@ -255,6 +258,7 @@ public class FsPrescribeDataScrmServiceImpl implements IFsPrescribeDataScrmServi
         fsPrescribeDataScrm.setFoodAndExerciseGuidance(addDoctorAdviceDTO.getFoodAndExerciseGuidance());
         fsPrescribeDataScrm.setNoteTaboos(addDoctorAdviceDTO.getNoteTaboos());
         fsPrescribeDataScrm.setHealingAreaJson(addDoctorAdviceDTO.getHealingAreaJson());
+        fsPrescribeDataScrm.setRecipeType(1);//医生已填写建议信息
         return fsPrescribeDataScrmMapper.updateFsPrescribeDataScrm(fsPrescribeDataScrm);
     }
 
@@ -363,6 +367,7 @@ public class FsPrescribeDataScrmServiceImpl implements IFsPrescribeDataScrmServi
         data.setCreateTime(DateUtils.getNowDate());
         data.setDoctorConfirm(0);
         data.setIsDocument(0);
+        data.setRecipeType(0);//医生是否填写建议,初始默认未填写
 
         //分配在线的随机药师
         FsDoctor fsDrugDoctor = null;
@@ -386,6 +391,7 @@ public class FsPrescribeDataScrmServiceImpl implements IFsPrescribeDataScrmServi
         mapCustomer.setId(companyCustomerId);
         mapCustomer.setProcessStatus(2);
         mapCustomer.setUpdateTime(DateUtils.getNowDate());
+        mapCustomer.setPrescribeId(data.getPrescribeId());
 
         //更新客户信息
         companyCustomerMapper.updateFsCompanyCustomer(mapCustomer);

+ 12 - 6
fs-service/src/main/java/com/fs/his/service/impl/PrescriptionTaskRecordServiceImpl.java

@@ -3,10 +3,7 @@ package com.fs.his.service.impl;
 import com.fs.common.exception.CustomException;
 import com.fs.common.utils.DateUtils;
 import com.fs.his.domain.*;
-import com.fs.his.mapper.FsPrescribeDataScrmMapper;
-import com.fs.his.mapper.FsPrescribeDrugDataScrmMapper;
-import com.fs.his.mapper.PrescribeScrmTaskRecordMapper;
-import com.fs.his.mapper.PrescriptionTaskRecordMapper;
+import com.fs.his.mapper.*;
 import com.fs.his.param.PrescribeXyImgParam;
 import com.fs.his.service.IFsPrescribeService;
 import com.fs.his.service.PrescriptionImageService;
@@ -53,6 +50,9 @@ public class PrescriptionTaskRecordServiceImpl implements PrescriptionTaskRecord
     @Autowired
     private FsStoreProductScrmMapper fsStoreProductScrmMapper;
 
+    @Autowired
+    private FsDoctorMapper fsDoctorMapper;
+
     /**
      * 生成处方签名
      */
@@ -179,7 +179,10 @@ public class PrescriptionTaskRecordServiceImpl implements PrescriptionTaskRecord
         }
 
         List<FsPrescribeDrugDataScrm> effectiveDrugs = filterNonDrugScrmPrescribe(drugList);
-
+        //补充医生证号和执业证号到图片VO,后续生成图片会用到
+        FsDoctor fsDoctor = fsDoctorMapper.selectFsDoctorByDoctorId(imgVO.getDoctorId());
+        imgVO.setDoctorCertificate(fsDoctor.getCertificateCode());
+        imgVO.setPractiseCode(fsDoctor.getPractiseCode());
         // 2. 按药品类型分组
         Map<Integer, List<FsPrescribeDrugDataScrm>> drugTypeMap = effectiveDrugs.stream()
                 .collect(Collectors.groupingBy(FsPrescribeDrugDataScrm::getDrugType));
@@ -263,7 +266,10 @@ public class PrescriptionTaskRecordServiceImpl implements PrescriptionTaskRecord
 
         imgParam.setDoctorName(imgVO.getDoctorName());
         imgParam.setAuditDoctor(imgVO.getDrugDoctorName());
-        imgParam.setTelPhone(imgVO.getPatientTel());
+        if (imgVO.getPatientTel() != null) {
+            // 隐藏手机号中间四位
+            imgParam.setTelPhone(imgVO.getPatientTel().replaceAll("(\\d{3})\\d*(\\d{4})", "$1****$2"));
+        }
         imgParam.setJobLicenseNumber(imgVO.getPractiseCode());
         imgParam.setDoctorNo(imgVO.getDoctorCertificate());
         imgParam.setDoctorTitle(imgVO.getDoctorPosition());

+ 14 - 0
fs-service/src/main/java/com/fs/his/vo/CustomerQuestionAnswerVO.java

@@ -0,0 +1,14 @@
+package com.fs.his.vo;
+
+import lombok.Data;
+
+/**
+ * 客户信息表-问答信息展示VO
+ */
+@Data
+public class CustomerQuestionAnswerVO {
+    /** 问题标题 */
+    private String title;
+    /** 用户选择的答案文本(多个用逗号分隔) */
+    private String answerText;
+}

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

@@ -12,7 +12,7 @@ public class FsPrescribeDataScrmImgVO extends FsPrescribeDataScrm {
     /** 医生签名 */
     private String doctorSign;
 
-    /** 医生执业号 */
+    /** 医生执业号 */
     private String practiseCode;
 
     /** 医生职称 */

+ 11 - 0
fs-service/src/main/java/com/fs/his/vo/PrescribeScrmDoctorAdviceVO.java

@@ -0,0 +1,11 @@
+package com.fs.his.vo;
+import lombok.Data;
+
+@Data
+public class PrescribeScrmDoctorAdviceVO {
+    private String diagnose;
+    private String facialDiagnosis;
+    private String foodAndExerciseGuidance;
+    private String healingAreaJson;  // 前端存储的 JSON 字符串
+    private String noteTaboos;
+}

+ 5 - 0
fs-service/src/main/java/com/fs/qw/mapper/FsCompanyCustomerMapper.java

@@ -81,4 +81,9 @@ public interface FsCompanyCustomerMapper {
      * 根据关联处方id更新客户信息表的处方进度状态
      * */
     int updateProcessStatusByPrescribeId(@Param("prescribeId") Long prescribeId,@Param("processStatus") Integer processStatus);
+
+    /**
+     * 根据关联处方id查询客户信息
+     * */
+    FsCompanyCustomer selectFsCompanyCustomerByPrescribeId(Long prescribeId);
 }

+ 4 - 1
fs-service/src/main/java/com/fs/qw/service/IFsCompanyCustomerService.java

@@ -1,10 +1,10 @@
 package com.fs.qw.service;
 
 import com.fs.company.domain.CompanyUser;
+import com.fs.his.vo.CustomerQuestionAnswerVO;
 import com.fs.hisStore.param.FsCompanyCustomerOrderParam;
 import com.fs.hisStore.vo.FsStoreOrderVO;
 import com.fs.qw.domain.FsCompanyCustomer;
-import com.fs.qw.domain.FsCompanyExternalPayReceipt;
 import com.fs.qw.param.TransferCustomerParam;
 
 import java.util.List;
@@ -44,4 +44,7 @@ public interface IFsCompanyCustomerService {
     int addBuyTimes(Long id);
 
     int improve(FsCompanyCustomer fsCompanyCustomer);
+
+    //查询客户问答信息(根据客户信息表主键ID)
+    List<CustomerQuestionAnswerVO> getCustomerQuestionAnswer(Long companyCustomerId);
 }

+ 65 - 5
fs-service/src/main/java/com/fs/qw/service/impl/FsCompanyCustomerServiceImpl.java

@@ -2,6 +2,8 @@ package com.fs.qw.service.impl;
 
 import cn.hutool.json.JSONArray;
 import cn.hutool.json.JSONUtil;
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.TypeReference;
 import com.fs.common.exception.CustomException;
 import com.fs.common.utils.DateUtils;
 import com.fs.common.utils.StringUtils;
@@ -9,8 +11,11 @@ import com.fs.company.domain.CompanyDept;
 import com.fs.company.domain.CompanyUser;
 import com.fs.company.mapper.CompanyDeptMapper;
 import com.fs.his.domain.FsImportMember;
+import com.fs.his.domain.FsPrescribeDataScrm;
 import com.fs.his.mapper.FsImportMemberMapper;
+import com.fs.his.mapper.FsPrescribeDataScrmMapper;
 import com.fs.his.service.IFsUserAddressService;
+import com.fs.his.vo.CustomerQuestionAnswerVO;
 import com.fs.hisStore.mapper.FsStoreOrderScrmMapper;
 import com.fs.hisStore.param.FsCompanyCustomerOrderParam;
 import com.fs.hisStore.vo.FsStoreOrderItemVO;
@@ -29,9 +34,8 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import java.math.BigDecimal;
-import java.util.Collections;
-import java.util.Date;
-import java.util.List;
+import java.util.*;
+import java.util.stream.Collectors;
 
 /**
  * 客户基础信息Service业务层处理
@@ -60,9 +64,15 @@ public class FsCompanyCustomerServiceImpl implements IFsCompanyCustomerService {
     @Autowired
     private FsCompanyExternalPayReceiptMapper externalPayReceiptMapper;
 
+    @Autowired
+    private FsPrescribeDataScrmMapper prescribeDataScrmMapper;
+
     @Autowired
     private IFsUserAddressService fsUserAddressService;
 
+    private static final Set<Integer> ALLOWED_STATUSES =
+            Collections.unmodifiableSet(new HashSet<>(Arrays.asList(0, 5, 6))); // 允许操作完善客户信息的状态
+
     @Override
     public FsCompanyCustomer selectFsCompanyCustomerById(Long id) {
         return fsCompanyCustomerMapper.selectFsCompanyCustomerById(id);
@@ -70,7 +80,19 @@ public class FsCompanyCustomerServiceImpl implements IFsCompanyCustomerService {
 
     @Override
     public List<FsCompanyCustomer> selectFsCompanyCustomerList(FsCompanyCustomer fsCompanyCustomer) {
-        return fsCompanyCustomerMapper.selectFsCompanyCustomerList(fsCompanyCustomer);
+        List<FsCompanyCustomer> companyCustomers = fsCompanyCustomerMapper.selectFsCompanyCustomerList(fsCompanyCustomer);
+        if (CollectionUtils.isEmpty(companyCustomers)) {
+            return companyCustomers;
+        }
+        //收集处方id
+        List<Long> prescriptionIds = companyCustomers.stream().map(FsCompanyCustomer::getPrescribeId).filter(Objects::nonNull).collect(Collectors.toList());
+        if (CollectionUtils.isEmpty(prescriptionIds)) {
+            return companyCustomers;
+        }
+        //批量获取处方信息
+        List<FsPrescribeDataScrm> fsPrescribeDataScrms = prescribeDataScrmMapper.selectFsPrescribeDataScrmListByIds(prescriptionIds);
+        //TODO 后续可能会在客户信息列表展示商城处方信息
+        return companyCustomers;
     }
 
     @Override
@@ -270,7 +292,7 @@ public class FsCompanyCustomerServiceImpl implements IFsCompanyCustomerService {
         if (customer == null) {
             throw new CustomException("客户信息不存在");
         }
-        if (customer.getProcessStatus()  != 0) {
+        if (!ALLOWED_STATUSES.contains(customer.getProcessStatus())) {
             throw new CustomException("客户正在处理中,请勿重复操作");
         }
         customer.setProcessStatus(1);
@@ -278,4 +300,42 @@ public class FsCompanyCustomerServiceImpl implements IFsCompanyCustomerService {
         customer.setJsonInfo(fsCompanyCustomer.getJsonInfo());
         return fsCompanyCustomerMapper.updateFsCompanyCustomer(customer);
     }
+
+    @Override
+    public List<CustomerQuestionAnswerVO> getCustomerQuestionAnswer(Long companyCustomerId) {
+        FsCompanyCustomer fsCompanyCustomer = fsCompanyCustomerMapper.selectFsCompanyCustomerById(companyCustomerId);
+        if (fsCompanyCustomer == null) {
+            return Collections.emptyList();
+        }
+        String jsonStr = fsCompanyCustomer.getJsonInfo();
+        if (StringUtils.isBlank(jsonStr)) {
+            return Collections.emptyList();
+        }
+        // 使用 TypeReference 安全解析
+        List<Map<String, Object>> list = JSON.parseObject(jsonStr, new TypeReference<List<Map<String, Object>>>() {});
+        List<CustomerQuestionAnswerVO> result = new ArrayList<>();
+        for (Map<String, Object> item : list) {
+            String title = (String) item.get("title");
+            List<Integer> values = (List<Integer>) item.get("value");
+            List<Map<String, Object>> options = (List<Map<String, Object>>) item.get("options");
+
+            List<String> answerNames = new ArrayList<>();
+            if (values != null && options != null) {
+                for (Integer val : values) {
+                    for (Map<String, Object> opt : options) {
+                        if (opt.get("value").equals(val)) {
+                            answerNames.add((String) opt.get("name"));
+                            break;
+                        }
+                    }
+                }
+            }
+            String answerText = String.join("、", answerNames);
+            CustomerQuestionAnswerVO vo = new CustomerQuestionAnswerVO();
+            vo.setTitle(title);
+            vo.setAnswerText(answerText);
+            result.add(vo);
+        }
+        return result;
+    }
 }

+ 3 - 0
fs-service/src/main/java/com/fs/qw/vo/FsPrescribeDataScrmVO.java

@@ -188,4 +188,7 @@ public class FsPrescribeDataScrmVO implements Serializable {
     private Integer isDocument;
 
     private List<FsPrescribeDrugDataScrm> drugsList;
+
+    /** 医生名称 */
+    private String doctorName;
 }

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

@@ -151,8 +151,9 @@
     </select>
 
     <select id="pendingStorePrescribeList" resultType="com.fs.qw.vo.FsPrescribeDataScrmVO">
-        select pds.* from fs_prescribe_data_scrm pds
+        select pds.*,fd.doctor_name as doctorName from fs_prescribe_data_scrm pds
         left join fs_company_customer fcc on pds.prescribe_id = fcc.prescribe_id
+        left join fs_doctor fd on pds.doctor_id = fd.doctor_id
         <where>
             <if test="status != 2">
             pds.drug_doctor_id = #{drugDoctorId} and pds.doctor_confirm = 1

+ 5 - 0
fs-service/src/main/resources/mapper/qw/FsCompanyCustomerMapper.xml

@@ -201,6 +201,11 @@
         SELECT * FROM fs_company_customer WHERE id = #{id} FOR UPDATE
     </select>
 
+    <select id="selectFsCompanyCustomerByPrescribeId" resultType="com.fs.qw.domain.FsCompanyCustomer">
+        <include refid="selectFsCompanyCustomerVo"/>
+        where del_flag = '0' and prescribe_id = #{prescribeId}
+    </select>
+
     <insert id="insertFsCompanyCustomer" parameterType="com.fs.qw.domain.FsCompanyCustomer" useGeneratedKeys="true" keyProperty="id">
         insert into fs_company_customer
         <trim prefix="(" suffix=")" suffixOverrides=",">