瀏覽代碼

代码修改

LAPTOP-KB9HII50\70708 3 年之前
父節點
當前提交
cc0aaa84bc

+ 2 - 1
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/wechat/WeiXinEventProcess.java

@ -168,7 +168,8 @@ public class WeiXinEventProcess {
        Map<String, String> articleFamily = new HashMap<>();
        // 图文URL
        String urlFamily = "https://open.weixin.qq.com/connect/oauth2/authorize?appid={appId}&amp;redirect_uri=https%3A%2F%2Fzhyzh.gongshu.gov.cn%2Fmedical-care-patient%2FlifeCare%2Findex&amp;response_type=code&amp;scope=snsapi_base&amp;state=STATE#wechat_redirect";
        String urlFamily = "https://open.weixin.qq.com/connect/oauth2/authorize?appid={appId}&amp;redirect_uri=https%3A%2F%2Fzhyzh.gongshu.gov.cn%2Fmedical-care-patient%2FlifeCare%2Findex%3Ftype%3D2&amp;response_type=code&amp;scope=snsapi_base&amp;state=STATE#wechat_redirect";
//        String urlFamily = "https://open.weixin.qq.com/connect/oauth2/authorize?appid={appId}&amp;redirect_uri=https%3A%2F%2Fzhyzh.gongshu.gov.cn%2Fmedical-care-patient%2FlifeCare%2Findex%3Ftype%3D2&amp;response_type=code&amp;scope=snsapi_base&amp;state=STATE#wechat_redirect";
        urlFamily = urlFamily.replace("{appId}", appId);
        articleFamily.put("Url", urlFamily);
        articleFamily.put("Title", "上门预约");

+ 0 - 8
svr/svr-cloud-device/src/main/java/com/yihu/jw/care/service/DeviceService.java

@ -877,14 +877,6 @@ public class DeviceService {
    @Async
    public void byOnlineStatus(String device,String onlinestatu,String time_begin){
        try {
            if(StringUtils.isNotBlank(device)){
                List<DevicePatientDevice> devicePatientDeviceDos = patientDeviceDao.findByDeviceSn(device);
                if (devicePatientDeviceDos.size()>0){
                    DevicePatientDevice tmp = devicePatientDeviceDos.get(0);
                    tmp.setOnlineStatus(Integer.parseInt(onlinestatu));
                    patientDeviceDao.save(tmp);
                }
            }
            DeviceDetail deviceDetail = deviceDetailDao.findBySn(device);
            if(deviceDetail!=null){
                deviceDetail.setContactStatus(Integer.parseInt(onlinestatu));

+ 4 - 4
svr/svr-cloud-job/src/main/java/com/yihu/jw/care/service/device/PatientDeviceService.java

@ -248,7 +248,7 @@ public class PatientDeviceService {
            List<String> lostSN = new ArrayList<>();
            List<String> onContact = new ArrayList<>();
            /*******************未失联**/
            //血糖仪,血压计。30天内有数据上传,则改为未失联
/*            //血糖仪,血压计。30天内有数据上传,则改为未失联
            String sql = " SELECT pd.device_sn FROM base.wlyy_patient_device pd  where pd.del=0 and pd.category_code in (1,2) and EXISTS ( " +
                    "select dp.device_sn from device_data_push_log dp where dp.device_sn = pd.device_sn and dp.create_time " +
                    " BETWEEN '"+startTimeDevice1+"' AND '"+endTime+"') ";
@ -265,13 +265,13 @@ public class PatientDeviceService {
            devices = jdbcTemplate.queryForList(sql,String.class) ;
            if (devices.size() > 0) {
                onContact.addAll(devices);
            }
            }*/
            /***************失联**/
            //血糖仪、血压**/
            sql = " SELECT pd.device_sn FROM base.wlyy_patient_device pd  where pd.del=0 and pd.category_code in (1,2) and not EXISTS ( " +
            String sql = " SELECT pd.device_sn FROM base.wlyy_patient_device pd  where pd.del=0 and pd.category_code in (1,2) and not EXISTS ( " +
                    "select dp.device_sn from device_data_push_log dp where dp.device_sn = pd.device_sn and dp.create_time " +
                    " BETWEEN '"+startTimeDevice1+"' AND '"+endTime+"') ";
            devices = jdbcTemplate.queryForList(sql,String.class) ;
            List<String> devices = jdbcTemplate.queryForList(sql,String.class) ;
            if (devices.size() > 0) {
                lostSN.addAll(devices);
            }

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

@ -0,0 +1,152 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>com.yihu.jw</groupId>
        <artifactId>wlyy-parent-pom</artifactId>
        <version>2.0.0</version>
        <relativePath>../../wlyy-parent-pom/pom.xml</relativePath>
    </parent>
    <groupId>com.yihu.jw</groupId>
    <artifactId>svr-cloud-transfor</artifactId>
    <packaging>jar</packaging>
    <version>${parent.version}</version>
    <dependencies>
        <!-- 支持Tomcat启动 -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-tomcat</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
<!--            <scope>provided</scope>-->
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.tomcat.embed</groupId>
            <artifactId>tomcat-embed-jasper</artifactId>
        </dependency>
        <!-- 支持Tomcat启动 -->
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>fastjson</artifactId>
        </dependency>
        <dependency>
            <groupId>com.yihu.jw</groupId>
            <artifactId>swagger-starter</artifactId>
            <version>2.0.0</version>
        </dependency>
        <!-- SPRINGSIDE -->
        <dependency>
            <groupId>org.springside</groupId>
            <artifactId>springside-core</artifactId>
            <version>4.2.3-GA</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-core</artifactId>
            <version>RELEASE</version>
            <scope>compile</scope>
        </dependency>
    </dependencies>
    <build>
        <finalName>svr-cloud-transfor</finalName>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <configuration>
                    <archive>
                        <!-- 生成的jar中,不要包含pom.xml和pom.properties这两个文件 -->
                        <addMavenDescriptor>false</addMavenDescriptor>
                        <manifest>
                            <!-- 是否要把第三方jar加入到类构建路径 -->
                            <addClasspath>true</addClasspath>
                            <!-- 外部依赖jar包的最终位置 -->
                            <classpathPrefix>lib/</classpathPrefix>
                            <mainClass>com.yihu.SvrCloudTransforApplication</mainClass>
                        </manifest>
                    </archive>
                </configuration>
            </plugin>
            <!--拷贝依赖到jar外面的lib目录-->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <id>copy-lib</id>
                        <phase>package</phase>
                        <goals>
                            <goal>copy-dependencies</goal>
                        </goals>
                        <configuration>
                            <!-- 依赖包输出目录,将来不打进jar包里 -->
                            <outputDirectory>${project.build.directory}/lib</outputDirectory>
                            <excludeTransitive>false</excludeTransitive>
                            <stripVersion>false</stripVersion>
                            <includeScope>runtime</includeScope>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <!--指定配置文件,将resources打成外部resource-->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <configuration>
                    <archive>
                        <!-- 指定配置文件目录,这样jar运行时会去找到同目录下的resources文件夹下查找 -->
                        <manifestEntries>
                            <Class-Path>resources/</Class-Path>
                        </manifestEntries>
                    </archive>
                    <!-- 打包时忽略的文件(也就是不打进jar包里的文件) -->
                    <excludes>
                        <exclude>**/*.yml</exclude>
                        <exclude>**/*.xml</exclude>
                    </excludes>
                </configuration>
            </plugin>
            <!-- 拷贝资源文件 外面的resource目录-->
            <plugin>
                <artifactId>maven-resources-plugin</artifactId>
                <executions>
                    <execution>
                        <id>copy-dependencies</id>
                        <phase>package</phase>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                            <!-- 资源文件输出目录 -->
                            <outputDirectory>${project.build.directory}/resources</outputDirectory>
                            <resources>
                                <resource>
                                    <directory>src/main/resources</directory>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

+ 24 - 0
svr/svr-cloud-transfor/src/main/java/com/yihu/SvrCloudTransforApplication.java

@ -0,0 +1,24 @@
package com.yihu;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.support.SpringBootServletInitializer;
import org.springframework.context.annotation.ComponentScan;
/**
 * Created by yeshijie on 2021/10/14.
 */
@SpringBootApplication
@ComponentScan("com.yihu")
public class SvrCloudTransforApplication extends SpringBootServletInitializer {
    public static void main(String[] args)  {
        SpringApplication.run(SvrCloudTransforApplication.class, args);
    }
    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
        return builder.sources(SvrCloudTransforApplication.class);
    }
}

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

@ -0,0 +1,430 @@
package com.yihu.jw.care.controller;
import com.alibaba.fastjson.JSON;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.care.service.AqgService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
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;
import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;
/**
 * Created by yeshijie on 2021/10/14.
 */
@RestController
@RequestMapping(value = "/device",produces = "application/json")
@Api(value = "请求转发相关服务", description = "请求转发相关服务")
public class TransforController {
    private static Logger logger = LoggerFactory.getLogger(TransforController.class);
    @Autowired
    private AqgService aqgService;
    @ApiOperation("爱牵挂设备sos数据接收")
    @RequestMapping(value = "aqgsos", method = {RequestMethod.POST,RequestMethod.GET})
    public String aqgsos(
            @ApiParam(name="imei",required = false,value="15位设备唯一序号",defaultValue = "")
            @RequestParam(value = "imei",required = false) String imei,
            @ApiParam(name="label_mac",required = false,value="只有主机下有绑定标贴才会发送这个参数,按哪个标贴就报哪个标贴Mac,按主机报警则不会发送",defaultValue = "")
            @RequestParam(value = "label_mac",required = false) String label_mac,
            @ApiParam(name="time_begin",required = false,value="发生时间YYYY-MM-DD HH:mm:SS",defaultValue = "1")
            @RequestParam(value = "time_begin",required = false) String time_begin,
            HttpServletRequest request) {
        try {
            long startTime=System.currentTimeMillis();
            String paraString = JSON.toJSONString(request.getParameterMap());
            String url = "device/aqgsos?imei="+imei+"&label_mac="+label_mac+"&time_begin="+time_begin;
            String result = aqgService.aqgForward(url);
            long endTime=System.currentTimeMillis();
            logger.info("爱牵挂设备sos数据接收,请求参数:"+paraString+" "+(endTime-startTime)+"ms; 响应:"+result);
            return success();
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1,"Device data incoming failure");
        }
    }
    @ApiOperation("爱牵挂设备开关机数据接收")
    @RequestMapping(value = "aqgSwitch", method = {RequestMethod.POST,RequestMethod.GET})
    public String aqgSwitch(
            @ApiParam(name="imei",required = false,value="15位设备唯一序号",defaultValue = "")
            @RequestParam(value = "imei",required = false) String imei,
            @ApiParam(name="time_begin",required = false,value="发生时间YYYY-MM-DD HH:mm:SS",defaultValue = "1")
            @RequestParam(value = "time_begin",required = false) String time_begin,
            @ApiParam(name="remaining_power",required = false,value="剩余电量(%) ",defaultValue = "")
            @RequestParam(value = "remaining_power",required = false) String remaining_power,
            @ApiParam(name="type",required = false,value=" 开/关机类型  0开机 2普通  3低电 ",defaultValue = "")
            @RequestParam(value = "type",required = false) String type,
            HttpServletRequest request) {
        try {
            long startTime=System.currentTimeMillis();
            String paraString = JSON.toJSONString(request.getParameterMap());
            String url = "device/aqgSwitch?imei="+imei+"&remaining_power="+remaining_power+"&time_begin="+time_begin+"&type="+type;
            String result = aqgService.aqgForward(url);
            long endTime=System.currentTimeMillis();
            logger.info("爱牵挂设备开关机数据接收,请求参数:"+paraString+" "+(endTime-startTime)+"ms; 响应:"+result);
            return success();
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1,"Device data incoming failure");
        }
    }
    @ApiOperation("爱牵挂设备消息通知数据接收")
    @RequestMapping(value = "pushdata", method = {RequestMethod.POST,RequestMethod.GET})
    public String pushdata(
            @ApiParam(name="type",required = false,value="根据type来定义给用户推送提示  type=1 SOS,type=5 设备低电, 其他类型非本机型所有",defaultValue = "")
            @RequestParam(value = "type",required = false) int type,
            @ApiParam(name="deviceid",required = false,value="15位设备唯一序号",defaultValue = "")
            @RequestParam(value = "deviceid",required = false) String deviceid,
            @ApiParam(name="communityid",required = false,value="机构ID",defaultValue = "1")
            @RequestParam(value = "communityid",required = false) String communityid,
            HttpServletRequest request) {
        try {
            long startTime=System.currentTimeMillis();
            String paraString = JSON.toJSONString(request.getParameterMap());
            String url = "device/pushdata?deviceid="+deviceid+"&communityid="+communityid+"&type="+type;
            String result = aqgService.aqgForward(url);
            long endTime=System.currentTimeMillis();
            logger.info("爱牵挂设备消息通知数据接收,请求参数:"+paraString+" "+(endTime-startTime)+"ms; 响应:"+result);
            return success();
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1,"Device data incoming failure");
        }
    }
    @ApiOperation("爱牵挂位置接收")
    @RequestMapping(value = "byLocation", method = {RequestMethod.POST,RequestMethod.GET})
    public String byLocation(
            @ApiParam(name="imei",required = false,value="15位设备唯一序号",defaultValue = "")
            @RequestParam(value = "imei",required = true) String imei,
            @ApiParam(name="time_begin",required = false,value="发生时间YYYY-MM-DD HH:mm:SS",defaultValue = "1")
            @RequestParam(value = "time_begin",required = false) String time_begin,
            @ApiParam(name="is_reply",required = false,value="是否为响应")
            @RequestParam(value = "is_reply",required = false) boolean is_reply,
            @ApiParam(name="is_track",required = false,value="是否轨迹")
            @RequestParam(value = "is_track",required = false) boolean is_track,
            @ApiParam(name="city",required = false,value="城市")
            @RequestParam(value = "city",required = false) String city,
            @ApiParam(name="address",required = false,value="地址")
            @RequestParam(value = "address",required = false) String address,
            @ApiParam(name="lon",required = false,value="经度")
            @RequestParam(value = "lon",required = false) double lon,
            @ApiParam(name="lat",required = false,value="纬度")
            @RequestParam(value = "lat",required = false) double lat,
            @ApiParam(name="type",required = false,value="类型  0:Gps定位; 1:基站定位")
            @RequestParam(value = "type",required = false) String type,
            HttpServletRequest request){
        try {
            long startTime=System.currentTimeMillis();
            String paraString = JSON.toJSONString(request.getParameterMap());
            String url = "device/byLocation?imei="+imei+"&is_reply="+is_reply+"&is_track="+is_track+"&city="+city
                    +"&address="+address+"&lon="+lon+"&lat="+lat+"&time_begin="+time_begin+"&type="+type;
            String result = aqgService.aqgForward(url);
            long endTime=System.currentTimeMillis();
            logger.info("爱牵挂位置接收,请求参数:"+paraString+" "+(endTime-startTime)+"ms; 响应:"+result);
            return success();
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1,"Device data incoming failure");
        }
    }
    @ApiOperation("爱牵挂心率数据接收")
    @RequestMapping(value = "byHeartRate",  method = {RequestMethod.POST,RequestMethod.GET})
    public String byHeartRate(
            @ApiParam(name = "imei", value = "15位设备唯一序号")
            @RequestParam(value = "imei",required = true)String imei,
            @ApiParam(name = "time_begin", value = "发生时间YYYY-MM-DD HH:mm:SS")
            @RequestParam(value = "time_begin",required = false)String time_begin,
            @ApiParam(name = "heartrate", value = "心率")
            @RequestParam(value = "heartrate",required = false)int heartrate,
            @ApiParam(name = "theshold_heartrate_h", value = "心率阈值上限")
            @RequestParam(value = "theshold_heartrate_h",required = false)int theshold_heartrate_h,
            @ApiParam(name = "theshold_heartrate_l", value = "心率阈值下限")
            @RequestParam(value = "theshold_heartrate_l",required = false)int theshold_heartrate_l,
            HttpServletRequest request){
        try {
            long startTime=System.currentTimeMillis();
            String paraString = JSON.toJSONString(request.getParameterMap());
            String url = "device/byHeartRate?imei="+imei+"&heartrate="+heartrate+"&time_begin="+time_begin+"&theshold_heartrate_h="+theshold_heartrate_h+"&theshold_heartrate_l="+theshold_heartrate_l;
            String result = aqgService.aqgForward(url);
            long endTime=System.currentTimeMillis();
            logger.info("爱牵挂心率数据接收,请求参数:"+paraString+" "+(endTime-startTime)+"ms; 响应:"+result);
            return success();
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1,"Device data incoming failure");
        }
    }
    @ApiOperation("爱牵挂血压数据接收")
    @RequestMapping(value = "byBloodPressure",  method = {RequestMethod.POST,RequestMethod.GET})
    public String byBloodPressure(
            @ApiParam(name = "imei", value = "15位设备唯一序号", required = true)
            @RequestParam(value = "imei",required = true)String imei,
            @ApiParam(name = "time_begin", value = "发生时间YYYY-MM-DD HH:mm:SS", required = true)
            @RequestParam(value = "time_begin",required = false)String time_begin,
            @ApiParam(name = "dbp", value = "舒张压", required = true)
            @RequestParam(value = "dbp",required = false)int dbp,
            @ApiParam(name = "dbp_l", value = "舒张压报警下限", required = true)
            @RequestParam(value = "dbp_l",required = false)int dbp_l,
            @ApiParam(name = "sbp", value = "收缩压", required = true)
            @RequestParam(value = "sbp",required = false)int sbp,
            @ApiParam(name = "sbp_h", value = "收缩压报警上限", required = true)
            @RequestParam(value = "sbp_h",required = false)int sbp_h,
            HttpServletRequest request){
        try {
            long startTime=System.currentTimeMillis();
            String paraString = JSON.toJSONString(request.getParameterMap());
            String url = "device/byBloodPressure?imei="+imei+"&dbp="+dbp+"&time_begin="+time_begin+"&dbp_l="+dbp_l+"&sbp="+sbp+"&sbp_h="+sbp_h;
            String result = aqgService.aqgForward(url);
            long endTime=System.currentTimeMillis();
            logger.info("爱牵挂血压数据接收,请求参数:"+paraString+" "+(endTime-startTime)+"ms; 响应:"+result);
            return success();
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1,"Device data incoming failure");
        }
    }
    @ApiOperation("爱牵挂跌倒数据接收")
    @RequestMapping(value = "byFall",  method = {RequestMethod.POST,RequestMethod.GET})
    public String byFall(
            @ApiParam(name = "imei", value = "15位设备唯一序号", required = true)
            @RequestParam(value = "imei",required = true)String imei,
            @ApiParam(name = "time_begin", value = "发生时间YYYY-MM-DD HH:mm:SS", required = true)
            @RequestParam(value = "time_begin",required = false)String time_begin,
            @ApiParam(name = "city", value = "城市", required = false)
            @RequestParam(value = "city",required = false)String city,
            @ApiParam(name = "address", value = "地址", required = false)
            @RequestParam(value = "address",required = false)String address,
            @ApiParam(name = "lon", value = "经度", required = false)
            @RequestParam(value = "lon",required = false)double lon,
            @ApiParam(name = "lat", value = "纬度", required = false)
            @RequestParam(value = "lat",required = false)double lat,
            @ApiParam(name = "type", value = "纬度", required = false)
            @RequestParam(value = "type",required = false)String type,
            HttpServletRequest request){
        try {
            long startTime=System.currentTimeMillis();
            String paraString = JSON.toJSONString(request.getParameterMap());
            String url = "device/byFall?imei="+imei+"&city="+city+"&address="+address+"&lon="+lon+"&lat="+lat+"&time_begin="+time_begin+"&type="+type;
            String result = aqgService.aqgForward(url);
            long endTime=System.currentTimeMillis();
            logger.info("爱牵挂跌倒数据接收,请求参数:"+paraString+" "+(endTime-startTime)+"ms; 响应:"+result);
            return success();
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1,"Device data incoming failure");
        }
    }
    @ApiOperation("设备步数接收")
    @RequestMapping(value = "bySteps",  method = {RequestMethod.POST,RequestMethod.GET})
    public String bySteps(
            @ApiParam(name="imei",required = false,value="15位设备唯一序号",defaultValue = "")
            @RequestParam(value = "imei",required = true) String imei,
            @ApiParam(name="time_begin",required = false,value="发生时间YYYY-MM-DD HH:mm:SS")
            @RequestParam(value = "time_begin",required = false) String time_begin,
            @ApiParam(name="value",required = false,value="步数")
            @RequestParam(value = "value",required = false) int value,
            HttpServletRequest request) {
        try {
            long startTime=System.currentTimeMillis();
            String paraString = JSON.toJSONString(request.getParameterMap());
            String url = "device/bySteps?imei="+imei+"&value="+value+"&time_begin="+time_begin;
            String result = aqgService.aqgForward(url);
            long endTime=System.currentTimeMillis();
            logger.info("设备步数接收,请求参数:"+paraString+" "+(endTime-startTime)+"ms; 响应:"+result);
            return success();
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1,"Device data incoming failure");
        }
    }
    /*******************************************睡眠带begin****************************************************************/
    @ApiOperation("爱牵挂-睡眠带睡眠接收")
    @RequestMapping(value = "bySleep",  method = {RequestMethod.POST,RequestMethod.GET})
    public String bySleep(
            @ApiParam(name="device",required = false,value="睡眠带MAC地址",defaultValue = "")
            @RequestParam(value = "device",required = true) String device,
            @ApiParam(name="time_begin",required = false,value="发生时间YYYY-MM-DD HH:mm:SS")
            @RequestParam(value = "time_begin",required = false) String time_begin,
            @ApiParam(name="heartrate",required = false,value="心率数据(离床或翻身测量失败时为0)")
            @RequestParam(value = "heartrate",required = false) String heartrate,
            @ApiParam(name="breath",required = false,value="呼吸率(离床或翻身测量失败时为0)")
            @RequestParam(value = "breath",required = false) String breath,
            @ApiParam(name="bed_status",required = false,value="在离床状态(0 离床,1 在床) ")
            @RequestParam(value = "bed_status",required = false) String bed_status,
            @ApiParam(name="turn_over",required = false,value="翻身状态(0 没翻身,1 在翻身)")
            @RequestParam(value = "turn_over",required = false)String turn_over,
            @ApiParam(name="is_warn",required = false,value="是否为离床报警(0 否 默认,1 是)")
            @RequestParam(value = "is_warn",required = false)String is_warn,
            HttpServletRequest request) {
        try {
            long startTime=System.currentTimeMillis();
            String paraString = JSON.toJSONString(request.getParameterMap());
            String url = "device/bySleep?device="+device+"&heartrate="+heartrate+"&time_begin="+time_begin
                    +"&breath="+breath+"&bed_status="+bed_status+"&turn_over="+turn_over+"&is_warn="+is_warn;
            String result = aqgService.aqgForward(url);
            long endTime=System.currentTimeMillis();
            logger.info("爱牵挂-睡眠带睡眠接收,请求参数:"+paraString+" "+(endTime-startTime)+"ms; 响应:"+result);
            return success();
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1,"Device data incoming failure");
        }
    }
    @ApiOperation("爱牵挂-睡眠带睡眠报告接收")
    @RequestMapping(value = "bySleepReport",  method = {RequestMethod.POST,RequestMethod.GET})
    public String bySleep(
            @ApiParam(name="device",required = false,value="睡眠带MAC地址",defaultValue = "")
            @RequestParam(value = "device",required = true) String device,
            @ApiParam(name="date",required = false,value="产生日期 YYYYMMDD")
            @RequestParam(value = "date",required = false) String date,
            @ApiParam(name="fallasleep",required = false,value="入睡时长 (分钟)")
            @RequestParam(value = "fallasleep",required = false) String fallasleep,
            @ApiParam(name="sleepTime",required = false,value="睡眠时长 (分钟)")
            @RequestParam(value = "sleepTime",required = false) String sleepTime,
            @ApiParam(name="restTime",required = false,value="休息时长 (分钟)")
            @RequestParam(value = "restTime",required = false) String restTime,
            @ApiParam(name="bed_status",required = false,value="在离床状态(0 离床,1 在床) ")
            @RequestParam(value = "bed_status",required = false) String bed_status,
            @ApiParam(name="awakeTime",required = false,value="清醒时长 (分钟)")
            @RequestParam(value = "awakeTime",required = false)String awakeTime,
            @ApiParam(name="lightTime",required = false,value="浅睡时长 (分钟)")
            @RequestParam(value = "lightTime",required = false)String lightTime,
            @ApiParam(name="remTime",required = false,value="rem时长  (分钟)")
            @RequestParam(value = "remTime",required = false)String remTime,
            @ApiParam(name="deepTime",required = false,value="深睡时长 (分钟) ")
            @RequestParam(value = "deepTime",required = false)String deepTime,
            @ApiParam(name="bucket",required = false,value="睡眠时段 ['18:00-18:21', '21:30-07:09'] ")
            @RequestParam(value = "bucket",required = false)String[] bucket,
            @ApiParam(name="avghr",required = false,value="平均心率 ")
            @RequestParam(value = "avghr",required = false)String avghr,
            @ApiParam(name="avgbr",required = false,value="平均呼吸率 ")
            @RequestParam(value = "avgbr",required = false)String avgbr,
            @ApiParam(name="awakePer",required = false,value="清醒百分比")
            @RequestParam(value = "awakePer",required = false)String awakePer,
            @ApiParam(name="remPer",required = false,value="rem百分比")
            @RequestParam(value = "remPer",required = false)String remPer,
            @ApiParam(name="lightPer",required = false,value="浅睡百分比")
            @RequestParam(value = "lightPer",required = false)String lightPer,
            @ApiParam(name="deepPer",required = false,value="深睡百分比")
            @RequestParam(value = "deepPer",required = false)String deepPer,
            @ApiParam(name="efficiency",required = false,value="睡眠效率")
            @RequestParam(value = "efficiency",required = false)String efficiency,
            @ApiParam(name="score",required = false,value="睡眠评分 <=0无睡眠数据,<60待改善,<70一般,<85良好 其他,非常好")
            @RequestParam(value = "score",required = false)String score,
            HttpServletRequest request) {
        try {
            long startTime=System.currentTimeMillis();
            String paraString = JSON.toJSONString(request.getParameterMap());
            String url = "device/bySleep?device="+device+"&date="+date+"&fallasleep="+fallasleep+"&sleepTime="+sleepTime
                    +"&restTime="+restTime+"&bed_status="+bed_status+"&awakeTime="+awakeTime+"&lightTime="+lightTime
                    +"&remTime="+remTime+"&deepTime="+deepTime+"&bucket="+bucket+"&avghr="+avghr
                    +"&avgbr="+avgbr+"&awakePer="+awakePer+"&remPer="+remPer+"&lightPer="+lightPer
                    +"&deepPer="+deepPer+"&efficiency="+efficiency+"&score="+score;
            String result = aqgService.aqgForward(url);
            long endTime=System.currentTimeMillis();
            logger.info("爱牵挂-睡眠带睡眠报告接收,请求参数:"+paraString+" "+(endTime-startTime)+"ms; 响应:"+result);
            return success();
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1,"Device data incoming failure");
        }
    }
    @ApiOperation("爱牵挂-睡眠带wifi在线状态接收")
    @RequestMapping(value = "byOnlineStatus",  method = {RequestMethod.POST,RequestMethod.GET})
    public String byOnlineStatus(
            @ApiParam(name="device",required = false,value="睡眠带MAC地址",defaultValue = "")
            @RequestParam(value = "device",required = true) String device,
            @ApiParam(name="onlinestatu",required = false,value="在线状态(0不在线,1在线)")
            @RequestParam(value = "onlinestatu",required = false) String onlinestatu,
            @ApiParam(name="time_begin",required = false,value="发生时间YYYY-MM-DD HH:mm:SS")
            @RequestParam(value = "time_begin",required = false) String time_begin,
            HttpServletRequest request) {
        try {
            long startTime=System.currentTimeMillis();
            String paraString = JSON.toJSONString(request.getParameterMap());
            String url = "device/byOnlineStatus?device="+device+"&onlinestatu="+onlinestatu+"&time_begin="+time_begin;
            String result = aqgService.aqgForward(url);
            long endTime=System.currentTimeMillis();
            logger.info("爱牵挂-睡眠带wifi在线状态接收,请求参数:"+paraString+" "+(endTime-startTime)+"ms; 响应:"+result);
            return success();
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1,"Device data incoming failure");
        }
    }
    /*******************************************睡眠带end****************************************************************/
    /**
     * 返回接口处理结果
     *
     * @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);
            map.put("success", false);
            return mapper.writeValueAsString(map);
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }
    /**
     * 接口处理成功
     * @return
     */
    public String success() {
        try {
            Map<Object, Object> map = new HashMap<Object, Object>();
            ObjectMapper mapper = new ObjectMapper();
            map.put("status", 200);
            map.put("success", true);
            return mapper.writeValueAsString(map);
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }
    public String write(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);
            map.put("success", true);
            return mapper.writeValueAsString(map);
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }
}

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

@ -0,0 +1,63 @@
package com.yihu.jw.care.service;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
import java.net.URLDecoder;
/**
 * Created with IntelliJ IDEA.
 * 爱牵挂转发
 * @Author: yeshijie
 * @Date: 2021/8/31
 * @Description:
 */
@Service
public class AqgService {
    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){
        String res = "";
        try {
            ResponseEntity<String> responseEntity = null;
            logger.info("推送爱牵挂数据给医养项目url="+ baseUrl+url);
            responseEntity = restTemplate.getForEntity(baseUrl+url, String.class);
            res = responseEntity.getBody();
            logger.info("推送爱牵挂数据给医养项目res="+ res);
        }catch (Exception e){
            e.printStackTrace();
        }
        return res;
    }
}

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

@ -0,0 +1,97 @@
#通用的配置不用区分环境变量
server:
  port: 10303
spring:
  datasource:
    max-active: 200
    max-idle: 200 #最大空闲连接
    min-idle: 10 #最小空闲连接
    validation-query-timeout: 20
    log-validation-errors: true
    validation-interval: 60000 #避免过度验证,保证验证不超过这个频率——以毫秒为单位。如果一个连接应该被验证,但上次验证未达到指定间隔,将不再次验证。
    validation-query: SELECT 1 #SQL 查询, 用来验证从连接池取出的连接, 在将连接返回给调用者之前。 如果指定, 则查询必须是一个SQL SELECT 并且必须返回至少一行记录
    test-on-borrow: true #指明是否在从池中取出连接前进行检验, 如果检验失败, 则从池中去除连接并尝试取出另一个。注意: 设置为true 后如果要生效,validationQuery 参数必须设置为非空字符串
    test-on-return: true #指明是否在归还到池中前进行检验 注意: 设置为true 后如果要生效validationQuery 参数必须设置为非空字符串
    idle-timeout: 20000
    connection-test-query: SELECT 1
    num-tests-per-eviction-run: 200 #在每次空闲连接回收器线程(如果有)运行时检查的连接数量,最好和maxActive
    test-while-idle: true #指明连接是否被空闲连接回收器(如果有)进行检验,如果检测失败,则连接将被从池中去除
    min-evictable-idle-time-millis: 3600000 #连接池中连接,在时间段内一直空闲,被逐出连接池的时间(1000*60*60),以毫秒为单位
    time-between-eviction-runs-millis: 300000 #在空闲连接回收器线程运行期间休眠的时间值,以毫秒为单位,一般比minEvictableIdleTimeMillis小
  http:
    multipart:
      max-file-size: 30MB
      max-request-size: 100MB
#      location: D:/work/soft_dev/IdeaWorkSpace/wlyy2.0/svr/svr-patient/temp_file/
#      resolve-lazily: true
es:
  index:
    servicePackLog: base_service_package_log
  type:
    servicePackLog: base_service_package_log
fast-dfs:
  connect-timeout: 2 #链接超时时间
  network-timeout: 30
  charset: ISO8859-1 #编码
  http:
    tracker-http-port: 80
    anti-steal-token: no
    secret-key: FastDFS1234567890
  pool: #连接池大小
    init-size: 5
    max-size: 20
    wait-time: 500
configDefault: # 默认配置
  saasId: xmjkzl_saasId
---
spring:
  profiles: jwdev
  datasource:
    driver-class-name: com.mysql.jdbc.Driver
    url: jdbc:mysql://172.26.0.114/base?useUnicode:true&characterEncoding=utf-8&autoReconnect=true&useSSL=false
    username: root
    password: jkzlehr
#  elasticsearch:
#    cluster-name: jkzl #集群名 默认elasticsearch
#    cluster-nodes: 172.26.0.115:9300,172.26.0.115:9300 #配置es节点信息,逗号分隔,如果没有指定,则启动ClientNode
#    client-transport-sniff: false
#    jest:
#      uris: http://172.26.0.112:9200,http://172.26.0.112:9200
#      connection-timeout: 60000 # Connection timeout in milliseconds.
#      multi-threaded: true # Enable connection requests from multiple execution threads.
base:
  url: http://172.17.110.212:10020/
  hospitalUrl: http://172.26.0.107:10022/
cloudCare:
  deviceUrl: http://172.26.0.107:9112/
---
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
#  elasticsearch:
#    cluster-name: jkzl #集群名 默认elasticsearch
#    cluster-nodes: 172.26.0.115:9300,172.26.0.115:9300 #配置es节点信息,逗号分隔,如果没有指定,则启动ClientNode
#    client-transport-sniff: false
#    jest:
#      uris: http://172.26.0.112:9200,http://172.26.0.112:9200
#      connection-timeout: 60000 # Connection timeout in milliseconds.
#      multi-threaded: true # Enable connection requests from multiple execution threads.
base:
  url: http://172.17.110.212:10020/
  hospitalUrl: http://172.26.0.107:10022/
cloudCare:
  deviceUrl: http://172.26.0.107:9112/