|
@@ -22,7 +22,6 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
-import java.io.InputStream;
|
|
|
import java.util.*;
|
|
|
import java.util.function.Function;
|
|
|
import java.util.stream.Collectors;
|
|
@@ -52,8 +51,9 @@ public class UploadService {
|
|
|
}
|
|
|
|
|
|
private MapResponse uploadCalendarReportSave(MultipartFile file) throws Exception {
|
|
|
- List<FuncidDefChangeRecord> funcidDefChangeRecordList = compareDataExcelReadFuncid(file);
|
|
|
- List<ClassDefChangeRecord> classDefChangeRecordList = compareDataExcelReadClass(file);
|
|
|
+ Map<String, Object> result = calendarReportExcelRead(file);
|
|
|
+ List<ClassDefChangeRecord> classDefChangeRecordList = (List<ClassDefChangeRecord>) result.get("classDefChangeRecordList");
|
|
|
+ List<FuncidDefChangeRecord> funcidDefChangeRecordList = (List<FuncidDefChangeRecord>) result.get("funcidDefChangeRecordList");
|
|
|
|
|
|
for (ClassDefChangeRecord classDefChangeRecord : classDefChangeRecordList) {
|
|
|
classDefChangeRecordService.create(classDefChangeRecord);
|
|
@@ -62,32 +62,58 @@ public class UploadService {
|
|
|
for (FuncidDefChangeRecord funcidDefChangeRecord : funcidDefChangeRecordList) {
|
|
|
funcidDefChangeRecordService.create(funcidDefChangeRecord);
|
|
|
}
|
|
|
-
|
|
|
return new MapResponse();
|
|
|
}
|
|
|
|
|
|
- public List<ClassDefChangeRecord> compareDataExcelReadClass(MultipartFile file) throws Exception {
|
|
|
+ private Map<String, Object> calendarReportExcelRead(MultipartFile file) throws Exception {
|
|
|
+
|
|
|
+ SheetReadInfo info1 = new SheetReadInfo();
|
|
|
+ info1.setStartRow(1);
|
|
|
+ info1.add(0, "majorCode", "string");
|
|
|
+ info1.add(2, "majorName", "string");
|
|
|
+ info1.add(3, "systemCode", "string");
|
|
|
+ info1.add(4, "systemAliasCode", "string");
|
|
|
+ info1.add(6, "systemName", "string");
|
|
|
+ info1.add(7, "equipmentCode", "string");
|
|
|
+ info1.add(8, "equipmentAliasCode", "string");
|
|
|
+ info1.add(10, "equipmentName", "string");
|
|
|
+ info1.add(11, "componentCode", "string");
|
|
|
+ info1.add(12, "componentAliasCode", "string");
|
|
|
+ info1.add(14, "componentName", "string");
|
|
|
+
|
|
|
+ SheetReadInfo info2 = new SheetReadInfo();
|
|
|
+ info2.setStartRow(1);
|
|
|
+ info2.add(0, "classCode", "string");
|
|
|
+ info2.add(2, "firstTag", "string");
|
|
|
+ info2.add(3, "secondTag", "string");
|
|
|
+ info2.add(4, "code", "string");
|
|
|
+ info2.add(5, "aliasCode", "string");
|
|
|
+ info2.add(6, "name", "string");
|
|
|
+ info2.add(7, "category", "string");
|
|
|
+ info2.add(8, "priority", "string");
|
|
|
+ info2.add(9, "unit", "string");
|
|
|
+ info2.add(10, "dataType", "string");
|
|
|
+ info2.add(11, "isMultiple", "integer");
|
|
|
+ info2.add(12, "isRegion", "integer");
|
|
|
+ info2.add(13, "dataSource", "string");
|
|
|
+ info2.add(14, "formater", "string");
|
|
|
+ info2.add(15, "note", "string");
|
|
|
+
|
|
|
+ List<List<Map<String, Object>>> result = ExcelUtils.read(file.getInputStream(), Arrays.asList(new SheetReadInfo(), info1, info2));
|
|
|
+ List<ClassDefChangeRecord> classDefChangeRecordList = compareDataExcelReadClass(result.get(1));
|
|
|
+ List<FuncidDefChangeRecord> funcidDefChangeRecordList = compareDataExcelReadFuncid(result.get(2));
|
|
|
+
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ map.put("classDefChangeRecordList", classDefChangeRecordList);
|
|
|
+ map.put("funcidDefChangeRecordList", funcidDefChangeRecordList);
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
+ public List<ClassDefChangeRecord> compareDataExcelReadClass(List<Map<String, Object>> result) throws Exception {
|
|
|
JacksonCriteria criteria = JacksonCriteria.newInstance();
|
|
|
criteria.add("type", "common");
|
|
|
List<ClassDefModel> data = classDefService.queryClass(criteria).getData();
|
|
|
Map<String, ClassDefModel> classCodeMap = data.stream().collect(Collectors.toMap(ClassDefModel::getCode, Function.identity()));
|
|
|
-
|
|
|
- SheetReadInfo info = new SheetReadInfo();
|
|
|
- info.setStartRow(1);
|
|
|
- info.add(0, "majorCode", "string");
|
|
|
- info.add(2, "majorName", "string");
|
|
|
- info.add(3, "systemCode", "string");
|
|
|
- info.add(4, "systemAliasCode", "string");
|
|
|
- info.add(6, "systemName", "string");
|
|
|
- info.add(7, "equipmentCode", "string");
|
|
|
- info.add(8, "equipmentAliasCode", "string");
|
|
|
- info.add(10, "equipmentName", "string");
|
|
|
- info.add(11, "componentCode", "string");
|
|
|
- info.add(12, "componentAliasCode", "string");
|
|
|
- info.add(14, "componentName", "string");
|
|
|
-
|
|
|
- InputStream inputStream = file.getInputStream();
|
|
|
- List<Map<String, Object>> result = ExcelUtils.read(inputStream, info);
|
|
|
List<ClassDefChangeRecord> classDefChangeRecordList = new ArrayList<>();
|
|
|
for (Map<String, Object> map : result) {
|
|
|
String majorCode = MapUtils.getString(map, "majorCode");
|
|
@@ -106,22 +132,26 @@ public class UploadService {
|
|
|
|
|
|
ClassDefChangeRecord changeRecord = new ClassDefChangeRecord();
|
|
|
if (componentCode != null) {
|
|
|
- getClassDefChangeRecord(classCodeMap, componentCode, componentName, componentAliasCode, componentName, ObjType.component, majorCode, systemCode, equipmentCode);
|
|
|
+ componentCode = majorCode + systemCode + equipmentCode + componentCode;
|
|
|
+ equipmentCode = majorCode + systemCode + equipmentCode;
|
|
|
+ systemCode = majorCode + systemCode;
|
|
|
+ getClassDefChangeRecord(classCodeMap, changeRecord, componentCode, componentName, componentAliasCode, componentName, ObjType.component, majorCode, systemCode, equipmentCode);
|
|
|
} else if (equipmentCode != null) {
|
|
|
- getClassDefChangeRecord(classCodeMap, equipmentCode, equipmentName, equipmentAliasCode, equipmentName, ObjType.equipment, majorCode, systemCode, null);
|
|
|
-
|
|
|
+ equipmentCode = majorCode + systemCode + equipmentCode;
|
|
|
+ systemCode = majorCode + systemCode;
|
|
|
+ getClassDefChangeRecord(classCodeMap, changeRecord, equipmentCode, equipmentName, equipmentAliasCode, equipmentName, ObjType.equipment, majorCode, systemCode, null);
|
|
|
} else if (systemCode != null) {
|
|
|
- getClassDefChangeRecord(classCodeMap, systemCode, systemName, systemAliasCode, systemName, ObjType.system, majorCode, null, null);
|
|
|
+ systemCode = majorCode + systemCode;
|
|
|
+ getClassDefChangeRecord(classCodeMap, changeRecord, systemCode, systemName, systemAliasCode, systemName, ObjType.system, majorCode, null, null);
|
|
|
}
|
|
|
classDefChangeRecordList.add(changeRecord);
|
|
|
}
|
|
|
return classDefChangeRecordList;
|
|
|
}
|
|
|
|
|
|
- public ClassDefChangeRecord getClassDefChangeRecord(Map<String, ClassDefModel> classCodeMap,
|
|
|
+ public ClassDefChangeRecord getClassDefChangeRecord(Map<String, ClassDefModel> classCodeMap, ClassDefChangeRecord changeRecord,
|
|
|
String code, String name, String aliasCode, String aliasName,
|
|
|
ObjType objType, String majorCode, String systemCode, String equipmentCode) {
|
|
|
- ClassDefChangeRecord changeRecord = new ClassDefChangeRecord();
|
|
|
if (classCodeMap.containsKey(code)) {
|
|
|
ClassDefModel classDefModel = classCodeMap.get(code);
|
|
|
changeRecord.setCode(classDefModel.getCode());
|
|
@@ -155,33 +185,13 @@ public class UploadService {
|
|
|
changeRecord.setState(EnumVersionState.INIT);
|
|
|
changeRecord.setOperationType(EnumOperationType.create);
|
|
|
}
|
|
|
- changeRecord.setAliasCode(aliasCode);
|
|
|
- changeRecord.setAliasName(name);
|
|
|
+ changeRecord.setAliasCode(aliasCode == null ? code : aliasCode);
|
|
|
+ changeRecord.setAliasName(aliasName);
|
|
|
return changeRecord;
|
|
|
}
|
|
|
|
|
|
- public List<FuncidDefChangeRecord> compareDataExcelReadFuncid(MultipartFile file) throws Exception {
|
|
|
+ public List<FuncidDefChangeRecord> compareDataExcelReadFuncid(List<Map<String, Object>> result) throws Exception {
|
|
|
Map<String, FuncidDefModel> funcidDefMap = new HashMap<>();
|
|
|
- SheetReadInfo info = new SheetReadInfo();
|
|
|
- info.setStartRow(1);
|
|
|
- info.add(0, "classCode", "string");
|
|
|
- info.add(2, "firstTag", "string");
|
|
|
- info.add(3, "secondTag", "string");
|
|
|
- info.add(4, "code", "string");
|
|
|
- info.add(5, "aliasCode", "string");
|
|
|
- info.add(6, "name", "string");
|
|
|
- info.add(7, "category", "string");
|
|
|
- info.add(8, "priority", "string");
|
|
|
- info.add(9, "unit", "string");
|
|
|
- info.add(10, "dataType", "string");
|
|
|
- info.add(11, "isMultiple", "integer");
|
|
|
- info.add(12, "isRegion", "integer");
|
|
|
- info.add(13, "dataSource", "string");
|
|
|
- info.add(14, "formater", "string");
|
|
|
- info.add(15, "note", "string");
|
|
|
-
|
|
|
- InputStream inputStream = file.getInputStream();
|
|
|
- List<Map<String, Object>> result = ExcelUtils.read(inputStream, info);
|
|
|
List<FuncidDefChangeRecord> funcidDefChangeRecordList = new ArrayList<>();
|
|
|
for (Map<String, Object> map : result) {
|
|
|
String classCode = MapUtils.getString(map, "classCode");
|