Files
smart_management_dev/src/main/resources/mybatis/wisdom/RkBillMapper.xml

162 lines
6.5 KiB
XML
Raw Normal View History

2025-06-09 15:16:00 +08:00
<?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.zg.project.wisdom.mapper.RkBillMapper">
<!-- 新增单据主表 -->
<insert id="insertRkBill" parameterType="com.zg.project.wisdom.domain.RkBill">
INSERT INTO rk_bill (
rk_type, wl_type, cangku, rk_time, lihuo_y,
2025-06-10 09:37:37 +08:00
ck_type, ck_time, ck_lihuo_y, ck_remark, team_code,
2025-06-09 15:16:00 +08:00
bill_no, is_chuku, is_delete,
2025-06-10 09:37:37 +08:00
created_by, created_at,
updated_by, updated_at
2025-06-09 15:16:00 +08:00
) VALUES (
#{rkType}, #{wlType}, #{cangku}, #{rkTime}, #{lihuoY},
2025-06-10 09:37:37 +08:00
#{ckType}, #{ckTime}, #{ckLihuoY}, #{ckRemark}, #{teamCode},
2025-06-09 15:16:00 +08:00
#{billNo}, #{isChuku}, #{isDelete},
2025-06-10 09:37:37 +08:00
#{createBy}, #{createTime},
#{updateBy}, #{updateTime}
2025-06-09 15:16:00 +08:00
)
</insert>
<!-- 查询列表(可用于分页或展示) -->
<select id="selectRkBillList"
parameterType="com.zg.project.wisdom.domain.RkBill"
resultType="com.zg.project.wisdom.domain.RkBill">
SELECT
rb.id,
rb.rk_type AS rkType,
st.type_name AS rkTypeName,
rb.wl_type AS wlType,
mt.type_name AS wlTypeName,
rb.cangku AS cangku,
wh.warehouse_name AS cangkuName,
rb.lihuo_y AS lihuoY,
rb.rk_time AS rkTime,
rb.bill_no AS billNo,
rb.is_chuku AS isChuku,
2025-06-10 09:37:37 +08:00
-- ✅ 出库相关字段(新增)
rb.ck_type AS ckType,
sot.ck_type_name AS ckTypeName,
rb.ck_time AS ckTime,
rb.ck_lihuo_y AS ckLihuoY,
rb.ck_remark AS ckRemark,
rb.team_code AS teamCode,
ct.team_name AS teamName,
2025-06-09 15:16:00 +08:00
rb.is_delete AS isDelete,
rb.created_by AS createBy,
rb.created_at AS createTime,
rb.updated_by AS updateBy,
rb.updated_at AS updateTime
2025-06-10 09:37:37 +08:00
2025-06-09 15:16:00 +08:00
FROM rk_bill rb
LEFT JOIN stock_in_type st ON rb.rk_type = st.type_code
LEFT JOIN material_type mt ON rb.wl_type = mt.type_code
LEFT JOIN warehouse_info wh ON rb.cangku = wh.warehouse_code
2025-06-10 09:37:37 +08:00
LEFT JOIN stock_out_type sot ON rb.ck_type = sot.ck_type_code
LEFT JOIN construction_team ct ON rb.team_code = ct.team_code
2025-06-09 15:16:00 +08:00
WHERE rb.is_delete = '0'
<if test="billNo != null and billNo != ''">
AND rb.bill_no LIKE CONCAT('%', #{billNo}, '%')
</if>
ORDER BY rb.rk_time DESC
</select>
2025-06-10 09:37:37 +08:00
2025-06-09 15:16:00 +08:00
<!-- 根据单据号查询单条 -->
<select id="selectRkBillByBillNo" resultType="com.zg.project.wisdom.domain.RkBill">
SELECT
2025-06-10 09:37:37 +08:00
rb.id,
rb.rk_type, st.type_name AS rkTypeName,
rb.wl_type, mt.type_name AS wlTypeName,
rb.cangku, wh.warehouse_name AS cangkuName,
rb.rk_time, rb.lihuo_y,
rb.ck_type, sot.ck_type_name AS ckTypeName,
rb.ck_time, rb.ck_lihuo_y,
rb.ck_remark, rb.team_code, ct.team_name AS teamName,
rb.bill_no, rb.is_chuku, rb.is_delete,
rb.created_by AS createBy, rb.created_at AS createTime,
rb.updated_by AS updateBy, rb.updated_at AS updateTime,
rb.remark
FROM rk_bill rb
LEFT JOIN stock_in_type st ON rb.rk_type = st.type_code
LEFT JOIN material_type mt ON rb.wl_type = mt.type_code
LEFT JOIN warehouse_info wh ON rb.cangku = wh.warehouse_code
LEFT JOIN stock_out_type sot ON rb.ck_type = sot.ck_type_code
LEFT JOIN construction_team ct ON rb.team_code = ct.team_code
WHERE rb.bill_no = #{billNo} AND rb.is_delete = '0'
2025-06-09 15:16:00 +08:00
LIMIT 1
</select>
<!-- 查询详情 -->
<select id="selectRkBillById" resultType="com.zg.project.wisdom.domain.RkBill">
2025-06-10 09:37:37 +08:00
SELECT
rb.id,
rb.rk_type, st.type_name AS rkTypeName,
rb.wl_type, mt.type_name AS wlTypeName,
rb.cangku, wh.warehouse_name AS cangkuName,
rb.rk_time, rb.lihuo_y,
rb.ck_type, sot.ck_type_name AS ckTypeName,
rb.ck_time, rb.ck_lihuo_y,
rb.ck_remark, rb.team_code, ct.team_name AS teamName,
rb.bill_no, rb.is_chuku, rb.is_delete,
rb.created_by AS createBy, rb.created_at AS createTime,
rb.updated_by AS updateBy, rb.updated_at AS updateTime,
rb.remark
FROM rk_bill rb
LEFT JOIN stock_in_type st ON rb.rk_type = st.type_code
LEFT JOIN material_type mt ON rb.wl_type = mt.type_code
LEFT JOIN warehouse_info wh ON rb.cangku = wh.warehouse_code
LEFT JOIN stock_out_type sot ON rb.ck_type = sot.ck_type_code
LEFT JOIN construction_team ct ON rb.team_code = ct.team_code
WHERE rb.id = #{id} AND rb.is_delete = '0'
2025-06-09 15:16:00 +08:00
</select>
<!-- 修改 -->
<update id="updateRkBill" parameterType="com.zg.project.wisdom.domain.RkBill">
UPDATE rk_bill
2025-06-10 09:37:37 +08:00
<set>
<if test="rkType != null">rk_type = #{rkType},</if>
<if test="wlType != null">wl_type = #{wlType},</if>
<if test="cangku != null">cangku = #{cangku},</if>
<if test="rkTime != null">rk_time = #{rkTime},</if>
<if test="lihuoY != null">lihuo_y = #{lihuoY},</if>
<if test="ckType != null">ck_type = #{ckType},</if>
<if test="ckTime != null">ck_time = #{ckTime},</if>
<if test="ckLihuoY != null">ck_lihuo_y = #{ckLihuoY},</if>
<if test="ckRemark != null">ck_remark = #{ckRemark},</if>
<if test="teamCode != null">team_code = #{teamCode},</if>
<if test="billNo != null">bill_no = #{billNo},</if>
<if test="isChuku != null">is_chuku = #{isChuku},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="updateBy != null">updated_by = #{updateBy},</if>
<if test="updateTime != null">updated_at = #{updateTime},</if>
</set>
2025-06-09 15:16:00 +08:00
WHERE id = #{id}
</update>
<!-- 批量逻辑删除 -->
<update id="logicDeleteRkBillByIds">
UPDATE rk_bill
SET is_delete = '1'
WHERE id IN
<foreach collection="ids" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</update>
</mapper>