Browse Source

发货提醒方法调整,效率优化

hejq 7 years ago
parent
commit
0d8c2d554d

+ 3 - 15
src/main/java/com/uas/platform/b2b/erp/controller/PurchaseNotifyController.java

@@ -24,7 +24,6 @@ import org.springframework.web.bind.annotation.ResponseBody;
 
 
 import java.io.UnsupportedEncodingException;
 import java.io.UnsupportedEncodingException;
 import java.net.URLDecoder;
 import java.net.URLDecoder;
-import java.util.ArrayList;
 import java.util.List;
 import java.util.List;
 
 
 /**
 /**
@@ -55,23 +54,12 @@ public class PurchaseNotifyController {
 	 */
 	 */
 	@RequestMapping(method = RequestMethod.POST)
 	@RequestMapping(method = RequestMethod.POST)
 	@ResponseBody
 	@ResponseBody
-	public List<PurchaseNotify> saveNotifies(@RequestParam("data") String data) throws UnsupportedEncodingException {
-		List<PurchaseNotify> modifiedNotifies = new ArrayList<PurchaseNotify>();
+	public void saveNotifies(@RequestParam("data") String data) throws UnsupportedEncodingException {
 		String jsonStr = URLDecoder.decode(data, "UTF-8");
 		String jsonStr = URLDecoder.decode(data, "UTF-8");
 		List<PurchaseNotify> notifies = FlexJsonUtils.fromJsonArray(jsonStr, PurchaseNotify.class);
 		List<PurchaseNotify> notifies = FlexJsonUtils.fromJsonArray(jsonStr, PurchaseNotify.class);
-		List<List<PurchaseNotice>> lists = purchaseNotifyService.convertPurchaseNotify(notifies);
-		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);
-			}
-		}
+		List<PurchaseNotice> notices = purchaseNotifyService.convertPurchaseNotify(notifies);
+		purchaseNoticeService.save(notices);
 		logger.log("送货提醒", "上传送货提醒", notifies.size());
 		logger.log("送货提醒", "上传送货提醒", notifies.size());
-		return modifiedNotifies;
 	}
 	}
 
 
 	/**
 	/**

+ 7 - 4
src/main/java/com/uas/platform/b2b/erp/service/PurchaseNotifyService.java

@@ -1,13 +1,16 @@
 package com.uas.platform.b2b.erp.service;
 package com.uas.platform.b2b.erp.service;
 
 
-import java.util.List;
-
-import com.uas.platform.b2b.erp.model.*;
+import com.uas.platform.b2b.erp.model.AcceptNotify;
+import com.uas.platform.b2b.erp.model.AcceptNotifyConfirm;
+import com.uas.platform.b2b.erp.model.AcceptNotifyVerify;
+import com.uas.platform.b2b.erp.model.PurchaseNotify;
 import com.uas.platform.b2b.model.PurchaseNotice;
 import com.uas.platform.b2b.model.PurchaseNotice;
 import com.uas.platform.b2b.model.SaleSend;
 import com.uas.platform.b2b.model.SaleSend;
 import com.uas.platform.b2b.model.SaleSendItem;
 import com.uas.platform.b2b.model.SaleSendItem;
 import com.uas.platform.b2b.model.SaleSendItemVerify;
 import com.uas.platform.b2b.model.SaleSendItemVerify;
 
 
+import java.util.List;
+
 public interface PurchaseNotifyService {
 public interface PurchaseNotifyService {
 
 
 	/**
 	/**
@@ -16,7 +19,7 @@ public interface PurchaseNotifyService {
 	 * @param notifies
 	 * @param notifies
 	 * @return
 	 * @return
 	 */
 	 */
-	List<List<PurchaseNotice>> convertPurchaseNotify(List<PurchaseNotify> notifies);
+	List<PurchaseNotice> convertPurchaseNotify(List<PurchaseNotify> notifies);
 
 
 	/**
 	/**
 	 * 将平台的发货单,转为买家ERP的收料通知单
 	 * 将平台的发货单,转为买家ERP的收料通知单

+ 7 - 10
src/main/java/com/uas/platform/b2b/erp/service/impl/PurchaseNotifyServiceImpl.java

@@ -36,20 +36,17 @@ public class PurchaseNotifyServiceImpl implements PurchaseNotifyService {
 	private SaleSendItemVerifyDao saleSendItemVerifyDao;
 	private SaleSendItemVerifyDao saleSendItemVerifyDao;
 
 
 	@Override
 	@Override
-	public List<List<PurchaseNotice>> convertPurchaseNotify(List<PurchaseNotify> notifies) {
-		List<List<PurchaseNotice>> allNotices = new ArrayList<List<PurchaseNotice>>();
+	public List<PurchaseNotice> convertPurchaseNotify(List<PurchaseNotify> notifies) {
 		List<PurchaseNotice> notices = new ArrayList<PurchaseNotice>();
 		List<PurchaseNotice> notices = new ArrayList<PurchaseNotice>();
 		for (PurchaseNotify notify : notifies) {
 		for (PurchaseNotify notify : notifies) {
 			PurchaseNotice notice = notify.convert();
 			PurchaseNotice notice = notify.convert();
 			List<PurchaseNotice> existNotices = purchaseNoticeDao.findByEnUUAndSourceId(notice.getEnUU(),
 			List<PurchaseNotice> existNotices = purchaseNoticeDao.findByEnUUAndSourceId(notice.getEnUU(),
 					notice.getSourceId());
 					notice.getSourceId());
 			if (CollectionUtils.isEmpty(existNotices)) {// sourceId不存在新增保存
 			if (CollectionUtils.isEmpty(existNotices)) {// sourceId不存在新增保存
-				List<PurchaseOrderItem> orderItems = purchaseOrderItemDao.findByEnUUAndOrderCodeAndNumber(
-						notice.getEnUU(), notice.getOrderItem().getOrder().getCode(),
-						notice.getOrderItem().getNumber());
-				if (!CollectionUtils.isEmpty(orderItems)) {
-				    notice.setOrderItem(orderItems.get(0));
-					notice.setOrderItemId(orderItems.get(0).getId());
+				List<Long> idList = purchaseOrderItemDao.findIdByEnUUAndOrderCodeAndNumber(notice.getEnUU(),
+                        notice.getOrderItem().getOrder().getCode(), notice.getOrderItem().getNumber());
+				if (!CollectionUtils.isEmpty(idList)) {
+					notice.setOrderItemId(idList.get(0));
 					notices.add(notice);
 					notices.add(notice);
 				}
 				}
 			} else {// 对现有的单据,修改
 			} else {// 对现有的单据,修改
@@ -76,6 +73,7 @@ public class PurchaseNotifyServiceImpl implements PurchaseNotifyService {
 						existNotice.setQty(notice.getQty());// 需求数量
 						existNotice.setQty(notice.getQty());// 需求数量
 						existNotice.setDelivery(notice.getDelivery());// 交期
 						existNotice.setDelivery(notice.getDelivery());// 交期
 						notices.add(existNotice);
 						notices.add(existNotice);
+
 					}
 					}
 				} else {
 				} else {
 					String existDeliveryStr = "空";
 					String existDeliveryStr = "空";
@@ -94,8 +92,7 @@ public class PurchaseNotifyServiceImpl implements PurchaseNotifyService {
 				}
 				}
 			}
 			}
 		}
 		}
-		allNotices.add(notices);
-		return allNotices;
+		return notices;
 	}
 	}
 
 
 
 

+ 2 - 2
src/main/java/com/uas/platform/b2b/model/PurchaseNotice.java

@@ -83,8 +83,8 @@ public class PurchaseNotice implements Serializable {
 	/**
 	/**
 	 * 客户采购单明细
 	 * 客户采购单明细
 	 */
 	 */
-	@OneToOne(cascade = { CascadeType.REFRESH })
-	@JoinColumn(name = "pn_pdid", insertable = false, updatable = false, nullable = false)
+	@OneToOne(cascade = { CascadeType.ALL }, fetch = FetchType.EAGER)
+	@JoinColumn(name = "pn_pdid", insertable = false, updatable = false)
 	private PurchaseOrderItem orderItem;
 	private PurchaseOrderItem orderItem;
 
 
 	@Column(name = "pn_pdid")
 	@Column(name = "pn_pdid")