职员餐补扣除天数统计详情

This commit is contained in:
zhangzhiguo 2025-02-21 17:26:14 +08:00
parent 0de251a569
commit effc1455f0
2 changed files with 354 additions and 144 deletions

View File

@ -0,0 +1,305 @@
package zcgj.zcdev.zcdev.fs.plugin.report;
import kd.bos.algo.DataSet;
import kd.bos.algo.Row;
import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.dataentity.entity.DynamicObjectCollection;
import kd.bos.entity.report.CellStyle;
import kd.bos.form.FormShowParameter;
import kd.bos.form.control.AbstractGrid;
import kd.bos.form.plugin.AbstractFormPlugin;
import kd.bos.orm.query.QCP;
import kd.bos.orm.query.QFilter;
import kd.bos.servicehelper.QueryServiceHelper;
import kd.sdk.plugin.Plugin;
import java.time.DayOfWeek;
import java.time.LocalDate;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.time.temporal.TemporalAdjusters;
import java.util.*;
/**
* 职工扣除餐补天数详情界面插件
*/
public class EmpTravelRptDetailListPlugin extends AbstractFormPlugin implements Plugin {
@Override
public void afterCreateNewData(EventObject e) {
super.afterCreateNewData(e);
// 获取当前页面的FormShowParameter对象
FormShowParameter formShowParameter = this.getView().getFormShowParameter();
// 获取自定义参数
Long userId = (Long)formShowParameter.getCustomParam("userId");
String queryDate = (String)formShowParameter.getCustomParam("queryDate");
Integer days = (Integer)formShowParameter.getCustomParam("days");
// 把参数值赋值到页面文本字段上
//AbstractGrid grid = this.getView().getControl("zcgj_entryentity");
//ArrayList csList = new ArrayList();
//CellStyle cs = new CellStyle();
//cs.setForeColor("#ff0000");//字体颜色
//cs.setFieldKey("zcgj_days");//列标识
//cs.setRow(0);//行索引
//csList.add(cs);
//grid.setCellStyle(csList);//设置单元格样式
DynamicObjectCollection zcgjKccbList = this.getModel().getDataEntity().getDynamicObjectCollection("zcgj_entryentity");
DataSet tripreimbursebill = getTripreimbursebill(queryDate, userId);
for (Row row : tripreimbursebill) {
DynamicObject dynamicObject = zcgjKccbList.addNew();
dynamicObject.set("zcgj_bill_type","差旅报销单");
dynamicObject.set("zcgj_type","差旅行程");
dynamicObject.set("zcgj_billno",row.getString("billno"));
Date startdate = row.getDate("startdate");
dynamicObject.set("zcgj_start_date",startdate);
Date enddate = row.getDate("enddate");
dynamicObject.set("zcgj_end_date",enddate);
Set<LocalDate> startAndEnd = getStartAndEnd(dateToLocalDate(startdate), dateToLocalDate(enddate));
dynamicObject.set("zcgj_days",startAndEnd.size());
}
DataSet tripreimbursebillHome = getTripreimbursebillHome(queryDate, userId);
for (Row row : tripreimbursebillHome) {
DynamicObject dynamicObject = zcgjKccbList.addNew();
dynamicObject.set("zcgj_bill_type","差旅报销单");
dynamicObject.set("zcgj_type","往来居家");
dynamicObject.set("zcgj_billno",row.getString("billno"));
Date startdate = row.getDate("startdate");
dynamicObject.set("zcgj_start_date",startdate);
Date enddate = row.getDate("enddate");
dynamicObject.set("zcgj_end_date",enddate);
dynamicObject.set("zcgj_days",row.getInteger("kccbdaycount"));
}
DataSet dailyreimbursebillVisit = getDailyreimbursebillVisit(queryDate, userId);
for (Row row : dailyreimbursebillVisit) {
DynamicObject dynamicObject = zcgjKccbList.addNew();
dynamicObject.set("zcgj_bill_type","费用报销单");
dynamicObject.set("zcgj_type","往来居家");
dynamicObject.set("zcgj_billno",row.getString("billno"));
Date startdate = row.getDate("startdate");
dynamicObject.set("zcgj_start_date",startdate);
Date enddate = row.getDate("enddate");
dynamicObject.set("zcgj_end_date",enddate);
dynamicObject.set("zcgj_days",row.getInteger("kccbdays"));
//Set<LocalDate> datesExcludingWeekends = getDatesExcludingWeekends(dateToLocalDate(startdate), dateToLocalDate(enddate));
//dynamicObject.set("zcgj_days",datesExcludingWeekends.size());
}
DataSet dailyreimbursebillHome = getDailyreimbursebillHome(queryDate, userId);
for (Row row : dailyreimbursebillHome) {
DynamicObject dynamicObject = zcgjKccbList.addNew();
dynamicObject.set("zcgj_bill_type","费用报销单");
dynamicObject.set("zcgj_type","往来居家");
dynamicObject.set("zcgj_billno",row.getString("billno"));
Date startdate = row.getDate("startdate");
dynamicObject.set("zcgj_start_date",startdate);
Date enddate = row.getDate("enddate");
dynamicObject.set("zcgj_end_date",enddate);
dynamicObject.set("zcgj_days",row.getInteger("kccbdaycount"));
}
System.out.println();
}
/**
* 获取差旅费报销单-行程信息
*
* @param applierId
* @return
*/
public DataSet getTripreimbursebill(String queryDate, Long applierId) {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
LocalDate date = LocalDate.parse(queryDate, formatter);
// 获取当前日期的月份的第一天
LocalDate firstDayOfMonth = date.with(TemporalAdjusters.firstDayOfMonth());
// 获取当前日期的月份的最后一天
LocalDate lastDayOfMonth = date.with(TemporalAdjusters.lastDayOfMonth());
//查询非暂存废弃的数据
List<String> billStatuslist = new ArrayList<>();
billStatuslist.add("E"); //审核通过
billStatuslist.add("F"); //等待付款
billStatuslist.add("G"); //已付款
billStatuslist.add("I"); //关闭
//查询申请人下的今年的探亲差旅单据
List<QFilter> 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("bizdate", QCP.large_equals, firstDayOfMonth));
searchFilterList.add( new QFilter("bizdate", QCP.less_equals, lastDayOfMonth));
DataSet dateSet = QueryServiceHelper.queryDataSet(
this.getClass().getName(),
"er_tripreimbursebill",
"id,applier,billno,tripentry.startdate as startdate,tripentry.enddate as enddate,tripentry.entryentity.orientryamount as orientryamount" ,
searchFilterList.toArray(new QFilter [] {}), null
);
return dateSet;
}
/**
* 获取差旅费报销单-来往家具地信息
*
* @param applierId
* @return
*/
public DataSet getTripreimbursebillHome(String queryDate, Long applierId) {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
LocalDate date = LocalDate.parse(queryDate, formatter);
// 获取当前日期的月份的第一天
LocalDate firstDayOfMonth = date.with(TemporalAdjusters.firstDayOfMonth());
// 获取当前日期的月份的最后一天
LocalDate lastDayOfMonth = date.with(TemporalAdjusters.lastDayOfMonth());
//查询非暂存废弃的数据
List<String> billStatuslist = new ArrayList<>();
billStatuslist.add("E"); //审核通过
billStatuslist.add("F"); //等待付款
billStatuslist.add("G"); //已付款
billStatuslist.add("I"); //关闭
//查询申请人下的今年的探亲差旅单据
List<QFilter> 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("bizdate", QCP.large_equals, firstDayOfMonth));
searchFilterList.add( new QFilter("bizdate", QCP.less_equals, lastDayOfMonth));
DataSet dateSet = QueryServiceHelper.queryDataSet(
this.getClass().getName(),
"er_tripreimbursebill",
"id,applier,billno,zcgj_homeentity.zcgj_startdate as startdate,zcgj_homeentity.zcgj_enddate as enddate,zcgj_homeentity.zcgj_kccbdaycount as kccbdaycount" ,
searchFilterList.toArray(new QFilter [] {}), null
);
return dateSet;
}
/**
* 获取费用报销单-探亲
*
* @return
*/
public DataSet getDailyreimbursebillVisit(String queryDate, Long applierId) {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
LocalDate date = LocalDate.parse(queryDate, formatter);
// 获取当前日期的月份的第一天
LocalDate firstDayOfMonth = date.with(TemporalAdjusters.firstDayOfMonth());
// 获取当前日期的月份的最后一天
LocalDate lastDayOfMonth = date.with(TemporalAdjusters.lastDayOfMonth());
//查询非暂存废弃的数据
List<String> billStatuslist = new ArrayList<>();
billStatuslist.add("E"); //审核通过
billStatuslist.add("F"); //等待付款
billStatuslist.add("G"); //已付款
//billStatuslist.add("H"); //废弃
billStatuslist.add("I"); //关闭
List<QFilter> searchFilterList = new ArrayList<>();
//查询申请人下的今年的探亲差旅单据
searchFilterList.add(new QFilter("applier", QCP.equals, applierId));
searchFilterList.add(new QFilter( "zcgj_is_visit", QCP.equals, true));
searchFilterList.add(new QFilter("billstatus", QCP.in, billStatuslist));
searchFilterList.add( new QFilter("bizdate", QCP.large_equals, firstDayOfMonth));
searchFilterList.add(new QFilter("bizdate", QCP.less_equals, lastDayOfMonth));
DataSet dateSet = QueryServiceHelper.queryDataSet(
this.getClass().getName(),
"er_dailyreimbursebill",
"id,applier,billno,zcgj_holiday_start_time as startdate,zcgj_holiday_end_time as enddate,zcgj_kccbdays as kccbdays",
searchFilterList.toArray(new QFilter [] {}), null
);
return dateSet;
}
/**
* 获取费用报销单-来往家居地
*
* @return
*/
public DataSet getDailyreimbursebillHome(String queryDate, Long applierId) {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
LocalDate date = LocalDate.parse(queryDate, formatter);
// 获取当前日期的月份的第一天
LocalDate firstDayOfMonth = date.with(TemporalAdjusters.firstDayOfMonth());
// 获取当前日期的月份的最后一天
LocalDate lastDayOfMonth = date.with(TemporalAdjusters.lastDayOfMonth());
//查询非暂存废弃的数据
List<String> billStatuslist = new ArrayList<>();
billStatuslist.add("E"); //审核通过
billStatuslist.add("F"); //等待付款
billStatuslist.add("G"); //已付款
//billStatuslist.add("H"); //废弃
billStatuslist.add("I"); //关闭
List<QFilter> 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("bizdate", QCP.large_equals, firstDayOfMonth));
searchFilterList.add(new QFilter("bizdate", QCP.less_equals, lastDayOfMonth));
DataSet dateSet = QueryServiceHelper.queryDataSet(
this.getClass().getName(),
"er_dailyreimbursebill",
"id,applier,billno,zcgj_homeentity.zcgj_startdate as startdate,zcgj_homeentity.zcgj_enddate as enddate,zcgj_homeentity.zcgj_kccbdaycount as kccbdaycount",
searchFilterList.toArray(new QFilter [] {}), null
);
return dateSet;
}
//获取开始结束时间
public static Set<LocalDate> getStartAndEnd(LocalDate startDate, LocalDate endDate) {
Set<LocalDate> result = new HashSet<>();
// 判断开始日期和结束日期是否为周末
if (!isWeekend(startDate)) {
result.add(startDate);
}
if (!isWeekend(endDate)) {
result.add(endDate);
}
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();
}
//去除开始日期结束日期移除周六日
public static Set<LocalDate> getDatesExcludingWeekends(LocalDate startDate, LocalDate endDate) {
Set<LocalDate> 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;
}
}

View File

@ -66,33 +66,24 @@ public class EmpTravelRptListPlugin extends AbstractReportFormPlugin implements
if(rowIndex > 0){
ReportList reportList = getView().getControl("reportlistap");
DynamicObject rowData = reportList.getReportModel().getRowData(rowIndex);
//row.getString()
if(rowData!=null && rowData.get("zcgj_user") != null){
DynamicObject user = (DynamicObject)rowData.get(0);
Long userId = (Long)user.getPkValue();
String zcgjYear = rowData.getString("zcgj_year");
DataSet tripreimbursebill = getTripreimbursebill(zcgjYear, "02", userId);
for (Row itemRow : tripreimbursebill){
String string = itemRow.getString("billno");
System.out.println();
}
Integer days = rowData.getInt(fieldName);
DataSet dailyreimbursebill = getDailyreimbursebill(zcgjYear, "02", userId);
for (Row itemRow : dailyreimbursebill){
String string = itemRow.getString("billno");
Date startTime = itemRow.getDate("zcgj_holiday_start_time");
Date endTime = itemRow.getDate("zcgj_holiday_end_time");
Date startTimeEntity = itemRow.getDate("zcgj_startdate");
Date endTimeEntity = itemRow.getDate("zcgj_enddate");
System.out.println();
}
System.out.println();
String month = monthToInt(fieldName);
String queryDate = zcgjYear+"-"+month+"-01";
FormShowParameter formShowParameter;
formShowParameter = new FormShowParameter();
formShowParameter.getOpenStyle().setShowType(ShowType.Modal);
formShowParameter.setFormId("zcgj_kccb_list");
// 自定义传参把当前单据的文本字段传过去
//formShowParameter.setCustomParam("list", this.getModel().getValue("kdec_textfield"));
formShowParameter.setCustomParam("queryDate", queryDate);
formShowParameter.setCustomParam("userId", userId);
formShowParameter.setCustomParam("days", days);
StyleCss styleCss = new StyleCss();
styleCss.setWidth("800");
styleCss.setHeight("600");
@ -101,38 +92,52 @@ public class EmpTravelRptListPlugin extends AbstractReportFormPlugin implements
}
}
//跳转到指定借款单
/* BillShowParameter showParameter = new BillShowParameter();
showParameter.setFormId("er_dailyloanbill");
showParameter.setPkId(loadSingle.getPkValue());
showParameter.getOpenStyle().setShowType(ShowType.MainNewTabPage);
showParameter.setStatus(OperationStatus.VIEW);
this.getView().showForm(showParameter);*/
System.out.println();
/*DataSet cDataSet = QueryServiceHelper.queryDataSet(this.getClass().getName(), "kdec_fruit_bill",
"billno as kdec_billno, kdec_fruit_pro.name as proname, kdec_entryentity.kdec_fruits as kdec_fruits",
null, "billno asc");
Iterator<Row> iterator = cDataSet.iterator();
int index = 0;
String billno = "";
while (iterator.hasNext()) {
index++;
Row row = iterator.next();
if (index == hyperLinkClickEvent.getRowIndex()) {
billno = row.getString(hyperLinkClickEvent.getFieldName());
break;
}
}*/
//System.out.println(billno + "HyperLinkClick");
}
});
}
public String monthToInt(String month){
String mont = "";
switch(month){
case "zcgj_january":
mont = "01";
break;
case "zcgj_february":
mont = "02";
break;
case "zcgj_march":
mont = "03";
break;
case "zcgj_april":
mont = "04";
break;
case "zcgj_may":
mont = "05";
break;
case "zcgj_june":
mont = "06";
break;
case "zcgj_july":
mont = "07";
break;
case "zcgj_august":
mont = "08";
break;
case "zcgj_september":
mont = "09";
break;
case "zcgj_october":
mont = "10";
break;
case "zcgj_november":
mont = "11";
break;
case "zcgj_december":
mont = "12";
break;
}
return mont;
}
@Override
public void setMergeColums(List<String> columns) {
@ -200,106 +205,6 @@ public class EmpTravelRptListPlugin extends AbstractReportFormPlugin implements
}
}*/
/**
* 获取差旅费报销单
*
* @param applierId
* @return
*/
public DataSet getTripreimbursebill(String queryYear,String month,Long applierId) {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
String queryDate = queryYear+"-"+month+"-01";
LocalDate date = LocalDate.parse(queryDate, formatter);
// 获取当前日期的月份的第一天
LocalDate firstDayOfMonth = date.with(TemporalAdjusters.firstDayOfMonth());
// 获取当前日期的月份的最后一天
LocalDate lastDayOfMonth = date.with(TemporalAdjusters.lastDayOfMonth());
//查询非暂存废弃的数据
List<String> billStatuslist = new ArrayList<>();
billStatuslist.add("E"); //审核通过
billStatuslist.add("F"); //等待付款
billStatuslist.add("G"); //已付款
billStatuslist.add("I"); //关闭
//查询申请人下的今年的探亲差旅单据
List<QFilter> 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("bizdate", QCP.large_equals, firstDayOfMonth));
searchFilterList.add( new QFilter("bizdate", QCP.less_equals, lastDayOfMonth));
DataSet dateSet = QueryServiceHelper.queryDataSet(
this.getClass().getName(),
"er_tripreimbursebill",
"id,billno,zcgj_kccbdays as kccbdays,bizdate",
searchFilterList.toArray(new QFilter [] {}), null
);
return dateSet;
}
/**
* 获取费用报销单
*
* @return
*/
public DataSet getDailyreimbursebill(String queryYear,String month,Long applierId) {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
String queryDate = queryYear+"-"+month+"-01";
LocalDate date = LocalDate.parse(queryDate, formatter);
// 获取当前日期的月份的第一天
LocalDate firstDayOfMonth = date.with(TemporalAdjusters.firstDayOfMonth());
// 获取当前日期的月份的最后一天
LocalDate lastDayOfMonth = date.with(TemporalAdjusters.lastDayOfMonth());
//查询非暂存废弃的数据
List<String> billStatuslist = new ArrayList<>();
billStatuslist.add("E"); //审核通过
billStatuslist.add("F"); //等待付款
billStatuslist.add("G"); //已付款
//billStatuslist.add("H"); //废弃
billStatuslist.add("I"); //关闭
List<QFilter> searchFilterList = new ArrayList<>();
//查询申请人下的今年的探亲差旅单据
searchFilterList.add(new QFilter("applier", QCP.equals, applierId));
searchFilterList.add(new QFilter( "zcgj_is_visit", QCP.equals, true));
searchFilterList.add(new QFilter("billstatus", QCP.in, billStatuslist));
searchFilterList.add( new QFilter("bizdate", QCP.large_equals, firstDayOfMonth));
searchFilterList.add(new QFilter("bizdate", QCP.less_equals, lastDayOfMonth));
//DynamicObject[] load = BusinessDataServiceHelper.load("er_dailyreimbursebill", "id,billno,zcgj_kccbdays as kccbdays,bizdate," +
// "zcgj_holiday_start_time,zcgj_holiday_end_time," +
// "zcgj_homemx.zcgj_startdate,zcgj_homemx.zcgj_enddate", searchFilterList.toArray(new QFilter[]{}));
DataSet dateSet = QueryServiceHelper.queryDataSet(
this.getClass().getName(),
"er_dailyreimbursebill",
"id,billno,zcgj_kccbdays as kccbdays,bizdate," +
"zcgj_holiday_start_time,zcgj_holiday_end_time," +
"zcgj_homemx",
searchFilterList.toArray(new QFilter [] {}), null
);
List<QFilter> searchFilterList1 = new ArrayList<>();
//查询申请人下的今年的探亲差旅单据
searchFilterList1.add(new QFilter("applier", QCP.equals, applierId));
searchFilterList1.add(new QFilter( "zcgj_is_home", QCP.equals, true));
searchFilterList1.add(new QFilter("billstatus", QCP.in, billStatuslist));
searchFilterList1.add( new QFilter("bizdate", QCP.large_equals, firstDayOfMonth));
searchFilterList1.add(new QFilter("bizdate", QCP.less_equals, lastDayOfMonth));
//DynamicObject[] load = BusinessDataServiceHelper.load("er_dailyreimbursebill", "id,billno,zcgj_kccbdays as kccbdays,bizdate," +
// "zcgj_holiday_start_time,zcgj_holiday_end_time," +
// "zcgj_homemx.zcgj_startdate,zcgj_homemx.zcgj_enddate", searchFilterList.toArray(new QFilter[]{}));
DataSet dateSet1 = QueryServiceHelper.queryDataSet(
this.getClass().getName(),
"er_dailyreimbursebill",
"id,billno,zcgj_kccbdays as kccbdays,bizdate," +
"zcgj_homemx.zcgj_startdate,zcgj_homemx.zcgj_enddate",
searchFilterList1.toArray(new QFilter [] {}), null
);
return dateSet;
}
/**
* java.util.Date 转换为 java.time.LocalDate
* @param date java.util.Date