From ae7a65d6056fa95755ef776aefdaa0d38752b821 Mon Sep 17 00:00:00 2001 From: zhangjunwen Date: Tue, 16 Apr 2024 10:07:37 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E6=8E=A5=E6=94=B6=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E5=A4=84=E7=90=86=E4=B8=8D=E5=90=8C=E7=8A=B6=E6=80=81?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/constant/CacheConstants.java | 5 + .../inspur/datasyn/modbus/IpcDataProcess.java | 56 +++++++-- .../domain/IpcRunningStatusRecord.java | 76 +++++++++++ .../mapper/IpcRunningStatusRecordMapper.java | 69 ++++++++++ .../IIpcRunningStatusRecordService.java | 70 +++++++++++ .../service/impl/DataQueryService.java | 78 ++++++------ .../impl/IpcAlarmRulesServiceImpl.java | 8 +- .../IpcRunningStatusRecordServiceImpl.java | 119 ++++++++++++++++++ .../IpcRunningStatusRecordMapper.xml | 65 ++++++++++ zfipc-ui/src/App.vue | 20 +++ zfipc-ui/src/views/dataLog/index.vue | 4 +- 11 files changed, 518 insertions(+), 52 deletions(-) create mode 100644 zfipc-server/zfipc-system/src/main/java/com/inspur/industrial/domain/IpcRunningStatusRecord.java create mode 100644 zfipc-server/zfipc-system/src/main/java/com/inspur/industrial/mapper/IpcRunningStatusRecordMapper.java create mode 100644 zfipc-server/zfipc-system/src/main/java/com/inspur/industrial/service/IIpcRunningStatusRecordService.java create mode 100644 zfipc-server/zfipc-system/src/main/java/com/inspur/industrial/service/impl/IpcRunningStatusRecordServiceImpl.java create mode 100644 zfipc-server/zfipc-system/src/main/resources/mapper/industrial/IpcRunningStatusRecordMapper.xml diff --git a/zfipc-server/zfipc-common/src/main/java/com/inspur/common/constant/CacheConstants.java b/zfipc-server/zfipc-common/src/main/java/com/inspur/common/constant/CacheConstants.java index 998ece2..9671a9c 100644 --- a/zfipc-server/zfipc-common/src/main/java/com/inspur/common/constant/CacheConstants.java +++ b/zfipc-server/zfipc-common/src/main/java/com/inspur/common/constant/CacheConstants.java @@ -46,4 +46,9 @@ public class CacheConstants * ipc规则 */ public static final String IPC_RULES_KEY = "ipc_rules:"; + + /** + * ipc运行状态 + */ + public static final String IPC_RUNNING_STATUS_KEY = "ipc_running_status:"; } diff --git a/zfipc-server/zfipc-datasyn/src/main/java/com/inspur/datasyn/modbus/IpcDataProcess.java b/zfipc-server/zfipc-datasyn/src/main/java/com/inspur/datasyn/modbus/IpcDataProcess.java index 1c9a508..46e4bff 100644 --- a/zfipc-server/zfipc-datasyn/src/main/java/com/inspur/datasyn/modbus/IpcDataProcess.java +++ b/zfipc-server/zfipc-datasyn/src/main/java/com/inspur/datasyn/modbus/IpcDataProcess.java @@ -5,8 +5,12 @@ import com.inspur.equip.domain.IpcEquipInfo; import com.inspur.equip.service.IIpcEquipInfoService; import com.inspur.industrial.domain.IpcAlarmRecord; import com.inspur.industrial.domain.IpcAlarmRules; +import com.inspur.industrial.domain.IpcRunningStatusRecord; +import com.inspur.industrial.domain.IpcSysStatus; import com.inspur.industrial.service.IIpcAlarmRecordService; import com.inspur.industrial.service.IIpcAlarmRulesService; +import com.inspur.industrial.service.IIpcRunningStatusRecordService; +import com.inspur.industrial.service.IIpcSysStatusService; import com.inspur.industrial.utils.Constant; import com.inspur.industrial.utils.IpcUtil; import com.inspur.system.service.influx.InfluxDBService; @@ -15,6 +19,7 @@ import com.serotonin.modbus4j.ModbusMaster; import org.springframework.core.annotation.Order; import org.springframework.stereotype.Component; +import java.time.LocalDateTime; import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -80,7 +85,7 @@ public class IpcDataProcess implements Runnable { String bottomCylId = equipList.stream().filter(equip -> equip.getEquipName().equals("超压底缸")).collect(Collectors.toList()).get(0).getId(); String topScollerId = equipList.stream().filter(equip -> equip.getEquipName().equals("可控中高辊顶辊")).collect(Collectors.toList()).get(0).getId(); String bottomScollerId = equipList.stream().filter(equip -> equip.getEquipName().equals("可控中高辊底辊")).collect(Collectors.toList()).get(0).getId(); - + saveRunningStatus("1"); bottomCylinderDataProcess(null, bottomCylId, i, ipcUtil, alarmRulesService, alarmRecordService); scollerDataProcess(null, topScollerId, topScollerMeasurement, i, ipcUtil, alarmRulesService, alarmRecordService); scollerDataProcess(null, bottomScollerId, bottomScollerMeasurement, i, ipcUtil, alarmRulesService, alarmRecordService); @@ -110,7 +115,6 @@ public class IpcDataProcess implements Runnable { Map tags = new TreeMap(); tags.put("equ_id", equipId); Map fields = new TreeMap(); - //TODO 停机运维状态数据不储存 tags.put("status", "1");//正常运行 0:停机 1:正常运行 2:待机 3:试运行 @@ -125,7 +129,7 @@ public class IpcDataProcess implements Runnable { fields.put("sys_level", (float) 0 + Math.random()); //液位最小和最大值通过报警参数设置获取 - IpcAlarmRules levelRule = getLevelAlarmRule(equipId); + IpcAlarmRules levelRule = getLevelAlarmRule(equipId, Constant.RUNNING);//TODO 根据接收运行参数确定参数 //正式需要放开 fields.put("level_min", levelRule == null ? 0.0 : levelRule.getAlertLowerBound().floatValue()); fields.put("level_max", levelRule == null ? 0.0 : levelRule.getAlertUpperBound().floatValue()); @@ -182,8 +186,8 @@ public class IpcDataProcess implements Runnable { //传动侧底缸位移 fields.put("driven_bottom_dis", (float) 0 + Math.random()); //报警处理 - List rulesList = alarmRulesService.selectIpcAlarmRulesByEquipId(equipId); - alarmRecordList.addAll(ipcUtil.dealRealTimeData(fields, tags, Constant.RUNNING, rulesList)); + List rulesList = alarmRulesService.selectIpcAlarmRulesConfigListByCache(equipId); + alarmRecordList.addAll(ipcUtil.dealRealTimeData(fields, tags, Constant.RUNNING, rulesList));//TODO 根据运行状态确定规则 i.insert(measurement, tags, fields); if (!alarmRecordList.isEmpty()) {//运行需放开 @@ -213,7 +217,7 @@ public class IpcDataProcess implements Runnable { // fields.put("ywmin",0.3); // fields.put("ywmax",1); //液位最小和最大值通过报警参数设置获取 - IpcAlarmRules levelRule = getLevelAlarmRule(equipId); + IpcAlarmRules levelRule = getLevelAlarmRule(equipId, Constant.RUNNING);//TODO 根据接收运行参数确定参数 //正式需要放开 fields.put("level_min", levelRule == null ? 0.0 : levelRule.getAlertLowerBound().floatValue()); fields.put("level_max", levelRule == null ? 0.0 : levelRule.getAlertUpperBound().floatValue()); @@ -277,8 +281,8 @@ public class IpcDataProcess implements Runnable { fields.put("flw11", (float) 0 + Math.random()); //报警处理 - List rulesList = alarmRulesService.selectIpcAlarmRulesByEquipId(equipId); - alarmRecordList.addAll(ipcUtil.dealRealTimeData(fields, tags, Constant.RUNNING, rulesList)); + List rulesList = alarmRulesService.selectIpcAlarmRulesConfigListByCache(equipId); + alarmRecordList.addAll(ipcUtil.dealRealTimeData(fields, tags, Constant.RUNNING, rulesList));//TODO 根据运行状态确定规则 if (!alarmRecordList.isEmpty()) {//运行需放开 // alarmRecordService.batchInsertIpcAlarmRecord(alarmRecordList); } @@ -290,12 +294,44 @@ public class IpcDataProcess implements Runnable { * * @return */ - private IpcAlarmRules getLevelAlarmRule(String equipId) { + private IpcAlarmRules getLevelAlarmRule(String equipId,Integer type) { IIpcAlarmRulesService ipcAlarmRulesService = SpringUtils.getBean(IIpcAlarmRulesService.class); IpcAlarmRules query = new IpcAlarmRules(); query.setEquipId(equipId); query.setAlarmNameKey("sys_level"); - query.setType(Constant.RUNNING);//运行中 + query.setType(type);//运行中 return ipcAlarmRulesService.selectIpcAlarmRulesList(query).get(0) == null ? null : ipcAlarmRulesService.selectIpcAlarmRulesList(query).get(0); } + + /** + * 根据状态存储时间,0:停机维护,1:运行,2:待机,3:试运行 + */ + private void saveRunningStatus(String status) { + + IIpcRunningStatusRecordService ipcRunningStatusRecordService = SpringUtils.getBean(IIpcRunningStatusRecordService.class); + String latestStatus = ipcRunningStatusRecordService.selectLatestStatus(); + if (latestStatus == null || !latestStatus.equals(status)) { + IpcRunningStatusRecord ipcRunningStatusRecord = new IpcRunningStatusRecord(status); + ipcRunningStatusRecordService.insertIpcRunningStatusRecord(ipcRunningStatusRecord); + //修改系统状态时间 + IIpcSysStatusService ipcSysStatusService = SpringUtils.getBean(IIpcSysStatusService.class); + IpcSysStatus sysStatus = ipcSysStatusService.selectIpcSysStatusList(null).get(0); + //0:停机维护,1:运行,2:待机,3:试运行 + switch(status) { + case "0" : + sysStatus.setShutdownTime(LocalDateTime.now()); + break; + case "1" : + sysStatus.setNormalTime(LocalDateTime.now()); + break; + case "2" : + sysStatus.setStandbyTime(LocalDateTime.now()); + break; + case "3" : + sysStatus.setTrialTime(LocalDateTime.now()); + break; + } + ipcSysStatusService.updateIpcSysStatus(sysStatus); + } + } } diff --git a/zfipc-server/zfipc-system/src/main/java/com/inspur/industrial/domain/IpcRunningStatusRecord.java b/zfipc-server/zfipc-system/src/main/java/com/inspur/industrial/domain/IpcRunningStatusRecord.java new file mode 100644 index 0000000..5fafe88 --- /dev/null +++ b/zfipc-server/zfipc-system/src/main/java/com/inspur/industrial/domain/IpcRunningStatusRecord.java @@ -0,0 +1,76 @@ +package com.inspur.industrial.domain; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.inspur.common.annotation.Excel; +import com.inspur.common.core.domain.BaseEntity; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; + +import java.util.Date; + +/** + * 运行状态记录对象 ipc_running_status_record + * + * @author inspur + * @date 2024-04-09 + */ +public class IpcRunningStatusRecord extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 主键 */ + private Long id; + + /** 运行状态 */ + @Excel(name = "运行状态") + private String runningStatus; + + /** 开始时间 */ + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "开始时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date startTime; + + public void setId(Long id) + { + this.id = id; + } + + public Long getId() + { + return id; + } + public void setRunningStatus(String runningStatus) + { + this.runningStatus = runningStatus; + } + + public String getRunningStatus() + { + return runningStatus; + } + public void setStartTime(Date startTime) + { + this.startTime = startTime; + } + + public Date getStartTime() + { + return startTime; + } + + public IpcRunningStatusRecord() { + } + + public IpcRunningStatusRecord(String runningStatus) { + this.runningStatus = runningStatus; + } + + @Override + public String toString() { + return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) + .append("id", getId()) + .append("runningStatus", getRunningStatus()) + .append("startTime", getStartTime()) + .toString(); + } +} diff --git a/zfipc-server/zfipc-system/src/main/java/com/inspur/industrial/mapper/IpcRunningStatusRecordMapper.java b/zfipc-server/zfipc-system/src/main/java/com/inspur/industrial/mapper/IpcRunningStatusRecordMapper.java new file mode 100644 index 0000000..72d8326 --- /dev/null +++ b/zfipc-server/zfipc-system/src/main/java/com/inspur/industrial/mapper/IpcRunningStatusRecordMapper.java @@ -0,0 +1,69 @@ +package com.inspur.industrial.mapper; + +import com.inspur.industrial.domain.IpcRunningStatusRecord; + +import java.util.List; + +/** + * 运行状态记录Mapper接口 + * + * @author inspur + * @date 2024-04-09 + */ +public interface IpcRunningStatusRecordMapper +{ + /** + * 查询运行状态记录 + * + * @param id 运行状态记录主键 + * @return 运行状态记录 + */ + public IpcRunningStatusRecord selectIpcRunningStatusRecordById(Long id); + + /** + * 查询运行状态记录列表 + * + * @param ipcRunningStatusRecord 运行状态记录 + * @return 运行状态记录集合 + */ + public List selectIpcRunningStatusRecordList(IpcRunningStatusRecord ipcRunningStatusRecord); + + /** + * 新增运行状态记录 + * + * @param ipcRunningStatusRecord 运行状态记录 + * @return 结果 + */ + public int insertIpcRunningStatusRecord(IpcRunningStatusRecord ipcRunningStatusRecord); + + /** + * 修改运行状态记录 + * + * @param ipcRunningStatusRecord 运行状态记录 + * @return 结果 + */ + public int updateIpcRunningStatusRecord(IpcRunningStatusRecord ipcRunningStatusRecord); + + /** + * 删除运行状态记录 + * + * @param id 运行状态记录主键 + * @return 结果 + */ + public int deleteIpcRunningStatusRecordById(Long id); + + /** + * 批量删除运行状态记录 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteIpcRunningStatusRecordByIds(Long[] ids); + + /** + * 查询最新状态 + * + * @return 结果 + */ + String selectLatestStatus(); +} diff --git a/zfipc-server/zfipc-system/src/main/java/com/inspur/industrial/service/IIpcRunningStatusRecordService.java b/zfipc-server/zfipc-system/src/main/java/com/inspur/industrial/service/IIpcRunningStatusRecordService.java new file mode 100644 index 0000000..8554783 --- /dev/null +++ b/zfipc-server/zfipc-system/src/main/java/com/inspur/industrial/service/IIpcRunningStatusRecordService.java @@ -0,0 +1,70 @@ +package com.inspur.industrial.service; + +import com.inspur.industrial.domain.IpcRunningStatusRecord; + +import java.util.List; + +/** + * 运行状态记录Service接口 + * + * @author inspur + * @date 2024-04-09 + */ +public interface IIpcRunningStatusRecordService +{ + /** + * 查询运行状态记录 + * + * @param id 运行状态记录主键 + * @return 运行状态记录 + */ + public IpcRunningStatusRecord selectIpcRunningStatusRecordById(Long id); + + /** + * 查询运行状态记录列表 + * + * @param ipcRunningStatusRecord 运行状态记录 + * @return 运行状态记录集合 + */ + public List selectIpcRunningStatusRecordList(IpcRunningStatusRecord ipcRunningStatusRecord); + + /** + * 新增运行状态记录 + * + * @param ipcRunningStatusRecord 运行状态记录 + * @return 结果 + */ + public int insertIpcRunningStatusRecord(IpcRunningStatusRecord ipcRunningStatusRecord); + + /** + * 修改运行状态记录 + * + * @param ipcRunningStatusRecord 运行状态记录 + * @return 结果 + */ + public int updateIpcRunningStatusRecord(IpcRunningStatusRecord ipcRunningStatusRecord); + + /** + * 批量删除运行状态记录 + * + * @param ids 需要删除的运行状态记录主键集合 + * @return 结果 + */ + public int deleteIpcRunningStatusRecordByIds(Long[] ids); + + /** + * 删除运行状态记录信息 + * + * @param id 运行状态记录主键 + * @return 结果 + */ + public int deleteIpcRunningStatusRecordById(Long id); + + /** + * 查询最新状态 + * + * @return 结果 + */ + String selectLatestStatus(); + String getSSS(); +} 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 5bf4497..fb944fa 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 @@ -43,39 +43,41 @@ public class DataQueryService implements IDataQueryService { return null; } Map resMap = new HashMap<>(); - resMap.put("sysstatus", list.get(0).get("status"));//系统状态 - 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", 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("sysstatus", list.get(0).get("status") == null ? 0 : list.get(0).get("status") );//系统状态 + resMap.put("sysflw", list.get(0).get("sys_flw") == null ? 0 : list.get(0).get("sys_flw"));//系统流量 + resMap.put("sysprs", list.get(0).get("sys_press") == null ? 0 : list.get(0).get("sys_press"));//系统压力 + resMap.put("syslevel", list.get(0).get("sys_level") == null ? 0 : list.get(0).get("sys_level"));//系统液位 + resMap.put("syslevelinit", Float.parseFloat(sysConfigService.selectConfigByKey("sys.liquidlevel.init") == null ? + "0" : sysConfigService.selectConfigByKey("sys.liquidlevel.init")));//液位初始值 + resMap.put("levelmax", list.get(0).get("level_max") == null ? 0 : list.get(0).get("level_max")); + resMap.put("levelmin", list.get(0).get("level_min") == null ? 0 : list.get(0).get("level_min")); - resMap.put("systemp",list.get(0).get("sys_temp"));//系统温度 - resMap.put("syshumid",list.get(0).get("oil_water"));//系统湿度 - resMap.put("sysvisc",list.get(0).get("visc"));//系统粘度 + resMap.put("systemp",list.get(0).get("sys_temp") == null ? 0 : list.get(0).get("sys_temp"));//系统温度 + resMap.put("syshumid",list.get(0).get("oil_water") == null ? 0 : list.get(0).get("oil_water"));//系统湿度 + resMap.put("sysvisc",list.get(0).get("visc") == null ? 0 : list.get(0).get("visc"));//系统粘度 //系统颗粒度 - resMap.put("sysgran4",list.get(0).get("gran4")); - resMap.put("sysgran6",list.get(0).get("gran6")); - resMap.put("sysgran14",list.get(0).get("gran14")); - resMap.put("sysgran21",list.get(0).get("gran21")); + resMap.put("sysgran4",list.get(0).get("gran4") == null ? 0 : list.get(0).get("gran4")); + resMap.put("sysgran6",list.get(0).get("gran6") == null ? 0 : list.get(0).get("gran6")); + resMap.put("sysgran14",list.get(0).get("gran14") == null ? 0 : list.get(0).get("gran14")); + resMap.put("sysgran21",list.get(0).get("gran21") == null ? 0 : list.get(0).get("gran21")); // Map oprsoftflw = (Map) new HashMap<>().put("oprsoftflw",list.get(0).get("opr_soft_flw") );//操作侧软辊流量 // Map oprhotflw = (Map) new HashMap<>().put("oprhotflw",list.get(0).get("opr_hot_flw") );//操作侧热辊流量 // Map drivensoftflw = (Map) new HashMap<>().put("drivensoftflw",list.get(0).get("driven_soft_flw") );//传动侧软辊流量 // Map drivenhotflw = (Map) new HashMap<>().put("drivenhotflw",list.get(0).get("driven_hot_flw") );//传动侧软辊流量 - resMap.put("oprservo",list.get(0).get("opr_servo"));//操作侧底缸比例换向阀 - resMap.put("drivenservo",list.get(0).get("driven_servo"));//操作侧底缸比例换向阀 + resMap.put("oprservo",list.get(0).get("opr_servo") == null ? 0 : list.get(0).get("opr_servo"));//操作侧底缸比例换向阀 + resMap.put("drivenservo",list.get(0).get("driven_servo") == null ? 0 : list.get(0).get("driven_servo"));//操作侧底缸比例换向阀 //功率= √3IUcosΦ/1000 - resMap.put("syspower",Math.sqrt(3)*Float.parseFloat(list.get(0).get("sys_cur").toString())*380*0.86/1000); + resMap.put("syspower",list.get(0).get("sys_cur") == null ? 0 : Math.sqrt(3)*Float.parseFloat(list.get(0).get("sys_cur").toString())*380*0.86/1000); //系统效率 = 系统压力*系统流量/系统功率 - double power = (double) resMap.get("syspower"); - double sysflw = (double)resMap.get("sysflw"); - double pressure = (double)resMap.get("sysprs"); - resMap.put("syseff",pressure * sysflw/power*100); + double power = (double)resMap.get("syspower") == 0 ? 0 : (double)resMap.get("syspower"); + double sysflw = (double)resMap.get("sysflw") == 0 ? 0 : (double)resMap.get("sysflw"); + double pressure = (double)resMap.get("sysprs") == 0 ? 0 : (double)resMap.get("sysprs"); + + resMap.put("syseff",power == 0 ? 0 : pressure * sysflw/power*100); List syscur = new ArrayList<>();//系统电流 @@ -111,7 +113,7 @@ public class DataQueryService implements IDataQueryService { for (int i = list.size() - 1; i >= 0; i--) { Map data = list.get(i); - syscur.add(data.get("sys_cur")); + syscur.add(data.get("sys_cur") == null ? 0 : 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")); @@ -409,33 +411,33 @@ public class DataQueryService implements IDataQueryService { private Map queryScollerData(List> list) { Map resMap = new HashMap<>(); - 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")));//液位初始值 + resMap.put("sysflw", list.get(0).get("sys_flw") == null ? 0 : (double) list.get(0).get("sys_flw"));//系统流量 + resMap.put("sysprs", list.get(0).get("sys_press") == null ? 0 : (double) list.get(0).get("sys_press"));//系统压力 + resMap.put("syslevel", list.get(0).get("sys_level") == null ? 0 : (double) list.get(0).get("sys_level"));//系统液位 + resMap.put("syslevelinit", Integer.parseInt(sysConfigService.selectConfigByKey("sys.liquidlevel.init") == null ? "0" : sysConfigService.selectConfigByKey("sys.liquidlevel.init")));//液位初始值 //TODO 获取系统液位高值和低值 - resMap.put("levelmax", list.get(0).get("level_max")); - resMap.put("levelmin", list.get(0).get("level_min")); + resMap.put("levelmax", list.get(0).get("level_max") == null ? 0 : (double) list.get(0).get("level_max")); + resMap.put("levelmin", list.get(0).get("level_min") == null ? 0 : (double) list.get(0).get("level_min")); - resMap.put("systemp",list.get(0).get("sys_temp"));//系统温度 - resMap.put("syshumid",list.get(0).get("oil_water"));//系统湿度 - resMap.put("sysvisc",list.get(0).get("visc"));//系统粘度 + resMap.put("systemp",list.get(0).get("sys_temp") == null ? 0 : (double) list.get(0).get("sys_temp"));//系统温度 + resMap.put("syshumid",list.get(0).get("oil_water") == null ? 0 : (double) list.get(0).get("oil_water"));//系统湿度 + resMap.put("sysvisc",list.get(0).get("visc") == null ? 0 : (double) list.get(0).get("visc"));//系统粘度 //系统颗粒度 - resMap.put("sysgran4",list.get(0).get("gran4")); - resMap.put("sysgran6",list.get(0).get("gran6")); - resMap.put("sysgran14",list.get(0).get("gran14")); - resMap.put("sysgran21",list.get(0).get("gran21")); + resMap.put("sysgran4",list.get(0).get("gran4") == null ? 0 : (double) list.get(0).get("gran4")); + resMap.put("sysgran6",list.get(0).get("gran6") == null ? 0 : (double) list.get(0).get("gran6")); + resMap.put("sysgran14",list.get(0).get("gran14") == null ? 0 : (double) list.get(0).get("gran14")); + resMap.put("sysgran21",list.get(0).get("gran21") == null ? 0 : (double) list.get(0).get("gran21")); - resMap.put("linespeed",list.get(0).get("line_speed"));//车速 + resMap.put("linespeed",list.get(0).get("line_speed") == null ? 0 : (double) list.get(0).get("line_speed"));//车速 //功率= √3IUcosΦ/1000 - resMap.put("syspower",Math.sqrt(3)*Float.parseFloat(list.get(0).get("sys_cur").toString())*380*0.86/1000); + resMap.put("syspower",list.get(0).get("sys_cur") == null ? 0 : Math.sqrt(3)*Float.parseFloat(list.get(0).get("sys_cur").toString())*380*0.86/1000); //系统效率 = 系统压力*系统流量/系统功率 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",power == 0 ? 0 : pressure * sysflw/power); List syscur = new ArrayList<>();//系统电流 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 f4223c2..39d4f9c 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 @@ -44,11 +44,13 @@ public class IpcAlarmRulesServiceImpl implements IIpcAlarmRulesService //加载规则到缓存 @PostConstruct public void init(){ - List rules = selectIpcAlarmRulesList(null); List equips = ipcEquipInfoService.selectIpcEquipInfoList(null); for (IpcEquipInfo equip : equips) { List rulesByEquipId = selectIpcAlarmRulesByEquipId(equip.getId()); - redisCache.setCacheObject(CacheConstants.IPC_RULES_KEY+equip.getId(),rulesByEquipId); + if(redisCache.getCacheObject(CacheConstants.IPC_RULES_KEY+equip.getId()) != null){ + redisCache.deleteObject(CacheConstants.IPC_RULES_KEY+equip.getId()); + } + redisCache.setCacheList((CacheConstants.IPC_RULES_KEY+equip.getId()),rulesByEquipId); } } @@ -173,7 +175,7 @@ public class IpcAlarmRulesServiceImpl implements IIpcAlarmRulesService List rules = redisCache.getCacheList(CacheConstants.IPC_RULES_KEY + equipId); if (rules == null || rules.size() == 0){ List rulesList = selectIpcAlarmRulesByEquipId(equipId); - redisCache.setCacheList(CacheConstants.IPC_RULES_KEY + equipId,rulesList); + redisCache.setCacheList((CacheConstants.IPC_RULES_KEY + equipId),rulesList); return rulesList; } return rules; diff --git a/zfipc-server/zfipc-system/src/main/java/com/inspur/industrial/service/impl/IpcRunningStatusRecordServiceImpl.java b/zfipc-server/zfipc-system/src/main/java/com/inspur/industrial/service/impl/IpcRunningStatusRecordServiceImpl.java new file mode 100644 index 0000000..745d2c3 --- /dev/null +++ b/zfipc-server/zfipc-system/src/main/java/com/inspur/industrial/service/impl/IpcRunningStatusRecordServiceImpl.java @@ -0,0 +1,119 @@ +package com.inspur.industrial.service.impl; + +import com.inspur.common.constant.CacheConstants; +import com.inspur.common.core.redis.RedisCache; +import com.inspur.common.utils.StringUtils; +import com.inspur.industrial.domain.IpcRunningStatusRecord; +import com.inspur.industrial.mapper.IpcRunningStatusRecordMapper; +import com.inspur.industrial.service.IIpcRunningStatusRecordService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * 运行状态记录Service业务层处理 + * + * @author inspur + * @date 2024-04-09 + */ +@Service +public class IpcRunningStatusRecordServiceImpl implements IIpcRunningStatusRecordService +{ + @Autowired + private IpcRunningStatusRecordMapper ipcRunningStatusRecordMapper; + @Autowired + private RedisCache redisCache; + /** + * 查询运行状态记录 + * + * @param id 运行状态记录主键 + * @return 运行状态记录 + */ + @Override + public IpcRunningStatusRecord selectIpcRunningStatusRecordById(Long id) + { + return ipcRunningStatusRecordMapper.selectIpcRunningStatusRecordById(id); + } + + /** + * 查询运行状态记录列表 + * + * @param ipcRunningStatusRecord 运行状态记录 + * @return 运行状态记录 + */ + @Override + public List selectIpcRunningStatusRecordList(IpcRunningStatusRecord ipcRunningStatusRecord) + { + return ipcRunningStatusRecordMapper.selectIpcRunningStatusRecordList(ipcRunningStatusRecord); + } + + /** + * 新增运行状态记录 + * + * @param ipcRunningStatusRecord 运行状态记录 + * @return 结果 + */ + @Override + public int insertIpcRunningStatusRecord(IpcRunningStatusRecord ipcRunningStatusRecord) + { + int num = ipcRunningStatusRecordMapper.insertIpcRunningStatusRecord(ipcRunningStatusRecord); + // 更新缓存 + redisCache.setCacheObject(CacheConstants.IPC_RUNNING_STATUS_KEY,ipcRunningStatusRecord.getRunningStatus()); + return num; + } + + /** + * 修改运行状态记录 + * + * @param ipcRunningStatusRecord 运行状态记录 + * @return 结果 + */ + @Override + public int updateIpcRunningStatusRecord(IpcRunningStatusRecord ipcRunningStatusRecord) + { + return ipcRunningStatusRecordMapper.updateIpcRunningStatusRecord(ipcRunningStatusRecord); + } + + /** + * 批量删除运行状态记录 + * + * @param ids 需要删除的运行状态记录主键 + * @return 结果 + */ + @Override + public int deleteIpcRunningStatusRecordByIds(Long[] ids) + { + return ipcRunningStatusRecordMapper.deleteIpcRunningStatusRecordByIds(ids); + } + + /** + * 删除运行状态记录信息 + * + * @param id 运行状态记录主键 + * @return 结果 + */ + @Override + public int deleteIpcRunningStatusRecordById(Long id) + { + return ipcRunningStatusRecordMapper.deleteIpcRunningStatusRecordById(id); + } + /** + * 查询最新状态 + * + * @return 结果 + */ + @Override + public String selectLatestStatus(){ + String status = redisCache.getCacheObject(CacheConstants.IPC_RUNNING_STATUS_KEY); + if(StringUtils.isNull(status) || StringUtils.isEmpty(status)){ + status = ipcRunningStatusRecordMapper.selectLatestStatus(); + redisCache.setCacheObject(CacheConstants.IPC_RUNNING_STATUS_KEY,status); + } + return status; + } + @Override + public String getSSS(){ + return redisCache.getCacheObject("status_test"); + } +} diff --git a/zfipc-server/zfipc-system/src/main/resources/mapper/industrial/IpcRunningStatusRecordMapper.xml b/zfipc-server/zfipc-system/src/main/resources/mapper/industrial/IpcRunningStatusRecordMapper.xml new file mode 100644 index 0000000..0d128b7 --- /dev/null +++ b/zfipc-server/zfipc-system/src/main/resources/mapper/industrial/IpcRunningStatusRecordMapper.xml @@ -0,0 +1,65 @@ + + + + + + + + + + + + select id, running_status, start_time from ipc_running_status_record + + + + + + + + insert into ipc_running_status_record + + running_status, + start_time + + + #{runningStatus}, + SYSDATE() + + + + + update ipc_running_status_record + + running_status = #{runningStatus}, + start_time = #{startTime}, + + where id = #{id} + + + + delete from ipc_running_status_record where id = #{id} + + + + delete from ipc_running_status_record where id in + + #{id} + + + + + diff --git a/zfipc-ui/src/App.vue b/zfipc-ui/src/App.vue index 730904f..b83366c 100644 --- a/zfipc-ui/src/App.vue +++ b/zfipc-ui/src/App.vue @@ -26,4 +26,24 @@ export default { .el-picker-panel__footer { background-color: #001129; } +div.el-table tr { + background-color: #0b2d57; +} +.el-tabs--border-card { + background-color: #124b86; +} +.el-tabs--border-card > .el-tabs__header .el-tabs__item.is-active { + background-color: #002250; + border-color: white; +} +.el-tabs--border-card > .el-tabs__header .el-tabs__item { + background-color: #124b86; + border-color: white; +} +.el-tabs--border-card > .el-tabs__header { + background-color: #124b86; +} +.pagination-container { + height: 30px; +} diff --git a/zfipc-ui/src/views/dataLog/index.vue b/zfipc-ui/src/views/dataLog/index.vue index f06de1d..97a0094 100644 --- a/zfipc-ui/src/views/dataLog/index.vue +++ b/zfipc-ui/src/views/dataLog/index.vue @@ -16,6 +16,7 @@ v-model="activeName" type="border-card" @tab-click="handleTabClick" + style="margin-top:20px" >