diff --git a/src/main/java/com/zhgd/xmgl/modules/realnamestatistics/entity/vo/WorkerAttendanceVo.java b/src/main/java/com/zhgd/xmgl/modules/realnamestatistics/entity/vo/WorkerAttendanceVo.java index be18c881d..e5f41d991 100644 --- a/src/main/java/com/zhgd/xmgl/modules/realnamestatistics/entity/vo/WorkerAttendanceVo.java +++ b/src/main/java/com/zhgd/xmgl/modules/realnamestatistics/entity/vo/WorkerAttendanceVo.java @@ -83,5 +83,11 @@ public class WorkerAttendanceVo { private String mockTime; private String enterpriseId; private String enterpriseName; + /** + * 人员id + */ + @ApiModelProperty(value = "人员id") + private java.lang.Long workerId; + } diff --git a/src/main/java/com/zhgd/xmgl/modules/safetyhat/service/impl/SafetyHatDataDailyStatisticsServiceImpl.java b/src/main/java/com/zhgd/xmgl/modules/safetyhat/service/impl/SafetyHatDataDailyStatisticsServiceImpl.java index d5d27a439..58efa0d63 100644 --- a/src/main/java/com/zhgd/xmgl/modules/safetyhat/service/impl/SafetyHatDataDailyStatisticsServiceImpl.java +++ b/src/main/java/com/zhgd/xmgl/modules/safetyhat/service/impl/SafetyHatDataDailyStatisticsServiceImpl.java @@ -73,7 +73,7 @@ public class SafetyHatDataDailyStatisticsServiceImpl extends ServiceImpl devSn2WorkerMap = safetyHatDevService.list(new LambdaQueryWrapper() - .eq(SafetyHatDev::getProjectSn, projectSn)).stream().collect(Collectors.toMap(SafetyHatDev::getDevSn, SafetyHatDev::getWorkerInfoId, (o1, o2) -> o1)); + .eq(SafetyHatDev::getProjectSn, projectSn)).stream().filter(d -> Objects.nonNull(d.getDevSn()) && Objects.nonNull(d.getWorkerInfoId())).collect(Collectors.toMap(SafetyHatDev::getDevSn, SafetyHatDev::getWorkerInfoId, (o1, o2) -> o1)); //实时计算 ArrayList vos = new ArrayList<>(); List fences = safetyHatFenceService.list(new LambdaQueryWrapper().eq(SafetyHatFence::getProjectSn, projectSn)); diff --git a/src/main/java/com/zhgd/xmgl/modules/worker/controller/WorkerDailyAttendanceStatisticsV2Controller.java b/src/main/java/com/zhgd/xmgl/modules/worker/controller/WorkerDailyAttendanceStatisticsV2Controller.java index f5c54988d..6498258dc 100644 --- a/src/main/java/com/zhgd/xmgl/modules/worker/controller/WorkerDailyAttendanceStatisticsV2Controller.java +++ b/src/main/java/com/zhgd/xmgl/modules/worker/controller/WorkerDailyAttendanceStatisticsV2Controller.java @@ -22,13 +22,16 @@ import com.zhgd.xmgl.async.AsyncAttendance; import com.zhgd.xmgl.base.entity.vo.echarts.ChartDataVo; import com.zhgd.xmgl.modules.project.entity.Project; import com.zhgd.xmgl.modules.project.service.IProjectService; +import com.zhgd.xmgl.modules.worker.entity.EnterpriseInfo; import com.zhgd.xmgl.modules.worker.entity.WorkerAttendance; import com.zhgd.xmgl.modules.worker.entity.WorkerDailyAttendanceStatisticsV2; import com.zhgd.xmgl.modules.worker.entity.WorkerInfo; +import com.zhgd.xmgl.modules.worker.entity.bo.ExportWorkerDailyAttendancesStaticsByDepartmentTeamXlsBo; import com.zhgd.xmgl.modules.worker.entity.dto.WorkerDailyAttendanceStatisticsV2Dto; import com.zhgd.xmgl.modules.worker.entity.vo.*; import com.zhgd.xmgl.modules.worker.service.IWorkerAttendanceService; import com.zhgd.xmgl.modules.worker.service.IWorkerDailyAttendanceStatisticsV2Service; +import com.zhgd.xmgl.modules.worker.service.impl.EnterpriseInfoServiceImpl; import com.zhgd.xmgl.modules.worker.service.impl.WorkerInfoServiceImpl; import com.zhgd.xmgl.security.util.SecurityUtils; import com.zhgd.xmgl.util.EasyPoiUtil; @@ -43,6 +46,7 @@ import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections.MapUtils; import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.ss.util.CellRangeAddress; +import org.jetbrains.annotations.Nullable; import org.simpleframework.xml.core.Validate; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Lazy; @@ -76,6 +80,9 @@ public class WorkerDailyAttendanceStatisticsV2Controller { @Lazy @Autowired IProjectService projectService; + @Autowired + @Lazy + EnterpriseInfoServiceImpl enterpriseInfoService; @Lazy @Autowired private IWorkerDailyAttendanceStatisticsV2Service workerDailyAttendanceStatisticsV2Service; @@ -250,6 +257,15 @@ public class WorkerDailyAttendanceStatisticsV2Controller { vo.setDailyDayMap(dailyDayMap); vo.setDailyAttendanceMap(dailyAttendanceMap); vo.setPersonSn(workerInfo.getPersonSn()); + vo.setWorkerId(workerInfo.getId()); + vo.setWorkerTypeName(workerInfo.getTypeName()); + vo.setPhoneNumber(workerInfo.getPhoneNumber()); + vo.setIdCard(workerInfo.getIdCard()); + vo.setSex(workerInfo.getSex()); + vo.setEnterDate(workerInfo.getEnterDate()); + vo.setProjectSn(workerInfo.getProjectSn()); + vo.setPayRollBankName(workerInfo.getPayRollBankName()); + vo.setPayRollBankNumber(workerInfo.getPayRollBankNumber()); vos.add(vo); } IPage p = new Page<>(); @@ -553,7 +569,7 @@ public class WorkerDailyAttendanceStatisticsV2Controller { vo.setPersonType(workerInfo.getPersonType()); vo.setEnterpriseName(workerInfo.getEnterpriseName()); vo.setWorkerName(workerInfo.getWorkerName()); - vo.setDeptName(workerInfo.getDepartmentName()); + vo.setDeptName(Objects.equals(workerInfo.getPersonType(), 1) ? workerInfo.getTeamName() : workerInfo.getDepartmentName()); vo.setProjectSn(workerInfo.getProjectSn()); vo.setPersonSn(workerInfo.getPersonSn()); vo.setAttendanceDate(DateUtil.parseDate(attendanceDate)); @@ -571,14 +587,10 @@ public class WorkerDailyAttendanceStatisticsV2Controller { } List attendances = personSn2AttendancesMap.get(workerInfo.getPersonSn()); if (Objects.equals(vo.getIsAttendance(), 1) && CollUtil.isNotEmpty(attendances)) { - String firstInTime = attendances.stream().filter(w -> Objects.equals(w.getPassType(), 1)).min(Comparator.comparing(WorkerAttendance::getCreateTime)).map(WorkerAttendance::getCreateTime).orElse(null); - String endOutTime = attendances.stream().filter(w -> Objects.equals(w.getPassType(), 2)).max(Comparator.comparing(WorkerAttendance::getCreateTime)).map(WorkerAttendance::getCreateTime).orElse(null); - vo.setFirstInTime(firstInTime); - vo.setEndOutTime(endOutTime); - String firstTimeAm = attendances.stream().filter(w -> DateUtil.compare(DateUtil.parseDateTime(w.getCreateTime()), DateUtil.parseDateTime(attendanceDate + " 12:00:00")) < 0).min(Comparator.comparing(WorkerAttendance::getCreateTime)).map(WorkerAttendance::getCreateTime).orElse(null); - vo.setFirstTimeAm(firstTimeAm); - String endTimePm = attendances.stream().filter(w -> DateUtil.compare(DateUtil.parseDateTime(w.getCreateTime()), DateUtil.parseDateTime(attendanceDate + " 12:00:00")) >= 0).max(Comparator.comparing(WorkerAttendance::getCreateTime)).map(WorkerAttendance::getCreateTime).orElse(null); - vo.setEndTimePm(endTimePm); + vo.setFirstInTime(Optional.ofNullable(getFirstInTime(attendances)).map(WorkerAttendance::getCreateTime).orElse(null)); + vo.setEndOutTime(Optional.ofNullable(getEndOutTime(attendances)).map(WorkerAttendance::getCreateTime).orElse(null)); + vo.setFirstTimeAm(Optional.ofNullable(getFirstTimeAm(attendances)).map(WorkerAttendance::getCreateTime).orElse(null)); + vo.setEndTimePm(Optional.ofNullable(getEndTimePm(attendances)).map(WorkerAttendance::getCreateTime).orElse(null)); vo.setAttendanceList(attendances); } vo.setWorkerId(workerInfo.getId()); @@ -592,6 +604,50 @@ public class WorkerDailyAttendanceStatisticsV2Controller { return p; } + /** + * 下午打卡(未次) + * + * @param attendances + * @return + */ + @Nullable + private WorkerAttendance getEndTimePm(List attendances) { + return attendances.stream().filter(w -> DateUtil.compare(DateUtil.parseDateTime(w.getCreateTime()), DateUtil.parseDateTime(w.getCreateTime().substring(0, 10) + " 12:00:00")) >= 0) + .max(Comparator.comparing(WorkerAttendance::getCreateTime)).orElse(null); + } + + /** + * 上午打卡(首次) + * + * @param attendances + * @return + */ + @Nullable + private WorkerAttendance getFirstTimeAm(List attendances) { + return attendances.stream().filter(w -> DateUtil.compare(DateUtil.parseDateTime(w.getCreateTime()), DateUtil.parseDateTime(w.getCreateTime().substring(0, 10) + " 12:00:00")) < 0) + .min(Comparator.comparing(WorkerAttendance::getCreateTime)).orElse(null); + } + + /** + * 获取出场打卡(末次) + * + * @param attendances + * @return + */ + private WorkerAttendance getEndOutTime(List attendances) { + return attendances.stream().filter(w -> Objects.equals(w.getPassType(), 2)).max(Comparator.comparing(WorkerAttendance::getCreateTime)).orElse(null); + } + + /** + * 获取进场打卡(首次) + * + * @param attendances + * @return + */ + private WorkerAttendance getFirstInTime(List attendances) { + return attendances.stream().filter(w -> Objects.equals(w.getPassType(), 1)).min(Comparator.comparing(WorkerAttendance::getCreateTime)).orElse(null); + } + @ApiOperation(value = "统计考勤日报", notes = "统计考勤日报", httpMethod = "POST") @ApiImplicitParams({ @ApiImplicitParam(name = "projectSn", value = "项目sn", paramType = "body", required = true, dataType = "String"), @@ -774,141 +830,372 @@ public class WorkerDailyAttendanceStatisticsV2Controller { @ApiImplicitParam(name = "startDate", value = "开始日期(yyyy-MM-dd)", paramType = "body", required = true, dataType = "String"), @ApiImplicitParam(name = "endDate", value = "结束日期(yyyy-MM-dd)", paramType = "body", required = true, dataType = "String"), @ApiImplicitParam(name = "groupByType", value = "1.按项目;2.按参建单位;3.按班组/部门;4.按人员", paramType = "body", required = true, dataType = "String"), - @ApiImplicitParam(name = "downloadType", value = "1上下午打卡2进出场打卡", paramType = "body", required = false, dataType = "String"), - @ApiImplicitParam(name = "effectiveHour", value = "有效工时", paramType = "body", required = false, dataType = "String"), + @ApiImplicitParam(name = "downloadType", value = "1每日明细(上下午打卡)2进出场打卡3每日工时4每日明细", paramType = "body", required = false, dataType = "String"), + @ApiImplicitParam(name = "hourValBegin", value = "大于有效工时", paramType = "body", required = false, dataType = "String"), + @ApiImplicitParam(name = "enterpriseId", value = "单位id", paramType = "body", required = false, dataType = "String"), }) @PostMapping(value = "/exportWorkerDailyAttendancesStaticsByMonthXls") public void exportWorkerDailyAttendancesStaticsByMonthXls(HttpServletResponse response, @RequestBody HashMap param) { -// String templateUrl = null; -// try { -// String projectSn = MapUtils.getString(param, "projectSn"); -// String startDate = MapUtils.getString(param, "startDate"); -// String endDate = MapUtils.getString(param, "endDate"); -// Integer downloadType = MapUtils.getInteger(param, "downloadType"); -// Integer groupByType = MapUtils.getInteger(param, "groupByType"); -// List dateTimes = DateUtil.rangeToList(DateUtil.parseDate(startDate), DateUtil.parseDate(endDate), DateField.DAY_OF_YEAR); -// Map> root = new HashMap<>(); -// if (Objects.equals(groupByType, 3)) { -// //按班组/部门 -// if (Objects.equals(downloadType, 1)) { -// //考勤月报-按班组-每日出入(打卡记录明细).xlsx -// param.put("startTime", startDate); -// param.put("endTime", endDate); -// param.put("pageSize", -1); -// List voList = this.doCountDailyAttendanceByDateRange(param).getRecords(); -// Map> deptNameMap = voList.stream().collect(Collectors.groupingBy(StatisticsListVo::getDeptName)); -// Map sheetMap = new HashMap<>(); -// List> listMap = new ArrayList<>(); -// for (Map.Entry> entry : deptNameMap.entrySet()) { -// int j = 0; -// for (StatisticsListVo vo : entry.getValue()) { -// Map map = new HashMap<>(); -// map.put("firstInTimeYes", StrUtil.isNotBlank(vo.getFirstInTime()) ? "√" : "×"); -// map.put("firstInTime", vo.getFirstInTime()); -// map.put("endOutTimeYes", StrUtil.isNotBlank(vo.getEndOutTime()) ? "√" : "×"); -// map.put("endOutTime", vo.getEndOutTime()); -// map.put("firstTimeAmYes", StrUtil.isNotBlank(vo.getFirstTimeAm()) ? "√" : "×"); -// map.put("firstTimeAm", vo.getFirstTimeAm()); -// map.put("endTimePmYes", StrUtil.isNotBlank(vo.getEndTimePm()) ? "√" : "×"); -// map.put("endTimePm", vo.getEndTimePm()); -// map.put("personType", vo.getPersonType()); -// map.put("enterpriseName", vo.getEnterpriseName()); -// map.put("workerName", vo.getWorkerName()); -// map.put("deptName", vo.getDeptName()); -// map.put("projectSn", vo.getProjectSn()); -// map.put("personSn", vo.getPersonSn()); -// map.put("attendanceDate", vo.getAttendanceDate()); -// map.put("hourVal", vo.getHourVal()); -// map.put("dayVal", vo.getDayVal()); -// map.put("isAttendance", vo.getIsAttendance()); -// map.put("overtimeHourVal", vo.getOvertimeHourVal()); -// map.put("overtimeDayVal", vo.getOvertimeDayVal()); -// map.put("inserviceType", vo.getInserviceType()); -// AtomicInteger i = new AtomicInteger(1); -// map.put("attendanceList", Objects.nonNull(vo.getAttendanceList()) ? vo.getAttendanceList().stream().map(a -> { -// return i.getAndIncrement() + ".(" + (Objects.equals(a.getPassType(), 1) ? "进场" : "出场") + a.getCreateTime() + ")"; -// }).collect(Collectors.joining("\n")) : ""); -// map.put("workerTypeName", vo.getWorkerTypeName()); -// map.put("phoneNumber", vo.getPhoneNumber()); -// map.put("idCard", vo.getIdCard()); -// map.put("sex", Objects.equals(vo.getSex(), 1) ? "男" : "女"); -// map.put("enterDate", vo.getEnterDate()); -// listMap.add(map); -// } -// } -// sheetMap.put("date", DateUtil.formatDate(dateTime)); -// sheetMap.put("listMap", listMap); -// root.put(j++, sheetMap); -// } -// } -// -// param.put("pageNo", 1); -// param.put("pageSize", -1); -// int j = 0; -// String tempSheetName; -// if (Objects.equals(downloadType, 1)) { -// tempSheetName = "考勤日报-出勤导出模版(上午下午).xlsx"; -// } else { -// tempSheetName = "考勤日报-出勤导出模版(进场出场).xlsx"; -// } -// for (DateTime dateTime : dateTimes) { -// param.put("attendanceDate", DateUtil.formatDate(dateTime)); -// List records = doGetWorkerDailyAttendancePageByDateVoIPage(param).getRecords(); -// Map sheetMap = new HashMap<>(); -// List> listMap = new ArrayList<>(); -// for (WorkerDailyAttendancesByDateVo vo : records) { -// Map map = new HashMap<>(); -// map.put("firstInTimeYes", StrUtil.isNotBlank(vo.getFirstInTime()) ? "√" : "×"); -// map.put("firstInTime", vo.getFirstInTime()); -// map.put("endOutTimeYes", StrUtil.isNotBlank(vo.getEndOutTime()) ? "√" : "×"); -// map.put("endOutTime", vo.getEndOutTime()); -// map.put("firstTimeAmYes", StrUtil.isNotBlank(vo.getFirstTimeAm()) ? "√" : "×"); -// map.put("firstTimeAm", vo.getFirstTimeAm()); -// map.put("endTimePmYes", StrUtil.isNotBlank(vo.getEndTimePm()) ? "√" : "×"); -// map.put("endTimePm", vo.getEndTimePm()); -// map.put("personType", vo.getPersonType()); -// map.put("enterpriseName", vo.getEnterpriseName()); -// map.put("workerName", vo.getWorkerName()); -// map.put("deptName", vo.getDeptName()); -// map.put("projectSn", vo.getProjectSn()); -// map.put("personSn", vo.getPersonSn()); -// map.put("attendanceDate", vo.getAttendanceDate()); -// map.put("hourVal", vo.getHourVal()); -// map.put("dayVal", vo.getDayVal()); -// map.put("isAttendance", vo.getIsAttendance()); -// map.put("overtimeHourVal", vo.getOvertimeHourVal()); -// map.put("overtimeDayVal", vo.getOvertimeDayVal()); -// map.put("inserviceType", vo.getInserviceType()); -// AtomicInteger i = new AtomicInteger(1); -// map.put("attendanceList", Objects.nonNull(vo.getAttendanceList()) ? vo.getAttendanceList().stream().map(a -> { -// return i.getAndIncrement() + ".(" + (Objects.equals(a.getPassType(), 1) ? "进场" : "出场") + a.getCreateTime() + ")"; -// }).collect(Collectors.joining("\n")) : ""); -// map.put("workerTypeName", vo.getWorkerTypeName()); -// map.put("phoneNumber", vo.getPhoneNumber()); -// map.put("idCard", vo.getIdCard()); -// map.put("sex", Objects.equals(vo.getSex(), 1) ? "男" : "女"); -// map.put("enterDate", vo.getEnterDate()); -// listMap.add(map); -// } -// sheetMap.put("date", DateUtil.formatDate(dateTime)); -// sheetMap.put("listMap", listMap); -// root.put(j++, sheetMap); -// } -// templateUrl = Fileutils.getExportTemplateFile("excel/" + tempSheetName).getAbsolutePath(); -// String outputTemplateFilePath = PathUtil.getBasePath() + "/temp/" + IdUtil.randomUUID() + ".xlsx"; -// EasyPoiUtil.cloneSheetMultipleTimes(templateUrl, outputTemplateFilePath, "1", dateTimes.size() - 1); -// TemplateExportParams params = new TemplateExportParams(outputTemplateFilePath, true); -// params.setSheetName(dateTimes.stream().map(DateUtil::formatDate).collect(Collectors.toList()).toArray(new String[]{})); -// Workbook workbook = ExcelExportUtil.exportExcel(root, params); -// //设置下拉 -// ExcelUtils.downLoadExcel(tempSheetName, response, workbook); -// } catch (IOException e) { -// log.error("", e); -// throw new OpenAlertException("系统错误"); -// } finally { -// if (templateUrl != null) { -// FileUtil.deleteFile(templateUrl); -// } -// } + String templateUrl = null; + try { + String projectSn = MapUtils.getString(param, "projectSn"); + Project project = projectService.getOne(new LambdaQueryWrapper() + .eq(Project::getProjectSn, projectSn)); + String startDate = MapUtils.getString(param, "startDate"); + String endDate = MapUtils.getString(param, "endDate"); + Integer downloadType = MapUtils.getInteger(param, "downloadType"); + Integer groupByType = MapUtils.getInteger(param, "groupByType"); + List dateTimes = DateUtil.rangeToList(DateUtil.parseDate(startDate), DateUtil.parseDate(endDate), DateField.DAY_OF_YEAR); + Map> root = new HashMap<>(); + int sheetIndex = 0; + List sheetNames = new ArrayList<>(); + String tempSheetName; + if (Objects.equals(groupByType, 3)) { + //按班组/部门 + tempSheetName = "考勤月报-按班组.xlsx"; + //考勤月报-按班组.xlsx + param.put("startTime", startDate); + param.put("endTime", endDate); + param.put("pageSize", -1); + List voList = this.doCountDailyAttendanceByDateRange(param).getRecords(); + Map> deptNameMap = voList.stream().collect(Collectors.groupingBy(StatisticsListVo::getDeptName)); + Map>> personSn2Date2AttendancesMap = workerAttendanceService.list(new LambdaQueryWrapper() + .eq(WorkerAttendance::getProjectSn, projectSn) + .ge(WorkerAttendance::getCreateTime, startDate) + .le(WorkerAttendance::getCreateTime, DateUtil.formatDateTime(DateUtil.endOfDay(DateUtil.parseDate(endDate)))) + .select(WorkerAttendance::getPersonSn, WorkerAttendance::getCreateTime, WorkerAttendance::getPassType)) + .stream().filter(w -> Objects.nonNull(w.getPersonSn())).collect(Collectors.groupingBy(WorkerAttendance::getPersonSn, + Collectors.groupingBy(o -> DateUtil.formatDate(DateUtil.parseDate(o.getCreateTime())), + Collectors.toList()))); + BigDecimal totalAttendanceDay = BigDecimal.ZERO; + BigDecimal totalHour = BigDecimal.ZERO; + for (Map.Entry> entry : deptNameMap.entrySet()) { + Map sheetMap = new HashMap<>(); + List> listMap = new ArrayList<>(); + List vos = entry.getValue(); + int index = 0; + for (StatisticsListVo vo : vos) { + Map map = new HashMap<>(); + map.put("no", ++index); + map.put("personType", vo.getPersonType()); + map.put("enterpriseName", vo.getEnterpriseName()); + map.put("workerName", vo.getWorkerName()); + map.put("deptName", vo.getDeptName()); + map.put("projectSn", vo.getProjectSn()); + map.put("personSn", vo.getPersonSn()); + map.put("workerTypeName", vo.getWorkerTypeName()); + map.put("phoneNumber", vo.getPhoneNumber()); + map.put("idCard", vo.getIdCard()); + map.put("sex", Objects.equals(vo.getSex(), 1) ? "男" : "女"); + map.put("enterDate", vo.getEnterDate()); + for (int z = 0; z < dateTimes.size(); z++) { + DateTime dateTime = dateTimes.get(z); + sheetMap.put("date" + (z + 1), DateUtil.format(dateTime, "M/d")); + sheetMap.put("delete" + (z + 1), false); + String value; + if (Objects.equals(downloadType, 1) || Objects.equals(downloadType, 2)) { + value = getExcelAmPmAttendanceByDate(personSn2Date2AttendancesMap, vo, dateTime, downloadType); + } else if (Objects.equals(downloadType, 3)) { + //每日工时 + value = Optional.ofNullable(vo.getDailyHourMap().get(DateUtil.formatDate(dateTime))).map(decimal -> decimal.toString()).orElse(""); + } else { + //每日明细 + value = Optional.ofNullable(vo.getDailyAttendanceMap().get(DateUtil.formatDate(dateTime))).map(integer -> Objects.equals(integer, 1) ? "√" : "×").orElse("x"); + } + map.put("attendanceByDate" + (z + 1), value); + } + for (int i = dateTimes.size(); i < 31; i++) { + sheetMap.put("delete" + (i + 1), true); + } + map.put("totalHour", vo.getTotalHour()); + map.put("totalAttendanceDay", vo.getTotalAttendanceDay()); + totalAttendanceDay = NumberUtil.add(vo.getTotalAttendanceDay(), totalAttendanceDay); + totalHour = NumberUtil.add(vo.getTotalHour(), totalHour); + listMap.add(map); + } + sheetMap.put("listMap", listMap); + sheetMap.put("projectName", project.getProjectName()); + StatisticsListVo vo = CollUtil.getFirst(vos); + sheetMap.put("title", StrUtil.format("项目名称:{} 参建单位名称:{} {}名称:{} 总人数:{} 时间:({} - {})", + project.getProjectName(), vo.getEnterpriseName(), vo.getPersonType() == 1 ? "班组" : "部门", vo.getDeptName(), vos.size(), startDate, endDate)); + sheetMap.put("totalAttendanceDay", totalAttendanceDay); + sheetMap.put("totalHour", totalHour); + root.put(sheetIndex++, sheetMap); + sheetNames.add(entry.getKey()); + } + templateUrl = Fileutils.getExportTemplateFile("excel/workerDailyAttendanceStatisticsV2/" + tempSheetName).getAbsolutePath(); + String outputTemplateFilePath = PathUtil.getBasePath() + "/temp/" + IdUtil.randomUUID() + ".xlsx"; + EasyPoiUtil.cloneSheetMultipleTimes(templateUrl, outputTemplateFilePath, "1", sheetNames.size() - 1); + TemplateExportParams params = new TemplateExportParams(outputTemplateFilePath, true); + params.setSheetName(sheetNames.toArray(new String[]{})); + Workbook workbook = ExcelExportUtil.exportExcel(root, params); + ExcelUtils.downLoadExcel(tempSheetName, response, workbook); + } else if (Objects.equals(groupByType, 2)) { + //按参建单位 + tempSheetName = "考勤月报-按单位-出勤人数与考勤报表.xlsx"; + //导出sheet1上海振南出勤人数 + List list = workerDailyAttendanceStatisticsV2Service.countExportWorkerDailyAttendancesStaticsByDepartmentTeamXlsBo(param); + Map> date2Map = list.stream().collect(Collectors.groupingBy(ExportWorkerDailyAttendancesStaticsByDepartmentTeamXlsBo::getDate)); + Map sheetMap1 = new HashMap<>(); + List> colList = new ArrayList>(); + List> listMap1 = new ArrayList<>(); + Integer totalGlNum = 0; + Integer totalSgNum = 0; + Map deptKeyMap = new HashMap<>(); + for (Map.Entry> entry : date2Map.entrySet()) { + int index = 0; + Map map = new HashMap<>(); + map.put("no", ++index); + map.put("date", entry.getKey()); + Integer glNum = 0; + Integer sgNum = 0; + for (ExportWorkerDailyAttendancesStaticsByDepartmentTeamXlsBo bo : entry.getValue()) { + Map e = new HashMap<>(); + e.put("name", bo.getDeptName() + (bo.getPersonType() == 2 ? "(部门)" : "(班组)")); + e.put("glName", "管理人数"); + e.put("sgName", "施工人数"); + String glKey = "gl" + bo.getDeptName(); + String sgKey = "sg" + bo.getDeptName(); + e.put("glNum", "t." + glKey); + e.put("sgNum", "t." + sgKey); + e.put("glTotalNum", glKey); + e.put("sgTotalNum", sgKey); + colList.add(e); + if (Objects.equals(bo.getPersonType(), 1)) { + sgNum = bo.getWorkerNum() + sgNum; + } else { + glNum = bo.getWorkerNum() + glNum; + } + Integer glKeyVal = Objects.equals(bo.getPersonType(), 1) ? 0 : bo.getWorkerNum(); + Integer sgKeyVal = Objects.equals(bo.getPersonType(), 2) ? 0 : bo.getWorkerNum(); + map.put(glKey, glKeyVal); + map.put(sgKey, sgKeyVal); + deptKeyMap.merge(glKey, glKeyVal, (o, n) -> o + n); + deptKeyMap.merge(sgKey, sgKeyVal, (o, n) -> o + n); + } + map.put("glNum", glNum); + map.put("sgNum", sgNum); + map.put("totalNum", glNum + sgNum); + listMap1.add(map); + totalGlNum += glNum; + totalSgNum += sgNum; + } + sheetMap1.putAll(deptKeyMap); + sheetMap1.put("listMap", listMap1); + sheetMap1.put("totalGlNum", totalGlNum); + sheetMap1.put("totalSgNum", totalSgNum); + sheetMap1.put("totalNum", totalGlNum + totalSgNum); + sheetMap1.put("projectName", project.getProjectName()); + String enterpriseId = MapUtils.getString(param, "enterpriseId"); + sheetMap1.put("hourValBegin", MapUtils.getInteger(param, "hourValBegin")); + EnterpriseInfo enterpriseInfo = enterpriseInfoService.getById(enterpriseId); + String enterpriseName = enterpriseInfo.getEnterpriseName(); + sheetMap1.put("enterpriseName", enterpriseName); + sheetMap1.put("colList", colList); + root.put(0, sheetMap1); + sheetNames.add(enterpriseName + "出勤人数"); + + //导出sheet2上海振南考勤报表 + List voList = this.doCountDailyAttendanceByDateRange(param).getRecords(); + Map sheetMap2 = new HashMap<>(); + int index = 0; + List> listMap2 = new ArrayList<>(); + for (StatisticsListVo vo : voList) { + Map map = new HashMap<>(); + map.put("no", ++index); + map.put("personType", vo.getPersonType()); + map.put("enterpriseName", vo.getEnterpriseName()); + map.put("workerName", vo.getWorkerName()); + map.put("deptName", vo.getDeptName()); + map.put("projectSn", vo.getProjectSn()); + map.put("personSn", vo.getPersonSn()); + map.put("workerTypeName", vo.getWorkerTypeName()); + map.put("phoneNumber", vo.getPhoneNumber()); + map.put("idCard", vo.getIdCard()); + map.put("sex", Objects.equals(vo.getSex(), 1) ? "男" : "女"); + map.put("enterDate", vo.getEnterDate()); + map.put("totalHour", vo.getTotalHour()); + map.put("totalAttendanceDay", vo.getTotalAttendanceDay()); + for (int z = 0; z < dateTimes.size(); z++) { + DateTime dateTime = dateTimes.get(z); + sheetMap2.put("date" + (z + 1), DateUtil.format(dateTime, "M/d")); + sheetMap2.put("delete" + (z + 1), false); + //每日工时 + String value = Optional.ofNullable(vo.getDailyHourMap().get(DateUtil.formatDate(dateTime))).map(decimal -> decimal.toString()).orElse(""); + map.put("attendanceByDate" + (z + 1), value); + } + for (int i = dateTimes.size(); i < 31; i++) { + sheetMap2.put("delete" + (i + 1), true); + } + listMap2.add(map); + } + sheetMap2.put("listMap", listMap2); + sheetMap2.put("projectName", project.getProjectName()); + sheetMap2.put("title", StrUtil.format("项目名称:{} 参建单位名称:{} 班组名称:全部 总人数:{} 时间:({} - {})", + project.getProjectName(), enterpriseName, voList.size(), startDate, endDate)); + sheetMap2.put("enterpriseName", enterpriseName); + root.put(1, sheetMap2); + sheetNames.add(enterpriseName + "考勤报表"); + templateUrl = Fileutils.getExportTemplateFile("excel/workerDailyAttendanceStatisticsV2/" + tempSheetName).getAbsolutePath(); + String outputTemplateFilePath = PathUtil.getBasePath() + "/temp/" + IdUtil.randomUUID() + ".xlsx"; + TemplateExportParams params = new TemplateExportParams(outputTemplateFilePath, true); + params.setSheetName(sheetNames.toArray(new String[]{})); + Workbook workbook = ExcelExportUtil.exportExcel(root, params); + ExcelUtils.downLoadExcel(tempSheetName, response, workbook); + } else if (Objects.equals(groupByType, 4)) { + //按人员 + tempSheetName = "单个人员考勤出入明细报表.xlsx"; + List voList = this.doCountDailyAttendanceByDateRange(param).getRecords(); + Map>> personSn2Date2AttendancesMap = workerAttendanceService.list(new LambdaQueryWrapper() + .eq(WorkerAttendance::getProjectSn, projectSn) + .ge(WorkerAttendance::getCreateTime, startDate) + .le(WorkerAttendance::getCreateTime, DateUtil.formatDateTime(DateUtil.endOfDay(DateUtil.parseDate(endDate)))) + .select(WorkerAttendance::getPersonSn, WorkerAttendance::getCreateTime, WorkerAttendance::getPassType)) + .stream().filter(w -> Objects.nonNull(w.getPersonSn())).collect(Collectors.groupingBy(WorkerAttendance::getPersonSn, + Collectors.groupingBy(o -> DateUtil.formatDate(DateUtil.parseDate(o.getCreateTime())), + Collectors.toList()))); + for (StatisticsListVo vo : voList) { + Map sheetMap = new HashMap<>(); + sheetMap.put("startDate", startDate); + sheetMap.put("endDate", endDate); + List> listMap = new ArrayList<>(); + for (int z = 0; z < dateTimes.size(); z++) { + Map map = new HashMap<>(); + DateTime date = dateTimes.get(z); + map.put("date", DateUtil.formatDate(date)); + map.put("week", DateUtil.dayOfWeekEnum(date).toChinese()); + map.put("detail", Optional.ofNullable(personSn2Date2AttendancesMap.get(vo.getPersonSn())).map(m -> m.get(DateUtil.formatDate(date))) + .map(attendances -> attendances.stream().sorted(Comparator.comparing(WorkerAttendance::getCreateTime)) + .map(att -> DateUtil.format(DateUtil.parseDateTime(att.getCreateTime()), "HH:mm") + (att.getPassType() == 1 ? "入场" : "出场")).collect(Collectors.joining("\n"))).orElse("")); + listMap.add(map); + } + root.put(sheetIndex++, sheetMap); + sheetMap.put("projectName", project.getProjectName()); + sheetMap.put("personType", vo.getPersonType() == 1 ? "班组" : "部门"); + sheetMap.put("enterpriseName", vo.getEnterpriseName()); + sheetMap.put("workerName", vo.getWorkerName()); + sheetMap.put("deptName", vo.getDeptName()); + sheetMap.put("workerTypeName", vo.getWorkerTypeName()); + sheetMap.put("totalAttendanceDay", vo.getTotalAttendanceDay()); + sheetNames.add(vo.getWorkerName()); + } + templateUrl = Fileutils.getExportTemplateFile("excel/workerDailyAttendanceStatisticsV2/" + tempSheetName).getAbsolutePath(); + String outputTemplateFilePath = PathUtil.getBasePath() + "/temp/" + IdUtil.randomUUID() + ".xlsx"; + EasyPoiUtil.cloneSheetMultipleTimes(templateUrl, outputTemplateFilePath, "1", sheetNames.size() - 1); + TemplateExportParams params = new TemplateExportParams(outputTemplateFilePath, true); + params.setSheetName(sheetNames.toArray(new String[]{})); + Workbook workbook = ExcelExportUtil.exportExcel(root, params); + ExcelUtils.downLoadExcel(tempSheetName, response, workbook); + } else if (Objects.equals(groupByType, 1)) { + //按项目 + tempSheetName = "考勤月报-按项目.xlsx"; + param.put("startTime", startDate); + param.put("endTime", endDate); + param.put("pageSize", -1); + List vos = this.doCountDailyAttendanceByDateRange(param).getRecords(); + Map>> personSn2Date2AttendancesMap = workerAttendanceService.list(new LambdaQueryWrapper() + .eq(WorkerAttendance::getProjectSn, projectSn) + .ge(WorkerAttendance::getCreateTime, startDate) + .le(WorkerAttendance::getCreateTime, DateUtil.formatDateTime(DateUtil.endOfDay(DateUtil.parseDate(endDate)))) + .select(WorkerAttendance::getPersonSn, WorkerAttendance::getCreateTime, WorkerAttendance::getPassType)) + .stream().filter(w -> Objects.nonNull(w.getPersonSn())).collect(Collectors.groupingBy(WorkerAttendance::getPersonSn, + Collectors.groupingBy(o -> DateUtil.formatDate(DateUtil.parseDate(o.getCreateTime())), + Collectors.toList()))); + BigDecimal totalAttendanceDay = BigDecimal.ZERO; + BigDecimal totalHour = BigDecimal.ZERO; + Map sheetMap = new HashMap<>(); + List> listMap = new ArrayList<>(); + int index = 0; + for (StatisticsListVo vo : vos) { + Map map = new HashMap<>(); + map.put("no", ++index); + map.put("personType", vo.getPersonType()); + map.put("enterpriseName", vo.getEnterpriseName()); + map.put("workerName", vo.getWorkerName()); + map.put("deptName", vo.getDeptName()); + map.put("projectSn", vo.getProjectSn()); + map.put("personSn", vo.getPersonSn()); + map.put("workerTypeName", vo.getWorkerTypeName()); + map.put("phoneNumber", vo.getPhoneNumber()); + map.put("idCard", vo.getIdCard()); + map.put("sex", Objects.equals(vo.getSex(), 1) ? "男" : "女"); + map.put("enterDate", vo.getEnterDate()); + for (int z = 0; z < dateTimes.size(); z++) { + DateTime dateTime = dateTimes.get(z); + sheetMap.put("date" + (z + 1), DateUtil.format(dateTime, "M/d")); + sheetMap.put("delete" + (z + 1), false); + String value; + if (Objects.equals(downloadType, 1) || Objects.equals(downloadType, 2)) { + value = getExcelAmPmAttendanceByDate(personSn2Date2AttendancesMap, vo, dateTime, downloadType); + } else if (Objects.equals(downloadType, 3)) { + //每日工时 + value = Optional.ofNullable(vo.getDailyHourMap().get(DateUtil.formatDate(dateTime))).map(decimal -> decimal.toString()).orElse(""); + } else { + //每日明细 + value = Optional.ofNullable(vo.getDailyAttendanceMap().get(DateUtil.formatDate(dateTime))).map(integer -> Objects.equals(integer, 1) ? "√" : "×").orElse("x"); + } + map.put("attendanceByDate" + (z + 1), value); + } + for (int i = dateTimes.size(); i < 31; i++) { + sheetMap.put("delete" + (i + 1), true); + } + map.put("totalHour", vo.getTotalHour()); + map.put("totalAttendanceDay", vo.getTotalAttendanceDay()); + totalAttendanceDay = NumberUtil.add(vo.getTotalAttendanceDay(), totalAttendanceDay); + totalHour = NumberUtil.add(vo.getTotalHour(), totalHour); + listMap.add(map); + } + sheetMap.put("listMap", listMap); + sheetMap.put("totalAttendanceDay", totalAttendanceDay); + sheetMap.put("totalWorkerNum", vos.size()); + sheetMap.put("totalHour", totalHour); + sheetMap.put("startDate", startDate); + sheetMap.put("endDate", endDate); + sheetMap.put("projectName", project.getProjectName()); + root.put(0, sheetMap); + sheetNames.add(project.getProjectName()); + templateUrl = Fileutils.getExportTemplateFile("excel/workerDailyAttendanceStatisticsV2/" + tempSheetName).getAbsolutePath(); + String outputTemplateFilePath = PathUtil.getBasePath() + "/temp/" + IdUtil.randomUUID() + ".xlsx"; + TemplateExportParams params = new TemplateExportParams(outputTemplateFilePath, true); + params.setSheetName(sheetNames.toArray(new String[]{})); + Workbook workbook = ExcelExportUtil.exportExcel(root, params); + ExcelUtils.downLoadExcel(tempSheetName, response, workbook); + } + } catch (IOException e) { + log.error("", e); + throw new OpenAlertException("系统错误"); + } finally { + if (templateUrl != null) { + FileUtil.deleteFile(templateUrl); + } + } + } + + /** + * 获取一天上下午/进出场打卡,格式: + * 07:19入场; + * 17:39出场 + * + * @param personSn2Date2AttendancesMap + * @param vo + * @param dateTime + * @param downloadType 1上下午打卡2进出场打卡 + * @return + */ + private String getExcelAmPmAttendanceByDate(Map>> personSn2Date2AttendancesMap, StatisticsListVo vo, DateTime dateTime, Integer downloadType) { + String attendanceByDate = ""; + Optional> workerAttendances = Optional.ofNullable(personSn2Date2AttendancesMap.get(vo.getPersonSn())).map(m -> m.get(DateUtil.formatDate(dateTime))); + WorkerAttendance first = workerAttendances.map(attendances -> downloadType == 1 ? getFirstTimeAm(attendances) : getFirstInTime(attendances)).orElse(null); + if (first != null) { + attendanceByDate = DateUtil.format(DateUtil.parseDateTime(first.getCreateTime()), "HH:mm") + (first.getPassType() == 1 ? "入场" : "出场"); + } + WorkerAttendance end = workerAttendances.map(attendances -> downloadType == 1 ? getEndTimePm(attendances) : getEndOutTime(attendances)).orElse(null); + if (end != null) { + if (StrUtil.isNotBlank(attendanceByDate)) { + attendanceByDate += "\n"; + } + attendanceByDate += DateUtil.format(DateUtil.parseDateTime(end.getCreateTime()), "HH:mm") + (end.getPassType() == 1 ? "入场" : "出场"); + } + return attendanceByDate; } } diff --git a/src/main/java/com/zhgd/xmgl/modules/worker/entity/bo/ExportWorkerDailyAttendancesStaticsByDepartmentTeamXlsBo.java b/src/main/java/com/zhgd/xmgl/modules/worker/entity/bo/ExportWorkerDailyAttendancesStaticsByDepartmentTeamXlsBo.java new file mode 100644 index 000000000..b3c36cf48 --- /dev/null +++ b/src/main/java/com/zhgd/xmgl/modules/worker/entity/bo/ExportWorkerDailyAttendancesStaticsByDepartmentTeamXlsBo.java @@ -0,0 +1,26 @@ +package com.zhgd.xmgl.modules.worker.entity.bo; + +import lombok.Data; + +@Data +public class ExportWorkerDailyAttendancesStaticsByDepartmentTeamXlsBo { + /** + * 人员类型 1、劳务人员 2、管理人员 + */ + private java.lang.Integer personType; + + /** + * 日期 + */ + private java.lang.String date; + + /** + * 班组/部门 + */ + private java.lang.String deptName; + + /** + * 人数 + */ + private java.lang.Integer workerNum; +} diff --git a/src/main/java/com/zhgd/xmgl/modules/worker/entity/vo/StatisticsListVo.java b/src/main/java/com/zhgd/xmgl/modules/worker/entity/vo/StatisticsListVo.java index 74df243b5..aa919d352 100644 --- a/src/main/java/com/zhgd/xmgl/modules/worker/entity/vo/StatisticsListVo.java +++ b/src/main/java/com/zhgd/xmgl/modules/worker/entity/vo/StatisticsListVo.java @@ -64,4 +64,50 @@ public class StatisticsListVo { */ @ApiModelProperty(value = "人员sn") private java.lang.String personSn; + /** + * 劳务人员Id + */ + @ApiModelProperty(value = "劳务人员Id") + private java.lang.Long workerId; + /** + * 工种名称 + */ + @ApiModelProperty(value = "工种名称") + private String workerTypeName; + /** + * 手机号 + */ + @ApiModelProperty(value = "手机号") + private java.lang.String phoneNumber; + /** + * 身份证号 + */ + @ApiModelProperty(value = "身份证号") + private java.lang.String idCard; + /** + * 性别 + */ + @ApiModelProperty(value = "性别,1男,2女") + private java.lang.Integer sex; + /** + * 进场日期 + */ + @ApiModelProperty(value = "进场日期") + private java.lang.String enterDate; + + /** + * 项目sn + */ + @ApiModelProperty(value = "项目sn") + private java.lang.String projectSn; + /** + * 工人工资卡银行开户行名称 + */ + @ApiModelProperty(value = "工人工资卡银行开户行名称") + private java.lang.String payRollBankName; + /** + * 工人银行卡号 + */ + @ApiModelProperty(value = "工人银行卡号") + private java.lang.String payRollBankNumber; } diff --git a/src/main/java/com/zhgd/xmgl/modules/worker/mapper/WorkerDailyAttendanceStatisticsV2Mapper.java b/src/main/java/com/zhgd/xmgl/modules/worker/mapper/WorkerDailyAttendanceStatisticsV2Mapper.java index 5e63ef9a7..8e56c7594 100644 --- a/src/main/java/com/zhgd/xmgl/modules/worker/mapper/WorkerDailyAttendanceStatisticsV2Mapper.java +++ b/src/main/java/com/zhgd/xmgl/modules/worker/mapper/WorkerDailyAttendanceStatisticsV2Mapper.java @@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.core.toolkit.Constants; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.zhgd.xmgl.modules.worker.entity.WorkerDailyAttendanceStatisticsV2; import com.zhgd.xmgl.modules.worker.entity.bo.CountWorkerDailyAttendanceStatisticsV2ByDateBo; +import com.zhgd.xmgl.modules.worker.entity.bo.ExportWorkerDailyAttendancesStaticsByDepartmentTeamXlsBo; import com.zhgd.xmgl.modules.worker.entity.vo.*; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -79,4 +80,6 @@ public interface WorkerDailyAttendanceStatisticsV2Mapper extends BaseMapper countNumByEnterprise(HashMap param); List countNumByWorkerType(HashMap param); + + List countExportWorkerDailyAttendancesStaticsByDepartmentTeamXlsBo(HashMap param); } diff --git a/src/main/java/com/zhgd/xmgl/modules/worker/mapper/xml/WorkerAttendanceMapper.xml b/src/main/java/com/zhgd/xmgl/modules/worker/mapper/xml/WorkerAttendanceMapper.xml index aa9f60460..998811569 100644 --- a/src/main/java/com/zhgd/xmgl/modules/worker/mapper/xml/WorkerAttendanceMapper.xml +++ b/src/main/java/com/zhgd/xmgl/modules/worker/mapper/xml/WorkerAttendanceMapper.xml @@ -55,6 +55,7 @@ ,ei.id as enterprise_id ,if(c.id is not null,c.id,d.id) as department_team_id ,if(c.team_name is not null,c.team_name,d.department_name) as department_team_name + ,b.id as worker_id from worker_attendance a LEFT JOIN worker_info b ON a.person_sn = b.person_sn LEFT JOIN team_info c ON b.team_id = c.id diff --git a/src/main/java/com/zhgd/xmgl/modules/worker/mapper/xml/WorkerDailyAttendanceStatisticsV2Mapper.xml b/src/main/java/com/zhgd/xmgl/modules/worker/mapper/xml/WorkerDailyAttendanceStatisticsV2Mapper.xml index f335d1644..5edc446a3 100644 --- a/src/main/java/com/zhgd/xmgl/modules/worker/mapper/xml/WorkerDailyAttendanceStatisticsV2Mapper.xml +++ b/src/main/java/com/zhgd/xmgl/modules/worker/mapper/xml/WorkerDailyAttendanceStatisticsV2Mapper.xml @@ -49,7 +49,7 @@ resultType="com.zhgd.xmgl.modules.worker.entity.vo.CountWorkerDailyAttendanceStatisticsV2Vo"> select t.* - ,ifnull(round(t.total_in_service_num/t.total_attendance_num*100,2),0) as attendance_rate_avg + ,ifnull(round(t.total_attendance_num/t.total_in_service_num*100,2),0) as attendance_rate_avg from ( select count(*) as total_in_service_num @@ -57,11 +57,11 @@ ,ifnull(sum(t.hour_val),0) as hour_val_total from worker_daily_attendance_statistics_v2 t JOIN worker_info a on t.person_sn=a.person_sn - JOIN team_info b ON a.team_id = b.id and a.person_type = 1 - JOIN department_info c ON a.department_id = c.id and a.person_type = 2 - JOIN worker_type wt ON b.worker_type_id = wt.id and a.person_type = 1 + LEFT JOIN team_info b ON a.team_id = b.id and a.person_type = 1 + LEFT JOIN department_info c ON a.department_id = c.id and a.person_type = 2 + LEFT JOIN worker_type wt ON b.worker_type_id = wt.id and a.person_type = 1 JOIN enterprise_info en ON en.id = a.enterprise_id - INNER JOIN project_enterprise pe ON a.id = pe.enterprise_id and pe.project_sn=t.project_sn + INNER JOIN project_enterprise pe ON en.id = pe.enterprise_id and pe.project_sn=t.project_sn where t.project_sn=#{projectSn} and a.person_sn = #{personSn} @@ -97,7 +97,7 @@ resultType="com.zhgd.xmgl.modules.worker.entity.bo.CountWorkerDailyAttendanceStatisticsV2ByDateBo"> select t.* - ,ifnull(round(t.total_in_service_num/t.total_attendance_num*100,2),0) as attendance_rate_avg + ,ifnull(round(t.total_attendance_num/t.total_in_service_num*100,2),0) as attendance_rate_avg from ( select @@ -110,11 +110,11 @@ ,ifnull(sum(t.is_attendance),0) as total_attendance_num from worker_daily_attendance_statistics_v2 t JOIN worker_info a on t.person_sn=a.person_sn - JOIN team_info b ON a.team_id = b.id and a.person_type = 1 - JOIN department_info c ON a.department_id = c.id and a.person_type = 2 - JOIN worker_type wt ON b.worker_type_id = wt.id and a.person_type = 1 + LEFT JOIN team_info b ON a.team_id = b.id and a.person_type = 1 + LEFT JOIN department_info c ON a.department_id = c.id and a.person_type = 2 + LEFT JOIN worker_type wt ON b.worker_type_id = wt.id and a.person_type = 1 JOIN enterprise_info en ON en.id = a.enterprise_id - INNER JOIN project_enterprise pe ON a.id = pe.enterprise_id and pe.project_sn=t.project_sn + INNER JOIN project_enterprise pe ON en.id = pe.enterprise_id and pe.project_sn=t.project_sn where t.project_sn=#{projectSn} and pe.enterprise_type_id = #{enterpriseTypeId} @@ -152,11 +152,11 @@ ,ifnull(sum(t.day_val),0) as day_val_total from worker_daily_attendance_statistics_v2 t JOIN worker_info a on t.person_sn=a.person_sn - JOIN team_info b ON a.team_id = b.id and a.person_type = 1 - JOIN department_info c ON a.department_id = c.id and a.person_type = 2 - JOIN worker_type wt ON b.worker_type_id = wt.id and a.person_type = 1 + LEFT JOIN team_info b ON a.team_id = b.id and a.person_type = 1 + LEFT JOIN department_info c ON a.department_id = c.id and a.person_type = 2 + LEFT JOIN worker_type wt ON b.worker_type_id = wt.id and a.person_type = 1 JOIN enterprise_info en ON en.id = a.enterprise_id - INNER JOIN project_enterprise pe ON a.id = pe.enterprise_id and pe.project_sn=t.project_sn + INNER JOIN project_enterprise pe ON en.id = pe.enterprise_id and pe.project_sn=t.project_sn where t.project_sn=#{projectSn} and pe.enterprise_type_id = #{enterpriseTypeId} @@ -195,11 +195,11 @@ ,ifnull(sum(t.is_attendance),0) as worker_count from worker_daily_attendance_statistics_v2 t JOIN worker_info a on t.person_sn=a.person_sn - JOIN team_info b ON a.team_id = b.id and a.person_type = 1 - JOIN department_info c ON a.department_id = c.id and a.person_type = 2 - JOIN worker_type wt ON b.worker_type_id = wt.id and a.person_type = 1 + LEFT JOIN team_info b ON a.team_id = b.id and a.person_type = 1 + LEFT JOIN department_info c ON a.department_id = c.id and a.person_type = 2 + LEFT JOIN worker_type wt ON b.worker_type_id = wt.id and a.person_type = 1 JOIN enterprise_info en ON en.id = a.enterprise_id - JOIN project_enterprise pe ON a.id = pe.enterprise_id and pe.project_sn=t.project_sn + JOIN project_enterprise pe ON en.id = pe.enterprise_id and pe.project_sn=t.project_sn where t.project_sn=#{projectSn} and a.person_type = #{personType} @@ -239,4 +239,30 @@ group by wt.id) t + + diff --git a/src/main/java/com/zhgd/xmgl/modules/worker/service/IWorkerDailyAttendanceStatisticsV2Service.java b/src/main/java/com/zhgd/xmgl/modules/worker/service/IWorkerDailyAttendanceStatisticsV2Service.java index 6cb12645a..1d6cf9f2b 100644 --- a/src/main/java/com/zhgd/xmgl/modules/worker/service/IWorkerDailyAttendanceStatisticsV2Service.java +++ b/src/main/java/com/zhgd/xmgl/modules/worker/service/IWorkerDailyAttendanceStatisticsV2Service.java @@ -7,6 +7,7 @@ import com.zhgd.xmgl.base.entity.vo.echarts.ChartDataVo; import com.zhgd.xmgl.modules.worker.entity.WorkerAttendanceRuleV2; import com.zhgd.xmgl.modules.worker.entity.WorkerDailyAttendanceStatisticsV2; import com.zhgd.xmgl.modules.worker.entity.bo.CalAttendanceBo; +import com.zhgd.xmgl.modules.worker.entity.bo.ExportWorkerDailyAttendancesStaticsByDepartmentTeamXlsBo; import com.zhgd.xmgl.modules.worker.entity.dto.WorkerDailyAttendanceStatisticsV2Dto; import com.zhgd.xmgl.modules.worker.entity.vo.*; @@ -101,4 +102,12 @@ public interface IWorkerDailyAttendanceStatisticsV2Service extends IService countNumByEnterprise(HashMap param); List countNumByWorkerType(HashMap param); + + /** + * 获取导出的 + * + * @param param + * @return + */ + List countExportWorkerDailyAttendancesStaticsByDepartmentTeamXlsBo(HashMap param); } diff --git a/src/main/java/com/zhgd/xmgl/modules/worker/service/impl/WorkerDailyAttendanceStatisticsV2ServiceImpl.java b/src/main/java/com/zhgd/xmgl/modules/worker/service/impl/WorkerDailyAttendanceStatisticsV2ServiceImpl.java index 4d7f22df1..85e60ce14 100644 --- a/src/main/java/com/zhgd/xmgl/modules/worker/service/impl/WorkerDailyAttendanceStatisticsV2ServiceImpl.java +++ b/src/main/java/com/zhgd/xmgl/modules/worker/service/impl/WorkerDailyAttendanceStatisticsV2ServiceImpl.java @@ -19,6 +19,7 @@ import com.zhgd.xmgl.modules.project.service.IProjectEnterpriseService; import com.zhgd.xmgl.modules.worker.entity.*; import com.zhgd.xmgl.modules.worker.entity.bo.CalAttendanceBo; import com.zhgd.xmgl.modules.worker.entity.bo.CountWorkerDailyAttendanceStatisticsV2ByDateBo; +import com.zhgd.xmgl.modules.worker.entity.bo.ExportWorkerDailyAttendancesStaticsByDepartmentTeamXlsBo; import com.zhgd.xmgl.modules.worker.entity.bo.Hour2dayJsonBo; import com.zhgd.xmgl.modules.worker.entity.dto.WorkerDailyAttendanceStatisticsV2Dto; import com.zhgd.xmgl.modules.worker.entity.vo.*; @@ -450,7 +451,12 @@ public class WorkerDailyAttendanceStatisticsV2ServiceImpl extends ServiceImpl 0) { + //没入场不在职 + inserviceType = 2; + } + this.calAndSaveStatistics(worker.getProjectSn(), worker.getPersonSn(), inserviceType, dateTime, ruleV2, attendances, allAttendances); } } } @@ -588,4 +594,9 @@ public class WorkerDailyAttendanceStatisticsV2ServiceImpl extends ServiceImpl countExportWorkerDailyAttendancesStaticsByDepartmentTeamXlsBo(HashMap param) { + return baseMapper.countExportWorkerDailyAttendancesStaticsByDepartmentTeamXlsBo(param); + } + } diff --git a/src/main/java/com/zhgd/xmgl/modules/worker/service/impl/WorkerInfoServiceImpl.java b/src/main/java/com/zhgd/xmgl/modules/worker/service/impl/WorkerInfoServiceImpl.java index a3fd450ee..f15b3dca6 100644 --- a/src/main/java/com/zhgd/xmgl/modules/worker/service/impl/WorkerInfoServiceImpl.java +++ b/src/main/java/com/zhgd/xmgl/modules/worker/service/impl/WorkerInfoServiceImpl.java @@ -18,6 +18,7 @@ import cn.hutool.poi.excel.ExcelWriter; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; @@ -617,6 +618,10 @@ public class WorkerInfoServiceImpl extends ServiceImpl() + .set(WorkerInfo::getAttendanceGroupV2Id, workerInfo.getAttendanceGroupV2Id()) + .eq(WorkerInfo::getId, workerInfo.getId()) + ); workerInfoMapper.updateById(workerInfo); systemUserService.updateRealNameFromWorker(workerInfo.getId(), workerInfo.getWorkerName()); boolean hikvisionConfig = projectUfaceConfigService.isHikvisionConfig(workerInfo.getProjectSn()); diff --git a/src/main/resources/excel/workerDailyAttendanceStatisticsV2/单个人员考勤出入明细报表.xlsx b/src/main/resources/excel/workerDailyAttendanceStatisticsV2/单个人员考勤出入明细报表.xlsx index 73d137584..88e51bd5c 100644 Binary files a/src/main/resources/excel/workerDailyAttendanceStatisticsV2/单个人员考勤出入明细报表.xlsx and b/src/main/resources/excel/workerDailyAttendanceStatisticsV2/单个人员考勤出入明细报表.xlsx differ diff --git a/src/main/resources/excel/workerDailyAttendanceStatisticsV2/考勤月报-按单位-出勤人数与考勤报表.xlsx b/src/main/resources/excel/workerDailyAttendanceStatisticsV2/考勤月报-按单位-出勤人数与考勤报表.xlsx new file mode 100644 index 000000000..17ba25843 Binary files /dev/null and b/src/main/resources/excel/workerDailyAttendanceStatisticsV2/考勤月报-按单位-出勤人数与考勤报表.xlsx differ diff --git a/src/main/resources/excel/workerDailyAttendanceStatisticsV2/考勤月报-按班组-每日出入(打卡记录明细).xlsx b/src/main/resources/excel/workerDailyAttendanceStatisticsV2/考勤月报-按班组-每日出入(打卡记录明细).xlsx deleted file mode 100644 index 68f03c877..000000000 Binary files a/src/main/resources/excel/workerDailyAttendanceStatisticsV2/考勤月报-按班组-每日出入(打卡记录明细).xlsx and /dev/null differ diff --git a/src/main/resources/excel/workerDailyAttendanceStatisticsV2/考勤月报-按班组.xlsx b/src/main/resources/excel/workerDailyAttendanceStatisticsV2/考勤月报-按班组.xlsx new file mode 100644 index 000000000..0cc9171c3 Binary files /dev/null and b/src/main/resources/excel/workerDailyAttendanceStatisticsV2/考勤月报-按班组.xlsx differ diff --git a/src/main/resources/excel/workerDailyAttendanceStatisticsV2/考勤月报-按项目.xlsx b/src/main/resources/excel/workerDailyAttendanceStatisticsV2/考勤月报-按项目.xlsx new file mode 100644 index 000000000..4c07e80b3 Binary files /dev/null and b/src/main/resources/excel/workerDailyAttendanceStatisticsV2/考勤月报-按项目.xlsx differ