| | |
| | | import cn.hutool.json.JSONArray; |
| | | import cn.hutool.json.JSONObject; |
| | | import cn.hutool.json.JSONUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.ltkj.common.core.domain.AjaxResult; |
| | | import com.ltkj.hosp.domain.HisApiConfig; |
| | | import com.ltkj.hosp.service.HisApiConfigService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.io.FileInputStream; |
| | | import java.io.IOException; |
| | |
| | | private static final String CONFIG_PATH = "/Users/chacca/开发相关/代码/ltkj_peis/ltkj-admin/src/main/resources/config.properties"; |
| | | // 数据库名 |
| | | private static String DB_NAME = ""; |
| | | private static String HIS_URL = ""; |
| | | @Autowired |
| | | private HisApiMethodService controller; |
| | | @Autowired |
| | | private HisApiConfigService hisApiConfigService; |
| | | |
| | | static { |
| | | try { |
| | | Class.forName("com.mysql.cj.jdbc.Driver"); |
| | | } catch (ClassNotFoundException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | try { |
| | | FileInputStream inputStream = new FileInputStream(CONFIG_PATH); |
| | | Properties props = new Properties(); |
| | | props.load(inputStream); |
| | | String url = props.getProperty("his_api_url"); |
| | | String port = props.getProperty("his_api_port"); |
| | | HIS_URL=url+":"+port+"/api/His/"; |
| | | } catch (IOException throwables) { |
| | | throwables.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | |
| | | * @param params 请求参数 |
| | | * @return |
| | | */ |
| | | @Transactional |
| | | public AjaxResult getHISData(String type, Map<String, Object> params) { |
| | | // Getoutaccountrecord 获取门诊结算记录 |
| | | // Getoutpatientcostinfo 获取门诊患者费用清单信息 |
| | | // Getlaburgentinfo 获取危急值信息 |
| | | // Getlabgermdetailinfo 获取微生物药敏信息 |
| | | // Getlabgermrepinfo 获取微生物报告记录信息 |
| | | // Getlabreportinfo 获取检验报告记录信息 |
| | | // Getlabapplyinfo 获取检验申请信息 |
| | | // Getexamurgentinfo 获取检查危急值信息 |
| | | // Getexamreportinfo 获取检查报告信息 |
| | | // Getexamapplyinfo 获取检查申请信息 |
| | | // LambdaQueryWrapper<HisApiConfig> lambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | // lambdaQueryWrapper.eq(HisApiConfig::getApiMethod, type); |
| | | // HisApiConfig hisApiConfig = hisApiConfigService.getOne(lambdaQueryWrapper); |
| | | |
| | | AjaxResult result = null; |
| | | // TODO 创建表 弄成数据库动态获取 接口地址、代码、是否分页 |
| | | // TODO 创建表 弄成数据库动态获取 接口地址、代码、是否分页、主键id、主键字段 |
| | | // TODO 从2.4.2获取到数据 根据his_registration_id删除旧数据在插入新数据 下层业务均一样根据返回的JYBGID删除旧数据在插入新数据 |
| | | switch (type) { |
| | | case "Getoutaccountrecord": |
| | | result = controller.Getoutaccountrecord(params); |
| | | result.put("limit", true); |
| | | // result.put("limit", true); |
| | | break; |
| | | case "Getoutpatientcostinfo": |
| | | result = controller.Getoutpatientcostinfo(params); |
| | | result.put("limit", true); |
| | | // result.put("limit", true); |
| | | break; |
| | | case "Getlaburgentinfo": |
| | | result = controller.Getlaburgentinfo(params); |
| | | result.put("limit", false); |
| | | // result.put("limit", false); |
| | | break; |
| | | case "Getlabgermdetailinfo": |
| | | result = controller.Getlabgermdetailinfo(params); |
| | | result.put("limit", false); |
| | | // result.put("limit", false); |
| | | break; |
| | | case "Getlabgermrepinfo": |
| | | result = controller.Getlabgermrepinfo(params); |
| | | result.put("limit", false); |
| | | // result.put("limit", false); |
| | | break; |
| | | case "Getlabreportinfo": |
| | | result = controller.Getlabreportinfo(params); |
| | | result.put("limit", true); |
| | | // result.put("limit", true); |
| | | break; |
| | | case "Getlabapplyinfo": |
| | | result = controller.Getlabapplyinfo(params); |
| | | result.put("limit", false); |
| | | // result.put("limit", false); |
| | | break; |
| | | case "Getexamurgentinfo": |
| | | result = controller.Getexamurgentinfo(params); |
| | | result.put("limit", true); |
| | | // result.put("limit", true); |
| | | break; |
| | | case "Getexamreportinfo": |
| | | result = controller.Getexamreportinfo(params); |
| | | result.put("limit", true); |
| | | // result.put("limit", true); |
| | | break; |
| | | case "Getexamapplyinfo": |
| | | result = controller.Getexamapplyinfo(params); |
| | | result.put("limit", false); |
| | | // result.put("limit", false); |
| | | break; |
| | | case "Getlabdetailinfo": |
| | | result = controller.Getlabdetailinfo(params); |
| | | result.put("limit", false); |
| | | // result.put("limit", false); |
| | | break; |
| | | } |
| | | String json = result.get("data").toString(); |
| | | JSONObject response = JSONUtil.parseObj(json).getJSONObject("Response"); |
| | | if (response.getStr("ResultCode").toString().equals("0")) { |
| | | AjaxResult ajaxResult = AjaxResult.success(); |
| | | if ((boolean) result.get("limit")) { |
| | | ajaxResult = saveArray(json, type); |
| | | // if ((boolean) result.get("limit")) { |
| | | // ajaxResult = saveArray(json, type); |
| | | JSONArray resultData = response.getJSONArray("ResultData"); |
| | | List<Map<String, String>> list = new ArrayList<>(); |
| | | for (Object resultDatum : resultData) { |
| | | JSONObject object = (JSONObject) resultDatum; |
| | | ajaxResult = save(object, type); |
| | | Map<String, String> map = new HashMap<>(); |
| | | for (String key : object.keySet()) { |
| | | String defaultVal = object.get(key).toString(); |
| | |
| | | list.add(map); |
| | | } |
| | | ajaxResult.put("data", list); |
| | | } else { |
| | | // 以集合返回 |
| | | JSONArray resultData = response.getJSONArray("ResultData"); |
| | | List<JSONObject> list = JSONUtil.toList(resultData, JSONObject.class); |
| | | ArrayList<Map<String, String>> maps = new ArrayList<>(); |
| | | for (JSONObject data : list) { |
| | | ajaxResult = save(data, type); |
| | | HashMap<String, String> map1 = new HashMap<>(); |
| | | for (String key : data.keySet()) { |
| | | String defaultVal = data.get(key).toString(); |
| | | String val = defaultVal.trim().replaceAll("\\s+", ""); |
| | | map1.put(key, val); |
| | | } |
| | | maps.add(map1); |
| | | } |
| | | ajaxResult.put("data", maps); |
| | | } |
| | | // } else { |
| | | // // 以集合返回 |
| | | // JSONArray resultData = response.getJSONArray("ResultData"); |
| | | // List<JSONObject> list = JSONUtil.toList(resultData, JSONObject.class); |
| | | // ArrayList<Map<String, String>> maps = new ArrayList<>(); |
| | | // for (JSONObject data : list) { |
| | | // ajaxResult = save(data, type); |
| | | // HashMap<String, String> map1 = new HashMap<>(); |
| | | // for (String key : data.keySet()) { |
| | | // String defaultVal = data.get(key).toString(); |
| | | // String val = defaultVal.trim().replaceAll("\\s+", ""); |
| | | // map1.put(key, val); |
| | | // } |
| | | // maps.add(map1); |
| | | // } |
| | | // ajaxResult.put("data", maps); |
| | | // } |
| | | return ajaxResult; |
| | | } else { |
| | | return AjaxResult.error().put("result", JSONUtil.parseObj(json)); |