设备详情数据接口对接与样式更新

This commit is contained in:
zhangjunwen 2024-10-12 14:44:48 +08:00
parent f33f54e75d
commit 05af698650
3 changed files with 107 additions and 0 deletions

View File

@ -117,6 +117,13 @@ public class DataQueryController {
return success(resMap);
}
@GetMapping("/getAllNewestData")
@Operation(summary = "获取所有最新数据")
public CommonResult<Map<String, Object>> getAllNewestData(String equipId){
Map<String, Object> resMap = dataQueryService.getAllNewestData(equipId);
return success(resMap);
}
@GetMapping("/export-current-excel")
@Operation(summary = "导出机床电流传感器参数 Excel")
@PreAuthorize("@ss.hasPermission('data:query:export')")

View File

@ -154,6 +154,7 @@ public class DataQueryService implements IDataQueryService {
/**
* 查询当日最新一条数据
*/
@Override
public Map<String, Object> 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<String, Object> getAllNewestData(String equipId){
Map<String,Object> 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<String, Object> getNewestCurrentData(String equipId){
String tableName = "gateway_current_data";
String columns = "chip_removal_1,chip_removal_2";
List<Map<String, Object>> dataList = selectOneDataByColumnsandDate(equipId, tableName, columns, null, null, "desc");
if (CollUtil.isEmpty(dataList)) {
String[] cols = columns.split(",");
Map<String, Object> resMap = new HashMap<>();
for (String col : cols) {
resMap.put(col, 0.0);
}
return resMap;
}
return dataList.get(0);
}
private Map<String, Object> getNewestPressData(String equipId){
String tableName = "gateway_hy_data";
String columns = "hy_1,hy_2,hy_3";
List<Map<String, Object>> dataList = selectOneDataByColumnsandDate(equipId, tableName, columns, null, null, "desc");
if (CollUtil.isEmpty(dataList)) {
String[] cols = columns.split(",");
Map<String, Object> resMap = new HashMap<>();
for (String col : cols) {
resMap.put(col, 0.0);
}
return resMap;
}
return dataList.get(0);
}
private Map<String, Object> 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<Map<String, Object>> dataList = selectOneDataByColumnsandDate(equipId, tableName, columns, null, null, "desc");
if (CollUtil.isEmpty(dataList)) {
String[] cols = columns.split(",");
Map<String, Object> resMap = new HashMap<>();
for (String col : cols) {
resMap.put(col, 0.0);
}
return resMap;
}
return dataList.get(0);
}
private Map<String, Object> 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<Map<String, Object>> dataList = selectOneDataByColumnsandDate(equipId, tableName, columns, null, null, "desc");
if (CollUtil.isEmpty(dataList)) {
String[] cols = columns.split(",");
Map<String, Object> resMap = new HashMap<>();
for (String col : cols) {
resMap.put(col, 0.0);
}
return resMap;
}
return dataList.get(0);
}
private Map<String, Object> getNewestWorkData(String equipId){
String tableName = "gateway_fanuc_data";
String columns = "power_time,process_num,total_process,work_time";
List<Map<String, Object>> dataList = selectOneDataByColumnsandDate(equipId, tableName, columns, null, null, "desc");
if (CollUtil.isEmpty(dataList)) {
String[] cols = columns.split(",");
Map<String, Object> resMap = new HashMap<>();
for (String col : cols) {
resMap.put(col, 0.0);
}
return resMap;
}
return dataList.get(0);
}
public Map<String, Object> getAllData2ChartData(String equipId, String tableName, String columns, String startTime, String endTime) {
LocalDateTime stime = DateUtils.tranUTCtoLocalDateTime(startTime);
LocalDateTime etime = DateUtils.tranUTCtoLocalDateTime(endTime);

View File

@ -56,4 +56,9 @@ public interface IDataQueryService {
* 查询当日最旧一条数据
*/
public Map<String, Object> getOldestData(String equipId, String tableName, String columns);
/**
* 根据设备id查询设备最新一条数据
*/
public Map<String, Object> getAllNewestData(String equipId);
}