|
@@ -1,626 +0,0 @@
|
|
|
-package com.persagy.ibms.data.sdk.util;
|
|
|
-
|
|
|
-import java.io.File;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
-
|
|
|
-import com.alibaba.fastjson.JSON;
|
|
|
-import com.alibaba.fastjson.JSONObject;
|
|
|
-import com.persagy.ibms.data.sdk.data.SceneDataObject;
|
|
|
-import com.persagy.ibms.data.sdk.data.SceneDataPrimitive;
|
|
|
-import com.persagy.ibms.data.sdk.data.SceneDataSet;
|
|
|
-import com.persagy.ibms.data.sdk.data.SceneDataValue;
|
|
|
-import com.persagy.ibms.data.sdk.data.SceneObject;
|
|
|
-import com.persagy.ibms.data.sdk.data.SceneProperty;
|
|
|
-import com.sagacloud.ExpressionUtil;
|
|
|
-import com.sagacloud.advanced.expression.AdvancedExpressionScanner;
|
|
|
-import com.sagacloud.advanced.expression.AdvancedExpressionWalker;
|
|
|
-
|
|
|
-import lombok.extern.slf4j.Slf4j;
|
|
|
-
|
|
|
-@Slf4j
|
|
|
-public class ComputeUtil {
|
|
|
-
|
|
|
- public static void DoRepository(Repository Repository, boolean load_physical_world) throws Exception {
|
|
|
- if (load_physical_world) {
|
|
|
- log.warn("LoadPhysicalWorld");
|
|
|
- RWDLoadUtil.LoadPhysicalWorld(Repository);
|
|
|
- log.warn("LoadReference");
|
|
|
- RWDLoadUtil.LoadReference(Repository);
|
|
|
- log.warn("LoadAlarm");
|
|
|
- if (Constant.alarm_enable) {
|
|
|
- RWDLoadUtil.LoadAlarm(Repository, false);
|
|
|
- } else {
|
|
|
- RWDLoadUtil.LoadAlarm(Repository, true);
|
|
|
- }
|
|
|
- log.warn("LoadIBMSPhysicalWorld");
|
|
|
- RWDLoadUtil.LoadIBMSPhysicalWorld(Repository);
|
|
|
- } else {
|
|
|
- Repository.objTypeMap = RepositoryBase.instance.objTypeMap;
|
|
|
- Repository.code2objTypeMap = RepositoryBase.instance.code2objTypeMap;
|
|
|
- Repository.infoArrayDic = RepositoryBase.instance.infoArrayDic;
|
|
|
- Repository.objectArrayDic = RepositoryBase.instance.objectArrayDic;
|
|
|
- Repository.objectArrayAll = RepositoryBase.instance.objectArrayAll;
|
|
|
- Repository.objType2id2Value = RepositoryBase.instance.objType2id2Value;
|
|
|
- Repository.relationArrayDic = RepositoryBase.instance.relationArrayDic;
|
|
|
- Repository.id2object = RepositoryBase.instance.id2object;
|
|
|
- Repository.id2sdv = RepositoryBase.instance.id2sdv;
|
|
|
- Repository.IBMSArrayDic = RepositoryBase.instance.IBMSArrayDic;
|
|
|
- }
|
|
|
-
|
|
|
- log.warn("LoadConfig");
|
|
|
- SceneObject sceneObject = new SceneObject();
|
|
|
- JSONObject sceneJSON = FastJsonReaderUtil.Instance().ReadJSONObject(new File(Constant.getLatestPath(Constant.config, false)));
|
|
|
- FastJsonUtil.Set_JavaObject(sceneJSON, sceneObject);
|
|
|
- Repository.sceneObject = sceneObject;
|
|
|
-
|
|
|
- Repository.property2SDV_enable = true;
|
|
|
- Repository.property2SDV.clear();
|
|
|
- ComputeUtil.RefreshRepository(Repository);
|
|
|
- List<List<SceneProperty>> spListList = ComputeUtil.computePrepare(Repository);
|
|
|
- log.warn("computeAll");
|
|
|
- ComputeUtil.computeAll(Repository, spListList);
|
|
|
- try {
|
|
|
- DeamonUtil.Process(Repository);
|
|
|
- } catch (Exception e) {
|
|
|
- log.error(e.getMessage(), e);
|
|
|
- }
|
|
|
- Repository.property2SDV_enable = false;
|
|
|
- Repository.property2SDV.clear();
|
|
|
- }
|
|
|
-
|
|
|
- public static void RefreshRepository(Repository Repository) {
|
|
|
- Repository.o2p = new HashMap<SceneObject, SceneProperty>();
|
|
|
- Repository.p2p = new HashMap<SceneProperty, SceneProperty>();
|
|
|
- Repository.p2o = new HashMap<SceneProperty, SceneObject>();
|
|
|
- Repository.p2scanner = new HashMap<SceneProperty, AdvancedExpressionScanner>();
|
|
|
- Repository.p2walker = new HashMap<SceneProperty, AdvancedExpressionWalker>();
|
|
|
- RefreshObject(Repository, null, Repository.sceneObject, false);
|
|
|
- }
|
|
|
-
|
|
|
- private static void RefreshObject(Repository Repository, SceneProperty parentSP, SceneObject so, boolean so_is_sai) {
|
|
|
- if (parentSP != null) {
|
|
|
- if (so_is_sai) {
|
|
|
- Repository.sai2p.put(so, parentSP);
|
|
|
- } else {
|
|
|
- Repository.o2p.put(so, parentSP);
|
|
|
- }
|
|
|
- }
|
|
|
- for (SceneProperty sp : so.propertyList) {
|
|
|
- RefreshProperty(Repository, so, null, sp, so_is_sai);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private static void RefreshProperty(Repository Repository, SceneObject parentSO, SceneProperty parentSP, SceneProperty sp, boolean so_is_sai) {
|
|
|
- if (parentSO != null) {
|
|
|
- if (so_is_sai) {
|
|
|
- Repository.p2sai.put(sp, parentSO);
|
|
|
- } else {
|
|
|
- Repository.p2o.put(sp, parentSO);
|
|
|
- }
|
|
|
- }
|
|
|
- if (parentSP != null) {
|
|
|
- Repository.p2p.put(sp, parentSP);
|
|
|
- }
|
|
|
- if (sp.query_attached != null) {
|
|
|
- for (SceneProperty spInner : sp.query_attached) {
|
|
|
- RefreshProperty(Repository, null, sp, spInner, false);
|
|
|
- }
|
|
|
- }
|
|
|
- if (sp.custom_object != null) {
|
|
|
- RefreshObject(Repository, sp, sp.custom_object, false);
|
|
|
- }
|
|
|
- if (sp.static_array != null) {
|
|
|
- for (SceneObject SO : sp.static_array) {
|
|
|
- RefreshObject(Repository, sp, SO, true);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- public static List<List<SceneProperty>> computePrepare(Repository Repository) throws Exception {
|
|
|
- // 先整理顺序
|
|
|
- List<SceneProperty> spList = getAll(Repository.sceneObject);
|
|
|
- // 处理expression
|
|
|
- for (SceneProperty spInner : spList) {
|
|
|
- if (spInner.propertyValueType.equals("query")) {
|
|
|
- try {
|
|
|
- JSONObject sql_json = JSON.parseObject(spInner.query_sql);
|
|
|
- if (sql_json.containsKey("QueryType")) {
|
|
|
- String QueryType = (String) sql_json.get("QueryType");
|
|
|
- if (QueryType.equals("expression")) {
|
|
|
- String expression = (String) sql_json.get("expression");
|
|
|
- JSONObject CriteriaObject = (JSONObject) sql_json.get("Criteria");
|
|
|
- ExpressionUtil.buildAndPut(Repository, spInner, expression, CriteriaObject);
|
|
|
- }
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- log.error(spInner.query_sql);
|
|
|
- throw e;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- log.info("****************");
|
|
|
- for (SceneProperty spInner : spList) {
|
|
|
- // 打印路径
|
|
|
- {
|
|
|
- String path = getPropertyPath(Repository, spInner);
|
|
|
- log.info("getPropertyBefore:" + path);
|
|
|
- }
|
|
|
- {
|
|
|
- List<SceneProperty> beforeList = CheckUtil.getPropertyBefore(Repository, spInner);
|
|
|
- Repository.beforeDic.put(spInner, beforeList);
|
|
|
- for (SceneProperty spInner2 : beforeList) {
|
|
|
- log.info(getPropertyPath(Repository, spInner2));
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- Map<SceneProperty, Boolean> processedDic = new HashMap<SceneProperty, Boolean>();
|
|
|
- List<List<SceneProperty>> spListList = new ArrayList<List<SceneProperty>>();
|
|
|
- while (true) {
|
|
|
- int count_curr = 0;
|
|
|
- List<SceneProperty> spInnerList = new ArrayList<SceneProperty>();
|
|
|
- for (SceneProperty spInner : spList) {
|
|
|
- if (processedDic.containsKey(spInner)) {
|
|
|
- continue;
|
|
|
- }
|
|
|
- List<SceneProperty> beforeList = Repository.beforeDic.get(spInner);
|
|
|
- boolean all_finish = true;
|
|
|
- for (SceneProperty sp_before : beforeList) {
|
|
|
- if (!processedDic.containsKey(sp_before)) {
|
|
|
- all_finish = false;
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- if (all_finish) {
|
|
|
- count_curr++;
|
|
|
- spInnerList.add(spInner);
|
|
|
- }
|
|
|
- }
|
|
|
- if (count_curr == 0) {
|
|
|
- break;
|
|
|
- }
|
|
|
- spListList.add(spInnerList);
|
|
|
- for (SceneProperty spInner : spInnerList) {
|
|
|
- processedDic.put(spInner, true);
|
|
|
- }
|
|
|
- }
|
|
|
- log.info("****************************************************************");
|
|
|
- for (List<SceneProperty> spInnerList : spListList) {
|
|
|
- log.info("********************************");
|
|
|
- for (SceneProperty spInner2 : spInnerList) {
|
|
|
- log.info(getPropertyPath(Repository, spInner2));
|
|
|
- if (!Repository.property2SDV.containsKey(spInner2)) {
|
|
|
- Repository.property2SDV.put(spInner2, new ArrayList<SceneDataValue>());
|
|
|
- }
|
|
|
- }
|
|
|
- log.info("********************************");
|
|
|
- }
|
|
|
- log.info("****************************************************************");
|
|
|
-
|
|
|
- return spListList;
|
|
|
- }
|
|
|
-
|
|
|
- public static String getPropertyPath(Repository Repository, SceneProperty spInner) throws Exception {
|
|
|
- Object parentData = spInner;
|
|
|
- List<SceneProperty> tmpList = new ArrayList<SceneProperty>();
|
|
|
- while (true) {
|
|
|
- if (parentData == null) {
|
|
|
- break;
|
|
|
- }
|
|
|
- if (parentData instanceof SceneProperty) {
|
|
|
- SceneProperty tmpProperty = (SceneProperty) parentData;
|
|
|
- tmpList.add(tmpProperty);
|
|
|
- if (Repository.p2p.containsKey(tmpProperty)) {
|
|
|
- parentData = Repository.p2p.get(tmpProperty);
|
|
|
- } else if (Repository.p2o.containsKey(tmpProperty)) {
|
|
|
- parentData = Repository.o2p.get(Repository.p2o.get(tmpProperty));
|
|
|
- } else if (Repository.p2sai.containsKey(tmpProperty)) {
|
|
|
- parentData = Repository.p2sai.get(tmpProperty);
|
|
|
- } else {
|
|
|
- throw new Exception();
|
|
|
- }
|
|
|
- } else if (parentData instanceof SceneObject) {
|
|
|
- SceneObject tmpObject = (SceneObject) parentData;
|
|
|
- if (Repository.sai2p.containsKey(tmpObject)) {
|
|
|
- parentData = Repository.sai2p.get(tmpObject);
|
|
|
- } else if (parentData == Repository.sceneObject) {
|
|
|
- break;
|
|
|
- } else {
|
|
|
- throw new Exception();
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- StringBuffer sb = new StringBuffer();
|
|
|
- for (int i = tmpList.size() - 1; i >= 0; i--) {
|
|
|
- SceneProperty ss = tmpList.get(i);
|
|
|
- if (sb.length() > 0) {
|
|
|
- sb.append("-");
|
|
|
- }
|
|
|
- sb.append(ss.propertyName);
|
|
|
- }
|
|
|
- return sb.toString();
|
|
|
- }
|
|
|
-
|
|
|
- private static List<SceneProperty> getAll(SceneObject so) {
|
|
|
- List<SceneProperty> result = new ArrayList<SceneProperty>();
|
|
|
- for (SceneProperty sp : so.propertyList) {
|
|
|
- List<SceneProperty> resultinner = getAll(sp);
|
|
|
- result.addAll(resultinner);
|
|
|
- }
|
|
|
- return result;
|
|
|
- }
|
|
|
-
|
|
|
- private static List<SceneProperty> getAll(SceneProperty sp) {
|
|
|
- List<SceneProperty> result = new ArrayList<SceneProperty>();
|
|
|
- if (sp.propertyValueType.equals("static")) {
|
|
|
- result.add(sp);
|
|
|
- if (sp.propertyValueSchema.equals("JSONArray")) {
|
|
|
- if (sp.static_array == null) {
|
|
|
- sp.static_array = new SceneObject[0];
|
|
|
- }
|
|
|
- for (SceneObject SceneObject : sp.static_array) {
|
|
|
- List<SceneProperty> resultinner = getAll(SceneObject);
|
|
|
- result.addAll(resultinner);
|
|
|
- }
|
|
|
- if (sp.query_attached != null) {
|
|
|
- for (SceneProperty spInner : sp.query_attached) {
|
|
|
- List<SceneProperty> resultinner = getAll(spInner);
|
|
|
- result.addAll(resultinner);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- } else if (sp.propertyValueType.equals("query")) {
|
|
|
- result.add(sp);
|
|
|
- if (sp.query_attached != null) {
|
|
|
- for (SceneProperty spInner : sp.query_attached) {
|
|
|
- List<SceneProperty> resultinner = getAll(spInner);
|
|
|
- result.addAll(resultinner);
|
|
|
- }
|
|
|
- }
|
|
|
- } else if (sp.propertyValueType.equals("custom")) {
|
|
|
- if (sp.custom_object == null) {
|
|
|
- sp.custom_object = new SceneObject();
|
|
|
- }
|
|
|
- result = getAll(sp.custom_object);
|
|
|
- } else if (sp.propertyValueType.equals("deamon")) {
|
|
|
- result.add(sp);
|
|
|
- }
|
|
|
- return result;
|
|
|
- }
|
|
|
-
|
|
|
- public static void computeAll(Repository Repository, List<List<SceneProperty>> spListList) throws Exception {
|
|
|
- // 开始计算
|
|
|
- Repository.objectData = new SceneDataObject(Repository, null, null, null, Repository.sceneObject, null, null);
|
|
|
- for (List<SceneProperty> spInnerList : spListList) {
|
|
|
- for (SceneProperty spInner2 : spInnerList) {
|
|
|
- // 打印路径
|
|
|
- {
|
|
|
- Object parentData = spInner2;
|
|
|
- List<SceneProperty> tmpList = new ArrayList<SceneProperty>();
|
|
|
- while (true) {
|
|
|
- if (parentData == null) {
|
|
|
- break;
|
|
|
- }
|
|
|
- if (parentData instanceof SceneProperty) {
|
|
|
- SceneProperty tmpProperty = (SceneProperty) parentData;
|
|
|
- tmpList.add(tmpProperty);
|
|
|
- if (Repository.p2p.containsKey(tmpProperty)) {
|
|
|
- parentData = Repository.p2p.get(tmpProperty);
|
|
|
- } else if (Repository.p2o.containsKey(tmpProperty)) {
|
|
|
- parentData = Repository.o2p.get(Repository.p2o.get(tmpProperty));
|
|
|
- } else if (Repository.p2sai.containsKey(tmpProperty)) {
|
|
|
- parentData = Repository.p2sai.get(tmpProperty);
|
|
|
- } else {
|
|
|
- throw new Exception();
|
|
|
- }
|
|
|
- } else {
|
|
|
- SceneObject tmpObject = (SceneObject) parentData;
|
|
|
- if (Repository.sai2p.containsKey(tmpObject)) {
|
|
|
- parentData = Repository.sai2p.get(tmpObject);
|
|
|
- } else if (parentData == Repository.sceneObject) {
|
|
|
- break;
|
|
|
- } else {
|
|
|
- throw new Exception();
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- StringBuffer sb = new StringBuffer();
|
|
|
- for (int i = tmpList.size() - 1; i >= 0; i--) {
|
|
|
- SceneProperty ss = tmpList.get(i);
|
|
|
- if (sb.length() > 0) {
|
|
|
- sb.append("-");
|
|
|
- }
|
|
|
- sb.append(ss.propertyName);
|
|
|
- }
|
|
|
- log.info("computeOnce:" + sb.toString());
|
|
|
- // if (sb.toString().equals("基础对象-品质-公共照明-照明空间-清单-照明状态")) {
|
|
|
- // System.out.println();
|
|
|
- // }
|
|
|
- }
|
|
|
- // 打印路径
|
|
|
- List<SceneDataValue> sdvList = Repository.property2SDV.get(spInner2);
|
|
|
- for (SceneDataValue sdv : sdvList) {
|
|
|
- computeProperty(Repository, sdv);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- public static void computeProperty(Repository Repository, SceneDataValue sv) throws Exception {
|
|
|
- String svPath = RecursiveUtil.getDataPath(sv);
|
|
|
- log.debug(svPath);
|
|
|
- // if (svPath.equals("基础对象.设备.[电梯].设备类型.[直梯].清单.[Eq4403070003d6f62fb297c64106b3bd17517a5b7f0c].状态")) {
|
|
|
- // System.out.println();
|
|
|
- // }
|
|
|
- SceneDataObject objectData = sv.parentObjectData;
|
|
|
- SceneProperty sceneProperty = sv.rel_property;
|
|
|
- if (sceneProperty.propertyValueType.equals("static")) {
|
|
|
- if (sv.rel_property.propertyValueSchema.equals("JSONObject")) {
|
|
|
- sv.finish = true;
|
|
|
- } else if (sv.rel_property.propertyValueSchema.equals("JSONArray")) {
|
|
|
- boolean finish = true;
|
|
|
- for (SceneDataObject sdbInner : sv.value_array.set) {
|
|
|
- if (sdbInner instanceof SceneDataObject) {
|
|
|
- SceneDataObject SODInner = (SceneDataObject) sdbInner;
|
|
|
- for (String keySOD : SODInner.keySet()) {
|
|
|
- SceneDataValue SVInner = SODInner.get(keySOD);
|
|
|
- if (!SVInner.finish) {
|
|
|
- finish = false;
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- if (!finish) {
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- if (finish) {
|
|
|
- sv.finish = true;
|
|
|
- }
|
|
|
- } else {
|
|
|
- sv.value_prim = new SceneDataPrimitive();
|
|
|
- sv.value_prim.value = QueryUtil.parse_static(sceneProperty.propertyValueSchema, sceneProperty.static_value);
|
|
|
- sv.value_prim.change = false;
|
|
|
- sv.finish = true;
|
|
|
- }
|
|
|
- } else if (sceneProperty.propertyValueType.equals("query")) {
|
|
|
- JSONObject sql_json = (JSONObject) JSON.parse(sceneProperty.query_sql);
|
|
|
- Object queryResult = QueryUtil.query(Repository, sv, sql_json, new QueryAssist());
|
|
|
- if (sceneProperty.propertyValueSchema.equals("JSONObject")) {
|
|
|
- // 结果集的聚合选择等等
|
|
|
- SceneDataObject queryResultObject = null;
|
|
|
- if (queryResult instanceof SceneDataObject) {
|
|
|
- queryResultObject = (SceneDataObject) queryResult;
|
|
|
- } else if (queryResult instanceof SceneDataSet) {
|
|
|
- SceneDataSet queryResultArray = (SceneDataSet) queryResult;
|
|
|
- if (queryResultArray.set.size() == 1) {
|
|
|
- queryResultObject = queryResultArray.set.get(0);
|
|
|
- }
|
|
|
- }
|
|
|
- sv.value_object = new SceneDataObject(Repository, objectData, sceneProperty.propertyName, null, null, sceneProperty.query_attached,
|
|
|
- queryResultObject);
|
|
|
- if (queryResult instanceof SceneDataObject) {
|
|
|
- queryResultObject = (SceneDataObject) queryResult;
|
|
|
- sv.value_object.setRowChange(queryResultObject.getRowChange());
|
|
|
- sv.value_object.setColChange(queryResultObject.getColChange());
|
|
|
- } else if (queryResult instanceof SceneDataSet) {
|
|
|
- SceneDataSet queryResultArray = (SceneDataSet) queryResult;
|
|
|
- sv.value_object.setRowChange(queryResultArray.getRowChange());
|
|
|
- sv.value_object.setColChange(queryResultArray.getColChange());
|
|
|
- }
|
|
|
- } else if (sceneProperty.propertyValueSchema.equals("JSONArray")) {
|
|
|
- SceneDataSet array = (SceneDataSet) queryResult;
|
|
|
- if (array.isSingleValueSet) {
|
|
|
- sv.value_array = new SceneDataSet(true);
|
|
|
- for (int i = 0; i < array.singleValueSet.size(); i++) {
|
|
|
- SceneDataValue arrayItem = array.singleValueSet.get(i);
|
|
|
- SceneDataValue sod = new SceneDataValue(Repository, null, null, null);
|
|
|
- sod.value_prim = new SceneDataPrimitive();
|
|
|
- sod.value_prim.value = arrayItem.value_prim.value;
|
|
|
- sv.value_array.singleValueSet.add(sod);
|
|
|
- }
|
|
|
- } else {
|
|
|
- sv.value_array = new SceneDataSet(false);
|
|
|
- for (int i = 0; i < array.set.size(); i++) {
|
|
|
- SceneDataObject arrayItem = array.set.get(i);
|
|
|
- SceneDataObject sod = new SceneDataObject(Repository, null, null, sv, null, sceneProperty.query_attached, arrayItem);
|
|
|
- sv.value_array.set.add(sod);
|
|
|
- }
|
|
|
- }
|
|
|
- sv.value_array.setRowChange(array.getRowChange());
|
|
|
- sv.value_array.setColChange(array.getColChange());
|
|
|
- } else {
|
|
|
- sv.value_prim = new SceneDataPrimitive();
|
|
|
- // 计算并放入objectData中
|
|
|
- if (queryResult instanceof SceneDataSet) {
|
|
|
- SceneDataSet sdvListInner = (SceneDataSet) queryResult;
|
|
|
- if (sdvListInner.singleValueSet.size() == 0) {
|
|
|
- } else if (sdvListInner.singleValueSet.size() == 1) {
|
|
|
- sv.value_prim.value = sdvListInner.singleValueSet.get(0).value_prim.value;
|
|
|
- } else {
|
|
|
- }
|
|
|
- sv.value_prim.setRowChange(sdvListInner.getRowChange());
|
|
|
- } else {
|
|
|
- SceneDataPrimitive sdp = (SceneDataPrimitive) queryResult;
|
|
|
- sv.value_prim.value = sdp.value;
|
|
|
- sv.value_prim.setRowChange(sdp.getRowChange());
|
|
|
- }
|
|
|
- if (sv.value_prim.getRowChange()) {
|
|
|
- // 需要向上影响ColChange
|
|
|
- if (sv.parentObjectData.parentArrayData != null) {
|
|
|
- if (!sv.parentObjectData.parentArrayData.value_array.getRowChange()) {
|
|
|
- sv.parentObjectData.parentArrayData.value_array.setColChange(sv.myPropertyName);
|
|
|
- }
|
|
|
- } else {
|
|
|
- if (!sv.parentObjectData.getRowChange()) {
|
|
|
- sv.parentObjectData.setColChange(sv.myPropertyName);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- if (sceneProperty.propertyValueSchema.equals("int")) {
|
|
|
- if (sv.value_prim.value != null) {
|
|
|
- Object jt = sv.value_prim.value;
|
|
|
- int jtValue;
|
|
|
- if (jt instanceof Integer) {
|
|
|
- jtValue = ((Integer) jt).intValue();
|
|
|
- } else if (jt instanceof Long) {
|
|
|
- jtValue = ((Long) jt).intValue();
|
|
|
- } else if (jt instanceof Float) {
|
|
|
- jtValue = ((Float) jt).intValue();
|
|
|
- } else {
|
|
|
- jtValue = ((Double) jt).intValue();
|
|
|
- }
|
|
|
- sv.value_prim.value = jtValue;
|
|
|
- }
|
|
|
- } else if (sceneProperty.propertyValueSchema.equals("double")) {
|
|
|
- if (sv.value_prim.value != null) {
|
|
|
- Object jt = sv.value_prim.value;
|
|
|
- double jtValue;
|
|
|
- if (jt instanceof Integer) {
|
|
|
- jtValue = ((Integer) jt).doubleValue();
|
|
|
- } else if (jt instanceof Long) {
|
|
|
- jtValue = ((Long) jt).doubleValue();
|
|
|
- } else if (jt instanceof Float) {
|
|
|
- jtValue = ((Float) jt).doubleValue();
|
|
|
- } else {
|
|
|
- jtValue = ((Double) jt).doubleValue();
|
|
|
- }
|
|
|
- sv.value_prim.value = jtValue;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- sv.finish = true;
|
|
|
- } else if (sceneProperty.propertyValueType.equals("custom")) {
|
|
|
- if (sv.value_object == null) {
|
|
|
- sv.value_object = new SceneDataObject(Repository, objectData, sceneProperty.propertyName, null, sceneProperty.custom_object, null,
|
|
|
- null);
|
|
|
- }
|
|
|
- } else if (sceneProperty.propertyValueType.equals("deamon")) {
|
|
|
- JSONObject sql_json = (JSONObject) JSON.parse(sceneProperty.query_sql);
|
|
|
- String QueryType = (String) sql_json.get("QueryType");
|
|
|
- if (QueryType.endsWith("trend")) {
|
|
|
- sv.value_prim = new SceneDataPrimitive();
|
|
|
- sv.value_prim.value = 0;
|
|
|
- sv.value_prim.setRowChange(true);
|
|
|
- } else if (QueryType.endsWith("curve")) {
|
|
|
- sv.value_array = new SceneDataSet(false);
|
|
|
- sv.value_array.set = new ArrayList<SceneDataObject>();
|
|
|
- sv.value_array.setRowChange(true);
|
|
|
- }
|
|
|
- JSONObject Criteria = (JSONObject) sql_json.get("Criteria");
|
|
|
- List<String> pointList = new ArrayList<String>();
|
|
|
- for (String key : Criteria.keySet()) {
|
|
|
- JSONObject CriteriaItemValue = (JSONObject) Criteria.get(key);
|
|
|
- String refString = (String) CriteriaItemValue.get("ref");
|
|
|
- SceneDataSet sdvList = QueryUtil.parseSetRef(Repository, sv, refString, new QueryAssist(), false, true);
|
|
|
- for (SceneDataValue sdvInner : sdvList.singleValueSet) {
|
|
|
- String point = RepositoryBase.sdv2point.get(sdvInner);
|
|
|
- pointList.add(point);
|
|
|
- }
|
|
|
- }
|
|
|
- Repository.deamon_sdv2pointList.put(sv, pointList);
|
|
|
- }
|
|
|
- sv.last_compute_time = new Date();
|
|
|
- }
|
|
|
-
|
|
|
- public static Object getValueObject(Repository Repository, String[] valuePath) {
|
|
|
- int index = 0;
|
|
|
- Object tmpData = Repository.objectData.get(valuePath[index]);
|
|
|
- index++;
|
|
|
- while (index < valuePath.length) {
|
|
|
- if (tmpData instanceof SceneDataValue) {
|
|
|
- SceneDataValue currData = (SceneDataValue) tmpData;
|
|
|
- currData = currData.value_object.get(valuePath[index]);
|
|
|
- tmpData = currData;
|
|
|
- if (currData.value_array != null) {
|
|
|
- if (index < valuePath.length - 1) {
|
|
|
- index++;
|
|
|
- SceneDataObject matchItem = null;
|
|
|
- for (SceneDataObject sdbInner : currData.value_array.set) {
|
|
|
- SceneDataObject sodInner = (SceneDataObject) sdbInner;
|
|
|
- if (sodInner.containsKey("id") && sodInner.get("id").value_prim.value.equals(valuePath[index])) {
|
|
|
- matchItem = sodInner;
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- if (matchItem == null) {
|
|
|
- for (SceneDataObject sdbInner : currData.value_array.set) {
|
|
|
- SceneDataObject sodInner = (SceneDataObject) sdbInner;
|
|
|
- if (sodInner.containsKey("名称") && sodInner.get("名称").value_prim.value.equals(valuePath[index])) {
|
|
|
- matchItem = sodInner;
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- tmpData = matchItem;
|
|
|
- }
|
|
|
- }
|
|
|
- } else if (tmpData instanceof SceneDataObject) {
|
|
|
- SceneDataObject currSOD = (SceneDataObject) tmpData;
|
|
|
- SceneDataValue currData = currSOD.get(valuePath[index]);
|
|
|
- tmpData = currData;
|
|
|
- if (currData.value_array != null) {
|
|
|
- if (index < valuePath.length - 1) {
|
|
|
- index++;
|
|
|
- SceneDataObject matchItem = null;
|
|
|
- for (SceneDataObject sdbInner : currData.value_array.set) {
|
|
|
- SceneDataObject sodInner = (SceneDataObject) sdbInner;
|
|
|
- if (sodInner.containsKey("id") && sodInner.get("id").value_prim.value.equals(valuePath[index])) {
|
|
|
- matchItem = sodInner;
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- if (matchItem == null) {
|
|
|
- for (SceneDataObject sdbInner : currData.value_array.set) {
|
|
|
- SceneDataObject sodInner = (SceneDataObject) sdbInner;
|
|
|
- if (sodInner.containsKey("名称") && sodInner.get("名称").value_prim.value.equals(valuePath[index])) {
|
|
|
- matchItem = sodInner;
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- tmpData = matchItem;
|
|
|
- }
|
|
|
- }
|
|
|
- } else {
|
|
|
- break;
|
|
|
- }
|
|
|
-
|
|
|
- index++;
|
|
|
- }
|
|
|
- return tmpData;
|
|
|
- }
|
|
|
-
|
|
|
- public static Object getValueJSON(Object tmpData) {
|
|
|
- Object result;
|
|
|
- if (tmpData instanceof SceneDataValue) {
|
|
|
- SceneDataValue currData = (SceneDataValue) tmpData;
|
|
|
- int read_level = currData.rel_property == null ? 1 : Integer.parseInt(currData.rel_property.read_level);
|
|
|
- result = currData.toJSON(true, read_level == 0 ? -1 : read_level);
|
|
|
- } else {
|
|
|
- SceneDataObject currData = (SceneDataObject) tmpData;
|
|
|
- int read_level = (currData.parentArrayData != null && currData.parentArrayData.rel_property != null)
|
|
|
- ? Integer.parseInt(currData.parentArrayData.rel_property.read_level) : 1;
|
|
|
- result = currData.toJSON(read_level == 0 ? -1 : read_level);
|
|
|
- }
|
|
|
-
|
|
|
- return result;
|
|
|
- }
|
|
|
-
|
|
|
- public static Object getValueJSON(Object tmpData, int read_level) {
|
|
|
- Object result;
|
|
|
- if (tmpData instanceof SceneDataValue) {
|
|
|
- SceneDataValue currData = (SceneDataValue) tmpData;
|
|
|
- result = currData.toJSON(true, read_level == 0 ? -1 : read_level);
|
|
|
- } else {
|
|
|
- SceneDataObject currData = (SceneDataObject) tmpData;
|
|
|
- result = currData.toJSON(read_level == 0 ? -1 : read_level);
|
|
|
- }
|
|
|
-
|
|
|
- return result;
|
|
|
- }
|
|
|
-}
|