//package com.ynxbd.common.helper.his; // //import com.alibaba.fastjson.JSON; //import com.alibaba.fastjson.JSONArray; //import com.alibaba.fastjson.JSONObject; //import com.alibaba.fastjson.TypeReference; //import com.ynxbd.common.helper.common.ErrorHelper; //import org.dom4j.Attribute; //import org.dom4j.Element; //import org.slf4j.Logger; //import org.slf4j.LoggerFactory; // //import java.math.BigDecimal; //import java.util.List; //import java.util.Map; // ///** // * HIS响应数据 // * // * @Author wsq // * @Date 2020/7/29 13:26 // * @Copyright @ 2020 云南新八达科技有限公司 All rights reserved. // */ // //public class HisResult { // private final static Logger log = LoggerFactory.getLogger(HisResult.class); // // // 响应状态码 // private Integer responseCode; // // 响应信息 // private String responseMessage; // // HIS响应码 // private String transactionCode; // // 数据 // private Map dataMap; // // // /** // * 创建一个异常信息 // * // * @param message 异常信息 // * @return 模拟his异常信息 // */ // public static HisResult createErrorHisResult(String message) { // HisResult hisResult = new HisResult(); // hisResult.setResponseCode(500); // // hisResult.setResponseMessage(message); // return hisResult; // } // // // /** // * 获取DataMap的值 String // * // * @param nodeName 节点名称 // * @return nodeVal 节点值 // */ // public String getDataMapString(String nodeName) { // try { // Object val = this.dataMap.get(nodeName); // if (val == null) { // return null; // } // String v = val.toString().trim(); // return "".equals(v) ? null : v; // } catch (Exception e) { // ErrorHelper.println(e); // return null; // } // } // // /** // * 获取DataMap的值 BigDecimal // * // * @param nodeName 节点名称 // * @return nodeVal 节点值 // */ // public BigDecimal getDataMapBigDecimal(String nodeName) { // try { // Object val = this.dataMap.get(nodeName); // return val == null ? null : new BigDecimal(val.toString()); // } catch (Exception e) { // ErrorHelper.println(e); // return null; // } // } // // /** // * 获取DataMap的值 Integer // * // * @param nodeName 节点名称 // * @return nodeVal 节点值 // */ // public Integer getDataMapInteger(String nodeName) { // try { // Object val = this.dataMap.get(nodeName); // return val == null ? null : Integer.parseInt(val.toString()); // } catch (Exception e) { // ErrorHelper.println(e); // return null; // } // } // // /** // * 获取DataMap的值 Boolean // * // * @param nodeName 节点名称 // * @return nodeVal 节点值 // */ // public Boolean getDataMapBoolean(String nodeName) { // try { // Object val = this.dataMap.get(nodeName); // return val == null ? null : Boolean.parseBoolean(val.toString()); // } catch (Exception e) { // ErrorHelper.println(e); // return null; // } // } // // // /** // * 获取DataMap的值 Long // * // * @param nodeName 节点名称 // * @return nodeVal 节点值 // */ // public Long getDataMapLong(String nodeName) { // try { // Object val = this.dataMap.get(nodeName); // return val == null ? null : Long.parseLong(val.toString()); // } catch (Exception e) { // ErrorHelper.println(e); // return null; // } // } // // // /** // * 获取DataMap的值 Double // * // * @param nodeName 节点名称 // * @return nodeVal 节点值 // */ // public Double getDataMapDouble(String nodeName) { // try { // Object val = this.dataMap.get(nodeName); // return val == null ? null : Double.parseDouble(val.toString()); // } catch (Exception e) { // ErrorHelper.println(e); // return null; // } // } // // // /** // * 获取根节点包含相同节点数据 // * 如: // * // * # 1 // * # 2 // * // * // * @param clazz 类型 // * @param rootNode 根节点名 // * @param nodes 子节点名,可变长参数 // * @return 集合 // */ // public List getDataMapList(Class clazz, String rootNode, String... nodes) { // JSONArray jsonArray = getJsonArray(rootNode, nodes); // return decodeList(jsonArray.toString(), clazz); // } // // // /** // * 获取嵌套多层的JSONArray // * // * @param rooNode 根节点 // * @param nodes 子节点,可变长参数 // * @return json数组 // */ // public JSONArray getJsonArray(String rooNode, String... nodes) { // Object rootObj = this.dataMap.get(rooNode); // String result = rootObj == null ? JSON.toJSONString(new JSONArray()) : rootObj.toString(); // try { // JSONArray jsonArray; // JSONObject jsonObject; // for (String node : nodes) { // jsonArray = JSONArray.parseArray(result); // if (jsonArray == null || jsonArray.size() == 0) { // return new JSONArray(); // } // if (jsonArray.size() == 1) { // 如果只有一个值继续处理 // jsonObject = jsonArray.getJSONObject(0); // result = JSON.toJSONString(jsonObject.getJSONArray(node)); // } else { // 如果有多个值返回当前数组 // result = JSON.toJSONString(jsonArray); // } // } // } catch (Exception e) { // log.error("JSON数据转换失败"); // ErrorHelper.println(e); // } // return JSONArray.parseArray(result); // } // // // /** // * JSON树形结构数据向下JSONArray中传递 // * // * @param jsonArray 根节点 // * @param properties 节点属性,可变长参数 // * @return JSONArray // */ // public List jsonParentToChild(Class clazz, JSONArray jsonArray, String rootNode, String... properties) { // JSONArray result = new JSONArray(); // JSONObject jsonObject, childNode; // JSONArray nodeJsonArr; // for (int i = 0; i < jsonArray.size(); i++) { // jsonObject = jsonArray.getJSONObject(i); // nodeJsonArr = jsonObject.getJSONArray(rootNode); // for (int j = 0; j < nodeJsonArr.size(); j++) { // childNode = nodeJsonArr.getJSONObject(j); // for (String property : properties) { // for (String key : jsonObject.keySet()) { // 忽略大小写 // if (key.toLowerCase().equals(property.toLowerCase())) { // property = key; // break; // } // } // String propertyVal = jsonObject.getString(property); // childNode.put(property, propertyVal); // } // result.add(childNode); // } // } // return decodeList(JSON.toJSONString(result), clazz); // } // // // /** // * 获取DataMap为bean // * // * @param clazz 类型 // * @return bean // */ // public T getDataMapBean(Class clazz) { // return decodeBean(JSONObject.toJSONString(this.dataMap), clazz); // } // // /** // * 获取DataMap为bean // * // * @param clazz 类型 // * @return bean // */ // public T getDataMapBean(Class clazz, String rooNode, String... nodes) { // JSONObject jsonObject = getJsonObject(rooNode, nodes); // if (jsonObject == null) { // jsonObject = new JSONObject(); // } // return decodeBean(jsonObject.toJSONString(), clazz); // } // //// /** //// * 获取DataMap为bean //// * //// * @param rooNode 根节点 //// * @param nodes 子节点 //// * @return bean //// */ //// public JSONObject getDataMapObject(String rooNode, String... nodes) { //// JSONObject jsonObject = getJsonObject(rooNode, nodes); //// if (jsonObject == null) { //// jsonObject = new JSONObject(); //// } //// return decodeBean(jsonObject.toJSONString()); //// } // // // /** // * 获取嵌套多层的JSONArray // * // * @param rooNode 根节点 // * @param nodes 子节点,可变长参数 // * @return json对象 // */ // public JSONObject getJsonObject(String rooNode, String... nodes) { // Object rootObj = this.dataMap.get(rooNode); // String result = rootObj == null ? new JSONObject().toJSONString() : rootObj.toString(); // try { // JSONArray jsonArray = JSONArray.parseArray(result); // if (jsonArray == null || jsonArray.size() == 0) { // return new JSONObject(); // } // // JSONObject jsonObject = jsonArray.getJSONObject(0); // if (jsonObject == null) { // return new JSONObject(); // } // // if (nodes.length == 0) { // result = jsonObject.toJSONString(); // } // // for (String node : nodes) { // result = jsonObject.getJSONObject(node).toJSONString(); // } // } catch (Exception e) { // log.error("JSON数据转换失败"); // ErrorHelper.println(e); // } // return JSONObject.parseObject(result); // } // // // // --------------------------------------------------------------- // // /** // * fastJson反序列化Bean // * // * @param json json // * @param clazz 类型 // * @return bean // */ // public static T decodeBean(String json, Class clazz) { // return JSON.parseObject(json, clazz); // } // // /** // * fastJson反序列化List // * // * @param json json // * @param clazz 类型 // * @return List // */ // public static List decodeList(String json, Class clazz) { // return decode(json, new TypeReference>(clazz) { // }); // } // // // /** // * fastJson反序列化 // * // * @param json json // * @param typeReference 类型 // * @return 反序列化后的值 // */ // public static T decode(String json, TypeReference typeReference) { // try { // return JSON.parseObject(json, typeReference); // } catch (Exception e) { // e.printStackTrace(); // } // return null; // } // // // /** // * 递归-Element转JSONObject // * // * @param rootNode 根节点 // * @return JSONObject // */ // public static JSONObject nodeToJsonObject(Element rootNode) { // JSONObject result = new JSONObject(); // // 当前节点的名称、文本内容和属性 // for (Attribute attr : rootNode.attributes()) {// 遍历当前节点的所有属性 // result.put(attr.getName(), attr.getValue()); // } // // // 递归遍历当前节点所有的子节点 // List listElement = rootNode.elements();// 所有一级子节点的list // if (!listElement.isEmpty()) { // String name, val; // // for (Element e : listElement) {// 遍历所有一级子节点 // name = e.getName(); // val = e.getTextTrim(); // if (e.attributes().isEmpty() && e.elements().isEmpty()) // 判断一级节点是否有属性和子节点 // result.put(name, val.equals("") ? null : val); // 沒有则将当前节点作为上级节点的属性对待 // else { // if (!result.containsKey(e.getName())) { // 判断父节点是否存在该一级节点名称的属性 // result.put(name, new JSONArray());// 没有则创建 // } // JSONArray jsonArray = (JSONArray) result.get(name); // jsonArray.add(nodeToJsonObject(e)); // 将该一级节点放入该节点名称的属性对应的值中 // } // } // } // return result; // } // // //// public static void main(String[] args) { //// String testXml = "20010成功0201急诊科全科医疗
门诊楼
0202院办全科医疗
0203重症医学科全科医疗
0205急诊科(二楼)全科医疗
门诊二楼
0206血液透析室全科医疗
住院部一楼
0207120急救中心全科医疗
0301内二科内科
门诊三楼内科专家(五
0304门诊部(二楼)内科
门诊二楼
0305门诊部(三楼)内科
门诊三楼
0306消化内科内科
门诊三楼内科专家(六
0307心内科内科
住院部五楼医生办公室
0308呼吸科内科
门诊三楼内科专家(六
0309精神心理科内科
门诊三楼内科专家(七
0310内分泌科内科
门诊三楼内科专家(七
0311内一科内科
门诊三楼内科专家(一
0312肾内科内科
门诊三楼内科专家(六
0313神经内科内科
住院部四楼医生办公室
0401外科外科
0402外一科外科
住院部二楼
0403外二科外科
医技综合楼七楼
0404外三科外科
住院部三楼
0406外(皮肤)科门诊外科
门诊二楼
0501妇产科妇产科
门诊二楼
0712儿科儿科
门诊三楼
1100耳鼻咽喉科耳鼻咽喉科
医技综合楼五楼
1101五官科耳鼻咽喉科
医技综合楼五楼
1201口腔科口腔科
门诊三楼
1300皮肤科皮肤科
外科专家诊室
1601抗病毒治疗室传染科
1607感染性疾病科传染科
2100中医康复科康复医学科
2101疼痛科门诊康复医学科
门诊三楼
3205功能科医学影象科
5001中医科中医科
5002中医肛肠科门诊中医科
门诊三楼
5201针灸科中西医结合
"; //// // 对象封装 //// WsResult wsResult = WsResult.xmlToBean(testXml); //// System.out.println(wsResult); //// List dept = wsResult.getDataMapList("Dept", DeptBean.class); //// //// for (DeptBean d : dept) { //// System.out.println(d); //// } //// } // // public HisResult() { // } // // public HisResult(Integer responseCode, String responseMessage, String transactionCode, Map dataMap) { // this.responseCode = responseCode; // this.responseMessage = responseMessage; // this.transactionCode = transactionCode; // this.dataMap = dataMap; // } // // public Integer getResponseCode() { // return responseCode; // } // // public void setResponseCode(Integer responseCode) { // this.responseCode = responseCode; // } // // public String getResponseMessage() { // return responseMessage; // } // // public void setResponseMessage(String responseMessage) { // this.responseMessage = responseMessage; // } // // public String getTransactionCode() { // return transactionCode; // } // // public void setTransactionCode(String transactionCode) { // this.transactionCode = transactionCode; // } // // public Map getDataMap() { // return dataMap; // } // // public void setDataMap(Map dataMap) { // this.dataMap = dataMap; // } // // @Override // public String toString() { // return "WsResult{" + // "responseCode=" + responseCode + // ", responseMessage='" + responseMessage + '\'' + // ", transactionCode='" + transactionCode + '\'' + // ", dataMap=" + dataMap + // '}'; // } //} //