|
@@ -12,39 +12,13 @@ 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.util.FastJsonUtil;
|
|
|
import com.persagy.ibms.core.util.FileUtil;
|
|
|
import com.persagy.ibms.data.sdk.service.rest.RestUtil;
|
|
|
|
|
|
public class ExeclReadEquipStaticInfoUtil {
|
|
|
|
|
|
- public static JSONObject ReadEquipStaticInfo(String firstName, String sheetName) throws Exception {
|
|
|
- FileInputStream fis = new FileInputStream(FileUtil.file(firstName + ".xlsx"));
|
|
|
- Workbook workbook = WorkbookFactory.create(new BufferedInputStream(fis));
|
|
|
- Sheet sheet = workbook.getSheet(sheetName);
|
|
|
- JSONObject object = new JSONObject();
|
|
|
- for (int i = 0; i < sheet.getNumMergedRegions(); i++) {
|
|
|
- // 获取合并单元格的值
|
|
|
- CellRangeAddress ca = sheet.getMergedRegion(i);
|
|
|
- int firstRow = ca.getFirstRow();
|
|
|
- Row fRow = sheet.getRow(firstRow);
|
|
|
- Cell fCell = fRow.getCell(0);
|
|
|
- String caVal = getCellValue(fCell);
|
|
|
- // 获取合并单元格之后的值,形成树形结构
|
|
|
- JSONArray dic = new JSONArray();
|
|
|
- for (int j = firstRow; j <= ca.getLastRow(); j++) {
|
|
|
- Row row = sheet.getRow(j);
|
|
|
- JSONObject obj = new JSONObject();
|
|
|
- obj.put("name", getCellValue(row.getCell(1)));
|
|
|
- obj.put("code", getCellValue(row.getCell(2)));
|
|
|
- obj.put("enable", row.getCell(3).getBooleanCellValue());
|
|
|
- dic.add(obj);
|
|
|
- }
|
|
|
- object.put(caVal, dic);
|
|
|
- }
|
|
|
- fis.close();
|
|
|
- return object;
|
|
|
- }
|
|
|
-
|
|
|
public static JSONObject ReadEquipStaticInfoById(String objId) throws Exception {
|
|
|
String ibmsSceneCode = null;
|
|
|
String ibmsClassCode = null;
|
|
@@ -73,44 +47,129 @@ public class ExeclReadEquipStaticInfoUtil {
|
|
|
return object;
|
|
|
}
|
|
|
|
|
|
+ public static JSONObject ReadEquipStaticInfo(String ibmsSceneCode, String ibmsClassCode) throws Exception {
|
|
|
+ RepositoryImpl Repository = RepositoryContainer.instance;
|
|
|
+ JSONObject object = new JSONObject();
|
|
|
+ if (Constant.info_point_version.equals("old")) {
|
|
|
+ FileInputStream fis = new FileInputStream(FileUtil.file(ibmsSceneCode + ".xlsx"));
|
|
|
+ Workbook workbook = WorkbookFactory.create(new BufferedInputStream(fis));
|
|
|
+ Sheet sheet = workbook.getSheet(ibmsClassCode);
|
|
|
+ for (int i = 0; i < sheet.getNumMergedRegions(); i++) {
|
|
|
+ // 获取合并单元格的值
|
|
|
+ CellRangeAddress ca = sheet.getMergedRegion(i);
|
|
|
+ int firstRow = ca.getFirstRow();
|
|
|
+ Row fRow = sheet.getRow(firstRow);
|
|
|
+ Cell fCell = fRow.getCell(0);
|
|
|
+ String caVal = getCellValue(fCell);
|
|
|
+ // 获取合并单元格之后的值,形成树形结构
|
|
|
+ JSONArray dic = new JSONArray();
|
|
|
+ for (int j = firstRow; j <= ca.getLastRow(); j++) {
|
|
|
+ Row row = sheet.getRow(j);
|
|
|
+ JSONObject obj = new JSONObject();
|
|
|
+ obj.put("name", getCellValue(row.getCell(1)));
|
|
|
+ obj.put("code", getCellValue(row.getCell(2)));
|
|
|
+ obj.put("enable", row.getCell(3).getBooleanCellValue());
|
|
|
+ dic.add(obj);
|
|
|
+ }
|
|
|
+ object.put(caVal, dic);
|
|
|
+ }
|
|
|
+ fis.close();
|
|
|
+ } else if (Constant.info_point_version.equals("new")) {
|
|
|
+ String infoClass = "基本参数";
|
|
|
+ JSONArray dic = new JSONArray();
|
|
|
+ for (SceneDataObject sdo : Repository.InfoPointListArray.set) {
|
|
|
+ String ibmsSceneCodeInner = (String) sdo.get("ibmsSceneCode").value_prim.value;
|
|
|
+ String ibmsClassCodeInner = (String) sdo.get("ibmsClassCode").value_prim.value;
|
|
|
+ if (!ibmsSceneCodeInner.equals(ibmsSceneCode) || !ibmsClassCodeInner.equals(ibmsClassCode)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ String infoType = (String) sdo.get("infoType").value_prim.value;
|
|
|
+ String infoCode = (String) sdo.get("infoCode").value_prim.value;
|
|
|
+ String infoName = (String) sdo.get("infoName").value_prim.value;
|
|
|
+ boolean isVisible = (Boolean) sdo.get("isVisible").value_prim.value;
|
|
|
+ if (infoType.equals(infoClass)) {
|
|
|
+ JSONObject obj = new JSONObject();
|
|
|
+ obj.put("name", infoName);
|
|
|
+ obj.put("code", infoCode);
|
|
|
+ obj.put("enable", isVisible);
|
|
|
+ dic.add(obj);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ object.put(infoClass, dic);
|
|
|
+ }
|
|
|
+ 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));
|
|
|
- Sheet sheet = workbook.getSheet(ibmsClassCode);
|
|
|
- for (int i = 0; i < sheet.getNumMergedRegions(); i++) {
|
|
|
- // 获取合并单元格的值
|
|
|
- CellRangeAddress ca = sheet.getMergedRegion(i);
|
|
|
- int firstRow = ca.getFirstRow();
|
|
|
- Row fRow = sheet.getRow(firstRow);
|
|
|
- Cell fCell = fRow.getCell(0);
|
|
|
- String caVal = getCellValue(fCell);
|
|
|
- // 获取合并单元格之后的值,形成树形结构
|
|
|
+ if (Constant.info_point_version.equals("old")) {
|
|
|
+ FileInputStream fis = new FileInputStream(FileUtil.file(ibmsSceneCode + ".xlsx"));
|
|
|
+ Workbook workbook = WorkbookFactory.create(new BufferedInputStream(fis));
|
|
|
+ Sheet sheet = workbook.getSheet(ibmsClassCode);
|
|
|
+ for (int i = 0; i < sheet.getNumMergedRegions(); i++) {
|
|
|
+ // 获取合并单元格的值
|
|
|
+ CellRangeAddress ca = sheet.getMergedRegion(i);
|
|
|
+ int firstRow = ca.getFirstRow();
|
|
|
+ Row fRow = sheet.getRow(firstRow);
|
|
|
+ Cell fCell = fRow.getCell(0);
|
|
|
+ String caVal = getCellValue(fCell);
|
|
|
+ // 获取合并单元格之后的值,形成树形结构
|
|
|
+ JSONArray dic = new JSONArray();
|
|
|
+ // 获取这个设备类的信息点列表
|
|
|
+ JSONArray array = Repository.infoArrayJson.get(classCode);
|
|
|
+ for (int j = firstRow; j <= ca.getLastRow(); j++) {
|
|
|
+ Row row = sheet.getRow(j);
|
|
|
+ String codeInfo = getCellValue(row.getCell(1));
|
|
|
+ for (int z = 0; z < array.size(); z++) {
|
|
|
+ JSONObject obj = (JSONObject) FastJsonUtil.Clone_JSON(array.get(z));
|
|
|
+ String codeVal = obj.get("code").toString();
|
|
|
+ if (codeVal.equals(codeInfo)) {
|
|
|
+ if (queryObj != null) {
|
|
|
+ obj.put("data", queryObj.get(codeInfo));
|
|
|
+ }
|
|
|
+ obj.put("enable", row.getCell(2).getBooleanCellValue());
|
|
|
+ dic.add(obj);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ object.put(caVal, dic);
|
|
|
+ }
|
|
|
+ fis.close();
|
|
|
+ } else if (Constant.info_point_version.equals("new")) {
|
|
|
+ JSONArray infoArray = Repository.infoArrayJson.get(classCode);
|
|
|
+
|
|
|
+ String infoClass = "基本参数";
|
|
|
JSONArray dic = new JSONArray();
|
|
|
- // 获取这个设备类的信息点列表
|
|
|
- JSONArray array = Repository.infoArrayJson.get(classCode);
|
|
|
- for (int j = firstRow; j <= ca.getLastRow(); j++) {
|
|
|
- Row row = sheet.getRow(j);
|
|
|
- String codeInfo = getCellValue(row.getCell(1));
|
|
|
- for (int z = 0; z < array.size(); z++) {
|
|
|
- JSONObject obj = (JSONObject) array.get(z);
|
|
|
- String codeVal = obj.get("code").toString();
|
|
|
- if (codeVal.equals(codeInfo)) {
|
|
|
- if (queryObj != null) {
|
|
|
- obj.put("data", queryObj.get(codeInfo));
|
|
|
+ for (SceneDataObject sdo : Repository.InfoPointListArray.set) {
|
|
|
+ String ibmsSceneCodeInner = (String) sdo.get("ibmsSceneCode").value_prim.value;
|
|
|
+ String ibmsClassCodeInner = (String) sdo.get("ibmsClassCode").value_prim.value;
|
|
|
+ if (!ibmsSceneCodeInner.equals(ibmsSceneCode) || !ibmsClassCodeInner.equals(ibmsClassCode)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ String infoType = (String) sdo.get("infoType").value_prim.value;
|
|
|
+ String infoCode = (String) sdo.get("infoCode").value_prim.value;
|
|
|
+ boolean isVisible = (Boolean) sdo.get("isVisible").value_prim.value;
|
|
|
+ if (infoType.equals(infoClass)) {
|
|
|
+ for (int z = 0; z < infoArray.size(); z++) {
|
|
|
+ JSONObject obj = (JSONObject) FastJsonUtil.Clone_JSON(infoArray.get(z));
|
|
|
+ String codeVal = obj.get("code").toString();
|
|
|
+ if (codeVal.equals(infoCode)) {
|
|
|
+ if (queryObj != null) {
|
|
|
+ obj.put("data", queryObj.get(infoCode));
|
|
|
+ }
|
|
|
+ obj.put("enable", isVisible);
|
|
|
+ dic.add(obj);
|
|
|
+ break;
|
|
|
}
|
|
|
- obj.put("enable", row.getCell(2).getBooleanCellValue());
|
|
|
- dic.add(obj);
|
|
|
- break;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- object.put(caVal, dic);
|
|
|
+ object.put(infoClass, dic);
|
|
|
}
|
|
|
- fis.close();
|
|
|
return object;
|
|
|
}
|
|
|
|