This commit is contained in:
LEED
2025-07-19 11:29:07 +08:00
parent 4c1521bda0
commit a9895296f0
45 changed files with 929 additions and 70 deletions

View File

@@ -0,0 +1,56 @@
package com.xinda.iot.domain;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.xinda.common.annotation.Excel;
import com.xinda.common.core.domain.BaseEntity;
/**
* 设备档案管理对象 iot_device_doc
*
* @author leed
* @date 2025-07-13
*/
@ApiModel(value = "DeviceDoc",description = "设备档案管理 iot_device_doc")
@Data
public class DeviceDoc extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** id唯一标识 */
private Long id;
/** 设备id */
@Excel(name = "设备id")
@ApiModelProperty("设备id")
private Long deviceId;
/** 设备编号 */
@Excel(name = "设备编号")
@ApiModelProperty("设备编号")
private String serialNumber;
/** 文件名称 */
@Excel(name = "文件名称")
@ApiModelProperty("文件名称")
private String fileName;
/** 资源请求路径 */
@Excel(name = "资源请求路径")
@ApiModelProperty("资源请求路径")
private String resourceUrl;
/** 租户id */
@Excel(name = "租户id")
@ApiModelProperty("租户id")
private Long tenantId;
/** 租户名称 */
@Excel(name = "租户名称")
@ApiModelProperty("租户名称")
private String tenantName;
}

View File

@@ -0,0 +1,61 @@
package com.xinda.iot.mapper;
import java.util.List;
import com.xinda.iot.domain.DeviceDoc;
/**
* 设备档案管理Mapper接口
*
* @author leed
* @date 2025-07-13
*/
public interface DeviceDocMapper
{
/**
* 查询设备档案管理
*
* @param id 设备档案管理主键
* @return 设备档案管理
*/
public DeviceDoc selectDeviceDocById(Long id);
/**
* 查询设备档案管理列表
*
* @param deviceDoc 设备档案管理
* @return 设备档案管理集合
*/
public List<DeviceDoc> selectDeviceDocList(DeviceDoc deviceDoc);
/**
* 新增设备档案管理
*
* @param deviceDoc 设备档案管理
* @return 结果
*/
public int insertDeviceDoc(DeviceDoc deviceDoc);
/**
* 修改设备档案管理
*
* @param deviceDoc 设备档案管理
* @return 结果
*/
public int updateDeviceDoc(DeviceDoc deviceDoc);
/**
* 删除设备档案管理
*
* @param id 设备档案管理主键
* @return 结果
*/
public int deleteDeviceDocById(Long id);
/**
* 批量删除设备档案管理
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
public int deleteDeviceDocByIds(Long[] ids);
}

View File

@@ -0,0 +1,61 @@
package com.xinda.iot.service;
import java.util.List;
import com.xinda.iot.domain.DeviceDoc;
/**
* 设备档案管理Service接口
*
* @author leed
* @date 2025-07-13
*/
public interface IDeviceDocService
{
/**
* 查询设备档案管理
*
* @param id 设备档案管理主键
* @return 设备档案管理
*/
public DeviceDoc selectDeviceDocById(Long id);
/**
* 查询设备档案管理列表
*
* @param deviceDoc 设备档案管理
* @return 设备档案管理集合
*/
public List<DeviceDoc> selectDeviceDocList(DeviceDoc deviceDoc);
/**
* 新增设备档案管理
*
* @param deviceDoc 设备档案管理
* @return 结果
*/
public int insertDeviceDoc(DeviceDoc deviceDoc);
/**
* 修改设备档案管理
*
* @param deviceDoc 设备档案管理
* @return 结果
*/
public int updateDeviceDoc(DeviceDoc deviceDoc);
/**
* 批量删除设备档案管理
*
* @param ids 需要删除的设备档案管理主键集合
* @return 结果
*/
public int deleteDeviceDocByIds(Long[] ids);
/**
* 删除设备档案管理信息
*
* @param id 设备档案管理主键
* @return 结果
*/
public int deleteDeviceDocById(Long id);
}

View File

@@ -0,0 +1,96 @@
package com.xinda.iot.service.impl;
import java.util.List;
import com.xinda.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.xinda.iot.mapper.DeviceDocMapper;
import com.xinda.iot.domain.DeviceDoc;
import com.xinda.iot.service.IDeviceDocService;
/**
* 设备档案管理Service业务层处理
*
* @author leed
* @date 2025-07-13
*/
@Service
public class DeviceDocServiceImpl implements IDeviceDocService
{
@Autowired
private DeviceDocMapper deviceDocMapper;
/**
* 查询设备档案管理
*
* @param id 设备档案管理主键
* @return 设备档案管理
*/
@Override
public DeviceDoc selectDeviceDocById(Long id)
{
return deviceDocMapper.selectDeviceDocById(id);
}
/**
* 查询设备档案管理列表
*
* @param deviceDoc 设备档案管理
* @return 设备档案管理
*/
@Override
public List<DeviceDoc> selectDeviceDocList(DeviceDoc deviceDoc)
{
return deviceDocMapper.selectDeviceDocList(deviceDoc);
}
/**
* 新增设备档案管理
*
* @param deviceDoc 设备档案管理
* @return 结果
*/
@Override
public int insertDeviceDoc(DeviceDoc deviceDoc)
{
deviceDoc.setCreateTime(DateUtils.getNowDate());
return deviceDocMapper.insertDeviceDoc(deviceDoc);
}
/**
* 修改设备档案管理
*
* @param deviceDoc 设备档案管理
* @return 结果
*/
@Override
public int updateDeviceDoc(DeviceDoc deviceDoc)
{
deviceDoc.setUpdateTime(DateUtils.getNowDate());
return deviceDocMapper.updateDeviceDoc(deviceDoc);
}
/**
* 批量删除设备档案管理
*
* @param ids 需要删除的设备档案管理主键
* @return 结果
*/
@Override
public int deleteDeviceDocByIds(Long[] ids)
{
return deviceDocMapper.deleteDeviceDocByIds(ids);
}
/**
* 删除设备档案管理信息
*
* @param id 设备档案管理主键
* @return 结果
*/
@Override
public int deleteDeviceDocById(Long id)
{
return deviceDocMapper.deleteDeviceDocById(id);
}
}

View File

@@ -279,6 +279,7 @@ public class SceneServiceImpl implements ISceneService {
}
}
// 构建规则链
LiteFlowChainELBuilder.createChain().setChainName(scene.getChainName()).setEL(scene.getElData()).build();
}
@@ -294,13 +295,14 @@ public class SceneServiceImpl implements ISceneService {
@Override
public String buildElData(Scene scene, List<Script> ruleScripts, List<SceneScript> sceneScripts, List<SceneDevice> sceneDevices) {
// 排除定时后的触发器等于0不生成规则数据等于1移除AND和OR
Long triggerNodeCount = scene.getTriggers().stream().filter(x -> x.getSource() != 2).count();
Long triggerNodeCount = scene.getTriggers().stream().filter(x -> x.getSource() != 2 && x.getSource() != 4).count();
Long triggerTimingCount = scene.getTriggers().stream().filter(x -> x.getSource() == 2).count();
Long selftriggerCount = scene.getTriggers().stream().filter(x -> x.getSource() == 4).count();
// 拼接规则数据格式如IF(AND(T1,T2,T3),THEN(A1,A2,A3))
StringBuilder triggerBuilder = new StringBuilder();
StringBuilder actionBuilder = new StringBuilder();
if (0 == triggerNodeCount && triggerTimingCount != 0) {
// if (0 == triggerNodeCount && triggerTimingCount != 0) {
if (0 == triggerNodeCount && (triggerTimingCount != 0 || selftriggerCount != 0 )) {
switch (scene.getExecuteMode()) {
case 1:
actionBuilder.append("THEN(");
@@ -341,7 +343,7 @@ public class SceneServiceImpl implements ISceneService {
// 保存触发器和执行动作
String scriptId = buildTriggerAction(scene.getTriggers().get(i), 2, scene, ruleScripts, sceneScripts, sceneDevices);
// 构建触发器EL排除定时触发器
if (scene.getTriggers().get(i).getSource() != 2 || scene.getTriggers().get(i).getSource() != 4) {
if (scene.getTriggers().get(i).getSource() != 2 && scene.getTriggers().get(i).getSource() != 4) {
triggerBuilder.append(scriptId + ",");
}
}
@@ -431,13 +433,17 @@ public class SceneServiceImpl implements ISceneService {
"sceneContext.process(json);", StringEscapeUtils.escapeJava(JSONObject.toJSONString(template)));
ruleScript.setScriptData(data);
// 构建脚本集合,规则脚本不需要存储定时触发器
if (sceneScript.getSource() != 2 || sceneScript.getSource() != 4) {
ruleScripts.add(ruleScript);
}
// if (sceneScript.getSource() != 2 || sceneScript.getSource() != 4) {
// ruleScripts.add(ruleScript);
// }
if (scriptPurpose == 2) {
// 构建脚本集合,规则脚本不需要存储定时触发器
if (sceneScript.getSource() != 2) {
ruleScripts.add(ruleScript);
}
// 触发器
if (sceneScript.getSource() == 1) {
if (sceneScript.getSource() == 1|| 5 == sceneScript.getSource()) {
// 构建场景设备集合
for (int j = 0; j < sceneScript.getDeviceNums().length; j++) {
SceneDevice sceneDevice = new SceneDevice();
@@ -466,6 +472,7 @@ public class SceneServiceImpl implements ISceneService {
sceneDevices.add(sceneDevice);
}
} else if (scriptPurpose == 3) {
ruleScripts.add(ruleScript);
if (sceneScript.getSource() == 1) {
// 构建场景设备集合
for (int j = 0; j < sceneScript.getDeviceNums().length; j++) {

View File

@@ -0,0 +1,97 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.xinda.iot.mapper.DeviceDocMapper">
<resultMap type="DeviceDoc" id="DeviceDocResult">
<result property="id" column="id" />
<result property="deviceId" column="device_id" />
<result property="serialNumber" column="serial_number" />
<result property="fileName" column="file_name" />
<result property="resourceUrl" column="resource_url" />
<result property="tenantId" column="tenant_id" />
<result property="tenantName" column="tenant_name" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
</resultMap>
<sql id="selectDeviceDocVo">
select id, device_id, serial_number, file_name, resource_url, tenant_id, tenant_name, create_by, create_time, update_by, update_time from iot_device_doc
</sql>
<select id="selectDeviceDocList" parameterType="DeviceDoc" resultMap="DeviceDocResult">
<include refid="selectDeviceDocVo"/>
<where>
<if test="deviceId != null "> and device_id = #{deviceId}</if>
<if test="serialNumber != null and serialNumber != ''"> and serial_number = #{serialNumber}</if>
<if test="fileName != null and fileName != ''"> and file_name like concat('%', #{fileName}, '%')</if>
<if test="resourceUrl != null and resourceUrl != ''"> and resource_url = #{resourceUrl}</if>
<if test="tenantId != null "> and tenant_id = #{tenantId}</if>
<if test="tenantName != null and tenantName != ''"> and tenant_name like concat('%', #{tenantName}, '%')</if>
</where>
</select>
<select id="selectDeviceDocById" parameterType="Long" resultMap="DeviceDocResult">
<include refid="selectDeviceDocVo"/>
where id = #{id}
</select>
<insert id="insertDeviceDoc" parameterType="DeviceDoc" useGeneratedKeys="true" keyProperty="id">
insert into iot_device_doc
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="deviceId != null">device_id,</if>
<if test="serialNumber != null">serial_number,</if>
<if test="fileName != null">file_name,</if>
<if test="resourceUrl != null">resource_url,</if>
<if test="tenantId != null">tenant_id,</if>
<if test="tenantName != null">tenant_name,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="deviceId != null">#{deviceId},</if>
<if test="serialNumber != null">#{serialNumber},</if>
<if test="fileName != null">#{fileName},</if>
<if test="resourceUrl != null">#{resourceUrl},</if>
<if test="tenantId != null">#{tenantId},</if>
<if test="tenantName != null">#{tenantName},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
</trim>
</insert>
<update id="updateDeviceDoc" parameterType="DeviceDoc">
update iot_device_doc
<trim prefix="SET" suffixOverrides=",">
<if test="deviceId != null">device_id = #{deviceId},</if>
<if test="serialNumber != null">serial_number = #{serialNumber},</if>
<if test="fileName != null">file_name = #{fileName},</if>
<if test="resourceUrl != null">resource_url = #{resourceUrl},</if>
<if test="tenantId != null">tenant_id = #{tenantId},</if>
<if test="tenantName != null">tenant_name = #{tenantName},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteDeviceDocById" parameterType="Long">
delete from iot_device_doc where id = #{id}
</delete>
<delete id="deleteDeviceDocByIds" parameterType="String">
delete from iot_device_doc where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>

View File

@@ -436,7 +436,7 @@
</update>
<select id="selectDeviceGShortList" parameterType="com.xinda.iot.domain.Device" resultMap="DeviceShortResult">
select d.device_id, d.device_name, p.product_id, p.product_name,p.device_type,
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,d.ic_way,d.iccid,d.volt,d.sd,d.pd,d.imei, d.gw_id, d.gw_name,
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)
@@ -538,7 +538,7 @@
<!-- </select>-->
<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,
select d.device_id, d.device_name, p.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,d.ic_way,d.iccid,d.volt,d.sd,d.pd,d.imei, d.gw_id, d.gw_name,
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,
@@ -576,7 +576,7 @@
</select>
<select id="selectDeviceShortGwList" parameterType="com.xinda.iot.domain.Device" resultMap="DeviceShortResult">
select d.device_id, d.device_name, p.product_id, p.product_name,p.device_type,
select d.device_id, d.device_name, p.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,d.ic_way,d.iccid,d.volt,d.sd,d.pd,d.imei, d.gw_id, d.gw_name,
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,
@@ -615,7 +615,7 @@
</select>
<select id="selectDeviceShortTreeList" parameterType="com.xinda.iot.domain.Device" resultMap="DeviceShortResult">
select d.device_id, d.device_name, p.product_id, p.product_name,p.device_type,
select d.device_id, d.device_name, p.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,d.ic_way,d.iccid,d.volt,d.sd,d.pd,d.imei, d.gw_id, d.gw_name,
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,
@@ -653,7 +653,7 @@
</select>
<select id="selectCamDeviceListByDeviceId" parameterType="Long" resultMap="DeviceShortResult">
select d.device_id, d.device_name, p.product_id, p.product_name,p.device_type,
select d.device_id, d.device_name, p.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,d.ic_way,d.iccid,d.volt,d.sd,d.pd,d.imei, d.gw_id, d.gw_name,
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,
@@ -675,7 +675,7 @@
select d.device_id,
d.device_name,
d.product_id,
p.product_name,
d.product_name,
p.device_type,
d.tenant_id,
d.tenant_name,