Compare commits

...

5 Commits

Author SHA1 Message Date
andy
cb1d56c751 钉钉员工入职离职回调 2026-03-18 13:29:08 +08:00
andy
022bfe4fb4 Merge remote-tracking branch 'remotes/origin/master' into dingding 2026-03-18 09:06:22 +08:00
andy
06ee3738f6 打卡详情调整 2026-03-18 08:55:47 +08:00
andy
7393d00710 1 2026-03-17 16:35:16 +08:00
andy
3e70da9fd9 处理打开失败情况 2026-03-17 16:07:20 +08:00
19 changed files with 340 additions and 13 deletions

View File

@ -51,7 +51,7 @@ public class RzAttendanceDetail extends BaseEntity
/** 周六标识 */
private String remark;
private String photo;
// private String photo;
/** 删除标记 */
private String delFlag;

View File

@ -0,0 +1,23 @@
package com.evo.attendance.domain;
import lombok.Data;
/**
* RzAttendancePhoto
*
* @author andy.shi
* @ClassName:RzAttendancePhoto
* @date: 2026年03月17日 8:52
* @remark: 开发人员联系方式 1042025947@qq.com/微信同步
*/
@Data
public class RzAttendancePhoto {
/** 主键 */
private Long id;
private Long attendanceDetailId;
private String photo;
}

View File

@ -27,6 +27,8 @@ public class RzAttendanceDetailTimeLineVO {
String size = "large";
String delFlag;
public RzAttendanceDetailTimeLineVO(String content, String photo, String timestamp, String delFlag) {
this.content = content;
this.photo = photo;
@ -36,7 +38,7 @@ public class RzAttendanceDetailTimeLineVO {
this.icon = timeLine.icon;
}
enum TimeLineEnum{
public enum TimeLineEnum{
UP("上班", "primary","el-icon-caret-top"),
OVERTIME("加班", "success","el-icon-plus"),
DOWN("下班", "warning","el-icon-caret-bottom"),
@ -46,8 +48,8 @@ public class RzAttendanceDetailTimeLineVO {
;
String typeWork;
String type;
String icon;
public String type;
public String icon;
TimeLineEnum(String typeWork, String type, String icon) {
this.typeWork = typeWork;

View File

@ -2,6 +2,7 @@ package com.evo.attendance.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.evo.attendance.domain.RzAttendanceDetail;
import com.evo.attendance.domain.vo.RzAttendanceDetailTimeLineVO;
import org.apache.ibatis.annotations.Param;
import java.util.Date;
@ -76,4 +77,6 @@ public interface RzAttendanceDetailMapper extends BaseMapper<RzAttendanceDetail>
public RzAttendanceDetail selectLastRzAttendanceDetailByBk(@Param("staffId") Long staffId, @Param("buttonType") String buttonType, @Param("startDateTime") Date startDateTime, @Param("endDateTime") Date endDateTime);
List<Map<String,Object>> getThreeDayNotCheck();
List<RzAttendanceDetailTimeLineVO> selectListByAttendanceId(@Param("attId")Long attId);
}

View File

@ -0,0 +1,15 @@
package com.evo.attendance.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.evo.attendance.domain.RzAttendancePhoto;
/**
* RzAttendancePhotoMapper
*
* @author andy.shi
* @ClassName:RzAttendancePhotoMapper
* @date: 2026年03月17日 8:58
* @remark: 开发人员联系方式 1042025947@qq.com/微信同步
*/
public interface RzAttendancePhotoMapper extends BaseMapper<RzAttendancePhoto> {
}

View File

@ -1,5 +1,6 @@
package com.evo.attendance.processor.impl;
import com.alibaba.fastjson2.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.evo.attendance.domain.RzAttendance;
import com.evo.attendance.domain.RzAttendanceDetail;
@ -174,6 +175,7 @@ public class KQDeviceExchangeProcessor implements PunchTheClockStrategyExchangeP
//获取员工的工作时长
RzAttendanceDetail attendanceDetail = rzAttendanceDetailService.addDetail(attendance, rules, sn, date, "", photo);
if(attendanceDetail.getId() == null){
log.info("[打卡失败]============> 因为没有打卡详情id{}", JSON.toJSONString(attendanceDetail));
return initMessage(1, "打卡失败");
}
@ -201,10 +203,10 @@ public class KQDeviceExchangeProcessor implements PunchTheClockStrategyExchangeP
}
//上班的下班卡
if(rzAttendanceDetail.getButtonType().contains("上班")){
return KqUtils.workOffDutyCard( date, rzAttendanceDetail.getButtonType(), attendance) ? initMessage(0, "打卡成功") : initMessage(1,"打卡失败");
}
log.info("[打卡失败]============> 走到最后了, 打卡人姓名{}", sysStaff.getName());
return initMessage(1, "打卡失败");
}
@ -233,6 +235,8 @@ public class KQDeviceExchangeProcessor implements PunchTheClockStrategyExchangeP
attendance.setYcsFlag("1");
}
}catch (Exception e){
log.info("[打卡失败]============> 出现异常了, 异常原因{}", e.getMessage());
e.printStackTrace();
return initMessage(1, "打卡失败,"+e.getMessage());
}
//查询昨天是否未打卡
@ -248,6 +252,7 @@ public class KQDeviceExchangeProcessor implements PunchTheClockStrategyExchangeP
e.printStackTrace();
log.error("查询前一天的打卡情况报错了");
}
log.info("[打卡失败]============> 上班卡模块, 走到最后了, 不知道成功还是失败, 打卡人姓名{}", attendance.getName());
return (rzAttendanceMapper.updateRzAttendance(attendance) > 0) ? initMessage(0, "打卡成功"+notBeforeEndTimeMessage) : initMessage(1, "打卡失败"+notBeforeEndTimeMessage);
}
//

View File

@ -0,0 +1,17 @@
package com.evo.attendance.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.evo.attendance.domain.RzAttendancePhoto;
/**
* 接口
*
* @ClassName:RzAttendanceDetailService
* @date: 2025年07月07日 13:32
* @author: andy.shi
* @contact: 17330188597
* @remark: 开发人员联系方式 1042025947@qq.com/微信同步
*/
public interface RzAttendancePhotoService extends IService<RzAttendancePhoto> {
}

View File

@ -4,9 +4,12 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.evo.attendance.domain.RzAttendance;
import com.evo.attendance.domain.RzAttendanceDetail;
import com.evo.attendance.domain.RzAttendancePhoto;
import com.evo.attendance.domain.vo.RzAttendanceDetailTimeLineVO;
import com.evo.attendance.mapper.RzAttendanceDetailMapper;
import com.evo.attendance.mapper.RzAttendancePhotoMapper;
import com.evo.attendance.service.RzAttendanceDetailService;
import com.evo.attendance.service.RzAttendancePhotoService;
import com.evo.common.constant.Constants;
import com.evo.common.core.domain.entity.SysDept;
import com.evo.common.utils.Collections;
@ -55,6 +58,8 @@ public class RzAttendanceDetailServiceImpl extends ServiceImpl<RzAttendanceDetai
RzLeaveDetailMapper rzLeaveDetailMapper;
@Autowired
private SysStaffMapper sysStaffMapper;
@Autowired
private RzAttendancePhotoMapper rzAttendancePhotoMapper;
@Override
public RzAttendanceDetail addDetail(RzAttendance attendance, String rules, String sn, Date date, String remark, String photo) {
@ -93,17 +98,25 @@ public class RzAttendanceDetailServiceImpl extends ServiceImpl<RzAttendanceDetai
attendanceDetail.setEquipmentCode(sn);
attendanceDetail.setCreateTime(new Date());
attendanceDetail.setRemark(remark);
if(StringUtils.isNotEmpty(photo)){
attendanceDetail.setPhoto(photo);
}
if(attendanceDetail.getId() == null){
save(attendanceDetail);
}else{
updateById(attendanceDetail);
}
if(StringUtils.isNotEmpty(photo)){
addPhoto(attendanceDetail.getId(), photo);
}
return attendanceDetail;
}
@Async
public void addPhoto(Long detailId, String photo){
RzAttendancePhoto rzAttendancePhoto = new RzAttendancePhoto();
rzAttendancePhoto.setAttendanceDetailId(detailId);
rzAttendancePhoto.setPhoto(photo);
rzAttendancePhotoMapper.insert(rzAttendancePhoto);
}
@Override
public RzAttendanceDetail selectLastRzAttendanceDetail(Long staffId) {
return getBaseMapper().selectLastRzAttendanceDetail(staffId);
@ -121,9 +134,18 @@ public class RzAttendanceDetailServiceImpl extends ServiceImpl<RzAttendanceDetai
@Override
public List<RzAttendanceDetailTimeLineVO> selectListByAttendanceId(Long attId) {
return list(new LambdaQueryWrapper<RzAttendanceDetail>().eq(RzAttendanceDetail::getAttendanceId, attId).select(RzAttendanceDetail::getButtonType, RzAttendanceDetail::getPhoto, RzAttendanceDetail::getDateTime,RzAttendanceDetail::getDelFlag)).stream().map(data ->{
return new RzAttendanceDetailTimeLineVO(data.getButtonType(), data.getPhoto(), DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:ss",data.getDateTime()), data.getDelFlag());
}).collect(Collectors.toList());
List<RzAttendanceDetailTimeLineVO> result = getBaseMapper().selectListByAttendanceId(attId);
result.stream().forEach(data->{
RzAttendanceDetailTimeLineVO.TimeLineEnum timeLine = RzAttendanceDetailTimeLineVO.TimeLineEnum.get(data.getContent(), data.getDelFlag());
data.setType(timeLine.type);
data.setIcon(timeLine.icon);
});
return result;
//
// return getBaseMapper().selectListByAttendanceId(new LambdaQueryWrapper<RzAttendanceDetail>().eq(RzAttendanceDetail::getAttendanceId, attId)
// .select(RzAttendanceDetail::getButtonType, RzAttendanceDetail::getPhoto, RzAttendanceDetail::getDateTime,RzAttendanceDetail::getDelFlag)).stream().map(data ->{
// return new RzAttendanceDetailTimeLineVO(data.getButtonType(), data.getPhoto(), DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:ss",data.getDateTime()), data.getDelFlag());
// }).collect(Collectors.toList());
}
SimpleDateFormat sdfd = new SimpleDateFormat("yyyy-MM-dd");

View File

@ -0,0 +1,22 @@
package com.evo.attendance.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.evo.attendance.domain.RzAttendancePhoto;
import com.evo.attendance.mapper.RzAttendancePhotoMapper;
import com.evo.attendance.service.RzAttendancePhotoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
/**
*
*
* @ClassName:RzAttendanceDetailServiceimpl
* @date: 2025年07月07日 13:33
* @author: andy.shi
* @contact: 17330188597
* @remark: 开发人员联系方式 1042025947@qq.com/微信同步
*/
@Slf4j
@Service
public class RzAttendancePhotoServiceImpl extends ServiceImpl<RzAttendancePhotoMapper, RzAttendancePhoto> implements RzAttendancePhotoService {
}

View File

@ -116,6 +116,20 @@ public class DingUtils {
}
return "";
}
//根据手机号获取用户id
public static String getUserInfoByUserId(String userId){
try {
DingTalkClient client = new DefaultDingTalkClient(DingGlobalParams.getUrl()+"v2/user/get");
OapiV2UserGetRequest req = new OapiV2UserGetRequest();
req.setUserid(userId);
OapiV2UserGetResponse rsp = client.execute(req, "");
return rsp.getBody();
} catch (Exception e) {
e.printStackTrace();
}
return "";
}
/***
* 获取班次信息
*

View File

@ -12,9 +12,14 @@ import com.alibaba.fastjson2.JSONObject;
*/
public interface DingCallBackExchangeProcessor {
//入职
static final String EVENT_TYPE_USER_ADD_ORG = "user_add_org";
//离职
static final String EVENT_TYPE_USER_LEAVE_ORG = "user_leave_org";
//打卡
static final String EVENT_TYPE_CHECK_RECORD = "attendance_check_record";
//审批实例订阅
//审批实例订阅-> 补卡
static final String EVENT_TYPE_INSTANCE_CHANGE = "bpms_instance_change";
//请假加班出差外出状态变更事件
static final String EVENT_TYPE_APPROVE_STATUS_CHANGE = "attendance_approve_status_change";

View File

@ -0,0 +1,41 @@
package com.evo.ding.processor.callback.impl;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.evo.ding.processor.callback.DingCallBackExchangeProcessor;
import com.evo.system.service.ISysStaffService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* 员工离职 DingCallBackUseLeaveOrgExchangeProcessor
*
* @author andy.shi
* @ClassName:DingCallBackUseLeaveOrgExchangeProcessor
* @date: 2026年03月12日 9:02
* @remark: 开发人员联系方式 1042025947@qq.com/微信同步
*/
@Slf4j
@Service
public class DingCallBackUseLeaveOrgExchangeProcessor implements DingCallBackExchangeProcessor {
@Autowired
ISysStaffService sysStaffService;
@Override
public boolean accept(String eventType) {
return EVENT_TYPE_USER_LEAVE_ORG.equals(eventType);
}
@Override
public void exchange(JSONObject json) {
log.info("钉钉 员工离职========================>>>{}", json.toString());
JSONArray dataList = json.getJSONArray("userId");
if(dataList!= null && dataList.size() > 0){
dataList.forEach(data->{
sysStaffService.sysStaffLeaveByDingUserId(String.valueOf(data));
});
}
}
}

View File

@ -0,0 +1,45 @@
package com.evo.ding.processor.callback.impl;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.evo.attendance.service.IRzAttendanceService;
import com.evo.common.utils.StringUtils;
import com.evo.ding.DingUtils;
import com.evo.ding.processor.callback.DingCallBackExchangeProcessor;
import com.evo.system.service.ISysStaffService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* 员工入职 DingCallBackUserAddOrgExchangeProcessor
*
* @author andy.shi
* @ClassName:DingCallBackUserAddOrgExchangeProcessor
* @date: 2026年03月12日 9:02
* @remark: 开发人员联系方式 1042025947@qq.com/微信同步
*/
@Slf4j
@Service
public class DingCallBackUserAddOrgExchangeProcessor implements DingCallBackExchangeProcessor {
@Autowired
ISysStaffService sysStaffService;
@Override
public boolean accept(String eventType) {
return EVENT_TYPE_USER_ADD_ORG.equals(eventType);
}
@Override
public void exchange(JSONObject json) {
log.info("钉钉 新增员工========================>>>{}", json.toString());
JSONArray dataList = json.getJSONArray("userId");
if(dataList!= null && dataList.size() > 0){
dataList.forEach(data->{
DingUtils.getUserInfoByUserId(String.valueOf(data));
sysStaffService.sysStaffLeaveByDingUserId(String.valueOf(data));
});
}
}
}

View File

@ -110,7 +110,7 @@ public class RzRestaurantStatisticsServiceImpl extends ServiceImpl<RzRestaurantS
//查询消费情况
Map<Long,String> dicMap = sysDictDataMapper.selectDictDataByType(Constants.SYS_RESTAUTANT).stream().collect(Collectors.toMap(SysDictData::getDictCode, SysDictData::getDictValue));
//优先检查是否为住宿
Map<Long, Boolean> zsMap = sysStaffMapper.selectSysStaffListAll().stream().collect(Collectors.toMap(SysStaff::getUserId, d->"".equals(d.getZsFlag())));
Map<Long, Boolean> zsMap = sysStaffMapper.selectSysStaffListByRzRestaurantStatistics(rzRestaurantStatistics.getMonth()).stream().collect(Collectors.toMap(SysStaff::getUserId, d->"".equals(d.getZsFlag())));
List<String> notAccommodationNames = ParamUtils.getInternNotAccommodation();
//然后在检查是否为日薪
Map<Long, Boolean> rxMap = sysStaffDetailMapper.selectList(new LambdaQueryWrapper<SysStaffDetail>().in(SysStaffDetail::getStaffId, zsMap.keySet().toArray())).stream().collect(Collectors.toMap(SysStaffDetail::getStaffId, d->d.getDailyWage() != null && d.getDailyWage().intValue() > 0));

View File

@ -51,6 +51,12 @@ public interface SysStaffMapper extends BaseMapper<SysStaff>
* @return
*/
public List<SysStaff> selectSysStaffListAll();
/**
* 查询所有的在职员工信息
* @return
*/
public List<SysStaff> selectSysStaffListByRzRestaurantStatistics(Date date);
/**
* 根据身份证号查询员工信息
* @param idCard

View File

@ -39,6 +39,13 @@ public interface ISysStaffService extends IService<SysStaff>
* @return 结果
*/
public AjaxResult insertSysStaff(SysStaff sysStaff);
/**
* 新增员工管理
*
* @param result 员工管理
* @return 结果
*/
public void insertSysStaffByDingDing(String result);
/**
* 修改员工管理
*
@ -122,4 +129,10 @@ public interface ISysStaffService extends IService<SysStaff>
* @return 员工管理
*/
public SysStaff selectSysStaffByDingUserId(String dingUserId);
/***
* 根据钉钉的用户id做用户离职
* @param dingUserId
*/
public void sysStaffLeaveByDingUserId(String dingUserId);
}

View File

@ -47,6 +47,8 @@ import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.math.BigDecimal;
@ -179,6 +181,68 @@ public class SysStaffServiceImpl extends ServiceImpl<SysStaffMapper, SysStaff> i
return AjaxResult.success();
}
@Override
public void insertSysStaffByDingDing(String result) {
JSONObject dingResult = JSONObject.parseObject(result);
dingResult.getJSONObject("result");
// //根据省份证号查询是否已经录入
// SysStaff p_staff = getBaseMapper().queryysStaffByIdCard(sysStaff.getIdCard());
// if(StringUtils.isNotNull(p_staff)){
// return AjaxResult.error("此人录入过!!");
// }
// //判断是否是领导是反写部门信息
// if("".equals(sysStaff.getIsLeader())){
// //根据ID查询部门信息
// SysDept sysDept = deptMapper.selectDeptById(sysStaff.getDeptId());
// sysDept.setPhone(sysStaff.getPhone());
// sysDept.setLeader(sysStaff.getName());
// int i = deptMapper.updateDept(sysDept);
// if(i < 1){
// return AjaxResult.error("更新部门负责人失败");
// }
// }
// //根据省份证确定性别和年龄
// sysStaff.setAge(Long.parseLong(new SimpleDateFormat("yyyy").format(new Date())) - Long.parseLong(sysStaff.getIdCard().substring(6,10)));
// //性别
// sysStaff.setSex((Integer.parseInt(sysStaff.getIdCard().substring(16,17)) % 2 == 0) ? "1" : "0");
// //员工编码
// sysStaff.setCode(getCodeByCompanyName());
// sysStaff.setSeniority(0l);
// sysStaff.setStatus(Constants.JOB_STATIS_0);
// sysStaff.setCreateTime(DateUtils.getNowDate());
// sysStaff.setCreateBy(SecurityUtils.getUsername());
// sysStaff.setDelFlag(Constants.DELETE_FLAG_0);
//
// if(CollectionUtils.isNotEmpty(sysStaff.getSubsidyList())){
// sysStaff.setSubsidys(sysStaff.getSubsidyList().stream().map(String::valueOf).collect(Collectors.joining(",")));
// }
// //打卡位置改为多选
// if(CollectionUtils.isNotEmpty(sysStaff.getTimeClockList())){
// sysStaff.setTimeClock(sysStaff.getTimeClockList().stream().collect(Collectors.joining(",")));
// }
// //新增员工信息到金蝶
// if(StringUtils.isNotEmpty(sysStaff.getJobCode())){
// sysStaff.setExtended(KingdeeRequestUtils.employeeSave(Collections.asMap("userName", sysStaff.getName(), "userCode", sysStaff.getCode(), "jobCode", sysStaff.getJobCode().split("_")[0],"deptCode", sysStaff.getJobCode().split("_")[1])));
// }else if(StringUtils.isEmpty(sysStaff.getJobCode())){
// sysStaff.setExtended(KingdeeRequestUtils.employeeSaveEmptyJob(Collections.asMap("userName", sysStaff.getName(), "userCode", sysStaff.getCode())));
// }
//
// int i = getBaseMapper().insertSysStaff(sysStaff);
// if(i < 1){
// return AjaxResult.error("员工添加失败");
// }
// //员工详情
// createStaffDetail(sysStaff);
// //打卡统计打卡详情
// rzAttendanceStatisticalService.createRzAttendance(sysStaff, Collections.emptyList(), null);
// //处理餐饮信息
// rzRestaurantStatisticsService.createRestaurantStatistics(sysStaff, DateUtils.getNowDate());
// //处理考勤机相关信息
// initCheckDevice(sysStaff);
}
private void initCheckDevice(SysStaff sysStaff){
//如果文件Id不为空, 则需要更新打卡设备信息, 完成后, 同步更新图片的业务Id数据
@ -843,4 +907,12 @@ public class SysStaffServiceImpl extends ServiceImpl<SysStaffMapper, SysStaff> i
public SysStaff selectSysStaffByDingUserId(String dingUserId) {
return getBaseMapper().selectSysStaffByDingUserId(dingUserId);
}
@Override
public void sysStaffLeaveByDingUserId(String dingUserId) {
SysStaff sysStaff = selectSysStaffByDingUserId(dingUserId);
//减去一分钟, 防止离职失败
sysStaff.setQuitDate(DateUtils.addMinutes(new Date(), -1));
updateSysStaff(sysStaff);
}
}

View File

@ -117,4 +117,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select>
<select id="selectListByAttendanceId" resultType="com.evo.attendance.domain.vo.RzAttendanceDetailTimeLineVO">
select ad.button_type as content, DATE_FORMAT(ad.date_time,"%Y-%m-%d %H:%i:%s") as `timestamp`, ad.del_flag as delFlag , ap.photo
from rz_attendance_detail ad
left join rz_attendance_photo ap on ap.attendance_detail_id = ad.id
where ad.attendance_id = #{attId}
</select>
</mapper>

View File

@ -260,6 +260,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<include refid="selectSysStaffVo"/>
where del_flag = '0' and status != '-1'
</select>
<select id="selectSysStaffListByRzRestaurantStatistics" resultMap="SysStaffResult">
select ss.user_id, ss.zs_flag
from sys_staff ss
left join rz_restaurant_statistics rrs on rrs.staff_id = ss.user_id
where DATE_FORMAT(rrs.month, '%Y%m' ) = DATE_FORMAT( #{date} , '%Y%m' )
</select>
<!-- 根据身份证号查询员工 -->
<select id="queryysStaffByIdCard" parameterType="String" resultMap="SysStaffResult">
<include refid="selectSysStaffVo"/>