@ -29,6 +29,7 @@ import weaver.general.Util;
import weaver.hrm.User ;
import weaver.systeminfo.SystemEnv ;
import javax.ejb.Remove ;
import java.text.DecimalFormat ;
import java.util.* ;
@ -386,6 +387,15 @@ public class KQReportBiz extends BaseBean {
datas . putAll ( getDailyStatAllowanceData ( params , user ) ) ;
/*考勤二开--计算驻点餐补end*/
/*考勤二开--计算夜班餐补start*/
datas . putAll ( getDailyNightShiftAllowanceData ( params , user ) ) ;
/*考勤二开--计算夜班餐补end*/
/*考勤二开--计算鸿仁驻点餐补start*/
datas . putAll ( getDailyOtherStatAllowanceData ( params , user ) ) ;
/*考勤二开--计算鸿仁驻点餐补end*/
} catch ( Exception e ) {
writeLog ( e ) ;
}
@ -404,6 +414,12 @@ public class KQReportBiz extends BaseBean {
datas . putAll ( getCardMap ( params , user ) ) ;
datas . putAll ( getOverTime ( params , user ) ) ;
/*考勤二开--计算驻点餐补start*/
datas . putAll ( getDailyStatAllowanceData ( params , user ) ) ;
/*考勤二开--计算驻点餐补end*/
} catch ( Exception e ) {
writeLog ( e ) ;
}
@ -1451,6 +1467,385 @@ public class KQReportBiz extends BaseBean {
return datas ;
}
/ * *
* 获 取 鸿 仁 驻 点 餐 补 数 据
* @param params
* @param user
* @return
* /
public Map < String , Object > getDailyOtherStatAllowanceData ( Map < String , Object > params , User user ) {
Map < String , Object > datas = new HashMap < > ( ) ; ;
RecordSet rs = new RecordSet ( ) ;
String sql = "" ;
String sqlWhere = " " ;
try {
KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo ( ) ;
JSONObject jsonObj = JSON . parseObject ( Util . null2String ( params . get ( "data" ) ) ) ;
String fromDate = Util . null2String ( jsonObj . get ( "fromDate" ) ) ;
String toDate = Util . null2String ( jsonObj . get ( "toDate" ) ) ;
String typeselect = Util . null2String ( jsonObj . get ( "typeselect" ) ) ;
if ( typeselect . length ( ) = = 0 ) typeselect = "3" ;
if ( ! typeselect . equals ( "" ) & & ! typeselect . equals ( "0" ) & & ! typeselect . equals ( "6" ) ) {
if ( typeselect . equals ( "1" ) ) {
fromDate = TimeUtil . getCurrentDateString ( ) ;
toDate = TimeUtil . getCurrentDateString ( ) ;
} else {
fromDate = TimeUtil . getDateByOption ( typeselect , "0" ) ;
toDate = TimeUtil . getDateByOption ( typeselect , "1" ) ;
}
}
String subCompanyId = Util . null2String ( jsonObj . get ( "subCompanyId" ) ) ;
String departmentId = Util . null2String ( jsonObj . get ( "departmentId" ) ) ;
String resourceId = Util . null2String ( jsonObj . get ( "resourceId" ) ) ;
String allLevel = Util . null2String ( jsonObj . get ( "allLevel" ) ) ;
String isNoAccount = Util . null2String ( jsonObj . get ( "isNoAccount" ) ) ;
String viewScope = Util . null2String ( jsonObj . get ( "viewScope" ) ) ;
if ( subCompanyId . length ( ) > 0 ) {
sqlWhere + = " and a.subcompanyid1 in(" + subCompanyId + ") " ;
}
if ( departmentId . length ( ) > 0 ) {
sqlWhere + = " and a.departmentid in(" + departmentId + ") " ;
}
if ( resourceId . length ( ) > 0 ) {
sqlWhere + = " and a.id in(" + resourceId + ") " ;
}
if ( viewScope . equals ( "4" ) ) { //我的下属
if ( allLevel . equals ( "1" ) ) { //所有下属
sqlWhere + = " and a.managerstr like '%," + user . getUID ( ) + ",%'" ;
} else {
sqlWhere + = " and a.managerid=" + user . getUID ( ) ; //直接下属
}
}
if ( ! "1" . equals ( isNoAccount ) ) {
sqlWhere + = " and a.loginid is not null " + ( rs . getDBType ( ) . equals ( "oracle" ) ? "" : " and a.loginid<>'' " ) ;
}
//获取加班时长
Map < String , Object > dailyFlowOverTimeData = getDailyFlowOverTimeDataAllowance ( params , user ) ;
bb . writeLog ( "dailyFlowOverTimeData: " + dailyFlowOverTimeData ) ;
String otherstatsub = Util . null2String ( bb . getPropValue ( "project_hostar" , "otherstatsubcompany" ) ) ;
if ( StringUtils . isNotBlank ( otherstatsub ) ) {
//查询该分部下的人员
List < String > resIds = new ArrayList < > ( ) ;
sqlWhere + = " and a.subcompanyid1 not in (" + otherstatsub + ") " ;
String acqResSql = "select a.id from hrmresource a where a.status in (0,1,2,3) " + sqlWhere ;
bb . writeLog ( "acqResSql: " + acqResSql ) ;
rs . executeQuery ( acqResSql ) ;
while ( rs . next ( ) ) {
String id = Util . null2String ( rs . getString ( "id" ) ) ;
if ( StringUtils . isNotBlank ( id ) ) {
resIds . add ( id ) ;
}
}
bb . writeLog ( "resIds: " + resIds ) ;
if ( resIds ! = null & & resIds . size ( ) > 0 & & StringUtils . isNotBlank ( fromDate ) & & StringUtils . isNotBlank ( toDate ) ) {
HostarUtil houtil = new HostarUtil ( ) ;
List < String > allDates = houtil . getAllDates ( fromDate , toDate ) ;
bb . writeLog ( "allDates: " + allDates ) ;
//先获取到出勤时长
Map < String , Double > attendanceMinsMap = new HashMap < > ( ) ;
String acqAttenSql = " select resourceid, attendancemins, kqdate from kq_format_total where resourceid in (" + String . join ( "," , resIds ) + ") and kqdate >='" + fromDate + "' and kqdate <='" + toDate + "'" ;
rs . executeQuery ( acqAttenSql ) ;
while ( rs . next ( ) ) {
String resourceid = Util . null2String ( rs . getString ( "resourceid" ) ) ;
Double attendancemins = Util . getDoubleValue ( Util . null2String ( rs . getString ( "attendancemins" ) ) ) ;
String kqdate = Util . null2String ( rs . getString ( "kqdate" ) ) ;
if ( attendancemins > = 0.00 ) {
attendanceMinsMap . put ( resourceid + "|" + kqdate , attendancemins ) ;
}
}
List < String > removeRes = new ArrayList < > ( ) ;
String acqNoOtherStatAllResSql = "select resourceid from uf_NoOtherStatAllRe where isdelete is null or isdelete = 0 " ;
rs . executeQuery ( acqNoOtherStatAllResSql ) ;
while ( rs . next ( ) ) {
String resourceid = Util . null2String ( rs . getString ( "resourceid" ) ) ;
if ( StringUtils . isNotBlank ( resourceid ) ) {
removeRes . add ( resourceid ) ;
}
}
if ( removeRes ! = null & & removeRes . size ( ) > 0 ) {
resIds . removeIf ( removeRes : : contains ) ;
}
for ( String date : allDates ) {
for ( String res : resIds ) {
//获取考勤打卡
Map < String , Object > otherinfo = new HashMap < > ( ) ; //存一些用得到的信息
String uuid = UUID . randomUUID ( ) . toString ( ) ;
KQTimesArrayComInfo kqTimesArrayComInfo = new KQTimesArrayComInfo ( ) ;
ArrayList < String > hostIps = InitServer . getRealIp ( ) ; //获取IP
boolean oneSign = false ; //一天一段出勤时间段
List < TimeScopeEntity > lsSignTime = new ArrayList < > ( ) ;
List < TimeScopeEntity > lsWorkTime = new ArrayList < > ( ) ;
// List<TimeScopeEntity> lsRestTime = new ArrayList<>();
KQWorkTime kqWorkTime = new KQWorkTime ( ) ;
kqWorkTime . setIsFormat ( true ) ;
WorkTimeEntity workTime = kqWorkTime . getWorkTime ( res , date ) ;
String preDate = DateUtil . addDate ( date , - 1 ) ; //上一天日期
String nextDate = DateUtil . addDate ( date , 1 ) ; //下一天日期
if ( workTime ! = null ) {
lsSignTime = workTime . getSignTime ( ) ; //允许打卡时间
lsWorkTime = workTime . getWorkTime ( ) ; //工作时间
// lsRestTime = workTime.getRestTime();//休息时段时间
oneSign = lsWorkTime ! = null & & lsWorkTime . size ( ) = = 1 ;
}
int shiftCount = lsWorkTime = = null ? 0 : lsWorkTime . size ( ) ;
int shiftI = 0 ;
List < Object > lsCheckInfo = new ArrayList < > ( ) ;
for ( int i = 0 ; lsWorkTime ! = null & & i < lsWorkTime . size ( ) ; i + + ) {
shiftI = i ;
TimeScopeEntity signTimeScope = lsSignTime . get ( i ) ;
TimeScopeEntity workTimeScope = lsWorkTime . get ( i ) ;
Map < String , String > shifRuleMap = Maps . newHashMap ( ) ;
String workBeginTime = Util . null2String ( workTimeScope . getBeginTime ( ) ) ;
int workBeginIdx = kqTimesArrayComInfo . getArrayindexByTimes ( workBeginTime ) ;
String workEndTime = Util . null2String ( workTimeScope . getEndTime ( ) ) ;
int workEndIdx = kqTimesArrayComInfo . getArrayindexByTimes ( workEndTime ) ;
boolean workEndTimeAcross = workTimeScope . getEndTimeAcross ( ) ;
if ( oneSign ) {
//个性化设置只支持一天一次上下班
ShiftInfoBean shiftInfoBean = new ShiftInfoBean ( ) ;
shiftInfoBean . setSplitDate ( date ) ;
shiftInfoBean . setShiftRuleMap ( workTime . getShiftRuleInfo ( ) ) ;
shiftInfoBean . setSignTime ( lsSignTime ) ;
shiftInfoBean . setWorkTime ( lsWorkTime ) ;
List < String > logList = Lists . newArrayList ( ) ;
KQShiftRuleInfoBiz . getShiftRuleInfo ( shiftInfoBean , res , shifRuleMap , logList ) ;
if ( ! shifRuleMap . isEmpty ( ) ) {
if ( ! logList . isEmpty ( ) ) {
otherinfo . put ( "logList" , logList ) ;
}
otherinfo . put ( "shiftRule" , shifRuleMap ) ;
if ( shifRuleMap . containsKey ( "shift_beginworktime" ) ) {
String shift_beginworktime = Util . null2String ( shifRuleMap . get ( "shift_beginworktime" ) ) ;
if ( shift_beginworktime . length ( ) > 0 ) {
workBeginTime = Util . null2String ( shift_beginworktime ) ;
workBeginIdx = kqTimesArrayComInfo . getArrayindexByTimes ( workBeginTime ) ;
workTimeScope . setBeginTime ( workBeginTime ) ;
workTimeScope . setBeginTimeAcross ( workBeginIdx > = 1440 ? true : false ) ;
}
}
if ( shifRuleMap . containsKey ( "shift_endworktime" ) ) {
String shift_endworktime = Util . null2String ( shifRuleMap . get ( "shift_endworktime" ) ) ;
if ( shift_endworktime . length ( ) > 0 ) {
workEndTime = Util . null2String ( shift_endworktime ) ;
workEndIdx = kqTimesArrayComInfo . getArrayindexByTimes ( workEndTime ) ;
workTimeScope . setEndTime ( workEndTime ) ;
workTimeScope . setEndTimeAcross ( workEndIdx > = 1440 ? true : false ) ;
}
}
}
}
lsCheckInfo = new KQFormatSignData ( ) . getSignInfo ( res , signTimeScope , workTimeScope , date , preDate , nextDate , kqTimesArrayComInfo , hostIps , uuid , shiftCount , shiftI ) ;
}
List < String > signIdList = new ArrayList < > ( ) ;
for ( int i = 0 ; i < lsCheckInfo . size ( ) ; i + + ) {
Object o = lsCheckInfo . get ( i ) ;
if ( o ! = null & & o ! = "" ) {
Map < String , Object > temp = ( Map < String , Object > ) o ;
signIdList . add ( Util . null2String ( temp . get ( "signId" ) ) ) ;
}
}
Integer signNumber = 0 ;
String acqShowAddress = "select showaddress from hrmschedulesign where id in (" + String . join ( "," , signIdList ) + ") " ;
bb . writeLog ( "acqShowAddress: " + acqShowAddress ) ;
rs . executeQuery ( acqShowAddress ) ;
while ( rs . next ( ) ) {
String showaddress = Util . null2String ( rs . getString ( "showaddress" ) ) ;
if ( "鸿仕达" . equals ( showaddress ) | | "hostar" . equalsIgnoreCase ( showaddress ) ) {
signNumber = signNumber + 1 ;
}
}
if ( signNumber = = 0 ) {
double workingDayOvertime_4leave = Util . getDoubleValue ( Util . null2String ( dailyFlowOverTimeData . get ( res + "|" + date + "|workingDayOvertime_4leave" ) ) ) ;
workingDayOvertime_4leave = workingDayOvertime_4leave < 0 ? 0 : workingDayOvertime_4leave ;
double restDayOvertime_4leave = Util . getDoubleValue ( Util . null2String ( dailyFlowOverTimeData . get ( res + "|" + date + "|restDayOvertime_4leave" ) ) ) ;
restDayOvertime_4leave = restDayOvertime_4leave < 0 ? 0 : restDayOvertime_4leave ;
double holidayOvertime_4leave = Util . getDoubleValue ( Util . null2String ( dailyFlowOverTimeData . get ( res + "|" + date + "|holidayOvertime_4leave" ) ) ) ;
holidayOvertime_4leave = holidayOvertime_4leave < 0 ? 0 : holidayOvertime_4leave ;
double workingDayOvertime_nonleave = Util . getDoubleValue ( Util . null2String ( dailyFlowOverTimeData . get ( res + "|" + date + "|workingDayOvertime_nonleave" ) ) ) ;
workingDayOvertime_nonleave = workingDayOvertime_nonleave < 0 ? 0 : workingDayOvertime_nonleave ;
double restDayOvertime_nonleave = Util . getDoubleValue ( Util . null2String ( dailyFlowOverTimeData . get ( res + "|" + date + "|restDayOvertime_nonleave" ) ) ) ;
restDayOvertime_nonleave = restDayOvertime_nonleave < 0 ? 0 : restDayOvertime_nonleave ;
double holidayOvertime_nonleave = Util . getDoubleValue ( Util . null2String ( dailyFlowOverTimeData . get ( res + "|" + date + "|holidayOvertime_nonleave" ) ) ) ;
holidayOvertime_nonleave = holidayOvertime_nonleave < 0 ? 0 : holidayOvertime_nonleave ;
double temp = workingDayOvertime_4leave + restDayOvertime_4leave + holidayOvertime_4leave +
workingDayOvertime_nonleave + restDayOvertime_nonleave + holidayOvertime_nonleave ;
bb . writeLog ( "-=-temp:" + temp ) ;
Double attendanceMins = Util . getDoubleValue ( Util . null2String ( attendanceMinsMap . get ( res + "|" + date ) ) ) ;
bb . writeLog ( "-=-attendanceMins:" + attendanceMins ) ;
double v = ( ( attendanceMins < 0.00 ) ? 0.00 : attendanceMins ) + temp ;
String value = "0" ;
if ( v > = 4.00 & & v < 9.00 ) {
value = "1" ;
} else if ( v > = 9.00 ) {
value = "2" ;
}
bb . writeLog ( "-=-value:" + value ) ;
datas . put ( res + "|" + "DailyOtherStatAllowance" + "|" + date , value ) ;
}
}
}
}
}
} catch ( Exception e ) {
writeLog ( e ) ;
bb . writeLog ( "DailyStatAllowance Exception: " + e ) ;
}
bb . writeLog ( "DailyStatAllowance datas: " + datas ) ;
return datas ;
}
/ * *
* 获 取 夜 班 餐 补 数 据
* @param params
* @param user
* @return
* /
public Map < String , Object > getDailyNightShiftAllowanceData ( Map < String , Object > params , User user ) {
Map < String , Object > datas = new HashMap < > ( ) ; ;
RecordSet rs = new RecordSet ( ) ;
String sql = "" ;
String sqlWhere = " " ;
try {
KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo ( ) ;
JSONObject jsonObj = JSON . parseObject ( Util . null2String ( params . get ( "data" ) ) ) ;
String fromDate = Util . null2String ( jsonObj . get ( "fromDate" ) ) ;
String toDate = Util . null2String ( jsonObj . get ( "toDate" ) ) ;
String typeselect = Util . null2String ( jsonObj . get ( "typeselect" ) ) ;
if ( typeselect . length ( ) = = 0 ) typeselect = "3" ;
if ( ! typeselect . equals ( "" ) & & ! typeselect . equals ( "0" ) & & ! typeselect . equals ( "6" ) ) {
if ( typeselect . equals ( "1" ) ) {
fromDate = TimeUtil . getCurrentDateString ( ) ;
toDate = TimeUtil . getCurrentDateString ( ) ;
} else {
fromDate = TimeUtil . getDateByOption ( typeselect , "0" ) ;
toDate = TimeUtil . getDateByOption ( typeselect , "1" ) ;
}
}
String subCompanyId = Util . null2String ( jsonObj . get ( "subCompanyId" ) ) ;
String departmentId = Util . null2String ( jsonObj . get ( "departmentId" ) ) ;
String resourceId = Util . null2String ( jsonObj . get ( "resourceId" ) ) ;
String allLevel = Util . null2String ( jsonObj . get ( "allLevel" ) ) ;
String isNoAccount = Util . null2String ( jsonObj . get ( "isNoAccount" ) ) ;
String viewScope = Util . null2String ( jsonObj . get ( "viewScope" ) ) ;
if ( subCompanyId . length ( ) > 0 ) {
sqlWhere + = " and a.subcompanyid1 in(" + subCompanyId + ") " ;
}
if ( departmentId . length ( ) > 0 ) {
sqlWhere + = " and a.departmentid in(" + departmentId + ") " ;
}
if ( resourceId . length ( ) > 0 ) {
sqlWhere + = " and a.id in(" + resourceId + ") " ;
}
if ( viewScope . equals ( "4" ) ) { //我的下属
if ( allLevel . equals ( "1" ) ) { //所有下属
sqlWhere + = " and a.managerstr like '%," + user . getUID ( ) + ",%'" ;
} else {
sqlWhere + = " and a.managerid=" + user . getUID ( ) ; //直接下属
}
}
if ( ! "1" . equals ( isNoAccount ) ) {
sqlWhere + = " and a.loginid is not null " + ( rs . getDBType ( ) . equals ( "oracle" ) ? "" : " and a.loginid<>'' " ) ;
}
//获取加班时长
Map < String , Object > dailyFlowOverTimeData = getDailyFlowOverTimeDataAllowance ( params , user ) ;
bb . writeLog ( "dailyFlowOverTimeData: " + dailyFlowOverTimeData ) ;
String nightshiftsub = Util . null2String ( bb . getPropValue ( "project_hostar" , "nightshiftsubcompany" ) ) ;
if ( StringUtils . isNotBlank ( nightshiftsub ) ) {
//查询该分部下的人员
List < String > resIds = new ArrayList < > ( ) ;
sqlWhere + = " and a.subcompanyid1 not in (" + nightshiftsub + ") " ;
String acqResSql = "select a.id from hrmresource a where a.status in (0,1,2,3) " + sqlWhere ;
bb . writeLog ( "acqResSql: " + acqResSql ) ;
rs . executeQuery ( acqResSql ) ;
while ( rs . next ( ) ) {
String id = Util . null2String ( rs . getString ( "id" ) ) ;
if ( StringUtils . isNotBlank ( id ) ) {
resIds . add ( id ) ;
}
}
bb . writeLog ( "resIds: " + resIds ) ;
if ( resIds ! = null & & resIds . size ( ) > 0 ) {
HostarUtil houtil = new HostarUtil ( ) ;
List < String > allDates = houtil . getAllDates ( fromDate , toDate ) ;
//先获取到出勤时长
Map < String , Double > attendanceMinsMap = new HashMap < > ( ) ;
String acqAttenSql = " select resourceid, attendancemins, kqdate from kq_format_total where resourceid in (" + String . join ( "," , resIds ) + ") and kqdate >='" + fromDate + "' and kqdate <='" + toDate + "'" ;
rs . executeQuery ( acqAttenSql ) ;
while ( rs . next ( ) ) {
String resourceid = Util . null2String ( rs . getString ( "resourceid" ) ) ;
Double attendancemins = Util . getDoubleValue ( Util . null2String ( rs . getString ( "attendancemins" ) ) ) ;
String kqdate = Util . null2String ( rs . getString ( "kqdate" ) ) ;
if ( attendancemins > = 0.00 ) {
attendanceMinsMap . put ( resourceid + "|" + kqdate , attendancemins ) ;
}
}
for ( String res : resIds ) {
for ( String date : allDates ) {
double workingDayOvertime_4leave = Util . getDoubleValue ( Util . null2String ( dailyFlowOverTimeData . get ( res + "|" + date + "|workingDayOvertime_4leave" ) ) ) ;
workingDayOvertime_4leave = workingDayOvertime_4leave < 0 ? 0 : workingDayOvertime_4leave ;
double restDayOvertime_4leave = Util . getDoubleValue ( Util . null2String ( dailyFlowOverTimeData . get ( res + "|" + date + "|restDayOvertime_4leave" ) ) ) ;
restDayOvertime_4leave = restDayOvertime_4leave < 0 ? 0 : restDayOvertime_4leave ;
double holidayOvertime_4leave = Util . getDoubleValue ( Util . null2String ( dailyFlowOverTimeData . get ( res + "|" + date + "|holidayOvertime_4leave" ) ) ) ;
holidayOvertime_4leave = holidayOvertime_4leave < 0 ? 0 : holidayOvertime_4leave ;
double workingDayOvertime_nonleave = Util . getDoubleValue ( Util . null2String ( dailyFlowOverTimeData . get ( res + "|" + date + "|workingDayOvertime_nonleave" ) ) ) ;
workingDayOvertime_nonleave = workingDayOvertime_nonleave < 0 ? 0 : workingDayOvertime_nonleave ;
double restDayOvertime_nonleave = Util . getDoubleValue ( Util . null2String ( dailyFlowOverTimeData . get ( res + "|" + date + "|restDayOvertime_nonleave" ) ) ) ;
restDayOvertime_nonleave = restDayOvertime_nonleave < 0 ? 0 : restDayOvertime_nonleave ;
double holidayOvertime_nonleave = Util . getDoubleValue ( Util . null2String ( dailyFlowOverTimeData . get ( res + "|" + date + "|holidayOvertime_nonleave" ) ) ) ;
holidayOvertime_nonleave = holidayOvertime_nonleave < 0 ? 0 : holidayOvertime_nonleave ;
double temp = workingDayOvertime_4leave + restDayOvertime_4leave + holidayOvertime_4leave +
workingDayOvertime_nonleave + restDayOvertime_nonleave + holidayOvertime_nonleave ;
bb . writeLog ( "-=-temp:" + temp ) ;
Double attendanceMins = Util . getDoubleValue ( Util . null2String ( attendanceMinsMap . get ( res + "|" + date ) ) ) ;
bb . writeLog ( "-=-attendanceMins:" + attendanceMins ) ;
String value = String . valueOf ( Math . ceil ( ( attendanceMins < 0.00 ? 0.00 : attendanceMins ) + temp ) ) ;
bb . writeLog ( "-=-value:" + value ) ;
datas . put ( res + "|" + "DailyNightShiftAllowanceData" + "|" + date , value ) ;
}
}
}
} else {
bb . writeLog ( "夜班餐补计算失败,没有设置该餐补享受分部" ) ;
}
} catch ( Exception e ) {
writeLog ( e ) ;
bb . writeLog ( "DailyNightShiftAllowanceData Exception: " + e ) ;
}
bb . writeLog ( "DailyNightShiftAllowanceData datas: " + datas ) ;
return datas ;
}
/ * *
* 获 取 驻 点 餐 补 数 据
* @param params
@ -1493,7 +1888,7 @@ public class KQReportBiz extends BaseBean {
}
if ( resourceId . length ( ) > 0 ) {
sqlWhere + = " and a. resource id in("+ resourceId + ") " ;
sqlWhere + = " and a. id in("+ resourceId + ") " ;
}
if ( viewScope . equals ( "4" ) ) { //我的下属
@ -1507,6 +1902,10 @@ public class KQReportBiz extends BaseBean {
sqlWhere + = " and a.loginid is not null " + ( rs . getDBType ( ) . equals ( "oracle" ) ? "" : " and a.loginid<>'' " ) ;
}
//获取加班时长
Map < String , Object > dailyFlowOverTimeData = getDailyFlowOverTimeDataAllowance ( params , user ) ;
bb . writeLog ( "dailyFlowOverTimeData: " + dailyFlowOverTimeData ) ;
//首先去除指定不享有的分部
List < String > subComoanyList = new ArrayList < > ( ) ;
String acqNoStatAllSql = "select subcompany from uf_NoStatAllSubCom where isdelete = 0 or isdelete is null" ;
@ -1517,6 +1916,8 @@ public class KQReportBiz extends BaseBean {
subComoanyList . add ( subcompany ) ;
}
}
bb . writeLog ( "subComoanyList: " + subComoanyList ) ;
String subComoanys = "" ;
if ( subComoanyList ! = null & & subComoanyList . size ( ) > 0 ) {
subComoanys = String . join ( "," , subComoanyList ) ;
@ -1526,7 +1927,9 @@ public class KQReportBiz extends BaseBean {
}
List < String > resIds = new ArrayList < > ( ) ;
String acqResSql = "select id from hrmresource a where a.status in (0,1,2,3) " + sqlWhere ;
String acqResSql = "select a.id from hrmresource a where a.status in (0,1,2,3) " + sqlWhere ;
bb . writeLog ( "acqResSql: " + acqResSql ) ;
rs . executeQuery ( acqResSql ) ;
while ( rs . next ( ) ) {
String id = Util . null2String ( rs . getString ( "id" ) ) ;
@ -1534,10 +1937,26 @@ public class KQReportBiz extends BaseBean {
resIds . add ( id ) ;
}
}
bb . writeLog ( "resIds: " + resIds ) ;
if ( resIds ! = null & & resIds . size ( ) > 0 & & StringUtils . isNotBlank ( fromDate ) & & StringUtils . isNotBlank ( toDate ) ) {
HostarUtil houtil = new HostarUtil ( ) ;
List < String > allDates = houtil . getAllDates ( fromDate , toDate ) ;
bb . writeLog ( "allDates: " + allDates ) ;
//先获取到出勤时长
Map < String , Double > attendanceMinsMap = new HashMap < > ( ) ;
String acqAttenSql = " select resourceid, attendancemins, kqdate from kq_format_total where resourceid in (" + String . join ( "," , resIds ) + ") and kqdate >='" + fromDate + "' and kqdate <='" + toDate + "'" ;
rs . executeQuery ( acqAttenSql ) ;
while ( rs . next ( ) ) {
String resourceid = Util . null2String ( rs . getString ( "resourceid" ) ) ;
Double attendancemins = Util . getDoubleValue ( Util . null2String ( rs . getString ( "attendancemins" ) ) ) ;
String kqdate = Util . null2String ( rs . getString ( "kqdate" ) ) ;
if ( attendancemins > = 0.00 ) {
attendanceMinsMap . put ( resourceid + "|" + kqdate , attendancemins ) ;
}
}
for ( String date : allDates ) {
for ( String res : resIds ) {
//获取考勤打卡
@ -1548,7 +1967,7 @@ public class KQReportBiz extends BaseBean {
boolean oneSign = false ; //一天一段出勤时间段
List < TimeScopeEntity > lsSignTime = new ArrayList < > ( ) ;
List < TimeScopeEntity > lsWorkTime = new ArrayList < > ( ) ;
List < TimeScopeEntity > lsRestTime = new ArrayList < > ( ) ;
// List<TimeScopeEntity> lsRestTime = new ArrayList<>();
KQWorkTime kqWorkTime = new KQWorkTime ( ) ;
kqWorkTime . setIsFormat ( true ) ;
WorkTimeEntity workTime = kqWorkTime . getWorkTime ( res , date ) ;
@ -1557,11 +1976,12 @@ public class KQReportBiz extends BaseBean {
if ( workTime ! = null ) {
lsSignTime = workTime . getSignTime ( ) ; //允许打卡时间
lsWorkTime = workTime . getWorkTime ( ) ; //工作时间
lsRestTime = workTime . getRestTime ( ) ; //休息时段时间
// lsRestTime = workTime.getRestTime();//休息时段时间
oneSign = lsWorkTime ! = null & & lsWorkTime . size ( ) = = 1 ;
}
int shiftCount = lsWorkTime = = null ? 0 : lsWorkTime . size ( ) ;
int shiftI = 0 ;
List < Object > lsCheckInfo = new ArrayList < > ( ) ;
for ( int i = 0 ; lsWorkTime ! = null & & i < lsWorkTime . size ( ) ; i + + ) {
shiftI = i ;
TimeScopeEntity signTimeScope = lsSignTime . get ( i ) ;
@ -1569,17 +1989,17 @@ public class KQReportBiz extends BaseBean {
Map < String , String > shifRuleMap = Maps . newHashMap ( ) ;
String workBeginTime = Util . null2String ( workTimeScope . getBeginTime ( ) ) ;
String ori_workBeginTime = workBeginTime ;
// String ori_workBeginTime = workBeginTime;
int workBeginIdx = kqTimesArrayComInfo . getArrayindexByTimes ( workBeginTime ) ;
boolean workBenginTimeAcross = workTimeScope . getBeginTimeAcross ( ) ;
// boolean workBenginTimeAcross = workTimeScope.getBeginTimeAcross();
String workEndTime = Util . null2String ( workTimeScope . getEndTime ( ) ) ;
String ori_workEndTime = workEndTime ;
// String ori_workEndTime = workEndTime;
int workEndIdx = kqTimesArrayComInfo . getArrayindexByTimes ( workEndTime ) ;
boolean workEndTimeAcross = workTimeScope . getEndTimeAcross ( ) ;
int workMins = workTimeScope . getWorkMins ( ) ;
String workBeginDate = workBenginTimeAcross ? nextDate : date ;
String workEndDate = workEndTimeAcross ? nextDate : date ;
// int workMins = workTimeScope.getWorkMins();
//
// String workBeginDate = workBenginTimeAcross ? nextDate : date;
// String workEndDate = workEndTimeAcross ? nextDate : date;
if ( oneSign ) {
//个性化设置只支持一天一次上下班
@ -1630,20 +2050,60 @@ public class KQReportBiz extends BaseBean {
// signDate = 2023 - 12 - 22,
// signId = 7
//}]
List< Object > lsCheckInfo = new KQFormatSignData ( ) . getSignInfo ( res , signTimeScope , workTimeScope , date , preDate , nextDate , kqTimesArrayComInfo , hostIps , uuid , shiftCount , shiftI ) ;
lsCheckInfo = new KQFormatSignData ( ) . getSignInfo ( res , signTimeScope , workTimeScope , date , preDate , nextDate , kqTimesArrayComInfo , hostIps , uuid , shiftCount , shiftI ) ;
}
List < String > signIdList = new ArrayList < > ( ) ;
for ( int i = 0 ; i < lsCheckInfo . size ( ) ; i + + ) {
Object o = lsCheckInfo . get ( i ) ;
if ( o ! = null & & o ! = "" ) {
Map < String , Object > temp = ( Map < String , Object > ) o ;
signIdList . add ( Util . null2String ( temp . get ( "signId" ) ) ) ;
}
}
Integer signNumber = 0 ;
String acqShowAddress = "select showaddress from hrmschedulesign where id in (" + String . join ( "," , signIdList ) + ") " ;
bb . writeLog ( "acqShowAddress: " + acqShowAddress ) ;
rs . executeQuery ( acqShowAddress ) ;
while ( rs . next ( ) ) {
String showaddress = Util . null2String ( rs . getString ( "showaddress" ) ) ;
if ( "鸿仕达" . equals ( showaddress ) | | "hostar" . equalsIgnoreCase ( showaddress ) ) {
signNumber = signNumber + 1 ;
}
}
if ( signNumber = = 0 ) {
double workingDayOvertime_4leave = Util . getDoubleValue ( Util . null2String ( dailyFlowOverTimeData . get ( res + "|" + date + "|workingDayOvertime_4leave" ) ) ) ;
workingDayOvertime_4leave = workingDayOvertime_4leave < 0 ? 0 : workingDayOvertime_4leave ;
double restDayOvertime_4leave = Util . getDoubleValue ( Util . null2String ( dailyFlowOverTimeData . get ( res + "|" + date + "|restDayOvertime_4leave" ) ) ) ;
restDayOvertime_4leave = restDayOvertime_4leave < 0 ? 0 : restDayOvertime_4leave ;
double holidayOvertime_4leave = Util . getDoubleValue ( Util . null2String ( dailyFlowOverTimeData . get ( res + "|" + date + "|holidayOvertime_4leave" ) ) ) ;
holidayOvertime_4leave = holidayOvertime_4leave < 0 ? 0 : holidayOvertime_4leave ;
double workingDayOvertime_nonleave = Util . getDoubleValue ( Util . null2String ( dailyFlowOverTimeData . get ( res + "|" + date + "|workingDayOvertime_nonleave" ) ) ) ;
workingDayOvertime_nonleave = workingDayOvertime_nonleave < 0 ? 0 : workingDayOvertime_nonleave ;
double restDayOvertime_nonleave = Util . getDoubleValue ( Util . null2String ( dailyFlowOverTimeData . get ( res + "|" + date + "|restDayOvertime_nonleave" ) ) ) ;
restDayOvertime_nonleave = restDayOvertime_nonleave < 0 ? 0 : restDayOvertime_nonleave ;
double holidayOvertime_nonleave = Util . getDoubleValue ( Util . null2String ( dailyFlowOverTimeData . get ( res + "|" + date + "|holidayOvertime_nonleave" ) ) ) ;
holidayOvertime_nonleave = holidayOvertime_nonleave < 0 ? 0 : holidayOvertime_nonleave ;
double temp = workingDayOvertime_4leave + restDayOvertime_4leave + holidayOvertime_4leave +
workingDayOvertime_nonleave + restDayOvertime_nonleave + holidayOvertime_nonleave ;
bb . writeLog ( "-=-temp:" + temp ) ;
Double attendanceMins = Util . getDoubleValue ( Util . null2String ( attendanceMinsMap . get ( res + "|" + date ) ) ) ;
bb . writeLog ( "-=-attendanceMins:" + attendanceMins ) ;
String value = String . valueOf ( Math . ceil ( ( attendanceMins < 0.00 ? 0.00 : attendanceMins ) + temp ) ) ;
bb . writeLog ( "-=-value:" + value ) ;
datas . put ( res + "|" + "DailyStatAllowance" + "|" + date , value ) ;
}
}
}
}
} catch ( Exception e ) {
writeLog ( e ) ;
bb . writeLog ( "DailyStatAllowance Exception: " + e ) ;
}
bb . writeLog ( "DailyStatAllowance datas: " + datas ) ;
return datas ;
}
@ -1959,6 +2419,111 @@ public class KQReportBiz extends BaseBean {
return datas ;
}
/ * *
* 获 取 每 日 加 班 数 据 ( 餐 补 使 用 )
* @return
* /
public Map < String , Object > getDailyFlowOverTimeDataAllowance ( Map < String , Object > params , User user ) {
Map < String , Object > datas = new HashMap < > ( ) ; ;
RecordSet rs = new RecordSet ( ) ;
String sql = "" ;
String sqlWhere = " " ;
try {
KQOvertimeRulesBiz kqOvertimeRulesBiz = new KQOvertimeRulesBiz ( ) ;
JSONObject jsonObj = JSON . parseObject ( Util . null2String ( params . get ( "data" ) ) ) ;
String fromDate = Util . null2String ( jsonObj . get ( "fromDate" ) ) ;
String toDate = Util . null2String ( jsonObj . get ( "toDate" ) ) ;
String typeselect = Util . null2String ( jsonObj . get ( "typeselect" ) ) ;
if ( typeselect . length ( ) = = 0 ) typeselect = "3" ;
if ( ! typeselect . equals ( "" ) & & ! typeselect . equals ( "0" ) & & ! typeselect . equals ( "6" ) ) {
if ( typeselect . equals ( "1" ) ) {
fromDate = TimeUtil . getCurrentDateString ( ) ;
toDate = TimeUtil . getCurrentDateString ( ) ;
} else {
fromDate = TimeUtil . getDateByOption ( typeselect , "0" ) ;
toDate = TimeUtil . getDateByOption ( typeselect , "1" ) ;
}
}
String subCompanyId = Util . null2String ( jsonObj . get ( "subCompanyId" ) ) ;
String departmentId = Util . null2String ( jsonObj . get ( "departmentId" ) ) ;
String resourceId = Util . null2String ( jsonObj . get ( "resourceId" ) ) ;
String allLevel = Util . null2String ( jsonObj . get ( "allLevel" ) ) ;
String isNoAccount = Util . null2String ( jsonObj . get ( "isNoAccount" ) ) ;
String viewScope = Util . null2String ( jsonObj . get ( "viewScope" ) ) ;
if ( subCompanyId . length ( ) > 0 ) {
sqlWhere + = " and a.subcompanyid1 in(" + subCompanyId + ") " ;
}
if ( departmentId . length ( ) > 0 ) {
sqlWhere + = " and a.departmentid in(" + departmentId + ") " ;
}
if ( resourceId . length ( ) > 0 ) {
sqlWhere + = " and a.id in(" + resourceId + ") " ;
}
if ( viewScope . equals ( "4" ) ) { //我的下属
if ( allLevel . equals ( "1" ) ) { //所有下属
sqlWhere + = " and a.managerstr like '%," + user . getUID ( ) + ",%'" ;
} else {
sqlWhere + = " and a.managerid=" + user . getUID ( ) ; //直接下属
}
}
if ( ! "1" . equals ( isNoAccount ) ) {
sqlWhere + = " and a.loginid is not null " + ( rs . getDBType ( ) . equals ( "oracle" ) ? "" : " and a.loginid<>'' " ) ;
}
int uintType = kqOvertimeRulesBiz . getMinimumUnit ( ) ; //当前加班单位
double hoursToDay = kqOvertimeRulesBiz . getHoursToDay ( ) ; //当前天跟小时计算关系
String valueField = "" ;
if ( uintType = = 3 | | uintType = = 5 | | uintType = = 6 ) { //按小时计算
valueField = "sum( case when durationrule='3' then duration else duration*" + hoursToDay + " end) as val" ;
} else { //按天计算
valueField = "sum( case when durationrule='3' then duration/" + hoursToDay + " else duration end) as val" ;
}
sql = " select resourceid,changeType,belongdate,paidLeaveEnable, sum(cast(duration_min as decimal(18,4))) as val " +
" from hrmresource a, kq_flow_overtime b " +
" where a.id = b.resourceid and belongdate >='" + fromDate + "' and belongdate <='" + toDate + "' " + sqlWhere +
" group by resourceid,changeType,paidLeaveEnable,belongdate " ;
rs . execute ( sql ) ;
while ( rs . next ( ) ) {
String resourceid = rs . getString ( "resourceid" ) ;
String belongdate = rs . getString ( "belongdate" ) ;
String paidLeaveEnable = rs . getString ( "paidLeaveEnable" ) ;
int changeType = rs . getInt ( "changeType" ) ; //1-节假日、2-工作日、3-休息日
double value = rs . getDouble ( "val" ) < 0 ? 0 : rs . getDouble ( "val" ) ;
if ( uintType = = 3 | | uintType = = 5 | | uintType = = 6 ) { //按小时计算
value = Util . getDoubleValue ( KQDurationCalculatorUtil . getDurationRound ( value + "" ) ) ;
} else { //按天计算
value = Util . getDoubleValue ( KQDurationCalculatorUtil . getDurationRound ( value + "" ) ) ;
}
String flowType = "" ;
if ( changeType = = 1 ) {
flowType = "holidayOvertime" ;
} else if ( changeType = = 2 ) {
flowType = "workingDayOvertime" ;
} else if ( changeType = = 3 ) {
flowType = "restDayOvertime" ;
}
if ( "1" . equalsIgnoreCase ( paidLeaveEnable ) ) {
//1表示关联调休
flowType + = "_4leave" ;
} else {
//0表示不关联调休
flowType + = "_nonleave" ;
}
//df.format 默认是不四舍五入的 0.125这样的就会直接变成0.12了
df . setMaximumFractionDigits ( 5 ) ;
datas . put ( resourceid + "|" + belongdate + "|" + flowType , format ( value ) ) ;
}
} catch ( Exception e ) {
writeLog ( e ) ;
}
return datas ;
}
/ * *
* 异 常 冲 抵
* @return