|
@@ -0,0 +1,86 @@
|
|
|
|
+package fi.ar.opplugin;
|
|
|
|
+
|
|
|
|
+import kd.bos.dataentity.entity.DynamicObject;
|
|
|
|
+import kd.bos.entity.botp.runtime.ConvertOperationResult;
|
|
|
|
+import kd.bos.entity.botp.runtime.PushArgs;
|
|
|
|
+import kd.bos.entity.datamodel.ListSelectedRow;
|
|
|
|
+import kd.bos.entity.plugin.AbstractOperationServicePlugIn;
|
|
|
|
+import kd.bos.entity.plugin.args.BeginOperationTransactionArgs;
|
|
|
|
+import kd.bos.orm.query.QCP;
|
|
|
|
+import kd.bos.orm.query.QFilter;
|
|
|
|
+import kd.bos.servicehelper.BusinessDataServiceHelper;
|
|
|
|
+import kd.bos.servicehelper.botp.ConvertServiceHelper;
|
|
|
|
+import kd.bos.metadata.botp.ConvertRuleReader;
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
+import java.util.List;
|
|
|
|
+import java.util.Set;
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * @author cjz
|
|
|
|
+ * @date 2024/9/10 15:21
|
|
|
|
+ * @description:应收挂账当下推坏账计提
|
|
|
|
+ */
|
|
|
|
+public class FinarbillPushOpPlugin extends AbstractOperationServicePlugIn {
|
|
|
|
+
|
|
|
|
+ private static String ar_finarbill="ar_finarbill";//应收挂账单标识源单
|
|
|
|
+ private static String ar_baddebtlossbill="ar_baddebtlossbill";//坏账损失单标识目标单
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void beginOperationTransaction(BeginOperationTransactionArgs e) {
|
|
|
|
+ super.beginOperationTransaction(e);
|
|
|
|
+ if ("sdpush".equals(e.getOperationKey())){
|
|
|
|
+ //是否诉讼类费用为是
|
|
|
|
+ QFilter filter=new QFilter("nckd_checkboxfield1", QCP.equals,true);
|
|
|
|
+ //未结算金额不为0
|
|
|
|
+// filter.and("unsettleamount", QCP.not_equals,0);
|
|
|
|
+ DynamicObject[] dynamicObjects=BusinessDataServiceHelper.load(ar_finarbill,"id",new QFilter[]{filter});
|
|
|
|
+ //获取转换规则id
|
|
|
|
+ ConvertRuleReader read=new ConvertRuleReader();
|
|
|
|
+ List<String> loadRuleIds = read.loadRuleIds(ar_finarbill, ar_baddebtlossbill, false);
|
|
|
|
+ for (int i=0;i< dynamicObjects.length;i++)
|
|
|
|
+ {
|
|
|
|
+ //获取应收挂帐单
|
|
|
|
+ DynamicObject info= BusinessDataServiceHelper
|
|
|
|
+ .loadSingle(dynamicObjects[i].getPkValue(),dynamicObjects[i].getDynamicObjectType().getName());
|
|
|
|
+ //源单id
|
|
|
|
+ Long pkid=info.getLong("id");
|
|
|
|
+ // 下推参数,设置所选数据项
|
|
|
|
+ List<ListSelectedRow> selectedRows=new ArrayList<>();
|
|
|
|
+ ListSelectedRow selectedRow=new ListSelectedRow(pkid);
|
|
|
|
+ //设置需要下推的单据名
|
|
|
|
+// selectedRow.setEntryEntityKey("nckd_salarydistribute");
|
|
|
|
+ // 设置需要下推的单据体行内码:按分录下推时必须设置
|
|
|
|
+ selectedRow.setEntryPrimaryKeyValue(pkid);
|
|
|
|
+ selectedRows.add(selectedRow);
|
|
|
|
+ // 创建下推参数
|
|
|
|
+ PushArgs pushArgs = new PushArgs();
|
|
|
|
+ // 源单标识
|
|
|
|
+ pushArgs.setSourceEntityNumber(ar_finarbill);
|
|
|
|
+ // 目标单据标识
|
|
|
|
+ pushArgs.setTargetEntityNumber(ar_baddebtlossbill);
|
|
|
|
+ // 生成转换结果报告
|
|
|
|
+ pushArgs.setBuildConvReport(true);
|
|
|
|
+ //传入下推使用的转换规则id,不填则使用默认规则
|
|
|
|
+ pushArgs.setRuleId(loadRuleIds.get(0));
|
|
|
|
+ //下推默认保存
|
|
|
|
+ pushArgs.setAutoSave(true);
|
|
|
|
+ // 设置源单选中的数据包
|
|
|
|
+ pushArgs.setSelectedRows(selectedRows);
|
|
|
|
+ // 执行下推操作
|
|
|
|
+ ConvertOperationResult result = ConvertServiceHelper.push(pushArgs);
|
|
|
|
+ //获取下推目标单id
|
|
|
|
+ Set<Object> targetBillIds = result.getTargetBillIds();
|
|
|
|
+ if(!targetBillIds.isEmpty()) {
|
|
|
|
+ this.operationResult.setShowMessage(true);
|
|
|
|
+ this.operationResult.setSuccess(true);
|
|
|
|
+ this.operationResult.setMessage("下推坏账处理单成功");
|
|
|
|
+ }else {
|
|
|
|
+ this.operationResult.setShowMessage(true);
|
|
|
|
+ this.operationResult.setSuccess(false);
|
|
|
|
+ this.operationResult.setMessage("下推坏账处理单失败");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+}
|