新增双向统计接口

This commit is contained in:
2025-10-29 14:40:09 +08:00
parent 2c49f4d600
commit 3ca854f85f
5 changed files with 60 additions and 28 deletions

View File

@@ -125,21 +125,25 @@ public class WmsMaterialCoilController extends BaseController {
/**
* 查询各个库区中不同类型的钢卷分布情况
* 按库区分组,统计每种物品类型的钢卷数量和重量
* 按库区分组,统计每种物品类型和物品ID的钢卷数量和重量
*/
@GetMapping("/distributionByWarehouse")
public R<List<WmsMaterialCoilVo>> getDistributionByWarehouse() {
List<WmsMaterialCoilVo> distribution = iWmsMaterialCoilService.getDistributionByWarehouse();
public R<List<WmsMaterialCoilVo>> getDistributionByWarehouse(
@RequestParam(required = false) String itemType,
@RequestParam(required = false) Long itemId) {
List<WmsMaterialCoilVo> distribution = iWmsMaterialCoilService.getDistributionByWarehouse(itemType, itemId);
return R.ok(distribution);
}
/**
* 查询不同类型的钢卷在不同库区的分布情况
* 按物品类型分组,统计每个库区的钢卷数量和重量
* 按物品类型和物品ID分组,统计每个库区的钢卷数量和重量
*/
@GetMapping("/distributionByItemType")
public R<List<WmsMaterialCoilVo>> getDistributionByItemType() {
List<WmsMaterialCoilVo> distribution = iWmsMaterialCoilService.getDistributionByItemType();
public R<List<WmsMaterialCoilVo>> getDistributionByItemType(
@RequestParam(required = false) String itemType,
@RequestParam(required = false) Long itemId) {
List<WmsMaterialCoilVo> distribution = iWmsMaterialCoilService.getDistributionByItemType(itemType, itemId);
return R.ok(distribution);
}
}

View File

@@ -3,6 +3,7 @@ package com.klp.mapper;
import com.klp.domain.WmsMaterialCoil;
import com.klp.domain.vo.WmsMaterialCoilVo;
import com.klp.common.core.mapper.BaseMapperPlus;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
@@ -16,18 +17,22 @@ public interface WmsMaterialCoilMapper extends BaseMapperPlus<WmsMaterialCoilMap
/**
* 查询各个库区中不同类型的钢卷分布情况
* 按库区分组,统计每种物品类型的钢卷数量和重量
* 按库区分组,统计每种物品类型和物品ID的钢卷数量和重量
*
* @param itemType 物品类型(可选)
* @param itemId 物品ID可选
* @return 分布情况列表
*/
List<Map<String, Object>> getDistributionByWarehouse();
List<Map<String, Object>> getDistributionByWarehouse(@Param("itemType") String itemType, @Param("itemId") Long itemId);
/**
* 查询不同类型的钢卷在不同库区的分布情况
* 按物品类型分组,统计每个库区的钢卷数量和重量
* 按物品类型和物品ID分组,统计每个库区的钢卷数量和重量
*
* @param itemType 物品类型(可选)
* @param itemId 物品ID可选
* @return 分布情况列表
*/
List<Map<String, Object>> getDistributionByItemType();
List<Map<String, Object>> getDistributionByItemType(@Param("itemType") String itemType, @Param("itemId") Long itemId);
}

View File

@@ -67,18 +67,22 @@ public interface IWmsMaterialCoilService {
/**
* 查询各个库区中不同类型的钢卷分布情况
* 按库区分组,统计每种物品类型的钢卷数量和重量
* 按库区分组,统计每种物品类型和物品ID的钢卷数量和重量
*
* @return 分布情况列表,包含库区信息、物品类型、数量、重量等
* @param itemType 物品类型(可选)
* @param itemId 物品ID可选
* @return 分布情况列表包含库区信息、物品类型、物品ID、数量、重量等
*/
List<WmsMaterialCoilVo> getDistributionByWarehouse();
List<WmsMaterialCoilVo> getDistributionByWarehouse(String itemType, Long itemId);
/**
* 查询不同类型的钢卷在不同库区的分布情况
* 按物品类型分组,统计每个库区的钢卷数量和重量
* 按物品类型和物品ID分组,统计每个库区的钢卷数量和重量
*
* @return 分布情况列表,包含物品类型、库区信息、数量、重量等
* @param itemType 物品类型(可选)
* @param itemId 物品ID可选
* @return 分布情况列表包含物品类型、物品ID、库区信息、数量、重量等
*/
List<WmsMaterialCoilVo> getDistributionByItemType();
List<WmsMaterialCoilVo> getDistributionByItemType(String itemType, Long itemId);
}

View File

@@ -1010,25 +1010,29 @@ public class WmsMaterialCoilServiceImpl implements IWmsMaterialCoilService {
/**
* 查询各个库区中不同类型的钢卷分布情况
* 按库区分组,统计每种物品类型的钢卷数量和重量
* 按库区分组,统计每种物品类型和物品ID的钢卷数量和重量
*
* @return 分布情况列表,包含库区信息、物品类型、数量、重量等
* @param itemType 物品类型(可选)
* @param itemId 物品ID可选
* @return 分布情况列表包含库区信息、物品类型、物品ID、数量、重量等
*/
@Override
public List<WmsMaterialCoilVo> getDistributionByWarehouse() {
List<Map<String, Object>> mapList = baseMapper.getDistributionByWarehouse();
public List<WmsMaterialCoilVo> getDistributionByWarehouse(String itemType, Long itemId) {
List<Map<String, Object>> mapList = baseMapper.getDistributionByWarehouse(itemType, itemId);
return convertMapListToVoList(mapList);
}
/**
* 查询不同类型的钢卷在不同库区的分布情况
* 按物品类型分组,统计每个库区的钢卷数量和重量
* 按物品类型和物品ID分组,统计每个库区的钢卷数量和重量
*
* @return 分布情况列表,包含物品类型、库区信息、数量、重量等
* @param itemType 物品类型(可选)
* @param itemId 物品ID可选
* @return 分布情况列表包含物品类型、物品ID、库区信息、数量、重量等
*/
@Override
public List<WmsMaterialCoilVo> getDistributionByItemType() {
List<Map<String, Object>> mapList = baseMapper.getDistributionByItemType();
public List<WmsMaterialCoilVo> getDistributionByItemType(String itemType, Long itemId) {
List<Map<String, Object>> mapList = baseMapper.getDistributionByItemType(itemType, itemId);
return convertMapListToVoList(mapList);
}
@@ -1042,6 +1046,7 @@ public class WmsMaterialCoilServiceImpl implements IWmsMaterialCoilService {
vo.setWarehouseId(map.get("warehouse_id") != null ? Long.valueOf(map.get("warehouse_id").toString()) : null);
vo.setWarehouseName(map.get("warehouse_name") != null ? map.get("warehouse_name").toString() : null);
vo.setItemType(map.get("item_type") != null ? map.get("item_type").toString() : null);
vo.setItemId(map.get("item_id") != null ? Long.valueOf(map.get("item_id").toString()) : null);
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);

View File

@@ -45,6 +45,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
w.warehouse_id,
w.warehouse_name,
mc.item_type,
mc.item_id,
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
@@ -53,14 +54,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
AND mc.data_type = 1
AND mc.del_flag = '0'
WHERE w.del_flag = '0'
GROUP BY w.warehouse_id, w.warehouse_name, mc.item_type
ORDER BY w.warehouse_id, mc.item_type
<if test="itemType != null and itemType != ''">
AND mc.item_type = #{itemType}
</if>
<if test="itemId != null">
AND mc.item_id = #{itemId}
</if>
GROUP BY w.warehouse_id, w.warehouse_name, mc.item_type, mc.item_id
ORDER BY w.warehouse_id, mc.item_type, mc.item_id
</select>
<!-- 查询不同类型的钢卷在不同库区的分布情况 -->
<select id="getDistributionByItemType" resultType="java.util.Map">
SELECT
mc.item_type,
mc.item_id,
w.warehouse_id,
w.warehouse_name,
COUNT(mc.coil_id) as coil_count,
@@ -71,8 +79,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
WHERE mc.data_type = 1
AND mc.del_flag = '0'
AND (w.del_flag = '0' OR w.del_flag IS NULL)
GROUP BY mc.item_type, w.warehouse_id, w.warehouse_name
ORDER BY mc.item_type, w.warehouse_id
<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.warehouse_id, w.warehouse_name
ORDER BY mc.item_type, mc.item_id, w.warehouse_id
</select>
</mapper>