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
35cbe3c8
Commit
35cbe3c8
authored
Jul 01, 2022
by
翁国栋
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
8小时后台--
导入替换人员异常
parent
db3ad21f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
92 additions
and
30 deletions
+92
-30
src/main/java/cn/timer/api/controller/insure/InsureContorll.java
+92
-30
No files found.
src/main/java/cn/timer/api/controller/insure/InsureContorll.java
View file @
35cbe3c8
...
...
@@ -370,7 +370,7 @@ public class InsureContorll {
insureUser
.
setApplicantEmployeeList
(
url
);
insureUser
.
setTricycleFrameNumber
(
p
.
getTricycleFrameNumber
());
insureUser
.
setPolicyDateStart
(
dtf3
.
parse
(
insureDto
.
getPolicyDateStart
()));
insureUser
.
setPolicyDateEnd
(
dtf3
.
parse
(
insureDto
.
getPolicyDateEnd
()
));
insureUser
.
setPolicyDateEnd
(
dtf3
.
parse
(
DateUtil
.
getStringFormat
(
DateUtil
.
getLastDayOfMonth
(
insureDto
.
getPolicyDateStart
()))+
" 23:59:59"
));
insureUser
.
setApplyType
(
2
);
//投保类型
insureUser
.
setPolicyId
(
insurePolicy
.
getId
());
insureUser
.
setCreateTime
(
new
Date
());
...
...
@@ -628,7 +628,6 @@ public class InsureContorll {
.
orgCode
(
y
.
getOrgCode
())
.
benefitOccupationCategory
(
insureDto
.
getBenefitOccupationCategory
())
.
insuredMobile
(
y
.
getPhone
())
.
benefitOccupationCategory
(
insureDto
.
getBenefitOccupationCategory
())
.
insuredNo
(
y
.
getZjNum
())
.
tricycleFrameNumber
(
insureDto
.
getTricycleFrameNumber
())
.
insuredEContact
(
y
.
getName
())
...
...
@@ -1704,21 +1703,21 @@ public class InsureContorll {
@PostMapping
(
value
=
"/replaceUserPolicy"
)
@ApiOperation
(
value
=
"18.导入替换人员"
,
httpMethod
=
"POST"
,
notes
=
"导入用户"
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
Result
<
Object
>
replaceUserPolicy
(
@RequestParam
(
"file"
)
MultipartFile
file
,
@RequestParam
(
"policyId"
)
Integer
policyId
){
public
Result
<
Object
>
replaceUserPolicy
(
@RequestParam
(
"file"
)
MultipartFile
file
,
@RequestParam
(
"policyId"
)
Integer
policyId
,
@RequestParam
(
"planId"
)
String
planId
,
@RequestParam
(
"categoryId"
)
String
categoryId
){
InsurePolicy
insurePolicy
=
InsurePolicy
.
builder
().
id
(
policyId
).
build
().
selectById
();
ByteArrayOutputStream
bos
=
null
;
ByteArrayOutputStream
bos
=
new
ByteArrayOutputStream
()
;
XSSFWorkbook
xw
=
null
;
try
{
xw
=
new
XSSFWorkbook
(
file
.
getInputStream
());
XSSFSheet
sheetAt
=
xw
.
getSheetAt
(
0
);
//默认第一行为标题行,i =
0
XSSFRow
titleRow
=
sheetAt
.
getRow
(
0
);
//默认第一行为标题行,i =
13
XSSFRow
titleRow
=
sheetAt
.
getRow
(
13
);
InsureUser
originalUser
;
InsureUser
replaceUser
;
/*原被保人集合*/
List
<
InsureUser
>
originalList
=
Lists
.
newArrayList
();
// 循环获取每一行数据
for
(
int
i
=
1
;
i
<
sheetAt
.
getPhysicalNumberOfRows
();
i
++)
{
for
(
int
i
=
1
4
;
i
<
sheetAt
.
getPhysicalNumberOfRows
();
i
++)
{
XSSFRow
row
=
sheetAt
.
getRow
(
i
);
originalUser
=
InsureUser
.
builder
().
build
();
replaceUser
=
InsureUser
.
builder
().
build
();
...
...
@@ -1758,6 +1757,7 @@ public class InsureContorll {
if
(
StringUtils
.
isNullOrEmpty
(
ExcelUtils
.
getString
(
cell
)))
{
return
ResultUtil
.
error
(
"第"
+
i
+
"行第"
+
index
+
"列批改生效日不能为空"
);
}
replaceUser
.
setPolicyDateStart
(
dtf3
.
parse
(
ExcelUtils
.
getString
(
cell
)+
" 00:00:00"
));
break
;
case
"replace_name"
:
if
(
StringUtils
.
isNullOrEmpty
(
ExcelUtils
.
getString
(
cell
)))
{
...
...
@@ -1776,26 +1776,14 @@ public class InsureContorll {
}
replaceUser
.
setInsuredNo
(
ExcelUtils
.
getString
(
cell
));
break
;
case
"Date_of_birth"
:
break
;
case
"insured_type"
:
break
;
case
"insured_relationship"
:
break
;
case
"cert_type_related_insured"
:
break
;
case
"insured_relationship_id"
:
break
;
case
"Branch"
:
break
;
case
"Tricycle_frame_number"
:
replaceUser
.
setTricycleFrameNumber
(
ExcelUtils
.
getString
(
cell
));
break
;
case
"insured_number"
:
break
;
case
"benefit_occupation_category"
:
replaceUser
.
setBenefitOccupationCategory
(
ExcelUtils
.
getString
(
cell
));
break
;
default
:
continue
;
}
originalUser
.
setReplaceUser
(
replaceUser
);
...
...
@@ -1803,12 +1791,14 @@ public class InsureContorll {
}
}
/*验证表格信息*/
List
<
String
>
userIdList
=
Lists
.
newArrayList
();
for
(
InsureUser
insureUser
:
originalList
)
{
InsureUser
getInsureUser
=
InsureUser
.
builder
().
build
().
selectOne
(
new
QueryWrapper
<
InsureUser
>().
lambda
()
.
eq
(
InsureUser:
:
getInsuredEContact
,
insureUser
.
getInsuredEContact
()).
eq
(
InsureUser:
:
getInsuredNo
,
insureUser
.
getInsuredNo
())
.
eq
(
InsureUser:
:
getInsureStatus
,
1
).
eq
(
InsureUser:
:
getStatus
,
1
).
eq
(
InsureUser:
:
getPolicyId
,
policyId
));
.
eq
(
InsureUser:
:
getInsureStatus
,
1
).
eq
(
InsureUser:
:
getStatus
,
1
).
eq
(
InsureUser:
:
getPolicyId
,
policyId
).
eq
(
InsureUser:
:
getBenefitBasicPlan
,
planId
)
.
eq
(
InsureUser:
:
getBenefitOccupationCategory
,
categoryId
));
if
(
getInsureUser
==
null
){
return
ResultUtil
.
error
(
insureUser
.
getInsured
Name
()+
"未投保"
);
return
ResultUtil
.
error
(
insureUser
.
getInsured
EContact
()+
"未投保"
);
}
YgglMainEmp
ygglMainEmp
=
YgglMainEmp
.
builder
().
build
().
selectOne
(
new
QueryWrapper
<
YgglMainEmp
>().
lambda
()
.
eq
(
YgglMainEmp:
:
getName
,
insureUser
.
getReplaceUser
().
getInsuredName
())
...
...
@@ -1825,9 +1815,11 @@ public class InsureContorll {
ygglMainEmp
.
setIsInsure
(
0
);
ygglMainEmp
.
insert
();
}
userIdList
.
add
(
String
.
valueOf
(
ygglMainEmp
.
getId
()));
}
/*上传替换文件到保司服务器*/
bos
=
new
ByteArrayOutputStream
();
/*保司返回地址*/
String
url
=
""
;
xw
.
write
(
bos
);
...
...
@@ -1845,26 +1837,96 @@ public class InsureContorll {
Map
<
String
,
Object
>
map
=
JSONObject
.
parseObject
(
JSONObject
.
toJSONString
(
o
));
url
=
map
.
get
(
"file_url"
).
toString
();
if
(
StringUtils
.
isNullOrEmpty
(
url
)||
url
==
"error"
){
return
ResultUtil
.
error
(
"上传文件路径异常"
);
throw
new
CustomException
(
"上传文件路径异常"
);
}
}
InsureLog
.
builder
().
requestParam
(
JSONObject
.
toJSONString
(
setParams
(
JSONObject
.
toJSONString
(
bodyMap
),
appidq
,
secretq
))).
type
(
6
)
.
requestData
(
JSONObject
.
toJSONString
(
bodyMap
)).
createTime
(
new
Date
()).
requestType
(
1
).
returnBody
(
data
).
requestPath
(
uploadUrl2
)
.
returnCode
(
dataMap
.
get
(
"errcode"
).
toString
()).
returnMsg
(
dataMap
.
get
(
"errmsg"
).
toString
()).
fileUrl
(
url
).
build
().
insert
();
List
<
InsureUser
>
oldInsureUserList
=
insureUserMapper
.
selectListByIds
(
originalList
.
stream
().
map
(
InsureUser:
:
getId
).
toArray
(
String
[]::
new
),
insurePolicy
.
getId
(),
null
);
String
[]
oldUser
=
new
String
[
oldInsureUserList
.
size
()];
for
(
int
i
=
0
;
i
<
oldInsureUserList
.
size
();
i
++)
{
oldUser
[
i
]
=
oldInsureUserList
.
get
(
i
).
getUserId
().
toString
();
}
Integer
price
=
getPrice
(
planId
,
categoryId
);
LocalDateTime
now
=
LocalDateTime
.
now
();
DateTimeFormatter
dtf2
=
DateTimeFormatter
.
ofPattern
(
"yyyyMMddHHmmss"
);
bodyMap
.
put
(
"contract_no"
,
insurePolicy
.
getPolicyNo
());
bodyMap
.
put
(
"order_status"
,
"3"
);
bodyMap
.
put
(
"callback_plan"
,
""
);
bodyMap
.
put
(
"file_url"
,
url
);
bodyMap
.
put
(
"from_source"
,
"API"
);
bodyMap
.
put
(
"import_review_callback"
,
""
);
bodyMap
.
put
(
"import_callback"
,
base_api_url
+
"/callBack/policy/CallBack"
);
bodyMap
.
put
(
"third_uuid"
,
"RP_"
+
insurePolicy
.
getOrgCode
()
+
"_"
+
dtf2
.
format
(
now
));
String
responData
=
HttpUtils
.
sendPost
(
batchUrl
,
setParams
(
JSONObject
.
toJSONString
(
bodyMap
),
appidq
,
secretq
),
bodyMap
);
Map
<
String
,
Object
>
batchDataMap
=
JSONObject
.
parseObject
(
responData
);
InsureLog
.
builder
().
requestParam
(
JSONObject
.
toJSONString
(
setParams
(
JSONObject
.
toJSONString
(
bodyMap
),
appid
,
secret
))).
type
(
3
)
.
requestData
(
JSONObject
.
toJSONString
(
bodyMap
)).
createTime
(
new
Date
()).
requestType
(
1
).
returnBody
(
responData
).
requestPath
(
batchUrl
)
.
returnCode
(
batchDataMap
.
get
(
"errcode"
).
toString
()).
returnMsg
(
batchDataMap
.
get
(
"errmsg"
).
toString
()).
policyId
(
insurePolicy
.
getId
()).
fileUrl
(
url
).
build
().
insert
();
if
(
batchDataMap
.
get
(
"errcode"
).
toString
().
equals
(
"suc"
))
{
Map
<
String
,
Object
>
batchData
=
JSONObject
.
parseObject
(
JSONObject
.
toJSONString
(
batchDataMap
.
get
(
"data"
)));
Map
<
String
,
Object
>
orderImportInfo
=
JSONObject
.
parseObject
(
JSONObject
.
toJSONString
(
batchData
.
get
(
"order_import_info"
)));
String
status
=
orderImportInfo
.
get
(
"status"
).
toString
();
if
(
status
.
equals
(
"5"
)
||
status
.
equals
(
"6"
)
||
status
.
equals
(
"7"
))
{
InsureLog
.
builder
().
requestParam
(
JSONObject
.
toJSONString
(
setParams
(
JSONObject
.
toJSONString
(
bodyMap
),
appid
,
secret
))).
type
(
2
)
.
requestData
(
JSONObject
.
toJSONString
(
bodyMap
)).
createTime
(
new
Date
()).
requestType
(
1
).
returnBody
(
responData
).
requestPath
(
batchUrl
)
.
returnCode
(
batchDataMap
.
get
(
"errcode"
).
toString
()).
returnMsg
(
batchDataMap
.
get
(
"errmsg"
).
toString
()).
policyId
(
insurePolicy
.
getId
()).
transId
(
"RP_"
+
insurePolicy
.
getOrgCode
()
+
"_"
+
dtf2
.
format
(
now
)).
fileUrl
(
batchData
.
get
(
"file_url"
).
toString
()).
build
().
insert
();
//TODO 写入日志
return
ResultUtil
.
error
(
"信息填写错误,请查看日志"
);
}
else
{
List
<
YgglMainEmp
>
ygglMainEmpList
=
ygglMainEmpMapper
.
selectListByIds
(
userIdList
.
stream
().
toArray
(
String
[]::
new
));
QyzxEntInfoM
qyzxEntInfoM
=
QyzxEntInfoM
.
builder
().
id
(
insurePolicy
.
getOrgCode
()).
build
().
selectById
();
ygglMainEmpList
.
forEach
(
y
->
{
InsureUser
.
builder
()
.
transId
(
"RP_"
+
insurePolicy
.
getOrgCode
()
+
"_"
+
dtf2
.
format
(
now
))
.
insuredName
(
qyzxEntInfoM
.
getName
())
.
price
(
price
.
toString
())
/*前端获取的保费*/
.
premium
(
String
.
valueOf
(
price
*
ygglMainEmpList
.
size
()))
.
batchNo
(
batchDataMap
.
get
(
"import_uuid"
).
toString
())
.
benefitBasicPlan
(
planId
)
.
policyNo
(
orderImportInfo
.
get
(
"contract_no"
).
toString
())
.
userId
(
y
.
getId
())
.
orgCode
(
y
.
getOrgCode
())
.
benefitOccupationCategory
(
categoryId
)
.
insuredMobile
(
y
.
getPhone
())
.
insuredNo
(
y
.
getZjNum
())
.
tricycleFrameNumber
(
oldInsureUserList
.
get
(
0
).
getTricycleFrameNumber
())
.
insuredEContact
(
y
.
getName
())
.
applicantEmployeeList
(
batchDataMap
.
get
(
"file_url"
).
toString
())
.
policyDateStart
(
oldInsureUserList
.
get
(
0
).
getPolicyDateStart
())
.
policyDateEnd
(
oldInsureUserList
.
get
(
0
).
getPolicyDateEnd
())
.
applyType
(
3
)
.
createTime
(
new
Date
())
.
status
(
"1"
).
insureStatus
(
3
).
policyId
(
insurePolicy
.
getId
()).
build
().
insert
();
y
.
setIsInsure
(
1
);
y
.
insertOrUpdate
();
});
oldInsureUserList
.
forEach
(
o
->
{
o
.
setReplaceTransId
(
batchDataMap
.
get
(
"import_uuid"
).
toString
());
o
.
updateById
();
});
return
ResultUtil
.
data
(
"核保成功,等待系统更新"
);
}
}
return
ResultUtil
.
error
(
"导入失败"
);
}
catch
(
Exception
e
){
throw
new
CustomException
(
"导入异常"
);
}
finally
{
try
{
xw
.
close
();
bos
.
close
();
}
catch
(
IOException
e
)
{
throw
new
CustomException
(
"
XSSFWorkbook
流关闭异常"
);
throw
new
CustomException
(
"
ByteArrayOutputStream
流关闭异常"
);
}
try
{
bos
.
close
();
xw
.
close
();
}
catch
(
IOException
e
)
{
throw
new
CustomException
(
"
ByteArrayOutputStream
流关闭异常"
);
throw
new
CustomException
(
"
XSSFWorkbook
流关闭异常"
);
}
}
return
ResultUtil
.
success
();
}
}
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