This commit is contained in:
Tony 2024-04-03 08:42:23 +08:00
commit 641fcbf033
31 changed files with 2940 additions and 84 deletions

View File

@ -0,0 +1,42 @@
package com.inspur.web.controller.ipc;
import com.inspur.common.core.controller.BaseController;
import com.inspur.common.core.domain.AjaxResult;
import com.inspur.ipc.service.IIpcDataLogService;
import com.inspur.ipc.service.IIpcDataShowService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* 数据展示界面
*
* @author inspur
*/
@RestController
@RequestMapping("/ipc/dataLog")
public class IpcDataLogController extends BaseController {
@Autowired
private IIpcDataLogService iIpcDataLogService;
/**
* 查询plc数据记录
*/
@PreAuthorize("@ss.hasPermi('ipc:dataLog:query')")
@GetMapping(value = "/plc/{part}")
public AjaxResult queryPlcDataLog(@PathVariable String part)
{
return AjaxResult.success(iIpcDataLogService.queryPlcDataLog(part));
}
/**
* 查询传感器温振数据记录
*/
@PreAuthorize("@ss.hasPermi('ipc:dataLog:query')")
@GetMapping(value = "/sensor/{part}")
public AjaxResult querySensorDataLog(@PathVariable String part)
{
return AjaxResult.success(iIpcDataLogService.querySensorDataLog(part));
}
}

View File

@ -0,0 +1,32 @@
package com.inspur.web.controller.ipc;
import com.inspur.common.core.domain.AjaxResult;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import java.util.Map;
@RestController
@RequestMapping("/ipc/dataReceive")
public class IpcDataReceiveController {
/**
* 接收PLC数据
*/
@PostMapping("/plcData")
public AjaxResult plcData(@RequestBody Map<String, List<String>> map) {
System.out.println(map.toString());
return AjaxResult.success(1);
}
/**
* 接收温振传感器数据
*/
@PostMapping("/sensorData")
public AjaxResult sensorData(@RequestBody Map<String, List<String>> map) {
System.out.println(map.toString());
return AjaxResult.success(1);
}
}

View File

@ -0,0 +1,32 @@
package com.inspur.web.controller.ipc;
import com.inspur.common.core.controller.BaseController;
import com.inspur.common.core.domain.AjaxResult;
import com.inspur.ipc.service.IIpcDataShowService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* 数据展示界面
*
* @author inspur
*/
@RestController
@RequestMapping("ipc/dataShow")
public class IpcDataShowController extends BaseController {
@Autowired
private IIpcDataShowService iIpcDataShowService;
/**
* 获取展示数据
*/
// @PreAuthorize("@ss.hasPermi('ipc:dataShow:query')")
@GetMapping(value = "/byPart/{parts}")
public AjaxResult getShowData(@PathVariable("parts") String[] parts)
{
return AjaxResult.success(iIpcDataShowService.getShowData(parts));
}
}

View File

@ -0,0 +1,112 @@
package com.inspur.web.controller.ipc;
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.inspur.common.annotation.Log;
import com.inspur.common.core.controller.BaseController;
import com.inspur.common.core.domain.AjaxResult;
import com.inspur.common.enums.BusinessType;
import com.inspur.ipc.domain.IpcFaultTreeConfig;
import com.inspur.ipc.service.IIpcFaultTreeConfigService;
import com.inspur.common.utils.poi.ExcelUtil;
/**
* 故障树配置Controller
*
* @author inspur
* @date 2024-04-02
*/
@RestController
@RequestMapping("/ipc/faultTreeConfig")
public class IpcFaultTreeConfigController extends BaseController
{
@Autowired
private IIpcFaultTreeConfigService ipcFaultTreeConfigService;
/**
* 查询故障树配置列表
*/
@PreAuthorize("@ss.hasPermi('ipc:faultTreeConfig:list')")
@GetMapping("/list")
public AjaxResult list(IpcFaultTreeConfig ipcFaultTreeConfig)
{
List<IpcFaultTreeConfig> list = ipcFaultTreeConfigService.selectIpcFaultTreeConfigList(ipcFaultTreeConfig);
return AjaxResult.success(list);
}
/**
* 导出故障树配置列表
*/
@PreAuthorize("@ss.hasPermi('ipc:faultTreeConfig:export')")
@Log(title = "故障树配置", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, IpcFaultTreeConfig ipcFaultTreeConfig)
{
List<IpcFaultTreeConfig> list = ipcFaultTreeConfigService.selectIpcFaultTreeConfigList(ipcFaultTreeConfig);
ExcelUtil<IpcFaultTreeConfig> util = new ExcelUtil<IpcFaultTreeConfig>(IpcFaultTreeConfig.class);
util.exportExcel(response, list, "故障树配置数据");
}
/**
* 获取故障树配置详细信息
*/
@PreAuthorize("@ss.hasPermi('ipc:faultTreeConfig:query')")
@GetMapping(value = "/{nodeId}")
public AjaxResult getInfo(@PathVariable("nodeId") Long nodeId)
{
return AjaxResult.success(ipcFaultTreeConfigService.selectIpcFaultTreeConfigByNodeId(nodeId));
}
/**
* 校验是否存在子节点
*/
@PreAuthorize("@ss.hasPermi('ipc:faultTreeConfig:query')")
@GetMapping(value = "/hasChild/{nodeId}")
public AjaxResult hasChild(@PathVariable("nodeId") Long nodeId)
{
return AjaxResult.success(ipcFaultTreeConfigService.hasChild(nodeId));
}
/**
* 新增故障树配置
*/
@PreAuthorize("@ss.hasPermi('ipc:faultTreeConfig:add')")
@Log(title = "故障树配置", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody IpcFaultTreeConfig ipcFaultTreeConfig)
{
return toAjax(ipcFaultTreeConfigService.insertIpcFaultTreeConfig(ipcFaultTreeConfig));
}
/**
* 修改故障树配置
*/
@PreAuthorize("@ss.hasPermi('ipc:faultTreeConfig:edit')")
@Log(title = "故障树配置", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody IpcFaultTreeConfig ipcFaultTreeConfig)
{
return toAjax(ipcFaultTreeConfigService.updateIpcFaultTreeConfig(ipcFaultTreeConfig));
}
/**
* 删除故障树配置
*/
@PreAuthorize("@ss.hasPermi('ipc:faultTreeConfig:remove')")
@Log(title = "故障树配置", businessType = BusinessType.DELETE)
@DeleteMapping("/{nodeIds}")
public AjaxResult remove(@PathVariable Long[] nodeIds)
{
return toAjax(ipcFaultTreeConfigService.deleteIpcFaultTreeConfigByNodeIds(nodeIds));
}
}

View File

@ -8,6 +8,7 @@ import com.inspur.ipc.domain.IpcMonitorField;
import com.inspur.ipc.service.IIpcAlarmRecordService;
import com.inspur.ipc.service.IIpcMonitorFieldService;
import com.inspur.ipc.utils.GetBeanUtil;
import com.inspur.ipc.utils.IpcConstant;
import com.inspur.ipc.utils.IpcUtil;
import com.inspur.system.service.influx.InfluxDBService;
import com.serotonin.modbus4j.BatchRead;
@ -73,7 +74,6 @@ public class IPCData2SyncThread implements Runnable {
List<IpcMonitorField> partList = iIpcMonitorFieldService.selectFieldDataByType(CacheConstants.MONITOR_PART_KEY);
List<IpcMonitorField> sensorList = iIpcMonitorFieldService.selectFieldDataByType(CacheConstants.SENSOR_MONITOR_PARAMS_KEY);
List<IpcAlarmRecord> alarmRecordList = new ArrayList<>();
String measurement = "tzipc_sensor_monitor_data_list";
// 字典数据列表集合
for (IpcMonitorField part : partList) {
Map<String, String> tags = new TreeMap();
@ -116,7 +116,7 @@ public class IPCData2SyncThread implements Runnable {
InfluxDBService i = SpringUtils.getBean(InfluxDBService.class);
// 根据报警规则校验
alarmRecordList.addAll(ipcUtil.dealRealTimeData(fields,tags.get("part"),CacheConstants.SENSOR_MONITOR_PARAMS_KEY));
i.insert(measurement, tags, fields);
i.insert(IpcConstant.SENSOR_MEASUREMENT, tags, fields);
}
// 批量保存报警数据
if(!alarmRecordList.isEmpty()){

View File

@ -9,6 +9,7 @@ import com.inspur.ipc.domain.IpcMonitorField;
import com.inspur.ipc.service.IIpcAlarmRecordService;
import com.inspur.ipc.service.IIpcMonitorFieldService;
import com.inspur.ipc.utils.GetBeanUtil;
import com.inspur.ipc.utils.IpcConstant;
import com.inspur.ipc.utils.IpcUtil;
import com.inspur.system.service.ISysDictDataService;
import com.inspur.system.service.influx.InfluxDBService;
@ -77,7 +78,6 @@ public class IPCDataSyncThread implements Runnable {
List<IpcMonitorField> partList = iIpcMonitorFieldService.selectFieldDataByType(CacheConstants.MONITOR_PART_KEY);
List<IpcMonitorField> plcList = iIpcMonitorFieldService.selectFieldDataByType(CacheConstants.PLC_MONITOR_PARAMS_KEY);
List<IpcAlarmRecord> alarmRecordList = new ArrayList<>();
String measurement = "tzipc_plc_monitor_data_list";
// 字典数据列表集合
for (IpcMonitorField part : partList) {
Map<String, String> tags = new TreeMap();
@ -120,7 +120,7 @@ public class IPCDataSyncThread implements Runnable {
InfluxDBService i = SpringUtils.getBean(InfluxDBService.class);
// 根据报警规则校验
alarmRecordList.addAll(ipcUtil.dealRealTimeData(fields,tags.get("part"),CacheConstants.PLC_MONITOR_PARAMS_KEY));
i.insert(measurement, tags, fields);
i.insert(IpcConstant.PLC_MEASUREMENT, tags, fields);
}
// 批量保存报警数据
if(!alarmRecordList.isEmpty()){

View File

@ -110,6 +110,8 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
.authorizeRequests()
// 对于登录login 注册register 验证码captchaImage 允许匿名访问
.antMatchers("/login", "/register", "/captchaImage").anonymous()
// 数据接收接口允许匿名访问
.antMatchers("/ipc/dataReceive/plcData","/ipc/dataReceive/sensorData").permitAll()
// 静态资源可匿名访问
.antMatchers(HttpMethod.GET, "/", "/*.html", "/**/*.html", "/**/*.css", "/**/*.js", "/profile/**").permitAll()
.antMatchers("/swagger-ui.html", "/swagger-resources/**", "/webjars/**", "/*/api-docs", "/druid/**").permitAll()

View File

@ -83,6 +83,12 @@ public class IpcAlarmRecord extends BaseEntity {
@Excel(name = "报警描述")
private String alarmDetail;
/**
* 报警规则id
*/
@Excel(name = "报警规则id")
private Long ruleConfigId;
/**
* 状态 0 未处理 1 已处理
*/
@ -199,6 +205,14 @@ public class IpcAlarmRecord extends BaseEntity {
return alarmDetail;
}
public Long getRuleConfigId() {
return ruleConfigId;
}
public void setRuleConfigId(Long ruleConfigId) {
this.ruleConfigId = ruleConfigId;
}
public void setAlarmStatus(String alarmStatus) {
this.alarmStatus = alarmStatus;
}
@ -226,7 +240,7 @@ public class IpcAlarmRecord extends BaseEntity {
public IpcAlarmRecord() {
}
public IpcAlarmRecord(String id, String partKey, String part, String nameKey, String name, String alarmData, String unit, String alarmLevel, String referenceName, String alarmDetail) {
public IpcAlarmRecord(String id, String partKey, String part, String nameKey, String name, String alarmData, String unit, String alarmLevel, String referenceName, String alarmDetail,Long ruleConfigId) {
this.id = id;
this.partKey = partKey;
this.part = part;
@ -237,6 +251,7 @@ public class IpcAlarmRecord extends BaseEntity {
this.alarmLevel = alarmLevel;
this.referenceName = referenceName;
this.alarmDetail = alarmDetail;
this.ruleConfigId = ruleConfigId;
}
@Override

View File

@ -51,8 +51,8 @@ public class IpcAlarmRulesConfig extends BaseEntity
@Excel(name = "规则值2(参考标准为区间时需要)")
private BigDecimal referenceValue2;
/** 规则值显示 */
@Excel(name = "规则值显示")
/** 规则描述 */
@Excel(name = "规则描述")
private String referenceName;
/** 判断规则 */

View File

@ -0,0 +1,205 @@
package com.inspur.ipc.domain;
import com.inspur.common.annotation.Excel;
import com.inspur.common.core.domain.TreeEntity;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
/**
* 故障树配置对象 ipc_fault_tree_config
*
* @author inspur
* @date 2024-04-02
*/
public class IpcFaultTreeConfig extends TreeEntity
{
private static final long serialVersionUID = 1L;
/** 节点id */
private Long nodeId;
/** 部门名称 */
@Excel(name = "节点名称")
private String nodeName;
/** 所属部位 */
@Excel(name = "所属部位")
private String partKey;
/** 规则id */
@Excel(name = "规则id")
private Long alarmRuleConfigId;
/** 规则描述 */
@Excel(name = "规则描述")
private String alarmRuleConfigDescription;
/** 节点图标 */
@Excel(name = "节点图标")
private String iconCls;
/** 节点形状 */
@Excel(name = "节点形状")
private String nodeShapeType;
/** 节点默认颜色 */
@Excel(name = "节点默认颜色")
private String nodeDefaultColor;
/** 节点报警颜色 */
@Excel(name = "节点报警颜色")
private String nodeAlarmColor;
/** 是否叶子节点 */
@Excel(name = "是否叶子节点")
private String isLeaf;
/** 是否报警 */
@Excel(name = "是否报警")
private String isAlarm;
/** 节点状态0正常 1停用 */
@Excel(name = "节点状态", readConverterExp = "0=正常,1=停用")
private String status;
/** 删除标志0代表存在 2代表删除 */
private String delFlag;
public void setNodeId(Long nodeId)
{
this.nodeId = nodeId;
}
public Long getNodeId()
{
return nodeId;
}
public void setNodeName(String nodeName)
{
this.nodeName = nodeName;
}
public String getNodeName()
{
return nodeName;
}
public void setPartKey(String partKey)
{
this.partKey = partKey;
}
public String getPartKey()
{
return partKey;
}
public void setIconCls(String iconCls)
{
this.iconCls = iconCls;
}
public String getIconCls()
{
return iconCls;
}
public void setNodeShapeType(String nodeShapeType)
{
this.nodeShapeType = nodeShapeType;
}
public String getNodeShapeType()
{
return nodeShapeType;
}
public void setNodeDefaultColor(String nodeDefaultColor)
{
this.nodeDefaultColor = nodeDefaultColor;
}
public String getNodeDefaultColor()
{
return nodeDefaultColor;
}
public void setNodeAlarmColor(String nodeAlarmColor)
{
this.nodeAlarmColor = nodeAlarmColor;
}
public String getNodeAlarmColor()
{
return nodeAlarmColor;
}
public void setIsAlarm(String isAlarm)
{
this.isAlarm = isAlarm;
}
public String getIsAlarm()
{
return isAlarm;
}
public void setStatus(String status)
{
this.status = status;
}
public String getStatus()
{
return status;
}
public void setDelFlag(String delFlag)
{
this.delFlag = delFlag;
}
public String getDelFlag()
{
return delFlag;
}
public Long getAlarmRuleConfigId() {
return alarmRuleConfigId;
}
public void setAlarmRuleConfigId(Long alarmRuleConfigId) {
this.alarmRuleConfigId = alarmRuleConfigId;
}
public String getAlarmRuleConfigDescription() {
return alarmRuleConfigDescription;
}
public void setAlarmRuleConfigDescription(String alarmRuleConfigDescription) {
this.alarmRuleConfigDescription = alarmRuleConfigDescription;
}
public String getIsLeaf() {
return isLeaf;
}
public void setIsLeaf(String isLeaf) {
this.isLeaf = isLeaf;
}
@Override
public String toString() {
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
.append("nodeId", getNodeId())
.append("parentId", getParentId())
.append("ancestors", getAncestors())
.append("nodeName", getNodeName())
.append("orderNum", getOrderNum())
.append("partKey", getPartKey())
.append("iconCls", getIconCls())
.append("nodeShapeType", getNodeShapeType())
.append("nodeDefaultColor", getNodeDefaultColor())
.append("nodeAlarmColor", getNodeAlarmColor())
.append("isAlarm", getIsAlarm())
.append("status", getStatus())
.append("delFlag", getDelFlag())
.append("createBy", getCreateBy())
.append("createTime", getCreateTime())
.append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime())
.toString();
}
}

View File

@ -0,0 +1,69 @@
package com.inspur.ipc.mapper;
import java.util.List;
import com.inspur.ipc.domain.IpcFaultTreeConfig;
/**
* 故障树配置Mapper接口
*
* @author inspur
* @date 2024-04-02
*/
public interface IpcFaultTreeConfigMapper
{
/**
* 查询故障树配置
*
* @param nodeId 故障树配置主键
* @return 故障树配置
*/
public IpcFaultTreeConfig selectIpcFaultTreeConfigByNodeId(Long nodeId);
/**
* 校验是否存在子节点
*
* @param nodeId 故障树配置主键
* @return 故障树配置
*/
public int hasChild(Long nodeId);
/**
* 查询故障树配置列表
*
* @param ipcFaultTreeConfig 故障树配置
* @return 故障树配置集合
*/
public List<IpcFaultTreeConfig> selectIpcFaultTreeConfigList(IpcFaultTreeConfig ipcFaultTreeConfig);
/**
* 新增故障树配置
*
* @param ipcFaultTreeConfig 故障树配置
* @return 结果
*/
public int insertIpcFaultTreeConfig(IpcFaultTreeConfig ipcFaultTreeConfig);
/**
* 修改故障树配置
*
* @param ipcFaultTreeConfig 故障树配置
* @return 结果
*/
public int updateIpcFaultTreeConfig(IpcFaultTreeConfig ipcFaultTreeConfig);
/**
* 删除故障树配置
*
* @param nodeId 故障树配置主键
* @return 结果
*/
public int deleteIpcFaultTreeConfigByNodeId(Long nodeId);
/**
* 批量删除故障树配置
*
* @param nodeIds 需要删除的数据主键集合
* @return 结果
*/
public int deleteIpcFaultTreeConfigByNodeIds(Long[] nodeIds);
}

View File

@ -0,0 +1,21 @@
package com.inspur.ipc.service;
import java.util.List;
import java.util.Map;
/**
* 数据展示界面Service接口
*
* @author inspur
*/
public interface IIpcDataLogService {
/**
* plc数据记录接口
*/
public List<Map<String,Object>> queryPlcDataLog(String part);
/**
* 温振传感器数据记录接口
*/
public List<Map<String,Object>> querySensorDataLog(String part);
}

View File

@ -0,0 +1,15 @@
package com.inspur.ipc.service;
import java.util.Map;
/**
* 数据展示界面Service接口
*
* @author inspur
*/
public interface IIpcDataShowService {
/**
* 展示数据获取
*/
public Map<String,Object> getShowData(String [] parts);
}

View File

@ -0,0 +1,70 @@
package com.inspur.ipc.service;
import java.util.List;
import com.inspur.ipc.domain.IpcFaultTreeConfig;
/**
* 故障树配置Service接口
*
* @author inspur
* @date 2024-04-02
*/
public interface IIpcFaultTreeConfigService
{
/**
* 查询故障树配置
*
* @param nodeId 故障树配置主键
* @return 故障树配置
*/
public IpcFaultTreeConfig selectIpcFaultTreeConfigByNodeId(Long nodeId);
/**
* 校验是否存在子节点
*
* @param nodeId 故障树配置主键
* @return 故障树配置
*/
public boolean hasChild(Long nodeId);
/**
* 查询故障树配置列表
*
* @param ipcFaultTreeConfig 故障树配置
* @return 故障树配置集合
*/
public List<IpcFaultTreeConfig> selectIpcFaultTreeConfigList(IpcFaultTreeConfig ipcFaultTreeConfig);
/**
* 新增故障树配置
*
* @param ipcFaultTreeConfig 故障树配置
* @return 结果
*/
public int insertIpcFaultTreeConfig(IpcFaultTreeConfig ipcFaultTreeConfig);
/**
* 修改故障树配置
*
* @param ipcFaultTreeConfig 故障树配置
* @return 结果
*/
public int updateIpcFaultTreeConfig(IpcFaultTreeConfig ipcFaultTreeConfig);
/**
* 批量删除故障树配置
*
* @param nodeIds 需要删除的故障树配置主键集合
* @return 结果
*/
public int deleteIpcFaultTreeConfigByNodeIds(Long[] nodeIds);
/**
* 删除故障树配置信息
*
* @param nodeId 故障树配置主键
* @return 结果
*/
public int deleteIpcFaultTreeConfigByNodeId(Long nodeId);
}

View File

@ -0,0 +1,37 @@
package com.inspur.ipc.service.impl;
import com.inspur.ipc.service.IIpcDataLogService;
import com.inspur.ipc.utils.IpcConstant;
import com.inspur.system.service.influx.InfluxDBService;
import org.influxdb.dto.QueryResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
@Service
public class IpcDataLogServiceImpl implements IIpcDataLogService {
@Autowired
private InfluxDBService influxDBService;
/**
* plc数据记录接口
*/
@Override
public List<Map<String, Object>> queryPlcDataLog(String part) {
QueryResult query = influxDBService.query("select * from "+ IpcConstant.PLC_MEASUREMENT +" where part = '" + part + "' order by time desc limit 20");
List<Map<String, Object>> maps = influxDBService.queryResultProcess(query);
return maps;
}
/**
* 温振传感器数据记录接口
*/
@Override
public List<Map<String, Object>> querySensorDataLog(String part) {
QueryResult query = influxDBService.query("select * from "+ IpcConstant.SENSOR_MEASUREMENT +" where part = '" + part + "' order by time desc limit 20");
List<Map<String, Object>> maps = influxDBService.queryResultProcess(query);
return maps;
}
}

View File

@ -0,0 +1,234 @@
package com.inspur.ipc.service.impl;
import com.inspur.ipc.service.IIpcDataShowService;
import com.inspur.ipc.utils.IpcConstant;
import com.inspur.system.service.influx.InfluxDBService;
import org.influxdb.dto.QueryResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
/**
* 数据展示界面Service业务层处理
*
* @author inspur
*/
@Service
public class IpcDataShowServiceImpl implements IIpcDataShowService {
@Autowired
private InfluxDBService influxDBService;
/**
* 展示数据获取
*/
@Override
public Map<String, Object> getShowData(String[] parts) {
Map<String, Object> dataMap = new HashMap<>();
CompletableFuture<Map<String, Map<String,Object>>> plcDataMap = CompletableFuture.supplyAsync(() -> dealPlcData(parts));
CompletableFuture<Map<String, Map<String,Object>>> sensorDataMap = CompletableFuture.supplyAsync(() -> dealSensorData(parts));
try {
plcDataMap.get().get(IpcConstant.OPERATION_NAME).putAll(sensorDataMap.get().get(IpcConstant.OPERATION_NAME));
plcDataMap.get().get(IpcConstant.DRIVE_NAME).putAll(sensorDataMap.get().get(IpcConstant.DRIVE_NAME));
dataMap.put(IpcConstant.OPERATION_NAME,plcDataMap.get().get(IpcConstant.OPERATION_NAME));
dataMap.put(IpcConstant.DRIVE_NAME,plcDataMap.get().get(IpcConstant.DRIVE_NAME));
} catch (InterruptedException e) {
e.printStackTrace();
} catch (ExecutionException e) {
e.printStackTrace();
}
return dataMap;
}
/**
* plc数据处理
* @param parts
* @return
*/
private Map<String,Map<String,Object>> dealPlcData(String[] parts){
Map<String, Map<String,Object>> dataMap = new HashMap<>();
try {
for (String part : parts) {
// 数据获取
QueryResult plcQuery = influxDBService.query("select * from " + IpcConstant.PLC_MEASUREMENT + " where part = '" + part + "' order by time desc limit 60");
List<Map<String, Object>> plcMaps = influxDBService.queryResultProcess(plcQuery);
// plc数据处理
// 横轴时间轴
List<String> xPlcData = new ArrayList<>();
//颗粒度4μm
List<Object> pz4 = new ArrayList<>();
//颗粒度6μm
List<Object> pz6 = new ArrayList<>();
//颗粒度14μm
List<Object> pz14 = new ArrayList<>();
//颗粒度21μm
List<Object> pz21 = new ArrayList<>();
//油水含量
List<Object> owc = new ArrayList<>();
//油品粘度
List<Object> ov = new ArrayList<>();
//回油温度
List<Object> rot = new ArrayList<>();
//轴套区温度
List<Object> ssat = new ArrayList<>();
//进油压力
List<Object> oip = new ArrayList<>();
//油液密度
List<Object> od = new ArrayList<>();
for (int i = plcMaps.size() - 1; i > -1; i--) {
System.out.println("1111111111111");
Map<String, Object> plcObj = plcMaps.get(i);
pz4.add(plcObj.get("pz4") == null ? 0 : plcObj.get("pz4"));
pz6.add(plcObj.get("pz6") == null ? 0 : plcObj.get("pz6"));
pz14.add(plcObj.get("pz14") == null ? 0 : plcObj.get("pz14"));
pz21.add(plcObj.get("pz21") == null ? 0 : plcObj.get("pz21"));
owc.add(plcObj.get("owc") == null ? 0 : plcObj.get("owc"));
ov.add(plcObj.get("ov") == null ? 0 : plcObj.get("ov"));
rot.add(plcObj.get("rot") == null ? 0 : plcObj.get("rot"));
ssat.add(plcObj.get("ssat") == null ? 0 : plcObj.get("ssat"));
oip.add(plcObj.get("oip") == null ? 0 : plcObj.get("oip"));
od.add(plcObj.get("od") == null ? 0 : plcObj.get("od"));
if (plcObj.containsKey("insertTime") && null != plcObj.get("insertTime")) {
xPlcData.add(this.dateTimeDeal(plcObj.get("insertTime"),"minute"));
}
}
Map<String, Object> map = new HashMap<>();
if (!xPlcData.isEmpty()) {
int plcIndex = xPlcData.size() - 1;
map.put("xPlcData", xPlcData);
map.put("pz4", pz4);
map.put("pz6", pz6);
map.put("pz14", pz14);
map.put("pz21", pz21);
map.put("owc", owc.get(plcIndex));
map.put("ov", ov.get(plcIndex));
map.put("rot", rot.get(plcIndex));
map.put("ssat", ssat.get(plcIndex));
map.put("oip", oip.get(plcIndex));
map.put("od", od.get(plcIndex));
}
// 根据位置处理
if (part.endsWith(IpcConstant.OPERATION_PROFILE)) {
// 操作侧
dataMap.put(IpcConstant.OPERATION_NAME, map);
} else if (part.endsWith(IpcConstant.DRIVE_PROFILE)) {
// 传动侧
dataMap.put(IpcConstant.DRIVE_NAME, map);
}
}
} catch (Exception e) {
e.printStackTrace();
}
return dataMap;
}
/**
* 传感器温振数据处理
* @param parts
* @return
*/
private Map<String,Map<String,Object>> dealSensorData(String[] parts){
Map<String, Map<String,Object>> dataMap = new HashMap<>();
try {
for (String part : parts) {
// 数据获取
QueryResult sensorQuery = influxDBService.query("select * from " + IpcConstant.SENSOR_MEASUREMENT + " where part = '" + part + "' order by time desc limit 60");
List<Map<String, Object>> sensorMaps = influxDBService.queryResultProcess(sensorQuery);
// 传感器温振数据处理
// 横轴时间轴
List<String> xSensorData = new ArrayList<>();
//振动温度
List<Object> vt = new ArrayList<>();
//振动x轴
List<Object> vx = new ArrayList<>();
//振动y轴
List<Object> vy = new ArrayList<>();
//振动z轴
List<Object> vz = new ArrayList<>();
for (int i = sensorMaps.size() - 1; i > -1; i--) {
System.out.println("222222222222");
Map<String, Object> sensorObj = sensorMaps.get(i);
vt.add(sensorObj.get("vt") == null ? 0 : sensorObj.get("vt"));
vx.add(sensorObj.get("vx") == null ? 0 : sensorObj.get("vx"));
vy.add(sensorObj.get("vy") == null ? 0 : sensorObj.get("vy"));
vz.add(sensorObj.get("vz") == null ? 0 : sensorObj.get("vz"));
if (sensorObj.containsKey("insertTime") && null != sensorObj.get("insertTime")) {
xSensorData.add(this.dateTimeDeal(sensorObj.get("insertTime"),"hour"));
}
}
Map<String, Object> map = new HashMap<>();
if (!xSensorData.isEmpty()) {
int sensorIndex = xSensorData.size() - 1;
map.put("xSensorData", xSensorData);
map.put("vt", vt.get(sensorIndex));
map.put("vx", vx);
map.put("vy", vy);
map.put("vz", vz);
}
// 根据位置处理
if (part.endsWith(IpcConstant.OPERATION_PROFILE)) {
// 操作侧
dataMap.put(IpcConstant.OPERATION_NAME, map);
} else if (part.endsWith(IpcConstant.DRIVE_PROFILE)) {
// 传动侧
dataMap.put(IpcConstant.DRIVE_NAME, map);
}
}
} catch (Exception e) {
e.printStackTrace();
}
return dataMap;
}
/**
* 时间格式处理
*
* @param obj
* @return
*/
private String dateTimeDeal(Object obj, String type) {
String dateTime = "";
//处理时间
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
try {
Date time = simpleDateFormat.parse(String.valueOf(obj));
Calendar calendar = Calendar.getInstance();
calendar.setTime(time);
int y = calendar.get(Calendar.YEAR);
String month = calendar.get(Calendar.MONTH) > 9 ? ""+calendar.get(Calendar.MONTH) : "0"+calendar.get(Calendar.MONTH);
String d = calendar.get(Calendar.DAY_OF_MONTH) > 9 ? ""+calendar.get(Calendar.DAY_OF_MONTH) : "0"+calendar.get(Calendar.DAY_OF_MONTH);
String h = calendar.get(Calendar.HOUR_OF_DAY) > 9 ? ""+calendar.get(Calendar.HOUR_OF_DAY) : "0"+calendar.get(Calendar.HOUR_OF_DAY);
String m = calendar.get(Calendar.MINUTE) > 9 ? ""+calendar.get(Calendar.MINUTE) : "0"+calendar.get(Calendar.MINUTE);
String s = calendar.get(Calendar.SECOND) > 9 ? ""+calendar.get(Calendar.SECOND) : "0"+calendar.get(Calendar.SECOND);
switch (type) {
case "year":
dateTime = y + "-" + month + "-" + d + " " + h + ":" + m + ":" + s;
break;
case "month":
dateTime = month + "-" + d + " " + h + ":" + m + ":" + s;
break;
case "day":
dateTime = d + " " + h + ":" + m + ":" + s;
break;
case "hour":
dateTime = h + ":" + m + ":" + s;
break;
case "minute":
dateTime = m + ":" + s;
break;
default:
dateTime = m + ":" + s;
break;
}
} catch (ParseException e) {
e.printStackTrace();
}
return dateTime;
}
}

View File

@ -0,0 +1,105 @@
package com.inspur.ipc.service.impl;
import java.util.List;
import com.inspur.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.inspur.ipc.mapper.IpcFaultTreeConfigMapper;
import com.inspur.ipc.domain.IpcFaultTreeConfig;
import com.inspur.ipc.service.IIpcFaultTreeConfigService;
/**
* 故障树配置Service业务层处理
*
* @author inspur
* @date 2024-04-02
*/
@Service
public class IpcFaultTreeConfigServiceImpl implements IIpcFaultTreeConfigService
{
@Autowired
private IpcFaultTreeConfigMapper ipcFaultTreeConfigMapper;
/**
* 查询故障树配置
*
* @param nodeId 故障树配置主键
* @return 故障树配置
*/
@Override
public IpcFaultTreeConfig selectIpcFaultTreeConfigByNodeId(Long nodeId)
{
return ipcFaultTreeConfigMapper.selectIpcFaultTreeConfigByNodeId(nodeId);
}
/**
* 校验是否存在子节点
*
* @param nodeId 故障树配置主键
* @return 故障树配置
*/
@Override
public boolean hasChild(Long nodeId){
return ipcFaultTreeConfigMapper.hasChild(nodeId) > 0;
}
/**
* 查询故障树配置列表
*
* @param ipcFaultTreeConfig 故障树配置
* @return 故障树配置
*/
@Override
public List<IpcFaultTreeConfig> selectIpcFaultTreeConfigList(IpcFaultTreeConfig ipcFaultTreeConfig)
{
return ipcFaultTreeConfigMapper.selectIpcFaultTreeConfigList(ipcFaultTreeConfig);
}
/**
* 新增故障树配置
*
* @param ipcFaultTreeConfig 故障树配置
* @return 结果
*/
@Override
public int insertIpcFaultTreeConfig(IpcFaultTreeConfig ipcFaultTreeConfig)
{
ipcFaultTreeConfig.setCreateTime(DateUtils.getNowDate());
return ipcFaultTreeConfigMapper.insertIpcFaultTreeConfig(ipcFaultTreeConfig);
}
/**
* 修改故障树配置
*
* @param ipcFaultTreeConfig 故障树配置
* @return 结果
*/
@Override
public int updateIpcFaultTreeConfig(IpcFaultTreeConfig ipcFaultTreeConfig)
{
ipcFaultTreeConfig.setUpdateTime(DateUtils.getNowDate());
return ipcFaultTreeConfigMapper.updateIpcFaultTreeConfig(ipcFaultTreeConfig);
}
/**
* 批量删除故障树配置
*
* @param nodeIds 需要删除的故障树配置主键
* @return 结果
*/
@Override
public int deleteIpcFaultTreeConfigByNodeIds(Long[] nodeIds)
{
return ipcFaultTreeConfigMapper.deleteIpcFaultTreeConfigByNodeIds(nodeIds);
}
/**
* 删除故障树配置信息
*
* @param nodeId 故障树配置主键
* @return 结果
*/
@Override
public int deleteIpcFaultTreeConfigByNodeId(Long nodeId)
{
return ipcFaultTreeConfigMapper.deleteIpcFaultTreeConfigByNodeId(nodeId);
}
}

View File

@ -35,4 +35,29 @@ public class IpcConstant {
* 区间外
*/
public static final String OUTSIDE_INTERVAL = "区间外";
/**
* plc数据表名
*/
public static final String PLC_MEASUREMENT = "tzipc_plc_monitor_data_list";
/**
* 温振传感器数据表名
*/
public static final String SENSOR_MEASUREMENT = "tzipc_sensor_monitor_data_list";
/**
* 操作侧简写
*/
public static final String OPERATION_PROFILE = "o";
/**
* 传动侧简写
*/
public static final String DRIVE_PROFILE = "d";
/**
* 操作侧
*/
public static final String OPERATION_NAME = "operation";
/**
* 传动侧
*/
public static final String DRIVE_NAME = "drive";
}

View File

@ -86,7 +86,7 @@ public class IpcUtil {
if (judgeAlarm(map.get(rulesConfig.getNameKey()), rulesConfig.getReferenceValue1(), rulesConfig.getReferenceValue2(), rulesConfig.getReferenceCon())) {
// 报警数据
map.put("isAlarm", 1);
IpcAlarmRecord ipcAlarmRecord = new IpcAlarmRecord(IdUtils.fastSimpleUUID(),rulesConfig.getPartKey(), rulesConfig.getPart(), rulesConfig.getNameKey(), rulesConfig.getName(), String.valueOf(map.get(rulesConfig.getNameKey())), rulesConfig.getUnit(), rulesConfig.getAlarmLevel(), rulesConfig.getReferenceName(), rulesConfig.getAlarmDetail());
IpcAlarmRecord ipcAlarmRecord = new IpcAlarmRecord(IdUtils.fastSimpleUUID(),rulesConfig.getPartKey(), rulesConfig.getPart(), rulesConfig.getNameKey(), rulesConfig.getName(), String.valueOf(map.get(rulesConfig.getNameKey())), rulesConfig.getUnit(), rulesConfig.getAlarmLevel(), rulesConfig.getReferenceName(), rulesConfig.getAlarmDetail(),rulesConfig.getId());
returnList.add(ipcAlarmRecord);
} else {
// 正常数据

View File

@ -107,11 +107,11 @@
<insert id="batchInsertIpcAlarmRecord" parameterType="com.inspur.ipc.domain.IpcAlarmRecord">
insert into ipc_alarm_record
(id,part_key,part,name_key,name,alarm_data,unit,alarm_level,alarm_time,reference_name,alarm_detail,alarm_status)
(id,part_key,part,name_key,name,alarm_data,unit,alarm_level,alarm_time,reference_name,alarm_detail,alarm_status,rule_config_id)
values
<foreach item="item" collection="list" separator=",">
(#{item.id}, #{item.partKey}, #{item.part},#{item.nameKey},#{item.name},#{item.alarmData}, #{item.unit},
#{item.alarmLevel},sysdate(),#{item.referenceName},#{item.alarmDetail},'0')
#{item.alarmLevel},sysdate(),#{item.referenceName},#{item.alarmDetail},'0',#{item.ruleConfigId})
</foreach>
;
</insert>

View File

@ -0,0 +1,141 @@
<?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.inspur.ipc.mapper.IpcFaultTreeConfigMapper">
<resultMap type="com.inspur.ipc.domain.IpcFaultTreeConfig" id="IpcFaultTreeConfigResult">
<result property="nodeId" column="node_id" />
<result property="parentId" column="parent_id" />
<result property="ancestors" column="ancestors" />
<result property="nodeName" column="node_name" />
<result property="orderNum" column="order_num" />
<result property="partKey" column="part_key" />
<result property="iconCls" column="icon_cls" />
<result property="nodeShapeType" column="node_shape_type" />
<result property="nodeDefaultColor" column="node_default_color" />
<result property="nodeAlarmColor" column="node_alarm_color" />
<result property="isLeaf" column="is_leaf" />
<result property="isAlarm" column="is_alarm" />
<result property="alarmRuleConfigId" column="alarm_rule_config_id" />
<result property="alarmRuleConfigDescription" column="alarm_rule_config_description" />
<result property="status" column="status" />
<result property="delFlag" column="del_flag" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
</resultMap>
<sql id="selectIpcFaultTreeConfigVo">
select node_id, parent_id, ancestors, node_name, order_num, part_key, icon_cls, node_shape_type, node_default_color, node_alarm_color, is_leaf,is_alarm, status, del_flag, create_by, create_time, update_by, update_time,alarm_rule_config_id,alarm_rule_config_description from ipc_fault_tree_config
</sql>
<select id="selectIpcFaultTreeConfigList" parameterType="com.inspur.ipc.domain.IpcFaultTreeConfig" resultMap="IpcFaultTreeConfigResult">
<include refid="selectIpcFaultTreeConfigVo"/>
<where>
<if test="parentId != null "> and parent_id = #{parentId}</if>
<if test="ancestors != null and ancestors != ''"> and ancestors = #{ancestors}</if>
<if test="nodeName != null and nodeName != ''"> and node_name like concat('%', #{nodeName}, '%')</if>
<if test="orderNum != null "> and order_num = #{orderNum}</if>
<if test="partKey != null and partKey != ''"> and part_key = #{partKey}</if>
<if test="iconCls != null and iconCls != ''"> and icon_cls = #{iconCls}</if>
<if test="nodeShapeType != null and nodeShapeType != ''"> and node_shape_type = #{nodeShapeType}</if>
<if test="nodeDefaultColor != null and nodeDefaultColor != ''"> and node_default_color = #{nodeDefaultColor}</if>
<if test="nodeAlarmColor != null and nodeAlarmColor != ''"> and node_alarm_color = #{nodeAlarmColor}</if>
<if test="isAlarm != null and isAlarm != ''"> and is_alarm = #{isAlarm}</if>
<if test="status != null and status != ''"> and status = #{status}</if>
</where>
</select>
<select id="selectIpcFaultTreeConfigByNodeId" parameterType="Long" resultMap="IpcFaultTreeConfigResult">
<include refid="selectIpcFaultTreeConfigVo"/>
where node_id = #{nodeId}
</select>
<select id="hasChild" parameterType="Long" resultType="int">
select count(0) from ipc_fault_tree_config where parent_id = #{nodeId}
</select>
<insert id="insertIpcFaultTreeConfig" parameterType="com.inspur.ipc.domain.IpcFaultTreeConfig" useGeneratedKeys="true" keyProperty="nodeId">
insert into ipc_fault_tree_config
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="parentId != null">parent_id,</if>
<if test="ancestors != null">ancestors,</if>
<if test="nodeName != null">node_name,</if>
<if test="orderNum != null">order_num,</if>
<if test="partKey != null">part_key,</if>
<if test="iconCls != null">icon_cls,</if>
<if test="nodeShapeType != null">node_shape_type,</if>
<if test="nodeDefaultColor != null">node_default_color,</if>
<if test="nodeAlarmColor != null">node_alarm_color,</if>
<if test="isLeaf != null">is_leaf,</if>
<if test="isAlarm != null">is_alarm,</if>
<if test="status != null">status,</if>
<if test="delFlag != null">del_flag,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="alarmRuleConfigId != null">alarm_rule_config_id,</if>
<if test="alarmRuleConfigDescription != null">alarm_rule_config_description,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="parentId != null">#{parentId},</if>
<if test="ancestors != null">#{ancestors},</if>
<if test="nodeName != null">#{nodeName},</if>
<if test="orderNum != null">#{orderNum},</if>
<if test="partKey != null">#{partKey},</if>
<if test="iconCls != null">#{iconCls},</if>
<if test="nodeShapeType != null">#{nodeShapeType},</if>
<if test="nodeDefaultColor != null">#{nodeDefaultColor},</if>
<if test="nodeAlarmColor != null">#{nodeAlarmColor},</if>
<if test="isLeaf != null">#{isLeaf},</if>
<if test="isAlarm != null">#{isAlarm},</if>
<if test="status != null">#{status},</if>
<if test="delFlag != null">#{delFlag},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="alarmRuleConfigId != null">#{alarmRuleConfigId},</if>
<if test="alarmRuleConfigDescription != null">#{alarmRuleConfigDescription},</if>
</trim>
</insert>
<update id="updateIpcFaultTreeConfig" parameterType="com.inspur.ipc.domain.IpcFaultTreeConfig">
update ipc_fault_tree_config
<trim prefix="SET" suffixOverrides=",">
<if test="parentId != null">parent_id = #{parentId},</if>
<if test="ancestors != null">ancestors = #{ancestors},</if>
<if test="nodeName != null">node_name = #{nodeName},</if>
<if test="orderNum != null">order_num = #{orderNum},</if>
<if test="partKey != null">part_key = #{partKey},</if>
<if test="iconCls != null">icon_cls = #{iconCls},</if>
<if test="nodeShapeType != null">node_shape_type = #{nodeShapeType},</if>
<if test="nodeDefaultColor != null">node_default_color = #{nodeDefaultColor},</if>
<if test="nodeAlarmColor != null">node_alarm_color = #{nodeAlarmColor},</if>
<if test="isLeaf != null">is_leaf = #{isLeaf},</if>
<if test="isAlarm != null">is_alarm = #{isAlarm},</if>
<if test="status != null">status = #{status},</if>
<if test="delFlag != null">del_flag = #{delFlag},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="alarmRuleConfigId != null">alarm_rule_config_id = #{alarmRuleConfigId},</if>
<if test="alarmRuleConfigDescription != null">alarm_rule_config_description = #{alarmRuleConfigDescription},</if>
</trim>
where node_id = #{nodeId}
</update>
<delete id="deleteIpcFaultTreeConfigByNodeId" parameterType="Long">
delete from ipc_fault_tree_config where node_id = #{nodeId}
</delete>
<delete id="deleteIpcFaultTreeConfigByNodeIds" parameterType="String">
delete from ipc_fault_tree_config where node_id in
<foreach item="nodeId" collection="array" open="(" separator="," close=")">
#{nodeId}
</foreach>
</delete>
</mapper>

View File

@ -0,0 +1,17 @@
import request from "@/utils/request";
// 查询plc数据记录
export function getPlcDataLog(part) {
return request({
url: "/ipc/dataLog/plc/" + part,
method: "get",
});
}
// 查询传感器温振数据记录
export function getSensorDataLog(part) {
return request({
url: "/ipc/dataLog/sensor/" + part,
method: "get",
});
}

View File

@ -0,0 +1,9 @@
import request from "@/utils/request";
// 根据部位查询展示数据
export function getShowData(parts) {
return request({
url: "/ipc/dataShow/byPart/" + parts,
method: "get",
});
}

View File

@ -0,0 +1,52 @@
import request from "@/utils/request";
// 查询故障树配置列表
export function listFaultTreeConfig(query) {
return request({
url: "/ipc/faultTreeConfig/list",
method: "get",
params: query,
});
}
// 查询故障树配置详细
export function getFaultTreeConfig(nodeId) {
return request({
url: "/ipc/faultTreeConfig/" + nodeId,
method: "get",
});
}
// 查询是否有子节点
export function selectHasChild(nodeId) {
return request({
url: "/ipc/faultTreeConfig/hasChild/" + nodeId,
method: "get",
});
}
// 新增故障树配置
export function addFaultTreeConfig(data) {
return request({
url: "/ipc/faultTreeConfig",
method: "post",
data: data,
});
}
// 修改故障树配置
export function updateFaultTreeConfig(data) {
return request({
url: "/ipc/faultTreeConfig",
method: "put",
data: data,
});
}
// 删除故障树配置
export function delFaultTreeConfig(nodeId) {
return request({
url: "/ipc/faultTreeConfig/" + nodeId,
method: "delete",
});
}

View File

@ -677,7 +677,7 @@ export default {
</script>
<style scoped lang="scss">
.color-green {
color: greenyellow;
color: green;
}
.picker .el-picker-panel__sidebar {

View File

@ -0,0 +1,280 @@
<template>
<div class="app-container image-background">
<el-select
v-model="part"
placeholder="请选择监测部位"
@change="getList()"
>
<el-option
v-for="field in monitorPartList"
:key="field.fieldValue"
:label="field.fieldLabel"
:value="field.fieldValue"
/>
</el-select>
<div class="content-but">
<div
v-if="refresh"
class="button-start"
@click="stopRefresh"
>暂停刷新</div>
<div
v-else
class="button-stop"
@click="startRefresh"
>自动刷新</div>
</div>
<el-table
class="tableCss"
v-loading="loading"
:data="dataList"
:row-class-name="tableRowClassName"
header-row-class-name="header-row"
>
<el-table-column
label="序号"
type="index"
align="center"
>
<template slot-scope="scope">
<span>{{scope.$index + 1}}</span>
</template>
</el-table-column>
<el-table-column
label="时间"
align="center"
key="insertTime"
prop="insertTime"
width="200"
show-overflow-tooltip
/>
<el-table-column
label="颗粒度4μm"
align="center"
key="pz4"
prop="pz4"
show-overflow-tooltip
/>
<el-table-column
label="颗粒度6μm"
align="center"
key="pz6"
prop="pz6"
show-overflow-tooltip
/>
<el-table-column
label="颗粒度14μm"
align="center"
key="pz14"
prop="pz14"
show-overflow-tooltip
/>
<el-table-column
label="颗粒度21μm"
align="center"
key="pz21"
prop="pz21"
show-overflow-tooltip
/>
<el-table-column
label="油水含量"
align="center"
key="owc"
prop="owc"
show-overflow-tooltip
/>
<el-table-column
label="油品粘度"
align="center"
key="ov"
prop="ov"
show-overflow-tooltip
/>
<el-table-column
label="回油温度"
align="center"
key="rot"
prop="rot"
show-overflow-tooltip
/>
<el-table-column
label="轴套区温度"
align="center"
key="ssat"
prop="ssat"
show-overflow-tooltip
/>
<el-table-column
label="进油压力"
align="center"
key="oip"
prop="oip"
show-overflow-tooltip
/>
<el-table-column
label="油液密度"
align="center"
key="od"
prop="od"
show-overflow-tooltip
/>
</el-table>
</div>
</template>
<script>
import { getPlcDataLog } from "@/api/ipc/dataLog";
import { getFields } from "@/api/ipc/monitorFields";
export default {
name: "plcDataLog",
data() {
return {
//
loading: true,
//
total: 0,
//
queryParams: {
pageNum: 1,
pageSize: 10,
},
//
monitorPartList: [],
part: "",
dataList: [],
refresh: false,
};
},
created() {
this.getMonitorPartList();
},
methods: {
/** 查询监测部位列表 */
getMonitorPartList() {
getFields("monitor_part")
.then((res) => {
this.monitorPartList = res.data;
this.part = this.monitorPartList[0].fieldValue;
this.getList();
})
.catch((error) => {
console.log(error);
});
},
/** 查询列表 */
getList() {
this.loading = true;
getPlcDataLog(this.part).then((response) => {
this.dataList = response.data;
this.loading = false;
});
},
tableRowClassName({ row, rowIndex }) {
if (rowIndex % 2 === 0) {
return "color-row";
}
return "";
},
startRefresh() {
this.refresh = true;
this.getDataTimer = setInterval(() => {
this.getList();
}, 1000);
},
stopRefresh() {
clearInterval(this.getDataTimer);
this.refresh = false;
},
},
};
</script>
<style lang="scss">
@import "@/theme/index.scss";
.color-row {
background-color: #67c7ff !important;
}
.header-row {
background: linear-gradient(180deg, #0b2357 0%, #2094dc 48%, #0b2357 100%);
opacity: 1;
}
.header-row .cell {
@include font_color(fontPrimary);
}
</style>
<style scoped lang="scss">
@import "@/theme/index.scss";
.image-background {
@include background_bg(homeBackgroundImage);
height: 100%;
padding-top: 0px;
}
.content {
max-width: 1400px;
margin: auto;
}
.success {
width: 12px;
height: 12px;
margin-right: 10px;
box-shadow: 0px 0px 6px 0px #0ddf7a, 0px 0px 10px 0px #0ddf7a;
opacity: 1;
border: 2px solid #0ddf7a;
border-radius: 12px;
}
.fail {
width: 12px;
height: 12px;
margin-right: 10px;
box-shadow: 0px 0px 6px 0px #ff473e, 0px 0px 10px 0px #ff473e;
opacity: 1;
border: 2px solid #ff473e;
border-radius: 12px;
}
.data-status-wrapper {
display: flex;
justify-content: center;
align-items: center;
span {
position: relative;
top: 2px;
}
}
.content-but {
height: 40px;
display: flex;
align-items: center;
float: right;
padding-right: 50px;
}
.button-start {
width: 100px;
height: 32px;
background: linear-gradient(180deg, #f18c41 0%, #b94e00 100%);
border-radius: 2px 2px 2px 2px;
opacity: 0.9;
border: 1px solid #f1bf23;
display: flex;
justify-content: center;
align-items: center;
cursor: pointer;
}
.button-stop {
width: 100px;
height: 32px;
background: linear-gradient(180deg, #3fbaff 0%, #0a4e83 100%);
border-radius: 2px 2px 2px 2px;
opacity: 0.9;
border: 1px solid #3fbaff;
display: flex;
justify-content: center;
align-items: center;
cursor: pointer;
}
</style>

View File

@ -0,0 +1,238 @@
<template>
<div class="app-container image-background">
<el-select
v-model="part"
placeholder="请选择监测部位"
@change="getList()"
>
<el-option
v-for="field in monitorPartList"
:key="field.fieldValue"
:label="field.fieldLabel"
:value="field.fieldValue"
/>
</el-select>
<div class="content-but">
<div
v-if="refresh"
class="button-start"
@click="stopRefresh"
>暂停刷新</div>
<div
v-else
class="button-stop"
@click="startRefresh"
>自动刷新</div>
</div>
<el-table
class="tableCss"
v-loading="loading"
:data="dataList"
:row-class-name="tableRowClassName"
header-row-class-name="header-row"
>
<el-table-column
label="序号"
type="index"
align="center"
>
<template slot-scope="scope">
<span>{{scope.$index + 1}}</span>
</template>
</el-table-column>
<el-table-column
label="时间"
align="center"
key="insertTime"
prop="insertTime"
width="200"
show-overflow-tooltip
/>
<el-table-column
label="振动温度"
align="center"
key="vt"
prop="vt"
show-overflow-tooltip
/>
<el-table-column
label="振动x轴"
align="center"
key="vx"
prop="vx"
show-overflow-tooltip
/>
<el-table-column
label="振动y轴"
align="center"
key="vy"
prop="vy"
show-overflow-tooltip
/>
<el-table-column
label="振动z轴"
align="center"
key="vz"
prop="vz"
show-overflow-tooltip
/>
</el-table>
</div>
</template>
<script>
import { getSensorDataLog } from "@/api/ipc/dataLog";
import { getFields } from "@/api/ipc/monitorFields";
export default {
name: "sensolrDataLog",
data() {
return {
//
loading: true,
//
total: 0,
//
queryParams: {
pageNum: 1,
pageSize: 10,
},
//
monitorPartList: [],
part: "",
dataList: [],
refresh: false,
};
},
created() {
this.getMonitorPartList();
},
methods: {
/** 查询监测部位列表 */
getMonitorPartList() {
getFields("monitor_part")
.then((res) => {
this.monitorPartList = res.data;
this.part = this.monitorPartList[0].fieldValue;
this.getList();
})
.catch((error) => {
console.log(error);
});
},
/** 查询列表 */
getList() {
this.loading = true;
getSensorDataLog(this.part).then((response) => {
this.dataList = response.data;
this.loading = false;
});
},
tableRowClassName({ row, rowIndex }) {
if (rowIndex % 2 === 0) {
return "color-row";
}
return "";
},
startRefresh() {
this.refresh = true;
this.getDataTimer = setInterval(() => {
this.getList();
}, 1000);
},
stopRefresh() {
clearInterval(this.getDataTimer);
this.refresh = false;
},
},
};
</script>
<style lang="scss">
@import "@/theme/index.scss";
.color-row {
background-color: #67c7ff !important;
}
.header-row {
background: linear-gradient(180deg, #0b2357 0%, #2094dc 48%, #0b2357 100%);
opacity: 1;
}
.header-row .cell {
@include font_color(fontPrimary);
}
</style>
<style scoped lang="scss">
@import "@/theme/index.scss";
.image-background {
@include background_bg(homeBackgroundImage);
height: 100%;
padding-top: 0px;
}
.content {
max-width: 1400px;
margin: auto;
}
.success {
width: 12px;
height: 12px;
margin-right: 10px;
box-shadow: 0px 0px 6px 0px #0ddf7a, 0px 0px 10px 0px #0ddf7a;
opacity: 1;
border: 2px solid #0ddf7a;
border-radius: 12px;
}
.fail {
width: 12px;
height: 12px;
margin-right: 10px;
box-shadow: 0px 0px 6px 0px #ff473e, 0px 0px 10px 0px #ff473e;
opacity: 1;
border: 2px solid #ff473e;
border-radius: 12px;
}
.data-status-wrapper {
display: flex;
justify-content: center;
align-items: center;
span {
position: relative;
top: 2px;
}
}
.content-but {
height: 40px;
display: flex;
align-items: center;
float: right;
padding-right: 50px;
}
.button-start {
width: 100px;
height: 32px;
background: linear-gradient(180deg, #f18c41 0%, #b94e00 100%);
border-radius: 2px 2px 2px 2px;
opacity: 0.9;
border: 1px solid #f1bf23;
display: flex;
justify-content: center;
align-items: center;
cursor: pointer;
}
.button-stop {
width: 100px;
height: 32px;
background: linear-gradient(180deg, #3fbaff 0%, #0a4e83 100%);
border-radius: 2px 2px 2px 2px;
opacity: 0.9;
border: 1px solid #3fbaff;
display: flex;
justify-content: center;
align-items: center;
cursor: pointer;
}
</style>

View File

@ -0,0 +1,771 @@
<template>
<div class="app-container">
<el-form
:model="queryParams"
ref="queryForm"
size="small"
:inline="true"
v-show="showSearch"
label-width="68px"
>
<el-form-item
label="部门名称"
prop="nodeName"
>
<el-input
v-model="queryParams.nodeName"
placeholder="请输入部门名称"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item
label="节点状态"
prop="status"
>
<el-select
v-model="queryParams.status"
placeholder="请选择节点状态"
clearable
>
<el-option
v-for="dict in dict.type.sys_normal_disable"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
<el-form-item>
<el-button
type="primary"
icon="el-icon-search"
size="mini"
@click="handleQuery"
>搜索</el-button>
<el-button
icon="el-icon-refresh"
size="mini"
@click="resetQuery"
>重置</el-button>
</el-form-item>
</el-form>
<el-row
:gutter="10"
class="mb8"
>
<el-col :span="1.5">
<el-button
type="primary"
plain
icon="el-icon-plus"
size="mini"
@click="handleAdd"
v-hasPermi="['ipc:faultTreeConfig:add']"
>新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="info"
plain
icon="el-icon-sort"
size="mini"
@click="toggleExpandAll"
>展开/折叠</el-button>
</el-col>
<right-toolbar
:showSearch.sync="showSearch"
@queryTable="getList"
></right-toolbar>
</el-row>
<el-table
v-if="refreshTable"
v-loading="loading"
:data="faultTreeConfigList"
row-key="nodeId"
:default-expand-all="isExpandAll"
:tree-props="{children: 'children', hasChildren: 'hasChildren'}"
>
<el-table-column
label="部门名称"
align="center"
prop="nodeName"
show-overflow-tooltip
/>
<el-table-column
label="显示顺序"
align="center"
prop="orderNum"
width="100"
show-overflow-tooltip
/>
<!-- <el-table-column
label="所属部位"
align="center"
prop="partKey"
show-overflow-tooltip
/>-->
<el-table-column
label="节点图标"
align="center"
prop="iconCls"
show-overflow-tooltip
>
<template slot-scope="scope">
<dict-tag
:options="dict.type.node_icon"
:value="scope.row.iconCls"
/>
</template>
</el-table-column>
<el-table-column
label="节点形状"
align="center"
prop="nodeShapeType"
show-overflow-tooltip
>
<template slot-scope="scope">
<dict-tag
:options="dict.type.node_shape"
:value="scope.row.nodeShapeType"
/>
</template>
</el-table-column>
<el-table-column
label="节点默认颜色"
align="center"
prop="nodeDefaultColor"
show-overflow-tooltip
>
<template slot-scope="scope">
<dict-tag
:options="dict.type.node_default_color"
:value="scope.row.nodeDefaultColor"
/>
</template>
</el-table-column>
<el-table-column
label="节点报警颜色"
align="center"
prop="nodeAlarmColor"
show-overflow-tooltip
>
<template slot-scope="scope">
<dict-tag
:options="dict.type.node_alarm_color"
:value="scope.row.nodeAlarmColor"
/>
</template>
</el-table-column>
<el-table-column
label="节点状态"
align="center"
prop="status"
show-overflow-tooltip
>
<template slot-scope="scope">
<dict-tag
:options="dict.type.sys_normal_disable"
:value="scope.row.status"
/>
</template>
</el-table-column>
<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-edit"
@click="handleUpdate(scope.row)"
v-hasPermi="['ipc:faultTreeConfig:edit']"
>修改</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-plus"
@click="handleAdd(scope.row)"
v-hasPermi="['ipc:faultTreeConfig:add']"
>新增</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
v-hasPermi="['ipc:faultTreeConfig:remove']"
v-if="scope.row.parentId != 0"
>删除</el-button>
</template>
</el-table-column>
</el-table>
<!-- 添加或修改故障树配置对话框 -->
<el-dialog
:title="title"
:visible.sync="open"
width="800px"
append-to-body
>
<el-form
ref="form"
:model="form"
:rules="rules"
label-width="80px"
>
<el-row>
<el-col :span="12">
<el-form-item
label="节点名称"
prop="nodeName"
>
<el-input
v-model="form.nodeName"
placeholder="请输入节点名称"
/>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item
label="父节点"
prop="parentId"
v-if="form.parentId != 0"
>
<treeselect
v-model="parentId"
:options="faultTreeConfigOptions"
:normalizer="normalizer"
placeholder="请选择父节点id"
/>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="12">
<el-form-item
label="显示顺序"
prop="orderNum"
>
<el-input-number
v-model="form.orderNum"
:max=100
:min=0
placeholder="请输入显示顺序"
/>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item
label="所属部位"
prop="partKey"
>
<span class="color-green">
{{ labelShow(monitorPartList,form.partKey) }}
</span>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="12">
<el-form-item
label="节点图标"
prop="iconCls"
>
<el-select
v-model="form.iconCls"
placeholder="请选择节点图标"
>
<el-option
v-for="dict in dict.type.node_icon"
:key="dict.value"
:label="dict.label"
:value="dict.value"
></el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item
label="节点形状"
prop="nodeShapeType"
>
<el-select
v-model="form.nodeShapeType"
placeholder="请选择节点形状"
>
<el-option
v-for="dict in dict.type.node_shape"
:key="dict.value"
:label="dict.label"
:value="dict.value"
></el-option>
</el-select>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="12">
<el-form-item
label="节点默认颜色"
prop="nodeDefaultColor"
>
<el-select
v-model="form.nodeDefaultColor"
placeholder="请选择节点默认颜色"
>
<el-option
v-for="dict in dict.type.node_default_color"
:key="dict.value"
:label="dict.label"
:value="dict.value"
></el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item
label="节点报警颜色"
prop="nodeAlarmColor"
>
<el-select
v-model="form.nodeAlarmColor"
placeholder="请选择节点报警颜色"
>
<el-option
v-for="dict in dict.type.node_alarm_color"
:key="dict.value"
:label="dict.label"
:value="dict.value"
></el-option>
</el-select>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="12">
<el-form-item
label="节点状态"
prop="status"
>
<el-radio-group v-model="form.status">
<el-radio
v-for="dict in dict.type.sys_normal_disable"
:key="dict.value"
:label="dict.value"
>{{dict.label}}</el-radio>
</el-radio-group>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item
label="是否叶子节点"
prop="isLeaf"
>
<el-radio-group v-model="form.isLeaf">
<el-radio
@change="validateIsLeaf"
v-for="dict in dict.type.is_leaf"
:key="dict.value"
:label="dict.value"
>{{dict.label}}</el-radio>
</el-radio-group>
</el-form-item>
</el-col>
</el-row>
<el-row v-if="isShowRuleConfig">
<el-col :span="12">
<el-form-item label="报警规则描述">
<span class="color-red">{{ form.alarmRuleConfigDescription }}</span>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item prop="alarmRuleConfigId">
<el-button
type="primary"
@click="selectAlarmRule"
>选择报警规则</el-button>
</el-form-item>
</el-col>
</el-row>
</el-form>
<div
slot="footer"
class="dialog-footer"
>
<el-button
type="primary"
@click="submitForm"
> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
<RuleConfigDialog
:partKey="form.partKey"
:openRuleDia="openRuleDia"
@ruleDataReturn="ruleDataReturn"
@closeRuleDialog="closeRuleDialog"
></RuleConfigDialog>
</div>
</template>
<script>
import {
listFaultTreeConfig,
getFaultTreeConfig,
delFaultTreeConfig,
addFaultTreeConfig,
updateFaultTreeConfig,
selectHasChild,
} from "@/api/ipc/faultTreeConfig";
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
import { getFields } from "@/api/ipc/monitorFields";
import RuleConfigDialog from "@/views/ipc/faultTree/ruleConfigDialog";
export default {
name: "FaultTreeConfig",
dicts: [
"node_default_color",
"sys_normal_disable",
"node_icon",
"node_alarm_color",
"node_shape",
"is_leaf",
],
components: {
Treeselect,
RuleConfigDialog,
},
data() {
return {
//
openRuleDia: false,
//
isShowRuleConfig: false,
//
monitorPartList: [],
//
loading: true,
//
showSearch: true,
//
faultTreeConfigList: [],
//
faultTreeConfigOptions: [],
//
faultData: [],
//
title: "",
//
open: false,
//
isExpandAll: true,
//
refreshTable: true,
//
queryParams: {
parentId: null,
ancestors: null,
nodeName: null,
orderNum: null,
partKey: null,
iconCls: null,
nodeShapeType: null,
nodeDefaultColor: null,
nodeAlarmColor: null,
isAlarm: null,
status: null,
},
//
form: {},
parentId: "0",
//
rules: {
nodeName: [
{ required: true, message: "节点名称不能为空", trigger: "blur" },
{ max: 20, message: "节点名称长度不能大于20", trigger: "blur" },
],
parentId: [
{ required: true, message: "父节点不能为空", trigger: "blur" },
],
iconCls: [
{ required: true, message: "请选择节点图标", trigger: "blur" },
],
nodeShapeType: [
{ required: true, message: "请选择节点行政", trigger: "blur" },
],
nodeDefaultColor: [
{ required: true, message: "请选择节点默认颜色", trigger: "blur" },
],
nodeAlarmColor: [
{ required: true, message: "请选择节点报警颜色", trigger: "blur" },
],
status: [
{ required: true, message: "请选择节点状态", trigger: "blur" },
],
isLeaf: [
{ required: true, message: "请选择是否子节点", trigger: "blur" },
],
alarmRuleConfigId: [
{ validator: this.validateAlarmRuleConfigId, trigger: "change" },
],
},
};
},
watch: {
parentId: {
deep: true,
handler(val) {
this.resetRule();
const node = this.faultData.find((item) => item.nodeId == val);
if (node && node.partKey) {
this.form.partKey = node.partKey;
} else {
this.form.partKey = "";
}
this.form.parentId = val;
},
},
},
created() {
this.getMonitorPartList();
this.getTreeselect();
this.getList();
},
methods: {
/** 选择报警规则 */
selectAlarmRule() {
if (this.form.partKey) {
this.openRuleDialog();
} else {
this.$modal.msgError("请先选择父节点");
}
},
/** 打开规则选择弹窗 */
openRuleDialog() {
this.openRuleDia = true;
},
/** 关闭规则选择弹窗 */
closeRuleDialog() {
this.openRuleDia = false;
},
/** 规则选择弹窗数据返回 */
ruleDataReturn(data) {
this.form.alarmRuleConfigDescription = data.referenceName;
this.form.alarmRuleConfigId = data.id;
this.closeRuleDialog();
},
/** 报警规则校验 */
validateAlarmRuleConfigId(rule, value, callback) {
if (this.form.isLeaf == "1" && !value) {
return callback(new Error("请选择报警规则配置"));
} else {
return callback();
}
},
/** 叶子节点校验 */
validateIsLeaf() {
if (this.form.isLeaf == "1") {
if (this.form.nodeId) {
selectHasChild(this.form.nodeId).then((response) => {
//
if (response.data) {
this.$modal.msgError(
"该节点下存在子节点,不允许设置为叶子节点!"
);
this.isShowRuleConfig = false;
this.resetRule();
this.form.isLeaf = "0";
} else {
this.isShowRuleConfig = true;
}
});
} else {
this.isShowRuleConfig = true;
}
} else {
this.isShowRuleConfig = false;
this.resetRule();
}
},
/** 根据value获取label */
labelShow(fieldList, fieldValue) {
const field = fieldList.find((item) => item.fieldValue == fieldValue);
return field && field.fieldLabel ? field.fieldLabel : "";
},
getMonitorPartList() {
getFields("monitor_part")
.then((res) => {
this.monitorPartList = res.data;
})
.catch((error) => {
console.log(error);
});
},
/** 查询故障树配置列表 */
getList() {
this.loading = true;
listFaultTreeConfig(this.queryParams).then((response) => {
this.faultTreeConfigList = this.handleTree(
response.data,
"nodeId",
"parentId"
);
this.loading = false;
});
},
/** 转换故障树配置数据结构 */
normalizer(node) {
if (node.children && !node.children.length) {
delete node.children;
}
return {
id: node.nodeId,
label: node.nodeName,
children: node.children,
};
},
/** 查询故障树配置下拉树结构 */
getTreeselect() {
listFaultTreeConfig().then((response) => {
// this.faultTreeConfigOptions = [];
// const data = { nodeId: 0, nodeName: "", children: [] };
// data.children = this.handleTree(response.data, "nodeId", "parentId");
// this.faultTreeConfigOptions.push(data);
this.faultData = response.data;
this.faultTreeConfigOptions = this.handleTree(
response.data,
"nodeId",
"parentId"
);
});
},
//
cancel() {
this.open = false;
this.reset();
},
//
reset() {
this.parentId = null;
this.isShowRuleConfig = false;
this.form = {
nodeId: null,
parentId: null,
ancestors: null,
nodeName: null,
orderNum: null,
partKey: null,
iconCls: null,
nodeShapeType: null,
nodeDefaultColor: null,
nodeAlarmColor: null,
isAlarm: null,
status: "0",
delFlag: null,
createBy: null,
createTime: null,
updateBy: null,
updateTime: null,
isLeaf: "0",
alarmRuleConfigId: null,
alarmRuleConfigDescription: "",
};
this.resetForm("form");
},
//
resetRule() {
this.form.alarmRuleConfigId = null;
this.form.alarmRuleConfigDescription = "";
},
/** 搜索按钮操作 */
handleQuery() {
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
/** 新增按钮操作 */
handleAdd(row) {
this.reset();
this.getTreeselect();
if (row != null && row.nodeId) {
this.parentId = row.nodeId;
} else {
this.parentId = null;
}
this.open = true;
this.title = "添加故障树配置";
},
/** 展开/折叠操作 */
toggleExpandAll() {
this.refreshTable = false;
this.isExpandAll = !this.isExpandAll;
this.$nextTick(() => {
this.refreshTable = true;
});
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
this.getTreeselect();
if (row != null) {
this.parentId = row.parentId;
}
getFaultTreeConfig(row.nodeId).then((response) => {
this.form = response.data;
this.open = true;
this.title = "修改故障树配置";
});
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate((valid) => {
if (valid) {
if (this.form.nodeId != null) {
updateFaultTreeConfig(this.form).then((response) => {
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
});
} else {
addFaultTreeConfig(this.form).then((response) => {
this.$modal.msgSuccess("新增成功");
this.open = false;
this.getList();
});
}
}
});
},
/** 删除按钮操作 */
handleDelete(row) {
this.$modal
.confirm('是否确认删除故障树配置编号为"' + row.nodeId + '"的数据项?')
.then(function () {
return delFaultTreeConfig(row.nodeId);
})
.then(() => {
this.getList();
this.$modal.msgSuccess("删除成功");
})
.catch(() => {});
},
},
};
</script>
<style scoped>
.el-input-number,
.el-select {
width: 100%;
}
.color-green {
color: green;
}
.color-red {
color: red;
}
</style>

View File

@ -0,0 +1,200 @@
<template>
<div>
<el-select
v-model="part"
placeholder="请选择监测部位"
@change="getList()"
>
<el-option
v-for="field in monitorPartList"
:key="field.fieldValue"
:label="field.fieldLabel"
:value="field.fieldValue"
/>
</el-select>
<div class="component-wrapper">
<vue-okr-tree
:data="testData"
show-collapsable
default-expand-all
:node-btn-content="renderContent"
></vue-okr-tree>
</div>
</div>
</template>
<script>
import { VueOkrTree } from "@/components/VueOkrTree/index.js";
import { getFields } from "@/api/ipc/monitorFields";
import _ from "lodash";
export default {
name: "faultTreeShow",
components: {
VueOkrTree,
},
data() {
return {
//
monitorPartList: [],
part: "",
testData: [
{
label: "xxx科技有有限公司",
content: "这是一个有活力的公司",
nodeDsc: "智",
iconCls: "icon-yumen",
nodeBorderColor: "#ddd",
children: [
{
label: "产品研发部",
content: "这是一个有活力的产品研发部",
nodeDsc: "材",
iconCls: "icon-huomen",
nodeBorderColor: "#000",
children: [
{
label: "研发-前端",
content: "这是一个有活力的研发-前端",
nodeBorderColor: "black",
nodeShapeType: "rectangle",
},
{
label: "研发-后端",
content: "这是一个有活力的研发-后端",
nodeShapeType: "trigle",
nodeBorderColor: "black",
nodeBorderColor: "red",
nodeFontColor: "#00FF00",
},
{
label: "UI 设计",
content: "这是一个有活力的UI 设计",
nodeShapeType: "trigleReverse",
nodeBorderColor: "red",
nodeFontColor: "green",
},
],
},
{
label: "销售部",
content: "这是一个有活力的销售部",
nodeDsc: "慧",
iconCls: "icon-jinmen",
nodeBorderColor: "#00FF00",
children: [
{
label: "销售一部",
content: "这是一个有活力的销售一部",
nodeBorderColor: "#FF0000",
nodeShapeType: "circle",
nodeFontColor: "red",
nodeBorderColor: "red",
children: [
{
label: "销售一部",
content: "这是一个有活力的销售一部",
nodeBorderColor: "#FF0000",
nodeShapeType: "circle",
nodeFontColor: "red",
nodeBorderColor: "red",
iconCls: "icon-jinmen",
},
],
},
{
label: "销售二部",
content: "这是一个有活力的销售二部",
nodeBorderColor: "red",
nodeShapeType: "diamond",
nodeBorderColor: "red",
},
],
},
{
label: "财务部",
content: "这是一个有活力的财务部",
nodeBorderColor: "#FF0000",
},
],
},
],
};
},
created() {
this.getMonitorPartList();
},
methods: {
/** 查询监测部位列表 */
getMonitorPartList() {
getFields("monitor_part")
.then((res) => {
this.monitorPartList = res.data;
this.part = this.monitorPartList[0].fieldValue;
// this.getList();
})
.catch((error) => {
console.log(error);
});
},
renderContent(h, node) {
console.log("h", h);
console.log("node", node);
let des = node.data.nodeDsc;
let iconCls = node.data.iconCls;
if (iconCls) {
return this.$createElement(
"p",
{
class: "org-chart-node-btn-text iconfont " + iconCls,
},
""
);
} else if (des) {
return this.$createElement(
"p",
{
class: "org-chart-node-btn-text",
},
des
);
} else {
return <div class="org-chart-node-btn-text"></div>;
}
},
},
};
</script>
<style>
.org-chart-node-label .org-chart-node-btn {
border-color: transparent !important;
box-shadow: none !important;
/* margin-top: 20px !important; */
}
.org-chart-node-children {
/* padding-top: 40px !important; */
}
.org-chart-node-btn-text.iconfont.icon-connect {
font-size: 18px;
padding: 0;
background: transparent;
top: -12px;
}
/**按钮文 */
.org-chart-node-btn-text {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: #fff;
border-radius: 50%;
font-size: 12px;
display: flex;
align-items: center;
justify-content: center;
color: #909090;
z-index: 2;
}
</style>

View File

@ -0,0 +1,198 @@
<template>
<div class="app-container">
<el-dialog
:title="title"
:visible.sync="openRuleDia"
width="800px"
append-to-body
>
<el-table
v-loading="loading"
:data="configList"
@row-dblclick="checkSelect"
>
<el-table-column
label="规则描述"
align="center"
prop="referenceName"
show-overflow-tooltip
/>
<el-table-column
label="监测部位"
align="center"
prop="part"
show-overflow-tooltip
>
<template slot-scope="scope">
{{ labelShow(monitorPartList,scope.row.partKey) }}
</template>
</el-table-column>
<el-table-column
label="参数名称"
align="center"
prop="name"
show-overflow-tooltip
>
<template slot-scope="scope">
{{ labelShow(monitorParamsList,scope.row.nameKey) }}
</template>
</el-table-column>
<el-table-column
label="报警描述"
align="center"
prop="alarmDetail"
show-overflow-tooltip
/>
<el-table-column
label="报警等级"
align="center"
prop="alarmLevel"
show-overflow-tooltip
>
<template slot-scope="scope">
<dict-tag
:options="dict.type.alarm_level"
:value="scope.row.alarmLevel"
/>
</template>
</el-table-column>
</el-table>
<span class="color-red">双击选中规则</span>
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
<div
slot="footer"
class="dialog-footer"
>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { listConfig } from "@/api/ipc/rulesConfig";
import { getFields } from "@/api/ipc/monitorFields";
export default {
name: "RuleConfigDialog",
dicts: ["alarm_level", "judge_rules"],
props: {
partKey: {
type: String,
default: null,
},
openRuleDia: {
type: Boolean,
default: false,
},
},
data() {
return {
//
monitorPartList: [],
monitorParamsList: [],
//
loading: true,
//
showSearch: true,
//
total: 0,
//
configList: [],
//
title: "报警规则选择",
//
queryParams: {
pageNum: 1,
pageSize: 10,
partKey: null,
},
};
},
watch: {
partKey: {
deep: true,
handler(val) {
this.getList();
},
},
},
created() {
this.getMonitorPartList();
this.getPlcMonitorParamsList();
this.getSensorMonitorParamsList();
this.getList();
},
methods: {
/** 确认选中 */
checkSelect(row, column, event) {
this.$emit("ruleDataReturn", row);
},
//
cancel() {
this.$emit("closeRuleDialog");
},
/** 根据value获取label */
labelShow(fieldList, fieldValue) {
const field = fieldList.find((item) => item.fieldValue == fieldValue);
return field && field.fieldLabel ? field.fieldLabel : "";
},
getMonitorPartList() {
getFields("monitor_part")
.then((res) => {
this.monitorPartList = res.data;
})
.catch((error) => {
console.log(error);
});
},
getPlcMonitorParamsList() {
getFields("plc_monitor_params")
.then((res) => {
this.monitorParamsList = this.monitorParamsList.concat(res.data);
})
.catch((error) => {
console.log(error);
});
},
getSensorMonitorParamsList() {
getFields("sensor_monitor_params")
.then((res) => {
this.monitorParamsList = this.monitorParamsList.concat(res.data);
})
.catch((error) => {
console.log(error);
});
},
/** 查询告警规则配置列表 */
getList() {
this.loading = true;
this.queryParams.partKey = this.partKey;
listConfig(this.queryParams).then((response) => {
this.configList = response.rows;
this.total = response.total;
this.loading = false;
});
},
},
};
</script>
<style scoped>
.el-input-number,
.el-select {
width: 100%;
}
.color-green {
color: green;
}
</style>
<style scoped>
.color-red {
color: red;
}
</style>

View File

@ -72,63 +72,9 @@
>重置</el-button>
</el-form-item>
</el-form>
<!-- <el-row
:gutter="10"
class="mb8"
>
<el-col :span="1.5">
<el-button
type="primary"
plain
icon="el-icon-plus"
size="mini"
@click="handleAdd"
v-hasPermi="['ipc:config:add']"
>新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="success"
plain
icon="el-icon-edit"
size="mini"
:disabled="single"
@click="handleUpdate"
v-hasPermi="['ipc:config:edit']"
>修改</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="danger"
plain
icon="el-icon-delete"
size="mini"
:disabled="multiple"
@click="handleDelete"
v-hasPermi="['ipc:config:remove']"
>删除</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="warning"
plain
icon="el-icon-download"
size="mini"
@click="handleExport"
v-hasPermi="['ipc:config:export']"
>导出</el-button>
</el-col>
<right-toolbar
:showSearch.sync="showSearch"
@queryTable="getList"
></right-toolbar>
</el-row> -->
<el-table
v-loading="loading"
:data="configList"
@selection-change="handleSelectionChange"
>
<el-table-column
label="监测部位"
@ -455,12 +401,6 @@ export default {
monitorParamsList: [],
//
loading: true,
//
ids: [],
//
single: true,
//
multiple: true,
//
showSearch: true,
//
@ -622,12 +562,6 @@ export default {
this.resetForm("queryForm");
this.handleQuery();
},
//
handleSelectionChange(selection) {
this.ids = selection.map((item) => item.id);
this.single = selection.length !== 1;
this.multiple = !selection.length;
},
/** 新增按钮操作 */
handleAdd() {
this.reset();
@ -637,7 +571,7 @@ export default {
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
const id = row.id || this.ids;
const id = row.id;
getConfig(id).then((response) => {
this.form = response.data;
this.open = true;
@ -673,6 +607,6 @@ export default {
width: 100%;
}
.color-green {
color: greenyellow;
color: green;
}
</style>