feat(wms): 增加根据实际库区查询钢卷分布的接口及相关字段
This commit is contained in:
@@ -158,5 +158,17 @@ public class WmsMaterialCoilController extends BaseController {
|
||||
List<WmsMaterialCoilVo> distribution = iWmsMaterialCoilService.getDistributionByItemType(itemType, itemId);
|
||||
return R.ok(distribution);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询不同类型的钢卷在不同库区的分布情况
|
||||
* 按物品类型和物品ID分组,统计每个库区的钢卷数量和重量
|
||||
*/
|
||||
@GetMapping("/distributionByActualItemType")
|
||||
public R<List<WmsMaterialCoilVo>> getDistributionByActualItemType(
|
||||
@RequestParam(required = false) String itemType,
|
||||
@RequestParam(required = false) Long itemId) {
|
||||
List<WmsMaterialCoilVo> distribution = iWmsMaterialCoilService.getDistributionByActualItemType(itemType, itemId);
|
||||
return R.ok(distribution);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -212,81 +212,87 @@ 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;
|
||||
|
||||
|
||||
/**
|
||||
* 产品BOM ID(联查字段)
|
||||
*/
|
||||
private Long productBomId;
|
||||
|
||||
private String specification; // 规格
|
||||
private String material; // 材质
|
||||
private String surfaceTreatmentDesc; // 表面处理
|
||||
private String zincLayer; // 锌层
|
||||
private String manufacturer; // 厂家
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -43,5 +43,7 @@ public interface WmsMaterialCoilMapper extends BaseMapperPlus<WmsMaterialCoilMap
|
||||
List<WmsMaterialCoilVo> selectVoListWithDynamicJoin(@Param("ew")QueryWrapper<WmsMaterialCoil> lqw);
|
||||
|
||||
List<Map<String, Object>> getDistributionByActualWarehouse(@Param("itemType") String itemType, @Param("itemId") Long itemId);
|
||||
|
||||
List<Map<String, Object>> getDistributionByActualItemType(@Param("itemType")String itemType,@Param("itemId") Long itemId);
|
||||
}
|
||||
|
||||
|
||||
@@ -86,5 +86,7 @@ public interface IWmsMaterialCoilService {
|
||||
List<WmsMaterialCoilVo> getDistributionByItemType(String itemType, Long itemId);
|
||||
|
||||
List<WmsMaterialCoilVo> getDistributionByActualWarehouse(String itemType, Long itemId);
|
||||
|
||||
List<WmsMaterialCoilVo> getDistributionByActualItemType(String itemType, Long itemId);
|
||||
}
|
||||
|
||||
|
||||
@@ -39,14 +39,8 @@ import com.klp.domain.vo.WmsActualWarehouseVo;
|
||||
import com.klp.domain.vo.WmsProductVo;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Collection;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
@@ -1233,12 +1227,12 @@ public class WmsMaterialCoilServiceImpl implements IWmsMaterialCoilService {
|
||||
LambdaQueryWrapper<com.klp.domain.WmsGenerateRecord> splitWrapper = Wrappers.lambdaQuery();
|
||||
splitWrapper.like(com.klp.domain.WmsGenerateRecord::getSerialNumber, enterCoilNo + "-");
|
||||
List<WmsGenerateRecordVo> splitRecords = generateRecordMapper.selectVoList(splitWrapper);
|
||||
|
||||
|
||||
// 去重:使用recordId作为唯一标识
|
||||
Set<Long> existingRecordIds = allQrRecords.stream()
|
||||
.map(WmsGenerateRecordVo::getRecordId)
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
|
||||
for (WmsGenerateRecordVo record : splitRecords) {
|
||||
if (record.getRecordId() != null && !existingRecordIds.contains(record.getRecordId())) {
|
||||
allQrRecords.add(record);
|
||||
@@ -1252,7 +1246,7 @@ public class WmsMaterialCoilServiceImpl implements IWmsMaterialCoilService {
|
||||
|
||||
// 优化2: ObjectMapper在循环外创建,避免重复创建
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
|
||||
|
||||
// 2. 合并所有二维码的steps信息,去重并重新编号
|
||||
Map<String, Map<String, Object>> uniqueSteps = new HashMap<>(); // 用于去重
|
||||
Set<String> allCoilNos = new HashSet<>();
|
||||
@@ -1472,6 +1466,9 @@ public class WmsMaterialCoilServiceImpl implements IWmsMaterialCoilService {
|
||||
List<Map<String, Object>> mapList = baseMapper.getDistributionByActualWarehouse(itemType, itemId);
|
||||
return convertMapListToVoListActual(mapList);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private List<WmsMaterialCoilVo> convertMapListToVoListActual(List<Map<String, Object>> mapList) {
|
||||
List<WmsMaterialCoilVo> voList = new ArrayList<>();
|
||||
for (Map<String, Object> map : mapList) {
|
||||
@@ -1483,6 +1480,13 @@ public class WmsMaterialCoilServiceImpl implements IWmsMaterialCoilService {
|
||||
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.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);
|
||||
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;
|
||||
@@ -1515,9 +1519,22 @@ public class WmsMaterialCoilServiceImpl implements IWmsMaterialCoilService {
|
||||
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.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);
|
||||
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;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<WmsMaterialCoilVo> getDistributionByActualItemType(String itemType, Long itemId) {
|
||||
List<Map<String, Object>> mapList = baseMapper.getDistributionByActualItemType(itemType, itemId);
|
||||
return convertMapListToVoListActual(mapList);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -149,7 +149,32 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
WHEN mc.item_type = 'raw_material' THEN rm.raw_material_code
|
||||
WHEN mc.item_type = 'product' THEN p.product_code
|
||||
ELSE NULL
|
||||
END as itemCode
|
||||
END as itemCode,
|
||||
CASE
|
||||
WHEN mc.item_type = 'raw_material' THEN rm.specification
|
||||
WHEN mc.item_type = 'product' THEN p.specification
|
||||
ELSE NULL
|
||||
END as specification,
|
||||
CASE
|
||||
WHEN mc.item_type = 'raw_material' THEN rm.material
|
||||
WHEN mc.item_type = 'product' THEN p.material
|
||||
ELSE NULL
|
||||
END as material,
|
||||
CASE
|
||||
WHEN mc.item_type = 'raw_material' THEN rm.surface_treatment_desc
|
||||
WHEN mc.item_type = 'product' THEN p.surface_treatment_desc
|
||||
ELSE NULL
|
||||
END as surfaceTreatmentDesc,
|
||||
CASE
|
||||
WHEN mc.item_type = 'raw_material' THEN rm.zinc_layer
|
||||
WHEN mc.item_type = 'product' THEN p.zinc_layer
|
||||
ELSE NULL
|
||||
END as zincLayer,
|
||||
CASE
|
||||
WHEN mc.item_type = 'raw_material' THEN rm.manufacturer
|
||||
WHEN mc.item_type = 'product' THEN p.manufacturer
|
||||
ELSE NULL
|
||||
END as manufacturer
|
||||
FROM wms_material_coil mc
|
||||
LEFT JOIN wms_warehouse w ON mc.warehouse_id = w.warehouse_id
|
||||
LEFT JOIN wms_raw_material rm ON mc.item_type = 'raw_material' AND mc.item_id = rm.raw_material_id
|
||||
@@ -165,7 +190,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="itemId != null">
|
||||
AND mc.item_id = #{itemId}
|
||||
</if>
|
||||
GROUP BY mc.item_type, mc.item_id, w.warehouse_id, w.warehouse_name
|
||||
GROUP BY mc.item_type, mc.item_id, w.warehouse_id, w.warehouse_name, itemName, itemCode, specification, material,
|
||||
surfaceTreatmentDesc, zincLayer, manufacturer
|
||||
ORDER BY mc.item_type, mc.item_id, w.warehouse_id
|
||||
</select>
|
||||
<select id="selectVoListWithDynamicJoin" resultType="com.klp.domain.vo.WmsMaterialCoilVo">
|
||||
@@ -230,6 +256,69 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
GROUP BY w.actual_warehouse_id, w.actual_warehouse_name
|
||||
ORDER BY w.actual_warehouse_id
|
||||
</select>
|
||||
<select id="getDistributionByActualItemType" resultType="java.util.Map">
|
||||
SELECT
|
||||
mc.item_type,
|
||||
mc.item_id,
|
||||
w.actual_warehouse_id,
|
||||
w.actual_warehouse_name,
|
||||
COUNT(mc.coil_id) as coil_count,
|
||||
COALESCE(SUM(mc.gross_weight), 0) as total_gross_weight,
|
||||
COALESCE(SUM(mc.net_weight), 0) as total_net_weight,
|
||||
CASE
|
||||
WHEN mc.item_type = 'raw_material' THEN rm.raw_material_name
|
||||
WHEN mc.item_type = 'product' THEN p.product_name
|
||||
ELSE NULL
|
||||
END as itemName,
|
||||
CASE
|
||||
WHEN mc.item_type = 'raw_material' THEN rm.raw_material_code
|
||||
WHEN mc.item_type = 'product' THEN p.product_code
|
||||
ELSE NULL
|
||||
END as itemCode,
|
||||
CASE
|
||||
WHEN mc.item_type = 'raw_material' THEN rm.specification
|
||||
WHEN mc.item_type = 'product' THEN p.specification
|
||||
ELSE NULL
|
||||
END as specification,
|
||||
CASE
|
||||
WHEN mc.item_type = 'raw_material' THEN rm.material
|
||||
WHEN mc.item_type = 'product' THEN p.material
|
||||
ELSE NULL
|
||||
END as material,
|
||||
CASE
|
||||
WHEN mc.item_type = 'raw_material' THEN rm.surface_treatment_desc
|
||||
WHEN mc.item_type = 'product' THEN p.surface_treatment_desc
|
||||
ELSE NULL
|
||||
END as surfaceTreatmentDesc,
|
||||
CASE
|
||||
WHEN mc.item_type = 'raw_material' THEN rm.zinc_layer
|
||||
WHEN mc.item_type = 'product' THEN p.zinc_layer
|
||||
ELSE NULL
|
||||
END as zincLayer,
|
||||
CASE
|
||||
WHEN mc.item_type = 'raw_material' THEN rm.manufacturer
|
||||
WHEN mc.item_type = 'product' THEN p.manufacturer
|
||||
ELSE NULL
|
||||
END as manufacturer
|
||||
FROM wms_material_coil mc
|
||||
LEFT JOIN wms_actual_warehouse w ON mc.actual_warehouse_id = w.actual_warehouse_id
|
||||
LEFT JOIN wms_raw_material rm ON mc.item_type = 'raw_material' AND mc.item_id = rm.raw_material_id
|
||||
LEFT JOIN wms_product p ON mc.item_type = 'product' AND mc.item_id = p.product_id
|
||||
WHERE mc.data_type = 1
|
||||
AND mc.del_flag = '0'
|
||||
AND (w.del_flag = '0' OR w.del_flag IS NULL)
|
||||
and (mc.material_type='成品' or mc.material_type='原料')
|
||||
and mc.status!=1
|
||||
<if test="itemType != null and itemType != ''">
|
||||
AND mc.item_type = #{itemType}
|
||||
</if>
|
||||
<if test="itemId != null">
|
||||
AND mc.item_id = #{itemId}
|
||||
</if>
|
||||
GROUP BY mc.item_type, mc.item_id, w.actual_warehouse_id, w.actual_warehouse_name, itemName, itemCode, specification,
|
||||
material,surfaceTreatmentDesc, zincLayer, manufacturer
|
||||
ORDER BY mc.item_type, mc.item_id, w.actual_warehouse_id
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
||||
|
||||
Reference in New Issue
Block a user