@ -11,13 +11,15 @@ import weaver.integration.logging.LoggerFactory;
import java.text.DateFormat ;
import java.text.DateFormat ;
import java.text.ParseException ;
import java.text.ParseException ;
import java.text.SimpleDateFormat ;
import java.text.SimpleDateFormat ;
import java.util.Calendar ;
import java.time.LocalDate ;
import java.time.YearMonth ;
import java.time.temporal.ChronoUnit ;
import java.util.Date ;
import java.util.Date ;
/ * *
/ * *
* 定 时 合 计 内 推 奖 励 台 账 盛 世 科 技
* 定 时 合 计 内 推 奖 励 台 账 盛 世 科 技
* /
* /
public class InternalReferralRewardService {
public class InternalReferralRewardService {
private final Logger log = LoggerFactory . getLogger ( InternalReferralRewardService . class ) ;
private final Logger log = LoggerFactory . getLogger ( InternalReferralRewardService . class ) ;
private static final String ntjljmid = Prop . getPropValue ( "jiangshixinchou" , "ntjlhjjmid" ) ;
private static final String ntjljmid = Prop . getPropValue ( "jiangshixinchou" , "ntjlhjjmid" ) ;
@ -33,9 +35,10 @@ public class InternalReferralRewardService{
RecordSet recordSete = new RecordSet ( ) ;
RecordSet recordSete = new RecordSet ( ) ;
RecordSet recordSetf = new RecordSet ( ) ;
RecordSet recordSetf = new RecordSet ( ) ;
RecordSet recordSetg = new RecordSet ( ) ;
RecordSet recordSetg = new RecordSet ( ) ;
RecordSet recordSeth = new RecordSet ( ) ;
//内推记录有并且已经入职的人员
//内推记录有并且已经入职的人员
String sql2 = "select b.id as uid,a.btjrxm,a.sfzhm,a.tjr,a.tjgw,b.companystartdate,c.rz,c.zz,c.rzbn,b.status from uf_ntjl a inner join hrmresource b on a.btjrxm = b.lastname " +
String sql2 = "select b.id as uid,a.btjrxm,a.sfzhm,a.tjr,a.tjgw,b.companystartdate,c.rz,c.zz,c.rzbn,b.status from uf_ntjl a inner join hrmresource b on a.btjrxm = b.lastname " +
"and a.sfzhm = b.certificatenum inner join uf_gwtjjlgz c on a.tjrylb = c.tjgw where b.status in (0,1,2,3) ";
"and a.sfzhm = b.certificatenum inner join uf_gwtjjlgz c on a.tjrylb = c.tjgw where b.status in (0,1,2,3) ";
recordSeta . executeQuery ( sql2 ) ;
recordSeta . executeQuery ( sql2 ) ;
log . error ( "howec::::::sql2:" + sql2 ) ;
log . error ( "howec::::::sql2:" + sql2 ) ;
while ( recordSeta . next ( ) ) {
while ( recordSeta . next ( ) ) {
@ -62,17 +65,23 @@ public class InternalReferralRewardService{
//判断 当前岗位当前推荐人,被推荐人,当前奖励类型是否已经发放工资
//判断 当前岗位当前推荐人,被推荐人,当前奖励类型是否已经发放工资
//以下奖励 都是针对被推荐人
//以下奖励 都是针对被推荐人
String statusstr = "" ;
String statusstr = "" ;
//先发一笔入职
//先发一笔入职 ,需要统计入职日期如果是被统计月,才进行合计
if ( ! getJudgeResult ( 1 , tjr , sfzhm , recordSetb ) ) { //如果不存在,处理
if ( ! getJudgeResult ( 1 , tjr , sfzhm , recordSetb ) ) { //如果不存在,处理
if ( judgeCurrentNyCompanyNy ( companystartdate , currentYm ) ) {
result + = rz ;
result + = rz ;
statusstr = statusstr + "1," ;
statusstr = statusstr + "1," ;
log . error ( "howec:::::::::::入职奖励新增" ) ;
log . error ( "howec:::::::::::入职奖励新增" ) ;
//记录入职奖励
//记录入职奖励
insertRzRecord ( recordSetc , tjr , 1 , rz , tjgw , btjrxm , sfzhm ) ;
insertRzRecord ( recordSetc , tjr , 1 , rz , tjgw , btjrxm , sfzhm ) ;
}
}
}
//判断员工状态是否存在转正,存在则给一笔转正钱
//判断员工状态是否存在转正,存在则给一笔转正钱
if ( isExistZz ( recordSetg , uid ) ) {
if ( isExistZz ( recordSetg , uid ) ) {
if ( ! getJudgeResult ( 2 , tjr , sfzhm , recordSetb ) ) { //如果不存在,处理
if ( ! getJudgeResult ( 2 , tjr , sfzhm , recordSetb ) ) { //如果不存在,处理
//如果存在转正,需要获取转正日期,如果转正日期是被统计月,则进行转正奖励
String zzrq = getZzrq ( recordSeth , uid ) ;
if ( judgeCurrentNyCompanyNy ( zzrq , currentYm ) ) {
result + = zz ;
result + = zz ;
statusstr = statusstr + "2," ;
statusstr = statusstr + "2," ;
log . error ( "howec:::::::::::转正奖励新增" ) ;
log . error ( "howec:::::::::::转正奖励新增" ) ;
@ -80,13 +89,13 @@ public class InternalReferralRewardService{
insertRzRecord ( recordSetc , tjr , 2 , zz , tjgw , btjrxm , sfzhm ) ;
insertRzRecord ( recordSetc , tjr , 2 , zz , tjgw , btjrxm , sfzhm ) ;
}
}
}
}
}
//判断员工 在职期间和入职时间差 大于180天则给奖励3
//判断员工 统计月月底和入职时间差 时间差如果大于6个月并且小于等于7个月
if ( ! getJudgeResult ( 3 , tjr , sfzhm , recordSetb ) ) { //如果不存在,处理
if ( ! getJudgeResult ( 3 , tjr , sfzhm , recordSetb ) ) { //如果不存在,处理
//判断当前日期是否大于180天
//判断当前日期是否大于180天
Date nowTime = parseDateBystr ( nowNy ) ;
String ny = getMonthEndDay ( currentYm ) ;
Date beforeTime = parseDateBystr ( companystartdate ) ;
if ( dataCompare ( companystartdate , ny ) = = 6l ) { //间隔时间刚好是6个月
if ( dataCompare ( nowTime , beforeTime ) ) {
result + = rzbn ;
result + = rzbn ;
statusstr = statusstr + "3," ;
statusstr = statusstr + "3," ;
log . error ( "howec:::::::::::入职半年新增" ) ;
log . error ( "howec:::::::::::入职半年新增" ) ;
@ -106,6 +115,22 @@ public class InternalReferralRewardService{
}
}
}
}
private String getMonthEndDay ( String ny1 ) {
String ny = ny1 ;
YearMonth currentYearMonth = YearMonth . parse ( ny ) ; // 获取当前的年月
LocalDate lastDayOfMonth = currentYearMonth . atEndOfMonth ( ) ; // 获取当前年月的最后一天
return lastDayOfMonth . toString ( ) ;
}
private boolean judgeCurrentNyCompanyNy ( String comparedate1 , String currentYm ) {
String comparedate = comparedate1 ;
comparedate = comparedate . substring ( 0 , 7 ) ;
if ( currentYm . equals ( comparedate ) ) {
return true ;
}
return false ;
}
//根据userid获取转正日期
//根据userid获取转正日期
private String getZzrq ( RecordSet recordSetf , String uid ) {
private String getZzrq ( RecordSet recordSetf , String uid ) {
String sql = "select count(id) as sums from hrmstatushistory where resourceid = " + uid + " and type_n = 2" ;
String sql = "select count(id) as sums from hrmstatushistory where resourceid = " + uid + " and type_n = 2" ;
@ -180,6 +205,8 @@ public class InternalReferralRewardService{
permissionReconstruction ( Util . getIntValue ( id ) , Integer . parseInt ( ntjljmid ) ) ;
permissionReconstruction ( Util . getIntValue ( id ) , Integer . parseInt ( ntjljmid ) ) ;
}
}
//
//
/ * *
/ * *
* 权 限 重 构
* 权 限 重 构
* @param billId
* @param billId
@ -202,28 +229,12 @@ public class InternalReferralRewardService{
}
}
/ * *
/ * *
* 日 期 比 较
* 日 期 比 较 差 6 个 月 发 工 资
* /
* /
public static Boolean dataCompare ( Date nowdate , Date beforedate ) {
public static long dataCompare ( String beforedate , String nowdate ) {
// 获取当前日期
LocalDate date1 = LocalDate . parse ( beforedate ) ;
Calendar currentCalendar = Calendar . getInstance ( ) ;
LocalDate date2 = LocalDate . parse ( nowdate ) ;
currentCalendar . setTime ( nowdate ) ;
long monthsBetween = ChronoUnit . MONTHS . between ( date1 , date2 ) ;
Date currentDate = currentCalendar . getTime ( ) ;
return monthsBetween ;
// 设置比较日期
Calendar compareCalendar = Calendar . getInstance ( ) ;
compareCalendar . setTime ( beforedate ) ;
Date compareDate = compareCalendar . getTime ( ) ;
// 判断当前日期是否大于比较日期半年
Calendar halfYearLater = Calendar . getInstance ( ) ;
halfYearLater . setTime ( compareDate ) ;
halfYearLater . add ( Calendar . MONTH , 6 ) ; // 增加6个月
Date halfYearLaterDate = halfYearLater . getTime ( ) ;
if ( currentDate . after ( halfYearLaterDate ) ) {
return true ;
} else {
return false ;
}
}
}
}
}