diff --git a/docsql/2026/04/多考勤系统.md b/docsql/2026/04/多考勤系统.md index 218014c5..cfd03e48 100644 --- a/docsql/2026/04/多考勤系统.md +++ b/docsql/2026/04/多考勤系统.md @@ -14,3 +14,19 @@ WHERE ac.is_default = 1 AND ac.enabled = 1 ) ac ON pmad.project_id = ac.project_id SET pmad.cfg_id = ac.cfg_id WHERE pmad.att_device = 'device' AND pmad.cfg_id = 0; + +### 2.attendance_ubi_data表增加cfg_id保存配置ID + +更新历史数据 + +UPDATE attendance_ubi_data a +SET cfg_id = ( +SELECT id +FROM attendance_cfg +WHERE project_id = a.projectid +AND com_id = a.comId +AND is_default = 1 +AND enabled = 1 +LIMIT 1 +) +WHERE a.cfg_id IS NULL; diff --git a/docsql/yanzhu_project_cloud.sql b/docsql/yanzhu_project_cloud.sql index 1eb9f017..78f5aac2 100644 --- a/docsql/yanzhu_project_cloud.sql +++ b/docsql/yanzhu_project_cloud.sql @@ -1736,6 +1736,7 @@ CREATE TABLE `attendance_ubi_data` ( `comName` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '公司名称', `projectId` int DEFAULT NULL COMMENT '项目ID', `projectName` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '项目名称', + `cfg_id` int DEFAULT NULL COMMENT '配置ID', `sub_dept_id` int DEFAULT NULL COMMENT '单位ID', `sub_dept_name` varchar(255) DEFAULT NULL COMMENT '单位名称', `userId` int DEFAULT NULL COMMENT '用户ID', diff --git a/yanzhu-common/yanzhu-common-mapper/src/main/java/com/yanzhu/manage/domain/AttendanceUbiData.java b/yanzhu-common/yanzhu-common-mapper/src/main/java/com/yanzhu/manage/domain/AttendanceUbiData.java index 73213108..9d5fb386 100644 --- a/yanzhu-common/yanzhu-common-mapper/src/main/java/com/yanzhu/manage/domain/AttendanceUbiData.java +++ b/yanzhu-common/yanzhu-common-mapper/src/main/java/com/yanzhu/manage/domain/AttendanceUbiData.java @@ -30,6 +30,10 @@ public class AttendanceUbiData extends BaseEntity @Excel(name = "项目ID") private Long projectId; + /** 配置ID */ + @Excel(name = "配置ID") + private Long cfgId; + /** 用户ID */ @Excel(name = "用户ID") private Long userId; @@ -180,6 +184,15 @@ public class AttendanceUbiData extends BaseEntity { return projectId; } + public void setCfgId(Long cfgId) + { + this.cfgId = cfgId; + } + + public Long getCfgId() + { + return cfgId; + } public void setUserId(Long userId) { this.userId = userId; diff --git a/yanzhu-common/yanzhu-common-mapper/src/main/java/com/yanzhu/manage/mapper/AttendanceUbiDataMapper.java b/yanzhu-common/yanzhu-common-mapper/src/main/java/com/yanzhu/manage/mapper/AttendanceUbiDataMapper.java index 4012d671..f1b493f7 100644 --- a/yanzhu-common/yanzhu-common-mapper/src/main/java/com/yanzhu/manage/mapper/AttendanceUbiDataMapper.java +++ b/yanzhu-common/yanzhu-common-mapper/src/main/java/com/yanzhu/manage/mapper/AttendanceUbiDataMapper.java @@ -64,8 +64,18 @@ public interface AttendanceUbiDataMapper */ public int deleteAttendanceUbiDataByIds(Long[] ids); + /** + * 查询考勤统计 + * @param attendanceUbiData 查询条件 + * @return 考勤统计集合 + */ List queryStatistics(AttendanceUbiData attendanceUbiData); + /** + * 根据用户ID列表查询考勤信息 + * @param attendanceUbiData 查询条件 + * @return 考勤信息集合 + */ List queryStatisticsByUserIds(AttendanceUbiData attendanceUbiData); /** diff --git a/yanzhu-common/yanzhu-common-mapper/src/main/resources/mapper/manage/AttendanceUbiDataMapper.xml b/yanzhu-common/yanzhu-common-mapper/src/main/resources/mapper/manage/AttendanceUbiDataMapper.xml index 642f7b73..a76fb6a5 100644 --- a/yanzhu-common/yanzhu-common-mapper/src/main/resources/mapper/manage/AttendanceUbiDataMapper.xml +++ b/yanzhu-common/yanzhu-common-mapper/src/main/resources/mapper/manage/AttendanceUbiDataMapper.xml @@ -10,6 +10,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + @@ -37,13 +38,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - select id, comId, projectId, userId, userName, sub_dept_group, sub_dept_group_name, craft_type, craft_post,admitGuid, + select id, comId, projectId, cfg_id, userId, userName, sub_dept_group, sub_dept_group_name, craft_type, craft_post,admitGuid, eventGuid,inPhoto,outPhoto,comName,projectName,sub_dept_id,sub_dept_name,work_area_id, inTime, outTime, deviceNo, is_del, state, remark, create_by, create_time, update_by, update_time from attendance_ubi_data - select id, comId, projectId, userId, userName, sub_dept_group, sub_dept_group_name, craft_type, craft_post,admitGuid, + select id, comId, projectId, cfg_id, userId, userName, sub_dept_group, sub_dept_group_name, craft_type, craft_post,admitGuid, eventGuid,inPhoto,outPhoto,inData,outData,comName,projectName,sub_dept_id,sub_dept_name,work_area_id, inTime, outTime, deviceNo, is_del, state, remark, create_by, create_time, update_by, update_time from attendance_ubi_data @@ -235,11 +236,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" select u.craft_type as craftType, count(1) as total from attendance_ubi_data d left join pro_project_info_subdepts_users u on u.user_id = d.userId - and d.projectId = #{projectId} - and d.sub_dept_id = #{subDeptId} - and d.sub_dept_group = #{subDeptGroup} - and date(d.create_time) = CURDATE() - + + and d.projectId = #{projectId} + and d.cfg_id in (select id from attendance_cfg where project_id=#{projectId} and is_default=1 and enabled=1) + + and d.sub_dept_id = #{subDeptId} + and d.sub_dept_group = #{subDeptGroup} + and date(d.create_time) = CURDATE() + group by u.craft_type @@ -247,7 +251,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" select DATE_FORMAT(days.attendanceTime, '%m-%d') as attendanceTime,days.total from( select date(d.create_time) as attendanceTime, count(1) as total from attendance_ubi_data d - and d.projectId = #{projectId} + + and d.projectId = #{projectId} + and d.cfg_id in (select id from attendance_cfg where project_id=#{projectId} and is_default=1 and enabled=1) + and d.sub_dept_id = #{subDeptId} and d.sub_dept_group = #{subDeptGroup} and date(d.create_time) >= CURDATE() - INTERVAL 7 DAY @@ -261,7 +268,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" SELECT dt comName, count(1) comId from (SELECT DISTINCT userid, date (ifNull(inTime, outTime)) dt from attendance_ubi_data - and projectid = #{prjId} + + and projectid = #{prjId} + and cfg_id in (select id from attendance_cfg where project_id=#{prjId} and is_default=1 and enabled=1) + and is_del = 0 and date(ifNull(inTime,outTime)) = ]]> date(#{dateStart}) and date(ifNull(outTime,inTime)) date(#{dateEnd}) @@ -272,6 +282,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" diff --git a/yanzhu-modules/yanzhu-manage/src/main/java/com/yanzhu/manage/controller/UniCallBackController.java b/yanzhu-modules/yanzhu-manage/src/main/java/com/yanzhu/manage/controller/UniCallBackController.java index b273cfb0..3a2c236c 100644 --- a/yanzhu-modules/yanzhu-manage/src/main/java/com/yanzhu/manage/controller/UniCallBackController.java +++ b/yanzhu-modules/yanzhu-manage/src/main/java/com/yanzhu/manage/controller/UniCallBackController.java @@ -142,6 +142,7 @@ public class UniCallBackController { ProProjectInfoSubdeptsUsers proUser = userList.get(0); AttendanceUbiData addData = new AttendanceUbiData(); addData.setAdmitGuid(admitGuid); + addData.setCfgId(cfgId); addData.setComName(proUser.getComName()); addData.setProjectName(proUser.getProjectName()); addData.setSubDeptId(proUser.getSubDeptId()); diff --git a/yanzhu-modules/yanzhu-manage/src/main/java/com/yanzhu/manage/service/IAttendanceCfgService.java b/yanzhu-modules/yanzhu-manage/src/main/java/com/yanzhu/manage/service/IAttendanceCfgService.java index 8af9a5e2..a646322b 100644 --- a/yanzhu-modules/yanzhu-manage/src/main/java/com/yanzhu/manage/service/IAttendanceCfgService.java +++ b/yanzhu-modules/yanzhu-manage/src/main/java/com/yanzhu/manage/service/IAttendanceCfgService.java @@ -69,6 +69,11 @@ public interface IAttendanceCfgService */ AttendanceCfg selectDefaultCfgByProjectAndCom(Long projectId, Long comId); + /** + * 根据项目ID和公司ID获取默认考勤配置 + */ + AttendanceCfg getDefaultAttendanceCfg(Long projectId, Long comId); + /** * 根据设备编号查询默认配置 */ diff --git a/yanzhu-modules/yanzhu-manage/src/main/java/com/yanzhu/manage/service/impl/AttendanceCfgServiceImpl.java b/yanzhu-modules/yanzhu-manage/src/main/java/com/yanzhu/manage/service/impl/AttendanceCfgServiceImpl.java index 550791ec..7afecf32 100644 --- a/yanzhu-modules/yanzhu-manage/src/main/java/com/yanzhu/manage/service/impl/AttendanceCfgServiceImpl.java +++ b/yanzhu-modules/yanzhu-manage/src/main/java/com/yanzhu/manage/service/impl/AttendanceCfgServiceImpl.java @@ -177,6 +177,14 @@ public class AttendanceCfgServiceImpl implements IAttendanceCfgService return attendanceCfgMapper.selectDefaultCfgByProjectAndCom(projectId, comId); } + /** + * 根据项目ID和公司ID获取默认考勤配置 + */ + @Override + public AttendanceCfg getDefaultAttendanceCfg(Long projectId, Long comId) { + return attendanceCfgMapper.selectDefaultCfgByProjectAndCom(projectId, comId); + } + /** * 根据设备编号查询默认配置 */ diff --git a/yanzhu-modules/yanzhu-manage/src/main/java/com/yanzhu/manage/service/impl/AttendanceUbiDataServiceImpl.java b/yanzhu-modules/yanzhu-manage/src/main/java/com/yanzhu/manage/service/impl/AttendanceUbiDataServiceImpl.java index 44d994db..226f5fcc 100644 --- a/yanzhu-modules/yanzhu-manage/src/main/java/com/yanzhu/manage/service/impl/AttendanceUbiDataServiceImpl.java +++ b/yanzhu-modules/yanzhu-manage/src/main/java/com/yanzhu/manage/service/impl/AttendanceUbiDataServiceImpl.java @@ -11,11 +11,13 @@ import com.yanzhu.common.core.enums.UserPostEnums; import com.yanzhu.common.core.utils.DateUtils; import com.yanzhu.common.core.utils.StringUtils; import com.yanzhu.common.security.utils.SecurityUtils; +import com.yanzhu.manage.domain.AttendanceCfg; import com.yanzhu.manage.domain.AttendanceUbiData; import com.yanzhu.manage.domain.ProMobileAttendanceData; import com.yanzhu.manage.domain.ProProjectInfoSubdeptsUsers; import com.yanzhu.manage.mapper.AttendanceUbiDataMapper; import com.yanzhu.manage.mapper.ProProjectInfoSubdeptsUsersMapper; +import com.yanzhu.manage.service.IAttendanceCfgService; import com.yanzhu.manage.service.IAttendanceUbiDataService; import com.yanzhu.manage.service.IProProjectInfoSubdeptsUsersService; import com.yanzhu.system.mapper.SysDictDataMapper; @@ -44,6 +46,10 @@ public class AttendanceUbiDataServiceImpl implements IAttendanceUbiDataService @Autowired private ProProjectInfoSubdeptsUsersMapper proProjectInfoSubdeptsUsersMapper; + + @Autowired + private IAttendanceCfgService attendanceCfgService; + @Autowired private IProProjectInfoSubdeptsUsersService proProjectInfoSubdeptsUsersService; /** @@ -320,6 +326,8 @@ public class AttendanceUbiDataServiceImpl implements IAttendanceUbiDataService if(user==null){ return 0; } + + attendance.setProjectId(attData.getProjectId()); attendance.setUserId(user.getUserId()); attendance.setIsDel(0L); @@ -353,6 +361,11 @@ public class AttendanceUbiDataServiceImpl implements IAttendanceUbiDataService attendance.setId(list.get(0).getId()); return updateAttendanceUbiData(attendance); }else{ + //根据projectId+comId获取默认考勤配置 + AttendanceCfg attendanceCfg=attendanceCfgService.getDefaultAttendanceCfg(attData.getProjectId(),user.getComId()); + if(attendanceCfg!=null){ + attendance.setCfgId(attendanceCfg.getId()); + } return insertAttendanceUbiData(attendance); } }