Bläddra i källkod

rest改为开发地址

huangzhiyong 8 år sedan
förälder
incheckning
fa1bba8f57

+ 16 - 13
hos-rest/src/main/java/com/yihu/hos/rest/models/crawler/qc/QcDaily.java

@ -5,6 +5,7 @@ import java.util.List;
/**
 * 质控-日报
 *
 * @author HZY
 * @vsrsion 1.0
 * Created at 2017/6/1.
@ -17,30 +18,30 @@ public class QcDaily {
    private Integer real_outpatient_num;
    private Integer total_hospital_num;
    private Integer real_hospital_num;
    private List<QcPatientIndex> total_outpatient=new ArrayList<>();
    private List<QcPatientIndex> real_outpatient=new ArrayList<>();
    private List<QcPatientIndex> total_hospital=new ArrayList<>();;
    private List<QcPatientIndex> real_hospital=new ArrayList<>();;
    private List<QcPatientIndex> total_outpatient = new ArrayList<>();
    private List<QcPatientIndex> real_outpatient = new ArrayList<>();
    private List<QcPatientIndex> total_hospital = new ArrayList<>();
    private List<QcPatientIndex> real_hospital = new ArrayList<>();
    ;
    public void addTotal(QcPatientIndex patientIndex,String dataSet){
        if ("HDSC01_02".equals(dataSet)){
    public void addTotal(QcPatientIndex patientIndex, String dataSet) {
        if ("HDSC01_02".equals(dataSet)) {
            this.total_outpatient.add(patientIndex);
        }else if ("HDSC02_09".equals(dataSet)){
        } else if ("HDSC02_09".equals(dataSet)) {
            this.total_hospital.add(patientIndex);
        }else {
        } else {
            return;
        }
    }
    public void addReal(QcPatientIndex patientIndex,String dataSet){
        if ("HDSC01_02".equals(dataSet)){
    public void addReal(QcPatientIndex patientIndex, String dataSet) {
        if ("HDSC01_02".equals(dataSet)) {//门诊
            this.real_outpatient.add(patientIndex);
        }else if ("HDSC02_09".equals(dataSet)){
        } else if ("HDSC02_09".equals(dataSet)) {//住院
            this.real_hospital.add(patientIndex);
        }else {
        } else {
            return;
        }
    }
@ -132,4 +133,6 @@ public class QcDaily {
    public void setReal_hospital(List<QcPatientIndex> real_hospital) {
        this.real_hospital = real_hospital;
    }
}

+ 6 - 43
hos-rest/src/main/java/com/yihu/hos/rest/services/crawler/EsbHttp.java

@ -166,22 +166,22 @@ public class EsbHttp {
            Map<String, String> header = new HashMap<>();
            header.put("Authorization", "Basic " + EHRHttpHelper.clientKey);
            Map<String, String> paramMap = new HashMap<>();
            paramMap.put("org_code", orgCode);
            paramMap.put("org_code", SysConfig.orgcode);
//            paramMap.put("token", token);
            String publicKeyMethod = EHRHttpHelper.httpCouldUrl + "/organizations/" + orgCode + "/key";
            String publicKeyMethod = EHRHttpHelper.httpCouldUrl + "/organizations/" + SysConfig.orgcode + "/key";
            HTTPResponse response = EHRHttpHelper.get(publicKeyMethod, paramMap, header);
            if (response != null && response.getStatusCode() == HttpStatus.SC_OK) {
                JSONObject json = new JSONObject(response.getBody());
                if (json.has("publicKey")) {
                    String publicKey = json.getString("publicKey");
                    SysConfig.getInstance().getPublicKeyMap().put(orgCode, publicKey);
                    SysConfig.getInstance().getPublicKeyMap().put(SysConfig.orgcode, publicKey);
                    return publicKey;
                } else {
                    logger.info("获取公钥失败,返回未包含publicKey。机构代码:"+orgCode);
                    logger.info("获取公钥失败,返回未包含publicKey。机构代码:"+SysConfig.orgcode);
                    return null;
                }
            } else {
                String msg = "获取公钥失败。机构代码:"+orgCode;
                String msg = "获取公钥失败。机构代码:"+SysConfig.orgcode;
                if (response != null) {
                    msg += "(错误代码:" + response.getStatusCode() + ",错误信息:" + response.getBody() + ")";
@ -320,7 +320,7 @@ public class EsbHttp {
    /**
     *
     * 上传质控包
     * 上传质控包/日报包
     */
    public static boolean uploadQC(Patient patient, File file, String encryptPwd, String type) {
        try {
@ -356,43 +356,6 @@ public class EsbHttp {
        }
    }
    /**
     *
     * 上传日报包
     */
    public static boolean uploadQcDaily(Patient patient, File file, String encryptPwd, String type) {
        try {
            String uploadMethod = EHRHttpHelper.httpAdminUrl + "/admin/report/receiveReportFile";
            String fileMd5 = MD5.getMd5ByFile(file);
            Map<String, String> formParams = new HashMap<>();
            formParams.put("md5", fileMd5);
            formParams.put("package_crypto", encryptPwd);
            formParams.put("org_code", SysConfig.orgcode);
            formParams.put("type", type);// 文件包类型 1 质控包, 2 日报包
            Map<String, String> header = new HashMap<>();
            header.put("Authorization", "Basic " + EHRHttpHelper.clientKey);
            header.put("User-Agent", "client " + EHRHttpHelper.clientId);
            HTTPResponse response = EHRHttpHelper.postFile(uploadMethod, formParams, file.getAbsolutePath(), header);
            if (response != null && response.getStatusCode() == HttpStatus.SC_OK) {
                logger.info("上传质控数据成功,patient_id:" + patient.getPatientId() + ",event_no:" + patient.getEventNo());
                return true;
            } else {
                String msg = "上传质控数据请求失败,patient_id:" + patient.getPatientId() + ",event_no:" + patient.getEventNo();
                if (response != null) {
                    msg += "(错误代码:" + response.getStatusCode() + ",错误信息:" + response.getBody() + ")";
                }
                logger.info(msg);
                return false;
            }
        } catch (Exception e) {
            logger.info("上传质控数据异常,patient_id:" + patient.getPatientId() + ",event_no:" + patient.getEventNo());
            logger.error(e.getCause().toString());
            e.printStackTrace();
            return false;
        }
    }
    /**
     * 下载标准包

+ 3 - 2
hos-rest/src/main/java/com/yihu/hos/rest/services/crawler/QCCrawlerManager.java

@ -245,7 +245,7 @@ public class QCCrawlerManager {
                }
            }
        }
        message = "本次采集病人共" + totalCount + "条,成功采集信息"+ count + "条";
        message = "本次上传病人共" + totalCount + "条,成功上传信息"+ count + "条";
        return Result.success(message);
    }
@ -282,7 +282,8 @@ public class QCCrawlerManager {
                 * 获取数据
                 */
                AdapterDataSet adapterDataSet = adapterDataSetMap.get(key);
                JsonNode jsonObject = dispatch.fecthData(patient, adapterDataSet);
                String stdVersion = adapterDatasetService.getStdVersionByAdapterDataSet(this.schemeVersion);
                JsonNode jsonObject = dispatch.fecthData(patient, adapterDataSet,stdVersion);
                if (StringUtil.isEmpty(jsonObject)) {
                    continue;
                }

+ 167 - 0
hos-rest/src/main/java/com/yihu/hos/rest/services/crawler/QCDataUpload.java

@ -0,0 +1,167 @@
package com.yihu.hos.rest.services.crawler;
import com.yihu.hos.core.compress.Zipper;
import com.yihu.hos.core.datatype.DateUtil;
import com.yihu.hos.core.encrypt.RSA;
import com.yihu.hos.core.file.FileUtil;
import com.yihu.hos.core.log.Logger;
import com.yihu.hos.core.log.LoggerFactory;
import com.yihu.hos.rest.models.crawler.config.SysConfig;
import com.yihu.hos.rest.models.crawler.patient.Patient;
import java.io.File;
import java.security.Key;
import java.util.UUID;
/**
 * 质控包上传
 *
 * @author Air
 * @version 1.0
 * @created 2015.07.06 15:58
 */
public class QCDataUpload {
    private static Logger logger = LoggerFactory.getLogger(QCDataUpload.class);
    /**
     * 上传质控 日报包
     * @param patient
     * @param type      质控包类型  1 质控包, 2 日报包
     * @param currentString      文件夹随机码
     * @return
     */
    public Boolean uploadQcDailyZip(Patient patient, String type,String currentString) {
        ZipFile zipFile = zip(patient,type,currentString);
        try {
            if (zipFile == null || zipFile.file == null) {
                logger.info("压缩质控日报数据失败,质控日报数据未生成,patient_id:" + patient.getPatientId() + ",event_no:" + patient.getEventNo());
                return false;
            }
            boolean result = uploadQc(patient, zipFile, type);
            if (!result) {
                logger.info("上传质控日报数据失败,patient_id:" + patient.getPatientId() + ",event_no:" + patient.getEventNo());
                result = FileUtil.deleteDirectory(new File(zipFile.directory));
                return result;
            }
            logger.trace(zipFile.directory);
            result = FileUtil.deleteDirectory(new File(zipFile.directory));
            if (!result) {
                logger.info("删除质控日报临时文件失败,patient_id:" + patient.getPatientId() + ",event_no:" + patient.getEventNo());
                return result;
            }
        } catch (Exception e) {
            logger.error("质控服务-日报包上传异常",e);
            FileUtil.deleteDirectory(new File(zipFile.directory));
            return false;
        }
        return true;
    }
    /**
     *  上传自控数据档案包
     * @param patient   病人信息
     * @param type      文件包类型 1 质控包, 2 日报包
     * @return
     */
    public Boolean uploadQc(Patient patient, String type) {
        ZipFile zipFile = zip(patient,type, DateUtil.getCurrentString(DateUtil.DEFAULT_NOW_STRING_FORMAT));
        try {
            if (zipFile == null || zipFile.file == null) {
                logger.info("压缩质控数据失败,质控数据未生成,patient_id:" + patient.getPatientId() + ",event_no:" + patient.getEventNo());
                return false;
            }
            boolean result = uploadQc(patient, zipFile, type);
            if (!result) {
                logger.info("上传质控数据失败,patient_id:" + patient.getPatientId() + ",event_no:" + patient.getEventNo());
                result = FileUtil.deleteDirectory(new File(zipFile.directory));
                return result;
            }
            logger.trace(zipFile.directory);
            result = FileUtil.deleteDirectory(new File(zipFile.directory));
            if (!result) {
                logger.info("删除质控临时文件失败,patient_id:" + patient.getPatientId() + ",event_no:" + patient.getEventNo());
                return result;
            }
        } catch (Exception e) {
            FileUtil.deleteDirectory(new File(zipFile.directory));
            return false;
        }
        return true;
    }
    /**
     * @param patient
     * @return
     * @modify 从质控数据目录生成zip数据
     */
    public ZipFile zip(Patient patient,String type,String currentString) {
        try {
            QCDataIndex qcDataIndex = new QCDataIndex(patient, currentString);
            String dataDirectory = null;
            String filePath = null;
            String directory = null;
            if (QCDataIndex.IndexType.QC_TYPE_DATASET.equals(type)){
                dataDirectory = qcDataIndex.getDataDirectory();
                directory = qcDataIndex.getDirectory();
                filePath = qcDataIndex.createIndex(PatientCDAIndex.IndexType.ZIP, PatientCDAIndex.FileType.ZIP);
            }else if (QCDataIndex.IndexType.QC_TYPE_DAILY.equals(type)){
                dataDirectory = qcDataIndex.getDataDailyDir();
                directory = qcDataIndex.getDailyDir();
                filePath = qcDataIndex.createQcDailyIndex(PatientCDAIndex.IndexType.ZIP, PatientCDAIndex.FileType.ZIP);
            }
            UUID uuidPwd = UUID.randomUUID();
            String pwd = uuidPwd.toString();
            String publicKey = SysConfig.getInstance().getPublicKeyMap().get(patient.getOrgCode());
            if(publicKey== null ||  publicKey.length() == 0) {
                publicKey = EsbHttp.getPublicKey(patient.getOrgCode());
                SysConfig.getInstance().getPublicKeyMap().put(patient.getOrgCode(), publicKey);
            }
            Key key = RSA.genPublicKey(publicKey);
            if (key == null) {
                logger.info("压缩质控文件错误,获取公钥错误.");
                return null;
            }
            ZipFile zipFile = new ZipFile();
            zipFile.encryptPwd = RSA.encrypt(pwd, key);
            Zipper zipper = new Zipper();
            zipFile.file = zipper.zipFileForAll(new File(dataDirectory), filePath, pwd);
            zipFile.dataDirectory = dataDirectory;
            zipFile.directory = directory;
            return zipFile;
        } catch (Exception e) {
            logger.error("从质控目录生成zip数据时,压缩文件异常");
            e.printStackTrace();
        }
        return null;
    }
    /**
     * 上传质控包/日报包
     * @param patient
     * @param zipFile
     * @param type      文件类型 :1-质控包,2-日报包
     * @return
     */
    private boolean uploadQc(Patient patient, ZipFile zipFile, String type) {
        return EsbHttp.uploadQC(patient, zipFile.file, zipFile.encryptPwd, type);
    }
    private class ZipFile {
        public File file;
        public String encryptPwd;
        public String directory;
        public String dataDirectory;
    }
}

+ 2 - 2
hos-rest/src/main/resources/config/dbhelper.properties

@ -1,7 +1,7 @@
defaultName = hos-mysql
defaultUri = jdbc:mysql://172.19.103.42:3306/esb?useUnicode=true&characterEncoding=UTF-8
defaultUri = jdbc:mysql://172.19.103.57:3306/esb?useUnicode=true&characterEncoding=UTF-8
defaultUser = esb
defaultPassword = esb
mongodbUri=mongodb://esb:esb@172.19.103.42:27017/?authSource=admin
mongodbUri=mongodb://esb:esb@172.19.103.57:27017/?authSource=admin
mongodbName=hos

+ 1 - 1
hos-rest/src/main/resources/config/http.properties

@ -8,7 +8,7 @@ httpAdminUrl = http://192.168.131.134:10000/api/v1.0
  #https://172.19.103.73:443/api/v1.0
sslKeystore = /usr/local/esb/tomcat.keystore
sslKeystore = D:/tomcat.keystore
sslPassword = 123456
clientId = zkGuSIm2Fg
clientKey = emtHdVNJbTJGZzpnUGR2VFJBWVVoc2tjaHht

+ 1 - 1
hos-rest/src/main/resources/config/sys.config.xml

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" ?>
<config>
    <temp_file>/usr/local/esb/temp</temp_file>
    <temp_file>D:/temp</temp_file>
    <ehr_version>
        <org_code code="jkzl">
            <version>56395d75b854</version>

+ 1 - 1
hos-rest/src/main/resources/spring/applicationContext.xml

@ -24,7 +24,7 @@
    <bean id="dataSource" class="org.apache.commons.dbcp2.BasicDataSource" destroy-method="close">
        <property name="driverClassName" value="com.mysql.jdbc.Driver"/>
        <property name="url" value="jdbc:mysql://172.19.103.42:8066/hos2?useUnicode=true&amp;characterEncoding=UTF-8"/>
        <property name="url" value="jdbc:mysql://172.19.103.57:8066/hos2?useUnicode=true&amp;characterEncoding=UTF-8"/>
        <property name="username" value="hos"/>
        <property name="password" value="123456"/>
        <property name="initialSize" value="1"/>