Forráskód Böngészése

主动报价物料数据修改

hejq 7 éve
szülő
commit
5382f1021c

+ 29 - 1
src/main/java/com/uas/platform/b2b/erp/model/Quotation.java

@@ -14,7 +14,7 @@ import java.util.*;
  * @author yingp
  *
  */
-public class Quotation {
+public class Quotation extends KeyEntity {
 
 	private long qu_id;
 	private long cu_uu;
@@ -215,4 +215,32 @@ public class Quotation {
 		this.details = details;
 	}
 
+	/**
+	 * 主键值
+	 *
+	 * @return
+	 */
+	@Override
+	public Object getKey() {
+		return null;
+	}
+
+	/**
+	 * 获取物料编号
+	 * <per>
+	 * 有可能是主表带出明细数据,所以用List封装
+	 * </per>
+	 *
+	 * @return
+	 */
+	@Override
+	public List<String> getProductCode() {
+		List<String> codeStr = new ArrayList<>();
+		if (!CollectionUtils.isEmpty(details)) {
+			details.forEach(detail -> {
+				codeStr.add(detail.getQd_custprodcode());
+			});
+		}
+		return codeStr;
+	}
 }

+ 6 - 7
src/main/java/com/uas/platform/b2b/erp/model/QuotationDetail.java

@@ -1,16 +1,15 @@
 package com.uas.platform.b2b.erp.model;
 
+import com.uas.platform.b2b.model.ProductInfo;
+import com.uas.platform.b2b.model.SaleQuotationItem;
+import com.uas.platform.b2b.model.SaleQuotationPrice;
+import org.apache.commons.collections.CollectionUtils;
+
 import java.util.ArrayList;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
 
-import org.apache.commons.collections.CollectionUtils;
-
-import com.uas.platform.b2b.model.Product;
-import com.uas.platform.b2b.model.SaleQuotationItem;
-import com.uas.platform.b2b.model.SaleQuotationPrice;
-
 /**
  * 供应商主动报价明细
  * 
@@ -142,7 +141,7 @@ public class QuotationDetail {
 		item.setBrand(this.qd_brand);
 		item.setVendorprodcode(this.qd_prodcode);
 		item.setLeadtime(this.qd_leadtime);
-		Product product = new Product();
+		ProductInfo product = new ProductInfo();
 		product.setCode(this.qd_custprodcode);
 		item.setProduct(product);
 		item.setCustProductCode(this.qd_custprodcode);

+ 1 - 1
src/main/java/com/uas/platform/b2b/erp/service/QuotationService.java

@@ -16,7 +16,7 @@ public interface QuotationService {
 	 * @param quotations
 	 * @return map 包含要保存的信息和返回的信息
 	 */
-	Map<String, List<SaleQuotationItem>> convertQuotation(List<Quotation> quotations);
+	Map<String, List<SaleQuotationItem>> convertQuotation(List<Quotation> quotations) throws Exception;
 
 	/**
 	 * 平台的主动报价的采纳结果,转为卖家ERP的主动报价的采纳结果

+ 12 - 10
src/main/java/com/uas/platform/b2b/erp/service/impl/QuotationServiceImpl.java

@@ -6,6 +6,7 @@ import com.uas.platform.b2b.erp.model.QuotationDecide;
 import com.uas.platform.b2b.erp.service.QuotationService;
 import com.uas.platform.b2b.erp.service.VendorService;
 import com.uas.platform.b2b.model.*;
+import com.uas.platform.b2b.ps.ProductUtils;
 import com.uas.platform.b2b.support.SystemSession;
 import com.uas.platform.core.model.Constant;
 import org.apache.commons.collections.CollectionUtils;
@@ -36,12 +37,12 @@ public class QuotationServiceImpl implements QuotationService {
 	private VendorService vendorService;
 
 	@Override
-	public Map<String, List<SaleQuotationItem>> convertQuotation(List<Quotation> quotations) {
+	public Map<String, List<SaleQuotationItem>> convertQuotation(List<Quotation> quotations) throws Exception {
 		Map<String, List<SaleQuotationItem>> mapSaleQuotationItem = new HashMap<String, List<SaleQuotationItem>>();
 		List<SaleQuotationItem> saveItems = new ArrayList<SaleQuotationItem>();
 		List<SaleQuotationItem> resItems = new ArrayList<SaleQuotationItem>();
 		long enUU = SystemSession.getUser().getEnterprise().getUu();
-        final String appId = "uas";// 应用来源
+        final String appId = "uas";
 		for (Quotation quotation : quotations) {
 			// 先查看是否已存在
 			List<SaleQuotation> quotations2 = saleQuotationDao.findByEnUUAndCode(enUU, quotation.getQu_code());
@@ -50,7 +51,7 @@ public class QuotationServiceImpl implements QuotationService {
 				List<Vendor> vendors = vendorDao.findByMyEnUUAndVendUU(saleQuotation.getCustUU(),
 						saleQuotation.getEnUU());
 				Vendor vendor = null;
-				if (vendors.size() > 0) {// 存在对应的供应商资料
+				if (vendors.size() > 0) {
 					vendor = vendors.get(0);
 					// 如果主动报价单中的客户联系人uu号为空 或 无效,则设为供应商资料中的客户联系人
 					if (saleQuotation.getCustUserUU() == null) {
@@ -74,7 +75,8 @@ public class QuotationServiceImpl implements QuotationService {
 				} else {// 不存在对应的供应商资料,增加供应商关系
 					vendor = addVendor(saleQuotation);
 					if (null != vendor) {
-                        vendorService.addPartnerShipRecord(vendor, appId); // 添加供应商关系同时增加合作伙伴关系记录
+						// 添加供应商关系同时增加合作伙伴关系记录
+                        vendorService.addPartnerShipRecord(vendor, appId);
 					}
 				}
 				if (vendor != null && vendor.getMyEnUU() != null) {
@@ -84,13 +86,12 @@ public class QuotationServiceImpl implements QuotationService {
 							SaleQuotationItem item = it.next();
 							item.setQuotation(saleQuotation);
 							// 取平台的产品ID
-							Product product = item.getProduct();
+							ProductInfo product = item.getProduct();
 							// 查找客户是否存在对应的物料号。
-							List<Product> products = productDao.findByEnUUAndCode(vendor.getMyEnUU(),
+							List<Product> productList = ProductUtils.findByEnUUAndCode(vendor.getMyEnUU(),
 									product.getCode());
-							if (products.size() > 0) {
-								item.setProduct(products.get(0));
-								item.setProductId(products.get(0).getId());
+							if (productList.size() > 0) {
+								item.setProductId(productList.get(0).getId());
 								item.setErpDate(new Date());
 								saveItems.add(item);
 							} else {
@@ -98,7 +99,8 @@ public class QuotationServiceImpl implements QuotationService {
 								resItem.setQuotation(new SaleQuotation());
 								resItem.setNumber(item.getNumber());
 								resItem.getQuotation().setCode(saleQuotation.getCode());
-								resItems.add(resItem);// 这里存储不能保存的明细,返回到erp,显示在备注中。
+                                // 这里存储不能保存的明细,返回到erp,显示在备注中。
+								resItems.add(resItem);
 								it.remove();
 							}
 						}