Browse Source

1、调整处方审核问题
2、调整训练营出现数据没有问题

yys 1 month ago
parent
commit
7d4ebb650c

+ 1 - 0
fs-admin/src/main/java/com/fs/course/controller/FsCourseRedPacketLogController.java

@@ -199,6 +199,7 @@ public class FsCourseRedPacketLogController extends BaseController
     @GetMapping(value = "/videoList/{id}")
     public R videoList(@PathVariable("id") Long id)
     {
+        PageHelper.clearPage();  // 关键:确保这次查询不受分页影响
         List<OptionsVO> optionsVOS = fsUserCourseVideoMapper.selectFsUserCourseVodeAllList(id);
         return R.ok().put("list", optionsVOS);
     }

+ 25 - 2
fs-doctor-app/src/main/java/com/fs/app/controller/PrescribeController.java

@@ -91,14 +91,37 @@ public class PrescribeController extends  AppBaseController {
     @GetMapping("/getPrescribeList")
     public R getPrescribeList(FsPrescribeListDParam param)
     {
+        Long doctorId = Long.parseLong(getDoctorId());
+        param.setDoctorId(doctorId);
+        param.setDoctorDrugId(doctorId);
+        normalizePrescribeListParam(param, doctorService.selectFsDoctorByDoctorId(doctorId));
+        PageHelper.clearPage();
         PageHelper.startPage(param.getPageNum(), param.getPageSize());
-        param.setDoctorId(Long.parseLong(getDoctorId()));
-        param.setDoctorDrugId(Long.parseLong(getDoctorId()));
         List<FsPrescribeListDVO> list=prescribeService.selectFsPrescribeListDVO(param);
         PageInfo<FsPrescribeListDVO> listPageInfo=new PageInfo<>(list);
         return R.ok().put("data",listPageInfo);
     }
 
+    /**
+     * 统一列表查询参数:前端 auditStatus 与 status 均表示 tab(1待审核 2已审核)
+     */
+    private void normalizePrescribeListParam(FsPrescribeListDParam param, FsDoctor doctor) {
+        if (param.getStatus() == null && param.getAuditStatus() != null) {
+            param.setStatus(param.getAuditStatus());
+        }
+        if (Integer.valueOf(0).equals(param.getStatus())) {
+            param.setStatus(1);
+        }
+        if (doctor != null && Integer.valueOf(2).equals(doctor.getDoctorType())) {
+            param.setType(2);
+        } else if (doctor != null && doctor.getDoctorType() != null && param.getType() == null) {
+            param.setType(doctor.getDoctorType());
+        }
+        if (Integer.valueOf(2).equals(param.getType()) && param.getStatus() == null) {
+            param.setStatus(1);
+        }
+    }
+
 
     @Login
     @GetMapping("/getPrescribeById")

+ 6 - 0
fs-service/src/main/java/com/fs/his/mapper/FsPrescribeMapper.java

@@ -109,6 +109,12 @@ public interface FsPrescribeMapper
             "<if test = ' maps.type==1  '> " +
             "and p.doctor_id = #{maps.doctorId} " +
             "</if>" +
+            "<if test = ' maps.type==1 and maps.status != null and maps.status == 1  '> " +
+            "and p.status = 0 " +
+            "</if>" +
+            "<if test = ' maps.type==1 and maps.status != null and maps.status == 2  '> " +
+            "and (p.status = 1 || p.status = 2) " +
+            "</if>" +
             "<if test = ' maps.type==2 and maps.status != null and maps.status == 1  '> " +
             "and p.status = 0 " +
             "</if>" +

+ 3 - 0
fs-service/src/main/java/com/fs/his/param/FsPrescribeAuditParam.java

@@ -2,12 +2,15 @@ package com.fs.his.param;
 
 import lombok.Data;
 
+import javax.validation.constraints.NotNull;
 import java.io.Serializable;
 
 @Data
 public class FsPrescribeAuditParam extends BaseParam implements Serializable {
+    @NotNull(message = "处方ID不能为空")
     private Long prescribeId;
     Long doctorId;
+    @NotNull(message = "审核状态不能为空")
     Integer status;//1通过 2不通过
     String auditReason;//拒绝原因
 

+ 4 - 1
fs-service/src/main/java/com/fs/his/param/FsPrescribeListDParam.java

@@ -12,7 +12,10 @@ import java.util.Map;
 public class FsPrescribeListDParam extends BaseParam implements Serializable {
     Long doctorId;
     Long doctorDrugId;
-    Integer status;//1待审核 2历史订单
+    /** 列表tab:1待审核 2已审核,与 status 同义,前端常用 auditStatus 传参 */
+    Integer auditStatus;
+    /** 列表tab:1待审核 2已审核(历史) */
+    Integer status;
     Integer type;//1医生 2药师
     String patientName;
     String prescribeCode;

+ 107 - 29
fs-service/src/main/java/com/fs/his/service/impl/FsPrescribeServiceImpl.java

@@ -163,13 +163,27 @@ public class FsPrescribeServiceImpl implements IFsPrescribeService
     public List<FsPrescribeListDVO> selectFsPrescribeListDVO(FsPrescribeListDParam param) {
         List<FsPrescribeListDVO> list=fsPrescribeMapper.selectFsPrescribeListDVO(param);
         for(FsPrescribeListDVO vo:list){
+            fillPrescribeListAuditDisplay(vo);
             FsPrescribeDrug map=new FsPrescribeDrug();
             map.setPrescribeId(vo.getPrescribeId());
             vo.setDrugs(fsPrescribeDrugMapper.selectFsPrescribeDrugList(map));
         }
         return list;
+    }
 
-
+    private void fillPrescribeListAuditDisplay(FsPrescribeListDVO vo) {
+        Integer prescribeStatus = vo.getStatus() == null ? 0 : vo.getStatus();
+        // DB status: 0待审核/1审核通过/2审核拒绝 → 前端约定: 1待审核/2审核通过/3审核不通过
+        vo.setAuditStatus(prescribeStatus + 1);
+        if (prescribeStatus == 0) {
+            vo.setAuditStatusName("待审核");
+        } else if (prescribeStatus == 1) {
+            vo.setAuditStatusName("审核通过");
+        } else if (prescribeStatus == 2) {
+            vo.setAuditStatusName("审核拒绝");
+        } else {
+            vo.setAuditStatusName("未知");
+        }
     }
 
     @Override
@@ -903,6 +917,9 @@ public class FsPrescribeServiceImpl implements IFsPrescribeService
         List<FsPrescribe> FsPrescribes=fsPrescribeDrugMapper.selectFsPrescribeNoAudit();
         for (FsPrescribe fsPrescribe : FsPrescribes) {
             Long id = doctorMapper.selectFsDoctorType2Ids(fsPrescribe.getPrescribeType());
+            if (id == null) {
+                continue;
+            }
             FsPrescribeAuditParam param=new FsPrescribeAuditParam();
             param.setDoctorId(id);
             param.setStatus(1);
@@ -914,9 +931,52 @@ public class FsPrescribeServiceImpl implements IFsPrescribeService
     @Override
     @Transactional
     public R audit(FsPrescribeAuditParam param){
+        if (param.getPrescribeId() == null) {
+            return R.error("处方ID不能为空");
+        }
+        if (param.getStatus() == null) {
+            return R.error("审核状态不能为空");
+        }
+        if (!Integer.valueOf(1).equals(param.getStatus()) && !Integer.valueOf(2).equals(param.getStatus())) {
+            return R.error("审核状态不正确");
+        }
         FsPrescribe prescribe=this.selectFsPrescribeByPrescribeId(param.getPrescribeId());
-        if(prescribe.getStatus()!=0){
-            return R.error("非法操作");
+        if (prescribe == null) {
+            return R.error("处方不存在");
+        }
+        Integer prescribeStatus = prescribe.getStatus() == null ? 0 : prescribe.getStatus();
+        if (Integer.valueOf(1).equals(param.getStatus())) {
+            if (prescribeStatus == 1) {
+                if (prescribe.getStoreOrderId() != null) {
+                    return R.error("该处方已审核通过");
+                }
+                R createResult = storeOrderService.createOrder(prescribe.getPrescribeId());
+                if (!isSuccess(createResult)) {
+                    return R.error(getResultMsg(createResult, "创建订单失败"));
+                }
+                sendPrescribeAuditMsg(this.selectFsPrescribeByPrescribeId(param.getPrescribeId()));
+                return R.ok("处方已审核,订单已补建");
+            }
+            if (prescribeStatus == 2) {
+                return R.error("该处方已审核拒绝,无法通过");
+            }
+            if (prescribeStatus != 0) {
+                return R.error("当前处方状态不允许审核");
+            }
+        } else {
+            if (prescribeStatus == 1) {
+                return R.error("该处方已审核通过,无法拒绝");
+            }
+            if (prescribeStatus == 2) {
+                return R.error("该处方已审核拒绝");
+            }
+            if (prescribeStatus != 0) {
+                return R.error("当前处方状态不允许审核");
+            }
+        }
+        FsDoctor doctor=doctorService.selectFsDoctorByDoctorId(param.getDoctorId());
+        if (doctor == null) {
+            return R.error("审核医生不存在");
         }
         FsPrescribe map=new FsPrescribe();
         map.setPrescribeId(param.getPrescribeId());
@@ -924,39 +984,57 @@ public class FsPrescribeServiceImpl implements IFsPrescribeService
         map.setStatus(param.getStatus());
         map.setAuditReason(param.getAuditReason());
         map.setAuditTime(new Date());
-        FsDoctor doctor=doctorService.selectFsDoctorByDoctorId(map.getDrugDoctorId());
         if(StringUtils.isNotEmpty(doctor.getSignUrl())){
             map.setDrugDoctorSignUrl(doctor.getSignUrl());
         }
-        if(param.getStatus().equals(1)){
-            this.updateFsPrescribe(map);
-            //写入订单
-            storeOrderService.createOrder(prescribe.getPrescribeId());
-            //发送信息
-            String orderId=prescribe.getInquiryOrderId().toString();
-            MsgDTO msgDTO=new MsgDTO();
-            MsgCustomDTO customDTO=new MsgCustomDTO();
-            FsInquiryOrder fsInquiryOrder = fsInquiryOrderMapper.selectFsInquiryOrderByOrderId(prescribe.getInquiryOrderId());
-            customDTO.setType("inquiry");
-            customDTO.setOrderId(orderId);
-            customDTO.setImType(1);
-            customDTO.setOrderType(fsInquiryOrder.getOrderType());
-            msgDTO.setCloudCustomData(JSONUtil.toJsonStr(customDTO));
-            msgDTO.setFrom_Account("D-"+prescribe.getDoctorId());
-            msgDTO.setTo_Account("U-"+prescribe.getUserId());
-            List<MsgDataDTO> msgs=new ArrayList<>();
-            MsgDataDTO msg=new MsgDataDTO();
-            String ext= JSONUtil.toJsonStr(prescribe);
-
-            msg.setMsgContent(new MsgDataFormatDTO("prescribe",ext,orderId));
-            msg.setMsgType("TIMCustomElem");//TIMCustomElem
-            msgs.add(msg);
-            msgDTO.setMsgBody(msgs);
-            imService.sendMsg(msgDTO);
+        this.updateFsPrescribe(map);
+        if(Integer.valueOf(1).equals(param.getStatus())){
+            R createResult = storeOrderService.createOrder(prescribe.getPrescribeId());
+            if (!isSuccess(createResult)) {
+                throw new CustomException(getResultMsg(createResult, "创建订单失败"));
+            }
+            sendPrescribeAuditMsg(prescribe);
             return R.ok();
         }
         return R.ok("操作成功");
+    }
+
+    private boolean isSuccess(R result) {
+        return result != null && Integer.valueOf(com.fs.common.constant.HttpStatus.SUCCESS).equals(result.get("code"));
+    }
+
+    private String getResultMsg(R result, String defaultMsg) {
+        if (result == null || result.get("msg") == null) {
+            return defaultMsg;
+        }
+        return String.valueOf(result.get("msg"));
+    }
 
+    private void sendPrescribeAuditMsg(FsPrescribe prescribe) {
+        if (prescribe.getInquiryOrderId() == null) {
+            return;
+        }
+        String orderId = prescribe.getInquiryOrderId().toString();
+        MsgDTO msgDTO = new MsgDTO();
+        MsgCustomDTO customDTO = new MsgCustomDTO();
+        FsInquiryOrder fsInquiryOrder = fsInquiryOrderMapper.selectFsInquiryOrderByOrderId(prescribe.getInquiryOrderId());
+        customDTO.setType("inquiry");
+        customDTO.setOrderId(orderId);
+        customDTO.setImType(1);
+        if (fsInquiryOrder != null) {
+            customDTO.setOrderType(fsInquiryOrder.getOrderType());
+        }
+        msgDTO.setCloudCustomData(JSONUtil.toJsonStr(customDTO));
+        msgDTO.setFrom_Account("D-" + prescribe.getDoctorId());
+        msgDTO.setTo_Account("U-" + prescribe.getUserId());
+        List<MsgDataDTO> msgs = new ArrayList<>();
+        MsgDataDTO msg = new MsgDataDTO();
+        String ext = JSONUtil.toJsonStr(prescribe);
+        msg.setMsgContent(new MsgDataFormatDTO("prescribe", ext, orderId));
+        msg.setMsgType("TIMCustomElem");
+        msgs.add(msg);
+        msgDTO.setMsgBody(msgs);
+        imService.sendMsg(msgDTO);
     }
 
     public void penDrawString( Graphics2D pen,String value,int x,int y){

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

@@ -43,9 +43,15 @@ public class FsPrescribeListDVO implements Serializable {
     private String diagnose;
 
 
-    /** 状态 0未开 1已开 */
+    /** 处方审核状态:0待审核 1审核通过 2审核拒绝 */
     private Integer status;
 
+    /** 审核状态(与 status 一致,供前端展示) */
+    private Integer auditStatus;
+
+    /** 审核状态名称:待审核/审核通过/审核拒绝 */
+    private String auditStatusName;
+
     /** 审核时间 */
     @JsonFormat(pattern = "yyyy-MM-dd")
     private Date auditTime;

+ 106 - 29
fs-service/src/main/java/com/fs/hisStore/service/impl/FsPrescribeScrmStoreServiceImpl.java

@@ -165,13 +165,26 @@ public class FsPrescribeScrmStoreServiceImpl implements IFsPrescribeScrmStoreSer
     public List<FsPrescribeListDVO> selectFsPrescribeListDVO(FsPrescribeListDParam param) {
         List<FsPrescribeListDVO> list=fsPrescribeMapper.selectFsPrescribeListDVO(param);
         for(FsPrescribeListDVO vo:list){
+            fillPrescribeListAuditDisplay(vo);
             FsPrescribeDrug map=new FsPrescribeDrug();
             map.setPrescribeId(vo.getPrescribeId());
             vo.setDrugs(fsPrescribeDrugMapper.selectFsPrescribeDrugList(map));
         }
         return list;
+    }
 
-
+    private void fillPrescribeListAuditDisplay(FsPrescribeListDVO vo) {
+        Integer prescribeStatus = vo.getStatus() == null ? 0 : vo.getStatus();
+        vo.setAuditStatus(prescribeStatus);
+        if (prescribeStatus == 0) {
+            vo.setAuditStatusName("待审核");
+        } else if (prescribeStatus == 1) {
+            vo.setAuditStatusName("审核通过");
+        } else if (prescribeStatus == 2) {
+            vo.setAuditStatusName("审核拒绝");
+        } else {
+            vo.setAuditStatusName("未知");
+        }
     }
 
     @Override
@@ -901,6 +914,9 @@ public class FsPrescribeScrmStoreServiceImpl implements IFsPrescribeScrmStoreSer
         List<FsPrescribe> FsPrescribes=fsPrescribeDrugMapper.selectFsPrescribeNoAudit();
         for (FsPrescribe fsPrescribe : FsPrescribes) {
             Long id = doctorMapper.selectFsDoctorType2Ids(fsPrescribe.getPrescribeType());
+            if (id == null) {
+                continue;
+            }
             FsPrescribeAuditParam param=new FsPrescribeAuditParam();
             param.setDoctorId(id);
             param.setStatus(1);
@@ -912,9 +928,52 @@ public class FsPrescribeScrmStoreServiceImpl implements IFsPrescribeScrmStoreSer
     @Override
     @Transactional
     public R audit(FsPrescribeAuditParam param){
+        if (param.getPrescribeId() == null) {
+            return R.error("处方ID不能为空");
+        }
+        if (param.getStatus() == null) {
+            return R.error("审核状态不能为空");
+        }
+        if (!Integer.valueOf(1).equals(param.getStatus()) && !Integer.valueOf(2).equals(param.getStatus())) {
+            return R.error("审核状态不正确");
+        }
         FsPrescribe prescribe=this.selectFsPrescribeByPrescribeId(param.getPrescribeId());
-        if(prescribe.getStatus()!=0){
-            return R.error("非法操作");
+        if (prescribe == null) {
+            return R.error("处方不存在");
+        }
+        Integer prescribeStatus = prescribe.getStatus() == null ? 0 : prescribe.getStatus();
+        if (Integer.valueOf(1).equals(param.getStatus())) {
+            if (prescribeStatus == 1) {
+                if (prescribe.getStoreOrderId() != null) {
+                    return R.error("该处方已审核通过");
+                }
+                R createResult = storeOrderService.createOrderByPrescribe(prescribe.getPrescribeId());
+                if (!isSuccess(createResult)) {
+                    return R.error(getResultMsg(createResult, "创建订单失败"));
+                }
+                sendPrescribeAuditMsg(this.selectFsPrescribeByPrescribeId(param.getPrescribeId()));
+                return R.ok("处方已审核,订单已补建");
+            }
+            if (prescribeStatus == 2) {
+                return R.error("该处方已审核拒绝,无法通过");
+            }
+            if (prescribeStatus != 0) {
+                return R.error("当前处方状态不允许审核");
+            }
+        } else {
+            if (prescribeStatus == 1) {
+                return R.error("该处方已审核通过,无法拒绝");
+            }
+            if (prescribeStatus == 2) {
+                return R.error("该处方已审核拒绝");
+            }
+            if (prescribeStatus != 0) {
+                return R.error("当前处方状态不允许审核");
+            }
+        }
+        FsDoctor doctor=doctorService.selectFsDoctorByDoctorId(param.getDoctorId());
+        if (doctor == null) {
+            return R.error("审核医生不存在");
         }
         FsPrescribe map=new FsPrescribe();
         map.setPrescribeId(param.getPrescribeId());
@@ -922,39 +981,57 @@ public class FsPrescribeScrmStoreServiceImpl implements IFsPrescribeScrmStoreSer
         map.setStatus(param.getStatus());
         map.setAuditReason(param.getAuditReason());
         map.setAuditTime(new Date());
-        FsDoctor doctor=doctorService.selectFsDoctorByDoctorId(map.getDrugDoctorId());
         if(StringUtils.isNotEmpty(doctor.getSignUrl())){
             map.setDrugDoctorSignUrl(doctor.getSignUrl());
         }
-        if(param.getStatus().equals(1)){
-            this.updateFsPrescribe(map);
-            //写入订单
-            storeOrderService.createOrderByPrescribe(prescribe.getPrescribeId());
-            //发送信息
-            String orderId=prescribe.getInquiryOrderId().toString();
-            MsgDTO msgDTO=new MsgDTO();
-            MsgCustomDTO customDTO=new MsgCustomDTO();
-            FsInquiryOrder fsInquiryOrder = fsInquiryOrderMapper.selectFsInquiryOrderByOrderId(prescribe.getInquiryOrderId());
-            customDTO.setType("inquiry");
-            customDTO.setOrderId(orderId);
-            customDTO.setImType(1);
-            customDTO.setOrderType(fsInquiryOrder.getOrderType());
-            msgDTO.setCloudCustomData(JSONUtil.toJsonStr(customDTO));
-            msgDTO.setFrom_Account("D-"+prescribe.getDoctorId());
-            msgDTO.setTo_Account("U-"+prescribe.getUserId());
-            List<MsgDataDTO> msgs=new ArrayList<>();
-            MsgDataDTO msg=new MsgDataDTO();
-            String ext= JSONUtil.toJsonStr(prescribe);
-
-            msg.setMsgContent(new MsgDataFormatDTO("prescribe",ext,orderId));
-            msg.setMsgType("TIMCustomElem");//TIMCustomElem
-            msgs.add(msg);
-            msgDTO.setMsgBody(msgs);
-            imService.sendMsg(msgDTO);
+        this.updateFsPrescribe(map);
+        if(Integer.valueOf(1).equals(param.getStatus())){
+            R createResult = storeOrderService.createOrderByPrescribe(prescribe.getPrescribeId());
+            if (!isSuccess(createResult)) {
+                throw new CustomException(getResultMsg(createResult, "创建订单失败"));
+            }
+            sendPrescribeAuditMsg(prescribe);
             return R.ok();
         }
         return R.ok("操作成功");
+    }
+
+    private boolean isSuccess(R result) {
+        return result != null && Integer.valueOf(com.fs.common.constant.HttpStatus.SUCCESS).equals(result.get("code"));
+    }
+
+    private String getResultMsg(R result, String defaultMsg) {
+        if (result == null || result.get("msg") == null) {
+            return defaultMsg;
+        }
+        return String.valueOf(result.get("msg"));
+    }
 
+    private void sendPrescribeAuditMsg(FsPrescribe prescribe) {
+        if (prescribe.getInquiryOrderId() == null) {
+            return;
+        }
+        String orderId = prescribe.getInquiryOrderId().toString();
+        MsgDTO msgDTO = new MsgDTO();
+        MsgCustomDTO customDTO = new MsgCustomDTO();
+        FsInquiryOrder fsInquiryOrder = fsInquiryOrderMapper.selectFsInquiryOrderByOrderId(prescribe.getInquiryOrderId());
+        customDTO.setType("inquiry");
+        customDTO.setOrderId(orderId);
+        customDTO.setImType(1);
+        if (fsInquiryOrder != null) {
+            customDTO.setOrderType(fsInquiryOrder.getOrderType());
+        }
+        msgDTO.setCloudCustomData(JSONUtil.toJsonStr(customDTO));
+        msgDTO.setFrom_Account("D-" + prescribe.getDoctorId());
+        msgDTO.setTo_Account("U-" + prescribe.getUserId());
+        List<MsgDataDTO> msgs = new ArrayList<>();
+        MsgDataDTO msg = new MsgDataDTO();
+        String ext = JSONUtil.toJsonStr(prescribe);
+        msg.setMsgContent(new MsgDataFormatDTO("prescribe", ext, orderId));
+        msg.setMsgType("TIMCustomElem");
+        msgs.add(msg);
+        msgDTO.setMsgBody(msgs);
+        imService.sendMsg(msgDTO);
     }
 
     public void penDrawString( Graphics2D pen,String value,int x,int y){