This commit is contained in:
quyixiao 2025-03-21 01:06:52 +08:00
parent 7da973567d
commit de36026739
5 changed files with 205 additions and 0 deletions

View File

@ -0,0 +1,98 @@
package com.heyu.api.data.utils;
import com.alibaba.fastjson.JSONObject;
import java.util.List;
import java.util.Map;
public class MapUtils {
public static <T> T getByExpr(Map<String, Object> map, String expression) {
String expressions[] = expression.split("\\.");
Object value = null;
for (int i = 0; i < expressions.length; i++) {
String expr = expressions[i];
if (expr.startsWith("[")) {
if (value != null) {
Integer exprVal = NumberUtil.objToIntDefault(expr.substring(1, expr.length() - 1), -1);
if(exprVal == -1){
return null;
}
List<Object> list = JSONObject.parseArray(value.toString(), Object.class);
if (list.size() < exprVal || list.get(exprVal) == null) {
return null;
}
if (i < expressions.length - 1) {
map = JSONObject.parseObject(list.get(exprVal).toString(), Map.class);
} else {
value = list.get(exprVal);
}
}
}
Object object = map.get(expr);
if (object != null) {
if (i < expressions.length - 1) {
if (expressions[i + 1].contains("[")) {
value = object;
} else {
map = JSONObject.parseObject(object.toString(), Map.class);
}
} else {
value = object;
}
}
}
return (T) value;
}
public static void main(String[] args) {
String a = "{\n" +
" \"words_result\": {\n" +
" \"账号\": {\n" +
" \"word\": [\n" +
" \"254653912299\"\n" +
" ]\n" +
" },\n" +
" \"公司名称\": {\n" +
" \"word\": [\n" +
" \"河南专开机械设备有限公司\"\n" +
" ]\n" +
" },\n" +
" \"核准号\": {\n" +
" \"word\": [\n" +
" \"J4910057237101\"\n" +
" ]\n" +
" },\n" +
" \"法人\": {\n" +
" \"word\": [\n" +
" \"郭娟\"\n" +
" ]\n" +
" },\n" +
" \"编号\": {\n" +
" \"word\": [\n" +
" \"4910-02691732\"\n" +
" ]\n" +
" },\n" +
" \"开户银行\": {\n" +
" \"word\": [\n" +
" \"中国银行股份有限公司郑州高新技术开发区支行\"\n" +
" ]\n" +
" }\n" +
" },\n" +
" \"words_result_num\": 6,\n" +
" \"log_id\": 1754840007553369396\n" +
"}";
Map data = JSONObject.parseObject(a, Map.class);
System.out.println(getByExpr(data, "words_result.账号.word.[0]"));
}
}

View File

@ -40,6 +40,13 @@ public class BusinessLicenseRecognizeController extends BaseController {
@Autowired
private ARecognizeBusinessLicenseHandle arRecognizeBusinessLicenseHandle;
@RequestMapping("/recognize")
@CacheResult
public R recognize(BusinessLicenseRecognizeRequest request) {

View File

@ -0,0 +1,44 @@
package com.heyu.api.controller.certificate;
import com.heyu.api.baidu.handle.certificate.BAccountOpeningHandle;
import com.heyu.api.baidu.request.certificate.BAccountOpeningRequest;
import com.heyu.api.data.annotation.CacheResult;
import com.heyu.api.data.annotation.NotIntercept;
import com.heyu.api.data.utils.ApiR;
import com.heyu.api.data.utils.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Map;
@Slf4j
@RestController
@RequestMapping("/account")
@NotIntercept
public class AccountOpeningController {
@Autowired
private BAccountOpeningHandle bAccountOpeningHandle;
@RequestMapping("/opening")
@CacheResult
public R recognize(BAccountOpeningRequest request) {
ApiR<Map> bR = bAccountOpeningHandle.handle(request);
if (bR.isSuccess()) {
Map<String, Object> data = bR.getData();
}
return R.error();
}
}

View File

@ -0,0 +1,8 @@
package com.heyu.api.request.certificate;
import lombok.Data;
@Data
public class AccountOpeningReq {
}

View File

@ -0,0 +1,48 @@
package com.heyu.api.resp.certificate;
import com.heyu.api.data.dto.BaseResp;
import lombok.Data;
@Data
public class AccountOpeningResp extends BaseResp {
/***
* 账号
*
*/
private String account ;
/***
* 公司名称
*/
private String companyName;
/***
* 核准号
*/
private String checkNumber;
/***
*法人
*/
private String legalPerson;
/**
* 编号
*/
private String serialNumber;
/***
* 开户银行
*/
private String openAccountBank;
public static void main(String[] args) {
}
}