Merge branch 'refs/heads/dev-ty1.2' into dev
# Conflicts: # mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/BmsServiceFeign.java # mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/OmsServiceFeign.java # mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/WlhyServiceFeign.java # mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/WmsServiceFeign.java # mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/YmsServiceFeign.java # mhd-common/mhd-common-core/src/main/java/com/mhd/common/core/feign/ThirdPartyServiceFeign.java # mhd_oms/src/main/java/com/mhd/oms/infrastructure/feign/ThirdPartyServiceFeign.java # mhd_oms/src/main/resources/bootstrap.yml
This commit is contained in:
@@ -0,0 +1,107 @@
|
||||
<?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(与列表"入仓日期"列同源,为空的历史单按建档时间兜底);
|
||||
一行 = 某仓单(b.in_order_number)内某货品(a.material_code)的合计,
|
||||
按件数(实际上架量 SUM(a.SHELVES_QUANTITY))降序排名
|
||||
-->
|
||||
<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') >= #{warehouseDateStart}
|
||||
</if>
|
||||
<if test="warehouseDateEnd != null and warehouseDateEnd != ''">
|
||||
and date_format(IFNULL(b.warehouse_date, b.create_time),'%Y-%m-%d') <= #{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>
|
||||
|
||||
<!-- 商品入库排名列表(仓单+货品汇总,按件数=实际上架量降序) -->
|
||||
<select id="queryMaterialRankList" parameterType="com.mhd.oms.domain.inboundRank.repository.todo.ExecutionInboundRankDO"
|
||||
resultType="com.mhd.oms.domain.inboundRank.repository.po.ExecutionInboundMaterialRankPO">
|
||||
select
|
||||
IFNULL(MAX(b.warehouse_date), MAX(b.create_time)) AS warehouseDate,
|
||||
b.in_order_number AS inOrderNumber,
|
||||
MAX(b.shipper_code) AS shipperCode,
|
||||
MAX(b.shipper_name) AS shipperName,
|
||||
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 b.in_order_number, a.material_code
|
||||
order by pieceCount desc, warehouseDate desc, inOrderNumber desc
|
||||
</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,
|
||||
COUNT(DISTINCT t.inOrderNumber) AS totalOrderCount
|
||||
from (
|
||||
select
|
||||
b.in_order_number AS inOrderNumber,
|
||||
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 b.in_order_number, a.material_code
|
||||
) t
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,121 @@
|
||||
<?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
|
||||
-->
|
||||
<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="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') >= #{createTimeStart}
|
||||
</if>
|
||||
<if test="createTimeEnd != null and createTimeEnd != ''">
|
||||
and date_format(b.create_time,'%Y-%m-%d') <= #{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,
|
||||
MAX(a.SPECIFICATION_MODEL) AS specificationModel,
|
||||
MAX(a.unit_name) AS unitName,
|
||||
IFNULL(SUM(a.outbound_quantity), 0) AS salesQuantity,
|
||||
COUNT(DISTINCT a.out_order_number) AS tradeCount,
|
||||
IFNULL(SUM(IFNULL(a.TOTAL_AMOUNT, 0)), 0) AS amount
|
||||
<include refid="outboundRankFrom"/>
|
||||
<where>
|
||||
<include refid="outboundRankConditions"/>
|
||||
</where>
|
||||
GROUP BY a.material_code
|
||||
order by salesQuantity desc
|
||||
</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,
|
||||
IFNULL(SUM(a.outbound_quantity), 0) AS salesQuantity,
|
||||
COUNT(DISTINCT b.out_order_number) AS tradeCount,
|
||||
IFNULL(SUM(IFNULL(a.TOTAL_AMOUNT, 0)), 0) AS amount
|
||||
<include refid="outboundRankFrom"/>
|
||||
<where>
|
||||
<include refid="outboundRankConditions"/>
|
||||
and b.line_code is not null and b.line_code != ''
|
||||
</where>
|
||||
GROUP BY b.line_code
|
||||
order by salesQuantity desc
|
||||
</select>
|
||||
|
||||
<!-- 商品出库排名合计(当前筛选条件全量) -->
|
||||
<select id="queryMaterialRankTotal" parameterType="com.mhd.oms.domain.outboundRank.repository.todo.ExecutionOutboundRankDO"
|
||||
resultType="com.mhd.oms.domain.outboundRank.repository.po.ExecutionOutboundRankTotalPO">
|
||||
select
|
||||
IFNULL(SUM(a.outbound_quantity), 0) AS totalSalesQuantity,
|
||||
COUNT(DISTINCT a.out_order_number) AS totalTradeCount,
|
||||
IFNULL(SUM(IFNULL(a.TOTAL_AMOUNT, 0)), 0) AS totalAmount
|
||||
<include refid="outboundRankFrom"/>
|
||||
<where>
|
||||
<include refid="outboundRankConditions"/>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<!-- 线路出库排名合计(当前筛选条件全量) -->
|
||||
<select id="queryLineRankTotal" parameterType="com.mhd.oms.domain.outboundRank.repository.todo.ExecutionOutboundRankDO"
|
||||
resultType="com.mhd.oms.domain.outboundRank.repository.po.ExecutionOutboundRankTotalPO">
|
||||
select
|
||||
IFNULL(SUM(a.outbound_quantity), 0) AS totalSalesQuantity,
|
||||
COUNT(DISTINCT b.out_order_number) AS totalTradeCount,
|
||||
IFNULL(SUM(IFNULL(a.TOTAL_AMOUNT, 0)), 0) AS totalAmount
|
||||
<include refid="outboundRankFrom"/>
|
||||
<where>
|
||||
<include refid="outboundRankConditions"/>
|
||||
and b.line_code is not null and b.line_code != ''
|
||||
</where>
|
||||
</select>
|
||||
</mapper>
|
||||
+98
-9
@@ -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) > 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>
|
||||
+10
-2
@@ -470,8 +470,16 @@ 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(客户编码)与 USER_SHIPPER.CUSTOMER_NC_CODE(NC客户代码,即单据khdm),
|
||||
模板填写的客户编号两者任一命中即可匹配到客户 -->
|
||||
<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
|
||||
left join NGWL_TEST_USER.USER_SHIPPER us
|
||||
on us.USER_ID = u.USER_ID and us.DEL_FLAG = 1
|
||||
where u.ORGANIZATION_ID = #{organizationId} and u.DEL_FLAG = 1
|
||||
and (u.USER_MEMBER_CODE = #{userMemberCode} or us.CUSTOMER_NC_CODE = #{userMemberCode})
|
||||
</select>
|
||||
|
||||
<select id="countByOrderNumberPrefix" resultType="java.lang.Integer" parameterType="java.lang.String">
|
||||
|
||||
Reference in New Issue
Block a user