|
@@ -0,0 +1,108 @@
|
|
|
|
+package kd.cosmic.jkjt.tmc.cfm.formplugin.confirm;
|
|
|
|
+
|
|
|
|
+import kd.bos.dataentity.entity.DynamicObject;
|
|
|
|
+import kd.bos.dataentity.entity.DynamicObjectCollection;
|
|
|
|
+import kd.bos.dataentity.resource.ResManager;
|
|
|
|
+import kd.bos.form.MessageTypes;
|
|
|
|
+import kd.bos.form.control.EntryGrid;
|
|
|
|
+import kd.bos.form.control.events.BeforeItemClickEvent;
|
|
|
|
+import kd.bos.list.plugin.AbstractListPlugin;
|
|
|
|
+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.QueryServiceHelper;
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
+import java.util.EventObject;
|
|
|
|
+import java.util.List;
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * 调出确认校验
|
|
|
|
+ * 调出业务确认:nckd_cim_busconfirm_l_ifa
|
|
|
|
+ * @author wanghaiwu_kd
|
|
|
|
+ * @date 2025/09/25
|
|
|
|
+ */
|
|
|
|
+public class BusinessConfirmInvestCusListPlugin extends AbstractListPlugin {
|
|
|
|
+ private static Log logger = LogFactory.getLog(BusinessConfirmInvestCusListPlugin.class);
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void registerListener(EventObject e) {
|
|
|
|
+ super.registerListener(e);
|
|
|
|
+
|
|
|
|
+ this.addItemClickListeners(new String[]{"toolbarap"});
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void beforeItemClick(BeforeItemClickEvent evt) {
|
|
|
|
+ super.beforeItemClick(evt);
|
|
|
|
+
|
|
|
|
+ switch (evt.getItemKey()) {
|
|
|
|
+ case "bar_confirm":
|
|
|
|
+ List<DynamicObject> selectedData = this.getSelectedData();
|
|
|
|
+
|
|
|
|
+ List<String> contractList = (List)selectedData.stream().filter((dy) -> {
|
|
|
|
+ return "contract".equals(dy.getString("businesstype"));
|
|
|
|
+ }).map((dy) -> {
|
|
|
|
+ return dy.getString("billno");
|
|
|
|
+ }).collect(Collectors.toList());
|
|
|
|
+
|
|
|
|
+ //如果是合同登记,需要校验是否存在已审核的【调出登记请示】
|
|
|
|
+ if (!contractList.isEmpty()) {
|
|
|
|
+ if (selectedData.size() > 0) {
|
|
|
|
+ List<String> failsBills = new ArrayList();
|
|
|
|
+ for (String contractNo : contractList) {
|
|
|
|
+ QFilter qFilter = new QFilter("billstatus", QCP.equals, "C");
|
|
|
|
+ qFilter.and(new QFilter("nckd_ifainnum", QCP.equals, contractNo));
|
|
|
|
+
|
|
|
|
+ boolean exists = QueryServiceHelper.exists("nckd_cfm_loanifa_outapply", qFilter.toArray());
|
|
|
|
+
|
|
|
|
+ if (!exists) {
|
|
|
|
+ failsBills.add(String.format(ResManager.loadKDString("%s:必须关联调出登记请示且审核通过", "BusinessConfirmInitPlugin_1", "tmc-cfm-formplugin", new Object[0]), contractNo));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (failsBills.size() > 0) {
|
|
|
|
+ this.getView().showMessage("以下单据不能执行确认操作", String.join("\n", failsBills), MessageTypes.Default);
|
|
|
|
+ evt.setCancel(true);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private List<DynamicObject> getSelectedData() {
|
|
|
|
+ List<Long> selectedIdList = this.getSelectedIdList();
|
|
|
|
+ DynamicObject dynFormObj = this.getModel().getDataEntity(true);
|
|
|
|
+ DynamicObjectCollection dataList = dynFormObj.getDynamicObjectCollection("entryentity");
|
|
|
|
+ if (selectedIdList == null) {
|
|
|
|
+ return null;
|
|
|
|
+ } else {
|
|
|
|
+ List<DynamicObject> selectedList = (List)dataList.stream().filter((i) -> {
|
|
|
|
+ return selectedIdList.contains(i.getLong("id"));
|
|
|
|
+ }).collect(Collectors.toList());
|
|
|
|
+ return selectedList;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ protected List<Long> getSelectedIdList() {
|
|
|
|
+ EntryGrid entry = (EntryGrid)this.getControl("entryentity");
|
|
|
|
+ int[] rows = entry.getSelectRows();
|
|
|
|
+ if (rows != null && rows.length != 0) {
|
|
|
|
+ List<Long> idList = new ArrayList(rows.length);
|
|
|
|
+ int[] var4 = rows;
|
|
|
|
+ int var5 = rows.length;
|
|
|
|
+
|
|
|
|
+ for(int var6 = 0; var6 < var5; ++var6) {
|
|
|
|
+ int index = var4[var6];
|
|
|
|
+ idList.add((Long)this.getModel().getValue("id", index));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return idList;
|
|
|
|
+ } else {
|
|
|
|
+ this.getView().showTipNotification(ResManager.loadKDString("请选择要执行的数据。", "AbstractTmcDyncListPlugin_0", "tmc-fbp-formplugin", new Object[0]));
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|