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} DELETE FROM rk_bill WHERE id = #{id} DELETE FROM rk_bill WHERE id IN #{id}