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

@@ -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,158 +293,155 @@ 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)
.append("productId", getProductId())
.append("productName", getProductName())
.append("categoryId", getCategoryId())
.append("categoryName", getCategoryName())
.append("tenantId", getTenantId())
.append("tenantName", getTenantName())
.append("isSys", getIsSys())
.append("isAuthorize", getIsAuthorize())
.append("status", getStatus())
.append("deviceType", getDeviceType())
.append("networkMethod", getNetworkMethod())
.append("vertificateMethod", getVertificateMethod())
.append("delFlag", getDelFlag())
.append("createBy", getCreateBy())
.append("createTime", getCreateTime())
.append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime())
.append("remark", getRemark())
.toString();
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
.append("productId", getProductId())
.append("productName", getProductName())
.append("categoryId", getCategoryId())
.append("categoryName", getCategoryName())
.append("tenantId", getTenantId())
.append("tenantName", getTenantName())
.append("isSys", getIsSys())
.append("isAuthorize", getIsAuthorize())
.append("status", getStatus())
.append("deviceType", getDeviceType())
.append("networkMethod", getNetworkMethod())
.append("vertificateMethod", getVertificateMethod())
.append("delFlag", getDelFlag())
.append("createBy", getCreateBy())
.append("createTime", getCreateTime())
.append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime())
.append("remark", getRemark())
.toString();
}
}

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

@@ -3,7 +3,7 @@
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.xinda.iot.mapper.DeviceModelMapper">
<resultMap type="DeviceModel" id="DeviceModelResult">
<result property="id" column="id" />
<result property="productModel" column="product_model" />
@@ -18,19 +18,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectDeviceModelList" parameterType="DeviceModel" resultMap="DeviceModelResult">
<include refid="selectDeviceModelVo"/>
<where>
<where>
<if test="productModel != null and productModel != ''"> and product_model = #{productModel}</if>
<if test="displayOrder != null "> and display_order = #{displayOrder}</if>
<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">
<include refid="selectDeviceModelVo"/>
where id = #{id}
</select>
<insert id="insertDeviceModel" parameterType="DeviceModel" useGeneratedKeys="true" keyProperty="id">
insert into iot_device_model
<trim prefix="(" suffix=")" suffixOverrides=",">
@@ -63,9 +64,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</delete>
<delete id="deleteDeviceModelByIds" parameterType="String">
delete from iot_device_model where id in
delete from iot_device_model where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>
</mapper>

View File

@@ -3,7 +3,7 @@
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.xinda.iot.mapper.GroupMapper">
<resultMap type="com.xinda.iot.domain.Group" id="GroupResult">
<result property="groupId" column="group_id" />
<result property="groupName" column="group_name" />
@@ -25,14 +25,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectGroupList" parameterType="com.xinda.iot.domain.Group" resultMap="GroupResult">
<include refid="selectGroupVo"/>
<where>
<where>
<if test="groupName != null and groupName != ''"> and group_name like concat('%', #{groupName}, '%')</if>
<if test="userName != null and userName != ''"> and user_name like concat('%', #{userName}, '%')</if>
<if test="userId != null "> and user_id = #{userId}</if>
</where>
order by group_order
</select>
<select id="selectGroupByGroupId" parameterType="Long" resultMap="GroupResult">
<include refid="selectGroupVo"/>
where group_id = #{groupId}
@@ -41,7 +41,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectDeviceIdsByGroupId" parameterType="Long" resultMap="IdsResult">
select device_id from iot_device_group where group_id=#{groupId}
</select>
<insert id="insertGroup" parameterType="com.xinda.iot.domain.Group" useGeneratedKeys="true" keyProperty="groupId">
insert into iot_group
<trim prefix="(" suffix=")" suffixOverrides=",">
@@ -102,7 +102,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</delete>
<delete id="deleteGroupByGroupIds" parameterType="String">
delete from iot_group where group_id in
delete from iot_group where group_id in
<foreach item="groupId" collection="array" open="(" separator="," close=")">
#{groupId}
</foreach>
@@ -133,4 +133,5 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</where>
order by group_order
</select>
</mapper>
</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>