|
@@ -0,0 +1,95 @@
|
|
|
|
+package fi.ar.task;
|
|
|
|
+
|
|
|
|
+import com.alibaba.druid.support.logging.Log;
|
|
|
|
+import com.alibaba.druid.support.logging.LogFactory;
|
|
|
|
+import kd.bos.context.RequestContext;
|
|
|
|
+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.exception.KDException;
|
|
|
|
+import kd.bos.metadata.botp.ConvertRuleReader;
|
|
|
|
+import kd.bos.orm.query.QCP;
|
|
|
|
+import kd.bos.orm.query.QFilter;
|
|
|
|
+import kd.bos.schedule.api.MessageHandler;
|
|
|
|
+import kd.bos.schedule.executor.AbstractTask;
|
|
|
|
+import kd.bos.servicehelper.BusinessDataServiceHelper;
|
|
|
|
+import kd.bos.servicehelper.botp.ConvertServiceHelper;
|
|
|
|
+import sys.sc.task.UpdateImpairmentDailyTask;
|
|
|
|
+
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
+import java.util.List;
|
|
|
|
+import java.util.Map;
|
|
|
|
+import java.util.Set;
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * @author cjz
|
|
|
|
+ * @date 2024/9/10 16:42
|
|
|
|
+ * @description:应收单下推坏账处理单调度计划,每月
|
|
|
|
+ */
|
|
|
|
+public class FinarbillPushTask extends AbstractTask {
|
|
|
|
+ private static final Log log = LogFactory.getLog(FinarbillPushTask.class);
|
|
|
|
+ private static String ar_finarbill="ar_finarbill";//应收挂账单标识源单
|
|
|
|
+ private static String ar_baddebtlossbill="ar_baddebtlossbill";//坏账损失单标识目标单
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public MessageHandler getMessageHandle() {
|
|
|
|
+ return super.getMessageHandle();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void execute(RequestContext requestContext, Map<String, Object> map) throws KDException {
|
|
|
|
+ //是否诉讼类费用为是
|
|
|
|
+ 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 (DynamicObject dynamicObject : dynamicObjects) {
|
|
|
|
+ //获取应收挂帐单
|
|
|
|
+ DynamicObject info = BusinessDataServiceHelper
|
|
|
|
+ .loadSingle(dynamicObject.getPkValue(), dynamicObject.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()) {
|
|
|
|
+ log.info("----------------------------下推坏账处理单成功----------------------");
|
|
|
|
+ } else {
|
|
|
|
+ log.info("----------------------------下推坏账处理单失败----------------------");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public boolean isSupportReSchedule() {
|
|
|
|
+ return super.isSupportReSchedule();
|
|
|
|
+ }
|
|
|
|
+}
|