Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
Y
yifu-mvp
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
fangxinjiang
yifu-mvp
Commits
c562be17
Commit
c562be17
authored
Aug 01, 2022
by
李灿灿
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
表内数据校验重复
parent
1f69b220
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
131 additions
and
37 deletions
+131
-37
LocalDateUtil.java
...ifu/cloud/plus/v1/yifu/insurances/util/LocalDateUtil.java
+31
-1
TInsuranceDetailServiceImpl.java
.../insurances/service/impl/TInsuranceDetailServiceImpl.java
+100
-36
No files found.
yifu-insurances/yifu-insurances-api/src/main/java/com/yifu/cloud/plus/v1/yifu/insurances/util/LocalDateUtil.java
View file @
c562be17
...
...
@@ -270,7 +270,37 @@ public class LocalDateUtil {
return
dif
;
}
/**
* 判断两个时间段是否有交集
*
* 思路:将有交集的情况列出,若不符合有交集的情况,则无交集
* 有交集的两种情况
* 1.第一个时间段的开始时间在第二个时间段的开始时间和结束时间当中
* 2.第二个时间段的开始时间在第一个时间段的开始时间和结束时间当中
*
* @author licancan
* @param leftStartDate 第一个时间段的开始时间
* @param leftEndDate 第一个时间段的结束时间
* @param rightStartDate 第二个时间段的开始时间
* @param rightEndDate 第二个时间段的结束时间
* @return {@link boolean} 若有交集, 返回true, 否则返回false
*/
public
static
boolean
hasOverlap
(
LocalDate
leftStartDate
,
LocalDate
leftEndDate
,
LocalDate
rightStartDate
,
LocalDate
rightEndDate
)
{
return
((
leftStartDate
.
equals
(
rightStartDate
)
||
leftStartDate
.
isAfter
(
rightStartDate
))
&&
leftStartDate
.
isBefore
(
rightEndDate
))
||
(
leftStartDate
.
isAfter
(
rightStartDate
)
&&
(
leftStartDate
.
equals
(
rightEndDate
)
||
leftStartDate
.
isBefore
(
rightEndDate
)))
||
((
rightStartDate
.
equals
(
leftStartDate
)
||
rightStartDate
.
isAfter
(
leftStartDate
))
&&
rightStartDate
.
isBefore
(
leftEndDate
))
||
(
rightStartDate
.
isAfter
(
leftStartDate
)
&&
(
rightStartDate
.
equals
(
leftEndDate
)
||
rightStartDate
.
isBefore
(
leftEndDate
)));
}
public
static
void
main
(
String
[]
args
)
{
System
.
out
.
println
(
betweenMonth
(
"2022-10-03"
,
"2022-08-03"
));
boolean
hasOverlap
=
hasOverlap
(
parseLocalDate
(
"2022-08-03"
),
parseLocalDate
(
"2022-08-04"
),
parseLocalDate
(
"2022-08-03"
),
parseLocalDate
(
"2022-08-04"
));
System
.
out
.
println
(
hasOverlap
);
}
}
yifu-insurances/yifu-insurances-biz/src/main/java/com/yifu/cloud/plus/v1/yifu/insurances/service/impl/TInsuranceDetailServiceImpl.java
View file @
c562be17
...
...
@@ -945,7 +945,11 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
Map
<
String
,
List
<
InsuranceAddParam
>>
map
=
new
HashMap
<>();
List
<
InsuranceAddParam
>
listResult
=
new
ArrayList
<>();
List
<
InsuranceAddParam
>
listSuccess
=
new
ArrayList
<>();
for
(
InsuranceAddParam
param
:
paramList
.
stream
().
distinct
().
collect
(
Collectors
.
toList
()))
{
List
<
InsuranceAddParam
>
distinctList
=
paramList
.
stream
().
distinct
().
collect
(
Collectors
.
toList
());
//定义外层循环标识,方便去重的时候跳出
outer:
for
(
int
i
=
0
;
i
<
distinctList
.
size
();
i
++)
{
InsuranceAddParam
param
=
distinctList
.
get
(
i
);
// 必填校验
if
(
StringUtils
.
isBlank
(
param
.
getEmpName
())){
param
.
setErrorMessage
(
InsurancesConstants
.
EMP_NAME_NOT_EMPTY
);
...
...
@@ -1043,6 +1047,44 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
listResult
.
add
(
param
);
continue
;
}
// 保单开始日期 > 当前派单日期
if
(!
LocalDateUtil
.
isDate
(
param
.
getPolicyStart
(),
LocalDateUtil
.
NORM_DATE_PATTERN
)){
param
.
setErrorMessage
(
InsurancesConstants
.
POLICY_START_PARSE_ERROR
);
listResult
.
add
(
param
);
continue
;
}
if
(!
LocalDateUtil
.
isDate
(
param
.
getPolicyEnd
(),
LocalDateUtil
.
NORM_DATE_PATTERN
)){
param
.
setErrorMessage
(
InsurancesConstants
.
POLICY_END_PARSE_ERROR
);
listResult
.
add
(
param
);
continue
;
}
if
(!
LocalDateUtil
.
isFutureDate
(
param
.
getPolicyStart
())){
param
.
setErrorMessage
(
InsurancesConstants
.
POLICY_START_SHOULD_IS_FUTURE
);
listResult
.
add
(
param
);
continue
;
}
if
(!
LocalDateUtil
.
compareDate
(
param
.
getPolicyStart
(),
param
.
getPolicyEnd
())){
param
.
setErrorMessage
(
InsurancesConstants
.
POLICY_START_SHOULD_LESS_THAN_POLICY_END
);
listResult
.
add
(
param
);
continue
;
}
//表内数据重复 员工姓名、员工身份证号码、保险公司、险种、起止时间(有交叉)
for
(
int
j
=
0
;
j
<
distinctList
.
size
();
j
++)
{
InsuranceAddParam
repeat
=
distinctList
.
get
(
j
);
if
(
param
.
getEmpName
().
equals
(
repeat
.
getEmpName
())
&&
param
.
getEmpIdcardNo
().
equals
(
repeat
.
getEmpIdcardNo
())
&&
param
.
getInsuranceCompanyName
().
equals
(
repeat
.
getInsuranceCompanyName
())
&&
param
.
getInsuranceTypeName
().
equals
(
repeat
.
getInsuranceTypeName
())
&&
LocalDateUtil
.
hasOverlap
(
LocalDateUtil
.
parseLocalDate
(
param
.
getPolicyStart
()),
LocalDateUtil
.
parseLocalDate
(
param
.
getPolicyEnd
()),
LocalDateUtil
.
parseLocalDate
(
repeat
.
getPolicyStart
()),
LocalDateUtil
.
parseLocalDate
(
repeat
.
getPolicyEnd
()))
&&
i
!=
j
){
param
.
setErrorMessage
(
InsurancesConstants
.
DUPLICATE_DATA_ERROR
);
listResult
.
add
(
param
);
continue
outer
;
}
}
//校验身份合法
/*TCheckIdCard checkIdCard = new TCheckIdCard();
checkIdCard.setName(param.getEmpName());
...
...
@@ -1119,28 +1161,6 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
param
.
setInsuranceHandleCity
(
Integer
.
parseInt
(
redisHandleCityName
));
}
// 保单开始日期 > 当前派单日期
if
(!
LocalDateUtil
.
isDate
(
param
.
getPolicyStart
(),
LocalDateUtil
.
NORM_DATE_PATTERN
)){
param
.
setErrorMessage
(
InsurancesConstants
.
POLICY_START_PARSE_ERROR
);
listResult
.
add
(
param
);
continue
;
}
if
(!
LocalDateUtil
.
isDate
(
param
.
getPolicyEnd
(),
LocalDateUtil
.
NORM_DATE_PATTERN
)){
param
.
setErrorMessage
(
InsurancesConstants
.
POLICY_END_PARSE_ERROR
);
listResult
.
add
(
param
);
continue
;
}
if
(!
LocalDateUtil
.
isFutureDate
(
param
.
getPolicyStart
())){
param
.
setErrorMessage
(
InsurancesConstants
.
POLICY_START_SHOULD_IS_FUTURE
);
listResult
.
add
(
param
);
continue
;
}
if
(!
LocalDateUtil
.
compareDate
(
param
.
getPolicyStart
(),
param
.
getPolicyEnd
())){
param
.
setErrorMessage
(
InsurancesConstants
.
POLICY_START_SHOULD_LESS_THAN_POLICY_END
);
listResult
.
add
(
param
);
continue
;
}
// 保险公司-险种-购买标准 是否存在
TInsuranceCompany
insuranceCompany
=
tInsuranceCompanyService
.
getOne
(
Wrappers
.<
TInsuranceCompany
>
query
().
lambda
()
.
eq
(
TInsuranceCompany:
:
getCompanyName
,
param
.
getInsuranceCompanyName
())
...
...
@@ -1297,7 +1317,11 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
Map
<
String
,
List
<
InsuranceBatchParam
>>
map
=
new
HashMap
<>();
List
<
InsuranceBatchParam
>
listResult
=
new
ArrayList
<>();
List
<
InsuranceBatchParam
>
listSuccess
=
new
ArrayList
<>();
for
(
InsuranceBatchParam
param
:
paramList
.
stream
().
distinct
().
collect
(
Collectors
.
toList
()))
{
List
<
InsuranceBatchParam
>
distinctList
=
paramList
.
stream
().
distinct
().
collect
(
Collectors
.
toList
());
//定义外层循环标识,方便去重的时候跳出
outer:
for
(
int
i
=
0
;
i
<
distinctList
.
size
();
i
++)
{
InsuranceBatchParam
param
=
distinctList
.
get
(
i
);
// 必填校验
if
(
StringUtils
.
isBlank
(
param
.
getDeptNo
())){
param
.
setErrorMessage
(
InsurancesConstants
.
DEPT_NO_NOT_EMPTY
);
...
...
@@ -1388,6 +1412,21 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
continue
;
}
//表内数据重复 员工姓名、员工身份证号码、保险公司、险种、保单号
for
(
int
j
=
0
;
j
<
distinctList
.
size
();
j
++)
{
InsuranceBatchParam
repeat
=
distinctList
.
get
(
j
);
if
(
param
.
getEmpName
().
equals
(
repeat
.
getEmpName
())
&&
param
.
getEmpIdcardNo
().
equals
(
repeat
.
getEmpIdcardNo
())
&&
param
.
getInsuranceCompanyName
().
equals
(
repeat
.
getInsuranceCompanyName
())
&&
param
.
getInsuranceTypeName
().
equals
(
repeat
.
getInsuranceTypeName
())
&&
param
.
getPolicyNo
().
equals
(
repeat
.
getPolicyNo
())
&&
i
!=
j
){
param
.
setErrorMessage
(
InsurancesConstants
.
DUPLICATE_DATA_ERROR
);
listResult
.
add
(
param
);
continue
outer
;
}
}
//校验身份合法
/*TCheckIdCard checkIdCard = new TCheckIdCard();
checkIdCard.setName(param.getEmpName());
...
...
@@ -1625,7 +1664,11 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
Map
<
String
,
List
<
InsuranceReplaceParam
>>
map
=
new
HashMap
<>();
List
<
InsuranceReplaceParam
>
listResult
=
new
ArrayList
<>();
List
<
InsuranceReplaceParam
>
listSuccess
=
new
ArrayList
<>();
for
(
InsuranceReplaceParam
param
:
paramList
.
stream
().
distinct
().
collect
(
Collectors
.
toList
()))
{
List
<
InsuranceReplaceParam
>
distinctList
=
paramList
.
stream
().
distinct
().
collect
(
Collectors
.
toList
());
//定义外层循环标识,方便去重的时候跳出
outer:
for
(
int
i
=
0
;
i
<
distinctList
.
size
();
i
++)
{
InsuranceReplaceParam
param
=
distinctList
.
get
(
i
);
// 必填校验
if
(
StringUtils
.
isBlank
(
param
.
getEmpName
())){
param
.
setErrorMessage
(
InsurancesConstants
.
EMP_NAME_NOT_EMPTY
);
...
...
@@ -1700,6 +1743,38 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
listResult
.
add
(
param
);
continue
;
}
if
(!
LocalDateUtil
.
isDate
(
param
.
getPolicyStart
(),
LocalDateUtil
.
NORM_DATE_PATTERN
)){
param
.
setErrorMessage
(
InsurancesConstants
.
POLICY_START_PARSE_ERROR
);
listResult
.
add
(
param
);
continue
;
}
if
(!
LocalDateUtil
.
isDate
(
param
.
getPolicyEnd
(),
LocalDateUtil
.
NORM_DATE_PATTERN
)){
param
.
setErrorMessage
(
InsurancesConstants
.
POLICY_END_PARSE_ERROR
);
listResult
.
add
(
param
);
continue
;
}
if
(!
LocalDateUtil
.
compareDate
(
param
.
getPolicyStart
(),
param
.
getPolicyEnd
())){
param
.
setErrorMessage
(
InsurancesConstants
.
POLICY_START_SHOULD_LESS_THAN_POLICY_END
);
listResult
.
add
(
param
);
continue
;
}
//表内数据重复 员工姓名、员工身份证号码、保险公司、险种、起止时间(有交叉)
for
(
int
j
=
0
;
j
<
distinctList
.
size
();
j
++)
{
InsuranceReplaceParam
repeat
=
distinctList
.
get
(
j
);
if
(((
param
.
getEmpName
().
equals
(
repeat
.
getEmpName
())
&&
param
.
getEmpIdcardNo
().
equals
(
repeat
.
getEmpIdcardNo
()))
||(
param
.
getReplaceEmpName
().
equals
(
repeat
.
getReplaceEmpName
())
&&
param
.
getReplaceEmpIdcardNo
().
equals
(
repeat
.
getReplaceEmpIdcardNo
())))
&&
param
.
getInsuranceCompanyName
().
equals
(
repeat
.
getInsuranceCompanyName
())
&&
param
.
getInsuranceTypeName
().
equals
(
repeat
.
getInsuranceTypeName
())
&&
LocalDateUtil
.
hasOverlap
(
LocalDateUtil
.
parseLocalDate
(
param
.
getPolicyStart
()),
LocalDateUtil
.
parseLocalDate
(
param
.
getPolicyEnd
()),
LocalDateUtil
.
parseLocalDate
(
repeat
.
getPolicyStart
()),
LocalDateUtil
.
parseLocalDate
(
repeat
.
getPolicyEnd
()))
&&
i
!=
j
){
param
.
setErrorMessage
(
InsurancesConstants
.
DUPLICATE_DATA_ERROR
);
listResult
.
add
(
param
);
continue
outer
;
}
}
//校验身份合法
/*TCheckIdCard checkIdCard = new TCheckIdCard();
checkIdCard.setName(param.getReplaceEmpName());
...
...
@@ -1738,17 +1813,6 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
}
}
if
(!
LocalDateUtil
.
isDate
(
param
.
getPolicyStart
(),
LocalDateUtil
.
NORM_DATE_PATTERN
)){
param
.
setErrorMessage
(
InsurancesConstants
.
POLICY_START_PARSE_ERROR
);
listResult
.
add
(
param
);
continue
;
}
if
(!
LocalDateUtil
.
isDate
(
param
.
getPolicyEnd
(),
LocalDateUtil
.
NORM_DATE_PATTERN
)){
param
.
setErrorMessage
(
InsurancesConstants
.
POLICY_END_PARSE_ERROR
);
listResult
.
add
(
param
);
continue
;
}
//原数据查重校验:姓名 + 身份证号 + 项目编码 + 保险公司 + 险种名称 + 保单开始时间 + 保单结束时间
TInsuranceDetail
detail
=
this
.
baseMapper
.
selectOne
(
Wrappers
.<
TInsuranceDetail
>
query
().
lambda
()
.
eq
(
TInsuranceDetail:
:
getEmpName
,
param
.
getEmpName
())
...
...
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