温湿度
This commit is contained in:
parent
26b29049d6
commit
ad4b66e197
|
@ -0,0 +1,33 @@
|
||||||
|
package com.nu.modules.yiweilian.common.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: 护理单元-物联管理-易维联-配置信息
|
||||||
|
* @Author: caolei
|
||||||
|
* @Date: 2025-06-13
|
||||||
|
* @Version: V1.0
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@TableName("nu_iot_yiweilian_config")
|
||||||
|
@Accessors(chain = true)
|
||||||
|
@EqualsAndHashCode(callSuper = false)
|
||||||
|
@ApiModel(value="nu_iot_yiweilian_config", description="护理单元-物联管理-易维联-配置信息")
|
||||||
|
public class YiweilianConfig implements Serializable {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
/**ID*/
|
||||||
|
@TableId(type = IdType.AUTO)
|
||||||
|
@ApiModelProperty(value = "ID")
|
||||||
|
private Integer id;
|
||||||
|
private String requestUrl; //云平台系统地址
|
||||||
|
private String clientId; //识别用户的唯一标识
|
||||||
|
}
|
|
@ -0,0 +1,17 @@
|
||||||
|
package com.nu.modules.yiweilian.common.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.nu.modules.yiweilian.common.entity.YiweilianConfig;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: 护理单元-物联管理-易维联-配置信息
|
||||||
|
* @Author: caolei
|
||||||
|
* @Date: 2025-06-13
|
||||||
|
* @Version: V1.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface YiweilianConfigMapper extends BaseMapper<YiweilianConfig> {
|
||||||
|
YiweilianConfig getConfig();
|
||||||
|
}
|
|
@ -0,0 +1,15 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.nu.modules.yiweilian.common.mapper.YiweilianConfigMapper">
|
||||||
|
|
||||||
|
<select id="getConfig" parameterType="String" resultType="com.nu.modules.yiweilian.common.entity.YiweilianConfig">
|
||||||
|
select
|
||||||
|
id,
|
||||||
|
request_url as requestUrl,
|
||||||
|
client_id as clientId
|
||||||
|
from nu_iot_yiweilian_config
|
||||||
|
order by id desc
|
||||||
|
limit 1
|
||||||
|
</select>
|
||||||
|
|
||||||
|
</mapper>
|
|
@ -0,0 +1,14 @@
|
||||||
|
package com.nu.modules.yiweilian.common.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.nu.modules.yiweilian.common.entity.YiweilianConfig;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: 护理单元-物联管理-易维联-配置信息
|
||||||
|
* @Author: caolei
|
||||||
|
* @Date: 2025-06-13
|
||||||
|
* @Version: V1.0
|
||||||
|
*/
|
||||||
|
public interface IYiweilianConfigService extends IService<YiweilianConfig> {
|
||||||
|
YiweilianConfig getConfig();
|
||||||
|
}
|
|
@ -0,0 +1,23 @@
|
||||||
|
package com.nu.modules.yiweilian.common.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.nu.modules.yiweilian.common.entity.YiweilianConfig;
|
||||||
|
import com.nu.modules.yiweilian.common.mapper.YiweilianConfigMapper;
|
||||||
|
import com.nu.modules.yiweilian.common.service.IYiweilianConfigService;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: 护理单元-物联管理-易维联-配置信息
|
||||||
|
* @Author: caolei
|
||||||
|
* @Date: 2025-06-13
|
||||||
|
* @Version: V1.0
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class YiweilianConfigServiceImpl extends ServiceImpl<YiweilianConfigMapper, YiweilianConfig> implements IYiweilianConfigService {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public YiweilianConfig getConfig(){
|
||||||
|
return baseMapper.getConfig();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,23 @@
|
||||||
|
package com.nu.modules.yiweilian.enums;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 接口枚举类
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public enum YiweilianApiEnum {
|
||||||
|
|
||||||
|
ADD_DEVICE("/mtInterface/device/addDevice","添加设备"),
|
||||||
|
UPDATE_DEVICE_CONFIG("/mtInterface/device/updateDeviceConfig","修改设备配置"),
|
||||||
|
DELETE_DEVICE("/mtInterface/device/deleteDevice","删除设备"),
|
||||||
|
// GET_DEVICES("/mtInterface/device/getDevices","查询设备列表(分页)"),
|
||||||
|
GET_DEVICE_CONFIGS("/mtInterface/device/getDeciveConfigs","查询设备列表含配置信息(分页)"),
|
||||||
|
GET_REAL_TIME("/mtInterface/realTime/getRealTime","查询设备实时数据(分页)"),
|
||||||
|
GET_WARNING_DATA("/mtInterface/warning/getWarningData","查询告警记录(分页)");
|
||||||
|
|
||||||
|
private final String value;//自定义属性,枚举值,获取:如ApiEnum.GET_ENCRYPT_KEY_FOR_LOGIN.getValue();
|
||||||
|
private final String remark;//自定义属性,枚举描述,获取:如ApiEnum.GET_ENCRYPT_KEY_FOR_LOGIN.getRemark();
|
||||||
|
}
|
|
@ -0,0 +1,59 @@
|
||||||
|
package com.nu.modules.yiweilian.humid.controller;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.nu.modules.yiweilian.humid.entity.HumidAlarm;
|
||||||
|
import com.nu.modules.yiweilian.humid.service.IHumidAlarmService;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.jeecg.common.api.vo.Result;
|
||||||
|
import org.jeecg.common.system.base.controller.JeecgController;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/iot/yiweilian/humidAlarm")
|
||||||
|
public class HumidAlarmController extends JeecgController<HumidAlarm, IHumidAlarmService> {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IHumidAlarmService service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页列表查询
|
||||||
|
*
|
||||||
|
* @param humidAlarm
|
||||||
|
* @param pageNo
|
||||||
|
* @param pageSize
|
||||||
|
* @param req
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping(value = "/list")
|
||||||
|
public Result<IPage<HumidAlarm>> queryPageList(HumidAlarm humidAlarm,
|
||||||
|
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
||||||
|
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
|
||||||
|
HttpServletRequest req) {
|
||||||
|
Page<HumidAlarm> page = new Page<HumidAlarm>(pageNo, pageSize);
|
||||||
|
IPage<HumidAlarm> pageList = service.findPage(page, humidAlarm);
|
||||||
|
return Result.OK(pageList);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取告警
|
||||||
|
*
|
||||||
|
* @param humidAlarm
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping(value = "/getAlarm")
|
||||||
|
public Result<String> getAlarm(HumidAlarm humidAlarm) {
|
||||||
|
service.getAlarm(humidAlarm);
|
||||||
|
return Result.OK();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,118 @@
|
||||||
|
package com.nu.modules.yiweilian.humid.controller;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.nu.modules.yiweilian.humid.entity.HumidDevice;
|
||||||
|
import com.nu.modules.yiweilian.humid.service.IHumidDeviceService;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.jeecg.common.api.vo.Result;
|
||||||
|
import org.jeecg.common.system.base.controller.JeecgController;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/iot/yiweilian/humidDevice")
|
||||||
|
public class HumidDeviceController extends JeecgController<HumidDevice, IHumidDeviceService> {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IHumidDeviceService service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页列表查询
|
||||||
|
*
|
||||||
|
* @param humidDevice
|
||||||
|
* @param pageNo
|
||||||
|
* @param pageSize
|
||||||
|
* @param req
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping(value = "/list")
|
||||||
|
public Result<IPage<HumidDevice>> queryPageList(HumidDevice humidDevice,
|
||||||
|
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
||||||
|
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
|
||||||
|
HttpServletRequest req) {
|
||||||
|
Page<HumidDevice> page = new Page<HumidDevice>(pageNo, pageSize);
|
||||||
|
IPage<HumidDevice> pageList = service.findPage(page, humidDevice);
|
||||||
|
return Result.OK(pageList);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加设备
|
||||||
|
*
|
||||||
|
* @param humidDevice
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping(value = "/insertDevice")
|
||||||
|
public Result<String> insertDevice(HumidDevice humidDevice) {
|
||||||
|
return service.insertDevice(humidDevice);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改设备
|
||||||
|
*
|
||||||
|
* @param humidDevice
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping(value = "/updateDevice")
|
||||||
|
public Result<String> updateDevice(HumidDevice humidDevice) {
|
||||||
|
return service.updateDevice(humidDevice);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除设备
|
||||||
|
*
|
||||||
|
* @param humidDevice
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping(value = "/deleteDevice")
|
||||||
|
public Result<String> deleteDevice(HumidDevice humidDevice) {
|
||||||
|
return service.deleteDevice(humidDevice);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取设备配置参数
|
||||||
|
*
|
||||||
|
* @param humidDevice
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping(value = "/getDeviceParameters")
|
||||||
|
public Result<String> getDeviceParameters(HumidDevice humidDevice) {
|
||||||
|
return service.getDeviceParameters(humidDevice);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 抄表
|
||||||
|
*
|
||||||
|
* @param humidDevice
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping(value = "/updateDeviceRealTime")
|
||||||
|
public Result<String> updateDeviceRealTime(HumidDevice humidDevice) {
|
||||||
|
String result = service.updateDeviceRealTime(humidDevice);
|
||||||
|
if(!result.equals("")){
|
||||||
|
return Result.error("抄表失败:"+result);
|
||||||
|
}
|
||||||
|
return Result.OK("抄表成功");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 操作日志分页列表查询
|
||||||
|
*
|
||||||
|
* @param humidDevice
|
||||||
|
* @param pageNo
|
||||||
|
* @param pageSize
|
||||||
|
* @param req
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping(value = "/logList")
|
||||||
|
public Result<IPage<HumidDevice>> queryLogPageList(HumidDevice humidDevice,
|
||||||
|
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
||||||
|
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
|
||||||
|
HttpServletRequest req) {
|
||||||
|
Page<HumidDevice> page = new Page<HumidDevice>(pageNo, pageSize);
|
||||||
|
IPage<HumidDevice> pageList = service.findLogPage(page, humidDevice);
|
||||||
|
return Result.OK(pageList);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,77 @@
|
||||||
|
package com.nu.modules.yiweilian.humid.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>Class:易维联-温湿度计告警Entity
|
||||||
|
* <p>功能描述:功能描述
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@TableName("nu_iot_yiweilian_humid_alarm")
|
||||||
|
@Accessors(chain = true)
|
||||||
|
@EqualsAndHashCode(callSuper = false)
|
||||||
|
@ApiModel(value="nu_iot_yiweilian_humid_alarm对象", description="易维联-温湿设备告警")
|
||||||
|
public class HumidAlarm implements Serializable {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@TableId(type = IdType.AUTO)
|
||||||
|
@ApiModelProperty(value = "主键")
|
||||||
|
private Integer id;
|
||||||
|
@Excel(name = "设备SN号", width = 15)
|
||||||
|
@ApiModelProperty(value = "设备SN号")
|
||||||
|
private String sn;
|
||||||
|
@Excel(name = "告警ID", width = 15)
|
||||||
|
@ApiModelProperty(value = "告警ID")
|
||||||
|
private String alarmId;
|
||||||
|
@Excel(name = "告警状态ID", width = 15)
|
||||||
|
@ApiModelProperty(value = "告警状态ID")
|
||||||
|
private String wrId;
|
||||||
|
@Excel(name = "告警数据", width = 15)
|
||||||
|
@ApiModelProperty(value = "告警数据")
|
||||||
|
private String wrData;
|
||||||
|
@Excel(name = "告警内容", width = 15)
|
||||||
|
@ApiModelProperty(value = "告警内容")
|
||||||
|
private String wrContent;
|
||||||
|
@Excel(name = "告警记录时间", width = 15)
|
||||||
|
@ApiModelProperty(value = "告警记录时间")
|
||||||
|
private String wrDate;
|
||||||
|
@Excel(name = "清除告警ID", width = 15)
|
||||||
|
@ApiModelProperty(value = "清除告警ID")
|
||||||
|
private String clearAlarmId;
|
||||||
|
@Excel(name = "清除告警状态ID", width = 15)
|
||||||
|
@ApiModelProperty(value = "清除告警状态ID")
|
||||||
|
private String clearId;
|
||||||
|
@Excel(name = "清除告警数据", width = 15)
|
||||||
|
@ApiModelProperty(value = "清除告警数据")
|
||||||
|
private String clearData;
|
||||||
|
@Excel(name = "清除告警内容", width = 15)
|
||||||
|
@ApiModelProperty(value = "清除告警内容")
|
||||||
|
private String clearContent;
|
||||||
|
@Excel(name = "清除告警记录时间", width = 15)
|
||||||
|
@ApiModelProperty(value = "清除告警记录时间")
|
||||||
|
private String clearDate;
|
||||||
|
@Excel(name = "状态", width = 15)
|
||||||
|
@ApiModelProperty(value = "状态")
|
||||||
|
private String status; //状态 0告警 1清除
|
||||||
|
|
||||||
|
@TableField(exist = false)
|
||||||
|
private Date alarmStartTime;
|
||||||
|
@TableField(exist = false)
|
||||||
|
private Date alarmEndTime;
|
||||||
|
@TableField(exist = false)
|
||||||
|
private Date clearStartTime;
|
||||||
|
@TableField(exist = false)
|
||||||
|
private Date clearEndTime;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,114 @@
|
||||||
|
package com.nu.modules.yiweilian.humid.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>Class:易维联-温湿度计Entity
|
||||||
|
* <p>功能描述:功能描述
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@TableName("nu_iot_yiweilian_humid_device")
|
||||||
|
@Accessors(chain = true)
|
||||||
|
@EqualsAndHashCode(callSuper = false)
|
||||||
|
@ApiModel(value="nu_iot_yiweilian_humid_device对象", description="易维联-温湿设备")
|
||||||
|
public class HumidDevice implements Serializable {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@TableId(type = IdType.AUTO)
|
||||||
|
@ApiModelProperty(value = "主键")
|
||||||
|
private Integer id;
|
||||||
|
@Excel(name = "设备SN号", width = 15)
|
||||||
|
@ApiModelProperty(value = "设备SN号")
|
||||||
|
private String sn;
|
||||||
|
@Excel(name = "设备名称", width = 15)
|
||||||
|
@ApiModelProperty(value = "设备名称")
|
||||||
|
private String deviceName;
|
||||||
|
@Excel(name = "设备类型", width = 15)
|
||||||
|
@ApiModelProperty(value = "设备类型")
|
||||||
|
private String deviceTypes;//一共16位,第几位为1代表设备有该功能. 1位温度 2位湿度 15位电量
|
||||||
|
@Excel(name = "上报间隔", width = 15)
|
||||||
|
@ApiModelProperty(value = "上报间隔")
|
||||||
|
private String reportingInterval; //实时数据上报时间间隔 单位分钟
|
||||||
|
@Excel(name = "记录间隔", width = 15)
|
||||||
|
@ApiModelProperty(value = "记录间隔")
|
||||||
|
private String recordInterval; //记录时间间隔 单位分钟
|
||||||
|
@Excel(name = "历史数据上报时刻", width = 15)
|
||||||
|
@ApiModelProperty(value = "历史数据上报时刻")
|
||||||
|
private String historyReportTime; //历史数据上报时刻 00:00
|
||||||
|
@Excel(name = "历史数据上报间隔", width = 15)
|
||||||
|
@ApiModelProperty(value = "历史数据上报间隔")
|
||||||
|
private String historyInterval; //历史数据上报间隔 单位小时
|
||||||
|
@Excel(name = "温度预警范围 上限值", width = 15)
|
||||||
|
@ApiModelProperty(value = "温度预警范围 上限值")
|
||||||
|
private String temperatureHigh ; //温度预警范围-上限值
|
||||||
|
@Excel(name = "温度预警范围 下限值", width = 15)
|
||||||
|
@ApiModelProperty(value = "温度预警范围 下限值")
|
||||||
|
private String temperatureLow; //温度预警范围-下限值
|
||||||
|
@Excel(name = "温度缓冲值", width = 15)
|
||||||
|
@ApiModelProperty(value = "温度缓冲值")
|
||||||
|
private String temperatureBuffer; //温度缓冲值
|
||||||
|
@Excel(name = "湿度预警范围 上限值", width = 15)
|
||||||
|
@ApiModelProperty(value = "湿度预警范围 上限值")
|
||||||
|
private String humidityHigh; //湿度预警范围-上限值
|
||||||
|
@Excel(name = "湿度预警范围 下限值", width = 15)
|
||||||
|
@ApiModelProperty(value = "湿度预警范围 下限值")
|
||||||
|
private String humidityLow; //湿度预警范围-下限值
|
||||||
|
@Excel(name = "湿度缓冲值", width = 15)
|
||||||
|
@ApiModelProperty(value = "湿度缓冲值")
|
||||||
|
private String humidityBuffer; //湿度缓冲值
|
||||||
|
@Excel(name = "设备所在时区", width = 15)
|
||||||
|
@ApiModelProperty(value = "设备所在时区")
|
||||||
|
private String timeCode; //设备所在时区 01北京时间 02纽约时间
|
||||||
|
@Excel(name = "断电报警", width = 15)
|
||||||
|
@ApiModelProperty(value = "断电报警")
|
||||||
|
private String izOutages; //断电报警 0开启 1关闭
|
||||||
|
@Excel(name = "低电报警", width = 15)
|
||||||
|
@ApiModelProperty(value = "低电报警")
|
||||||
|
private String izLowBattery; //低电报警 0开启 1关闭
|
||||||
|
@Excel(name = "上下线通知", width = 15)
|
||||||
|
@ApiModelProperty(value = "上下线通知")
|
||||||
|
private String izOnline; //上下线通知 0开启 1关闭
|
||||||
|
@Excel(name = "温度", width = 15)
|
||||||
|
@ApiModelProperty(value = "温度")
|
||||||
|
private String temperature; //温度
|
||||||
|
@Excel(name = "湿度", width = 15)
|
||||||
|
@ApiModelProperty(value = "湿度")
|
||||||
|
private String humidity; //湿度
|
||||||
|
@Excel(name = "在线状态", width = 15)
|
||||||
|
@ApiModelProperty(value = "在线状态")
|
||||||
|
private String status; //在线状态,0在线 1离线
|
||||||
|
@Excel(name = "最新上报时间", width = 15)
|
||||||
|
@ApiModelProperty(value = "最新上报时间")
|
||||||
|
private String reportingTime; //最新上报时间
|
||||||
|
@Excel(name = "电量", width = 15)
|
||||||
|
@ApiModelProperty(value = "电量")
|
||||||
|
private String electricity; //电量 0~4
|
||||||
|
|
||||||
|
private String optType; //操作类型
|
||||||
|
private String optTime; //操作时间
|
||||||
|
private String optBy; //操作人
|
||||||
|
|
||||||
|
private Integer alarmCn; //告警数量
|
||||||
|
|
||||||
|
private String nuId;//护理单元ID
|
||||||
|
private String nuName;//护理单元
|
||||||
|
private String departId;//机构ID
|
||||||
|
private String departName;//机构名称
|
||||||
|
private String departServerUrl;//机构服务地址
|
||||||
|
private String oldServerUrl;//原机构服务地址
|
||||||
|
private String syncType;//是否同步 0 未同步 1已同步
|
||||||
|
private String oldDepartId;//原机构id
|
||||||
|
private String oldDepartName;//原机构名称
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,40 @@
|
||||||
|
package com.nu.modules.yiweilian.humid.job;
|
||||||
|
|
||||||
|
import com.nu.modules.yiweilian.humid.entity.HumidAlarm;
|
||||||
|
import com.nu.modules.yiweilian.humid.service.IHumidAlarmService;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.jeecg.common.api.vo.Result;
|
||||||
|
import org.jeecg.common.util.DateUtils;
|
||||||
|
import org.quartz.Job;
|
||||||
|
import org.quartz.JobExecutionContext;
|
||||||
|
import org.quartz.JobExecutionException;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
|
import java.util.Calendar;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 温湿度告警采集
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
public class HumidAlarmJob implements Job {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
IHumidAlarmService service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 5分钟一次
|
||||||
|
* @param jobExecutionContext
|
||||||
|
* @throws JobExecutionException
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
|
||||||
|
Calendar ca = Calendar.getInstance();
|
||||||
|
HumidAlarm humidAlarm = new HumidAlarm();
|
||||||
|
humidAlarm.setAlarmEndTime(ca.getTime());
|
||||||
|
ca.add(Calendar.MINUTE,-6);
|
||||||
|
humidAlarm.setAlarmStartTime(ca.getTime());
|
||||||
|
String result = service.getAlarm(humidAlarm);
|
||||||
|
log.error("HumidAlarmJob:{}-{}", DateUtils.now(),result);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,33 @@
|
||||||
|
package com.nu.modules.yiweilian.humid.job;
|
||||||
|
|
||||||
|
import com.nu.modules.yiweilian.humid.entity.HumidDevice;
|
||||||
|
import com.nu.modules.yiweilian.humid.service.IHumidDeviceService;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.jeecg.common.util.DateUtils;
|
||||||
|
import org.quartz.Job;
|
||||||
|
import org.quartz.JobExecutionContext;
|
||||||
|
import org.quartz.JobExecutionException;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
|
import java.util.Calendar;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 温湿度采集
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
public class HumidReadJob implements Job {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
IHumidDeviceService service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 5分钟一次
|
||||||
|
* @param jobExecutionContext
|
||||||
|
* @throws JobExecutionException
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
|
||||||
|
String result = service.updateDeviceRealTime(new HumidDevice());
|
||||||
|
log.error("HumidReadJob:{}-{}", DateUtils.now(),result);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
package com.nu.modules.yiweilian.humid.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.nu.modules.yiweilian.humid.entity.HumidAlarm;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
public interface HumidAlarmMapper extends BaseMapper<HumidAlarm> {
|
||||||
|
IPage<HumidAlarm> findPage(Page<HumidAlarm> page, @Param("params") HumidAlarm HumidAlarm);
|
||||||
|
HumidAlarm getHumidAlarm(HumidAlarm HumidAlarm);
|
||||||
|
int insertAlarm(HumidAlarm HumidAlarm);
|
||||||
|
int updateAlarm(HumidAlarm HumidAlarm);
|
||||||
|
}
|
|
@ -0,0 +1,18 @@
|
||||||
|
package com.nu.modules.yiweilian.humid.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.nu.modules.yiweilian.humid.entity.HumidDevice;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
public interface HumidDeviceMapper extends BaseMapper<HumidDevice> {
|
||||||
|
IPage<HumidDevice> findPage(Page<HumidDevice> page, @Param("params") HumidDevice humidDevice);
|
||||||
|
HumidDevice getHumidDevice(HumidDevice humidDevice);
|
||||||
|
int insertDevice(HumidDevice humidDevice);
|
||||||
|
int updateDevice(HumidDevice humidDevice);
|
||||||
|
int deleteDevice(HumidDevice humidDevice);
|
||||||
|
int updateValue(HumidDevice humidDevice);
|
||||||
|
int insertLog(HumidDevice humidDevice);
|
||||||
|
IPage<HumidDevice> findLogPage(Page<HumidDevice> page, @Param("params") HumidDevice humidDevice);
|
||||||
|
}
|
|
@ -0,0 +1,102 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.nu.modules.yiweilian.humid.mapper.HumidAlarmMapper">
|
||||||
|
|
||||||
|
<select id="findPage" parameterType="com.nu.modules.yiweilian.humid.entity.HumidAlarm" resultType="com.nu.modules.yiweilian.humid.entity.HumidAlarm">
|
||||||
|
select
|
||||||
|
id,
|
||||||
|
sn,
|
||||||
|
alarm_id as alarmId,
|
||||||
|
wr_id as wrId,
|
||||||
|
wr_data as wrData,
|
||||||
|
wr_content as wrContent,
|
||||||
|
wr_date as wrDate,
|
||||||
|
clear_alarm_id as clearAlarmId,
|
||||||
|
clear_id as clearId,
|
||||||
|
clear_data as clearData,
|
||||||
|
clear_content as clearContent,
|
||||||
|
clear_date as clearDate,
|
||||||
|
status
|
||||||
|
from nu_iot_yiweilian_humid_alarm
|
||||||
|
<where>
|
||||||
|
<if test="params.sn != null and params.sn != ''">
|
||||||
|
AND sn = #{params.sn}
|
||||||
|
</if>
|
||||||
|
<if test="params.alarmStartTime != null">
|
||||||
|
AND wr_date >= #{params.alarmStartTime}
|
||||||
|
</if>
|
||||||
|
<if test="params.alarmEndTime != null">
|
||||||
|
AND wr_date <= #{params.alarmEndTime}
|
||||||
|
</if>
|
||||||
|
<if test="params.clearStartTime != null">
|
||||||
|
AND clear_date >= #{params.clearStartTime}
|
||||||
|
</if>
|
||||||
|
<if test="params.clearEndTime != null">
|
||||||
|
AND clear_date <= #{params.clearEndTime}
|
||||||
|
</if>
|
||||||
|
<if test="params.status != null and params.status != ''">
|
||||||
|
AND status = #{params.status}
|
||||||
|
</if>
|
||||||
|
</where>
|
||||||
|
order by id desc
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="getHumidAlarm" parameterType="com.nu.modules.yiweilian.humid.entity.HumidAlarm" resultType="com.nu.modules.yiweilian.humid.entity.HumidAlarm">
|
||||||
|
select
|
||||||
|
id,
|
||||||
|
sn,
|
||||||
|
alarm_id as alarmId,
|
||||||
|
wr_id as wrId,
|
||||||
|
wr_data as wrData,
|
||||||
|
wr_content as wrContent,
|
||||||
|
wr_date as wrDate,
|
||||||
|
clear_alarm_id as clearAlarmId,
|
||||||
|
clear_id as clearId,
|
||||||
|
clear_data as clearData,
|
||||||
|
clear_content as clearContent,
|
||||||
|
clear_date as clearDate,
|
||||||
|
status
|
||||||
|
from nu_iot_yiweilian_humid_alarm
|
||||||
|
where alarm_id = #{alarmId}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<insert id="insertAlarm" parameterType="com.nu.modules.yiweilian.humid.entity.HumidAlarm">
|
||||||
|
insert into nu_iot_yiweilian_humid_alarm(
|
||||||
|
sn,
|
||||||
|
alarm_id,
|
||||||
|
wr_id,
|
||||||
|
wr_data,
|
||||||
|
wr_content,
|
||||||
|
wr_date,
|
||||||
|
status,
|
||||||
|
create_time
|
||||||
|
)
|
||||||
|
values(
|
||||||
|
#{sn},
|
||||||
|
#{alarmId},
|
||||||
|
#{wrId},
|
||||||
|
#{wrData},
|
||||||
|
#{wrContent},
|
||||||
|
#{wrDate},
|
||||||
|
'0',
|
||||||
|
now()
|
||||||
|
)
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
<update id="updateAlarm" parameterType="com.nu.modules.yiweilian.humid.entity.HumidAlarm">
|
||||||
|
update nu_iot_yiweilian_humid_alarm
|
||||||
|
set
|
||||||
|
clear_alarm_id = #{clearAlarmId},
|
||||||
|
clear_id = #{clearId},
|
||||||
|
clear_data = #{clearData},
|
||||||
|
clear_content = #{clearContent},
|
||||||
|
clear_date = #{clearDate},
|
||||||
|
status = '1',
|
||||||
|
update_time = now()
|
||||||
|
where status = '0'
|
||||||
|
and sn = #{sn}
|
||||||
|
and wr_id = #{wrId}
|
||||||
|
and wr_date <= #{clearDate}
|
||||||
|
</update>
|
||||||
|
|
||||||
|
</mapper>
|
|
@ -0,0 +1,340 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.nu.modules.yiweilian.humid.mapper.HumidDeviceMapper">
|
||||||
|
|
||||||
|
<select id="findPage" parameterType="com.nu.modules.yiweilian.humid.entity.HumidDevice" resultType="com.nu.modules.yiweilian.humid.entity.HumidDevice">
|
||||||
|
select
|
||||||
|
id,
|
||||||
|
sn,
|
||||||
|
device_name as deviceName,
|
||||||
|
device_types as deviceTypes,
|
||||||
|
reporting_interval as reportingInterval,
|
||||||
|
record_interval as recordInterval,
|
||||||
|
history_report_time as historyReportTime,
|
||||||
|
history_interval as historyInterval,
|
||||||
|
temperature_high as temperatureHigh,
|
||||||
|
temperature_low as temperatureLow,
|
||||||
|
temperature_buffer as temperatureBuffer,
|
||||||
|
humidity_high as humidityHigh,
|
||||||
|
humidity_low as humidityLow,
|
||||||
|
humidity_buffer as humidityBuffer,
|
||||||
|
iz_outages as izOutages,
|
||||||
|
iz_low_battery as izLowBattery,
|
||||||
|
iz_online as izOnline,
|
||||||
|
time_code as timeCode,
|
||||||
|
temperature,
|
||||||
|
humidity,
|
||||||
|
status,
|
||||||
|
reporting_time as reportingTime,
|
||||||
|
electricity,
|
||||||
|
nu_id as nuId,
|
||||||
|
nu_name as nuName,
|
||||||
|
depart_id as departId,
|
||||||
|
depart_name as departName,
|
||||||
|
depart_server_url as departServerUrl,
|
||||||
|
old_server_url ,
|
||||||
|
sync_type,
|
||||||
|
(select count(*) from nu_iot_yiweilian_humid_alarm b where a.sn = b.sn and b.status = '0') as alarmCn
|
||||||
|
from nu_iot_yiweilian_humid_device a
|
||||||
|
<where>
|
||||||
|
<if test="params.sn != null and params.sn != ''">
|
||||||
|
AND sn = #{params.sn}
|
||||||
|
</if>
|
||||||
|
<if test="params.nuId != null and params.nuId != ''">
|
||||||
|
AND nu_id = #{params.nuId}
|
||||||
|
</if>
|
||||||
|
<if test="params.departId != null and params.departId != ''">
|
||||||
|
AND depart_id = #{params.departId}
|
||||||
|
</if>
|
||||||
|
<if test="params.status != null and params.status != ''">
|
||||||
|
AND status = #{params.status}
|
||||||
|
</if>
|
||||||
|
</where>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="getHumidDevice" parameterType="com.nu.modules.yiweilian.humid.entity.HumidDevice" resultType="com.nu.modules.yiweilian.humid.entity.HumidDevice">
|
||||||
|
select
|
||||||
|
id,
|
||||||
|
sn,
|
||||||
|
device_name as deviceName,
|
||||||
|
device_types as deviceTypes,
|
||||||
|
reporting_interval as reportingInterval,
|
||||||
|
record_interval as recordInterval,
|
||||||
|
history_report_time as historyReportTime,
|
||||||
|
history_interval as historyInterval,
|
||||||
|
temperature_high as temperatureHigh,
|
||||||
|
temperature_low as temperatureLow,
|
||||||
|
temperature_buffer as temperatureBuffer,
|
||||||
|
humidity_high as humidityHigh,
|
||||||
|
humidity_low as humidityLow,
|
||||||
|
humidity_buffer as humidityBuffer,
|
||||||
|
iz_outages as izOutages,
|
||||||
|
iz_low_battery as izLowBattery,
|
||||||
|
iz_online as izOnline,
|
||||||
|
time_code as timeCode,
|
||||||
|
temperature,
|
||||||
|
humidity,
|
||||||
|
status,
|
||||||
|
reporting_time as reportingTime,
|
||||||
|
electricity,
|
||||||
|
nu_id as nuId,
|
||||||
|
nu_name as nuName,
|
||||||
|
depart_id as departId,
|
||||||
|
depart_name as departName,
|
||||||
|
depart_server_url as departServerUrl,
|
||||||
|
old_server_url ,
|
||||||
|
sync_type,
|
||||||
|
(select count(*) from nu_iot_yiweilian_humid_alarm b where a.sn = b.sn and b.status = '0') as alarmCn
|
||||||
|
from nu_iot_yiweilian_humid_device
|
||||||
|
<where>
|
||||||
|
<if test="sn != null and sn != ''">
|
||||||
|
AND sn = #{sn}
|
||||||
|
</if>
|
||||||
|
<if test="nuId != null and nuId != ''">
|
||||||
|
AND nu_id = #{nuId}
|
||||||
|
</if>
|
||||||
|
</where>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<insert id="insertDevice" parameterType="com.nu.modules.yiweilian.humid.entity.HumidDevice">
|
||||||
|
insert into nu_iot_yiweilian_humid_device(
|
||||||
|
sn,
|
||||||
|
time_code,
|
||||||
|
device_name,
|
||||||
|
create_time
|
||||||
|
)
|
||||||
|
values(
|
||||||
|
#{sn},
|
||||||
|
#{timeCode},
|
||||||
|
#{deviceName},
|
||||||
|
now()
|
||||||
|
)
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
<update id="updateDevice" parameterType="com.nu.modules.yiweilian.humid.entity.HumidDevice">
|
||||||
|
update nu_iot_yiweilian_humid_device
|
||||||
|
set
|
||||||
|
device_name = #{deviceName},
|
||||||
|
device_types = #{deviceTypes},
|
||||||
|
reporting_interval = #{reportingInterval},
|
||||||
|
record_interval = #{recordInterval},
|
||||||
|
history_report_time = #{historyReportTime},
|
||||||
|
history_interval = #{historyInterval},
|
||||||
|
temperature_high = #{temperatureHigh},
|
||||||
|
temperature_low = #{temperatureLow},
|
||||||
|
temperature_buffer = #{temperatureBuffer},
|
||||||
|
humidity_high = #{humidityHigh},
|
||||||
|
humidity_low = #{humidityLow},
|
||||||
|
humidity_buffer = #{humidityBuffer},
|
||||||
|
iz_outages = #{izOutages},
|
||||||
|
iz_low_battery = #{izLowBattery},
|
||||||
|
iz_online = #{izOnline},
|
||||||
|
time_code = #{timeCode},
|
||||||
|
update_time = now()
|
||||||
|
where sn = #{sn}
|
||||||
|
</update>
|
||||||
|
|
||||||
|
<delete id="deleteDevice" parameterType="com.nu.modules.yiweilian.humid.entity.HumidDevice">
|
||||||
|
delete from nu_iot_yiweilian_humid_device where sn = #{sn}
|
||||||
|
</delete>
|
||||||
|
|
||||||
|
<update id="updateValue" parameterType="com.nu.modules.yiweilian.humid.entity.HumidDevice">
|
||||||
|
update nu_iot_yiweilian_humid_device
|
||||||
|
set
|
||||||
|
temperature = #{temperature},
|
||||||
|
humidity = #{humidity},
|
||||||
|
status = #{status},
|
||||||
|
reporting_time = #{reportingTime},
|
||||||
|
electricity = #{electricity}
|
||||||
|
where sn = #{sn}
|
||||||
|
</update>
|
||||||
|
|
||||||
|
<insert id="insertLog" parameterType="com.nu.modules.yiweilian.humid.entity.HumidDevice">
|
||||||
|
insert into nu_iot_yiweilian_humid_device_log(
|
||||||
|
sn,
|
||||||
|
<if test="timeCode != null and timeCode != ''">
|
||||||
|
time_code,
|
||||||
|
</if>
|
||||||
|
<if test="deviceName != null and deviceName != ''">
|
||||||
|
device_name,
|
||||||
|
</if>
|
||||||
|
<if test="deviceTypes != null and deviceTypes != ''">
|
||||||
|
device_types,
|
||||||
|
</if>
|
||||||
|
<if test="reportingInterval != null and reportingInterval != ''">
|
||||||
|
reporting_interval,
|
||||||
|
</if>
|
||||||
|
<if test="recordInterval != null and recordInterval != ''">
|
||||||
|
record_interval,
|
||||||
|
</if>
|
||||||
|
<if test="historyReportTime != null and historyReportTime != ''">
|
||||||
|
history_report_time,
|
||||||
|
</if>
|
||||||
|
<if test="historyInterval != null and historyInterval != ''">
|
||||||
|
history_interval,
|
||||||
|
</if>
|
||||||
|
<if test="temperatureHigh != null and temperatureHigh != ''">
|
||||||
|
temperature_high,
|
||||||
|
</if>
|
||||||
|
<if test="temperatureLow != null and temperatureLow != ''">
|
||||||
|
temperature_low,
|
||||||
|
</if>
|
||||||
|
<if test="temperatureBuffer != null and temperatureBuffer != ''">
|
||||||
|
temperature_buffer,
|
||||||
|
</if>
|
||||||
|
<if test="humidityHigh != null and humidityHigh != ''">
|
||||||
|
humidity_high,
|
||||||
|
</if>
|
||||||
|
<if test="humidityLow != null and humidityLow != ''">
|
||||||
|
humidity_low,
|
||||||
|
</if>
|
||||||
|
<if test="humidityBuffer != null and humidityBuffer != ''">
|
||||||
|
humidity_buffer,
|
||||||
|
</if>
|
||||||
|
<if test="izOutages != null and izOutages != ''">
|
||||||
|
iz_outages,
|
||||||
|
</if>
|
||||||
|
<if test="izLowBattery != null and izLowBattery != ''">
|
||||||
|
iz_low_battery,
|
||||||
|
</if>
|
||||||
|
<if test="izOnline != null and izOnline != ''">
|
||||||
|
iz_online,
|
||||||
|
</if>
|
||||||
|
<if test="temperature != null and temperature != ''">
|
||||||
|
temperature,
|
||||||
|
</if>
|
||||||
|
<if test="humidity != null and humidity != ''">
|
||||||
|
humidity,
|
||||||
|
</if>
|
||||||
|
<if test="status != null and status != ''">
|
||||||
|
status,
|
||||||
|
</if>
|
||||||
|
<if test="reportingTime != null and reportingTime != ''">
|
||||||
|
reporting_time,
|
||||||
|
</if>
|
||||||
|
<if test="electricity != null and electricity != ''">
|
||||||
|
electricity,
|
||||||
|
</if>
|
||||||
|
opt_time,
|
||||||
|
<if test="optBy != null and optBy != ''">
|
||||||
|
opt_by,
|
||||||
|
</if>
|
||||||
|
opt_type
|
||||||
|
)values(
|
||||||
|
#{sn},
|
||||||
|
<if test="timeCode != null and timeCode != ''">
|
||||||
|
#{timeCode},
|
||||||
|
</if>
|
||||||
|
<if test="deviceName != null and deviceName != ''">
|
||||||
|
#{deviceName},
|
||||||
|
</if>
|
||||||
|
<if test="deviceTypes != null and deviceTypes != ''">
|
||||||
|
#{deviceTypes},
|
||||||
|
</if>
|
||||||
|
<if test="reportingInterval != null and reportingInterval != ''">
|
||||||
|
#{reportingInterval},
|
||||||
|
</if>
|
||||||
|
<if test="recordInterval != null and recordInterval != ''">
|
||||||
|
#{recordInterval},
|
||||||
|
</if>
|
||||||
|
<if test="historyReportTime != null and historyReportTime != ''">
|
||||||
|
#{historyReportTime},
|
||||||
|
</if>
|
||||||
|
<if test="historyInterval != null and historyInterval != ''">
|
||||||
|
#{historyInterval},
|
||||||
|
</if>
|
||||||
|
<if test="temperatureHigh != null and temperatureHigh != ''">
|
||||||
|
#{temperatureHigh},
|
||||||
|
</if>
|
||||||
|
<if test="temperatureLow != null and temperatureLow != ''">
|
||||||
|
#{temperatureLow},
|
||||||
|
</if>
|
||||||
|
<if test="temperatureBuffer != null and temperatureBuffer != ''">
|
||||||
|
#{temperatureBuffer},
|
||||||
|
</if>
|
||||||
|
<if test="humidityHigh != null and humidityHigh != ''">
|
||||||
|
#{humidityHigh},
|
||||||
|
</if>
|
||||||
|
<if test="humidityLow != null and humidityLow != ''">
|
||||||
|
#{humidityLow},
|
||||||
|
</if>
|
||||||
|
<if test="humidityBuffer != null and humidityBuffer != ''">
|
||||||
|
#{humidityBuffer},
|
||||||
|
</if>
|
||||||
|
<if test="izOutages != null and izOutages != ''">
|
||||||
|
#{izOutages},
|
||||||
|
</if>
|
||||||
|
<if test="izLowBattery != null and izLowBattery != ''">
|
||||||
|
#{izLowBattery},
|
||||||
|
</if>
|
||||||
|
<if test="izOnline != null and izOnline != ''">
|
||||||
|
#{izOnline},
|
||||||
|
</if>
|
||||||
|
<if test="temperature != null and temperature != ''">
|
||||||
|
#{temperature},
|
||||||
|
</if>
|
||||||
|
<if test="humidity != null and humidity != ''">
|
||||||
|
#{humidity},
|
||||||
|
</if>
|
||||||
|
<if test="status != null and status != ''">
|
||||||
|
#{status},
|
||||||
|
</if>
|
||||||
|
<if test="reportingTime != null and reportingTime != ''">
|
||||||
|
#{reportingTime},
|
||||||
|
</if>
|
||||||
|
<if test="electricity != null and electricity != ''">
|
||||||
|
#{electricity},
|
||||||
|
</if>
|
||||||
|
now(),
|
||||||
|
<if test="optBy != null and optBy != ''">
|
||||||
|
#{optBy},
|
||||||
|
</if>
|
||||||
|
#{optType}
|
||||||
|
)
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
<select id="findLogPage" parameterType="com.nu.modules.yiweilian.humid.entity.HumidDevice" resultType="com.nu.modules.yiweilian.humid.entity.HumidDevice">
|
||||||
|
select
|
||||||
|
id,
|
||||||
|
sn,
|
||||||
|
device_name as deviceName,
|
||||||
|
time_code as timeCode,
|
||||||
|
device_types as deviceTypes,
|
||||||
|
reporting_interval as reportingInterval,
|
||||||
|
record_interval as recordInterval,
|
||||||
|
history_report_time as historyReportTime,
|
||||||
|
history_interval as historyInterval,
|
||||||
|
temperature_high as temperatureHigh,
|
||||||
|
temperature_low as temperatureLow,
|
||||||
|
temperature_buffer as temperatureBuffer,
|
||||||
|
humidity_high as humidityHigh,
|
||||||
|
humidity_low as humidityLow,
|
||||||
|
humidity_buffer as humidityBuffer,
|
||||||
|
iz_outages as izOutages,
|
||||||
|
iz_low_battery as izLowBattery,
|
||||||
|
iz_online as izOnline,
|
||||||
|
temperature,
|
||||||
|
humidity,
|
||||||
|
status,
|
||||||
|
reporting_time as reportingTime,
|
||||||
|
electricity,
|
||||||
|
opt_time as optTime,
|
||||||
|
opt_by as optBy,
|
||||||
|
opt_type as optType
|
||||||
|
from nu_iot_yiweilian_humid_device_log
|
||||||
|
<where>
|
||||||
|
<if test="params.sn != null and params.sn != ''">
|
||||||
|
AND sn = #{params.sn}
|
||||||
|
</if>
|
||||||
|
<if test="params.optType != null and params.optType != '' and params.optType == 'read' ">
|
||||||
|
AND opt_type = 'read'
|
||||||
|
</if>
|
||||||
|
<if test="params.optType != null and params.optType != '' and params.optType != 'read' ">
|
||||||
|
AND opt_type != 'read'
|
||||||
|
AND opt_type = #{params.optType}
|
||||||
|
</if>
|
||||||
|
</where>
|
||||||
|
order by id desc
|
||||||
|
</select>
|
||||||
|
|
||||||
|
</mapper>
|
|
@ -0,0 +1,14 @@
|
||||||
|
package com.nu.modules.yiweilian.humid.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.nu.modules.yiweilian.humid.entity.HumidAlarm;
|
||||||
|
import org.jeecg.common.api.vo.Result;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface IHumidAlarmService extends IService<HumidAlarm> {
|
||||||
|
IPage<HumidAlarm> findPage(Page<HumidAlarm> page, HumidAlarm humidAlarm);
|
||||||
|
String getAlarm(HumidAlarm humidAlarm);
|
||||||
|
}
|
|
@ -0,0 +1,19 @@
|
||||||
|
package com.nu.modules.yiweilian.humid.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.nu.modules.yiweilian.humid.entity.HumidDevice;
|
||||||
|
import org.jeecg.common.api.vo.Result;
|
||||||
|
|
||||||
|
public interface IHumidDeviceService extends IService<HumidDevice> {
|
||||||
|
IPage<HumidDevice> findPage(Page<HumidDevice> page, HumidDevice humidDevice);
|
||||||
|
Result<String> insertDevice(HumidDevice humidDevice);
|
||||||
|
String updateDeviceParameters(HumidDevice humidDevice,String type);
|
||||||
|
String updateDeviceRealTime(HumidDevice humidDevice);
|
||||||
|
Result<String> updateDevice(HumidDevice humidDevice);
|
||||||
|
Result<String> deleteDevice(HumidDevice humidDevice);
|
||||||
|
Result getDeviceParameters(HumidDevice humidDevice);
|
||||||
|
IPage<HumidDevice> findLogPage(Page<HumidDevice> page, HumidDevice humidDevice);
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,138 @@
|
||||||
|
package com.nu.modules.yiweilian.humid.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.json.JSONArray;
|
||||||
|
import cn.hutool.json.JSONObject;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.nu.modules.yiweilian.humid.entity.HumidAlarm;
|
||||||
|
import com.nu.modules.yiweilian.humid.mapper.HumidAlarmMapper;
|
||||||
|
import com.nu.modules.yiweilian.humid.service.IHumidAlarmService;
|
||||||
|
import com.nu.modules.yiweilian.utils.YiweilianApi;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.jeecg.common.util.DateUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Service
|
||||||
|
public class HumidAlarmServiceImpl extends ServiceImpl<HumidAlarmMapper, HumidAlarm> implements IHumidAlarmService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
YiweilianApi yiweilianApi;
|
||||||
|
|
||||||
|
public IPage<HumidAlarm> findPage(Page<HumidAlarm> page, HumidAlarm HumidAlarm){
|
||||||
|
return baseMapper.findPage(page,HumidAlarm);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取告警数据
|
||||||
|
* @param HumidAlarm
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String getAlarm(HumidAlarm HumidAlarm){
|
||||||
|
Map<String, Object> params = getParmas(0,1000,HumidAlarm);
|
||||||
|
return updateAlarm(params,HumidAlarm);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取接口请求参数
|
||||||
|
* @param page
|
||||||
|
* @param limit
|
||||||
|
* @param HumidAlarm
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private Map<String, Object> getParmas(int page,int limit,HumidAlarm HumidAlarm){
|
||||||
|
Map<String, Object> params = new HashMap<>();
|
||||||
|
params.put("rows", limit);
|
||||||
|
params.put("page", page);
|
||||||
|
params.put("type", 2);//根据时间排序 1降序 2升序 ,此字段貌似不好使
|
||||||
|
if(HumidAlarm.getSn()!=null&&!HumidAlarm.getSn().equals("")){
|
||||||
|
params.put("sn", HumidAlarm.getSn());
|
||||||
|
}
|
||||||
|
if(HumidAlarm.getAlarmStartTime()!=null){
|
||||||
|
params.put("startTime", DateUtils.formatDate(HumidAlarm.getAlarmStartTime(),"yyyy-MM-dd HH:mm:ss"));
|
||||||
|
}
|
||||||
|
if(HumidAlarm.getAlarmEndTime()!=null){
|
||||||
|
params.put("endTime", DateUtils.formatDate(HumidAlarm.getAlarmEndTime(),"yyyy-MM-dd HH:mm:ss"));
|
||||||
|
}
|
||||||
|
return params;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新告警数据
|
||||||
|
* @param map
|
||||||
|
* @param HumidAlarm
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private String updateAlarm(Map<String,Object> map,HumidAlarm HumidAlarm){
|
||||||
|
String errorMsg = "";
|
||||||
|
String responseStr = yiweilianApi.getWarningData(map);
|
||||||
|
JSONObject jsonObject = new JSONObject(responseStr);
|
||||||
|
Integer responseCode = jsonObject.getInt("code");
|
||||||
|
if(responseCode.equals(0)){
|
||||||
|
JSONObject dataObj = jsonObject.getJSONObject("data");
|
||||||
|
Integer count = dataObj.getInt("count");
|
||||||
|
Integer limit = dataObj.getInt("rows");
|
||||||
|
Integer page = dataObj.getInt("page");
|
||||||
|
JSONArray dataArr = dataObj.getJSONArray("dataList");
|
||||||
|
if(dataArr.size()>0){
|
||||||
|
List<JSONObject> list = new ArrayList<>();
|
||||||
|
for (int i = 0; i < dataArr.size(); i++) {
|
||||||
|
list.add(dataArr.getJSONObject(i));
|
||||||
|
}
|
||||||
|
Collections.sort(list, (o1, o2) -> {
|
||||||
|
String name1 = o1.getStr("id");
|
||||||
|
String name2 = o2.getStr("id");
|
||||||
|
return name1.compareTo(name2);
|
||||||
|
});
|
||||||
|
dataArr = new JSONArray(list);
|
||||||
|
}
|
||||||
|
log.info("排序后:{}",dataArr.toString());
|
||||||
|
for(int i=0;i<dataArr.size();i++){
|
||||||
|
HumidAlarm ha = new HumidAlarm();
|
||||||
|
JSONObject json = (JSONObject)dataArr.get(i);
|
||||||
|
String alarmId = json.getStr("id");
|
||||||
|
String sn = json.getStr("sn");
|
||||||
|
String wrId = json.getStr("wrId");
|
||||||
|
String wrData = json.getStr("wrData");
|
||||||
|
String wrContent = json.getStr("content");
|
||||||
|
String wrDate = json.getStr("date");
|
||||||
|
|
||||||
|
ha.setAlarmId(alarmId);
|
||||||
|
ha.setSn(sn);
|
||||||
|
Integer wrIdint = Integer.parseInt(wrId);
|
||||||
|
if(wrIdint>100){
|
||||||
|
wrIdint = wrIdint -100;
|
||||||
|
ha.setWrId(""+wrIdint);
|
||||||
|
ha.setClearAlarmId(alarmId);
|
||||||
|
ha.setClearId(wrId);
|
||||||
|
ha.setClearData(wrData);
|
||||||
|
ha.setClearContent(wrContent);
|
||||||
|
ha.setClearDate(wrDate);
|
||||||
|
baseMapper.updateAlarm(ha);
|
||||||
|
}else{
|
||||||
|
HumidAlarm entity = baseMapper.getHumidAlarm(ha);
|
||||||
|
if(entity == null){
|
||||||
|
ha.setWrId(wrId);
|
||||||
|
ha.setWrData(wrData);
|
||||||
|
ha.setWrContent(wrContent);
|
||||||
|
ha.setWrDate(wrDate);
|
||||||
|
baseMapper.insertAlarm(ha);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if((page+1)*limit<count){
|
||||||
|
Map<String, Object> params = getParmas(page+1,limit,HumidAlarm);
|
||||||
|
errorMsg += updateAlarm(params,HumidAlarm);
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
errorMsg = jsonObject.getStr("msg");
|
||||||
|
}
|
||||||
|
return errorMsg;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,399 @@
|
||||||
|
package com.nu.modules.yiweilian.humid.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.json.JSONArray;
|
||||||
|
import cn.hutool.json.JSONObject;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.nu.modules.tq.utils.HttpTool;
|
||||||
|
import com.nu.modules.yiweilian.humid.entity.HumidDevice;
|
||||||
|
import com.nu.modules.yiweilian.humid.mapper.HumidDeviceMapper;
|
||||||
|
import com.nu.modules.yiweilian.humid.service.IHumidDeviceService;
|
||||||
|
import com.nu.modules.yiweilian.utils.YiweilianApi;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.shiro.SecurityUtils;
|
||||||
|
import org.jeecg.common.api.vo.Result;
|
||||||
|
import org.jeecg.common.system.vo.LoginUser;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Service
|
||||||
|
public class HumidDeviceServiceImpl extends ServiceImpl<HumidDeviceMapper, HumidDevice> implements IHumidDeviceService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
YiweilianApi yiweilianApi;
|
||||||
|
|
||||||
|
public IPage<HumidDevice> findPage(Page<HumidDevice> page, HumidDevice humidDevice){
|
||||||
|
return baseMapper.findPage(page,humidDevice);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Result<String> insertDevice(HumidDevice humidDevice){
|
||||||
|
Map<String, Object> params = new HashMap<>();
|
||||||
|
params.put("sn", humidDevice.getSn());
|
||||||
|
params.put("timeCode", humidDevice.getTimeCode());
|
||||||
|
params.put("deviceName", humidDevice.getDeviceName());
|
||||||
|
String responseStr = yiweilianApi.addDevice(params);
|
||||||
|
JSONObject jsonObject = new JSONObject(responseStr);
|
||||||
|
Integer responseCode = jsonObject.getInt("code");
|
||||||
|
if(responseCode.equals(10003)){
|
||||||
|
baseMapper.insertDevice(humidDevice);
|
||||||
|
humidDevice.setOptType("insert");
|
||||||
|
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||||
|
if(sysUser!=null){
|
||||||
|
humidDevice.setOptBy(sysUser.getUsername());
|
||||||
|
}
|
||||||
|
baseMapper.insertLog(humidDevice);
|
||||||
|
String error = updateDeviceParameters(humidDevice,"insert");
|
||||||
|
if(!error.equals("")){
|
||||||
|
String result = "设备添加成功,但是获取配置参数错误:"+ error;
|
||||||
|
return Result.error(result);
|
||||||
|
}
|
||||||
|
String error2 = updateDeviceRealTime(humidDevice);
|
||||||
|
if(!error2.equals("")){
|
||||||
|
String result = "设备添加成功,但是获取实时数据错误:"+ error2;
|
||||||
|
return Result.error(result);
|
||||||
|
}
|
||||||
|
return Result.OK("添加成功");
|
||||||
|
}else{
|
||||||
|
String result = "添加失败:"+jsonObject.getStr("msg");
|
||||||
|
return Result.error(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新设备配置参数
|
||||||
|
* @param humidDevice
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String updateDeviceParameters(HumidDevice humidDevice,String type){
|
||||||
|
Map<String, Object> params = getParmas(0,100,humidDevice);
|
||||||
|
return updateDeviceConfigs(params,humidDevice,type);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取接口请求参数
|
||||||
|
* @param page
|
||||||
|
* @param limit
|
||||||
|
* @param humidDevice
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private Map<String, Object> getParmas(int page,int limit,HumidDevice humidDevice){
|
||||||
|
Map<String, Object> params = new HashMap<>();
|
||||||
|
params.put("rows", limit);
|
||||||
|
params.put("page", page);
|
||||||
|
if(humidDevice.getSn()!=null&&!humidDevice.getSn().equals("")){
|
||||||
|
params.put("sn", humidDevice.getSn());
|
||||||
|
}
|
||||||
|
return params;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 调用接口更新设备配置参数
|
||||||
|
* @param map
|
||||||
|
* @param humidDevice
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private String updateDeviceConfigs(Map<String,Object> map,HumidDevice humidDevice,String type){
|
||||||
|
String errorMsg = "";
|
||||||
|
String responseStr = yiweilianApi.getDeviceConfigs(map);
|
||||||
|
JSONObject jsonObject = new JSONObject(responseStr);
|
||||||
|
Integer responseCode = jsonObject.getInt("code");
|
||||||
|
if(responseCode.equals(0)){
|
||||||
|
JSONObject dataObj = jsonObject.getJSONObject("data");
|
||||||
|
Integer count = dataObj.getInt("count");
|
||||||
|
Integer limit = dataObj.getInt("rows");
|
||||||
|
Integer page = dataObj.getInt("page");
|
||||||
|
JSONArray dataArr = dataObj.getJSONArray("dataList");
|
||||||
|
for(int i=0;i<dataArr.size();i++){
|
||||||
|
HumidDevice dh = new HumidDevice();
|
||||||
|
JSONObject json = (JSONObject)dataArr.get(i);
|
||||||
|
String sn = json.getStr("sn");
|
||||||
|
String deviceName = json.getStr("deviceName");
|
||||||
|
String deviceTypes = json.getStr("deviceTypes");
|
||||||
|
String reportingInterval = json.getStr("reportingInterval");
|
||||||
|
String recordInterval = json.getStr("recordInterval");
|
||||||
|
String historyReportTime = json.getStr("historyReportTime");
|
||||||
|
String historyInterval = json.getStr("historyInterval");
|
||||||
|
String temperatureHigh = json.getStr("temperatureHigh");
|
||||||
|
String temperatureLow = json.getStr("temperatureLow");
|
||||||
|
String temperatureBuffer = json.getStr("temperatureBuffer");
|
||||||
|
String humidityHigh = json.getStr("humidityHigh");
|
||||||
|
String humidityLow = json.getStr("humidityLow");
|
||||||
|
String humidityBuffer = json.getStr("humidityBuffer");
|
||||||
|
String timeCode = json.getStr("timeCode");
|
||||||
|
String isOutages = json.getStr("isOutages");
|
||||||
|
String isLowBattery = json.getStr("isLowBattery");
|
||||||
|
String isOnline = json.getStr("isOnline");
|
||||||
|
|
||||||
|
dh.setSn(sn);
|
||||||
|
dh.setDeviceName(deviceName);
|
||||||
|
dh.setDeviceTypes(deviceTypes);
|
||||||
|
dh.setReportingInterval(reportingInterval);
|
||||||
|
dh.setRecordInterval(recordInterval);
|
||||||
|
dh.setHistoryReportTime(historyReportTime);
|
||||||
|
dh.setHistoryInterval(historyInterval);
|
||||||
|
dh.setTemperatureHigh(temperatureHigh);
|
||||||
|
dh.setTemperatureLow(temperatureLow);
|
||||||
|
dh.setTemperatureBuffer(temperatureBuffer);
|
||||||
|
dh.setHumidityHigh(humidityHigh);
|
||||||
|
dh.setHumidityLow(humidityLow);
|
||||||
|
dh.setHumidityBuffer(humidityBuffer);
|
||||||
|
dh.setTimeCode(timeCode);
|
||||||
|
dh.setIzOutages(isOutages);
|
||||||
|
dh.setIzLowBattery(isLowBattery);
|
||||||
|
dh.setIzOnline(isOnline);
|
||||||
|
baseMapper.updateDevice(dh);
|
||||||
|
dh.setOptType(type);
|
||||||
|
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||||
|
if(sysUser!=null){
|
||||||
|
dh.setOptBy(sysUser.getUsername());
|
||||||
|
}
|
||||||
|
baseMapper.insertLog(dh);
|
||||||
|
}
|
||||||
|
if((page+1)*limit<count){
|
||||||
|
Map<String, Object> params = getParmas(page+1,limit,humidDevice);
|
||||||
|
errorMsg += updateDeviceConfigs(params,humidDevice,type);
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
errorMsg = jsonObject.getStr("msg");
|
||||||
|
}
|
||||||
|
return errorMsg;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新设备实时数据(抄表)
|
||||||
|
* @param humidDevice
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String updateDeviceRealTime(HumidDevice humidDevice){
|
||||||
|
Map<String, Object> params = getRealTimeParmas(0,50,humidDevice);
|
||||||
|
return updateDeviceRealTimeData(params,humidDevice);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 获取实时数据接口请求参数
|
||||||
|
* @param page
|
||||||
|
* @param limit
|
||||||
|
* @param humidDevice
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private Map<String, Object> getRealTimeParmas(int page,int limit,HumidDevice humidDevice){
|
||||||
|
Map<String, Object> params = new HashMap<>();
|
||||||
|
params.put("rows", limit);
|
||||||
|
params.put("page", page);
|
||||||
|
if(humidDevice.getSn()!=null&&!humidDevice.getSn().equals("")){
|
||||||
|
String[] str = new String[1];
|
||||||
|
str[0] = humidDevice.getSn();
|
||||||
|
params.put("snList", str);
|
||||||
|
}
|
||||||
|
return params;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 调用接口更新设备实时数据(抄表)
|
||||||
|
* @param map
|
||||||
|
* @param humidDevice
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private String updateDeviceRealTimeData(Map<String,Object> map,HumidDevice humidDevice){
|
||||||
|
String errorMsg = "";
|
||||||
|
String responseStr = yiweilianApi.getRealTime(map);
|
||||||
|
JSONObject jsonObject = new JSONObject(responseStr);
|
||||||
|
Integer responseCode = jsonObject.getInt("code");
|
||||||
|
if(responseCode.equals(0)){
|
||||||
|
JSONObject dataObj = jsonObject.getJSONObject("data");
|
||||||
|
Integer count = dataObj.getInt("count");
|
||||||
|
Integer limit = dataObj.getInt("rows");
|
||||||
|
Integer page = dataObj.getInt("page");
|
||||||
|
JSONArray dataArr = dataObj.getJSONArray("dataList");
|
||||||
|
for(int i=0;i<dataArr.size();i++){
|
||||||
|
HumidDevice dh = new HumidDevice();
|
||||||
|
JSONObject json = (JSONObject)dataArr.get(i);
|
||||||
|
String sn = json.getStr("sn");
|
||||||
|
String status = json.getStr("status");
|
||||||
|
String electricity = json.getStr("electricity");
|
||||||
|
String temperature = json.getStr("temperature");
|
||||||
|
String humidity = json.getStr("humidity");
|
||||||
|
String reportingTime = json.getStr("date");
|
||||||
|
|
||||||
|
dh.setSn(sn);
|
||||||
|
dh.setStatus(status);
|
||||||
|
dh.setElectricity(electricity);
|
||||||
|
dh.setTemperature(temperature);
|
||||||
|
dh.setHumidity(humidity);
|
||||||
|
dh.setReportingTime(reportingTime);
|
||||||
|
baseMapper.updateValue(dh);
|
||||||
|
humidDevice.setOptType("read");
|
||||||
|
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||||
|
if(sysUser!=null){
|
||||||
|
humidDevice.setOptBy(sysUser.getUsername());
|
||||||
|
}
|
||||||
|
baseMapper.insertLog(humidDevice);
|
||||||
|
}
|
||||||
|
if((page+1)*limit<count){
|
||||||
|
Map<String, Object> params = getParmas(page+1,limit,humidDevice);
|
||||||
|
errorMsg += updateDeviceRealTimeData(params,humidDevice);
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
errorMsg = jsonObject.getStr("msg");
|
||||||
|
}
|
||||||
|
return errorMsg;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Map<String, Object> getUpdateParmas(HumidDevice humidDevice){
|
||||||
|
Map<String, Object> params = new HashMap<>();
|
||||||
|
params.put("sn", humidDevice.getSn());
|
||||||
|
params.put("timeCode", humidDevice.getTimeCode());
|
||||||
|
params.put("deviceName", humidDevice.getDeviceName());
|
||||||
|
params.put("reportingInterval", humidDevice.getReportingInterval());
|
||||||
|
params.put("recordInterval", humidDevice.getRecordInterval());
|
||||||
|
params.put("historyReportTime", humidDevice.getHistoryReportTime());
|
||||||
|
params.put("historyInterval", humidDevice.getHistoryInterval());
|
||||||
|
params.put("temperatureHigh", humidDevice.getTemperatureHigh());
|
||||||
|
params.put("temperatureLow", humidDevice.getTemperatureLow());
|
||||||
|
params.put("temperatureBuffer", humidDevice.getTemperatureBuffer());
|
||||||
|
params.put("humidityHigh", humidDevice.getHumidityHigh());
|
||||||
|
params.put("humidityLow", humidDevice.getHumidityLow());
|
||||||
|
params.put("humidityBuffer", humidDevice.getHumidityBuffer());
|
||||||
|
params.put("isOutages", humidDevice.getIzOutages());
|
||||||
|
params.put("isLowBattery", humidDevice.getIzLowBattery());
|
||||||
|
params.put("isOnline", humidDevice.getIzOnline());
|
||||||
|
return params;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Result<String> updateDevice(HumidDevice humidDevice){
|
||||||
|
Map<String, Object> params = getUpdateParmas(humidDevice);
|
||||||
|
String responseStr = yiweilianApi.updateDeviceConfig(params);
|
||||||
|
JSONObject jsonObject = new JSONObject(responseStr);
|
||||||
|
Integer responseCode = jsonObject.getInt("code");
|
||||||
|
if(responseCode.equals(0)){
|
||||||
|
baseMapper.updateDevice(humidDevice);
|
||||||
|
humidDevice.setOptType("update");
|
||||||
|
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||||
|
humidDevice.setOptBy(sysUser.getUsername());
|
||||||
|
baseMapper.insertLog(humidDevice);
|
||||||
|
return Result.OK("修改成功");
|
||||||
|
}else{
|
||||||
|
String error = "修改失败:"+jsonObject.getStr("msg");
|
||||||
|
return Result.error(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Result<String> deleteDevice(HumidDevice humidDevice){
|
||||||
|
Map<String, Object> params = new HashMap<>();
|
||||||
|
params.put("sn", humidDevice.getSn());
|
||||||
|
String responseStr = yiweilianApi.deleteDevice(params);
|
||||||
|
JSONObject jsonObject = new JSONObject(responseStr);
|
||||||
|
Integer responseCode = jsonObject.getInt("code");
|
||||||
|
if(responseCode.equals(0)){
|
||||||
|
baseMapper.deleteDevice(humidDevice);
|
||||||
|
humidDevice.setOptType("delete");
|
||||||
|
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||||
|
humidDevice.setOptBy(sysUser.getUsername());
|
||||||
|
baseMapper.insertLog(humidDevice);
|
||||||
|
return Result.OK("删除成功");
|
||||||
|
}else{
|
||||||
|
String error = "删除失败:"+jsonObject.getStr("msg");
|
||||||
|
return Result.error(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取设备配置参数
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Result getDeviceParameters(HumidDevice humidDevice){
|
||||||
|
if(humidDevice.getSn()==null||humidDevice.getSn().equals("")){
|
||||||
|
return Result.error("请指定设备SN号");
|
||||||
|
}
|
||||||
|
Map<String, Object> params = getParmas(0,1,humidDevice);
|
||||||
|
HumidDevice deviceParameters = getDeviceConfigs(params);
|
||||||
|
if(deviceParameters!=null){
|
||||||
|
return Result.OK(deviceParameters);
|
||||||
|
}else{
|
||||||
|
return Result.error("获取设备配置参数错误");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 调用接口获取设备配置参数
|
||||||
|
* @param map
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private HumidDevice getDeviceConfigs(Map<String,Object> map){
|
||||||
|
HumidDevice dh = new HumidDevice();
|
||||||
|
String responseStr = yiweilianApi.getDeviceConfigs(map);
|
||||||
|
JSONObject jsonObject = new JSONObject(responseStr);
|
||||||
|
Integer responseCode = jsonObject.getInt("code");
|
||||||
|
if(responseCode.equals(0)){
|
||||||
|
JSONObject dataObj = jsonObject.getJSONObject("data");
|
||||||
|
JSONArray dataArr = dataObj.getJSONArray("dataList");
|
||||||
|
for(int i=0;i<dataArr.size();i++){
|
||||||
|
JSONObject json = (JSONObject)dataArr.get(i);
|
||||||
|
String sn = json.getStr("sn");
|
||||||
|
String deviceName = json.getStr("deviceName");
|
||||||
|
String deviceTypes = json.getStr("deviceTypes");
|
||||||
|
String reportingInterval = json.getStr("reportingInterval");
|
||||||
|
String recordInterval = json.getStr("recordInterval");
|
||||||
|
String historyReportTime = json.getStr("historyReportTime");
|
||||||
|
String historyInterval = json.getStr("historyInterval");
|
||||||
|
String temperatureHigh = json.getStr("temperatureHigh");
|
||||||
|
String temperatureLow = json.getStr("temperatureLow");
|
||||||
|
String temperatureBuffer = json.getStr("temperatureBuffer");
|
||||||
|
String humidityHigh = json.getStr("humidityHigh");
|
||||||
|
String humidityLow = json.getStr("humidityLow");
|
||||||
|
String humidityBuffer = json.getStr("humidityBuffer");
|
||||||
|
String timeCode = json.getStr("timeCode");
|
||||||
|
String isOutages = json.getStr("isOutages");
|
||||||
|
String isLowBattery = json.getStr("isLowBattery");
|
||||||
|
String isOnline = json.getStr("isOnline");
|
||||||
|
|
||||||
|
dh.setSn(sn);
|
||||||
|
dh.setDeviceName(deviceName);
|
||||||
|
dh.setDeviceTypes(deviceTypes);
|
||||||
|
dh.setReportingInterval(reportingInterval);
|
||||||
|
dh.setRecordInterval(recordInterval);
|
||||||
|
dh.setHistoryReportTime(historyReportTime);
|
||||||
|
dh.setHistoryInterval(historyInterval);
|
||||||
|
dh.setTemperatureHigh(temperatureHigh);
|
||||||
|
dh.setTemperatureLow(temperatureLow);
|
||||||
|
dh.setTemperatureBuffer(temperatureBuffer);
|
||||||
|
dh.setHumidityHigh(humidityHigh);
|
||||||
|
dh.setHumidityLow(humidityLow);
|
||||||
|
dh.setHumidityBuffer(humidityBuffer);
|
||||||
|
dh.setTimeCode(timeCode);
|
||||||
|
dh.setIzOutages(isOutages);
|
||||||
|
dh.setIzLowBattery(isLowBattery);
|
||||||
|
dh.setIzOnline(isOnline);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return dh;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IPage<HumidDevice> findLogPage(Page<HumidDevice> page, HumidDevice humidDevice){
|
||||||
|
return baseMapper.findLogPage(page,humidDevice);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,85 @@
|
||||||
|
package com.nu.modules.yiweilian.utils;
|
||||||
|
|
||||||
|
import cn.hutool.json.JSONObject;
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import org.apache.http.HttpResponse;
|
||||||
|
import org.apache.http.NameValuePair;
|
||||||
|
import org.apache.http.client.HttpClient;
|
||||||
|
import org.apache.http.client.entity.UrlEncodedFormEntity;
|
||||||
|
import org.apache.http.client.methods.HttpPost;
|
||||||
|
import org.apache.http.impl.client.HttpClientBuilder;
|
||||||
|
import org.apache.http.message.BasicNameValuePair;
|
||||||
|
import org.apache.http.util.EntityUtils;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.io.OutputStream;
|
||||||
|
import java.net.HttpURLConnection;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class HttpTool {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送http POST请求
|
||||||
|
* @param url
|
||||||
|
* @param map
|
||||||
|
* @return
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public static String httpClientPost(String url, Map<String,Object> map){
|
||||||
|
String errorMsg = "";
|
||||||
|
Gson gson = new Gson();
|
||||||
|
String map2 = gson.toJson(map);
|
||||||
|
System.out.println(map2);
|
||||||
|
try {
|
||||||
|
URL obj = new URL(url);
|
||||||
|
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
|
||||||
|
// 设置请求方法为 POST
|
||||||
|
con.setRequestMethod("POST");
|
||||||
|
// 设置请求头
|
||||||
|
con.setRequestProperty("Content-Type", "application/json"); // 声明发送 JSON
|
||||||
|
con.setRequestProperty("Accept", "application/json"); // 声明期望接收 JSON
|
||||||
|
con.setDoOutput(true); // 允许写入请求体
|
||||||
|
// 写入 JSON 请求体
|
||||||
|
try (OutputStream os = con.getOutputStream()) {
|
||||||
|
byte[] input = map2.getBytes("utf-8");
|
||||||
|
os.write(input, 0, input.length);
|
||||||
|
}
|
||||||
|
// 获取响应码
|
||||||
|
int responseCode = con.getResponseCode();
|
||||||
|
System.out.println("Response Code: " + responseCode);
|
||||||
|
// 读取响应(成功时)
|
||||||
|
if (responseCode == HttpURLConnection.HTTP_OK) { // 200
|
||||||
|
try (BufferedReader br = new BufferedReader(
|
||||||
|
new InputStreamReader(con.getInputStream(), "UTF-8"))) {
|
||||||
|
StringBuilder response = new StringBuilder();
|
||||||
|
String responseLine;
|
||||||
|
while ((responseLine = br.readLine()) != null) {
|
||||||
|
response.append(responseLine.trim());
|
||||||
|
}
|
||||||
|
System.out.println("Response: " + response.toString());
|
||||||
|
errorMsg = response.toString();
|
||||||
|
}
|
||||||
|
} else { // 错误时读取错误流
|
||||||
|
try (BufferedReader br = new BufferedReader(
|
||||||
|
new InputStreamReader(con.getErrorStream(), "UTF-8"))) {
|
||||||
|
StringBuilder errorResponse = new StringBuilder();
|
||||||
|
String errorLine;
|
||||||
|
while ((errorLine = br.readLine()) != null) {
|
||||||
|
errorResponse.append(errorLine.trim());
|
||||||
|
}
|
||||||
|
System.out.println("Error Response: " + errorResponse.toString());
|
||||||
|
errorMsg = "{\"code\":"+responseCode+",\"msg\":\""+errorResponse.toString()+"\" }";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return errorMsg;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,124 @@
|
||||||
|
package com.nu.modules.yiweilian.utils;
|
||||||
|
|
||||||
|
import com.nu.modules.yiweilian.common.entity.YiweilianConfig;
|
||||||
|
import com.nu.modules.yiweilian.common.mapper.YiweilianConfigMapper;
|
||||||
|
import com.nu.modules.yiweilian.enums.YiweilianApiEnum;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@Slf4j
|
||||||
|
public class YiweilianApi {
|
||||||
|
|
||||||
|
YiweilianConfig yiweilianConfig;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
YiweilianConfigMapper yiweilianConfigMapper;
|
||||||
|
|
||||||
|
private void initYiweilianConfig(){
|
||||||
|
if(yiweilianConfig==null){
|
||||||
|
yiweilianConfig = yiweilianConfigMapper.getConfig();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public YiweilianConfig getYiweilianConfig(){
|
||||||
|
this.initYiweilianConfig();
|
||||||
|
return yiweilianConfig;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加设备
|
||||||
|
*/
|
||||||
|
public String addDevice(Map<String, Object> params){
|
||||||
|
this.initYiweilianConfig();
|
||||||
|
params.put("clientId", yiweilianConfig.getClientId());
|
||||||
|
log.info("addDevice:request:{}",params);
|
||||||
|
String url = yiweilianConfig.getRequestUrl()+ YiweilianApiEnum.ADD_DEVICE.getValue();
|
||||||
|
String responseStr = HttpTool.httpClientPost(url, params);
|
||||||
|
log.info("addDevice:response:{}",responseStr);
|
||||||
|
return responseStr;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改设备配置
|
||||||
|
*/
|
||||||
|
public String updateDeviceConfig(Map<String, Object> params){
|
||||||
|
this.initYiweilianConfig();
|
||||||
|
params.put("clientId", yiweilianConfig.getClientId());
|
||||||
|
log.info("updateDeviceConfig:request:{}",params);
|
||||||
|
String url = yiweilianConfig.getRequestUrl()+YiweilianApiEnum.UPDATE_DEVICE_CONFIG.getValue();
|
||||||
|
String responseStr = HttpTool.httpClientPost(url, params);
|
||||||
|
log.info("updateDeviceConfig:response:{}",responseStr);
|
||||||
|
return responseStr;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除设备
|
||||||
|
*/
|
||||||
|
public String deleteDevice(Map<String, Object> params){
|
||||||
|
this.initYiweilianConfig();
|
||||||
|
params.put("clientId", yiweilianConfig.getClientId());
|
||||||
|
log.info("deleteDevice:request:{}",params);
|
||||||
|
String url = yiweilianConfig.getRequestUrl()+YiweilianApiEnum.DELETE_DEVICE.getValue();
|
||||||
|
String responseStr = HttpTool.httpClientPost(url, params);
|
||||||
|
log.info("deleteDevice:response:{}",responseStr);
|
||||||
|
return responseStr;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询设备列表(分页)
|
||||||
|
*/
|
||||||
|
// public String getDevices(Map<String, Object> params){
|
||||||
|
// this.initYiweilianConfig();
|
||||||
|
// params.put("clientId", yiweilianConfig.getClientId());
|
||||||
|
// log.info("getDevices:request:{}",params);
|
||||||
|
// String url = yiweilianConfig.getRequestUrl()+YiweilianApiEnum.GET_DEVICES.getValue();
|
||||||
|
// String responseStr = HttpTool.httpClientPost(url, params);
|
||||||
|
// log.info("getDevices:response:{}",responseStr);
|
||||||
|
// return responseStr;
|
||||||
|
// }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询设备列表含配置信息(分页)
|
||||||
|
*/
|
||||||
|
public String getDeviceConfigs(Map<String, Object> params){
|
||||||
|
this.initYiweilianConfig();
|
||||||
|
params.put("clientId", yiweilianConfig.getClientId());
|
||||||
|
log.info("getDeviceConfigs:request:{}",params);
|
||||||
|
String url = yiweilianConfig.getRequestUrl()+YiweilianApiEnum.GET_DEVICE_CONFIGS.getValue();
|
||||||
|
String responseStr = HttpTool.httpClientPost(url, params);
|
||||||
|
log.info("getDeviceConfigs:response:{}",responseStr);
|
||||||
|
return responseStr;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询设备实时数据(分页)
|
||||||
|
*/
|
||||||
|
public String getRealTime(Map<String, Object> params){
|
||||||
|
this.initYiweilianConfig();
|
||||||
|
params.put("clientId", yiweilianConfig.getClientId());
|
||||||
|
log.info("getRealTime:request:{}",params);
|
||||||
|
String url = yiweilianConfig.getRequestUrl()+YiweilianApiEnum.GET_REAL_TIME.getValue();
|
||||||
|
String responseStr = HttpTool.httpClientPost(url, params);
|
||||||
|
log.info("getRealTime:response:{}",responseStr);
|
||||||
|
return responseStr;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询告警记录(分页)
|
||||||
|
*/
|
||||||
|
public String getWarningData(Map<String, Object> params){
|
||||||
|
this.initYiweilianConfig();
|
||||||
|
params.put("clientId", yiweilianConfig.getClientId());
|
||||||
|
log.info("getWarningData:request:{}",params);
|
||||||
|
String url = yiweilianConfig.getRequestUrl()+YiweilianApiEnum.GET_WARNING_DATA.getValue();
|
||||||
|
String responseStr = HttpTool.httpClientPost(url, params);
|
||||||
|
log.info("getWarningData:response:{}",responseStr);
|
||||||
|
return responseStr;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue