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
f98534e7
Commit
f98534e7
authored
Mar 19, 2022
by
翁国栋
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
运营后台--
保全增员
parent
bd909e43
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
128 additions
and
57 deletions
+128
-57
src/main/java/cn/timer/api/controller/insure/InsureContorll.java
+101
-56
src/main/java/cn/timer/api/dao/insure/InsurePolicyMapper.java
+2
-0
src/main/java/cn/timer/api/dto/insure/InsureDto.java
+1
-0
src/main/java/cn/timer/api/dto/insure/PolicyDto.java
+1
-0
src/main/java/cn/timer/api/dto/yggl/YgQueryDto.java
+3
-0
src/main/resources/mapping/insure/InsurePolicyMapper.xml
+18
-0
src/main/resources/mapping/yggl/YgglMainEmpMapper.xml
+2
-1
No files found.
src/main/java/cn/timer/api/controller/insure/InsureContorll.java
View file @
f98534e7
...
...
@@ -40,6 +40,7 @@ import org.springframework.web.multipart.MultipartFile;
import
java.io.*
;
import
java.net.URLEncoder
;
import
java.security.Policy
;
import
java.text.DateFormat
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
...
...
@@ -82,6 +83,8 @@ public class InsureContorll {
private
static
String
insuredUrl
=
"http://sandbox.portal.unistar-ins.com/mall/Home/Index/createQuotePolicy"
;
/*测试用保全上传文件地址*/
private
static
String
uploadUrl2
=
"http://sandbox.portal.unistar-ins.com/fuli/Home/Index/file_upload"
;
/*测试用保全申请地址*/
private
static
String
batchUrl
=
"http://sandbox.portal.unistar-ins.com/fuli/Home/WelfareProduct/batch_declare"
;
@Autowired
private
YgglMainEmpMapper
ygglMainEmpMapper
;
...
...
@@ -98,7 +101,7 @@ public class InsureContorll {
* @param sign
* @return
*/
private
Map
setParams
(
String
sign
){
private
Map
setParams
(
String
sign
,
String
appid
,
String
secret
){
/*当前时间戳*/
long
timestamp
=
System
.
currentTimeMillis
()/
1000
;
log
.
info
(
"时间戳"
+
timestamp
);
...
...
@@ -114,23 +117,6 @@ public class InsureContorll {
log
.
info
(
"params参数======"
+
JSONObject
.
toJSONString
(
paramsMap
));
return
paramsMap
;
}
/*保全*/
private
Map
setParams2
(
String
sign
){
/*当前时间戳*/
long
timestamp
=
System
.
currentTimeMillis
()/
1000
;
log
.
info
(
"时间戳"
+
timestamp
);
Map
paramsMap
=
Maps
.
newHashMap
();
paramsMap
.
put
(
"pid"
,
appidq
);
paramsMap
.
put
(
"timestamp"
,
String
.
valueOf
(
timestamp
/
1000
));
paramsMap
.
put
(
"trace_id"
,
appidq
+
timestamp
+
new
Random
().
nextInt
((
9999
-
100
)
+
1
)
+
10
);
// paramsMap.put("sign",Md5.md5(appidq+secret+timestamp+sign.trim()));
String
value
=
appidq
+
secretq
+
timestamp
+
sign
;
log
.
info
(
"body参数======"
+
sign
);
paramsMap
.
put
(
"sign"
,
DigestUtils
.
md5Hex
(
value
));
log
.
info
(
"params参数======"
+
JSONObject
.
toJSONString
(
paramsMap
));
return
paramsMap
;
}
@PostMapping
(
value
=
"/insured_add"
)
@ApiOperation
(
value
=
"1.投保申请"
,
httpMethod
=
"Post"
,
notes
=
"投保申请"
)
...
...
@@ -277,12 +263,12 @@ public class InsureContorll {
}
/*测试用生产环境不需要*/
synchronized
private
Map
requestAgent
(
Map
bodyMap
){
String
data
=
HttpUtils
.
sendPost
(
insuredUrl
,
setParams
(
JSONObject
.
toJSONString
(
bodyMap
)),
bodyMap
);
String
data
=
HttpUtils
.
sendPost
(
insuredUrl
,
setParams
(
JSONObject
.
toJSONString
(
bodyMap
)
,
appid
,
secret
),
bodyMap
);
Map
dataMap
=
JSONObject
.
parseObject
(
data
,
Map
.
class
);
if
(
dataMap
.
get
(
"errcode"
).
toString
().
equals
(
"suc"
))
{
return
dataMap
;
}
else
{
if
(
dataMap
.
get
(
"errcode"
).
toString
().
equals
(
"e1"
)&&
dataMap
.
get
(
"errmsg"
).
toString
().
equals
(
"出单中"
)){
if
(
dataMap
.
get
(
"errcode"
).
toString
().
equals
(
"e1"
)&&
(
dataMap
.
get
(
"errmsg"
).
toString
().
equals
(
"出单中"
)||
dataMap
.
get
(
"errmsg"
).
toString
().
equals
(
"系统正在处理中,请稍候再试"
)
)){
try
{
Thread
.
sleep
(
30000
);
return
requestAgent
(
bodyMap
);
...
...
@@ -318,44 +304,11 @@ public class InsureContorll {
bodyMap
.
put
(
"name"
,
file
.
getName
());
bodyMap
.
put
(
"file"
,
fileBase64
);
/*end*/
String
data
=
HttpUtils
.
sendPost
(
uploadUrl
,
setParams
(
JSONObject
.
toJSONString
(
bodyMap
)),
bodyMap
);
String
data
=
HttpUtils
.
sendPost
(
uploadUrl
,
setParams
(
JSONObject
.
toJSONString
(
bodyMap
)
,
appid
,
secret
),
bodyMap
);
log
.
info
(
"请求返回的结果====="
+
data
);
/*文件流base64*/
return
ResultUtil
.
data
(
message
(
data
));
};
@PostMapping
(
value
=
"/file_upload2"
)
@ApiOperation
(
value
=
"3.保全上传文件"
,
httpMethod
=
"Post"
,
notes
=
"上传文件"
)
@ApiOperationSupport
(
order
=
2
)
public
Result
<
Object
>
fileUpload2
(
@CurrentUser
UserBean
userBean
,
@RequestParam
(
required
=
true
)
MultipartFile
file
)
{
if
(
file
==
null
)
{
return
ResultUtil
.
error
(
"上传失败,请选择上传文件"
);
}
byte
[]
bytes
=
null
;
try
{
bytes
=
file
.
getBytes
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
log
.
warn
(
"文件转换Base64异常"
);
}
String
fileBase64
=
Base64
.
byteArrayToBase64
(
bytes
);
/*body参数 begin*/
Map
bodyMap
=
Maps
.
newHashMap
();
// bodyMap.put("app","mall");
// bodyMap.put("name","劳务公司批增-月单(1).xlsx");
bodyMap
.
put
(
"file"
,
fileBase64
);
/*end*/
String
data
=
HttpUtils
.
sendPost
(
uploadUrl2
,
setParams2
(
JSONObject
.
toJSONString
(
bodyMap
)),
bodyMap
);
log
.
info
(
"请求返回的结果====="
+
data
);
/*文件流base64*/
return
ResultUtil
.
data
(
message
(
data
));
};
// @PostMapping(value = "/baoquan")
// @ApiOperation(value = "2.单个添加保全", httpMethod = "Post", notes = "上传文件")
// @ApiOperationSupport(order = 2)
// public Result<Object> baoquan_add(InsuredUser user) {
//return null;
// }
/**
* 设置错误信息
...
...
@@ -370,7 +323,11 @@ public class InsureContorll {
return
dataMap
.
get
(
"errmsg"
);
}
/**
* 生成投保问文件
* @param ids
* @return
*/
public
String
creaXSSFWorkbook
(
String
[]
ids
){
if
(
ids
.
length
<=
0
){
return
"error"
;
...
...
@@ -398,7 +355,7 @@ public class InsureContorll {
bodyMap
.
put
(
"name"
,
localDate
+
"_"
+
list
.
size
()+
"名人员清单.xlsx"
);
bodyMap
.
put
(
"file"
,
fileBase64
);
/*end*/
String
data
=
HttpUtils
.
sendPost
(
uploadUrl
,
setParams
(
JSONObject
.
toJSONString
(
bodyMap
)),
bodyMap
);
String
data
=
HttpUtils
.
sendPost
(
uploadUrl
,
setParams
(
JSONObject
.
toJSONString
(
bodyMap
)
,
appid
,
secret
),
bodyMap
);
Map
<
String
,
Object
>
dataMap
=
JSONObject
.
parseObject
(
data
);
if
(
dataMap
.
get
(
"errcode"
).
toString
().
equals
(
"suc"
))
{
Object
o
=
dataMap
.
get
(
"data"
);
...
...
@@ -434,4 +391,92 @@ public class InsureContorll {
List
<
PolicyDto
>
list
=
insurePolicyMapper
.
policyList
();
return
ResultUtil
.
data
(
list
);
}
@GetMapping
(
value
=
"/policyDetail"
)
@ApiOperation
(
value
=
"5.保单信息"
,
httpMethod
=
"Get"
,
notes
=
"保单列表"
)
@ApiOperationSupport
(
order
=
2
)
public
Result
<
Object
>
policyDetail
(
@RequestParam
(
"policyId"
)
Integer
policyId
)
{
PolicyDto
policyDto
=
insurePolicyMapper
.
getPolicyDetail
(
policyId
);
if
(
policyDto
==
null
){
return
ResultUtil
.
error
(
"保单不存在"
);
}
return
ResultUtil
.
data
(
policyDto
);
}
@PostMapping
(
value
=
"/joinUser"
)
@ApiOperation
(
value
=
"5.增员"
,
httpMethod
=
"Post"
,
notes
=
"增员"
)
@ApiOperationSupport
(
order
=
2
)
public
Result
<
Object
>
policyDetail
(
@RequestBody
InsureDto
insureDto
)
{
InsurePolicy
insurePolicy
=
InsurePolicy
.
builder
().
id
(
Integer
.
parseInt
(
insureDto
.
getId
())).
build
().
selectById
();
if
(
insurePolicy
==
null
){
return
ResultUtil
.
error
(
"保单不存在"
);
}
LocalDateTime
now
=
LocalDateTime
.
now
();
String
url
=
creaXSSFWorkbook1
(
insureDto
.
getUserIds
());
log
.
info
(
"保全增员文件地址"
,
url
);
DateTimeFormatter
dtf2
=
DateTimeFormatter
.
ofPattern
(
"yyyyMMddHHmmss"
);
Map
bodyMap
=
Maps
.
newHashMap
();
bodyMap
.
put
(
"contract_no"
,
insurePolicy
.
getPolicyNo
());
bodyMap
.
put
(
"order_status"
,
"1"
);
bodyMap
.
put
(
"callback_plan"
,
""
);
bodyMap
.
put
(
"file_url"
,
url
);
bodyMap
.
put
(
"from_source"
,
"API"
);
bodyMap
.
put
(
"import_review_callback"
,
""
);
bodyMap
.
put
(
"import_callback"
,
""
);
bodyMap
.
put
(
"third_uuid"
,
"BQ_"
+
insurePolicy
.
getOrgCode
()+
"_"
+
dtf2
.
format
(
now
));
String
data
=
HttpUtils
.
sendPost
(
batchUrl
,
setParams
(
JSONObject
.
toJSONString
(
bodyMap
),
appidq
,
secretq
),
bodyMap
);
log
.
info
(
"保全增员返回"
,
data
);
return
ResultUtil
.
data
(
""
);
}
/**
* 生成保全增员文件
* @param ids
* @return
*/
public
String
creaXSSFWorkbook1
(
String
[]
ids
){
if
(
ids
.
length
<=
0
){
return
"error"
;
}
LocalDate
localDate
=
LocalDate
.
now
();
List
<
YgglMainEmp
>
ygglMainEmpList
=
ygglMainEmpMapper
.
selectListByIds
(
ids
);
List
list
=
Lists
.
newArrayList
();
for
(
YgglMainEmp
y:
ygglMainEmpList
)
{
String
[]
arr
=
new
String
[]{
String
.
valueOf
(
y
.
getId
()),
y
.
getName
(),
"身份证"
,
y
.
getZjNum
(),
"50万意外/5万医疗/扩展24小时(A类)"
,
""
,
"深圳名邦人力资源管理有限公司"
,
"无"
,
"A类"
};
list
.
add
(
arr
);
}
String
[]
rowName
=
new
String
[]{
"ID"
,
"name"
,
"ID_type"
,
"ID_number"
,
"Scheme_name"
,
"Date_start"
,
"Branch"
,
"Tricycle_frame_number"
,
"benefit_occupation_category"
};
XSSFWorkbook
xssfWorkbook
=
ExcelUtils
.
exportExcel
(
localDate
+
"_"
+
list
.
size
()+
"名人员清单.xlsx"
,
rowName
,
list
);
ByteArrayOutputStream
byteArrayOutputStream
=
new
ByteArrayOutputStream
();
try
{
xssfWorkbook
.
write
(
byteArrayOutputStream
);
byte
[]
bytes
=
byteArrayOutputStream
.
toByteArray
();
String
fileBase64
=
Base64
.
byteArrayToBase64
(
bytes
);
/*body参数 begin*/
Map
bodyMap
=
Maps
.
newHashMap
();
bodyMap
.
put
(
"media"
,
fileBase64
);
/*end*/
String
data
=
HttpUtils
.
sendPost
(
uploadUrl2
,
setParams
(
JSONObject
.
toJSONString
(
bodyMap
),
appidq
,
secretq
),
bodyMap
);
Map
<
String
,
Object
>
dataMap
=
JSONObject
.
parseObject
(
data
);
if
(
dataMap
.
get
(
"errcode"
).
toString
().
equals
(
"suc"
))
{
Object
o
=
dataMap
.
get
(
"data"
);
Map
<
String
,
Object
>
map
=
JSONObject
.
parseObject
(
JSONObject
.
toJSONString
(
o
));
return
map
.
get
(
"file_url"
).
toString
();
}
/*文件流base64*/
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
finally
{
try
{
xssfWorkbook
.
close
();
byteArrayOutputStream
.
close
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
return
"suc"
;
}
}
src/main/java/cn/timer/api/dao/insure/InsurePolicyMapper.java
View file @
f98534e7
...
...
@@ -3,6 +3,7 @@ package cn.timer.api.dao.insure;
import
cn.timer.api.bean.insure.InsurePolicy
;
import
cn.timer.api.dto.insure.PolicyDto
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
org.apache.ibatis.annotations.Param
;
import
org.springframework.stereotype.Repository
;
import
java.util.List
;
...
...
@@ -17,5 +18,6 @@ import java.util.List;
@Repository
public
interface
InsurePolicyMapper
extends
BaseMapper
<
InsurePolicy
>
{
public
List
<
PolicyDto
>
policyList
();
PolicyDto
getPolicyDetail
(
@Param
(
"id"
)
Integer
id
);
}
src/main/java/cn/timer/api/dto/insure/InsureDto.java
View file @
f98534e7
...
...
@@ -19,6 +19,7 @@ import java.util.Date;
@NoArgsConstructor
@AllArgsConstructor
public
class
InsureDto
{
private
String
id
;
private
String
orgCode
;
/*劳动合同*/
private
String
companyName
;
/*用工单位实际工作单位*/
private
String
[]
userIds
;
...
...
src/main/java/cn/timer/api/dto/insure/PolicyDto.java
View file @
f98534e7
...
...
@@ -30,5 +30,6 @@ public class PolicyDto {
private
String
insuredName
;
private
String
benefitBasicPlan
;
private
String
price
;
private
String
orgCode
;
}
src/main/java/cn/timer/api/dto/yggl/YgQueryDto.java
View file @
f98534e7
...
...
@@ -74,4 +74,7 @@ public class YgQueryDto extends Page {
@ApiModelProperty
(
value
=
"性别"
,
example
=
"1"
)
private
Integer
sex
;
@ApiModelProperty
(
value
=
"是否已购买保险"
,
example
=
"0"
)
private
Integer
isInsure
;
}
src/main/resources/mapping/insure/InsurePolicyMapper.xml
View file @
f98534e7
...
...
@@ -271,4 +271,22 @@
</select>
<select
id=
"getPolicyDetail"
resultType=
"cn.timer.api.dto.insure.PolicyDto"
>
SELECT
ip.id as id,
ip.scheme_name as schemeName,
ip.policy_date_start as policyDateStart,
ip.policy_date_end as policyDateEnd,
ip.policy_no as policyNo,
ip.org_code as orgCode,
iu.insured_name as insuredName,
iu.benefit_basic_plan as benefitBasicPlan
FROM
insure_policy ip
LEFT JOIN insure_user iu ON iu.policy_no = ip.policy_no
WHERE
ip.id = #{id}
LIMIT 1
</select>
</mapper>
src/main/resources/mapping/yggl/YgglMainEmpMapper.xml
View file @
f98534e7
...
...
@@ -240,7 +240,8 @@
a.phone phone,
a.job_status jobStatus,
a.head_url headUrl,
a.sex sex
a.sex sex,
a.is_insure isInsure
FROM
yggl_main_emp a
LEFT JOIN zzgl_bmgw_m b ON a.bmgw_id = b.id
...
...
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