|
@@ -1,6 +1,8 @@
|
|
|
package com.persagy.ibms.data.sdk.util;
|
|
|
|
|
|
+import java.text.ParseException;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
+import java.util.Calendar;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
@@ -83,6 +85,92 @@ public class RepositoryImpl extends RepositoryBase {
|
|
|
long interval_between_compute) {
|
|
|
super(use_thread, enable_factor, thread_count, interval_between_compute);
|
|
|
this.RepositoryProject = RepositoryProject;
|
|
|
+ this.base_value = generate_base_value();
|
|
|
+ }
|
|
|
+
|
|
|
+ public static boolean accelerate_enable = false;
|
|
|
+ public static long accelerate_ratio = 60 * 60 * 24;
|
|
|
+ public static String init_timeString = "2021-01-01 00:00:00";
|
|
|
+ public static Date init_time;
|
|
|
+ public static Date start_time;
|
|
|
+
|
|
|
+ public static Map<String, SceneDataValue> generate_base_value() {
|
|
|
+ Map<String, SceneDataValue> base_value = new ConcurrentHashMap<String, SceneDataValue>();
|
|
|
+ Calendar calendar = Calendar.getInstance();
|
|
|
+ Map<String, Date> timeMap = new ConcurrentHashMap<String, Date>();
|
|
|
+ Map<String, SimpleDateFormat> sdfMap = new ConcurrentHashMap<String, SimpleDateFormat>();
|
|
|
+ sdfMap.put("simple", new SimpleDateFormat("yyyyMMddHHmmss"));
|
|
|
+ sdfMap.put("normal", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"));
|
|
|
+ sdfMap.put("T", new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"));
|
|
|
+
|
|
|
+ Date currTime = new Date();
|
|
|
+ if (accelerate_enable) {
|
|
|
+ if (init_time == null) {
|
|
|
+ try {
|
|
|
+ init_time = sdfMap.get("normal").parse(init_timeString);
|
|
|
+ } catch (ParseException e) {
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (start_time == null) {
|
|
|
+ start_time = currTime;
|
|
|
+ }
|
|
|
+
|
|
|
+ currTime = new Date(init_time.getTime() + (currTime.getTime() - start_time.getTime()) * accelerate_ratio);
|
|
|
+ }
|
|
|
+ Date today = new Date((currTime.getTime() + (1000L * 60 * 60 * 8)) / (1000L * 60 * 60 * 24) * (1000L * 60 * 60 * 24) - (1000L * 60 * 60 * 8));
|
|
|
+ {
|
|
|
+ calendar.setTime(today);
|
|
|
+ timeMap.put("curr_day", calendar.getTime());
|
|
|
+ calendar.add(Calendar.DAY_OF_MONTH, -1);
|
|
|
+ timeMap.put("last_day", calendar.getTime());
|
|
|
+ calendar.add(Calendar.DAY_OF_MONTH, +1);
|
|
|
+ calendar.add(Calendar.DAY_OF_MONTH, +1);
|
|
|
+ timeMap.put("next_day", calendar.getTime());
|
|
|
+ }
|
|
|
+ {
|
|
|
+ calendar.setTime(today);
|
|
|
+ calendar.set(Calendar.DAY_OF_WEEK, 1);
|
|
|
+ timeMap.put("curr_week", calendar.getTime());
|
|
|
+ calendar.add(Calendar.WEEK_OF_MONTH, -1);
|
|
|
+ timeMap.put("last_week", calendar.getTime());
|
|
|
+ calendar.add(Calendar.WEEK_OF_MONTH, +1);
|
|
|
+ calendar.add(Calendar.WEEK_OF_MONTH, +1);
|
|
|
+ timeMap.put("next_week", calendar.getTime());
|
|
|
+ }
|
|
|
+ {
|
|
|
+ calendar.setTime(today);
|
|
|
+ calendar.set(Calendar.DAY_OF_MONTH, 1);
|
|
|
+ timeMap.put("curr_month", calendar.getTime());
|
|
|
+ calendar.add(Calendar.MONTH, -1);
|
|
|
+ timeMap.put("last_month", calendar.getTime());
|
|
|
+ calendar.add(Calendar.MONTH, +1);
|
|
|
+ calendar.add(Calendar.MONTH, +1);
|
|
|
+ timeMap.put("next_month", calendar.getTime());
|
|
|
+ }
|
|
|
+ {
|
|
|
+ calendar.setTime(today);
|
|
|
+ calendar.set(Calendar.DAY_OF_MONTH, 1);
|
|
|
+ calendar.set(Calendar.MONTH, 0);
|
|
|
+ timeMap.put("curr_year", calendar.getTime());
|
|
|
+ calendar.add(Calendar.YEAR, -1);
|
|
|
+ timeMap.put("last_year", calendar.getTime());
|
|
|
+ calendar.add(Calendar.YEAR, +1);
|
|
|
+ calendar.add(Calendar.YEAR, +1);
|
|
|
+ timeMap.put("next_year", calendar.getTime());
|
|
|
+ }
|
|
|
+
|
|
|
+ for (String key : timeMap.keySet()) {
|
|
|
+ for (String sdfKey : sdfMap.keySet()) {
|
|
|
+ SimpleDateFormat sdf = sdfMap.get(sdfKey);
|
|
|
+ SceneDataValue SceneDataValue = new SceneDataValue(null, null, null, null);
|
|
|
+ SceneDataValue.value_prim = new SceneDataPrimitive();
|
|
|
+ SceneDataValue.value_prim.change = true;
|
|
|
+ SceneDataValue.value_prim.value = sdf.format(timeMap.get(key));
|
|
|
+ base_value.put(key + "_" + sdfKey, SceneDataValue);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return base_value;
|
|
|
}
|
|
|
|
|
|
public void copyFromRepositoryContainer() {
|