|
@@ -237,74 +237,48 @@ public class RollClubThreeDetailsController extends JeecgController<RollClubThre
|
|
|
@GetMapping(value = "/exportThreeXls")
|
|
|
public void exportThreeXls(HttpServletResponse response, StorageBillPrint storageBillPrint) {
|
|
|
try {
|
|
|
- QueryWrapper<StorageBillPrint> queryWrapper = new QueryWrapper<>();
|
|
|
-
|
|
|
- // 手动设置必要条件,避免 QueryGenerator 自动生成不必要的条件
|
|
|
- if (oConvertUtils.isNotEmpty(storageBillPrint.getCcmNo())) {
|
|
|
- queryWrapper.eq("ccm_no", storageBillPrint.getCcmNo());
|
|
|
- }
|
|
|
- if (oConvertUtils.isNotEmpty(storageBillPrint.getLicensePlate())) {
|
|
|
- queryWrapper.eq("license_plate", storageBillPrint.getLicensePlate());
|
|
|
- }
|
|
|
-
|
|
|
- queryWrapper.eq("destination", "棒三");
|
|
|
-
|
|
|
- Date finalStartTime = null;
|
|
|
- Date finalEndTime = null;
|
|
|
-
|
|
|
- boolean hasQueryDate = storageBillPrint.getQueryDate() != null;
|
|
|
- boolean hasChangeShiftId = oConvertUtils.isNotEmpty(storageBillPrint.getChangeShiftId());
|
|
|
- boolean hasRange = storageBillPrint.getStartTime() != null || storageBillPrint.getEndTime() != null;
|
|
|
-
|
|
|
- // 校验:只能传一个
|
|
|
- int count = (hasQueryDate ? 1 : 0) + (hasChangeShiftId ? 1 : 0) + (hasRange ? 1 : 0);
|
|
|
- if (count > 1) {
|
|
|
- log.warn("参数冲突:queryDate、changeShiftId、startTime/endTime 只能传一个");
|
|
|
- }
|
|
|
-
|
|
|
- // 处理 queryDate:某一天
|
|
|
- if (hasQueryDate) {
|
|
|
- Date queryDate = storageBillPrint.getQueryDate();
|
|
|
- // 当天 0 点
|
|
|
- finalStartTime = Date.from(queryDate.toInstant().atZone(ZoneId.systemDefault())
|
|
|
- .toLocalDate().atStartOfDay(ZoneId.systemDefault()).toInstant());
|
|
|
- // 第二天 0 点减 1 毫秒 = 当天 23:59:59.999
|
|
|
- finalEndTime = Date.from(queryDate.toInstant().atZone(ZoneId.systemDefault())
|
|
|
- .toLocalDate().plusDays(1).atStartOfDay(ZoneId.systemDefault()).minusNanos(1).toInstant());
|
|
|
- // 处理交班记录
|
|
|
- } else if (hasChangeShiftId) {
|
|
|
- LambdaQueryWrapper<BilletHotsendChangeShift> shiftWrapper = new LambdaQueryWrapper<>();
|
|
|
- shiftWrapper.eq(BilletHotsendChangeShift::getId, storageBillPrint.getChangeShiftId());
|
|
|
- BilletHotsendChangeShift shift = billetHotsendChangeShiftService.getOne(shiftWrapper);
|
|
|
- if (shift != null) {
|
|
|
- finalStartTime = shift.getCreateTime();
|
|
|
- finalEndTime = shift.getChangeShiftTime() != null ? shift.getChangeShiftTime() : new Date();
|
|
|
- if (StringUtils.isNotBlank(shift.getShift()) && StringUtils.isNotBlank(shift.getShiftGroup())) {
|
|
|
- String combinedClass = shift.getShift() + "/" + shift.getShiftGroup();
|
|
|
- queryWrapper.eq("classes", combinedClass);
|
|
|
- }
|
|
|
-
|
|
|
+ QueryWrapper<StorageBillPrint> queryWrapper = new QueryWrapper<StorageBillPrint>();
|
|
|
+ // 铸机号查询条件
|
|
|
+ queryWrapper.eq("ccm_no", storageBillPrint.getCcmNo());
|
|
|
+ // 目的地
|
|
|
+ queryWrapper.eq("destination", storageBillPrint.getDestination());
|
|
|
+ if(oConvertUtils.isNotEmpty(storageBillPrint.getChangeShiftId())) { // 班组取班组时间
|
|
|
+ // 根据铸机号、交班记录ID,获取交班记录中的班别、班次、创建时间
|
|
|
+ LambdaQueryWrapper<BilletHotsendChangeShift> changeQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ changeQueryWrapper.eq(BilletHotsendChangeShift::getId, storageBillPrint.getChangeShiftId()).eq(BilletHotsendChangeShift::getCcmNo, storageBillPrint.getCcmNo());
|
|
|
+ BilletHotsendChangeShift billetHotsendChangeShift = billetHotsendChangeShiftService.getOne(changeQueryWrapper);
|
|
|
+ if (billetHotsendChangeShift == null){
|
|
|
+ throw new RuntimeException("未查询到交班记录,无法导出!");
|
|
|
}
|
|
|
-
|
|
|
- // 处理时间范围
|
|
|
- } else if (hasRange) {
|
|
|
- finalStartTime = storageBillPrint.getStartTime();
|
|
|
- finalEndTime = storageBillPrint.getEndTime();
|
|
|
+ Date startChnageTime = billetHotsendChangeShift.getCreateTime();
|
|
|
+ String classes = billetHotsendChangeShift.getShift() + "/" + billetHotsendChangeShift.getShiftGroup();
|
|
|
+ queryWrapper.eq("classes", classes);
|
|
|
+ Date endChnageTime = oConvertUtils.isNotEmpty(billetHotsendChangeShift.getChangeShiftTime()) ? billetHotsendChangeShift.getChangeShiftTime() : new Date();
|
|
|
+ // 修改时间范围查询条件为 >= startTime 且 <= endTime
|
|
|
+ queryWrapper.ge("arrival_time", startChnageTime) // 大于等于开始时间
|
|
|
+ .le("arrival_time", endChnageTime); // 小于等于结束时间
|
|
|
+ }else if(oConvertUtils.isNotEmpty(storageBillPrint.getStartTime()) && oConvertUtils.isNotEmpty(storageBillPrint.getEndTime())){ // 时间范围
|
|
|
+ // 修改时间范围查询条件为 >= startTime 且 <= endTime
|
|
|
+ queryWrapper.ge("arrival_time", storageBillPrint.getStartTime()) // 大于等于开始时间
|
|
|
+ .le("arrival_time", storageBillPrint.getEndTime()); // 小于等于结束时间
|
|
|
+ } else if(oConvertUtils.isNotEmpty(storageBillPrint.getQueryDate())){ // 具体时间
|
|
|
+ Date startArrivalTime = DateUtils.getStartOfDayByDate(DateUtils.getStartOfDay(storageBillPrint.getQueryDate()));
|
|
|
+ // 结束时间 减一个小时
|
|
|
+ Date endArrivalTime = DateUtils.getEndOfDayByDate(startArrivalTime);
|
|
|
+ log.info("查询时间范围:startTime={}, endTime={}", storageBillPrint.getStartTime(),storageBillPrint.getEndTime());
|
|
|
+ // 修改时间范围查询条件为 >= startTime 且 <= endTime
|
|
|
+ queryWrapper.ge("arrival_time", startArrivalTime) // 大于等于开始时间
|
|
|
+ .le("arrival_time", endArrivalTime); // 小于等于结束时间
|
|
|
}
|
|
|
-
|
|
|
- // 校验时间区间是否合法
|
|
|
- if (finalStartTime != null && finalEndTime != null && finalStartTime.after(finalEndTime)) {
|
|
|
- log.warn("无效时间区间:start={}, end={}", finalStartTime, finalEndTime);
|
|
|
- }
|
|
|
-
|
|
|
- // 应用到 wrapper 上
|
|
|
- if (finalStartTime != null) {
|
|
|
- queryWrapper.ge("arrival_time", finalStartTime);
|
|
|
+ // 炉号查询
|
|
|
+ if (oConvertUtils.isNotEmpty(storageBillPrint.getHeatNo())) {
|
|
|
+ queryWrapper.like("heat_no", storageBillPrint.getHeatNo());
|
|
|
}
|
|
|
- if (finalEndTime != null) {
|
|
|
- queryWrapper.le("arrival_time", finalEndTime);
|
|
|
+ // 车辆查询
|
|
|
+ if (oConvertUtils.isNotEmpty(storageBillPrint.getLicensePlate())) {
|
|
|
+ queryWrapper.like("license_plate", storageBillPrint.getLicensePlate());
|
|
|
}
|
|
|
- //
|
|
|
+ // 根据到站时间排序
|
|
|
queryWrapper.orderByDesc("arrival_time");
|
|
|
List<StorageBillPrint> exportList = storageBillPrintService.list(queryWrapper);
|
|
|
|