1.探亲休假台账调整

This commit is contained in:
zhangzhiguo 2025-03-25 09:14:35 +08:00
parent 55975606a7
commit 426c023324
4 changed files with 426 additions and 31 deletions

View File

@ -0,0 +1,103 @@
package zcgj.zcdev.zcdev.fs.plugin.report;
import java.util.Date;
public class VisitReportVo {
private Long applier;
private String appliername;
private String orgname;
private Integer holidayHaveDays;
private Integer holidayDays;
private Integer holidayNoDays;
private String phone;
private Integer totalCount;
private Integer usesCount;
public VisitReportVo() {
}
public VisitReportVo(Long applier, String appliername, String orgname, Integer holidayHaveDays, Integer holidayDays, Integer holidayNoDays, String phone, Integer totalCount, Integer usesCount) {
this.applier = applier;
this.appliername = appliername;
this.orgname = orgname;
this.holidayHaveDays = holidayHaveDays;
this.holidayDays = holidayDays;
this.holidayNoDays = holidayNoDays;
this.phone = phone;
this.totalCount = totalCount;
this.usesCount = usesCount;
}
public Long getApplier() {
return applier;
}
public void setApplier(Long applier) {
this.applier = applier;
}
public String getAppliername() {
return appliername;
}
public void setAppliername(String appliername) {
this.appliername = appliername;
}
public String getOrgname() {
return orgname;
}
public void setOrgname(String orgname) {
this.orgname = orgname;
}
public Integer getHolidayHaveDays() {
return holidayHaveDays;
}
public void setHolidayHaveDays(Integer holidayHaveDays) {
this.holidayHaveDays = holidayHaveDays;
}
public Integer getHolidayDays() {
return holidayDays;
}
public void setHolidayDays(Integer holidayDays) {
this.holidayDays = holidayDays;
}
public Integer getHolidayNoDays() {
return holidayNoDays;
}
public void setHolidayNoDays(Integer holidayNoDays) {
this.holidayNoDays = holidayNoDays;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
public Integer getTotalCount() {
return totalCount;
}
public void setTotalCount(Integer totalCount) {
this.totalCount = totalCount;
}
public Integer getUsesCount() {
return usesCount;
}
public void setUsesCount(Integer usesCount) {
this.usesCount = usesCount;
}
}

View File

@ -0,0 +1,136 @@
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.form.FormShowParameter;
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.text.SimpleDateFormat;
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 VisitRptDetailListPlugin extends AbstractFormPlugin implements Plugin {
@Override
public void afterCreateNewData(EventObject e) {
super.afterCreateNewData(e);
// 获取当前页面的FormShowParameter对象
FormShowParameter formShowParameter = this.getView().getFormShowParameter();
// 日期格式化
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
// 获取自定义参数
Long userId = (Long)formShowParameter.getCustomParam("userId");
String queryDate = (String)formShowParameter.getCustomParam("queryDate");
LocalDate parse = LocalDate.parse(queryDate);
System.out.println();
DynamicObjectCollection zcgjKccbList = this.getModel().getDataEntity().getDynamicObjectCollection("zcgj_entryentity");
DataSet tripreimbursebill = getDailyreimbursebill(queryDate, userId);
for (Row row : tripreimbursebill) {
DynamicObject dynamicObject = zcgjKccbList.addNew();
String billNo = row.getString("billno");
dynamicObject.set("zcgj_billno",billNo);
String triptypename = row.getString("triptypename");
dynamicObject.set("zcgj_holiday_type","1".equals(triptypename) ?"探望父母":"探望配偶");
Date startdate = row.getDate("startdate");
String startdateStr = dateFormat.format(startdate);
Date enddate = row.getDate("enddate");
String enddateStr = dateFormat.format(enddate);
dynamicObject.set("zcgj_holiday_date_start",startdate);
dynamicObject.set("zcgj_holiday_date_end",enddate);
Integer days = row.getInteger("days");
dynamicObject.set("zcgj_holiday_days",days);
String address = row.getString("address");
dynamicObject.set("zcgj_holiday_addr",address);
String description = row.getString("description");
dynamicObject.set("zcgj_reason",description);
}
}
/**
* 获取差旅费报销单-行程信息
*
* @param applierId
* @return
*/
public DataSet getDailyreimbursebill(String queryDate, Long applierId) {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
LocalDate queryYear = LocalDate.parse(queryDate, formatter);
// 查询条件
List<QFilter> searchFilterList = new ArrayList<>();
searchFilterList.add(new QFilter("zcgj_is_visit", QCP.equals, true));
//QFilter[] filterArray = new QFilter[1];
//查询申请人下的单据
searchFilterList.add(new QFilter("applier", QCP.equals, applierId));
if(queryYear!=null){
LocalDate firstDay = getFirstDayOfYear(queryYear.getYear());
LocalDate lastDay = getLastDayOfYear(queryYear.getYear());
searchFilterList.add(new QFilter("zcgj_holiday_start_time", QCP.large_equals, firstDay));
searchFilterList.add(new QFilter("zcgj_holiday_start_time", QCP.less_equals, lastDay));
}
List<String> 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"); //关闭
searchFilterList.add(new QFilter("billstatus", QCP.in, billStatuslist));//增加过滤
DataSet dateSet = QueryServiceHelper.queryDataSet(
this.getClass().getName(),
"er_dailyreimbursebill",
"id,applier,billno,applier.name as appliername,applier.phone as appliernamephone,description," +
"org.name as orgname,zcgj_visit_type as triptypename," +
"zcgj_holiday_address as address," +
"zcgj_holiday_start_time as startdate,zcgj_holiday_end_time as enddate,zcgj_holiday_days as days" ,
searchFilterList.toArray(new QFilter [] {}), null
).orderBy(new String[]{"applier", "startdate"});
return dateSet;
}
// 获取某年份的第一天
public static LocalDate getFirstDayOfYear(int year) {
return LocalDate.of(year, 1, 1);
}
// 获取某年份的最后一天
public static LocalDate getLastDayOfYear(int year) {
return LocalDate.of(year, 12, 31);
}
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();
}
}

View File

@ -1,16 +1,28 @@
package zcgj.zcdev.zcdev.fs.plugin.report;
import kd.bos.algo.DataSet;
import kd.bos.algo.Row;
import kd.bos.context.RequestContext;
import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.entity.datamodel.IDataModel;
import kd.bos.entity.datamodel.events.PackageDataEvent;
import kd.bos.entity.report.FilterInfo;
import kd.bos.entity.report.IReportListModel;
import kd.bos.entity.report.ReportQueryParam;
import kd.bos.form.FormShowParameter;
import kd.bos.form.ShowType;
import kd.bos.form.StyleCss;
import kd.bos.form.events.HyperLinkClickEvent;
import kd.bos.form.events.HyperLinkClickListener;
import kd.bos.report.ReportList;
import kd.bos.report.events.CellStyleRule;
import kd.bos.report.events.SortAndFilterEvent;
import kd.bos.report.plugin.AbstractReportFormPlugin;
import kd.bos.servicehelper.QueryServiceHelper;
import kd.sdk.plugin.Plugin;
import java.util.Date;
import java.util.EventObject;
import java.util.List;
/**
@ -24,11 +36,28 @@ public class VisitRptListPlugin extends AbstractReportFormPlugin implements Plug
private static final String DEV_KEY="zcgj";
private static final String[] FIELDS = {
DEV_KEY+"_user", DEV_KEY+"_username", DEV_KEY+"_department",DEV_KEY+"_holiday_date_start",
DEV_KEY+"_holiday_date_end",DEV_KEY+"_holiday_days",
DEV_KEY+"_user", DEV_KEY+"_username", DEV_KEY+"_department",DEV_KEY+"_holiday_date",
DEV_KEY+"_holiday_have_days",DEV_KEY+"_holiday_days",DEV_KEY+"_holiday_no_days",
DEV_KEY+"_holiday_type", DEV_KEY+"_holiday_addr", DEV_KEY+"_phone",
DEV_KEY+"_reason"
DEV_KEY+"_reason",DEV_KEY+"_total_count",DEV_KEY+"_uses_count"
};
@Override
public void afterQuery(ReportQueryParam queryParam) {
ReportList reportList = getView().getControl("reportlistap");
IReportListModel reportModel = reportList.getReportModel();
/*DataSet dataSet = QueryServiceHelper.queryDataSet(this.getClass().getName(), "zcgj_family_leave_rpt",
"zcgj_user as user,zcgj_holiday_have_days as havdDays,zcgj_holiday_days as holidayDays," +
"zcgj_holiday_no_days as holidayNoDays,zcgj_total_count as totalCount,zcgj_uses_count as usesCount", null, null);
int sumApplyDay = 0;
for (Row row : dataSet) {
int applyday = (int) row.get("havdDays");
sumApplyDay = sumApplyDay + applyday;
}*/
//this.getModel().setValue("kdec_sumapplyday", sumApplyDay);
super.afterQuery(queryParam);
}
@Override
public void setMergeColums(List<String> columns) {
columns.add(MERGECOLUM);
@ -70,6 +99,43 @@ public class VisitRptListPlugin extends AbstractReportFormPlugin implements Plug
super.setCellStyleRules(cellStyleRules);
}
@Override
public void registerListener(EventObject e) {
//监听报表超链接点击事件
super.registerListener(e);
ReportList reportList = getControl("reportlistap");
reportList.addHyperClickListener(new HyperLinkClickListener() {
@Override
public void hyperLinkClick(HyperLinkClickEvent hyperLinkClickEvent) {
String fieldName = hyperLinkClickEvent.getFieldName();
int rowIndex = hyperLinkClickEvent.getRowIndex();
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");
FormShowParameter formShowParameter;
formShowParameter = new FormShowParameter();
formShowParameter.getOpenStyle().setShowType(ShowType.Modal);
formShowParameter.setFormId("zcgj_visit_rpt_detail");
// 自定义传参把当前单据的文本字段传过去
formShowParameter.setCustomParam("queryDate", zcgjYear);
formShowParameter.setCustomParam("userId", userId);
StyleCss styleCss = new StyleCss();
styleCss.setWidth("800");
styleCss.setHeight("600");
formShowParameter.getOpenStyle().setInlineStyleCss(styleCss);
getView().showForm(formShowParameter);
}
}
}
});
}
/**
* 设置过滤排序列
*

View File

@ -57,14 +57,13 @@ public class VisitRptQueryPlugin extends AbstractReportListDataPlugin {
// 报表字段及数据类型
String[] FIELDS = {
DEV_KEY+"_user", DEV_KEY+"_username", DEV_KEY+"_department",DEV_KEY+"_holiday_date_start",
DEV_KEY+"_holiday_date_end",DEV_KEY+"_holiday_days",
DEV_KEY+"_holiday_type", DEV_KEY+"_holiday_addr", DEV_KEY+"_phone",
DEV_KEY+"_reason"
DEV_KEY+"_user", DEV_KEY+"_username", DEV_KEY+"_department",
DEV_KEY+"_holiday_have_days",DEV_KEY+"_holiday_days",DEV_KEY+"_holiday_no_days",
DEV_KEY+"_phone",DEV_KEY+"_total_count",DEV_KEY+"_uses_count",DEV_KEY+"_year"
};
DataType[] DATATYPES = {
DataType.LongType,DataType.StringType, DataType.StringType, DataType.StringType,
DataType.StringType,DataType.IntegerType,
DataType.LongType,DataType.StringType, DataType.StringType,
DataType.StringType,DataType.StringType,DataType.StringType,
DataType.StringType, DataType.StringType, DataType.StringType,
DataType.StringType
};
@ -116,44 +115,135 @@ public class VisitRptQueryPlugin extends AbstractReportListDataPlugin {
this.getClass().getName(),
"er_dailyreimbursebill",
"id,applier,applier.name as appliername,applier.phone as appliernamephone,description," +
"org.name as orgname,'探亲休假' as triptypename," +
"org.name as orgname,zcgj_visit_type as triptypename," +
"zcgj_holiday_address as address," +
"zcgj_holiday_start_time as startdate,zcgj_holiday_end_time as enddate,zcgj_holiday_days as days" ,
searchFilterList.toArray(new QFilter [] {}), null
).orderBy(new String[]{"applier", "startdate"});
// 汇总数据
Map<Long, Map<String, Map<String, BigDecimal>>> allData = new HashMap<>();
Map<Long,VisitReportVo> map = new HashMap<>();
for (Row itemRow : bdMaterialDataSet) {
Long applier = itemRow.getLong("applier");
String appliername = itemRow.getString("appliername");
String orgname = itemRow.getString("orgname");
String appliernamephone = itemRow.getString("appliernamephone");
Date startdate = itemRow.getDate("startdate");
String startdateStr = dateFormat.format(startdate);
Date enddate = itemRow.getDate("enddate");
String enddateStr = dateFormat.format(enddate);
String triptypename = itemRow.getString("triptypename");
String description = itemRow.getString("description");
String address = itemRow.getString("address");
Integer days = itemRow.getInteger("days");
Map<String, Integer> visitCount = getVisitCount(applier);
//婚姻状况1已婚2未婚
int marriedStatus = visitCount.get("marriedStatus");
//探父母天数
int visitDays = visitCount.get("visitDays");
//已婚探望配偶年限
int marriedSpouseYear =visitCount.get("marriedSpouseYear");
//已婚探配偶天数
int marriedSpouseDays =visitCount.get("marriedSpouseDays");
//未婚探望父母年限
int unmarriedParentsYear =visitCount.get("unmarriedParentsYear");
//已婚探望父母次数
int marriedParentsTime =visitCount.get("marriedParentsTime");
//已婚探望配偶次数
int marriedSpouseTime =visitCount.get("marriedSpouseTime");
//未婚探望父母次数
int unmarriedParentsTime =visitCount.get("unmarriedParentsTime");
//总探亲假天数 = 探望父母天数+已婚探配偶天数
VisitReportVo vp = null;
if(map.containsKey(applier)){
vp = map.get(applier);
vp.setHolidayDays(vp.getHolidayDays()+days);//未休
vp.setHolidayNoDays(vp.getHolidayNoDays()-days);//未休
Integer usesCount = vp.getUsesCount();
usesCount = usesCount+1;
vp.setUsesCount(usesCount);//已报销次数
}else{
vp = new VisitReportVo();
String appliername = itemRow.getString("appliername");
String orgname = itemRow.getString("orgname");
String appliernamephone = itemRow.getString("appliernamephone");
vp.setApplier(applier);
vp.setAppliername(appliername);
vp.setOrgname(orgname);
vp.setPhone(appliernamephone);
if(marriedStatus == 1){ //已婚
vp.setHolidayHaveDays(visitDays+marriedSpouseDays);
vp.setTotalCount(marriedSpouseTime+marriedParentsTime);//可报销次数 = 已婚探望配偶次数+已婚探望父母次数
}else{
vp.setHolidayHaveDays(visitDays);
vp.setTotalCount(unmarriedParentsTime);//可报销次数 = 未婚探望父母次数
}
vp.setHolidayDays(days); //已休
vp.setHolidayNoDays(vp.getHolidayHaveDays()-days);//未休
vp.setUsesCount(1);//已报销次数
map.put(applier,vp);
}
}
for (Long userId : map.keySet()) {
Object[] totalRow = new Object[FIELDS.length];
totalRow[0] = applier;
totalRow[1] = appliername;
totalRow[2] = orgname;
totalRow[3] = startdateStr;
totalRow[4] = enddateStr;
totalRow[5] = days;
totalRow[6] = triptypename;
totalRow[7] = address;
totalRow[8] = appliernamephone;
totalRow[9] = description;
VisitReportVo visitReportVo = map.get(userId);
totalRow[0] = visitReportVo.getApplier();
totalRow[1] = visitReportVo.getAppliername(); //用户名
totalRow[2] = visitReportVo.getOrgname();//组织
totalRow[3] = visitReportVo.getHolidayHaveDays();//应休
totalRow[4] = visitReportVo.getHolidayDays();//已休
totalRow[5] = visitReportVo.getHolidayNoDays();//20; //未休
totalRow[6] = visitReportVo.getPhone();
totalRow[7] = visitReportVo.getTotalCount();//可报销次数
totalRow[8] = visitReportVo.getUsesCount();//已报销次数
totalRow[9] = dateToLocalDate(queryYear);//已报销次数
coll.add(totalRow);
}
return resultDataSet;
}
public Map<String,Integer> getVisitCount(Long applierId){
Map<String,Integer> map = new HashMap<>();
QFilter[] visitSetFilterArray = new QFilter[1];
visitSetFilterArray[0] = new QFilter("zcgj_user", QCP.equals, applierId);
DynamicObject dynamicObject = QueryServiceHelper.queryOne( "zcgj_user_visit_set",
"id,zcgj_visit_times as visitTime,zcgj_visit_days as visitDays,zcgj_married_spouse_days marriedSpouseDays,zcgj_married_status as marriedStatus," +
"zcgj_married_parents_year as marriedParentsYear,zcgj_married_parents_time as marriedParentsTime," +
"zcgj_married_spouse_year as marriedSpouseYear,zcgj_married_spouse_time as marriedSpouseTime," +
"zcgj_unmarried_parents_y as unmarriedParentsYear,zcgj_unmarried_parents_t as unmarriedParentsTime",visitSetFilterArray);
if(dynamicObject == null){
return map;
}
//婚姻状况1已婚2未婚
int marriedStatus =dynamicObject.getInt("marriedStatus");
//未婚/已婚探父母天数
int visitDays =dynamicObject.getInt("visitDays");
//已婚探望配偶天数
int marriedSpouseDays = dynamicObject.getInt("marriedSpouseDays");
//已婚探望父母年限
int marriedParentsYear =dynamicObject.getInt("marriedParentsYear");
//已婚探望父母次数
int marriedParentsTime =dynamicObject.getInt("marriedParentsTime");
//已婚探望配偶年限
int marriedSpouseYear =dynamicObject.getInt("marriedSpouseYear");
//已婚探望配偶次数
int marriedSpouseTime =dynamicObject.getInt("marriedSpouseTime");
//未婚探望父母年限
int unmarriedParentsYear =dynamicObject.getInt("unmarriedParentsYear");
//未婚探望父母次数
int unmarriedParentsTime =dynamicObject.getInt("unmarriedParentsTime");
map.put("marriedStatus", marriedStatus);
map.put("visitDays", visitDays);
map.put("marriedSpouseDays", marriedSpouseDays);
map.put("marriedParentsYear", marriedParentsYear);
map.put("marriedParentsTime", marriedParentsTime);
map.put("marriedSpouseYear", marriedSpouseYear);
map.put("marriedSpouseTime", marriedSpouseTime);
map.put("unmarriedParentsYear", unmarriedParentsYear);
map.put("unmarriedParentsTime", unmarriedParentsTime);
return map;
}
// 获取某年份的第一天
public static LocalDate getFirstDayOfYear(int year) {