Commit 5048ed09 authored by hkl's avatar hkl

feat: 1.分析算法提交

parent 0a30bb36
......@@ -25,11 +25,11 @@ public class CodeGenerate {
String outputDir = projectPath + "\\jeecg-module-system\\src\\main\\java\\";
// 模块名
String moduleName = "dynamicStaticAnalysis";
String moduleName = "checkData.equipmentCheckData";
// 表名
String[] tables = {
"t_dsa_analysis_batch_unit_device_tqi_score",
"t_djt_movement_additive_info_unit_device_map",
};
......
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 io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
/**
* <p>
* 动静态几何尺寸对应的添乘仪详情表
* </p>
*
* @author hkl
* @since 2023-08-31
*/
@Getter
@Setter
@TableName("t_djt_movement_additive_info_unit_device_map")
@ApiModel(value = "MovementAdditiveInfoUnitDeviceMap对象", description = "动静态几何尺寸对应的添乘仪详情表")
public class MovementAdditiveInfoUnitDeviceMap implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty("主键")
@TableId("id")
private String id;
@ApiModelProperty("创建人")
@TableField("create_by")
private String createBy;
@ApiModelProperty("创建日期")
@TableField("create_time")
private Date createTime;
@ApiModelProperty("更新人")
@TableField("update_by")
private String updateBy;
@ApiModelProperty("更新时间")
@TableField("update_time")
private Date updateTime;
@ApiModelProperty("动静态几何尺寸数据主表主键-》外键")
@TableField("movement_master_id")
private String movementMasterId;
@ApiModelProperty("设备单元id")
@TableField("unit_id")
private String unitId;
@ApiModelProperty("设备单元编码")
@TableField("unit_code")
private String unitCode;
@ApiModelProperty("设备单元编码")
@TableField("unit_device_code")
private String unitDeviceCode;
@ApiModelProperty("设备单元类型1-钢轨,2-曲线,3-竖曲线,4-道岔")
@TableField("unit_type")
private Integer unitType;
@ApiModelProperty("设备单元类型名称")
@TableField("unit_type_name")
private String unitTypeName;
@ApiModelProperty("设备单元起始里程")
@TableField("unit_start_mileage")
private BigDecimal unitStartMileage;
@ApiModelProperty("设备单元中心里程")
@TableField("unit_center_mileage")
private BigDecimal unitCenterMileage;
@ApiModelProperty("设备单元终点里程")
@TableField("unit_end_mileage")
private BigDecimal unitEndMileage;
@ApiModelProperty("测点里程")
@TableField("point_mileage")
private BigDecimal pointMileage;
@ApiModelProperty("水平加速度")
@TableField("zontal_speed")
private BigDecimal zontalSpeed;
@ApiModelProperty("水平加速度等级")
@TableField("zontal_speed_level")
private Integer zontalSpeedLevel;
@ApiModelProperty("垂直加速度")
@TableField("vertical_speed")
private BigDecimal verticalSpeed;
@ApiModelProperty("垂直加速度等级")
@TableField("vertical_speed_level")
private Integer verticalSpeedLevel;
@ApiModelProperty("速度")
@TableField("speed")
private BigDecimal speed;
@ApiModelProperty("手动标记")
@TableField("mark")
private String mark;
@ApiModelProperty("是否删除(0:未删除;1:已删除)")
@TableField("del_flag")
private String delFlag;
@ApiModelProperty("排序字段")
@TableField("info_sort")
private Integer infoSort;
}
package org.jeecg.modules.checkData.equipmentCheckData.mapper;
import org.jeecg.modules.checkData.equipmentCheckData.entity.MovementAdditiveInfoUnitDeviceMap;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* <p>
* 动静态几何尺寸对应的添乘仪详情表 Mapper 接口
* </p>
*
* @author hkl
* @since 2023-08-31
*/
public interface MovementAdditiveInfoUnitDeviceMapMapper extends BaseMapper<MovementAdditiveInfoUnitDeviceMap> {
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.jeecg.modules.checkData.equipmentCheckData.mapper.MovementAdditiveInfoUnitDeviceMapMapper">
</mapper>
package org.jeecg.modules.checkData.equipmentCheckData.service;
import org.jeecg.modules.checkData.equipmentCheckData.entity.MovementAdditiveInfoUnitDeviceMap;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* <p>
* 动静态几何尺寸对应的添乘仪详情表 服务类
* </p>
*
* @author hkl
* @since 2023-08-31
*/
public interface IMovementAdditiveInfoUnitDeviceMapService extends IService<MovementAdditiveInfoUnitDeviceMap> {
}
package org.jeecg.modules.checkData.equipmentCheckData.service.impl;
import org.jeecg.modules.checkData.equipmentCheckData.entity.MovementAdditiveInfoUnitDeviceMap;
import org.jeecg.modules.checkData.equipmentCheckData.mapper.MovementAdditiveInfoUnitDeviceMapMapper;
import org.jeecg.modules.checkData.equipmentCheckData.service.IMovementAdditiveInfoUnitDeviceMapService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
/**
* <p>
* 动静态几何尺寸对应的添乘仪详情表 服务实现类
* </p>
*
* @author hkl
* @since 2023-08-31
*/
@Service
public class MovementAdditiveInfoUnitDeviceMapServiceImpl extends ServiceImpl<MovementAdditiveInfoUnitDeviceMapMapper, MovementAdditiveInfoUnitDeviceMap> implements IMovementAdditiveInfoUnitDeviceMapService {
}
......@@ -74,28 +74,28 @@ public class AnalysisAlgorithm {
private IConfigRailVehicleCheckService configRailVehicleCheckService;
@Resource
private IMovementTqiReportUnitDeviceMapService movementTqiReportUnitDeviceMapService;
private IConfigInstrumentCheckService configInstrumentCheckService;
@Resource
private IMovementTqiReportUnitDeviceMapService movementTqiReportUnitDeviceMapService;
@Resource
private IAnalysisBatchUnitDeviceTqiScoreService analysisBatchUnitDeviceTqiScoreService;
@Resource
private IMovementAdditiveInfoUnitDeviceMapService movementAdditiveInfoUnitDeviceMapService;
public void analysis(String analysisBatchId) {
Map<String, Map<String, Object>> unitDeviceTable = new TreeMap<>();
Map<String, Map<String, Object>> unitDeviceTable = new LinkedHashMap<>();
// 1.1 获取分析基础数据
AnalysisBatch analysisBatch = analysisBatchService.getById(analysisBatchId);
List<AnalysisBatchCheckDataMap> analysisBatchCheckDataMapList = analysisBatchCheckDataMapService.lambdaQuery()
.eq(AnalysisBatchCheckDataMap::getAnalysisBatchId, analysisBatchId)
.list();
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(),
analysisBatch.getStartingMileage(),
analysisBatch.getEndMileage());
List<Map<String, Object>> unitDeviceList = analysisAlgorithmMapper.getUnitDevice(analysisBatch.getLightRailId(), analysisBatch.getLineAliasId(), analysisBatch.getStartingMileage(), analysisBatch.getEndMileage());
// 1.3 关联关系
......@@ -129,29 +129,17 @@ public class AnalysisAlgorithm {
if (ObjectUtil.isNotEmpty(unitDeviceTable)) {
// 删除超限
analysisBatchUnitDeviceTransfiniteService.lambdaUpdate()
.eq(AnalysisBatchUnitDeviceTransfinite::getAnalysisBatchId, analysisBatch.getId())
.remove();
analysisBatchUnitDeviceTransfiniteService.lambdaUpdate().eq(AnalysisBatchUnitDeviceTransfinite::getAnalysisBatchId, analysisBatch.getId()).remove();
// 删除得分
analysisBatchUnitDevicePointScoreService.lambdaUpdate()
.eq(AnalysisBatchUnitDevicePointScore::getAnalysisBatchId, analysisBatch.getId())
.remove();
analysisBatchUnitDevicePointScoreService.lambdaUpdate().eq(AnalysisBatchUnitDevicePointScore::getAnalysisBatchId, analysisBatch.getId()).remove();
// 删除分析关联设备id
analysisBatchUnitDeviceService.lambdaUpdate()
.eq(AnalysisBatchUnitDevice::getAnalysisBatchId, analysisBatchId)
.remove();
analysisBatchUnitDeviceService.lambdaUpdate().eq(AnalysisBatchUnitDevice::getAnalysisBatchId, analysisBatchId).remove();
// 删除轨检车tqi得分
analysisBatchUnitDeviceTqiScoreService.lambdaUpdate()
.eq(AnalysisBatchUnitDeviceTqiScore::getAnalysisBatchId, analysisBatch.getId())
.remove();
analysisBatchUnitDeviceTqiScoreService.lambdaUpdate().eq(AnalysisBatchUnitDeviceTqiScore::getAnalysisBatchId, analysisBatch.getId()).remove();
// 3.1 保存分析批次-单元设备
List<ConfigGradeLimit> configGradeLimitList = configGradeLimitService.lambdaQuery()
.eq(ConfigGradeLimit::getSpeedMax, analysisBatch.getSpeedMax())
.eq(ConfigGradeLimit::getSpeedMin, analysisBatch.getSpeedMin())
.eq(ConfigGradeLimit::getDelFlag, '0')
.list();
List<ConfigGradeLimit> configGradeLimitList = configGradeLimitService.lambdaQuery().eq(ConfigGradeLimit::getSpeedMax, analysisBatch.getSpeedMax()).eq(ConfigGradeLimit::getSpeedMin, analysisBatch.getSpeedMin()).eq(ConfigGradeLimit::getDelFlag, '0').list();
List<AnalysisBatchUnitDevice> analysisBatchUnitDevices = new ArrayList<>();
List<AnalysisBatchUnitDeviceTransfinite> transfiniteList = new ArrayList<>();
......@@ -217,6 +205,21 @@ public class AnalysisAlgorithm {
}
}
// 添乘仪得分
BigDecimal addInstrumentCheckScore = (BigDecimal) unitDevice.get("addInstrumentCheckScore");
if (null == addInstrumentCheckScore) {
analysisBatchUnitDevice.setAddDeviceCheck(0);
analysisBatchUnitDevice.setAddDeviceCheckScore(new BigDecimal("-1"));
} else {
analysisBatchUnitDevice.setAddDeviceCheck(1);
analysisBatchUnitDevice.setAddDeviceCheckScore(railVehicleCheckScore);
if (unitScore == null) {
unitScore = addInstrumentCheckScore;
} else {
unitScore = unitScore.add(addInstrumentCheckScore);
}
}
// 计算总分
Integer unitScoreLevel = null;
......@@ -224,7 +227,7 @@ public class AnalysisAlgorithm {
if (unitScore != null) {
for (ConfigGradeLimit configGradeLimit : configGradeLimitList) {
// 匹配单元设备类型
if (analysisBatchUnitDevice.getUnitType() == configGradeLimit.getDeviceType()) {
if (analysisBatchUnitDevice.getUnitType().equals(configGradeLimit.getDeviceType())) {
// 匹配等级
if (configGradeLimit.getGradeMin().compareTo(unitScore) <= 0 && configGradeLimit.getGradeMax().compareTo(unitScore) > 0) {
unitScoreLevel = configGradeLimit.getGradeLevel();
......@@ -236,7 +239,7 @@ public class AnalysisAlgorithm {
}
} else {
unitScore = new BigDecimal("-1");
unitScoreLevelStr = "暂无数据记录";
unitScoreLevelStr = "";
unitScoreLevel = 4;
}
// -1代表未评分
......@@ -342,6 +345,38 @@ public class AnalysisAlgorithm {
}
// 保存添乘仪检查数据超限
List<AnalysisBatchUnitDeviceTransfinite> addInstrumentTransfiniteList = (List<AnalysisBatchUnitDeviceTransfinite>) unitDevice.get("addInstrumentTransfiniteList");
if (ObjectUtil.isNotEmpty(addInstrumentTransfiniteList)) {
for (AnalysisBatchUnitDeviceTransfinite addInstrumentTransfinite : addInstrumentTransfiniteList) {
addInstrumentTransfinite.setAnalysisBatchUnitDeviceId(analysisBatchUnitDevice.getId());
addInstrumentTransfinite.setAnalysisBatchId(analysisBatchUnitDevice.getAnalysisBatchId());
addInstrumentTransfinite.setAnalysisBatchCode(analysisBatchUnitDevice.getAnalysisBatchCode());
addInstrumentTransfinite.setUnitId(analysisBatchUnitDevice.getUnitId());
addInstrumentTransfinite.setUnitCode(analysisBatchUnitDevice.getUnitCode());
addInstrumentTransfinite.setUnitType(analysisBatchUnitDevice.getUnitType());
addInstrumentTransfinite.setUnitTypeName(analysisBatchUnitDevice.getUnitTypeName());
transfiniteList.add(addInstrumentTransfinite);
}
}
// 保存添乘仪检查查数据计算得分
List<AnalysisBatchUnitDevicePointScore> addInstrumentCheckScoreList = (List<AnalysisBatchUnitDevicePointScore>) unitDevice.get("addInstrumentCheckScoreList");
if (ObjectUtil.isNotEmpty(addInstrumentCheckScoreList)) {
for (AnalysisBatchUnitDevicePointScore score : addInstrumentCheckScoreList) {
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());
scoreList.add(score);
}
}
}
analysisBatchUnitDeviceTqiScoreService.saveBatch(tqiScoreList);
analysisBatchUnitDeviceService.saveBatch(analysisBatchUnitDevices);
......@@ -349,9 +384,7 @@ public class AnalysisAlgorithm {
analysisBatchUnitDevicePointScoreService.saveBatch(scoreList);
}
// 分析完成
analysisBatchService.lambdaUpdate().set(AnalysisBatch::getAnalysisStatus, 99)
.eq(AnalysisBatch::getId, analysisBatchId)
.update();
analysisBatchService.lambdaUpdate().set(AnalysisBatch::getAnalysisStatus, 99).eq(AnalysisBatch::getId, analysisBatchId).update();
log.info("[分析完成]|线程id:【" + Thread.currentThread().getId() + "】=============分析批次ID:【" + analysisBatchId + "】");
}
......@@ -360,68 +393,317 @@ public class AnalysisAlgorithm {
*/
private void addInstrumentAnalysis(AnalysisBatch analysisBatch, AnalysisBatchCheckDataMap checkDataMap, List<Map<String, Object>> unitDeviceList) {
// 1.添乘仪查数据相关数据
// 1.1 获取缺陷报告
List<MovementOverReport> movementOverReports = movementOverReportService.lambdaQuery()
.eq(MovementOverReport::getMovementMasterId, checkDataMap.getEkId())
.ge(MovementOverReport::getMileage, analysisBatch.getStartingMileage())
.le(MovementOverReport::getMileage, analysisBatch.getEndMileage())
.orderByAsc(MovementOverReport::getMileage)
// 缩小1000倍
BigDecimal analysisStartingMileage = analysisBatch.getStartingMileage()
.divide(new BigDecimal("1000"), 3, BigDecimal.ROUND_HALF_UP);
BigDecimal analysisEndMileage = analysisBatch.getEndMileage()
.divide(new BigDecimal("1000"), 3, BigDecimal.ROUND_HALF_UP);
// 1.1 添乘仪查数据相关数据
List<MovementAdditiveInfo> additiveInfos = movementAdditiveInfoService.lambdaQuery()
.eq(MovementAdditiveInfo::getMovementMasterId, checkDataMap.getEkId())
.ge(MovementAdditiveInfo::getPointMileage, analysisStartingMileage)
.le(MovementAdditiveInfo::getPointMileage, analysisEndMileage)
.orderByAsc(MovementAdditiveInfo::getPointMileage)
.list();
Map<BigDecimal, List<MovementOverReport>> movementOverReportMap = new HashMap<>();
for (MovementOverReport movementOverReport : movementOverReports) {
List<MovementOverReport> list = movementOverReportMap.get(movementOverReport.getMileage());
if (ObjectUtil.isEmpty(list)) {
list = new ArrayList<>();
movementOverReportMap.put(movementOverReport.getMileage(), list);
}
list.add(movementOverReport);
}
// 1.2 获添乘仪检查超限权值
ConfigInstrumentCheck configInstrumentCheck = configInstrumentCheckService.lambdaQuery()
.eq(ConfigInstrumentCheck::getSpeedMax, analysisBatch.getSpeedMax())
.eq(ConfigInstrumentCheck::getSpeedMin, analysisBatch.getSpeedMin())
.eq(ConfigInstrumentCheck::getDelFlag, "0")
.last("limit 1")
.one();
// 1-钢轨,2-曲线,3-竖曲线,4-道岔
JSONObject railWeightValueJsonObject = JSONObject.parseObject(configInstrumentCheck.getRail());
JSONObject curveWeightValueJsonObject = JSONObject.parseObject(configInstrumentCheck.getCurve());
JSONObject verticalCurveWeightValueJsonObject = JSONObject.parseObject(configInstrumentCheck.getVerticalCurve());
JSONObject switchWeightValueJsonObject = JSONObject.parseObject(configInstrumentCheck.getRailSwitch());
// 1.2 获取tqi数据
List<MovementTqiReport> tqiReports = movementTqiReportService.lambdaQuery()
.eq(MovementTqiReport::getMovementMasterId, checkDataMap.getEkId())
.ge(MovementTqiReport::getStartMileage, analysisBatch.getStartingMileage())
.le(MovementTqiReport::getEndMileage, analysisBatch.getEndMileage())
.orderByAsc(MovementTqiReport::getStartMileage)
.list();
// 1.3 获取是否派工配置
// 轨检车动态检查数据-1级超限
Integer isWorkRailVehicleOver1 = 1;
String reasonLabelRailVehicleOver1 = "";
Integer isWorkAddInstrumentOver1 = 1;
String reasonLabelAddInstrumentOver1 = "";
// 轨检车动态检查数据-2级超限
Integer isWorkRailVehicleOver2 = 1;
String reasonLabelRailVehicleOver2 = "";
Integer isWorkAddInstrumentOver2 = 1;
String reasonLabelAddInstrumentOver2 = "";
// 轨检车动态检查数据-3级超限
Integer isWorkRailVehicleOver3 = 1;
String reasonLabelRailVehicleOver3 = "";
Integer isWorkAddInstrumentOver3 = 1;
String reasonLabelAddInstrumentOver3 = "";
// 轨检车动态检查数据-4级超限
Integer isWorkRailVehicleOver4 = 1;
String reasonLabelRailVehicleOver4 = "";
Integer isWorkAddInstrumentOver4 = 1;
String reasonLabelAddInstrumentOver4 = "";
JSONArray dispatchingList = JSONArray.parseArray(analysisBatch.getDispatching());
for (Object obj : dispatchingList) {
JSONObject dispatching = (JSONObject) obj;
String reasonValue = String.valueOf(dispatching.get("reasonValue"));
String reasonLabel = String.valueOf(dispatching.get("reasonLabel"));
if ("add_instrument_1".equals(reasonValue)) {
Boolean isWorkTemp = Boolean.valueOf(dispatching.get("isWork").toString());
if (isWorkTemp) {
isWorkAddInstrumentOver1 = 1;
reasonLabelAddInstrumentOver1 = reasonLabel;
} else {
isWorkAddInstrumentOver1 = 0;
}
}
if ("add_instrument_2".equals(reasonValue)) {
Boolean isWorkTemp = Boolean.valueOf(dispatching.get("isWork").toString());
if (isWorkTemp) {
isWorkAddInstrumentOver2 = 2;
reasonLabelAddInstrumentOver2 = reasonLabel;
} else {
isWorkAddInstrumentOver2 = 0;
}
}
if ("add_instrument_3".equals(reasonValue)) {
Boolean isWorkTemp = Boolean.valueOf(dispatching.get("isWork").toString());
if (isWorkTemp) {
isWorkAddInstrumentOver3 = 3;
reasonLabelAddInstrumentOver3 = reasonLabel;
} else {
isWorkAddInstrumentOver3 = 0;
}
}
if ("add_instrument_4".equals(reasonValue)) {
Boolean isWorkTemp = Boolean.valueOf(dispatching.get("isWork").toString());
if (isWorkTemp) {
isWorkAddInstrumentOver4 = 4;
reasonLabelAddInstrumentOver4 = reasonLabel;
} else {
isWorkAddInstrumentOver4 = 0;
}
}
}
// 2.循环遍历单元设备中心里程落在检查项目【开始-结束】这个区间视为这个区间的单元设备
List<MovementAdditiveInfoUnitDeviceMap> additiveInfoUnitMaps = new ArrayList<>();
int analysisType = analysisBatch.getAnalysisType();
for (Map<String, Object> unitDevice : unitDeviceList) {
// 1-钢轨,2-曲线,3-竖曲线,4-道岔
Integer type = Convert.toInt(unitDevice.get("type"));
JSONObject weightValuesjsonObject = null;
if (type == 1) {
weightValuesjsonObject = railWeightValueJsonObject;
} else if (type == 2) {
weightValuesjsonObject = curveWeightValueJsonObject;
} else if (type == 3) {
weightValuesjsonObject = verticalCurveWeightValueJsonObject;
} else if (type == 4) {
weightValuesjsonObject = switchWeightValueJsonObject;
}
// 垂直加速度权值
BigDecimal verticalSpendWeightValue = weightValuesjsonObject.getBigDecimal("verticalSpend");
// 水平加速度权值
BigDecimal transverseSpendWeightValue = weightValuesjsonObject.getBigDecimal("transverseSpend");
BigDecimal startMileage = Convert.toBigDecimal(unitDevice.get("startMileage"));
BigDecimal endMileage = Convert.toBigDecimal(unitDevice.get("endMileage"));
List<MovementAdditiveInfo> currentUnitDeviceAdditiveList = new ArrayList<>();
List<AnalysisBatchUnitDeviceTransfinite> addInstrumentTransfiniteList = new ArrayList<>();
Iterator<MovementAdditiveInfo> iterator = additiveInfos.iterator();
while (iterator.hasNext()) {
MovementAdditiveInfo additiveInfo = iterator.next();
BigDecimal pointMileage = additiveInfo.getPointMileage().multiply(new BigDecimal("1000"));
if (startMileage.compareTo(pointMileage) <= 0 && endMileage.compareTo(pointMileage) > 0) {
// 记录映射关系
MovementAdditiveInfoUnitDeviceMap additiveInfoUnitMap = new MovementAdditiveInfoUnitDeviceMap();
additiveInfoUnitMap.setId(UUIDGenerator.generate());
additiveInfoUnitMap.setMovementMasterId(checkDataMap.getEkId());
additiveInfoUnitMap.setUnitId(Convert.toStr(unitDevice.get("id")));
additiveInfoUnitMap.setUnitCode(Convert.toStr(unitDevice.get("unitCode")));
additiveInfoUnitMap.setUnitDeviceCode(Convert.toStr(unitDevice.get("deviceCode")));
additiveInfoUnitMap.setUnitType(Convert.toInt(unitDevice.get("type")));
additiveInfoUnitMap.setUnitTypeName(Convert.toStr(unitDevice.get("typeName")));
additiveInfoUnitMap.setUnitStartMileage(Convert.toBigDecimal(unitDevice.get("startMileage")));
additiveInfoUnitMap.setUnitCenterMileage(Convert.toBigDecimal(unitDevice.get("centerMileage")));
additiveInfoUnitMap.setUnitEndMileage(Convert.toBigDecimal(unitDevice.get("endMileage")));
additiveInfoUnitMap.setPointMileage(pointMileage);
additiveInfoUnitMap.setZontalSpeed(additiveInfo.getZontalSpeed());
additiveInfoUnitMap.setZontalSpeedLevel(additiveInfo.getZontalSpeedLevel());
additiveInfoUnitMap.setVerticalSpeed(additiveInfo.getVerticalSpeed());
additiveInfoUnitMap.setVerticalSpeedLevel(additiveInfo.getVerticalSpeedLevel());
additiveInfoUnitMap.setSpeed(additiveInfo.getSpeed());
additiveInfoUnitMap.setMark(additiveInfo.getMark());
additiveInfoUnitMaps.add(additiveInfoUnitMap);
// 水平超限
if (additiveInfo.getZontalSpeedLevel() != null) {
AnalysisBatchUnitDeviceTransfinite zontalSpeedTransfinite = new AnalysisBatchUnitDeviceTransfinite();
zontalSpeedTransfinite.setId(UUIDGenerator.generate());
zontalSpeedTransfinite.setTransfiniteGrade(additiveInfo.getZontalSpeedLevel());
zontalSpeedTransfinite.setTransfiniteType("水平超限");
if (1 == additiveInfo.getZontalSpeedLevel()) {
zontalSpeedTransfinite.setTransfiniteGradeName(reasonLabelAddInstrumentOver1);
zontalSpeedTransfinite.setIsWork(isWorkAddInstrumentOver1);
} else if (2 == additiveInfo.getZontalSpeedLevel()) {
zontalSpeedTransfinite.setTransfiniteGradeName(reasonLabelAddInstrumentOver2);
zontalSpeedTransfinite.setIsWork(isWorkAddInstrumentOver2);
} else if (3 == additiveInfo.getZontalSpeedLevel()) {
zontalSpeedTransfinite.setTransfiniteGradeName(reasonLabelAddInstrumentOver3);
zontalSpeedTransfinite.setIsWork(isWorkAddInstrumentOver3);
} else {
zontalSpeedTransfinite.setTransfiniteGradeName(reasonLabelAddInstrumentOver4);
zontalSpeedTransfinite.setIsWork(isWorkAddInstrumentOver4);
}
// String allowValue = Convert.toBigDecimal(movementOverReport.getPeakValue()).subtract(Convert.toBigDecimal(movementOverReport.getDataDifference())).toString();
// zontalSpeedTransfinite.setAllowValue();
zontalSpeedTransfinite.setMeasurePointValue(additiveInfo.getVerticalSpeed().toString());
addInstrumentTransfiniteList.add(zontalSpeedTransfinite);
}
// 垂直超限
if (additiveInfo.getVerticalSpeedLevel() != null) {
AnalysisBatchUnitDeviceTransfinite verticalSpeedTransfinite = new AnalysisBatchUnitDeviceTransfinite();
verticalSpeedTransfinite.setId(UUIDGenerator.generate());
verticalSpeedTransfinite.setTransfiniteGrade(additiveInfo.getVerticalSpeedLevel());
verticalSpeedTransfinite.setTransfiniteType("垂直超限");
if (1 == additiveInfo.getVerticalSpeedLevel()) {
verticalSpeedTransfinite.setTransfiniteGradeName(reasonLabelAddInstrumentOver1);
verticalSpeedTransfinite.setIsWork(isWorkAddInstrumentOver1);
} else if (2 == additiveInfo.getVerticalSpeedLevel()) {
verticalSpeedTransfinite.setTransfiniteGradeName(reasonLabelAddInstrumentOver2);
verticalSpeedTransfinite.setIsWork(isWorkAddInstrumentOver2);
} else if (3 == additiveInfo.getVerticalSpeedLevel()) {
verticalSpeedTransfinite.setTransfiniteGradeName(reasonLabelAddInstrumentOver3);
verticalSpeedTransfinite.setIsWork(isWorkAddInstrumentOver3);
} else {
verticalSpeedTransfinite.setTransfiniteGradeName(reasonLabelAddInstrumentOver4);
verticalSpeedTransfinite.setIsWork(isWorkAddInstrumentOver4);
}
// String allowValue = Convert.toBigDecimal(movementOverReport.getPeakValue()).subtract(Convert.toBigDecimal(movementOverReport.getDataDifference())).toString();
// zontalSpeedTransfinite.setAllowValue();
verticalSpeedTransfinite.setMeasurePointValue(additiveInfo.getVerticalSpeed().toString());
addInstrumentTransfiniteList.add(verticalSpeedTransfinite);
}
currentUnitDeviceAdditiveList.add(additiveInfo);
// 在集合中删除这个对象
iterator.remove();
}
}
unitDevice.put("addInstrumentTransfiniteList", addInstrumentTransfiniteList);
// 计算得分
BigDecimal sumUnitScore = null;
BigDecimal finalZontalSpeed = null;
BigDecimal sumZontalSpeed = BigDecimal.ZERO;
int zontalSpeedSize = 1;
BigDecimal finalVerticalSpeed = null;
BigDecimal sumVerticalSpeed = BigDecimal.ZERO;
int verticalSpeedSize = 1;
List<AnalysisBatchUnitDevicePointScore> scoreList = new ArrayList<>();
for (MovementAdditiveInfo movementAdditiveInfo : currentUnitDeviceAdditiveList) {
// 计算水平得分
BigDecimal zontalSpeed = movementAdditiveInfo.getZontalSpeed().abs();
if (1 == analysisType) {// 均值
sumZontalSpeed = sumZontalSpeed.add(zontalSpeed);
zontalSpeedSize++;
finalZontalSpeed = sumZontalSpeed.divide(new BigDecimal(zontalSpeedSize), 3, BigDecimal.ROUND_HALF_UP);
} else { // 峰值
if (null == finalZontalSpeed || finalZontalSpeed.compareTo(zontalSpeed) < 0) {
finalZontalSpeed = zontalSpeed;
}
}
// 计算垂直得分
BigDecimal verticalSpeed = movementAdditiveInfo.getVerticalSpeed().abs();
if (1 == analysisType) {// 均值
sumVerticalSpeed = sumVerticalSpeed.add(verticalSpeed);
verticalSpeedSize++;
finalVerticalSpeed = sumVerticalSpeed.divide(new BigDecimal(verticalSpeedSize), 3, BigDecimal.ROUND_HALF_UP);
} else { // 峰值
if (null == finalVerticalSpeed || finalVerticalSpeed.compareTo(verticalSpeed) < 0) {
finalVerticalSpeed = verticalSpeed;
}
}
}
if (null != finalZontalSpeed) {
BigDecimal zontalSpeedScore = finalZontalSpeed.multiply(transverseSpendWeightValue);
if (sumUnitScore == null) {
sumUnitScore = zontalSpeedScore;
} else {
sumUnitScore = sumUnitScore.add(zontalSpeedScore);
}
AnalysisBatchUnitDevicePointScore zontalSpeedPointScore = new AnalysisBatchUnitDevicePointScore();
zontalSpeedPointScore.setId(UUIDGenerator.generate());
zontalSpeedPointScore.setAnalysisType(analysisType);
zontalSpeedPointScore.setSpeedMax(analysisBatch.getSpeedMax());
zontalSpeedPointScore.setSpeedMin(analysisBatch.getSpeedMin());
zontalSpeedPointScore.setAnalysisBatchId(analysisBatch.getId());
zontalSpeedPointScore.setAnalysisBatchCode(analysisBatch.getAnalysisBatchCode());
zontalSpeedPointScore.setPointTypeName("水平");
zontalSpeedPointScore.setCheckType(4);
zontalSpeedPointScore.setPointValue(finalZontalSpeed);
zontalSpeedPointScore.setWeightValues(transverseSpendWeightValue);
zontalSpeedPointScore.setPointScore(zontalSpeedScore);
scoreList.add(zontalSpeedPointScore);
}
if (null != finalVerticalSpeed) {
BigDecimal verticalSpeedScore = finalVerticalSpeed.multiply(verticalSpendWeightValue);
if (sumUnitScore == null) {
sumUnitScore = verticalSpeedScore;
} else {
sumUnitScore = sumUnitScore.add(verticalSpeedScore);
}
AnalysisBatchUnitDevicePointScore verticalSpeedPointScore = new AnalysisBatchUnitDevicePointScore();
verticalSpeedPointScore.setId(UUIDGenerator.generate());
verticalSpeedPointScore.setAnalysisType(analysisType);
verticalSpeedPointScore.setSpeedMax(analysisBatch.getSpeedMax());
verticalSpeedPointScore.setSpeedMin(analysisBatch.getSpeedMin());
verticalSpeedPointScore.setAnalysisBatchId(analysisBatch.getId());
verticalSpeedPointScore.setAnalysisBatchCode(analysisBatch.getAnalysisBatchCode());
verticalSpeedPointScore.setPointTypeName("垂直");
verticalSpeedPointScore.setCheckType(4);
verticalSpeedPointScore.setPointValue(finalVerticalSpeed);
verticalSpeedPointScore.setWeightValues(transverseSpendWeightValue);
verticalSpeedPointScore.setPointScore(verticalSpeedScore);
scoreList.add(verticalSpeedPointScore);
}
unitDevice.put("addInstrumentCheckScore", sumUnitScore);
unitDevice.put("addInstrumentCheckScoreList", scoreList);
}
if (ObjectUtil.isNotEmpty(additiveInfoUnitMaps)) {
movementAdditiveInfoUnitDeviceMapService.lambdaUpdate()
.eq(MovementAdditiveInfoUnitDeviceMap::getMovementMasterId, checkDataMap.getEkId())
.remove();
movementAdditiveInfoUnitDeviceMapService.saveBatch(additiveInfoUnitMaps);
}
}
/**
* 轨检车检查数据解析
*/
private void railVehicleCheckDataAnalysis(AnalysisBatch analysisBatch,
AnalysisBatchCheckDataMap checkDataMap,
List<Map<String, Object>> unitDeviceList) {
private void railVehicleCheckDataAnalysis(AnalysisBatch analysisBatch, AnalysisBatchCheckDataMap checkDataMap, List<Map<String, Object>> unitDeviceList) {
// 1.获取轨检车相关数据
// 1.1 获取缺陷报告
List<MovementOverReport> movementOverReports = movementOverReportService.lambdaQuery()
.eq(MovementOverReport::getMovementMasterId, checkDataMap.getEkId())
.ge(MovementOverReport::getMileage, analysisBatch.getStartingMileage())
.le(MovementOverReport::getMileage, analysisBatch.getEndMileage())
.orderByAsc(MovementOverReport::getMileage)
.list();
List<MovementOverReport> movementOverReports = movementOverReportService.lambdaQuery().eq(MovementOverReport::getMovementMasterId, checkDataMap.getEkId()).ge(MovementOverReport::getMileage, analysisBatch.getStartingMileage()).le(MovementOverReport::getMileage, analysisBatch.getEndMileage()).orderByAsc(MovementOverReport::getMileage).list();
Map<BigDecimal, List<MovementOverReport>> movementOverReportMap = new HashMap<>();
for (MovementOverReport movementOverReport : movementOverReports) {
......@@ -435,12 +717,7 @@ public class AnalysisAlgorithm {
// 1.2 获取tqi数据
List<MovementTqiReport> tqiReports = movementTqiReportService.lambdaQuery()
.eq(MovementTqiReport::getMovementMasterId, checkDataMap.getEkId())
.ge(MovementTqiReport::getStartMileage, analysisBatch.getStartingMileage())
.le(MovementTqiReport::getEndMileage, analysisBatch.getEndMileage())
.orderByAsc(MovementTqiReport::getStartMileage)
.list();
List<MovementTqiReport> tqiReports = movementTqiReportService.lambdaQuery().eq(MovementTqiReport::getMovementMasterId, checkDataMap.getEkId()).ge(MovementTqiReport::getStartMileage, analysisBatch.getStartingMileage()).le(MovementTqiReport::getEndMileage, analysisBatch.getEndMileage()).orderByAsc(MovementTqiReport::getStartMileage).list();
// 1.3 获取是否派工配置
......@@ -506,12 +783,7 @@ public class AnalysisAlgorithm {
// 1.4 获取轨检车检查超限权值
ConfigRailVehicleCheck configRailVehicle = configRailVehicleCheckService.lambdaQuery()
.eq(ConfigRailVehicleCheck::getSpeedMax, analysisBatch.getSpeedMax())
.eq(ConfigRailVehicleCheck::getSpeedMin, analysisBatch.getSpeedMin())
.eq(ConfigRailVehicleCheck::getDelFlag, "0")
.last("limit 1")
.one();
ConfigRailVehicleCheck configRailVehicle = configRailVehicleCheckService.lambdaQuery().eq(ConfigRailVehicleCheck::getSpeedMax, analysisBatch.getSpeedMax()).eq(ConfigRailVehicleCheck::getSpeedMin, analysisBatch.getSpeedMin()).eq(ConfigRailVehicleCheck::getDelFlag, "0").last("limit 1").one();
// 1-钢轨,2-曲线,3-竖曲线,4-道岔
JSONObject railWeightValueJsonObject = JSONObject.parseObject(configRailVehicle.getRail());
JSONObject curveWeightValueJsonObject = JSONObject.parseObject(configRailVehicle.getCurve());
......@@ -520,12 +792,7 @@ public class AnalysisAlgorithm {
// 1.5 获取轨检车TQI超限权值
ConfigRailVehicleTqi configRailVehicleTqi = configRailVehicleTqlService.lambdaQuery()
.eq(ConfigRailVehicleTqi::getSpeedMax, analysisBatch.getSpeedMax())
.eq(ConfigRailVehicleTqi::getSpeedMin, analysisBatch.getSpeedMin())
.eq(ConfigRailVehicleTqi::getDelFlag, "0")
.last("limit 1")
.one();
ConfigRailVehicleTqi configRailVehicleTqi = configRailVehicleTqlService.lambdaQuery().eq(ConfigRailVehicleTqi::getSpeedMax, analysisBatch.getSpeedMax()).eq(ConfigRailVehicleTqi::getSpeedMin, analysisBatch.getSpeedMin()).eq(ConfigRailVehicleTqi::getDelFlag, "0").last("limit 1").one();
// 1-钢轨,2-曲线,3-竖曲线,4-道岔
JSONObject railTqiJsonObject = JSONObject.parseObject(configRailVehicleTqi.getRail());
......@@ -679,27 +946,27 @@ public class AnalysisAlgorithm {
// 计算轨距得分
Double finalTrackGauge = Math.abs(Convert.toDouble(tqiReport.getTrackGauge()));
BigDecimal finalTrackGauge = Convert.toBigDecimal(tqiReport.getTrackGauge()).abs();
if (ObjectUtil.isNotEmpty(railVehicleTransfiniteList)) {
int trackGaugeSize = 1;
double sumTrackGauge = finalTrackGauge;
BigDecimal sumTrackGauge = finalTrackGauge;
for (AnalysisBatchUnitDeviceTransfinite record : railVehicleTransfiniteList) {
if ("轨距".equals(record.getTransfiniteType())) {
Double trackGauge = Math.abs(Convert.toDouble(record.getMeasurePointValue()));
BigDecimal trackGauge = Convert.toBigDecimal(record.getMeasurePointValue()).abs();
if (1 == analysisType) { // 均值
sumTrackGauge = sumTrackGauge + trackGauge;
sumTrackGauge = sumTrackGauge.add(trackGauge);
trackGaugeSize++;
finalTrackGauge = sumTrackGauge / trackGaugeSize;
finalTrackGauge = sumTrackGauge.divide(new BigDecimal(trackGaugeSize), 3, BigDecimal.ROUND_HALF_UP);
} else { // 峰值
if (finalTrackGauge < trackGauge) {
if (finalTrackGauge.compareTo(trackGauge) < 0) {
finalTrackGauge = trackGauge;
}
}
}
}
}
BigDecimal trackGaugeUnitScore = trackGaugeWeightValues.multiply(new BigDecimal(finalTrackGauge));
BigDecimal trackGaugeUnitScore = trackGaugeWeightValues.multiply(finalTrackGauge);
sumUnitScore = sumUnitScore.add(trackGaugeUnitScore);
AnalysisBatchUnitDevicePointScore trackGaugePointScore = new AnalysisBatchUnitDevicePointScore();
......@@ -718,20 +985,20 @@ public class AnalysisAlgorithm {
// 计算水平得分
Double finalLevel = Convert.toDouble(tqiReport.getLevel());
BigDecimal finalLevel = Convert.toBigDecimal(tqiReport.getLevel()).abs();
if (ObjectUtil.isNotEmpty(railVehicleTransfiniteList)) {
int levelSize = 1;
double sumLevel = finalLevel;
BigDecimal sumLevel = finalLevel;
for (AnalysisBatchUnitDeviceTransfinite record : railVehicleTransfiniteList) {
if (record.getTransfiniteType().contains("水平")) {
Double level = Math.abs(Convert.toDouble(record.getMeasurePointValue()));
BigDecimal level = Convert.toBigDecimal(record.getMeasurePointValue()).abs();
if (1 == analysisType) { // 均值
sumLevel = sumLevel + level;
sumLevel = sumLevel.add(level);
levelSize++;
finalLevel = sumLevel / levelSize;
finalLevel = sumLevel.divide(new BigDecimal(levelSize), 3, BigDecimal.ROUND_HALF_UP);
} else { // 峰值
if (finalLevel < level) {
if (finalLevel.compareTo(level) < 0) {
finalLevel = level;
}
}
......@@ -739,7 +1006,7 @@ public class AnalysisAlgorithm {
}
}
BigDecimal levelUnitScore = levelWeightValues.multiply(new BigDecimal(finalLevel));
BigDecimal levelUnitScore = levelWeightValues.multiply(finalLevel);
sumUnitScore = sumUnitScore.add(levelUnitScore);
......@@ -759,27 +1026,27 @@ public class AnalysisAlgorithm {
// 计算三角坑得分
Double finalTriangularPit = Math.abs(Convert.toDouble(tqiReport.getLevel()));
BigDecimal finalTriangularPit = Convert.toBigDecimal(tqiReport.getLevel()).abs();
if (ObjectUtil.isNotEmpty(railVehicleTransfiniteList)) {
int triangularPitSize = 1;
double sumTriangularPit = finalTriangularPit;
BigDecimal sumTriangularPit = finalTriangularPit;
for (AnalysisBatchUnitDeviceTransfinite record : railVehicleTransfiniteList) {
if (record.getTransfiniteType().contains("三角坑")) {
Double level = Math.abs(Convert.toDouble(record.getMeasurePointValue()));
BigDecimal level = Convert.toBigDecimal(record.getMeasurePointValue()).abs();
if (1 == analysisBatch.getAnalysisType()) { // 均值
sumTriangularPit = sumTriangularPit + level;
sumTriangularPit = sumTriangularPit.add(level);
triangularPitSize++;
finalTriangularPit = sumTriangularPit / triangularPitSize;
finalTriangularPit = sumTriangularPit.divide(new BigDecimal(triangularPitSize), 3, BigDecimal.ROUND_HALF_UP);
} else { // 峰值
if (finalTriangularPit < level) {
if (finalTriangularPit.compareTo(level) < 0) {
finalTriangularPit = level;
}
}
}
}
}
BigDecimal triangularPitUnitScore = triangularPitWeightValues.multiply(new BigDecimal(finalTriangularPit));
BigDecimal triangularPitUnitScore = triangularPitWeightValues.multiply(finalTriangularPit);
sumUnitScore = sumUnitScore.add(triangularPitUnitScore);
......@@ -799,29 +1066,31 @@ public class AnalysisAlgorithm {
// 计算高低得分
Double finalHeight = null;
BigDecimal finalHeight = null;
BigDecimal finalHeightLowLeft = Convert.toBigDecimal(tqiReport.getHighLowLeft()).abs();
BigDecimal finalHeightLowRight = Convert.toBigDecimal(tqiReport.getHighLowRight()).abs();
if (1 == analysisBatch.getAnalysisType()) {
finalHeight = (Math.abs(Convert.toDouble(tqiReport.getHighLowLeft())) + Math.abs(Convert.toDouble(tqiReport.getHighLowRight()))) / 2;
finalHeight = finalHeightLowLeft.add(finalHeightLowRight).divide(new BigDecimal("2"), 3, BigDecimal.ROUND_HALF_UP);
} else {
if (Convert.toDouble(tqiReport.getHighLowLeft()) > Convert.toDouble(tqiReport.getHighLowRight())) {
finalHeight = Math.abs(Convert.toDouble(tqiReport.getHighLowLeft()));
if (finalHeightLowLeft.compareTo(finalHeightLowRight) > 0) {
finalHeight = finalHeightLowLeft;
} else {
finalHeight = Math.abs(Convert.toDouble(tqiReport.getHighLowRight()));
finalHeight = finalHeightLowRight;
}
}
if (ObjectUtil.isNotEmpty(railVehicleTransfiniteList)) {
int heightSize = 1;
double sumHeight = finalHeight;
BigDecimal sumHeight = finalHeight;
for (AnalysisBatchUnitDeviceTransfinite record : railVehicleTransfiniteList) {
if (record.getTransfiniteType().contains("高低")) {
Double level = Math.abs(Convert.toDouble(record.getMeasurePointValue()));
BigDecimal level = Convert.toBigDecimal(record.getMeasurePointValue()).abs();
if (1 == analysisBatch.getAnalysisType()) { // 均值
sumHeight = sumHeight + level;
sumHeight = sumHeight.add(level);
heightSize++;
finalHeight = sumHeight / heightSize;
finalHeight = sumHeight.divide(new BigDecimal(heightSize), 3, BigDecimal.ROUND_HALF_UP);
} else { // 峰值
if (finalHeight < level) {
if (finalHeight.compareTo(level) < 0) {
finalHeight = level;
}
}
......@@ -829,7 +1098,7 @@ public class AnalysisAlgorithm {
}
}
BigDecimal heightUnitScore = heightWeightValues.multiply(new BigDecimal(finalHeight));
BigDecimal heightUnitScore = heightWeightValues.multiply(finalHeight);
sumUnitScore = sumUnitScore.add(heightUnitScore);
......@@ -849,36 +1118,38 @@ public class AnalysisAlgorithm {
// 计算轨向得分
Double finalDirection = null;
BigDecimal finalDirection = null;
BigDecimal finalDirectionLeft = Convert.toBigDecimal(tqiReport.getTrackLeft()).abs();
BigDecimal finalDirectionRight = Convert.toBigDecimal(tqiReport.getTrackRight()).abs();
if (1 == analysisType) {
finalDirection = (Math.abs(Convert.toDouble(tqiReport.getTrackRight())) + Math.abs(Convert.toDouble(tqiReport.getTrackLeft()))) / 2;
finalDirection = finalDirectionLeft.add(finalDirectionRight).divide(new BigDecimal("2"), 3, BigDecimal.ROUND_HALF_UP);
} else {
if (Convert.toDouble(tqiReport.getTrackRight()) > Convert.toDouble(tqiReport.getTrackLeft())) {
finalDirection = Math.abs(Convert.toDouble(tqiReport.getTrackRight()));
if (finalDirectionLeft.compareTo(finalDirectionRight) > 0) {
finalDirection = finalDirectionLeft;
} else {
finalDirection = Math.abs(Convert.toDouble(tqiReport.getTrackLeft()));
finalDirection = finalDirectionRight;
}
}
if (ObjectUtil.isNotEmpty(railVehicleTransfiniteList)) {
int heightSize = 1;
double sumDirection = finalDirection;
BigDecimal sumDirection = finalDirection;
for (AnalysisBatchUnitDeviceTransfinite record : railVehicleTransfiniteList) {
if (record.getTransfiniteType().contains("高低")) {
Double level = Math.abs(Convert.toDouble(record.getMeasurePointValue()));
if (record.getTransfiniteType().contains("轨向")) {
BigDecimal level = Convert.toBigDecimal(record.getMeasurePointValue()).abs();
if (1 == analysisType) { // 均值
sumDirection = sumDirection + level;
sumDirection = sumDirection.add(level);
heightSize++;
finalDirection = sumDirection / heightSize;
finalDirection = sumDirection.divide(new BigDecimal(heightSize), 3, BigDecimal.ROUND_HALF_UP);
} else { // 峰值
if (finalDirection < level) {
if (finalDirection.compareTo(level) < 0) {
finalDirection = level;
}
}
}
}
}
BigDecimal directionUnitScore = directionWeightValues.multiply(new BigDecimal(finalDirection));
BigDecimal directionUnitScore = directionWeightValues.multiply(finalDirection);
sumUnitScore = sumUnitScore.add(directionUnitScore);
......@@ -932,13 +1203,7 @@ public class AnalysisAlgorithm {
BigDecimal tqiComeUpon = Convert.toBigDecimal(tqiReport.getTqiComeUpon());
BigDecimal tqiComeUponScore = tqiComeUpon.multiply(tqiComeUponTqi);
BigDecimal sumScore = highLowLeftScore.add(highLowRightScore)
.add(trackLeftScore)
.add(trackRightScore)
.add(levelScore)
.add(trackGaugeScore)
.add(triangularPitScore)
.add(tqiComeUponScore);
BigDecimal sumScore = highLowLeftScore.add(highLowRightScore).add(trackLeftScore).add(trackRightScore).add(levelScore).add(trackGaugeScore).add(triangularPitScore).add(tqiComeUponScore);
AnalysisBatchUnitDeviceTqiScore tqiScore = new AnalysisBatchUnitDeviceTqiScore();
tqiScore.setId(UUIDGenerator.generate());
......@@ -985,12 +1250,15 @@ public class AnalysisAlgorithm {
tqiScore.setSumScore(sumScore);
unitDevice.put("railVehicleTqiScore", tqiScore);
// 判断tqi指标是否派工
break;
}
}
System.out.println(Convert.toStr(unitDevice.get("unitCode")) + "=" + sumUnitScore);
unitDevice.put("railVehicleCheckScore", sumUnitScore);
unitDevice.put("railVehicleCheckScoreList", scoreList);
......@@ -1011,27 +1279,24 @@ public class AnalysisAlgorithm {
/**
* 轨检仪检查数据分析
*/
private void railDeviceCheckDataAnalysis(AnalysisBatch analysisBatch,
AnalysisBatchCheckDataMap checkDataMap,
List<Map<String, Object>> unitDeviceList) {
private void railDeviceCheckDataAnalysis(AnalysisBatch analysisBatch, AnalysisBatchCheckDataMap checkDataMap, List<Map<String, Object>> unitDeviceList) {
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));
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.循环单元设备根据单元设备的中心里程落在检查项目【开始-结束】这个区间视为这个区间的单元设备第第一个就行了
for (Map<String, Object> unitDevice : unitDeviceList) {
BigDecimal centerMileage = Convert.toBigDecimal(unitDevice.get("centerMileage"));
// 2.1 这里可能出现开始时间比结束时间大的情况,轨检仪数据还要乘1000
// 2.1 循环遍历检查项目比较【开始-结束】来映射关联关系
for (RailInspectionEquipmentItem checkItem : checkItemList) {
// 1.2 处理检查项目是公里的情况
BigDecimal checkItemStartingMileage = checkItem.getCourseStartingMileage().multiply(new BigDecimal("1000"));
checkItem.setCourseStartingMileage(checkItemStartingMileage);
BigDecimal checkItemEndMileage = checkItem.getCourseEndMileage().multiply(new BigDecimal("1000"));
......@@ -1041,27 +1306,16 @@ public class AnalysisAlgorithm {
checkItemEndMileage = checkItem.getCourseStartingMileage();
}
// 2.2 单元设备中心里程落在检查项目【开始-结束】这个区间视为这个区间的单元设备
for (Map<String, Object> unitDevice : unitDeviceList) {
BigDecimal centerMileage = Convert.toBigDecimal(unitDevice.get("centerMileage"));
// 2.2.1 命中检查项目
if (checkItemStartingMileage.compareTo(centerMileage) <= 0 && checkItemEndMileage.compareTo(centerMileage) > 0) {
List<RailInspectionEquipmentItemDetail> movementCourseInfos = checkItemItemDetailMap.get(checkItem.getId());
if (ObjectUtil.isNotEmpty(movementCourseInfos)) {
// 按照检查项目聚合
Map<String, List<RailInspectionEquipmentItemDetail>> trackCodeMap = movementCourseInfos.stream()
.collect(Collectors.groupingBy(
Map<String, List<RailInspectionEquipmentItemDetail>> trackCodeMap = movementCourseInfos.stream().collect(Collectors.groupingBy(
// 处理一下“标示里程:20.100” 中文字符
record -> StrUtil.extractTextToNumber(record.getCheckItem()).toString()
));
record -> StrUtil.extractTextToNumber(record.getCheckItem()).toString()));
int size = trackCodeMap.size();
BigDecimal averageDec = checkItemEndMileage.subtract(checkItemStartingMileage).divide(new BigDecimal(size), 3, RoundingMode.HALF_UP);
List<String> trackCodes = trackCodeMap.keySet().stream()
.map(BigDecimal::new)
.sorted()
.map(BigDecimal::toString)
.collect(Collectors.toList());
List<String> trackCodes = trackCodeMap.keySet().stream().map(BigDecimal::new).sorted().map(BigDecimal::toString).collect(Collectors.toList());
BigDecimal currentStartMileage = checkItemStartingMileage;
BigDecimal currentEndEndMileage = checkItemStartingMileage.add(averageDec);
......@@ -1078,6 +1332,8 @@ public class AnalysisAlgorithm {
for (RailInspectionEquipmentItemDetail movementCourseInfo : railDeviceCheckList) {
// 保存检查数据-单元关联关系
MovementCheckDataUnitDeviceMap map = this.railDeviceCheckDeviceMapSave(movementCourseInfo, unitDevice, checkItem);
map.setCheckDetailStartingMileage(currentStartMileage);
map.setCheckDetailEndMileage(currentEndEndMileage);
movementCheckDataUnitDeviceMaps.add(map);
// 计算超限:如果为null则计算,否则和单元绑定
......@@ -1094,13 +1350,13 @@ public class AnalysisAlgorithm {
currentStartMileage = currentEndEndMileage;
currentEndEndMileage = currentEndEndMileage.add(averageDec);
}
}
break;
}
}
}
// 保存之前先删除
movementCheckDataUnitDeviceMapService.lambdaUpdate().eq(MovementCheckDataUnitDeviceMap::getCheckId, checkDataMap.getEkId()).remove();
movementCheckDataUnitDeviceMapService.saveBatch(movementCheckDataUnitDeviceMaps);
}
......@@ -1108,44 +1364,44 @@ public class AnalysisAlgorithm {
/**
* 轨检仪检查数据分数
*/
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();
Double finalTrackGauge = null;
Double finalTriangularPit = null;
Double finalLevel = null;
BigDecimal finalTrackGauge = null;
BigDecimal finalTriangularPit = null;
BigDecimal finalLevel = null;
BigDecimal sumTrackGauge = BigDecimal.ZERO;
BigDecimal sumTriangularPit = BigDecimal.ZERO;
BigDecimal sumLevel = BigDecimal.ZERO;
double sumTrackGauge = 0;
double sumTriangularPit = 0;
double sumLevel = 0;
BigDecimal maxTrackGauge = BigDecimal.ZERO;
BigDecimal maxTriangularPit = BigDecimal.ZERO;
BigDecimal maxLevel = BigDecimal.ZERO;
double maxTrackGauge = 0;
double maxTriangularPit = 0;
double maxLevel = 0;
BigDecimal avgTrackGauge;
BigDecimal avgTriangularPit;
BigDecimal avgLevel;
double avgTrackGauge = 0;
double avgTriangularPit = 0;
double avgLevel = 0;
int trackGaugeSize = 0;
int triangularPitSize = 0;
int levelSize = 0;
double trackGaugeSize = 0;
double triangularPitSize = 0;
double levelSize = 0;
int scale = 3; // 保留3位小数
// 循环计算均值/峰值
for (RailInspectionEquipmentItemDetail movementCourseInfo : railDeviceCheckList) {
// 轨距
Integer trackGauge = Convert.toInt(movementCourseInfo.getTrackGauge());
BigDecimal trackGauge = Convert.toBigDecimal(movementCourseInfo.getTrackGauge());
if (ObjectUtil.isNotEmpty(trackGauge)) {
trackGauge = Math.abs(trackGauge);
trackGauge = trackGauge.abs();
// 均值
sumTrackGauge = sumTrackGauge + trackGauge;
sumTrackGauge = sumTrackGauge.add(trackGauge);
trackGaugeSize++;
avgTrackGauge = sumTrackGauge / trackGaugeSize;
avgTrackGauge = sumTrackGauge.divide(new BigDecimal(trackGaugeSize), scale, BigDecimal.ROUND_HALF_UP);
// 峰值
if (trackGauge > maxTrackGauge) {
if (trackGauge.compareTo(maxTrackGauge) > 0) {
maxTrackGauge = trackGauge;
}
......@@ -1158,15 +1414,15 @@ public class AnalysisAlgorithm {
}
// 水平
Integer level = Convert.toInt(movementCourseInfo.getLevel());
BigDecimal level = Convert.toBigDecimal(movementCourseInfo.getLevel());
if (ObjectUtil.isNotEmpty(level)) {
level = Math.abs(level);
level = level.abs();
// 均值
sumLevel = sumLevel + level;
sumLevel = sumLevel.add(level);
levelSize++;
avgLevel = sumLevel / levelSize;
avgLevel = sumLevel.divide(new BigDecimal(levelSize), scale, BigDecimal.ROUND_HALF_UP);
// 峰值
if (level > maxLevel) {
if (level.compareTo(maxLevel) > 0) {
maxLevel = level;
}
......@@ -1178,15 +1434,15 @@ public class AnalysisAlgorithm {
}
//三角坑
Integer triangularPit = Convert.toInt(movementCourseInfo.getTriangularPit());
BigDecimal triangularPit = Convert.toBigDecimal(movementCourseInfo.getTriangularPit());
if (ObjectUtil.isNotEmpty(triangularPit)) {
triangularPit = Math.abs(triangularPit);
triangularPit = triangularPit.abs();
// 均值
sumTriangularPit = sumTriangularPit + triangularPit;
sumTriangularPit = sumTriangularPit.add(triangularPit);
triangularPitSize++;
avgTriangularPit = sumTriangularPit / triangularPitSize;
avgTriangularPit = sumTriangularPit.divide(new BigDecimal(triangularPitSize), scale, BigDecimal.ROUND_HALF_UP);
// 峰值
if (triangularPit > maxTriangularPit) {
if (triangularPit.compareTo(maxTriangularPit) > 0) {
maxTriangularPit = triangularPit;
}
......@@ -1199,12 +1455,7 @@ public class AnalysisAlgorithm {
}
ConfigRailDeviceCheck configRailDevice = configRailDeviceCheckService.lambdaQuery()
.eq(ConfigRailDeviceCheck::getSpeedMax, analysisBatch.getSpeedMax())
.eq(ConfigRailDeviceCheck::getSpeedMin, analysisBatch.getSpeedMin())
.eq(ConfigRailDeviceCheck::getDelFlag, "0")
.last("limit 1")
.one();
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"));
......@@ -1306,8 +1557,7 @@ public class AnalysisAlgorithm {
/**
* 轨检仪检查数据超限
*/
private AnalysisBatchUnitDeviceTransfinite railDeviceCheckTransfinite(AnalysisBatch analysisBatch,
RailInspectionEquipmentItemDetail movementCourseInfo) {
private AnalysisBatchUnitDeviceTransfinite railDeviceCheckTransfinite(AnalysisBatch analysisBatch, RailInspectionEquipmentItemDetail movementCourseInfo) {
// 超限配置
JSONObject allowValue = JSONObject.parseObject(analysisBatch.getAllowValue());
Integer bigTrackGauge = Convert.toInt(allowValue.get("bigTrackGauge")); // 大轨距
......@@ -1401,10 +1651,7 @@ public class AnalysisAlgorithm {
/**
* 轨检仪检查
*/
private MovementCheckDataUnitDeviceMap railDeviceCheckDeviceMapSave(RailInspectionEquipmentItemDetail
movementCourseInfo,
Map<String, Object> unitDevice,
RailInspectionEquipmentItem checkItem) {
private MovementCheckDataUnitDeviceMap railDeviceCheckDeviceMapSave(RailInspectionEquipmentItemDetail movementCourseInfo, Map<String, Object> unitDevice, RailInspectionEquipmentItem checkItem) {
MovementCheckDataUnitDeviceMap movementCheckDataUnitDeviceMap = new MovementCheckDataUnitDeviceMap();
movementCheckDataUnitDeviceMap.setId(UUIDGenerator.generate());
movementCheckDataUnitDeviceMap.setCheckType(2);// 2-轨检仪静态检查
......@@ -1434,26 +1681,21 @@ public class AnalysisAlgorithm {
/**
* 人工检查数据分析
*/
public void labourCheckDataAnalysis(AnalysisBatch analysisBatch,
AnalysisBatchCheckDataMap checkDataMap,
List<Map<String, Object>> unitDeviceList) {
public void labourCheckDataAnalysis(AnalysisBatch analysisBatch, AnalysisBatchCheckDataMap checkDataMap, List<Map<String, Object>> unitDeviceList) {
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));
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 循环遍历检查项目比较【开始-结束】来映射关联关系
// 2.循环遍历单元设备中心里程落在检查项目【开始-结束】这个区间视为这个区间的单元设备
for (Map<String, Object> unitDevice : unitDeviceList) {
BigDecimal centerMileage = Convert.toBigDecimal(unitDevice.get("centerMileage"));
// 循环遍历检查项目比较【开始-结束】来映射关联关系
for (MovementCourse checkItem : checkItemList) {
// 2.1 这里可能出现开始时间比结束时间大的情况
// 这里可能出现开始时间比结束时间大的情况
BigDecimal checkItemStartingMileage = checkItem.getCourseStartingMileage();
BigDecimal checkItemEndMileage = checkItem.getCourseEndMileage();
if (checkItemStartingMileage.compareTo(checkItemEndMileage) > 0) {
......@@ -1461,28 +1703,17 @@ public class AnalysisAlgorithm {
checkItemEndMileage = checkItem.getCourseStartingMileage();
}
// 2.2 单元设备中心里程落在检查项目【开始-结束】这个区间视为这个区间的单元设备
for (Map<String, Object> unitDevice : unitDeviceList) {
BigDecimal centerMileage = Convert.toBigDecimal(unitDevice.get("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));
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());
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) {
......@@ -1496,6 +1727,8 @@ public class AnalysisAlgorithm {
movementCourseInfo.setCurrentStartMileage(currentStartMileage);
movementCourseInfo.setCurrentEndEndMileage(currentEndEndMileage);
MovementCheckDataUnitDeviceMap map = this.labourCheckDeviceMapSave(movementCourseInfo, unitDevice, checkItem);
map.setCheckDetailStartingMileage(currentStartMileage);
map.setCheckDetailEndMileage(currentEndEndMileage);
movementCheckDataUnitDeviceMaps.add(map);
// 计算超限:如果为null则计算,否则和单元绑定
......@@ -1512,18 +1745,10 @@ public class AnalysisAlgorithm {
currentStartMileage = currentEndEndMileage;
currentEndEndMileage = currentEndEndMileage.add(averageDec);
}
break;
}
}
}
// 保存检查数据-单元映射关联关系
if (ObjectUtil.isNotEmpty(movementCheckDataUnitDeviceMaps)) {
movementCheckDataUnitDeviceMapService.lambdaUpdate().eq(MovementCheckDataUnitDeviceMap::getCheckId, checkDataMap.getEkId()).remove();
movementCheckDataUnitDeviceMapService.saveBatch(movementCheckDataUnitDeviceMaps);
}
}
}
......@@ -1531,34 +1756,32 @@ public class AnalysisAlgorithm {
/**
* 人工分数
*/
private void labourCheckScore(AnalysisBatch analysisBatch,
List<MovementCourseInfo> labourCheckList,
Map<String, Object> unitDevice) {
private void labourCheckScore(AnalysisBatch analysisBatch, List<MovementCourseInfo> labourCheckList, Map<String, Object> unitDevice) {
Integer analysisType = analysisBatch.getAnalysisType();
Double finalTrackGauge = null;
Double finalLevel = null;
Double finalTriangularPit = null;
Double finalHeight = null;
Double finalDirection = null;
BigDecimal finalTrackGauge = null;
BigDecimal finalLevel = null;
BigDecimal finalTriangularPit = null;
BigDecimal finalHeight = null;
BigDecimal finalDirection = null;
double sumTrackGauge = 0;
double sumLevel = 0;
double sumTriangularPit = 0;
double sumHeight = 0;
double sumDirection = 0;
BigDecimal sumTrackGauge = BigDecimal.ZERO;
BigDecimal sumLevel = BigDecimal.ZERO;
BigDecimal sumTriangularPit = BigDecimal.ZERO;
BigDecimal sumHeight = BigDecimal.ZERO;
BigDecimal sumDirection = BigDecimal.ZERO;
double maxTrackGauge = 0;
double maxLevel = 0;
double maxTriangularPit = 0;
double maxHeight = 0;
double maxDirection = 0;
BigDecimal maxTrackGauge = BigDecimal.ZERO;
BigDecimal maxLevel = BigDecimal.ZERO;
BigDecimal maxTriangularPit = BigDecimal.ZERO;
BigDecimal maxHeight = BigDecimal.ZERO;
BigDecimal maxDirection = BigDecimal.ZERO;
double avgTrackGauge = 0;
double avgLevel = 0;
double avgTriangularPit = 0;
double avgHeight = 0;
double avgDirection = 0;
BigDecimal avgTrackGauge;
BigDecimal avgLevel;
BigDecimal avgTriangularPit;
BigDecimal avgHeight;
BigDecimal avgDirection;
int trackGaugeSize = 0;
......@@ -1567,18 +1790,20 @@ public class AnalysisAlgorithm {
int heightSize = 0;
int directionSize = 0;
int scale = 3; // 保留3位小数
// 循环计算均值/峰值
for (MovementCourseInfo movementCourseInfo : labourCheckList) {
// 轨距
Integer trackGauge = Convert.toInt(movementCourseInfo.getTrackGauge());
BigDecimal trackGauge = Convert.toBigDecimal(movementCourseInfo.getTrackGauge());
if (ObjectUtil.isNotEmpty(trackGauge)) {
trackGauge = Math.abs(trackGauge);
trackGauge = trackGauge.abs();
// 均值
sumTrackGauge = sumTrackGauge + trackGauge;
sumTrackGauge = sumTrackGauge.add(trackGauge);
trackGaugeSize++;
avgTrackGauge = sumTrackGauge / trackGaugeSize;
avgTrackGauge = sumTrackGauge.divide(new BigDecimal(trackGaugeSize), scale, BigDecimal.ROUND_HALF_UP);
// 峰值
if (trackGauge > maxTrackGauge) {
if (trackGauge.compareTo(maxTrackGauge) > 0) {
maxTrackGauge = trackGauge;
}
......@@ -1591,15 +1816,15 @@ public class AnalysisAlgorithm {
}
// 水平
Integer level = Convert.toInt(movementCourseInfo.getLevel());
BigDecimal level = Convert.toBigDecimal(movementCourseInfo.getLevel());
if (ObjectUtil.isNotEmpty(level)) {
level = Math.abs(level);
level = level.abs();
// 均值
sumLevel = sumLevel + level;
sumLevel = sumLevel.add(level);
levelSize++;
avgLevel = sumLevel / levelSize;
avgLevel = sumLevel.divide(new BigDecimal(levelSize), scale, BigDecimal.ROUND_HALF_UP);
// 峰值
if (level > maxLevel) {
if (level.compareTo(maxLevel) > 0) {
maxLevel = level;
}
......@@ -1611,15 +1836,15 @@ public class AnalysisAlgorithm {
}
//三角坑
Integer triangularPit = Convert.toInt(movementCourseInfo.getTriangularPit());
BigDecimal triangularPit = Convert.toBigDecimal(movementCourseInfo.getTriangularPit());
if (ObjectUtil.isNotEmpty(triangularPit)) {
triangularPit = Math.abs(triangularPit);
triangularPit = triangularPit.abs();
// 均值
sumTriangularPit = sumTriangularPit + triangularPit;
sumTriangularPit = sumTriangularPit.add(triangularPit);
triangularPitSize++;
avgTriangularPit = sumTriangularPit / triangularPitSize;
avgTriangularPit = sumTriangularPit.divide(new BigDecimal(triangularPitSize), scale, BigDecimal.ROUND_HALF_UP);
// 峰值
if (triangularPit > maxTriangularPit) {
if (triangularPit.compareTo(maxTriangularPit) > 0) {
maxTriangularPit = triangularPit;
}
......@@ -1631,15 +1856,15 @@ public class AnalysisAlgorithm {
}
// 高低
Integer height = Convert.toInt(movementCourseInfo.getHeight());
BigDecimal height = Convert.toBigDecimal(movementCourseInfo.getHeight());
if (ObjectUtil.isNotEmpty(height)) {
height = Math.abs(height);
height = height.abs();
// 均值
sumHeight = sumHeight + height;
sumHeight = sumHeight.add(height);
heightSize++;
avgHeight = sumHeight / heightSize;
avgHeight = sumHeight.divide(new BigDecimal(heightSize), scale, BigDecimal.ROUND_HALF_UP);
// 峰值
if (height > maxHeight) {
if (height.compareTo(maxHeight) > 0) {
maxHeight = height;
}
......@@ -1652,15 +1877,15 @@ public class AnalysisAlgorithm {
// 轨向
Integer direction = Convert.toInt(movementCourseInfo.getDirection());
BigDecimal direction = Convert.toBigDecimal(movementCourseInfo.getDirection());
if (ObjectUtil.isNotEmpty(direction)) {
direction = Math.abs(direction);
direction = direction.abs();
// 均值
sumDirection = sumDirection + direction;
sumDirection = sumDirection.add(direction);
directionSize++;
avgDirection = sumDirection / directionSize;
avgDirection = sumDirection.divide(new BigDecimal(directionSize), scale, BigDecimal.ROUND_HALF_UP);
// 峰值
if (direction > maxDirection) {
if (direction.compareTo(maxDirection) > 0) {
maxDirection = direction;
}
......@@ -1673,12 +1898,7 @@ public class AnalysisAlgorithm {
}
ConfigLabourCheck configLabour = configLabourCheckService.lambdaQuery()
.eq(ConfigLabourCheck::getSpeedMax, analysisBatch.getSpeedMax())
.eq(ConfigLabourCheck::getSpeedMin, analysisBatch.getSpeedMin())
.eq(ConfigLabourCheck::getDelFlag, "0")
.last("limit 1")
.one();
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-道岔
......@@ -1837,8 +2057,7 @@ public class AnalysisAlgorithm {
* @param movementCourseInfo
* @return
*/
private AnalysisBatchUnitDeviceTransfinite labourCheckTransfinite(AnalysisBatch
analysisBatch, MovementCourseInfo movementCourseInfo) {
private AnalysisBatchUnitDeviceTransfinite labourCheckTransfinite(AnalysisBatch analysisBatch, MovementCourseInfo movementCourseInfo) {
// 超限配置
JSONObject allowValue = JSONObject.parseObject(analysisBatch.getAllowValue());
Integer bigTrackGauge = Convert.toInt(allowValue.get("bigTrackGauge")); // 大轨距
......@@ -1956,9 +2175,7 @@ public class AnalysisAlgorithm {
* @param checkItem
* @return
*/
private MovementCheckDataUnitDeviceMap labourCheckDeviceMapSave(MovementCourseInfo movementCourseInfo,
Map<String, Object> unitDevice,
MovementCourse checkItem) {
private MovementCheckDataUnitDeviceMap labourCheckDeviceMapSave(MovementCourseInfo movementCourseInfo, Map<String, Object> unitDevice, MovementCourse checkItem) {
MovementCheckDataUnitDeviceMap record = new MovementCheckDataUnitDeviceMap();
record.setId(UUIDGenerator.generate());
record.setCheckType(1);// 人工检查
......
......@@ -97,7 +97,7 @@ public class AnalysisBatchUnitDevicePointScore implements Serializable {
@ApiModelProperty("测点值")
@TableField("point_value")
private Double pointValue;
private BigDecimal pointValue;
@ApiModelProperty("测点得分")
@TableField("point_score")
......
package org.jeecg.modules.dynamicStaticAnalysis.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.util.Date;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
/**
* <p>
* 动静态分析-分析批次-单元设备派工表
* </p>
*
* @author hkl
* @since 2023-08-30
*/
@Getter
@Setter
@TableName("t_dsa_analysis_batch_unit_device_work")
@ApiModel(value = "AnalysisBatchUnitDeviceWork对象", description = "动静态分析-分析批次-单元设备派工表")
public class AnalysisBatchUnitDeviceWork implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty("主键")
@TableId("id")
private String id;
@ApiModelProperty("创建人")
@TableField("create_by")
private String createBy;
@ApiModelProperty("创建日期")
@TableField("create_time")
private Date createTime;
@ApiModelProperty("更新人")
@TableField("update_by")
private String updateBy;
@ApiModelProperty("更新时间")
@TableField("update_time")
private Date updateTime;
@ApiModelProperty("分析批次单元设备id")
@TableField("analysis_batch_unit_device_id")
private String analysisBatchUnitDeviceId;
@ApiModelProperty("分析批次号")
@TableField("analysis_batch_code")
private String analysisBatchCode;
@ApiModelProperty("分析批id")
@TableField("analysis_batch_id")
private String analysisBatchId;
@ApiModelProperty("单元设备id")
@TableField("unit_id")
private String unitId;
@ApiModelProperty("单元设备code")
@TableField("unit_code")
private String unitCode;
@ApiModelProperty("设备单元类型1-钢轨,2-曲线,3-竖曲线,4-道岔")
@TableField("unit_type")
private Integer unitType;
@ApiModelProperty("设备单元类型名称")
@TableField("unit_type_name")
private String unitTypeName;
@ApiModelProperty("派工原因")
@TableField("work_reason")
private Integer workReason;
@ApiModelProperty("备注")
@TableField("remark")
private String remark;
}
package org.jeecg.modules.dynamicStaticAnalysis.mapper;
import org.jeecg.modules.dynamicStaticAnalysis.entity.AnalysisBatchUnitDeviceWork;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* <p>
* 动静态分析-分析批次-单元设备派工表 Mapper 接口
* </p>
*
* @author hkl
* @since 2023-08-30
*/
public interface AnalysisBatchUnitDeviceWorkMapper extends BaseMapper<AnalysisBatchUnitDeviceWork> {
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.jeecg.modules.dynamicStaticAnalysis.mapper.AnalysisBatchUnitDeviceWorkMapper">
</mapper>
package org.jeecg.modules.dynamicStaticAnalysis.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.util.Date;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
/**
* <p>
* 动静态分析-分析批次-单元设备派工表
* </p>
*
* @author hkl
* @since 2023-08-30
*/
@Getter
@Setter
@ApiModel(value = "AnalysisBatchUnitDeviceWork对象", description = "动静态分析-分析批次-单元设备派工表")
public class AnalysisBatchUnitDeviceWorkDTO {
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("分析批次单元设备id")
private String analysisBatchUnitDeviceId;
@ApiModelProperty("分析批次号")
private String analysisBatchCode;
@ApiModelProperty("分析批id")
private String analysisBatchId;
@ApiModelProperty("单元设备id")
private String unitId;
@ApiModelProperty("单元设备code")
private String unitCode;
@ApiModelProperty("设备单元类型1-钢轨,2-曲线,3-竖曲线,4-道岔")
private Integer unitType;
@ApiModelProperty("设备单元类型名称")
private String unitTypeName;
@ApiModelProperty("派工原因")
private Integer workReason;
@ApiModelProperty("备注")
private String remark;
}
package org.jeecg.modules.dynamicStaticAnalysis.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.util.Date;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
/**
* <p>
* 动静态分析-分析批次-单元设备派工表
* </p>
*
* @author hkl
* @since 2023-08-30
*/
@Getter
@Setter
@ApiModel(value = "AnalysisBatchUnitDeviceWork对象", description = "动静态分析-分析批次-单元设备派工表")
public class AnalysisBatchUnitDeviceWorkVO {
private static final long serialVersionUID = 1L;
@ApiModelProperty("主键")
@TableId("id")
private String id;
@ApiModelProperty("创建人")
@TableField("create_by")
private String createBy;
@ApiModelProperty("创建日期")
@TableField("create_time")
private Date createTime;
@ApiModelProperty("更新人")
@TableField("update_by")
private String updateBy;
@ApiModelProperty("更新时间")
@TableField("update_time")
private Date updateTime;
@ApiModelProperty("分析批次单元设备id")
@TableField("analysis_batch_unit_device_id")
private String analysisBatchUnitDeviceId;
@ApiModelProperty("分析批次号")
@TableField("analysis_batch_code")
private String analysisBatchCode;
@ApiModelProperty("分析批id")
@TableField("analysis_batch_id")
private String analysisBatchId;
@ApiModelProperty("单元设备id")
@TableField("unit_id")
private String unitId;
@ApiModelProperty("单元设备code")
@TableField("unit_code")
private String unitCode;
@ApiModelProperty("设备单元类型1-钢轨,2-曲线,3-竖曲线,4-道岔")
@TableField("unit_type")
private Integer unitType;
@ApiModelProperty("设备单元类型名称")
@TableField("unit_type_name")
private String unitTypeName;
@ApiModelProperty("派工原因")
@TableField("work_reason")
private Integer workReason;
@ApiModelProperty("备注")
@TableField("remark")
private String remark;
}
package org.jeecg.modules.dynamicStaticAnalysis.service;
import org.jeecg.modules.dynamicStaticAnalysis.entity.AnalysisBatchUnitDeviceWork;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* <p>
* 动静态分析-分析批次-单元设备派工表 服务类
* </p>
*
* @author hkl
* @since 2023-08-30
*/
public interface IAnalysisBatchUnitDeviceWorkService extends IService<AnalysisBatchUnitDeviceWork> {
}
......@@ -141,6 +141,8 @@ public class AnalysisBatchServiceImpl extends ServiceImpl<AnalysisBatchMapper, A
wrapper.eq(AnalysisBatchCheckDataMap::getAnalysisBatchId, id);
analysisBatchCheckDataMapMapper.delete(wrapper);
// 2.删除主信息
this.removeById(id);
}
......
package org.jeecg.modules.dynamicStaticAnalysis.service.impl;
import org.jeecg.modules.dynamicStaticAnalysis.entity.AnalysisBatchUnitDeviceWork;
import org.jeecg.modules.dynamicStaticAnalysis.mapper.AnalysisBatchUnitDeviceWorkMapper;
import org.jeecg.modules.dynamicStaticAnalysis.service.IAnalysisBatchUnitDeviceWorkService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
/**
* <p>
* 动静态分析-分析批次-单元设备派工表 服务实现类
* </p>
*
* @author hkl
* @since 2023-08-30
*/
@Service
public class AnalysisBatchUnitDeviceWorkServiceImpl extends ServiceImpl<AnalysisBatchUnitDeviceWorkMapper, AnalysisBatchUnitDeviceWork> implements IAnalysisBatchUnitDeviceWorkService {
}
......@@ -125,6 +125,12 @@
<artifactId>dingtalk</artifactId>
<version>2.0.30</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>4.1.2</version>
<scope>compile</scope>
</dependency>
</dependencies>
......
......@@ -13,8 +13,8 @@ public class GlobalExceptionHandler {
@ExceptionHandler(value = {Exception.class})
@ResponseBody
public BaseResponse<?> deal(Exception e) {
BaseResponse<?> response = new BaseResponse<>();
public <T> BaseResponse<T> deal(Exception e) {
BaseResponse<T> response = new BaseResponse<>();
if (e instanceof BusinessException) {
} else if (e instanceof ParamValidException) {
......
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