|
|
@@ -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();
|
|
|
}
|
|
|
}
|