浏览代码

采集注册上传逻辑归并调试

lingfeng 9 年之前
父节点
当前提交
ab8125fbe3

+ 38 - 0
Hos-Framework/src/main/java/com/yihu/ehr/framework/util/compress/Zipper.java

@ -133,6 +133,44 @@ public class Zipper {
        return null;
    }
    public File zipFileForAll(File unzipFile, String zipFileName, String pwd) throws ZipException {
        //文件不存在时不压缩
        if (!unzipFile.exists()) {
            return null;
        }
        ZipParameters parameters = new ZipParameters();
        parameters.setCompressionMethod(Zip4jConstants.COMP_DEFLATE);
        parameters.setCompressionLevel(Zip4jConstants.DEFLATE_LEVEL_NORMAL);
        if (!StringUtil.isEmpty(pwd)) {
            parameters.setEncryptFiles(true);
            parameters.setEncryptionMethod(Zip4jConstants.ENC_METHOD_STANDARD);
            parameters.setPassword(pwd.toCharArray());
        }
        File file = new File(zipFileName);
        if (!file.exists()) {
            file.getParentFile().mkdirs();
        }
        ZipFile zipFile = new ZipFile(zipFileName);
        if (unzipFile.isDirectory()) {
//            zipFile.addFolder(unzipFile, parameters);
            File[] files = unzipFile.listFiles();
            for (int i = 0; i < files.length; i++) {
                if (files[i].isDirectory()) {
                    zipFile.addFolder(files[i], parameters);
                } else {
                    zipFile.addFile(files[i], parameters);
                }
            }
        } else {
            zipFile.addFile(unzipFile, parameters);
        }
        return new File(zipFileName);
    }
    /**
     * @param zipFile        需要解压的文件名
     * @param unzipDirectory 解压文件路径

+ 15 - 0
Hos-Framework/src/main/java/com/yihu/ehr/framework/util/file/FileUtil.java

@ -13,6 +13,21 @@ import java.io.*;
public class FileUtil {
    public static boolean writeFile(String filePath, String data, String encoding) throws IOException {
        File file = new File(filePath);
        if (!file.getParentFile().exists()) {
            if (!file.getParentFile().mkdirs()) {
                return false;
            }
        }
        FileOutputStream fileOutputStream = new FileOutputStream(file);
        OutputStreamWriter outputStreamWriter = new OutputStreamWriter(fileOutputStream, encoding);
        outputStreamWriter.write(data);
        outputStreamWriter.flush();
        outputStreamWriter.close();
        return true;
    }
    public static boolean writeFileDecode(String filePath, String data, String encoding) throws IOException {
        File file = new File(filePath);
//        if (file.exists()) {
//            return false;
//        }

+ 1 - 1
Hos-Framework/src/main/java/com/yihu/ehr/framework/util/httpclient/HttpClientUtil.java

@ -189,7 +189,7 @@ public class HttpClientUtil {
        } catch (Exception e) {
            re.setStatusCode(201);
            re.setBody(e.getMessage());
            e.printStackTrace();
            System.out.print(e.getMessage());
        } finally {
            close(httpClient, response);
        }

+ 1 - 2
Hos-Framework/src/main/java/com/yihu/ehr/framework/util/httpclient/HttpHelper.java

@ -41,7 +41,6 @@ public class HttpHelper {
            httpGateway = props.getProperty("httpGateway");
            String sslKeystore = props.getProperty("sslKeystore");
            String sslPassword = props.getProperty("sslPassword");
            if(sslKeystore!=null && sslKeystore.length()>0 && sslPassword!=null &&sslPassword.length()>0)
            {
                SSLContext sslContext = SSLContexts.custom()
@ -52,7 +51,7 @@ public class HttpHelper {
                        sslContext,
                        new String[]{"TLSv1"},
                        null,
                        null);
                        SSLConnectionSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
            }
        }

+ 1 - 1
Hos-resource/src/main/java/com/yihu/ehr/crawler/controller/CrawlerController.java

@ -22,7 +22,7 @@ import javax.annotation.Resource;
@Api(protocols = "http", value = "CrawlerController", description = "档案采集接口", tags = {"采集"})
public class CrawlerController {
    @RequestMapping(value = "patient", method = RequestMethod.GET)
    @RequestMapping(value = "patient", method = RequestMethod.POST)
    @ApiOperation(value = "采集病人健康档案", produces = "application/json", notes = "采集病人健康档案")
    public Boolean crawler(
            @ApiParam(name = "patient", value = "病人索引信息", required = true)

+ 9 - 0
Hos-resource/src/main/java/com/yihu/ehr/crawler/model/config/SysConfig.java

@ -2,6 +2,7 @@ package com.yihu.ehr.crawler.model.config;
import com.yihu.ehr.crawler.model.patient.PatientIdentity;
import com.yihu.ehr.framework.util.log.LogService;
import com.yihu.ehr.framework.util.operator.StringUtil;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.Element;
@ -112,6 +113,14 @@ public class SysConfig {
    }
    private void initCrawler(Element rootElement) {
        String tempFile = rootElement.elementTextTrim("temp_file");
        if (!StringUtil.isEmpty(tempFile)) {
            this.tempFile = tempFile;
        } else {
            String home = System.getProperty("catalina.home").replace('\\','/');
            String homeUrl = home.substring(0,home.lastIndexOf('/')+1);
            this.tempFile = homeUrl + "temp";
        }
        List queueDataSets = rootElement.element("patient_queue").elements("dataset");
        for (Object obj : queueDataSets) {
            if (obj instanceof Element) {

+ 4 - 3
Hos-resource/src/main/java/com/yihu/ehr/crawler/service/CrawlerManager.java

@ -71,9 +71,7 @@ public class CrawlerManager {
    }
    public Boolean collectProcess(Patient patient) {
        if (!dispatch.getToken()) {
            return false;
        }
        SysConfig.getInstance().setOrgCode(patient.getOrgCode());
        getAdapterDataSetList();
        patient.setReUploadFlg(StringUtil.toString(false));
        LogService.getLogger().trace("采集->注册->打包上传,任务ID:,patient_id:" + patient.getPatientId() + ", event_no:" + patient.getEventNo());
@ -81,6 +79,9 @@ public class CrawlerManager {
            Map<String, AdapterDataSet> dataSetMap = new HashMap<>();
            List<JsonNode> dataList = new ArrayList<>();
            //采集、注册
            if (!dispatch.getToken()) {
                return false;
            }
            for (AdapterDataSet adapterDataSet : adapterDataSetList) {
                String data = dispatch.fecthData(patient, adapterDataSet);
                if (StringUtil.isEmpty(data)) {

+ 2 - 6
Hos-resource/src/main/java/com/yihu/ehr/crawler/service/EsbHttp.java

@ -20,10 +20,7 @@ import org.json.JSONObject;
import sun.misc.BASE64Encoder;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
/**
 * Created by hzp on 2016/3/10.
@ -62,7 +59,7 @@ public class EsbHttp {
     */
    private static String GetFingerprint(){
        try {
            return "123456";
            return UUID.randomUUID().toString();
        }
        catch (Exception e)
        {
@ -316,7 +313,6 @@ public class EsbHttp {
        try {
            String uploadMethod = HttpHelper.defaultHttpUrl + "/packages";
            String fileMd5= MD5.getMd5ByFile(file);
            Map<String, Object> paramMap = new HashMap<>();
            List<NameValuePair> formParams = new ArrayList<>();
            formParams.add(new BasicNameValuePair("md5", fileMd5));
            formParams.add(new BasicNameValuePair("package_crypto", encryptPwd));

+ 1 - 1
Hos-resource/src/main/java/com/yihu/ehr/crawler/service/PatientCDAUpload.java

@ -83,7 +83,7 @@ public class PatientCDAUpload {
            zipFile.encryptPwd = RSA.encrypt(pwd, key);
            Zipper zipper = new Zipper();
            zipFile.file = zipper.zipFile(new File(dataDirectory), filePath, pwd);
            zipFile.file = zipper.zipFileForAll(new File(dataDirectory), filePath, pwd);
            zipFile.dataDirectory = dataDirectory;
            zipFile.directory = patientCDAIndex.getDirectory();

+ 1 - 1
Hos-resource/src/main/resources/config/sys.config.xml

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" ?>
<config>
    <debug>true</debug>
    <!--<temp_file>D:\temp</temp_file>-->
    <event_no>
        <item>HDSD03_01_031</item>
        <item>HDSD00_01_579</item>

+ 1 - 1
Hos-resource/src/main/webapp/WEB-INF/web.xml

@ -59,7 +59,7 @@
        </init-param>
        <init-param>
            <param-name>notCheckURLList</param-name>
            <param-value>/loginPage;/system/loginAction;/error</param-value>
            <param-value>/loginPage;/system/loginAction;/error;/crawler/patient</param-value>
        </init-param>
    </filter>
    <filter-mapping>