Commit 548b31d2 authored by 赵啸非's avatar 赵啸非

添加员工钉钉同步userId

parent 4e9d5846
package com.mortals.xhx.common.code;
import java.util.LinkedHashMap;
import java.util.Map;
/**
* @author: finegirl
* @date: 2021/7/16 11:50
* @description: 组件枚举类
**/
public enum QiongLaiProcessInstanceEnum {
邛崃大厅人员请假("PROC-E1A4A56A-0EA7-43FE-A073-52E2B9C53E58", "邛崃大厅人员请假"),
邛崃大厅人员因公外出("PROC-034CE8B1-ED6D-492F-AC2C-61BAC5C0B4B9", "邛崃大厅人员因公外出"),
邛崃大厅人员补卡申请("PROC-16D29417-3049-4EB8-9710-9D39F9EDD1BD", "邛崃大厅人员补卡申请"),
/*
邛崃机关人员补卡申请("PROC-DDBEBB18-4FFC-486A-8E97-BAD7911BB9F2", "邛崃机关人员补卡申请"),
邛崃机关人员请假("PROC-7C84DFC5-579E-4500-9159-F38642E7238C", "邛崃机关人员请假"),
邛崃机关人员因公外出("PROC-6B46D143-4A05-4E9B-9C99-E0BD75A29003", "机关人员因公外出"),*/;
private String value;
private String desc;
QiongLaiProcessInstanceEnum(String value, String desc) {
this.value = value;
this.desc = desc;
}
public String getValue() {
return this.value;
}
public String getDesc() {
return this.desc;
}
public static QiongLaiProcessInstanceEnum getByValue(String value) {
for (QiongLaiProcessInstanceEnum componentEnum : QiongLaiProcessInstanceEnum.values()) {
if (componentEnum.getValue() == value) {
return componentEnum;
}
}
return null;
}
/**
* 获取Map集合
*
* @param eItem 不包含项
* @return
*/
public static Map<String, String> getEnumMap(String... eItem) {
Map<String, String> resultMap = new LinkedHashMap<>();
for (QiongLaiProcessInstanceEnum item : QiongLaiProcessInstanceEnum.values()) {
try {
boolean hasE = false;
for (String e : eItem) {
if (item.getValue() == e) {
hasE = true;
break;
}
}
if (!hasE) {
resultMap.put(item.getValue() + "", item.getDesc());
}
} catch (Exception ex) {
}
}
return resultMap;
}
}
\ No newline at end of file
......@@ -37,6 +37,7 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
......@@ -86,7 +87,7 @@ public class SyncUserTaskImpl implements ITaskExcuteService {
//同步钉钉人员
staffService.syncPersonsByDingTalk(null);
log.info("同步钉钉usreId");
syncDingDingLocalUserIds();
//syncDingDingLocalUserIds();
log.info("钉钉直连同步人员信息");
//同步最近10天请假信息
......@@ -116,46 +117,32 @@ public class SyncUserTaskImpl implements ITaskExcuteService {
}
private void syncDingDingUserIds() {
try {
List<UserEntity> userList = userService.getCacheList().stream()
.filter(f -> !ObjectUtils.isEmpty(f.getCustomerId()))
.filter(f -> ObjectUtils.isEmpty(f.getDingUserId())).collect(Collectors.toList());
List<UserEntity> updateUserList = userList.stream().map(item -> {
UserEntity userEntity = new UserEntity();
userEntity.setId(item.getId());
String mobile = "";
StaffEntity staffCache = staffService.getCache(item.getCustomerId().toString());
List<StaffEntity> staffList = staffService.getCacheList();
List<StaffEntity> updateList = new ArrayList<>();
for (StaffEntity staffCache : staffList) {
if (!ObjectUtils.isEmpty(staffCache) && !ObjectUtils.isEmpty(staffCache.getPhoneNumber())) {
mobile = staffCache.getPhoneNumber();
if (ObjectUtils.isEmpty(item.getMobile())) {
userEntity.setMobile(mobile);
}
}
if (!ObjectUtils.isEmpty(mobile)) {
Rest<String> personByMobile = dingPersonService.getPersonByMobile(mobile);
String phoneNumber = staffCache.getPhoneNumber();
if (!ObjectUtils.isEmpty(phoneNumber)) {
Rest<String> personByMobile = dingPersonService.getPersonByMobile(phoneNumber);
if (!ObjectUtils.isEmpty(personByMobile) &&
YesNoEnum.YES.getValue() == personByMobile.getCode()
&& !ObjectUtils.isEmpty(personByMobile.getData())) {
userEntity.setDingUserId(personByMobile.getData());
StaffEntity updateStaff = new StaffEntity();
updateStaff.setId(staffCache.getId());
updateStaff.setDingUserId(personByMobile.getData());
updateList.add(updateStaff);
}
}
userEntity.setUpdateTime(new Date());
userEntity.setUpdateUserId(1L);
return userEntity;
}).filter(f -> !ObjectUtils.isEmpty(f.getDingUserId())).collect(Collectors.toList());
if (!ObjectUtils.isEmpty(updateUserList)) {
log.info("更新用户钉钉id信息数量:{}", updateUserList.size());
userService.getUserDao().updateBatch(updateUserList);
}
} catch (Exception e) {
log.error("同步钉钉usreId失败");
if (!ObjectUtils.isEmpty(updateList)) {
log.info("更新用户钉钉id信息数量:{}", updateList.size());
staffService.update(updateList);
}
}
}
private void syncDingDingLocalUserIds() {
try {
......
......@@ -93,8 +93,8 @@ public class AttendanceLeaveRecordServiceImpl extends AbstractCRUDServiceImpl<At
this.updateBefore(entity, context);
boolean doPerformAttend = true;
AttendanceLeaveRecordEntity temp = this.get(entity.getId());
if(temp!=null){
if(AppealResultEnum.通过.getValue() == temp.getAuditResult() && LeaveTypeEnum.事假.getValue() == temp.getLeaveType()){
if (temp != null) {
if (AppealResultEnum.通过.getValue() == temp.getAuditResult() && LeaveTypeEnum.事假.getValue() == temp.getLeaveType()) {
doPerformAttend = false;
}
}
......@@ -103,7 +103,7 @@ public class AttendanceLeaveRecordServiceImpl extends AbstractCRUDServiceImpl<At
throw new AppException(-1002, "更新失败!");
} else {
super.updateAfter(entity, context);
if(doPerformAttend) {
if (doPerformAttend) {
creatPerformAttend(entity, context);
}
doUpdateRecordAndSummary(entity, context);
......@@ -186,7 +186,7 @@ public class AttendanceLeaveRecordServiceImpl extends AbstractCRUDServiceImpl<At
}
}
log.info("请假通过后汇总考勤,请假人员:"+entity.getLeavePerson());
log.info("请假通过后汇总考勤,请假人员:" + entity.getLeavePerson());
AttendanceSummaryQuery query = new AttendanceSummaryQuery();
query.setSummaryTimeEnd(DateUtils.getStrDate(entity.getEndTime()));
query.setSummaryTimeStart(DateUtils.getStrDate(entity.getStartTime()));
......@@ -202,24 +202,21 @@ public class AttendanceLeaveRecordServiceImpl extends AbstractCRUDServiceImpl<At
public Rest<String> syncLeaveRecord(AttendanceLeaveRecordQuery query, Context context) {
List<AttendanceLeaveRecordEntity> waitSyncLeaveRecords = new ArrayList<>();
Long staffId = query.getStaffId();
List<UserEntity> userCacheList = userService.getCacheList();
List<StaffEntity> staffCacheList = staffService.getCacheList();
// List<UserEntity> userCacheList = userService.getCacheList();
if (ObjectUtils.isEmpty(staffId)) {
//同步所有用户
List<UserEntity> userEntityList = userCacheList.stream()
List<StaffEntity> userEntityList = staffCacheList.stream()
.filter(f -> !ObjectUtils.isEmpty(f.getDingUserId())).collect(Collectors.toList());
getLeaveRecordByUserList(query, userEntityList, waitSyncLeaveRecords);
} else {
//同步指定用户
List<UserEntity> userEntityList = userCacheList.stream()
List<StaffEntity> userEntityList = staffCacheList.stream()
.filter(f -> !ObjectUtils.isEmpty(f.getDingUserId()))
.filter(f -> staffId.equals(f.getCustomerId()))
.collect(Collectors.toList());
getLeaveRecordByUserList(query, userEntityList, waitSyncLeaveRecords);
}
log.info("待同步请假记录:{}", JSON.toJSONString(waitSyncLeaveRecords));
if (!ObjectUtils.isEmpty(waitSyncLeaveRecords)) {
for (AttendanceLeaveRecordEntity waitSyncLeaveRecord : waitSyncLeaveRecords) {
dingPersonService.handleByProcessInstanceId(waitSyncLeaveRecord.getRemark());
......@@ -228,11 +225,11 @@ public class AttendanceLeaveRecordServiceImpl extends AbstractCRUDServiceImpl<At
return Rest.ok();
}
private void getLeaveRecordByUserList(AttendanceLeaveRecordQuery query, List<UserEntity> userEntityList, List<AttendanceLeaveRecordEntity> waitSyncLeaveRecords) {
List<List<UserEntity>> partition = Lists.partition(userEntityList, 10);
for (List<UserEntity> userList : partition) {
private void getLeaveRecordByUserList(AttendanceLeaveRecordQuery query, List<StaffEntity> staffCacheList, List<AttendanceLeaveRecordEntity> waitSyncLeaveRecords) {
List<List<StaffEntity>> partition = Lists.partition(staffCacheList, 10);
for (List<StaffEntity> staffList : partition) {
//String dingUserId = item.getDingUserId();
List<String> dingUserIds = userList.stream().map(m -> m.getDingUserId()).collect(Collectors.toList());
List<String> dingUserIds = staffList.stream().map(m -> m.getDingUserId()).collect(Collectors.toList());
long startTime = DateUtil.parseDateTime(query.getStartTimeStart() + " 00:00:00").getTime();
long endTime = DateUtil.parseDateTime(query.getEndTimeEnd() + " 23:59:59").getTime();
Long nextToken = 0L;
......@@ -245,21 +242,6 @@ public class AttendanceLeaveRecordServiceImpl extends AbstractCRUDServiceImpl<At
}
}
}
/* for (UserEntity item : userEntityList) {
String dingUserId = item.getDingUserId();
long startTime = DateUtil.parseDateTime(query.getStartTimeStart() + " 00:00:00").getTime();
long endTime = DateUtil.parseDateTime(query.getEndTimeEnd() + " 23:59:59").getTime();
Long nextToken = 0L;
long maxResults = 20L;
for (ProcessInstanceEnum processInstanceEnum : ProcessInstanceEnum.values()) {
try {
getRecords(waitSyncLeaveRecords, item, processInstanceEnum, startTime, endTime, nextToken, maxResults, dingUserId);
} catch (Exception e) {
log.error("同步请假记录异常", e);
}
}
}*/
}
private void getRecords(List<AttendanceLeaveRecordEntity> waitSyncLeaveRecords, ProcessInstanceEnum processInstanceEnum, long startTime, long endTime, Long nextToken, long maxResults, List<String> dingUserIds) throws Exception {
......@@ -291,7 +273,7 @@ public class AttendanceLeaveRecordServiceImpl extends AbstractCRUDServiceImpl<At
String leaveKey = cacheService.get(LEAVE_REIDS_KEY + redisKey);
if (StringUtils.isEmpty(leaveKey)) {
cacheService.set(LEAVE_REIDS_KEY + redisKey, redisKey, 300); //五分钟内不会重复
PerformAttendRecordEntity recordEntity = conversionLeaveRecord(entity,multiple);
PerformAttendRecordEntity recordEntity = conversionLeaveRecord(entity, multiple);
recordEntity.setCreateTime(new Date());
recordEntity.setCreateUserId(1l);
recordEntity.setErrorTime(entity.getStartTime());
......@@ -314,7 +296,7 @@ public class AttendanceLeaveRecordServiceImpl extends AbstractCRUDServiceImpl<At
}
private PerformAttendRecordEntity conversionLeaveRecord(AttendanceLeaveRecordEntity entity,int multiple) {
private PerformAttendRecordEntity conversionLeaveRecord(AttendanceLeaveRecordEntity entity, int multiple) {
PerformAttendRecordEntity recordEntity = new PerformAttendRecordEntity();
recordEntity.initAttrValue();
StaffEntity staffEntity = staffService.get(entity.getLeavePersonId());
......@@ -333,10 +315,10 @@ public class AttendanceLeaveRecordServiceImpl extends AbstractCRUDServiceImpl<At
recordEntity.setAttendanceGroupName(groupStaffEntity.getGroupName());
}
String ruleCode = "ATTEND1009";
if(multiple%2>0){ //奇数,半天
if (multiple % 2 > 0) { //奇数,半天
ruleCode = "ATTEND1010";
}
if(multiple%2==0){ //偶数,全天
if (multiple % 2 == 0) { //偶数,全天
ruleCode = "ATTEND1011";
}
PerformRulesEntity performRulesEntity = performRulesService.selectOne(new PerformRulesQuery().ruleCode(ruleCode));
......@@ -346,15 +328,15 @@ public class AttendanceLeaveRecordServiceImpl extends AbstractCRUDServiceImpl<At
recordEntity.setCategoryId(performRulesEntity.getCategoryId());
recordEntity.setCategoryName(performRulesEntity.getCategoryName());
recordEntity.setSubAddType(performRulesEntity.getSubAddType());
if(ruleCode.equals("ATTEND1011")){
int m = multiple/2;
if (ruleCode.equals("ATTEND1011")) {
int m = multiple / 2;
recordEntity.setScore(performRulesEntity.getScore().multiply(new BigDecimal(m)));
}else {
} else {
recordEntity.setScore(performRulesEntity.getScore().multiply(new BigDecimal(multiple)));
}
recordEntity.setRemark(performRulesEntity.getContent());
} else {
throw new AppException("没有查询到请假扣分规则:"+ruleCode);
throw new AppException("没有查询到请假扣分规则:" + ruleCode);
}
recordEntity.setSubMethod(SubMethodEnum.系统自动.getValue());
recordEntity.setDeductPerson("系统管理员");
......@@ -362,10 +344,10 @@ public class AttendanceLeaveRecordServiceImpl extends AbstractCRUDServiceImpl<At
}
@Override
public void doCreatPerformAttend(Long id, Context context){
public void doCreatPerformAttend(Long id, Context context) {
AttendanceLeaveRecordEntity temp = this.get(id);
if(temp!=null){
if(AppealResultEnum.通过.getValue() == temp.getAuditResult() && LeaveTypeEnum.事假.getValue() == temp.getLeaveType()){
if (temp != null) {
if (AppealResultEnum.通过.getValue() == temp.getAuditResult() && LeaveTypeEnum.事假.getValue() == temp.getLeaveType()) {
creatPerformAttend(temp, context);
}
}
......
......@@ -8,8 +8,6 @@ import cn.hutool.core.date.DateUtil;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.mortals.framework.annotation.Excel;
import com.mortals.framework.annotation.desensitization.IdCardDesensitize;
import com.mortals.framework.annotation.desensitization.MobileDesensitize;
import com.mortals.framework.model.BaseEntityLong;
import com.mortals.xhx.module.staff.model.vo.StaffVo;
import lombok.Data;
......@@ -17,7 +15,7 @@ import lombok.Data;
* 员工基本信息实体对象
*
* @author zxfei
* @date 2024-01-11
* @date 2025-04-02
*/
@Data
public class StaffEntity extends StaffVo {
......@@ -26,12 +24,10 @@ public class StaffEntity extends StaffVo {
/**
* 员工姓名
*/
@Excel(name = "员工姓名")
private String name;
/**
* 性别(1.男,2.女)
*/
@Excel(name = "性别", readConverterExp = "1=男,2=女")
private Integer gender;
/**
* 出生日期
......@@ -44,19 +40,14 @@ public class StaffEntity extends StaffVo {
/**
* 联系电话
*/
@Excel(name = "联系电话")
@MobileDesensitize
private String phoneNumber;
/**
* 身份证号码
*/
@Excel(name = "身份证号码")
@IdCardDesensitize
private String idCard;
/**
* 工号
*/
@Excel(name = "工号")
private String workNum;
/**
* 政治面貌 (1.中共党员,2.中共预备党员,3.共青团员,4.群众,5.其它)
......@@ -69,7 +60,6 @@ public class StaffEntity extends StaffVo {
/**
* 所属部门名称
*/
@Excel(name = "所属部门名称")
private String deptName;
/**
* 职位ID
......@@ -78,22 +68,15 @@ public class StaffEntity extends StaffVo {
/**
* 职位名称
*/
@Excel(name = "职位名称")
private String positionName;
/**
* 员工类型(1.全职,2.兼职,3.实习)
*/
@Excel(name = "员工类型", readConverterExp = "1=全职,2=兼职,3=实习")
private Integer staffType;
/**
* 员工状态(1.正式,2.试用,3.离职)
*/
@Excel(name = "员工状态", readConverterExp = "1=正式,2=试用,3=离职")
private Integer status;
/**
* 员工来源(1.外部,2.内部)
*/
private Integer source;
/**
* 入职登记表
*/
......@@ -101,7 +84,6 @@ public class StaffEntity extends StaffVo {
/**
* 入职时间
*/
@Excel(name = "入职时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date entryDate;
/**
* 转正时间
......@@ -119,6 +101,10 @@ public class StaffEntity extends StaffVo {
* 备注
*/
private String remarkId;
/**
* 员工来源(1.外部,2.内部)
*/
private Integer source;
/**
* 相对图片pic
*/
......@@ -127,22 +113,6 @@ public class StaffEntity extends StaffVo {
* 图片资源唯一标识
*/
private String serverIndexCode;
/**
* 绩效分数
*/
private BigDecimal score;
/**
* 员工登录名
*/
private String loginName;
/**
* 员工登录密码
*/
private String loginPwd;
/**
* 最后登录时间
*/
private Date lastLoginTime;
/**
* 考勤授权(0.不启用,1.启用)
*/
......@@ -175,6 +145,26 @@ public class StaffEntity extends StaffVo {
* 所属大厅名称
*/
private String salaName;
/**
* 绩效分数
*/
private BigDecimal score;
/**
* 员工登录名
*/
private String loginName;
/**
* 员工登录密码
*/
private String loginPwd;
/**
* 最后登录时间
*/
private Date lastLoginTime;
/**
* 钉钉userId
*/
private String dingUserId;
@Override
public int hashCode() {
return this.getId().hashCode();
......@@ -206,19 +196,15 @@ public class StaffEntity extends StaffVo {
this.positionName = "";
this.staffType = 1;
this.status = 1;
this.source = 1;
this.registerPath = "";
this.entryDate = null;
this.regularDate = null;
this.leaveDate = null;
this.remark = "";
this.remarkId = "";
this.source = 1;
this.picUri = "";
this.serverIndexCode = "";
this.score = BigDecimal.ZERO;
this.loginName = "";
this.loginPwd = "";
this.lastLoginTime = null;
this.attendCheck = 1;
this.complainCheck = 1;
this.reviewCheck = 1;
......@@ -227,5 +213,10 @@ public class StaffEntity extends StaffVo {
this.otherCheck = 1;
this.salaId = null;
this.salaName = "";
this.score = BigDecimal.ZERO;
this.loginName = "";
this.loginPwd = "";
this.lastLoginTime = null;
this.dingUserId = "";
}
}
\ No newline at end of file
......@@ -143,7 +143,7 @@ Authorization: {{authToken}}
Content-Type: application/json
{
"staffId": 816,
"staffId": 349,
"startTimeStart": "2025-02-01",
"endTimeEnd": "2025-03-31"
}
......
......@@ -1376,3 +1376,9 @@ PRIMARY KEY (`id`)
,KEY `year` (`year`) USING BTREE
,KEY `deptName` (`deptName`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='窗口绩效汇总登记';
-- ----------------------------
-- 2025-04-02
-- ----------------------------
ALTER TABLE mortals_xhx_staff ADD COLUMN `dingUserId` varchar(128) COMMENT '钉钉userId';
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment