|
|
@@ -1,16 +1,10 @@
|
|
|
package com.uas.platform.b2b.service.impl;
|
|
|
|
|
|
import com.uas.platform.b2b.core.util.ContextUtils;
|
|
|
-import com.uas.platform.b2b.dao.CommonDao;
|
|
|
-import com.uas.platform.b2b.dao.PagingReleaseCountDao;
|
|
|
-import com.uas.platform.b2b.dao.PurchaseApBillDao;
|
|
|
-import com.uas.platform.b2b.dao.PurchaseApBillItemDao;
|
|
|
+import com.uas.platform.b2b.dao.*;
|
|
|
import com.uas.platform.b2b.erp.model.ProdInOutRefreshPrice;
|
|
|
import com.uas.platform.b2b.event.PurchaseApBillSaveEvent;
|
|
|
-import com.uas.platform.b2b.model.PurchaseAcceptItem;
|
|
|
-import com.uas.platform.b2b.model.PurchaseApBill;
|
|
|
-import com.uas.platform.b2b.model.PurchaseApBillItem;
|
|
|
-import com.uas.platform.b2b.model.SearchFilter;
|
|
|
+import com.uas.platform.b2b.model.*;
|
|
|
import com.uas.platform.b2b.search.SearchService;
|
|
|
import com.uas.platform.b2b.service.PurchaseApBillService;
|
|
|
import com.uas.platform.b2b.support.SystemSession;
|
|
|
@@ -53,6 +47,9 @@ public class PurchaseApBillServiceImpl implements PurchaseApBillService {
|
|
|
@Autowired
|
|
|
private CommonDao commonDao;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ProductDao productDao;
|
|
|
+
|
|
|
@Override
|
|
|
public void save(List<PurchaseApBillItem> apBillItems) {
|
|
|
List<PurchaseApBillItem> newApBillItems = purchaseApBillItemDao.save(apBillItems);
|
|
|
@@ -169,16 +166,25 @@ public class PurchaseApBillServiceImpl implements PurchaseApBillService {
|
|
|
|
|
|
@Override
|
|
|
public void refreshPrice(List<ProdInOutRefreshPrice> prodInOuts) {
|
|
|
+ Long enuu = SystemSession.getUser().getEnterprise().getUu();
|
|
|
if(!CollectionUtils.isEmpty(prodInOuts)) {
|
|
|
for(ProdInOutRefreshPrice prod : prodInOuts) {
|
|
|
- // 更新明细单价、税率
|
|
|
- String sql = " merge into purc$apbillitem i using purc$apbill a on (i.papi_papid = a.pab_id and i.papi_pdinoutno = '" + prod.getPbu_inoutno() + "' and a.pad_enuu = " + SystemSession.getUser().getEnterprise().getUu() + ")" +
|
|
|
- " when matched then update set i.papi_price = " + prod.getPbu_orderprice() + ", i.papi_apamount = i.papi_thisvoqty * " + prod.getPbu_orderprice();
|
|
|
- if(null != prod.getPbu_taxrate())
|
|
|
- sql = sql + ",i.papi_taxrate = " + prod.getPbu_taxrate();
|
|
|
- commonDao.getJdbcTemplate().update(sql);
|
|
|
- // 更新主表的税金合计
|
|
|
- purchaseApBillDao.refreshAmountAndTaxSum(SystemSession.getUser().getEnterprise().getUu(), prod.getPbu_inoutno());
|
|
|
+ // 只更新一条数据,这里只能用物料编号去判断,采购单序号等无法判断
|
|
|
+ List<Product> prods = productDao.findByEnUUAndCode(enuu, prod.getPd_prodcode());
|
|
|
+ if(!CollectionUtils.isEmpty(prods)) {
|
|
|
+ // 更新明细单价、税率
|
|
|
+ String sql = " merge into purc$apbillitem i using purc$apbill a "
|
|
|
+ + "on (i.papi_papid = a.pab_id and i.papi_pdinoutno = '" + prod.getPbu_inoutno()
|
|
|
+ + "' and a.pad_enuu = " + enuu + "and i.papi_product = " + prods.get(0).getId() + ")"
|
|
|
+ + " when matched then "
|
|
|
+ + "update set i.papi_price = " + prod.getPbu_orderprice() + ", i.papi_apamount = i.papi_thisvoqty * " + prod.getPbu_orderprice()
|
|
|
+ + ", i.papi_amount = i.papi_price * i.papi_qty";
|
|
|
+ if(null != prod.getPbu_taxrate())
|
|
|
+ sql = sql + ",i.papi_taxrate = " + prod.getPbu_taxrate();
|
|
|
+ commonDao.getJdbcTemplate().update(sql);
|
|
|
+ // 更新主表的税金合计
|
|
|
+ purchaseApBillDao.refreshAmountAndTaxSum(SystemSession.getUser().getEnterprise().getUu(), prod.getPbu_inoutno());
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|