|
@@ -8,6 +8,9 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.fasterxml.jackson.core.JsonProcessingException;
|
|
|
+import com.fasterxml.jackson.core.type.TypeReference;
|
|
|
+import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
@@ -72,6 +75,7 @@ import org.jeecg.modules.billet.storageBill.vo.*;
|
|
|
import org.jeecg.modules.billet.storageCarLog.entity.StorageCarLog;
|
|
|
import org.jeecg.modules.billet.storageCarLog.service.IStorageCarLogService;
|
|
|
import org.jeecg.modules.carUnit.service.ICarUnitService;
|
|
|
+import org.jeecg.modules.carUnit.service.ISysDictService;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.data.redis.core.RedisTemplate;
|
|
@@ -281,15 +285,67 @@ public class StorageBillController extends JeecgController<StorageBill, IStorage
|
|
|
bill.setAssemblyNumber(mergedAssemblyNumbers);
|
|
|
}
|
|
|
|
|
|
+ // 查询 StorageBillPrint 中对应的最新记录
|
|
|
+ Map<String, StorageBillPrint> latestPrints = new HashMap<>();
|
|
|
+ if (!records.isEmpty()) {
|
|
|
+ LambdaQueryWrapper<StorageBillPrint> printWrapper = new LambdaQueryWrapper<>();
|
|
|
+ printWrapper.in(StorageBillPrint::getStorageBillId, billIds);
|
|
|
+ printWrapper.orderByDesc(StorageBillPrint::getCreateTime);
|
|
|
+
|
|
|
+ List<StorageBillPrint> allPrints = storageBillPrintService.list(printWrapper);
|
|
|
+
|
|
|
+ latestPrints = allPrints.stream()
|
|
|
+ .collect(Collectors.toMap(
|
|
|
+ StorageBillPrint::getStorageBillId,
|
|
|
+ p -> p,
|
|
|
+ (existing, replacement) -> existing // 保留 createTime 最大的那条
|
|
|
+ ));
|
|
|
+ }
|
|
|
+
|
|
|
+ // 构建未匹配的 StorageBill 集合
|
|
|
+ List<StorageBill> needFillHeatNoBills = new ArrayList<>();
|
|
|
+
|
|
|
+ for (StorageBill bill : records) {
|
|
|
+ StorageBillPrint print = latestPrints.get(bill.getId());
|
|
|
+ if (print != null) {
|
|
|
+ bill.setOutTime(print.getArrivalTime());
|
|
|
+ bill.setDestination(print.getDestination());
|
|
|
+ bill.setAmountTotal(print.getAmountTotal());
|
|
|
+ bill.setSize(print.getSize());
|
|
|
+ bill.setBrandNum(print.getBrandNum());
|
|
|
+ try {
|
|
|
+ String heatNoJson = print.getHeatNo();
|
|
|
+ if (StringUtils.isNotBlank(heatNoJson)) {
|
|
|
+ ObjectMapper objectMapper = new ObjectMapper();
|
|
|
+ Map<String, Integer> heatNoMap = objectMapper.readValue(heatNoJson, new TypeReference<Map<String, Integer>>() {});
|
|
|
+
|
|
|
+ bill.setHeatNoCountMap(heatNoMap);
|
|
|
+ } else {
|
|
|
+ bill.setHeatNoCountMap(new HashMap<>()); // 空值处理
|
|
|
+ }
|
|
|
+ } catch (JsonProcessingException e) {
|
|
|
+ log.error("解析 heatNo JSON 失败,原始值: {}", print.getHeatNo(), e);
|
|
|
+ bill.setHeatNo(""); // 异常时设为空
|
|
|
+ }
|
|
|
+
|
|
|
+ } else {
|
|
|
+ needFillHeatNoBills.add(bill); // 未匹配的放入待补充集合
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
// 8. 填充车次编号与交班记录信息
|
|
|
storageBillService.fillCarNumbersAndShiftInfo(records);
|
|
|
|
|
|
- storageBillService.fillHeatNoCountMapForBills(page.getRecords());
|
|
|
+ // 9. 仅对未匹配记录调用 fillHeatNoCountMapForBills
|
|
|
+ if (!needFillHeatNoBills.isEmpty()) {
|
|
|
+ storageBillService.fillHeatNoCountMapForBills(needFillHeatNoBills);
|
|
|
+ }
|
|
|
|
|
|
- // 9. 返回分页结果
|
|
|
+ // 10. 设置分页返回内容
|
|
|
pagedBills.setRecords(records);
|
|
|
return Result.OK(pagedBills);
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|