【泛微接口】采购入库反审核减去商城商品的数量
This commit is contained in:
parent
f166d392f3
commit
a5c8858d76
|
|
@ -0,0 +1,67 @@
|
|||
package tqq9.lc123.cloud.app.plugin.operate.im;
|
||||
|
||||
import kd.bos.dataentity.entity.DynamicObject;
|
||||
import kd.bos.dataentity.entity.DynamicObjectCollection;
|
||||
import kd.bos.dataentity.utils.StringUtils;
|
||||
import kd.bos.entity.operate.result.OperationResult;
|
||||
import kd.bos.entity.plugin.AbstractOperationServicePlugIn;
|
||||
import kd.bos.entity.plugin.args.AfterOperationArgs;
|
||||
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
||||
import kd.bos.servicehelper.operation.SaveServiceHelper;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 采购入库反审核
|
||||
* 减去商城商品中的数量
|
||||
*/
|
||||
public class PurinUnauditSubGoodsQtyPlugin extends AbstractOperationServicePlugIn {
|
||||
|
||||
@Override
|
||||
public void afterExecuteOperationTransaction(AfterOperationArgs e) {
|
||||
super.afterExecuteOperationTransaction(e);
|
||||
OperationResult operationResult = this.getOperationResult();
|
||||
List<Object> successPkIds = operationResult.getSuccessPkIds();
|
||||
for (Object successPkId : successPkIds) {
|
||||
DynamicObject bill = BusinessDataServiceHelper.loadSingle(successPkId, "im_purinbill");
|
||||
DynamicObjectCollection entries = bill.getDynamicObjectCollection("billentry");
|
||||
for (DynamicObject entry : entries) {
|
||||
String lotnumber = entry.getString("lotnumber");
|
||||
DynamicObject warehouse = entry.getDynamicObject("warehouse");
|
||||
String whNumber = warehouse.getString("number");
|
||||
Date producedate = entry.getDate("producedate");
|
||||
Date expirydate = entry.getDate("expirydate");
|
||||
BigDecimal qty = entry.getBigDecimal("qty");
|
||||
DynamicObject tqq9_goods = entry.getDynamicObject("tqq9_goods");
|
||||
if(tqq9_goods != null){
|
||||
tqq9_goods = BusinessDataServiceHelper.loadSingle(tqq9_goods.getPkValue(), tqq9_goods.getDynamicObjectType().getName());
|
||||
DynamicObjectCollection goodsEntries = tqq9_goods.getDynamicObjectCollection("");
|
||||
for (DynamicObject goodsEntry : goodsEntries) {
|
||||
DynamicObject tqq9_lot = goodsEntry.getDynamicObject("tqq9_lot");
|
||||
String lotNumber = tqq9_lot.getString("number");//批次号
|
||||
DynamicObject tqq9_basedatafield = goodsEntry.getDynamicObject("tqq9_basedatafield");
|
||||
String warehouseNumber = tqq9_basedatafield.getString("number");//仓库编码
|
||||
Date tqq9_productdate = goodsEntry.getDate("tqq9_productdate");
|
||||
Date tqq9_todate = goodsEntry.getDate("tqq9_todate");
|
||||
BigDecimal tqq9_availablestock = goodsEntry.getBigDecimal("tqq9_availablestock");
|
||||
BigDecimal tqq9_upstock = goodsEntry.getBigDecimal("tqq9_upstock");
|
||||
|
||||
if(((StringUtils.isBlank(lotNumber) && StringUtils.isBlank(lotnumber)) || lotNumber.equals(lotnumber))
|
||||
&& ((StringUtils.isBlank(whNumber) && StringUtils.isBlank(warehouseNumber)) || whNumber.equals(warehouseNumber))
|
||||
&& ((tqq9_productdate == null && producedate == null) || (tqq9_productdate.equals(producedate)))
|
||||
&& ((tqq9_todate == null && expirydate == null) || (tqq9_todate.equals(expirydate)))){
|
||||
tqq9_availablestock = tqq9_availablestock.subtract(qty);
|
||||
tqq9_upstock = tqq9_upstock.subtract(qty);
|
||||
goodsEntry.set("tqq9_availablestock", tqq9_availablestock);
|
||||
goodsEntry.set("tqq9_upstock", tqq9_upstock);
|
||||
SaveServiceHelper.save(new DynamicObject[]{tqq9_goods});
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue