This commit is contained in:
Harryxzy 2022-09-26 17:04:07 +08:00
parent cff05b3f29
commit 1658f50fa7
2 changed files with 75 additions and 1 deletions

View File

@ -4,10 +4,12 @@ import com.engine.bjcj220907.dao.MonthBonusDAO;
import com.engine.bjcj220907.entity.JwCZInfo;
import com.engine.bjcj220907.entity.JwCZInfoDetail;
import com.engine.bjcj220907.service.OverseasAllowanceCountService;
import com.engine.bjcj220907.utils.BjcjCommonUtils;
import weaver.general.BaseBean;
import java.util.Calendar;
import java.util.List;
import java.util.stream.Collectors;
/**
* @author Harryxzy
@ -37,8 +39,80 @@ public class OverseasAllowanceCountServiceImpl implements OverseasAllowanceCount
// 将境外常驻信息格式化
List<JwCZInfo> jwCZInfos = MonthBonusCountServiceImpl.formatJwCZInfo(czInfos);
baseBean.writeLog("将境外常驻信息格式化");
// 考勤开始日期
Calendar startAttendanceCal = BjcjCommonUtils.getStartAttendanceCal(countCal.getTime());
// 考勤结束日期
Calendar endAttendanceCal = BjcjCommonUtils.getEndAttendanceCal(countCal.getTime());
baseBean.writeLog("将境外常驻信息格式化");
// 如果用户在考勤周期内存在境外常驻信息则过滤出来并且计算当月应常驻天数
jwCZInfos = getCZInfosAndCZDays(jwCZInfos,startAttendanceCal,endAttendanceCal);
//
}
/**
* @description 获取用户在考勤周期内存在境外常驻信息过滤出来并且计算当月应常驻天数
* @return List<JwCZInfo>
* @author Harryxzy
* @date 2022/9/26 16:29
*/
public List<JwCZInfo> getCZInfosAndCZDays(List<JwCZInfo> jwCZInfos,Calendar startAttendanceCal,Calendar endAttendanceCal){
List<JwCZInfo> collect = jwCZInfos.stream().filter(czInfo -> {
List<JwCZInfoDetail> czDetails = czInfo.getInfos();
// 用于存储计算到哪一天的日期
Calendar c = Calendar.getInstance();
c.setTime(endAttendanceCal.getTime());
Calendar[] countDay = {c};
int[] ycq = {0};
boolean[] flag = {false};
for (int i = 0; i < czDetails.size(); i++) {
JwCZInfoDetail detail = czDetails.get(i);
if (detail.getLx() == 0 && (detail.getJwczksrq().before(endAttendanceCal.getTime()) || detail.getJwczksrq().equals(endAttendanceCal.getTime()))) {
// 涉及考勤周期内的开始常驻
if (detail.getJwczksrq().after(startAttendanceCal.getTime())) {
// 开始常驻日期在 考勤开始日期后结束日期前
int days = BjcjCommonUtils.getDays(detail.getJwczksrq(), endAttendanceCal.getTime());
ycq[0] += days;
countDay[0].setTime(detail.getJwczksrq());
countDay[0].add(Calendar.DATE, -1);
flag[0] = true;
} else {
// 开始常驻日期在 考勤开始日期前应出勤日期为自然日
int days = BjcjCommonUtils.getDays(startAttendanceCal.getTime(), endAttendanceCal.getTime());
czInfo.setYczDays(days);
return true;
}
}
if (detail.getLx() == 1 &&
((detail.getJwczksrq().before(endAttendanceCal.getTime()) || detail.getJwczksrq().equals(endAttendanceCal.getTime()))
&& (detail.getJwczjsrq().after(startAttendanceCal.getTime()) || detail.getJwczjsrq().equals(startAttendanceCal.getTime())))) {
// 涉及考勤周期内的结束常驻
// 修正境外常驻开始日期
Calendar countStartCal = Calendar.getInstance();
countStartCal.setTime(detail.getJwczksrq());
if (detail.getJwczksrq().before(startAttendanceCal.getTime())) {
countStartCal.setTime(startAttendanceCal.getTime());
}
// 修正境外常驻结束日期
Calendar countEndCal = Calendar.getInstance();
countEndCal.setTime(detail.getJwczjsrq());
if (detail.getJwczjsrq().after(endAttendanceCal.getTime())) {
countEndCal.setTime(endAttendanceCal.getTime());
}
ycq[0] += BjcjCommonUtils.getDays(countStartCal.getTime(), countEndCal.getTime());
flag[0] = true;
}
if (i == czDetails.size() - 1 && flag[0] == true) {
// 已计算出应出勤天数
czInfo.setYczDays(ycq[0]);
return true;
}
}
return false;
}).collect(Collectors.toList());
return collect;
}
}

View File

@ -28,7 +28,7 @@ public class OverseasAllowanceCountController {
* 境外津贴计算
*/
@GET
@Path("/countOverseasAllowanceCount")
@Path("/countOverseasAllowance")
@Produces(MediaType.APPLICATION_JSON)
public void countOverseasAllowance(@Context HttpServletRequest request, @Context HttpServletResponse response) {
User user = HrmUserVarify.getUser(request, response);