From 8853292babb2ad94de4a3207966f1e83b767cd2d Mon Sep 17 00:00:00 2001
From: zhongrj <646384940@qq.com>
Date: Sun, 17 Sep 2023 16:38:34 +0800
Subject: [PATCH] 新增流程节点进程查询接口
---
src/main/java/org/springblade/modules/attendance/controller/AttendanceController.java | 391 ++++++++++++++++++++++++++-----------------------------
1 files changed, 182 insertions(+), 209 deletions(-)
diff --git a/src/main/java/org/springblade/modules/attendance/controller/AttendanceController.java b/src/main/java/org/springblade/modules/attendance/controller/AttendanceController.java
index 1cdb7ac..04d33b7 100644
--- a/src/main/java/org/springblade/modules/attendance/controller/AttendanceController.java
+++ b/src/main/java/org/springblade/modules/attendance/controller/AttendanceController.java
@@ -1,5 +1,6 @@
package org.springblade.modules.attendance.controller;
+import bsh.ParseException;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
@@ -8,6 +9,7 @@
import lombok.AllArgsConstructor;
import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.excel.util.ExcelUtil;
+import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
@@ -18,12 +20,16 @@
import org.springblade.modules.attendance.service.IAttendanceService;
import org.springblade.modules.attendance.vo.AttendanceVO;
import org.springblade.modules.attendance.wrapper.AttendanceWrapper;
+import org.springblade.modules.system.entity.DictBiz;
+import org.springblade.modules.system.entity.User;
import org.springblade.modules.system.service.IDictBizService;
import org.springblade.modules.system.service.IUserService;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
+import java.text.SimpleDateFormat;
+import java.util.Date;
import java.util.List;
/**
@@ -40,11 +46,9 @@
private final IAttendanceService attendanceService;
-// private final IEnclosureService iEnclosureService;
-
private final IDictBizService iDictBizService;
- private final IUserService iUserService;
+ private final IUserService userService;
/**
* 详情
@@ -74,193 +78,179 @@
@GetMapping("/page")
@ApiOperationSupport(order = 3)
@ApiOperation(value = "分页", notes = "传入attendance")
- public R<IPage<AttendanceVO>> page(AttendanceVO attendance, Query query, Long department) {
- IPage<Attendance> pages = attendanceService.selectAttendancePage(Condition.getPage(query), department, attendance);
- return R.data(AttendanceWrapper.build().pageVO(pages));
+ public R<IPage<AttendanceVO>> page(AttendanceVO attendance, Query query) {
+ IPage<AttendanceVO> pages = attendanceService.selectAttendancePage(Condition.getPage(query), attendance);
+ return R.data(pages);
}
-// /**
-// * 保安位置比对
-// */
-// @GetMapping("/positionThan")
-// public R positionThan(@Valid Attendance attendance, HttpServletResponse response) {
-// response.setHeader("Access-Control-Allow-Origin", "*");
-// response.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE");
-// response.setHeader("Access-Control-Allow-Credentials", "true");
-// Enclosure enclosure = new Enclosure();
-// enclosure.setAnumber(attendance.getNumber());
-// //查询当前处警人员的电子围栏信息
-// Boolean onArea = iEnclosureService.isOnArea(attendance.getJd(),attendance.getWd(),enclosure);
-// if (onArea){
-// return R.data(true);
-// }
-// return R.data(false);
-// }
+ /**
+ * 打卡(洪城义警app)
+ * @param response
+ * @param attendance
+ * @return
+ */
+ @PostMapping("/AppSave")
+ public R AppSave(@Valid AttendanceVO attendance, HttpServletResponse response) {
+ response.setHeader("Access-Control-Allow-Origin", "*");
+ response.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE");
+ response.setHeader("Access-Control-Allow-Credentials", "true");
+ //先查询用户信息
+ User user = new User();
+ user.setCardid(attendance.getIdCardNo());
+ user.setStatus(1);
+ user.setIsDeleted(0);
+ User user1 = userService.getOne(Condition.getQueryWrapper(user));
+ if (null!=user1) {
+ attendance.setUserId(user1.getId());
+ attendance.setClockTime(new Date());
+ //查询当前考勤人员的部门信息
+ attendance.setDeptId(Long.parseLong(user1.getDeptId()));
+ //获取当前日期是礼拜几
+ attendance.setWeek(new SimpleDateFormat("EEEE").format(new Date()));
+ //获取打卡时间标准
+ List<DictBiz> dictBizList = iDictBizService.getList("attendanceStandard");
+ //定义打卡时间标准,上午,下午
+ StringBuilder forenoon = new StringBuilder();
+ StringBuilder afternoon = new StringBuilder();
+ String format = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
+ for (DictBiz dictBiz : dictBizList) {
+ if (dictBiz.getDictValue().contains("上午")) {
+ forenoon = forenoon.append(dictBiz.getDictKey());
+ }
+ if (dictBiz.getDictValue().contains("下午")) {
+ afternoon = afternoon.append(dictBiz.getDictKey());
+ }
+ }
+ //上午打卡时间标准
+ String forenoonWorkTime = format + " " + forenoon.toString().split("-")[0] + ":00";
+ String forenoonOfDutyTime = format + " " + forenoon.toString().split("-")[1] + ":00";
+ //下午打卡时间标准
+ String afternoonWorkTime = format + " " + afternoon.toString().split("-")[0] + ":00";
+ String afternoonOfDutyTime = format + " " + afternoon.toString().split("-")[1] + ":00";
+ //判断打卡时间
+ try {
+ long time = attendance.getClockTime().getTime();
-// /**
-// * 新增
-// */
-// @PostMapping("/AppSave")
-// @ApiOperationSupport(order = 4)
-// @ApiOperation(value = "新增", notes = "传入attendance")
-// public R AppSave(@Valid Attendance attendance, HttpServletResponse response) {
-// response.setHeader("Access-Control-Allow-Origin", "*");
-// response.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE");
-// response.setHeader("Access-Control-Allow-Credentials", "true");
-// Enclosure enclosure = new Enclosure();
-// enclosure.setAnumber(attendance.getNumber());
-// //查询当前处警人员的电子围栏信息
-// Boolean onArea = iEnclosureService.isOnArea(attendance.getJd(),attendance.getWd(),enclosure);
-// //判断是否在所在区域打卡,返回数据
-// if (onArea) {
-// //查询当前考勤人员的部门信息
-// attendance.setDepartment(iUserService.selUserByCode(attendance.getNumber()).getDeptId());
-// //获取当前日期是礼拜几
-// attendance.setWeek(new SimpleDateFormat("EEEE").format(new Date()));
-// //获取打卡时间标准
-// List<DictBiz> dictBizList = iDictBizService.getList("attendanceStandard");
-// //定义打卡时间标准,上午,下午
-// StringBuilder forenoon = new StringBuilder();
-// StringBuilder afternoon = new StringBuilder();
-// String format = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
-// for (DictBiz dictBiz : dictBizList) {
-// if (dictBiz.getDictValue().contains("上午")) {
-// forenoon = forenoon.append(dictBiz.getDictKey());
-// }
-// if (dictBiz.getDictValue().contains("下午")) {
-// afternoon = afternoon.append(dictBiz.getDictKey());
-// }
-// }
-// //上午打卡时间标准
-// String forenoonWorkTime = format + " " + forenoon.toString().split("-")[0] + ":00";
-// String forenoonOfDutyTime = format + " " + forenoon.toString().split("-")[1] + ":00";
-// //下午打卡时间标准
-// String afternoonWorkTime = format + " " + afternoon.toString().split("-")[0] + ":00";
-// String afternoonOfDutyTime = format + " " + afternoon.toString().split("-")[1] + ":00";
-// //判断打卡时间
-// try {
-// long time = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(attendance.getClockTime()).getTime();
-//
-// //判断上午上班之前半小时前打卡为无效打卡
-// if (time-(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(forenoonWorkTime).getTime()-30*60*1000)<0){
-// attendance.setClocktype("0");
-// attendance.setAttendancetype("4");
-// return R.status(attendanceService.save(attendance));
-// }
-//
-// //上午上班半小时前到上班时间打卡为正常打卡
-// if (time-(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(forenoonWorkTime).getTime()-30*60*1000)>=0
-// && time-new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(forenoonWorkTime).getTime()<=0) {
-// attendance.setClocktype("0");
-// attendance.setAttendancetype("0");
-// return R.status(attendanceService.save(attendance));
-// }
-//
-// //上午上班后到上班下班前打卡为正常打卡
-// if (time-new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(forenoonWorkTime).getTime()>0
-// && time-new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(forenoonOfDutyTime).getTime()<0) {
-// //查询当前时间之前当前考勤人员的最新的一条考勤数据
-// Attendance attendanceNow = attendanceService.selAttendanceNewNow(attendance.getNumber());
-// if (null!=attendanceNow){
-// if (attendanceNow.getAttendancetype().equals("0") || attendanceNow.getClocktype().equals("1")) {
-// //下班早退
-// attendance.setClocktype("1");
-// attendance.setAttendancetype("2");
-// }
-// if (attendanceNow.getAttendancetype().equals("4")){
-// //上班迟到
-// attendance.setClocktype("0");
-// attendance.setAttendancetype("1");
-// }
-// }else {
-// //上班迟到
-// attendance.setClocktype("0");
-// attendance.setAttendancetype("1");
-// }
-// return R.status(attendanceService.save(attendance));
-// }
-//
-// //正常下班时间-下班半小时后
-// if (time-new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(forenoonOfDutyTime).getTime()>=0
-// && time-(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(forenoonOfDutyTime).getTime()+30*60*1000)<=0){
-// //正常下班打卡
-// attendance.setClocktype("1");
-// attendance.setAttendancetype("0");
-// return R.status(attendanceService.save(attendance));
-// }
-//
-// //上午下班半小时后-下午上班之前半小時打卡为无效打卡
-// if (time-(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonWorkTime).getTime()-30*60*1000)<0
-// && time-(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(forenoonOfDutyTime).getTime()+30*60*1000)>0){
-// //无效打卡
-// attendance.setClocktype("0");
-// attendance.setAttendancetype("4");
-// return R.status(attendanceService.save(attendance));
-// }
-//
-// //下午上班之前半小時-下午上班时间之前打卡为下午正常上班打卡
-// if (time-(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonWorkTime).getTime()-30*60*1000)>=0
-// && time-new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonWorkTime).getTime()<=0){
-// //下午正常打卡
-// attendance.setClocktype("0");
-// attendance.setAttendancetype("0");
-// return R.status(attendanceService.save(attendance));
-// }
-//
-// //下午上班之后到下午下班之前
-// if (time-new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonWorkTime).getTime()>0
-// && time-new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonOfDutyTime).getTime()<0){
-// //查询当前时间之前当前考勤人员的最新的一条考勤数据
-// Attendance attendanceNow = attendanceService.selAttendanceNewNow(attendance.getNumber());
-// if (null!=attendanceNow){
-// if (attendanceNow.getAttendancetype().equals("0") && attendanceNow.getClocktype().equals("0")) {
-// //下班早退
-// attendance.setClocktype("1");
-// attendance.setAttendancetype("2");
-// }
-// if (attendanceNow.getClocktype().equals("1")) {
-// //下班早退
-// attendance.setClocktype("1");
-// attendance.setAttendancetype("2");
-// }
-// if (attendanceNow.getAttendancetype().equals("4")){
-// //上班迟到
-// attendance.setClocktype("0");
-// attendance.setAttendancetype("1");
-// }
-// }else {
-// //上班迟到
-// attendance.setClocktype("0");
-// attendance.setAttendancetype("1");
-// }
-// return R.status(attendanceService.save(attendance));
-// }
-//
-// //正常打下午下班卡
-// if (time-new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonOfDutyTime).getTime()>=0
-// && time-(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonOfDutyTime).getTime()+30*60*1000)<=0
-// ){
-// //下午正常下班打卡
-// attendance.setClocktype("1");
-// attendance.setAttendancetype("0");
-// return R.status(attendanceService.save(attendance));
-// }
-//
-// //打卡时间超过下午下班打卡时间后的半小时为无效打卡
-// if (time-(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonOfDutyTime).getTime()+30*60*1000)>0){
-// //下午下班打卡无效
-// attendance.setClocktype("1");
-// attendance.setAttendancetype("4");
-// return R.status(attendanceService.save(attendance));
-// }
-//
-// } catch (ParseException e) {
-// e.printStackTrace();
-// }
-// }
-// return R.status(false);
-// }
+ //判断上午上班之前半小时前打卡为无效打卡
+ if (time - (new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(forenoonWorkTime).getTime() - 30 * 60 * 1000) < 0) {
+ attendance.setClockType(1);
+ attendance.setAttendanceType(5);
+ return R.status(attendanceService.save(attendance));
+ }
+
+ //上午上班半小时前到上班时间打卡为正常打卡
+ if (time - (new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(forenoonWorkTime).getTime() - 30 * 60 * 1000) >= 0
+ && time - new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(forenoonWorkTime).getTime() <= 0) {
+ attendance.setClockType(1);
+ attendance.setAttendanceType(1);
+ return R.status(attendanceService.save(attendance));
+ }
+
+ //上午上班后到上班下班前打卡为正常打卡
+ if (time - new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(forenoonWorkTime).getTime() > 0
+ && time - new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(forenoonOfDutyTime).getTime() < 0) {
+ //查询当前时间之前当前考勤人员的最新的一条考勤数据
+ Attendance attendanceNow = attendanceService.selAttendanceNewNow(attendance.getUserId());
+ if (null != attendanceNow) {
+ if (attendanceNow.getAttendanceType().equals(1) || attendanceNow.getClockType().equals(2)) {
+ //下班早退
+ attendance.setClockType(2);
+ attendance.setAttendanceType(3);
+ }
+ if (attendanceNow.getAttendanceType().equals(5)) {
+ //上班迟到
+ attendance.setClockType(1);
+ attendance.setAttendanceType(2);
+ }
+ } else {
+ //上班迟到
+ attendance.setClockType(1);
+ attendance.setAttendanceType(2);
+ }
+ return R.status(attendanceService.save(attendance));
+ }
+
+ //正常下班时间-下班半小时后
+ if (time - new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(forenoonOfDutyTime).getTime() >= 0
+ && time - (new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(forenoonOfDutyTime).getTime() + 30 * 60 * 1000) <= 0) {
+ //正常下班打卡
+ attendance.setClockType(2);
+ attendance.setAttendanceType(1);
+ return R.status(attendanceService.save(attendance));
+ }
+
+ //上午下班半小时后-下午上班之前半小時打卡为无效打卡
+ if (time - (new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonWorkTime).getTime() - 30 * 60 * 1000) < 0
+ && time - (new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(forenoonOfDutyTime).getTime() + 30 * 60 * 1000) > 0) {
+ //无效打卡
+ attendance.setClockType(1);
+ attendance.setAttendanceType(5);
+ return R.status(attendanceService.save(attendance));
+ }
+
+ //下午上班之前半小時-下午上班时间之前打卡为下午正常上班打卡
+ if (time - (new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonWorkTime).getTime() - 30 * 60 * 1000) >= 0
+ && time - new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonWorkTime).getTime() <= 0) {
+ //下午正常打卡
+ attendance.setClockType(1);
+ attendance.setAttendanceType(1);
+ return R.status(attendanceService.save(attendance));
+ }
+
+ //下午上班之后到下午下班之前
+ if (time - new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonWorkTime).getTime() > 0
+ && time - new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonOfDutyTime).getTime() < 0) {
+ //查询当前时间之前当前考勤人员的最新的一条考勤数据
+ Attendance attendanceNow = attendanceService.selAttendanceNewNow(attendance.getUserId());
+ if (null != attendanceNow) {
+ if (attendanceNow.getAttendanceType().equals(1) && attendanceNow.getClockType().equals(1)) {
+ //下班早退
+ attendance.setClockType(2);
+ attendance.setAttendanceType(3);
+ }
+ if (attendanceNow.getClockType().equals(2)) {
+ //下班早退
+ attendance.setClockType(2);
+ attendance.setAttendanceType(3);
+ }
+ if (attendanceNow.getAttendanceType().equals(5)) {
+ //上班迟到
+ attendance.setClockType(1);
+ attendance.setAttendanceType(2);
+ }
+ } else {
+ //上班迟到
+ attendance.setClockType(1);
+ attendance.setAttendanceType(2);
+ }
+ return R.status(attendanceService.save(attendance));
+ }
+
+ //正常打下午下班卡
+ if (time - new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonOfDutyTime).getTime() >= 0
+ && time - (new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonOfDutyTime).getTime() + 30 * 60 * 1000) <= 0
+ ) {
+ //下午正常下班打卡
+ attendance.setClockType(2);
+ attendance.setAttendanceType(1);
+ return R.status(attendanceService.save(attendance));
+ }
+
+ //打卡时间超过下午下班打卡时间后的半小时为无效打卡
+ if (time - (new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonOfDutyTime).getTime() + 30 * 60 * 1000) > 0) {
+ //下午下班打卡无效
+ attendance.setClockType(2);
+ attendance.setAttendanceType(5);
+ return R.status(attendanceService.save(attendance));
+ }
+
+ } catch (java.text.ParseException e) {
+ e.printStackTrace();
+ }
+ }
+ return R.status(false);
+ }
/**
* 修改
@@ -294,31 +284,14 @@
}
/**
- * 导出用户
+ * 导出考勤数据
+ * @param response
+ * @param attendance
*/
@GetMapping("/export-Attendance")
- public void exportAttendane(String name, String beginTime, String endTime, String attendancetype, HttpServletResponse response) {
- String beginTimes = null;
- String endTimes = null;
- String attendancetypes = null;
- if (beginTime.equals("undefined ") && endTime.equals("undefined")) {
- beginTimes=null;
- endTimes=null;
- attendancetypes=attendancetype;
- }
- else if (attendancetype.equals("undefined")){
- attendancetypes=null;
- }
- else {
- beginTimes=beginTime;
- endTimes=endTime;
- attendancetypes=attendancetype;
- }
-
- List<AttendanceExcel> list = attendanceService.exportAttendane(name, beginTimes, endTimes, attendancetypes);
+ public void exportAttendane(AttendanceVO attendance, HttpServletResponse response) {
+ List<AttendanceExcel> list = attendanceService.exportAttendane(attendance);
ExcelUtil.export(response, "考勤数据" + DateUtil.time(), "考勤数据表", list, AttendanceExcel.class);
-
-
-}
+ }
}
--
Gitblit v1.9.3