SELECT
ri.*,
/* 出入库类型名称 */
COALESCE(sit.type_name, sot.type_name) AS operation_type_name,
/* 物资类型名称 */
mt.type_name AS wl_type_name,
/* 仓库信息 */
wh.warehouse_name,
wh.parent_warehouse_code,
wh.parent_warehouse_name,
/* 理货员 */
su.nick_name AS operator_name,
/* 库龄 */
DATEDIFF(CURRENT_DATE, ri.operation_time) AS stock_age
FROM rk_info ri
LEFT JOIN stock_in_type sit ON ri.operation_type = sit.type_code
LEFT JOIN stock_out_type sot ON ri.operation_type = sot.type_code
LEFT JOIN material_type mt ON ri.wl_type = mt.type_code
LEFT JOIN warehouse_info wh ON ri.cangku = wh.warehouse_code
LEFT JOIN sys_user su ON ri.operator = su.user_id
DELETE FROM rk_info WHERE id = #{id}
DELETE FROM rk_info
WHERE id IN
#{id}
INSERT INTO rk_info (
operation_type, biz_type, wl_type, cangku, operation_time, operator,
is_chuku, status, exec_status, remark, bill_no,
xj, xm_no, xm_ms, xm_no_ck, xm_ms_ck,
wl_no, wl_ms,
gys_no, gys_mc,
jh_amt, ht_dj, sap_no, xh,
jh_qty, ht_qty, dw, real_qty,
pcode, pcode_id, tray_code, entity_id,
team_code, borrow_time, return_time,
has_moved, is_borrowed,
gys_jh_id,
rdid, rdid_ck, sid,
is_delivery,
fycde_1, fycde_2,
is_update,
create_by, create_time, is_delete
)
VALUES (
#{operationType}, #{bizType}, #{wlType}, #{cangku}, #{operationTime}, #{operator},
#{isChuku}, #{status}, #{execStatus}, #{remark}, #{billNo},
#{xj}, #{xmNo}, #{xmMs}, #{xmNoCk}, #{xmMsCk},
#{wlNo}, #{wlMs},
#{gysNo}, #{gysMc},
#{jhAmt}, #{htDj}, #{sapNo}, #{xh},
#{jhQty}, #{htQty}, #{dw}, #{realQty},
#{pcode}, #{pcodeId}, #{trayCode}, #{entityId},
#{teamCode}, #{borrowTime}, #{returnTime},
#{hasMoved}, #{isBorrowed},
#{gysJhId},
#{rdid}, #{rdidCk}, #{sid},
#{isDelivery},
#{fycde1}, #{fycde2},
#{isUpdate},
#{createBy}, #{createTime}, #{isDelete}
)
UPDATE rk_info
operation_type = #{operationType},
biz_type = #{bizType},
wl_type = #{wlType},
cangku = #{cangku},
operation_time = #{operationTime},
operator = #{operator},
is_chuku = #{isChuku},
status = #{status},
exec_status = #{execStatus},
remark = #{remark},
bill_no = #{billNo},
xj = #{xj},
xm_no = #{xmNo},
xm_ms = #{xmMs},
xm_no_ck = #{xmNoCk},
xm_ms_ck = #{xmMsCk},
wl_no = #{wlNo},
wl_ms = #{wlMs},
gys_no = #{gysNo},
gys_mc = #{gysMc},
jh_amt = #{jhAmt},
ht_dj = #{htDj},
sap_no = #{sapNo},
xh = #{xh},
jh_qty = #{jhQty},
ht_qty = #{htQty},
dw = #{dw},
real_qty = #{realQty},
pcode = #{pcode},
pcode_id = #{pcodeId},
tray_code = #{trayCode},
entity_id = #{entityId},
team_code = #{teamCode},
borrow_time = #{borrowTime},
return_time = #{returnTime},
has_moved = #{hasMoved},
is_borrowed = #{isBorrowed},
gys_jh_id = #{gysJhId},
rdid = #{rdid},
rdid_ck = #{rdidCk},
sid = #{sid},
is_delivery = #{isDelivery},
fycde_1 = #{fycde1},
fycde_2 = #{fycde2},
is_update = #{isUpdate},
update_by = #{updateBy},
update_time = #{updateTime},
is_delete = #{isDelete},
WHERE id = #{id}
UPDATE rk_info
SET exec_status = #{execStatus}
WHERE id IN
#{id}
update rk_info
set real_qty = #{realQty},
update_time = now()
where id = #{id}
update rk_info
set is_chuku = #{isChuku},
update_time = now()
where id = #{id}
UPDATE rk_info
SET is_borrowed = #{isBorrowed},
return_time = #{returnTime},
update_time = NOW()
WHERE id = #{id}