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.borrow_time,
rb.return_time,
rb.xm_no_ck,
rb.xm_ms_ck,
rb.remark,
rb.is_delivery,
rb.is_delete,
rb.create_by,
rb.create_time,
rb.update_by,
rb.update_time,
rb.is_upload_photo,
rb.demand_dept_name,
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,
ct.team_name AS team_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
LEFT JOIN construction_team ct
ON rb.team_code = ct.team_code
AND ct.is_delete = '0'
INSERT INTO rk_bill (
bill_no,
biz_type,
wl_type,
cangku,
operation_type,
operation_time,
operator,
team_code,
borrow_time,
return_time,
xm_no_ck,
xm_ms_ck,
exec_status,
is_delivery,
remark,
create_by,
create_time,
is_delete,
is_upload_photo,
demand_dept_name
) VALUES (
#{billNo},
#{bizType},
#{wlType},
#{cangku},
#{operationType},
#{operationTime},
#{operator},
#{teamCode},
#{borrowTime},
#{returnTime},
#{xmNoCk},
#{xmMsCk},
#{execStatus},
#{isDelivery},
#{remark},
#{createBy},
#{createTime},
#{isDelete},
#{isUploadPhoto},
#{demandDeptName}
)
UPDATE rk_bill
wl_type = #{wlType},
cangku = #{cangku},
bill_no = #{billNo},
operation_type = #{operationType},
biz_type = #{bizType},
operation_time = #{operationTime},
borrow_time = #{borrowTime},
return_time = #{returnTime},
xm_no_ck = #{xmNoCk},
xm_ms_ck = #{xmMsCk},
exec_status = #{execStatus},
operator = #{operator},
team_code = #{teamCode},
remark = #{remark},
is_delivery = #{isDelivery},
is_delete = #{isDelete},
is_upload_photo = #{isUploadPhoto},
demand_dept_name = #{demandDeptName},
WHERE id = #{id}
UPDATE rk_bill
SET exec_status = #{execStatus}
WHERE bill_no = #{billNo}
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}
UPDATE rk_bill
SET is_delivery = #{isDelivery},
update_time = NOW()
WHERE bill_no = #{billNo}
AND is_delete = '0'