package com.engine.hostar.thread ;
import com.alibaba.fastjson.JSONObject ;
import com.engine.hostar.util.HostarUtil ;
import com.engine.kq.biz.KQFormatSignData ;
import com.engine.kq.biz.KQGroupMemberComInfo ;
import com.engine.kq.biz.KQLeaveRulesComInfo ;
import com.engine.kq.biz.KQOvertimeRulesBiz ;
import com.engine.kq.biz.KQShiftRuleInfoBiz ;
import com.engine.kq.biz.KQTimesArrayComInfo ;
import com.engine.kq.biz.KQWorkTime ;
import com.engine.kq.biz.chain.shiftinfo.ShiftInfoBean ;
import com.engine.kq.cmd.shiftmanagement.toolkit.ShiftManagementToolKit ;
import com.engine.kq.entity.TimeScopeEntity ;
import com.engine.kq.entity.WorkTimeEntity ;
import com.engine.kq.util.KQDurationCalculatorUtil ;
import com.google.common.collect.Lists ;
import com.google.common.collect.Maps ;
import org.apache.commons.lang3.StringUtils ;
import org.springframework.util.CollectionUtils ;
import weaver.conn.RecordSet ;
import weaver.formmode.setup.ModeRightInfo ;
import weaver.general.BaseBean ;
import weaver.general.InitServer ;
import weaver.general.Util ;
import java.text.DecimalFormat ;
import java.text.DecimalFormatSymbols ;
import java.text.SimpleDateFormat ;
import java.time.LocalDate ;
import java.time.LocalTime ;
import java.time.format.DateTimeFormatter ;
import java.util.ArrayList ;
import java.util.Arrays ;
import java.util.Date ;
import java.util.HashMap ;
import java.util.HashSet ;
import java.util.List ;
import java.util.Map ;
import java.util.Objects ;
import java.util.Set ;
import java.util.UUID ;
/ * *
* @version 1.0
* @Title ecology - 9
* @Company 泛 微 软 件
* @CreateDate 2024 / 3 / 12
* @Description 处 理 餐 补 数 据
* @Author AdminZm
* /
public class HandleCBDataThread extends BaseBean implements Runnable {
BaseBean baseBean = new BaseBean ( ) ;
private String userId ;
private String kqDate ;
private Set < String > zrzbcSet ;
private Set < String > pbzbcSet ;
private List < String > removeRes ;
private List < String > nightShiftList ;
private List < String > noRes ;
private static DecimalFormat df = new DecimalFormat ( "0.00" ) ;
private DecimalFormatSymbols symbols = new DecimalFormatSymbols ( ) ;
// public HandleCBDataThread(String userId, String kqDate) {
// this.userId = userId;
// this.kqDate = kqDate;
// }
public HandleCBDataThread ( String userId , String kqDate , Set < String > zrzbcSet , Set < String > pbzbcSet , List < String > removeRes ,
List < String > nightShiftList , List < String > noRes ) {
this . userId = userId ;
this . kqDate = kqDate ;
this . zrzbcSet = zrzbcSet ;
this . pbzbcSet = pbzbcSet ;
this . removeRes = removeRes ;
this . nightShiftList = nightShiftList ;
this . noRes = noRes ;
}
@Override
public void run ( ) {
baseBean . writeLog ( "HandleCBDataThread:" + userId + "、" + kqDate ) ;
try {
RecordSet rs = new RecordSet ( ) ;
// 判断该条数据是否人工调整,是人工调整则不更新
int cnt = 0 ;
rs . executeQuery ( "SELECT count(*) as cnt FROM uf_cbxxjlb where xm = ? and rq = ? and sfrgdz = 0" , userId , kqDate ) ;
if ( rs . next ( ) ) {
cnt = rs . getInt ( "cnt" ) ;
}
if ( cnt > 0 ) {
return ;
}
// 判断是否关账, 关账则不更新
int userSubCompany1 = 0 ;
int userDepartment = 0 ;
if ( userSubCompany1 < = 0 | | userDepartment < = 0 ) {
rs . execute ( "select departmentid, subcompanyid1 from hrmresource where id = " + userId ) ;
if ( rs . next ( ) ) {
userSubCompany1 = rs . getInt ( "subcompanyid1" ) ;
userDepartment = rs . getInt ( "departmentid" ) ;
}
}
String gzSql = "select count(*) as cnt from uf_kqfz where (','+CAST(bm AS varchar(max))+',' like '%,'+CAST(" + userDepartment + " AS varchar(10))+',%' " +
"or ','+CAST(fb AS varchar(max))+',' like '%,'+CAST(" + userSubCompany1 + " AS varchar(10))+',%') and fczt = 1 and fzksrq <= '" + kqDate + "' and fzjsrq >= '" + kqDate + "'" ;
rs . execute ( gzSql ) ;
int cntTemp = 0 ;
if ( rs . next ( ) ) {
cntTemp = rs . getInt ( "cnt" ) ;
}
if ( cntTemp > 0 ) {
return ;
}
//获取加班时长
Map < String , Object > dailyFlowOverTimeData = getDailyFlowOverTimeDataAllowance ( userId , kqDate ) ;
baseBean . writeLog ( "HandleCBDataThread dailyFlowOverTimeData:" + JSONObject . toJSONString ( dailyFlowOverTimeData ) ) ;
KQGroupMemberComInfo kqGroupMemberComInfo = new KQGroupMemberComInfo ( ) ;
//先获取到实际打卡时长
Map < String , Double > signminsMap = new HashMap < > ( ) ;
Map < String , Double > attendanceMinsMap = new HashMap < > ( ) ;
String acqAttenSql = " select resourceid, attendancemins, kqdate,signmins from kq_format_total where resourceid in (" + userId + ") and kqdate >='" + kqDate + "' and kqdate <='" + kqDate + "'" ;
rs . executeQuery ( acqAttenSql ) ;
while ( rs . next ( ) ) {
String resourceid = Util . null2String ( rs . getString ( "resourceid" ) ) ;
Double attendancemins = Util . getDoubleValue ( Util . null2String ( rs . getString ( "attendancemins" ) ) ) ;
Double signmins = Util . getDoubleValue ( Util . null2String ( rs . getString ( "signmins" ) ) ) ;
String kqdate = Util . null2String ( rs . getString ( "kqdate" ) ) ;
if ( signmins > = 0.00 ) {
signminsMap . put ( resourceid + "|" + kqdate , signmins ) ;
}
if ( attendancemins > = 0.00 ) {
attendanceMinsMap . put ( resourceid + "|" + kqdate , attendancemins ) ;
}
}
String groupId = kqGroupMemberComInfo . getKQGroupId ( userId , kqDate ) ;
// 获取考勤二开--夜班补助
String nightShiftSubsidy = getNightShiftSubsidy ( userId , kqDate , nightShiftList , dailyFlowOverTimeData , signminsMap , attendanceMinsMap ,
groupId , zrzbcSet , pbzbcSet ) ;
baseBean . writeLog ( "nightShiftSubsidy:" + nightShiftSubsidy ) ;
if ( StringUtils . isEmpty ( nightShiftSubsidy ) ) {
nightShiftSubsidy = "0" ;
}
// 获取考勤二开--鸿仁驻点餐补
String otherStatAllowance = getOtherStatAllowance ( userId , kqDate , dailyFlowOverTimeData , signminsMap , attendanceMinsMap , removeRes ) ;
baseBean . writeLog ( "otherStatAllowance:" + otherStatAllowance ) ;
if ( StringUtils . isEmpty ( otherStatAllowance ) ) {
otherStatAllowance = "0" ;
}
// 考勤二开--精密夜班餐补
String nightAllowance = getNightAllowance ( userId , kqDate , dailyFlowOverTimeData , signminsMap , attendanceMinsMap , nightShiftList ) ;
baseBean . writeLog ( "nightAllowance:" + nightAllowance ) ;
if ( StringUtils . isEmpty ( nightAllowance ) ) {
nightAllowance = "0" ;
}
// 考勤二开--驻点餐补
String statAllowance = getStatAllowance ( userId , kqDate , dailyFlowOverTimeData , signminsMap , attendanceMinsMap , noRes ) ;
baseBean . writeLog ( "statAllowance:" + statAllowance ) ;
if ( StringUtils . isEmpty ( statAllowance ) ) {
statAllowance = "0" ;
}
// 考勤二开--出差餐补
String mealAllowance = getMealAllowance ( userId , kqDate ) ;
if ( ! ( StringUtils . equals ( statAllowance , "0" ) & & StringUtils . equals ( otherStatAllowance , "0" ) ) ) {
mealAllowance = "0" ;
}
baseBean . writeLog ( "mealAllowance:" + mealAllowance ) ;
if ( StringUtils . isEmpty ( mealAllowance ) ) {
mealAllowance = "0" ;
}
// 考勤二开--零点补助
String zeropoint = getZeroBt ( userId , kqDate , nightShiftList ) ;
baseBean . writeLog ( "zeropoint:" + zeropoint ) ;
if ( StringUtils . isEmpty ( zeropoint ) ) {
zeropoint = "0" ;
}
// 考勤二开--夜班餐补_白班
String ybcbbb = getNightShiftSubsidyBb ( userId , kqDate , nightShiftList , dailyFlowOverTimeData , signminsMap , attendanceMinsMap ,
groupId , zrzbcSet , pbzbcSet ) ;
baseBean . writeLog ( "ybcbbb:" + ybcbbb ) ;
if ( StringUtils . isEmpty ( ybcbbb ) ) {
ybcbbb = "0" ;
}
rs . executeQuery ( "select id from uf_cbxxjlb where xm = ? and rq = ?" , userId , kqDate ) ;
RecordSet rs1 = new RecordSet ( ) ;
String cbxxjlModeId = rs1 . getPropValue ( "hostar_zm_prop" , "cbxxjl_modeid" ) ;
if ( rs . next ( ) ) {
int cbxxjlId = rs . getInt ( "id" ) ;
SimpleDateFormat dtFormat = new SimpleDateFormat ( "yyyy-MM-dd HH:mm:ss" ) ; //设置日期格式
String nowDateTime = dtFormat . format ( new Date ( ) ) ;
rs1 . executeUpdate ( "update uf_cbxxjlb set hrzdcb = ?, jmybcb = ?, zdcb = ?, ybbz = ?, cccb = ?, ldbz = ?, ybcbbb = ?, modedatamodifydatetime = ? where id = ?" ,
otherStatAllowance , nightAllowance , statAllowance , nightShiftSubsidy , mealAllowance , zeropoint , ybcbbb , nowDateTime , cbxxjlId ) ;
//权限重构
ModeRightInfo ModeRightInfo = new ModeRightInfo ( ) ;
ModeRightInfo . setNewRight ( true ) ;
ModeRightInfo . editModeDataShare ( 1 , Integer . parseInt ( cbxxjlModeId ) , cbxxjlId ) ;
} else {
String uuidT = UUID . randomUUID ( ) . toString ( ) ;
SimpleDateFormat sdfDate = new SimpleDateFormat ( "yyyy-MM-dd" ) ; //设置日期格式
SimpleDateFormat sdfTime = new SimpleDateFormat ( "HH:mm:ss" ) ; //设置日期格式
String nowDate = sdfDate . format ( new Date ( ) ) ;
String nowTime = sdfTime . format ( new Date ( ) ) ;
String gh = null ;
String bm = null ;
rs1 . executeQuery ( "SELECT workcode, departmentid from hrmresource where id = ?" , userId ) ;
if ( rs1 . next ( ) ) {
gh = rs1 . getString ( "workcode" ) ;
bm = rs1 . getString ( "departmentid" ) ;
}
rs1 . executeUpdate ( "insert into uf_cbxxjlb (xm, rq, gh, bm, hrzdcb, jmybcb, zdcb, ybbz, cccb, ldbz, ybcbbb, formmodeid, MODEUUID, " +
"modedatacreater, modedatacreatertype, modedatacreatedate, modedatacreatetime) values(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? ,? ,?, ?, ?)" ,
userId , kqDate , gh , bm , otherStatAllowance , nightAllowance , statAllowance , nightShiftSubsidy , mealAllowance , zeropoint , ybcbbb , cbxxjlModeId , uuidT , "1" , "0" , nowDate , nowTime ) ;
RecordSet qxcgRs = new RecordSet ( ) ;
qxcgRs . execute ( "select id from uf_cbxxjlb where MODEUUID = '" + uuidT + "'" ) ;
Integer idT = 0 ;
while ( qxcgRs . next ( ) ) {
idT = qxcgRs . getInt ( "id" ) ;
}
//权限重构
ModeRightInfo ModeRightInfo = new ModeRightInfo ( ) ;
ModeRightInfo . setNewRight ( true ) ;
ModeRightInfo . editModeDataShare ( 1 , Integer . parseInt ( cbxxjlModeId ) , idT ) ;
}
} catch ( Exception e ) {
baseBean . writeLog ( "HandleCBDataThread error:" + e . getMessage ( ) ) ;
}
}
public Map < String , Object > getDailyFlowOverTimeDataAllowance ( String userId , String kqDate ) {
BaseBean bb = new BaseBean ( ) ;
Map < String , Object > datas = new HashMap < > ( ) ; ;
RecordSet rs = new RecordSet ( ) ;
String sql = "" ;
String sqlWhere = " " ;
try {
if ( userId . length ( ) > 0 ) {
sqlWhere + = " and a.id in(" + userId + ") " ;
}
KQOvertimeRulesBiz kqOvertimeRulesBiz = new KQOvertimeRulesBiz ( ) ;
int uintType = kqOvertimeRulesBiz . getMinimumUnit ( ) ; //当前加班单位
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 >='" + kqDate + "' and belongdate <='" + kqDate + "' " + 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了
symbols . setDecimalSeparator ( '.' ) ;
df . setMaximumFractionDigits ( 5 ) ;
df . setDecimalFormatSymbols ( symbols ) ;
datas . put ( resourceid + "|" + belongdate + "|" + flowType , df . format ( value ) ) ;
}
} catch ( Exception e ) {
bb . writeLog ( "getDailyFlowOverTimeDataAllowance error:" + e . getMessage ( ) ) ;
}
return datas ;
}
public String getZeroBt ( String userId , String kqDate , List < String > nightShiftList ) {
BaseBean bb = new BaseBean ( ) ;
RecordSet rs = new RecordSet ( ) ;
String value = "0" ;
try {
//获取当天班次
KQWorkTime kqWorkTime = new KQWorkTime ( ) ;
WorkTimeEntity workTime = kqWorkTime . getWorkTime ( userId , kqDate ) ;
String bc = workTime . getSerialId ( ) ;
if ( StringUtils . isEmpty ( bc ) ) {
return value ;
}
int serialid = Integer . parseInt ( bc ) ;
if ( serialid > 0 ) {
if ( ( ! CollectionUtils . isEmpty ( nightShiftList ) ) & & nightShiftList . contains ( String . valueOf ( serialid ) ) ) {
value = "0" ;
} else {
rs . executeQuery ( "select zeropoint from kq_format_total where resourceid = ? and kqdate = ?" , userId , kqDate ) ;
if ( rs . next ( ) ) {
value = rs . getString ( "zeropoint" ) ;
}
}
} else {
value = "0" ;
}
} catch ( Exception e ) {
bb . writeLog ( "get ZeroBt error:" + e . getMessage ( ) ) ;
}
return value ;
}
public String getNightShiftSubsidy ( String userId , String kqDate , List < String > nightShiftList , Map < String , Object > dailyFlowOverTimeData ,
Map < String , Double > signminsMap , Map < String , Double > attendanceMinsMap , String groupId ,
Set < String > zrzbcSet , Set < String > pbzbcSet ) {
BaseBean bb = new BaseBean ( ) ;
String value = "" ;
try {
if ( nightShiftList ! = null & nightShiftList . size ( ) > 0 ) {
KQWorkTime kqWorkTime = new KQWorkTime ( ) ;
WorkTimeEntity workTime = kqWorkTime . getWorkTime ( userId , kqDate ) ;
String bc = workTime . getSerialId ( ) ;
if ( StringUtils . isEmpty ( bc ) ) {
return "0" ;
}
int serialid = Integer . parseInt ( bc ) ;
bb . writeLog ( "getNightShiftSubsidy serialid:" + serialid ) ;
if ( serialid > 0 ) {
if ( ! nightShiftList . contains ( String . valueOf ( serialid ) ) ) {
return "0" ;
}
} else {
return "0" ;
}
bb . writeLog ( "getNightShiftSubsidy groupId:" + groupId ) ;
if ( ( ! CollectionUtils . isEmpty ( pbzbcSet ) ) & & pbzbcSet . contains ( groupId ) ) {
double workingDayOvertime_4leave = Util . getDoubleValue ( Util . null2String ( dailyFlowOverTimeData . get ( userId + "|" + kqDate + "|workingDayOvertime_4leave" ) ) ) ;
workingDayOvertime_4leave = workingDayOvertime_4leave < 0 ? 0 : workingDayOvertime_4leave ;
double restDayOvertime_4leave = Util . getDoubleValue ( Util . null2String ( dailyFlowOverTimeData . get ( userId + "|" + kqDate + "|restDayOvertime_4leave" ) ) ) ;
restDayOvertime_4leave = restDayOvertime_4leave < 0 ? 0 : restDayOvertime_4leave ;
double holidayOvertime_4leave = Util . getDoubleValue ( Util . null2String ( dailyFlowOverTimeData . get ( userId + "|" + kqDate + "|holidayOvertime_4leave" ) ) ) ;
holidayOvertime_4leave = holidayOvertime_4leave < 0 ? 0 : holidayOvertime_4leave ;
double workingDayOvertime_nonleave = Util . getDoubleValue ( Util . null2String ( dailyFlowOverTimeData . get ( userId + "|" + kqDate + "|workingDayOvertime_nonleave" ) ) ) ;
workingDayOvertime_nonleave = workingDayOvertime_nonleave < 0 ? 0 : workingDayOvertime_nonleave ;
double restDayOvertime_nonleave = Util . getDoubleValue ( Util . null2String ( dailyFlowOverTimeData . get ( userId + "|" + kqDate + "|restDayOvertime_nonleave" ) ) ) ;
restDayOvertime_nonleave = restDayOvertime_nonleave < 0 ? 0 : restDayOvertime_nonleave ;
double holidayOvertime_nonleave = Util . getDoubleValue ( Util . null2String ( dailyFlowOverTimeData . get ( userId + "|" + kqDate + "|holidayOvertime_nonleave" ) ) ) ;
holidayOvertime_nonleave = holidayOvertime_nonleave < 0 ? 0 : holidayOvertime_nonleave ;
double temp = workingDayOvertime_4leave + restDayOvertime_4leave + holidayOvertime_4leave +
workingDayOvertime_nonleave + restDayOvertime_nonleave + holidayOvertime_nonleave ;
Double attendanceMins = Util . getDoubleValue ( Util . null2String ( attendanceMinsMap . get ( userId + "|" + kqDate ) ) ) ;
value = ( Math . floor ( ( ( attendanceMins < 0.00 ? 0.00 : attendanceMins ) + temp ) / 60 ) > = 8.00 ) ? "1" : "0" ;
}
if ( ( ! CollectionUtils . isEmpty ( zrzbcSet ) ) & & zrzbcSet . contains ( groupId ) ) {
Double signmins = Util . getDoubleValue ( Util . null2String ( signminsMap . get ( userId + "|" + kqDate ) ) ) ;
value = ( ( signmins / 60 ) > = 9.00 ) ? "1" : "0" ;
}
}
} catch ( Exception e ) {
bb . writeLog ( "get NightShiftSubsidy error:" + e . getMessage ( ) ) ;
}
return value ;
}
public String getNightShiftSubsidyBb ( String userId , String kqDate , List < String > nightShiftList , Map < String , Object > dailyFlowOverTimeData ,
Map < String , Double > signminsMap , Map < String , Double > attendanceMinsMap , String groupId ,
Set < String > zrzbcSet , Set < String > pbzbcSet ) {
BaseBean bb = new BaseBean ( ) ;
String value = "" ;
try {
KQWorkTime kqWorkTime = new KQWorkTime ( ) ;
WorkTimeEntity workTime = kqWorkTime . getWorkTime ( userId , kqDate ) ;
String bc = workTime . getSerialId ( ) ;
if ( StringUtils . isEmpty ( bc ) ) {
return "0" ;
}
int serialid = Integer . parseInt ( bc ) ;
bb . writeLog ( "getNightShiftSubsidyBb serialid:" + serialid ) ;
if ( serialid < = 0 ) {
return "0" ;
}
if ( CollectionUtils . isEmpty ( nightShiftList ) | | ! nightShiftList . contains ( String . valueOf ( serialid ) ) ) {
if ( ( ! CollectionUtils . isEmpty ( pbzbcSet ) ) & & pbzbcSet . contains ( groupId ) ) {
double workingDayOvertime_4leave = Util . getDoubleValue ( Util . null2String ( dailyFlowOverTimeData . get ( userId + "|" + kqDate + "|workingDayOvertime_4leave" ) ) ) ;
workingDayOvertime_4leave = workingDayOvertime_4leave < 0 ? 0 : workingDayOvertime_4leave ;
double restDayOvertime_4leave = Util . getDoubleValue ( Util . null2String ( dailyFlowOverTimeData . get ( userId + "|" + kqDate + "|restDayOvertime_4leave" ) ) ) ;
restDayOvertime_4leave = restDayOvertime_4leave < 0 ? 0 : restDayOvertime_4leave ;
double holidayOvertime_4leave = Util . getDoubleValue ( Util . null2String ( dailyFlowOverTimeData . get ( userId + "|" + kqDate + "|holidayOvertime_4leave" ) ) ) ;
holidayOvertime_4leave = holidayOvertime_4leave < 0 ? 0 : holidayOvertime_4leave ;
double workingDayOvertime_nonleave = Util . getDoubleValue ( Util . null2String ( dailyFlowOverTimeData . get ( userId + "|" + kqDate + "|workingDayOvertime_nonleave" ) ) ) ;
workingDayOvertime_nonleave = workingDayOvertime_nonleave < 0 ? 0 : workingDayOvertime_nonleave ;
double restDayOvertime_nonleave = Util . getDoubleValue ( Util . null2String ( dailyFlowOverTimeData . get ( userId + "|" + kqDate + "|restDayOvertime_nonleave" ) ) ) ;
restDayOvertime_nonleave = restDayOvertime_nonleave < 0 ? 0 : restDayOvertime_nonleave ;
double holidayOvertime_nonleave = Util . getDoubleValue ( Util . null2String ( dailyFlowOverTimeData . get ( userId + "|" + kqDate + "|holidayOvertime_nonleave" ) ) ) ;
holidayOvertime_nonleave = holidayOvertime_nonleave < 0 ? 0 : holidayOvertime_nonleave ;
double temp = workingDayOvertime_4leave + restDayOvertime_4leave + holidayOvertime_4leave +
workingDayOvertime_nonleave + restDayOvertime_nonleave + holidayOvertime_nonleave ;
Double attendanceMins = Util . getDoubleValue ( Util . null2String ( attendanceMinsMap . get ( userId + "|" + kqDate ) ) ) ;
RecordSet rs = new RecordSet ( ) ;
String appointBc = rs . getPropValue ( "hostar_zm_prop" , "night_shift_appoint_bc" ) ;
double floor = Math . floor ( ( ( attendanceMins < 0.00 ? 0.00 : attendanceMins ) + temp ) / 60 ) ;
if ( StringUtils . isEmpty ( appointBc ) ) {
if ( floor > = 19.00 ) {
value = "2" ;
}
if ( floor < 19.00 & & floor > = 14.00 ) {
value = "1" ;
}
} else {
List < String > appointBcList = Arrays . asList ( appointBc . split ( "," ) ) ;
if ( appointBcList . contains ( bc ) ) {
if ( floor > = 15.00 ) {
value = "2" ;
}
if ( floor < 15.00 & & floor > = 10.00 ) {
value = "1" ;
}
} else {
ShiftManagementToolKit shiftManagementToolKit = new ShiftManagementToolKit ( ) ;
String shiftOnOffWorkSections = shiftManagementToolKit . getShiftOnOffWorkSections ( bc , 7 ) ;
if ( StringUtils . isEmpty ( shiftOnOffWorkSections ) | | ! shiftOnOffWorkSections . contains ( "夜班" ) ) {
if ( floor > = 19.00 ) {
value = "2" ;
}
if ( floor < 19.00 & & floor > = 14.00 ) {
value = "1" ;
}
}
}
}
}
}
} catch ( Exception e ) {
bb . writeLog ( "get getNightShiftSubsidyBb error:" + e . getMessage ( ) ) ;
}
return value ;
}
public String getOtherStatAllowance ( String userId , String kqDate , Map < String , Object > dailyFlowOverTimeData , Map < String , Double > signminsMap ,
Map < String , Double > attendanceMinsMap , List < String > removeRes ) {
BaseBean bb = new BaseBean ( ) ;
RecordSet rs = new RecordSet ( ) ;
String value = "" ;
String sqlWhere = " " ;
try {
if ( userId . length ( ) > 0 ) {
sqlWhere + = " and a.id in(" + userId + ") " ;
}
String otherstatsub = Util . null2String ( bb . getPropValue ( "project_hostar" , "otherstatsubcompany" ) ) ;
if ( StringUtils . isNotBlank ( otherstatsub ) ) {
//查询该分部下的人员
List < String > resIds = new ArrayList < > ( ) ;
sqlWhere + = " and a.subcompanyid1 in (" + otherstatsub + ") " ;
String acqResSql = "select a.id from hrmresource a where 1=1 " + 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 ) ;
}
}
KQGroupMemberComInfo kqGroupMemberComInfo = new KQGroupMemberComInfo ( ) ;
if ( resIds ! = null & & resIds . size ( ) > 0 & & StringUtils . isNotBlank ( kqDate ) ) {
if ( removeRes ! = null & & removeRes . size ( ) > 0 ) {
resIds . removeIf ( removeRes : : contains ) ;
}
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 , kqDate ) ;
String preDate = weaver . common . DateUtil . addDate ( kqDate , - 1 ) ; //上一天日期
String nextDate = weaver . common . DateUtil . addDate ( kqDate , 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 ( kqDate ) ;
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 , kqDate , 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 ;
String signId = Util . null2String ( temp . get ( "signId" ) ) ;
if ( StringUtils . isNotBlank ( signId ) ) {
signIdList . add ( signId ) ;
}
}
}
Integer signNumber = 0 ;
if ( signIdList ! = null & & signIdList . size ( ) > 0 ) {
String acqShowAddress = "select showaddress,addr,signfrom 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" ) ) ;
String signfrom = Util . null2String ( rs . getString ( "signfrom" ) ) ;
if ( StringUtils . isEmpty ( signfrom ) | | ! StringUtils . equals ( signfrom , "e9mobile" ) ) {
signNumber = signNumber + 1 ;
}
String addr = Util . null2String ( rs . getString ( "addr" ) ) ;
if ( "鸿仕达" . equals ( showaddress ) | | "hostar" . equalsIgnoreCase ( showaddress ) | | "鸿仕达" . equals ( addr ) | | "hostar" . equalsIgnoreCase ( addr ) ) {
signNumber = signNumber + 1 ;
}
if ( StringUtils . isNotEmpty ( showaddress ) & & ( showaddress . contains ( "鸿仕达" ) | | showaddress . toLowerCase ( ) . contains ( "hostar" ) ) ) {
signNumber = signNumber + 1 ;
}
if ( StringUtils . isNotEmpty ( addr ) & & ( addr . contains ( "鸿仕达" ) | | addr . toLowerCase ( ) . contains ( "hostar" ) ) ) {
signNumber = signNumber + 1 ;
}
if ( StringUtils . isNotEmpty ( showaddress ) & & ( showaddress . contains ( "台湾" ) | | showaddress . contains ( "越南" )
| | showaddress . toLowerCase ( ) . contains ( "hostar" ) | | showaddress . toLowerCase ( ) . contains ( "vinh" ) | | showaddress . toLowerCase ( ) . contains ( "ha noi" ) ) ) {
signNumber = signNumber + 1 ;
}
if ( StringUtils . isNotEmpty ( addr ) & & ( addr . contains ( "台湾" ) | | addr . contains ( "越南" )
| | addr . toLowerCase ( ) . contains ( "hostar" ) | | addr . toLowerCase ( ) . contains ( "vinh" ) | | addr . toLowerCase ( ) . contains ( "ha noi" ) ) ) {
signNumber = signNumber + 1 ;
}
}
}
String groupId = kqGroupMemberComInfo . getKQGroupId ( res , kqDate ) ;
if ( signNumber = = 0 ) {
double minValue = 0.00 ;
// if ((!CollectionUtils.isEmpty(pbzbcSet)) && pbzbcSet.contains(groupId)) {
double workingDayOvertime_4leave = Util . getDoubleValue ( Util . null2String ( dailyFlowOverTimeData . get ( res + "|" + kqDate + "|workingDayOvertime_4leave" ) ) ) ;
workingDayOvertime_4leave = workingDayOvertime_4leave < 0 ? 0 : workingDayOvertime_4leave ;
double restDayOvertime_4leave = Util . getDoubleValue ( Util . null2String ( dailyFlowOverTimeData . get ( res + "|" + kqDate + "|restDayOvertime_4leave" ) ) ) ;
restDayOvertime_4leave = restDayOvertime_4leave < 0 ? 0 : restDayOvertime_4leave ;
double holidayOvertime_4leave = Util . getDoubleValue ( Util . null2String ( dailyFlowOverTimeData . get ( res + "|" + kqDate + "|holidayOvertime_4leave" ) ) ) ;
holidayOvertime_4leave = holidayOvertime_4leave < 0 ? 0 : holidayOvertime_4leave ;
double workingDayOvertime_nonleave = Util . getDoubleValue ( Util . null2String ( dailyFlowOverTimeData . get ( res + "|" + kqDate + "|workingDayOvertime_nonleave" ) ) ) ;
workingDayOvertime_nonleave = workingDayOvertime_nonleave < 0 ? 0 : workingDayOvertime_nonleave ;
double restDayOvertime_nonleave = Util . getDoubleValue ( Util . null2String ( dailyFlowOverTimeData . get ( res + "|" + kqDate + "|restDayOvertime_nonleave" ) ) ) ;
restDayOvertime_nonleave = restDayOvertime_nonleave < 0 ? 0 : restDayOvertime_nonleave ;
double holidayOvertime_nonleave = Util . getDoubleValue ( Util . null2String ( dailyFlowOverTimeData . get ( res + "|" + kqDate + "|holidayOvertime_nonleave" ) ) ) ;
holidayOvertime_nonleave = holidayOvertime_nonleave < 0 ? 0 : holidayOvertime_nonleave ;
double temp = workingDayOvertime_4leave + restDayOvertime_4leave + holidayOvertime_4leave +
workingDayOvertime_nonleave + restDayOvertime_nonleave + holidayOvertime_nonleave ;
Double attendanceMins = Util . getDoubleValue ( Util . null2String ( attendanceMinsMap . get ( res + "|" + kqDate ) ) ) ;
if ( attendanceMins < 0.00 ) {
attendanceMins = 0.00 ;
}
minValue = attendanceMins + temp ;
double v = Math . round ( Math . max ( minValue , 0.00 ) ) / 60.00 ;
value = "0" ;
if ( v > = 4.00 & & v < 9.00 ) {
value = "1" ;
} else if ( v > = 9.00 ) {
value = "2" ;
}
}
}
}
}
} catch ( Exception e ) {
bb . writeLog ( "get OtherStatAllowance error:" + e . getMessage ( ) ) ;
}
return value ;
}
public String getNightAllowance ( String userId , String kqDate , Map < String , Object > dailyFlowOverTimeData , Map < String , Double > signminsMap ,
Map < String , Double > attendanceMinsMap , List < String > nightShiftList ) {
BaseBean bb = new BaseBean ( ) ;
String value = "" ;
RecordSet rs = new RecordSet ( ) ;
String sql = "" ;
String sqlWhere = " " ;
try {
if ( userId . length ( ) > 0 ) {
sqlWhere + = " and a.id in(" + userId + ") " ;
}
if ( nightShiftList ! = null & nightShiftList . size ( ) > 0 ) {
String nightshiftsub = Util . null2String ( bb . getPropValue ( "project_hostar" , "nightshiftsubcompany" ) ) ;
if ( StringUtils . isNotBlank ( nightshiftsub ) ) {
//查询该分部下的人员
List < String > resIds = new ArrayList < > ( ) ;
sqlWhere + = " and a.subcompanyid1 in (" + nightshiftsub + ") " ;
String acqResSql = "select a.id from hrmresource a where 1=1 " + 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 ) ;
}
}
if ( resIds ! = null & & resIds . size ( ) > 0 ) {
KQWorkTime kqWorkTime = new KQWorkTime ( ) ;
for ( String res : resIds ) {
//获取当天班次
WorkTimeEntity workTime = kqWorkTime . getWorkTime ( userId , kqDate ) ;
String bc = workTime . getSerialId ( ) ;
if ( StringUtils . isEmpty ( bc ) ) {
continue ;
}
int serialid = Integer . parseInt ( bc ) ;
if ( serialid > 0 ) {
if ( ! nightShiftList . contains ( String . valueOf ( serialid ) ) ) {
continue ;
}
} else {
continue ;
}
double workingDayOvertime_4leave = Util . getDoubleValue ( Util . null2String ( dailyFlowOverTimeData . get ( res + "|" + kqDate + "|workingDayOvertime_4leave" ) ) ) ;
workingDayOvertime_4leave = workingDayOvertime_4leave < 0 ? 0 : workingDayOvertime_4leave ;
double restDayOvertime_4leave = Util . getDoubleValue ( Util . null2String ( dailyFlowOverTimeData . get ( res + "|" + kqDate + "|restDayOvertime_4leave" ) ) ) ;
restDayOvertime_4leave = restDayOvertime_4leave < 0 ? 0 : restDayOvertime_4leave ;
double holidayOvertime_4leave = Util . getDoubleValue ( Util . null2String ( dailyFlowOverTimeData . get ( res + "|" + kqDate + "|holidayOvertime_4leave" ) ) ) ;
holidayOvertime_4leave = holidayOvertime_4leave < 0 ? 0 : holidayOvertime_4leave ;
double workingDayOvertime_nonleave = Util . getDoubleValue ( Util . null2String ( dailyFlowOverTimeData . get ( res + "|" + kqDate + "|workingDayOvertime_nonleave" ) ) ) ;
workingDayOvertime_nonleave = workingDayOvertime_nonleave < 0 ? 0 : workingDayOvertime_nonleave ;
double restDayOvertime_nonleave = Util . getDoubleValue ( Util . null2String ( dailyFlowOverTimeData . get ( res + "|" + kqDate + "|restDayOvertime_nonleave" ) ) ) ;
restDayOvertime_nonleave = restDayOvertime_nonleave < 0 ? 0 : restDayOvertime_nonleave ;
double holidayOvertime_nonleave = Util . getDoubleValue ( Util . null2String ( dailyFlowOverTimeData . get ( res + "|" + kqDate + "|holidayOvertime_nonleave" ) ) ) ;
holidayOvertime_nonleave = holidayOvertime_nonleave < 0 ? 0 : holidayOvertime_nonleave ;
double temp = workingDayOvertime_4leave + restDayOvertime_4leave + holidayOvertime_4leave +
workingDayOvertime_nonleave + restDayOvertime_nonleave + holidayOvertime_nonleave ;
Double attendanceMins = Util . getDoubleValue ( Util . null2String ( attendanceMinsMap . get ( res + "|" + kqDate ) ) ) ;
value = String . valueOf ( Math . floor ( ( ( attendanceMins < 0.00 ? 0.00 : attendanceMins ) + temp ) / 300 ) ) ;
}
}
}
}
} catch ( Exception e ) {
bb . writeLog ( "get NightAllowance error:" + e . getMessage ( ) ) ;
}
return value ;
}
public String getStatAllowance ( String userId , String kqDate , Map < String , Object > dailyFlowOverTimeData , Map < String , Double > signminsMap ,
Map < String , Double > attendanceMinsMap , List < String > noRes ) {
BaseBean bb = new BaseBean ( ) ;
String value = "0" ;
RecordSet rs = new RecordSet ( ) ;
String sql = "" ;
String sqlWhere = " " ;
try {
if ( userId . length ( ) > 0 ) {
sqlWhere + = " and a.id in(" + userId + ") " ;
}
//首先去除指定不享有的分部
List < String > subComoanyList = new ArrayList < > ( ) ;
String acqNoStatAllSql = "select subcompany from uf_NoStatAllSubCom where isdelete = 0 or isdelete is null" ;
rs . executeQuery ( acqNoStatAllSql ) ;
while ( rs . next ( ) ) {
String subcompany = Util . null2String ( rs . getString ( "subcompany" ) ) ;
if ( StringUtils . isNotBlank ( subcompany ) ) {
subComoanyList . add ( subcompany ) ;
}
}
String subComoanys = "" ;
if ( subComoanyList ! = null & & subComoanyList . size ( ) > 0 ) {
subComoanys = String . join ( "," , subComoanyList ) ;
}
if ( StringUtils . isNotBlank ( subComoanys ) ) {
sqlWhere + = " and a.subcompanyid1 not in (" + subComoanys + ") " ;
}
if ( noRes ! = null & & noRes . size ( ) > 0 ) {
sqlWhere + = " and a.id not in (" + String . join ( "," , noRes ) + ") " ;
}
List < String > resIds = new ArrayList < > ( ) ;
String acqResSql = "select a.id from hrmresource a where 1=1 " + 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 ( kqDate ) ) {
KQGroupMemberComInfo kqGroupMemberComInfo = new KQGroupMemberComInfo ( ) ;
// 获取享受的考勤组
List < String > grouplist = new ArrayList < String > ( ) ;
String acqGroupSql = "select kqgroup from uf_StatAlloKqGroup where isdelete is null or isdelete = 0 " ;
rs . executeQuery ( acqGroupSql ) ;
while ( rs . next ( ) ) {
String kqgroup = Util . null2String ( rs . getString ( "kqgroup" ) ) ;
if ( StringUtils . isNotBlank ( kqgroup ) ) {
grouplist . add ( kqgroup ) ;
}
}
if ( grouplist ! = null & & grouplist . size ( ) = = 0 ) {
return "0" ;
}
for ( String res : resIds ) {
//判断考勤组
/*获取考勤组的ID, 因为考勤组有有效期, 所以需要传入日期*/
String groupId = kqGroupMemberComInfo . getKQGroupId ( userId , kqDate ) ;
if ( ! grouplist . contains ( groupId ) ) {
continue ;
}
//获取考勤打卡
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 < > ( ) ;
KQWorkTime kqWorkTime = new KQWorkTime ( ) ;
kqWorkTime . setIsFormat ( true ) ;
WorkTimeEntity workTime = kqWorkTime . getWorkTime ( res , kqDate ) ;
String preDate = weaver . common . DateUtil . addDate ( kqDate , - 1 ) ; //上一天日期
String nextDate = weaver . common . DateUtil . addDate ( kqDate , 1 ) ; //下一天日期
if ( workTime ! = null ) {
lsSignTime = workTime . getSignTime ( ) ; //允许打卡时间
lsWorkTime = workTime . getWorkTime ( ) ; //工作时间
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 ( kqDate ) ;
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 , kqDate , 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 ;
String signId = Util . null2String ( temp . get ( "signId" ) ) ;
if ( StringUtils . isNotBlank ( signId ) ) {
signIdList . add ( signId ) ;
}
}
}
// bb.writeLog("signIdList: " + signIdList);
Integer signNumber = 0 ;
if ( signIdList ! = null & & signIdList . size ( ) > 0 ) {
String acqShowAddress = "select showaddress,addr,signfrom 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" ) ) ;
String signfrom = Util . null2String ( rs . getString ( "signfrom" ) ) ;
if ( StringUtils . isEmpty ( signfrom ) | | ! StringUtils . equals ( signfrom , "e9mobile" ) ) {
signNumber = signNumber + 1 ;
}
String addr = Util . null2String ( rs . getString ( "addr" ) ) ;
if ( "鸿仕达" . equals ( showaddress ) | | "hostar" . equalsIgnoreCase ( showaddress ) | | "鸿仕达" . equals ( addr ) | | "hostar" . equalsIgnoreCase ( addr ) ) {
signNumber = signNumber + 1 ;
}
if ( StringUtils . isNotEmpty ( showaddress ) & & ( showaddress . contains ( "鸿仕达" ) | | showaddress . toLowerCase ( ) . contains ( "hostar" ) ) ) {
signNumber = signNumber + 1 ;
}
if ( StringUtils . isNotEmpty ( addr ) & & ( addr . contains ( "鸿仕达" ) | | addr . toLowerCase ( ) . contains ( "hostar" ) ) ) {
signNumber = signNumber + 1 ;
}
if ( StringUtils . isNotEmpty ( showaddress ) & & ( showaddress . contains ( "台湾" ) | | showaddress . contains ( "越南" )
| | showaddress . toLowerCase ( ) . contains ( "hostar" ) | | showaddress . toLowerCase ( ) . contains ( "vinh" ) | | showaddress . toLowerCase ( ) . contains ( "ha noi" ) ) ) {
signNumber = signNumber + 1 ;
}
if ( StringUtils . isNotEmpty ( addr ) & & ( addr . contains ( "台湾" ) | | addr . contains ( "越南" )
| | addr . toLowerCase ( ) . contains ( "hostar" ) | | addr . toLowerCase ( ) . contains ( "vinh" ) | | addr . toLowerCase ( ) . contains ( "ha noi" ) ) ) {
signNumber = signNumber + 1 ;
}
}
}
if ( signNumber = = 0 ) {
// if ((!CollectionUtils.isEmpty(pbzbcSet)) && pbzbcSet.contains(groupId)) {
double workingDayOvertime_4leave = Util . getDoubleValue ( Util . null2String ( dailyFlowOverTimeData . get ( res + "|" + kqDate + "|workingDayOvertime_4leave" ) ) ) ;
workingDayOvertime_4leave = workingDayOvertime_4leave < 0 ? 0 : workingDayOvertime_4leave ;
double restDayOvertime_4leave = Util . getDoubleValue ( Util . null2String ( dailyFlowOverTimeData . get ( res + "|" + kqDate + "|restDayOvertime_4leave" ) ) ) ;
restDayOvertime_4leave = restDayOvertime_4leave < 0 ? 0 : restDayOvertime_4leave ;
double holidayOvertime_4leave = Util . getDoubleValue ( Util . null2String ( dailyFlowOverTimeData . get ( res + "|" + kqDate + "|holidayOvertime_4leave" ) ) ) ;
holidayOvertime_4leave = holidayOvertime_4leave < 0 ? 0 : holidayOvertime_4leave ;
double workingDayOvertime_nonleave = Util . getDoubleValue ( Util . null2String ( dailyFlowOverTimeData . get ( res + "|" + kqDate + "|workingDayOvertime_nonleave" ) ) ) ;
workingDayOvertime_nonleave = workingDayOvertime_nonleave < 0 ? 0 : workingDayOvertime_nonleave ;
double restDayOvertime_nonleave = Util . getDoubleValue ( Util . null2String ( dailyFlowOverTimeData . get ( res + "|" + kqDate + "|restDayOvertime_nonleave" ) ) ) ;
restDayOvertime_nonleave = restDayOvertime_nonleave < 0 ? 0 : restDayOvertime_nonleave ;
double holidayOvertime_nonleave = Util . getDoubleValue ( Util . null2String ( dailyFlowOverTimeData . get ( res + "|" + kqDate + "|holidayOvertime_nonleave" ) ) ) ;
holidayOvertime_nonleave = holidayOvertime_nonleave < 0 ? 0 : holidayOvertime_nonleave ;
double temp = workingDayOvertime_4leave + restDayOvertime_4leave + holidayOvertime_4leave +
workingDayOvertime_nonleave + restDayOvertime_nonleave + holidayOvertime_nonleave ;
Double attendanceMins = Util . getDoubleValue ( Util . null2String ( attendanceMinsMap . get ( res + "|" + kqDate ) ) ) ;
value = String . valueOf ( Math . floor ( ( ( attendanceMins < 0.00 ? 0.00 : attendanceMins ) + temp ) / 300 ) ) ;
// }
// if ((!CollectionUtils.isEmpty(zrzbcSet)) && zrzbcSet.contains(groupId)) {
// Double signmins = Util.getDoubleValue(Util.null2String(signminsMap.get(res + "|" + kqDate)));
// value = String.valueOf(Math.floor((signmins < 0.00 ? 0.00 : signmins) / 360));
// }
}
}
}
} catch ( Exception e ) {
bb . writeLog ( "get StatAllowance error:" + e . getMessage ( ) ) ;
}
return value ;
}
public String getMealAllowance ( String id , String kqDateA ) {
BaseBean bb = new BaseBean ( ) ;
String value = "0" ;
RecordSet rs = new RecordSet ( ) ;
String sql = "" ;
try {
// 首先获取出差公出流程信息
String evectionTableName = Util . null2String ( bb . getPropValue ( "project_hostar" , "evectionTableName" ) ) ;
sql = " select a.* from (" +
"select id, requestid, jd as longitude, wd as latitude from " + evectionTableName +
" WHERE (sjccr = '" + id + "' or ','+CAST(nbtxr AS varchar(max))+',' like '%,'+CAST(" + id + " AS varchar(10))+',%') " +
" and ksrq <='" + kqDateA + "' and (((sjjsrq is null or sjjsrq = '') and yjjsrq >= '" + kqDateA + "') or (sjjsrq is not null and sjjsrq != '' and sjjsrq >= '" + kqDateA + "'))" +
") a, workflow_requestbase b WHERE a.requestId = b.requestId and b.currentnodetype != 0" ;
bb . writeLog ( "sql: " + sql ) ;
boolean isGoing = false ;
rs . execute ( sql ) ;
while ( rs . next ( ) ) {
isGoing = true ;
}
Map < String , Map < String , Object > > lsCheckInfo = new HashMap < > ( ) ;
List < Map < String , Object > > legWorkInfos = new ArrayList < > ( ) ;
// 解析日期字符串为LocalDate对象
LocalDate date = LocalDate . parse ( kqDateA , DateTimeFormatter . ISO_DATE ) ;
// 获取后一天的日期
LocalDate nextDay = date . plusDays ( 1 ) ;
// 将后一天的日期转换为字符串
String kqDateB = nextDay . format ( DateTimeFormatter . ISO_DATE ) ;
String dateParamA = kqDateA + " 05:00:00" ;
String dateParamB = kqDateB + " 04:59:59" ;
if ( isGoing ) {
// String acqLegWorkSignSql = "select operate_time, longitude, latitude,address from mobile_sign where operater = ? and operate_date = '" + kqDateA + "' order by operate_time asc ";
String acqLegWorkSignSql = "select operate_time, longitude, latitude,address,operate_date,CONCAT(operate_date, ' ', operate_time) as dateTimeNew from mobile_sign " +
"where operater = ? and CAST(operate_date + ' ' + operate_time AS datetime) >= CAST('" + dateParamA + "' AS datetime) " +
"and CAST(operate_date + ' ' + operate_time AS datetime) <= CAST('" + dateParamB + "' AS datetime) " ;
rs . executeQuery ( acqLegWorkSignSql , id ) ;
while ( rs . next ( ) ) {
String operateTime = Util . null2String ( rs . getString ( "operate_time" ) ) ;
String longitude = Util . null2String ( rs . getString ( "longitude" ) ) ;
String latitude = Util . null2String ( rs . getString ( "latitude" ) ) ;
String address = Util . null2String ( rs . getString ( "address" ) ) ;
String dateTimeNew = Util . null2String ( rs . getString ( "dateTimeNew" ) ) ;
if ( "hostar" . equalsIgnoreCase ( address ) | | "鸿仕达" . equals ( address ) | | "增善路" . equals ( address )
| | "星圃路" . equals ( address ) | | "智慧新城" . equals ( address ) ) {
continue ;
}
if ( StringUtils . isNotEmpty ( address ) & & ( address . contains ( "鸿仕达" ) | | address . contains ( "增善路" )
| | address . contains ( "星圃路" ) | | address . contains ( "智慧新城" ) | | address . toLowerCase ( ) . contains ( "hostar" ) ) ) {
continue ;
}
if ( StringUtils . isNotEmpty ( address ) & & ( address . contains ( "台湾" ) | | address . contains ( "越南" )
| | address . toLowerCase ( ) . contains ( "hostar" ) | | address . toLowerCase ( ) . contains ( "vinh" ) | | address . toLowerCase ( ) . contains ( "ha noi" ) ) ) {
continue ;
}
// if ( StringUtils.isNotBlank(operateTime) && StringUtils.isNotBlank(longitude) && StringUtils.isNotBlank(latitude) ) {
if ( StringUtils . isNotBlank ( operateTime ) ) {
Map < String , Object > temp = new HashMap < > ( ) ;
temp . put ( "operateTime" , operateTime ) ;
temp . put ( "longitude" , longitude ) ;
temp . put ( "latitude" , latitude ) ;
temp . put ( "dateTimeNew" , dateTimeNew ) ;
legWorkInfos . add ( temp ) ;
}
}
if ( legWorkInfos ! = null & & legWorkInfos . size ( ) > 1 ) {
String tempSignIn = "" ;
String tempSignInDateTime = "" ;
String tempSignOutDateTime = "" ;
String tempSignInLatitude = "" ;
String tempSignInLongitude = "" ;
String tempSignOutLatitude = "" ;
String tempSignOutLongitude = "" ;
String tempSignOut = "" ;
Map < String , Object > checkInfo = new HashMap < > ( ) ;
for ( Map < String , Object > temp : legWorkInfos ) {
String operateTime = Util . null2String ( temp . get ( "operateTime" ) ) ;
String longitude = Util . null2String ( temp . get ( "longitude" ) ) ;
String latitude = Util . null2String ( temp . get ( "latitude" ) ) ;
String dateTimeNew = Util . null2String ( temp . get ( "dateTimeNew" ) ) ;
if ( StringUtils . isBlank ( tempSignIn ) ) {
tempSignIn = operateTime ;
tempSignInLatitude = latitude ;
tempSignInLongitude = longitude ;
tempSignInDateTime = dateTimeNew ;
} else {
if ( dateTimeNew . compareTo ( tempSignInDateTime ) < 0 ) {
tempSignIn = operateTime ;
tempSignInLatitude = latitude ;
tempSignInLongitude = longitude ;
tempSignInDateTime = dateTimeNew ;
}
}
if ( StringUtils . isBlank ( tempSignOut ) ) {
tempSignOut = operateTime ;
tempSignOutDateTime = dateTimeNew ;
tempSignOutLatitude = latitude ;
tempSignOutLongitude = longitude ;
} else {
if ( dateTimeNew . compareTo ( tempSignOutDateTime ) > 0 ) {
tempSignOut = operateTime ;
tempSignOutDateTime = dateTimeNew ;
tempSignOutLatitude = latitude ;
tempSignOutLongitude = longitude ;
}
}
}
// }
checkInfo . put ( "signDate" , kqDateA ) ; //签到签退日期
checkInfo . put ( "signInTime" , tempSignIn ) ; //签到时间
checkInfo . put ( "signInDateTime" , tempSignInDateTime ) ; //签到日期时间
checkInfo . put ( "signInLatitude" , tempSignInLatitude ) ; //签到纬度
checkInfo . put ( "signInLongitude" , tempSignInLongitude ) ; //签到经度
checkInfo . put ( "signOutTime" , tempSignOut ) ; //签退时间
checkInfo . put ( "signOutDateTime" , tempSignOutDateTime ) ; //签退日期时间
checkInfo . put ( "signOutLatitude" , tempSignOutLatitude ) ; //签退纬度
checkInfo . put ( "signOutLongitude" , tempSignOutLongitude ) ; //签退经度
lsCheckInfo . put ( id + "|" + kqDateA , checkInfo ) ;
}
}
HostarUtil hostarUtil = new HostarUtil ( ) ;
String MealAlloTableName = Util . null2String ( bb . getPropValue ( "project_hostar" , "MealAllowanceTableName" ) ) ;
// 定义日期格式
DateTimeFormatter formatterRq = DateTimeFormatter . ofPattern ( "yyyy-MM-dd" ) ;
// 定义时间格式
DateTimeFormatter formatter = DateTimeFormatter . ofPattern ( "HH:mm:ss" ) ;
if ( StringUtils . isNotBlank ( MealAlloTableName ) ) {
//获取餐补判断时间
List < Map < String , String > > MealMap = new ArrayList < > ( ) ;
String acqTimeSql = "select startTime, endTime from " + MealAlloTableName + " where (isDelete is null or isDelete = 0)" ;
// bb.writeLog("acqTimeSql: " + acqTimeSql);
rs . executeQuery ( acqTimeSql ) ;
while ( rs . next ( ) ) {
String startTime = Util . null2String ( rs . getString ( "startTime" ) ) ;
String endTime = Util . null2String ( rs . getString ( "endTime" ) ) ;
Map < String , String > temp = new HashMap < > ( ) ;
temp . put ( "startTime" , startTime ) ;
temp . put ( "endTime" , endTime ) ;
MealMap . add ( temp ) ;
}
// bb.writeLog("MealMap: " + MealMap);
//根据外勤打卡数据计算餐补数据
for ( String key : lsCheckInfo . keySet ( ) ) {
// String[] split = key.split("\\|");
// String userId = split[0];
// String kqDate = split[1];
Map < String , Object > temp = lsCheckInfo . get ( key ) ;
String signInTime = Util . null2String ( temp . get ( "signInTime" ) ) ;
String signOutTime = Util . null2String ( temp . get ( "signOutTime" ) ) ;
String signInDateTime = Util . null2String ( temp . get ( "signInDateTime" ) ) ;
String signOutDateTime = Util . null2String ( temp . get ( "signOutDateTime" ) ) ;
String signDate = Util . null2String ( temp . get ( "signDate" ) ) ;
if ( StringUtils . isNotBlank ( signInTime ) & & StringUtils . isNotBlank ( signOutTime ) ) {
for ( Map < String , String > me : MealMap ) {
String startTime = me . get ( "startTime" ) ;
String startDateTime = "" ;
String endTime = me . get ( "endTime" ) ;
String endDateTime = "" ;
if ( StringUtils . isNotBlank ( startTime ) & & StringUtils . isNotBlank ( endTime ) ) {
startTime = startTime + ":00" ;
endTime = endTime + ":00" ;
String signDateNew = signDate ;
// 判断时间
LocalTime t1 = LocalTime . parse ( startTime , formatter ) ;
LocalTime t2 = LocalTime . parse ( endTime , formatter ) ;
if ( t2 . isBefore ( t1 ) ) {
LocalDate dateToday = LocalDate . parse ( signDateNew , formatterRq ) ;
// 加一天
LocalDate nextDayNew = dateToday . plusDays ( 1 ) ;
signDateNew = nextDayNew . format ( formatterRq ) ;
}
startDateTime = signDate + " " + startTime ;
endDateTime = signDateNew + " " + endTime ;
}
if ( ( signInDateTime . compareTo ( startDateTime ) < = 0 ) & & ( signOutDateTime . compareTo ( endDateTime ) > = 0 ) ) {
if ( StringUtils . isEmpty ( value ) | | StringUtils . equals ( value , "0" ) ) {
value = "1" ;
} else {
int valueT = Integer . parseInt ( value ) + 1 ;
value = String . valueOf ( valueT ) ;
}
}
}
}
}
}
} catch ( Exception e ) {
bb . writeLog ( "get MealAllowance error:" + e . getMessage ( ) ) ;
}
return value ;
}
}