Merge branch 'zjw'
This commit is contained in:
commit
67d28f7018
@ -150,7 +150,7 @@ public class DateUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static String tranUTC2LocalDateTime(String utcTimeString) throws ParseException {
|
public static String tranUTC2LocalDateTime(String utcTimeString) throws ParseException {
|
||||||
SimpleDateFormat utcFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
|
SimpleDateFormat utcFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
|
||||||
utcFormat.setTimeZone(TimeZone.getTimeZone("UTC")); // 设置UTC时区
|
utcFormat.setTimeZone(TimeZone.getTimeZone("UTC")); // 设置UTC时区
|
||||||
Date utcDate = utcFormat.parse(utcTimeString); // 解析UTC时间
|
Date utcDate = utcFormat.parse(utcTimeString); // 解析UTC时间
|
||||||
SimpleDateFormat localFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
SimpleDateFormat localFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||||
|
@ -1,7 +1,15 @@
|
|||||||
package com.inspur.module.data.controller.admin.query;
|
package com.inspur.module.data.controller.admin.query;
|
||||||
|
|
||||||
|
import com.inspur.framework.apilog.core.annotation.ApiAccessLog;
|
||||||
import com.inspur.framework.common.pojo.CommonResult;
|
import com.inspur.framework.common.pojo.CommonResult;
|
||||||
|
import com.inspur.framework.common.pojo.PageParam;
|
||||||
|
import com.inspur.framework.common.util.object.BeanUtils;
|
||||||
|
import com.inspur.framework.excel.core.util.ExcelUtils;
|
||||||
|
import com.inspur.module.data.controller.admin.query.vo.CurrentDataRespVO;
|
||||||
import com.inspur.module.data.service.IDataQueryService;
|
import com.inspur.module.data.service.IDataQueryService;
|
||||||
|
import com.inspur.module.system.controller.admin.alarm.vo.AlarmDataPageReqVO;
|
||||||
|
import com.inspur.module.system.controller.admin.alarm.vo.AlarmDataRespVO;
|
||||||
|
import com.inspur.module.system.dal.dataobject.alarm.AlarmDataDO;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
@ -9,10 +17,15 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import javax.validation.Valid;
|
||||||
|
import java.io.IOException;
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static com.inspur.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
|
||||||
import static com.inspur.framework.common.pojo.CommonResult.success;
|
import static com.inspur.framework.common.pojo.CommonResult.success;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -30,10 +43,10 @@ public class DataQueryController {
|
|||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
@Operation(summary = "获取/查询网关数据列表")
|
@Operation(summary = "获取/查询网关数据列表")
|
||||||
@PreAuthorize("@ss.hasPermission('data:query:list')")
|
@PreAuthorize("@ss.hasPermission('data:query:list')")
|
||||||
public CommonResult<Map<String, Object>> getData(String equipId, String startTime, String endTime, Integer pageSize, Integer pageNum){
|
public CommonResult<Map<String, Object>> getData(String equipId,String tableName, String startTime, String endTime, Integer pageSize, Integer pageNum){
|
||||||
Map<String,Object> resMap = new HashMap<>();
|
Map<String,Object> resMap = new HashMap<>();
|
||||||
try {
|
try {
|
||||||
resMap = dataQueryService.selectDataListByPages(equipId,startTime,endTime,pageSize,pageNum);
|
resMap = dataQueryService.selectDataListByPages(equipId,tableName,startTime,endTime,pageSize,pageNum);
|
||||||
} catch (ParseException e) {
|
} catch (ParseException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return CommonResult.error(800,"时间格式错误");
|
return CommonResult.error(800,"时间格式错误");
|
||||||
@ -41,4 +54,16 @@ public class DataQueryController {
|
|||||||
return success(resMap);
|
return success(resMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/export-current-excel")
|
||||||
|
@Operation(summary = "导出机床电流传感器参数 Excel")
|
||||||
|
@PreAuthorize("@ss.hasPermission('data:query:export')")
|
||||||
|
@ApiAccessLog(operateType = EXPORT)
|
||||||
|
public void exportCurrentDataExcel(String equipId,String tableName, String startTime, String endTime,
|
||||||
|
HttpServletResponse response) throws IOException, ParseException {
|
||||||
|
List<CurrentDataRespVO> list = (List<CurrentDataRespVO>)dataQueryService.selectDataListByPages(equipId,tableName,startTime,endTime,null,null).get("list");
|
||||||
|
// 导出 Excel
|
||||||
|
ExcelUtils.write(response, "机床电流参数报警记录.xls", "电流数据", CurrentDataRespVO.class,
|
||||||
|
BeanUtils.toBean(list, CurrentDataRespVO.class));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,23 @@
|
|||||||
|
package com.inspur.module.data.controller.admin.query.vo;
|
||||||
|
|
||||||
|
import com.alibaba.excel.annotation.ExcelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 电流传感器数据返回对象
|
||||||
|
* @Author zhangjunwen
|
||||||
|
* @create 2024/9/5
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class CurrentDataRespVO {
|
||||||
|
|
||||||
|
@ExcelProperty("时间")
|
||||||
|
private String time;
|
||||||
|
|
||||||
|
@ExcelProperty("x轴推屑电流")
|
||||||
|
private String x_push_temp;
|
||||||
|
|
||||||
|
@ExcelProperty("y轴推屑电流")
|
||||||
|
private String y_push_temp;
|
||||||
|
|
||||||
|
}
|
@ -24,32 +24,53 @@ public class DataQueryService implements IDataQueryService{
|
|||||||
private InfluxDBService influxDBService;
|
private InfluxDBService influxDBService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> selectDataListByPages(String equipId,String startTime,String endTime, Integer pageSize, Integer pageNum) throws ParseException {
|
public Map<String, Object> selectDataListByPages(String equipId,String tableName,String startTime,String endTime, Integer pageSize, Integer pageNum){
|
||||||
Map<String, Object> resMap = new HashMap<>();
|
Map<String, Object> resMap = new HashMap<>();
|
||||||
//TODO 分页查找条数,根据设备id、表名、时间范围、页码、每页条数
|
//TODO 分页查找条数,根据设备id、表名、时间范围、页码、每页条数
|
||||||
List<Map<String, Object>> dataList = queryDataByTime("data", equipId, startTime, endTime, pageNum, pageSize);
|
List<Map<String, Object>> dataList = queryDataByTime(tableName, null, startTime, endTime, pageNum, pageSize);
|
||||||
|
dataList.forEach(map -> {
|
||||||
|
try {
|
||||||
|
map.put("time", DateUtils.tranUTC2LocalDateTime(map.get("time").toString()));
|
||||||
|
} catch (ParseException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
});
|
||||||
//TODO 时间需要将查询到的UTC时间转为系统时间(北京时间)
|
//TODO 时间需要将查询到的UTC时间转为系统时间(北京时间)
|
||||||
DateUtils.tranUTC2LocalDateTime("2024-08-28T08:00:00Z");
|
// DateUtils.tranUTC2LocalDateTime("2024-08-28T08:00:00Z");
|
||||||
//TODO 查询数据总条数
|
//TODO 查询数据总条数
|
||||||
long total = countDataList("data", "value", equipId, startTime, endTime);
|
long total = countDataList(tableName, "x_push_temp", null, startTime, endTime);
|
||||||
resMap.put("data", dataList);
|
resMap.put("list", dataList);
|
||||||
resMap.put("total", total);
|
resMap.put("total", total);
|
||||||
return resMap;
|
return resMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<Map<String, Object>> queryDataByTime(String tableName, String equipId, String beginTime, String endTime, Integer pageNum, Integer pageSize) {
|
private List<Map<String, Object>> queryDataByTime(String tableName, String equipId, String beginTime, String endTime, Integer pageNum, Integer pageSize) {
|
||||||
StringBuilder sql = new StringBuilder("select * from ")
|
StringBuilder sql = new StringBuilder("select * from ")
|
||||||
.append("\"").append(tableName).append("\"")
|
.append("\"").append(tableName).append("\"");
|
||||||
.append(" where equip_id = '").append(equipId).append("'");
|
if(equipId != null){
|
||||||
|
sql.append(" where equip_id = '").append(equipId).append("'");
|
||||||
|
}
|
||||||
if(beginTime != null){
|
if(beginTime != null){
|
||||||
sql.append(" and time >= '").append(beginTime).append("'");
|
if(!sql.toString().contains("where")){
|
||||||
|
sql.append(" where");
|
||||||
|
}else{
|
||||||
|
sql.append(" and");
|
||||||
|
}
|
||||||
|
sql.append(" time >= '").append(beginTime).append("'");
|
||||||
}
|
}
|
||||||
if(endTime != null){
|
if(endTime != null){
|
||||||
sql.append(" and time <= '").append(endTime).append("'");
|
if(!sql.toString().contains("where")){
|
||||||
|
sql.append(" where");
|
||||||
|
}else{
|
||||||
|
sql.append(" and");
|
||||||
}
|
}
|
||||||
|
sql.append(" time <= '").append(endTime).append("'");
|
||||||
|
}
|
||||||
|
if(pageNum != null || pageSize != null) {
|
||||||
sql.append(" order by time desc ")
|
sql.append(" order by time desc ")
|
||||||
.append(" limit ").append(pageSize)
|
.append(" limit ").append(pageSize)
|
||||||
.append(" offset ").append((pageNum - 1) * pageSize);
|
.append(" offset ").append((pageNum - 1) * pageSize);
|
||||||
|
}
|
||||||
// .append(" tz('Asia/Shanghai')");
|
// .append(" tz('Asia/Shanghai')");
|
||||||
|
|
||||||
return influxDBService.queryResultProcess(influxDBService.query(sql.toString()));
|
return influxDBService.queryResultProcess(influxDBService.query(sql.toString()));
|
||||||
@ -57,13 +78,25 @@ public class DataQueryService implements IDataQueryService{
|
|||||||
|
|
||||||
private long countDataList(String tableName,String field, String equipId, String beginTime, String endTime){
|
private long countDataList(String tableName,String field, String equipId, String beginTime, String endTime){
|
||||||
StringBuilder sql = new StringBuilder("select count(").append(field).append(") from ")
|
StringBuilder sql = new StringBuilder("select count(").append(field).append(") from ")
|
||||||
.append("\"").append(tableName).append("\"")
|
.append("\"").append(tableName).append("\"");
|
||||||
.append(" where equip_id = '").append(equipId).append("'");
|
if(equipId != null){
|
||||||
|
sql.append(" where equip_id = '").append(equipId).append("'");
|
||||||
|
}
|
||||||
if(beginTime != null){
|
if(beginTime != null){
|
||||||
sql.append(" and time >= '").append(beginTime).append("'");
|
if(!sql.toString().contains("where")){
|
||||||
|
sql.append(" where");
|
||||||
|
}else{
|
||||||
|
sql.append(" and");
|
||||||
|
}
|
||||||
|
sql.append(" time >= '").append(beginTime).append("'");
|
||||||
}
|
}
|
||||||
if(endTime != null){
|
if(endTime != null){
|
||||||
sql.append(" and time <= '").append(endTime).append("'");
|
if(!sql.toString().contains("where")){
|
||||||
|
sql.append(" where");
|
||||||
|
}else{
|
||||||
|
sql.append(" and");
|
||||||
|
}
|
||||||
|
sql.append(" time <= '").append(endTime).append("'");
|
||||||
}
|
}
|
||||||
return influxDBService.countResultProcess(influxDBService.query(sql.toString()));
|
return influxDBService.countResultProcess(influxDBService.query(sql.toString()));
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,6 @@ public interface IDataQueryService {
|
|||||||
* @param pageSize 每页大小
|
* @param pageSize 每页大小
|
||||||
* @param pageNum 当前页码
|
* @param pageNum 当前页码
|
||||||
*/
|
*/
|
||||||
Map<String, Object> selectDataListByPages(String equipId,String startTime,String endTime,Integer pageSize,Integer pageNum) throws ParseException;
|
Map<String, Object> selectDataListByPages(String equipId,String tableName,String startTime,String endTime,Integer pageSize,Integer pageNum) throws ParseException;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
20
imt-ui/src/api/data/query.js
Normal file
20
imt-ui/src/api/data/query.js
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
import request from "@/utils/request";
|
||||||
|
|
||||||
|
// 根据时间查询超压底缸数据
|
||||||
|
export function getDataList(params) {
|
||||||
|
return request({
|
||||||
|
url: "/data/query/list",
|
||||||
|
method: "get",
|
||||||
|
params: params,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 导出机床电流参数报警记录 Excel
|
||||||
|
export function exportCurrentDataExcel(params) {
|
||||||
|
return request({
|
||||||
|
url: "/data/query/export-current-excel",
|
||||||
|
method: "get",
|
||||||
|
params,
|
||||||
|
responseType: "blob",
|
||||||
|
});
|
||||||
|
}
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user