Merge remote-tracking branch 'origin/main'

This commit is contained in:
wenlukang1 2025-06-30 18:29:41 +08:00
commit 813dd64baa
3 changed files with 201 additions and 1 deletions

View File

@ -47,6 +47,11 @@ import java.util.*;
* 单据界面插件
*/
public class CasRecbillFormPlugin extends AbstractBillPlugIn implements BeforeF7SelectListener {
public static final List<String> update_fk = Arrays.asList("payername","payeracctbanknum","f7_payerbank","payerbankname");//拉单需要更新的付款方
public static final List<String> update_sk = Arrays.asList("org", "payeebank", "accountbank");//拉单需要更新的收款方
public static final List<String> update_qt = Arrays.asList("receivingtype");//拉单需要更新的其他字段
@Override
public void registerListener(EventObject e) {
//监听基础资料
@ -316,13 +321,32 @@ public class CasRecbillFormPlugin extends AbstractBillPlugIn implements BeforeF7
DynamicObject cdm_drafttradebill = BusinessDataServiceHelper.loadSingle(Long.parseLong(iPageCache.get("shkd_ywclid")), "cdm_drafttradebill");
dynamicObject.set("shkd_ywcl",cdm_drafttradebill);
}
for (int i = 0; i < update_fk.size(); i++) {
if (this.getModel().getValue(update_fk.get(i))!=null&& !this.getModel().getValue(update_fk.get(i)).equals("")){
dynamicObject.set(update_fk.get(i),this.getModel().getValue(update_fk.get(i)));
}
}
for (int i = 0; i < update_sk.size(); i++) {
if (this.getModel().getValue(update_sk.get(i))!=null&& !this.getModel().getValue(update_sk.get(i)).equals("")){
dynamicObject.set(update_sk.get(i),this.getModel().getValue(update_sk.get(i)));
}
}
for (int i = 0; i < update_qt.size(); i++) {
if (this.getModel().getValue(update_qt.get(i))!=null&& !this.getModel().getValue(update_qt.get(i)).equals("")){
dynamicObject.set(update_qt.get(i),this.getModel().getValue(update_qt.get(i)));
}
}
((IBillModel)this.getView().getModel()).push(dynamicObject);
DynamicObjectCollection entry = (DynamicObjectCollection) this.getView().getModel().getValue("entry");
if (entry.size()>1){
this.getView().getModel().deleteEntryRow("entry", 1);
}
DynamicObjectCollection cas_draftinfo = (DynamicObjectCollection) this.getView().getModel().getValue("cas_draftinfo");
if (cas_draftinfo.size()>1){
this.getView().getModel().deleteEntryRow("cas_draftinfo", 0);
}
this.getView().updateView();
result.release(refProvider, this.getView().getModel().getDataEntityType());
SaveServiceHelper.save(new DynamicObject[]{this.getView().getModel().getDataEntity()});
} else {

View File

@ -52,6 +52,10 @@ import static kd.bos.servicehelper.workflow.WorkflowServiceHelper.abandonByBusie
public class PaymentProcessingBillPlugin extends AbstractBillPlugIn implements Plugin, BeforeF7SelectListener {
private static final Log logger = LogFactory.getLog(PaymentProcessingBillPlugin.class);
public static final List<String> update_sk = Arrays.asList("payeename","payeebanknum","recaccbankname","payeecurrency","payeebank","payeebankname","recbanknumber");//拉单需要更新的收款方
public static final List<String> update_fk = Arrays.asList("org", "payeracctbank", "payerbank");//拉单需要更新的付款方
public static final List<String> update_qt = Arrays.asList("paymenttype");//拉单需要更新的其他字段
@Override
public void registerListener(EventObject e) {
Toolbar tbmain = this.getView().getControl("tbmain");
@ -240,6 +244,21 @@ public class PaymentProcessingBillPlugin extends AbstractBillPlugIn implements P
DynamicObject cdm_drafttradebill = BusinessDataServiceHelper.loadSingle(Long.parseLong(iPageCache.get("shkd_ywclid")), "cdm_drafttradebill");
dynamicObject.set("shkd_ywcl",cdm_drafttradebill);
}
for (int i = 0; i < update_fk.size(); i++) {
if (this.getModel().getValue(update_fk.get(i))!=null&& !this.getModel().getValue(update_fk.get(i)).equals("")){
dynamicObject.set(update_fk.get(i),this.getModel().getValue(update_fk.get(i)));
}
}
for (int i = 0; i < update_sk.size(); i++) {
if (this.getModel().getValue(update_sk.get(i))!=null&& !this.getModel().getValue(update_sk.get(i)).equals("")){
dynamicObject.set(update_sk.get(i),this.getModel().getValue(update_sk.get(i)));
}
}
for (int i = 0; i < update_qt.size(); i++) {
if (this.getModel().getValue(update_qt.get(i))!=null&& !this.getModel().getValue(update_qt.get(i)).equals("")){
dynamicObject.set(update_qt.get(i),this.getModel().getValue(update_qt.get(i)));
}
}
((IBillModel)this.getView().getModel()).push(dynamicObject);
DynamicObjectCollection entry = (DynamicObjectCollection) this.getView().getModel().getValue("entry");
if (entry.size()>1){

View File

@ -0,0 +1,157 @@
package shkd.sys.sys.plugin.operation;
import kd.bos.algo.DataSet;
import kd.bos.algo.Row;
import kd.bos.dataentity.OperateOption;
import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.entity.operate.result.OperationResult;
import kd.bos.entity.plugin.AbstractOperationServicePlugIn;
import kd.bos.entity.plugin.args.ReturnOperationArgs;
import kd.bos.logging.Log;
import kd.bos.logging.LogFactory;
import kd.bos.orm.query.QCP;
import kd.bos.orm.query.QFilter;
import kd.bos.servicehelper.BusinessDataServiceHelper;
import kd.bos.servicehelper.QueryServiceHelper;
import kd.bos.servicehelper.botp.BFTrackerServiceHelper;
import kd.bos.servicehelper.operation.OperationServiceHelper;
import kd.tmc.cdm.common.constant.CdmEntityConst;
import kd.tmc.cdm.common.enums.BillStatusEnum;
import kd.tmc.cdm.common.enums.DraftTradeTypeEnum;
import kd.tmc.cdm.common.enums.DraftTranStatusEnum;
import shkd.sys.sys.plugin.task.redeemTaskPlugin;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;
public class DrafttradebillOP extends AbstractOperationServicePlugIn {
private static final Log logger = LogFactory.getLog(DrafttradebillOP.class);
@Override
public void onReturnOperation(ReturnOperationArgs e) {
super.onReturnOperation(e);
List<Object> successPkIds = e.getOperationResult().getSuccessPkIds();//执行成功的数据
for (Object successPkId : successPkIds) {
Long id=(Long)successPkId;
// DynamicObject cdm_drafttradebill = BusinessDataServiceHelper.loadSingle(id, "cdm_drafttradebill");
Map<String, HashSet<Long>> srcBills = BFTrackerServiceHelper.findSourceBills("cdm_drafttradebill", new Long[]{id});
if (srcBills.containsKey(CdmEntityConst.CDM_PAYABLEBILL)) {
HashSet<Long> ar_invoice = srcBills.get(CdmEntityConst.CDM_PAYABLEBILL);
// 获取第一个元素如果集合不为空
Long firstElement = ar_invoice.stream().findFirst().orElse(null);
DynamicObject cdm_payablebill = BusinessDataServiceHelper.loadSingle(firstElement, CdmEntityConst.CDM_PAYABLEBILL);
String draftbillstatus = cdm_payablebill.getString("draftbillstatus");
String settlementtype = cdm_payablebill.getString("draftbilltype.settlementtype");
if (!draftbillstatus.equals("payoffed")){
continue;
}
if (!settlementtype.equals("5")){
continue;
}
QFilter filter = new QFilter("id", QCP.equals, firstElement);
DynamicObject[] CDM_PAYABLEBILLs = BusinessDataServiceHelper.load(CdmEntityConst.CDM_PAYABLEBILL, "id,billno,amount,billstatus,draftbilltranstatus", filter.toArray());
Set<Object> draftIds = (Set)Arrays.stream(CDM_PAYABLEBILLs).map((s) -> {
return s.getPkValue();
}).collect(Collectors.toSet());
QFilter filter1 = new QFilter("entrys.draftbill.id", "in", draftIds);
filter1.and("tradetype", "=", DraftTradeTypeEnum.REDEEM.getValue());
filter1.and("draftbilltranstatus", "=", "success");
Map<Long, BigDecimal> amountMap = new HashMap(16);
DataSet rows = QueryServiceHelper.queryDataSet("PayableBillRedeemValidator", "cdm_drafttradebill", "entrys.draftbill.id,entrys.billamt", filter1.toArray(), (String)null);
Throwable var8 = null;
try {
Iterator var9 = rows.iterator();
while(var9.hasNext()) {
Row row = (Row)var9.next();
Long draftBillId = row.getLong("entrys.draftbill.id");
BigDecimal orDefault = (BigDecimal)amountMap.getOrDefault(draftBillId, BigDecimal.ZERO);
amountMap.put(draftBillId, orDefault.add(row.getBigDecimal("entrys.billamt")));
}
} catch (Throwable throwable) {
var8 = throwable;
throw throwable;
} finally {
if (rows != null) {
if (var8 != null) {
try {
rows.close();
} catch (Throwable var25) {
var8.addSuppressed(var25);
}
} else {
rows.close();
}
}
}
try {
Long draftId = cdm_payablebill.getLong("id");
BigDecimal sumBillAmt = (BigDecimal)amountMap.getOrDefault(draftId, BigDecimal.ZERO);
BigDecimal amount = cdm_payablebill.getBigDecimal("amount");
boolean isNoAmount = sumBillAmt.compareTo(BigDecimal.ZERO) != 0 && amount.compareTo(sumBillAmt) == 0;
String billStatus = cdm_payablebill.getString("billstatus");
String draftbillTranstatus = cdm_payablebill.getString("draftbilltranstatus");
if (!BillStatusEnum.AUDIT.getValue().equals(billStatus) || !DraftTranStatusEnum.SUCCESS.getValue().equals(draftbillTranstatus) || isNoAmount) {
logger.info("单据编号:"+cdm_payablebill.getString("billno")+"单据状态为“已审核”且票据交易状态为“交易成功”的未兑付票据才能操作票据兑付。");
continue;
}
List<Long> dataEntitys = new ArrayList<>();
dataEntitys.add(Long.parseLong(cdm_payablebill.getString("id")));
OperateOption option = OperateOption.create();
option.setVariableValue("tradeType", "redeem");
option.setVariableValue("remarks", "后台下推");
//调用方法执行数据 - 自动兑付下推
OperationResult operationResult = OperationServiceHelper.executeOperate("pushandsaveredeem",
CdmEntityConst.CDM_PAYABLEBILL,
dataEntitys.toArray(new Object[]{}), option);
if (operationResult.getAllErrorInfo().size()!=0) {
logger.info("单据编号:"+cdm_payablebill.getString("billno")+"后台生单失败,原因:"+operationResult.getAllErrorInfo().get(0).getMessage());
String targetpkvalue = operationResult.getAllErrorInfo().get(0).getErrorCustInfos().get("targetpkvalue");
DynamicObject cdm_drafttradebill = BusinessDataServiceHelper.loadSingle(targetpkvalue, "cdm_drafttradebill");
OperationResult delete = OperationServiceHelper.executeOperate("delete", "cdm_drafttradebill", new DynamicObject[]{cdm_drafttradebill}, OperateOption.create());
if (delete.isSuccess()==true){
logger.info("删除单据编号:"+cdm_payablebill.getString("billno")+"成功");
}else {
logger.info("删除单据编号:"+cdm_payablebill.getString("billno")+"失败,原因:"+delete.getMessage());
}
}else {
logger.info("单据编号:"+cdm_payablebill.getString("billno")+"后台生单成功");
//根据源单id查询源单下游单据
Map<String, HashSet<Long>> tarBills = BFTrackerServiceHelper.findTargetBills("cdm_payablebill", new Long[]{cdm_payablebill.getLong("id")});
//返回的Map对象 如果有数据 String 对应的是 目标单据标识 value 对应的目标单ids
Set<DynamicObject> bill = new HashSet<DynamicObject>();
if (tarBills.containsKey("cdm_drafttradebill")) {
HashSet<Long> billId = tarBills.get("cdm_drafttradebill");
for (Long aLong : billId) {
QFilter billfilter = new QFilter("tradetype", QCP.equals, "redeem");
billfilter.and(new QFilter("billstatus", QCP.equals, "C"));
billfilter.and(new QFilter("id", QCP.equals, aLong));
DynamicObject cdm_drafttradebill = BusinessDataServiceHelper.loadSingle("cdm_drafttradebill", "id,billno", billfilter.toArray());
if (cdm_drafttradebill != null) {
OperationResult operation = OperationServiceHelper.executeOperate("drawbillsave", "cdm_drafttradebill", new Object[]{aLong}, OperateOption.create());
if (operation.isSuccess()) {
logger.info("单据编号:" + cdm_drafttradebill.getString("billno") + "确认交易成功");
} else {
logger.info("单据编号:" + cdm_drafttradebill.getString("billno") + "确认交易失败,请检查交易状态或者手动操作");
}
}
}
}
}
} catch (NumberFormatException exception) {
logger.error("单据编号:"+cdm_payablebill.getString("billno")+"后台生单錯誤原因:"+exception.getMessage());
}
}
}
}
}