Jelajahi Sumber

Merge branch 'dev' of demon/patient-co-management into dev

zlf 8 tahun lalu
induk
melakukan
ef9d21933c

+ 5 - 1
patient-co-wlyy/pom.xml

@ -243,6 +243,11 @@
            <artifactId>jackson-databind</artifactId>
            <version>${jackson.version}</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.dataformat</groupId>
            <artifactId>jackson-dataformat-xml</artifactId>
            <version>${jackson.version}</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.module</groupId>
            <artifactId>jackson-module-jaxb-annotations</artifactId>
@ -266,7 +271,6 @@
            <version>1.1</version>
        </dependency>
        <!-- LOGGING begin -->
        <dependency>
            <groupId>org.slf4j</groupId>

+ 8 - 8
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/record/HealthDataService.java

@ -3,10 +3,10 @@ package com.yihu.wlyy.service.app.record;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.util.HttpClientUtil;
import com.yihu.wlyy.util.SystemConf;
import com.yihu.wlyy.util.XMLUtil;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.stereotype.Service;
@ -22,7 +22,7 @@ public class HealthDataService extends BaseService {
    /**
     * 获取健康档案信息
     */
    public String getHealthData(String strSSID, String strEvent, String strCatalog, String strSerial) throws Exception {
    public JSONObject getHealthData(String strSSID, String strEvent, String strCatalog, String strSerial) throws Exception {
        String url = SystemConf.getInstance().getSystemProperties().getProperty("sign_check_upload");
        url = url + "/third/smjk/HealthData";
@ -33,20 +33,20 @@ public class HealthDataService extends BaseService {
        params.add(new BasicNameValuePair("strSerial", strSerial));
        String response = HttpClientUtil.post(url, params, "UTF-8");
        JSONArray result = new JSONArray();
        JSONObject result = new JSONObject();
        if (!StringUtils.isEmpty(response)){
            JSONObject jsonObject = new JSONObject(response);
            int status = jsonObject.getInt("status");
            if (status == 200){
                String data = jsonObject.getString("data");
                if (!StringUtils.isEmpty(data)){
                    JSONObject jsonData = new JSONObject(data);
                    result = jsonData.getJSONArray("EhrList");
                String xmlData = jsonObject.getString("data");
                if (!StringUtils.isEmpty(xmlData)){
                    String xmlJson = XMLUtil.xml2JSON(xmlData);
                    result = new JSONObject(xmlJson);
                }
            }
        }
        return result.toString();
        return result;
    }
}

File diff ditekan karena terlalu besar
+ 21 - 24
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/record/InspectionService.java


+ 32 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/util/XMLUtil.java

@ -1,6 +1,11 @@
package com.yihu.wlyy.util;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
import net.sf.json.JSON;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import net.sf.json.xml.XMLSerializer;
@ -278,10 +283,36 @@ public class XMLUtil {
        if (StringUtils.isEmpty(xml)) {
            return "";
        } else {
            return new XMLSerializer().read(xml).toString();
            xml = xml.replace("\r","").replace("\n","").replace("\t","").replace("\f", "");
            XMLSerializer xmlSerializer = new XMLSerializer();
            xmlSerializer.setTrimSpaces(false);
            xmlSerializer.setSkipNamespaces(false);
            JSON read = xmlSerializer.read(xml);
            return read.toString();
        }
    }
    public static String xml2json(String xml){
        StringWriter w = new StringWriter();
        ObjectMapper objectMapper = new ObjectMapper();
        XmlMapper xmlMapper = new XmlMapper();
        JsonParser jp;
        try {
            jp = xmlMapper.getFactory().createParser(xml);
            JsonGenerator jg = objectMapper.getFactory().createGenerator(w);
            while (jp.nextToken() != null) {
                jg.copyCurrentEvent(jp);
            }
            jp.close();
            jg.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return w.toString();
    }
    public static String json2XML(String json) {
        if (StringUtils.isEmpty(json)) {
            return "";

+ 2 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/record/HealthDataController.java

@ -5,6 +5,7 @@ import com.yihu.wlyy.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
@ -41,7 +42,7 @@ public class HealthDataController extends BaseController {
                                @ApiParam(name="strSerial",value="该类别顺序号,默认填1",defaultValue = "1")
                                @RequestParam(value="strSerial",required = true) String strSerial) {
        try {
            String data = healthDataService.getHealthData(strSSID, strEvent, strCatalog, strSerial);
            JSONObject data = healthDataService.getHealthData(strSSID, strEvent, strCatalog, strSerial);
            return write(200, "获取健康档案信息成功!", "data", data);
        } catch (Exception e) {