|
|
@@ -90,24 +90,17 @@ public class ProductController {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 批量更新物料信息(子应用做验证,这里只负责存) (商城与b2b)
|
|
|
+ * 批量更新物料信息(子应用做验证,这里只负责存) 商城
|
|
|
*
|
|
|
* @param data 物料信息
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "/update", method = RequestMethod.POST)
|
|
|
@ResponseBody
|
|
|
- public List<Long> updateProdInfo(@RequestBody String data, String sourceApp) throws UnsupportedEncodingException {
|
|
|
+ public List<Long> updateProdInfo(@RequestBody String data) throws UnsupportedEncodingException {
|
|
|
// TODO 物料信息中的企业UU和用户UU,需要在调用接口之前设置。有id为更新,无id为新增
|
|
|
List<Product> productInfo = JSONObject.parseArray(data, Product.class);
|
|
|
List<Long> resultProducts = new ArrayList<>();
|
|
|
-
|
|
|
- boolean fromB2B = sourceApp != null && sourceApp.equalsIgnoreCase("B2B");
|
|
|
- String batchCode = UUID.randomUUID().toString().replace("-", "");
|
|
|
- if (fromB2B) {
|
|
|
- productDao.setSessionVariable(sourceApp, batchCode, productInfo.size());
|
|
|
- }
|
|
|
-
|
|
|
for (Product product : productInfo) {
|
|
|
List<Product> products = productService.findByEnUUAndPCmpCodeAndPBrandEn(product.getEnUU(),product.getpCmpCode(),product.getpBrandEn());
|
|
|
if (org.apache.commons.collections.CollectionUtils.isEmpty(products)) {
|
|
|
@@ -117,10 +110,33 @@ public class ProductController {
|
|
|
resultProducts.add(products.get(0).getId());
|
|
|
}
|
|
|
}
|
|
|
- productDao.unsetSessionVariable();
|
|
|
- if (fromB2B) {
|
|
|
- consumer.waitResponse(batchCode);
|
|
|
+// logger.log("更新物料", "[" + productInfo.getUserUU() + "]更新了id为" + productInfo.getId() + "的["
|
|
|
+// + productInfo.getTitle() + "]");
|
|
|
+ return resultProducts;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 批量更新物料信息(子应用做验证,这里只负责存) B2B
|
|
|
+ *
|
|
|
+ * @param data 物料信息
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/update/b2b", method = RequestMethod.POST)
|
|
|
+ @ResponseBody
|
|
|
+ public List<Long> updateB2bProdInfo(@RequestBody List<Product> data) throws UnsupportedEncodingException {
|
|
|
+ List<Product> productInfo = data;
|
|
|
+ List<Long> resultProducts = new ArrayList<>();
|
|
|
+ String batchCode = UUID.randomUUID().toString().replace("-", "");
|
|
|
+ productDao.setSessionVariable("B2B", batchCode, productInfo.size());
|
|
|
+ productInfo = productService.updateB2bProdInfo(productInfo);
|
|
|
+ // B2B批量更新不返回
|
|
|
+ if (productInfo.size() > 1) {
|
|
|
+ return new ArrayList<>();
|
|
|
+ } else if (productInfo.size() == 1) {
|
|
|
+ resultProducts.add(productInfo.get(0).getId());
|
|
|
}
|
|
|
+ productDao.unsetSessionVariable();
|
|
|
+ consumer.waitResponse(batchCode);
|
|
|
// logger.log("更新物料", "[" + productInfo.getUserUU() + "]更新了id为" + productInfo.getId() + "的["
|
|
|
// + productInfo.getTitle() + "]");
|
|
|
return resultProducts;
|