3ab28ffb 张雷

奥体项目时间粒度修改

1 个父辈 e1e02a5c
......@@ -6,6 +6,7 @@ import com.skua.modules.business.service.ISynthesizeService;
import com.skua.modules.business.vo.AlarmParams;
import com.skua.modules.business.vo.EchartResult;
import com.skua.modules.business.vo.InputQueryParams;
import com.skua.modules.business.vo.ReportParams;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
......@@ -142,10 +143,10 @@ public class OlympicCenterController {
@ApiOperation(value="获取趋势图new", notes="获取趋势图new")
@GetMapping(value = "/getHistoryTrends")
public Result<List<EchartResult>> getHistoryTrends(String equipId,String type){
public Result<List<EchartResult>> getHistoryTrends(ReportParams reportParams){
Result<List<EchartResult>> result = new Result<List<EchartResult>>();
List<EchartResult> list = new ArrayList<EchartResult>();
list = olympicCenterService.getHistoryTrends(equipId,type);
list = olympicCenterService.getHistoryTrends(reportParams);
result.setResult(list);
result.setSuccess(true);
return result;
......
......@@ -3,6 +3,7 @@ package com.skua.modules.business.service;
import com.skua.modules.business.vo.AlarmParams;
import com.skua.modules.business.vo.EchartResult;
import com.skua.modules.business.vo.InputQueryParams;
import com.skua.modules.business.vo.ReportParams;
import java.util.List;
import java.util.Map;
......@@ -26,7 +27,7 @@ public interface IOlympicCenterService {
Map<String, Object> getRealTimeDataNew(String sourceType);
List<EchartResult> getHistoryTrends(String equipId, String type);
List<EchartResult> getHistoryTrends(ReportParams reportParams);
Map<String, Object> getRealTimeDataToUENew();
......
......@@ -5,10 +5,7 @@ import com.skua.core.service.IFactoryInfoService;
import com.skua.modules.business.entity.WhatStructData;
import com.skua.modules.business.mapper.WhatStructDataMapper;
import com.skua.modules.business.service.IOlympicCenterService;
import com.skua.modules.business.vo.AlarmParams;
import com.skua.modules.business.vo.EchartResult;
import com.skua.modules.business.vo.InputQueryParams;
import com.skua.modules.business.vo.TextResult;
import com.skua.modules.business.vo.*;
import com.skua.modules.monitor.service.IFmPgQueryService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -928,9 +925,12 @@ public class OlympicCenterServiceImpl implements IOlympicCenterService {
}
@Override
public List<EchartResult> getHistoryTrends(String equipId, String type) {
public List<EchartResult> getHistoryTrends(ReportParams reportParams) {
List<EchartResult> list = new ArrayList<>();
List<WhatStructData> wList = whatStructDataMapper.getDataList(equipId);
List<WhatStructData> wList = whatStructDataMapper.getDataList(reportParams.getEquipId());
String type = reportParams.getType();
String start = reportParams.getStartDate() + " 00:00:00";
String end = reportParams.getEndDate() + " 23:59:59";
String pgField = "";
if(wList.size() == 0){
return list;
......@@ -939,12 +939,14 @@ public class OlympicCenterServiceImpl implements IOlympicCenterService {
pgField = pgField +","+whatStructData.getMonitorId();
}
}
if(reportParams.getStartDate()==null||reportParams.getEndDate()==null){
Calendar cal = Calendar.getInstance();
cal.add(Calendar.DATE, -7);
String startDate = new SimpleDateFormat("yyyy-MM-dd").format(cal.getTime());
String start = startDate + " 00:00:00";
start = startDate + " 00:00:00";
String endDate = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
String end = endDate + " 23:59:59";
end = endDate + " 23:59:59";
}
List<Map<String, Object>> dataList = factoryInfoService.queryReportData(AT_ID, pgField, start, end,"hour");
if(dataList.size()>0){
for (Map<String, Object> map:dataList) {
......@@ -1922,16 +1924,16 @@ public class OlympicCenterServiceImpl implements IOlympicCenterService {
}
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date now = new Date();
// System.out.println("当前时间为:" + dateFormat.format(now));
Date before = new Date(now.getTime() - minute * 60 * 1000);
// System.out.println("之前的时间为:" + dateFormat.format(before));
List<Map<String, Object>> list = new ArrayList<>();
JdbcTemplate alarmDB = (JdbcTemplate) SpringContextUtils.getBean("mysql-alarm");
list = alarmDB.queryForList("select alarm_content as alarmContent,alarm_param_code as alarmParamCode " +
list = alarmDB.queryForList("select max(record_time) as recordTime,alarm_param_name as alarmParamName," +
" alarm_content as alarmContent,alarm_param_code as alarmParamCode " +
" from alert_record_history " +
" where handle_status = 0 " +
" and alarm_param_code like '"+AT_ID+"_%' " +
" and record_time between '"+dateFormat.format(before)+"' and '"+dateFormat.format(now)+"' " +
" GROUP BY alarm_param_name " +
" ORDER BY record_time");
return list;
}
......
package com.skua.modules.business.vo;
import lombok.Data;
@Data
public class ReportParams {
private String equipId;
private String type;
private String startDate;
private String endDate;
}
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!