大数据企业异常发票分析

 

一、   数据说明:

1、数据组成

(1)增值税发票数据,文件名zzsfp

(2)发票对应货物明细数据,文件名zzsfp_hwmx

(3)企业信息,文件名nsrxx

2、数据字段说明

1zzsfp表字典

字段名称

字段含义

数据类型

备注

fp_nid

发票id

String

发票唯一标识

xf_id

销方识别号

String

企业唯一身份标识

gf_id

购方识别号

String

企业唯一身份标识

je

金额

Double

 

se

税额

Double

 

jshj

价税合计

Double

 

kpyf

开票月份

String

 

kprq

开票日期

String

 

zfbz

作废标志

String

‘Y’代表作废

 

2381619

2483868

zzsfp表内容($ less zzsfp

 

2zzsfp_hwmx

字段名称

字段含义

数据类型

备注

fp_nid

发票id

String

发票唯一标识

date_key

开票月份

String

 

hwmc

货物名称

String

 

ggxh

规格型号

String

 

dw

单位

String

 

sl

数量

Double

 

dj

单价

Double

 

je

金额

Double

 

se

税额

Double

 

spbm

商品编码

String

 

zzsfp_hwmx表内容($ less zzsfp_hwmx)

 

3nsrxx

字段名称

字段含义

数据类型

备注

hydm

行业代码

String

 

nsr_id

纳税人id

String

企业唯一身份标识

djzclx_dm

登记注册类型代码

String

网上可查阅相关代码含义

kydjrq

开业登记日期

String

 

xgrq

修改日期

String

给企业打标签的时间

label

标签

String

‘0’代表正常企业

‘1’代表问题企业

nsrxx表内容($ less nsrxx)

 

3、关联数据的必要说明

(1)zzsfp表可通过fp_nid进行关联

(2)zzsfp表可通过xf_id或者gf_id与nsrxx中的nsr_id进行关联,分离出销项发票表和进项发票表

二、    测试要求:

1、数据导入:

   要求将三个样表文件中的数据导入HIVE数据仓库中。

2、数据分析:

   企业异常的判断标准参考:

    (1)、企业增值税发票进项与出项严重不符即出现只出不进或者只进不出的企业;

    (2)企业发票数据与详细流水信息不符;

    (3)个人上网查阅企业异常信息数据标准;

3、处理结果入库:

   将上述异常标准的结果分别汇总统计,并将结果数据导出到mySQL数据库中。

   最终结果参考提示:

          最终给出的数据情况

企业总数:33,829

非正常企业总数:318

 

4、数据可视化展示:

   利用Echarts将上述统计结果以图形化展示的方式展现出来:饼图、柱状图、地图、折线图等。

三、    测试报告:

1、按照测试题目顺序,将实验步骤说明和结果截图存储到答题纸上。

            

创建表

create table tab051(

fp_nid string,

xf_id string,

gf_id string,

je double,

se double,

jshj double,

kpyf string,

kprq string,

zfbz string

)

row format delimited fields terminated by ','

lines terminated by '\n';

create table tab052(

fp_nid string,

date_key string,

hwmc string,

ggxh string,

dw string,

sl double,

dj double,

je double,

se double,

spbm string

)

row format delimited fields terminated by ','

lines terminated by '\n';

create table tab053(

hydm string,

nsr_id string,

djzclx_dm string,

kydjrq string,

xgrq string,

label string

)

row format delimited fields terminated by ','

lines terminated by '\n';

导入数据

 

 

 

再创三个表用于存放清洗括号后的数据

create table tab51(

fp_nid string,

xf_id string,

gf_id string,

je double,

se double,

jshj double,

kpyf string,

kprq string,

zfbz string

)

row format delimited fields terminated by ','

lines terminated by '\n';

create table tab52(

fp_nid string,

date_key string,

hwmc string,

ggxh string,

dw string,

sl double,

dj double,

je double,

se double,

spbm string

)

row format delimited fields terminated by ','

lines terminated by '\n';

create table tab53(

hydm string,

nsr_id string,

djzclx_dm string,

kydjrq string,

xgrq string,

label string

)

row format delimited fields terminated by ','

lines terminated by '\n';

存放数据

insert overwrite table tab51 select 

translate(fp_nid,'(',''),

xf_id,

gf_id,

je,

se,

jshj,

kpyf,

kprq,

translate(zfbz, ')', '')

from tab051;

insert overwrite table tab52 select 

translate(fp_nid,'(',''),

date_key,

hwmc,

ggxh,

dw,

sl,

dj,

je,

se,

translate(spbm, ')', '')

from tab052;

insert overwrite table tab53 select 

translate(hydm,'(',''),

nsr_id,

djzclx_dm,

kydjrq,

xgrq,

translate(label, ')', '')

from tab053;

 

 

 

1.将没有进行过交易的企业列入问题企业

nsert into table noxf select hydm from tab53 where not exists (select xf_id from tab51 where tab53.hydm=tab51.xf_id);

insert into table noxf select hydm from tab53 where not exists (select gf_id from tab51 where tab53.hydm=tab51.gf_id);

select distinct id from noxf;

insert into noxfandgf select distinct id from noxf;

有一万多家。

 

2.查出企业开出的支票作废次数,放到zf表。

select xf_id, gf_id ,count(zfbz) from tab51 where zfbz = 'Y'  group by xf_id,gf_id;

Insert into table zf(xf_id,gf_id,zfcs) (select xf_id, gf_id ,count(zfbz) from tab51 where zfbz = 'Y'  group by xf_id,gf_id);

SELECT COUNT(*) FROM zf WHERE zfcs>17;查询作废次数大于中位数17的

有684家。

放入wt表。

create table wt2(id string);

insert overwrite table wt(SELECT xf_id FROM zf WHERE zfcs>17);

insert into table wt(SELECT gf_id FROM zf WHERE zfcs>17);

3.查出企业支票金额相差幅度太大的企业

select xf_id from tab51 join tab52 on tab51.fp_nid=tab52.fp_nid where tab51.je-tab52.je>10000000 or tab52.je-tab51.je>10000000;

然后按次数查出开假支票次数多的企业。

select id,count(id) from jewt group by id;

select id from jewt3 cs where cs>1;

 

合并三个标准。

insert into wt12 select wt.id from wt join wt2 where wt.id=wt2.id;

insert into wt13 select wt.id from wt join wt3 where wt.id=wt3.id;

insert into wt23 select wt2.id from wt2 join wt3 where wt2.id=wt3.id;

最后查出385家

 

原文地址:https://www.cnblogs.com/a8047/p/15652398.html