|
|
@@ -1,10 +1,16 @@
|
|
|
package com.uas.platform.b2b.erp.controller;
|
|
|
|
|
|
+import com.uas.platform.b2b.erp.model.Prod;
|
|
|
+import com.uas.platform.b2b.erp.model.ProductSaler;
|
|
|
import com.uas.platform.b2b.erp.service.ProdService;
|
|
|
import com.uas.platform.b2b.erp.support.ErpBufferedLogger;
|
|
|
+import com.uas.platform.b2b.model.Product;
|
|
|
import com.uas.platform.b2b.service.ProductService;
|
|
|
import com.uas.platform.core.logging.BufferedLoggerManager;
|
|
|
import com.uas.platform.core.model.Constant;
|
|
|
+import com.uas.platform.core.model.Status;
|
|
|
+import com.uas.platform.core.util.serializer.FlexJsonUtils;
|
|
|
+import org.apache.commons.collections.CollectionUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
@@ -14,13 +20,15 @@ import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
|
|
|
import java.io.UnsupportedEncodingException;
|
|
|
import java.net.URLDecoder;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
|
|
|
/**
|
|
|
* 对ERP的数据接口<br>
|
|
|
* 产品处理
|
|
|
- *
|
|
|
+ *
|
|
|
* @author yingp
|
|
|
- * @since 2018年1月24日 09:25:28 --UAS物料传输相关,调用产品传输公共服务接口,这里的方法除了禁用,其他都弃用 dongbw
|
|
|
+ *
|
|
|
*/
|
|
|
@Controller
|
|
|
@RequestMapping("/erp/product")
|
|
|
@@ -34,6 +42,71 @@ public class ProdController {
|
|
|
|
|
|
private final static ErpBufferedLogger logger = BufferedLoggerManager.getLogger(ErpBufferedLogger.class);
|
|
|
|
|
|
+ /**
|
|
|
+ * 将ERP的产品资料写到平台
|
|
|
+ *
|
|
|
+ * @param data
|
|
|
+ * @return
|
|
|
+ * @throws UnsupportedEncodingException
|
|
|
+ */
|
|
|
+ @RequestMapping(method = RequestMethod.POST)
|
|
|
+ @ResponseBody
|
|
|
+ public void saveProducts(@RequestParam("data") String data) throws UnsupportedEncodingException {
|
|
|
+ String jsonStr = URLDecoder.decode(data, "UTF-8");
|
|
|
+ List<Prod> prods = FlexJsonUtils.fromJsonArray(jsonStr, Prod.class);
|
|
|
+ productService.save(prodService.convertProduct(prods));
|
|
|
+ logger.log("物料资料", "上传物料资料", prods.size());
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 定时任务更新物料信息
|
|
|
+ *
|
|
|
+ * @param data
|
|
|
+ * @return
|
|
|
+ * @throws UnsupportedEncodingException
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/cycleupdate", method = RequestMethod.POST)
|
|
|
+ @ResponseBody
|
|
|
+ public void updateProducts(@RequestParam("data") String data) throws UnsupportedEncodingException {
|
|
|
+ String jsonStr = URLDecoder.decode(data, "UTF-8");
|
|
|
+ List<Prod> prods = FlexJsonUtils.fromJsonArray(jsonStr, Prod.class);
|
|
|
+ productService.save(prodService.convertProduct(prods));
|
|
|
+ logger.log("物料资料", "定时任务更新物料资料", prods.size());
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 将平台更新的ERP的物料数据回传回ERP
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/backtouas", method = RequestMethod.GET)
|
|
|
+ @ResponseBody
|
|
|
+ public List<Prod> getProds() {
|
|
|
+ List<Prod> prods = new ArrayList<Prod>();
|
|
|
+ List<Product> products = productService.findBySourceAppAndDownloadstatus("ERP", Status.NOT_UPLOAD.value());
|
|
|
+ if (!CollectionUtils.isEmpty(products)) {
|
|
|
+ for (Product product : products) {
|
|
|
+ Prod prod = new Prod();
|
|
|
+ prod.setPr_uuid(product.getCmpUuId());
|
|
|
+ prod.setPr_id(product.getSourceId());
|
|
|
+ prod.setB2b_id(product.getId());
|
|
|
+ prods.add(prod);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return prods;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 更新下载成功的状态
|
|
|
+ *
|
|
|
+ * @param data
|
|
|
+ * @throws UnsupportedEncodingException
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/refreshDownloadstatus", method = RequestMethod.POST)
|
|
|
+ @ResponseBody
|
|
|
+ public void refreshDownloadstatus(@RequestParam("data") String data) throws UnsupportedEncodingException {
|
|
|
+ productService.onProductDownSuccess(URLDecoder.decode(data, "UTF-8").split(","));
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* UAS端禁用物料时调用此接口使B2B也禁用此物料
|
|
|
@@ -49,103 +122,37 @@ public class ProdController {
|
|
|
return productService.updateB2bEnabled(code, b2bDisabled);
|
|
|
}
|
|
|
|
|
|
-// /**
|
|
|
-// * 将ERP的产品资料写到平台
|
|
|
-// *
|
|
|
-// * @param data
|
|
|
-// * @return
|
|
|
-// * @throws UnsupportedEncodingException
|
|
|
-// */
|
|
|
-// @RequestMapping(method = RequestMethod.POST)
|
|
|
-// @ResponseBody
|
|
|
-// public void saveProducts(@RequestParam("data") String data) throws UnsupportedEncodingException {
|
|
|
-// String jsonStr = URLDecoder.decode(data, "UTF-8");
|
|
|
-// List<Prod> prods = FlexJsonUtils.fromJsonArray(jsonStr, Prod.class);
|
|
|
-// productService.save(prodService.convertProduct(prods));
|
|
|
-// logger.log("物料资料", "上传物料资料", prods.size());
|
|
|
-// }
|
|
|
-//
|
|
|
-// /**
|
|
|
-// * 定时任务更新物料信息
|
|
|
-// *
|
|
|
-// * @param data
|
|
|
-// * @return
|
|
|
-// * @throws UnsupportedEncodingException
|
|
|
-// */
|
|
|
-// @RequestMapping(value = "/cycleupdate", method = RequestMethod.POST)
|
|
|
-// @ResponseBody
|
|
|
-// public void updateProducts(@RequestParam("data") String data) throws UnsupportedEncodingException {
|
|
|
-// String jsonStr = URLDecoder.decode(data, "UTF-8");
|
|
|
-// List<Prod> prods = FlexJsonUtils.fromJsonArray(jsonStr, Prod.class);
|
|
|
-// productService.save(prodService.convertProduct(prods));
|
|
|
-// logger.log("物料资料", "定时任务更新物料资料", prods.size());
|
|
|
-// }
|
|
|
-//
|
|
|
-// /**
|
|
|
-// * 将平台更新的ERP的物料数据回传回ERP
|
|
|
-// *
|
|
|
-// * @return
|
|
|
-// */
|
|
|
-// @RequestMapping(value = "/backtouas", method = RequestMethod.GET)
|
|
|
-// @ResponseBody
|
|
|
-// public List<Prod> getProds() {
|
|
|
-// List<Prod> prods = new ArrayList<Prod>();
|
|
|
-// List<Product> products = productService.findBySourceAppAndDownloadstatus("ERP", Status.NOT_UPLOAD.value());
|
|
|
-// if (!CollectionUtils.isEmpty(products)) {
|
|
|
-// for (Product product : products) {
|
|
|
-// Prod prod = new Prod();
|
|
|
-// prod.setPr_uuid(product.getCmpUuId());
|
|
|
-// prod.setPr_id(product.getSourceId());
|
|
|
-// prod.setB2b_id(product.getId());
|
|
|
-// prods.add(prod);
|
|
|
-// }
|
|
|
-// }
|
|
|
-// return prods;
|
|
|
-// }
|
|
|
-//
|
|
|
-// /**
|
|
|
-// * 更新下载成功的状态
|
|
|
-// *
|
|
|
-// * @param data
|
|
|
-// * @throws UnsupportedEncodingException
|
|
|
-// */
|
|
|
-// @RequestMapping(value = "/refreshDownloadstatus", method = RequestMethod.POST)
|
|
|
-// @ResponseBody
|
|
|
-// public void refreshDownloadstatus(@RequestParam("data") String data) throws UnsupportedEncodingException {
|
|
|
-// productService.onProductDownSuccess(URLDecoder.decode(data, "UTF-8").split(","));
|
|
|
-// }
|
|
|
-//
|
|
|
-// /**
|
|
|
-// * ERP个人物料同步到平台
|
|
|
-// *
|
|
|
-// * @author hejq
|
|
|
-// * @date 2018-01-12 19:11
|
|
|
-// * @param data
|
|
|
-// * @throws UnsupportedEncodingException
|
|
|
-// */
|
|
|
-// @RequestMapping(value = "/produser", method = RequestMethod.POST)
|
|
|
-// @ResponseBody
|
|
|
-// public void updateProdSaler(@RequestParam("data") String data) throws UnsupportedEncodingException {
|
|
|
-// String jsonStr = URLDecoder.decode(data, "UTF-8");
|
|
|
-// List<ProductSaler> productSalers = FlexJsonUtils.fromJsonArray(jsonStr, ProductSaler.class);
|
|
|
-// productService.updateProdSaler(productSalers);
|
|
|
-// logger.log("物料资料", "上传个人物料资料", productSalers.size());
|
|
|
-// }
|
|
|
-//
|
|
|
-// /**
|
|
|
-// * ERP个人物料删除同步状态到平台
|
|
|
-// *
|
|
|
-// * @author hejq
|
|
|
-// * @date 2018-01-12 19:11
|
|
|
-// * @param data
|
|
|
-// * @throws UnsupportedEncodingException
|
|
|
-// */
|
|
|
-// @RequestMapping(value = "/produser/quit", method = RequestMethod.POST)
|
|
|
-// @ResponseBody
|
|
|
-// public void uploadProductSalerForCancel(@RequestParam("data") String data) throws UnsupportedEncodingException {
|
|
|
-// String jsonStr = URLDecoder.decode(data, "UTF-8");
|
|
|
-// List<ProductSaler> productSalers = FlexJsonUtils.fromJsonArray(jsonStr, ProductSaler.class);
|
|
|
-// productService.quitProdSaler(productSalers);
|
|
|
-// logger.log("物料资料", "ERP取消个人物料同步到平台", productSalers.size());
|
|
|
-// }
|
|
|
+ /**
|
|
|
+ * ERP个人物料同步到平台
|
|
|
+ *
|
|
|
+ * @author hejq
|
|
|
+ * @date 2018-01-12 19:11
|
|
|
+ * @param data
|
|
|
+ * @throws UnsupportedEncodingException
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/produser", method = RequestMethod.POST)
|
|
|
+ @ResponseBody
|
|
|
+ public void updateProdSaler(@RequestParam("data") String data) throws UnsupportedEncodingException {
|
|
|
+ String jsonStr = URLDecoder.decode(data, "UTF-8");
|
|
|
+ List<ProductSaler> productSalers = FlexJsonUtils.fromJsonArray(jsonStr, ProductSaler.class);
|
|
|
+ productService.updateProdSaler(productSalers);
|
|
|
+ logger.log("物料资料", "上传个人物料资料", productSalers.size());
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * ERP个人物料删除同步状态到平台
|
|
|
+ *
|
|
|
+ * @author hejq
|
|
|
+ * @date 2018-01-12 19:11
|
|
|
+ * @param data
|
|
|
+ * @throws UnsupportedEncodingException
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/produser/quit", method = RequestMethod.POST)
|
|
|
+ @ResponseBody
|
|
|
+ public void uploadProductSalerForCancel(@RequestParam("data") String data) throws UnsupportedEncodingException {
|
|
|
+ String jsonStr = URLDecoder.decode(data, "UTF-8");
|
|
|
+ List<ProductSaler> productSalers = FlexJsonUtils.fromJsonArray(jsonStr, ProductSaler.class);
|
|
|
+ productService.quitProdSaler(productSalers);
|
|
|
+ logger.log("物料资料", "ERP取消个人物料同步到平台", productSalers.size());
|
|
|
+ }
|
|
|
}
|