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

总后台新增医生处方统计

cgp 5 дней назад
Родитель
Сommit
7eb720eea6

+ 74 - 10
fs-admin/src/main/java/com/fs/his/controller/FsPrescribeDataScrmController.java

@@ -4,19 +4,24 @@ package com.fs.his.controller;
 import com.fs.common.core.controller.BaseController;
 import com.fs.common.core.domain.AjaxResult;
 import com.fs.common.core.page.TableDataInfo;
+import com.fs.common.utils.poi.ExcelUtil;
 import com.fs.his.domain.FsPrescribeDataScrm;
 import com.fs.his.dto.DoctorNotPrescribeQueryDto;
 import com.fs.his.service.IFsPrescribeDataScrmService;
-import com.fs.his.vo.CustomerInfoVO;
-import com.fs.his.vo.DoctorSignVO;
-import com.fs.his.vo.PrescribeScrmDoctorAdviceVO;
+import com.fs.his.vo.*;
 import com.fs.hisStore.domain.FsStoreOrderScrm;
 import com.fs.hisStore.service.IFsStoreOrderScrmService;
 import com.fs.qw.service.IFsCompanyCustomerService;
+import com.github.pagehelper.PageHelper;
+import org.apache.commons.collections4.CollectionUtils;
+import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
+import javax.validation.Valid;
+import java.util.Collections;
 import java.util.List;
+import java.util.stream.Collectors;
 
 /**
  * 商城处方表(SCRM)Controller
@@ -104,16 +109,75 @@ public class FsPrescribeDataScrmController extends BaseController
      * 获取医生不开方列表信息
      * */
     @PostMapping("/doctorNotPrescribeList")
-    public TableDataInfo doctorNotPrescribeList(@RequestBody DoctorNotPrescribeQueryDto queryDto)
+    public TableDataInfo doctorNotPrescribeList(@Valid @RequestBody DoctorNotPrescribeQueryDto queryDto)
     {
-        startPage();
-        List<FsPrescribeDataScrm> list = fsPrescribeScrmService.doctorNotPrescribeList(queryDto);
-        for (FsPrescribeDataScrm vo : list){
-            if (vo.getPatientTel()!=null){
-                vo.setPatientTel(vo.getPatientTel().replaceAll("(\\d{3})\\d*(\\d{4})", "$1****$2"));
+        Integer pageNum = queryDto.getPageNum() == null ? 1 : queryDto.getPageNum();
+        Integer pageSize = queryDto.getPageSize() == null ? 10 : queryDto.getPageSize();
+        PageHelper.startPage(pageNum, pageSize);
+        List<DoctorScrmPrescribeVO> list = fsPrescribeScrmService.doctorNotPrescribeList(queryDto);
+        return getDataTable(list);
+    }
+
+    @GetMapping("/doctorNotPrescribeList/export")
+    public AjaxResult export(@ModelAttribute DoctorNotPrescribeQueryDto queryDto) {
+        List<DoctorScrmPrescribeVO> list = fsPrescribeScrmService.doctorNotPrescribeList(queryDto);
+        // 转换为导出 VO(需处理状态文本)
+        List<DoctorScrmExportVO> exportList = convertToExportVO(list);
+        ExcelUtil<DoctorScrmExportVO> util = new ExcelUtil<>(DoctorScrmExportVO.class);
+        return util.exportExcel(exportList, "开方列表统计");
+    }
+
+    /**
+     * 将查询结果 VO 转换为导出专用 VO
+     */
+    private List<DoctorScrmExportVO> convertToExportVO(List<DoctorScrmPrescribeVO> list) {
+        if (CollectionUtils.isEmpty(list)) {
+            return Collections.emptyList();
+        }
+        return list.stream().map(vo -> {
+            DoctorScrmExportVO dto = new DoctorScrmExportVO();
+            // 复制同名属性
+            BeanUtils.copyProperties(vo, dto);
+
+            // 处理处方状态文本
+            String doctorConfirmText = convertDoctorConfirm(vo.getDoctorConfirm(), vo.getStatus());
+            dto.setDoctorConfirmText(doctorConfirmText);
+
+            // 处理制单状态文本
+            String isDocumentText = convertIsDocument(vo.getIsDocument());
+            dto.setIsDocumentText(isDocumentText);
+
+            return dto;
+        }).collect(Collectors.toList());
+    }
+
+    /**
+     * 转换处方状态为显示文本
+     */
+    private String convertDoctorConfirm(Integer doctorConfirm, Integer status) {
+        if (doctorConfirm != null) {
+            if (doctorConfirm == 0) return "待开方";
+            if (doctorConfirm == -2) return "暂不开方";
+            if (status != null) {
+                if (status == 0) return "待审核";
+                if (status == 1) return "已完成";
+                if (status == 2) return "已拒方";
             }
         }
-        return getDataTable(list);
+        return "-";
     }
 
+    /**
+     * 转换制单状态为显示文本
+     */
+    private String convertIsDocument(Integer isDocument) {
+        if (isDocument != null) {
+            if (isDocument == 0) return "未制单";
+            if (isDocument == 1) return "已制单";
+        }
+        return "-";
+    }
+
+
+
 }

+ 11 - 0
fs-service/src/main/java/com/fs/his/dto/DoctorNotPrescribeQueryDto.java

@@ -13,9 +13,15 @@ public class DoctorNotPrescribeQueryDto {
     /** 患者名称 */
     private String patientName;
 
+    /** 销售名称 */
+    private String companyUserName;
+
     /** 医生id */
     private Long doctorId;
 
+    /** 动态查询条件 0:暂不开方;1:待开方,2:开方未成交,3:开方已成交*/
+    private Integer dynamicConditions;
+
     /** 开始时间 */
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
     @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@@ -25,4 +31,9 @@ public class DoctorNotPrescribeQueryDto {
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
     @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     private String endTime;
+
+    // 分页相关
+    private Integer pageNum;
+
+    private Integer pageSize;
 }

+ 11 - 0
fs-service/src/main/java/com/fs/his/mapper/FsPrescribeDataScrmMapper.java

@@ -1,8 +1,10 @@
 package com.fs.his.mapper;
 
 import com.fs.his.domain.FsPrescribeDataScrm;
+import com.fs.his.dto.DoctorNotPrescribeQueryDto;
 import com.fs.his.dto.FsPrescribeDataDoctorQueryDto;
 import com.fs.his.dto.FsPrescribeDataDrugDoctorQueryDto;
+import com.fs.his.vo.DoctorScrmPrescribeVO;
 import com.fs.his.vo.FsPrescribeDataScrmImgVO;
 import com.fs.qw.vo.FsPrescribeDataScrmVO;
 import org.apache.ibatis.annotations.Param;
@@ -33,6 +35,15 @@ public interface FsPrescribeDataScrmMapper
      */
     public List<FsPrescribeDataScrm> selectFsPrescribeDataScrmList(FsPrescribeDataScrm fsPrescribeDataScrm);
 
+    /**
+     * 查询商城处方表及其关联订单列表数据
+     *
+     * @param queryDto 处方表(SCRM)
+     * @return 处方表(SCRM)集合
+     */
+    public List<DoctorScrmPrescribeVO> selectFsPrescribeDataScrmAndOrderList(DoctorNotPrescribeQueryDto queryDto);
+
+
     /**
      * 新增处方表(SCRM)
      *

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

@@ -2,6 +2,7 @@ package com.fs.his.service;
 
 import com.fs.his.domain.FsPrescribeDataScrm;
 import com.fs.his.dto.*;
+import com.fs.his.vo.DoctorScrmPrescribeVO;
 import com.fs.his.vo.DoctorSignVO;
 import com.fs.qw.vo.FsPrescribeDataScrmVO;
 
@@ -128,5 +129,5 @@ public interface IFsPrescribeDataScrmService
     /**
      * 医生不开方列表
      * */
-    List<FsPrescribeDataScrm> doctorNotPrescribeList(DoctorNotPrescribeQueryDto queryDto);
+    List<DoctorScrmPrescribeVO> doctorNotPrescribeList(DoctorNotPrescribeQueryDto queryDto);
 }

+ 50 - 12
fs-service/src/main/java/com/fs/his/service/impl/FsPrescribeDataScrmServiceImpl.java

@@ -1,6 +1,7 @@
 package com.fs.his.service.impl;
 
 import cn.hutool.core.util.IdUtil;
+import com.alibaba.excel.EasyExcel;
 import com.fs.common.BeanCopyUtils;
 import com.fs.common.exception.CustomException;
 import com.fs.common.utils.DateUtils;
@@ -11,6 +12,8 @@ import com.fs.his.mapper.*;
 import com.fs.his.service.IFsPrescribeDataScrmService;
 import com.fs.his.service.IPollingAssignDoctorService;
 import com.fs.his.service.PrescriptionTaskRecordService;
+import com.fs.his.vo.DoctorScrmExportVO;
+import com.fs.his.vo.DoctorScrmPrescribeVO;
 import com.fs.his.vo.DoctorSignVO;
 import com.fs.qw.domain.FsCompanyCustomer;
 import com.fs.qw.mapper.FsCompanyCustomerMapper;
@@ -19,11 +22,14 @@ import com.fs.qw.vo.FsPrescribeDataScrmVO;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.collections4.CollectionUtils;
 import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.ApplicationContext;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
 import java.util.*;
 import java.util.stream.Collectors;
 
@@ -356,20 +362,52 @@ public class FsPrescribeDataScrmServiceImpl implements IFsPrescribeDataScrmServi
     }
 
     @Override
-    public List<FsPrescribeDataScrm> doctorNotPrescribeList(DoctorNotPrescribeQueryDto queryDto) {
-        FsPrescribeDataScrm fsPrescribeDataScrm = new FsPrescribeDataScrm();
-        BeanCopyUtils.copy(queryDto, fsPrescribeDataScrm);
-        fsPrescribeDataScrm.setDoctorConfirm(-2);//医生不开方
-        List<FsPrescribeDataScrm> fsPrescribeDataScrms = fsPrescribeDataScrmMapper.selectFsPrescribeDataScrmList(fsPrescribeDataScrm);
-        if (CollectionUtils.isEmpty(fsPrescribeDataScrms)){
+    public List<DoctorScrmPrescribeVO> doctorNotPrescribeList(DoctorNotPrescribeQueryDto queryDto) {
+        List<DoctorScrmPrescribeVO> prescribeList = fsPrescribeDataScrmMapper.selectFsPrescribeDataScrmAndOrderList(queryDto);
+        if (CollectionUtils.isEmpty(prescribeList)) {
             return Collections.emptyList();
         }
-        //收集医生id
-        Set<Long> doctorIds = fsPrescribeDataScrms.stream().map(FsPrescribeDataScrm::getDoctorId).collect(Collectors.toSet());
-        List<FsDoctor> doctorList = fsDoctorMapper.selectDoctorByIds(new ArrayList<>(doctorIds));
-        Map<Long, String> doctorMap = doctorList.stream().collect(Collectors.toMap(FsDoctor::getDoctorId, FsDoctor::getDoctorName));
-        fsPrescribeDataScrms.forEach(item -> item.setDoctorName(doctorMap.get(item.getDoctorId())));
-        return fsPrescribeDataScrms;
+        populateDoctorNames(prescribeList);
+        maskPatientPhone(prescribeList);
+
+        return prescribeList;
+    }
+
+    /**
+     * 根据处方列表中的医生ID批量填充医生姓名
+     */
+    private void populateDoctorNames(List<DoctorScrmPrescribeVO> prescribeList) {
+        Set<Long> doctorIds = prescribeList.stream()
+                .map(DoctorScrmPrescribeVO::getDoctorId)
+                .filter(Objects::nonNull)
+                .collect(Collectors.toSet());
+        if (doctorIds.isEmpty()) {
+            return;
+        }
+
+        List<FsDoctor> doctors = fsDoctorMapper.selectDoctorByIds(new ArrayList<>(doctorIds));
+        Map<Long, String> doctorNameMap = doctors.stream()
+                .collect(Collectors.toMap(
+                        FsDoctor::getDoctorId,
+                        FsDoctor::getDoctorName,
+                        (existing, replacement) -> existing
+                ));
+
+        prescribeList.forEach(item -> {
+            String name = doctorNameMap.get(item.getDoctorId());
+            item.setDoctorName(name);
+        });
+    }
+
+    /**
+     * 对患者电话进行脱敏处理(保留前3位和后4位,中间替换为****)
+     */
+    private void maskPatientPhone(List<DoctorScrmPrescribeVO> prescribeList) {
+        prescribeList.stream()
+                .filter(vo -> vo.getPatientTel() != null)
+                .forEach(vo -> vo.setPatientTel(
+                        vo.getPatientTel().replaceAll("(\\d{3})\\d*(\\d{4})", "$1****$2")
+                ));
     }
 
     /**

+ 39 - 0
fs-service/src/main/java/com/fs/his/vo/DoctorScrmExportVO.java

@@ -0,0 +1,39 @@
+package com.fs.his.vo;
+
+import com.fs.common.annotation.Excel;
+import lombok.Data;
+
+import java.util.Date;
+
+@Data
+public class DoctorScrmExportVO {
+    @Excel(name = "处方编号")
+    private String prescribeCode;
+
+    @Excel(name = "医生姓名")
+    private String doctorName;
+
+    @Excel(name = "销售姓名")
+    private String companyUserName;
+
+    @Excel(name = "患者姓名")
+    private String patientName;
+
+    @Excel(name = "患者年龄")
+    private String patientAge;
+
+    @Excel(name = "患者电话")
+    private String patientTel;
+
+    @Excel(name = "订单编号")
+    private String orderCode;
+
+    @Excel(name = "处方状态")
+    private String doctorConfirmText;
+
+    @Excel(name = "销售制单状态")
+    private String isDocumentText;
+
+    @Excel(name = "创建时间", dateFormat = "yyyy-MM-dd HH:mm:ss")
+    private Date createTime;
+}

+ 46 - 0
fs-service/src/main/java/com/fs/his/vo/DoctorScrmPrescribeVO.java

@@ -0,0 +1,46 @@
+package com.fs.his.vo;
+
+import com.alibaba.excel.annotation.ExcelProperty;
+import com.alibaba.excel.annotation.format.DateTimeFormat;
+import com.fs.his.domain.FsPrescribeDataScrm;
+import lombok.Data;
+
+import java.util.Date;
+
+@Data
+public class DoctorScrmPrescribeVO extends FsPrescribeDataScrm {
+    // 销售人员名称
+    @ExcelProperty(value = "销售姓名", index = 2)
+    private String companyUserName;
+
+    // 导出用字段 - 处方状态文本
+    @ExcelProperty(value = "处方状态", index = 7)
+    private String doctorConfirmText;
+
+    // 导出用字段 - 销售制单状态文本
+    @ExcelProperty(value = "销售制单状态", index = 8)
+    private String isDocumentText;
+
+    // 覆盖父类字段,标注 Excel 列顺序
+    @ExcelProperty(value = "处方编号", index = 0)
+    private String prescribeCode;
+
+    @ExcelProperty(value = "医生姓名", index = 1)
+    private String doctorName;
+
+    @ExcelProperty(value = "患者姓名", index = 3)
+    private String patientName;
+
+    @ExcelProperty(value = "患者年龄", index = 4)
+    private String patientAge;
+
+    @ExcelProperty(value = "患者电话", index = 5)
+    private String patientTel;
+
+    @ExcelProperty(value = "订单编号", index = 6)
+    private String orderCode;
+
+    @ExcelProperty(value = "创建时间", index = 9)
+    @DateTimeFormat("yyyy-MM-dd HH:mm:ss")
+    private Date createTime;
+}

+ 0 - 1
fs-service/src/main/java/com/fs/sop/service/impl/SopUserLogsInfoServiceImpl.java

@@ -1136,7 +1136,6 @@ public class SopUserLogsInfoServiceImpl implements ISopUserLogsInfoService {
                             break;
                         //飞书看课
                         case "18":
-
                             addWatchLogIfNeeded(param.getSopId(), param.getVideoId(), param.getCourseId(),
                                     item.getFsUserId(), qwUserId, companyUserId, companyId,
                                     item.getExternalId(), param.getStartTime(), createTime);

+ 41 - 0
fs-service/src/main/resources/mapper/his/FsPrescribeDataScrmMapper.xml

@@ -138,6 +138,47 @@
         order by create_time desc
     </select>
 
+    <select id="selectFsPrescribeDataScrmAndOrderList" parameterType="com.fs.his.dto.DoctorNotPrescribeQueryDto" resultType="com.fs.his.vo.DoctorScrmPrescribeVO">
+        select fpds.prescribe_id, fpds.prescribe_type, orderScrm.order_code,fpds.prescribe_code,
+        fpds.patient_age, fpds.patient_name, fpds.is_history_allergic, fpds.patient_tel,
+        fpds.patient_gender, fpds.prescribe_img_url,fpds.prescribe_img_store_url,fpds.audit_reason,
+        fpds.diagnose, fpds.doctor_id, fpds.drug_doctor_id, fpds.create_time, fpds.status,fpds.audit_time,
+        fpds.remark, fpds.prescribe_doctor_id, fpds.doctor_sign_url,fpds.recipe_type, fpds.source,
+        fpds.doctor_confirm, fpds.company_customer_id,fpds.food_and_exercise_guidance, fpds.healing_area_json,
+        fpds.note_taboos,fpds.facial_diagnosis,fpds.is_document,fpds.diagnose_chinese,fpds.remark_chinese,
+        fpds.not_prescribe_reason,cu.nick_name as companyUserName
+        from fs_prescribe_data_scrm fpds left join fs_store_order_scrm orderScrm on fpds.prescribe_id = orderScrm.prescribe_id
+        left join  company_user cu on orderScrm.company_user_id = cu.user_id
+        <where>
+            <if test="doctorId != null"> and fpds.doctor_id = #{doctorId}</if>
+            <if test="companyUserName != null"> and cu.nick_name like concat('%', #{companyUserName}, '%')</if>
+            <if test="dynamicConditions != null">
+                <choose>
+                    <when test="dynamicConditions == 0">
+                        and fpds.doctor_confirm = -2
+                    </when>
+                    <when test="dynamicConditions == 1">
+                        and fpds.doctor_confirm = 0
+                    </when>
+                    <when test="dynamicConditions == 2">
+                        and orderScrm.status != 3
+                    </when>
+                    <when test="dynamicConditions == 3">
+                        and orderScrm.status = 3
+                    </when>
+                </choose>
+            </if>
+            <!-- 按时间范围查询 -->
+            <if test="beginTime != null and beginTime != ''">
+                and fpds.create_time >= #{beginTime}
+            </if>
+            <if test="endTime != null and endTime != ''">
+                and fpds.create_time &lt;= #{endTime}
+            </if>
+        </where>
+        order by fpds.create_time desc
+    </select>
+
     <select id="waitOpenPrescribeList" resultType="com.fs.qw.vo.FsPrescribeDataScrmVO">
         select pds.* from fs_prescribe_data_scrm pds
         left join fs_company_customer fcc on pds.prescribe_id = fcc.prescribe_id