Browse Source

1:增加医生开方-拒方逻辑;2:医生端不再展示已经取消订单、退款订单的处方数据

cgp 5 days ago
parent
commit
602ef02e30

+ 10 - 10
fs-company/src/main/java/com/fs/company/controller/qw/FsUserInformationCollectionScheduleController.java

@@ -115,17 +115,17 @@ public class FsUserInformationCollectionScheduleController extends BaseControlle
     }
 
     /**
-     * 终止用户信息采集进度
+     * 终止用户信息采集进度(已弃用)
      */
-    @PreAuthorize("@ss.hasPermi('qw:collectionSchedule:stop')")
-    @Log(title = "终止用户信息采集进度", businessType = BusinessType.INSERT)
-    @PutMapping("/endProcess")
-    public AjaxResult stopCollectionSchedule(@RequestBody FsUserInformationCollectionSchedule fsUserInformationCollectionSchedule)
-    {
-        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
-        fsUserInformationCollectionSchedule.setTerminatedBy(loginUser.getCompany().getUserId());
-        return toAjax(fsUserInformationCollectionScheduleService.stopCollectionSchedule(fsUserInformationCollectionSchedule));
-    }
+//    @PreAuthorize("@ss.hasPermi('qw:collectionSchedule:stop')")
+//    @Log(title = "终止用户信息采集进度", businessType = BusinessType.INSERT)
+//    @PutMapping("/endProcess")
+//    public AjaxResult stopCollectionSchedule(@RequestBody FsUserInformationCollectionSchedule fsUserInformationCollectionSchedule)
+//    {
+//        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
+//        fsUserInformationCollectionSchedule.setTerminatedBy(loginUser.getCompany().getUserId());
+//        return toAjax(fsUserInformationCollectionScheduleService.stopCollectionSchedule(fsUserInformationCollectionSchedule));
+//    }
 
     /**
      * 删除用户信息采集进度

+ 15 - 5
fs-doctor-app/src/main/java/com/fs/app/controller/FsPrescribeController.java

@@ -1,6 +1,5 @@
 package com.fs.app.controller;
 
-import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
 import com.fs.app.utils.JwtUtils;
 import com.fs.common.annotation.Log;
 import com.fs.common.core.controller.BaseController;
@@ -11,11 +10,9 @@ import com.fs.common.core.redis.RedisCache;
 import com.fs.common.enums.BusinessType;
 import com.fs.common.utils.SecurityUtils;
 import com.fs.common.utils.ServletUtils;
-import com.fs.his.domain.FsDoctor;
-import com.fs.his.domain.FsExportTask;
-import com.fs.his.domain.FsPatient;
-import com.fs.his.domain.FsPrescribe;
+import com.fs.his.domain.*;
 import com.fs.his.dto.FsPrescribeRecordRejectDto;
+import com.fs.his.dto.PrescribeRejectDTO;
 import com.fs.his.mapper.FsPatientMapper;
 import com.fs.his.param.FsPrescribeParam;
 import com.fs.his.service.IFsDoctorService;
@@ -75,6 +72,19 @@ public class FsPrescribeController extends BaseController
         fsPrescribeService.confirmPrescribe(param);
         return AjaxResult.success();
     }
+    /**
+     * 医生拒方
+     */
+    @PutMapping("/handleReject")
+    public R handleReject(@RequestBody PrescribeRejectDTO rejectDTO){
+        try {
+            rejectDTO.setTerminatedBy(getUserId()); //这里似乎获取不到用户信息
+        } catch (Exception e){
+            logger.error("获取拒访医生信息失败");
+        }
+        fsPrescribeService.handleReject(rejectDTO);
+        return R.ok();
+    }
     /**
      * 查询处方列表
      */

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

@@ -17,7 +17,7 @@ import lombok.EqualsAndHashCode;
 @EqualsAndHashCode(callSuper = true)
 public class FsUserInformationCollectionSchedule extends BaseEntity{
 
-    /** 主键 */
+    /** 采集进度表主键 */
     private Long id;
 
     /** 用户信息采集表id */

+ 15 - 0
fs-service/src/main/java/com/fs/his/dto/PrescribeRejectDTO.java

@@ -0,0 +1,15 @@
+package com.fs.his.dto;
+
+import lombok.Data;
+
+@Data
+public class PrescribeRejectDTO {
+    //处方id
+    private Long prescribeId;
+
+    //备注
+    private String remark;
+
+    //终止人
+    private Long terminatedBy;
+}

+ 4 - 0
fs-service/src/main/java/com/fs/his/service/IFsPrescribeService.java

@@ -6,6 +6,7 @@ import com.fs.common.core.domain.R;
 import com.fs.his.domain.FsPackageOrder;
 import com.fs.his.domain.FsPrescribe;
 import com.fs.his.domain.FsPrescribeDrug;
+import com.fs.his.dto.PrescribeRejectDTO;
 import com.fs.his.param.*;
 import com.fs.his.vo.*;
 import com.github.pagehelper.PageInfo;
@@ -67,6 +68,7 @@ public interface IFsPrescribeService
     public int deleteFsPrescribeByPrescribeId(Long prescribeId);
 
     List<FsPrescribeListVO> selectFsPrescribeListVO(FsPrescribeParam fsPrescribe);
+
     List<FsPrescribeListVO> selectFsPrescribeListVOWithConfirm(FsPrescribeParam fsPrescribe);
 
     List<FsPrescribeListDVO> selectFsPrescribeListDVO(FsPrescribeListDParam param);
@@ -125,4 +127,6 @@ public interface IFsPrescribeService
      * 获取医生开方操作时长列表
      * */
     PageInfo<DoctorOperateStatVO> getDurationList(PrescribeStatParam  param);
+
+    void handleReject(PrescribeRejectDTO rejectDTO);
 }

+ 37 - 5
fs-service/src/main/java/com/fs/his/service/impl/FsPrescribeServiceImpl.java

@@ -19,6 +19,7 @@ import com.fs.his.domain.*;
 import com.fs.his.dto.FsPackagePatientDTO;
 import com.fs.his.dto.FsPackagePruductDTO;
 import com.fs.his.dto.FsPrescribeUsageDTO;
+import com.fs.his.dto.PrescribeRejectDTO;
 import com.fs.his.enums.PrescriptionTaskStepEnum;
 import com.fs.his.mapper.*;
 import com.fs.his.param.*;
@@ -28,10 +29,7 @@ import com.fs.his.utils.qrcode.QRCodeUtils;
 import com.fs.his.vo.*;
 import com.fs.hisStore.domain.FsUserInformationCollection;
 import com.fs.hisStore.mapper.FsUserInformationCollectionMapper;
-import com.fs.im.dto.MsgCustomDTO;
-import com.fs.im.dto.MsgDTO;
-import com.fs.im.dto.MsgDataDTO;
-import com.fs.im.dto.MsgDataFormatDTO;
+import com.fs.hisStore.service.IFsUserInformationCollectionService;
 import com.fs.im.service.IImService;
 import com.fs.qw.mapper.FsUserInformationCollectionScheduleMapper;
 import com.fs.system.oss.CloudStorageService;
@@ -126,6 +124,10 @@ public class FsPrescribeServiceImpl implements IFsPrescribeService
     @Autowired
     private FsStoreOrderMapper storeOrderMapper;
 
+    @Lazy
+    @Autowired
+    private IFsUserInformationCollectionService fsUserInformationCollectionService;
+
     /**
      * 查询处方
      *
@@ -567,7 +569,7 @@ public class FsPrescribeServiceImpl implements IFsPrescribeService
                 //医生签名
                 o.setUrl(f.getUrl());
             }else if (signFlag!=null&&signFlag==2){
-                //医生签名
+                //医生签名+药师签名
                 o.setUrl(f.getUrl());
                 //药师签名
                 o.setDrugDoctorUrl(f.getDrugDoctorSignUrl());
@@ -1405,4 +1407,34 @@ public class FsPrescribeServiceImpl implements IFsPrescribeService
         return new PageInfo<>(operateStatVOList);
     }
 
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public void handleReject(PrescribeRejectDTO rejectDTO) {
+        //根据处方id查询订单号,根据订单号查询信息采集表id,根据信息采集表id 查询 信息采集进度
+        FsStoreOrder fsStoreOrder =new FsStoreOrder();
+        fsStoreOrder.setPrescribeId(rejectDTO.getPrescribeId());
+        List<FsStoreOrder> fsStoreOrders = storeOrderMapper.selectFsStoreOrderList(fsStoreOrder);
+        if (CollectionUtils.isEmpty(fsStoreOrders)&& fsStoreOrders.isEmpty()){
+            log.error("处方订单不存在,处方id:{}",rejectDTO.getPrescribeId());
+            throw new CustomException("订单不存在");
+        }else {
+            String orderCode = fsStoreOrders.get(0).getOrderCode();
+            FsUserInformationCollection fsUserInformationCollection = new FsUserInformationCollection();
+            fsUserInformationCollection.setPackageOrderCode(orderCode);
+            List<FsUserInformationCollection> fsUserInformationCollections = fsUserInformationCollectionService.selectFsUserInformationCollectionList(fsUserInformationCollection);
+            if (CollectionUtils.isEmpty(fsUserInformationCollections)){
+                log.error("用户采集信息不存在,处方id:{}",rejectDTO.getPrescribeId());
+                throw new CustomException("用户采集信息不存在");
+            }
+            Long collectionId=fsUserInformationCollections.get(0).getId();
+            // 1. 停止采集(状态变更)
+            FsUserInformationCollectionSchedule paramCondition=new FsUserInformationCollectionSchedule();
+            paramCondition.setRemark("医生拒访:"+rejectDTO.getRemark());
+            paramCondition.setCollectionId(collectionId);
+            paramCondition.setOrderCode(orderCode);
+            fsUserInformationCollectionService.stopCollection(paramCondition,rejectDTO.getTerminatedBy());//包含退款操作
+        }
+
+    }
+
 }

+ 19 - 9
fs-service/src/main/java/com/fs/hisStore/service/impl/FsUserInformationCollectionServiceImpl.java

@@ -953,6 +953,7 @@ public class FsUserInformationCollectionServiceImpl extends ServiceImpl<FsUserIn
     }
 
     @Override
+    @Transactional(rollbackFor = Exception.class)
     public R stopCollection(FsUserInformationCollectionSchedule param, Long operateId) {
         FsUserInformationCollection collection = this.fsUserInformationCollectionMapper.selectFsUserInformationCollectionById(param.getCollectionId());
         if (collection == null) {
@@ -970,19 +971,28 @@ public class FsUserInformationCollectionServiceImpl extends ServiceImpl<FsUserIn
         map.setDoctorConfirm(0);
         map.setStatus(1);
         if(fsUserInformationCollectionMapper.updateFsUserInformationCollection(map) > 0) {
-            //同步采集进度
-            FsUserInformationCollectionSchedule fsUserInformationCollectionSchedule= new FsUserInformationCollectionSchedule();
-            fsUserInformationCollectionSchedule.setId(param.getId());
+            //根据采集表id查询信息采集进度信息
+            FsUserInformationCollectionSchedule schedule;
+            // 有进度id主键就用进度id查询,没有就行采集表id查询
+            if (param.getId()!=null){
+                schedule=scheduleMapper.selectFsUserInformationCollectionScheduleById(param.getId());
+            }else {
+                schedule = scheduleMapper.selectCollectionScheduleByCollectionId(param.getCollectionId());
+            }
             // "用户采集进度"中止时间
-            fsUserInformationCollectionSchedule.setTerminatedTime(DateUtils.getNowDate());
+            schedule.setTerminatedTime(DateUtils.getNowDate());
             // "用户采集进度"中止标识
-            fsUserInformationCollectionSchedule.setStatus(CollectionTaskStatusEnum.TERMINATED.getCode());
+            schedule.setStatus(CollectionTaskStatusEnum.TERMINATED.getCode());
             // "用户采集进度"中止原因
-            fsUserInformationCollectionSchedule.setRemark(param.getRemark());
+            schedule.setRemark(param.getRemark());
             // "用户采集进度"中止操作人员
-            fsUserInformationCollectionSchedule.setTerminatedBy(operateId);
-            scheduleMapper.updateFsUserInformationCollectionSchedule(fsUserInformationCollectionSchedule);
-
+            schedule.setTerminatedBy(operateId);
+            int result = scheduleMapper.updateFsUserInformationCollectionSchedule(schedule);
+            if (StringUtils.isNotBlank(param.getOrderCode())){
+                //如果传入订单号不为空则在终止时需要执行退款操作
+                map.setPackageOrderCode(param.getOrderCode());
+                autoRefund(map);
+            }
             return R.ok();
         }
         return R.error("终止失败");

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

@@ -295,6 +295,7 @@
         <if test="orderStatus != null "> and fso.`status` = #{orderStatus}</if>
         <if test="storeId != null "> and so.store_id = #{storeId}</if>
     </select>
+    <!--    已取消、已退款的处方不展示-->
     <select id="selectFsPrescribeListVOWithConfirm" resultType="com.fs.his.vo.FsPrescribeListVO">
         select so.*,CAST(operate_second AS CHAR) operateTime,us.nick_name,dc.doctor_name,
                dp.doctor_name doctor_drug_name,
@@ -303,7 +304,7 @@
                    LEFT JOIN fs_user us ON us.user_id=so.user_id
                    LEFT JOIN fs_doctor dc ON dc.doctor_id = so.doctor_id
                    LEFT JOIN fs_doctor dp ON dp.doctor_id =so.drug_doctor_id
-                   LEFT JOIN fs_store_order fso ON fso.order_id = so.store_order_id
+                   INNER JOIN fs_store_order fso ON fso.order_id = so.store_order_id AND fso.status != -3  AND fso.status != -2
                    LEFT JOIN fs_store fse ON fse.store_id = so.store_id
         <where>
             doctor_confirm !=  -1