费用报销单探亲休假功能调整

This commit is contained in:
zhangzhiguo 2025-11-12 15:31:03 +08:00
parent 62fca77de0
commit d39d5f0ba5
1 changed files with 57 additions and 45 deletions

View File

@ -11,6 +11,7 @@ import kd.bos.entity.plugin.PreparePropertysEventArgs;
import kd.bos.entity.validate.AbstractValidator; import kd.bos.entity.validate.AbstractValidator;
import kd.bos.orm.query.QCP; import kd.bos.orm.query.QCP;
import kd.bos.orm.query.QFilter; import kd.bos.orm.query.QFilter;
import kd.bos.servicehelper.BusinessDataServiceHelper;
import kd.bos.servicehelper.QueryServiceHelper; import kd.bos.servicehelper.QueryServiceHelper;
import kd.bos.servicehelper.user.UserServiceHelper; import kd.bos.servicehelper.user.UserServiceHelper;
import zcgj.zcdev.zcdev.fs.utils.OrgCheckUtils; import zcgj.zcdev.zcdev.fs.utils.OrgCheckUtils;
@ -62,10 +63,10 @@ public class DailyreimbursVisitCheckOp extends AbstractOperationServicePlugIn {
public void validate() { public void validate() {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy"); SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy");
ExtendedDataEntity[] extendedDataEntities = this.getDataEntities(); ExtendedDataEntity[] extendedDataEntities = this.getDataEntities();
int i =0; // int i =0;
Map<Long,Map<String,Object>> allMap = new HashMap<>(); // Map<Long,Map<String,Object>> allMap = new HashMap<>();
//当前提交的探亲单据id集合 //当前提交的探亲单据id集合
Map<Long,List<Long>> currentBillIdListMap = new HashMap<>(); // Map<Long,List<Long>> currentBillIdListMap = new HashMap<>();
for (ExtendedDataEntity extendedDataEntity : extendedDataEntities) { for (ExtendedDataEntity extendedDataEntity : extendedDataEntities) {
DynamicObject dataEntity = extendedDataEntity.getDataEntity(); DynamicObject dataEntity = extendedDataEntity.getDataEntity();
@ -113,7 +114,7 @@ public class DailyreimbursVisitCheckOp extends AbstractOperationServicePlugIn {
//探亲年限 //探亲年限
int visitYear = 0; int visitYear = 0;
//总年探亲天数 //探父母假天数
int visitDays =dynamicObject.getInt("visitDays"); int visitDays =dynamicObject.getInt("visitDays");
//婚姻状况1已婚2未婚 //婚姻状况1已婚2未婚
int marriedStatus =dynamicObject.getInt("marriedStatus"); int marriedStatus =dynamicObject.getInt("marriedStatus");
@ -136,31 +137,8 @@ public class DailyreimbursVisitCheckOp extends AbstractOperationServicePlugIn {
//未婚探望父母次数 //未婚探望父母次数
int unmarriedParentsTime =dynamicObject.getInt("unmarriedParentsTime"); int unmarriedParentsTime =dynamicObject.getInt("unmarriedParentsTime");
/*if(visitDays == 0 ){ //配置婚姻状况 zcgj_married_status
this.addFatalErrorMessage(extendedDataEntity, "人员探亲配置探父母天数为空!");
return;
}*/
if(marriedStatus == 1 ){ // 已婚 if(marriedStatus == 1 ){ // 已婚
/*if(marriedSpouseDays == 0 ){
this.addFatalErrorMessage(extendedDataEntity, "人员探亲配置探配偶天数为空!");
return;
}
if(marriedParentsYear == 0 ){
this.addFatalErrorMessage(extendedDataEntity, "人员探亲配置已婚探望父母年限为空!");
return;
}
if(marriedParentsTime == 0 ){
this.addFatalErrorMessage(extendedDataEntity, "人员探亲配置已婚探望父母次数为空!");
return;
}
if(marriedSpouseYear == 0 ){
this.addFatalErrorMessage(extendedDataEntity, "人员探亲配置已婚探望配偶年限为空!");
return;
}
if(marriedSpouseTime == 0 ){
this.addFatalErrorMessage(extendedDataEntity, "人员探亲配置已婚探望配偶次数为空!");
return;
}*/
//如果是探望父母 //如果是探望父母
if("1".equals(visitType)){ if("1".equals(visitType)){
visitYear = marriedParentsYear; visitYear = marriedParentsYear;
@ -172,18 +150,10 @@ public class DailyreimbursVisitCheckOp extends AbstractOperationServicePlugIn {
visitYear = marriedSpouseYear; visitYear = marriedSpouseYear;
} }
}else if (marriedStatus == 2) { // 未婚 }else if (marriedStatus == 2) { // 未婚
if(!"1".equals(visitType)){ if(!"1".equals(visitType)){//报销探亲类型
this.addFatalErrorMessage(extendedDataEntity, "未婚状态下探亲类型只能选择探望父母!"); this.addFatalErrorMessage(extendedDataEntity, "未婚状态下探亲类型只能选择探望父母!");
return; return;
} }
/*if(unmarriedParentsYear == 0 ){
this.addFatalErrorMessage(extendedDataEntity, "人员探亲配置未婚探望父母年限为空!");
return;
}
if(unmarriedParentsTime == 0 ){
this.addFatalErrorMessage(extendedDataEntity, "人员探亲配置未婚探望父母次数为空!");
return;
}*/
visitTime = unmarriedParentsTime; visitTime = unmarriedParentsTime;
visitYear = unmarriedParentsYear; visitYear = unmarriedParentsYear;
@ -207,22 +177,65 @@ public class DailyreimbursVisitCheckOp extends AbstractOperationServicePlugIn {
billStatuslist.add("F"); billStatuslist.add("F");
billStatuslist.add("G"); billStatuslist.add("G");
// 查询条件 // 查询条件
QFilter[] filterArray = new QFilter[5]; QFilter[] filterArray = new QFilter[6];
//查询申请人下的今年的探亲差旅单据 //查询申请人下的今年的探亲差旅单据
filterArray[0] = new QFilter(prefix+"_holiday_start_time", QCP.large_equals, firstDayOfYear); filterArray[0] = new QFilter(prefix+"_holiday_start_time", QCP.large_equals, firstDayOfYear);
filterArray[1] = new QFilter(prefix+"_holiday_start_time", QCP.less_equals, lastDayOfYear); filterArray[1] = new QFilter(prefix+"_holiday_start_time", QCP.less_equals, lastDayOfYear);
filterArray[2] = new QFilter("applier", QCP.equals, applierId); filterArray[2] = new QFilter("applier", QCP.equals, applierId);
filterArray[3] = new QFilter(prefix+"_is_visit", QCP.equals, true); filterArray[3] = new QFilter(prefix+"_is_visit", QCP.equals, true);
filterArray[4] = new QFilter("billstatus", QCP.in, billStatuslist); filterArray[4] = new QFilter("billstatus", QCP.in, billStatuslist);
filterArray[5] = new QFilter("zcgj_visit_type", QCP.equals, visitType);
DataSet dateSet = QueryServiceHelper.queryDataSet( DynamicObject[] dailyreimbursebillArray = BusinessDataServiceHelper.load("er_dailyreimbursebill",
"id,billno,zcgj_visit_type ,zcgj_holiday_start_time ,zcgj_holiday_end_time ,zcgj_holiday_days ",filterArray );
//类型请假总次数
int allHolidayCount = 0;//已用探亲假天数
int holidayCount = 0;//已用探亲假次数
for (DynamicObject dailyreimbursebill : dailyreimbursebillArray) {
long billId = dailyreimbursebill.getLong("id");
if(billId != aLong){
String string = dailyreimbursebill.getString("billno");
Date startTimeVal = dailyreimbursebill.getDate("zcgj_holiday_start_time");
Date endTimeVal = dailyreimbursebill.getDate("zcgj_holiday_end_time");
Integer dayCount = dailyreimbursebill.getInt("zcgj_holiday_days");
String type = dailyreimbursebill.getString("zcgj_visit_type");//1:探父母2:探配哦
//long dayCount = ChronoUnit.DAYS.between(dateToLocalDate(startTimeVal), dateToLocalDate(endTimeVal));
allHolidayCount+=dayCount;
holidayCount++;
}
}
//已用剩余次数
int remainderTimes = visitTime-holidayCount;
//已用剩余天数
int remainderDays =visitDays-allHolidayCount;
//计算提交单据的剩余次数
int tims = remainderTimes - 1;
//计算提交单据的剩余天数
int dayCount = remainderDays - days;
String typeStr = "父母";
if("2".equals(visitType)){
typeStr = "配偶";
}
String message = String.format("您在%s年到%s年中已用%d次探"+typeStr+"休假,剩余%d次探"+typeStr+"休假,已用%d天探"+typeStr+"天数,剩余%d天探"+typeStr+"天数。本次休假天数%d天。"
,firstDayYearsAgo.getYear(),dateFormat.format(startTime),
holidayCount,remainderTimes,
allHolidayCount,remainderDays,
days);
if((tims < 0) || dayCount < 0){
this.addFatalErrorMessage(extendedDataEntity, "探亲次数或探亲天数不足!"+message);
}
/*DataSet dateSet = QueryServiceHelper.queryDataSet(
this.getClass().getName(), this.getClass().getName(),
"er_dailyreimbursebill", "er_dailyreimbursebill",
"id,billno,zcgj_visit_type as visitType,zcgj_holiday_start_time as startTime,zcgj_holiday_end_time as endTime,zcgj_holiday_days as days", "id,billno,zcgj_visit_type as visitType,zcgj_holiday_start_time as startTime,zcgj_holiday_end_time as endTime,zcgj_holiday_days as days",
filterArray, null filterArray, null
); );*/
if(currentBillIdListMap.containsKey(applierId)){ /*if(currentBillIdListMap.containsKey(applierId)){
List<Long> longs = currentBillIdListMap.get(applierId); List<Long> longs = currentBillIdListMap.get(applierId);
longs.add(aLong); longs.add(aLong);
}else{ }else{
@ -241,10 +254,10 @@ public class DailyreimbursVisitCheckOp extends AbstractOperationServicePlugIn {
filterArray1, null filterArray1, null
); );
dateSet = dateSet.union(dateSetSave) ; dateSet = dateSet.union(dateSetSave) ;
} }*/
//使用请假总天数 //使用请假总天数
int allHolidayCount = 0; /*int allHolidayCount = 0;
int allHolidayCountPO = 0; int allHolidayCountPO = 0;
//使用请假总次数 //使用请假总次数
int holidayCount = 0; int holidayCount = 0;
@ -290,10 +303,9 @@ public class DailyreimbursVisitCheckOp extends AbstractOperationServicePlugIn {
}else{ }else{
this.addFatalErrorMessage(extendedDataEntity, "探亲次数或探亲天数不足!"+message); this.addFatalErrorMessage(extendedDataEntity, "探亲次数或探亲天数不足!"+message);
return; return;
}*/
} }
} }
i++;
}
} }
} }
} }