78eebf40 张雷

奥体项目数据报表时间修改

1 个父辈 9873efc0
......@@ -4,6 +4,7 @@ import com.skua.core.api.vo.Result;
import com.skua.modules.business.service.IOlympicCenterService;
import com.skua.modules.business.service.ISynthesizeService;
import com.skua.modules.business.vo.EchartResult;
import com.skua.modules.business.vo.InputQueryParams;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
......@@ -204,4 +205,25 @@ public class OlympicCenterController {
return result;
}
@ApiOperation(value="获取系统的压力和流量趋势图", notes="获取系统的压力和流量趋势图")
@GetMapping(value = "/getPumpOrFlowChart")
public Result<Map<String,Object>> getPumpOrFlowChart(InputQueryParams inputQueryParams){
Result<Map<String,Object>> result = new Result<Map<String,Object>>();
Map<String,Object> map = olympicCenterService.getPumpOrFlowChart(inputQueryParams);
result.setResult(map);
result.setSuccess(true);
return result;
}
@ApiOperation(value="获取趋势图", notes="获取趋势图")
@GetMapping(value = "/getHistoryTrendsByDate")
public Result<List<EchartResult>> getHistoryTrendsByDate(InputQueryParams inputQueryParams){
Result<List<EchartResult>> result = new Result<List<EchartResult>>();
List<EchartResult> list = new ArrayList<EchartResult>();
list = olympicCenterService.getHistoryTrendsByDate(inputQueryParams);
result.setResult(list);
result.setSuccess(true);
return result;
}
}
......
......@@ -31,4 +31,6 @@ public interface WhatStructDataMapper {
List<WhatStructData> getEquipDataList(@Param("sourceType") String sourceType, @Param("pumpId") String pumpId);
List<WhatStructData> getEquipDataListBySource(@Param("sourceType") String sourceType);
List<WhatStructData> getSumEquipListBySource(@Param("sourceType") String sourceType);
}
......
......@@ -15,7 +15,7 @@
</select>
<select id="getListByType" resultType="com.skua.modules.business.entity.WhatStructData">
select * from what_struct_data_bak
select * from what_struct_data
where 1=1
<if test="sourceType!=null and sourceType!=''">
and system_code = #{sourceType}
......@@ -24,44 +24,54 @@
</select>
<select id="getDataList" resultType="com.skua.modules.business.entity.WhatStructData">
select * from what_struct_data_bak
select * from what_struct_data
where id LIKE CONCAT( #{equipId},'%')
order by monitor_sort
</select>
<select id="getListForUENew" resultType="com.skua.modules.business.entity.WhatStructData">
select * from what_struct_data_bak order by monitor_sort
select * from what_struct_data order by monitor_sort
</select>
<select id="getFlowList" resultType="com.skua.modules.business.entity.WhatStructData">
select * from what_struct_data_bak where equip_type like CONCAT('flow','%')
select * from what_struct_data where equip_type like CONCAT('flow','%')
<if test="loction!=null and loction!=''">
and pump_code = #{loction}
</if>
</select>
<select id="getPressureList" resultType="com.skua.modules.business.entity.WhatStructData">
select * from what_struct_data_bak where equip_type like CONCAT('pressure','%')
select * from what_struct_data where equip_type like CONCAT('pressure','%')
<if test="loction!=null and loction!=''">
and pump_code = #{loction}
</if>
</select>
<select id="getTemperatureList" resultType="com.skua.modules.business.entity.WhatStructData">
select * from what_struct_data_bak where equip_type like CONCAT('temperature','%')
select * from what_struct_data where equip_type like CONCAT('temperature','%')
<if test="loction!=null and loction!=''">
and pump_code = #{loction}
</if>
</select>
<select id="getEquipDataList" resultType="com.skua.modules.business.entity.WhatStructData">
select * from what_struct_data_bak
select * from what_struct_data
where pump_code = #{sourceType} and equip_code = #{pumpId}
</select>
<select id="getEquipDataListBySource" resultType="com.skua.modules.business.entity.WhatStructData">
select * from what_struct_data_bak
select * from what_struct_data
where pump_code = #{sourceType}
</select>
<select id="getSumEquipListBySource" resultType="com.skua.modules.business.entity.WhatStructData">
SELECT
*
FROM
what_struct_data
WHERE
system_code = #{sourceType}
AND is_sum = 1
</select>
</mapper>
\ No newline at end of file
......
package com.skua.modules.business.service;
import com.skua.modules.business.vo.EchartResult;
import com.skua.modules.business.vo.InputQueryParams;
import java.util.List;
import java.util.Map;
......@@ -39,4 +40,8 @@ public interface IOlympicCenterService {
List<Map<String, Object>> getHistoryReportClos(String dataType, String loction);
List<Map<String, Object>> getHistoryReportData(String dataType, String loction);
Map<String, Object> getPumpOrFlowChart(InputQueryParams inputQueryParams);
List<EchartResult> getHistoryTrendsByDate(InputQueryParams inputQueryParams);
}
......
......@@ -5,6 +5,7 @@ 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.EchartResult;
import com.skua.modules.business.vo.InputQueryParams;
import com.skua.modules.business.vo.TextResult;
import com.skua.modules.monitor.service.IFmPgQueryService;
import lombok.extern.slf4j.Slf4j;
......@@ -296,6 +297,12 @@ public class OlympicCenterServiceImpl implements IOlympicCenterService {
start = new SimpleDateFormat("yyyy-MM-dd").format(date.getTime());
end = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
}
if("".equals(start)||"".equals(end)){
Calendar date = Calendar.getInstance();
date.add(Calendar.DATE, -30);
start = new SimpleDateFormat("yyyy-MM-dd").format(date.getTime());
end = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
}
}
try{
Long startTime = df.parse(start).getTime();
......@@ -890,8 +897,12 @@ public class OlympicCenterServiceImpl implements IOlympicCenterService {
EchartResult echartResult = new EchartResult();
echartResult.setName(map.get("time").toString());
if("p".equals(type)){
if(map.get(wList.get(0).getMonitorId())==null){
echartResult.setValue("");
}else{
double pResult = formatDouble(Double.parseDouble(map.get(wList.get(0).getMonitorId()).toString())*Double.parseDouble(wList.get(0).getMonitorZoom()));
echartResult.setValue(String.valueOf(pResult));
}
echartResult.setSeries("压力表");
list.add(echartResult);
}else if("f".equals(type)){
......@@ -1352,6 +1363,204 @@ public class OlympicCenterServiceImpl implements IOlympicCenterService {
return list;
}
@Override
public Map<String, Object> getPumpOrFlowChart(InputQueryParams inputQueryParams) {
Map<String, Object> map = new HashMap<>();
Map<String, Object> monitorMap = new HashMap<>();
List<Map<String, Object>> pumpList = new ArrayList<>();
List<Map<String, Object>> flowList = new ArrayList<>();
map.put("pump", new ArrayList<>());
map.put("flow", new ArrayList<>());
String timeStep = "hour";
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";
String endDate = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
String end = endDate + " 23:59:59";
String timeType = inputQueryParams.getTimeType();
if("today".equals(timeType)){
timeStep = "hour";
start = endDate + " 00:00:00";
end = endDate + " 23:59:59";
}else if("week".equals(timeType)){
timeStep = "hour";
}else if("month".equals(timeType)){
timeStep = "day";
cal.add(Calendar.DATE, -30);
start = new SimpleDateFormat("yyyy-MM-dd").format(cal.getTime()) + " 00:00:00";
end = endDate + " 23:59:59";
}else if("6month".equals(timeType)){
timeStep = "day";
cal.add(Calendar.DATE, -180);
start = new SimpleDateFormat("yyyy-MM-dd").format(cal.getTime()) + " 00:00:00";
end = endDate + " 23:59:59";
}else if("custom".equals(timeType)){
timeStep = "day";
start = inputQueryParams.getStart();
end = inputQueryParams.getEnd();
}else {
timeStep = "day";
}
String sourceType = inputQueryParams.getSourceType();
List<WhatStructData> equipList = whatStructDataMapper.getSumEquipListBySource(sourceType);
String pPgField = "";
String fPgField = "";
if(equipList.size() == 0){
return map;
}else{
for (WhatStructData whatStructData:equipList) {
if("flow".equals(whatStructData.getEquipType())){
fPgField = fPgField +","+whatStructData.getMonitorId();
}else if("pressure".equals(whatStructData.getEquipType())){
pPgField = pPgField +","+whatStructData.getMonitorId();
}else{}
if(whatStructData.getMonitorId()!=null){
monitorMap.put(whatStructData.getMonitorId(),whatStructData.getId());
}
}
}
List<Map<String, Object>> pDataList = factoryInfoService.queryReportData(AT_ID, pPgField, start, end, timeStep);
for (Map<String, Object> bmap : pDataList) {
Map<String, Object> newMap = new HashMap<>();
for (Map.Entry<String, Object> entry : bmap.entrySet()) {
if("time".equals(entry.getKey())){
newMap.put(entry.getKey(),entry.getValue());
}else {
newMap.put(monitorMap.get(entry.getKey()).toString(),entry.getValue());
}
}
pumpList.add(newMap);
}
List<Map<String, Object>> fDataList = factoryInfoService.queryReportData(AT_ID, fPgField, start, end, timeStep);
for (Map<String, Object> bmap : fDataList) {
Map<String, Object> newMap = new HashMap<>();
for (Map.Entry<String, Object> entry : bmap.entrySet()) {
if("time".equals(entry.getKey())){
newMap.put(entry.getKey(),entry.getValue());
}else {
newMap.put(monitorMap.get(entry.getKey()).toString(),entry.getValue());
}
}
flowList.add(newMap);
}
map.put("pump", pumpList);
map.put("flow", flowList);
return map;
}
@Override
public List<EchartResult> getHistoryTrendsByDate(InputQueryParams inputQueryParams) {
List<EchartResult> list = new ArrayList<>();
String type = inputQueryParams.getEquipType();
List<WhatStructData> wList = whatStructDataMapper.getDataList(inputQueryParams.getEquipId());
String pgField = "";
if(wList.size() == 0){
return list;
}else{
for (WhatStructData whatStructData:wList) {
pgField = pgField +","+whatStructData.getMonitorId();
}
}
String timeStep = "hour";
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";
String endDate = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
String end = endDate + " 23:59:59";
String timeType = inputQueryParams.getTimeType();
if("today".equals(timeType)){
timeStep = "hour";
start = endDate + " 00:00:00";
end = endDate + " 23:59:59";
}else if("week".equals(timeType)){
timeStep = "hour";
}else if("month".equals(timeType)){
timeStep = "day";
cal.add(Calendar.DATE, -30);
start = new SimpleDateFormat("yyyy-MM-dd").format(cal.getTime()) + " 00:00:00";
end = endDate + " 23:59:59";
}else if("6month".equals(timeType)){
timeStep = "day";
cal.add(Calendar.DATE, -180);
start = new SimpleDateFormat("yyyy-MM-dd").format(cal.getTime()) + " 00:00:00";
end = endDate + " 23:59:59";
}else if("custom".equals(timeType)){
timeStep = "day";
start = inputQueryParams.getStart();
end = inputQueryParams.getEnd();
}else {
timeStep = "day";
}
List<Map<String, Object>> dataList = factoryInfoService.queryReportData(AT_ID, pgField, start, end, timeStep);
if(dataList.size()>0){
for (Map<String, Object> map:dataList) {
EchartResult echartResult = new EchartResult();
echartResult.setName(map.get("time").toString());
if("p".equals(type)){
if(map.get(wList.get(0).getMonitorId())==null){
echartResult.setValue("");
}else{
double pResult = formatDouble(Double.parseDouble(map.get(wList.get(0).getMonitorId()).toString())*Double.parseDouble(wList.get(0).getMonitorZoom()));
echartResult.setValue(String.valueOf(pResult));
}
echartResult.setSeries("压力表");
list.add(echartResult);
}else if("f".equals(type)){
for (WhatStructData whatStructData:wList) {
EchartResult eResult = new EchartResult();
eResult.setName(map.get("time").toString());
if(whatStructData.getMonitorId()==null){
eResult.setValue("");
}else{
eResult.setValue(map.get(whatStructData.getMonitorId()).toString());
}
if("flow".equals(whatStructData.getEquipType())){
eResult.setSeries("瞬时流量");
}else if("flow_ljll".equals(whatStructData.getEquipType())){
eResult.setSeries("正向累计流量");
}else if("flow_rljll".equals(whatStructData.getEquipType())){
eResult.setSeries("反向累计流量");
}else{
eResult.setSeries(whatStructData.getEquipType());
}
list.add(eResult);
}
}else if("t".equals(type)){
echartResult.setValue(map.get(wList.get(0).getMonitorId()).toString());
echartResult.setSeries("温度计");
list.add(echartResult);
}else{
echartResult.setValue("--");
echartResult.setSeries("--");
list.add(echartResult);
}
}
}else{
for (int i = 0; i < 7; i++) {
Calendar date = Calendar.getInstance();
date.add(Calendar.DATE, i-7);
String newDate = new SimpleDateFormat("yyyy-MM-dd").format(date.getTime()).substring(5,10);
EchartResult echartResult = new EchartResult();
echartResult.setName(newDate);
echartResult.setValue("--");
if("p".equals(type)){
echartResult.setSeries("压力表");
}else if("f".equals(type)){
echartResult.setSeries("流量计");
}else if("t".equals(type)){
echartResult.setSeries("温度计");
}else{
echartResult.setSeries("--");
}
list.add(echartResult);
}
}
return list;
}
private String getStatus1(Map<String, Object> map, List<Map<String, Object>> list, String pumpId) {
String status = "停止";
Map<String, Object> bean = list.get(0);
......
package com.skua.modules.business.vo;
import lombok.Data;
/**
* 返回数据实体
*/
@Data
public class InputQueryParams {
/**设备编码*/
private String equipId;
/**设备类型 压力:p,流量:f,温度:t*/
private String equipType;
/**系统类型*/
private String sourceType;
/**时间粒度 今日:today,本周:week,本月:month,近6月:6month,自定义:custom*/
private String timeType;
/**开始时间 yyyy-MM-DD*/
private String start;
/**结束时间 yyyy-MM-DD*/
private String end;
}
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!