From 97fe253709f27d2c6d685825aecd565ebdd9dfbf Mon Sep 17 00:00:00 2001 From: zhangzhiguo Date: Thu, 9 Jan 2025 20:12:17 +0800 Subject: [PATCH] =?UTF-8?q?1.=E5=8A=9F=E8=83=BD=E5=BC=80=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../form/AccountsitemsmapImpPlugin.java | 42 ++++ .../plugin/form/AutoCalWorkingDaysPlugin.java | 172 +++++++------- .../fs/plugin/form/BeyondBalancePlugin.java | 1 + .../form/BeyondBalancePrepaybillPlugin.java | 1 + ...ontractbillContractpartyDefaultPlugin.java | 5 +- .../plugin/form/CostcompanyDefaultPlugin.java | 10 +- .../form/DailyloanbillExpAccPlugin.java | 7 +- .../form/DailyreimbursExpAccPlugin.java | 6 +- .../plugin/form/OverseaStaysLimitPlugin.java | 15 +- .../plugin/form/PrepaybillContractPlugin.java | 18 +- .../plugin/form/PrepaybillExpAccPlugin.java | 6 +- .../PublicreimbursebillContractPlugin.java | 9 +- .../form/PublicreimbursebillExpAccPlugin.java | 6 +- .../form/TriprAutoCalWorkingDaysPlugin.java | 209 ++++++++++++++++++ .../form/TriprCostcompanyDefaultPlugin.java | 7 +- .../TripreimbursebillAbroadAlertedPlugin.java | 3 +- .../operate/DailyreimbursHomeCheckOp.java | 2 +- .../operate/DailyreimbursVisitCheckOp.java | 5 +- .../TripreimbursebillIsHomeCheckOp.java | 3 +- .../plugin/operate/TripreimbursebillUpOp.java | 10 +- .../report/EmpTravelRptQueryPlugin.java | 56 +++-- .../{plugin/form => utils}/OrgCheckUtils.java | 2 +- 22 files changed, 414 insertions(+), 181 deletions(-) create mode 100644 code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/AccountsitemsmapImpPlugin.java create mode 100644 code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/TriprAutoCalWorkingDaysPlugin.java rename code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/{plugin/form => utils}/OrgCheckUtils.java (97%) diff --git a/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/AccountsitemsmapImpPlugin.java b/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/AccountsitemsmapImpPlugin.java new file mode 100644 index 0000000..4de6f8e --- /dev/null +++ b/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/AccountsitemsmapImpPlugin.java @@ -0,0 +1,42 @@ +package zcgj.zcdev.zcdev.fs.plugin.form; + +import kd.bos.bill.AbstractBillPlugIn; +import kd.bos.dataentity.entity.DynamicObject; +import kd.bos.entity.datamodel.BasedataItem; +import kd.bos.entity.datamodel.events.QueryImportBasedataEventArgs; +import kd.bos.entity.plugin.AbstractDataModelPlugin; +import kd.bos.servicehelper.BusinessDataServiceHelper; + +import java.util.Collections; +import java.util.List; +import java.util.Map; + +/** + * 会计科目与费用项目映射表 自定义引入 + */ +public class AccountsitemsmapImpPlugin extends AbstractBillPlugIn { + + public static final String ACCOUNT_ITEM = "zcgj_account_item"; + + //最新科目表编码 + public static final String ACCOUNT_TABLE_NUMBER ="0003"; + + @Override + public void queryImportBasedata(QueryImportBasedataEventArgs e) { + Map> searchResult = e.getSearchResult(); + for (Map.Entry> baseDataItemListEntry : searchResult.entrySet()) { + BasedataItem basedataItem = baseDataItemListEntry.getKey(); + if (basedataItem.getFieldKey().equals(ACCOUNT_ITEM)) {//判断当前基础资料是否为 会计科目 + //遍历物料的内码,根据内码拿到物料的数据包,选择长度为 20 的 电风扇 + for (int i = 0;i < baseDataItemListEntry.getValue().size();i++){ + DynamicObject dynamicObject = BusinessDataServiceHelper.loadSingle(baseDataItemListEntry.getValue().get(i), basedataItem.getEntityNumber()); + String tableNumber = ((DynamicObject) dynamicObject.get("accounttable")).getString("number"); + if(ACCOUNT_TABLE_NUMBER.equals(tableNumber)){ + baseDataItemListEntry.setValue(Collections.singletonList(baseDataItemListEntry.getValue().get(i)));//设置科目id + } + } + } + } + } + +} diff --git a/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/AutoCalWorkingDaysPlugin.java b/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/AutoCalWorkingDaysPlugin.java index 0e0f901..1475261 100644 --- a/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/AutoCalWorkingDaysPlugin.java +++ b/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/AutoCalWorkingDaysPlugin.java @@ -1,54 +1,46 @@ package zcgj.zcdev.zcdev.fs.plugin.form; import kd.bos.bill.AbstractBillPlugIn; +import kd.bos.context.RequestContext; import kd.bos.dataentity.entity.DynamicObject; import kd.bos.dataentity.entity.DynamicObjectCollection; import kd.bos.entity.datamodel.events.ChangeData; import kd.bos.entity.datamodel.events.PropertyChangedArgs; -import kd.bos.form.ConfirmCallBackListener; -import kd.bos.form.MessageBoxOptions; -import kd.bos.form.control.events.BeforeItemClickEvent; import kd.bos.form.control.events.ItemClickEvent; import kd.sdk.plugin.Plugin; +import zcgj.zcdev.zcdev.fs.utils.OrgCheckUtils; import java.text.SimpleDateFormat; -import java.util.Calendar; -import java.util.Date; -import java.util.EventObject; +import java.time.DayOfWeek; +import java.time.LocalDate; +import java.time.ZoneId; +import java.util.*; /** - * 往返家居工作日天数自动计算插件 + * 费用报销单往返家居工作日天数自动计算插件 */ public class AutoCalWorkingDaysPlugin extends AbstractBillPlugIn implements Plugin { @Override public void propertyChanged(PropertyChangedArgs e) { - String name = e.getProperty().getName(); - SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); - if(name.equals("zcgj_startdate") ||name.equals("zcgj_enddate")){ - ChangeData[] changeSet = e.getChangeSet(); - //获取分录 - DynamicObject dataEntity = this.getModel().getDataEntity(true); - DynamicObjectCollection dynamicObjectCollection = dataEntity.getDynamicObjectCollection("zcgj_homeentity"); - DynamicObject dynamicObject = dynamicObjectCollection.get(changeSet[0].getRowIndex()); - Date zcgjStartdate = dynamicObject.getDate("zcgj_startdate"); - Date zcgjEnddate = dynamicObject.getDate("zcgj_enddate"); - if(zcgjEnddate!=null){ - int workDays = calculateWorkdays(zcgjStartdate, zcgjEnddate); - int allDays = calculateDaysBetween(zcgjStartdate, zcgjEnddate); - dynamicObject.set("zcgj_homedaycount",workDays); - int day = allDays - workDays; - if(day>=0&&workDays>0){ - dynamicObject.set("zcgj_kccbdaycount",day); + //当前切换选择的组织 + Long currentOrgId = RequestContext.get().getOrgId(); + if(OrgCheckUtils.isKS(currentOrgId)){ + String name = e.getProperty().getName(); + if(name.equals("zcgj_startdate") ||name.equals("zcgj_enddate")){ + ChangeData[] changeSet = e.getChangeSet(); + int rowIndex = changeSet[0].getRowIndex(); + int count = calHomeentityDay(rowIndex); + this.getModel().setValue("zcgj_kccbdays",count); + }else if("zcgj_holiday_start_time".equals(name) || "zcgj_holiday_end_time".equals(name)){ + Date zcgjStartdate = (Date)this.getModel().getValue("zcgj_holiday_start_time"); + Date zcgjEnddate = (Date)this.getModel().getValue("zcgj_holiday_end_time"); + if(zcgjStartdate!=null && zcgjEnddate!=null){ + Set datesExcludingWeekends = getDatesExcludingWeekends(dateToLocalDate(zcgjStartdate), dateToLocalDate(zcgjEnddate)); + this.getModel().setValue("zcgj_kccbdays",datesExcludingWeekends.size()); }else{ - dynamicObject.set("zcgj_kccbdaycount",0); + this.getModel().setValue("zcgj_kccbdays",null); } - int allHomeCount = 0; - for (DynamicObject entry : dynamicObjectCollection) { - allHomeCount += entry.getInt("zcgj_kccbdaycount"); - } - this.getModel().setValue("zcgj_kccbdays",allHomeCount); - this.getView().updateView("zcgj_homeentity"); } } super.propertyChanged(e); @@ -59,7 +51,7 @@ public class AutoCalWorkingDaysPlugin extends AbstractBillPlugIn implements Plug public void registerListener(EventObject e) { super.registerListener(e); //监听工具栏按钮点击事件 - //this.addItemClickListeners("zcgj_hometoolbarap"); + this.addItemClickListeners("zcgj_hometoolbarap"); } @Override @@ -78,57 +70,89 @@ public class AutoCalWorkingDaysPlugin extends AbstractBillPlugIn implements Plug } } - // 计算工作日天数 - public static int calculateWorkdays(Date startDate, Date endDate) { - // 使用 Calendar 类进行日期操作 - Calendar startCalendar = Calendar.getInstance(); - Calendar endCalendar = Calendar.getInstance(); - - startCalendar.setTime(startDate); - endCalendar.setTime(endDate); - - // 特殊情况处理:如果开始日期是周五且结束日期是周一,返回0 - if (startCalendar.get(Calendar.DAY_OF_WEEK) == Calendar.FRIDAY && - endCalendar.get(Calendar.DAY_OF_WEEK) == Calendar.MONDAY) { - return 0; + public int calHomeentityDay(int rowIndex){ + //获取分录 + DynamicObject dataEntity = this.getModel().getDataEntity(true); + DynamicObjectCollection dynamicObjectCollection = dataEntity.getDynamicObjectCollection("zcgj_homeentity"); + DynamicObject dynamicObject = dynamicObjectCollection.get(rowIndex); + Date zcgjStartdate = dynamicObject.getDate("zcgj_startdate"); + Date zcgjEnddate = dynamicObject.getDate("zcgj_enddate"); + int allHomeCount = 0; + if(zcgjStartdate!=null && zcgjEnddate!=null){ + Set datesExcludingWeekends = getDatesExcludingWeekends(dateToLocalDate(zcgjStartdate), dateToLocalDate(zcgjEnddate)); + allHomeCount = datesExcludingWeekends.size(); + this.getModel().setValue("zcgj_kccbdaycount",allHomeCount); } + return allHomeCount; + } - // 计算工作日天数 - int workdays = 0; - - // 从开始日期到结束日期遍历 - while (!startCalendar.after(endCalendar)) { - int dayOfWeek = startCalendar.get(Calendar.DAY_OF_WEEK); - // 只统计周一到周五(排除周六和周日) - if (dayOfWeek != Calendar.SATURDAY && dayOfWeek != Calendar.SUNDAY) { - workdays++; + public Set calHomeentityDay(){ + //获取分录 + DynamicObject dataEntity = this.getModel().getDataEntity(true); + DynamicObjectCollection dynamicObjectCollection = dataEntity.getDynamicObjectCollection("zcgj_homeentity"); + Set addDateSet = new HashSet<>(); + for (DynamicObject dynamicObject : dynamicObjectCollection) { + Date zcgjStartdate = dynamicObject.getDate("zcgj_startdate"); + Date zcgjEnddate = dynamicObject.getDate("zcgj_enddate"); + if(zcgjStartdate!=null && zcgjEnddate!=null){ + Set datesExcludingWeekends = getDatesExcludingWeekends(dateToLocalDate(zcgjStartdate), dateToLocalDate(zcgjEnddate)); + addDateSet.addAll(datesExcludingWeekends); } - startCalendar.add(Calendar.DAY_OF_MONTH, 1); // 移动到下一天 + } + return addDateSet; + } + + //获取开始结束时间 + public static Set getStartAndEnd(LocalDate startDate, LocalDate endDate) { + Set result = new HashSet<>(); + + // 判断开始日期和结束日期是否为周末 + if (!isWeekend(startDate)) { + result.add(startDate); } - return workdays; + if (!isWeekend(endDate)) { + result.add(endDate); + } + + return result; } - // 计算开始日期和结束日期之间的天数 - public static int calculateDaysBetween(Date startDate, Date endDate) { - // 日期格式化 - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + //去除开始日期结束日期,移除周六日 + public static Set getDatesExcludingWeekends(LocalDate startDate, LocalDate endDate) { + Set result = new HashSet<>(); - // 使用 Calendar 类来处理日期 - Calendar startCalendar = Calendar.getInstance(); - Calendar endCalendar = Calendar.getInstance(); + // 计算从开始日期到结束日期之间的日期 + LocalDate currentDate = startDate.plusDays(1); // 排除开始日期 + LocalDate lastDate = endDate.minusDays(1); // 排除结束日期 - startCalendar.setTime(startDate); - endCalendar.setTime(endDate); + // 遍历日期范围 + while (!currentDate.isAfter(lastDate)) { + if (!isWeekend(currentDate)) { + result.add(currentDate); + } + currentDate = currentDate.plusDays(1); + } - // 计算两个日期之间的天数差 - long startMillis = startCalendar.getTimeInMillis(); - long endMillis = endCalendar.getTimeInMillis(); - - // 计算天数差,注意加1天因为天数是区间的数量(包含开始日期) - long diffMillis = endMillis - startMillis; - int diffDays = (int) (diffMillis / (24 * 60 * 60 * 1000)); - - return diffDays + 1; // 因为差值是天数之间的差,包含开始日期 + return result; } + + private static boolean isWeekend(LocalDate date) { + return date.getDayOfWeek() == DayOfWeek.SATURDAY || date.getDayOfWeek() == DayOfWeek.SUNDAY; + } + /** + * 将 java.util.Date 转换为 java.time.LocalDate + * @param date java.util.Date + * @return java.time.LocalDate + */ + public static LocalDate dateToLocalDate(Date date) { + if (date == null) { + throw new IllegalArgumentException("日期不能为 null"); + } + return date.toInstant() + .atZone(ZoneId.systemDefault()) + .toLocalDate(); + } + + } diff --git a/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/BeyondBalancePlugin.java b/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/BeyondBalancePlugin.java index 5d5c7a5..27f0e10 100644 --- a/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/BeyondBalancePlugin.java +++ b/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/BeyondBalancePlugin.java @@ -12,6 +12,7 @@ import kd.bos.exception.KDBizException; import kd.bos.logging.Log; import kd.bos.logging.LogFactory; import kd.bos.servicehelper.DispatchServiceHelper; +import zcgj.zcdev.zcdev.fs.utils.OrgCheckUtils; import java.util.Arrays; import java.util.List; diff --git a/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/BeyondBalancePrepaybillPlugin.java b/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/BeyondBalancePrepaybillPlugin.java index 20ddac0..7d8f46f 100644 --- a/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/BeyondBalancePrepaybillPlugin.java +++ b/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/BeyondBalancePrepaybillPlugin.java @@ -13,6 +13,7 @@ import kd.bos.exception.KDBizException; import kd.bos.logging.Log; import kd.bos.logging.LogFactory; import kd.bos.servicehelper.DispatchServiceHelper; +import zcgj.zcdev.zcdev.fs.utils.OrgCheckUtils; import java.util.Arrays; import java.util.List; diff --git a/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/ContractbillContractpartyDefaultPlugin.java b/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/ContractbillContractpartyDefaultPlugin.java index e5fe291..4cf7276 100644 --- a/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/ContractbillContractpartyDefaultPlugin.java +++ b/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/ContractbillContractpartyDefaultPlugin.java @@ -4,16 +4,13 @@ import kd.bos.bill.AbstractBillPlugIn; import kd.bos.context.RequestContext; import kd.bos.dataentity.entity.DynamicObject; import kd.bos.dataentity.entity.DynamicObjectCollection; -import kd.bos.entity.datamodel.events.PropertyChangedArgs; -import kd.bos.form.ConfirmCallBackListener; -import kd.bos.form.MessageBoxOptions; -import kd.bos.form.control.events.BeforeItemClickEvent; import kd.bos.form.control.events.ItemClickEvent; import kd.bos.orm.query.QCP; import kd.bos.orm.query.QFilter; import kd.bos.servicehelper.BusinessDataServiceHelper; import kd.bos.servicehelper.user.UserServiceHelper; import kd.sdk.plugin.Plugin; +import zcgj.zcdev.zcdev.fs.utils.OrgCheckUtils; import java.util.EventObject; diff --git a/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/CostcompanyDefaultPlugin.java b/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/CostcompanyDefaultPlugin.java index cc222bd..9455ef9 100644 --- a/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/CostcompanyDefaultPlugin.java +++ b/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/CostcompanyDefaultPlugin.java @@ -11,6 +11,7 @@ import kd.bos.orm.query.QFilter; import kd.bos.servicehelper.BusinessDataServiceHelper; import kd.bos.servicehelper.user.UserServiceHelper; import kd.sdk.plugin.Plugin; +import zcgj.zcdev.zcdev.fs.utils.OrgCheckUtils; import java.util.EventObject; @@ -69,10 +70,13 @@ public class CostcompanyDefaultPlugin extends AbstractBillPlugIn implements Plu QFilter numberFilter = new QFilter("number",QCP.equals,costcompanyObj.getString("number")); DynamicObject[] dynamicObjectAccItem = BusinessDataServiceHelper.load("bos_costcenter", "number,name", new QFilter[]{numberFilter}); for (DynamicObject dynamicObject : dynamicObjectCollection) { - if(dynamicObjectAccItem!=null){ + if(dynamicObjectAccItem!=null && dynamicObjectAccItem.length>0){ dynamicObject.set("std_entrycostcenter",dynamicObjectAccItem[0]); - getView().updateView("expenseentryentity"); + }else{ + dynamicObject.set("std_entrycostcenter",null); } + getView().updateView("expenseentryentity"); + } } } @@ -124,7 +128,7 @@ public class CostcompanyDefaultPlugin extends AbstractBillPlugIn implements Plu //bos_costcenter QFilter numberFilter = new QFilter("number",QCP.equals,costcompanyObj.getString("number")); DynamicObject[] dynamicObjectAccItem = BusinessDataServiceHelper.load("bos_costcenter", "number,name", new QFilter[]{numberFilter}); - if(dynamicObjectAccItem!=null){ + if(dynamicObjectAccItem!=null && !dynamicObjectCollection.isEmpty()){ DynamicObject dynamicObject = dynamicObjectCollection.get(dynamicObjectCollection.size() - 1); dynamicObject.set("std_entrycostcenter",dynamicObjectAccItem[0]); } diff --git a/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/DailyloanbillExpAccPlugin.java b/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/DailyloanbillExpAccPlugin.java index 00b117e..16b07bc 100644 --- a/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/DailyloanbillExpAccPlugin.java +++ b/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/DailyloanbillExpAccPlugin.java @@ -21,16 +21,11 @@ import kd.bos.logging.LogFactory; import kd.bos.orm.query.QCP; import kd.bos.orm.query.QFilter; import kd.bos.servicehelper.BusinessDataServiceHelper; -import kd.bos.servicehelper.org.OrgUnitServiceHelper; import kd.bos.servicehelper.user.UserServiceHelper; -import kd.bos.tree.TreeFilterParameter; import kd.sdk.plugin.Plugin; +import zcgj.zcdev.zcdev.fs.utils.OrgCheckUtils; -import java.util.ArrayList; import java.util.EventObject; -import java.util.List; -import java.util.Set; -import java.util.stream.Collectors; /** * 借款单会计科目与费用项目关联插件 diff --git a/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/DailyreimbursExpAccPlugin.java b/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/DailyreimbursExpAccPlugin.java index b9b41c1..a919bf9 100644 --- a/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/DailyreimbursExpAccPlugin.java +++ b/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/DailyreimbursExpAccPlugin.java @@ -21,15 +21,11 @@ import kd.bos.logging.LogFactory; import kd.bos.orm.query.QCP; import kd.bos.orm.query.QFilter; import kd.bos.servicehelper.BusinessDataServiceHelper; -import kd.bos.servicehelper.org.OrgUnitServiceHelper; import kd.bos.servicehelper.user.UserServiceHelper; import kd.sdk.plugin.Plugin; +import zcgj.zcdev.zcdev.fs.utils.OrgCheckUtils; -import java.util.ArrayList; import java.util.EventObject; -import java.util.List; -import java.util.Set; -import java.util.stream.Collectors; /** * 费用报销单会计科目与费用项目关联插件 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 index 98ca42f..cce26ce 100644 --- 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 @@ -3,13 +3,6 @@ package zcgj.zcdev.zcdev.fs.plugin.form; import kd.bos.bill.AbstractBillPlugIn; import kd.bos.context.RequestContext; 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; @@ -18,17 +11,11 @@ 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.bos.servicehelper.org.OrgUnitServiceHelper; import kd.bos.servicehelper.user.UserServiceHelper; import kd.sdk.plugin.Plugin; +import zcgj.zcdev.zcdev.fs.utils.OrgCheckUtils; -import java.math.BigDecimal; -import java.util.ArrayList; import java.util.EventObject; -import java.util.List; -import java.util.Set; -import java.util.stream.Collectors; /** * 国外住宿费标准 diff --git a/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/PrepaybillContractPlugin.java b/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/PrepaybillContractPlugin.java index 63c6c13..20f8099 100644 --- a/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/PrepaybillContractPlugin.java +++ b/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/PrepaybillContractPlugin.java @@ -2,35 +2,19 @@ package zcgj.zcdev.zcdev.fs.plugin.form; import kd.bos.bill.AbstractBillPlugIn; import kd.bos.context.RequestContext; -import kd.bos.dataentity.entity.CloneUtils; import kd.bos.dataentity.entity.DynamicObject; import kd.bos.dataentity.entity.DynamicObjectCollection; -import kd.bos.entity.datamodel.ListSelectedRow; -import kd.bos.entity.datamodel.ListSelectedRowCollection; import kd.bos.entity.operate.Submit; -import kd.bos.form.CloseCallBack; -import kd.bos.form.ShowFormHelper; import kd.bos.form.events.BeforeDoOperationEventArgs; -import kd.bos.form.events.ClosedCallBackEvent; -import kd.bos.form.field.BasedataEdit; -import kd.bos.form.field.events.AfterF7SelectEvent; -import kd.bos.form.field.events.AfterF7SelectListener; -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.bos.servicehelper.org.OrgUnitServiceHelper; import kd.bos.servicehelper.user.UserServiceHelper; import kd.sdk.plugin.Plugin; +import zcgj.zcdev.zcdev.fs.utils.OrgCheckUtils; import java.time.LocalDate; import java.time.ZoneId; import java.util.*; -import java.util.stream.Collectors; /** * 预付单去年合同提醒插件 diff --git a/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/PrepaybillExpAccPlugin.java b/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/PrepaybillExpAccPlugin.java index 6f53d0f..566c237 100644 --- a/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/PrepaybillExpAccPlugin.java +++ b/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/PrepaybillExpAccPlugin.java @@ -21,15 +21,11 @@ import kd.bos.logging.LogFactory; import kd.bos.orm.query.QCP; import kd.bos.orm.query.QFilter; import kd.bos.servicehelper.BusinessDataServiceHelper; -import kd.bos.servicehelper.org.OrgUnitServiceHelper; import kd.bos.servicehelper.user.UserServiceHelper; import kd.sdk.plugin.Plugin; +import zcgj.zcdev.zcdev.fs.utils.OrgCheckUtils; -import java.util.ArrayList; import java.util.EventObject; -import java.util.List; -import java.util.Set; -import java.util.stream.Collectors; /** * 预付单会计科目与费用项目关联插件 diff --git a/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/PublicreimbursebillContractPlugin.java b/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/PublicreimbursebillContractPlugin.java index 223f34f..f451a28 100644 --- a/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/PublicreimbursebillContractPlugin.java +++ b/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/PublicreimbursebillContractPlugin.java @@ -8,20 +8,13 @@ import kd.bos.entity.operate.Submit; import kd.bos.form.events.BeforeDoOperationEventArgs; 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.bos.servicehelper.org.OrgUnitServiceHelper; import kd.bos.servicehelper.user.UserServiceHelper; import kd.sdk.plugin.Plugin; +import zcgj.zcdev.zcdev.fs.utils.OrgCheckUtils; import java.time.LocalDate; import java.time.ZoneId; -import java.util.ArrayList; import java.util.Date; -import java.util.List; -import java.util.Set; -import java.util.stream.Collectors; /** * 对公报销单去年合同提醒插件 diff --git a/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/PublicreimbursebillExpAccPlugin.java b/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/PublicreimbursebillExpAccPlugin.java index de79c9d..4a9d9d3 100644 --- a/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/PublicreimbursebillExpAccPlugin.java +++ b/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/PublicreimbursebillExpAccPlugin.java @@ -21,15 +21,11 @@ import kd.bos.logging.LogFactory; import kd.bos.orm.query.QCP; import kd.bos.orm.query.QFilter; import kd.bos.servicehelper.BusinessDataServiceHelper; -import kd.bos.servicehelper.org.OrgUnitServiceHelper; import kd.bos.servicehelper.user.UserServiceHelper; import kd.sdk.plugin.Plugin; +import zcgj.zcdev.zcdev.fs.utils.OrgCheckUtils; -import java.util.ArrayList; import java.util.EventObject; -import java.util.List; -import java.util.Set; -import java.util.stream.Collectors; /** * 对公报销单会计科目与费用项目关联插件 diff --git a/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/TriprAutoCalWorkingDaysPlugin.java b/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/TriprAutoCalWorkingDaysPlugin.java new file mode 100644 index 0000000..5cfda17 --- /dev/null +++ b/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/TriprAutoCalWorkingDaysPlugin.java @@ -0,0 +1,209 @@ +package zcgj.zcdev.zcdev.fs.plugin.form; + +import com.alibaba.druid.util.StringUtils; +import kd.bos.bill.AbstractBillPlugIn; +import kd.bos.context.RequestContext; +import kd.bos.dataentity.entity.DynamicObject; +import kd.bos.dataentity.entity.DynamicObjectCollection; +import kd.bos.entity.datamodel.events.ChangeData; +import kd.bos.entity.datamodel.events.PropertyChangedArgs; +import kd.bos.form.control.Button; +import kd.bos.form.control.Control; +import kd.bos.form.control.events.ItemClickEvent; +import kd.sdk.plugin.Plugin; +import zcgj.zcdev.zcdev.fs.utils.OrgCheckUtils; + +import java.text.SimpleDateFormat; +import java.time.DayOfWeek; +import java.time.LocalDate; +import java.time.ZoneId; +import java.util.*; + +/** + * 差旅报销单往返家居工作日天数自动计算插件 + */ +public class TriprAutoCalWorkingDaysPlugin extends AbstractBillPlugIn implements Plugin { + + @Override + public void propertyChanged(PropertyChangedArgs e) { + //当前切换选择的组织 + Object company = this.getModel().getValue("costcompany");//核算组织 + Long currentOrgId = RequestContext.get().getOrgId(); + DynamicObject companyObj = (DynamicObject)company; + Long companyId = companyObj.getLong("id"); + if(OrgCheckUtils.isKS(currentOrgId) && OrgCheckUtils.isKS(companyId)){ + String name = e.getProperty().getName(); + SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); + if(name.equals("zcgj_startdate") ||name.equals("zcgj_enddate")){ + ChangeData[] changeSet = e.getChangeSet(); + int rowIndex = changeSet[0].getRowIndex(); + calHomeentityDay(rowIndex); + Set allSet = new HashSet<>(); + Set localDates1 = calHomeentityDay(); + Set localDates2 = calTripentryDay(); + allSet.addAll(localDates1); + allSet.addAll(localDates2); + this.getModel().setValue("zcgj_kccbdays",allSet.size()); + } else if(name.equals("startdate") ||name.equals("enddate")){ + // 计算结果 + Set allSet = new HashSet<>(); + Set localDates1 = calHomeentityDay(); + Set localDates2 = calTripentryDay(); + allSet.addAll(localDates1); + allSet.addAll(localDates2); + this.getModel().setValue("zcgj_kccbdays",allSet.size()); + } + + } + super.propertyChanged(e); + + } + + @Override + public void registerListener(EventObject e) { + super.registerListener(e); + Object company = this.getModel().getValue("costcompany");//核算组织 + if(company!=null){ + Long currentOrgId = RequestContext.get().getOrgId(); + DynamicObject companyObj = (DynamicObject)company; + Long companyId = companyObj.getLong("id"); + String companyNumber = companyObj.getString("number"); + if(OrgCheckUtils.isKS(currentOrgId) && OrgCheckUtils.isKS(companyId)){ + //监听工具栏按钮点击事件 + this.addItemClickListeners("zcgj_hometoolbarap"); + // 按钮点击 + Button button = this.getView().getControl("deltripentry"); + button.addClickListener(this); + } + } + } + + @Override + public void itemClick(ItemClickEvent evt) { + super.itemClick(evt); + if (evt.getItemKey().equals("zcgj_delhome")) { + Set allSet = new HashSet<>(); + Set localDates1 = calHomeentityDay(); + Set localDates2 = calTripentryDay(); + allSet.addAll(localDates1); + allSet.addAll(localDates2); + this.getModel().setValue("zcgj_kccbdays",allSet.size()); + getView().updateView(); + } + } + + @Override + + public void click(EventObject evt) { + Control source = (Control)evt.getSource(); + if (StringUtils.equals("deltripentry", source.getKey())){ + Set allSet = new HashSet<>(); + Set localDates1 = calHomeentityDay(); + Set localDates2 = calTripentryDay(); + allSet.addAll(localDates1); + allSet.addAll(localDates2); + this.getModel().setValue("zcgj_kccbdays",allSet.size()); + } + } + + public int calHomeentityDay(int rowIndex){ + //获取分录 + DynamicObject dataEntity = this.getModel().getDataEntity(true); + DynamicObjectCollection dynamicObjectCollection = dataEntity.getDynamicObjectCollection("zcgj_homeentity"); + DynamicObject dynamicObject = dynamicObjectCollection.get(rowIndex); + Date zcgjStartdate = dynamicObject.getDate("zcgj_startdate"); + Date zcgjEnddate = dynamicObject.getDate("zcgj_enddate"); + int allHomeCount = 0; + if(zcgjStartdate!=null && zcgjEnddate!=null){ + Set datesExcludingWeekends = getDatesExcludingWeekends(dateToLocalDate(zcgjStartdate), dateToLocalDate(zcgjEnddate)); + allHomeCount = datesExcludingWeekends.size(); + this.getModel().setValue("zcgj_kccbdaycount",allHomeCount); + } + return allHomeCount; + } + + public Set calHomeentityDay(){ + //获取分录 + DynamicObject dataEntity = this.getModel().getDataEntity(true); + DynamicObjectCollection dynamicObjectCollection = dataEntity.getDynamicObjectCollection("zcgj_homeentity"); + Set addDateSet = new HashSet<>(); + for (DynamicObject dynamicObject : dynamicObjectCollection) { + Date zcgjStartdate = dynamicObject.getDate("zcgj_startdate"); + Date zcgjEnddate = dynamicObject.getDate("zcgj_enddate"); + if(zcgjStartdate!=null && zcgjEnddate!=null){ + Set datesExcludingWeekends = getDatesExcludingWeekends(dateToLocalDate(zcgjStartdate), dateToLocalDate(zcgjEnddate)); + addDateSet.addAll(datesExcludingWeekends); + } + } + return addDateSet; + } + + public Set calTripentryDay(){ + int allHomeCount = 0; + DynamicObjectCollection dynamicObjectCollection = this.getModel().getDataEntity() + .getDynamicObjectCollection("tripentry"); + Set addDateSet = new HashSet<>(); + for (DynamicObject dynamicObject : dynamicObjectCollection) { + Date startdate = dynamicObject.getDate("startdate"); + Date enddate = dynamicObject.getDate("enddate"); + if(startdate!=null && enddate!=null){ + Set datesExcludingWeekends = getStartAndEnd(dateToLocalDate(startdate), dateToLocalDate(enddate)); + addDateSet.addAll(datesExcludingWeekends); + } + } + + return addDateSet; + } + + //获取开始结束时间 + public static Set getStartAndEnd(LocalDate startDate, LocalDate endDate) { + Set result = new HashSet<>(); + + // 判断开始日期和结束日期是否为周末 + if (!isWeekend(startDate)) { + result.add(startDate); + } + + if (!isWeekend(endDate)) { + result.add(endDate); + } + + return result; + } + + //去除开始日期结束日期,移除周六日 + public static Set getDatesExcludingWeekends(LocalDate startDate, LocalDate endDate) { + Set result = new HashSet<>(); + + // 计算从开始日期到结束日期之间的日期 + LocalDate currentDate = startDate.plusDays(1); // 排除开始日期 + LocalDate lastDate = endDate.minusDays(1); // 排除结束日期 + + // 遍历日期范围 + while (!currentDate.isAfter(lastDate)) { + if (!isWeekend(currentDate)) { + result.add(currentDate); + } + currentDate = currentDate.plusDays(1); + } + + return result; + } + + private static boolean isWeekend(LocalDate date) { + return date.getDayOfWeek() == DayOfWeek.SATURDAY || date.getDayOfWeek() == DayOfWeek.SUNDAY; + } + /** + * 将 java.util.Date 转换为 java.time.LocalDate + * @param date java.util.Date + * @return java.time.LocalDate + */ + public static LocalDate dateToLocalDate(Date date) { + if (date == null) { + throw new IllegalArgumentException("日期不能为 null"); + } + return date.toInstant() + .atZone(ZoneId.systemDefault()) + .toLocalDate(); + } +} diff --git a/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/TriprCostcompanyDefaultPlugin.java b/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/TriprCostcompanyDefaultPlugin.java index 2f125a1..2bc1961 100644 --- a/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/TriprCostcompanyDefaultPlugin.java +++ b/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/TriprCostcompanyDefaultPlugin.java @@ -11,6 +11,7 @@ import kd.bos.orm.query.QFilter; import kd.bos.servicehelper.BusinessDataServiceHelper; import kd.bos.servicehelper.user.UserServiceHelper; import kd.sdk.plugin.Plugin; +import zcgj.zcdev.zcdev.fs.utils.OrgCheckUtils; import java.util.EventObject; @@ -65,7 +66,11 @@ public class TriprCostcompanyDefaultPlugin extends AbstractBillPlugIn implements if(costcompanyObj!=null){ QFilter numberFilter = new QFilter("number",QCP.equals,costcompanyObj.getString("number")); DynamicObject[] dynamicObjectAccItem = BusinessDataServiceHelper.load("bos_costcenter", "number,name", new QFilter[]{numberFilter}); - this.getModel().setValue("std_costcenter",dynamicObjectAccItem[0]); + if(dynamicObjectAccItem != null && dynamicObjectAccItem.length>0){ + this.getModel().setValue("std_costcenter",dynamicObjectAccItem[0]); + }else{ + this.getModel().setValue("std_costcenter",null); + } getView().updateView("std_costcenter"); } } 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 index 7395b0f..db3528e 100644 --- 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 @@ -9,15 +9,14 @@ 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.bos.servicehelper.org.OrgUnitServiceHelper; import kd.bos.servicehelper.user.UserServiceHelper; import kd.sdk.plugin.Plugin; +import zcgj.zcdev.zcdev.fs.utils.OrgCheckUtils; import java.io.InputStream; import java.math.BigDecimal; import java.math.RoundingMode; import java.util.*; -import java.util.stream.Collectors; /** * 差旅报销单国外住宿标准提醒插件 diff --git a/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/operate/DailyreimbursHomeCheckOp.java b/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/operate/DailyreimbursHomeCheckOp.java index 7f6a6e8..6ea2c3f 100644 --- a/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/operate/DailyreimbursHomeCheckOp.java +++ b/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/operate/DailyreimbursHomeCheckOp.java @@ -15,7 +15,7 @@ import kd.bos.orm.query.QFilter; import kd.bos.servicehelper.QueryServiceHelper; import kd.bos.servicehelper.user.UserServiceHelper; import kd.bos.util.StringUtils; -import zcgj.zcdev.zcdev.fs.plugin.form.OrgCheckUtils; +import zcgj.zcdev.zcdev.fs.utils.OrgCheckUtils; import java.text.SimpleDateFormat; import java.time.LocalDate; diff --git a/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/operate/DailyreimbursVisitCheckOp.java b/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/operate/DailyreimbursVisitCheckOp.java index 484e16e..aae9416 100644 --- a/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/operate/DailyreimbursVisitCheckOp.java +++ b/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/operate/DailyreimbursVisitCheckOp.java @@ -11,11 +11,9 @@ import kd.bos.entity.plugin.PreparePropertysEventArgs; import kd.bos.entity.validate.AbstractValidator; import kd.bos.orm.query.QCP; import kd.bos.orm.query.QFilter; -import kd.bos.servicehelper.BusinessDataServiceHelper; import kd.bos.servicehelper.QueryServiceHelper; -import kd.bos.servicehelper.org.OrgUnitServiceHelper; import kd.bos.servicehelper.user.UserServiceHelper; -import zcgj.zcdev.zcdev.fs.plugin.form.OrgCheckUtils; +import zcgj.zcdev.zcdev.fs.utils.OrgCheckUtils; import java.text.SimpleDateFormat; import java.time.LocalDate; @@ -23,7 +21,6 @@ import java.time.Month; import java.time.ZoneId; import java.time.temporal.TemporalAdjusters; import java.util.*; -import java.util.stream.Collectors; /** * 费用报销单探亲检查 diff --git a/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/operate/TripreimbursebillIsHomeCheckOp.java b/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/operate/TripreimbursebillIsHomeCheckOp.java index c1e5286..c9b51c9 100644 --- a/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/operate/TripreimbursebillIsHomeCheckOp.java +++ b/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/operate/TripreimbursebillIsHomeCheckOp.java @@ -15,13 +15,12 @@ import kd.bos.orm.query.QFilter; import kd.bos.servicehelper.QueryServiceHelper; import kd.bos.servicehelper.user.UserServiceHelper; import kd.bos.util.StringUtils; -import zcgj.zcdev.zcdev.fs.plugin.form.OrgCheckUtils; +import zcgj.zcdev.zcdev.fs.utils.OrgCheckUtils; import java.text.SimpleDateFormat; import java.time.LocalDate; import java.time.Month; import java.time.ZoneId; -import java.time.format.DateTimeFormatter; import java.time.temporal.TemporalAdjusters; import java.util.*; diff --git a/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/operate/TripreimbursebillUpOp.java b/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/operate/TripreimbursebillUpOp.java index c7df556..61f9eff 100644 --- a/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/operate/TripreimbursebillUpOp.java +++ b/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/operate/TripreimbursebillUpOp.java @@ -10,19 +10,11 @@ import kd.bos.entity.plugin.PreparePropertysEventArgs; import kd.bos.entity.validate.AbstractValidator; 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.bos.servicehelper.org.OrgUnitServiceHelper; import kd.bos.servicehelper.user.UserServiceHelper; -import zcgj.zcdev.zcdev.fs.plugin.form.OrgCheckUtils; +import zcgj.zcdev.zcdev.fs.utils.OrgCheckUtils; import java.math.BigDecimal; import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.List; -import java.util.Set; -import java.util.stream.Collectors; /** * 差旅报销单上浮20%控制 diff --git a/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/report/EmpTravelRptQueryPlugin.java b/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/report/EmpTravelRptQueryPlugin.java index 2ff30d2..f374a7d 100644 --- a/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/report/EmpTravelRptQueryPlugin.java +++ b/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/report/EmpTravelRptQueryPlugin.java @@ -116,15 +116,14 @@ public class EmpTravelRptQueryPlugin extends AbstractReportListDataPlugin { for (Row row : tripreimbursebill) { String billno = row.getString("billno"); int kccbdays = row.getInteger("kccbdays");//扣除餐补天数(周六日、节假日) - - String startdateStr = dateFormat.format(row.getDate("startdate"));// + LocalDate bizdate = dateToLocalDate(row.getDate("bizdate")); + /* String startdateStr = dateFormat.format(row.getDate("startdate"));// String enddateStr = dateFormat.format(row.getDate("enddate")); String bxmonthStr = dateFormat.format(row.getDate("bxmonth"));//归属月份 - int homedaycount = row.getInteger("homedaycount");//工作天日数 - - LocalDate bxmonth = dateToLocalDate(row.getDate("bxmonth")); - monthDaysMap.put(bxmonth.getMonth().getValue(), - monthDaysMap.getOrDefault(bxmonth.getMonth().getValue(), 0) + homedaycount); + int homedaycount = row.getInteger("homedaycount");//工作天日数*/ + //LocalDate bxmonth = dateToLocalDate(row.getDate("bxmonth")); + monthDaysMap.put(bizdate.getMonth().getValue(), + monthDaysMap.getOrDefault(bizdate.getMonth().getValue(), 0) + kccbdays); } @@ -132,15 +131,14 @@ public class EmpTravelRptQueryPlugin extends AbstractReportListDataPlugin { for (Row row : dailyreimbursebill) { String billno = row.getString("billno"); int kccbdays = row.getInteger("kccbdays");//扣除餐补天数(周六日、节假日) - - String startdateStr = dateFormat.format(row.getDate("startdate"));// + /*String startdateStr = dateFormat.format(row.getDate("startdate"));// String enddateStr = dateFormat.format(row.getDate("enddate")); - String bxmonthStr = dateFormat.format(row.getDate("bxmonth"));//归属月份 - int homedaycount = row.getInteger("homedaycount");//工作天日数 - - LocalDate bxmonth = dateToLocalDate(row.getDate("bxmonth")); - monthDaysMap.put(bxmonth.getMonth().getValue(), - monthDaysMap.getOrDefault(bxmonth.getMonth().getValue(), 0) + homedaycount); + String bxmonthStr = dateFormat.format(row.getDate("bxmonth"));//归属月份*/ + // int homedaycount = row.getInteger("homedaycount");//工作天日数 + //LocalDate bxmonth = dateToLocalDate(row.getDate("bxmonth")); + LocalDate bizdate = dateToLocalDate(row.getDate("bizdate")); + monthDaysMap.put(bizdate.getMonth().getValue(), + monthDaysMap.getOrDefault(bizdate.getMonth().getValue(), 0) + kccbdays); } } @@ -196,15 +194,24 @@ public class EmpTravelRptQueryPlugin extends AbstractReportListDataPlugin { searchFilterList.add(new QFilter("applier", QCP.equals, applierId)); searchFilterList.add(new QFilter( "zcgj_is_include_home", QCP.equals, true)); searchFilterList.add(new QFilter("billstatus", QCP.in, billStatuslist)); - searchFilterList.add( new QFilter("zcgj_homeentity.zcgj_bxmonth", QCP.large_equals, firstDay)); - searchFilterList.add(new QFilter("zcgj_homeentity.zcgj_bxmonth", QCP.less_equals, lastDay)); - DataSet dateSet = QueryServiceHelper.queryDataSet( + searchFilterList.add( new QFilter("bizdate", QCP.large_equals, firstDay)); + searchFilterList.add( new QFilter("bizdate", QCP.less_equals, lastDay)); + //searchFilterList.add( new QFilter("zcgj_homeentity.zcgj_bxmonth", QCP.large_equals, firstDay)); + //searchFilterList.add(new QFilter("zcgj_homeentity.zcgj_bxmonth", QCP.less_equals, lastDay)); + /*DataSet dateSet = QueryServiceHelper.queryDataSet( this.getClass().getName(), "er_tripreimbursebill", "id,billno,zcgj_kccbdays as kccbdays,zcgj_homeentity,zcgj_homeentity.zcgj_bxmonth as bxmonth," + "zcgj_homeentity.zcgj_startdate as startdate,zcgj_homeentity.zcgj_enddate as enddate," + "zcgj_homeentity.zcgj_homebz as homebz,zcgj_homeentity.zcgj_homedaycount as homedaycount", searchFilterList.toArray(new QFilter [] {}), null + );*/ + + DataSet dateSet = QueryServiceHelper.queryDataSet( + this.getClass().getName(), + "er_tripreimbursebill", + "id,billno,zcgj_kccbdays as kccbdays,bizdate", + searchFilterList.toArray(new QFilter [] {}), null ); return dateSet; } @@ -233,9 +240,12 @@ public class EmpTravelRptQueryPlugin extends AbstractReportListDataPlugin { List searchFilterList = new ArrayList<>(); //查询申请人下的今年的探亲差旅单据 searchFilterList.add(new QFilter("applier", QCP.equals, applierId)); - searchFilterList.add(new QFilter( "zcgj_is_home", QCP.equals, true)); + searchFilterList.add(new QFilter( "zcgj_is_home", QCP.equals, true) + .or(new QFilter( "zcgj_is_visit", QCP.equals, true))); searchFilterList.add(new QFilter("billstatus", QCP.in, billStatuslist)); - searchFilterList.add( new QFilter("zcgj_homeentity.zcgj_bxmonth", QCP.large_equals, firstDay)); + searchFilterList.add( new QFilter("bizdate", QCP.large_equals, firstDay)); + searchFilterList.add(new QFilter("bizdate", QCP.less_equals, lastDay)); + /*searchFilterList.add( new QFilter("zcgj_homeentity.zcgj_bxmonth", QCP.large_equals, firstDay)); searchFilterList.add(new QFilter("zcgj_homeentity.zcgj_bxmonth", QCP.less_equals, lastDay)); DataSet dateSet = QueryServiceHelper.queryDataSet( this.getClass().getName(), @@ -244,6 +254,12 @@ public class EmpTravelRptQueryPlugin extends AbstractReportListDataPlugin { "zcgj_homeentity.zcgj_startdate as startdate,zcgj_homeentity.zcgj_enddate as enddate," + "zcgj_homeentity.zcgj_homebz as homebz,zcgj_homeentity.zcgj_homedaycount as homedaycount", searchFilterList.toArray(new QFilter [] {}), null + );*/ + DataSet dateSet = QueryServiceHelper.queryDataSet( + this.getClass().getName(), + "er_dailyreimbursebill", + "id,billno,zcgj_kccbdays as kccbdays,bizdate", + searchFilterList.toArray(new QFilter [] {}), null ); return dateSet; } diff --git a/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/OrgCheckUtils.java b/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/utils/OrgCheckUtils.java similarity index 97% rename from code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/OrgCheckUtils.java rename to code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/utils/OrgCheckUtils.java index d83c94f..83a62ff 100644 --- a/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/OrgCheckUtils.java +++ b/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/utils/OrgCheckUtils.java @@ -1,4 +1,4 @@ -package zcgj.zcdev.zcdev.fs.plugin.form; +package zcgj.zcdev.zcdev.fs.utils; import kd.bos.dataentity.entity.DynamicObject; import kd.bos.orm.query.QCP;