package com.klp.mapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.core.metadata.IPage; import com.klp.domain.WmsMaterialCoil; import com.klp.domain.vo.*; import com.klp.common.core.mapper.BaseMapperPlus; import org.apache.ibatis.annotations.Param; import com.klp.domain.vo.dashboard.CoilTrimRawVo; import com.klp.domain.vo.dashboard.CategoryWidthRawVo; import java.util.List; import java.util.Map; public interface WmsMaterialCoilMapper extends BaseMapperPlus { /** * 查询各个库区中不同类型的钢卷分布情况 * 按库区分组,统计每种物品类型和物品ID的钢卷数量和重量 * * @param itemType 物品类型(可选) * @param itemId 物品ID(可选) * @return 分布情况列表 */ List> getDistributionByWarehouse(@Param("itemType") String itemType, @Param("itemId") Long itemId); /** * 查询不同类型的钢卷在不同库区的分布情况 * 按物品类型和物品ID分组,统计每个库区的钢卷数量和重量 * * @param itemType 物品类型(可选) * @param itemId 物品ID(可选) * @return 分布情况列表 */ List> getDistributionByItemType(@Param("itemType") String itemType, @Param("itemId") Long itemId); Page selectVoPagePlus(Page build,@Param("ew") QueryWrapper lqw); /** * orderBy=true 时使用:包含库位排序辅助字段(aw_sort_key/aw_layer_key/aw_id_key)以及父库位 join */ Page selectVoPagePlusOrderBy(Page build, @Param("ew") QueryWrapper lqw); /** * orderByPlanDesc=true 时使用:包含发货计划 join,支持按计划创建时间排序 */ Page selectVoPagePlusPlanOrder(Page build, @Param("ew") QueryWrapper lqw); List selectVoListWithDynamicJoin(@Param("ew")QueryWrapper lqw); Map selectCountForSpecSync(@Param("ew") QueryWrapper qw); List> getDistributionByActualWarehouse(@Param("itemType") String itemType, @Param("itemId") Long itemId); List> getDistributionByActualItemType(@Param("itemType")String itemType,@Param("itemId") Long itemId); /** * 查询钢卷导出数据(包含所有关联字段) * * @param lqw 查询条件 * @return 导出数据列表 */ List selectExportList(@Param("ew")QueryWrapper lqw); /** * 查询重复入场卷号的钢卷信息 * * @return 重复入场卷号的钢卷列表 */ List selectDuplicateEnterCoilNoList(); /** * 查询重复当前卷号的钢卷信息 * * @return 重复当前卷号的钢卷列表 */ List selectDuplicateCurrentCoilNoList(); /** * 更新钢卷发货撤回:将发货时间置空,状态改为指定值 * * @param coilId 钢卷ID * @param status 目标状态 * @return 影响行数 */ int updateForWithdrawExport(@Param("coilId") Long coilId, @Param("status") Integer status); /** * 发货报表导出:按钢卷ID列表联查(钢卷 + 发货单明细 + 发货单主表 + 发货计划) * * @param coilIds 钢卷ID集合 * @return 发货报表导出数据 */ List selectDeliveryExportListByCoilIds(@Param("coilIds") java.util.Collection coilIds); /** * 退火报表导出:按钢卷ID列表联查(钢卷 + 退火计划 + 退火计划钢卷关系) * * @param coilIds 钢卷ID集合 * @return 退火报表导出数据 */ List selectAnnealExportListByCoilIds(@Param("coilIds") java.util.Collection coilIds); /** * 分页查询钢卷报表数据(轻量级,仅返回必要字段) * * @param lqw 查询条件 * @return 分页报表数据 */ List selectReportList(@Param("ew") QueryWrapper lqw); /** * 分页查询钢卷环比报表数据(轻量级,包含实际长度、理论长度、理论厚度) * * @param lqw 查询条件 * @return 环比报表数据 */ List selectPeriodComparisonList(@Param("ew") QueryWrapper lqw); List selectCoilTrimStatistics(); List selectCategoryWidthStatistics(); /** * 查询itemId和itemType不匹配的钢卷 * @return 不匹配的钢卷列表 */ List selectMismatchedItemCoils(); /** * 统计筛选条件下的全量汇总数据(高性能:只查sum/count) * @param qw 查询条件(只使用WHERE和JOIN部分) * @return 统计结果(Map包含totalGrossWeight, totalNetWeight) */ Map selectStatistics(@Param("ew") QueryWrapper qw); /** * 统计已发货钢卷的平均囤积周期和平均囤积成本 * 使用JSON_EXTRACT解析二维码steps[0].create_time,一次SQL完成聚合 * @param qw 查询条件(与buildQueryWrapperPlus一致) * @return Map包含total_count, avg_hoarding_days, avg_hoarding_cost */ Map selectHoardingStatistics(@Param("ew") QueryWrapper qw); /** * 统计仓库使用次数(按warehouse_id出现次数排序) * * @param warehouseIds 仓库ID列表 * @return 每个仓库的钢卷数量 */ List> selectWarehouseIdCount(@Param("list") List warehouseIds); /** * 分页查询材质异常的钢卷 */ IPage selectMaterialMismatchCoilsPage(IPage page); /** * 根据入场钢卷号查询最早的热轧卷板材质 * @param enterCoilNo 入场钢卷号 * @return 材质信息 */ String selectEarliestHotRolledMaterial(@Param("enterCoilNo") String enterCoilNo); }