refactor(wms): 重构物料卷服务中的VO设置逻辑
- 提取重复代码到独立方法 setSubMaterialVo - 根据 itemType 动态设置原材料或产品信息 - 避免在多个地方重复设置相同的字段值 - 简化主逻辑,提高代码可读性和维护性
This commit is contained in:
@@ -1480,14 +1480,8 @@ public class WmsMaterialCoilServiceImpl implements IWmsMaterialCoilService {
|
|||||||
vo.setCoilCount(map.get("coil_count") != null ? Long.valueOf(map.get("coil_count").toString()) : 0L);
|
vo.setCoilCount(map.get("coil_count") != null ? Long.valueOf(map.get("coil_count").toString()) : 0L);
|
||||||
vo.setTotalGrossWeight(map.get("total_gross_weight") != null ? new BigDecimal(map.get("total_gross_weight").toString()) : BigDecimal.ZERO);
|
vo.setTotalGrossWeight(map.get("total_gross_weight") != null ? new BigDecimal(map.get("total_gross_weight").toString()) : BigDecimal.ZERO);
|
||||||
vo.setTotalNetWeight(map.get("total_net_weight") != null ? new BigDecimal(map.get("total_net_weight").toString()) : BigDecimal.ZERO);
|
vo.setTotalNetWeight(map.get("total_net_weight") != null ? new BigDecimal(map.get("total_net_weight").toString()) : BigDecimal.ZERO);
|
||||||
vo.setItemName(map.get("itemName") != null ? map.get("itemName").toString() : null);
|
|
||||||
vo.setItemCode(map.get("itemCode") != null ? map.get("itemCode").toString() : null);
|
setSubMaterialVo(vo, map, voList);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
return voList;
|
return voList;
|
||||||
}
|
}
|
||||||
@@ -1519,18 +1513,39 @@ public class WmsMaterialCoilServiceImpl implements IWmsMaterialCoilService {
|
|||||||
vo.setCoilCount(map.get("coil_count") != null ? Long.valueOf(map.get("coil_count").toString()) : 0L);
|
vo.setCoilCount(map.get("coil_count") != null ? Long.valueOf(map.get("coil_count").toString()) : 0L);
|
||||||
vo.setTotalGrossWeight(map.get("total_gross_weight") != null ? new BigDecimal(map.get("total_gross_weight").toString()) : BigDecimal.ZERO);
|
vo.setTotalGrossWeight(map.get("total_gross_weight") != null ? new BigDecimal(map.get("total_gross_weight").toString()) : BigDecimal.ZERO);
|
||||||
vo.setTotalNetWeight(map.get("total_net_weight") != null ? new BigDecimal(map.get("total_net_weight").toString()) : BigDecimal.ZERO);
|
vo.setTotalNetWeight(map.get("total_net_weight") != null ? new BigDecimal(map.get("total_net_weight").toString()) : BigDecimal.ZERO);
|
||||||
vo.setItemName(map.get("itemName") != null ? map.get("itemName").toString() : null);
|
setSubMaterialVo(vo, map, voList);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
return voList;
|
return voList;
|
||||||
}
|
}
|
||||||
|
private void setSubMaterialVo(WmsMaterialCoilVo vo, Map<String, Object> map, List<WmsMaterialCoilVo> voList) {
|
||||||
|
String itemType = vo.getItemType();
|
||||||
|
if (itemType == null) {
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
voList.add(vo);
|
||||||
|
}
|
||||||
@Override
|
@Override
|
||||||
public List<WmsMaterialCoilVo> getDistributionByActualItemType(String itemType, Long itemId) {
|
public List<WmsMaterialCoilVo> getDistributionByActualItemType(String itemType, Long itemId) {
|
||||||
List<Map<String, Object>> mapList = baseMapper.getDistributionByActualItemType(itemType, itemId);
|
List<Map<String, Object>> mapList = baseMapper.getDistributionByActualItemType(itemType, itemId);
|
||||||
|
|||||||
Reference in New Issue
Block a user