diff --git a/inspect-main/inspect-main-task/src/main/java/com/inspect/partrolresult/controller/PatrolResultController.java b/inspect-main/inspect-main-task/src/main/java/com/inspect/partrolresult/controller/PatrolResultController.java index a0d13c3..5e81266 100644 --- a/inspect-main/inspect-main-task/src/main/java/com/inspect/partrolresult/controller/PatrolResultController.java +++ b/inspect-main/inspect-main-task/src/main/java/com/inspect/partrolresult/controller/PatrolResultController.java @@ -1115,7 +1115,7 @@ public class PatrolResultController extends BaseController { PatrolTask patrolTask = new PatrolTask(); patrolTask.setTaskCode(patrolTaskStatusItem.getTaskCode()); List list = patrolTaskService.selectPatrolTaskList(patrolTask); - if (CollectionUtils.isEmpty(list)) { + if (StringUtils.isEmpty(patrolTaskStatusItem.getTaskCode()) || CollectionUtils.isEmpty(list)) { logger.info("TASK CODE: {} NO EXIST, SKIP IT!", patrolTaskStatusItem.getTaskCode()); } else { try { diff --git a/inspect-main/inspect-main-task/src/main/java/com/inspect/partrolresult/service/impl/PatrolResultServiceImpl.java b/inspect-main/inspect-main-task/src/main/java/com/inspect/partrolresult/service/impl/PatrolResultServiceImpl.java index a242d45..528f2c3 100644 --- a/inspect-main/inspect-main-task/src/main/java/com/inspect/partrolresult/service/impl/PatrolResultServiceImpl.java +++ b/inspect-main/inspect-main-task/src/main/java/com/inspect/partrolresult/service/impl/PatrolResultServiceImpl.java @@ -964,24 +964,22 @@ public class PatrolResultServiceImpl implements IPatrolResultService { } public String statisticsAnalyseNumV3(List lineIds, String filter) { -// int okNum = 0; -// int failNum = 0; -// int confirmNum = 0; + int okNum = 0; + int failNum = 0; + int confirmNum = 0; List analyses = resultAnalysisMapper.selectResultAnalysisListByMainIdsNew(lineIds, filter); int totalNum = analyses.size(); log.info("lineIds:{},statisticsAnalyseNum analyses:{}", lineIds, analyses); -// for (ResultAnalysis analyse : analyses) { -// String pointStatus = analyse.getPointStatus(); -// if (pointStatus.equals("0")) { -// ++failNum; -// } else if (pointStatus.equals("1")) { -// ++okNum; -// } else if (pointStatus.equals("2")) { -// ++confirmNum; -// } else { -// log.error("【归档-统计分析数量】异常分析类型:{}", analyse.getPointStatus()); -// } -// } + for (ResultAnalysis analyse : analyses) { + String resultType = analyse.getResultType(); + if (resultType.equals("0")) { + ++confirmNum; + } else if (resultType.equals("1")) { + ++okNum; + } else if (resultType.equals("2")) { + ++failNum; + } + } // // int lastNum = totalNum - failNum - confirmNum; // if (lastNum != okNum) { @@ -990,7 +988,7 @@ public class PatrolResultServiceImpl implements IPatrolResultService { // return String.format("总点位:%d个,已检点位:%d个,未检点位:0个,正常点位:%d个,异常点位:%d个,待人工确认点位:%d个。", totalNum, totalNum, okNum, failNum, confirmNum); // return String.format(messageUtils.get("总点位:%d个,已检点位:%d个,未检点位:0个,正常点位:%d个,异常点位:%d个,待人工确认点位:%d个。"), totalNum, totalNum, okNum, failNum, confirmNum); - return String.format(messageUtils.get("缺陷总数:%d个"), totalNum); + return String.format(messageUtils.get("缺陷总数:%d个"), confirmNum); } diff --git a/inspect-main/inspect-main-task/src/main/java/com/inspect/resultmain/controller/PatrolTaskResultMainController.java b/inspect-main/inspect-main-task/src/main/java/com/inspect/resultmain/controller/PatrolTaskResultMainController.java index 7f2335c..2905545 100644 --- a/inspect-main/inspect-main-task/src/main/java/com/inspect/resultmain/controller/PatrolTaskResultMainController.java +++ b/inspect-main/inspect-main-task/src/main/java/com/inspect/resultmain/controller/PatrolTaskResultMainController.java @@ -242,7 +242,7 @@ public class PatrolTaskResultMainController extends BaseController { }); PrintUtil.useTime("saveReport", startTime); // 当saveReport完成后,再异步处理所有导出任务 - saveReportFuture.thenAcceptAsync(reportIds -> { + CompletableFuture reportsToExportFuture = saveReportFuture.thenAcceptAsync(reportIds -> { logger.info("-----------[ARCHIVE] Saved export reportIds: {}", reportIds); if (reportIds.isEmpty()) { logger.warn("No reports to export"); @@ -262,6 +262,7 @@ public class PatrolTaskResultMainController extends BaseController { }); PrintUtil.useTime("exportExcelWordAndZip", startTime); // logger.info("-----------[ARCHIVE] EndTime: {}, reportIds: {}", DateUtil.now(), reportIds); + CompletableFuture.allOf(reportsToExportFuture).join(); return toAjax(1); } @@ -2092,9 +2093,9 @@ public class PatrolTaskResultMainController extends BaseController { // InspectionReportData inspection = new InspectionReportData(); // inspection.setPointStatus(MessageUtils.get("待人工确认")); // list.add(inspection); - InspectionReportData inection = new InspectionReportData(); - inection.setPointStatus(MessageUtils.get("正常")); - list.add(inection); +// InspectionReportData inection = new InspectionReportData(); +// inection.setPointStatus(MessageUtils.get("正常")); +// list.add(inection); inspectionReportData.setPointStatus(MessageUtils.get("缺陷")); list.add(inspectionReportData); int total = 0; @@ -2850,7 +2851,7 @@ public class PatrolTaskResultMainController extends BaseController { cella1 = rowb1.createCell(15); if (crr.getImgType().equals("0")) { try { - insertImage(wb, patriarch, this.images(crr.getImg(), inputStreamMap), 7 + total, 0, 2); + insertImageLingzhou(wb, patriarch, this.images(crr.getImg(), inputStreamMap), 7 + total, 0, 2); } catch (Exception var97) { var97.printStackTrace(); } @@ -2960,6 +2961,17 @@ public class PatrolTaskResultMainController extends BaseController { } private static void insertImage(SXSSFWorkbook wb, SXSSFDrawing pa, byte[] data, int row, int column, int index) { + int x1 = 0; + int y1 = 0; + int x2 = 1023; + int y2 = 255; + if (data != null && data.length != 0) { + XSSFClientAnchor anchor = new XSSFClientAnchor(x1, y1, x2, y2, (short) 12, row - 1, (short) 15, row + 1); + pa.createPicture(anchor, wb.addPicture(data, 5)); + } + } + + private static void insertImageLingzhou(SXSSFWorkbook wb, SXSSFDrawing pa, byte[] data, int row, int column, int index) { int x1 = 0; int y1 = 0; int x2 = 1023; diff --git a/inspect-main/inspect-main-task/src/main/java/com/inspect/taskstatus/controller/PatrolTaskStatusController.java b/inspect-main/inspect-main-task/src/main/java/com/inspect/taskstatus/controller/PatrolTaskStatusController.java index a2d2090..ee7d963 100644 --- a/inspect-main/inspect-main-task/src/main/java/com/inspect/taskstatus/controller/PatrolTaskStatusController.java +++ b/inspect-main/inspect-main-task/src/main/java/com/inspect/taskstatus/controller/PatrolTaskStatusController.java @@ -743,34 +743,46 @@ public class PatrolTaskStatusController extends BaseController { log.warn("[TASK] No illegal task: {} in patrol_task", patrolTaskStatus.getTaskCode()); return; } + PatrolTask patrolTask = patrolTaskList.get(0); /** * Calc receive code */ - String receiveCode = ""; - final List bookList = patrolResultService.selectBasedataEqpBookList(BasedataEqpBookMoMain.builder().build()); - for (BasedataEqpBookMoMain book : bookList) { - if (!StringUtils.isEmpty(receiveCode) || StringUtils.isEmpty(book.getMainSystemCode())) { - continue; - } - - final String type = book.getType(); - if(StringUtils.isEmpty(type)) { - continue; - } - if (posType.equals("0") && (type.equals("10") || type.equals("11"))) { - log.info("[DEBUG] receiveCode three: id: {}", book.getEqpBookId()); - receiveCode = book.getMainSystemCode(); - } else if (posType.equals("1") && ((type.equals("1") || type.equals("2") || type.equals("3")))) { - log.info("[DEBUG] receiveCode one: id: {}", book.getEqpBookId()); - receiveCode = book.getMainSystemCode(); - } else if (posType.equals("2") && type.equals("13")) { - log.info("[DEBUG] receiveCode two: id: {}", book.getEqpBookId()); - receiveCode = book.getMainSystemCode(); + final List bookList = patrolResultService.selectBasedataEqpBookList(BasedataEqpBookMoMain.builder().build()); + String[] devNoArr = patrolTask.getDevNo().split(StringUtils.COMMA); + Set receiveCodeSet = new HashSet<>(); + for (int i = 0; i < devNoArr.length; i++) { + BasedataEqpBookMoMain basedataEqpbookMomain = new BasedataEqpBookMoMain(); + basedataEqpbookMomain.setPatrolDeviceCode(devNoArr[i]); + List eqpBookMoMains = patrolResultService.selectBasedataEqpBookList(basedataEqpbookMomain); + if (!eqpBookMoMains.isEmpty() && eqpBookMoMains.get(0).getMainSystemCode() != null) { + String receiveCode = eqpBookMoMains.get(0).getMainSystemCode(); + receiveCodeSet.add(receiveCode); } } - log.info("[TASK] receiveCode: {}", receiveCode); +// for (BasedataEqpBookMoMain book : bookList) { +// if (!StringUtils.isEmpty(receiveCode) || StringUtils.isEmpty(book.getMainSystemCode())) { +// continue; +// } +// +// final String type = book.getType(); +// if(StringUtils.isEmpty(type)) { +// continue; +// } +// +// if (posType.equals("0") && (type.equals("10") || type.equals("11"))) { +// log.info("[DEBUG] receiveCode three: id: {}", book.getEqpBookId()); +// receiveCode = book.getMainSystemCode(); +// } else if (posType.equals("1") && ((type.equals("1") || type.equals("2") || type.equals("3")))) { +// log.info("[DEBUG] receiveCode one: id: {}", book.getEqpBookId()); +// receiveCode = book.getMainSystemCode(); +// } else if (posType.equals("2") && type.equals("13")) { +// log.info("[DEBUG] receiveCode two: id: {}", book.getEqpBookId()); +// receiveCode = book.getMainSystemCode(); +// } +// } + log.info("[TASK] receiveCodeSet: {}", receiveCodeSet); /** * Calc send code @@ -841,26 +853,27 @@ public class PatrolTaskStatusController extends BaseController { feignTaskClient.updateCameraPatrolTaskExecRecordState(patrolTaskStatus.getTaskCode(), patrolTaskStatus.getCode(), cmd); } } else if (posType.equals("1") || posType.equals("2")) { - for (String wrj : wrjCode) { - String strSendTaskControl = JSONObject.toJSONString(SendTask.builder().receiveCode(receiveCode).sendCode(sendCode).code(wrj).type("1").command("5").items(Collections.singletonList(PatrolSendTask.builder().value("1").build())).build()); - log.info("[TASK] MODE CHANGE: {}", strSendTaskControl); - feignTaskClient.sendCommand(strSendTaskControl); - } - - SendTask sendTask = new SendTask(); - sendTask.setReceiveCode(receiveCode); - sendTask.setSendCode(sendCode); - if ("1".equals(patrolTaskStatus.getCommand())) { - sendTask.setCode(patrolTaskTemp.getTaskId() + ""); - } else { - sendTask.setCode(patrolTaskStatus.getTaskPatrolledId()); + // 机器人,无人机 + for (String receiveCode : receiveCodeSet) { + for (String wrj : wrjCode) { + String strSendTaskControl = JSONObject.toJSONString(SendTask.builder().receiveCode(receiveCode).sendCode(sendCode).code(wrj).type("1").command("5").items(Collections.singletonList(PatrolSendTask.builder().value("1").build())).build()); + log.info("[TASK] MODE CHANGE: {}", strSendTaskControl); + feignTaskClient.sendCommand(strSendTaskControl); + } + SendTask sendTask = new SendTask(); + sendTask.setReceiveCode(receiveCode); + sendTask.setSendCode(sendCode); + if ("1".equals(patrolTaskStatus.getCommand())) { + sendTask.setCode(patrolTaskTemp.getTaskId() + ""); + } else { + sendTask.setCode(patrolTaskStatus.getTaskPatrolledId()); + } + sendTask.setType("41"); + sendTask.setCommand(patrolTaskStatus.getCommand()); + String sendTaskCmd = JSONObject.toJSONString(sendTask); + log.info("[TASK] TASK STATUS CONTROL: {}", sendTaskCmd); + feignTaskClient.sendCommand(sendTaskCmd); } - - sendTask.setType("41"); - sendTask.setCommand(patrolTaskStatus.getCommand()); - String sendTaskCmd = JSONObject.toJSONString(sendTask); - log.info("[TASK] TASK CONTROL: {}", sendTaskCmd); - feignTaskClient.sendCommand(sendTaskCmd); } } diff --git a/inspect-main/inspect-main-task/src/main/resources/mapper/task/PatrolResultMapper.xml b/inspect-main/inspect-main-task/src/main/resources/mapper/task/PatrolResultMapper.xml index dfc8dbf..115c0ce 100644 --- a/inspect-main/inspect-main-task/src/main/resources/mapper/task/PatrolResultMapper.xml +++ b/inspect-main/inspect-main-task/src/main/resources/mapper/task/PatrolResultMapper.xml @@ -250,7 +250,14 @@ left join basedata_patrolpoint c on a.device_id = c.patrol_point_id left join basedata_device d on c.device_id = d.device_id left join basedata_area e on e.area_id = d.area_id - left join patrol_preset_pos f on c.patrol_point_id = f.patrol_point_id + + + left join basedata_patrolpoint_preset f on c.patrol_point_id = f.patrol_point_id + + + left join patrol_preset_pos f on c.patrol_point_id = f.patrol_point_id + + left join basedata_eqpbook_channel g on f.channel_id = g.channel_id diff --git a/inspect-metadata/src/main/java/com/inspect/metadata/prodevmnt/domain/vo/ProMainDevicePatrolEquTreeSelect.java b/inspect-metadata/src/main/java/com/inspect/metadata/prodevmnt/domain/vo/ProMainDevicePatrolEquTreeSelect.java index 6aefbbc..f680cb7 100644 --- a/inspect-metadata/src/main/java/com/inspect/metadata/prodevmnt/domain/vo/ProMainDevicePatrolEquTreeSelect.java +++ b/inspect-metadata/src/main/java/com/inspect/metadata/prodevmnt/domain/vo/ProMainDevicePatrolEquTreeSelect.java @@ -198,4 +198,31 @@ public class ProMainDevicePatrolEquTreeSelect implements Serializable { public void setChildren(List children) { this.children = children; } + + @Override + public String toString() { + return "ProMainDevicePatrolEquTreeSelect{" + + "dataId='" + dataId + '\'' + + ", label='" + label + '\'' + + ", parentId='" + parentId + '\'' + + ", mainDeviceId=" + mainDeviceId + + ", mainDeviceName='" + mainDeviceName + '\'' + + ", powerMainEquFlag='" + powerMainEquFlag + '\'' + + ", deviceId=" + deviceId + + ", componentName='" + componentName + '\'' + + ", componentFlag='" + componentFlag + '\'' + + ", positionX='" + positionX + '\'' + + ", positionY='" + positionY + '\'' + + ", positionZ='" + positionZ + '\'' + + ", patrolpointFlag='" + patrolpointFlag + '\'' + + ", patrolpointId=" + patrolpointId + + ", patrolpointName='" + patrolpointName + '\'' + + ", presetCode='" + presetCode + '\'' + + ", eqpbookId=" + eqpbookId + + ", patroldeviceFlag='" + patroldeviceFlag + '\'' + + ", patroldeviceCode='" + patroldeviceCode + '\'' + + ", patroldeviceName='" + patroldeviceName + '\'' + + ", children=" + children + + '}'; + } } diff --git a/inspect-metadata/src/main/java/com/inspect/metadata/prodevmnt/service/impl/BasedataDeviceServiceImpl.java b/inspect-metadata/src/main/java/com/inspect/metadata/prodevmnt/service/impl/BasedataDeviceServiceImpl.java index 347cfdc..fcc8086 100644 --- a/inspect-metadata/src/main/java/com/inspect/metadata/prodevmnt/service/impl/BasedataDeviceServiceImpl.java +++ b/inspect-metadata/src/main/java/com/inspect/metadata/prodevmnt/service/impl/BasedataDeviceServiceImpl.java @@ -26,11 +26,7 @@ import com.inspect.base.core.utils.DateUtils; import com.inspect.base.core.utils.StringUtils; import com.inspect.base.core.utils.bean.BeanUtils; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.stream.Collectors; import org.slf4j.Logger; @@ -323,7 +319,7 @@ public class BasedataDeviceServiceImpl implements IBasedataDeviceService { return !this.getChildList(list, t).isEmpty(); } - public List treeProMainDevicePatrolEquSelect(List mainDevices) { + public List treeProMainDevicePatrolEquSelectOld(List mainDevices) { List mainDevVOS = new ArrayList<>(); List mainDeviceExistPointList = new ArrayList<>(); if (!mainDevices.isEmpty()) { @@ -335,7 +331,9 @@ public class BasedataDeviceServiceImpl implements IBasedataDeviceService { mainDevice = iterator.next(); BasedataPatrolPoint patrolPointMainDevQuery = new BasedataPatrolPoint(); patrolPointMainDevQuery.setMainDeviceId(mainDevice.getDeviceId()); + // 查询设备下有预置点的点位信息(一个) basedataPatrolpoint = this.basedataPatrolPointMapper.selectBasedataPatrolPointPresetForOne(patrolPointMainDevQuery); + // 该设备下存在预置点位信息 if (null != basedataPatrolpoint) { BasedataDevice mainDeviceForQuery = new BasedataDevice(); BeanUtils.copyBeanProp(mainDeviceForQuery, mainDevice); @@ -349,12 +347,13 @@ public class BasedataDeviceServiceImpl implements IBasedataDeviceService { mainDevVO.setPositionX(mainDevice.getPositionX()); mainDevVO.setPositionY(mainDevice.getPositionY()); mainDevVO.setPositionZ(mainDevice.getPositionZ()); + // 添加设备信息 mainDevVOS.add(mainDevVO); } } iterator = mainDeviceExistPointList.iterator(); - logger.info("---222-------mainDeviceExistPointList:{}", mainDeviceExistPointList); + logger.info("---222------存在预置位的点位设备-mainDeviceExistPointList:{}", mainDeviceExistPointList); label70: while (true) { List patrolpointList; @@ -370,6 +369,7 @@ public class BasedataDeviceServiceImpl implements IBasedataDeviceService { basedataPatrolpoint = new BasedataPatrolPoint(); basedataPatrolpoint.setMainDeviceId(mainDevice.getDeviceId()); mapDevToPoint = new HashMap<>(); + // 查询设备下的所有点位信息 patrolpointList = this.basedataPatrolPointMapper.selectBasedataPatrolPointList(basedataPatrolpoint); } while (patrolpointList.isEmpty()); @@ -380,7 +380,9 @@ public class BasedataDeviceServiceImpl implements IBasedataDeviceService { patrolpoint = (BasedataPatrolPoint) iterator1.next(); BasedataPatrolPoint patrolPointIsExistPreset = new BasedataPatrolPoint(); patrolPointIsExistPreset.setPatrolPointId(patrolpoint.getPatrolPointId()); + // 判断点位下是否存在预置信息 BasedataPatrolPoint patrolPointExistOne = this.basedataPatrolPointMapper.selectBasedataPatrolPointPresetForOne(patrolPointIsExistPreset); + // 存在预置信息 if (null != patrolPointExistOne) { Long mainDeviceId = patrolpoint.getMainDeviceId(); Long deviceId = patrolpoint.getDeviceId(); @@ -399,6 +401,7 @@ public class BasedataDeviceServiceImpl implements IBasedataDeviceService { pointTreeVO.setPositionX(patrolpoint.getPositionX()); pointTreeVO.setPositionY(patrolpoint.getPositionY()); pointTreeVO.setPositionZ(patrolpoint.getPositionZ()); + // 添加点位信息 mainDevVOS.add(pointTreeVO); } } @@ -415,6 +418,7 @@ public class BasedataDeviceServiceImpl implements IBasedataDeviceService { patrolpoint = (BasedataPatrolPoint) iterator1.next(); BasedataPatrolPointPreset basedataPatrolpointPreset = new BasedataPatrolPointPreset(); basedataPatrolpointPreset.setPatrolPointId(patrolpoint.getPatrolPointId()); + // 查询点位下预置位信息 patrolpointPresetS = this.basedataPatrolPointPresetMapper.selectBasedataPatrolPointPresetList(basedataPatrolpointPreset); } while (patrolpointPresetS.isEmpty()); logger.info("---444-------patrolpointPresetS:{}", patrolpointPresetS); @@ -438,6 +442,7 @@ public class BasedataDeviceServiceImpl implements IBasedataDeviceService { pointPreSetTreeVO.setDataId(patrolpoint.getDeviceId() + "-" + patrolpoint.getPatrolPointId() + basedataEqpbook.getEqpBookId()); pointPreSetTreeVO.setPatroldeviceFlag("Yes"); map.put(basedataEqpbook.getEqpBookId(), basedataEqpbook.getEqpBookId()); + // 添加巡视设备(ebook)信息 mainDevVOS.add(pointPreSetTreeVO); } } @@ -450,7 +455,193 @@ public class BasedataDeviceServiceImpl implements IBasedataDeviceService { return (List) ProMainDevicePatrolEquTreeSelectUtil.buildDeviceTree(mainDevVOS); } - public void recursionGetProMainDevice(Long mainDeviceId, String mainDeviceName, Long deviceId, List mainDevVOS, HashMap mapDevToPoint) { + + public List treeProMainDevicePatrolEquSelect(List mainDevices) { + List mainDevVOS = new ArrayList<>(); + List mainDeviceExistPointList = new ArrayList<>(); + + if (mainDevices == null || mainDevices.isEmpty()) { + return mainDevVOS; + } + + logger.info("---111-------mainDevices:{}", mainDevices); + + // 第一层处理:主设备预置点检查 + for (BasedataDevice mainDevice : mainDevices) { + BasedataPatrolPoint patrolPointMainDevQuery = new BasedataPatrolPoint(); + patrolPointMainDevQuery.setMainDeviceId(mainDevice.getDeviceId()); + + // 查询设备下的预置点 + BasedataPatrolPoint basedataPatrolpoint = this.basedataPatrolPointMapper.selectBasedataPatrolPointPresetForOne(patrolPointMainDevQuery); + + if (basedataPatrolpoint != null) { + // 复制设备信息到新对象 + BasedataDevice mainDeviceForQuery = new BasedataDevice(); + BeanUtils.copyBeanProp(mainDeviceForQuery, mainDevice); + mainDeviceExistPointList.add(mainDeviceForQuery); + + // 创建主设备节点 + ProMainDevicePatrolEquTreeSelect mainDevVO = new ProMainDevicePatrolEquTreeSelect(); + mainDevVO.setDataId(String.valueOf(mainDevice.getDeviceId())); + mainDevVO.setMainDeviceId(mainDevice.getDeviceId()); + mainDevVO.setLabel(mainDevice.getDeviceName()); + mainDevVO.setMainDeviceName(mainDevice.getDeviceName()); + mainDevVO.setPowerMainEquFlag("Yes"); + mainDevVO.setPositionX(mainDevice.getPositionX()); + mainDevVO.setPositionY(mainDevice.getPositionY()); + mainDevVO.setPositionZ(mainDevice.getPositionZ()); + mainDevVOS.add(mainDevVO); + } + } + + logger.info("---222------存在预置位的点位设备-mainDeviceExistPointList:{}", mainDeviceExistPointList); + + // 第二层处理:设备下的点位信息 + for (BasedataDevice mainDevice : mainDeviceExistPointList) { + String mainDeviceName = mainDevice.getDeviceName(); + + BasedataPatrolPoint basedataPatrolpoint = new BasedataPatrolPoint(); + basedataPatrolpoint.setMainDeviceId(mainDevice.getDeviceId()); + + // 查询设备下的所有点位信息 + List patrolpointList = this.basedataPatrolPointMapper.selectBasedataPatrolPointList(basedataPatrolpoint); + if (patrolpointList.isEmpty()) { + continue; + } + + logger.info("---333-------patrolpointList:{}", patrolpointList); + + Map mapDevToPoint = new HashMap<>(); + + // 处理每个点位 + for (BasedataPatrolPoint patrolpoint : patrolpointList) { + BasedataPatrolPoint patrolPointIsExistPreset = new BasedataPatrolPoint(); + patrolPointIsExistPreset.setPatrolPointId(patrolpoint.getPatrolPointId()); + + // 检查点位是否存在预置信息 + BasedataPatrolPoint patrolPointExistOne = this.basedataPatrolPointMapper.selectBasedataPatrolPointPresetForOne(patrolPointIsExistPreset); + + if (patrolPointExistOne != null) { + Long mainDeviceId = patrolpoint.getMainDeviceId(); + Long deviceId = patrolpoint.getDeviceId(); + + // 处理非主设备的情况 + if (deviceId.longValue() != mainDeviceId.longValue() && !mapDevToPoint.containsKey(deviceId)) { + this.recursionGetProMainDevice(mainDeviceId, mainDeviceName, deviceId, mainDevVOS, mapDevToPoint); + } + + // 创建点位节点 + ProMainDevicePatrolEquTreeSelect pointTreeVO = new ProMainDevicePatrolEquTreeSelect(); + pointTreeVO.setPatrolpointId(patrolpoint.getPatrolPointId()); + pointTreeVO.setDataId(deviceId + "-" + patrolpoint.getPatrolPointId()); + pointTreeVO.setLabel(patrolpoint.getPatrolPointName()); + pointTreeVO.setPatrolpointName(patrolpoint.getPatrolPointName()); + pointTreeVO.setMainDeviceName(mainDeviceName); + pointTreeVO.setParentId(String.valueOf(deviceId)); + pointTreeVO.setPatrolpointFlag("Yes"); + pointTreeVO.setPositionX(patrolpoint.getPositionX()); + pointTreeVO.setPositionY(patrolpoint.getPositionY()); + pointTreeVO.setPositionZ(patrolpoint.getPositionZ()); + mainDevVOS.add(pointTreeVO); + } + } + + // 处理点位下的预置位 + for (BasedataPatrolPoint patrolpoint : patrolpointList) { + BasedataPatrolPointPreset basedataPatrolpointPreset = new BasedataPatrolPointPreset(); + basedataPatrolpointPreset.setPatrolPointId(patrolpoint.getPatrolPointId()); + + // 查询点位下的预置位信息 + List patrolpointPresetS = this.basedataPatrolPointPresetMapper.selectBasedataPatrolPointPresetList(basedataPatrolpointPreset); + if (patrolpointPresetS.isEmpty()) { + continue; + } + + logger.info("---444-------patrolpointPresetS:{}", patrolpointPresetS); + + Map map = new HashMap<>(); + + for (BasedataPatrolPointPreset preset : patrolpointPresetS) { + if (map.containsKey(preset.getEqpBookId())) { + continue; + } + + ProMainDevicePatrolEquTreeSelect pointPreSetTreeVO = new ProMainDevicePatrolEquTreeSelect(); + pointPreSetTreeVO.setParentId(patrolpoint.getDeviceId() + "-" + patrolpoint.getPatrolPointId()); + pointPreSetTreeVO.setEqpbookId(preset.getEqpBookId()); + pointPreSetTreeVO.setPresetCode(preset.getPresetCode()); + + logger.info("---555-------BasedataPatrolPointPreset:{}", preset); + + if (preset.getEqpBookId() != null) { + BasedataEqpBook basedataEqpbook = this.basedataEqpbookMapper.selectBasedataEqpBookByEqpBookId(preset.getEqpBookId()); + if (basedataEqpbook != null) { + pointPreSetTreeVO.setPatroldeviceName(basedataEqpbook.getPatrolDeviceName()); + pointPreSetTreeVO.setMainDeviceName(basedataEqpbook.getPatrolDeviceName()); + pointPreSetTreeVO.setLabel(basedataEqpbook.getPatrolDeviceName()); + pointPreSetTreeVO.setPatroldeviceCode(basedataEqpbook.getPatrolDeviceCode()); + pointPreSetTreeVO.setPatroldeviceName(basedataEqpbook.getPatrolDeviceName()); + pointPreSetTreeVO.setDataId(patrolpoint.getDeviceId() + "-" + patrolpoint.getPatrolPointId() + basedataEqpbook.getEqpBookId()); + pointPreSetTreeVO.setPatroldeviceFlag("Yes"); + + map.put(basedataEqpbook.getEqpBookId(), basedataEqpbook.getEqpBookId()); + mainDevVOS.add(pointPreSetTreeVO); + } + } + } + } + } + + logger.info("----------------mainDevVOS:{} ", mainDevVOS); + return ProMainDevicePatrolEquTreeSelectUtil.buildDeviceTree(mainDevVOS); + } + + public void recursionGetProMainDevice(Long mainDeviceId, String mainDeviceName, Long deviceId, + List mainDevVOS, + Map mapDevToPoint) { + if (mapDevToPoint.containsKey(deviceId)) { + return; + } + + if (mainDeviceId.longValue() != deviceId.longValue()) { + BasedataDevice basedataDevice = this.basedataDeviceMapper.selectBasedataDeviceByDeviceId(deviceId); + if (basedataDevice == null) { + return; + } + + ProMainDevicePatrolEquTreeSelect mainDevVO = new ProMainDevicePatrolEquTreeSelect(); + mainDevVO.setDataId(String.valueOf(deviceId)); + mainDevVO.setLabel(basedataDevice.getDeviceName()); + mainDevVO.setParentId(String.valueOf(basedataDevice.getParentId())); + mainDevVO.setMainDeviceId(mainDeviceId); + mainDevVO.setMainDeviceName(mainDeviceName); + mainDevVO.setComponentName(basedataDevice.getDeviceName()); + mainDevVO.setDeviceId(deviceId); + mainDevVO.setPowerMainEquFlag("No"); + mainDevVO.setComponentFlag("Yes"); + mainDevVO.setPositionX(basedataDevice.getPositionX()); + mainDevVO.setPositionY(basedataDevice.getPositionY()); + mainDevVO.setPositionZ(basedataDevice.getPositionZ()); + + mainDevVOS.add(mainDevVO); + mapDevToPoint.put(deviceId, basedataDevice); + + if (basedataDevice.getParentId() == null || + mainDeviceId.longValue() == basedataDevice.getParentId().longValue()) { + return; + } + + this.recursionGetProMainDevice( + mainDeviceId, + mainDeviceName, + basedataDevice.getParentId(), + mainDevVOS, + mapDevToPoint + ); + } + } + + public void recursionGetProMainDeviceOld(Long mainDeviceId, String mainDeviceName, Long deviceId, List mainDevVOS, HashMap mapDevToPoint) { if (!mapDevToPoint.containsKey(deviceId)) { if (mainDeviceId.longValue() != deviceId.longValue()) { BasedataDevice basedataDevice = this.basedataDeviceMapper.selectBasedataDeviceByDeviceId(deviceId); @@ -475,7 +666,7 @@ public class BasedataDeviceServiceImpl implements IBasedataDeviceService { } deviceId = basedataDevice.getParentId(); - this.recursionGetProMainDevice(mainDeviceId, mainDeviceName, deviceId, mainDevVOS, mapDevToPoint); + this.recursionGetProMainDeviceOld(mainDeviceId, mainDeviceName, deviceId, mainDevVOS, mapDevToPoint); } }