lc/lc123/cloud/app/plugin/operate/pm/ReceiptNoticeSaveToUpdPurbi...

66 lines
2.8 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package tqq9.lc123.cloud.app.plugin.operate.pm;
import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.dataentity.entity.DynamicObjectCollection;
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.botp.BFTrackerServiceHelper;
import kd.bos.servicehelper.operation.SaveServiceHelper;
import java.math.BigDecimal;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
/**
* 收货通知单 保存 & 删除插件
* 操作后上查采购订单,判断该采购订单是否全部下推收获通知
* 如果采购订单明细行的采购数量 != 关联数量,则将采购订单下拉字段【是否可做收获通知 tqq9_sfkzsh】赋值为“true”否则赋值为“false”
*/
public class ReceiptNoticeSaveToUpdPurbillOp extends AbstractOperationServicePlugIn {
@Override
public void afterExecuteOperationTransaction(AfterOperationArgs e) {
super.afterExecuteOperationTransaction(e);
OperationResult operationResult = this.getOperationResult();
List<Object> successPkIds = operationResult.getSuccessPkIds();
for (Object successPkId : successPkIds) {
Long id = (Long) successPkId;
Long[] idArr = new Long[]{id};
Map<String, HashSet<Long>> map = BFTrackerServiceHelper.findSourceBills("pm_receiptnotice", idArr);
for (String s : map.keySet()) {
if("pm_purorderbill".equals(s)){
HashSet<Long> longs = map.get(s);
for (Long aLong : longs) {
DynamicObject bill = BusinessDataServiceHelper.loadSingle(aLong, s);
DynamicObjectCollection entries = bill.getDynamicObjectCollection("billentry");
boolean isEquals = true;//采购订单分录中是否所有行中,采购数量 = 关联数量
for (DynamicObject entry : entries) {
BigDecimal qty = entry.getBigDecimal("qty");
BigDecimal joinqty = entry.getBigDecimal("joinqty");
if(qty.compareTo(joinqty) != 0){
isEquals = false;
break;
}
}
if(isEquals){
bill.set("tqq9_sfkzsh", "false");
}else{
bill.set("tqq9_sfkzsh", "true");
}
SaveServiceHelper.save(new DynamicObject[]{bill});
}
}
}
}
}
}