人脸更新

This commit is contained in:
fl 2024-12-04 16:27:28 +08:00
parent c51e73ae07
commit 3c8e07cfe4
6 changed files with 352 additions and 104 deletions

View File

@ -97,6 +97,16 @@ public class AttDetailBean {
return params; return params;
} }
/**
* 开始日期
*/
private String startDate;
/**
* 结束日期
*/
private String endDate;
public void setParams(Map<String, Object> params) public void setParams(Map<String, Object> params)
{ {
this.params = params; this.params = params;

View File

@ -9,10 +9,13 @@ import cn.hutool.poi.excel.ExcelWriter;
import com.bonus.common.core.constant.BusinessConstants; import com.bonus.common.core.constant.BusinessConstants;
import com.bonus.common.core.enums.AttStatus; import com.bonus.common.core.enums.AttStatus;
import com.bonus.common.core.utils.ExcelStyleUtil; import com.bonus.common.core.utils.ExcelStyleUtil;
import com.bonus.common.core.utils.StringHelper;
import com.bonus.common.core.utils.StringUtils; import com.bonus.common.core.utils.StringUtils;
import com.bonus.common.core.utils.poi.MultiSheetExcelExporter;
import com.bonus.common.security.annotation.RequiresPermissions; import com.bonus.common.security.annotation.RequiresPermissions;
import com.bonus.common.security.utils.SecurityUtils; import com.bonus.common.security.utils.SecurityUtils;
import com.bonus.system.att.entity.*; import com.bonus.system.att.entity.*;
import com.bonus.system.att.service.AttDetailByMonthService;
import com.bonus.system.att.service.AttendanceDetailsService; import com.bonus.system.att.service.AttendanceDetailsService;
import com.bonus.system.att.service.OrgChangeService; import com.bonus.system.att.service.OrgChangeService;
import com.bonus.system.basic.domain.SysOrg; import com.bonus.system.basic.domain.SysOrg;
@ -33,7 +36,7 @@ import com.bonus.system.wechat.service.WechatEvectionService;
import com.bonus.system.wechat.service.WechatLeaveReportingService; import com.bonus.system.wechat.service.WechatLeaveReportingService;
import com.bonus.system.wechat.service.WechatService; import com.bonus.system.wechat.service.WechatService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.poi.ss.formula.functions.T; import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.ss.usermodel.Workbook;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
@ -42,7 +45,6 @@ import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.ServletOutputStream; import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.IOException; import java.io.IOException;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
@ -50,6 +52,10 @@ import java.net.URLEncoder;
import java.text.DateFormat; import java.text.DateFormat;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.YearMonth;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeParseException;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -121,9 +127,13 @@ public class ExportFileController {
@Resource(name = "WechatService") @Resource(name = "WechatService")
private WechatService wechatService; private WechatService wechatService;
@Resource(name = "attDetailByMonthService")
private AttDetailByMonthService attDetailByMonthService;
/** /**
* 分公司项目部导出 * 分公司项目部导出
*
* @param response * @param response
* @param bean * @param bean
* @return void * @return void
@ -155,6 +165,7 @@ public class ExportFileController {
/** /**
* 轮休请假外出办事导出 * 轮休请假外出办事导出
*
* @param response * @param response
* @param bean * @param bean
* @return void * @return void
@ -201,6 +212,7 @@ public class ExportFileController {
/** /**
* 考勤明细导出/原始数据导出 * 考勤明细导出/原始数据导出
*
* @param response * @param response
* @param bean * @param bean
* @return void * @return void
@ -361,6 +373,7 @@ public class ExportFileController {
/** /**
* 组织导出 * 组织导出
*
* @param response * @param response
* @param bean * @param bean
* @return void * @return void
@ -390,6 +403,7 @@ public class ExportFileController {
/** /**
* 日报表导出 * 日报表导出
*
* @param response * @param response
* @param bean * @param bean
* @return void * @return void
@ -398,24 +412,120 @@ public class ExportFileController {
*/ */
@GetMapping("/exportDayReport") @GetMapping("/exportDayReport")
public void exportDayReport(HttpServletResponse response, AttDayReportBean bean) { public void exportDayReport(HttpServletResponse response, AttDayReportBean bean) {
// try {
// List<AttDayReportExportBean> personExportVoList = new ArrayList<>();
// List<AttDayReportBean> attDayReportList = attendanceDetailsService.getAttDayReportList(bean);
// for (int i = 0; i < attDayReportList.size(); i++) {
// AttDayReportBean vo = attDayReportList.get(i);
// AttDayReportExportBean voe = new AttDayReportExportBean();
// BeanUtils.copyProperties(vo, voe);
// voe.setId((i + 1));
// personExportVoList.add(voe);
// }
// extracted(personExportVoList, AttDayReportExportBean.class, "日报表导出", "日报表导出", "日报表导出", response);
// } catch (Exception e) {
// log.error(e.toString(), e);
// }
try { try {
List<AttDayReportExportBean> personExportVoList = new ArrayList<>(); MultiSheetExcelExporter exporter = new MultiSheetExcelExporter();
List<AttDayReportBean> attDayReportList = attendanceDetailsService.getAttDayReportList(bean); List<AttDayReportBean> attDayReportList = attendanceDetailsService.getAttDayReportList(bean);
Sheet departmentSheet1 = exporter.createSheet("日报表详情");
List<String> departmentHeaders1 = Arrays.asList("序号", "考勤日期", "正常打卡人数", "迟到人数", "早退人数",
"矿工人数", "请假人数", "打卡地异常人数", "出入异常人数", "轮休人数", "临时外出人数");
exporter.addHeaderRow(departmentSheet1, departmentHeaders1);
List<Map<String, Object>> departmentData1 = new ArrayList<>();
for (int i = 0; i < attDayReportList.size(); i++) { for (int i = 0; i < attDayReportList.size(); i++) {
AttDayReportBean vo = attDayReportList.get(i); Map<String, Object> map = new LinkedHashMap<>();
AttDayReportExportBean voe = new AttDayReportExportBean(); map.put("序号", i + 1);
BeanUtils.copyProperties(vo, voe); map.put("考勤日期", attDayReportList.get(i).getAttCurrentDay());
voe.setId((i + 1)); map.put("正常打卡人数", attDayReportList.get(i).getNormalNum());
personExportVoList.add(voe); map.put("迟到人数", attDayReportList.get(i).getLateNum());
map.put("早退人数", attDayReportList.get(i).getEarlyNum());
map.put("矿工人数", attDayReportList.get(i).getSkippingNum());
map.put("请假人数", attDayReportList.get(i).getLeaveNum());
map.put("打卡地异常人数", attDayReportList.get(i).getAddressErrorNum());
map.put("出入异常人数", attDayReportList.get(i).getEinErrorNum());
map.put("轮休人数", attDayReportList.get(i).getRestNum());
map.put("临时外出人数", attDayReportList.get(i).getOutNum());
departmentData1.add(map);
} }
extracted(personExportVoList, AttDayReportExportBean.class, "日报表导出", "日报表导出", "日报表导出", response); exporter.addDataRows(departmentSheet1, departmentData1, departmentHeaders1);
} catch (Exception e) { //详情的数据导出
log.error(e.toString(), e); Map<String, String> headers = new HashMap<>();
headers.put("1", "正常打卡");
headers.put("2", "迟到详情");
headers.put("3", "旷工详情");
headers.put("4", "早退详情");
headers.put("5", "轮休详情");
headers.put("6", "请假详情");
headers.put("7", "外出办事");
headers.put("8", "出入异常");
headers.put("9", "打卡地异常");
Map<String, String> attStatus = getStringStringMap();
if (StringHelper.isNotEmpty(bean.getStartDate()) && StringHelper.isNotEmpty(bean.getEndDate())) {
AttDataDetailsBean dayTable = new AttDataDetailsBean();
dayTable.setStartDate(bean.getStartDate());
dayTable.setEndDate(bean.getEndDate());
headers.entrySet()
.forEach(entry -> {
dayTable.setAttStatus(entry.getKey());
List<AttDataDetailsBean> list = attendanceDetailsService.getAttDayReportDetailsList(dayTable);
Sheet departmentSheet2 = exporter.createSheet(entry.getValue());
List<String> departmentHeaders2 = Arrays.asList("序号", "姓名", "所属部门", "打卡日期", "上班打卡时间", "上班状态", "打卡地址", "下班打卡时间", "下班状态", "打卡地址");
exporter.addHeaderRow(departmentSheet2, departmentHeaders2);
List<Map<String, Object>> departmentData2 = new ArrayList<>();
for (int i = 0; i < list.size(); i++) {
Map<String, Object> map = new LinkedHashMap<>();
map.put("序号", i + 1);
map.put("姓名", list.get(i).getUserName());
map.put("所属部门", list.get(i).getOrgName());
map.put("打卡日期", list.get(i).getAttCurrentDay());
map.put("上班打卡时间", list.get(i).getToWorkAttCurrentTime());
map.put("上班状态", attStatus.get(list.get(i).getToWorkAttStatus()));
map.put("上班打卡地址", list.get(i).getToWorkAttAddress());
map.put("下班打卡时间", list.get(i).getOffWorkAttCurrentTime());
map.put("下班状态", attStatus.get(list.get(i).getOffWorkAttStatus()));
map.put("下班打卡地址", list.get(i).getOffWorkAttAddress());
departmentData2.add(map);
} }
exporter.addDataRows(departmentSheet2, departmentData2, departmentHeaders2);
});
// 导出Excel文件
exporter.exportToResponse(response, "日报表导出");
}
} catch (IOException e) {
e.printStackTrace();
}
}
private Map<String, String> getStringStringMap() {
Map<String, String> attStatus = new HashMap<>();
attStatus.put("1", "正常");
attStatus.put("2", "迟到");
attStatus.put("3", "旷工");
attStatus.put("4", "早退");
attStatus.put("5", "轮休");
attStatus.put("6", "请假");
attStatus.put("7", "外出");
attStatus.put("8", "出入异常");
attStatus.put("9", "打卡地异常");
attStatus.put("10", "出差");
attStatus.put("11", "法定节假日");
attStatus.put("12", "年休假");
attStatus.put("13", "探亲假");
attStatus.put("14", "事假");
attStatus.put("15", "病假");
attStatus.put("16", "产假");
attStatus.put("17", "婚假");
attStatus.put("18", "丧假");
return attStatus;
} }
/** /**
* 月报表导出 * 月报表导出
*
* @param response * @param response
* @param bean * @param bean
* @return void * @return void
@ -424,26 +534,134 @@ public class ExportFileController {
*/ */
@GetMapping("/exportMonthReport") @GetMapping("/exportMonthReport")
public void exportMonthReport(HttpServletResponse response, AttMonthReportBean bean) { public void exportMonthReport(HttpServletResponse response, AttMonthReportBean bean) {
// try {
// List<AttMonthReportExportBean> personExportVoList = new ArrayList<>();
// List<AttMonthReportBean> attMonthReportList = attendanceDetailsService.getAttMonthReportList(bean);
// for (int i = 0; i < attMonthReportList.size(); i++) {
// AttMonthReportBean vo = attMonthReportList.get(i);
// AttMonthReportExportBean voe = new AttMonthReportExportBean();
// BeanUtils.copyProperties(vo, voe);
// voe.setId(i + 1);
// personExportVoList.add(voe);
// }
// extracted(personExportVoList, AttMonthReportExportBean.class, "月报表导出", "月报表导出", "月报表导出", response);
// } catch (Exception e) {
// log.error(e.toString(), e);
// }
try { try {
List<AttMonthReportExportBean> personExportVoList = new ArrayList<>(); MultiSheetExcelExporter exporter = new MultiSheetExcelExporter();
List<AttMonthReportBean> attMonthReportList = attendanceDetailsService.getAttMonthReportList(bean); List<AttMonthReportBean> attDayReportList = attendanceDetailsService.getAttMonthReportList(bean);
for (int i = 0; i < attMonthReportList.size(); i++) { Sheet departmentSheet1 = exporter.createSheet("月报表详情");
AttMonthReportBean vo = attMonthReportList.get(i); List<String> departmentHeaders1 = Arrays.asList("序号", "姓名", "所属部门", "考勤月", "应考勤天数", "正常打卡天数",
AttMonthReportExportBean voe = new AttMonthReportExportBean(); "迟到天数", "早退天数", "矿工天数", "请假天数", "打卡地异常天数", "出入异常天数", "轮休天数", "临时外出天数");
BeanUtils.copyProperties(vo, voe); exporter.addHeaderRow(departmentSheet1, departmentHeaders1);
voe.setId(i + 1); List<Map<String, Object>> departmentData1 = new ArrayList<>();
personExportVoList.add(voe); for (int i = 0; i < attDayReportList.size(); i++) {
Map<String, Object> map = new LinkedHashMap<>();
map.put("序号", i + 1);
map.put("姓名", attDayReportList.get(i).getUserName());
map.put("所属部门", attDayReportList.get(i).getOrgName());
map.put("考勤月", attDayReportList.get(i).getMonth());
map.put("应考勤天数", attDayReportList.get(i).getRequiredDays());
map.put("正常打卡天数", attDayReportList.get(i).getNormalNum());
map.put("迟到天数", attDayReportList.get(i).getLateNum());
map.put("早退天数", attDayReportList.get(i).getEarlyNum());
map.put("矿工天数", attDayReportList.get(i).getSkippingNum());
map.put("请假天数", attDayReportList.get(i).getLeaveNum());
map.put("打卡地异常天数", attDayReportList.get(i).getAddressErrorNum());
map.put("出入异常天数", attDayReportList.get(i).getEinErrorNum());
map.put("轮休天数", attDayReportList.get(i).getRestNum());
map.put("临时外出天数", attDayReportList.get(i).getOutNum());
departmentData1.add(map);
} }
extracted(personExportVoList, AttMonthReportExportBean.class, "月报表导出", "月报表导出", "月报表导出", response); exporter.addDataRows(departmentSheet1, departmentData1, departmentHeaders1);
} catch (Exception e) { //详情的数据导出
log.error(e.toString(), e); Map<String, String> headers = new HashMap<>();
headers.put("1", "正常打卡");
headers.put("2", "迟到详情");
headers.put("3", "旷工详情");
headers.put("4", "早退详情");
headers.put("5", "轮休详情");
headers.put("6", "请假详情");
headers.put("7", "外出办事");
headers.put("8", "出入异常");
headers.put("9", "打卡地异常");
Map<String, String> attStatus = getStringStringMap();
if (StringHelper.isNotEmpty(bean.getMonth())) {
List<String> monthFirstAndLast = getMonthFirstAndLast(bean.getMonth());
AttDetailBean dayTable = new AttDetailBean();
dayTable.setStartDate(monthFirstAndLast.get(0));
dayTable.setEndDate(monthFirstAndLast.get(1));
headers.entrySet()
.forEach(entry -> {
List<AttDetailBean> list = attDetailByMonthService.getDetailList(dayTable);
Sheet departmentSheet2 = exporter.createSheet(entry.getValue());
List<String> departmentHeaders2 = Arrays.asList("序号", "姓名", "所属部门", "打卡日期", "上班打卡时间", "上班状态", "打卡地址", "下班打卡时间", "下班状态", "打卡地址");
exporter.addHeaderRow(departmentSheet2, departmentHeaders2);
List<Map<String, Object>> departmentData2 = new ArrayList<>();
// for (int i = 0; i < list.size(); i++) {
// Map<String, Object> map = new LinkedHashMap<>();
// map.put("序号", i + 1);
// map.put("姓名", list.get(i).getUserName());
// map.put("所属部门", list.get(i).getOrgName());
// map.put("打卡日期", list.get(i).getAttCurrentDay());
// map.put("上班打卡时间", list.get(i).getToWorkAttCurrentTime());
// map.put("上班状态", attStatus.get(list.get(i).getToWorkAttStatus()));
// map.put("上班打卡地址", list.get(i).getToWorkAttAddress());
// map.put("下班打卡时间", list.get(i).getOffWorkAttCurrentTime());
// map.put("下班状态", attStatus.get(list.get(i).getOffWorkAttStatus()));
// map.put("下班打卡地址", list.get(i).getOffWorkAttAddress());
// departmentData2.add(map);
// }
exporter.addDataRows(departmentSheet2, departmentData2, departmentHeaders2);
});
// 导出Excel文件
exporter.exportToResponse(response, "日报表导出");
}
} catch (IOException e) {
e.printStackTrace();
} }
} }
private List<String> getMonthFirstAndLast(String monthString) {
List<String> months = new ArrayList<>();
// 定义日期格式
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM");
YearMonth yearMonth;
// 使用预定义的 ISO_LOCAL_DATE 格式 (yyyy-MM-dd)
DateTimeFormatter isoFormatter = DateTimeFormatter.ISO_LOCAL_DATE;
try {
// 判空及默认为当月
if (monthString == null || monthString.trim().isEmpty()) {
// 如果字符串为空或仅包含空白字符取当前月份
yearMonth = YearMonth.from(LocalDate.now());
} else {
// 尝试将字符串解析为 YearMonth 对象
yearMonth = YearMonth.parse(monthString, formatter);
}
// 获取该月的第一天
LocalDate firstDayOfMonth = yearMonth.atDay(1);
// 获取该月的最后一天
LocalDate lastDayOfMonth = yearMonth.atEndOfMonth();
months.add(firstDayOfMonth.format(isoFormatter));
months.add(lastDayOfMonth.format(isoFormatter));
} catch (DateTimeParseException e) {
// 如果解析失败打印错误信息并使用当前月份
YearMonth currentYearMonth = YearMonth.from(LocalDate.now());
LocalDate firstDayOfCurrentMonth = currentYearMonth.atDay(1);
LocalDate lastDayOfCurrentMonth = currentYearMonth.atEndOfMonth();
months.add(firstDayOfCurrentMonth.format(isoFormatter));
months.add(lastDayOfCurrentMonth.format(isoFormatter));
}
return months;
}
/** /**
* 导出excel文件 * 导出excel文件
*
* @param list 数据 * @param list 数据
* @param clazz bean.class * @param clazz bean.class
* @param title 标题 * @param title 标题
@ -497,9 +715,9 @@ public class ExportFileController {
} }
/** /**
* 休假报备 * 休假报备
*
* @param response * @param response
* @param bean * @param bean
* @return void * @return void
@ -539,6 +757,7 @@ public class ExportFileController {
/** /**
* 出差报备 * 出差报备
*
* @param response * @param response
* @param bean * @param bean
* @return void * @return void
@ -577,6 +796,7 @@ public class ExportFileController {
/** /**
* 组织架构变更导出 * 组织架构变更导出
*
* @param response * @param response
* @param bean * @param bean
* @return void * @return void
@ -618,9 +838,9 @@ public class ExportFileController {
} }
/** /**
* 小程序打卡数据导出 * 小程序打卡数据导出
*
* @param response * @param response
* @param bean * @param bean
* @return void * @return void
@ -690,6 +910,7 @@ public class ExportFileController {
/** /**
* 数据管理-休假报备 * 数据管理-休假报备
*
* @param response * @param response
* @param bean * @param bean
* @return void * @return void
@ -729,6 +950,7 @@ public class ExportFileController {
/** /**
* 数据管理-出差报备 * 数据管理-出差报备
*
* @param response * @param response
* @param bean * @param bean
* @return void * @return void

View File

@ -183,6 +183,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
(vat.att_current_day &gt;= CONCAT(#{attCurrent}, '-01') AND (vat.att_current_day &gt;= CONCAT(#{attCurrent}, '-01') AND
vat.att_current_day &lt; LAST_DAY(CONCAT(#{attCurrent}, '-01'))) vat.att_current_day &lt; LAST_DAY(CONCAT(#{attCurrent}, '-01')))
</if> </if>
<if test="startDate != null and startDate != ''">
and vat.att_current_day between #{startDate} and #{endDate}
</if>
<if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 --> <if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
and date_format(vat.att_current_day,'%y%m%d') &gt;= date_format(#{params.beginTime},'%y%m%d') and date_format(vat.att_current_day,'%y%m%d') &gt;= date_format(#{params.beginTime},'%y%m%d')
</if> </if>

View File

@ -113,7 +113,7 @@
attendance_date as attCurrentDay, attendance_time as attCurrentTime, attendance_date as attCurrentDay, attendance_time as attCurrentTime,
CASE attendance_type WHEN '上班' THEN 1 ELSE 2 END as attType, CASE attendance_type WHEN '上班' THEN 1 ELSE 2 END as attType,
'0' as attAddress, lon as attLon, lat as attLat, '1' as dataSource '0' as attAddress, lon as attLon, lat as attLat, '1' as dataSource
from gz_cloud.fc_sup_attendance sup from gz_cloud_test.fc_sup_attendance sup
where sup.attendance_date where sup.attendance_date
<if test=' pushType == "1" '> <if test=' pushType == "1" '>
>= #{pushDate} - INTERVAL 3 DAY >= #{pushDate} - INTERVAL 3 DAY

View File

@ -156,7 +156,13 @@
select su.user_name, so.org_name, v.* from v_att_update_data v select su.user_name, so.org_name, v.* from v_att_update_data v
left join sys_user su on su.user_id = v.user_id left join sys_user su on su.user_id = v.user_id
left join sys_organization so on so.id = v.org_id left join sys_organization so on so.id = v.org_id
where att_current_day = #{attCurrentDay} <where>
<if test="attCurrentDay != null and attCurrentDay != ''">
AND att_current_day = #{attCurrentDay}
</if>
<if test="startDate != null and startDate != ''">
AND att_current_day between #{startDate} AND #{endDate}
</if>
<if test='attStatus != null and attStatus == "6"'> <if test='attStatus != null and attStatus == "6"'>
and (toWorkAttStatus in (12,13,14,15,16,17,18) or offWorkAttStatus in (12,13,14,15,16,17,18)) and (toWorkAttStatus in (12,13,14,15,16,17,18) or offWorkAttStatus in (12,13,14,15,16,17,18))
</if> </if>
@ -171,6 +177,7 @@
<if test="userName != null and userName != ''"> <if test="userName != null and userName != ''">
AND su.user_name like concat('%', #{userName}, '%') AND su.user_name like concat('%', #{userName}, '%')
</if> </if>
</where>
ORDER BY att_current_day DESC ORDER BY att_current_day DESC
</select> </select>

View File

@ -9,6 +9,8 @@
su.user_name, su.user_name,
so.org_name AS oldOrgName, so.org_name AS oldOrgName,
so2.org_name AS newOrgName, so2.org_name AS newOrgName,
ag.group_name AS oldAttGroup,
ag2.group_name AS newAttGroup,
oc.* oc.*
FROM FROM
org_change oc org_change oc
@ -18,6 +20,10 @@
AND so.is_active = '1' AND so.is_active = '1'
LEFT JOIN sys_organization so2 ON oc.new_org_id = so2.id LEFT JOIN sys_organization so2 ON oc.new_org_id = so2.id
AND so2.is_active = '1' AND so2.is_active = '1'
LEFT JOIN att_group ag ON oc.old_att_group = ag.id
AND ag.is_active = '1'
LEFT JOIN att_group ag2 ON oc.new_att_group = ag2.id
AND ag2.is_active = '1'
WHERE WHERE
oc.is_active = '1' oc.is_active = '1'
<if test="userId != null and userId != '' "> <if test="userId != null and userId != '' ">