月报表、月异常报表导出修改
This commit is contained in:
parent
d5757a7e05
commit
96194bd879
|
|
@ -963,6 +963,26 @@ public class DateTimeHelper {
|
|||
return dateList.toArray(new String[0]);
|
||||
}
|
||||
|
||||
public static List<String> getMonthStartAndEndDay(String startMonth, String endMonth){
|
||||
List<String> list = new ArrayList<>();
|
||||
// 格式化器,用于解析年月字符串
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM");
|
||||
// 解析开始年月
|
||||
YearMonth start = YearMonth.parse(startMonth, formatter);
|
||||
// 获取开始年月的第一天
|
||||
LocalDate startDate = start.atDay(1);
|
||||
// 解析结束年月
|
||||
YearMonth end = YearMonth.parse(endMonth, formatter);
|
||||
// 获取结束年月的最后一天
|
||||
LocalDate endDate = end.atEndOfMonth();
|
||||
// 输出结果
|
||||
System.out.println("开始年月的第一天: " + startDate);
|
||||
System.out.println("结束年月的最后一天: " + endDate);
|
||||
list.add(startDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
|
||||
list.add(endDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
|
||||
return list;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
boolean b = DateTimeHelper.compareTime2("2024-11-27 08:01:35","2024-11-27 08:01:43");
|
||||
System.out.println(b);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.bonus.system.att.controller;
|
||||
|
||||
import com.bonus.common.core.utils.DateTimeHelper;
|
||||
import com.bonus.common.core.utils.StringHelper;
|
||||
import com.bonus.common.core.utils.poi.ExcelUtil;
|
||||
import com.bonus.common.core.utils.poi.MultiSheetExcelExporter;
|
||||
|
|
@ -167,10 +168,10 @@ public class AttDetailByMonthController extends BaseController {
|
|||
}
|
||||
MultiSheetExcelExporter exporter = new MultiSheetExcelExporter();
|
||||
//将表格时间区间取出来做标题
|
||||
String title = bean.getAttCurrentMonth();
|
||||
String title = bean.getStartMonth() + " ~ " + bean.getEndMonth();
|
||||
List<AttDetailByMonthBean> attDayReportList = attDetailByMonthService.selectAttDetailList(bean);
|
||||
Sheet departmentSheet1 = exporter.createSheet("月异常报表详情");
|
||||
List<String> departmentHeaders1 = Arrays.asList("序号", "姓名", "所属部门", "考勤月", "应考勤天数", "正常打卡天数",
|
||||
List<String> departmentHeaders1 = Arrays.asList("序号", "姓名", "所属部门", "考勤月","打卡记录", "应考勤天数", "正常打卡天数",
|
||||
"迟到天数", "早退天数", "旷工天数", "打卡地异常天数", "出入异常天数");
|
||||
exporter.addHeaderRowAndTitle(departmentSheet1, departmentHeaders1, title);
|
||||
List<Map<String, Object>> departmentData1 = new ArrayList<>();
|
||||
|
|
@ -180,6 +181,7 @@ public class AttDetailByMonthController extends BaseController {
|
|||
map.put("姓名", attDayReportList.get(i).getName());
|
||||
map.put("所属部门", attDayReportList.get(i).getOrgName());
|
||||
map.put("考勤月", attDayReportList.get(i).getAttCurrentMonth());
|
||||
map.put("打卡记录", attDayReportList.get(i).getClockingRecordNum());
|
||||
map.put("应考勤天数", attDayReportList.get(i).getRequiredDays());
|
||||
map.put("正常打卡天数", attDayReportList.get(i).getNormalNum());
|
||||
map.put("迟到天数", attDayReportList.get(i).getLateNum());
|
||||
|
|
@ -203,8 +205,9 @@ public class AttDetailByMonthController extends BaseController {
|
|||
headers.put("9", "打卡地异常");
|
||||
headers.put("99", "工作外出");
|
||||
Map<String, String> attStatus = getStringStringMap();
|
||||
if (StringHelper.isNotEmpty(bean.getAttCurrentMonth())) {
|
||||
List<String> monthFirstAndLast = getMonthFirstAndLast(bean.getAttCurrentMonth());
|
||||
if (StringHelper.isNotEmpty(bean.getStartMonth()) && StringHelper.isNotEmpty(bean.getEndMonth())) {
|
||||
// List<String> monthFirstAndLast = getMonthFirstAndLast(bean.getAttCurrentMonth());
|
||||
List<String> monthFirstAndLast = DateTimeHelper.getMonthStartAndEndDay(bean.getStartMonth(),bean.getEndMonth());
|
||||
AttDetailBean dayTable = new AttDetailBean();
|
||||
dayTable.setStartDate(monthFirstAndLast.get(0));
|
||||
dayTable.setEndDate(monthFirstAndLast.get(1));
|
||||
|
|
@ -221,7 +224,9 @@ public class AttDetailByMonthController extends BaseController {
|
|||
.forEach(entry -> {
|
||||
if ("99".equals(entry.getKey())) {
|
||||
AttDataDetailsBean att = new AttDataDetailsBean();
|
||||
att.setAttCurrentMonth(bean.getAttCurrentMonth());
|
||||
att.setStartDate(monthFirstAndLast.get(0));
|
||||
att.setEndDate(monthFirstAndLast.get(1));
|
||||
// att.setAttCurrentMonth(bean.getAttCurrentMonth());
|
||||
if (bean.getOrgId() != null) {
|
||||
att.setOrgId(Long.valueOf(bean.getOrgId()));
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -348,6 +348,13 @@ public class AttendanceDetailsController extends BaseController {
|
|||
return getDataTableError(new ArrayList<>());
|
||||
}
|
||||
|
||||
@GetMapping("/getClockingRecordListByUserId")
|
||||
@Log(title = "考勤报表->月报表->打卡记录", businessType = BusinessType.QUERY)
|
||||
public TableDataInfo getClockingRecordListByUserId(AttMonthReportBean bean) {
|
||||
startPage();
|
||||
return getDataTable(attendanceDetailsService.getClockingRecordListByUserId(bean));
|
||||
}
|
||||
|
||||
/**
|
||||
* 月报表导出
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -71,4 +71,13 @@ public interface AttDetailByMonthDao {
|
|||
List<Map<String,Object>> getSonsById(int orgId);
|
||||
|
||||
Map<String,Object> getSonsFinish(int orgId);
|
||||
|
||||
/**
|
||||
* 考勤报表->月异常报表->打卡记录
|
||||
* @param c
|
||||
* @return int
|
||||
* @author cwchen
|
||||
* @date 2025/2/18 19:59
|
||||
*/
|
||||
int getClockingRecordNum(@Param("c")AttDetailByMonthBean c);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.bonus.system.att.dao;
|
||||
|
||||
import com.bonus.system.api.domain.MapVo;
|
||||
import com.bonus.system.att.entity.AttClockingRecordVo;
|
||||
import com.bonus.system.att.entity.AttDataDetailsBean;
|
||||
import com.bonus.system.att.entity.AttDayReportBean;
|
||||
import com.bonus.system.att.entity.AttMonthReportBean;
|
||||
|
|
@ -97,4 +98,22 @@ public interface AttendanceDetailsDao {
|
|||
List<AttDataDetailsBean> getOrgUserOutCountList(@Param("bean") AttDataDetailsBean bean);
|
||||
|
||||
List<MapVo> getAttStatusList();
|
||||
|
||||
/**
|
||||
* 查询打卡记录
|
||||
* @param c
|
||||
* @return int
|
||||
* @author cwchen
|
||||
* @date 2025/2/18 14:32
|
||||
*/
|
||||
int getClockingRecordNum(@Param("c") AttMonthReportBean c);
|
||||
|
||||
/**
|
||||
* 考勤报表->月报表->打卡记录
|
||||
* @param bean
|
||||
* @return List<AttClockingRecordVo>
|
||||
* @author cwchen
|
||||
* @date 2025/2/18 15:59
|
||||
*/
|
||||
List<AttClockingRecordVo> getClockingRecordListByUserId(AttMonthReportBean bean);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,35 @@
|
|||
package com.bonus.system.att.entity;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @className:AttClockingRecordVo
|
||||
* @author:cwchen
|
||||
* @date:2025-02-18-15:00
|
||||
* @version:1.0
|
||||
* @description:考勤打卡记录-vo
|
||||
*/
|
||||
@Data
|
||||
public class AttClockingRecordVo {
|
||||
|
||||
|
||||
/**考勤日期*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
private Date attCurrentDay;
|
||||
|
||||
/**考勤时间*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date attCurrentTime;
|
||||
|
||||
/**考勤类型1上班2下班*/
|
||||
private String attType;
|
||||
|
||||
/**打卡地址*/
|
||||
private String attAddress;
|
||||
|
||||
/**备注*/
|
||||
private String remark;
|
||||
}
|
||||
|
|
@ -96,6 +96,10 @@ public class AttDetailByMonthBean {
|
|||
@Excel(name = "请假天数")
|
||||
private double leaveNum;
|
||||
|
||||
/**打卡记录*/
|
||||
@Excel(name = "打卡记录")
|
||||
private int clockingRecordNum;
|
||||
|
||||
private int[] orgIds;
|
||||
|
||||
/**
|
||||
|
|
@ -106,4 +110,7 @@ public class AttDetailByMonthBean {
|
|||
/** 部门列表 */
|
||||
private List<String> orgList;
|
||||
|
||||
private String startMonth;
|
||||
private String endMonth;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -111,8 +111,17 @@ public class AttMonthReportBean {
|
|||
*/
|
||||
private Double outCount;
|
||||
|
||||
/**打卡记录*/
|
||||
@Excel(name = "打卡记录", sort = 14)
|
||||
private int clockingRecordNum;
|
||||
|
||||
/**
|
||||
* 自己项目部所在分公司下的所有项目部id
|
||||
*/
|
||||
private List<String> orgList;
|
||||
|
||||
/**开始月份*/
|
||||
private String startMonth;
|
||||
/**结束月份*/
|
||||
private String endMonth;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -79,7 +79,11 @@ public class AttDetailByMonthServiceImpl implements AttDetailByMonthService{
|
|||
List<AttDetailByMonthBean> list = new ArrayList<>();
|
||||
try {
|
||||
list = attDetailByMonthDao.selectAttAllList(data);
|
||||
|
||||
// 查询打卡记录
|
||||
list.forEach(c -> {
|
||||
int clockingRecordNum = attDetailByMonthDao.getClockingRecordNum(c);
|
||||
c.setClockingRecordNum(clockingRecordNum);
|
||||
});
|
||||
} catch (Exception e) {
|
||||
log.error("查询月异常报表列表", e);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package com.bonus.system.att.service;
|
|||
|
||||
import com.bonus.common.core.web.domain.AjaxResult;
|
||||
import com.bonus.system.api.domain.MapVo;
|
||||
import com.bonus.system.att.entity.AttClockingRecordVo;
|
||||
import com.bonus.system.att.entity.AttDataDetailsBean;
|
||||
import com.bonus.system.att.entity.AttDayReportBean;
|
||||
import com.bonus.system.att.entity.AttMonthReportBean;
|
||||
|
|
@ -111,4 +112,13 @@ public interface AttendanceDetailsService {
|
|||
List<AttDataDetailsBean> getOrgUserOutCountList(AttDataDetailsBean bean);
|
||||
|
||||
List<MapVo> getAttStatusList();
|
||||
|
||||
/**
|
||||
* 考勤报表->月报表->打卡记录
|
||||
* @param bean
|
||||
* @return List<AttClockingRecordVo>
|
||||
* @author cwchen
|
||||
* @date 2025/2/18 16:00
|
||||
*/
|
||||
List<AttClockingRecordVo> getClockingRecordListByUserId(AttMonthReportBean bean);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,10 +7,7 @@ import com.bonus.common.security.utils.SecurityUtils;
|
|||
import com.bonus.system.api.domain.MapVo;
|
||||
import com.bonus.system.api.domain.SysUser;
|
||||
import com.bonus.system.att.dao.AttendanceDetailsDao;
|
||||
import com.bonus.system.att.entity.AttDataDetailsBean;
|
||||
import com.bonus.system.att.entity.AttDayReportBean;
|
||||
import com.bonus.system.att.entity.AttGroupBean;
|
||||
import com.bonus.system.att.entity.AttMonthReportBean;
|
||||
import com.bonus.system.att.entity.*;
|
||||
import com.bonus.system.att.tasks.AttTasks;
|
||||
import com.bonus.system.att.tasks.WechatTasks;
|
||||
import com.bonus.system.basic.domain.SysNotice;
|
||||
|
|
@ -163,7 +160,13 @@ public class AttendanceDetailsServiceImpl implements AttendanceDetailsService {
|
|||
|
||||
@Override
|
||||
public List<AttMonthReportBean> getAttMonthReportList(AttMonthReportBean bean) {
|
||||
return attendanceDetailsDao.getAttMonthReportList(bean);
|
||||
List<AttMonthReportBean> attMonthReportList = attendanceDetailsDao.getAttMonthReportList(bean);
|
||||
// 查询打卡记录
|
||||
attMonthReportList.forEach(c -> {
|
||||
int clockingRecordNum = attendanceDetailsDao.getClockingRecordNum(c);
|
||||
c.setClockingRecordNum(clockingRecordNum);
|
||||
});
|
||||
return attMonthReportList;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -268,4 +271,14 @@ public class AttendanceDetailsServiceImpl implements AttendanceDetailsService {
|
|||
return allList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AttClockingRecordVo> getClockingRecordListByUserId(AttMonthReportBean bean) {
|
||||
List<AttClockingRecordVo> list = new ArrayList<>();
|
||||
try {
|
||||
list = attendanceDetailsDao.getClockingRecordListByUserId(bean);
|
||||
} catch (Exception e) {
|
||||
log.error(e.toString(),e);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import cn.hutool.poi.excel.ExcelUtil;
|
|||
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.DateTimeHelper;
|
||||
import com.bonus.common.core.utils.ExcelStyleUtil;
|
||||
import com.bonus.common.core.utils.StringHelper;
|
||||
import com.bonus.common.core.utils.StringUtils;
|
||||
|
|
@ -672,10 +673,10 @@ public class ExportFileController {
|
|||
}
|
||||
MultiSheetExcelExporter exporter = new MultiSheetExcelExporter();
|
||||
//将表格时间区间取出来做标题
|
||||
String title = bean.getMonth();
|
||||
String title = bean.getStartMonth() + " ~ " + bean.getEndMonth();
|
||||
List<AttMonthReportBean> attDayReportList = attendanceDetailsService.getAttMonthReportList(bean);
|
||||
Sheet departmentSheet1 = exporter.createSheet("月报表详情");
|
||||
List<String> departmentHeaders1 = Arrays.asList("序号", "姓名", "所属部门", "考勤月", "应考勤天数", "正常打卡天数",
|
||||
List<String> departmentHeaders1 = Arrays.asList("序号", "姓名", "所属部门", "考勤月","打卡记录", "应考勤天数", "正常打卡天数",
|
||||
"迟到天数", "早退天数", "旷工天数", "请假天数", "打卡地异常天数", "出入异常天数", "轮休天数", "临时外出天数", "出差天数");
|
||||
exporter.addHeaderRowAndTitle(departmentSheet1, departmentHeaders1, title);
|
||||
List<Map<String, Object>> departmentData1 = new ArrayList<>();
|
||||
|
|
@ -684,7 +685,8 @@ public class ExportFileController {
|
|||
map.put("序号", i + 1);
|
||||
map.put("姓名", attDayReportList.get(i).getUserName());
|
||||
map.put("所属部门", attDayReportList.get(i).getOrgName());
|
||||
map.put("考勤月", title);
|
||||
map.put("考勤月", attDayReportList.get(i).getAttCurrentMonth());
|
||||
map.put("打卡记录", attDayReportList.get(i).getClockingRecordNum());
|
||||
map.put("应考勤天数", attDayReportList.get(i).getRequiredDays());
|
||||
map.put("正常打卡天数", attDayReportList.get(i).getNormalNum());
|
||||
map.put("迟到天数", attDayReportList.get(i).getLateNum());
|
||||
|
|
@ -713,8 +715,8 @@ public class ExportFileController {
|
|||
headers.put("10", "出差详情");
|
||||
headers.put("99", "工作外出");
|
||||
Map<Long, String> attStatus = getStringStringMap();
|
||||
if (StringHelper.isNotEmpty(bean.getMonth())) {
|
||||
List<String> monthFirstAndLast = getMonthFirstAndLast(bean.getMonth());
|
||||
if (StringHelper.isNotEmpty(bean.getStartMonth()) && StringHelper.isNotEmpty(bean.getEndMonth())) {
|
||||
List<String> monthFirstAndLast = DateTimeHelper.getMonthStartAndEndDay(bean.getStartMonth(), bean.getEndMonth());
|
||||
AttDetailBean dayTable = new AttDetailBean();
|
||||
dayTable.setStartDate(monthFirstAndLast.get(0));
|
||||
dayTable.setEndDate(monthFirstAndLast.get(1));
|
||||
|
|
@ -731,7 +733,9 @@ public class ExportFileController {
|
|||
.forEach(entry -> {
|
||||
if ("99".equals(entry.getKey())) {
|
||||
AttDataDetailsBean att = new AttDataDetailsBean();
|
||||
att.setAttCurrentMonth(bean.getMonth());
|
||||
// att.setAttCurrentMonth(bean.getMonth());
|
||||
att.setStartDate(monthFirstAndLast.get(0));
|
||||
att.setEndDate(monthFirstAndLast.get(1));
|
||||
if (bean.getOrgId() != null) {
|
||||
att.setOrgId(bean.getOrgId());
|
||||
}else{
|
||||
|
|
|
|||
|
|
@ -64,8 +64,8 @@
|
|||
left join att_group_person_relation p on p.user_id = amr.user_id
|
||||
where amr.is_active = 1 and p.is_active = 1
|
||||
and amr.required_days != amr.normal_num
|
||||
<if test="bean.attCurrentMonth != null and bean.attCurrentMonth != '' ">
|
||||
and amr.att_current_month = #{bean.attCurrentMonth}
|
||||
<if test="bean.startMonth != null and bean.startMonth != '' ">
|
||||
and amr.att_current_month BETWEEN #{bean.startMonth} AND #{bean.endMonth}
|
||||
</if>
|
||||
<if test="bean.name != null and bean.name != '' ">
|
||||
and INSTR(amr.name,#{bean.name}) > 0
|
||||
|
|
@ -271,4 +271,9 @@
|
|||
where so.id = #{orgId}
|
||||
and is_active = 1
|
||||
</select>
|
||||
<!--考勤报表->月异常报表->打卡记录-->
|
||||
<select id="getClockingRecordNum" resultType="java.lang.Integer">
|
||||
SELECT COUNT(*) FROM att_source_data
|
||||
WHERE name = #{c.name} AND DATE_FORMAT(att_current_day,'%Y-%m') = #{c.attCurrentMonth} AND is_active = '1'
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
|
|||
|
|
@ -249,10 +249,11 @@
|
|||
</select>
|
||||
|
||||
<select id="getAttMonthReportList" resultType="com.bonus.system.att.entity.AttMonthReportBean">
|
||||
select v.*, v.name as userName,IF(awa.outCount is null,0,awa.outCount) as outCount from att_month_report v
|
||||
select v.*, v.name as userName,IF(awa.outCount is null,0,awa.outCount) as outCount
|
||||
from att_month_report v
|
||||
left join att_group_person_relation p on p.user_id = v.user_id and p.is_active = 1
|
||||
LEFT JOIN (SELECT user_id,count(user_id) as outCount FROM att_work_abnormal WHERE LOCATE(#{bean.month},att_current_day) GROUP BY user_id) awa ON awa.user_id = v.user_id
|
||||
where v.att_current_month = #{bean.month} and p.group_id is not null
|
||||
where v.att_current_month BETWEEN #{bean.startMonth} AND #{bean.endMonth} and p.group_id is not null
|
||||
<if test="bean.orgId != null and bean.orgId != ''">
|
||||
AND v.org_id = #{bean.orgId}
|
||||
</if>
|
||||
|
|
@ -447,8 +448,8 @@
|
|||
<if test="bean.attCurrentDay != null and bean.attCurrentDay != ''">
|
||||
and awa.att_current_day = #{bean.attCurrentDay}
|
||||
</if>
|
||||
<if test="bean.attCurrentMonth != null and bean.attCurrentMonth != ''">
|
||||
and locate(#{bean.attCurrentMonth},awa.att_current_day)
|
||||
<if test="bean.startDate != null and bean.startDate != '' and bean.endDate != null and bean.endDate != ''">
|
||||
AND awa.att_current_day BETWEEN #{bean.startDate} AND #{bean.endDate}
|
||||
</if>
|
||||
<if test="bean.userName != null and bean.userName != ''">
|
||||
and locate(#{bean.userName},awa.user_name)
|
||||
|
|
@ -478,6 +479,21 @@
|
|||
ORDER BY
|
||||
dict_sort ASC
|
||||
</select>
|
||||
<!--查询打卡记录-->
|
||||
<select id="getClockingRecordNum" resultType="java.lang.Integer">
|
||||
SELECT COUNT(*) FROM att_source_data
|
||||
WHERE name = #{c.userName} AND DATE_FORMAT(att_current_day,'%Y-%m') = #{c.attCurrentMonth} AND is_active = '1'
|
||||
</select>
|
||||
<!--考勤报表->月报表->打卡记录-->
|
||||
<select id="getClockingRecordListByUserId" resultType="com.bonus.system.att.entity.AttClockingRecordVo">
|
||||
SELECT att_current_day AS attCurrentDay,
|
||||
att_current_time AS attCurrentTime,
|
||||
att_type AS attType,
|
||||
att_address AS attAddress,
|
||||
remark
|
||||
FROM att_source_data
|
||||
WHERE name = #{userName} AND DATE_FORMAT(att_current_day,'%Y-%m') = #{month} AND is_active = '1'
|
||||
</select>
|
||||
|
||||
<update id="updateAttDetailsData">
|
||||
<foreach collection="list" item="params" separator=";">
|
||||
|
|
|
|||
Loading…
Reference in New Issue