|
@@ -3,7 +3,6 @@ package com.persagy.ibms.data.sdk.util;
|
|
|
import java.io.BufferedInputStream;
|
|
|
import java.io.FileInputStream;
|
|
|
|
|
|
-import com.persagy.ibms.data.sdk.service.rest.RestUtil;
|
|
|
import org.apache.poi.ss.usermodel.Cell;
|
|
|
import org.apache.poi.ss.usermodel.Row;
|
|
|
import org.apache.poi.ss.usermodel.Sheet;
|
|
@@ -13,9 +12,8 @@ import org.apache.poi.ss.util.CellRangeAddress;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
-import com.persagy.ibms.core.data.SceneDataObject;
|
|
|
-import com.persagy.ibms.core.data.SceneDataSet;
|
|
|
import com.persagy.ibms.core.util.FileUtil;
|
|
|
+import com.persagy.ibms.data.sdk.service.rest.RestUtil;
|
|
|
|
|
|
public class ExeclReadEquipStaticInfoUtil {
|
|
|
|
|
@@ -48,30 +46,37 @@ public class ExeclReadEquipStaticInfoUtil {
|
|
|
}
|
|
|
|
|
|
public static JSONObject ReadEquipStaticInfoById(String objId) throws Exception {
|
|
|
- RepositoryImpl Repository = RepositoryContainer.instance;
|
|
|
String ibmsSceneCode = null;
|
|
|
String ibmsClassCode = null;
|
|
|
- JSONObject queryTarget=new JSONObject();
|
|
|
- queryTarget.put("Source","rwd");
|
|
|
- queryTarget.put("rwd","object");
|
|
|
- queryTarget.put("objType","equipment");
|
|
|
- JSONObject queryCriteria=new JSONObject();
|
|
|
- queryCriteria.put("id",objId);
|
|
|
- JSONObject queryParam=new JSONObject();
|
|
|
- queryParam.put("QueryType","select");
|
|
|
- queryParam.put("Target",queryTarget);
|
|
|
- queryParam.put("Criteria",queryCriteria);
|
|
|
- String queryResult= RestUtil.query(queryParam.toString());
|
|
|
- JSONArray queryArr= JSONObject.parseArray(queryResult);
|
|
|
- JSONObject queryObj=queryArr.getJSONObject(0);
|
|
|
- ibmsSceneCode=queryObj.getString("ibmsSceneCode");
|
|
|
- ibmsClassCode=queryObj.getString("ibmsClassCode");
|
|
|
- String classCode=queryObj.getString("classCode");
|
|
|
+ JSONObject queryTarget = new JSONObject();
|
|
|
+ queryTarget.put("Source", "rwd");
|
|
|
+ queryTarget.put("rwd", "object");
|
|
|
+ queryTarget.put("objType", "equipment");
|
|
|
+ JSONObject queryCriteria = new JSONObject();
|
|
|
+ queryCriteria.put("id", objId);
|
|
|
+ JSONObject queryParam = new JSONObject();
|
|
|
+ queryParam.put("QueryType", "select");
|
|
|
+ queryParam.put("Target", queryTarget);
|
|
|
+ queryParam.put("Criteria", queryCriteria);
|
|
|
+ String queryResult = RestUtil.query(queryParam.toString());
|
|
|
+ JSONArray queryArr = JSONObject.parseArray(queryResult);
|
|
|
+ JSONObject queryObj = queryArr.getJSONObject(0);
|
|
|
+ ibmsSceneCode = queryObj.getString("ibmsSceneCode");
|
|
|
+ ibmsClassCode = queryObj.getString("ibmsClassCode");
|
|
|
+ String classCode = queryObj.getString("classCode");
|
|
|
JSONObject object = new JSONObject();
|
|
|
// 如果ibmsClassCode和ibmsSceneCode为空则返回,意味着查询失败
|
|
|
if (ibmsSceneCode == null && ibmsClassCode == null) {
|
|
|
return object;
|
|
|
}
|
|
|
+ object = ReadEquipStaticInfoById(ibmsSceneCode, ibmsClassCode, classCode, queryObj);
|
|
|
+ return object;
|
|
|
+ }
|
|
|
+
|
|
|
+ public static JSONObject ReadEquipStaticInfoById(String ibmsSceneCode, String ibmsClassCode, String classCode, JSONObject queryObj)
|
|
|
+ throws Exception {
|
|
|
+ RepositoryImpl Repository = RepositoryContainer.instance;
|
|
|
+ JSONObject object = new JSONObject();
|
|
|
// 根据ibmsSceneCode和ibmsClassCode查询对应的excel获取台账信息点
|
|
|
FileInputStream fis = new FileInputStream(FileUtil.file(ibmsSceneCode + ".xlsx"));
|
|
|
Workbook workbook = WorkbookFactory.create(new BufferedInputStream(fis));
|
|
@@ -94,7 +99,9 @@ public class ExeclReadEquipStaticInfoUtil {
|
|
|
JSONObject obj = (JSONObject) array.get(z);
|
|
|
String codeVal = obj.get("code").toString();
|
|
|
if (codeVal.equals(codeInfo)) {
|
|
|
- obj.put("data", queryObj.get(codeInfo));
|
|
|
+ if (queryObj != null) {
|
|
|
+ obj.put("data", queryObj.get(codeInfo));
|
|
|
+ }
|
|
|
obj.put("enable", row.getCell(2).getBooleanCellValue());
|
|
|
dic.add(obj);
|
|
|
break;
|