diff --git a/zfipc-server/zfipc-admin/src/main/java/com/inspur/web/controller/equip/IpcEquipInfoController.java b/zfipc-server/zfipc-admin/src/main/java/com/inspur/web/controller/equip/IpcEquipInfoController.java index 994cbd3..f2e4b29 100644 --- a/zfipc-server/zfipc-admin/src/main/java/com/inspur/web/controller/equip/IpcEquipInfoController.java +++ b/zfipc-server/zfipc-admin/src/main/java/com/inspur/web/controller/equip/IpcEquipInfoController.java @@ -46,6 +46,13 @@ public class IpcEquipInfoController extends BaseController return getDataTable(list); } + @GetMapping("/listAll") + public AjaxResult listAll(IpcEquipInfo ipcEquipInfo) + { + List list = ipcEquipInfoService.selectIpcEquipInfoList(ipcEquipInfo); + return AjaxResult.success(list); + } + /** * 导出设备信息列表 */ diff --git a/zfipc-server/zfipc-admin/src/main/java/com/inspur/web/controller/industrial/IpcAlarmRecordController.java b/zfipc-server/zfipc-admin/src/main/java/com/inspur/web/controller/industrial/IpcAlarmRecordController.java new file mode 100644 index 0000000..8e5117c --- /dev/null +++ b/zfipc-server/zfipc-admin/src/main/java/com/inspur/web/controller/industrial/IpcAlarmRecordController.java @@ -0,0 +1,114 @@ +package com.inspur.web.controller.industrial; + +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.industrial.domain.IpcAlarmRecord; +import com.inspur.industrial.service.IIpcAlarmRecordService; +import com.inspur.common.utils.poi.ExcelUtil; +import com.inspur.common.core.page.TableDataInfo; + +/** + * 报警记录Controller + * + * @Author zhangjunwen + * @create 2024/4/10 + */ +@RestController +@RequestMapping("/alarm/record") +public class IpcAlarmRecordController extends BaseController +{ + @Autowired + private IIpcAlarmRecordService ipcAlarmRecordService; + + /** + * 查询报警记录列表 + */ + @PreAuthorize("@ss.hasPermi('system:record:list')") + @GetMapping("/list") + public TableDataInfo list(IpcAlarmRecord ipcAlarmRecord) + { + startPage(); + List list = ipcAlarmRecordService.selectIpcAlarmRecordList(ipcAlarmRecord); + return getDataTable(list); + } + + /** + * 导出报警记录列表 + */ + @PreAuthorize("@ss.hasPermi('system:record:export')") + @Log(title = "报警记录", businessType = BusinessType.EXPORT) + @PostMapping("/export") + public void export(HttpServletResponse response, IpcAlarmRecord ipcAlarmRecord) + { + List list = ipcAlarmRecordService.selectIpcAlarmRecordList(ipcAlarmRecord); + ExcelUtil util = new ExcelUtil(IpcAlarmRecord.class); + util.exportExcel(response, list, "报警记录数据"); + } + + /** + * 获取报警记录详细信息 + */ + @PreAuthorize("@ss.hasPermi('system:record:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return AjaxResult.success(ipcAlarmRecordService.selectIpcAlarmRecordById(id)); + } + + /** + * 新增报警记录 + */ + @PreAuthorize("@ss.hasPermi('system:record:add')") + @Log(title = "报警记录", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody IpcAlarmRecord ipcAlarmRecord) + { + return toAjax(ipcAlarmRecordService.insertIpcAlarmRecord(ipcAlarmRecord)); + } + + /** + * 修改报警记录 + */ + @PreAuthorize("@ss.hasPermi('system:record:edit')") + @Log(title = "报警记录", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody IpcAlarmRecord ipcAlarmRecord) + { + return toAjax(ipcAlarmRecordService.updateIpcAlarmRecord(ipcAlarmRecord)); + } + + /** + * 批量修改报警记录 + */ + @PostMapping("/batchUpdate") + public AjaxResult batchUpdate( @RequestBody IpcAlarmRecord ipcAlarmRecord) + { + return toAjax(ipcAlarmRecordService.batchUpdateIpcAlarmRecord(ipcAlarmRecord.getIds(),ipcAlarmRecord.getResult())); + } + + /** + * 删除报警记录 + */ + @PreAuthorize("@ss.hasPermi('system:record:remove')") + @Log(title = "报警记录", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable Long[] ids) + { + return toAjax(ipcAlarmRecordService.deleteIpcAlarmRecordByIds(ids)); + } +} + diff --git a/zfipc-server/zfipc-admin/src/main/java/com/inspur/web/controller/industrial/IpcAlarmRulesController.java b/zfipc-server/zfipc-admin/src/main/java/com/inspur/web/controller/industrial/IpcAlarmRulesController.java index 6f387a6..4b2732e 100644 --- a/zfipc-server/zfipc-admin/src/main/java/com/inspur/web/controller/industrial/IpcAlarmRulesController.java +++ b/zfipc-server/zfipc-admin/src/main/java/com/inspur/web/controller/industrial/IpcAlarmRulesController.java @@ -28,7 +28,7 @@ import com.inspur.common.core.page.TableDataInfo; * @create 2024/4/9 */ @RestController -@RequestMapping("/system/rules") +@RequestMapping("/alarm/rules") public class IpcAlarmRulesController extends BaseController { @Autowired @@ -46,6 +46,13 @@ public class IpcAlarmRulesController extends BaseController return getDataTable(list); } + @GetMapping("/listAll") + public AjaxResult listAll(IpcAlarmRules ipcAlarmRules) + { + List list = ipcAlarmRulesService.selectIpcAlarmRulesList(ipcAlarmRules); + return AjaxResult.success(list); + } + /** * 导出设备报警规则列表 */ diff --git a/zfipc-server/zfipc-datasyn/src/main/java/com/inspur/datasyn/modbus/IPCDataSyncThread.java b/zfipc-server/zfipc-datasyn/src/main/java/com/inspur/datasyn/modbus/IPCDataSyncThread.java index 5823751..fa362cc 100644 --- a/zfipc-server/zfipc-datasyn/src/main/java/com/inspur/datasyn/modbus/IPCDataSyncThread.java +++ b/zfipc-server/zfipc-datasyn/src/main/java/com/inspur/datasyn/modbus/IPCDataSyncThread.java @@ -1,7 +1,14 @@ package com.inspur.datasyn.modbus; import com.inspur.common.utils.spring.SpringUtils; +import com.inspur.industrial.domain.IpcAlarmRecord; +import com.inspur.industrial.domain.IpcAlarmRules; +import com.inspur.industrial.service.IIpcAlarmRecordService; +import com.inspur.industrial.service.IIpcAlarmRulesService; +import com.inspur.industrial.utils.Constant; +import com.inspur.industrial.utils.IpcUtil; import com.inspur.industrial.utils.JudgeUtil; +import com.inspur.system.service.ISysConfigService; import com.inspur.system.service.influx.InfluxDBService; import com.serotonin.modbus4j.BatchRead; import com.serotonin.modbus4j.BatchResults; @@ -15,10 +22,7 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.List; -import java.util.Map; -import java.util.TreeMap; +import java.util.*; public class IPCDataSyncThread implements Runnable { private static final Logger logger = LoggerFactory.getLogger(IPCDataSyncThread.class); @@ -26,6 +30,8 @@ public class IPCDataSyncThread implements Runnable { private ModbusMaster master; private String time; + private static final String EQUIP_ID = "e2ae4710b516419c84d1d4a819429348"; + public IPCDataSyncThread(ModbusMaster master, String time){ this.master = master; this.time = time; @@ -57,22 +63,33 @@ public class IPCDataSyncThread implements Runnable { // BatchResults results = master.send(batch); //超压底缸加压液压系统 String measurement = "zfipc_industrial_monitor_data1"; + InfluxDBService i = SpringUtils.getBean(InfluxDBService.class); + IpcUtil ipcUtil = SpringUtils.getBean(IpcUtil.class); + IIpcAlarmRulesService alarmRulesService = SpringUtils.getBean(IIpcAlarmRulesService.class); + IIpcAlarmRecordService alarmRecordService = SpringUtils.getBean(IIpcAlarmRecordService.class); + + List alarmRecordList = new ArrayList<>(); + Map tags = new TreeMap(); - tags.put("equ_id","e2ae4710b516419c84d1d4a819429348"); + tags.put("equ_id",EQUIP_ID); Map fields = new TreeMap(); // 系统电流 fields.put("sys_cur",(float) 0 + Math.random()); // 系统流量 - fields.put("sys_flw",(float) 0 + Math.random()); + fields.put("sys_flw",(float) 0 + Math.random()); // 系统压力 fields.put("sys_press",(float) 0 + Math.random()); // 系统液位 fields.put("sys_level",(float) 0 + Math.random()); -// fields.put("ywcsz",0.5); -// fields.put("ywmin",0.3); -// fields.put("ywmax",1); + + //液位最小和最大值通过报警参数设置获取 + IpcAlarmRules levelRule = getLevelAlarmRule(); + //正式需要放开 + fields.put("level_min",levelRule == null ? 0.0 : levelRule.getAlertLowerBound().floatValue()); + fields.put("level_max",levelRule == null ? 0.0 : levelRule.getAlertUpperBound().floatValue()); + // 系统温度 fields.put("sys_temp",(float) 0 + Math.random()); // 油液颗粒度 @@ -91,7 +108,7 @@ public class IPCDataSyncThread implements Runnable { // 传动侧软辊流量 fields.put("driven_soft_flw",(float) 0 + Math.random()); // 传动侧热辊流量 - fields.put("[driven_hot_flw]",(float) 0 + Math.random()); + fields.put("driven_hot_flw",(float) 0 + Math.random()); //操作侧底缸比例换向阀 fields.put("opr_servo",(float) 0 + Math.random()); //传动侧比例换向阀 @@ -100,6 +117,10 @@ public class IPCDataSyncThread implements Runnable { fields.put("opr_bottom_press",(float) 0 + Math.random()); //传动侧底缸压力 fields.put("driven_bottom_press",(float) 0 + Math.random()); + //操作侧底缸设定压力 + fields.put("opr_bottom_set_press",(float) 0 + Math.random()); + //传动侧底缸设定压力 + fields.put("driven_bottom_set_press",(float) 0 + Math.random()); //操作侧软辊压力 fields.put("opr_soft_real_press",(float) 0 + Math.random());//实际压力 fields.put("opr_soft_bond_press",(float) 0 + Math.random());//合辊压力 @@ -161,13 +182,31 @@ public class IPCDataSyncThread implements Runnable { SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS"); String format = simpleDateFormat.format(new Date()); - fields.put("insertTime",format); - InfluxDBService i = SpringUtils.getBean(InfluxDBService.class); - // 判断并处理报警数据 -// JudgeUtil.judgeAndSaveAlarmData(fields,"1"); + tags.put("insertTime",format); + + //报警处理 + List rulesList = alarmRulesService.selectIpcAlarmRulesByEquipId(EQUIP_ID); + alarmRecordList.addAll(ipcUtil.dealRealTimeData(fields,tags, Constant.RUNNING,rulesList)); i.insert(measurement,tags,fields); + + if (!alarmRecordList.isEmpty()){//运行需放开 + //alarmRecordService.batchInsertIpcAlarmRecord(alarmRecordList); + } } catch (Exception e) { e.printStackTrace(); } } + + /** + * 获取液位的报警规则 + * @return + */ + private IpcAlarmRules getLevelAlarmRule(){ + IIpcAlarmRulesService ipcAlarmRulesService = SpringUtils.getBean(IIpcAlarmRulesService.class); + IpcAlarmRules query = new IpcAlarmRules(); + query.setEquipId(EQUIP_ID); + query.setAlarmNameKey("sys_level"); + query.setType(Constant.RUNNING);//运行中 + return ipcAlarmRulesService.selectIpcAlarmRulesList(query).get(0) == null ? null : ipcAlarmRulesService.selectIpcAlarmRulesList(query).get(0); + } } diff --git a/zfipc-server/zfipc-system/src/main/java/com/inspur/industrial/domain/IpcAlarmRecord.java b/zfipc-server/zfipc-system/src/main/java/com/inspur/industrial/domain/IpcAlarmRecord.java new file mode 100644 index 0000000..5f9915c --- /dev/null +++ b/zfipc-server/zfipc-system/src/main/java/com/inspur/industrial/domain/IpcAlarmRecord.java @@ -0,0 +1,214 @@ +package com.inspur.industrial.domain; + +import java.math.BigDecimal; +import java.util.Date; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.inspur.common.annotation.Excel; +import com.inspur.common.core.domain.BaseEntity; +import com.inspur.equip.domain.IpcEquipInfo; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; + +/** + * 报警记录对象 ipc_alarm_record + * + * @author inspur + * @date 2024-04-10 + */ +public class IpcAlarmRecord extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 设备报警记录id */ + private Long id; + + /** 报警信息id */ + @Excel(name = "报警信息id") + private String alarmRulesId; + + /** 设备id */ + @Excel(name = "设备id") + private String equipId; + + /** 传感器id */ + @Excel(name = "传感器id") + private String sensorId; + + /** 报警内容 */ + @Excel(name = "报警内容") + private String content; + + /** 报警值 */ + @Excel(name = "报警值") + private BigDecimal alarmValue; + + /** 报警时间 */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @Excel(name = "报警时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss") + private Date alarmTime; + + /** 处理结果 */ + @Excel(name = "处理结果") + private String result; + + /** 报警记录的状态(0:未处理,1:已处理) */ + @Excel(name = "报警记录的状态", readConverterExp = "0=:未处理,1:已处理") + private Integer status; + + /** 处理人 */ + @Excel(name = "处理人") + private Long operator; + + /** + * 报警等级 + */ + private Integer alarmLevel; + + private IpcEquipInfo equipInfo; + + private String[] ids; + + + private IpcAlarmRules alarmRules; + + public void setId(Long id) + { + this.id = id; + } + + public Long getId() + { + return id; + } + public void setAlarmRulesId(String alarmRulesId) + { + this.alarmRulesId = alarmRulesId; + } + + public String getAlarmRulesId() + { + return alarmRulesId; + } + public void setEquipId(String equipId) + { + this.equipId = equipId; + } + + public String getEquipId() + { + return equipId; + } + public void setSensorId(String sensorId) + { + this.sensorId = sensorId; + } + + public String getSensorId() + { + return sensorId; + } + public void setContent(String content) + { + this.content = content; + } + + public String getContent() + { + return content; + } + public void setAlarmValue(BigDecimal alarmValue) + { + this.alarmValue = alarmValue; + } + + public BigDecimal getAlarmValue() + { + return alarmValue; + } + public void setAlarmTime(Date alarmTime) + { + this.alarmTime = alarmTime; + } + + public Date getAlarmTime() + { + return alarmTime; + } + public void setResult(String result) + { + this.result = result; + } + + public String getResult() + { + return result; + } + public void setStatus(Integer status) + { + this.status = status; + } + + public Integer getStatus() + { + return status; + } + public void setOperator(Long operator) + { + this.operator = operator; + } + + public Long getOperator() + { + return operator; + } + + public Integer getAlarmLevel() { + return alarmLevel; + } + + public void setAlarmLevel(Integer alarmLevel) { + this.alarmLevel = alarmLevel; + } + + public IpcEquipInfo getEquipInfo() { + return equipInfo; + } + + public void setEquipInfo(IpcEquipInfo equipInfo) { + this.equipInfo = equipInfo; + } + + public IpcAlarmRules getAlarmRules() { + return alarmRules; + } + + public void setAlarmRules(IpcAlarmRules alarmRules) { + this.alarmRules = alarmRules; + } + + public String[] getIds() { + return ids; + } + + public void setIds(String[] ids) { + this.ids = ids; + } + + @Override + public String toString() { + return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) + .append("id", getId()) + .append("alarmRulesId", getAlarmRulesId()) + .append("equipId", getEquipId()) + .append("sensorId", getSensorId()) + .append("content", getContent()) + .append("alarmValue", getAlarmValue()) + .append("alarmTime", getAlarmTime()) + .append("result", getResult()) + .append("status", getStatus()) + .append("operator", getOperator()) + .append("alarmLevel", getAlarmLevel()) + .toString(); + } +} + diff --git a/zfipc-server/zfipc-system/src/main/java/com/inspur/industrial/mapper/IpcAlarmRecordMapper.java b/zfipc-server/zfipc-system/src/main/java/com/inspur/industrial/mapper/IpcAlarmRecordMapper.java new file mode 100644 index 0000000..45a351b --- /dev/null +++ b/zfipc-server/zfipc-system/src/main/java/com/inspur/industrial/mapper/IpcAlarmRecordMapper.java @@ -0,0 +1,79 @@ +package com.inspur.industrial.mapper; + +import java.util.List; +import com.inspur.industrial.domain.IpcAlarmRecord; +import org.apache.ibatis.annotations.Param; + +/** + * 报警记录Mapper接口 + * + * @Author zhangjunwen + * @create 2024/4/10 + */ +public interface IpcAlarmRecordMapper +{ + /** + * 查询报警记录 + * + * @param id 报警记录主键 + * @return 报警记录 + */ + public IpcAlarmRecord selectIpcAlarmRecordById(Long id); + + /** + * 查询报警记录列表 + * + * @param ipcAlarmRecord 报警记录 + * @return 报警记录集合 + */ + public List selectIpcAlarmRecordList(IpcAlarmRecord ipcAlarmRecord); + + /** + * 新增报警记录 + * + * @param ipcAlarmRecord 报警记录 + * @return 结果 + */ + public int insertIpcAlarmRecord(IpcAlarmRecord ipcAlarmRecord); + + /** + * 批量新增报警记录 + * + * @param ipcAlarmRecordList 报警记录 + * @return 结果 + */ + public int batchInsertIpcAlarmRecord(@Param("list") List ipcAlarmRecordList); + + /** + * 修改报警记录 + * + * @param ipcAlarmRecord 报警记录 + * @return 结果 + */ + public int updateIpcAlarmRecord(IpcAlarmRecord ipcAlarmRecord); + + /** + * 批量修改报警记录 + * + * @param ids 报警记录主键 + * @return 结果 + */ + public int batchUpdateIpcAlarmRecord(@Param("ids") String[] ids,@Param("alarmResult") String alarmResult,@Param("operator") String operotor); + + /** + * 删除报警记录 + * + * @param id 报警记录主键 + * @return 结果 + */ + public int deleteIpcAlarmRecordById(Long id); + + /** + * 批量删除报警记录 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteIpcAlarmRecordByIds(Long[] ids); +} + diff --git a/zfipc-server/zfipc-system/src/main/java/com/inspur/industrial/mapper/IpcAlarmRulesMapper.java b/zfipc-server/zfipc-system/src/main/java/com/inspur/industrial/mapper/IpcAlarmRulesMapper.java index 14f662d..17b4fbe 100644 --- a/zfipc-server/zfipc-system/src/main/java/com/inspur/industrial/mapper/IpcAlarmRulesMapper.java +++ b/zfipc-server/zfipc-system/src/main/java/com/inspur/industrial/mapper/IpcAlarmRulesMapper.java @@ -27,6 +27,11 @@ public interface IpcAlarmRulesMapper */ public List selectIpcAlarmRulesList(IpcAlarmRules ipcAlarmRules); + /** + * 根据设备id获取设备报警规则 + */ + public List selectIpcAlarmRulesByEquipId(String equipId); + /** * 新增设备报警规则 * diff --git a/zfipc-server/zfipc-system/src/main/java/com/inspur/industrial/service/IIpcAlarmRecordService.java b/zfipc-server/zfipc-system/src/main/java/com/inspur/industrial/service/IIpcAlarmRecordService.java new file mode 100644 index 0000000..354f633 --- /dev/null +++ b/zfipc-server/zfipc-system/src/main/java/com/inspur/industrial/service/IIpcAlarmRecordService.java @@ -0,0 +1,78 @@ +package com.inspur.industrial.service; + +import java.util.List; +import com.inspur.industrial.domain.IpcAlarmRecord; + +/** + * 报警记录Service接口 + * + * @Author zhangjunwen + * @create 2024/4/10 + */ +public interface IIpcAlarmRecordService +{ + /** + * 查询报警记录 + * + * @param id 报警记录主键 + * @return 报警记录 + */ + public IpcAlarmRecord selectIpcAlarmRecordById(Long id); + + /** + * 查询报警记录列表 + * + * @param ipcAlarmRecord 报警记录 + * @return 报警记录集合 + */ + public List selectIpcAlarmRecordList(IpcAlarmRecord ipcAlarmRecord); + + /** + * 新增报警记录 + * + * @param ipcAlarmRecord 报警记录 + * @return 结果 + */ + public int insertIpcAlarmRecord(IpcAlarmRecord ipcAlarmRecord); + + /** + * 批量新增报警记录 + * + * @param ipcAlarmRecordList 报警记录 + * @return 结果 + */ + public int batchInsertIpcAlarmRecord(List ipcAlarmRecordList); + + /** + * 修改报警记录 + * + * @param ipcAlarmRecord 报警记录 + * @return 结果 + */ + public int updateIpcAlarmRecord(IpcAlarmRecord ipcAlarmRecord); + + /** + * 批量修改报警记录 + * + * @param ids 报警记录主键 + * @return 结果 + */ + public int batchUpdateIpcAlarmRecord(String[] ids,String alarmResult); + + /** + * 批量删除报警记录 + * + * @param ids 需要删除的报警记录主键集合 + * @return 结果 + */ + public int deleteIpcAlarmRecordByIds(Long[] ids); + + /** + * 删除报警记录信息 + * + * @param id 报警记录主键 + * @return 结果 + */ + public int deleteIpcAlarmRecordById(Long id); +} + diff --git a/zfipc-server/zfipc-system/src/main/java/com/inspur/industrial/service/IIpcAlarmRulesService.java b/zfipc-server/zfipc-system/src/main/java/com/inspur/industrial/service/IIpcAlarmRulesService.java index bdee9f0..b279a34 100644 --- a/zfipc-server/zfipc-system/src/main/java/com/inspur/industrial/service/IIpcAlarmRulesService.java +++ b/zfipc-server/zfipc-system/src/main/java/com/inspur/industrial/service/IIpcAlarmRulesService.java @@ -27,6 +27,10 @@ public interface IIpcAlarmRulesService */ public List selectIpcAlarmRulesList(IpcAlarmRules ipcAlarmRules); + /** + * 根据设备id获取设备报警规则 + */ + public List selectIpcAlarmRulesByEquipId(String equipId); // public void tran(); /** diff --git a/zfipc-server/zfipc-system/src/main/java/com/inspur/industrial/service/impl/DataQueryService.java b/zfipc-server/zfipc-system/src/main/java/com/inspur/industrial/service/impl/DataQueryService.java index 780442b..4c4059a 100644 --- a/zfipc-server/zfipc-system/src/main/java/com/inspur/industrial/service/impl/DataQueryService.java +++ b/zfipc-server/zfipc-system/src/main/java/com/inspur/industrial/service/impl/DataQueryService.java @@ -46,8 +46,9 @@ public class DataQueryService implements IDataQueryService { resMap.put("sysflw", list.get(0).get("sys_flw"));//系统流量 resMap.put("sysprs", list.get(0).get("sys_press"));//系统压力 resMap.put("syslevel", list.get(0).get("sys_level"));//系统液位 - resMap.put("syslevelinit", Integer.parseInt(sysConfigService.selectConfigByKey("sys.liquidlevel.init")));//液位初始值 - //TODO 获取系统液位高值和低值 + resMap.put("syslevelinit", Float.parseFloat(sysConfigService.selectConfigByKey("sys.liquidlevel.init")));//液位初始值 + resMap.put("levelmax", list.get(0).get("level_max")); + resMap.put("levelmin", list.get(0).get("level_min")); resMap.put("systemp",list.get(0).get("sys_temp"));//系统温度 resMap.put("syshumid",list.get(0).get("oil_water"));//系统湿度 @@ -73,12 +74,19 @@ public class DataQueryService implements IDataQueryService { double power = (double) resMap.get("syspower"); double sysflw = (double)resMap.get("sysflw"); double pressure = (double)resMap.get("sysprs"); - resMap.put("syseff",pressure * sysflw/power); + resMap.put("syseff",pressure * sysflw/power*100); List syscur = new ArrayList<>();//系统电流 + List oprsoftflw = new ArrayList<>();//操作侧软辊流量 + List oprhotflw = new ArrayList<>();//操作侧热辊流量 + List drivensoftflw = new ArrayList<>();//传动侧软辊流量 + List drivenhotflw = new ArrayList<>();//传动侧热辊流量 + List oprbottompress = new ArrayList<>();//底缸操作侧压力 List drivenbottompress = new ArrayList<>();//底缸传动侧压力 + List oprbottomsetpress = new ArrayList<>();//底缸操作侧设定压力 + List drivenbottomsetpress = new ArrayList<>();//底缸传动侧设定压力 List oprsoftrealpress = new ArrayList<>();//操作侧软辊压力 List oprsoftbondpress = new ArrayList<>();//操作侧软辊合辊压力 @@ -104,8 +112,15 @@ public class DataQueryService implements IDataQueryService { syscur.add(data.get("sys_cur")); + oprsoftflw.add(data.get("opr_soft_flw") == null ? 0 : data.get("opr_soft_flw")); + oprhotflw.add(data.get("opr_hot_flw") == null ? 0 : data.get("opr_hot_flw")); + drivensoftflw.add(data.get("driven_soft_flw") == null ? 0 : data.get("driven_soft_flw")); + drivenhotflw.add(data.get("driven_hot_flw") == null ? 0 : data.get("driven_hot_flw")); + oprbottompress.add(data.get("opr_bottom_press") == null ? 0 : data.get("opr_bottom_press")); drivenbottompress.add(data.get("driven_bottom_press") == null ? 0 : data.get("driven_bottom_press")); + oprbottomsetpress.add(data.get("opr_bottom_set_press") == null ? 0 : data.get("opr_bottom_set_press")); + drivenbottomsetpress.add(data.get("driven_bottom_set_press") == null ? 0 : data.get("driven_bottom_set_press")); oprsoftrealpress.add(data.get("opr_soft_real_press") == null ? 0 : data.get("opr_soft_real_press")); oprsoftbondpress.add(data.get("opr_soft_bond_press") == null ? 0 : data.get("opr_soft_bond_press")); @@ -130,8 +145,15 @@ public class DataQueryService implements IDataQueryService { resMap.put("syscur",syscur); + resMap.put("oprsoftflw",oprsoftflw); + resMap.put("oprhotflw",oprhotflw); + resMap.put("drivensoftflw",drivensoftflw); + resMap.put("drivenhotflw",drivenhotflw); + resMap.put("oprbottompress",oprbottompress); resMap.put("drivenbottompress",drivenbottompress); + resMap.put("oprbottomsetpress",oprbottomsetpress); + resMap.put("drivenbottomsetpress",drivenbottomsetpress); resMap.put("oprsoftrealpress",oprsoftrealpress); resMap.put("oprsoftbondpress",oprsoftbondpress); diff --git a/zfipc-server/zfipc-system/src/main/java/com/inspur/industrial/service/impl/IpcAlarmRecordServiceImpl.java b/zfipc-server/zfipc-system/src/main/java/com/inspur/industrial/service/impl/IpcAlarmRecordServiceImpl.java new file mode 100644 index 0000000..9b1bf8a --- /dev/null +++ b/zfipc-server/zfipc-system/src/main/java/com/inspur/industrial/service/impl/IpcAlarmRecordServiceImpl.java @@ -0,0 +1,128 @@ +package com.inspur.industrial.service.impl; + +import java.util.List; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutionException; + +import com.inspur.common.utils.SecurityUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.inspur.industrial.mapper.IpcAlarmRecordMapper; +import com.inspur.industrial.domain.IpcAlarmRecord; +import com.inspur.industrial.service.IIpcAlarmRecordService; + +/** + * 报警记录Service业务层处理 + * + * @Author zhangjunwen + * @create 2024/4/10 + */ +@Service +public class IpcAlarmRecordServiceImpl implements IIpcAlarmRecordService +{ + @Autowired + private IpcAlarmRecordMapper ipcAlarmRecordMapper; + + /** + * 查询报警记录 + * + * @param id 报警记录主键 + * @return 报警记录 + */ + @Override + public IpcAlarmRecord selectIpcAlarmRecordById(Long id) + { + return ipcAlarmRecordMapper.selectIpcAlarmRecordById(id); + } + + /** + * 查询报警记录列表 + * + * @param ipcAlarmRecord 报警记录 + * @return 报警记录 + */ + @Override + public List selectIpcAlarmRecordList(IpcAlarmRecord ipcAlarmRecord) + { + return ipcAlarmRecordMapper.selectIpcAlarmRecordList(ipcAlarmRecord); + } + + /** + * 新增报警记录 + * + * @param ipcAlarmRecord 报警记录 + * @return 结果 + */ + @Override + public int insertIpcAlarmRecord(IpcAlarmRecord ipcAlarmRecord) + { + return ipcAlarmRecordMapper.insertIpcAlarmRecord(ipcAlarmRecord); + } + + /** + * 批量新增报警记录 + * + * @param ipcAlarmRecordList 报警记录 + * @return 结果 + */ + @Override + public int batchInsertIpcAlarmRecord(List ipcAlarmRecordList){ + int num = 0; + CompletableFuture resultData = CompletableFuture.supplyAsync(() -> ipcAlarmRecordMapper.batchInsertIpcAlarmRecord(ipcAlarmRecordList)); + try { + num = resultData.get(); + } catch (InterruptedException e) { + e.printStackTrace(); + } catch (ExecutionException e) { + e.printStackTrace(); + } + return num; + } + + /** + * 修改报警记录 + * + * @param ipcAlarmRecord 报警记录 + * @return 结果 + */ + @Override + public int updateIpcAlarmRecord(IpcAlarmRecord ipcAlarmRecord) + { + return ipcAlarmRecordMapper.updateIpcAlarmRecord(ipcAlarmRecord); + } + + /** + * 批量修改报警记录 + * + * @param ids 报警记录主键 + * @return 结果 + */ + public int batchUpdateIpcAlarmRecord(String[] ids,String alarmResult){ + return ipcAlarmRecordMapper.batchUpdateIpcAlarmRecord(ids, alarmResult, SecurityUtils.getUserId().toString()); + } + + /** + * 批量删除报警记录 + * + * @param ids 需要删除的报警记录主键 + * @return 结果 + */ + @Override + public int deleteIpcAlarmRecordByIds(Long[] ids) + { + return ipcAlarmRecordMapper.deleteIpcAlarmRecordByIds(ids); + } + + /** + * 删除报警记录信息 + * + * @param id 报警记录主键 + * @return 结果 + */ + @Override + public int deleteIpcAlarmRecordById(Long id) + { + return ipcAlarmRecordMapper.deleteIpcAlarmRecordById(id); + } +} + diff --git a/zfipc-server/zfipc-system/src/main/java/com/inspur/industrial/service/impl/IpcAlarmRulesServiceImpl.java b/zfipc-server/zfipc-system/src/main/java/com/inspur/industrial/service/impl/IpcAlarmRulesServiceImpl.java index b454ce0..005e2c1 100644 --- a/zfipc-server/zfipc-system/src/main/java/com/inspur/industrial/service/impl/IpcAlarmRulesServiceImpl.java +++ b/zfipc-server/zfipc-system/src/main/java/com/inspur/industrial/service/impl/IpcAlarmRulesServiceImpl.java @@ -54,6 +54,14 @@ public class IpcAlarmRulesServiceImpl implements IIpcAlarmRulesService return ipcAlarmRulesMapper.selectIpcAlarmRulesList(ipcAlarmRules); } + /** + * 根据设备id获取设备报警规则 + */ + @Override + public List selectIpcAlarmRulesByEquipId(String equipId){ + return ipcAlarmRulesMapper.selectIpcAlarmRulesByEquipId(equipId); + } + // public void tran(){ // List list = ipcMonitorDataInfoService.selectIpcMonitorDataInfoList(null); // AtomicInteger num = new AtomicInteger(1); diff --git a/zfipc-server/zfipc-system/src/main/java/com/inspur/industrial/utils/Constant.java b/zfipc-server/zfipc-system/src/main/java/com/inspur/industrial/utils/Constant.java index 6bcd2e3..e69ed2b 100644 --- a/zfipc-server/zfipc-system/src/main/java/com/inspur/industrial/utils/Constant.java +++ b/zfipc-server/zfipc-system/src/main/java/com/inspur/industrial/utils/Constant.java @@ -36,4 +36,14 @@ public class Constant { * 区间外 */ public static final String OUTSIDE_INTERVAL = "区间外"; + + /** + * 运行中 + */ + public static final Integer RUNNING = 0; + + /** + * 试运行 + */ + public static final Integer TRY_RUNNING = 1; } diff --git a/zfipc-server/zfipc-system/src/main/java/com/inspur/industrial/utils/IpcUtil.java b/zfipc-server/zfipc-system/src/main/java/com/inspur/industrial/utils/IpcUtil.java new file mode 100644 index 0000000..f1bd5e0 --- /dev/null +++ b/zfipc-server/zfipc-system/src/main/java/com/inspur/industrial/utils/IpcUtil.java @@ -0,0 +1,97 @@ +package com.inspur.industrial.utils; + +import com.inspur.common.utils.DateUtils; +import com.inspur.common.utils.SecurityUtils; +import com.inspur.common.utils.uuid.IdUtils; +import com.inspur.industrial.domain.IpcAlarmRecord; +import com.inspur.industrial.domain.IpcAlarmRules; +import org.springframework.stereotype.Component; + +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +@Component +public class IpcUtil { + + + /** + * 根据报警规则判断是否正常 + * + * @param realValueObj 实际值 + * @param referenceValue1 上限值 + * @param referenceValue2 下限值 + * @param referenceCon 比较标准 + * @return 是否报警 + */ + public static Boolean judgeAlarm(Object realValueObj, BigDecimal referenceValue1, BigDecimal referenceValue2, String referenceCon) { + // 是否报警 + Boolean flag = false; + BigDecimal realValue; + // 无法转为数字即异常数据 + if (realValueObj instanceof String || realValueObj instanceof Number) { + try { + realValue = new BigDecimal(String.valueOf(realValueObj)); + } catch (Exception e) { + flag = true; + return flag; + } + } else { + flag = true; + return flag; + } + if (Constant.GREATER.equals(referenceCon)) { + flag = realValue.compareTo(referenceValue1) > 0; + } else if (Constant.GREATER_EQUAL.equals(referenceCon)) { + flag = realValue.compareTo(referenceValue1) >= 0; + } else if (Constant.LESS.equals(referenceCon)) { + flag = realValue.compareTo(referenceValue1) < 0; + } else if (Constant.LESS_EQUAL.equals(referenceCon)) { + flag = realValue.compareTo(referenceValue1) <= 0; + } else if (Constant.EQUAL.equals(referenceCon)) { + flag = realValue.compareTo(referenceValue1) == 0; + } else if (Constant.WIDTHIN_INTERVAL.equals(referenceCon)) { + flag = realValue.compareTo(referenceValue1) >= 0 && realValue.compareTo(referenceValue2) <= 0; + } else if (Constant.OUTSIDE_INTERVAL.equals(referenceCon)) { + flag = realValue.compareTo(referenceValue1) <= 0 || realValue.compareTo(referenceValue2) >= 0; + } else { + flag = true; + } + return flag; + } + + /** + * 批量处理实时数据 + */ + public List dealRealTimeData(Map map, Map tags,int type, List rulesList) { + + List returnList = new ArrayList<>(); + for (IpcAlarmRules rule : rulesList) { + // 判断是否当前参数类型 0:运行中 1:待机 + if (type == rule.getType()) { + if (judgeAlarm(map.get(rule.getAlarmNameKey()), rule.getAlertLowerBound(), rule.getAlertUpperBound(), rule.getReferenceCon())) { + // 报警数据 + tags.put("isAlarm", "1"); + IpcAlarmRecord ipcAlarmRecord = new IpcAlarmRecord(); + ipcAlarmRecord.setAlarmRulesId(rule.getId()); + ipcAlarmRecord.setAlarmTime(DateUtils.getNowDate()); + ipcAlarmRecord.setEquipId(rule.getEquipId()); + ipcAlarmRecord.setSensorId(rule.getSensorId()); + String name = rule.getAlarmNameKey(); + double value = (double) map.get(name); + ipcAlarmRecord.setAlarmValue(BigDecimal.valueOf(value)); + ipcAlarmRecord.setContent(rule.getReferenceName()); + ipcAlarmRecord.setStatus(0); + ipcAlarmRecord.setOperator(1L); + ipcAlarmRecord.setAlarmLevel(rule.getAlarmLevel()); + returnList.add(ipcAlarmRecord); + } else { + // 正常数据 + tags.put("isAlarm", "0"); + } + } + } + return returnList; + } +} diff --git a/zfipc-server/zfipc-system/src/main/resources/mapper/industrial/IpcAlarmRecordMapper.xml b/zfipc-server/zfipc-system/src/main/resources/mapper/industrial/IpcAlarmRecordMapper.xml new file mode 100644 index 0000000..1e6072e --- /dev/null +++ b/zfipc-server/zfipc-system/src/main/resources/mapper/industrial/IpcAlarmRecordMapper.xml @@ -0,0 +1,169 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + select a.id, a.alarm_rules_id, a.equip_id, a.sensor_id, a.content, a.alarm_value, a.alarm_time, a.result, a.status, a.operator, a.alarm_level, + b.equip_name,b.equip_num, + c.alarm_name,c.alarm_info_unit + from ipc_alarm_record a + left join ipc_equip_info b on a.equip_id = b.id + left join ipc_alarm_rules c on a.alarm_rules_id = c.id + + + + + + + + insert into ipc_alarm_record + + alarm_rules_id, + equip_id, + sensor_id, + content, + alarm_value, + alarm_time, + result, + status, + opeartor, + alarm_level, + + + #{alarmRulesId}, + #{equipId}, + #{sensorId}, + #{content}, + #{alarmValue}, + #{alarmTime}, + #{result}, + #{status}, + #{operator}, + #{alarmLevel}, + + + + + + insert into ipc_alarm_record + (alarm_rules_id,equip_id,sensor_id,content,alarm_value,alarm_time,status,operator,alarm_level) + values + + (#{item.alarmRulesId}, + #{item.equipId}, + #{item.sensorId}, + #{item.content}, + #{item.alarmValue}, + #{item.alarmTime}, + #{item.status}, + #{item.operator} + #{item.alarmLevel}) + + ; + + + + update ipc_alarm_record + + alarm_rules_id = #{alarmRulesId}, + equip_id = #{equipId}, + sensor_id = #{sensorId}, + content = #{content}, + alarm_value = #{alarmValue}, + alarm_time = #{alarmTime}, + result = #{result}, + status = #{status}, + operator = #{operator}, + alarm_level = #{alarmLevel}, + + where id = #{id} + + + + update ipc_alarm_record + + status = 1, + result = #{alarmResult}, + operator = #{operator}, + + where id in + + #{id} + + + + + delete from ipc_alarm_record where id = #{id} + + + + delete from ipc_alarm_record where id in + + #{id} + + + \ No newline at end of file diff --git a/zfipc-server/zfipc-system/src/main/resources/mapper/industrial/IpcAlarmRulesMapper.xml b/zfipc-server/zfipc-system/src/main/resources/mapper/industrial/IpcAlarmRulesMapper.xml index 1266c08..e991aa4 100644 --- a/zfipc-server/zfipc-system/src/main/resources/mapper/industrial/IpcAlarmRulesMapper.xml +++ b/zfipc-server/zfipc-system/src/main/resources/mapper/industrial/IpcAlarmRulesMapper.xml @@ -42,6 +42,7 @@ and reference_con = #{referenceCon} and alarm_level = #{alarmLevel} and sort = #{sort} + order by type @@ -50,6 +51,11 @@ where id = #{id} + + insert into ipc_alarm_rules diff --git a/zfipc-ui/src/api/industrial/rules.js b/zfipc-ui/src/api/industrial/rules.js index ba44ab8..ff20f3c 100644 --- a/zfipc-ui/src/api/industrial/rules.js +++ b/zfipc-ui/src/api/industrial/rules.js @@ -3,7 +3,16 @@ import request from "@/utils/request"; // 查询设备报警规则列表 export function listRules(query) { return request({ - url: "/system/rules/list", + url: "/alarm/rules/list", + method: "get", + params: query, + }); +} + +// 查询所有设备报警规则列表 +export function listAllRules(query) { + return request({ + url: "/alarm/rules/listAll", method: "get", params: query, }); @@ -12,7 +21,7 @@ export function listRules(query) { // 查询设备报警规则详细 export function getRules(id) { return request({ - url: "/system/rules/" + id, + url: "/alarm/rules/" + id, method: "get", }); } @@ -20,7 +29,7 @@ export function getRules(id) { // 新增设备报警规则 export function addRules(data) { return request({ - url: "/system/rules", + url: "/alarm/rules", method: "post", data: data, }); @@ -29,7 +38,7 @@ export function addRules(data) { // 修改设备报警规则 export function updateRules(data) { return request({ - url: "/system/rules", + url: "/alarm/rules", method: "put", data: data, }); @@ -38,7 +47,7 @@ export function updateRules(data) { // 删除设备报警规则 export function delRules(id) { return request({ - url: "/system/rules/" + id, + url: "/alarm/rules/" + id, method: "delete", }); } diff --git a/zfipc-ui/src/views/warn/alarm/index.vue b/zfipc-ui/src/views/warn/alarm/index.vue index 4f0568a..1a9d21c 100644 --- a/zfipc-ui/src/views/warn/alarm/index.vue +++ b/zfipc-ui/src/views/warn/alarm/index.vue @@ -25,6 +25,7 @@ @@ -58,7 +59,8 @@ > - @@ -133,17 +135,15 @@ :showSearch.sync="showSearch" @queryTable="getList" > - + --> + > + + + + + + + + + + + + + + + + + + + 搜索 + 重置 + + + + + + + + + + + + + + + + + + + + + + + > + + + + + + + + + + + + + + + + + + + 搜索 + 重置 + + + + + + + + + + + + + + + + + + + + + + { console.log("monitor:", response);