|
@@ -12,8 +12,7 @@ import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.text.ParseException;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.List;
|
|
|
+import java.util.*;
|
|
|
|
|
|
/**
|
|
|
* @author Wang Jiawen
|
|
@@ -24,58 +23,83 @@ import java.util.List;
|
|
|
@Service
|
|
|
public class TargetdetailService extends SocketToolService {
|
|
|
|
|
|
- static String point = "";
|
|
|
+ public static Map<String,String> targetdetail_target_pointMap = new HashMap<>();
|
|
|
+ public static Map<String,String> targetdetail_curve_pointMap = new HashMap<>();
|
|
|
+ public static Map<String,String> targetdetail_histogram_pointMap = new HashMap<>();
|
|
|
|
|
|
public void targetdetail_target() throws Exception {
|
|
|
+ Set set = targetdetail_target_pointMap.keySet();
|
|
|
+ Iterator<String> it = set.iterator();
|
|
|
IMongodbUtil mongodb = new MongodbUtilImpl();
|
|
|
-//查看实时数据
|
|
|
- PointData real=mongodb.getRealData("HB_GD_KBF_JS_P4_L19_220_CI0136");
|
|
|
- double pointValueInDouble = real.getPointValueInDouble();
|
|
|
- this.pushToWeb("pageNumber_8","functionNumber_1",pointValueInDouble, Messagetype.MESSAGE);
|
|
|
+ Map<String,Double> pointDataMap = new HashMap();
|
|
|
+ while(it.hasNext()){
|
|
|
+ String ip = it.next();
|
|
|
+ PointData real=mongodb.getRealData(targetdetail_target_pointMap.get(ip));
|
|
|
+ double pointValueInDouble = real.getPointValueInDouble();
|
|
|
+ pointDataMap.put(ip,pointValueInDouble);
|
|
|
+ }
|
|
|
+
|
|
|
+ this.pushToWeb("pageNumber_8","functionNumber_1",pointDataMap, Messagetype.MESSAGE);
|
|
|
}
|
|
|
|
|
|
public void targetdetail_curve() throws Exception {
|
|
|
+ Set set = targetdetail_curve_pointMap.keySet();
|
|
|
+ Iterator<String> it = set.iterator();
|
|
|
IMongodbUtil mongodb = new MongodbUtilImpl();
|
|
|
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH");
|
|
|
- Date nowTime = DateUtils.getNowDate();
|
|
|
- Date endTime = sdf.parse(sdf.format(nowTime));
|
|
|
- SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
- Date beginTime = sdf1.parse(sdf1.format(nowTime));
|
|
|
- Long count = (endTime.getTime()-beginTime.getTime())/1000L/3600L;
|
|
|
- List<PointData> ls = mongodb.getHistoryDatasSnap("HB_GD_KBF_JS_P4_L19_220_CI0136",
|
|
|
- beginTime.getTime() / 1000, endTime.getTime() / 1000,
|
|
|
- (long) count, 3600L);
|
|
|
- for(int i=0;i<ls.size();i++){
|
|
|
- ls.get(i).setPointTime(ls.get(i).getPointTime()-3600);
|
|
|
+ Map<String,List<PointData>> pointDataMap = new HashMap();
|
|
|
+ while(it.hasNext()) {
|
|
|
+ String ip = it.next();
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH");
|
|
|
+ Date nowTime = DateUtils.getNowDate();
|
|
|
+ Date endTime = sdf.parse(sdf.format(nowTime));
|
|
|
+ SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ Date beginTime = sdf1.parse(sdf1.format(nowTime));
|
|
|
+ Long count = (endTime.getTime() - beginTime.getTime()) / 1000L / 3600L;
|
|
|
+ List<PointData> ls = mongodb.getHistoryDatasSnap(targetdetail_curve_pointMap.get(ip),
|
|
|
+ beginTime.getTime() / 1000, endTime.getTime() / 1000,
|
|
|
+ (long) count, 3600L);
|
|
|
+ for (int i = 0; i < ls.size(); i++) {
|
|
|
+ ls.get(i).setPointTime(ls.get(i).getPointTime() - 3600);
|
|
|
+ }
|
|
|
+ if(ls.size()>0) {
|
|
|
+ ls.remove(0);
|
|
|
+ }
|
|
|
+ pointDataMap.put(ip,ls);
|
|
|
}
|
|
|
- ls.remove(0);
|
|
|
-
|
|
|
/* if (!ls.isEmpty()) {
|
|
|
ls.forEach(obj -> System.out.println(obj.getEdnaId() + "___" +obj.getPointTime() + "___" + obj.getPointValueInDouble()));
|
|
|
}
|
|
|
for(PointData obj:ls){
|
|
|
System.out.println(obj.getEdnaId() + "___" +obj.getPointTime() + "___" + obj.getPointValueInDouble());
|
|
|
}*/
|
|
|
- this.pushToWeb("pageNumber_8","functionNumber_2",ls, Messagetype.MESSAGE);
|
|
|
+ this.pushToWeb("pageNumber_8","functionNumber_2",pointDataMap, Messagetype.MESSAGE);
|
|
|
}
|
|
|
|
|
|
public void targetdetail_histogram() throws Exception {
|
|
|
+ Set set = targetdetail_histogram_pointMap.keySet();
|
|
|
+ Iterator<String> it = set.iterator();
|
|
|
IMongodbUtil mongodb = new MongodbUtilImpl();
|
|
|
- Date nowTime = DateUtils.getNowDate();
|
|
|
- SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
- Date endTime = sdf1.parse(sdf1.format(nowTime));
|
|
|
- Date beginTime = DateUtils.addDays(endTime, -7);
|
|
|
+ Map<String,List<PointData>> pointDataMap = new HashMap();
|
|
|
+ while(it.hasNext()) {
|
|
|
+ String ip = it.next();
|
|
|
+ Date nowTime = DateUtils.getNowDate();
|
|
|
+ SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ Date endTime = sdf1.parse(sdf1.format(nowTime));
|
|
|
+ Date beginTime = DateUtils.addDays(endTime, -7);
|
|
|
//查看历史快照数据
|
|
|
- List<PointData> ls = mongodb.getHistoryDatasSnap("HB_GD_KBF_JS_P4_L19_220_CI0136",
|
|
|
- beginTime.getTime() / 1000, endTime.getTime() / 1000,
|
|
|
- 7L, 3600*24L);
|
|
|
- for (int i=0;i<ls.size();i++){
|
|
|
- ls.get(i).setPointTime(ls.get(i).getPointTime()-24*3600);
|
|
|
+ List<PointData> ls = mongodb.getHistoryDatasSnap(targetdetail_histogram_pointMap.get(ip),
|
|
|
+ beginTime.getTime() / 1000, endTime.getTime() / 1000,
|
|
|
+ 7L, 3600 * 24L);
|
|
|
+ for (int i = 0; i < ls.size(); i++) {
|
|
|
+ ls.get(i).setPointTime(ls.get(i).getPointTime() - 24 * 3600);
|
|
|
+ }
|
|
|
+ ls.remove(0);
|
|
|
+ pointDataMap.put(ip,ls);
|
|
|
}
|
|
|
- ls.remove(0);
|
|
|
+
|
|
|
/*if (!ls.isEmpty()) {
|
|
|
ls.forEach(obj -> System.out.println(obj.getEdnaId() + "___" +obj.getPointTime() + "___" + obj.getPointValueInDouble()));
|
|
|
}*/
|
|
|
- this.pushToWeb("pageNumber_8","functionNumber_3",ls, Messagetype.MESSAGE);
|
|
|
+ this.pushToWeb("pageNumber_8","functionNumber_3",pointDataMap, Messagetype.MESSAGE);
|
|
|
}
|
|
|
}
|