Commit b2eded42 authored by kang.nie@inzymeits.com's avatar kang.nie@inzymeits.com
Browse files

初始化代码

parent 12156d65
Pipeline #3109 failed with stages
in 0 seconds
package com.cusc.nirvana.user.rnr.mg.service;
import com.cusc.nirvana.user.rnr.notice.dto.RnrNoticeConfigDTO;
/**
* @className: NoticeConfigService
* @author: jk
* @date: 2022/7/29 19:39
* @version: 1.0
**/
public interface NoticeConfigService {
RnrNoticeConfigDTO queryNoticeConfig(String noticeConfigId);
}
package com.cusc.nirvana.user.rnr.mg.service;
import com.cusc.nirvana.common.result.Response;
import com.cusc.nirvana.user.rnr.mg.constants.ProjectConstant;
import com.cusc.nirvana.user.rnr.mg.dto.ProjectNumRequestDTO;
import com.cusc.nirvana.user.rnr.mg.dto.ProjectNumResponseDTO;
import com.cusc.nirvana.user.rnr.mg.util.RnrMgRestTemplateUtils;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
import javax.annotation.Resource;
/**
* @author yubo
* @since 2022-04-19 15:38
*/
@Service
public class ProjectServiceImpl implements IProjectService {
@Resource
RestTemplate restTemplate;
@Override
public Response<ProjectNumResponseDTO> findProjectNoByIccid(String iccid) {
return RnrMgRestTemplateUtils.postForResponse(restTemplate, ProjectConstant.PROJECT_SERVICE_URL + "/project/api/v1/sim/iccid/project", new ProjectNumRequestDTO(iccid), ProjectNumResponseDTO.class);
}
}
package com.cusc.nirvana.user.rnr.mg.service;
import com.cusc.nirvana.user.rnr.notice.dto.RnrNoticeConfigDTO;
import com.cusc.nirvana.user.rnr.notice.dto.RnrNoticeContentDTO;
import java.util.List;
/**
* @className: TimingSendService
* @author: jk
* @date: 2022/7/29 17:20
* @version: 1.0
**/
public interface TimingSendService {
void sendKafka (List<RnrNoticeContentDTO> list);
}
package com.cusc.nirvana.user.rnr.mg.service.impl;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.cusc.nirvana.common.result.Response;
import com.cusc.nirvana.user.ciam.client.CiamUserClient;
import com.cusc.nirvana.user.ciam.dto.CiamUserDTO;
import com.cusc.nirvana.user.rnr.mg.dto.MgRnrInfoDTO;
import com.cusc.nirvana.user.rnr.mg.service.ICiamService;
import com.cusc.nirvana.user.rnr.mg.service.IMgRnrInfoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* @author yubo
* @since 2022-05-06 20:46
*/
@Service
@Slf4j
public class CiamServiceImpl implements ICiamService {
@Autowired
CiamUserClient userClient;
@Autowired
IMgRnrInfoService mgRnrInfoService;
@Override
public void createUser(MgRnrInfoDTO mgRnrInfoDTO) {
//创建用户
log.info("创建用户,{}", mgRnrInfoDTO);
try {
CiamUserDTO userDTO = new CiamUserDTO();
userDTO.setTenantNo(mgRnrInfoDTO.getTenantNo());
userDTO.setPhoneNum(mgRnrInfoDTO.getPhone());
Response<CiamUserDTO> user = userClient.createUser(userDTO);
if (!user.isSuccess() && user.getData() == null) {
log.error("创建用户失败:{}", JSON.toJSONString(user));
return;
}
UpdateWrapper updateWrapper = new UpdateWrapper();
updateWrapper.eq("uuid", mgRnrInfoDTO.getUuid());
updateWrapper.set("user_id", user.getData().getUuid());
mgRnrInfoService.update(updateWrapper);
} catch (Exception e) {
log.error("创建用户失败", e);
}
}
}
package com.cusc.nirvana.user.rnr.mg.service.impl;
import com.alibaba.fastjson.JSON;
import com.cusc.nirvana.common.loader.CollectionUtils;
import com.cusc.nirvana.common.result.Response;
import com.cusc.nirvana.user.eiam.client.UserClient;
import com.cusc.nirvana.user.eiam.dto.UserDTO;
import com.cusc.nirvana.user.rnr.mg.constants.AuthWayTypeEnum;
import com.cusc.nirvana.user.rnr.mg.constants.CertTypeEnum;
import com.cusc.nirvana.user.rnr.mg.constants.CompanyTypeEnum;
import com.cusc.nirvana.user.rnr.mg.constants.GenderEnum;
import com.cusc.nirvana.user.rnr.mg.constants.IndustryTypeEnum;
import com.cusc.nirvana.user.rnr.mg.constants.RnrFileType;
import com.cusc.nirvana.user.rnr.mg.dto.EnterpriseVerifyDetailDTO;
import com.cusc.nirvana.user.rnr.mg.dto.MgRnrAuthenticationResultDTO;
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.RnrOrderDTO;
import com.cusc.nirvana.user.rnr.mg.service.IEnterpriseVerifyService;
import com.cusc.nirvana.user.rnr.mg.service.IFileService;
import com.cusc.nirvana.user.rnr.mg.service.IMgRnrAuthenticationResultService;
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 javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* @author xxx
*/
@Service
@Slf4j
public class EnterpriseVerifyServiceImpl implements IEnterpriseVerifyService {
@Autowired
private RnrOrderServiceImpl rnrOrderService;
@Autowired
private MgRnrCompanyInfoServiceImpl mgRnrCompanyInfoService;
@Autowired
private MgRnrInfoServiceImpl mgRnrInfoService;
@Autowired
private MgRnrFileServiceImpl mgRnrFileService;
@Autowired
private IMgRnrAuthenticationResultService iMgRnrAuthenticationResultService;
@Autowired
private UserClient userClient;
@Resource
private IFileService fileService;
@Override
public Response<EnterpriseVerifyDetailDTO> getEnterpriseDetail(RnrOrderDTO rnrOrderDTO) {
EnterpriseVerifyDetailDTO enterpriseVerifyDetailDTO = new EnterpriseVerifyDetailDTO();
//查询工单信息
RnrOrderDTO rnrOrderDetails = rnrOrderService.getByUuid(rnrOrderDTO);
log.info("查询工单信息返参:{}", JSON.toJSONString(rnrOrderDetails));
if (null == rnrOrderDetails) {
return Response.createError("工单不存在");
}
BeanUtils.copyProperties(rnrOrderDetails, enterpriseVerifyDetailDTO.getRnrOrderDetail());
//----企业信息,根据rnr_id实名id查询企业信息
MgRnrCompanyInfoDTO companyInfoParams = new MgRnrCompanyInfoDTO();
//rnr_id为uuid
companyInfoParams.setRnrId(rnrOrderDetails.getRnrId());
MgRnrCompanyInfoDTO mgRnrCompanyInfoDTO = mgRnrCompanyInfoService.getByRnrid(companyInfoParams);
log.info("查询企业信息返参:{}", JSON.toJSONString(mgRnrCompanyInfoDTO));
if (mgRnrCompanyInfoDTO == null) {
return Response.createError("企业信息不能为空");
}
BeanUtils.copyProperties(mgRnrCompanyInfoDTO, enterpriseVerifyDetailDTO.getCompanyInfoDetail());
//责任人的信息
MgRnrInfoDTO rnrInfoParams = new MgRnrInfoDTO();
rnrInfoParams.setUuid(rnrOrderDetails.getRnrId());
MgRnrInfoDTO mgRnrInfoDTO = mgRnrInfoService.getByUuid(rnrInfoParams);
log.info("查询责任人的信息返参:{}", JSON.toJSONString(mgRnrInfoDTO));
if (mgRnrInfoDTO == null || StringUtils.isBlank(mgRnrInfoDTO.getCertType())) {
return Response.createError("实名责任人信息不能为空");
}
EnterpriseVerifyDetailDTO.CorporationInfoDetail corporationInfoDetail =
enterpriseVerifyDetailDTO.getCorporationInfoDetail();
corporationInfoDetail.setCorporationName(mgRnrInfoDTO.getFullName());
corporationInfoDetail.setCorporationGender(mgRnrInfoDTO.getGender());
corporationInfoDetail.setCorporationGenderName(GenderEnum.findNameByCode(mgRnrInfoDTO.getGender()));
// corporationInfoDetail.setCorporationCertType(mgRnrInfoDTO.getCertType());
corporationInfoDetail.setCorporationCertType(CertTypeEnum.getEnumByCode(mgRnrInfoDTO.getCertType()).getName());
corporationInfoDetail.setCorporationCertNumber(mgRnrInfoDTO.getCertNumber());
corporationInfoDetail.setCorporationCertExpirationDate(mgRnrInfoDTO.getExpiredDate());
corporationInfoDetail.setCorporationCertAddress(mgRnrInfoDTO.getCertAddress());
corporationInfoDetail.setCorporationPhone(mgRnrInfoDTO.getPhone());
corporationInfoDetail.setCorporationContactAddress(mgRnrInfoDTO.getContactAddress());
BeanUtils.copyProperties(mgRnrInfoDTO, enterpriseVerifyDetailDTO.getCorporationInfoDetail());
//通过rnrId查询企业所有相关证件,包括责任人身份证人像面、身份证国徽面、活体截图1、企业证件照片、委托书
MgRnrFileDTO file = new MgRnrFileDTO();
file.setRnrId(rnrOrderDetails.getRnrId());
/////file.setFileType(RnrFileType.ENTERPRISE_AUTH_FILE.getCode());
List<MgRnrFileDTO> fileList = mgRnrFileService.queryByList(file);
log.info("查询文件信息返参:{}", JSON.toJSONString(fileList));
if (CollectionUtils.isEmpty(fileList)) {
return Response.createError("企业相关证件不能为空");
}
fileList.forEach(mgRnrFileDTO -> {
try {
//活体认证视频,视频返回url
//base64与url不同时返回,url放在base64里
if (RnrFileType.LIVENESS_VIDEO.getCode().intValue() == mgRnrFileDTO.getFileType()
&& StringUtils.isNotBlank(mgRnrFileDTO.getFileSystemId())) {
/* String objectUrl = null;
if (FIleSystemType.OSS.getCode().equals(fileSelect)) {
objectUrl = OSSUtil.getFileUrl(ossConfig.getBucketName(),
ossConfig.getPrefix() + mgRnrFileDTO.getFileSystemId());
} else {
throw new CuscUserException(fileSelect, "未知文件系统");
}*/
String fileUrl = fileService.getFileUrl(mgRnrFileDTO.getFileSystemId());
mgRnrFileDTO.setFileBase64(fileUrl);
}
} catch (Exception e) {
log.error("---根据FileSystemId获取文件url失败mgRnrFileDTO:{}", mgRnrFileDTO);
log.error("---根据FileSystemId获取文件url失败Exception:{}", e);
}
});
//文件根据fileSystemId统一调用接口
//根据文件类型分组
Map<Integer, List<MgRnrFileDTO>> fileMap2List =
fileList.stream().collect(Collectors.groupingBy(MgRnrFileDTO::getFileType));
List<String> fileSystemList = new ArrayList<>();
log.warn("fileList++++++++{}",JSON.toJSON(fileList));
for(MgRnrFileDTO mgRnrFileDTO:fileList){
if(RnrFileType.VEHUCLE_BIND.getCode().equals(mgRnrFileDTO.getFileType())||RnrFileType.DUTY_FILE.getCode().equals(mgRnrFileDTO.getFileType())||RnrFileType.ENTERPRISE_AUTH_FILE.getCode().equals(mgRnrFileDTO.getFileType())){
fileSystemList.add(mgRnrFileDTO.getFileSystemId());
}
}
log.warn("fileSystemList========={}",JSON.toJSON(fileSystemList));
enterpriseVerifyDetailDTO.getCorporationInfoDetail().setFileSystemList(fileSystemList);
//设置企业证件照片
enterpriseVerifyDetailDTO.getCompanyInfoDetail()
.setCompanyLicenseFiles(fileMap2List.get(RnrFileType.ENTERPRISE_PIC.getCode()));
enterpriseVerifyDetailDTO.getCompanyInfoDetail().setCompanyCertType(CertTypeEnum.getEnumByCode(mgRnrCompanyInfoDTO.getCompanyCertType()).getName());
enterpriseVerifyDetailDTO.getCompanyInfoDetail().setCompanyType(null !=CompanyTypeEnum.getEnumByCode(mgRnrCompanyInfoDTO.getCompanyType())?CompanyTypeEnum.getEnumByCode(mgRnrCompanyInfoDTO.getCompanyType()).getValue():"");
enterpriseVerifyDetailDTO.getCompanyInfoDetail().setIndustryType(null != IndustryTypeEnum.getEnumByCode(mgRnrCompanyInfoDTO.getIndustryType()) ?IndustryTypeEnum.getEnumByCode(mgRnrCompanyInfoDTO.getIndustryType()).getValue():"");
//设置企业实名认证授权书
enterpriseVerifyDetailDTO.getCorporationInfoDetail()
.setAuthorizationLetterPic(fileMap2List.get(RnrFileType.ENTERPRISE_AUTH_FILE.getCode()));
//人脸图片
enterpriseVerifyDetailDTO.getVerifyLivingMsg().getFaceImages()
.addAll((fileMap2List.get(RnrFileType.LIVENESS_SCREEN_FIRST.getCode())));
enterpriseVerifyDetailDTO.getVerifyLivingMsg().getFaceImages()
.addAll((fileMap2List.get(RnrFileType.LIVENESS_SCREEN_TWO.getCode())));
//活体认证视频,视频返回url
enterpriseVerifyDetailDTO.getVerifyLivingMsg()
.setLivingVideo(fileMap2List.get(RnrFileType.LIVENESS_VIDEO.getCode()).get(0));
////上面会必有的文件,下面可能没有,只会有一种,如身份证或警官证,详见枚举类CertTypeEnum,根据证件类型返回文件
String certType = mgRnrInfoDTO.getCertType();
//身份证
if (CertTypeEnum.IDCARD.getCode().equalsIgnoreCase(certType)) {
//设置责任人身份证人像面
enterpriseVerifyDetailDTO.getCorporationInfoDetail().setCorporationCertFrontPic(
CollectionUtils.isNotEmpty(fileMap2List.get(RnrFileType.IDENTITY_CARD_BACK.getCode())) ?
fileMap2List.get(RnrFileType.IDENTITY_CARD_BACK.getCode()).get(0) : null);
//设置责任人身份证身份证国徽面
enterpriseVerifyDetailDTO.getCorporationInfoDetail().setCorporationCertBackPic(
CollectionUtils.isNotEmpty(fileMap2List.get(RnrFileType.IDENTITY_CARD_FRONT.getCode())) ?
fileMap2List.get(RnrFileType.IDENTITY_CARD_FRONT.getCode()).get(0) : null);
}
//港澳居民来往内地通行证
else if (CertTypeEnum.HKIDCARD.getCode().equalsIgnoreCase(certType)) {
enterpriseVerifyDetailDTO.getCorporationInfoDetail().setCorporationCertFrontPic(
CollectionUtils.isNotEmpty(fileMap2List.get(RnrFileType.HK_MACAO_PASSPORT_FRONT.getCode())) ?
fileMap2List.get(RnrFileType.HK_MACAO_PASSPORT_FRONT.getCode()).get(0) : null);
enterpriseVerifyDetailDTO.getCorporationInfoDetail().setCorporationCertBackPic(
CollectionUtils.isNotEmpty(fileMap2List.get(RnrFileType.HK_MACAO_PASSPORT_BACK.getCode())) ?
fileMap2List.get(RnrFileType.HK_MACAO_PASSPORT_BACK.getCode()).get(0) : null);
}
//护照
else if (CertTypeEnum.PASSPORT.getCode().equalsIgnoreCase(certType)) {
enterpriseVerifyDetailDTO.getCorporationInfoDetail().setCorporationCertFrontPic(
CollectionUtils.isNotEmpty(
fileMap2List.get(RnrFileType.FOREIGN_NATIONAL_PASSPORT_FRONT.getCode())) ?
fileMap2List.get(RnrFileType.FOREIGN_NATIONAL_PASSPORT_FRONT.getCode()).get(0) : null);
enterpriseVerifyDetailDTO.getCorporationInfoDetail().setCorporationCertBackPic(
CollectionUtils.isNotEmpty(fileMap2List.get(RnrFileType.FOREIGN_NATIONAL_PASSPORT_BACK.getCode())) ?
fileMap2List.get(RnrFileType.FOREIGN_NATIONAL_PASSPORT_BACK.getCode()).get(0) : null);
}
//军官证
else if (CertTypeEnum.PLA.getCode().equalsIgnoreCase(certType)) {
enterpriseVerifyDetailDTO.getCorporationInfoDetail().setCorporationCertFrontPic(
CollectionUtils.isNotEmpty(fileMap2List.get(RnrFileType.OFFICIAL_CARD_FRONT.getCode())) ?
fileMap2List.get(RnrFileType.OFFICIAL_CARD_FRONT.getCode()).get(0) : null);
enterpriseVerifyDetailDTO.getCorporationInfoDetail().setCorporationCertBackPic(
CollectionUtils.isNotEmpty(fileMap2List.get(RnrFileType.OFFICIAL_CARD_BACK.getCode())) ?
fileMap2List.get(RnrFileType.OFFICIAL_CARD_BACK.getCode()).get(0) : null);
}
//警官证
else if (CertTypeEnum.POLICEPAPER.getCode().equalsIgnoreCase(certType)) {
enterpriseVerifyDetailDTO.getCorporationInfoDetail().setCorporationCertFrontPic(
CollectionUtils.isNotEmpty(fileMap2List.get(RnrFileType.POLICE_CARD_FRONT.getCode())) ?
fileMap2List.get(RnrFileType.POLICE_CARD_FRONT.getCode()).get(0) : null);
enterpriseVerifyDetailDTO.getCorporationInfoDetail().setCorporationCertBackPic(
CollectionUtils.isNotEmpty(fileMap2List.get(RnrFileType.POLICE_CARD_BACK.getCode())) ?
fileMap2List.get(RnrFileType.POLICE_CARD_BACK.getCode()).get(0) : null);
}
//台湾居民来往大陆通行证
else if (CertTypeEnum.TAIBAOZHENG.getCode().equalsIgnoreCase(certType)) {
enterpriseVerifyDetailDTO.getCorporationInfoDetail().setCorporationCertFrontPic(
CollectionUtils.isNotEmpty(fileMap2List.get(RnrFileType.TAIWAN_CARD_FRONT.getCode())) ?
fileMap2List.get(RnrFileType.TAIWAN_CARD_FRONT.getCode()).get(0) : null);
enterpriseVerifyDetailDTO.getCorporationInfoDetail().setCorporationCertBackPic(
CollectionUtils.isNotEmpty(fileMap2List.get(RnrFileType.TAIWAN_CARD_BACK.getCode())) ?
fileMap2List.get(RnrFileType.TAIWAN_CARD_BACK.getCode()).get(0) : null);
}
//港澳居民居住证
else if (CertTypeEnum.HKRESIDENCECARD.getCode().equalsIgnoreCase(certType)) {
enterpriseVerifyDetailDTO.getCorporationInfoDetail().setCorporationCertFrontPic(
CollectionUtils.isNotEmpty(
fileMap2List.get(RnrFileType.HK_MACAO_RESIDENCE_PERMIT_FRONT.getCode())) ?
fileMap2List.get(RnrFileType.HK_MACAO_RESIDENCE_PERMIT_FRONT.getCode()).get(0) : null);
enterpriseVerifyDetailDTO.getCorporationInfoDetail().setCorporationCertBackPic(
CollectionUtils.isNotEmpty(fileMap2List.get(RnrFileType.HK_MACAO_RESIDENCE_PERMIT_BACK.getCode())) ?
fileMap2List.get(RnrFileType.HK_MACAO_RESIDENCE_PERMIT_BACK.getCode()).get(0) : null);
}
//台湾居民居住证
else if (CertTypeEnum.TWRESIDENCECARD.getCode().equalsIgnoreCase(certType)) {
enterpriseVerifyDetailDTO.getCorporationInfoDetail().setCorporationCertFrontPic(
CollectionUtils.isNotEmpty(fileMap2List.get(RnrFileType.TAIWAN_RESIDENCE_PERMIT_FRONT.getCode())) ?
fileMap2List.get(RnrFileType.TAIWAN_RESIDENCE_PERMIT_FRONT.getCode()).get(0) : null);
enterpriseVerifyDetailDTO.getCorporationInfoDetail().setCorporationCertBackPic(
CollectionUtils.isNotEmpty(fileMap2List.get(RnrFileType.TAIWAN_RESIDENCE_PERMIT_BACK.getCode())) ?
fileMap2List.get(RnrFileType.TAIWAN_RESIDENCE_PERMIT_BACK.getCode()).get(0) : null);
}
//事业代为法人证书或社会团体法人证书,
// SOCIAL_ORG_LEGAL_PERSON_CERT("3", "事业代为法人证书或社会团体法人证书", false, ENTERPRISE_AUTH_FILE),
//对应RnrFileType类的ENTERPRISE_AUTH_FILE,可上传3张,但提交时只存了两张,可以get(1)
else if (CertTypeEnum.SOCIAL_ORG_LEGAL_PERSON_CERT.getCode().equalsIgnoreCase(certType)) {
enterpriseVerifyDetailDTO.getCorporationInfoDetail().setCorporationCertFrontPic(
CollectionUtils.isNotEmpty(fileMap2List.get(RnrFileType.ENTERPRISE_AUTH_FILE.getCode())) ?
fileMap2List.get(RnrFileType.ENTERPRISE_AUTH_FILE.getCode()).get(0) : null);
enterpriseVerifyDetailDTO.getCorporationInfoDetail().setCorporationCertBackPic(
CollectionUtils.isNotEmpty(fileMap2List.get(RnrFileType.ENTERPRISE_AUTH_FILE.getCode())) ?
fileMap2List.get(RnrFileType.ENTERPRISE_AUTH_FILE.getCode()).get(0) : null);
}
//户口簿
else if (CertTypeEnum.RESIDENCE.getCode().equalsIgnoreCase(certType)) {
enterpriseVerifyDetailDTO.getCorporationInfoDetail().setCorporationCertFrontPic(
CollectionUtils.isNotEmpty(fileMap2List.get(RnrFileType.RESIDENCE_BOOKLET_FRONT.getCode())) ?
fileMap2List.get(RnrFileType.RESIDENCE_BOOKLET_FRONT.getCode()).get(0) : null);
enterpriseVerifyDetailDTO.getCorporationInfoDetail().setCorporationCertBackPic(
CollectionUtils.isNotEmpty(fileMap2List.get(RnrFileType.RESIDENCE_BOOKLET_BACK.getCode())) ?
fileMap2List.get(RnrFileType.RESIDENCE_BOOKLET_BACK.getCode()).get(0) : null);
}
//其他证件
else if (CertTypeEnum.OTHER.getCode().equalsIgnoreCase(certType)) {
List<MgRnrFileDTO> fileDTOS = fileMap2List.get(RnrFileType.OTHER.getCode());
if (!CollectionUtils.isEmpty(fileDTOS)) {
for (int i =0 ;i<fileDTOS.size();i++){
MgRnrFileDTO fileDTO = fileDTOS.get(i);
if (i == 0) {
enterpriseVerifyDetailDTO.getCorporationInfoDetail().setCorporationCertFrontPic(fileDTO);
} else {
enterpriseVerifyDetailDTO.getCorporationInfoDetail().setCorporationCertBackPic(fileDTO);
}
}
}
}
//认证结果信息
MgRnrAuthenticationResultDTO bean = new MgRnrAuthenticationResultDTO();
bean.setRnrId(rnrOrderDetails.getRnrId());
List<MgRnrAuthenticationResultDTO> authenticationResultDTOS =
iMgRnrAuthenticationResultService.queryByList(bean);
if (CollectionUtils.isNotEmpty(authenticationResultDTOS)) {
List<EnterpriseVerifyDetailDTO.AuthResult> authResultInfo =
new ArrayList<>(authenticationResultDTOS.size());
authenticationResultDTOS.forEach(authResultDTO -> {
EnterpriseVerifyDetailDTO.AuthResult authResult = new EnterpriseVerifyDetailDTO.AuthResult();
authResult.setTpAction(authResultDTO.getAuthWayType());
authResult.setTpActionName(AuthWayTypeEnum.getEnumByCode(authResultDTO.getAuthWayType()).getName());
authResult.setMessage(authResultDTO.getAuthResultMsg());
//实名认证结果,1-成功,其他-失败
authResult.setSuccess("1".equals(authResultDTO.getAuthResult()) ? true : false);
authResultInfo.add(authResult);
});
enterpriseVerifyDetailDTO.setAuthResultInfo(authResultInfo);
}
//审核信息
UserDTO userDTO = new UserDTO();
userDTO.setUuid(rnrOrderDTO.getUserId());
userDTO.setApplicationId(rnrOrderDTO.getApplicationId());
userDTO.setTenantNo(rnrOrderDTO.getTenantNo());
Response<UserDTO> userDTOResponse = userClient.getByUuid(userDTO);
UserDTO user = userDTOResponse.getData();
log.info("审核人的信息返参:{}", JSON.toJSONString(user));
if (userDTOResponse == null || user == null) {
return Response.createError("审核人不能为空");
}
//前端自己显示审核用户
enterpriseVerifyDetailDTO.getVerifyMsg().setReviewer(user.getUserName());
enterpriseVerifyDetailDTO.getVerifyMsg().setReviewDate
(DateTimeFormatter.ofPattern("yyyy-MM-dd").format(LocalDate.now()));
//设置审核意见复选框
enterpriseVerifyDetailDTO.getVerifyMsg().setVerifyComments(
Arrays.stream(rnrOrderDetails.getVerifyComments().split(",")).collect(Collectors.toList()));
//其他审核意见
enterpriseVerifyDetailDTO.getVerifyMsg().setOtherComments(rnrOrderDetails.getComment());
enterpriseVerifyDetailDTO.getVerifyMsg().setOrderStatus(rnrOrderDetails.getOrderStatus());
log.warn("enterpriseVerifyDetailDTO回参{}",JSON.toJSON(enterpriseVerifyDetailDTO));
return Response.createSuccess(enterpriseVerifyDetailDTO);
}
}
package com.cusc.nirvana.user.rnr.mg.service.impl;
import com.cusc.nirvana.common.result.Response;
import com.cusc.nirvana.user.rnr.mg.constants.RnrFileType;
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.*;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Slf4j
@Service
public class LocalChangeEnterpriseRnrPersonService {
@Autowired
private RnrOrderServiceImpl rnrOrderService;
@Autowired
private MgRnrCompanyInfoServiceImpl mgRnrCompanyInfoService;
@Autowired
private MgRnrInfoServiceImpl mgRnrInfoService;
@Autowired
private MgRnrFileServiceImpl mgRnrFileService;
/**
* 企业负责人变更审核详情
*
* @param uuid rnr_order的业务主键
* @return
*/
public Response<CompanyCorporationChangeRespDTO> enterpriseRnrPersonDetail(String uuid) {
CompanyCorporationChangeRespDTO rs = new CompanyCorporationChangeRespDTO();
//工单信息实体类
RnrOrderDTO queryBean = new RnrOrderDTO();
queryBean.setUuid(uuid);
RnrOrderDTO rnrOrderDTO = rnrOrderService.getByUuid(queryBean);
if (null == rnrOrderDTO) {
rs.setErrorCode(10001);
rs.setErrorMsg("未查询到相关工单信息");
return Response.createError(rs.getErrorMsg(), rs.getErrorCode(), rs);
} else {
CompanyCorporationChangeRespDTO.OrderDto orderDto = new CompanyCorporationChangeRespDTO.OrderDto();
//业务类型
RnrOrderType rnrOrderType = RnrOrderType.getTypeByCode(rnrOrderDTO.getOrderType());
orderDto.setOrderType(rnrOrderType.getComment());
//经销商名称
String organName = rnrOrderService.getOrganNameForOrgId(rnrOrderDTO.getOrgId());
orderDto.setOrganName(organName);
//车企名称
MgRnrCompanyInfoDTO bean2 = new MgRnrCompanyInfoDTO();
bean2.setRnrId(rnrOrderDTO.getRnrId());
MgRnrCompanyInfoDTO mgRnrCompanyInfoDTO = mgRnrCompanyInfoService.getByRnrid(bean2);
orderDto.setCompanyName(mgRnrCompanyInfoDTO.getCompanyName());
//实名日期
MgRnrInfoDTO bean3 = new MgRnrInfoDTO();
bean3.setUuid(rnrOrderDTO.getUuid());
MgRnrInfoDTO mgRnrInfoDTO = mgRnrInfoService.getByUuid(bean3);
orderDto.setUpdateTime(mgRnrInfoDTO.getUpdateTime());
orderDto.setOrderStatus(rnrOrderDTO.getOrderStatus());
rs.setOrderDto(orderDto);
}
//原企业和责任人信息
MgRnrInfoDTO queryBean2 = new MgRnrInfoDTO();
queryBean2.setTenantNo(rnrOrderDTO.getTenantNo());
queryBean2.setRnrStatus(RnrStatus.RNR.getCode());
queryBean2.setCompanyName(rs.getOrderDto().getCompanyName());
List<MgRnrInfoDTO> mgRnrInfoDTOList = mgRnrInfoService.queryByList(queryBean2);
if (mgRnrInfoDTOList.size() <= 0) {
rs.setErrorCode(10002);
rs.setErrorMsg("未查询到原企业和责任人信息");
return Response.createError(rs.getErrorMsg(), rs.getErrorCode(), rs);
} else {
CompanyCorporationChangeRespDTO.OldMgRnrInfoDto oldMgRnrInfoDto =
new CompanyCorporationChangeRespDTO.OldMgRnrInfoDto();
MgRnrInfoDTO mgRnrInfoDTO = mgRnrInfoDTOList.get(0);
oldMgRnrInfoDto.setFullName(mgRnrInfoDTO.getFullName());
oldMgRnrInfoDto.setCompanyName(mgRnrInfoDTO.getCompanyName());
rs.setOldMgRnrInfoDto(oldMgRnrInfoDto);
}
//图片相关
MgRnrFileDTO bean = new MgRnrFileDTO();
bean.setRnrId(rnrOrderDTO.getUuid());
bean.setTenantNo(rnrOrderDTO.getTenantNo());
List<MgRnrFileDTO> mgRnrFileDTOList = mgRnrFileService.getByRnrid(bean);
bean.setTenantNo(rnrOrderDTO.getTenantNo());
if (mgRnrFileDTOList.size() < 0) {
rs.setErrorCode(10003);
rs.setErrorMsg("新责任人信息查不到证件信息");
return Response.createError(rs.getErrorMsg(), rs.getErrorCode(), rs);
}
mgRnrFileDTOList.forEach(mgRnrFileDTO -> {
try {
//base64与url不同时返回,url放在base64里
if (StringUtils.isNotBlank(mgRnrFileDTO.getFileSystemId())) {
//todo 此处去掉了minio
//mgRnrFileDTO.setFileBase64(MinIOUtils.getPresignedObjectUrl(minIOConfig.getBucketName(), mgRnrFileDTO.getFileSystemId()));
}
} catch (Exception e) {
log.error("---根据FileSystemId获取文件url失败mgRnrFileDTO:{}", mgRnrFileDTO);
log.error("---根据FileSystemId获取文件url失败Exception:{}", e);
}
});
//新责任人信息
MgRnrInfoDTO queryBean3 = new MgRnrInfoDTO();
queryBean3.setUuid(rnrOrderDTO.getUuid());
MgRnrInfoDTO mgRnrInfoDTO = mgRnrInfoService.getByUuid(queryBean3);
if (null == mgRnrInfoDTO) {
rs.setErrorCode(10004);
rs.setErrorMsg("未查询到新责任人信息");
return Response.createError(rs.getErrorMsg(), rs.getErrorCode(), rs);
} else {
CompanyCorporationChangeRespDTO.NewMgRnrInfoDto newMgRnrInfoDto =
new CompanyCorporationChangeRespDTO.NewMgRnrInfoDto();
newMgRnrInfoDto.setFullName(mgRnrInfoDTO.getFullName());
newMgRnrInfoDto.setGender(mgRnrInfoDTO.getGender());
newMgRnrInfoDto.setCertType(mgRnrInfoDTO.getCertType());
newMgRnrInfoDto.setCertNumber(mgRnrInfoDTO.getCertNumber());
newMgRnrInfoDto.setExpiredDate(mgRnrInfoDTO.getExpiredDate());
newMgRnrInfoDto.setCertAddress(mgRnrInfoDTO.getCertAddress());
newMgRnrInfoDto.setPhone(mgRnrInfoDTO.getPhone());
newMgRnrInfoDto.setContactAddress(mgRnrInfoDTO.getContactAddress());
for (MgRnrFileDTO mf : mgRnrFileDTOList) {
if (mf.getFileType().equals(RnrFileType.IDENTITY_CARD_BACK.getCode())) {
//身份证人像面
newMgRnrInfoDto.setIdentityCardBackForUuId(mf.getFileBase64());
} else if (mf.getFileType().equals(RnrFileType.IDENTITY_CARD_FRONT.getCode())) {
//身份证国徽面
newMgRnrInfoDto.setIdentityCardFrontForUuId(mf.getFileBase64());
}
}
if (StringUtils.isEmpty(newMgRnrInfoDto.getIdentityCardBackForUuId())
|| StringUtils.isEmpty(newMgRnrInfoDto.getIdentityCardFrontForUuId())) {
rs.setErrorCode(10005);
rs.setErrorMsg("新责任人信息证件信息不齐");
return Response.createError(rs.getErrorMsg(), rs.getErrorCode(), rs);
}
rs.setNewMgRnrInfoDto(newMgRnrInfoDto);
}
for (MgRnrFileDTO mf : mgRnrFileDTOList) {
if (mf.getFileType().equals(RnrFileType.ENTERPRISE_AUTH_FILE.getCode())) {
//企业实名认证授权书
rs.setEnterpriseAuthFileForUuId(mf.getFileBase64());
} else if (mf.getFileType().equals(RnrFileType.LIVENESS_SCREEN_FIRST.getCode())) {
//活体截图1
rs.setLivenessScreenFirstForUuId(mf.getFileBase64());
} else if (mf.getFileType().equals(RnrFileType.LIVENESS_VIDEO.getCode())) {
//活体视频
rs.setLivenessVideoForUuId(mf.getFileBase64());
}
}
if (StringUtils.isEmpty(rs.getEnterpriseAuthFileForUuId())) {
rs.setErrorCode(10005);
rs.setErrorMsg("授权书信息有误");
return Response.createError(rs.getErrorMsg(), rs.getErrorCode(), rs);
}
if (StringUtils.isEmpty(rs.getLivenessScreenFirstForUuId())
|| StringUtils.isEmpty(rs.getLivenessVideoForUuId())) {
rs.setErrorCode(10005);
rs.setErrorMsg("证件信息不齐");
return Response.createError(rs.getErrorMsg(), rs.getErrorCode(), rs);
}
return Response.createSuccess(rs);
}
}
package com.cusc.nirvana.user.rnr.mg.service.impl;
import cn.hutool.crypto.SmUtil;
import cn.hutool.crypto.symmetric.SymmetricCrypto;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.cusc.nirvana.common.loader.CollectionUtils;
import com.cusc.nirvana.common.result.PageResult;
import com.cusc.nirvana.common.result.Response;
import com.cusc.nirvana.user.eiam.client.UserClient;
import com.cusc.nirvana.user.eiam.dto.UserDTO;
import com.cusc.nirvana.user.rnr.mg.constants.AuthWayTypeEnum;
import com.cusc.nirvana.user.rnr.mg.constants.CertTypeEnum;
import com.cusc.nirvana.user.rnr.mg.constants.GenderEnum;
import com.cusc.nirvana.user.rnr.mg.constants.PassCodeEnum;
import com.cusc.nirvana.user.rnr.mg.constants.RnrFileType;
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.constants.SubjectTypeEnum;
import com.cusc.nirvana.user.rnr.mg.converter.MgRnrCompanyInfoConverter;
import com.cusc.nirvana.user.rnr.mg.converter.MgRnrImageConverter;
import com.cusc.nirvana.user.rnr.mg.converter.MgRnrInfoConverter;
import com.cusc.nirvana.user.rnr.mg.converter.MgRnrLiaisonInfoConverter;
import com.cusc.nirvana.user.rnr.mg.converter.RnrOrderConverter;
import com.cusc.nirvana.user.rnr.mg.dao.RnrOrderDao;
import com.cusc.nirvana.user.rnr.mg.dao.entity.MgRnrCardInfoPO;
import com.cusc.nirvana.user.rnr.mg.dao.entity.MgRnrCompanyInfoPO;
import com.cusc.nirvana.user.rnr.mg.dao.entity.MgRnrFilePO;
import com.cusc.nirvana.user.rnr.mg.dao.entity.MgRnrInfoPO;
import com.cusc.nirvana.user.rnr.mg.dao.entity.MgRnrLiaisonInfoPO;
import com.cusc.nirvana.user.rnr.mg.dao.entity.RnrOrderPO;
import com.cusc.nirvana.user.rnr.mg.dto.EnterpriseVerifyDetailDTO;
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.LocalVerifyPersonDetailDTO;
import com.cusc.nirvana.user.rnr.mg.dto.LocalVerifySubmitRq;
import com.cusc.nirvana.user.rnr.mg.dto.MgRnrAuthenticationResultDTO;
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.MgRnrLiaisonInfoDTO;
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.service.IFileService;
import com.cusc.nirvana.user.rnr.mg.service.IMgRnrAuthenticationResultService;
import com.cusc.nirvana.user.rnr.mg.util.DateUtil;
import com.cusc.nirvana.user.rnr.workorder.constants.WorkOrderTypeEnum;
import com.cusc.nirvana.user.rnr.workorder.dto.WorkOrderReviewCallBackRequestDTO;
import com.cusc.nirvana.user.rnr.workorder.handler.impl.EnterpriseChangeCallBackHandler;
import com.cusc.nirvana.user.rnr.workorder.handler.impl.ManufacturerRnrCallBackHandler;
import com.cusc.nirvana.user.rnr.workorder.handler.impl.RnrWorkOrderCallBackHandler;
import com.cusc.nirvana.user.rnr.workorder.handler.impl.UnbindWorkOrderCallBackHandler;
import com.cusc.nirvana.user.util.CuscStringUtils;
import com.cusc.nirvana.user.util.crypt.CryptKeyUtil;
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.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Date;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
@Slf4j
@Service
public class LocalVerifyService {
@Autowired
NotifyCloudService notifyCloudService;
@Autowired
RnrOrderServiceImpl rnrOrderService;
@Autowired
RnrOrderDao rnrOrderDao;
@Autowired
MgRnrInfoServiceImpl mgRnrInfoService;
@Autowired
MgRnrCardInfoServiceImpl mgRnrCardInfoService;
@Autowired
MgRnrCompanyInfoServiceImpl mgRnrCompanyInfoService;
@Autowired
MgRnrFileServiceImpl mgRnrFileService;
@Autowired
MgRnrLiaisonInfoServiceImpl mgRnrLiaisonInfoService;
@Autowired
ManufacturerRnrCallBackHandler manufacturerRnrCallBackHandler;
@Autowired
UnbindWorkOrderCallBackHandler unbindWorkOrderCallBackHandler;
@Autowired
RnrWorkOrderCallBackHandler rnrWorkOrderCallBackHandler;
@Autowired
EnterpriseChangeCallBackHandler enterpriseChangeCallBackHandler;
@Resource
private IFileService fileService;
@Autowired
private UserClient userClient;
@Autowired
private IMgRnrAuthenticationResultService iMgRnrAuthenticationResultService;
/**
* 自然人关联文件类型集合
*/
private static Set<Integer> NPFileTypeSet = new HashSet<>();
static {
NPFileTypeSet.add(RnrFileType.IDENTITY_CARD_BACK.getCode());
NPFileTypeSet.add(RnrFileType.IDENTITY_CARD_FRONT.getCode());
NPFileTypeSet.add(RnrFileType.POLICE_CARD_FRONT.getCode());
NPFileTypeSet.add(RnrFileType.POLICE_CARD_BACK.getCode());
NPFileTypeSet.add(RnrFileType.HK_MACAO_PASSPORT_FRONT.getCode());
NPFileTypeSet.add(RnrFileType.HK_MACAO_PASSPORT_BACK.getCode());
NPFileTypeSet.add(RnrFileType.TAIWAN_CARD_FRONT.getCode());
NPFileTypeSet.add(RnrFileType.TAIWAN_CARD_BACK.getCode());
NPFileTypeSet.add(RnrFileType.FOREIGN_NATIONAL_PASSPORT_FRONT.getCode());
NPFileTypeSet.add(RnrFileType.FOREIGN_NATIONAL_PASSPORT_BACK.getCode());
NPFileTypeSet.add(RnrFileType.HK_MACAO_RESIDENCE_PERMIT_FRONT.getCode());
NPFileTypeSet.add(RnrFileType.HK_MACAO_RESIDENCE_PERMIT_BACK.getCode());
NPFileTypeSet.add(RnrFileType.TAIWAN_RESIDENCE_PERMIT_FRONT.getCode());
NPFileTypeSet.add(RnrFileType.TAIWAN_RESIDENCE_PERMIT_BACK.getCode());
NPFileTypeSet.add(RnrFileType.RESIDENCE_BOOKLET_FRONT.getCode());
NPFileTypeSet.add(RnrFileType.RESIDENCE_BOOKLET_BACK.getCode());
NPFileTypeSet.add(RnrFileType.OFFICIAL_CARD_FRONT.getCode());
NPFileTypeSet.add(RnrFileType.OFFICIAL_CARD_BACK.getCode());
NPFileTypeSet.add(RnrFileType.OTHER.getCode());
}
public Response<PageResult<LocalVerifyListDTO>> orderList(LocalVerifyListRqDTO rq) {
PageResult pageResult = new PageResult();
if (StringUtils.isNotBlank(rq.getVin())) {
rq.setVin(CryptKeyUtil.encryptToBase64(rq.getVin()));
}
if (StringUtils.isNotBlank(rq.getIccid())) {
rq.setIccid(CryptKeyUtil.encryptToBase64(rq.getIccid()));
}
if (StringUtils.isNotBlank(rq.getVinOwnerName())) {
rq.setVinOwnerName("%" + CryptKeyUtil.encryptToBase64(rq.getVinOwnerName()) + "%");
}
if (StringUtils.isNotBlank(rq.getVinOwnerPhone())) {
rq.setVinOwnerPhone("%" + CryptKeyUtil.encryptToBase64(rq.getVinOwnerPhone()) + "%");
}
if (StringUtils.isNotBlank(rq.getVinCompanyName())) {
rq.setVinCompanyName("%" + CryptKeyUtil.encryptToBase64(rq.getVinCompanyName()) + "%");
}
if (StringUtils.isNotBlank(rq.getOrgName())) {
rq.setOrgName("%" + CryptKeyUtil.encryptToBase64(rq.getOrgName()) + "%");
}
Integer total = rnrOrderService.orderTotal(rq);
List<LocalVerifyListDTO> datas = rnrOrderService.orderList(rq);
if (!CollectionUtils.isEmpty(datas)) {
for (LocalVerifyListDTO data : datas) {
if (null != data) {
//data.setVin(CryptKeyUtil.decryptByBase64(data.getVin()));
//一平sql用,拼的,多个iccid时不能直接解密
if (data.getIccid().contains(",")) {
List<String> iccids = new LinkedList<>();
for (String iccid : data.getIccid().split(",")) {
iccids.add(CryptKeyUtil.decryptByBase64(iccid));
}
data.setIccid(StringUtils.join(iccids, ","));
} else {
data.setIccid(CryptKeyUtil.decryptByBase64(data.getIccid()));
}
if (data.getVin().contains(",")) {
List<String> vinList = new LinkedList<>();
for (String vin : data.getVin().split(",")) {
vinList.add(CryptKeyUtil.decryptByBase64(vin));
}
data.setVin(StringUtils.join(vinList, ","));
} else {
data.setVin(CryptKeyUtil.decryptByBase64(data.getVin()));
}
data.setOrderTypeName(
RnrOrderType.getTypeByCode(Integer.valueOf(data.getOrderType())).getComment());
data.setVinOwnerName(CryptKeyUtil.decryptByBase64(data.getVinOwnerName()));
data.setVinOwnerPhone(CryptKeyUtil.decryptByBase64(data.getVinOwnerPhone()));
data.setVinCompanyName(CryptKeyUtil.decryptByBase64(data.getVinCompanyName()));
}
}
}
pageResult.setCurrPage(rq.getCurrPage());
pageResult.setPageSize(rq.getPageSize());
pageResult.setTotalCount(total);
pageResult.setList(datas);
return Response.createSuccess(pageResult);
}
public Response<LocalVerifyPersonDetailDTO> personDetail(LocalVerifyListRqDTO rq) {
RnrOrderPO rnrOrderPO =
rnrOrderService.getOne(new QueryWrapper<RnrOrderPO>().eq("uuid", rq.getRnrOrderInfoId()));
if (null == rnrOrderPO) {
return Response.createError("工单不存在");
}
MgRnrInfoPO mgRnrInfoPO =
mgRnrInfoService.getOne(new QueryWrapper<MgRnrInfoPO>().eq("uuid", rnrOrderPO.getRnrId()));
if (null == mgRnrInfoPO) {
return Response.createError("工单详情不存在");
}
List<MgRnrCardInfoPO> mgRnrCardInfoPOS =
mgRnrCardInfoService.list(new QueryWrapper<MgRnrCardInfoPO>().eq("rnr_id", rnrOrderPO.getRnrId()));
if (null == mgRnrInfoPO || mgRnrCardInfoPOS.size() == 0) {
return Response.createError("实名信息不存在");
}
String companyName = "";
List<MgRnrCompanyInfoPO> mgRnrCompanyInfoPOS = mgRnrCompanyInfoService.list(
new QueryWrapper<MgRnrCompanyInfoPO>().eq("rnr_id", rnrOrderPO.getRnrId()));
if (null != mgRnrCompanyInfoPOS && mgRnrCompanyInfoPOS.size() != 0) {
companyName = mgRnrCompanyInfoPOS.get(0).getCompanyName();
}
List<MgRnrFilePO> mgRnrFilePOS =
mgRnrFileService.getPoByRnridOrderByOrderno(mgRnrInfoPO.getUuid(), mgRnrInfoPO.getTenantNo());
if (CollectionUtils.isNotEmpty(mgRnrFilePOS)) {
mgRnrFilePOS.forEach(mgRnrFileDTO -> {
try {
//活体认证视频,视频返回url
//base64与url不同时返回,url放在base64里
if (RnrFileType.LIVENESS_VIDEO.getCode().intValue() == mgRnrFileDTO.getFileType()
&& StringUtils.isNotBlank(mgRnrFileDTO.getFileSystemId())) {
/* String objectUrl = null;
if (FIleSystemType.OSS.getCode().equals(fileSelect)) {
objectUrl = OSSUtil.getFileUrl(ossConfig.getBucketName(),
ossConfig.getPrefix() + mgRnrFileDTO.getFileSystemId());
} else {
throw new CuscUserException(fileSelect, "未知文件系统");
}*/
String fileUrl = fileService.getFileUrl(mgRnrFileDTO.getFileSystemId());
mgRnrFileDTO.setFileSystemId(fileUrl);
}
} catch (Exception e) {
log.error("---根据FileSystemId获取文件url失败mgRnrFileDTO:{}", mgRnrFileDTO);
log.error("---根据FileSystemId获取文件url失败Exception:{}", e);
}
});
}
String orgname = rnrOrderDao.getOrgnameById(mgRnrInfoPO.getOrgId());
LocalVerifyPersonDetailDTO localVerifyPersonDetailDTO = new LocalVerifyPersonDetailDTO();
//工单信息
localVerifyPersonDetailDTO.setRnrOrderDetail(new LocalVerifyPersonDetailDTO.RnrOrderDetail(
orgname, companyName,
RnrOrderType.getTypeByCode(Integer.valueOf(rnrOrderPO.getOrderType())).getComment(),
DateUtil.toString(rnrOrderPO.getCreateTime(), DateUtil.yyyy_MM_dd_HH_mm_ss)));
//车卡信息
ArrayList<LocalVerifyPersonDetailDTO.VinCardMsg> vinCardMsgs = new ArrayList<>();
for (MgRnrCardInfoPO mgRnrCardInfoPO : mgRnrCardInfoPOS) {
vinCardMsgs.add(new LocalVerifyPersonDetailDTO.VinCardMsg(
mgRnrCardInfoPO.getIotId(), mgRnrCardInfoPO.getIccid(),
RnrStatus.getEnumByCode(mgRnrCardInfoPO.getRnrStatus()).getComment()));
}
localVerifyPersonDetailDTO.setVinCardMsg(vinCardMsgs);
//车主信息
localVerifyPersonDetailDTO.setVinOwnerMsg(new LocalVerifyPersonDetailDTO.PersonMsg(
mgRnrInfoPO.getFullName(), GenderEnum.findByCode(mgRnrInfoPO.getGender()).getName(),
CertTypeEnum.getEnumByCode(mgRnrInfoPO.getCertType()).getName(),
"", "", mgRnrInfoPO.getCertNumber(),
mgRnrInfoPO.getExpiredDate(),
mgRnrInfoPO.getCertAddress(), mgRnrInfoPO.getPhone(), mgRnrInfoPO.getContactAddress()
));
/* for (MgRnrFilePO mgRnrFilePO : mgRnrFilePOS) {
//是0,为自然人的证件信息,不是0为代办人证件信息
if (StringUtils.isNotBlank(mgRnrFilePO.getLiaisonId()) && "0".equals(mgRnrFilePO.getLiaisonId()) && -1
!=RnrFileType.getIdImageFace().indexOf(mgRnrFilePO.getFileType())) {
localVerifyPersonDetailDTO.getVinOwnerMsg().setIdImageFace(mgRnrFilePO.getFileSystemId());
} else if (StringUtils.isNotBlank(mgRnrFilePO.getLiaisonId()) && "0".equals(mgRnrFilePO.getLiaisonId())
&&-1 !=RnrFileType.getIdImageEmblem().indexOf(mgRnrFilePO.getFileType()) ) {
localVerifyPersonDetailDTO.getVinOwnerMsg().setIdImageEmblem(mgRnrFilePO.getFileSystemId());
}
}*/
//车主展示文件
List<MgRnrFilePO> ownerFileList = mgRnrFilePOS.stream().filter(file ->
StringUtils.isNotBlank(file.getLiaisonId()) && "0".equals(file.getLiaisonId())
&& NPFileTypeSet.contains(file.getFileType())
).sorted(Comparator.comparing(MgRnrFilePO::getFileType)).collect(Collectors.toList());
for (int i = 0; i < ownerFileList.size(); i++) {
MgRnrFilePO mgRnrFilePO = ownerFileList.get(i);
if (i == 0) {
localVerifyPersonDetailDTO.getVinOwnerMsg().setIdImageFace(mgRnrFilePO.getFileSystemId());
} else {
localVerifyPersonDetailDTO.getVinOwnerMsg().setIdImageEmblem(mgRnrFilePO.getFileSystemId());
}
}
//代办人信息
if (1 == mgRnrInfoPO.getIsTrust()) {
MgRnrLiaisonInfoPO mgRnrLiaisonInfoPO = mgRnrLiaisonInfoService.getPoByRnrid(mgRnrInfoPO.getUuid());
localVerifyPersonDetailDTO.setVinLiaisonMsg(new LocalVerifyPersonDetailDTO.PersonMsg(
mgRnrLiaisonInfoPO.getLiaisonName(),
GenderEnum.findByCode(mgRnrLiaisonInfoPO.getLiaisonGender()).getName(),
CertTypeEnum.getEnumByCode(mgRnrLiaisonInfoPO.getLiaisonCertType()).getName(),
"", "", mgRnrLiaisonInfoPO.getLiaisonCertNumber(),
mgRnrLiaisonInfoPO.getLiaisonExpiredDate(),
mgRnrLiaisonInfoPO.getLiaisonCertAddress(), mgRnrLiaisonInfoPO.getLiaisonPhone(),
mgRnrLiaisonInfoPO.getLiaisonContactAddress()
));
//代办人展示文件
List<MgRnrFilePO> liaisonFileList = mgRnrFilePOS.stream().filter(file ->
!"0".equals(file.getLiaisonId()) && NPFileTypeSet.contains(file.getFileType())
).sorted(Comparator.comparing(MgRnrFilePO::getFileType)).collect(Collectors.toList());
for (int i = 0; i < liaisonFileList.size(); i++) {
MgRnrFilePO liaisonFile = liaisonFileList.get(i);
if (i == 0) {
localVerifyPersonDetailDTO.getVinLiaisonMsg().setIdImageFace(liaisonFile.getFileSystemId());
} else {
localVerifyPersonDetailDTO.getVinLiaisonMsg().setIdImageEmblem(liaisonFile.getFileSystemId());
}
}
/*for (MgRnrFilePO mgRnrFilePO : mgRnrFilePOS) {
//不是0,为代办人的证件信息
if (!"0".equals(mgRnrFilePO.getLiaisonId())) {
if (RnrFileType.IDENTITY_CARD_BACK.getCode().intValue() == mgRnrFilePO.getFileType()) {
localVerifyPersonDetailDTO.getVinLiaisonMsg().setIdImageFace(mgRnrFilePO.getFileSystemId());
} else if (RnrFileType.IDENTITY_CARD_FRONT.getCode().intValue() == mgRnrFilePO.getFileType()) {
localVerifyPersonDetailDTO.getVinLiaisonMsg().setIdImageEmblem(mgRnrFilePO.getFileSystemId());
}
}
}*/
}
//文件信息、认证信息
localVerifyPersonDetailDTO.setVerifyFileMsg(new LocalVerifyPersonDetailDTO.VerifyFileMsg());
for (MgRnrFilePO mgRnrFilePO : mgRnrFilePOS) {
if (RnrFileType.LETTER_ATTORNEY.getCode().intValue() == mgRnrFilePO.getFileType()) {
localVerifyPersonDetailDTO.getVerifyFileMsg().getAttorneyImage().add(mgRnrFilePO.getFileSystemId());
} else if (RnrFileType.CAR_PURCHASE_INVOICE.getCode().intValue() == mgRnrFilePO.getFileType()) {
localVerifyPersonDetailDTO.getVerifyFileMsg().getBuyBillImage().add(mgRnrFilePO.getFileSystemId());
} else if (RnrFileType.CAR_PURCHASE_CONTRACT.getCode().intValue() == mgRnrFilePO.getFileType()) {
localVerifyPersonDetailDTO.getVerifyFileMsg().getBuyContractImage().add(mgRnrFilePO.getFileSystemId());
} else if (RnrFileType.CAR_TRANSFER_CERTIFICATE.getCode().intValue() == mgRnrFilePO.getFileType()) {
localVerifyPersonDetailDTO.getVerifyFileMsg().getTransferOwnershipProveImage()
.add(mgRnrFilePO.getFileSystemId());
} else if (RnrFileType.VEHUCLE_BIND.getCode().intValue() == mgRnrFilePO.getFileType()
|| RnrFileType.DUTY_FILE.getCode().intValue() == mgRnrFilePO.getFileType()) {
localVerifyPersonDetailDTO.getVerifyFileMsg().getNetworkAccessContractImage()
.add(mgRnrFilePO.getFileSystemId());
} else if (RnrFileType.LIVENESS_SCREEN_FIRST.getCode().intValue() == mgRnrFilePO.getFileType() ||
RnrFileType.LIVENESS_SCREEN_TWO.getCode().intValue() == mgRnrFilePO.getFileType()) {
localVerifyPersonDetailDTO.getVerifyLivingMsg().getFaceImage().add(mgRnrFilePO.getFileSystemId());
} else if (RnrFileType.LIVENESS_VIDEO.getCode().intValue() == mgRnrFilePO.getFileType()) {
localVerifyPersonDetailDTO.getVerifyLivingMsg().setLivingVideo(mgRnrFilePO.getFileSystemId());
} else if ("0".equals(mgRnrFilePO.getLiaisonId())
&& RnrFileType.IDENTITY_CARD_BACK.getCode().intValue() == mgRnrFilePO.getFileType()) {
localVerifyPersonDetailDTO.getVinOwnerMsg().setIdImageFace(mgRnrFilePO.getFileSystemId());
} else if ("0".equals(mgRnrFilePO.getLiaisonId())
&& RnrFileType.IDENTITY_CARD_FRONT.getCode().intValue() == mgRnrFilePO.getFileType()) {
localVerifyPersonDetailDTO.getVinOwnerMsg().setIdImageEmblem(mgRnrFilePO.getFileSystemId());
}
}
//审核信息
LinkedHashMap<String, String> verifySuggestion = new LinkedHashMap<>();
verifySuggestion.put(PassCodeEnum.INFO_INCOMPLETE.getCode().toString(),
PassCodeEnum.INFO_INCOMPLETE.getComment());
verifySuggestion.put(PassCodeEnum.INFO_ATYPISM.getCode().toString(), PassCodeEnum.INFO_ATYPISM.getComment());
verifySuggestion.put(PassCodeEnum.INFO_NOT_FOUND.getCode().toString(),
PassCodeEnum.INFO_NOT_FOUND.getComment());
verifySuggestion.put(PassCodeEnum.PIC_FORMAT_ERROR.getCode().toString(),
PassCodeEnum.PIC_FORMAT_ERROR.getComment());
verifySuggestion.put(PassCodeEnum.PIC_BLURRING.getCode().toString(), PassCodeEnum.PIC_BLURRING.getComment());
//认证结果信息
MgRnrAuthenticationResultDTO bean = new MgRnrAuthenticationResultDTO();
bean.setRnrId(rnrOrderPO.getRnrId());
List<MgRnrAuthenticationResultDTO> authenticationResultDTOS =
iMgRnrAuthenticationResultService.queryByList(bean);
if (CollectionUtils.isNotEmpty(authenticationResultDTOS)) {
List<EnterpriseVerifyDetailDTO.AuthResult> authResultInfo =
new ArrayList<>(authenticationResultDTOS.size());
List<EnterpriseVerifyDetailDTO.AuthResult> liaisonResultInfo =
new ArrayList<>(authenticationResultDTOS.size());
authenticationResultDTOS.forEach(authResultDTO -> {
EnterpriseVerifyDetailDTO.AuthResult authResult = new EnterpriseVerifyDetailDTO.AuthResult();
authResult.setTpAction(authResultDTO.getAuthWayType());
authResult.setTpActionName(AuthWayTypeEnum.getEnumByCode(authResultDTO.getAuthWayType()).getName());
authResult.setMessage(authResultDTO.getAuthResultMsg());
//实名认证结果,1-成功,其他-失败
authResult.setSuccess("1".equals(authResultDTO.getAuthResult()) ? true : false);
if (SubjectTypeEnum.ONESELF.getCode().equals(authResultDTO.getSubjectType())) {
authResultInfo.add(authResult);
} else {
liaisonResultInfo.add(authResult);
}
});
localVerifyPersonDetailDTO.setAuthResultInfo(authResultInfo);
localVerifyPersonDetailDTO.setLiaisonAuthResultInfo(liaisonResultInfo);
}
//审核信息
UserDTO userDTO = new UserDTO();
userDTO.setUuid(rq.getUserId());
userDTO.setApplicationId(rq.getApplicationId());
userDTO.setTenantNo(rq.getTenantNo());
Response<UserDTO> userDTOResponse = userClient.getByUuid(userDTO);
UserDTO user = userDTOResponse.getData();
log.info("审核人的信息返参:{}", JSON.toJSONString(user));
if (userDTOResponse == null || user == null) {
return Response.createError("审核人不能为空");
}
localVerifyPersonDetailDTO.setVerifyMsg(new LocalVerifyPersonDetailDTO.VerifyMsg(user.getUserName(),
DateUtil.toString(new Date(), DateUtil.yyyy_MM_dd), verifySuggestion, rnrOrderPO.getOrderStatus()));
return Response.createSuccess(localVerifyPersonDetailDTO);
}
@Transactional(rollbackFor = Throwable.class)
public Response submit(LocalVerifySubmitRq rq) {
RnrOrderPO rnrOrderPO = rnrOrderService.getPoByUuid(rq.getRnrOrderInfoId());
RnrOrderType typeByCode = RnrOrderType.getTypeByCode(rnrOrderPO.getOrderType());
WorkOrderTypeEnum workOrderTypeEnum
= WorkOrderTypeEnum.getWorkOrderTypeEnumByRnrOrderType(typeByCode);
WorkOrderReviewCallBackRequestDTO dto = new WorkOrderReviewCallBackRequestDTO();
dto.setBusinessObjectId(rnrOrderPO.getUuid());
if (RnrOrderStatusEnum.PASS.getCode().toString().equals(rq.getAuditResult())) {
dto.setAuditResult("1");
} else if (RnrOrderStatusEnum.NOT_PASS.getCode().toString().equals(rq.getAuditResult())) {
dto.setAuditResult("2");
}
if ("rnrWorkOrderCallBackHandler".equals(workOrderTypeEnum.getWorkOrderCallBackServiceName())) {
//人工实名认证工单、二手车实名认证工单、企业新车实名认证
rnrWorkOrderCallBackHandler.reviewCallBack(dto);
} else if ("manufacturerRnrCallBackHandler".equals(workOrderTypeEnum.getWorkOrderCallBackServiceName())) {
//车企新车实名认证
manufacturerRnrCallBackHandler.reviewCallBack(dto);
} else if ("unbindWorkOrderCallBackHandler".equals(workOrderTypeEnum.getWorkOrderCallBackServiceName())) {
//二手车主解绑
unbindWorkOrderCallBackHandler.reviewCallBack(dto);
} else if ("enterpriseChangeCallBackHandler".equals(workOrderTypeEnum.getWorkOrderCallBackServiceName())) {
//企业责任人变更
enterpriseChangeCallBackHandler.reviewCallBack(dto);
}
//更新审核用户、审核意见、备注
//审核时间
rnrOrderPO.setAuditTime(new Date());
//设置操作人
rnrOrderPO.setReviewUserId(rq.getUserId());
//审核状态
rnrOrderPO.setOrderStatus(Integer.parseInt(rq.getAuditResult()));
//审核意见, 可以多选
rnrOrderPO.setVerifyComments(StringUtils.join(rq.getAuditNote(), ","));
//其他意见
rnrOrderPO.setComment(rq.getOtherComments());
rnrOrderDao.updateById(rnrOrderPO);
//发送通知
List<MgRnrCardInfoDTO> mgRnrCardInfoDTOS = mgRnrCardInfoService.getByRnrid(rnrOrderPO.getRnrId());
MgRnrInfoPO mgRnrInfoPO = mgRnrInfoService.getPoByUuid(rnrOrderPO.getRnrId());
notifyCloudService.notifyResult(mgRnrCardInfoDTOS, rnrOrderPO.getRnrBizzType().toString(),
rnrOrderPO.getId().toString(), mgRnrInfoPO.getOrgId(), rnrOrderPO.getOrderStatus().toString());
return Response.createSuccess("请求成功");
}
public Response retry(LocalVerifySubmitRq rq) {
RnrRelationDTO rsBean = new RnrRelationDTO();
rsBean.setRequestId(CuscStringUtils.generateUuid());
RnrOrderPO rnrOrderPO =
rnrOrderService.getOne(new QueryWrapper<RnrOrderPO>().eq("uuid", rq.getRnrOrderInfoId()));
if (null == rnrOrderPO) {
return Response.createError("工单不存在");
} else {
RnrOrderDTO rnrOrderDTO = RnrOrderConverter.INSTANCE.poToDto(rnrOrderPO);
rsBean.setOrder(rnrOrderDTO);
rsBean.setTenantNo(rnrOrderDTO.getTenantNo());
if (rnrOrderDTO.getOrderType().equals("2")) {
rsBean.setIsSecondHandCar(1);
} else {
rsBean.setIsSecondHandCar(0);
}
}
//是否是委托实名 0 否 1 是
boolean isTrust = false;
MgRnrInfoPO mgRnrInfoPO = mgRnrInfoService.getPoByUuid(rnrOrderPO.getRnrId());
if (null == mgRnrInfoPO) {
return Response.createError("工单实名信息不存在");
} else {
MgRnrInfoDTO info = MgRnrInfoConverter.INSTANCE.poToDto(mgRnrInfoPO);
rsBean.setInfo(info);
rsBean.setIsTrust(info.getIsTrust());
if (info.getIsTrust().equals("1")) {
isTrust = true;
}
}
List<MgRnrCompanyInfoPO> mgRnrCompanyInfoPOS = mgRnrCompanyInfoService.list(
new QueryWrapper<MgRnrCompanyInfoPO>().eq("rnr_id", rnrOrderPO.getRnrId()));
if (null != mgRnrCompanyInfoPOS && mgRnrCompanyInfoPOS.size() != 0) {
MgRnrCompanyInfoDTO companyInfo = MgRnrCompanyInfoConverter.INSTANCE.poToDto(mgRnrCompanyInfoPOS.get(0));
}
//代办人信息
if (isTrust) {
List<MgRnrLiaisonInfoDTO> rnrLiaisonList = new ArrayList<>();
MgRnrLiaisonInfoPO mgRnrLiaisonInfoPO = mgRnrLiaisonInfoService.getPoByRnrid(mgRnrInfoPO.getUuid());
rnrLiaisonList.add(MgRnrLiaisonInfoConverter.INSTANCE.poToDto(mgRnrLiaisonInfoPO));
rsBean.setRnrLiaisonList(rnrLiaisonList);
}
//实名文件信息
List<MgRnrFilePO> mgRnrFilePOS =
mgRnrFileService.getPoByRnridOrderByOrderno(mgRnrInfoPO.getUuid(), mgRnrInfoPO.getTenantNo());
if (mgRnrFilePOS.size() > 0) {
List<MgRnrFileDTO> rnrFileList = MgRnrImageConverter.INSTANCE.poListToDtoList(mgRnrFilePOS);
rsBean.setRnrFileList(rnrFileList);
}
return Response.createSuccess(rsBean);
}
private static final String key = "89c0Cusc268f5A51";
public Response validationRnrOrder(LocalVerifyListRqDTO rq) {
SymmetricCrypto sm4 = SmUtil.sm4(key.getBytes());
String vinEncryptStr = sm4.encryptBase64(rq.getVin());
String iccidEncryptStr = sm4.encryptBase64(rq.getIccid());
Integer returnInt = rnrOrderDao.validationRnrOrder(vinEncryptStr, iccidEncryptStr);
if (returnInt > 0) {
return Response.createSuccess();
} else {
return Response.createError();
}
}
}
package com.cusc.nirvana.user.rnr.mg.service.impl;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.cache.CacheFactory;
import com.cache.exception.CacheException;
import com.cusc.nirvana.common.loader.CollectionUtils;
import com.cusc.nirvana.common.result.PageResult;
import com.cusc.nirvana.rds.mybatis.PageHelper;
import com.cusc.nirvana.user.rnr.common.constants.RedisConstant;
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.RnrStatus;
import com.cusc.nirvana.user.rnr.mg.dao.MgCheckProgressDao;
import com.cusc.nirvana.user.rnr.mg.dto.MgCheckProgressDTO;
import com.cusc.nirvana.user.rnr.mg.dto.MgCheckStatisticsDTO;
import com.cusc.nirvana.user.rnr.mg.dto.MgCheckStatisticsQueryDTO;
import com.cusc.nirvana.user.rnr.mg.service.IMgCheckProgressService;
import com.cusc.nirvana.user.util.DateUtils;
import com.cusc.nirvana.user.util.crypt.CryptKeyUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
* @author hxin
* @date 2022/5/18 19:15
* @modify 2022-06-01
*/
@Service
@Slf4j
public class MgCheckProgressServiceImpl implements IMgCheckProgressService {
@Resource
private MgCheckProgressDao mgCheckProgressDao;
@Resource
private CacheFactory cacheFactory;
private static final Integer MAX_NUMBER = 500;
@Override
public PageResult<MgCheckProgressDTO> queryByPage(MgCheckProgressDTO bean) {
bean.setFullName(CryptKeyUtil.encryptToBase64(bean.getFullName()));
bean.setPhone(CryptKeyUtil.encryptToBase64(bean.getPhone()));
bean.setIotId(CryptKeyUtil.encryptToBase64(bean.getIotId()));
bean.setIccid(CryptKeyUtil.encryptToBase64(bean.getIccid()));
bean.setCompanyName(CryptKeyUtil.encryptToBase64(bean.getCompanyName()));
Page<MgCheckProgressDTO> page = new Page<>(bean.getCurrPage(), bean.getPageSize());
page.setRecords(mgCheckProgressDao.queryCheckProgressByPage(page, bean));
return PageHelper.convert(page, MgCheckProgressDTO.class);
}
/**
* @modify 加入租户和用户的所属车企的所有下属组织做筛选
* 组织idList比较多
* 考虑改成 for循环分批查询再累计
* redis key采用 租户编号+用户当前组织id+日期
* @param queryDTO
* @return
*/
@Override
public MgCheckStatisticsDTO queryCheckStatistics(MgCheckStatisticsQueryDTO queryDTO) {
String cachedValue = this.getCachedStatisticsValue(queryDTO);
if(StringUtils.isNotBlank(cachedValue)){
return JSON.parseObject(cachedValue,MgCheckStatisticsDTO.class);
}
List<List<String>> subList = this.subList(queryDTO.getOrgIdList()); //orgIdList切分 分批查询
//查询参数
MgCheckStatisticsQueryDTO queryPeopleDTO = this.initQueryParam(CommonYesOrNoEnum.NO.getCode(),queryDTO.getTenantNo());
MgCheckStatisticsQueryDTO queryCompanyDTO = this.initQueryParam(CommonYesOrNoEnum.YES.getCode(),queryDTO.getTenantNo());
//车企的所有的实名数目 状态 1 2 3
List<Integer> rnrStatusAllList = new ArrayList<>();
rnrStatusAllList.add(RnrStatus.RNR.getCode());
rnrStatusAllList.add(RnrStatus.RNR_FAIL.getCode());
rnrStatusAllList.add(RnrStatus.UNBOUND.getCode());
MgCheckStatisticsQueryDTO allParam = initVehicleQueryParam(rnrStatusAllList);
allParam.setTenantNo(queryDTO.getTenantNo());
//车企的成功的实名数目 状态1 3
List<Integer> rnrStatusSuccessList = new ArrayList<>();
rnrStatusSuccessList.add(RnrStatus.RNR.getCode());
rnrStatusSuccessList.add(RnrStatus.UNBOUND.getCode());
MgCheckStatisticsQueryDTO successParam = initVehicleQueryParam(rnrStatusSuccessList);
successParam.setTenantNo(queryDTO.getTenantNo());
Integer peopleRnrNumTotal = 0;
Integer companyRnrNumTotal = 0;
Integer allNumTotal = 0;
Integer successNumTotal = 0;
for(List<String> orgIdList : subList){
queryPeopleDTO.setOrgIdList(orgIdList);
Integer peopleRnrNum = mgCheckProgressDao.queryStatisticsCountByCondition(queryPeopleDTO);
peopleRnrNumTotal += peopleRnrNum;
queryCompanyDTO.setOrgIdList(orgIdList);
Integer companyRnrNum = mgCheckProgressDao.queryStatisticsCountByCondition(queryCompanyDTO);
companyRnrNumTotal += companyRnrNum;
allParam.setOrgIdList(orgIdList);
Integer allNum = mgCheckProgressDao.queryStatisticsCountByCondition(allParam);
allNumTotal += allNum;
successParam.setOrgIdList(orgIdList);
Integer successNum = mgCheckProgressDao.queryStatisticsCountByCondition(successParam);
successNumTotal += successNum;
}
String rate;
if(allNumTotal == 0 || successNumTotal == 0){
rate = "暂无车企数据";
}else {
rate = calculatePercent(successNumTotal,allNumTotal);
}
//车企处理平均时长
String vehicleHandleTimeAvg = this.getVehicleHandleTimeAvg(queryDTO, subList);
MgCheckStatisticsDTO result = new MgCheckStatisticsDTO();
result.setPeopleRnrNum(peopleRnrNumTotal);
result.setCompanyRnrNum(companyRnrNumTotal);
result.setVehicleCompanyRnrSuccessRate(rate);
result.setVehicleHandleTimeAvg(vehicleHandleTimeAvg);
this.setCachedStatisticsValue(result,queryDTO);
return result;
}
public String getCachedStatisticsValue(MgCheckStatisticsQueryDTO queryDTO){
String key = RedisConstant.RNR_CARD_STATISTICS_KEY+queryDTO.getTenantNo()+":"+queryDTO.getUserOrgId()+initDate().substring(0,10);
String valueStr = null;
try {
valueStr = cacheFactory.getStringService().getValue(key,String.class);
} catch (CacheException e) {
log.error("MgCheckProgressServiceImpl.getCachedCheckStatistics 获取缓存失败,key = {}", key, e);
}
return valueStr;
}
public void setCachedStatisticsValue(MgCheckStatisticsDTO result,MgCheckStatisticsQueryDTO queryDTO){
String key = RedisConstant.RNR_CARD_STATISTICS_KEY+queryDTO.getTenantNo()+":"+queryDTO.getUserOrgId()+initDate().substring(0,10);
try {
cacheFactory.getExpireStringService().setExpireValue(key,JSON.toJSONString(result),60*60*24);
} catch (CacheException e) {
log.error("MgCheckProgressServiceImpl.setCachedValue 加入缓存失败,key = {}", key, e);
}
}
/**
* 车企处理平均时长
* @return
*/
private String getVehicleHandleTimeAvg(MgCheckStatisticsQueryDTO queryDTO,List<List<String>> subList){
MgCheckStatisticsQueryDTO param = new MgCheckStatisticsQueryDTO();
param.setDateTime(initDate());
param.setTenantNo(queryDTO.getTenantNo());
List<Integer> rnrBizzTypeList = new ArrayList<>();
rnrBizzTypeList.add(RnrBizzTypeEnum.Bind.getCode());
rnrBizzTypeList.add(RnrBizzTypeEnum.Unbound.getCode());
rnrBizzTypeList.add(RnrBizzTypeEnum.ChangeBinding.getCode());
rnrBizzTypeList.add(RnrBizzTypeEnum.INFO_CHANGE.getCode());
rnrBizzTypeList.add(RnrBizzTypeEnum.REPEAT_BIND.getCode());
param.setRnrBizzTypeList(rnrBizzTypeList);
//param.setIsCompany(CommonYesOrNoEnum.YES.getCode());
//param.setIsVehicleCompany(CommonYesOrNoEnum.YES.getCode());
//分批查询
List<Integer> all = new ArrayList<>();
for(List<String> orgIdList : subList){
param.setOrgIdList(orgIdList);
List<Integer> list = mgCheckProgressDao.queryVehicleCompanyHandleTime(param);
all.addAll(list);
}
List<Integer> collect = all.stream().filter(Objects::nonNull).collect(Collectors.toList());
log.info("collect:"+collect);
if(CollectionUtils.isEmpty(collect)){
return "暂无平均处理时长";
}
//计算平均值
Double average = collect.stream().mapToDouble(Number::doubleValue).average().getAsDouble();
String s = secondToTime(average.longValue());
log.info("average"+s);
return s;
}
/**
* 秒转为时分秒
* @param
* @return
*/
private static String secondToTime(long second) {
long days = second /86400;//转换天数
second = second %86400;//剩余秒数
long hours = second /3600;//转换小时数
second = second %3600;//剩余秒数
long minutes = second /60;//转换分钟
second = second %60;//剩余秒数
if (0 < days){
return days +":"+hours+":"+minutes+":"+second;
}else {
return hours+":"+minutes+":"+second;
}
}
/**
* 计算切分次数
*/
private Integer countStep(Integer size) {
return (size + MAX_NUMBER - 1) / MAX_NUMBER;
}
/**
* 切分list
* @param list
* @return
*/
private List<List<String>> subList(List<String> list){
int limit = countStep(list.size());
List<List<String>> mglist = new ArrayList<>();
if(CollectionUtils.isEmpty(list)){
return mglist;
}
Stream.iterate(0, n -> n + 1).limit(limit).forEach(i -> {
mglist.add(list.stream().skip(i * MAX_NUMBER).limit(MAX_NUMBER).collect(Collectors.toList()));
});
return mglist;
}
/**
* 自然人或企业
* 实名查询参数
* @modify rnr_status改为1和3 失败不统计
* @return
*/
private MgCheckStatisticsQueryDTO initQueryParam(Integer isCompany,String tenantNo){
MgCheckStatisticsQueryDTO queryDTO = new MgCheckStatisticsQueryDTO();
queryDTO.setDateTime(initDate());
queryDTO.setTenantNo(tenantNo);
List<Integer> rnrBizzTypeList = new ArrayList<>();
rnrBizzTypeList.add(RnrBizzTypeEnum.Bind.getCode());
queryDTO.setRnrBizzTypeList(rnrBizzTypeList);
List<Integer> rnrStatusList = new ArrayList<>();
rnrStatusList.add(RnrStatus.RNR.getCode());
//rnrStatusList.add(RnrStatus.RNR_FAIL.getCode());
rnrStatusList.add(RnrStatus.UNBOUND.getCode());
queryDTO.setRnrStatusList(rnrStatusList);
queryDTO.setIsCompany(isCompany);
return queryDTO;
}
/**
* 车企实名成功率查询参数
* @return
*/
private MgCheckStatisticsQueryDTO initVehicleQueryParam(List<Integer> rnrStatusList){
MgCheckStatisticsQueryDTO queryDTO = new MgCheckStatisticsQueryDTO();
queryDTO.setDateTime(initDate());
List<Integer> rnrBizzTypeList = new ArrayList<>();
rnrBizzTypeList.add(RnrBizzTypeEnum.Bind.getCode());
queryDTO.setRnrBizzTypeList(rnrBizzTypeList);
queryDTO.setRnrStatusList(rnrStatusList);
//queryDTO.setIsCompany(CommonYesOrNoEnum.YES.getCode());
//queryDTO.setIsVehicleCompany(CommonYesOrNoEnum.YES.getCode());
return queryDTO;
}
/**
* 获取凌晨时间
* @return
*/
public static String initDate(){
Calendar calendar = Calendar.getInstance();
calendar.setTime(new Date());
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
return DateUtils.formatDatetime(calendar.getTime());
}
/**
* a / b 计算百分比
*
*/
public static String calculatePercent(Integer a , Integer b){
//保留两位 四舍五入
String percent = new BigDecimal((double)a*100/b).setScale(0,BigDecimal.ROUND_HALF_UP)+"%";
return percent;
}
}
package com.cusc.nirvana.user.rnr.mg.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cusc.nirvana.user.rnr.mg.dao.MgOrderApproverDao;
import com.cusc.nirvana.user.rnr.mg.dao.entity.MgOrderApproverPO;
import com.cusc.nirvana.user.rnr.mg.service.IMgOrderApproverService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
/**
* @author stayAnd
* @date 2022/3/31
*/
@Service
@Slf4j
public class MgOrderApproverServiceImpl extends ServiceImpl<MgOrderApproverDao,MgOrderApproverPO> implements IMgOrderApproverService {
}
package com.cusc.nirvana.user.rnr.mg.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cusc.nirvana.user.rnr.mg.converter.MgRnrAuthenticationResultConverter;
import com.cusc.nirvana.user.rnr.mg.dao.MgRnrAuthenticationResultDao;
import com.cusc.nirvana.user.rnr.mg.dao.entity.MgRnrAuthenticationResultPO;
import com.cusc.nirvana.user.rnr.mg.dto.MgRnrAuthenticationResultDTO;
import com.cusc.nirvana.user.rnr.mg.service.IMgRnrAuthenticationResultService;
import com.cusc.nirvana.user.util.CuscStringUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
/**
* 实名认证结果(MgRnrAuthenticationResult)表服务实现类
*
* @author yuy336
* @since 2022-05-19 17:36:05
*/
@Service
public class MgRnrAuthenticationResultServiceImpl extends ServiceImpl<MgRnrAuthenticationResultDao, MgRnrAuthenticationResultPO> implements IMgRnrAuthenticationResultService {
/**
* 通过UUID查询单条数据
*
* @param bean
* @return 实例对象
*/
@Override
public MgRnrAuthenticationResultDTO getByUuid(MgRnrAuthenticationResultDTO bean) {
MgRnrAuthenticationResultPO record = this.getPoByUuid(bean.getUuid());;
return MgRnrAuthenticationResultConverter.INSTANCE.poToDto(record);
}
/**
* 通过查询条件查询集合数据
*
* @param bean
* @return 集合对象
*/
@Override
public List<MgRnrAuthenticationResultDTO> queryByList(MgRnrAuthenticationResultDTO bean) {
QueryWrapper queryWrapper = new QueryWrapper();
if (StringUtils.isNotBlank(bean.getRnrId())) {
queryWrapper.eq("rnr_id", bean.getRnrId());
}
if (StringUtils.isNotBlank(bean.getTenantNo())) {
queryWrapper.eq("tenant_no", bean.getTenantNo());
}
queryWrapper.eq(StringUtils.isNotBlank(bean.getOrderId()),"order_id",bean.getOrderId());
queryWrapper.orderByDesc("create_time");
List<MgRnrAuthenticationResultPO> record = this.list(queryWrapper);
return MgRnrAuthenticationResultConverter.INSTANCE.poListToDtoList(record);
}
/**
* 新增数据
*
* @param bean 实例对象
* @return 实例对象
*/
@Override
@Transactional
public MgRnrAuthenticationResultDTO insert(MgRnrAuthenticationResultDTO bean) {
MgRnrAuthenticationResultPO mgRnrAuthenticationResultPO = MgRnrAuthenticationResultConverter.INSTANCE.dtoToPo(bean);
mgRnrAuthenticationResultPO.setUuid(CuscStringUtils.generateUuid());
this.save(mgRnrAuthenticationResultPO);
bean.setUuid(mgRnrAuthenticationResultPO.getUuid());
return bean;
}
/**
* 修改数据
*
* @param bean 实例对象
* @return 实例对象
*/
@Override
@Transactional
public MgRnrAuthenticationResultDTO update(MgRnrAuthenticationResultDTO bean) {
MgRnrAuthenticationResultPO mgRnrAuthenticationResultPO = this.getPoByUuid(bean.getUuid());
if(mgRnrAuthenticationResultPO == null){
return null;
}
MgRnrAuthenticationResultPO tmpBean = MgRnrAuthenticationResultConverter.INSTANCE.dtoToPo(bean);
tmpBean.setId(mgRnrAuthenticationResultPO.getId());
this.updateById(tmpBean);
return bean;
}
/**
* 通过UUID查询单条数据
*
* @param uuid
* @return 实例对象
*/
private MgRnrAuthenticationResultPO getPoByUuid(String uuid) {
QueryWrapper queryWrapper = new QueryWrapper();
queryWrapper.eq("uuid", uuid);
return this.getOne(queryWrapper);
}
}
package com.cusc.nirvana.user.rnr.mg.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cusc.nirvana.common.result.PageResult;
import com.cusc.nirvana.rds.mybatis.PageHelper;
import com.cusc.nirvana.user.rnr.common.constants.RnrConstants;
import com.cusc.nirvana.user.rnr.mg.constants.CommonDeleteEnum;
import com.cusc.nirvana.user.rnr.mg.constants.CryptKeyHelper;
import com.cusc.nirvana.user.rnr.mg.constants.MbCodeEnum;
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.converter.MgRnrCardInfoConverter;
import com.cusc.nirvana.user.rnr.mg.dao.MgRnrCardInfoDao;
import com.cusc.nirvana.user.rnr.mg.dao.entity.MgRnrCardInfoPO;
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.service.IMgRnrCardInfoService;
import com.cusc.nirvana.user.rnr.mg.service.IMgRnrCardNoticeService;
import com.cusc.nirvana.user.util.CuscStringUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/**
* 实名卡信息(MgRnrCardInfo)表服务实现类
*
* @author yuy336
* @since 2022-03-04 11:06:45
*/
@Service
@Slf4j
public class MgRnrCardInfoServiceImpl extends ServiceImpl<MgRnrCardInfoDao, MgRnrCardInfoPO>
implements IMgRnrCardInfoService {
@Resource
@Lazy
private IMgRnrCardNoticeService cardNoticeService;
/**
* 通过UUID查询单条数据
*
* @param bean
* @return 实例对象
*/
@Override
public MgRnrCardInfoDTO getByUuid(MgRnrCardInfoDTO bean) {
MgRnrCardInfoPO record = this.getPoByUuid(bean.getUuid());
return MgRnrCardInfoConverter.INSTANCE.poToDto(record);
}
/**
* 通过查询条件查询集合数据
*
* @param bean
* @return 集合对象
*/
@Override
public List<MgRnrCardInfoDTO> queryByList(MgRnrCardInfoDTO bean) {
QueryWrapper queryWrapper = new QueryWrapper();
queryWrapper.eq("is_delete", CommonDeleteEnum.NORMAL.getCode());
queryWrapper.eq(StringUtils.isNotBlank(bean.getRnrId()), "rnr_id", bean.getRnrId());
queryWrapper.eq(StringUtils.isNotBlank(bean.getTenantNo()), "tenant_no", bean.getTenantNo());
queryWrapper.eq(StringUtils.isNotBlank(bean.getIccid()), "iccid", CryptKeyHelper.encrypt(bean.getIccid()));
queryWrapper.eq(null != bean.getRnrStatus(), "rnr_status", bean.getRnrStatus());
queryWrapper.eq(null != bean.getRnrBizzType(), "rnr_bizz_type", bean.getRnrBizzType());
queryWrapper.eq(null != bean.getOrderId(), "order_id", bean.getOrderId());
queryWrapper.eq(StringUtils.isNotEmpty(bean.getIotId()), "iot_id", CryptKeyHelper.encrypt(bean.getIotId()));
queryWrapper.in(!CollectionUtils.isEmpty(bean.getRnrIdList()), "rnr_id", bean.getRnrIdList());
queryWrapper.in(!CollectionUtils.isEmpty(bean.getOrderIdList()), "order_id", bean.getOrderIdList());
queryWrapper.in(!CollectionUtils.isEmpty(bean.getBizTypeList()), "rnr_bizz_type", bean.getBizTypeList());
queryWrapper.in(!CollectionUtils.isEmpty(bean.getIccidList()), "iccid",
CryptKeyHelper.encrypt(bean.getIccidList()));
queryWrapper.orderByDesc("create_time");
List<MgRnrCardInfoPO> record = this.list(queryWrapper);
return MgRnrCardInfoConverter.INSTANCE.poListToDtoList(record);
}
/**
* 分页查询
*
* @param bean 筛选条件
* @return 查询结果
*/
@Override
public PageResult<MgRnrCardInfoDTO> queryByPage(MgRnrCardInfoDTO bean) {
QueryWrapper queryWrapper = new QueryWrapper();
queryWrapper.eq(null != bean.getOrderId(), "order_id", bean.getOrderId());
queryWrapper.orderByDesc("create_time");
queryWrapper.eq("is_delete", CommonDeleteEnum.NORMAL.getCode());
Page<MgRnrCardInfoPO> page =
this.page(new Page<>(bean.getCurrPage(), bean.getPageSize()), queryWrapper);
return PageHelper.convert(page, MgRnrCardInfoDTO.class);
}
/**
* 新增数据
*
* @param bean 实例对象
* @return 实例对象
*/
@Override
@Transactional
public MgRnrCardInfoDTO insert(MgRnrCardInfoDTO bean) {
MgRnrCardInfoPO mgRnrCardInfoPO = MgRnrCardInfoConverter.INSTANCE.dtoToPo(bean);
if (CuscStringUtils.isEmpty(bean.getUuid())) {
mgRnrCardInfoPO.setUuid(CuscStringUtils.generateUuid());
bean.setUuid(mgRnrCardInfoPO.getUuid());
}
this.save(mgRnrCardInfoPO);
return bean;
}
/**
* 修改数据
*
* @param bean 实例对象
* @return 实例对象
*/
@Override
@Transactional
public MgRnrCardInfoDTO update(MgRnrCardInfoDTO bean) {
MgRnrCardInfoPO mgRnrCardInfoPO = this.getPoByUuid(bean.getUuid());
if (mgRnrCardInfoPO == null) {
return null;
}
MgRnrCardInfoPO tmpBean = MgRnrCardInfoConverter.INSTANCE.dtoToPo(bean);
tmpBean.setId(mgRnrCardInfoPO.getId());
this.updateById(tmpBean);
return bean;
}
/**
* 通过主键删除数据
*
* @param bean 实例对象
* @return 是否成功
*/
@Override
@Transactional
public boolean deleteById(MgRnrCardInfoDTO bean) {
MgRnrCardInfoPO mgRnrCardInfoPO = this.getPoByUuid(bean.getUuid());
if (mgRnrCardInfoPO == null) {
return false;
}
MgRnrCardInfoPO tmpBean = new MgRnrCardInfoPO();
tmpBean.setId(mgRnrCardInfoPO.getId());
tmpBean.setIsDelete(CommonDeleteEnum.DELETED.getCode());
return this.updateById(tmpBean);
}
@Override
public Integer addRnrCardBatch(List<MgRnrCardInfoPO> beanList) {
beanList.forEach(bean -> {
if (null == bean.getOldCardId()) {
bean.setOldCardId("");
}
//数据加密
bean.setIccid(CryptKeyHelper.encrypt(bean.getIccid()));
bean.setIotId(CryptKeyHelper.encrypt(bean.getIotId()));
//bean.setOldCardId(CryptKeyHelper.encrypt(bean.getOldCardId()));
});
return baseMapper.addRnrCardBatch(beanList);
}
@Override
public List<MgRnrCardInfoDTO> getByIccid(MgRnrCardInfoDTO bean) {
//return MgRnrCardInfoConverter.INSTANCE.poListToDtoList(queryRnrCardByEs(bean));
//直接查库
return null;
}
@Override
public List<MgRnrCardInfoDTO> getListByIccid(MgRnrCardInfoDTO bean) {
List<MgRnrCardInfoPO> oneByIccid = this.getListByIccid(bean.getIccid());
return MgRnrCardInfoConverter.INSTANCE.poListToDtoList(oneByIccid);
}
@Override
public MgRnrCardInfoDTO getOneByIccid(MgRnrCardInfoDTO bean) {
MgRnrCardInfoPO oneCardByIccid = getOneCardByIccid(bean.getIccid(), bean.getIotId(), bean.getTenantNo());
return MgRnrCardInfoConverter.INSTANCE.poToDto(oneCardByIccid);
}
/**
* 根据业务id和iccid查找记录
*
* @param orderId
* @param iccid
* @return
*/
@Override
public MgRnrCardInfoDTO getByOrderIdAndIccId(String orderId, String iccid) {
QueryWrapper<MgRnrCardInfoPO> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("order_id", orderId);
queryWrapper.eq("iccid", CryptKeyHelper.encrypt(iccid));
List<MgRnrCardInfoPO> list = this.list(queryWrapper);
return list.isEmpty() ? null : MgRnrCardInfoConverter.INSTANCE.poToDto(list.get(0));
}
/**
* 更新mq发送状态
*
* @param mgRnrCardInfoDTO
* @return
*/
@Override
public Integer updateCardNoticeStatus(MgRnrCardInfoDTO mgRnrCardInfoDTO) {
return this.baseMapper.updateCardNoticeStatus(mgRnrCardInfoDTO);
}
@Override
public Integer updateCardStatusByOrderId(String orderId, int noticeStatus, int rnrStatus) {
return this.baseMapper.updateCardStatusByOrderId(orderId, noticeStatus, rnrStatus);
}
@Override
public boolean checkIccidExists(MgRnrCardInfoDTO bean) {
boolean ret = false;
List<MgRnrCardInfoDTO> cardList = getByIccid(bean);
if (CollectionUtils.isEmpty(cardList)) {
return ret;
}
for (MgRnrCardInfoDTO card : cardList) {
if (RnrConstants.RNR_STATUS_WAIT_CHECK == card.getRnrStatus()
|| RnrConstants.RNR_STATUS_CHECK_ACCESS == card.getRnrStatus()
|| RnrConstants.RNR_STATUS_WAIT_MANUAL_CHECK == card.getRnrStatus()) {
ret = true;
break;
}
}
return ret;
}
@Override
public boolean checkIccid(MgRnrCardInfoDTO bean) {
boolean ret = false;
List<MgRnrCardInfoDTO> cardList = getListByIccid(bean);
if (CollectionUtils.isEmpty(cardList)) {
return ret;
}
for (MgRnrCardInfoDTO card : cardList) {
if (RnrConstants.RNR_STATUS_NOT_BINDING == card.getRnrStatus()) {
ret = true;
break;
}
}
return ret;
}
@Override
public List<MgRnrCardInfoDTO> queryBindListByVin(String vin) {
QueryWrapper queryWrapper = new QueryWrapper();
queryWrapper.eq("is_delete", CommonDeleteEnum.NORMAL.getCode());
queryWrapper.eq("rnr_status", RnrStatus.RNR.getCode());
queryWrapper.eq("iot_id", CryptKeyHelper.encrypt(vin));
queryWrapper.orderByDesc("create_time");
List<MgRnrCardInfoPO> record = this.list(queryWrapper);
return MgRnrCardInfoConverter.INSTANCE.poListToDtoList(record);
}
@Override
public List<MgRnrCardInfoDTO> queryBindListByVinsAndIccids(List<String> vins, List<String> iccids) {
List<String> encryptVins = new ArrayList<>();
if (!CollectionUtils.isEmpty(vins)) {
vins.forEach(vin -> encryptVins.add(CryptKeyHelper.encrypt(vin)));
}
List<String> encryptIccids = new ArrayList<>();
if (!CollectionUtils.isEmpty(iccids)) {
iccids.forEach(iccid -> encryptIccids.add(CryptKeyHelper.encrypt(iccid)));
}
QueryWrapper queryWrapper = new QueryWrapper();
queryWrapper.eq("is_delete", CommonDeleteEnum.NORMAL.getCode());
queryWrapper.in("rnr_status", Arrays.asList(RnrStatus.RNR.getCode(), RnrStatus.INIT.getCode()));
queryWrapper.in("iot_id", encryptVins);
queryWrapper.in(!CollectionUtils.isEmpty(encryptIccids),"iccid", encryptIccids);
queryWrapper.orderByDesc("create_time");
List<MgRnrCardInfoPO> record = this.list(queryWrapper);
return MgRnrCardInfoConverter.INSTANCE.poListToDtoList(record);
}
@Override
public List<MgRnrCardInfoDTO> queryBindListByVinAndBizType(String vin, int bizTpye) {
QueryWrapper queryWrapper = new QueryWrapper();
queryWrapper.eq("is_delete", CommonDeleteEnum.NORMAL.getCode());
queryWrapper.eq("rnr_status", RnrStatus.RNR.getCode());
queryWrapper.eq("iot_id", CryptKeyHelper.encrypt(vin));
queryWrapper.eq("rnr_bizz_type", bizTpye);
queryWrapper.orderByDesc("create_time");
List<MgRnrCardInfoPO> record = this.list(queryWrapper);
return MgRnrCardInfoConverter.INSTANCE.poListToDtoList(record);
}
@Override
public List<MgRnrCardInfoDTO> queryListByVin(String vin) {
QueryWrapper queryWrapper = new QueryWrapper();
queryWrapper.eq("is_delete", CommonDeleteEnum.NORMAL.getCode());
//queryWrapper.eq("rnr_status", RnrStatus.RNR.getCode());
queryWrapper.eq("iot_id", CryptKeyHelper.encrypt(vin));
queryWrapper.orderByDesc("create_time");
List<MgRnrCardInfoPO> record = this.list(queryWrapper);
return MgRnrCardInfoConverter.INSTANCE.poListToDtoList(record);
}
/**
* 更新解绑记录
*
* @param uuids
* @return
*/
@Override
public Integer unboundCardBatch(List<String> uuids, RnrStatus status) {
return baseMapper.unboundCardBatch(uuids, status.getCode());
}
/**
* 自然人批量解绑卡
*
* @param beans
* @return
*/
@Override
public Integer updateBatchCardStatus(List<MgRnrCardInfoDTO> beans) {
List<String> uuidList = new ArrayList<>();
for (MgRnrCardInfoDTO cardInfoDTO : beans) {
uuidList.add(cardInfoDTO.getUuid());
}
return unboundCardBatch(uuidList, RnrStatus.UNBOUND);
}
@Override
public Integer insertBatchCards(List<MgRnrCardInfoDTO> beans) {
int target = 0;
List<String> uuidList = new ArrayList<>();
for (MgRnrCardInfoDTO cardInfoDTO : beans) {
MgRnrCardInfoDTO insert = this.insert(cardInfoDTO);
if (insert == null) {
break;
} else {
target++;
}
}
return target;
}
@Override
@Transactional
public void updateCardStatusByRnrId(MgRnrCardInfoDTO dto) {
MgRnrCardInfoPO updateEntity = new MgRnrCardInfoPO();
updateEntity.setRnrStatus(dto.getRnrStatus());
LambdaQueryWrapper<MgRnrCardInfoPO> query = new LambdaQueryWrapper<>();
query.eq(MgRnrCardInfoPO::getRnrId, dto.getRnrId());
this.baseMapper.update(updateEntity, query);
}
@Override
public void sendCardNotice(MgRnrCardInfoDTO dto) {
if (StringUtils.isBlank(dto.getOrderId())) {
return;
}
cardNoticeService.sendCardNoticeByOrderId(dto.getOrderId());
}
@Override
public PageResult<MgRnrCardInfoDTO> queryPageByUserId(MgRnrCardInfoDTO bean) {
Page<MgRnrCardInfoPO> page = new Page<>(bean.getCurrPage(), bean.getPageSize());
page.setRecords(baseMapper.queryByUserId(page, bean));
return PageHelper.convert(page, MgRnrCardInfoDTO.class);
}
/**
* 根据iccid最新的实名卡信息
*/
@Override
public MgRnrCardInfoDTO getNewRnrCardByIccid(MgRnrCardInfoDTO bean) {
QueryWrapper queryWrapper = new QueryWrapper();
queryWrapper.eq("is_delete", CommonDeleteEnum.NORMAL.getCode());
queryWrapper.ne( "rnr_bizz_type", RnrBizzTypeEnum.Unbound.getCode());
queryWrapper.eq("iccid", CryptKeyHelper.encrypt(bean.getIccid()));
queryWrapper.eq("tenant_no", bean.getTenantNo());
queryWrapper.eq("rnr_status", RnrStatus.RNR.getCode());
queryWrapper.orderByDesc("create_time");
List<MgRnrCardInfoPO> record = this.list(queryWrapper);
if(CollectionUtils.isEmpty(record)){
return null;
}
return MgRnrCardInfoConverter.INSTANCE.poToDto(record.get(0));
}
@Override
public int getNumWithUnload(MgRnrInfoDTO dto) {
int num = 0 ;
String certNumber = CryptKeyHelper.encrypt(dto.getCertNumber());
List<String> retList = this.baseMapper.getNumWithUnload(certNumber);
for (String iccid : retList) {
iccid = CryptKeyHelper.decrypt(iccid);
MbCodeEnum mbCodeEnum = MbCodeEnum.get(iccid);
log.info("解密之后是,{},通讯商是,{},前6位是,{}", iccid, mbCodeEnum.getName(), iccid.substring(0, 6));
if(MbCodeEnum.CUCC.equals(mbCodeEnum)){
num ++;
}
}
return num;
}
//-----------私有方法区--------------
/**
* 通过UUID查询单条数据
*
* @param uuid
* @return 实例对象
*/
private MgRnrCardInfoPO getPoByUuid(String uuid) {
QueryWrapper queryWrapper = new QueryWrapper();
queryWrapper.eq("uuid", uuid);
queryWrapper.eq("is_delete", CommonDeleteEnum.NORMAL.getCode());
return this.getOne(queryWrapper);
}
/**
* 通过iccid查询单条数据
*/
private List<MgRnrCardInfoPO> getListByIccid(String iccid) {
QueryWrapper queryWrapper = new QueryWrapper();
queryWrapper.eq("iccid", CryptKeyHelper.encrypt(iccid));
queryWrapper.eq("is_delete", CommonDeleteEnum.NORMAL.getCode());
return this.list(queryWrapper);
}
/**
* 通过iccid和vin查询实名后的单条数据
*/
private MgRnrCardInfoPO getOneCardByIccid(String iccid, String vin, String tenantNo) {
QueryWrapper queryWrapper = new QueryWrapper();
queryWrapper.eq("iccid", CryptKeyHelper.encrypt(iccid));
queryWrapper.ne("rnr_bizz_type", RnrBizzTypeEnum.Unbound.getCode());
queryWrapper.eq("is_delete", CommonDeleteEnum.NORMAL.getCode());
queryWrapper.eq("rnr_status", RnrStatus.RNR.getCode());
queryWrapper.eq("tenant_no", tenantNo);
if (StringUtils.isNotEmpty(vin)) {
queryWrapper.eq("iot_id", CryptKeyHelper.encrypt(vin));
}
List<MgRnrCardInfoPO> retList = this.list(queryWrapper);
if (!CollectionUtils.isEmpty(retList)) {
return retList.get(0);
}
return null;
}
public List<MgRnrCardInfoDTO> getByRnrid(String uuid) {
QueryWrapper queryWrapper = new QueryWrapper();
queryWrapper.eq("is_delete", CommonDeleteEnum.NORMAL.getCode());
queryWrapper.eq("rnr_id", uuid);
queryWrapper.orderByDesc("create_time");
List<MgRnrCardInfoPO> record = this.list(queryWrapper);
return MgRnrCardInfoConverter.INSTANCE.poListToDtoList(record);
}
/**
* 通过iccid查询单条数据
*//*
private List<MgRnrCardInfoPO> getCardByIccids(String vin) {
QueryWrapper queryWrapper = new QueryWrapper();
queryWrapper.eq("is_delete", CommonDeleteEnum.NORMAL.getCode());
queryWrapper.eq("rnr_status", RnrStatus.RNR.getCode());
queryWrapper.eq("iot_id",vin);
return this.list(queryWrapper);
}*/
}
package com.cusc.nirvana.user.rnr.mg.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.nacos.common.utils.CollectionUtils;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.cache.CacheFactory;
import com.cache.exception.CacheException;
import com.cusc.nirvana.common.result.Response;
import com.cusc.nirvana.user.eiam.dto.OrganizationDTO;
import com.cusc.nirvana.user.rnr.common.constants.RedisConstant;
import com.cusc.nirvana.user.rnr.mg.constants.NoticeStatusEnum;
import com.cusc.nirvana.user.rnr.mg.constants.RnrBizzTypeEnum;
import com.cusc.nirvana.user.rnr.mg.constants.RnrMgMqConstant;
import com.cusc.nirvana.user.rnr.mg.constants.RnrOrderType;
import com.cusc.nirvana.user.rnr.mg.converter.MgRnrCardInfoConverter;
import com.cusc.nirvana.user.rnr.mg.dao.entity.MgRnrCardInfoPO;
import com.cusc.nirvana.user.rnr.mg.dto.MgCardNoticeDTO;
import com.cusc.nirvana.user.rnr.mg.dto.MgRnrCardInfoDTO;
import com.cusc.nirvana.user.rnr.mg.dto.MgRnrTaskDTO;
import com.cusc.nirvana.user.rnr.mg.dto.RnrOrderDTO;
import com.cusc.nirvana.user.rnr.mg.service.*;
import com.cusc.nirvana.user.rnr.mg.util.RnrOrderUtil;
import com.cusc.nirvana.user.rnr.notice.kafka.KafkaProduct;
import com.cusc.nirvana.user.rnr.workorder.context.WorkOrderCallBackContext;
import com.cusc.nirvana.user.rnr.workorder.dto.WorkOrderReviewCallBackRequestDTO;
import com.cusc.nirvana.user.rnr.workorder.handler.WorkOrderCallBackHandler;
import com.cusc.nirvana.user.util.CuscStringUtils;
import com.cusc.nirvana.user.util.DateUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
/**
* 消息发送实现类
*
* @author yubo
* @since 2022-04-16 14:53
*/
@Service
@Slf4j
@EnableScheduling
public class MgRnrCardNoticeServiceImpl implements IMgRnrCardNoticeService {
@Autowired
IMgRnrCardInfoService cardInfoService;
@Autowired
IRnrOrderService orderService;
@Resource
private CacheFactory cacheFactory;
@Autowired
private KafkaProduct kafkaProduct;
@Value("${mg.rnr.mq.lock.expireTime:6000}")
private int expireTime;
@Autowired
private IOrganService organService;
@Resource
private WorkOrderCallBackContext context;
@Resource
private IMgRnrTaskService mgRnrTaskService;
@Scheduled(fixedDelayString = "${mg.rnr.mq.interval:300000}")
@Override
public void sendCardNotices() {
log.info("MgRnrCardNoticeServiceImpl sendCardNotices start {}", DateUtils.currentTimeStr());
Iterator<MgRnrCardInfoPO> it = findNoticeCards();
while (it.hasNext()) {
MgRnrCardInfoPO cardInfoPO = it.next();
RnrOrderDTO rnrOrderDTO = new RnrOrderDTO();
rnrOrderDTO.setUuid(cardInfoPO.getOrderId());
rnrOrderDTO = orderService.getByUuid(rnrOrderDTO);
//如果是换件,需要查询老卡iccid。用于T1上报
if (RnrOrderType.TBOX_CHANGE.getCode() == rnrOrderDTO.getOrderType()) {
MgRnrCardInfoDTO mgRnrCardInfoDTO = new MgRnrCardInfoDTO();
mgRnrCardInfoDTO.setUuid(cardInfoPO.getOldCardId());
MgRnrCardInfoDTO mgRnrCardInfo = cardInfoService.getByUuid(mgRnrCardInfoDTO);
if (null != mgRnrCardInfo) {
cardInfoPO.setOldCardId(mgRnrCardInfo.getIccid());
}
}
sendCardNotice(convertToNotice(cardInfoPO, RnrOrderUtil.orderTypeToNoticeType(rnrOrderDTO.getOrderType()),
rnrOrderDTO)); }
}
/**
* 发送实名卡通知
*/
@Async("mqExecutor")
@Override
public void sendCardNotice(List<MgCardNoticeDTO> dtos) {
for (MgCardNoticeDTO dto : dtos) {
sendCardNotice(dto);
}
}
@Override
public void sendCardNoticeByOrderId(String orderId) {
RnrOrderDTO rnrOrderDTO = new RnrOrderDTO();
rnrOrderDTO.setUuid(orderId);
rnrOrderDTO = orderService.getByUuid(rnrOrderDTO);
//查询车企信息
String manufacturerOrgId;
OrganizationDTO organ = new OrganizationDTO();
organ.setTenantNo(rnrOrderDTO.getTenantNo());
organ.setUuid(rnrOrderDTO.getOrgId());
Response<OrganizationDTO> organResp = organService.getCarSubOrganByOrgId(organ);
if (organResp != null && organResp.isSuccess() && organResp.getData() != null) {
manufacturerOrgId = organResp.getData().getUuid();
}else{
log.warn("sendCardNoticeByOrderId 获取车企组织失败,{}", JSON.toJSONString(organResp));
manufacturerOrgId = "0";
}
QueryWrapper<MgRnrCardInfoPO> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("order_id", orderId);
List<MgRnrCardInfoPO> list = cardInfoService.list(queryWrapper);
List<MgCardNoticeDTO> dtos = new ArrayList<>();
for (MgRnrCardInfoPO cardInfo : list) {
MgCardNoticeDTO mgCardNoticeDTO =
convertToNotice(cardInfo, RnrOrderUtil.orderTypeToNoticeType(rnrOrderDTO.getOrderType()),
rnrOrderDTO);
if (mgCardNoticeDTO != null) {
mgCardNoticeDTO.setManufacturerOrgId(manufacturerOrgId);
dtos.add(mgCardNoticeDTO);
}
}
sendCardNotice(dtos);
}
// ------------------ 私有方法区 --------------------
/**
* 发送卡操作消息
*
* @param dto
*/
private void sendCardNotice(MgCardNoticeDTO dto) {
String lockKey = RedisConstant.RNR_CARD_NOTICE_LOCK + dto.getOrderId() + ":" + dto.getIccid();
try {
Boolean lock = cacheFactory.getLockService().lock(lockKey, expireTime);
if (!lock) {
return;
}
kafkaProduct.sendMessage(RnrMgMqConstant.RNR_CARD_OPERATION_TOPIC, JSON.toJSONString(dto));
log.info("发送实名kafka消息成功:{}", JSON.toJSONString(dto));
MgRnrCardInfoDTO mgRnrCardInfoDTO = cardInfoService.getByOrderIdAndIccId(dto.getOrderId(), dto.getIccid
());
log.warn("mgRnrCardInfoDTO==={}", JSON.toJSON(mgRnrCardInfoDTO));
if (mgRnrCardInfoDTO != null) {
MgRnrCardInfoPO cardInfoPO = new MgRnrCardInfoPO();
cardInfoPO.setId(mgRnrCardInfoDTO.getId());
cardInfoPO.setNoticeStatus(NoticeStatusEnum.SUCCESS.getCode());
cardInfoService.updateById(cardInfoPO);
log.info("更新发送状态:{}", JSON.toJSONString(dto));
}
} catch (Exception e) {
log.error("RetryUploadInfo failed, card notice: " + dto.getOrderId() + ":" + dto.getIccid(), e);
} finally {
try {
cacheFactory.getLockService().unLock(lockKey);
} catch (CacheException e) {
log.error("Failed to unlock " + lockKey, e);
}
}
}
/**
* 转成要发送的消息体
*
* @param cardInfo
* @return
*/
private MgCardNoticeDTO convertToNotice(MgRnrCardInfoPO cardInfo, RnrBizzTypeEnum rnrNoticeTypeEnum,
RnrOrderDTO rnrOrderDTO) {
MgCardNoticeDTO mqDTO = MgRnrCardInfoConverter.INSTANCE.poToNoticeDTO(cardInfo);
mqDTO.setVin(cardInfo.getIotId());
mqDTO.setRnrBizzType(rnrNoticeTypeEnum.getCode());
mqDTO.setOrderId(cardInfo.getOrderId());
mqDTO.setOldIccid(cardInfo.getOldCardId());
mqDTO.setIccid(cardInfo.getIccid());
mqDTO.setManufacturerOrgId(rnrOrderDTO.getOrgId());
mqDTO.setResultCode(rnrOrderDTO.getOrderStatus());
mqDTO.setTenantNo(rnrOrderDTO.getTenantNo());
return mqDTO;
}
/**
* 获取待发送卡消息
*/
private Iterator<MgRnrCardInfoPO> findNoticeCards() {
return new Iterator<MgRnrCardInfoPO>() {
private Page<MgRnrCardInfoPO> cardInfoPOs;
int currentPage = 1;
int currentIndex = 0;
@Override
public boolean hasNext() {
if (cardInfoPOs != null && currentIndex < cardInfoPOs.getRecords().size()) {
return true;
}
if (cardInfoPOs == null) {
cardInfoPOs = findNexPage(currentPage++);
currentIndex = 0;
} else if (currentIndex >= cardInfoPOs.getRecords().size()) {
currentIndex = 0;
if (cardInfoPOs.hasNext()) {
cardInfoPOs = findNexPage(currentPage++);
} else {
cardInfoPOs = null;
}
}
return cardInfoPOs != null && !cardInfoPOs.getRecords().isEmpty();
}
@Override
public MgRnrCardInfoPO next() {
return cardInfoPOs.getRecords().get(currentIndex++);
}
};
}
private Page<MgRnrCardInfoPO> findNexPage(int page) {
QueryWrapper<MgRnrCardInfoPO> queryWrapper = new QueryWrapper<>();
//notice_status != 0 and notice_status != 2
queryWrapper.eq("notice_status", NoticeStatusEnum.NEED.getCode());
queryWrapper.orderByAsc("create_time");
return cardInfoService.page(new Page<>(page, 100), queryWrapper);
}
@Async("asyncOrderExecutor")
@Override
public void asyncOrderExecutor(WorkOrderReviewCallBackRequestDTO callBackRequestDTO) {
WorkOrderCallBackHandler workBackHandler = context.getWorkBackHandler(callBackRequestDTO.getWorkOrderKey());
MgRnrTaskDTO mgRnrTaskDTO = new MgRnrTaskDTO();
mgRnrTaskDTO.setUuid(CuscStringUtils.generateUuid());
mgRnrTaskDTO.setBizKey(callBackRequestDTO.getCode());
mgRnrTaskDTO.setBizCode("asyncOrder");
mgRnrTaskDTO.setBizContent(JSONObject.toJSONString(callBackRequestDTO));
mgRnrTaskDTO.setBizStatus(0);
mgRnrTaskService.insert(mgRnrTaskDTO);
if (null != workBackHandler) {
try {
workBackHandler.reviewCallBack(callBackRequestDTO);
mgRnrTaskDTO.setBizStatus(1);
mgRnrTaskService.update(mgRnrTaskDTO);
} catch (Exception e) {
mgRnrTaskDTO.setBizStatus(2);
mgRnrTaskService.update(mgRnrTaskDTO);
log.warn("callBackRequestDTO{},e{}",JSON.toJSONString(callBackRequestDTO),e);
}
}
}
}
package com.cusc.nirvana.user.rnr.mg.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cache.annotation.tag.Cache;
import com.cusc.nirvana.user.rnr.common.constants.RedisConstant;
import com.cusc.nirvana.user.rnr.mg.constants.CommonDeleteEnum;
import com.cusc.nirvana.user.rnr.mg.converter.MgRnrCommonConfigConverter;
import com.cusc.nirvana.user.rnr.mg.dao.MgRnrCommonConfigDao;
import com.cusc.nirvana.user.rnr.mg.dao.entity.MgRnrCommonConfigPO;
import com.cusc.nirvana.user.rnr.mg.dto.MgRnrCommonConfigDTO;
import com.cusc.nirvana.user.rnr.mg.service.IMgRnrCommonConfigService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
/**
* 实名业务公共配置(MgRnrCommonConfig)表服务实现类
*
* @author yuy336
* @since 2022-03-03 10:56:46
*/
@Service
public class MgRnrCommonConfigServiceImpl extends ServiceImpl<MgRnrCommonConfigDao, MgRnrCommonConfigPO>
implements IMgRnrCommonConfigService {
/**
* 通过UUID查询单条数据
*
* @param bean
* @return 实例对象
*/
@Override
public MgRnrCommonConfigDTO getByUuid(MgRnrCommonConfigDTO bean) {
MgRnrCommonConfigPO record = this.getPoByUuid(bean.getUuid());
;
return MgRnrCommonConfigConverter.INSTANCE.poToDto(record);
}
/**
* 通过查询条件查询集合数据
*
* @param bean
* @return 集合对象
*/
@Override
public List<MgRnrCommonConfigDTO> queryByList(MgRnrCommonConfigDTO bean) {
QueryWrapper queryWrapper = new QueryWrapper();
queryWrapper.eq("is_delete", CommonDeleteEnum.NORMAL.getCode());
queryWrapper.orderByDesc("create_time");
List<MgRnrCommonConfigPO> record = this.list(queryWrapper);
return MgRnrCommonConfigConverter.INSTANCE.poListToDtoList(record);
}
/**
* 新增数据
*
* @param bean 实例对象
* @return 实例对象
*/
@Override
@Transactional
@Cache(keyPrefix = RedisConstant.RNR_COMMON_CONFIG, key = "#bean.configPath", level1 = "redis", action = 0)
public MgRnrCommonConfigDTO insert(MgRnrCommonConfigDTO bean) {
MgRnrCommonConfigPO mgRnrCommonConfigPO = MgRnrCommonConfigConverter.INSTANCE.dtoToPo(bean);
this.save(mgRnrCommonConfigPO);
return bean;
}
/**
* 修改数据
*
* @param bean 实例对象
* @return 实例对象
*/
@Override
@Transactional
@Cache(keyPrefix = RedisConstant.RNR_COMMON_CONFIG, key = "#bean.configPath", level1 = "redis", action = 0)
public MgRnrCommonConfigDTO update(MgRnrCommonConfigDTO bean) {
MgRnrCommonConfigPO mgRnrCommonConfigPO = this.getPoByUuid(bean.getUuid());
if (mgRnrCommonConfigPO == null) {
return null;
}
MgRnrCommonConfigPO tmpBean = MgRnrCommonConfigConverter.INSTANCE.dtoToPo(bean);
tmpBean.setId(mgRnrCommonConfigPO.getId());
this.updateById(tmpBean);
return bean;
}
/**
* 通过主键删除数据
*
* @param bean 实例对象
* @return 是否成功
*/
@Override
@Transactional
@Cache(keyPrefix = RedisConstant.RNR_COMMON_CONFIG, key = "#bean.configPath", level1 = "redis", action = 0)
public boolean deleteById(MgRnrCommonConfigDTO bean) {
MgRnrCommonConfigPO mgRnrCommonConfigPO = this.getPoByUuid(bean.getUuid());
if (mgRnrCommonConfigPO == null) {
return false;
}
MgRnrCommonConfigPO tmpBean = new MgRnrCommonConfigPO();
tmpBean.setId(mgRnrCommonConfigPO.getId());
tmpBean.setIsDelete(CommonDeleteEnum.DELETED.getCode());
return this.updateById(tmpBean);
}
@Override
@Cache(keyPrefix = RedisConstant.RNR_COMMON_CONFIG, key = "#path", level1 = "redis")
public MgRnrCommonConfigDTO getByConfigPath(String path) {
QueryWrapper queryWrapper = new QueryWrapper();
queryWrapper.eq("config_path", path);
queryWrapper.eq("is_delete", CommonDeleteEnum.NORMAL.getCode());
MgRnrCommonConfigPO record = this.getOne(queryWrapper);
return MgRnrCommonConfigConverter.INSTANCE.poToDto(record);
}
@Override
public List<MgRnrCommonConfigDTO> getByConfigParentPath(String parentPath) {
QueryWrapper queryWrapper = new QueryWrapper();
queryWrapper.eq("parent_path", parentPath);
queryWrapper.eq("is_delete", CommonDeleteEnum.NORMAL.getCode());
queryWrapper.orderByAsc("create_time");
List<MgRnrCommonConfigPO> record = this.list(queryWrapper);
return MgRnrCommonConfigConverter.INSTANCE.poListToDtoList(record);
}
/**
* 通过UUID查询单条数据
*
* @param uuid
* @return 实例对象
*/
private MgRnrCommonConfigPO getPoByUuid(String uuid) {
QueryWrapper queryWrapper = new QueryWrapper();
queryWrapper.eq("uuid", uuid);
queryWrapper.eq("is_delete", CommonDeleteEnum.NORMAL.getCode());
return this.getOne(queryWrapper);
}
}
package com.cusc.nirvana.user.rnr.mg.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cusc.nirvana.user.rnr.mg.constants.CommonDeleteEnum;
import com.cusc.nirvana.user.rnr.mg.constants.CryptKeyHelper;
import com.cusc.nirvana.user.rnr.mg.converter.MgRnrCompanyInfoConverter;
import com.cusc.nirvana.user.rnr.mg.dao.MgRnrCompanyInfoDao;
import com.cusc.nirvana.user.rnr.mg.dao.entity.MgRnrCompanyInfoPO;
import com.cusc.nirvana.user.rnr.mg.dto.MgRnrCompanyInfoDTO;
import com.cusc.nirvana.user.rnr.mg.service.IMgRnrCompanyInfoService;
import com.cusc.nirvana.user.util.CuscStringUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import java.util.List;
import java.util.stream.Collectors;
/**
* 实名公司信息表(MgRnrCompanyInfo)表服务实现类
*
* @author yuy336
* @since 2022-02-10 18:30:32
*/
@Service
public class MgRnrCompanyInfoServiceImpl extends ServiceImpl<MgRnrCompanyInfoDao, MgRnrCompanyInfoPO> implements IMgRnrCompanyInfoService {
/**
* 通过UUID查询单条数据
*
* @param bean
* @return 实例对象
*/
@Override
public MgRnrCompanyInfoDTO getByUuid(MgRnrCompanyInfoDTO bean) {
MgRnrCompanyInfoPO record = this.getPoByUuid(bean.getUuid());;
return MgRnrCompanyInfoConverter.INSTANCE.poToDto(record);
}
@Override
public MgRnrCompanyInfoDTO getByRnrid(MgRnrCompanyInfoDTO bean) {
MgRnrCompanyInfoPO record = this.getPoByRnrid(bean.getRnrId());;
return MgRnrCompanyInfoConverter.INSTANCE.poToDto(record);
}
@Override
public List<String> findRnrIdsByCompanyName(MgRnrCompanyInfoDTO bean) {
QueryWrapper queryWrapper = new QueryWrapper();
queryWrapper.eq("is_delete", CommonDeleteEnum.NORMAL.getCode());
queryWrapper.eq("company_name", CryptKeyHelper.encrypt(bean.getCompanyName()));
queryWrapper.orderByDesc("create_time");
List<MgRnrCompanyInfoPO> record = this.list(queryWrapper);
return record.stream().map(info -> info.getRnrId()).collect(Collectors.toList());
}
/**
* 通过查询条件查询集合数据
*
* @param bean
* @return 集合对象
*/
@Override
public List<MgRnrCompanyInfoDTO> queryByList(MgRnrCompanyInfoDTO bean) {
QueryWrapper queryWrapper = new QueryWrapper();
queryWrapper.eq("is_delete", CommonDeleteEnum.NORMAL.getCode());
queryWrapper.eq(StringUtils.isNotBlank(bean.getTenantNo()),"tenant_no",bean.getTenantNo());
queryWrapper.eq(null != bean.getIsVehicleCompany(),"is_vehicle_company",bean.getIsVehicleCompany());
queryWrapper.eq(StringUtils.isNotBlank(bean.getRnrId()),"rnr_id",bean.getRnrId());
queryWrapper.in(!CollectionUtils.isEmpty(bean.getRnrIdList()),"rnr_id",bean.getRnrIdList());
queryWrapper.likeLeft(StringUtils.isNotBlank(bean.getCompanyName()),"company_name",CryptKeyHelper.encrypt(bean.getCompanyName()));
queryWrapper.orderByDesc("create_time");
List<MgRnrCompanyInfoPO> record = this.list(queryWrapper);
return MgRnrCompanyInfoConverter.INSTANCE.poListToDtoList(record);
}
/**
* 新增数据
*
* @param bean 实例对象
* @return 实例对象
*/
@Override
@Transactional
public MgRnrCompanyInfoDTO insert(MgRnrCompanyInfoDTO bean) {
MgRnrCompanyInfoPO mgRnrCompanyInfoPO = MgRnrCompanyInfoConverter.INSTANCE.dtoToPo(bean);
if(CuscStringUtils.isEmpty(bean.getUuid())){
mgRnrCompanyInfoPO.setUuid(CuscStringUtils.generateUuid());
bean.setUuid(mgRnrCompanyInfoPO.getUuid());
}
this.save(mgRnrCompanyInfoPO);
return bean;
}
/**
* 修改数据
*
* @param bean 实例对象
* @return 实例对象
*/
@Override
@Transactional
public MgRnrCompanyInfoDTO update(MgRnrCompanyInfoDTO bean) {
MgRnrCompanyInfoPO mgRnrCompanyInfoPO = this.getPoByUuid(bean.getUuid());
if(mgRnrCompanyInfoPO == null){
return null;
}
MgRnrCompanyInfoPO tmpBean = MgRnrCompanyInfoConverter.INSTANCE.dtoToPo(bean);
tmpBean.setId(mgRnrCompanyInfoPO.getId());
this.updateById(tmpBean);
return bean;
}
/**
* 通过主键删除数据
* @param bean 实例对象
* @return 是否成功
*/
@Override
@Transactional
public boolean deleteById(MgRnrCompanyInfoDTO bean) {
MgRnrCompanyInfoPO mgRnrCompanyInfoPO = this.getPoByUuid(bean.getUuid());
if (mgRnrCompanyInfoPO == null) {
return false;
}
MgRnrCompanyInfoPO tmpBean = new MgRnrCompanyInfoPO();
tmpBean.setId(mgRnrCompanyInfoPO.getId());
tmpBean.setIsDelete(CommonDeleteEnum.DELETED.getCode());
return this.updateById(tmpBean);
}
/**
* 通过UUID查询单条数据
*
* @param uuid
* @return 实例对象
*/
private MgRnrCompanyInfoPO getPoByUuid(String uuid) {
QueryWrapper queryWrapper = new QueryWrapper();
queryWrapper.eq("uuid", uuid);
queryWrapper.eq("is_delete", CommonDeleteEnum.NORMAL.getCode());
return this.getOne(queryWrapper);
}
/**
* 根据rnrid获取列表
* @param rnrid
* @return
*/
private MgRnrCompanyInfoPO getPoByRnrid(String rnrid) {
QueryWrapper queryWrapper = new QueryWrapper();
queryWrapper.eq("rnr_id", rnrid);
queryWrapper.eq("is_delete", CommonDeleteEnum.NORMAL.getCode());
return this.getOne(queryWrapper);
}
}
package com.cusc.nirvana.user.rnr.mg.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cusc.nirvana.common.result.PageResult;
import com.cusc.nirvana.rds.mybatis.PageHelper;
import com.cusc.nirvana.user.rnr.mg.constants.CommonDeleteEnum;
import com.cusc.nirvana.user.rnr.mg.converter.MgRnrImageConverter;
import com.cusc.nirvana.user.rnr.mg.dao.MgRnrFileDao;
import com.cusc.nirvana.user.rnr.mg.dao.entity.MgRnrFilePO;
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.service.IFileService;
import com.cusc.nirvana.user.rnr.mg.service.IMgRnrFileService;
import com.cusc.nirvana.user.util.CuscStringUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import java.util.ArrayList;
import java.util.List;
/**
* 实名图片信息表(MgRnrImage0)表服务实现类
*
* @author yuy336
* @since 2022-01-26 13:49:12
*/
@Service
public class MgRnrFileServiceImpl extends ServiceImpl<MgRnrFileDao, MgRnrFilePO> implements IMgRnrFileService {
@Autowired
private IFileService fileService;
/**
* 通过UUID查询单条数据
*
* @param bean
* @return 实例对象
*/
@Override
public MgRnrFileDTO getByUuid(MgRnrFileDTO bean) {
MgRnrFilePO record = this.getPoByUuid(bean.getUuid());
return MgRnrImageConverter.INSTANCE.poToDto(record);
}
/**
* 通过RNRID查询数据
*
* @param bean
* @return 实例对象
*/
@Override
public List<MgRnrFileDTO> getByRnrid(MgRnrFileDTO bean) {
List<MgRnrFilePO> poByRnrid = this.getPoByRnrid(bean.getRnrId(), bean.getTenantNo());
return MgRnrImageConverter.INSTANCE.poListToDtoList(poByRnrid);
}
/**
* 通过查询条件查询集合数据
*
* @param bean
* @return 集合对象
*/
@Override
public List<MgRnrFileDTO> queryByList(MgRnrFileDTO bean) {
QueryWrapper queryWrapper = new QueryWrapper();
queryWrapper.eq(StringUtils.isNotBlank(bean.getRnrId()), "rnr_id", bean.getRnrId());
queryWrapper.eq(bean.getRnrBizzType() != null, "rnr_bizz_type", bean.getRnrBizzType());
queryWrapper.eq(bean.getFileType() != null, "file_type", bean.getFileType());
queryWrapper.eq(StringUtils.isNotBlank(bean.getRnrCompanyId()), "rnr_company_id", bean.getRnrCompanyId());
queryWrapper.eq(StringUtils.isNotBlank(bean.getLiaisonId()), "liaison_id", bean.getLiaisonId());
queryWrapper.eq(bean.getRoutingKey() != null, "routing_key", bean.getRoutingKey());
queryWrapper.eq(StringUtils.isNotBlank(bean.getTenantNo()), "tenant_no", bean.getTenantNo());
queryWrapper.eq("is_delete", CommonDeleteEnum.NORMAL.getCode());
queryWrapper.orderByDesc("order_no", "create_time");
List<MgRnrFilePO> record = this.list(queryWrapper);
return MgRnrImageConverter.INSTANCE.poListToDtoList(record);
}
/**
* 分页查询
*
* @param bean 筛选条件
* @return 查询结果
*/
@Override
public PageResult<MgRnrFileDTO> queryByPage(MgRnrFileDTO bean) {
QueryWrapper queryWrapper = new QueryWrapper();
queryWrapper.orderByDesc("create_time");
queryWrapper.eq("is_delete", CommonDeleteEnum.NORMAL.getCode());
Page<MgRnrFilePO> page =
this.page(new Page<>(bean.getCurrPage(), bean.getPageSize()), queryWrapper);
return PageHelper.convert(page, MgRnrFileDTO.class);
}
/**
* 新增数据
*
* @param bean 实例对象
* @return 实例对象
*/
@Override
@Transactional
public MgRnrFileDTO insert(MgRnrFileDTO bean) {
MgRnrFilePO mgRnrImagePO = MgRnrImageConverter.INSTANCE.dtoToPo(bean);
if (CuscStringUtils.isEmpty(bean.getUuid())) {
mgRnrImagePO.setUuid(CuscStringUtils.generateUuid());
bean.setUuid(mgRnrImagePO.getUuid());
}
this.save(mgRnrImagePO);
return bean;
}
/**
* 修改数据
*
* @param bean 实例对象
* @return 实例对象
*/
@Override
@Transactional
public MgRnrFileDTO update(MgRnrFileDTO bean) {
MgRnrFilePO MgRnrImagePO = this.getPoByUuid(bean.getUuid());
if (MgRnrImagePO == null) {
return null;
}
MgRnrFilePO tmpBean = MgRnrImageConverter.INSTANCE.dtoToPo(bean);
tmpBean.setId(MgRnrImagePO.getId());
this.updateById(tmpBean);
return bean;
}
/**
* 通过主键删除数据
*
* @param bean 实例对象
* @return 是否成功
*/
@Override
@Transactional
public boolean deleteById(MgRnrFileDTO bean) {
MgRnrFilePO MgRnrImagePO = this.getPoByUuid(bean.getUuid());
if (MgRnrImagePO == null) {
return false;
}
MgRnrFilePO tmpBean = new MgRnrFilePO();
tmpBean.setId(MgRnrImagePO.getId());
tmpBean.setIsDelete(CommonDeleteEnum.DELETED.getCode());
return this.updateById(tmpBean);
}
@Override
public List<MgRnrFileDTO> rnrImageBatchUpload(List<MgRnrFileDTO> imageList, MgRnrInfoDTO rnrInfoDTO) {
return null;
}
@Override
public Integer addRnrFileBatch(List<MgRnrFilePO> beanList) {
return baseMapper.addRnrFileBatch(beanList);
}
@Override
public Integer addRnrFileFromInfo(MgRnrInfoDTO info, List<MgRnrFileDTO> beanList) {
if (CollectionUtils.isEmpty(beanList)) {
return 0;
}
MgRnrFilePO imagePO;
// FileEntityBase64DTO fileEntityDTO;
List<MgRnrFilePO> imagePOList = new ArrayList<>();
// List<FileEntityBase64DTO> fileEntityList = new ArrayList<>();
for (MgRnrFileDTO imageDTO : beanList) {
imageDTO.setUuid(CuscStringUtils.generateUuid());
imageDTO.setFileSystemId(imageDTO.getFileSystemId());
imageDTO.setRnrId(info.getUuid());
imageDTO.setTenantNo(info.getTenantNo());
imageDTO.setRoutingKey(info.getRoutingKey());
imageDTO.setRnrBizzType(info.getRnrBizzType());
imageDTO.setIsCompany(info.getIsCompany());
imagePO = MgRnrImageConverter.INSTANCE.dtoToPo(imageDTO);
imagePOList.add(imagePO);
// fileEntityDTO = new FileEntityBase64DTO();
// fileEntityDTO.setUuid(imageDTO.getUuid());
// fileEntityDTO.setFileName(imageDTO.getFileName());
// fileEntityDTO.setBase64(imageDTO.getFileBase64());
// fileEntityList.add(fileEntityDTO);
}
//文件上传
// FileBase64ReqDTO base64ReqDTO = new FileBase64ReqDTO();
// base64ReqDTO.setFileList(fileEntityList);
// boolean isUploadFile = fileService.uploadBase64(base64ReqDTO);
// if (!isUploadFile) {
// throw new CuscUserException(ResponseCode.RNR_IMAGE_UPLOAD_FAIL.getCode(),
// ResponseCode.RNR_IMAGE_UPLOAD_FAIL.getMsg());
// }
//执行文件保存
return addRnrFileBatch(imagePOList);
}
/**
* 通过UUID查询单条数据
*
* @param uuid
* @return 实例对象
*/
private MgRnrFilePO getPoByUuid(String uuid) {
QueryWrapper queryWrapper = new QueryWrapper();
queryWrapper.eq("uuid", uuid);
queryWrapper.eq("is_delete", CommonDeleteEnum.NORMAL.getCode());
return this.getOne(queryWrapper);
}
/**
* 根据rnrid获取列表
*
* @param rnrid
* @return
*/
public List<MgRnrFilePO> getPoByRnrid(String rnrid, String tenantNo) {
QueryWrapper queryWrapper = new QueryWrapper();
queryWrapper.eq("rnr_id", rnrid);
queryWrapper.eq("tenant_no", tenantNo);
queryWrapper.eq("is_delete", CommonDeleteEnum.NORMAL.getCode());
return this.list(queryWrapper);
}
/**
* 根据rnrid获取列表
*
* @param rnrid
* @return
*/
public List<MgRnrFilePO> getPoByRnridOrderByOrderno(String rnrid, String tenantNo) {
QueryWrapper queryWrapper = new QueryWrapper();
queryWrapper.eq("rnr_id", rnrid);
queryWrapper.eq("tenant_no", tenantNo);
queryWrapper.eq("is_delete", CommonDeleteEnum.NORMAL.getCode());
queryWrapper.orderByAsc("order_no");
return this.list(queryWrapper);
}
}
package com.cusc.nirvana.user.rnr.mg.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cusc.nirvana.common.result.PageResult;
import com.cusc.nirvana.rds.mybatis.PageHelper;
import com.cusc.nirvana.user.rnr.mg.constants.CommonDeleteEnum;
import com.cusc.nirvana.user.rnr.mg.constants.CryptKeyHelper;
import com.cusc.nirvana.user.rnr.mg.constants.RnrStatus;
import com.cusc.nirvana.user.rnr.mg.converter.MgRnrInfoConverter;
import com.cusc.nirvana.user.rnr.mg.dao.MgRnrInfoDao;
import com.cusc.nirvana.user.rnr.mg.dao.entity.MgRnrInfoPO;
import com.cusc.nirvana.user.rnr.mg.dto.MgRnrInfoDTO;
import com.cusc.nirvana.user.rnr.mg.service.IMgRnrInfoService;
import com.cusc.nirvana.user.rnr.mg.util.CuscSqlUtils;
import com.cusc.nirvana.user.util.CuscStringUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import java.util.List;
/**
* 实名信息表(MgRnrInfo)表服务实现类
*
* @author yuy336
* @since 2022-02-10 18:30:52
*/
@Service
public class MgRnrInfoServiceImpl extends ServiceImpl<MgRnrInfoDao, MgRnrInfoPO> implements IMgRnrInfoService {
/**
* 通过UUID查询单条数据
*
* @param bean
* @return 实例对象
*/
@Override
public MgRnrInfoDTO getByUuid(MgRnrInfoDTO bean) {
MgRnrInfoPO record = this.getPoByUuid(bean.getUuid());
return MgRnrInfoConverter.INSTANCE.poToDto(record);
}
/**
* 通过查询条件查询集合数据
*
* @param bean
* @return 集合对象
*/
@Override
public List<MgRnrInfoDTO> queryByList(MgRnrInfoDTO bean) {
QueryWrapper queryWrapper = new QueryWrapper();
queryWrapper.eq("is_delete", CommonDeleteEnum.NORMAL.getCode());
queryWrapper.in(!CollectionUtils.isEmpty(bean.getUuidList()),"uuid",bean.getUuidList());
queryWrapper.eq(StringUtils.isNotBlank(bean.getTenantNo()),"tenant_no",bean.getTenantNo());
queryWrapper.eq(StringUtils.isNotBlank(bean.getFullName()),"full_name", CryptKeyHelper.encrypt(bean.getFullName()));
queryWrapper.eq(StringUtils.isNotBlank(bean.getPhone()),"phone",CryptKeyHelper.encrypt(bean.getPhone()));
queryWrapper.eq(StringUtils.isNotBlank(bean.getCertNumber()),"cert_number",CryptKeyHelper.encrypt(bean.getCertNumber()));
queryWrapper.eq(null != bean.getRnrStatus(),"rnr_status",bean.getRnrStatus());
//关联公司进行查询
queryWrapper.exists(StringUtils.isNotBlank(bean.getCompanyName()),"select 1 from mg_rnr_company_info company where mg_rnr_info.uuid = company.rnr_id and company.company_name = '" + CryptKeyHelper.encrypt(
CuscSqlUtils.transactSQLInjection(bean.getCompanyName()))+"'");
queryWrapper.orderByDesc("create_time");
List<MgRnrInfoPO> record = this.list(queryWrapper);
return MgRnrInfoConverter.INSTANCE.poListToDtoList(record);
}
/**
* 分页查询
*
* @param bean 筛选条件
* @return 查询结果
*/
@Override
public PageResult<MgRnrInfoDTO> queryByPage(MgRnrInfoDTO bean) {
QueryWrapper queryWrapper = new QueryWrapper();
queryWrapper.orderByDesc("create_time");
queryWrapper.eq("is_delete", CommonDeleteEnum.NORMAL.getCode());
Page<MgRnrInfoPO> page =
this.page(new Page<>(bean.getCurrPage(), bean.getPageSize()), queryWrapper);
return PageHelper.convert(page, MgRnrInfoDTO.class);
}
/**
* 新增数据
*
* @param bean 实例对象
* @return 实例对象
*/
@Override
@Transactional
public MgRnrInfoDTO insert(MgRnrInfoDTO bean) {
MgRnrInfoPO mgRnrInfoPO = MgRnrInfoConverter.INSTANCE.dtoToPo(bean);
if(CuscStringUtils.isEmpty(bean.getUuid())){
mgRnrInfoPO.setUuid(CuscStringUtils.generateUuid());
bean.setUuid(mgRnrInfoPO.getUuid());
}
this.save(mgRnrInfoPO);
return bean;
}
/**
* 修改数据
*
* @param bean 实例对象
* @return 实例对象
*/
@Override
@Transactional
public MgRnrInfoDTO update(MgRnrInfoDTO bean) {
MgRnrInfoPO mgRnrInfoPO = this.getPoByUuid(bean.getUuid());
if(mgRnrInfoPO == null){
return null;
}
MgRnrInfoPO tmpBean = MgRnrInfoConverter.INSTANCE.dtoToPo(bean);
tmpBean.setId(mgRnrInfoPO.getId());
this.updateById(tmpBean);
return bean;
}
/**
* 通过主键删除数据
* @param bean 实例对象
* @return 是否成功
*/
@Override
@Transactional
public boolean deleteById(MgRnrInfoDTO bean) {
MgRnrInfoPO mgRnrInfoPO = this.getPoByUuid(bean.getUuid());
if (mgRnrInfoPO == null) {
return false;
}
MgRnrInfoPO tmpBean = new MgRnrInfoPO();
tmpBean.setId(mgRnrInfoPO.getId());
tmpBean.setIsDelete(CommonDeleteEnum.DELETED.getCode());
return this.updateById(tmpBean);
}
@Override
public void updateRnrStatus(String rnrId, RnrStatus status) {
this.baseMapper.updateRnrStatus(rnrId,status.getCode());
}
@Override
public void updateRnrStatusBatch(List<String> rnrIds, RnrStatus status) {
this.baseMapper.updateRnrStatusBatch(rnrIds,status.getCode());
}
/**
* 通过UUID查询单条数据
*
* @param uuid
* @return 实例对象
*/
public MgRnrInfoPO getPoByUuid(String uuid) {
QueryWrapper queryWrapper = new QueryWrapper();
queryWrapper.eq("uuid", uuid);
queryWrapper.eq("is_delete", CommonDeleteEnum.NORMAL.getCode());
return this.getOne(queryWrapper);
}
}
package com.cusc.nirvana.user.rnr.mg.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cusc.nirvana.common.result.PageResult;
import com.cusc.nirvana.rds.mybatis.PageHelper;
import com.cusc.nirvana.user.rnr.mg.constants.CommonDeleteEnum;
import com.cusc.nirvana.user.rnr.mg.converter.MgRnrLiaisonInfoConverter;
import com.cusc.nirvana.user.rnr.mg.dao.MgRnrLiaisonInfoDao;
import com.cusc.nirvana.user.rnr.mg.dao.entity.MgRnrLiaisonInfoPO;
import com.cusc.nirvana.user.rnr.mg.dto.MgRnrInfoDTO;
import com.cusc.nirvana.user.rnr.mg.dto.MgRnrLiaisonInfoDTO;
import com.cusc.nirvana.user.rnr.mg.service.IMgRnrLiaisonInfoService;
import com.cusc.nirvana.user.util.CuscStringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
/**
* 实名联系人信息表(MgRnrLiaisonInfo)表服务实现类
*
* @author yuy336
* @since 2022-03-03 19:59:05
*/
@Service
public class MgRnrLiaisonInfoServiceImpl extends ServiceImpl<MgRnrLiaisonInfoDao, MgRnrLiaisonInfoPO>
implements IMgRnrLiaisonInfoService {
/**
* 通过UUID查询单条数据
*
* @param bean
* @return 实例对象
*/
@Override
public MgRnrLiaisonInfoDTO getByUuid(MgRnrLiaisonInfoDTO bean) {
MgRnrLiaisonInfoPO record = this.getPoByUuid(bean.getUuid());
;
return MgRnrLiaisonInfoConverter.INSTANCE.poToDto(record);
}
@Override
public MgRnrLiaisonInfoDTO getByRnrid(MgRnrLiaisonInfoDTO bean) {
MgRnrLiaisonInfoPO record = this.getPoByRnrid(bean.getRnrId());
return MgRnrLiaisonInfoConverter.INSTANCE.poToDto(record);
}
/**
* 通过查询条件查询集合数据
*
* @param bean
* @return 集合对象
*/
@Override
public List<MgRnrLiaisonInfoDTO> queryByList(MgRnrLiaisonInfoDTO bean) {
QueryWrapper queryWrapper = new QueryWrapper();
queryWrapper.eq("is_delete", CommonDeleteEnum.NORMAL.getCode());
queryWrapper.eq(CuscStringUtils.isNotEmpty(bean.getRnrId()), "rnr_id", bean.getRnrId());
queryWrapper.eq(bean.getRnrBizzType() != null, "rnr_bizz_type", bean.getRnrBizzType());
queryWrapper.eq("tenant_no", bean.getTenantNo());
queryWrapper.orderByDesc("create_time");
List<MgRnrLiaisonInfoPO> record = this.list(queryWrapper);
return MgRnrLiaisonInfoConverter.INSTANCE.poListToDtoList(record);
}
/**
* 分页查询
*
* @param bean 筛选条件
* @return 查询结果
*/
@Override
public PageResult<MgRnrLiaisonInfoDTO> queryByPage(MgRnrLiaisonInfoDTO bean) {
QueryWrapper queryWrapper = new QueryWrapper();
queryWrapper.orderByDesc("create_time");
queryWrapper.eq("is_delete", CommonDeleteEnum.NORMAL.getCode());
Page<MgRnrLiaisonInfoPO> page =
this.page(new Page<>(bean.getCurrPage(), bean.getPageSize()), queryWrapper);
return PageHelper.convert(page, MgRnrLiaisonInfoDTO.class);
}
/**
* 新增数据
*
* @param bean 实例对象
* @return 实例对象
*/
@Override
@Transactional
public MgRnrLiaisonInfoDTO insert(MgRnrLiaisonInfoDTO bean) {
MgRnrLiaisonInfoPO mgRnrLiaisonInfoPO = MgRnrLiaisonInfoConverter.INSTANCE.dtoToPo(bean);
mgRnrLiaisonInfoPO.setUuid(CuscStringUtils.generateUuid());
this.save(mgRnrLiaisonInfoPO);
bean.setUuid(mgRnrLiaisonInfoPO.getUuid());
return bean;
}
/**
* 修改数据
*
* @param bean 实例对象
* @return 实例对象
*/
@Override
@Transactional
public MgRnrLiaisonInfoDTO update(MgRnrLiaisonInfoDTO bean) {
MgRnrLiaisonInfoPO mgRnrLiaisonInfoPO = this.getPoByUuid(bean.getUuid());
if (mgRnrLiaisonInfoPO == null) {
return null;
}
MgRnrLiaisonInfoPO tmpBean = MgRnrLiaisonInfoConverter.INSTANCE.dtoToPo(bean);
tmpBean.setId(mgRnrLiaisonInfoPO.getId());
this.updateById(tmpBean);
return bean;
}
/**
* 通过主键删除数据
*
* @param bean 实例对象
* @return 是否成功
*/
@Override
@Transactional
public boolean deleteById(MgRnrLiaisonInfoDTO bean) {
MgRnrLiaisonInfoPO mgRnrLiaisonInfoPO = this.getPoByUuid(bean.getUuid());
if (mgRnrLiaisonInfoPO == null) {
return false;
}
MgRnrLiaisonInfoPO tmpBean = new MgRnrLiaisonInfoPO();
tmpBean.setId(mgRnrLiaisonInfoPO.getId());
tmpBean.setIsDelete(CommonDeleteEnum.DELETED.getCode());
return this.updateById(tmpBean);
}
@Override
public Integer addRnrLiaisonBatch(List<MgRnrLiaisonInfoPO> beanList) {
return baseMapper.addRnrLiaisonBatch(beanList);
}
@Override
public Integer addRnrLiaisonFromRnrInfo(MgRnrInfoDTO info, List<MgRnrLiaisonInfoDTO> beanList) {
MgRnrLiaisonInfoPO liaisonPO;
//List<MgRnrLiaisonInfoPO> liaisonPOList = new ArrayList<>();
for (MgRnrLiaisonInfoDTO liaisonDTO : beanList) {
// liaisonDTO.setUuid(CuscStringUtils.generateUuid());
liaisonDTO.setRnrId(info.getUuid());
liaisonDTO.setTenantNo(info.getTenantNo());
liaisonDTO.setRoutingKey(info.getRoutingKey());
liaisonPO = MgRnrLiaisonInfoConverter.INSTANCE.dtoToPo(liaisonDTO);
//liaisonPOList.add(liaisonPO);
this.baseMapper.insert(liaisonPO);
}
return beanList.size();
}
//-------------------私有方法区-------------------
/**
* 通过UUID查询单条数据
*
* @param uuid
* @return 实例对象
*/
private MgRnrLiaisonInfoPO getPoByUuid(String uuid) {
QueryWrapper queryWrapper = new QueryWrapper();
queryWrapper.eq("uuid", uuid);
queryWrapper.eq("is_delete", CommonDeleteEnum.NORMAL.getCode());
return this.getOne(queryWrapper);
}
/**
* 根据rnrid查询单条数据
*
* @param rnrid
* @return
*/
public MgRnrLiaisonInfoPO getPoByRnrid(String rnrid) {
QueryWrapper queryWrapper = new QueryWrapper();
queryWrapper.eq("rnr_id", rnrid);
queryWrapper.eq("is_delete", CommonDeleteEnum.NORMAL.getCode());
return this.getOne(queryWrapper);
}
}
package com.cusc.nirvana.user.rnr.mg.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cusc.nirvana.common.result.PageResult;
import com.cusc.nirvana.rds.mybatis.PageHelper;
import com.cusc.nirvana.user.rnr.mg.constants.CommonDeleteEnum;
import com.cusc.nirvana.user.rnr.mg.converter.MgRnrOperationLogConverter;
import com.cusc.nirvana.user.rnr.mg.dao.MgRnrOperationLogDao;
import com.cusc.nirvana.user.rnr.mg.dao.entity.MgRnrOperationLogPO;
import com.cusc.nirvana.user.rnr.mg.dto.MgRnrOperationLogDTO;
import com.cusc.nirvana.user.rnr.mg.service.IMgRnrOperationLogService;
import com.cusc.nirvana.user.util.CuscStringUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
/**
* 实名操作日志,包含rnr_info_oplog(MgRnrOperationLog)表服务实现类
*
* @author yuy336
* @since 2022-03-04 15:07:43
*/
@Service
@Slf4j
public class MgRnrOperationLogServiceImpl extends ServiceImpl<MgRnrOperationLogDao, MgRnrOperationLogPO>
implements IMgRnrOperationLogService {
/**
* 通过UUID查询单条数据
*
* @param bean
* @return 实例对象
*/
@Override
public MgRnrOperationLogDTO getByUuid(MgRnrOperationLogDTO bean) {
MgRnrOperationLogPO record = this.getPoByUuid(bean.getUuid());
;
return MgRnrOperationLogConverter.INSTANCE.poToDto(record);
}
/**
* 通过查询条件查询集合数据
*
* @param bean
* @return 集合对象
*/
@Override
public List<MgRnrOperationLogDTO> queryByList(MgRnrOperationLogDTO bean) {
QueryWrapper queryWrapper = new QueryWrapper();
queryWrapper.eq("is_delete", CommonDeleteEnum.NORMAL.getCode());
queryWrapper.orderByDesc("create_time");
List<MgRnrOperationLogPO> record = this.list(queryWrapper);
return MgRnrOperationLogConverter.INSTANCE.poListToDtoList(record);
}
/**
* 分页查询
*
* @param bean 筛选条件
* @return 查询结果
*/
@Override
public PageResult<MgRnrOperationLogDTO> queryByPage(MgRnrOperationLogDTO bean) {
QueryWrapper queryWrapper = new QueryWrapper();
queryWrapper.orderByDesc("create_time");
queryWrapper.eq("is_delete", CommonDeleteEnum.NORMAL.getCode());
Page<MgRnrOperationLogPO> page =
this.page(new Page<>(bean.getCurrPage(), bean.getPageSize()), queryWrapper);
return PageHelper.convert(page, MgRnrOperationLogDTO.class);
}
/**
* 新增数据
*
* @param bean 实例对象
* @return 实例对象
*/
@Override
@Transactional
public MgRnrOperationLogDTO insert(MgRnrOperationLogDTO bean) {
MgRnrOperationLogPO mgRnrOperationLogPO = MgRnrOperationLogConverter.INSTANCE.dtoToPo(bean);
mgRnrOperationLogPO.setUuid(CuscStringUtils.generateUuid());
this.save(mgRnrOperationLogPO);
bean.setUuid(mgRnrOperationLogPO.getUuid());
return bean;
}
/**
* 修改数据
*
* @param bean 实例对象
* @return 实例对象
*/
@Override
@Transactional
public MgRnrOperationLogDTO update(MgRnrOperationLogDTO bean) {
MgRnrOperationLogPO mgRnrOperationLogPO = this.getPoByUuid(bean.getUuid());
if (mgRnrOperationLogPO == null) {
return null;
}
MgRnrOperationLogPO tmpBean = MgRnrOperationLogConverter.INSTANCE.dtoToPo(bean);
tmpBean.setId(mgRnrOperationLogPO.getId());
this.updateById(tmpBean);
return bean;
}
@Override
@Async("logToDBExecutor")
public void addRnrOperationLogBatch(List<MgRnrOperationLogDTO> beanList) {
log.info("addRnrOperationLogBatch paramter: {}", beanList);
baseMapper.addRnrOperationLogBatch(MgRnrOperationLogConverter.INSTANCE.dtoListToPoList(beanList));
}
@Override
@Async("logToDBExecutor")
public void addRnrOperationLogPOBatch(List<MgRnrOperationLogPO> beanList) {
log.info("addRnrOperationLogPOBatch paramter: {}", beanList);
baseMapper.addRnrOperationLogBatch(beanList);
}
/**
* 通过UUID查询单条数据
*
* @param uuid
* @return 实例对象
*/
private MgRnrOperationLogPO getPoByUuid(String uuid) {
QueryWrapper queryWrapper = new QueryWrapper();
queryWrapper.eq("uuid", uuid);
queryWrapper.eq("is_delete", CommonDeleteEnum.NORMAL.getCode());
return this.getOne(queryWrapper);
}
}
package com.cusc.nirvana.user.rnr.mg.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cusc.nirvana.common.result.PageResult;
import com.cusc.nirvana.rds.mybatis.PageHelper;
import com.cusc.nirvana.user.rnr.mg.constants.CommonDeleteEnum;
import com.cusc.nirvana.user.rnr.mg.converter.MgRnrTagConverter;
import com.cusc.nirvana.user.rnr.mg.dao.MgRnrTagDao;
import com.cusc.nirvana.user.rnr.mg.dao.entity.MgRnrTagPO;
import com.cusc.nirvana.user.rnr.mg.dto.MgRnrInfoDTO;
import com.cusc.nirvana.user.rnr.mg.dto.MgRnrTagDTO;
import com.cusc.nirvana.user.rnr.mg.service.IMgRnrTagService;
import com.cusc.nirvana.user.util.CuscStringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List;
/**
* 实名标签,可用于对数据权限查询(MgRnrTag15)表服务实现类
*
* @author yuy336
* @since 2022-01-26 13:50:09
*/
@Service
public class MgRnrTagServiceImpl extends ServiceImpl<MgRnrTagDao, MgRnrTagPO> implements IMgRnrTagService {
/**
* 通过UUID查询单条数据
*
* @param bean
* @return 实例对象
*/
@Override
public MgRnrTagDTO getByUuid(MgRnrTagDTO bean) {
MgRnrTagPO record = this.getPoByUuid(bean.getUuid());;
return MgRnrTagConverter.INSTANCE.poToDto(record);
}
/**
* 通过查询条件查询集合数据
*
* @param bean
* @return 集合对象
*/
@Override
public List<MgRnrTagDTO> queryByList(MgRnrTagDTO bean) {
QueryWrapper queryWrapper = new QueryWrapper();
queryWrapper.eq("is_delete", CommonDeleteEnum.NORMAL.getCode());
queryWrapper.orderByDesc("create_time");
List<MgRnrTagPO> record = this.list(queryWrapper);
return MgRnrTagConverter.INSTANCE.poListToDtoList(record);
}
/**
* 分页查询
*
* @param bean 筛选条件
* @return 查询结果
*/
@Override
public PageResult<MgRnrTagDTO> queryByPage(MgRnrTagDTO bean) {
QueryWrapper queryWrapper = new QueryWrapper();
queryWrapper.orderByDesc("create_time");
queryWrapper.eq("is_delete", CommonDeleteEnum.NORMAL.getCode());
Page<MgRnrTagPO> page =
this.page(new Page<>(bean.getCurrPage(), bean.getPageSize()), queryWrapper);
return PageHelper.convert(page, MgRnrTagDTO.class);
}
/**
* 新增数据
*
* @param bean 实例对象
* @return 实例对象
*/
@Override
@Transactional
public MgRnrTagDTO insert(MgRnrTagDTO bean) {
MgRnrTagPO MgRnrTagPO = MgRnrTagConverter.INSTANCE.dtoToPo(bean);
MgRnrTagPO.setUuid(CuscStringUtils.generateUuid());
this.save(MgRnrTagPO);
bean.setUuid(MgRnrTagPO.getUuid());
return bean;
}
/**
* 修改数据
*
* @param bean 实例对象
* @return 实例对象
*/
@Override
@Transactional
public MgRnrTagDTO update(MgRnrTagDTO bean) {
MgRnrTagPO MgRnrTagPO = this.getPoByUuid(bean.getUuid());
if(MgRnrTagPO == null){
return null;
}
MgRnrTagPO tmpBean = MgRnrTagConverter.INSTANCE.dtoToPo(bean);
tmpBean.setId(MgRnrTagPO.getId());
this.updateById(tmpBean);
return bean;
}
/**
* 通过主键删除数据
* @param bean 实例对象
* @return 是否成功
*/
@Override
@Transactional
public boolean deleteById(MgRnrTagDTO bean) {
MgRnrTagPO MgRnrTagPO = this.getPoByUuid(bean.getUuid());
if (MgRnrTagPO == null) {
return false;
}
MgRnrTagPO tmpBean = new MgRnrTagPO();
tmpBean.setId(MgRnrTagPO.getId());
tmpBean.setIsDelete(CommonDeleteEnum.DELETED.getCode());
return this.updateById(tmpBean);
}
@Override
public Integer addRnrTagBatch(List<MgRnrTagPO> beanList) {
return baseMapper.addRnrTagBatch(beanList);
}
@Override
public Integer addRnrTagFromRnrInfo(MgRnrInfoDTO info, List<MgRnrTagDTO> beanList) {
MgRnrTagPO tagPO;
List<MgRnrTagPO> tagPOList = new ArrayList<>();
for (MgRnrTagDTO tagDTO : beanList) {
tagDTO.setUuid(CuscStringUtils.generateUuid());
tagDTO.setRnrId(info.getUuid());
tagDTO.setTenantNo(info.getTenantNo());
tagDTO.setRoutingKey(info.getRoutingKey());
tagPO = MgRnrTagConverter.INSTANCE.dtoToPo(tagDTO);
tagPOList.add(tagPO);
}
return addRnrTagBatch(tagPOList);
}
//-----------私有方法区--------------
/**
* 通过UUID查询单条数据
*
* @param uuid
* @return 实例对象
*/
private MgRnrTagPO getPoByUuid(String uuid) {
QueryWrapper queryWrapper = new QueryWrapper();
queryWrapper.eq("uuid", uuid);
queryWrapper.eq("is_delete", CommonDeleteEnum.NORMAL.getCode());
return this.getOne(queryWrapper);
}
}
package com.cusc.nirvana.user.rnr.mg.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cusc.nirvana.common.result.PageResult;
import com.cusc.nirvana.rds.mybatis.PageHelper;
import com.cusc.nirvana.user.rnr.mg.constants.CommonDeleteEnum;
import com.cusc.nirvana.user.rnr.mg.converter.MgRnrTaskConverter;
import com.cusc.nirvana.user.rnr.mg.dao.entity.MgRnrTaskPO;
import com.cusc.nirvana.user.rnr.mg.dao.mapper.MgRnrTaskDao;
import com.cusc.nirvana.user.rnr.mg.dto.MgRnrTaskDTO;
import com.cusc.nirvana.user.rnr.mg.service.IMgRnrTaskService;
import com.cusc.nirvana.user.util.CuscStringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
/**
* (MgRnrTask)表服务实现类
*
* @author makejava
* @since 2022-09-24 11:26:04
*/
@Service
public class MgRnrTaskServiceImpl extends ServiceImpl<MgRnrTaskDao, MgRnrTaskPO> implements IMgRnrTaskService {
/**
* 通过UUID查询单条数据
*
* @param bean
* @return 实例对象
*/
@Override
public MgRnrTaskDTO getByUuid(MgRnrTaskDTO bean) {
MgRnrTaskPO record = this.getPoByUuid(bean.getUuid());
return MgRnrTaskConverter.INSTANCE.poToDto(record);
}
/**
* 通过查询条件查询集合数据
*
* @param bean
* @return 集合对象
*/
@Override
public List<MgRnrTaskDTO> queryByList(MgRnrTaskDTO bean) {
QueryWrapper queryWrapper = new QueryWrapper();
queryWrapper.eq("is_delete", CommonDeleteEnum.NORMAL.getCode());
queryWrapper.orderByDesc("create_time");
List<MgRnrTaskPO> record = this.list(queryWrapper);
return MgRnrTaskConverter.INSTANCE.poListToDtoList(record);
}
/**
* 分页查询
*
* @param bean 筛选条件
* @return 查询结果
*/
@Override
public PageResult<MgRnrTaskDTO> queryByPage(MgRnrTaskDTO bean) {
QueryWrapper queryWrapper = new QueryWrapper();
queryWrapper.orderByDesc("create_time");
queryWrapper.eq("is_delete", CommonDeleteEnum.NORMAL.getCode());
Page<MgRnrTaskPO> page =
this.page(new Page<>(bean.getCurrPage(), bean.getPageSize()), queryWrapper);
return PageHelper.convert(page, MgRnrTaskDTO.class);
}
/**
* 新增数据
*
* @param bean 实例对象
* @return 实例对象
*/
@Override
@Transactional
public MgRnrTaskDTO insert(MgRnrTaskDTO bean) {
MgRnrTaskPO mgRnrTaskPO = MgRnrTaskConverter.INSTANCE.dtoToPo(bean);
mgRnrTaskPO.setUuid(CuscStringUtils.generateUuid());
this.save(mgRnrTaskPO);
bean.setUuid(mgRnrTaskPO.getUuid());
return bean;
}
/**
* 修改数据
*
* @param bean 实例对象
* @return 实例对象
*/
@Override
@Transactional
public MgRnrTaskDTO update(MgRnrTaskDTO bean) {
MgRnrTaskPO mgRnrTaskPO = this.getPoByUuid(bean.getUuid());
if(mgRnrTaskPO == null){
return null;
}
MgRnrTaskPO tmpBean = MgRnrTaskConverter.INSTANCE.dtoToPo(bean);
tmpBean.setId(mgRnrTaskPO.getId());
this.updateById(tmpBean);
return bean;
}
/**
* 通过主键删除数据
* @param bean 实例对象
* @return 是否成功
*/
@Override
@Transactional
public boolean deleteById(MgRnrTaskDTO bean) {
MgRnrTaskPO mgRnrTaskPO = this.getPoByUuid(bean.getUuid());
if (mgRnrTaskPO == null) {
return false;
}
MgRnrTaskPO tmpBean = new MgRnrTaskPO();
tmpBean.setId(mgRnrTaskPO.getId());
tmpBean.setIsDelete(CommonDeleteEnum.DELETED.getCode());
return this.updateById(tmpBean);
}
/**
* 通过UUID查询单条数据
*
* @param uuid
* @return 实例对象
*/
private MgRnrTaskPO getPoByUuid(String uuid) {
QueryWrapper queryWrapper = new QueryWrapper();
queryWrapper.eq("uuid", uuid);
queryWrapper.eq("is_delete", CommonDeleteEnum.NORMAL.getCode());
return this.getOne(queryWrapper);
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment