From 26e38d18ae975019979908eec752d3da6cc78cfe Mon Sep 17 00:00:00 2001 From: chenshaoxin <1981897232@qq.com> Date: Thu, 19 Jun 2025 11:23:46 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BA=BA=EF=BC=9A=E9=99=88?= =?UTF-8?q?=E7=BB=8D=E9=91=AB=20=E6=97=A5=E6=9C=9F=EF=BC=9A2025/6/19=2012?= =?UTF-8?q?=EF=BC=9A00=20=E5=86=85=E5=AE=B9:=E6=94=B6=E6=AC=BE=E5=A4=84?= =?UTF-8?q?=E7=90=86=E5=88=97=E8=A1=A8=E6=8F=92=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../plugin/list/ReceivingBillListPlugin.java | 135 ++++++++++++++++++ 1 file changed, 135 insertions(+) create mode 100644 sys/shkd-sys-sys/src/main/java/shkd/sys/sys/plugin/list/ReceivingBillListPlugin.java diff --git a/sys/shkd-sys-sys/src/main/java/shkd/sys/sys/plugin/list/ReceivingBillListPlugin.java b/sys/shkd-sys-sys/src/main/java/shkd/sys/sys/plugin/list/ReceivingBillListPlugin.java new file mode 100644 index 0000000..550c82d --- /dev/null +++ b/sys/shkd-sys-sys/src/main/java/shkd/sys/sys/plugin/list/ReceivingBillListPlugin.java @@ -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 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 selectedIdSet = (Set) Stream.of(selectedRows.getPrimaryKeyValues()).collect(Collectors.toSet()); + Set noMatchIdSet = noMatchBillMap.keySet(); + selectedIdSet.removeAll(noMatchIdSet); + view.getPageCache().put("manualmatchid", JSON.toJSONString(selectedIdSet)); + List 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 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 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 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)); + } +}