38 lines
1.7 KiB
Java
38 lines
1.7 KiB
Java
|
|
package tqq9.lc123.cloud.app.plugin.operate.pm;
|
|||
|
|
|
|||
|
|
import kd.bos.dataentity.entity.DynamicObject;
|
|||
|
|
import kd.bos.dataentity.entity.DynamicObjectCollection;
|
|||
|
|
import kd.bos.entity.plugin.AbstractOperationServicePlugIn;
|
|||
|
|
import kd.bos.entity.plugin.args.BeforeOperationArgs;
|
|||
|
|
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
|||
|
|
import kd.bos.servicehelper.operation.SaveServiceHelper;
|
|||
|
|
import kd.sdk.plugin.Plugin;
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* 单据操作插件
|
|||
|
|
* 采购单点击关闭操作后,将已关闭数量=数量-已入库数量
|
|||
|
|
*/
|
|||
|
|
public class PurOlderCloseCountOp extends AbstractOperationServicePlugIn implements Plugin {
|
|||
|
|
|
|||
|
|
@Override
|
|||
|
|
public void beforeExecuteOperationTransaction(BeforeOperationArgs e) {
|
|||
|
|
super.beforeExecuteOperationTransaction(e);
|
|||
|
|
DynamicObject[] dataEntities = e.getDataEntities();
|
|||
|
|
String operationKey = e.getOperationKey();
|
|||
|
|
if(dataEntities.length>0 && "bizclose".equals(operationKey)){
|
|||
|
|
for(DynamicObject purOlder:dataEntities){
|
|||
|
|
purOlder = BusinessDataServiceHelper.loadSingle(purOlder.getPkValue(), "pm_purorderbill");
|
|||
|
|
DynamicObjectCollection billentry = purOlder.getDynamicObjectCollection("billentry");
|
|||
|
|
if(billentry.size()>0){
|
|||
|
|
for (DynamicObject dynamicObject : billentry) {
|
|||
|
|
Integer invqty = dynamicObject.getInt("invqty");//已入库数量
|
|||
|
|
Integer qty = dynamicObject.getInt("qty");//数量
|
|||
|
|
Integer tqq9_qtyfield = qty-invqty;//已关闭数量
|
|||
|
|
dynamicObject.set("tqq9_qtyfield",tqq9_qtyfield);
|
|||
|
|
}
|
|||
|
|
SaveServiceHelper.save(new DynamicObject[]{purOlder});
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|