Commit da037ca7 by suxiaochun

境外码 增加目标市场

parent 45e3bca3
......@@ -15,8 +15,10 @@ import io.office.modules.manage.vo.request.VbgOutFirmSearchVo;
import io.office.modules.manage.vo.request.VbgOutOtherKeyVo;
import io.office.modules.manage.vo.request.VbgOutSearchGLNVo;
import io.office.modules.manage.vo.request.VbgOutVerifiedVo;
import io.office.modules.manage.vo.response.NationalDictionaryRe;
import io.office.modules.sys.service.SysCaptchaService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
......@@ -28,10 +30,7 @@ import javax.crypto.SecretKey;
import javax.crypto.spec.SecretKeySpec;
import javax.servlet.http.HttpServletRequest;
import javax.xml.bind.DatatypeConverter;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.*;
@RestController
@RequestMapping(value = "/vbgOutSearch")
......@@ -42,7 +41,8 @@ public class GLNOutController {
private static String KEY = "2mI+lM0U5AmGOr6dWDR735hcS4qLah7NoFI3LYnYtoo=";
private static String HOST = "http://192.168.100.163:8088";
private static JSONArray COUNTRYS;
private static List<NationalDictionaryRe> COUNTRYS = new ArrayList<>();
private static Map<String, NationalDictionaryRe> NUMBERCODEMAP = new HashMap<>();
@Autowired
private SysCaptchaService sysCaptchaService;
......@@ -97,10 +97,42 @@ public class GLNOutController {
String result = HttpUtil.get(url, paramMap);
log.info("/verified==>{}==>{}", paramMap, result);
JSONArray objects = JSONArray.parseArray(result);
//
if (CollectionUtils.isNotEmpty(objects)) {
JSONObject jsonObject = objects.getJSONObject(0);
//人为增加英文产品类别
String gpcCategoryCode = jsonObject.getString("gpcCategoryCode");
if (StringUtils.isNotBlank(gpcCategoryCode)) {
String s = HttpUtil.get(HOST + "/api/ProductManager/GetSuccessGpc?code=" + gpcCategoryCode);
if (StringUtils.isNotBlank(s)) {
String gpcEnName = JSONObject.parseObject(s).getString("GPCEnName");
jsonObject.put("gpcCategoryCodeEnName", gpcEnName);
}
}
//人为赋值目标市场
List<JSONObject> countryOfSaleCodes = JSONArray.parseArray(jsonObject.getString("countryOfSaleCode"), JSONObject.class);
if (countryOfSaleCodes != null) {
for (JSONObject countryOfSaleCode : countryOfSaleCodes) {
String numeric = countryOfSaleCode.getString("numeric");
if ("001".equals(numeric)) {
countryOfSaleCode.put("countrySale", "全球");
} else {
if (NUMBERCODEMAP.size() < 1) {
getCountry();
}
NationalDictionaryRe re = NUMBERCODEMAP.get(numeric);
if (re != null) {
countryOfSaleCode.put("countrySale", re.getCountrytitle());
}
}
}
jsonObject.put("countryOfSaleCode", countryOfSaleCodes);
}
}
return R.ok().put("data", objects);
}
/**
* 境外条码查询--验证其他GS1标识
* 通过其他key查询企业信息
......@@ -287,17 +319,30 @@ public class GLNOutController {
@Login
@RequestMapping("/api/searchCountry")
public R searchCountry() {
if (COUNTRYS == null) {
String url = "http://219.232.114.68:8088/api/importer/v1/CodeApi?name=ISO3166Code";
String result = HttpUtil.get(url);
log.info("/searchCountry==>{}", result);
COUNTRYS = JSONArray.parseArray(result);
if (CollectionUtils.isEmpty(COUNTRYS)) {
getCountry();
}
return R.ok().put("data", COUNTRYS);
}
/**
* 初始化国家字典
*/
private static void getCountry() {
log.info("初始化国家字典");
String url = "http://219.232.114.68:8088/api/importer/v1/CodeApi?name=ISO3166Code";
String result = HttpUtil.get(url);
COUNTRYS = JSONArray.parseArray(result, NationalDictionaryRe.class);
log.info("COUNTRYS==>{}", COUNTRYS.size());
//初始化
for (NationalDictionaryRe country : COUNTRYS) {
NUMBERCODEMAP.put(country.getNumbercode(), country);
}
}
/**
* 公共方法
*
* @param key
......
package io.office.modules.manage.vo.response;
import lombok.Data;
import java.io.Serializable;
@Data
public class NationalDictionaryRe implements Serializable {
private String twocode;
private String threecode;
private String numbercode;
private String ISOcode;
private String countrytitle;
}
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