Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
聂康
local-rnr-fp
Commits
015d4257
Commit
015d4257
authored
Jun 17, 2025
by
kang.nie@inzymeits.com
Browse files
初始化代码
parent
bd38ff8b
Pipeline
#3108
failed with stages
in 0 seconds
Changes
404
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
local-rnr-fp-server/src/main/java/com/cusc/nirvana/user/rnr/fp/service/IOrganService.java
0 → 100644
View file @
015d4257
package
com.cusc.nirvana.user.rnr.fp.service
;
import
com.cusc.nirvana.common.result.Response
;
import
com.cusc.nirvana.user.eiam.dto.OrganizationDTO
;
/**
* Description: 组织操作service
* <br />
* CreateDate 2022-07-06 19:32:37
*
* @author yuyi
**/
public
interface
IOrganService
{
/**
* Description: 根据组织id获取上一级的车企组织id
* <br />
* CreateDate 2022-05-27 18:59:35
*
* @author yuyi
**/
Response
<
OrganizationDTO
>
getCarSubOrganByOrgId
(
OrganizationDTO
bean
);
/**
* Description: 根据组织查询编码获取上一级的车企组织id
* <br />
* CreateDate 2022-05-27 18:59:35
*
* @author yuyi
**/
Response
<
OrganizationDTO
>
getCarSubOrganByQueryCodePrivate
(
OrganizationDTO
bean
);
}
local-rnr-fp-server/src/main/java/com/cusc/nirvana/user/rnr/fp/service/IRnrOrderService.java
0 → 100644
View file @
015d4257
package
com.cusc.nirvana.user.rnr.fp.service
;
import
com.cusc.nirvana.common.result.PageResult
;
import
com.cusc.nirvana.user.rnr.fp.dto.RnrOrderDetailDTO
;
import
com.cusc.nirvana.user.rnr.fp.dto.RnrOrderListQueryDTO
;
import
com.cusc.nirvana.user.rnr.fp.dto.RnrOrderListResponseDTO
;
import
com.cusc.nirvana.user.rnr.fp.dto.VinCardDTO
;
import
com.cusc.nirvana.user.rnr.mg.dto.LocalVerifyListDTO
;
import
com.cusc.nirvana.user.rnr.mg.dto.LocalVerifyListRqDTO
;
import
com.cusc.nirvana.user.rnr.mg.dto.MgRnrCardInfoDTO
;
/**
* @author stayAnd
* @date 2022/7/28
*/
public
interface
IRnrOrderService
{
/**
* 页面分页查询
* @param dto 请求参数
* @return 返回结果
*/
PageResult
<
RnrOrderListResponseDTO
>
pageListQuery
(
RnrOrderListQueryDTO
dto
);
/**
* 根据工单id分页查询卡信息
* @param dto orderId
* @return 返回结果
*/
PageResult
<
VinCardDTO
>
queryCardPageByOrderId
(
MgRnrCardInfoDTO
dto
);
/**
* 查询详情
* @param orderId orderId
* @return 返回结果
*/
RnrOrderDetailDTO
queryOrderDetail
(
String
orderId
);
/**
* 查询
* @param dto
* @return
*/
PageResult
<
LocalVerifyListDTO
>
localverifyList
(
RnrOrderListQueryDTO
dto
);
}
local-rnr-fp-server/src/main/java/com/cusc/nirvana/user/rnr/fp/service/IRnrService.java
0 → 100644
View file @
015d4257
package
com.cusc.nirvana.user.rnr.fp.service
;
import
com.cusc.nirvana.common.result.Response
;
import
com.cusc.nirvana.user.rnr.fp.dto.*
;
import
com.cusc.nirvana.user.rnr.mg.dto.MgRnrCardInfoDTO
;
import
com.cusc.nirvana.user.rnr.mg.dto.MgRnrInfoDTO
;
import
com.cusc.nirvana.user.rnr.mg.dto.RnrOrderDTO
;
import
com.cusc.nirvana.user.rnr.mg.dto.RnrRelationDTO
;
import
java.util.List
;
/**
* @author stayAnd
* @date 2022/4/18
*/
public
interface
IRnrService
{
/**
* 人脸对比,人证对比
*/
RnrResponseDTO
doIdAndFaceCompare
(
RnrRequestDTO
dto
,
String
[]
livenessPic
,
Integer
subjectType
);
/**
* 获取活体数字验证码
* @param dto 请求参数
* @return
*/
LivenessCodeResponseDTO
getLivenessCode
(
LivenessCodeRequestDTO
dto
);
/**
* 个人实名
* @param serialNumber serialNumber
* @param requestId requestId
* @param dto dto
* @return 0认证通过 1-人工审核中
*/
Integer
personRnr
(
String
serialNumber
,
String
requestId
,
RnrRelationDTO
dto
);
/**
* 个人二手车实名
* @param serialNumber serialNumber
* @param requestId requestId
* @param dto dto
* @return 0认证通过 1-人工审核中
*/
Integer
personSecondHandRnr
(
String
serialNumber
,
String
requestId
,
RnrRelationDTO
dto
);
/**
* 企业责任人实名
* @param dto
* @param livenessPic
* @return
*/
RnrResponseDTO
doPersonRnr
(
RnrRequestDTO
dto
,
String
[]
livenessPic
);
/**
* 参数类型转换
* @param dto
* @return
*/
RnrRequestDTO
rnrPersonRelationDto2RnrRequestDTO
(
RnrRelationDTO
dto
);
/**
* 校验个人信息
*/
boolean
checkPersonData
(
String
serialNumber
,
String
requestId
,
RnrRelationDTO
dto
);
/**
* H5实名
* @param serialNumber
* @param dto
*/
void
personRnrH5
(
String
serialNumber
,
RnrRelationDTO
dto
);
Integer
personH5CallBack
(
PersonH5CallBackRequestDTO
dto
);
/**
* 一证十卡
* @param dto
*/
void
cardNumberCheck
(
RnrRelationDTO
dto
);
void
iccidListCheck
(
RnrRelationDTO
dto
);
String
getRnrLivenessType
(
String
tenantNo
);
/**
* 本地系统将实名结果回传给智网
* @param dtoList 实名卡信息列表
* @param rnrBizzType 实名业务类型RnrBizzTypeEnum
* @param serialNumber 请求ID
* @param orgId 组织id
* @param resultCode 业务结果类型ResultCodeEnum
*/
Response
notifyResult
(
List
<
MgRnrCardInfoDTO
>
dtoList
,
String
rnrBizzType
,
String
serialNumber
,
String
orgId
,
String
resultCode
);
/**
* h5接口
* @param dto
*/
Response
<
LiveLoginRespDTO
>
h5LiveLoginUrl
(
LiveLoginReqDTO
dto
);
RnrRequestDTO
h5InfoToRnrRequest
(
boolean
isTrust
,
RnrOrderDTO
orderDTO
,
String
rnrId
,
MgRnrInfoDTO
rnrInfo
);
/**
* 获取H5活体检测URL
* @param dto
* @return
*/
Response
<
LivenessResultDTO
>
h5LivenessResult
(
LiveLoginReqDTO
dto
);
/**
* h5验证身份证信息
* @param dto
* @return
*/
Response
<
RnrResponseDTO
>
h5ValidationOCR
(
H5ValidationOCRReqDTO
dto
);
/**
* 修改实名信息为无效
* @param bean
* @return
*/
Response
updateRnrInValid
(
RnrOrderDTO
bean
);
}
local-rnr-fp-server/src/main/java/com/cusc/nirvana/user/rnr/fp/service/IRnrUnbindService.java
0 → 100644
View file @
015d4257
package
com.cusc.nirvana.user.rnr.fp.service
;
import
com.cusc.nirvana.common.result.Response
;
import
com.cusc.nirvana.user.rnr.mg.dto.RnrRelationDTO
;
/**
* 实名解绑接口
*
* @author yubo
* @since 2022-04-25 09:44
*/
public
interface
IRnrUnbindService
{
/**
* 二手车现车主解绑-自然人
*/
Integer
secondHandPersonalUnbind
(
String
serialNumber
,
String
requestId
,
RnrRelationDTO
dto
);
}
local-rnr-fp-server/src/main/java/com/cusc/nirvana/user/rnr/fp/service/ISimVehicleRelService.java
0 → 100644
View file @
015d4257
package
com.cusc.nirvana.user.rnr.fp.service
;
import
com.cusc.nirvana.common.result.PageResult
;
import
com.cusc.nirvana.common.result.Response
;
import
com.cusc.nirvana.user.rnr.fp.dto.*
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
java.util.List
;
public
interface
ISimVehicleRelService
{
/**
* 导入车卡关系接口
* @param bindingDTO
* @return
*/
Response
<
SimVehicleBindingResult
>
importSimVehicle
(
@RequestBody
SimVehicleBindingDTO
bindingDTO
);
/**
* 车卡关系解绑
* @param requestDTO
* @return
*/
Response
<
SimVehicleDTO
>
unbind
(
BindRequestDTO
requestDTO
);
/**
* 车卡关系绑定
* @param requestDTO
* @return
*/
Response
<
SimVehicleDTO
>
bind
(
BindRequestDTO
requestDTO
);
/**
* 车辆绑卡查询
* @param vin
* @return
*/
Response
<
List
<
VinIccidDTO
>>
getIccidByVin
(
String
vin
);
/**
* 根据iccid查询车卡关系
* @param iccid
* @return
*/
Response
<
VinIccidDTO
>
getVinByIccid
(
String
iccid
);
/**
* 查看车卡绑定状态
* @param iccid
* @param vin
* @return
*/
Response
<
VinIccidDTO
>
getBindingInfo
(
String
iccid
,
String
vin
);
/**
* 查询多个iccid的详细信息
* @param listDTO
* @return
*/
Response
<
List
<
IccidDetailDTO
>>
queryByIccids
(
@RequestBody
IccidListDTO
listDTO
);
/**
* 获取指定iccid的明细
* @param iccid
* @return
*/
Response
<
IccidDetailDTO
>
getDetailByIccid
(
String
iccid
);
/**
* 查询车卡绑定信息列表
* @param queryDTO
* @return
*/
Response
<
PageResult
<
SimVehicleResultDTO
>>
queryBindingPage
(
SimVehicleQueryDTO
queryDTO
);
}
local-rnr-fp-server/src/main/java/com/cusc/nirvana/user/rnr/fp/service/ISmsService.java
0 → 100644
View file @
015d4257
package
com.cusc.nirvana.user.rnr.fp.service
;
import
com.cusc.nirvana.common.result.Response
;
import
com.cusc.nirvana.user.eiam.dto.ApplicationDTO
;
import
com.cusc.nirvana.user.rnr.fp.dto.SmsResponseDTO
;
import
com.cusc.nirvana.user.rnr.fp.dto.SmsSendConfig
;
import
java.util.List
;
/**
* Description: 短信service
* <br />
* CreateDate 2021-11-02 20:25:19
*
* @author yuyi
**/
public
interface
ISmsService
{
/**
* Description: 发送短信-多个参数
* <br />
* CreateDate 2021-12-03 14:53:06
*
* @author yuyi
**/
Response
<
SmsResponseDTO
>
sendSms
(
String
phone
,
List
<
String
>
paramterList
,
String
smsTemplate
);
/**
* Description: 发送短信-单个参数
* <br />
* CreateDate 2021-12-03 14:53:06
*
* @author yuyi
**/
Response
<
SmsResponseDTO
>
sendSms
(
String
phone
,
String
paramter
,
String
smsTemplate
);
// /**
// * Description: 检查短信配置是否为空
// * <br />
// * CreateDate 2022-01-27 14:43:41
// *
// * @author yuyi
// **/
// boolean checkSmsConfigNotNull(SmsSendConfig bean);
// /**
// * Description: 从应用配置转短信配置
// * <br />
// * CreateDate 2022-01-27 14:43:41
// *
// * @author yuyi
// **/
// void convertToSmsConfig(ApplicationDTO fromBean, SmsSendConfig toBean);
//
//
// /**
// * Description: 短信发送限制检查
// * <br />
// * CreateDate 2022-01-27 14:43:41
// *
// * @author yuyi
// **/
// void checkSmsSendLimit(String phone, SmsSendConfig bean);
}
local-rnr-fp-server/src/main/java/com/cusc/nirvana/user/rnr/fp/service/IT1UploadService.java
0 → 100644
View file @
015d4257
package
com.cusc.nirvana.user.rnr.fp.service
;
import
com.cusc.nirvana.common.result.Response
;
import
com.cusc.nirvana.user.rnr.fp.dto.*
;
import
com.cusc.nirvana.user.rnr.mg.dto.MgCardNoticeDTO
;
import
java.io.File
;
/**
* Description: T1上报服务
* <br />
* CreateDate 2022-06-07 20:13:09
*
* @author yuyi
**/
public
interface
IT1UploadService
{
/**
* Description: 上传开户信息和文件信息
* <br />
* CreateDate 2022-06-07 20:17:48
*
* @author yuyi
**/
Response
uploadUserInfoAndFile
(
MgCardNoticeDTO
cardNoticeDTO
);
T1AuthDTO
getAuth
(
EncryptionKeyDTO
encryptionKeyDTO
);
File
encryptZipFile
(
File
zip
,
EncryptionKeyDTO
encryptionKeyDTO
)
throws
Exception
;
T1CommonResponseDTO
t1CallbackResult
(
T1CallbackResultDTO
t1CallbackResultDTO
);
Response
againUploadUserInfoAndFile
(
AgainUploadDTO
againUploadDTO
);
}
local-rnr-fp-server/src/main/java/com/cusc/nirvana/user/rnr/fp/service/IVehicleRnrUnBoundService.java
0 → 100644
View file @
015d4257
package
com.cusc.nirvana.user.rnr.fp.service
;
import
com.cusc.nirvana.common.result.Response
;
import
com.cusc.nirvana.user.rnr.fp.dto.VehicleUnboundVerifyRequestDTO
;
import
com.cusc.nirvana.user.rnr.fp.dto.VerifyVinCardResponseDTO
;
import
com.cusc.nirvana.user.rnr.mg.dto.VehicleUnbindDTO
;
/**
* @author yubo
* @since 2022-04-24 17:09
*/
public
interface
IVehicleRnrUnBoundService
{
/**
* 校验绑定车卡关系
*
* @param responseDTO
* @return
*/
Response
<
VerifyVinCardResponseDTO
>
verifyUnboundVinCardBatch
(
VehicleUnboundVerifyRequestDTO
responseDTO
);
/**
* 车企批量解绑
*
* @param rnrIds
* @return
*/
Response
batchUnbound
(
VehicleUnbindDTO
rnrIds
);
}
local-rnr-fp-server/src/main/java/com/cusc/nirvana/user/rnr/fp/service/IVinCardService.java
0 → 100644
View file @
015d4257
package
com.cusc.nirvana.user.rnr.fp.service
;
import
com.cusc.nirvana.common.result.Response
;
import
com.cusc.nirvana.user.rnr.fp.dto.*
;
import
java.util.List
;
/**
* @author stayAnd
* @date 2022/4/11
*/
public
interface
IVinCardService
{
VinCardInfoDTO
queryVinCard
(
String
vin
);
List
<
VinCardInfoDTO
>
queryVinCardList
(
List
<
String
>
vinList
);
/**
* 车卡关系和卡校验
*
* @return
*/
Response
verifyVinCard
(
List
<
VinCardDTO
>
verifyDTOs
);
}
local-rnr-fp-server/src/main/java/com/cusc/nirvana/user/rnr/fp/service/OperatorService.java
0 → 100644
View file @
015d4257
package
com.cusc.nirvana.user.rnr.fp.service
;
/**
* @className: OperatorService
* @description: 运营商配置
* @author: jk
* @date: 2022/8/2 11:19
* @version: 1.0
**/
public
interface
OperatorService
{
String
get
(
String
iccid
);
}
local-rnr-fp-server/src/main/java/com/cusc/nirvana/user/rnr/fp/service/OrganizationService.java
0 → 100644
View file @
015d4257
package
com.cusc.nirvana.user.rnr.fp.service
;
import
com.cusc.nirvana.common.result.Response
;
import
com.cusc.nirvana.user.eiam.dto.OrganizationDTO
;
/**
* @className: OrganizationService
* @description:
* @author: jk
* @date: 2022/6/10 10:37
* @version: 1.0
**/
public
interface
OrganizationService
{
Response
<
OrganizationDTO
>
getCarSubOrganByQueryCode
(
OrganizationDTO
bean
);
Response
<
OrganizationDTO
>
getCarSubOrganByQueryCodePrivate
(
OrganizationDTO
bean
);
}
local-rnr-fp-server/src/main/java/com/cusc/nirvana/user/rnr/fp/service/ShortMessageCheckService.java
0 → 100644
View file @
015d4257
package
com.cusc.nirvana.user.rnr.fp.service
;
import
com.cusc.nirvana.common.result.Response
;
import
com.cusc.nirvana.user.rnr.fp.dto.SmsRequestDTO
;
import
com.cusc.nirvana.user.rnr.fp.dto.SmsResponseDTO
;
public
interface
ShortMessageCheckService
{
Response
<
SmsResponseDTO
>
sendSmsCaptcha
(
SmsRequestDTO
bean
);
Response
checkSmsCaptcha
(
SmsRequestDTO
bean
);
Response
<
SmsResponseDTO
>
sendUnbindSms
(
SmsRequestDTO
bean
,
String
rnrId
,
String
iccids
);
Response
<
SmsResponseDTO
>
sendSms
(
SmsRequestDTO
bean
);
}
local-rnr-fp-server/src/main/java/com/cusc/nirvana/user/rnr/fp/service/T1ReportCompletionService.java
0 → 100644
View file @
015d4257
package
com.cusc.nirvana.user.rnr.fp.service
;
import
com.cusc.nirvana.common.result.Response
;
import
com.cusc.nirvana.user.rnr.fp.dto.T1CompletionReqDTO
;
/**
* @className: T1ReportCompletionService
* @description: t1报竣
* @author: jk
* @date: 2022/8/23 11:03
* @version: 1.0
**/
public
interface
T1ReportCompletionService
{
Response
T1ReportCompletionCmcc
(
T1CompletionReqDTO
t1CompletionReqDTO
);
}
local-rnr-fp-server/src/main/java/com/cusc/nirvana/user/rnr/fp/service/impl/ChinaMobileT1UploadServiceImpl.java
0 → 100644
View file @
015d4257
package
com.cusc.nirvana.user.rnr.fp.service.impl
;
import
cn.hutool.crypto.SecureUtil
;
import
cn.hutool.crypto.symmetric.AES
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.cusc.nirvana.user.rnr.fp.common.util.ChinaMobileSftpUtil
;
import
com.cusc.nirvana.user.rnr.fp.dto.*
;
import
com.cusc.nirvana.user.rnr.fp.util.AESUtil
;
import
com.cusc.nirvana.user.rnr.fp.util.RnrDataSM3Utils
;
import
com.jcraft.jsch.JSchException
;
import
com.jcraft.jsch.SftpException
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Qualifier
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.http.*
;
import
org.springframework.stereotype.Service
;
import
org.springframework.web.client.RestTemplate
;
import
java.io.File
;
@Service
@Slf4j
public
class
ChinaMobileT1UploadServiceImpl
extends
VehicleT1UploadServiceImpl
{
@Value
(
"${t1.chinaMobile.userInfoUrl:}"
)
private
String
userInfoUrl
;
@Value
(
"${t1.chinaMobile.vehicleInfoUrl:}"
)
private
String
vehicleInfoUrl
;
@Value
(
"${t1.chinaMobile.phoPath:}"
)
private
String
phoPath
;
@Value
(
"${t1.chinaMobile.phoPathByInstruction:}"
)
private
String
phoPathByInstruction
;
@Value
(
"${t1.chinaMobile.platformID:}"
)
//由OneLink车联卡实名平台为各个车 企分配的标识
private
String
platformID
;
@Value
(
"${t1.chinaMobile.code:}"
)
//工信部下发的车企编码,道路机动 车辆生产 企业编码
private
String
code
;
@Value
(
"${t1.chinaMobile.t1UserInfoKey:}"
)
//开户信息的加密密钥由 OneLink 平台生成后,自动发送到指定邮箱。
private
String
t1UserInfoKey
=
"7faf0abf9e6c4aa0aa04eeccf3110e37"
;
@Autowired
@Qualifier
(
"noBalanceRestTemplateRnrFp"
)
RestTemplate
noBalanceRestTemplateRnrFp
;
@Autowired
private
ChinaMobileSftpUtil
sftpUtil
;
public
File
encryptZipFile
(
String
zipFileName
,
String
folderPath
)
{
try
{
return
AESUtil
.
encryptFile
(
t1UserInfoKey
,
zipFileName
,
folderPath
+
".bin"
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
log
.
error
(
"chinaMobile encryZipFile failed."
,
e
);
}
return
null
;
}
/**
* 加密用户开户信息
*
* @param userInfoStr * @return 需要加密的字符串内容
*/
private
final
String
encryptUserInfo
(
String
userInfoStr
)
{
byte
[]
key
=
AESUtil
.
MD5
(
t1UserInfoKey
);
//构建
AES
aes
=
SecureUtil
.
aes
(
key
);
//加密
return
aes
.
encryptHex
(
userInfoStr
);
}
public
String
encrypt
(
T1UserInfoDTO
ret
)
{
return
encryptUserInfo
(
JSON
.
toJSONString
(
ret
));
}
private
final
T1AuthDTO
getAuth
()
{
final
T1AuthDTO
t1AuthDTO
=
new
T1AuthDTO
();
t1AuthDTO
.
setPlatformID
(
platformID
);
//平台标识+密码的SM3值,密码由 OneLink车联卡实名平台分配
String
signNature
=
platformID
+
t1UserInfoKey
;
t1AuthDTO
.
setSignNature
(
RnrDataSM3Utils
.
encode
(
signNature
));
return
t1AuthDTO
;
}
public
T1CommonResponseDTO
uploadT1UserInfo
(
T1UserInfoReqDTO
userInfo
)
{
long
startTime
=
System
.
currentTimeMillis
();
userInfo
.
setAuth
(
getAuth
());
String
requestStrTmp
=
JSON
.
toJSONString
(
userInfo
);
JSONObject
jsonObject
=
JSON
.
parseObject
(
requestStrTmp
);
jsonObject
.
remove
(
"ServiceProvider"
);
final
String
requestStr
=
jsonObject
.
toJSONString
();
log
.
info
(
"uploadUserInfo url: {},request: {}"
,
userInfoUrl
,
requestStr
);
HttpHeaders
requestHeaders
=
new
HttpHeaders
();
requestHeaders
.
setContentType
(
MediaType
.
APPLICATION_JSON_UTF8
);
ResponseEntity
<
String
>
entity
=
noBalanceRestTemplateRnrFp
.
exchange
(
userInfoUrl
,
HttpMethod
.
POST
,
new
HttpEntity
<>(
requestStr
,
requestHeaders
),
String
.
class
);
log
.
info
(
"uploadUserInfo url: {},response: {},cost: {} ms"
,
userInfoUrl
,
entity
.
getBody
(),
System
.
currentTimeMillis
()
-
startTime
);
T1CommonResponseDTO
result
=
JSON
.
parseObject
(
entity
.
getBody
(),
T1CommonResponseDTO
.
class
);
return
result
;
}
public
T1CommonResponseDTO
uploadT1File
(
T1FileReqDTO
file
)
{
if
(
StringUtils
.
isEmpty
(
phoPath
))
{
log
.
error
(
"ChinaMobileT1UploadServiceImpl uploadT1File failure, phoPath:{}, T1FileReqDTO:{}"
,
phoPath
,
file
);
return
T1CommonResponseDTO
.
createError
(
file
.
getRequestID
(),
"phoPath is empty, please check nacos!!!"
);
}
final
String
realPath
=
phoPath
+
file
.
getRequestID
();
return
upload
(
file
,
realPath
);
}
public
T1CommonResponseDTO
uploadT1FileByInstruction
(
T1FileReqDTO
file
)
{
if
(
StringUtils
.
isEmpty
(
phoPathByInstruction
))
{
log
.
error
(
"ChinaMobileT1UploadServiceImpl uploadT1File failure, phoPath:{}, T1FileReqDTO:{}"
,
phoPath
,
file
);
return
T1CommonResponseDTO
.
createError
(
file
.
getRequestID
(),
"phoPath is empty, please check nacos!!!"
);
}
final
String
realPath
=
phoPathByInstruction
+
file
.
getRequestID
();
return
upload
(
file
,
realPath
);
}
private
final
T1CommonResponseDTO
upload
(
T1FileReqDTO
file
,
String
realPath
)
{
long
startTime
=
System
.
currentTimeMillis
();
String
uploadFile
=
null
;
try
{
uploadFile
=
sftpUtil
.
uploadFile
(
file
.
getEncryptFile
().
getPath
(),
realPath
);
}
catch
(
SftpException
|
JSchException
e
)
{
e
.
printStackTrace
();
return
T1CommonResponseDTO
.
createError
(
file
.
getRequestID
(),
"upload file failed, exception cause:"
+
e
.
getMessage
());
}
if
(
StringUtils
.
isEmpty
(
uploadFile
))
{
log
.
error
(
"ChinaMobileT1UploadServiceImpl uploadT1File failure, phoPath:{}, T1FileReqDTO:{}, uploadFile:{}"
,
phoPath
,
file
,
uploadFile
);
return
T1CommonResponseDTO
.
createError
(
file
.
getRequestID
(),
"ChinaMobileT1UploadServiceImpl uploadFile is empty"
);
}
log
.
info
(
"{} uploadFile:{} success. cost time:{} ms"
,
this
,
uploadFile
,
System
.
currentTimeMillis
()
-
startTime
);
return
T1CommonResponseDTO
.
createSuccess
(
file
.
getRequestID
());
}
public
T1CommonResponseDTO
uploadT1VehicleInfo
(
T1VehicleInfoReqDTO
vehicleInfoReqDTO
,
String
vin
)
{
final
String
vehicleInfo
=
getVehicleInfo
(
vin
);
//加密
final
String
encryptCarInfo
=
encryptCarInfo
(
vehicleInfo
);
vehicleInfoReqDTO
.
setEncryptCarInfo
(
encryptCarInfo
);
long
startTime
=
System
.
currentTimeMillis
();
vehicleInfoReqDTO
.
setAuth
(
getAuth
());
String
requestStrTmp
=
JSON
.
toJSONString
(
vehicleInfoReqDTO
);
JSONObject
jsonObject
=
JSON
.
parseObject
(
requestStrTmp
);
jsonObject
.
remove
(
"ServiceProvider"
);
final
String
requestStr
=
jsonObject
.
toJSONString
();
log
.
info
(
"uploadT1VehicleInfo url: {},request: {}"
,
vehicleInfoUrl
,
requestStr
);
HttpHeaders
requestHeaders
=
new
HttpHeaders
();
requestHeaders
.
setContentType
(
MediaType
.
APPLICATION_JSON_UTF8
);
ResponseEntity
<
String
>
entity
=
noBalanceRestTemplateRnrFp
.
exchange
(
vehicleInfoUrl
,
HttpMethod
.
POST
,
new
HttpEntity
<>(
requestStr
,
requestHeaders
),
String
.
class
);
log
.
info
(
"uploadT1VehicleInfo url: {},response: {},cost: {} ms"
,
vehicleInfoUrl
,
entity
.
getBody
(),
System
.
currentTimeMillis
()
-
startTime
);
T1CommonResponseDTO
result
=
JSON
.
parseObject
(
entity
.
getBody
(),
T1CommonResponseDTO
.
class
);
return
result
;
}
public
String
getCode
()
{
return
code
;
}
public
String
getT1UserInfoKey
()
{
return
t1UserInfoKey
;
}
public
String
getPlatformID
()
{
return
platformID
;
}
}
local-rnr-fp-server/src/main/java/com/cusc/nirvana/user/rnr/fp/service/impl/ChinaTelecomT1UploadServiceImpl.java
0 → 100644
View file @
015d4257
package
com.cusc.nirvana.user.rnr.fp.service.impl
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.cusc.nirvana.user.rnr.fp.dto.*
;
import
com.cusc.nirvana.user.rnr.fp.util.*
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Qualifier
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.core.io.FileSystemResource
;
import
org.springframework.http.*
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.LinkedMultiValueMap
;
import
org.springframework.util.MultiValueMap
;
import
org.springframework.web.client.RestTemplate
;
import
java.io.File
;
@Service
@Slf4j
public
class
ChinaTelecomT1UploadServiceImpl
extends
VehicleT1UploadServiceImpl
{
@Value
(
"${t1.chinaTelecom.url:}"
)
private
String
dateUrl
;
@Value
(
"${t1.chinaTelecom.platformID:}"
)
//由OneLink车联卡实名平台为各个车 企分配的标识
private
String
platformID
;
@Value
(
"${t1.chinaTelecom.code:}"
)
//工信部下发的车企编码,道路机动 车辆生产 企业编码
private
String
code
;
@Value
(
"${t1.chinaTelecom.t1UserInfoKey:}"
)
//开户信息的加密密钥由 OneLink 平台生成后,自动发送到指定邮箱。
private
String
t1UserInfoKey
=
"7faf0abf9e6c4aa0aa04eeccf3110e37"
;
@Autowired
@Qualifier
(
"noBalanceRestTemplateRnrFp"
)
RestTemplate
noBalanceRestTemplateRnrFp
;
public
File
encryptZipFile
(
String
zipFileName
,
String
folderPath
){
byte
[]
byteArr
=
ZipUtils
.
readByteFromFile
(
zipFileName
);
byte
[]
encodeByteArr
=
RnrDataSm4Util
.
encryptEcbPaddingBytes
(
t1UserInfoKey
,
byteArr
,
true
);
return
CuscFileUtils
.
byte2File
(
encodeByteArr
,
folderPath
+
".bin"
);
}
public
String
encrypt
(
T1UserInfoDTO
ret
)
{
return
RnrDataSm4Util
.
encryptEcbPadding
(
t1UserInfoKey
,
JSON
.
toJSONString
(
ret
),
true
,
null
);
}
private
final
T1AuthDTO
getAuth
()
{
final
T1AuthDTO
t1AuthDTO
=
new
T1AuthDTO
();
t1AuthDTO
.
setPlatformID
(
platformID
);
//平台标识+密码的SM3值,密码由 OneLink车联卡实名平台分配
String
signNature
=
platformID
+
t1UserInfoKey
;
t1AuthDTO
.
setSignNature
(
RnrDataSM3Utils
.
encode
(
signNature
));
return
t1AuthDTO
;
}
public
T1CommonResponseDTO
uploadT1UserInfo
(
T1UserInfoReqDTO
userInfo
)
{
long
startTime
=
System
.
currentTimeMillis
();
userInfo
.
setAuth
(
getAuth
());
String
url
=
dateUrl
+
"/data/upload/userInfo"
;
String
requestStrTmp
=
JSON
.
toJSONString
(
userInfo
);
JSONObject
jsonObject
=
JSON
.
parseObject
(
requestStrTmp
);
jsonObject
.
remove
(
"ServiceProvider"
);
final
String
requestStr
=
jsonObject
.
toJSONString
();
log
.
info
(
"uploadUserInfo url: {},request: {}"
,
url
,
requestStr
);
HttpHeaders
requestHeaders
=
new
HttpHeaders
();
requestHeaders
.
setContentType
(
MediaType
.
APPLICATION_JSON_UTF8
);
ResponseEntity
<
String
>
entity
=
noBalanceRestTemplateRnrFp
.
exchange
(
url
,
HttpMethod
.
POST
,
new
HttpEntity
<>(
requestStr
,
requestHeaders
),
String
.
class
);
log
.
info
(
"uploadUserInfo url: {},response: {},cost: {} ms"
,
url
,
entity
.
getBody
(),
System
.
currentTimeMillis
()
-
startTime
);
T1CommonResponseDTO
result
=
JSON
.
parseObject
(
entity
.
getBody
(),
T1CommonResponseDTO
.
class
);
return
result
;
}
public
T1CommonResponseDTO
uploadT1File
(
T1FileReqDTO
file
)
{
long
startTime
=
System
.
currentTimeMillis
();
String
url
=
dateUrl
+
"/file/upload/rnr"
;
log
.
info
(
"uploadT1File url: {},request: {}"
,
url
,
JSON
.
toJSONString
(
file
));
FileSystemResource
fileSystemResource
=
new
FileSystemResource
(
file
.
getEncryptFile
());
// headers参数
HttpHeaders
requestHeaders
=
new
HttpHeaders
();
// body体参数
MultiValueMap
<
String
,
Object
>
requestBody
=
new
LinkedMultiValueMap
<>();
// 设置header是文件上传
requestHeaders
.
setContentType
(
MediaType
.
MULTIPART_FORM_DATA
);
// 参数设置文件
requestBody
.
add
(
"RequestID"
,
file
.
getRequestID
());
requestBody
.
add
(
"Code"
,
file
.
getCode
());
requestBody
.
add
(
"EncryptFile"
,
fileSystemResource
);
requestBody
.
add
(
"FileMd5"
,
Md5CaculateUtil
.
getFileMD5
(
file
.
getEncryptFile
()));
requestBody
.
add
(
"ServiceProvider"
,
file
.
getServiceProvider
());
// 封装所有参数
HttpEntity
<
MultiValueMap
<
String
,
Object
>>
requestEntity
=
new
HttpEntity
<>(
requestBody
,
requestHeaders
);
ResponseEntity
<
String
>
entity
=
noBalanceRestTemplateRnrFp
.
exchange
(
url
,
HttpMethod
.
POST
,
requestEntity
,
String
.
class
);
log
.
info
(
"uploadT1File url: {},response: {},cost: {} ms"
,
url
,
entity
.
getBody
(),
System
.
currentTimeMillis
()
-
startTime
);
T1CommonResponseDTO
result
=
JSON
.
parseObject
(
entity
.
getBody
(),
T1CommonResponseDTO
.
class
);
return
result
;
}
public
T1CommonResponseDTO
uploadT1VehicleInfo
(
T1VehicleInfoReqDTO
vehicleInfoReqDTO
,
String
vin
)
{
String
url
=
dateUrl
+
"/data/upload/vehicleInfo"
;
final
String
vehicleInfo
=
getVehicleInfo
(
vin
);
//加密
final
String
encryptCarInfo
=
encryptCarInfo
(
vehicleInfo
);
vehicleInfoReqDTO
.
setEncryptCarInfo
(
encryptCarInfo
);
long
startTime
=
System
.
currentTimeMillis
();
vehicleInfoReqDTO
.
setAuth
(
getAuth
());
String
requestStrTmp
=
JSON
.
toJSONString
(
vehicleInfoReqDTO
);
JSONObject
jsonObject
=
JSON
.
parseObject
(
requestStrTmp
);
final
String
requestStr
=
jsonObject
.
toJSONString
();
log
.
info
(
"uploadT1VehicleInfo url: {},request: {}"
,
url
,
requestStr
);
HttpHeaders
requestHeaders
=
new
HttpHeaders
();
requestHeaders
.
setContentType
(
MediaType
.
APPLICATION_JSON_UTF8
);
ResponseEntity
<
String
>
entity
=
noBalanceRestTemplateRnrFp
.
exchange
(
url
,
HttpMethod
.
POST
,
new
HttpEntity
<>(
requestStr
,
requestHeaders
),
String
.
class
);
log
.
info
(
"uploadT1VehicleInfo url: {},response: {},cost: {} ms"
,
url
,
entity
.
getBody
(),
System
.
currentTimeMillis
()
-
startTime
);
T1CommonResponseDTO
result
=
JSON
.
parseObject
(
entity
.
getBody
(),
T1CommonResponseDTO
.
class
);
return
result
;
}
public
String
getCode
()
{
return
code
;
}
public
String
getT1UserInfoKey
()
{
return
t1UserInfoKey
;
}
public
String
getPlatformID
()
{
return
platformID
;
}
}
local-rnr-fp-server/src/main/java/com/cusc/nirvana/user/rnr/fp/service/impl/ChinaUnicomT1UploadServiceImpl.java
0 → 100644
View file @
015d4257
package
com.cusc.nirvana.user.rnr.fp.service.impl
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.cusc.nirvana.common.result.Response
;
import
com.cusc.nirvana.user.rnr.fp.dto.*
;
import
com.cusc.nirvana.user.rnr.fp.service.IT1UploadService
;
import
com.cusc.nirvana.user.rnr.fp.util.*
;
import
com.cusc.nirvana.user.rnr.mg.client.MgRnrRelationClient
;
import
com.cusc.nirvana.user.rnr.mg.dto.*
;
import
com.cusc.nirvana.user.util.CuscStringUtils
;
import
lombok.extern.slf4j.Slf4j
;
import
org.bouncycastle.jce.provider.BouncyCastleProvider
;
import
org.bouncycastle.pqc.math.linearalgebra.ByteUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Qualifier
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.core.io.FileSystemResource
;
import
org.springframework.http.*
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.LinkedMultiValueMap
;
import
org.springframework.util.MultiValueMap
;
import
org.springframework.util.StringUtils
;
import
org.springframework.web.client.RestTemplate
;
import
javax.crypto.Cipher
;
import
javax.crypto.NoSuchPaddingException
;
import
javax.crypto.spec.SecretKeySpec
;
import
java.io.File
;
import
java.nio.charset.StandardCharsets
;
import
java.security.InvalidKeyException
;
import
java.security.Key
;
import
java.security.NoSuchAlgorithmException
;
import
java.security.NoSuchProviderException
;
import
static
com
.
alibaba
.
nacos
.
client
.
utils
.
EnvUtil
.
LOGGER
;
@Service
@Slf4j
public
class
ChinaUnicomT1UploadServiceImpl
extends
VehicleT1UploadServiceImpl
{
@Value
(
"${t1.chinaUnicom.url:}"
)
private
String
dateUrl
;
@Value
(
"${t1.chinaUnicom.platformID:}"
)
//由OneLink车联卡实名平台为各个车 企分配的标识
private
String
platformID
=
"xxxx"
;
@Value
(
"${t1.chinaUnicom.code:}"
)
//工信部下发的车企编码,道路机动 车辆生产 企业编码
private
String
code
=
"xxxx"
;
@Value
(
"${t1.chinaUnicom.t1UserInfoKey:}"
)
//开户信息的加密密钥由 OneLink 平台生成后,自动发送到指定邮箱。
private
String
t1UserInfoKey
=
"7faf0abf9e6c4aa0aa04eeccf3110e37"
;
@Autowired
@Qualifier
(
"noBalanceRestTemplateRnrFp"
)
RestTemplate
noBalanceRestTemplateRnrFp
;
public
String
encrypt
(
T1UserInfoDTO
ret
)
{
return
RnrDataSm4Util
.
encryptEcbPadding
(
t1UserInfoKey
,
JSON
.
toJSONString
(
ret
),
true
,
null
);
}
public
File
encryptZipFile
(
String
zipFileName
,
String
folderPath
){
byte
[]
byteArr
=
ZipUtils
.
readByteFromFile
(
zipFileName
);
byte
[]
encodeByteArr
=
RnrDataSm4Util
.
encryptEcbPaddingBytes
(
t1UserInfoKey
,
byteArr
,
true
);
return
CuscFileUtils
.
byte2File
(
encodeByteArr
,
folderPath
+
".bin"
);
}
private
final
T1AuthDTO
getAuth
(){
final
T1AuthDTO
t1AuthDTO
=
new
T1AuthDTO
();
t1AuthDTO
.
setPlatformID
(
platformID
);
//平台标识+密码的SM3值,密码由 OneLink车联卡实名平台分配
String
signNature
=
platformID
+
t1UserInfoKey
;
t1AuthDTO
.
setSignNature
(
RnrDataSM3Utils
.
encode
(
signNature
));
return
t1AuthDTO
;
}
public
T1CommonResponseDTO
uploadT1UserInfo
(
T1UserInfoReqDTO
userInfo
)
{
long
startTime
=
System
.
currentTimeMillis
();
userInfo
.
setAuth
(
getAuth
());
String
url
=
dateUrl
+
"/data/upload/userInfo"
;
String
requestStrTmp
=
JSON
.
toJSONString
(
userInfo
);
JSONObject
jsonObject
=
JSON
.
parseObject
(
requestStrTmp
);
final
String
requestStr
=
jsonObject
.
toJSONString
();
log
.
info
(
"uploadUserInfo url: {},request: {}"
,
url
,
requestStr
);
HttpHeaders
requestHeaders
=
new
HttpHeaders
();
requestHeaders
.
setContentType
(
MediaType
.
APPLICATION_JSON_UTF8
);
ResponseEntity
<
String
>
entity
=
noBalanceRestTemplateRnrFp
.
exchange
(
url
,
HttpMethod
.
POST
,
new
HttpEntity
<>(
requestStr
,
requestHeaders
),
String
.
class
);
log
.
info
(
"uploadUserInfo url: {},response: {},cost: {} ms"
,
url
,
entity
.
getBody
(),
System
.
currentTimeMillis
()
-
startTime
);
T1CommonResponseDTO
result
=
JSON
.
parseObject
(
entity
.
getBody
(),
T1CommonResponseDTO
.
class
);
return
result
;
}
public
T1CommonResponseDTO
uploadT1File
(
T1FileReqDTO
file
)
{
long
startTime
=
System
.
currentTimeMillis
();
String
url
=
dateUrl
+
"/file/upload/rnr"
;
log
.
info
(
"uploadT1File url: {},request: {}"
,
url
,
JSON
.
toJSONString
(
file
));
FileSystemResource
fileSystemResource
=
new
FileSystemResource
(
file
.
getEncryptFile
());
// headers参数
HttpHeaders
requestHeaders
=
new
HttpHeaders
();
// body体参数
MultiValueMap
<
String
,
Object
>
requestBody
=
new
LinkedMultiValueMap
<>();
// 设置header是文件上传
requestHeaders
.
setContentType
(
MediaType
.
MULTIPART_FORM_DATA
);
// 参数设置文件
requestBody
.
add
(
"RequestID"
,
file
.
getRequestID
());
requestBody
.
add
(
"Code"
,
file
.
getCode
());
requestBody
.
add
(
"EncryptFile"
,
fileSystemResource
);
requestBody
.
add
(
"FileMd5"
,
Md5CaculateUtil
.
getFileMD5
(
file
.
getEncryptFile
()));
requestBody
.
add
(
"ServiceProvider"
,
file
.
getServiceProvider
());
// 封装所有参数
HttpEntity
<
MultiValueMap
<
String
,
Object
>>
requestEntity
=
new
HttpEntity
<>(
requestBody
,
requestHeaders
);
ResponseEntity
<
String
>
entity
=
noBalanceRestTemplateRnrFp
.
exchange
(
url
,
HttpMethod
.
POST
,
requestEntity
,
String
.
class
);
log
.
info
(
"uploadT1File url: {},response: {},cost: {} ms"
,
url
,
entity
.
getBody
(),
System
.
currentTimeMillis
()
-
startTime
);
T1CommonResponseDTO
result
=
JSON
.
parseObject
(
entity
.
getBody
(),
T1CommonResponseDTO
.
class
);
return
result
;
}
public
T1CommonResponseDTO
uploadT1VehicleInfo
(
T1VehicleInfoReqDTO
vehicleInfoReqDTO
,
String
vin
)
{
///data/upload/vehicleInfo 地址需要确认下
String
url
=
dateUrl
+
"/data/upload/vehicleInfo"
;
final
String
vehicleInfo
=
getVehicleInfo
(
vin
);
//加密
final
String
encryptCarInfo
=
encryptCarInfo
(
vehicleInfo
);
vehicleInfoReqDTO
.
setEncryptCarInfo
(
encryptCarInfo
);
long
startTime
=
System
.
currentTimeMillis
();
vehicleInfoReqDTO
.
setAuth
(
getAuth
());
String
requestStrTmp
=
JSON
.
toJSONString
(
vehicleInfoReqDTO
);
JSONObject
jsonObject
=
JSON
.
parseObject
(
requestStrTmp
);
final
String
requestStr
=
jsonObject
.
toJSONString
();
log
.
info
(
"uploadT1VehicleInfo url: {},request: {}"
,
url
,
requestStr
);
HttpHeaders
requestHeaders
=
new
HttpHeaders
();
requestHeaders
.
setContentType
(
MediaType
.
APPLICATION_JSON_UTF8
);
ResponseEntity
<
String
>
entity
=
noBalanceRestTemplateRnrFp
.
exchange
(
url
,
HttpMethod
.
POST
,
new
HttpEntity
<>(
requestStr
,
requestHeaders
),
String
.
class
);
log
.
info
(
"uploadT1VehicleInfo url: {},response: {},cost: {} ms"
,
url
,
entity
.
getBody
(),
System
.
currentTimeMillis
()
-
startTime
);
T1CommonResponseDTO
result
=
JSON
.
parseObject
(
entity
.
getBody
(),
T1CommonResponseDTO
.
class
);
return
result
;
}
public
String
getCode
()
{
return
code
;
}
public
String
getT1UserInfoKey
()
{
return
t1UserInfoKey
;
}
public
String
getPlatformID
()
{
return
platformID
;
}
}
local-rnr-fp-server/src/main/java/com/cusc/nirvana/user/rnr/fp/service/impl/CmccT1UploadServiceImpl.java
0 → 100644
View file @
015d4257
package
com.cusc.nirvana.user.rnr.fp.service.impl
;
import
com.cusc.nirvana.common.result.Response
;
import
com.cusc.nirvana.user.rnr.fp.common.util.CMCCSftpUtil
;
import
com.cusc.nirvana.user.rnr.fp.dto.T1CommonResponseDTO
;
import
com.cusc.nirvana.user.rnr.fp.dto.T1FileReqDTO
;
import
com.cusc.nirvana.user.rnr.fp.service.CmccT1UploadService
;
import
com.jcraft.jsch.JSchException
;
import
com.jcraft.jsch.SftpException
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.StringUtils
;
/**
* @className: CtccT1UploadServiceImpl
* @description: 移动T1上报指令
* @author: jk
* @date: 2022/7/26 14:36
* @version: 1.0
**/
@Service
@Slf4j
public
class
CmccT1UploadServiceImpl
implements
CmccT1UploadService
{
//ip地址
@Value
(
"${t1.CMCC.host:}"
)
private
String
host
;
//端口号
@Value
(
"${t1.CMCC.port:}"
)
private
Integer
port
;
//路径
@Value
(
"${t1.CMCC.phoPath:}"
)
private
String
phoPath
;
//用户名
@Value
(
"${t1.CMCC.username:}"
)
private
String
username
;
//密码
@Value
(
"${t1.CMCC.password:}"
)
private
String
password
;
//session链接超时时间
@Value
(
"${t1.CMCC.sessionConnectTimeout:15000}"
)
private
Integer
sessionConnectTimeout
=
15000
;
//channel链接超时时间
@Value
(
"${t1.CMCC:15000}"
)
private
Integer
channelConnectedTimeout
=
15000
;
@Override
public
Response
upload
(
T1FileReqDTO
file
)
{
CMCCSftpUtil
cmccSftpUtil
=
new
CMCCSftpUtil
(
host
,
port
,
phoPath
,
username
,
password
,
sessionConnectTimeout
,
channelConnectedTimeout
);
String
uploadFile
=
null
;
try
{
uploadFile
=
cmccSftpUtil
.
uploadFile
(
file
);
}
catch
(
SftpException
|
JSchException
e
)
{
e
.
printStackTrace
();
return
Response
.
createError
(
"CmccUpload file failed, exception cause:"
+
e
.
getMessage
(),
file
.
getRequestID
());
}
if
(
StringUtils
.
isEmpty
(
uploadFile
)){
return
Response
.
createError
(
file
.
getRequestID
(),
"指令下发失败"
);
}
return
Response
.
createSuccess
(
uploadFile
,
file
.
getRequestID
());
}
}
local-rnr-fp-server/src/main/java/com/cusc/nirvana/user/rnr/fp/service/impl/CtccT1UploadServiceImpl.java
0 → 100644
View file @
015d4257
package
com.cusc.nirvana.user.rnr.fp.service.impl
;
import
com.cusc.nirvana.common.result.Response
;
import
com.cusc.nirvana.user.rnr.fp.common.util.CTCCSftpUtil
;
import
com.cusc.nirvana.user.rnr.fp.dto.T1FileReqDTO
;
import
com.cusc.nirvana.user.rnr.fp.service.CtccT1UploadService
;
import
com.jcraft.jsch.JSchException
;
import
com.jcraft.jsch.SftpException
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.StringUtils
;
/**
* @className: CtccT1UploadServiceImpl
* @description: 电信T1上报指令
* @author: jk
* @date: 2022/7/26 14:36
* @version: 1.0
**/
@Service
@Slf4j
public
class
CtccT1UploadServiceImpl
implements
CtccT1UploadService
{
//ip地址
@Value
(
"${t1.CTCC.host:}"
)
private
String
host
;
//端口号
@Value
(
"${t1.CTCC.port:}"
)
private
Integer
port
;
//路径
@Value
(
"${t1.CTCC.phoPath:}"
)
private
String
phoPath
;
//用户名
@Value
(
"${t1.CTCC.username:}"
)
private
String
username
;
//密码
@Value
(
"${t1.CTCC.password:}"
)
private
String
password
;
//session链接超时时间
@Value
(
"${t1.CTCC.sessionConnectTimeout:15000}"
)
private
Integer
sessionConnectTimeout
=
15000
;
//channel链接超时时间
@Value
(
"${t1.CTCC:15000}"
)
private
Integer
channelConnectedTimeout
=
15000
;
@Override
public
Response
upload
(
T1FileReqDTO
file
)
{
CTCCSftpUtil
ctccSftpUtil
=
new
CTCCSftpUtil
(
host
,
port
,
phoPath
,
username
,
password
,
sessionConnectTimeout
,
channelConnectedTimeout
);
String
uploadFile
=
null
;
try
{
uploadFile
=
ctccSftpUtil
.
uploadFile
(
file
.
getEncryptFile
().
getPath
());
}
catch
(
SftpException
|
JSchException
e
)
{
e
.
printStackTrace
();
return
Response
.
createError
(
"CmccUpload file failed, exception cause:"
+
e
.
getMessage
(),
file
.
getRequestID
());
}
if
(
StringUtils
.
isEmpty
(
uploadFile
)){
return
Response
.
createError
(
"指令下发失败"
,
file
.
getRequestID
());
}
return
Response
.
createSuccess
(
uploadFile
,
file
.
getRequestID
());
}
}
local-rnr-fp-server/src/main/java/com/cusc/nirvana/user/rnr/fp/service/impl/CuFlowServiceImpl.java
0 → 100644
View file @
015d4257
package
com.cusc.nirvana.user.rnr.fp.service.impl
;
import
com.alibaba.fastjson.JSON
;
import
com.cusc.nirvana.common.encrypt.sign.HMAC
;
import
com.cusc.nirvana.common.loader.StringUtils
;
import
com.cusc.nirvana.common.result.Response
;
import
com.cusc.nirvana.user.rnr.fp.common.FpLogOutputJsonSerializeFilter
;
import
com.cusc.nirvana.user.rnr.fp.config.SimVehicleConfig
;
import
com.cusc.nirvana.user.rnr.fp.converter.CuFlowConverter
;
import
com.cusc.nirvana.user.rnr.fp.dto.FlowDernrRequestDTO
;
import
com.cusc.nirvana.user.rnr.fp.dto.FlowEnterpriseInfoDTO
;
import
com.cusc.nirvana.user.rnr.fp.dto.FlowExtsDTO
;
import
com.cusc.nirvana.user.rnr.fp.dto.FlowPersonalInfoDTO
;
import
com.cusc.nirvana.user.rnr.fp.dto.FlowRnrInfoDTO
;
import
com.cusc.nirvana.user.rnr.fp.dto.FlowRnrRequestDTO
;
import
com.cusc.nirvana.user.rnr.fp.dto.FlowSwapDeviceRequestDTO
;
import
com.cusc.nirvana.user.rnr.fp.dto.FlowVehicleInfoDTO
;
import
com.cusc.nirvana.user.rnr.fp.dto.FpT1UploadStatusDTO
;
import
com.cusc.nirvana.user.rnr.fp.service.ICuFlowService
;
import
com.cusc.nirvana.user.rnr.fp.service.IFpT1UploadStatusService
;
import
com.cusc.nirvana.user.rnr.fp.util.RnrFpRestTemplateUtils
;
import
com.cusc.nirvana.user.rnr.mg.client.MgRnrCompanyInfoClient
;
import
com.cusc.nirvana.user.rnr.mg.client.MgRnrInfoClient
;
import
com.cusc.nirvana.user.rnr.mg.client.OrgBusinessTagClient
;
import
com.cusc.nirvana.user.rnr.mg.client.OrgSimRelClient
;
import
com.cusc.nirvana.user.rnr.mg.client.RnrOrderClient
;
import
com.cusc.nirvana.user.rnr.mg.constants.CertTypeEnum
;
import
com.cusc.nirvana.user.rnr.mg.constants.CommonYesOrNoEnum
;
import
com.cusc.nirvana.user.rnr.mg.constants.CompanyTypeEnum
;
import
com.cusc.nirvana.user.rnr.mg.constants.RnrBizzTypeEnum
;
import
com.cusc.nirvana.user.rnr.mg.constants.SystemCodeEnum
;
import
com.cusc.nirvana.user.rnr.mg.dto.MgCardNoticeDTO
;
import
com.cusc.nirvana.user.rnr.mg.dto.MgRnrCompanyInfoDTO
;
import
com.cusc.nirvana.user.rnr.mg.dto.MgRnrInfoDTO
;
import
com.cusc.nirvana.user.rnr.mg.dto.OrgBusinessTagDTO
;
import
com.cusc.nirvana.user.rnr.mg.dto.OrgSimRelDTO
;
import
com.cusc.nirvana.user.rnr.mg.dto.RnrOrderDTO
;
import
com.cusc.nirvana.user.rnr.project.constant.SignConstants
;
import
com.cusc.nirvana.user.util.CuscStringUtils
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Qualifier
;
import
org.springframework.http.HttpEntity
;
import
org.springframework.http.HttpHeaders
;
import
org.springframework.http.MediaType
;
import
org.springframework.stereotype.Service
;
import
org.springframework.web.client.RestTemplate
;
import
javax.annotation.Resource
;
import
java.util.Arrays
;
import
java.util.Date
;
/**
* Description:联通切流service
* <br />
* CreateDate 2022-07-28 11:12:21
*
* @author yuyi
**/
@Service
@Slf4j
public
class
CuFlowServiceImpl
implements
ICuFlowService
{
@Resource
private
IFpT1UploadStatusService
fpT1UploadStatusService
;
@Autowired
@Qualifier
(
"noBalanceRestTemplateRnrFp"
)
private
RestTemplate
noBalanceRestTemplateRnrFp
;
@Autowired
private
SimVehicleConfig
simVehicleConfig
;
@Autowired
private
OrgSimRelClient
orgSimRelClient
;
@Autowired
private
OrgBusinessTagClient
orgBusinessTagClient
;
@Autowired
private
RnrOrderClient
orderClient
;
@Autowired
private
MgRnrInfoClient
rnrInfoClient
;
@Autowired
private
MgRnrCompanyInfoClient
rnrCompanyInfoClient
;
/**
* Description: 切流事件
* <br />
* CreateDate 2022-07-27 20:35:00
*
* @author yuyi
**/
@Override
public
Response
switchNetwork
(
MgCardNoticeDTO
bean
)
{
if
(
RnrBizzTypeEnum
.
INFO_CHANGE
.
getCode
().
equals
(
bean
.
getRnrBizzType
())
||
bean
.
getResultCode
()
!=
3
)
{
log
.
info
(
"switchNetwork 不用处理 , param : {}"
,
JSON
.
toJSONString
(
bean
,
new
FpLogOutputJsonSerializeFilter
()));
return
Response
.
createSuccess
(
"无需处理"
);
}
FpT1UploadStatusDTO
t1UploadStatus
=
new
FpT1UploadStatusDTO
();
t1UploadStatus
.
setIccid
(
bean
.
getIccid
());
t1UploadStatus
.
setOrderId
(
bean
.
getOrderId
());
t1UploadStatus
.
setTenantNo
(
bean
.
getTenantNo
());
t1UploadStatus
=
fpT1UploadStatusService
.
insertOrResetFlow
(
t1UploadStatus
);
log
.
info
(
"switchNetwork t1UploadStatus : {}"
,
JSON
.
toJSONString
(
t1UploadStatus
));
Response
ret
;
try
{
//实名
if
(
RnrBizzTypeEnum
.
Bind
.
getCode
().
equals
(
bean
.
getRnrBizzType
()))
{
ret
=
rnr
(
bean
);
}
else
if
(
RnrBizzTypeEnum
.
Unbound
.
getCode
().
equals
(
bean
.
getRnrBizzType
()))
{
//解绑
ret
=
dernr
(
bean
);
}
else
if
(
RnrBizzTypeEnum
.
ChangeBinding
.
getCode
().
equals
(
bean
.
getRnrBizzType
()))
{
//换件
ret
=
swapDevice
(
bean
);
}
else
{
ret
=
Response
.
createSuccess
(
"未知的业务类型"
);
}
if
(!
ret
.
isSuccess
())
{
log
.
warn
(
"switchNetwork请求事件服务未正常返回,request:{},response:{}"
,
JSON
.
toJSONString
(
bean
),
JSON
.
toJSONString
(
ret
));
//防止通知模块重试
ret
=
Response
.
createSuccess
(
ret
.
getMsg
());
}
FpT1UploadStatusDTO
fpT1UploadStatusDTO
=
new
FpT1UploadStatusDTO
();
fpT1UploadStatusDTO
.
setUuid
(
t1UploadStatus
.
getUuid
());
fpT1UploadStatusDTO
.
setFlowStatus
(
1
);
fpT1UploadStatusDTO
.
setFlowStatusResp
(
JSON
.
toJSONString
(
ret
));
fpT1UploadStatusService
.
update
(
fpT1UploadStatusDTO
);
}
catch
(
Exception
e
)
{
log
.
error
(
"switchNetwork error : "
+
JSON
.
toJSONString
(
bean
),
e
);
ret
=
Response
.
createError
(
"系统异常"
);
}
return
ret
;
}
@Override
public
Response
rnr
(
MgCardNoticeDTO
bean
)
{
//通过iccid查询卡信息
Response
<
OrgSimRelDTO
>
simResp
=
orgSimRelClient
.
getByIccid
(
bean
.
getIccid
());
if
(!
simResp
.
isSuccess
())
{
return
simResp
;
}
OrgSimRelDTO
simInfo
=
simResp
.
getData
();
if
(
simInfo
==
null
)
{
return
Response
.
createError
(
"ICCID["
+
bean
.
getIccid
()
+
"]查询卡信息为空"
);
}
//通过工单查询自然人信息
RnrOrderDTO
orderDTO
=
new
RnrOrderDTO
();
orderDTO
.
setUuid
(
bean
.
getOrderId
());
orderDTO
.
setTenantNo
(
bean
.
getTenantNo
());
Response
<
RnrOrderDTO
>
orderResp
=
orderClient
.
getByUuid
(
orderDTO
);
if
(!
orderResp
.
isSuccess
()
||
orderResp
.
getData
()
==
null
)
{
log
.
warn
(
"rnr 查询工单信息失败 : {}"
,
JSON
.
toJSONString
(
orderDTO
));
return
Response
.
createError
(
"查询工单信息失败或未查询到工单信息"
);
}
orderDTO
=
orderResp
.
getData
();
//通过实名id查询实名信息
MgRnrInfoDTO
rnrInfo
=
new
MgRnrInfoDTO
();
rnrInfo
.
setUuid
(
orderDTO
.
getRnrId
());
rnrInfo
.
setTenantNo
(
orderDTO
.
getTenantNo
());
Response
<
MgRnrInfoDTO
>
rnrInfoResp
=
rnrInfoClient
.
getByUuid
(
rnrInfo
);
if
(!
rnrInfoResp
.
isSuccess
()
||
rnrInfoResp
.
getData
()
==
null
)
{
log
.
warn
(
"rnr 查询实名信息失败 : {}"
,
JSON
.
toJSONString
(
rnrInfoResp
));
return
Response
.
createError
(
"查询实名信息失败或未找到实名信息"
);
}
rnrInfo
=
rnrInfoResp
.
getData
();
MgRnrCompanyInfoDTO
companyInfo
=
null
;
if
(
CommonYesOrNoEnum
.
YES
.
getCode
()
==
rnrInfo
.
getIsCompany
().
intValue
())
{
//通过实名id查询企业信息
companyInfo
=
new
MgRnrCompanyInfoDTO
();
companyInfo
.
setRnrId
(
rnrInfo
.
getUuid
());
companyInfo
.
setTenantNo
(
rnrInfo
.
getTenantNo
());
Response
<
MgRnrCompanyInfoDTO
>
companyInfoResp
=
rnrCompanyInfoClient
.
getByRnrid
(
companyInfo
);
if
(!
companyInfoResp
.
isSuccess
()
||
companyInfoResp
.
getData
()
==
null
)
{
log
.
warn
(
"rnr 查询实名企业信息失败 : {}"
,
JSON
.
toJSONString
(
companyInfoResp
));
return
Response
.
createError
(
"查询实名企业信息失败或未找到实名企业信息"
);
}
companyInfo
=
companyInfoResp
.
getData
();
}
FlowRnrRequestDTO
rnrReq
=
new
FlowRnrRequestDTO
();
FlowVehicleInfoDTO
vehicleInfoDTO
=
CuFlowConverter
.
INSTANCE
.
vehicleFromOrgSim
(
simInfo
);
FlowRnrInfoDTO
rnrInfoDTO
=
CuFlowConverter
.
INSTANCE
.
rnrFromCardNotice
(
bean
,
vehicleInfoDTO
);
rnrReq
.
setRnrInfos
(
Arrays
.
asList
(
rnrInfoDTO
));
rnrReq
.
setBizType
(
transformBizType
(
rnrInfo
,
companyInfo
));
rnrReq
.
setExts
(
buildFlowExts
(
1
,
simInfo
.
getTagUuid
(),
rnrInfo
,
companyInfo
));
return
rnrRequest
(
rnrReq
);
}
@Override
public
Response
dernr
(
MgCardNoticeDTO
bean
)
{
//通过iccid查询卡信息
Response
<
OrgSimRelDTO
>
simResp
=
orgSimRelClient
.
getByIccid
(
bean
.
getIccid
());
if
(!
simResp
.
isSuccess
())
{
return
simResp
;
}
OrgSimRelDTO
simInfo
=
simResp
.
getData
();
if
(
simInfo
==
null
)
{
return
Response
.
createError
(
"ICCID["
+
bean
.
getIccid
()
+
"]查询卡信息为空"
);
}
//通过工单查询自然人信息
RnrOrderDTO
orderDTO
=
new
RnrOrderDTO
();
orderDTO
.
setUuid
(
bean
.
getOrderId
());
orderDTO
.
setTenantNo
(
bean
.
getTenantNo
());
Response
<
RnrOrderDTO
>
orderResp
=
orderClient
.
getByUuid
(
orderDTO
);
if
(!
orderResp
.
isSuccess
()
||
orderResp
.
getData
()
==
null
)
{
log
.
warn
(
"rnr 查询工单信息失败 : {}"
,
JSON
.
toJSONString
(
orderDTO
));
return
Response
.
createError
(
"查询工单信息失败或未查询到工单信息"
);
}
orderDTO
=
orderResp
.
getData
();
//通过实名id查询实名信息
MgRnrInfoDTO
rnrInfo
=
new
MgRnrInfoDTO
();
rnrInfo
.
setUuid
(
orderDTO
.
getRnrId
());
rnrInfo
.
setTenantNo
(
orderDTO
.
getTenantNo
());
Response
<
MgRnrInfoDTO
>
rnrInfoResp
=
rnrInfoClient
.
getByUuid
(
rnrInfo
);
if
(!
rnrInfoResp
.
isSuccess
()
||
rnrInfoResp
.
getData
()
==
null
)
{
log
.
warn
(
"rnr 查询实名信息失败 : {}"
,
JSON
.
toJSONString
(
rnrInfoResp
));
return
Response
.
createError
(
"查询实名信息失败或未找到实名信息"
);
}
rnrInfo
=
rnrInfoResp
.
getData
();
FlowDernrRequestDTO
dernrReq
=
new
FlowDernrRequestDTO
();
FlowVehicleInfoDTO
vehicleInfoDTO
=
CuFlowConverter
.
INSTANCE
.
vehicleFromOrgSim
(
simInfo
);
FlowRnrInfoDTO
rnrInfoDTO
=
CuFlowConverter
.
INSTANCE
.
rnrFromCardNotice
(
bean
,
vehicleInfoDTO
);
dernrReq
.
setRnrInfos
(
Arrays
.
asList
(
rnrInfoDTO
));
dernrReq
.
setExts
(
buildFlowExts
(
2
,
simInfo
.
getTagUuid
(),
rnrInfo
,
null
));
return
dernrRequest
(
dernrReq
);
}
@Override
public
Response
swapDevice
(
MgCardNoticeDTO
bean
)
{
//通过iccid查询卡信息
Response
<
OrgSimRelDTO
>
simResp
=
orgSimRelClient
.
getByIccid
(
bean
.
getIccid
());
if
(!
simResp
.
isSuccess
())
{
return
simResp
;
}
OrgSimRelDTO
simInfo
=
simResp
.
getData
();
if
(
simInfo
==
null
)
{
return
Response
.
createError
(
"ICCID["
+
bean
.
getIccid
()
+
"]查询卡信息为空"
);
}
//通过工单查询自然人信息
RnrOrderDTO
orderDTO
=
new
RnrOrderDTO
();
orderDTO
.
setUuid
(
bean
.
getOrderId
());
orderDTO
.
setTenantNo
(
bean
.
getTenantNo
());
Response
<
RnrOrderDTO
>
orderResp
=
orderClient
.
getByUuid
(
orderDTO
);
if
(!
orderResp
.
isSuccess
()
||
orderResp
.
getData
()
==
null
)
{
log
.
warn
(
"rnr 查询工单信息失败 : {}"
,
JSON
.
toJSONString
(
orderDTO
));
return
Response
.
createError
(
"查询工单信息失败或未查询到工单信息"
);
}
orderDTO
=
orderResp
.
getData
();
//通过实名id查询实名信息
MgRnrInfoDTO
rnrInfo
=
new
MgRnrInfoDTO
();
rnrInfo
.
setUuid
(
orderDTO
.
getRnrId
());
rnrInfo
.
setTenantNo
(
orderDTO
.
getTenantNo
());
Response
<
MgRnrInfoDTO
>
rnrInfoResp
=
rnrInfoClient
.
getByUuid
(
rnrInfo
);
if
(!
rnrInfoResp
.
isSuccess
()
||
rnrInfoResp
.
getData
()
==
null
)
{
log
.
warn
(
"rnr 查询实名信息失败 : {}"
,
JSON
.
toJSONString
(
rnrInfoResp
));
return
Response
.
createError
(
"查询实名信息失败或未找到实名信息"
);
}
rnrInfo
=
rnrInfoResp
.
getData
();
FlowDernrRequestDTO
dernrReq
=
new
FlowDernrRequestDTO
();
FlowVehicleInfoDTO
vehicleInfoDTO
=
CuFlowConverter
.
INSTANCE
.
vehicleFromOrgSim
(
simInfo
);
FlowRnrInfoDTO
rnrInfoDTO
=
CuFlowConverter
.
INSTANCE
.
rnrFromCardNotice
(
bean
,
vehicleInfoDTO
);
dernrReq
.
setRnrInfos
(
Arrays
.
asList
(
rnrInfoDTO
));
dernrReq
.
setExts
(
buildFlowExts
(
2
,
simInfo
.
getTagUuid
(),
rnrInfo
,
null
));
FlowSwapDeviceRequestDTO
swapDeviceReq
=
new
FlowSwapDeviceRequestDTO
();
swapDeviceReq
.
setVin
(
bean
.
getVin
());
swapDeviceReq
.
setOldIccid
(
bean
.
getOldIccid
());
swapDeviceReq
.
setOldRnrStatus
(
0
);
swapDeviceReq
.
setNewIccid
(
bean
.
getIccid
());
swapDeviceReq
.
setNewRnrStatus
(
1
);
swapDeviceReq
.
setExts
(
buildFlowExts
(
3
,
simInfo
.
getTagUuid
(),
rnrInfo
,
null
));
return
swapDeviceRequest
(
swapDeviceReq
);
}
//------------------------------私有方法区域--------------------
/**
* Description: 实名事件请求
* <br />
* CreateDate 2022-07-28 16:25:02
*
* @author yuyi
**/
private
Response
rnrRequest
(
FlowRnrRequestDTO
rnrReq
)
{
HttpEntity
httpEntity
=
new
HttpEntity
(
rnrReq
,
headers
());
try
{
String
url
=
simVehicleConfig
.
getUrl
()
+
"/notify/rnr"
;
return
RnrFpRestTemplateUtils
.
postOpenApiForObject
(
noBalanceRestTemplateRnrFp
,
url
,
httpEntity
,
Response
.
class
);
}
catch
(
Exception
e
)
{
log
.
error
(
"rnrRequest error : "
,
e
);
return
Response
.
createError
(
"系统异常"
);
}
}
/**
* Description: 解绑事件请求
* <br />
* CreateDate 2022-07-28 16:25:02
*
* @author yuyi
**/
private
Response
dernrRequest
(
FlowDernrRequestDTO
dernrReq
)
{
HttpEntity
httpEntity
=
new
HttpEntity
(
dernrReq
,
headers
());
try
{
String
url
=
simVehicleConfig
.
getUrl
()
+
"/notify/dernr"
;
return
RnrFpRestTemplateUtils
.
postOpenApiForObject
(
noBalanceRestTemplateRnrFp
,
url
,
httpEntity
,
Response
.
class
);
}
catch
(
Exception
e
)
{
log
.
error
(
"dernrRequest error : "
,
e
);
return
Response
.
createError
(
"系统异常"
);
}
}
/**
* Description: 换件事件请求
* <br />
* CreateDate 2022-07-28 16:25:02
*
* @author yuyi
**/
private
Response
swapDeviceRequest
(
FlowSwapDeviceRequestDTO
bean
)
{
HttpEntity
httpEntity
=
new
HttpEntity
(
bean
,
headers
());
try
{
String
url
=
simVehicleConfig
.
getUrl
()
+
"/notify/swap-device"
;
return
RnrFpRestTemplateUtils
.
postOpenApiForObject
(
noBalanceRestTemplateRnrFp
,
url
,
httpEntity
,
Response
.
class
);
}
catch
(
Exception
e
)
{
log
.
error
(
"swapDeviceRequest error : "
,
e
);
return
Response
.
createError
(
"系统异常"
);
}
}
/**
* 生成请求头
*
* @return
*/
private
HttpHeaders
headers
()
{
HttpHeaders
httpHeaders
=
new
HttpHeaders
();
httpHeaders
.
add
(
SignConstants
.
APP_ID
,
simVehicleConfig
.
getAppId
());
httpHeaders
.
add
(
SignConstants
.
NONCE_STR
,
CuscStringUtils
.
generateUuid
());
httpHeaders
.
add
(
SignConstants
.
TIMESTAMP
,
String
.
valueOf
(
new
Date
().
getTime
()));
httpHeaders
.
add
(
SignConstants
.
VERSION
,
simVehicleConfig
.
getVersion
());
StringBuilder
sb
=
new
StringBuilder
();
sb
.
append
(
SignConstants
.
APP_ID
+
simVehicleConfig
.
getAppId
());
sb
.
append
(
SignConstants
.
NONCE_STR
+
httpHeaders
.
get
(
SignConstants
.
NONCE_STR
).
get
(
0
));
sb
.
append
(
SignConstants
.
TIMESTAMP
+
httpHeaders
.
get
(
SignConstants
.
TIMESTAMP
).
get
(
0
));
sb
.
append
(
SignConstants
.
VERSION
+
simVehicleConfig
.
getVersion
());
String
scret
=
HMAC
.
sign
(
sb
.
toString
(),
simVehicleConfig
.
getAppScret
(),
HMAC
.
Type
.
HmacSHA256
);
httpHeaders
.
add
(
SignConstants
.
SIGN
,
scret
);
httpHeaders
.
setContentType
(
MediaType
.
parseMediaType
(
"application/json; charset=UTF-8"
));
return
httpHeaders
;
}
/**
* Description: 构建事件服务的扩展属性
* eventType : 1 实名 2 解绑 3换件
* <br />
* CreateDate 2022-07-28 22:05:11
*
* @author yuyi
**/
private
FlowExtsDTO
buildFlowExts
(
int
eventType
,
String
tagUuid
,
MgRnrInfoDTO
rnrInfo
,
MgRnrCompanyInfoDTO
companyInfo
)
{
FlowExtsDTO
ret
=
new
FlowExtsDTO
();
if
(
StringUtils
.
isNotBlank
(
tagUuid
))
{
//通过tagid查询tagcode
OrgBusinessTagDTO
obt
=
new
OrgBusinessTagDTO
();
obt
.
setTenantNo
(
rnrInfo
.
getTenantNo
());
obt
.
setTagCode
(
tagUuid
);
Response
<
OrgBusinessTagDTO
>
orgBusinessTagDTOResp
=
orgBusinessTagClient
.
getByTagCode
(
obt
);
if
(
orgBusinessTagDTOResp
.
isSuccess
()
&&
orgBusinessTagDTOResp
.
getData
()
!=
null
)
{
if
(
SystemCodeEnum
.
OLD_RNR
.
getCode
()
==
orgBusinessTagDTOResp
.
getData
().
getSystemCode
())
{
ret
.
setBrandId
(
orgBusinessTagDTOResp
.
getData
().
getTagCode
());
}
else
{
ret
.
setAbilityUserId
(
orgBusinessTagDTOResp
.
getData
().
getTagCode
());
}
}
}
if
(
eventType
==
3
)
{
//换件
return
ret
;
}
ret
.
setPersonalInfo
(
personalFromMgRnrInfo
(
rnrInfo
));
if
(
eventType
==
1
)
{
//实名时增加企业信息
ret
.
setEnterpriseInfo
(
enterpriseFromCompanyInfo
(
companyInfo
));
}
return
ret
;
}
/**
* Description: 业务类型转换
* <br />
* CreateDate 2022-07-29 19:41:50
*
* @author yuyi
**/
private
int
transformBizType
(
MgRnrInfoDTO
rnrInfo
,
MgRnrCompanyInfoDTO
companyInfo
)
{
if
(
rnrInfo
.
getRnrBizzType
().
intValue
()
==
RnrBizzTypeEnum
.
Bind
.
getCode
())
{
if
(
CommonYesOrNoEnum
.
YES
.
getCode
()
==
rnrInfo
.
getIsSecondHandCar
().
intValue
())
{
//二手车
return
3
;
}
if
(
CommonYesOrNoEnum
.
NO
.
getCode
()
==
rnrInfo
.
getIsCompany
().
intValue
())
{
//个人
return
1
;
}
else
{
if
(
companyInfo
!=
null
&&
companyInfo
.
getIsVehicleCompany
().
intValue
()
==
CommonYesOrNoEnum
.
YES
.
getCode
())
{
//车企
return
2
;
}
else
{
//企业
return
4
;
}
}
}
return
0
;
}
/**
* Description: 实名信息转个人信息
* <br />
* CreateDate 2022-07-29 19:42:03
*
* @author yuyi
**/
private
FlowPersonalInfoDTO
personalFromMgRnrInfo
(
MgRnrInfoDTO
rnrInfo
)
{
if
(
rnrInfo
==
null
)
{
return
null
;
}
FlowPersonalInfoDTO
personalInfoDTO
=
new
FlowPersonalInfoDTO
();
personalInfoDTO
.
setName
(
rnrInfo
.
getFullName
());
personalInfoDTO
.
setPhone
(
rnrInfo
.
getPhone
());
personalInfoDTO
.
setCertId
(
rnrInfo
.
getCertNumber
());
personalInfoDTO
.
setCertType
(
transformCertType
(
rnrInfo
.
getCertType
()));
return
personalInfoDTO
;
}
/**
* Description: 实名企业信息转企业信息
* <br />
* CreateDate 2022-07-29 19:42:03
*
* @author yuyi
**/
private
FlowEnterpriseInfoDTO
enterpriseFromCompanyInfo
(
MgRnrCompanyInfoDTO
companyInfo
)
{
if
(
companyInfo
==
null
)
{
return
null
;
}
FlowEnterpriseInfoDTO
enterpriseInfoDTO
=
new
FlowEnterpriseInfoDTO
();
enterpriseInfoDTO
.
setName
(
companyInfo
.
getCompanyName
());
enterpriseInfoDTO
.
setComType
(
transformComType
(
companyInfo
.
getCompanyType
()));
enterpriseInfoDTO
.
setLicenseCode
(
companyInfo
.
getCompanyCertNumber
());
enterpriseInfoDTO
.
setAddress
(
companyInfo
.
getCompanyCertAddress
());
return
enterpriseInfoDTO
;
}
/**
* Description: 证件类型转换
* <br />
* 1军官证,2护照,3居民身份证,4警官证,5港澳居民来往内地通行证,6台湾居民来往大陆通行证,7其他
* CreateDate 2022-07-29 19:40:26
*
* @author yuyi
**/
private
int
transformCertType
(
String
certType
)
{
if
(
CertTypeEnum
.
PLA
.
getCode
().
equals
(
certType
))
{
return
1
;
}
if
(
CertTypeEnum
.
PASSPORT
.
getCode
().
equals
(
certType
))
{
return
2
;
}
if
(
CertTypeEnum
.
IDCARD
.
getCode
().
equals
(
certType
))
{
return
3
;
}
if
(
CertTypeEnum
.
POLICEPAPER
.
getCode
().
equals
(
certType
))
{
return
4
;
}
if
(
CertTypeEnum
.
HKIDCARD
.
getCode
().
equals
(
certType
))
{
return
5
;
}
if
(
CertTypeEnum
.
TAIBAOZHENG
.
getCode
().
equals
(
certType
))
{
return
6
;
}
return
7
;
}
/**
* Description: 公司类型转换
* <br />
* CreateDate 2022-07-29 19:51:26
*
* @author yuyi
**/
private
String
transformComType
(
String
companyType
)
{
if
(
companyType
.
equals
(
CompanyTypeEnum
.
YXZRGS
.
getCode
()))
{
return
"1"
;
}
if
(
companyType
.
equals
(
CompanyTypeEnum
.
GFYXGS
.
getCode
()))
{
return
"2"
;
}
if
(
companyType
.
equals
(
CompanyTypeEnum
.
GRDZQY
.
getCode
()))
{
return
"3"
;
}
if
(
companyType
.
equals
(
CompanyTypeEnum
.
SYQY
.
getCode
()))
{
return
"4"
;
}
if
(
companyType
.
equals
(
CompanyTypeEnum
.
LYQY
.
getCode
()))
{
return
"5"
;
}
return
"0"
;
}
}
local-rnr-fp-server/src/main/java/com/cusc/nirvana/user/rnr/fp/service/impl/EnterpriseRnrServiceImpl.java
0 → 100644
View file @
015d4257
package
com.cusc.nirvana.user.rnr.fp.service.impl
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.cache.CacheFactory
;
import
com.cache.exception.CacheException
;
import
com.cusc.nirvana.common.result.Response
;
import
com.cusc.nirvana.user.exception.CuscUserException
;
import
com.cusc.nirvana.user.rnr.fp.common.ResponseCode
;
import
com.cusc.nirvana.user.rnr.fp.common.RnrResultEnum
;
import
com.cusc.nirvana.user.rnr.fp.common.cloud.CloudMethod
;
import
com.cusc.nirvana.user.rnr.fp.common.cloud.CloudService
;
import
com.cusc.nirvana.user.rnr.fp.common.util.DateUtil
;
import
com.cusc.nirvana.user.rnr.fp.constants.RedisConstant
;
import
com.cusc.nirvana.user.rnr.fp.constants.ResultCodeEnum
;
import
com.cusc.nirvana.user.rnr.fp.dto.AttachmentDTO
;
import
com.cusc.nirvana.user.rnr.fp.dto.AttachmentRespDTO
;
import
com.cusc.nirvana.user.rnr.fp.dto.EnterpriseChangeRnrPersonDTO
;
import
com.cusc.nirvana.user.rnr.fp.dto.EnterpriseH5CallBackRequestDTO
;
import
com.cusc.nirvana.user.rnr.fp.dto.EnterpriseRnrPersonNameReqDTO
;
import
com.cusc.nirvana.user.rnr.fp.dto.EnterpriseRnrPersonNameResponseDTO
;
import
com.cusc.nirvana.user.rnr.fp.dto.RnrRequestDTO
;
import
com.cusc.nirvana.user.rnr.fp.dto.RnrResponseDTO
;
import
com.cusc.nirvana.user.rnr.fp.service.IEnterpriseRnrService
;
import
com.cusc.nirvana.user.rnr.fp.service.IFileService
;
import
com.cusc.nirvana.user.rnr.fp.service.IRnrService
;
import
com.cusc.nirvana.user.rnr.fp.service.ShortMessageCheckService
;
import
com.cusc.nirvana.user.rnr.mg.client.ChangeOrUnbindIccidsClient
;
import
com.cusc.nirvana.user.rnr.mg.client.MgRnrCardInfoClient
;
import
com.cusc.nirvana.user.rnr.mg.client.MgRnrCompanyInfoClient
;
import
com.cusc.nirvana.user.rnr.mg.client.MgRnrFileClient
;
import
com.cusc.nirvana.user.rnr.mg.client.MgRnrInfoClient
;
import
com.cusc.nirvana.user.rnr.mg.client.MgRnrRelationClient
;
import
com.cusc.nirvana.user.rnr.mg.client.MgRnrUnboundClient
;
import
com.cusc.nirvana.user.rnr.mg.client.MgVehicleCompanyClient
;
import
com.cusc.nirvana.user.rnr.mg.client.RnrOrderClient
;
import
com.cusc.nirvana.user.rnr.mg.constants.CertFileRnrFileTypeRelation
;
import
com.cusc.nirvana.user.rnr.mg.constants.CertTypeEnum
;
import
com.cusc.nirvana.user.rnr.mg.constants.CommonYesOrNoEnum
;
import
com.cusc.nirvana.user.rnr.mg.constants.RnrBizzTypeEnum
;
import
com.cusc.nirvana.user.rnr.mg.constants.RnrFileType
;
import
com.cusc.nirvana.user.rnr.mg.constants.RnrOrderAuditTypeEnum
;
import
com.cusc.nirvana.user.rnr.mg.constants.RnrOrderSourceEnum
;
import
com.cusc.nirvana.user.rnr.mg.constants.RnrOrderStatusEnum
;
import
com.cusc.nirvana.user.rnr.mg.constants.RnrOrderType
;
import
com.cusc.nirvana.user.rnr.mg.constants.RnrStatus
;
import
com.cusc.nirvana.user.rnr.mg.dto.MgRnrCardInfoDTO
;
import
com.cusc.nirvana.user.rnr.mg.dto.MgRnrCompanyInfoDTO
;
import
com.cusc.nirvana.user.rnr.mg.dto.MgRnrFileDTO
;
import
com.cusc.nirvana.user.rnr.mg.dto.MgRnrInfoDTO
;
import
com.cusc.nirvana.user.rnr.mg.dto.MgVehicleCompanyDTO
;
import
com.cusc.nirvana.user.rnr.mg.dto.RnrOrderDTO
;
import
com.cusc.nirvana.user.rnr.mg.dto.RnrRelationDTO
;
import
com.cusc.nirvana.user.rnr.mg.dto.RnrUnbindDTO
;
import
com.cusc.nirvana.user.util.CuscStringUtils
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.CollectionUtils
;
import
javax.annotation.Resource
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
@Service
@Slf4j
public
class
EnterpriseRnrServiceImpl
implements
IEnterpriseRnrService
{
@Resource
private
MgRnrRelationClient
mgRnrRelationClient
;
@Resource
private
MgRnrCardInfoClient
mgRnrCardInfoClient
;
@Autowired
private
MgRnrUnboundClient
unboundClient
;
@Autowired
private
IRnrService
rnrService
;
@Resource
private
MgRnrInfoClient
rnrInfoClient
;
@Resource
private
MgRnrCompanyInfoClient
companyInfoClient
;
@Resource
private
ShortMessageCheckService
shortMessageCheckService
;
@Resource
private
MgVehicleCompanyClient
vehicleCompanyClient
;
@Resource
private
RnrOrderClient
orderClient
;
@Resource
private
IFileService
fileService
;
@Resource
private
MgRnrFileClient
fileClient
;
@Autowired
private
CloudService
cloudService
;
@Resource
private
ChangeOrUnbindIccidsClient
changeOrUnbindIccidsClient
;
@Resource
private
CacheFactory
cacheFactory
;
/**
* 企业实名
*
* @param dto
* @return
*/
@Override
public
Response
enterpriseRnr
(
RnrRelationDTO
dto
,
String
requestId
)
{
//卡实名状态校验
rnrService
.
iccidListCheck
(
dto
);
//校验人卡实名状态 iccid和实名状态去查
List
<
MgRnrCardInfoDTO
>
iccidList
=
dto
.
getCardList
();
if
(
CollectionUtils
.
isEmpty
(
iccidList
))
{
return
Response
.
createError
(
"iccid不能为空"
);
}
for
(
MgRnrCardInfoDTO
iccid
:
iccidList
)
{
MgRnrCardInfoDTO
mgRnrCardInfoDTO
=
new
MgRnrCardInfoDTO
();
mgRnrCardInfoDTO
.
setIccid
(
iccid
.
getIccid
());
Response
<
Boolean
>
cardInfoClientResponse
=
mgRnrCardInfoClient
.
checkStatus
(
mgRnrCardInfoDTO
);
if
(!
cardInfoClientResponse
.
isSuccess
()
||
cardInfoClientResponse
.
getData
()
==
null
)
{
return
Response
.
createError
(
cardInfoClientResponse
.
getMsg
(),
cardInfoClientResponse
.
getCode
());
}
log
.
info
(
"卡实名状态:{}"
,
JSON
.
toJSONString
(
cardInfoClientResponse
));
if
(
cardInfoClientResponse
.
getData
())
{
return
Response
.
createError
(
"卡【"
+
iccid
.
getIccid
()
+
"】已实名"
);
}
}
//企业实名
RnrRequestDTO
rnrRequestDTO
=
rnrService
.
rnrPersonRelationDto2RnrRequestDTO
(
dto
);
rnrRequestDTO
.
setSerialNumber
(
dto
.
getOrder
().
getUuid
());
rnrRequestDTO
.
setRequestId
(
requestId
);
// log.info("RnrRequestDTO1111111: {}", JSON.toJSONString(rnrRequestDTO));
RnrResponseDTO
rnrResponseDTO
=
rnrService
.
doPersonRnr
(
rnrRequestDTO
,
null
);
log
.
info
(
"企业实名"
,
rnrResponseDTO
);
//添加活体图片1
MgRnrFileDTO
livenessPic1
=
new
MgRnrFileDTO
();
livenessPic1
.
setUuid
(
CuscStringUtils
.
generateUuid
());
livenessPic1
.
setRnrBizzType
(
RnrBizzTypeEnum
.
Bind
.
getCode
());
livenessPic1
.
setRnrId
(
dto
.
getInfo
().
getUuid
());
livenessPic1
.
setIsCompany
(
CommonYesOrNoEnum
.
YES
.
getCode
());
livenessPic1
.
setRnrCompanyId
(
dto
.
getCompanyInfo
().
getUuid
());
livenessPic1
.
setFileSystemId
(
rnrResponseDTO
.
getLivenessPic1
());
livenessPic1
.
setFileType
(
RnrFileType
.
LIVENESS_SCREEN_FIRST
.
getCode
());
livenessPic1
.
setTenantNo
(
dto
.
getTenantNo
());
livenessPic1
.
setRoutingKey
(
dto
.
getInfo
().
getRoutingKey
());
livenessPic1
.
setCreator
(
dto
.
getInfo
().
getCreator
());
livenessPic1
.
setFileName
(
"活体视频1.png"
);
livenessPic1
.
setLiaisonId
(
"0"
);
dto
.
getRnrFileList
().
add
(
livenessPic1
);
//添加活体图片1
MgRnrFileDTO
livenessPic2
=
new
MgRnrFileDTO
();
livenessPic2
.
setUuid
(
CuscStringUtils
.
generateUuid
());
livenessPic2
.
setRnrBizzType
(
RnrBizzTypeEnum
.
Bind
.
getCode
());
livenessPic2
.
setRnrId
(
dto
.
getInfo
().
getUuid
());
livenessPic2
.
setIsCompany
(
CommonYesOrNoEnum
.
YES
.
getCode
());
livenessPic2
.
setRnrCompanyId
(
dto
.
getCompanyInfo
().
getUuid
());
livenessPic2
.
setFileSystemId
(
rnrResponseDTO
.
getLivenessPic2
());
livenessPic2
.
setFileType
(
RnrFileType
.
LIVENESS_SCREEN_TWO
.
getCode
());
livenessPic2
.
setCreator
(
dto
.
getInfo
().
getCreator
());
livenessPic2
.
setFileName
(
"活体视频2.png"
);
livenessPic2
.
setTenantNo
(
dto
.
getTenantNo
());
livenessPic2
.
setRoutingKey
(
dto
.
getInfo
().
getRoutingKey
());
livenessPic2
.
setLiaisonId
(
"0"
);
dto
.
getRnrFileList
().
add
(
livenessPic2
);
//创建手工工单 调用工单接口 client
log
.
info
(
"数据信息"
,
dto
);
Response
response
=
mgRnrRelationClient
.
saveRnrRelation
(
dto
);
if
(!
response
.
isSuccess
())
{
return
response
;
}
return
Response
.
createSuccess
(
1
);
}
@Override
public
Response
enterpriseRnrFollowUp
(
RnrRelationDTO
dto
)
{
log
.
info
(
"enterpriseRnrFollowUp param : {}"
,
JSON
.
toJSONString
(
dto
));
//校验人卡实名状态 iccid和实名状态去查
List
<
MgRnrCardInfoDTO
>
iccidList
=
dto
.
getCardList
();
if
(
CollectionUtils
.
isEmpty
(
iccidList
))
{
return
Response
.
createError
(
"iccid不能为空"
);
}
for
(
MgRnrCardInfoDTO
iccid
:
iccidList
)
{
MgRnrCardInfoDTO
mgRnrCardInfoDTO
=
new
MgRnrCardInfoDTO
();
mgRnrCardInfoDTO
.
setIccid
(
iccid
.
getIccid
());
Response
<
Boolean
>
cardInfoClientResponse
=
mgRnrCardInfoClient
.
checkStatus
(
mgRnrCardInfoDTO
);
if
(!
cardInfoClientResponse
.
isSuccess
()
||
cardInfoClientResponse
.
getData
()
==
null
)
{
return
Response
.
createError
(
cardInfoClientResponse
.
getMsg
(),
cardInfoClientResponse
.
getCode
());
}
log
.
info
(
"卡实名状态:{}"
,
JSON
.
toJSONString
(
cardInfoClientResponse
));
if
(
cardInfoClientResponse
.
getData
())
{
return
Response
.
createError
(
"卡【"
+
iccid
.
getIccid
()
+
"】已实名"
);
}
}
//创建手工工单 调用工单接口 client
Response
response
=
mgRnrRelationClient
.
saveRnrRelation
(
dto
);
if
(!
response
.
isSuccess
())
{
return
response
;
}
return
Response
.
createSuccess
(
1
);
}
@Override
public
Response
uploadSecondaryEnterprise
(
RnrRelationDTO
dto
)
{
//解绑卡
Response
response
=
unboundCards
(
dto
);
if
(!
response
.
isSuccess
())
{
return
Response
.
createSuccess
(
false
);
}
//调用新车绑定方法
//return uploadEnterpriseInfo(dto);
return
null
;
}
@Override
public
List
<
EnterpriseRnrPersonNameResponseDTO
>
queryEnterpriseRnrPersonName
(
EnterpriseRnrPersonNameReqDTO
dto
)
{
MgRnrCompanyInfoDTO
companyQueryDto
=
new
MgRnrCompanyInfoDTO
();
companyQueryDto
.
setTenantNo
(
dto
.
getTenantNo
());
companyQueryDto
.
setCompanyName
(
dto
.
getCompanyName
());
if
(!
dto
.
getVehicleCompany
())
{
companyQueryDto
.
setIsVehicleCompany
(
0
);
}
Response
<
List
<
MgRnrCompanyInfoDTO
>>
companyResponse
=
companyInfoClient
.
queryByList
(
companyQueryDto
);
if
(!
companyResponse
.
getSuccess
())
{
throw
new
CuscUserException
(
companyResponse
.
getCode
(),
companyResponse
.
getException
());
}
List
<
MgRnrCompanyInfoDTO
>
companyInfoDTOList
=
companyResponse
.
getData
();
if
(
CollectionUtils
.
isEmpty
(
companyInfoDTOList
))
{
//throw new CuscUserException("","该公司未查询到实名信息");
return
Collections
.
emptyList
();
}
Map
<
String
,
String
>
companyMap
=
companyInfoDTOList
.
stream
().
collect
(
Collectors
.
toMap
(
MgRnrCompanyInfoDTO:
:
getRnrId
,
MgRnrCompanyInfoDTO:
:
getCompanyName
,
(
k
,
v
)
->
v
));
List
<
String
>
rnrIdList
=
companyInfoDTOList
.
stream
().
map
(
MgRnrCompanyInfoDTO:
:
getRnrId
).
collect
(
Collectors
.
toList
());
MgRnrInfoDTO
rnrQuery
=
new
MgRnrInfoDTO
();
rnrQuery
.
setUuidList
(
rnrIdList
);
rnrQuery
.
setRnrStatus
(
RnrStatus
.
RNR
.
getCode
());
Response
<
List
<
MgRnrInfoDTO
>>
rnrInfoResponse
=
rnrInfoClient
.
queryByList
(
rnrQuery
);
if
(!
rnrInfoResponse
.
getSuccess
())
{
throw
new
CuscUserException
(
rnrInfoResponse
.
getCode
(),
rnrInfoResponse
.
getException
());
}
List
<
MgRnrInfoDTO
>
rnrInfoDTOList
=
rnrInfoResponse
.
getData
();
//按照人分组
Map
<
String
,
List
<
MgRnrInfoDTO
>>
personMap
=
rnrInfoDTOList
.
stream
().
collect
(
Collectors
.
groupingBy
(
MgRnrInfoDTO:
:
getFullName
));
List
<
EnterpriseRnrPersonNameResponseDTO
>
reponseList
=
new
ArrayList
<>();
for
(
Map
.
Entry
<
String
,
List
<
MgRnrInfoDTO
>>
entry
:
personMap
.
entrySet
())
{
List
<
MgRnrInfoDTO
>
rnrInfoList
=
entry
.
getValue
();
for
(
MgRnrInfoDTO
mgRnrInfoDTO
:
rnrInfoList
)
{
MgRnrCardInfoDTO
cardQuery
=
new
MgRnrCardInfoDTO
();
cardQuery
.
setRnrId
(
mgRnrInfoDTO
.
getUuid
());
cardQuery
.
setRnrStatus
(
RnrStatus
.
RNR
.
getCode
());
Response
<
List
<
MgRnrCardInfoDTO
>>
response
=
mgRnrCardInfoClient
.
queryByList
(
cardQuery
);
if
(
response
!=
null
&&
!
CollectionUtils
.
isEmpty
(
response
.
getData
()))
{
//这个责任人下 有实名通过的卡' 处理下一个人
EnterpriseRnrPersonNameResponseDTO
responseDTO
=
new
EnterpriseRnrPersonNameResponseDTO
();
responseDTO
.
setFullName
(
mgRnrInfoDTO
.
getFullName
());
responseDTO
.
setCompanyName
(
companyMap
.
get
(
mgRnrInfoDTO
.
getUuid
()));
reponseList
.
add
(
responseDTO
);
break
;
}
}
}
return
reponseList
;
}
/**
* 解绑卡
*
* @param dto
*/
private
Response
unboundCards
(
RnrRelationDTO
dto
)
{
List
<
String
>
iccidList
=
dto
.
getCardList
().
stream
().
map
(
MgRnrCardInfoDTO:
:
getIccid
).
collect
(
Collectors
.
toList
());
MgRnrCardInfoDTO
query
=
new
MgRnrCardInfoDTO
();
query
.
setIccidList
(
iccidList
);
Response
<
List
<
MgRnrCardInfoDTO
>>
response
=
mgRnrCardInfoClient
.
queryByList
(
query
);
if
(
null
==
response
||
!
response
.
getSuccess
())
{
return
Response
.
createError
(
"查询卡信息失败"
);
}
//获取汽车过户证明
/*MgRnrFileDTO mgRnrFileDTO = dto.getRnrFileList().stream()
.filter(f -> f.getFileType() == RnrFileType.CAR_TRANSFER_CERTIFICATE.getCode())
.findFirst().get();
if(mgRnrFileDTO == null) {
return Response.createError("汽车过户证明缺失");
}*/
if
(!
CollectionUtils
.
isEmpty
(
response
.
getData
()))
{
List
<
MgRnrCardInfoDTO
>
bindCards
=
new
ArrayList
<>();
for
(
MgRnrCardInfoDTO
cardDto
:
response
.
getData
())
{
//还在审核中的卡不能实名
if
(
cardDto
.
getRnrStatus
()
==
RnrStatus
.
INIT
.
getCode
())
{
return
Response
.
createError
(
"卡["
+
cardDto
.
getIccid
()
+
"]正在实名中"
);
}
//实名成功的卡需要解绑
if
(
cardDto
.
getRnrStatus
()
==
RnrStatus
.
RNR
.
getCode
())
{
bindCards
.
add
(
cardDto
);
}
}
//依次解绑
if
(!
bindCards
.
isEmpty
())
{
RnrUnbindDTO
unbindDTO
;
for
(
MgRnrCardInfoDTO
bindCard
:
bindCards
)
{
//获取实名主体信息
MgRnrInfoDTO
mgRnrInfoDTO
=
new
MgRnrInfoDTO
();
mgRnrInfoDTO
.
setUuid
(
bindCard
.
getRnrId
());
Response
<
MgRnrInfoDTO
>
byUuid
=
rnrInfoClient
.
getByUuid
(
mgRnrInfoDTO
);
if
(
byUuid
==
null
||
!
byUuid
.
isSuccess
())
{
return
byUuid
;
}
MgRnrInfoDTO
rnrInfoDTO
=
byUuid
.
getData
();
unbindDTO
=
new
RnrUnbindDTO
();
unbindDTO
.
setIccid
(
bindCard
.
getIccid
());
unbindDTO
.
setVin
(
bindCard
.
getIotId
());
unbindDTO
.
setCertNumber
(
rnrInfoDTO
.
getCertNumber
());
unbindDTO
.
setCertType
(
rnrInfoDTO
.
getCertType
());
unbindDTO
.
setFullName
(
rnrInfoDTO
.
getFullName
());
unbindDTO
.
setPhone
(
rnrInfoDTO
.
getPhone
());
unbindDTO
.
setReason
(
3
);
unbindDTO
.
setManualUnbind
(
false
);
//unbindDTO.setEvidence(mgRnrFileDTO.getFileSystemId());
response
=
unboundClient
.
rnrUnbound
(
unbindDTO
);
if
(
null
==
response
||
(!
response
.
getSuccess
()
&&
response
.
getCode
()
!=
ResponseCode
.
ICCID_RNR_INFO_NOT_MATCHED
.
getCode
()))
{
return
Response
.
createError
(
"解绑卡["
+
bindCard
.
getIccid
()
+
"]失败"
);
}
}
}
}
return
Response
.
createSuccess
();
}
/**
* 提交企业责任人变更
* @param serialNumber
* @param requestId
* @param dto
*/
@Override
public
void
changeEnterpriseRnrPerson
(
String
serialNumber
,
String
requestId
,
EnterpriseChangeRnrPersonDTO
dto
)
{
log
.
info
(
"企业责任人变更,request = {}"
,
JSONObject
.
toJSONString
(
dto
));
//短信校验
/*SmsRequestDTO smsDto = new SmsRequestDTO();
smsDto.setTenantNo(dto.getTenantNo());
smsDto.setBizType(BizTypeEnum.ENTERPRISE_CHANGE.getCode());
smsDto.setCaptcha(dto.getCaptcha());
smsDto.setPhone(dto.getCorporationPhone());
Response response = shortMessageCheckService.checkSmsCaptcha(smsDto);
if (!response.isSuccess()) {
throw new CuscUserException(response.getCode(),response.getMsg());
}*/
changeEnterpriseRnrPersonNoSms
(
serialNumber
,
requestId
,
dto
);
}
@Override
public
void
changeEnterpriseRnrPersonNoSms
(
String
serialNumber
,
String
requestId
,
EnterpriseChangeRnrPersonDTO
dto
)
{
log
.
info
(
"企业责任人变更,request = {}"
,
JSONObject
.
toJSONString
(
dto
));
//查询出原来责任人对应的实名业务
MgRnrInfoDTO
rnrInfoQuery
=
new
MgRnrInfoDTO
();
rnrInfoQuery
.
setTenantNo
(
dto
.
getTenantNo
());
rnrInfoQuery
.
setFullName
(
dto
.
getOrigCorporationName
());
rnrInfoQuery
.
setRnrStatus
(
RnrStatus
.
RNR
.
getCode
());
rnrInfoQuery
.
setCompanyName
(
dto
.
getCompanyName
());
List
<
MgRnrInfoDTO
>
orginRnrInfoList
=
rnrInfoClient
.
queryByList
(
rnrInfoQuery
).
getData
();
if
(
CollectionUtils
.
isEmpty
(
orginRnrInfoList
))
{
throw
new
CuscUserException
(
""
,
"未查询到"
+
dto
.
getOrigCorporationName
()
+
"有实名通过的业务"
);
}
log
.
info
(
"企业责任人变更,原实名业务 = {}"
,
orginRnrInfoList
.
stream
().
map
(
MgRnrInfoDTO:
:
getUuid
).
collect
(
Collectors
.
toList
()));
//查询到实名业务 对应的 卡信息
List
<
String
>
rnrIdList
=
orginRnrInfoList
.
stream
().
map
(
MgRnrInfoDTO:
:
getUuid
).
collect
(
Collectors
.
toList
());
MgRnrCardInfoDTO
cardQuery
=
new
MgRnrCardInfoDTO
();
cardQuery
.
setRnrIdList
(
rnrIdList
);
cardQuery
.
setRnrStatus
(
RnrStatus
.
RNR
.
getCode
());
List
<
MgRnrCardInfoDTO
>
rnrCardList
=
mgRnrCardInfoClient
.
queryByList
(
cardQuery
).
getData
();
if
(
CollectionUtils
.
isEmpty
(
rnrCardList
))
{
throw
new
CuscUserException
(
""
,
"未查询到"
+
dto
.
getOrigCorporationName
()
+
"有实名通过的卡信息"
);
}
log
.
info
(
"企业责任人变更,原卡信息 = {}"
,
rnrCardList
.
stream
().
map
(
MgRnrCardInfoDTO:
:
getUuid
).
collect
(
Collectors
.
toList
()));
//构建新的RnrRelationDto
RnrRelationDTO
rnrRelationDTO
=
enterpriseChangeDto2RnrRelation
(
dto
,
rnrCardList
,
serialNumber
,
orginRnrInfoList
.
get
(
0
));
RnrRequestDTO
rnrRequestDTO
=
rnrService
.
rnrPersonRelationDto2RnrRequestDTO
(
rnrRelationDTO
);
rnrRequestDTO
.
setSerialNumber
(
rnrRelationDTO
.
getOrder
().
getUuid
());
rnrRequestDTO
.
setBizUuid
(
rnrRelationDTO
.
getInfo
().
getUuid
());
rnrRequestDTO
.
setRequestId
(
requestId
);
RnrResponseDTO
rnrResponseDTO
=
rnrService
.
doPersonRnr
(
rnrRequestDTO
,
null
);
//添加活体图片1
MgRnrFileDTO
livenessPic1
=
new
MgRnrFileDTO
();
livenessPic1
.
setUuid
(
CuscStringUtils
.
generateUuid
());
livenessPic1
.
setRnrBizzType
(
RnrBizzTypeEnum
.
Bind
.
getCode
());
livenessPic1
.
setRnrId
(
rnrRelationDTO
.
getInfo
().
getUuid
());
livenessPic1
.
setIsCompany
(
CommonYesOrNoEnum
.
YES
.
getCode
());
livenessPic1
.
setRnrCompanyId
(
rnrRelationDTO
.
getCompanyInfo
().
getUuid
());
livenessPic1
.
setFileSystemId
(
rnrResponseDTO
.
getLivenessPic1
());
livenessPic1
.
setFileType
(
RnrFileType
.
LIVENESS_SCREEN_FIRST
.
getCode
());
livenessPic1
.
setTenantNo
(
dto
.
getTenantNo
());
livenessPic1
.
setRoutingKey
(
rnrRelationDTO
.
getInfo
().
getRoutingKey
());
livenessPic1
.
setCreator
(
rnrRelationDTO
.
getInfo
().
getCreator
());
livenessPic1
.
setFileName
(
"活体视频1.png"
);
livenessPic1
.
setLiaisonId
(
"0"
);
rnrRelationDTO
.
getRnrFileList
().
add
(
livenessPic1
);
//添加活体图片1
MgRnrFileDTO
livenessPic2
=
new
MgRnrFileDTO
();
livenessPic2
.
setUuid
(
CuscStringUtils
.
generateUuid
());
livenessPic2
.
setRnrBizzType
(
RnrBizzTypeEnum
.
Bind
.
getCode
());
livenessPic2
.
setRnrId
(
rnrRelationDTO
.
getInfo
().
getUuid
());
livenessPic2
.
setIsCompany
(
CommonYesOrNoEnum
.
YES
.
getCode
());
livenessPic2
.
setRnrCompanyId
(
rnrRelationDTO
.
getCompanyInfo
().
getUuid
());
livenessPic2
.
setFileSystemId
(
rnrResponseDTO
.
getLivenessPic2
());
livenessPic2
.
setFileType
(
RnrFileType
.
LIVENESS_SCREEN_TWO
.
getCode
());
livenessPic2
.
setCreator
(
rnrRelationDTO
.
getInfo
().
getCreator
());
livenessPic2
.
setFileName
(
"活体视频2.png"
);
livenessPic2
.
setTenantNo
(
rnrRelationDTO
.
getTenantNo
());
livenessPic2
.
setRoutingKey
(
rnrRelationDTO
.
getInfo
().
getRoutingKey
());
livenessPic2
.
setLiaisonId
(
"0"
);
rnrRelationDTO
.
getRnrFileList
().
add
(
livenessPic2
);
log
.
info
(
"企业责任人变更,构建RnrRelation = {}"
,
JSONObject
.
toJSONString
(
rnrRelationDTO
));
mgRnrRelationClient
.
saveRnrRelation
(
rnrRelationDTO
);
//将实名结果回传给智网
rnrService
.
notifyResult
(
rnrRelationDTO
.
getCardList
(),
RnrBizzTypeEnum
.
INFO_CHANGE
.
getCode
().
toString
(),
serialNumber
,
null
,
ResultCodeEnum
.
PASS
.
getCode
());
}
private
RnrRelationDTO
enterpriseChangeDto2RnrRelation
(
EnterpriseChangeRnrPersonDTO
dto
,
List
<
MgRnrCardInfoDTO
>
rnrCardList
,
String
serialNumber
,
MgRnrInfoDTO
mgRnrInfoDTO
)
{
RnrRelationDTO
rnrRelationDTO
=
new
RnrRelationDTO
();
rnrRelationDTO
.
setIsTrust
(
0
);
rnrRelationDTO
.
setTenantNo
(
dto
.
getTenantNo
());
//实名信息
MgRnrInfoDTO
rnrInfo
=
new
MgRnrInfoDTO
();
BeanUtils
.
copyProperties
(
mgRnrInfoDTO
,
rnrInfo
);
rnrInfo
.
setRnrBizzType
(
RnrBizzTypeEnum
.
INFO_CHANGE
.
getCode
());
rnrInfo
.
setTenantNo
(
dto
.
getTenantNo
());
rnrInfo
.
setUuid
(
CuscStringUtils
.
generateUuid
());
rnrInfo
.
setFullName
(
dto
.
getCorporationName
());
rnrInfo
.
setCertType
(
dto
.
getCorporationCertType
());
rnrInfo
.
setCertNumber
(
dto
.
getCorporationCertNumber
());
rnrInfo
.
setCertAddress
(
dto
.
getCorporationCertAddress
());
rnrInfo
.
setGender
(
Integer
.
parseInt
(
dto
.
getCorporationGender
()));
rnrInfo
.
setEffectiveDate
(
DateUtil
.
parseDate
(
dto
.
getCorporationCertEffectiveDate
(),
DateUtil
.
YYMM_DD_MM
));
rnrInfo
.
setExpiredDate
(
dto
.
getCorporationCertExpirationDate
());
rnrInfo
.
setContactAddress
(
dto
.
getCorporationContactAddress
());
rnrInfo
.
setPhone
(
dto
.
getCorporationPhone
());
rnrInfo
.
setCreator
(
dto
.
getCreator
());
rnrInfo
.
setOperator
(
dto
.
getCreator
());
rnrInfo
.
setIsCompany
(
1
);
rnrRelationDTO
.
setInfo
(
rnrInfo
);
//订单信息
RnrOrderDTO
orderDTO
=
new
RnrOrderDTO
();
orderDTO
.
setTenantNo
(
dto
.
getTenantNo
());
orderDTO
.
setRnrBizzType
(
RnrBizzTypeEnum
.
INFO_CHANGE
.
getCode
());
orderDTO
.
setRnrId
(
rnrInfo
.
getUuid
());
orderDTO
.
setUuid
(
CuscStringUtils
.
generateUuid
());
orderDTO
.
setOrderType
(
RnrOrderType
.
COMPANY_CORPORATION_CHANGE
.
getCode
());
orderDTO
.
setAuditType
(
RnrOrderAuditTypeEnum
.
MANUAL
.
getCode
());
orderDTO
.
setOrderStatus
(
RnrOrderStatusEnum
.
ASSIGNMENT
.
getCode
());
orderDTO
.
setOrderSource
(
RnrOrderSourceEnum
.
PORTAL
.
getCode
());
orderDTO
.
setSerialNumber
(
serialNumber
);
orderDTO
.
setIsBatchOrder
(
0
);
orderDTO
.
setCreator
(
dto
.
getCreator
());
orderDTO
.
setOperator
(
dto
.
getCreator
());
orderDTO
.
setSendWorkOrder
(
true
);
orderDTO
.
setOrgId
(
mgRnrInfoDTO
.
getOrgId
());
rnrRelationDTO
.
setOrder
(
orderDTO
);
MgRnrCompanyInfoDTO
companyQueryDto
=
new
MgRnrCompanyInfoDTO
();
companyQueryDto
.
setTenantNo
(
dto
.
getTenantNo
());
companyQueryDto
.
setCompanyName
(
dto
.
getCompanyName
());
Response
<
List
<
MgRnrCompanyInfoDTO
>>
companyResponse
=
companyInfoClient
.
queryByList
(
companyQueryDto
);
//公司信息
MgRnrCompanyInfoDTO
companyInfoDTO
=
new
MgRnrCompanyInfoDTO
();
if
(
null
!=
companyResponse
&&
companyResponse
.
isSuccess
()
&&
!
CollectionUtils
.
isEmpty
(
companyResponse
.
getData
()))
{
MgRnrCompanyInfoDTO
orginalCompanyInfo
=
companyResponse
.
getData
().
get
(
0
);
BeanUtils
.
copyProperties
(
orginalCompanyInfo
,
companyInfoDTO
);
}
companyInfoDTO
.
setTenantNo
(
dto
.
getTenantNo
());
companyInfoDTO
.
setUuid
(
CuscStringUtils
.
generateUuid
());
companyInfoDTO
.
setRnrBizzType
(
RnrBizzTypeEnum
.
INFO_CHANGE
.
getCode
());
companyInfoDTO
.
setRnrId
(
rnrInfo
.
getUuid
());
companyInfoDTO
.
setCompanyName
(
dto
.
getCompanyName
());
companyInfoDTO
.
setCreator
(
dto
.
getCreator
());
companyInfoDTO
.
setOperator
(
dto
.
getCreator
());
MgVehicleCompanyDTO
vehicleQuery
=
new
MgVehicleCompanyDTO
();
vehicleQuery
.
setTenantNo
(
dto
.
getTenantNo
());
vehicleQuery
.
setCompanyName
(
dto
.
getCompanyName
());
Response
<
List
<
MgVehicleCompanyDTO
>>
vcListResp
=
vehicleCompanyClient
.
queryByList
(
vehicleQuery
);
MgVehicleCompanyDTO
vehicleCompanyDTO
=
null
;
if
(
vcListResp
!=
null
&&
vcListResp
.
isSuccess
()
&&
!
CollectionUtils
.
isEmpty
(
vcListResp
.
getData
()))
{
companyInfoDTO
.
setIsVehicleCompany
(
1
);
vehicleCompanyDTO
=
vcListResp
.
getData
().
get
(
0
);
}
rnrRelationDTO
.
setCompanyInfo
(
companyInfoDTO
);
//文件信息
List
<
MgRnrFileDTO
>
fileDTOList
=
new
ArrayList
<>();
//视频
MgRnrFileDTO
videoFile
=
new
MgRnrFileDTO
();
videoFile
.
setTenantNo
(
dto
.
getTenantNo
());
videoFile
.
setUuid
(
CuscStringUtils
.
generateUuid
());
videoFile
.
setFileType
(
RnrFileType
.
LIVENESS_VIDEO
.
getCode
());
videoFile
.
setRnrId
(
rnrInfo
.
getUuid
());
videoFile
.
setLiaisonId
(
"0"
);
videoFile
.
setIsCompany
(
1
);
videoFile
.
setRnrCompanyId
(
companyInfoDTO
.
getUuid
());
videoFile
.
setFileSystemId
(
dto
.
getCorporationVideo
());
videoFile
.
setCreator
(
dto
.
getCreator
());
videoFile
.
setOperator
(
dto
.
getCreator
());
fileDTOList
.
add
(
videoFile
);
//责任人证件信息
List
<
MgRnrFileDTO
>
certFileList
=
getCorporationCertFile
(
dto
,
rnrInfo
.
getUuid
(),
companyInfoDTO
.
getUuid
());
fileDTOList
.
addAll
(
certFileList
);
//企业实名认证授权书
for
(
String
syetemFileId
:
dto
.
getAuthorizationLetterPic
())
{
MgRnrFileDTO
authFile
=
new
MgRnrFileDTO
();
authFile
.
setTenantNo
(
dto
.
getTenantNo
());
authFile
.
setUuid
(
CuscStringUtils
.
generateUuid
());
authFile
.
setFileType
(
RnrFileType
.
ENTERPRISE_AUTH_FILE
.
getCode
());
authFile
.
setRnrId
(
rnrInfo
.
getUuid
());
authFile
.
setLiaisonId
(
"0"
);
authFile
.
setIsCompany
(
1
);
authFile
.
setRnrCompanyId
(
companyInfoDTO
.
getUuid
());
authFile
.
setFileSystemId
(
syetemFileId
);
authFile
.
setCreator
(
dto
.
getCreator
());
authFile
.
setOperator
(
dto
.
getCreator
());
fileDTOList
.
add
(
authFile
);
}
if
(
null
!=
vehicleCompanyDTO
)
{
MgRnrFileDTO
fileQuery
=
new
MgRnrFileDTO
();
fileQuery
.
setRnrId
(
vehicleCompanyDTO
.
getFirstRnrId
());
fileQuery
.
setTenantNo
(
orderDTO
.
getTenantNo
());
List
<
MgRnrFileDTO
>
fileList
=
fileClient
.
getByRnrid
(
fileQuery
).
getData
();
for
(
MgRnrFileDTO
fileDTO
:
fileList
)
{
//新提交的个人信息 和 企业实名认证授权书 不需要复制过来
if
(
notChangeNewSubmitFile
(
fileDTO
.
getFileType
())){
MgRnrFileDTO
copyFile
=
new
MgRnrFileDTO
();
BeanUtils
.
copyProperties
(
fileDTO
,
copyFile
);
copyFile
.
setUuid
(
CuscStringUtils
.
generateUuid
());
copyFile
.
setRnrId
(
rnrInfo
.
getUuid
());
copyFile
.
setRnrCompanyId
(
companyInfoDTO
.
getUuid
());
fileDTOList
.
add
(
copyFile
);
}
}
}
rnrRelationDTO
.
setRnrFileList
(
fileDTOList
);
//卡信息
List
<
MgRnrCardInfoDTO
>
newCardIdList
=
rnrCardList
.
stream
().
map
(
origCard
->
{
MgRnrCardInfoDTO
newCard
=
new
MgRnrCardInfoDTO
();
newCard
.
setUuid
(
CuscStringUtils
.
generateUuid
());
newCard
.
setRnrId
(
rnrInfo
.
getUuid
());
newCard
.
setOrderId
(
orderDTO
.
getUuid
());
newCard
.
setIotId
(
origCard
.
getIotId
());
newCard
.
setOldCardId
(
origCard
.
getUuid
());
newCard
.
setIccid
(
origCard
.
getIccid
());
newCard
.
setRnrStatus
(
RnrStatus
.
INIT
.
getCode
());
newCard
.
setTenantNo
(
dto
.
getTenantNo
());
newCard
.
setRoutingKey
(
origCard
.
getRoutingKey
());
newCard
.
setCreator
(
dto
.
getCreator
());
newCard
.
setOperator
(
dto
.
getCreator
());
newCard
.
setRnrBizzType
(
RnrBizzTypeEnum
.
INFO_CHANGE
.
getCode
());
return
newCard
;
}).
collect
(
Collectors
.
toList
());
rnrRelationDTO
.
setCardList
(
newCardIdList
);
return
rnrRelationDTO
;
}
private
boolean
notChangeNewSubmitFile
(
Integer
fileType
)
{
List
<
Integer
>
list
=
Arrays
.
asList
(
RnrFileType
.
IDENTITY_CARD_BACK
.
getCode
(),
RnrFileType
.
IDENTITY_CARD_FRONT
.
getCode
(),
RnrFileType
.
OFFICIAL_CARD_FRONT
.
getCode
(),
RnrFileType
.
OFFICIAL_CARD_BACK
.
getCode
(),
RnrFileType
.
POLICE_CARD_FRONT
.
getCode
(),
RnrFileType
.
POLICE_CARD_BACK
.
getCode
(),
RnrFileType
.
HK_MACAO_PASSPORT_FRONT
.
getCode
(),
RnrFileType
.
HK_MACAO_PASSPORT_BACK
.
getCode
(),
RnrFileType
.
TAIWAN_CARD_FRONT
.
getCode
(),
RnrFileType
.
TAIWAN_CARD_BACK
.
getCode
(),
RnrFileType
.
FOREIGN_NATIONAL_PASSPORT_FRONT
.
getCode
(),
RnrFileType
.
FOREIGN_NATIONAL_PASSPORT_BACK
.
getCode
(),
RnrFileType
.
HK_MACAO_RESIDENCE_PERMIT_FRONT
.
getCode
(),
RnrFileType
.
HK_MACAO_RESIDENCE_PERMIT_BACK
.
getCode
(),
RnrFileType
.
TAIWAN_RESIDENCE_PERMIT_FRONT
.
getCode
(),
RnrFileType
.
TAIWAN_RESIDENCE_PERMIT_BACK
.
getCode
(),
RnrFileType
.
RESIDENCE_BOOKLET_FRONT
.
getCode
(),
RnrFileType
.
RESIDENCE_BOOKLET_BACK
.
getCode
(),
RnrFileType
.
ENTERPRISE_AUTH_FILE
.
getCode
());
return
!
list
.
contains
(
fileType
);
}
private
List
<
MgRnrFileDTO
>
getCorporationCertFile
(
EnterpriseChangeRnrPersonDTO
dto
,
String
rnrId
,
String
companyId
)
{
String
corporationCertType
=
dto
.
getCorporationCertType
();
CertTypeEnum
certTypeEnum
=
CertTypeEnum
.
getEnumByCode
(
corporationCertType
);
if
(
null
==
certTypeEnum
)
{
return
Collections
.
emptyList
();
}
List
<
MgRnrFileDTO
>
fileDTOS
=
new
ArrayList
<>();
List
<
RnrFileType
>
rnrFileList
=
CertFileRnrFileTypeRelation
.
getRnrFileList
(
certTypeEnum
);
List
<
String
>
corporationCertPic
=
dto
.
getCorporationCertPic
();
for
(
int
index
=
0
;
index
<
corporationCertPic
.
size
();
index
++)
{
int
rnrFileType
;
if
(
index
>=
rnrFileList
.
size
())
{
rnrFileType
=
rnrFileList
.
get
(
rnrFileList
.
size
()
-
1
).
getCode
();
}
else
{
rnrFileType
=
rnrFileList
.
get
(
index
).
getCode
();
}
MgRnrFileDTO
fileDTO
=
new
MgRnrFileDTO
();
fileDTO
.
setTenantNo
(
dto
.
getTenantNo
());
fileDTO
.
setUuid
(
CuscStringUtils
.
generateUuid
());
fileDTO
.
setFileType
(
rnrFileType
);
fileDTO
.
setRnrId
(
rnrId
);
fileDTO
.
setLiaisonId
(
"0"
);
fileDTO
.
setIsCompany
(
1
);
fileDTO
.
setRnrCompanyId
(
companyId
);
fileDTO
.
setFileSystemId
(
corporationCertPic
.
get
(
index
));
fileDTO
.
setCreator
(
dto
.
getCreator
());
fileDTO
.
setOperator
(
dto
.
getCreator
());
fileDTOS
.
add
(
fileDTO
);
}
return
fileDTOS
;
}
@Override
public
void
submitH5
(
RnrRelationDTO
rnrRelationDTO
)
{
rnrRelationDTO
.
getInfo
().
setRnrStatus
(
RnrStatus
.
INIT
.
getCode
());
rnrRelationDTO
.
getInfo
().
setRnrBizzType
(
RnrBizzTypeEnum
.
Bind
.
getCode
());
rnrRelationDTO
.
getOrder
().
setOrderStatus
(
RnrOrderStatusEnum
.
COMMIT
.
getCode
());
rnrRelationDTO
.
getOrder
().
setRnrBizzType
(
RnrBizzTypeEnum
.
Bind
.
getCode
());
rnrRelationDTO
.
getOrder
().
setSendWorkOrder
(
false
);
rnrRelationDTO
.
getCardList
().
forEach
(
card
->
card
.
setRnrStatus
(
RnrStatus
.
INIT
.
getCode
()));
Response
response
=
mgRnrRelationClient
.
saveRnrRelation
(
rnrRelationDTO
);
if
(
response
.
isSuccess
())
{
RnrOrderDTO
message
=
new
RnrOrderDTO
();
message
.
setUuid
(
rnrRelationDTO
.
getOrder
().
getUuid
());
changeOrUnbindIccidsClient
.
sendMSMToMQ
(
message
);
}
}
@Override
public
Integer
personH5CallBack
(
EnterpriseH5CallBackRequestDTO
dto
)
{
if
(
null
==
dto
.
getLivenessPicFileId
()
||
dto
.
getLivenessPicFileId
().
length
!=
2
)
{
throw
new
CuscUserException
(
""
,
"活体照片不是2张"
);
}
//订单号
String
orderNo
=
dto
.
getOrderNo
();
//根据订单号加锁
try
{
boolean
lockStatus
=
cacheFactory
.
getLockService
().
lock
(
RedisConstant
.
RNR_H5_CALLBACK_LOCK
+
orderNo
,
RedisConstant
.
RNR_H5_CALLBACK_LOCK_EXPIRE
);
if
(!
lockStatus
){
throw
new
CuscUserException
(
""
,
"当前有正在处理的实名请求,请勿重复提交"
);
}
}
catch
(
CacheException
e
)
{
log
.
error
(
"personH5CallBack 加锁失败 "
,
e
);
}
RnrOrderDTO
orderQuery
=
new
RnrOrderDTO
();
orderQuery
.
setUuid
(
orderNo
);
Response
<
RnrOrderDTO
>
orderResponse
=
orderClient
.
getByUuid
(
orderQuery
);
if
(!
orderResponse
.
isSuccess
()
||
null
==
orderResponse
.
getData
())
{
throw
new
CuscUserException
(
""
,
"未查询到订单信息"
);
}
RnrOrderDTO
orderDTO
=
orderResponse
.
getData
();
//判断工单是否作废
if
(
orderDTO
.
getOrderStatus
()
!=
null
&&
RnrOrderStatusEnum
.
CANCEL
.
getCode
().
intValue
()
==
orderDTO
.
getOrderStatus
().
intValue
())
{
throw
new
CuscUserException
(
""
,
"实名工单已超时作废,请重新实名"
);
}
if
(
orderDTO
.
getOrderStatus
()
!=
null
&&
RnrOrderStatusEnum
.
NOT_PASS
.
getCode
().
intValue
()
==
orderDTO
.
getOrderStatus
().
intValue
())
{
throw
new
CuscUserException
(
""
,
"实名工单审核不通过,请重新实名"
);
}
if
(
orderDTO
.
getOrderStatus
()
!=
null
&&
RnrOrderStatusEnum
.
ASSIGNMENT
.
getCode
().
intValue
()
==
orderDTO
.
getOrderStatus
().
intValue
())
{
throw
new
CuscUserException
(
""
,
"已有工单在审核中,请等待"
);
}
//实名通过
if
(
orderDTO
.
getOrderStatus
()
!=
null
&&
RnrOrderStatusEnum
.
PASS
.
getCode
()
==
orderDTO
.
getOrderStatus
())
{
return
RnrResultEnum
.
PASS
.
getCode
();
}
String
rnrId
=
orderDTO
.
getRnrId
();
MgRnrInfoDTO
rnrInfoQuery
=
new
MgRnrInfoDTO
();
rnrInfoQuery
.
setUuid
(
rnrId
);
Response
<
MgRnrInfoDTO
>
rnrInfoResponse
=
rnrInfoClient
.
getByUuid
(
rnrInfoQuery
);
if
(!
rnrInfoResponse
.
isSuccess
()
||
null
==
rnrInfoResponse
.
getData
())
{
throw
new
CuscUserException
(
""
,
"未查询到实名信息"
);
}
MgRnrInfoDTO
rnrInfo
=
rnrInfoResponse
.
getData
();
if
(
orderDTO
.
getOrderStatus
()
!=
null
&&
RnrOrderStatusEnum
.
ASSIGNMENT
.
getCode
().
intValue
()
==
orderDTO
.
getOrderStatus
().
intValue
())
{
throw
new
CuscUserException
(
""
,
"已有工单在审核中,请等待"
);
}
String
[]
bestBaseLiveness64
=
new
String
[
2
];
String
[]
bestBaseLiveness64ForFile
=
new
String
[
2
];
AttachmentDTO
attachmentDTO
=
new
AttachmentDTO
();
attachmentDTO
.
setSerialNumber
(
CuscStringUtils
.
generateUuid
());
attachmentDTO
.
setFileId
(
dto
.
getLivenessPicFileId
()[
0
]);
Response
<
AttachmentRespDTO
>
response1
=
cloudService
.
postForResponse
(
CloudMethod
.
ATTACHMENT_DOWNLOAD
,
attachmentDTO
,
AttachmentRespDTO
.
class
);
if
(
response1
.
isSuccess
())
{
AttachmentRespDTO
attachmentRespDTO
=
response1
.
getData
();
bestBaseLiveness64
[
0
]
=
attachmentRespDTO
.
getBase64
();
bestBaseLiveness64
[
1
]
=
attachmentRespDTO
.
getBase64
();
bestBaseLiveness64ForFile
[
0
]=
attachmentRespDTO
.
getBase64
();
}
else
{
throw
new
CuscUserException
(
ResponseCode
.
SYSTEM_ERROR
.
getCode
(),
"下载活体截图失败"
);
}
AttachmentDTO
attachmentDTOForVideo
=
new
AttachmentDTO
();
attachmentDTOForVideo
.
setSerialNumber
(
CuscStringUtils
.
generateUuid
());
attachmentDTOForVideo
.
setFileId
(
dto
.
getVideFileId
());
Response
<
AttachmentRespDTO
>
response3
=
cloudService
.
postForResponse
(
CloudMethod
.
ATTACHMENT_DOWNLOAD
,
attachmentDTOForVideo
,
AttachmentRespDTO
.
class
);
if
(
response3
.
isSuccess
()){
AttachmentRespDTO
attachmentRespDTO
=
response3
.
getData
();
bestBaseLiveness64ForFile
[
1
]=
attachmentRespDTO
.
getBase64
();
}
else
{
log
.
info
(
"活体视频下载失败,orderNo = {}"
,
dto
.
getOrderNo
());
}
RnrRequestDTO
rnrRequestDTO
=
rnrService
.
h5InfoToRnrRequest
(
false
,
orderDTO
,
rnrId
,
rnrInfo
);
RnrResponseDTO
rnrResponseDTO
=
rnrService
.
doPersonRnr
(
rnrRequestDTO
,
bestBaseLiveness64
);
//文件上传
String
best64Img
=
bestBaseLiveness64ForFile
[
0
];
String
best64ImgFileKey
=
""
;
if
(
StringUtils
.
isNotBlank
(
best64Img
)){
best64ImgFileKey
=
fileService
.
upLoadImgBase64
(
best64Img
,
"png"
);
}
String
video
=
bestBaseLiveness64ForFile
[
1
];
String
videoFileKey
=
""
;
if
(
StringUtils
.
isNotBlank
(
video
)){
videoFileKey
=
fileService
.
upLoadFileBase64
(
video
,
"mp4"
);
}
//视屏文件存储
MgRnrFileDTO
videoFile
=
new
MgRnrFileDTO
();
videoFile
.
setUuid
(
CuscStringUtils
.
generateUuid
());
videoFile
.
setRnrId
(
rnrId
);
videoFile
.
setFileType
(
RnrFileType
.
LIVENESS_VIDEO
.
getCode
());
videoFile
.
setFileSystemId
(
videoFileKey
);
videoFile
.
setTenantNo
(
orderDTO
.
getTenantNo
());
videoFile
.
setRoutingKey
(
orderDTO
.
getRoutingKey
());
videoFile
.
setRnrBizzType
(
RnrBizzTypeEnum
.
Bind
.
getCode
());
videoFile
.
setIsCompany
(
1
);
fileClient
.
add
(
videoFile
);
//活体截图1
MgRnrFileDTO
faceFile
=
new
MgRnrFileDTO
();
faceFile
.
setUuid
(
CuscStringUtils
.
generateUuid
());
faceFile
.
setRnrId
(
rnrId
);
faceFile
.
setFileType
(
RnrFileType
.
LIVENESS_SCREEN_FIRST
.
getCode
());
faceFile
.
setFileSystemId
(
best64ImgFileKey
);
faceFile
.
setTenantNo
(
orderDTO
.
getTenantNo
());
faceFile
.
setRoutingKey
(
orderDTO
.
getRoutingKey
());
faceFile
.
setRnrBizzType
(
RnrBizzTypeEnum
.
Bind
.
getCode
());
faceFile
.
setIsCompany
(
1
);
fileClient
.
add
(
faceFile
);
//活体截图1
MgRnrFileDTO
nationFile
=
new
MgRnrFileDTO
();
nationFile
.
setUuid
(
CuscStringUtils
.
generateUuid
());
nationFile
.
setRnrId
(
rnrId
);
nationFile
.
setFileType
(
RnrFileType
.
LIVENESS_SCREEN_TWO
.
getCode
());
nationFile
.
setFileSystemId
(
best64ImgFileKey
);
nationFile
.
setTenantNo
(
orderDTO
.
getTenantNo
());
nationFile
.
setRoutingKey
(
orderDTO
.
getRoutingKey
());
nationFile
.
setRnrBizzType
(
RnrBizzTypeEnum
.
Bind
.
getCode
());
nationFile
.
setIsCompany
(
1
);
fileClient
.
add
(
nationFile
);
RnrOrderDTO
orderUpdate
=
new
RnrOrderDTO
();
orderUpdate
.
setUuid
(
orderDTO
.
getUuid
());
orderUpdate
.
setOrderStatus
(
RnrOrderStatusEnum
.
ASSIGNMENT
.
getCode
());
orderClient
.
update
(
orderUpdate
);
try
{
//发起一个工单'
RnrOrderDTO
workOrder
=
new
RnrOrderDTO
();
workOrder
.
setUuid
(
orderDTO
.
getUuid
());
orderClient
.
startWorkOrder
(
workOrder
);
}
catch
(
Exception
e
)
{
log
.
error
(
"企业H5回调发起工单流程失败:info = {}"
,
JSONObject
.
toJSONString
(
dto
),
e
);
}
try
{
//解锁
cacheFactory
.
getLockService
().
unLock
(
RedisConstant
.
RNR_H5_CALLBACK_LOCK
+
orderNo
);
}
catch
(
CacheException
e
)
{
log
.
error
(
"personH5CallBack 解锁失败 "
,
e
);
}
return
RnrResultEnum
.
REVIEW
.
getCode
();
}
}
Prev
1
…
13
14
15
16
17
18
19
20
21
Next
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