数据记录查询条件和导出

This commit is contained in:
zhanghan11 2024-04-09 11:25:39 +08:00
parent defad5d8c2
commit 756358ad3d
9 changed files with 183 additions and 85 deletions

View File

@ -2,7 +2,10 @@ package com.inspur.web.controller.ipc;
import com.inspur.common.core.controller.BaseController; import com.inspur.common.core.controller.BaseController;
import com.inspur.common.core.domain.AjaxResult; import com.inspur.common.core.domain.AjaxResult;
import com.inspur.common.utils.poi.ExcelUtil;
import com.inspur.ipc.domain.IpcPlcData;
import com.inspur.ipc.domain.IpcQueryParams; import com.inspur.ipc.domain.IpcQueryParams;
import com.inspur.ipc.domain.IpcSensorData;
import com.inspur.ipc.service.IIpcDataLogService; import com.inspur.ipc.service.IIpcDataLogService;
import com.inspur.ipc.service.IIpcDataShowService; import com.inspur.ipc.service.IIpcDataShowService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -10,6 +13,8 @@ import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;
/** /**
* 数据展示界面 * 数据展示界面
@ -21,22 +26,22 @@ import javax.servlet.http.HttpServletResponse;
public class IpcDataLogController extends BaseController { public class IpcDataLogController extends BaseController {
@Autowired @Autowired
private IIpcDataLogService iIpcDataLogService; private IIpcDataLogService iIpcDataLogService;
/** /**
* 查询plc数据记录 * 查询plc数据记录
*/ */
@PreAuthorize("@ss.hasPermi('ipc:dataLog:query')") @PreAuthorize("@ss.hasPermi('ipc:dataLog:query')")
@GetMapping(value = "/plc") @GetMapping(value = "/plc")
public AjaxResult queryPlcDataLog(@RequestBody IpcQueryParams ipcQueryParams) public AjaxResult queryPlcDataLog(IpcQueryParams ipcQueryParams) {
{
return AjaxResult.success(iIpcDataLogService.queryPlcDataLog(ipcQueryParams)); return AjaxResult.success(iIpcDataLogService.queryPlcDataLog(ipcQueryParams));
} }
/** /**
* 查询传感器温振数据记录 * 查询传感器温振数据记录
*/ */
@PreAuthorize("@ss.hasPermi('ipc:dataLog:query')") @PreAuthorize("@ss.hasPermi('ipc:dataLog:query')")
@GetMapping(value = "/sensor") @GetMapping(value = "/sensor")
public AjaxResult querySensorDataLog(@RequestBody IpcQueryParams ipcQueryParams) public AjaxResult querySensorDataLog(IpcQueryParams ipcQueryParams) {
{
return AjaxResult.success(iIpcDataLogService.querySensorDataLog(ipcQueryParams)); return AjaxResult.success(iIpcDataLogService.querySensorDataLog(ipcQueryParams));
} }
@ -44,19 +49,26 @@ public class IpcDataLogController extends BaseController {
* 导出plc数据记录 * 导出plc数据记录
*/ */
@PreAuthorize("@ss.hasPermi('ipc:dataLog:query')") @PreAuthorize("@ss.hasPermi('ipc:dataLog:query')")
@GetMapping(value = "/plcExport") @PostMapping(value = "/plcExport")
public AjaxResult exportPlcDataLog(HttpServletResponse response, @RequestBody IpcQueryParams ipcQueryParams) public void exportPlcDataLog(HttpServletResponse response, IpcQueryParams ipcQueryParams) {
{ ipcQueryParams.setPageNum(0);
return AjaxResult.success(iIpcDataLogService.queryPlcDataLog(ipcQueryParams)); ipcQueryParams.setPageSize(0);
Map<String, Object> resMap = iIpcDataLogService.queryPlcDataLog(ipcQueryParams);
ExcelUtil<IpcPlcData> util = new ExcelUtil<IpcPlcData>(IpcPlcData.class);
util.exportExcel(response, (List<IpcPlcData>)resMap.get("rows"), "plc温压数据");
} }
/** /**
* 导出传感器温振数据记录 * 导出传感器温振数据记录
*/ */
@PreAuthorize("@ss.hasPermi('ipc:dataLog:query')") @PreAuthorize("@ss.hasPermi('ipc:dataLog:query')")
@GetMapping(value = "/sensorExport") @PostMapping(value = "/sensorExport")
public AjaxResult exportSensorDataLog(HttpServletResponse response,@RequestBody IpcQueryParams ipcQueryParams) public void exportSensorDataLog(HttpServletResponse response, IpcQueryParams ipcQueryParams) {
{ ipcQueryParams.setPageNum(0);
return AjaxResult.success(iIpcDataLogService.querySensorDataLog(ipcQueryParams)); ipcQueryParams.setPageSize(0);
Map<String, Object> resMap = iIpcDataLogService.querySensorDataLog(ipcQueryParams);
ExcelUtil<IpcSensorData> util = new ExcelUtil<IpcSensorData>(IpcSensorData.class);
util.exportExcel(response, (List<IpcSensorData>)resMap.get("rows"), "传感器温振数据");
} }
/** /**
@ -64,8 +76,7 @@ public class IpcDataLogController extends BaseController {
*/ */
@PreAuthorize("@ss.hasPermi('ipc:dataShow:query')") @PreAuthorize("@ss.hasPermi('ipc:dataShow:query')")
@GetMapping(value = "/getTendencyData") @GetMapping(value = "/getTendencyData")
public AjaxResult getTendencyData(@RequestBody IpcQueryParams ipcQueryParams) public AjaxResult getTendencyData(@RequestBody IpcQueryParams ipcQueryParams) {
{
return AjaxResult.success(iIpcDataLogService.getTendencyData(ipcQueryParams)); return AjaxResult.success(iIpcDataLogService.getTendencyData(ipcQueryParams));
} }
} }

View File

@ -109,7 +109,7 @@ public class IPCPlcDataSyncThread implements Runnable {
// fields.put("vz", (float) 0 + Math.random()); // fields.put("vz", (float) 0 + Math.random());
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS"); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");
String format = simpleDateFormat.format(new Date()); String format = simpleDateFormat.format(new Date());
tags.put("insertTime", format); fields.put("insertTime", format);
// TODO 根据报警规则校验 // TODO 根据报警规则校验
// 根据运行状态获取规则 // 根据运行状态获取规则
List<IpcAlarmRulesConfig> rulesConfigList = iIpcAlarmRulesConfigService.selectIpcAlarmRulesConfigList(tags.get("part")); List<IpcAlarmRulesConfig> rulesConfigList = iIpcAlarmRulesConfigService.selectIpcAlarmRulesConfigList(tags.get("part"));

View File

@ -57,7 +57,7 @@ public class IPCSensorDataSyncThread implements Runnable {
fields.put(field.getFieldValue(), getData()); fields.put(field.getFieldValue(), getData());
} }
} }
tags.put("insertTime", format); fields.put("insertTime", format);
InfluxDBService i = SpringUtils.getBean(InfluxDBService.class); InfluxDBService i = SpringUtils.getBean(InfluxDBService.class);
i.insert(IpcConstant.SENSOR_MEASUREMENT, tags, fields); i.insert(IpcConstant.SENSOR_MEASUREMENT, tags, fields);
} }

View File

@ -4,6 +4,8 @@ import com.inspur.common.annotation.Excel;
public class IpcPlcData { public class IpcPlcData {
@Excel(name = "时间")
private String insertTime ;
@Excel(name = "运行状态") @Excel(name = "运行状态")
private String rstatus ; private String rstatus ;
@Excel(name = "字段排序") @Excel(name = "字段排序")
@ -28,7 +30,8 @@ public class IpcPlcData {
public IpcPlcData() { public IpcPlcData() {
} }
public IpcPlcData(String rstatus,String pz4, String pz6, String pz14, String pz21, String owc, String ov, String rot, String oip, String od) { public IpcPlcData(String insertTime, String rstatus, String pz4, String pz6, String pz14, String pz21, String owc, String ov, String rot, String oip, String od) {
this.insertTime = insertTime;
this.rstatus = rstatus; this.rstatus = rstatus;
this.pz4 = pz4; this.pz4 = pz4;
this.pz6 = pz6; this.pz6 = pz6;
@ -41,6 +44,14 @@ public class IpcPlcData {
this.od = od; this.od = od;
} }
public String getInsertTime() {
return insertTime;
}
public void setInsertTime(String insertTime) {
this.insertTime = insertTime;
}
public String getRstatus() { public String getRstatus() {
return rstatus; return rstatus;
} }
@ -124,7 +135,8 @@ public class IpcPlcData {
@Override @Override
public String toString() { public String toString() {
return "IpcPlcData{" + return "IpcPlcData{" +
"rstatus='" + rstatus + '\'' + "insertTime='" + insertTime + '\'' +
", rstatus='" + rstatus + '\'' +
", pz4='" + pz4 + '\'' + ", pz4='" + pz4 + '\'' +
", pz6='" + pz6 + '\'' + ", pz6='" + pz6 + '\'' +
", pz14='" + pz14 + '\'' + ", pz14='" + pz14 + '\'' +

View File

@ -1,6 +1,8 @@
package com.inspur.ipc.domain; package com.inspur.ipc.domain;
public class IpcQueryParams { import com.inspur.common.core.domain.BaseEntity;
public class IpcQueryParams extends BaseEntity {
/** /**
* 监测部位 * 监测部位
*/ */

View File

@ -3,6 +3,8 @@ package com.inspur.ipc.domain;
import com.inspur.common.annotation.Excel; import com.inspur.common.annotation.Excel;
public class IpcSensorData { public class IpcSensorData {
@Excel(name = "时间")
private String insertTime ;
@Excel(name = "时间") @Excel(name = "时间")
private String stime ; private String stime ;
@Excel(name = "轴套区温度") @Excel(name = "轴套区温度")
@ -17,7 +19,8 @@ public class IpcSensorData {
public IpcSensorData() { public IpcSensorData() {
} }
public IpcSensorData(String stime, String ssat, String vx, String vy, String vz) { public IpcSensorData(String insertTime, String stime, String ssat, String vx, String vy, String vz) {
this.insertTime = insertTime;
this.stime = stime; this.stime = stime;
this.ssat = ssat; this.ssat = ssat;
this.vx = vx; this.vx = vx;
@ -25,6 +28,14 @@ public class IpcSensorData {
this.vz = vz; this.vz = vz;
} }
public String getInsertTime() {
return insertTime;
}
public void setInsertTime(String insertTime) {
this.insertTime = insertTime;
}
public String getStime() { public String getStime() {
return stime; return stime;
} }
@ -68,7 +79,8 @@ public class IpcSensorData {
@Override @Override
public String toString() { public String toString() {
return "IpcSensorData{" + return "IpcSensorData{" +
"stime='" + stime + '\'' + "insertTime='" + insertTime + '\'' +
", stime='" + stime + '\'' +
", ssat='" + ssat + '\'' + ", ssat='" + ssat + '\'' +
", vx='" + vx + '\'' + ", vx='" + vx + '\'' +
", vy='" + vy + '\'' + ", vy='" + vy + '\'' +

View File

@ -30,17 +30,13 @@ public class IpcDataLogServiceImpl implements IIpcDataLogService {
@Override @Override
public Map<String, Object> queryPlcDataLog(IpcQueryParams ipcQueryParams) { public Map<String, Object> queryPlcDataLog(IpcQueryParams ipcQueryParams) {
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
String tableName = IpcConstant.PLC_MEASUREMENT;
String part = ipcQueryParams.getPart();
String startTime = InfluxdbTimeUtil.cstToUtc(ipcQueryParams.getStartTime());
String endTime = InfluxdbTimeUtil.cstToUtc(ipcQueryParams.getEndTime());
// 查询总数 // 查询总数
int total = countInfluxdbList(IpcConstant.PLC_MEASUREMENT, ipcQueryParams.getPart(), ipcQueryParams.getIsAlarm(),startTime,endTime); int total = countInfluxdbList(IpcConstant.PLC_MEASUREMENT, ipcQueryParams.getPart(), ipcQueryParams.getIsAlarm(), ipcQueryParams.getStartTime(), ipcQueryParams.getEndTime());
// 查询数据 // 查询数据
List<Map<String, Object>> maps = selectAllDataByPart(IpcConstant.PLC_MEASUREMENT, ipcQueryParams.getPart(), ipcQueryParams.getIsAlarm(),startTime,endTime,ipcQueryParams.getPageSize(),ipcQueryParams.getPageNum()); List<Map<String, Object>> maps = selectAllDataByPart(IpcConstant.PLC_MEASUREMENT, ipcQueryParams.getPart(), ipcQueryParams.getIsAlarm(), ipcQueryParams.getStartTime(), ipcQueryParams.getEndTime(), ipcQueryParams.getPageSize(), ipcQueryParams.getPageNum());
List<IpcPlcData> list = JSON.parseArray(JSON.toJSONString(maps), IpcPlcData.class); List<IpcPlcData> list = JSON.parseArray(JSON.toJSONString(maps), IpcPlcData.class);
map.put("total",total); map.put("total", total);
map.put("rows",list); map.put("rows", list);
return map; return map;
} }
@ -51,12 +47,12 @@ public class IpcDataLogServiceImpl implements IIpcDataLogService {
public Map<String, Object> querySensorDataLog(IpcQueryParams ipcQueryParams) { public Map<String, Object> querySensorDataLog(IpcQueryParams ipcQueryParams) {
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
// 查询总数 // 查询总数
int total = countInfluxdbList(IpcConstant.SENSOR_MEASUREMENT, ipcQueryParams.getPart(), ipcQueryParams.getIsAlarm(),ipcQueryParams.getStartTime(), ipcQueryParams.getEndTime()); int total = countInfluxdbList(IpcConstant.SENSOR_MEASUREMENT, ipcQueryParams.getPart(), ipcQueryParams.getIsAlarm(), ipcQueryParams.getStartTime(), ipcQueryParams.getEndTime());
// 查询数据 // 查询数据
List<Map<String, Object>> maps = selectAllDataByPart(IpcConstant.SENSOR_MEASUREMENT, ipcQueryParams.getPart(), ipcQueryParams.getIsAlarm(),ipcQueryParams.getStartTime(), ipcQueryParams.getEndTime(),ipcQueryParams.getPageSize(),ipcQueryParams.getPageNum()); List<Map<String, Object>> maps = selectAllDataByPart(IpcConstant.SENSOR_MEASUREMENT, ipcQueryParams.getPart(), ipcQueryParams.getIsAlarm(), ipcQueryParams.getStartTime(), ipcQueryParams.getEndTime(), ipcQueryParams.getPageSize(), ipcQueryParams.getPageNum());
List<IpcPlcData> list = JSON.parseArray(JSON.toJSONString(maps), IpcPlcData.class); List<IpcSensorData> list = JSON.parseArray(JSON.toJSONString(maps), IpcSensorData.class);
map.put("total",total); map.put("total", total);
map.put("rows",list); map.put("rows", list);
return map; return map;
} }
@ -64,8 +60,8 @@ public class IpcDataLogServiceImpl implements IIpcDataLogService {
* 趋势数据获取 * 趋势数据获取
*/ */
@Override @Override
public Map<String,Object> getTendencyData(IpcQueryParams ipcQueryParams){ public Map<String, Object> getTendencyData(IpcQueryParams ipcQueryParams) {
Map<String,Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
String utcStartTime = InfluxdbTimeUtil.cstToUtc(ipcQueryParams.getStartTime()); String utcStartTime = InfluxdbTimeUtil.cstToUtc(ipcQueryParams.getStartTime());
String utcEndTime = InfluxdbTimeUtil.cstToUtc(ipcQueryParams.getEndTime()); String utcEndTime = InfluxdbTimeUtil.cstToUtc(ipcQueryParams.getEndTime());
@ -74,18 +70,18 @@ public class IpcDataLogServiceImpl implements IIpcDataLogService {
LocalDateTime etime = LocalDateTime.parse(ipcQueryParams.getEndTime()); LocalDateTime etime = LocalDateTime.parse(ipcQueryParams.getEndTime());
long intervalHours = ChronoUnit.HOURS.between(stime, etime); long intervalHours = ChronoUnit.HOURS.between(stime, etime);
List<Map<String, Object>> list = new ArrayList<>(); List<Map<String, Object>> list = new ArrayList<>();
if(intervalHours <= 6){//6小时内全查 if (intervalHours <= 6) {//6小时内全查
list = selectDataByParamNameandDate(IpcConstant.SENSOR_MEASUREMENT, ipcQueryParams.getPart(),ipcQueryParams.getParam(), utcStartTime, utcEndTime); list = selectDataByParamNameandDate(IpcConstant.SENSOR_MEASUREMENT, ipcQueryParams.getPart(), ipcQueryParams.getParam(), utcStartTime, utcEndTime);
}else if(intervalHours <= 7*24 ){//7天内每30s一个 } else if (intervalHours <= 7 * 24) {//7天内每30s一个
list = selectLongTimeDataByParamNameandDate(IpcConstant.SENSOR_MEASUREMENT, ipcQueryParams.getPart(),ipcQueryParams.getParam(), utcStartTime, utcEndTime, "30s"); list = selectLongTimeDataByParamNameandDate(IpcConstant.SENSOR_MEASUREMENT, ipcQueryParams.getPart(), ipcQueryParams.getParam(), utcStartTime, utcEndTime, "30s");
}else if(intervalHours <= 30*24 ){//30天内每2min一个 } else if (intervalHours <= 30 * 24) {//30天内每2min一个
list = selectLongTimeDataByParamNameandDate(IpcConstant.SENSOR_MEASUREMENT, ipcQueryParams.getPart(),ipcQueryParams.getParam(), utcStartTime, utcEndTime, "2m"); list = selectLongTimeDataByParamNameandDate(IpcConstant.SENSOR_MEASUREMENT, ipcQueryParams.getPart(), ipcQueryParams.getParam(), utcStartTime, utcEndTime, "2m");
}else if (intervalHours <= 90*24){//90天以上每4h一个 } else if (intervalHours <= 90 * 24) {//90天以上每4h一个
list = selectLongTimeDataByParamNameandDate(IpcConstant.SENSOR_MEASUREMENT, ipcQueryParams.getPart(),ipcQueryParams.getParam(), utcStartTime, utcEndTime, "6m"); list = selectLongTimeDataByParamNameandDate(IpcConstant.SENSOR_MEASUREMENT, ipcQueryParams.getPart(), ipcQueryParams.getParam(), utcStartTime, utcEndTime, "6m");
} }
Map<String, Object> resMap = new HashMap<>(); Map<String, Object> resMap = new HashMap<>();
if (list.size() == 0){ if (list.size() == 0) {
return null; return null;
} }
return map; return map;
@ -93,6 +89,7 @@ public class IpcDataLogServiceImpl implements IIpcDataLogService {
/** /**
* 根据字段名称和起止时间查询数据 * 根据字段名称和起止时间查询数据
*
* @param tableName 表名 * @param tableName 表名
* @param part 监测部位 * @param part 监测部位
* @param param 参数 * @param param 参数
@ -100,53 +97,61 @@ public class IpcDataLogServiceImpl implements IIpcDataLogService {
* @param endTime 结束时间 * @param endTime 结束时间
* @return 数据 * @return 数据
*/ */
private List<Map<String, Object>> selectDataByParamNameandDate(String tableName, String part,String param, String startTime, String endTime){ private List<Map<String, Object>> selectDataByParamNameandDate(String tableName, String part, String param, String startTime, String endTime) {
String sql = "select time," + param + " from " + tableName + " where part = '" + part + "' time >= '" + startTime + "' and time <= '" + endTime + "'"; String sql = "select time," + param + " from " + tableName + " where part = '" + part + "' time >= '" + startTime + "' and time <= '" + endTime + "'";
return influxDBService.queryResultProcess(influxDBService.query(sql)); return influxDBService.queryResultProcess(influxDBService.query(sql));
} }
/** /**
* 查询长时间数据每分钟取一条展示最长3个月 * 查询长时间数据每分钟取一条展示最长3个月
*
* @return * @return
*/ */
private List<Map<String, Object>> selectLongTimeDataByParamNameandDate(String tableName, String part,String param, String startTime, String endTime, String interval){ private List<Map<String, Object>> selectLongTimeDataByParamNameandDate(String tableName, String part, String param, String startTime, String endTime, String interval) {
String sql = "select time, mean(" + param + ") from " + tableName + " where part = '" + part + "' time >= '" + startTime + "' and time <= '" + endTime + "' group by time(" + interval +")"; String sql = "select time, mean(" + param + ") from " + tableName + " where part = '" + part + "' time >= '" + startTime + "' and time <= '" + endTime + "' group by time(" + interval + ")";
return influxDBService.queryResultProcess(influxDBService.query(sql)); return influxDBService.queryResultProcess(influxDBService.query(sql));
} }
/** /**
* 根据监测部位查询最近num条数据 * 根据监测部位查询最近num条数据
*
* @param tableName 表名 * @param tableName 表名
* @param part 监测部位 * @param part 监测部位
* @return 数据 * @return 数据
*/ */
private List<Map<String, Object>> selectAllDataByPart(String tableName, String part,String isAlarm,String startTime, String endTime, int pageSize, int pageNum){ private List<Map<String, Object>> selectAllDataByPart(String tableName, String part, String isAlarm, String startTime, String endTime, int pageSize, int pageNum) {
String sql = "select * from " + tableName + " where equ_id = '" + part + "'"; String sql = "select * from " + tableName + " where part = '" + part + "'";
if(isAlarm != null){ if (isAlarm != null) {
sql += " and isAlarm = '" + isAlarm + "'"; sql += " and isAlarm = '" + isAlarm + "'";
} }
if(startTime != null){ if (startTime != null) {
startTime = InfluxdbTimeUtil.cstToUtc(startTime);
sql += " and time >= '" + startTime + "'"; sql += " and time >= '" + startTime + "'";
} }
if(endTime != null){ if (endTime != null) {
endTime = InfluxdbTimeUtil.cstToUtc(endTime);
sql += " and time <= '" + endTime + "'"; sql += " and time <= '" + endTime + "'";
} }
sql += " order by time desc limit " + pageSize + " offset " +(pageNum - 1)*pageSize; sql += " order by time desc limit " + pageSize + " offset " + (pageNum - 1) * pageSize;
System.out.println(sql);
return influxDBService.queryResultProcess(influxDBService.query(sql)); return influxDBService.queryResultProcess(influxDBService.query(sql));
} }
private int countInfluxdbList(String tableName, String part,String isAlarm,String startTime, String endTime){ private int countInfluxdbList(String tableName, String part, String isAlarm, String startTime, String endTime) {
String sql = "select count(isAlarm) from " + tableName + " where part = '" + part + "'"; String sql = "select count(insertTime) from " + tableName + " where part = '" + part + "'";
if(isAlarm != null){ if (isAlarm != null) {
sql += " and isAlarm = '" + isAlarm + "'"; sql += " and isAlarm = '" + isAlarm + "'";
} }
if(startTime != null){ if (startTime != null) {
startTime = InfluxdbTimeUtil.cstToUtc(startTime);
sql += " and time >= '" + startTime + "'"; sql += " and time >= '" + startTime + "'";
} }
if(endTime != null){ if (endTime != null) {
endTime = InfluxdbTimeUtil.cstToUtc(endTime);
sql += " and time <= '" + endTime + "'"; sql += " and time <= '" + endTime + "'";
} }
List<Map<String, Object>> list = influxDBService.queryResultProcess(influxDBService.query(sql)); List<Map<String, Object>> list = influxDBService.queryResultProcess(influxDBService.query(sql));
return list.size() == 0 ? 0 : ((Double)list.get(0).get("count")).intValue(); System.out.println(sql);
return list.size() == 0 ? 0 : ((Double) list.get(0).get("count")).intValue();
} }
} }

View File

@ -39,11 +39,11 @@ public class IpcConstant {
/** /**
* plc数据表名 * plc数据表名
*/ */
public static final String PLC_MEASUREMENT = "tz_ipc_plc_monitor_data_list"; public static final String PLC_MEASUREMENT = "tz_ipc_plc_monitor_data_list1";
/** /**
* 温振传感器数据表名 * 温振传感器数据表名
*/ */
public static final String SENSOR_MEASUREMENT = "tz_ipc_sensor_monitor_data_list"; public static final String SENSOR_MEASUREMENT = "tz_ipc_sensor_monitor_data_list1";
/** /**
* 操作侧简写 * 操作侧简写
*/ */

View File

@ -5,7 +5,6 @@
ref="queryForm" ref="queryForm"
size="small" size="small"
:inline="true" :inline="true"
v-show="showSearch"
label-width="68px" label-width="68px"
> >
<el-form-item <el-form-item
@ -27,7 +26,7 @@
</el-form-item> </el-form-item>
<el-form-item <el-form-item
label="是否报警" label="是否报警"
prop="alarmLevel" prop="isAlarm"
> >
<el-select <el-select
v-model="queryParams.isAlarm" v-model="queryParams.isAlarm"
@ -57,6 +56,24 @@
> >
</el-date-picker> </el-date-picker>
</el-form-item> </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-button
icon="el-icon-download"
size="mini"
@click="exportData"
>导出</el-button>
</el-form-item>
</el-form> </el-form>
<!-- <div class="content-but"> <!-- <div class="content-but">
<div <div
@ -95,16 +112,18 @@
show-overflow-tooltip show-overflow-tooltip
/> />
<el-table-column <el-table-column
label="颗粒度4μm" label="运行状态"
align="center" align="center"
key="rstatus" key="rstatus"
prop="rstatus" prop="rstatus"
show-overflow-tooltip show-overflow-tooltip
> >
<template slot-scope="scope">
<dict-tag <dict-tag
:options="dict.type.running_status" :options="dict.type.running_status"
:value="scope.row.rstatus" :value="scope.row.rstatus"
/> />
</template>
</el-table-column> </el-table-column>
<el-table-column <el-table-column
label="颗粒度4μm" label="颗粒度4μm"
@ -155,13 +174,6 @@
prop="rot" prop="rot"
show-overflow-tooltip show-overflow-tooltip
/> />
<el-table-column
label="轴套区温度"
align="center"
key="ssat"
prop="ssat"
show-overflow-tooltip
/>
<el-table-column <el-table-column
label="进油压力" label="进油压力"
align="center" align="center"
@ -270,12 +282,41 @@ export default {
this.getMonitorPartList(); this.getMonitorPartList();
}, },
methods: { methods: {
/** 导出数据 */
exportData() {
if (this.total > 10000) {
this.$message({
showClose: true,
message: "数据量过大,请联系管理员进行导出!",
type: "warning",
});
} else {
this.download(
"/ipc/dataLog/plcExport",
{
...this.queryParams,
},
`传感器温振数据_${new Date().getTime()}.xlsx`
);
}
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.queryParams.part = this.monitorPartList[0].fieldValue;
this.handleQuery();
},
/** 查询监测部位列表 */ /** 查询监测部位列表 */
getMonitorPartList() { getMonitorPartList() {
getFields("monitor_part") getFields("monitor_part")
.then((res) => { .then((res) => {
this.monitorPartList = res.data; this.monitorPartList = res.data;
this.part = this.monitorPartList[0].fieldValue; this.queryParams.part = this.monitorPartList[0].fieldValue;
this.getList(); this.getList();
}) })
.catch((error) => { .catch((error) => {
@ -293,11 +334,26 @@ export default {
); );
} }
this.loading = true; this.loading = true;
getPlcDataLog(this.part).then((response) => { getPlcDataLog(this.queryParams).then((response) => {
this.dataList = response.data; this.dataList = response.data.rows;
this.total = response.data.total;
this.loading = false; this.loading = false;
}); });
}, },
dateToStr(date) {
var y = date.getFullYear();
var m = date.getMonth() + 1;
m = m < 10 ? "0" + m : m;
var d = date.getDate();
d = d < 10 ? "0" + d : d;
var h = date.getHours();
h = h < 10 ? "0" + h : h;
var minute = date.getMinutes();
minute = minute < 10 ? "0" + minute : minute;
var second = date.getSeconds();
second = second < 10 ? "0" + second : second;
return y + "-" + m + "-" + d + "T" + h + ":" + minute + ":" + second;
},
tableRowClassName({ row, rowIndex }) { tableRowClassName({ row, rowIndex }) {
if (rowIndex % 2 === 0) { if (rowIndex % 2 === 0) {
return "color-row"; return "color-row";