提交人:陈绍鑫

日期:2025/6/19 12:00
内容:收款处理列表插件
This commit is contained in:
陈绍鑫 2025-06-19 11:23:46 +08:00
parent b1dddf8de3
commit 26e38d18ae
1 changed files with 135 additions and 0 deletions

View File

@ -0,0 +1,135 @@
package shkd.sys.sys.plugin.list;
import com.alibaba.fastjson.JSON;
import kd.bos.dataentity.entity.DynamicObjectCollection;
import kd.bos.dataentity.resource.ResManager;
import kd.bos.entity.datamodel.ListSelectedRowCollection;
import kd.bos.form.*;
import kd.bos.form.events.AfterDoOperationEventArgs;
import kd.bos.form.events.BeforeDoOperationEventArgs;
import kd.bos.form.operate.AbstractOperate;
import kd.bos.form.plugin.IFormPlugin;
import kd.bos.list.BillList;
import kd.bos.list.plugin.AbstractListPlugin;
import kd.bos.orm.query.QFilter;
import kd.bos.servicehelper.QueryServiceHelper;
import kd.bos.util.StringUtils;
import kd.fi.cas.business.helper.ManualMatchHelper;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;
public class ReceivingBillListPlugin extends AbstractListPlugin {
@Override
public void beforeDoOperation(BeforeDoOperationEventArgs args) {
AbstractOperate operate = (AbstractOperate)args.getSource();
String opKey = operate.getOperateKey();
BillList billList = (BillList)this.getControl("billlistap");
ListSelectedRowCollection selectedRows = billList.getSelectedRows();
if ("matchdetail1".equals(opKey)) {
ManualMatchHelper.verifySameOrg(selectedRows, "cas_recbill", this.getView(), args);
}
}
@Override
public void afterDoOperation(AfterDoOperationEventArgs e) {
BillList list = (BillList)this.getView().getControl("billlistap");
ListSelectedRowCollection selectedRows = list.getSelectedRows();
if ("matchdetail1".equals(e.getOperateKey())) {
bizBillMatchDetail1(this.getView(), e, selectedRows, this, list.getEntityId(), "org,accountbank,currency");
}
}
public static void bizBillMatchDetail1(IFormView view, AfterDoOperationEventArgs e, ListSelectedRowCollection selectedRows, IFormPlugin listener, String entityName, String fields) {
AbstractOperate op = (AbstractOperate)e.getSource();
String noMatchBillNoStr = op.getOption().containsVariable("noMatchBillNo") ? op.getOption().getVariableValue("noMatchBillNo") : null;
LinkedHashMap<Long, String> noMatchBillMap = StringUtils.isNotEmpty(noMatchBillNoStr) ? (LinkedHashMap) JSON.parseObject(noMatchBillNoStr, LinkedHashMap.class) : new LinkedHashMap();
if (!selectedRows.isEmpty() && noMatchBillMap.size() == selectedRows.getPrimaryKeyValues().length) {
view.showTipNotification(ResManager.loadKDString("所选单据无需匹配交易明细。", "ManualMatchHelper_1", "fi-cas-business", new Object[0]));
} else {
boolean isSuccess = e.getOperationResult() == null ? false : e.getOperationResult().isSuccess();
boolean selectedPass = isSuccess && noMatchBillMap.isEmpty();
if (!selectedRows.isEmpty() && !selectedPass) {
if (!noMatchBillMap.isEmpty()) {
Set<Object> selectedIdSet = (Set) Stream.of(selectedRows.getPrimaryKeyValues()).collect(Collectors.toSet());
Set<Long> noMatchIdSet = noMatchBillMap.keySet();
selectedIdSet.removeAll(noMatchIdSet);
view.getPageCache().put("manualmatchid", JSON.toJSONString(selectedIdSet));
List<String> noMatchBillNoMsg = new ArrayList(noMatchBillMap.size());
Iterator var14 = noMatchBillMap.values().iterator();
String title;
while(var14.hasNext()) {
title = (String)var14.next();
String tip = String.format(ResManager.loadKDString("%1$s无需匹配交易明细。", "ManualMatchHelper_2", "fi-cas-business", new Object[0]), title);
noMatchBillNoMsg.add(tip);
}
String detail = String.join("\r\n", noMatchBillNoMsg);
title = ResManager.loadKDString("所选单据中存在无需匹配交易明细的业务单据,点击是,可针对需要匹配的业务单据发起匹配;点击否,返回列表界面重新选择业务单据发起匹配。", "ManualMatchHelper_3", "fi-cas-business", new Object[0]);
view.showConfirm(title, detail, MessageBoxOptions.YesNo, ConfirmTypes.Default, new ConfirmCallBackListener("CONFIRM_MANUALMATCH", listener));
}
} else {
FormShowParameter fsp = new FormShowParameter();
fsp.setFormId("shkd_cas_addmanualmatch");
fsp.getOpenStyle().setShowType(ShowType.MainNewTabPage);
fsp.setCustomParam("ismergerows", false);
Object[] pks = selectedRows.getPrimaryKeyValues();
if (selectedPass && pks.length > 0) {
setFspCustomParams(fsp, entityName, fields, pks);
}
view.showForm(fsp);
}
}
}
private static void setFspCustomParams(FormShowParameter fsp, String entityName, String fields, Object[] pks) {
DynamicObjectCollection bill = QueryServiceHelper.query(entityName, "id," + fields, new QFilter[]{new QFilter("id", "in", pks)});
String[] fieldArr = fields.split(",");
Set<Object> orgId = (Set)bill.stream().map((b) -> {
return b.get(fieldArr[0]);
}).collect(Collectors.toSet());
Set acctBankId;
Set currencyId;
if (fieldArr.length == 5) {
acctBankId = (Set)bill.stream().filter((b) -> {
return (Long)b.get(fieldArr[1]) != 0L;
}).map((b) -> {
return (Long)b.get(fieldArr[1]);
}).collect(Collectors.toSet());
Set<Long> acctBankIdSell = (Set)bill.stream().filter((b) -> {
return (Long)b.get(fieldArr[2]) != 0L;
}).map((b) -> {
return (Long)b.get(fieldArr[2]);
}).collect(Collectors.toSet());
acctBankId.addAll(acctBankIdSell);
currencyId = (Set)bill.stream().filter((b) -> {
return (Long)b.get(fieldArr[3]) != 0L;
}).map((b) -> {
return (Long)b.get(fieldArr[3]);
}).collect(Collectors.toSet());
Set<Long> currencyIdSell = (Set)bill.stream().filter((b) -> {
return (Long)b.get(fieldArr[4]) != 0L;
}).map((b) -> {
return (Long)b.get(fieldArr[4]);
}).collect(Collectors.toSet());
currencyId.addAll(currencyIdSell);
} else {
acctBankId = (Set)bill.stream().map((b) -> {
return (Long)b.get(fieldArr[1]);
}).collect(Collectors.toSet());
currencyId = (Set)bill.stream().map((b) -> {
return (Long)b.get(fieldArr[2]);
}).collect(Collectors.toSet());
}
fsp.setCustomParam("filter_org", orgId.toArray()[0]);
fsp.setCustomParam("filter_accountbank", acctBankId);
fsp.setCustomParam("filter_currency", currencyId);
fsp.setCustomParam("bizbillname", entityName);
fsp.setCustomParam("bizbillid", Arrays.asList(pks));
}
}