diff --git a/main/java/shjh/jhzj7/fi/fi/plugin/form/ClaimFormPlugin.java b/main/java/shjh/jhzj7/fi/fi/plugin/form/ClaimFormPlugin.java new file mode 100644 index 0000000..c6ba079 --- /dev/null +++ b/main/java/shjh/jhzj7/fi/fi/plugin/form/ClaimFormPlugin.java @@ -0,0 +1,83 @@ +package shjh.jhzj7.fi.fi.plugin.form; + +import kd.bos.dataentity.entity.DynamicObject; +import kd.bos.entity.datamodel.events.PropertyChangedArgs; +import kd.bos.form.field.BasedataEdit; +import kd.bos.form.field.events.BeforeF7SelectEvent; +import kd.bos.form.field.events.BeforeF7SelectListener; +import kd.bos.form.plugin.AbstractFormPlugin; +import kd.bos.list.ListShowParameter; +import kd.bos.orm.query.QCP; +import kd.bos.orm.query.QFilter; +import kd.sdk.plugin.Plugin; + +import java.util.EventObject; + +/** + * 认领单,收款单,付款单表单插件 + * shjh_cas_claimbill_ext + * shjh_cas_recbill_ext + * shjh_cas_paybill_ext + * 根据业务大类过滤业务小类 + */ +public class ClaimFormPlugin extends AbstractFormPlugin implements Plugin , BeforeF7SelectListener { + + @Override + public void registerListener(EventObject e) { + super.registerListener(e); + String entityId = this.getView().getEntityId(); + String type_small = "shjh_bizsmall"; + String type_big = "shjh_bizbig"; + //收款单(业务大类标识不同)_认领单,付款单 + if ("cas_recbill".equals(entityId)) { + type_big = "shjh_bizebig"; + } + //业务小类 + BasedataEdit shjh_bizsmall = this.getView().getControl(type_small); + shjh_bizsmall.addBeforeF7SelectListener(this); + //业务大类 + BasedataEdit shjh_bizbig = this.getView().getControl(type_big); + shjh_bizbig.addBeforeF7SelectListener(this); + } + @Override + public void beforeF7Select(BeforeF7SelectEvent beforeF7SelectEvent) { + String entityId = this.getView().getEntityId(); + String type = "shjh_bizbig"; + //收款单(业务大类标识不同)_认领单,付款单 + if ("cas_recbill".equals(entityId)) { + type = "shjh_bizebig"; + } + String name = beforeF7SelectEvent.getProperty().getName(); + switch (name) { + case "shjh_bizsmall": + QFilter q1 = null; + DynamicObject shjh_bizbig = this.getModel().getDataEntity().getDynamicObject(type); + if (null != shjh_bizbig) { + q1 = new QFilter("shjh_bizbigtype.id", QCP.equals, shjh_bizbig.getLong("id")); + } + ListShowParameter listShowParameter = (ListShowParameter) beforeF7SelectEvent.getFormShowParameter(); + listShowParameter.getListFilterParameter().setFilter(q1); + break; + default: + break; + } + } + + @Override + public void propertyChanged(PropertyChangedArgs e) { + super.propertyChanged(e); + String name = e.getProperty().getName(); + switch (name) { + //业务大类(付款单,认领单) + case "shjh_bizbig": + this.getView().getModel().setValue("shjh_bizsmall", null); + break; + //收款单 + case "shjh_bizebig": + this.getView().getModel().setValue("shjh_bizsmall", null); + break; + default: + break; + } + } +} diff --git a/main/java/shjh/jhzj7/fi/fi/plugin/form/RecBillFromPlugin.java b/main/java/shjh/jhzj7/fi/fi/plugin/form/RecBillFromPlugin.java index e528668..ae3ee1c 100644 --- a/main/java/shjh/jhzj7/fi/fi/plugin/form/RecBillFromPlugin.java +++ b/main/java/shjh/jhzj7/fi/fi/plugin/form/RecBillFromPlugin.java @@ -2,8 +2,12 @@ package shjh.jhzj7.fi.fi.plugin.form; import kd.bos.dataentity.entity.DynamicObject; import kd.bos.dataentity.entity.DynamicObjectCollection; +import kd.bos.dataentity.entity.LocaleString; import kd.bos.dataentity.utils.StringUtils; +import kd.bos.entity.EntityMetadataCache; +import kd.bos.entity.ValueMapItem; import kd.bos.entity.datamodel.events.PropertyChangedArgs; +import kd.bos.entity.property.ComboProp; import kd.bos.form.control.events.BeforeItemClickEvent; import kd.bos.form.events.ClosedCallBackEvent; import kd.bos.form.plugin.AbstractFormPlugin; @@ -14,6 +18,7 @@ import kd.sdk.plugin.Plugin; import shjh.jhzj7.fi.fi.plugin.form.info.RecFieldsInfo; import java.util.EventObject; +import java.util.List; /** * 表单插件-【收款单】 @@ -35,9 +40,9 @@ public class RecBillFromPlugin extends AbstractFormPlugin implements Plugin { carryCustomer(); //根据分录清账状态去默认表头的清账状态 String state = (String) this.getModel().getValue(RecFieldsInfo.TOP_BILL_STATUS); - if ("A".equals(state)){ + if ("A".equals(state)) { String value = (String) this.getModel().getValue(RecFieldsInfo.CLOSING_STATUS); - if (value==null || "".equals(value)){ + if (value == null || "".equals(value)) { DynamicObjectCollection entry = (DynamicObjectCollection) this.getModel().getValue("entry"); if (null != entry && entry.size() != 0) { setClosingStatus(entry); @@ -46,13 +51,13 @@ public class RecBillFromPlugin extends AbstractFormPlugin implements Plugin { } } - private void carryCustomer(){ - String sourcebilltype = (String)this.getModel().getValue("sourcebilltype");//源单类型:被动付款入账(bei_intelpay) + private void carryCustomer() { + String sourcebilltype = (String) this.getModel().getValue("sourcebilltype");//源单类型:被动付款入账(bei_intelpay) if (!"bei_intelrec".equals(sourcebilltype)) { return; } - String sourcebillnumber = (String)this.getModel().getValue("sourcebillnumber");//源单编码:被动付款单号(bei_intelpay) + String sourcebillnumber = (String) this.getModel().getValue("sourcebillnumber");//源单编码:被动付款单号(bei_intelpay) QFilter q1 = new QFilter("billno", QCP.equals, sourcebillnumber); DynamicObject beiIntelpay = BusinessDataServiceHelper.loadSingle("bei_intelrec", q1.toArray()); if (null != beiIntelpay) { @@ -60,25 +65,25 @@ public class RecBillFromPlugin extends AbstractFormPlugin implements Plugin { //根据适配规则名称查询适配规则 (cas_recpayrule) // 单据:生单/通知规则(shjh_cas_recpayrule_ext) 单据体:入账规则(entryentity) 字段:规则项名称(e_rulesname) QFilter q2 = new QFilter("entryentity.e_rulesname", QCP.equals, rulename); - DynamicObject rule = BusinessDataServiceHelper.loadSingle("cas_recpayrule",q2.toArray()); + DynamicObject rule = BusinessDataServiceHelper.loadSingle("cas_recpayrule", q2.toArray()); if (null != rule) { //根据适配规则携带对应分录的业务大类,业务小类,成本中心,利润中心 DynamicObjectCollection collection = rule.getDynamicObjectCollection("entryentity"); for (DynamicObject entry : collection) { if (rulename.equals(entry.getString("e_rulesname"))) { - DynamicObject shjhBizbig = (DynamicObject)this.getModel().getValue("shjh_bizebig"); + DynamicObject shjhBizbig = (DynamicObject) this.getModel().getValue("shjh_bizebig"); if (null == shjhBizbig) { this.getModel().setValue("shjh_bizebig", entry.getDynamicObject("shjh_e_bizbig")); } - DynamicObject shjhBizsmall = (DynamicObject)this.getModel().getValue("shjh_bizsmall"); + DynamicObject shjhBizsmall = (DynamicObject) this.getModel().getValue("shjh_bizsmall"); if (null == shjhBizsmall) { this.getModel().setValue("shjh_bizsmall", entry.getDynamicObject("shjh_e_bizsmall")); } - DynamicObject shjhCostcenter = (DynamicObject)this.getModel().getValue("shjh_costcenter"); + DynamicObject shjhCostcenter = (DynamicObject) this.getModel().getValue("shjh_costcenter"); if (null == shjhCostcenter) { this.getModel().setValue("shjh_costcenter", entry.getDynamicObject("shjh_e_cc")); } - DynamicObject shjhPc = (DynamicObject)this.getModel().getValue("shjh_profitcenter"); + DynamicObject shjhPc = (DynamicObject) this.getModel().getValue("shjh_profitcenter"); if (null == shjhPc) { this.getModel().setValue("shjh_profitcenter", entry.getDynamicObject("shjh_e_pc")); } @@ -101,13 +106,14 @@ public class RecBillFromPlugin extends AbstractFormPlugin implements Plugin { /** * 已推送SAP不允许取消收款 + * * @param evt */ private void cancelRecValidator(BeforeItemClickEvent evt) { - String billno = (String)this.getModel().getValue("billno"); + String billno = (String) this.getModel().getValue("billno"); DynamicObject recObj = BusinessDataServiceHelper.loadSingle("cas_recbill", "id,billno,isvoucher,billstatus,receivingtype,shjh_ispushsap", new QFilter[]{new QFilter("billno", "=", billno)}); boolean ispushsap = recObj.getBoolean("shjh_ispushsap"); - if (ispushsap){ + if (ispushsap) { this.getView().showTipNotification("已推送SAP,不允许取消收款!"); evt.setCancel(true); } @@ -125,7 +131,7 @@ public class RecBillFromPlugin extends AbstractFormPlugin implements Plugin { } } //监听分录清账状态 - else if (StringUtils.equals(fieldKey, RecFieldsInfo.ENTRY_CLOSING_STATUS)){ + else if (StringUtils.equals(fieldKey, RecFieldsInfo.ENTRY_CLOSING_STATUS)) { DynamicObjectCollection entry = this.getModel().getEntryEntity("entry"); if (null != entry && entry.size() != 0) { setClosingStatus(entry); @@ -133,17 +139,17 @@ public class RecBillFromPlugin extends AbstractFormPlugin implements Plugin { } //监听付款人id //一次性客户/一次性供应商时设置默认值。 - else if (StringUtils.equals(fieldKey, "payer")){ + else if (StringUtils.equals(fieldKey, "payer")) { String type = (String) this.getModel().getValue(RecFieldsInfo.PAYER_TYPE); - if ("bd_customer".equals(type)||"bd_supplier".equals(type)){ + if ("bd_customer".equals(type) || "bd_supplier".equals(type)) { Object value = this.getModel().getValue("payer"); - if (null!=value){ + if (null != value) { DynamicObject dynamicObject = BusinessDataServiceHelper.loadSingle(value, type); - if (null!=dynamicObject){ + if (null != dynamicObject) { String name = dynamicObject.getString("group.name"); - if (null!=name && name.contains("一次性客户")){ - this.getModel().setValue("shjh_country","中国"); - this.getModel().setValue("shjh_city","上海"); + if (null != name && name.contains("一次性客户")) { + this.getModel().setValue("shjh_country", "中国"); + this.getModel().setValue("shjh_city", "上海"); } } } @@ -155,35 +161,35 @@ public class RecBillFromPlugin extends AbstractFormPlugin implements Plugin { //付款人类型=客户 String type = (String) this.getModel().getValue(RecFieldsInfo.PAYER_TYPE); - if ("bd_customer".equals(type)){ + if ("bd_customer".equals(type)) { DynamicObject bizSmall = (DynamicObject) this.getModel().getValue("shjh_bizsmall"); - if (null!=bizSmall){ + if (null != bizSmall) { String string = bizSmall.getString("shjh_qzfs"); //当收款单【业务小类】清账方式字段=待判断清账 - if ("dpdqz".equals(string)){ + if ("dpdqz".equals(string)) { //判断收款单中的客户信息,是否在《结构性清账客户映射表》中 //判断客户是否拆分 boolean customerSplit = (boolean) this.getModel().getValue("shjh_customersplit"); if (!customerSplit) { //当客户拆分=否时,使用表头付款方入账。 Object value = this.getModel().getValue("payer"); - if (null!=value) { + if (null != value) { DynamicObject customerObj = BusinessDataServiceHelper.loadSingle(value, type); QFilter number = new QFilter("shjh_customer.number", QCP.equals, customerObj.getString("number")); DynamicObject mappingObj = BusinessDataServiceHelper.loadSingle("shjh_jgqzcust", number.toArray()); DynamicObjectCollection entryEntity = this.getModel().getEntryEntity("entry"); - if (null!=mappingObj){ - if (null!=entryEntity){ + if (null != mappingObj) { + if (null != entryEntity) { for (int i = 0; i < entryEntity.size(); i++) { - this.getModel().setValue("shjh_needpushbill",true,i); - this.getModel().setValue("shjh_closingstatus","B",i); + this.getModel().setValue("shjh_needpushbill", true, i); + this.getModel().setValue("shjh_closingstatus", "B", i); } } - }else { - if (null!=entryEntity){ + } else { + if (null != entryEntity) { for (int i = 0; i < entryEntity.size(); i++) { - this.getModel().setValue("shjh_needpushbill",false,i); - this.getModel().setValue("shjh_closingstatus","A",i); + this.getModel().setValue("shjh_needpushbill", false, i); + this.getModel().setValue("shjh_closingstatus", "A", i); } } } @@ -196,14 +202,14 @@ public class RecBillFromPlugin extends AbstractFormPlugin implements Plugin { } //监听分录客户 //当客户拆分=是时,使用分录行客户入账。 - else if (StringUtils.equals(fieldKey,"shjh_entrycustomer")) { + else if (StringUtils.equals(fieldKey, "shjh_entrycustomer")) { DynamicObjectCollection entryEntity = this.getModel().getEntryEntity("entry"); - if (null!=entryEntity){ + if (null != entryEntity) { for (int i = 0; i < entryEntity.size(); i++) { QFilter number = new QFilter("shjh_customer.number", QCP.equals, entryEntity.get(i).getString("shjh_entrycustomer.number")); DynamicObject mappingObj = BusinessDataServiceHelper.loadSingle("shjh_jgqzcust", number.toArray()); - if (null!=mappingObj){ - this.getModel().setValue("shjh_needpushbill",true,i); + if (null != mappingObj) { + this.getModel().setValue("shjh_needpushbill", true, i); } } } @@ -241,20 +247,24 @@ public class RecBillFromPlugin extends AbstractFormPlugin implements Plugin { // 遍历分录行,判断清账状态 for (int i = 0; i < entry.size(); i++) { String closingStatus = entry.get(i).getString("shjh_closingstatus"); - if (null!=closingStatus){ + if (null != closingStatus) { switch (closingStatus) { case "A": + case "无需金蝶清账": hasNoClear = true; break; case "B": + case "待清账": hasPendingClear = true; break; case "C": + case "已清账": hasCleared = true; // 如果有不是“已清账”的,就说明不是全部“已清账” allCleared = false; break; case "D": + case "反清账": hasReversedClear = true; // 如果有不是“反清账”的,就说明不是全部“反清账” allReversedCleared = false; @@ -288,7 +298,7 @@ public class RecBillFromPlugin extends AbstractFormPlugin implements Plugin { } else if (isPartialReversedCleared) { // 部分反清账的条件 headerStatus = "F"; - }else { + } else { headerStatus = null; } @@ -297,5 +307,4 @@ public class RecBillFromPlugin extends AbstractFormPlugin implements Plugin { } - } \ No newline at end of file diff --git a/main/java/shjh/jhzj7/fi/fi/plugin/operate/RecBillSaveOperation.java b/main/java/shjh/jhzj7/fi/fi/plugin/operate/RecBillSaveOperation.java index 63e350b..f379a01 100644 --- a/main/java/shjh/jhzj7/fi/fi/plugin/operate/RecBillSaveOperation.java +++ b/main/java/shjh/jhzj7/fi/fi/plugin/operate/RecBillSaveOperation.java @@ -2,6 +2,7 @@ package shjh.jhzj7.fi.fi.plugin.operate; import kd.bos.dataentity.entity.DynamicObject; import kd.bos.dataentity.entity.DynamicObjectCollection; +import kd.bos.dataentity.metadata.IDataEntityType; import kd.bos.entity.plugin.AbstractOperationServicePlugIn; import kd.bos.entity.plugin.args.AfterOperationArgs; import kd.bos.logging.Log; @@ -28,7 +29,14 @@ public class RecBillSaveOperation extends AbstractOperationServicePlugIn impleme //付款单提交之后 付款标识为被动付款,并且资金计划科目为空,从配置表(shjh_pay_account)携带资金计划科目 DynamicObject[] dataEntities = e.getDataEntities(); for (DynamicObject bill : dataEntities) { + IDataEntityType dataEntityType = bill.getDataEntityType(); + String name = dataEntityType.getName(); + if (!"cas_recbill".equals(name)) { + return; + } bill = BusinessDataServiceHelper.loadSingle(bill.getPkValue(),"cas_recbill"); + + // DynamicObject planClass = bill.getDynamicObject("shjh_planclass"); // if (null == planClass) { //根据配置表携带资金计划科目