@ -185,7 +185,7 @@ public class AskForLeaveServiceImpl extends Service implements AskForLeaveServic
empIdToName = data . stream ( ) . collect ( Collectors . toMap ( e - > Util . null2String ( e . get ( "id" ) ) , e - > Util . null2String ( e . get ( "lastname" ) ) ) ) ;
}
//获取填写的请假类型关联的考勤项目
String sql = "select id,mc,hsdw,hsl,jcbyxsyqjb,yxsydjb,qzsyyxjb,zdycbcndfgzsd,zdycrqqjndxxb from uf_jcl_kq_kqxm where id=?";
String sql = "select id,mc,hsdw,hsl,jcbyxsyqjb,yxsydjb,qzsyyxjb,zdycbcndfgzsd,zdycrqqjndxxb ,yxyz,zdyzsl from uf_jcl_kq_kqxm where id=?";
Map < String , Object > holidayItem = DbTools . getSqlToMap ( sql , leaveType ) ;
//勾选假期类型名称
String checkItemName = Util . null2String ( holidayItem . get ( "mc" ) ) ;
@ -216,14 +216,14 @@ public class AskForLeaveServiceImpl extends Service implements AskForLeaveServic
continue ;
}
//1-收集使用勾选的关联的可使用的余额, 才能够生成请假明细, 可使用的条件为, a-满足最小使用时长, b-满足使用次数上限, c-存在未休时长
List < Map < String , Object > > canUseCheckJqyeInfo = collectUsableHolidayBalance ( unableUseJqyeIdList , editedUseJqed , leaveType , startDate , entry . getKey ( ) ) ;
List < Map < String , Object > > canUseCheckJqyeInfo = collectUsableHolidayBalance ( unableUseJqyeIdList , editedUseJqed , holidayItem , startDate , entry . getKey ( ) ) ;
List < Map < String , String > > detailListItem ;
//判断考勤项目是否需要强制使用“优先使用项目”
if ( useFirstItemSign ) {
//勾选假期类型名称
String firstItemName = Util . null2String ( holidayPriorityItem . get ( "mc" ) ) ;
//2-收集优先使用的项目关联的可使用的余额, 才能够生成请假明细, 可使用的条件为, a-满足最小使用时长, b-满足使用次数上限, c-存在未休时长
List < Map < String , Object > > canUseFirstJqyeInfo = collectUsableHolidayBalance ( unableUseJqyeIdList , editedUseJqed , holidayPriorityItem .get ( "id" ) . toString ( ) , startDate , entry . getKey ( ) ) ;
List < Map < String , Object > > canUseFirstJqyeInfo = collectUsableHolidayBalance ( unableUseJqyeIdList , editedUseJqed , holidayPriorityItem , startDate , entry . getKey ( ) ) ;
detailListItem = matchHolidayBalance ( editedLeaveInfo , checkAmountJqIdList , errorMessage , entry . getKey ( ) , empIdToName . get ( entry . getKey ( ) ) , canUseCheckJqyeInfo , canUseFirstJqyeInfo , editedUseJqed ,
editedUseJqlxWithEmp , entry . getValue ( ) , leaveType , holidayPriorityItem . get ( "id" ) . toString ( ) , checkItemName , firstItemName ) ;
} else {
@ -684,13 +684,17 @@ public class AskForLeaveServiceImpl extends Service implements AskForLeaveServic
* 收 集 假 期 类 型 关 联 的 可 使 用 的 假 期 余 额
* @param unableUseJqyeIdList 不 可 使 用 的 假 期 余 额 id 集 合
* @param editedUseJqed 已 编 辑 过 的 假 期 余 额 id 和 具 体 使 用 的 时 长 映 射
* @param itemId 假 期 类 型 对 应 的 考 勤 项 目 id
* @param hol idayI tem 假 期 类 型 对 应 的 考 勤 项 目 信 息
* @param startDate 开 始 日 期
* @param leaveEmpId 请 假 人 id
* /
private List < Map < String , Object > > collectUsableHolidayBalance ( List < String > unableUseJqyeIdList , Map < String , Double > editedUseJqed , String itemId , String startDate , String leaveEmpId ) {
String sql = "select id,jqid,sxrq,ktsc,yxsc,wxsc,yqsxrq,ztsc from uf_jcl_kq_jqye where ygid=? and jqid=? and sxrq<=? and yqsxrq>=? order by sxrq" ;
private List < Map < String , Object > > collectUsableHolidayBalance ( List < String > unableUseJqyeIdList , Map < String , Double > editedUseJqed , Map < String , Object > holidayItem , String startDate , String leaveEmpId ) {
String itemId = Util . null2String ( holidayItem . get ( "id" ) ) ;
String sql = "select id,jqid,sxrq,ktsc,yxsc,wxsc,yqsxrq,ztsc from uf_jcl_kq_jqye where ygid=? and jqid=? and sxrq<=? and yqsxrq>=? order by sxrq, modedatacreatedate, modedatacreatetime" ;
List < Map < String , Object > > holidayBalanceList = DbTools . getSqlToList ( sql , leaveEmpId , itemId , startDate , startDate ) ;
//获取失效日期最晚的一条
Map < String , Object > maxSxrqMap = holidayBalanceList . stream ( ) . reduce ( ( m1 , m2 ) - > m2 ) . orElse ( null ) ;
//获取假期额度规则中额度可修次数、单次最小休时长、额度单位
String jqedSql = "select eddw, dczskxsc, edbxdcxw from uf_jcl_kq_jqed where jb = ?" ;
Map < String , Object > jqedInfo = DbTools . getSqlToMap ( jqedSql , itemId ) ;
@ -736,12 +740,19 @@ public class AskForLeaveServiceImpl extends Service implements AskForLeaveServic
return Integer . parseInt ( allowLeaveNumStr ) > beforeUseNum ;
} ) . collect ( Collectors . toList ( ) ) ;
}
//判断是否可预支
String allowAdvance = Util . null2String ( holidayItem . get ( "yxyz" ) ) ;
String advanceSc = Util . null2String ( holidayItem . get ( "zdyzsl" ) ) ;
//遍历可使用的假期余额,去除已编辑请假明细记录中使用的时长
List < Map < String , Object > > canUseHolidayBalanceList = new ArrayList < > ( ) ;
for ( Map < String , Object > holidayBalance : holidayBalanceList ) {
String jqyeId = Util . null2String ( holidayBalance . get ( "id" ) ) ;
if ( ! unableUseJqyeIdList . contains ( jqyeId ) ) {
double wxsc = Utils . convertDouble ( holidayBalance . get ( "wxsc" ) ) * multiple ;
//如果该条假期余额可以预支,则在原有未休时长基础上增加预支时长
if ( "1" . equals ( allowAdvance ) & & maxSxrqMap ! = null & & Util . null2String ( maxSxrqMap . get ( "id" ) ) . equals ( jqyeId ) ) {
wxsc = wxsc + Utils . convertDouble ( advanceSc ) * multiple ;
}
double editedUseSc = Utils . convertDouble ( editedUseJqed . get ( jqyeId ) ) ;
double realWxsc = wxsc - editedUseSc ;
if ( ( minLeaveDuration = = null | | wxsc > = minLeaveDuration ) & & realWxsc > 0 ) {