|
@@ -244,6 +244,59 @@ public class RollClubOneServiceImpl extends ServiceImpl<RollClubOneMapper, RollC
|
|
|
@Override
|
|
|
public List<RollClubOneVO> rollClubOneList(RollClubOneQueryDTO queryDTO) {
|
|
|
LambdaQueryWrapper<BilletOriginalProductRecord> oneQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+
|
|
|
+ Date finalStartTime = null;
|
|
|
+ Date finalEndTime = null;
|
|
|
+
|
|
|
+ // === 1. 从交班记录中获取时间段(如果 changeShiftId 存在) ===
|
|
|
+ Date shiftStart = null;
|
|
|
+ Date shiftEnd = null;
|
|
|
+ if (oConvertUtils.isNotEmpty(queryDTO.getChangeShiftId())) {
|
|
|
+ LambdaQueryWrapper<BilletHotsendChangeShift> shiftWrapper = new LambdaQueryWrapper<>();
|
|
|
+ shiftWrapper.eq(BilletHotsendChangeShift::getId, queryDTO.getChangeShiftId());
|
|
|
+ BilletHotsendChangeShift shift = billetHotsendChangeShiftService.getOne(shiftWrapper);
|
|
|
+
|
|
|
+ if (shift != null) {
|
|
|
+ shiftStart = shift.getCreateTime();
|
|
|
+ shiftEnd = shift.getChangeShiftTime() != null ? shift.getChangeShiftTime() : new Date();
|
|
|
+ } else {
|
|
|
+ log.warn("未查询到交班记录,changeShiftId={}", queryDTO.getChangeShiftId());
|
|
|
+ return Collections.emptyList();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // === 2. 获取前端传入的时间段 ===
|
|
|
+ Date paramStart = queryDTO.getStorageTimeBegin();
|
|
|
+ Date paramEnd = queryDTO.getStorageTimeEnd();
|
|
|
+
|
|
|
+ // === 3. 决定最终查询时间段 ===
|
|
|
+ if (shiftStart != null && shiftEnd != null && paramStart != null && paramEnd != null) {
|
|
|
+ // 两者都传,取交集
|
|
|
+ finalStartTime = paramStart.after(shiftStart) ? paramStart : shiftStart;
|
|
|
+ finalEndTime = paramEnd.before(shiftEnd) ? paramEnd : shiftEnd;
|
|
|
+ if (finalStartTime.after(finalEndTime)) {
|
|
|
+ log.warn("时间区间无交集:finalStartTime={}, finalEndTime={}", finalStartTime, finalEndTime);
|
|
|
+ return Collections.emptyList();
|
|
|
+ }
|
|
|
+ } else if (paramStart != null || paramEnd != null) {
|
|
|
+ // 仅传前端参数
|
|
|
+ finalStartTime = paramStart;
|
|
|
+ finalEndTime = paramEnd;
|
|
|
+ } else if (shiftStart != null && shiftEnd != null) {
|
|
|
+ // 仅传交班记录
|
|
|
+ finalStartTime = shiftStart;
|
|
|
+ finalEndTime = shiftEnd;
|
|
|
+ } // else 不设置时间过滤(慎用)
|
|
|
+
|
|
|
+ // === 构造查询条件 ===
|
|
|
+ if (finalStartTime != null) {
|
|
|
+ oneQueryWrapper.ge(BilletOriginalProductRecord::getCreateTime, finalStartTime);
|
|
|
+ }
|
|
|
+ if (finalEndTime != null) {
|
|
|
+ oneQueryWrapper.le(BilletOriginalProductRecord::getCreateTime, finalEndTime);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
if (StringUtils.isNotBlank(queryDTO.getCcmNo())) {
|
|
|
oneQueryWrapper.eq(BilletOriginalProductRecord::getCcmNo, queryDTO.getCcmNo());
|
|
|
}
|