|
|
|
|
@ -3,9 +3,15 @@ package cn.iocoder.yudao.module.erp.dal.mysql.stock;
|
|
|
|
|
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
|
|
|
|
import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockOutItemPalletDO;
|
|
|
|
|
import org.apache.ibatis.annotations.Mapper;
|
|
|
|
|
import org.apache.ibatis.annotations.Param;
|
|
|
|
|
import org.apache.ibatis.annotations.Select;
|
|
|
|
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
|
import java.util.Collection;
|
|
|
|
|
import java.util.Collections;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
@Mapper
|
|
|
|
|
public interface ErpStockOutItemPalletMapper extends BaseMapperX<ErpStockOutItemPalletDO> {
|
|
|
|
|
@ -21,4 +27,42 @@ public interface ErpStockOutItemPalletMapper extends BaseMapperX<ErpStockOutItem
|
|
|
|
|
default int deleteByOutId(Long outId) {
|
|
|
|
|
return delete(ErpStockOutItemPalletDO::getOutId, outId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
default Map<Long, BigDecimal> selectLockedPackageCountMap(Collection<Long> palletIds,
|
|
|
|
|
Collection<Integer> statuses,
|
|
|
|
|
String outType) {
|
|
|
|
|
if (palletIds == null || palletIds.isEmpty()) {
|
|
|
|
|
return Collections.emptyMap();
|
|
|
|
|
}
|
|
|
|
|
List<Map<String, Object>> list = selectLockedPackageCountList(palletIds, statuses, outType);
|
|
|
|
|
if (list == null || list.isEmpty()) {
|
|
|
|
|
return Collections.emptyMap();
|
|
|
|
|
}
|
|
|
|
|
return list.stream().collect(Collectors.toMap(
|
|
|
|
|
item -> ((Number) item.get("palletId")).longValue(),
|
|
|
|
|
item -> item.get("lockedPackageCount") == null ? BigDecimal.ZERO
|
|
|
|
|
: new BigDecimal(item.get("lockedPackageCount").toString()),
|
|
|
|
|
(count1, count2) -> count1));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Select({"<script>",
|
|
|
|
|
"SELECT item_pallet.pallet_id AS palletId, COALESCE(SUM(item_pallet.package_count), 0) AS lockedPackageCount",
|
|
|
|
|
"FROM erp_stock_out_item_pallet item_pallet",
|
|
|
|
|
"INNER JOIN erp_stock_out stock_out ON stock_out.id = item_pallet.out_id",
|
|
|
|
|
"WHERE item_pallet.pallet_id IN",
|
|
|
|
|
"<foreach collection='palletIds' item='palletId' open='(' separator=',' close=')'>",
|
|
|
|
|
"#{palletId}",
|
|
|
|
|
"</foreach>",
|
|
|
|
|
"AND stock_out.out_type = #{outType}",
|
|
|
|
|
"<if test='statuses != null and statuses.size() > 0'>",
|
|
|
|
|
"AND stock_out.status IN",
|
|
|
|
|
"<foreach collection='statuses' item='status' open='(' separator=',' close=')'>",
|
|
|
|
|
"#{status}",
|
|
|
|
|
"</foreach>",
|
|
|
|
|
"</if>",
|
|
|
|
|
"GROUP BY item_pallet.pallet_id",
|
|
|
|
|
"</script>"})
|
|
|
|
|
List<Map<String, Object>> selectLockedPackageCountList(@Param("palletIds") Collection<Long> palletIds,
|
|
|
|
|
@Param("statuses") Collection<Integer> statuses,
|
|
|
|
|
@Param("outType") String outType);
|
|
|
|
|
}
|
|
|
|
|
|