ebb278a6 张雷

奥体项目数据报表接口修改

1 个父辈 a30d7c24
......@@ -39,7 +39,7 @@ public class OlympicCenterController {
return result;
}
@ApiOperation(value="获取整体实时数据", notes="获取整体实时数据")
@ApiOperation(value="获取整体实时数据new", notes="获取整体实时数据new")
@GetMapping(value = "/getRealTimeDataNew")
public Result<Map<String,Object>> getRealTimeDataNew(String sourceType){
Result<Map<String,Object>> result = new Result<Map<String,Object>>();
......@@ -59,7 +59,7 @@ public class OlympicCenterController {
return result;
}
@ApiOperation(value="获取整体实时数据给UE", notes="获取整体实时数据给UE")
@ApiOperation(value="新获取整体实时数据给UE", notes="新获取整体实时数据给UE")
@GetMapping(value = "/getRealTimeDataToUENew")
public Result<Map<String,Object>> getRealTimeDataToUENew(){
Result<Map<String,Object>> result = new Result<Map<String,Object>>();
......@@ -128,7 +128,7 @@ public class OlympicCenterController {
return result;
}
@ApiOperation(value="获取趋势图", notes="获取趋势图")
@ApiOperation(value="获取趋势图new", notes="获取趋势图new")
@GetMapping(value = "/getPressureChartNew")
public Result<List<EchartResult>> getPressureChartNew(String equipId,String type){
Result<List<EchartResult>> result = new Result<List<EchartResult>>();
......@@ -139,4 +139,26 @@ public class OlympicCenterController {
return result;
}
@ApiOperation(value="获取流量计详细数据", notes="获取流量计详细数据")
@GetMapping(value = "/getFlowData")
public Result<List<Map<String,Object>>> getFlowData(String equipId){
Result<List<Map<String,Object>>> result = new Result<List<Map<String,Object>>>();
List<Map<String,Object>> list = new ArrayList<Map<String,Object>>();
list = olympicCenterService.getFlowData(equipId);
result.setResult(list);
result.setSuccess(true);
return result;
}
@ApiOperation(value="获取实时数据报表", notes="获取实时数据报表")
@GetMapping(value = "/getRealTimeReport")
public Result<List<Map<String,Object>>> getRealTimeReport(String dataType,String loction){
Result<List<Map<String,Object>>> result = new Result<List<Map<String,Object>>>();
List<Map<String,Object>> list = new ArrayList<>();
list = olympicCenterService.getRealTimeReport(dataType, loction);
result.setResult(list);
result.setSuccess(true);
return result;
}
}
......
......@@ -44,6 +44,9 @@ public class WhatStructData {
/**点实时值*/
@ApiModelProperty(value = "点实时值")
private String monitorValue;
/**缩放倍数*/
@ApiModelProperty(value = "缩放倍数")
private String monitorZoom;
/**所属泵站*/
@ApiModelProperty(value = "所属泵站")
private String pumpCode;
......
......@@ -21,4 +21,10 @@ public interface WhatStructDataMapper {
List<WhatStructData> getDataList(@Param("equipId") String equipId);
List<WhatStructData> getListForUENew();
List<WhatStructData> getFlowList(@Param("loction") String loction);
List<WhatStructData> getPressureList(@Param("loction") String loction);
List<WhatStructData> getTemperatureList(@Param("loction") String loction);
}
......
......@@ -33,4 +33,25 @@
select * from what_struct_data_bak 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','%')
<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','%')
<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','%')
<if test="loction!=null and loction!=''">
and pump_code = #{loction}
</if>
</select>
</mapper>
\ No newline at end of file
......
......@@ -27,4 +27,8 @@ public interface IOlympicCenterService {
List<EchartResult> getPressureChartNew(String equipId, String type);
Map<String, Object> getRealTimeDataToUENew();
List<Map<String, Object>> getFlowData(String equipId);
List<Map<String, Object>> getRealTimeReport(String dataType, String loction);
}
......
......@@ -76,7 +76,7 @@ public class OlympicCenterServiceImpl implements IOlympicCenterService {
if(monitorMap.get(pybList.get(i).getMonitorId())==null){
textResult.setValue("--");
}else{
double pResult = formatDouble(Double.parseDouble(monitorMap.get(pybList.get(i).getMonitorId()).toString())/100);
double pResult = formatDouble(Double.parseDouble(monitorMap.get(pybList.get(i).getMonitorId()).toString())*Double.parseDouble(pybList.get(i).getMonitorZoom()));
textResult.setValue(String.valueOf(pResult));
}
}else{
......@@ -125,7 +125,7 @@ public class OlympicCenterServiceImpl implements IOlympicCenterService {
if(monitorMap.get(pybList.get(i).getMonitorId())==null){
textResult.setValue("--");
}else{
double pResult = formatDouble(Double.parseDouble(monitorMap.get(pybList.get(i).getMonitorId()).toString())/100);
double pResult = formatDouble(Double.parseDouble(monitorMap.get(pybList.get(i).getMonitorId()).toString())*Double.parseDouble(pybList.get(i).getMonitorZoom()));
textResult.setValue(String.valueOf(pResult));
}
}else{
......@@ -190,7 +190,7 @@ public class OlympicCenterServiceImpl implements IOlympicCenterService {
if(monitorMap.get(pybList.get(i).getMonitorId())==null){
textResult.setValue("--");
}else{
double pResult = formatDouble(Double.parseDouble(monitorMap.get(pybList.get(i).getMonitorId()).toString())/100);
double pResult = formatDouble(Double.parseDouble(monitorMap.get(pybList.get(i).getMonitorId()).toString())*Double.parseDouble(pybList.get(i).getMonitorZoom()));
textResult.setValue(String.valueOf(pResult));
}
}else{
......@@ -387,7 +387,7 @@ public class OlympicCenterServiceImpl implements IOlympicCenterService {
EchartResult echartResult = new EchartResult();
echartResult.setName(map.get("time").toString());
if("p".equals(type)){
double pResult = formatDouble(Double.parseDouble(map.get(whatStructData.getMonitorId()).toString())/100);
double pResult = formatDouble(Double.parseDouble(map.get(whatStructData.getMonitorId()).toString())*Double.parseDouble(whatStructData.getMonitorZoom()));
echartResult.setValue(String.valueOf(pResult));
echartResult.setSeries("压力表");
}else if("f".equals(type)){
......@@ -530,7 +530,7 @@ public class OlympicCenterServiceImpl implements IOlympicCenterService {
for (WhatStructData whatStructData:list) {
if(whatStructData.getMonitorId()!=null){
if("pressure".equals(whatStructData.getEquipType())){
double pResult = formatDouble(Double.parseDouble(monitorMap.get(whatStructData.getMonitorId()).toString())/100);
double pResult = formatDouble(Double.parseDouble(monitorMap.get(whatStructData.getMonitorId()).toString())*Double.parseDouble(whatStructData.getMonitorZoom()));
map.put(whatStructData.getId(),String.valueOf(pResult));
}else{
map.put(whatStructData.getId(),monitorMap.get(whatStructData.getMonitorId()));
......@@ -591,7 +591,7 @@ public class OlympicCenterServiceImpl implements IOlympicCenterService {
if(monitorMap.get(pybList.get(i).getMonitorId())==null){
textResult.setValue("--");
}else{
double pResult = formatDouble(Double.parseDouble(monitorMap.get(pybList.get(i).getMonitorId()).toString())/100);
double pResult = formatDouble(Double.parseDouble(monitorMap.get(pybList.get(i).getMonitorId()).toString())*Double.parseDouble(pybList.get(i).getMonitorZoom()));
textResult.setValue(String.valueOf(pResult));
}
}else{
......@@ -667,7 +667,7 @@ public class OlympicCenterServiceImpl implements IOlympicCenterService {
if(monitorMap.get(pybList.get(i).getMonitorId())==null){
textResult.setValue("--");
}else{
double pResult = formatDouble(Double.parseDouble(monitorMap.get(pybList.get(i).getMonitorId()).toString())/100);
double pResult = formatDouble(Double.parseDouble(monitorMap.get(pybList.get(i).getMonitorId()).toString())*Double.parseDouble(pybList.get(i).getMonitorZoom()));
textResult.setValue(String.valueOf(pResult));
}
}else{
......@@ -759,7 +759,7 @@ public class OlympicCenterServiceImpl implements IOlympicCenterService {
if(monitorMap.get(pybList.get(i).getMonitorId())==null){
textResult.setValue("--");
}else{
double pResult = formatDouble(Double.parseDouble(monitorMap.get(pybList.get(i).getMonitorId()).toString())/100);
double pResult = formatDouble(Double.parseDouble(monitorMap.get(pybList.get(i).getMonitorId()).toString())*Double.parseDouble(pybList.get(i).getMonitorZoom()));
textResult.setValue(String.valueOf(pResult));
}
}else{
......@@ -890,7 +890,7 @@ public class OlympicCenterServiceImpl implements IOlympicCenterService {
EchartResult echartResult = new EchartResult();
echartResult.setName(map.get("time").toString());
if("p".equals(type)){
double pResult = formatDouble(Double.parseDouble(map.get(wList.get(0).getMonitorId()).toString())/100);
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);
......@@ -977,7 +977,7 @@ public class OlympicCenterServiceImpl implements IOlympicCenterService {
for (WhatStructData whatStructData:otherList) {
if(whatStructData.getMonitorId()!=null){
if("pressure".equals(whatStructData.getEquipType())){
double pResult = formatDouble(Double.parseDouble(monitorMap.get(whatStructData.getMonitorId()).toString())/100);
double pResult = formatDouble(Double.parseDouble(monitorMap.get(whatStructData.getMonitorId()).toString())*Double.parseDouble(whatStructData.getMonitorZoom()));
map.put(whatStructData.getId(),String.valueOf(pResult));
}else{
map.put(whatStructData.getId(),monitorMap.get(whatStructData.getMonitorId()));
......@@ -1001,14 +1001,134 @@ public class OlympicCenterServiceImpl implements IOlympicCenterService {
return map;
}
// public static void main(String[] args) {
// for (int i = 0; i < 24; i++) {
// Calendar date = Calendar.getInstance();
// date.add(Calendar.HOUR, i-24);
// String newDate = new SimpleDateFormat("HH:00").format(date.getTime());
// System.out.println("=========="+newDate+"============");
// }
// }
@Override
public List<Map<String, Object>> getFlowData(String equipId) {
List<Map<String, Object>> list = new ArrayList<>();
List<WhatStructData> wList = whatStructDataMapper.getDataList(equipId);
String pgField = "";
if(wList.size() == 0){
list = getMnData();
return list;
}else{
for (WhatStructData whatStructData:wList) {
pgField = pgField +","+whatStructData.getMonitorId();
}
}
Map<String, Object> monitorMap = new HashMap<>();
List<Map<String, Object>> monitorList = fmPgQueryService.queryFactoryMonitorFromRealTimeData(AT_ID,pgField);
if(monitorList.size()==1){
monitorMap = monitorList.get(0);
for (WhatStructData whatStructData:wList) {
Map<String, Object> map = new HashMap<>();
map.put("name", whatStructData.getEquipType());
if(monitorMap.get(whatStructData.getMonitorId())==null){
map.put("value","--");
}else{
map.put("value",monitorMap.get(whatStructData.getMonitorId()));
}
list.add(map);
}
}else{
list = getMnData();
return list;
}
return list;
}
@Override
public List<Map<String, Object>> getRealTimeReport(String dataType, String loction) {
List<Map<String, Object>> list = new ArrayList<>();
List<WhatStructData> wList = new ArrayList<>();
List<WhatStructData> flowList = new ArrayList<>();
Map<String, Object> flowMap = new HashMap<>();
String pgField = "";
if("flow".equals(dataType)){
wList = whatStructDataMapper.getFlowList(loction);
for (WhatStructData whatStructData:wList) {
flowMap.put(whatStructData.getMonitorId(),whatStructData.getId());
if("flow".equals(whatStructData.getEquipType())){
flowList.add(whatStructData);
}
}
}else if("pressure".equals(dataType)){
wList = whatStructDataMapper.getPressureList(loction);
}else if("temperature".equals(dataType)){
wList = whatStructDataMapper.getTemperatureList(loction);
}else{
return list;
}
for (WhatStructData whatStructData:wList) {
pgField = pgField +","+whatStructData.getMonitorId();
}
List<Map<String, Object>> monitorList = fmPgQueryService.queryMonitorForReport(AT_ID,pgField);
if("flow".equals(dataType)){
for (Map<String, Object> beanMap : monitorList ) {
boolean status = flowMap.get(beanMap.get("monitorid")).toString().contains("_");
if(status){
beanMap.put("equipId",flowMap.get(beanMap.get("monitorid")).toString().split("_")[0]);
String type = flowMap.get(beanMap.get("monitorid")).toString().split("_")[1];
if("LJLL".equals(type)){
beanMap.put("equipType","flow_ljll");
}else if("RLJLL".equals(type)){
beanMap.put("equipType","flow_rljll");
}else{
beanMap.put("equipType","");
}
}else{
beanMap.put("equipId",flowMap.get(beanMap.get("monitorid")));
beanMap.put("equipType","flow");
}
}
for (WhatStructData whatStructData:flowList) {
Map<String, Object> map = new HashMap<>();
map.put("id",whatStructData.getId());
map.put("name",whatStructData.getId());
map.put("time","");
map.put("flow","");
map.put("flow_ljll","");
map.put("flow_rljll","");
for (Map<String, Object> mMap : monitorList ) {
if(whatStructData.getId().equals(mMap.get("equipId"))){
map.put("time",mMap.get("time"));
if("flow".equals(mMap.get("equipType"))){
map.put("flow",mMap.get("monitorvalue"));
}else if("flow_ljll".equals(mMap.get("equipType"))){
map.put("flow_ljll",mMap.get("monitorvalue"));
}else if("flow_rljll".equals(mMap.get("equipType"))){
map.put("flow_rljll",mMap.get("monitorvalue"));
}else{
map.put("other",mMap.get("monitorvalue"));
}
}
}
list.add(map);
}
}else if("pressure".equals(dataType)){
return list;
}else if("temperature".equals(dataType)){
return list;
}else{
return list;
}
return list;
}
private List<Map<String, Object>> getMnData(){
List<Map<String, Object>> list = new ArrayList<>();
Map<String, Object> flowMap = new HashMap<>();
flowMap.put("name","flow");
flowMap.put("value","--");
Map<String, Object> fflowMap = new HashMap<>();//
fflowMap.put("name","flow_ljll");
fflowMap.put("value","--");
Map<String, Object> rflowMap = new HashMap<>();//
rflowMap.put("name","flow_rljll");
rflowMap.put("value","--");
list.add(flowMap);
list.add(fflowMap);
list.add(rflowMap);
return list;
}
/**
* 获取大于等于min,小于max的随机小数
......
......@@ -10,4 +10,6 @@ public interface IFmPgQueryService {
List<Map<String, Object>> queryFactoryMonitorFromRealTimeData(String factoryId, String fields);
List<Map<String, Object>> queryMonitorForReport(String factoryId, String fields);
}
......
......@@ -11,7 +11,7 @@ import java.text.SimpleDateFormat;
import java.util.*;
/**
* 数据指标信息表
* 实时数据查询
*/
@Service
public class FmPgQueryServiceImpl implements IFmPgQueryService {
......@@ -94,4 +94,44 @@ public class FmPgQueryServiceImpl implements IFmPgQueryService {
}
return timeStemp/1000;
}
@Override
public List<Map<String, Object>> queryMonitorForReport(String factoryId, String fields) {
String[] factoryIdArray = factoryId.split(",");
String sqlPart = "";
for(String id : factoryIdArray) {
sqlPart = sqlPart +",'"+id+"'";
}
sqlPart = sqlPart.substring(1);
JdbcTemplate pgDb = (JdbcTemplate) SpringContextUtils.getBean("pg-db");
List<Map<String,Object>> result = new ArrayList<Map<String,Object>>();
JdbcTemplate masterDB = (JdbcTemplate)SpringContextUtils.getBean("master");
List<Map<String, Object>> factoryDesign = masterDB
.queryForList("select * from sys_factory_device where factory_id in ("+sqlPart+")");
if(factoryDesign==null||factoryDesign.size()==0) {
return result;
}
StringBuilder str = new StringBuilder();
String[] fieldsArr = fields.split(",");
for (int i = 0; i < fieldsArr.length; ++i){
if(!StringUtils.isEmpty(fieldsArr[i])&&!fieldsArr[i].equals("null")) {
str.append("'"+fieldsArr[i]+"'").append(",");
}
}
if(fieldsArr.length > 0){
str.append("''");
}else{
return result;
}
String deviceIds = "";
for(Map<String,Object> map: factoryDesign) {
deviceIds = deviceIds +",'"+map.get("device_id")+"'";
}
deviceIds = deviceIds.substring(1);
//获取pg数据库时间,向前推采集频率的三倍时间,做数据容错
String sql = "select ts as time,nm as monitorId,v as monitorValue from realtimedata where nm in("+str.toString()+") and factoryname in ("+deviceIds+")";
result = pgDb.queryForList(sql);
return result;
}
}
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!