42db58e6 张雷

奥体项目接口开发

1 个父辈 5b848fa0
......@@ -31,19 +31,40 @@ public class OlympicCenterController {
@ApiOperation(value="获取整体实时数据", notes="获取整体实时数据")
@GetMapping(value = "/getRealTimeData")
public Result<Map<String,Object>> getRealTimeData(){
public Result<Map<String,Object>> getRealTimeData(String sourceType){
Result<Map<String,Object>> result = new Result<Map<String,Object>>();
Map<String,Object> map = olympicCenterService.getRealTimeData();
Map<String,Object> map = olympicCenterService.getRealTimeData(sourceType);
result.setResult(map);
result.setSuccess(true);
return result;
}
@ApiOperation(value="获取指标历史趋势曲线", notes="获取指标历史趋势曲线")
/**
* 获取泵站指标历史趋势曲线
* @param field ssll:瞬时流量 ljll:累计流量 rll:日流量
* @param sourceType feed:给水泵房 hot:热水锅炉站 fire:消防泵站
* @return
*/
@ApiOperation(value="获取泵站指标历史趋势曲线", notes="获取泵站指标历史趋势曲线")
@GetMapping(value = "/getHistoryData")
public Result<Map<String,Object>> getHistoryData(String field){
public Result<List<EchartResult>> getHistoryData(String field,String sourceType){
Result<List<EchartResult>> result = new Result<List<EchartResult>>();
List<EchartResult> list = olympicCenterService.getHistoryData(field,sourceType);
result.setResult(list);
result.setSuccess(true);
return result;
}
/**
* 获取泵站指标实时数据
* @param sourceType feed:给水泵房 hot:热水锅炉站 fire:消防泵站
* @return
*/
@ApiOperation(value="获取泵站指标实时数据", notes="获取泵站指标实时数据")
@GetMapping(value = "/getBzRealTimeData")
public Result<Map<String,Object>> getBzRealTimeData(String sourceType){
Result<Map<String,Object>> result = new Result<Map<String,Object>>();
Map<String,Object> map = olympicCenterService.getHistoryData(field);
Map<String,Object> map = olympicCenterService.getBzRealTimeData(sourceType);
result.setResult(map);
result.setSuccess(true);
return result;
......@@ -60,12 +81,18 @@ public class OlympicCenterController {
return result;
}
@ApiOperation(value="获取压力趋势图", notes="获取压力趋势图")
/**
* 获取趋势图
* @param equipId
* @param type p:压力 f:流量计 t:温度计
* @return
*/
@ApiOperation(value="获取趋势图", notes="获取趋势图")
@GetMapping(value = "/getPressureChart")
public Result<List<EchartResult>> getPressureChart(String equipId){
public Result<List<EchartResult>> getPressureChart(String equipId,String type){
Result<List<EchartResult>> result = new Result<List<EchartResult>>();
List<EchartResult> list = new ArrayList<EchartResult>();
list = olympicCenterService.getPressureChart(equipId);
list = olympicCenterService.getPressureChart(equipId,type);
result.setResult(list);
result.setSuccess(true);
return result;
......
......@@ -10,11 +10,13 @@ import java.util.Map;
*/
public interface IOlympicCenterService {
Map<String,Object> getRealTimeData();
Map<String,Object> getRealTimeData(String sourceType);
Map<String, Object> getHistoryData(String field);
List<EchartResult> getHistoryData(String field,String sourceType);
List<EchartResult> getWaterChart(String sourceType, String dateType, String start, String end);
List<EchartResult> getPressureChart(String equipId);
List<EchartResult> getPressureChart(String equipId,String type);
Map<String, Object> getBzRealTimeData(String sourceType);
}
......
......@@ -3,6 +3,7 @@ package com.skua.modules.business.service.impl;
import com.skua.core.service.IPgQueryService;
import com.skua.modules.business.service.IOlympicCenterService;
import com.skua.modules.business.vo.EchartResult;
import com.skua.modules.business.vo.TextResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -15,23 +16,120 @@ import java.util.*;
@Service
public class OlympicCenterServiceImpl implements IOlympicCenterService {
@Autowired
private IPgQueryService pgQueryService;
// @Autowired
// private IPgQueryService pgQueryService;
@Override
public Map<String,Object> getRealTimeData() {
public Map<String,Object> getRealTimeData(String sourceType) {
Map<String,Object> map = new HashMap<>();
String jsFields = "BKYHWSC_JS_Tag2,BKYHWSC_JS_Tag3";
List<Map<String, Object>> monitorList = pgQueryService.queryFactoryMonitorFromRealTimeData("",jsFields);
if(monitorList.size()==1){
map = monitorList.get(0);
// String jsFields = "BKYHWSC_JS_Tag2,BKYHWSC_JS_Tag3";
// List<Map<String, Object>> monitorList = pgQueryService.queryFactoryMonitorFromRealTimeData("",jsFields);
// if(monitorList.size()==1){
// map = monitorList.get(0);
// }
List<TextResult> pList = new ArrayList<>();
List<TextResult> fList = new ArrayList<>();
List<TextResult> wList = new ArrayList<>();
if("feed".equals(sourceType)){//压力14流量8
for (int i = 0; i < 14; i++) {
TextResult textResult = new TextResult();
textResult.setTitle("压力表"+(i+1));
if(i==8){
textResult.setValue("0.41");
}else{
textResult.setValue("0.00");
}
pList.add(i,textResult);
}
for (int j = 0; j < 8; j++) {
TextResult textResult = new TextResult();
textResult.setTitle("流量计"+(j+1));
textResult.setValue("0.00");
fList.add(j,textResult);
}
map.put("pressure",pList);
map.put("flow",fList);
}else if("hot".equals(sourceType)){//压力10流量4温度4;
for (int i = 0; i < 10; i++) {
TextResult textResult = new TextResult();
textResult.setTitle("压力表"+(i+1));
textResult.setValue("0.00");
pList.add(i,textResult);
}
for (int j = 0; j < 4; j++) {
TextResult textResult = new TextResult();
textResult.setTitle("流量计"+(j+1));
textResult.setValue("0.00");
fList.add(j,textResult);
}
for (int k = 0; k < 4; k++) {
TextResult textResult = new TextResult();
textResult.setTitle("温度计"+(k+1));
textResult.setValue("--");
wList.add(k,textResult);
}
map.put("pressure",pList);
map.put("flow",fList);
map.put("temperature",wList);
}else if("fire".equals(sourceType)){//压力9流量2.
for (int i = 0; i < 9; i++) {
TextResult textResult = new TextResult();
textResult.setTitle("压力表"+(i+1));
textResult.setValue("0.00");
pList.add(i,textResult);
}
for (int j = 0; j < 2; j++) {
TextResult textResult = new TextResult();
textResult.setTitle("流量计"+(j+1));
textResult.setValue("0.00");
fList.add(j,textResult);
}
map.put("pressure",pList);
map.put("flow",fList);
}else{
for (int i = 0; i < 33; i++) {
TextResult textResult = new TextResult();
textResult.setTitle("压力表"+(i+1));
if(i==8){
textResult.setValue("0.41");
}else{
textResult.setValue("0.00");
}
pList.add(i,textResult);
}
for (int j = 0; j < 14; j++) {
TextResult textResult = new TextResult();
textResult.setTitle("流量计"+(j+1));
textResult.setValue("0.00");
fList.add(j,textResult);
}
for (int k = 0; k < 4; k++) {
TextResult textResult = new TextResult();
textResult.setTitle("温度计"+(k+1));
textResult.setValue("--");
wList.add(k,textResult);
}
map.put("pressure",pList);
map.put("flow",fList);
map.put("temperature",wList);
}
return map;
}
@Override
public Map<String, Object> getHistoryData(String field) {
return null;
public List<EchartResult> getHistoryData(String field,String sourceType) {
List<EchartResult> list = new ArrayList<>();
for (int i = 0; i < 24; i++) {
Calendar date = Calendar.getInstance();
date.add(Calendar.HOUR, i-24);
String newHour = new SimpleDateFormat("HH:00").format(date.getTime());
EchartResult echartResult = new EchartResult();
echartResult.setName(newHour);
echartResult.setValue(formatDouble(getRandom(0.00,1.00)).toString());
echartResult.setSeries(field);
list.add(echartResult);
}
return list;
}
@Override
......@@ -61,7 +159,7 @@ public class OlympicCenterServiceImpl implements IOlympicCenterService {
}
@Override
public List<EchartResult> getPressureChart(String equipId) {
public List<EchartResult> getPressureChart(String equipId,String type) {//p:压力 f:流量计 t:温度计
List<EchartResult> list = new ArrayList<>();
for (int i = 0; i < 30; i++) {
Calendar date = Calendar.getInstance();
......@@ -69,18 +167,102 @@ public class OlympicCenterServiceImpl implements IOlympicCenterService {
String newDate = new SimpleDateFormat("yyyy-MM-dd").format(date.getTime()).substring(5,10);
EchartResult echartResult = new EchartResult();
echartResult.setName(newDate);
if("p".equals(type)){
echartResult.setValue(formatDouble(getRandom(0.40,0.50)).toString());
echartResult.setSeries("压力表");
}else if("f".equals(type)){
echartResult.setValue("0.00");
echartResult.setSeries("流量计");
}else if("t".equals(type)){
echartResult.setValue("0.00");
echartResult.setSeries("温度计");
}else{
echartResult.setValue("--");
echartResult.setSeries("--");
}
list.add(echartResult);
}
return list;
}
@Override
public Map<String, Object> getBzRealTimeData(String sourceType) {
Map<String,Object> map = new HashMap<>();
List<TextResult> bList = new ArrayList<>();
if("feed".equals(sourceType)){
TextResult ssllResult = new TextResult();
ssllResult.setTitle("瞬时流量");
ssllResult.setValue("0.00");
TextResult ljllResult = new TextResult();
ljllResult.setTitle("累计流量");
ljllResult.setValue("0.00");
TextResult rllResult = new TextResult();
rllResult.setTitle("日流量");
rllResult.setValue("0.00");
for (int i = 0; i < 4; i++) {
TextResult textResult = new TextResult();
textResult.setTitle("泵"+(i+1));
textResult.setValue("0");
bList.add(i,textResult);
}
map.put("ssll",ssllResult);
map.put("ljll",ljllResult);
map.put("rll",rllResult);
map.put("equip",bList);
}else if("hot".equals(sourceType)){//压力10流量4温度4;
TextResult ssllResult = new TextResult();
ssllResult.setTitle("瞬时流量");
ssllResult.setValue("0.00");
TextResult ljllResult = new TextResult();
ljllResult.setTitle("累计流量");
ljllResult.setValue("0.00");
TextResult rllResult = new TextResult();
rllResult.setTitle("日流量");
rllResult.setValue("0.00");
for (int i = 0; i < 3; i++) {
TextResult textResult = new TextResult();
textResult.setTitle("泵"+(i+1));
textResult.setValue("0");
bList.add(i,textResult);
}
map.put("ssll",ssllResult);
map.put("ljll",ljllResult);
map.put("rll",rllResult);
map.put("equip",bList);
}else if("fire".equals(sourceType)){//压力9流量2.
TextResult ssllResult = new TextResult();
ssllResult.setTitle("瞬时流量");
ssllResult.setValue("0.00");
TextResult ljllResult = new TextResult();
ljllResult.setTitle("累计流量");
ljllResult.setValue("0.00");
TextResult rllResult = new TextResult();
rllResult.setTitle("日流量");
rllResult.setValue("0.00");
for (int i = 0; i < 4; i++) {
TextResult textResult = new TextResult();
textResult.setTitle("泵"+(i+1));
textResult.setValue("0");
bList.add(i,textResult);
}
map.put("ssll",ssllResult);
map.put("ljll",ljllResult);
map.put("rll",rllResult);
map.put("equip",bList);
}else{
map.put("ssll",new TextResult());
map.put("ljll",new TextResult());
map.put("rll",new TextResult());
map.put("equip",new ArrayList<>());
}
return map;
}
public static void main(String[] args) {
for (int i = 0; i < 30; i++) {
for (int i = 0; i < 24; i++) {
Calendar date = Calendar.getInstance();
date.add(Calendar.DATE, i-30);
String newDate = new SimpleDateFormat("yyyy-MM-dd").format(date.getTime()).substring(5,10);
date.add(Calendar.HOUR, i-24);
String newDate = new SimpleDateFormat("HH:00").format(date.getTime());
System.out.println("=========="+newDate+"============");
}
}
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!