Commit 33c4bddc authored by 吴卿华's avatar 吴卿华

增加 报警信息管理 下级设备信息查询 下级设备信息添加

parent 94583016
......@@ -7,7 +7,9 @@ import com.zehong.common.core.domain.AjaxResult;
import com.zehong.common.core.page.TableDataInfo;
import com.zehong.common.enums.BusinessType;
import com.zehong.common.utils.poi.ExcelUtil;
import com.zehong.system.domain.EquipmentForm;
import com.zehong.system.domain.TDeviceInfo;
import com.zehong.system.domain.TDeviceInformation;
import com.zehong.system.domain.vo.DeviceInfoVo;
import com.zehong.system.service.ITDeviceInfoService;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -19,14 +21,13 @@ import java.util.Map;
/**
* 设备信息Controller
*
*
* @author zehong
* @date 2021-07-09
*/
@RestController
@RequestMapping("/device/deviceInfo")
public class TDeviceInfoController extends BaseController
{
public class TDeviceInfoController extends BaseController {
@Autowired
private ITDeviceInfoService tDeviceInfoService;
......@@ -35,8 +36,7 @@ public class TDeviceInfoController extends BaseController
*/
@PreAuthorize("@ss.hasPermi('device:deviceInfo:list')")
@GetMapping("/list")
public TableDataInfo list(TDeviceInfo tDeviceInfo)
{
public TableDataInfo list(TDeviceInfo tDeviceInfo) {
startPage();
PageInfo<DeviceInfoVo> page = tDeviceInfoService.selectTDeviceInfoPage(tDeviceInfo);
return getDataTable(page);
......@@ -44,11 +44,12 @@ public class TDeviceInfoController extends BaseController
/**
* 获取所有设备信息
*
* @param tDeviceInfo
* @return
*/
@GetMapping("/deviceListInfo")
public AjaxResult deviceListInfo(TDeviceInfo tDeviceInfo){
public AjaxResult deviceListInfo(TDeviceInfo tDeviceInfo) {
return AjaxResult.success(tDeviceInfoService.selectTDeviceInfoList(tDeviceInfo));
}
......@@ -56,8 +57,7 @@ public class TDeviceInfoController extends BaseController
* 获取设备下拉树列表
*/
@PutMapping("/deviceTree")
public AjaxResult deviceTree(@RequestBody Map<Object, List> param)
{
public AjaxResult deviceTree(@RequestBody Map<Object, List> param) {
return AjaxResult.success(tDeviceInfoService.buildDeviceTreeSelect(param));
}
......@@ -65,8 +65,7 @@ public class TDeviceInfoController extends BaseController
* 获取设备树
*/
@GetMapping("/deviceNodeTree")
public AjaxResult deviceNodeTree() throws Exception
{
public AjaxResult deviceNodeTree() throws Exception {
List<Map<Object, Object>> list = null;
try {
list = tDeviceInfoService.buildDeviceTree();
......@@ -84,8 +83,7 @@ public class TDeviceInfoController extends BaseController
@PreAuthorize("@ss.hasPermi('device:deviceInfo:export')")
@Log(title = "设备信息", businessType = BusinessType.EXPORT)
@GetMapping("/export")
public AjaxResult export(TDeviceInfo tDeviceInfo)
{
public AjaxResult export(TDeviceInfo tDeviceInfo) {
List<DeviceInfoVo> list = tDeviceInfoService.selectTDeviceInfoList(tDeviceInfo);
ExcelUtil<DeviceInfoVo> util = new ExcelUtil<DeviceInfoVo>(DeviceInfoVo.class);
return util.exportExcel(list, "设备信息数据");
......@@ -96,8 +94,7 @@ public class TDeviceInfoController extends BaseController
*/
@PreAuthorize("@ss.hasPermi('device:deviceInfo:query')")
@GetMapping(value = "/{deviceId}")
public AjaxResult getInfo(@PathVariable("deviceId") int deviceId)
{
public AjaxResult getInfo(@PathVariable("deviceId") int deviceId) {
return AjaxResult.success(tDeviceInfoService.selectTDeviceInfoById(deviceId));
}
......@@ -107,10 +104,10 @@ public class TDeviceInfoController extends BaseController
@PreAuthorize("@ss.hasPermi('device:deviceInfo:add')")
@Log(title = "设备信息", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody TDeviceInfo tDeviceInfo)
{
public AjaxResult add(@RequestBody TDeviceInfo tDeviceInfo) {
System.out.println(tDeviceInfo.getEquipmentList());
int result = tDeviceInfoService.insertTDeviceInfo(tDeviceInfo);
if(result<=0){
if (result <= 0) {
new Exception("设备信息插入失败");
}
return AjaxResult.success(tDeviceInfo.getDeviceId());
......@@ -122,8 +119,15 @@ public class TDeviceInfoController extends BaseController
@PreAuthorize("@ss.hasPermi('device:deviceInfo:edit')")
@Log(title = "设备信息", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody TDeviceInfo tDeviceInfo)
{
public AjaxResult edit(@RequestBody TDeviceInfo tDeviceInfo) {
/**
* 先执行删除 在执行添加 不能删除任何一个
*/
/**删除下级设备信息*/
tDeviceInfoService.deleteEquipmentList(tDeviceInfo.getEquipmentList(),tDeviceInfo.getDeviceId());
/**新增下级设备信息*/
tDeviceInfoService.insertEquipmentList(tDeviceInfo.getEquipmentList(),tDeviceInfo.getDeviceId());
return toAjax(tDeviceInfoService.updateTDeviceInfo(tDeviceInfo));
}
......@@ -132,9 +136,8 @@ public class TDeviceInfoController extends BaseController
*/
@PreAuthorize("@ss.hasPermi('device:deviceInfo:remove')")
@Log(title = "设备信息", businessType = BusinessType.DELETE)
@DeleteMapping("/{deviceIds}")
public AjaxResult remove(@PathVariable int[] deviceIds)
{
@DeleteMapping("/{deviceIds}")
public AjaxResult remove(@PathVariable int[] deviceIds) {
return toAjax(tDeviceInfoService.deleteTDeviceInfoByIds(deviceIds));
}
......@@ -143,14 +146,36 @@ public class TDeviceInfoController extends BaseController
*/
//@PreAuthorize("@ss.hasPermi('device:deviceInfo:countDeviceByType')")
@GetMapping("/countDeviceByType")
public AjaxResult countDeviceByType()
{
public AjaxResult countDeviceByType() {
List<Map<Object, Object>> list = tDeviceInfoService.countDeviceByType();
return AjaxResult.success(list);
}
@PutMapping("/devicefeed")
public AjaxResult devicefeed(@RequestBody Map<String, Object> param)
{
public AjaxResult devicefeed(@RequestBody Map<String, Object> param) {
return AjaxResult.success(tDeviceInfoService.devicefeed(param));
}
/**
* 查询下级设备所有信息
* @return
*/
@GetMapping("/selectDevice")
public AjaxResult selectDevice(Integer id) {
return AjaxResult.success(tDeviceInfoService.selectDevice(id));
}
/**
* 根据设备id查询最新的设备信息数据
* @param deviceId
* @return
*/
@GetMapping("/getInformation")
public AjaxResult getInformation(Integer deviceId){
return AjaxResult.success(tDeviceInfoService.getInformations(deviceId));
}
}
package com.zehong.system.domain;
import java.util.Date;
public class EquipmentForm {
/**
* 主键
*/
private Integer relationId;
/**
* 关联设备id
*/
private Integer relationDeviceId;
/**
* 设备名称
*/
private String deviceNames;
/**
* 设备编号
*/
private String deviceCodes;
/**
* 创建时间
* @return
*/
private Date createTime;
public Integer getRelationId() {
return relationId;
}
public void setRelationId(Integer relationId) {
this.relationId = relationId;
}
public Integer getRelationDeviceId() {
return relationDeviceId;
}
public void setRelationDeviceId(Integer relationDeviceId) {
this.relationDeviceId = relationDeviceId;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public String getDeviceNames() {
return deviceNames;
}
public void setDeviceNames(String deviceNames) {
this.deviceNames = deviceNames;
}
public String getDeviceCodes() {
return deviceCodes;
}
public void setDeviceCodes(String deviceCodes) {
this.deviceCodes = deviceCodes;
}
@Override
public String toString() {
return "EquipmentForm{" +
"relationId=" + relationId +
", relationDeviceId=" + relationDeviceId +
", deviceNames='" + deviceNames + '\'' +
", deviceCodes='" + deviceCodes + '\'' +
", createTime=" + createTime +
'}';
}
}
......@@ -2,6 +2,8 @@ package com.zehong.system.domain;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
......@@ -10,7 +12,7 @@ import com.zehong.common.core.domain.BaseEntity;
/**
* 设备信息对象 t_device_info
*
*
* @author zehong
* @date 2021-07-09
*/
......@@ -91,6 +93,23 @@ public class TDeviceInfo extends BaseEntity
@Excel(name = "备注")
private String remarks;
/**
* 下级设备
*/
private List<EquipmentForm> equipmentList;
public static long getSerialVersionUID() {
return serialVersionUID;
}
public List<EquipmentForm> getEquipmentList() {
return equipmentList;
}
public void setEquipmentList(List<EquipmentForm> equipmentList) {
this.equipmentList = equipmentList;
}
public void setDeviceId(Integer deviceId)
{
this.deviceId = deviceId;
......@@ -118,12 +137,12 @@ public class TDeviceInfo extends BaseEntity
{
return pipeId;
}
public void setDeviceName(String deviceName)
public void setDeviceName(String deviceName)
{
this.deviceName = deviceName;
}
public String getDeviceName()
public String getDeviceName()
{
return deviceName;
}
......@@ -141,97 +160,97 @@ public class TDeviceInfo extends BaseEntity
this.deviceAddr = deviceAddr;
}
public String getDeviceAddr()
public String getDeviceAddr()
{
return deviceAddr;
}
public void setDeviceModel(String deviceModel)
public void setDeviceModel(String deviceModel)
{
this.deviceModel = deviceModel;
}
public String getDeviceModel()
public String getDeviceModel()
{
return deviceModel;
}
public void setDeviceType(String deviceType)
public void setDeviceType(String deviceType)
{
this.deviceType = deviceType;
}
public String getDeviceType()
public String getDeviceType()
{
return deviceType;
}
public void setLongitude(BigDecimal longitude)
public void setLongitude(BigDecimal longitude)
{
this.longitude = longitude;
}
public BigDecimal getLongitude()
public BigDecimal getLongitude()
{
return longitude;
}
public void setLatitude(BigDecimal latitude)
public void setLatitude(BigDecimal latitude)
{
this.latitude = latitude;
}
public BigDecimal getLatitude()
public BigDecimal getLatitude()
{
return latitude;
}
public void setIotNo(String iotNo)
public void setIotNo(String iotNo)
{
this.iotNo = iotNo;
}
public String getIotNo()
public String getIotNo()
{
return iotNo;
}
public void setIconUrl(String iconUrl)
public void setIconUrl(String iconUrl)
{
this.iconUrl = iconUrl;
}
public String getIconUrl()
public String getIconUrl()
{
return iconUrl;
}
public void setLinkman(String linkman)
public void setLinkman(String linkman)
{
this.linkman = linkman;
}
public String getLinkman()
public String getLinkman()
{
return linkman;
}
public void setPhone(String phone)
public void setPhone(String phone)
{
this.phone = phone;
}
public String getPhone()
public String getPhone()
{
return phone;
}
public void setInstallationTime(Date installationTime)
public void setInstallationTime(Date installationTime)
{
this.installationTime = installationTime;
}
public Date getInstallationTime()
public Date getInstallationTime()
{
return installationTime;
}
public void setInspectionTime(Date inspectionTime)
public void setInspectionTime(Date inspectionTime)
{
this.inspectionTime = inspectionTime;
}
public Date getInspectionTime()
public Date getInspectionTime()
{
return inspectionTime;
}
......@@ -249,31 +268,33 @@ public class TDeviceInfo extends BaseEntity
this.remarks = remarks;
}
public String getRemarks()
public String getRemarks()
{
return remarks;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("deviceId", getDeviceId())
.append("enterpriseId", getEnterpriseId())
.append("pipeCode", getPipeId())
.append("deviceName", getDeviceName())
.append("deviceCode", getDeviceCode())
.append("deviceAddr", getDeviceAddr())
.append("deviceModel", getDeviceModel())
.append("deviceType", getDeviceType())
.append("longitude", getLongitude())
.append("latitude", getLatitude())
.append("iotNo", getIotNo())
.append("iconUrl", getIconUrl())
.append("linkman", getLinkman())
.append("phone", getPhone())
.append("installationTime", getInstallationTime())
.append("inspectionTime", getInspectionTime())
.append("remarks", getRemarks())
.toString();
return "TDeviceInfo{" +
"deviceId=" + deviceId +
", enterpriseId=" + enterpriseId +
", pipeId=" + pipeId +
", deviceName='" + deviceName + '\'' +
", deviceCode='" + deviceCode + '\'' +
", deviceAddr='" + deviceAddr + '\'' +
", deviceModel='" + deviceModel + '\'' +
", deviceType='" + deviceType + '\'' +
", longitude=" + longitude +
", latitude=" + latitude +
", iotNo='" + iotNo + '\'' +
", iconUrl='" + iconUrl + '\'' +
", linkman='" + linkman + '\'' +
", phone='" + phone + '\'' +
", installationTime=" + installationTime +
", inspectionTime=" + inspectionTime +
", isDel='" + isDel + '\'' +
", remarks='" + remarks + '\'' +
", equipmentList=" + equipmentList +
'}';
}
}
package com.zehong.system.domain;
import org.springframework.security.core.parameters.P;
import java.util.Date;
/**
* 下级设备信息
*/
public class TDeviceInformation {
/**
* 设备名称
*/
private String deviceName;
/**
* 设备编号
*/
private String deviceCode;
/**
* 设备状态
*/
private Integer status;
/**
* 设备浓度
*/
private String potency;
/**
* 创建时间
* @return
*/
private Date createTime;
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public String getDeviceName() {
return deviceName;
}
public void setDeviceName(String deviceName) {
this.deviceName = deviceName;
}
public String getDeviceCode() {
return deviceCode;
}
public void setDeviceCode(String deviceCode) {
this.deviceCode = deviceCode;
}
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
public String getPotency() {
return potency;
}
public void setPotency(String potency) {
this.potency = potency;
}
@Override
public String toString() {
return "TDeviceInformation{" +
"deviceName='" + deviceName + '\'' +
", deviceCode='" + deviceCode + '\'' +
", status=" + status +
", potency='" + potency + '\'' +
", createTime=" + createTime +
'}';
}
}
......@@ -3,21 +3,25 @@ package com.zehong.system.mapper;
import java.util.List;
import java.util.Map;
import com.zehong.system.domain.EquipmentForm;
import com.zehong.system.domain.TDeviceInfo;
import com.zehong.system.domain.TDeviceInformation;
import org.apache.commons.math3.analysis.function.Add;
import org.apache.ibatis.annotations.Param;
import javax.validation.Valid;
/**
* 设备信息Mapper接口
*
*
* @author zehong
* @date 2021-07-09
*/
public interface TDeviceInfoMapper
public interface TDeviceInfoMapper
{
/**
* 查询设备信息
*
*
* @param deviceId 设备信息ID
* @return 设备信息
*/
......@@ -33,7 +37,7 @@ public interface TDeviceInfoMapper
/**
* 查询设备信息列表
*
*
* @param tDeviceInfo 设备信息
* @return 设备信息集合
*/
......@@ -47,7 +51,7 @@ public interface TDeviceInfoMapper
/**
* 新增设备信息
*
*
* @param tDeviceInfo 设备信息
* @return 结果
*/
......@@ -55,7 +59,7 @@ public interface TDeviceInfoMapper
/**
* 修改设备信息
*
*
* @param tDeviceInfo 设备信息
* @return 结果
*/
......@@ -63,7 +67,7 @@ public interface TDeviceInfoMapper
/**
* 删除设备信息
*
*
* @param deviceId 设备信息ID
* @return 结果
*/
......@@ -71,7 +75,7 @@ public interface TDeviceInfoMapper
/**
* 批量删除设备信息
*
*
* @param deviceIds 需要删除的数据ID
* @return 结果
*/
......@@ -83,4 +87,30 @@ public interface TDeviceInfoMapper
List<Map<String,Object>> selectdevicefeed(@Param("orderId") String orderId,
@Param("ids") List<Integer> ids,
@Param("ids2") List<Integer> ids2);
/**
* 添加下级设备
* @param equipmentList
*/
void insertTrelation(List<EquipmentForm> equipmentList);
/**
* 查询下级设备所有信息
* @return
*/
List<EquipmentForm> selectDevice(int relationDeviceId);
/**
* 删除下级设备信息
* @param equipmentList
*/
void deleteEquipmentList(@Param("list") List<EquipmentForm> equipmentList, @Param("devids") int devid);
/**
* 根据设备id查询最新的设备信息数据
* @param deviceId
* @return
*/
List<TDeviceInformation> getInformation(int deviceId);
}
......@@ -4,20 +4,22 @@ import java.util.List;
import java.util.Map;
import com.github.pagehelper.PageInfo;
import com.zehong.system.domain.EquipmentForm;
import com.zehong.system.domain.TDeviceInfo;
import com.zehong.system.domain.TDeviceInformation;
import com.zehong.system.domain.vo.DeviceInfoVo;
/**
* 设备信息Service接口
*
*
* @author zehong
* @date 2021-07-09
*/
public interface ITDeviceInfoService
public interface ITDeviceInfoService
{
/**
* 查询设备信息
*
*
* @param deviceId 设备信息ID
* @return 设备信息
*/
......@@ -25,7 +27,7 @@ public interface ITDeviceInfoService
/**
* 查询设备信息列表
*
*
* @param tDeviceInfo 设备信息
* @return 设备信息集合
*/
......@@ -63,7 +65,7 @@ public interface ITDeviceInfoService
/**
* 新增设备信息
*
*
* @param tDeviceInfo 设备信息
* @return 结果
*/
......@@ -71,7 +73,7 @@ public interface ITDeviceInfoService
/**
* 修改设备信息
*
*
* @param tDeviceInfo 设备信息
* @return 结果
*/
......@@ -79,7 +81,7 @@ public interface ITDeviceInfoService
/**
* 批量删除设备信息
*
*
* @param deviceIds 需要删除的设备信息ID
* @return 结果
*/
......@@ -87,7 +89,7 @@ public interface ITDeviceInfoService
/**
* 删除设备信息信息
*
*
* @param deviceId 设备信息ID
* @return 结果
*/
......@@ -98,4 +100,29 @@ public interface ITDeviceInfoService
* @return
*/
public List<Map<String,Object>> devicefeed(Map<String, Object> param);
/**
* 查询下级设备所有信息
* @param relationDeviceId
* @return
*/
List<EquipmentForm> selectDevice(int relationDeviceId);
/**
* 新增下级设备信息
* @param equipmentList
*/
void insertEquipmentList(List<EquipmentForm> equipmentList,int devid);
/**
* 删除下级设备信息
* @param equipmentList
*/
void deleteEquipmentList(List<EquipmentForm> equipmentList,int devid);
/**
* 根据设备id查询最新的设备信息数据
* @param deviceId
*/
List<TDeviceInformation> getInformations(int deviceId);
}
......@@ -3,7 +3,9 @@ package com.zehong.system.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageInfo;
import com.zehong.common.utils.PageInfoUtil;
import com.zehong.system.domain.EquipmentForm;
import com.zehong.system.domain.TDeviceInfo;
import com.zehong.system.domain.TDeviceInformation;
import com.zehong.system.domain.TPipe;
import com.zehong.system.domain.vo.DeviceInfoVo;
import com.zehong.system.mapper.TDeviceInfoMapper;
......@@ -13,10 +15,7 @@ import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
/**
* 设备信息Service业务层处理
......@@ -132,6 +131,53 @@ public class TDeviceInfoServiceImpl implements ITDeviceInfoService
}
return list;
}
/**
* 查询下级设备所有信息
* @param relationDeviceId
* @return
*/
@Override
public List<EquipmentForm> selectDevice(int relationDeviceId) {
return tDeviceInfoMapper.selectDevice(relationDeviceId);
}
/**
* 新增下级设备信息
* @param equipmentList
*/
@Override
public void insertEquipmentList(List<EquipmentForm> equipmentList,int devId) {
List<EquipmentForm> equipmentForms=new ArrayList<>();
for (int i=0;i<equipmentList.size();i++){
if (equipmentList.get(i).getRelationDeviceId()==null){
equipmentList.get(i).setRelationDeviceId(devId);
equipmentList.get(i).setCreateTime(new Date());
equipmentForms.add(equipmentList.get(i));
}
}
if (equipmentForms.size()!=0){
tDeviceInfoMapper.insertTrelation(equipmentForms);
}
}
/**
* 删除下级设备信息
* @param equipmentList
*/
@Override
public void deleteEquipmentList(List<EquipmentForm> equipmentList,int devid) {
ArrayList<EquipmentForm> equipmentLists=new ArrayList<EquipmentForm>();
for (int i=0;i<equipmentList.size();i++){
if (equipmentList.get(i).getRelationId()!=null){
equipmentLists.add(equipmentList.get(i));
}
}
tDeviceInfoMapper.deleteEquipmentList(equipmentLists,devid);
}
/**
* 构建前端所需要下拉树结构
*
......@@ -271,7 +317,16 @@ public class TDeviceInfoServiceImpl implements ITDeviceInfoService
@Override
public int insertTDeviceInfo(TDeviceInfo tDeviceInfo)
{
return tDeviceInfoMapper.insertTDeviceInfo(tDeviceInfo);
int deviceId = tDeviceInfoMapper.insertTDeviceInfo(tDeviceInfo);
for (int i=0;i<tDeviceInfo.getEquipmentList().size();i++){
tDeviceInfo.getEquipmentList().get(i).setCreateTime(new Date());
tDeviceInfo.getEquipmentList().get(i).setRelationDeviceId(tDeviceInfo.getDeviceId());
}
/*添加下级设备*/
tDeviceInfoMapper.insertTrelation(tDeviceInfo.getEquipmentList());
/**添加*/
System.out.println(tDeviceInfo.getDeviceId());
return deviceId;
}
/**
......@@ -309,4 +364,14 @@ public class TDeviceInfoServiceImpl implements ITDeviceInfoService
{
return tDeviceInfoMapper.deleteTDeviceInfoById(deviceId);
}
/**
* 根据设备id查询最新的设备信息数据
* @param deviceId
* @return
*/
@Override
public List<TDeviceInformation> getInformations(int deviceId) {
return tDeviceInfoMapper.getInformation(deviceId);
}
}
......@@ -3,7 +3,7 @@
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.zehong.system.mapper.TDeviceInfoMapper">
<resultMap type="TDeviceInfo" id="TDeviceInfoResult">
<result property="deviceId" column="device_id" />
<result property="enterpriseId" column="enterprise_id" />
......@@ -25,6 +25,25 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="remarks" column="remarks" />
</resultMap>
<resultMap type="EquipmentForm" id="EquipmentFormResult">
<result property="relationId" column="relation_id" />
<result property="relationDeviceId" column="relation_device_id" />
<result property="deviceNames" column="device_name" />
<result property="deviceCodes" column="device_code" />
<result property="createTime" column="create_time" />
<result property="status" column="status" />
<result property="potency" column="potency" />
</resultMap>
<resultMap type="TDeviceInformation" id="TDeviceInformationResult">
<result property="deviceName" column="device_name" />
<result property="deviceCode" column="device_code" />
<result property="createTime" column="create_time" />
<result property="status" column="status" />
<result property="potency" column="potency" />
</resultMap>
<sql id="selectTDeviceInfoVo">
select device_id, enterprise_id, pipe_id, device_name, device_code, device_addr, device_model, device_type, longitude, latitude, iot_no, icon_url, linkman, phone, installation_time, inspection_time, is_del, remarks from t_device_info
</sql>
......@@ -50,7 +69,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="remarks != null and remarks != ''"> and remarks = #{remarks}</if>
</where>
</select>
<select id="selectTDeviceInfoById" parameterType="int" resultMap="TDeviceInfoResult">
<include refid="selectTDeviceInfoVo"/>
where device_id = #{deviceId}
......@@ -66,7 +85,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where is_del = '0'
group by device_type
</select>
<insert id="insertTDeviceInfo" parameterType="TDeviceInfo" useGeneratedKeys="true" keyProperty="deviceId">
insert into t_device_info
<trim prefix="(" suffix=")" suffixOverrides=",">
......@@ -136,7 +155,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</delete>
<delete id="deleteTDeviceInfoByIds" parameterType="String">
delete from t_device_info where device_id in
delete from t_device_info where device_id in
<foreach item="deviceId" collection="array" open="(" separator="," close=")">
#{deviceId}
</foreach>
......@@ -168,4 +187,43 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
group by p.pipe_id
</if>
</select>
</mapper>
\ No newline at end of file
<!--添加下级设备-->
<insert id="insertTrelation" parameterType="java.util.List">
insert into t_relation_device_info (relation_device_id,device_name,device_code,create_time) values
<foreach collection="list" item="equipmentList" index="index" separator=",">
(
#{equipmentList.relationDeviceId},
#{equipmentList.deviceNames},
#{equipmentList.deviceCodes},
#{equipmentList.createTime})
</foreach>
</insert>
<!--查询下级设备所有信息-->
<select id="selectDevice" parameterType="int" resultMap="EquipmentFormResult" >
select relation_id,relation_device_id,device_name,device_code,create_time from t_relation_device_info where relation_device_id=#{relationDeviceId} and is_del='0'
</select>
<!--删除下级设备信息-->
<delete id="deleteEquipmentList" parameterType="java.util.List">
delete from t_relation_device_info where relation_device_id=#{devids}
<if test="list.size()!=0">
and relation_id not in
<foreach collection="list" item="list" index="index" separator=",">
( #{list.relationId} )
</foreach>
</if>
</delete>
<!--根据设备id查询最新的设备信息数据-->
<select id="getInformation" parameterType="int" resultMap="TDeviceInformationResult">
select * from(
select a.device_name,b.status,b.potency,b.create_time,b.device_code from t_relation_device_info a left join t_relation_device_data b on a.device_code=b.device_code
where a.relation_device_id=#{deviceId} order by b.create_time desc LIMIT 100000)b group by b.device_code
</select>
</mapper>
......@@ -86,3 +86,18 @@ export function deviceNodeTree() {
})
}
// 查询设备信息
export function getDevice(query) {
return request({
url: '/device/deviceInfo/selectDevice?id='+query,
method: 'get',
})
}
// 根据设备id查询最新的设备信息数据
export function getInformation(query) {
return request({
url: '/device/deviceInfo/getInformation?deviceId='+query,
method: 'get',
})
}
......@@ -72,6 +72,56 @@
</el-col>
</el-row>
<el-divider></el-divider>
<el-row v-if="this.deviceType=='调压阀'||this.deviceType=='阀门井'" style="width: 100%;height: 45px;margin-top: -15px;">
<el-col :span="14" style="margin-bottom: -10px;">
<div style="color: #31EAEA;">
<ul><li>下级设备信息</li></ul>
</div>
</el-col>
</el-row>
<el-row v-if="this.deviceType=='调压阀'||this.deviceType=='阀门井'">
<el-col :span="36" style="padding: 20px;width: 100%;">
<div style="width: 100%;float: left;height: 100%;" v-if="form.deviceType != '管道'">
<el-table :data="deviceInfoList" style="width: 100%">
<el-table-column label="设备名称" align="center" prop="deviceName" />
<el-table-column label="设备编号" align="center" prop="deviceCode" />
<el-table-column label="浓度" align="center" prop="potency" />
<el-table-column label="设备状态" align="center" prop="deviceType" >
<template slot-scope="scope">
<span v-if="scope.row.status == 0">预热</span>
<span v-if="scope.row.status == 1">正常</span>
<span v-if="scope.row.status == 2">错误</span>
<span v-if="scope.row.status == 3">传感器故障</span>
<span v-if="scope.row.status == 4">报警</span>
<span v-if="scope.row.status == 5">低报</span>
<span v-if="scope.row.status == 6">高报</span>
<span v-if="scope.row.status == 7">通信故障</span>
<span v-if="scope.row.status == 8">通信故障</span>
<span v-if="scope.row.status == 9">离线</span>
<span v-if="scope.row.status == 10">电量低</span>
<span v-if="scope.row.status == 11">主电故障</span>
<span v-if="scope.row.status == 12">备电故障</span>
<span v-if="scope.row.status == 13">无此节点</span>
<span v-if="scope.row.status == 14">低电压</span>
<span v-if="scope.row.status == 15">故障</span>
<span v-if="scope.row.status == 16">报警联动</span>
<span v-if="scope.row.status == 17">低低报</span>
<span v-if="scope.row.status == 18">高高报</span>
<span v-if="scope.row.status == 19">水位淹没报警</span>
</template>
</el-table-column>
</el-table>
</div>
</el-col>
</el-row>
<el-row style="width: 100%;height: 45px;margin-top: -15px;">
<el-col :span="24" style="margin-bottom: -10px;">
<div style="color: #31EAEA;">
......@@ -158,6 +208,7 @@
</el-col>
</el-row>
<template v-if="$route.query.deviceType!='管道' && form.deviceType != '管道'">
<el-row v-if="form.deviceType != '压力表'">
<el-col :span="12" style="padding: 10px;">
......@@ -252,7 +303,7 @@
<script>
import { getDeviceAlarm } from "@/api/dataMonitoring/deviceAlarm";
import { deviceTree } from "@/api/device/deviceInfo";
import { deviceTree,getInformation } from "@/api/device/deviceInfo";
import { addBasicsInfo } from "@/api/workOrder/basicsInfo";
import gaodeMap from "utils/gaodeMap.js";
import { map, DEVICE_TYPE } from "utils/gaodeMap.js";
......@@ -269,7 +320,10 @@ export default {
return {
dialogVisible: false,
dataListdetail: [],
// 设备信息表格数据
deviceInfoList: [],
alarmId:'',
deviceType:'',
// 折线图标题
title: "",
open: false,
......@@ -419,7 +473,7 @@ export default {
boundaryGap: false, //控制日期是否在中间显示
axisLabel: {
show: true, //是否显示日期
// interval: 0, //强制显示全部
// interval: 0, //强制显示全部
rotate: 40,//倾斜的角度
textStyle: {
color: '#000', //日期的颜色
......@@ -509,7 +563,7 @@ export default {
boundaryGap: false, //控制日期是否在中间显示
axisLabel: {
show: true, //是否显示日期
// interval: 0, //强制显示全部 //
// interval: 0, //强制显示全部 //
rotate: 40,//倾斜的角度
textStyle: {
color: '#000', //日期的颜色
......@@ -581,7 +635,7 @@ export default {
boundaryGap: false, //控制日期是否在中间显示
axisLabel: {
show: true, //是否显示日期
// interval: 0, //强制显示全部 //
// interval: 0, //强制显示全部 //
rotate: 40,//倾斜的角度
textStyle: {
color: '#000', //日期的颜色
......@@ -687,6 +741,11 @@ export default {
getDetail (){
getDeviceAlarm(this.alarmId).then(response =>{
this.form = response.data;
this.deviceType=this.form.deviceType;
getInformation(this.form.deviceId).then(response =>{
this.deviceInfoList=response.data;
})
console.log("this.form", this.form);
if(this.form.pipeList != null){
......@@ -766,22 +825,22 @@ export default {
}
});
},
dateFtt(fmt,date) { //author: meizz
var o = {
"M+" : date.getMonth()+1, //月份
"d+" : date.getDate(), //日
"h+" : date.getHours(), //小时
"m+" : date.getMinutes(), //分
"s+" : date.getSeconds(), //秒
"q+" : Math.floor((date.getMonth()+3)/3), //季度
"S" : date.getMilliseconds() //毫秒
};
if(/(y+)/.test(fmt))
fmt=fmt.replace(RegExp.$1, (date.getFullYear()+"").substr(4 - RegExp.$1.length));
for(var k in o)
if(new RegExp("("+ k +")").test(fmt))
fmt = fmt.replace(RegExp.$1, (RegExp.$1.length==1) ? (o[k]) : (("00"+ o[k]).substr((""+ o[k]).length)));
return fmt;
dateFtt(fmt,date) { //author: meizz
var o = {
"M+" : date.getMonth()+1, //月份
"d+" : date.getDate(), //日
"h+" : date.getHours(), //小时
"m+" : date.getMinutes(), //分
"s+" : date.getSeconds(), //秒
"q+" : Math.floor((date.getMonth()+3)/3), //季度
"S" : date.getMilliseconds() //毫秒
};
if(/(y+)/.test(fmt))
fmt=fmt.replace(RegExp.$1, (date.getFullYear()+"").substr(4 - RegExp.$1.length));
for(var k in o)
if(new RegExp("("+ k +")").test(fmt))
fmt = fmt.replace(RegExp.$1, (RegExp.$1.length==1) ? (o[k]) : (("00"+ o[k]).substr((""+ o[k]).length)));
return fmt;
}
}
}
......
......@@ -270,9 +270,66 @@
</el-col>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button v-if="form.deviceType==1||form.deviceType==2" type="primary" @click="addDevice">添加设备</el-button>
<el-button type="primary" @click="submitForm">确 定</el-button>
<el-button @click="cancel">取 消</el-button>
</div>
</el-dialog>
<!--新增设备列表-->
<el-dialog title="新增设备" :visible.sync="dialogFormVisible">
<el-table v-loading="loading" :data="equipmentList" @selection-change="handleSelectionChange">
<el-table-column label="设备名称" align="center" prop="deviceNames" />
<el-table-column label="设备编号" align="center" prop="deviceCodes" />
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="equipmentDelete(scope.$index)"
v-hasPermi="['device:deviceInfo:remove']"
>删除</el-button>
</template>
</el-table-column>
</el-table>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="equipment = true">新增</el-button>
<el-button type="primary" @click="dialogFormVisible=false">确 定</el-button>
</div>
</el-dialog>
<!--新增设备添加-->
<el-dialog title="新增设备" :visible.sync="equipment">
<el-form ref="form" :model="equipmentForm" :rules="rules" label-width="135px">
<el-col :span="12">
<el-form-item label="设备名称" >
<el-input
v-model="equipmentForm.deviceNames"
placeholder="请输入设备名称"
/>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="设备编号" >
<el-input
v-model="equipmentForm.deviceCodes"
placeholder="请输入设备编号"
/>
</el-form-item>
</el-col>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitEquipment">确 定</el-button>
<el-button @click="equipment=false">取 消</el-button>
</div>
</el-dialog>
<Mapdialog
......@@ -287,7 +344,7 @@
</template>
<script>
import { listDeviceInfo, getDeviceInfo, addDeviceInfo, updateDeviceInfo, exportDeviceInfo } from "@/api/device/deviceInfo";
import { listDeviceInfo, getDeviceInfo, addDeviceInfo, updateDeviceInfo, exportDeviceInfo,getDevice } from "@/api/device/deviceInfo";
import { pipeAllInfoList } from "@/api/device/pipe";
import MyFileUpload from '@/components/MyFileUpload';
import Mapdialog from "@/components/mapDialog/checkDeviceLoaction.vue";
......@@ -300,6 +357,14 @@
},
data() {
return {
dynamicValidateForm: {
domains: [{
value: ''
}],
email: ''
},
dialogFormVisible: false,
equipment:false,
// 遮罩层
loading: true,
// 导出遮罩层
......@@ -316,6 +381,8 @@
total: 0,
// 设备信息表格数据
deviceInfoList: [],
//下级绑定设备数据
equipmentList:[],
// 弹出层标题
title: "",
// 是否显示弹出层
......@@ -351,6 +418,7 @@
},
// 表单参数
form: {},
equipmentForm:{},
// 表单校验
rules: {
pipeId: [
......@@ -400,6 +468,28 @@
});
},
methods: {
/**添加设备*/
addDevice(){
this.$refs["form"].validate(valid => {
if (valid) {
if (this.form.deviceId != null) {
const id=this.form.deviceId
getDevice(id).then(response => {
this.equipmentList=response.data
});
console.log('有值')
} else {
console.log('没值')
}
}
});
this.dialogFormVisible=true;
},
/** 查询设备信息列表 */
getList() {
this.loading = true;
......@@ -453,7 +543,8 @@
phone: null,
installationTime: null,
inspectionTime: null,
remarks: null
remarks: null,
equipmentList:[],
};
this.resetForm("form");
},
......@@ -500,18 +591,27 @@
this.title = "修改设备信息";
});
},
/*提交*/
submitEquipment(){
this.equipmentList.push(this.equipmentForm)
this.equipmentForm={}
this.equipment = false;
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
if (this.form.deviceId != null) {
this.form.equipmentList=this.equipmentList;
this.equipmentList=[];
updateDeviceInfo(this.form).then(response => {
this.msgSuccess("修改成功");
this.open = false;
this.getList();
});
} else {
console.log(this.form, "this.form");
this.form.equipmentList=this.equipmentList;
this.equipmentList=[];
addDeviceInfo(this.form).then(response => {
this.msgSuccess("新增成功");
this.open = false;
......@@ -521,6 +621,11 @@
}
});
},
/**设备删除*/
equipmentDelete(row){
this.equipmentList.splice(row,1);
},
/** 删除按钮操作 */
handleDelete(row) {
row.isDel = "1";
......
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