优化完善页面信息. 新增error提醒

This commit is contained in:
andy 2025-08-30 11:23:24 +08:00
parent 355e5e2d73
commit 17b44fef1e
9 changed files with 327 additions and 41 deletions

View File

@ -61,4 +61,5 @@ public interface IRzAttendanceService extends IService<RzAttendance>
RzAttendance selectRzAttendanceBySfIdAndNameAndTime(Long userId, String employeeName, String replacementTime,Boolean isAttendance);
public void sendAbnormalAttendance();
}

View File

@ -20,6 +20,10 @@ import com.evo.equipment.service.IEqImagesService;
import com.evo.system.domain.SysStaff;
import com.evo.system.mapper.SysDeptMapper;
import com.evo.system.service.ISysStaffService;
import com.evo.wechat.service.SendClientService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
@ -34,6 +38,7 @@ import java.util.List;
* @author chenyj
* @date 2024-09-05
*/
@Slf4j
@Service
public class RzAttendanceServiceImpl extends ServiceImpl<RzAttendanceMapper, RzAttendance> implements IRzAttendanceService {
@Resource
@ -44,12 +49,15 @@ public class RzAttendanceServiceImpl extends ServiceImpl<RzAttendanceMapper, RzA
private IEqImagesService eqImagesService;
@Resource
private RzAttendanceDetailService rzAttendanceDetailService;
@Resource
private SendClientService sendClientService;
private static final String MORNING_CARD_SINGLE = "上班卡(单班制)";
private static final String MORNING_CARD_DOUBLE = "上班卡(双班制)";
private static final String MORNING_CARD_TRIPLE = "上班卡(三班制)";
private static final String NIGHT_CARD = "下班卡";
@Autowired
private SysDeptMapper sysDeptMapper;
/**
* 查询考勤记录
@ -459,4 +467,36 @@ public class RzAttendanceServiceImpl extends ServiceImpl<RzAttendanceMapper, RzA
return rzAttendance;
}
@Override
public void sendAbnormalAttendance(){
try {
for (SysStaff sysStaff : sysStaffService.selectSysStaffListAll()){
Date date = DateUtils.addDays(new Date(), -1);
RzAttendance beforeAttendance = getBaseMapper().queryNowDayAttendanceByStatisticalIdAndDate(sysStaff.getUserId(), date);
if(beforeAttendance.getWorkStartTime() != null && beforeAttendance.getWorkEndTime() == null){
sendAbnormalAttendance(sysStaff, beforeAttendance.getWorkStartTime());
}
}
} catch (Exception e) {
e.printStackTrace();
log.error("查询前一天的打卡情况报错了");
}
}
@Async
protected void sendAbnormalAttendance(SysStaff sysStaff, Date date){
try {
if(sysStaff != null && StringUtils.isNotEmpty(sysStaff.getOpenid())){
SysDept sysDept = sysDeptMapper.selectById(sysStaff.getDeptId());
sendClientService.sendAbnormalAttendance(sysDept != null ? sysDept.getDeptName() : "未知",sysStaff.getName(), "昨天下班未打卡", date, sysStaff.getOpenid());
}
} catch (Exception e) {
log.error("推送公众号打卡异常失败, 原因为: {}", e.getMessage(), e);
}
}
}

View File

@ -12,6 +12,7 @@ import com.evo.personnelMatters.mapper.RzOverTimeMapper;
import com.evo.restaurant.service.IRzRestaurantStatisticsService;
import com.evo.system.domain.SysStaff;
import com.evo.system.service.ISysStaffService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
@ -111,6 +112,25 @@ public class TestController {
}
@GetMapping("/error")
public String error(Model model) {
SysStaff user = new SysStaff();
user.setName("张三");
user.setIdCard("130132197019183237");
user.setOpenid("123456");
model.addAttribute("user", user);
model.addAttribute("message", "信息提交失败, 请检查你的个人信息录入是否正确");
return "error.html";
}
@GetMapping("/success")
public String success(Model model) {
model.addAttribute("message", "信息提交成功");
return "success.html";
}
/**
* 清洗加班

View File

@ -0,0 +1,51 @@
package com.evo.common.controller;
import com.evo.system.domain.SysStaff;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
/**
*
*
* @ClassName:TestWebController
* @date: 2025年08月30日 11:10
* @author: andy.shi
* @remark: 开发人员联系方式 1042025947@qq.com/微信同步
*/
@Controller
@RequestMapping("/test/web")
public class TestWebController {
@GetMapping("/message")
public String message(Model model, String code) {
System.out.println(code);
SysStaff user = new SysStaff();
user.setOpenid(code);
model.addAttribute("user", user);
return "user_info.html";
}
@GetMapping("/error")
public String error(Model model) {
SysStaff user = new SysStaff();
user.setName("张三");
user.setIdCard("130132197019183237");
user.setOpenid("123456");
model.addAttribute("user", user);
model.addAttribute("message", "信息提交失败, 请检查你的个人信息录入是否正确");
return "error.html";
}
@GetMapping("/success")
public String success(Model model) {
model.addAttribute("message", "信息提交成功");
return "success.html";
}
}

View File

@ -1,6 +1,7 @@
package com.evo.task;
import com.evo.attendance.service.IRzAbnormalDetailService;
import com.evo.attendance.service.IRzAttendanceService;
import com.evo.attendance.service.IRzAttendanceStatisticalService;
import com.evo.common.utils.DateUtils;
import com.evo.restaurant.domain.RzRestaurantImages;
@ -29,6 +30,8 @@ public class TaskController {
private IRzAttendanceStatisticalService rzAttendanceStatisticalService;
@Resource
private IRzRestaurantImagesService rzRestaurantImagesService;
@Resource
private IRzAttendanceService rzAttendanceService;
/**
* 每月1号 020 自动生成考勤数据
*/
@ -92,6 +95,12 @@ public class TaskController {
abnormalDetailService.insertRzAbnormalDetail();
}
@Scheduled(cron = "0 0 9 * * ?")
public void autoAbnormalAttendance(){
rzAttendanceService.sendAbnormalAttendance();
}
// /**
// * 每月10号2点自动计算工龄
// */

View File

@ -7,6 +7,7 @@ import com.evo.system.service.ISysStaffService;
import com.evo.wechat.config.GZHProperties;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
@ -51,17 +52,19 @@ public class WeChatController {
public String submitUser(Model model, @ModelAttribute("user") SysStaff user) {
log.info("获取到的code{}", user.toString());
SysStaff sysStaff = sysStaffService.getOne(new LambdaQueryWrapper<SysStaff>().eq(SysStaff::getIdCard, user.getIdCard()), false);
SysStaff sysStaff = sysStaffService.getOne(new LambdaQueryWrapper<SysStaff>().eq(SysStaff::getName, user.getName().trim()).eq(SysStaff::getIdCard, user.getIdCard().trim()), false);
if(ObjectUtils.isEmpty(sysStaff)){
sysStaff = sysStaffService.getOne(new LambdaQueryWrapper<SysStaff>().eq(SysStaff::getPhone, user.getPhone()), false);
model.addAttribute("message", "信息提交失败, 请检查你的个人信息录入是否正确");
model.addAttribute("user", user);
return "error.html";
}
if(ObjectUtils.isEmpty(sysStaff)){
model.addAttribute("message", "处理失败, 请检查你的个人信息录入是否正确");
return "success.html";
if(StringUtils.isEmpty(sysStaff.getOpenid())){
sysStaff.setOpenid(user.getOpenid());
sysStaffService.updateById(sysStaff);
model.addAttribute("message", "信息提交成功");
}else{
model.addAttribute("message", "当前用户信息已完善, 无需再次提交");
}
sysStaff.setOpenid(user.getOpenid());
sysStaffService.updateById(sysStaff);
model.addAttribute("message", "处理成功");
return "success.html";
}
}

View File

@ -0,0 +1,133 @@
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>河北伊特机械设备有限公司-提交失败</title>
<!-- 引入Tailwind CSS -->
<script src="https://cdn.tailwindcss.com"></script>
<!-- 引入Font Awesome -->
<link href="https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/css/font-awesome.min.css" rel="stylesheet">
<!-- 自定义Tailwind配置与原页面一致 -->
<script>
tailwind.config = {
theme: {
extend: {
colors: {
primary: '#3b82f6',
secondary: '#64748b',
danger: '#ef4444', // 失败状态主色
},
fontFamily: {
sans: ['Inter', 'system-ui', 'sans-serif'],
},
}
}
}
</script>
<style type="text/tailwindcss">
@layer utilities {
.btn-primary {
@apply bg-primary hover:bg-primary/90 text-white font-medium py-2.5 px-6 rounded-lg transition duration-200 flex items-center justify-center;
}
.form-label {
@apply block text-sm font-medium text-gray-700 mb-1;
}
.form-input {
@apply w-full px-4 py-2 border border-gray-300 rounded-lg transition duration-200 focus:ring-2 focus:ring-primary/50 focus:border-primary focus:outline-none;
}
.error-message {
@apply text-red-500 text-sm mt-1;
}
}
</style>
</head>
<body class="bg-gray-50 min-h-screen flex items-center justify-center p-4">
<!-- 主容器 -->
<div class="w-full max-w-md bg-white-white roundedrounded-xl shadow-lg overflow-hidden">
<div class="p-6 sm:p-8">
<!-- 标题区域 -->
<div class="text-center mb-6">
<h1 class="text-2xl font-bold text-gray-900">河北伊特机械设备有限公司考勤系统</h1>
<h2 class="text-2xl font-bold text-gray-900">信息提交结果</h2>
</div>
<!-- 失败提示区域 -->
<div class="mb-6 p-4 bg-red-50 border border-red-200 rounded-lg">
<div class="flex items-start">
<div class="flex-shrink-0 mt-0.5">
<i class="fa fa fa-exclamation-circle text-danger text-xl"></i>
</div>
<div class="ml-3">
<!-- 显示失败原因接收message参数 -->
<h3 class="text-sm font-medium text-dangerer" th:text="${message}">
信息提交失败,请检查相关信息后重试
</h3>
</div>
</div>
</div>
<!-- 已填写信息表单接收user对象姓名、身份证号可编辑并重新提交 -->
<form th:action="@{/wechat/submit_user}" th:object="${user}" method="post" class="space-y-5 mb-8">
<h4 class="text-sm font-medium text-gray-600">请修改以下信息并重新提交:</h4>
<!-- 姓名字段 -->
<div>
<label for="name" class="form-label">
<i class="fa fa-user-circle mr-1"></i>用户姓名
</label>
<input type="text" id="name" th:field="*{name}"
class="form-input"
placeholder="请输入您的姓名"
required>
<p th:if="${#fields.hasErrors('name')}" th:errors="*{name}" class="error-message"></p>
</div>
<!-- 身份证号证号字段 -->
<div>
<label for="idCard" class="form-label">
<i class="fa fa-id-card mr-1"></i>身份证号
</label>
<input type="text" id="idCard" th:field="*{idCard}"
class="form-input"
placeholder="请输入18位身份证号"
maxlength="18"
required>
<p th:if="${#fields.hasErrors('idCard')}" th:errors="*{idCard}" class="error-message"></p>
</div>
<!-- 隐藏字段保持不变 -->
<input type="hidden" id="openid" th:field="*{openid}" th:value="${openid}">
<!-- 重新提交按钮 -->
<div>
<button type="submit" class="w-full btn-primary">
<i class="fa fa-refresh mr-2"></i>确认修改并重新提交
</button>
</div>
</form>
</div>
</div>
<!-- 简单的表单验证脚本 -->
<script>
// 表单提交前的基本验证
document.querySelector('form').addEventListener('submit', function(e) {
const idCard = document.getElementById('idCard').value;
let isValid = true;
// 身份证号简单验证18位
if (idCard.length !== 18) {
alert('请输入18位身份证号');
isValid = false;
}
if (!isValid) {
e.preventDefault(); // 阻止表单提交
}
});
</script>
</body>
</html>

View File

@ -1,9 +1,61 @@
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<title>Hello</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>河北伊特机械设备有限公司-提交成功</title>
<!-- 引入Tailwind CSS -->
<script src="https://cdn.tailwindcss.com"></script>
<!-- 引入Font Awesome -->
<link href="https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/css/font-awesome.min.css" rel="stylesheet">
<!-- 自定义Tailwind配置与原页面一致 -->
<script>
tailwind.config = {
theme: {
extend: {
colors: {
primary: '#3b82f6',
secondary: '#64748b',
accent: '#10b981', // 成功状态主色
},
fontFamily: {
sans: ['Inter', 'system-ui', 'sans-serif'],
},
}
}
}
</script>
<style type="text/tailwindcss">
@layer utilities {
.btn-primary {
@apply bg-primary hover:bg-primary/90 text-white font-medium py-2.5 px-6 rounded-lg transition duration-200 flex items-center justify-center;
}
}
</style>
</head>
<body>
<h1 th:text="${message}"></h1>
<body class="bg-gray-50 min-h-screen flex items-center justify-center p-4">
<!-- 主容器 -->
<div class="w-full max-w-md bg-white rounded-xl shadow-lg overflow-hidden">
<div class="p-6 sm:p-8">
<!-- 标题区域 -->
<div class="text-center mb-8">
<h1 class="text-2xl font-bold text-gray-900">河北伊特机械设备有限公司考勤系统</h1>
<h2 class="text-2xl font-bold text-gray-900">信息提交结果</h2>
</div>
<!-- 成功提示区域 -->
<div class="text-center mb-8 p-5 bg-green-50 border border-green-200 rounded-lg">
<div class="inline-flex items-center justify-center w-16 h-16 bg-accent/20 text-accent rounded-full mb-4">
<i class="fa fa-check text-3xl"></i>
</div>
<!-- 显示成功消息接收message参数 -->
<p class="text-lg font-medium text-green-800" th:text="${message}">
信息提交成功!您将收到考勤异常通知
</p>
</div>
</div>
</div>
</body>
</html>
</html>

View File

@ -3,7 +3,7 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>用户信息提交</title>
<title>河北伊特机械设备有限公司-用户信息完善</title>
<!-- 引入Tailwind CSS -->
<script src="https://cdn.tailwindcss.com"></script>
<!-- 引入Font Awesome -->
@ -48,7 +48,7 @@
<div class="w-full max-w-md bg-white rounded-xl shadow-lg overflow-hidden">
<div class="p-6 sm:p-8">
<div class="text-center mb-6">
<h2 class="text-2xl font-bold text-gray-900">用户信息信息完善</h2>
<h1 class="text-2xl font-bold text-gray-900">河北伊特机械制造有限公司考勤系统</h1>
<p class="mt-2 text-sm text-gray-500">请填写以下信息并提交</p>
</div>
@ -78,26 +78,9 @@
required>
<p th:if="${#fields.hasErrors('idCard')}" th:errors="*{idCard}" class="error-message"></p>
</div>
<!-- 手机号字段 -->
<div>
<label for="phone" class="form-label">
<i class="fa fa-phone mr-1"></i>手机号
</label>
<input type="tel" id="phone" th:field="*{phone}"
class="form-input"
placeholder="请输入11位手机号"
maxlength="11"
required>
<p th:if="${#fields.hasErrors('phone')}" th:errors="*{phone}" class="error-message"></p>
</div>
<!-- 隐藏文本输入框 -->
<!-- <input type="tel" id="openid" th:field="*{openid}"-->
<!-- th:value="${openid}"-->
<!-- class="form-input"-->
<!-- readonly>-->
<input type="hidden" id="openid" th:field="*{openid}" th:value="${openid}">
<p class="mt-2 text-sm text-gray-500">信息用途为完善考勤系统用户信息,以便通过微信公众号的途径将相关信息通知用户</p>
<p class="mt-2 text-sm text-gray-500">此信息为自愿填报,若不填报将无法收到考勤异常通知</p>
<!-- 提交按钮 -->
<div>
<button type="submit" class="w-full bg-primary hover:bg-primary/90 text-white font-medium py-2.5 px-4 rounded-lg transition duration-200 flex items-center justify-center">
@ -119,7 +102,7 @@
// 表单提交前的基本验证
document.querySelector('form').addEventListener('submit', function(e) {
const idCard = document.getElementById('idCard').value;
const phone = document.getElementById('phone').value;
// const phone = document.getElementById('phone').value;
let isValid = true;
// 身份证号简单验证18位
@ -128,12 +111,6 @@
isValid = false;
}
// 手机号简单验证11位数字
if (!/^\d{11}$/.test(phone)) {
alert('请输入有效的11位手机号');
isValid = false;
}
if (!isValid) {
e.preventDefault(); // 阻止表单提交
}