parent
e86d850e51
commit
aecd1edbb8
|
|
@ -62,7 +62,6 @@ public class AttHisPullController extends BaseController {
|
|||
|
||||
/**
|
||||
* 1.数据拉取(考勤)定时器 每隔1个小时获取一次数据
|
||||
* 2.考勤数据应用(步骤一:考勤数据更新)
|
||||
*/
|
||||
@GetMapping("/getAttDataPull")
|
||||
@Log(title = "考勤数据拉取->数据拉取(考勤)考勤数据更新", businessType = BusinessType.QUERY)
|
||||
|
|
@ -72,6 +71,24 @@ public class AttHisPullController extends BaseController {
|
|||
Collections.reverse(dateList);
|
||||
for (String date : dateList) {
|
||||
attTask.getAttendanceData(date,2);
|
||||
}
|
||||
return toAjax(true);
|
||||
}catch (Exception e){
|
||||
log.error(e.toString(),e);
|
||||
}
|
||||
return error("系统异常");
|
||||
}
|
||||
|
||||
/**
|
||||
* 2.考勤数据应用(步骤一:考勤数据更新)
|
||||
*/
|
||||
@GetMapping("/updateAttData")
|
||||
@Log(title = "考勤数据拉取->数据拉取(考勤)考勤数据更新", businessType = BusinessType.QUERY)
|
||||
public AjaxResult updateAttData( AttDataDetailsBean bean) {
|
||||
try{
|
||||
List<String> dateList = AttTimeUtil.getStrDateListBetween(bean.getStartDate(), bean.getEndDate());
|
||||
Collections.reverse(dateList);
|
||||
for (String date : dateList) {
|
||||
attTask.updateAttData(date,2);
|
||||
}
|
||||
return toAjax(true);
|
||||
|
|
|
|||
|
|
@ -442,4 +442,17 @@ public class AttendanceDetailsController extends BaseController {
|
|||
return getDataTableError(new ArrayList<>());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取数据看板-详细记录
|
||||
*/
|
||||
@GetMapping("/updateAttMonthDays")
|
||||
@Log(title = "考勤报表->月报表->月出勤天数重新计算", businessType = BusinessType.QUERY)
|
||||
public AjaxResult updateAttMonthDays(AttMonthDaysMakeUpBean bean) {
|
||||
try {
|
||||
return attendanceDetailsService.updateAttMonthDays(bean);
|
||||
} catch (Exception e) {
|
||||
log.error(e.toString(), e);
|
||||
}
|
||||
return error("系统异常");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -140,4 +140,8 @@ public interface AttendanceDetailsDao {
|
|||
* @date 2025/2/23 21:01
|
||||
*/
|
||||
void addAttDataAuditRecord(List<AttDataUpdateAuditRecordVo> list);
|
||||
|
||||
List<AttMonthReportBean> getAttMonthReportListSimple(String attCurrentMonth);
|
||||
|
||||
void batchUpdateMonthReportRequiredDay(List<AttMonthReportBean> list);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -118,9 +118,16 @@ public interface AttendanceDetailsService {
|
|||
List<AttClockingRecordVo> getClockingRecordListByUserId(AttMonthReportBean bean);
|
||||
|
||||
/**
|
||||
*
|
||||
*出勤天数组成
|
||||
* @param bean
|
||||
* @return
|
||||
*/
|
||||
List<AttMonthDaysMakeUpBean> getAttMonthDaysMakeUp(AttMonthDaysMakeUpBean bean);
|
||||
|
||||
/**
|
||||
* 月出勤天数重新计算
|
||||
* @param bean
|
||||
* @return
|
||||
*/
|
||||
AjaxResult updateAttMonthDays(AttMonthDaysMakeUpBean bean);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -415,4 +415,63 @@ public class AttendanceDetailsServiceImpl implements AttendanceDetailsService {
|
|||
}
|
||||
return listDays;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AjaxResult updateAttMonthDays(AttMonthDaysMakeUpBean bean) {
|
||||
String attCurrentMonth = bean.getAttCurrentMonth() + "-01";
|
||||
//先查所有人
|
||||
List<AttMonthReportBean> list = attendanceDetailsDao.getAttMonthReportListSimple(bean.getAttCurrentMonth());
|
||||
for (AttMonthReportBean attMonthReportBean : list) {
|
||||
bean.setUserId(attMonthReportBean.getUserId());
|
||||
//查询历史考勤规则,方便分组计算
|
||||
List<AttGroupBean> dataList = attCalService.getAttSettingHistoryByUserAndDate(String.valueOf(attMonthReportBean.getUserId()),attCurrentMonth);
|
||||
//查询那个人是否还在考勤组,如果不再了,就不需要不全当月剩余时间
|
||||
int i = attCalService.getPersonAttGroup(bean.getUserId());
|
||||
AtomicLong requiredDays = new AtomicLong();
|
||||
if(i>0){
|
||||
//以最后一个考勤规则补全剩下当月日期所有考勤规则数据
|
||||
// 获取最后一个数据的日期
|
||||
AttGroupBean lastData = dataList.get(dataList.size() - 1);
|
||||
LocalDate lastDate = LocalDate.parse(lastData.getCurrentDay(), DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
||||
// 获取当月的总天数
|
||||
int lastDayOfMonth = lastDate.lengthOfMonth();
|
||||
// 从最后一个日期开始补全当月剩下的日期
|
||||
for (int day = lastDate.getDayOfMonth() + 1; day <= lastDayOfMonth; day++) {
|
||||
LocalDate newDate = lastDate.withDayOfMonth(day);
|
||||
dataList.add(new AttGroupBean(lastData.getUserId(), lastData.getGroupId(), newDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))));
|
||||
}
|
||||
}
|
||||
if (!dataList.isEmpty()) {
|
||||
List<List<AttGroupBean>> result = new ArrayList<>();
|
||||
List<AttGroupBean> currentList = new ArrayList<>();
|
||||
//查出考勤组
|
||||
List<AttGroupBean> groupList = attCalService.getSimplyGroupData();
|
||||
List<Holiday> holidays = attSourceDataDao.selectHolidayByMonth(attCurrentMonth);
|
||||
Long currentGroupId = dataList.get(0).getGroupId();
|
||||
for (AttGroupBean data : dataList) {
|
||||
if (!Objects.equals(data.getGroupId(), currentGroupId)) {
|
||||
result.add(currentList);
|
||||
currentList = new ArrayList<>();
|
||||
currentGroupId = data.getGroupId();
|
||||
}
|
||||
currentList.add(data);
|
||||
}
|
||||
result.add(currentList);
|
||||
result.forEach(v -> {
|
||||
List<AttGroupBean> collect = groupList.stream().filter(g -> Objects.equals(g.getGroupId(), v.get(0).getGroupId())).collect(Collectors.toList());
|
||||
if(!collect.isEmpty()){
|
||||
//应考勤天数
|
||||
List<String> attDayList = WorkdayCalculator.getWorkDay(collect.get(0).getAttDay(),
|
||||
collect.get(0).getIsHaveHoliday(), holidays, v.get(0).getCurrentDay(),v.get(v.size()-1).getCurrentDay());
|
||||
requiredDays.addAndGet(attDayList.size());
|
||||
}
|
||||
});
|
||||
attMonthReportBean.setRequiredDays((int) requiredDays.get());
|
||||
}
|
||||
}
|
||||
if(!list.isEmpty()) {
|
||||
attendanceDetailsDao.batchUpdateMonthReportRequiredDay(list);
|
||||
}
|
||||
return AjaxResult.success();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -598,6 +598,11 @@
|
|||
LEFT JOIN sys_user su ON su.user_id = adu.user_id
|
||||
WHERE adu.user_id = #{userId} AND adu.att_current_day = #{attCurrentDay} AND adu.org_id = #{orgId} LIMIT 1
|
||||
</select>
|
||||
<select id="getAttMonthReportListSimple" resultType="com.bonus.system.att.entity.AttMonthReportBean">
|
||||
SELECT v.user_id,v.att_current_month as `month`
|
||||
FROM att_month_report v
|
||||
where v.att_current_month BETWEEN #{bean.startMonth} AND #{bean.endMonth}
|
||||
</select>
|
||||
|
||||
<update id="updateAttDetailsData">
|
||||
<foreach collection="list" item="params" separator=";">
|
||||
|
|
@ -645,4 +650,10 @@
|
|||
</if>
|
||||
</foreach>
|
||||
</update>
|
||||
<update id="batchUpdateMonthReportRequiredDay">
|
||||
<foreach collection="list" item="params" separator=";">
|
||||
update att_month_report set required_days = #{params.requiredDays}
|
||||
where user_id = #{params.userId} and att_current_month = #{params.month}
|
||||
</foreach>
|
||||
</update>
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue