接入天眼接口

cert
anthonywj 2 years ago
parent bb707f6601
commit b94067697e

@ -12,9 +12,11 @@ import com.glxp.api.common.res.BaseResponse;
import com.glxp.api.common.util.ResultVOUtils;
import com.glxp.api.controller.BaseController;
import com.glxp.api.entity.basic.ProductInfoEntity;
import com.glxp.api.entity.basic.TyCompanySearchEntity;
import com.glxp.api.entity.sup.UserCompanyEntity;
import com.glxp.api.entity.sup.UserCompanyOnlineEntity;
import com.glxp.api.exception.JsonException;
import com.glxp.api.http.YyHttpClient;
import com.glxp.api.req.auth.FilterUserComapanyRequest;
import com.glxp.api.req.basic.ProductInfoFilterRequest;
import com.glxp.api.res.PageSimpleResponse;
@ -24,6 +26,7 @@ import com.glxp.api.res.sup.UserCompanyResponse;
import com.glxp.api.service.sup.UserCompanyOnlineService;
import com.glxp.api.service.sup.UserCompanyService;
import com.glxp.api.util.DateUtil;
import com.glxp.api.util.UnifiedCodeUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
@ -111,21 +114,39 @@ public class UserComanyController extends BaseController {
return ResultVOUtils.success(userCompanyResponse);
}
@Resource
YyHttpClient yyHttpClient;
@ApiOperation(value = "查询用户企业信息", response = UserCompanyEntity.class)
@GetMapping("udi/auth/user/comapny/info")
public BaseResponse getCompanyInfo(FilterUserComapanyRequest filterUserComapanyRequest) {
if (StrUtil.isNotEmpty(filterUserComapanyRequest.getCreditNum())) {
if (!UnifiedCodeUtil.CodeValidate(filterUserComapanyRequest.getCreditNum())) {
return ResultVOUtils.error(500, "非正确统一社会信用代码!");
}
}
UserCompanyResponse userCompanyResponse = new UserCompanyResponse();
List<UserCompanyEntity> userCompanyEntities = userCompanyService.filterCompanyName(filterUserComapanyRequest);
if (CollUtil.isNotEmpty(userCompanyEntities)) {
UserCompanyEntity userCompanyEntity = userCompanyEntities.get(0);
BeanUtil.copyProperties(userCompanyEntity, userCompanyResponse);
userCompanyResponse.setRegStatus(1);
return ResultVOUtils.success(userCompanyResponse);
} else {
userCompanyResponse.setCreditNum(filterUserComapanyRequest.getCreditNum());
userCompanyResponse.setRegStatus(3);
BaseResponse<TyCompanySearchEntity> baseResponse = yyHttpClient.findBycCeditCode(filterUserComapanyRequest.getCreditNum());
if (baseResponse != null && baseResponse.getCode() == 20000) {
TyCompanySearchEntity tyCompanySearchEntity = baseResponse.getData();
userCompanyResponse.setCompanyName(tyCompanySearchEntity.getName());
userCompanyResponse.setLegalPerson(tyCompanySearchEntity.getLegalPersonName());
userCompanyResponse.setCreditNum(filterUserComapanyRequest.getCreditNum());
userCompanyResponse.setRegStatus(3);
return ResultVOUtils.success(userCompanyResponse);
} else
return ResultVOUtils.error(500, "查无此企业!");
}
return ResultVOUtils.success(userCompanyResponse);
}

@ -0,0 +1,65 @@
package com.glxp.api.entity.basic;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
@Data
public class TyCompanySearchEntity implements Serializable {
private String id;
@TableField(value = "regStatus")
@ApiModelProperty(value = "")
private String regStatus;
@TableField(value = "estiblishTime")
@ApiModelProperty(value = "")
private String estiblishTime;
@TableField(value = "regCapital")
@ApiModelProperty(value = "")
private String regCapital;
@TableField(value = "companyType")
@ApiModelProperty(value = "")
private String companyType;
@TableField(value = "matchType")
@ApiModelProperty(value = "")
private String matchType;
@TableField(value = "`type`")
@ApiModelProperty(value = "")
private String type;
@TableField(value = "legalPersonName")
@ApiModelProperty(value = "")
private String legalPersonName;
@TableField(value = "regNumber")
@ApiModelProperty(value = "")
private String regNumber;
@TableField(value = "creditCode")
@ApiModelProperty(value = "")
private String creditCode;
@TableField(value = "`name`")
@ApiModelProperty(value = "")
private String name;
@TableField(value = "orgNumber")
@ApiModelProperty(value = "")
private String orgNumber;
@TableField(value = "base")
@ApiModelProperty(value = "")
private String base;
private static final long serialVersionUID = 1L;
}

@ -0,0 +1,35 @@
package com.glxp.api.http;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import com.glxp.api.common.res.BaseResponse;
import com.glxp.api.common.util.ResultVOUtils;
import com.glxp.api.entity.basic.TyCompanySearchEntity;
import com.glxp.api.util.HttpClient;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.Map;
@Service
public class YyHttpClient {
@Value("${UDI_SERVER_URL}")
private String udiUrl;
public BaseResponse<TyCompanySearchEntity> findBycCeditCode(String creditCode) {
try {
Map<String, Object> paramMap = new HashMap<>(16);
paramMap.put("creditCode", creditCode);
String response = HttpClient.mipsGet(udiUrl + "/udidl/ty/company/findBycCeditCode", paramMap);
BaseResponse<TyCompanySearchEntity> baseResponse =
JSONObject.parseObject(response, new TypeReference<BaseResponse<TyCompanySearchEntity>>() {
});
return baseResponse;
} catch (Exception e) {
e.printStackTrace();
return ResultVOUtils.error(500, "查询统一社会信用号出错!");
}
}
}

@ -0,0 +1,108 @@
package com.glxp.api.util;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.regex.Pattern;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.regex.Pattern;
import org.apache.commons.lang3.StringUtils;
//import plugin.template.TemplateStepMeta;
/**
*
*
* @author balizuoan
*/
public class UnifiedCodeUtil {
//正则校验 如果想要不区分大小写,就在最后一个数组中加入 abcsefghjklmnpqrtuwxy
private static final String REGEX = "[1-9NY]{1}[1-9]{1}[1-6]{1}[0-9]{5}[0123456789ABCDEFGHJKLMNPQRTUWXYabcsefghjklmnpqrtuwxy]{10}";
private static final int[] WEIGHT = {1, 3, 9, 27, 19, 26, 16, 17, 20, 29, 25, 13, 8, 24, 10, 30, 28};
private static final String BASE_CODE_STRING = "0123456789ABCDEFGHJKLMNPQRTUWXYabcsefghjklmnpqrtuwxy";
private static final char[] BASE_CODE_ARRAY = BASE_CODE_STRING.toCharArray();
private static final List<Character> BASE_CODES = new ArrayList<>();
/**
* +
* http://www.sohu.com/a/332134717_120209852
*/
private static final List<String> REGIST_CODE = Arrays.asList(
"11", "12", "13", "19",
"21", "29",
"31", "32", "33", "34", "35", "39",
"41", "49",
"51", "52", "53", "59",
"61", "62", "69",
"71", "72", "79",
"81", "89",
"91", "92", "93",
"A1", "A9",
"N1", "N2", "N3", "N9",
"Y1"
);
/**
*
*/
private static final List<String> PROVINCE_REGION_CODE = Arrays.asList(
"11", "12", "13", "14", "15", "21", "22", "23", "31", "32", "33", "34", "35", "36", "37", "41", "42", "43", "44", "45", "46",
"50", "51", "52", "53", "54", "61", "62", "63", "64", "65", "71", "81", "82", "91"
);
static {
for (char c : BASE_CODE_ARRAY) {
BASE_CODES.add(c);
}
}
/**
*
*
* @param value
* @return
*/
public static boolean CodeValidate(String value) {
if (StringUtils.isEmpty(value)) {
return true;
}
// 长度验证
if (value.length() != 18) {
return false;
}
// 登记管理部门+机构类别代码验证
if (!REGIST_CODE.contains(value.substring(0, 2))) {
return false;
}
// 省级行政区划代码验证
if (!PROVINCE_REGION_CODE.contains(value.substring(2, 4))) {
return false;
}
// 正则初验
if (!Pattern.matches(REGEX, value)) {
return false;
}
// 效验码校验
char[] businessCodeArray = value.toCharArray();
// char check= businessCodeArray[17];
String check = Character.toString(businessCodeArray[17]);
int sum = 0;
for (int i = 0; i < 17; i++) {
char key = businessCodeArray[i];
sum += (BASE_CODES.indexOf(key) * WEIGHT[i]);
}
int checkCode = 31 - sum % 31;
String s = Character.toString(BASE_CODE_ARRAY[checkCode % 31]);
//对比时将两个字符转为字符串,不区分大小写对比最后一位
return s.equalsIgnoreCase(check);
}
}

@ -4,9 +4,9 @@ server:
spring:
datasource:
driver-class-name: com.p6spy.engine.spy.P6SpyDriver
jdbc-url: jdbc:p6spy:mysql://192.168.0.66:3364/udi_cpt?allowMultiQueries=true&serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowPublicKeyRetrieval=true
jdbc-url: jdbc:p6spy:mysql://127.0.0.1:3306/udi_cpt?allowMultiQueries=true&serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowPublicKeyRetrieval=true
username: root
password: Glxp@6066
password: 123456
hikari:
connection-timeout: 60000
maximum-pool-size: 20
@ -76,8 +76,8 @@ logging:
file_path: D:/udi/inUdiwms/udiwmsfile/
UDI_KEY: 6b137c66-6286-46c6-8efa-c2f5dd9237df
#UDI_SERVER_URL: https://www.udims.com/UDI_DL_Server_test
UDI_SERVER_URL: http://127.0.0.1:9994
UDI_SERVER_URL: https://www.udims.com/UDI_DL_Server_test
#UDI_SERVER_URL: http://127.0.0.1:9994
SPMS_KEY: lCOdWCBKS6Kw45wdnnqUTELXyuSKnXEs
back_file_path: D:/share/udisps/back/

@ -4,9 +4,9 @@ server:
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
jdbc-url: jdbc:mysql://192.168.0.66:3364/udi_cpt?allowMultiQueries=true&serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowPublicKeyRetrieval=true
jdbc-url: jdbc:mysql://127.0.0.1:3306/udi_cpt?allowMultiQueries=true&serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowPublicKeyRetrieval=true
username: root
password: Glxp@6066
password: 123456
hikari:
connection-timeout: 60000
maximum-pool-size: 60

Loading…
Cancel
Save