|
@@ -72,21 +72,50 @@ public class BilletOriginalProductRecordServiceImpl extends ServiceImpl<BilletOr
|
|
|
List<QualityInspectionVO> resultList = new ArrayList<>();
|
|
|
LambdaQueryWrapper<BilletOriginalProductRecord> oneQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
oneQueryWrapper.eq(BilletOriginalProductRecord::getCcmNo, queryDTO.getCcmNo());
|
|
|
- LambdaQueryWrapper<BilletHotsendChangeShift> changeShiftQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
|
|
|
BilletHotsendChangeShift newBilletHotsendChangeShift = null;
|
|
|
|
|
|
if (oConvertUtils.isNotEmpty(queryDTO.getChangeShiftId())) {
|
|
|
- // 指定了换班记录ID
|
|
|
- changeShiftQueryWrapper.eq(BilletHotsendChangeShift::getId, queryDTO.getChangeShiftId());
|
|
|
+ // 指定了换班记录ID,先查出来
|
|
|
+ newBilletHotsendChangeShift = billetHotsendChangeShiftService.getById(queryDTO.getChangeShiftId());
|
|
|
+
|
|
|
+ // 判断是否需要切换为当前铸机号的记录
|
|
|
+ if (newBilletHotsendChangeShift != null &&
|
|
|
+ !queryDTO.getCcmNo().equals(newBilletHotsendChangeShift.getCcmNo())) {
|
|
|
+
|
|
|
+ // 当前换班记录不属于目标铸机号,需要重新查找符合 shift 和 shiftGroup 的当前铸机记录
|
|
|
+ Date baseTime = newBilletHotsendChangeShift.getCreateTime();
|
|
|
+ Date startWindow = new Date(baseTime.getTime() - 10 * 60 * 1000); // -10分钟
|
|
|
+ Date endWindow = new Date(baseTime.getTime() + 10 * 60 * 1000); // +10分钟
|
|
|
+
|
|
|
+ LambdaQueryWrapper<BilletHotsendChangeShift> ccmChangeQuery = new LambdaQueryWrapper<>();
|
|
|
+ ccmChangeQuery.eq(BilletHotsendChangeShift::getCcmNo, queryDTO.getCcmNo())
|
|
|
+ .eq(BilletHotsendChangeShift::getShift, newBilletHotsendChangeShift.getShift())
|
|
|
+ .eq(BilletHotsendChangeShift::getShiftGroup, newBilletHotsendChangeShift.getShiftGroup())
|
|
|
+ .between(BilletHotsendChangeShift::getCreateTime, startWindow, endWindow)
|
|
|
+ .orderByAsc(BilletHotsendChangeShift::getCreateTime)
|
|
|
+ .last("limit 1");
|
|
|
+
|
|
|
+ BilletHotsendChangeShift matchedShift = billetHotsendChangeShiftService.getOne(ccmChangeQuery);
|
|
|
+
|
|
|
+ // 如果找到符合条件的记录,就替换
|
|
|
+ if (matchedShift != null) {
|
|
|
+ newBilletHotsendChangeShift = matchedShift;
|
|
|
+ } else {
|
|
|
+ // 没找到也可以保底返回原数据,或者视为无效请求
|
|
|
+ return Collections.emptyMap();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
} else {
|
|
|
// 未指定ID,则取指定铸机号下最新一条换班记录
|
|
|
- changeShiftQueryWrapper.eq(BilletHotsendChangeShift::getCcmNo, queryDTO.getCcmNo())
|
|
|
+ LambdaQueryWrapper<BilletHotsendChangeShift> latestShiftQuery = new LambdaQueryWrapper<>();
|
|
|
+ latestShiftQuery.eq(BilletHotsendChangeShift::getCcmNo, queryDTO.getCcmNo())
|
|
|
.orderByDesc(BilletHotsendChangeShift::getCreateTime)
|
|
|
- .last("limit 1"); // 只取一条
|
|
|
+ .last("limit 1");
|
|
|
+ newBilletHotsendChangeShift = billetHotsendChangeShiftService.getOne(latestShiftQuery);
|
|
|
}
|
|
|
|
|
|
- newBilletHotsendChangeShift = billetHotsendChangeShiftService.getOne(changeShiftQueryWrapper);
|
|
|
|
|
|
if (newBilletHotsendChangeShift == null) {
|
|
|
return Collections.emptyMap(); // 无数据,直接返回空
|
|
@@ -310,10 +339,12 @@ public class BilletOriginalProductRecordServiceImpl extends ServiceImpl<BilletOr
|
|
|
|
|
|
@Override
|
|
|
public void getQualityInspectionScreen() {
|
|
|
- String ccmNo = "5";
|
|
|
+ String ccmNo5 = "5";
|
|
|
+ String ccmNo6 = "6";
|
|
|
|
|
|
// 初始化补全月统计(缺失部分)
|
|
|
- initMonthlyStatisticsIfMissing(ccmNo);
|
|
|
+ initMonthlyStatisticsIfMissing(ccmNo5);
|
|
|
+ initMonthlyStatisticsIfMissing(ccmNo6);
|
|
|
|
|
|
}
|
|
|
|