refactor(material-coil): 重构钢卷物料查询服务
- 移除 WmsMaterialCoilVo 中的嵌套对象结构(rawMaterial、product、bomItemList) - 新增 WmsMaterialCoilBindVo 视图对象专门处理发货绑定信息 - 添加 queryPageListWithBindInfo 方法支持发货绑定增强字段查询 - 将联查字段改为扁平化结构,直接填充基础物料属性 - 优化分页查询逻辑,分离通用查询和绑定信息查询流程 - 移除 BOM 项批量查询功能,简化服务依赖关系
This commit is contained in:
@@ -59,6 +59,14 @@ public class WmsMaterialCoilController extends BaseController {
|
||||
return iWmsMaterialCoilService.queryPageList(bo, pageQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询钢卷物料表列表(包含发货绑定增强字段)
|
||||
*/
|
||||
@GetMapping("/listWithBindInfo")
|
||||
public TableDataInfo<WmsMaterialCoilBindVo> listWithBindInfo(WmsMaterialCoilBo bo, PageQuery pageQuery) {
|
||||
return iWmsMaterialCoilService.queryPageListWithBindInfo(bo, pageQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
* 原料钢卷库位分布查询(先库位,再钢卷映射)
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
package com.klp.domain.vo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
/**
|
||||
* 钢卷物料表视图对象(包含发货绑定信息) wms_material_coil
|
||||
*
|
||||
* @author Joshi
|
||||
* @date 2025-07-18
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class WmsMaterialCoilBindVo extends WmsMaterialCoilVo {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
// ========== 发货绑定信息(由发货单明细占用) ==========
|
||||
|
||||
/**
|
||||
* 是否已被发货单明细绑定(true=不可再次绑定)
|
||||
*/
|
||||
private Boolean bound;
|
||||
|
||||
private Long bindDetailId;
|
||||
|
||||
private Long bindWaybillId;
|
||||
private String bindWaybillNo;
|
||||
private String bindWaybillName;
|
||||
|
||||
private Long bindPlanId;
|
||||
private String bindPlanName;
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
private Date bindPlanDate;
|
||||
|
||||
// ========== 补充的发货绑定信息字段 ==========
|
||||
/**
|
||||
* 车牌号
|
||||
*/
|
||||
private String bindLicensePlate;
|
||||
|
||||
/**
|
||||
* 收货单位
|
||||
*/
|
||||
private String bindConsigneeUnit;
|
||||
|
||||
/**
|
||||
* 发货单位
|
||||
*/
|
||||
private String bindSenderUnit;
|
||||
|
||||
/**
|
||||
* 发货时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date bindDeliveryTime;
|
||||
|
||||
/**
|
||||
* 地磅
|
||||
*/
|
||||
private String bindWeighbridge;
|
||||
|
||||
/**
|
||||
* 销售人员
|
||||
*/
|
||||
private String bindSalesPerson;
|
||||
|
||||
/**
|
||||
* 负责人
|
||||
*/
|
||||
private String bindPrincipal;
|
||||
|
||||
/**
|
||||
* 负责人电话
|
||||
*/
|
||||
private String bindPrincipalPhone;
|
||||
|
||||
/**
|
||||
* 运单状态
|
||||
*/
|
||||
private Long bindWaybillStatus;
|
||||
|
||||
/**
|
||||
* 运单备注
|
||||
*/
|
||||
private String bindWaybillRemark;
|
||||
|
||||
/**
|
||||
* 明细结算类型
|
||||
*/
|
||||
private String bindDetailSettlementType;
|
||||
|
||||
/**
|
||||
* 明细单价
|
||||
*/
|
||||
private BigDecimal bindDetailUnitPrice;
|
||||
}
|
||||
@@ -141,23 +141,6 @@ public class WmsMaterialCoilVo extends BaseEntity {
|
||||
*/
|
||||
private WmsGenerateRecordVo qrcodeRecord;
|
||||
|
||||
/**
|
||||
* 原材料信息(当itemType为raw_material时)
|
||||
*/
|
||||
private WmsRawMaterialVo rawMaterial;
|
||||
|
||||
/**
|
||||
* 产品信息(当itemType为product时)
|
||||
*/
|
||||
private WmsProductVo product;
|
||||
|
||||
/**
|
||||
* BOM列表(原材料对应的BOM项目信息)
|
||||
*/
|
||||
private List<WmsBomItemVo> bomItemList;
|
||||
|
||||
// ========== 统计相关属性 ==========
|
||||
|
||||
/**
|
||||
* 库区名称(用于统计查询)
|
||||
*/
|
||||
@@ -218,87 +201,13 @@ public class WmsMaterialCoilVo extends BaseEntity {
|
||||
*/
|
||||
private String packagingRequirement;
|
||||
|
||||
// ========== 联查临时字段(用于优化查询性能,避免单独查询) ==========
|
||||
|
||||
/**
|
||||
* 原材料ID(联查字段)
|
||||
*/
|
||||
private Long rawMaterialId;
|
||||
|
||||
/**
|
||||
* 原材料编号(联查字段)
|
||||
*/
|
||||
private String rawMaterialCode;
|
||||
|
||||
/**
|
||||
* 原材料名称(联查字段)
|
||||
*/
|
||||
private String rawMaterialName;
|
||||
|
||||
/**
|
||||
* 原材料规格(联查字段)
|
||||
*/
|
||||
private String rawMaterialSpecification;
|
||||
|
||||
/**
|
||||
* 原材料钢种(联查字段)
|
||||
*/
|
||||
private String rawMaterialSteelGrade;
|
||||
|
||||
/**
|
||||
* 原材料厚度(联查字段)
|
||||
*/
|
||||
private BigDecimal rawMaterialThickness;
|
||||
|
||||
/**
|
||||
* 原材料宽度(联查字段)
|
||||
*/
|
||||
private BigDecimal rawMaterialWidth;
|
||||
|
||||
/**
|
||||
* 原材料BOM ID(联查字段)
|
||||
*/
|
||||
private Long rawMaterialBomId;
|
||||
|
||||
/**
|
||||
* 产品ID(联查字段)
|
||||
*/
|
||||
private Long productId;
|
||||
|
||||
/**
|
||||
* 产品编号(联查字段)
|
||||
*/
|
||||
private String productCode;
|
||||
|
||||
/**
|
||||
* 产品名称(联查字段)
|
||||
*/
|
||||
private String productName;
|
||||
|
||||
/**
|
||||
* 产品规格(联查字段)
|
||||
*/
|
||||
private String productSpecification;
|
||||
|
||||
/**
|
||||
* 产品厚度(联查字段)
|
||||
*/
|
||||
private BigDecimal productThickness;
|
||||
|
||||
/**
|
||||
* 产品宽度(联查字段)
|
||||
*/
|
||||
private BigDecimal productWidth;
|
||||
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@ExcelProperty(value = "发货时间")
|
||||
private Date exportTime;
|
||||
|
||||
/**
|
||||
* 产品BOM ID(联查字段)
|
||||
*/
|
||||
private Long productBomId;
|
||||
|
||||
private String specification; // 规格
|
||||
private String material; // 材质
|
||||
@@ -351,90 +260,13 @@ public class WmsMaterialCoilVo extends BaseEntity {
|
||||
*/
|
||||
private Integer furnaceLevel;
|
||||
|
||||
// ========== 发货绑定信息(由发货单明细占用) ==========
|
||||
|
||||
/**
|
||||
* 是否已被发货单明细绑定(true=不可再次绑定)
|
||||
*/
|
||||
private Boolean bound;
|
||||
|
||||
private Long bindDetailId;
|
||||
|
||||
private Long bindWaybillId;
|
||||
private String bindWaybillNo;
|
||||
private String bindWaybillName;
|
||||
|
||||
private Long bindPlanId;
|
||||
private String bindPlanName;
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
private Date bindPlanDate;
|
||||
|
||||
// 父钢卷id
|
||||
private String parentCoilId;
|
||||
|
||||
// ========== 补充的发货绑定信息字段 ==========
|
||||
/**
|
||||
* 车牌号
|
||||
*/
|
||||
private String bindLicensePlate;
|
||||
|
||||
/**
|
||||
* 收货单位
|
||||
*/
|
||||
private String bindConsigneeUnit;
|
||||
|
||||
/**
|
||||
* 发货单位
|
||||
*/
|
||||
private String bindSenderUnit;
|
||||
|
||||
/**
|
||||
* 发货时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date bindDeliveryTime;
|
||||
|
||||
/**
|
||||
* 地磅
|
||||
*/
|
||||
private String bindWeighbridge;
|
||||
|
||||
/**
|
||||
* 销售人员
|
||||
*/
|
||||
private String bindSalesPerson;
|
||||
|
||||
/**
|
||||
* 负责人
|
||||
*/
|
||||
private String bindPrincipal;
|
||||
|
||||
/**
|
||||
* 负责人电话
|
||||
*/
|
||||
private String bindPrincipalPhone;
|
||||
|
||||
/**
|
||||
* 运单状态
|
||||
*/
|
||||
private Long bindWaybillStatus;
|
||||
|
||||
/**
|
||||
* 运单备注
|
||||
*/
|
||||
private String bindWaybillRemark;
|
||||
|
||||
/**
|
||||
* 明细结算类型
|
||||
*/
|
||||
private String bindDetailSettlementType;
|
||||
|
||||
/**
|
||||
* 明细单价
|
||||
*/
|
||||
private BigDecimal bindDetailUnitPrice;
|
||||
|
||||
/**
|
||||
* 实测长度
|
||||
*/
|
||||
|
||||
@@ -31,6 +31,11 @@ public interface IWmsMaterialCoilService {
|
||||
*/
|
||||
TableDataInfo<WmsMaterialCoilVo> queryPageList(WmsMaterialCoilBo bo, PageQuery pageQuery);
|
||||
|
||||
/**
|
||||
* 查询钢卷物料表列表(包含发货单明细绑定信息)
|
||||
*/
|
||||
TableDataInfo<WmsMaterialCoilBindVo> queryPageListWithBindInfo(WmsMaterialCoilBo bo, PageQuery pageQuery);
|
||||
|
||||
/**
|
||||
* 查询钢卷物料表列表
|
||||
*/
|
||||
|
||||
@@ -19,8 +19,6 @@ import com.klp.domain.bo.WmsCoilWarehouseOperationLogBo;
|
||||
import com.klp.domain.vo.WmsCoilWarehouseOperationLogVo;
|
||||
import com.klp.domain.vo.WmsCoilWarehouseOperationLogExportVo;
|
||||
import com.klp.domain.vo.WmsMaterialCoilVo;
|
||||
import com.klp.domain.vo.WmsRawMaterialVo;
|
||||
import com.klp.domain.vo.WmsProductVo;
|
||||
import com.klp.domain.WmsCoilWarehouseOperationLog;
|
||||
import com.klp.mapper.WmsCoilWarehouseOperationLogMapper;
|
||||
import com.klp.service.IWmsCoilWarehouseOperationLogService;
|
||||
@@ -149,35 +147,7 @@ public class WmsCoilWarehouseOperationLogServiceImpl implements IWmsCoilWarehous
|
||||
}
|
||||
|
||||
private void buildItemObjectFromJoin(WmsMaterialCoilVo vo) {
|
||||
if (vo.getItemId() == null || vo.getItemType() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ("raw_material".equals(vo.getItemType())) {
|
||||
WmsRawMaterialVo rawMaterial = new WmsRawMaterialVo();
|
||||
rawMaterial.setRawMaterialId(vo.getItemId());
|
||||
rawMaterial.setRawMaterialCode(vo.getItemCode());
|
||||
rawMaterial.setRawMaterialName(vo.getItemName());
|
||||
rawMaterial.setSpecification(vo.getSpecification());
|
||||
rawMaterial.setMaterial(vo.getMaterial());
|
||||
rawMaterial.setManufacturer(vo.getManufacturer());
|
||||
rawMaterial.setSurfaceTreatmentDesc(vo.getSurfaceTreatmentDesc());
|
||||
rawMaterial.setZincLayer(vo.getZincLayer());
|
||||
vo.setRawMaterial(rawMaterial);
|
||||
}
|
||||
|
||||
if ("product".equals(vo.getItemType())) {
|
||||
WmsProductVo product = new WmsProductVo();
|
||||
product.setProductId(vo.getItemId());
|
||||
product.setProductCode(vo.getItemCode());
|
||||
product.setProductName(vo.getItemName());
|
||||
product.setSpecification(vo.getSpecification());
|
||||
product.setMaterial(vo.getMaterial());
|
||||
product.setManufacturer(vo.getManufacturer());
|
||||
product.setSurfaceTreatmentDesc(vo.getSurfaceTreatmentDesc());
|
||||
product.setZincLayer(vo.getZincLayer());
|
||||
vo.setProduct(product);
|
||||
}
|
||||
// no-op: WmsMaterialCoilVo 改为仅返回扁平字段,不再构建嵌套对象
|
||||
}
|
||||
|
||||
private Set<Long> getAllChildWarehouseIds(Long parentId) {
|
||||
|
||||
@@ -69,7 +69,7 @@ public class WmsMaterialCoilServiceImpl implements IWmsMaterialCoilService {
|
||||
private final IWmsWarehouseService warehouseService;
|
||||
private final IWmsActualWarehouseService actualWarehouseService;
|
||||
private final IWmsRawMaterialService rawMaterialService;
|
||||
private final IWmsBomItemService bomItemService;
|
||||
// private final IWmsBomItemService bomItemService;
|
||||
private final IWmsCoilPendingActionService coilPendingActionService;
|
||||
private final WmsCoilPendingActionMapper coilPendingActionMapper;
|
||||
private final IWmsProductService productService;
|
||||
@@ -198,18 +198,6 @@ public class WmsMaterialCoilServiceImpl implements IWmsMaterialCoilService {
|
||||
}
|
||||
}
|
||||
|
||||
// 批量查询BOM信息
|
||||
Map<Long, List<WmsBomItemVo>> bomItemMap = new HashMap<>();
|
||||
if (!bomIds.isEmpty()) {
|
||||
for (Long bomId : bomIds) {
|
||||
WmsBomItemBo bomItemBo = new WmsBomItemBo();
|
||||
bomItemBo.setBomId(bomId);
|
||||
List<WmsBomItemVo> bomItemList = bomItemService.queryList(bomItemBo);
|
||||
if (bomItemList != null && !bomItemList.isEmpty()) {
|
||||
bomItemMap.put(bomId, bomItemList);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 填充到VO对象中
|
||||
for (WmsMaterialCoilVo vo : voList) {
|
||||
@@ -228,17 +216,24 @@ public class WmsMaterialCoilServiceImpl implements IWmsMaterialCoilService {
|
||||
}
|
||||
if ("raw_material".equals(vo.getItemType()) && vo.getItemId() != null && rawMaterialMap.containsKey(vo.getItemId())) {
|
||||
WmsRawMaterialVo rawMaterial = rawMaterialMap.get(vo.getItemId());
|
||||
vo.setRawMaterial(rawMaterial);
|
||||
if (rawMaterial.getBomId() != null && bomItemMap.containsKey(rawMaterial.getBomId())) {
|
||||
vo.setBomItemList(bomItemMap.get(rawMaterial.getBomId()));
|
||||
}
|
||||
vo.setItemName(rawMaterial.getRawMaterialName());
|
||||
vo.setItemCode(rawMaterial.getRawMaterialCode());
|
||||
vo.setSpecification(rawMaterial.getSpecification());
|
||||
vo.setMaterial(rawMaterial.getMaterial());
|
||||
vo.setManufacturer(rawMaterial.getManufacturer());
|
||||
vo.setSurfaceTreatmentDesc(rawMaterial.getSurfaceTreatmentDesc());
|
||||
vo.setZincLayer(rawMaterial.getZincLayer());
|
||||
}
|
||||
if ("product".equals(vo.getItemType()) && vo.getItemId() != null && productMap.containsKey(vo.getItemId())) {
|
||||
WmsProductVo product = productMap.get(vo.getItemId());
|
||||
vo.setProduct(product);
|
||||
if (product.getBomId() != null && bomItemMap.containsKey(product.getBomId())) {
|
||||
vo.setBomItemList(bomItemMap.get(product.getBomId()));
|
||||
}
|
||||
vo.setItemId(product.getProductId());
|
||||
vo.setItemName(product.getProductName());
|
||||
vo.setItemCode(product.getProductCode());
|
||||
vo.setSpecification(product.getSpecification());
|
||||
vo.setMaterial(product.getMaterial());
|
||||
vo.setManufacturer(product.getManufacturer());
|
||||
vo.setSurfaceTreatmentDesc(product.getSurfaceTreatmentDesc());
|
||||
vo.setZincLayer(product.getZincLayer());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -273,31 +268,38 @@ public class WmsMaterialCoilServiceImpl implements IWmsMaterialCoilService {
|
||||
vo.setQrcodeRecord(qrcodeRecord);
|
||||
}
|
||||
|
||||
// 查询原材料信息(当itemType为raw_material时)
|
||||
// 查询原材料并直接回填扁平字段(避免返回嵌套对象)
|
||||
if ("raw_material".equals(vo.getItemType()) && vo.getItemId() != null) {
|
||||
WmsRawMaterialVo rawMaterial = rawMaterialService.queryById(vo.getItemId());
|
||||
vo.setRawMaterial(rawMaterial);
|
||||
|
||||
// 查询原材料对应的BOM信息(通过bomId查询BomItem列表)
|
||||
if (rawMaterial != null && rawMaterial.getBomId() != null) {
|
||||
WmsBomItemBo bomItemBo = new WmsBomItemBo();
|
||||
bomItemBo.setBomId(rawMaterial.getBomId());
|
||||
List<WmsBomItemVo> bomItemList = bomItemService.queryList(bomItemBo);
|
||||
vo.setBomItemList(bomItemList);
|
||||
if (rawMaterial != null) {
|
||||
vo.setItemName(rawMaterial.getRawMaterialName());
|
||||
vo.setItemCode(rawMaterial.getRawMaterialCode());
|
||||
vo.setSpecification(rawMaterial.getSpecification());
|
||||
vo.setMaterial(rawMaterial.getMaterial());
|
||||
vo.setManufacturer(rawMaterial.getManufacturer());
|
||||
vo.setSurfaceTreatmentDesc(rawMaterial.getSurfaceTreatmentDesc());
|
||||
// 锌层
|
||||
if (rawMaterial.getZincLayer() != null) {
|
||||
vo.setZincLayer(rawMaterial.getZincLayer());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 查询产品信息(当itemType为product时)
|
||||
// 查询产品并直接回填扁平字段(避免返回嵌套对象)
|
||||
if ("product".equals(vo.getItemType()) && vo.getItemId() != null) {
|
||||
WmsProductVo product = productService.queryById(vo.getItemId());
|
||||
vo.setProduct(product);
|
||||
|
||||
// 查询产品对应的BOM信息(通过bomId查询BomItem列表)
|
||||
if (product != null && product.getBomId() != null) {
|
||||
WmsBomItemBo bomItemBo = new WmsBomItemBo();
|
||||
bomItemBo.setBomId(product.getBomId());
|
||||
List<WmsBomItemVo> bomItemList = bomItemService.queryList(bomItemBo);
|
||||
vo.setBomItemList(bomItemList);
|
||||
if (product != null) {
|
||||
vo.setItemId(product.getProductId());
|
||||
vo.setItemName(product.getProductName());
|
||||
vo.setItemCode(product.getProductCode());
|
||||
vo.setSpecification(product.getSpecification());
|
||||
vo.setMaterial(product.getMaterial());
|
||||
vo.setManufacturer(product.getManufacturer());
|
||||
vo.setSurfaceTreatmentDesc(product.getSurfaceTreatmentDesc());
|
||||
// 锌层
|
||||
if (product.getZincLayer() != null) {
|
||||
vo.setZincLayer(product.getZincLayer());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -307,6 +309,38 @@ public class WmsMaterialCoilServiceImpl implements IWmsMaterialCoilService {
|
||||
*/
|
||||
@Override
|
||||
public TableDataInfo<WmsMaterialCoilVo> queryPageList(WmsMaterialCoilBo bo, PageQuery pageQuery) {
|
||||
Page<WmsMaterialCoilVo> result = queryMaterialCoilPage(bo, pageQuery);
|
||||
List<WmsMaterialCoilVo> records = result.getRecords();
|
||||
if (records == null || records.isEmpty()) {
|
||||
return TableDataInfo.build(result);
|
||||
}
|
||||
fillPageCommonFields(records);
|
||||
return TableDataInfo.build(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TableDataInfo<WmsMaterialCoilBindVo> queryPageListWithBindInfo(WmsMaterialCoilBo bo, PageQuery pageQuery) {
|
||||
Page<WmsMaterialCoilVo> result = queryMaterialCoilPage(bo, pageQuery);
|
||||
List<WmsMaterialCoilVo> baseRecords = result.getRecords();
|
||||
if (baseRecords == null || baseRecords.isEmpty()) {
|
||||
return TableDataInfo.build(new Page<>(result.getCurrent(), result.getSize(), result.getTotal()));
|
||||
}
|
||||
|
||||
List<WmsMaterialCoilBindVo> bindRecords = baseRecords.stream().map(item -> {
|
||||
WmsMaterialCoilBindVo bindVo = new WmsMaterialCoilBindVo();
|
||||
BeanUtil.copyProperties(item, bindVo);
|
||||
return bindVo;
|
||||
}).collect(Collectors.toList());
|
||||
|
||||
fillBindInfoForPage(bindRecords);
|
||||
fillPageCommonFields(bindRecords);
|
||||
|
||||
Page<WmsMaterialCoilBindVo> bindResult = new Page<>(result.getCurrent(), result.getSize(), result.getTotal());
|
||||
bindResult.setRecords(bindRecords);
|
||||
return TableDataInfo.build(bindResult);
|
||||
}
|
||||
|
||||
private Page<WmsMaterialCoilVo> queryMaterialCoilPage(WmsMaterialCoilBo bo, PageQuery pageQuery) {
|
||||
QueryWrapper<WmsMaterialCoil> qw = buildQueryWrapperPlus(bo);
|
||||
Page<WmsMaterialCoilVo> result;
|
||||
if (Boolean.TRUE.equals(bo.getOrderBy())) {
|
||||
@@ -314,67 +348,10 @@ public class WmsMaterialCoilServiceImpl implements IWmsMaterialCoilService {
|
||||
} else {
|
||||
result = baseMapper.selectVoPagePlus(pageQuery.build(), qw);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
List<WmsMaterialCoilVo> records = result.getRecords();
|
||||
if (records == null || records.isEmpty()) {
|
||||
return TableDataInfo.build(result);
|
||||
}
|
||||
|
||||
// 批量查询当前页钢卷的“发货单明细绑定”信息(用于禁选/置灰/提示来源)
|
||||
// 仅当前端明确需要时才查询,避免不必要的性能开销
|
||||
if (Boolean.TRUE.equals(bo.getIncludeBindInfo())) {
|
||||
try {
|
||||
List<Long> coilIds = records.stream()
|
||||
.map(WmsMaterialCoilVo::getCoilId)
|
||||
.filter(Objects::nonNull)
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
|
||||
if (!coilIds.isEmpty()) {
|
||||
Map<Long, WmsCoilBindInfoVo> bindMap = deliveryWaybillDetailMapper
|
||||
.selectBindInfoByCoilIds(coilIds)
|
||||
.stream()
|
||||
.collect(Collectors.toMap(
|
||||
WmsCoilBindInfoVo::getCoilId,
|
||||
v -> v,
|
||||
(a, b) -> a
|
||||
));
|
||||
|
||||
for (WmsMaterialCoilVo vo : records) {
|
||||
WmsCoilBindInfoVo bind = bindMap.get(vo.getCoilId());
|
||||
if (bind != null) {
|
||||
vo.setBound(Boolean.TRUE);
|
||||
vo.setBindDetailId(bind.getDetailId());
|
||||
vo.setBindWaybillId(bind.getWaybillId());
|
||||
vo.setBindWaybillNo(bind.getWaybillNo());
|
||||
vo.setBindWaybillName(bind.getWaybillName());
|
||||
vo.setBindPlanId(bind.getPlanId());
|
||||
vo.setBindPlanName(bind.getPlanName());
|
||||
vo.setBindPlanDate(bind.getPlanDate());
|
||||
|
||||
// 补充设置更多的绑定信息字段
|
||||
vo.setBindLicensePlate(bind.getLicensePlate());
|
||||
vo.setBindConsigneeUnit(bind.getConsigneeUnit());
|
||||
vo.setBindSenderUnit(bind.getSenderUnit());
|
||||
vo.setBindDeliveryTime(bind.getDeliveryTime());
|
||||
vo.setBindWeighbridge(bind.getWeighbridge());
|
||||
vo.setBindSalesPerson(bind.getSalesPerson());
|
||||
vo.setBindPrincipal(bind.getPrincipal());
|
||||
vo.setBindPrincipalPhone(bind.getPrincipalPhone());
|
||||
vo.setBindWaybillStatus(bind.getWaybillStatus());
|
||||
vo.setBindWaybillRemark(bind.getWaybillRemark());
|
||||
vo.setBindDetailSettlementType(bind.getDetailSettlementType());
|
||||
vo.setBindDetailUnitPrice(bind.getDetailUnitPrice());
|
||||
} else {
|
||||
vo.setBound(Boolean.FALSE);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception ignore) {
|
||||
// 绑定信息属于增强字段,查询失败时不影响钢卷列表主流程
|
||||
}
|
||||
}
|
||||
|
||||
private void fillPageCommonFields(List<? extends WmsMaterialCoilVo> records) {
|
||||
Set<String> userNames = records.stream()
|
||||
.flatMap(v -> java.util.stream.Stream.of(v.getCreateBy(), v.getUpdateBy(), v.getExportBy()))
|
||||
.filter(StringUtils::isNotBlank)
|
||||
@@ -398,11 +375,61 @@ public class WmsMaterialCoilServiceImpl implements IWmsMaterialCoilService {
|
||||
vo.setExportByName(nickMap.getOrDefault(vo.getExportBy(), vo.getExportBy()));
|
||||
}
|
||||
}
|
||||
// 从联查结果中构建产品和原材料对象(避免单独查询)
|
||||
buildItemObjectFromJoin(vo);
|
||||
}
|
||||
}
|
||||
|
||||
return TableDataInfo.build(result);
|
||||
private void fillBindInfoForPage(List<WmsMaterialCoilBindVo> records) {
|
||||
// 绑定信息仅用于专用接口,避免污染通用分页结构
|
||||
try {
|
||||
List<Long> coilIds = records.stream()
|
||||
.map(WmsMaterialCoilVo::getCoilId)
|
||||
.filter(Objects::nonNull)
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
|
||||
if (coilIds.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Map<Long, WmsCoilBindInfoVo> bindMap = deliveryWaybillDetailMapper
|
||||
.selectBindInfoByCoilIds(coilIds)
|
||||
.stream()
|
||||
.collect(Collectors.toMap(
|
||||
WmsCoilBindInfoVo::getCoilId,
|
||||
v -> v,
|
||||
(a, b) -> a
|
||||
));
|
||||
|
||||
for (WmsMaterialCoilBindVo vo : records) {
|
||||
WmsCoilBindInfoVo bind = bindMap.get(vo.getCoilId());
|
||||
if (bind != null) {
|
||||
vo.setBound(Boolean.TRUE);
|
||||
vo.setBindDetailId(bind.getDetailId());
|
||||
vo.setBindWaybillId(bind.getWaybillId());
|
||||
vo.setBindWaybillNo(bind.getWaybillNo());
|
||||
vo.setBindWaybillName(bind.getWaybillName());
|
||||
vo.setBindPlanId(bind.getPlanId());
|
||||
vo.setBindPlanName(bind.getPlanName());
|
||||
vo.setBindPlanDate(bind.getPlanDate());
|
||||
vo.setBindLicensePlate(bind.getLicensePlate());
|
||||
vo.setBindConsigneeUnit(bind.getConsigneeUnit());
|
||||
vo.setBindSenderUnit(bind.getSenderUnit());
|
||||
vo.setBindDeliveryTime(bind.getDeliveryTime());
|
||||
vo.setBindWeighbridge(bind.getWeighbridge());
|
||||
vo.setBindSalesPerson(bind.getSalesPerson());
|
||||
vo.setBindPrincipal(bind.getPrincipal());
|
||||
vo.setBindPrincipalPhone(bind.getPrincipalPhone());
|
||||
vo.setBindWaybillStatus(bind.getWaybillStatus());
|
||||
vo.setBindWaybillRemark(bind.getWaybillRemark());
|
||||
vo.setBindDetailSettlementType(bind.getDetailSettlementType());
|
||||
vo.setBindDetailUnitPrice(bind.getDetailUnitPrice());
|
||||
} else {
|
||||
vo.setBound(Boolean.FALSE);
|
||||
}
|
||||
}
|
||||
} catch (Exception ignore) {
|
||||
// 绑定信息属于增强字段,查询失败时不影响钢卷列表主流程
|
||||
}
|
||||
}
|
||||
|
||||
private QueryWrapper<WmsMaterialCoil> buildQueryWrapperPlus(WmsMaterialCoilBo bo) {
|
||||
@@ -959,41 +986,10 @@ public class WmsMaterialCoilServiceImpl implements IWmsMaterialCoilService {
|
||||
}
|
||||
|
||||
/**
|
||||
* 从联查结果中构建物品对象(产品或原材料)
|
||||
* 直接从VO的临时字段中获取数据构建对象,避免单独查询数据库
|
||||
* 联查场景下数据已经是扁平字段,无需再构建 rawMaterial/product 嵌套对象。
|
||||
*/
|
||||
private void buildItemObjectFromJoin(WmsMaterialCoilVo vo) {
|
||||
if (vo.getItemId() == null || vo.getItemType() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 构建原材料对象
|
||||
if ("raw_material".equals(vo.getItemType())) {
|
||||
WmsRawMaterialVo rawMaterial = new WmsRawMaterialVo();
|
||||
rawMaterial.setRawMaterialId(vo.getItemId());
|
||||
rawMaterial.setRawMaterialCode(vo.getItemCode());
|
||||
rawMaterial.setRawMaterialName(vo.getItemName());
|
||||
rawMaterial.setSpecification(vo.getSpecification());
|
||||
rawMaterial.setMaterial(vo.getMaterial());
|
||||
rawMaterial.setManufacturer(vo.getManufacturer());
|
||||
rawMaterial.setSurfaceTreatmentDesc(vo.getSurfaceTreatmentDesc());
|
||||
rawMaterial.setZincLayer(vo.getZincLayer());
|
||||
vo.setRawMaterial(rawMaterial);
|
||||
}
|
||||
|
||||
// 构建产品对象
|
||||
if ("product".equals(vo.getItemType())) {
|
||||
WmsProductVo product = new WmsProductVo();
|
||||
product.setProductId(vo.getItemId());
|
||||
product.setProductCode(vo.getItemCode());
|
||||
product.setProductName(vo.getItemName());
|
||||
product.setSpecification(vo.getSpecification());
|
||||
product.setMaterial(vo.getMaterial());
|
||||
product.setManufacturer(vo.getManufacturer());
|
||||
product.setSurfaceTreatmentDesc(vo.getSurfaceTreatmentDesc());
|
||||
product.setZincLayer(vo.getZincLayer());
|
||||
vo.setProduct(product);
|
||||
}
|
||||
// no-op
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2397,27 +2393,13 @@ public class WmsMaterialCoilServiceImpl implements IWmsMaterialCoilService {
|
||||
voList.add(vo);
|
||||
return;
|
||||
}
|
||||
if ("raw_material".equals(itemType)) {
|
||||
WmsRawMaterialVo rawMaterial = new WmsRawMaterialVo();
|
||||
rawMaterial.setRawMaterialName(map.get("itemName") != null ? map.get("itemName").toString() : null);
|
||||
rawMaterial.setRawMaterialCode(map.get("itemCode") != null ? map.get("itemCode").toString() : null);
|
||||
rawMaterial.setSpecification(map.get("specification") != null ? map.get("specification").toString() : null);
|
||||
rawMaterial.setMaterial(map.get("material") != null ? map.get("material").toString() : null);
|
||||
rawMaterial.setSurfaceTreatmentDesc(map.get("surfaceTreatmentDesc") != null ? map.get("surfaceTreatmentDesc").toString() : null);
|
||||
rawMaterial.setZincLayer(map.get("zincLayer") != null ? map.get("zincLayer").toString() : null);
|
||||
rawMaterial.setManufacturer(map.get("manufacturer") != null ? map.get("manufacturer").toString() : null);
|
||||
vo.setRawMaterial(rawMaterial);
|
||||
} else if ("product".equals(itemType)) {
|
||||
WmsProductVo product = new WmsProductVo();
|
||||
product.setProductName(map.get("itemName") != null ? map.get("itemName").toString() : null);
|
||||
product.setProductCode(map.get("itemCode") != null ? map.get("itemCode").toString() : null);
|
||||
product.setSpecification(map.get("specification") != null ? map.get("specification").toString() : null);
|
||||
product.setMaterial(map.get("material") != null ? map.get("material").toString() : null);
|
||||
product.setSurfaceTreatmentDesc(map.get("surfaceTreatmentDesc") != null ? map.get("surfaceTreatmentDesc").toString() : null);
|
||||
product.setZincLayer(map.get("zincLayer") != null ? map.get("zincLayer").toString() : null);
|
||||
product.setManufacturer(map.get("manufacturer") != null ? map.get("manufacturer").toString() : null);
|
||||
vo.setProduct(product);
|
||||
}
|
||||
vo.setItemName(map.get("itemName") != null ? map.get("itemName").toString() : null);
|
||||
vo.setItemCode(map.get("itemCode") != null ? map.get("itemCode").toString() : null);
|
||||
vo.setSpecification(map.get("specification") != null ? map.get("specification").toString() : null);
|
||||
vo.setMaterial(map.get("material") != null ? map.get("material").toString() : null);
|
||||
vo.setSurfaceTreatmentDesc(map.get("surfaceTreatmentDesc") != null ? map.get("surfaceTreatmentDesc").toString() : null);
|
||||
vo.setZincLayer(map.get("zincLayer") != null ? map.get("zincLayer").toString() : null);
|
||||
vo.setManufacturer(map.get("manufacturer") != null ? map.get("manufacturer").toString() : null);
|
||||
voList.add(vo);
|
||||
}
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user