1-21 ------

This commit is contained in:
Xiao
2025-01-21 18:51:12 +08:00
parent 867209e6dd
commit 8f2f0ea7c6
14 changed files with 946 additions and 544 deletions

View File

@@ -34,4 +34,5 @@ public class DeviceStatusBo {
private String mqttAccount;
private String password;
}

View File

@@ -73,6 +73,8 @@ public class DeviceStatusConsumer {
device.setStatus(1);
device.setTenantId(1L);
device.setTenantName("admin");
device.setGroupId(0L);
deviceService.insertDeviceTest(device);
device = deviceService.selectDeviceBySerialNumber(bo.getSerialNumber());
}
@@ -84,12 +86,22 @@ public class DeviceStatusConsumer {
if (containsKey && !isOnline) {
//如果session存在但数据库状态不在线则以session为准
bo.setStatus(DeviceStatus.ONLINE);
device.setDelFlag("0");
}
if (!containsKey && isOnline) {
bo.setStatus(DeviceStatus.OFFLINE);
// 判断下 项目id
if (device.getGroupId().equals(0L) || device.getGroupId() == null) {
//设置删除状态 todo
device.setDelFlag("2");
}
}
}
/*更新设备状态*/
deviceCache.updateDeviceStatusCache(bo, device);
//处理影子模式值
this.handlerShadow(device, bo.getStatus());

View File

@@ -2,6 +2,7 @@ package com.xinda.data.controller;
import com.xinda.common.core.controller.BaseController;
import com.xinda.common.core.domain.AjaxResult;
import com.xinda.common.core.domain.R;
import com.xinda.common.core.page.TableDataInfo;
import com.xinda.common.utils.poi.ExcelUtil;
import com.xinda.iot.domain.DeviceModel;
@@ -25,19 +26,30 @@ import java.util.List;
@RestController
@RequestMapping("/iot/deviceModel")
@Api(tags = "产品型号")
public class DeviceModelController extends BaseController
{
public class DeviceModelController extends BaseController {
@Autowired
private IDeviceModelService deviceModelService;
/**
* 查询全部产品下拉框
* @return
*/
@GetMapping("/getAllModel")
public R getAllModel()
{
return R.ok(deviceModelService.selectDeviceModelList(new DeviceModel()));
}
/**
* 查询产品型号列表
*/
@PreAuthorize("@ss.hasPermi('iot:model:list')")
@GetMapping("/list")
@ApiOperation("查询产品型号列表")
public TableDataInfo list(DeviceModel deviceModel)
{
public TableDataInfo list(DeviceModel deviceModel) {
startPage();
List<DeviceModel> list = deviceModelService.selectDeviceModelList(deviceModel);
return getDataTable(list);
@@ -49,8 +61,7 @@ public class DeviceModelController extends BaseController
@ApiOperation("导出产品型号列表")
@PreAuthorize("@ss.hasPermi('iot:model:export')")
@PostMapping("/export")
public void export(HttpServletResponse response, DeviceModel deviceModel)
{
public void export(HttpServletResponse response, DeviceModel deviceModel) {
List<DeviceModel> list = deviceModelService.selectDeviceModelList(deviceModel);
ExcelUtil<DeviceModel> util = new ExcelUtil<DeviceModel>(DeviceModel.class);
util.exportExcel(response, list, "产品型号数据");
@@ -62,8 +73,7 @@ public class DeviceModelController extends BaseController
@PreAuthorize("@ss.hasPermi('iot:model:query')")
@GetMapping(value = "/{id}")
@ApiOperation("获取产品型号详细信息")
public AjaxResult getInfo(@PathVariable("id") Long id)
{
public AjaxResult getInfo(@PathVariable("id") Long id) {
return success(deviceModelService.selectDeviceModelById(id));
}
@@ -73,8 +83,7 @@ public class DeviceModelController extends BaseController
@PreAuthorize("@ss.hasPermi('iot:model:add')")
@PostMapping
@ApiOperation("新增产品型号")
public AjaxResult add(@RequestBody DeviceModel deviceModel)
{
public AjaxResult add(@RequestBody DeviceModel deviceModel) {
deviceModel.setCreateTime(new Date());
return toAjax(deviceModelService.insertDeviceModel(deviceModel));
}
@@ -85,8 +94,7 @@ public class DeviceModelController extends BaseController
@PreAuthorize("@ss.hasPermi('iot:model:edit')")
@PutMapping
@ApiOperation("修改产品型号")
public AjaxResult edit(@RequestBody DeviceModel deviceModel)
{
public AjaxResult edit(@RequestBody DeviceModel deviceModel) {
return toAjax(deviceModelService.updateDeviceModel(deviceModel));
}
@@ -96,8 +104,7 @@ public class DeviceModelController extends BaseController
@PreAuthorize("@ss.hasPermi('iot:model:remove')")
@DeleteMapping("/{ids}")
@ApiOperation("删除产品型号")
public AjaxResult remove(@PathVariable Long[] ids)
{
public AjaxResult remove(@PathVariable Long[] ids) {
return toAjax(deviceModelService.deleteDeviceModelByIds(ids));
}
}

View File

@@ -4,6 +4,7 @@ import java.util.ArrayList;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.xinda.common.core.domain.R;
import com.xinda.iot.domain.DeviceGroup;
import com.xinda.iot.model.DeviceGroupInput;
import io.swagger.annotations.Api;
@@ -41,6 +42,16 @@ public class GroupController extends BaseController
@Autowired
private IGroupService groupService;
/**
* 所属项目下拉框数据
*/
@GetMapping("/getAllGroupList")
public R getAllGroupList()
{
return R.ok(groupService.selectGroupList(new Group()));
}
/**
* 查询设备分组列表
*/

View File

@@ -58,16 +58,31 @@ public class MqttPublish implements MqttHandler {
@Override
public void handler(ChannelHandlerContext ctx, MqttMessage message) {
JSONObject jsonObject = JSON.parseObject((String) message.payload());
System.out.println(jsonObject);
// 查看消息
MqttPublishMessage publishMessage = (MqttPublishMessage) message;
/*获取客户端id*/
String clientId = AttributeUtils.getClientId(ctx.channel());
String topicName = publishMessage.variableHeader().topicName();
log.debug("=>***客户端[{}],主题[{}],推送消息[{}]", clientId, topicName,
ByteBufUtil.hexDump(publishMessage.content()));
// 以get结尾是模拟客户端数据,只转发消息
if (topicName.endsWith(XinDaConstant.MQTT.PROPERTY_GET_SIMULATE)) {
sendTestToMQ(publishMessage);
} else {
}
// else if (topicName.contains("/function/get/")) {
//// 改成订阅主题 进行保存
// System.out.println("改成订阅主题");
// } else if (topicName.contains("/info/get/")) {
// //发布主题 推送的消息进行保存
// System.out.println("发布主题");
// }
else {
/*获取客户端session*/
Session session = AttributeUtils.getSession(ctx.channel());
//平台检测session是否同步

View File

@@ -26,133 +26,191 @@ import java.util.List;
@ApiModel(value = "Device", description = "设备对象 iot_device")
@JsonInclude(JsonInclude.Include.NON_NULL)
@Data
public class Device extends BaseEntity
{
public class Device extends BaseEntity {
private static final long serialVersionUID = 1L;
/** 设备ID */
/**
* 设备ID
*/
@ApiModelProperty("设备ID")
private Long deviceId;
/** 设备名称 */
/**
* 设备名称
*/
@ApiModelProperty("设备名称")
@Excel(name = "设备名称")
private String deviceName;
/** 产品ID */
/**
* 产品ID
*/
@ApiModelProperty("产品ID")
@Excel(name = "产品ID")
private Long productId;
/** 产品名称 */
/**
* 产品名称
*/
@ApiModelProperty("产品名称")
@Excel(name = "产品名称")
private String productName;
/** 租户ID */
/**
* 租户ID
*/
@ApiModelProperty("租户ID")
@Excel(name = "租户ID")
private Long tenantId;
/** 租户名称 */
/**
* 租户名称
*/
@ApiModelProperty("租户名称")
@Excel(name = "租户名称")
private String tenantName;
/** 设备编号 */
/**
* 设备编号
*/
@ApiModelProperty("设备编号")
@Excel(name = "设备编号")
private String serialNumber;
/** 固件版本 */
/**
* 固件版本
*/
@ApiModelProperty("固件版本")
@Excel(name = "固件版本")
private BigDecimal firmwareVersion;
/** 设备类型1-直连设备、2-网关设备、3-监控设备) */
/**
* 设备类型1-直连设备、2-网关设备、3-监控设备)
*/
@ApiModelProperty("设备类型1-直连设备、2-网关设备、3-监控设备 4-网关子设备)")
private Integer deviceType;
/** 设备状态1-未激活2-禁用3-在线4-离线) */
/**
* 设备状态1-未激活2-禁用3-在线4-离线)
*/
@ApiModelProperty("设备状态1-未激活2-禁用3-在线4-离线)")
@Excel(name = "设备状态")
private Integer status;
/** wifi信号强度信号极好4格[-55— 0]信号好3格[-70— -55]信号一般2格[-85— -70]信号差1格[-100— -85] */
/**
* wifi信号强度信号极好4格[-55— 0]信号好3格[-70— -55]信号一般2格[-85— -70]信号差1格[-100— -85]
*/
@ApiModelProperty("wifi信号强度信号极好4格[-55— 0]信号好3格[-70— -55]信号一般2格[-85— -70]信号差1格[-100— -85]")
@Excel(name = "wifi信号强度")
private Integer rssi;
/** 设备影子 */
/**
* 设备影子
*/
@ApiModelProperty("是否启用设备影子(0=禁用1=启用)")
private Integer isShadow;
/** 设备所在地址 */
/**
* 设备所在地址
*/
@ApiModelProperty("设备所在地址")
@Excel(name = "设备所在地址")
private String networkAddress;
/** 设备入网IP */
/**
* 设备入网IP
*/
@ApiModelProperty("设备入网IP")
@Excel(name = "设备入网IP")
private String networkIp;
/** 设备经度 */
/**
* 设备经度
*/
@ApiModelProperty("设备经度")
@Excel(name = "设备经度")
private BigDecimal longitude;
/** 设备纬度 */
/**
* 设备纬度
*/
@ApiModelProperty("设备纬度")
@Excel(name = "设备纬度")
private BigDecimal latitude;
/** 激活时间 */
/**
* 激活时间
*/
@ApiModelProperty("激活时间")
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "激活时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date activeTime;
/** 子设备网关编号 */
/**
* 子设备网关编号
*/
@ApiModelProperty("子设备网关编号")
@Excel(name = "网关设备编号(子设备使用)")
private String gwDevCode;
/** 物模型值 */
/**
* 物模型值
*/
@ApiModelProperty("物模型值")
@Excel(name = "物模型")
private String thingsModelValue;
/** 图片地址 */
/**
* 图片地址
*/
@ApiModelProperty("图片地址")
private String imgUrl;
/** 是否自定义位置 **/
/**
* 是否自定义位置
**/
@ApiModelProperty("定位方式(1=ip自动定位2=设备定位3=自定义)")
private Integer locationWay;
/** 设备摘要 **/
/**
* 设备摘要
**/
@ApiModelProperty("设备摘要")
private String summary;
/** 分组ID用于分组查询 **/
/**
* 分组ID用于分组查询
**/
@ApiModelProperty("分组ID用于分组查询")
private Long groupId;
/** 是否设备所有者,用于查询 **/
// 需要排除分分组id 排除0
private String groupIdExclude;
/**
* 是否设备所有者,用于查询
**/
@ApiModelProperty("是否设备所有者,用于查询")
private Integer isOwner;
/**子设备数量*/
/**
* 子设备数量
*/
@ApiModelProperty("子设备数量")
private Integer subDeviceCount;
/**是否是模拟设备*/
/**
* 是否是模拟设备
*/
@ApiModelProperty("是否是模拟设备")
private Integer isSimulate;
/**子设备地址*/
/**
* 子设备地址
*/
@ApiModelProperty("子设备地址")
private Integer slaveId;
/**设备传输协议*/
/**
* 设备传输协议
*/
@ApiModelProperty("设备传输协议")
private String transport;
@@ -166,7 +224,9 @@ public class Device extends BaseEntity
private List<Device> subDeviceList;
/** 删除标志0代表存在 2代表删除 */
/**
* 删除标志0代表存在 2代表删除
*/
@ApiModelProperty("删除标志")
private String delFlag;
@@ -174,6 +234,11 @@ public class Device extends BaseEntity
* 关联组态,来源产品
*/
private String guid;
// todo
private Long agenciesId;
private List<SipRelation> sipRelationList;

View File

@@ -17,58 +17,83 @@ import org.springframework.data.annotation.Transient;
*/
@ApiModel(value = "Product", description = "产品对象 iot_product")
@JsonInclude(JsonInclude.Include.NON_NULL)
public class Product extends BaseEntity
{
public class Product extends BaseEntity {
private static final long serialVersionUID = 1L;
/** 产品ID */
/**
* 产品ID
*/
@ApiModelProperty("产品ID")
private Long productId;
/** 产品名称 */
/**
* 产品名称
*/
@ApiModelProperty("产品名称")
@Excel(name = "产品名称")
private String productName;
/** 产品分类ID */
// 判断的未分类
private String productNameExclude;
/**
* 产品分类ID
*/
@ApiModelProperty("产品分类ID")
@Excel(name = "产品分类ID")
private Long categoryId;
/** 产品分类名称 */
/**
* 产品分类名称
*/
@ApiModelProperty("产品分类名称")
@Excel(name = "产品分类名称")
private String categoryName;
/** 租户ID */
/**
* 租户ID
*/
@ApiModelProperty("租户ID")
@Excel(name = "租户ID")
private Long tenantId;
/** 租户名称 */
/**
* 租户名称
*/
@ApiModelProperty("租户名称")
@Excel(name = "租户名称")
private String tenantName;
/** 是否私有产品0-否1-是)私有下级不能共享 */
/**
* 是否私有产品0-否1-是)私有下级不能共享
*/
@ApiModelProperty(value = "是否私有产品", notes = "0-否1-是)")
@Excel(name = "是否私有产品", readConverterExp = "0-否1-是")
private Integer isSys;
/** 是否启用授权码0-否1-是) */
/**
* 是否启用授权码0-否1-是)
*/
@ApiModelProperty(value = "是否启用授权码", notes = "0-否1-是)")
@Excel(name = "是否启用授权码", readConverterExp = "0=-否1-是")
private Integer isAuthorize;
/** mqtt账号 */
/**
* mqtt账号
*/
@ApiModelProperty("mqtt账号")
private String mqttAccount;
/** mqtt密码 */
/**
* mqtt密码
*/
@ApiModelProperty("mqtt密码")
private String mqttPassword;
/** 产品秘钥 */
/**
* 产品秘钥
*/
@ApiModelProperty("产品秘钥")
private String mqttSecret;
@@ -80,10 +105,14 @@ public class Product extends BaseEntity
@ApiModelProperty("产品支持的传输协议,多个的选一个即可")
private String transport;
/** 是否自定义位置 **/
/**
* 是否自定义位置
**/
@ApiModelProperty("定位方式(1=ip自动定位2=设备定位3=自定义)")
private Integer locationWay;
public String getTransport() {
return transport;
}
@@ -108,39 +137,55 @@ public class Product extends BaseEntity
this.mqttSecret = mqttSecret;
}
/** 状态1-未发布2-已发布,不能修改) */
/**
* 状态1-未发布2-已发布,不能修改)
*/
@ApiModelProperty(value = "状态", notes = "1-未发布2-已发布,不能修改)")
@Excel(name = "状态", readConverterExp = "1==未发布2=已发布,不能修改")
private Integer status;
/** 设备类型1-直连设备、2-网关子设备、3-网关设备) */
/**
* 设备类型1-直连设备、2-网关子设备、3-网关设备)
*/
@ApiModelProperty(value = "设备类型", notes = "1-直连设备、2-网关子设备、3-网关设备、4-网关子设备)")
@Excel(name = "设备类型", readConverterExp = "1=直连设备、2=网关设备、3=监控设备、4-网关子设备")
private Integer deviceType;
/** 联网方式1=-wifi、2-蜂窝(2G/3G/4G/5G)、3-以太网、4-其他) */
/**
* 联网方式1=-wifi、2-蜂窝(2G/3G/4G/5G)、3-以太网、4-其他)
*/
@ApiModelProperty(value = "联网方式", notes = "1=-wifi、2-蜂窝(2G/3G/4G/5G)、3-以太网、4-其他)")
@Excel(name = "联网方式", readConverterExp = "1=-wifi、2=蜂窝(2G/3G/4G/5G)、3=以太网、4=其他")
private Integer networkMethod;
/** 认证方式1-账号密码、2-证书、3-Http */
/**
* 认证方式1-账号密码、2-证书、3-Http
*/
@ApiModelProperty(value = "认证方式", notes = "1-账号密码、2-证书、3-Http")
@Excel(name = "认证方式", readConverterExp = "1=账号密码、2=证书、3=Http")
private Integer vertificateMethod;
/** 图片地址 */
/**
* 图片地址
*/
@ApiModelProperty("图片地址")
private String imgUrl;
/** 删除标志0代表存在 2代表删除 */
/**
* 删除标志0代表存在 2代表删除
*/
@ApiModelProperty(value = "删除标志", notes = "0代表存在 2代表删除")
private String delFlag;
/** 物模型Json **/
/**
* 物模型Json
**/
@ApiModelProperty("物模型Json")
private String thingsModelsJson;
/**采集点模板id*/
/**
* 采集点模板id
*/
@ApiModelProperty("采集点模板id")
private Long templateId;
@@ -248,137 +293,134 @@ public class Product extends BaseEntity
this.imgUrl = imgUrl;
}
public void setProductId(Long productId)
{
public void setProductId(Long productId) {
this.productId = productId;
}
public Long getProductId()
{
public Long getProductId() {
return productId;
}
public void setProductName(String productName)
{
public void setProductName(String productName) {
this.productName = productName;
}
public String getProductName()
{
public String getProductName() {
return productName;
}
public void setCategoryId(Long categoryId)
{
public void setCategoryId(Long categoryId) {
this.categoryId = categoryId;
}
public Long getCategoryId()
{
public Long getCategoryId() {
return categoryId;
}
public void setCategoryName(String categoryName)
{
public void setCategoryName(String categoryName) {
this.categoryName = categoryName;
}
public String getCategoryName()
{
public String getCategoryName() {
return categoryName;
}
public void setTenantId(Long tenantId)
{
public void setTenantId(Long tenantId) {
this.tenantId = tenantId;
}
public Long getTenantId()
{
public Long getTenantId() {
return tenantId;
}
public void setTenantName(String tenantName)
{
public void setTenantName(String tenantName) {
this.tenantName = tenantName;
}
public String getTenantName()
{
public String getTenantName() {
return tenantName;
}
public void setIsSys(Integer isSys)
{
public void setIsSys(Integer isSys) {
this.isSys = isSys;
}
public Integer getIsSys()
{
public Integer getIsSys() {
return isSys;
}
public void setIsAuthorize(Integer isAuthorize) {this.isAuthorize = isAuthorize;}
public Integer getIsAuthorize() {return isAuthorize;}
public void setIsAuthorize(Integer isAuthorize) {
this.isAuthorize = isAuthorize;
}
public void setMqttAccount(String mqttAccount)
{
public Integer getIsAuthorize() {
return isAuthorize;
}
public void setMqttAccount(String mqttAccount) {
this.mqttAccount = mqttAccount;
}
public String getMqttAccount()
{
public String getMqttAccount() {
return mqttAccount;
}
public void setMqttPassword(String mqttPassword)
{
public void setMqttPassword(String mqttPassword) {
this.mqttPassword = mqttPassword;
}
public String getMqttPassword()
{
public String getMqttPassword() {
return mqttPassword;
}
public void setStatus(Integer status)
{
public void setStatus(Integer status) {
this.status = status;
}
public Integer getStatus()
{
public Integer getStatus() {
return status;
}
public void setDeviceType(Integer deviceType)
{
public void setDeviceType(Integer deviceType) {
this.deviceType = deviceType;
}
public Integer getDeviceType()
{
public Integer getDeviceType() {
return deviceType;
}
public void setNetworkMethod(Integer networkMethod)
{
public void setNetworkMethod(Integer networkMethod) {
this.networkMethod = networkMethod;
}
public Integer getNetworkMethod()
{
public Integer getNetworkMethod() {
return networkMethod;
}
public void setVertificateMethod(Integer vertificateMethod)
{
public void setVertificateMethod(Integer vertificateMethod) {
this.vertificateMethod = vertificateMethod;
}
public Integer getVertificateMethod()
{
public Integer getVertificateMethod() {
return vertificateMethod;
}
public void setDelFlag(String delFlag)
{
public void setDelFlag(String delFlag) {
this.delFlag = delFlag;
}
public String getDelFlag()
{
public String getDelFlag() {
return delFlag;
}
public String getProductNameExclude() {
return productNameExclude;
}
public void setProductNameExclude(String productNameExclude) {
this.productNameExclude = productNameExclude;
}
@Override
public String toString() {
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)

View File

@@ -363,4 +363,5 @@ public interface DeviceMapper
*/
List<DeviceGroup> listDeviceGroupByGroupIds(List<Long> groupIds);
void deleteDeviceBygroupId();
}

View File

@@ -4,6 +4,7 @@ import com.xinda.iot.model.ThingsModels.ThingsModelValueItem;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.xinda.common.annotation.Excel;
import com.xinda.iot.model.ThingsModelItem.*;
import lombok.Data;
import java.math.BigDecimal;
import java.util.ArrayList;
@@ -16,6 +17,7 @@ import java.util.List;
* @author kerwincui
* @date 2021-12-16
*/
@Data
public class DeviceShortOutput
{
public DeviceShortOutput(){
@@ -127,6 +129,18 @@ public class DeviceShortOutput
*/
private String guid;
private Long groupId;
private Long agenciesId;
/**
* 所属机构
* agenciesName
* @return
*/
private String agenciesName;
public String getGuid() {
return guid;
}

View File

@@ -38,6 +38,7 @@ import com.xinda.iot.cache.IDeviceCache;
import com.xinda.iot.cache.ITSLValueCache;
import com.xinda.iot.tdengine.service.ILogService;
import com.xinda.system.mapper.SysDeptMapper;
import com.xinda.system.service.ISysDeptService;
import com.xinda.system.service.ISysUserService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -123,6 +124,8 @@ public class DeviceServiceImpl implements IDeviceService {
private SubGatewayMapper subGatewayMapper;
@Resource
private IOrderControlService orderControlService;
@Resource
private IGroupService groupService;
/**
@@ -467,6 +470,9 @@ public class DeviceServiceImpl implements IDeviceService {
return deviceMapper.selectAllDeviceShortList(device);
}
@Autowired
private ISysDeptService deptService;
/**
* 查询设备分页简短列表
*
@@ -475,6 +481,13 @@ public class DeviceServiceImpl implements IDeviceService {
*/
@Override
public List<DeviceShortOutput> selectDeviceShortList(Device device) {
// 清空离线并且 group_id = 0 的数据
// deviceMapper.deleteDeviceBygroupId();
List<DeviceShortOutput> list = deviceMapper.selectDeviceShortList(device);
List<DeviceAlertCount> alist = alertLogService.selectDeviceAlertCount();
for (DeviceAlertCount item : alist) {
@@ -482,6 +495,18 @@ public class DeviceServiceImpl implements IDeviceService {
.filter(it -> Objects.equals(it.getSerialNumber(), item.getSerialNumber()))
.forEach(it -> it.setAlertCount(item));
}
for (DeviceShortOutput deviceShortOutput : list) {
if(deviceShortOutput.getAgenciesId()!=null){
SysDept sysDept = deptService.selectDeptById(deviceShortOutput.getAgenciesId());
deviceShortOutput.setAgenciesName(sysDept.getDeptName());
}else{
deviceShortOutput.setAgenciesName("未分配");
}
}
return list;
}
@@ -686,10 +711,17 @@ public class DeviceServiceImpl implements IDeviceService {
// 设置图片
Product product = productService.selectProductByProductId(device.getProductId());
device.setImgUrl(product.getImgUrl());
// 随机经纬度和地址
SysUser user = getLoginUser().getUser();
device.setNetworkIp(user.getLoginIp());
// 连接MQTTX todo
setLocation(user.getLoginIp(), device);
deviceMapper.insertDevice(device);
// redis缓存设备默认状态物模型值
@@ -855,6 +887,7 @@ public class DeviceServiceImpl implements IDeviceService {
}
/**
* 修改设备
*
@@ -888,6 +921,7 @@ public class DeviceServiceImpl implements IDeviceService {
device.setProductName(null);
}
deviceMapper.updateDevice(device);
return AjaxResult.success("修改成功", 1);
}

View File

@@ -35,6 +35,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="slaveId" column="slave_id"/>
<result property="transport" column="transport"/>
<result property="guid" column="guid"/>
<result property="groupId" column="group_id"/>
<result property="agenciesId" column="agencies_id"/>
</resultMap>
<resultMap type="com.xinda.iot.model.DeviceShortOutput" id="DeviceShortResult">
@@ -63,6 +65,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="protocolCode" column="protocol_code"/>
<result property="transport" column="transport"/>
<result property="guid" column="guid"/>
<result property="groupId" column="group_id"/>
<result property="agenciesId" column="agencies_id"/>
</resultMap>
<resultMap type="com.xinda.iot.model.DeviceAllShortOutput" id="DeviceAllShortResult">
@@ -160,30 +164,94 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="tenantId" column="tenant_id"/>
</resultMap>
<sql id="selectDeviceVo">
select device_id, device_name, product_id, product_name, tenant_id, tenant_name, serial_number,gw_dev_code, firmware_version, status, rssi,is_shadow ,is_simulate,location_way,things_model_value,network_address, network_ip, longitude, latitude, active_time, create_time, update_time, img_url,summary,remark,slave_id from iot_device
select device_id,
device_name,
product_id,
product_name,
tenant_id,
tenant_name,
serial_number,
gw_dev_code,
firmware_version,
status,
rssi,
is_shadow,
is_simulate,
location_way,
things_model_value,
network_address,
network_ip,
longitude,
latitude,
active_time,
create_time,
update_time,
img_url,
summary,
remark,
slave_id,group_id,agencies_id
from iot_device
</sql>
<sql id="selectDeviceShortVo">
select device_id, device_name, product_id, product_name, tenant_id, tenant_name, serial_number, firmware_version, status,rssi,is_shadow ,is_simulate,location_way,things_model_value, active_time,img_url,slave_id from iot_device
select device_id,
device_name,
product_id,
product_name,
tenant_id,
tenant_name,
serial_number,
firmware_version,
status,
rssi,
is_shadow,
is_simulate,
location_way,
things_model_value,
active_time,
img_url,
slave_id,group_id,agencies_id
from iot_device
</sql>
<sql id="selectWebhookDeviceVo">
select device_id, device_name,product_id, serial_number,tenant_id, tenant_name, status,is_shadow,is_simulate, rssi ,location_way,things_model_value, active_time from iot_device
select device_id,
device_name,
product_id,
serial_number,
tenant_id,
tenant_name,
status,
is_shadow,
is_simulate,
rssi,
location_way,
things_model_value,
active_time,group_id,agencies_id
from iot_device
</sql>
<select id="selectDeviceList" parameterType="com.xinda.iot.domain.Device" resultMap="DeviceResult">
<include refid="selectDeviceVo"/>
<where>
<if test="gwDevCode != null and gwDevCode != ''">and gw_dev_code = #{gwDevCode}</if>
<if test="deviceName != null and deviceName != ''"> and device_name like concat('%', #{deviceName}, '%')</if>
<if test="deviceName != null and deviceName != ''">and device_name like concat('%', #{deviceName}, '%')
</if>
<if test="productId != null ">and product_id = #{productId}</if>
<if test="productName != null and productName != ''"> and product_name like concat('%', #{productName}, '%')</if>
<if test="productName != null and productName != ''">and product_name like concat('%', #{productName},
'%')
</if>
<if test="tenantId != null ">and tenant_id = #{tenantId}</if>
<if test="tenantName != null and tenantName != ''"> and tenant_name like concat('%', #{tenantName}, '%')</if>
<if test="tenantName != null and tenantName != ''">and tenant_name like concat('%', #{tenantName}, '%')
</if>
<if test="serialNumber != null and serialNumber != ''">and serial_number = #{serialNumber}</if>
<if test="status != null ">and status = #{status}</if>
<if test="networkAddress != null and networkAddress != ''"> and network_address like concat('%', #{networkAddress}, '%')</if>
<if test="networkAddress != null and networkAddress != ''">and network_address like concat('%',
#{networkAddress}, '%')
</if>
<if test="deptId != null and deptId != 0 and showChild != null and showChild">
and tenant_id in (SELECT u.user_id FROM sys_user u
join sys_dept de on u.dept_id = de.dept_id
@@ -192,23 +260,30 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="deptId != null and deptId != 0 and showChild != null and !showChild">
and tenant_id = (SELECT dept_user_id FROM sys_dept WHERE dept_id = #{deptId})
</if>
<if test="params.beginActiveTime != null and params.beginActiveTime != '' and params.endActiveTime != null and params.endActiveTime != ''"> and active_time between #{params.beginActiveTime} and #{params.endActiveTime}</if>
<if test="params.beginActiveTime != null and params.beginActiveTime != '' and params.endActiveTime != null and params.endActiveTime != ''">
and active_time between #{params.beginActiveTime} and #{params.endActiveTime}
</if>
</where>
order by create_time desc
</select>
<select id="selectUnAuthDeviceList" parameterType="com.xinda.iot.domain.Device" resultMap="DeviceResult">
select d.device_id, d.device_name, d.product_id, d.product_name, d.tenant_id, d.tenant_name,
d.serial_number,d.gw_dev_code, d.firmware_version, d.status,d.is_shadow,d.is_simulate ,d.location_way,d.active_time, d.img_url,a.device_id as auth_device_id
d.serial_number,d.gw_dev_code, d.firmware_version, d.status,d.is_shadow,d.is_simulate
,d.location_way,d.active_time, d.img_url,a.device_id as auth_device_id
from iot_device d
left join iot_product_authorize a on a.device_id=d.device_id
<where>
<if test="1==1">and ISNULL(a.device_id)</if>
<if test="deviceName != null and deviceName != ''"> and d.device_name like concat('%', #{deviceName}, '%')</if>
<if test="deviceName != null and deviceName != ''">and d.device_name like concat('%', #{deviceName}, '%')
</if>
<if test="productId != null ">and d.product_id = #{productId}</if>
<if test="productName != null and productName != ''"> and d.product_name like concat('%', #{productName}, '%')</if>
<if test="productName != null and productName != ''">and d.product_name like concat('%', #{productName},
'%')
</if>
<if test="tenantId != null ">and d.tenant_id = #{tenantId}</if>
<if test="tenantName != null and tenantName != ''"> and d.tenant_name like concat('%', #{tenantName}, '%')</if>
<if test="tenantName != null and tenantName != ''">and d.tenant_name like concat('%', #{tenantName}, '%')
</if>
<if test="serialNumber != null and serialNumber != ''">and d.serial_number = #{serialNumber}</if>
<if test="gwDevCode != null and gwDevCode != ''">and d.gw_dev_code = #{gwDevCode,jdbcType=VARCHAR}</if>
<if test="status != null ">and d.status = #{status}</if>
@@ -220,24 +295,34 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="deptId != null and deptId != 0 and showChild != null and !showChild">
and d.tenant_id = (SELECT dept_user_id FROM sys_dept WHERE dept_id = #{deptId})
</if>
<if test="params.beginActiveTime != null and params.beginActiveTime != '' and params.endActiveTime != null and params.endActiveTime != ''"> and d.active_time between #{params.beginActiveTime} and #{params.endActiveTime}</if>
<if test="params.beginActiveTime != null and params.beginActiveTime != '' and params.endActiveTime != null and params.endActiveTime != ''">
and d.active_time between #{params.beginActiveTime} and #{params.endActiveTime}
</if>
</where>
order by d.create_time desc
</select>
<select id="selectDeviceListByGroup" parameterType="com.xinda.iot.domain.Device" resultMap="DeviceResult">
select d.device_id, d.device_name, d.product_name, d.serial_number,d.gw_dev_code, d.firmware_version, d.status,d.rssi,d.is_shadow ,
select d.device_id, d.device_name, d.product_name, d.serial_number,d.gw_dev_code, d.firmware_version,
d.status,d.rssi,d.is_shadow ,
d.location_way, d.active_time,d.network_address,d.longitude,d.latitude
from iot_device d
<where>
<if test="productId != null ">and d.product_id = #{productId}</if>
<if test="deviceName != null and deviceName != ''"> and d.device_name like concat('%', #{deviceName}, '%')</if>
<if test="productName != null and productName != ''"> and d.product_name like concat('%', #{productName}, '%')</if>
<if test="deviceName != null and deviceName != ''">and d.device_name like concat('%', #{deviceName}, '%')
</if>
<if test="productName != null and productName != ''">and d.product_name like concat('%', #{productName},
'%')
</if>
<if test="serialNumber != null and serialNumber != ''">and d.serial_number = #{serialNumber}</if>
<if test="gwDevCode != null and gwDevCode != ''">and d.gw_dev_code = #{gwDevCode}</if>
<if test="status != null ">and d.status = #{status}</if>
<if test="networkAddress != null and networkAddress != ''"> and d.network_address like concat('%', #{networkAddress}, '%')</if>
<if test="params.beginActiveTime != null and params.beginActiveTime != '' and params.endActiveTime != null and params.endActiveTime != ''"> and d.active_time between #{params.beginActiveTime} and #{params.endActiveTime}</if>
<if test="networkAddress != null and networkAddress != ''">and d.network_address like concat('%',
#{networkAddress}, '%')
</if>
<if test="params.beginActiveTime != null and params.beginActiveTime != '' and params.endActiveTime != null and params.endActiveTime != ''">
and d.active_time between #{params.beginActiveTime} and #{params.endActiveTime}
</if>
<if test="deptId != null and deptId != 0 and showChild != null and showChild">
and d.tenant_id in (SELECT u.user_id FROM sys_user u
join sys_dept de on u.dept_id = de.dept_id
@@ -253,11 +338,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select>
<select id="selectAllDeviceShortList" parameterType="com.xinda.iot.domain.Device" resultMap="DeviceAllShortResult">
select d.device_id, d.device_name, d.product_name,p.device_type, d.tenant_name, d.serial_number,d.gw_dev_code, d.firmware_version, d.status,d.rssi,d.is_shadow ,
select d.device_id, d.device_name, d.product_name,p.device_type, d.tenant_name, d.serial_number,d.gw_dev_code,
d.firmware_version, d.status,d.rssi,d.is_shadow ,
d.location_way, d.active_time,d.network_address,d.longitude,d.latitude
from iot_device d
left join iot_product p on p.product_id=d.product_id
<where>
and del_flag = '0'
<if test="productId != null ">and d.product_id = #{productId}</if>
<if test="deptId != null and deptId != 0 and showChild != null and showChild">
and d.tenant_id in (SELECT u.user_id FROM sys_user u
@@ -272,46 +359,75 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select>
<select id="selectSerialNumberByProductId" parameterType="Long" resultType="String">
select serial_number from iot_device where product_id = #{productId}
select serial_number
from iot_device
where product_id = #{productId} and del_flag = '0'
</select>
<select id="selectDeviceCountByProductId" parameterType="Long" resultType="Integer">
select count(device_id) from iot_device where product_id = #{productId}
select count(device_id)
from iot_device
where product_id = #{productId} and del_flag = '0'
</select>
<select id="selectDeviceThingsModelValueBySerialNumber" parameterType="String" resultMap="DeviceThingsValueResult">
select product_id,product_name,device_id,device_name,serial_number,gw_dev_code,is_shadow,is_simulate,status,tenant_id, tenant_name,things_model_value from iot_device where serial_number = #{serialNumber}
select product_id,
product_name,
device_id,
device_name,
serial_number,
gw_dev_code,
is_shadow,
is_simulate,
status,
tenant_id,
tenant_name,
things_model_value
from iot_device
where serial_number = #{serialNumber} and del_flag = '0'
</select>
<update id="updateDeviceThingsModelValue" parameterType="com.xinda.common.core.thingsModel.ThingsModelValuesInput">
update iot_device set things_model_value=#{stringValue} where device_id = #{deviceId}
update iot_device
set things_model_value=#{stringValue}
where device_id = #{deviceId}
</update>
<select id="selectDeviceShortList" parameterType="com.xinda.iot.domain.Device" resultMap="DeviceShortResult">
select d.device_id, d.device_name, p.product_id, p.product_name,p.device_type,
d.tenant_id, d.tenant_name, d.serial_number,d.gw_dev_code,
d.firmware_version, d.status,d.rssi,d.is_shadow,d.is_simulate ,d.location_way,
d.things_model_value, d.active_time,d.create_time, if(null = d.img_url or '' = d.img_url, p.img_url, d.img_url) as img_url,
d.things_model_value, d.active_time,d.create_time, if(null = d.img_url or '' = d.img_url, p.img_url, d.img_url)
as img_url,
case
when (select count(*) from iot_device_share du where du.device_id = d.device_id and du.user_id = #{tenantId}) then 0
when (select count(*) from iot_device_share du where du.device_id = d.device_id and du.user_id = #{tenantId})
then 0
else 1
end as is_owner,
(select count(*) from iot_device d1 where d1.gw_dev_code = d.serial_number) as sub_device_count,
p.protocol_code,p.transport,p.guid
p.protocol_code,p.transport,p.guid,
d.group_id,d.agencies_id
from iot_device d
left join iot_product p on p.product_id=d.product_id
<if test="groupId != null and groupId !=0 ">left join iot_device_group g on g.device_id=d.device_id</if>
<where>
and d.gw_dev_code is null
<if test="groupId != null and groupId !=0 "> and g.group_id = #{groupId}</if>
<if test="deviceName != null and deviceName != ''"> and d.device_name like concat('%', #{deviceName}, '%')</if>
and d.gw_dev_code is null and d.del_flag = '0'
<if test="groupId != null and groupId !=0 ">and d.group_id = #{groupId}</if>
<if test="deviceName != null and deviceName != ''">and d.device_name like concat('%', #{deviceName}, '%')
</if>
<if test="productId != null ">and d.product_id = #{productId}</if>
<if test="deviceType != null ">and p.device_type = #{deviceType}</if>
<if test="productName != null and productName != ''"> and d.product_name like concat('%', #{productName}, '%')</if>
<if test="productName != null and productName != ''">and d.product_name like concat('%', #{productName},
'%')
</if>
<if test="serialNumber != null and serialNumber != ''">and d.serial_number = #{serialNumber}</if>
<if test="gwDevCode != null and gwDevCode != ''">and d.gw_dev_code = #{gwDevCode}</if>
<if test="status != null ">and d.status = #{status}</if>
<if test="isSimulate != null">and d.is_simulate = #{isSimulate}</if>
<if test="groupIdExclude != null">and d.group_id != #{groupIdExclude}</if>
<if test="deptId != null and deptId != 0 and showChild != null and showChild">
and
( d.tenant_id in (SELECT u.user_id FROM sys_user u
@@ -326,17 +442,45 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
or d.device_id in (select du.device_id from iot_device_share du where du.user_id = #{tenantId})
)
</if>
<if test="params.beginActiveTime != null and params.beginActiveTime != '' and params.endActiveTime != null and params.endActiveTime != ''"> and d.active_time between #{params.beginActiveTime} and #{params.endActiveTime}</if>
<if test="params.beginActiveTime != null and params.beginActiveTime != '' and params.endActiveTime != null and params.endActiveTime != ''">
and d.active_time between #{params.beginActiveTime} and #{params.endActiveTime}
</if>
</where>
group by d.device_id,d.tenant_id
order by d.create_time desc
</select>
<select id="selectDeviceByDeviceId" parameterType="Long" resultMap="DeviceResult">
select d.device_id, d.device_name, d.product_id, p.product_name,p.device_type, d.tenant_id, d.tenant_name,
d.serial_number, d.firmware_version, d.status, d.rssi,d.is_shadow,d.is_simulate ,d.location_way,d.things_model_value,
d.network_address, d.network_ip, d.longitude, d.latitude, d.active_time, d.create_time, d.update_time,
d.img_url,d.summary,d.remark,p.guid from iot_device d
select d.device_id,
d.device_name,
d.product_id,
p.product_name,
p.device_type,
d.tenant_id,
d.tenant_name,
d.serial_number,
d.firmware_version,
d.status,
d.rssi,
d.is_shadow,
d.is_simulate,
d.location_way,
d.things_model_value,
d.network_address,
d.network_ip,
d.longitude,
d.latitude,
d.active_time,
d.create_time,
d.update_time,
d.img_url,
d.summary,
d.remark,
p.guid,
d.group_id,
d.agencies_id
from iot_device d
left join iot_product p on p.product_id = d.product_id
where device_id = #{deviceId}
</select>
@@ -347,7 +491,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select>
<select id="selectDeviceCountBySerialNumber" parameterType="String" resultType="int">
select count(device_id) from iot_device
select count(device_id)
from iot_device
where serial_number = #{serialNumber}
</select>
@@ -448,14 +593,25 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
) as alertCount
</select>
<select id="selectProductAuthenticate" parameterType="com.xinda.iot.model.AuthenticateInputModel" resultMap="DeviceAuthenticateResult">
SELECT p.mqtt_password,p.mqtt_account, p.mqtt_secret,p.is_authorize,p.product_id,p.product_name,p.vertificate_method,p.STATUS as product_status,d.device_id,d.device_name,d.STATUS,d.serial_number
<select id="selectProductAuthenticate" parameterType="com.xinda.iot.model.AuthenticateInputModel"
resultMap="DeviceAuthenticateResult">
SELECT p.mqtt_password,
p.mqtt_account,
p.mqtt_secret,
p.is_authorize,
p.product_id,
p.product_name,
p.vertificate_method,
p.STATUS as product_status,
d.device_id,
d.device_name,
d.STATUS,
d.serial_number
FROM iot_product p
LEFT JOIN (SELECT device_id, device_name, STATUS, product_id, product_name, serial_number
FROM iot_device
WHERE serial_number = #{serialNumber}) AS d ON d.product_id = p.product_id
WHERE
p.product_id = #{productId}
WHERE p.product_id = #{productId}
</select>
<select id="selectShortDeviceBySerialNumber" parameterType="String" resultMap="DeviceResult">
@@ -468,7 +624,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where device_id = #{deviceId}
</select>
<insert id="insertDevice" parameterType="com.xinda.iot.domain.Device" useGeneratedKeys="true" keyProperty="deviceId">
<insert id="insertDevice" parameterType="com.xinda.iot.domain.Device" useGeneratedKeys="true"
keyProperty="deviceId">
insert into iot_device
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="deviceName != null and deviceName != ''">device_name,</if>
@@ -499,6 +656,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="gwDevCode != null">gw_dev_code,</if>
<if test="isSimulate != null">is_simulate,</if>
<if test="slaveId != null">slave_id,</if>
<if test="groupId != null">group_id,</if>
<if test="agenciesId != null">agencies_id,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="deviceName != null and deviceName != ''">#{deviceName},</if>
@@ -529,11 +688,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="gwDevCode != null">#{gwDevCode},</if>
<if test="isSimulate != null">#{isSimulate},</if>
<if test="slaveId != null">#{slaveId},</if>
<if test="groupId != null">#{groupId},</if>
<if test="agenciesId != null">#{agenciesId},</if>
</trim>
</insert>
<insert id="insertBatchDevice" parameterType="com.xinda.iot.domain.Device" useGeneratedKeys="true" keyProperty="deviceId">
insert into iot_device (device_name, product_id, product_name, tenant_id, tenant_name, serial_number, firmware_version, rssi, is_shadow, location_way, create_by, create_time)
<insert id="insertBatchDevice" parameterType="com.xinda.iot.domain.Device" useGeneratedKeys="true"
keyProperty="deviceId">
insert into iot_device (device_name, product_id, product_name, tenant_id, tenant_name, serial_number,
firmware_version, rssi, is_shadow, location_way, create_by, create_time)
values
<foreach collection="deviceList" item="device" separator=",">
(#{device.deviceName},
@@ -582,6 +745,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="imgUrl != null">img_url = #{imgUrl},</if>
<if test="summary != null">summary = #{summary},</if>
<if test="slaveId != null">slave_id = #{slaveId},</if>
<if test="groupId != null">group_id = #{groupId},</if>
<if test="agenciesId != null">agencies_id = #{agenciesId},</if>
</trim>
where device_id = #{deviceId}
</update>
@@ -595,7 +760,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="longitude != null">longitude = #{longitude},</if>
<if test="latitude != null">latitude = #{latitude},</if>
<if test="activeTime != null">active_time = #{activeTime},</if>
<if test="delFlag != null">del_flag = #{delFlag},</if>
<if test="updateTime !=null">update_time = #{updateTime,jdbcType=TIMESTAMP}</if>
</trim>
where serial_number = #{serialNumber} or gw_dev_code = #{serialNumber}
</update>
@@ -608,8 +775,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<update id="resetDeviceStatus" parameterType="String">
-- 设备状态1-未激活2-禁用3-在线4-离线)
update iot_device set status=4
where serial_number = #{serialNumber} and status = 3
update iot_device
set status=4
where serial_number = #{serialNumber}
and status = 3
</update>
<update id="updateDeviceBySerialNumber" parameterType="com.xinda.iot.domain.Device">
@@ -642,12 +811,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="imgUrl != null">img_url = #{imgUrl},</if>
<if test="summary != null">summary = #{summary},</if>
<if test="gwDevCode != null">gw_dev_code = #{gwDevCode},</if>
<if test="slaveId != null">slave_id = #{slaveId},</if>
<if test="groupId != null">group_id = #{groupId},</if>
<if test="agenciesId != null">agencies_id = #{agenciesId},</if>
</trim>
where serial_number = #{serialNumber}
</update>
<delete id="deleteDeviceByDeviceId" parameterType="Long">
delete from iot_device where device_id = #{deviceId}
delete
from iot_device
where device_id = #{deviceId}
</delete>
<delete id="deleteDeviceByDeviceIds" parameterType="String">
@@ -658,7 +832,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</delete>
<select id="getDeviceNumCount" parameterType="String" resultType="int">
select count(*) from iot_device where serial_number = #{deviceNum}
select count(*)
from iot_device
where serial_number = #{deviceNum}
</select>
<delete id="deleteDeviceGroupByDeviceId" parameterType="com.xinda.iot.model.UserIdDeviceIdModel">
@@ -742,7 +918,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
p.mqtt_secret,
p.vertificate_method,
p.is_authorize
from iot_device d inner join iot_product p on d.product_id = p.product_id
from iot_device d
inner join iot_product p on d.product_id = p.product_id
where d.device_id = #{deviceId}
and d.del_flag = 0
and p.del_flag = 0
@@ -756,15 +933,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{deviceNumber}
</foreach>
</select>
<select id="selectRelateAlertLogBySerialNumber" parameterType="java.lang.String" resultMap="DeviceRelateAlertLogVOResult">
<select id="selectRelateAlertLogBySerialNumber" parameterType="java.lang.String"
resultMap="DeviceRelateAlertLogVOResult">
select device_id, serial_number, device_name
from iot_device
where serial_number = #{deviceNumber}
</select>
<select id="getDeviceNumsByProductId" parameterType="Long" resultType="String">
select serial_number from iot_device
where product_id = #{productId} and gw_dev_code is NULL
select serial_number
from iot_device
where product_id = #{productId}
and gw_dev_code is NULL
</select>
<select id="selectDeviceStatusByNumbers" parameterType="String" resultMap="DeviceStatusResult">
@@ -808,20 +988,24 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<where>
and d.gw_dev_code is null
<if test="groupId != null and groupId !=0 ">and g.group_id = #{groupId}</if>
<if test="deviceName != null and deviceName != ''"> and d.device_name like concat('%', #{deviceName}, '%')</if>
<if test="deviceName != null and deviceName != ''">and d.device_name like concat('%', #{deviceName}, '%')
</if>
<if test="productId != null ">and d.product_id = #{productId}</if>
<if test="deviceType != null ">and p.device_type = #{deviceType}</if>
<if test="productName != null and productName != ''"> and d.product_name like concat('%', #{productName}, '%')</if>
<if test="productName != null and productName != ''">and d.product_name like concat('%', #{productName},
'%')
</if>
<if test="serialNumber != null and serialNumber != ''">and d.serial_number = #{serialNumber}</if>
<if test="gwDevCode != null and gwDevCode != ''">and d.gw_dev_code = #{gwDevCode}</if>
<if test="status != null ">and d.status = #{status}</if>
<if test="isSimulate != null">and d.is_simulate = #{isSimulate}</if>
<if test="params.beginActiveTime != null and params.beginActiveTime != '' and params.endActiveTime != null and params.endActiveTime != ''"> and d.active_time between #{params.beginActiveTime} and #{params.endActiveTime}</if>
<if test="params.beginActiveTime != null and params.beginActiveTime != '' and params.endActiveTime != null and params.endActiveTime != ''">
and d.active_time between #{params.beginActiveTime} and #{params.endActiveTime}
</if>
</where>
order by u.is_owner desc, d.create_time desc
<!-- select d.device_id, d.device_name, d.product_id, d.product_name,p.device_type,-->
<!-- d.tenant_id, d.tenant_name, d.serial_number,d.gw_dev_code,-->
<!-- d.firmware_version, d.status,d.rssi,d.is_shadow,d.is_simulate ,d.location_way,-->
@@ -856,7 +1040,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select>
<select id="listTerminalUserByGroup" resultType="com.xinda.iot.domain.Device">
select d.device_id, d.device_name, d.product_name, d.serial_number,d.gw_dev_code, d.firmware_version, d.status,d.rssi,d.is_shadow ,
select d.device_id, d.device_name, d.product_name, d.serial_number,d.gw_dev_code, d.firmware_version,
d.status,d.rssi,d.is_shadow ,
d.location_way, d.active_time,d.network_address,d.longitude,d.latitude
from (
select device_id, 1 AS is_owner
@@ -871,19 +1056,24 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
inner join iot_product p on d.product_id = p.product_id
<where>
and d.gw_dev_code is null
<if test="deviceName != null and deviceName != ''"> and d.device_name like concat('%', #{deviceName}, '%')</if>
<if test="deviceName != null and deviceName != ''">and d.device_name like concat('%', #{deviceName}, '%')
</if>
</where>
order by u.is_owner desc, d.create_time desc
</select>
<update id="reSetDeviceStatus">
update iot_device set status = 4 where status = 3
update iot_device
set status = 4
where status = 3
</update>
<select id="selectDeviceActive" resultType="com.xinda.iot.model.DeviceStatusVO">
select d.status, d.serial_number as serialNumber
from iot_device d inner join iot_product p on d.product_id = p.product_id
where d.status in (3,4) and p.transport not in ('GB28181')
from iot_device d
inner join iot_product p on d.product_id = p.product_id
where d.status in (3, 4)
and p.transport not in ('GB28181')
</select>
<select id="countByTenantId" resultType="java.lang.Integer">
@@ -913,19 +1103,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</update>
<select id="selectDeviceByChannelId" resultMap="DeviceResult">
select device_name,device_id from iot_device
select device_name, device_id
from iot_device
where channel_id = #{channelId}
</select>
<select id="selectDeviceStatusAndTransportStatus" resultType="com.xinda.iot.model.DeviceStatusVO">
SELECT
d.status,
SELECT d.status,
d.serial_number,
p.transport,
p.product_id,
p.device_type
FROM
iot_device d inner join iot_product p on d.product_id = p.product_id
FROM iot_device d
inner join iot_product p on d.product_id = p.product_id
WHERE d.serial_number = #{serialNumber,jdbcType=VARCHAR}
</select>
@@ -941,5 +1131,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</if>
</where>
</select>
<!-- 删除没有 离线并且 没有分配项目 设备-->
<update id="deleteDeviceBygroupId">
update iot_device
set del_flag = '2'
where status = 4
and group_id = '0'
</update>
</mapper>

View File

@@ -24,6 +24,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="createdAt != null "> and created_at = #{createdAt}</if>
<if test="remarks != null and remarks != ''"> and remarks = #{remarks}</if>
</where>
order by display_order asc
</select>
<select id="selectDeviceModelById" parameterType="Long" resultMap="DeviceModelResult">

View File

@@ -133,4 +133,5 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</where>
order by group_order
</select>
</mapper>

View File

@@ -71,6 +71,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
and p.tenant_id = #{tenantId}
</if>
<if test="productName != null and productName != ''"> and p.product_name like concat('%', #{productName}, '%')</if>
<if test="productNameExclude != null and productNameExclude != ''"> and p.product_name != #{productNameExclude}</if>
<if test="categoryName != null and categoryName != ''"> and p.category_name like concat('%', #{categoryName}, '%')</if>
<if test="status != null "> and p.status = #{status}</if>
<if test="deviceType != null "> and device_type = #{deviceType}</if>