采购入库单审核后将信息写道商品信息中
This commit is contained in:
parent
b357c2c27c
commit
eb89b2d052
|
|
@ -13,6 +13,7 @@ import kd.bos.servicehelper.BusinessDataServiceHelper;
|
|||
import kd.bos.servicehelper.operation.SaveServiceHelper;
|
||||
import kd.sdk.plugin.Plugin;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
|
||||
|
|
@ -35,7 +36,7 @@ public class PurInIotManagePlugin extends AbstractOperationServicePlugIn impleme
|
|||
String billno = dataEntity.getString("billno");
|
||||
QFilter qFilter = new QFilter("billno", QCP.equals, billno);
|
||||
DynamicObject dynamicObject = BusinessDataServiceHelper.loadSingle("im_purinbill",
|
||||
"billentry.producedate,billentry.expirydate,billentry.lotnumber,billentry.tqq9_registration,billentry.material",
|
||||
"billentry.producedate,billentry.expirydate,billentry.lotnumber,billentry.tqq9_registration,billentry.material,billentry.warehouse",
|
||||
qFilter.toArray());
|
||||
DynamicObjectCollection billentry = dynamicObject.getDynamicObjectCollection("billentry");
|
||||
// DynamicObject[] tqq9_goodlotmanages=new DynamicObject[billentry.size()];
|
||||
|
|
@ -72,6 +73,58 @@ public class PurInIotManagePlugin extends AbstractOperationServicePlugIn impleme
|
|||
falg = true;
|
||||
tqq9_goodlotmanages.add(tqq9_goodlotmanage);
|
||||
}
|
||||
|
||||
String warehouseNumber = null;
|
||||
DynamicObject warehouse = entry.getDynamicObject("warehouse");
|
||||
if(warehouse != null){
|
||||
warehouseNumber = warehouse.getString("number");
|
||||
}
|
||||
|
||||
//同时将批次信息写到商城商品信息上
|
||||
QFilter f1 = new QFilter("tqq9_mater.id", "=", "material.id");
|
||||
QFilter f2 = new QFilter("tqq9_isauto", "=", true);
|
||||
DynamicObject[] goodsArr = BusinessDataServiceHelper.load("tqq9_goodspackage", "id,name.number", new QFilter[]{f1, f2});
|
||||
if(goodsArr != null && goodsArr.length > 0){
|
||||
// 物料已经被封装成了商品
|
||||
boolean isExistEntry = false;//在明细中是否能找到对应的商品信息
|
||||
DynamicObjectCollection entryies = goodsArr[0].getDynamicObjectCollection("tqq9_entry");
|
||||
for (DynamicObject entry1 : entryies) {
|
||||
String lotNumber = null;
|
||||
DynamicObject tqq9_lot = entry1.getDynamicObject("tqq9_lot");
|
||||
if(tqq9_lot != null){
|
||||
lotNumber = tqq9_lot.getString("number");
|
||||
}
|
||||
String whNumber = "";
|
||||
DynamicObject wh = entry1.getDynamicObject("tqq9_basedatafield");
|
||||
if(wh != null){
|
||||
whNumber = wh.getString("number");
|
||||
}
|
||||
Date tqq9_productdate = entry1.getDate("tqq9_productdate");
|
||||
Date tqq9_todate = entry1.getDate("tqq9_todate");
|
||||
|
||||
if(lotNumber.equals(lotnumber) && whNumber.equals(warehouseNumber)
|
||||
&& ((tqq9_productdate == null && producedate == null) || (tqq9_productdate.equals(producedate)))
|
||||
&& ((tqq9_todate == null && expirydate == null) || (tqq9_todate.equals(expirydate)))){
|
||||
// 如果现有的商品数据存在
|
||||
BigDecimal tqq9_availablestock = entry1.getBigDecimal("tqq9_availablestock");
|
||||
entry1.set("tqq9_availablestock", tqq9_availablestock.add(entry.getBigDecimal("qty")));
|
||||
BigDecimal tqq9_upstock = entry1.getBigDecimal("tqq9_upstock");
|
||||
entry1.set("tqq9_upstock", tqq9_upstock.add(entry.getBigDecimal("qty")));
|
||||
}
|
||||
}
|
||||
if(!isExistEntry){
|
||||
DynamicObject entry1 = entryies.addNew();
|
||||
entry1.set("tqq9_lot", entry.getDynamicObject("lot"));//批号
|
||||
entry1.set("tqq9_basedatafield", warehouse);//仓库
|
||||
entry1.set("tqq9_productdate", producedate);//生产日期
|
||||
entry1.set("tqq9_todate", expirydate);//到期日期
|
||||
entry1.set("tqq9_availablestock", entry.getBigDecimal("qty"));//到期日期
|
||||
entry1.set("tqq9_upstock", entry.getBigDecimal("qty"));//到期日期
|
||||
}
|
||||
SaveServiceHelper.save(new DynamicObject[]{goodsArr[0]});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
if (falg) {
|
||||
DynamicObject[] objects = new DynamicObject[tqq9_goodlotmanages.size()];
|
||||
|
|
|
|||
Loading…
Reference in New Issue