@ -59,12 +59,15 @@ public class OvertimePlanServiceImpl extends Service implements OvertimePlanServ
List < Map < String , Object > > jblxAttendanceList = DbTools . getSqlToList ( sql , AttendanceItemTypeEnum . WORK_OVERTIME . getKey ( ) , WorkForTimeEnum . PLAN_WORK_OVERTIME . getKey ( ) ) ;
List < Map < String , Object > > jblxAttendanceList = DbTools . getSqlToList ( sql , AttendanceItemTypeEnum . WORK_OVERTIME . getKey ( ) , WorkForTimeEnum . PLAN_WORK_OVERTIME . getKey ( ) ) ;
//获取人员id和姓名信息
//获取人员id和姓名信息
Map < String , String > empIdToNameInfo = CommonUtil . empIdToNameInfo ( empIdList ) ;
Map < String , String > empIdToNameInfo = CommonUtil . empIdToNameInfo ( empIdList ) ;
//获取目标人员列表已存在的加班计划
Map < String , List < Map < String , Object > > > existOvertimePlanInfo = getOvertimePlanInfo ( empIdList , startDate ) ;
List < Map < String , Object > > existOvertimePlanList = new ArrayList < > ( ) ;
for ( String empId : empIdList ) {
for ( String empId : empIdList ) {
List < Map < String , Object > > scheduleInfoList = scheduleInfoMap . get ( empId ) ;
List < Map < String , Object > > scheduleInfoList = scheduleInfoMap . get ( empId ) ;
Map < String , String > dateToBcxxMap = scheduleInfoList = = null ? new HashMap < > ( ) : scheduleInfoList . stream ( ) . collect ( Collectors . toMap ( e - > Util . null2String ( e . get ( "bcrq" ) ) , e - > Util . null2String ( e . get ( "bcxx" ) ) ) ) ;
Map < String , String > dateToBcxxMap = scheduleInfoList = = null ? new HashMap < > ( ) : scheduleInfoList . stream ( ) . collect ( Collectors . toMap ( e - > Util . null2String ( e . get ( "bcrq" ) ) , e - > Util . null2String ( e . get ( "bcxx" ) ) ) ) ;
Map < String , String > dateTypeInfoFromBc = scheduleInfoList = = null ? new HashMap < > ( ) : scheduleInfoList . stream ( ) . collect ( Collectors . toMap ( e - > Util . null2String ( e . get ( "bcrq" ) ) , e - > Util . null2String ( e . get ( "rqlx" ) ) ) ) ;
Map < String , String > dateTypeInfoFromBc = scheduleInfoList = = null ? new HashMap < > ( ) : scheduleInfoList . stream ( ) . collect ( Collectors . toMap ( e - > Util . null2String ( e . get ( "bcrq" ) ) , e - > Util . null2String ( e . get ( "rqlx" ) ) ) ) ;
existOvertimePlanList = existOvertimePlanInfo . get ( empId ) ;
for ( String date : dateList ) {
for ( String date : dateList ) {
String realEndDate = date ;
String realEndDate = date ;
detailItem = new HashMap < > ( ) ;
detailItem = new HashMap < > ( ) ;
@ -80,6 +83,12 @@ public class OvertimePlanServiceImpl extends Service implements OvertimePlanServ
realEndDate = DateUtil . AfterDay ( date , 1 ) ;
realEndDate = DateUtil . AfterDay ( date , 1 ) ;
}
}
detailItem . put ( "jsrq" , realEndDate ) ;
detailItem . put ( "jsrq" , realEndDate ) ;
//判断改组明细是否与已存在的加班计划有重叠
boolean overLappingSign = checkOverlapping ( existOvertimePlanList , date + " " + startTime , realEndDate + " " + endTime ) ;
if ( overLappingSign ) {
errorMessage . add ( Util . null2String ( empIdToNameInfo . get ( empId ) ) + "在日期" + date + "的加班计划区间和已申请的加班计划(已审核/待审核)出现时间重叠,不允许申请加班!" ) ;
continue ;
}
//加班时长
//加班时长
int overtimeMinutes = DateUtil . getBetWeenMinutes ( date + " " + startTime , realEndDate + " " + endTime ) ;
int overtimeMinutes = DateUtil . getBetWeenMinutes ( date + " " + startTime , realEndDate + " " + endTime ) ;
detailItem . put ( "jbsc" , String . format ( "%.2f" , overtimeMinutes / 60.0 ) ) ;
detailItem . put ( "jbsc" , String . format ( "%.2f" , overtimeMinutes / 60.0 ) ) ;
@ -184,6 +193,40 @@ public class OvertimePlanServiceImpl extends Service implements OvertimePlanServ
return resultMap ;
return resultMap ;
}
}
private boolean checkOverlapping ( List < Map < String , Object > > existOvertimePlanList , String startTimePoint , String endTimePoint ) {
boolean overlappingSign = false ;
if ( existOvertimePlanList ! = null & & existOvertimePlanList . size ( ) > 0 ) {
String contrastStartPoint = "" ;
String contrastEndPoint = "" ;
for ( Map < String , Object > item : existOvertimePlanList ) {
contrastStartPoint = item . get ( "ksrq" ) + " " + item . get ( "kssj" ) ;
contrastEndPoint = item . get ( "jsrq" ) + " " + item . get ( "jssj" ) ;
overlappingSign = DateUtil . isOverlapping ( contrastStartPoint , contrastEndPoint , startTimePoint , endTimePoint ) ;
if ( overlappingSign ) {
break ;
}
}
}
return overlappingSign ;
}
/ * *
* 获 取 目 标 人 员 在 加 班 计 划 表 中 结 束 日 期 大 于 等 于 匹 配 日 期 的 数 据 记 录
* @param empIdList 人 员 id 列 表
* @param matchDate 匹 配 日 期
* @returnd
* /
private Map < String , List < Map < String , Object > > > getOvertimePlanInfo ( List < String > empIdList , String matchDate ) {
Map < String , List < Map < String , Object > > > result = new HashMap < > ( ) ;
if ( empIdList . size ( ) > 0 & & ! "" . equals ( matchDate ) ) {
String sql = "select b.id, b.jbry, b.ksrq, b.jsrq, b.kssj, b.jssj from uf_jcl_kq_jbjh a left join uf_jcl_kq_jbjh_dt1 b on b.mainid = a.id where a.jlzt != 2 and b.jsrq >= '"
+ matchDate + "' and b.jbry in (" + String . join ( "," , empIdList ) + ")" ;
List < Map < String , Object > > data = DbTools . getSqlToList ( sql ) ;
result = data . stream ( ) . collect ( Collectors . groupingBy ( e - > e . get ( "jbry" ) . toString ( ) ) ) ;
}
return result ;
}
public String getBcStartAndEndTime ( String date , String currentDayBcId , List < String > workBdlxList ) {
public String getBcStartAndEndTime ( String date , String currentDayBcId , List < String > workBdlxList ) {
String startToEnd = "" ;
String startToEnd = "" ;
if ( ! "" . equals ( currentDayBcId ) ) {
if ( ! "" . equals ( currentDayBcId ) ) {