change - 添加设备报警记录

master
yinq 6 months ago
parent 84944acb80
commit c9e27123dd

@ -0,0 +1,101 @@
package com.aucma.report.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.aucma.common.utils.DateUtils;
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.aucma.common.annotation.Log;
import com.aucma.common.core.controller.BaseController;
import com.aucma.common.core.domain.AjaxResult;
import com.aucma.common.enums.BusinessType;
import com.aucma.report.domain.DeviceAlarmRecord;
import com.aucma.report.service.IDeviceAlarmRecordService;
import com.aucma.common.utils.poi.ExcelUtil;
import com.aucma.common.core.page.TableDataInfo;
/**
* Controller
*
* @author Yinq
* @date 2024-03-26
*/
@RestController
@RequestMapping("/report/deviceAlarmRecord")
public class DeviceAlarmRecordController extends BaseController {
@Autowired
private IDeviceAlarmRecordService deviceAlarmRecordService;
/**
*
*/
@PreAuthorize("@ss.hasPermi('report:deviceAlarmRecord:list')")
@GetMapping("/list")
public TableDataInfo list(DeviceAlarmRecord deviceAlarmRecord) {
startPage();
List<DeviceAlarmRecord> list = deviceAlarmRecordService.selectDeviceAlarmRecordList(deviceAlarmRecord);
return getDataTable(list);
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('report:deviceAlarmRecord:export')")
@Log(title = "设备报警记录", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, DeviceAlarmRecord deviceAlarmRecord) {
List<DeviceAlarmRecord> list = deviceAlarmRecordService.selectDeviceAlarmRecordList(deviceAlarmRecord);
ExcelUtil<DeviceAlarmRecord> util = new ExcelUtil<DeviceAlarmRecord>(DeviceAlarmRecord.class);
util.exportExcel(response, list, "设备报警记录数据");
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('report:deviceAlarmRecord:query')")
@GetMapping(value = "/{objId}")
public AjaxResult getInfo(@PathVariable("objId") Long objId) {
return success(deviceAlarmRecordService.selectDeviceAlarmRecordByObjId(objId));
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('report:deviceAlarmRecord:add')")
@Log(title = "设备报警记录", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody DeviceAlarmRecord deviceAlarmRecord) {
deviceAlarmRecord.setCreatedBy(getUsername());
deviceAlarmRecord.setCreatedTime(DateUtils.getNowDate());
return toAjax(deviceAlarmRecordService.insertDeviceAlarmRecord(deviceAlarmRecord));
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('report:deviceAlarmRecord:edit')")
@Log(title = "设备报警记录", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody DeviceAlarmRecord deviceAlarmRecord) {
return toAjax(deviceAlarmRecordService.updateDeviceAlarmRecord(deviceAlarmRecord));
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('report:deviceAlarmRecord:remove')")
@Log(title = "设备报警记录", businessType = BusinessType.DELETE)
@DeleteMapping("/{objIds}")
public AjaxResult remove(@PathVariable Long[] objIds) {
return toAjax(deviceAlarmRecordService.deleteDeviceAlarmRecordByObjIds(objIds));
}
}

@ -0,0 +1,177 @@
package com.aucma.report.domain;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.aucma.common.annotation.Excel;
import com.aucma.common.core.domain.BaseEntity;
/**
* device_alarm_record
*
* @author Yinq
* @date 2024-03-26
*/
public class DeviceAlarmRecord extends BaseEntity {
private static final long serialVersionUID = 1L;
/**
*
*/
private Long objId;
/**
*
*/
@Excel(name = "设备编号")
private String deviceCode;
/**
*
*/
@Excel(name = "设备名称")
private String deviceName;
/**
*
*/
@Excel(name = "设备类型")
private String deviceType;
/**
*
*/
@Excel(name = "报警信息")
private String alarmInfo;
/**
*
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "报警时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
private Date alarmTime;
/**
*
*/
@Excel(name = "标识")
private Long isFlag;
/**
*
*/
@Excel(name = "创建人")
private String createdBy;
/**
*
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "创建时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
private Date createdTime;
/**
*
*/
@Excel(name = "批次标识")
private String batchId;
public void setObjId(Long objId) {
this.objId = objId;
}
public Long getObjId() {
return objId;
}
public void setDeviceCode(String deviceCode) {
this.deviceCode = deviceCode;
}
public String getDeviceCode() {
return deviceCode;
}
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 setAlarmInfo(String alarmInfo) {
this.alarmInfo = alarmInfo;
}
public String getAlarmInfo() {
return alarmInfo;
}
public void setAlarmTime(Date alarmTime) {
this.alarmTime = alarmTime;
}
public Date getAlarmTime() {
return alarmTime;
}
public void setIsFlag(Long isFlag) {
this.isFlag = isFlag;
}
public Long getIsFlag() {
return isFlag;
}
public void setCreatedBy(String createdBy) {
this.createdBy = createdBy;
}
public String getCreatedBy() {
return createdBy;
}
public void setCreatedTime(Date createdTime) {
this.createdTime = createdTime;
}
public Date getCreatedTime() {
return createdTime;
}
public void setBatchId(String batchId) {
this.batchId = batchId;
}
public String getBatchId() {
return batchId;
}
@Override
public String toString() {
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
.append("objId", getObjId())
.append("deviceCode", getDeviceCode())
.append("deviceName", getDeviceName())
.append("deviceType", getDeviceType())
.append("alarmInfo", getAlarmInfo())
.append("alarmTime", getAlarmTime())
.append("remark", getRemark())
.append("isFlag", getIsFlag())
.append("createdBy", getCreatedBy())
.append("createdTime", getCreatedTime())
.append("batchId", getBatchId())
.toString();
}
}

@ -0,0 +1,61 @@
package com.aucma.report.mapper;
import java.util.List;
import com.aucma.report.domain.DeviceAlarmRecord;
/**
* Mapper
*
* @author Yinq
* @date 2024-03-26
*/
public interface DeviceAlarmRecordMapper
{
/**
*
*
* @param objId
* @return
*/
public DeviceAlarmRecord selectDeviceAlarmRecordByObjId(Long objId);
/**
*
*
* @param deviceAlarmRecord
* @return
*/
public List<DeviceAlarmRecord> selectDeviceAlarmRecordList(DeviceAlarmRecord deviceAlarmRecord);
/**
*
*
* @param deviceAlarmRecord
* @return
*/
public int insertDeviceAlarmRecord(DeviceAlarmRecord deviceAlarmRecord);
/**
*
*
* @param deviceAlarmRecord
* @return
*/
public int updateDeviceAlarmRecord(DeviceAlarmRecord deviceAlarmRecord);
/**
*
*
* @param objId
* @return
*/
public int deleteDeviceAlarmRecordByObjId(Long objId);
/**
*
*
* @param objIds
* @return
*/
public int deleteDeviceAlarmRecordByObjIds(Long[] objIds);
}

@ -0,0 +1,61 @@
package com.aucma.report.service;
import java.util.List;
import com.aucma.report.domain.DeviceAlarmRecord;
/**
* Service
*
* @author Yinq
* @date 2024-03-26
*/
public interface IDeviceAlarmRecordService
{
/**
*
*
* @param objId
* @return
*/
public DeviceAlarmRecord selectDeviceAlarmRecordByObjId(Long objId);
/**
*
*
* @param deviceAlarmRecord
* @return
*/
public List<DeviceAlarmRecord> selectDeviceAlarmRecordList(DeviceAlarmRecord deviceAlarmRecord);
/**
*
*
* @param deviceAlarmRecord
* @return
*/
public int insertDeviceAlarmRecord(DeviceAlarmRecord deviceAlarmRecord);
/**
*
*
* @param deviceAlarmRecord
* @return
*/
public int updateDeviceAlarmRecord(DeviceAlarmRecord deviceAlarmRecord);
/**
*
*
* @param objIds
* @return
*/
public int deleteDeviceAlarmRecordByObjIds(Long[] objIds);
/**
*
*
* @param objId
* @return
*/
public int deleteDeviceAlarmRecordByObjId(Long objId);
}

@ -0,0 +1,93 @@
package com.aucma.report.service.impl;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.aucma.report.mapper.DeviceAlarmRecordMapper;
import com.aucma.report.domain.DeviceAlarmRecord;
import com.aucma.report.service.IDeviceAlarmRecordService;
/**
* Service
*
* @author Yinq
* @date 2024-03-26
*/
@Service
public class DeviceAlarmRecordServiceImpl implements IDeviceAlarmRecordService
{
@Autowired
private DeviceAlarmRecordMapper deviceAlarmRecordMapper;
/**
*
*
* @param objId
* @return
*/
@Override
public DeviceAlarmRecord selectDeviceAlarmRecordByObjId(Long objId)
{
return deviceAlarmRecordMapper.selectDeviceAlarmRecordByObjId(objId);
}
/**
*
*
* @param deviceAlarmRecord
* @return
*/
@Override
public List<DeviceAlarmRecord> selectDeviceAlarmRecordList(DeviceAlarmRecord deviceAlarmRecord)
{
return deviceAlarmRecordMapper.selectDeviceAlarmRecordList(deviceAlarmRecord);
}
/**
*
*
* @param deviceAlarmRecord
* @return
*/
@Override
public int insertDeviceAlarmRecord(DeviceAlarmRecord deviceAlarmRecord)
{
return deviceAlarmRecordMapper.insertDeviceAlarmRecord(deviceAlarmRecord);
}
/**
*
*
* @param deviceAlarmRecord
* @return
*/
@Override
public int updateDeviceAlarmRecord(DeviceAlarmRecord deviceAlarmRecord)
{
return deviceAlarmRecordMapper.updateDeviceAlarmRecord(deviceAlarmRecord);
}
/**
*
*
* @param objIds
* @return
*/
@Override
public int deleteDeviceAlarmRecordByObjIds(Long[] objIds)
{
return deviceAlarmRecordMapper.deleteDeviceAlarmRecordByObjIds(objIds);
}
/**
*
*
* @param objId
* @return
*/
@Override
public int deleteDeviceAlarmRecordByObjId(Long objId)
{
return deviceAlarmRecordMapper.deleteDeviceAlarmRecordByObjId(objId);
}
}

@ -0,0 +1,136 @@
<?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.aucma.report.mapper.DeviceAlarmRecordMapper">
<resultMap type="DeviceAlarmRecord" id="DeviceAlarmRecordResult">
<result property="objId" column="obj_id"/>
<result property="deviceCode" column="device_code"/>
<result property="deviceName" column="device_name"/>
<result property="deviceType" column="device_type"/>
<result property="alarmInfo" column="alarm_info"/>
<result property="alarmTime" column="alarm_time"/>
<result property="remark" column="remark"/>
<result property="isFlag" column="is_flag"/>
<result property="createdBy" column="created_by"/>
<result property="createdTime" column="created_time"/>
<result property="batchId" column="batch_id"/>
<result property="paramCode" column="param_code"/>
<result property="paramValue" column="param_value"/>
</resultMap>
<sql id="selectDeviceAlarmRecordVo">
select obj_id,
device_code,
device_name,
device_type,
alarm_info,
alarm_time,
remark,
is_flag,
created_by,
created_time,
batch_id,
param_code,
param_value
from record_alarm_device
</sql>
<select id="selectDeviceAlarmRecordList" parameterType="DeviceAlarmRecord" resultMap="DeviceAlarmRecordResult">
<include refid="selectDeviceAlarmRecordVo"/>
<where>
<if test="deviceCode != null and deviceCode != ''">and device_code = #{deviceCode}</if>
<if test="deviceName != null and deviceName != ''">and device_name like concat(concat('%', #{deviceName}),
'%')
</if>
<if test="deviceType != null and deviceType != ''">and device_type = #{deviceType}</if>
<if test="alarmInfo != null and alarmInfo != ''">and alarm_info = #{alarmInfo}</if>
<if test="params.beginAlarmTime != null and params.beginAlarmTime != '' and params.endAlarmTime != null and params.endAlarmTime != ''">
and alarm_time between to_date(#{params.beginAlarmTime}, 'yyyy-mm-dd hh24:mi:ss') and
to_date(#{params.endAlarmTime}, 'yyyy-mm-dd hh24:mi:ss')
</if>
<if test="isFlag != null ">and is_flag = #{isFlag}</if>
<if test="createdBy != null and createdBy != ''">and created_by = #{createdBy}</if>
<if test="createdTime != null ">and created_time = #{createdTime}</if>
<if test="batchId != null and batchId != ''">and batch_id = #{batchId}</if>
<if test="paramCode != null and paramCode != ''"> and param_code = #{paramCode}</if>
<if test="paramValue != null and paramValue != ''"> and param_value = #{paramValue}</if>
</where>
order by alarm_time desc
</select>
<select id="selectDeviceAlarmRecordByObjId" parameterType="Long" resultMap="DeviceAlarmRecordResult">
<include refid="selectDeviceAlarmRecordVo"/>
where obj_id = #{objId}
</select>
<insert id="insertDeviceAlarmRecord" parameterType="DeviceAlarmRecord">
<selectKey keyProperty="objId" resultType="long" order="BEFORE">
SELECT seq_device_alarm_record.NEXTVAL as objId FROM DUAL
</selectKey>
insert into RECORD_ALARM_DEVICE
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="objId != null">obj_id,</if>
<if test="deviceCode != null">device_code,</if>
<if test="deviceName != null">device_name,</if>
<if test="deviceType != null">device_type,</if>
<if test="alarmInfo != null">alarm_info,</if>
<if test="alarmTime != null">alarm_time,</if>
<if test="remark != null">remark,</if>
<if test="isFlag != null">is_flag,</if>
<if test="createdBy != null">created_by,</if>
<if test="createdTime != null">created_time,</if>
<if test="batchId != null">batch_id,</if>
<if test="paramCode != null">param_code,</if>
<if test="paramValue != null">param_value,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="objId != null">#{objId},</if>
<if test="deviceCode != null">#{deviceCode},</if>
<if test="deviceName != null">#{deviceName},</if>
<if test="deviceType != null">#{deviceType},</if>
<if test="alarmInfo != null">#{alarmInfo},</if>
<if test="alarmTime != null">#{alarmTime},</if>
<if test="remark != null">#{remark},</if>
<if test="isFlag != null">#{isFlag},</if>
<if test="createdBy != null">#{createdBy},</if>
<if test="createdTime != null">#{createdTime},</if>
<if test="batchId != null">#{batchId},</if>
<if test="paramCode != null">#{paramCode},</if>
<if test="paramValue != null">#{paramValue},</if>
</trim>
</insert>
<update id="updateDeviceAlarmRecord" parameterType="DeviceAlarmRecord">
update RECORD_ALARM_DEVICE
<trim prefix="SET" suffixOverrides=",">
<if test="deviceCode != null">device_code = #{deviceCode},</if>
<if test="deviceName != null">device_name = #{deviceName},</if>
<if test="deviceType != null">device_type = #{deviceType},</if>
<if test="alarmInfo != null">alarm_info = #{alarmInfo},</if>
<if test="alarmTime != null">alarm_time = #{alarmTime},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="isFlag != null">is_flag = #{isFlag},</if>
<if test="createdBy != null">created_by = #{createdBy},</if>
<if test="createdTime != null">created_time = #{createdTime},</if>
<if test="batchId != null">batch_id = #{batchId},</if>
<if test="paramCode != null">param_code = #{paramCode},</if>
<if test="paramValue != null">param_value = #{paramValue},</if>
</trim>
where obj_id = #{objId}
</update>
<delete id="deleteDeviceAlarmRecordByObjId" parameterType="Long">
delete
from RECORD_ALARM_DEVICE
where obj_id = #{objId}
</delete>
<delete id="deleteDeviceAlarmRecordByObjIds" parameterType="String">
delete from RECORD_ALARM_DEVICE where obj_id in
<foreach item="objId" collection="array" open="(" separator="," close=")">
#{objId}
</foreach>
</delete>
</mapper>
Loading…
Cancel
Save