Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Z
zhj-report
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
data-spider
zhj-report
Commits
e4a9a576
Commit
e4a9a576
authored
Nov 21, 2019
by
董建华
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
数据上报
parent
ae762cd0
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
263 additions
and
65 deletions
+263
-65
ReportController.java
src/main/java/com/controller/ReportController.java
+1
-0
ErrorReson.java
src/main/java/com/emums/ErrorReson.java
+30
-0
InfoType.java
src/main/java/com/emums/InfoType.java
+0
-3
ReportService.java
src/main/java/com/service/report/ReportService.java
+4
-0
IReportServiceImpl.java
...main/java/com/service/report/impl/IReportServiceImpl.java
+126
-10
ReportTimer.java
src/main/java/com/timer/ReportTimer.java
+3
-3
Utils.java
src/main/java/com/util/Utils.java
+99
-49
No files found.
src/main/java/com/controller/ReportController.java
View file @
e4a9a576
...
...
@@ -200,3 +200,4 @@ public class ReportController {
return
sb
.
substring
(
0
,
sb
.
length
()
-
1
);
}
}
src/main/java/com/emums/ErrorReson.java
0 → 100644
View file @
e4a9a576
package
com
.
emums
;
import
lombok.Getter
;
@Getter
public
enum
ErrorReson
{
E032
(
"0000032"
,
"同一债权融资交易信息文件中,任意两条债权融资交易信息的“业务发生机构”、“业务号、“业务发生日期”不能完全相同"
),
E000
(
"0000000"
,
"其他错误"
),
E101
(
"7001101"
,
"业务类型不在数据字典列表中"
),
E102
(
"7002102"
,
"业务种类不在数据字典列表中"
),
E108
(
"8002108"
,
"证件类型不在数据字典列表中"
),
E013
(
"7007013"
,
"当业务类型非 4-循环时,“授信金额”须大于等于“余额”"
),
E008
(
"7004008"
,
"“开户日期”<=“文件生成时间”中的日期,“开户日期”<=“到期日期”,“开户日期”<=“业务发生日期”"
),
E014
(
"7010014"
,
"“业务发生日期应小于等于文件报送日期/文件生成日期”"
),
E011
(
"7014011"
,
"“本月还款状态”为“C-结清或销户”时,“余额”必须为零"
),
E0111
(
"7016011"
,
"“本月还款状态”为“C-结清或销户”时,“当前逾期总额”必须为零"
),
E012
(
"7023012"
,
"本月还款状态为“1-7”时,“当前逾期金额”应大于零 "
),
E901
(
"7022901"
,
"数据库中记录前最近一个月的“本月还款状态”必须为“C-结清或销户”以外的值;"
),
E902
(
"7022902"
,
"当记录为漏报记录时,则“本月还款状态”不能为“C-结清或销户”"
),
E903
(
"6001903"
,
"业务发生机构(组织机构代码)不在数据字典列表中"
),
;
private
String
errorCode
;
private
String
errorReson
;
private
ErrorReson
(
String
errorCode
,
String
errorReson
)
{
this
.
errorCode
=
errorCode
;
this
.
errorReson
=
errorReson
;
}
}
src/main/java/com/emums/InfoType.java
View file @
e4a9a576
package
com
.
emums
;
import
lombok.Getter
;
public
enum
InfoType
{
CREDIT_FINANCING_INFO
(
"12"
,
"个人债权融资信息"
),
DELETE_INFO
(
"00"
,
"刪除信息"
),
...
...
src/main/java/com/service/report/ReportService.java
View file @
e4a9a576
...
...
@@ -15,6 +15,8 @@ public interface ReportService {
FileEntry
creatZipFile
(
String
date
,
List
<
Map
<
String
,
Object
>>
dataList
,
InfoType
infoType
,
BusinessType
businessType
)
throws
QgException
;
FileEntry
creatZipFileByString
(
List
<
String
>
dataList
,
InfoType
infoType
,
BusinessType
businessType
,
int
index
)
throws
QgException
;
void
creatTxtFile
(
String
filePath
,
List
<
Map
<
String
,
Object
>>
dataList
,
InfoType
infoType
,
BusinessType
businessType
,
boolean
isDesensitization
)
throws
QgException
;
List
<
Map
<
String
,
Object
>>
getDataAsync
(
Map
<
String
,
String
>
param
);
...
...
@@ -39,4 +41,6 @@ public interface ReportService {
void
runData
(
String
date
);
void
runMonthData
(
String
date
);
void
autoReReport
(
String
path
);
}
src/main/java/com/service/report/impl/IReportServiceImpl.java
View file @
e4a9a576
This diff is collapsed.
Click to expand it.
src/main/java/com/timer/ReportTimer.java
View file @
e4a9a576
...
...
@@ -38,7 +38,7 @@ public class ReportTimer {
}
//每天凌晨2点
//
@Scheduled(cron = "0 0 2 * * ?")
@Scheduled
(
cron
=
"0 0 2 * * ?"
)
void
reportDayData
()
{
if
(!
isRun
)
{
return
;
...
...
@@ -59,7 +59,7 @@ public class ReportTimer {
}
//每月1次
//
@Scheduled(cron = "0 0 3 1 1/1 ?")
@Scheduled
(
cron
=
"0 0 3 1 1/1 ?"
)
void
reportMonthData
()
{
if
(!
isRun
)
{
return
;
...
...
@@ -75,7 +75,7 @@ public class ReportTimer {
}
//一小时一次 延迟10秒
//
@Scheduled(fixedDelay = 1000 * 60 * 60, initialDelay = 10000)
@Scheduled
(
fixedDelay
=
1000
*
60
*
60
,
initialDelay
=
10000
)
public
void
quaryReportedStatus
()
{
//测试先去掉这个限制
if
(!
isRun
)
{
...
...
src/main/java/com/util/Utils.java
View file @
e4a9a576
...
...
@@ -270,9 +270,13 @@ public class Utils {
return
new
BigDecimal
(
String
.
valueOf
(
val
)).
setScale
(
0
,
BigDecimal
.
ROUND_HALF_UP
).
toString
();
}
public
static
String
getStr
(
String
str
)
{
public
static
String
getStr
(
String
str
,
int
indx
)
{
String
[]
split
=
str
.
split
(
","
,
0
);
return
split
[
4
];
return
split
[
indx
];
}
public
static
String
getStr
(
String
str
)
{
return
getStr
(
str
,
4
);
}
public
static
Collection
<
String
>
getData
(
File
file
,
Collection
<
String
>
list
)
{
...
...
@@ -321,8 +325,8 @@ public class Utils {
List
<
T
>
item
=
new
ArrayList
<>();
for
(
int
j
=
i
*
size
;
(
j
<
(
i
+
1
)
*
size
&&
j
<
allSize
);
j
++)
{
T
t
=
data
.
get
(
j
);
if
(
t
instanceof
Map
)
{
((
Map
<
String
,
Object
>)
t
).
put
(
"type"
,
type
);
if
(
t
instanceof
Map
)
{
((
Map
<
String
,
Object
>)
t
).
put
(
"type"
,
type
);
}
item
.
add
(
t
);
}
...
...
@@ -331,51 +335,97 @@ public class Utils {
return
result
;
}
public
static
void
main
(
String
[]
args
)
{
//// Set<String> list = new HashSet<>();
// List<String> list = new ArrayList<>();
//// File file = new File("D:\\report\\ids.txt");
// File newfile = new File("D:\\report\\10月份数据");
// getData(newfile, list);
// System.err.println("分割前总大小:"+list.size());
// List<List<String>> lists = subList(list, 1000);
// int count = 0;
// for (List<String> stringList : lists) {
// for (String s : stringList) {
// count++;
// }
//
// }
//
// System.err.println("分割后总大小:"+count);
// list.stream().forEach(o->{
// try {
// FileUtils.write(newfile,o+"\r\n","GBK",true);
//
// }catch (Exception e){
// e.printStackTrace();
// }
// });
// list.stream().close();
// List<String> list2 = new ArrayList<>();
// File file2 = new File("D:\\report\\9月份数据");
//
// getData(file2, list2);
// System.out.println("9月份数据量" + list2.size());
// List<String> collect = list2.stream().filter(o -> !list.contains(o)).collect(Collectors.toList());
// System.out.println("10月份没有更新的数据量" + collect.size());
// File txt = new File("D:\\report\\txt");
// collect.stream().forEach(o -> {
// try {
// FileUtils.write(txt, o + "\r\n", "GBK", true);
//
// } catch (Exception e) {
// e.printStackTrace();
// }
// });
// list.stream().close();
public
List
<
String
>
getDataFromFile
(
String
path
)
{
List
<
String
>
result
=
new
ArrayList
<>();
FileInputStream
fis
=
null
;
try
{
fis
=
new
FileInputStream
(
path
);
String
charset
=
getFilecharset
(
fis
);
// 防止路径乱码 如果utf-8 乱码 改GBK eclipse里创建的txt 用UTF-8,在电脑上自己创建的txt 用GBK
InputStreamReader
isr
=
null
;
fis
=
new
FileInputStream
(
path
);
isr
=
new
InputStreamReader
(
fis
,
charset
);
BufferedReader
br
=
new
BufferedReader
(
isr
);
String
line
=
""
;
while
((
line
=
br
.
readLine
())
!=
null
)
{
result
.
add
(
line
);
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
finally
{
if
(
fis
!=
null
)
{
try
{
fis
.
close
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
}
return
result
;
}
//判断编码格式方法
private
String
getFilecharset
(
FileInputStream
sourceFile
)
{
String
charset
=
"GBK"
;
byte
[]
first3Bytes
=
new
byte
[
3
];
try
{
boolean
checked
=
false
;
BufferedInputStream
bis
=
new
BufferedInputStream
(
sourceFile
);
bis
.
mark
(
0
);
int
read
=
bis
.
read
(
first3Bytes
,
0
,
3
);
if
(
read
==
-
1
)
{
return
charset
;
//文件编码为 ANSI
}
else
if
(
first3Bytes
[
0
]
==
(
byte
)
0xFF
&&
first3Bytes
[
1
]
==
(
byte
)
0xFE
)
{
charset
=
"UTF-16LE"
;
//文件编码为 Unicode
checked
=
true
;
}
else
if
(
first3Bytes
[
0
]
==
(
byte
)
0xFE
&&
first3Bytes
[
1
]
==
(
byte
)
0xFF
)
{
charset
=
"UTF-16BE"
;
//文件编码为 Unicode big endian
checked
=
true
;
}
else
if
(
first3Bytes
[
0
]
==
(
byte
)
0xEF
&&
first3Bytes
[
1
]
==
(
byte
)
0xBB
&&
first3Bytes
[
2
]
==
(
byte
)
0xBF
)
{
charset
=
"UTF-8"
;
//文件编码为 UTF-8
checked
=
true
;
}
bis
.
reset
();
if
(!
checked
)
{
int
loc
=
0
;
while
((
read
=
bis
.
read
())
!=
-
1
)
{
loc
++;
if
(
read
>=
0xF0
)
break
;
if
(
0x80
<=
read
&&
read
<=
0xBF
)
// 单独出现BF以下的,也算是GBK
break
;
if
(
0xC0
<=
read
&&
read
<=
0xDF
)
{
read
=
bis
.
read
();
if
(
0x80
<=
read
&&
read
<=
0xBF
)
// 双字节 (0xC0 - 0xDF)
// (0x80
// - 0xBF),也可能在GB编码内
continue
;
else
break
;
}
else
if
(
0xE0
<=
read
&&
read
<=
0xEF
)
{
// 也有可能出错,但是几率较小
read
=
bis
.
read
();
if
(
0x80
<=
read
&&
read
<=
0xBF
)
{
read
=
bis
.
read
();
if
(
0x80
<=
read
&&
read
<=
0xBF
)
{
charset
=
"UTF-8"
;
break
;
}
else
break
;
}
else
break
;
}
}
}
bis
.
close
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
charset
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment