From ae456405d1a6325447988d12d5b989d36084a062 Mon Sep 17 00:00:00 2001 From: zhangzhiguo Date: Tue, 17 Dec 2024 21:51:55 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=9B=BD=E5=A4=96=E4=BD=8F?= =?UTF-8?q?=E5=AE=BF=E6=A0=87=E5=87=86=E6=8F=90=E9=86=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../plugin/form/OverseaStaysLimitPlugin.java | 86 +++++++++++++ .../TripreimbursebillAbroadAlertedPlugin.java | 89 +++++++++++++ .../plugin/form/TripreimbursebillPlugin.java | 120 ------------------ 3 files changed, 175 insertions(+), 120 deletions(-) create mode 100644 code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/OverseaStaysLimitPlugin.java create mode 100644 code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/TripreimbursebillAbroadAlertedPlugin.java delete mode 100644 code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/TripreimbursebillPlugin.java diff --git a/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/OverseaStaysLimitPlugin.java b/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/OverseaStaysLimitPlugin.java new file mode 100644 index 0000000..5b89067 --- /dev/null +++ b/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/OverseaStaysLimitPlugin.java @@ -0,0 +1,86 @@ +package zcgj.zcdev.zcdev.fs.plugin.form; + +import kd.bos.bill.AbstractBillPlugIn; +import kd.bos.dataentity.entity.DynamicObject; +import kd.bos.dataentity.entity.DynamicObjectCollection; +import kd.bos.entity.datamodel.IDataModel; +import kd.bos.entity.datamodel.events.ChangeData; +import kd.bos.entity.datamodel.events.PropertyChangedArgs; +import kd.bos.entity.operate.Submit; +import kd.bos.form.FormShowParameter; +import kd.bos.form.events.BeforeDoOperationEventArgs; +import kd.bos.form.field.BasedataEdit; +import kd.bos.form.field.events.BeforeF7SelectEvent; +import kd.bos.form.field.events.BeforeF7SelectListener; +import kd.bos.list.ListShowParameter; +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.sdk.plugin.Plugin; + +import java.math.BigDecimal; +import java.util.EventObject; + +/** + * 国外住宿费标准 + */ +public class OverseaStaysLimitPlugin extends AbstractBillPlugIn implements Plugin, BeforeF7SelectListener { + + private static final Log log = LogFactory.getLog(OverseaStaysLimitPlugin.class); + //开发商标识 + private static final String prefix ="zcgj"; + + @Override + public void registerListener(EventObject e) { + super.registerListener(e); + BasedataEdit fieldEdit = this.getView().getControl("zcgj_district_f7"); + fieldEdit.addBeforeF7SelectListener(this); + } + + @Override + public void beforeF7Select(BeforeF7SelectEvent f7) { + String name = f7.getProperty().getName(); + if (name.equals("zcgj_district_f7")){ + DynamicObject zcgjCountry = (DynamicObject)this.getModel().getValue("zcgj_country"); + long countryId = zcgjCountry.getLong("id"); + ListShowParameter showParameter = (ListShowParameter) f7.getFormShowParameter(); + showParameter.getListFilterParameter().getQFilters().add(new QFilter("country", QCP.equals,countryId)); + } + } + + /*@Override + public void propertyChanged(PropertyChangedArgs e) { + super.propertyChanged(e); + String name = e.getProperty().getName(); + if("zcgj_district_f7".equals(name)){ + IDataModel model = this.getModel(); + ChangeData[] changeSet = e.getChangeSet(); + DynamicObject newValue = (DynamicObject)changeSet[0].getNewValue(); + long id = newValue.getLong("id"); + //获取地域详细信息 + //bd_admindivision + DynamicObject cityObj = BusinessDataServiceHelper.loadSingle("bd_admindivision", "country", + new QFilter[]{new QFilter("id", QCP.equals,id)}); + if(cityObj!=null){ + DynamicObject country = cityObj.getDynamicObject("country"); + long countryId = country.getLong("id"); + //获取所属国家 + //bd_country + DynamicObject countryObj = BusinessDataServiceHelper.loadSingle("bd_country", "number,name,twocountrycode", + new QFilter[]{new QFilter("id", QCP.equals,countryId)}); + if(countryObj!=null){ + String twocountrycode = countryObj.getString("twocountrycode"); + String countname = countryObj.getString("name"); + if(!"CN".equals(twocountrycode)){ + //保存国家id + // this.getModel().setValue("zcgj_countryid",countryId); + } + } + } + } + }*/ + + +} diff --git a/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/TripreimbursebillAbroadAlertedPlugin.java b/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/TripreimbursebillAbroadAlertedPlugin.java new file mode 100644 index 0000000..86fe33e --- /dev/null +++ b/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/TripreimbursebillAbroadAlertedPlugin.java @@ -0,0 +1,89 @@ +package zcgj.zcdev.zcdev.fs.plugin.form; + +import kd.bos.bill.AbstractBillPlugIn; +import kd.bos.dataentity.entity.DynamicObject; +import kd.bos.entity.datamodel.IDataModel; +import kd.bos.entity.datamodel.events.ChangeData; +import kd.bos.entity.datamodel.events.PropertyChangedArgs; +import kd.bos.orm.query.QCP; +import kd.bos.orm.query.QFilter; +import kd.bos.servicehelper.BusinessDataServiceHelper; +import kd.sdk.plugin.Plugin; + +import java.math.BigDecimal; +import java.math.RoundingMode; +import java.util.HashMap; +import java.util.Map; + +/** + * 差旅报销单国外住宿标准提醒插件 + */ +public class TripreimbursebillAbroadAlertedPlugin extends AbstractBillPlugIn implements Plugin { + + //private static final Log log = LogFactory.getLog(TripreimbursebillPlugin.class); + //开发商标识 + private static final String prefix ="zcgj"; + + @Override + public void propertyChanged(PropertyChangedArgs e) { + super.propertyChanged(e); + String name = e.getProperty().getName(); + //目的地变更 + if("to".equals(name)){ + IDataModel model = this.getModel(); + ChangeData[] changeSet = e.getChangeSet(); + DynamicObject newValue = (DynamicObject)changeSet[0].getNewValue(); + long id = newValue.getLong("id"); + //获取地域详细信息 + //bd_admindivision + DynamicObject cityObj = BusinessDataServiceHelper.loadSingle("bd_admindivision", "country", + new QFilter[]{new QFilter("id", QCP.equals,id)}); + if(cityObj!=null){ + DynamicObject country = cityObj.getDynamicObject("country"); + long countryId = country.getLong("id"); + //获取所属国家 + //bd_country + DynamicObject countryObj = BusinessDataServiceHelper.loadSingle("bd_country", "number,name,twocountrycode", + new QFilter[]{new QFilter("id", QCP.equals,countryId)}); + if(countryObj!=null){ + String twocountrycode = countryObj.getString("twocountrycode"); + String countname = countryObj.getString("name"); + if(!"CN".equals(twocountrycode)){ + DynamicObject[] load = BusinessDataServiceHelper.load("zcgj_oversea_stays_limit", + "zcgj_district_f7,zcgj_country,zcgj_currency,zcgj_stays_criteria,zcgj_rate" + , new QFilter[]{new QFilter("zcgj_country", QCP.equals, countryId)}); + BigDecimal otherAmount = BigDecimal.ZERO; + BigDecimal cirtyAmount = BigDecimal.ZERO; + String currencyName = ""; + String currencySign = ""; + if(load == null || load.length<1){ + // this.getView().showTipNotification("当前出差国家为:"+countname+",未设置住宿标准!"); + }else{ + Map map = new HashMap<>(); + for (DynamicObject dynamicObject : load) { + DynamicObject zcgjCountry = dynamicObject.getDynamicObject("zcgj_country"); + DynamicObject zcgjDistrictF7 = dynamicObject.getDynamicObject("zcgj_district_f7"); + DynamicObject zcgjCurrency = dynamicObject.getDynamicObject("zcgj_currency"); + BigDecimal zcgjStaysCriteria = dynamicObject.getBigDecimal("zcgj_stays_criteria"); + BigDecimal zcgjRate = dynamicObject.getBigDecimal("zcgj_rate"); + currencyName = zcgjCurrency.getString("name"); + if(zcgjDistrictF7 ==null ){ + otherAmount = zcgjStaysCriteria.multiply(zcgjRate); + }else if(countryId == zcgjDistrictF7.getLong("id")){ + cirtyAmount = zcgjStaysCriteria.multiply(zcgjRate); + } + } + if(!BigDecimal.ZERO.equals(otherAmount) && BigDecimal.ZERO.equals(cirtyAmount) ){ + //this.getView().showTipNotification("当前出差国家为:"+countname+",币别为:"+currencyName+",住宿标准为:"+otherAmount.setScale(2, RoundingMode.HALF_UP)); + this.getView().showTipNotification("当前出差国家为:"+countname+",住宿标准为(人民币):"+otherAmount.setScale(2, RoundingMode.HALF_UP)+"元"); + }else if(BigDecimal.ZERO.equals(otherAmount) && !BigDecimal.ZERO.equals(cirtyAmount) ){ + //this.getView().showTipNotification("当前出差国家为:"+countname+",币别为:"+currencyName+",住宿标准为:"+cirtyAmount.setScale(2, RoundingMode.HALF_UP)); + this.getView().showTipNotification("当前出差国家为:"+countname+",住宿标准为(人民币):"+cirtyAmount.setScale(2, RoundingMode.HALF_UP)+"元"); + } + } + } + } + } + } + } +} diff --git a/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/TripreimbursebillPlugin.java b/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/TripreimbursebillPlugin.java deleted file mode 100644 index 932a751..0000000 --- a/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/TripreimbursebillPlugin.java +++ /dev/null @@ -1,120 +0,0 @@ -package zcgj.zcdev.zcdev.fs.plugin.form; - -import kd.bos.bill.AbstractBillPlugIn; -import kd.bos.dataentity.entity.DynamicObject; -import kd.bos.dataentity.entity.DynamicObjectCollection; -import kd.bos.entity.datamodel.IDataModel; -import kd.bos.entity.datamodel.events.ChangeData; -import kd.bos.entity.datamodel.events.PropertyChangedArgs; -import kd.bos.entity.operate.Submit; -import kd.bos.form.events.BeforeDoOperationEventArgs; -import kd.bos.logging.Log; -import kd.bos.logging.LogFactory; -import kd.sdk.plugin.Plugin; - -import java.math.BigDecimal; - -/** - * 差旅报销单插件 - */ -@Deprecated -public class TripreimbursebillPlugin extends AbstractBillPlugIn implements Plugin { - - private static final Log log = LogFactory.getLog(TripreimbursebillPlugin.class); - //开发商标识 - private static final String prefix ="zcgj"; - - @Override - public void beforeDoOperation(BeforeDoOperationEventArgs args) { - if((args.getSource() instanceof Submit) ){ - Submit source = (Submit)args.getSource(); - if(source.getOperateKey().equals("submit") ){ - //highseasontripstdshow - //提交时校验附件是否必填 - IDataModel model = this.getModel(); - String zsKey = String.valueOf(model.getValue("zcgj_zs_key")); - boolean isfloating20 = Boolean.parseBoolean(model.getValue("zcgj_isfloating20")+""); - - //获取当前费用为住宿的 - DynamicObjectCollection tripentryCollection = model.getEntryEntity("tripentry"); - //tripentry.get(0).getDynamicObjectCollection("entryentity").get(2).getDynamicObject("expenseitem").getString("number"); - for (DynamicObject tripentry : tripentryCollection) { - DynamicObjectCollection entryentityCollection = tripentry.getDynamicObjectCollection("entryentity"); - for (DynamicObject entryentity : entryentityCollection) { - DynamicObject expenseitem = entryentity.getDynamicObject("expenseitem"); - String zsNumber = expenseitem.getString("number"); - if(zsKey.equals(zsNumber)){ - BigDecimal orientryamount = entryentity.getBigDecimal("orientryamount");//报销金额 - BigDecimal tripstandardamount = entryentity.getBigDecimal("tripstandardamount");//差旅标准金额 - Integer caldaycount = entryentity.getInt("caldaycount");//标准天数 - //如果选择了上浮20%,则按照上浮20%进行判断 - if(isfloating20){ - //BigDecimal multiply = tripstandardamount.multiply(new BigDecimal("1.2")).multiply(new BigDecimal(caldaycount)); - BigDecimal multiply = tripstandardamount.multiply(new BigDecimal(caldaycount)); - //-1表示小于,0是等于,1是大于 - if(orientryamount.compareTo(multiply) > 0){ - this.getView().showTipNotification("报销住宿超出标准!(上浮20%)"); - //取消提交操作 - args.setCancel(true); - } - }else{ - BigDecimal multiply = tripstandardamount.multiply(new BigDecimal(caldaycount)); - //-1表示小于,0是等于,1是大于 - if(orientryamount.compareTo(multiply) > 0){ - this.getView().showTipNotification("报销住宿超出标准!"); - //取消提交操作 - args.setCancel(true); - } - } - } - } - - } - - //获取当前差旅标准 - /* Object value = model.getValue("tripstandardamount"); - this.getView().showTipNotification(value+"");*/ - } - } - } - - @Override - public void propertyChanged(PropertyChangedArgs e) { - super.propertyChanged(e); - String name = e.getProperty().getName(); - /*if(name.equals("zcgj_isfloating20")){ - IDataModel model = this.getModel(); - ChangeData[] changeSet = e.getChangeSet(); - Boolean isfloating20 = (Boolean)changeSet[0].getNewValue(); - String zsKey = String.valueOf(model.getValue("zcgj_zs_key")); - - //获取当前费用为住宿的 - DynamicObjectCollection tripentryCollection = model.getEntryEntity("tripentry"); - //tripentry.get(0).getDynamicObjectCollection("entryentity").get(2).getDynamicObject("expenseitem").getString("number"); - for (DynamicObject tripentry : tripentryCollection) { - DynamicObjectCollection entryentityCollection = tripentry.getDynamicObjectCollection("entryentity"); - for (DynamicObject entryentity : entryentityCollection) { - DynamicObject expenseitem = entryentity.getDynamicObject("expenseitem"); - String zsNumber = expenseitem.getString("number"); - if(zsKey.equals(zsNumber)){ - BigDecimal orientryamount = entryentity.getBigDecimal("orientryamount");//报销金额 - BigDecimal tripstandardamount = entryentity.getBigDecimal("tripstandardamount");//差旅标准金额 - BigDecimal tripstandardamountOld = tripstandardamount;//差旅标准金额 - - Integer caldaycount = entryentity.getInt("caldaycount");//标准天数 - //如果选择了上浮20%,则按照上浮20%进行判断 - if(isfloating20){ - BigDecimal multiply = tripstandardamount.multiply(new BigDecimal("1.2")); - entryentity.set("tripstandardamount",multiply); - }else{ - entryentity.set("tripstandardamount",tripstandardamountOld); - } - this.getView().updateView("entryentity"); - //this.getView().showTipNotification(tripstandardamount+" "+tripstandardamountOld); - } - } - } - - }*/ - } -}