diff --git a/bonus-modules/bonus-system/src/main/java/com/bonus/system/att/controller/AttHisPullController.java b/bonus-modules/bonus-system/src/main/java/com/bonus/system/att/controller/AttHisPullController.java new file mode 100644 index 0000000..2baf029 --- /dev/null +++ b/bonus-modules/bonus-system/src/main/java/com/bonus/system/att/controller/AttHisPullController.java @@ -0,0 +1,196 @@ +package com.bonus.system.att.controller; + +import com.bonus.common.core.utils.StringUtils; +import com.bonus.common.core.web.controller.BaseController; +import com.bonus.common.core.web.domain.AjaxResult; +import com.bonus.common.core.web.page.TableDataInfo; +import com.bonus.common.log.annotation.Log; +import com.bonus.common.log.enums.BusinessType; +import com.bonus.common.security.utils.SecurityUtils; +import com.bonus.system.att.entity.AttDataDetailsBean; +import com.bonus.system.att.entity.OrgChangeBean; +import com.bonus.system.att.service.AttCalService; +import com.bonus.system.att.service.OrgChangeService; +import com.bonus.system.att.tasks.AttTasks; +import com.bonus.system.att.tasks.NewAttTask; +import com.bonus.system.att.utils.AttTimeUtil; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.CollectionUtils; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import java.util.ArrayList; +import java.util.List; + +/** + * 考勤数据拉取控制层 + * + * @author fly + */ +@RestController +@RequestMapping("/attHisPull") +@Slf4j +public class AttHisPullController extends BaseController { + + @Resource + private NewAttTask attTask; + + /** + * 考勤模版数据 + * 某天考勤人员列表 + * 基模版数据生成 + */ + @GetMapping("/getAttTempData") + @Log(title = "考勤数据拉取->考勤模版数据", businessType = BusinessType.QUERY) + public AjaxResult getAttTempData(@RequestBody AttDataDetailsBean bean) { + try{ + List dateList = AttTimeUtil.getStrDateListBetween(bean.getStartDate(), bean.getEndDate()); + for (String date : dateList) { + attTask.insertAttDateHistory(date); + attTask.insertAttTempData(date, 2); + } + return toAjax(true); + }catch (Exception e){ + log.error(e.toString(),e); + } + return error("系统异常"); + } + + /** + * 1.数据拉取(考勤)定时器 每隔1个小时获取一次数据 + * 2.考勤数据应用(步骤一:考勤数据更新) + */ + @GetMapping("/getAttDataPull") + @Log(title = "考勤数据拉取->数据拉取(考勤)考勤数据更新", businessType = BusinessType.QUERY) + public AjaxResult getAttDataPull(@RequestBody AttDataDetailsBean bean) { + try{ + List dateList = AttTimeUtil.getStrDateListBetween(bean.getStartDate(), bean.getEndDate()); + for (String date : dateList) { + attTask.getAttendanceData(date,2); + attTask.updateAttData(date,2); + } + return toAjax(true); + }catch (Exception e){ + log.error(e.toString(),e); + } + return error("系统异常"); + } + + /** + * 单独子流程,不在主流程中 + * 旷工判断 + */ + @GetMapping("/getAbsenteeismData") + @Log(title = "考勤数据拉取->旷工判断", businessType = BusinessType.QUERY) + public AjaxResult getAbsenteeismData(@RequestBody AttDataDetailsBean bean) { + try{ + List dateList = AttTimeUtil.getStrDateListBetween(bean.getStartDate(), bean.getEndDate()); + for (String date : dateList) { + attTask.updateAbsenteeismData(date,1); + } + return toAjax(true); + }catch (Exception e){ + log.error(e.toString(),e); + } + return error("系统异常"); + } + + /** + * 请假数据应用--法假 + * 每天更新一次一点更新 + */ + @GetMapping("/getLegalHolidayData") + @Log(title = "考勤数据拉取->请假数据应用--法假", businessType = BusinessType.QUERY) + public AjaxResult getLegalHolidayData(@RequestBody AttDataDetailsBean bean) { + try{ + List dateList = AttTimeUtil.getStrDateListBetween(bean.getStartDate(), bean.getEndDate()); + for (String date : dateList) { + attTask.updateLegalHolidayData(date); + } + return toAjax(true); + }catch (Exception e){ + log.error(e.toString(),e); + } + return error("系统异常"); + } + + /** + * 请假数据应用--请假 + * 每天更新两次上午8点,下午18点(45天前数据) + */ + @GetMapping("/getLeaveData") + @Log(title = "考勤数据拉取->请假数据应用--请假", businessType = BusinessType.QUERY) + public AjaxResult getLeaveData(@RequestBody AttDataDetailsBean bean) { + try{ + List dateList = AttTimeUtil.getStrDateListBetween(bean.getStartDate(), bean.getEndDate()); + for (String date : dateList) { + attTask.updateLeaveData(date); + } + return toAjax(true); + }catch (Exception e){ + log.error(e.toString(),e); + } + return error("系统异常"); + } + + /** + * 报表数据生成(日报表) + * 每次更新数据都要执行(跟随) + */ + @GetMapping("/insertDayReportData") + @Log(title = "考勤数据拉取->报表数据生成(日报表)", businessType = BusinessType.QUERY) + public AjaxResult insertDayReportData(@RequestBody AttDataDetailsBean bean) { + try{ + List dateList = AttTimeUtil.getStrDateListBetween(bean.getStartDate(), bean.getEndDate()); + for (String date : dateList) { + attTask.updateLeaveData(date); + } + return toAjax(true); + }catch (Exception e){ + log.error(e.toString(),e); + } + return error("系统异常"); + } + + /** + * 报表数据生成(月报表) + * 月初生成一次 + */ + @GetMapping("/insertMonthReportTempData") + @Log(title = "考勤数据拉取->报表数据生成(月报表)", businessType = BusinessType.QUERY) + public AjaxResult insertMonthReportTempData(@RequestBody AttDataDetailsBean bean) { + try{ + List dateList = AttTimeUtil.getStrDateListBetween(bean.getStartDate(), bean.getEndDate()); + for (String date : dateList) { + attTask.insertMonthReportTempData(date); + } + return toAjax(true); + }catch (Exception e){ + log.error(e.toString(),e); + } + return error("系统异常"); + } + + /** + * 报表数据生成--月报表 + * 每日数据变化修改之后修改 + */ + @GetMapping("/updateMonthReportData") + @Log(title = "考勤数据拉取->报表数据生成--月报表修改", businessType = BusinessType.QUERY) + public AjaxResult updateMonthReportData(@RequestBody AttDataDetailsBean bean) { + try{ + List dateList = AttTimeUtil.getStrDateListBetween(bean.getStartDate(), bean.getEndDate()); + for (String date : dateList) { + attTask.updateMonthReportData(date); + } + return toAjax(true); + }catch (Exception e){ + log.error(e.toString(),e); + } + return error("系统异常"); + } + + + +}