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

初始化代码

parent 00477413
Pipeline #3106 failed with stages
in 0 seconds
package com.cusc.nirvana.user.rnr.customer.service;
import com.cusc.nirvana.user.eiam.dto.UserDTO;
/**
* @author: jk
* @date: 2022/6/8 9:28
* @version: 1.0
*/
public interface IUserService {
/**
* 获取用户的组织id
* @param userId 用户id
* @return
*/
String getOrganId(String userId,String tenantNo);
/**
* 添加用户
* @param userId 用户id
* @param organId 组织id
* @param roleCode 角色code
*/
void addUserRelationRole(String userId, String organId, String roleCode);
/**
* 获取角色id
* @param roleCode
* @return
*/
String getRoleId(String roleCode);
/**
* 获取组织名称
* @param organId
* @return
*/
String getOrganName(String organId,String tenantNo);
/**
* 根据号码查询用户
* @param phone
* @return
*/
UserDTO queryUserInInfoByPhone(String phone);
/**
* 添加用户
* @param userDTO
* @return
*/
UserDTO addUser(UserDTO userDTO);
/**
* 修改用户角色
* @param roleId
* @param userId
*/
void updateUserRole(String roleId, String userId);
}
package com.cusc.nirvana.user.rnr.customer.service;
import com.cusc.nirvana.common.result.Response;
import com.cusc.nirvana.user.rnr.customer.dto.EMVinCardResponseDTO;
import com.cusc.nirvana.user.rnr.customer.dto.UnBindIccidDTO;
import com.cusc.nirvana.user.rnr.customer.dto.VehicleCardRnrDTO;
import com.cusc.nirvana.user.rnr.customer.dto.VinDTO;
import com.cusc.nirvana.user.rnr.fp.dto.IccidListDTO;
import com.cusc.nirvana.user.rnr.fp.dto.VerifyVinCardResponseDTO;
import com.cusc.nirvana.user.rnr.fp.dto.VinCardDTO;
import com.cusc.nirvana.user.rnr.fp.dto.VinCardInfoDTO;
import java.util.List;
/**
* 车卡服务接口
*
* @author yubo
* @since 2022-04-18 09:15
*/
public interface IVehicleCardService {
/**
* 车卡关系和卡校验
*
* @param vinCardListDTO
* @return
*/
Response<VerifyVinCardResponseDTO> verifyVinCard(VinCardInfoDTO vinCardListDTO);
/**
* 批量车卡关系和卡校验
*
* @param verifyDTOs
* @return
*/
Response<VerifyVinCardResponseDTO> verifyVinCardBatch(List<VinCardDTO> verifyDTOs);
/**
* 通过vin查询未实名的iccid
* @param vinDTO
* @return
*/
Response<UnBindIccidDTO> getUnBindIccidList(VinDTO vinDTO);
/**
* 通过vin查询实名的iccid
* @param vinDTO
* @return
*/
Response<VehicleCardRnrDTO> getBindIccidList(VinDTO vinDTO);
/**
新车实名查询iccid,如果已经有实名信息,提醒走一车多卡
* @param vin
* @return
*/
Response<IccidListDTO> getNewCarUnBindIccidList(String vin);
}
package com.cusc.nirvana.user.rnr.customer.service;
import com.cusc.nirvana.common.result.Response;
/**
* @className: ValidationService
* @author: jk
* @date: 2022/7/22 9:49
* @version: 1.0
**/
public interface ValidationService {
Response checkEffectiveTime();
}
package com.cusc.nirvana.user.rnr.customer.service.impl;
import com.cusc.nirvana.common.result.Response;
import com.cusc.nirvana.user.rnr.customer.constants.CompanyTypeEnum;
import com.cusc.nirvana.user.rnr.customer.constants.IndustryTypeEnum;
import com.cusc.nirvana.user.rnr.customer.dto.DicDTO;
import com.cusc.nirvana.user.rnr.customer.service.IBaseConfigService;
import com.cusc.nirvana.user.rnr.fp.constants.LivenessActionSeqEnum;
import com.cusc.nirvana.user.rnr.fp.constants.LivenessTypeEnum;
import com.cusc.nirvana.user.rnr.mg.constants.CertTypeEnum;
import org.springframework.stereotype.Service;
import java.util.*;
@Service
public class BaseConfigServiceImpl implements IBaseConfigService {
private static final Set<String> PERSON_CERTTYPE_CODE_SET = new HashSet<String>();
private static final Set<String> COMPANY_CERTTYPE_CODE_SET = new HashSet<>();
static {
PERSON_CERTTYPE_CODE_SET.add(CertTypeEnum.IDCARD.getCode());
PERSON_CERTTYPE_CODE_SET.add(CertTypeEnum.HKIDCARD.getCode());
PERSON_CERTTYPE_CODE_SET.add(CertTypeEnum.PASSPORT.getCode());
PERSON_CERTTYPE_CODE_SET.add(CertTypeEnum.PLA.getCode());
PERSON_CERTTYPE_CODE_SET.add(CertTypeEnum.POLICEPAPER.getCode());
PERSON_CERTTYPE_CODE_SET.add(CertTypeEnum.TAIBAOZHENG.getCode());
PERSON_CERTTYPE_CODE_SET.add(CertTypeEnum.HKRESIDENCECARD.getCode());
PERSON_CERTTYPE_CODE_SET.add(CertTypeEnum.TWRESIDENCECARD.getCode());
//PERSON_CERTTYPE_CODE_SET.add(CertTypeEnum.SOCIAL_ORG_LEGAL_PERSON_CERT.getCode());
PERSON_CERTTYPE_CODE_SET.add(CertTypeEnum.RESIDENCE.getCode());
PERSON_CERTTYPE_CODE_SET.add(CertTypeEnum.OTHER.getCode());
COMPANY_CERTTYPE_CODE_SET.add(CertTypeEnum.UNITCREDITCODE.getCode());
COMPANY_CERTTYPE_CODE_SET.add(CertTypeEnum.BUSINESS_LICENSE_NO.getCode());
}
@Override
public Response getDicData(String tenantNo) {
Map<String, Object> dicMap = new HashMap<>();
dicMap.put("certType", wrapPersonCertTypeDicList());
dicMap.put("companyCertType", wrapCompanyCertTypeDicList());
dicMap.put("companyType", wrapCompanyTypeDicList());
dicMap.put("industryType", wrapIndustryTypeDicList());
dicMap.put("livenessType", wrapLivenessTypeDicList());
dicMap.put("livenessActionSeq", wrapLivenessActionSeqDicList());
return Response.createSuccess(dicMap);
}
private Object wrapLivenessActionSeqDicList() {
List<DicDTO> list = new ArrayList<>();
for (LivenessActionSeqEnum item : LivenessActionSeqEnum.values()) {
DicDTO dicItem = new DicDTO();
dicItem.setLabel(item.getName());
dicItem.setValue(item.getCode());
list.add(dicItem);
}
return list;
}
private Object wrapLivenessTypeDicList() {
List<DicDTO> list = new ArrayList<>();
for (LivenessTypeEnum item : LivenessTypeEnum.values()) {
DicDTO dicItem = new DicDTO();
dicItem.setLabel(item.getName());
dicItem.setValue(item.getCode());
list.add(dicItem);
}
return list;
}
private List<DicDTO> wrapIndustryTypeDicList() {
List<DicDTO> list = new ArrayList<>();
for (IndustryTypeEnum item : IndustryTypeEnum.values()) {
DicDTO dicItem = new DicDTO();
dicItem.setLabel(item.getValue());
dicItem.setValue(item.getCode() + "");
list.add(dicItem);
}
return list;
}
private List<DicDTO> wrapCompanyCertTypeDicList() {
List<DicDTO> list = new ArrayList<>();
for (CertTypeEnum item : CertTypeEnum.values()) {
DicDTO dicItem = new DicDTO();
if (COMPANY_CERTTYPE_CODE_SET.contains(item.getCode())) {
dicItem.setLabel(item.getName());
dicItem.setValue(item.getCode());
list.add(dicItem);
}
}
return list;
}
private List<DicDTO> wrapCompanyTypeDicList() {
List<DicDTO> list = new ArrayList<>();
for (CompanyTypeEnum item : CompanyTypeEnum.values()) {
DicDTO dicItem = new DicDTO();
dicItem.setLabel(item.getValue());
dicItem.setValue(item.getCode() + "");
list.add(dicItem);
}
return list;
}
private List<DicDTO> wrapPersonCertTypeDicList() {
List<DicDTO> list = new ArrayList<>();
for (CertTypeEnum item : CertTypeEnum.values()) {
DicDTO dicItem = new DicDTO();
if (PERSON_CERTTYPE_CODE_SET.contains(item.getCode())) {
dicItem.setLabel(item.getName());
dicItem.setValue(item.getCode());
list.add(dicItem);
}
}
return list;
}
}
package com.cusc.nirvana.user.rnr.customer.service.impl;
import com.alibaba.fastjson.JSON;
import com.cusc.nirvana.common.result.Response;
import com.cusc.nirvana.user.rnr.customer.dto.FileDownloadDTO;
import com.cusc.nirvana.user.rnr.customer.service.IFileService;
import com.cusc.nirvana.user.rnr.fp.client.FileSystemClient;
import com.cusc.nirvana.user.rnr.fp.dto.FileRecordDTO;
import com.cusc.nirvana.user.rnr.fp.dto.FileUploadDTO;
import com.cusc.nirvana.user.rnr.fp.dto.ImageBase64DTO;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.FileUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import sun.misc.BASE64Decoder;
import javax.annotation.Resource;
import java.io.*;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
/**
* 文件上传服务类
*
* @author huzl
* @date 2022/04/18
*/
@Slf4j
@Service
public class FileServiceImpl implements IFileService {
//文件后缀常量
private static final List<String> FILE_SUFFIX_LIST =
Arrays.asList("jpg","jpeg", "png", "gif", "bmp", "pdf", "mp4", "avi", "wav",
"rm","xls","xlsx","doc","docx");
// @Value("${rnr.fileSystem}")
// private String fileServiceSrv;
// @Value("${rnr.fileSelect}")
// private String fileSelect;
@Resource
private FileSystemClient fileSystemClient;
//@Resource
//private RestTemplate nonLoadBalancedFile;
@Override
public Response<FileRecordDTO> upload(FileUploadDTO fileUploadDTO) {
// String url = fileServiceSrv + "/file/upload/" + fileUploadDTO.getType();
//
// final HttpHeaders headers = new HttpHeaders();
// headers.setContentType(MediaType.MULTIPART_FORM_DATA);
// if (StringUtils.isNotBlank(fileUploadDTO.getRootPath())) {
// headers.set("rootPath", fileUploadDTO.getRootPath());
// } else {
// headers.set("rootPath", "rnr/");
// }
//
// MultiValueMap<String, Object> parameters = new LinkedMultiValueMap<>();
// if (StringUtils.isNotBlank(fileUploadDTO.getPath())) {
// parameters.add("path", fileUploadDTO.getPath());
// }
// if (StringUtils.isNotBlank(fileUploadDTO.getUuid())) {
// parameters.add("uuid", fileUploadDTO.getUuid());
// }
//
// ByteArrayResource resource = null;
// try {
// resource = new ByteArrayResource(fileUploadDTO.getFile().getBytes()) {
// @Override
// public String getFilename() {
// return fileUploadDTO.getFile().getOriginalFilename();
// }
// };
// } catch (IOException e) {
// throw new AppGlobalException("读取文件流错误", e);
// }
//
// parameters.add("file", resource);
//
// final HttpEntity<MultiValueMap<String, Object>> httpEntity = new HttpEntity<>(parameters, headers);
// final ResponseEntity<String> entity = nonLoadBalancedFile.exchange(url, HttpMethod.POST, httpEntity, String
// .class);
// log.info("FileUpload, url:{},parameter:{},header:{},response:{}", url, fileUploadDTO, headers,
// entity.toString());
// Response<FileRecordDTO> response = JSONObject.parseObject(entity.getBody(),
// new TypeReference<Response<FileRecordDTO>>(new Type[] {FileRecordDTO.class}) {
// }.getType());
return fileSystemClient.uploadImage(fileUploadDTO);
}
/**
* 文件上传-重新写
*
* @param fileUploadDTO
* @return
*/
@Override
public Response<FileRecordDTO> uploadTwo(FileUploadDTO fileUploadDTO) {
Response<FileRecordDTO> response = null;
try {
String originalFilename = fileUploadDTO.getFile().getOriginalFilename();
//检查文件后缀
Response fileSuffixResp = chechFileSuffix(originalFilename);
if(!fileSuffixResp.isSuccess()){
return fileSuffixResp;
}
//保存文件防止文件名重复。
// String saveFileName = CuscStringUtils.generateUuid()
// + originalFilename.substring(originalFilename.lastIndexOf("."));
//
// String path = "";
// Object objectWriteResponse = null;
response = fileSystemClient.uploadFile(fileUploadDTO);
log.info("FileUpload response:{}", JSON.toJSON(response));
// FileRecordDTO fileRecord =response.getData();
// FileRecordDTO fileRecordDTO = new FileRecordDTO();
// fileRecordDTO.setFileName(fileRecord.getFileName());
// fileRecordDTO.setPath(fileRecord.getPath());
// fileRecordDTO.setUuid(fileRecord.getUuid());
// fileRecordDTO.setAccessUrl(fileRecord.getAccessUrl());
// response = Response.createSuccess(fileRecordDTO);
} catch (Exception e) {
log.error("----upload-Exception---", e);
}
return response;
}
/**
* 下载文件
*
* @param downloadDTO
* @return
*/
@Override
public InputStream download(FileDownloadDTO downloadDTO) {
byte[] result = downloadToByteArray(downloadDTO);
return new ByteArrayInputStream(result);
}
/**
* 下载文件
*
* @param downloadDTO
* @return
*/
@Override
public byte[] downloadToByteArray(FileDownloadDTO downloadDTO) {
// String url = fileServiceSrv + "/file/download/" + downloadDTO.getUuid();
// log.debug("url: " + url);
//
// log.info("下载文件-开始");
// final ResponseEntity<byte[]> response = nonLoadBalancedFile.getForEntity(url, byte[].class);
// ContentDisposition contentDisposition = response.getHeaders().getContentDisposition();
// log.info("下载文件-结束");
// try {
// if (contentDisposition != null && CuscStringUtils.isNotEmpty(contentDisposition.getFilename())) {
// downloadDTO.setFileName(URLDecoder.decode(contentDisposition.getFilename(), "utf-8"));
// }
// } catch (UnsupportedEncodingException e) {
// log.warn("fileName decode error", e);
// }
// byte[] result = response.getBody();
com.cusc.nirvana.user.rnr.fp.dto.FileDownloadDTO fileDownloadDTO =
new com.cusc.nirvana.user.rnr.fp.dto.FileDownloadDTO();
BeanUtils.copyProperties(downloadDTO, fileDownloadDTO);
Response<ImageBase64DTO> response = fileSystemClient.getBase64(fileDownloadDTO);
ImageBase64DTO imageBase64DTO = response.getData();
byte[] result = null;
try {
result = new BASE64Decoder().decodeBuffer(imageBase64DTO.getBase64());
} catch (IOException e) {
log.warn("fileName decode error", e);
}
return result;
}
// @Override
// public File downloadToLocal(FileDownloadDTO downloadDTO) throws Exception {
// String url = fileServiceSrv + "/file/download/" + downloadDTO.getUuid();
// String localFileName = "";
// if (StringUtils.isNotEmpty(downloadDTO.getFileName())) {
// localFileName = downloadDTO.getFileName();
// }
// String targetPath = generateTmpPath(localFileName);
// //定义请求头的接收类型
// AtomicBoolean isError = new AtomicBoolean(false);
// MultiValueMap<String, String> headers = new HttpHeaders();
// headers.add("Accept", MediaType.toString(Arrays.asList(MediaType.APPLICATION_OCTET_STREAM, MediaType.ALL)));
// final HttpEntity<MultiValueMap<String, Object>> httpEntity = new HttpEntity(null, headers);
// RequestCallback requestCallback = nonLoadBalancedFile.httpEntityCallback(httpEntity);
// //对响应进行流式处理而不是将其全部加载到内存中
// nonLoadBalancedFile.execute(url, HttpMethod.GET, requestCallback, clientHttpResponse -> {
// HttpStatus statusCode = clientHttpResponse.getStatusCode();
// if (statusCode != HttpStatus.OK) {
// isError.set(true);
// } else {
// Files.copy(clientHttpResponse.getBody(), Paths.get(targetPath));
// }
// return null;
// });
// if (isError.get()) {
// throw new Exception("文件下载失败");
// }
// return new File(targetPath);
// }
private String generateTmpPath(String fileName) {
SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd");
Date date = new Date();
String path = format.format(date);
StringBuilder targetPath = new StringBuilder();
int index = fileName.lastIndexOf(".");
String name = index == -1 ? fileName : fileName.substring(0, index);
String ext = index == -1 ? "" : fileName.substring(index);
String tmpPath = FileUtils.getTempDirectoryPath();
targetPath.append(tmpPath).append((tmpPath.endsWith(File.separator) ? "" : File.separator)).append(path)
.append(File.separator);
File filePath = new File(targetPath.toString());
if (!filePath.exists()) {
filePath.mkdirs();
}
targetPath.append(name).append("_").append(System.currentTimeMillis()).append(ext);
return targetPath.toString();
}
/**
* Description: 文件后缀检查
* <br />
* CreateDate 2022-07-09 23:56:03
*
* @author yuyi
**/
private Response chechFileSuffix(String fileName) {
int startIndex = fileName.lastIndexOf(".");
if (startIndex <= 0) {
return Response.createError("请上传规定的文件格式");
}
String suffixName = fileName.substring(startIndex+1).toLowerCase();
if (FILE_SUFFIX_LIST.contains(suffixName)) {
return Response.createSuccess();
}
return Response.createError("请上传规定的文件格式");
}
}
package com.cusc.nirvana.user.rnr.customer.service.impl;
import com.cusc.nirvana.common.result.Response;
import com.cusc.nirvana.user.auth.authentication.plug.user.UserSubjectUtil;
import com.cusc.nirvana.user.eiam.client.OrganizationClient;
import com.cusc.nirvana.user.eiam.dto.OrganizationDTO;
import com.cusc.nirvana.user.eiam.dto.UserOrganDTO;
import com.cusc.nirvana.user.exception.CuscUserException;
import com.cusc.nirvana.user.rnr.customer.config.CustomerConfig;
import com.cusc.nirvana.user.rnr.customer.constants.ResponseCode;
import com.cusc.nirvana.user.rnr.customer.dto.ProtocolManageDTO;
import com.cusc.nirvana.user.rnr.customer.dto.ProtocolManageOneDTO;
import com.cusc.nirvana.user.rnr.customer.dto.ProtocolManageUrlDTO;
import com.cusc.nirvana.user.rnr.customer.service.IProtocolManageService;
import com.cusc.nirvana.user.rnr.fp.client.FileSystemClient;
import com.cusc.nirvana.user.rnr.fp.client.FpRnrProtocolManageClient;
import com.cusc.nirvana.user.rnr.fp.dto.FileDownloadDTO;
import com.cusc.nirvana.user.rnr.fp.dto.FileRecordDTO;
import com.cusc.nirvana.user.rnr.fp.dto.FpRnrProtocolManageDTO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import javax.annotation.Resource;
import java.lang.reflect.InvocationTargetException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* @className: IProtocolManageServiceImpl
* @description: 协议管理
* @author: jk
* @date: 2022/6/10 13:39
* @version: 1.0
**/
@Service
@Slf4j
public class IProtocolManageServiceImpl implements IProtocolManageService {
@Resource
private FpRnrProtocolManageClient fpRnrProtocolManageClient;
@Resource
private FileSystemClient fileSystemClient;
@Resource
private CustomerConfig customerConfig;
@Resource
private OrganizationClient organizationClient;
@Override
public Response<List<ProtocolManageDTO>> query() {
//通过组织id出协议文件
FpRnrProtocolManageDTO fpRnrProtocolManageDTO = new FpRnrProtocolManageDTO();
fpRnrProtocolManageDTO.setTenantNo(UserSubjectUtil.getTenantNo());
fpRnrProtocolManageDTO.setType("1");
Response<List<FpRnrProtocolManageDTO>> responseList = fpRnrProtocolManageClient.queryByList(fpRnrProtocolManageDTO);
if (!responseList.isSuccess()) {
throw new CuscUserException(ResponseCode.SYS_BUSY.getCode(), ResponseCode.SYS_BUSY.getMsg());
}
List<FpRnrProtocolManageDTO> rnrProtocolManageDTOList = responseList.getData();
if (CollectionUtils.isEmpty(rnrProtocolManageDTOList)) {
return Response.createSuccess(rnrProtocolManageDTOList);
}
FpRnrProtocolManageDTO fpRnrProtocolManage = rnrProtocolManageDTOList.get(0);
ProtocolManageDTO protocolManageDTO = new ProtocolManageDTO();
String orgId = fpRnrProtocolManage.getOrgId();
ProtocolManageOneDTO protocolManageOneDTO = new ProtocolManageOneDTO();
BeanUtils.copyProperties(fpRnrProtocolManage, protocolManageOneDTO);
//将对象属性转为map
Map<String, String> map = convertToMap(protocolManageOneDTO);
Map<String, Object> mapReturn = new HashMap<>();
//并行调用查询文件路径
map.entrySet().stream().map(entry -> {
if(!StringUtils.isEmpty(entry.getValue())) {
FileDownloadDTO fileRecordDTO = new FileDownloadDTO();
fileRecordDTO.setUuid(entry.getValue());
Response<FileRecordDTO> fileRecordDTOResponse = fileSystemClient.getUrl(fileRecordDTO);
if (!fileRecordDTOResponse.isSuccess()) {
throw new CuscUserException(ResponseCode.SYS_BUSY.getCode(), ResponseCode.SYS_BUSY.getMsg());
}
ProtocolManageUrlDTO protocolManageUrlDTO = new ProtocolManageUrlDTO();
protocolManageUrlDTO.setFileUrl(fileRecordDTOResponse.getData().getAccessUrl());
// protocolManageUrlDTO.setFileName(fileRecordDTOResponse.getData().getFileName());
protocolManageUrlDTO.setUuid(fileRecordDTOResponse.getData().getUuid());
mapReturn.put(entry.getKey(), protocolManageUrlDTO);
}else {
mapReturn.put(entry.getKey(), "");
}
return mapReturn;
//将路径塞进map对应的key中
// entry.setValue(fileRecordDTOResponse.getData().getPath());
}).collect(Collectors.toList());
mapReturn.put("id", fpRnrProtocolManage.getId());
mapReturn.put("uuid", fpRnrProtocolManage.getUuid());
mapReturn.put("orgId", fpRnrProtocolManage.getOrgId());
//通过反射将map key对应value塞进对应bean属性中
// Object obj= toBean(map1,ProtocolManageDTO.class);
// protocolManageDTO = (ProtocolManageDTO)obj;
// protocolManageDTO.setOrgId(orgId);
return Response.createSuccess(mapReturn);
}
@Override
public Response<List<ProtocolManageDTO>> noLogin() {
OrganizationDTO organizationDTO = new OrganizationDTO();
organizationDTO.setTenantNo(customerConfig.getTenantNo());
organizationDTO.setParentId("0");
organizationDTO.setBizType(1);
Response<List<OrganizationDTO>> re = organizationClient.queryByList(organizationDTO);
if(!re.isSuccess()){
throw new CuscUserException("","获取组织信息失败");
}
//通过组织id出协议文件
FpRnrProtocolManageDTO fpRnrProtocolManageDTO = new FpRnrProtocolManageDTO();
fpRnrProtocolManageDTO.setTenantNo(customerConfig.getTenantNo());
fpRnrProtocolManageDTO.setType("1");
Response<List<FpRnrProtocolManageDTO>> responseList = fpRnrProtocolManageClient.queryByList(fpRnrProtocolManageDTO);
if (!responseList.isSuccess()) {
throw new CuscUserException(ResponseCode.SYS_BUSY.getCode(), ResponseCode.SYS_BUSY.getMsg());
}
List<FpRnrProtocolManageDTO> rnrProtocolManageDTOList = responseList.getData();
if (CollectionUtils.isEmpty(rnrProtocolManageDTOList)) {
return Response.createSuccess(rnrProtocolManageDTOList);
}
FpRnrProtocolManageDTO fpRnrProtocolManage = rnrProtocolManageDTOList.get(0);
ProtocolManageDTO protocolManageDTO = new ProtocolManageDTO();
String orgId = fpRnrProtocolManage.getOrgId();
ProtocolManageOneDTO protocolManageOneDTO = new ProtocolManageOneDTO();
BeanUtils.copyProperties(fpRnrProtocolManage, protocolManageOneDTO);
//将对象属性转为map
Map<String, String> map = convertToMap(protocolManageOneDTO);
Map<String, Object> mapReturn = new HashMap<>();
//并行调用查询文件路径
map.entrySet().stream().map(entry -> {
if(!StringUtils.isEmpty(entry.getValue())) {
FileDownloadDTO fileRecordDTO = new FileDownloadDTO();
fileRecordDTO.setUuid(entry.getValue());
Response<FileRecordDTO> fileRecordDTOResponse = fileSystemClient.getUrl(fileRecordDTO);
if (!fileRecordDTOResponse.isSuccess()) {
throw new CuscUserException(ResponseCode.SYS_BUSY.getCode(), ResponseCode.SYS_BUSY.getMsg());
}
ProtocolManageUrlDTO protocolManageUrlDTO = new ProtocolManageUrlDTO();
protocolManageUrlDTO.setFileUrl(fileRecordDTOResponse.getData().getAccessUrl());
// protocolManageUrlDTO.setFileName(fileRecordDTOResponse.getData().getFileName());
protocolManageUrlDTO.setUuid(fileRecordDTOResponse.getData().getUuid());
if (StringUtils.isEmpty(UserSubjectUtil.getUserId()) && ("logoPc".equals(entry.getKey()) || "logoH5".equals(entry.getKey()))) {
mapReturn.put(entry.getKey(), protocolManageUrlDTO);
}
}else {
mapReturn.put(entry.getKey(), "");
}
return mapReturn;
//将路径塞进map对应的key中
// entry.setValue(fileRecordDTOResponse.getData().getPath());
}).collect(Collectors.toList());
mapReturn.put("id", fpRnrProtocolManage.getId());
mapReturn.put("uuid", fpRnrProtocolManage.getUuid());
mapReturn.put("orgId", fpRnrProtocolManage.getOrgId());
mapReturn.put("organName",re.getData().get(0).getOrganName());
//通过反射将map key对应value塞进对应bean属性中
// Object obj= toBean(map1,ProtocolManageDTO.class);
// protocolManageDTO = (ProtocolManageDTO)obj;
// protocolManageDTO.setOrgId(orgId);
return Response.createSuccess(mapReturn);
}
//将java对象转为map为了方便调用文件查询接口
public static Map<String, String> convertToMap(Object obj) {
try {
if (obj instanceof Map) {
return (Map)obj;
}
Map<String, String> returnMap = org.apache.commons.beanutils.BeanUtils.describe(obj);
returnMap.remove("class");
return returnMap;
} catch (IllegalAccessException e1) {
e1.getMessage();
} catch (InvocationTargetException e2) {
e2.getMessage();
} catch (NoSuchMethodException e3) {
e3.getMessage();
}
return new HashMap();
}
}
package com.cusc.nirvana.user.rnr.customer.service.impl;
import com.cusc.nirvana.common.result.Response;
import com.cusc.nirvana.user.exception.CuscUserException;
import com.cusc.nirvana.user.rnr.customer.service.INewVinCardService;
import com.cusc.nirvana.user.rnr.fp.client.NewVinCardClient;
import com.cusc.nirvana.user.rnr.fp.client.SimVehicleRelClient;
import com.cusc.nirvana.user.rnr.fp.common.ResponseCode;
import com.cusc.nirvana.user.rnr.fp.dto.*;
import com.cusc.nirvana.user.rnr.mg.client.MgRnrCardInfoClient;
import com.cusc.nirvana.user.rnr.mg.dto.MgRnrCardInfoDTO;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
/**
* @author stayAnd
* @date 2022/5/18
*/
@Service
public class NewVinCardServiceImpl implements INewVinCardService {
@Resource
private NewVinCardClient newVinCardClient;
@Resource
private SimVehicleRelClient simVehicleRelClient;
@Resource
private MgRnrCardInfoClient cardInfoClient;
@Override
public Response<VinCardResultDTO> queryUnBindCardByVin(VinCardQueryDTO queryDTO) {
MgRnrCardInfoDTO mgRnrCardInfoDTO = new MgRnrCardInfoDTO();
List<String> list = new ArrayList<>();
list.add(queryDTO.getVin());
mgRnrCardInfoDTO.setVinList(list);
Response<List<MgRnrCardInfoDTO>> mgRnrCardInfo = cardInfoClient.queryBindListByVin(mgRnrCardInfoDTO);
if(!mgRnrCardInfo.isSuccess()){
throw new CuscUserException(mgRnrCardInfo.getCode(),mgRnrCardInfo.getMsg());
}
for(MgRnrCardInfoDTO mgRnrCardInfos: mgRnrCardInfo.getData()){
if(mgRnrCardInfos.getRnrStatus()==0){
return Response.createError("该车实名审核中");
}else {
return Response.createError("该车已实名");
}
}
return newVinCardClient.queryUnBindCardByVin(queryDTO);
}
@Override
public VinCardCheckResultDTO checkVinCard(VinCardCheckDTO vinCardCheckDTO) {
//paramCheck(vinCardCheckDTO);
if (!CollectionUtils.isEmpty(vinCardCheckDTO.getIccidList()) && vinCardCheckDTO.getIccidList().stream().distinct().count() != vinCardCheckDTO.getIccidList().size()) {
throw new CuscUserException(ResponseCode.SYSTEM_ERROR.getCode(),"请不要输入同样的iccid");
}
//todo 是否允许补录
//查询是否允许补录
IccidListDTO mgRnrCardInfoDTO = new IccidListDTO();
mgRnrCardInfoDTO.setIccidList(vinCardCheckDTO.getIccidList());
Response<List<IccidDetailDTO>> iccids = simVehicleRelClient.queryByIccids(mgRnrCardInfoDTO);
if (!iccids.isSuccess()) {
throw new CuscUserException(iccids.getCode(), iccids.getMsg());
}
for(IccidDetailDTO iccidDetailDTO:iccids.getData()){
if (!iccidDetailDTO.getRealBySelf()) {
throw new CuscUserException("", desensitization(iccidDetailDTO.getIccid())+"不可以补录");
}
}
Response<VinCardCheckResultDTO> checkResponse = newVinCardClient.checkVinCard(vinCardCheckDTO);
if (!checkResponse.isSuccess()) {
throw new CuscUserException(checkResponse.getCode(),checkResponse.getMsg());
}
return checkResponse.getData();
}
@Override
public VinCheckResultDTO checkVin(VinCheckRequestDTO requestDTO) {
if (requestDTO.getVinList().stream().distinct().count() != requestDTO.getVinList().size()) {
throw new CuscUserException(ResponseCode.SYSTEM_ERROR.getCode(),"请不要输入同样的iccid");
}
Response<VinCheckResultDTO> response = newVinCardClient.checkVin(requestDTO);
if (!response.isSuccess()) {
throw new CuscUserException(response.getCode(),response.getMsg());
}
//是否允许补录
if(null != response.getData()) {
for (VinCheckResultDTO.VinCheckDetailDTO vinCheckDetailDTO : response.getData().getCheckList()) {
Response<List<VinIccidDTO>> iccids = simVehicleRelClient.getIccidByVin(vinCheckDetailDTO.getVin());
if (!iccids.isSuccess()) {
throw new CuscUserException(iccids.getCode(), iccids.getMsg());
}
String msg = "";
for (VinIccidDTO vinIccidDTO : iccids.getData()) {
if (!vinIccidDTO.getRealBySelf()) {
msg = msg.concat("当前VIN下iccid为" + desensitization(vinIccidDTO.getIccid()) + "不可以补录;");
}
}
if (!StringUtils.isEmpty(msg)) {
vinCheckDetailDTO.setErrorMsg(msg);
vinCheckDetailDTO.setCheckResult(false);
}
}
}
return response.getData();
}
private String desensitization(String parameter){
String reposen =parameter.substring(0,4)+"***"+parameter.substring(parameter.length()-4,parameter.length());
return reposen;
}
}
package com.cusc.nirvana.user.rnr.customer.service.impl;
import com.cusc.nirvana.common.result.Response;
import com.cusc.nirvana.user.auth.authentication.plug.user.UserSubjectUtil;
import com.cusc.nirvana.user.exception.CuscUserException;
import com.cusc.nirvana.user.rnr.customer.service.ISmsService;
import com.cusc.nirvana.user.rnr.customer.util.ValidationUtil;
import com.cusc.nirvana.user.rnr.fp.client.SmsClient;
import com.cusc.nirvana.user.rnr.fp.common.ResponseCode;
import com.cusc.nirvana.user.rnr.fp.dto.SmsRequestDTO;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* Description: 短信service
* <br />
* CreateDate 2022-04-16 15:11:41
*
* @author yuyi
**/
@Service
@Slf4j
public class SmsServiceImpl implements ISmsService {
@Autowired
SmsClient smsClient;
@Override
public Response sendSmsRnr(SmsRequestDTO bean) {
if (StringUtils.isBlank(bean.getBizType())) {
return Response.createError("业务类型不能为空", ResponseCode.INVALID_DATA);
}
if (StringUtils.isBlank(bean.getPhone())) {
return Response.createError("手机号不能为空", ResponseCode.INVALID_DATA);
}
//检查手机
Response checkPhone = ValidationUtil.checkPhone(bean.getPhone());
if (!checkPhone.isSuccess()) {
throw new CuscUserException(checkPhone.getCode(),checkPhone.getMsg());
}
bean.setTenantNo(UserSubjectUtil.getTenantNo());
return smsClient.sendSmsCaptcha(bean);
}
@Override
public Response checkSmsCaptcha(SmsRequestDTO bean) {
if (StringUtils.isBlank(bean.getBizType())) {
return Response.createError("业务类型不能为空", ResponseCode.INVALID_DATA);
}
if (StringUtils.isBlank(bean.getPhone())) {
return Response.createError("手机号不能为空", ResponseCode.INVALID_DATA);
}
if (StringUtils.isBlank(bean.getCaptcha())) {
return Response.createError("验证码不能为空", ResponseCode.INVALID_DATA);
}
bean.setTenantNo(UserSubjectUtil.getTenantNo());
return smsClient.checkSmsCaptcha(bean);
}
}
This diff is collapsed.
spring:
application:
name: local-rnr-customer
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