|
@@ -0,0 +1,76 @@
|
|
|
+package nckd.jimin.jyyy.fi.plugin.operate;
|
|
|
+
|
|
|
+import com.kingdee.util.StringUtils;
|
|
|
+import kd.bos.dataentity.OperateOption;
|
|
|
+import kd.bos.dataentity.entity.DynamicObject;
|
|
|
+import kd.bos.dataentity.entity.DynamicObjectCollection;
|
|
|
+import kd.bos.entity.EntityMetadataCache;
|
|
|
+import kd.bos.entity.MainEntityType;
|
|
|
+import kd.bos.entity.operate.result.OperationResult;
|
|
|
+import kd.bos.entity.plugin.AbstractOperationServicePlugIn;
|
|
|
+import kd.bos.entity.plugin.PreparePropertysEventArgs;
|
|
|
+import kd.bos.entity.plugin.args.AfterOperationArgs;
|
|
|
+import kd.bos.logging.Log;
|
|
|
+import kd.bos.logging.LogFactory;
|
|
|
+import kd.bos.servicehelper.BusinessDataServiceHelper;
|
|
|
+import kd.bos.servicehelper.operation.OperationServiceHelper;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 插件说明:保存按钮,触发分录对应报销单的预算返还操作
|
|
|
+ * 表单标识:SAP凭证(nckd_sapsjszjb)
|
|
|
+ * @author wanghaiwu_kd
|
|
|
+ * @date 2025/07/31
|
|
|
+ */
|
|
|
+public class SapVoucherSaveOpPlugin extends AbstractOperationServicePlugIn {
|
|
|
+ private static final Log logger = LogFactory.getLog(AbstractOperationServicePlugIn.class);
|
|
|
+
|
|
|
+ public void onPreparePropertys(PreparePropertysEventArgs e) {
|
|
|
+ super.onPreparePropertys(e);
|
|
|
+
|
|
|
+ List<String> fieldKeys = e.getFieldKeys();
|
|
|
+
|
|
|
+ fieldKeys.add("entryentity");
|
|
|
+ fieldKeys.add("entryentity.nckd_bxbillno");
|
|
|
+ fieldKeys.add("entryentity.nckd_bxbillid");
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void afterExecuteOperationTransaction(AfterOperationArgs e) {
|
|
|
+ super.afterExecuteOperationTransaction(e);
|
|
|
+
|
|
|
+ DynamicObject[] billEntities = e.getDataEntities();
|
|
|
+
|
|
|
+ List<Long> publicIds = new ArrayList<>();
|
|
|
+ for (DynamicObject billInfo : billEntities) {
|
|
|
+ DynamicObjectCollection entrys = billInfo.getDynamicObjectCollection("entryentity");
|
|
|
+ for(DynamicObject entry : entrys){
|
|
|
+ String billNo = entry.getString("nckd_bxbillno");
|
|
|
+ Long billId = entry.getLong("nckd_bxbillid");
|
|
|
+ String entityName = "";
|
|
|
+ if("CL".equals(billNo.substring(0, 2))){
|
|
|
+
|
|
|
+ } else {
|
|
|
+ entityName = "er_publicreimbursebill";
|
|
|
+ }
|
|
|
+
|
|
|
+ if(StringUtils.isEmpty(entityName)){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ publicIds.add(billId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ String operationKey = "nckd_returnbudget";
|
|
|
+ if(publicIds.size() > 0) {
|
|
|
+ String entityName = "er_publicreimbursebill";
|
|
|
+ MainEntityType entityType= EntityMetadataCache.getDataEntityType(entityName);
|
|
|
+ DynamicObject[] publicBills = BusinessDataServiceHelper.load(publicIds.toArray(), entityType);
|
|
|
+
|
|
|
+ //调用报销付款单预算返还操作
|
|
|
+ OperationResult returnResult = OperationServiceHelper.executeOperate(operationKey, entityName, publicBills, OperateOption.create());
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|