| | |
| | | |
| | | // @Transactional |
| | | public AjaxResult getHISDataNew(String type, Map<String, Object> params){ |
| | | LambdaQueryWrapper<HisApiConfig> lambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | lambdaQueryWrapper.eq(HisApiConfig::getApiMethod, type); |
| | | HisApiConfig hisApiConfig = hisApiConfigService.getOne(lambdaQueryWrapper); |
| | | String responseJson = HttpClientUtils.sendPost(HIS_URL + hisApiConfig.getApiUrl(), params); |
| | | Integer isResponse = hisApiConfig.getIsResponse(); |
| | | JSONObject response = null; |
| | | if (isResponse == 1) { |
| | | response = JSONUtil.parseObj(responseJson).getJSONObject("Response"); |
| | | } else{ |
| | | response = JSONUtil.parseObj(responseJson); |
| | | } |
| | | if (response.getStr(hisApiConfig.getResultCodeKey()).equals("0")) { |
| | | AjaxResult ajaxResult = AjaxResult.success(); |
| | | JSONArray resultData = response.getJSONArray(hisApiConfig.getResultDataKey()); |
| | | List<Map<String, String>> list = new ArrayList<>(); |
| | | for (Object resultDatum : resultData) { |
| | | JSONObject object = (JSONObject) resultDatum; |
| | | ajaxResult = save(object, type,hisApiConfig,JSONUtil.toJsonStr(params)); |
| | | Map<String, String> map = new HashMap<>(); |
| | | for (String key : object.keySet()) { |
| | | String defaultVal = object.get(key).toString(); |
| | | String val = defaultVal.trim().replaceAll("\\s+", ""); |
| | | map.put(key, val); |
| | | } |
| | | list.add(map); |
| | | try { |
| | | LambdaQueryWrapper<HisApiConfig> lambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | lambdaQueryWrapper.eq(HisApiConfig::getApiMethod, type); |
| | | HisApiConfig hisApiConfig = hisApiConfigService.getOne(lambdaQueryWrapper); |
| | | String responseJson = HttpClientUtils.sendPost(HIS_URL + hisApiConfig.getApiUrl(), params); |
| | | Integer isResponse = hisApiConfig.getIsResponse(); |
| | | JSONObject response = null; |
| | | if (isResponse == 1) { |
| | | response = JSONUtil.parseObj(responseJson).getJSONObject("Response"); |
| | | } else{ |
| | | response = JSONUtil.parseObj(responseJson); |
| | | } |
| | | ajaxResult.put("data", list); |
| | | return ajaxResult; |
| | | } else { |
| | | return AjaxResult.error().put("result", JSONUtil.parseObj(responseJson)); |
| | | if (response.getStr(hisApiConfig.getResultCodeKey()).equals("0")) { |
| | | AjaxResult ajaxResult = AjaxResult.success(); |
| | | JSONArray resultData = response.getJSONArray(hisApiConfig.getResultDataKey()); |
| | | List<Map<String, String>> list = new ArrayList<>(); |
| | | for (Object resultDatum : resultData) { |
| | | JSONObject object = (JSONObject) resultDatum; |
| | | ajaxResult = save(object, type,hisApiConfig,JSONUtil.toJsonStr(params)); |
| | | Map<String, String> map = new HashMap<>(); |
| | | for (String key : object.keySet()) { |
| | | String defaultVal = object.get(key).toString(); |
| | | String val = defaultVal.trim().replaceAll("\\s+", ""); |
| | | map.put(key, val); |
| | | } |
| | | list.add(map); |
| | | } |
| | | ajaxResult.put("data", list); |
| | | return ajaxResult; |
| | | } else { |
| | | return AjaxResult.error().put("result", JSONUtil.parseObj(responseJson)); |
| | | } |
| | | } catch (Exception e) { |
| | | // throw new RuntimeException(e); |
| | | log.error(String.valueOf(e)); |
| | | return AjaxResult.error(); |
| | | } |
| | | } |
| | | |
| | |
| | | * @throws SQLException |
| | | */ |
| | | @Transactional |
| | | private void insertDataNew(Connection connection, JSONObject jsonObject,Object hisApiConfig,String paramsJson,String code) throws SQLException { |
| | | public void insertDataNew(Connection connection, JSONObject jsonObject, Object hisApiConfig, String paramsJson, String code) throws SQLException { |
| | | String tabName = ""; |
| | | List<String> primaryKesList; |
| | | if (code.equals("lis") || code.equals("pacs")) { |