Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
gsc
/
gsc-vcp-web-facade
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 16727cac
authored
Dec 01, 2025
by
林冲
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
bugfix:解决定金尾款导入无法处理中文
1 parent
672f0018
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
86 additions
and
32 deletions
src/main/java/com/gsc4cloud/gsc/facade/vpcweb/service/evalorder/EvalElectronicContractService.java
src/main/java/com/gsc4cloud/gsc/facade/vpcweb/utils/NumberUtil.java
src/main/java/com/gsc4cloud/gsc/facade/vpcweb/utils/excel/property/ContractImportRow.java
src/main/java/com/gsc4cloud/gsc/facade/vpcweb/service/evalorder/EvalElectronicContractService.java
View file @
16727ca
...
@@ -34,6 +34,7 @@ import org.springframework.stereotype.Service;
...
@@ -34,6 +34,7 @@ import org.springframework.stereotype.Service;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.InputStream
;
import
java.math.BigDecimal
;
import
java.net.HttpURLConnection
;
import
java.net.HttpURLConnection
;
import
java.net.URL
;
import
java.net.URL
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
...
@@ -145,6 +146,7 @@ public class EvalElectronicContractService {
...
@@ -145,6 +146,7 @@ public class EvalElectronicContractService {
// 阶段2: 数据校验和转换
// 阶段2: 数据校验和转换
for
(
int
i
=
0
;
i
<
excelRows
.
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
excelRows
.
size
();
i
++)
{
ContractImportRow
row
=
excelRows
.
get
(
i
);
ContractImportRow
row
=
excelRows
.
get
(
i
);
try
{
List
<
String
>
errors
=
new
ArrayList
<>();
List
<
String
>
errors
=
new
ArrayList
<>();
validateRow
(
row
,
errors
);
validateRow
(
row
,
errors
);
EvalElectronicContractImportDTO
dto
=
convertToImportDTO
(
row
,
accountInfo
);
EvalElectronicContractImportDTO
dto
=
convertToImportDTO
(
row
,
accountInfo
);
...
@@ -158,6 +160,11 @@ public class EvalElectronicContractService {
...
@@ -158,6 +160,11 @@ public class EvalElectronicContractService {
continue
;
continue
;
}
}
toImportList
.
add
(
dto
);
toImportList
.
add
(
dto
);
}
catch
(
BusinessException
e
)
{
log
.
error
(
"导入合同校验数据异常"
,
e
);
failList
.
add
(
buildFailDTO
(
row
,
e
.
getMessage
()));
}
}
}
// 阶段3: 并行导入操作
// 阶段3: 并行导入操作
List
<
CompletableFuture
<
Void
>>
importFutures
=
toImportList
.
stream
()
List
<
CompletableFuture
<
Void
>>
importFutures
=
toImportList
.
stream
()
...
@@ -312,8 +319,13 @@ public class EvalElectronicContractService {
...
@@ -312,8 +319,13 @@ public class EvalElectronicContractService {
dto
.
setBrand
(
StringUtils
.
trimToNull
(
row
.
getBrand
()));
dto
.
setBrand
(
StringUtils
.
trimToNull
(
row
.
getBrand
()));
dto
.
setCarCategory
(
StringUtils
.
trimToNull
(
row
.
getCarCategory
()));
dto
.
setCarCategory
(
StringUtils
.
trimToNull
(
row
.
getCarCategory
()));
dto
.
setPayType
(
StringUtils
.
trimToNull
(
row
.
getPayType
()));
dto
.
setPayType
(
StringUtils
.
trimToNull
(
row
.
getPayType
()));
dto
.
setDepositAmount
(
row
.
getDepositAmount
());
try
{
dto
.
setFinalAmount
(
row
.
getFinalAmount
());
dto
.
setDepositAmount
(
new
BigDecimal
(
row
.
getDepositAmount
()));
dto
.
setFinalAmount
(
new
BigDecimal
(
row
.
getFinalAmount
()));
}
catch
(
Exception
e
)
{
log
.
error
(
"数值转换异常"
,
e
);
}
dto
.
setPayeeName
(
StringUtils
.
trimToNull
(
row
.
getPayeeName
()));
dto
.
setPayeeName
(
StringUtils
.
trimToNull
(
row
.
getPayeeName
()));
dto
.
setBankName
(
StringUtils
.
trimToNull
(
row
.
getBankName
()));
dto
.
setBankName
(
StringUtils
.
trimToNull
(
row
.
getBankName
()));
dto
.
setBankAccountNo
(
StringUtils
.
trimToNull
(
row
.
getBankAccountNo
()));
dto
.
setBankAccountNo
(
StringUtils
.
trimToNull
(
row
.
getBankAccountNo
()));
...
@@ -327,7 +339,7 @@ public class EvalElectronicContractService {
...
@@ -327,7 +339,7 @@ public class EvalElectronicContractService {
return
dto
;
return
dto
;
}
}
private
EvalElectronicContractImportFailDTO
buildFailDTO
(
EvalElectronicContractImportDTO
source
,
String
reason
)
{
private
EvalElectronicContractImportFailDTO
buildFailDTO
(
ContractImportRow
source
,
String
reason
)
{
EvalElectronicContractImportFailDTO
dto
=
new
EvalElectronicContractImportFailDTO
();
EvalElectronicContractImportFailDTO
dto
=
new
EvalElectronicContractImportFailDTO
();
dto
.
setMerchantNo
(
source
.
getMerchantNo
());
dto
.
setMerchantNo
(
source
.
getMerchantNo
());
dto
.
setPlateNo
(
source
.
getPlateNo
());
dto
.
setPlateNo
(
source
.
getPlateNo
());
...
@@ -340,10 +352,26 @@ public class EvalElectronicContractService {
...
@@ -340,10 +352,26 @@ public class EvalElectronicContractService {
dto
.
setPayeeName
(
source
.
getPayeeName
());
dto
.
setPayeeName
(
source
.
getPayeeName
());
dto
.
setBankName
(
source
.
getBankName
());
dto
.
setBankName
(
source
.
getBankName
());
dto
.
setBankAccountNo
(
source
.
getBankAccountNo
());
dto
.
setBankAccountNo
(
source
.
getBankAccountNo
());
dto
.
setOperator
(
source
.
getOperator
());
dto
.
setReason
(
StringUtils
.
defaultIfBlank
(
reason
,
"unknown failure reason"
));
dto
.
setOperatorAccount
(
source
.
getOperatorAccount
());
return
dto
;
dto
.
setOperatorUuid
(
source
.
getOperatorUuid
());
}
dto
.
setOperatorPhone
(
source
.
getOperatorPhone
());
private
EvalElectronicContractImportFailDTO
buildFailDTO
(
EvalElectronicContractImportDTO
source
,
String
reason
)
{
EvalElectronicContractImportFailDTO
dto
=
new
EvalElectronicContractImportFailDTO
();
dto
.
setMerchantNo
(
source
.
getMerchantNo
());
dto
.
setPlateNo
(
source
.
getPlateNo
());
dto
.
setVin
(
source
.
getVin
());
dto
.
setBrand
(
source
.
getBrand
());
dto
.
setCarCategory
(
source
.
getCarCategory
());
dto
.
setPayType
(
source
.
getPayType
());
if
(
source
.
getDepositAmount
()
!=
null
)
{
dto
.
setDepositAmount
(
source
.
getDepositAmount
().
toString
());
}
if
(
source
.
getFinalAmount
()
!=
null
)
{
dto
.
setFinalAmount
(
source
.
getFinalAmount
().
toString
());
}
dto
.
setPayeeName
(
source
.
getPayeeName
());
dto
.
setBankName
(
source
.
getBankName
());
dto
.
setBankAccountNo
(
source
.
getBankAccountNo
());
dto
.
setReason
(
StringUtils
.
defaultIfBlank
(
reason
,
"unknown failure reason"
));
dto
.
setReason
(
StringUtils
.
defaultIfBlank
(
reason
,
"unknown failure reason"
));
return
dto
;
return
dto
;
}
}
...
@@ -355,36 +383,47 @@ public class EvalElectronicContractService {
...
@@ -355,36 +383,47 @@ public class EvalElectronicContractService {
}
}
if
(
StringUtils
.
isBlank
(
row
.
getMerchantNo
()))
{
if
(
StringUtils
.
isBlank
(
row
.
getMerchantNo
()))
{
errors
.
add
(
"商户号必填"
);
errors
.
add
(
"商户号必填"
);
return
;
}
}
if
(
StringUtils
.
isBlank
(
row
.
getPlateNo
()))
{
if
(
StringUtils
.
isBlank
(
row
.
getPlateNo
()))
{
errors
.
add
(
"车牌号必填"
);
errors
.
add
(
"车牌号必填"
);
return
;
}
}
if
(
StringUtils
.
isBlank
(
row
.
getVin
()))
{
if
(
StringUtils
.
isBlank
(
row
.
getVin
()))
{
errors
.
add
(
"车架号必填"
);
errors
.
add
(
"车架号必填"
);
return
;
}
}
if
(
StringUtils
.
isBlank
(
row
.
getBrand
()))
{
if
(
StringUtils
.
isBlank
(
row
.
getBrand
()))
{
errors
.
add
(
"品牌必填"
);
errors
.
add
(
"品牌必填"
);
return
;
}
}
if
(
StringUtils
.
isBlank
(
row
.
getCarCategory
()))
{
if
(
StringUtils
.
isBlank
(
row
.
getCarCategory
()))
{
errors
.
add
(
"车辆类别必填"
);
errors
.
add
(
"车辆类别必填"
);
return
;
}
}
if
(
StringUtils
.
isBlank
(
row
.
getPayType
()))
{
if
(
StringUtils
.
isBlank
(
row
.
getPayType
()))
{
errors
.
add
(
"支付方式必填"
);
errors
.
add
(
"支付方式必填"
);
return
;
}
}
if
(
row
.
getDepositAmount
()
==
null
)
{
if
(
row
.
getDepositAmount
()
==
null
)
{
errors
.
add
(
"定金金额必填"
);
errors
.
add
(
"定金金额必填"
);
return
;
}
}
if
(
row
.
getFinalAmount
()
==
null
)
{
if
(
row
.
getFinalAmount
()
==
null
)
{
errors
.
add
(
"尾款金额必填"
);
errors
.
add
(
"尾款金额必填"
);
return
;
}
}
if
(
StringUtils
.
isBlank
(
row
.
getPayeeName
()))
{
if
(
StringUtils
.
isBlank
(
row
.
getPayeeName
()))
{
errors
.
add
(
"收款人必填"
);
errors
.
add
(
"收款人必填"
);
return
;
}
}
if
(
StringUtils
.
isBlank
(
row
.
getBankName
()))
{
if
(
StringUtils
.
isBlank
(
row
.
getBankName
()))
{
errors
.
add
(
"开户行必填"
);
errors
.
add
(
"开户行必填"
);
return
;
}
}
if
(
StringUtils
.
isBlank
(
row
.
getBankAccountNo
()))
{
if
(
StringUtils
.
isBlank
(
row
.
getBankAccountNo
()))
{
errors
.
add
(
"收款银行账号必填"
);
errors
.
add
(
"收款银行账号必填"
);
return
;
}
}
// 校验4s店编号必须都是数字
// 校验4s店编号必须都是数字
...
@@ -418,30 +457,9 @@ public class EvalElectronicContractService {
...
@@ -418,30 +457,9 @@ public class EvalElectronicContractService {
}
}
// 定金金额校验:最多10位数,不包含小数
// 定金金额校验:最多10位数,不包含小数
if
(
row
.
getDepositAmount
()
!=
null
)
{
NumberUtil
.
validatePositiveIntegerRegex
(
row
.
getDepositAmount
());
String
depositAmountStr
=
row
.
getDepositAmount
().
toString
();
if
(
depositAmountStr
.
contains
(
"."
))
{
errors
.
add
(
"定金金额不能包含小数"
);
}
// 去除可能的负号再检查位数
String
absDepositAmount
=
depositAmountStr
.
replace
(
"-"
,
""
).
replace
(
"."
,
""
);
if
(
absDepositAmount
.
length
()
>
10
)
{
errors
.
add
(
"定金金额最多10位数"
);
}
}
// 尾款金额校验:最多10位数,不包含小数
// 尾款金额校验:最多10位数,不包含小数
if
(
row
.
getFinalAmount
()
!=
null
)
{
NumberUtil
.
validatePositiveIntegerRegex
(
row
.
getFinalAmount
());
String
finalAmountStr
=
row
.
getFinalAmount
().
toString
();
if
(
finalAmountStr
.
contains
(
"."
))
{
errors
.
add
(
"尾款金额不能包含小数"
);
}
// 去除可能的负号再检查位数
String
absFinalAmount
=
finalAmountStr
.
replace
(
"-"
,
""
).
replace
(
"."
,
""
);
if
(
absFinalAmount
.
length
()
>
10
)
{
errors
.
add
(
"尾款金额最多10位数"
);
}
}
// 收款人校验:1-20字符
// 收款人校验:1-20字符
if
(
StringUtils
.
isNotBlank
(
row
.
getPayeeName
()))
{
if
(
StringUtils
.
isNotBlank
(
row
.
getPayeeName
()))
{
...
...
src/main/java/com/gsc4cloud/gsc/facade/vpcweb/utils/NumberUtil.java
View file @
16727ca
package
com
.
gsc4cloud
.
gsc
.
facade
.
vpcweb
.
utils
;
package
com
.
gsc4cloud
.
gsc
.
facade
.
vpcweb
.
utils
;
import
com.gsc4cloud.gsc.vpc.api.exception.BusinessException
;
public
class
NumberUtil
{
public
class
NumberUtil
{
public
static
boolean
isAllDigits
(
String
str
)
{
public
static
boolean
isAllDigits
(
String
str
)
{
return
str
!=
null
&&
str
.
matches
(
"^[0-9]+$"
);
return
str
!=
null
&&
str
.
matches
(
"^[0-9]+$"
);
}
}
/**
* 非公共方法
*/
public
static
void
validatePositiveIntegerRegex
(
String
str
)
{
if
(
str
==
null
)
{
throw
new
BusinessException
(
"输入不能为null"
);
}
if
(
str
.
isEmpty
())
{
throw
new
BusinessException
(
"输入不能为空字符串"
);
}
// 检查是否全为数字
if
(!
str
.
matches
(
"\\d+"
))
{
throw
new
BusinessException
(
"输入包含非数字字符"
);
}
// 检查前导零和长度
if
(
str
.
matches
(
"0[0-9]+"
))
{
throw
new
BusinessException
(
"数字不能有前导零(除了0本身)"
);
}
if
(
str
.
length
()
>
10
)
{
throw
new
BusinessException
(
"数字长度不能超过10位"
);
}
// 检查数值范围
if
(
str
.
length
()
==
10
)
{
if
(
str
.
compareTo
(
"9999999999"
)
>
0
)
{
throw
new
BusinessException
(
"数字不能超过10位"
);
}
}
}
}
}
src/main/java/com/gsc4cloud/gsc/facade/vpcweb/utils/excel/property/ContractImportRow.java
View file @
16727ca
...
@@ -30,10 +30,10 @@ public class ContractImportRow {
...
@@ -30,10 +30,10 @@ public class ContractImportRow {
private
String
payType
;
private
String
payType
;
@ExcelProperty
(
index
=
6
)
// *定金金额
@ExcelProperty
(
index
=
6
)
// *定金金额
private
BigDecimal
depositAmount
;
private
String
depositAmount
;
@ExcelProperty
(
index
=
7
)
// *尾款金额
@ExcelProperty
(
index
=
7
)
// *尾款金额
private
BigDecimal
finalAmount
;
private
String
finalAmount
;
@ExcelProperty
(
index
=
8
)
// *收款人
@ExcelProperty
(
index
=
8
)
// *收款人
private
String
payeeName
;
private
String
payeeName
;
...
...
Write
Preview
Markdown
is supported
Attach a file
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 post a comment