LAPTOP-KB9HII50\70708 2 年之前
父節點
當前提交
93e66dd12d

+ 11 - 0
svr/svr-cloud-transfor/pom.xml

@ -50,6 +50,17 @@
            <artifactId>swagger-starter</artifactId>
            <version>2.0.0</version>
        </dependency>
        <dependency>
            <groupId>com.yihu</groupId>
            <artifactId>mysql-starter</artifactId>
            <version>2.0.0</version>
            <exclusions>
                <exclusion>
                    <groupId>org.apache.tomcat</groupId>
                    <artifactId>tomcat-jdbc</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <!-- SPRINGSIDE -->
        <dependency>
            <groupId>org.springside</groupId>

+ 12 - 12
svr/svr-cloud-transfor/src/main/java/com/yihu/jw/care/controller/TransforController.java

@ -45,7 +45,7 @@ public class TransforController {
            long startTime=System.currentTimeMillis();
            String paraString = JSON.toJSONString(request.getParameterMap());
            String url = RequestParamUtil.getParamUrl(request);
            String result = aqgService.aqgForward(url);
            String result = aqgService.aqgForward(url,imei);
            long endTime=System.currentTimeMillis();
            logger.info("爱牵挂设备sos数据接收,请求参数:"+paraString+" "+(endTime-startTime)+"ms; 响应:"+result);
            return success();
@ -71,7 +71,7 @@ public class TransforController {
            long startTime=System.currentTimeMillis();
            String paraString = JSON.toJSONString(request.getParameterMap());
            String url = RequestParamUtil.getParamUrl(request);
            String result = aqgService.aqgForward(url);
            String result = aqgService.aqgForward(url,imei);
            long endTime=System.currentTimeMillis();
            logger.info("爱牵挂设备开关机数据接收,请求参数:"+paraString+" "+(endTime-startTime)+"ms; 响应:"+result);
            return success();
@ -95,7 +95,7 @@ public class TransforController {
            long startTime=System.currentTimeMillis();
            String paraString = JSON.toJSONString(request.getParameterMap());
            String url = RequestParamUtil.getParamUrl(request);
            String result = aqgService.aqgForward(url);
            String result = aqgService.aqgForward(url,deviceid);
            long endTime=System.currentTimeMillis();
            logger.info("爱牵挂设备消息通知数据接收,请求参数:"+paraString+" "+(endTime-startTime)+"ms; 响应:"+result);
            return success();
@ -131,7 +131,7 @@ public class TransforController {
            long startTime=System.currentTimeMillis();
            String paraString = JSON.toJSONString(request.getParameterMap());
            String url = RequestParamUtil.getParamUrl(request);
            String result = aqgService.aqgForward(url);
            String result = aqgService.aqgForward(url,imei);
            long endTime=System.currentTimeMillis();
            logger.info("爱牵挂位置接收,请求参数:"+paraString+" "+(endTime-startTime)+"ms; 响应:"+result);
            return success();
@ -160,7 +160,7 @@ public class TransforController {
            long startTime=System.currentTimeMillis();
            String paraString = JSON.toJSONString(request.getParameterMap());
            String url = RequestParamUtil.getParamUrl(request);
            String result = aqgService.aqgForward(url);
            String result = aqgService.aqgForward(url,imei);
            long endTime=System.currentTimeMillis();
            logger.info("爱牵挂心率数据接收,请求参数:"+paraString+" "+(endTime-startTime)+"ms; 响应:"+result);
            return success();
@ -190,7 +190,7 @@ public class TransforController {
            long startTime=System.currentTimeMillis();
            String paraString = JSON.toJSONString(request.getParameterMap());
            String url =RequestParamUtil.getParamUrl(request);
            String result = aqgService.aqgForward(url);
            String result = aqgService.aqgForward(url,imei);
            long endTime=System.currentTimeMillis();
            logger.info("爱牵挂血压数据接收,请求参数:"+paraString+" "+(endTime-startTime)+"ms; 响应:"+result);
            return success();
@ -222,7 +222,7 @@ public class TransforController {
            long startTime=System.currentTimeMillis();
            String paraString = JSON.toJSONString(request.getParameterMap());
            String url = RequestParamUtil.getParamUrl(request);
            String result = aqgService.aqgForward(url);
            String result = aqgService.aqgForward(url,imei);
            long endTime=System.currentTimeMillis();
            logger.info("爱牵挂跌倒数据接收,请求参数:"+paraString+" "+(endTime-startTime)+"ms; 响应:"+result);
            return success();
@ -246,7 +246,7 @@ public class TransforController {
            long startTime=System.currentTimeMillis();
            String paraString = JSON.toJSONString(request.getParameterMap());
            String url = RequestParamUtil.getParamUrl(request);
            String result = aqgService.aqgForward(url);
            String result = aqgService.aqgForward(url,imei);
            long endTime=System.currentTimeMillis();
            logger.info("设备步数接收,请求参数:"+paraString+" "+(endTime-startTime)+"ms; 响应:"+result);
            return success();
@ -279,7 +279,7 @@ public class TransforController {
            long startTime=System.currentTimeMillis();
            String paraString = JSON.toJSONString(request.getParameterMap());
            String url = RequestParamUtil.getParamUrl(request);
            String result = aqgService.aqgForward(url);
            String result = aqgService.aqgForward(url,device);
            long endTime=System.currentTimeMillis();
            logger.info("爱牵挂-睡眠带睡眠接收,请求参数:"+paraString+" "+(endTime-startTime)+"ms; 响应:"+result);
            return success();
@ -336,7 +336,7 @@ public class TransforController {
            long startTime=System.currentTimeMillis();
            String paraString = JSON.toJSONString(request.getParameterMap());
            String url = RequestParamUtil.getParamUrl(request);
            String result = aqgService.aqgForward(url);
            String result = aqgService.aqgForward(url,device);
            long endTime=System.currentTimeMillis();
            logger.info("爱牵挂-睡眠带睡眠报告接收,请求参数:"+paraString+" "+(endTime-startTime)+"ms; 响应:"+result);
            return success();
@ -360,7 +360,7 @@ public class TransforController {
            long startTime=System.currentTimeMillis();
            String paraString = JSON.toJSONString(request.getParameterMap());
            String url = RequestParamUtil.getParamUrl(request);
            String result = aqgService.aqgForward(url);
            String result = aqgService.aqgForward(url,device);
            long endTime=System.currentTimeMillis();
            logger.info("爱牵挂-睡眠带wifi在线状态接收,请求参数:"+paraString+" "+(endTime-startTime)+"ms; 响应:"+result);
            return success();
@ -394,7 +394,7 @@ public class TransforController {
            long startTime=System.currentTimeMillis();
            String paraString = JSON.toJSONString(request.getParameterMap());
            String url = RequestParamUtil.getParamUrl(request);
            String result = aqgService.aqgForward(url);
            String result = aqgService.aqgForward(url,imei);
            long endTime=System.currentTimeMillis();
            logger.info("爱牵挂-手表睡眠接收,请求参数:"+paraString+" "+(endTime-startTime)+"ms; 响应:"+result);
            return success();

+ 22 - 23
svr/svr-cloud-transfor/src/main/java/com/yihu/jw/care/service/AqgService.java

@ -4,11 +4,14 @@ package com.yihu.jw.care.service;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
import java.net.URLDecoder;
import java.util.List;
import java.util.Map;
/**
 * Created with IntelliJ IDEA.
@ -20,36 +23,32 @@ import java.net.URLDecoder;
@Service
public class AqgService {
    @Autowired
    private JdbcTemplate jdbcTemplate;
    public String getBaseUrl(String imei){
        if(StringUtils.isBlank(imei)){
            return "https://zhyzh.gongshu.gov.cn/device/";
        }
        String sql = "SELECT push_address from device_push_address where device_sn = '"+imei+"'";
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        if(list==null||list.size()==0){
            return "https://zhyzh.gongshu.gov.cn/device/";
        }else {
            return list.get(0).get("push_address")+"";
        }
    }
    private Logger logger = LoggerFactory.getLogger(AqgService.class);
    private static final RestTemplate restTemplate = new RestTemplate();
    private static final String baseUrl = "https://zhyzh.gongshu.gov.cn/device/";
//    private static final String baseUrl = "http://ehr.yihu.com/wlyy/aqg";
    public String aqgForward(String method,String body,String uri){
        String res = "";
        try {
            String url;
            if(StringUtils.isBlank(body)){
                uri = URLDecoder.decode(uri,"UTF-8");
                url = baseUrl+uri;
            }else{
                url = baseUrl+method+"?"+body;
            }
            ResponseEntity<String> responseEntity = null;
            logger.info("推送爱牵挂数据给医养项目url="+ url);
            responseEntity = restTemplate.getForEntity(url, String.class);
            res = responseEntity.getBody();
            logger.info("推送爱牵挂数据给医养项目res="+ res);
        }catch (Exception e){
            e.printStackTrace();
        }
        return res;
    }
    public String aqgForward(String url){
    public String aqgForward(String url,String imei){
        String res = "";
        try {
            String baseUrl = getBaseUrl(imei);
            ResponseEntity<String> responseEntity = null;
            logger.info("推送爱牵挂数据给医养项目url="+ baseUrl+url);
            responseEntity = restTemplate.getForEntity(baseUrl+url, String.class);

+ 3 - 3
svr/svr-cloud-transfor/src/main/resources/application.yml

@ -77,9 +77,9 @@ spring:
  profiles: prod
  datasource:
    driver-class-name: com.mysql.jdbc.Driver
    url: jdbc:mysql://172.26.0.104/base?useUnicode:true&amp;characterEncoding=utf-8&amp;autoReconnect=true&useSSL=false
    username: ssgg
    password: ssgg@jkzl2019
    url: jdbc:mysql://192.168.1.221:3306/device?useUnicode:true&amp;characterEncoding=utf-8&amp;autoReconnect=true&useSSL=false
    username: wlyy_sr
    password: 4zjQjEax
#  elasticsearch:
#    cluster-name: jkzl #集群名 默认elasticsearch
#    cluster-nodes: 172.26.0.115:9300,172.26.0.115:9300 #配置es节点信息,逗号分隔,如果没有指定,则启动ClientNode