|
|
@@ -36,8 +36,31 @@ public class ProductUtils {
|
|
|
*/
|
|
|
private static final int ONE_TIME_DATA_SIZE = 1000;
|
|
|
|
|
|
+ /**
|
|
|
+ * 记录日志
|
|
|
+ */
|
|
|
private static final Logger logger = Logger.getLogger(ProductUtils.class);
|
|
|
|
|
|
+ /**
|
|
|
+ * 失败标志
|
|
|
+ */
|
|
|
+ static final String FALSE_SIGN = "false";
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 成功标志
|
|
|
+ */
|
|
|
+ static final String TRUE_SIGN = "true";
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 成功返回值
|
|
|
+ */
|
|
|
+ static final String SUCCESS_CODE = "success";
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 消息
|
|
|
+ */
|
|
|
+ static final String MESSAGE = "message";
|
|
|
+
|
|
|
/**
|
|
|
* 分页批量更新物料
|
|
|
*
|
|
|
@@ -131,12 +154,12 @@ public class ProductUtils {
|
|
|
ModelMap map = new ModelMap();
|
|
|
String res = HttpUtil.doPost(PRODUCT_PUBLIC_SERVICE_URL + "/product/update/addToProductUser", FlexJsonUtils.toJsonDeep(products));
|
|
|
JSONObject response = JSON.parseObject(res);
|
|
|
- if ("true".equals(response.get("success"))) {
|
|
|
+ if (TRUE_SIGN.equals(response.get(SUCCESS_CODE))) {
|
|
|
map.put("success", "true");
|
|
|
// 成功增加的个人产品库数量
|
|
|
map.put("result", response.get("result"));
|
|
|
return map;
|
|
|
- } else if (!StringUtils.isEmpty(response.get("message"))){
|
|
|
+ } else if (!StringUtils.isEmpty(response.get(MESSAGE))){
|
|
|
map.put("success", "false");
|
|
|
map.put("message", response.get("message"));
|
|
|
}
|
|
|
@@ -165,7 +188,7 @@ public class ProductUtils {
|
|
|
pageContent.add(product);
|
|
|
if (i++ % ONE_TIME_DATA_SIZE == 0) {
|
|
|
ModelMap modelMap = updateProdInfoAndAddToProductUser(pageContent);
|
|
|
- if ("false".equals(modelMap.get("success")) && null != modelMap.get("message")) {
|
|
|
+ if (FALSE_SIGN.equals(modelMap.get(SUCCESS_CODE)) && null != modelMap.get(MESSAGE)) {
|
|
|
map.put("success", "false");
|
|
|
map.put("message", modelMap.get("message"));
|
|
|
}
|
|
|
@@ -175,7 +198,7 @@ public class ProductUtils {
|
|
|
}
|
|
|
if (!pageContent.isEmpty()) {
|
|
|
ModelMap modelMap = updateProdInfoAndAddToProductUser(pageContent);
|
|
|
- if ("false".equals(modelMap.get("success")) && null != modelMap.get("message")) {
|
|
|
+ if (FALSE_SIGN.equals(modelMap.get(SUCCESS_CODE)) && null != modelMap.get(MESSAGE)) {
|
|
|
map.put("success", "false");
|
|
|
map.put("message", modelMap.get("message"));
|
|
|
}
|
|
|
@@ -183,33 +206,13 @@ public class ProductUtils {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- if (!"false".equals(map.get("success"))) {
|
|
|
+ if (!FALSE_SIGN.equals(map.get(SUCCESS_CODE))) {
|
|
|
map.put("success", "true");
|
|
|
}
|
|
|
map.put("result", result);
|
|
|
return map;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- /**
|
|
|
- * 批量更新个人物料
|
|
|
- *
|
|
|
- * @author dongbw
|
|
|
- * @param productUsers 要保存的个人物料信息
|
|
|
- * @return
|
|
|
- * @throws Exception
|
|
|
- */
|
|
|
- public static ModelMap updateProductUsersByBatch(List<ProductUsers> productUsers) throws Exception {
|
|
|
- if (CollectionUtils.isEmpty(productUsers)) {
|
|
|
- return null;
|
|
|
- }
|
|
|
- String res = HttpUtil.doPost(PRODUCT_PUBLIC_SERVICE_URL + "/productuser/save", FlexJsonUtils.toJsonDeep(productUsers));
|
|
|
- if (null == res) {
|
|
|
- throw new RuntimeException("批量保存个人物料失败");
|
|
|
- }
|
|
|
- return null;
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* 单个更新个人物料
|
|
|
*
|
|
|
@@ -404,11 +407,17 @@ public class ProductUtils {
|
|
|
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 + "/product/get/findByEnUUAndCode", map);
|
|
|
+ Response res = null;
|
|
|
+ try {
|
|
|
+ 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 {
|
|
|
- throw new Exception("查询物料失败");
|
|
|
+ logger.error("findByEnUUAndCode http response status error: " + res.getStatusCode());
|
|
|
}
|
|
|
+ return null;
|
|
|
}
|
|
|
}
|