|
|
@@ -2,14 +2,18 @@ package com.uas.platform.b2b.ps;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.alibaba.fastjson.TypeReference;
|
|
|
+import com.alibaba.fastjson.parser.Feature;
|
|
|
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.model.PageInfo;
|
|
|
import com.uas.platform.core.util.HttpUtil;
|
|
|
import com.uas.platform.core.util.HttpUtil.Response;
|
|
|
import com.uas.platform.core.util.serializer.FlexJsonUtils;
|
|
|
+import com.uas.sso.support.Page;
|
|
|
import org.apache.commons.collections.map.HashedMap;
|
|
|
import org.apache.http.protocol.HTTP;
|
|
|
import org.apache.log4j.Logger;
|
|
|
@@ -420,4 +424,75 @@ public class ProductUtils {
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 用idList查询物料信息
|
|
|
+ *
|
|
|
+ * @param idList idList
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public static List<Product> findByIds(List<Long> idList) {
|
|
|
+ Response res = null;
|
|
|
+ try {
|
|
|
+ HashMap<String, Object> map = new HashMap<>(1);
|
|
|
+ map.put("ids", ListToString(idList, ","));
|
|
|
+ res = HttpUtil.sendGetRequest(PRODUCT_PUBLIC_SERVICE_URL + "/product/get/findByEnUUAndCode", map);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ if (HttpStatus.OK.value() == res.getStatusCode()) {
|
|
|
+ return JSONObject.parseArray(res.getResponseText(), Product.class);
|
|
|
+ } else {
|
|
|
+ logger.error("findByIds http response status error: " + res.getStatusCode());
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 通过分页参数查询物料信息
|
|
|
+ *
|
|
|
+ * @param pageInfo 分页信息
|
|
|
+ * @param keyword 关键字
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public static Page<Product> findByPageInfo(PageInfo pageInfo, String keyword) {
|
|
|
+ pageInfo.setSort(null);
|
|
|
+ Response res = null;
|
|
|
+ try {
|
|
|
+ JSONObject formData = JSON.parseObject(JSON.toJSONString(pageInfo));
|
|
|
+ if (null != keyword) {
|
|
|
+ formData.put("keyword", keyword);
|
|
|
+ }
|
|
|
+ res = HttpUtil.sendGetRequest(PRODUCT_PUBLIC_SERVICE_URL + "/product/get/findByPageInfo", formData);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ if (HttpStatus.OK.value() == res.getStatusCode()) {
|
|
|
+ return (Page)JSONObject.parseObject(res.getResponseText(), new TypeReference<Page<Product>>() {
|
|
|
+ }, new Feature[0]);
|
|
|
+ } else {
|
|
|
+ logger.error("findByPageInfo http response status error: " + res.getStatusCode());
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 将List转为StringBuffer
|
|
|
+ *
|
|
|
+ * @param idList id
|
|
|
+ * @param mark 符号
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private static StringBuffer ListToString(List<Long> idList, String mark) {
|
|
|
+ StringBuffer buffer = new StringBuffer();
|
|
|
+ idList.forEach(id -> {
|
|
|
+ if (buffer.length() > 0) {
|
|
|
+ buffer.append(mark);
|
|
|
+ }
|
|
|
+ buffer.append(id);
|
|
|
+ });
|
|
|
+ return buffer;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|