小程序打卡数据
This commit is contained in:
parent
768676bd01
commit
5e14cf0b29
|
|
@ -25,6 +25,8 @@ import com.bonus.system.holiday.entity.HolidayBean;
|
|||
import com.bonus.system.holiday.service.HolidayService;
|
||||
import com.bonus.system.leaveReporting.entity.LeaveReportingBean;
|
||||
import com.bonus.system.leaveReporting.service.LeaveReportingService;
|
||||
import com.bonus.system.wechat.entity.WechatBean;
|
||||
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.Workbook;
|
||||
|
|
@ -97,6 +99,9 @@ public class ExportFileController {
|
|||
@Resource(name = "OrgChangeService")
|
||||
private OrgChangeService orgChangeService;
|
||||
|
||||
@Resource(name = "WechatService")
|
||||
private WechatService wechatService;
|
||||
|
||||
|
||||
/**
|
||||
* 分公司项目部导出
|
||||
|
|
@ -584,4 +589,73 @@ public class ExportFileController {
|
|||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 小程序打卡数据导出
|
||||
* @param response
|
||||
* @param bean
|
||||
* @return void
|
||||
* @author:fly
|
||||
* @date:2024-10-14-10:30
|
||||
*/
|
||||
@GetMapping("/exportWechatReport")
|
||||
public void exportWechatReport(HttpServletResponse response, WechatBean bean) {
|
||||
try {
|
||||
List<WechatBean> wechatExportVoList = new ArrayList<>();
|
||||
List<WechatBean> wechatReportList = wechatService.getWechatUserList(bean);
|
||||
for (int i = 0; i < wechatReportList.size(); i++) {
|
||||
WechatBean vo = wechatReportList.get(i);
|
||||
vo.setId((i + 1));
|
||||
String attStatus = getAttStatus(vo.getAttStatus());
|
||||
vo.setAttStatus(attStatus);
|
||||
wechatExportVoList.add(vo);
|
||||
}
|
||||
extracted(wechatExportVoList, WechatBean.class, "小程序打卡数据导出", "小程序打卡数据导出", "小程序打卡数据导出", response);
|
||||
} catch (Exception e) {
|
||||
log.error(e.toString(), e);
|
||||
}
|
||||
}
|
||||
|
||||
private String getAttStatus(String attStatus) {
|
||||
switch (attStatus) {
|
||||
case "1":
|
||||
attStatus = "正常";
|
||||
break;
|
||||
case "2":
|
||||
attStatus = "迟到";
|
||||
break;
|
||||
case "3":
|
||||
attStatus = "旷工";
|
||||
break;
|
||||
case "4":
|
||||
attStatus = "早退";
|
||||
break;
|
||||
case "5":
|
||||
attStatus = "轮休";
|
||||
break;
|
||||
case "6":
|
||||
attStatus = "请假";
|
||||
break;
|
||||
case "7":
|
||||
attStatus = "外出办事";
|
||||
break;
|
||||
case "8":
|
||||
attStatus = "出入异常";
|
||||
break;
|
||||
case "9":
|
||||
attStatus = "打卡地异常";
|
||||
break;
|
||||
case "10":
|
||||
attStatus = "出差";
|
||||
break;
|
||||
case "19":
|
||||
attStatus = "出差报备";
|
||||
break;
|
||||
default:
|
||||
attStatus = "休假";
|
||||
break;
|
||||
}
|
||||
return attStatus;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,165 @@
|
|||
package com.bonus.system.wechat.controller;
|
||||
|
||||
import com.bonus.common.core.utils.poi.MultiSheetExcelExporter;
|
||||
import com.bonus.common.core.web.controller.BaseController;
|
||||
import com.bonus.common.core.web.domain.AjaxResult;
|
||||
import com.bonus.common.core.web.page.TableDataInfo;
|
||||
import com.bonus.common.log.annotation.Log;
|
||||
import com.bonus.common.log.annotation.SysLog;
|
||||
import com.bonus.common.log.enums.BusinessType;
|
||||
import com.bonus.common.log.enums.OperaType;
|
||||
import com.bonus.common.security.annotation.RequiresPermissions;
|
||||
import com.bonus.common.security.utils.SecurityUtils;
|
||||
import com.bonus.system.holiday.entity.WorkReportBean;
|
||||
import com.bonus.system.wechat.entity.WechatBean;
|
||||
import com.bonus.system.wechat.service.WechatService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.poi.ss.usermodel.Sheet;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 小程序打卡数据
|
||||
*
|
||||
* @author lsun
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/wechat")
|
||||
@Slf4j
|
||||
public class WechatController extends BaseController {
|
||||
|
||||
@Resource(name = "WechatService")
|
||||
private WechatService wechatService;
|
||||
|
||||
/**
|
||||
* 获取小程序打卡数据列表(表格)
|
||||
*/
|
||||
@RequiresPermissions("flow:wechat:list")
|
||||
@GetMapping("/list")
|
||||
@Log(title = "流程管理->小程序打卡数据->列表查询", businessType = BusinessType.QUERY)
|
||||
public TableDataInfo list(WechatBean bean) {
|
||||
try{
|
||||
startPage();
|
||||
return getDataTable(wechatService.getWechatList(bean));
|
||||
}catch (Exception e){
|
||||
log.error(e.toString(),e);
|
||||
}
|
||||
return getDataTableError(new ArrayList<>());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取小程序打卡数据单用户列表(审核表格)
|
||||
*/
|
||||
@RequiresPermissions("flow:wechat:list")
|
||||
@GetMapping("/userList")
|
||||
@Log(title = "流程管理->小程序打卡数据->单用户列表查询", businessType = BusinessType.QUERY)
|
||||
public TableDataInfo userList(WechatBean bean) {
|
||||
try{
|
||||
startPage();
|
||||
return getDataTable(wechatService.getWechatUserList(bean));
|
||||
}catch (Exception e){
|
||||
log.error(e.toString(),e);
|
||||
}
|
||||
return getDataTableError(new ArrayList<>());
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/export")
|
||||
@SysLog(title = "小程序打卡数据", businessType = OperaType.EXPORT,module = "小程序打卡数据")
|
||||
public void export(HttpServletResponse response, WechatBean bean) {
|
||||
try {
|
||||
//先查询小程序打卡数据
|
||||
List<WechatBean> list = wechatService.getWechatList(bean);
|
||||
//轮休数据
|
||||
List<WechatBean> listUser=new ArrayList<>();
|
||||
MultiSheetExcelExporter exporter = new MultiSheetExcelExporter();
|
||||
// 创建第一个sheet:员工信息
|
||||
Sheet employeeSheet = exporter.createSheet("小程序打卡数据");
|
||||
List<String> employeeHeaders = Arrays.asList("序号", "姓名", "打卡天数", "今日是否考勤");
|
||||
exporter.addHeaderRow(employeeSheet, employeeHeaders);
|
||||
|
||||
List<Map<String, Object>> employeeData = 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).getDays());
|
||||
map.put("今日是否考勤", list.get(i).getIsToday());
|
||||
employeeData.add(map);
|
||||
}
|
||||
exporter.addDataRows(employeeSheet, employeeData, employeeHeaders);
|
||||
|
||||
//查询用户数据
|
||||
List<WechatBean> list1 = wechatService.getWechatUserList(bean);
|
||||
listUser.addAll(list1);
|
||||
// 创建第二个sheet:查询用户数据
|
||||
Sheet departmentSheet = exporter.createSheet("查询用户数据");
|
||||
List<String> departmentHeaders = Arrays.asList("序号", "姓名", "日期", "打卡时间", "考勤状态", "备注");
|
||||
exporter.addHeaderRow(departmentSheet, departmentHeaders);
|
||||
List<Map<String, Object>> departmentData = new ArrayList<>();
|
||||
for (int i = 0; i < listUser.size(); i++) {
|
||||
Map<String, Object> map = new LinkedHashMap<>();
|
||||
map.put("序号", i + 1);
|
||||
map.put("姓名", listUser.get(i).getUserName());
|
||||
map.put("日期", listUser.get(i).getAttCurrentDay());
|
||||
map.put("打卡时间", listUser.get(i).getAttCurrentTime());
|
||||
String attStatus =getAttStatus(listUser.get(i).getAttStatus());
|
||||
map.put("考勤状态",attStatus);
|
||||
map.put("备注",listUser.get(i).getErrorRemake());
|
||||
departmentData.add(map);
|
||||
}
|
||||
exporter.addDataRows(departmentSheet, departmentData, departmentHeaders);
|
||||
// 导出Excel文件
|
||||
exporter.exportToResponse(response, "小程序打卡数据报表");
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private String getAttStatus(String attStatus) {
|
||||
switch (attStatus) {
|
||||
case "1":
|
||||
attStatus = "正常";
|
||||
break;
|
||||
case "2":
|
||||
attStatus = "迟到";
|
||||
break;
|
||||
case "3":
|
||||
attStatus = "旷工";
|
||||
break;
|
||||
case "4":
|
||||
attStatus = "早退";
|
||||
break;
|
||||
case "5":
|
||||
attStatus = "轮休";
|
||||
break;
|
||||
case "6":
|
||||
attStatus = "请假";
|
||||
break;
|
||||
case "7":
|
||||
attStatus = "外出办事";
|
||||
break;
|
||||
case "8":
|
||||
attStatus = "出入异常";
|
||||
break;
|
||||
case "9":
|
||||
attStatus = "打卡地异常";
|
||||
break;
|
||||
case "10":
|
||||
attStatus = "出差";
|
||||
break;
|
||||
case "19":
|
||||
attStatus = "出差报备";
|
||||
break;
|
||||
default:
|
||||
attStatus = "休假";
|
||||
break;
|
||||
}
|
||||
return attStatus;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
package com.bonus.system.wechat.dao;
|
||||
|
||||
|
||||
import com.bonus.system.wechat.entity.WechatBean;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 小程序打卡数据-数据访问层
|
||||
*
|
||||
* @author lsun
|
||||
*/
|
||||
@Repository("WechatDao")
|
||||
public interface WechatDao {
|
||||
/**
|
||||
* 小程序打卡数据列表
|
||||
*
|
||||
* @param bean
|
||||
* @return
|
||||
*/
|
||||
List<WechatBean> getWechatList(WechatBean bean);
|
||||
|
||||
/**
|
||||
* 小程序打卡数据列表-用户查询
|
||||
*
|
||||
* @param bean
|
||||
* @return
|
||||
*/
|
||||
List<WechatBean> getWechatUserList(WechatBean bean);
|
||||
}
|
||||
|
|
@ -0,0 +1,88 @@
|
|||
package com.bonus.system.wechat.entity;
|
||||
|
||||
import cn.afterturn.easypoi.excel.annotation.Excel;
|
||||
import com.bonus.common.core.web.domain.BaseBean;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* LeaveApply
|
||||
*
|
||||
*/
|
||||
@Data
|
||||
public class WechatBean extends BaseBean {
|
||||
|
||||
/**
|
||||
* 编号
|
||||
*/
|
||||
@Excel(name = "序号", width = 10.0,height = 20.0, orderNum = "0")
|
||||
private long id;
|
||||
|
||||
|
||||
/**
|
||||
* 所属部门编号
|
||||
*/
|
||||
private Long orgId;
|
||||
|
||||
|
||||
/**
|
||||
* 请假人用户编号
|
||||
*/
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 请假人姓名
|
||||
*/
|
||||
@Excel(name = "姓名", width = 10.0,height = 20.0, orderNum = "1")
|
||||
private String userName;
|
||||
|
||||
/**
|
||||
* 打卡天数
|
||||
*/
|
||||
|
||||
private String days;
|
||||
|
||||
/**
|
||||
* 今日是否考勤
|
||||
*/
|
||||
private String isToday;
|
||||
|
||||
|
||||
/**
|
||||
* 开始日期
|
||||
*/
|
||||
private String startDate;
|
||||
|
||||
/**
|
||||
* 结束日期
|
||||
*/
|
||||
private String endDate;
|
||||
|
||||
/**
|
||||
* 考勤日期
|
||||
*/
|
||||
@Excel(name = "考勤日期", width = 20.0,height = 20.0, orderNum = "2")
|
||||
private String attCurrentDay;
|
||||
|
||||
/**
|
||||
* 考勤状态
|
||||
*/
|
||||
@Excel(name = "考勤状态", width = 20.0,height = 20.0, orderNum = "4")
|
||||
private String attStatus;
|
||||
|
||||
/**
|
||||
* 考勤时间
|
||||
*/
|
||||
@Excel(name = "打卡时间", width = 20.0,height = 20.0, orderNum = "3")
|
||||
private String attCurrentTime;
|
||||
|
||||
/**
|
||||
* 异常备注
|
||||
*/
|
||||
@Excel(name = "备注", width = 20.0,height = 20.0, orderNum = "5")
|
||||
private String errorRemake;
|
||||
}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
package com.bonus.system.wechat.service;
|
||||
|
||||
|
||||
import com.bonus.common.core.web.domain.AjaxResult;
|
||||
import com.bonus.system.wechat.entity.WechatBean;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 小程序打卡数据业务层
|
||||
* @author lsun
|
||||
*/
|
||||
public interface WechatService {
|
||||
|
||||
/**
|
||||
* 获取小程序打卡数据列表(表格)
|
||||
* @param bean 参数
|
||||
* @return list bean
|
||||
*/
|
||||
List<WechatBean> getWechatList(WechatBean bean);
|
||||
|
||||
/**
|
||||
* 单用户列表查询
|
||||
* @param bean
|
||||
* @return
|
||||
*/
|
||||
List<WechatBean> getWechatUserList(WechatBean bean);
|
||||
}
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
package com.bonus.system.wechat.service;
|
||||
|
||||
|
||||
|
||||
import com.bonus.system.wechat.dao.WechatDao;
|
||||
import com.bonus.system.wechat.entity.WechatBean;
|
||||
import org.springframework.stereotype.Service;
|
||||
import javax.annotation.Resource;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 小程序打卡数据-业务层
|
||||
*
|
||||
* @author lsun
|
||||
*/
|
||||
@Service("WechatService")
|
||||
public class WechatServiceImpl implements WechatService {
|
||||
|
||||
@Resource(name = "WechatDao")
|
||||
private WechatDao wechatDao;
|
||||
|
||||
|
||||
@Override
|
||||
public List<WechatBean> getWechatList(WechatBean bean) {
|
||||
return wechatDao.getWechatList(bean);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<WechatBean> getWechatUserList(WechatBean bean) {
|
||||
return wechatDao.getWechatUserList(bean);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,79 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.bonus.system.wechat.dao.WechatDao">
|
||||
<select id="getWechatList" resultType="com.bonus.system.wechat.entity.WechatBean">
|
||||
SELECT *,
|
||||
count(a.user_id) AS days,
|
||||
CASE
|
||||
WHEN a.att_current_day = CURDATE() THEN
|
||||
'已考勤'
|
||||
ELSE '未考勤'
|
||||
END AS isToday
|
||||
FROM (SELECT ad.user_id,
|
||||
su.user_name,
|
||||
ad.org_id,
|
||||
att_current_day,
|
||||
ad.att_status,
|
||||
sd.dict_label,
|
||||
ad.error_remake,
|
||||
ad.att_current_time,
|
||||
ad.att_type
|
||||
FROM att_data ad
|
||||
LEFT JOIN sys_user su ON ad.user_id = su.user_id
|
||||
LEFT JOIN (SELECT * FROM sys_dict_data WHERE dict_type = 'att_status') sd
|
||||
ON ad.att_status = sd.dict_value
|
||||
WHERE ad.is_active = '1'
|
||||
AND ad.data_source = '3'
|
||||
AND sd.dict_value IN ('1', '2', '4', '7', '8', '9', '10', '19')
|
||||
<if test="userName!=null and userName!=''">
|
||||
AND su.user_name like concat('%', #{userName}, '%')
|
||||
</if>
|
||||
|
||||
<if test="startDate!=null and startDate!='' and endDate!=null and endDate!=''">
|
||||
AND ad.att_current_day BETWEEN #{startDate} AND #{endDate}
|
||||
</if>
|
||||
GROUP BY ad.user_id,
|
||||
ad.org_id,
|
||||
ad.att_current_day
|
||||
ORDER BY ad.att_current_day DESC) a
|
||||
GROUP BY a.user_id,
|
||||
a.org_id
|
||||
</select>
|
||||
|
||||
<select id="getWechatUserList" resultType="com.bonus.system.wechat.entity.WechatBean">
|
||||
SELECT
|
||||
ad.user_id,
|
||||
su.user_name,
|
||||
ad.org_id,
|
||||
att_current_day,
|
||||
ad.att_status,
|
||||
sd.dict_label,
|
||||
ad.error_remake,
|
||||
ad.att_current_time,
|
||||
ad.att_type
|
||||
|
||||
FROM
|
||||
att_data ad
|
||||
LEFT JOIN sys_user su ON ad.user_id = su.user_id
|
||||
LEFT JOIN ( SELECT * FROM sys_dict_data WHERE dict_type = 'att_status' ) sd ON ad.att_status = sd.dict_value
|
||||
WHERE
|
||||
ad.is_active = '1' AND
|
||||
ad.data_source = '3'
|
||||
AND sd.dict_value IN ( '1', '2', '4', '7', '8', '9', '10', '19' )
|
||||
|
||||
<if test="userId!=null and userId!=''">
|
||||
AND ad.user_id = #{userId}
|
||||
</if>
|
||||
|
||||
<if test="userName!=null and userName!=''">
|
||||
AND su.user_name like concat('%', #{userName}, '%')
|
||||
</if>
|
||||
|
||||
<if test="startDate!=null and startDate!='' and endDate!=null and endDate!=''">
|
||||
AND ad.att_current_day BETWEEN #{startDate} AND #{endDate}
|
||||
</if>
|
||||
ORDER BY att_current_time DESC
|
||||
</select>
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue