@ -1,25 +1,26 @@
package com.engine.matfron.service.impl ;
package com.engine.matfron.service.impl ;
import com.engine.core.impl.Service ;
import com.engine.core.impl.Service ;
import com.engine.matfron.entity.DepartmentParam ;
import com.engine.matfron.entity.OptionVO ;
import com.engine.matfron.entity.OptionVO ;
import com.engine.matfron.entity.PortalTopVO ;
import com.engine.matfron.entity.PortalTopVO ;
import com.engine.matfron.entity.SeriesParam ;
import com.engine.matfron.service.StatisticsPortalService ;
import com.engine.matfron.service.StatisticsPortalService ;
import com.engine.matfron.util.CommonDateUtil ;
import com.engine.matfron.util.CommonDateUtil ;
import com.engine.matfron.util.CommonUtils ;
import com.engine.matfron.util.CommonUtils ;
import org.apache.commons.lang.StringUtils ;
import weaver.conn.RecordSet ;
import weaver.conn.RecordSet ;
import weaver.general.Util ;
import weaver.general.Util ;
import java.time.LocalDate ;
import java.time.YearMonth ;
import java.time.YearMonth ;
import java.util.ArrayList ;
import java.util.* ;
import java.util.List ;
import java.util.TreeSet ;
/ * *
/ * *
* @Author liang . cheng
* @Author liang . cheng
* @Date 2023 / 9 / 26 5 : 52 PM
* @Date 2023 / 9 / 26 5 : 52 PM
* @Description : TODO
* @Description :
* @Version 1.0
* @Version 1.0
* /
* /
public class StatisticsPortalServiceImpl extends Service implements StatisticsPortalService {
public class StatisticsPortalServiceImpl extends Service implements StatisticsPortalService {
@ -62,9 +63,88 @@ public class StatisticsPortalServiceImpl extends Service implements StatisticsPo
@Override
@Override
public OptionVO getPortalDepartment ( ) {
public OptionVO getPortalDepartment ( ) {
RecordSet rs = new RecordSet ( ) ;
RecordSet rs = new RecordSet ( ) ;
TreeSet < String > xData = new TreeSet < > ( ) ;
TreeSet < Integer > yData = new TreeSet < > ( ) ;
List < Integer > ids = new ArrayList < > ( ) ;
rs . executeQuery ( "select id,departmentname from hrmdepartment where supdepid = 0" ) ;
rs . executeQuery ( "select id,departmentname from hrmdepartment where supdepid = 0" ) ;
while ( rs . next ( ) ) {
xData . add ( Util . null2String ( rs . getString ( "departmentname" ) ) ) ;
ids . add ( Util . getIntValue ( rs . getString ( "id" ) ) ) ;
}
List < DepartmentParam > deptList = new ArrayList < > ( ) ;
rs . executeQuery ( "select departmentid,count(1) AS count from hrmresource where status < 4 and departmentid in (" + StringUtils . join ( ids , "," ) + ") group by departmentid" ) ;
while ( rs . next ( ) ) {
deptList . add ( DepartmentParam . builder ( ) . departmentId ( Util . getIntValue ( rs . getString ( "departmentid" ) ) ) . count ( Util . getIntValue ( rs . getString ( "count" ) ) ) . build ( ) ) ;
}
ids . forEach ( item - > deptList . forEach ( dept - > {
if ( dept . getDepartmentId ( ) . equals ( item ) ) {
yData . add ( dept . getCount ( ) ) ;
} else {
yData . add ( 0 ) ;
}
} ) ) ;
int max = Collections . max ( yData ) ;
int ceil = ( int ) Math . ceil ( ( double ) max / 5 ) ;
ceil = CommonUtils . roundUpToNearestTen ( ceil ) ;
int roundedMax = CommonUtils . roundedMax ( ceil , 5 ) ;
return OptionVO . builder ( )
. titleText ( "一级部门人数统计" )
. xData ( xData )
. yMin ( 0 )
. yMax ( roundedMax )
. yInterval ( ceil )
. yData ( yData )
. build ( ) ;
}
@Override
public OptionVO getPortalSubCompany ( ) {
RecordSet rs = new RecordSet ( ) ;
TreeSet < Integer > yData = new TreeSet < > ( ) ;
List < YearMonth > yearMonths = CommonDateUtil . getYearMonths ( LocalDate . now ( ) ) ;
yearMonths . forEach ( yearMonth - > {
String startMonth = CommonDateUtil . getFormatYear ( CommonDateUtil . toDateStartOfMonth ( yearMonth ) ) ;
String endMonth = CommonDateUtil . getFormatYear ( CommonDateUtil . toDateEndOfMonth ( yearMonth ) ) ;
rs . executeQuery ( "select count(1) as sum from hrmresource where status < 4 and companystartdate >= ? and companystartdate <= ? " , startMonth , endMonth ) ;
rs . next ( ) ;
Integer sum = Util . getIntValue ( rs . getString ( "sum" ) , 0 ) ;
yData . add ( sum ) ;
} ) ;
int max = Collections . max ( yData ) ;
int ceil = ( int ) Math . ceil ( ( double ) max / 5 ) ;
ceil = CommonUtils . roundUpToNearestTen ( ceil ) ;
int roundedMax = CommonUtils . roundedMax ( ceil , 5 ) ;
return OptionVO . builder ( )
. titleText ( "各月份分部总人数" )
. yMin ( 0 )
. yMax ( roundedMax )
. yInterval ( ceil )
. yData ( yData )
. build ( ) ;
}
@Override
public OptionVO getPortalEthnic ( ) {
RecordSet rs = new RecordSet ( ) ;
List < String > colorList = Arrays . asList ( "#6e94f3" , "#83d8ae" , "#697695" , "#8ac9e9" ) ;
TreeSet < SeriesParam > seriesData = new TreeSet < > ( ) ;
rs . executeQuery ( "select distinct folk,count(1) as count from hrmresource where status < 4 \n" +
" and folk is not null group by folk" ) ;
while ( rs . next ( ) ) {
seriesData . add ( SeriesParam . builder ( ) . build ( ) ) ;
}
return null ;
return null ;
}
}
}
}