|
@@ -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);
|
|
|
+
|
|
|
+ filter.and("unsettleamount", QCP.not_equals,0);
|
|
|
+ DynamicObject[] dynamicObjects= BusinessDataServiceHelper.load(ar_finarbill,"id",new QFilter[]{filter});
|
|
|
+
|
|
|
+ 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());
|
|
|
+
|
|
|
+ Long pkid = info.getLong("id");
|
|
|
+
|
|
|
+ List<ListSelectedRow> selectedRows = new ArrayList<>();
|
|
|
+ ListSelectedRow selectedRow = new ListSelectedRow(pkid);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ selectedRow.setEntryPrimaryKeyValue(pkid);
|
|
|
+ selectedRows.add(selectedRow);
|
|
|
+
|
|
|
+ PushArgs pushArgs = new PushArgs();
|
|
|
+
|
|
|
+ pushArgs.setSourceEntityNumber(ar_finarbill);
|
|
|
+
|
|
|
+ pushArgs.setTargetEntityNumber(ar_baddebtlossbill);
|
|
|
+
|
|
|
+ pushArgs.setBuildConvReport(true);
|
|
|
+
|
|
|
+ pushArgs.setRuleId(loadRuleIds.get(0));
|
|
|
+
|
|
|
+ pushArgs.setAutoSave(true);
|
|
|
+
|
|
|
+ pushArgs.setSelectedRows(selectedRows);
|
|
|
+
|
|
|
+ ConvertOperationResult result = ConvertServiceHelper.push(pushArgs);
|
|
|
+
|
|
|
+ Set<Object> targetBillIds = result.getTargetBillIds();
|
|
|
+ if (!targetBillIds.isEmpty()) {
|
|
|
+ log.info("----------------------------下推坏账处理单成功----------------------");
|
|
|
+ } else {
|
|
|
+ log.info("----------------------------下推坏账处理单失败----------------------");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public boolean isSupportReSchedule() {
|
|
|
+ return super.isSupportReSchedule();
|
|
|
+ }
|
|
|
+}
|