|
|
@@ -1,12 +1,15 @@
|
|
|
package com.uas.platform.b2b.erp.service.impl;
|
|
|
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
import java.util.ArrayList;
|
|
|
+import java.util.Date;
|
|
|
import java.util.List;
|
|
|
import java.util.Set;
|
|
|
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.util.StringUtils;
|
|
|
|
|
|
import com.uas.platform.b2b.dao.PurchaseNoticeDao;
|
|
|
import com.uas.platform.b2b.dao.PurchaseOrderItemDao;
|
|
|
@@ -23,6 +26,7 @@ import com.uas.platform.b2b.model.SaleSend;
|
|
|
import com.uas.platform.b2b.model.SaleSendItem;
|
|
|
import com.uas.platform.b2b.model.SaleSendItemVerify;
|
|
|
import com.uas.platform.b2b.support.SystemSession;
|
|
|
+import com.uas.platform.core.model.Status;
|
|
|
|
|
|
@Service
|
|
|
public class PurchaseNotifyServiceImpl implements PurchaseNotifyService {
|
|
|
@@ -37,8 +41,10 @@ public class PurchaseNotifyServiceImpl implements PurchaseNotifyService {
|
|
|
private SaleSendItemVerifyDao saleSendItemVerifyDao;
|
|
|
|
|
|
@Override
|
|
|
- public List<PurchaseNotice> convertPurchaseNotify(List<PurchaseNotify> notifies) {
|
|
|
+ public List<List<PurchaseNotice>> convertPurchaseNotify(List<PurchaseNotify> notifies) {
|
|
|
+ List<List<PurchaseNotice>> allNotices = new ArrayList<List<PurchaseNotice>>();
|
|
|
List<PurchaseNotice> notices = new ArrayList<PurchaseNotice>();
|
|
|
+ List<PurchaseNotice> oppNotices = new ArrayList<PurchaseNotice>();
|
|
|
for (PurchaseNotify notify : notifies) {
|
|
|
PurchaseNotice notice = notify.convert();
|
|
|
List<PurchaseNotice> existNotices = purchaseNoticeDao.findByEnUUAndSourceId(notice.getEnUU(), notice.getSourceId());
|
|
|
@@ -50,9 +56,43 @@ public class PurchaseNotifyServiceImpl implements PurchaseNotifyService {
|
|
|
notice.setOrderItemId(notice.getOrderItem().getId());
|
|
|
notices.add(notice);
|
|
|
}
|
|
|
+ } else {// 对现有的单据,
|
|
|
+ PurchaseNotice existNotice = existNotices.get(0);
|
|
|
+ SimpleDateFormat dateFormat = new SimpleDateFormat("MM月dd日");
|
|
|
+ existNotice.setSendStatus((short) Status.NOT_UPLOAD.value());//对卖家传输状态 待上传
|
|
|
+ if(existNotice.getEndQty() <= notice.getQty()) {
|
|
|
+ // 已发货数小于或等于新的需求数,修改平台上的需求数为已发货数,将已发货数量传回买家ERP修改发货提醒的数量
|
|
|
+ if(StringUtils.hasText(existNotice.getRemark())) {
|
|
|
+ existNotice.setRemark(existNotice.getRemark() + ";" +
|
|
|
+ dateFormat.format(new Date()) + "修改需求数量" +
|
|
|
+ existNotice.getQty() + "变为" + existNotice.getEndQty());
|
|
|
+ } else {
|
|
|
+ existNotice.setRemark(dateFormat.format(new Date()) + "修改需求数量" +
|
|
|
+ existNotice.getQty() + "变为" + existNotice.getEndQty());
|
|
|
+ }
|
|
|
+ existNotice.setQty(existNotice.getEndQty());//需求数量
|
|
|
+ existNotice.setStatus((short) Status.REPLIED.value());//状态 已回复
|
|
|
+ oppNotices.add(existNotice);
|
|
|
+ notices.add(existNotice);
|
|
|
+ } else {
|
|
|
+ // 已发货数大于新的需求数,修改平台上的需求数为新的需求数
|
|
|
+ if(StringUtils.hasText(existNotice.getRemark())) {
|
|
|
+ existNotice.setRemark(existNotice.getRemark() + ";" +
|
|
|
+ dateFormat.format(new Date()) + "修改需求数量" +
|
|
|
+ existNotice.getQty() + "变为" + notice.getQty());
|
|
|
+ } else {
|
|
|
+ existNotice.setRemark(dateFormat.format(new Date()) + "修改需求数量" +
|
|
|
+ existNotice.getQty() + "变为" + notice.getQty());
|
|
|
+ }
|
|
|
+ existNotice.setQty(notice.getQty());// 需求数量
|
|
|
+ existNotice.setDelivery(notice.getDelivery());// 交期
|
|
|
+ notices.add(existNotice);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- return notices;
|
|
|
+ allNotices.add(notices);
|
|
|
+ allNotices.add(oppNotices);
|
|
|
+ return allNotices;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -106,11 +146,15 @@ public class PurchaseNotifyServiceImpl implements PurchaseNotifyService {
|
|
|
public List<SaleSendItemVerify> convertAcceptNotifyVerify(List<AcceptNotifyVerify> verifies) {
|
|
|
List<SaleSendItemVerify> sendItemVerifies = new ArrayList<SaleSendItemVerify>();
|
|
|
for (AcceptNotifyVerify verify : verifies) {
|
|
|
- SaleSendItemVerify sendItemVerify = verify.convert();
|
|
|
- List<SaleSendItem> items = saleSendItemDao.findBySendAndNumber(verify.getB2b_ss_id(), verify.getAnd_detno());
|
|
|
- if (items.size() > 0) {
|
|
|
- sendItemVerify.setSendItemId(items.get(0).getId());
|
|
|
- sendItemVerifies.add(sendItemVerify);
|
|
|
+ List<SaleSendItemVerify> verifies2 = saleSendItemVerifyDao.findByCustUUAndSourceId(
|
|
|
+ SystemSession.getUser().getEnterprise().getUu(), verify.getVad_id());
|
|
|
+ if(verifies2.size() == 0) {
|
|
|
+ SaleSendItemVerify sendItemVerify = verify.convert();
|
|
|
+ List<SaleSendItem> items = saleSendItemDao.findBySendAndNumber(verify.getB2b_ss_id(), verify.getAnd_detno());
|
|
|
+ if (items.size() > 0) {
|
|
|
+ sendItemVerify.setSendItemId(items.get(0).getId());
|
|
|
+ sendItemVerifies.add(sendItemVerify);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
return sendItemVerifies;
|