新增图片模块
This commit is contained in:
@@ -317,6 +317,244 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
ORDER BY ri.rk_time DESC
|
||||
</select>
|
||||
|
||||
<!--
|
||||
按单据分组(bill_no)列表
|
||||
复用 <sql id="selectRkInfoVo"> 作为子查询,外层分组聚合
|
||||
返回字段:bill_no、bill_no_ck + 你指定的通用字段(rk_type、wl_type、cangku、rk_time、lihuo_y、is_chuku、xj、
|
||||
xm_no、xm_ms、xm_no_ck、xm_ms_ck、wl_no、wl_ms、gys_no、sap_no)
|
||||
-->
|
||||
<select id="selectGroupedByBill" resultMap="RkInfoResult" parameterType="map">
|
||||
SELECT
|
||||
/* ============= 主键:取单据内任一(用最小 ID 代表) ============= */
|
||||
MIN(t.id) AS id,
|
||||
|
||||
/* ============= 单据号 ============= */
|
||||
t.bill_no AS bill_no, -- 入库单据号(分组键)
|
||||
ANY_VALUE(t.bill_no_ck) AS bill_no_ck, -- 出库单据号(若单据发生过出库则可能有值)
|
||||
|
||||
/* ============= 通用字段(代表值/聚合) ============= */
|
||||
ANY_VALUE(t.rk_type) AS rk_type, -- 入库类型编码(type_code)
|
||||
-- 入库类型名称(由 stock_in_type 反查)
|
||||
(SELECT si.type_name
|
||||
FROM stock_in_type si
|
||||
WHERE si.type_code = ANY_VALUE(t.rk_type)
|
||||
LIMIT 1) AS rk_type_name,
|
||||
|
||||
ANY_VALUE(t.wl_type) AS wl_type, -- 物资类型
|
||||
ANY_VALUE(t.cangku) AS cangku, -- 仓库(编码)
|
||||
MIN(t.rk_time) AS rk_time, -- 入库时间(单据内最早)
|
||||
ANY_VALUE(t.lihuo_y) AS lihuo_y, -- 理货员(ID)
|
||||
MAX(t.is_chuku) AS is_chuku, -- 是否出库(单据内只要有出库,用最大值反映)
|
||||
ANY_VALUE(t.xj) AS xj, -- 县局
|
||||
|
||||
ANY_VALUE(t.xm_no) AS xm_no, -- 入库项目号
|
||||
ANY_VALUE(t.xm_ms) AS xm_ms, -- 入库项目描述
|
||||
ANY_VALUE(t.xm_no_ck) AS xm_no_ck, -- 出库项目号
|
||||
ANY_VALUE(t.xm_ms_ck) AS xm_ms_ck, -- 出库项目描述
|
||||
|
||||
ANY_VALUE(t.wl_no) AS wl_no, -- 物料号
|
||||
ANY_VALUE(t.wl_ms) AS wl_ms, -- 物料描述
|
||||
ANY_VALUE(t.gys_no) AS gys_no, -- 供应商编码
|
||||
ANY_VALUE(t.sap_no) AS sap_no, -- SAP 订单号
|
||||
|
||||
/* ============= 出库附加信息 ============= */
|
||||
ANY_VALUE(t.ck_type) AS ck_type, -- 出库类型编码
|
||||
(SELECT s.type_name
|
||||
FROM stock_out_type s
|
||||
WHERE s.type_code = ANY_VALUE(t.ck_type)
|
||||
LIMIT 1) AS ck_type_name, -- 出库类型名称
|
||||
|
||||
MAX(t.ly_time) AS ly_time, -- 领用时间(单据内最新)
|
||||
|
||||
ANY_VALUE(t.ck_lihuo_y) AS ck_lihuo_y, -- 出库理货员ID
|
||||
(SELECT u.user_name
|
||||
FROM sys_user u
|
||||
WHERE u.user_id = ANY_VALUE(t.ck_lihuo_y)
|
||||
LIMIT 1) AS ck_lihuo_y_name -- 出库理货员姓名
|
||||
|
||||
FROM (
|
||||
<!-- 这里完全复用你已有的 SELECT + JOIN 片段,列别名与 RkInfoResult 一致 -->
|
||||
<include refid="selectRkInfoVo"/>
|
||||
) t
|
||||
|
||||
<where>
|
||||
<!-- ================= 与 /list 相同的筛选条件(把 ri.* 改为 t.*) ================= -->
|
||||
|
||||
<!-- is_chuku:优先列表,其次单值 -->
|
||||
<choose>
|
||||
<when test="q.isChukuList != null and q.isChukuList.size > 0">
|
||||
AND t.is_chuku IN
|
||||
<foreach collection="q.isChukuList" item="val" open="(" separator="," close=")">
|
||||
#{val}
|
||||
</foreach>
|
||||
</when>
|
||||
<when test="q.isChuku != null and q.isChuku != ''">
|
||||
AND t.is_chuku = #{q.isChuku}
|
||||
</when>
|
||||
</choose>
|
||||
|
||||
<!-- 关键词模糊 -->
|
||||
<if test="q.keyword != null and q.keyword != ''">
|
||||
AND (
|
||||
t.xm_no like concat('%', #{q.keyword}, '%')
|
||||
or t.xm_ms like concat('%', #{q.keyword}, '%')
|
||||
or t.wl_no like concat('%', #{q.keyword}, '%')
|
||||
or t.wl_ms like concat('%', #{q.keyword}, '%')
|
||||
or t.gys_no like concat('%', #{q.keyword}, '%')
|
||||
or t.gys_mc like concat('%', #{q.keyword}, '%')
|
||||
or t.sap_no like concat('%', #{q.keyword}, '%')
|
||||
or t.bill_no like concat('%', #{q.keyword}, '%')
|
||||
or t.bill_no_ck like concat('%', #{q.keyword}, '%')
|
||||
or t.ck_type like concat('%', #{q.keyword}, '%')
|
||||
or t.pcode like concat('%', #{q.keyword}, '%')
|
||||
)
|
||||
</if>
|
||||
|
||||
<!-- 维度筛选 -->
|
||||
<if test="q.rkType != null and q.rkType != ''">
|
||||
AND t.rk_type like concat('%', #{q.rkType}, '%')
|
||||
</if>
|
||||
<if test="q.wlType != null and q.wlType != ''">
|
||||
AND t.wl_type like concat('%', #{q.wlType}, '%')
|
||||
</if>
|
||||
<if test="q.cangku != null and q.cangku != ''">
|
||||
AND t.cangku like concat('%', #{q.cangku}, '%')
|
||||
</if>
|
||||
|
||||
<!-- ID 列表 -->
|
||||
<if test="q.ids != null and q.ids.size > 0">
|
||||
AND t.id IN
|
||||
<foreach collection="q.ids" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</if>
|
||||
|
||||
<!-- 入库时间范围(闭区间) -->
|
||||
<if test="q.startTime != null"><![CDATA[
|
||||
AND t.rk_time >= #{q.startTime}
|
||||
]]></if>
|
||||
<if test="q.endTime != null"><![CDATA[
|
||||
AND t.rk_time <= #{q.endTime}
|
||||
]]></if>
|
||||
|
||||
<!-- 领用时间范围(闭区间) -->
|
||||
<if test="q.lyStartTime != null"><![CDATA[
|
||||
AND t.ly_time >= #{q.lyStartTime}
|
||||
]]></if>
|
||||
<if test="q.lyEndTime != null"><![CDATA[
|
||||
AND t.ly_time <= #{q.lyEndTime}
|
||||
]]></if>
|
||||
|
||||
<!-- 其它模糊/等值 -->
|
||||
<if test="q.lihuoY != null and q.lihuoY != ''">
|
||||
AND t.lihuo_y like concat('%', #{q.lihuoY}, '%')
|
||||
</if>
|
||||
<if test="q.xj != null and q.xj != ''">
|
||||
AND t.xj like concat('%', #{q.xj}, '%')
|
||||
</if>
|
||||
<if test="q.billNo != null and q.billNo != ''">
|
||||
AND t.bill_no like concat('%', #{q.billNo}, '%')
|
||||
</if>
|
||||
<if test="q.billNoCk != null and q.billNoCk != ''">
|
||||
AND t.bill_no_ck like concat('%', #{q.billNoCk}, '%')
|
||||
</if>
|
||||
<if test="q.xmNo != null and q.xmNo != ''">
|
||||
AND t.xm_no like concat('%', #{q.xmNo}, '%')
|
||||
</if>
|
||||
<if test="q.xmMs != null and q.xmMs != ''">
|
||||
AND t.xm_ms like concat('%', #{q.xmMs}, '%')
|
||||
</if>
|
||||
<if test="q.wlNo != null and q.wlNo != ''">
|
||||
AND t.wl_no like concat('%', #{q.wlNo}, '%')
|
||||
</if>
|
||||
<if test="q.wlMs != null and q.wlMs != ''">
|
||||
AND t.wl_ms like concat('%', #{q.wlMs}, '%')
|
||||
</if>
|
||||
<if test="q.gysNo != null and q.gysNo != ''">
|
||||
AND t.gys_no like concat('%', #{q.gysNo}, '%')
|
||||
</if>
|
||||
<if test="q.gysMc != null and q.gysMc != ''">
|
||||
AND t.gys_mc like concat('%', #{q.gysMc}, '%')
|
||||
</if>
|
||||
|
||||
<if test="q.jhAmt != null">
|
||||
AND t.jh_amt = #{q.jhAmt}
|
||||
</if>
|
||||
<if test="q.htDj != null">
|
||||
AND t.ht_dj = #{q.htDj}
|
||||
</if>
|
||||
|
||||
<if test="q.sapNo != null and q.sapNo != ''">
|
||||
AND t.sap_no like concat('%', #{q.sapNo}, '%')
|
||||
</if>
|
||||
<if test="q.xh != null and q.xh != ''">
|
||||
AND t.xh like concat('%', #{q.xh}, '%')
|
||||
</if>
|
||||
<if test="q.jhQty != null">
|
||||
AND t.jh_qty = #{q.jhQty}
|
||||
</if>
|
||||
<if test="q.htQty != null">
|
||||
AND t.ht_qty = #{q.htQty}
|
||||
</if>
|
||||
<if test="q.dw != null and q.dw != ''">
|
||||
AND t.dw like concat('%', #{q.dw}, '%')
|
||||
</if>
|
||||
<if test="q.realQty != null">
|
||||
AND t.real_qty = #{q.realQty}
|
||||
</if>
|
||||
|
||||
<if test="q.pcode != null and q.pcode != ''">
|
||||
AND t.pcode like concat('%', #{q.pcode}, '%')
|
||||
</if>
|
||||
<if test="q.lyTime != null">
|
||||
AND t.ly_time = #{q.lyTime}
|
||||
</if>
|
||||
<if test="q.returnTime != null">
|
||||
AND t.return_time = #{q.returnTime}
|
||||
</if>
|
||||
<if test="q.trayCode != null and q.trayCode != ''">
|
||||
AND t.tray_code like concat('%', #{q.trayCode}, '%')
|
||||
</if>
|
||||
<if test="q.entityId != null and q.entityId != ''">
|
||||
AND t.entity_id like concat('%', #{q.entityId}, '%')
|
||||
</if>
|
||||
<if test="q.ckType != null and q.ckType != ''">
|
||||
AND t.ck_type like concat('%', #{q.ckType}, '%')
|
||||
</if>
|
||||
|
||||
<!-- 若查询出库单据:单值 is_chuku=1 或 列表包含 1,都要求已生成出库单号 -->
|
||||
<if test="(q.isChuku != null and q.isChuku == 1)
|
||||
or (q.isChukuList != null and q.isChukuList.size > 0 and q.isChukuList.contains(1))">
|
||||
AND t.bill_no_ck IS NOT NULL
|
||||
</if>
|
||||
|
||||
<!-- 删除标记(默认 0) -->
|
||||
<choose>
|
||||
<when test="q.isDelete != null and q.isDelete != ''">
|
||||
AND t.is_delete = #{q.isDelete}
|
||||
</when>
|
||||
<otherwise>
|
||||
AND t.is_delete = 0
|
||||
</otherwise>
|
||||
</choose>
|
||||
|
||||
<!-- 审核开启:剔除“审核失败”的明细(未审核/通过保留) -->
|
||||
<if test="needAudit != null and needAudit == 1">
|
||||
AND NOT EXISTS (
|
||||
SELECT 1
|
||||
FROM audit_signature asg
|
||||
WHERE asg.rk_id = t.id
|
||||
AND asg.approver_id IS NOT NULL
|
||||
AND (asg.audit_result IS NOT NULL AND asg.audit_result != '1')
|
||||
)
|
||||
</if>
|
||||
</where>
|
||||
|
||||
GROUP BY t.bill_no
|
||||
ORDER BY MIN(t.rk_time) DESC
|
||||
</select>
|
||||
|
||||
|
||||
|
||||
<select id="selectRkInfoById" parameterType="Long" resultMap="RkInfoResult">
|
||||
<include refid="selectRkInfoVo"/>
|
||||
|
||||
Reference in New Issue
Block a user