Commit 6c121853 authored by hkl's avatar hkl

feat: 1.轨检仪器bug修改

parent 6ca0da31
...@@ -51,11 +51,11 @@ public class RailInspectionEquipmentItem implements Serializable { ...@@ -51,11 +51,11 @@ public class RailInspectionEquipmentItem implements Serializable {
@TableField("rail_inspection_equipment_id") @TableField("rail_inspection_equipment_id")
private String railInspectionEquipmentId; private String railInspectionEquipmentId;
@ApiModelProperty("检查起始里程(m)") @ApiModelProperty("检查起始里程(km)")
@TableField("course_starting_mileage") @TableField("course_starting_mileage")
private BigDecimal courseStartingMileage; private BigDecimal courseStartingMileage;
@ApiModelProperty("检查终点里程(m)") @ApiModelProperty("检查终点里程(km)")
@TableField("course_end_mileage") @TableField("course_end_mileage")
private BigDecimal courseEndMileage; private BigDecimal courseEndMileage;
......
...@@ -24,6 +24,7 @@ import org.springframework.web.multipart.MultipartFile; ...@@ -24,6 +24,7 @@ import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.io.IOException; import java.io.IOException;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
...@@ -93,6 +94,8 @@ public class RailInspectionEquipmentItemServiceImpl extends ServiceImpl<RailInsp ...@@ -93,6 +94,8 @@ public class RailInspectionEquipmentItemServiceImpl extends ServiceImpl<RailInsp
int skipRow = analysisItemDetail(i, titleHeader, item.getId(), rowRecords, itemDetails); int skipRow = analysisItemDetail(i, titleHeader, item.getId(), rowRecords, itemDetails);
i = i + skipRow; i = i + skipRow;
} else {
i++;
} }
} }
...@@ -127,9 +130,12 @@ public class RailInspectionEquipmentItemServiceImpl extends ServiceImpl<RailInsp ...@@ -127,9 +130,12 @@ public class RailInspectionEquipmentItemServiceImpl extends ServiceImpl<RailInsp
private int analysisItemDetail(int rows, String titleHeader, String itemId, List<List<Object>> rowRecords, List<RailInspectionEquipmentItemDetail> itemDetails) { private int analysisItemDetail(int rows, String titleHeader, String itemId, List<List<Object>> rowRecords, List<RailInspectionEquipmentItemDetail> itemDetails) {
// 解析检查项目:3行:跳过2行不解析
// 解析检查项目:1行:跳过2行不解析
List<Object> checkItems = rowRecords.get(rows + 2); List<Object> checkItems = rowRecords.get(rows + 2);
// 解析规矩轨距:1行 // 解析测点:1行
List<Object> measurePoints = rowRecords.get(rows + 3);
// 解析轨距:1行
List<Object> trackGauges = rowRecords.get(rows + 4); List<Object> trackGauges = rowRecords.get(rows + 4);
// 解析水平 :1行 // 解析水平 :1行
List<Object> levels = rowRecords.get(rows + 5); List<Object> levels = rowRecords.get(rows + 5);
...@@ -139,37 +145,36 @@ public class RailInspectionEquipmentItemServiceImpl extends ServiceImpl<RailInsp ...@@ -139,37 +145,36 @@ public class RailInspectionEquipmentItemServiceImpl extends ServiceImpl<RailInsp
List<Object> others = rowRecords.get(rows + 7); List<Object> others = rowRecords.get(rows + 7);
int measurePoint = 1;
int sort = 1; int sort = 1;
for (int i = 2; i < 32; i++) { for (int i = 2; i < 32; i++) {
if (measurePoint % 8 == 0) { // 测点:测点8和9不保留
measurePoint = 1; Integer measurePoint = Convert.toInt(measurePoints.get(i));
i = i + 2; if (measurePoint == 8 || measurePoint == 9) {
continue; continue;
} else {
measurePoint++;
} }
RailInspectionEquipmentItemDetail itemDetail = new RailInspectionEquipmentItemDetail(); RailInspectionEquipmentItemDetail itemDetail = new RailInspectionEquipmentItemDetail();
itemDetail.setId(UUIDGenerator.generate()); itemDetail.setId(UUIDGenerator.generate());
itemDetail.setRailInspectionEquipmentItemId(itemId); itemDetail.setRailInspectionEquipmentItemId(itemId);
// 检查项目 // 检查项目
String checkItem = checkItems.get(i).toString(); String checkItem = checkItems.get(i).toString();
itemDetail.setCheckItem(checkItem); itemDetail.setCheckItem(checkItem);
//轨距 // 轨距
String trackGauge = trackGauges.get(i).toString(); String trackGauge = trackGauges.get(i).toString();
itemDetail.setTrackGauge(trackGauge); itemDetail.setTrackGauge(trackGauge);
//水平 // 水平
String level = levels.get(i).toString(); String level = levels.get(i).toString();
itemDetail.setLevel(level); itemDetail.setLevel(level);
//三角坑 // 三角坑
String triangularPit = triangularPits.get(i).toString(); String triangularPit = triangularPits.get(i).toString();
itemDetail.setTriangularPit(triangularPit); itemDetail.setTriangularPit(triangularPit);
//解析轨向、高低及其它 //解析轨向、高低及其它
String other = others.get(i).toString(); String other = others.get(i).toString();
itemDetail.setOther(other); itemDetail.setOther(other);
// 测点 // 测点值向后偏移一个
itemDetail.setMeasurePoint(measurePoint); itemDetail.setMeasurePoint(measurePoint + 1);
itemDetail.setInfoSort(sort++); itemDetail.setInfoSort(sort++);
itemDetails.add(itemDetail); itemDetails.add(itemDetail);
...@@ -200,6 +205,11 @@ public class RailInspectionEquipmentItemServiceImpl extends ServiceImpl<RailInsp ...@@ -200,6 +205,11 @@ public class RailInspectionEquipmentItemServiceImpl extends ServiceImpl<RailInsp
@Override @Override
public void saveRecord(RailInspectionEquipmentItem record) { public void saveRecord(RailInspectionEquipmentItem record) {
// 中心里程 = (开始里程+结束里程) / 2
BigDecimal startMileage = record.getCourseStartingMileage();
BigDecimal endMileage = record.getCourseEndMileage();
BigDecimal avgMileage = endMileage.subtract(startMileage).divide(new BigDecimal("2"), 3, RoundingMode.HALF_UP);
// 保存item表 // 保存item表
record.setId(UUIDGenerator.generate()); record.setId(UUIDGenerator.generate());
...@@ -208,23 +218,28 @@ public class RailInspectionEquipmentItemServiceImpl extends ServiceImpl<RailInsp ...@@ -208,23 +218,28 @@ public class RailInspectionEquipmentItemServiceImpl extends ServiceImpl<RailInsp
// 初始化明细表 // 初始化明细表
String checkItem = "检查项目:";
List<RailInspectionEquipmentItemDetail> itemDetails = new ArrayList<>(); List<RailInspectionEquipmentItemDetail> itemDetails = new ArrayList<>();
int measurePoint = 1; int measurePoint = 0;
int sort = 1; int sort = 1;
for (int i = 2; i < 32; i++) { for (int i = 2; i < 32; i++) {
if (measurePoint % 8 == 0) { if (measurePoint == 8) {
measurePoint = 1;
i = i + 2;
continue;
} else {
measurePoint++; measurePoint++;
continue;
} }
if (measurePoint == 9) {
measurePoint = 0;
startMileage = startMileage.add(avgMileage);
continue;
}
measurePoint++;
RailInspectionEquipmentItemDetail itemDetail = new RailInspectionEquipmentItemDetail(); RailInspectionEquipmentItemDetail itemDetail = new RailInspectionEquipmentItemDetail();
itemDetail.setId(UUIDGenerator.generate()); itemDetail.setId(UUIDGenerator.generate());
itemDetail.setRailInspectionEquipmentId(record.getRailInspectionEquipmentId()); itemDetail.setRailInspectionEquipmentId(record.getRailInspectionEquipmentId());
itemDetail.setRailInspectionEquipmentItemId(record.getId()); itemDetail.setRailInspectionEquipmentItemId(record.getId());
// 检查项目 // 检查项目
itemDetail.setCheckItem(""); itemDetail.setCheckItem(checkItem + startMileage.add(avgMileage));
//轨距 //轨距
itemDetail.setTrackGauge(""); itemDetail.setTrackGauge("");
//水平 //水平
...@@ -235,12 +250,7 @@ public class RailInspectionEquipmentItemServiceImpl extends ServiceImpl<RailInsp ...@@ -235,12 +250,7 @@ public class RailInspectionEquipmentItemServiceImpl extends ServiceImpl<RailInsp
itemDetail.setOther(""); itemDetail.setOther("");
// 测点 // 测点
itemDetail.setMeasurePoint(measurePoint - 1); itemDetail.setMeasurePoint(measurePoint);
if (measurePoint % 10 == 0) {
measurePoint = 1;
} else {
measurePoint++;
}
itemDetail.setInfoSort(sort++); itemDetail.setInfoSort(sort++);
itemDetails.add(itemDetail); itemDetails.add(itemDetail);
} }
......
...@@ -20,15 +20,13 @@ import org.jeecg.modules.checkData.equipmentCheckData.service.IMovementOverRepor ...@@ -20,15 +20,13 @@ import org.jeecg.modules.checkData.equipmentCheckData.service.IMovementOverRepor
import org.jeecg.modules.dynamicStaticAnalysis.entity.*; import org.jeecg.modules.dynamicStaticAnalysis.entity.*;
import org.jeecg.modules.dynamicStaticAnalysis.mapper.AnalysisAlgorithmMapper; import org.jeecg.modules.dynamicStaticAnalysis.mapper.AnalysisAlgorithmMapper;
import org.jeecg.modules.dynamicStaticAnalysis.service.*; import org.jeecg.modules.dynamicStaticAnalysis.service.*;
import org.jeecg.modules.dynamicStaticAnalysis.util.StrUtil;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode; import java.math.RoundingMode;
import java.util.ArrayList; import java.util.*;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
...@@ -74,24 +72,35 @@ public class AnalysisAlgorithm { ...@@ -74,24 +72,35 @@ public class AnalysisAlgorithm {
.eq(AnalysisBatchCheckDataMap::getAnalysisBatchId, analysisBatchId) .eq(AnalysisBatchCheckDataMap::getAnalysisBatchId, analysisBatchId)
.list(); .list();
// 1.2 按公里数正序排序所有1-钢轨,2-曲线,3-竖曲线,4-道岔 // 1.2 按公里数正序排序所有1-钢轨,2-曲线,3-竖曲线,4-道岔
List<Map<String, Object>> unitDeviceList = analysisAlgorithmMapper.getUnitDevice(analysisBatch.getLightRailId(), analysisBatch.getLineAliasId()); List<Map<String, Object>> unitDeviceList = analysisAlgorithmMapper.getUnitDevice(
analysisBatch.getLightRailId(),
analysisBatch.getLineAliasId(),
analysisBatch.getStartingMileage(),
analysisBatch.getEndMileage());
// 1.3 关联关系
for (Map<String, Object> unitDevice : unitDeviceList) {
unitDeviceTable.put(unitDevice.get("unitCode").toString(), unitDevice);
}
// 1.3 获取检查数据
// 1.4 循环分析检查项目
for (AnalysisBatchCheckDataMap checkDataMap : analysisBatchCheckDataMapList) { for (AnalysisBatchCheckDataMap checkDataMap : analysisBatchCheckDataMapList) {
// 检查数据类型 1-人工静态检查 2-轨检仪静态检查 3-轨检车检查 4-添乘仪检查 // 检查数据类型 1-人工静态检查 2-轨检仪静态检查 3-轨检车检查 4-添乘仪检查
if (1 == checkDataMap.getEkType()) { if (1 == checkDataMap.getEkType()) {
labourCheckDataAnalysis(analysisBatch, checkDataMap, unitDeviceList, unitDeviceTable); labourCheckDataAnalysis(analysisBatch, checkDataMap, unitDeviceList);
} else if (2 == checkDataMap.getEkType()) { } else if (2 == checkDataMap.getEkType()) {
railDeviceCheckDataAnalysis(analysisBatch, checkDataMap, unitDeviceList, unitDeviceTable); railDeviceCheckDataAnalysis(analysisBatch, checkDataMap, unitDeviceList);
} else if (3 == checkDataMap.getEkType()) { } else if (3 == checkDataMap.getEkType()) {
railVehicleCheckDataAnalysis(analysisBatch, checkDataMap, unitDeviceList, unitDeviceTable); railVehicleCheckDataAnalysis(analysisBatch, checkDataMap, unitDeviceList);
} else { } else {
...@@ -100,6 +109,22 @@ public class AnalysisAlgorithm { ...@@ -100,6 +109,22 @@ public class AnalysisAlgorithm {
// 3.保存算法结果 // 3.保存算法结果
if (ObjectUtil.isNotEmpty(unitDeviceTable)) { if (ObjectUtil.isNotEmpty(unitDeviceTable)) {
// 删除超限
analysisBatchUnitDeviceTransfiniteService.lambdaUpdate()
.eq(AnalysisBatchUnitDeviceTransfinite::getAnalysisBatchId, analysisBatch.getId())
.remove();
// 删除得分
analysisBatchUnitDevicePointScoreService.lambdaUpdate()
.eq(AnalysisBatchUnitDevicePointScore::getAnalysisBatchId, analysisBatch.getId())
.remove();
// 删除分析关联设备id
analysisBatchUnitDeviceService.lambdaUpdate()
.eq(AnalysisBatchUnitDevice::getAnalysisBatchId, analysisBatchId)
.remove();
// 3.1 保存分析批次-单元设备
List<AnalysisBatchUnitDevice> analysisBatchUnitDevices = new ArrayList<>(); List<AnalysisBatchUnitDevice> analysisBatchUnitDevices = new ArrayList<>();
for (Map.Entry<String, Map<String, Object>> entry : unitDeviceTable.entrySet()) { for (Map.Entry<String, Map<String, Object>> entry : unitDeviceTable.entrySet()) {
Map<String, Object> unitDevice = entry.getValue(); Map<String, Object> unitDevice = entry.getValue();
...@@ -122,6 +147,7 @@ public class AnalysisAlgorithm { ...@@ -122,6 +147,7 @@ public class AnalysisAlgorithm {
} else { } else {
analysisBatchUnitDevice.setLabourCheck(0); analysisBatchUnitDevice.setLabourCheck(0);
} }
BigDecimal labourCheckScore = (BigDecimal) unitDevice.get("labourCheckScore"); BigDecimal labourCheckScore = (BigDecimal) unitDevice.get("labourCheckScore");
// -1代表未评分 // -1代表未评分
if (labourCheckScore == null) { if (labourCheckScore == null) {
...@@ -145,7 +171,7 @@ public class AnalysisAlgorithm { ...@@ -145,7 +171,7 @@ public class AnalysisAlgorithm {
// 保存超限 // 保存超限
Object transfiniteData = unitDevice.get("transfinite"); Object transfiniteData = unitDevice.get("labourCheckTransfinite");
if (ObjectUtil.isNotEmpty(transfiniteData)) { if (ObjectUtil.isNotEmpty(transfiniteData)) {
AnalysisBatchUnitDeviceTransfinite transfinite = (AnalysisBatchUnitDeviceTransfinite) transfiniteData; AnalysisBatchUnitDeviceTransfinite transfinite = (AnalysisBatchUnitDeviceTransfinite) transfiniteData;
transfinite.setAnalysisBatchUnitDeviceId(analysisBatchUnitDevice.getId()); transfinite.setAnalysisBatchUnitDeviceId(analysisBatchUnitDevice.getId());
...@@ -155,7 +181,6 @@ public class AnalysisAlgorithm { ...@@ -155,7 +181,6 @@ public class AnalysisAlgorithm {
transfinite.setUnitCode(analysisBatchUnitDevice.getUnitCode()); transfinite.setUnitCode(analysisBatchUnitDevice.getUnitCode());
transfinite.setUnitType(analysisBatchUnitDevice.getUnitType()); transfinite.setUnitType(analysisBatchUnitDevice.getUnitType());
transfinite.setUnitTypeName(analysisBatchUnitDevice.getUnitTypeName()); transfinite.setUnitTypeName(analysisBatchUnitDevice.getUnitTypeName());
analysisBatchUnitDeviceTransfiniteService.lambdaUpdate().eq(AnalysisBatchUnitDeviceTransfinite::getAnalysisBatchUnitDeviceId, analysisBatchUnitDevice.getId()).remove();
analysisBatchUnitDeviceTransfiniteService.save(transfinite); analysisBatchUnitDeviceTransfiniteService.save(transfinite);
} }
...@@ -171,23 +196,24 @@ public class AnalysisAlgorithm { ...@@ -171,23 +196,24 @@ public class AnalysisAlgorithm {
score.setUnitType(analysisBatchUnitDevice.getUnitType()); score.setUnitType(analysisBatchUnitDevice.getUnitType());
score.setUnitTypeName(analysisBatchUnitDevice.getUnitTypeName()); score.setUnitTypeName(analysisBatchUnitDevice.getUnitTypeName());
} }
analysisBatchUnitDevicePointScoreService.lambdaUpdate().eq(AnalysisBatchUnitDevicePointScore::getAnalysisBatchUnitDeviceId, analysisBatchUnitDevice.getId()).remove();
analysisBatchUnitDevicePointScoreService.saveBatch(scoreList); analysisBatchUnitDevicePointScoreService.saveBatch(scoreList);
} }
} }
analysisBatchUnitDeviceService.lambdaUpdate().eq(AnalysisBatchUnitDevice::getAnalysisBatchId, analysisBatchId).remove();
analysisBatchUnitDeviceService.saveBatch(analysisBatchUnitDevices); analysisBatchUnitDeviceService.saveBatch(analysisBatchUnitDevices);
} }
// 分析完成
analysisBatchService.lambdaUpdate().set(AnalysisBatch::getAnalysisStatus, 99) analysisBatchService.lambdaUpdate().set(AnalysisBatch::getAnalysisStatus, 99)
.eq(AnalysisBatch::getId, analysisBatchId) .eq(AnalysisBatch::getId, analysisBatchId)
.update(); .update();
} }
/**
* 轨检车检查数据解析
*/
private void railVehicleCheckDataAnalysis(AnalysisBatch analysisBatch, private void railVehicleCheckDataAnalysis(AnalysisBatch analysisBatch,
AnalysisBatchCheckDataMap checkDataMap, AnalysisBatchCheckDataMap checkDataMap,
List<Map<String, Object>> unitDeviceList, List<Map<String, Object>> unitDeviceList) {
Map<String, Map<String, Object>> unitDeviceTable) {
// 1.获取轨检车检查超限 // 1.获取轨检车检查超限
List<MovementOverReport> movementOverReports = movementOverReportService List<MovementOverReport> movementOverReports = movementOverReportService
.lambdaQuery() .lambdaQuery()
...@@ -215,9 +241,6 @@ public class AnalysisAlgorithm { ...@@ -215,9 +241,6 @@ public class AnalysisAlgorithm {
break; break;
} }
} }
unitDeviceTable.putIfAbsent(unitDevice.get("unitCode").toString(), unitDevice); // 放入命中分析-单元表中
} }
} }
...@@ -227,12 +250,12 @@ public class AnalysisAlgorithm { ...@@ -227,12 +250,12 @@ public class AnalysisAlgorithm {
/** /**
* 轨检仪检查数据分析 * 轨检仪检查数据分析
*/ */
private void railDeviceCheckDataAnalysis(AnalysisBatch analysisBatch, AnalysisBatchCheckDataMap checkDataMap, private void railDeviceCheckDataAnalysis(AnalysisBatch analysisBatch,
List<Map<String, Object>> unitDeviceList, AnalysisBatchCheckDataMap checkDataMap,
Map<String, Map<String, Object>> unitDeviceTable) { List<Map<String, Object>> unitDeviceList) {
List<MovementCheckDataUnitDeviceMap> movementCheckDataUnitDeviceMaps = new ArrayList<>(); List<MovementCheckDataUnitDeviceMap> movementCheckDataUnitDeviceMaps = new ArrayList<>();
// 1 获取轨检仪静态检查 // 1 获取轨检仪静态检查
List<RailInspectionEquipmentItem> checkItemList = railInspectionEquipmentItemService.lambdaQuery() List<RailInspectionEquipmentItem> checkItemList = railInspectionEquipmentItemService.lambdaQuery()
.eq(RailInspectionEquipmentItem::getRailInspectionEquipmentId, checkDataMap.getEkId()) .eq(RailInspectionEquipmentItem::getRailInspectionEquipmentId, checkDataMap.getEkId())
...@@ -247,9 +270,11 @@ public class AnalysisAlgorithm { ...@@ -247,9 +270,11 @@ public class AnalysisAlgorithm {
// 2 循环遍历检查项目比较【开始-结束】来映射关联关系 // 2 循环遍历检查项目比较【开始-结束】来映射关联关系
for (RailInspectionEquipmentItem checkItem : checkItemList) { for (RailInspectionEquipmentItem checkItem : checkItemList) {
// 2.1 这里可能出现开始时间比结束时间大的情况 // 2.1 这里可能出现开始时间比结束时间大的情况,轨检仪数据还要乘1000
BigDecimal checkItemStartingMileage = checkItem.getCourseStartingMileage(); BigDecimal checkItemStartingMileage = checkItem.getCourseStartingMileage().multiply(new BigDecimal("1000"));
BigDecimal checkItemEndMileage = checkItem.getCourseEndMileage(); checkItem.setCourseStartingMileage(checkItemStartingMileage);
BigDecimal checkItemEndMileage = checkItem.getCourseEndMileage().multiply(new BigDecimal("1000"));
checkItem.setCourseEndMileage(checkItemEndMileage);
if (checkItemStartingMileage.compareTo(checkItemEndMileage) > 0) { if (checkItemStartingMileage.compareTo(checkItemEndMileage) > 0) {
checkItemStartingMileage = checkItem.getCourseEndMileage(); checkItemStartingMileage = checkItem.getCourseEndMileage();
checkItemEndMileage = checkItem.getCourseStartingMileage(); checkItemEndMileage = checkItem.getCourseStartingMileage();
...@@ -257,31 +282,24 @@ public class AnalysisAlgorithm { ...@@ -257,31 +282,24 @@ public class AnalysisAlgorithm {
// 2.2 单元设备中心里程落在检查项目【开始-结束】这个区间视为这个区间的单元设备 // 2.2 单元设备中心里程落在检查项目【开始-结束】这个区间视为这个区间的单元设备
for (Map<String, Object> unitDevice : unitDeviceList) { for (Map<String, Object> unitDevice : unitDeviceList) {
BigDecimal startMileage = Convert.toBigDecimal(unitDevice.get("startMileage")); BigDecimal centerMileage = Convert.toBigDecimal(unitDevice.get("centerMileage"));
BigDecimal endMileage = Convert.toBigDecimal(unitDevice.get("endMileage"));
BigDecimal centerMileage = startMileage.add(endMileage).divide(new BigDecimal("2"), 3, RoundingMode.HALF_UP);
unitDevice.put("centerMileage", centerMileage);
// 2.2.1 命中检查项目 // 2.2.1 命中检查项目
if (checkItemStartingMileage.compareTo(centerMileage) <= 0 && checkItemEndMileage.compareTo(centerMileage) > 0) { if (checkItemStartingMileage.compareTo(centerMileage) <= 0 && checkItemEndMileage.compareTo(centerMileage) > 0) {
List<RailInspectionEquipmentItemDetail> movementCourseInfos = checkItemItemDetailMap.get(checkItem.getId()); List<RailInspectionEquipmentItemDetail> movementCourseInfos = checkItemItemDetailMap.get(checkItem.getId());
for (RailInspectionEquipmentItemDetail info : movementCourseInfos) {
String checkItemKey = info.getCheckItem();
BigDecimal bigDecimal = new BigDecimal(checkItemKey);
BigDecimal multiply = bigDecimal.multiply(new BigDecimal("1000"));
info.setCheckItem(String.valueOf(multiply.intValue()));
}
if (ObjectUtil.isNotEmpty(movementCourseInfos)) { if (ObjectUtil.isNotEmpty(movementCourseInfos)) {
// 1 处理3个格子映射问题 // 按照检查项目聚合
Map<String, List<RailInspectionEquipmentItemDetail>> trackCodeMap = movementCourseInfos.stream() Map<String, List<RailInspectionEquipmentItemDetail>> trackCodeMap = movementCourseInfos.stream()
.collect(Collectors.groupingBy(RailInspectionEquipmentItemDetail::getCheckItem)); .collect(Collectors.groupingBy(
// 处理一下“标示里程:20.100” 中文字符
record -> StrUtil.extractTextToNumber(record.getCheckItem()).toString()
));
int size = trackCodeMap.size(); int size = trackCodeMap.size();
BigDecimal averageDec = checkItemEndMileage.subtract(checkItemStartingMileage).divide(new BigDecimal(size), 3, RoundingMode.HALF_UP); BigDecimal averageDec = checkItemEndMileage.subtract(checkItemStartingMileage).divide(new BigDecimal(size), 3, RoundingMode.HALF_UP);
List<String> trackCodes = trackCodeMap.keySet().stream() List<String> trackCodes = trackCodeMap.keySet().stream()
.mapToInt(Integer::valueOf) .map(BigDecimal::new)
.sorted() .sorted()
.mapToObj(String::valueOf) .map(BigDecimal::toString)
.collect(Collectors.toList()); .collect(Collectors.toList());
BigDecimal currentStartMileage = checkItemStartingMileage; BigDecimal currentStartMileage = checkItemStartingMileage;
BigDecimal currentEndEndMileage = checkItemStartingMileage.add(averageDec); BigDecimal currentEndEndMileage = checkItemStartingMileage.add(averageDec);
...@@ -297,9 +315,7 @@ public class AnalysisAlgorithm { ...@@ -297,9 +315,7 @@ public class AnalysisAlgorithm {
// 循环处理测点数据 // 循环处理测点数据
for (RailInspectionEquipmentItemDetail movementCourseInfo : railDeviceCheckList) { for (RailInspectionEquipmentItemDetail movementCourseInfo : railDeviceCheckList) {
// 保存数据 // 保存检查数据-单元关联关系
movementCourseInfo.setCurrentStartMileage(currentStartMileage);
movementCourseInfo.setCurrentEndEndMileage(currentEndEndMileage);
MovementCheckDataUnitDeviceMap map = this.railDeviceCheckDeviceMapSave(movementCourseInfo, unitDevice, checkItem); MovementCheckDataUnitDeviceMap map = this.railDeviceCheckDeviceMapSave(movementCourseInfo, unitDevice, checkItem);
movementCheckDataUnitDeviceMaps.add(map); movementCheckDataUnitDeviceMaps.add(map);
...@@ -313,8 +329,6 @@ public class AnalysisAlgorithm { ...@@ -313,8 +329,6 @@ public class AnalysisAlgorithm {
// 计算得分 // 计算得分
this.railDeviceCheckScore(analysisBatch, railDeviceCheckList, unitDevice); this.railDeviceCheckScore(analysisBatch, railDeviceCheckList, unitDevice);
unitDeviceTable.putIfAbsent(unitDevice.get("unitCode").toString(), unitDevice); // 放入命中分析-单元表中
} }
currentStartMileage = currentEndEndMileage; currentStartMileage = currentEndEndMileage;
currentEndEndMileage = currentEndEndMileage.add(averageDec); currentEndEndMileage = currentEndEndMileage.add(averageDec);
...@@ -330,7 +344,12 @@ public class AnalysisAlgorithm { ...@@ -330,7 +344,12 @@ public class AnalysisAlgorithm {
movementCheckDataUnitDeviceMapService.saveBatch(movementCheckDataUnitDeviceMaps); movementCheckDataUnitDeviceMapService.saveBatch(movementCheckDataUnitDeviceMaps);
} }
private void railDeviceCheckScore(AnalysisBatch analysisBatch, List<RailInspectionEquipmentItemDetail> railDeviceCheckList, Map<String, Object> unitDevice) { /**
* 轨检仪检查数据分数
*/
private void railDeviceCheckScore(AnalysisBatch analysisBatch,
List<RailInspectionEquipmentItemDetail> railDeviceCheckList,
Map<String, Object> unitDevice) {
Integer analysisType = analysisBatch.getAnalysisType(); Integer analysisType = analysisBatch.getAnalysisType();
Integer finalTrackGauge = null; Integer finalTrackGauge = null;
...@@ -523,7 +542,11 @@ public class AnalysisAlgorithm { ...@@ -523,7 +542,11 @@ public class AnalysisAlgorithm {
unitDevice.put("railDeviceCheckScoreList", scoreList); unitDevice.put("railDeviceCheckScoreList", scoreList);
} }
private AnalysisBatchUnitDeviceTransfinite railDeviceCheckTransfinite(AnalysisBatch analysisBatch, RailInspectionEquipmentItemDetail movementCourseInfo) { /**
* 轨检仪检查数据超限
*/
private AnalysisBatchUnitDeviceTransfinite railDeviceCheckTransfinite(AnalysisBatch analysisBatch,
RailInspectionEquipmentItemDetail movementCourseInfo) {
// 超限配置 // 超限配置
JSONObject allowValue = JSONObject.parseObject(analysisBatch.getAllowValue()); JSONObject allowValue = JSONObject.parseObject(analysisBatch.getAllowValue());
Integer bigTrackGauge = Convert.toInt(allowValue.get("bigTrackGauge")); // 大轨距 Integer bigTrackGauge = Convert.toInt(allowValue.get("bigTrackGauge")); // 大轨距
...@@ -613,12 +636,13 @@ public class AnalysisAlgorithm { ...@@ -613,12 +636,13 @@ public class AnalysisAlgorithm {
} }
} }
private MovementCheckDataUnitDeviceMap railDeviceCheckDeviceMapSave(RailInspectionEquipmentItemDetail movementCourseInfo, Map<String, Object> unitDevice, RailInspectionEquipmentItem checkItem) {
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);
/**
* 轨检仪检查
*/
private MovementCheckDataUnitDeviceMap railDeviceCheckDeviceMapSave(RailInspectionEquipmentItemDetail movementCourseInfo,
Map<String, Object> unitDevice,
RailInspectionEquipmentItem checkItem) {
MovementCheckDataUnitDeviceMap movementCheckDataUnitDeviceMap = new MovementCheckDataUnitDeviceMap(); MovementCheckDataUnitDeviceMap movementCheckDataUnitDeviceMap = new MovementCheckDataUnitDeviceMap();
movementCheckDataUnitDeviceMap.setId(UUIDGenerator.generate()); movementCheckDataUnitDeviceMap.setId(UUIDGenerator.generate());
movementCheckDataUnitDeviceMap.setCheckType(2);// 2-轨检仪静态检查 movementCheckDataUnitDeviceMap.setCheckType(2);// 2-轨检仪静态检查
...@@ -626,9 +650,9 @@ public class AnalysisAlgorithm { ...@@ -626,9 +650,9 @@ public class AnalysisAlgorithm {
movementCheckDataUnitDeviceMap.setUnitCode(Convert.toStr(unitDevice.get("unitCode"))); movementCheckDataUnitDeviceMap.setUnitCode(Convert.toStr(unitDevice.get("unitCode")));
movementCheckDataUnitDeviceMap.setUnitType(Convert.toInt(unitDevice.get("type"))); movementCheckDataUnitDeviceMap.setUnitType(Convert.toInt(unitDevice.get("type")));
movementCheckDataUnitDeviceMap.setUnitTypeName(Convert.toStr(unitDevice.get("typeName"))); movementCheckDataUnitDeviceMap.setUnitTypeName(Convert.toStr(unitDevice.get("typeName")));
movementCheckDataUnitDeviceMap.setUnitStartingMileage(startMileage); movementCheckDataUnitDeviceMap.setUnitStartingMileage(Convert.toBigDecimal(unitDevice.get("startMileage")));
movementCheckDataUnitDeviceMap.setUnitCenterMileage(centerMileage); movementCheckDataUnitDeviceMap.setUnitCenterMileage(Convert.toBigDecimal(unitDevice.get("centerMileage")));
movementCheckDataUnitDeviceMap.setUnitEndMileage(endMileage); movementCheckDataUnitDeviceMap.setUnitEndMileage(Convert.toBigDecimal(unitDevice.get("endMileage")));
movementCheckDataUnitDeviceMap.setCheckId(checkItem.getRailInspectionEquipmentId()); movementCheckDataUnitDeviceMap.setCheckId(checkItem.getRailInspectionEquipmentId());
movementCheckDataUnitDeviceMap.setCheckItemId(checkItem.getRailInspectionEquipmentId()); movementCheckDataUnitDeviceMap.setCheckItemId(checkItem.getRailInspectionEquipmentId());
movementCheckDataUnitDeviceMap.setCheckItemStartingMileage(checkItem.getCourseStartingMileage()); movementCheckDataUnitDeviceMap.setCheckItemStartingMileage(checkItem.getCourseStartingMileage());
...@@ -647,15 +671,13 @@ public class AnalysisAlgorithm { ...@@ -647,15 +671,13 @@ public class AnalysisAlgorithm {
/** /**
* 人工检查数据分析 * 人工检查数据分析
*
* @param checkDataMap
*/ */
public void labourCheckDataAnalysis(AnalysisBatch analysisBatch, public void labourCheckDataAnalysis(AnalysisBatch analysisBatch,
AnalysisBatchCheckDataMap checkDataMap, AnalysisBatchCheckDataMap checkDataMap,
List<Map<String, Object>> unitDeviceList, List<Map<String, Object>> unitDeviceList) {
Map<String, Map<String, Object>> unitDeviceTable) {
List<MovementCheckDataUnitDeviceMap> movementCheckDataUnitDeviceMaps = new ArrayList<>(); List<MovementCheckDataUnitDeviceMap> movementCheckDataUnitDeviceMaps = new ArrayList<>();
// 1 获取人工检查数据 // 1 获取人工检查数据
List<MovementCourse> checkItemList = movementCourseService.lambdaQuery() List<MovementCourse> checkItemList = movementCourseService.lambdaQuery()
.eq(MovementCourse::getMovementMasterId, checkDataMap.getEkId()) .eq(MovementCourse::getMovementMasterId, checkDataMap.getEkId())
...@@ -669,7 +691,6 @@ public class AnalysisAlgorithm { ...@@ -669,7 +691,6 @@ public class AnalysisAlgorithm {
// 2 循环遍历检查项目比较【开始-结束】来映射关联关系 // 2 循环遍历检查项目比较【开始-结束】来映射关联关系
for (MovementCourse checkItem : checkItemList) { for (MovementCourse checkItem : checkItemList) {
// 2.1 这里可能出现开始时间比结束时间大的情况 // 2.1 这里可能出现开始时间比结束时间大的情况
BigDecimal checkItemStartingMileage = checkItem.getCourseStartingMileage(); BigDecimal checkItemStartingMileage = checkItem.getCourseStartingMileage();
BigDecimal checkItemEndMileage = checkItem.getCourseEndMileage(); BigDecimal checkItemEndMileage = checkItem.getCourseEndMileage();
...@@ -680,10 +701,7 @@ public class AnalysisAlgorithm { ...@@ -680,10 +701,7 @@ public class AnalysisAlgorithm {
// 2.2 单元设备中心里程落在检查项目【开始-结束】这个区间视为这个区间的单元设备 // 2.2 单元设备中心里程落在检查项目【开始-结束】这个区间视为这个区间的单元设备
for (Map<String, Object> unitDevice : unitDeviceList) { for (Map<String, Object> unitDevice : unitDeviceList) {
BigDecimal startMileage = Convert.toBigDecimal(unitDevice.get("startMileage")); BigDecimal centerMileage = Convert.toBigDecimal(unitDevice.get("centerMileage"));
BigDecimal endMileage = Convert.toBigDecimal(unitDevice.get("endMileage"));
BigDecimal centerMileage = startMileage.add(endMileage).divide(new BigDecimal("2"), 3, RoundingMode.HALF_UP);
unitDevice.put("centerMileage", centerMileage);
// 2.2.1 命中检查项目 // 2.2.1 命中检查项目
if (checkItemStartingMileage.compareTo(centerMileage) <= 0 && checkItemEndMileage.compareTo(centerMileage) > 0) { if (checkItemStartingMileage.compareTo(centerMileage) <= 0 && checkItemEndMileage.compareTo(centerMileage) > 0) {
...@@ -728,8 +746,6 @@ public class AnalysisAlgorithm { ...@@ -728,8 +746,6 @@ public class AnalysisAlgorithm {
// 计算得分 // 计算得分
this.labourCheckScore(analysisBatch, labourCheckList, unitDevice); this.labourCheckScore(analysisBatch, labourCheckList, unitDevice);
unitDeviceTable.putIfAbsent(unitDevice.get("unitCode").toString(), unitDevice); // 放入命中分析-单元表中
} }
currentStartMileage = currentEndEndMileage; currentStartMileage = currentEndEndMileage;
currentEndEndMileage = currentEndEndMileage.add(averageDec); currentEndEndMileage = currentEndEndMileage.add(averageDec);
...@@ -752,10 +768,6 @@ public class AnalysisAlgorithm { ...@@ -752,10 +768,6 @@ public class AnalysisAlgorithm {
/** /**
* 人工分数 * 人工分数
*
* @param analysisBatch
* @param labourCheckList
* @param unitDevice
*/ */
private void labourCheckScore(AnalysisBatch analysisBatch, private void labourCheckScore(AnalysisBatch analysisBatch,
List<MovementCourseInfo> labourCheckList, List<MovementCourseInfo> labourCheckList,
......
package org.jeecg.modules.dynamicStaticAnalysis.mapper; package org.jeecg.modules.dynamicStaticAnalysis.mapper;
import java.math.BigDecimal;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -19,5 +20,8 @@ public interface AnalysisAlgorithmMapper { ...@@ -19,5 +20,8 @@ public interface AnalysisAlgorithmMapper {
* @param lightRailId 线路id * @param lightRailId 线路id
* @param lineAliasId 线别id * @param lineAliasId 线别id
*/ */
List<Map<String,Object>> getUnitDevice(String lightRailId, String lineAliasId); List<Map<String, Object>> getUnitDevice(String lightRailId,
String lineAliasId,
BigDecimal startMileage,
BigDecimal endMileage);
} }
...@@ -69,6 +69,14 @@ ...@@ -69,6 +69,14 @@
WHERE t1.line_alias_id = #{lineAliasId} WHERE t1.line_alias_id = #{lineAliasId}
AND t2.light_rail_id = #{lightRailId} AND t2.light_rail_id = #{lightRailId}
) t ) t
<where>
<if test="startMileage != null">
AND t.centerMileage >= #{startMileage}
</if>
<if test="endMileage != null">
AND t.centerMileage <![CDATA[ <= ]]> #{endMileage}
</if>
</where>
ORDER BY t.startMileage ORDER BY t.startMileage
</select> </select>
</mapper> </mapper>
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
t1.unit_device_code, t1.unit_device_code,
t1.unit_type, t1.unit_type,
t1.unit_type_name, t1.unit_type_name,
t1.unit_starting_mileage, t1.unit_start_mileage unit_starting_mileage,
t1.unit_center_mileage, t1.unit_center_mileage,
t1.unit_end_mileage, t1.unit_end_mileage,
t1.unit_score, t1.unit_score,
......
package org.jeecg.modules.dynamicStaticAnalysis.util; package org.jeecg.modules.dynamicStaticAnalysis.util;
import java.math.BigDecimal;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
...@@ -30,4 +31,27 @@ public class StrUtil { ...@@ -30,4 +31,27 @@ public class StrUtil {
return speedLevel; return speedLevel;
} }
/**
* 提取文字成数字并去掉末尾多余的0
*
* @param text
* @return
*/
public static BigDecimal extractTextToNumber(String text) {
String regex = "(-\\|+)?\\d+(\\.\\d+)?";
Pattern pattern = Pattern.compile(regex);
Matcher matcher = pattern.matcher(text);
BigDecimal result = null;
while (matcher.find()) {
String group = matcher.group();
if (null != group && !group.isEmpty()) {
result = new BigDecimal(group);
break;
}
}
return result;
}
} }
...@@ -99,12 +99,15 @@ ...@@ -99,12 +99,15 @@
WHERE t1.line_alias_id = #{dto.lineAliasId} WHERE t1.line_alias_id = #{dto.lineAliasId}
AND t2.light_rail_id = #{dto.lightRailId} AND t2.light_rail_id = #{dto.lightRailId}
) t ) t
<where>
<if test="dto.startMileage != null"> <if test="dto.startMileage != null">
AND t.centerMileage >= #{dto.startMileage} AND t.centerMileage >= #{dto.startMileage}
</if> </if>
<if test="dto.endMileage != null"> <if test="dto.endMileage != null">
AND t.centerMileage <![CDATA[ <= ]]> #{dto.endMileage} AND t.centerMileage <![CDATA[ <= ]]> #{dto.endMileage}
</if> </if>
</where>
ORDER BY t.startMileage ORDER BY t.startMileage
</select> </select>
</mapper> </mapper>
...@@ -9,6 +9,8 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; ...@@ -9,6 +9,8 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.jeecg.common.util.UUIDGenerator; import org.jeecg.common.util.UUIDGenerator;
import org.jeecg.modules.dynamicStaticAnalysis.entity.AnalysisBatchUnitDevice; import org.jeecg.modules.dynamicStaticAnalysis.entity.AnalysisBatchUnitDevice;
import org.jeecg.modules.dynamicStaticAnalysis.mapper.AnalysisBatchUnitDeviceMapper; import org.jeecg.modules.dynamicStaticAnalysis.mapper.AnalysisBatchUnitDeviceMapper;
import org.jeecg.modules.dynamicStaticAnalysis.mapper.AnalysisBatchUnitDeviceTransfiniteMapper;
import org.jeecg.modules.dynamicStaticAnalysis.vo.AnalysisBatchUnitDeviceTransfiniteVO;
import org.jeecg.modules.maintenanceWork.dto.*; import org.jeecg.modules.maintenanceWork.dto.*;
import org.jeecg.modules.maintenanceWork.entity.WorkBatch; import org.jeecg.modules.maintenanceWork.entity.WorkBatch;
import org.jeecg.modules.maintenanceWork.entity.WorkBatchDetail; import org.jeecg.modules.maintenanceWork.entity.WorkBatchDetail;
...@@ -39,6 +41,8 @@ public class WorkBatchServiceImpl extends ServiceImpl<WorkBatchMapper, WorkBatch ...@@ -39,6 +41,8 @@ public class WorkBatchServiceImpl extends ServiceImpl<WorkBatchMapper, WorkBatch
@Resource @Resource
private AnalysisBatchUnitDeviceMapper analysisBatchUnitDeviceMapper; private AnalysisBatchUnitDeviceMapper analysisBatchUnitDeviceMapper;
@Resource
private AnalysisBatchUnitDeviceTransfiniteMapper transfiniteMapper;
@Override @Override
public Page<WorkBatchVO> listRecord(Page<WorkBatchVO> pageData, WorkBatchDTO dto) { public Page<WorkBatchVO> listRecord(Page<WorkBatchVO> pageData, WorkBatchDTO dto) {
...@@ -46,6 +50,10 @@ public class WorkBatchServiceImpl extends ServiceImpl<WorkBatchMapper, WorkBatch ...@@ -46,6 +50,10 @@ public class WorkBatchServiceImpl extends ServiceImpl<WorkBatchMapper, WorkBatch
for (WorkBatchVO record : pageRecords.getRecords()) { for (WorkBatchVO record : pageRecords.getRecords()) {
List<WorkBatchDetailVO> detailList = workBatchDetailMapper.queryListByWorkBatchId(record.getId()); List<WorkBatchDetailVO> detailList = workBatchDetailMapper.queryListByWorkBatchId(record.getId());
// for (WorkBatchDetailVO workBatchDetailVO : detailList) {
// List<AnalysisBatchUnitDeviceTransfiniteVO> transfiniteList = transfiniteMapper.getTransfiniteList(record.getId());
// workBatchDetailVO.setTransfiniteList(transfiniteList);
// }
record.setDetailList(detailList); record.setDetailList(detailList);
} }
......
...@@ -6,13 +6,16 @@ import com.baomidou.mybatisplus.annotation.TableName; ...@@ -6,13 +6,16 @@ import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable; import java.io.Serializable;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import org.jeecg.modules.dynamicStaticAnalysis.vo.AnalysisBatchUnitDeviceTransfiniteVO;
/** /**
* <p> * <p>
...@@ -68,4 +71,8 @@ public class WorkBatchDetailVO { ...@@ -68,4 +71,8 @@ public class WorkBatchDetailVO {
@ApiModelProperty("备注") @ApiModelProperty("备注")
private String remark; private String remark;
@ApiModelProperty("超限")
private List<AnalysisBatchUnitDeviceTransfiniteVO> transfiniteList = new ArrayList<>();
} }
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