|
|
@@ -1,18 +1,7 @@
|
|
|
package com.uas.platform.b2b.erp.controller;
|
|
|
|
|
|
-import java.io.UnsupportedEncodingException;
|
|
|
-import java.net.URLDecoder;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.List;
|
|
|
-
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.stereotype.Controller;
|
|
|
-import org.springframework.util.CollectionUtils;
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
-import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
-import org.springframework.web.bind.annotation.RequestParam;
|
|
|
-import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
-
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.uas.platform.b2b.erp.model.AcceptNotify;
|
|
|
import com.uas.platform.b2b.erp.model.AcceptNotifyConfirm;
|
|
|
import com.uas.platform.b2b.erp.model.AcceptNotifyVerify;
|
|
|
@@ -23,6 +12,20 @@ import com.uas.platform.b2b.model.PurchaseNotice;
|
|
|
import com.uas.platform.b2b.service.PurchaseNoticeService;
|
|
|
import com.uas.platform.core.logging.BufferedLoggerManager;
|
|
|
import com.uas.platform.core.util.serializer.FlexJsonUtils;
|
|
|
+import org.apache.axis.utils.StringUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Controller;
|
|
|
+import org.springframework.ui.ModelMap;
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
+import org.springframework.web.bind.annotation.RequestParam;
|
|
|
+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>
|
|
|
@@ -71,6 +74,49 @@ public class PurchaseNotifyController {
|
|
|
return modifiedNotifies;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 将送货提醒写到平台(EDI)
|
|
|
+ *
|
|
|
+ * @param data
|
|
|
+ * @return
|
|
|
+ * @throws UnsupportedEncodingException
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/EDI", method = RequestMethod.POST)
|
|
|
+ @ResponseBody
|
|
|
+ public ModelMap saveEDINotifies(@RequestParam("data") String data) throws UnsupportedEncodingException {
|
|
|
+ ModelMap map = new ModelMap();
|
|
|
+ if (null == data) {
|
|
|
+ map.put("success", false);
|
|
|
+ map.put("message", "未传入参数!");
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+// List<PurchaseNotify> modifiedNotifies = new ArrayList<PurchaseNotify>();
|
|
|
+ String jsonStr = URLDecoder.decode(data, "UTF-8");
|
|
|
+ JSONObject jsonObject = JSON.parseObject(jsonStr);
|
|
|
+ if (StringUtils.isEmpty(jsonObject.getString("enUU")) || StringUtils.isEmpty(jsonObject.getString("PurchaseNotify"))) {
|
|
|
+ map.put("success", false);
|
|
|
+ map.put("message", "参数名有误!");
|
|
|
+ return map;
|
|
|
+
|
|
|
+ }
|
|
|
+ List<PurchaseNotify> notifies = FlexJsonUtils.fromJsonArray(jsonObject.getString("PurchaseNotify"), PurchaseNotify.class);
|
|
|
+ Long enUU = FlexJsonUtils.fromJson(jsonObject.getString("enUU"), Long.class);
|
|
|
+ List<List<PurchaseNotice>> lists = purchaseNotifyService.convertEDIPurchaseNotify(notifies, enUU);
|
|
|
+ purchaseNoticeService.save(lists.get(0));
|
|
|
+ List<PurchaseNotice> oppNotices = lists.get(1);
|
|
|
+ if (!CollectionUtils.isEmpty(oppNotices)) {
|
|
|
+ for (PurchaseNotice notice : oppNotices) {
|
|
|
+ PurchaseNotify notify = new PurchaseNotify();
|
|
|
+ notify.setPn_id(notice.getSourceId());
|
|
|
+ notify.setPn_qty(notice.getQty());
|
|
|
+// modifiedNotifies.add(notify);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ logger.log("送货提醒", "上传送货提醒", notifies.size());
|
|
|
+ map.put("success", true);
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 从买家ERP获取平台的发货单
|
|
|
*
|
|
|
@@ -84,6 +130,7 @@ public class PurchaseNotifyController {
|
|
|
return notifies;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
/**
|
|
|
* 平台的发货单传到ERP之后,修改平台里面的发货单的状态
|
|
|
*
|
|
|
@@ -96,6 +143,48 @@ public class PurchaseNotifyController {
|
|
|
purchaseNoticeService.onSendUploadSuccess(URLDecoder.decode(data, "UTF-8").split(","));
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 从买家ERP获取平台的发货单(EDI)
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/accept/EDI", method = RequestMethod.GET)
|
|
|
+ @ResponseBody
|
|
|
+ public ModelMap getEDIAcceptNotify(@RequestParam("data") String data) throws UnsupportedEncodingException {
|
|
|
+ ModelMap map = new ModelMap();
|
|
|
+ if (null == data) {
|
|
|
+ map.put("success", false);
|
|
|
+ map.put("message", "未传入参数!");
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+ String enUU = URLDecoder.decode(data, "UTF-8");
|
|
|
+ List<AcceptNotify> notifies = purchaseNotifyService.convertSaleSend(purchaseNoticeService.findNotUploadSendEDI(Long.valueOf(enUU)));
|
|
|
+ logger.log("供应商发货单", "下载来自供应商的发货单", notifies.size());
|
|
|
+ map.put("success", true);
|
|
|
+ map.put("AcceptNotify", notifies);
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 平台的发货单传到ERP之后,修改平台里面的发货单的状态(EDI)
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ * @throws UnsupportedEncodingException
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/accept/back/EDI", method = RequestMethod.POST)
|
|
|
+ @ResponseBody
|
|
|
+ public ModelMap onSendSuccessEDI(@RequestParam("data") String data) throws UnsupportedEncodingException {
|
|
|
+ ModelMap map = new ModelMap();
|
|
|
+ if (null == data) {
|
|
|
+ map.put("success", false);
|
|
|
+ map.put("message", "未传入参数!");
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+ purchaseNoticeService.onSendUploadSuccess(URLDecoder.decode(data, "UTF-8").split(","));
|
|
|
+ map.put("success", true);
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 买家ERP主动收料的记录上传到平台 <br>
|
|
|
* 买卖双方直接电话沟通之后,结果由买家填写到ERP系统的情况
|