Browse Source

优化体检报告查询

lighter 2 years ago
parent
commit
8a6b6b271d

+ 11 - 17
src/main/java/thyyxxk/wxservice_server/controller/PowersiPhysicalCheckController.java

@@ -5,6 +5,8 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 import thyyxxk.wxservice_server.config.exception.ExceptionEnum;
 import thyyxxk.wxservice_server.entity.ResultVo;
+import thyyxxk.wxservice_server.entity.physicalcheck.IdCardInquiry;
+import thyyxxk.wxservice_server.entity.physicalcheck.PhysicalCheckIndexInquiry;
 import thyyxxk.wxservice_server.service.PowersiPhysicalCheckService;
 import thyyxxk.wxservice_server.utils.AgentUtil;
 import thyyxxk.wxservice_server.utils.ResultVoUtil;
@@ -22,27 +24,19 @@ public class PowersiPhysicalCheckController {
         this.service = service;
     }
 
-    @GetMapping("/getIdCard")
-    public ResultVo<String> getIdCard(@RequestParam("patientId") String patientId, HttpServletRequest request) {
-//        if (!AgentUtil.fromWechatBrowser(request)) {
-//            return ResultVoUtil.fail(ExceptionEnum.INTERNAL_SERVER_ERROR, "请求失败,调用来源验证失败。");
-//        }
-//        return service.getIdCard(patientId);
-        return ResultVoUtil.fail(ExceptionEnum.INTERNAL_SERVER_ERROR, "请求失败,调用来源验证失败。");
+    @PostMapping("/getIdCard")
+    public ResultVo<String> getIdCard(@RequestBody IdCardInquiry inquiry, HttpServletRequest request) {
+        if (AgentUtil.notFromWechatBrowser(request)) {
+            return ResultVoUtil.fail(ExceptionEnum.INTERNAL_SERVER_ERROR, "请求失败,调用来源验证失败。");
+        }
+        return service.getIdCard(inquiry);
     }
 
-    @GetMapping("/getPhysicalCheckIndex")
-    public ResultVo<JSONObject> getPhysicalCheckIndex(@RequestParam("idCard") String idCard,
-                                                      @RequestParam("patientId") String patientId,
-                                                      @RequestParam("pageNo") Integer pageNo) {
-        return service.getPhysicalCheckIndex(idCard, patientId, pageNo);
+    @PostMapping("/getPhysicalCheckIndex")
+    public ResultVo<JSONObject> getPhysicalCheckIndex(@RequestBody PhysicalCheckIndexInquiry inquiry) {
+        return service.getPhysicalCheckIndex(inquiry);
     }
 
-//    @GetMapping("/getPhysicalCheckResult")
-//    public ResultVo<JSONObject> getPhysicalCheckResult(@RequestParam("tjid") String tjid) {
-//        return service.getPhysicalCheckResult(tjid);
-//    }
-
     @PostMapping("/exportPDF")
     public String exportPDF(HttpServletResponse response, @RequestBody JSONObject tjIndex) {
         return service.exportPDF(response, tjIndex);

+ 6 - 4
src/main/java/thyyxxk/wxservice_server/dao/PhysicalExamDao.java

@@ -2,12 +2,14 @@ package thyyxxk.wxservice_server.dao;
 
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Select;
+import thyyxxk.wxservice_server.entity.physicalcheck.IdCardInquiry;
+import thyyxxk.wxservice_server.entity.physicalcheck.PhysicalCheckIndexInquiry;
 
 @Mapper
 public interface PhysicalExamDao {
-    @Select("select top 1 social_no from t_wechat_patient_bind where patient_id=#{patientId}")
-    String selectIdCard(String patientId);
+    @Select("select top 1 social_no from t_wechat_patient_bind where patient_id=#{patNo} and open_id=#{openId}")
+    String selectIdCard(IdCardInquiry inquiry);
 
-    @Select("select count(1) from t_wechat_patient_bind where social_no=#{socialNo} and patient_id=#{patId}")
-    int selectSocialNoAndPatIdMatch(String socialNo, String patId);
+    @Select("select count(1) from t_wechat_patient_bind where social_no=#{idCard} and patient_id=#{patNo}")
+    int selectSocialNoAndPatIdMatch(PhysicalCheckIndexInquiry inquiry);
 }

+ 9 - 0
src/main/java/thyyxxk/wxservice_server/entity/physicalcheck/IdCardInquiry.java

@@ -0,0 +1,9 @@
+package thyyxxk.wxservice_server.entity.physicalcheck;
+
+import lombok.Data;
+
+@Data
+public class IdCardInquiry {
+    private String patNo;
+    private String openId;
+}

+ 10 - 0
src/main/java/thyyxxk/wxservice_server/entity/physicalcheck/PhysicalCheckIndexInquiry.java

@@ -0,0 +1,10 @@
+package thyyxxk.wxservice_server.entity.physicalcheck;
+
+import lombok.Data;
+
+@Data
+public class PhysicalCheckIndexInquiry {
+    private String patNo;
+    private String idCard;
+    private Integer pageNo;
+}

+ 15 - 11
src/main/java/thyyxxk/wxservice_server/service/PowersiPhysicalCheckService.java

@@ -2,8 +2,6 @@ package thyyxxk.wxservice_server.service;
 
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
-import com.itextpdf.text.*;
-import com.itextpdf.text.pdf.*;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
@@ -12,14 +10,14 @@ import org.springframework.web.client.RestTemplate;
 import thyyxxk.wxservice_server.config.exception.ExceptionEnum;
 import thyyxxk.wxservice_server.dao.PhysicalExamDao;
 import thyyxxk.wxservice_server.entity.ResultVo;
+import thyyxxk.wxservice_server.entity.physicalcheck.IdCardInquiry;
+import thyyxxk.wxservice_server.entity.physicalcheck.PhysicalCheckIndexInquiry;
 import thyyxxk.wxservice_server.utils.DateUtil;
 import thyyxxk.wxservice_server.utils.PhysicalCheckPDFUtil;
 import thyyxxk.wxservice_server.utils.ResultVoUtil;
 import thyyxxk.wxservice_server.utils.StringUtil;
 
 import javax.servlet.http.HttpServletResponse;
-import java.io.OutputStream;
-import java.net.URLEncoder;
 import java.util.Comparator;
 import java.util.List;
 
@@ -35,19 +33,20 @@ public class PowersiPhysicalCheckService {
         this.dao = dao;
     }
 
-    public ResultVo<String> getIdCard(String patientId) {
-        String idCard = dao.selectIdCard(patientId);
+    public ResultVo<String> getIdCard(IdCardInquiry inquiry) {
+        String idCard = dao.selectIdCard(inquiry);
         if (StringUtil.isBlank(idCard)) {
-            return ResultVoUtil.fail(ExceptionEnum.NO_DATA_EXIST, "未查询到绑定的身份证号,请手动输入身份证或体检号查询。");
+            return ResultVoUtil.fail(ExceptionEnum.NO_DATA_EXIST, "未查询到绑定的身份证号,请手动输入身份证查询。");
         }
         return ResultVoUtil.success(idCard);
     }
 
-    public ResultVo<JSONObject> getPhysicalCheckIndex(String idCard, String patientId, Integer pageNo) {
-        if (dao.selectSocialNoAndPatIdMatch(idCard, patientId) < 1) {
+    public ResultVo<JSONObject> getPhysicalCheckIndex(PhysicalCheckIndexInquiry inquiry) {
+        if (dao.selectSocialNoAndPatIdMatch(inquiry) < 1) {
             return ResultVoUtil.fail(ExceptionEnum.NULL_POINTER, "就诊人和身份证不匹配,没有查询的权限。");
         }
-        String url = physicalCheckUrl + "317926227bc2431399c86240375ba549?IDCARD=" + idCard + "&IDCARDTYPE=01&pageNo=" + pageNo;
+        String url = physicalCheckUrl + "317926227bc2431399c86240375ba549?IDCARD=" +
+                inquiry.getIdCard() + "&IDCARDTYPE=01&pageNo=" + inquiry.getPageNo();
         RestTemplate template = new RestTemplate();
         JSONObject rawdata = template.getForObject(url, JSONObject.class);
         if (null == rawdata) {
@@ -62,7 +61,12 @@ public class PowersiPhysicalCheckService {
             for (int i = 0; i < rows.size(); i++) {
                 JSONObject item = rows.getJSONObject(i);
                 String checkTime = item.getString("登记日期");
-                checkTime = checkTime.substring(0, 4) + "-" + checkTime.substring(4, 6) + "-" + checkTime.substring(6);
+                if (null == checkTime) {
+                    checkTime = "";
+                }
+                if (StringUtil.notBlank(checkTime) && checkTime.length() >= 8) {
+                    checkTime = checkTime.substring(0, 4) + "-" + checkTime.substring(4, 6) + "-" + checkTime.substring(6);
+                }
                 item.put("checkTime", checkTime);
             }
             return ResultVoUtil.success(rawdata);

+ 8 - 2
src/main/java/thyyxxk/wxservice_server/utils/PhysicalCheckPDFUtil.java

@@ -159,9 +159,15 @@ public class PhysicalCheckPDFUtil {
         paragraph.add(departmentChunk);
         paragraph.add(Chunk.NEWLINE);
 
-        String date = DateUtil.parseTimestamp(tjIndex.getLong("登记日期"), "yyyy-MM-dd");
+        String checkTime = tjIndex.getString("登记日期");
+        if (null == checkTime) {
+            checkTime = "";
+        }
+        if (StringUtil.notBlank(checkTime) && checkTime.length() >= 8) {
+            checkTime = checkTime.substring(0, 4) + "-" + checkTime.substring(4, 6) + "-" + checkTime.substring(6);
+        }
         String phone = tjIndex.getString("手机");
-        Chunk dateChunk = new Chunk("体检日期:" + (null == date ? "" : date)
+        Chunk dateChunk = new Chunk("体检日期:" + checkTime
                 + "               电话:" + (null == phone ? "" : phone));
         dateChunk.setFont(font);
         paragraph.add(dateChunk);