赵士淞
2022-12-28 aae6ed1f7e083eee72083bae55d8414bfd5ba7e2
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/impl/AttendanceServiceImpl.java
@@ -18,6 +18,7 @@
import me.zhengjie.modules.attendance.domain.Attendance;
import me.zhengjie.modules.constant.Constant;
import me.zhengjie.modules.system.domain.User;
import me.zhengjie.modules.system.repository.DictDetailRepository;
import me.zhengjie.modules.system.repository.UserRepository;
import me.zhengjie.utils.ValidationUtil;
import me.zhengjie.utils.FileUtil;
@@ -53,6 +54,7 @@
    private final AttendanceRepository attendanceRepository;
    private final AttendanceMapper attendanceMapper;
    private final UserRepository userRepository;
    private final DictDetailRepository dictDetailRepository;
    @Override
    public Map<String,Object> queryAll(AttendanceQueryCriteria criteria, Pageable pageable){
@@ -112,65 +114,23 @@
    public void download(List<AttendanceDto> all, HttpServletResponse response) throws IOException {
        List<Map<String, Object>> list = new ArrayList<>();
        for (AttendanceDto attendance : all) {
            String startLocationResults = attendance.getStartLocationResults() != null ? dictDetailRepository.findByDictNameAndValue("location_results", attendance.getStartLocationResults()).getLabel() : "";
            String startClockResults = attendance.getStartClockResults() != null ? dictDetailRepository.findByDictNameAndValue("attendance_state", attendance.getStartClockResults()).getLabel() : "";
            String endLocationResults = attendance.getEndLocationResults() != null ? dictDetailRepository.findByDictNameAndValue("location_results", attendance.getEndLocationResults()).getLabel() : "";
            String endClockResults = attendance.getEndClockResults() != null ? dictDetailRepository.findByDictNameAndValue("attendance_state", attendance.getEndClockResults()).getLabel() : "";
            String dateType = attendance.getDateType() != null ? dictDetailRepository.findByDictNameAndValue("date_type", attendance.getDateType()).getLabel() : "";
            Map<String,Object> map = new LinkedHashMap<>();
            map.put("员工", attendance.getUserName());
            map.put("考勤日期", attendance.getAttendanceDate());
            map.put("排班工作开始时间", attendance.getRosteringWorkStartTime());
            map.put("实际工作开始时间", attendance.getActualWorkStartTime());
            //开始位置判断
            if(ObjectUtils.isNotEmpty(attendance.getStartLocationResults()) && attendance.getStartLocationResults().equals(Constant.LOCATION_RESULTS_NORMAL)) {
                map.put("开始位置结果","范围内");
            } else if(ObjectUtils.isNotEmpty(attendance.getStartLocationResults()) && attendance.getStartLocationResults().equals(Constant.LOCATION_RESULTS_OUTSIDE)) {
                map.put("开始位置结果","范围外");
            } else{
                map.put("开始位置结果","未打卡");
            }
            //开始打卡判断
            if(ObjectUtils.isNotEmpty(attendance.getStartClockResults()) && attendance.getStartClockResults().equals(Constant.ATTENDANCE_STATE_WAITFOR)) {
                map.put("开始打卡结果","等待");
            } else if(ObjectUtils.isNotEmpty(attendance.getStartClockResults()) && attendance.getStartClockResults().equals(Constant.ATTENDANCE_STATE_NORMAL)){
                map.put("开始打卡结果","正常");
            } else if(ObjectUtils.isNotEmpty(attendance.getStartClockResults()) && attendance.getStartClockResults().equals(Constant.ATTENDANCE_STATE_NOTSIGNED)){
                map.put("开始打卡结果","缺卡");
            } else if(ObjectUtils.isNotEmpty(attendance.getStartClockResults()) && attendance.getStartClockResults().equals(Constant.ATTENDANCE_STATE_GOOUT)){
                map.put("开始打卡结果","外出");
            } else if(ObjectUtils.isNotEmpty(attendance.getStartClockResults()) && attendance.getStartClockResults().equals(Constant.ATTENDANCE_STATE_BUSINESS)){
                map.put("开始打卡结果","出差");
            } else if(ObjectUtils.isNotEmpty(attendance.getStartClockResults()) && attendance.getStartClockResults().equals(Constant.ATTENDANCE_STATE_LEAVE)){
                map.put("开始打卡结果","请假");
            }
            map.put("开始位置结果",startLocationResults);
            map.put("开始打卡结果",startClockResults);
            map.put("排班工作结束时间", attendance.getRosteringWorkEndTime());
            map.put("实际工作结束时间", attendance.getActualWorkEndTime());
            //结束位置判断
            if(ObjectUtils.isNotEmpty(attendance.getEndLocationResults()) && attendance.getEndLocationResults().equals(Constant.LOCATION_RESULTS_NORMAL)) {
                map.put("结束位置结果","范围内");
            } else if(ObjectUtils.isNotEmpty(attendance.getEndLocationResults()) && attendance.getEndLocationResults().equals(Constant.LOCATION_RESULTS_OUTSIDE)) {
                map.put("结束位置结果","范围外");
            } else{
                map.put("结束位置结果","未打卡");
            }
            //结束打卡判断
            if(ObjectUtils.isNotEmpty(attendance.getEndClockResults()) && attendance.getEndClockResults().equals(Constant.ATTENDANCE_STATE_WAITFOR)) {
                map.put("结束打卡结果","等待");
            } else if(ObjectUtils.isNotEmpty(attendance.getEndClockResults()) && attendance.getEndClockResults().equals(Constant.ATTENDANCE_STATE_NORMAL)){
                map.put("结束打卡结果","正常");
            } else if(ObjectUtils.isNotEmpty(attendance.getEndClockResults()) && attendance.getEndClockResults().equals(Constant.ATTENDANCE_STATE_NOTSIGNED)){
                map.put("结束打卡结果","缺卡");
            } else if(ObjectUtils.isNotEmpty(attendance.getEndClockResults()) && attendance.getEndClockResults().equals(Constant.ATTENDANCE_STATE_GOOUT)){
                map.put("结束打卡结果","外出");
            } else if(ObjectUtils.isNotEmpty(attendance.getEndClockResults()) && attendance.getEndClockResults().equals(Constant.ATTENDANCE_STATE_BUSINESS)){
                map.put("结束打卡结果","出差");
            } else if(ObjectUtils.isNotEmpty(attendance.getEndClockResults()) && attendance.getEndClockResults().equals(Constant.ATTENDANCE_STATE_LEAVE)){
                map.put("结束打卡结果","请假");
            }
            //日期类型判断
            if(attendance.getDateType().equals(Constant.DATE_TYPE_WEEKDAY)){
                map.put("日期类型","工作日");
            } else if(attendance.getDateType().equals(Constant.DATE_TYPE_HOLIDAYS)){
                map.put("日期类型","节假日(串休)");
            } else{
                map.put("日期类型","节假日(法定)");
            }
            map.put("结束位置结果",endLocationResults);
            map.put("结束打卡结果",endClockResults);
            map.put("日期类型",dateType);
            map.put("备注", attendance.getRemarks());
            map.put("创建者", attendance.getCreateBy());
            map.put("创建时间", attendance.getCreateTime());