Explorar o código

Merge branch 'dev' of huangzhanpeng/wlyy_management into dev

chenweida %!s(int64=8) %!d(string=hai) anos
pai
achega
d40daa5162

+ 4 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/health/PatientHealthIndexService.java

@ -20,6 +20,7 @@ import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.patient.PatientDeviceDao;
import com.yihu.wlyy.repository.patient.PatientHealthStandardDao;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.task.HealthIndexUploadTask;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.math.NumberUtils;
import org.json.JSONArray;
@ -501,6 +502,9 @@ public class PatientHealthIndexService extends BaseService {
            }
            patientHealthIndexDao.save(obj);
            //保存完后上传基卫
            new Thread(new HealthIndexUploadTask(String.valueOf(obj.getId()))).start();
        } else {
            throw new Exception("不存在该患者!");
        }

+ 119 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/jw/JwArchivesService.java

@ -0,0 +1,119 @@
package com.yihu.wlyy.service.third.jw;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.wlyy.entity.dict.SystemDict;
import com.yihu.wlyy.service.system.SystemDictService;
import com.yihu.wlyy.service.third.ehr.EhrService;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.HttpClientUtil;
import com.yihu.wlyy.util.SystemConf;
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.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * Created by hzp on 2016/11/15.
 * 基卫健康档案服务
 */
@Service("JwArchivesService")
public class JwArchivesService {
    //基卫服务地址
    private String jwUrl = SystemConf.getInstance().getJwUrl();
    /**
     *  查询居民健康体检列表信息接口
     */
    public String getEhrSickMedicalList(String idcard)  throws Exception
    {
        String re = "";
        String url = jwUrl + "/third/archives/getEhrSickMedicalList";
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("idcard", idcard));
        String response = HttpClientUtil.post(url, params, "UTF-8");
        if(!StringUtils.isEmpty(response))
        {
            JSONObject json = new JSONObject(response);
            if("1".equals(json.optString("CODE")))
            {
                re = json.getJSONArray("DATA").toString();
            }
            else{
                throw new Exception(json.optString("MESSAGE"));
            }
        }
        else{
            re = "[]";
        }
        return re;
    }
    /**
     *  查询居民健康体检详情接口
     */
    public String getEhrSickMedicalRecord(String medicalNo)  throws Exception
    {
        String re = "";
        String url = jwUrl + "/third/archives/getEhrSickMedicalRecord";
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("medicalNo", medicalNo));
        String response = HttpClientUtil.post(url, params, "UTF-8");
        if(!StringUtils.isEmpty(response))
        {
            JSONObject json = new JSONObject(response);
            if("1".equals(json.optString("CODE")))
            {
                re = json.getJSONArray("DATA").toString();
            }
            else{
                throw new Exception(json.optString("MESSAGE"));
            }
        }
        else{
            re = "[]";
        }
        return re;
    }
    /**
     *  上传体征指标接口
     */
    public void uploadHealthIndex(String id)  throws Exception
    {
        String url = jwUrl + "/third/archives/uploadHealthIndex";
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("id", id));
        String response = HttpClientUtil.post(url, params, "UTF-8");
        if(!StringUtils.isEmpty(response))
        {
            JSONObject json = new JSONObject(response);
            if (!"200".equals(json.optString("status"))) {
                throw new Exception(json.optString("msg"));
            }
        }
        else{
            throw new Exception("返回结果为空!");
        }
    }
}

+ 1 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/jw/JwSmjkService.java

@ -28,7 +28,7 @@ import java.util.*;
/**
 * Created by hzp on 2016/11/14.
 * 基卫健康档案服务
 * 基卫健康市民健康服务
 */
@Service
public class JwSmjkService {

+ 38 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/task/HealthIndexUploadTask.java

@ -0,0 +1,38 @@
package com.yihu.wlyy.task;
import com.yihu.wlyy.service.third.jw.JwArchivesService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.context.support.SpringBeanAutowiringSupport;
/**
 * 健康指标推送
 * Created by hzp on 2016/11/15.
 */
public class HealthIndexUploadTask implements Runnable {
    private static Logger logger = LoggerFactory.getLogger(HealthIndexUploadTask.class);
    @Autowired
    private JwArchivesService jwArchivesService;
    String id = "";
    public HealthIndexUploadTask(String id) {
        this.id = id;
    }
    @Override
    public void run() {
        try {
            Thread.sleep(3000);
            SpringBeanAutowiringSupport.processInjectionBasedOnCurrentContext(this);
            jwArchivesService.uploadHealthIndex(id);
            logger.info("healthIndex:"+id+" upload success.");
        } catch (Exception e) {
            e.printStackTrace();
            logger.info("healthIndex:"+id+" upload fail."+e.getMessage());
        }
    }
}