From 5e14cf0b296081d939339c672b21932fefd90ee0 Mon Sep 17 00:00:00 2001 From: lSun <15893999301@qq.com> Date: Tue, 3 Dec 2024 16:27:11 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=8F=E7=A8=8B=E5=BA=8F=E6=89=93=E5=8D=A1?= =?UTF-8?q?=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system/download/ExportFileController.java | 74 ++++++++ .../wechat/controller/WechatController.java | 165 ++++++++++++++++++ .../bonus/system/wechat/dao/WechatDao.java | 31 ++++ .../system/wechat/entity/WechatBean.java | 88 ++++++++++ .../system/wechat/service/WechatService.java | 31 ++++ .../wechat/service/WechatServiceImpl.java | 32 ++++ .../resources/mapper/wechat/WechatMapper.xml | 79 +++++++++ 7 files changed, 500 insertions(+) create mode 100644 bonus-modules/bonus-system/src/main/java/com/bonus/system/wechat/controller/WechatController.java create mode 100644 bonus-modules/bonus-system/src/main/java/com/bonus/system/wechat/dao/WechatDao.java create mode 100644 bonus-modules/bonus-system/src/main/java/com/bonus/system/wechat/entity/WechatBean.java create mode 100644 bonus-modules/bonus-system/src/main/java/com/bonus/system/wechat/service/WechatService.java create mode 100644 bonus-modules/bonus-system/src/main/java/com/bonus/system/wechat/service/WechatServiceImpl.java create mode 100644 bonus-modules/bonus-system/src/main/resources/mapper/wechat/WechatMapper.xml diff --git a/bonus-modules/bonus-system/src/main/java/com/bonus/system/download/ExportFileController.java b/bonus-modules/bonus-system/src/main/java/com/bonus/system/download/ExportFileController.java index a1fb2b0..00be0a4 100644 --- a/bonus-modules/bonus-system/src/main/java/com/bonus/system/download/ExportFileController.java +++ b/bonus-modules/bonus-system/src/main/java/com/bonus/system/download/ExportFileController.java @@ -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 wechatExportVoList = new ArrayList<>(); + List 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; + } + } diff --git a/bonus-modules/bonus-system/src/main/java/com/bonus/system/wechat/controller/WechatController.java b/bonus-modules/bonus-system/src/main/java/com/bonus/system/wechat/controller/WechatController.java new file mode 100644 index 0000000..e682e30 --- /dev/null +++ b/bonus-modules/bonus-system/src/main/java/com/bonus/system/wechat/controller/WechatController.java @@ -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 list = wechatService.getWechatList(bean); + //轮休数据 + List listUser=new ArrayList<>(); + MultiSheetExcelExporter exporter = new MultiSheetExcelExporter(); + // 创建第一个sheet:员工信息 + Sheet employeeSheet = exporter.createSheet("小程序打卡数据"); + List employeeHeaders = Arrays.asList("序号", "姓名", "打卡天数", "今日是否考勤"); + exporter.addHeaderRow(employeeSheet, employeeHeaders); + + List> employeeData = new ArrayList<>(); + for (int i = 0; i < list.size(); i++) { + Map 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 list1 = wechatService.getWechatUserList(bean); + listUser.addAll(list1); + // 创建第二个sheet:查询用户数据 + Sheet departmentSheet = exporter.createSheet("查询用户数据"); + List departmentHeaders = Arrays.asList("序号", "姓名", "日期", "打卡时间", "考勤状态", "备注"); + exporter.addHeaderRow(departmentSheet, departmentHeaders); + List> departmentData = new ArrayList<>(); + for (int i = 0; i < listUser.size(); i++) { + Map 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; + } + +} diff --git a/bonus-modules/bonus-system/src/main/java/com/bonus/system/wechat/dao/WechatDao.java b/bonus-modules/bonus-system/src/main/java/com/bonus/system/wechat/dao/WechatDao.java new file mode 100644 index 0000000..81c88ec --- /dev/null +++ b/bonus-modules/bonus-system/src/main/java/com/bonus/system/wechat/dao/WechatDao.java @@ -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 getWechatList(WechatBean bean); + + /** + * 小程序打卡数据列表-用户查询 + * + * @param bean + * @return + */ + List getWechatUserList(WechatBean bean); +} diff --git a/bonus-modules/bonus-system/src/main/java/com/bonus/system/wechat/entity/WechatBean.java b/bonus-modules/bonus-system/src/main/java/com/bonus/system/wechat/entity/WechatBean.java new file mode 100644 index 0000000..41b05b8 --- /dev/null +++ b/bonus-modules/bonus-system/src/main/java/com/bonus/system/wechat/entity/WechatBean.java @@ -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; +} diff --git a/bonus-modules/bonus-system/src/main/java/com/bonus/system/wechat/service/WechatService.java b/bonus-modules/bonus-system/src/main/java/com/bonus/system/wechat/service/WechatService.java new file mode 100644 index 0000000..7b4bf53 --- /dev/null +++ b/bonus-modules/bonus-system/src/main/java/com/bonus/system/wechat/service/WechatService.java @@ -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 getWechatList(WechatBean bean); + + /** + * 单用户列表查询 + * @param bean + * @return + */ + List getWechatUserList(WechatBean bean); +} diff --git a/bonus-modules/bonus-system/src/main/java/com/bonus/system/wechat/service/WechatServiceImpl.java b/bonus-modules/bonus-system/src/main/java/com/bonus/system/wechat/service/WechatServiceImpl.java new file mode 100644 index 0000000..1c7cb8e --- /dev/null +++ b/bonus-modules/bonus-system/src/main/java/com/bonus/system/wechat/service/WechatServiceImpl.java @@ -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 getWechatList(WechatBean bean) { + return wechatDao.getWechatList(bean); + } + + @Override + public List getWechatUserList(WechatBean bean) { + return wechatDao.getWechatUserList(bean); + } +} diff --git a/bonus-modules/bonus-system/src/main/resources/mapper/wechat/WechatMapper.xml b/bonus-modules/bonus-system/src/main/resources/mapper/wechat/WechatMapper.xml new file mode 100644 index 0000000..1d87574 --- /dev/null +++ b/bonus-modules/bonus-system/src/main/resources/mapper/wechat/WechatMapper.xml @@ -0,0 +1,79 @@ + + + + + + + \ No newline at end of file