Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
8
8timerapiv200
Overview
Overview
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
8timerv2
8timerapiv200
Commits
6eab9947
Commit
6eab9947
authored
Apr 15, 2022
by
翁国栋
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
8小时运营后台--
保单导入
parent
410f9f4f
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
151 additions
and
9 deletions
+151
-9
src/main/java/cn/timer/api/controller/insure/InsureContorll.java
+151
-9
No files found.
src/main/java/cn/timer/api/controller/insure/InsureContorll.java
View file @
6eab9947
...
...
@@ -868,7 +868,7 @@ public class InsureContorll {
@PostMapping
(
value
=
"/importUser"
)
@ApiOperation
(
value
=
"导入用户--
8小时端
"
,
httpMethod
=
"post"
,
notes
=
"导入用户"
)
@ApiOperation
(
value
=
"导入用户--
运营后台
"
,
httpMethod
=
"post"
,
notes
=
"导入用户"
)
public
Result
<
Object
>
importUser
(
@RequestParam
(
"orgCode"
)
String
orgCode
,
@RequestParam
(
"file"
)
MultipartFile
file
)
{
SimpleDateFormat
dtf
=
new
SimpleDateFormat
(
"yyyyMMdd"
);
QyzxEntInfoM
company
=
QyzxEntInfoM
.
builder
().
id
(
Integer
.
valueOf
(
orgCode
)).
build
().
selectById
();
...
...
@@ -914,14 +914,14 @@ public class InsureContorll {
case
"证件号"
:
String
idNo
=
Optional
.
ofNullable
(
ExcelUtils
.
getString
(
cell
)).
orElse
(
""
);
if
(
Strings
.
isNullOrEmpty
(
idNo
)
&&
idNo
.
length
()
!=
18
)
{
return
ResultUtil
.
error
(
y
.
getName
()
+
"身份证格式不正确"
);
return
ResultUtil
.
error
(
y
.
getName
()
+
"身份证格式不正确"
);
}
if
(!
idNo
.
matches
(
"^(\\d{6})(\\d{4})(\\d{2})(\\d{2})(\\d{3})([0-9]|X)$"
))
{
return
ResultUtil
.
error
(
y
.
getName
()
+
"身份证格式不正确"
);
if
(!
idNo
.
matches
(
"^(\\d{6})(\\d{4})(\\d{2})(\\d{2})(\\d{3})([0-9]|X)$"
))
{
return
ResultUtil
.
error
(
y
.
getName
()
+
"身份证格式不正确"
);
}
try
{
y
.
setBirthday
(
dtf
.
parse
(
idNo
.
substring
(
6
,
14
)));
y
.
setBirthday
(
dtf
.
parse
(
idNo
.
substring
(
6
,
14
)));
}
catch
(
ParseException
e
)
{
e
.
printStackTrace
();
}
...
...
@@ -940,15 +940,15 @@ public class InsureContorll {
break
;
}
}
if
(
StringUtils
.
isNullOrEmpty
(
y
.
getName
())
||
StringUtils
.
isNullOrEmpty
(
y
.
getZjNum
()))
{
if
(
StringUtils
.
isNullOrEmpty
(
y
.
getName
())
||
StringUtils
.
isNullOrEmpty
(
y
.
getZjNum
()))
{
continue
;
}
yg
.
add
(
y
);
}
List
<
YgglMainEmp
>
userList
=
YgglMainEmp
.
builder
().
build
().
selectList
(
new
QueryWrapper
<
YgglMainEmp
>().
lambda
().
eq
(
YgglMainEmp:
:
getOrgCode
,
orgCode
));
List
<
String
>
idNumList
=
userList
.
stream
().
map
(
YgglMainEmp:
:
getZjNum
).
collect
(
Collectors
.
toList
());
List
<
YgglMainEmp
>
newList
=
yg
.
stream
().
filter
(
v
->
!
idNumList
.
contains
(
v
.
getZjNum
())).
collect
(
Collectors
.
toList
());
if
(
newList
.
size
()>
0
)
{
List
<
String
>
idNumList
=
userList
.
stream
().
map
(
YgglMainEmp:
:
getZjNum
).
collect
(
Collectors
.
toList
());
List
<
YgglMainEmp
>
newList
=
yg
.
stream
().
filter
(
v
->
!
idNumList
.
contains
(
v
.
getZjNum
())).
collect
(
Collectors
.
toList
());
if
(
newList
.
size
()
>
0
)
{
newList
.
forEach
(
u
->
u
.
insert
());
}
//假期规则初始化
...
...
@@ -961,4 +961,146 @@ public class InsureContorll {
return
ResultUtil
.
data
(
"成功添加"
);
}
@PostMapping
(
value
=
"/importPolicy"
)
@ApiOperation
(
value
=
"导入保单--运营后台"
,
httpMethod
=
"post"
,
notes
=
"导入用户"
)
public
Result
<
Object
>
importPolicy
(
@RequestParam
(
"file"
)
MultipartFile
file
)
{
SimpleDateFormat
dtf
=
new
SimpleDateFormat
(
"yyyyMMdd"
);
if
(
file
.
getSize
()
<=
0
)
{
return
ResultUtil
.
error
(
"请上传文件"
);
}
try
{
XSSFWorkbook
xw
=
new
XSSFWorkbook
(
file
.
getInputStream
());
XSSFSheet
sheetAt
=
xw
.
getSheetAt
(
0
);
//默认第一行为标题行,i = 0
XSSFRow
titleRow
=
sheetAt
.
getRow
(
0
);
InsurePolicy
policy
=
InsurePolicy
.
builder
().
build
();
QyzxEntInfoM
company
=
null
;
InsureUser
user
;
List
<
InsureUser
>
userList
=
Lists
.
newArrayList
();
// 循环获取每一行数据
for
(
int
i
=
1
;
i
<
sheetAt
.
getPhysicalNumberOfRows
();
i
++)
{
XSSFRow
row
=
sheetAt
.
getRow
(
i
);
user
=
InsureUser
.
builder
().
build
();
// 读取每一格内容
for
(
int
index
=
0
;
index
<
row
.
getPhysicalNumberOfCells
();
index
++)
{
XSSFCell
titleCell
=
titleRow
.
getCell
(
index
);
XSSFCell
cell
=
row
.
getCell
(
index
);
cell
.
setCellType
(
CellType
.
STRING
);
switch
(
ExcelUtils
.
getString
(
titleCell
))
{
case
"申报日期"
:
Date
createTime
=
null
;
try
{
createTime
=
dtf3
.
parse
(
ExcelUtils
.
getString
(
cell
));
}
catch
(
ParseException
e
)
{
e
.
printStackTrace
();
}
policy
.
setCreateTime
(
createTime
);
break
;
case
"保单号"
:
policy
.
setPolicyNo
(
Optional
.
ofNullable
(
ExcelUtils
.
getString
(
cell
)).
orElse
(
""
));
user
.
setPolicyNo
(
Optional
.
ofNullable
(
ExcelUtils
.
getString
(
cell
)).
orElse
(
""
));
break
;
case
"申报类型"
:
if
(
ExcelUtils
.
getString
(
cell
).
equals
(
"新增"
))
{
user
.
setApplyType
(
1
);
}
else
if
(
ExcelUtils
.
getString
(
cell
).
equals
(
"批改"
))
{
user
.
setApplyType
(
3
);
}
break
;
case
"方案名称"
:
break
;
case
"有效时间"
:
Date
start
=
null
;
try
{
start
=
dtf3
.
parse
(
ExcelUtils
.
getString
(
cell
));
}
catch
(
ParseException
e
)
{
e
.
printStackTrace
();
}
user
.
setPolicyDateStart
(
start
);
policy
.
setPolicyDateStart
(
start
);
break
;
case
"有效期止"
:
Date
end
=
null
;
try
{
end
=
dtf3
.
parse
(
ExcelUtils
.
getString
(
cell
));
}
catch
(
ParseException
e
)
{
e
.
printStackTrace
();
}
user
.
setPolicyDateStart
(
end
);
policy
.
setPolicyDateStart
(
end
);
break
;
case
"被保险人姓名"
:
user
.
setInsuredEContact
(
ExcelUtils
.
getString
(
cell
));
break
;
case
"证件类型"
:
if
(
ExcelUtils
.
getString
(
cell
).
equals
(
"身份证"
))
{
}
break
;
case
"证件号码"
:
user
.
setInsuredNo
(
ExcelUtils
.
getString
(
cell
));
break
;
case
"二、三轮车车架号"
:
user
.
setTricycleFrameNumber
(!
ExcelUtils
.
getString
(
cell
).
equals
(
"无"
)
?
ExcelUtils
.
getString
(
cell
)
:
null
);
break
;
case
"职业类别"
:
if
(
ExcelUtils
.
getString
(
cell
).
equals
(
"A类"
))
{
user
.
setBenefitOccupationCategory
(
"63119"
);
}
else
if
(
ExcelUtils
.
getString
(
cell
).
equals
(
"B类"
))
{
user
.
setBenefitOccupationCategory
(
"63120"
);
}
else
if
(
ExcelUtils
.
getString
(
cell
).
equals
(
"C类"
))
{
user
.
setBenefitOccupationCategory
(
"63121"
);
}
break
;
case
"企业全称"
:
company
=
QyzxEntInfoM
.
builder
().
build
().
selectOne
(
new
QueryWrapper
<
QyzxEntInfoM
>().
lambda
().
eq
(
QyzxEntInfoM:
:
getAttestName
,
ExcelUtils
.
getString
(
cell
)));
if
(
company
==
null
)
{
return
ResultUtil
.
error
(
"企业不存在"
);
}
user
.
setOrgCode
(
company
.
getId
());
break
;
case
"总保费"
:
user
.
setPrice
(
ExcelUtils
.
getString
(
cell
));
break
;
}
}
userList
.
add
(
user
);
}
InsurePolicy
oldPolicy
=
InsurePolicy
.
builder
().
build
().
selectOne
(
new
QueryWrapper
<
InsurePolicy
>().
lambda
().
eq
(
InsurePolicy:
:
getPolicyNo
,
policy
.
getPolicyNo
()));
if
(
oldPolicy
==
null
)
{
policy
.
insert
();
}
else
{
policy
=
oldPolicy
;
}
if
(
userList
.
size
()
<=
0
)
{
return
ResultUtil
.
error
(
"导入错误,保单已存在"
);
}
for
(
InsureUser
insureUser
:
userList
)
{
/*根据名字,身份,所属企业获取员工*/
YgglMainEmp
ygglMainEmp
=
YgglMainEmp
.
builder
().
build
().
selectOne
(
new
QueryWrapper
<
YgglMainEmp
>().
lambda
()
.
eq
(
YgglMainEmp:
:
getName
,
insureUser
.
getInsuredEContact
())
.
eq
(
YgglMainEmp:
:
getZjNum
,
insureUser
.
getInsuredNo
())
.
eq
(
YgglMainEmp:
:
getOrgCode
,
insureUser
.
getOrgCode
()));
if
(
ygglMainEmp
!=
null
)
{
ygglMainEmp
.
setIsInsure
(
1
);
}
else
{
/*如果不存在员工就创建一名员工*/
ygglMainEmp
.
builder
().
build
();
ygglMainEmp
.
setName
(
insureUser
.
getInsuredEContact
());
ygglMainEmp
.
setZjType
(
0
);
ygglMainEmp
.
setZjNum
(
insureUser
.
getInsuredNo
());
ygglMainEmp
.
setOrgCode
(
insureUser
.
getOrgCode
());
}
insureUser
.
setPolicyId
(
policy
.
getId
());
ygglMainEmp
.
insertOrUpdate
();
insureUser
.
insert
();
}
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
return
ResultUtil
.
data
(
"成功导入"
);
}
}
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