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 mqttAccount;
private String password; private String password;
} }

View File

@@ -73,6 +73,8 @@ public class DeviceStatusConsumer {
device.setStatus(1); device.setStatus(1);
device.setTenantId(1L); device.setTenantId(1L);
device.setTenantName("admin"); device.setTenantName("admin");
device.setGroupId(0L);
deviceService.insertDeviceTest(device); deviceService.insertDeviceTest(device);
device = deviceService.selectDeviceBySerialNumber(bo.getSerialNumber()); device = deviceService.selectDeviceBySerialNumber(bo.getSerialNumber());
} }
@@ -84,12 +86,22 @@ public class DeviceStatusConsumer {
if (containsKey && !isOnline) { if (containsKey && !isOnline) {
//如果session存在但数据库状态不在线则以session为准 //如果session存在但数据库状态不在线则以session为准
bo.setStatus(DeviceStatus.ONLINE); bo.setStatus(DeviceStatus.ONLINE);
device.setDelFlag("0");
} }
if (!containsKey && isOnline) { if (!containsKey && isOnline) {
bo.setStatus(DeviceStatus.OFFLINE); bo.setStatus(DeviceStatus.OFFLINE);
// 判断下 项目id
if (device.getGroupId().equals(0L) || device.getGroupId() == null) {
//设置删除状态 todo
device.setDelFlag("2");
}
} }
} }
/*更新设备状态*/ /*更新设备状态*/
deviceCache.updateDeviceStatusCache(bo, device); deviceCache.updateDeviceStatusCache(bo, device);
//处理影子模式值 //处理影子模式值
this.handlerShadow(device, bo.getStatus()); 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.controller.BaseController;
import com.xinda.common.core.domain.AjaxResult; 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.core.page.TableDataInfo;
import com.xinda.common.utils.poi.ExcelUtil; import com.xinda.common.utils.poi.ExcelUtil;
import com.xinda.iot.domain.DeviceModel; import com.xinda.iot.domain.DeviceModel;
@@ -25,19 +26,30 @@ import java.util.List;
@RestController @RestController
@RequestMapping("/iot/deviceModel") @RequestMapping("/iot/deviceModel")
@Api(tags = "产品型号") @Api(tags = "产品型号")
public class DeviceModelController extends BaseController public class DeviceModelController extends BaseController {
{
@Autowired @Autowired
private IDeviceModelService deviceModelService; private IDeviceModelService deviceModelService;
/**
* 查询产品型号列表 /**
*/ * 查询全部产品下拉框
@PreAuthorize("@ss.hasPermi('iot:model:list')") * @return
@GetMapping("/list") */
@ApiOperation("查询产品型号列表") @GetMapping("/getAllModel")
public TableDataInfo list(DeviceModel deviceModel) public R getAllModel()
{ {
return R.ok(deviceModelService.selectDeviceModelList(new DeviceModel()));
}
/**
* 查询产品型号列表
*/
@PreAuthorize("@ss.hasPermi('iot:model:list')")
@GetMapping("/list")
@ApiOperation("查询产品型号列表")
public TableDataInfo list(DeviceModel deviceModel) {
startPage(); startPage();
List<DeviceModel> list = deviceModelService.selectDeviceModelList(deviceModel); List<DeviceModel> list = deviceModelService.selectDeviceModelList(deviceModel);
return getDataTable(list); return getDataTable(list);
@@ -49,8 +61,7 @@ public class DeviceModelController extends BaseController
@ApiOperation("导出产品型号列表") @ApiOperation("导出产品型号列表")
@PreAuthorize("@ss.hasPermi('iot:model:export')") @PreAuthorize("@ss.hasPermi('iot:model:export')")
@PostMapping("/export") @PostMapping("/export")
public void export(HttpServletResponse response, DeviceModel deviceModel) public void export(HttpServletResponse response, DeviceModel deviceModel) {
{
List<DeviceModel> list = deviceModelService.selectDeviceModelList(deviceModel); List<DeviceModel> list = deviceModelService.selectDeviceModelList(deviceModel);
ExcelUtil<DeviceModel> util = new ExcelUtil<DeviceModel>(DeviceModel.class); ExcelUtil<DeviceModel> util = new ExcelUtil<DeviceModel>(DeviceModel.class);
util.exportExcel(response, list, "产品型号数据"); util.exportExcel(response, list, "产品型号数据");
@@ -62,8 +73,7 @@ public class DeviceModelController extends BaseController
@PreAuthorize("@ss.hasPermi('iot:model:query')") @PreAuthorize("@ss.hasPermi('iot:model:query')")
@GetMapping(value = "/{id}") @GetMapping(value = "/{id}")
@ApiOperation("获取产品型号详细信息") @ApiOperation("获取产品型号详细信息")
public AjaxResult getInfo(@PathVariable("id") Long id) public AjaxResult getInfo(@PathVariable("id") Long id) {
{
return success(deviceModelService.selectDeviceModelById(id)); return success(deviceModelService.selectDeviceModelById(id));
} }
@@ -73,8 +83,7 @@ public class DeviceModelController extends BaseController
@PreAuthorize("@ss.hasPermi('iot:model:add')") @PreAuthorize("@ss.hasPermi('iot:model:add')")
@PostMapping @PostMapping
@ApiOperation("新增产品型号") @ApiOperation("新增产品型号")
public AjaxResult add(@RequestBody DeviceModel deviceModel) public AjaxResult add(@RequestBody DeviceModel deviceModel) {
{
deviceModel.setCreateTime(new Date()); deviceModel.setCreateTime(new Date());
return toAjax(deviceModelService.insertDeviceModel(deviceModel)); return toAjax(deviceModelService.insertDeviceModel(deviceModel));
} }
@@ -85,8 +94,7 @@ public class DeviceModelController extends BaseController
@PreAuthorize("@ss.hasPermi('iot:model:edit')") @PreAuthorize("@ss.hasPermi('iot:model:edit')")
@PutMapping @PutMapping
@ApiOperation("修改产品型号") @ApiOperation("修改产品型号")
public AjaxResult edit(@RequestBody DeviceModel deviceModel) public AjaxResult edit(@RequestBody DeviceModel deviceModel) {
{
return toAjax(deviceModelService.updateDeviceModel(deviceModel)); return toAjax(deviceModelService.updateDeviceModel(deviceModel));
} }
@@ -96,8 +104,7 @@ public class DeviceModelController extends BaseController
@PreAuthorize("@ss.hasPermi('iot:model:remove')") @PreAuthorize("@ss.hasPermi('iot:model:remove')")
@DeleteMapping("/{ids}") @DeleteMapping("/{ids}")
@ApiOperation("删除产品型号") @ApiOperation("删除产品型号")
public AjaxResult remove(@PathVariable Long[] ids) public AjaxResult remove(@PathVariable Long[] ids) {
{
return toAjax(deviceModelService.deleteDeviceModelByIds(ids)); return toAjax(deviceModelService.deleteDeviceModelByIds(ids));
} }
} }

View File

@@ -4,6 +4,7 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import com.xinda.common.core.domain.R;
import com.xinda.iot.domain.DeviceGroup; import com.xinda.iot.domain.DeviceGroup;
import com.xinda.iot.model.DeviceGroupInput; import com.xinda.iot.model.DeviceGroupInput;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
@@ -41,6 +42,16 @@ public class GroupController extends BaseController
@Autowired @Autowired
private IGroupService groupService; 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 @Override
public void handler(ChannelHandlerContext ctx, MqttMessage message) { public void handler(ChannelHandlerContext ctx, MqttMessage message) {
JSONObject jsonObject = JSON.parseObject((String) message.payload());
System.out.println(jsonObject);
// 查看消息
MqttPublishMessage publishMessage = (MqttPublishMessage) message; MqttPublishMessage publishMessage = (MqttPublishMessage) message;
/*获取客户端id*/ /*获取客户端id*/
String clientId = AttributeUtils.getClientId(ctx.channel()); String clientId = AttributeUtils.getClientId(ctx.channel());
String topicName = publishMessage.variableHeader().topicName(); String topicName = publishMessage.variableHeader().topicName();
log.debug("=>***客户端[{}],主题[{}],推送消息[{}]", clientId, topicName, log.debug("=>***客户端[{}],主题[{}],推送消息[{}]", clientId, topicName,
ByteBufUtil.hexDump(publishMessage.content())); ByteBufUtil.hexDump(publishMessage.content()));
// 以get结尾是模拟客户端数据,只转发消息 // 以get结尾是模拟客户端数据,只转发消息
if (topicName.endsWith(XinDaConstant.MQTT.PROPERTY_GET_SIMULATE)) { if (topicName.endsWith(XinDaConstant.MQTT.PROPERTY_GET_SIMULATE)) {
sendTestToMQ(publishMessage); 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 session = AttributeUtils.getSession(ctx.channel()); Session session = AttributeUtils.getSession(ctx.channel());
//平台检测session是否同步 //平台检测session是否同步

View File

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

View File

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

View File

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

View File

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

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="createdAt != null "> and created_at = #{createdAt}</if>
<if test="remarks != null and remarks != ''"> and remarks = #{remarks}</if> <if test="remarks != null and remarks != ''"> and remarks = #{remarks}</if>
</where> </where>
order by display_order asc
</select> </select>
<select id="selectDeviceModelById" parameterType="Long" resultMap="DeviceModelResult"> <select id="selectDeviceModelById" parameterType="Long" resultMap="DeviceModelResult">

View File

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

View File

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