
create or replace view tjfxview as
(select t1.dwdm as zsdw,
       '' as tjfw,
       t1.accept_no as slbh,
       t1.case_no as zjbh,
       '滮()' as mjyj,
       t1.xxdjbh as xxbbh,
       t1.build_department as jsdwmc,
       t1.build_item as gcxmmc,
       t1.build_place as gcmxdz,
       '' as lxpw,
       to_char(t1.check_area) as zjsmj,
       (case t1.process_type when '0001'then 'ֱӽɷ' when '0002'then '' when '0003' then '' when '0004' then '' when '0005' then 'Ƕ' when '0006' then 'صƷ' end ) as bllb,
      (case t1.policy_type when '1000' then '췢[1999]113' when '1100' then '췢[1999]113'
      when '2000' then 'ĵ' when '2100' then 'ĵ' when '3000' then 'йļ涨' when '3100' then 'ʽ' when '3200' then 'ũóг([2003]49)' when '3300' then
        'ͣ' when '3400' then  'ҵصĿ(췢[1999]66)' when '3500' then 'ũóг([2003]49)' when '3600' then 'صҵ԰(ί[2002]13)'
        when '3700' then 'ҵصĿ(ί[2003]39)' when '4000' then '' when '4100' then '' when '4300' then 'Ҫ' when '4400'then '÷([2008]116)'
        when '5100' then '˸([2006]226)' when '6000' then '[2003]104' when '6100' then '[2003]104'
        when '7000' then 'ҵصĿ([2000]94)' when '7100' then 'ҵصĿ([2000]94)' when '7101' then '÷([2004]253)' when '7102' then '[2004]253'
        when '7103' then 'Ŀ([2006]286ŵ)' when '7104' then 'Ͷҵ(200636ŵ)' when '7105' then '' when '7106' then '÷([2008]116)'
         when '7107' then 'Σɷ([2008]22)' when '7108' then 'Ͷҵ(200636ŵ)' when '7109' then 'СѧУ(۷[2010]16ŵ)'
         when '7110' then 'ֵ(ղ[2007]80)' when '7111' then '弶([2010]76)' when '7112' then 'СѧУ(۷[2010]16ŵ)'
           when '7113' then 'Ŀ([2006]286ŵ)' when '7114' then 'Ͻƴ([2014]171)' when '7115' then '[2016]5'  end
       )as zclb ,
       '' as jktk,
       '' as bxzd2,
       '' as lmlb,
       to_char(t2.fee_0001*10000) as ptyjje,
       to_char(t2.fee_0002*10000) as ptymje,
       to_char(t4.check_time,'yyyy-mm-dd') as lcjssj,
       to_char(t3.OPERATE_TIME,'yyyy-mm-dd') as createTime,
       to_char(t1.accept_Time,'yyyy-mm-dd') as slsj,
       to_char(t3.pay_money*10000) as sjcsje,
       t3.receipt_no as voucher_Code,
       t1.message_No as dzbh,
       '' as dzbh1,
       t1.zsjxdbh as zslxdbh,
       '' as ecn,
       t1.file_No as anno,
       '' as isdikou,
       '' as lsck,
       to_char(t5.fee) as cd,
        to_char(t3.CHARGE_TIME,'yyyy-mm-dd') as dzdate,
         to_char(t2.fee_0003*10000) as pthjje
  from (select * from HISSFCJBXXB where info_Process in ('A','7','8','9')) t1
  left join fymxb t2
    on t1.accept_no = t2.accept_no
    left join (select * from HISSFJFJLB where HISSFJFJLB.ROW_ID in  (select min(t2.ROW_ID) from  (select * from  HISSFJFJLB where HISSFJFJLB.Pay_Class='1100') t2 group by t2.accept_no))t3 on t1.accept_no=t3.accept_no
    left join  (select max(check_time) check_time,accept_no from hissfspjlb group by  accept_no) t4 on t1.accept_no=t4.accept_no
    left join  (select sum(fee) fee,a.accept_no from  ( select t.fee,t.accept_no  from HISSFXXB t  left join hissfcjbxxb tt on t.accept_no=tt.accept_no where   capture_type='0005' and tt.process_type='0003') a   group by a.accept_no )t5 on t1.accept_no=t5.accept_no 
union all
select t1.dwdm as zsdw,
       '' as tjfw,
       t1.accept_no as slbh,
       t1.case_no as zjbh,
       '滮()' as mjyj,
       t1.xxdjbh as xxbbh,
       t1.build_department as jsdwmc,
       t1.build_item as gcxmmc,
       t1.build_place as gcmxdz,
       '' as lxpw,
       to_char(t1.check_area) as zjsmj,
       (case t1.process_type when '0001'then 'ֱӽɷ' when '0002'then '' when '0003' then '' when '0004' then '' when '0005' then 'Ƕ' when '0006' then 'صƷ' when '0007' then '³' when '0009' then 'Ң³' end ) as bllb,
      (case t1.policy_type when '1000' then '췢[1999]113' when '1100' then '췢[1999]113'
      when '2000' then 'ĵ' when '2100' then 'ĵ' when '3000' then 'йļ涨' when '3100' then 'ʽ' when '3200' then 'ũóг([2003]49)' when '3300' then
        'ͣ' when '3400' then  'ҵصĿ(췢[1999]66)'
      when '4000' then '' when '4100' then '' when '4200' then 'Ҫ' when '4300' then '÷([2008]116)' 
        when '5100' then '[2003]104' when '5101' then  '췢[2003]49Ĺ涨(ũóг)' when '5102' then 'صҵ԰(ί[2002]13)' when '5103' then 'ί[2003]39' when '5104' then 'ҵصĿ([2000]94)'
          when '5105' then '÷([2008]116)' when '5106' then 'СѧУ(۷[2010]16ŵ)' when '5107' then '[2016]5' end
       )as zclb ,
       '' as jktk,
       '' as bxzd2,
       '' as lmlb,
       to_char(t5.fee) as ptyjje,
       to_char(t6.fee) as ptymje,
       to_char(t4.check_time,'yyyy-mm-dd') as lcjssj,
       to_char(t3.OPERATE_TIME,'yyyy-mm-dd') as createTime,
       to_char(t1.accept_Time,'yyyy-mm-dd') as slsj,
       to_char(t3.pay_money*10000) as sjcsje,
       t3.receipt_no as voucher_Code,
       t1.message_No as dzbh,
       '' as dzbh1,
       t1.zsjxdbh as zslxdbh,
       '' as ecn,
       t1.file_No as anno,
        '' as isdikou,
        '' as lsck,
        '' as cd,
     to_char(t3.CHARGE_TIME,'yyyy-mm-dd') as dzdate,
     to_char(t2.fee_0003*10000) as pthjje
  from (select * from HISXRJBXXB where info_Process in ('A','7','8','9')) t1
  left join HISXRFYMXB t2
    on t1.accept_no = t2.accept_no
    left join (select * from HISXRJFJLB where HISXRJFJLB.ROW_ID in  (select min(t2.ROW_ID) from  (select * from  HISXRJFJLB where HISXRJFJLB.Pay_Class='1100') t2 group by t2.accept_no))t3 on t1.accept_no=t3.accept_no
    left join  (select max(check_time) check_time,accept_no from hisxlspjlb group by  accept_no) t4 on t1.accept_no=t4.accept_no
    left join (select sum(fee) fee,a.accept_no from (select * from HISXRSFXXB where  fee_type='0001' and capture_type='0001') a group by a.accept_no)t5 on t1.accept_no=t5.accept_no
    left join (select sum(fee) fee,a.accept_no from (select * from HISXRSFXXB where  fee_type='0001' and capture_type='0002') a group by a.accept_no)t6 on t1.accept_no=t6.accept_no
union all

select t1.dwdm as zsdw,
       '' as tjfw,
       t1.accept_no as slbh,
       t1.case_no as zjbh,
       '滮()' as mjyj,
       t1.xxdjbh as xxbbh,
       t1.build_department as jsdwmc,
       t1.build_item as gcxmmc,
       t1.build_place as gcmxdz,
       '' as lxpw,
       to_char(t1.check_area) as zjsmj,
        (case t1.process_type when '0001'then 'ֱӽɷ' when '0002'then '' when '0003' then '' when '0004' then '' when '0005' then 'Ƕ' when '0006' then 'صƷ' when '0007' then '³' when '0008' then 'ִѧ' end ) as bllb,
      (case t1.policy_type when '1000' then '췢[1999]113' when '1100' then '췢[1999]113'
      when '2000' then 'ĵ' when '2100' then 'ĵ' when '3000' then 'йļ涨' when '3100' then 'ʽ' when '3200' then 'ũóг([2003]49)' when '3300' then
        'ͣ' when '3400' then  'ҵصĿ(췢[1999]66)' 
        when '4000' then '' when '4100' then ''when '4200' then 'Ҫ'  when '4300' then '÷([2008]116)' 
        when '5100' then '[2003]104' when '6100' then '췢[2003]49Ĺ涨(ũóг)' when '7100' then 'صҵ԰(ί[2002]13)' when '8100' then 'ί[2003]39' when '9100' then 'ҵصĿ([2000]94)'
         when '9101' then '÷([2008]116)' when '9102' then 'Ͻƴ([2014]171)' when '9103' then '۷2014155ļ(У)' when '9104' then '[2000]94(ҵҵصĿ)'
           when '9105' then 'ϵ' when '9106' then 'СѧУ(۷[2010]16ŵ)' when '9107' then '[2016]5' end
       )as zclb ,
       '' as jktk,
       '' as bxzd2,
       '' as lmlb,
       to_char(t5.fee) as ptyjje,
       to_char(t6.fee) as ptymje,
        to_char(t4.check_time,'yyyy-mm-dd') as lcjssj,
       to_char(t3.OPERATE_TIME,'yyyy-mm-dd') as createTime,
       to_char(t1.accept_Time,'yyyy-mm-dd') as slsj,
       to_char(t3.pay_money*10000) as sjcsje,
       t3.receipt_no as voucher_Code,
       t1.message_No as dzbh,
       '' as dzbh1,
       t1.zsjxdbh as zslxdbh,
       '' as ecn,
       t1.file_No as anno,
        '' as isdikou,
        '' as lsck,
        '' as cd,
     to_char(t3.CHARGE_TIME,'yyyy-mm-dd') as dzdate,
      to_char(t2.fee_0003*10000) as pthjje
  from (select * from HISXLJBXXB where info_Process in ('A','7','8','9')) t1
  left join HISXLFYMXB t2
    on t1.accept_no = t2.accept_no
    left join (select * from HISXLJFJLB where HISXLJFJLB.ROW_ID in  (select min(t2.ROW_ID) from  (select * from  HISXLJFJLB where HISXLJFJLB.Pay_Class='1100') t2 group by t2.accept_no))t3 on t1.accept_no=t3.accept_no
    left join  (select max(check_time) check_time,accept_no from hisxlspjlb group by  accept_no) t4 on t1.accept_no=t4.accept_no
        left join (select sum(fee) fee,a.accept_no from (select * from HISXLSFXXB where  fee_type='0001' and capture_type='0001') a group by a.accept_no)t5 on t1.accept_no=t5.accept_no
    left join (select sum(fee) fee,a.accept_no from (select * from HISXLSFXXB where  fee_type='0001' and capture_type='0002') a group by a.accept_no)t6 on t1.accept_no=t6.accept_no
union all

select t1.dwdm as zsdw,
       '' as tjfw,
       t1.accept_no as slbh,
       t1.case_no as zjbh,
       '滮()' as mjyj,
       t1.xxdjbh as xxbbh,
       t1.build_department as jsdwmc,
       t1.build_item as gcxmmc,
       t1.build_place as gcmxdz,
       '' as lxpw,
       to_char(t1.check_area) as zjsmj,
       (case t1.process_type when '0001'then 'ֱӽɷ' when '0002'then '' when '0003' then ''  when '0006' then 'صƷ' when '0007' then '³'   end ) as bllb,
      (case t1.policy_type 
      when '2000' then 'ĵ' when '2100' then 'ĵ' when '3000' then 'йļ涨' when '3100' then 'ʽ' when '3200' then 'ũóг([2003]49)' when '3300' then
        'ͣ' when '3400' then  'ҵصĿ(췢[1999]66)' 
       when '4100' then '' when '4200' then 'и칫98102ŻҪ' when '4300' then 'Ҫ' when '4400'then '÷([2008]116)'
         when '5100' then 'ҵصĿ([2000]94)' when '6100' then '[2003]104' when '7100' then '[1999]49(ũóг)'
           when '8100' then 'صҵ԰(ί[2002]13)' when '9100' then 'ί[2003]39' when '9103' then '[2016]5'
         end
       )as zclb ,
       '' as jktk,
       '' as bxzd2,
       '' as lmlb,
       to_char(t5.fee) as ptyjje,
       to_char(t6.fee) as ptymje,
       to_char(t4.check_time,'yyyy-mm-dd') as lcjssj,
       to_char(t3.OPERATE_TIME,'yyyy-mm-dd') as createTime,
        to_char(t1.accept_Time,'yyyy-mm-dd') as slsj,
       to_char(t3.pay_money*10000) as sjcsje,
       t3.receipt_no as voucher_Code,
       t1.message_No as dzbh,
       '' as dzbh1,
       t1.zsjxdbh as zslxdbh,
       '' as ecn,
       t1.file_No as anno,
        '' as isdikou,
        '' as lsck,
        to_char(t7.fee) as cd ,
     to_char(t3.CHARGE_TIME,'yyyy-mm-dd') as dzdate,
      to_char(t2.fee_0003*10000) as pthjje
        
  from (select * from HISHXJBXXB where info_Process in ('A','7','8','9')) t1
  left join HISHXFYMXB t2
    on t1.accept_no = t2.accept_no
    left join (select * from HISHXJFJLB where HISHXJFJLB.ROW_ID in  (select min(t2.ROW_ID) from  (select * from  HISHXJFJLB where HISHXJFJLB.Pay_Class='1100') t2 group by t2.accept_no))t3 on t1.accept_no=t3.accept_no
    left join  (select max(check_time) check_time,accept_no from hishxspjlb group by  accept_no) t4 on t1.accept_no=t4.accept_no
        left join (select sum(fee) fee,a.accept_no from (select * from HISHXSFXXB where  fee_type='0001' and capture_type='0001') a group by a.accept_no)t5 on t1.accept_no=t5.accept_no
    left join (select sum(fee) fee,a.accept_no from (select * from HISHXSFXXB where  fee_type='0001' and capture_type='0002') a group by a.accept_no)t6 on t1.accept_no=t6.accept_no
      left join  (select sum(fee) fee,a.accept_no from  ( select t.fee,t.accept_no  from HISHXSFXXB t  left join hishxjbxxb tt on t.accept_no=tt.accept_no where   capture_type='0005' ) a   group by a.accept_no )t7 on t1.accept_no=t7.accept_no 
union all

select t1.dwdm as zsdw,
       t2.tjfw,
       t1.slbh,
       t2.zjbh,
        (case t1.mjyj when '001' then '滮()' when '002' then '()' when '003' then '׵Ǽ(Ͻƴ)' when '004' then 'İ(Ӫ÷)' when '005' then '滮()' end) ,
       t2.xxbbh,
       t2.jsdwmc,
       t2.gcxmmc,
       t2.gcxmdz,
       t1.lxpw,
       t1.zjsmj,
       t2.bllb,
       t2.zclb,
       t3.jktk,
       t1.bxzd2,
       t3.jmlb,
       t5.ptyjje,
       t4.ptymje,
       to_char(t2.lcjssj,'yyyy-mm-dd'),
       to_char(t5.createtime,'yyyy-mm-dd'),
       to_char(t2.slsj,'yyyy-mm-dd'),
       t5.ptyjje,
       t6.Voucher_Code,
       t7.dzbh,
       t8.dzbh as dzbh1,
       t5.zslxdbh,
       t5.ecn,
       t9.dano,
       t1.isdikou,
       t1.lsck,
       '' as cd,
       t10.rkdate as dzdate,
      ''as pthjje
  from (select * from xmxxb  where issptg=0) t1
  left join (select * from spjlb where delflag=0) t2
    on t1.slbh = t2.slbh
left join (select * from jkmx where ROW_ID in(select min(ROW_ID)
  from jkmx
 where delflag = 0
   and jklb =0 group by slbh ))t3 on t1.slbh=t3.slbh
    left join (select * from spjkjl where delflag=0 ) t4 on t1.slbh=t4.slbh
    left join (select * from payment_item_his where delflag=0) t5 on t1.slbh=t5.slbh
    left join (select * from payment_voucher_his where delflag=0 and apply_status='0') t6 on t1.slbh=t6.order_id
    left join (select * from jktzs where delflag =0 ) t7 on t1.slbh=t7.slbh
     left join (select * from cktzs) t8 on t1.slbh=t8.slbh
     left join (select * from guidang  where delflag=0) t9 on t1.slbh=t9.slbh
          left join (select *  from pjjx where delflag=0) t10 on t1.slbh=t10.slbh
 where t1.delflag = 0

 union all

 select dwdm as zsdw,
       '' as tjfw,
       slbh as slbh,
        '' as zjbh,
       '' as mjyj,
       '' as xxbbh,
       zsdw as jsdwmc,
       xmmc as gcxmmc,
       xmdz as gcxmdz,
       '' as lxpw,
       zjmj as zjsmj,
       bllb as bllb,
       zclb as zclb,
       '' as jktk,
       '' as bxzd2,
       '' as jmlb,
       to_char(to_number(yjje)*10000) as ptyjje,
         to_char(to_number(ymje)*10000) as ptymje,
       spxx as lcjssj,
       '' as createTime,
      spxx as slsj,
       '' as sjcsje,
       '' as voucher_Code,
       '' as dzbh,
       '' as dzbh1,
       '' as zslxdbh,
       '' as ecn,
       dah as dano,
        '' as isdikou,
        '' as lsck,
        to_char(to_number(cd1)*10000) as cd,
  '' as dzdate,
 to_char(to_number(hj1)*10000) as pthjje
  from lsfc);
