可信空间连接器入住接口
Showing
4 changed files
with
160 additions
and
20 deletions
| ... | @@ -3,6 +3,7 @@ package com.csbr.qingcloud.portal.domain.vo; | ... | @@ -3,6 +3,7 @@ package com.csbr.qingcloud.portal.domain.vo; |
| 3 | import com.csbr.cloud.workflow.domain.vo.appove.FlowRQBaseVO; | 3 | import com.csbr.cloud.workflow.domain.vo.appove.FlowRQBaseVO; |
| 4 | import com.fasterxml.jackson.annotation.JsonFormat; | 4 | import com.fasterxml.jackson.annotation.JsonFormat; |
| 5 | import io.swagger.v3.oas.annotations.media.Schema; | 5 | import io.swagger.v3.oas.annotations.media.Schema; |
| 6 | import jakarta.validation.constraints.NotBlank; | ||
| 6 | import lombok.Data; | 7 | import lombok.Data; |
| 7 | 8 | ||
| 8 | import java.math.BigDecimal; | 9 | import java.math.BigDecimal; |
| ... | @@ -121,12 +122,14 @@ public class EnterpriseRQVO extends FlowRQBaseVO { | ... | @@ -121,12 +122,14 @@ public class EnterpriseRQVO extends FlowRQBaseVO { |
| 121 | * 法人证件类型 | 122 | * 法人证件类型 |
| 122 | */ | 123 | */ |
| 123 | @Schema(description = "法人证件类型") | 124 | @Schema(description = "法人证件类型") |
| 125 | @NotBlank(message = "法人证件类型不能为空。") | ||
| 124 | private String juridicalPersonIdType; | 126 | private String juridicalPersonIdType; |
| 125 | 127 | ||
| 126 | /** | 128 | /** |
| 127 | * 法人证件号 | 129 | * 法人证件号 |
| 128 | */ | 130 | */ |
| 129 | @Schema(description = "法人证件号") | 131 | @Schema(description = "法人证件号") |
| 132 | @NotBlank(message = "法人证件号不能为空。") | ||
| 130 | private String juridicalPersonId; | 133 | private String juridicalPersonId; |
| 131 | 134 | ||
| 132 | /** | 135 | /** |
| ... | @@ -154,9 +157,10 @@ public class EnterpriseRQVO extends FlowRQBaseVO { | ... | @@ -154,9 +157,10 @@ public class EnterpriseRQVO extends FlowRQBaseVO { |
| 154 | private String contactTel; | 157 | private String contactTel; |
| 155 | 158 | ||
| 156 | /** | 159 | /** |
| 157 | * 管理员证件号 | 160 | * 经办人证件号 |
| 158 | */ | 161 | */ |
| 159 | @Schema(description = "管理员证件号") | 162 | @Schema(description = "经办人证件号") |
| 163 | @NotBlank(message = "经办人证件号不能为空。") | ||
| 160 | private String managerPersonId; | 164 | private String managerPersonId; |
| 161 | 165 | ||
| 162 | /** | 166 | /** |
| ... | @@ -196,6 +200,7 @@ public class EnterpriseRQVO extends FlowRQBaseVO { | ... | @@ -196,6 +200,7 @@ public class EnterpriseRQVO extends FlowRQBaseVO { |
| 196 | private String identityState = "N"; | 200 | private String identityState = "N"; |
| 197 | 201 | ||
| 198 | @Schema(description = "经办人证件类型") | 202 | @Schema(description = "经办人证件类型") |
| 203 | @NotBlank(message = "经办人证件类型不能为空。") | ||
| 199 | private String handlePersonIdType; | 204 | private String handlePersonIdType; |
| 200 | 205 | ||
| 201 | /******** 库表存储属性 需处理 *****/ | 206 | /******** 库表存储属性 需处理 *****/ | ... | ... |
| ... | @@ -73,13 +73,13 @@ public class DataPortServiceImpl implements DataPortService { | ... | @@ -73,13 +73,13 @@ public class DataPortServiceImpl implements DataPortService { |
| 73 | 73 | ||
| 74 | @Override | 74 | @Override |
| 75 | public void operatorRegister(MfEnterprise entity) { | 75 | public void operatorRegister(MfEnterprise entity) { |
| 76 | log.info("======经办人用户注册开始======"); | 76 | // log.info("======经办人用户注册开始======"); |
| 77 | OperatorRegisterRQVO operatorRegisterRQVO = beforeOperator(entity); | 77 | // OperatorRegisterRQVO operatorRegisterRQVO = beforeOperator(entity); |
| 78 | String message = dataPortConnectUtil.postByAuthKey(operatorRegisterRQVO, dataPortConfig.getOperatorRegisterUri()); | 78 | // String message = dataPortConnectUtil.postByAuthKey(operatorRegisterRQVO, dataPortConfig.getOperatorRegisterUri()); |
| 79 | if (StringUtils.isNotEmpty(message) && !message.contains("经办人账号身份标识已存在,无法注册")) { | 79 | // if (StringUtils.isNotEmpty(message) && !message.contains("经办人账号身份标识已存在,无法注册")) { |
| 80 | throw new CsbrSystemException(SystemError.DATA_GET_ERROR, message); | 80 | // throw new CsbrSystemException(SystemError.DATA_GET_ERROR, message); |
| 81 | } | 81 | // } |
| 82 | log.info("======经办人用户注册结束======"); | 82 | // log.info("======经办人用户注册结束======"); |
| 83 | } | 83 | } |
| 84 | 84 | ||
| 85 | @Override | 85 | @Override |
| ... | @@ -93,13 +93,13 @@ public class DataPortServiceImpl implements DataPortService { | ... | @@ -93,13 +93,13 @@ public class DataPortServiceImpl implements DataPortService { |
| 93 | 93 | ||
| 94 | @Override | 94 | @Override |
| 95 | public void enterpriseRegister(MfEnterprise entity) { | 95 | public void enterpriseRegister(MfEnterprise entity) { |
| 96 | log.info("======法人用户注册开始======"); | 96 | // log.info("======法人用户注册开始======"); |
| 97 | EnterpriseRegisterRQVO enterpriseRegisterRQVO = beforeEnterprise(entity); | 97 | // EnterpriseRegisterRQVO enterpriseRegisterRQVO = beforeEnterprise(entity); |
| 98 | String message = dataPortConnectUtil.postByAuthKey(enterpriseRegisterRQVO, dataPortConfig.getEnterpriseRegisterUri()); | 98 | // String message = dataPortConnectUtil.postByAuthKey(enterpriseRegisterRQVO, dataPortConfig.getEnterpriseRegisterUri()); |
| 99 | if (StringUtils.isNotEmpty(message) && !message.contains("统一社会信用代码已存在")) { | 99 | // if (StringUtils.isNotEmpty(message) && !message.contains("统一社会信用代码已存在")) { |
| 100 | throw new CsbrSystemException(SystemError.DATA_GET_ERROR, message); | 100 | // throw new CsbrSystemException(SystemError.DATA_GET_ERROR, message); |
| 101 | } | 101 | // } |
| 102 | log.info("======法人用户注册结束======"); | 102 | // log.info("======法人用户注册结束======"); |
| 103 | } | 103 | } |
| 104 | 104 | ||
| 105 | @Override | 105 | @Override | ... | ... |
| ... | @@ -38,10 +38,7 @@ import com.csbr.qingcloud.portal.service.DataPortService; | ... | @@ -38,10 +38,7 @@ import com.csbr.qingcloud.portal.service.DataPortService; |
| 38 | import com.csbr.qingcloud.portal.service.EnterpriseAttachmentService; | 38 | import com.csbr.qingcloud.portal.service.EnterpriseAttachmentService; |
| 39 | import com.csbr.qingcloud.portal.service.EnterpriseDomainService; | 39 | import com.csbr.qingcloud.portal.service.EnterpriseDomainService; |
| 40 | import com.csbr.qingcloud.portal.service.EnterpriseService; | 40 | import com.csbr.qingcloud.portal.service.EnterpriseService; |
| 41 | import com.csbr.qingcloud.portal.util.ChangeInfoUtil; | 41 | import com.csbr.qingcloud.portal.util.*; |
| 42 | import com.csbr.qingcloud.portal.util.DateUtil; | ||
| 43 | import com.csbr.qingcloud.portal.util.InvokeUtil; | ||
| 44 | import com.csbr.qingcloud.portal.util.ZQConfig; | ||
| 45 | import csbr.cloud.entity.domain.base.vo.PageListVO; | 42 | import csbr.cloud.entity.domain.base.vo.PageListVO; |
| 46 | import csbr.cloud.entity.enums.ApprovalStateEnum; | 43 | import csbr.cloud.entity.enums.ApprovalStateEnum; |
| 47 | import io.seata.spring.annotation.GlobalTransactional; | 44 | import io.seata.spring.annotation.GlobalTransactional; |
| ... | @@ -835,6 +832,8 @@ public class EnterpriseServiceImpl extends FlowAbstractImpl implements Enterpris | ... | @@ -835,6 +832,8 @@ public class EnterpriseServiceImpl extends FlowAbstractImpl implements Enterpris |
| 835 | private void beforeSave(EnterpriseRQVO rqVO) { | 832 | private void beforeSave(EnterpriseRQVO rqVO) { |
| 836 | //region 1.输入基础验证 | 833 | //region 1.输入基础验证 |
| 837 | check(rqVO); | 834 | check(rqVO); |
| 835 | //验证证件类型证件类型 | ||
| 836 | verifyDocumentType(rqVO); | ||
| 838 | //endregion | 837 | //endregion |
| 839 | // 校验附加信息 | 838 | // 校验附加信息 |
| 840 | List<EnterpriseAttachmentRQVO> attachmentRQVOS = rqVO.getAttachmentRQVOS(); | 839 | List<EnterpriseAttachmentRQVO> attachmentRQVOS = rqVO.getAttachmentRQVOS(); |
| ... | @@ -895,6 +894,47 @@ public class EnterpriseServiceImpl extends FlowAbstractImpl implements Enterpris | ... | @@ -895,6 +894,47 @@ public class EnterpriseServiceImpl extends FlowAbstractImpl implements Enterpris |
| 895 | //endregion 5.过程处理 | 894 | //endregion 5.过程处理 |
| 896 | } | 895 | } |
| 897 | 896 | ||
| 897 | /** | ||
| 898 | * 证件类型校验 | ||
| 899 | * @param rqVO | ||
| 900 | */ | ||
| 901 | private void verifyDocumentType(EnterpriseRQVO rqVO) { | ||
| 902 | //验证法人证件 | ||
| 903 | String juridicalPersonId = rqVO.getJuridicalPersonId(); | ||
| 904 | Boolean idValid = true; | ||
| 905 | switch (rqVO.getJuridicalPersonIdType()){ | ||
| 906 | case "1": | ||
| 907 | idValid = IDValidator.idCardValid(juridicalPersonId); | ||
| 908 | break; | ||
| 909 | case "2": | ||
| 910 | idValid = IDValidator.passportValid(juridicalPersonId); | ||
| 911 | break; | ||
| 912 | case "3": | ||
| 913 | idValid = IDValidator.militaryValid(juridicalPersonId); | ||
| 914 | break; | ||
| 915 | } | ||
| 916 | if(!idValid){ | ||
| 917 | throw new CsbrSystemException(SystemError.DATA_INPUT_ERROR,"法人证件号格式不正确。"); | ||
| 918 | } | ||
| 919 | //验证经办人证件 | ||
| 920 | String managerPersonId = rqVO.getManagerPersonId(); | ||
| 921 | idValid = true; | ||
| 922 | switch (rqVO.getHandlePersonIdType()){ | ||
| 923 | case "1": | ||
| 924 | idValid = IDValidator.idCardValid(managerPersonId); | ||
| 925 | break; | ||
| 926 | case "2": | ||
| 927 | idValid = IDValidator.passportValid(managerPersonId); | ||
| 928 | break; | ||
| 929 | case "3": | ||
| 930 | idValid = IDValidator.militaryValid(managerPersonId); | ||
| 931 | break; | ||
| 932 | } | ||
| 933 | if(!idValid){ | ||
| 934 | throw new CsbrSystemException(SystemError.DATA_INPUT_ERROR,"经办人证件号格式不正确。"); | ||
| 935 | } | ||
| 936 | } | ||
| 937 | |||
| 898 | public List<DataDictVO> getSystemParamsList(String dictType){ | 938 | public List<DataDictVO> getSystemParamsList(String dictType){ |
| 899 | if(StringUtils.isEmpty(dictType)){ | 939 | if(StringUtils.isEmpty(dictType)){ |
| 900 | throw new CsbrSystemException(SystemError.ERROR,"数据字典类型不能为空。"); | 940 | throw new CsbrSystemException(SystemError.ERROR,"数据字典类型不能为空。"); |
| ... | @@ -950,6 +990,8 @@ public class EnterpriseServiceImpl extends FlowAbstractImpl implements Enterpris | ... | @@ -950,6 +990,8 @@ public class EnterpriseServiceImpl extends FlowAbstractImpl implements Enterpris |
| 950 | private void beforeUpdate(EnterpriseRQVO rqVO) { | 990 | private void beforeUpdate(EnterpriseRQVO rqVO) { |
| 951 | //region 1.输入基础验证 | 991 | //region 1.输入基础验证 |
| 952 | check(rqVO); | 992 | check(rqVO); |
| 993 | //验证证件类型证件类型 | ||
| 994 | verifyDocumentType(rqVO); | ||
| 953 | if (StringUtils.isBlank(rqVO.getGuid())) { | 995 | if (StringUtils.isBlank(rqVO.getGuid())) { |
| 954 | // W00012 = {0}:参数[{1}]不能为空! | 996 | // W00012 = {0}:参数[{1}]不能为空! |
| 955 | throw new CsbrSystemException(SystemError.DATA_INPUT_ERROR, messageSourceUtil.getMessage("W00010", String.format("修改%s数据",FUNCTION_NAME), "数据唯一标识")); | 997 | throw new CsbrSystemException(SystemError.DATA_INPUT_ERROR, messageSourceUtil.getMessage("W00010", String.format("修改%s数据",FUNCTION_NAME), "数据唯一标识")); | ... | ... |
| 1 | package com.csbr.qingcloud.portal.util; | ||
| 2 | |||
| 3 | import java.util.regex.Pattern; | ||
| 4 | |||
| 5 | /** | ||
| 6 | * 证件校验 | ||
| 7 | */ | ||
| 8 | public class IDValidator { | ||
| 9 | |||
| 10 | // 身份证号码正则表达式(18位) | ||
| 11 | private static final String ID_CARD_REGEX = "^[1-9]\\d{5}(18|19|20)\\d{2}(0[1-9]|1[0-2])(0[1-9]|[12]\\d|3[01])\\d{3}[\\dXx]$"; | ||
| 12 | // 中国护照号码正则表达式 | ||
| 13 | private static final String PASSPORT_REGEX = "^[EGDS]\\d{8}$"; | ||
| 14 | // 军官证号码正则表达式(兼容常见格式) | ||
| 15 | private static final String MILITARY_ID_REGEX = "^[军海空北南东西JHKBNDX]\\d{7,8}$|^[军海空北南东西JHKBNDX]字第?\\d{7,8}号?$"; | ||
| 16 | |||
| 17 | // 校验码计算权重 | ||
| 18 | private static final int[] WEIGHTS = {7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2}; | ||
| 19 | // 校验码对应值(0-10分别对应) | ||
| 20 | private static final char[] CHECK_CODES = {'1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2'}; | ||
| 21 | |||
| 22 | |||
| 23 | /** | ||
| 24 | * 验证身份证号码是否合法 | ||
| 25 | * @param idCard 身份证号码 | ||
| 26 | * @return 合法返回true,否则false | ||
| 27 | */ | ||
| 28 | public static boolean idCardValid(String idCard) { | ||
| 29 | Pattern idCardPattern = Pattern.compile(ID_CARD_REGEX); | ||
| 30 | // 1. 校验格式 | ||
| 31 | if (idCard == null || !idCardPattern.matcher(idCard).matches()) { | ||
| 32 | return false; | ||
| 33 | } | ||
| 34 | // 2. 校验校验码 | ||
| 35 | char[] idChars = idCard.toUpperCase().toCharArray(); // 统一转为大写 | ||
| 36 | int sum = 0; | ||
| 37 | for (int i = 0; i < 17; i++) { | ||
| 38 | // 前17位必须为数字(正则已保证,此处可简化) | ||
| 39 | int num = idChars[i] - '0'; | ||
| 40 | sum += num * WEIGHTS[i]; | ||
| 41 | } | ||
| 42 | // 计算校验码 | ||
| 43 | int checkCodeIndex = sum % 11; | ||
| 44 | char calculatedCheckCode = CHECK_CODES[checkCodeIndex]; | ||
| 45 | // 对比最后一位校验码 | ||
| 46 | return idChars[17] == calculatedCheckCode; | ||
| 47 | } | ||
| 48 | |||
| 49 | /** | ||
| 50 | * 验证中国护照号码是否合法 | ||
| 51 | * @param passport 护照号码 | ||
| 52 | * @return 合法返回true,否则false | ||
| 53 | */ | ||
| 54 | public static boolean passportValid(String passport) { | ||
| 55 | Pattern passportPattern = Pattern.compile(PASSPORT_REGEX); | ||
| 56 | if (passport == null) { | ||
| 57 | return false; | ||
| 58 | } | ||
| 59 | // 忽略大小写(实际护照号码为大写,此处兼容输入可能的小写) | ||
| 60 | return passportPattern.matcher(passport.toUpperCase()).matches(); | ||
| 61 | } | ||
| 62 | |||
| 63 | /** | ||
| 64 | * 验证军官证号码是否符合常见格式 | ||
| 65 | * @param militaryId 军官证号码 | ||
| 66 | * @return 符合格式返回true,否则false | ||
| 67 | */ | ||
| 68 | public static boolean militaryValid(String militaryId) { | ||
| 69 | Pattern militaryPattern = Pattern.compile(MILITARY_ID_REGEX); | ||
| 70 | if (militaryId == null || militaryId.trim().isEmpty()) { | ||
| 71 | return false; | ||
| 72 | } | ||
| 73 | // 去除可能的空格后验证 | ||
| 74 | return militaryPattern.matcher(militaryId.trim()).matches(); | ||
| 75 | } | ||
| 76 | |||
| 77 | public static void main(String[] args) { | ||
| 78 | // 测试案例 | ||
| 79 | String[] testCases = { | ||
| 80 | "110101199001011234", // 合法格式+正确校验码 | ||
| 81 | "11010119900101123X", // 合法格式+正确校验码(X) | ||
| 82 | "110101199001011235", // 合法格式+错误校验码 | ||
| 83 | "010101199001011234", // 首位为0(格式错误) | ||
| 84 | "110101199002301234", // 日期非法(2月30日,正则会通过但实际无效) | ||
| 85 | "110101900101123" // 15位旧身份证(格式错误) | ||
| 86 | }; | ||
| 87 | |||
| 88 | for (String id : testCases) { | ||
| 89 | System.out.println(id + " -> " + (idCardValid(id) ? "合法" : "非法")); | ||
| 90 | } | ||
| 91 | } | ||
| 92 | |||
| 93 | } |
-
Please register or sign in to post a comment