浏览代码

Merge branch 'dev' of http://192.168.1.220:10080/Amoy2/wlyy2.0 into dev

wangjun 4 年之前
父节点
当前提交
a903fe69c4
共有 23 个文件被更改,包括 1823 次插入116 次删除
  1. 3 3
      common/common-entity/src/main/java/com/yihu/jw/entity/care/device/PatientDevice.java
  2. 1 1
      common/common-entity/src/main/java/com/yihu/jw/entity/care/device/DevicePatientHealthIndex.java
  3. 32 0
      common/common-util/src/main/java/com/yihu/jw/util/http/HttpClientUtil.java
  4. 23 23
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/device/PatientDeviceDao.java
  5. 2 2
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/device/DoctorDeviceController.java
  6. 5 5
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/device/PatientDeviceController.java
  7. 26 26
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/device/DeviceDetailService.java
  8. 48 48
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/device/PatientDeviceService.java
  9. 2 2
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/device/PatientHealthIndexService.java
  10. 2 6
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/security/SecurityMonitoringOrderService.java
  11. 230 0
      svr/svr-cloud-device/pom.xml
  12. 3 0
      svr/svr-cloud-device/readme.MD
  13. 30 0
      svr/svr-cloud-device/src/main/java/com/yihu/SvrCloudDeviceApplication.java
  14. 29 0
      svr/svr-cloud-device/src/main/java/com/yihu/jw/care/config/AqgConfig.java
  15. 42 0
      svr/svr-cloud-device/src/main/java/com/yihu/jw/care/config/AsyncConfig.java
  16. 21 0
      svr/svr-cloud-device/src/main/java/com/yihu/jw/care/dao/device/DeviceDao.java
  17. 16 0
      svr/svr-cloud-device/src/main/java/com/yihu/jw/care/dao/device/DeviceDetailDao.java
  18. 70 0
      svr/svr-cloud-device/src/main/java/com/yihu/jw/care/dao/device/DevicePatientHealthIndexDao.java
  19. 54 0
      svr/svr-cloud-device/src/main/java/com/yihu/jw/care/dao/device/PatientDeviceDao.java
  20. 416 0
      svr/svr-cloud-device/src/main/java/com/yihu/jw/care/endpoint/DeviceController.java
  21. 381 0
      svr/svr-cloud-device/src/main/java/com/yihu/jw/care/service/DeviceService.java
  22. 364 0
      svr/svr-cloud-device/src/main/resources/application.yml
  23. 23 0
      svr/svr-cloud-device/src/main/resources/banner.txt

+ 3 - 3
common/common-entity/src/main/java/com/yihu/jw/entity/care/device/PatientDevice.java

@ -9,7 +9,7 @@ import java.util.Date;
@Entity
@Table(name = "wlyy_patient_device")
@SequenceGenerator(name="id_generated", sequenceName="wlyy_patient_device")
public class PatientDevice extends IdEntity {
public class DevicePatientDevice extends IdEntity {
    // 设备ID
    private Long deviceId;
@ -260,7 +260,7 @@ public class PatientDevice extends IdEntity {
        this.address = address;
    }
    public PatientDevice(String address, Date czrq, String userIdcard, String deviceSn, Long deviceId) {
    public DevicePatientDevice(String address, Date czrq, String userIdcard, String deviceSn, Long deviceId) {
        this.address = address;
        this.czrq = czrq;
        this.userIdcard = userIdcard;
@ -268,7 +268,7 @@ public class PatientDevice extends IdEntity {
        this.deviceId = deviceId;
    }
    public PatientDevice() {
    public DevicePatientDevice() {
    }
    
    public Integer getApplyStatus() {

+ 1 - 1
common/common-entity/src/main/java/com/yihu/jw/entity/care/device/DevicePatientHealthIndex.java

@ -35,7 +35,7 @@ public class DevicePatientHealthIndex extends IdEntity {
	private String value6;
	// 睡前
	private String value7;
	// 健康指标类型(1血糖,2血压,3体重/身高/BMI,4腰围)
	// 健康指标类型(1血糖,2血压,3体重/身高/BMI,4腰围,5心率)
	private Integer type;
	// 记录时间

+ 32 - 0
common/common-util/src/main/java/com/yihu/jw/util/http/HttpClientUtil.java

@ -1,5 +1,6 @@
package com.yihu.jw.util.http;
import com.alibaba.fastjson.JSONObject;
import org.apache.http.Consts;
import org.apache.http.HttpEntity;
import org.apache.http.NameValuePair;
@ -14,8 +15,10 @@ import org.apache.http.impl.client.HttpClients;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Component;
import org.springframework.util.MultiValueMap;
import org.springframework.web.client.RestTemplate;
import java.io.*;
@ -485,4 +488,33 @@ public class HttpClientUtil {
        return null;
    }
    /**
     * 爱牵挂请求
     * @param url
     * @param params
     * @return
     */
    public org.springframework.http.HttpEntity<JSONObject> cookiePostHttp(String url,MultiValueMap<String, String> params){
        RestTemplate restTemplate = new RestTemplate();
        HttpHeaders headers = new HttpHeaders();
        MediaType type = MediaType.parseMediaType("application/x-www-form-urlencoded");
        headers.setContentType(type);
        headers.add("Accept", MediaType.APPLICATION_JSON.toString());
        org.springframework.http.HttpEntity<MultiValueMap<String, String>> request = new org.springframework.http.HttpEntity<>(params, headers);
        org.springframework.http.HttpEntity<JSONObject> response = restTemplate.exchange(url, HttpMethod.POST, request, JSONObject.class);
        return response;
    }
//    public static void main(String[] args) {
//        JSONObject param = new JSONObject();
//        param.put("username","13559485270");
//        param.put("password","zjxl@2021");
//        MultiValueMap<String, String> map = new LinkedMultiValueMap<>();
//        map.add("username","13559485270");
//        map.add("password","zjxl@2021");
//        org.springframework.http.HttpEntity<JSONObject> response = cookiePostHttp("http://api.aiqiangua.com:8888/api/auth/login",map);
//        org.springframework.http.HttpHeaders responseHeaders = response.getHeaders();
//        System.out.println("11111");
//    }
}

+ 23 - 23
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/device/PatientDeviceDao.java

@ -1,6 +1,6 @@
package com.yihu.jw.care.dao.device;
import com.yihu.jw.entity.care.device.PatientDevice;
import com.yihu.jw.entity.care.device.DevicePatientDevice;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
@ -9,46 +9,46 @@ import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
public interface PatientDeviceDao extends PagingAndSortingRepository<PatientDevice, Long>, JpaSpecificationExecutor<PatientDevice> {
public interface PatientDeviceDao extends PagingAndSortingRepository<DevicePatientDevice, Long>, JpaSpecificationExecutor<DevicePatientDevice> {
    @Query("select a from PatientDevice a where a.user = ?1 ")
    Iterable<PatientDevice> findByUser(String user);
    @Query("select a from DevicePatientDevice a where a.user = ?1 ")
    Iterable<DevicePatientDevice> findByUser(String user);
    @Query("select a from PatientDevice a where a.user = ?1 ")
    List<PatientDevice> findByPatient(String user);
    @Query("select a from DevicePatientDevice a where a.user = ?1 ")
    List<DevicePatientDevice> findByPatient(String user);
    @Query("select a from PatientDevice a where a.user = ?1 and a.del=0 and a.deviceName like '%药盒%'")
    List<PatientDevice> findByPatientAndDel(String user);
    @Query("select a from DevicePatientDevice a where a.user = ?1 and a.del=0 and a.deviceName like '%药盒%'")
    List<DevicePatientDevice> findByPatientAndDel(String user);
    @Query("select a from PatientDevice a where a.user = ?1 and a.deviceSn=?2 ")
    List<PatientDevice> findByPatientAndDeviceSn(String user, String deviceSn);
    @Query("select a from DevicePatientDevice a where a.user = ?1 and a.deviceSn=?2 ")
    List<DevicePatientDevice> findByPatientAndDeviceSn(String user, String deviceSn);
    List<PatientDevice> findByUser(String user, Pageable pageRequest);
    List<DevicePatientDevice> findByUser(String user, Pageable pageRequest);
    List<PatientDevice> findByUserAndDoctor(String user, String doctor, Pageable pageRequest);
    List<DevicePatientDevice> findByUserAndDoctor(String user, String doctor, Pageable pageRequest);
    List<PatientDevice> findByDeviceSnAndCategoryCode(String deviceSn, String categoryCode);
    List<DevicePatientDevice> findByDeviceSnAndCategoryCode(String deviceSn, String categoryCode);
    PatientDevice findByDeviceSnAndCategoryCodeAndUserType(String deviceSn, String categoryCode, String userType);
    DevicePatientDevice findByDeviceSnAndCategoryCodeAndUserType(String deviceSn, String categoryCode, String userType);
    PatientDevice findByDeviceIdAndDeviceSnAndUserType(Long deviceId, String deviceSn, String userType);
    DevicePatientDevice findByDeviceIdAndDeviceSnAndUserType(Long deviceId, String deviceSn, String userType);
    PatientDevice findByDeviceSnAndUserType(String deviceSn, String userType);
    DevicePatientDevice findByDeviceSnAndUserType(String deviceSn, String userType);
    @Query("select pd from PatientDevice pd where pd.deviceSn = ?1 and pd.del=0")
    List<PatientDevice> findByDeviceSn(String deviceSn);
    @Query("select pd from DevicePatientDevice pd where pd.deviceSn = ?1 and pd.del=0")
    List<DevicePatientDevice> findByDeviceSn(String deviceSn);
    //更换患者绑定的血糖仪
    @Modifying
    @Query("update PatientDevice t set t.deviceSn = ?3 , t.userType = ?4,t.sim=?5,t.hospital=?6,t.hospitalName=?7,t.checkDoctorName=?8 where t.user = ?1 and t.deviceSn = ?2 ")
    @Query("update DevicePatientDevice t set t.deviceSn = ?3 , t.userType = ?4,t.sim=?5,t.hospital=?6,t.hospitalName=?7,t.checkDoctorName=?8 where t.user = ?1 and t.deviceSn = ?2 ")
    int updatePatientDevice(String user, String deviceSN, String newDeviceSN, String userType, String sim, String hospital, String hospitalName, String checkDoctorName);
    @Query("select a from PatientDevice a")
    List<PatientDevice> findAll();
    @Query("select a from DevicePatientDevice a")
    List<DevicePatientDevice> findAll();
    @Query("select a from PatientDevice a where a.user=?1 and a.del=0")
    List<PatientDevice> findAllByUser(String user);
    @Query("select a from DevicePatientDevice a where a.user=?1 and a.del=0")
    List<DevicePatientDevice> findAllByUser(String user);
}

+ 2 - 2
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/device/DoctorDeviceController.java

@ -7,7 +7,7 @@ import com.yihu.jw.care.service.device.DeviceDetailService;
import com.yihu.jw.care.service.device.PatientDeviceService;
import com.yihu.jw.care.util.CommonUtil;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.entity.care.device.PatientDevice;
import com.yihu.jw.entity.care.device.DevicePatientDevice;
import com.yihu.jw.patient.dao.BasePatientDao;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@ -80,7 +80,7 @@ public class DoctorDeviceController extends BaseController {
	public String getPatientDeviceInfo(@ApiParam(name="id",value="患者设备ID",defaultValue = "34")
									   @RequestParam(value="id",required = true) String id) {
		try {
			PatientDevice device = patientDeviceService.findById(id);
			DevicePatientDevice device = patientDeviceService.findById(id);
			return write(200, "查询成功", "data", device);
		} catch (Exception ex) {

+ 5 - 5
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/device/PatientDeviceController.java

@ -7,7 +7,7 @@ import com.yihu.jw.care.service.device.DeviceDetailService;
import com.yihu.jw.care.service.device.PatientDeviceService;
import com.yihu.jw.care.service.device.PatientHealthIndexService;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.care.device.PatientDevice;
import com.yihu.jw.entity.care.device.DevicePatientDevice;
import com.yihu.jw.patient.dao.BasePatientDao;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@ -79,7 +79,7 @@ public class PatientDeviceController extends BaseController {
    public String saveDevice(@ApiParam(name = "json", value = "设备数据json", defaultValue = "{\"deviceId\": \"3\",\"deviceName\": \"血压计-优瑞恩\",\"deviceSn\": \"7052169111\",\"categoryCode\": \"1\",\"userType\": \"-1\"}")
                             @RequestParam(value = "json", required = true) String json) {
        try {
            PatientDevice device = objectMapper.readValue(json, PatientDevice.class);
            DevicePatientDevice device = objectMapper.readValue(json, DevicePatientDevice.class);
            // 设置患者标识
            device.setUser(getRepUID());
            //患者和设备是否首绑
@ -122,7 +122,7 @@ public class PatientDeviceController extends BaseController {
                                     @ApiParam(name = "pagesize", value = "每页条数", defaultValue = "10")
                                     @RequestParam(value = "pagesize", required = true) int pagesize) {
        try {
            Page<PatientDevice> list = patientDeviceService.findByPatient(getRepUID(), id, pagesize);
            Page<DevicePatientDevice> list = patientDeviceService.findByPatient(getRepUID(), id, pagesize);
            return write(200, "查询成功", "data", list);
        } catch (Exception ex) {
@ -139,7 +139,7 @@ public class PatientDeviceController extends BaseController {
                                       @RequestParam(value = "id", required = true) String id) {
        try {
            Map mapList = new HashMap();
            PatientDevice device = patientDeviceService.findById(id);
            DevicePatientDevice device = patientDeviceService.findById(id);
            mapList.put("device", device);
            return write(200, "查询成功", "data", mapList);
        } catch (Exception ex) {
@ -180,7 +180,7 @@ public class PatientDeviceController extends BaseController {
    public String delete(@ApiParam(name = "id", value = "删除设备关联ID")
                         @RequestParam(value = "id", required = true) String id) {
        try {
            PatientDevice pd = patientDeviceService.findById(id);
            DevicePatientDevice pd = patientDeviceService.findById(id);
            if (pd != null) {
                if (!StringUtils.equals(pd.getUser(), getRepUID())) {
                    return error(-1, "只允许删除自己的设备!");

+ 26 - 26
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/device/DeviceDetailService.java

@ -10,7 +10,7 @@ import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.care.device.Device;
import com.yihu.jw.entity.care.device.DeviceDetail;
import com.yihu.jw.entity.care.device.PatientDevice;
import com.yihu.jw.entity.care.device.DevicePatientDevice;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.mysql.query.BaseJpaService;
@ -47,14 +47,14 @@ public class DeviceDetailService extends BaseJpaService<DeviceDetail, DeviceDeta
	/**
	 * 绑定时更新设备表中的信息
	 * @param patientDevice
	 * @param devicePatientDevice
	 * @param grantTime
	 * @param isFirst
	 * @throws Exception
	 */
	@Transactional
	public void updateAfterBinding(PatientDevice patientDevice, Date grantTime, boolean isFirst)throws Exception{
		DeviceDetail deviceDetail = deviceDetailDao.findBySn(patientDevice.getDeviceSn());
	public void updateAfterBinding(DevicePatientDevice devicePatientDevice, Date grantTime, boolean isFirst)throws Exception{
		DeviceDetail deviceDetail = deviceDetailDao.findBySn(devicePatientDevice.getDeviceSn());
		int bind = deviceDetail.getIsBinding();
		long adminTeam=0L;
		String hospital = "";
@ -63,13 +63,13 @@ public class DeviceDetailService extends BaseJpaService<DeviceDetail, DeviceDeta
		String doctorCode ="";
		String doctorName="";
		String keyType = "1";
		if ("2".equals(patientDevice.getUserType())){
		if ("2".equals(devicePatientDevice.getUserType())){
			keyType="2";
		}
		//设备表没有数据则插入一条数据
		if (deviceDetail==null){
			insertDevice(patientDevice,String.valueOf(adminTeam),hospitalName,hospital,"",doctorCode,doctorName,1);
			deviceDetail = deviceDetailDao.findBySn(patientDevice.getDeviceSn());
			insertDevice(devicePatientDevice,String.valueOf(adminTeam),hospitalName,hospital,"",doctorCode,doctorName,1);
			deviceDetail = deviceDetailDao.findBySn(devicePatientDevice.getDeviceSn());
		}
		isFirstBind = deviceDetail.getBindingCount();
@ -82,24 +82,24 @@ public class DeviceDetailService extends BaseJpaService<DeviceDetail, DeviceDeta
		if (isFirst){
			String updateFirstSql ="update wlyy_devices dd set dd.is_grant=1,dd.grant_admin_team=?,dd.grant_org_code=?,dd.binding_count=?,dd.grant_time = ?,dd.org_name=?,dd.grant_doctor=?,dd.grant_doctor_name=?,dd.is_binding=1 where dd.device_code=?";
			jdbcTemplate.update(updateFirstSql,new Object[]{String.valueOf(adminTeam),hospital,isFirstBind,grantTime,hospitalName,doctorCode, doctorName,patientDevice.getDeviceSn()});
			jdbcTemplate.update(updateFirstSql,new Object[]{String.valueOf(adminTeam),hospital,isFirstBind,grantTime,hospitalName,doctorCode, doctorName, devicePatientDevice.getDeviceSn()});
		}else {
			List<PatientDevice> patientDeviceList = patientDeviceDao.findByDeviceSn(patientDevice.getDeviceSn());
			int patientDeviceSize = patientDeviceList.size();
			List<DevicePatientDevice> devicePatientDeviceList = patientDeviceDao.findByDeviceSn(devicePatientDevice.getDeviceSn());
			int patientDeviceSize = devicePatientDeviceList.size();
			String updateSql = "";
			if (bind == 0){
				updateSql ="update wlyy_devices dd set dd.is_grant=1,dd.grant_admin_team=?,dd.grant_org_code=?,dd.binding_count=?,dd.is_binding=?,dd.org_name=?,dd.grant_doctor=?,dd.grant_doctor_name=?  where dd.device_code=?";
				jdbcTemplate.update(updateSql,new Object[]{String.valueOf(adminTeam),hospital,isFirstBind,patientDeviceSize,hospitalName,doctorCode,doctorName,patientDevice.getDeviceSn()});
				jdbcTemplate.update(updateSql,new Object[]{String.valueOf(adminTeam),hospital,isFirstBind,patientDeviceSize,hospitalName,doctorCode,doctorName, devicePatientDevice.getDeviceSn()});
			}else if (bind>0){
				updateSql ="update wlyy_devices dd set dd.is_grant=1,dd.binding_count=?,dd.is_binding=? where dd.device_code=?";
				jdbcTemplate.update(updateSql,new Object[]{isFirstBind,patientDeviceSize,patientDevice.getDeviceSn()});
				jdbcTemplate.update(updateSql,new Object[]{isFirstBind,patientDeviceSize, devicePatientDevice.getDeviceSn()});
			}
		}
	}
	/**
	 * 绑定时设备表如果没有数据则插入一条数据
	 * @param patientDevice
	 * @param devicePatientDevice
	 * @param adminTeam
	 * @param orgName
	 * @param orgCode
@ -107,19 +107,19 @@ public class DeviceDetailService extends BaseJpaService<DeviceDetail, DeviceDeta
	 * @param isBind 0未绑定  1已绑定
	 * @throws Exception
	 */
	public void insertDevice(PatientDevice patientDevice, String adminTeam, String orgName, String orgCode,String bindCount,String doctorCode,String doctorName,int isBind)throws Exception{
	public void insertDevice(DevicePatientDevice devicePatientDevice, String adminTeam, String orgName, String orgCode, String bindCount, String doctorCode, String doctorName, int isBind)throws Exception{
		//获取原始数据
		DeviceDetail deviceDetail = new DeviceDetail();
		BasePatientDO patient = patientDao.findById(patientDevice.getUser());
		BaseDoctorDO doctor = doctorDao.findById(patientDevice.getDoctor());
		Device device = deviceDao.findOne(patientDevice.getDeviceId());
		BasePatientDO patient = patientDao.findById(devicePatientDevice.getUser());
		BaseDoctorDO doctor = doctorDao.findById(devicePatientDevice.getDoctor());
		Device device = deviceDao.findOne(devicePatientDevice.getDeviceId());
		//添加数据到具体字段
		deviceDetail.setDeviceCode(patientDevice.getDeviceSn());
		deviceDetail.setDeviceName(patientDevice.getDeviceName());
		deviceDetail.setSim(patientDevice.getSim());
		deviceDetail.setDeviceCode(devicePatientDevice.getDeviceSn());
		deviceDetail.setDeviceName(devicePatientDevice.getDeviceName());
		deviceDetail.setSim(devicePatientDevice.getSim());
		deviceDetail.setGrantAdminTeam(adminTeam);
		deviceDetail.setGrantOrgCode(orgCode);
		deviceDetail.setGrantTime(patientDevice.getCzrq());
		deviceDetail.setGrantTime(devicePatientDevice.getCzrq());
		deviceDetail.setApplyDate(DateUtil.getStringDate("yyyy-MM-dd HH:mm:ss"));
		deviceDetail.setOrgName(orgName);
		deviceDetail.setGrantDoctor(doctorCode);
@ -139,7 +139,7 @@ public class DeviceDetailService extends BaseJpaService<DeviceDetail, DeviceDeta
		if (StringUtils.isNotEmpty(bindCount)){
			deviceDetail.setBindingCount(bindCount);
		}else {
			if (Integer.valueOf(patientDevice.getUserType())>0){
			if (Integer.valueOf(devicePatientDevice.getUserType())>0){
				deviceDetail.setBindingCount("{\"1\":\"0\",\"2\":\"0\"}");
			}else {
				deviceDetail.setBindingCount("{\"1\":\"0\"}");
@ -163,17 +163,17 @@ public class DeviceDetailService extends BaseJpaService<DeviceDetail, DeviceDeta
	 * @param deviceSn
	 */
	public void unBindUpdateIsBinding(String deviceSn)throws Exception{
		List<PatientDevice> patientDeviceList = patientDeviceDao.findByDeviceSn(deviceSn);
		List<DevicePatientDevice> devicePatientDeviceList = patientDeviceDao.findByDeviceSn(deviceSn);
		String sql = "update wlyy_devices dd set dd.is_binding=? where dd.device_code=?";
		if (patientDeviceList.size()==0){
		if (devicePatientDeviceList.size()==0){
			jdbcTemplate.update(sql,new Object[]{0,deviceSn});
			//deviceDetailDao.updateUnbindAll(0,deviceSn);
		}
		if (patientDeviceList.size()==1){
		if (devicePatientDeviceList.size()==1){
			jdbcTemplate.update(sql,new Object[]{1,deviceSn});
			//deviceDetailDao.updateUnbindAll(1,deviceSn);
		}
		if (patientDeviceList.size()>1){
		if (devicePatientDeviceList.size()>1){
			jdbcTemplate.update(sql,new Object[]{2,deviceSn});
			//deviceDetailDao.updateUnbindAll(2,deviceSn);
		}

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

@ -12,7 +12,7 @@ import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.care.device.Device;
import com.yihu.jw.entity.care.device.DeviceDetail;
import com.yihu.jw.entity.care.device.PatientDevice;
import com.yihu.jw.entity.care.device.DevicePatientDevice;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.util.common.IdCardUtil;
import com.yihu.jw.util.date.DateUtil;
@ -40,7 +40,7 @@ import java.util.*;
@Component
@Transactional(rollbackFor = Exception.class)
public class PatientDeviceService extends BaseJpaService<PatientDevice, PatientDeviceDao> {
public class PatientDeviceService extends BaseJpaService<DevicePatientDevice, PatientDeviceDao> {
    @Autowired
@ -105,21 +105,21 @@ public class PatientDeviceService extends BaseJpaService<PatientDevice, PatientD
    /**
     * 保存患者设备
     */
    public boolean saveDevice(PatientDevice patientDevice) throws Exception {
    public boolean saveDevice(DevicePatientDevice devicePatientDevice) throws Exception {
        //判断sn码是否被使用
        String sn = patientDevice.getDeviceSn();
        String type = patientDevice.getCategoryCode();
        Long deviceId = patientDevice.getDeviceId();
        String userType = patientDevice.getUserType();
        String sn = devicePatientDevice.getDeviceSn();
        String type = devicePatientDevice.getCategoryCode();
        Long deviceId = devicePatientDevice.getDeviceId();
        String userType = devicePatientDevice.getUserType();
        if (userType == null) {
            userType = "-1";
            patientDevice.setUserType("-1");
            devicePatientDevice.setUserType("-1");
        }
        boolean needVerify = true;
        //修改操作
        if (patientDevice.getId() != null) {
            PatientDevice deviceOld = patientDeviceDao.findOne(patientDevice.getId());
        if (devicePatientDevice.getId() != null) {
            DevicePatientDevice deviceOld = patientDeviceDao.findOne(devicePatientDevice.getId());
            if (deviceOld != null) {
                if (deviceOld.getDeviceSn().equals(sn)) {
                    needVerify = false;
@ -131,19 +131,19 @@ public class PatientDeviceService extends BaseJpaService<PatientDevice, PatientD
        //校验sn码是否被使用
        if (needVerify) {
            PatientDevice device = patientDeviceDao.findByDeviceSnAndUserType(sn, userType);
            if (device != null && !device.getId().equals(patientDevice.getId())) {
            DevicePatientDevice device = patientDeviceDao.findByDeviceSnAndUserType(sn, userType);
            if (device != null && !device.getId().equals(devicePatientDevice.getId())) {
                throw new Exception("sn码" + sn + "已被使用!");
            }
        }
        patientDevice.setCzrq(new Date());
        patientDevice.setDel(0);
        devicePatientDevice.setCzrq(new Date());
        devicePatientDevice.setDel(0);
        //当前用户的身份证
        BasePatientDO patient = patientDao.findById(patientDevice.getUser());
        patientDevice.setUserIdcard(patient.getIdcard());
        BasePatientDO patient = patientDao.findById(devicePatientDevice.getUser());
        devicePatientDevice.setUserIdcard(patient.getIdcard());
        if(checkDeviceSn(sn)){
            patientDeviceDao.save(patientDevice);
            patientDeviceDao.save(devicePatientDevice);
        }else {
            String message = "设备不存在";
            throw new Exception(message);
@ -154,12 +154,12 @@ public class PatientDeviceService extends BaseJpaService<PatientDevice, PatientD
    public void deleteDevices(String deviceSn, String type, String uuid) {
        List<PatientDevice> patientDevices = patientDeviceDao.findByDeviceSnAndCategoryCode(deviceSn, type);
        if (patientDevices == null || patientDevices.size() == 0) {
        List<DevicePatientDevice> devicePatientDevices = patientDeviceDao.findByDeviceSnAndCategoryCode(deviceSn, type);
        if (devicePatientDevices == null || devicePatientDevices.size() == 0) {
            throw new RuntimeException("设备未被绑定!");
        }
        for (PatientDevice patientDevice : patientDevices) {
            patientDeviceDao.delete(patientDevice);
        for (DevicePatientDevice devicePatientDevice : devicePatientDevices) {
            patientDeviceDao.delete(devicePatientDevice);
        }
    }
@ -167,14 +167,14 @@ public class PatientDeviceService extends BaseJpaService<PatientDevice, PatientD
     * 删除患者设备
     */
    public List<com.alibaba.fastjson.JSONObject> deleteDevice(String id, String uuid) {
        PatientDevice device = patientDeviceDao.findOne(Long.valueOf(id));
        DevicePatientDevice device = patientDeviceDao.findOne(Long.valueOf(id));
        patientDeviceDao.delete(device);
        List<PatientDevice> patientDevices = patientDeviceDao.findByDeviceSnAndCategoryCode(device.getDeviceSn(), device.getCategoryCode());
        List<DevicePatientDevice> devicePatientDevices = patientDeviceDao.findByDeviceSnAndCategoryCode(device.getDeviceSn(), device.getCategoryCode());
        List<com.alibaba.fastjson.JSONObject> objects = new ArrayList<>();
        for (PatientDevice patientDevice : patientDevices) {
            String json = com.alibaba.fastjson.JSONObject.toJSONString(patientDevice) ;
        for (DevicePatientDevice devicePatientDevice : devicePatientDevices) {
            String json = com.alibaba.fastjson.JSONObject.toJSONString(devicePatientDevice) ;
            com.alibaba.fastjson.JSONObject object = com.alibaba.fastjson.JSONObject.parseObject(json) ;
            BasePatientDO patient = patientDao.findById(patientDevice.getUser());
            BasePatientDO patient = patientDao.findById(devicePatientDevice.getUser());
            if (patient != null) {
                object.put("userName", patient.getName());
            }
@ -186,7 +186,7 @@ public class PatientDeviceService extends BaseJpaService<PatientDevice, PatientD
    /**
     * 患者设备列表接口(分页)
     */
    public Page<PatientDevice> findByPatient(String patientCode, long id, int pageSize) {
    public Page<DevicePatientDevice> findByPatient(String patientCode, long id, int pageSize) {
        if (id < 0) {
            id = 0;
        }
@ -209,7 +209,7 @@ public class PatientDeviceService extends BaseJpaService<PatientDevice, PatientD
            filters.put("id", new SearchFilter("id", Operator.LT, id));
        }
        Specification<PatientDevice> spec = DynamicSpecifications.bySearchFilter(filters.values(), PatientDevice.class);
        Specification<DevicePatientDevice> spec = DynamicSpecifications.bySearchFilter(filters.values(), DevicePatientDevice.class);
        return patientDeviceDao.findAll(spec, pageRequest);
    }
@ -229,14 +229,14 @@ public class PatientDeviceService extends BaseJpaService<PatientDevice, PatientD
        PageRequest pageRequest = new PageRequest(page - 1, pagesize);
        List<PatientDevice> list = new ArrayList<>();
        List<DevicePatientDevice> list = new ArrayList<>();
        list = patientDeviceDao.findByUser(patientCode, pageRequest);
        if (list != null) {
            //获取设备路径,医生姓名
            List<Device> deviceList = deviceDao.findAll();
            BaseDoctorDO self = doctorDao.findById(doctorCode);
            for (PatientDevice item : list) {
            for (DevicePatientDevice item : list) {
                Map<String, Object> map = new HashMap<>();
                if (StringUtils.isNotBlank(item.getDoctor())) {
                    if (StringUtils.equals(item.getDoctor(), doctorCode)) {
@ -311,14 +311,14 @@ public class PatientDeviceService extends BaseJpaService<PatientDevice, PatientD
     * @param patient
     * @return
     */
    public Iterator<PatientDevice> findPatientHave(String patient) {
    public Iterator<DevicePatientDevice> findPatientHave(String patient) {
        return patientDeviceDao.findByUser(patient).iterator();
    }
    /**
     * 获取患者设备信息
     **/
    public PatientDevice findById(String id) {
    public DevicePatientDevice findById(String id) {
        return patientDeviceDao.findOne(Long.valueOf(id));
    }
@ -328,9 +328,9 @@ public class PatientDeviceService extends BaseJpaService<PatientDevice, PatientD
     **/
    public List<Map<String, String>> getDeviceUser(String user, String deviceSn, String type) throws Exception {
        List<Map<String, String>> re = new ArrayList<>();
        List<PatientDevice> list = patientDeviceDao.findByDeviceSnAndCategoryCode(deviceSn, type);
        List<DevicePatientDevice> list = patientDeviceDao.findByDeviceSnAndCategoryCode(deviceSn, type);
        if (list != null) {
            for (PatientDevice item : list) {
            for (DevicePatientDevice item : list) {
                Map<String, String> map = new HashMap<>();
                map.put("type", item.getUserType());
                String code = item.getUser();
@ -356,11 +356,11 @@ public class PatientDeviceService extends BaseJpaService<PatientDevice, PatientD
    }
    public JSONArray getDeviceByDeviceSn(String deviceSn, String type) {
        List<PatientDevice> list = patientDeviceDao.findByDeviceSnAndCategoryCode(deviceSn, type);
        List<DevicePatientDevice> list = patientDeviceDao.findByDeviceSnAndCategoryCode(deviceSn, type);
        JSONArray objects = new JSONArray();
        for (PatientDevice patientDevice : list) {
            JSONObject object = new JSONObject(patientDevice);
            BasePatientDO patient = patientDao.findById(patientDevice.getUser());
        for (DevicePatientDevice devicePatientDevice : list) {
            JSONObject object = new JSONObject(devicePatientDevice);
            BasePatientDO patient = patientDao.findById(devicePatientDevice.getUser());
            if (patient != null) {
                object.put("userName", patient.getName());
            }
@ -390,7 +390,7 @@ public class PatientDeviceService extends BaseJpaService<PatientDevice, PatientD
    public com.alibaba.fastjson.JSONObject deviceInfo(String deviceSn,String patientCode){
        com.alibaba.fastjson.JSONObject jsonObject = new com.alibaba.fastjson.JSONObject();
        List<PatientDevice> device = patientDeviceDao.findByDeviceSn(deviceSn);
        List<DevicePatientDevice> device = patientDeviceDao.findByDeviceSn(deviceSn);
        jsonObject.put("sim",device.get(0).getSim());
        jsonObject.put("deviceSn",device.get(0).getDeviceSn());
        jsonObject.put("categoryCode",device.get(0).getCategoryCode());
@ -544,17 +544,17 @@ public class PatientDeviceService extends BaseJpaService<PatientDevice, PatientD
        if (mapSqlList!=null && mapSqlList.size()>0){
            map = mapSqlList.get(0);
        }
        List<PatientDevice> list = patientDeviceDao.findByDeviceSn(deviceSn);
        List<DevicePatientDevice> list = patientDeviceDao.findByDeviceSn(deviceSn);
        List<Map<String,Object>> mapList = new ArrayList<>();
        for (PatientDevice patientDevice : list) {
        for (DevicePatientDevice devicePatientDevice : list) {
            Map<String,Object> infoMap = new HashedMap();
            BasePatientDO patient = patientDao.findById(patientDevice.getUser());
            BasePatientDO patient = patientDao.findById(devicePatientDevice.getUser());
            if (patient!=null){
                infoMap.put("patientDeviceId",patientDevice.getId());
                infoMap.put("patientDeviceId", devicePatientDevice.getId());
                infoMap.put("userCode",patient.getId());
                infoMap.put("userName",patient.getName());
                infoMap.put("idCard",patient.getIdcard());
                infoMap.put("userType",patientDevice.getUserType());
                infoMap.put("userType", devicePatientDevice.getUserType());
            }
            mapList.add(infoMap);
@ -563,13 +563,13 @@ public class PatientDeviceService extends BaseJpaService<PatientDevice, PatientD
        return map;
    }
    public Map<String,Object> checkBindingFirstAndType(PatientDevice patientDevice)throws Exception{
    public Map<String,Object> checkBindingFirstAndType(DevicePatientDevice devicePatientDevice)throws Exception{
        Map<String,Object> resultMap = new HashedMap();
        boolean flag = true;
        int code = 200;
        String msg = "";
        String deviceSn = patientDevice.getDeviceSn();
        String userType = patientDevice.getUserType();
        String deviceSn = devicePatientDevice.getDeviceSn();
        String userType = devicePatientDevice.getUserType();
        //设备是否是第一次被绑定
        String keyType = "1";
@ -649,7 +649,7 @@ public class PatientDeviceService extends BaseJpaService<PatientDevice, PatientD
     * @param deviceSn 设备sn码
     * @return
     */
    public List<PatientDevice> findByDeviceSn(String deviceSn){
    public List<DevicePatientDevice> findByDeviceSn(String deviceSn){
       return  patientDeviceDao.findByDeviceSn(deviceSn);
    }

+ 2 - 2
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/device/PatientHealthIndexService.java

@ -9,7 +9,7 @@ import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.care.device.DeviceDetail;
import com.yihu.jw.entity.care.device.DevicePatientHealthIndex;
import com.yihu.jw.entity.care.device.PatientDevice;
import com.yihu.jw.entity.care.device.DevicePatientDevice;
import com.yihu.jw.message.dao.MessageDao;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.util.date.DateUtil;
@ -670,7 +670,7 @@ public class PatientHealthIndexService extends BaseJpaService<DevicePatientHealt
                userType = map.get("user");
            }
            //根据设备获取患者(不同厂家sn码一样的问题未解决!!)
            PatientDevice device = patientDeviceDao.findByDeviceSnAndCategoryCodeAndUserType(deviceSn, type, userType);
            DevicePatientDevice device = patientDeviceDao.findByDeviceSnAndCategoryCodeAndUserType(deviceSn, type, userType);
            if (device != null) {
                patientCode = device.getUser();
                patient = patientDao.findById(patientCode);

+ 2 - 6
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/security/SecurityMonitoringOrderService.java

@ -5,7 +5,6 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.sun.org.apache.bcel.internal.generic.IF_ACMPEQ;
import com.yihu.jw.care.dao.device.PatientDeviceDao;
import com.yihu.jw.care.dao.security.*;
import com.yihu.jw.care.service.sign.ServicePackageService;
@ -13,15 +12,12 @@ import com.yihu.jw.care.util.MessageUtil;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.doctor.dao.BaseDoctorHospitalDao;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.doctor.BaseDoctorHospitalDO;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.servicePackage.ServicePackageRecordDO;
import com.yihu.jw.entity.care.device.PatientDevice;
import com.yihu.jw.entity.care.device.DevicePatientDevice;
import com.yihu.jw.entity.care.securitymonitoring.*;
import com.yihu.jw.hospital.message.dao.SystemMessageDao;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.restmodel.ResponseContant;
import com.yihu.jw.rm.base.BaseRequestMapping;
import com.yihu.jw.util.common.IdCardUtil;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.util.entity.EntityUtils;
@ -279,7 +275,7 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
            Integer age  = IdCardUtil.getAgeForIdcard(tmp.getString("idcard"));
            tmp.put("age",age);
            //患者设备
            List<PatientDevice> devices = patientDeviceDao.findAllByUser(tmp.get("patientCode").toString());
            List<DevicePatientDevice> devices = patientDeviceDao.findAllByUser(tmp.get("patientCode").toString());
            if (devices.size()>0){
                tmp.put("deviceFlag","1");
            }

+ 230 - 0
svr/svr-cloud-device/pom.xml

@ -0,0 +1,230 @@
<?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-device</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>org.apache.tomcat.embed</groupId>
            <artifactId>tomcat-embed-jasper</artifactId>
        </dependency>
        <!-- 支持Tomcat启动 -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-redis</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-activemq</artifactId>
        </dependency>
        <dependency>
            <groupId>org.json</groupId>
            <artifactId>json</artifactId>
        </dependency>
        <dependency>
            <groupId>com.yihu.jw</groupId>
            <artifactId>common-entity</artifactId>
        </dependency>
        <dependency>
            <groupId>com.yihu.jw</groupId>
            <artifactId>common-rest-model</artifactId>
        </dependency>
        <dependency>
            <groupId>com.yihu.jw</groupId>
            <artifactId>common-request-mapping</artifactId>
        </dependency>
        <dependency>
            <groupId>com.yihu.jw</groupId>
            <artifactId>common-exception</artifactId>
        </dependency>
        <dependency>
            <groupId>com.yihu.jw</groupId>
            <artifactId>common-util</artifactId>
        </dependency>
        <dependency>
            <groupId>com.yihu.jw</groupId>
            <artifactId>common-web</artifactId>
        </dependency>
        <!-- Jzkl Starter -->
        <dependency>
            <groupId>com.yihu</groupId>
            <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>
        <dependency>
            <groupId>com.zaxxer</groupId>
            <artifactId>HikariCP</artifactId>
            <!-- <scope>runtime</scope> -->
        </dependency>
        <dependency>
            <groupId>io.github.swagger2markup</groupId>
            <artifactId>swagger2markup</artifactId>
            <version>1.3.2</version>
            <exclusions>
                <exclusion>
                    <artifactId>mailapi</artifactId>
                    <groupId>javax.mail</groupId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-core</artifactId>
            <version>RELEASE</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>net.sf.json-lib</groupId>
            <artifactId>json-lib</artifactId>
            <version>2.4</version>
        </dependency>
        <dependency>
            <groupId>com.yihu.jw</groupId>
            <artifactId>im-service</artifactId>
            <version>2.0.0</version>
            <exclusions>
                <exclusion>
                    <groupId>xalan</groupId>
                    <artifactId>xalan</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
    </dependencies>
    <build>
        <finalName>svr-cloud-device</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.SvrCloudDeviceApplication</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>

+ 3 - 0
svr/svr-cloud-device/readme.MD

@ -0,0 +1,3 @@
医养项目设备对接工程
为了设备接收稳定,防止主程序重启导致设备数据没接收到,故独立项目
目前正在对接爱牵挂设备

+ 30 - 0
svr/svr-cloud-device/src/main/java/com/yihu/SvrCloudDeviceApplication.java

@ -0,0 +1,30 @@
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.data.jpa.repository.config.EnableJpaAuditing;
import org.springframework.scheduling.annotation.EnableAsync;
/**
 * Created with IntelliJ IDEA.
 *
 * @Author: yeshijie
 * @Date: 2021/4/29
 * @Description:
 */
@SpringBootApplication
@EnableJpaAuditing
@EnableAsync
public class SvrCloudDeviceApplication extends SpringBootServletInitializer {
    public static void main(String[] args)  {
        SpringApplication.run(SvrCloudDeviceApplication.class, args);
    }
    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
        return builder.sources(SvrCloudDeviceApplication.class);
    }
}

+ 29 - 0
svr/svr-cloud-device/src/main/java/com/yihu/jw/care/config/AqgConfig.java

@ -0,0 +1,29 @@
package com.yihu.jw.care.config;
/**
 * Created with IntelliJ IDEA.
 *
 * @Author: yeshijie
 * @Date: 2021/4/29
 * @Description: 爱牵挂配置
 */
public class AqgConfig {
    /**
     * 基础url
     */
//    public static final String baseUrl = "http://120.24.56.48:8889";//测试环境
    public static final String baseUrl = "http://api.aiqiangua.com:8888";// 正式环境
    /**
     * 登录
     */
    public static final String login = baseUrl +"/api/auth/login";
    public static final String username = "13559485270";
    public static final String password = "zjxl@2021";
    public static final String redisKey = "aqgCooker";
    /**
     * cookie时效24小时,吧过期时间设置为23 小时
     */
    public static final Long overTime = 23L;
}

+ 42 - 0
svr/svr-cloud-device/src/main/java/com/yihu/jw/care/config/AsyncConfig.java

@ -0,0 +1,42 @@
package com.yihu.jw.care.config;
import org.apache.tomcat.util.threads.ThreadPoolExecutor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import java.util.concurrent.Executor;
/**
 * Created with IntelliJ IDEA.
 *
 * @Author: yeshijie
 * @Date: 2021/4/30
 * @Description: 异步线程配置
 */
@Configuration
public class AsyncConfig {
    @Bean
    public Executor taskExecutor() {
        ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
        // 设置核心线程数
        executor.setCorePoolSize(5);
        // 设置最大线程数
        executor.setMaxPoolSize(20);
        // 设置队列容量
        executor.setQueueCapacity(200);
        // 设置线程活跃时间(秒)
        executor.setKeepAliveSeconds(60);
        // 设置默认线程名称
        executor.setThreadNamePrefix("user-device-");
        // 设置拒绝策略
        // rejection-policy:当pool已经达到max size的时候,如何处理新任务
        // CALLER_RUNS:不在新线程中执行任务,而是有调用者所在的线程来执行
        executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
//        // 等待所有任务结束后再关闭线程池
//        executor.setWaitForTasksToCompleteOnShutdown(true);
        executor.initialize();
        return executor;
    }
}

+ 21 - 0
svr/svr-cloud-device/src/main/java/com/yihu/jw/care/dao/device/DeviceDao.java

@ -0,0 +1,21 @@
/*******************************************************************************
 * Copyright (c) 2005, 2014 springside.github.io
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 *******************************************************************************/
package com.yihu.jw.care.dao.device;
import com.yihu.jw.entity.care.device.Device;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
public interface DeviceDao extends PagingAndSortingRepository<Device, Long> {
	@Query("select a from Device a where a.categoryCode = ?1 and a.del = '1'")
	List<Device> findByCategoryCode(String categoryCode);
	@Query("select a from Device a where a.del = '1'")
	List<Device> findAll();
}

+ 16 - 0
svr/svr-cloud-device/src/main/java/com/yihu/jw/care/dao/device/DeviceDetailDao.java

@ -0,0 +1,16 @@
package com.yihu.jw.care.dao.device;
import com.yihu.jw.entity.care.device.DeviceDetail;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * @author yeshijie on 2018/1/10.
 */
public interface DeviceDetailDao extends PagingAndSortingRepository<DeviceDetail, Long>, JpaSpecificationExecutor<DeviceDetail> {
    @Query(value = "select a.* from wlyy_devices a where a.device_code=?1 limit 0,1",nativeQuery = true)
    DeviceDetail findBySn(String sn);
}

+ 70 - 0
svr/svr-cloud-device/src/main/java/com/yihu/jw/care/dao/device/DevicePatientHealthIndexDao.java

@ -0,0 +1,70 @@
package com.yihu.jw.care.dao.device;
import com.yihu.jw.entity.care.device.DevicePatientHealthIndex;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.Date;
import java.util.List;
public interface DevicePatientHealthIndexDao
		extends PagingAndSortingRepository<DevicePatientHealthIndex, Long>, JpaSpecificationExecutor<DevicePatientHealthIndex> {
	List<DevicePatientHealthIndex> findByIdcardAndType(String idcard, Integer type);
	/**
	 * 按录入时间和患者标识查询健康记录
	 *
	 * @param patientCode
	 * @param date
	 * @return
	 */
	@Query("select a from DevicePatientHealthIndex a where a.user = ?1 and type = ?2 and a.recordDate = ?3 and a.del = '1'")
	Iterable<DevicePatientHealthIndex> findByPatienDate(String patientCode, int type, Date date);
	@Query("select a from DevicePatientHealthIndex a where a.user = ?1 and a.type = ?2 and a.recordDate between ?3 and ?4 and a.del = '1' group by recordDate order by recordDate asc")
	Iterable<DevicePatientHealthIndex> findByPatient(String user, int type, Date begin, Date end);
	@Query("select a from DevicePatientHealthIndex a where a.user = ?1 and a.type = ?2 and a.del = '1'")
	List<DevicePatientHealthIndex> findIndexByPatient(String patient, int type, Pageable pageRequest);
	@Query("SELECT a FROM DevicePatientHealthIndex a where a.user = ?1 and a.del = '1' order by a.recordDate desc ")
	List<DevicePatientHealthIndex> findRecentByPatient(String patient);
	@Query(value = "select a.* from wlyy_patient_health_index a where a.user=?1 and a.type=?2 and a.del='1' order by a.record_date desc limit 0,1",nativeQuery = true)
	DevicePatientHealthIndex findLastData(String patient, Integer type);
	/**
	 * 获取患者一天的具体某个类型的数据
	 */
	@Query("select a from DevicePatientHealthIndex a where a.type=?1 and a.user = ?2 and DATE_FORMAT(a.recordDate,'%Y-%m-%d') = ?3 and a.deviceSn = ?4 and a.del = '1' order by a.recordDate,a.id")
	List<DevicePatientHealthIndex> findByDateAndType(int type, String patient, String date, String devicesn);
	
	/**
	 * 获取患者单月的具体某个类型的数据
	 */
	@Query(value = "SELECT a.* FROM wlyy_patient_health_index a WHERE a.type=?1 AND a.USER=?2 AND DATE_FORMAT(a.record_date,'%Y-%m')=?3 AND a.device_sn=?4 AND a.del='1' ORDER BY a.record_date,a.id",nativeQuery = true)
	List<DevicePatientHealthIndex> findByDateMonthAndType(int type, String patient, String date, String devicesn);
	@Query(value = "select a.* from wlyy_patient_health_index a where a.user = ?1 and a.type = ?2 and a.record_date >= ?3 and a.record_date <= ?4 and a.del = '1' order by a.sort_date desc ,record_date desc limit ?5 ,?6",nativeQuery = true)
	List<DevicePatientHealthIndex> findIndexByPatientNative(String patient, int type, Date start, Date end, int currentSize, int pageSize);
	@Query(value = "select DATE_FORMAT(a.record_date,'%Y-%m-%d') from wlyy_patient_health_index a where a.user = ?1 and a.record_date >= ?2 and a.record_date <= ?3 and a.del = '1' group by DATE_FORMAT(a.record_date,'%Y-%m-%d') order by DATE_FORMAT(a.record_date,'%Y-%m-%d') desc limit ?4 ,?5",nativeQuery = true)
	List<String> findDateList(String patient, Date start, Date end, int currentSize, int pageSize);
	@Query(value = "select DATE_FORMAT(a.record_date,'%Y-%m-%d') from wlyy_patient_health_index a where a.user = ?1 and a.type=?2 and a.record_date >= ?3 and a.record_date <= ?4 and a.del = '1' group by DATE_FORMAT(a.record_date,'%Y-%m-%d') order by DATE_FORMAT(a.record_date,'%Y-%m-%d') desc limit ?5 ,?6",nativeQuery = true)
	List<String> findDateList(String patient, int type, Date start, Date end, int currentSize, int pageSize);
	
	@Query(value= " select * from wlyy_patient_health_index where type in (1,2) and record_date BETWEEN ?1 AND ?2  AND user in (select p.code from wlyy.wlyy_patient p INNER JOIN wlyy.wlyy_sign_family s on s.patient = p.code RIGHT JOIN wlyy.wlyy_sign_patient_label_info sp on sp.patient = p.code where  s.status > 0 AND s.admin_team_code = ?3 and (s.doctor = ?4 or s.doctor_health =?4) and sp.status = 1 and sp.label_type = 3 and (sp.label = 1 or sp.label = 2))",nativeQuery = true)
	List<DevicePatientHealthIndex> findByTeamcodeAndRecordDate(Date start, Date end, String teamcode, String doctorcode);
	@Query(value="select * from wlyy_patient_health_index where user = ?1 and type = ?2 ORDER BY record_date desc limit 0 ,5",nativeQuery = true)
	List<DevicePatientHealthIndex> findByPatientAndTypeByPage(String patientCode, int type);
	@Query("select count(a) from DevicePatientHealthIndex a where a.recordDate >= ?1 and a.recordDate <= ?2 and a.type in (1,2) and a.status = ?3 and a.del = '1' and user = ?4")
	int getCountByTimeAndStatus(Date start, Date end, int status, String patientCode);
}

+ 54 - 0
svr/svr-cloud-device/src/main/java/com/yihu/jw/care/dao/device/PatientDeviceDao.java

@ -0,0 +1,54 @@
package com.yihu.jw.care.dao.device;
import com.yihu.jw.entity.care.device.DevicePatientDevice;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
public interface PatientDeviceDao extends PagingAndSortingRepository<DevicePatientDevice, Long>, JpaSpecificationExecutor<DevicePatientDevice> {
    @Query("select a from DevicePatientDevice a where a.user = ?1 ")
    Iterable<DevicePatientDevice> findByUser(String user);
    @Query("select a from DevicePatientDevice a where a.user = ?1 ")
    List<DevicePatientDevice> findByPatient(String user);
    @Query("select a from DevicePatientDevice a where a.user = ?1 and a.del=0 and a.deviceName like '%药盒%'")
    List<DevicePatientDevice> findByPatientAndDel(String user);
    @Query("select a from DevicePatientDevice a where a.user = ?1 and a.deviceSn=?2 ")
    List<DevicePatientDevice> findByPatientAndDeviceSn(String user, String deviceSn);
    List<DevicePatientDevice> findByUser(String user, Pageable pageRequest);
    List<DevicePatientDevice> findByUserAndDoctor(String user, String doctor, Pageable pageRequest);
    List<DevicePatientDevice> findByDeviceSnAndCategoryCode(String deviceSn, String categoryCode);
    DevicePatientDevice findByDeviceSnAndCategoryCodeAndUserType(String deviceSn, String categoryCode, String userType);
    DevicePatientDevice findByDeviceIdAndDeviceSnAndUserType(Long deviceId, String deviceSn, String userType);
    DevicePatientDevice findByDeviceSnAndUserType(String deviceSn, String userType);
    @Query("select pd from DevicePatientDevice pd where pd.deviceSn = ?1 and pd.del=0")
    List<DevicePatientDevice> findByDeviceSn(String deviceSn);
    //更换患者绑定的血糖仪
    @Modifying
    @Query("update DevicePatientDevice t set t.deviceSn = ?3 , t.userType = ?4,t.sim=?5,t.hospital=?6,t.hospitalName=?7,t.checkDoctorName=?8 where t.user = ?1 and t.deviceSn = ?2 ")
    int updatePatientDevice(String user, String deviceSN, String newDeviceSN, String userType, String sim, String hospital, String hospitalName, String checkDoctorName);
    @Query("select a from DevicePatientDevice a")
    List<DevicePatientDevice> findAll();
    @Query("select a from DevicePatientDevice a where a.user=?1 and a.del=0")
    List<DevicePatientDevice> findAllByUser(String user);
}

+ 416 - 0
svr/svr-cloud-device/src/main/java/com/yihu/jw/care/endpoint/DeviceController.java

@ -0,0 +1,416 @@
package com.yihu.jw.care.endpoint;
import com.alibaba.fastjson.JSON;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.care.service.DeviceService;
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.*;
import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;
/**
 * Created with IntelliJ IDEA.
 *
 * @Author: yeshijie
 * @Date: 2021/4/29
 * @Description:
 */
@RestController
@RequestMapping("/device")
@Api(value = "设备相关服务", description = "设备相关服务")
public class DeviceController {
    private static Logger logger = LoggerFactory.getLogger(DeviceController.class);
    @Autowired
    private DeviceService deviceService;
    @GetMapping("test")
    public String test(){
        return deviceService.getCookie();
    }
    @ApiOperation("爱牵挂设备sos数据接收")
    @RequestMapping(value = "aqgsos", produces = "application/x-www-form-urlencoded;charset=UTF-8", method = RequestMethod.POST)
    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 {
            String paraString = JSON.toJSONString(request.getParameterMap());
            logger.info("爱牵挂设备sos数据接收,请求参数:\n"+paraString);
            deviceService.aqgsos(imei, label_mac, time_begin,request);
            return success();
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1,"Device data incoming failure");
        }
    }
    @ApiOperation("爱牵挂设备开关机数据接收")
    @RequestMapping(value = "aqgSwitch", produces = "application/x-www-form-urlencoded;charset=UTF-8", method = RequestMethod.POST)
    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 {
            String paraString = JSON.toJSONString(request.getParameterMap());
            logger.info("爱牵挂设备开关机数据接收,请求参数:\n"+paraString);
            deviceService.aqgSwitch(imei, time_begin, remaining_power, type,request);
            return success();
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1,"Device data incoming failure");
        }
    }
    @ApiOperation("爱牵挂设备消息通知数据接收")
    @RequestMapping(value = "pushdata", produces = "application/x-www-form-urlencoded;charset=UTF-8", method = 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 {
            String paraString = JSON.toJSONString(request.getParameterMap());
            logger.info("爱牵挂设备消息通知数据接收,请求参数:\n"+paraString);
            deviceService.pushdata(type, deviceid, communityid, request);
            return success();
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1,"Device data incoming failure");
        }
    }
    //
    @ApiOperation("柏颐设备位置接收")
    @RequestMapping(value = "byLocation", produces = "application/x-www-form-urlencoded;charset=UTF-8", method = RequestMethod.POST)
    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 {
            String paraString = JSON.toJSONString(request.getParameterMap());
            logger.info("柏颐设备位置接收,请求参数:\n"+paraString);
            deviceService.byLocation(imei,time_begin,is_reply,is_track,city,address,lon,lat,type);
            return success();
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1,"Device data incoming failure");
        }
    }
    @ApiOperation("柏颐心率数据接收")
    @RequestMapping(value = "byHeartRate", produces = "application/x-www-form-urlencoded;charset=UTF-8", method = RequestMethod.POST)
    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 {
            String paraString = JSON.toJSONString(request.getParameterMap());
            logger.info("柏颐心率数据接收,请求参数: \n"+paraString);
            deviceService.byHeartRate(imei,time_begin,heartrate,theshold_heartrate_h,theshold_heartrate_l);
            return success();
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1,"Device data incoming failure");
        }
    }
    @ApiOperation("柏颐血压数据接收")
    @RequestMapping(value = "byBloodPressure", produces = "application/x-www-form-urlencoded;charset=UTF-8", method = RequestMethod.POST)
    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 {
            String paraString = JSON.toJSONString(request.getParameterMap());
            logger.info("柏颐血压数据,接收请求参数:\n"+paraString);
            deviceService.byBloodPressure(imei,time_begin,dbp,dbp_l,sbp,sbp_h);
            return success();
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1,"Device data incoming failure");
        }
    }
    @ApiOperation("柏颐跌倒数据接收")
    @RequestMapping(value = "byFall", produces = "application/x-www-form-urlencoded;charset=UTF-8", method = RequestMethod.POST)
    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 {
            String paraString = JSON.toJSONString(request.getParameterMap());
            logger.info("柏颐跌倒数据接收,请求参数: \n"+paraString);
            deviceService.byFall(imei,time_begin,city,address,lon,lat,type);
            return success();
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1,"Device data incoming failure");
        }
    }
    @ApiOperation("柏颐设备sos数据接收")
    @RequestMapping(value = "bySos", produces = "application/x-www-form-urlencoded;charset=UTF-8", method = RequestMethod.POST)
    public String bySos(
            @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="heartrate",required = false,value="心率")
            @RequestParam(value = "heartrate",required = false) int heartrate,
            @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 {
            String paraString = JSON.toJSONString(request.getParameterMap());
            logger.info("请求参数:"+paraString);
            deviceService.bySos(imei,time_begin,heartrate,city,address,lon,lat,type);
            return success();
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1,"Device data incoming failure");
        }
    }
    @ApiOperation("柏颐设备步数接收")
    @RequestMapping(value = "bySteps", produces = "application/x-www-form-urlencoded;charset=UTF-8", method = RequestMethod.POST)
    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 {
            String paraString = JSON.toJSONString(request.getParameterMap());
            logger.info("柏颐设备步数接收,请求参数:\n"+paraString);
            deviceService.bySteps(imei,time_begin,value);
            return success();
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1,"Device data incoming failure");
        }
    }
    @ApiOperation("柏颐设备睡眠接收")
    @RequestMapping(value = "bySleep", produces = "application/x-www-form-urlencoded;charset=UTF-8", method = RequestMethod.POST)
    public String bySleep(
            @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="time_end",required = false,value="结束时间YYYY-MM-DD HH:mm:SS")
            @RequestParam(value = "time_end",required = false) String time_end,
            @ApiParam(name="interval",required = false,value="固定30分钟")
            @RequestParam(value = "interval",required = false) int interval,
            @ApiParam(name="total",required = false,value="检测次数")
            @RequestParam(value = "total",required = false) int total,
            @ApiParam(name="data",required = false,value="样例截取 睡眠数据 (格式:state,turn_over|state,turn_over|...)")
            @RequestParam(value = "data",required = false)String data,
            HttpServletRequest request) {
        try {
            //data 为字符串,格式为:  state,turn_over|state,turn_over|state, ... state和turn_over的
            // 含义见object.md 文档中sleepdatasleep
            String paraString = JSON.toJSONString(request.getParameterMap());
            logger.info("柏颐设备睡眠接收,请求参数:"+paraString);
            deviceService.bySleep(imei,time_begin,time_end,interval,total,data);
            return success();
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1,"Device data incoming failure");
        }
    }
    @ApiOperation("柏颐设备开关机数据接收")
    @RequestMapping(value = "bySwitch", produces = "application/x-www-form-urlencoded;charset=UTF-8", method = RequestMethod.POST)
    public String bySwitch(
            @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="type",required = false,value="开/关机类型  0:开机; 1:关机; 2:电量上报; 3:低电通知")
            @RequestParam(value = "type",required = false) String type,
            @ApiParam(name="remaining_power",required = false,value="剩余电量(%)")
            @RequestParam(value = "remaining_power",required = false) int remaining_power,
            HttpServletRequest request) {
        try {
            String paraString = JSON.toJSONString(request.getParameterMap());
            logger.info("请求参数:"+paraString);
            deviceService.bySwitch(imei,time_begin,type,remaining_power);
            return success();
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1,"Device data incoming failure");
        }
    }
    @ApiOperation("柏颐设备消息通知数据接收")
    @RequestMapping(value = "byPushData", produces = "application/x-www-form-urlencoded;charset=UTF-8", method = RequestMethod.POST)
    public String byPushData(
            @ApiParam(name="type",required = false,value="type=1 SOS,type=2 fall,type=3 new 新成员加入 ,type=4 电子围栏触发, type=5 设备低电,type=6 环境音 ",defaultValue = "")
            @RequestParam(value = "type",required = false) int type,
            @ApiParam(name="deviceid",required = false,value="15位设备唯一序号",defaultValue = "")
            @RequestParam(value = "deviceid",required = true) String deviceid,
            @ApiParam(name="communityid",required = false,value="机构ID")
            @RequestParam(value = "communityid",required = false) String communityid,
            @ApiParam(name="url",required = false,value="环境音下载地址 只有环境音(type=6)为必填,其他type都为非必填")
            @RequestParam(value = "url",required = false) String url,
            @ApiParam(name="name",required = false,value="设备名称")
            @RequestParam(value = "name",required = false) String name,
            HttpServletRequest request) {
        try {
            String paraString = JSON.toJSONString(request.getParameterMap());
            logger.info("请求参数:"+paraString);
            deviceService.byPushData(type,deviceid,communityid,url,name);
            return success();
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1,"Device data incoming failure");
        }
    }
    /**
     * 返回接口处理结果
     *
     * @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;
        }
    }
}

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

@ -0,0 +1,381 @@
package com.yihu.jw.care.service;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.care.config.AqgConfig;
import com.yihu.jw.care.dao.device.DevicePatientHealthIndexDao;
import com.yihu.jw.care.dao.device.PatientDeviceDao;
import com.yihu.jw.entity.care.device.DevicePatientHealthIndex;
import com.yihu.jw.entity.care.device.DevicePatientDevice;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.util.http.HttpClientUtil;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import javax.servlet.http.HttpServletRequest;
import java.util.Date;
import java.util.List;
import java.util.concurrent.TimeUnit;
/**
 * Created with IntelliJ IDEA.
 *
 * @Author: yeshijie
 * @Date: 2021/4/29
 * @Description:
 */
@Service
public class DeviceService {
    private static Logger logger = LoggerFactory.getLogger(DeviceService.class);
    @Autowired
    private HttpClientUtil httpClientUtil;
    @Autowired
    private StringRedisTemplate redisTemplate;
    @Autowired
    private PatientDeviceDao patientDeviceDao;
    @Autowired
    private DevicePatientHealthIndexDao healthIndexDao;
    /**
     * 获取爱牵挂管理员cookie
     */
    public synchronized String getCookie(){
        if(redisTemplate.hasKey(AqgConfig.redisKey)){
            return redisTemplate.opsForValue().get(AqgConfig.redisKey);
        }
        MultiValueMap<String, String> param = new LinkedMultiValueMap<>();
        param.add("username",AqgConfig.username);
        param.add("password",AqgConfig.password);
        HttpEntity<JSONObject> response = httpClientUtil.cookiePostHttp(AqgConfig.login,param);
        HttpHeaders responseHeaders = response.getHeaders();
        String cookie =  responseHeaders.get("Set-Cookie").get(0);
        logger.info("cookie="+cookie);
        redisTemplate.opsForValue().set(AqgConfig.redisKey,cookie,AqgConfig.overTime, TimeUnit.HOURS);
        return cookie;
    }
    public String testAsync(){
        String res = "";
        String key = "tmp_test";
       if(redisTemplate.hasKey(key)){
           System.out.println("11111");
           return redisTemplate.opsForValue().get(key);
       }
        res = "wagagadss";
        redisTemplate.opsForValue().set(key,res,60, TimeUnit.SECONDS);
       return  res;
    }
    /**
     * 爱牵挂设备SOS数据接收
     * @param imei 15位设备唯一序号
     * @param label_mac 只有主机下有绑定标贴才会发送这个参数,按哪个标贴就报哪个标贴Mac,按主机报警则不会发送
     * @param time_begin 发生时间YYYY-MM-DD HH:mm:SS
     *
     * 柏颐sos 接收
     * @param imei  15位设备唯一序号
     * @param time_begin  发生时间YYYY-MM-DD HH:mm:SS
     * @param heartrate   心率 int
     * @param city  城市 String
     * @param address  地址 String
     * @param lon  经度 double
     * @param lat  纬度 double
     * @param type  类型   0:Gps定位; 1:基站定位 String
     */
    @Async
    public void aqgsos(String imei,String label_mac,String time_begin, HttpServletRequest request) {
        try {
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    /**
     * 爱牵挂设备数据接收
     * @param imei 15位设备唯一序号
     * @param time_begin 发生时间YYYY-MM-DD HH:mm:SS
     * @param remaining_power 剩余电量(%)
     * @param type 开/关机类型  0开机 2普通  3低电
     *
     * 柏颐开关机数据接收
     * @param imei 15位设备唯一序号
     * @param time_begin 发生时间YYYY-MM-DD HH:mm:SS
     * @param type 开/关机类型  0:开机; 1:关机; 2:电量上报; 3:低电通知
     * @param remaining_power 剩余电量(%)
     */
    @Async
    public void aqgSwitch(String imei,String time_begin,String remaining_power,String type,HttpServletRequest request) {
        try {
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    /**
     * 爱牵挂设备数据接收
     * @param type 根据type来定义给用户推送提示  type=1 SOS,type=5 设备低电, 其他类型非本机型所有
     * @param deviceid 5位设备唯一序号
     * @param communityid 机构ID
     *
     * 柏颐数据消息通知
     * @param type  type=1 SOS,type=2 fall,type=3 new 新成员加入 ,type=4 电子围栏触发, type=5 设备低电,type=6 环境音
     * @param deviceid 15位设备唯一序号
     * @param communityid 机构ID
     * @param url  String 环境音下载地址 只有环境音(type=6)为必填,其他type都为非必填
     * @param name String 设备名称
     */
    @Async
    public void pushdata(int type,String deviceid,String communityid,HttpServletRequest request) {
        try {
            if(StringUtils.isNotBlank(deviceid)){
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    /**
     * 柏颐位置数据接收
     * @param imei 15位设备唯一序号
     * @param time_begin 发生时间YYYY-MM-DD HH:mm:SS
     * @param is_reply 是否为响应
     * @param is_track 是否轨迹
     * @param city 城市
     * @param address 地址
     * @param lon 经度
     * @param lat 纬度
     * @param type 类型   0:Gps定位; 1:基站定位
     */
    @Async
    public void byLocation(String imei,String time_begin,boolean is_reply,boolean is_track,String city,String address,double lon,double lat,String type) {
        try {
            if(StringUtils.isNotBlank(imei)){
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    /**
     * 柏颐心率数据接收
     * @param imei 15位设备唯一序号
     * @param time_begin 发生时间YYYY-MM-DD HH:mm:SS
     * @param heartrate 心率
     * @param theshold_heartrate_h 心率阈值上限 140
     * @param theshold_heartrate_l 心率阈值下限 60
     */
    @Async
    public void byHeartRate(String imei,String time_begin,int heartrate,int theshold_heartrate_h,int theshold_heartrate_l) {
        try {
            if(StringUtils.isNotBlank(imei)){
                List<DevicePatientDevice> devicePatientDeviceDos = patientDeviceDao.findByDeviceSn(imei);
                if (devicePatientDeviceDos.size()>0){
                    DevicePatientDevice devicePatientDevice = devicePatientDeviceDos.get(0);
                    DevicePatientHealthIndex patientHealthIndex = new DevicePatientHealthIndex();
                    patientHealthIndex.setDeviceSn(imei);
                    patientHealthIndex.setUser(devicePatientDevice.getUser());
                    patientHealthIndex.setIdcard(devicePatientDevice.getUserIdcard());
                    patientHealthIndex.setValue1(heartrate+"");
                    patientHealthIndex.setType(5);
                    Date recordDate = DateUtil.strToDate(time_begin);
                    patientHealthIndex.setRecordDate(recordDate);
                    patientHealthIndex.setSortDate(recordDate);
                    patientHealthIndex.setCzrq(new Date());
                    if (heartrate>=theshold_heartrate_h||heartrate<=theshold_heartrate_l){
                        patientHealthIndex.setStatus(1);
                    }
                    healthIndexDao.save(patientHealthIndex);
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    /**
     * 柏颐血压数据接收
     * @param imei 15位设备唯一序号
     * @param time_begin 发生时间YYYY-MM-DD HH:mm:SS
     * @param dbp 舒张压
     * @param dbp_l 舒张压报警下限
     * @param sbp 收缩压
     * @param sbp_h 收缩压报警上限
     */
    @Async
    public void byBloodPressure(String imei,String time_begin,int dbp,int dbp_l,int sbp,int sbp_h) {
        try {
            if(StringUtils.isNotBlank(imei)){
                List<DevicePatientDevice> devicePatientDeviceDos = patientDeviceDao.findByDeviceSn(imei);
                if (devicePatientDeviceDos.size()>0){
                    DevicePatientDevice devicePatientDevice = devicePatientDeviceDos.get(0);
                    DevicePatientHealthIndex patientHealthIndex = new DevicePatientHealthIndex();
                    patientHealthIndex.setDeviceSn(imei);
                    patientHealthIndex.setUser(devicePatientDevice.getUser());
                    patientHealthIndex.setIdcard(devicePatientDevice.getUserIdcard());
                    patientHealthIndex.setValue1(sbp+"");//收缩压
                    patientHealthIndex.setValue2(dbp+"");//舒张压
                    patientHealthIndex.setType(2);
                    Date recordDate = DateUtil.strToDate(time_begin);
                    patientHealthIndex.setRecordDate(recordDate);
                    patientHealthIndex.setSortDate(recordDate);
                    patientHealthIndex.setCzrq(new Date());
                    if (sbp>=sbp_h||dbp<=dbp_l){
                        patientHealthIndex.setStatus(1);
                    }
                    healthIndexDao.save(patientHealthIndex);
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    /**
     * 柏颐跌倒数据接收
     * @param imei 15位设备唯一序号
     * @param time_begin 发生时间YYYY-MM-DD HH:mm:SS
     * @param city 城市
     * @param address 地址
     * @param lon 经度
     * @param lat 纬度
     * @param type 类型   0:Gps定位; 1:基站定位
     */
    @Async
    public void byFall(String imei,String time_begin,String city,String address,double lon,double lat,String type) {
        try {
            if(StringUtils.isNotBlank(imei)){
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    /**
     * 柏颐sos 接收
     * @param imei  15位设备唯一序号
     * @param time_begin  发生时间YYYY-MM-DD HH:mm:SS
     * @param heartrate   心率
     * @param city  城市
     * @param address  地址
     * @param lon  经度
     * @param lat  纬度
     * @param type  类型   0:Gps定位; 1:基站定位
     */
    @Async
    public void bySos(String imei,String time_begin,int heartrate,String city,String address,double lon,double lat,String type) {
        try {
            if(StringUtils.isNotBlank(imei)){
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    /**
     * 柏颐步数数据接收
     * @param imei 15位设备唯一序号
     * @param time_begin 发生时间YYYY-MM-DD HH:mm:SS
     * @param value 步数
     */
    @Async
    public void bySteps(String imei,String time_begin,int value) {
        try {
            if(StringUtils.isNotBlank(imei)){
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    /**
     *柏颐睡眠数据接收
     * @param imei 15位设备唯一序号
     * @param time_begin 发生时间YYYY-MM-DD HH:mm:SS
     * @param time_end 结束时间YYYY-MM-DD HH:mm:SS
     * @param interval 固定30分钟
     * @param total 检测次数
     * @param data 样例截取   睡眠数据 (格式:state,turn_over|state,turn_over|...) 含义见object.md 文档中sleepdatasleep
     */
    @Async
    public void bySleep(String imei,String time_begin,String time_end,int interval,int total,String data) {
        try {
            if(StringUtils.isNotBlank(imei)){
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    /**
     * 柏颐开关机数据接收
     * @param imei 15位设备唯一序号
     * @param time_begin 发生时间YYYY-MM-DD HH:mm:SS
     * @param type 开/关机类型  0:开机; 1:关机; 2:电量上报; 3:低电通知
     * @param remaining_power 剩余电量(%)
     */
    @Async
    public void bySwitch(String imei,String time_begin,String type,int remaining_power) {
        try {
            if(StringUtils.isNotBlank(imei)){
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    /**
     * 柏颐数据消息通知
     * @param type  type=1 SOS,type=2 fall,type=3 new 新成员加入 ,type=4 电子围栏触发, type=5 设备低电,type=6 环境音
     * @param deviceid 15位设备唯一序号
     * @param communityid 机构ID
     * @param url 环境音下载地址 只有环境音(type=6)为必填,其他type都为非必填
     * @param name 设备名称
     */
    @Async
    public void byPushData(int type,String deviceid,String communityid,String url,String name) {
        try {
            if(StringUtils.isNotBlank(deviceid)){
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

+ 364 - 0
svr/svr-cloud-device/src/main/resources/application.yml

@ -0,0 +1,364 @@
#通用的配置不用区分环境变量
server:
  port: 9112
spring:
  application:
      name:  svr-cloud-device
  aop:
    proxy-target-class: true
  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
  redis:
    database: 0 # Database index used by the connection factory.
    password: # Login password of the redis server.
    timeout: 120000 # 连接超时时间(毫秒) 60秒
    pool:
      max-active: 20 # 连接池最大连接数(使用负值表示没有限制)
      max-wait: -1  # 连接池最大阻塞等待时间(使用负值表示没有限制)
      max-idle: 20  # 连接池中的最大空闲连接
      min-idle: 5  # 连接池中的最小空闲连接
  mail:
    default-encoding: UTF-8
#端口
    port: 25
#协议
    protocol: smtp
    properties.mail.smtp.auth: true
    properties.mail.smtp.starttls.enable: true
    properties.mail.smtp.starttls.required: true
    host: smtp.163.com
#发送者的邮箱密码
    password: xmijk181016jkzl
#发送者的邮箱账号
    username: i_jiankang@163.com
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.
  activemq:
    broker-url: tcp://172.26.0.116:61616
    user: admin
    password: admin
  redis:
    host: 172.26.0.253 # Redis server host.
    port: 6379 # Redis server port.
#    password: jkzl_ehr
#  zipkin:
#    base-url: http://localhost:9411 #日志追踪的地址
fastDFS:
  fastdfs_file_url: http://172.26.0.110:8888/
fast-dfs:
  tracker-server: 172.26.0.110:22122 #服务器地址
# 短信发送地址
jw:
  smsUrl: http://svr-base:10020/sms_gateway/send
myFamily:
  qrCodeFailurTime: 2
# 短信验证码发送的客户端标识,居民端
sms:
  clientId: EwC0iRSrcP
# mq 是否获取his数据,flag代表获取演示数据,false代表获取his真实数据
demo:
  flag: true
#支付支付
pay:
  flag: true
hospital:
  url: https://wx.xmzsh.com
  mqUser: JKZL
  mqPwd: 123456
  SourceSysCode: S60
  TargetSysCode: S01
wechat:
  appId: wxd03f859efdf0873d
  appSecret: 2935b54b53a957d9516c920a544f2537
  wechat_token: 27eb3bb24f149a7760cf1bb154b08040
  wechat_base_url: http%3a%2f%2fweixin.xmtyw.cn%2fwlyy-dev
  accId: gh_ffd64560fb21
  id: sd_tnzyy_wx  # base库中,wx_wechat 的id字段
  flag: false #演示环境  true走Mysql数据库  false走Oracle
im:
  im_list_get: http://172.26.0.105:3000/
  data_base_name: im_internet_hospital
es:
  pwflag: 1 # 1需要密码,2不需要密码
  index:
    Statistics: hlw_quota_test
    FollowUp: wlyy_followup
  type:
    Statistics: hlw_quota_test
    FollowUpContent: wlyy_followup_content
  host:  http://172.26.0.55:9000
  tHost: 172.26.0.55:9300
  clusterName: jkzl
  securityUser: lion:jkzlehr
  user: lion
  password: jkzlehr
# 上传文件临时路径配置
FileTempPath:
  upload_temp_path : /var/local/temp
  image_path : /var/local/upload/images
  voice_path : /var/local/upload/voice
  chat_file_path : /var/local/upload/chat
qywx:
  url: 2
  id: 2
express:
  sf_url: https://mrds-admin.sf-express.com:443
  sf_code: JKZL
  sf_check_word: QkeIfIvQdheqIv2cVSgAUnBU29lfNbVk
baiduApi:
  AK: 0vjnCSReegE7A47a941ohjv9a07ONiMC
  url: http://api.map.baidu.com/
---
spring:
  profiles: jwtest
  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.
  activemq:
    broker-url: tcp://172.26.0.116:61616
    user: admin
    password: admin
  redis:
    host: 172.26.0.253 # Redis server host.
    port: 6379 # Redis server port.
fastDFS:
  fastdfs_file_url: http://172.26.0.110:8888/
fast-dfs:
  tracker-server: 172.26.0.110:22122 #服务器地址
# 短信验证码发送的客户端标识,居民端
sms:
  clientId: EwC0iRSrcP
myFamily:
  qrCodeFailurTime: 2
# mq 是否获取his数据,flag代表获取演示数据,false代表获取his真实数据
demo:
  flag: true
#支付支付
pay:
  flag: true
hospital:
  url: https://wx.xmzsh.com
  mqUser: JKZL
  mqPwd: 123456
  SourceSysCode: S60
  TargetSysCode: S01
wechat:
  appId: wxd03f859efdf0873d
  appSecret: 2935b54b53a957d9516c920a544f2537
  wechat_token: 27eb3bb24f149a7760cf1bb154b08040
  wechat_base_url: http%3a%2f%2fweixin.xmtyw.cn%2fwlyy-dev
  accId: gh_ffd64560fb21
  id: sd_tnzyy_wx  # base库中,wx_wechat 的id字段
  flag: false #演示环境  true走Mysql数据库  false走Oracle
im:
  im_list_get: http://172.26.0.105:3000/
  data_base_name: im_internet_hospital
es:
  pwflag: 1 # 1需要密码,2不需要密码
  index:
    Statistics: hlw_quota_test
    FollowUp: wlyy_followup
  type:
    Statistics: hlw_quota_test
    FollowUpContent: wlyy_followup_content
  host:  http://172.26.0.55:9000
  tHost: 172.26.0.55:9300
  clusterName: jkzl
  securityUser: lion:jkzlehr
  user: lion
  password: jkzlehr
# 上传文件临时路径配置
FileTempPath:
  upload_temp_path : /var/local/temp
  image_path : /var/local/upload/images
  voice_path : /var/local/upload/voice
  chat_file_path : /var/local/upload/chat
#文件服务器上传配置 0本地,1.I健康,2.内网调用
testPattern:
  sign: 0
  remote_inner_url: 172.16.100.240:10023/open/fileUpload/upload_stream
wlyy:
  url: http://ehr.yihu.com/wlyy/
qywx:
  url: 2
  id: 1
express:
  sf_url: http://mrds-admin-ci.sit.sf-express.com:45478
  sf_code: HD000001
  sf_check_word: AAAABBBBCCCCDDDD
baiduApi:
  AK: 0vjnCSReegE7A47a941ohjv9a07ONiMC
  url: http://api.map.baidu.com/
---
spring:
  profiles: jwprod
  datasource:
    driver-class-name: com.mysql.jdbc.Driver
    url: jdbc:mysql://172.16.1.42:3306/base?useUnicode:true&characterEncoding=utf-8&autoReconnect=true&useSSL=false
    username: im
    password: 2oEq3Kf7
#  elasticsearch:
#    cluster-name: jkzl #集群名 默认elasticsearch
#    cluster-nodes: 192.0.33.26:9200 #配置es节点信息,逗号分隔,如果没有指定,则启动ClientNode
#    client-transport-sniff: false
#    jest:
#      uris: http://192.0.33.26:9300
#      connection-timeout: 60000 # Connection timeout in milliseconds.
#      multi-threaded: true # Enable connection requests from multiple execution threads.
  activemq:
    broker-url: tcp://59.61.92.90:9103
    user: jkzl
    password: jkzlehr
  redis:
    host: 192.0.33.26 # Redis server host.
    port: 6390 # Redis server port.
    password: Kb6wKDQP1W4
fastDFS:
  fastdfs_file_url: https://hlwyy.xmzsh.com/fastdfs/
fast-dfs:
  tracker-server: 192.0.33.26:22122 #服务器地址
# 短信验证码发送的客户端标识,居民端
sms:
  clientId: EwC0iRSrcP #todo 待配置
myFamily:
  qrCodeFailurTime: 2
# mq 是否获取his数据,flag代表获取演示数据,false代表获取his真实数据
demo:
  flag: true
#支付支付
pay:
  flag: true
hospital:
  url: https://wx.xmzsh.com
  mqUser: JKZL
  mqPwd: 123456
  SourceSysCode: S60
  TargetSysCode: S01
wechat:
  appId: wxd03f859efdf0873d
  appSecret: 2935b54b53a957d9516c920a544f2537
  wechat_token: 27eb3bb24f149a7760cf1bb154b08040
  wechat_base_url: http%3a%2f%2fweixin.xmtyw.cn%2fwlyy-dev
  accId: gh_ffd64560fb21
  id: sd_tnzyy_wx  # base库中,wx_wechat 的id字段
  flag: false #演示环境  true走Mysql数据库  false走Oracle
im:
  im_list_get: http://172.26.0.105:3000/
  data_base_name: im_internet_hospital
es:
  pwflag: 1 # 1需要密码,2不需要密码
  index:
    Statistics: hlw_quota_test
    FollowUp: wlyy_followup
  type:
    Statistics: hlw_quota_test
    FollowUpContent: wlyy_followup_content
  host:  http://172.26.0.55:9000
  tHost: 172.26.0.55:9300
  clusterName: jkzl
  securityUser: lion:jkzlehr
  user: lion
  password: jkzlehr
# 上传文件临时路径配置
FileTempPath:
  upload_temp_path : /var/local/temp
  image_path : /var/local/upload/images
  voice_path : /var/local/upload/voice
  chat_file_path : /var/local/upload/chat
#文件服务器上传配置 0本地,1.I健康,2.内网调用
testPattern:
  sign: 0
  remote_inner_url: 172.16.100.240:10023/open/fileUpload/upload_stream
wlyy:
  url: http://www.xmtyw.cn/wlyytest/
qywx:
  url: https://hlwyy.xmzsh.com/hlwyy
  id: zsyy
express:
  sf_url: https://mrds-admin.sf-express.com:443
  sf_code: WH000102
  sf_check_word: TGUQASFNAZyjt9112
baiduApi:
  AK: 0vjnCSReegE7A47a941ohjv9a07ONiMC
  url: http://api.map.baidu.com/

+ 23 - 0
svr/svr-cloud-device/src/main/resources/banner.txt

@ -0,0 +1,23 @@
${AnsiColor.BRIGHT_GREEN}
                                    ////////////////////////////////////////////////////////////////////
                                    //                          _ooOoo_                               //
                                    //                         o8888888o                              //
                                    //                         88" . "88                              //
                                    //                         (| ^_^ |)                              //
                                    //                         O\  =  /O                              //
                                    //                      ____/`---'\____                           //
                                    //                    .'  \\|     |//  `.                         //
                                    //                   /  \\|||  :  |||//  \                        //
                                    //                  /  _||||| -:- |||||-  \                       //
                                    //                  |   | \\\  -  /// |   |                       //
                                    //                  | \_|  ''\---/''  |   |                       //
                                    //                  \  .-\__  `-`  ___/-. /                       //
                                    //                ___`. .'  /--.--\  `. . ___                     //
                                    //              ."" '<  `.___\_<|>_/___.'  >'"".                  //
                                    //            | | :  `- \`.;`\ _ /`;.`/ - ` : | |                 //
                                    //            \  \ `-.   \_ __\ /__ _/   .-` /  /                 //
                                    //      ========`-.____`-.___\_____/___.-`____.-'========         //
                                    //                           `=---='                              //
                                    //      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^        //
                                    //            佛祖保佑       永不宕机     永无BUG                 //
                                    ////////////////////////////////////////////////////////////////////