LiTaohong 7 years ago
parent
commit
a71f3575df
21 changed files with 895 additions and 41 deletions
  1. 23 0
      app/app-iot-server/src/main/java/com/yihu/ehr/iot/controller/common/BaseController.java
  2. 164 0
      app/app-iot-server/src/main/java/com/yihu/ehr/iot/controller/third/wlyy/MonitoringHealthPlatformController.java
  3. 1 0
      app/app-iot-server/src/main/java/com/yihu/ehr/iot/security/config/EhrWebSecurityConfiguration.java
  4. 191 0
      app/app-iot-server/src/main/java/com/yihu/ehr/iot/service/third/wlyy/MonitoringHealthService.java
  5. 219 0
      app/app-iot-server/src/main/java/com/yihu/ehr/iot/util/http/HttpUtil.java
  6. 16 0
      app/app-iot-server/src/main/resources/application.yml
  7. 1 1
      common/common-entity/src/main/java/com/yihu/jw/entity/archives/PatientArchives.java
  8. 1 1
      common/common-entity/src/main/java/com/yihu/jw/entity/archives/PatientArchivesInfo.java
  9. 100 0
      common/common-entity/src/main/java/com/yihu/jw/iot/device/LocationDataDO.java
  10. 1 0
      common/common-request-mapping/src/main/java/com/yihu/jw/rm/iot/IotRequestMapping.java
  11. 20 1
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/iot/device/IotPatientDeviceVO.java
  12. 80 0
      common/common-util/src/main/java/com/yihu/jw/util/common/LatitudeUtils.java
  13. 0 1
      server/svr-configuration/src/main/resources/bootstrap.yml
  14. 5 3
      svr/svr-iot/src/main/java/com/yihu/iot/controller/device/IotPatientDeviceController.java
  15. 4 0
      svr/svr-iot/src/main/java/com/yihu/iot/datainput/util/ConstantUtils.java
  16. 44 0
      svr/svr-iot/src/main/java/com/yihu/iot/service/device/IotPatientDeviceService.java
  17. 2 2
      svr/svr-iot/src/main/resources/application.yml
  18. 6 13
      svr/svr-wlyy-archives/src/main/java/com/yihu/jw/controller/PatientArchivesController.java
  19. 3 3
      svr/svr-wlyy-archives/src/main/java/com/yihu/jw/dao/PatientArchivesDao.java
  20. 4 4
      svr/svr-wlyy-archives/src/main/java/com/yihu/jw/dao/PatientArchivesInfoDao.java
  21. 10 12
      svr/svr-wlyy-archives/src/main/java/com/yihu/jw/service/PatientArchivesSevice.java

+ 23 - 0
app/app-iot-server/src/main/java/com/yihu/ehr/iot/controller/common/BaseController.java

@ -1,9 +1,12 @@
package com.yihu.ehr.iot.controller.common;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.ehr.util.rest.Envelop;
import org.springframework.beans.factory.annotation.Value;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * Controller - 基类
@ -37,4 +40,24 @@ public class BaseController {
        return envelop;
    }
    /**
     * 返回接口处理结果
     *
     * @param code  结果码,成功为200
     * @param msg   结果提示信息
     * @return
     */
    public String error(int code, String msg) {
        try {
            Map<Object, Object> map = new HashMap<Object, Object>();
            ObjectMapper mapper = new ObjectMapper();
            map.put("status", code);
            map.put("msg", msg);
            return mapper.writeValueAsString(map);
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }
}

+ 164 - 0
app/app-iot-server/src/main/java/com/yihu/ehr/iot/controller/third/wlyy/MonitoringHealthPlatformController.java

@ -0,0 +1,164 @@
package com.yihu.ehr.iot.controller.third.wlyy;
import com.yihu.ehr.iot.controller.common.BaseController;
import com.yihu.ehr.iot.service.third.wlyy.MonitoringHealthService;
import com.yihu.jw.rm.iot.IotRequestMapping;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
 * 远程监测健康平台-访问wlyy
 * @author yeshijie on 2018/2/11.
 */
@RestController
@RequestMapping(IotRequestMapping.Common.wlyy)
@Api(tags = "远程监测健康平台", description = "远程监测健康平台")
public class MonitoringHealthPlatformController extends BaseController{
    @Autowired
    private MonitoringHealthService monitoringHealthService;
    @RequestMapping(value = "/equipmentDistribution",method = RequestMethod.GET)
    @ApiOperation("设备发放情况")
    public String equipmentDistribution(){
        try {
            return monitoringHealthService.equipmentDistribution();
        }catch (Exception e){
            e.printStackTrace();
            return error(-1,"查询失败");
        }
    }
    @RequestMapping(value = "/chronicDiseaseCount",method = RequestMethod.GET)
    @ApiOperation("慢病患者情况-统计")
    public String chronicDiseaseCount(
            @ApiParam(name="type",value="类型(2糖尿病,1高血压)",defaultValue = "")
            @RequestParam(value="type",required = false) String type){
        try {
            return monitoringHealthService.chronicDiseaseCount(type);
        }catch (Exception e){
            e.printStackTrace();
            return error(-1,"查询失败");
        }
    }
    @RequestMapping(value = "/warningInformationAlarm",method = RequestMethod.GET)
    @ApiOperation("预警信息警报")
    public String warningInformationAlarm(
            @ApiParam(name="page",value="第几页(默认第一页)",defaultValue = "1")
            @RequestParam(value="page",required = false) Integer page,
            @ApiParam(name="pageSize",value="每页几行(默认10条记录)",defaultValue = "10")
            @RequestParam(value="pageSize",required = false) Integer pageSize){
        try {
            if(page==null){
                page = 1;
            }
            if(pageSize==null){
                pageSize = 10;
            }
            return monitoringHealthService.warningInformationAlarm(page,pageSize);
        }catch (Exception e){
            e.printStackTrace();
            return error(-1,"查询失败");
        }
    }
    @RequestMapping(value = "/deviceBinding",method = RequestMethod.GET)
    @ApiOperation("设备绑定情况")
    public String deviceBinding(
            @ApiParam(name="type",value="设备类型(1血糖仪,2血压计)",defaultValue = "")
            @RequestParam(value="type",required = false) String type){
        try {
            return monitoringHealthService.deviceBinding(type);
        }catch (Exception e){
            e.printStackTrace();
            return error(-1,"查询失败");
        }
    }
    @RequestMapping(value = "/persionalInfo",method = RequestMethod.GET)
    @ApiOperation("个人信息")
    public String persionalInfo(@ApiParam(name="patient",value="居民code",defaultValue = "")
                                @RequestParam(value="patient",required = true) String patient){
        try {
            return monitoringHealthService.persionalInfo(patient);
        }catch (Exception e){
            e.printStackTrace();
            return error(-1,"查询失败");
        }
    }
    @RequestMapping(value = "/familyMember",method = RequestMethod.GET)
    @ApiOperation("家人信息")
    public String familyMember(@ApiParam(name="patient",value="居民code",defaultValue = "")
                               @RequestParam(value="patient",required = true) String patient){
        try {
            return monitoringHealthService.familyMember(patient);
        }catch (Exception e){
            e.printStackTrace();
            return error(-1,"查询失败");
        }
    }
    @RequestMapping(value = "/healthDevice",method = RequestMethod.GET)
    @ApiOperation("健康设备")
    public String healthDevice(@ApiParam(name="patient",value="居民code",defaultValue = "")
                               @RequestParam(value="patient",required = true) String patient){
        try {
            return monitoringHealthService.healthDevice(patient);
        }catch (Exception e){
            e.printStackTrace();
            return error(-1,"查询失败");
        }
    }
    @RequestMapping(value = "chart", method = RequestMethod.GET)
    @ApiOperation("根据患者标志获取健康指标(图表)")
    public String getHealthIndexChartByPatient(@ApiParam(name="patient",value="居民code",defaultValue = "")
                                               @RequestParam(value="patient",required = true) String patient,
                                               @ApiParam(name = "type", value = "指标类型(1血糖,2血压,3体重,4腰围)", defaultValue = "1")
                                               @RequestParam(value = "type", required = true) Integer type,
                                               @ApiParam(name = "gi_type", value = "就餐类型0全部", defaultValue = "1")
                                               @RequestParam(value = "gi_type", required = false) Integer gi_type,
                                               @ApiParam(name = "begin", value = "开始时间", defaultValue = "2017-05-22")
                                               @RequestParam(value = "begin", required = true) String begin,
                                               @ApiParam(name = "end", value = "结束时间", defaultValue = "2018-06-02")
                                               @RequestParam(value = "end", required = true) String end) {
        try {
            return monitoringHealthService.getHealthIndexChartByPatient(patient,type,gi_type,begin,end);
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1,"查询失败");
        }
    }
    @ApiOperation("获取门诊记录/住院记录(基卫+APP)")
    @RequestMapping(value = "/event", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
    public String getAllEvent(@ApiParam(name = "patient", value = "患者代码", defaultValue = "")
                              @RequestParam(value = "patient", required = true) String patient,
                              @ApiParam(name = "type", value = "类型(1血糖,2血压)", defaultValue = "")
                              @RequestParam(value = "type", required = false) String type,
                              @ApiParam(name = "page", value = "第几页", defaultValue = "1")
                              @RequestParam(value = "page", required = true) String page,
                              @ApiParam(name = "pageSize", value = "每页几行", defaultValue = "10")
                              @RequestParam(value = "pageSize", required = true) String pageSize) {
        try {
            return monitoringHealthService.getAllEvent(patient, type, page, pageSize);
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1,"查询失败");
        }
    }
}

+ 1 - 0
app/app-iot-server/src/main/java/com/yihu/ehr/iot/security/config/EhrWebSecurityConfiguration.java

@ -71,6 +71,7 @@ public class EhrWebSecurityConfiguration extends WebSecurityConfigurerAdapter {
                .antMatchers("/front/js/**").permitAll()
                .antMatchers("/front/views/signin.html").permitAll()
                .antMatchers("/login/**").permitAll()
                .antMatchers("/svr-iot/wlyy/**").permitAll()//健康监测平台没有做登录(这里添加免登录验证)
                .antMatchers("/front/views/**").hasRole("USER")
                .antMatchers("/**").hasRole("USER")
                .and().formLogin().loginPage("/login")

+ 191 - 0
app/app-iot-server/src/main/java/com/yihu/ehr/iot/service/third/wlyy/MonitoringHealthService.java

@ -0,0 +1,191 @@
package com.yihu.ehr.iot.service.third.wlyy;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.yihu.ehr.iot.service.common.BaseService;
import com.yihu.ehr.iot.util.http.HttpHelper;
import com.yihu.ehr.iot.util.http.HttpResponse;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
/**
 * @author yeshijie on 2018/2/11.
 */
@Service
public class MonitoringHealthService extends BaseService{
    private Logger logger = LoggerFactory.getLogger(MonitoringHealthService.class);
    @Value("${third.wlyy.url}")
    private String wlyyUrl;
    @Value("${third.wlyy.appid}")
    private String appid;
    @Value("${third.wlyy.appsecret}")
    private String appSecret;
    /**
     * 访问i健康接口,自带登录信息
     * @param url
     * @return
     */
    private String sendGet(String url,Map<String, Object> params){
        params.put("accesstoken",getAccessToken());
        HttpResponse response = HttpHelper.get(wlyyUrl + url, params);
        return response.getBody();
    }
    /**
     * 返回accessToken
     * @return
     * @throws IOException
     */
    private String getAccessToken(){
        Map<String, Object> params = new HashMap<>();
        params.put("appid", appid);
        params.put("appSecret", appSecret);
        String url = "/gc/accesstoken";
        HttpResponse response = HttpHelper.post(wlyyUrl + url, params);
        JSONObject jsonObject = JSON.parseObject(response.getBody());
        if(jsonObject.getInteger("status")==10000){
            return jsonObject.getJSONObject("result").getString("accesstoken");
        }
        return null;
    }
    /**
     * 设备发放情况
     */
    public String equipmentDistribution(){
        String url = "/wlyygc/iot_monitoring/equipmentDistribution";
        Map<String, Object> params = new HashMap<>();
        return sendGet(url,params);
    }
    /**
     * 慢病患者情况-统计
     * 类型(2糖尿病,1高血压)
     */
    public String chronicDiseaseCount(String type){
        String url = "/wlyygc/iot_monitoring/chronicDiseaseCount";
        Map<String, Object> params = new HashMap<>();
        params.put("type",type);
        return sendGet(url,params);
    }
    /**
     * 预警信息警报
     * @param page
     * @param pageSize
     * @return
     */
    public String warningInformationAlarm(Integer page,Integer pageSize){
        String url = "/wlyygc/iot_monitoring/warningInformationAlarm";
        Map<String, Object> params = new HashMap<>();
        params.put("page",page);
        params.put("pageSize",pageSize);
        return sendGet(url,params);
    }
    /**
     * 设备绑定情况
     * @param type 设备类型(1血糖仪,2血压计
     * @return
     */
    public String deviceBinding(String type){
        String url = "/wlyygc/iot_monitoring/deviceBinding";
        Map<String, Object> params = new HashMap<>();
        params.put("type",type);
        return sendGet(url,params);
    }
    /**
     * 个人信息
     * @param patient
     * @return
     */
    @RequestMapping(value = "/persionalInfo",method = RequestMethod.GET)
    @ApiOperation("个人信息")
    public String persionalInfo(String patient){
        String url = "/wlyygc/iot_monitoring/persionalInfo";
        Map<String, Object> params = new HashMap<>();
        params.put("patient",patient);
        return sendGet(url,params);
    }
    /**
     * 家人信息
     * @param patient
     * @return
     */
    public String familyMember(String patient){
        String url = "/wlyygc/iot_monitoring/familyMember";
        Map<String, Object> params = new HashMap<>();
        params.put("patient",patient);
        return sendGet(url,params);
    }
    /**
     * 健康设备
     * @param patient
     * @return
     */
    @RequestMapping(value = "/healthDevice",method = RequestMethod.GET)
    @ApiOperation("健康设备")
    public String healthDevice(String patient){
        String url = "/wlyygc/iot_monitoring/healthDevice";
        Map<String, Object> params = new HashMap<>();
        params.put("patient",patient);
        return sendGet(url,params);
    }
    /**
     * 体征数据
     * @param patient
     * @param type
     * @param gi_type
     * @param begin
     * @param end
     * @return
     */
    public String getHealthIndexChartByPatient(String patient,Integer type, Integer gi_type,String begin,String end) {
        String url = "/wlyygc/iot_monitoring/chart";
        Map<String, Object> params = new HashMap<>();
        params.put("patient",patient);
        params.put("type",type);
        params.put("begin",begin);
        params.put("end",end);
        params.put("gi_type",gi_type);
        return sendGet(url,params);
    }
    /**
     * 获取门诊记录/住院记录(基卫+APP)
     * @param patient
     * @param type 类型(1血糖,2血压)
     * @param page
     * @param pageSize
     * @return
     */
    public String getAllEvent(String patient,String type,String page,String pageSize) {
        String url = "/wlyygc/iot_monitoring/event";
        Map<String, Object> params = new HashMap<>();
        params.put("patient",patient);
        params.put("type",type);
        params.put("page",page);
        params.put("pageSize",pageSize);
        return sendGet(url,params);
    }
}

+ 219 - 0
app/app-iot-server/src/main/java/com/yihu/ehr/iot/util/http/HttpUtil.java

@ -0,0 +1,219 @@
package com.yihu.ehr.iot.util.http;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import java.io.*;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLConnection;
/*
 * MD5 算法
 */
@Component
public class HttpUtil {
	private static final Logger logger = LoggerFactory.getLogger(HttpUtil.class);
	/**
	 * 向指定URL发送GET方法的请求
	 *
	 * @param url
	 *            发送请求的URL
	 * @param param
	 *            请求参数,请求参数应该是 name1=value1&name2=value2 的形式。
	 * @return URL 所代表远程资源的响应结果
	 */
	public  String sendGet(String url, String param) {
		String result = "";
		BufferedReader in = null;
		try {
			String urlNameString = url + "?" + param;
			URL realUrl = new URL(urlNameString);
			// 打开和URL之间的连接
			URLConnection connection = realUrl.openConnection();
			// 设置通用的请求属性
			connection.setRequestProperty("accept", "*/*");
			connection.setRequestProperty("connection", "Keep-Alive");
			connection.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
			// 建立实际的连接
			connection.connect();
			// 定义 BufferedReader输入流来读取URL的响应
			in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
			String line;
			while ((line = in.readLine()) != null) {
				result += line;
			}
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			try {
				if (in != null) {
					in.close();
				}
			} catch (Exception e2) {
				e2.printStackTrace();
			}
		}
		return result;
	}
	/**
	 * 向指定 URL 发送POST方法的请求
	 *
	 * @param url
	 *            发送请求的 URL带上参数
	 * @param param
	 *            POST参数。
	 * @return 所代表远程资源的响应结果
	 */
	public  String sendPost(String url, String param) {
		StringBuffer buffer = new StringBuffer();
		PrintWriter out = null;
		BufferedReader in = null;
		HttpURLConnection conn = null;
		try {
			URL realUrl = new URL(url);
			// 打开和URL之间的连接
			conn = (HttpURLConnection) realUrl.openConnection();
			conn.setRequestMethod("POST");
			conn.setConnectTimeout(5000);
			conn.setDoOutput(true);
			conn.setDoInput(true);
			conn.setUseCaches(false);
			conn.setRequestProperty("Content-Type", "application/text");
			conn.setRequestProperty("accept", "*/*");
			conn.setRequestProperty("connection", "Keep-Alive");
			conn.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
			OutputStreamWriter osw = new OutputStreamWriter(conn.getOutputStream(), "UTF-8");
			osw.write(param.toString());
			osw.flush();
			// 读取返回内容
			BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream(), "UTF-8"));
			String temp;
			while ((temp = br.readLine()) != null) {
				buffer.append(temp);
				buffer.append("\n");
			}
		} catch (Exception e) {
			logger.error("push message error:", e);
		} finally {
			try {
				if (out != null) {
					out.close();
				}
				if (in != null) {
					in.close();
				}
			} catch (IOException ex) {
				ex.printStackTrace();
			}
		}
		return buffer.toString();
	}
	/**
	 * 向指定 URL 发送POST方法的请求
	 *
	 * @param url 发送请求的 URL带上参数
	 * @param param POST参数。
	 * @param charset 编码格式
	 * @return 所代表远程资源的响应结果
	 */
	public  String sendPost(String url, String param, String charset) {
		StringBuffer buffer = new StringBuffer();
		PrintWriter out = null;
		BufferedReader in = null;
		HttpURLConnection conn = null;
		try {
			URL realUrl = new URL(url);
			// 打开和URL之间的连接
			conn = (HttpURLConnection) realUrl.openConnection();
			conn.setRequestMethod("POST");
			conn.setDoOutput(true);
			conn.setDoInput(true);
			conn.setUseCaches(false);
			conn.setRequestProperty("Content-Type", "application/text");
			conn.setRequestProperty("accept", "*/*");
			conn.setRequestProperty("connection", "Keep-Alive");
			conn.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
			OutputStreamWriter osw = new OutputStreamWriter(conn.getOutputStream(), charset);
			osw.write(param.toString());
			osw.flush();
			// 读取返回内容
			BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream(), charset));
			String temp;
			while ((temp = br.readLine()) != null) {
				buffer.append(temp);
				buffer.append("\n");
			}
		} catch (Exception e) {
			logger.error("push message error:", e);
		} finally {
			try {
				if (out != null) {
					out.close();
				}
				if (in != null) {
					in.close();
				}
			} catch (IOException ex) {
				ex.printStackTrace();
			}
		}
		return buffer.toString();
	}
	/**
	 * 向指定URL发送GET方法的请求
	 *
	 * @param url
	 *            发送请求的URL
	 * @param param
	 *            请求参数,请求参数应该是 name1=value1&name2=value2 的形式。
	 * @return URL 所代表远程资源的响应结果
	 */
	public  String sendLoginGet(String url, String param,String userAgent) {
		String result = "";
		BufferedReader in = null;
		try {
			String urlNameString = url;
			if(StringUtils.isNotBlank(param)){
				urlNameString+="?" + param;
			}
			URL realUrl = new URL(urlNameString);
			// 打开和URL之间的连接
			URLConnection connection = realUrl.openConnection();
			// 设置通用的请求属性
			connection.setRequestProperty("accept", "*/*");
			connection.setRequestProperty("connection", "Keep-Alive");
			connection.setRequestProperty("user-agent", userAgent);
			// 建立实际的连接
			connection.connect();
			// 定义 BufferedReader输入流来读取URL的响应
			in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
			String line;
			while ((line = in.readLine()) != null) {
				result += line;
			}
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			try {
				if (in != null) {
					in.close();
				}
			} catch (Exception e2) {
				e2.printStackTrace();
			}
		}
		return result;
	}
}

+ 16 - 0
app/app-iot-server/src/main/resources/application.yml

@ -65,6 +65,11 @@ service-gateway:
  portalInnerUrl: http://172.19.103.73:10280/api/v1.0/portal
  portalOuterUrl: http://27.154.233.186:10280/api/v1.0/portal
third:
  wlyy:
    url: http://192.168.131.24:8086/
    appid: 915d0345-5b1d-11e6-8344-fa163e8aee61
    appsecret: 915d0345-5b1d-11e6-8344-fa163e8aee57
fast-dfs:
  tracker-server: 172.19.103.54:22122
@ -85,10 +90,16 @@ app:
  oauth2InnerUrl: http://172.19.103.73:10260/
  oauth2OuterUrl: http://27.154.233.186:10260/
service-gateway:
  iotUrl: http://172.19.103.88:10050/svr-iot/
  profileInnerUrl: http://172.19.103.73:10000/api/v1.0/admin
  profileOuterUrl: http://27.154.233.186:10000/api/v1.0/admin
  portalInnerUrl: http://172.19.103.73:10280/api/v1.0/portal
  portalOuterUrl: http://27.154.233.186:10280/api/v1.0/portal
third:
  wlyy:
    url: http://ehr.yihu.com/wlyy/
    appid: 915d0345-5b1d-11e6-8344-fa163e8aee61
    appsecret: 915d0345-5b1d-11e6-8344-fa163e8aee57
fast-dfs:
  tracker-server: 172.19.103.54:22122
  public-server: http://172.19.103.54:80/
@ -112,6 +123,11 @@ service-gateway:
  profileOuterUrl: http://27.154.233.186:10000/api/v1.0/admin
  portalInnerUrl: http://172.19.103.73:10280/api/v1.0/portal
  portalOuterUrl: http://27.154.233.186:10280/api/v1.0/portal
third:
  wlyy:
    url: http://www.yihu.com/wlyy/
    appid: 915d0345-5b1d-11e6-8344-fa163e8aee61
    appsecret: 915d0345-5b1d-11e6-8344-fa163e8aee57
fast-dfs:
  tracker-server: 11.1.2.9:22122
  accessUrl: http://11.1.2.9

+ 1 - 1
common/common-entity/src/main/java/com/yihu/jw/entity/archives/PatientArchives.java

@ -13,7 +13,7 @@ import java.util.Date;
 */
@Entity
@Table(name = "wlyy_patient_archives")
public class PatientArchives extends IdEntityWithOperation implements Serializable {
public class PatientArchivesDO extends IdEntityWithOperation implements Serializable {
    @Column(name = "saas_id")
    private String saasId; //saasid
    @Column(name = "patient_code")

+ 1 - 1
common/common-entity/src/main/java/com/yihu/jw/entity/archives/PatientArchivesInfo.java

@ -13,7 +13,7 @@ import java.util.Date;
 */
@Entity
@Table(name = "wlyy_patient_archives_info")
public class PatientArchivesInfo extends IdEntityWithOperation implements Serializable {
public class PatientArchivesInfoDO extends IdEntityWithOperation implements Serializable {
    @Column(name = "saas_id")
    private String saasId; //saasid

+ 100 - 0
common/common-entity/src/main/java/com/yihu/jw/iot/device/LocationDataDO.java

@ -0,0 +1,100 @@
package com.yihu.jw.iot.device;
import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.searchbox.annotations.JestId;
import org.springframework.data.elasticsearch.annotations.GeoPointField;
import org.springframework.data.elasticsearch.core.geo.GeoPoint;
import java.util.Date;
/**
 * Created by chenweida on 2018/2/12.
 */
public class LocationDataDO {
    @JestId
    private String id;
    private String idCard; //设备绑定身份证
    private String deviceSn;//设备SnID
    private String categoryCode;//设备类型标识
    @GeoPointField
    private GeoPoint location;//经纬度
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ssXX")
    @JSONField(format = "yyyy-MM-dd'T'HH:mm:ssXX")
    private Date deviceTime;//设备绑定时间
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ssXX")
    @JSONField(format = "yyyy-MM-dd'T'HH:mm:ssXX")
    private Date createTime;  // 创建时间(ES:必填)
    public String getId() {
        return id;
    }
    public void setId(String id) {
        this.id = id;
    }
    public String getIdCard() {
        return idCard;
    }
    public void setIdCard(String idCard) {
        this.idCard = idCard;
    }
    public String getDeviceSn() {
        return deviceSn;
    }
    public void setDeviceSn(String deviceSn) {
        this.deviceSn = deviceSn;
    }
    public String getCategoryCode() {
        return categoryCode;
    }
    public void setCategoryCode(String categoryCode) {
        this.categoryCode = categoryCode;
    }
    public GeoPoint getLocation() {
        return location;
    }
    public void setLocation(GeoPoint location) {
        this.location = location;
    }
    public Date getDeviceTime() {
        return deviceTime;
    }
    public void setDeviceTime(Date deviceTime) {
        this.deviceTime = deviceTime;
    }
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    public void setLocation(Double lat, Double lng) {
        GeoPoint geoPoint = new GeoPoint(lat, lng);
        this.location = geoPoint;
    }
}

+ 1 - 0
common/common-request-mapping/src/main/java/com/yihu/jw/rm/iot/IotRequestMapping.java

@ -20,6 +20,7 @@ public class IotRequestMapping {
        public static final String device = api_iot_common + "/device";
        public static final String quality = api_iot_common + "/quality";
        public static final String patientDevice = api_iot_common + "/patientDevice";
        public static final String wlyy = api_iot_common + "/wlyy";
        public static final String message_success_update = "update success";

+ 20 - 1
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/iot/device/IotPatientDeviceVO.java

@ -12,7 +12,7 @@ import java.io.Serializable;
 * @author yeshijie on 2018/1/16.
 */
@JsonInclude(JsonInclude.Include.ALWAYS)
@ApiModel(value = "设备质检计划表", description = "设备质检计划表")
@ApiModel(value = "居民设备绑定表", description = "居民设备绑定表")
public class IotPatientDeviceVO extends BaseVO implements Serializable {
    @ApiModelProperty("居民code")
@ -33,6 +33,10 @@ public class IotPatientDeviceVO extends BaseVO implements Serializable {
    private String agent;
    @ApiModelProperty("按键号")
    private String userType;
    @ApiModelProperty("设备类型标识(1血压计,2血糖仪)")
    private String categoryCode;
    @ApiModelProperty("地址")
    private String address;
    public String getPatient() {
        return patient;
@ -106,4 +110,19 @@ public class IotPatientDeviceVO extends BaseVO implements Serializable {
        this.userType = userType;
    }
    public String getAddress() {
        return address;
    }
    public void setAddress(String address) {
        this.address = address;
    }
    public String getCategoryCode() {
        return categoryCode;
    }
    public void setCategoryCode(String categoryCode) {
        this.categoryCode = categoryCode;
    }
}

+ 80 - 0
common/common-util/src/main/java/com/yihu/jw/util/common/LatitudeUtils.java

@ -0,0 +1,80 @@
package com.yihu.jw.util.common;
import org.springframework.util.StringUtils;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLEncoder;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
public class LatitudeUtils {
    public static final String KEY_1 = "7d9fbeb43e975cd1e9477a7e5d5e192a";
    /**
     * 返回输入地址的经纬度坐标
     * key lng(经度),lat(纬度)
     */
    public static Map<String,String> getGeocoderLatitude(String address){
        BufferedReader in = null;
        try {
            //将地址转换成utf-8的16进制
            address = URLEncoder.encode(address, "UTF-8");
            URL tirc = new URL("http://api.map.baidu.com/geocoder?address="+ address +"&output=json&key="+ UUID.randomUUID().toString().replace("-",""));
            in = new BufferedReader(new InputStreamReader(tirc.openStream(),"UTF-8"));
            String res;
            StringBuilder sb = new StringBuilder("");
            while((res = in.readLine())!=null){
                sb.append(res.trim());
            }
            String str = sb.toString();
            Map<String,String> map = null;
            if(!StringUtils.isEmpty(str)){
                int lngStart = str.indexOf("lng\":");
                int lngEnd = str.indexOf(",\"lat");
                int latEnd = str.indexOf("},\"precise");
                if(lngStart > 0 && lngEnd > 0 && latEnd > 0){
                    String lng = str.substring(lngStart+5, lngEnd);
                    String lat = str.substring(lngEnd+7, latEnd);
                    map = new HashMap<String,String>();
                    map.put("lng", lng);
                    map.put("lat", lat);
                    return map;
                }
            }
        }catch (Exception e) {
            e.printStackTrace();
        }finally{
            try {
                in.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return null;
    }
//    public static void main(String args[]){
//        try {
//            Map<String, String> json = LatitudeUtils.getGeocoderLatitude("浦东区张杨路1725号");
//            System.out.println("经度 : " + json.get("lng"));
//            System.out.println("纬度 : " + json.get("lat"));
//        }catch (Exception e ){
//            e.printStackTrace();
//        }
//    }
}

+ 0 - 1
server/svr-configuration/src/main/resources/bootstrap.yml

@ -36,7 +36,6 @@ spring:
      server:
        git:
          uri: http://192.168.1.220:10080/jiwei/jw.config.git
          force-pull: true
        default-label: master

+ 5 - 3
svr/svr-iot/src/main/java/com/yihu/iot/controller/device/IotPatientDeviceController.java

@ -17,13 +17,11 @@ import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.List;
import static com.yihu.jw.rm.iot.IotRequestMapping.Common.patientDevice;
/**
 * @author yeshijie on 2018/2/8.
 */
@RestController
@RequestMapping(patientDevice)
@RequestMapping(IotRequestMapping.Common.patientDevice)
@Api(tags = "居民设备管理相关操作", description = "居民设备管理相关操作")
public class IotPatientDeviceController extends EnvelopRestController{
@ -36,8 +34,12 @@ public class IotPatientDeviceController extends EnvelopRestController{
    public Envelop<IotPatientDeviceVO> create(@ApiParam(name = "json_data", value = "", defaultValue = "")
                                       @RequestParam String jsonData) {
        try {
            //设备绑定
            IotPatientDeviceDO patientDevice = toEntity(jsonData, IotPatientDeviceDO.class);
            iotPatientDeviceService.create(patientDevice);
            //地址信息存入es
            IotPatientDeviceVO deviceVO = toEntity(jsonData, IotPatientDeviceVO.class);
            iotPatientDeviceService.deviceData2Es(deviceVO);
            return Envelop.getSuccess(IotRequestMapping.Device.message_success_create);
        } catch (Exception e) {
            e.printStackTrace();

+ 4 - 0
svr/svr-iot/src/main/java/com/yihu/iot/datainput/util/ConstantUtils.java

@ -16,4 +16,8 @@ public class ConstantUtils {
    //微信运动数据es类型
    public static String weRunDataType = "step_data";
    //设备坐标es索引
    public static String deviceLocationIndex = "device_location_index";
    //设备坐标es类型
    public static String deviceLocationType = "device_location_type";
}

+ 44 - 0
svr/svr-iot/src/main/java/com/yihu/iot/service/device/IotPatientDeviceService.java

@ -1,13 +1,24 @@
package com.yihu.iot.service.device;
import com.alibaba.fastjson.JSONObject;
import com.yihu.base.es.config.ElastricSearchHelper;
import com.yihu.base.mysql.query.BaseJpaService;
import com.yihu.iot.dao.device.IotPatientDeviceDao;
import com.yihu.iot.datainput.util.ConstantUtils;
import com.yihu.jw.iot.device.IotPatientDeviceDO;
import com.yihu.jw.iot.device.LocationDataDO;
import com.yihu.jw.restmodel.iot.device.IotPatientDeviceVO;
import com.yihu.jw.util.common.LatitudeUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
 * @author yeshijie on 2018/1/16.
@ -15,8 +26,11 @@ import java.util.List;
@Service
public class IotPatientDeviceService extends BaseJpaService<IotPatientDeviceDO,IotPatientDeviceDao> {
    private Logger logger = LoggerFactory.getLogger(IotPatientDeviceService.class);
    @Autowired
    private IotPatientDeviceDao iotPatientDeviceDao;
    @Autowired
    private ElastricSearchHelper elastricSearchHelper;
    /**
     * 新增
@ -30,6 +44,36 @@ public class IotPatientDeviceService extends BaseJpaService<IotPatientDeviceDO,I
        return iotPatientDeviceDao.save(patientDevice);
    }
    /**
     * 设备绑定时 把坐标信息存入es
     * @param deviceVO
     */
    public void deviceData2Es(IotPatientDeviceVO deviceVO) {
        try {
            if (StringUtils.isEmpty(deviceVO.getAddress())) {
                return;
            }
//            List<LocationDataDO> dataDTOs = new ArrayList<>();
            LocationDataDO dataDTO = new LocationDataDO();
            dataDTO.setCreateTime(new Date());
            dataDTO.setDeviceTime(new Date());
            dataDTO.setCategoryCode(deviceVO.getCategoryCode());
            dataDTO.setDeviceSn(deviceVO.getDeviceSn());
            dataDTO.setIdCard(deviceVO.getIdcard());
            Map<String, String> json = LatitudeUtils.getGeocoderLatitude(deviceVO.getAddress().replace("G.", "").replace("(糖友网)", "").replace("(高友网)", ""));
            if (json == null) {
                return;
            }
            logger.info("地址:," + deviceVO.getAddress() + "坐标" + json.toString());
            dataDTO.setLocation(Double.valueOf(json.get("lat")), Double.valueOf(json.get("lng")));
//            dataDTOs.add(dataDTO);
            elastricSearchHelper.save(ConstantUtils.deviceLocationIndex, ConstantUtils.deviceLocationType,JSONObject.toJSONString(dataDTO));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    /**
     * 按id查找
     * @param id

+ 2 - 2
svr/svr-iot/src/main/resources/application.yml

@ -27,14 +27,14 @@ spring:
  data:
    elasticsearch: #ElasticsearchProperties
      cluster-name: jkzl #默认即为elasticsearch  集群名
      cluster-nodes: 172.19.103.45:9300,172.19.103.68:9300 #配置es节点信息,逗号分隔,如果没有指定,则启动ClientNode
      cluster-nodes: 172.19.103.68:9300 #配置es节点信息,逗号分隔,如果没有指定,则启动ClientNode
      local: false #是否本地连接
      properties: # Additional properties used to configure the client.
        enable: true
  # JEST (Elasticsearch HTTP client) (JestProperties)
  elasticsearch:
    jest:
      uris: http://172.19.103.45:9200,http://172.19.103.68:9200
      uris: http://172.19.103.68:9200
#      uris: http://172.19.103.68:9200
      connection-timeout: 60000 # Connection timeout in milliseconds.
      multi-threaded: true # Enable connection requests from multiple execution threads.

+ 6 - 13
svr/svr-wlyy-archives/src/main/java/com/yihu/jw/controller/PatientArchivesController.java

@ -1,21 +1,15 @@
package com.yihu.jw.controller;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.entity.archives.PatientArchives;
import com.yihu.jw.entity.archives.PatientArchivesInfo;
import com.yihu.jw.iot.device.IotDeviceQualityInspectionPlanDO;
import com.yihu.jw.entity.archives.PatientArchivesDO;
import com.yihu.jw.entity.archives.PatientArchivesInfoDO;
import com.yihu.jw.restmodel.archives.PatientArchivesInfoVO;
import com.yihu.jw.restmodel.archives.PatientArchivesVO;
import com.yihu.jw.restmodel.archives.Test;
import com.yihu.jw.restmodel.common.Envelop;
import com.yihu.jw.restmodel.common.EnvelopRestController;
import com.yihu.jw.restmodel.iot.device.IotDeviceImportVO;
import com.yihu.jw.rm.archives.PatientArchivesMapping;
import com.yihu.jw.rm.iot.IotRequestMapping;
import com.yihu.jw.service.PatientArchivesSevice;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@ -24,7 +18,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.sleuth.Tracer;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.List;
/**
@ -85,9 +78,9 @@ public class PatientArchivesController extends EnvelopRestController {
                                                  @ApiParam(name = "list", value = "建档详情Json")
                                                  @RequestParam(value = "list", required = true)String list){
        try {
            PatientArchives ps = toEntity(patientArchives, PatientArchives.class);
            PatientArchivesDO ps = toEntity(patientArchives, PatientArchivesDO.class);
            List<PatientArchivesInfo> infos = new ObjectMapper().readValue(list, new TypeReference<List<PatientArchivesInfo>>(){});
            List<PatientArchivesInfoDO> infos = new ObjectMapper().readValue(list, new TypeReference<List<PatientArchivesInfoDO>>(){});
            return patientArchivesSevice.createPatientArchives(ps,infos);
        }catch (Exception e){
@ -104,9 +97,9 @@ public class PatientArchivesController extends EnvelopRestController {
                                                  @ApiParam(name = "list", value = "建档详情")
                                                  @RequestParam(value = "list", required = true)String list){
        try {
            PatientArchives ps = toEntity(patientArchives, PatientArchives.class);
            PatientArchivesDO ps = toEntity(patientArchives, PatientArchivesDO.class);
            List<PatientArchivesInfo> infos = new ObjectMapper().readValue(list, new TypeReference<List<PatientArchivesInfo>>(){});
            List<PatientArchivesInfoDO> infos = new ObjectMapper().readValue(list, new TypeReference<List<PatientArchivesInfoDO>>(){});
            return patientArchivesSevice.updatePatientArchives(ps,infos);
        }catch (Exception e){

+ 3 - 3
svr/svr-wlyy-archives/src/main/java/com/yihu/jw/dao/PatientArchivesDao.java

@ -1,12 +1,12 @@
package com.yihu.jw.dao;
import com.yihu.jw.entity.archives.PatientArchives;
import com.yihu.jw.entity.archives.PatientArchivesDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by Trick on 2018/2/7.
 */
public interface PatientArchivesDao extends PagingAndSortingRepository<PatientArchives, String>,
        JpaSpecificationExecutor<PatientArchives> {
public interface PatientArchivesDao extends PagingAndSortingRepository<PatientArchivesDO, String>,
        JpaSpecificationExecutor<PatientArchivesDO> {
}

+ 4 - 4
svr/svr-wlyy-archives/src/main/java/com/yihu/jw/dao/PatientArchivesInfoDao.java

@ -1,6 +1,6 @@
package com.yihu.jw.dao;
import com.yihu.jw.entity.archives.PatientArchivesInfo;
import com.yihu.jw.entity.archives.PatientArchivesInfoDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
@ -9,8 +9,8 @@ import java.util.List;
/**
 * Created by Trick on 2018/2/7.
 */
public interface PatientArchivesInfoDao extends PagingAndSortingRepository<PatientArchivesInfo, String>,
        JpaSpecificationExecutor<PatientArchivesInfo> {
    List<PatientArchivesInfo> findByArchivesCodeOrderByLevel1(String archivesCode);
public interface PatientArchivesInfoDao extends PagingAndSortingRepository<PatientArchivesInfoDO, String>,
        JpaSpecificationExecutor<PatientArchivesInfoDO> {
    List<PatientArchivesInfoDO> findByArchivesCodeOrderByLevel1(String archivesCode);
    int deleteByArchivesCode(String archivesCode);
}

+ 10 - 12
svr/svr-wlyy-archives/src/main/java/com/yihu/jw/service/PatientArchivesSevice.java

@ -4,8 +4,8 @@ package com.yihu.jw.service;
import com.yihu.base.mysql.query.BaseJpaService;
import com.yihu.jw.dao.PatientArchivesDao;
import com.yihu.jw.dao.PatientArchivesInfoDao;
import com.yihu.jw.entity.archives.PatientArchives;
import com.yihu.jw.entity.archives.PatientArchivesInfo;
import com.yihu.jw.entity.archives.PatientArchivesDO;
import com.yihu.jw.entity.archives.PatientArchivesInfoDO;
import com.yihu.jw.restmodel.archives.PatientArchivesInfoVO;
import com.yihu.jw.restmodel.archives.PatientArchivesVO;
import com.yihu.jw.restmodel.common.Envelop;
@ -13,11 +13,9 @@ import com.yihu.jw.rm.archives.PatientArchivesMapping;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.persistence.EntityManager;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Collection;
@ -28,7 +26,7 @@ import java.util.List;
 */
@Service
@Transactional
public class PatientArchivesSevice extends BaseJpaService<PatientArchives,PatientArchivesDao> {
public class PatientArchivesSevice extends BaseJpaService<PatientArchivesDO,PatientArchivesDao> {
    @Autowired
    private PatientArchivesInfoDao patientArchivesInfoDao;
@ -62,7 +60,7 @@ public class PatientArchivesSevice extends BaseJpaService<PatientArchives,Patien
        }
        String sorts = "-createTime";
        //得到list数据
        List<PatientArchivesVO> list = search(null, filters, sorts, page, size);
        List<PatientArchivesDO> list = search(null, filters, sorts, page, size);
        //获取总数
        long count = getCount(filters);
@ -79,26 +77,26 @@ public class PatientArchivesSevice extends BaseJpaService<PatientArchives,Patien
     */
    public Envelop<PatientArchivesInfoVO> queryPatientArchivesInfoPage(String code) throws ParseException {
        List<PatientArchivesInfo> list = patientArchivesInfoDao.findByArchivesCodeOrderByLevel1(code);
        List<PatientArchivesInfoDO> list = patientArchivesInfoDao.findByArchivesCodeOrderByLevel1(code);
        List<PatientArchivesInfoVO> patientArchivesinfoVOs = convertToModelVOs2(list,new ArrayList<>(list.size()));
        return Envelop.getSuccessList(PatientArchivesMapping.api_success,patientArchivesinfoVOs);
    }
    public Envelop<Boolean> createPatientArchives(PatientArchives patientArchives,List<PatientArchivesInfo> list){
    public Envelop<Boolean> createPatientArchives(PatientArchivesDO patientArchivesDO, List<PatientArchivesInfoDO> list){
        patientArchivesDao.save(patientArchives);
        patientArchivesDao.save(patientArchivesDO);
        patientArchivesInfoDao.save(list);
        Envelop envelop = new Envelop();
        envelop.setObj(true);
        return envelop;
    }
    public  Envelop<Boolean> updatePatientArchives(PatientArchives patientArchives,List<PatientArchivesInfo> list){
    public  Envelop<Boolean> updatePatientArchives(PatientArchivesDO patientArchivesDO, List<PatientArchivesInfoDO> list){
        patientArchivesDao.save(patientArchives);
        patientArchivesInfoDao.deleteByArchivesCode(patientArchives.getId());
        patientArchivesDao.save(patientArchivesDO);
        patientArchivesInfoDao.deleteByArchivesCode(patientArchivesDO.getId());
        patientArchivesInfoDao.save(list);
        Envelop envelop = new Envelop();
        envelop.setObj(true);