a30d7c24 张雷

奥体项目实时数据接口修改

1 个父辈 7a86522a
......@@ -39,6 +39,16 @@ public class OlympicCenterController {
return result;
}
@ApiOperation(value="获取整体实时数据", notes="获取整体实时数据")
@GetMapping(value = "/getRealTimeDataNew")
public Result<Map<String,Object>> getRealTimeDataNew(String sourceType){
Result<Map<String,Object>> result = new Result<Map<String,Object>>();
Map<String,Object> map = olympicCenterService.getRealTimeDataNew(sourceType);
result.setResult(map);
result.setSuccess(true);
return result;
}
@ApiOperation(value="获取整体实时数据给UE", notes="获取整体实时数据给UE")
@GetMapping(value = "/getRealTimeDataToUE")
public Result<Map<String,Object>> getRealTimeDataToUE(){
......@@ -49,6 +59,16 @@ public class OlympicCenterController {
return result;
}
@ApiOperation(value="获取整体实时数据给UE", notes="获取整体实时数据给UE")
@GetMapping(value = "/getRealTimeDataToUENew")
public Result<Map<String,Object>> getRealTimeDataToUENew(){
Result<Map<String,Object>> result = new Result<Map<String,Object>>();
Map<String,Object> map = olympicCenterService.getRealTimeDataToUENew();
result.setResult(map);
result.setSuccess(true);
return result;
}
/**
* 获取泵站指标历史趋势曲线
* @param field ssll:瞬时流量 ljll:累计流量 rll:日流量
......@@ -108,4 +128,15 @@ public class OlympicCenterController {
return result;
}
@ApiOperation(value="获取趋势图", notes="获取趋势图")
@GetMapping(value = "/getPressureChartNew")
public Result<List<EchartResult>> getPressureChartNew(String equipId,String type){
Result<List<EchartResult>> result = new Result<List<EchartResult>>();
List<EchartResult> list = new ArrayList<EchartResult>();
list = olympicCenterService.getPressureChartNew(equipId,type);
result.setResult(list);
result.setSuccess(true);
return result;
}
}
......
......@@ -15,4 +15,10 @@ public interface WhatStructDataMapper {
List<WhatStructData> getListForUE();
WhatStructData getOneById(@Param("id") String id);
List<WhatStructData> getListByType(@Param("sourceType") String sourceType);
List<WhatStructData> getDataList(@Param("equipId") String equipId);
List<WhatStructData> getListForUENew();
}
......
......@@ -14,4 +14,23 @@
select * from what_struct_data where id = #{id} limit 1
</select>
<select id="getListByType" resultType="com.skua.modules.business.entity.WhatStructData">
select * from what_struct_data_bak
where 1=1
<if test="sourceType!=null and sourceType!=''">
and system_code = #{sourceType}
</if>
order by monitor_sort
</select>
<select id="getDataList" resultType="com.skua.modules.business.entity.WhatStructData">
select * from what_struct_data_bak
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>
</mapper>
\ No newline at end of file
......
......@@ -21,4 +21,10 @@ public interface IOlympicCenterService {
Map<String, Object> getBzRealTimeData(String sourceType);
Map<String, Object> getRealTimeDataToUE();
Map<String, Object> getRealTimeDataNew(String sourceType);
List<EchartResult> getPressureChartNew(String equipId, String type);
Map<String, Object> getRealTimeDataToUENew();
}
......
package com.skua.modules.business.service.impl;
import com.skua.core.service.IFactoryInfoService;
import com.skua.core.service.IPgQueryService;
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.TextResult;
import com.skua.modules.monitor.service.IFmPgQueryService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -24,7 +24,7 @@ import java.util.*;
public class OlympicCenterServiceImpl implements IOlympicCenterService {
@Autowired
private IPgQueryService pgQueryService;
private IFmPgQueryService fmPgQueryService;
@Autowired
private IFactoryInfoService factoryInfoService;
//queryReportData
......@@ -39,7 +39,7 @@ public class OlympicCenterServiceImpl implements IOlympicCenterService {
Map<String, Object> monitorMap = new HashMap<>();
List<WhatStructData> pybList = new ArrayList<>();
List<WhatStructData> fybList = new ArrayList<>();
List<WhatStructData> ljbList = new ArrayList<>();
List<WhatStructData> ljList = new ArrayList<>();
List<WhatStructData> wybList = new ArrayList<>();
List<TextResult> pList = new ArrayList<>();
List<TextResult> fList = new ArrayList<>();
......@@ -57,7 +57,7 @@ public class OlympicCenterServiceImpl implements IOlympicCenterService {
}else if("flow".equals(whatStructData.getEquipType())){
fybList.add(whatStructData);
}else if("flow_ljll".equals(whatStructData.getEquipType())){
ljbList.add(whatStructData);
ljList.add(whatStructData);
}else if("temperature".equals(whatStructData.getEquipType())){
wybList.add(whatStructData);
}else{ }
......@@ -65,7 +65,7 @@ public class OlympicCenterServiceImpl implements IOlympicCenterService {
}
}
}
List<Map<String, Object>> monitorList = pgQueryService.queryFactoryMonitorFromRealTimeData(AT_ID,pgField);
List<Map<String, Object>> monitorList = fmPgQueryService.queryFactoryMonitorFromRealTimeData(AT_ID,pgField);
if(monitorList.size()==1){
monitorMap = monitorList.get(0);
if("feed".equals(sourceType)){//压力14流量8
......@@ -102,12 +102,12 @@ public class OlympicCenterServiceImpl implements IOlympicCenterService {
}
for (int k = 0; k < 8; k++) {
TextResult textResult = new TextResult();
if(k<ljbList.size()){
textResult.setTitle(ljbList.get(k).getId());
if(monitorMap.get(ljbList.get(k).getMonitorId())==null){
if(k<ljList.size()){
textResult.setTitle(ljList.get(k).getId());
if(monitorMap.get(ljList.get(k).getMonitorId())==null){
textResult.setValue("--");
}else{
textResult.setValue(monitorMap.get(ljbList.get(k).getMonitorId()).toString());
textResult.setValue(monitorMap.get(ljList.get(k).getMonitorId()).toString());
}
}else{
textResult.setTitle("flow_ljll"+(k+1));
......@@ -151,12 +151,12 @@ public class OlympicCenterServiceImpl implements IOlympicCenterService {
}
for (int h = 0; h < 4; h++) {
TextResult textResult = new TextResult();
if(h<ljbList.size()){
textResult.setTitle(ljbList.get(h).getId());
if(monitorMap.get(ljbList.get(h).getMonitorId())==null){
if(h<ljList.size()){
textResult.setTitle(ljList.get(h).getId());
if(monitorMap.get(ljList.get(h).getMonitorId())==null){
textResult.setValue("--");
}else{
textResult.setValue(monitorMap.get(ljbList.get(h).getMonitorId()).toString());
textResult.setValue(monitorMap.get(ljList.get(h).getMonitorId()).toString());
}
}else{
textResult.setTitle("flow_ljll"+(h+1));
......@@ -216,12 +216,12 @@ public class OlympicCenterServiceImpl implements IOlympicCenterService {
}
for (int k = 0; k < 2; k++) {
TextResult textResult = new TextResult();
if(k<ljbList.size()){
textResult.setTitle(ljbList.get(k).getId());
if(monitorMap.get(ljbList.get(k).getMonitorId())==null){
if(k<ljList.size()){
textResult.setTitle(ljList.get(k).getId());
if(monitorMap.get(ljList.get(k).getMonitorId())==null){
textResult.setValue("--");
}else{
textResult.setValue(monitorMap.get(ljbList.get(k).getMonitorId()).toString());
textResult.setValue(monitorMap.get(ljList.get(k).getMonitorId()).toString());
}
}else{
textResult.setTitle("flow_ljll"+(k+1));
......@@ -403,9 +403,9 @@ public class OlympicCenterServiceImpl implements IOlympicCenterService {
list.add(echartResult);
}
}else{
for (int i = 0; i < 30; i++) {
for (int i = 0; i < 7; i++) {
Calendar date = Calendar.getInstance();
date.add(Calendar.DATE, i-30);
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);
......@@ -524,7 +524,7 @@ public class OlympicCenterServiceImpl implements IOlympicCenterService {
for (WhatStructData whatStructData:list) {
pgField = pgField +","+whatStructData.getMonitorId();
}
List<Map<String, Object>> monitorList = pgQueryService.queryFactoryMonitorFromRealTimeData(AT_ID,pgField);
List<Map<String, Object>> monitorList = fmPgQueryService.queryFactoryMonitorFromRealTimeData(AT_ID,pgField);
if(monitorList.size()==1){
monitorMap = monitorList.get(0);
for (WhatStructData whatStructData:list) {
......@@ -547,6 +547,460 @@ public class OlympicCenterServiceImpl implements IOlympicCenterService {
return map;
}
@Override
public Map<String, Object> getRealTimeDataNew(String sourceType) {
Map<String,Object> map = new HashMap<>();
List<WhatStructData> list = whatStructDataMapper.getListByType(sourceType);
Map<String, Object> monitorMap = new HashMap<>();
List<WhatStructData> pybList = new ArrayList<>();
List<WhatStructData> fybList = new ArrayList<>();
List<WhatStructData> ljList = new ArrayList<>();
List<WhatStructData> wybList = new ArrayList<>();
List<TextResult> pList = new ArrayList<>();
List<Map<String,Object>> fList = new ArrayList<>();
List<TextResult> wList = new ArrayList<>();
String pgField = "";
if(sourceType==null){
for (WhatStructData whatStructData:list) {
pgField = pgField +","+whatStructData.getMonitorId();
}
}else{
for (WhatStructData whatStructData:list) {
if(sourceType.equals(whatStructData.getSystemCode())){
if("pressure".equals(whatStructData.getEquipType())){
pybList.add(whatStructData);
}else if("flow".equals(whatStructData.getEquipType())){
fybList.add(whatStructData);
}else if("flow_ljll".equals(whatStructData.getEquipType())||"flow_rljll".equals(whatStructData.getEquipType())){
ljList.add(whatStructData);
}else if("temperature".equals(whatStructData.getEquipType())){
wybList.add(whatStructData);
}else{ }
pgField = pgField +","+whatStructData.getMonitorId();
}
}
}
List<Map<String, Object>> monitorList = fmPgQueryService.queryFactoryMonitorFromRealTimeData(AT_ID,pgField);
if(monitorList.size()==1){
monitorMap = monitorList.get(0);
if("feed".equals(sourceType)){//压力14流量8
for (int i = 0; i < 14; i++) {
TextResult textResult = new TextResult();
if(i<pybList.size()){
textResult.setTitle(pybList.get(i).getId());
if(monitorMap.get(pybList.get(i).getMonitorId())==null){
textResult.setValue("--");
}else{
double pResult = formatDouble(Double.parseDouble(monitorMap.get(pybList.get(i).getMonitorId()).toString())/100);
textResult.setValue(String.valueOf(pResult));
}
}else{
textResult.setTitle("pressure"+(i+1));
textResult.setValue("--");
}
pList.add(i,textResult);
}
for (int j = 0; j < 8; j++) {
Map<String,Object> fMap = new HashMap<>();
List<TextResult> flowList = new ArrayList<>();
TextResult flow = new TextResult();
TextResult fFlow = new TextResult();
TextResult rFlow = new TextResult();
if(j<fybList.size()){
flow.setTitle(fybList.get(j).getEquipType());
if(fybList.get(j).getMonitorId()!=null){
flow.setValue(monitorMap.get(fybList.get(j).getMonitorId()).toString());
flowList.add(flow);
String equipCode = fybList.get(j).getEquipCode();
int fcount = 0;
for (WhatStructData whatStructData : ljList) {
if(fcount < 2){
if(equipCode.equals(whatStructData.getEquipCode())){
if("flow_ljll".equals(whatStructData.getEquipType())){
fFlow.setTitle(whatStructData.getEquipType());
fFlow.setValue(monitorMap.get(whatStructData.getMonitorId()).toString());
flowList.add(fFlow);
fcount++;
}else if("flow_rljll".equals(whatStructData.getEquipType())){
rFlow.setTitle(whatStructData.getEquipType());
rFlow.setValue(monitorMap.get(whatStructData.getMonitorId()).toString());
flowList.add(rFlow);
fcount++;
}else{}
}
}else{
break;
}
}
}else{
flow.setValue("--");
flowList.add(flow);
fFlow.setTitle("flow_ljll");
fFlow.setValue("--");
flowList.add(fFlow);
rFlow.setTitle("flow_rljll");
rFlow.setValue("--");
flowList.add(rFlow);
}
fMap.put(fybList.get(j).getId(),flowList);
}else{
flow.setTitle((j+1)+"flow");
flow.setValue("--");
flowList.add(flow);
fFlow.setTitle((j+1)+"flow_ljll");
fFlow.setValue("--");
flowList.add(fFlow);
rFlow.setTitle((j+1)+"flow_rljll");
rFlow.setValue("--");
flowList.add(rFlow);
fMap.put("flow"+(j+1),flowList);
}
fList.add(j,fMap);
}
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();
if(i<pybList.size()){
textResult.setTitle(pybList.get(i).getId());
if(monitorMap.get(pybList.get(i).getMonitorId())==null){
textResult.setValue("--");
}else{
double pResult = formatDouble(Double.parseDouble(monitorMap.get(pybList.get(i).getMonitorId()).toString())/100);
textResult.setValue(String.valueOf(pResult));
}
}else{
textResult.setTitle("pressure"+(i+1));
textResult.setValue("--");
}
pList.add(i,textResult);
}
for (int j = 0; j < 4; j++) {
Map<String,Object> fMap = new HashMap<>();
List<TextResult> flowList = new ArrayList<>();
TextResult flow = new TextResult();
TextResult fFlow = new TextResult();
TextResult rFlow = new TextResult();
if(j<fybList.size()){
flow.setTitle(fybList.get(j).getEquipType());
if(fybList.get(j).getMonitorId()!=null){
flow.setValue(monitorMap.get(fybList.get(j).getMonitorId()).toString());
flowList.add(flow);
String equipCode = fybList.get(j).getEquipCode();
int fcount = 0;
for (WhatStructData whatStructData : ljList) {
if(fcount < 2){
if(equipCode.equals(whatStructData.getEquipCode())){
if("flow_ljll".equals(whatStructData.getEquipType())){
fFlow.setTitle(whatStructData.getEquipType());
fFlow.setValue(monitorMap.get(whatStructData.getMonitorId()).toString());
flowList.add(fFlow);
fcount++;
}else if("flow_rljll".equals(whatStructData.getEquipType())){
rFlow.setTitle(whatStructData.getEquipType());
rFlow.setValue(monitorMap.get(whatStructData.getMonitorId()).toString());
flowList.add(rFlow);
fcount++;
}else{}
}
}else{
break;
}
}
}else{
flow.setValue("--");
flowList.add(flow);
fFlow.setTitle("flow_ljll");
fFlow.setValue("--");
flowList.add(fFlow);
rFlow.setTitle("flow_rljll");
rFlow.setValue("--");
flowList.add(rFlow);
}
fMap.put(fybList.get(j).getId(),flowList);
}else{
flow.setTitle((j+1)+"flow");
flow.setValue("--");
flowList.add(flow);
fFlow.setTitle((j+1)+"flow_ljll");
fFlow.setValue("--");
flowList.add(fFlow);
rFlow.setTitle((j+1)+"flow_rljll");
rFlow.setValue("--");
flowList.add(rFlow);
fMap.put("flow"+(j+1),flowList);
}
fList.add(j,fMap);
}
for (int k = 0; k < 4; k++) {
TextResult textResult = new TextResult();
if(k<wybList.size()){
textResult.setTitle(wybList.get(k).getId());
if(monitorMap.get(wybList.get(k).getMonitorId())==null){
textResult.setValue("--");
}else{
textResult.setValue(monitorMap.get(wybList.get(k).getMonitorId()).toString());
}
}else{
textResult.setTitle("temperature"+(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();
if(i<pybList.size()){
textResult.setTitle(pybList.get(i).getId());
if(monitorMap.get(pybList.get(i).getMonitorId())==null){
textResult.setValue("--");
}else{
double pResult = formatDouble(Double.parseDouble(monitorMap.get(pybList.get(i).getMonitorId()).toString())/100);
textResult.setValue(String.valueOf(pResult));
}
}else{
textResult.setTitle("pressure"+(i+1));
textResult.setValue("--");
}
pList.add(i,textResult);
}
for (int j = 0; j < 2; j++) {
Map<String,Object> fMap = new HashMap<>();
List<TextResult> flowList = new ArrayList<>();
TextResult flow = new TextResult();
TextResult fFlow = new TextResult();
TextResult rFlow = new TextResult();
if(j<fybList.size()){
flow.setTitle(fybList.get(j).getEquipType());
if(fybList.get(j).getMonitorId()!=null){
flow.setValue(monitorMap.get(fybList.get(j).getMonitorId()).toString());
flowList.add(flow);
String equipCode = fybList.get(j).getEquipCode();
int fcount = 0;
for (WhatStructData whatStructData : ljList) {
if(fcount < 2){
if(equipCode.equals(whatStructData.getEquipCode())){
if("flow_ljll".equals(whatStructData.getEquipType())){
fFlow.setTitle(whatStructData.getEquipType());
fFlow.setValue(monitorMap.get(whatStructData.getMonitorId()).toString());
flowList.add(fFlow);
fcount++;
}else if("flow_rljll".equals(whatStructData.getEquipType())){
rFlow.setTitle(whatStructData.getEquipType());
rFlow.setValue(monitorMap.get(whatStructData.getMonitorId()).toString());
flowList.add(rFlow);
fcount++;
}else{}
}
}else{
break;
}
}
}else{
flow.setValue("--");
flowList.add(flow);
fFlow.setTitle("flow_ljll");
fFlow.setValue("--");
flowList.add(fFlow);
rFlow.setTitle("flow_rljll");
rFlow.setValue("--");
flowList.add(rFlow);
}
fMap.put(fybList.get(j).getId(),flowList);
}else{
flow.setTitle((j+1)+"flow");
flow.setValue("--");
flowList.add(flow);
fFlow.setTitle((j+1)+"flow_ljll");
fFlow.setValue("--");
flowList.add(fFlow);
rFlow.setTitle((j+1)+"flow_rljll");
rFlow.setValue("--");
flowList.add(rFlow);
fMap.put("flow"+(j+1),flowList);
}
fList.add(j,fMap);
}
map.put("pressure",pList);
map.put("flow",fList);
}else{
for (int i = 0; i < 33; i++) {
TextResult textResult = new TextResult();
textResult.setTitle("pressure"+(i+1));
textResult.setValue("0.00");
pList.add(i,textResult);
}
for (int j = 0; j < 14; j++) {
Map<String,Object> fMap = new HashMap<>();
List<TextResult> flowList = new ArrayList<>();
TextResult flow = new TextResult();
TextResult fFlow = new TextResult();
TextResult rFlow = new TextResult();
flow.setTitle("flow");
flow.setValue("--");
flowList.add(flow);
fFlow.setTitle("flow_ljll");
fFlow.setValue("--");
flowList.add(fFlow);
rFlow.setTitle("flow_rljll");
rFlow.setValue("--");
flowList.add(rFlow);
fMap.put("F0"+(j+1),flowList);
fList.add(fMap);
}
for (int k = 0; k < 4; k++) {
TextResult textResult = new TextResult();
textResult.setTitle("temperature"+(k+1));
textResult.setValue("--");
wList.add(k,textResult);
}
map.put("pressure",pList);
map.put("flow",fList);
map.put("temperature",wList);
}
}
return map;
}
@Override
public List<EchartResult> getPressureChartNew(String equipId, String type) {
List<EchartResult> list = new ArrayList<>();
List<WhatStructData> wList = whatStructDataMapper.getDataList(equipId);
String pgField = "";
if(wList.size() == 0){
return list;
}else{
for (WhatStructData whatStructData:wList) {
pgField = pgField +","+whatStructData.getMonitorId();
}
}
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";
List<Map<String, Object>> dataList = factoryInfoService.queryReportData(AT_ID, pgField, start, end,"hour");
if(dataList.size()>0){
for (Map<String, Object> map:dataList) {
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);
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());
eResult.setValue(map.get(whatStructData.getMonitorId()).toString());
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;
}
@Override
public Map<String, Object> getRealTimeDataToUENew() {
List<WhatStructData> list = whatStructDataMapper.getListForUENew();
List<WhatStructData> fList = new ArrayList<>();
List<WhatStructData> otherList = new ArrayList<>();
Map<String, Object> map = new HashMap<>();
Map<String, Object> monitorMap = new HashMap<>();
String pgField = "";
for (WhatStructData whatStructData:list) {
pgField = pgField +","+whatStructData.getMonitorId();
if("flow".equals(whatStructData.getEquipType())){
fList.add(whatStructData);
}
if(!whatStructData.getEquipType().contains("flow")){
otherList.add(whatStructData);
}
}
List<Map<String, Object>> monitorList = fmPgQueryService.queryFactoryMonitorFromRealTimeData(AT_ID,pgField);
if(monitorList.size()==1){
monitorMap = monitorList.get(0);
for (WhatStructData whatStructData:fList) {
if(whatStructData.getMonitorId()!=null){
String fId = whatStructData.getId();
Map<String, Object> beanMap = new HashMap<>();
for (WhatStructData bean : list) {
if(bean.getId().startsWith(fId)){
beanMap.put(bean.getEquipType(),monitorMap.get(bean.getMonitorId()));
}
}
map.put(fId,beanMap);
}else{
Map<String, Object> kMap = new HashMap<>();
kMap.put("flow","--");
kMap.put("flow_ljll","--");
kMap.put("flow_rljll","--");
map.put(whatStructData.getId(),kMap);
}
}
for (WhatStructData whatStructData:otherList) {
if(whatStructData.getMonitorId()!=null){
if("pressure".equals(whatStructData.getEquipType())){
double pResult = formatDouble(Double.parseDouble(monitorMap.get(whatStructData.getMonitorId()).toString())/100);
map.put(whatStructData.getId(),String.valueOf(pResult));
}else{
map.put(whatStructData.getId(),monitorMap.get(whatStructData.getMonitorId()));
}
}else{
map.put(whatStructData.getId(),"--");
}
}
}else{
for (WhatStructData whatStructData:fList) {
Map<String, Object> kMap = new HashMap<>();
kMap.put("flow","--");
kMap.put("flow_ljll","--");
kMap.put("flow_rljll","--");
map.put(whatStructData.getId(),kMap);
}
for (WhatStructData whatStructData:otherList) {
map.put(whatStructData.getId(),"--");
}
}
return map;
}
// public static void main(String[] args) {
// for (int i = 0; i < 24; i++) {
// Calendar date = Calendar.getInstance();
......
......@@ -6,6 +6,7 @@ import com.skua.modules.location.UserLocationFactory;
import com.skua.modules.location.entity.UserBaseInfo;
import com.skua.modules.location.entity.UserLocation;
import com.skua.modules.location.service.ILocationService;
import com.skua.modules.location.vo.QueryParams;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
......@@ -14,7 +15,9 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Slf4j
@Api(tags="人员定位系统对接")
......@@ -26,12 +29,12 @@ public class UserLocationController {
@AutoLog(value = "义乌人员定位-获取所有人员列表")
@ApiOperation(value="义乌人员定位-获取所有人员列表", notes="义乌人员定位-获取所有人员列表")
@GetMapping(value = "/yw/getAllUser")
public Result<List<UserBaseInfo>> getAllUserYW(String userName) {
Result<List<UserBaseInfo>> result = new Result<List<UserBaseInfo>>();
List<UserBaseInfo> list = new ArrayList<>();
public Result<Map<String,Object>> getAllUserYW(QueryParams queryParams) {
Result<Map<String,Object>> result = new Result<Map<String,Object>>();
Map<String,Object> map = new HashMap<>();
ILocationService locationService = UserLocationFactory.getLocationService("YW");
list = locationService.getAllUser(userName);
result.setResult(list);
map = locationService.getAllUser(queryParams);
result.setResult(map);
result.setSuccess(true);
return result;
}
......@@ -66,12 +69,12 @@ public class UserLocationController {
@AutoLog(value = "余杭人员定位-获取所有人员列表")
@ApiOperation(value="余杭人员定位-获取所有人员列表", notes="余杭人员定位-获取所有人员列表")
@GetMapping(value = "/yh/getAllUser")
public Result<List<UserBaseInfo>> getAllUserBKYH(String userName) {
Result<List<UserBaseInfo>> result = new Result<List<UserBaseInfo>>();
List<UserBaseInfo> list = new ArrayList<>();
public Result<Map<String,Object>> getAllUserBKYH(QueryParams queryParams) {
Result<Map<String,Object>> result = new Result<Map<String,Object>>();
Map<String,Object> map = new HashMap<>();
ILocationService locationService = UserLocationFactory.getLocationService("BKYH");
list = locationService.getAllUser(userName);
result.setResult(list);
map = locationService.getAllUser(queryParams);
result.setResult(map);
result.setSuccess(true);
return result;
}
......
......@@ -2,8 +2,10 @@ package com.skua.modules.location.service;
import com.skua.modules.location.entity.UserBaseInfo;
import com.skua.modules.location.entity.UserLocation;
import com.skua.modules.location.vo.QueryParams;
import java.util.List;
import java.util.Map;
public interface ILocationService {
......@@ -11,7 +13,7 @@ public interface ILocationService {
List<UserLocation> getUserHistory(String deviceCode, String startTime, String endTime);
List<UserBaseInfo> getAllUser(String userName);
Map<String,Object> getAllUser(QueryParams queryParams);
}
......
......@@ -6,6 +6,7 @@ import com.skua.modules.location.entity.*;
import com.skua.modules.location.service.ILocationService;
import com.skua.modules.location.util.ChangeLocationUtils;
import com.skua.modules.location.util.MD5Util;
import com.skua.modules.location.vo.QueryParams;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;
......@@ -108,8 +109,9 @@ public class BkyhLocationServiceImpl implements ILocationService {
}
@Override
public List<UserBaseInfo> getAllUser(String userName) {
public Map<String,Object> getAllUser(QueryParams queryParams) {
List<UserBaseInfo> list = new ArrayList<>();
Map<String,Object> map = new HashMap<>();
String post = getBuildingAllInfo();
JSONObject json = JSONObject.parseObject(JSONObject.parseObject(post).get("data").toString());
List<UserBaseInfoBkyhResult> userList = JSONObject.parseArray(json.get("devices").toString(), UserBaseInfoBkyhResult.class);
......@@ -131,7 +133,8 @@ public class BkyhLocationServiceImpl implements ILocationService {
userBaseInfo.setUserName(userBaseInfoBkyhResult.getName());
list.add(userBaseInfo);
}
return list;
map.put("list",list);
return map;
}
}
......
......@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject;
import com.skua.modules.location.entity.*;
import com.skua.modules.location.service.ILocationService;
import com.skua.modules.location.util.ChangeLocationUtils;
import com.skua.modules.location.vo.QueryParams;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
......@@ -94,17 +95,19 @@ public class YwLocationServiceImpl implements ILocationService {
}
@Override
public List<UserBaseInfo> getAllUser(String userName) {
public Map<String,Object> getAllUser(QueryParams queryParams) {
List<UserBaseInfo> list = new ArrayList<>();
HashMap<String,Object> map = new HashMap<>();
map.put("username", username);
map.put("password", password);
map.put("page",1);
map.put("rows",1000);
map.put("emp",userName);
String post = HttpUtil.get(url+"open/information/getEmp.do",map);
Map<String,Object> map = new HashMap<>();
HashMap<String,Object> pmap = new HashMap<>();
pmap.put("username", username);
pmap.put("password", password);
pmap.put("page",1);
pmap.put("rows",1000);
pmap.put("emp",queryParams.getUserName());
String post = HttpUtil.get(url+"open/information/getEmp.do",pmap);
JSONObject json = JSONObject.parseObject(JSONObject.parseObject(post).get("data").toString());
List<UserBaseInfoYwResult> userList = JSONObject.parseArray(json.get("rows").toString(), UserBaseInfoYwResult.class);
List<Map> onlineList = getOnLineList();
for (UserBaseInfoYwResult userBaseInfoYwResult : userList) {
UserBaseInfo userBaseInfo = new UserBaseInfo();
userBaseInfo.setDeviceCode(userBaseInfoYwResult.getDeviceno());
......@@ -114,6 +117,19 @@ public class YwLocationServiceImpl implements ILocationService {
userBaseInfo.setUserStatus("0");
list.add(userBaseInfo);
}
map.put("list",list);
map.put("onlineCount",onlineList.size());
return map;
}
public List<Map> getOnLineList(){
List<Map> list = new ArrayList<>();
HashMap<String,Object> map = new HashMap<>();
map.put("username", username);
map.put("password", password);
String post = HttpUtil.get(url+"/open/information/getRealInformation.do",map);
JSONObject json = JSONObject.parseObject(JSONObject.parseObject(post).get("data").toString());
list = JSONObject.parseArray(json.get("list").toString(), Map.class);
return list;
}
}
......
package com.skua.modules.location.vo;
import lombok.Data;
@Data
public class QueryParams {
/**人员名称*/
private String userName;
/**在线状态*/
private String userStatus;
}
package com.skua.modules.monitor.service;
import java.util.List;
import java.util.Map;
/**
* PG实时数据查询接口
*/
public interface IFmPgQueryService {
List<Map<String, Object>> queryFactoryMonitorFromRealTimeData(String factoryId, String fields);
}
package com.skua.modules.monitor.service.impl;
import com.skua.core.context.SpringContextUtils;
import org.apache.commons.lang.StringUtils;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import com.skua.modules.monitor.service.IFmPgQueryService;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
/**
* 数据指标信息表
*/
@Service
public class FmPgQueryServiceImpl implements IFmPgQueryService {
@Override
public List<Map<String, Object>> queryFactoryMonitorFromRealTimeData(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);
Date d=new Date();//获取时间
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
long todayTimeStemp = gettimeStemp(sdf.format(d)+" 00:00:00","yyyy-MM-dd");
//获取pg数据库时间,向前推采集频率的三倍时间,做数据容错
String sql = "select ts as time,nm as monitorId,v as monitorValue from realtimedata where nm in("+str.toString()+") and factoryname in ("+deviceIds+")";
List<Map<String, Object>> monitorList = pgDb.queryForList(sql);
Map<String,Object> map = new HashMap<>();
if(monitorList.size() > 0){
map.put("time",monitorList.get(0).get("time").toString());
for (int m = 0; m < monitorList.size(); m++) {
if(Long.parseLong(monitorList.get(m).get("time").toString()) > todayTimeStemp){
map.put(monitorList.get(m).get("monitorId").toString(),monitorList.get(m).get("monitorValue"));
}else{
map.put(monitorList.get(m).get("monitorId").toString(),0.00);
}
}
result.add(map);
}else{
return result;
}
return result;
}
public static void main(String[] args) {
Date d=new Date();//获取时间
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
System.out.println(gettimeStemp(sdf.format(d)+" 00:00:00","yyyy-MM-dd"));
}
public static long gettimeStemp(String time, String format) {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
if (!"".equals(format)) {
simpleDateFormat = new SimpleDateFormat(format);
}
long timeStemp = 0;
try {
Date date = simpleDateFormat.parse(time);
timeStemp = date.getTime();
} catch (ParseException e) {
e.printStackTrace();
}
return timeStemp/1000;
}
}
......@@ -57,7 +57,6 @@
</exclusion>
</exclusions>
</dependency>
<!-- online form -->
</dependencies>
<build>
......
......@@ -185,3 +185,10 @@ skua :
#cas单点登录
cas:
prefixUrl: http://cas.example.org:8443/cas
#微信相关
wx:
# 公众号
app-id: wxbdc5610cc59c1631
app-secret: xxxxxxxxxxxxxxxxxxxxxxx
redirect-url: https://passport.yhd.com/wechat/callback.do
......
......@@ -98,9 +98,9 @@ spring:
driver-class-name: com.mysql.jdbc.Driver
# 多数据源配置
pg-db:
url: jdbc:postgresql://120.24.205.69:10086/postgres?useUnicode=true&characterEncoding=UTF8
url: jdbc:postgresql://47.104.99.86:10086/postgres?useUnicode=true&characterEncoding=UTF8
username: postgres
password: server_2021_%Jksc
password: JKjnf9713xt
driver-class-name: org.postgresql.Driver
#redis 配置
redis:
......@@ -186,3 +186,10 @@ skua :
#cas单点登录
cas:
prefixUrl: http://cas.example.org:8443/cas
#微信相关
wx:
# 公众号
app-id: wxbdc5610cc59c1631
app-secret: xxxxxxxxxxxxxxxxxxxxxxx
redirect-url: https://passport.yhd.com/wechat/callback.do
......
......@@ -186,3 +186,10 @@ skua :
#cas单点登录
cas:
prefixUrl: http://cas.example.org:8443/cas
#微信相关
wx:
# 公众号
app-id: wxbdc5610cc59c1631
app-secret: xxxxxxxxxxxxxxxxxxxxxxx
redirect-url: https://passport.yhd.com/wechat/callback.do
......
......@@ -186,3 +186,9 @@ skua :
#cas单点登录
cas:
prefixUrl: http://cas.example.org:8443/cas
#微信相关
wx:
# 公众号
app-id: wxbdc5610cc59c1631
app-secret: xxxxxxxxxxxxxxxxxxxxxxx
redirect-url: https://passport.yhd.com/wechat/callback.do
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!