Commit 9cdd2b7d authored by hkl's avatar hkl

feat:1.动静态分析代码核心业务代码提交

parent 69c00675
......@@ -2,6 +2,11 @@ package org.jeecg.modules.dynamicStaticAnalysis.algorithm;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.convert.Converter;
import cn.hutool.core.util.ObjectUtil;
import org.jeecg.modules.checkData.dynamicStaticGeometricData.entity.RailInspectionEquipmentItem;
import org.jeecg.modules.checkData.dynamicStaticGeometricData.entity.RailInspectionEquipmentItemDetail;
import org.jeecg.modules.checkData.dynamicStaticGeometricData.service.IRailInspectionEquipmentItemDetailService;
import org.jeecg.modules.checkData.dynamicStaticGeometricData.service.IRailInspectionEquipmentItemService;
import org.jeecg.modules.checkData.equipmentCheckData.entity.MovementCourse;
import org.jeecg.modules.checkData.equipmentCheckData.entity.MovementCourseInfo;
import org.jeecg.modules.checkData.equipmentCheckData.service.IMovementCourseInfoService;
......@@ -16,8 +21,10 @@ import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import java.util.stream.Collectors;
/**
......@@ -35,6 +42,10 @@ public class AnalysisAlgorithm {
private IMovementCourseInfoService movementCourseInfoService;
@Resource
private IMovementCourseService movementCourseService;
@Resource
private IRailInspectionEquipmentItemService railInspectionEquipmentItemService;
@Resource
private IRailInspectionEquipmentItemDetailService railInspectionEquipmentItemDetailService;
/**
* 分析
......@@ -49,9 +60,11 @@ public class AnalysisAlgorithm {
// 1.2 按公里数正序排序所有道岔,钢轨,曲线,竖曲线
List<Map<String, Object>> unitDeviceList = analysisAlgorithmMapper.getUnitDevice(analysisBatch.getLightRailId(), analysisBatch.getLineAliasId());
Map<String, Map<String, Object>> unitDeviceTable = new TreeMap<>();
// 1.3 获取检查数据
for (AnalysisBatchCheckDataMap checkDataMap : analysisBatchCheckDataMapList) {
// 检查数据类型 1-人工静态检查 2-轨检仪静态检查 3-轨检车检查 4-添乘仪检查
if (1 == checkDataMap.getEkType()) {
// 1 获取人工检查数据
......@@ -67,11 +80,9 @@ public class AnalysisAlgorithm {
// 2 循环遍历检查项目比较【开始-结束】来映射关联关系
for (MovementCourse checkItem : checkItemList) {
// 2.1 这里可能出现开始时间比结束时间大的情况
String seq = "ASC";
BigDecimal checkItemStartingMileage = checkItem.getCourseStartingMileage();
BigDecimal checkItemEndMileage = checkItem.getCourseEndMileage();
if (checkItemStartingMileage.compareTo(checkItemEndMileage) > 0) {
seq = "DESC"; // 说明起始和结束里程颠倒了
checkItemStartingMileage = checkItem.getCourseEndMileage();
checkItemEndMileage = checkItem.getCourseStartingMileage();
}
......@@ -85,30 +96,92 @@ public class AnalysisAlgorithm {
if (checkItemStartingMileage.compareTo(centerMileage) > 0) {
break;
}
// 2.2.1 命中检查项目
if (checkItemStartingMileage.compareTo(centerMileage) <= 0 && checkItemEndMileage.compareTo(centerMileage) > 0) {
List<MovementCourseInfo> movementCourseInfos = checkItemItemDetailMap.get(checkItem.getId());
if (ObjectUtil.isNotEmpty(movementCourseInfos)) {
// 1 处理3个格子映射问题
Map<String, List<MovementCourseInfo>> trackCodeMap = movementCourseInfos.stream()
.collect(Collectors.groupingBy(MovementCourseInfo::getTrackCode));
int size = trackCodeMap.size();
BigDecimal averageDec = checkItemStartingMileage.add(checkItemEndMileage).divide(new BigDecimal(size), 3, RoundingMode.HALF_UP);
List<String> trackCodes = trackCodeMap.keySet().stream()
.mapToInt(Integer::valueOf)
.sorted()
.mapToObj(String::valueOf)
.collect(Collectors.toList());
BigDecimal currentStartMileage = checkItemStartingMileage;
BigDecimal currentEndEndMileage = checkItemStartingMileage.add(averageDec);
for (String trackCode : trackCodes) {
// 2.命中格子
if (currentStartMileage.compareTo(centerMileage) <= 0 && currentEndEndMileage.compareTo(centerMileage) > 0) {
String unitCode = Convert.toStr(unitDevice.get("unitCode"));
// 人工检查数据
List<MovementCourseInfo> labourCheck = trackCodeMap.get(trackCode);
unitDevice.put("labourCheck", labourCheck);
Map<String, Object> unitDeviceMap = unitDeviceTable.get(unitCode);
if (unitDeviceMap == null) {
unitDeviceTable.put(unitCode, unitDevice);
}
} else {
currentStartMileage = currentEndEndMileage;
currentEndEndMileage = currentEndEndMileage.add(averageDec);
}
}
Map<String, List<MovementCourseInfo>> trackCodeMap = movementCourseInfos.stream().collect(Collectors.groupingBy(MovementCourseInfo::getTrackCode));
int size = trackCodeMap.size();
if (size != 0) {
BigDecimal divide = checkItemStartingMileage.add(checkItemEndMileage).divide(new BigDecimal(size), 3, RoundingMode.HALF_UP);
}
}
}
}
} else if (2 == checkDataMap.getEkType()) {
// 1 获取轨检仪静态检查
List<RailInspectionEquipmentItem> checkItemList = railInspectionEquipmentItemService.lambdaQuery()
.eq(RailInspectionEquipmentItem::getRailInspectionEquipmentId, checkDataMap.getEkId())
.list();
List<RailInspectionEquipmentItemDetail> checkItemItemDetailList = railInspectionEquipmentItemDetailService.lambdaQuery()
.eq(RailInspectionEquipmentItemDetail::getRailInspectionEquipmentId, checkDataMap.getEkId())
.list();
Map<String, List<RailInspectionEquipmentItemDetail>> checkItemItemDetailMap = checkItemItemDetailList.stream()
.collect(Collectors.groupingBy(RailInspectionEquipmentItemDetail::getRailInspectionEquipmentId));
// 2 循环遍历检查项目比较【开始-结束】来映射关联关系
for (RailInspectionEquipmentItem checkItem : checkItemList) {
// 2.1 这里可能出现开始时间比结束时间大的情况
BigDecimal checkItemStartingMileage = checkItem.getCourseStartingMileage();
BigDecimal checkItemEndMileage = checkItem.getCourseEndMileage();
if (checkItemStartingMileage.compareTo(checkItemEndMileage) > 0) {
checkItemStartingMileage = checkItem.getCourseEndMileage();
checkItemEndMileage = checkItem.getCourseStartingMileage();
}
// 2.2 单元设备中心里程落在检查项目【开始-结束】这个区间视为这个区间的单元设备
for (Map<String, Object> unitDevice : unitDeviceList) {
BigDecimal startMileage = Convert.toBigDecimal(unitDevice.get("startMileage"));
BigDecimal endMileage = Convert.toBigDecimal(unitDevice.get("endMileage"));
BigDecimal centerMileage = startMileage.add(endMileage).divide(new BigDecimal("2"), 3, RoundingMode.HALF_UP);
if (checkItemStartingMileage.compareTo(centerMileage) > 0) {
break;
}
// 2.2.1 命中检查项目
if (checkItemStartingMileage.compareTo(centerMileage) <= 0 && checkItemEndMileage.compareTo(centerMileage) > 0) {
}
}
}
} else if (3 == checkDataMap.getEkType()) {
} else {
}
}
// 1.映射单元格
// 1.映射单元格
// 2.评分
}
// 2.评分
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment