diff --git a/main/java/shjh/jhzj7/fi/fi/plugin/operate/ClearAccountBillOperation.java b/main/java/shjh/jhzj7/fi/fi/plugin/operate/ClearAccountBillOperation.java index e4e8dd4..84b934b 100644 --- a/main/java/shjh/jhzj7/fi/fi/plugin/operate/ClearAccountBillOperation.java +++ b/main/java/shjh/jhzj7/fi/fi/plugin/operate/ClearAccountBillOperation.java @@ -51,6 +51,8 @@ public class ClearAccountBillOperation extends AbstractOperationServicePlugIn im private static final String queryRealtion = "select fsid,fsbillid from tk_shjh_clear_account_tc where ftbillid=?;";//查看清账单与收款单的关联关系表 private static final String updateReceivBill = "update T_CAS_ReceivingBill set fk_shjh_qzzt=? where fid=?;";//收款单表头清账状态 + //收款单分录已下推标记改为否 + private static final String updateRecEntryPush = "update T_CAS_ReceivingBillEntry set fk_shjh_pushbill='0' where FEntryID in (select fsid from tk_shjh_clear_account_tc where ftbillid=?);"; private static final String entityName = "shjh_clear_acctdetail";//清账明细单 private static final String userName = "bos_user";//用户 @@ -722,6 +724,9 @@ public class ClearAccountBillOperation extends AbstractOperationServicePlugIn im prinfo = dos[i]; DB.update(DBRoute.of("fi"), updateInvalidStatus, new Object[]{prinfo.getLong("id")}); DB.update(DBRoute.of("fi"), updateDetailStatusByBill, new Object[]{prinfo.getString("id")}); + + //反写上游收款单分录的已下推标记为否,让收款单可以再次下推 + DB.update(DBRoute.of("fi"), updateRecEntryPush, new Object[]{prinfo.getLong("id")}); //处理完成提示 this.operationResult.addSuccessPkId(prinfo.getPkValue()); } diff --git a/main/java/shjh/jhzj7/fi/fi/plugin/operate/RecPushVoucherOperation.java b/main/java/shjh/jhzj7/fi/fi/plugin/operate/RecPushVoucherOperation.java index f90258b..f146b52 100644 --- a/main/java/shjh/jhzj7/fi/fi/plugin/operate/RecPushVoucherOperation.java +++ b/main/java/shjh/jhzj7/fi/fi/plugin/operate/RecPushVoucherOperation.java @@ -179,6 +179,18 @@ public class RecPushVoucherOperation extends AbstractOperationServicePlugIn impl } } +// else{ +// //如果是退预付款 103 则将入参中的PO号和PO行号字段设置值 +// String poNumber = null; +// String poRowNumber = null; +// if(!recBill.getDynamicObjectCollection("entry").isEmpty()){ +// poNumber = recBill.getDynamicObjectCollection("entry").get(0).getString("shjh_purchasenum"); +// poRowNumber = recBill.getDynamicObjectCollection("entry").get(0).getString("shjh_purchaselinenum"); +// } +// if(!JhzjUtils.isEmpty(poNumber)){ +// +// } +// } } String type = recBill.getString(RecFieldsInfo.PAYER_TYPE);//付款人类型 long id = recBill.getLong("payer");//付款人id @@ -522,7 +534,6 @@ public class RecPushVoucherOperation extends AbstractOperationServicePlugIn impl */ private JSONObject createClearItem(DynamicObject entry, String customerNum, String supplierNum, BigDecimal clearAmount) { JSONObject item = new JSONObject(); - //公共字段设置 item.put("BUKRS", entry.getString("e_settleorg.number"));//公司代码-分录结算组织编号 item.put("BELNR", entry.getString("shjh_verificationnum"));//会计凭证编号-原预付款和借款单的凭证号 @@ -541,6 +552,8 @@ public class RecPushVoucherOperation extends AbstractOperationServicePlugIn impl item.put("DMBTR1", clearAmount != null ? clearAmount.toString() : "0"); // 清账金额 // item.put("DMBTR2", ""); // 剩余金额 // item.put("ERLKZ", ""); // 已完成的未清项标识符 + item.put("EBELN", entry.getString("shjh_purchasenum"));//PO号-采购凭证号 + item.put("EBELP", entry.getString("shjh_purchaselinenum"));//PO行号-采购凭证的项目编号 return item; } diff --git a/main/java/shjh/jhzj7/fi/fi/plugin/task/RecPushSapTask.java b/main/java/shjh/jhzj7/fi/fi/plugin/task/RecPushSapTask.java index 70d8a40..093c45d 100644 --- a/main/java/shjh/jhzj7/fi/fi/plugin/task/RecPushSapTask.java +++ b/main/java/shjh/jhzj7/fi/fi/plugin/task/RecPushSapTask.java @@ -29,7 +29,7 @@ public class RecPushSapTask extends AbstractTask implements Plugin { private final static Log logger = LogFactory.getLog(RecPushSapTask.class); - private static final String KEY_REC_BILL = "cas_recbill";//收款单实体标识 + private static final String KEY_REC_BILL = "cas_recbill";//收款单实体标识 T_CAS_ReceivingBill @Override public void execute(RequestContext requestContext, Map map) throws KDException { @@ -60,13 +60,14 @@ public class RecPushSapTask extends AbstractTask implements Plugin { // 配置操作选项(共用) OperateOption operateOption = createStrictOperateOption(); - - // 并行处理两组数据 - CompletableFuture normalFuture = processBillsAsync(normalBills, "pushvoucher", operateOption); - CompletableFuture redFuture = processBillsAsync(redBills, "redpunch", operateOption); - - // 等待所有任务完成 - CompletableFuture.allOf(normalFuture, redFuture).join(); + //先处理负数红冲推送,再处理正数推送 + pushBills(redBills, "redpunch", operateOption); + pushBills(normalBills, "pushvoucher", operateOption); + //异步处理红冲和正数下推--由于不能异步,故注释 +// CompletableFuture redFuture = processBillsAsync(redBills, "redpunch", operateOption); +// CompletableFuture normalFuture = processBillsAsync(normalBills, "pushvoucher", operateOption); +// // 等待所有任务完成 +// CompletableFuture.allOf(redFuture, normalFuture).join(); } // 创建严格的操作选项 @@ -79,6 +80,26 @@ public class RecPushSapTask extends AbstractTask implements Plugin { return option; } + //处理下推 + private void pushBills(List bills, String operation, OperateOption option){ + if (bills.isEmpty()){ + return; + } + try { + DynamicObject[] billArray = bills.toArray(new DynamicObject[0]); + OperationResult result = OperationServiceHelper.executeOperate(operation, KEY_REC_BILL, billArray, option); + + if (result.isSuccess()) { + logger.info(String.format("【%s】批量处理成功:%d 张单据", operation, bills.size())); + } else { + logger.error(String.format("【%s】处理失败:%s", operation, result.getMessage())); + // 可在此添加失败重试逻辑 + } + } catch (Exception e) { + logger.error(String.format("【%s】执行异常:", operation), e); + } + } + // 异步处理单据组 private CompletableFuture processBillsAsync(List bills, String operation, OperateOption option) { return CompletableFuture.runAsync(() -> {