浏览代码

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

 Conflicts:
	common/common-entity/sql记录
liubing 3 年之前
父节点
当前提交
5e2ce8092d
共有 28 个文件被更改,包括 1363 次插入80 次删除
  1. 41 0
      common/common-entity/sql记录
  2. 74 0
      common/common-entity/src/main/java/com/yihu/jw/entity/care/device/BaseSleepPlan.java
  3. 10 0
      common/common-entity/src/main/java/com/yihu/jw/entity/care/device/DeviceDetail.java
  4. 65 0
      common/common-entity/src/main/java/com/yihu/jw/entity/care/device/DeviceHealthIndex.java
  5. 1 1
      common/common-entity/src/main/java/com/yihu/jw/entity/care/device/DevicePatientDevice.java
  6. 37 0
      common/common-entity/src/main/java/com/yihu/jw/entity/care/device/HvDeviceRecord.java
  7. 130 0
      common/common-entity/src/main/java/com/yihu/jw/entity/care/device/HvDeviceSosLog.java
  8. 1 1
      common/common-entity/src/main/java/com/yihu/jw/entity/care/securitymonitoring/SecurityMonitoringOrderDO.java
  9. 5 0
      svr/svr-cloud-care/pom.xml
  10. 16 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/device/BaseSleepPlanDao.java
  11. 15 2
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/device/PadDeviceController.java
  12. 24 3
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/device/PatientDeviceController.java
  13. 13 4
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/statistics/DetectionPlatformEndpoint.java
  14. 14 2
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/assistance/EmergencyAssistanceService.java
  15. 95 2
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/device/PatientDeviceService.java
  16. 19 1
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/statistics/DetectionPlatformService.java
  17. 250 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/util/ArtemisPostTest.java
  18. 60 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/util/Tools.java
  19. 1 1
      svr/svr-cloud-care/src/main/resources/bootstrap.yml
  20. 3 0
      svr/svr-cloud-device/src/main/java/com/yihu/jw/care/dao/device/DeviceDetailDao.java
  21. 16 0
      svr/svr-cloud-device/src/main/java/com/yihu/jw/care/dao/device/DeviceHealthIndexDao.java
  22. 15 0
      svr/svr-cloud-device/src/main/java/com/yihu/jw/care/dao/device/HvDeviceRecordDao.java
  23. 16 0
      svr/svr-cloud-device/src/main/java/com/yihu/jw/care/dao/device/HvDeviceSosLogDao.java
  24. 125 2
      svr/svr-cloud-device/src/main/java/com/yihu/jw/care/endpoint/DeviceController.java
  25. 30 0
      svr/svr-cloud-device/src/main/java/com/yihu/jw/care/endpoint/HvDeviceController.java
  26. 175 0
      svr/svr-cloud-device/src/main/java/com/yihu/jw/care/service/HvDeviceService.java
  27. 68 60
      svr/svr-cloud-device/src/main/java/com/yihu/jw/care/service/YsDeviceService.java
  28. 44 1
      svr/svr-cloud-device/src/main/java/com/yihu/jw/care/util/ArtemisPostTest.java

+ 41 - 0
common/common-entity/sql记录

@ -1309,6 +1309,47 @@ CREATE TABLE `base_patient_add` (
  `del` int(1) DEFAULT '1' COMMENT '1有效  0失效',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
-- 2021-08-23 气感烟感设备
CREATE TABLE `base_device_health_index` (
  `id` varchar(50) NOT NULL,
  `device_sn` varchar(50) DEFAULT NULL COMMENT '设备sn',
  `device_type` varchar(4) DEFAULT NULL COMMENT '设备类型 1气感 2烟感',
  `value` varchar(20) DEFAULT NULL COMMENT '测量值',
  `unit` varchar(20) DEFAULT NULL COMMENT '单位',
  `create_time` datetime DEFAULT NULL COMMENT '创建时间',
  `record_time` varchar(50) DEFAULT NULL COMMENT '记录时间',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='烟感气感实时数据';
CREATE TABLE `base_hvdevice_record` (
  `id` varchar(50) NOT NULL,
  `device_id` varchar(50) DEFAULT NULL COMMENT '海康平台设备id',
  `device_sn` varchar(50) DEFAULT NULL COMMENT '设备sn',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='海康烟感气感设备记录表';
CREATE TABLE `base_hvdevice_sos_log` (
  `id` varchar(50) NOT NULL,
  `resourceID` varchar(50) DEFAULT NULL,
  `resourceSerial` varchar(50) DEFAULT NULL,
  `resourceName` varchar(50) DEFAULT NULL,
  `alarmNum` int(10) DEFAULT NULL,
  `alarmTime` varchar(50) DEFAULT NULL,
  `monitorValue` varchar(50) DEFAULT NULL,
  `alarmType` varchar(20) DEFAULT NULL,
  `systemType` varchar(20) DEFAULT NULL,
  `alarmID` varchar(50) DEFAULT NULL,
  `resourceType` varchar(50) DEFAULT NULL,
  `location` varchar(500) DEFAULT NULL,
  `create_time` datetime DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='烟感气感设备报警日志记录表';
-- 2021-08-23 已执行
ALTER table `base`.`wlyy_devices` add column `device_type` tinyint(2) DEFAULT NULL COMMENT '设备种类 0健康设备 1安防设备'
-- 20210819
alter table wlyy_devices add COLUMN device_type TINYINT(2) default null COMMENT '设备种类 0健康设备 1安防设备';
alter table wlyy_patient_device add COLUMN device_type TINYINT(2) default null COMMENT '设备种类 0健康设备 1安防设备';

+ 74 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/care/device/BaseSleepPlan.java

@ -0,0 +1,74 @@
package com.yihu.jw.entity.care.device;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.jw.entity.IdEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/***
 * @ClassName: BaseSleepPlan
 * @Description:    睡眠带监测计划
 * @Auther: shi kejing
 * @Date: 2021/8/23 17:17
 */
@Entity
@Table(name="base_sleep_plan")
public class BaseSleepPlan extends IdEntity {
    private String patient;
    private String deviceSn;
    private String getUpTime;
    private String napTime;
    private String nightRestTime;
    private Date createTime;
    public String getPatient() {
        return patient;
    }
    public void setPatient(String patient) {
        this.patient = patient;
    }
    public String getDeviceSn() {
        return deviceSn;
    }
    public void setDeviceSn(String deviceSn) {
        this.deviceSn = deviceSn;
    }
    public String getGetUpTime() {
        return getUpTime;
    }
    public void setGetUpTime(String getUpTime) {
        this.getUpTime = getUpTime;
    }
    public String getNapTime() {
        return napTime;
    }
    public void setNapTime(String napTime) {
        this.napTime = napTime;
    }
    public String getNightRestTime() {
        return nightRestTime;
    }
    public void setNightRestTime(String nightRestTime) {
        this.nightRestTime = nightRestTime;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
}

+ 10 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/care/device/DeviceDetail.java

@ -43,6 +43,7 @@ public class DeviceDetail extends IdEntity {
    private Integer isBinding;//是否绑定(0否 1 绑定单端口 2 绑定双端口)
    private String bindingCount;//绑定次数({"1":"0", "2":"0"})
    private Date grantTime;//发放时间
    private Integer deviceType;
    //1.5.0版本新增字段
    private String grantDoctor;//发放医生code
@ -314,4 +315,13 @@ public class DeviceDetail extends IdEntity {
    public void setGrantDoctorName(String grantDoctorName) {
        this.grantDoctorName = grantDoctorName;
    }
    @Column(name = "device_type")
    public Integer getDeviceType() {
        return deviceType;
    }
    public void setDeviceType(Integer deviceType) {
        this.deviceType = deviceType;
    }
}

+ 65 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/care/device/DeviceHealthIndex.java

@ -0,0 +1,65 @@
package com.yihu.jw.entity.care.device;
import com.yihu.jw.entity.UuidIdentityEntityWithCreateTime;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
 * Created with IntelliJ IDEA.
 * base_device_health_index
 * 烟感气感实时数据
 * @Author: yeshijie
 * @Date: 2021/8/23
 * @Description:
 */
@Entity
@Table(name = "base_device_health_index")
public class DeviceHealthIndex extends UuidIdentityEntityWithCreateTime{
    private String deviceSn;//设备sn
    private String deviceType;//设备类型 1气感 2烟感
    private String value;//测量值
    private String unit;//单位
    private String recordTime;//记录时间
    public String getDeviceSn() {
        return deviceSn;
    }
    public void setDeviceSn(String deviceSn) {
        this.deviceSn = deviceSn;
    }
    public String getDeviceType() {
        return deviceType;
    }
    public void setDeviceType(String deviceType) {
        this.deviceType = deviceType;
    }
    public String getValue() {
        return value;
    }
    public void setValue(String value) {
        this.value = value;
    }
    public String getUnit() {
        return unit;
    }
    public void setUnit(String unit) {
        this.unit = unit;
    }
    public String getRecordTime() {
        return recordTime;
    }
    public void setRecordTime(String recordTime) {
        this.recordTime = recordTime;
    }
}

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

@ -21,7 +21,7 @@ public class DevicePatientDevice extends IdEntity {
    private String deviceName;
    // 用户code
    private String user;
    // 设备类型标识 1血糖仪,2.血压计,3药盒,4智能手表,7 = 居家报警器,12 监控器 13 睡眠带 14火灾报警器
    // 设备类型标识 1血糖仪,2.血压计,3药盒,4智能手表,7 = 居家报警器,12 监控器 13 睡眠带 14气感报警器 15烟感报警器
    private String categoryCode;
    // 用户类型标准 -1代表单用户
    private String userType;

+ 37 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/care/device/HvDeviceRecord.java

@ -0,0 +1,37 @@
package com.yihu.jw.entity.care.device;
import com.yihu.jw.entity.UuidIdentityEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
 * Created with IntelliJ IDEA.
 * '海康烟感气感设备记录表'
 * @Author: yeshijie
 * @Date: 2021/8/23
 * @Description:
 */
@Entity
@Table(name = "base_hvdevice_record")
public class HvDeviceRecord extends UuidIdentityEntity {
    private String deviceId;//海康平台设备id
    private String deviceSn;//设备sn
    public String getDeviceId() {
        return deviceId;
    }
    public void setDeviceId(String deviceId) {
        this.deviceId = deviceId;
    }
    public String getDeviceSn() {
        return deviceSn;
    }
    public void setDeviceSn(String deviceSn) {
        this.deviceSn = deviceSn;
    }
}

+ 130 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/care/device/HvDeviceSosLog.java

@ -0,0 +1,130 @@
package com.yihu.jw.entity.care.device;
import com.yihu.jw.entity.UuidIdentityEntityWithCreateTime;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
 * Created with IntelliJ IDEA.
 * 烟感气感设备报警日志记录表
 * @Author: yeshijie
 * @Date: 2021/8/23
 * @Description:
 */
@Entity
@Table(name = "base_hvdevice_sos_log")
public class HvDeviceSosLog extends UuidIdentityEntityWithCreateTime{
    private String resourceID;
    private String resourceSerial;
    private String resourceName;
    private Integer alarmNum;
    private String alarmTime;
    private String monitorValue;
    private String alarmType;
    private String systemType;
    private String alarmID;
    private String resourceType;
    private String location;
    @Column(name = "resourceID")
    public String getResourceID() {
        return resourceID;
    }
    public void setResourceID(String resourceID) {
        this.resourceID = resourceID;
    }
    @Column(name = "resourceSerial")
    public String getResourceSerial() {
        return resourceSerial;
    }
    public void setResourceSerial(String resourceSerial) {
        this.resourceSerial = resourceSerial;
    }
    @Column(name = "resourceName")
    public String getResourceName() {
        return resourceName;
    }
    public void setResourceName(String resourceName) {
        this.resourceName = resourceName;
    }
    @Column(name = "alarmNum")
    public Integer getAlarmNum() {
        return alarmNum;
    }
    public void setAlarmNum(Integer alarmNum) {
        this.alarmNum = alarmNum;
    }
    @Column(name = "alarmTime")
    public String getAlarmTime() {
        return alarmTime;
    }
    public void setAlarmTime(String alarmTime) {
        this.alarmTime = alarmTime;
    }
    @Column(name = "monitorValue")
    public String getMonitorValue() {
        return monitorValue;
    }
    public void setMonitorValue(String monitorValue) {
        this.monitorValue = monitorValue;
    }
    @Column(name = "alarmType")
    public String getAlarmType() {
        return alarmType;
    }
    public void setAlarmType(String alarmType) {
        this.alarmType = alarmType;
    }
    @Column(name = "systemType")
    public String getSystemType() {
        return systemType;
    }
    public void setSystemType(String systemType) {
        this.systemType = systemType;
    }
    @Column(name = "alarmID")
    public String getAlarmID() {
        return alarmID;
    }
    public void setAlarmID(String alarmID) {
        this.alarmID = alarmID;
    }
    @Column(name = "resourceType")
    public String getResourceType() {
        return resourceType;
    }
    public void setResourceType(String resourceType) {
        this.resourceType = resourceType;
    }
    @Column(name = "location")
    public String getLocation() {
        return location;
    }
    public void setLocation(String location) {
        this.location = location;
    }
}

+ 1 - 1
common/common-entity/src/main/java/com/yihu/jw/entity/care/securitymonitoring/SecurityMonitoringOrderDO.java

@ -318,7 +318,7 @@ public class SecurityMonitoringOrderDO extends UuidIdentityEntityWithOperator {
    private String serviceStatus;//服务类型 1-预约项目 2-即时项目
    private String orderInfo;//工单详情 0-未推送 1-未确认 2-已确认
    private String doctorConfirmFinishImg;
    private Integer orderSource;//工单发起来源状态 1APP 2手环 3居家报警 4监控器发起 5睡眠带
    private Integer orderSource;//工单发起来源状态 1APP 2手环 3居家报警 4监控器发起 5睡眠带 6气感报警器 7 烟感报警器
    private Integer emergencyCancel;// 紧急预警工单误报警原因 字典emergency_cancel
    private String topicItem;//安防工单所属专题 base_system_dict_entry表service_item
    private String sceneImg;//现场照片

+ 5 - 0
svr/svr-cloud-care/pom.xml

@ -256,6 +256,11 @@
            <artifactId>es-service</artifactId>
            <version>2.0.0</version>
        </dependency>
        <dependency>
            <groupId>com.hikvision.ga</groupId>
            <artifactId>artemis-http-client</artifactId>
            <version>1.1.3</version>
        </dependency>
    </dependencies>
    <build>

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

@ -0,0 +1,16 @@
package com.yihu.jw.care.dao.device;
import com.yihu.jw.entity.care.device.BaseSleepDeviceReport;
import com.yihu.jw.entity.care.device.BaseSleepPlan;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/***
 * @ClassName: BaseSleepPlanDao
 * @Description:
 * @Auther: shi kejing
 * @Date: 2021/8/23 17:20
 */
public interface BaseSleepPlanDao extends PagingAndSortingRepository<BaseSleepPlan,Long>,
        JpaSpecificationExecutor<BaseSleepPlan> {
}

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

@ -13,14 +13,17 @@ import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.sync.BaseSyncDataDO;
import com.yihu.jw.entity.care.device.BaseSleepPlan;
import com.yihu.jw.entity.care.device.DevicePatientDevice;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.restmodel.ResponseContant;
import com.yihu.jw.restmodel.web.ListEnvelop;
import com.yihu.jw.rm.base.BaseRequestMapping;
import com.yihu.jw.utils.StringUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.RequestMapping;
@ -104,10 +107,20 @@ public class PadDeviceController extends BaseController {
    public String saveDevice(@ApiParam(name = "json", value = "设备数据json", defaultValue = "{     \"deviceId\":\"3\",     \"deviceName\":\"血压计-优瑞恩\",     \"deviceSn\":\"7052169111\",     \"categoryCode\":\"7\",     \"userType\":\"-1\", \"sosAddress\":\"福建省厦门市思明区望海路55号之1\" }")
                             @RequestParam(value = "json", required = true) String json,
                             @ApiParam(name = "patient", value = "居民code") @RequestParam(value = "patient", required = false) String patientCode,
                             @ApiParam(name = "doctorCode", value = "管理员code") @RequestParam(value = "doctorCode", required = false) String doctorCode
                             @ApiParam(name = "doctorCode", value = "管理员code") @RequestParam(value = "doctorCode", required = false) String doctorCode,
                             @ApiParam(name = "safe_area",value = "lon1,lat1;lon2,lat2; 5个坐标 形成一个封闭区域  A;B;C;D;A ")  @RequestParam(value = "safe_area",required = false)String safe_area,
                             @ApiParam(name = "name",value = "安全区名称") @RequestParam(value = "name",required = false)String name,
                             @ApiParam(name = "fenceNO",value = "安全区编号") @RequestParam(value = "fenceNO",required = false)Integer fenceNO,
                             @ApiParam(name = "sleepPlanJson", value = "睡眠计划json") @RequestParam(value = "sleepPlanJson", required = false) String sleepPlanJson
                             //{"deviceSn": "7052169111","getUpTime": "07:00","napTime": "13:00","nightRestTime": "21:30"}
                             ) {
        try {
            DevicePatientDevice device = objectMapper.readValue(json, DevicePatientDevice.class);
            BaseSleepPlan sleepPlan = new BaseSleepPlan();
            if (StringUtils.isNotBlank(sleepPlanJson)){
                sleepPlan = objectMapper.readValue(sleepPlanJson,BaseSleepPlan.class);
                sleepPlan.setPatient(patientCode);
            }
            // 设置患者标识
            device.setUser(patientCode);
            //患者和设备是否首绑
@ -123,7 +136,7 @@ public class PadDeviceController extends BaseController {
            device.setAgentName(doctor.getName());
            String sn = device.getDeviceSn();
            synchronized (sn.intern()){
                Boolean flagDevice = patientDeviceService.saveDevice(device);
                Boolean flagDevice = patientDeviceService.saveDevice(device,safe_area,fenceNO,name,sleepPlan);
                if (flagDevice == false){
                    return write(-1,"请填写投放地址");
                }

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

@ -7,10 +7,10 @@ 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.BaseSleepPlan;
import com.yihu.jw.entity.care.device.DevicePatientDevice;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.restmodel.ResponseContant;
import com.yihu.jw.restmodel.web.ListEnvelop;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
@ -68,6 +68,17 @@ public class PatientDeviceController extends BaseController {
        }
    }
    @ApiOperation("环境信息")
    @RequestMapping(value = "envMessage", method = RequestMethod.GET)
    public String envMessage(@ApiParam(name = "patientId", value = "居民id", defaultValue = "1")
                                    @RequestParam(value = "patientId", required = true) String patientId){
        try {
            JSONObject json = patientDeviceService.envMessage(patientId);
            return write(200,"获取成功","data",json);
        } catch (Exception ex) {
            return errorResult(ex);
        }
    }
    /**
     * 设备保存接口  ---增加血糖时间段保存 Reece v1.3.3
@ -75,9 +86,19 @@ public class PatientDeviceController extends BaseController {
    @ApiOperation("设备保存接口")
    @RequestMapping(value = "SavePatientDevice", method = RequestMethod.POST)
    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) {
                             @RequestParam(value = "json", required = true) String json,
                             @ApiParam(name = "safe_area",value = "lon1,lat1;lon2,lat2; 5个坐标 形成一个封闭区域  A;B;C;D;A ") @RequestParam(value = "safe_area",required = false)String safe_area,
                             @ApiParam(name = "name",value = "安全区名称") @RequestParam(value = "name",required = false)String name,
                             @ApiParam(name = "fenceNO",value = "安全区编号") @RequestParam(value = "fenceNO",required = false)Integer fenceNO,
                             @ApiParam(name = "sleepPlanJson", value = "睡眠计划json") @RequestParam(value = "sleepPlanJson", required = false) String sleepPlanJson){
        //{"deviceSn": "7052169111","getUpTime": "07:00","napTime": "13:00","nightRestTime": "21:30"})
        try {
            DevicePatientDevice device = objectMapper.readValue(json, DevicePatientDevice.class);
            BaseSleepPlan sleepPlan = new BaseSleepPlan();
            if (StringUtils.isNotBlank(sleepPlanJson)){
                sleepPlan = objectMapper.readValue(sleepPlanJson,BaseSleepPlan.class);
                sleepPlan.setPatient(getRepUID());
            }
            // 设置患者标识
            device.setUser(getRepUID());
            //患者和设备是否首绑
@ -96,7 +117,7 @@ public class PatientDeviceController extends BaseController {
            String sn = device.getDeviceSn();
            synchronized (sn.intern()){
//                patientDeviceService.saveDevice(device);
                Boolean flagDevice = patientDeviceService.saveDevice(device);
                Boolean flagDevice = patientDeviceService.saveDevice(device,safe_area,fenceNO,name,sleepPlan);
                if (flagDevice == false){
                    return write(-1,"请填写投放地址");
                }

+ 13 - 4
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/statistics/DetectionPlatformEndpoint.java

@ -29,9 +29,9 @@ public class DetectionPlatformEndpoint extends EnvelopRestEndpoint {
    @Autowired
    private DetectionPlatformService platformService;
    @GetMapping(value = "statisticsTotalAmount")
    @ApiOperation(value = "统计总数")
    public PageEnvelop statisticsTotalAmount(
    @GetMapping(value = "security")
    @ApiOperation(value = "体征监测/安防监护")
    public PageEnvelop security(
            @ApiParam(name="page",value = "page") @RequestParam(required = true) int page,
            @ApiParam(name="size",value = "size") @RequestParam(required = true) int size,
            @ApiParam(name="type",value = "type=1(健康监测)   type=2(安防检测)") @RequestParam(required = true) int type) {
@ -42,6 +42,15 @@ public class DetectionPlatformEndpoint extends EnvelopRestEndpoint {
        }
    }
    @GetMapping(value = "company")
    @ApiOperation(value = "设备入驻")
    public ObjEnvelop getDeviceCompany(){
        try {
            JSONObject o = platformService.getDeviceComapny();
            return success(o);
        }catch (Exception e){
            return failedObjEnvelopException(e);
        }
    }
}

+ 14 - 2
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/assistance/EmergencyAssistanceService.java

@ -9,7 +9,6 @@ import com.yihu.jw.care.dao.device.PatientDeviceDao;
import com.yihu.jw.care.dao.security.BaseEmergencyWarnLogDao;
import com.yihu.jw.care.dao.security.EmergencyWarnConclusionDao;
import com.yihu.jw.care.dao.security.EmergencyWarnDoctorResponseDao;
import com.yihu.jw.care.dao.security.SecurityMonitoringOrderDao;
import com.yihu.jw.care.dao.sign.ServicePackageSignRecordDao;
import com.yihu.jw.care.dao.team.BaseTeamMemberDao;
import com.yihu.jw.care.service.common.DictService;
@ -30,7 +29,6 @@ import com.yihu.jw.entity.care.device.DevicePatientDevice;
import com.yihu.jw.entity.care.securitymonitoring.BaseEmergencyWarnLogDO;
import com.yihu.jw.entity.care.securitymonitoring.EmergencyWarnConclusionDO;
import com.yihu.jw.entity.care.securitymonitoring.EmergencyWarnDoctorResponseDO;
import com.yihu.jw.entity.care.securitymonitoring.SecurityMonitoringOrderDO;
import com.yihu.jw.entity.hospital.message.SystemMessageDO;
import com.yihu.jw.hospital.message.dao.SystemMessageDao;
import com.yihu.jw.im.dao.ConsultDao;
@ -108,6 +106,20 @@ public class EmergencyAssistanceService extends BaseJpaService<EmergencyAssistan
    @Autowired
    private ContactsService contactsService;
    /**
     * 获取百度天气
     */
    public JSONObject getBaiduWeather(){
        String url = "https://api.map.baidu.com/weather/v1/?district_id=330100&data_type=now&ak=0vjnCSReegE7A47a941ohjv9a07ONiMC";
        String response = httpClientUtil.get(url,"UTF-8");
        JSONObject responseObj = JSONObject.parseObject(response);
        if (responseObj.getInteger("status")==0){
            JSONObject now = responseObj.getJSONObject("result").getJSONObject("now");
            return now;
        }
        return new JSONObject();
    }
    /**
     * 新建居民紧急救助
     * @param patient

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

@ -4,9 +4,11 @@ package com.yihu.jw.care.service.device;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.yihu.jw.care.config.AqgConfig;
import com.yihu.jw.care.dao.device.BaseSleepPlanDao;
import com.yihu.jw.care.dao.device.DeviceDao;
import com.yihu.jw.care.dao.device.DeviceDetailDao;
import com.yihu.jw.care.dao.device.PatientDeviceDao;
import com.yihu.jw.care.service.assistance.EmergencyAssistanceService;
import com.yihu.jw.care.service.contacts.ContactsService;
import com.yihu.jw.care.service.wechat.WeiXinAccessTokenUtils;
import com.yihu.jw.care.util.ConcealUtil;
@ -14,12 +16,12 @@ import com.yihu.jw.care.util.MyJdbcTemplate;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.care.device.BaseSleepPlan;
import com.yihu.jw.entity.care.device.Device;
import com.yihu.jw.entity.care.device.DeviceDetail;
import com.yihu.jw.entity.care.device.DevicePatientDevice;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.restmodel.ResponseContant;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.util.common.GpsUtil;
import com.yihu.jw.util.common.IdCardUtil;
import com.yihu.jw.util.date.DateUtil;
@ -87,6 +89,8 @@ public class PatientDeviceService extends BaseJpaService<DevicePatientDevice, Pa
    private HttpClientUtil httpClientUtil;
    @Autowired
    private YsDeviceService ysDeviceService;
    @Autowired
    private BaseSleepPlanDao sleepPlanDao;
    @Autowired
    WeiXinAccessTokenUtils tokenUtils;
@ -103,6 +107,8 @@ public class PatientDeviceService extends BaseJpaService<DevicePatientDevice, Pa
    private ContactsService contactsService;
    @Autowired
    private HealthIndexUtil healthIndexUtil;
    @Autowired
    private EmergencyAssistanceService emergencyAssistanceService;
    @PostConstruct
    public void init() {
@ -117,6 +123,47 @@ public class PatientDeviceService extends BaseJpaService<DevicePatientDevice, Pa
        relations.put(8, "免疫关联");
    }
    /**
     * 获取烟雾 燃气浓度
     * @param patient
     */
    public JSONObject concentrationMessage(String patient){
        JSONObject result = new JSONObject();
        String sql = "SELECT r.value from wlyy_patient_device pd,base_device_health_index r " +
                "WHERE pd.device_sn = r.device_sn and pd.`user` = '"+patient+"' ";
        String sql1 = sql + " and pd.category_code='14' ORDER BY r.create_time desc LIMIT 1";
        String sql2 = sql + " and pd.category_code='15' ORDER BY r.create_time desc LIMIT 1";
        List<Map<String,Object>> list1 = jdbcTemplate.queryForList(sql1);
        if(list1.size()==0){
            result.put("methane","-1");
        }else{
            result.put("methane",list1.get(0).get("value"));
        }
        List<Map<String,Object>> list2 = jdbcTemplate.queryForList(sql2);
        if(list2.size()==0){
            result.put("smoke","-1");
        }else{
            result.put("smoke",list2.get(0).get("value"));
        }
        return result;
    }
    /**
     * 环境信息
     * @return
     */
    public JSONObject envMessage(String patient){
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("concentration",concentrationMessage(patient));
        jsonObject.put("weather",emergencyAssistanceService.getBaiduWeather());
        return jsonObject;
    }
    /**
     * 验证sn码 先调总部接口 未注册才查询本地数据库,如果也没有才不能绑定
     * 屏蔽总部调总部接口,直接本地数据库验证,modify by Hmf on 2020.1.15
@ -136,13 +183,14 @@ public class PatientDeviceService extends BaseJpaService<DevicePatientDevice, Pa
    /**
     * 保存患者设备
     */
    public boolean saveDevice(DevicePatientDevice devicePatientDevice) throws Exception {
    public boolean saveDevice(DevicePatientDevice devicePatientDevice, String safe_area, Integer fenceNO, String name, BaseSleepPlan sleepPlan) throws Exception {
        //判断sn码是否被使用
        String sn = devicePatientDevice.getDeviceSn();
        String type = devicePatientDevice.getCategoryCode();
        Long deviceId = devicePatientDevice.getDeviceId();
        String userType = devicePatientDevice.getUserType();
        String sosAddress = null;
        String url ="";
        if (userType == null) {
            userType = "-1";
            devicePatientDevice.setUserType("-1");
@ -177,6 +225,12 @@ public class PatientDeviceService extends BaseJpaService<DevicePatientDevice, Pa
        if (needVerify) {
            DevicePatientDevice device = patientDeviceDao.findByDeviceSnAndUserType(sn, userType);
            if (device != null && !device.getId().equals(devicePatientDevice.getId()) && device.getDel() == 0) {
                //V1.0.0    监控器、报警器、燃气传感器 烟雾传感器支持一个设备绑定多个居民
                //监控器 12   报警器 7  14  15
                if ("12".equals(type) || "14".equals(type) || "15".equals(type) || "7".equals(type) ) {
                    System.out.println("此类设备支持多绑定");
                }
                throw new Exception("sn码" + sn + "已被使用!");
            }
        }
@ -186,7 +240,46 @@ public class PatientDeviceService extends BaseJpaService<DevicePatientDevice, Pa
        BasePatientDO patient = patientDao.findById(devicePatientDevice.getUser());
        devicePatientDevice.setUserIdcard(patient.getIdcard());
        MultiValueMap<String, String> param = new LinkedMultiValueMap<>();
        if(checkDeviceSn(sn)){
            //V1.0.0 添加手表的时候需要设置围栏
            if ("4".equals(type)){
                Device device = deviceDao.findOne(new Long (type));
                if (device!=null){
                    if ("X1".equals(device.getModel())){
                        url = MessageFormat.format(AqgConfig.X1fence_area, sn,fenceNO);
                    }
                }
                param.add("name", name);
                param.add("freq", "1"); //"0,触发一天;1,每日触发 "
                param.add("enable","1");
                param.add("time_begin", "0");
                param.add("time_end", "86400");
                param.add("safe_area", safe_area);
                HttpEntity<com.alibaba.fastjson.JSONObject> response = httpClientUtil.aqgCookieHttp(url, param, HttpMethod.POST, getCookie());
                com.alibaba.fastjson.JSONObject object = response.getBody();
                if (object.get("success").equals("true")){
                    System.out.println("围栏地址添加成功");
                } else {
                    System.out.println("添加失败");
                    String message = "围栏设置失败";
                    throw new Exception(message);
                }
            }
            if ("16".equals(type)){ //智能拐杖
            }
            if ("13".equals(type)){ //睡眠带
                if (StringUtils.isBlank(sleepPlan.getGetUpTime()) || StringUtils.isBlank(sleepPlan.getNightRestTime())) {
                    String message = "请完善睡眠时间规划";
                    throw new Exception(message);
                }
                sleepPlanDao.save(sleepPlan);
            }
            patientDeviceDao.save(devicePatientDevice);
        }else {
            String message = "设备不存在";

+ 19 - 1
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/statistics/DetectionPlatformService.java

@ -1,5 +1,6 @@
package com.yihu.jw.care.service.statistics;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.restmodel.web.PageEnvelop;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -45,8 +46,25 @@ public class DetectionPlatformService  {
            List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
            return PageEnvelop.getSuccessListWithPage("查询成功",list,page,pageSize,count);
        }
    }
    public JSONObject getDeviceComapny(){
        JSONObject object = new JSONObject();
        String deviceTypeSum = "SELECT COUNT(1) deviceTypeSum FROM dm_device where del = 1 GROUP BY brands";
        List<Map<String , Object>> deviceList = jdbcTemplate.queryForList(deviceTypeSum);
        if (deviceList.size() > 0) {
            object.put("deviceTypeCount",deviceList.size()); //设备品牌数量
        } else {
            object.put("deviceTypeCount",0);
        }
        String manufacturerSql = "";
        List<Map<String , Object>> manufacturerList = jdbcTemplate.queryForList(manufacturerSql);
        if (manufacturerList.size() > 0) {
            object.put("manufacturerCount",manufacturerList.size());
        } else {
            object.put("manufacturerCount",0);
        }
        return object;
    }
}

+ 250 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/util/ArtemisPostTest.java

@ -0,0 +1,250 @@
package com.yihu.jw.care.util;
import com.alibaba.fastjson.JSONObject;
import com.hikvision.artemis.sdk.ArtemisHttpUtil;
import com.hikvision.artemis.sdk.config.ArtemisConfig;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
public class ArtemisPostTest {
	/**
	 * 请根据自己的appKey和appSecret更换static静态块中的三个参数. [1 host]
	 * 如果你选择的是和现场环境对接,host要修改为现场环境的ip,https端口默认为443,http端口默认为80.例如10.33.25.22:443 或者10.33.25.22:80
	 * appKey和appSecret请按照或得到的appKey和appSecret更改.
	 * TODO 调用前先要清楚接口传入的是什么,是传入json就用doPostStringArtemis方法,下载图片doPostStringImgArtemis方法
	 */
	static {
		ArtemisConfig.host = "open.hikfirecloud.com";// 代理API网关nginx服务器ip端口
		ArtemisConfig.appKey = "23553385";// 秘钥appkey
		ArtemisConfig.appSecret = "HfjuKlQnzTbn0mfxm5Vk";// 秘钥appSecret
	}
	/**
	 * 能力开放平台的网站路径
	 * TODO 路径不用修改,就是/artemis
	 */
	private static final String ARTEMIS_PATH = "/artemis";
	/**
	 * 调用POST请求类型(application/json)接口,这里以入侵报警事件日志为例
	 * https://open.hikvision.com/docs/918519baf9904844a2b608e558b21bb6#e6798840
	 *
	 * @return
	 */
	public static String callPostStringApi(String url,String body){
		/**
		 * http://10.33.47.50/artemis/api/scpms/v1/eventLogs/searches
		 * 根据API文档可以看出来,这是一个POST请求的Rest接口,而且传入的参数值为一个json
		 * ArtemisHttpUtil工具类提供了doPostStringArtemis这个函数,一共六个参数在文档里写明其中的意思,因为接口是https,
		 * 所以第一个参数path是一个hashmap类型,请put一个key-value,query为传入的参数,body为传入的json数据
		 * 传入的contentType为application/json,accept不指定为null
		 * header没有额外参数可不传,指定为null
		 *
		 */
		final String getCamsApi = ARTEMIS_PATH + url;
		Map<String, String> path = new HashMap<String, String>(2) {
			{
				put("https://", getCamsApi);//根据现场环境部署确认是http还是https
			}
		};
		String result = ArtemisHttpUtil.doPostStringArtemis(path,body,null,null,"application/json",null);// post请求application/json类型参数
		return result;
	}
	/**
	 * 调用POST请求下载图片类型接口,这里以获取访客记录中的图片接口为例
	 * https://open.hikvision.com/docs/a0a1a0a24701a00aa904f7b151f97410#f11f3208
	 *
	 * @return
	 */
	public static void callPostImgStringApi(){
		/**
		 * http://10.33.47.50/api/visitor/v1/record/pictures
		 * 根据API文档可以看出来,这是一个POST请求的Rest接口,而且传入的参数值为一个json
		 * ArtemisHttpUtil工具类提供了doPostStringImgArtemis这个函数,一共六个参数在文档里写明其中的意思,因为接口是https,
		 * 所以第一个参数path是一个hashmap类型,请put一个key-value,query为传入的参数,body为传入的json数据
		 * 传入的contentType为application/json,accept不指定为null
		 * header没有额外参数可不传,指定为null
		 *
		 */
		final String VechicleDataApi = ARTEMIS_PATH +"/api/visitor/v1/record/pictures";
		Map<String,String> path = new HashMap<String,String>(2){
			{
				put("http://",VechicleDataApi);
			}
		};
		JSONObject jsonBody = new JSONObject();
		jsonBody.put("svrIndexCode", "8907fd9d-d090-43d3-bb3a-3a4b10dd7219");
		jsonBody.put("picUri", "/pic?0dd453i3c-e*046456451175m6ep=t=i2p*i=d1s*i3d0d*=*1b8i81f4747059503--bdf90a-855s5721z3b9i=1=");
		String body = jsonBody.toJSONString();
		System.out.println("body: "+body);
		HttpResponse result = ArtemisHttpUtil.doPostStringImgArtemis(path,body,null,null,"application/json",null);
		try {
			HttpResponse resp = result;
			if (200==resp.getStatusLine().getStatusCode()) {
				HttpEntity entity = resp.getEntity();
				InputStream in = entity.getContent();
				Tools.savePicToDisk(in, "d:/", "test4.jpg");
				System.out.println("下载成功");
			}else{
				System.out.println("下载出错");
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	/**
	 * 消息订阅
	 *
	 * 980001	资源信息变更通知	1
		 980002	报警实时信息	2
		 980003	报警处理信息	3
		 980004	故障实时信息	4
		 980005	故障处理信息	5
		 980006	设备在离线消息	6
		 980007	监控点在离线消息	7
		 980008	监测实时信息	8
     */
	public static void subscription_info(String msgType){
		String url = "/api/firepro/v1/subscription/info";
		//消息类型	msgType	String	是
		//回调URL	postUrl	String	是
		JSONObject jsonBody = new JSONObject();
		jsonBody.put("msgType", msgType);
		jsonBody.put("postUrl", "http://ehr.yihu.com/wlyy/aqg/hvdevice/messageNotification");
		//http://ehr.yihu.com/wlyy/aqg/device/byOnlineStatus
		//http://ehr.yihu.com/wlyy/aqg
		String body = jsonBody.toJSONString();
		String StringeResult = callPostStringApi(url,body);
		System.out.println("StringeResult结果示例: "+StringeResult);
	}
	/**
	 * 修改订阅
	 */
	public void subscription_update(){
		String url = "/api/firepro/v1/subscription/update";
		JSONObject jsonBody = new JSONObject();
		jsonBody.put("pageNo", 1);
		jsonBody.put("pageSize", 3);
		String body = jsonBody.toJSONString();
		String StringeResult = callPostStringApi(url,body);
		System.out.println("StringeResult结果示例: "+StringeResult);
	}
	/**
	 * 删除订阅
	 */
	public void subscription_deletion(){
		String url = "/api/firepro/v1/subscription/deletion";
		JSONObject jsonBody = new JSONObject();
		jsonBody.put("pageNo", 1);
		jsonBody.put("pageSize", 3);
		String body = jsonBody.toJSONString();
		String StringeResult = callPostStringApi(url,body);
		System.out.println("StringeResult结果示例: "+StringeResult);
	}
	/**
	 * 设备监测信息查询
	 */
	public static String getMonitor(String deviceID){
		String url = "/api/firepro/v1/getMonitor";
		JSONObject jsonBody = new JSONObject();
		jsonBody.put("deviceID", deviceID);
		jsonBody.put("pageNo", 1);
		jsonBody.put("pageSize", 1);
		jsonBody.put("flagId", "");
		jsonBody.put("offset", 0);
		String body = jsonBody.toJSONString();
		String StringeResult = callPostStringApi(url,body);
		return StringeResult;
	}
	/**
	 * 获取消防设备信息
	 */
	public static String getDevice(){
		String url = "/api/firepro/v1/getDevice";
		JSONObject jsonBody = new JSONObject();
		jsonBody.put("pageNo", 1);
		jsonBody.put("pageSize", 500);
		jsonBody.put("flagId", "");
		jsonBody.put("offset", 0);
		String body = jsonBody.toJSONString();
		String StringeResult = callPostStringApi(url,body);
		return StringeResult;
	}
	/**
	 * 消防设备添加
	 *
	 * 设备名称	deviceName	String	true	设备名称
	 设备序列号	deviceSerial	String	true	设备序列号
	 设备型号	deviceModel	String	true	设备型号,详见字典表
	 800022	NP-FY200-N 烟
	 800056 JT-HK400-N 气
	 设备类型	deviceType	Number	true	设备类型,详见字典表
	 600002	独立式光电感烟探测器(NB)
	 600006	独立式可燃气体探测器(NB)
	 通讯类型	communicationType	Number	true	通讯类型,详见字典表
	 900004	NB移动
	 */
	public static void addDevice(String deviceName,String deviceSerial,String deviceModel,String deviceType){
		String url = "/api/bws/device/v1/add";
		JSONObject jsonBody = new JSONObject();
		jsonBody.put("deviceName", deviceName);
		jsonBody.put("deviceSerial", deviceSerial);
		jsonBody.put("deviceModel", deviceModel);
		jsonBody.put("deviceType", deviceType);
		jsonBody.put("communicationType", "900004");
		String body = jsonBody.toJSONString();
		String StringeResult = callPostStringApi(url,body);
		System.out.println("StringeResult结果示例: "+StringeResult);
	}
	/**
	 * 查询订阅
	 */
	public void subscription_list(){
		String url = "/api/firepro/v1/subscription/list";
		JSONObject jsonBody = new JSONObject();
		jsonBody.put("pageNo", 1);
		jsonBody.put("pageSize", 3);
		String body = jsonBody.toJSONString();
		String StringeResult = callPostStringApi(url,body);
		System.out.println("StringeResult结果示例: "+StringeResult);
	}
	public static void main(String[] args) {
//		String url = "/api/firepro/v1/getCompany";
//		JSONObject jsonBody = new JSONObject();
//		jsonBody.put("pageNo", 1);
//		jsonBody.put("pageSize", 3);
//		String body = jsonBody.toJSONString();
//		String StringeResult = callPostStringApi(url,body);
//		System.out.println("StringeResult结果示例: "+StringeResult);
//		callPostImgStringApi();
//		getDevice();
		System.out.println(getMonitor("635486270136270848"));
//		subscription_info("980001");
//		subscription_info("980002");
//		subscription_info("980003");
//		subscription_info("980004");
//		subscription_info("980005");
//		subscription_info("980006");
//		subscription_info("980007");
//		subscription_info("980008");
	}
}

+ 60 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/util/Tools.java

@ -0,0 +1,60 @@
package com.yihu.jw.care.util;/**
 * Created by lifutao on 2019/1/11.
 */
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
/**
 * 工具类
 *
 * @author
 * @create 2019-01-11 17:06
 **/
public class Tools {
    /**
     * 将图片写到 硬盘指定目录下
     *
     * @param in
     * @param dirPath
     * @param filePath
     */
    public static void savePicToDisk(InputStream in, String dirPath,
                                      String filePath) {
        try {
            File dir = new File(dirPath);
            if (dir == null || !dir.exists()) {
                dir.mkdirs();
            }
            //文件真实路径
            String realPath = dirPath.concat(filePath);
            File file = new File(realPath);
            if (file == null || !file.exists()) {
                file.createNewFile();
            }
            FileOutputStream fos = new FileOutputStream(file);
            byte[] buf = new byte[1024];
            int len = 0;
            while ((len = in.read(buf)) != -1) {
                fos.write(buf, 0, len);
            }
            fos.flush();
            fos.close();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                in.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}

+ 1 - 1
svr/svr-cloud-care/src/main/resources/bootstrap.yml

@ -1,6 +1,6 @@
spring:
  application:
    name:  svr-cloud-care
    name:  svr-cloud-care-ysj
  cloud:
    config:
      failFast: true

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

@ -20,4 +20,7 @@ public interface DeviceDetailDao extends PagingAndSortingRepository<DeviceDetail
    @Query("select a from DeviceDetail a where a.deviceCode = ?1 and a.manufacturerCode = ?2")
    DeviceDetail findByDeviceCodeAndManufacturerCode(String deviceCode,String manufacturerCode);
    @Query("select a from DeviceDetail a where a.sim = ?2")
    List<DeviceDetail> findBySim(String sim);
}

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

@ -0,0 +1,16 @@
package com.yihu.jw.care.dao.device;
import com.yihu.jw.entity.care.device.DeviceHealthIndex;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created with IntelliJ IDEA.
 *
 * @Author: yeshijie
 * @Date: 2021/8/23
 * @Description:
 */
public interface DeviceHealthIndexDao extends PagingAndSortingRepository<DeviceHealthIndex, String>, JpaSpecificationExecutor<DeviceHealthIndex> {
}

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

@ -0,0 +1,15 @@
package com.yihu.jw.care.dao.device;
import com.yihu.jw.entity.care.device.HvDeviceRecord;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created with IntelliJ IDEA.
 *
 * @Author: yeshijie
 * @Date: 2021/8/23
 * @Description:
 */
public interface HvDeviceRecordDao extends PagingAndSortingRepository<HvDeviceRecord, String>, JpaSpecificationExecutor<HvDeviceRecord> {
}

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

@ -0,0 +1,16 @@
package com.yihu.jw.care.dao.device;
import com.yihu.jw.entity.care.device.HvDeviceSosLog;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created with IntelliJ IDEA.
 *
 * @Author: yeshijie
 * @Date: 2021/8/23
 * @Description:
 */
public interface HvDeviceSosLogDao extends PagingAndSortingRepository<HvDeviceSosLog, String>, JpaSpecificationExecutor<HvDeviceSosLog> {
}

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

@ -1,19 +1,27 @@
package com.yihu.jw.care.endpoint;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.care.dao.device.DeviceDetailDao;
import com.yihu.jw.care.service.DeviceService;
import com.yihu.jw.entity.care.device.DeviceDetail;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import jxl.Sheet;
import jxl.Workbook;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;
import java.io.InputStream;
import java.text.SimpleDateFormat;
import java.util.*;
/**
 * Created with IntelliJ IDEA.
@ -31,6 +39,121 @@ public class DeviceController {
    @Autowired
    private DeviceService deviceService;
    @Autowired
    private DeviceDetailDao deviceDetailDao;
    @RequestMapping(value = "/importDeviceFromExcel", produces = "application/json;charset=UTF-8",method = RequestMethod.POST)
    @ResponseBody
    public String importFromExcel(HttpServletRequest request,@ApiParam(value = "文件", required = true)
    @RequestParam(value = "file", required = true) MultipartFile file) {
        List errorLs = new ArrayList<>();
        List correctLs = new ArrayList<>();
        Map<String, String> errorMsgMap = new HashMap<>();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        List<String> deviceCodes = new ArrayList<>();
        try {
            request.setCharacterEncoding("UTF-8");
            InputStream inputStream = file.getInputStream();
            Workbook rwb = Workbook.getWorkbook(inputStream);
            Sheet[] sheets = rwb.getSheets();
            int rows;
            int row;
            String manufacturer=null;//厂商名称
            String deviceName; //设备名称
            String deviceModel; //设备型号
            String deviceCode;  //设备SN
            String sim;  //sim卡号
            String bindingCount; //单人{"1":"0"}  多人{"1":"0", "2":"0"}
            String deviceType; //设备种类  0健康设备 1安防设备
            Sheet sheet = sheets[0];    //第一张表
            rows = sheet.getRows();
            for (int j = 1; j < rows; j++) {
                if (sheet.getRow(j).length == 0) {
                    continue;
                }
                DeviceDetail deviceDetail = new DeviceDetail();
                row = j;
                manufacturer = sheet.getCell(0, row).getContents().trim();    //0 厂商名称
                deviceName = sheet.getCell(1, row).getContents().trim();  //1 设备名称
                deviceModel = sheet.getCell(2, row).getContents().trim();   //2 设备型号
                deviceCode = sheet.getCell(3, row).getContents().trim(); //3 设备SN
                sim = sheet.getCell(4, row).getContents().trim();  //4 sim卡号
                bindingCount = sheet.getCell(5, row).getContents().trim(); //5
                deviceType = sheet.getCell(6, row).getContents().trim(); //6 设备种类
                if (StringUtils.isBlank(deviceCode)){
                    continue;
                }
                if (deviceCodes.contains(deviceCode)){
                    errorMsgMap.put(deviceCode,"设备SN码重复");
                    continue;
                }
                deviceCodes.add(deviceCode);
                if (StringUtils.isBlank(manufacturer)){
                    errorMsgMap.put(deviceCode,"厂商名称不能为空");
                    continue;
                }
                if (StringUtils.isBlank(deviceName)){
                    errorMsgMap.put(deviceCode,"设备名称不能为空");
                    continue;
                }
                if (StringUtils.isBlank(deviceModel)){
                    errorMsgMap.put(deviceCode,"设备型号不能为空");
                    continue;
                }
                if (StringUtils.isBlank(bindingCount)){
                    errorMsgMap.put(deviceCode,"设备类型不能为空");
                    continue;
                }
                if (StringUtils.isBlank(deviceType)){
                    errorMsgMap.put(deviceCode,"设备种类不能为空");
                    continue;
                }else {
                    if ("健康设备".equals(deviceType)){
                        deviceType = "1";
                    }
                    else if ("安防设备".equals(deviceType)){
                        deviceType= "0";
                    }
                    else {
                        errorMsgMap.put(deviceCode,"不支持该设备种类");
                        continue;
                    }
                }
                if (deviceDetailDao.findByDeviceCode(deviceCode).size()>0){
                    errorMsgMap.put(deviceCode,"该设备SN码已存在");
                    continue;
                }
                if (StringUtils.isNotBlank(sim) && deviceDetailDao.findBySim(sim).size()>0){
                    errorMsgMap.put(deviceCode,"该sim卡号已存在");
                    continue;
                }
                deviceDetail.setApplyDate(sdf.format(new Date()));
                deviceDetail.setManufacturer(manufacturer);
                deviceDetail.setDeviceName(deviceName);
                deviceDetail.setDeviceModel(deviceModel);
                deviceDetail.setDeviceCode(deviceCode);
                deviceDetail.setSim(sim);
                deviceDetail.setBindingCount("");
                deviceDetail.setDeviceType(Integer.parseInt(deviceType));
                correctLs.add(deviceDetail);
            }
            deviceDetailDao.save(correctLs);
            //包装导入结果(导入成功数量、错误对象集合)
            Map<String, Object> map = new HashMap<>();
            map.put("successNum", correctLs.size());
            map.put("failedNum", rows-1 - correctLs.size() );
            map.put("errorData", JSON.toJSONString(errorMsgMap, SerializerFeature.WriteMapNullValue));
            System.out.println(map);
            return success();
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "操作失败!");
        }
    }
    @GetMapping("test")
    public String test(){

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

@ -1,10 +1,16 @@
package com.yihu.jw.care.endpoint;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.care.service.HvDeviceService;
import com.yihu.jw.utils.StringUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
@ -29,6 +35,8 @@ public class HvDeviceController {
    private static Logger logger = LoggerFactory.getLogger(HvDeviceController.class);
    @Autowired
    private HvDeviceService hvDeviceService;
    /**
     * 消息订阅
@ -48,6 +56,15 @@ public class HvDeviceController {
            HttpServletRequest request) {
        try {
            String str = getRequestBodyData(request);
            if(!StringUtil.isBlank(str)){
                JSONObject json = JSON.parseObject(str);
                JSONObject fps = json.getJSONObject("fps");
                JSONArray msgList = fps.getJSONArray("msgList");
                for(int i=0;i<msgList.size();i++){
                    JSONObject jsonObject = msgList.getJSONObject(i);
                    hvDeviceService.messageNotification(jsonObject);
                }
            }
            logger.info("======================:"+str);
            return success();
        } catch (Exception e) {
@ -56,6 +73,19 @@ public class HvDeviceController {
        }
    }
    @ApiOperation("同步设备")
    @RequestMapping(value = "synDevice",method = {RequestMethod.POST})
    public String synDevice() {
        try {
            hvDeviceService.synDevice();
            return success();
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1,"Device data incoming failure");
        }
    }
    /**
     * 获取request中body数据
     */

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

@ -0,0 +1,175 @@
package com.yihu.jw.care.service;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.care.dao.device.DeviceHealthIndexDao;
import com.yihu.jw.care.dao.device.HvDeviceRecordDao;
import com.yihu.jw.care.dao.device.HvDeviceSosLogDao;
import com.yihu.jw.care.util.ArtemisPostTest;
import com.yihu.jw.entity.care.device.DeviceHealthIndex;
import com.yihu.jw.entity.care.device.HvDeviceRecord;
import com.yihu.jw.entity.care.device.HvDeviceSosLog;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
/**
 * Created with IntelliJ IDEA.
 *
 * @Author: yeshijie
 * @Date: 2021/8/23
 * @Description:
 */
@Service
public class HvDeviceService {
    private static Logger logger = LoggerFactory.getLogger(HvDeviceService.class);
    @Autowired
    private DeviceHealthIndexDao deviceHealthIndexDao;
    @Autowired
    private YsDeviceService ysDeviceService;
    @Autowired
    private HvDeviceSosLogDao hvdeviceSosLogDao;
    @Autowired
    private HvDeviceRecordDao hvdeviceRecordDao;
    /**
     * 消息通知接收
     * @param json
     */
    public void messageNotification(JSONObject json){
        String msgType = json.getString("msgType");
        JSONObject body = json.getJSONObject("body");
        if("980008".equals(msgType)){
            message980008(body);
            return;
        }
        if ("980002".equals(msgType)){
            message980002(body);
            return;
        }
    }
    /**
     * 报警实时信息
     * @param json
     */
    public void message980002(JSONObject json){
        JSONArray data = json.getJSONArray("data");
        List<HvDeviceSosLog> list = new ArrayList<>();
        for (int i=0;i<data.size();i++){
            JSONObject jsonObject = data.getJSONObject(i);
            String resourceSerial = jsonObject.getString("resourceSerial");
            String deviceType = jsonObject.getString("deviceType");
            Integer alarmNum = jsonObject.getInteger("alarmNum");
            String resourceID = jsonObject.getString("resourceID");
            String location = jsonObject.getString("location");
            String resourceType = jsonObject.getString("resourceType");
            String alarmID = jsonObject.getString("alarmID");
            String systemType = jsonObject.getString("systemType");
            String alarmType = jsonObject.getString("alarmType");
            String monitorValue = jsonObject.getString("monitorValue");
            String resourceName = jsonObject.getString("resourceName");
            String alarmTime = jsonObject.getString("alarmTime");
            HvDeviceSosLog log = new HvDeviceSosLog();
            log.setAlarmID(alarmID);
            log.setAlarmNum(alarmNum);
            log.setAlarmTime(alarmTime);
            log.setAlarmType(alarmType);
            log.setLocation(location);
            log.setMonitorValue(monitorValue);
            log.setResourceID(resourceID);
            log.setResourceName(resourceName);
            log.setResourceSerial(resourceSerial);
            log.setResourceType(resourceType);
            log.setSystemType(systemType);
            list.add(log);
            if(alarmNum>1){
                continue;
            }
            if("600006".equals(deviceType)){
                //独立式可燃气体探测器(NB)
                ysDeviceService.createOrder(resourceSerial,null,new JSONObject(),6,"11","preventGasLeakage");
            }
            if("600002".equals(deviceType)){
                //独立式光电感烟探测器(NB)
                ysDeviceService.createOrder(resourceSerial,null,new JSONObject(),7,"10","preventFire");
            }
        }
        if(list.size()>0){
            hvdeviceSosLogDao.save(list);
        }
    }
    /**
     * 监测实时信息
     */
    public void message980008(JSONObject json){
        JSONArray data = json.getJSONArray("data");
        List<DeviceHealthIndex> list = new ArrayList<>();
        for (int i=0;i<data.size();i++){
            JSONObject jsonObject = data.getJSONObject(i);
            String resourceSerial = jsonObject.getString("resourceSerial");
            String monitorType = jsonObject.getString("monitorType");
            String resourceType = jsonObject.getString("resourceType");
            String monitorUnit = jsonObject.getString("monitorUnit");
            String monitorValue = jsonObject.getString("monitorValue");
            String happenTime = jsonObject.getString("happenTime");
            DeviceHealthIndex index = new DeviceHealthIndex();
            index.setDeviceSn(resourceSerial);
            index.setUnit(monitorUnit);
            index.setValue(monitorValue);
            index.setRecordTime(happenTime);
            if("600006".equals(resourceType)&&"400003".equals(monitorType)){
                //独立式可燃气体探测器(NB)
                index.setDeviceType("1");
                list.add(index);
            }
            if("600002".equals(resourceType)&&"400013".equals(monitorType)){
                //独立式光电感烟探测器(NB)
                index.setDeviceType("2");
                list.add(index);
            }
        }
        if(list.size()>0){
            deviceHealthIndexDao.save(list);
        }
    }
    /**
     * 同步设备
     */
    public void synDevice(){
        String res = ArtemisPostTest.getDevice();
        JSONObject jsonObject = JSON.parseObject(res);
        if("0".equals(jsonObject.getString("code"))){
            List<HvDeviceRecord> deviceRecordList = new ArrayList<>();
            JSONArray list = jsonObject.getJSONObject("data").getJSONArray("list");
            for (int i=0;i<list.size();i++){
                JSONObject json = list.getJSONObject(i);
                String deviceID = json.getString("deviceID");
                String deviceSerial = json.getString("deviceSerial");
                HvDeviceRecord record = new HvDeviceRecord();
                record.setDeviceSn(deviceSerial);
                record.setDeviceId(deviceID);
                deviceRecordList.add(record);
            }
            if(deviceRecordList.size()>0){
                hvdeviceRecordDao.deleteAll();;
                hvdeviceRecordDao.save(deviceRecordList);
            }
        }
    }
}

+ 68 - 60
svr/svr-cloud-device/src/main/java/com/yihu/jw/care/service/YsDeviceService.java

@ -1,9 +1,7 @@
package com.yihu.jw.care.service;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.yihu.fastdfs.FastDFSUtil;
import com.yihu.jw.care.config.YsConfig;
@ -17,16 +15,8 @@ import com.yihu.jw.restmodel.iot.common.UploadVO;
import com.yihu.jw.util.common.LatitudeUtils;
import com.yihu.jw.util.http.HttpClientUtil;
import com.yihu.jw.utils.encode.Base64;
import org.apache.commons.lang3.StringEscapeUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.mime.MultipartEntityBuilder;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.util.EntityUtils;
import org.csource.common.MyException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -44,7 +34,6 @@ import javax.servlet.http.HttpServletRequest;
import java.io.*;
import java.net.URL;
import java.net.URLConnection;
import java.nio.charset.Charset;
import java.security.NoSuchAlgorithmException;
import java.security.Security;
import java.util.HashMap;
@ -148,66 +137,85 @@ public class YsDeviceService {
                }
            }
            if (fallFlag){//发起安防工单
                String lat = "";
                String lon = "";
                List<DevicePatientDevice> devicePatientDeviceDos = patientDeviceDao.findByDeviceSn(deviceSN);
                if (devicePatientDeviceDos.size()>0){
                    DevicePatientDevice deviceDO = devicePatientDeviceDos.get(0);
                    Map<String, String> json = null;
                    if (org.apache.commons.lang.StringUtils.isNotBlank(deviceDO.getSosAddress())) {
                        json = LatitudeUtils.getGeocoderLatitude(deviceDO.getSosAddress().replace("G.", "").replace("(糖友网)", "").replace("(高友网)", ""));
                    }
                    if (json != null) {
                        lat = json.get("lat").toString();
                        lon = json.get("lng").toString();
                    }
                result = createOrder(deviceSN,sceneUrl,result,4,"2","preventFall");
            }
        }catch (Exception e){
            e.printStackTrace();
        }
        return result;
        //https://www.yuque.com/u1400669/kb/mlqrm2
        //https://www.yuque.com/u1400669/kb/div5py
    }
                    BasePatientDO patientDO = patientDao.findById(deviceDO.getUser());
                    String  url = cloudCareUrl+"/cloudCare/noLogin/security/createOrder";
                    Map map = new HashMap<String, String>();
                    map = new HashMap();
                    String sql ="select DISTINCT item.org_code,item.org_name\n" +
                            " from base_service_package_sign_record sr,base_service_package_record pr,base_service_package_item item ,base_service_package pack\n" +
                            "where pr.patient = '"+patientDO.getId()+"' and sr.id = pr.sign_id and pr.service_package_id = item.service_package_id \tand  item.`code`='preventFall'  and item.service_package_id = pack.id \n" +
                            "  and pack.del=1";
                    List<Map<String,Object>> sqlResult = jdbcTemplate.queryForList(sql);
                    JSONObject jsonObject = new JSONObject();
                    jsonObject.put("patient",patientDO.getId());
                    jsonObject.put("patientName",patientDO.getName());
                    jsonObject.put("patientPhone",patientDO.getMobile());
                    jsonObject.put("serveDesc","疑似跌倒");
                    jsonObject.put("hospital",sqlResult.get(0).get("org_code"));
                    jsonObject.put("serveAddress",deviceDO.getSosAddress());
                    jsonObject.put("serveLat",lat);
                    jsonObject.put("serveLon",lon);
                    jsonObject.put("topicItem","preventFall");
                    jsonObject.put("deviceSn",deviceSN);
                    if (StringUtils.isNotBlank(sceneUrl)){
                        jsonObject.put("sceneImg",sceneUrl);
                    }
                    JSONObject jsonObjectParam = new JSONObject();
                    jsonObjectParam.put("order", jsonObject);
                    map.put("jsonData", jsonObjectParam.toJSONString());
                    map.put("orderSource", 4);
                    map.put("warnStr", "疑似跌倒");
    public JSONObject createOrder(String deviceSN,String sceneUrl,JSONObject result,Integer orderSource,String dictCode,String topicItem){
        try {
            String lat = "";
            String lon = "";
            List<DevicePatientDevice> devicePatientDeviceDos = patientDeviceDao.findByDeviceSn(deviceSN);
            if (devicePatientDeviceDos.size()>0){
                DevicePatientDevice deviceDO = devicePatientDeviceDos.get(0);
                Map<String, String> json = null;
                if (org.apache.commons.lang.StringUtils.isNotBlank(deviceDO.getSosAddress())) {
                    json = LatitudeUtils.getGeocoderLatitude(deviceDO.getSosAddress().replace("G.", "").replace("(糖友网)", "").replace("(高友网)", ""));
                }
                if (json != null) {
                    lat = json.get("lat").toString();
                    lon = json.get("lng").toString();
                }
                BasePatientDO patientDO = patientDao.findById(deviceDO.getUser());
                String  url = cloudCareUrl+"/cloudCare/noLogin/security/createOrder";
                Map map = new HashMap<String, String>();
                map = new HashMap();
                String sql ="select DISTINCT item.org_code,item.org_name\n" +
                        " from base_service_package_sign_record sr,base_service_package_record pr,base_service_package_item item ,base_service_package pack\n" +
                        "where pr.patient = '"+patientDO.getId()+"' and sr.id = pr.sign_id and pr.service_package_id = item.service_package_id \tand  item.`code`='preventFall'  and item.service_package_id = pack.id \n" +
                        "  and pack.del=1";
                List<Map<String,Object>> sqlResult = jdbcTemplate.queryForList(sql);
                String serveDesc = "";
                String sqlDesc = "SELECT dict_value from wlyy_hospital_sys_dict WHERE dict_code = '"+dictCode+"' and dict_name = 'security_server_dict'";
                List<Map<String,Object>> listTmp = jdbcTemplate.queryForList(sqlDesc);
                if (listTmp!=null&&listTmp.size()>0){
                    serveDesc = listTmp.get(0).get("dict_value")+"";
                }
                    String content = com.alibaba.fastjson.JSONObject.toJSONString(map);
                    String postParams = AesEncryptUtils.agEncrypt(content);
                    String response = httpClientUtil.postBodyRawForm(url,postParams);
                    result = com.alibaba.fastjson.JSONObject.parseObject(response);
                    JSONObject jsonObjectData =JSONObject.parseObject(AesEncryptUtils.agDecrypt(result.getString("data")));
                    System.out.println(jsonObjectData.toJSONString());
                JSONObject jsonObject = new JSONObject();
                jsonObject.put("patient",patientDO.getId());
                jsonObject.put("patientName",patientDO.getName());
                jsonObject.put("patientPhone",patientDO.getMobile());
                jsonObject.put("serveDesc",serveDesc);
                jsonObject.put("hospital",sqlResult.get(0).get("org_code"));
                jsonObject.put("serveAddress",deviceDO.getSosAddress());
                jsonObject.put("serveLat",lat);
                jsonObject.put("serveLon",lon);
                jsonObject.put("topicItem",topicItem);
                jsonObject.put("deviceSn",deviceSN);
                if (StringUtils.isNotBlank(sceneUrl)){
                    jsonObject.put("sceneImg",sceneUrl);
                }
                JSONObject jsonObjectParam = new JSONObject();
                jsonObjectParam.put("order", jsonObject);
                map.put("jsonData", jsonObjectParam.toJSONString());
                map.put("orderSource", orderSource);
                map.put("warnStr", serveDesc);
                String content = com.alibaba.fastjson.JSONObject.toJSONString(map);
                String postParams = AesEncryptUtils.agEncrypt(content);
                String response = httpClientUtil.postBodyRawForm(url,postParams);
                result = com.alibaba.fastjson.JSONObject.parseObject(response);
                JSONObject jsonObjectData =JSONObject.parseObject(AesEncryptUtils.agDecrypt(result.getString("data")));
                System.out.println(jsonObjectData.toJSONString());
            }
        }catch (Exception e){
            e.printStackTrace();
        }
        return result;
        //https://www.yuque.com/u1400669/kb/mlqrm2
        //https://www.yuque.com/u1400669/kb/div5py
    }
    /**
     * 消息解密
     * @param sSrc

+ 44 - 1
svr/svr-cloud-device/src/main/java/com/yihu/jw/care/util/ArtemisPostTest.java

@ -158,7 +158,7 @@ public class ArtemisPostTest {
	/**
	 * 设备监测信息查询
     */
	 */
	public static void getMonitor(){
		String url = "/api/firepro/v1/getMonitor";
		JSONObject jsonBody = new JSONObject();
@ -171,6 +171,48 @@ public class ArtemisPostTest {
		System.out.println("StringeResult结果示例: "+StringeResult);
	}
	/**
	 * 获取消防设备信息
	 */
	public static String getDevice(){
		String url = "/api/firepro/v1/getDevice";
		JSONObject jsonBody = new JSONObject();
		jsonBody.put("pageNo", 1);
		jsonBody.put("pageSize", 500);
		jsonBody.put("flagId", "");
		jsonBody.put("offset", 0);
		String body = jsonBody.toJSONString();
		String StringeResult = callPostStringApi(url,body);
		return StringeResult;
	}
	/**
	 * 消防设备添加
	 *
	 * 设备名称	deviceName	String	true	设备名称
	 设备序列号	deviceSerial	String	true	设备序列号
	 设备型号	deviceModel	String	true	设备型号,详见字典表
	 800022	NP-FY200-N 烟
	 800056 JT-HK400-N 气
	 设备类型	deviceType	Number	true	设备类型,详见字典表
	 600002	独立式光电感烟探测器(NB)
	 600006	独立式可燃气体探测器(NB)
	 通讯类型	communicationType	Number	true	通讯类型,详见字典表
	 900004	NB移动
	 */
	public static void addDevice(String deviceName,String deviceSerial,String deviceModel,String deviceType){
		String url = "/api/bws/device/v1/add";
		JSONObject jsonBody = new JSONObject();
		jsonBody.put("deviceName", deviceName);
		jsonBody.put("deviceSerial", deviceSerial);
		jsonBody.put("deviceModel", deviceModel);
		jsonBody.put("deviceType", deviceType);
		jsonBody.put("communicationType", "900004");
		String body = jsonBody.toJSONString();
		String StringeResult = callPostStringApi(url,body);
		System.out.println("StringeResult结果示例: "+StringeResult);
	}
	/**
	 * 查询订阅
	 */
@ -194,6 +236,7 @@ public class ArtemisPostTest {
//		System.out.println("StringeResult结果示例: "+StringeResult);
//		callPostImgStringApi();
//		getDevice();
		getMonitor();
//		subscription_info("980001");
//		subscription_info("980002");