| | |
| | | try { |
| | | Class.forName("com.mysql.cj.jdbc.Driver"); |
| | | } catch (ClassNotFoundException e) { |
| | | e.printStackTrace(); |
| | | log.error(String.valueOf(e),e.getMessage()); |
| | | } |
| | | // try { |
| | | // InputStreamReader reader = new InputStreamReader(new FileInputStream(url), StandardCharsets.UTF_8); |
| | |
| | | |
| | | // @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)); |
| | | // 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),e.getMessage()); |
| | | return AjaxResult.error(); |
| | | } |
| | | } |
| | | |
| | |
| | | try { |
| | | creatTable(object, tabName, connection); |
| | | } catch (SQLException e) { |
| | | e.printStackTrace(); |
| | | return AjaxResult.error(); |
| | | log.error(String.valueOf(e),e.getMessage()); |
| | | // return AjaxResult.error(); |
| | | } |
| | | } |
| | | //插入数据 |
| | | try { |
| | | operationTable(object,connection,hisApiConfig,paramsJson,code); |
| | | } catch (SQLException e) { |
| | | e.printStackTrace(); |
| | | return AjaxResult.error(); |
| | | log.error(String.valueOf(e),e.getMessage()); |
| | | // return AjaxResult.error(); |
| | | }finally { |
| | | try { |
| | | connection.close(); |
| | |
| | | * @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")) { |
| | |
| | | String key = entry.getKey().trim().toLowerCase(); |
| | | if (StrUtil.isBlank(defaultVal) || defaultVal.equals("null")) |
| | | continue; |
| | | String val = defaultVal.trim().replaceAll("\\s+", ""); |
| | | String val = defaultVal.trim().replaceAll("\\s+", "").replaceAll("[^\\x00-\\x7F]", ""); |
| | | if (primaryKesList.contains(key)) { |
| | | deleteSqlBuilder.append(key).append(" = '").append(val).append("' and "); |
| | | } |
| | |
| | | statement.close(); |
| | | return next; |
| | | } catch (SQLException throwables) { |
| | | throwables.printStackTrace(); |
| | | log.error(String.valueOf(throwables),throwables.getMessage()); |
| | | } |
| | | log.error("查询表执行sql返回为null ->{},{},{}",tabSql,DB_NAME,tableName); |
| | | return null; |
| | | } |
| | | |