考勤ID增加Cfg_ID

dev_xd
lj7788 2026-03-30 15:14:05 +08:00
parent fdc8f217d9
commit e2c98b0c3a
9 changed files with 87 additions and 9 deletions

View File

@ -14,3 +14,19 @@ WHERE ac.is_default = 1 AND ac.enabled = 1
) ac ON pmad.project_id = ac.project_id ) ac ON pmad.project_id = ac.project_id
SET pmad.cfg_id = ac.cfg_id SET pmad.cfg_id = ac.cfg_id
WHERE pmad.att_device = 'device' AND pmad.cfg_id = 0; 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;

View File

@ -1736,6 +1736,7 @@ CREATE TABLE `attendance_ubi_data` (
`comName` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '公司名称', `comName` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '公司名称',
`projectId` int DEFAULT NULL COMMENT '项目ID', `projectId` int DEFAULT NULL COMMENT '项目ID',
`projectName` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '项目名称', `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_id` int DEFAULT NULL COMMENT '单位ID',
`sub_dept_name` varchar(255) DEFAULT NULL COMMENT '单位名称', `sub_dept_name` varchar(255) DEFAULT NULL COMMENT '单位名称',
`userId` int DEFAULT NULL COMMENT '用户ID', `userId` int DEFAULT NULL COMMENT '用户ID',

View File

@ -30,6 +30,10 @@ public class AttendanceUbiData extends BaseEntity
@Excel(name = "项目ID") @Excel(name = "项目ID")
private Long projectId; private Long projectId;
/** 配置ID */
@Excel(name = "配置ID")
private Long cfgId;
/** 用户ID */ /** 用户ID */
@Excel(name = "用户ID") @Excel(name = "用户ID")
private Long userId; private Long userId;
@ -180,6 +184,15 @@ public class AttendanceUbiData extends BaseEntity
{ {
return projectId; return projectId;
} }
public void setCfgId(Long cfgId)
{
this.cfgId = cfgId;
}
public Long getCfgId()
{
return cfgId;
}
public void setUserId(Long userId) public void setUserId(Long userId)
{ {
this.userId = userId; this.userId = userId;

View File

@ -64,8 +64,18 @@ public interface AttendanceUbiDataMapper
*/ */
public int deleteAttendanceUbiDataByIds(Long[] ids); public int deleteAttendanceUbiDataByIds(Long[] ids);
/**
*
* @param attendanceUbiData
* @return
*/
List<AttendanceUbiData> queryStatistics(AttendanceUbiData attendanceUbiData); List<AttendanceUbiData> queryStatistics(AttendanceUbiData attendanceUbiData);
/**
* ID
* @param attendanceUbiData
* @return
*/
List<AttendanceUbiData> queryStatisticsByUserIds(AttendanceUbiData attendanceUbiData); List<AttendanceUbiData> queryStatisticsByUserIds(AttendanceUbiData attendanceUbiData);
/** /**

View File

@ -10,6 +10,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="comName" column="comName"/> <result property="comName" column="comName"/>
<result property="projectName" column="projectName"/> <result property="projectName" column="projectName"/>
<result property="projectId" column="projectId" /> <result property="projectId" column="projectId" />
<result property="cfgId" column="cfg_id" />
<result property="subDeptId" column="sub_dept_id" /> <result property="subDeptId" column="sub_dept_id" />
<result property="subDeptName" column="sub_dept_name" /> <result property="subDeptName" column="sub_dept_name" />
<result property="userId" column="userId" /> <result property="userId" column="userId" />
@ -37,13 +38,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap> </resultMap>
<sql id="selectAttendanceUbiDataVo"> <sql id="selectAttendanceUbiDataVo">
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, 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 inTime, outTime, deviceNo, is_del, state, remark, create_by, create_time, update_by, update_time from attendance_ubi_data
</sql> </sql>
<sql id="selectAttendanceUbiDataAllVo"> <sql id="selectAttendanceUbiDataAllVo">
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, 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 inTime, outTime, deviceNo, is_del, state, remark, create_by, create_time, update_by, update_time from attendance_ubi_data
</sql> </sql>
@ -235,7 +236,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
select u.craft_type as craftType, count(1) as total from attendance_ubi_data d 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 left join pro_project_info_subdepts_users u on u.user_id = d.userId
<where> <where>
<if test="projectId != null "> and d.projectId = #{projectId}</if> <if test="projectId != null ">
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)
</if>
<if test="subDeptId != null "> and d.sub_dept_id = #{subDeptId}</if> <if test="subDeptId != null "> and d.sub_dept_id = #{subDeptId}</if>
<if test="subDeptGroup != null "> and d.sub_dept_group = #{subDeptGroup}</if> <if test="subDeptGroup != null "> and d.sub_dept_group = #{subDeptGroup}</if>
and date(d.create_time) = CURDATE() and date(d.create_time) = CURDATE()
@ -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_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 select date(d.create_time) as attendanceTime, count(1) as total from attendance_ubi_data d
<where> <where>
<if test="projectId != null "> and d.projectId = #{projectId}</if> <if test="projectId != null ">
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)
</if>
<if test="subDeptId != null "> and d.sub_dept_id = #{subDeptId}</if> <if test="subDeptId != null "> and d.sub_dept_id = #{subDeptId}</if>
<if test="subDeptGroup != null "> and d.sub_dept_group = #{subDeptGroup}</if> <if test="subDeptGroup != null "> and d.sub_dept_group = #{subDeptGroup}</if>
and date(d.create_time) &gt;= CURDATE() - INTERVAL 7 DAY and date(d.create_time) &gt;= CURDATE() - INTERVAL 7 DAY
@ -261,7 +268,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
SELECT dt comName, count(1) comId SELECT dt comName, count(1) comId
from (SELECT DISTINCT userid, date (ifNull(inTime, outTime)) dt from attendance_ubi_data from (SELECT DISTINCT userid, date (ifNull(inTime, outTime)) dt from attendance_ubi_data
<where> <where>
<if test="prjId != null "> and projectid = #{prjId}</if> <if test="prjId != null ">
and projectid = #{prjId}
and cfg_id in (select id from attendance_cfg where project_id=#{prjId} and is_default=1 and enabled=1)
</if>
and is_del = 0 and is_del = 0
and date(ifNull(inTime,outTime)) <![CDATA[ >= ]]> date(#{dateStart}) and date(ifNull(outTime,inTime)) <![CDATA[ <= ]]> date(#{dateEnd}) and date(ifNull(inTime,outTime)) <![CDATA[ >= ]]> date(#{dateStart}) and date(ifNull(outTime,inTime)) <![CDATA[ <= ]]> date(#{dateEnd})
</where> </where>
@ -272,6 +282,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="getRealAttendance" resultMap="AttendanceUbiDataResult"> <select id="getRealAttendance" resultMap="AttendanceUbiDataResult">
<include refid="selectAttendanceUbiDataVo"/> <include refid="selectAttendanceUbiDataVo"/>
where projectid=#{prjId} and is_del=0 and date(ifNull(inTime,outTime)) = date(CURDATE()) where projectid=#{prjId} and is_del=0 and date(ifNull(inTime,outTime)) = date(CURDATE())
and cfg_id in (select id from attendance_cfg where project_id=#{prjId} and is_default=1 and enabled=1)
order by ifNull(inTime,outTime) DESC order by ifNull(inTime,outTime) DESC
LIMIT 4 LIMIT 4
</select> </select>

View File

@ -142,6 +142,7 @@ public class UniCallBackController {
ProProjectInfoSubdeptsUsers proUser = userList.get(0); ProProjectInfoSubdeptsUsers proUser = userList.get(0);
AttendanceUbiData addData = new AttendanceUbiData(); AttendanceUbiData addData = new AttendanceUbiData();
addData.setAdmitGuid(admitGuid); addData.setAdmitGuid(admitGuid);
addData.setCfgId(cfgId);
addData.setComName(proUser.getComName()); addData.setComName(proUser.getComName());
addData.setProjectName(proUser.getProjectName()); addData.setProjectName(proUser.getProjectName());
addData.setSubDeptId(proUser.getSubDeptId()); addData.setSubDeptId(proUser.getSubDeptId());

View File

@ -69,6 +69,11 @@ public interface IAttendanceCfgService
*/ */
AttendanceCfg selectDefaultCfgByProjectAndCom(Long projectId, Long comId); AttendanceCfg selectDefaultCfgByProjectAndCom(Long projectId, Long comId);
/**
* IDID
*/
AttendanceCfg getDefaultAttendanceCfg(Long projectId, Long comId);
/** /**
* *
*/ */

View File

@ -177,6 +177,14 @@ public class AttendanceCfgServiceImpl implements IAttendanceCfgService
return attendanceCfgMapper.selectDefaultCfgByProjectAndCom(projectId, comId); return attendanceCfgMapper.selectDefaultCfgByProjectAndCom(projectId, comId);
} }
/**
* IDID
*/
@Override
public AttendanceCfg getDefaultAttendanceCfg(Long projectId, Long comId) {
return attendanceCfgMapper.selectDefaultCfgByProjectAndCom(projectId, comId);
}
/** /**
* *
*/ */

View File

@ -11,11 +11,13 @@ import com.yanzhu.common.core.enums.UserPostEnums;
import com.yanzhu.common.core.utils.DateUtils; import com.yanzhu.common.core.utils.DateUtils;
import com.yanzhu.common.core.utils.StringUtils; import com.yanzhu.common.core.utils.StringUtils;
import com.yanzhu.common.security.utils.SecurityUtils; import com.yanzhu.common.security.utils.SecurityUtils;
import com.yanzhu.manage.domain.AttendanceCfg;
import com.yanzhu.manage.domain.AttendanceUbiData; import com.yanzhu.manage.domain.AttendanceUbiData;
import com.yanzhu.manage.domain.ProMobileAttendanceData; import com.yanzhu.manage.domain.ProMobileAttendanceData;
import com.yanzhu.manage.domain.ProProjectInfoSubdeptsUsers; import com.yanzhu.manage.domain.ProProjectInfoSubdeptsUsers;
import com.yanzhu.manage.mapper.AttendanceUbiDataMapper; import com.yanzhu.manage.mapper.AttendanceUbiDataMapper;
import com.yanzhu.manage.mapper.ProProjectInfoSubdeptsUsersMapper; import com.yanzhu.manage.mapper.ProProjectInfoSubdeptsUsersMapper;
import com.yanzhu.manage.service.IAttendanceCfgService;
import com.yanzhu.manage.service.IAttendanceUbiDataService; import com.yanzhu.manage.service.IAttendanceUbiDataService;
import com.yanzhu.manage.service.IProProjectInfoSubdeptsUsersService; import com.yanzhu.manage.service.IProProjectInfoSubdeptsUsersService;
import com.yanzhu.system.mapper.SysDictDataMapper; import com.yanzhu.system.mapper.SysDictDataMapper;
@ -44,6 +46,10 @@ public class AttendanceUbiDataServiceImpl implements IAttendanceUbiDataService
@Autowired @Autowired
private ProProjectInfoSubdeptsUsersMapper proProjectInfoSubdeptsUsersMapper; private ProProjectInfoSubdeptsUsersMapper proProjectInfoSubdeptsUsersMapper;
@Autowired
private IAttendanceCfgService attendanceCfgService;
@Autowired @Autowired
private IProProjectInfoSubdeptsUsersService proProjectInfoSubdeptsUsersService; private IProProjectInfoSubdeptsUsersService proProjectInfoSubdeptsUsersService;
/** /**
@ -320,6 +326,8 @@ public class AttendanceUbiDataServiceImpl implements IAttendanceUbiDataService
if(user==null){ if(user==null){
return 0; return 0;
} }
attendance.setProjectId(attData.getProjectId()); attendance.setProjectId(attData.getProjectId());
attendance.setUserId(user.getUserId()); attendance.setUserId(user.getUserId());
attendance.setIsDel(0L); attendance.setIsDel(0L);
@ -353,6 +361,11 @@ public class AttendanceUbiDataServiceImpl implements IAttendanceUbiDataService
attendance.setId(list.get(0).getId()); attendance.setId(list.get(0).getId());
return updateAttendanceUbiData(attendance); return updateAttendanceUbiData(attendance);
}else{ }else{
//根据projectId+comId获取默认考勤配置
AttendanceCfg attendanceCfg=attendanceCfgService.getDefaultAttendanceCfg(attData.getProjectId(),user.getComId());
if(attendanceCfg!=null){
attendance.setCfgId(attendanceCfg.getId());
}
return insertAttendanceUbiData(attendance); return insertAttendanceUbiData(attendance);
} }
} }