|
|
@@ -1,6 +1,7 @@
|
|
|
package com.uas.platform.b2b.erp.service.impl;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
+import java.util.Iterator;
|
|
|
import java.util.List;
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
@@ -43,15 +44,18 @@ public class PurchaseAPBillServiceImpl implements PurchaseAPBillService{
|
|
|
Enterprise vendor = enterpriseDao.findEnterpriseByUu(apBill.getAb_vendoruu());
|
|
|
if(apBills2.size() == 0 && vendor != null) {
|
|
|
PurchaseApBill purchaseApBill = apBill.convert();
|
|
|
- for(PurchaseApBillItem apBillItem : purchaseApBill.getItems()){
|
|
|
+ Iterator<PurchaseApBillItem> items = purchaseApBill.getItems().iterator();
|
|
|
+ while(items.hasNext()) {
|
|
|
+ PurchaseApBillItem apBillItem = items.next();
|
|
|
List<Product> products = productDao.findByEnUUAndCode(enUU, apBillItem.getProduct().getCode());
|
|
|
if(products.size() > 0) {
|
|
|
apBillItem.setProduct(products.get(0));
|
|
|
apBillItem.setProductId(products.get(0).getId());
|
|
|
apBillItem.setaPBill(purchaseApBill);
|
|
|
apBillItems.add(apBillItem);
|
|
|
- } else
|
|
|
- purchaseApBill.getItems().remove(apBillItem);
|
|
|
+ } else {
|
|
|
+ items.remove();
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|