SELECT
rb.id,
rb.wl_type,
rb.cangku,
rb.bill_no,
rb.operation_type,
rb.biz_type,
rb.operation_time,
rb.exec_status,
rb.operator,
rb.team_code,
rb.remark,
rb.is_delivery,
rb.is_delete,
mt.type_name AS wl_type_name,
COALESCE(sit.type_name, sot.type_name) AS operation_type_name,
su.nick_name AS operator_name,
wh.warehouse_name AS warehouse_name,
wh.parent_warehouse_name AS parent_warehouse_name
FROM rk_bill rb
LEFT JOIN warehouse_info wh
ON rb.cangku = wh.warehouse_code
AND wh.status = 1
LEFT JOIN material_type mt
ON rb.wl_type = mt.type_code
AND mt.status = 1
LEFT JOIN stock_in_type sit
ON rb.operation_type = sit.type_code
AND sit.status = 1
LEFT JOIN stock_out_type sot
ON rb.operation_type = sot.type_code
AND (sot.is_delete = '0' OR sot.is_delete IS NULL)
LEFT JOIN sys_user su
ON rb.operator = su.user_id
INSERT INTO rk_bill (
bill_no,
biz_type,
wl_type,
cangku,
operation_type,
operation_time,
operator,
exec_status,
is_delivery,
remark,
create_by,
create_time,
is_delete
) VALUES (
#{billNo},
#{bizType},
#{wlType},
#{cangku},
#{operationType},
#{operationTime},
#{operator},
#{execStatus},
#{isDelivery},
#{remark},
#{createBy},
#{createTime},
#{isDelete}
)
UPDATE rk_bill
wl_type = #{wlType},cangku = #{cangku},bill_no = #{billNo},operation_type = #{operationType},biz_type = #{bizType},operation_time = #{operationTime},exec_status = #{execStatus},operator = #{operator},team_code = #{teamCode},remark = #{remark},is_delivery = #{isDelivery},is_delete = #{isDelete},
WHERE id = #{id}
UPDATE rk_bill
SET exec_status = #{execStatus}
WHERE bill_no = #{billNo}
DELETE FROM rk_bill WHERE id = #{id}
DELETE FROM rk_bill
WHERE id IN
#{id}