feat(device): 增加设备故障记录功能并完善监控逻辑
- 在 DeviceSsjMapper.xml 中添加 ipAddress 和 port 字段映射 - 调整 SQL 查询语句字段顺序以适配新增字段 - MonitoringThread.java 引入 BasFaultRecord 相关类及工具类 - 初始化 basFaultRecordService 和 mydoJobService 服务实例 - 实现设备状态异常检测逻辑,并创建或更新故障记录 - 新增 BasFaultRecord 实体类用于存储设备故障信息 - 创建 BasFaultRecordController 控制器提供 RESTful 接口 - 添加 BasFaultRecordMapper 接口定义数据库操作方法 - 编写 BasFaultRecordMapper.xml 配置文件实现 CRUD 操作 - 实现 BasFaultRecordServiceImpl 业务逻辑处理层 - 定义 IBasFaultRecordService 接口规范服务行为
This commit is contained in:
@@ -0,0 +1,98 @@
|
||||
<?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.ruoyi.bas.fault.mapper.BasFaultRecordMapper">
|
||||
|
||||
<resultMap type="BasFaultRecord" id="BasFaultRecordResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="deviceId" column="device_id" />
|
||||
<result property="deviceName" column="device_name" />
|
||||
<result property="deviceType" column="device_type" />
|
||||
<result property="taskNo" column="task_no" />
|
||||
<result property="jobId" column="job_id" />
|
||||
<result property="fault" column="fault" />
|
||||
<result property="startTime" column="start_time" />
|
||||
<result property="finishTime" column="finish_time" />
|
||||
<result property="warehouseId" column="warehouse_id" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectBasFaultRecordVo">
|
||||
select id, device_id, device_name, device_type, task_no, job_id, fault, start_time, finish_time, warehouse_id from bas_fault_record
|
||||
</sql>
|
||||
|
||||
<select id="selectBasFaultRecordList" parameterType="BasFaultRecord" resultMap="BasFaultRecordResult">
|
||||
<include refid="selectBasFaultRecordVo"/>
|
||||
<where>
|
||||
<if test="deviceId != null and deviceId != ''"> and device_id = #{deviceId}</if>
|
||||
<if test="deviceName != null and deviceName != ''"> and device_name like concat('%', #{deviceName}, '%')</if>
|
||||
<if test="deviceType != null and deviceType != ''"> and device_type = #{deviceType}</if>
|
||||
<if test="taskNo != null and taskNo != ''"> and task_no = #{taskNo}</if>
|
||||
<if test="jobId != null and jobId != ''"> and job_id = #{jobId}</if>
|
||||
<if test="fault != null and fault != ''"> and fault = #{fault}</if>
|
||||
<if test="startTime != null and startTime != ''"> and start_time = #{startTime}</if>
|
||||
<if test="finishTime != null and finishTime != ''"> and finish_time = #{finishTime}</if>
|
||||
<if test="warehouseId != null and warehouseId != ''"> and warehouse_id = #{warehouseId}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectBasFaultRecordById" parameterType="String" resultMap="BasFaultRecordResult">
|
||||
<include refid="selectBasFaultRecordVo"/>
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<insert id="insertBasFaultRecord" parameterType="BasFaultRecord">
|
||||
insert into bas_fault_record
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null and id != ''">id,</if>
|
||||
<if test="deviceId != null and deviceId != ''">device_id,</if>
|
||||
<if test="deviceName != null and deviceName != ''">device_name,</if>
|
||||
<if test="deviceType != null and deviceType != ''">device_type,</if>
|
||||
<if test="taskNo != null">task_no,</if>
|
||||
<if test="jobId != null">job_id,</if>
|
||||
<if test="fault != null">fault,</if>
|
||||
<if test="startTime != null">start_time,</if>
|
||||
<if test="finishTime != null">finish_time,</if>
|
||||
<if test="warehouseId != null">warehouse_id,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null and id != ''">#{id},</if>
|
||||
<if test="deviceId != null and deviceId != ''">#{deviceId},</if>
|
||||
<if test="deviceName != null and deviceName != ''">#{deviceName},</if>
|
||||
<if test="deviceType != null and deviceType != ''">#{deviceType},</if>
|
||||
<if test="taskNo != null">#{taskNo},</if>
|
||||
<if test="jobId != null">#{jobId},</if>
|
||||
<if test="fault != null">#{fault},</if>
|
||||
<if test="startTime != null">#{startTime},</if>
|
||||
<if test="finishTime != null">#{finishTime},</if>
|
||||
<if test="warehouseId != null">#{warehouseId},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateBasFaultRecord" parameterType="BasFaultRecord">
|
||||
update bas_fault_record
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="deviceId != null and deviceId != ''">device_id = #{deviceId},</if>
|
||||
<if test="deviceName != null and deviceName != ''">device_name = #{deviceName},</if>
|
||||
<if test="deviceType != null and deviceType != ''">device_type = #{deviceType},</if>
|
||||
<if test="taskNo != null">task_no = #{taskNo},</if>
|
||||
<if test="jobId != null">job_id = #{jobId},</if>
|
||||
<if test="fault != null">fault = #{fault},</if>
|
||||
<if test="startTime != null">start_time = #{startTime},</if>
|
||||
<if test="finishTime != null">finish_time = #{finishTime},</if>
|
||||
<if test="warehouseId != null">warehouse_id = #{warehouseId},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteBasFaultRecordById" parameterType="String">
|
||||
delete from bas_fault_record where id = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteBasFaultRecordByIds" parameterType="String">
|
||||
delete from bas_fault_record where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
</mapper>
|
||||
@@ -22,10 +22,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<result property="exception" column="exception" />
|
||||
<result property="traySize" column="tray_size" />
|
||||
<result property="allowPut" column="allow_put" />
|
||||
<result property="ipAddress" column="ip_address" />
|
||||
<result property="port" column="port" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectDeviceSsjVo">
|
||||
select id, device_code , name , type, ip_address, plc_db_read_address, is_active, create_time, plc_db_write_address, rkqq, kx, dw, tray_code, task_no,exception,tray_size,allow_put from device_ssj
|
||||
select id, device_code , name , type, plc_db_read_address, is_active, create_time, plc_db_write_address, rkqq, kx, dw, tray_code, task_no,exception,tray_size,allow_put,ip_address , port from device_ssj
|
||||
</sql>
|
||||
|
||||
<select id="selectDeviceSsjList" parameterType="DeviceSsj" resultMap="DeviceSsjResult">
|
||||
|
||||
Reference in New Issue
Block a user