@ -9,6 +9,7 @@ import com.engine.common.entity.BizLogContext;
import com.engine.jucailinkq.common.util.DateUtil ;
import com.engine.jucailinkq.common.util.DbTools ;
import com.engine.core.interceptor.CommandContext ;
import com.engine.jucailinkq.common.util.Utils ;
import com.google.common.collect.Lists ;
import com.google.common.collect.Maps ;
@ -16,6 +17,8 @@ import lombok.extern.slf4j.Slf4j;
import weaver.general.Util ;
import weaver.hrm.company.DepartmentComInfo ;
import java.time.ZoneOffset ;
import java.util.Comparator ;
import java.util.List ;
import java.util.Map ;
import java.util.Set ;
@ -68,7 +71,7 @@ public class GetDatatableRecurrenceCmd extends AbstractCommonCommand<Map<String,
log . debug ( "递归查询人员-人员节点, sql:{},param:{}" , querySqlbyPbdx , param ) ;
List < Map < String , Object > > dataList = DbTools . getSqlToList ( querySqlbyPbdx , param . toArray ( ) ) ;
//人员数据
Map < String , List < Map < String , Object > > > personCollect = dataList . stream ( ) . collect ( Collectors . groupingBy ( e - > e . get ( "pbtj" ) . toString ( ) ) ) ;
// Map<String,List<Map<String,Object>>> personCollect = dataList.stream().collect(Collectors.groupingBy(e->e.get("pbtj").toString()));
//人员分组数据
@ -77,7 +80,9 @@ public class GetDatatableRecurrenceCmd extends AbstractCommonCommand<Map<String,
String currentTime = DateUtil . getCurrentDate ( ) ;
String queryryfz = "select a.mainid,a.empid,a.filters,a.bdate,a.edate,a.sqltj from uf_ryqz_dt1 a,(select pbdxryfz from uf_pbjg where dxlx=1 group by pbdxryfz) b where a.mainid =b.pbdxryfz and a.bdate <= '" + currentTime + "'" ;
List < Map < String , Object > > personGroupData = DbTools . getSqlToList ( queryryfz ) ;
Set < String > personnelGroupIds = PersongroupCommonUtil . getPersonnelGroupingByPerson ( personGroupData , pbdx , null , null ) ;
List < Map < String , Object > > personnelGroups = PersongroupCommonUtil . getPersonnelGroupByPerson ( personGroupData , pbdx , null ) ;
Map < String , List < Map < String , Object > > > personnelGroupsCollect = personnelGroups . stream ( ) . collect ( Collectors . groupingBy ( e - > e . get ( "mainid" ) . toString ( ) ) ) ;
Set < String > personnelGroupIds = personnelGroups . stream ( ) . map ( e - > e . get ( "mainid" ) . toString ( ) ) . collect ( Collectors . toSet ( ) ) ;
querySqlbyPbdx = sql + conditions + " and pbdxryfz in (" ;
log . debug ( "递归查询人员-人员分组节点, sql:{},personnelGroupIds:{}" , querySqlbyPbdx , personnelGroupIds ) ;
if ( personnelGroupIds . size ( ) > 0 ) {
@ -85,7 +90,22 @@ public class GetDatatableRecurrenceCmd extends AbstractCommonCommand<Map<String,
log . debug ( "递归查询人员-人员分组节点, sql:{}" , querySqlbyPbdx ) ;
personGroupList = DbTools . getSqlToList ( querySqlbyPbdx , Dateparam . toArray ( ) ) ;
}
Map < String , List < Map < String , Object > > > personGroupCollect = personGroupList . stream ( ) . collect ( Collectors . groupingBy ( e - > e . get ( "pbtj" ) . toString ( ) ) ) ;
personGroupList = personGroupList . stream ( ) . filter ( e - > {
String bcrq = e . get ( "bcrq" ) . toString ( ) ;
String pbdxryfz = e . get ( "pbdxryfz" ) . toString ( ) ;
Map < String , Object > personnelGroup = personnelGroupsCollect . get ( pbdxryfz ) . get ( personnelGroupsCollect . get ( pbdxryfz ) . size ( ) - 1 ) ;
String edate = Util . null2String ( personnelGroup . get ( "edate" ) ) ;
String bdate = Util . null2String ( personnelGroup . get ( "bdate" ) ) ;
e . put ( "bdate" , bdate ) ;
if ( ( ! "" . equals ( bdate ) & & DateUtil . getTime ( bcrq ) . compareTo ( DateUtil . getTime ( bdate ) ) < 0 ) | |
( ! "" . equals ( edate ) & & DateUtil . getTime ( bcrq ) . compareTo ( DateUtil . getTime ( edate ) ) > 0 ) ) {
return false ;
} else {
return true ;
}
} ) . collect ( Collectors . toList ( ) ) ;
//Map<String,List<Map<String,Object>>> personGroupCollect = personGroupList.stream().collect(Collectors.groupingBy(e->e.get("pbtj").toString()));
//部门数据
@ -101,7 +121,7 @@ public class GetDatatableRecurrenceCmd extends AbstractCommonCommand<Map<String,
log . debug ( "递归查询人员-部门节点, sql:{},pdeptids:{}" , querySqlbyPbdx , pdeptids ) ;
querySqlbyPbdx = querySqlbyPbdx + pdeptids + ") order by bcrq" ;
departmentList = DbTools . getSqlToList ( querySqlbyPbdx , Dateparam . toArray ( ) ) ;
Map < String , List < Map < String , Object > > > departmentCollect = departmentList . stream ( ) . collect ( Collectors . groupingBy ( e - > e . get ( "pbtj" ) . toString ( ) ) ) ;
// Map<String,List<Map<String,Object>>> departmentCollect = departmentList.stream().collect(Collectors.groupingBy(e->e.get("pbtj").toString()));
//分部数据
@ -113,34 +133,81 @@ public class GetDatatableRecurrenceCmd extends AbstractCommonCommand<Map<String,
param . addAll ( Dateparam ) ;
param . add ( dataMap . get ( "subcompanyid1" ) ) ;
subCompanyList = DbTools . getSqlToList ( querySqlbyPbdx , param . toArray ( ) ) ;
Map < String , List < Map < String , Object > > > subCompanyCollect = subCompanyList . stream ( ) . collect ( Collectors . groupingBy ( e - > e . get ( "pbtj" ) . toString ( ) ) ) ;
//Map<String,List<Map<String,Object>>> subCompanyCollect = subCompanyList.stream().collect(Collectors.groupingBy(e->e.get("pbtj").toString()));
//排班途径枚举集合
dataList . addAll ( personGroupList ) ;
dataList . addAll ( departmentList ) ;
dataList . addAll ( subCompanyList ) ;
if ( CheckBoxEnum . CHECKED . getKey ( ) . equals ( showAll ) ) {
dataTableList . addAll ( dataList ) ;
dataTableList . addAll ( personGroupList ) ;
dataTableList . addAll ( departmentList ) ;
dataTableList . addAll ( subCompanyList ) ;
} else {
if ( ! CheckBoxEnum . CHECKED . getKey ( ) . equals ( showAll ) ) {
Map < String , List < Map < String , Object > > > dataCollect = dataList . stream ( ) . collect ( Collectors . groupingBy ( e - > e . get ( "pbtj" ) . toString ( ) ) ) ;
for ( SchedulingApproachEnum schedulingApproachEnum : SchedulingApproachEnum . values ( ) ) {
List < Map < String , Object > > resulstList = person Collect. get ( schedulingApproachEnum . getKey ( ) ) ;
List < Map < String , Object > > resulstList = dataCollect . get ( schedulingApproachEnum . getKey ( ) ) ;
if ( resulstList = = null | | resulstList . size ( ) = = 0 ) {
resulstList = personGroupCollect . get ( schedulingApproachEnum . getKey ( ) ) ;
if ( resulstList = = null | | resulstList . size ( ) = = 0 ) {
resulstList = departmentCollect . get ( schedulingApproachEnum . getKey ( ) ) ;
if ( resulstList = = null | | resulstList . size ( ) = = 0 ) {
resulstList = subCompanyCollect . get ( schedulingApproachEnum . getKey ( ) ) ;
continue ;
}
Map < String , List < Map < String , Object > > > resulstCollect = resulstList . stream ( ) . collect ( Collectors . groupingBy ( e - > Util . null2String ( e . get ( "bcrq" ) ) ) ) ;
for ( Map . Entry < String , List < Map < String , Object > > > entry : resulstCollect . entrySet ( ) ) {
String bcrq = entry . getKey ( ) ;
List < Map < String , Object > > scheduleList = entry . getValue ( ) ;
if ( scheduleList . size ( ) > 1 ) {
//优先级。人员 》人员分组》部门》分部
List < Map < String , Object > > psersonList = scheduleList . stream ( ) . filter ( e - > ! Util . null2String ( e . get ( "pbdxry" ) ) . equals ( "" ) ) . collect ( Collectors . toList ( ) ) ;
if ( psersonList . size ( ) = = 0 ) {
psersonList = scheduleList . stream ( ) . filter ( e - > ! Util . null2String ( e . get ( "pbdxryfz" ) ) . equals ( "" ) ) . collect ( Collectors . toList ( ) ) ;
if ( psersonList . size ( ) > 1 ) {
psersonList = psersonList . stream ( ) . sorted ( Comparator . comparing ( e - > DateUtil . getTime ( e . get ( "bdate" ) . toString ( ) ) . toInstant ( ZoneOffset . of ( "+8" ) ) . toEpochMilli ( ) ) ) . collect ( Collectors . toList ( ) ) ;
psersonList = Lists . newArrayList ( psersonList . get ( psersonList . size ( ) - 1 ) ) ;
}
}
if ( psersonList . size ( ) = = 0 ) {
psersonList = scheduleList . stream ( ) . filter ( e - > ! Util . null2String ( e . get ( "pbdxbm" ) ) . equals ( "" ) ) . collect ( Collectors . toList ( ) ) ;
}
if ( psersonList . size ( ) = = 0 ) {
psersonList = scheduleList . stream ( ) . filter ( e - > ! Util . null2String ( e . get ( "pbdxfb" ) ) . equals ( "" ) ) . collect ( Collectors . toList ( ) ) ;
}
if ( psersonList . size ( ) > 0 ) {
if ( schedulingApproachEnum = = SchedulingApproachEnum . RULE ) {
psersonList = psersonList . stream ( ) . sorted ( Comparator . comparing ( e - > Long . valueOf ( e . get ( "pbgl" ) . toString ( ) ) ) ) . collect ( Collectors . toList ( ) ) ;
} else {
psersonList = psersonList . stream ( ) . sorted ( Comparator . comparing ( e - > Long . valueOf ( e . get ( "keyid" ) . toString ( ) ) ) ) . collect ( Collectors . toList ( ) ) ;
}
dataTableList . add ( psersonList . get ( psersonList . size ( ) - 1 ) ) ;
}
} else {
dataTableList . add ( scheduleList . get ( 0 ) ) ;
}
}
if ( resulstList ! = null & & resulstList . size ( ) ! = 0 ) {
dataTableList . addAll ( resulstList ) ;
}
}
} else {
dataTableList = dataList ;
}
// if (CheckBoxEnum.CHECKED.getKey().equals(showAll)){
// dataTableList.addAll(dataList);
// dataTableList.addAll(personGroupList);
// dataTableList.addAll(departmentList);
// dataTableList.addAll(subCompanyList);
// }else {
// for (SchedulingApproachEnum schedulingApproachEnum :SchedulingApproachEnum.values()){
// List<Map<String,Object>> resulstList = personCollect.get(schedulingApproachEnum.getKey());
// if (resulstList == null || resulstList.size() == 0){
// resulstList = personGroupCollect.get(schedulingApproachEnum.getKey());
// if (resulstList == null || resulstList.size() == 0){
// resulstList = departmentCollect.get(schedulingApproachEnum.getKey());
// if (resulstList == null || resulstList.size() == 0){
// resulstList = subCompanyCollect.get(schedulingApproachEnum.getKey());
// }
// }
// }
// if (resulstList != null && resulstList.size() != 0){
// dataTableList.addAll(resulstList);
// }
// }
// }
} else if ( "1" . equals ( pblx ) ) {
List < Object > param = Lists . newArrayList ( ) ;
param . addAll ( Dateparam ) ;
@ -220,7 +287,7 @@ public class GetDatatableRecurrenceCmd extends AbstractCommonCommand<Map<String,
String currentTime = DateUtil . getCurrentDate ( ) ;
String queryryfz = "select a.mainid,a.empid,a.filters,a.bdate,a.edate,a.sqltj from uf_ryqz_dt1 a,(select pbdxryfz from uf_pbjg where dxlx=1 group by pbdxryfz) b where a.mainid =b.pbdxryfz and a.bdate <= '" + currentTime + "'" ;
List < Map < String , Object > > personGroupData = DbTools . getSqlToList ( queryryfz ) ;
Set < String > personnelGroupIds = PersongroupCommonUtil . getPersonnelGroupingByPerson ( personGroupData , pbdx , null ,null );
Set < String > personnelGroupIds = PersongroupCommonUtil . getPersonnelGroupingByPerson ( personGroupData , pbdx , null );
String querySqlbyPbdx = sql + conditions + " and pbdxryfz in (" ;
log . debug ( "递归查询人员-人员分组节点, sql:{},personnelGroupIds:{}" , querySqlbyPbdx , personnelGroupIds ) ;
if ( personnelGroupIds . size ( ) > 0 ) {