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,104 @@
|
||||
package com.ruoyi.bas.fault.controller;
|
||||
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.bas.fault.domain.BasFaultRecord;
|
||||
import com.ruoyi.bas.fault.service.IBasFaultRecordService;
|
||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
|
||||
/**
|
||||
* 设备故障记录Controller
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2025-12-11
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/bas/faultRecord")
|
||||
public class BasFaultRecordController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private IBasFaultRecordService basFaultRecordService;
|
||||
|
||||
/**
|
||||
* 查询设备故障记录列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('bas:faultRecord:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(BasFaultRecord basFaultRecord)
|
||||
{
|
||||
startPage();
|
||||
List<BasFaultRecord> list = basFaultRecordService.selectBasFaultRecordList(basFaultRecord);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出设备故障记录列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('bas:faultRecord:export')")
|
||||
@Log(title = "设备故障记录", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, BasFaultRecord basFaultRecord)
|
||||
{
|
||||
List<BasFaultRecord> list = basFaultRecordService.selectBasFaultRecordList(basFaultRecord);
|
||||
ExcelUtil<BasFaultRecord> util = new ExcelUtil<BasFaultRecord>(BasFaultRecord.class);
|
||||
util.exportExcel(response, list, "设备故障记录数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取设备故障记录详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('bas:faultRecord:query')")
|
||||
@GetMapping(value = "/{id}")
|
||||
public AjaxResult getInfo(@PathVariable("id") String id)
|
||||
{
|
||||
return success(basFaultRecordService.selectBasFaultRecordById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增设备故障记录
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('bas:faultRecord:add')")
|
||||
@Log(title = "设备故障记录", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody BasFaultRecord basFaultRecord)
|
||||
{
|
||||
return toAjax(basFaultRecordService.insertBasFaultRecord(basFaultRecord));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改设备故障记录
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('bas:faultRecord:edit')")
|
||||
@Log(title = "设备故障记录", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody BasFaultRecord basFaultRecord)
|
||||
{
|
||||
return toAjax(basFaultRecordService.updateBasFaultRecord(basFaultRecord));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除设备故障记录
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('bas:faultRecord:remove')")
|
||||
@Log(title = "设备故障记录", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public AjaxResult remove(@PathVariable String[] ids)
|
||||
{
|
||||
return toAjax(basFaultRecordService.deleteBasFaultRecordByIds(ids));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,172 @@
|
||||
package com.ruoyi.bas.fault.domain;
|
||||
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
|
||||
/**
|
||||
* 设备故障记录对象 bas_fault_record
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2025-12-11
|
||||
*/
|
||||
public class BasFaultRecord extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** id 主键 */
|
||||
private String id;
|
||||
|
||||
/** 设备id */
|
||||
@Excel(name = "设备id")
|
||||
private String deviceId;
|
||||
|
||||
/** 设备名称 */
|
||||
@Excel(name = "设备名称")
|
||||
private String deviceName;
|
||||
|
||||
/** 设备类型 */
|
||||
@Excel(name = "设备类型")
|
||||
private String deviceType;
|
||||
|
||||
/** 任务号 */
|
||||
@Excel(name = "任务号")
|
||||
private String taskNo;
|
||||
|
||||
/** 作业id */
|
||||
@Excel(name = "作业id ")
|
||||
private String jobId;
|
||||
|
||||
/** 报警信息 */
|
||||
@Excel(name = "报警信息")
|
||||
private String fault;
|
||||
|
||||
/** 报警开始时间 */
|
||||
@Excel(name = "报警开始时间")
|
||||
private String startTime;
|
||||
|
||||
/** 报警结束时间 */
|
||||
@Excel(name = "报警结束时间")
|
||||
private String finishTime;
|
||||
|
||||
/** 仓库 */
|
||||
@Excel(name = "仓库")
|
||||
private String warehouseId;
|
||||
|
||||
public void setId(String id)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getId()
|
||||
{
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setDeviceId(String deviceId)
|
||||
{
|
||||
this.deviceId = deviceId;
|
||||
}
|
||||
|
||||
public String getDeviceId()
|
||||
{
|
||||
return deviceId;
|
||||
}
|
||||
|
||||
public void setDeviceName(String deviceName)
|
||||
{
|
||||
this.deviceName = deviceName;
|
||||
}
|
||||
|
||||
public String getDeviceName()
|
||||
{
|
||||
return deviceName;
|
||||
}
|
||||
|
||||
public void setDeviceType(String deviceType)
|
||||
{
|
||||
this.deviceType = deviceType;
|
||||
}
|
||||
|
||||
public String getDeviceType()
|
||||
{
|
||||
return deviceType;
|
||||
}
|
||||
|
||||
public void setTaskNo(String taskNo)
|
||||
{
|
||||
this.taskNo = taskNo;
|
||||
}
|
||||
|
||||
public String getTaskNo()
|
||||
{
|
||||
return taskNo;
|
||||
}
|
||||
|
||||
public void setJobId(String jobId)
|
||||
{
|
||||
this.jobId = jobId;
|
||||
}
|
||||
|
||||
public String getJobId()
|
||||
{
|
||||
return jobId;
|
||||
}
|
||||
|
||||
public void setFault(String fault)
|
||||
{
|
||||
this.fault = fault;
|
||||
}
|
||||
|
||||
public String getFault()
|
||||
{
|
||||
return fault;
|
||||
}
|
||||
|
||||
public void setStartTime(String startTime)
|
||||
{
|
||||
this.startTime = startTime;
|
||||
}
|
||||
|
||||
public String getStartTime()
|
||||
{
|
||||
return startTime;
|
||||
}
|
||||
|
||||
public void setFinishTime(String finishTime)
|
||||
{
|
||||
this.finishTime = finishTime;
|
||||
}
|
||||
|
||||
public String getFinishTime()
|
||||
{
|
||||
return finishTime;
|
||||
}
|
||||
|
||||
public void setWarehouseId(String warehouseId)
|
||||
{
|
||||
this.warehouseId = warehouseId;
|
||||
}
|
||||
|
||||
public String getWarehouseId()
|
||||
{
|
||||
return warehouseId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("id", getId())
|
||||
.append("deviceId", getDeviceId())
|
||||
.append("deviceName", getDeviceName())
|
||||
.append("deviceType", getDeviceType())
|
||||
.append("taskNo", getTaskNo())
|
||||
.append("jobId", getJobId())
|
||||
.append("fault", getFault())
|
||||
.append("startTime", getStartTime())
|
||||
.append("finishTime", getFinishTime())
|
||||
.append("warehouseId", getWarehouseId())
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package com.ruoyi.bas.fault.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import com.ruoyi.bas.fault.domain.BasFaultRecord;
|
||||
|
||||
/**
|
||||
* 设备故障记录Mapper接口
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2025-12-11
|
||||
*/
|
||||
public interface BasFaultRecordMapper
|
||||
{
|
||||
/**
|
||||
* 查询设备故障记录
|
||||
*
|
||||
* @param id 设备故障记录主键
|
||||
* @return 设备故障记录
|
||||
*/
|
||||
public BasFaultRecord selectBasFaultRecordById(String id);
|
||||
|
||||
/**
|
||||
* 查询设备故障记录列表
|
||||
*
|
||||
* @param basFaultRecord 设备故障记录
|
||||
* @return 设备故障记录集合
|
||||
*/
|
||||
public List<BasFaultRecord> selectBasFaultRecordList(BasFaultRecord basFaultRecord);
|
||||
|
||||
/**
|
||||
* 新增设备故障记录
|
||||
*
|
||||
* @param basFaultRecord 设备故障记录
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertBasFaultRecord(BasFaultRecord basFaultRecord);
|
||||
|
||||
/**
|
||||
* 修改设备故障记录
|
||||
*
|
||||
* @param basFaultRecord 设备故障记录
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateBasFaultRecord(BasFaultRecord basFaultRecord);
|
||||
|
||||
/**
|
||||
* 删除设备故障记录
|
||||
*
|
||||
* @param id 设备故障记录主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteBasFaultRecordById(String id);
|
||||
|
||||
/**
|
||||
* 批量删除设备故障记录
|
||||
*
|
||||
* @param ids 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteBasFaultRecordByIds(String[] ids);
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package com.ruoyi.bas.fault.service;
|
||||
|
||||
import java.util.List;
|
||||
import com.ruoyi.bas.fault.domain.BasFaultRecord;
|
||||
|
||||
/**
|
||||
* 设备故障记录Service接口
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2025-12-11
|
||||
*/
|
||||
public interface IBasFaultRecordService
|
||||
{
|
||||
/**
|
||||
* 查询设备故障记录
|
||||
*
|
||||
* @param id 设备故障记录主键
|
||||
* @return 设备故障记录
|
||||
*/
|
||||
public BasFaultRecord selectBasFaultRecordById(String id);
|
||||
|
||||
/**
|
||||
* 查询设备故障记录列表
|
||||
*
|
||||
* @param basFaultRecord 设备故障记录
|
||||
* @return 设备故障记录集合
|
||||
*/
|
||||
public List<BasFaultRecord> selectBasFaultRecordList(BasFaultRecord basFaultRecord);
|
||||
|
||||
/**
|
||||
* 新增设备故障记录
|
||||
*
|
||||
* @param basFaultRecord 设备故障记录
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertBasFaultRecord(BasFaultRecord basFaultRecord);
|
||||
|
||||
/**
|
||||
* 修改设备故障记录
|
||||
*
|
||||
* @param basFaultRecord 设备故障记录
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateBasFaultRecord(BasFaultRecord basFaultRecord);
|
||||
|
||||
/**
|
||||
* 批量删除设备故障记录
|
||||
*
|
||||
* @param ids 需要删除的设备故障记录主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteBasFaultRecordByIds(String[] ids);
|
||||
|
||||
/**
|
||||
* 删除设备故障记录信息
|
||||
*
|
||||
* @param id 设备故障记录主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteBasFaultRecordById(String id);
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
package com.ruoyi.bas.fault.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.ruoyi.bas.fault.mapper.BasFaultRecordMapper;
|
||||
import com.ruoyi.bas.fault.domain.BasFaultRecord;
|
||||
import com.ruoyi.bas.fault.service.IBasFaultRecordService;
|
||||
|
||||
/**
|
||||
* 设备故障记录Service业务层处理
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2025-12-11
|
||||
*/
|
||||
@Service
|
||||
public class BasFaultRecordServiceImpl implements IBasFaultRecordService
|
||||
{
|
||||
@Autowired
|
||||
private BasFaultRecordMapper basFaultRecordMapper;
|
||||
|
||||
/**
|
||||
* 查询设备故障记录
|
||||
*
|
||||
* @param id 设备故障记录主键
|
||||
* @return 设备故障记录
|
||||
*/
|
||||
@Override
|
||||
public BasFaultRecord selectBasFaultRecordById(String id)
|
||||
{
|
||||
return basFaultRecordMapper.selectBasFaultRecordById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询设备故障记录列表
|
||||
*
|
||||
* @param basFaultRecord 设备故障记录
|
||||
* @return 设备故障记录
|
||||
*/
|
||||
@Override
|
||||
public List<BasFaultRecord> selectBasFaultRecordList(BasFaultRecord basFaultRecord)
|
||||
{
|
||||
return basFaultRecordMapper.selectBasFaultRecordList(basFaultRecord);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增设备故障记录
|
||||
*
|
||||
* @param basFaultRecord 设备故障记录
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertBasFaultRecord(BasFaultRecord basFaultRecord)
|
||||
{
|
||||
return basFaultRecordMapper.insertBasFaultRecord(basFaultRecord);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改设备故障记录
|
||||
*
|
||||
* @param basFaultRecord 设备故障记录
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateBasFaultRecord(BasFaultRecord basFaultRecord)
|
||||
{
|
||||
return basFaultRecordMapper.updateBasFaultRecord(basFaultRecord);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除设备故障记录
|
||||
*
|
||||
* @param ids 需要删除的设备故障记录主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteBasFaultRecordByIds(String[] ids)
|
||||
{
|
||||
return basFaultRecordMapper.deleteBasFaultRecordByIds(ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除设备故障记录信息
|
||||
*
|
||||
* @param id 设备故障记录主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteBasFaultRecordById(String id)
|
||||
{
|
||||
return basFaultRecordMapper.deleteBasFaultRecordById(id);
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,25 @@
|
||||
package com.ruoyi.schedule.scheduleTask.monit;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.ObjUtil;
|
||||
import com.ruoyi.bas.fault.domain.BasFaultRecord;
|
||||
import com.ruoyi.bas.fault.service.IBasFaultRecordService;
|
||||
import com.ruoyi.common.utils.spring.SpringUtils;
|
||||
import com.ruoyi.device.ddj.domain.MsgDdj;
|
||||
import com.ruoyi.device.ddj.service.IMsgDdjService;
|
||||
import com.ruoyi.device.ssj.domain.DeviceSsj;
|
||||
import com.ruoyi.device.ssj.service.IDeviceSsjService;
|
||||
import com.ruoyi.job.domain.MydoJob;
|
||||
import com.ruoyi.job.service.IMydoJobService;
|
||||
import com.ruoyi.schedule.plcRead.ddj.PlcDdjRead;
|
||||
import com.ruoyi.schedule.plcRead.ssj.PlcSsjRead;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 监控线程
|
||||
*/
|
||||
@@ -18,11 +30,15 @@ public class MonitoringThread implements Runnable {
|
||||
|
||||
private IDeviceSsjService deviceSsjService;
|
||||
private IMsgDdjService msgDdjService;
|
||||
private IBasFaultRecordService basFaultRecordService;
|
||||
private IMydoJobService mydoJobService;
|
||||
|
||||
|
||||
public void init() {
|
||||
deviceSsjService = SpringUtils.getBean(IDeviceSsjService.class);
|
||||
msgDdjService = SpringUtils.getBean(IMsgDdjService.class);
|
||||
basFaultRecordService = SpringUtils.getBean(IBasFaultRecordService.class);
|
||||
mydoJobService = SpringUtils.getBean(IMydoJobService.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -34,7 +50,43 @@ public class MonitoringThread implements Runnable {
|
||||
deviceSsjService.updateDeviceSsj(deviceSsj);
|
||||
}
|
||||
for (String ddjCode : PlcDdjRead.deviceDdjMap.keySet()) {
|
||||
msgDdjService.updateMsgDdj(PlcDdjRead.deviceDdjMap.get(ddjCode));
|
||||
MsgDdj msgDdj = PlcDdjRead.deviceDdjMap.get(ddjCode);
|
||||
msgDdjService.updateMsgDdj(msgDdj);
|
||||
|
||||
if (msgDdj.getSbzt() > 1000) {
|
||||
BasFaultRecord param = new BasFaultRecord();
|
||||
param.setTaskNo(msgDdj.getRwh() + "");
|
||||
param.setDeviceId(String.valueOf(msgDdj.getId()));
|
||||
param.setDeviceType("DDJ");
|
||||
param.setJobId("0");
|
||||
List<BasFaultRecord> basFaultRecords = basFaultRecordService.selectBasFaultRecordList(param);
|
||||
if (CollUtil.isEmpty(basFaultRecords)) {
|
||||
BasFaultRecord faultRecord = new BasFaultRecord();
|
||||
faultRecord.setId(IdUtil.fastSimpleUUID());
|
||||
faultRecord.setDeviceId(String.valueOf(msgDdj.getId()));
|
||||
faultRecord.setDeviceName(msgDdj.getName());
|
||||
faultRecord.setDeviceType("DDJ");
|
||||
faultRecord.setJobId("0");
|
||||
faultRecord.setTaskNo(msgDdj.getRwh() + "");
|
||||
faultRecord.setFault(msgDdj.getSbzt() + "");
|
||||
faultRecord.setStartTime(DateUtil.formatDateTime(DateUtil.date()));
|
||||
//faultRecord.setWarehouseId(mydoJob.getWarehouseId());
|
||||
basFaultRecordService.insertBasFaultRecord(faultRecord);
|
||||
}
|
||||
}
|
||||
if (msgDdj.getSbzt() < 1000 && msgDdj.getCzfs() == 5){
|
||||
BasFaultRecord param = new BasFaultRecord();
|
||||
param.setTaskNo(msgDdj.getRwh() + "");
|
||||
param.setDeviceId(String.valueOf(msgDdj.getId()));
|
||||
param.setDeviceType("DDJ");
|
||||
List<BasFaultRecord> basFaultRecords = basFaultRecordService.selectBasFaultRecordList(param);
|
||||
if (CollUtil.isNotEmpty(basFaultRecords)) {
|
||||
BasFaultRecord faultRecord = basFaultRecords.get(0);
|
||||
faultRecord.setJobId("1");
|
||||
faultRecord.setFinishTime(DateUtil.formatDateTime(DateUtil.date()));
|
||||
basFaultRecordService.updateBasFaultRecord(faultRecord);
|
||||
}
|
||||
}
|
||||
}
|
||||
try {
|
||||
Thread.sleep(1500);
|
||||
|
||||
@@ -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