Browse Source

完善医技预约模块。

lighter 4 years ago
parent
commit
4a4935c2f2

+ 35 - 7
src/main/java/thyyxxk/wxservice_server/controller/BookableController.java

@@ -3,8 +3,9 @@ package thyyxxk.wxservice_server.controller;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 import thyyxxk.wxservice_server.entity.ResultVo;
-import thyyxxk.wxservice_server.entity.bookable.ExamItem;
-import thyyxxk.wxservice_server.entity.bookable.BookedExamination;
+import thyyxxk.wxservice_server.entity.bookable.YjReqItem;
+import thyyxxk.wxservice_server.entity.bookable.BookedYjReq;
+import thyyxxk.wxservice_server.entity.bookable.RejectedYjReq;
 import thyyxxk.wxservice_server.service.BookableService;
 
 import java.util.List;
@@ -26,18 +27,30 @@ public class BookableController {
     }
 
     @GetMapping("/getBookableData")
-    public ResultVo<List<ExamItem>> getBookableData(@RequestParam("tableName") String tableName) {
+    public ResultVo<List<YjReqItem>> getBookableData(@RequestParam("tableName") String tableName) {
         return service.getBookableData(tableName);
     }
 
-    @PostMapping("/getFullScheduleOfMedicalForPlatform")
+    @GetMapping("/getFullScheduleOfMedicalForPlatform")
     public ResultVo<Map<String, Object>> getFullScheduleOfMedicalForPlatform
-            (@RequestBody BookedExamination exam) {
-        return service.getFullScheduleOfMedicalForPlatform(exam);
+            (@RequestParam("execUnit") String execUnit) {
+        return service.getFullScheduleOfMedicalForPlatform(execUnit);
+    }
+
+    @GetMapping("/getOtherTimeForRejectedReq")
+    public ResultVo<List<Map<String, Object>>> getOtherTimeForRejectedReq
+            (@RequestParam("execUnit") String execUnit) {
+        return service.getOtherTimeForRejectedReq(execUnit);
+    }
+
+    @GetMapping("/getBookTip")
+    public ResultVo<String[]> getBookTip(@RequestParam("tableName") String tableName,
+                                       @RequestParam("code") String code) {
+        return service.getBookTip(tableName, code);
     }
 
     @PostMapping("/saveBookPrescription")
-    public ResultVo<Integer> saveBookPrescription(@RequestBody BookedExamination param) throws InterruptedException {
+    public ResultVo<Integer> saveBookPrescription(@RequestBody BookedYjReq param) throws InterruptedException {
         return service.saveBookPrescription(param);
     }
 
@@ -45,4 +58,19 @@ public class BookableController {
     public ResultVo<String> revokeBookPrescription(@RequestParam("reqNo") Integer reqNo) {
         return service.revokeBookPrescription(reqNo);
     }
+
+    @GetMapping("/getRejectedYjReq")
+    public ResultVo<RejectedYjReq> getRejectedYjReq(@RequestParam("reqNo") Integer reqNo) {
+        return service.getRejectedYjReq(reqNo);
+    }
+
+    @PostMapping("/changeYjReqTime")
+    public ResultVo<String> changeYjReqTime(@RequestBody BookedYjReq param) {
+        return service.changeYjReqTime(param);
+    }
+
+    @GetMapping("/applyRefund")
+    public ResultVo<String> applyRefund(@RequestParam("reqNo") Integer reqNo) {
+        return service.applyRefund(reqNo);
+    }
 }

+ 15 - 2
src/main/java/thyyxxk/wxservice_server/dao/BookableDao.java

@@ -4,7 +4,9 @@ import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Select;
 import org.apache.ibatis.annotations.Update;
-import thyyxxk.wxservice_server.entity.bookable.ExamItem;
+import thyyxxk.wxservice_server.entity.bookable.BookedYjReq;
+import thyyxxk.wxservice_server.entity.bookable.YjReqItem;
+import thyyxxk.wxservice_server.entity.bookable.RejectedYjReq;
 import thyyxxk.wxservice_server.entity.wxapi.WxPayOrder;
 
 import java.util.List;
@@ -19,7 +21,10 @@ public interface BookableDao {
     @Select("select rtrim(code) as code, rtrim(name) as name, rtrim(exec_unit) as execUnit, " +
             "execUnitName=(select rtrim(name) from zd_unit_code where code=exec_unit) " +
             "from ${tableName} where isnull(del_flag,0)!=1 and wx_bookable_flag=1 and isnull(exec_unit,'')!=''")
-    List<ExamItem> getBookableData(@Param("tableName") String tableName);
+    List<YjReqItem> getBookableData(@Param("tableName") String tableName);
+
+    @Select("select book_tip from ${tableName} where code=#{code}")
+    String selectBookTip(@Param("tableName") String tableName, @Param("code") String code);
 
     @Select("select count(1) from mz_yj_req where patient_id=#{patientId} and pay_mark=5 and " +
             "order_code=#{code} and isnull(del_flag,0)=0 and req_doctor='99999' and datediff(day,req_date,getdate())<=3")
@@ -31,6 +36,9 @@ public interface BookableDao {
     Integer selectReqNo(@Param("patientId") String patientId,
                         @Param("code") String code);
 
+    @Update("update mz_yj_req set record_date=#{recordDate},begin_time=#{beginTime},end_time=#{endTime} where req_no=#{reqNo}")
+    void updateReqInfo(BookedYjReq req);
+
     @Select("select pay_mark from mz_yj_req where req_no=#{reqNo}")
     Integer selectPayMarkByReqNo(@Param("reqNo") int reqNo);
 
@@ -42,4 +50,9 @@ public interface BookableDao {
 
     @Select("select * from t_wechat_pay_order where yj_req_no=#{reqNo}")
     WxPayOrder selectWxPayOrder(@Param("reqNo") int reqNo);
+
+    @Select("select req_no,patient_id,rtrim(p_name) as patientName,order_code,order_name,exec_dept,req_date," +
+            "execUnitName=(select rtrim(name) from zd_unit_code where code=exec_dept),record_date,begin_time,end_time " +
+            "from mz_yj_req where req_no=#{reqNo}")
+    RejectedYjReq getRejectedYjReq(@Param("reqNo") int reqNo);
 }

+ 2 - 1
src/main/java/thyyxxk/wxservice_server/dao/WxApiDao.java

@@ -13,7 +13,8 @@ public interface WxApiDao {
     @Select("select rtrim(name) from mz_patient_mi where patient_id=#{patientId}")
     String selectPatientName(@Param("patientId") String patientId);
 
-    @Select("select * from t_wechat_pay_order where patient_id=#{patientId} and mzy_request_id=#{mzyRequestId}")
+    @Select("select * from t_wechat_pay_order where patient_id=#{patientId} and " +
+            "mzy_request_id=#{mzyRequestId} ")
     WxPayOrder selectSameGhOrder(@Param("patientId") String patientId,
                                  @Param("mzyRequestId") Integer mzyRequestId);
 

+ 2 - 2
src/main/java/thyyxxk/wxservice_server/entity/bookable/BookedExamination.java → src/main/java/thyyxxk/wxservice_server/entity/bookable/BookedYjReq.java

@@ -11,7 +11,7 @@ import java.util.concurrent.TimeUnit;
  * @create: 2021-04-25 14:15:23
  **/
 @Data
-public class BookedExamination implements Delayed {
+public class BookedYjReq implements Delayed {
     private Integer id;
     private Integer reqNo;
     private String patientId;
@@ -31,6 +31,6 @@ public class BookedExamination implements Delayed {
 
     @Override
     public int compareTo(Delayed o) {
-        return this.getCancelTime().compareTo(((BookedExamination) o).getCancelTime());
+        return this.getCancelTime().compareTo(((BookedYjReq) o).getCancelTime());
     }
 }

+ 1 - 1
src/main/java/thyyxxk/wxservice_server/entity/bookable/Prescription.java

@@ -27,7 +27,7 @@ public class Prescription {
     private List<HashMap<String, String>> mzChargeDetailList = new ArrayList<>();
     private List<HashMap<String, String>> mzYjReqList;
 
-    public void initMzYjReqList(BookedExamination book) {
+    public void initMzYjReqList(BookedYjReq book) {
         setPatientId(book.getPatientId());
         setVisitDeptCode(book.getExecUnit());
         setReqComment("自助开单-" + book.getName());

+ 25 - 0
src/main/java/thyyxxk/wxservice_server/entity/bookable/RejectedYjReq.java

@@ -0,0 +1,25 @@
+package thyyxxk.wxservice_server.entity.bookable;
+
+import lombok.Data;
+
+import java.util.Date;
+
+/**
+ * @description: 被驳回的医技预约
+ * @author: DingJie
+ * @create: 2021-05-17 08:57:27
+ **/
+@Data
+public class RejectedYjReq {
+    private Integer reqNo;
+    private String patientId;
+    private String patientName;
+    private String orderCode;
+    private String orderName;
+    private String execDept;
+    private Date reqDate;
+    private String execUnitName;
+    private String recordDate;
+    private String beginTime;
+    private String endTime;
+}

+ 1 - 1
src/main/java/thyyxxk/wxservice_server/entity/bookable/ExamItem.java → src/main/java/thyyxxk/wxservice_server/entity/bookable/YjReqItem.java

@@ -7,7 +7,7 @@ import lombok.Data;
  * @create: 2021-04-25 11:39:22
  **/
 @Data
-public class ExamItem {
+public class YjReqItem {
     private String code;
     private String name;
     private String execUnit;

+ 68 - 16
src/main/java/thyyxxk/wxservice_server/service/BookableService.java

@@ -11,15 +11,17 @@ import thyyxxk.wxservice_server.config.exception.ExceptionEnum;
 import thyyxxk.wxservice_server.constant.Constants;
 import thyyxxk.wxservice_server.dao.BookableDao;
 import thyyxxk.wxservice_server.entity.ResultVo;
-import thyyxxk.wxservice_server.entity.bookable.ExamItem;
-import thyyxxk.wxservice_server.entity.bookable.BookedExamination;
+import thyyxxk.wxservice_server.entity.bookable.YjReqItem;
+import thyyxxk.wxservice_server.entity.bookable.BookedYjReq;
 import thyyxxk.wxservice_server.entity.bookable.Prescription;
+import thyyxxk.wxservice_server.entity.bookable.RejectedYjReq;
 import thyyxxk.wxservice_server.entity.hrgresponse.HrgCommonResponse;
 import thyyxxk.wxservice_server.entity.hrgresponse.SaveMzFeeResponse;
 import thyyxxk.wxservice_server.entity.wxapi.WxPayOrder;
 import thyyxxk.wxservice_server.utils.CastUtil;
 import thyyxxk.wxservice_server.utils.DateUtil;
 import thyyxxk.wxservice_server.utils.ResultVoUtil;
+import thyyxxk.wxservice_server.utils.StringUtil;
 
 import java.util.*;
 import java.util.concurrent.DelayQueue;
@@ -34,7 +36,7 @@ import java.util.concurrent.TimeUnit;
 public class BookableService {
     private final BookableDao dao;
     private final WxApiService wxApiService;
-    DelayQueue<BookedExamination> queue = new DelayQueue<>();
+    DelayQueue<BookedYjReq> queue = new DelayQueue<>();
 
     @Value("${hrgApiUrl}")
     private String hrgApiUrl;
@@ -45,7 +47,7 @@ public class BookableService {
         this.wxApiService = wxApiService;
     }
 
-    public ResultVo<List<ExamItem>> getBookableData(String tableName) {
+    public ResultVo<List<YjReqItem>> getBookableData(String tableName) {
         return ResultVoUtil.success(dao.getBookableData(tableName));
     }
 
@@ -56,7 +58,7 @@ public class BookableService {
         RestTemplate restTemplate = new RestTemplate();
         while (true) {
             try {
-                BookedExamination bookedItem = queue.take();
+                BookedYjReq bookedItem = queue.take();
                 Integer payMark = dao.selectPayMarkByReqNo(bookedItem.getReqNo());
                 if (null != payMark && payMark == 5) {
                     String url = hrgApiUrl + "/cancelApplyScheduleOfMedical?scheduleId=" + bookedItem.getId();
@@ -70,12 +72,12 @@ public class BookableService {
         }
     }
 
-    public ResultVo<Map<String, Object>> getFullScheduleOfMedicalForPlatform(BookedExamination exam) {
+    public ResultVo<Map<String, Object>> getFullScheduleOfMedicalForPlatform(String execUnit) {
         String[] dateRange = DateUtil.getDatesInOneWeek();
         RestTemplate restTemplate = new RestTemplate();
         HrgCommonResponse hrgResponse = restTemplate
                 .getForObject(String.format(hrgApiUrl + "/getFullScheduleOfMedicalForPlatform?depNo=%s&beginTime=%s&endTime=%s",
-                        exam.getExecUnit(), dateRange[0], dateRange[6]), HrgCommonResponse.class);
+                        execUnit, dateRange[0], dateRange[6]), HrgCommonResponse.class);
         if (null == hrgResponse) {
             return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "网络服务错误!");
         }
@@ -107,7 +109,33 @@ public class BookableService {
         return ResultVoUtil.success(resultMap);
     }
 
-    public ResultVo<Integer> saveBookPrescription(BookedExamination param) throws InterruptedException {
+    public ResultVo<List<Map<String, Object>>> getOtherTimeForRejectedReq(String execUnit) {
+        String[] dateRange = DateUtil.getDatesInOneWeek();
+        RestTemplate restTemplate = new RestTemplate();
+        HrgCommonResponse hrgResponse = restTemplate
+                .getForObject(String.format(hrgApiUrl + "/getFullScheduleOfMedicalForPlatform?depNo=%s&beginTime=%s&endTime=%s",
+                        execUnit, dateRange[0], dateRange[6]), HrgCommonResponse.class);
+        if (null == hrgResponse) {
+            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "网络服务错误!");
+        }
+        if (-1 == hrgResponse.getCode()) {
+            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, hrgResponse.getMessage());
+        }
+        List<Map<String, Object>> data = CastUtil.cast(hrgResponse.getData());
+        data.removeIf(item -> (int) item.get("status") != 0);
+        return ResultVoUtil.success(data);
+    }
+
+    public ResultVo<String[]> getBookTip(String tableName, String code) {
+        String tip = dao.selectBookTip(tableName, code);
+        if (StringUtil.isBlank(tip)) {
+            return ResultVoUtil.success(null);
+        }
+        String[] tips = tip.split("\n");
+        return ResultVoUtil.success(tips);
+    }
+
+    public ResultVo<Integer> saveBookPrescription(BookedYjReq param) throws InterruptedException {
         int reqNoExist = dao.reqNoExist(param.getPatientId(), param.getCode());
         if (reqNoExist > 0) {
             return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "您有未缴费的相同预约,无法继续预约,敬请谅解。");
@@ -151,6 +179,7 @@ public class BookableService {
         }
         long beginTime = System.currentTimeMillis();
         param.setReqNo(reqNo);
+        dao.updateReqInfo(param);
         param.setCreateTime(new Date());
         param.setCancelTime(new Date(beginTime + 30 * 60 * 1000L));
         queue.add(param);
@@ -158,19 +187,42 @@ public class BookableService {
         return ResultVoUtil.success(reqNo);
     }
 
+    public ResultVo<String> changeYjReqTime(BookedYjReq param) {
+        JSONObject obj = new JSONObject();
+        obj.put("scheduleId", param.getId());
+        obj.put("xdtjcjg", 0);
+        obj.put("actOrderNo", param.getReqNo());
+        RestTemplate restTemplate = new RestTemplate();
+        HrgCommonResponse hrgCommonResponse = restTemplate.postForObject(hrgApiUrl + "/applyScheduleOfMedicalForPlatform",
+                obj, HrgCommonResponse.class);
+        if (null == hrgCommonResponse) {
+            return ResultVoUtil.fail(ExceptionEnum.NETWORK_ERROR);
+        }
+        if (0 != hrgCommonResponse.getCode()) {
+            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, hrgCommonResponse.getMessage());
+        }
+        dao.updateReqInfo(param);
+        return ResultVoUtil.success("修改预约时间成功。");
+    }
+
     public ResultVo<String> revokeBookPrescription(Integer reqNo) {
         dao.revokeMzYjReq(reqNo, 2);
         queue.removeIf(item -> item.getReqNo().equals(reqNo));
         log.info("【reqNo: {}】驳回检查预约,容器剩余:{}", reqNo, queue.size());
+        return ResultVoUtil.success();
+    }
+
+    public ResultVo<RejectedYjReq> getRejectedYjReq(Integer reqNo) {
+        return ResultVoUtil.success(dao.getRejectedYjReq(reqNo));
+    }
+
+    public ResultVo<String> applyRefund(Integer reqNo) {
         WxPayOrder order = dao.selectWxPayOrder(reqNo);
-        if (order.getPayStatus() == 1) {
-            ResultVo<String> refund = wxApiService.autoRefund(order.getTradeNo(), "驳回检查检验预约,自动退款。");
-            log.info("【reqNo: {}】驳回检查预约,自动退款结果:{}", reqNo, refund);
-            if (null != refund && refund.getCode() == 200) {
-                return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "【reqNo: " + reqNo + "】已驳回检查检验预约,自动退款成功。");
-            }
-            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "【reqNo: " + reqNo + "】已驳回检查检验预约,自动退款失败。");
+        ResultVo<String> refundResult = wxApiService.autoRefund(order.getTradeNo(), "驳回的医技预约,患者选择退款。");
+        log.info("【reqNo: {}】驳回的检查预约,患者选择退款,退款结果:{}", reqNo, refundResult);
+        if (null != refundResult && refundResult.getCode() == 200) {
+            return ResultVoUtil.success("退款成功,资金已原路返还,请您留意退款到账信息(可能有1到3分钟延迟)。");
         }
-        return ResultVoUtil.success();
+        return refundResult;
     }
 }

+ 4 - 3
src/main/resources/application.yml

@@ -8,7 +8,8 @@ spring:
   thymeleaf:
     cache: false
   datasource:
-    url: jdbc:jtds:sqlserver://172.16.32.179:1433/thxyhisdb
+#    url: jdbc:jtds:sqlserver://172.16.32.179:1433/thxyhisdb
+    url: jdbc:jtds:sqlserver://172.16.32.168:1433/thxyhisdb
     hikari:
       username: sa
       password:
@@ -30,6 +31,6 @@ mybatis:
   configuration:
     map-underscore-to-camel-case: true
 
-hrgApiUrl: http://172.16.30.33:8089/thmz/api/v1
-#hrgApiUrl: http://webhis.thyy.cn:81/thmz/api/v1
+#hrgApiUrl: http://172.16.30.33:8089/thmz/api/v1
+hrgApiUrl: http://webhis.thyy.cn:81/thmz/api/v1
 inspectionUrl: http://172.16.32.178:622/pushservice.asmx?wsdl