|
@@ -15,28 +15,20 @@ import cn.hutool.poi.excel.WorkbookUtil;
|
|
|
import cn.hutool.poi.excel.cell.CellUtil;
|
|
|
import cn.hutool.poi.excel.editors.TrimEditor;
|
|
|
import com.alibaba.excel.EasyExcel;
|
|
|
-import com.alibaba.fastjson.JSONObject;
|
|
|
-import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
-import com.fasterxml.jackson.databind.node.JsonNodeFactory;
|
|
|
import com.fasterxml.jackson.databind.node.ObjectNode;
|
|
|
import com.persagy.dmp.basic.dto.RequestData;
|
|
|
import com.persagy.dmp.basic.model.QueryCriteria;
|
|
|
import com.persagy.dmp.common.constant.ResponseCode;
|
|
|
import com.persagy.dmp.common.context.AppContext;
|
|
|
import com.persagy.dmp.common.exception.BusinessException;
|
|
|
-import com.persagy.dmp.common.helper.SpringHelper;
|
|
|
-import com.persagy.dmp.common.model.entity.BaseEntity;
|
|
|
import com.persagy.dmp.common.model.response.CommonResult;
|
|
|
-import com.persagy.dmp.define.client.DigitalDefineFacade;
|
|
|
import com.persagy.dmp.define.client.DigitalObjectInfoFacade;
|
|
|
import com.persagy.dmp.define.entity.ObjectInfoDefine;
|
|
|
import com.persagy.dmp.define.entity.ObjectTypeDefine;
|
|
|
import com.persagy.dmp.digital.client.DigitalObjectFacade;
|
|
|
-import com.persagy.dmp.digital.entity.ObjectDigital;
|
|
|
import com.persagy.dmp.simple.client.DigitalObjectSimpleFacade;
|
|
|
import com.persagy.proxy.adm.constant.AdmCommonConstant;
|
|
|
import com.persagy.proxy.adm.constant.AdmDictCategoryEnum;
|
|
|
-import com.persagy.proxy.adm.constant.AdmRelationTypeEnum;
|
|
|
import com.persagy.proxy.adm.request.*;
|
|
|
import com.persagy.proxy.adm.service.IAdmRelationService;
|
|
|
import com.persagy.proxy.adm.utils.AdmContextUtil;
|
|
@@ -50,6 +42,7 @@ import com.persagy.proxy.dictionary.model.AdmObjectType;
|
|
|
import com.persagy.proxy.dictionary.service.IAdmDictService;
|
|
|
import com.persagy.proxy.object.model.AdmEquipment;
|
|
|
import com.persagy.proxy.object.model.AdmProject;
|
|
|
+import com.persagy.proxy.object.model.AdmSystem;
|
|
|
import com.persagy.proxy.object.service.IAdmEquipmentService;
|
|
|
import com.persagy.proxy.object.service.IAdmProjectService;
|
|
|
import com.persagy.proxy.report.model.EquipmentPointExcel;
|
|
@@ -92,7 +85,6 @@ public class AdmEquipmentController {
|
|
|
private IAdmDictService dictService;
|
|
|
@Autowired
|
|
|
private IAdmProjectService projectService;
|
|
|
-
|
|
|
/**
|
|
|
* 统计
|
|
|
*
|
|
@@ -163,8 +155,6 @@ public class AdmEquipmentController {
|
|
|
return AdmCreateResponse.success();
|
|
|
}
|
|
|
filterVOs = service.doInsert(AdmContextUtil.toDmpContext(), AdmEquipment.class, filterVOs);
|
|
|
- //处理关系
|
|
|
- processRelations(filterVOs);
|
|
|
return AdmCreateResponse.success(filterVOs);
|
|
|
}
|
|
|
|
|
@@ -178,122 +168,60 @@ public class AdmEquipmentController {
|
|
|
public AdmResponse delete( @RequestBody List<AdmEquipment> vos) throws Exception {
|
|
|
// 组装上下文条件
|
|
|
service.doDelete(AdmContextUtil.toDmpContext(), vos);
|
|
|
- QueryCriteria queryCriteria = new QueryCriteria();
|
|
|
- vos.forEach(vo -> {
|
|
|
- /** 清除空间和建筑楼层的的数据 */
|
|
|
- dealRelation(vo.getId(), queryCriteria, AdmRelationTypeEnum.EQ2BD.getRelCode());
|
|
|
- dealRelation(vo.getId(), queryCriteria, AdmRelationTypeEnum.EQ2FL.getRelCode());
|
|
|
- });
|
|
|
return AdmResponse.success();
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- /**
|
|
|
- * 更新
|
|
|
- * @param createRequest
|
|
|
- * @return
|
|
|
- * @throws Exception
|
|
|
- */
|
|
|
- @PostMapping("/update")
|
|
|
- public AdmResponse update(@RequestBody AdmCreateRequest<AdmEquipment> createRequest) throws Exception {
|
|
|
- List<AdmEquipment> vos = CollUtil.newArrayList(createRequest.getContent());
|
|
|
- //vos = service.doUpdateEuip(AdmContextUtil.toDmpContext(), AdmEquipment.class, vos);
|
|
|
- //针对设备更新时,所有更新的字段都放到信息点中的情况特殊处理
|
|
|
- if(CollUtil.isNotEmpty(vos)){
|
|
|
- Map<String, AdmEquipment> admEquipmentMap = CollUtil.fieldValueMap(vos, BaseEntity.PROP_ID);
|
|
|
- AdmRelationTypeEnum typeEnum = AdmRelationTypeEnum.EQ2BD;
|
|
|
- String graphCode = typeEnum.getGraphCode();
|
|
|
- QueryCriteria criteria = new QueryCriteria();
|
|
|
- ObjectNode node = JsonNodeFactory.instance.objectNode();
|
|
|
- node.put("graphCode", graphCode);
|
|
|
- admEquipmentMap.keySet().stream().forEach(equipId -> {
|
|
|
- AdmEquipment admEquipment = admEquipmentMap.get(equipId);
|
|
|
- //处理建筑 楼层信息点
|
|
|
- int removeflBd = 0 ;//关系处理 0不删除 1删除bd 2删除fl 3都删除
|
|
|
- String flowBuild = admEquipment.getFlowBuild();
|
|
|
- if(StrUtil.isNotEmpty(flowBuild)){
|
|
|
- if(!flowBuild.contains("-")){
|
|
|
- if(flowBuild.startsWith("Bd")){
|
|
|
- admEquipment.setBuildingId(flowBuild);
|
|
|
- if(StrUtil.isNotEmpty(admEquipment.getFloorId())){
|
|
|
- Map<String, Object> infos = new HashMap<String,Object>(16);
|
|
|
- infos.put("$remove", Arrays.asList("floorId"));
|
|
|
- admEquipment.setInfos(infos);
|
|
|
- removeflBd = 2;
|
|
|
- }
|
|
|
- }
|
|
|
- }else {
|
|
|
- String[] str = flowBuild.split("-");
|
|
|
- if(str[0].startsWith("Bd")){
|
|
|
- admEquipment.setBuildingId(str[0]);
|
|
|
- admEquipment.setFloorId(str[1]);
|
|
|
- }else{
|
|
|
- admEquipment.setBuildingId(str[1]);
|
|
|
- admEquipment.setFloorId(str[0]);
|
|
|
- }
|
|
|
- removeflBd = 3;
|
|
|
- }
|
|
|
- admEquipment.setFlowBuild(null);
|
|
|
- }else{
|
|
|
- if(StrUtil.isAllNotEmpty(admEquipment.getBuildingId(),admEquipment.getFloorId())){
|
|
|
- Map<String, Object> infos = new HashMap<String,Object>(16);
|
|
|
- infos.put("$remove",Arrays.asList("floorId","buildingId"));
|
|
|
- admEquipment.setInfos(infos);
|
|
|
- removeflBd = 3;
|
|
|
+ /**
|
|
|
+ * 更新
|
|
|
+ * @param createRequest
|
|
|
+ * @return
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ @PostMapping("/update")
|
|
|
+ public AdmResponse update(@RequestBody AdmCreateRequest<AdmEquipment> createRequest) throws Exception {
|
|
|
+ List<AdmEquipment> vos = createRequest.getContent();
|
|
|
+ if(CollUtil.isEmpty(vos)) {
|
|
|
+ return AdmResponse.success(vos);
|
|
|
+ }
|
|
|
+ for(AdmEquipment vo:vos) {
|
|
|
+ if(StrUtil.isNotBlank(vo.getFlowBuild())) {
|
|
|
+ // 处理建筑-楼层信息点
|
|
|
+ List<String> flows = StrUtil.splitTrim(vo.getFlowBuild(), "-");
|
|
|
+ for(String flow:flows) {
|
|
|
+ if(StrUtil.startWith(flow, "Bd")) {
|
|
|
+ vo.setBuildingId(flow);
|
|
|
+ } else if(StrUtil.startWith(flow, "fl")) {
|
|
|
+ vo.setFloorId(flow);
|
|
|
}
|
|
|
}
|
|
|
- //删除关系 然后重建
|
|
|
- if(removeflBd == 3 || removeflBd == 2){
|
|
|
- node.put("relCode", "Eq2Fl");
|
|
|
- node.put("objFrom", equipId);
|
|
|
- criteria.setCriteria(node);
|
|
|
- relationService.doDelete(AdmContextUtil.toDmpContext(), criteria);
|
|
|
- }
|
|
|
- if(removeflBd == 3 || removeflBd == 1){
|
|
|
- node.put("relCode", "Eq2Bd");
|
|
|
- node.put("objFrom", equipId);
|
|
|
- criteria.setCriteria(node);
|
|
|
- relationService.doDelete(AdmContextUtil.toDmpContext(), criteria);
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
- List<RelationDTO> relationDTOList = new ArrayList<>(vos.size());
|
|
|
- admEquipmentMap.keySet().stream().forEach(equipId -> {
|
|
|
- if(StrUtil.isNotEmpty(admEquipmentMap.get(equipId).getBuildingId())){
|
|
|
- RelationDTO relationbd = new RelationDTO(null, graphCode, "Eq2Bd", null, equipId, admEquipmentMap.get(equipId).getBuildingId());
|
|
|
- relationDTOList.add(relationbd);
|
|
|
- }
|
|
|
- if(StrUtil.isNotEmpty(admEquipmentMap.get(equipId).getFloorId())) {
|
|
|
- RelationDTO relationfl = new RelationDTO(null, graphCode, "Eq2Fl", null, equipId, admEquipmentMap.get(equipId).getFloorId());
|
|
|
- relationDTOList.add(relationfl);
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
- if(CollUtil.isNotEmpty(relationDTOList)){
|
|
|
- relationService.doSave(AdmContextUtil.toDmpContext(), relationDTOList);
|
|
|
+ vo.setFlowBuild(null);
|
|
|
}
|
|
|
- //处理设备更新特殊数据
|
|
|
- vos.stream().forEach(equipment -> {
|
|
|
- //特殊处理位置信息
|
|
|
- if(StrUtil.isNotEmpty(equipment.getBimLocation())){
|
|
|
- Map<String,Object> infos = equipment.getInfos();
|
|
|
- if(CollUtil.isEmpty(infos)){
|
|
|
- infos = new HashMap<String, Object>();
|
|
|
- infos.put("bimLocation", equipment.getBimLocation());
|
|
|
- equipment.setInfos(infos);
|
|
|
- }
|
|
|
- }
|
|
|
- if(CollUtil.isNotEmpty(equipment.getInfos())){
|
|
|
- Object localId = equipment.getInfos().get("localId");
|
|
|
- if(localId != null && StrUtil.isNotEmpty(localId.toString())){
|
|
|
- equipment.setLocalId(localId.toString());
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
- vos = service.doUpdate(AdmContextUtil.toDmpContext(), AdmEquipment.class, vos);
|
|
|
- return AdmResponse.success(vos);
|
|
|
- }
|
|
|
+ // 设置remove信息
|
|
|
+ Set<String> nullList = CollUtil.newHashSet(vo.getNullList());
|
|
|
+ if(StrUtil.isBlank(vo.getFloorId())) {
|
|
|
+ nullList.add("floorId");
|
|
|
+ }
|
|
|
+ if(StrUtil.isBlank(vo.getBuildingId())) {
|
|
|
+ nullList.add("buildingId");
|
|
|
+ }
|
|
|
+ vo.setNullList(CollUtil.newArrayList(nullList));
|
|
|
+ //特殊处理位置信息
|
|
|
+ Map<String,Object> infos = vo.getInfos();
|
|
|
+ if(infos == null) {
|
|
|
+ infos = new HashMap<String, Object>();
|
|
|
+ vo.setInfos(infos);
|
|
|
+ }
|
|
|
+ if(StrUtil.isNotEmpty(vo.getBimLocation())){
|
|
|
+ infos.put("bimLocation", vo.getBimLocation());
|
|
|
+ }
|
|
|
+ String localId = MapUtil.getStr(infos, "localId");
|
|
|
+ if(StrUtil.isNotEmpty(localId)){
|
|
|
+ vo.setLocalId(localId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ vos = service.doUpdate(AdmContextUtil.toDmpContext(), AdmEquipment.class, vos);
|
|
|
+ return AdmResponse.success(vos);
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* 查询
|
|
@@ -433,39 +361,23 @@ public class AdmEquipmentController {
|
|
|
if(CollUtil.isEmpty(vos)){
|
|
|
return AdmCreateResponse.success();
|
|
|
}
|
|
|
- //创建设备
|
|
|
- vos.stream().forEach(equipment -> {
|
|
|
- if (StrUtil.isEmpty(equipment.getName())){
|
|
|
- equipment.setName(ObjectNameUtil.objectName("设备-"));
|
|
|
- }
|
|
|
- });
|
|
|
- List<AdmEquipment> reVos = new ArrayList<>(vos.size());
|
|
|
+ // 这里应该要移到实现类里
|
|
|
List<RelationDTO> relationDTOS = new ArrayList<>(16);
|
|
|
- vos.stream().forEach(admEq -> {
|
|
|
- //创建设备
|
|
|
- List<AdmEquipment> vosR = service.doInsert(AdmContextUtil.toDmpContext(), AdmEquipment.class, CollUtil.newArrayList(admEq));
|
|
|
- //TODO 创建资产
|
|
|
- //添加设备和系统、建筑、楼层的关系
|
|
|
- if(CollUtil.isNotEmpty(vosR)){
|
|
|
- String equipId = vosR.get(0).getId();
|
|
|
- if(StrUtil.isNotEmpty(equipId)){
|
|
|
- if(CollUtil.isNotEmpty(admEq.getLinkSystem())){
|
|
|
- admEq.getLinkSystem().stream().forEach(admSystem -> {
|
|
|
- relationDTOS.add(new RelationDTO(null, "MechSubset", "Sy2Eq", null , admSystem.getId(), equipId));
|
|
|
- });
|
|
|
- }
|
|
|
- if(StrUtil.isNotEmpty(admEq.getBuildingId())){
|
|
|
- relationDTOS.add(new RelationDTO(null, "MechInArch", "Eq2Bd", null , equipId, admEq.getBuildingId()));
|
|
|
- }
|
|
|
- if(StrUtil.isNotEmpty(admEq.getFloorId())){
|
|
|
- relationDTOS.add(new RelationDTO(null, "MechInArch", "Eq2Fl", null , equipId, admEq.getFloorId()));
|
|
|
- }
|
|
|
- }
|
|
|
+ for(AdmEquipment vo:vos) {
|
|
|
+ if (StrUtil.isEmpty(vo.getName())){
|
|
|
+ vo.setName(ObjectNameUtil.objectName("设备-"));
|
|
|
+ }
|
|
|
+ List<AdmSystem> systems = vo.getLinkSystem();
|
|
|
+ if(CollUtil.isEmpty(systems)){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ for(AdmSystem system:systems) {
|
|
|
+ relationDTOS.add(new RelationDTO(null, "MechSubset", "Sy2Eq", null , system.getId(), vo.getId()));
|
|
|
}
|
|
|
- reVos.addAll(vosR);
|
|
|
- });
|
|
|
+ }
|
|
|
relationService.doSave(AdmContextUtil.toDmpContext(),relationDTOS);
|
|
|
- return AdmCreateResponse.success(reVos);
|
|
|
+ vos = service.doInsert(AdmContextUtil.toDmpContext(), AdmEquipment.class, vos);
|
|
|
+ return AdmCreateResponse.success(vos);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -475,258 +387,6 @@ public class AdmEquipmentController {
|
|
|
* @param request
|
|
|
* @param response
|
|
|
*/
|
|
|
-// @RequestMapping("/import")
|
|
|
-// public AdmResponse importFile(@RequestParam("file") MultipartFile file, HttpServletRequest request, HttpServletResponse response) {
|
|
|
-// if (file == null) {
|
|
|
-// return AdmResponse.failure("未选择文件");
|
|
|
-// }
|
|
|
-// String path = AdmCommonConstant.SERVER_ROOT_PATH + AdmExcelUtil.TEMP_UPLOAD_PAHT;
|
|
|
-//
|
|
|
-// int failurNum = 0;
|
|
|
-// int successCount = 0;
|
|
|
-// String failure = null;
|
|
|
-// String primaryKey = null;
|
|
|
-// String classCodeCloumn = null;
|
|
|
-// XSSFWorkbook workbook = null;
|
|
|
-// FileOutputStream fileOutputStream = null;
|
|
|
-// String groupCode = AppContext.getContext().getGroupCode();
|
|
|
-// String projectId = AppContext.getContext().getProjectId();
|
|
|
-// try {
|
|
|
-//
|
|
|
-// workbook = new XSSFWorkbook(file.getInputStream());
|
|
|
-// XSSFSheet sheet = workbook.getSheetAt(0); // 第一个sheet
|
|
|
-// XSSFRow row1 = sheet.getRow(1);
|
|
|
-// if (row1 == null) {
|
|
|
-// AdmExcelUtil.writeFile2Local(workbook, projectId, path, file.getOriginalFilename());
|
|
|
-// return AdmExcelUtil.getImportFailResult("数据不存在", "2", 0, ++failurNum);
|
|
|
-// }
|
|
|
-//
|
|
|
-// /** 获取识别码 */
|
|
|
-// XSSFCell markCell = row1.getCell(0);
|
|
|
-// if (markCell == null) {
|
|
|
-// AdmExcelUtil.writeFile2Local(workbook, projectId, path, file.getOriginalFilename());
|
|
|
-// return AdmExcelUtil.getImportFailResult("未填写识别码", "2", 0, ++failurNum);
|
|
|
-// }
|
|
|
-// primaryKey = markCell.getStringCellValue().trim(); // 识别码
|
|
|
-// boolean containsKey = AdmCommonConstant.codeColMap.containsKey(primaryKey);
|
|
|
-// if (!containsKey) {
|
|
|
-// AdmExcelUtil.writeFile2Local(workbook, projectId, path, file.getOriginalFilename());
|
|
|
-// return AdmExcelUtil.getImportFailResult("未找到识别码", "2", 0, ++failurNum);
|
|
|
-// }
|
|
|
-// primaryKey = AdmCommonConstant.codeColMap.get(primaryKey);
|
|
|
-//
|
|
|
-// /** 获取类型 */
|
|
|
-// XSSFCell cell = row1.getCell(1);
|
|
|
-// if (cell == null) {
|
|
|
-// AdmExcelUtil.writeFile2Local(workbook, projectId, path, file.getOriginalFilename());
|
|
|
-// return AdmExcelUtil.getImportFailResult("未填写设备类型", "2", 0, ++failurNum);
|
|
|
-// }
|
|
|
-// classCodeCloumn = cell.getStringCellValue().trim();
|
|
|
-// if (!"ClassCode".equals(classCodeCloumn)) {
|
|
|
-// AdmExcelUtil.writeFile2Local(workbook, projectId, path, file.getOriginalFilename());
|
|
|
-// return AdmExcelUtil.getImportFailResult("缺少设备类型(ClassCode)", "2", 0, ++failurNum);
|
|
|
-// }
|
|
|
-//
|
|
|
-// // 存取所有的信息点
|
|
|
-// Map<Integer, String> infoMap = new HashMap<Integer, String>();
|
|
|
-// short lastCellNum = row1.getLastCellNum();
|
|
|
-// for (int i = 1; i <= lastCellNum; i++) {
|
|
|
-// XSSFCell xssfCell = row1.getCell(i);
|
|
|
-// if (xssfCell != null && xssfCell.getStringCellValue() != null) {
|
|
|
-// infoMap.put(i, xssfCell.getStringCellValue().trim());
|
|
|
-// }
|
|
|
-// }
|
|
|
-//
|
|
|
-// // 录入数据获取
|
|
|
-// int lastRowNum = sheet.getLastRowNum();
|
|
|
-// boolean isClassCode = "classCode".equals(primaryKey);
|
|
|
-// for (int i = 2; i <= lastRowNum; i++) {
|
|
|
-// XSSFRow xssfRow = sheet.getRow(i);
|
|
|
-// if (xssfRow == null) {
|
|
|
-// continue;
|
|
|
-// }
|
|
|
-//
|
|
|
-// String value = null;
|
|
|
-// String classCode = null;
|
|
|
-// ObjectNode equipment = null;
|
|
|
-// List<ObjectNode> equipmentList = null;
|
|
|
-// Map<String, Object> tempMap = new HashMap<String, Object>();
|
|
|
-//
|
|
|
-// lastCellNum = xssfRow.getLastCellNum();
|
|
|
-// for (int j = 0; j <= lastCellNum; j++) {
|
|
|
-// cell = xssfRow.getCell(j);
|
|
|
-// if (cell == null || StrUtil.isBlank(cell.getRawValue())) {
|
|
|
-// xssfRow.createCell(j);
|
|
|
-// if (j == 0) {
|
|
|
-// this.setColor(workbook, 252, 255, 77, xssfRow.getCell(j));
|
|
|
-// } else {
|
|
|
-// this.setColor(workbook, 77, 178, 255, xssfRow.getCell(j));
|
|
|
-// }
|
|
|
-// continue;
|
|
|
-// }
|
|
|
-// if (j == 0) {
|
|
|
-// cell.setCellType(CellType.STRING);
|
|
|
-// value = cell.getStringCellValue().trim();
|
|
|
-// String codeType = isClassCode ? xssfRow.getCell(0).toString().trim() : xssfRow.getCell(1).toString().trim();
|
|
|
-// // 获取类型定义
|
|
|
-// ObjectTypeDefine define = this.getObjectTypeDefine(groupCode, projectId, codeType);
|
|
|
-// if (define == null) {
|
|
|
-// this.setColor(workbook, 56, 94, 15, cell);
|
|
|
-// continue;
|
|
|
-// }
|
|
|
-// classCode = define.getCode();
|
|
|
-// equipmentList = isClassCode ? this.getEquipmentList(groupCode, projectId, null, null, classCode)
|
|
|
-// : this.getEquipmentList(groupCode, projectId, primaryKey, value, classCode);
|
|
|
-//
|
|
|
-// if (CollectionUtil.isEmpty(equipmentList)) {
|
|
|
-// failurNum++;
|
|
|
-// this.setColor(workbook, 153, 225, 77, cell);
|
|
|
-// continue;
|
|
|
-// }
|
|
|
-//
|
|
|
-// if (isClassCode) {
|
|
|
-// equipment = equipmentList.get(0);
|
|
|
-// } else {
|
|
|
-// if (equipmentList.size() > 1) {
|
|
|
-// failurNum++;
|
|
|
-// this.setColor(workbook, 249, 203, 77, cell);
|
|
|
-// } else {
|
|
|
-// equipment = equipmentList.get(0);
|
|
|
-// }
|
|
|
-// }
|
|
|
-//
|
|
|
-// continue;
|
|
|
-// }
|
|
|
-// // 剩余列数据处理
|
|
|
-// if (j != 1 && equipment != null && infoMap.containsKey(j)) {
|
|
|
-// // 获取设备类的信息点
|
|
|
-// List<ObjectInfoDefine> funidList = this.relationReportService.queryFunidList(groupCode, projectId, Sets.newHashSet(classCode), infoMap.get(j), "STATIC");
|
|
|
-// if (CollectionUtil.isEmpty(funidList)) {
|
|
|
-// failurNum++;
|
|
|
-// this.setColor(workbook, 77, 178, 255, cell);
|
|
|
-// continue;
|
|
|
-// }
|
|
|
-// ObjectInfoDefine define = funidList.get(0);
|
|
|
-// if ("STRING".equalsIgnoreCase(define.getDataType())) {
|
|
|
-// cell.setCellType(CellType.STRING);
|
|
|
-// tempMap.put(define.getCode(), cell.getStringCellValue().trim());
|
|
|
-// } else if ("INTEGER".equalsIgnoreCase(define.getDataType())) {
|
|
|
-// try {
|
|
|
-// if (!CellType.NUMERIC.equals(cell.getCellTypeEnum()) || StrUtil.isBlank(cell.getRawValue())) {
|
|
|
-// failurNum++;
|
|
|
-// this.setColor(workbook, 155, 227, 255, cell);
|
|
|
-// continue;
|
|
|
-// }
|
|
|
-// cell.setCellType(CellType.STRING);
|
|
|
-// tempMap.put(define.getCode(), cell.getStringCellValue().trim());
|
|
|
-// } catch (Exception e) {
|
|
|
-// failurNum++;
|
|
|
-// this.setColor(workbook, 155, 227, 255, cell);
|
|
|
-// continue;
|
|
|
-// }
|
|
|
-// } else if ("ENUM".equalsIgnoreCase(define.getDataType())) {
|
|
|
-// if (CellType.NUMERIC.equals(cell.getCellTypeEnum()) && StrUtil.isNotBlank(cell.getRawValue())) {
|
|
|
-// cell.setCellType(CellType.STRING);
|
|
|
-// tempMap.put(define.getCode(), cell.getStringCellValue().trim());
|
|
|
-// } else if (CellType.STRING.equals(cell.getCellTypeEnum()) && StrUtil.isNotBlank(cell.getRawValue())) {
|
|
|
-// tempMap.put(define.getCode(), cell.getStringCellValue().trim());
|
|
|
-// } else {
|
|
|
-// failurNum++;
|
|
|
-// this.setColor(workbook, 155, 227, 255, cell);
|
|
|
-// continue;
|
|
|
-// }
|
|
|
-// } else if ("DATETIME".equalsIgnoreCase(define.getDataType())) {
|
|
|
-// try {
|
|
|
-// cell.setCellType(CellType.STRING);
|
|
|
-// String trim = cell.getStringCellValue().trim();
|
|
|
-// tempMap.put(define.getCode(), DateUtil.parseByPatterns(trim, "yyyyMMdd"));
|
|
|
-// } catch (Exception e) {
|
|
|
-// failurNum++;
|
|
|
-// this.setColor(workbook, 155, 227, 255, cell);
|
|
|
-// continue;
|
|
|
-// }
|
|
|
-// } else if ("DOUBLE".equalsIgnoreCase(define.getDataType())) {
|
|
|
-// try {
|
|
|
-// cell.setCellType(CellType.STRING);
|
|
|
-// String trim = cell.getStringCellValue().trim();
|
|
|
-// tempMap.put(define.getCode(), Double.parseDouble(trim));
|
|
|
-// } catch (Exception e) {
|
|
|
-// failurNum++;
|
|
|
-// this.setColor(workbook, 155, 227, 255, cell);
|
|
|
-// continue;
|
|
|
-// }
|
|
|
-// } else if ("BOOLEAN".equalsIgnoreCase(define.getDataType())) {
|
|
|
-// cell.setCellType(CellType.STRING);
|
|
|
-// String trim = cell.getStringCellValue() == null ? null : cell.getStringCellValue().trim();
|
|
|
-// if ("1".equals(trim) || "0".equals(trim)) {
|
|
|
-// tempMap.put(define.getCode(), Double.parseDouble(trim));
|
|
|
-// } else {
|
|
|
-// failurNum++;
|
|
|
-// this.setColor(workbook, 155, 227, 255, cell);
|
|
|
-// continue;
|
|
|
-// }
|
|
|
-// } else {
|
|
|
-// failurNum++;
|
|
|
-// this.setColor(workbook, 204, 99, 233, cell);
|
|
|
-// continue;
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }
|
|
|
-//
|
|
|
-// if (isClassCode) {
|
|
|
-// if (CollectionUtil.isNotEmpty(equipmentList) && tempMap.size() > 0) {
|
|
|
-// for (ObjectNode equipNode : equipmentList) {
|
|
|
-// int success = this.updateEquipInfo(tempMap, groupCode, projectId, equipNode.get("id").asText());
|
|
|
-// if (success == 0) {
|
|
|
-// failurNum++;
|
|
|
-// } else {
|
|
|
-// successCount++;
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }
|
|
|
-// } else {
|
|
|
-// if (StrUtil.isNotBlank(value) && equipment != null && tempMap.size() > 0) {
|
|
|
-// int success = this.updateEquipInfo(tempMap, groupCode, projectId, equipment.get("id").asText());
|
|
|
-// if (success == 0) {
|
|
|
-// failurNum++;
|
|
|
-// } else {
|
|
|
-// successCount++;
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }
|
|
|
-//
|
|
|
-// // 写入错误报告对比值颜色
|
|
|
-// this.wirteReport(workbook, sheet);
|
|
|
-//
|
|
|
-// // 返回正确结果
|
|
|
-// String fileName = AdmExcelUtil.writeFile2Local(workbook, projectId, path, file.getOriginalFilename());
|
|
|
-// return AdmExcelUtil.getImportSuccessResult(fileName, successCount, failurNum);
|
|
|
-// } catch (Exception e) {
|
|
|
-// log.error("台账信息导入失败", e);
|
|
|
-// failure = e.getMessage();
|
|
|
-// } finally {
|
|
|
-// if (fileOutputStream != null) {
|
|
|
-// try {
|
|
|
-// fileOutputStream.flush();
|
|
|
-// fileOutputStream.close();
|
|
|
-// } catch (IOException e) {}
|
|
|
-// }
|
|
|
-// if (workbook != null) {
|
|
|
-// try {
|
|
|
-// workbook.close();
|
|
|
-// } catch (IOException e) {}
|
|
|
-// }
|
|
|
-// }
|
|
|
-// return AdmResponse.failure(failure);
|
|
|
-// }
|
|
|
- /**
|
|
|
- * 设备上传excel识别静态信息点
|
|
|
- *
|
|
|
- * @param file
|
|
|
- * @param request
|
|
|
- * @param response
|
|
|
- */
|
|
|
@RequestMapping("/import")
|
|
|
public AdmResponse importFile(@RequestParam("file") MultipartFile file, HttpServletRequest request, HttpServletResponse response) {
|
|
|
if (file == null) {
|
|
@@ -1002,80 +662,6 @@ public class AdmEquipmentController {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 更新设备信息
|
|
|
- *
|
|
|
- * @param tempMap
|
|
|
- * @param groupCode
|
|
|
- * @param projectId
|
|
|
- * @param equipId
|
|
|
- * @return
|
|
|
- */
|
|
|
- private int updateEquipInfo(Map<String, Object> tempMap, String groupCode, String projectId, String equipId) {
|
|
|
- ObjectMapper objectMapper = SpringHelper.getBean(ObjectMapper.class);
|
|
|
-
|
|
|
- Set<String> keySet = tempMap.keySet();
|
|
|
- ObjectNode updateEquip = objectMapper.createObjectNode();
|
|
|
- for (String key : keySet) {
|
|
|
- Object obj = tempMap.get(key);
|
|
|
-
|
|
|
- updateEquip.put("id", equipId);
|
|
|
- if (obj instanceof Date) {
|
|
|
- updateEquip.putPOJO(key, obj);
|
|
|
- } else {
|
|
|
- updateEquip.put(key, obj.toString());
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- ObjectDigital updateOne = DigitalObjectFacade.updateOne(groupCode, projectId, AdmCommonConstant.APP_ID, AdmCommonConstant.USER_ID, updateEquip);
|
|
|
- return updateOne == null ? 0 : 1;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 获取类型定义
|
|
|
- *
|
|
|
- * @param code
|
|
|
- * @return
|
|
|
- */
|
|
|
- private ObjectTypeDefine getObjectTypeDefine(String groupCode, String projectId, String code) {
|
|
|
- QueryCriteria queryCriteria = new QueryCriteria();
|
|
|
- ObjectMapper objectMapper = SpringHelper.getBean(ObjectMapper.class);
|
|
|
- ObjectNode condition = objectMapper.createObjectNode();
|
|
|
- JSONObject arrays = new JSONObject();
|
|
|
- arrays.put("$ne", "system");
|
|
|
- condition.putPOJO("parentCode", arrays);
|
|
|
- condition.put("code", code);
|
|
|
- queryCriteria.setCriteria(condition);
|
|
|
-
|
|
|
- List<ObjectTypeDefine> objectType = DigitalDefineFacade.queryObjectType(groupCode, projectId, AdmCommonConstant.APP_ID, AdmCommonConstant.USER_ID, queryCriteria);
|
|
|
- return CollectionUtil.isEmpty(objectType) ? null : objectType.get(0);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 获取设备
|
|
|
- *
|
|
|
- * @param groupCode
|
|
|
- * @param projectId
|
|
|
- * @param primaryKey
|
|
|
- * @param code
|
|
|
- * @param classCode
|
|
|
- * @return
|
|
|
- */
|
|
|
- private List<ObjectNode> getEquipmentList(String groupCode, String projectId, String primaryKey, String code, String classCode) {
|
|
|
- QueryCriteria queryCriteria = new QueryCriteria();
|
|
|
- ObjectMapper objectMapper = SpringHelper.getBean(ObjectMapper.class);
|
|
|
- ObjectNode condition = objectMapper.createObjectNode();
|
|
|
- if (StrUtil.isAllNotBlank(primaryKey, code)) {
|
|
|
- condition.put(primaryKey, code);
|
|
|
- }
|
|
|
- condition.put("classCode", classCode);
|
|
|
- queryCriteria.setCriteria(condition);
|
|
|
-
|
|
|
- List<ObjectNode> objectNodes = DigitalObjectFacade.query(groupCode, projectId, AdmCommonConstant.APP_ID, AdmCommonConstant.USER_ID, queryCriteria);
|
|
|
- return objectNodes;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
* 设置填充色
|
|
|
*
|
|
|
* @param workbook
|
|
@@ -1182,41 +768,6 @@ public class AdmEquipmentController {
|
|
|
this.setColor(workbook,56,94,15,createCell);
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 添加绑定关系
|
|
|
- */
|
|
|
- private void processRelations(List<AdmEquipment> vosR){
|
|
|
- if(CollUtil.isNotEmpty(vosR)) {
|
|
|
- List<RelationDTO> relationDTOS = new ArrayList<>(vosR.size());
|
|
|
- vosR.forEach(admEquipment -> {
|
|
|
- if (StrUtil.isNotEmpty(admEquipment.getBuildingId())) {
|
|
|
- relationDTOS.add(new RelationDTO(null, AdmRelationTypeEnum.EQ2BD.getGraphCode(), AdmRelationTypeEnum.EQ2BD.getRelCode(), admEquipment.getClassCode(), admEquipment.getId(), admEquipment.getBuildingId()));
|
|
|
- }
|
|
|
- if (StrUtil.isNotEmpty(admEquipment.getFloorId())) {
|
|
|
- relationDTOS.add(new RelationDTO(null, AdmRelationTypeEnum.EQ2FL.getGraphCode(), AdmRelationTypeEnum.EQ2FL.getRelCode(), admEquipment.getClassCode(), admEquipment.getId(),admEquipment.getFloorId()));
|
|
|
- }
|
|
|
- });
|
|
|
- if (CollUtil.isNotEmpty(relationDTOS)) {
|
|
|
- relationService.doSave(AdmContextUtil.toDmpContext(), relationDTOS);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 删除关系
|
|
|
- * @param euipId
|
|
|
- * @param queryCriteria
|
|
|
- * @param relCode
|
|
|
- */
|
|
|
- private void dealRelation(String euipId, QueryCriteria queryCriteria, String relCode){
|
|
|
- ObjectNode rBd = JsonNodeFactory.instance.objectNode();
|
|
|
- rBd.put("objFrom",euipId);
|
|
|
- rBd.put("relCode",relCode);
|
|
|
- queryCriteria.setCriteria(rBd);
|
|
|
- relationService.doDelete(AdmContextUtil.toDmpContext(), queryCriteria);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
/**
|
|
|
* 组装需要导出的设备信息点
|
|
|
* @param groupCode
|