From a609a1a37a5af7825f5ea2f8d5ef1367f95b0c0d Mon Sep 17 00:00:00 2001 From: zhangzhiguo Date: Fri, 27 Dec 2024 17:28:39 +0800 Subject: [PATCH 1/5] =?UTF-8?q?.=E5=90=88=E5=90=8C=E5=8F=B0=E8=B4=A6?= =?UTF-8?q?=E7=AD=BE=E7=BA=A6=E6=96=B9=E9=BB=98=E8=AE=A4=E4=B8=BA=E5=BD=93?= =?UTF-8?q?=E5=89=8D=E6=A0=B8=E7=AE=97=E7=BB=84=E7=BB=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../form/ContractbillContractpartyDefaultPlugin.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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 dd26891..68deb2e 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 @@ -2,6 +2,7 @@ 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.servicehelper.user.UserServiceHelper; import kd.sdk.plugin.Plugin; @@ -23,7 +24,12 @@ public class ContractbillContractpartyDefaultPlugin extends AbstractBillPlugIn Long currentOrgId = RequestContext.get().getOrgId(); //当前所在的组织是属于矿山下的 if(OrgCheckUtils.isKS(currentOrgId)){ - this.getModel().setValue("contractparty",mainOrgId); + Object company = this.getModel().getValue("costcompany");//核算组织 + if(company!=null){ + DynamicObject companyObj = (DynamicObject)company; + this.getModel().setValue("contractparty",companyObj); + + } } } } From 2fc98ac0607c083c5b77b1fc5dfc6bc5df47df9b Mon Sep 17 00:00:00 2001 From: zhangzhiguo Date: Tue, 31 Dec 2024 15:14:51 +0800 Subject: [PATCH 2/5] =?UTF-8?q?1.=E8=B4=B9=E7=94=A8=E6=8A=A5=E9=94=80?= =?UTF-8?q?=E5=8D=95=E5=92=8C=E5=B7=AE=E6=97=85=E6=8A=A5=E9=94=80=E5=8D=95?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=BE=80=E6=9D=A5=E5=B1=85=E5=AE=B6=E6=A0=A1?= =?UTF-8?q?=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../operate/DailyreimbursHomeCheckOp.java | 315 +++++++++++++++++ .../operate/DailyreimbursVisitCheckOp.java | 67 +--- .../TripreimbursebillIsHomeCheckOp.java | 316 ++++++++++++++++++ 3 files changed, 640 insertions(+), 58 deletions(-) create mode 100644 code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/operate/DailyreimbursHomeCheckOp.java create mode 100644 code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/operate/TripreimbursebillIsHomeCheckOp.java 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 new file mode 100644 index 0000000..4962d41 --- /dev/null +++ b/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/operate/DailyreimbursHomeCheckOp.java @@ -0,0 +1,315 @@ +package zcgj.zcdev.zcdev.fs.plugin.operate; + +import kd.bos.algo.DataSet; +import kd.bos.algo.Row; +import kd.bos.context.RequestContext; +import kd.bos.dataentity.entity.DynamicObject; +import kd.bos.dataentity.entity.DynamicObjectCollection; +import kd.bos.entity.ExtendedDataEntity; +import kd.bos.entity.plugin.AbstractOperationServicePlugIn; +import kd.bos.entity.plugin.AddValidatorsEventArgs; +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.QueryServiceHelper; +import kd.bos.servicehelper.user.UserServiceHelper; +import kd.bos.util.StringUtils; +import zcgj.zcdev.zcdev.fs.plugin.form.OrgCheckUtils; + +import java.text.SimpleDateFormat; +import java.time.LocalDate; +import java.time.Month; +import java.time.ZoneId; +import java.time.temporal.TemporalAdjusters; +import java.util.*; + +/** + * 费用报销单往来家居检查操作 + */ +public class DailyreimbursHomeCheckOp extends AbstractOperationServicePlugIn { + private static final String prefix ="zcgj"; + @Override + public void onPreparePropertys(PreparePropertysEventArgs e) { + super.onPreparePropertys(e); + e.getFieldKeys().add("zcgj_is_home"); + e.getFieldKeys().add("applier"); + e.getFieldKeys().add("zcgj_homeentity"); + } + + @Override + public void onAddValidators(AddValidatorsEventArgs e) { + super.onAddValidators(e); + Long currentUserId = UserServiceHelper.getCurrentUserId(); + // 当前用户所属组织 + Long mainOrgId = UserServiceHelper.getUserMainOrgId(currentUserId); + //当前切换选择的组织 + Long currentOrgId = RequestContext.get().getOrgId(); + //当前所在的组织是属于矿山下的 + if(OrgCheckUtils.isKS(currentOrgId)){ + e.getValidators().add(new ValidatorExt()); + } + } + + class ValidatorExt extends AbstractValidator { + @Override + public void validate() { + SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM"); + ExtendedDataEntity[] extendedDataEntities = this.getDataEntities(); + Map> allMap = new HashMap<>(); + //当前提交的探亲单据id集合 + Map> currentBillIdListMap = new HashMap<>(); + + for (ExtendedDataEntity extendedDataEntity : extendedDataEntities) { + DynamicObject dataEntity = extendedDataEntity.getDataEntity(); + long aLong = dataEntity.getLong("id"); + //获取报销人 + DynamicObject applier = dataEntity.getDynamicObject("applier"); + long applierId = applier.getLong("id"); + //获取申请日期 + //Date bizdate = dataEntity.getDate( "bizdate"); + //获取是否探亲 + //如果是探亲,则进行逻辑判断 + boolean isHome = dataEntity.getBoolean(prefix + "_is_home"); + + //判断是否来往家居地 + if(isHome){ + //获取当前人的往来家居地配置 + QFilter[] visitSetFilterArray = new QFilter[1]; + visitSetFilterArray[0] = new QFilter(prefix+"_user", QCP.equals, applierId); + DataSet homeDataSet = QueryServiceHelper.queryDataSet( + this.getClass().getName(), + prefix+"_user_home_conf", + "id,zcgj_month_times as monthTime", + visitSetFilterArray, null + ); + int monthTime = 0; + for (Row row : homeDataSet) { + monthTime = row.getInteger("monthTime"); + } + if(monthTime != 0){ + DynamicObjectCollection tripentry = dataEntity.getDynamicObjectCollection("zcgj_homeentity");//oa流程分录 + Map homeentityCountMap = new HashMap<>(); + int i = 1; + boolean isOk=true; + for (DynamicObject dynamicObject : tripentry) { + Date bxmonth = dynamicObject.getDate("zcgj_bxmonth"); + String yearMonth = dateFormat.format(bxmonth); + + String bxmonthStr = dateFormat.format(bxmonth); + String startdateStr = dateFormat.format(dynamicObject.getDate("zcgj_startdate")); + String enddateStr = dateFormat.format(dynamicObject.getDate("zcgj_enddate")); + isOk = checkBelongMonth(bxmonthStr, startdateStr, enddateStr); + if(!isOk){ + this.addFatalErrorMessage(extendedDataEntity, String.format("当前单据中往来居家明细的第%d行,往返日期不在报销归属月中!",i)); + } + // 更新统计次数 + homeentityCountMap.put(yearMonth, homeentityCountMap.getOrDefault(yearMonth, 0) + 1); + i++; + } + // 输出结果 + for (Map.Entry entry : homeentityCountMap.entrySet()) { + if(entry.getValue() > monthTime){ + String message = String.format("当前单据在%s月中提交了%d次往来居家,往来居家次数超限,限制每月%d次!",entry.getKey(),entry.getValue() ,monthTime); + isOk= false; + this.addFatalErrorMessage(extendedDataEntity, message); + } + //System.out.println(entry.getKey() + ": " + entry.getValue() + " 次"); + } + if(isOk){ + for (DynamicObject dynamicObject : tripentry) { + Date bxmonth = dynamicObject.getDate("zcgj_bxmonth"); + DataSet tripreimbursebill = getTripreimbursebill(bxmonth, applierId); + //已用次数 + int goHomeCount = 0; + StringBuilder trSb = new StringBuilder(); + for (Row row : tripreimbursebill) { + goHomeCount++; + String billno = row.getString("billno"); + /*String bxmonthStr = dateFormat.format(row.getDate("bxmonth")); + String startdateStr = dateFormat.format(row.getDate("startdate")); + String enddateStr = dateFormat.format(row.getDate("enddate")); + boolean b = checkBelongMonth(bxmonthStr, startdateStr, enddateStr);*/ + trSb.append(billno).append(";"); + } + DataSet dailyreimbursebill = getDailyreimbursebill(bxmonth, applierId); + StringBuilder daSb = new StringBuilder(); + for (Row row : dailyreimbursebill) { + goHomeCount++; + String billno = row.getString("billno"); + /* String bxmonthStr = dateFormat.format(row.getDate("bxmonth")); + String startdateStr = dateFormat.format(row.getDate("startdate")); + String enddateStr = dateFormat.format(row.getDate("enddate")); + boolean b = checkBelongMonth(bxmonthStr, startdateStr, enddateStr);*/ + daSb.append(billno).append(";"); + } + + if(goHomeCount >= monthTime){ + int monthVal = getFirstDayOfMonth(bxmonth).getMonth().getValue(); + String message = String.format("请知悉:您每月共有%d次往来家居地报销次数,在%d月中已进行过%d次来往家居地报销。",monthTime,monthVal,goHomeCount); + if(!StringUtils.isBlank(trSb.toString())){ + message+="已提交的差旅报销单:【"+trSb.toString()+"】 "; + } + if(!StringUtils.isBlank(daSb.toString())){ + message+="已提交的费用报销单:【"+daSb.toString()+"】 "; + } + this.addFatalErrorMessage(extendedDataEntity, message); + } + } + } + } + } + } + } + } + // 判断归属月份是否与开始时间或结束时间的月份相同 + public static boolean checkBelongMonth(String belongMonth, String startDate, String endDate) { + // 比较归属月份是否与开始时间或结束时间的月份相同 + return belongMonth.equals(startDate) || belongMonth.equals(endDate); + + } + /** + * 获取差旅费报销单 + * @param bxmonth + * @param applierId + * @return + */ + public DataSet getTripreimbursebill(Date bxmonth,long applierId){ + //查询非暂存、废弃的数据 + List billStatuslist = new ArrayList<>(); + billStatuslist.add("B"); + billStatuslist.add("C"); + billStatuslist.add("D"); + billStatuslist.add("E"); + billStatuslist.add("F"); + billStatuslist.add("G"); + LocalDate firstDayOfMonth = getFirstDayOfMonth(bxmonth); + LocalDate lastDayOfMonth = getLastDayOfMonth(bxmonth); + QFilter[] filterArray = new QFilter[5]; + //查询申请人下的今年的探亲差旅单据 + filterArray[0] = new QFilter("zcgj_homeentity.zcgj_bxmonth", QCP.large_equals, firstDayOfMonth); + filterArray[1] = new QFilter("zcgj_homeentity.zcgj_bxmonth", QCP.less_equals, lastDayOfMonth); + filterArray[2] = new QFilter("applier", QCP.equals, applierId); + filterArray[3] = new QFilter(prefix+"_is_include_home", QCP.equals, true); + filterArray[4] = new QFilter("billstatus", QCP.in, billStatuslist); + DataSet dateSet = QueryServiceHelper.queryDataSet( + this.getClass().getName(), + "er_tripreimbursebill", + "id,billno,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", + filterArray, null + ); + return dateSet; + } + + /** + * 获取费用报销单 + * @param bxmonth + * @param applierId + * @return + */ + public DataSet getDailyreimbursebill(Date bxmonth,long applierId){ + //查询非暂存、废弃的数据 + List billStatuslist = new ArrayList<>(); + billStatuslist.add("B"); + billStatuslist.add("C"); + billStatuslist.add("D"); + billStatuslist.add("E"); + billStatuslist.add("F"); + billStatuslist.add("G"); + + LocalDate firstDayOfMonth = getFirstDayOfMonth(bxmonth); + LocalDate lastDayOfMonth = getLastDayOfMonth(bxmonth); + QFilter[] filterArray = new QFilter[5]; + //查询申请人下的今年的探亲差旅单据 + filterArray[0] = new QFilter("zcgj_homeentity.zcgj_bxmonth", QCP.large_equals, firstDayOfMonth); + filterArray[1] = new QFilter("zcgj_homeentity.zcgj_bxmonth", QCP.less_equals, lastDayOfMonth); + filterArray[2] = new QFilter("applier", QCP.equals, applierId); + filterArray[3] = new QFilter(prefix+"_is_home", QCP.equals, true); + filterArray[4] = new QFilter("billstatus", QCP.in, billStatuslist); + DataSet dateSet = QueryServiceHelper.queryDataSet( + this.getClass().getName(), + "er_dailyreimbursebill", + "id,billno,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", + filterArray, null + ); + return dateSet; + } + + /** + * 将 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(); + } + + /** + * 获取指定日期所在年份的第一天 + * @param date java.util.Date + * @return java.util.Date + */ + public static Date getFirstDayOfYear(Date date) { + LocalDate localDate = dateToLocalDate(date); + LocalDate firstDayOfYear = LocalDate.of(localDate.getYear(), Month.JANUARY, 1); + return Date.from(firstDayOfYear.atStartOfDay(ZoneId.systemDefault()).toInstant()); + } + + /** + * 获取指定日期所在年份的最后一天 + * @param date java.util.Date + * @return java.util.Date + */ + public static Date getLastDayOfYear(Date date) { + LocalDate localDate = dateToLocalDate(date); + LocalDate lastDayOfYear = LocalDate.of(localDate.getYear(), Month.DECEMBER, 31); + return Date.from(lastDayOfYear.atStartOfDay(ZoneId.systemDefault()).toInstant()); + } + + /** + * 获取指定日期所在月份的第一天 + * @param date 指定日期 + * @return LocalDate 所在月份的第一天 + */ + public static LocalDate getFirstDayOfMonth(Date date) { + LocalDate localDate = dateToLocalDate(date); + return localDate.with(TemporalAdjusters.firstDayOfMonth()); + } + + /** + * 获取指定日期所在月份的最后一天 + * @param date 指定日期 + * @return LocalDate 所在月份的最后一天 + */ + public static LocalDate getLastDayOfMonth(Date date) { + LocalDate localDate = dateToLocalDate(date); + return localDate.with(TemporalAdjusters.lastDayOfMonth()); + } + + /** + * 获取指定年限-1年前的第一天 + * @param date 指定日期 + * @param years 年限值 + * @return LocalDate 年限-1年前的第一天 + */ + public static LocalDate getFirstDayYearsAgo(LocalDate date, int years) { + if (date == null) { + throw new IllegalArgumentException("日期不能为空"); + } + if (years < 1) { + throw new IllegalArgumentException("年限值必须大于等于 1"); + } + return LocalDate.of(date.getYear() - (years - 1), Month.JANUARY, 1); + } + +} + 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 12d8219..484e16e 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 @@ -75,24 +75,23 @@ public class DailyreimbursVisitCheckOp extends AbstractOperationServicePlugIn { //获取报销人 DynamicObject applier = dataEntity.getDynamicObject("applier"); long applierId = applier.getLong("id"); - //获取休假开始时间 - Date startTime = dataEntity.getDate(prefix + "_holiday_start_time"); - //获取休假结束时间 - Date endTime = dataEntity.getDate(prefix + "_holiday_end_time"); - //获取休假天数 - Integer days = dataEntity.getInt(prefix + "_holiday_days"); //获取申请日期 - Date bizdate = dataEntity.getDate( "bizdate"); + //Date bizdate = dataEntity.getDate( "bizdate"); //获取是否探亲 //如果是探亲,则进行逻辑判断 boolean isVisit = dataEntity.getBoolean(prefix + "_is_visit"); boolean isHome = dataEntity.getBoolean(prefix + "_is_home"); - //探亲类型 1:探望父母,2:探望配偶 - String visitType = dataEntity.getString(prefix + "_visit_type"); //判断是否探亲 if(isVisit){ - + //获取休假开始时间 + Date startTime = dataEntity.getDate(prefix + "_holiday_start_time"); + //获取休假结束时间 + Date endTime = dataEntity.getDate(prefix + "_holiday_end_time"); + //获取休假天数 + Integer days = dataEntity.getInt(prefix + "_holiday_days"); + //探亲类型 1:探望父母,2:探望配偶 + String visitType = dataEntity.getString(prefix + "_visit_type"); //获取当前人的探亲假配置 QFilter[] visitSetFilterArray = new QFilter[1]; visitSetFilterArray[0] = new QFilter(prefix+"_user", QCP.equals, applierId); @@ -260,54 +259,6 @@ public class DailyreimbursVisitCheckOp extends AbstractOperationServicePlugIn { return; } } - //判断是否来往家居地 - if(isHome){ - //获取当前人的往来家居地配置 - QFilter[] visitSetFilterArray = new QFilter[1]; - visitSetFilterArray[0] = new QFilter(prefix+"_user", QCP.equals, applierId); - DataSet homeDataSet = QueryServiceHelper.queryDataSet( - this.getClass().getName(), - prefix+"_user_home_conf", - "id,zcgj_month_times as monthTime", - visitSetFilterArray, null - ); - Integer monthTime = null; - for (Row row : homeDataSet) { - monthTime = row.getInteger("monthTime"); - } - - - //获取申请人在月份的单据量 - LocalDate firstDayOfMonth = getFirstDayOfMonth(bizdate); - LocalDate lastDayOfMonth = getLastDayOfMonth(bizdate); - QFilter[] filterArray = new QFilter[4]; - //查询申请人下的今年的探亲差旅单据 - filterArray[0] = new QFilter("bizdate", QCP.large_equals, firstDayOfMonth); - filterArray[1] = new QFilter("bizdate", QCP.less_equals, lastDayOfMonth); - filterArray[2] = new QFilter("applier", QCP.equals, applierId); - filterArray[3] = new QFilter(prefix+"_is_home", QCP.equals, true); - DataSet dateSet = QueryServiceHelper.queryDataSet( - this.getClass().getName(), - "er_dailyreimbursebill", - "id,billno,zcgj_holiday_start_time as startTime,zcgj_holiday_end_time as endTime,zcgj_is_home as ishome,", - filterArray, null - ); - int goHomeCount = 0; - for (Row row : dateSet) { - Boolean ishome = row.getBoolean("ishome"); - System.out.println(row.getString("billno")); - if(ishome){ - goHomeCount++; - } - } - if(monthTime != null && monthTime != 0){ - int monthVal = firstDayOfMonth.getMonth().getValue(); - String message = String.format("请知悉:您每月共有%d次往来家居地报销次数,在%d月中已进行过%d次来往家居地报销。",monthTime,monthVal,goHomeCount); - //this.getView().showSuccessNotification(message); - this.addMessage(extendedDataEntity, message); - } - - } i++; } } 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 new file mode 100644 index 0000000..c1e5286 --- /dev/null +++ b/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/operate/TripreimbursebillIsHomeCheckOp.java @@ -0,0 +1,316 @@ +package zcgj.zcdev.zcdev.fs.plugin.operate; + +import kd.bos.algo.DataSet; +import kd.bos.algo.Row; +import kd.bos.context.RequestContext; +import kd.bos.dataentity.entity.DynamicObject; +import kd.bos.dataentity.entity.DynamicObjectCollection; +import kd.bos.entity.ExtendedDataEntity; +import kd.bos.entity.plugin.AbstractOperationServicePlugIn; +import kd.bos.entity.plugin.AddValidatorsEventArgs; +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.QueryServiceHelper; +import kd.bos.servicehelper.user.UserServiceHelper; +import kd.bos.util.StringUtils; +import zcgj.zcdev.zcdev.fs.plugin.form.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.*; + +/** + * 差旅报销单往来家居检查操作 + */ +public class TripreimbursebillIsHomeCheckOp extends AbstractOperationServicePlugIn { + private static final String prefix ="zcgj"; + @Override + public void onPreparePropertys(PreparePropertysEventArgs e) { + super.onPreparePropertys(e); + e.getFieldKeys().add("zcgj_is_include_home"); + e.getFieldKeys().add("applier"); + e.getFieldKeys().add("zcgj_homeentity"); + } + + @Override + public void onAddValidators(AddValidatorsEventArgs e) { + super.onAddValidators(e); + Long currentUserId = UserServiceHelper.getCurrentUserId(); + // 当前用户所属组织 + Long mainOrgId = UserServiceHelper.getUserMainOrgId(currentUserId); + //当前切换选择的组织 + Long currentOrgId = RequestContext.get().getOrgId(); + //当前所在的组织是属于矿山下的 + if(OrgCheckUtils.isKS(currentOrgId)){ + e.getValidators().add(new ValidatorExt()); + } + } + + class ValidatorExt extends AbstractValidator { + @Override + public void validate() { + SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM"); + ExtendedDataEntity[] extendedDataEntities = this.getDataEntities(); + Map> allMap = new HashMap<>(); + //当前提交的探亲单据id集合 + Map> currentBillIdListMap = new HashMap<>(); + + for (ExtendedDataEntity extendedDataEntity : extendedDataEntities) { + DynamicObject dataEntity = extendedDataEntity.getDataEntity(); + long aLong = dataEntity.getLong("id"); + //获取报销人 + DynamicObject applier = dataEntity.getDynamicObject("applier"); + long applierId = applier.getLong("id"); + //获取申请日期 + //Date bizdate = dataEntity.getDate( "bizdate"); + //获取是否探亲 + //如果是探亲,则进行逻辑判断 + boolean isHome = dataEntity.getBoolean(prefix + "_is_include_home"); + + //判断是否来往家居地 + if(isHome){ + //获取当前人的往来家居地配置 + QFilter[] visitSetFilterArray = new QFilter[1]; + visitSetFilterArray[0] = new QFilter(prefix+"_user", QCP.equals, applierId); + DataSet homeDataSet = QueryServiceHelper.queryDataSet( + this.getClass().getName(), + prefix+"_user_home_conf", + "id,zcgj_month_times as monthTime", + visitSetFilterArray, null + ); + int monthTime = 0; + for (Row row : homeDataSet) { + monthTime = row.getInteger("monthTime"); + } + if(monthTime != 0){ + DynamicObjectCollection tripentry = dataEntity.getDynamicObjectCollection("zcgj_homeentity");//oa流程分录 + Map homeentityCountMap = new HashMap<>(); + int i = 1; + boolean isOk=true; + for (DynamicObject dynamicObject : tripentry) { + Date bxmonth = dynamicObject.getDate("zcgj_bxmonth"); + String yearMonth = dateFormat.format(bxmonth); + + String bxmonthStr = dateFormat.format(bxmonth); + String startdateStr = dateFormat.format(dynamicObject.getDate("zcgj_startdate")); + String enddateStr = dateFormat.format(dynamicObject.getDate("zcgj_enddate")); + isOk = checkBelongMonth(bxmonthStr, startdateStr, enddateStr); + if(!isOk){ + this.addFatalErrorMessage(extendedDataEntity, String.format("当前单据中往来居家明细的第%d行,往返日期不在报销归属月中!",i)); + } + // 更新统计次数 + homeentityCountMap.put(yearMonth, homeentityCountMap.getOrDefault(yearMonth, 0) + 1); + i++; + } + // 输出结果 + for (Map.Entry entry : homeentityCountMap.entrySet()) { + if(entry.getValue() > monthTime){ + String message = String.format("当前单据在%s月中提交了%d次往来居家,往来居家次数超限,限制每月%d次!",entry.getKey(),entry.getValue() ,monthTime); + isOk= false; + this.addFatalErrorMessage(extendedDataEntity, message); + } + //System.out.println(entry.getKey() + ": " + entry.getValue() + " 次"); + } + if(isOk){ + for (DynamicObject dynamicObject : tripentry) { + Date bxmonth = dynamicObject.getDate("zcgj_bxmonth"); + DataSet tripreimbursebill = getTripreimbursebill(bxmonth, applierId); + //已用次数 + int goHomeCount = 0; + StringBuilder trSb = new StringBuilder(); + for (Row row : tripreimbursebill) { + goHomeCount++; + String billno = row.getString("billno"); + /*String bxmonthStr = dateFormat.format(row.getDate("bxmonth")); + String startdateStr = dateFormat.format(row.getDate("startdate")); + String enddateStr = dateFormat.format(row.getDate("enddate")); + boolean b = checkBelongMonth(bxmonthStr, startdateStr, enddateStr);*/ + trSb.append(billno).append(";"); + } + DataSet dailyreimbursebill = getDailyreimbursebill(bxmonth, applierId); + StringBuilder daSb = new StringBuilder(); + for (Row row : dailyreimbursebill) { + goHomeCount++; + String billno = row.getString("billno"); + /* String bxmonthStr = dateFormat.format(row.getDate("bxmonth")); + String startdateStr = dateFormat.format(row.getDate("startdate")); + String enddateStr = dateFormat.format(row.getDate("enddate")); + boolean b = checkBelongMonth(bxmonthStr, startdateStr, enddateStr);*/ + daSb.append(billno).append(";"); + } + + if(goHomeCount >= monthTime){ + int monthVal = getFirstDayOfMonth(bxmonth).getMonth().getValue(); + String message = String.format("请知悉:您每月共有%d次往来家居地报销次数,在%d月中已进行过%d次来往家居地报销。",monthTime,monthVal,goHomeCount); + if(!StringUtils.isBlank(trSb.toString())){ + message+="已提交的差旅报销单:【"+trSb.toString()+"】 "; + } + if(!StringUtils.isBlank(daSb.toString())){ + message+="已提交的费用报销单:【"+daSb.toString()+"】 "; + } + this.addFatalErrorMessage(extendedDataEntity, message); + } + } + } + } + } + } + } + } + // 判断归属月份是否与开始时间或结束时间的月份相同 + public static boolean checkBelongMonth(String belongMonth, String startDate, String endDate) { + // 比较归属月份是否与开始时间或结束时间的月份相同 + return belongMonth.equals(startDate) || belongMonth.equals(endDate); + + } + /** + * 获取差旅费报销单 + * @param bxmonth + * @param applierId + * @return + */ + public DataSet getTripreimbursebill(Date bxmonth,long applierId){ + //查询非暂存、废弃的数据 + List billStatuslist = new ArrayList<>(); + billStatuslist.add("B"); + billStatuslist.add("C"); + billStatuslist.add("D"); + billStatuslist.add("E"); + billStatuslist.add("F"); + billStatuslist.add("G"); + LocalDate firstDayOfMonth = getFirstDayOfMonth(bxmonth); + LocalDate lastDayOfMonth = getLastDayOfMonth(bxmonth); + QFilter[] filterArray = new QFilter[5]; + //查询申请人下的今年的探亲差旅单据 + filterArray[0] = new QFilter("zcgj_homeentity.zcgj_bxmonth", QCP.large_equals, firstDayOfMonth); + filterArray[1] = new QFilter("zcgj_homeentity.zcgj_bxmonth", QCP.less_equals, lastDayOfMonth); + filterArray[2] = new QFilter("applier", QCP.equals, applierId); + filterArray[3] = new QFilter(prefix+"_is_include_home", QCP.equals, true); + filterArray[4] = new QFilter("billstatus", QCP.in, billStatuslist); + DataSet dateSet = QueryServiceHelper.queryDataSet( + this.getClass().getName(), + "er_tripreimbursebill", + "id,billno,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", + filterArray, null + ); + return dateSet; + } + + /** + * 获取费用报销单 + * @param bxmonth + * @param applierId + * @return + */ + public DataSet getDailyreimbursebill(Date bxmonth,long applierId){ + //查询非暂存、废弃的数据 + List billStatuslist = new ArrayList<>(); + billStatuslist.add("B"); + billStatuslist.add("C"); + billStatuslist.add("D"); + billStatuslist.add("E"); + billStatuslist.add("F"); + billStatuslist.add("G"); + + LocalDate firstDayOfMonth = getFirstDayOfMonth(bxmonth); + LocalDate lastDayOfMonth = getLastDayOfMonth(bxmonth); + QFilter[] filterArray = new QFilter[5]; + //查询申请人下的今年的探亲差旅单据 + filterArray[0] = new QFilter("zcgj_homeentity.zcgj_bxmonth", QCP.large_equals, firstDayOfMonth); + filterArray[1] = new QFilter("zcgj_homeentity.zcgj_bxmonth", QCP.less_equals, lastDayOfMonth); + filterArray[2] = new QFilter("applier", QCP.equals, applierId); + filterArray[3] = new QFilter(prefix+"_is_home", QCP.equals, true); + filterArray[4] = new QFilter("billstatus", QCP.in, billStatuslist); + DataSet dateSet = QueryServiceHelper.queryDataSet( + this.getClass().getName(), + "er_dailyreimbursebill", + "id,billno,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", + filterArray, null + ); + return dateSet; + } + + /** + * 将 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(); + } + + /** + * 获取指定日期所在年份的第一天 + * @param date java.util.Date + * @return java.util.Date + */ + public static Date getFirstDayOfYear(Date date) { + LocalDate localDate = dateToLocalDate(date); + LocalDate firstDayOfYear = LocalDate.of(localDate.getYear(), Month.JANUARY, 1); + return Date.from(firstDayOfYear.atStartOfDay(ZoneId.systemDefault()).toInstant()); + } + + /** + * 获取指定日期所在年份的最后一天 + * @param date java.util.Date + * @return java.util.Date + */ + public static Date getLastDayOfYear(Date date) { + LocalDate localDate = dateToLocalDate(date); + LocalDate lastDayOfYear = LocalDate.of(localDate.getYear(), Month.DECEMBER, 31); + return Date.from(lastDayOfYear.atStartOfDay(ZoneId.systemDefault()).toInstant()); + } + + /** + * 获取指定日期所在月份的第一天 + * @param date 指定日期 + * @return LocalDate 所在月份的第一天 + */ + public static LocalDate getFirstDayOfMonth(Date date) { + LocalDate localDate = dateToLocalDate(date); + return localDate.with(TemporalAdjusters.firstDayOfMonth()); + } + + /** + * 获取指定日期所在月份的最后一天 + * @param date 指定日期 + * @return LocalDate 所在月份的最后一天 + */ + public static LocalDate getLastDayOfMonth(Date date) { + LocalDate localDate = dateToLocalDate(date); + return localDate.with(TemporalAdjusters.lastDayOfMonth()); + } + + /** + * 获取指定年限-1年前的第一天 + * @param date 指定日期 + * @param years 年限值 + * @return LocalDate 年限-1年前的第一天 + */ + public static LocalDate getFirstDayYearsAgo(LocalDate date, int years) { + if (date == null) { + throw new IllegalArgumentException("日期不能为空"); + } + if (years < 1) { + throw new IllegalArgumentException("年限值必须大于等于 1"); + } + return LocalDate.of(date.getYear() - (years - 1), Month.JANUARY, 1); + } + +} + From 0767caa6de53fd52678a6cf6ffc1ff2f0336dd2b Mon Sep 17 00:00:00 2001 From: zhangzhiguo Date: Tue, 31 Dec 2024 18:30:11 +0800 Subject: [PATCH 3/5] =?UTF-8?q?1.=E5=A2=9E=E5=8A=A0=E8=81=8C=E5=91=98?= =?UTF-8?q?=E5=87=BA=E5=B7=AE=E5=A4=A9=E6=95=B0=E7=BB=9F=E8=AE=A1=E5=8F=B0?= =?UTF-8?q?=E8=B4=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../operate/DailyreimbursHomeCheckOp.java | 27 +- .../plugin/report/EmpTravelRptListPlugin.java | 97 +++++ .../report/EmpTravelRptQueryPlugin.java | 353 ++++++++++++++++++ 3 files changed, 465 insertions(+), 12 deletions(-) create mode 100644 code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/report/EmpTravelRptListPlugin.java create mode 100644 code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/report/EmpTravelRptQueryPlugin.java 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 4962d41..7f6a6e8 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 @@ -168,13 +168,15 @@ public class DailyreimbursHomeCheckOp extends AbstractOperationServicePlugIn { return belongMonth.equals(startDate) || belongMonth.equals(endDate); } + /** * 获取差旅费报销单 + * * @param bxmonth * @param applierId * @return */ - public DataSet getTripreimbursebill(Date bxmonth,long applierId){ + public DataSet getTripreimbursebill(Date bxmonth, long applierId) { //查询非暂存、废弃的数据 List billStatuslist = new ArrayList<>(); billStatuslist.add("B"); @@ -187,11 +189,11 @@ public class DailyreimbursHomeCheckOp extends AbstractOperationServicePlugIn { LocalDate lastDayOfMonth = getLastDayOfMonth(bxmonth); QFilter[] filterArray = new QFilter[5]; //查询申请人下的今年的探亲差旅单据 - filterArray[0] = new QFilter("zcgj_homeentity.zcgj_bxmonth", QCP.large_equals, firstDayOfMonth); - filterArray[1] = new QFilter("zcgj_homeentity.zcgj_bxmonth", QCP.less_equals, lastDayOfMonth); - filterArray[2] = new QFilter("applier", QCP.equals, applierId); - filterArray[3] = new QFilter(prefix+"_is_include_home", QCP.equals, true); - filterArray[4] = new QFilter("billstatus", QCP.in, billStatuslist); + filterArray[0] = new QFilter("zcgj_homeentity.zcgj_bxmonth", QCP.large_equals, firstDayOfMonth); + filterArray[1] = new QFilter("zcgj_homeentity.zcgj_bxmonth", QCP.less_equals, lastDayOfMonth); + filterArray[2] = new QFilter("applier", QCP.equals, applierId); + filterArray[3] = new QFilter(prefix + "_is_include_home", QCP.equals, true); + filterArray[4] = new QFilter("billstatus", QCP.in, billStatuslist); DataSet dateSet = QueryServiceHelper.queryDataSet( this.getClass().getName(), "er_tripreimbursebill", @@ -205,11 +207,12 @@ public class DailyreimbursHomeCheckOp extends AbstractOperationServicePlugIn { /** * 获取费用报销单 + * * @param bxmonth * @param applierId * @return */ - public DataSet getDailyreimbursebill(Date bxmonth,long applierId){ + public DataSet getDailyreimbursebill(Date bxmonth, long applierId) { //查询非暂存、废弃的数据 List billStatuslist = new ArrayList<>(); billStatuslist.add("B"); @@ -223,11 +226,11 @@ public class DailyreimbursHomeCheckOp extends AbstractOperationServicePlugIn { LocalDate lastDayOfMonth = getLastDayOfMonth(bxmonth); QFilter[] filterArray = new QFilter[5]; //查询申请人下的今年的探亲差旅单据 - filterArray[0] = new QFilter("zcgj_homeentity.zcgj_bxmonth", QCP.large_equals, firstDayOfMonth); - filterArray[1] = new QFilter("zcgj_homeentity.zcgj_bxmonth", QCP.less_equals, lastDayOfMonth); - filterArray[2] = new QFilter("applier", QCP.equals, applierId); - filterArray[3] = new QFilter(prefix+"_is_home", QCP.equals, true); - filterArray[4] = new QFilter("billstatus", QCP.in, billStatuslist); + filterArray[0] = new QFilter("zcgj_homeentity.zcgj_bxmonth", QCP.large_equals, firstDayOfMonth); + filterArray[1] = new QFilter("zcgj_homeentity.zcgj_bxmonth", QCP.less_equals, lastDayOfMonth); + filterArray[2] = new QFilter("applier", QCP.equals, applierId); + filterArray[3] = new QFilter(prefix + "_is_home", QCP.equals, true); + filterArray[4] = new QFilter("billstatus", QCP.in, billStatuslist); DataSet dateSet = QueryServiceHelper.queryDataSet( this.getClass().getName(), "er_dailyreimbursebill", diff --git a/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/report/EmpTravelRptListPlugin.java b/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/report/EmpTravelRptListPlugin.java new file mode 100644 index 0000000..a09afcf --- /dev/null +++ b/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/report/EmpTravelRptListPlugin.java @@ -0,0 +1,97 @@ +package zcgj.zcdev.zcdev.fs.plugin.report; + +import kd.bos.context.RequestContext; +import kd.bos.entity.datamodel.IDataModel; +import kd.bos.entity.datamodel.events.PackageDataEvent; +import kd.bos.entity.report.FilterInfo; +import kd.bos.entity.report.ReportQueryParam; +import kd.bos.report.events.CellStyleRule; +import kd.bos.report.plugin.AbstractReportFormPlugin; +import kd.sdk.plugin.Plugin; + +import java.util.Date; +import java.util.List; + +/** + * 职员出差天数统计台账 + * 报表格式化插件 + */ +public class EmpTravelRptListPlugin extends AbstractReportFormPlugin implements Plugin { + + private static final String DEV_KEY="zcgj"; + private static final String MERGECOLUM= DEV_KEY+"_username";//合并单元格字段 + //预算与汇总报表上的所有字段 + private static final String[] FIELDS={ + DEV_KEY+"_user", DEV_KEY+"_username", + DEV_KEY+"_january",DEV_KEY+"_february",DEV_KEY+"_march",DEV_KEY+"_april", + DEV_KEY+"_may", DEV_KEY+"_june", DEV_KEY+"_july",DEV_KEY+"_august", + DEV_KEY+"_september",DEV_KEY+"_october",DEV_KEY+"_november",DEV_KEY+"_december", + DEV_KEY+"_total" + }; + + @Override + public void setMergeColums(List columns) { + columns.add(MERGECOLUM); + super.setMergeColums(columns); + } + + @Override + public void packageData(PackageDataEvent packageDataEvent) { + super.packageData(packageDataEvent); + } + + @Override + public void initDefaultQueryParam(ReportQueryParam queryParam) { + super.initDefaultQueryParam(queryParam); + IDataModel model = this.getModel(); + //获取当前登陆人所在组织 + long orgId = RequestContext.get().getOrgId(); + model.setValue("zcgj_query_org",orgId); + model.setValue("zcgj_query_year",new Date()); + } + + @Override + public boolean verifyQuery(ReportQueryParam queryParam) { + FilterInfo filter = queryParam.getFilter(); + StringBuilder sb = new StringBuilder(); + if (filter.getValue("zcgj_query_org") == null){ + this.getView().showTipNotification("请选择查询组织!"); + return false; + } + if (filter.getValue("zcgj_query_year") == null){ + this.getView().showTipNotification("请选择查询年度!"); + return false; + } + return true; + } + + + + @Override + public void setCellStyleRules(List cellStyleRules) { + for (String field : FIELDS) { + CellStyleRule cellStyleRule = new CellStyleRule(); + cellStyleRule.setFieldKey(field);// 字段标识 + cellStyleRule.setForeColor("#666666");// 前景色 + cellStyleRule.setBackgroundColor("#ffc000");// 背景色 + cellStyleRule.setDegree(100);// 透明度 + cellStyleRule.setCondition(DEV_KEY+"_username = '合计'");// 前置条件,值与表达式计算器一致 + cellStyleRules.add(cellStyleRule); + } + super.setCellStyleRules(cellStyleRules); + } + + /** + * 设置过滤排序列 + * + * @param allColumns 报表列 + */ + /*@Override + public void setSortAndFilter(List allColumns) { + super.setSortAndFilter(allColumns); + for (SortAndFilterEvent ent : allColumns) { + ent.setFilter(true); + ent.setSort(true); + } + }*/ +} 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 new file mode 100644 index 0000000..8a346f6 --- /dev/null +++ b/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/report/EmpTravelRptQueryPlugin.java @@ -0,0 +1,353 @@ +package zcgj.zcdev.zcdev.fs.plugin.report; + +import kd.bos.algo.*; +import kd.bos.algo.input.CollectionInput; +import kd.bos.dataentity.entity.DynamicObject; +import kd.bos.dataentity.entity.DynamicObjectCollection; +import kd.bos.entity.report.AbstractReportListDataPlugin; +import kd.bos.entity.report.FilterItemInfo; +import kd.bos.entity.report.ReportQueryParam; +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 kd.bos.servicehelper.user.UserServiceHelper; + +import java.math.BigDecimal; +import java.text.SimpleDateFormat; +import java.time.LocalDate; +import java.time.Month; +import java.time.ZoneId; +import java.util.*; +import java.util.stream.Collectors; + +/** + * 职员出差天数统计台账 + * 报表取数插件 + */ +public class EmpTravelRptQueryPlugin extends AbstractReportListDataPlugin { + private static final Log logger = LogFactory.getLog(EmpTravelRptQueryPlugin.class); + + private static final String DEV_KEY="zcgj"; + + @Override + public DataSet query(ReportQueryParam reportQueryParam, Object o) throws Throwable { + List filters = reportQueryParam.getFilter().getFilterItems(); + Set applierId = new HashSet<>(); + Long orgId = null; + Date queryYear = null; + boolean istax = false; + for (FilterItemInfo filterItem : filters) { + switch (filterItem.getPropName()) { + case DEV_KEY+"_query_users": + DynamicObjectCollection users = (DynamicObjectCollection)filterItem.getValue(); + if(users != null){ + for (DynamicObject user : users) { + applierId.add(Long.valueOf(String.valueOf(user.getPkValue()))); + } + } + break; + case DEV_KEY+"_query_year": + queryYear = filterItem.getDate(); + break; + case DEV_KEY+"_query_org": + orgId = (filterItem.getValue() == null) ? null :Long.valueOf(String.valueOf(((DynamicObject) filterItem.getValue()).getPkValue())); + break; + case DEV_KEY+"_query_istax": + istax = filterItem.getBoolean(); + break; + default: + break; + } + } + // 报表字段及数据类型 + String[] FIELDS = { + DEV_KEY+"_user", DEV_KEY+"_username", + DEV_KEY+"_january",DEV_KEY+"_february",DEV_KEY+"_march",DEV_KEY+"_april", + DEV_KEY+"_may", DEV_KEY+"_june", DEV_KEY+"_july",DEV_KEY+"_august", + DEV_KEY+"_september",DEV_KEY+"_october",DEV_KEY+"_november",DEV_KEY+"_december", + DEV_KEY+"_total" + }; + DataType[] DATATYPES = { + DataType.LongType,DataType.StringType, + DataType.StringType, DataType.StringType,DataType.StringType,DataType.IntegerType, + DataType.StringType, DataType.StringType, DataType.StringType,DataType.StringType, + DataType.StringType, DataType.StringType, DataType.StringType,DataType.StringType, + DataType.StringType + }; + // 初始化 DataSet + RowMeta rowMeta = RowMetaFactory.createRowMeta(FIELDS, DATATYPES); + Collection coll = new ArrayList<>(); + CollectionInput inputs = new CollectionInput(rowMeta, coll); + DataSet resultDataSet = Algo.create(this.getClass().getName()).createDataSet(inputs); + + if(orgId==null || queryYear == null){ + return resultDataSet; + } + SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); + //获取公司下的所有人 + List orgIds = new ArrayList<>(); + orgIds.add(orgId); + List allUsersOfOrg = UserServiceHelper.getAllUsersOfOrg(orgIds); + if(!applierId.isEmpty()){ + //通过查询用户过滤组织下的人 + allUsersOfOrg = allUsersOfOrg.stream().filter(applierId::contains).collect(Collectors.toList()); + } + LocalDate localDate = dateToLocalDate(queryYear); + int year = localDate.getYear(); + Set userSet = new HashSet<>(); + // 用 Map 来按照报销人、单据编号、费用发生日期分组 + Map reportMap = new LinkedHashMap<>(); + Map> userMonthDaysMap = new HashMap<>(); + for (Long userId : allUsersOfOrg) { + Map monthDaysMap = null; + if(userMonthDaysMap.containsKey(userId)){ + monthDaysMap = userMonthDaysMap.get(userId); + }else{ + monthDaysMap = new HashMap<>(); + for (int i = 1; i <= 12; i++) { + monthDaysMap.put(i,0); + } + userMonthDaysMap.put(userId,monthDaysMap); + } + + DataSet tripreimbursebill = getTripreimbursebill(queryYear, userId); + for (Row row : tripreimbursebill) { + String billno = row.getString("billno"); + int kccbdays = row.getInteger("kccbdays");//扣除餐补天数(周六日、节假日) + + String startdateStr = dateFormat.format(row.getDate("startdate"));// + String enddateStr = dateFormat.format(row.getDate("enddate")); + String bxmonthStr = dateFormat.format(row.getDate("bxmonth"));//归属月份 + + LocalDate bxmonth = dateToLocalDate(row.getDate("bxmonth")); + if(!skip(row.getDate("startdate"), row.getDate("enddate"))){ + int days = calculateDaysBetween(row.getDate("startdate"), row.getDate("enddate")); + if(days >= kccbdays){ + monthDaysMap.put(bxmonth.getMonth().getValue(), + monthDaysMap.getOrDefault(bxmonth.getMonth().getValue(), 0) + (days-kccbdays)); + } + } + } + + DataSet dailyreimbursebill = getDailyreimbursebill(queryYear, userId); + for (Row row : dailyreimbursebill) { + String billno = row.getString("billno"); + int kccbdays = row.getInteger("kccbdays");//扣除餐补天数(周六日、节假日) + + String startdateStr = dateFormat.format(row.getDate("startdate"));// + String enddateStr = dateFormat.format(row.getDate("enddate")); + String bxmonthStr = dateFormat.format(row.getDate("bxmonth"));//归属月份 + + LocalDate bxmonth = dateToLocalDate(row.getDate("bxmonth")); + if(!skip(row.getDate("startdate"), row.getDate("enddate"))){ + int days = calculateDaysBetween(row.getDate("startdate"), row.getDate("enddate")); + if(days >= kccbdays){ + monthDaysMap.put(bxmonth.getMonth().getValue(), + monthDaysMap.getOrDefault(bxmonth.getMonth().getValue(), 0) + (days-kccbdays)); + } + } + } + System.out.println(); + } + + for (Long userId : userMonthDaysMap.keySet()) { + Map integerIntegerMap = userMonthDaysMap.get(userId); + Map userInfoByID = UserServiceHelper.getUserInfoByID(userId); + String username = String.valueOf(userInfoByID.get("name"));//报销人 + Object [] tempData = new Object [FIELDS.length]; + coll.add(tempData); + + tempData[0] = userId; + tempData[1] = username; + int index = 2; + int totalDays = 0; + for (int i = 1; i <=12 ; i++) { + totalDays += integerIntegerMap.get(i); + tempData[index] = integerIntegerMap.get(i) == 0 ?null:integerIntegerMap.get(i)+""; + index++; + } + if(totalDays!=0){ + tempData[14] = totalDays; + } + } + + return resultDataSet; + } + + /** + * 获取差旅费报销单 + * + * @param applierId + * @return + */ + public DataSet getTripreimbursebill(Date queryYear,Long applierId) { + LocalDate localDate = dateToLocalDate(queryYear); + LocalDate firstDay = getFirstDayOfYear(localDate.getYear()); + LocalDate lastDay = getLastDayOfYear(localDate.getYear()); + //查询非暂存、废弃的数据 + List billStatuslist = new ArrayList<>(); + //billStatuslist.add("A"); //暂存 + //billStatuslist.add("B"); //已提交 + //billStatuslist.add("C"); //审核中 + //billStatuslist.add("D"); //审核未通过 + billStatuslist.add("E"); //审核通过 + billStatuslist.add("F"); //等待付款 + billStatuslist.add("G"); //已付款 + //billStatuslist.add("H"); //废弃 + billStatuslist.add("I"); //关闭 + //查询申请人下的今年的探亲差旅单据 + List searchFilterList = new ArrayList<>(); + 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( + 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", + searchFilterList.toArray(new QFilter [] {}), null + ); + return dateSet; + } + + /** + * 获取费用报销单 + * + * @return + */ + public DataSet getDailyreimbursebill(Date queryYear,Long applierId) { + LocalDate localDate = dateToLocalDate(queryYear); + LocalDate firstDay = getFirstDayOfYear(localDate.getYear()); + LocalDate lastDay = getLastDayOfYear(localDate.getYear()); + //查询非暂存、废弃的数据 + List billStatuslist = new ArrayList<>(); + //billStatuslist.add("A"); //暂存 + //billStatuslist.add("B"); //已提交 + //billStatuslist.add("C"); //审核中 + //billStatuslist.add("D"); //审核未通过 + billStatuslist.add("E"); //审核通过 + billStatuslist.add("F"); //等待付款 + billStatuslist.add("G"); //已付款 + //billStatuslist.add("H"); //废弃 + billStatuslist.add("I"); //关闭 + + 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("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( + this.getClass().getName(), + "er_dailyreimbursebill", + "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", + searchFilterList.toArray(new QFilter [] {}), null + ); + return dateSet; + } + + public boolean skip(Date startDate, Date endDate) throws Exception{ + // 日期格式化 + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + + // 使用 Calendar 类进行日期操作 + Calendar startCalendar = Calendar.getInstance(); + Calendar endCalendar = Calendar.getInstance(); + + startCalendar.setTime(startDate); + endCalendar.setTime(endDate); + + // 特殊情况处理:如果开始日期是周五且结束日期是周一,跳过统计 + if (startCalendar.get(Calendar.DAY_OF_WEEK) == Calendar.FRIDAY && + endCalendar.get(Calendar.DAY_OF_WEEK) == Calendar.MONDAY) { + return true; + } + return false; + } + + // 计算开始日期和结束日期之间的天数 + public static int calculateDaysBetween(Date startDate, Date endDate) throws Exception { + // 日期格式化 + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + + // 使用 Calendar 类来处理日期 + Calendar startCalendar = Calendar.getInstance(); + Calendar endCalendar = Calendar.getInstance(); + + startCalendar.setTime(startDate); + endCalendar.setTime(endDate); + + // 计算两个日期之间的天数差 + long startMillis = startCalendar.getTimeInMillis(); + long endMillis = endCalendar.getTimeInMillis(); + + // 计算天数差,注意加1天因为天数是区间的数量(包含开始日期) + long diffMillis = endMillis - startMillis; + int diffDays = (int) (diffMillis / (24 * 60 * 60 * 1000)); + + return diffDays + 1; // 因为差值是天数之间的差,包含开始日期 + } + + // 计算工作日天数 + public static int calculateWorkdays(Date startDate, Date endDate) throws Exception { + // 使用 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; + } + + // 计算工作日天数 + int workdays = 0; + + // 从开始日期到结束日期遍历 + while (!startCalendar.after(endCalendar)) { + int dayOfWeek = startCalendar.get(Calendar.DAY_OF_WEEK); + // 只统计周一到周五(排除周六和周日) + if (dayOfWeek != Calendar.SATURDAY && dayOfWeek != Calendar.SUNDAY) { + workdays++; + } + startCalendar.add(Calendar.DAY_OF_MONTH, 1); // 移动到下一天 + } + + return workdays; + } + + // 获取某年份的第一天 + public static LocalDate getFirstDayOfYear(int year) { + return LocalDate.of(year, 1, 1); + } + + // 获取某年份的最后一天 + public static LocalDate getLastDayOfYear(int year) { + return LocalDate.of(year, 12, 31); + } + + /** + * 将 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(); + } +} From cee3debf85d3f41e03b1de338e00e8a2f7a92cc3 Mon Sep 17 00:00:00 2001 From: zhangzhiguo Date: Thu, 2 Jan 2025 15:29:05 +0800 Subject: [PATCH 4/5] =?UTF-8?q?1.=E5=A2=9E=E5=8A=A0=E8=81=8C=E5=91=98?= =?UTF-8?q?=E5=87=BA=E5=B7=AE=E5=A4=A9=E6=95=B0=E7=BB=9F=E8=AE=A1=E5=8F=B0?= =?UTF-8?q?=E8=B4=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../plugin/form/AutoCalWorkingDaysPlugin.java | 133 ++++++++++++++++++ .../report/EmpTravelRptQueryPlugin.java | 30 ++-- 2 files changed, 145 insertions(+), 18 deletions(-) create mode 100644 code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/AutoCalWorkingDaysPlugin.java 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 new file mode 100644 index 0000000..424a1b8 --- /dev/null +++ b/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/AutoCalWorkingDaysPlugin.java @@ -0,0 +1,133 @@ +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.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 java.text.SimpleDateFormat; +import java.util.Calendar; +import java.util.Date; +import java.util.EventObject; + +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); + }else{ + dynamicObject.set("zcgj_kccbdaycount",0); + } + getView().updateView(); + int allHomeCount = 0; + for (DynamicObject entry : dynamicObjectCollection) { + allHomeCount += entry.getInt("zcgj_kccbdaycount"); + } + this.getModel().setValue("zcgj_kccbdays",allHomeCount); + getView().updateView(); + } + } + super.propertyChanged(e); + } + + @Override + public void registerListener(EventObject e) { + super.registerListener(e); +//监听工具栏按钮点击事件 + this.addItemClickListeners("zcgj_hometoolbarap"); + this.addClickListeners("advcontoolbarap"); + } + + @Override + public void itemClick(ItemClickEvent evt) { + super.itemClick(evt); + if (evt.getItemKey().equals("zcgj_delhome")) { + //获取分录 + DynamicObject dataEntity = this.getModel().getDataEntity(); + DynamicObjectCollection dynamicObjectCollection = dataEntity.getDynamicObjectCollection("zcgj_homeentity"); + getView().updateView(); + int allHomeCount = 0; + for (DynamicObject entry : dynamicObjectCollection) { + allHomeCount += entry.getInt("zcgj_kccbdaycount"); + } + this.getModel().setValue("zcgj_kccbdays",allHomeCount); + getView().updateView(); + } + } + + // 计算工作日天数 + 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; + } + + // 计算工作日天数 + int workdays = 0; + + // 从开始日期到结束日期遍历 + while (!startCalendar.after(endCalendar)) { + int dayOfWeek = startCalendar.get(Calendar.DAY_OF_WEEK); + // 只统计周一到周五(排除周六和周日) + if (dayOfWeek != Calendar.SATURDAY && dayOfWeek != Calendar.SUNDAY) { + workdays++; + } + startCalendar.add(Calendar.DAY_OF_MONTH, 1); // 移动到下一天 + } + + return workdays; + } + + // 计算开始日期和结束日期之间的天数 + public static int calculateDaysBetween(Date startDate, Date endDate) { + // 日期格式化 + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + + // 使用 Calendar 类来处理日期 + Calendar startCalendar = Calendar.getInstance(); + Calendar endCalendar = Calendar.getInstance(); + + startCalendar.setTime(startDate); + endCalendar.setTime(endDate); + + // 计算两个日期之间的天数差 + long startMillis = startCalendar.getTimeInMillis(); + long endMillis = endCalendar.getTimeInMillis(); + + // 计算天数差,注意加1天因为天数是区间的数量(包含开始日期) + long diffMillis = endMillis - startMillis; + int diffDays = (int) (diffMillis / (24 * 60 * 60 * 1000)); + + return diffDays + 1; // 因为差值是天数之间的差,包含开始日期 + } +} 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 8a346f6..6e40875 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 @@ -120,15 +120,12 @@ public class EmpTravelRptQueryPlugin extends AbstractReportListDataPlugin { 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")); - if(!skip(row.getDate("startdate"), row.getDate("enddate"))){ - int days = calculateDaysBetween(row.getDate("startdate"), row.getDate("enddate")); - if(days >= kccbdays){ - monthDaysMap.put(bxmonth.getMonth().getValue(), - monthDaysMap.getOrDefault(bxmonth.getMonth().getValue(), 0) + (days-kccbdays)); - } - } + monthDaysMap.put(bxmonth.getMonth().getValue(), + monthDaysMap.getOrDefault(bxmonth.getMonth().getValue(), 0) + homedaycount); + } DataSet dailyreimbursebill = getDailyreimbursebill(queryYear, userId); @@ -139,15 +136,12 @@ public class EmpTravelRptQueryPlugin extends AbstractReportListDataPlugin { 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")); - if(!skip(row.getDate("startdate"), row.getDate("enddate"))){ - int days = calculateDaysBetween(row.getDate("startdate"), row.getDate("enddate")); - if(days >= kccbdays){ - monthDaysMap.put(bxmonth.getMonth().getValue(), - monthDaysMap.getOrDefault(bxmonth.getMonth().getValue(), 0) + (days-kccbdays)); - } - } + monthDaysMap.put(bxmonth.getMonth().getValue(), + monthDaysMap.getOrDefault(bxmonth.getMonth().getValue(), 0) + homedaycount); + } System.out.println(); } @@ -201,7 +195,7 @@ public class EmpTravelRptQueryPlugin extends AbstractReportListDataPlugin { List searchFilterList = new ArrayList<>(); 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("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( @@ -209,7 +203,7 @@ public class EmpTravelRptQueryPlugin extends AbstractReportListDataPlugin { "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_homebz as homebz,zcgj_homedaycount as homedaycount", searchFilterList.toArray(new QFilter [] {}), null ); return dateSet; @@ -240,7 +234,7 @@ public class EmpTravelRptQueryPlugin extends AbstractReportListDataPlugin { //查询申请人下的今年的探亲差旅单据 searchFilterList.add(new QFilter("applier", QCP.equals, applierId)); searchFilterList.add(new QFilter( "zcgj_is_home", QCP.equals, true)); - //searchFilterList.add(new QFilter("billstatus", QCP.in, billStatuslist)); + 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( @@ -248,7 +242,7 @@ public class EmpTravelRptQueryPlugin extends AbstractReportListDataPlugin { "er_dailyreimbursebill", "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_homebz as homebz,zcgj_homedaycount as homedaycount", searchFilterList.toArray(new QFilter [] {}), null ); return dateSet; From dd9a29bb6208c9b9663f8650c3c0a79414026aa2 Mon Sep 17 00:00:00 2001 From: zhangzhiguo Date: Thu, 2 Jan 2025 18:44:51 +0800 Subject: [PATCH 5/5] =?UTF-8?q?1.=E5=A2=9E=E5=8A=A0=E8=81=8C=E5=91=98?= =?UTF-8?q?=E5=87=BA=E5=B7=AE=E5=A4=A9=E6=95=B0=E7=BB=9F=E8=AE=A1=E5=8F=B0?= =?UTF-8?q?=E8=B4=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fs/plugin/form/AutoCalWorkingDaysPlugin.java | 11 ++++++----- .../fs/plugin/report/EmpTravelRptQueryPlugin.java | 8 ++++---- 2 files changed, 10 insertions(+), 9 deletions(-) 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 424a1b8..0e0f901 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 @@ -16,6 +16,9 @@ import java.util.Calendar; import java.util.Date; import java.util.EventObject; +/** + * 往返家居工作日天数自动计算插件 + */ public class AutoCalWorkingDaysPlugin extends AbstractBillPlugIn implements Plugin { @Override @@ -40,24 +43,23 @@ public class AutoCalWorkingDaysPlugin extends AbstractBillPlugIn implements Plug }else{ dynamicObject.set("zcgj_kccbdaycount",0); } - getView().updateView(); int allHomeCount = 0; for (DynamicObject entry : dynamicObjectCollection) { allHomeCount += entry.getInt("zcgj_kccbdaycount"); } this.getModel().setValue("zcgj_kccbdays",allHomeCount); - getView().updateView(); + this.getView().updateView("zcgj_homeentity"); } } super.propertyChanged(e); + } @Override public void registerListener(EventObject e) { super.registerListener(e); //监听工具栏按钮点击事件 - this.addItemClickListeners("zcgj_hometoolbarap"); - this.addClickListeners("advcontoolbarap"); + //this.addItemClickListeners("zcgj_hometoolbarap"); } @Override @@ -67,7 +69,6 @@ public class AutoCalWorkingDaysPlugin extends AbstractBillPlugIn implements Plug //获取分录 DynamicObject dataEntity = this.getModel().getDataEntity(); DynamicObjectCollection dynamicObjectCollection = dataEntity.getDynamicObjectCollection("zcgj_homeentity"); - getView().updateView(); int allHomeCount = 0; for (DynamicObject entry : dynamicObjectCollection) { allHomeCount += entry.getInt("zcgj_kccbdaycount"); 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 6e40875..2ff30d2 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 @@ -143,7 +143,6 @@ public class EmpTravelRptQueryPlugin extends AbstractReportListDataPlugin { monthDaysMap.getOrDefault(bxmonth.getMonth().getValue(), 0) + homedaycount); } - System.out.println(); } for (Long userId : userMonthDaysMap.keySet()) { @@ -151,7 +150,6 @@ public class EmpTravelRptQueryPlugin extends AbstractReportListDataPlugin { Map userInfoByID = UserServiceHelper.getUserInfoByID(userId); String username = String.valueOf(userInfoByID.get("name"));//报销人 Object [] tempData = new Object [FIELDS.length]; - coll.add(tempData); tempData[0] = userId; tempData[1] = username; @@ -162,8 +160,10 @@ public class EmpTravelRptQueryPlugin extends AbstractReportListDataPlugin { tempData[index] = integerIntegerMap.get(i) == 0 ?null:integerIntegerMap.get(i)+""; index++; } + //如果总天数不为0的 if(totalDays!=0){ tempData[14] = totalDays; + coll.add(tempData); } } @@ -203,7 +203,7 @@ public class EmpTravelRptQueryPlugin extends AbstractReportListDataPlugin { "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_homedaycount as homedaycount", + "zcgj_homeentity.zcgj_homebz as homebz,zcgj_homeentity.zcgj_homedaycount as homedaycount", searchFilterList.toArray(new QFilter [] {}), null ); return dateSet; @@ -242,7 +242,7 @@ public class EmpTravelRptQueryPlugin extends AbstractReportListDataPlugin { "er_dailyreimbursebill", "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_homedaycount as homedaycount", + "zcgj_homeentity.zcgj_homebz as homebz,zcgj_homeentity.zcgj_homedaycount as homedaycount", searchFilterList.toArray(new QFilter [] {}), null ); return dateSet;