소스 검색

增加体检报告查询

hsh 3 년 전
부모
커밋
84fba6e317

+ 57 - 0
src/main/java/thyyxxk/webserver/controller/bodyexam/BodyExamController.java

@@ -0,0 +1,57 @@
+package thyyxxk.webserver.controller.bodyexam;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import thyyxxk.webserver.entity.ResultVo;
+import thyyxxk.webserver.service.bodyexam.BodyExamService;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @ClassName bodyExamController
+ * @Description 体检报告
+ * @Author hsh
+ * @Date 2022/8/12 16:53
+ **/
+@RestController
+@RequestMapping("/bodyExam")
+public class BodyExamController {
+
+    private final BodyExamService service;
+
+    @Autowired
+    public BodyExamController(BodyExamService service) {
+        this.service = service;
+    }
+
+    @PostMapping("/getTjReportData")
+    public ResultVo<List<Map>> getTjReportData(@RequestBody @Validated Map<String, String> map){
+        return service.getTjReportData(map);
+    }
+
+    @PostMapping("/getTjReportPersonalInfo")
+    public ResultVo<List<Map>> getTjReportPersonalInfo(@RequestBody @Validated Map<String, String> map){
+        return service.getTjReportPersonalInfo(map);
+    }
+
+    @PostMapping("/getTjReportTotalInfo")
+    public ResultVo<List<Map>> getTjReportTotalInfo(@RequestBody @Validated Map<String, String> map){
+        return service.getTjReportTotalInfo(map);
+    }
+
+    @PostMapping("/getTjReportResult")
+    public ResultVo<List<Map>> getTjReportResult(@RequestBody @Validated Map<String, String> map){
+        return service.getTjReportResult(map);
+    }
+
+    @PostMapping("/getTjReportModuleInfo")
+    public ResultVo<List<Map>> getTjReportModuleInfo(@RequestBody @Validated Map<String, String> map){
+        return service.getTjReportModuleInfo(map);
+    }
+
+}

+ 215 - 0
src/main/java/thyyxxk/webserver/service/bodyexam/BodyExamService.java

@@ -0,0 +1,215 @@
+package thyyxxk.webserver.service.bodyexam;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import thyyxxk.webserver.config.exception.ExceptionEnum;
+import thyyxxk.webserver.entity.ResultVo;
+import thyyxxk.webserver.service.externalhttp.PowersiTjReport;
+import thyyxxk.webserver.utils.ResultVoUtil;
+import thyyxxk.webserver.utils.StringUtil;
+
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Comparator;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+/**
+ * @ClassName BodyExamService
+ * @Description 体检数据获取
+ * @Author hsh
+ * @Date 2022/8/15 16:43
+ **/
+@Service
+public class BodyExamService {
+
+    private final PowersiTjReport report;
+
+    @Autowired
+    public BodyExamService(PowersiTjReport report) {
+        this.report = report;
+    }
+
+    public ResultVo<List<Map>> getTjReportData(Map<String, String> map){
+        String id = map.get("tjid");
+        if(StringUtil.isBlank(id)){
+            return ResultVoUtil.fail(ExceptionEnum.INVALID_PARAM, "体检id为空");
+        }
+
+        // 个人信息
+        JSONObject result1 = report.getTjReportPersonalInfo(id);
+        // 体检结果
+        JSONObject result2 = report.getTjReportResult(id);
+        // 体检汇总信息
+        JSONObject result3 = report.getTjReportTotalInfo(id);
+        // 体检模块信息
+        JSONObject result4 = report.getTjReportModuleInfo(id);
+
+        List<Map> list = new ArrayList<>();
+        JSONArray rows1 = result1.getJSONArray("rows");
+        if(rows1 != null && rows1.size()> 0){
+            List<Map> list1 = rows1.toJavaList(Map.class);
+            Map p = new HashMap<>();
+            p.put("reportHeader", list1.get(0));
+            list.add(p);
+        }
+
+        // 体检结果和体检模块信息需要汇总在一块
+        // 顺便提取所有的检验项目或者检查科室
+        List<Map> item = new ArrayList<>();
+        JSONArray rows2 = result2.getJSONArray("rows");
+        if(rows2 != null && rows2.size() > 0){
+            List<Map> list2 = rows2.toJavaList(Map.class);
+            Map<String, List<Map>> m = list2.stream().collect(Collectors.groupingBy(f -> String.valueOf(f.get("检查单元C")), Collectors.toList()));
+            for(Map.Entry<String, List<Map>> entry : m.entrySet()){
+                Map<String, List<Map>> reMap = new HashMap<>();
+                String key = entry.getKey();
+                List<Map> l = entry.getValue();
+                JSONArray rows4 = result4.getJSONArray("rows");
+                if(rows4 != null && rows4.size() > 0){
+                    List<Map> list4 = rows4.toJavaList(Map.class);
+                    for(Map m4 : list4){
+                        String d = m4.get("体检单元名称") + "";
+                        String sj = m4.get("检查日期") + "";
+                        long times = Long.valueOf(sj);
+                        Date date = new Date(times);
+                        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+                        String dateString = formatter.format(date);
+                        if(key.equals(d)){
+                            Map map1 = new HashMap();
+                            map1.put("time", dateString);
+                            map1.put("name", d);
+                            item.add(map1);
+                            l.add(m4);
+                            break;
+                        }
+                    }
+                }
+                reMap.put(key, l);
+                list.add(reMap);
+            }
+        }
+
+        if(item != null && item.size() > 0){
+            Map p1 = new HashMap<>();
+            List<Map> listItem = item.stream().sorted(Comparator.comparing(a -> String.valueOf(a.get("time")))).collect(Collectors.toList());
+            p1.put("reportItems", listItem);
+            list.add(p1);
+        }
+
+        JSONArray rows3 = result3.getJSONArray("rows");
+        if(rows3 != null && rows3.size() > 0){
+            List<Map> list3 = rows3.toJavaList(Map.class);
+            String sumStr = String.valueOf(list3.get(0).get("汇总建议"));
+            sumStr = sumStr.replace("\r\n\r\n", "<br /><br />").replace("\r\n", "<br />");
+            list3.get(0).put("汇总建议", sumStr);
+            Map p3 = new HashMap<>();
+            p3.put("reportSummary", list3.get(0));
+            list.add(p3);
+        }
+
+        return ResultVoUtil.success(list);
+    }
+
+    /**
+     *@Author hsh
+     *@Description // 获取体检个人信息
+     *@Date 2022/8/15 17:08
+     *@Param [map]
+     *@Return thyyxxk.webserver.entity.ResultVo<java.util.List<java.util.Map>>
+     **/
+    public ResultVo<List<Map>> getTjReportPersonalInfo(Map<String, String> map){
+        String id = map.get("tjid");
+        if(StringUtil.isBlank(id)){
+            return ResultVoUtil.fail(ExceptionEnum.INVALID_PARAM, "体检id为空");
+        }
+        JSONObject result = report.getTjReportPersonalInfo(id);
+
+        if(result == null || result.isEmpty()){
+            return ResultVoUtil.fail(ExceptionEnum.NO_DATA_EXIST, "没有体检数据");
+        }
+
+        JSONArray rows = result.getJSONArray("rows");
+        List<Map> list = rows.toJavaList(Map.class);
+
+        return ResultVoUtil.success(list);
+    }
+
+    /**
+     *@Author hsh
+     *@Description // 体检汇总信息
+     *@Date 2022/8/15 17:29
+     *@Param [map]
+     *@Return thyyxxk.webserver.entity.ResultVo<java.util.List<java.util.Map>>
+     **/
+    public ResultVo<List<Map>> getTjReportTotalInfo(Map<String, String> map){
+        String id = map.get("tjid");
+        if(StringUtil.isBlank(id)){
+            return ResultVoUtil.fail(ExceptionEnum.INVALID_PARAM, "体检id为空");
+        }
+        JSONObject result = report.getTjReportTotalInfo(id);
+
+        if(result == null || result.isEmpty()){
+            return ResultVoUtil.fail(ExceptionEnum.NO_DATA_EXIST, "没有体检数据");
+        }
+
+        JSONArray rows = result.getJSONArray("rows");
+        List<Map> list = rows.toJavaList(Map.class);
+
+        return ResultVoUtil.success(list);
+    }
+
+    /**
+     *@Author hsh
+     *@Description // 体检结果
+     *@Date 2022/8/16 8:54
+     *@Param [map]
+     *@Return thyyxxk.webserver.entity.ResultVo<java.util.List<java.util.Map>>
+     **/
+    public ResultVo<List<Map>> getTjReportResult(Map<String, String> map){
+        String id = map.get("tjid");
+        if(StringUtil.isBlank(id)){
+            return ResultVoUtil.fail(ExceptionEnum.INVALID_PARAM, "体检id为空");
+        }
+        JSONObject result = report.getTjReportResult(id);
+
+        if(result == null || result.isEmpty()){
+            return ResultVoUtil.fail(ExceptionEnum.NO_DATA_EXIST, "没有体检数据");
+        }
+
+        JSONArray rows = result.getJSONArray("rows");
+        List<Map> list = rows.toJavaList(Map.class);
+
+        return ResultVoUtil.success(list);
+    }
+
+    /**
+     *@Author hsh
+     *@Description // 体检模块信息
+     *@Date 2022/8/16 8:55
+     *@Param [map]
+     *@Return thyyxxk.webserver.entity.ResultVo<java.util.List<java.util.Map>>
+     **/
+    public ResultVo<List<Map>> getTjReportModuleInfo(Map<String, String> map){
+        String id = map.get("tjid");
+        if(StringUtil.isBlank(id)){
+            return ResultVoUtil.fail(ExceptionEnum.INVALID_PARAM, "体检id为空");
+        }
+        JSONObject result = report.getTjReportModuleInfo(id);
+
+        if(result == null || result.isEmpty()){
+            return ResultVoUtil.fail(ExceptionEnum.NO_DATA_EXIST, "没有体检数据");
+        }
+
+        JSONArray rows = result.getJSONArray("rows");
+        List<Map> list = rows.toJavaList(Map.class);
+
+        return ResultVoUtil.success(list);
+    }
+
+}

+ 51 - 0
src/main/java/thyyxxk/webserver/service/externalhttp/PowersiTjReport.java

@@ -0,0 +1,51 @@
+package thyyxxk.webserver.service.externalhttp;
+
+import com.alibaba.fastjson.JSONObject;
+import com.dtflys.forest.annotation.Get;
+import com.dtflys.forest.annotation.Query;
+import org.springframework.stereotype.Service;
+
+@Service
+public interface PowersiTjReport {
+
+    /**
+     *@Author hsh
+     *@Description // 体检者个人信息
+     *@Date 2022/8/15 10:40
+     *@Param [obj]
+     *@Return com.alibaba.fastjson.JSONObject
+     **/
+    @Get("http://172.16.32.183:8888/bdp/dataservice/api/e33647d980f74dcfb079baad503670a4?tjid=${id}")
+    JSONObject getTjReportPersonalInfo(@Query("id") String id);
+
+    /**
+     *@Author hsh
+     *@Description // 体检汇总信息
+     *@Date 2022/8/15 10:42
+     *@Param [obj]
+     *@Return com.alibaba.fastjson.JSONObject
+     **/
+    @Get("http://172.16.32.183:8888/bdp/dataservice/api/7033a7386d0e45d295b7a13dd079704e?tjid=${id}")
+    JSONObject getTjReportTotalInfo(@Query("id") String id);
+
+    /**
+     *@Author hsh
+     *@Description // 体检结果
+     *@Date 2022/8/15 10:46
+     *@Param [obj]
+     *@Return com.alibaba.fastjson.JSONObject
+     **/
+    @Get("http://172.16.32.183:8888/bdp/dataservice/api/92eef45c69974df4869b3eed05f5234f?tjid=${id}")
+    JSONObject getTjReportResult(@Query("id") String id);
+
+    /**
+     *@Author hsh
+     *@Description // 体检模块信息
+     *@Date 2022/8/15 10:43
+     *@Param [obj]
+     *@Return com.alibaba.fastjson.JSONObject
+     **/
+    @Get("http://172.16.32.183:8888/bdp/dataservice/api/f9c6ad55fa1b43b8a6f9e44cc7e126b9?tjid=${id}")
+    JSONObject getTjReportModuleInfo(@Query("id") String id);
+
+}