|
|
@@ -4,20 +4,21 @@ import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.uas.platform.b2b.core.util.ContextUtils;
|
|
|
import com.uas.platform.b2b.model.Product;
|
|
|
+import com.uas.platform.b2b.model.ProductInfo;
|
|
|
import com.uas.platform.b2b.model.ProductUsers;
|
|
|
import com.uas.platform.b2b.support.SysConf;
|
|
|
import com.uas.platform.core.util.HttpUtil;
|
|
|
import com.uas.platform.core.util.HttpUtil.Response;
|
|
|
import com.uas.platform.core.util.serializer.FlexJsonUtils;
|
|
|
+import org.apache.commons.collections.map.HashedMap;
|
|
|
+import org.apache.http.protocol.HTTP;
|
|
|
import org.springframework.http.HttpStatus;
|
|
|
import org.springframework.ui.ModelMap;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Arrays;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.List;
|
|
|
+import java.net.URLEncoder;
|
|
|
+import java.util.*;
|
|
|
|
|
|
/**
|
|
|
* 对接公共物料服务的接口
|
|
|
@@ -364,14 +365,38 @@ public class ProductUtils {
|
|
|
* 通过企业UU和code串查询物料信息
|
|
|
*
|
|
|
* @param enUU 企业UU
|
|
|
- * @param codeStr 物料code
|
|
|
+ * @param codeSet 物料code
|
|
|
* @return
|
|
|
*/
|
|
|
- public static List<Product> findByEnUUAndCodes(Long enUU, String codeStr) throws Exception {
|
|
|
+ public static Map<String, ProductInfo> findByEnUUAndCodes(Long enUU, Set<String> codeSet) throws Exception {
|
|
|
HashMap<String, Object> map = new HashMap<>(2);
|
|
|
map.put("enUU", enUU);
|
|
|
- map.put("codes", Arrays.asList(codeStr));
|
|
|
- Response res = HttpUtil.sendPostRequest(PRODUCT_PUBLIC_SERVICE_URL + "/get/findByEnUUAndCode", map);
|
|
|
+ map.put("codes", FlexJsonUtils.toJsonDeep(codeSet));
|
|
|
+ Response res = HttpUtil.sendGetRequest(PRODUCT_PUBLIC_SERVICE_URL + "/product/get/findByEnUUAndCodes", map);
|
|
|
+ Map<String, ProductInfo> resultMap = new HashedMap();
|
|
|
+ if (HttpStatus.OK.value() == res.getStatusCode()) {
|
|
|
+ List<ProductInfo> productInfoList = JSONObject.parseArray(res.getResponseText(), ProductInfo.class);
|
|
|
+ productInfoList.forEach(productInfo -> {
|
|
|
+ resultMap.put(productInfo.getCode(), productInfo);
|
|
|
+ });
|
|
|
+ return resultMap;
|
|
|
+ } else {
|
|
|
+ throw new Exception("查询物料失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 通过企业UU和code查询物料信息
|
|
|
+ *
|
|
|
+ * @param enUU 企业UU
|
|
|
+ * @param code 物料code
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public static List<Product> findByEnUUAndCode(Long enUU, String code) throws Exception {
|
|
|
+ HashMap<String, Object> map = new HashMap<>(2);
|
|
|
+ map.put("enUU", enUU);
|
|
|
+ map.put("code", URLEncoder.encode(code, HTTP.UTF_8));
|
|
|
+ Response res = HttpUtil.sendGetRequest(PRODUCT_PUBLIC_SERVICE_URL + "/get/findByEnUUAndCode", map);
|
|
|
if (HttpStatus.OK.value() == res.getStatusCode()) {
|
|
|
return JSONObject.parseArray(res.getResponseText(), Product.class);
|
|
|
} else {
|