Commit 3b37c54f authored by 耿迪迪's avatar 耿迪迪

燃气设备监控配置 gengdidi

parent e4063260
package com.zehong.web.controller.device;
import java.util.List;
import com.zehong.system.domain.form.RelationTMonitorDevice;
import com.zehong.system.domain.form.TMonitorDeviceFrom;
import com.zehong.system.service.ITDeviceInfoService;
import com.zehong.system.service.impl.TPipeServiceImpl;
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.zehong.common.annotation.Log;
import com.zehong.common.core.controller.BaseController;
import com.zehong.common.core.domain.AjaxResult;
import com.zehong.common.enums.BusinessType;
import com.zehong.system.domain.TMonitorDevice;
import com.zehong.system.service.ITMonitorDeviceService;
import com.zehong.common.utils.poi.ExcelUtil;
import com.zehong.common.core.page.TableDataInfo;
/**
* 设备监控Controller
*
* @author zehong
* @date 2021-08-05
*/
@RestController
@RequestMapping("/system/device")
public class TMonitorDeviceController extends BaseController
{
@Autowired
private ITMonitorDeviceService tMonitorDeviceService;
@Autowired
private ITDeviceInfoService itDeviceInfoService;
@Autowired
private TPipeServiceImpl tPipeService;
/**
* 查询设备监控列表
*/
@PreAuthorize("@ss.hasPermi('system:device:list')")
@GetMapping("/list")
public TableDataInfo list(TMonitorDevice tMonitorDevice)
{
startPage();
List<TMonitorDevice> list = tMonitorDeviceService.selectTMonitorDeviceList(tMonitorDevice);
for(TMonitorDevice device: list){
device.setDeviceName(itDeviceInfoService.selectTDeviceInfoById(device.getDeviceId().intValue()).getDeviceName());
device.setRelationDeviceName(itDeviceInfoService.selectTDeviceInfoById(device.getRelationDeviceId().intValue()).getDeviceName());
device.setRelationPipeName(tPipeService.selectTPipeById(device.getRelationPipeId().intValue()).getPipeName());
}
return getDataTable(list);
}
/**
* 导出设备监控列表
*/
@PreAuthorize("@ss.hasPermi('system:device:export')")
@Log(title = "设备监控", businessType = BusinessType.EXPORT)
@GetMapping("/export")
public AjaxResult export(TMonitorDevice tMonitorDevice)
{
List<TMonitorDevice> list = tMonitorDeviceService.selectTMonitorDeviceList(tMonitorDevice);
ExcelUtil<TMonitorDevice> util = new ExcelUtil<TMonitorDevice>(TMonitorDevice.class);
return util.exportExcel(list, "设备监控数据");
}
/**
* 获取设备监控详细信息
*/
@PreAuthorize("@ss.hasPermi('system:device:query')")
@GetMapping(value = "/{monitorId}")
public AjaxResult getInfo(@PathVariable("monitorId") Long monitorId)
{
return AjaxResult.success(tMonitorDeviceService.selectTMonitorDeviceById(monitorId));
}
/**
* 新增设备监控
*/
@PreAuthorize("@ss.hasPermi('system:device:add')")
@Log(title = "设备监控", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody TMonitorDevice tMonitorDevice)
{
return toAjax(tMonitorDeviceService.insertTMonitorDevice(tMonitorDevice));
}
@PostMapping("/batchAdd")
public AjaxResult batchAdd(@RequestBody TMonitorDeviceFrom tMonitorDeviceFrom){
for(RelationTMonitorDevice relationTMonitorDevice : tMonitorDeviceFrom.getRelationDevices()){
TMonitorDevice tMonitorDevice = new TMonitorDevice();
tMonitorDevice.setDeviceId(tMonitorDeviceFrom.getDeviceId());
tMonitorDevice.setDeviceThreshold(tMonitorDeviceFrom.getDeviceThreshold());
tMonitorDevice.setRelationDeviceId(relationTMonitorDevice.getRelationDeviceId());
tMonitorDevice.setRelationDeviceThreshold(relationTMonitorDevice.getRelationDeviceThreshold());
tMonitorDevice.setRelationPipeId(relationTMonitorDevice.getRelationPipeId());
tMonitorDevice.setRelationPipeThreshold(relationTMonitorDevice.getRelationPipeThreshold());
tMonitorDeviceService.insertTMonitorDevice(tMonitorDevice);
}
return AjaxResult.success();
}
/**
* 修改设备监控
*/
@PreAuthorize("@ss.hasPermi('system:device:edit')")
@Log(title = "设备监控", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody TMonitorDevice tMonitorDevice)
{
return toAjax(tMonitorDeviceService.updateTMonitorDevice(tMonitorDevice));
}
/**
* 删除设备监控
*/
@PreAuthorize("@ss.hasPermi('system:device:remove')")
@Log(title = "设备监控", businessType = BusinessType.DELETE)
@DeleteMapping("/{monitorIds}")
public AjaxResult remove(@PathVariable Long[] monitorIds)
{
return toAjax(tMonitorDeviceService.deleteTMonitorDeviceByIds(monitorIds));
}
}
package com.zehong.system.domain;
import java.math.BigDecimal;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.zehong.common.annotation.Excel;
import com.zehong.common.core.domain.BaseEntity;
/**
* 设备监控对象 t_monitor_device
*
* @author zehong
* @date 2021-08-05
*/
public class TMonitorDevice extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 设备监控id */
private Long monitorId;
/** 设备id */
@Excel(name = "设备id")
private Long deviceId;
/** 设备阈值 */
@Excel(name = "设备阈值")
private BigDecimal deviceThreshold;
/** 关联管道id */
@Excel(name = "关联管道id")
private Long relationPipeId;
/** 关联管道阈值 */
@Excel(name = "关联管道阈值")
private BigDecimal relationPipeThreshold;
/** 关联设备id */
@Excel(name = "关联设备id")
private Long relationDeviceId;
/** 关联设备阈值 */
@Excel(name = "关联设备阈值")
private BigDecimal relationDeviceThreshold;
private String relationPipeName;
private String deviceName;
private String relationDeviceName;
public String getRelationPipeName() {
return relationPipeName;
}
public void setRelationPipeName(String relationPipeName) {
this.relationPipeName = relationPipeName;
}
public String getDeviceName() {
return deviceName;
}
public void setDeviceName(String deviceName) {
this.deviceName = deviceName;
}
public String getRelationDeviceName() {
return relationDeviceName;
}
public void setRelationDeviceName(String relationDeviceName) {
this.relationDeviceName = relationDeviceName;
}
public void setMonitorId(Long monitorId)
{
this.monitorId = monitorId;
}
public Long getMonitorId()
{
return monitorId;
}
public void setDeviceId(Long deviceId)
{
this.deviceId = deviceId;
}
public Long getDeviceId()
{
return deviceId;
}
public void setDeviceThreshold(BigDecimal deviceThreshold)
{
this.deviceThreshold = deviceThreshold;
}
public BigDecimal getDeviceThreshold()
{
return deviceThreshold;
}
public void setRelationPipeId(Long relationPipeId)
{
this.relationPipeId = relationPipeId;
}
public Long getRelationPipeId()
{
return relationPipeId;
}
public void setRelationPipeThreshold(BigDecimal relationPipeThreshold)
{
this.relationPipeThreshold = relationPipeThreshold;
}
public BigDecimal getRelationPipeThreshold()
{
return relationPipeThreshold;
}
public void setRelationDeviceId(Long relationDeviceId)
{
this.relationDeviceId = relationDeviceId;
}
public Long getRelationDeviceId()
{
return relationDeviceId;
}
public void setRelationDeviceThreshold(BigDecimal relationDeviceThreshold)
{
this.relationDeviceThreshold = relationDeviceThreshold;
}
public BigDecimal getRelationDeviceThreshold()
{
return relationDeviceThreshold;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("monitorId", getMonitorId())
.append("deviceId", getDeviceId())
.append("deviceThreshold", getDeviceThreshold())
.append("relationPipeId", getRelationPipeId())
.append("relationPipeThreshold", getRelationPipeThreshold())
.append("relationDeviceId", getRelationDeviceId())
.append("relationDeviceThreshold", getRelationDeviceThreshold())
.append("createTime", getCreateTime())
.append("updateTime", getUpdateTime())
.toString();
}
}
package com.zehong.system.domain.form;
import java.math.BigDecimal;
public class RelationTMonitorDevice {
/** 关联管道id */
private Long relationPipeId;
/** 关联管道阈值 */
private BigDecimal relationPipeThreshold;
/** 关联设备id */
private Long relationDeviceId;
/** 关联设备阈值 */
private BigDecimal relationDeviceThreshold;
public Long getRelationPipeId() {
return relationPipeId;
}
public void setRelationPipeId(Long relationPipeId) {
this.relationPipeId = relationPipeId;
}
public BigDecimal getRelationPipeThreshold() {
return relationPipeThreshold;
}
public void setRelationPipeThreshold(BigDecimal relationPipeThreshold) {
this.relationPipeThreshold = relationPipeThreshold;
}
public Long getRelationDeviceId() {
return relationDeviceId;
}
public void setRelationDeviceId(Long relationDeviceId) {
this.relationDeviceId = relationDeviceId;
}
public BigDecimal getRelationDeviceThreshold() {
return relationDeviceThreshold;
}
public void setRelationDeviceThreshold(BigDecimal relationDeviceThreshold) {
this.relationDeviceThreshold = relationDeviceThreshold;
}
}
package com.zehong.system.domain.form;
import java.math.BigDecimal;
import java.util.List;
public class TMonitorDeviceFrom {
/** 设备id */
private Long deviceId;
/** 设备阈值 */
private BigDecimal deviceThreshold;
private List<RelationTMonitorDevice> relationDevices;
public Long getDeviceId() {
return deviceId;
}
public void setDeviceId(Long deviceId) {
this.deviceId = deviceId;
}
public BigDecimal getDeviceThreshold() {
return deviceThreshold;
}
public void setDeviceThreshold(BigDecimal deviceThreshold) {
this.deviceThreshold = deviceThreshold;
}
public List<RelationTMonitorDevice> getRelationDevices() {
return relationDevices;
}
public void setRelationDevices(List<RelationTMonitorDevice> relationDevices) {
this.relationDevices = relationDevices;
}
}
package com.zehong.system.mapper;
import java.util.List;
import com.zehong.system.domain.TMonitorDevice;
/**
* 设备监控Mapper接口
*
* @author zehong
* @date 2021-08-05
*/
public interface TMonitorDeviceMapper
{
/**
* 查询设备监控
*
* @param monitorId 设备监控ID
* @return 设备监控
*/
public TMonitorDevice selectTMonitorDeviceById(Long monitorId);
/**
* 查询设备监控列表
*
* @param tMonitorDevice 设备监控
* @return 设备监控集合
*/
public List<TMonitorDevice> selectTMonitorDeviceList(TMonitorDevice tMonitorDevice);
/**
* 新增设备监控
*
* @param tMonitorDevice 设备监控
* @return 结果
*/
public int insertTMonitorDevice(TMonitorDevice tMonitorDevice);
/**
* 修改设备监控
*
* @param tMonitorDevice 设备监控
* @return 结果
*/
public int updateTMonitorDevice(TMonitorDevice tMonitorDevice);
/**
* 删除设备监控
*
* @param monitorId 设备监控ID
* @return 结果
*/
public int deleteTMonitorDeviceById(Long monitorId);
/**
* 批量删除设备监控
*
* @param monitorIds 需要删除的数据ID
* @return 结果
*/
public int deleteTMonitorDeviceByIds(Long[] monitorIds);
}
package com.zehong.system.service;
import java.util.List;
import com.zehong.system.domain.TMonitorDevice;
/**
* 设备监控Service接口
*
* @author zehong
* @date 2021-08-05
*/
public interface ITMonitorDeviceService
{
/**
* 查询设备监控
*
* @param monitorId 设备监控ID
* @return 设备监控
*/
public TMonitorDevice selectTMonitorDeviceById(Long monitorId);
/**
* 查询设备监控列表
*
* @param tMonitorDevice 设备监控
* @return 设备监控集合
*/
public List<TMonitorDevice> selectTMonitorDeviceList(TMonitorDevice tMonitorDevice);
/**
* 新增设备监控
*
* @param tMonitorDevice 设备监控
* @return 结果
*/
public int insertTMonitorDevice(TMonitorDevice tMonitorDevice);
/**
* 修改设备监控
*
* @param tMonitorDevice 设备监控
* @return 结果
*/
public int updateTMonitorDevice(TMonitorDevice tMonitorDevice);
/**
* 批量删除设备监控
*
* @param monitorIds 需要删除的设备监控ID
* @return 结果
*/
public int deleteTMonitorDeviceByIds(Long[] monitorIds);
/**
* 删除设备监控信息
*
* @param monitorId 设备监控ID
* @return 结果
*/
public int deleteTMonitorDeviceById(Long monitorId);
}
package com.zehong.system.service.impl;
import java.util.List;
import com.zehong.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.zehong.system.mapper.TMonitorDeviceMapper;
import com.zehong.system.domain.TMonitorDevice;
import com.zehong.system.service.ITMonitorDeviceService;
/**
* 设备监控Service业务层处理
*
* @author zehong
* @date 2021-08-05
*/
@Service
public class TMonitorDeviceServiceImpl implements ITMonitorDeviceService
{
@Autowired
private TMonitorDeviceMapper tMonitorDeviceMapper;
/**
* 查询设备监控
*
* @param monitorId 设备监控ID
* @return 设备监控
*/
@Override
public TMonitorDevice selectTMonitorDeviceById(Long monitorId)
{
return tMonitorDeviceMapper.selectTMonitorDeviceById(monitorId);
}
/**
* 查询设备监控列表
*
* @param tMonitorDevice 设备监控
* @return 设备监控
*/
@Override
public List<TMonitorDevice> selectTMonitorDeviceList(TMonitorDevice tMonitorDevice)
{
return tMonitorDeviceMapper.selectTMonitorDeviceList(tMonitorDevice);
}
/**
* 新增设备监控
*
* @param tMonitorDevice 设备监控
* @return 结果
*/
@Override
public int insertTMonitorDevice(TMonitorDevice tMonitorDevice)
{
tMonitorDevice.setCreateTime(DateUtils.getNowDate());
return tMonitorDeviceMapper.insertTMonitorDevice(tMonitorDevice);
}
/**
* 修改设备监控
*
* @param tMonitorDevice 设备监控
* @return 结果
*/
@Override
public int updateTMonitorDevice(TMonitorDevice tMonitorDevice)
{
tMonitorDevice.setUpdateTime(DateUtils.getNowDate());
return tMonitorDeviceMapper.updateTMonitorDevice(tMonitorDevice);
}
/**
* 批量删除设备监控
*
* @param monitorIds 需要删除的设备监控ID
* @return 结果
*/
@Override
public int deleteTMonitorDeviceByIds(Long[] monitorIds)
{
return tMonitorDeviceMapper.deleteTMonitorDeviceByIds(monitorIds);
}
/**
* 删除设备监控信息
*
* @param monitorId 设备监控ID
* @return 结果
*/
@Override
public int deleteTMonitorDeviceById(Long monitorId)
{
return tMonitorDeviceMapper.deleteTMonitorDeviceById(monitorId);
}
}
<?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.zehong.system.mapper.TMonitorDeviceMapper">
<resultMap type="TMonitorDevice" id="TMonitorDeviceResult">
<result property="monitorId" column="monitor_id" />
<result property="deviceId" column="device_id" />
<result property="deviceThreshold" column="device_threshold" />
<result property="relationPipeId" column="relation_pipe_id" />
<result property="relationPipeThreshold" column="relation_pipe_threshold" />
<result property="relationDeviceId" column="relation_device_id" />
<result property="relationDeviceThreshold" column="relation_device_threshold" />
<result property="createTime" column="create_time" />
<result property="updateTime" column="update_time" />
</resultMap>
<sql id="selectTMonitorDeviceVo">
select monitor_id, device_id, device_threshold, relation_pipe_id, relation_pipe_threshold, relation_device_id, relation_device_threshold, create_time, update_time from t_monitor_device
</sql>
<select id="selectTMonitorDeviceList" parameterType="TMonitorDevice" resultMap="TMonitorDeviceResult">
<include refid="selectTMonitorDeviceVo"/>
<where>
<if test="deviceId != null "> and device_id = #{deviceId}</if>
<if test="deviceThreshold != null "> and device_threshold = #{deviceThreshold}</if>
<if test="relationPipeId != null "> and relation_pipe_id = #{relationPipeId}</if>
<if test="relationPipeThreshold != null "> and relation_pipe_threshold = #{relationPipeThreshold}</if>
<if test="relationDeviceId != null "> and relation_device_id = #{relationDeviceId}</if>
<if test="relationDeviceThreshold != null "> and relation_device_threshold = #{relationDeviceThreshold}</if>
</where>
</select>
<select id="selectTMonitorDeviceById" parameterType="Long" resultMap="TMonitorDeviceResult">
<include refid="selectTMonitorDeviceVo"/>
where monitor_id = #{monitorId}
</select>
<insert id="insertTMonitorDevice" parameterType="TMonitorDevice" useGeneratedKeys="true" keyProperty="monitorId">
insert into t_monitor_device
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="deviceId != null">device_id,</if>
<if test="deviceThreshold != null">device_threshold,</if>
<if test="relationPipeId != null">relation_pipe_id,</if>
<if test="relationPipeThreshold != null">relation_pipe_threshold,</if>
<if test="relationDeviceId != null">relation_device_id,</if>
<if test="relationDeviceThreshold != null">relation_device_threshold,</if>
<if test="createTime != null">create_time,</if>
<if test="updateTime != null">update_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="deviceId != null">#{deviceId},</if>
<if test="deviceThreshold != null">#{deviceThreshold},</if>
<if test="relationPipeId != null">#{relationPipeId},</if>
<if test="relationPipeThreshold != null">#{relationPipeThreshold},</if>
<if test="relationDeviceId != null">#{relationDeviceId},</if>
<if test="relationDeviceThreshold != null">#{relationDeviceThreshold},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateTime != null">#{updateTime},</if>
</trim>
</insert>
<update id="updateTMonitorDevice" parameterType="TMonitorDevice">
update t_monitor_device
<trim prefix="SET" suffixOverrides=",">
<if test="deviceId != null">device_id = #{deviceId},</if>
<if test="deviceThreshold != null">device_threshold = #{deviceThreshold},</if>
<if test="relationPipeId != null">relation_pipe_id = #{relationPipeId},</if>
<if test="relationPipeThreshold != null">relation_pipe_threshold = #{relationPipeThreshold},</if>
<if test="relationDeviceId != null">relation_device_id = #{relationDeviceId},</if>
<if test="relationDeviceThreshold != null">relation_device_threshold = #{relationDeviceThreshold},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
</trim>
where monitor_id = #{monitorId}
</update>
<delete id="deleteTMonitorDeviceById" parameterType="Long">
delete from t_monitor_device where monitor_id = #{monitorId}
</delete>
<delete id="deleteTMonitorDeviceByIds" parameterType="String">
delete from t_monitor_device where monitor_id in
<foreach item="monitorId" collection="array" open="(" separator="," close=")">
#{monitorId}
</foreach>
</delete>
</mapper>
\ No newline at end of file
import request from '@/utils/request'
// 查询设备监控列表
export function listDevice(query) {
return request({
url: '/system/device/list',
method: 'get',
params: query
})
}
// 查询设备监控详细
export function getDevice(monitorId) {
return request({
url: '/system/device/' + monitorId,
method: 'get'
})
}
// 新增设备监控
export function addDevice(data) {
return request({
url: '/system/device',
method: 'post',
data: data
})
}
export function batchAdd(data) {
return request({
url: '/system/device/batchAdd',
method: 'post',
data: data
})
}
// 修改设备监控
export function updateDevice(data) {
return request({
url: '/system/device',
method: 'put',
data: data
})
}
// 删除设备监控
export function delDevice(monitorId) {
return request({
url: '/system/device/' + monitorId,
method: 'delete'
})
}
// 导出设备监控
export function exportDevice(query) {
return request({
url: '/system/device/export',
method: 'get',
params: query
})
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment