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-openapi
Commits
df1d7dc5
Commit
df1d7dc5
authored
Jun 17, 2025
by
kang.nie@inzymeits.com
Browse files
初始化代码
parent
565dfc9e
Pipeline
#3110
failed with stages
in 0 seconds
Changes
83
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/main/java/com/cusc/nirvana/user/rnr/openapi/service/IChangeTboxService.java
0 → 100644
View file @
df1d7dc5
package
com.cusc.nirvana.user.rnr.openapi.service
;
import
com.cusc.nirvana.common.result.Response
;
import
com.cusc.nirvana.user.rnr.fp.dto.FpRnrSmsInfoDTO
;
import
com.cusc.nirvana.user.rnr.fp.dto.UnbindReceiceSMSDTO
;
import
com.cusc.nirvana.user.rnr.openapi.dto.ChangeTboxDTO
;
public
interface
IChangeTboxService
{
Response
submit
(
ChangeTboxDTO
bean
);
Response
queryResult
(
ChangeTboxDTO
bean
);
Response
receiveMessage
(
UnbindReceiceSMSDTO
bean
);
Response
checkSMSStatus
(
FpRnrSmsInfoDTO
bean
);
}
src/main/java/com/cusc/nirvana/user/rnr/openapi/service/IOrganizationService.java
0 → 100644
View file @
df1d7dc5
package
com.cusc.nirvana.user.rnr.openapi.service
;
import
com.cusc.nirvana.user.rnr.openapi.dto.OrganizationRespDTO
;
import
com.cusc.nirvana.user.rnr.openapi.dto.PagerDTO
;
import
java.util.List
;
/**
* 实名开放平台组织结构接口
*
* @author caow
* @date 2022-05-09
*/
public
interface
IOrganizationService
{
/**
* 获取实名开放平台租户的组织结构
* @param openTenantId 云平台开放平台租户ID
* @param pagerDTO 分页参数
* @return
*/
List
<
OrganizationRespDTO
>
getOrgListByPage
(
String
openTenantId
,
PagerDTO
pagerDTO
);
}
src/main/java/com/cusc/nirvana/user/rnr/openapi/service/IPersonalRnrService.java
0 → 100644
View file @
df1d7dc5
package
com.cusc.nirvana.user.rnr.openapi.service
;
import
com.cusc.nirvana.common.result.Response
;
import
com.cusc.nirvana.user.rnr.fp.dto.LivenessCodeResponseDTO
;
import
com.cusc.nirvana.user.rnr.fp.dto.RnrResponseDTO
;
import
com.cusc.nirvana.user.rnr.mg.dto.RnrRelationDTO
;
import
com.cusc.nirvana.user.rnr.openapi.dto.*
;
import
org.springframework.web.bind.annotation.RequestBody
;
/**
* 个人实名认证服务接口
*
* @author huchenhui
* @date 2022-04-14
*/
public
interface
IPersonalRnrService
{
/**
* 检查参数并转换
*
* @param requestDTO
* @return
*/
Response
<
RnrRelationDTO
>
checkAndConvertToRelation
(
PersonalRnrRequestDTO
requestDTO
,
boolean
unbind
);
}
src/main/java/com/cusc/nirvana/user/rnr/openapi/service/IRnrAuthSearchService.java
0 → 100644
View file @
df1d7dc5
package
com.cusc.nirvana.user.rnr.openapi.service
;
import
com.cusc.nirvana.common.result.Response
;
import
com.cusc.nirvana.user.rnr.openapi.dto.QueryRnAuthDTO
;
import
com.cusc.nirvana.user.rnr.openapi.dto.VinDTO
;
import
com.cusc.nirvana.user.rnr.openapi.dto.response.RnAuthInfoRsp
;
import
com.cusc.nirvana.user.rnr.openapi.dto.response.RnAuthStateRsp
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
javax.validation.Valid
;
import
java.util.List
;
/**
* @author yubo
* @since 2022-06-09 11:04
*/
public
interface
IRnrAuthSearchService
{
Response
<
List
<
RnAuthInfoRsp
>>
getRnrInfoByVin
(
VinDTO
vinDTO
);
Response
<
RnAuthStateRsp
>
getRnAuthState
(
QueryRnAuthDTO
queryRnAuthDTO
);
}
src/main/java/com/cusc/nirvana/user/rnr/openapi/service/ISmsService.java
0 → 100644
View file @
df1d7dc5
package
com.cusc.nirvana.user.rnr.openapi.service
;
import
com.cusc.nirvana.common.result.Response
;
import
com.cusc.nirvana.user.rnr.fp.dto.SmsRequestDTO
;
/**
* Description: 短信service
* <br />
* CreateDate 2022-04-16 15:10:32
*
* @author yuyi
**/
public
interface
ISmsService
{
/**
* Description: 发送实名短信
* <br />
* CreateDate 2022-04-16 15:11:01
*
* @author yuyi
**/
Response
sendSmsRnr
(
SmsRequestDTO
bean
);
//校验验证码
Response
checkSmsCaptcha
(
SmsRequestDTO
bean
);
}
src/main/java/com/cusc/nirvana/user/rnr/openapi/service/IVehicleCardService.java
0 → 100644
View file @
df1d7dc5
package
com.cusc.nirvana.user.rnr.openapi.service
;
import
com.cusc.nirvana.common.result.Response
;
import
com.cusc.nirvana.user.rnr.fp.dto.VerifyVinCardResponseDTO
;
import
com.cusc.nirvana.user.rnr.fp.dto.VinCardDTO
;
import
com.cusc.nirvana.user.rnr.mg.dto.MgRnrCardInfoDTO
;
import
com.cusc.nirvana.user.rnr.openapi.dto.*
;
import
java.util.List
;
/**
* 车卡服务接口
*
* @author yubo
* @since 2022-04-18 09:15
*/
public
interface
IVehicleCardService
{
/**
* 车卡关系和卡校验
*
* @param vinCardListDTO
* @return
*/
Response
<
VerifyVinCardResponseDTO
>
verifyVinCard
(
VinCardInfoDTO
vinCardListDTO
);
/**
* 批量车卡关系和卡校验
*
* @param verifyDTOs
* @return
*/
Response
<
VerifyVinCardResponseDTO
>
verifyVinCardBatch
(
List
<
VinCardDTO
>
verifyDTOs
);
Response
<
List
<
MgRnrCardInfoDTO
>>
getBindsByVinsAndIccids
(
List
<
String
>
vins
,
List
<
String
>
iccids
);
}
src/main/java/com/cusc/nirvana/user/rnr/openapi/service/impl/CardUnBindServiceImpl.java
0 → 100644
View file @
df1d7dc5
package
com.cusc.nirvana.user.rnr.openapi.service.impl
;
import
com.alibaba.fastjson.JSON
;
import
com.cusc.nirvana.common.result.Response
;
import
com.cusc.nirvana.user.rnr.fp.client.CardUnBindClient
;
import
com.cusc.nirvana.user.rnr.fp.client.FpRnrUnbindClient
;
import
com.cusc.nirvana.user.rnr.fp.constants.BizTypeEnum
;
import
com.cusc.nirvana.user.rnr.fp.dto.FpRnrSmsInfoDTO
;
import
com.cusc.nirvana.user.rnr.fp.dto.FpSendMessageDTO
;
import
com.cusc.nirvana.user.rnr.fp.dto.FpVehicleCardRnrDTO
;
import
com.cusc.nirvana.user.rnr.fp.dto.SmsRequestDTO
;
import
com.cusc.nirvana.user.rnr.mg.constants.*
;
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
com.cusc.nirvana.user.rnr.openapi.constants.CustomerTypeEnum
;
import
com.cusc.nirvana.user.rnr.openapi.convert.PersonalRnrRequestConvert
;
import
com.cusc.nirvana.user.rnr.openapi.dto.PersonalRnrDTO
;
import
com.cusc.nirvana.user.rnr.openapi.dto.PersonalRnrRequestDTO
;
import
com.cusc.nirvana.user.rnr.openapi.dto.SecondHandUnbindRequestDTO
;
import
com.cusc.nirvana.user.rnr.openapi.dto.VehicleCardRnrDTO
;
import
com.cusc.nirvana.user.rnr.openapi.service.ICardUnBindService
;
import
com.cusc.nirvana.user.rnr.openapi.service.IPersonalRnrService
;
import
com.cusc.nirvana.user.rnr.openapi.util.UserSubjectUtil
;
import
com.cusc.nirvana.user.util.CuscStringUtils
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.stream.Collectors
;
/**
* 解绑实现类
*
* @author yubo
* @since 2022-04-25 09:32
*/
@Service
@Slf4j
public
class
CardUnBindServiceImpl
implements
ICardUnBindService
{
@Autowired
FpRnrUnbindClient
rnrUnbindClient
;
@Resource
private
CardUnBindClient
cardUnBindClient
;
@Autowired
IPersonalRnrService
personalRnrService
;
/**
* 校验工单状态
*
* @param bean
* @return
*/
@Override
public
Response
checkOrderStatus
(
RnrOrderDTO
bean
)
{
//短信校验
Response
response
=
cardUnBindClient
.
checkMessageOutTime
(
bean
);
if
(!
response
.
isSuccess
())
{
return
response
;
}
Response
<
RnrOrderDTO
>
orderStatus
=
cardUnBindClient
.
getOrderStatus
(
bean
);
if
(!
orderStatus
.
isSuccess
())
{
return
Response
.
createError
(
"获取工单信息失败"
,
orderStatus
.
getData
());
}
return
orderStatus
;
}
/**
* 车主 解绑
*
* @param bean
* @return
*/
@Override
public
Response
originalOwner
(
VehicleCardRnrDTO
bean
)
{
//log.info("自认人解绑入参: {}", JSON.toJSONString(bean));
//校验
FpVehicleCardRnrDTO
fpVehicleCardRnrDTO
=
new
FpVehicleCardRnrDTO
();
fpVehicleCardRnrDTO
.
setVin
(
bean
.
getVin
());
Response
<
List
<
MgRnrCardInfoDTO
>>
cardList
=
cardUnBindClient
.
getCardList
(
fpVehicleCardRnrDTO
);
if
(!
cardList
.
isSuccess
()
||
cardList
.
getData
()
==
null
)
{
//卡未实名或没有绑定在车上
return
Response
.
createError
(
cardList
.
getMsg
(),
cardList
.
getCode
());
}
List
<
MgRnrCardInfoDTO
>
cardDatas
=
cardList
.
getData
();
List
<
String
>
iccidList
=
bean
.
getIccidList
();
List
<
MgRnrCardInfoDTO
>
rnrCardInfoDTOS
=
cardDatas
.
stream
().
filter
(
t
->
iccidList
.
contains
(
t
.
getIccid
())).
collect
(
Collectors
.
toList
());
for
(
MgRnrCardInfoDTO
rnrCardInfoDTO
:
rnrCardInfoDTOS
)
{
rnrCardInfoDTO
.
setRnrStatus
(
RnrStatus
.
UNBOUND
.
getCode
());
}
MgRnrInfoDTO
rnrInfo
=
getRnrInfo
(
bean
);
if
(
rnrInfo
==
null
)
{
return
Response
.
createError
(
"获取实名人员信息失败"
);
}
return
this
.
sendMessage
(
bean
);
}
/**
* 二手车现车主解绑-自然人
*/
@Override
public
Response
secondHandPersonalUnbind
(
SecondHandUnbindRequestDTO
bean
)
{
//调用新车主实名认证接口
PersonalRnrRequestDTO
personalRnrRequestDTO
=
PersonalRnrRequestConvert
.
INSTANCE
.
secondHandUnbindDTOToPersonalRnrDTO
(
bean
);
personalRnrRequestDTO
.
setCustomerType
(
CustomerTypeEnum
.
USED_CAR_OWNER
.
getCode
());
personalRnrRequestDTO
.
setRnrBizzTypeEnum
(
RnrBizzTypeEnum
.
Unbound
.
getCode
());
Response
<
RnrRelationDTO
>
rnrRelationDTOResponse
=
personalRnrService
.
checkAndConvertToRelation
(
personalRnrRequestDTO
,
true
);
if
(!
rnrRelationDTOResponse
.
isSuccess
())
{
return
Response
.
createError
(
rnrRelationDTOResponse
.
getMsg
(),
rnrRelationDTOResponse
.
getCode
());
}
//调用fp接口
RnrRelationDTO
rnrRelationDTO
=
rnrRelationDTOResponse
.
getData
();
//修改order信息
changeOrder
(
rnrRelationDTO
.
getOrder
());
Response
rnrResponse
=
rnrUnbindClient
.
secondHandUnbind
(
rnrRelationDTO
.
getOrder
().
getSerialNumber
(),
bean
.
getRequestId
(),
rnrRelationDTO
);
if
(
rnrResponse
.
isSuccess
())
{
return
Response
.
createSuccess
(
new
PersonalRnrDTO
((
Integer
)
rnrResponse
.
getData
()));
}
return
rnrResponse
;
}
//-----------------------私有方法区
//修改order信息
private
void
changeOrder
(
RnrOrderDTO
order
)
{
order
.
setAuditType
(
RnrOrderAuditTypeEnum
.
MANUAL
.
getCode
());
order
.
setAutoRnr
(
false
);
order
.
setOrderType
(
RnrOrderType
.
SEC_UNBIND
.
getCode
());
order
.
setSendWorkOrder
(
true
);
}
private
RnrOrderDTO
createOrder
(
String
rnrid
,
String
tenNo
,
String
orgId
)
{
RnrOrderDTO
rnrOrderDTO
=
new
RnrOrderDTO
();
rnrOrderDTO
.
setUuid
(
CuscStringUtils
.
generateUuid
());
rnrOrderDTO
.
setOrderType
(
RnrOrderType
.
UNBIND
.
getCode
());
rnrOrderDTO
.
setRnrId
(
rnrid
);
rnrOrderDTO
.
setAuditType
(
RnrOrderAuditTypeEnum
.
AUTO
.
getCode
());
rnrOrderDTO
.
setAutoRnr
(
true
);
rnrOrderDTO
.
setIsBatchOrder
(
1
);
rnrOrderDTO
.
setSerialNumber
(
CuscStringUtils
.
generateUuid
());
rnrOrderDTO
.
setOrderSource
(
RnrOrderSourceEnum
.
API
.
getCode
());
rnrOrderDTO
.
setCreator
(
UserSubjectUtil
.
getUserId
());
rnrOrderDTO
.
setOperator
(
UserSubjectUtil
.
getUserId
());
rnrOrderDTO
.
setTenantNo
(
tenNo
);
rnrOrderDTO
.
setOrderStatus
(
RnrOrderStatusEnum
.
ASSIGNMENT
.
getCode
());
rnrOrderDTO
.
setOrgId
(
orgId
);
return
rnrOrderDTO
;
}
private
MgRnrInfoDTO
getRnrInfo
(
VehicleCardRnrDTO
bean
)
{
log
.
info
(
"获取实名人员信息入参: {}"
,
JSON
.
toJSONString
(
bean
));
//获取人员信息
FpVehicleCardRnrDTO
fpVehicleCardRnrDTO
=
new
FpVehicleCardRnrDTO
();
fpVehicleCardRnrDTO
.
setRnrId
(
bean
.
getRnrId
());
log
.
info
(
"获取实名人员信息转换参数: {}"
,
JSON
.
toJSONString
(
fpVehicleCardRnrDTO
));
Response
<
MgRnrInfoDTO
>
rnrInfo
=
cardUnBindClient
.
getRnrInfo
(
fpVehicleCardRnrDTO
);
if
(!
rnrInfo
.
isSuccess
())
{
return
null
;
}
return
rnrInfo
.
getData
();
}
/**
* 发送短信
*
* @param bean
* @return
*/
@Override
public
Response
sendMessage
(
VehicleCardRnrDTO
bean
)
{
log
.
info
(
"自然人解绑短信发送入参: {}"
,
JSON
.
toJSONString
(
bean
));
MgRnrInfoDTO
rnrInfoData
=
getRnrInfo
(
bean
);
if
(
rnrInfoData
==
null
)
{
return
Response
.
createError
(
"实名信息为空"
);
}
RnrOrderDTO
order
=
this
.
createOrder
(
rnrInfoData
.
getUuid
(),
rnrInfoData
.
getTenantNo
(),
bean
.
getOrgId
());
//插入工单信息
Response
<
RnrOrderDTO
>
rnrOrderDTOResponse
=
cardUnBindClient
.
insertOrder
(
order
);
if
(!
rnrOrderDTOResponse
.
isSuccess
()
||
rnrOrderDTOResponse
.
getData
()
==
null
)
{
return
Response
.
createError
(
rnrOrderDTOResponse
.
getMsg
(),
rnrOrderDTOResponse
.
getData
());
}
//配置短信参数
List
<
String
>
paramsList
=
new
ArrayList
<>();
/*if (rnrInfoData.getGender() == 0) {
paramsList.add(rnrInfoData.getFullName() + "女士");
} else {
paramsList.add(rnrInfoData.getFullName() + "先生");
}*/
paramsList
.
add
(
rnrInfoData
.
getFullName
()
+
"女士/先生"
);
paramsList
.
add
(
bean
.
getVin
());
//拼接iccid参数列表
String
iccIdList
=
""
;
for
(
String
iccid
:
bean
.
getIccidList
())
{
iccIdList
+=
iccid
+
","
;
}
String
subIccIdList
=
iccIdList
.
substring
(
0
,
iccIdList
.
length
()
-
1
);
paramsList
.
add
(
subIccIdList
);
SmsRequestDTO
smsRequestDTO
=
new
SmsRequestDTO
();
smsRequestDTO
.
setBizType
(
BizTypeEnum
.
UNBOUND
.
getCode
());
smsRequestDTO
.
setParams
(
paramsList
);
smsRequestDTO
.
setPhone
(
rnrInfoData
.
getPhone
());
FpSendMessageDTO
fpSendMessageDTO
=
new
FpSendMessageDTO
();
fpSendMessageDTO
.
setRnrid
(
bean
.
getRnrId
());
fpSendMessageDTO
.
setUser
(
rnrInfoData
.
getCreator
());
fpSendMessageDTO
.
setIccidLists
(
subIccIdList
);
fpSendMessageDTO
.
setSmsRequestDTO
(
smsRequestDTO
);
fpSendMessageDTO
.
setOrderId
(
rnrOrderDTOResponse
.
getData
().
getUuid
());
//发送短信
Response
<
FpRnrSmsInfoDTO
>
fpRnrSmsInfoDTOResponse
=
cardUnBindClient
.
sendSms
(
fpSendMessageDTO
);
if
(!
fpRnrSmsInfoDTOResponse
.
isSuccess
()
&&
fpRnrSmsInfoDTOResponse
.
getData
()
==
null
)
{
return
Response
.
createError
(
"短信发送失败"
,
fpRnrSmsInfoDTOResponse
.
getCode
());
}
else
{
return
Response
.
createSuccess
(
"短信发送成功"
,
rnrOrderDTOResponse
.
getData
());
}
}
}
src/main/java/com/cusc/nirvana/user/rnr/openapi/service/impl/ChangeTboxServiceImpl.java
0 → 100644
View file @
df1d7dc5
package
com.cusc.nirvana.user.rnr.openapi.service.impl
;
import
com.alibaba.fastjson.JSON
;
import
com.cusc.nirvana.common.result.Response
;
import
com.cusc.nirvana.user.rnr.fp.client.CardUnBindClient
;
import
com.cusc.nirvana.user.rnr.fp.client.ChangeTboxClient
;
import
com.cusc.nirvana.user.rnr.fp.dto.FpDirectTboxChangeDTO
;
import
com.cusc.nirvana.user.rnr.fp.dto.FpRnrSmsInfoDTO
;
import
com.cusc.nirvana.user.rnr.fp.dto.FpVehicleCardRnrDTO
;
import
com.cusc.nirvana.user.rnr.fp.dto.UnbindReceiceSMSDTO
;
import
com.cusc.nirvana.user.rnr.mg.client.RnrOrderClient
;
import
com.cusc.nirvana.user.rnr.mg.constants.*
;
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
com.cusc.nirvana.user.rnr.openapi.dto.ChangeTboxDTO
;
import
com.cusc.nirvana.user.rnr.openapi.dto.IccidChangeDTO
;
import
com.cusc.nirvana.user.rnr.openapi.service.IChangeTboxService
;
import
com.cusc.nirvana.user.rnr.openapi.util.UserSubjectUtil
;
import
com.cusc.nirvana.user.util.CuscStringUtils
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.CollectionUtils
;
import
javax.annotation.Resource
;
import
java.util.*
;
/**
* @author changh
* @date 2022/4/24
*/
@Service
@Slf4j
public
class
ChangeTboxServiceImpl
implements
IChangeTboxService
{
@Resource
private
CardUnBindClient
cardUnBindClient
;
@Resource
private
RnrOrderClient
orderClient
;
@Resource
private
ChangeTboxClient
changeTboxClient
;
@Override
public
Response
submit
(
ChangeTboxDTO
bean
)
{
log
.
info
(
"换卡入参:{}"
,
JSON
.
toJSONString
(
bean
));
Map
<
String
,
String
>
newOldRelMap
=
new
HashMap
<>();
for
(
IccidChangeDTO
changeDTO
:
bean
.
getIccidList
())
{
newOldRelMap
.
put
(
changeDTO
.
getNewIccid
(),
changeDTO
.
getOldIccid
());
}
//校验新的iccid
Response
<
Boolean
>
checkStatus
=
changeTboxClient
.
checkStatus
(
new
ArrayList
<>(
newOldRelMap
.
keySet
()));
log
.
info
(
"校验新车卡出参:{}"
,
JSON
.
toJSONString
(
checkStatus
));
if
(!
checkStatus
.
isSuccess
()
||
!
checkStatus
.
getData
())
{
return
Response
.
createError
(
"换卡iccid状态为已实名"
);
}
return
this
.
changeTBox
(
bean
,
newOldRelMap
);
}
private
MgRnrInfoDTO
getRnrInfo
(
ChangeTboxDTO
bean
)
{
//获取人员信息
FpVehicleCardRnrDTO
fpVehicleCardRnrDTO
=
new
FpVehicleCardRnrDTO
();
fpVehicleCardRnrDTO
.
setVin
(
bean
.
getVin
());
Response
<
List
<
MgRnrCardInfoDTO
>>
cardList
=
cardUnBindClient
.
getCardList
(
fpVehicleCardRnrDTO
);
if
(!
cardList
.
isSuccess
()
||
CollectionUtils
.
isEmpty
(
cardList
.
getData
()))
{
return
null
;
}
FpVehicleCardRnrDTO
vehicleCardRnrDTO
=
new
FpVehicleCardRnrDTO
();
vehicleCardRnrDTO
.
setRnrId
(
cardList
.
getData
().
get
(
0
).
getRnrId
());
Response
<
MgRnrInfoDTO
>
rnrInfo
=
cardUnBindClient
.
getRnrInfo
(
vehicleCardRnrDTO
);
if
(!
rnrInfo
.
isSuccess
())
{
return
null
;
}
return
rnrInfo
.
getData
();
}
private
RnrRelationDTO
turnParams
(
List
<
String
>
oldIccids
,
List
<
String
>
newIccids
,
String
vin
,
String
rnrid
,
String
tenNo
,
String
orgId
)
{
RnrRelationDTO
rnrRelationDTO
=
new
RnrRelationDTO
();
String
uuid
=
CuscStringUtils
.
generateUuid
();
RnrOrderDTO
order
=
createOrder
(
rnrid
,
tenNo
,
orgId
,
uuid
);
List
<
MgRnrCardInfoDTO
>
cardInfoDTOS
=
new
ArrayList
<>();
List
<
MgRnrCardInfoDTO
>
oldCardInfoDTOS
=
createCardInfoDTOS
(
oldIccids
,
tenNo
,
vin
,
rnrid
,
order
.
getUuid
());
List
<
MgRnrCardInfoDTO
>
newCardInfoDTOS
=
createCardInfoDTOS
(
newIccids
,
tenNo
,
vin
,
rnrid
,
order
.
getUuid
());
cardInfoDTOS
.
addAll
(
oldCardInfoDTOS
);
cardInfoDTOS
.
addAll
(
newCardInfoDTOS
);
rnrRelationDTO
.
setOrder
(
order
);
rnrRelationDTO
.
setCardList
(
cardInfoDTOS
);
return
rnrRelationDTO
;
}
private
RnrOrderDTO
createOrder
(
String
rnrid
,
String
tenNo
,
String
orgId
,
String
uuid
)
{
RnrOrderDTO
rnrOrderDTO
=
new
RnrOrderDTO
();
rnrOrderDTO
.
setUuid
(
uuid
);
rnrOrderDTO
.
setRnrBizzType
(
RnrBizzTypeEnum
.
ChangeBinding
.
getCode
());
rnrOrderDTO
.
setOrderType
(
RnrOrderType
.
TBOX_CHANGE
.
getCode
());
rnrOrderDTO
.
setRnrId
(
rnrid
);
rnrOrderDTO
.
setAuditType
(
RnrOrderAuditTypeEnum
.
AUTO
.
getCode
());
rnrOrderDTO
.
setAutoRnr
(
true
);
rnrOrderDTO
.
setIsBatchOrder
(
1
);
rnrOrderDTO
.
setSerialNumber
(
CuscStringUtils
.
generateUuid
());
rnrOrderDTO
.
setOrderSource
(
RnrOrderSourceEnum
.
API
.
getCode
());
rnrOrderDTO
.
setCreator
(
UserSubjectUtil
.
getUserId
());
rnrOrderDTO
.
setOperator
(
UserSubjectUtil
.
getUserId
());
rnrOrderDTO
.
setTenantNo
(
tenNo
);
rnrOrderDTO
.
setOrderStatus
(
RnrOrderStatusEnum
.
TO_EXAMINE
.
getCode
());
rnrOrderDTO
.
setOrgId
(
orgId
);
return
rnrOrderDTO
;
}
private
List
<
MgRnrCardInfoDTO
>
createCardInfoDTOS
(
List
<
String
>
iccidList
,
String
tenNo
,
String
vin
,
String
rnrid
,
String
uuid
)
{
List
<
MgRnrCardInfoDTO
>
cardInfoDTOS
=
new
ArrayList
<>();
for
(
String
iccid
:
iccidList
)
{
MgRnrCardInfoDTO
mgRnrCardInfoDTO
=
new
MgRnrCardInfoDTO
();
mgRnrCardInfoDTO
.
setUuid
(
CuscStringUtils
.
generateUuid
());
mgRnrCardInfoDTO
.
setIccid
(
iccid
);
mgRnrCardInfoDTO
.
setTenantNo
(
tenNo
);
mgRnrCardInfoDTO
.
setIotId
(
vin
);
mgRnrCardInfoDTO
.
setRnrId
(
rnrid
);
mgRnrCardInfoDTO
.
setOrderId
(
uuid
);
mgRnrCardInfoDTO
.
setCreator
(
UserSubjectUtil
.
getUserId
());
mgRnrCardInfoDTO
.
setOperator
(
UserSubjectUtil
.
getUserId
());
mgRnrCardInfoDTO
.
setRnrBizzType
(
RnrBizzTypeEnum
.
ChangeBinding
.
getCode
());
cardInfoDTOS
.
add
(
mgRnrCardInfoDTO
);
}
return
cardInfoDTOS
;
}
@Override
public
Response
queryResult
(
ChangeTboxDTO
bean
)
{
//1.通过submit方法响应的新的rnrId查询业务结果
return
Response
.
createSuccess
(
true
);
}
private
Response
changeTBox
(
ChangeTboxDTO
bean
,
Map
<
String
,
String
>
newOldRelMap
)
{
log
.
info
(
"换卡入参:{}"
,
JSON
.
toJSONString
(
bean
));
MgRnrInfoDTO
rnrInfoData
=
getRnrInfo
(
bean
);
if
(
rnrInfoData
==
null
)
{
return
Response
.
createError
(
"通过vin无法查询到此车实名信息"
);
}
String
uuid
=
CuscStringUtils
.
generateUuid
();
RnrOrderDTO
order
=
createOrder
(
rnrInfoData
.
getUuid
(),
rnrInfoData
.
getTenantNo
(),
bean
.
getOrgId
(),
uuid
);
//工单入库
orderClient
.
add
(
order
);
//更改逻辑
FpDirectTboxChangeDTO
tboxChangeDTO
=
new
FpDirectTboxChangeDTO
();
tboxChangeDTO
.
setNewOldIccidRelMap
(
newOldRelMap
);
tboxChangeDTO
.
setOperator
(
order
.
getOperator
());
tboxChangeDTO
.
setOrderUuid
(
order
.
getUuid
());
tboxChangeDTO
.
setRnrId
(
order
.
getRnrId
());
tboxChangeDTO
.
setRoutingKey
(
order
.
getRoutingKey
());
tboxChangeDTO
.
setTenantNo
(
order
.
getTenantNo
());
tboxChangeDTO
.
setVin
(
bean
.
getVin
());
Response
changeRsp
=
changeTboxClient
.
directChangeBox
(
tboxChangeDTO
);
if
(!
changeRsp
.
isSuccess
())
{
return
Response
.
createError
(
changeRsp
.
getMsg
(),
changeRsp
.
getData
());
}
RnrOrderDTO
rnrOrderDTO
=
new
RnrOrderDTO
();
rnrOrderDTO
.
setUuid
(
uuid
);
rnrOrderDTO
.
setOrderStatus
(
RnrOrderStatusEnum
.
PASS
.
getCode
());
orderClient
.
updateOrderStatus
(
rnrOrderDTO
);
return
Response
.
createSuccess
(
"车机更换成功"
,
changeRsp
.
getMsg
());
}
//短信回调接口
@Override
public
Response
receiveMessage
(
UnbindReceiceSMSDTO
bean
)
{
log
.
info
(
"换卡短信回调入参:{}"
,
JSON
.
toJSONString
(
bean
));
return
cardUnBindClient
.
receiveMessage
(
bean
);
}
@Override
public
Response
checkSMSStatus
(
FpRnrSmsInfoDTO
bean
)
{
log
.
info
(
"换卡校验短信状态入参:{}"
,
JSON
.
toJSONString
(
bean
));
Response
<
FpRnrSmsInfoDTO
>
messageStatus
=
cardUnBindClient
.
getMessageStatus
(
bean
);
if
(!
messageStatus
.
isSuccess
()
||
messageStatus
.
getData
()
==
null
)
{
return
Response
.
createError
(
"获取短信失败"
);
}
long
currentTimeMillis
=
System
.
currentTimeMillis
();
//校验时间2分钟内
Date
createTime
=
messageStatus
.
getData
().
getCreateTime
();
long
startTime
=
createTime
.
getTime
();
if
(
currentTimeMillis
-
120
*
1000
>
startTime
)
{
return
Response
.
createError
(
"短信获取超时"
);
}
//校验内容
if
(!
messageStatus
.
getData
().
getReceiveContent
().
toLowerCase
().
equals
(
"y"
))
{
return
Response
.
createError
(
"短信回复为N"
);
}
return
Response
.
createSuccess
(
"短信校验通过"
);
}
}
src/main/java/com/cusc/nirvana/user/rnr/openapi/service/impl/OrganizationServiceImpl.java
0 → 100644
View file @
df1d7dc5
package
com.cusc.nirvana.user.rnr.openapi.service.impl
;
import
com.cusc.nirvana.common.result.PageResult
;
import
com.cusc.nirvana.common.result.Response
;
import
com.cusc.nirvana.user.eiam.client.OrganizationClient
;
import
com.cusc.nirvana.user.eiam.dto.OrganizationDTO
;
import
com.cusc.nirvana.user.rnr.openapi.convert.OrganizationRespConvert
;
import
com.cusc.nirvana.user.rnr.openapi.dto.OrganizationRespDTO
;
import
com.cusc.nirvana.user.rnr.openapi.dto.PagerDTO
;
import
com.cusc.nirvana.user.rnr.openapi.service.IOrganizationService
;
import
org.apache.logging.log4j.util.Strings
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.stream.Collectors
;
@Service
public
class
OrganizationServiceImpl
implements
IOrganizationService
{
@Autowired
private
OrganizationClient
organizationClient
;
@Override
public
List
<
OrganizationRespDTO
>
getOrgListByPage
(
String
tenantNo
,
PagerDTO
pagerDTO
)
{
List
<
OrganizationRespDTO
>
orgRespList
=
new
ArrayList
<>();
if
(
tenantNo
==
null
||
tenantNo
.
equals
(
Strings
.
EMPTY
))
{
return
orgRespList
;
}
// 通过实名开放平台租户ID,获取组织结构
OrganizationDTO
dto
=
new
OrganizationDTO
();
dto
.
setTenantNo
(
tenantNo
);
dto
.
setCurrPage
(
pagerDTO
.
getCurrPage
());
dto
.
setPageSize
(
pagerDTO
.
getPageSize
());
Response
<
PageResult
<
OrganizationDTO
>>
orgListResponse
=
organizationClient
.
queryByPage
(
dto
);
if
(
orgListResponse
!=
null
&&
orgListResponse
.
getData
()
!=
null
)
{
orgRespList
=
orgListResponse
.
getData
()
.
getList
()
.
stream
()
.
map
(
ret
->
OrganizationRespConvert
.
INSTANCE
.
convert
(
ret
))
.
collect
(
Collectors
.
toList
());
}
return
orgRespList
;
}
}
src/main/java/com/cusc/nirvana/user/rnr/openapi/service/impl/PersonalRnrServiceImpl.java
0 → 100644
View file @
df1d7dc5
package
com.cusc.nirvana.user.rnr.openapi.service.impl
;
import
com.alibaba.fastjson.JSON
;
import
com.cusc.nirvana.common.result.Response
;
import
com.cusc.nirvana.user.rnr.fp.client.CardUnBindClient
;
import
com.cusc.nirvana.user.rnr.fp.client.FpRnrClient
;
import
com.cusc.nirvana.user.rnr.fp.client.VinCardClient
;
import
com.cusc.nirvana.user.rnr.fp.common.ResponseCode
;
import
com.cusc.nirvana.user.rnr.mg.client.MgRnrRelationClient
;
import
com.cusc.nirvana.user.rnr.mg.constants.*
;
import
com.cusc.nirvana.user.rnr.mg.dto.*
;
import
com.cusc.nirvana.user.rnr.openapi.constants.CustomerTypeEnum
;
import
com.cusc.nirvana.user.rnr.openapi.constants.IdentifyConstants
;
import
com.cusc.nirvana.user.rnr.openapi.convert.PersonalRnrRequestConvert
;
import
com.cusc.nirvana.user.rnr.openapi.dto.*
;
import
com.cusc.nirvana.user.rnr.openapi.service.IPersonalRnrService
;
import
com.cusc.nirvana.user.rnr.openapi.service.IVehicleCardService
;
import
com.cusc.nirvana.user.rnr.openapi.util.FileUtil
;
import
com.cusc.nirvana.user.rnr.openapi.util.SpringValidationUtil
;
import
com.cusc.nirvana.user.rnr.openapi.util.UserSubjectUtil
;
import
com.cusc.nirvana.user.rnr.openapi.util.ValidationUtil
;
import
com.cusc.nirvana.user.util.CuscStringUtils
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.CollectionUtils
;
import
javax.annotation.Resource
;
import
javax.validation.ConstraintViolation
;
import
java.util.*
;
import
java.util.stream.Collectors
;
/**
* 个人实名信息
*
* @author **
*/
@Service
@Slf4j
public
class
PersonalRnrServiceImpl
implements
IPersonalRnrService
{
@Autowired
IVehicleCardService
vehicleCardService
;
@Autowired
SmsServiceImpl
smsService
;
@Autowired
FpRnrClient
fpRnrClient
;
@Autowired
MgRnrRelationClient
mgRnrRelationClient
;
@Autowired
VinCardClient
vinCardClient
;
@Autowired
CardUnBindClient
cardUnBindClient
;
/**
* 检查参数并转换
*
* @param requestDTO
* @return
*/
@Override
public
Response
<
RnrRelationDTO
>
checkAndConvertToRelation
(
PersonalRnrRequestDTO
requestDTO
,
boolean
unbind
)
{
log
.
info
(
"Param checkAndConvertToRelation:{}"
,
JSON
.
toJSONString
(
requestDTO
));
//参数必填校验
Response
response
=
validRnrInfo
(
requestDTO
,
unbind
);
if
(!
response
.
isSuccess
())
{
if
(
StringUtils
.
equals
(
response
.
getMsg
(),
ResponseCode
.
INVALID_DATA
.
getMsg
()))
{
//返回第一个错误
return
Response
.
createError
(((
PersonalRnrResponseDTO
)
response
.
getData
()).
getResponseMsg
().
get
(
0
),
response
.
getCode
());
}
return
Response
.
createError
(
response
.
getMsg
(),
response
.
getCode
());
}
return
Response
.
createSuccess
(
convertToRelationDTO
(
requestDTO
));
}
/**
* 转成实名信息
*
* @param requestDTO 请求消息
*/
private
RnrRelationDTO
convertToRelationDTO
(
PersonalRnrRequestDTO
requestDTO
)
{
String
rnrID
=
CuscStringUtils
.
generateUuid
();
RnrRelationDTO
rnrRelationDTO
=
new
RnrRelationDTO
();
rnrRelationDTO
.
setRequestId
(
requestDTO
.
getRequestId
());
String
tenantNo
=
UserSubjectUtil
.
getTenantNo
();
//租户
rnrRelationDTO
.
setTenantNo
(
tenantNo
);
rnrRelationDTO
.
setIsTrust
(
requestDTO
.
getIsConsigner
()
?
1
:
0
);
rnrRelationDTO
.
setIsSecondHandCar
(
null
!=
requestDTO
.
getCustomerType
()
&&
requestDTO
.
getCustomerType
()
==
1
?
1
:
0
);
//实名实体信息
rnrRelationDTO
.
setInfo
(
getMgRnrInfoDTO
(
requestDTO
,
rnrID
));
//实名工单信息
rnrRelationDTO
.
setOrder
(
getMgRnrOrderDTO
(
requestDTO
,
rnrRelationDTO
));
rnrRelationDTO
.
getOrder
().
setTenantNo
(
tenantNo
);
//实名卡信息
rnrRelationDTO
.
setCardList
(
getMgRnrCardDTOs
(
requestDTO
,
rnrRelationDTO
));
//联系人信息
if
(
requestDTO
.
getIsConsigner
())
{
rnrRelationDTO
.
setRnrLiaisonList
(
getMgRnrLiaisonDTOs
(
requestDTO
,
rnrRelationDTO
));
}
//实名文件信息
rnrRelationDTO
.
setRnrFileList
(
getMgRnrFileDTOs
(
requestDTO
,
rnrRelationDTO
));
rnrRelationDTO
.
setSerialNumber
(
requestDTO
.
getSerialNumber
());
return
rnrRelationDTO
;
}
/**
* 创建工单信息
*
* @param requestDTO 请求消息
* @param rnrRelationDTO 实名消息
*/
private
RnrOrderDTO
getMgRnrOrderDTO
(
PersonalRnrRequestDTO
requestDTO
,
RnrRelationDTO
rnrRelationDTO
)
{
//二手车、或者证书类型不是身份证都是手工
//boolean sendWorkOrder = isSendWorkOrder(requestDTO);
boolean
isSecondHandCar
=
rnrRelationDTO
.
getIsSecondHandCar
()
==
1
;
RnrOrderDTO
rnrOrderDTO
=
new
RnrOrderDTO
();
rnrOrderDTO
.
setUuid
(
CuscStringUtils
.
generateUuid
());
rnrOrderDTO
.
setOrderType
(
isSecondHandCar
?
RnrOrderType
.
SEC_VEHICLE
.
getCode
()
:
RnrOrderType
.
NEW_VEHICLE
.
getCode
());
rnrOrderDTO
.
setRnrId
(
rnrRelationDTO
.
getInfo
().
getUuid
());
//rnrOrderDTO.setAuditType(sendWorkOrder ? RnrOrderAuditTypeEnum.MANUAL.getCode() : RnrOrderAuditTypeEnum.AUTO.getCode());
rnrOrderDTO
.
setAuditType
(
RnrOrderAuditTypeEnum
.
AUTO
.
getCode
());
rnrOrderDTO
.
setTenantNo
(
UserSubjectUtil
.
getTenantNo
());
rnrOrderDTO
.
setAutoRnr
(
true
);
rnrOrderDTO
.
setIsBatchOrder
(
0
);
rnrOrderDTO
.
setSerialNumber
(
rnrRelationDTO
.
getInfo
().
getSerial_number
());
rnrOrderDTO
.
setOrderSource
(
RnrOrderSourceEnum
.
API
.
getCode
());
rnrOrderDTO
.
setCreator
(
UserSubjectUtil
.
getUserId
());
rnrOrderDTO
.
setOperator
(
UserSubjectUtil
.
getUserId
());
rnrOrderDTO
.
setSendWorkOrder
(
false
);
//rnrOrderDTO.setOrderStatus(sendWorkOrder ? RnrOrderStatusEnum.ASSIGNMENT.getCode() : RnrOrderStatusEnum.PASS.getCode());
rnrOrderDTO
.
setOrderStatus
(
RnrOrderStatusEnum
.
PASS
.
getCode
());
rnrOrderDTO
.
setRnrBizzType
(
requestDTO
.
getRnrBizzTypeEnum
());
rnrOrderDTO
.
setOrgId
(
requestDTO
.
getOrgId
());
return
rnrOrderDTO
;
}
/**
* 判断是否是是否需要发送工单
*
* @param requestDTO
* @return
*/
// private boolean isSendWorkOrder(PersonalRnrRequestDTO requestDTO) {
// //二手车实名,委托人模式,新车车主非身份证模式都需要发送工单
// return requestDTO.getCustomerType() == CustomerTypeEnum.USED_CAR_OWNER.getCode()
// || requestDTO.getIsConsigner()
// || !StringUtils.equalsIgnoreCase(requestDTO.getCertType(), CertTypeEnum.IDCARD.getCode());
// }
/**
* 获取联系人信息
*
* @param requestDTO 请求消息
*/
private
List
<
MgRnrLiaisonInfoDTO
>
getMgRnrLiaisonDTOs
(
PersonalRnrRequestDTO
requestDTO
,
RnrRelationDTO
rnrRelationDTO
)
{
List
<
MgRnrLiaisonInfoDTO
>
liaisonInfoDTOS
=
new
ArrayList
<>();
ConsignerInfoDTO
consignerInfo
=
requestDTO
.
getConsignerInfo
();
MgRnrLiaisonInfoDTO
mgRnrLiaisonInfoDTO
=
new
MgRnrLiaisonInfoDTO
();
mgRnrLiaisonInfoDTO
.
setLiaisonName
(
consignerInfo
.
getFullName
());
mgRnrLiaisonInfoDTO
.
setLiaisonPhone
(
consignerInfo
.
getPhone
());
mgRnrLiaisonInfoDTO
.
setLiaisonCertAddress
(
consignerInfo
.
getCertAddress
());
mgRnrLiaisonInfoDTO
.
setLiaisonCertNumber
(
consignerInfo
.
getCertNumber
());
mgRnrLiaisonInfoDTO
.
setLiaisonCertType
(
consignerInfo
.
getCertType
());
mgRnrLiaisonInfoDTO
.
setLiaisonContactAddress
(
consignerInfo
.
getContactAddress
());
mgRnrLiaisonInfoDTO
.
setLiaisonType
(
RnrLiaisonType
.
CONSIGNEE
.
getCode
());
mgRnrLiaisonInfoDTO
.
setTenantNo
(
UserSubjectUtil
.
getTenantNo
());
mgRnrLiaisonInfoDTO
.
setUuid
(
CuscStringUtils
.
generateUuid
());
mgRnrLiaisonInfoDTO
.
setRnrId
(
rnrRelationDTO
.
getInfo
().
getUuid
());
mgRnrLiaisonInfoDTO
.
setOperator
(
UserSubjectUtil
.
getUserId
());
mgRnrLiaisonInfoDTO
.
setCreator
(
UserSubjectUtil
.
getUserId
());
mgRnrLiaisonInfoDTO
.
setRnrBizzType
(
requestDTO
.
getRnrBizzTypeEnum
());
mgRnrLiaisonInfoDTO
.
setLiaisonGender
(
StringUtils
.
isEmpty
(
consignerInfo
.
getGender
())?
null
:
Integer
.
valueOf
(
consignerInfo
.
getGender
()));
mgRnrLiaisonInfoDTO
.
setLiaisonExpiredDate
(
consignerInfo
.
getCertExpirationDate
());
liaisonInfoDTOS
.
add
(
mgRnrLiaisonInfoDTO
);
return
liaisonInfoDTOS
;
}
/**
* 获取实名文件信息
*
* @param requestDTO 请求消息
*/
private
List
<
MgRnrFileDTO
>
getMgRnrFileDTOs
(
PersonalRnrRequestDTO
requestDTO
,
RnrRelationDTO
rnrRelationDTO
)
{
List
<
MgRnrFileDTO
>
mgRnrFileDTOS
=
new
ArrayList
<>();
String
rnrId
=
rnrRelationDTO
.
getInfo
().
getUuid
();
int
rnrBizzTypeEnum
=
requestDTO
.
getRnrBizzTypeEnum
();
//证件照片
List
<
String
>
certPic
=
requestDTO
.
getCertPic
();
for
(
int
i
=
0
;
i
<
certPic
.
size
();
i
++)
{
String
pic
=
certPic
.
get
(
i
);
Integer
fileType
=
FileUtil
.
getFileType
(
requestDTO
.
getCertType
(),
i
);
if
(
fileType
!=
null
)
{
mgRnrFileDTOS
.
add
(
FileUtil
.
newFileDTO
(
rnrId
,
pic
,
fileType
,
rnrBizzTypeEnum
));
}
}
if
(
requestDTO
.
getIsConsigner
())
{
String
consignerId
=
rnrRelationDTO
.
getRnrLiaisonList
().
get
(
0
).
getUuid
();
//委托人照片
List
<
String
>
consignerPic
=
requestDTO
.
getConsignerInfo
().
getCertPic
();
for
(
int
i
=
0
;
i
<
consignerPic
.
size
();
i
++)
{
String
pic
=
consignerPic
.
get
(
i
);
Integer
fileType
=
FileUtil
.
getFileType
(
requestDTO
.
getConsignerInfo
().
getCertType
(),
i
);
mgRnrFileDTOS
.
add
(
FileUtil
.
newFileDTO
(
rnrId
,
pic
,
fileType
,
consignerId
,
rnrBizzTypeEnum
));
}
//委托书
for
(
String
attorney
:
requestDTO
.
getConsignerInfo
().
getAttorneyLetterPic
())
{
mgRnrFileDTOS
.
add
(
FileUtil
.
newFileDTO
(
rnrId
,
attorney
,
RnrFileType
.
LETTER_ATTORNEY
.
getCode
(),
consignerId
,
rnrBizzTypeEnum
));
}
//活体视频
if
(
StringUtils
.
isNotBlank
(
requestDTO
.
getLiveVerificationVideo
()))
{
mgRnrFileDTOS
.
add
(
FileUtil
.
newFileDTO
(
rnrId
,
requestDTO
.
getLiveVerificationVideo
(),
RnrFileType
.
LIVENESS_VIDEO
.
getCode
(),
consignerId
,
rnrBizzTypeEnum
));
}
}
else
{
//活体视频
if
(
StringUtils
.
isNotBlank
(
requestDTO
.
getLiveVerificationVideo
()))
{
mgRnrFileDTOS
.
add
(
FileUtil
.
newFileDTO
(
rnrId
,
requestDTO
.
getLiveVerificationVideo
(),
RnrFileType
.
LIVENESS_VIDEO
.
getCode
(),
rnrBizzTypeEnum
));
}
}
//二手车,购车合同,购车发票,过户合同
if
(
null
!=
requestDTO
.
getCustomerType
()
&&
requestDTO
.
getCustomerType
()
==
CustomerTypeEnum
.
USED_CAR_OWNER
.
getCode
())
{
if
(!
CollectionUtils
.
isEmpty
(
requestDTO
.
getPurchaseInvoicePic
()))
{
for
(
String
invoice
:
requestDTO
.
getPurchaseInvoicePic
())
{
mgRnrFileDTOS
.
add
(
FileUtil
.
newFileDTO
(
rnrId
,
invoice
,
RnrFileType
.
CAR_PURCHASE_INVOICE
.
getCode
(),
rnrBizzTypeEnum
));
}
}
for
(
String
contract
:
requestDTO
.
getPurchaseContractPic
())
{
mgRnrFileDTOS
.
add
(
FileUtil
.
newFileDTO
(
rnrId
,
contract
,
RnrFileType
.
CAR_PURCHASE_CONTRACT
.
getCode
(),
rnrBizzTypeEnum
));
}
for
(
String
transfer
:
requestDTO
.
getTransferCertificatePic
())
{
mgRnrFileDTOS
.
add
(
FileUtil
.
newFileDTO
(
rnrId
,
transfer
,
RnrFileType
.
CAR_TRANSFER_CERTIFICATE
.
getCode
(),
rnrBizzTypeEnum
));
}
}
//入网合同
if
(!
CollectionUtils
.
isEmpty
(
requestDTO
.
getContractPic
()))
{
for
(
String
contractPic
:
requestDTO
.
getContractPic
())
{
mgRnrFileDTOS
.
add
(
FileUtil
.
newFileDTO
(
rnrId
,
contractPic
,
RnrFileType
.
VEHUCLE_BIND
.
getCode
(),
rnrBizzTypeEnum
));
}
}
return
mgRnrFileDTOS
;
}
/**
* 获取实名卡信息
*
* @param requestDTO 请求消息
*/
private
List
<
MgRnrCardInfoDTO
>
getMgRnrCardDTOs
(
PersonalRnrRequestDTO
requestDTO
,
RnrRelationDTO
rnrRelationDTO
)
{
List
<
String
>
iccidList
=
requestDTO
.
getIccidList
();
List
<
MgRnrCardInfoDTO
>
mgRnrCardInfoDTOS
=
new
ArrayList
<>();
MgRnrCardInfoDTO
mgRnrCardInfoDTO
;
if
(!
CollectionUtils
.
isEmpty
(
iccidList
))
{
for
(
String
iccid
:
iccidList
)
{
mgRnrCardInfoDTO
=
new
MgRnrCardInfoDTO
();
mgRnrCardInfoDTO
.
setUuid
(
CuscStringUtils
.
generateUuid
());
mgRnrCardInfoDTO
.
setIccid
(
iccid
);
mgRnrCardInfoDTO
.
setTenantNo
(
UserSubjectUtil
.
getTenantNo
());
mgRnrCardInfoDTO
.
setIotId
(
requestDTO
.
getVin
());
mgRnrCardInfoDTO
.
setRnrId
(
rnrRelationDTO
.
getInfo
().
getUuid
());
mgRnrCardInfoDTO
.
setOrderId
(
rnrRelationDTO
.
getOrder
().
getUuid
());
mgRnrCardInfoDTO
.
setCreator
(
UserSubjectUtil
.
getUserId
());
mgRnrCardInfoDTO
.
setOperator
(
UserSubjectUtil
.
getUserId
());
mgRnrCardInfoDTO
.
setRnrBizzType
(
requestDTO
.
getRnrBizzTypeEnum
());
mgRnrCardInfoDTOS
.
add
(
mgRnrCardInfoDTO
);
}
}
return
mgRnrCardInfoDTOS
;
}
/**
* 获取实名主体信息
*
* @param requestDTO 请求消息
*/
private
MgRnrInfoDTO
getMgRnrInfoDTO
(
PersonalRnrRequestDTO
requestDTO
,
String
rnrID
)
{
MgRnrInfoDTO
mgRnrInfoDTO
=
PersonalRnrRequestConvert
.
INSTANCE
.
requestDTOToMgRnrDTO
(
requestDTO
);
mgRnrInfoDTO
.
setIsCompany
(
0
);
mgRnrInfoDTO
.
setIsTrust
(
requestDTO
.
getIsConsigner
()
?
1
:
0
);
mgRnrInfoDTO
.
setIsSecondHandCar
(
Objects
.
equals
(
requestDTO
.
getCustomerType
(),
CustomerTypeEnum
.
NEW_CAR_OWNER
.
getCode
())
?
0
:
1
);
mgRnrInfoDTO
.
setUuid
(
rnrID
);
mgRnrInfoDTO
.
setCreator
(
UserSubjectUtil
.
getUserId
());
mgRnrInfoDTO
.
setOperator
(
UserSubjectUtil
.
getUserId
());
mgRnrInfoDTO
.
setSerial_number
(
CuscStringUtils
.
generateUuid
());
mgRnrInfoDTO
.
setTenantNo
(
UserSubjectUtil
.
getTenantNo
());
mgRnrInfoDTO
.
setRnrStatus
(
requestDTO
.
getRnrStatus
());
mgRnrInfoDTO
.
setRnrBizzType
(
requestDTO
.
getRnrBizzTypeEnum
());
mgRnrInfoDTO
.
setExpiredDate
(
requestDTO
.
getCertExpirationDate
());
return
mgRnrInfoDTO
;
}
/**
* 进行参数验证
*
* @param requestDTO 请求消息
*/
private
Response
validRnrInfo
(
PersonalRnrRequestDTO
requestDTO
,
boolean
unbind
)
{
// if (StringUtils.isBlank(requestDTO.getPurchaseContract())) {
// return Response.createError("购车合同不能为空", ResponseCode.INVALID_DATA.getCode());
// }
// if (StringUtils.isBlank(requestDTO.getPurchaseInvoice())) {
// return Response.createError("购车证明不能为空", ResponseCode.INVALID_DATA.getCode());
// }
//检查手机
Response
response
=
ValidationUtil
.
checkPhone
(
requestDTO
.
getPhone
());
if
(!
response
.
isSuccess
())
{
return
response
;
}
//性别校验
response
=
validGender
(
requestDTO
.
getGender
());
if
(!
response
.
isSuccess
())
{
return
response
;
}
//校验证件号码
response
=
ValidationUtil
.
checkIdentifyNumber
(
requestDTO
.
getCertType
(),
requestDTO
.
getCertNumber
());
if
(!
response
.
isSuccess
())
{
return
response
;
}
//证件照数量验证
response
=
ValidationUtil
.
checkIdentifyPics
(
requestDTO
.
getCertType
(),
requestDTO
.
getCertPic
().
size
());
if
(!
response
.
isSuccess
())
{
return
response
;
}
//二手车车主,需要有过户证明
if
(
requestDTO
.
getCustomerType
()
==
CustomerTypeEnum
.
USED_CAR_OWNER
.
getCode
())
{
if
(
CollectionUtils
.
isEmpty
(
requestDTO
.
getTransferCertificatePic
()))
{
return
Response
.
createError
(
"过户证明不能为空"
,
ResponseCode
.
INVALID_DATA
.
getCode
());
}
if
(
CollectionUtils
.
isEmpty
(
requestDTO
.
getPurchaseContractPic
()))
{
return
Response
.
createError
(
"购车合同不能为空"
,
ResponseCode
.
INVALID_DATA
.
getCode
());
}
if
(!
unbind
&&
CollectionUtils
.
isEmpty
(
requestDTO
.
getPurchaseInvoicePic
()))
{
return
Response
.
createError
(
"购车发票不能为空"
,
ResponseCode
.
INVALID_DATA
.
getCode
());
}
}
if
(
requestDTO
.
getIsConsigner
())
{
//验证委托人关系
ConsignerInfoDTO
consignerInfo
=
requestDTO
.
getConsignerInfo
();
Set
<
ConstraintViolation
<
ConsignerInfoDTO
>>
violations
=
SpringValidationUtil
.
groupVerificationParameters
(
consignerInfo
);
if
(!
violations
.
isEmpty
())
{
return
Response
.
createError
(
violations
.
stream
().
findFirst
().
get
().
getMessage
());
}
//性别校验
response
=
validGender
(
consignerInfo
.
getGender
());
if
(!
response
.
isSuccess
())
{
return
response
;
}
//校验证件号码
response
=
ValidationUtil
.
checkIdentifyNumber
(
consignerInfo
.
getCertType
(),
consignerInfo
.
getCertNumber
());
if
(!
response
.
isSuccess
())
{
return
response
;
}
//证件照数量验证
response
=
ValidationUtil
.
checkIdentifyPics
(
consignerInfo
.
getCertType
(),
consignerInfo
.
getCertPic
().
size
());
if
(!
response
.
isSuccess
())
{
return
response
;
}
//检查手机
response
=
ValidationUtil
.
checkPhone
(
consignerInfo
.
getPhone
());
if
(!
response
.
isSuccess
())
{
return
response
;
}
}
//api层不需要验证码
// else {
//没有委托人,车主验证码必填
// if (StringUtils.isBlank(requestDTO.getVerificationCode())) {
// return Response.createError("手机验证码不能为空", ResponseCode.INVALID_DATA.getCode());
// }
//}
return
Response
.
createSuccess
();
}
/**
* 校验性别
*
* @param gender
*/
private
Response
validGender
(
String
gender
)
{
if
(!
gender
.
equals
(
IdentifyConstants
.
GENDER_MALE
)
&&
!
gender
.
equals
(
IdentifyConstants
.
GENDER_FEMALE
))
{
return
Response
.
createError
(
"性别格式错误"
,
ResponseCode
.
INVALID_DATA
.
getCode
());
}
return
Response
.
createSuccess
();
}
}
src/main/java/com/cusc/nirvana/user/rnr/openapi/service/impl/RnrAuthSearchServiceImpl.java
0 → 100644
View file @
df1d7dc5
package
com.cusc.nirvana.user.rnr.openapi.service.impl
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.nacos.common.utils.MapUtils
;
import
com.cusc.nirvana.common.result.Response
;
import
com.cusc.nirvana.user.rnr.mg.client.MgRnrCardInfoClient
;
import
com.cusc.nirvana.user.rnr.mg.client.MgRnrInfoClient
;
import
com.cusc.nirvana.user.rnr.mg.client.MgVehicleCompanyClient
;
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.RnrStatus
;
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.MgVehicleCompanyDTO
;
import
com.cusc.nirvana.user.rnr.openapi.dto.QueryRnAuthDTO
;
import
com.cusc.nirvana.user.rnr.openapi.dto.VinDTO
;
import
com.cusc.nirvana.user.rnr.openapi.dto.response.RnAuthInfoRsp
;
import
com.cusc.nirvana.user.rnr.openapi.dto.response.RnAuthStateRsp
;
import
com.cusc.nirvana.user.rnr.openapi.service.IRnrAuthSearchService
;
import
com.cusc.nirvana.user.util.DateUtils
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.util.StringUtils
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
/**
* @author yubo
* @since 2022-06-09 11:05
*/
@Service
public
class
RnrAuthSearchServiceImpl
implements
IRnrAuthSearchService
{
@Autowired
private
MgRnrCardInfoClient
mgRnrCardInfoClient
;
@Autowired
private
MgRnrInfoClient
mgRnrInfoClient
;
@Autowired
private
MgVehicleCompanyClient
mgVehicleCompanyClient
;
@Override
public
Response
<
List
<
RnAuthInfoRsp
>>
getRnrInfoByVin
(
VinDTO
vinDTO
)
{
MgRnrCardInfoDTO
bean
=
new
MgRnrCardInfoDTO
();
bean
.
setIotId
(
vinDTO
.
getVin
());
List
<
Integer
>
bizTypeList
=
new
ArrayList
<>();
bizTypeList
.
add
(
RnrBizzTypeEnum
.
Bind
.
getCode
());
bizTypeList
.
add
(
RnrBizzTypeEnum
.
INFO_CHANGE
.
getCode
());
bizTypeList
.
add
(
RnrBizzTypeEnum
.
ChangeBinding
.
getCode
());
bizTypeList
.
add
(
RnrBizzTypeEnum
.
REPEAT_BIND
.
getCode
());
bean
.
setBizTypeList
(
bizTypeList
);
//todo 也要返回自然人的信息
Response
<
List
<
MgRnrCardInfoDTO
>>
mgRsp
=
mgRnrCardInfoClient
.
queryByList
(
bean
);
if
(
mgRsp
.
isSuccess
())
{
List
<
MgRnrCardInfoDTO
>
cardInfoDTOS
=
mgRsp
.
getData
();
List
<
RnAuthInfoRsp
>
rnAuthInfoRspList
=
new
ArrayList
<>();
if
(!
CollectionUtils
.
isEmpty
(
cardInfoDTOS
))
{
//根据createTime排序 取最新的实名状态信息
MgRnrCardInfoDTO
lastestRnrInfo
=
cardInfoDTOS
.
get
(
0
);
MgRnrInfoDTO
mgRnrInfoDTO
=
new
MgRnrInfoDTO
();
mgRnrInfoDTO
.
setUuid
(
lastestRnrInfo
.
getRnrId
());
Response
<
MgRnrInfoDTO
>
response
=
mgRnrInfoClient
.
getByUuid
(
mgRnrInfoDTO
);
RnAuthInfoRsp
authInfoRsp
=
new
RnAuthInfoRsp
();
BeanUtils
.
copyProperties
(
lastestRnrInfo
,
authInfoRsp
);
authInfoRsp
.
setRnrStatus
(
RnrStatus
.
getEnumByCode
(
lastestRnrInfo
.
getRnrStatus
()).
getComment
());
if
(
response
.
isSuccess
()
&&
null
!=
response
.
getData
())
{
BeanUtils
.
copyProperties
(
response
.
getData
(),
authInfoRsp
);
authInfoRsp
.
setIsCompany
(
String
.
valueOf
(
response
.
getData
().
getIsCompany
()));
if
(
1
==
response
.
getData
().
getIsCompany
())
{
MgVehicleCompanyDTO
mgVehicleCompanyDTO
=
new
MgVehicleCompanyDTO
();
mgVehicleCompanyDTO
.
setUuid
(
response
.
getData
().
getRnrCompanyId
());
Response
<
MgVehicleCompanyDTO
>
mgVehicleCompanyDTOResponse
=
mgVehicleCompanyClient
.
getByUuid
(
mgVehicleCompanyDTO
);
if
(
mgVehicleCompanyDTOResponse
.
isSuccess
()
&&
null
!=
mgVehicleCompanyDTOResponse
.
getData
())
{
authInfoRsp
.
setCompanyName
(
mgVehicleCompanyDTOResponse
.
getData
().
getCompanyName
());
}
}
}
rnAuthInfoRspList
.
add
(
authInfoRsp
);
}
return
Response
.
createSuccess
(
"查询实名信息成功"
,
rnAuthInfoRspList
);
}
else
{
return
Response
.
createError
(
"查询实名信息失败:error->"
+
mgRsp
.
getMsg
());
}
}
@Override
public
Response
<
RnAuthStateRsp
>
getRnAuthState
(
QueryRnAuthDTO
queryRnAuthDTO
)
{
MgRnrCardInfoDTO
cardInfoDTO
=
new
MgRnrCardInfoDTO
();
if
(
StringUtils
.
isEmpty
(
queryRnAuthDTO
.
getVin
())
&&
CollectionUtils
.
isEmpty
(
queryRnAuthDTO
.
getIccidList
()))
{
return
Response
.
createError
(
"vin和iccid均为空,无法查询实名状态"
);
}
cardInfoDTO
.
setIotId
(
queryRnAuthDTO
.
getVin
());
List
<
Integer
>
bizTypeList
=
new
ArrayList
<>();
bizTypeList
.
add
(
RnrBizzTypeEnum
.
Bind
.
getCode
());
bizTypeList
.
add
(
RnrBizzTypeEnum
.
INFO_CHANGE
.
getCode
());
bizTypeList
.
add
(
RnrBizzTypeEnum
.
ChangeBinding
.
getCode
());
bizTypeList
.
add
(
RnrBizzTypeEnum
.
REPEAT_BIND
.
getCode
());
cardInfoDTO
.
setBizTypeList
(
bizTypeList
);
cardInfoDTO
.
setIccidList
(
queryRnAuthDTO
.
getIccidList
());
Response
<
List
<
MgRnrCardInfoDTO
>>
mgRsp
=
mgRnrCardInfoClient
.
queryByList
(
cardInfoDTO
);
if
(
mgRsp
.
isSuccess
())
{
List
<
MgRnrCardInfoDTO
>
cardInfoDTOS
=
mgRsp
.
getData
();
RnAuthStateRsp
authStateRsp
=
new
RnAuthStateRsp
();
if
(!
CollectionUtils
.
isEmpty
(
cardInfoDTOS
))
{
Map
<
String
,
String
>
stateMap
=
new
HashMap
<>();
Map
<
String
,
MgRnrCardInfoDTO
>
cardInfoDTOMap
=
new
HashMap
<>();
//根据createTime排序 取最新的实名状态信息
for
(
MgRnrCardInfoDTO
rnrCardInfoDTO
:
cardInfoDTOS
)
{
String
iccid
=
rnrCardInfoDTO
.
getIccid
();
MgRnrCardInfoDTO
infoDTO
=
cardInfoDTOMap
.
get
(
iccid
);
if
(
null
!=
infoDTO
)
{
if
(
DateUtils
.
compareDate
(
rnrCardInfoDTO
.
getCreateTime
(),
infoDTO
.
getCreateTime
())
==
1
)
{
cardInfoDTOMap
.
put
(
iccid
,
rnrCardInfoDTO
);
}
}
else
{
cardInfoDTOMap
.
put
(
iccid
,
rnrCardInfoDTO
);
}
}
if
(
MapUtils
.
isNotEmpty
(
cardInfoDTOMap
))
{
cardInfoDTOMap
.
values
().
forEach
(
lastestRnrState
->
stateMap
.
put
(
lastestRnrState
.
getIotId
()
+
"-"
+
lastestRnrState
.
getIccid
(),
RnrStatus
.
getEnumByCode
(
lastestRnrState
.
getRnrStatus
()).
getComment
()));
}
authStateRsp
.
setRnAuthStateMap
(
stateMap
);
}
return
Response
.
createSuccess
(
"查询实名状态成功"
,
authStateRsp
);
}
else
{
return
Response
.
createError
(
"查询实名状态失败:error->"
+
mgRsp
.
getMsg
());
}
}
}
src/main/java/com/cusc/nirvana/user/rnr/openapi/service/impl/SmsServiceImpl.java
0 → 100644
View file @
df1d7dc5
package
com.cusc.nirvana.user.rnr.openapi.service.impl
;
import
com.cusc.nirvana.common.result.Response
;
import
com.cusc.nirvana.user.rnr.fp.client.SmsClient
;
import
com.cusc.nirvana.user.rnr.fp.common.ResponseCode
;
import
com.cusc.nirvana.user.rnr.fp.dto.SmsRequestDTO
;
import
com.cusc.nirvana.user.rnr.openapi.service.ISmsService
;
import
com.cusc.nirvana.user.rnr.openapi.util.UserSubjectUtil
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
/**
* Description: 短信service
* <br />
* CreateDate 2022-04-16 15:11:41
*
* @author yuyi
**/
@Service
@Slf4j
public
class
SmsServiceImpl
implements
ISmsService
{
@Autowired
SmsClient
smsClient
;
@Override
public
Response
sendSmsRnr
(
SmsRequestDTO
bean
)
{
if
(
StringUtils
.
isBlank
(
bean
.
getBizType
()))
{
return
Response
.
createError
(
"业务类型不能为空"
,
ResponseCode
.
INVALID_DATA
);
}
if
(
StringUtils
.
isBlank
(
bean
.
getPhone
()))
{
return
Response
.
createError
(
"手机号不能为空"
,
ResponseCode
.
INVALID_DATA
);
}
bean
.
setTenantNo
(
UserSubjectUtil
.
getTenantNo
());
return
smsClient
.
sendSmsCaptcha
(
bean
);
}
@Override
public
Response
checkSmsCaptcha
(
SmsRequestDTO
bean
)
{
if
(
StringUtils
.
isBlank
(
bean
.
getBizType
()))
{
return
Response
.
createError
(
"业务类型不能为空"
,
ResponseCode
.
INVALID_DATA
);
}
if
(
StringUtils
.
isBlank
(
bean
.
getPhone
()))
{
return
Response
.
createError
(
"手机号不能为空"
,
ResponseCode
.
INVALID_DATA
);
}
if
(
StringUtils
.
isBlank
(
bean
.
getCaptcha
()))
{
return
Response
.
createError
(
"验证码不能为空"
,
ResponseCode
.
INVALID_DATA
);
}
bean
.
setTenantNo
(
UserSubjectUtil
.
getTenantNo
());
return
smsClient
.
checkSmsCaptcha
(
bean
);
}
}
src/main/java/com/cusc/nirvana/user/rnr/openapi/service/impl/VehicleCardServiceImpl.java
0 → 100644
View file @
df1d7dc5
package
com.cusc.nirvana.user.rnr.openapi.service.impl
;
import
com.cusc.nirvana.common.result.Response
;
import
com.cusc.nirvana.user.rnr.fp.client.CardUnBindClient
;
import
com.cusc.nirvana.user.rnr.fp.client.FileSystemClient
;
import
com.cusc.nirvana.user.rnr.fp.client.VinCardClient
;
import
com.cusc.nirvana.user.rnr.fp.dto.*
;
import
com.cusc.nirvana.user.rnr.mg.client.MgRnrCardInfoClient
;
import
com.cusc.nirvana.user.rnr.mg.dto.MgRnrCardInfoDTO
;
import
com.cusc.nirvana.user.rnr.openapi.service.IVehicleCardService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
import
javax.validation.Valid
;
import
java.util.List
;
import
java.util.stream.Collectors
;
/**
* @author yubo
* @since 2022-04-18 09:26
*/
@Service
@Slf4j
public
class
VehicleCardServiceImpl
implements
IVehicleCardService
{
@Autowired
VinCardClient
vinCardClient
;
@Autowired
CardUnBindClient
cardUnBindClient
;
@Value
(
"${fileTemplate.manufacturer.fileSize: 500}"
)
private
String
fileSize
;
@Resource
private
FileSystemClient
fileSystemClient
;
@Resource
private
MgRnrCardInfoClient
cardInfoClient
;
/**
* 车卡关系和卡校验
*
* @param vinCardDTO
* @return
*/
@Override
public
Response
<
VerifyVinCardResponseDTO
>
verifyVinCard
(
@Valid
com
.
cusc
.
nirvana
.
user
.
rnr
.
openapi
.
dto
.
VinCardInfoDTO
vinCardDTO
)
{
//调用批量验证接口
List
<
VinCardDTO
>
vinCardDTOS
=
vinCardDTO
.
getIccidList
().
stream
().
map
(
iccid
->
new
VinCardDTO
(
vinCardDTO
.
getVin
(),
iccid
)).
collect
(
Collectors
.
toList
());
return
verifyVinCardBatch
(
vinCardDTOS
);
}
/**
* 批量车卡关系和卡校验
*
* @param verifyDTOs
* @return
*/
@Override
public
Response
<
VerifyVinCardResponseDTO
>
verifyVinCardBatch
(
List
<
VinCardDTO
>
verifyDTOs
)
{
//进行vin和iccid的验证
Response
<
VerifyVinCardResponseDTO
>
response
=
vinCardClient
.
verifyVinCard
(
verifyDTOs
);
if
(!
response
.
isSuccess
())
{
return
response
;
}
return
Response
.
createSuccess
(
response
.
getData
());
}
@Override
public
Response
<
List
<
MgRnrCardInfoDTO
>>
getBindsByVinsAndIccids
(
List
<
String
>
vins
,
List
<
String
>
iccidList
)
{
MgRnrCardInfoDTO
bean
=
new
MgRnrCardInfoDTO
();
bean
.
setVinList
(
vins
);
bean
.
setIccidList
(
iccidList
);
Response
<
List
<
MgRnrCardInfoDTO
>>
cardListResponse
=
cardInfoClient
.
queryBindListByVinsAndIccids
(
bean
);
if
(!
cardListResponse
.
isSuccess
())
{
return
Response
.
createError
(
cardListResponse
.
getMsg
(),
cardListResponse
.
getCode
());
}
return
cardListResponse
;
}
}
src/main/java/com/cusc/nirvana/user/rnr/openapi/util/FileUtil.java
0 → 100644
View file @
df1d7dc5
package
com.cusc.nirvana.user.rnr.openapi.util
;
import
com.cusc.nirvana.user.exception.CuscUserException
;
import
com.cusc.nirvana.user.rnr.fp.common.ResponseCode
;
import
com.cusc.nirvana.user.rnr.fp.dto.VerifyExcelStatusEnum
;
import
com.cusc.nirvana.user.rnr.fp.dto.VinCardDTO
;
import
com.cusc.nirvana.user.rnr.fp.dto.VinCardVerityResult
;
import
com.cusc.nirvana.user.rnr.mg.constants.CertTypeEnum
;
import
com.cusc.nirvana.user.rnr.mg.dto.MgRnrFileDTO
;
import
com.cusc.nirvana.user.rnr.openapi.dto.ExcelSheetDTO
;
import
com.cusc.nirvana.user.util.CuscStringUtils
;
import
org.apache.commons.fileupload.FileItem
;
import
org.apache.commons.fileupload.disk.DiskFileItemFactory
;
import
org.apache.commons.io.IOUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.poi.hssf.usermodel.HSSFWorkbook
;
import
org.apache.poi.ss.usermodel.*
;
import
org.apache.poi.xssf.usermodel.XSSFWorkbook
;
import
org.springframework.http.MediaType
;
import
org.springframework.web.multipart.MultipartFile
;
import
org.springframework.web.multipart.commons.CommonsMultipartFile
;
import
java.io.*
;
import
java.util.ArrayList
;
import
java.util.Iterator
;
import
java.util.List
;
/**
* 文件处理类
*
* @author yubo
* @since 2022-04-19 10:12
*/
public
class
FileUtil
{
/**
* 车企和企业的excel转成车卡list
*
* @param inputStream
* @return
*/
public
static
List
<
VinCardDTO
>
convertExcelToVinCardList
(
InputStream
inputStream
,
String
fileName
)
throws
IOException
{
return
convertExcelToVinCardList
(
inputStream
,
isExcelXSSFFormat
(
fileName
),
1
);
}
public
static
List
<
VinCardVerityResult
>
convertExcelToVinCardLists
(
InputStream
inputStream
,
String
fileName
)
throws
IOException
{
return
convertExcelToVinCardLists
(
inputStream
,
isExcelXSSFFormat
(
fileName
),
1
);
}
//创建文件信息
public
static
MgRnrFileDTO
newFileDTO
(
String
rnrId
,
String
pic
,
Integer
fileType
,
int
rnrBizzType
)
{
return
newFileDTO
(
rnrId
,
pic
,
fileType
,
"0"
,
rnrBizzType
);
}
//创建文件信息
public
static
MgRnrFileDTO
newFileDTO
(
String
rnrId
,
String
pic
,
Integer
fileType
,
String
liasionId
,
int
rnrBizzType
)
{
MgRnrFileDTO
mgRnrFileDTO
=
new
MgRnrFileDTO
();
mgRnrFileDTO
.
setUuid
(
CuscStringUtils
.
generateUuid
());
mgRnrFileDTO
.
setRnrId
(
rnrId
);
mgRnrFileDTO
.
setFileType
(
fileType
);
mgRnrFileDTO
.
setFileSystemId
(
pic
);
mgRnrFileDTO
.
setTenantNo
(
UserSubjectUtil
.
getTenantNo
());
mgRnrFileDTO
.
setLiaisonId
(
liasionId
);
mgRnrFileDTO
.
setCreator
(
UserSubjectUtil
.
getUserId
());
mgRnrFileDTO
.
setOperator
(
UserSubjectUtil
.
getUserId
());
mgRnrFileDTO
.
setRnrBizzType
(
rnrBizzType
);
return
mgRnrFileDTO
;
}
/**
* 车企和企业的excel转成车卡list
*
* @param usingXSSF 是否使用xssf
* @param skipLines 跳过的行数,用于跳过列名行
* @return
*/
public
static
List
<
VinCardDTO
>
convertExcelToVinCardList
(
InputStream
inputStream
,
boolean
usingXSSF
,
int
skipLines
)
throws
IOException
{
try
(
Workbook
wb
=
usingXSSF
?
new
XSSFWorkbook
(
inputStream
)
:
new
HSSFWorkbook
(
inputStream
))
{
Sheet
sheet
=
wb
.
getSheetAt
(
0
);
Iterator
<
Row
>
iterator
=
sheet
.
iterator
();
List
<
VinCardDTO
>
vinCardDTOS
=
new
ArrayList
<>();
int
index
=
0
;
while
(
iterator
.
hasNext
())
{
Row
next
=
iterator
.
next
();
if
(
index
<
skipLines
)
{
index
++;
continue
;
}
//如果读取到的第一列的数据为空,则跳过
String
cellValue
=
getCellValue
(
next
.
getCell
(
0
));
if
(
StringUtils
.
isBlank
(
cellValue
)){
continue
;
}
vinCardDTOS
.
add
(
new
VinCardDTO
(
cellValue
,
getCellValue
(
next
.
getCell
(
1
))));
}
return
vinCardDTOS
;
}
}
/**
* 获取文件类型
*
* @param certType 证书类型
* @param index 索引
*/
public
static
Integer
getFileType
(
String
certType
,
int
index
)
{
CertTypeEnum
typeEnum
=
CertTypeEnum
.
getEnumByCode
(
certType
);
if
(
index
<
0
||
typeEnum
==
null
||
typeEnum
.
getFileTypes
()
==
null
||
typeEnum
.
getFileTypes
().
length
<
0
)
{
throw
new
CuscUserException
(
ResponseCode
.
INVALID_DATA
.
getCode
(),
"证件类型【"
+
certType
+
"】错误"
);
}
//不能超过固定的文件数量
if
(
typeEnum
.
isFixedSize
()
&&
index
>=
typeEnum
.
getFileTypes
().
length
)
{
throw
new
CuscUserException
(
ResponseCode
.
INVALID_DATA
.
getCode
(),
"证件【"
+
typeEnum
.
getName
()
+
"】上传文件数超过指定数量【"
+
typeEnum
.
getFileTypes
().
length
+
"】"
);
}
if
(
index
>=
typeEnum
.
getFileTypes
().
length
)
{
index
=
typeEnum
.
getFileTypes
().
length
-
1
;
}
return
typeEnum
.
getFileTypes
()[
index
].
getCode
();
}
public
static
List
<
VinCardVerityResult
>
convertExcelToVinCardLists
(
InputStream
inputStream
,
boolean
usingXSSF
,
int
skipLines
)
throws
IOException
{
try
(
Workbook
wb
=
usingXSSF
?
new
XSSFWorkbook
(
inputStream
)
:
new
HSSFWorkbook
(
inputStream
))
{
Sheet
sheet
=
wb
.
getSheetAt
(
0
);
Iterator
<
Row
>
iterator
=
sheet
.
iterator
();
List
<
VinCardVerityResult
>
vinCardDTOS
=
new
ArrayList
<>();
int
index
=
0
;
while
(
iterator
.
hasNext
())
{
Row
next
=
iterator
.
next
();
if
(
index
<
skipLines
)
{
index
++;
continue
;
}
//如果读取到的第一列的数据为空,表示已经读到最后,跳出
String
cellValue
=
getCellValue
(
next
.
getCell
(
0
));
if
(
StringUtils
.
isBlank
(
cellValue
)){
continue
;
}
vinCardDTOS
.
add
(
new
VinCardVerityResult
(
cellValue
,
getCellValue
(
next
.
getCell
(
1
)),
StringUtils
.
equals
(
getCellValue
(
next
.
getCell
(
2
)),
VerifyExcelStatusEnum
.
SUCCESS
.
getCode
())
,
getCellValue
(
next
.
getCell
(
3
))));
}
return
vinCardDTOS
;
}
}
/**
* 获取单元格值
*
* @param cell
* @return
*/
private
static
String
getCellValue
(
Cell
cell
)
{
if
(
cell
==
null
)
{
return
""
;
}
CellType
cellType
=
cell
.
getCellType
();
switch
(
cellType
)
{
case
STRING:
return
cell
.
getStringCellValue
();
case
NUMERIC:
return
String
.
valueOf
((
int
)
cell
.
getNumericCellValue
());
case
BOOLEAN:
return
String
.
valueOf
(
cell
.
getBooleanCellValue
());
default
:
return
""
;
}
}
/**
* 校验结果转成excel数据
*/
public
static
ExcelSheetDTO
convertVerityResultToExcelDTO
(
List
<
VinCardVerityResult
>
verityResults
)
{
ExcelSheetDTO
excelSheetDTO
=
new
ExcelSheetDTO
();
excelSheetDTO
.
setSheetName
(
"验证结果列表"
);
excelSheetDTO
.
setSchema
(
new
String
[]{
"VIN"
,
"ICCID"
,
"状态"
,
"错误信息"
});
if
(!
verityResults
.
isEmpty
())
{
for
(
VinCardVerityResult
verityResult
:
verityResults
)
{
excelSheetDTO
.
getData
().
add
(
new
String
[]{
verityResult
.
getVin
(),
verityResult
.
getIccid
()
,
verityResult
.
isExist
()
?
VerifyExcelStatusEnum
.
SUCCESS
.
getCode
()
:
VerifyExcelStatusEnum
.
FAILED
.
getCode
()
,
verityResult
.
getMsg
()});
}
}
return
excelSheetDTO
;
}
/**
* 通过文件名判断excel格式
*
* @param fileName
* @return
*/
public
static
boolean
isExcelXSSFFormat
(
String
fileName
)
{
return
StringUtils
.
isNotBlank
(
fileName
)
&&
fileName
.
toLowerCase
().
endsWith
(
".xlsx"
);
}
public
static
MultipartFile
bytesToMultipartFile
(
byte
[]
bytes
,
String
fileName
)
{
FileItem
fileItem
=
new
DiskFileItemFactory
().
createItem
(
"file"
,
MediaType
.
MULTIPART_FORM_DATA_VALUE
,
true
,
fileName
);
try
(
InputStream
input
=
new
ByteArrayInputStream
(
bytes
);
OutputStream
os
=
fileItem
.
getOutputStream
())
{
IOUtils
.
copy
(
input
,
os
);
}
catch
(
Exception
e
)
{
throw
new
IllegalArgumentException
(
"Invalid file: "
+
e
,
e
);
}
return
new
CommonsMultipartFile
(
fileItem
);
}
public
static
byte
[]
createExcelBytes
(
ExcelSheetDTO
excelSheetDTO
,
String
fileName
)
throws
IOException
{
return
createExcelBytes
(
excelSheetDTO
,
isExcelXSSFFormat
(
fileName
));
}
private
static
byte
[]
createExcelBytes
(
ExcelSheetDTO
excelSheetDTO
,
boolean
excelXSSFFormat
)
throws
IOException
{
Workbook
workbook
=
excelXSSFFormat
?
new
XSSFWorkbook
()
:
new
HSSFWorkbook
();
Sheet
sheet
=
workbook
.
createSheet
(
excelSheetDTO
.
getSheetName
());
//写入列名行
int
rowIndex
=
0
,
colIndex
=
0
;
Row
row
=
sheet
.
createRow
(
rowIndex
++);
for
(
String
name
:
excelSheetDTO
.
getSchema
())
{
row
.
createCell
(
colIndex
++).
setCellValue
(
name
);
}
//写入信息
for
(
String
[]
colData
:
excelSheetDTO
.
getData
())
{
colIndex
=
0
;
row
=
sheet
.
createRow
(
rowIndex
++);
for
(
String
cellValue
:
colData
)
{
row
.
createCell
(
colIndex
++).
setCellValue
(
cellValue
);
}
}
ByteArrayOutputStream
byteArrayOutputStream
=
new
ByteArrayOutputStream
(
1024
);
workbook
.
write
(
byteArrayOutputStream
);
return
byteArrayOutputStream
.
toByteArray
();
}
}
src/main/java/com/cusc/nirvana/user/rnr/openapi/util/HMACUtils.java
0 → 100644
View file @
df1d7dc5
package
com.cusc.nirvana.user.rnr.openapi.util
;
import
org.apache.commons.lang3.StringUtils
;
import
org.bouncycastle.jce.provider.BouncyCastleProvider
;
import
javax.crypto.KeyGenerator
;
import
javax.crypto.Mac
;
import
javax.crypto.SecretKey
;
import
javax.crypto.spec.SecretKeySpec
;
import
java.io.UnsupportedEncodingException
;
import
java.security.*
;
/**
* @author jeff.chen
* @file HMAC
* @E-mail chenjf159@chinaunicom.cn
*/
public
class
HMACUtils
{
static
{
if
(
null
==
Security
.
getProvider
(
BouncyCastleProvider
.
PROVIDER_NAME
))
{
Security
.
addProvider
(
new
BouncyCastleProvider
());
}
}
/**
* 签名
*
* @param content 待签名内容
* @param key 秘钥
* @param algorithm 签名算法
* @return
*/
public
static
String
sign
(
String
content
,
String
key
,
Type
algorithm
)
{
if
(
StringUtils
.
isBlank
(
content
))
{
return
null
;
}
try
{
if
(
Type
.
HmacSHA224
.
equals
(
algorithm
)
||
Type
.
HmacSHA384
.
equals
(
algorithm
))
{
// 未与在线加密工具对齐信息
return
bouncyCastle
(
content
,
key
,
algorithm
);
}
else
{
return
jdk
(
content
,
key
,
algorithm
);
}
}
catch
(
Exception
e
)
{
throw
new
RuntimeException
(
"HMAC "
+
algorithm
.
algorithm
+
e
.
getMessage
());
}
}
private
static
String
jdk
(
String
content
,
String
key
,
Type
algorithm
)
throws
NoSuchAlgorithmException
,
UnsupportedEncodingException
,
InvalidKeyException
{
Mac
mac
=
Mac
.
getInstance
(
algorithm
.
algorithm
);
mac
.
init
(
new
SecretKeySpec
(
key
.
getBytes
(
"UTF-8"
),
algorithm
.
algorithm
));
byte
[]
bytes
=
mac
.
doFinal
(
content
.
getBytes
(
"UTF-8"
));
return
Utils
.
parseByte2HexStr
(
bytes
);
}
private
static
String
bouncyCastle
(
String
content
,
String
key
,
Type
algorithm
)
throws
NoSuchAlgorithmException
,
UnsupportedEncodingException
,
InvalidKeyException
,
NoSuchProviderException
{
KeyGenerator
keyGenerator
=
KeyGenerator
.
getInstance
(
algorithm
.
algorithm
,
BouncyCastleProvider
.
PROVIDER_NAME
);
keyGenerator
.
init
(
new
SecureRandom
(
key
.
getBytes
(
"UTF-8"
)));
SecretKey
secretKey
=
keyGenerator
.
generateKey
();
byte
[]
secret
=
secretKey
.
getEncoded
();
SecretKey
secretKey0
=
new
SecretKeySpec
(
secret
,
algorithm
.
algorithm
);
Mac
mac
=
Mac
.
getInstance
(
secretKey0
.
getAlgorithm
());
mac
.
init
(
secretKey0
);
byte
[]
bytes
=
mac
.
doFinal
(
content
.
getBytes
(
"UTF-8"
));
return
Utils
.
parseByte2HexStr
(
bytes
);
}
public
enum
Type
{
/**
* HmacSHA1
*/
HmacSHA1
(
"HmacSHA1"
),
/**
* HmacSHA224
*/
HmacSHA224
(
"HmacSHA224"
),
/**
* HmacSHA256
*/
HmacSHA256
(
"HmacSHA256"
),
/**
* HmacSHA384
*/
HmacSHA384
(
"HmacSHA384"
),
/**
* HmacSHA512
*/
HmacSHA512
(
"HmacSHA512"
),
/**
* HmacMD5
*/
HmacMD5
(
"HmacMD5"
);
String
algorithm
;
Type
(
String
algorithm
)
{
this
.
algorithm
=
algorithm
;
}
}
}
src/main/java/com/cusc/nirvana/user/rnr/openapi/util/SignUtils.java
0 → 100644
View file @
df1d7dc5
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
com.cusc.nirvana.user.rnr.openapi.util
;
import
com.cusc.nirvana.user.rnr.openapi.common.Constants
;
import
com.google.common.collect.Maps
;
import
lombok.extern.slf4j.Slf4j
;
import
java.util.*
;
import
java.util.stream.Collectors
;
/**
* SignUtils.
*/
@Slf4j
public
final
class
SignUtils
{
private
static
final
SignUtils
SIGN_UTILS
=
new
SignUtils
();
private
SignUtils
()
{
}
/**
* getInstance.
*
* @return {@linkplain SignUtils}
*/
public
static
SignUtils
getInstance
()
{
return
SIGN_UTILS
;
}
/**
* acquired sign.
*
* @param signKey sign key
* @param params params
* @return sign
*/
public
static
String
generateSign
(
final
String
signKey
,
final
Map
<
String
,
String
>
params
)
{
List
<
String
>
storedKeys
=
Arrays
.
stream
(
params
.
keySet
()
.
toArray
(
new
String
[]{}))
.
sorted
(
Comparator
.
naturalOrder
())
.
collect
(
Collectors
.
toList
());
final
String
sign
=
storedKeys
.
stream
()
.
filter
(
key
->
!
Objects
.
equals
(
key
,
Constants
.
SIGN
))
.
map
(
key
->
String
.
join
(
""
,
key
,
params
.
get
(
key
)))
.
collect
(
Collectors
.
joining
()).
trim
();
System
.
out
.
println
(
"signstr:"
+
sign
);
// TODO this is a risk for error charset coding with getBytes
return
HMACUtils
.
sign
(
sign
,
signKey
,
HMACUtils
.
Type
.
HmacSHA256
).
toUpperCase
();
}
/**
* isValid.
*
* @param sign sign
* @param params params
* @param signKey signKey
* @return boolean
*/
public
boolean
isValid
(
final
String
sign
,
final
Map
<
String
,
String
>
params
,
final
String
signKey
)
{
log
.
info
(
"加密信息====={}"
,
generateSign
(
signKey
,
params
));
return
Objects
.
equals
(
sign
,
generateSign
(
signKey
,
params
));
}
/**
* Generate key string.
*
* @return the string
*/
public
String
generateKey
()
{
return
UUID
.
randomUUID
().
toString
().
replaceAll
(
"-"
,
""
).
toUpperCase
();
}
public
static
void
main
(
String
[]
args
)
{
Map
<
String
,
String
>
map
=
Maps
.
newHashMapWithExpectedSize
(
4
);
map
.
put
(
Constants
.
APP_ID
,
"5455909B7FF644168384498F5E89C055"
);
map
.
put
(
Constants
.
NONCE_STR
,
"a2f6cc37063b4246858142bacd4ba23g"
);
map
.
put
(
Constants
.
TIMESTAMP
,
"1654825095546"
);
map
.
put
(
Constants
.
VERSION
,
"1.0.0"
);
System
.
out
.
println
(
"sign---->"
+
SignUtils
.
generateSign
(
"460660B2004B49708B141B423E209B74"
,
map
));
}
}
src/main/java/com/cusc/nirvana/user/rnr/openapi/util/SpringValidationUtil.java
0 → 100644
View file @
df1d7dc5
package
com.cusc.nirvana.user.rnr.openapi.util
;
import
javax.validation.ConstraintViolation
;
import
javax.validation.Validation
;
import
javax.validation.ValidatorFactory
;
import
java.util.Set
;
/**
* @author yubo
* @since 2022-04-18 19:17
*/
public
class
SpringValidationUtil
{
/**
* 分组验证参数
* @param <T>
* @param validateData 参数
* @param validateGroup 分组
* @return
*/
public
static
<
T
>
Set
<
ConstraintViolation
<
T
>>
groupVerificationParameters
(
T
validateData
,
Class
<?>...
validateGroup
)
{
ValidatorFactory
validatorFactory
=
Validation
.
buildDefaultValidatorFactory
();
return
validatorFactory
.
getValidator
().
validate
(
validateData
,
validateGroup
);
}
}
src/main/java/com/cusc/nirvana/user/rnr/openapi/util/ThreadLocalUtil.java
0 → 100644
View file @
df1d7dc5
package
com.cusc.nirvana.user.rnr.openapi.util
;
import
java.util.HashMap
;
import
java.util.Map
;
/**
* Description: 本地线程工具类
* <br />
* CreateDate 2021-11-08 10:25
*
* @author yuyi
**/
public
class
ThreadLocalUtil
{
private
static
ThreadLocal
<
Map
<
String
,
Object
>>
cache
=
new
ThreadLocal
<>();
/**
* 从ThreadLocal里获取缓存的值
*
* @param key 要获取的数据的KEY
* @return 要获取的值
*/
public
static
Object
getCache
(
String
key
)
{
Map
<
String
,
Object
>
map
=
cache
.
get
();
if
(
isCacheIsNull
())
{
return
null
;
}
if
(
map
.
containsKey
(
key
))
{
return
map
.
get
(
key
);
}
return
null
;
}
/**
* 向ThreadLocal缓存值
*
* @param key 要缓存的KEY
* @param value 要缓存的VALUE
*/
public
static
void
set
(
String
key
,
Object
value
)
{
if
(!
isCacheIsNull
())
{
cache
.
get
().
put
(
key
,
value
);
}
else
{
Map
<
String
,
Object
>
vmap
=
new
HashMap
<>();
vmap
.
put
(
key
,
value
);
cache
.
set
(
vmap
);
}
}
/**
* 根据KEY移除缓存里的数据
*
* @param key
*/
public
static
void
removeByKey
(
String
key
)
{
if
(!
isCacheIsNull
())
{
cache
.
get
().
remove
(
key
);
}
}
/**
* 移除当前线程缓存
* 用于释放当前线程threadlocal资源
*/
public
static
void
remove
()
{
cache
.
remove
();
}
private
static
boolean
isCacheIsNull
()
{
return
cache
.
get
()
==
null
;
}
public
static
String
cacheToString
()
{
return
isCacheIsNull
()
?
null
:
cache
.
get
().
toString
();
}
}
src/main/java/com/cusc/nirvana/user/rnr/openapi/util/UserSubjectUtil.java
0 → 100644
View file @
df1d7dc5
package
com.cusc.nirvana.user.rnr.openapi.util
;
import
com.cusc.nirvana.user.rnr.openapi.constants.AuthConstant
;
import
org.springframework.beans.factory.annotation.Value
;
/**
* Description: 用户信息获取service
* <br />
* CreateDate 2021-11-08 9:41
*
* @author yuyi
**/
public
class
UserSubjectUtil
{
/**
* Description: 获取用户id
* <br />
* CreateDate 2021-11-08 10:32:53
*
* @author yuyi
**/
public
static
String
getUserId
()
{
Object
ret
=
ThreadLocalUtil
.
getCache
(
AuthConstant
.
USER_ID_NAME
);
if
(
ret
!=
null
)
{
return
String
.
valueOf
(
ret
);
}
return
"OPENAPI"
;
}
/**
* Description: 获取组织id
* <br />
* CreateDate 2021-11-08 10:32:53
*
* @author yuyi
**/
public
static
String
geOrgId
()
{
Object
ret
=
ThreadLocalUtil
.
getCache
(
AuthConstant
.
BODY_ORG_ID
);
if
(
ret
!=
null
)
{
return
String
.
valueOf
(
ret
);
}
return
null
;
}
/**
* Description: 获取当前用户所在的租户
* <br />
* CreateDate 2021-11-08 10:32:53
*
* @author yuyi
**/
public
static
String
getTenantNo
()
{
Object
ret
=
ThreadLocalUtil
.
getCache
(
AuthConstant
.
TENANT_NO_NAME
);
if
(
ret
!=
null
)
{
return
String
.
valueOf
(
ret
);
}
return
null
;
}
}
src/main/java/com/cusc/nirvana/user/rnr/openapi/util/Utils.java
0 → 100644
View file @
df1d7dc5
package
com.cusc.nirvana.user.rnr.openapi.util
;
import
org.apache.commons.codec.binary.Base64
;
import
java.security.KeyPair
;
import
java.security.PrivateKey
;
import
java.security.PublicKey
;
public
class
Utils
{
/**
* 将二进制转换成16进制
*/
public
static
String
parseByte2HexStr
(
byte
buf
[])
{
StringBuffer
sb
=
new
StringBuffer
();
for
(
int
i
=
0
;
i
<
buf
.
length
;
i
++)
{
String
hex
=
Integer
.
toHexString
(
buf
[
i
]
&
0xFF
);
if
(
hex
.
length
()
==
1
)
{
hex
=
'0'
+
hex
;
}
sb
.
append
(
hex
.
toUpperCase
());
}
return
sb
.
toString
();
}
/**
* 将16进制转换为二进制
*/
public
static
byte
[]
parseHexStr2Byte
(
String
hexStr
)
{
if
(
hexStr
.
length
()
<
1
)
{
return
null
;
}
byte
[]
result
=
new
byte
[
hexStr
.
length
()
/
2
];
for
(
int
i
=
0
;
i
<
hexStr
.
length
()
/
2
;
i
++)
{
int
high
=
Integer
.
parseInt
(
hexStr
.
substring
(
i
*
2
,
i
*
2
+
1
),
16
);
int
low
=
Integer
.
parseInt
(
hexStr
.
substring
(
i
*
2
+
1
,
i
*
2
+
2
),
16
);
result
[
i
]
=
(
byte
)
(
high
*
16
+
low
);
}
return
result
;
}
/**
* 从密钥对获取 私钥
*
* @param keyPair
* @return
*/
public
static
String
privateKey
(
KeyPair
keyPair
)
{
byte
[]
privateKey
=
keyPair
.
getPrivate
().
getEncoded
();
return
Base64
.
encodeBase64String
(
privateKey
);
}
/**
* 从密钥对获取 公钥
*
* @param keyPair
* @return
*/
public
static
String
publicKey
(
KeyPair
keyPair
)
{
byte
[]
publicKey
=
keyPair
.
getPublic
().
getEncoded
();
return
Base64
.
encodeBase64String
(
publicKey
);
}
/**
* print KeyPair to console for test
*
* @param keyPair
*/
public
static
void
print
(
KeyPair
keyPair
)
{
// 分别得到公钥和私钥
PublicKey
publicKey
=
keyPair
.
getPublic
();
PrivateKey
privateKey
=
keyPair
.
getPrivate
();
// 使用 Base64编码
String
publicKeyStr
=
Base64
.
encodeBase64String
(
publicKey
.
getEncoded
());
String
privateKeyStr
=
Base64
.
encodeBase64String
(
privateKey
.
getEncoded
());
System
.
out
.
println
(
publicKeyStr
);
System
.
err
.
println
(
privateKeyStr
);
}
}
Prev
1
2
3
4
5
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