Commit 3cc309c3 authored by hkl's avatar hkl

feat:1.更新数据库 2.维修作业管理

parent 2246fff3
......@@ -5,8 +5,10 @@ import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
......@@ -88,5 +90,15 @@ public class RailInspectionEquipmentItemDetail implements Serializable {
@TableField("info_sort")
private Integer infoSort;
@ApiModelProperty("当前格子的起始里程:计算用")
@TableField(exist = false)
@JsonIgnore
private BigDecimal currentStartMileage;
@ApiModelProperty("当前格子的起始里程:计算用")
@TableField(exist = false)
@JsonIgnore
private BigDecimal currentEndEndMileage;
}
......@@ -3,10 +3,13 @@ package org.jeecg.modules.checkData.equipmentCheckData.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
......@@ -105,4 +108,15 @@ public class MovementCourseInfo implements Serializable {
@TableField("info_sort")
private Integer infoSort;
@ApiModelProperty("当前格子的起始里程:计算用")
@TableField(exist = false)
@JsonIgnore
private BigDecimal currentStartMileage;
@ApiModelProperty("当前格子的起始里程:计算用")
@TableField(exist = false)
@JsonIgnore
private BigDecimal currentEndEndMileage;
}
package org.jeecg.modules.dynamicStaticAnalysis.algorithm;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.math.MathUtil;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import io.swagger.models.auth.In;
import org.jeecg.common.util.UUIDGenerator;
import org.jeecg.modules.checkData.dynamicStaticGeometricData.entity.RailInspectionEquipmentItem;
import org.jeecg.modules.checkData.dynamicStaticGeometricData.entity.RailInspectionEquipmentItemDetail;
......@@ -14,9 +12,11 @@ import org.jeecg.modules.checkData.dynamicStaticGeometricData.service.IRailInspe
import org.jeecg.modules.checkData.equipmentCheckData.entity.MovementCheckDataUnitDeviceMap;
import org.jeecg.modules.checkData.equipmentCheckData.entity.MovementCourse;
import org.jeecg.modules.checkData.equipmentCheckData.entity.MovementCourseInfo;
import org.jeecg.modules.checkData.equipmentCheckData.entity.MovementOverReport;
import org.jeecg.modules.checkData.equipmentCheckData.service.IMovementCheckDataUnitDeviceMapService;
import org.jeecg.modules.checkData.equipmentCheckData.service.IMovementCourseInfoService;
import org.jeecg.modules.checkData.equipmentCheckData.service.IMovementCourseService;
import org.jeecg.modules.checkData.equipmentCheckData.service.IMovementOverReportService;
import org.jeecg.modules.dynamicStaticAnalysis.entity.*;
import org.jeecg.modules.dynamicStaticAnalysis.mapper.AnalysisAlgorithmMapper;
import org.jeecg.modules.dynamicStaticAnalysis.service.*;
......@@ -60,11 +60,15 @@ public class AnalysisAlgorithm {
private IAnalysisBatchUnitDevicePointScoreService analysisBatchUnitDevicePointScoreService;
@Resource
private IConfigLabourCheckService configLabourCheckService;
@Resource
private IConfigRailDeviceCheckService configRailDeviceCheckService;
@Resource
private IMovementOverReportService movementOverReportService;
/**
* 分析
*/
public void analysis(String analysisBatchId) {
public void analysis2(String analysisBatchId) {
// 1.映射单元格
// 1.1 获取分析批次数据
AnalysisBatch analysisBatch = analysisBatchService.getById(analysisBatchId);
......@@ -245,7 +249,6 @@ public class AnalysisAlgorithm {
unitDeviceTable.putIfAbsent(unitCode, unitDevice);
// 保存单元-测点数据
// 保存单元-测点数据
for (RailInspectionEquipmentItemDetail movementCourseInfo : railDevice) {
MovementCheckDataUnitDeviceMap movementCheckDataUnitDeviceMap = new MovementCheckDataUnitDeviceMap();
......@@ -792,4 +795,1159 @@ public class AnalysisAlgorithm {
}
}
public void analysis(String analysisBatchId) {
Map<String, Map<String, Object>> unitDeviceTable = new TreeMap<>();
// 1.1 获取分析基础数据
AnalysisBatch analysisBatch = analysisBatchService.getById(analysisBatchId);
List<AnalysisBatchCheckDataMap> analysisBatchCheckDataMapList = analysisBatchCheckDataMapService.lambdaQuery()
.eq(AnalysisBatchCheckDataMap::getAnalysisBatchId, analysisBatchId)
.list();
// 1.2 按公里数正序排序所有1-钢轨,2-曲线,3-竖曲线,4-道岔
List<Map<String, Object>> unitDeviceList = analysisAlgorithmMapper.getUnitDevice(analysisBatch.getLightRailId(), analysisBatch.getLineAliasId());
// 1.3 获取检查数据
for (AnalysisBatchCheckDataMap checkDataMap : analysisBatchCheckDataMapList) {
// 检查数据类型 1-人工静态检查 2-轨检仪静态检查 3-轨检车检查 4-添乘仪检查
if (1 == checkDataMap.getEkType()) {
labourCheckDataAnalysis(analysisBatch, checkDataMap, unitDeviceList, unitDeviceTable);
} else if (2 == checkDataMap.getEkType()) {
railDeviceCheckDataAnalysis(analysisBatch, checkDataMap, unitDeviceList, unitDeviceTable);
} else if (3 == checkDataMap.getEkType()) {
railVehicleCheckDataAnalysis(analysisBatch, checkDataMap, unitDeviceList, unitDeviceTable);
} else {
}
}
// 3.保存算法结果
if (ObjectUtil.isNotEmpty(unitDeviceTable)) {
List<AnalysisBatchUnitDevice> analysisBatchUnitDevices = new ArrayList<>();
for (Map.Entry<String, Map<String, Object>> entry : unitDeviceTable.entrySet()) {
Map<String, Object> unitDevice = entry.getValue();
AnalysisBatchUnitDevice analysisBatchUnitDevice = new AnalysisBatchUnitDevice();
analysisBatchUnitDevice.setId(UUIDGenerator.generate());
analysisBatchUnitDevice.setAnalysisBatchId(analysisBatch.getId());
analysisBatchUnitDevice.setAnalysisBatchCode(analysisBatch.getAnalysisBatchCode());
analysisBatchUnitDevice.setUnitId(Convert.toStr(unitDevice.get("id")));
analysisBatchUnitDevice.setUnitCode(Convert.toStr(unitDevice.get("unitCode")));
analysisBatchUnitDevice.setUnitDeviceCode(Convert.toStr(unitDevice.get("deviceCode")));
analysisBatchUnitDevice.setUnitType(Convert.toInt(unitDevice.get("type")));
analysisBatchUnitDevice.setUnitTypeName(Convert.toStr(unitDevice.get("typeName")));
analysisBatchUnitDevice.setUnitStartingMileage(Convert.toBigDecimal(unitDevice.get("startMileage")));
analysisBatchUnitDevice.setUnitCenterMileage(Convert.toBigDecimal(unitDevice.get("centerMileage")));
analysisBatchUnitDevice.setUnitEndMileage(Convert.toBigDecimal(unitDevice.get("endMileage")));
Object labourCheckData = unitDevice.get("labourCheck");
if (ObjectUtil.isNotEmpty(labourCheckData)) {
analysisBatchUnitDevice.setLabourCheck(1);
} else {
analysisBatchUnitDevice.setLabourCheck(0);
}
BigDecimal labourCheckScore = (BigDecimal) unitDevice.get("labourCheckScore");
// -1代表未评分
if (labourCheckScore == null) {
analysisBatchUnitDevice.setLabourCheckScore(new BigDecimal("-1"));
} else {
analysisBatchUnitDevice.setLabourCheckScore(labourCheckScore);
// 先写死
analysisBatchUnitDevice.setUnitScore(labourCheckScore);
analysisBatchUnitDevice.setUnitScoreLevel(3);
analysisBatchUnitDevice.setUnitScoreLevelStr("失格");
}
Object railDeviceData = unitDevice.get("railDevice");
if (ObjectUtil.isNotEmpty(railDeviceData)) {
analysisBatchUnitDevice.setRailDeviceCheck(1);
} else {
analysisBatchUnitDevice.setRailDeviceCheck(0);
}
analysisBatchUnitDevices.add(analysisBatchUnitDevice);
// 保存超限
Object transfiniteData = unitDevice.get("transfinite");
if (ObjectUtil.isNotEmpty(transfiniteData)) {
AnalysisBatchUnitDeviceTransfinite transfinite = (AnalysisBatchUnitDeviceTransfinite) transfiniteData;
transfinite.setAnalysisBatchUnitDeviceId(analysisBatchUnitDevice.getId());
transfinite.setAnalysisBatchId(analysisBatchUnitDevice.getAnalysisBatchId());
transfinite.setAnalysisBatchCode(analysisBatchUnitDevice.getAnalysisBatchCode());
transfinite.setUnitId(analysisBatchUnitDevice.getUnitId());
transfinite.setUnitCode(analysisBatchUnitDevice.getUnitCode());
transfinite.setUnitType(analysisBatchUnitDevice.getUnitType());
transfinite.setUnitTypeName(analysisBatchUnitDevice.getUnitTypeName());
analysisBatchUnitDeviceTransfiniteService.lambdaUpdate().eq(AnalysisBatchUnitDeviceTransfinite::getAnalysisBatchUnitDeviceId, analysisBatchUnitDevice.getId()).remove();
analysisBatchUnitDeviceTransfiniteService.save(transfinite);
}
// 保存人工计算得分
List<AnalysisBatchUnitDevicePointScore> scoreList = (List<AnalysisBatchUnitDevicePointScore>) unitDevice.get("labourCheckScoreList");
if (ObjectUtil.isNotEmpty(scoreList)) {
for (AnalysisBatchUnitDevicePointScore score : scoreList) {
score.setAnalysisBatchUnitDeviceId(analysisBatchUnitDevice.getId());
score.setAnalysisBatchId(analysisBatchUnitDevice.getAnalysisBatchId());
score.setAnalysisBatchCode(analysisBatchUnitDevice.getAnalysisBatchCode());
score.setUnitId(analysisBatchUnitDevice.getUnitId());
score.setUnitCode(analysisBatchUnitDevice.getUnitCode());
score.setUnitType(analysisBatchUnitDevice.getUnitType());
score.setUnitTypeName(analysisBatchUnitDevice.getUnitTypeName());
}
analysisBatchUnitDevicePointScoreService.lambdaUpdate().eq(AnalysisBatchUnitDevicePointScore::getAnalysisBatchUnitDeviceId, analysisBatchUnitDevice.getId()).remove();
analysisBatchUnitDevicePointScoreService.saveBatch(scoreList);
}
}
analysisBatchUnitDeviceService.lambdaUpdate().eq(AnalysisBatchUnitDevice::getAnalysisBatchId, analysisBatchId).remove();
analysisBatchUnitDeviceService.saveBatch(analysisBatchUnitDevices);
}
analysisBatchService.lambdaUpdate().set(AnalysisBatch::getAnalysisStatus, 99)
.eq(AnalysisBatch::getId, analysisBatchId)
.update();
}
private void railVehicleCheckDataAnalysis(AnalysisBatch analysisBatch,
AnalysisBatchCheckDataMap checkDataMap,
List<Map<String, Object>> unitDeviceList,
Map<String, Map<String, Object>> unitDeviceTable) {
// 1.获取轨检车检查超限
List<MovementOverReport> movementOverReports = movementOverReportService
.lambdaQuery()
.eq(MovementOverReport::getMovementMasterId, checkDataMap.getEkId())
.list();
// 2. 根据分析批次的里程查询出映射单元
BigDecimal checkStartingMileage = analysisBatch.getStartingMileage();
BigDecimal checkEndMileage = analysisBatch.getEndMileage();
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);
unitDevice.put("centerMileage", centerMileage);
// 命中单元设备
if (checkStartingMileage.compareTo(centerMileage) <= 0 && checkEndMileage.compareTo(centerMileage) > 0) {
// 循环超限数据来比
for (MovementOverReport movementOverReport : movementOverReports) {
BigDecimal mileage = movementOverReport.getMileage();
if (startMileage.compareTo(mileage) <= 0 && endMileage.compareTo(mileage) > 0) {
break;
}
}
unitDeviceTable.putIfAbsent(unitDevice.get("unitCode").toString(), unitDevice); // 放入命中分析-单元表中
}
}
}
/**
* 轨检仪检查数据分析
*/
private void railDeviceCheckDataAnalysis(AnalysisBatch analysisBatch, AnalysisBatchCheckDataMap checkDataMap,
List<Map<String, Object>> unitDeviceList,
Map<String, Map<String, Object>> unitDeviceTable) {
List<MovementCheckDataUnitDeviceMap> movementCheckDataUnitDeviceMaps = new ArrayList<>();
// 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::getRailInspectionEquipmentItemId));
// 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);
unitDevice.put("centerMileage", centerMileage);
// 2.2.1 命中检查项目
if (checkItemStartingMileage.compareTo(centerMileage) <= 0 && checkItemEndMileage.compareTo(centerMileage) > 0) {
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)) {
// 1 处理3个格子映射问题
Map<String, List<RailInspectionEquipmentItemDetail>> trackCodeMap = movementCourseInfos.stream()
.collect(Collectors.groupingBy(RailInspectionEquipmentItemDetail::getCheckItem));
int size = trackCodeMap.size();
BigDecimal averageDec = checkItemEndMileage.subtract(checkItemStartingMileage).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);
// 2.循环来命中格子
for (String trackCode : trackCodes) {
if (currentStartMileage.compareTo(centerMileage) <= 0 && currentEndEndMileage.compareTo(centerMileage) > 0) {
// 轨检仪检查数据
List<RailInspectionEquipmentItemDetail> railDeviceCheckList = trackCodeMap.get(trackCode);
unitDevice.put("railDeviceCheck", railDeviceCheckList);
AnalysisBatchUnitDeviceTransfinite transfinite = null;
// 循环处理测点数据
for (RailInspectionEquipmentItemDetail movementCourseInfo : railDeviceCheckList) {
// 保存数据
movementCourseInfo.setCurrentStartMileage(currentStartMileage);
movementCourseInfo.setCurrentEndEndMileage(currentEndEndMileage);
MovementCheckDataUnitDeviceMap map = this.railDeviceCheckDeviceMapSave(movementCourseInfo, unitDevice, checkItem);
movementCheckDataUnitDeviceMaps.add(map);
// 计算超限:如果为null则计算,否则和单元绑定
if (null == transfinite) {
transfinite = this.railDeviceCheckTransfinite(analysisBatch, movementCourseInfo);
} else {
unitDevice.put("labourCheckTransfinite", transfinite);
}
}
// 计算得分
this.railDeviceCheckScore(analysisBatch, railDeviceCheckList, unitDevice);
unitDeviceTable.putIfAbsent(unitDevice.get("unitCode").toString(), unitDevice); // 放入命中分析-单元表中
}
currentStartMileage = currentEndEndMileage;
currentEndEndMileage = currentEndEndMileage.add(averageDec);
}
}
}
}
}
// 保存之前先删除
movementCheckDataUnitDeviceMapService.lambdaUpdate().eq(MovementCheckDataUnitDeviceMap::getCheckId, checkDataMap.getEkId()).remove();
movementCheckDataUnitDeviceMapService.saveBatch(movementCheckDataUnitDeviceMaps);
}
private void railDeviceCheckScore(AnalysisBatch analysisBatch, List<RailInspectionEquipmentItemDetail> railDeviceCheckList, Map<String, Object> unitDevice) {
Integer analysisType = analysisBatch.getAnalysisType();
Integer finalTrackGauge = null;
Integer finalTriangularPit = null;
Integer finalLevel = null;
int sumTrackGauge = 0;
int sumTriangularPit = 0;
int sumLevel = 0;
int maxTrackGauge = 0;
int maxTriangularPit = 0;
int maxLevel = 0;
int avgTrackGauge = 0;
int avgTriangularPit = 0;
int avgLevel = 0;
int trackGaugeSize = 0;
int triangularPitSize = 0;
int levelSize = 0;
// 循环计算均值/峰值
for (RailInspectionEquipmentItemDetail movementCourseInfo : railDeviceCheckList) {
// 轨距
Integer trackGauge = Convert.toInt(movementCourseInfo.getTrackGauge());
if (ObjectUtil.isNotEmpty(trackGauge)) {
trackGauge = Math.abs(trackGauge);
// 均值
sumTrackGauge = sumTrackGauge + trackGauge;
trackGaugeSize++;
avgTrackGauge = sumTrackGauge / trackGaugeSize;
// 峰值
if (trackGauge > maxTrackGauge) {
maxTrackGauge = trackGauge;
}
if (1 == analysisType) {
finalTrackGauge = avgTrackGauge;
} else {
finalTrackGauge = maxLevel;
}
}
// 水平
Integer level = Convert.toInt(movementCourseInfo.getLevel());
if (ObjectUtil.isNotEmpty(level)) {
level = Math.abs(level);
// 均值
sumLevel = sumLevel + level;
levelSize++;
avgLevel = sumLevel / levelSize;
// 峰值
if (level > maxLevel) {
maxLevel = level;
}
if (1 == analysisType) {
finalLevel = avgLevel;
} else {
finalLevel = maxLevel;
}
}
//三角坑
Integer triangularPit = Convert.toInt(movementCourseInfo.getTriangularPit());
if (ObjectUtil.isNotEmpty(triangularPit)) {
triangularPit = Math.abs(triangularPit);
// 均值
sumTriangularPit = sumTriangularPit + triangularPit;
triangularPitSize++;
avgTriangularPit = sumTriangularPit / triangularPitSize;
// 峰值
if (triangularPit > maxTriangularPit) {
maxTriangularPit = triangularPit;
}
if (1 == analysisType) {
finalTriangularPit = avgTriangularPit;
} else {
finalTriangularPit = maxTriangularPit;
}
}
}
ConfigRailDeviceCheck configRailDevice = configRailDeviceCheckService.lambdaQuery()
.eq(ConfigRailDeviceCheck::getSpeedMax, analysisBatch.getSpeedMax())
.eq(ConfigRailDeviceCheck::getSpeedMin, analysisBatch.getSpeedMin())
.eq(ConfigRailDeviceCheck::getDelFlag, "0")
.last("limit 1")
.one();
// 1-钢轨,2-曲线,3-竖曲线,4-道岔
Integer type = Convert.toInt(unitDevice.get("type"));
JSONObject jsonObject = null;
if (type == 1) {
jsonObject = JSONObject.parseObject(configRailDevice.getRail());
} else if (type == 2) {
jsonObject = JSONObject.parseObject(configRailDevice.getCurve());
} else if (type == 3) {
jsonObject = JSONObject.parseObject(configRailDevice.getVerticalCurve());
} else if (type == 4) {
jsonObject = JSONObject.parseObject(configRailDevice.getRailSwitch());
}
BigDecimal trackGaugeWeightValues = jsonObject.getBigDecimal("trackGauge");
BigDecimal levelWeightValues = jsonObject.getBigDecimal("level");
BigDecimal triangularPitWeightValues = jsonObject.getBigDecimal("triangularPit");
// 总单元得分
BigDecimal sumUnitScore = null;
// 轨距单元得分
BigDecimal trackGaugeUnitScore = null;
List<AnalysisBatchUnitDevicePointScore> scoreList = new ArrayList<>();
if (ObjectUtil.isNotEmpty(finalTrackGauge)) {
trackGaugeUnitScore = trackGaugeWeightValues.multiply(new BigDecimal(finalTrackGauge.toString()));
if (sumUnitScore == null) {
sumUnitScore = BigDecimal.ZERO;
}
sumUnitScore = sumUnitScore.add(trackGaugeUnitScore);
AnalysisBatchUnitDevicePointScore score = new AnalysisBatchUnitDevicePointScore();
score.setId(UUIDGenerator.generate());
score.setAnalysisType(analysisType);
score.setSpeedMax(analysisBatch.getSpeedMax());
score.setSpeedMin(analysisBatch.getSpeedMin());
score.setAnalysisBatchId(analysisBatch.getId());
score.setAnalysisBatchCode(analysisBatch.getAnalysisBatchCode());
score.setPointTypeName("轨距");
score.setCheckType(2);
score.setPointValue(finalTrackGauge);
score.setWeightValues(trackGaugeWeightValues);
score.setPointScore(trackGaugeUnitScore);
scoreList.add(score);
}
// 水平单元得分
BigDecimal levelUnitScore;
if (ObjectUtil.isNotEmpty(finalLevel)) {
levelUnitScore = levelWeightValues.multiply(new BigDecimal(finalLevel.toString()));
if (sumUnitScore == null) {
sumUnitScore = BigDecimal.ZERO;
}
sumUnitScore = sumUnitScore.add(levelUnitScore);
AnalysisBatchUnitDevicePointScore score = new AnalysisBatchUnitDevicePointScore();
score.setId(UUIDGenerator.generate());
score.setAnalysisType(analysisType);
score.setSpeedMax(analysisBatch.getSpeedMax());
score.setSpeedMin(analysisBatch.getSpeedMin());
score.setAnalysisBatchId(analysisBatch.getId());
score.setAnalysisBatchCode(analysisBatch.getAnalysisBatchCode());
score.setPointTypeName("高低");
score.setCheckType(2);
score.setPointValue(finalLevel);
score.setWeightValues(levelWeightValues);
score.setPointScore(levelUnitScore);
scoreList.add(score);
}
// 三角坑单元得分
BigDecimal triangularPitGaugeUnitScore;
if (ObjectUtil.isNotEmpty(finalTriangularPit)) {
triangularPitGaugeUnitScore = triangularPitWeightValues.multiply(new BigDecimal(finalTriangularPit.toString()));
if (sumUnitScore == null) {
sumUnitScore = BigDecimal.ZERO;
}
sumUnitScore = sumUnitScore.add(triangularPitGaugeUnitScore);
AnalysisBatchUnitDevicePointScore score = new AnalysisBatchUnitDevicePointScore();
score.setId(UUIDGenerator.generate());
score.setAnalysisType(analysisType);
score.setSpeedMax(analysisBatch.getSpeedMax());
score.setSpeedMin(analysisBatch.getSpeedMin());
score.setAnalysisBatchId(analysisBatch.getId());
score.setAnalysisBatchCode(analysisBatch.getAnalysisBatchCode());
score.setPointTypeName("三角坑");
score.setCheckType(2);
score.setPointValue(finalTriangularPit);
score.setWeightValues(triangularPitWeightValues);
score.setPointScore(triangularPitGaugeUnitScore);
scoreList.add(score);
}
unitDevice.put("railDeviceCheckScore", sumUnitScore);
unitDevice.put("railDeviceCheckScoreList", scoreList);
}
private AnalysisBatchUnitDeviceTransfinite railDeviceCheckTransfinite(AnalysisBatch analysisBatch, RailInspectionEquipmentItemDetail movementCourseInfo) {
// 超限配置
JSONObject allowValue = JSONObject.parseObject(analysisBatch.getAllowValue());
Integer bigTrackGauge = Convert.toInt(allowValue.get("bigTrackGauge")); // 大轨距
Integer smallTrackGauge = Convert.toInt(allowValue.get("smallTrackGauge")); // 小轨距
Integer allowLevel = Convert.toInt(allowValue.get("level")); // 水平
Integer allowTriangularPit = Convert.toInt(allowValue.get("triangularPit")); // 三角坑
Integer allowHeight = Convert.toInt(allowValue.get("height")); // 高低
Integer allowDirection = Convert.toInt(allowValue.get("direction")); // 轨向
// 是否派工配置
Integer isWork = 1;
String reasonLabel = "";
JSONArray dispatchingList = JSONArray.parseArray(analysisBatch.getDispatching());
for (Object obj : dispatchingList) {
JSONObject dispatching = (JSONObject) obj;
String reasonValue = String.valueOf(dispatching.get("reasonValue"));
reasonLabel = String.valueOf(dispatching.get("reasonLabel"));
if ("static_limit".equals(reasonValue)) {
Boolean isWorkTemp = Boolean.valueOf(dispatching.get("isWork").toString());
if (isWorkTemp) {
isWork = 1;
} else {
isWork = 0;
}
}
}
boolean isTransfinite = false;
String allowValueSave = "";
String measurePointValue = "";
String transfiniteType = "";
// 轨距
Integer trackGauge = Convert.toInt(movementCourseInfo.getTrackGauge());
if (ObjectUtil.isNotEmpty(trackGauge)) {
if (trackGauge > bigTrackGauge) {
isTransfinite = true;
allowValueSave = bigTrackGauge.toString();
measurePointValue = trackGauge.toString();
transfiniteType = "大轨距";
} else if (trackGauge < smallTrackGauge) {
isTransfinite = true;
allowValueSave = smallTrackGauge.toString();
measurePointValue = trackGauge.toString();
transfiniteType = "小轨距";
}
}
// 水平
Integer level = Convert.toInt(movementCourseInfo.getLevel());
if (ObjectUtil.isNotEmpty(level)) {
if (level > allowLevel) {
isTransfinite = true;
allowValueSave = allowLevel.toString();
measurePointValue = level.toString();
transfiniteType = "水平";
}
}
//三角坑
Integer triangularPit = Convert.toInt(movementCourseInfo.getTriangularPit());
if (ObjectUtil.isNotEmpty(triangularPit)) {
if (triangularPit > allowTriangularPit) {
isTransfinite = true;
allowValueSave = allowTriangularPit.toString();
measurePointValue = triangularPit.toString();
transfiniteType = "三角坑";
}
}
// 超限
if (isTransfinite) {
AnalysisBatchUnitDeviceTransfinite record = new AnalysisBatchUnitDeviceTransfinite();
record.setId(UUIDGenerator.generate());
record.setTransfiniteGrade(1);
record.setTransfiniteGradeName(reasonLabel);
record.setTransfiniteType(transfiniteType);
record.setAllowValue(allowValueSave);
record.setMeasurePointValue(measurePointValue);
record.setIsWork(isWork);
return record;
} else {
return null;
}
}
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);
MovementCheckDataUnitDeviceMap movementCheckDataUnitDeviceMap = new MovementCheckDataUnitDeviceMap();
movementCheckDataUnitDeviceMap.setId(UUIDGenerator.generate());
movementCheckDataUnitDeviceMap.setCheckType(2);// 2-轨检仪静态检查
movementCheckDataUnitDeviceMap.setUnitId(Convert.toStr(unitDevice.get("id")));
movementCheckDataUnitDeviceMap.setUnitCode(Convert.toStr(unitDevice.get("unitCode")));
movementCheckDataUnitDeviceMap.setUnitType(Convert.toInt(unitDevice.get("type")));
movementCheckDataUnitDeviceMap.setUnitTypeName(Convert.toStr(unitDevice.get("typeName")));
movementCheckDataUnitDeviceMap.setUnitStartingMileage(startMileage);
movementCheckDataUnitDeviceMap.setUnitCenterMileage(centerMileage);
movementCheckDataUnitDeviceMap.setUnitEndMileage(endMileage);
movementCheckDataUnitDeviceMap.setCheckId(checkItem.getRailInspectionEquipmentId());
movementCheckDataUnitDeviceMap.setCheckItemId(checkItem.getRailInspectionEquipmentId());
movementCheckDataUnitDeviceMap.setCheckItemStartingMileage(checkItem.getCourseStartingMileage());
movementCheckDataUnitDeviceMap.setCheckItemEndMileage(checkItem.getCourseEndMileage());
movementCheckDataUnitDeviceMap.setCheckItemText(movementCourseInfo.getCheckItem());
movementCheckDataUnitDeviceMap.setCheckDetailId(movementCourseInfo.getId());
movementCheckDataUnitDeviceMap.setCheckDetailStartingMileage(movementCourseInfo.getCurrentStartMileage());
movementCheckDataUnitDeviceMap.setCheckDetailEndMileage(movementCourseInfo.getCurrentEndEndMileage());
movementCheckDataUnitDeviceMap.setTrackGauge(movementCourseInfo.getTrackGauge());
movementCheckDataUnitDeviceMap.setLevel(movementCourseInfo.getLevel());
movementCheckDataUnitDeviceMap.setTriangularPit(movementCourseInfo.getTriangularPit());
movementCheckDataUnitDeviceMap.setMeasurePoint(movementCourseInfo.getMeasurePoint());
return movementCheckDataUnitDeviceMap;
}
/**
* 人工检查数据分析
*
* @param checkDataMap
*/
public void labourCheckDataAnalysis(AnalysisBatch analysisBatch,
AnalysisBatchCheckDataMap checkDataMap,
List<Map<String, Object>> unitDeviceList,
Map<String, Map<String, Object>> unitDeviceTable) {
List<MovementCheckDataUnitDeviceMap> movementCheckDataUnitDeviceMaps = new ArrayList<>();
// 1 获取人工检查数据
List<MovementCourse> checkItemList = movementCourseService.lambdaQuery()
.eq(MovementCourse::getMovementMasterId, checkDataMap.getEkId())
.list();
List<MovementCourseInfo> checkItemItemDetailList = movementCourseInfoService.lambdaQuery()
.eq(MovementCourseInfo::getMovementMasterId, checkDataMap.getEkId())
.list();
Map<String, List<MovementCourseInfo>> checkItemItemDetailMap = checkItemItemDetailList.stream()
.collect(Collectors.groupingBy(MovementCourseInfo::getMovementCourseId));
// 2 循环遍历检查项目比较【开始-结束】来映射关联关系
for (MovementCourse 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);
unitDevice.put("centerMileage", centerMileage);
// 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 = checkItemEndMileage.subtract(checkItemStartingMileage).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);
// 2.循环来命中格子
for (String trackCode : trackCodes) {
if (currentStartMileage.compareTo(centerMileage) <= 0 && currentEndEndMileage.compareTo(centerMileage) > 0) {
List<MovementCourseInfo> labourCheckList = trackCodeMap.get(trackCode);
unitDevice.put("labourCheck", labourCheckList);
AnalysisBatchUnitDeviceTransfinite transfinite = null;
// 循环处理测点数据
for (MovementCourseInfo movementCourseInfo : labourCheckList) {
// 保存数据
movementCourseInfo.setCurrentStartMileage(currentStartMileage);
movementCourseInfo.setCurrentEndEndMileage(currentEndEndMileage);
MovementCheckDataUnitDeviceMap map = this.labourCheckDeviceMapSave(movementCourseInfo, unitDevice, checkItem);
movementCheckDataUnitDeviceMaps.add(map);
// 计算超限:如果为null则计算,否则和单元绑定
if (null == transfinite) {
transfinite = this.labourCheckTransfinite(analysisBatch, movementCourseInfo);
} else {
unitDevice.put("labourCheckTransfinite", transfinite);
}
}
// 计算得分
this.labourCheckScore(analysisBatch, labourCheckList, unitDevice);
unitDeviceTable.putIfAbsent(unitDevice.get("unitCode").toString(), unitDevice); // 放入命中分析-单元表中
}
currentStartMileage = currentEndEndMileage;
currentEndEndMileage = currentEndEndMileage.add(averageDec);
}
}
}
}
// 保存检查数据-单元映射关联关系
if (ObjectUtil.isNotEmpty(movementCheckDataUnitDeviceMaps)) {
movementCheckDataUnitDeviceMapService.lambdaUpdate().eq(MovementCheckDataUnitDeviceMap::getCheckId, checkDataMap.getEkId()).remove();
movementCheckDataUnitDeviceMapService.saveBatch(movementCheckDataUnitDeviceMaps);
}
}
}
/**
* 人工分数
*
* @param analysisBatch
* @param labourCheckList
* @param unitDevice
*/
private void labourCheckScore(AnalysisBatch analysisBatch,
List<MovementCourseInfo> labourCheckList,
Map<String, Object> unitDevice) {
Integer analysisType = analysisBatch.getAnalysisType();
Integer finalTrackGauge = null;
Integer finalLevel = null;
Integer finalTriangularPit = null;
Integer finalHeight = null;
Integer finalDirection = null;
int sumTrackGauge = 0;
int sumLevel = 0;
int sumTriangularPit = 0;
int sumHeight = 0;
int sumDirection = 0;
int maxTrackGauge = 0;
int maxLevel = 0;
int maxTriangularPit = 0;
int maxHeight = 0;
int maxDirection = 0;
int avgTrackGauge = 0;
int avgLevel = 0;
int avgTriangularPit = 0;
int avgHeight = 0;
int avgDirection = 0;
int trackGaugeSize = 0;
int levelSize = 0;
int triangularPitSize = 0;
int heightSize = 0;
int directionSize = 0;
// 循环计算均值/峰值
for (MovementCourseInfo movementCourseInfo : labourCheckList) {
// 轨距
Integer trackGauge = Convert.toInt(movementCourseInfo.getTrackGauge());
if (ObjectUtil.isNotEmpty(trackGauge)) {
trackGauge = Math.abs(trackGauge);
// 均值
sumTrackGauge = sumTrackGauge + trackGauge;
trackGaugeSize++;
avgTrackGauge = sumTrackGauge / trackGaugeSize;
// 峰值
if (trackGauge > maxTrackGauge) {
maxTrackGauge = trackGauge;
}
if (1 == analysisType) {
finalTrackGauge = avgTrackGauge;
} else {
finalTrackGauge = maxLevel;
}
}
// 水平
Integer level = Convert.toInt(movementCourseInfo.getLevel());
if (ObjectUtil.isNotEmpty(level)) {
level = Math.abs(level);
// 均值
sumLevel = sumLevel + level;
levelSize++;
avgLevel = sumLevel / levelSize;
// 峰值
if (level > maxLevel) {
maxLevel = level;
}
if (1 == analysisType) {
finalLevel = avgLevel;
} else {
finalLevel = maxLevel;
}
}
//三角坑
Integer triangularPit = Convert.toInt(movementCourseInfo.getTriangularPit());
if (ObjectUtil.isNotEmpty(triangularPit)) {
triangularPit = Math.abs(triangularPit);
// 均值
sumTriangularPit = sumTriangularPit + triangularPit;
triangularPitSize++;
avgTriangularPit = sumTriangularPit / triangularPitSize;
// 峰值
if (triangularPit > maxTriangularPit) {
maxTriangularPit = triangularPit;
}
if (1 == analysisType) {
finalTriangularPit = avgTriangularPit;
} else {
finalTriangularPit = maxTriangularPit;
}
}
// 高低
Integer height = Convert.toInt(movementCourseInfo.getHeight());
if (ObjectUtil.isNotEmpty(height)) {
height = Math.abs(height);
// 均值
sumHeight = sumHeight + height;
heightSize++;
avgHeight = sumHeight / heightSize;
// 峰值
if (height > maxHeight) {
maxHeight = height;
}
if (1 == analysisType) {
finalHeight = avgHeight;
} else {
finalHeight = maxHeight;
}
}
// 轨向
Integer direction = Convert.toInt(movementCourseInfo.getDirection());
if (ObjectUtil.isNotEmpty(direction)) {
direction = Math.abs(direction);
// 均值
sumDirection = sumDirection + direction;
directionSize++;
avgDirection = sumDirection / directionSize;
// 峰值
if (direction > maxDirection) {
maxDirection = direction;
}
if (1 == analysisType) {
finalDirection = avgDirection;
} else {
finalDirection = maxDirection;
}
}
}
ConfigLabourCheck configLabour = configLabourCheckService.lambdaQuery()
.eq(ConfigLabourCheck::getSpeedMax, analysisBatch.getSpeedMax())
.eq(ConfigLabourCheck::getSpeedMin, analysisBatch.getSpeedMin())
.eq(ConfigLabourCheck::getDelFlag, "0")
.last("limit 1")
.one();
// 1-钢轨,2-曲线,3-竖曲线,4-道岔
Integer type = Convert.toInt(unitDevice.get("type"));
JSONObject jsonObject = null;
if (type == 1) {
jsonObject = JSONObject.parseObject(configLabour.getRail());
} else if (type == 2) {
jsonObject = JSONObject.parseObject(configLabour.getCurve());
} else if (type == 3) {
jsonObject = JSONObject.parseObject(configLabour.getVerticalCurve());
} else if (type == 4) {
jsonObject = JSONObject.parseObject(configLabour.getRailSwitch());
}
BigDecimal trackGaugeWeightValues = jsonObject.getBigDecimal("trackGauge");
BigDecimal directionWeightValues = jsonObject.getBigDecimal("direction");
BigDecimal triangularPitWeightValues = jsonObject.getBigDecimal("triangularPit");
BigDecimal heightWeightValues = jsonObject.getBigDecimal("height");
BigDecimal levelWeightValues = jsonObject.getBigDecimal("level");
// 总单元得分
BigDecimal sumUnitScore = null;
// 轨距单元得分
BigDecimal trackGaugeUnitScore;
List<AnalysisBatchUnitDevicePointScore> scoreList = new ArrayList<>();
if (ObjectUtil.isNotEmpty(finalTrackGauge)) {
trackGaugeUnitScore = trackGaugeWeightValues.multiply(new BigDecimal(finalTrackGauge.toString()));
if (sumUnitScore == null) {
sumUnitScore = BigDecimal.ZERO;
}
sumUnitScore = sumUnitScore.add(trackGaugeUnitScore);
AnalysisBatchUnitDevicePointScore score = new AnalysisBatchUnitDevicePointScore();
score.setId(UUIDGenerator.generate());
score.setAnalysisType(analysisType);
score.setSpeedMax(analysisBatch.getSpeedMax());
score.setSpeedMin(analysisBatch.getSpeedMin());
score.setAnalysisBatchId(analysisBatch.getId());
score.setAnalysisBatchCode(analysisBatch.getAnalysisBatchCode());
score.setCheckType(1);
score.setPointTypeName("轨距");
score.setPointValue(finalTrackGauge);
score.setWeightValues(trackGaugeWeightValues);
score.setPointScore(trackGaugeUnitScore);
scoreList.add(score);
}
// 轨向单元得分
BigDecimal directionGaugeUnitScore = null;
if (ObjectUtil.isNotEmpty(finalDirection)) {
directionGaugeUnitScore = directionWeightValues.multiply(new BigDecimal(finalDirection.toString()));
if (sumUnitScore == null) {
sumUnitScore = BigDecimal.ZERO;
}
sumUnitScore = sumUnitScore.add(directionGaugeUnitScore);
AnalysisBatchUnitDevicePointScore score = new AnalysisBatchUnitDevicePointScore();
score.setId(UUIDGenerator.generate());
score.setAnalysisType(analysisType);
score.setSpeedMax(analysisBatch.getSpeedMax());
score.setSpeedMin(analysisBatch.getSpeedMin());
score.setAnalysisBatchId(analysisBatch.getId());
score.setAnalysisBatchCode(analysisBatch.getAnalysisBatchCode());
score.setCheckType(1);
score.setPointTypeName("轨向");
score.setPointValue(finalDirection);
score.setWeightValues(directionGaugeUnitScore);
score.setPointScore(directionGaugeUnitScore);
scoreList.add(score);
}
// 三角坑单元得分
BigDecimal triangularPitGaugeUnitScore;
if (ObjectUtil.isNotEmpty(finalTriangularPit)) {
triangularPitGaugeUnitScore = triangularPitWeightValues.multiply(new BigDecimal(finalTriangularPit.toString()));
if (sumUnitScore == null) {
sumUnitScore = BigDecimal.ZERO;
}
sumUnitScore = sumUnitScore.add(triangularPitGaugeUnitScore);
AnalysisBatchUnitDevicePointScore score = new AnalysisBatchUnitDevicePointScore();
score.setId(UUIDGenerator.generate());
score.setAnalysisType(analysisType);
score.setSpeedMax(analysisBatch.getSpeedMax());
score.setSpeedMin(analysisBatch.getSpeedMin());
score.setAnalysisBatchId(analysisBatch.getId());
score.setAnalysisBatchCode(analysisBatch.getAnalysisBatchCode());
score.setCheckType(1);
score.setPointTypeName("三角坑");
score.setPointValue(finalTriangularPit);
score.setWeightValues(triangularPitWeightValues);
score.setPointScore(triangularPitGaugeUnitScore);
scoreList.add(score);
}
// 高低单元得分
BigDecimal heightGaugeUnitScore;
if (ObjectUtil.isNotEmpty(finalHeight)) {
heightGaugeUnitScore = heightWeightValues.multiply(new BigDecimal(finalHeight.toString()));
if (sumUnitScore == null) {
sumUnitScore = BigDecimal.ZERO;
}
sumUnitScore = sumUnitScore.add(heightGaugeUnitScore);
AnalysisBatchUnitDevicePointScore score = new AnalysisBatchUnitDevicePointScore();
score.setId(UUIDGenerator.generate());
score.setAnalysisType(analysisType);
score.setSpeedMax(analysisBatch.getSpeedMax());
score.setSpeedMin(analysisBatch.getSpeedMin());
score.setAnalysisBatchId(analysisBatch.getId());
score.setAnalysisBatchCode(analysisBatch.getAnalysisBatchCode());
score.setCheckType(1);
score.setPointTypeName("高低");
score.setPointValue(finalHeight);
score.setWeightValues(heightWeightValues);
score.setPointScore(heightGaugeUnitScore);
scoreList.add(score);
}
// 水平单元得分
BigDecimal levelUnitScore;
if (ObjectUtil.isNotEmpty(finalLevel)) {
levelUnitScore = levelWeightValues.multiply(new BigDecimal(finalLevel.toString()));
if (sumUnitScore == null) {
sumUnitScore = BigDecimal.ZERO;
}
sumUnitScore = sumUnitScore.add(levelUnitScore);
AnalysisBatchUnitDevicePointScore score = new AnalysisBatchUnitDevicePointScore();
score.setId(UUIDGenerator.generate());
score.setAnalysisType(analysisType);
score.setSpeedMax(analysisBatch.getSpeedMax());
score.setSpeedMin(analysisBatch.getSpeedMin());
score.setAnalysisBatchId(analysisBatch.getId());
score.setAnalysisBatchCode(analysisBatch.getAnalysisBatchCode());
score.setCheckType(1);
score.setPointTypeName("高低");
score.setPointValue(finalLevel);
score.setWeightValues(levelWeightValues);
score.setPointScore(levelUnitScore);
scoreList.add(score);
}
unitDevice.put("labourCheckScore", sumUnitScore);
unitDevice.put("labourCheckScoreList", scoreList);
}
/**
* 如果超限了就返回 超限对象,没有就返回 null
*
* @param analysisBatch
* @param movementCourseInfo
* @return
*/
private AnalysisBatchUnitDeviceTransfinite labourCheckTransfinite(AnalysisBatch analysisBatch, MovementCourseInfo movementCourseInfo) {
// 超限配置
JSONObject allowValue = JSONObject.parseObject(analysisBatch.getAllowValue());
Integer bigTrackGauge = Convert.toInt(allowValue.get("bigTrackGauge")); // 大轨距
Integer smallTrackGauge = Convert.toInt(allowValue.get("smallTrackGauge")); // 小轨距
Integer allowLevel = Convert.toInt(allowValue.get("level")); // 水平
Integer allowTriangularPit = Convert.toInt(allowValue.get("triangularPit")); // 三角坑
Integer allowHeight = Convert.toInt(allowValue.get("height")); // 高低
Integer allowDirection = Convert.toInt(allowValue.get("direction")); // 轨向
// 是否派工配置
Integer isWork = 1;
String reasonLabel = "";
JSONArray dispatchingList = JSONArray.parseArray(analysisBatch.getDispatching());
for (Object obj : dispatchingList) {
JSONObject dispatching = (JSONObject) obj;
String reasonValue = String.valueOf(dispatching.get("reasonValue"));
reasonLabel = String.valueOf(dispatching.get("reasonLabel"));
if ("static_limit".equals(reasonValue)) {
Boolean isWorkTemp = Boolean.valueOf(dispatching.get("isWork").toString());
if (isWorkTemp) {
isWork = 1;
} else {
isWork = 0;
}
}
}
boolean isTransfinite = false;
String allowValueSave = "";
String measurePointValue = "";
String transfiniteType = "";
// 轨距
Integer trackGauge = Convert.toInt(movementCourseInfo.getTrackGauge());
if (ObjectUtil.isNotEmpty(trackGauge)) {
if (trackGauge > bigTrackGauge) {
isTransfinite = true;
allowValueSave = bigTrackGauge.toString();
measurePointValue = trackGauge.toString();
transfiniteType = "大轨距";
} else if (trackGauge < smallTrackGauge) {
isTransfinite = true;
allowValueSave = smallTrackGauge.toString();
measurePointValue = trackGauge.toString();
transfiniteType = "小轨距";
}
}
// 水平
Integer level = Convert.toInt(movementCourseInfo.getLevel());
if (ObjectUtil.isNotEmpty(level)) {
if (level > allowLevel) {
isTransfinite = true;
allowValueSave = allowLevel.toString();
measurePointValue = level.toString();
transfiniteType = "水平";
}
}
//三角坑
Integer triangularPit = Convert.toInt(movementCourseInfo.getTriangularPit());
if (ObjectUtil.isNotEmpty(triangularPit)) {
if (triangularPit > allowTriangularPit) {
isTransfinite = true;
allowValueSave = allowTriangularPit.toString();
measurePointValue = triangularPit.toString();
transfiniteType = "三角坑";
}
}
// 高低
Integer height = Convert.toInt(movementCourseInfo.getHeight());
if (ObjectUtil.isNotEmpty(height)) {
if (height > allowHeight) {
isTransfinite = true;
allowValueSave = allowHeight.toString();
measurePointValue = height.toString();
transfiniteType = "高低";
}
}
// 轨向
Integer direction = Convert.toInt(movementCourseInfo.getDirection());
if (ObjectUtil.isNotEmpty(direction)) {
if (direction > allowDirection) {
isTransfinite = true;
allowValueSave = allowDirection.toString();
measurePointValue = direction.toString();
transfiniteType = "轨向";
}
}
// 超限
if (isTransfinite) {
AnalysisBatchUnitDeviceTransfinite record = new AnalysisBatchUnitDeviceTransfinite();
record.setId(UUIDGenerator.generate());
record.setTransfiniteGrade(1);
record.setTransfiniteGradeName(reasonLabel);
record.setTransfiniteType(transfiniteType);
record.setAllowValue(allowValueSave);
record.setMeasurePointValue(measurePointValue);
record.setIsWork(isWork);
return record;
} else {
return null;
}
}
/**
* 人工检查设备映射
*
* @param movementCourseInfo
* @param unitDevice
* @param checkItem
* @return
*/
private MovementCheckDataUnitDeviceMap labourCheckDeviceMapSave(MovementCourseInfo movementCourseInfo,
Map<String, Object> unitDevice,
MovementCourse 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);
MovementCheckDataUnitDeviceMap record = new MovementCheckDataUnitDeviceMap();
record.setId(UUIDGenerator.generate());
record.setCheckType(1);// 人工检查
record.setUnitId(Convert.toStr(unitDevice.get("id")));
record.setUnitCode(Convert.toStr(unitDevice.get("unitCode")));
record.setUnitType(Convert.toInt(unitDevice.get("type")));
record.setUnitTypeName(Convert.toStr(unitDevice.get("typeName")));
record.setUnitStartingMileage(startMileage);
record.setUnitCenterMileage(centerMileage);
record.setUnitEndMileage(endMileage);
record.setCheckId(checkItem.getMovementMasterId());
record.setCheckItemId(checkItem.getId());
record.setCheckItemStartingMileage(checkItem.getCourseStartingMileage());
record.setCheckItemEndMileage(checkItem.getCourseEndMileage());
record.setCheckItemText(movementCourseInfo.getTrackCode());
record.setCheckDetailId(movementCourseInfo.getId());
record.setCheckDetailStartingMileage(movementCourseInfo.getCurrentStartMileage());
record.setCheckDetailEndMileage(movementCourseInfo.getCurrentEndEndMileage());
record.setTrackGauge(movementCourseInfo.getTrackGauge());
record.setLevel(movementCourseInfo.getLevel());
record.setTriangularPit(movementCourseInfo.getTriangularPit());
record.setMeasurePoint(movementCourseInfo.getMeasurePoint());
record.setDirection(movementCourseInfo.getDirection());
record.setHeight(movementCourseInfo.getHeight());
record.setStructure(movementCourseInfo.getStructure());
record.setRectification(movementCourseInfo.getRectification());
return record;
}
}
\ No newline at end of file
......@@ -36,7 +36,7 @@ public class AnalysisBatchUnitDeviceDTO {
private BigDecimal unitEndMileage;
@ApiModelProperty("是否超限")
private int isTransfinite;
private Integer isTransfinite;
@ApiModelProperty("单元编号")
private String unitCode;
......
......@@ -93,6 +93,10 @@ public class AnalysisBatchUnitDevice implements Serializable {
@TableField("unit_score_level")
private Integer unitScoreLevel;
@ApiModelProperty("单元得分等级说明")
@TableField("unit_score_level_str")
private String unitScoreLevelStr;
@ApiModelProperty("单元得分")
@TableField("unit_score")
private BigDecimal unitScore;
......
......@@ -87,6 +87,10 @@ public class AnalysisBatchUnitDevicePointScore implements Serializable {
@TableField("unit_type_name")
private String unitTypeName;
@ApiModelProperty("检查类型 1-人工检查 2-轨检仪类型 3-轨检车类型 4-添乘仪类型")
@TableField("check_type")
private Integer checkType;
@ApiModelProperty("测点类型")
@TableField("point_type_name")
private String pointTypeName;
......
......@@ -21,11 +21,13 @@
t1.unit_starting_mileage,
t1.unit_center_mileage,
t1.unit_end_mileage,
t1.unit_score finalGrade,
t1.unit_score_level gradeJudge,
t1.unit_score,
t1.unit_score_level,
t1.unit_score_level_str,
t1.remark,
( SELECT COUNT( 1 ) FROM t_dsa_analysis_batch_unit_device_transfinite WHERE analysis_batch_unit_device_id = t1.id LIMIT 1 ) AS is_work,
( SELECT COUNT( 1 ) FROM t_dsa_analysis_batch_unit_device_transfinite WHERE analysis_batch_unit_device_id = t1.id LIMIT 1 ) AS is_transfinite
( SELECT COUNT( 1 ) FROM t_dsa_analysis_batch_unit_device_transfinite WHERE analysis_batch_unit_device_id = t1.id LIMIT 1 ) AS is_transfinite,
( SELECT COUNT( 1 ) FROM t_mw_work_batch_detail WHERE analysis_batch_unit_device_id = t1.id LIMIT 1 ) AS work_status
FROM
t_dsa_analysis_batch_unit_device t1
WHERE
......@@ -45,5 +47,8 @@
#{item}
</foreach>
</if>
<if test="dto.isTransfinite != null">
AND analysis.is_transfinite = 1
</if>
</select>
</mapper>
......@@ -54,11 +54,14 @@ public class AnalysisBatchUnitDeviceVO {
@ApiModelProperty("设备单元结束里程")
private BigDecimal unitEndMileage;
@ApiModelProperty("最后得分")
private BigDecimal finalGrade;
@ApiModelProperty("单元得分等级中文")
private String unitScoreLevelStr;
@ApiModelProperty("得分平级")
private String gradeJudge;
@ApiModelProperty("单元得分等级 1-优良 2-合格 3-失格")
private int unitScoreLevel;
@ApiModelProperty("单元得分")
private String unitScore;
@ApiModelProperty("备注")
private String remark;
......@@ -69,11 +72,9 @@ public class AnalysisBatchUnitDeviceVO {
@ApiModelProperty("是否超限 0-否 1-是")
private Integer isTransfinite;
@ApiModelProperty("是否派工 0-否 1-是")
private Integer isWork;
@ApiModelProperty("派工状态 0-未派工 1-派工")
private Integer workStatus;
}
......@@ -7,9 +7,7 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.jeecg.modules.dynamicStaticAnalysis.dto.AnalysisBatchSaveOrUpdateDTO;
import org.jeecg.modules.maintenanceWork.dto.WorkBatchDTO;
import org.jeecg.modules.maintenanceWork.dto.WorkBatchSaveOrUpdateDTO;
import org.jeecg.modules.maintenanceWork.dto.*;
import org.jeecg.modules.maintenanceWork.entity.WorkBatch;
import org.jeecg.modules.maintenanceWork.service.IWorkBatchService;
import org.jeecg.modules.maintenanceWork.vo.WorkBatchVO;
......@@ -17,6 +15,9 @@ import org.springframework.web.bind.annotation.*;
import org.jeecg.common.system.base.controller.JeecgController;
import java.util.List;
import java.util.Map;
/**
* <p>
* 维修作业管理-作业计划批次管理表 前端控制器
......@@ -51,6 +52,16 @@ public class WorkBatchController extends JeecgController<WorkBatch, IWorkBatchSe
return Result.OK("操作成功");
}
@AutoLog(value = "维修作业管理-作业计划批次管理-超限页面新增")
@ApiOperation(value = "维修作业管理-作业计划批次管理-超限页面新增", notes = "维修作业管理-作业计划批次管理-超限页面新增")
@PostMapping(value = "/transfiniteSaveRecord")
public Result<String> transfiniteSaveRecord(@RequestBody WorkBatchTransfiniteSaveDTO dto) {
this.service.transfiniteSaveRecord(dto);
return Result.OK("操作成功");
}
@AutoLog(value = "维修作业管理-作业计划批次管理-维修作业管理页面更新")
@ApiOperation(value = "维修作业管理-作业计划批次管理-维修作业管理页面更新", notes = "维修作业管理-作业计划批次管理-维修作业管理页面更新")
......@@ -70,4 +81,27 @@ public class WorkBatchController extends JeecgController<WorkBatch, IWorkBatchSe
return Result.OK("删除成功!");
}
@AutoLog(value = "维修作业管理-作业计划批次管理-获取里程单元设备")
@ApiOperation(value = "维修作业管理-作业计划批次管理-获取里程单元设备", notes = "维修作业管理-作业计划批次管理-获取里程单元设备")
@GetMapping(value = "/getUnitDeviceList")
public Result<List<Map<String, Object>>> getUnitDeviceList(@RequestBody UnitDeviceDTO dto) {
List<Map<String, Object>> records = this.service.getUnitDeviceList(dto);
return Result.OK(records);
}
@AutoLog(value = "维修作业管理-作业计划批次管理-维修作业管理页面详情新增")
@ApiOperation(value = "维修作业管理-作业计划批次管理-维修作业管理页面新增", notes = "维修作业管理-作业计划批次管理-维修作业管理页面新增")
@PostMapping(value = "/saveDetailRecord")
public Result<String> saveDetailRecord(@RequestBody WorkBatchDetailDTO dto) {
this.service.saveDetailRecord(dto);
return Result.OK("操作成功");
}
}
package org.jeecg.modules.maintenanceWork.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
/**
* <p>
* 维修作业管理-作业计划批次管理明细表
* </p>
*
* @author hkl
* @since 2023-08-09
*/
@Data
@ApiModel(value = "TransfiniteDTO对象", description = "维修作业管理-超限")
public class DispatchDTO {
@ApiModelProperty("分析批次单元设备id")
private String id;
@ApiModelProperty("单元设备id")
private String unitId;
@ApiModelProperty("单元设备code")
private String unitCode;
@ApiModelProperty("设备单元类型1-钢轨 2-曲线 3-竖曲线 4-道岔")
private Integer unitType;
@ApiModelProperty("设备单元类型名称")
private String unitTypeName;
@ApiModelProperty("设备编号")
private String unitDeviceCode;
@ApiModelProperty("设备单元起始里程")
private BigDecimal unitStartingMileage;
@ApiModelProperty("设备单元中心里程")
private BigDecimal unitCenterMileage;
@ApiModelProperty("设备单元结束里程")
private BigDecimal unitEndMileage;
@ApiModelProperty("单元得分等级中文")
private String unitScoreLevelStr;
@ApiModelProperty("单元得分等级 1-优良 2-合格 3-失格")
private int unitScoreLevel;
@ApiModelProperty("单元得分")
private BigDecimal unitScore;
}
package org.jeecg.modules.maintenanceWork.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
@Data
@ApiModel(value = "UnitDeviceDTO对象", description = "fsf1")
public class UnitDeviceDTO {
@ApiModelProperty("作业计划批次号")
private String lightRailId;
@ApiModelProperty("作业计划批次号")
private String lineAliasId;
@ApiModelProperty("作业计划批次号")
private BigDecimal startMileage;
@ApiModelProperty("作业计划批次号")
private BigDecimal endMileage;
}
......@@ -28,7 +28,6 @@ public class WorkBatchDTO {
private static final long serialVersionUID = 1L;
@ApiModelProperty("作业计划批次号")
private String workBatchCode;
......
package org.jeecg.modules.maintenanceWork.dto;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
/**
* <p>
......@@ -26,79 +20,12 @@ import lombok.Setter;
@ApiModel(value = "WorkBatchDetailDTO对象", description = "维修作业管理-作业计划批次管理明细表")
public class WorkBatchDetailDTO {
private static final long serialVersionUID = 1L;
@ApiModelProperty("主键")
private String id;
@ApiModelProperty("创建人")
private String createBy;
@ApiModelProperty("创建日期")
private Date createTime;
@ApiModelProperty("更新人")
private String updateBy;
@ApiModelProperty("更新时间")
private Date updateTime;
@ApiModelProperty("工作批次code")
private String workBatchCode;
@ApiModelProperty("工作批次id")
@ApiModelProperty("作业计划批id")
private String workBatchId;
@ApiModelProperty("检查批次号")
private String ekCode;
@ApiModelProperty("检查批id")
private String ekId;
@ApiModelProperty("检查数据类型 1-人工静态检查 2-轨检仪静态检查 3-轨检车检查 4-添乘仪检查")
private Integer ekType;
@ApiModelProperty("检查日期")
private Date checkTime;
@ApiModelProperty("起始里程")
private BigDecimal startingMileage;
@ApiModelProperty("终点里程")
private BigDecimal endMileage;
@ApiModelProperty("单元设备id")
private String unitId;
@ApiModelProperty("单元设备code")
private String unitCode;
@ApiModelProperty("设备单元类型1-钢轨,2-曲线,3-竖曲线,4-道岔")
private Integer unitType;
@ApiModelProperty("设备单元类型名称")
private String unitTypeName;
@ApiModelProperty("设备编号")
private String unitDeviceCode;
@ApiModelProperty("设备单元起始里程")
private BigDecimal unitStartingMileage;
@ApiModelProperty("设备单元中心里程")
private BigDecimal unitCenterMileage;
@ApiModelProperty("设备单元结束里程")
private BigDecimal unitEndMileage;
@ApiModelProperty("单元得分等级 1-优良 2-合格 3-失格")
private Integer unitScoreLevel;
@ApiModelProperty("单元得分")
private BigDecimal unitScore;
@ApiModelProperty("备注")
private String remark;
@ApiModelProperty("作业计划批次号")
private String workBatchCode;
@ApiModelProperty("单元设备列表")
private List<DispatchDTO> unitDeviceList;
}
......@@ -4,6 +4,7 @@ import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
import java.util.Date;
/**
......@@ -15,7 +16,7 @@ import java.util.Date;
* @since 2023-08-09
*/
@Data
@ApiModel(value = "WorkBatchSaveOrUpdateDTO对象", description = "维修作业管理-作业计划批次管理表")
@ApiModel(value = "PageSaveOrUpdateDTO对象", description = "维修作业管理-页面来源保存或更新dto")
public class WorkBatchSaveOrUpdateDTO {
private static final long serialVersionUID = 1L;
......@@ -37,6 +38,15 @@ public class WorkBatchSaveOrUpdateDTO {
@ApiModelProperty("所属线别名称")
private String lineAliasName;
@ApiModelProperty("作业起始里程")
private BigDecimal workStartingMileage;
@ApiModelProperty("作业终点里程")
private BigDecimal workEndMileage;
@ApiModelProperty("作业终止时间")
private Date workStartTime;
@ApiModelProperty("作业终止时间")
private Date workEndTime;
......@@ -48,8 +58,4 @@ public class WorkBatchSaveOrUpdateDTO {
@ApiModelProperty("作业状态 0-未作业 1-已作业")
private Integer workStatus;
@ApiModelProperty("是否删除 0-未删除 1-已删除")
private String delFlag;
}
package org.jeecg.modules.maintenanceWork.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
/**
* <p>
* 维修作业管理-作业计划批次管理表
* </p>
*
* @author hkl
* @since 2023-08-09
*/
@Data
@ApiModel(value = "WorkBatchSaveOrUpdateDTO对象", description = "维修作业管理-作业计划批次管理表")
public class WorkBatchTransfiniteSaveDTO {
private static final long serialVersionUID = 1L;
private String id;
@ApiModelProperty("作业计划批次号")
private String workBatchCode;
@ApiModelProperty("所属线路id")
private String lightRailId;
@ApiModelProperty("所属线路名称")
private String lightRailName;
@ApiModelProperty("所属线别id")
private String lineAliasId;
@ApiModelProperty("所属线别名称")
private String lineAliasName;
@ApiModelProperty("作业终止时间")
private Date workStartTime;
@ApiModelProperty("作业终止时间")
private Date workEndTime;
@ApiModelProperty("作业起始里程")
private BigDecimal workStartMileage;
@ApiModelProperty("作业终点里程")
private BigDecimal workEndMileage;
@ApiModelProperty("作业班组")
private String team;
@ApiModelProperty("派工列表")
private List<DispatchDTO> dispatchList;
}
......@@ -68,8 +68,8 @@ public class WorkBatch implements Serializable {
private String lineAliasName;
@ApiModelProperty("作业起始里程")
@TableField("work_starting_mileage")
private BigDecimal workStartingMileage;
@TableField("work_start_mileage")
private BigDecimal workStartMileage;
@ApiModelProperty("作业终点里程")
@TableField("work_end_mileage")
......
......@@ -3,9 +3,11 @@ package org.jeecg.modules.maintenanceWork.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
......@@ -55,29 +57,9 @@ public class WorkBatchDetail implements Serializable {
@TableField("work_batch_id")
private String workBatchId;
@ApiModelProperty("检查批次号")
@TableField("ek_code")
private String ekCode;
@ApiModelProperty("检查批id")
@TableField("ek_id")
private String ekId;
@ApiModelProperty("检查数据类型 1-人工静态检查 2-轨检仪静态检查 3-轨检车检查 4-添乘仪检查")
@TableField("ek_type")
private Integer ekType;
@ApiModelProperty("检查日期")
@TableField("check_time")
private Date checkTime;
@ApiModelProperty("起始里程")
@TableField("starting_mileage")
private BigDecimal startingMileage;
@ApiModelProperty("终点里程")
@TableField("end_mileage")
private BigDecimal endMileage;
@ApiModelProperty("分析批次单元设备id")
@TableField("analysis_batch_unit_device_id")
private String analysisBatchUnitDeviceId;
@ApiModelProperty("单元设备id")
@TableField("unit_id")
......@@ -115,6 +97,10 @@ public class WorkBatchDetail implements Serializable {
@TableField("unit_score_level")
private Integer unitScoreLevel;
@ApiModelProperty("单元得分等级说明")
@TableField("unit_score_level_str")
private String unitScoreLevelStr;
@ApiModelProperty("单元得分")
@TableField("unit_score")
private BigDecimal unitScore;
......
......@@ -14,14 +14,15 @@
t1.light_rail_name,
t1.line_alias_id,
t1.line_alias_name,
t1.work_starting_mileage,
t1.work_start_mileage,
t1.work_end_mileage,
t1.work_start_time,
t1.work_end_time,
t1.team,
t1.source,
t1.work_status,
t1.del_flag
t1.del_flag,
(SELECT count(1) FROM t_mw_work_batch_detail WHERE work_batch_id = t1.id) work_unit_device_num
FROM
t_mw_work_batch t1
WHERE
......
package org.jeecg.modules.maintenanceWork.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.jeecg.modules.maintenanceWork.dto.WorkBatchDTO;
import org.jeecg.modules.maintenanceWork.dto.WorkBatchSaveOrUpdateDTO;
import org.jeecg.modules.maintenanceWork.dto.*;
import org.jeecg.modules.maintenanceWork.entity.WorkBatch;
import com.baomidou.mybatisplus.extension.service.IService;
import org.jeecg.modules.maintenanceWork.vo.WorkBatchVO;
import java.util.List;
import java.util.Map;
/**
* <p>
* 维修作业管理-作业计划批次管理表 服务类
......@@ -24,4 +26,10 @@ public interface IWorkBatchService extends IService<WorkBatch> {
void updateRecord(WorkBatchSaveOrUpdateDTO dto);
void deleteRecord(String id);
void transfiniteSaveRecord(WorkBatchTransfiniteSaveDTO dto);
void saveDetailRecord(WorkBatchDetailDTO dto);
List<Map<String, Object>> getUnitDeviceList(UnitDeviceDTO dto);
}
package org.jeecg.modules.maintenanceWork.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.convert.Convert;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.jeecg.common.util.UUIDGenerator;
import org.jeecg.modules.maintenanceWork.dto.WorkBatchDTO;
import org.jeecg.modules.maintenanceWork.dto.WorkBatchSaveOrUpdateDTO;
import org.jeecg.modules.dynamicStaticAnalysis.mapper.AnalysisAlgorithmMapper;
import org.jeecg.modules.maintenanceWork.dto.*;
import org.jeecg.modules.maintenanceWork.entity.WorkBatch;
import org.jeecg.modules.maintenanceWork.entity.WorkBatchDetail;
import org.jeecg.modules.maintenanceWork.mapper.WorkBatchDetailMapper;
......@@ -15,6 +18,11 @@ import org.jeecg.modules.maintenanceWork.vo.WorkBatchVO;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* <p>
......@@ -29,6 +37,9 @@ public class WorkBatchServiceImpl extends ServiceImpl<WorkBatchMapper, WorkBatch
@Resource
private WorkBatchDetailMapper workBatchDetailMapper;
@Resource
private AnalysisAlgorithmMapper analysisAlgorithmMapper;
@Override
public Page<WorkBatchVO> listRecord(Page<WorkBatchVO> pageData, WorkBatchDTO dto) {
return this.baseMapper.listRecord(pageData, dto);
......@@ -48,8 +59,88 @@ public class WorkBatchServiceImpl extends ServiceImpl<WorkBatchMapper, WorkBatch
}
@Override
public void deleteRecord(String id) {
this.removeById(id);
public void deleteRecord(String workBatchId) {
this.removeById(workBatchId);
LambdaQueryWrapper<WorkBatchDetail> delWrapper = Wrappers.lambdaQuery();
delWrapper.eq(WorkBatchDetail::getWorkBatchId, workBatchId);
workBatchDetailMapper.delete(delWrapper);
}
@Override
public void transfiniteSaveRecord(WorkBatchTransfiniteSaveDTO dto) {
WorkBatch workBatch = BeanUtil.copyProperties(dto, WorkBatch.class);
workBatch.setId(UUIDGenerator.generate());
workBatch.setWorkStatus(9); // 9-已作业
workBatch.setSource(2); // 超限页面
this.save(workBatch);
List<DispatchDTO> transfiniteList = dto.getDispatchList();
for (DispatchDTO transfiniteDTO : transfiniteList) {
WorkBatchDetail workBatchDetail = new WorkBatchDetail();
workBatchDetail.setId(UUIDGenerator.generate());
workBatchDetail.setWorkBatchId(workBatch.getId());
workBatchDetail.setWorkBatchCode(workBatch.getWorkBatchCode());
workBatchDetail.setAnalysisBatchUnitDeviceId(transfiniteDTO.getId());
workBatchDetail.setUnitId(transfiniteDTO.getUnitId());
workBatchDetail.setUnitCode(transfiniteDTO.getUnitCode());
workBatchDetail.setUnitType(transfiniteDTO.getUnitType());
workBatchDetail.setUnitTypeName(transfiniteDTO.getUnitTypeName());
workBatchDetail.setUnitDeviceCode(transfiniteDTO.getUnitDeviceCode());
workBatchDetail.setUnitEndMileage(transfiniteDTO.getUnitStartingMileage());
workBatchDetail.setUnitEndMileage(transfiniteDTO.getUnitEndMileage());
workBatchDetail.setUnitCenterMileage(transfiniteDTO.getUnitCenterMileage());
workBatchDetail.setUnitScore(transfiniteDTO.getUnitScore());
workBatchDetail.setUnitScoreLevel(transfiniteDTO.getUnitScoreLevel());
workBatchDetail.setUnitScoreLevelStr(transfiniteDTO.getUnitScoreLevelStr());
workBatchDetailMapper.insert(workBatchDetail);
}
}
@Override
public void saveDetailRecord(WorkBatchDetailDTO dto) {
// 先删除
LambdaQueryWrapper<WorkBatchDetail> delWrapper = Wrappers.lambdaQuery();
delWrapper.eq(WorkBatchDetail::getWorkBatchId, dto.getWorkBatchId());
workBatchDetailMapper.delete(delWrapper);
List<DispatchDTO> transfiniteList = dto.getUnitDeviceList();
for (DispatchDTO dispatchDTO : transfiniteList) {
WorkBatchDetail workBatchDetail = new WorkBatchDetail();
workBatchDetail.setId(UUIDGenerator.generate());
workBatchDetail.setWorkBatchId(dto.getWorkBatchId());
workBatchDetail.setWorkBatchCode(dto.getWorkBatchCode());
workBatchDetail.setUnitId(dispatchDTO.getUnitId());
workBatchDetail.setUnitCode(dispatchDTO.getUnitCode());
workBatchDetail.setUnitType(dispatchDTO.getUnitType());
workBatchDetail.setUnitTypeName(dispatchDTO.getUnitTypeName());
workBatchDetail.setUnitDeviceCode(dispatchDTO.getUnitDeviceCode());
workBatchDetail.setUnitEndMileage(dispatchDTO.getUnitStartingMileage());
workBatchDetail.setUnitEndMileage(dispatchDTO.getUnitEndMileage());
workBatchDetail.setUnitCenterMileage(dispatchDTO.getUnitCenterMileage());
workBatchDetail.setUnitScore(dispatchDTO.getUnitScore());
workBatchDetail.setUnitScoreLevel(dispatchDTO.getUnitScoreLevel());
workBatchDetail.setUnitScoreLevelStr(dispatchDTO.getUnitScoreLevelStr());
workBatchDetailMapper.insert(workBatchDetail);
}
}
@Override
public List<Map<String, Object>> getUnitDeviceList(UnitDeviceDTO dto) {
List<Map<String, Object>> resultList = new ArrayList<>();
List<Map<String, Object>> unitDeviceList = analysisAlgorithmMapper.getUnitDevice(dto.getLightRailId(), dto.getLineAliasId());
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 (dto.getStartMileage().compareTo(centerMileage) <= 0 && dto.getEndMileage().compareTo(centerMileage) > 0) {
resultList.add(unitDevice);
}
}
return resultList;
}
}
package org.jeecg.modules.maintenanceWork.vo;
import com.baomidou.mybatisplus.annotation.TableField;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
......@@ -23,6 +24,12 @@ public class WorkBatchVO {
private String id;
@ApiModelProperty("创建人")
private String createBy;
@ApiModelProperty("创建日期")
private Date createTime;
@ApiModelProperty("作业计划批次号")
private String workBatchCode;
......@@ -38,19 +45,32 @@ public class WorkBatchVO {
@ApiModelProperty("所属线别名称")
private String lineAliasName;
@ApiModelProperty("作业开始时间")
private Date workStartTime;
@ApiModelProperty("作业终止时间")
private Date workEndTime;
@ApiModelProperty("作业终止时间")
private BigDecimal workStartMileage;
@ApiModelProperty("作业终止时间")
private BigDecimal workEndMileage;
@ApiModelProperty("作业班组")
private String team;
@ApiModelProperty("来源 1-页面添加 2-超限派工添加")
private Integer source;
@ApiModelProperty("作业状态 0-未作业 1-已作业")
@ApiModelProperty("作业状态 0-未作业 9-已作业")
private Integer workStatus;
@ApiModelProperty("作业单元数量")
private Integer workUnitDeviceNum;
@ApiModelProperty("是否删除 0-未删除 1-已删除")
private String delFlag;
}
......@@ -60,8 +60,8 @@ public class SubwaySectionServiceImpl extends ServiceImpl<SubwaySectionMapper, S
SubwaySection subwaySection = BeanUtil.copyProperties(dto, SubwaySection.class);
LightRail rail = lightRailMapper.selectById(dto.getLightRailId()); // 线路id
subwaySection.setLightRailName(rail.getRailLineName());// 线路昵称
subwaySection.setSectionStartingMileage(startTrainStation.getCenterMileage()); // 区间起始里程
subwaySection.setSectionEndMileage(endTrainStation.getCenterMileage());// 区间结束里程
subwaySection.setSectionStartingMileage(startTrainStation.getEndMileage()); // 区间起始里程
subwaySection.setSectionEndMileage(endTrainStation.getStartingMileage());// 区间结束里程
//维护区间的更新人和更新时间
subwaySection.setUpdateTime(new Date());
LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
......
......@@ -131,7 +131,7 @@ spring:
connectionProperties: druid.stat.mergeSql\=true;druid.stat.slowSqlMillis\=5000
datasource:
master:
url: jdbc:mysql://47.94.207.62:3306/hzsomms?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&zeroDateTimeBehavior=convertToNull
url: jdbc:mysql://47.94.207.62:3306/hzgw?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&zeroDateTimeBehavior=convertToNull
username: root
password: superAdmin&321
driver-class-name: com.mysql.jdbc.Driver
......
......@@ -131,7 +131,7 @@ spring:
connectionProperties: druid.stat.mergeSql\=true;druid.stat.slowSqlMillis\=5000
datasource:
master:
url: jdbc:mysql://127.0.0.1:3306/hzsomms?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&zeroDateTimeBehavior=convertToNull
url: jdbc:mysql://127.0.0.1:3306/hzgw?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&zeroDateTimeBehavior=convertToNull
username: root
password: superAdmin&321
driver-class-name: com.mysql.jdbc.Driver
......
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