From 05af69865064e751f36f983adc119f663827f51d Mon Sep 17 00:00:00 2001 From: zhangjunwen Date: Sat, 12 Oct 2024 14:44:48 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=BE=E5=A4=87=E8=AF=A6=E6=83=85=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E6=8E=A5=E5=8F=A3=E5=AF=B9=E6=8E=A5=E4=B8=8E=E6=A0=B7?= =?UTF-8?q?=E5=BC=8F=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/query/DataQueryController.java | 7 ++ .../module/data/service/DataQueryService.java | 95 +++++++++++++++++++ .../data/service/IDataQueryService.java | 5 + 3 files changed, 107 insertions(+) diff --git a/imt-server/imt-module-data/imt-module-data-biz/src/main/java/com/inspur/module/data/controller/admin/query/DataQueryController.java b/imt-server/imt-module-data/imt-module-data-biz/src/main/java/com/inspur/module/data/controller/admin/query/DataQueryController.java index 6a808e7..5defbc0 100644 --- a/imt-server/imt-module-data/imt-module-data-biz/src/main/java/com/inspur/module/data/controller/admin/query/DataQueryController.java +++ b/imt-server/imt-module-data/imt-module-data-biz/src/main/java/com/inspur/module/data/controller/admin/query/DataQueryController.java @@ -117,6 +117,13 @@ public class DataQueryController { return success(resMap); } + @GetMapping("/getAllNewestData") + @Operation(summary = "获取所有最新数据") + public CommonResult> getAllNewestData(String equipId){ + Map resMap = dataQueryService.getAllNewestData(equipId); + return success(resMap); + } + @GetMapping("/export-current-excel") @Operation(summary = "导出机床电流传感器参数 Excel") @PreAuthorize("@ss.hasPermission('data:query:export')") diff --git a/imt-server/imt-module-data/imt-module-data-biz/src/main/java/com/inspur/module/data/service/DataQueryService.java b/imt-server/imt-module-data/imt-module-data-biz/src/main/java/com/inspur/module/data/service/DataQueryService.java index e269d5a..9aa46ab 100644 --- a/imt-server/imt-module-data/imt-module-data-biz/src/main/java/com/inspur/module/data/service/DataQueryService.java +++ b/imt-server/imt-module-data/imt-module-data-biz/src/main/java/com/inspur/module/data/service/DataQueryService.java @@ -154,6 +154,7 @@ public class DataQueryService implements IDataQueryService { /** * 查询当日最新一条数据 */ + @Override public Map getLatestData(String equipId, String tableName, String columns){ LocalDate now = LocalDate.now(); @@ -181,6 +182,100 @@ public class DataQueryService implements IDataQueryService { return dataList.get(0); } + /** + * 根据设备id查询设备最新一条数据 + */ + public Map getAllNewestData(String equipId){ + Map resultMap = new HashMap<>(); + resultMap.put("current", getNewestCurrentData(equipId)); + resultMap.put("hy", getNewestPressData(equipId)); + resultMap.put("temp", getNewestTempData(equipId)); + resultMap.put("aclr", getNewestVibrData(equipId)); + resultMap.put("fanuc", getNewestWorkData(equipId)); + return resultMap; + } + + /** + * 最新的一条电流数据 + * @param equipId 设备id + * @return 电流数据 + */ + private Map getNewestCurrentData(String equipId){ + String tableName = "gateway_current_data"; + String columns = "chip_removal_1,chip_removal_2"; + List> dataList = selectOneDataByColumnsandDate(equipId, tableName, columns, null, null, "desc"); + if (CollUtil.isEmpty(dataList)) { + String[] cols = columns.split(","); + Map resMap = new HashMap<>(); + for (String col : cols) { + resMap.put(col, 0.0); + } + return resMap; + } + return dataList.get(0); + } + + private Map getNewestPressData(String equipId){ + String tableName = "gateway_hy_data"; + String columns = "hy_1,hy_2,hy_3"; + List> dataList = selectOneDataByColumnsandDate(equipId, tableName, columns, null, null, "desc"); + if (CollUtil.isEmpty(dataList)) { + String[] cols = columns.split(","); + Map resMap = new HashMap<>(); + for (String col : cols) { + resMap.put(col, 0.0); + } + return resMap; + } + return dataList.get(0); + } + + private Map getNewestTempData(String equipId){ + String tableName = "gateway_temp_data"; + String columns = "cr1_temp,cr2_temp,x0_temp,xp_temp,xn_temp,y0_temp,yp_temp,yn_temp,z0_temp,zp_temp,zn_temp"; + List> dataList = selectOneDataByColumnsandDate(equipId, tableName, columns, null, null, "desc"); + if (CollUtil.isEmpty(dataList)) { + String[] cols = columns.split(","); + Map resMap = new HashMap<>(); + for (String col : cols) { + resMap.put(col, 0.0); + } + return resMap; + } + return dataList.get(0); + } + + private Map getNewestVibrData(String equipId){ + String tableName = "gateway_aclr_data"; + String columns = "x_aclr_rms,x_speed_rms,x_dis_rms,y_aclr_rms,y_speed_rms,y_dis_rms,z_aclr_rms,z_speed_rms,z_dis_rms," + + "x_aclr_peak,x_speed_peak,x_dis_peak,y_aclr_peak,y_speed_peak,y_dis_peak,z_aclr_peak,z_speed_peak,z_dis_peak"; + List> dataList = selectOneDataByColumnsandDate(equipId, tableName, columns, null, null, "desc"); + if (CollUtil.isEmpty(dataList)) { + String[] cols = columns.split(","); + Map resMap = new HashMap<>(); + for (String col : cols) { + resMap.put(col, 0.0); + } + return resMap; + } + return dataList.get(0); + } + + private Map getNewestWorkData(String equipId){ + String tableName = "gateway_fanuc_data"; + String columns = "power_time,process_num,total_process,work_time"; + List> dataList = selectOneDataByColumnsandDate(equipId, tableName, columns, null, null, "desc"); + if (CollUtil.isEmpty(dataList)) { + String[] cols = columns.split(","); + Map resMap = new HashMap<>(); + for (String col : cols) { + resMap.put(col, 0.0); + } + return resMap; + } + return dataList.get(0); + } + public Map getAllData2ChartData(String equipId, String tableName, String columns, String startTime, String endTime) { LocalDateTime stime = DateUtils.tranUTCtoLocalDateTime(startTime); LocalDateTime etime = DateUtils.tranUTCtoLocalDateTime(endTime); diff --git a/imt-server/imt-module-data/imt-module-data-biz/src/main/java/com/inspur/module/data/service/IDataQueryService.java b/imt-server/imt-module-data/imt-module-data-biz/src/main/java/com/inspur/module/data/service/IDataQueryService.java index 130f9d6..d8492f4 100644 --- a/imt-server/imt-module-data/imt-module-data-biz/src/main/java/com/inspur/module/data/service/IDataQueryService.java +++ b/imt-server/imt-module-data/imt-module-data-biz/src/main/java/com/inspur/module/data/service/IDataQueryService.java @@ -56,4 +56,9 @@ public interface IDataQueryService { * 查询当日最旧一条数据 */ public Map getOldestData(String equipId, String tableName, String columns); + + /** + * 根据设备id查询设备最新一条数据 + */ + public Map getAllNewestData(String equipId); }