|
|
|
|
@ -9,10 +9,13 @@ import cn.hutool.poi.excel.ExcelWriter;
|
|
|
|
|
import com.bonus.common.core.constant.BusinessConstants;
|
|
|
|
|
import com.bonus.common.core.enums.AttStatus;
|
|
|
|
|
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.poi.MultiSheetExcelExporter;
|
|
|
|
|
import com.bonus.common.security.annotation.RequiresPermissions;
|
|
|
|
|
import com.bonus.common.security.utils.SecurityUtils;
|
|
|
|
|
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.OrgChangeService;
|
|
|
|
|
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.WechatService;
|
|
|
|
|
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.springframework.beans.BeanUtils;
|
|
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
|
|
@ -42,7 +45,6 @@ import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import javax.servlet.ServletOutputStream;
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.io.UnsupportedEncodingException;
|
|
|
|
|
@ -50,6 +52,10 @@ import java.net.URLEncoder;
|
|
|
|
|
import java.text.DateFormat;
|
|
|
|
|
import java.text.ParseException;
|
|
|
|
|
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.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
@ -121,9 +127,13 @@ public class ExportFileController {
|
|
|
|
|
@Resource(name = "WechatService")
|
|
|
|
|
private WechatService wechatService;
|
|
|
|
|
|
|
|
|
|
@Resource(name = "attDetailByMonthService")
|
|
|
|
|
private AttDetailByMonthService attDetailByMonthService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 分公司项目部导出
|
|
|
|
|
*
|
|
|
|
|
* @param response
|
|
|
|
|
* @param bean
|
|
|
|
|
* @return void
|
|
|
|
|
@ -155,6 +165,7 @@ public class ExportFileController {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 轮休、请假、外出办事导出
|
|
|
|
|
*
|
|
|
|
|
* @param response
|
|
|
|
|
* @param bean
|
|
|
|
|
* @return void
|
|
|
|
|
@ -165,8 +176,8 @@ public class ExportFileController {
|
|
|
|
|
public void exportHoliday(HttpServletResponse response, HolidayBean bean) {
|
|
|
|
|
try {
|
|
|
|
|
List<HolidayBean> personExportVoList = new ArrayList<>();
|
|
|
|
|
if("审批".equals(bean.getExportType())){
|
|
|
|
|
}else{
|
|
|
|
|
if ("审批".equals(bean.getExportType())) {
|
|
|
|
|
} else {
|
|
|
|
|
//只能查询自己的
|
|
|
|
|
bean.setUserId(SecurityUtils.getLoginUser().getSysUser().getUserId());
|
|
|
|
|
}
|
|
|
|
|
@ -176,15 +187,15 @@ public class ExportFileController {
|
|
|
|
|
vo.setId((i + 1));
|
|
|
|
|
vo.setExamineStatus(BusinessConstants.WAIT_CHECK.equals(vo.getExamineStatus()) ? "待审核" : BusinessConstants.PASS_CHECK.equals(vo.getExamineStatus()) ? "已通过" : BusinessConstants.NOT_PASS_CHECK.equals(vo.getExamineStatus()) ? "未通过" : "撤回");
|
|
|
|
|
//事件处理
|
|
|
|
|
if("1".equals(vo.getLeaveStartInterval())){
|
|
|
|
|
vo.setLeaveStartInterval(vo.getLeaveStartDate()+" 上午");
|
|
|
|
|
}else{
|
|
|
|
|
vo.setLeaveStartInterval(vo.getLeaveStartDate()+" 下午");
|
|
|
|
|
if ("1".equals(vo.getLeaveStartInterval())) {
|
|
|
|
|
vo.setLeaveStartInterval(vo.getLeaveStartDate() + " 上午");
|
|
|
|
|
} else {
|
|
|
|
|
vo.setLeaveStartInterval(vo.getLeaveStartDate() + " 下午");
|
|
|
|
|
}
|
|
|
|
|
if("1".equals(vo.getLeaveEndInterval())){
|
|
|
|
|
vo.setLeaveEndInterval(vo.getLeaveEndDate()+" 上午");
|
|
|
|
|
}else{
|
|
|
|
|
vo.setLeaveEndInterval(vo.getLeaveEndDate()+" 下午");
|
|
|
|
|
if ("1".equals(vo.getLeaveEndInterval())) {
|
|
|
|
|
vo.setLeaveEndInterval(vo.getLeaveEndDate() + " 上午");
|
|
|
|
|
} else {
|
|
|
|
|
vo.setLeaveEndInterval(vo.getLeaveEndDate() + " 下午");
|
|
|
|
|
}
|
|
|
|
|
// 创建一个 SimpleDateFormat 对象,用于格式化日期
|
|
|
|
|
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
@ -201,6 +212,7 @@ public class ExportFileController {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 考勤明细导出/原始数据导出
|
|
|
|
|
*
|
|
|
|
|
* @param response
|
|
|
|
|
* @param bean
|
|
|
|
|
* @return void
|
|
|
|
|
@ -211,9 +223,9 @@ public class ExportFileController {
|
|
|
|
|
public void att(HttpServletResponse response, AttDataDetailsBean bean) {
|
|
|
|
|
try {
|
|
|
|
|
List<AttDataDetailsBean> attList;
|
|
|
|
|
if("考勤明细".equals(bean.getExportType())){
|
|
|
|
|
if ("考勤明细".equals(bean.getExportType())) {
|
|
|
|
|
attList = attendanceDetailsService.exportAttDetailsList(bean);
|
|
|
|
|
}else{
|
|
|
|
|
} else {
|
|
|
|
|
attList = attendanceDetailsService.exportAttOriginalsList(bean);
|
|
|
|
|
}
|
|
|
|
|
//将数据转换成为汉字
|
|
|
|
|
@ -249,9 +261,9 @@ public class ExportFileController {
|
|
|
|
|
.map(user -> {
|
|
|
|
|
AttDayBean attDayBean = new AttDayBean();
|
|
|
|
|
attDayBean.setCurrentDay(user.getAttCurrentDay());
|
|
|
|
|
if(!user.getToWorkAttStatus().equals(user.getOffWorkAttStatus())){
|
|
|
|
|
attDayBean.setAttType(user.getToWorkAttStatus()+"|"+user.getOffWorkAttStatus());
|
|
|
|
|
}else{
|
|
|
|
|
if (!user.getToWorkAttStatus().equals(user.getOffWorkAttStatus())) {
|
|
|
|
|
attDayBean.setAttType(user.getToWorkAttStatus() + "|" + user.getOffWorkAttStatus());
|
|
|
|
|
} else {
|
|
|
|
|
attDayBean.setAttType(user.getToWorkAttStatus());
|
|
|
|
|
}
|
|
|
|
|
// if(user.getOrgName().contains(",")){
|
|
|
|
|
@ -267,7 +279,7 @@ public class ExportFileController {
|
|
|
|
|
.anyMatch(attDay -> dayStr.equals(attDay.getCurrentDay()));
|
|
|
|
|
// 如果不存在,则添加新的 AttDayBean 记录
|
|
|
|
|
if (!dayExists) {
|
|
|
|
|
listAttDay.add(new AttDayBean(dayStr, "旷",""));
|
|
|
|
|
listAttDay.add(new AttDayBean(dayStr, "旷", ""));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -327,19 +339,19 @@ public class ExportFileController {
|
|
|
|
|
// "部门:",true);
|
|
|
|
|
|
|
|
|
|
writer.merge(2 + days.size(),
|
|
|
|
|
bean.getStartDate() + "至" + bean.getEndDate() + "考勤",true);
|
|
|
|
|
bean.getStartDate() + "至" + bean.getEndDate() + "考勤", true);
|
|
|
|
|
int rowNum = 2;
|
|
|
|
|
writer.merge(rowNum + listData.size(),rowNum + listData.size() + 1,0,0,
|
|
|
|
|
"说明",false);
|
|
|
|
|
writer.merge(rowNum + listData.size(),rowNum + listData.size(),1,2 + days.size(),
|
|
|
|
|
"1.考勤记录:出勤记“√”,出差记“Δ”,年休假记“年”,探亲假记“探”,事假记“事”,法定假记“法”,病假记“病”,产假记“产”,婚假记“婚”,丧假记“丧”,补休记“补”,旷工记“旷”,迟到记“迟”,早退记“退”,省内工地记“工”,省外工地记“外”,出差需在备注栏备注清楚出差地点。",false);
|
|
|
|
|
writer.merge(rowNum + listData.size() + 1,rowNum + listData.size() + 1,1,2 + days.size(),
|
|
|
|
|
"2.员工有关请假凭证,记录清楚准确,与本表于次月3日前一并报人力资源管理部门(专业分公司报送时间为30日前)。",false);
|
|
|
|
|
writer.merge(rowNum + listData.size(), rowNum + listData.size() + 1, 0, 0,
|
|
|
|
|
"说明", false);
|
|
|
|
|
writer.merge(rowNum + listData.size(), rowNum + listData.size(), 1, 2 + days.size(),
|
|
|
|
|
"1.考勤记录:出勤记“√”,出差记“Δ”,年休假记“年”,探亲假记“探”,事假记“事”,法定假记“法”,病假记“病”,产假记“产”,婚假记“婚”,丧假记“丧”,补休记“补”,旷工记“旷”,迟到记“迟”,早退记“退”,省内工地记“工”,省外工地记“外”,出差需在备注栏备注清楚出差地点。", false);
|
|
|
|
|
writer.merge(rowNum + listData.size() + 1, rowNum + listData.size() + 1, 1, 2 + days.size(),
|
|
|
|
|
"2.员工有关请假凭证,记录清楚准确,与本表于次月3日前一并报人力资源管理部门(专业分公司报送时间为30日前)。", false);
|
|
|
|
|
writer.autoSizeColumn(3);
|
|
|
|
|
writer.write(rows, true);
|
|
|
|
|
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8");
|
|
|
|
|
try {
|
|
|
|
|
response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode( bean.getStartDate() + "至" + bean.getEndDate() + "考勤", "UTF-8") + ".xlsx");
|
|
|
|
|
response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(bean.getStartDate() + "至" + bean.getEndDate() + "考勤", "UTF-8") + ".xlsx");
|
|
|
|
|
} catch (UnsupportedEncodingException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
@ -361,6 +373,7 @@ public class ExportFileController {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 组织导出
|
|
|
|
|
*
|
|
|
|
|
* @param response
|
|
|
|
|
* @param bean
|
|
|
|
|
* @return void
|
|
|
|
|
@ -390,6 +403,7 @@ public class ExportFileController {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 日报表导出
|
|
|
|
|
*
|
|
|
|
|
* @param response
|
|
|
|
|
* @param bean
|
|
|
|
|
* @return void
|
|
|
|
|
@ -398,24 +412,120 @@ public class ExportFileController {
|
|
|
|
|
*/
|
|
|
|
|
@GetMapping("/exportDayReport")
|
|
|
|
|
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 {
|
|
|
|
|
List<AttDayReportExportBean> personExportVoList = new ArrayList<>();
|
|
|
|
|
MultiSheetExcelExporter exporter = new MultiSheetExcelExporter();
|
|
|
|
|
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++) {
|
|
|
|
|
AttDayReportBean vo = attDayReportList.get(i);
|
|
|
|
|
AttDayReportExportBean voe = new AttDayReportExportBean();
|
|
|
|
|
BeanUtils.copyProperties(vo, voe);
|
|
|
|
|
voe.setId((i + 1));
|
|
|
|
|
personExportVoList.add(voe);
|
|
|
|
|
Map<String, Object> map = new LinkedHashMap<>();
|
|
|
|
|
map.put("序号", i + 1);
|
|
|
|
|
map.put("考勤日期", attDayReportList.get(i).getAttCurrentDay());
|
|
|
|
|
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, AttDayReportExportBean.class, "日报表导出", "日报表导出", "日报表导出", response);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
log.error(e.toString(), e);
|
|
|
|
|
exporter.addDataRows(departmentSheet1, departmentData1, departmentHeaders1);
|
|
|
|
|
//详情的数据导出
|
|
|
|
|
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 bean
|
|
|
|
|
* @return void
|
|
|
|
|
@ -424,35 +534,143 @@ public class ExportFileController {
|
|
|
|
|
*/
|
|
|
|
|
@GetMapping("/exportMonthReport")
|
|
|
|
|
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 {
|
|
|
|
|
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);
|
|
|
|
|
MultiSheetExcelExporter exporter = new MultiSheetExcelExporter();
|
|
|
|
|
List<AttMonthReportBean> attDayReportList = attendanceDetailsService.getAttMonthReportList(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++) {
|
|
|
|
|
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);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
log.error(e.toString(), e);
|
|
|
|
|
exporter.addDataRows(departmentSheet1, departmentData1, departmentHeaders1);
|
|
|
|
|
//详情的数据导出
|
|
|
|
|
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文件
|
|
|
|
|
* @param list 数据
|
|
|
|
|
* @param clazz bean.class
|
|
|
|
|
* @param title 标题
|
|
|
|
|
*
|
|
|
|
|
* @param list 数据
|
|
|
|
|
* @param clazz bean.class
|
|
|
|
|
* @param title 标题
|
|
|
|
|
* @param sheetName sheet名字
|
|
|
|
|
* @param fileName 文件名
|
|
|
|
|
* @param response 响应
|
|
|
|
|
* @param fileName 文件名
|
|
|
|
|
* @param response 响应
|
|
|
|
|
* @throws IOException
|
|
|
|
|
*/
|
|
|
|
|
private static void extracted(List<? extends Object> list,Class<? extends Object> clazz,String title,String sheetName,String fileName, HttpServletResponse response) throws IOException {
|
|
|
|
|
private static void extracted(List<? extends Object> list, Class<? extends Object> clazz, String title, String sheetName, String fileName, HttpServletResponse response) throws IOException {
|
|
|
|
|
ExportParams exportParams = new ExportParams(title, sheetName, ExcelType.XSSF);
|
|
|
|
|
exportParams.setStyle(ExcelStyleUtil.class);
|
|
|
|
|
Workbook workbook = ExcelExportUtil.exportExcel(exportParams, clazz, list);
|
|
|
|
|
@ -497,9 +715,9 @@ public class ExportFileController {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 休假报备
|
|
|
|
|
*
|
|
|
|
|
* @param response
|
|
|
|
|
* @param bean
|
|
|
|
|
* @return void
|
|
|
|
|
@ -513,15 +731,15 @@ public class ExportFileController {
|
|
|
|
|
LeaveReportingBean vo = personLists.get(i);
|
|
|
|
|
vo.setId((i + 1));
|
|
|
|
|
//事件处理
|
|
|
|
|
if("1".equals(vo.getLeaveStartInterval())){
|
|
|
|
|
vo.setLeaveStartInterval(vo.getLeaveStartDate()+" ");
|
|
|
|
|
}else{
|
|
|
|
|
vo.setLeaveStartInterval(vo.getLeaveStartDate()+" ");
|
|
|
|
|
if ("1".equals(vo.getLeaveStartInterval())) {
|
|
|
|
|
vo.setLeaveStartInterval(vo.getLeaveStartDate() + " ");
|
|
|
|
|
} else {
|
|
|
|
|
vo.setLeaveStartInterval(vo.getLeaveStartDate() + " ");
|
|
|
|
|
}
|
|
|
|
|
if("1".equals(vo.getLeaveEndInterval())){
|
|
|
|
|
vo.setLeaveEndInterval(vo.getLeaveEndDate()+" ");
|
|
|
|
|
}else{
|
|
|
|
|
vo.setLeaveEndInterval(vo.getLeaveEndDate()+" ");
|
|
|
|
|
if ("1".equals(vo.getLeaveEndInterval())) {
|
|
|
|
|
vo.setLeaveEndInterval(vo.getLeaveEndDate() + " ");
|
|
|
|
|
} else {
|
|
|
|
|
vo.setLeaveEndInterval(vo.getLeaveEndDate() + " ");
|
|
|
|
|
}
|
|
|
|
|
// 创建一个 SimpleDateFormat 对象,用于格式化日期
|
|
|
|
|
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
@ -539,6 +757,7 @@ public class ExportFileController {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 出差报备
|
|
|
|
|
*
|
|
|
|
|
* @param response
|
|
|
|
|
* @param bean
|
|
|
|
|
* @return void
|
|
|
|
|
@ -552,15 +771,15 @@ public class ExportFileController {
|
|
|
|
|
EvectionBean vo = personLists.get(i);
|
|
|
|
|
vo.setId((i + 1));
|
|
|
|
|
//事件处理
|
|
|
|
|
if("1".equals(vo.getLeaveStartInterval())){
|
|
|
|
|
vo.setLeaveStartInterval(vo.getLeaveStartDate()+" ");
|
|
|
|
|
}else{
|
|
|
|
|
vo.setLeaveStartInterval(vo.getLeaveStartDate()+" ");
|
|
|
|
|
if ("1".equals(vo.getLeaveStartInterval())) {
|
|
|
|
|
vo.setLeaveStartInterval(vo.getLeaveStartDate() + " ");
|
|
|
|
|
} else {
|
|
|
|
|
vo.setLeaveStartInterval(vo.getLeaveStartDate() + " ");
|
|
|
|
|
}
|
|
|
|
|
if("1".equals(vo.getLeaveEndInterval())){
|
|
|
|
|
vo.setLeaveEndInterval(vo.getLeaveEndDate()+" ");
|
|
|
|
|
}else{
|
|
|
|
|
vo.setLeaveEndInterval(vo.getLeaveEndDate()+" ");
|
|
|
|
|
if ("1".equals(vo.getLeaveEndInterval())) {
|
|
|
|
|
vo.setLeaveEndInterval(vo.getLeaveEndDate() + " ");
|
|
|
|
|
} else {
|
|
|
|
|
vo.setLeaveEndInterval(vo.getLeaveEndDate() + " ");
|
|
|
|
|
}
|
|
|
|
|
// 创建一个 SimpleDateFormat 对象,用于格式化日期
|
|
|
|
|
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
@ -577,6 +796,7 @@ public class ExportFileController {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 组织架构变更导出
|
|
|
|
|
*
|
|
|
|
|
* @param response
|
|
|
|
|
* @param bean
|
|
|
|
|
* @return void
|
|
|
|
|
@ -588,12 +808,12 @@ public class ExportFileController {
|
|
|
|
|
public void exportOrgChange(HttpServletResponse response, OrgChangeBean bean) {
|
|
|
|
|
try {
|
|
|
|
|
List<OrgChangeBean> personExportVoList = new ArrayList<>();
|
|
|
|
|
if("1".equals(bean.getExportType())){
|
|
|
|
|
if ("1".equals(bean.getExportType())) {
|
|
|
|
|
//只查自己的
|
|
|
|
|
Long userId = SecurityUtils.getLoginUser().getSysUser().getUserId();
|
|
|
|
|
bean.setUserId(userId);
|
|
|
|
|
}else{
|
|
|
|
|
if(StringUtils.isEmpty(bean.getIsCheck())){
|
|
|
|
|
} else {
|
|
|
|
|
if (StringUtils.isEmpty(bean.getIsCheck())) {
|
|
|
|
|
//不查撤回的
|
|
|
|
|
bean.setIsCheck("-1");
|
|
|
|
|
}
|
|
|
|
|
@ -618,9 +838,9 @@ public class ExportFileController {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 小程序打卡数据导出
|
|
|
|
|
*
|
|
|
|
|
* @param response
|
|
|
|
|
* @param bean
|
|
|
|
|
* @return void
|
|
|
|
|
@ -664,7 +884,7 @@ public class ExportFileController {
|
|
|
|
|
break;
|
|
|
|
|
case "6":
|
|
|
|
|
attStatus = "请假";
|
|
|
|
|
break;
|
|
|
|
|
break;
|
|
|
|
|
case "7":
|
|
|
|
|
attStatus = "外出办事";
|
|
|
|
|
break;
|
|
|
|
|
@ -690,6 +910,7 @@ public class ExportFileController {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 数据管理-休假报备
|
|
|
|
|
*
|
|
|
|
|
* @param response
|
|
|
|
|
* @param bean
|
|
|
|
|
* @return void
|
|
|
|
|
@ -703,15 +924,15 @@ public class ExportFileController {
|
|
|
|
|
WechatLeaveReportingBean vo = personLists.get(i);
|
|
|
|
|
vo.setId((i + 1));
|
|
|
|
|
//事件处理
|
|
|
|
|
if("1".equals(vo.getLeaveStartInterval())){
|
|
|
|
|
vo.setLeaveStartInterval(vo.getLeaveStartDate()+" ");
|
|
|
|
|
}else{
|
|
|
|
|
vo.setLeaveStartInterval(vo.getLeaveStartDate()+" ");
|
|
|
|
|
if ("1".equals(vo.getLeaveStartInterval())) {
|
|
|
|
|
vo.setLeaveStartInterval(vo.getLeaveStartDate() + " ");
|
|
|
|
|
} else {
|
|
|
|
|
vo.setLeaveStartInterval(vo.getLeaveStartDate() + " ");
|
|
|
|
|
}
|
|
|
|
|
if("1".equals(vo.getLeaveEndInterval())){
|
|
|
|
|
vo.setLeaveEndInterval(vo.getLeaveEndDate()+" ");
|
|
|
|
|
}else{
|
|
|
|
|
vo.setLeaveEndInterval(vo.getLeaveEndDate()+" ");
|
|
|
|
|
if ("1".equals(vo.getLeaveEndInterval())) {
|
|
|
|
|
vo.setLeaveEndInterval(vo.getLeaveEndDate() + " ");
|
|
|
|
|
} else {
|
|
|
|
|
vo.setLeaveEndInterval(vo.getLeaveEndDate() + " ");
|
|
|
|
|
}
|
|
|
|
|
// 创建一个 SimpleDateFormat 对象,用于格式化日期
|
|
|
|
|
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
@ -729,6 +950,7 @@ public class ExportFileController {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 数据管理-出差报备
|
|
|
|
|
*
|
|
|
|
|
* @param response
|
|
|
|
|
* @param bean
|
|
|
|
|
* @return void
|
|
|
|
|
@ -742,15 +964,15 @@ public class ExportFileController {
|
|
|
|
|
WechatEvectionBean vo = personLists.get(i);
|
|
|
|
|
vo.setId((i + 1));
|
|
|
|
|
//事件处理
|
|
|
|
|
if("1".equals(vo.getLeaveStartInterval())){
|
|
|
|
|
vo.setLeaveStartInterval(vo.getLeaveStartDate()+" ");
|
|
|
|
|
}else{
|
|
|
|
|
vo.setLeaveStartInterval(vo.getLeaveStartDate()+" ");
|
|
|
|
|
if ("1".equals(vo.getLeaveStartInterval())) {
|
|
|
|
|
vo.setLeaveStartInterval(vo.getLeaveStartDate() + " ");
|
|
|
|
|
} else {
|
|
|
|
|
vo.setLeaveStartInterval(vo.getLeaveStartDate() + " ");
|
|
|
|
|
}
|
|
|
|
|
if("1".equals(vo.getLeaveEndInterval())){
|
|
|
|
|
vo.setLeaveEndInterval(vo.getLeaveEndDate()+" ");
|
|
|
|
|
}else{
|
|
|
|
|
vo.setLeaveEndInterval(vo.getLeaveEndDate()+" ");
|
|
|
|
|
if ("1".equals(vo.getLeaveEndInterval())) {
|
|
|
|
|
vo.setLeaveEndInterval(vo.getLeaveEndDate() + " ");
|
|
|
|
|
} else {
|
|
|
|
|
vo.setLeaveEndInterval(vo.getLeaveEndDate() + " ");
|
|
|
|
|
}
|
|
|
|
|
// 创建一个 SimpleDateFormat 对象,用于格式化日期
|
|
|
|
|
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
|