Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
Y
YX_IDENT_beijing_auxiliary_YD
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
zhangyusheng
YX_IDENT_beijing_auxiliary_YD
Commits
2a43b235
Commit
2a43b235
authored
Mar 24, 2025
by
xiachenqi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
改进出入境购车比对,支持多个excel文件上传
parent
82b7e642
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
32 additions
and
84 deletions
+32
-84
pom.xml
pom.xml
+1
-0
ExtensionApi.java
src/main/java/com/yxproject/start/api/ExtensionApi.java
+20
-4
ReadExcelApi.java
src/main/java/com/yxproject/start/api/ReadExcelApi.java
+2
-1
ExtensionServiceImpl.java
...om/yxproject/start/service/impl/ExtensionServiceImpl.java
+9
-5
YXStringUtils.java
src/main/java/com/yxproject/start/utils/YXStringUtils.java
+0
-23
tmp.txt
src/main/resources/tmp.txt
+0
-51
No files found.
pom.xml
View file @
2a43b235
...
...
@@ -93,6 +93,7 @@
<dependency>
<groupId>
org.projectlombok
</groupId>
<artifactId>
lombok
</artifactId>
<version>
1.18.32
</version>
</dependency>
<dependency>
<groupId>
com.oracle
</groupId>
...
...
src/main/java/com/yxproject/start/api/ExtensionApi.java
View file @
2a43b235
...
...
@@ -40,12 +40,28 @@ public class ExtensionApi {
if
(
fileName
!=
null
&&
!
fileName
.
endsWith
(
"xls"
)
&&
!
fileName
.
endsWith
(
"xlsx"
))
{
throw
new
RuntimeException
(
"Only .xls or .xlsx files are supported"
);
}
Thread
thread
=
new
Thread
(()
->
{
extensionService
.
analysisGAT
(
file
);
});
Thread
thread
=
new
Thread
(()
->
extensionService
.
analysisGAT
(
file
));
// 处理文件并生成新的Excel
thread
.
start
();
// extensionService.analysisGAT(file);
return
"ok"
;
}
@PostMapping
(
value
=
"analysisMultiGAT"
,
consumes
=
MediaType
.
MULTIPART_FORM_DATA
)
public
String
analysisGAT
(
@RequestPart
(
"files"
)
MultipartFile
[]
files
)
{
for
(
MultipartFile
file
:
files
)
{
// 检查文件是否为空
if
(
file
.
isEmpty
())
{
throw
new
RuntimeException
(
"One or more files are empty"
);
}
// 获取文件名
String
fileName
=
file
.
getOriginalFilename
();
if
(
fileName
!=
null
&&
!
fileName
.
endsWith
(
"xls"
)
&&
!
fileName
.
endsWith
(
"xlsx"
))
{
throw
new
RuntimeException
(
"Only .xls or .xlsx files are supported"
);
}
Thread
thread
=
new
Thread
(()
->
extensionService
.
analysisGAT
(
file
));
// 处理文件并生成新的Excel
thread
.
start
();
}
return
"ok"
;
}
}
src/main/java/com/yxproject/start/api/ReadExcelApi.java
View file @
2a43b235
...
...
@@ -208,7 +208,8 @@ public class ReadExcelApi {
personPostEntity
.
setLatticeMouthInformation
((
String
)
list2
.
get
(
21
));
personPostEntity
.
setNatureOfTheInternal
((
String
)
list2
.
get
(
22
));
personPostEntity
.
setNatureOfTheInformation
((
String
)
list2
.
get
(
23
));
personPostEntity
.
setFirstWhite
(
list2
.
get
(
24
).
toString
().
substring
(
5
,
27
));
// personPostEntity.setFirstWhite(list2.get(24).toString().substring(5, 27));
personPostEntity
.
setFirstWhite
(
list2
.
get
(
24
).
toString
());
personPostEntity
.
setFileId
(
fileNameDicEntity
.
getFileId
());
personPostEntity
.
setGk
(
gkMap
);
}
...
...
src/main/java/com/yxproject/start/service/impl/ExtensionServiceImpl.java
View file @
2a43b235
...
...
@@ -36,10 +36,8 @@ public class ExtensionServiceImpl {
try
(
InputStream
inputStream
=
file
.
getInputStream
();
Workbook
workbook
=
WorkbookFactory
.
create
(
inputStream
))
{
Sheet
hkSheet
=
workbook
.
getSheetAt
(
0
);
// Sheet twSheet = workbook.getSheetAt(1);
// 分析和更新Sheet
analysisSheet
(
hkSheet
);
// analysisSheet(twSheet);
String
fileName
=
file
.
getOriginalFilename
();
File
excelFile
=
new
File
(
"./"
+
"(已比对)"
+
fileName
);
try
(
OutputStream
outputStream
=
Files
.
newOutputStream
(
excelFile
.
toPath
()))
{
...
...
@@ -57,7 +55,7 @@ public class ExtensionServiceImpl {
*
* @param sheet 工作表
*/
p
ublic
void
analysisSheet
(
Sheet
sheet
)
{
p
rivate
void
analysisSheet
(
Sheet
sheet
)
{
for
(
Row
row
:
sheet
)
{
ExtensionGatAnalysisResultDto
resultDto
=
new
ExtensionGatAnalysisResultDto
(
"没有记录"
,
""
);
if
(
row
.
getRowNum
()
==
0
)
continue
;
...
...
@@ -71,13 +69,19 @@ public class ExtensionServiceImpl {
if
(
cell
!=
null
&&
cell
.
getCellType
()
==
CellType
.
STRING
)
{
birthday
=
cell
.
getStringCellValue
();
}
String
cardType
=
""
;
cell
=
row
.
getCell
(
7
);
if
(
cell
!=
null
&&
cell
.
getCellType
()
==
CellType
.
STRING
)
{
cardType
=
cell
.
getStringCellValue
();
}
String
card_no
=
row
.
getCell
(
9
).
getStringCellValue
();
card_no
=
cardType
.
equals
(
"TWN"
)
?
card_no
.
substring
(
0
,
8
)
:
card_no
;
List
<
ExtensionGatDto
>
prodRecords
=
extensionMapper
.
getProdGatCardList
(
card_no
);
List
<
ExtensionGatDto
>
hisRecords
=
extensionMapper
.
getHisGatCardList
(
card_no
);
List
<
ExtensionGatDto
>
combinedRecords
=
new
ArrayList
<>();
combinedRecords
.
addAll
(
prodRecords
);
combinedRecords
.
addAll
(
hisRecords
);
System
.
out
.
println
(
"rowNum: "
+
row
.
getRowNum
()
+
"|| name: "
+
name
+
" || birthday: "
+
birthday
+
" || card_no: "
+
card_no
+
" || recordCount: "
+
combinedRecords
.
size
());
System
.
out
.
println
(
"
cardType: "
+
cardType
+
"||
rowNum: "
+
row
.
getRowNum
()
+
"|| name: "
+
name
+
" || birthday: "
+
birthday
+
" || card_no: "
+
card_no
+
" || recordCount: "
+
combinedRecords
.
size
());
if
(!
combinedRecords
.
isEmpty
())
{
resultDto
.
setResult
(
"比对成功"
);
for
(
ExtensionGatDto
record
:
combinedRecords
)
{
...
...
@@ -92,7 +96,7 @@ public class ExtensionServiceImpl {
if
(!
record
.
getBirthday
().
equals
(
birthday
))
{
String
message
=
resultDto
.
getMessage
();
resultDto
.
setResult
(
"数据异常"
);
resultDto
.
setMessage
(
message
+
"与第"
+
record
.
getSignTimes
()
+
"出生日期不一致 "
);
resultDto
.
setMessage
(
message
+
"与第"
+
record
.
getSignTimes
()
+
"
次办证
出生日期不一致 "
);
}
}
}
...
...
src/main/java/com/yxproject/start/utils/YXStringUtils.java
View file @
2a43b235
...
...
@@ -3,8 +3,6 @@ package com.yxproject.start.utils;
import
org.dom4j.Document
;
import
org.dom4j.io.OutputFormat
;
import
org.dom4j.io.XMLWriter
;
import
sun.misc.BASE64Decoder
;
import
sun.misc.BASE64Encoder
;
import
java.io.*
;
...
...
@@ -120,27 +118,6 @@ public class YXStringUtils {
}
public
static
byte
[]
decodeImageAsBytes
(
String
imgStr
)
throws
IOException
{
BASE64Decoder
decoder
=
new
BASE64Decoder
();
// 解密
byte
[]
b
=
decoder
.
decodeBuffer
(
imgStr
);
// 处理数据
for
(
int
i
=
0
;
i
<
b
.
length
;
++
i
)
{
if
(
b
[
i
]
<
0
)
{
b
[
i
]
+=
256
;
}
}
return
b
;
}
public
static
String
Base64Encoding
(
byte
[]
data
)
{
BASE64Encoder
encoder
=
new
BASE64Encoder
();
return
encoder
.
encode
(
data
);
}
public
static
byte
[]
inputStream2byte
(
String
filename
)
throws
IOException
,
FileNotFoundException
{
FileInputStream
fis
=
new
FileInputStream
(
new
File
(
filename
));
...
...
src/main/resources/tmp.txt
deleted
100644 → 0
View file @
82b7e642
columns 0: 订单号
columns 1: 产品分类
columns 2: 产品名称
columns 3: 服务网点
columns 4: 订单状态
columns 5: 配送方式
columns 6: 订单渠道
columns 7: 支付方式
columns 8: 邮费金额
columns 9: 服务费
columns 10: 保价费
columns 11: 邮费退款额
columns 12: 服务费退款额
columns 13: 保价费退款额
columns 14: 下单支付时间
columns 15: 尾款支付时间
columns 16: 运单类型
columns 17: 邮件号
columns 18: 寄件人
columns 19: 寄件人手机
columns 20: 寄件省
columns 21: 寄件市
columns 22: 寄件区
columns 23: 寄件人街道地址
columns 24: 收件人
columns 25: 收件人手机
columns 26: 收件省
columns 27: 收件市
columns 28: 收件区
columns 29: 收件人街道地址
columns 30: 创建时间
columns 31: 邮件号录入时间
columns 32: 物品名称
columns 33: 物品重量(g)
columns 34: 物品数量
columns 35: 派揽单号
columns 36: 派揽状态
columns 37: 派揽失败原因
columns 38: 派揽发起时间
columns 39: 完成时间
columns 40: 提货人
columns 41: 提货人电话
columns 42: 提货时间
columns 43: 邮件打印次数
columns 44: 邮件最近打印时间
columns 45: 受理机构
columns 46: 受理号
columns 47: 办证人姓名
columns 48: 出生日期
columns 49: 手机号
\ No newline at end of file
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