lq =...(+) 修改

来源:百度文库 编辑:神马文学网 时间:2024/04/27 23:16:21
--处理科室领用
select detl.*,
       dict.material_name,
       dict.specification,
       dict.durable_flag,
       unit.name unit_name,
       class.class_name,
       base.shelf_no,
       drawer.name drawer_name,
       giver.name giver_name,
       ql_acct.acct_name unit_ql,
       acct.acct_name unit_in,
       zd_group.group_name,
       out_type.name out_name,
       manu.manu_name,
       0 back_amount,
       in_detl.current_stock_amount  ,
       dict.repeat_use_flag
from wz_out_detl detl,
     wz_dict dict,
     wz_base base,
     wz_zd_unit unit,
     wz_zd_class class,
     a_employee_mi drawer,
     a_employee_mi giver,
     wz_zd_inner_acct_no ql_acct,
     wz_zd_inner_acct_no acct,
     wz_zd_group zd_group,
     wz_zd_in_out_type out_type,
     wz_in_detl in_detl,
     wz_zd_manufacture manu
where detl.material_code = dict.material_code
  and detl.kzh_no = dict.kzh_no
  and dict.unit = unit.code(+)
  and detl.class_code = class.class_code
  and detl.kzh_no = class.kzh_no
  and detl.material_code = base.material_code
  and detl.group_no_out = base.group_no
  and detl.drawer = drawer.emp_sn(+)
  and detl.giver = giver.emp_sn(+)
  and detl.ql_inner_acct_no = ql_acct.acct_no(+)
  and detl.inner_acct_no = acct.acct_no
  and detl.group_no_out = zd_group.group_no
  and detl.out_type = out_type.code
  and detl.in_date = in_detl.in_date
  and detl.in_seri = in_detl.in_seri
  and (case nvl(in_detl.manu_code,'%') when '%' then dict.manu_code else in_detl.manu_code end) = manu.manu_code   --(+) lq
  and detl.inner_acct_no is not null
  and detl.issue_amount > 0
  and detl.out_type <> '29'
  and detl.group_no_out like :group_out1
  and detl.out_date >= :begin_date1
  and detl.out_date < :end_date1
  and cast(draw_no as varchar2(20)) like :draw_no1
union
--处理移库出库
select detl.*,
       dict.material_name,
       dict.specification,
       dict.durable_flag,
       unit.name unit_name,
       class.class_name,
       base.shelf_no,
       drawer.name drawer_name,
       giver.name giver_name,
       '' unit_ql,
       group_in.group_name unit_in,
       zd_group.group_name,
       out_type.name inout_name,
       manu.manu_name,
       0 back_amount,
       in_detl.current_stock_amount  ,
       dict.repeat_use_flag
from wz_out_detl detl,
     wz_dict dict,
     wz_base base,
     wz_zd_unit unit,
     wz_zd_class class,
     a_employee_mi drawer,
     a_employee_mi giver,
     wz_zd_group group_in,
     wz_zd_group zd_group,
     wz_zd_in_out_type out_type,
     wz_in_detl in_detl,
     wz_zd_manufacture manu
where detl.material_code = dict.material_code
  and detl.kzh_no = dict.kzh_no
  and dict.unit = unit.code(+)
  and detl.class_code = class.class_code
  and detl.kzh_no = class.kzh_no
  and detl.material_code = base.material_code
  and detl.group_no_out = base.group_no
  and detl.drawer = drawer.emp_sn(+)
  and detl.giver = giver.emp_sn(+)
  and detl.group_no_in = group_in.group_no
  and detl.group_no_out = zd_group.group_no
  and detl.out_type = out_type.code
  and detl.in_date = in_detl.in_date
  and detl.in_seri = in_detl.in_seri
  and (case nvl(in_detl.manu_code,'%') when '%' then dict.manu_code else in_detl.manu_code end) = manu.manu_code --(+) lq exceptions
  and detl.group_no_in is not null
  and detl.group_no_out <> detl.group_no_in
  and detl.issue_amount > 0
  and detl.group_no_out like :group_out2
  and detl.out_date >= :begin_date2
  and detl.out_date < :end_date2
  and cast(draw_no as varchar2(20)) like :draw_no2
--处理调拨
union
select detl.*,
       dict.material_name,
       dict.specification,
       dict.durable_flag,
       unit.name unit_name,
       class.class_name,
       base.shelf_no,
       drawer.name drawer_name,
       giver.name giver_name,
       '' unit_ql,
       rtrim(ltrim(detl.allo_unit)) unit_in,
       zd_group.group_name,
       out_type.name out_name,
       manu.manu_name,
       0 back_amount,
       in_detl.current_stock_amount  ,
      dict.repeat_use_flag
from wz_out_detl detl,
     wz_dict dict,
     wz_base base,
     wz_zd_unit unit,
     wz_zd_class class,
     a_employee_mi drawer,
     a_employee_mi giver,
     wz_zd_group zd_group,
     wz_zd_in_out_type out_type,
     wz_in_detl in_detl,
     wz_zd_manufacture manu
where detl.material_code = dict.material_code
  and detl.kzh_no = dict.kzh_no
  and dict.unit = unit.code(+)
  and detl.class_code = class.class_code
  and detl.kzh_no = class.kzh_no
  and detl.material_code = base.material_code
  and detl.group_no_out = base.group_no
  and detl.drawer = drawer.emp_sn(+)
  and detl.giver = giver.emp_sn(+)
  and detl.group_no_out = zd_group.group_no
  and detl.out_type = out_type.code
  and detl.in_date = in_detl.in_date
  and detl.in_seri = in_detl.in_seri
  and (case nvl(in_detl.manu_code,'%') when '%' then dict.manu_code else in_detl.manu_code end) = manu.manu_code --(+) lq
  and rtrim(ltrim(nvl(detl.allo_unit,''))) is not null
  and issue_amount > 0
  and detl.group_no_out like :group_out3
  and detl.out_date >= :begin_date3
  and detl.out_date < :end_date3
  and cast(draw_no as varchar2(20)) like :draw_no3
order by shelf_no,
         class_name,
         material_name