Merge branch 'dev' into dev-bms-260826

# Conflicts:
#	mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/BmsServiceFeign.java
#	mhd_oms/src/main/java/com/mhd/oms/domain/reservationStockInOrder/repository/facade/IReservationStockInOrderService.java
#	mhd_oms/src/main/java/com/mhd/oms/domain/reservationStockInOrder/repository/mapper/ReservationStockInOrderMapper.java
#	mhd_oms/src/main/resources/mapper/reservationStockInOrder/ReservationStockInOrderMapper.xml
#	mhd_wms/src/main/java/com/mhd/wms/domain/materialInventory/repository/po/MaterialInventoryPO.java
#	mhd_wms/src/main/java/com/mhd/wms/domain/materialInventory/repository/todo/MaterialInventoryDO.java
#	mhd_wms/src/main/java/com/mhd/wms/interfaces/dto/materialInventory/MaterialInventoryDTO.java
#	mhd_wms/src/main/resources/mapper/materialInventory/MaterialInventoryMapper.xml
This commit is contained in:
王奎兴
2026-09-05 15:14:35 +08:00
211 changed files with 9989 additions and 706 deletions
+4 -4
View File
@@ -18,15 +18,15 @@ spring:
discovery:
# server-addr: 127.0.0.1:8848
# 线上测试环境配置 容器名+端口号
# server-addr: 10.33.0.129:6010
server-addr: 10.102.192.31:6848
server-addr: 10.33.0.129:6010
# server-addr: 10.102.192.30:6848
username: nacos
password: manhuoda@2023
config:
# server-addr: 127.0.0.1:8848
# 线上测试环境配置 容器名+端口号
# server-addr: 10.33.0.129:6010
server-addr: 10.102.192.31:6848
server-addr: 10.33.0.129:6010
# server-addr: 10.102.192.30:6848
username: nacos
password: manhuoda@2023
#线上正式环境
@@ -700,6 +700,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="pushTimeEnd != null">
and bdo.PUSH_TIME <![CDATA[<=]]> #{pushTimeEnd} + 1 - 1/86400
</if>
<if test="layDateStart != null">
and bdo.LAY_DATE <![CDATA[>=]]> #{layDateStart}
</if>
<if test="layDateEnd != null">
and bdo.LAY_DATE <![CDATA[<=]]> #{layDateEnd} + 1 - 1/86400
</if>
<if test="ieType != null ">
and bdo.IE_TYPE = #{ieType}
</if>
@@ -412,7 +412,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
b.warehouse_date
from execution_in_material_detail a
left join execution_stock_in_order b on a.in_order_number = b.in_order_number
left join material_base_info c on a.material_base_info_id = c.material_base_info_id
left join NGWL_TEST_WMS.material_base_info c on a.material_base_info_id = c.material_base_info_id
<where>
<if test="organizationId != null ">
and a.organization_id = #{organizationId}
@@ -459,6 +459,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="orderShipperName" column="order_shipper_name" />
<result property="orderOutboundDate" column="order_outbound_date" />
<result property="orderOutboundTime" column="order_outbound_time" />
<result property="insureAmount" column="insure_amount" />
<result property="goodsType" column="goods_type" />
</resultMap>
<select id="queryOutOrderDetailList"
@@ -493,6 +495,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
a.stock_unit, a.stock_quantity, a.inventory_quantity,
a.line_num_gw, a.spec_gw, a.unit_gw, a.qty_gw,
a.erp_curr_gw, a.erp_price_gw, a.amount_gw, a.in_order_number_gw, a.in_line_num_gw,
c.insure_amount, c.goods_type,
b.shipper_id as order_shipper_id,
b.shipper_code as order_shipper_code,
b.shipper_name as order_shipper_name,
@@ -502,6 +505,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
b.audit_status as out_order_audit_status
from execution_out_material_detail a
left join execution_stock_out_order b on a.out_order_number = b.out_order_number
left join NGWL_TEST_WMS.material_base_info c on a.material_base_info_id = c.material_base_info_id
<where>
<if test="organizationId != null ">
and a.organization_id = #{organizationId}
@@ -0,0 +1,109 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.mhd.oms.domain.inboundRank.repository.mapper.ExecutionInboundRankMapper">
<!--
入库排名统计公共查询条件(OMS 端,跨库取 WMS 入库数据)
数据源:WMS 库入库明细 NGWL_TEST_WMS.in_material_detail(a,仅 level=1 主行防重复)
join WMS 库入仓单 NGWL_TEST_WMS.stock_in_order(b)
left join WMS 库货品档案 NGWL_TEST_WMS.material_base_info(c,取保额作投保总额)
说明:OMS 库执行入库单状态/上架数量均不回传(状态长期停留 status=1,上架量回填代码未启用),
"已入库/实际上架量"的真实数据在 WMS 库,故跨库取数
(与 OMS 出库排名跨库取 NGWL_TEST_WMS 出库表、OMS 库存查询跨库 join material_base_info 同一模式),
口径与 WMS 端 /inboundRankApi 完全一致,两边数字一致;
条件:b.status = 5已入库(排除已取消(6)/已关闭(7)及未完成单据);
日期筛选按入仓单入仓日期 b.warehouse_date(与列表"入仓日期"列同源,为空的历史单按建档时间兜底);
一行 = 一个物料的合计(按物料编码合并,区间内全部已入库仓单),按件数(实际上架量 SUM(a.SHELVES_QUANTITY))降序排名,
件数为0的物料不返回(HAVING过滤);仓单编号/客户编号/存货人/入仓日期为单据级字段仅作查询条件不返回
-->
<sql id="inboundRankConditions">
a.del_flag = 1
and a.level = 1
and b.status = 5
<if test="topOrganizationId != null">
and b.top_organization_id = #{topOrganizationId}
</if>
<if test="warehouseName != null and warehouseName != ''">
and b.warehouse_name like concat('%', #{warehouseName}, '%')
</if>
<if test="inOrderNumber != null and inOrderNumber != ''">
and b.in_order_number like concat('%', #{inOrderNumber}, '%')
</if>
<if test="shipperCode != null and shipperCode != ''">
and b.shipper_code like concat('%', #{shipperCode}, '%')
</if>
<if test="shipperName != null and shipperName != ''">
and b.shipper_name like concat('%', #{shipperName}, '%')
</if>
<if test="materialCode != null and materialCode != ''">
and a.material_code like concat('%', #{materialCode}, '%')
</if>
<if test="materialName != null and materialName != ''">
and a.material_name like concat('%', #{materialName}, '%')
</if>
<if test="warehouseDateStart != null and warehouseDateStart != ''">
and date_format(IFNULL(b.warehouse_date, b.create_time),'%Y-%m-%d') &gt;= #{warehouseDateStart}
</if>
<if test="warehouseDateEnd != null and warehouseDateEnd != ''">
and date_format(IFNULL(b.warehouse_date, b.create_time),'%Y-%m-%d') &lt;= #{warehouseDateEnd}
</if>
</sql>
<sql id="inboundRankFrom">
from NGWL_TEST_WMS.in_material_detail a
join NGWL_TEST_WMS.stock_in_order b on a.in_order_number = b.in_order_number and b.del_flag = 1
left join NGWL_TEST_WMS.material_base_info c on a.material_base_info_id = c.material_base_info_id
</sql>
<!-- 商品入库排名列表(按物料编码合并,按件数=实际上架量降序,过滤0件行) -->
<select id="queryMaterialRankList" parameterType="com.mhd.oms.domain.inboundRank.repository.todo.ExecutionInboundRankDO"
resultType="com.mhd.oms.domain.inboundRank.repository.po.ExecutionInboundMaterialRankPO">
select
a.material_code AS materialCode,
MAX(a.material_name) AS materialName,
MAX(a.SPECIFICATION_MODEL) AS specificationModel,
MAX(a.unit_name) AS unitName,
IFNULL(SUM(a.SHELVES_QUANTITY), 0) AS pieceCount,
ROUND(IFNULL(SUM(a.TOTAL_GROSS_WEIGHT), 0) / 1000, 3) AS grossWeightTon,
MAX(IFNULL(c.insure_amount, 0)) AS insureAmount,
IFNULL(SUM(a.TOTAL_VOLUME), 0) AS totalVolume
<include refid="inboundRankFrom"/>
<where>
<include refid="inboundRankConditions"/>
</where>
GROUP BY a.material_code
HAVING pieceCount > 0
order by pieceCount desc, materialCode
</select>
<!-- 商品入库排名合计(当前筛选条件全量;外层对物料分组结果再汇总,投保总额合计=各物料保额之和(每物料计一次);
涉及仓单数按明细行去重统计仓单) -->
<select id="queryMaterialRankTotal" parameterType="com.mhd.oms.domain.inboundRank.repository.todo.ExecutionInboundRankDO"
resultType="com.mhd.oms.domain.inboundRank.repository.po.ExecutionInboundRankTotalPO">
select
IFNULL(SUM(t.pieceCount), 0) AS totalPieceCount,
ROUND(IFNULL(SUM(t.grossWeightKG), 0) / 1000, 3) AS totalGrossWeightTon,
IFNULL(SUM(t.insureAmount), 0) AS totalInsureAmount,
IFNULL(SUM(t.totalVolume), 0) AS totalVolume,
(select COUNT(DISTINCT b.in_order_number)
<include refid="inboundRankFrom"/>
<where>
<include refid="inboundRankConditions"/>
</where>) AS totalOrderCount
from (
select
a.material_code AS materialCode,
IFNULL(SUM(a.SHELVES_QUANTITY), 0) AS pieceCount,
IFNULL(SUM(a.TOTAL_GROSS_WEIGHT), 0) AS grossWeightKG,
MAX(IFNULL(c.insure_amount, 0)) AS insureAmount,
IFNULL(SUM(a.TOTAL_VOLUME), 0) AS totalVolume
<include refid="inboundRankFrom"/>
<where>
<include refid="inboundRankConditions"/>
</where>
GROUP BY a.material_code
) t
</select>
</mapper>
@@ -0,0 +1,181 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.mhd.oms.domain.outEntrustOrder.repository.mapper.OutEntrustOrderMapper">
<resultMap type="com.mhd.oms.domain.outEntrustOrder.repository.po.OutEntrustOrderPO" id="OutEntrustOrderResult">
<result property="id" column="id" />
<result property="createBy" column="create_by" />
<result property="createByName" column="create_by_name" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateByName" column="update_by_name" />
<result property="updateTime" column="update_time" />
<result property="delFlag" column="del_flag" />
<result property="entrustNumber" column="entrust_number" />
<result property="warehouseId" column="warehouse_id" />
<result property="warehouseCode" column="warehouse_code" />
<result property="warehouseName" column="warehouse_name" />
<result property="shipperId" column="shipper_id" />
<result property="shipperCode" column="shipper_code" />
<result property="shipperName" column="shipper_name" />
<result property="salesmanId" column="salesman_id" />
<result property="salesmanName" column="salesman_name" />
<result property="orderTypeCode" column="order_type_code" />
<result property="orderTypeName" column="order_type_name" />
<result property="settlementCurrency" column="settlement_currency" />
<result property="priorityLevelCode" column="priority_level_code" />
<result property="priorityLevelName" column="priority_level_name" />
<result property="directWarehouse" column="direct_warehouse" />
<result property="review" column="review" />
<result property="expectTime" column="expect_time" />
<result property="outboundDate" column="outbound_date" />
<result property="orderDate" column="order_date" />
<result property="completeTime" column="complete_time" />
<result property="toReceiver" column="to_receiver" />
<result property="contactPerson" column="contact_person" />
<result property="vehicleModelPlate" column="vehicle_model_plate" />
<result property="entrustNo" column="entrust_no" />
<result property="tel" column="tel" />
<result property="fax" column="fax" />
<result property="driverSign" column="driver_sign" />
<result property="carrier" column="carrier" />
<result property="carrierName" column="carrier_name" />
<result property="containerNo" column="container_no" />
<result property="containerNoName" column="container_no_name" />
<result property="transportModeCode" column="transport_mode_code" />
<result property="transportModeName" column="transport_mode_name" />
<result property="supervisionModeCode" column="supervision_mode_code" />
<result property="supervisionModeName" column="supervision_mode_name" />
<result property="declareCustoms" column="declare_customs" />
<result property="entryExitCustoms" column="entry_exit_customs" />
<result property="departureArrivalCountry" column="departure_arrival_country" />
<result property="customsInspectionFlag" column="customs_inspection_flag" />
<result property="needDeclareFlag" column="need_declare_flag" />
<result property="needTransportFlag" column="need_transport_flag" />
<result property="manufacturer" column="manufacturer" />
<result property="customsDeclarerInfo" column="customs_declarer_info" />
<result property="deliveryAddr" column="delivery_addr" />
<result property="annexUrl" column="annex_url" />
<result property="orderStatus" column="order_status" />
<result property="orderStatusStr" column="order_status_str" />
<result property="auditBy" column="audit_by" />
<result property="auditByName" column="audit_by_name" />
<result property="auditTime" column="audit_time" />
<result property="auditRemark" column="audit_remark" />
<result property="issueStatus" column="issue_status" />
<result property="issueStatusStr" column="issue_status_str" />
<result property="issueBy" column="issue_by" />
<result property="issueByName" column="issue_by_name" />
<result property="issueTime" column="issue_time" />
<result property="declareTotalQuantity" column="declare_total_quantity" />
<result property="remark" column="remark" />
<result property="organizationId" column="organization_id" />
<result property="organizationName" column="organization_name" />
<result property="topOrganizationId" column="top_organization_id" />
</resultMap>
<sql id="selectOutEntrustOrderPo">
select
a.id,a.create_by,a.create_by_name,a.create_time,a.update_by,a.update_by_name,a.update_time,a.del_flag,
a.entrust_number,a.warehouse_id,a.warehouse_code,a.warehouse_name,a.shipper_id,a.shipper_code,a.shipper_name,
a.salesman_id,a.salesman_name,a.order_type_code,a.order_type_name,a.settlement_currency,a.priority_level_code,a.priority_level_name,
a.direct_warehouse,a.review,a.expect_time,a.outbound_date,a.order_date,a.complete_time,
a.to_receiver,a.contact_person,a.vehicle_model_plate,a.entrust_no,a.tel,a.fax,a.driver_sign,
a.carrier,a.carrier_name,a.container_no,a.container_no_name,
a.transport_mode_code,a.transport_mode_name,a.supervision_mode_code,a.supervision_mode_name,
a.declare_customs,a.entry_exit_customs,a.departure_arrival_country,a.customs_inspection_flag,
a.need_declare_flag,a.need_transport_flag,a.manufacturer,a.customs_declarer_info,a.delivery_addr,a.annex_url,
a.order_status,a.audit_by,a.audit_by_name,a.audit_time,a.audit_remark,
a.issue_status,a.issue_by,a.issue_by_name,a.issue_time,a.declare_total_quantity,
a.remark,a.organization_id,a.organization_name,a.top_organization_id,
case a.order_status when 1 then '待审核' when 2 then '已审核' when 3 then '已驳回' when 4 then '进行中' when 5 then '已入库' else '未知状态' end order_status_str,
case a.issue_status when 1 then '未下发' when 2 then '已下发' else '未知状态' end issue_status_str
from
oms_out_entrust_order a
</sql>
<sql id="selectOutEntrustOrderPo1">
<where>
a.del_flag = 1
<if test="entrustNumber != null and entrustNumber != ''">
and a.entrust_number like concat('%', #{entrustNumber}, '%')
</if>
<if test="entrustNo != null and entrustNo != ''">
and a.entrust_no like concat('%', #{entrustNo}, '%')
</if>
<if test="warehouseId != null">
and a.warehouse_id = #{warehouseId}
</if>
<if test="warehouseName != null and warehouseName != ''">
and a.warehouse_name like concat('%', #{warehouseName}, '%')
</if>
<if test="shipperId != null">
and a.shipper_id = #{shipperId}
</if>
<if test="shipperName != null and shipperName != ''">
and a.shipper_name like concat('%', #{shipperName}, '%')
</if>
<if test="salesmanId != null and salesmanId != ''">
and a.salesman_id = #{salesmanId}
</if>
<if test="salesmanName != null and salesmanName != ''">
and a.salesman_name like concat('%', #{salesmanName}, '%')
</if>
<if test="containerNo != null and containerNo != ''">
and a.container_no like concat('%', #{containerNo}, '%')
</if>
<if test="orderStatus != null">
and a.order_status = #{orderStatus}
</if>
<if test="issueStatus != null">
and a.issue_status = #{issueStatus}
</if>
<if test="settlementCurrency != null and settlementCurrency != ''">
and a.settlement_currency = #{settlementCurrency}
</if>
<if test="invoiceNo != null and invoiceNo != ''">
and exists (
select 1 from oms_out_entrust_order_detail d
where d.entrust_number = a.entrust_number
and d.del_flag = 1
and d.invoice_no like concat('%', #{invoiceNo}, '%')
)
</if>
<if test="topOrganizationId != null">
and a.top_organization_id = #{topOrganizationId}
</if>
<if test="beginCreateTime != null">
and a.create_time &gt;= #{beginCreateTime}
</if>
<if test="endCreateTime != null">
and a.create_time &lt;= #{endCreateTime}
</if>
<if test="idList != null">
and a.id in
<foreach collection="idList" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</if>
</where>
order by a.create_time desc
</sql>
<select id="queryList" parameterType="com.mhd.oms.domain.outEntrustOrder.repository.todo.OutEntrustOrderDO" resultMap="OutEntrustOrderResult">
<include refid="selectOutEntrustOrderPo"/>
<include refid="selectOutEntrustOrderPo1"/>
</select>
<select id="getInfoByIds" resultMap="OutEntrustOrderResult">
<include refid="selectOutEntrustOrderPo"/>
<where>
a.del_flag = 1
and a.id in
<foreach collection="idList" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</where>
</select>
</mapper>
@@ -0,0 +1,133 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.mhd.oms.domain.outboundRank.repository.mapper.ExecutionOutboundRankMapper">
<!--
出库排名统计公共查询条件(OMS 端,跨库取 WMS 出库数据)
数据源:WMS 库出库明细 NGWL_TEST_WMS.out_material_detail(a,仅 level=1 主行防重复)
join WMS 库出库单 NGWL_TEST_WMS.stock_out_order(b)
说明:OMS 库出库单状态不流转(无"已出库"数据),"已出库"状态的真实数据在 WMS 库,
故跨库取数(与 OMS 库存查询跨库 join NGWL_TEST_WMS.material_base_info 同一模式),
口径与 WMS 端 /outboundRankApi 完全一致,两边数字一致;
条件:b.status in (9已出库,12已复核,13已交接),排除已取消(10)/已关闭(11);
日期按出库单创建时间 b.create_time
商品排名:一行 = 一个货品(GROUP BY a.material_code),区间内跨单汇总,按实际出库量降序;
线路排名:一行 = 线路×货品(GROUP BY b.line_code, a.material_code),仅统计带线路的单;
件数 = SUM(a.CHECK_QUANTITY) 复核确认的实际出库量(与入库排名的实际上架量 SHELVES_QUANTITY 对称)
-->
<sql id="outboundRankConditions">
a.del_flag = 1
and a.level = 1
and b.status in (9, 12, 13)
<if test="topOrganizationId != null">
and b.top_organization_id = #{topOrganizationId}
</if>
<if test="warehouseName != null and warehouseName != ''">
and b.warehouse_name like concat('%', #{warehouseName}, '%')
</if>
<if test="customerName != null and customerName != ''">
and b.customer_name like concat('%', #{customerName}, '%')
</if>
<if test="shipperName != null and shipperName != ''">
and b.shipper_name like concat('%', #{shipperName}, '%')
</if>
<if test="lineCode != null and lineCode != ''">
and b.line_code like concat('%', #{lineCode}, '%')
</if>
<if test="lineName != null and lineName != ''">
and b.line_name like concat('%', #{lineName}, '%')
</if>
<if test="outOrderNumber != null and outOrderNumber != ''">
and b.out_order_number like concat('%', #{outOrderNumber}, '%')
</if>
<if test="inOrderNumber != null and inOrderNumber != ''">
and a.in_order_number like concat('%', #{inOrderNumber}, '%')
</if>
<if test="materialCode != null and materialCode != ''">
and a.material_code like concat('%', #{materialCode}, '%')
</if>
<if test="materialName != null and materialName != ''">
and a.material_name like concat('%', #{materialName}, '%')
</if>
<if test="createTimeStart != null and createTimeStart != ''">
and date_format(b.create_time,'%Y-%m-%d') &gt;= #{createTimeStart}
</if>
<if test="createTimeEnd != null and createTimeEnd != ''">
and date_format(b.create_time,'%Y-%m-%d') &lt;= #{createTimeEnd}
</if>
</sql>
<sql id="outboundRankFrom">
from NGWL_TEST_WMS.out_material_detail a
join NGWL_TEST_WMS.stock_out_order b on a.out_order_number = b.out_order_number and b.del_flag = 1
</sql>
<!-- 商品出库排名列表(按物料编码合并,跨单汇总;退保总额暂无后端字段不提供) -->
<select id="queryMaterialRankList" parameterType="com.mhd.oms.domain.outboundRank.repository.todo.ExecutionOutboundRankDO"
resultType="com.mhd.oms.domain.outboundRank.repository.po.ExecutionOutboundMaterialRankPO">
select
a.material_code AS materialCode,
MAX(a.material_name) AS materialName,
IFNULL(SUM(a.CHECK_QUANTITY), 0) AS pieceCount,
ROUND(IFNULL(SUM(a.TOTAL_GROSS_WEIGHT), 0) / 1000, 3) AS grossWeightTon,
IFNULL(SUM(a.TOTAL_VOLUME), 0) AS totalVolume
<include refid="outboundRankFrom"/>
<where>
<include refid="outboundRankConditions"/>
</where>
GROUP BY a.material_code
order by pieceCount desc, materialCode asc
</select>
<!-- 商品出库排名合计(当前筛选条件全量) -->
<select id="queryMaterialRankTotal" parameterType="com.mhd.oms.domain.outboundRank.repository.todo.ExecutionOutboundRankDO"
resultType="com.mhd.oms.domain.outboundRank.repository.po.ExecutionOutboundDetailRankTotalPO">
select
IFNULL(SUM(a.CHECK_QUANTITY), 0) AS totalPieceCount,
ROUND(IFNULL(SUM(a.TOTAL_GROSS_WEIGHT), 0) / 1000, 3) AS totalGrossWeightTon,
IFNULL(SUM(a.TOTAL_VOLUME), 0) AS totalVolume,
COUNT(DISTINCT a.out_order_number) AS totalOrderCount
<include refid="outboundRankFrom"/>
<where>
<include refid="outboundRankConditions"/>
</where>
</select>
<!-- 线路出库排名列表(线路+物料编码合并,仅统计带线路的单;商品/线路筛选参数均生效) -->
<select id="queryLineRankList" parameterType="com.mhd.oms.domain.outboundRank.repository.todo.ExecutionOutboundRankDO"
resultType="com.mhd.oms.domain.outboundRank.repository.po.ExecutionOutboundLineRankPO">
select
b.line_code AS lineCode,
MAX(b.line_name) AS lineName,
a.material_code AS materialCode,
MAX(a.material_name) AS materialName,
IFNULL(SUM(a.CHECK_QUANTITY), 0) AS pieceCount,
ROUND(IFNULL(SUM(a.TOTAL_GROSS_WEIGHT), 0) / 1000, 3) AS grossWeightTon,
IFNULL(SUM(a.TOTAL_VOLUME), 0) AS totalVolume
<include refid="outboundRankFrom"/>
<where>
<include refid="outboundRankConditions"/>
and b.line_code is not null and b.line_code != ''
</where>
GROUP BY b.line_code, a.material_code
order by pieceCount desc, lineCode asc, materialCode asc
</select>
<!-- 线路出库排名合计(当前筛选条件全量) -->
<select id="queryLineRankTotal" parameterType="com.mhd.oms.domain.outboundRank.repository.todo.ExecutionOutboundRankDO"
resultType="com.mhd.oms.domain.outboundRank.repository.po.ExecutionOutboundDetailRankTotalPO">
select
IFNULL(SUM(a.CHECK_QUANTITY), 0) AS totalPieceCount,
ROUND(IFNULL(SUM(a.TOTAL_GROSS_WEIGHT), 0) / 1000, 3) AS totalGrossWeightTon,
IFNULL(SUM(a.TOTAL_VOLUME), 0) AS totalVolume,
COUNT(DISTINCT b.line_code) AS totalLineCount,
COUNT(DISTINCT b.out_order_number) AS totalOrderCount
<include refid="outboundRankFrom"/>
<where>
<include refid="outboundRankConditions"/>
and b.line_code is not null and b.line_code != ''
</where>
</select>
</mapper>
@@ -56,6 +56,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="productionDate" column="production_date" />
<result property="expiryDate" column="expiry_date" />
<result property="inventoryDate" column="inventory_date" />
<result property="purchaseDate" column="purchase_date" />
<result property="batchRefNo" column="batch_ref_no" />
<result property="sheetRefNo" column="sheet_ref_no" />
<result property="boxPalletNo" column="box_pallet_no" />
@@ -64,6 +65,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="barCode" column="inv_bar_code" />
<result property="inOrderNumber" column="in_order_number" />
<result property="lotNumber" column="lot_number" />
<result property="materialClassifyCode" column="material_classify_code"
typeHandler="com.mhd.common.core.handler.ListTypeHandler" />
<result property="materialClassifyName" column="material_classify_name"
typeHandler="com.mhd.common.core.handler.ListTypeHandler" />
</resultMap>
<sql id="JoinMaterialBaseInfoPo">
@@ -138,7 +143,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
IFNULL (sum(a.GROSS_WEIGHT), 0) GROSS_WEIGHT,
IFNULL (sum(a.VOLUME), 0) VOLUME,
a.ext_attr_1, a.ext_attr_2, a.ext_attr_3, a.ext_attr_4,
a.production_date, a.expiry_date, a.inventory_date,
a.production_date, a.expiry_date, a.inventory_date, a.purchase_date,
a.BATCH_REF_NO, a.SHEET_REF_NO, a.BOX_PALLET_NO,nvl(a.unit_name,b.unit_name) as unit_name,
a.bar_code as inv_bar_code,
a.in_order_number,a.lot_number
@@ -280,6 +285,35 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="expiryDateEnd != null and expiryDateEnd != ''">
and a.expiry_date <![CDATA[ < ]]> DATEADD(DAY, 1, #{expiryDateEnd})
</if>
<if test="purchaseDateStr != null and purchaseDateStr != ''">
AND TO_CHAR(a.purchase_date, 'yyyy-MM-dd') = #{purchaseDateStr}
</if>
<if test="purchaseDateStart != null and purchaseDateStart != ''">
and a.purchase_date >= #{purchaseDateStart}
</if>
<if test="purchaseDateEnd != null and purchaseDateEnd != ''">
and a.purchase_date <![CDATA[ < ]]> DATEADD(DAY, 1, #{purchaseDateEnd})
</if>
</sql>
<!-- 导出排除库存为0:所有维度查询(all/hz/wl/kw/wlkw/wlExpiry)的库存数量均为SUM聚合值,
统一在各语句 GROUP BY 之后用 HAVING 过滤(与sort_order对0库存的定义保持一致);
仅前端导出传 excludeZeroInventoryQuantity=true 时拼接,正常列表查询不传则完全不受影响 -->
<sql id="excludeZeroInventoryHaving">
<if test="excludeZeroInventoryQuantity != null and excludeZeroInventoryQuantity == true">
HAVING IFNULL(SUM(a.inventory_quantity), 0) &gt; 0
</if>
</sql>
<!-- 导出融合排序(isExport=true):保留"到期日优先"第一优先级(到期日倒序、空值最后),
融合新增"同到期日内按物料编码升序",再保留 0库存靠后、更新时间倒序 兜底,
末位以 MAX(物料库存ID) 保证分页序稳定;不传 isExport 各语句保持原有排序 -->
<sql id="exportOrderByMaterialCode">
order by CASE WHEN MAX(a.expiry_date) IS NULL THEN 1 ELSE 0 END ASC, MAX(a.expiry_date) DESC,
MAX(b.material_code) ASC,
CASE WHEN IFNULL(SUM(a.inventory_quantity), 0) = 0 THEN 1 ELSE 0 END ASC,
MAX(a.update_time) DESC,
MAX(a.material_inventory_id) DESC
</sql>
<select id="queryList" parameterType="com.mhd.oms.domain.reservationMaterialInventory.repository.todo.ReservationMaterialInventoryDO" resultMap="MaterialInventoryResult">
@@ -292,7 +326,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<include refid="selectMaterialInventoryPo1"/>
<include refid="JoinMaterialBaseInfoPoWhere"/>
</where>
group by a.MATERIAL_INVENTORY_ID order by a.update_time desc
group by a.MATERIAL_INVENTORY_ID <include refid="excludeZeroInventoryHaving"/>
<choose>
<when test="isExport != null and isExport == true">
<include refid="exportOrderByMaterialCode"/>
</when>
<otherwise> order by a.update_time desc </otherwise>
</choose>
</select>
<select id="queryListByWlKw" parameterType="com.mhd.oms.domain.reservationMaterialInventory.repository.todo.ReservationMaterialInventoryDO" resultMap="MaterialInventoryResult">
@@ -306,6 +346,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<include refid="JoinMaterialBaseInfoPoWhere"/>
</where>
GROUP BY a.MATERIAL_BASE_INFO_ID,a.WAREHOUSE_ID,a.STORAGE_SECTION_ID,a.STORAGE_LOCATION_ID
<include refid="excludeZeroInventoryHaving"/>
<if test="isExport != null and isExport == true">
<include refid="exportOrderByMaterialCode"/>
</if>
</select>
<select id="queryListByKw" parameterType="com.mhd.oms.domain.reservationMaterialInventory.repository.todo.ReservationMaterialInventoryDO" resultMap="MaterialInventoryResult">
@@ -319,6 +363,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<include refid="JoinMaterialBaseInfoPoWhere"/>
</where>
GROUP BY a.WAREHOUSE_ID,a.STORAGE_SECTION_ID,a.STORAGE_LOCATION_ID
<include refid="excludeZeroInventoryHaving"/>
<if test="isExport != null and isExport == true">
<include refid="exportOrderByMaterialCode"/>
</if>
</select>
<select id="queryListByWl" parameterType="com.mhd.oms.domain.reservationMaterialInventory.repository.todo.ReservationMaterialInventoryDO" resultMap="MaterialInventoryResult">
@@ -332,6 +380,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<include refid="JoinMaterialBaseInfoPoWhere"/>
</where>
GROUP BY a.MATERIAL_BASE_INFO_ID
<include refid="excludeZeroInventoryHaving"/>
<if test="isExport != null and isExport == true">
<include refid="exportOrderByMaterialCode"/>
</if>
</select>
<!-- 按物料+过期日期汇总 -->
@@ -353,12 +405,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
IFNULL(SUM(a.VOLUME), 0) AS VOLUME,
MAX(a.unit) AS unit,
MAX(a.unit_name) AS unit_name,
MAX(a.create_time) AS create_time,
MAX(a.update_time) AS update_time,
MAX(a.production_date) AS production_date,
MAX(a.inventory_date) AS inventory_date,
MAX(a.purchase_date) AS purchase_date,
MAX(a.batch_ref_no) AS batch_ref_no, MAX(a.sheet_ref_no) AS sheet_ref_no, MAX(a.box_pallet_no) AS box_pallet_no,
MAX(a.bar_code) AS inv_bar_code,
MAX(a.in_order_number) AS in_order_number, MAX(a.lot_number) AS lot_number,
b.material_code, b.material_name,
MAX(b.material_classify_code) AS material_classify_code,
MAX(b.material_classify_name) AS material_classify_name,
CASE WHEN IFNULL(SUM(a.inventory_quantity), 0) = 0 THEN 1 ELSE 0 END AS sort_order
from reservation_material_inventory a
left join NGWL_TEST_WMS.material_base_info b on a.material_base_info_id = b.material_base_info_id
@@ -369,16 +426,26 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
GROUP BY a.MATERIAL_BASE_INFO_ID, a.EXPIRY_DATE, a.shipper_id, a.shipper_code, a.shipper_name,
a.organization_id, a.organization_name, a.top_organization_id,
b.material_code, b.material_name
<!-- 导出(queryRule=wlExpiry + orderByExpiryDate=true)按到期日分组归类:到期日倒序(日期近的在前)、
空值放最后、0库存靠后、同到期日按更新时间倒序;相同物料+相同到期日合并为一行,数量类字段SUM汇总。
不传 orderByExpiryDate 保持原有排序 -->
<include refid="excludeZeroInventoryHaving"/>
<!-- 导出排序两级开关:isExport=true 用融合排序(到期日优先→同到期日按物料编码升序,与 orderByExpiryDate 融合不取代)
否则保持原有 orderByExpiryDate 分支排序 -->
<choose>
<when test="orderByExpiryDate != null and orderByExpiryDate == true">
order by CASE WHEN a.expiry_date IS NULL THEN 1 ELSE 0 END ASC, a.expiry_date DESC,
sort_order, MAX(a.update_time) DESC
<when test="isExport != null and isExport == true">
<include refid="exportOrderByMaterialCode"/>
</when>
<otherwise>
order by sort_order, MAX(a.update_time) desc
<!-- 导出(queryRule=wlExpiry + orderByExpiryDate=true)按到期日分组归类:到期日倒序(日期近的在前)、
空值放最后、0库存靠后、同到期日按更新时间倒序;相同物料+相同到期日合并为一行,数量类字段SUM汇总。
不传 orderByExpiryDate 保持原有排序 -->
<choose>
<when test="orderByExpiryDate != null and orderByExpiryDate == true">
order by CASE WHEN a.expiry_date IS NULL THEN 1 ELSE 0 END ASC, a.expiry_date DESC,
sort_order, MAX(a.update_time) DESC
</when>
<otherwise>
order by sort_order, MAX(a.update_time) desc
</otherwise>
</choose>
</otherwise>
</choose>
</select>
@@ -394,6 +461,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<include refid="JoinMaterialBaseInfoPoWhere"/>
</where>
GROUP BY a.SHIPPER_ID
<include refid="excludeZeroInventoryHaving"/>
<if test="isExport != null and isExport == true">
<include refid="exportOrderByMaterialCode"/>
</if>
</select>
<resultMap type="com.mhd.oms.domain.reservationMaterialInventory.repository.po.ReservationMaterialInventoryQueryListPO" id="MaterialQueryListResult">
@@ -447,6 +518,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="productionDate" column="production_date" />
<result property="expiryDate" column="expiry_date" />
<result property="inventoryDate" column="inventory_date" />
<result property="purchaseDate" column="purchase_date" />
<result property="extAttr3" column="ext_attr_3" />
<result property="extAttr4" column="ext_attr_4" />
<result property="remark" column="remark" />
@@ -527,4 +599,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
FROM NGWL_TEST_WMS.material_bar_code
WHERE material_base_info_id = #{id} AND del_flag = 1
</select>
<!-- 入库业务单新增:根据物料编号查询其库存批次的过期日期+批次号,去重后取最近5条,供前端下拉回显 -->
<select id="selectRecentExpiryBatches" resultType="com.mhd.oms.domain.reservationMaterialInventory.repository.po.MaterialInventoryExpiryBatchPO">
select distinct
date_format(a.expiry_date, '%Y-%m-%d') as expiryDate,
a.batch_number as batchNumber
from reservation_material_inventory a
left join NGWL_TEST_WMS.material_base_info b on a.material_base_info_id = b.material_base_info_id
where a.del_flag = 1
and a.expiry_date is not null
and b.material_code = #{materialCode}
<if test="topOrganizationId != null">
and a.top_organization_id = #{topOrganizationId}
</if>
order by expiryDate desc, batchNumber desc
limit 5
</select>
</mapper>
@@ -556,6 +556,11 @@
</select>
<select id="getkcId" resultType="com.mhd.oms.domain.reservationMaterialInventory.repository.po.ReservationMaterialInventoryPO">
select * from "NGWL_TEST_WMS".MATERIAL_INVENTORY where 1 = 1 and DEL_FLAG = 1 and MATERIAL_BASE_INFO_ID = #{id} and ALLOCATION_QUANTITY >= #{q}
<if test="warehouseId != null">
and WAREHOUSE_ID = #{warehouseId}
</if>
<!-- 同物料同仓存在多条可用库存时:有批次号的优先分配(空批次的历史记录沉底),同组按入库先后 -->
order by (case when BATCH_NUMBER is null or BATCH_NUMBER = '' then 1 else 0 end), MATERIAL_INVENTORY_ID asc
</select>
<select id="getUserNcCode" parameterType="java.lang.Long" resultType="java.lang.String">
select CUSTOMER_NC_CODE from "NGWL_TEST_USER".USER_SHIPPER where 1 = 1 and DEL_FLAG = 1 and USER_ID = #{id} limit 1
@@ -696,4 +701,9 @@
AND EXTRACT(MONTH FROM CREATE_TIME) >= EXTRACT(MONTH FROM SYSDATE - 1)
AND DEL_FLAG = 1
</select>
<!-- 导入模板自带OrderNO按业务单号查重 -->
<select id="existsByBusinessOrderNo" resultType="java.lang.Integer" parameterType="java.lang.String">
SELECT COUNT(1) FROM reservation_stock_in_order WHERE business_order_no = #{businessOrderNo}
</select>
</mapper>
@@ -470,8 +470,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="boxPalletNo" column="box_pallet_no"/>
</resultMap>
<select id="queryShipperId" resultType="java.lang.Long">
select max(user_id) as user_id from NGWL_TEST_USER."USER" where ORGANIZATION_ID = #{organizationId} and USER_MEMBER_CODE = #{userMemberCode} and DEL_FLAG = 1
<!-- 按客户编号+组织查询客户(用户表):出入库导入校验客户存在性并自动匹配客户名称,结果为空表示客户不存在。
客户编码只认 USER.USER_MEMBER_CODE(客户编码);
2026-09-03 起不再放行 USER_SHIPPER.CUSTOMER_NC_CODENC客户代码),避免会员/NC编码撞车导致不存在的客户编号误通过 -->
<select id="queryCustomerByCode" resultType="com.mhd.common.core.domain.po.UserPo">
select max(u.user_id) as user_id, max(u.user_name) as user_name, max(u.user_member_code) as user_member_code
from NGWL_TEST_USER."USER" u
where u.ORGANIZATION_ID = #{organizationId} and u.DEL_FLAG = 1
and u.USER_MEMBER_CODE = #{userMemberCode}
</select>
<select id="countByOrderNumberPrefix" resultType="java.lang.Integer" parameterType="java.lang.String">
@@ -558,7 +558,7 @@
</resultMap>
<select id="detailsList" parameterType="com.mhd.oms.domain.reserveStockInOrder.repository.todo.ReserveStockInOrderDO" resultMap="MaterialDetailResult">
select b.*
select b.*, a.status, a.issue_status
from reserve_stock_in_order a left join reserve_in_material_detail b on a.IN_ORDER_NUMBER = b.IN_ORDER_NUMBER
<where>
<include refid="selectStockInOrderPo1"/>
@@ -671,14 +671,17 @@
<if test="customerId != null">
and a."customerId" = #{customerId}
</if>
<if test="inOrOut != null">
<if test="inOrOut != null and inOrOut != '' and inOrOut != 'all'">
and a."inOrOut" = #{inOrOut}
</if>
<if test="status != null">
and a."status" = #{status}
</if>
<if test="issueStatus != null">
and a."issueStatus" = #{issueStatus}
</if>
<if test="orderNumber != null">
and a."orderNumber" = #{orderNumber}
<if test="orderNumber != null and orderNumber != ''">
and a."orderNumber" like concat('%', #{orderNumber}, '%')
</if>
<if test="createTimeStart != null and createTimeStart != ''">
and date_format(a."createTime",'%Y-%m-%d') &gt;= #{createTimeStart}
@@ -361,6 +361,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="topOrganizationId" column="top_organization_id" />
<result property="uniqueId" column="unique_id" />
<result property="outOrderNumber" column="out_order_number" />
<result property="status" column="status" />
<result property="issueStatus" column="issue_status" />
<result property="materialBaseInfoId" column="material_base_info_id" />
<result property="materialCode" column="material_code" />
<result property="materialName" column="material_name" />
@@ -452,7 +454,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="detailsList" parameterType="com.mhd.oms.domain.reserveStockOutOrder.repository.todo.ReserveStockOutOrderDO" resultMap="MaterialDetailResult">
select
b.*
b.*, a.status, a.issue_status
from reserve_stock_out_order a left join reserve_out_material_detail b on a.OUT_ORDER_NUMBER = b.OUT_ORDER_NUMBER
<where>
<include refid="selectStockOutOrderPo1"/>