diff --git a/src/main/java/com/zhgd/xmgl/modules/worker/mapper/xml/WorkerMonthAttendanceDurationMapper.xml b/src/main/java/com/zhgd/xmgl/modules/worker/mapper/xml/WorkerMonthAttendanceDurationMapper.xml index f0963993f..41a48c46a 100644 --- a/src/main/java/com/zhgd/xmgl/modules/worker/mapper/xml/WorkerMonthAttendanceDurationMapper.xml +++ b/src/main/java/com/zhgd/xmgl/modules/worker/mapper/xml/WorkerMonthAttendanceDurationMapper.xml @@ -49,5 +49,11 @@ and w1.department_id=#{departmentId} + + AND st.query_time >= DATE_FORMAT(#{startTime}, "%Y-%m") + + + and st.query_time <= DATE_FORMAT(#{endTime}, "%Y-%m") + - \ No newline at end of file + diff --git a/src/main/java/com/zhgd/xmgl/modules/worker/service/impl/WorkerAttendanceServiceImpl.java b/src/main/java/com/zhgd/xmgl/modules/worker/service/impl/WorkerAttendanceServiceImpl.java index c28898122..7a9de9877 100644 --- a/src/main/java/com/zhgd/xmgl/modules/worker/service/impl/WorkerAttendanceServiceImpl.java +++ b/src/main/java/com/zhgd/xmgl/modules/worker/service/impl/WorkerAttendanceServiceImpl.java @@ -5,13 +5,10 @@ import cn.hutool.core.collection.CollUtil; import cn.hutool.core.date.DateUtil; import cn.hutool.core.exceptions.ExceptionUtil; import cn.hutool.core.io.FileUtil; +import cn.hutool.core.util.NumberUtil; import cn.xuyanwu.spring.file.storage.FileInfo; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; -//import com.arcsoft.face.FaceFeature; -//import com.arcsoft.face.FaceInfo; -//import com.arcsoft.face.FaceSimilar; -//import com.arcsoft.face.toolkit.ImageInfo; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; @@ -139,6 +136,8 @@ public class WorkerAttendanceServiceImpl extends ServiceImpl viewDayAttendanceList(Map map) { @@ -315,7 +314,7 @@ public class WorkerAttendanceServiceImpl extends ServiceImpl -1) { + if (entTime.indexOf(Cts.COMMA + hour + Cts.COMMA) > -1) { type = 1; } else { type = 2; @@ -373,10 +372,66 @@ public class WorkerAttendanceServiceImpl extends ServiceImpl map1 = new HashMap<>(16); + map1.put("heads", heads1); + map1.put("headsStr", headsStr1); + map1.put("dataList", list); + map1.put("sheetName", MapUtils.getString(map, "monthTime") + "单位工时汇总"); + List> sheetList = new ArrayList<>(); + sheetList.add(map1); + + List durationList = workerMonthAttendanceDurationMapper.getMonthWorkerAttendanceDurationList(map); + Map dataList4Map = new HashMap<>(); + for (Map demo : durationList) { + BigDecimal min = new BigDecimal("0"); + for (int i = 1; i <= 31; i++) { + //1、正常 2、迟到 3、早退 4、加班5、缺卡 + if (demo.get("day" + i) != null) { + if (DateUtil.compare(DateUtil.parse(MapUtils.getString(demo, "queryTime") + "-" + i), DateUtil.parse(MapUtils.getString(map, "startTime"))) >= 0 + && DateUtil.compare(DateUtil.parse(MapUtils.getString(demo, "queryTime") + "-" + i), DateUtil.parse(MapUtils.getString(map, "endTime"))) <= 0 + && Integer.valueOf(demo.get("day" + i).toString()) > 0) { + int minuteTime = Integer.valueOf(demo.get("day" + i).toString()).intValue(); + min = NumberUtil.add(min, new BigDecimal(minuteTime)); + } + } + } + String enterpriseName = MapUtils.getString(demo, "enterpriseName"); + BigDecimal d = dataList4Map.get(enterpriseName); + if (d == null) { + d = new BigDecimal("0"); + } else { + d = NumberUtil.add(d, min); + } + dataList4Map.put("enterpriseName", d); + } + List> dataList4 = dataList4Map.entrySet().stream().map(o -> { + Map m = new HashMap<>(); + m.put("enterpriseName", o.getKey()); + int minuteTime = o.getValue().intValue(); + if (minuteTime == 0) { + m.put("total", 0); + } else { + int hours = (int) Math.floor(minuteTime / 60); + int minute = minuteTime % 60; + m.put("total", hours + "小时" + minute + "分钟"); + } + return m; + }).collect(Collectors.toList()); + String[] heads2 = {"所属单位", "工时总和"}; + String[] headsStr2 = {"enterpriseName", "total"}; + Map map2 = new HashMap<>(16); + map2.put("heads", heads2); + map2.put("headsStr", headsStr2); + map2.put("dataList", list); + map2.put("sheetName", "单位工时汇总"); + sheetList.add(map2); + JxlExcelUtils.excelManySheetExport("考勤明细列表", sheetList, response); } catch (Exception e) { log.error("error:", e); } diff --git a/src/main/java/com/zhgd/xmgl/modules/worker/service/impl/WorkerMonthAttendanceStatisticsServiceImpl.java b/src/main/java/com/zhgd/xmgl/modules/worker/service/impl/WorkerMonthAttendanceStatisticsServiceImpl.java index b766d5357..384e67755 100644 --- a/src/main/java/com/zhgd/xmgl/modules/worker/service/impl/WorkerMonthAttendanceStatisticsServiceImpl.java +++ b/src/main/java/com/zhgd/xmgl/modules/worker/service/impl/WorkerMonthAttendanceStatisticsServiceImpl.java @@ -1,6 +1,7 @@ package com.zhgd.xmgl.modules.worker.service.impl; import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.NumberUtil; import cn.hutool.core.util.ObjectUtil; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; @@ -21,7 +22,6 @@ import com.zhgd.xmgl.util.DateUtils; import com.zhgd.xmgl.util.EnvironmentUtil; import com.zhgd.xmgl.util.JxlExcelUtils; import com.zhgd.xmgl.util.ReflectUtils; -import lombok.extern.log4j.Log4j; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections.MapUtils; import org.apache.commons.lang.math.NumberUtils; @@ -31,6 +31,7 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import javax.servlet.http.HttpServletResponse; +import java.math.BigDecimal; import java.text.SimpleDateFormat; import java.util.*; import java.util.stream.Collectors; @@ -469,6 +470,49 @@ public class WorkerMonthAttendanceStatisticsServiceImpl extends ServiceImpl dataList4Map = new HashMap<>(); + for (Map demo : durationList) { + BigDecimal min = new BigDecimal("0"); + for (int i = 1; i <= maxDate; i++) { + //1、正常 2、迟到 3、早退 4、加班5、缺卡 + if (demo.get("day" + i) != null) { + if (Integer.valueOf(demo.get("day" + i).toString()) > 0) { + int minuteTime = Integer.valueOf(demo.get("day" + i).toString()).intValue(); + min = NumberUtil.add(min, new BigDecimal(minuteTime)); + } + } + } + String enterpriseName = MapUtils.getString(demo, "enterpriseName"); + BigDecimal d = dataList4Map.get(enterpriseName); + if (d == null) { + d = new BigDecimal("0"); + } else { + d = NumberUtil.add(d, min); + } + dataList4Map.put("enterpriseName", d); + } + List> dataList4 = dataList4Map.entrySet().stream().map(o -> { + Map m = new HashMap<>(); + m.put("enterpriseName", o.getKey()); + int minuteTime = o.getValue().intValue(); + if (minuteTime == 0) { + m.put("total", 0); + } else { + int hours = (int) Math.floor(minuteTime / 60); + int minute = minuteTime % 60; + m.put("total", hours + "小时" + minute + "分钟"); + } + return m; + }).collect(Collectors.toList()); + Map map4 = new HashMap<>(16); + map4.put("heads", heads4); + map4.put("headsStr", headsStr4); + map4.put("dataList", dataList4); + map4.put("sheetName", MapUtils.getString(map, "monthTime") + "单位工时汇总"); + sheetList.add(map4); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); String excelName = "考勤统计-" + sdf.format(new Date()); JxlExcelUtils.excelManySheetExport(excelName, sheetList, response);