Commit 663e32af authored by 廖旭伟's avatar 廖旭伟

Merge remote-tracking branch 'origin/master'

parents f85d5b1a fad1753f
...@@ -443,6 +443,7 @@ export default { ...@@ -443,6 +443,7 @@ export default {
width: 100, width: 100,
show: true, show: true,
}, },
{ label: "大厅", prop: "salaName", show: true },
{ label: "部门", prop: "deptName", show: true }, { label: "部门", prop: "deptName", show: true },
{ {
label: "应到", label: "应到",
......
...@@ -71,6 +71,7 @@ ...@@ -71,6 +71,7 @@
<profiles.hik.appKey>25128371</profiles.hik.appKey> <profiles.hik.appKey>25128371</profiles.hik.appKey>
<profiles.hik.appSecret>2m9RcPJOKq5j2QPQM4v5</profiles.hik.appSecret> <profiles.hik.appSecret>2m9RcPJOKq5j2QPQM4v5</profiles.hik.appSecret>
<profiles.dingtalk.domain>https://oapi.dingtalk.com</profiles.dingtalk.domain> <profiles.dingtalk.domain>https://oapi.dingtalk.com</profiles.dingtalk.domain>
<profiles.dingtalk.oaScheme>https</profiles.dingtalk.oaScheme>
<profiles.dingtalk.oaUrl>api.dingtalk.com</profiles.dingtalk.oaUrl> <profiles.dingtalk.oaUrl>api.dingtalk.com</profiles.dingtalk.oaUrl>
<profiles.dingtalk.agentId>2652674890</profiles.dingtalk.agentId> <profiles.dingtalk.agentId>2652674890</profiles.dingtalk.agentId>
<profiles.dingtalk.appKey>dingpqzradgfr4efdi2j</profiles.dingtalk.appKey> <profiles.dingtalk.appKey>dingpqzradgfr4efdi2j</profiles.dingtalk.appKey>
...@@ -136,6 +137,7 @@ ...@@ -136,6 +137,7 @@
<profiles.hik.appSecret>2m9RcPJOKq5j2QPQM4v5</profiles.hik.appSecret> <profiles.hik.appSecret>2m9RcPJOKq5j2QPQM4v5</profiles.hik.appSecret>
<profiles.dingtalk.domain>http://172.15.28.113:8918</profiles.dingtalk.domain> <profiles.dingtalk.domain>http://172.15.28.113:8918</profiles.dingtalk.domain>
<profiles.dingtalk.oaScheme>http</profiles.dingtalk.oaScheme>
<profiles.dingtalk.oaUrl>172.15.28.113:8919</profiles.dingtalk.oaUrl> <profiles.dingtalk.oaUrl>172.15.28.113:8919</profiles.dingtalk.oaUrl>
<profiles.dingtalk.agentId>2652674890</profiles.dingtalk.agentId> <profiles.dingtalk.agentId>2652674890</profiles.dingtalk.agentId>
<profiles.dingtalk.appKey>dingpqzradgfr4efdi2j</profiles.dingtalk.appKey> <profiles.dingtalk.appKey>dingpqzradgfr4efdi2j</profiles.dingtalk.appKey>
......
package com.mortals.xhx.busiz.h5.web; package com.mortals.xhx.busiz.h5.web;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import cn.hutool.core.lang.Validator;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
...@@ -9,6 +10,7 @@ import com.mortals.framework.common.Rest; ...@@ -9,6 +10,7 @@ import com.mortals.framework.common.Rest;
import com.mortals.framework.exception.AppException; import com.mortals.framework.exception.AppException;
import com.mortals.xhx.busiz.h5.req.*; import com.mortals.xhx.busiz.h5.req.*;
import com.mortals.xhx.common.code.SubMethodEnum; import com.mortals.xhx.common.code.SubMethodEnum;
import com.mortals.xhx.common.code.YesNoEnum;
import com.mortals.xhx.module.perform.model.*; import com.mortals.xhx.module.perform.model.*;
import com.mortals.xhx.module.perform.service.*; import com.mortals.xhx.module.perform.service.*;
import com.mortals.xhx.module.staff.model.StaffEntity; import com.mortals.xhx.module.staff.model.StaffEntity;
...@@ -168,26 +170,34 @@ public class ApiWebPerformController extends AbstractBaseController<PerformReq> ...@@ -168,26 +170,34 @@ public class ApiWebPerformController extends AbstractBaseController<PerformReq>
@PostMapping("effect/save") @PostMapping("effect/save")
@UnAuth @UnAuth
public Rest<Void> effectSave(@RequestBody EffectSaveReq req) { public Rest<Void> effectSave(@RequestBody EffectSaveReq req) {
// log.info("web Api req==>{}", JSON.toJSONString(req));
// log.info("web Api req==>{}", JSON.toJSONString(req));
String busiDesc = "外部效能新增"; String busiDesc = "外部效能新增";
Rest rest = Rest.ok(busiDesc + "成功!"); Rest rest = Rest.ok(busiDesc + "成功!");
try { try {
//如果手机号码为空 将当前记录保存到临时表中,人工手动处理 boolean isMobile = Validator.isMobile(req.getPhone());
if (!isMobile) {
effectErrorSave(req);
rest = Rest.fail("手机号码不正确!");
}
if (ObjectUtils.isEmpty(req.getPhone())) { if (ObjectUtils.isEmpty(req.getPhone())) {
//保存异常数据 //保存异常数据/
effectErrorSave(req); effectErrorSave(req);
rest = Rest.fail("手机号码为空!"); rest = Rest.fail("手机号码为空!");
} else { }
if (ObjectUtils.isEmpty(req.getRuleCode())) { //如果手机号码为空 将当前记录保存到临时表中,人工手动处理
throw new AppException("绩效规则编码不能为空!");
} else { if (ObjectUtils.isEmpty(req.getRuleCode())) {
effect(req); //保存异常数据/
} effectErrorSave(req);
rest = Rest.fail("绩效规则编码不能为空!");
}
if (YesNoEnum.YES.getValue() == rest.getCode()) {
effect(req);
} }
//if (ObjectUtils.isEmpty(req.getPhone())) throw new AppException("手机号码不能为空!"); //if (ObjectUtils.isEmpty(req.getPhone())) throw new AppException("手机号码不能为空!");
//if (ObjectUtils.isEmpty(req.getRuleCode())) throw new AppException("绩效规则编码不能为空!"); //if (ObjectUtils.isEmpty(req.getRuleCode())) throw new AppException("绩效规则编码不能为空!");
// boolean bool = effect(req); // boolean bool = effect(req);
// if (bool) throw new AppException(busiDesc + "失败!"); // if (bool) throw new AppException(busiDesc + "失败!");
} catch (Exception e) { } catch (Exception e) {
log.error(busiDesc, e); log.error(busiDesc, e);
......
...@@ -258,7 +258,6 @@ public class InspectApiController extends AbstractBaseController<PerformReq> { ...@@ -258,7 +258,6 @@ public class InspectApiController extends AbstractBaseController<PerformReq> {
log.info("【{}】【请求体】--> {}", busiDesc, JSONObject.toJSONString(req)); log.info("【{}】【请求体】--> {}", busiDesc, JSONObject.toJSONString(req));
Rest<PerformAttendAppealEntity> rest = Rest.ok(busiDesc + " 【成功】"); Rest<PerformAttendAppealEntity> rest = Rest.ok(busiDesc + " 【成功】");
Context context = this.getContext(); Context context = this.getContext();
// req.setStaffId(context.getUser().getCustomerId());
try { try {
//根据状态 查询 当前是否已经存在正在进行的申诉 //根据状态 查询 当前是否已经存在正在进行的申诉
if (ObjectUtils.isEmpty(context) || ObjectUtils.isEmpty(context.getUser())) { if (ObjectUtils.isEmpty(context) || ObjectUtils.isEmpty(context.getUser())) {
......
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 ProcessInstanceEnum {
请假("PROC-2E5C0DFF-3615-4409-A614-A2011FED5D38", "请假"),
外出("PROC-56D3ADEE-45A4-47BC-931A-2A0DC067DE32", "外出"),
出差("PROC-578CBDDF-B768-496D-9918-44A3F1D9CAE7", "出差");
private String value;
private String desc;
ProcessInstanceEnum(String value, String desc) {
this.value = value;
this.desc = desc;
}
public String getValue() {
return this.value;
}
public String getDesc() {
return this.desc;
}
public static ProcessInstanceEnum getByValue(String value) {
for (ProcessInstanceEnum componentEnum : ProcessInstanceEnum.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 (ProcessInstanceEnum item : ProcessInstanceEnum.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
...@@ -53,16 +53,16 @@ public class AddAttendThread implements Runnable { ...@@ -53,16 +53,16 @@ public class AddAttendThread implements Runnable {
Long compare = DateUtil.between(attendEnd, attendStart, DateUnit.DAY); Long compare = DateUtil.between(attendEnd, attendStart, DateUnit.DAY);
StopWatch stopWatch = new StopWatch("stopwatch attend"); StopWatch stopWatch = new StopWatch("stopwatch attend");
log.info("考勤计算天数区间:{}", compare); log.info("考勤计算天数区间:{}", compare);
stopWatch.start("执行本地方法");
for (int i = 0; i <= compare.intValue(); i++) { for (int i = 0; i <= compare.intValue(); i++) {
DateTime curDate = DateUtil.offsetDay(attendStart, i); DateTime curDate = DateUtil.offsetDay(attendStart, i);
log.info("考勤计算日期:{}", curDate.toDateStr()); //log.info("考勤计算日期:{}", curDate.toDateStr());
stopWatch.start("执行本地方法");
hikEntity.setAttendanceDateStart(curDate.toDateStr()); hikEntity.setAttendanceDateStart(curDate.toDateStr());
hikEntity.setAttendanceDateEnd(curDate.toDateStr()); hikEntity.setAttendanceDateEnd(curDate.toDateStr());
hikService.addAttendanceRecordByQuery(hikEntity, context); hikService.addAttendanceRecordByQuery(hikEntity, context);
stopWatch.stop();
log.info("考勤计算日期:{} 完成,耗时:{}ms", curDate.toDateStr(), stopWatch.getLastTaskTimeMillis());
} }
stopWatch.stop();
log.info("完成,耗时:{}ms", stopWatch.getLastTaskTimeMillis());
//生成汇总信息 //生成汇总信息
log.info("生成考勤汇总消息开始。。。"); log.info("生成考勤汇总消息开始。。。");
AttendanceSummaryQuery query = new AttendanceSummaryQuery(); AttendanceSummaryQuery query = new AttendanceSummaryQuery();
......
...@@ -73,15 +73,15 @@ public class SyncUserTaskImpl implements ITaskExcuteService { ...@@ -73,15 +73,15 @@ public class SyncUserTaskImpl implements ITaskExcuteService {
UserEntity userEntity = new UserEntity(); UserEntity userEntity = new UserEntity();
userEntity.setId(item.getId()); userEntity.setId(item.getId());
String mobile = item.getMobile(); String mobile="";
if (ObjectUtils.isEmpty(mobile)) { StaffEntity staffCache = staffService.getCache(item.getCustomerId().toString());
//根据customerId查询staff 看是否有 if (!ObjectUtils.isEmpty(staffCache) && !ObjectUtils.isEmpty(staffCache.getPhoneNumber())) {
StaffEntity staffCache = staffService.getCache(item.getCustomerId().toString()); mobile = staffCache.getPhoneNumber();
if (!ObjectUtils.isEmpty(staffCache) && !ObjectUtils.isEmpty(staffCache.getPhoneNumber())) { if(ObjectUtils.isEmpty(item.getMobile())){
mobile = staffCache.getPhoneNumber();
userEntity.setMobile(mobile); userEntity.setMobile(mobile);
} }
} }
if (!ObjectUtils.isEmpty(mobile)) { if (!ObjectUtils.isEmpty(mobile)) {
Rest<String> personByMobile = dingPersonService.getPersonByMobile(mobile); Rest<String> personByMobile = dingPersonService.getPersonByMobile(mobile);
if (!ObjectUtils.isEmpty(personByMobile) && if (!ObjectUtils.isEmpty(personByMobile) &&
......
...@@ -33,4 +33,7 @@ public class AttendanceLeaveRecordVo extends BaseEntityLong { ...@@ -33,4 +33,7 @@ public class AttendanceLeaveRecordVo extends BaseEntityLong {
/** 结束 创建时间 */ /** 结束 创建时间 */
private String createTimeEnd; private String createTimeEnd;
private Long staffId;
} }
\ No newline at end of file
package com.mortals.xhx.module.attendance.service; package com.mortals.xhx.module.attendance.service;
import com.mortals.framework.common.Rest;
import com.mortals.framework.model.Context;
import com.mortals.framework.service.ICRUDService; import com.mortals.framework.service.ICRUDService;
import com.mortals.xhx.module.attendance.model.AttendanceLeaveRecordEntity; import com.mortals.xhx.module.attendance.model.AttendanceLeaveRecordEntity;
import com.mortals.xhx.module.attendance.model.AttendanceLeaveRecordQuery; import com.mortals.xhx.module.attendance.model.AttendanceLeaveRecordQuery;
import org.springframework.web.bind.annotation.RequestBody;
/** /**
* AttendanceLeaveRecordService * AttendanceLeaveRecordService
...@@ -15,4 +18,7 @@ public interface AttendanceLeaveRecordService extends ICRUDService<AttendanceLea ...@@ -15,4 +18,7 @@ public interface AttendanceLeaveRecordService extends ICRUDService<AttendanceLea
//根据remark(钉钉返回的id)查询对象 //根据remark(钉钉返回的id)查询对象
AttendanceLeaveRecordEntity doUpdateRecord(String processInstanceId,AttendanceLeaveRecordEntity leaveRecordEntity) throws Exception; AttendanceLeaveRecordEntity doUpdateRecord(String processInstanceId,AttendanceLeaveRecordEntity leaveRecordEntity) throws Exception;
Rest<String> syncLeaveRecord(AttendanceLeaveRecordQuery query, Context context);
} }
\ No newline at end of file
package com.mortals.xhx.module.attendance.service.impl; package com.mortals.xhx.module.attendance.service.impl;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSONObject;
import com.aliyun.dingtalkworkflow_1_0.models.ListProcessInstanceIdsResponse;
import com.aliyun.dingtalkworkflow_1_0.models.ListProcessInstanceIdsResponseBody;
import com.mortals.framework.common.Rest;
import com.mortals.framework.service.ICacheService; import com.mortals.framework.service.ICacheService;
import com.mortals.framework.util.DataUtil;
import com.mortals.framework.util.DateUtils; import com.mortals.framework.util.DateUtils;
import com.mortals.framework.util.ThreadPool; import com.mortals.framework.util.ThreadPool;
import com.mortals.xhx.base.system.user.model.UserEntity;
import com.mortals.xhx.base.system.user.service.UserService;
import com.mortals.xhx.common.code.AppealResultEnum; import com.mortals.xhx.common.code.AppealResultEnum;
import com.mortals.xhx.common.code.AuditStatusEnum; import com.mortals.xhx.common.code.AuditStatusEnum;
import com.mortals.xhx.common.code.ProcessInstanceEnum;
import com.mortals.xhx.common.code.YesNoEnum;
import com.mortals.xhx.common.utils.AddAttendThread; import com.mortals.xhx.common.utils.AddAttendThread;
import com.mortals.xhx.common.utils.AttendSummaryThread; import com.mortals.xhx.common.utils.AttendSummaryThread;
import com.mortals.xhx.module.attendance.model.AttendanceLeaveRecordQuery; import com.mortals.xhx.module.attendance.model.AttendanceLeaveRecordQuery;
...@@ -14,6 +23,8 @@ import com.mortals.xhx.module.attendance.model.AttendanceRecordHikQuery; ...@@ -14,6 +23,8 @@ import com.mortals.xhx.module.attendance.model.AttendanceRecordHikQuery;
import com.mortals.xhx.module.attendance.model.vo.AttendanceSummaryQuery; import com.mortals.xhx.module.attendance.model.vo.AttendanceSummaryQuery;
import com.mortals.xhx.module.attendance.service.AttendanceRecordHikService; import com.mortals.xhx.module.attendance.service.AttendanceRecordHikService;
import com.mortals.xhx.module.attendance.service.AttendanceStatService; import com.mortals.xhx.module.attendance.service.AttendanceStatService;
import com.mortals.xhx.module.dingding.personal.service.IDingPersonService;
import com.mortals.xhx.module.staff.service.StaffService;
import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -24,7 +35,11 @@ import com.mortals.xhx.module.attendance.dao.AttendanceLeaveRecordDao; ...@@ -24,7 +35,11 @@ import com.mortals.xhx.module.attendance.dao.AttendanceLeaveRecordDao;
import com.mortals.xhx.module.attendance.model.AttendanceLeaveRecordEntity; import com.mortals.xhx.module.attendance.model.AttendanceLeaveRecordEntity;
import com.mortals.xhx.module.attendance.service.AttendanceLeaveRecordService; import com.mortals.xhx.module.attendance.service.AttendanceLeaveRecordService;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date; import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
import static com.mortals.xhx.common.key.RedisKey.KEY_ATTENDANCE_STAT_CACHE; import static com.mortals.xhx.common.key.RedisKey.KEY_ATTENDANCE_STAT_CACHE;
...@@ -42,9 +57,14 @@ public class AttendanceLeaveRecordServiceImpl extends AbstractCRUDServiceImpl<At ...@@ -42,9 +57,14 @@ public class AttendanceLeaveRecordServiceImpl extends AbstractCRUDServiceImpl<At
private AttendanceStatService attendanceStatService; private AttendanceStatService attendanceStatService;
@Autowired @Autowired
private ICacheService cacheService; private ICacheService cacheService;
@Autowired
private StaffService staffService;
@Autowired
private UserService userService;
@Autowired @Autowired
private AttendanceRecordHikService hikService; private AttendanceRecordHikService hikService;
@Autowired
private IDingPersonService dingPersonService;
@Override @Override
protected void updateAfter(AttendanceLeaveRecordEntity entity, Context context) throws AppException { protected void updateAfter(AttendanceLeaveRecordEntity entity, Context context) throws AppException {
...@@ -91,6 +111,7 @@ public class AttendanceLeaveRecordServiceImpl extends AbstractCRUDServiceImpl<At ...@@ -91,6 +111,7 @@ public class AttendanceLeaveRecordServiceImpl extends AbstractCRUDServiceImpl<At
/** /**
* 更新汇总信息 * 更新汇总信息
*
* @param entity * @param entity
* @param context * @param context
*/ */
...@@ -102,16 +123,16 @@ public class AttendanceLeaveRecordServiceImpl extends AbstractCRUDServiceImpl<At ...@@ -102,16 +123,16 @@ public class AttendanceLeaveRecordServiceImpl extends AbstractCRUDServiceImpl<At
return; return;
} }
//更新考勤记录与异常记录 //更新考勤记录与异常记录
if (AppealResultEnum.通过.getValue() == entity.getAuditResult()||AppealResultEnum.撤销审批通过.getValue() == entity.getAuditResult()) { if (AppealResultEnum.通过.getValue() == entity.getAuditResult() || AppealResultEnum.撤销审批通过.getValue() == entity.getAuditResult()) {
AttendanceRecordHikQuery attendanceRecordHikQuery = new AttendanceRecordHikQuery(); AttendanceRecordHikQuery attendanceRecordHikQuery = new AttendanceRecordHikQuery();
attendanceRecordHikQuery.setStaffId(entity.getLeavePersonId()); attendanceRecordHikQuery.setStaffId(entity.getLeavePersonId());
//判断请假的开始日期与结束日期 //判断请假的开始日期与结束日期
boolean in = DateUtil.isIn(new Date(), entity.getEndTime(), new Date()); boolean in = DateUtil.isIn(new Date(), entity.getStartTime(),entity.getEndTime());
if (in) { if (in) {
//当前日期在请假期间,计算考勤结束时间为当前时间; //当前日期在请假期间,计算考勤结束时间为当前时间;
attendanceRecordHikQuery.setAttendanceDateStart(DateUtil.formatDate(entity.getStartTime())); attendanceRecordHikQuery.setAttendanceDateStart(DateUtil.formatDate(entity.getStartTime()));
attendanceRecordHikQuery.setAttendanceDateEnd(DateUtil.today()); attendanceRecordHikQuery.setAttendanceDateEnd(DateUtil.today());
}else{ } else {
attendanceRecordHikQuery.setAttendanceDateStart(DateUtil.formatDate(entity.getStartTime())); attendanceRecordHikQuery.setAttendanceDateStart(DateUtil.formatDate(entity.getStartTime()));
attendanceRecordHikQuery.setAttendanceDateEnd(DateUtil.formatDate(entity.getEndTime())); attendanceRecordHikQuery.setAttendanceDateEnd(DateUtil.formatDate(entity.getEndTime()));
} }
...@@ -119,4 +140,68 @@ public class AttendanceLeaveRecordServiceImpl extends AbstractCRUDServiceImpl<At ...@@ -119,4 +140,68 @@ public class AttendanceLeaveRecordServiceImpl extends AbstractCRUDServiceImpl<At
ThreadPool.getInstance().execute(addAttendThread); ThreadPool.getInstance().execute(addAttendThread);
} }
} }
@Override
public Rest<String> syncLeaveRecord(AttendanceLeaveRecordQuery query, Context context) {
List<AttendanceLeaveRecordEntity> waitSyncLeaveRecords = new ArrayList<>();
Long staffId = query.getStaffId();
List<UserEntity> userCacheList = userService.getCacheList();
if (ObjectUtils.isEmpty(staffId)) {
//同步所有用户
List<UserEntity> userEntityList = userCacheList.stream()
.filter(f -> !ObjectUtils.isEmpty(f.getDingUserId())).collect(Collectors.toList());
getLeaveRecordByUserList(query, userEntityList, waitSyncLeaveRecords);
} else {
//同步指定用户
List<UserEntity> userEntityList = userCacheList.stream()
.filter(f -> !ObjectUtils.isEmpty(f.getDingUserId()))
.filter(f -> staffId == f.getCustomerId())
.collect(Collectors.toList());
getLeaveRecordByUserList(query, userEntityList, waitSyncLeaveRecords);
}
if (!ObjectUtils.isEmpty(waitSyncLeaveRecords)) {
for (AttendanceLeaveRecordEntity waitSyncLeaveRecord : waitSyncLeaveRecords) {
dingPersonService.handleByProcessInstanceId(waitSyncLeaveRecord.getRemark());
}
}
return Rest.ok();
}
private void getLeaveRecordByUserList(AttendanceLeaveRecordQuery query, List<UserEntity> userEntityList, List<AttendanceLeaveRecordEntity> waitSyncLeaveRecords) {
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, UserEntity item, ProcessInstanceEnum processInstanceEnum, long startTime, long endTime, Long nextToken, long maxResults, String dingUserId) throws Exception {
Rest<ListProcessInstanceIdsResponseBody.ListProcessInstanceIdsResponseBodyResult> rest = dingPersonService.getProcessInstanceIdByUserIds(processInstanceEnum.getValue(), startTime, endTime, nextToken, maxResults, dingUserId);
if (YesNoEnum.YES.getValue() == rest.getCode()) {
if (ObjectUtils.isEmpty(rest.getData().getNextToken())) {
List<String> processInstanceList = rest.getData().getList();
for (String process : processInstanceList) {
AttendanceLeaveRecordEntity leaveRecord = new AttendanceLeaveRecordEntity();
leaveRecord.setRemark(process);
leaveRecord.setStaffId(item.getCustomerId());
waitSyncLeaveRecords.add(leaveRecord);
}
} else {
nextToken = DataUtil.converStr2Long(rest.getData().getNextToken(), 0L);
getRecords(waitSyncLeaveRecords, item, processInstanceEnum, startTime, endTime, nextToken, maxResults, dingUserId);
}
}
}
} }
\ No newline at end of file
package com.mortals.xhx.module.attendance.web; package com.mortals.xhx.module.attendance.web;
import cn.hutool.core.date.DateUnit;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.io.unit.DataUnit;
import com.alibaba.fastjson.JSONObject;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context; import com.mortals.framework.model.Context;
import com.mortals.framework.util.DateUtils;
import com.mortals.framework.util.ThreadPool;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController; import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.base.system.param.service.ParamService; import com.mortals.xhx.base.system.param.service.ParamService;
import com.mortals.xhx.base.system.user.model.UserQuery; import com.mortals.xhx.base.system.user.model.UserQuery;
...@@ -9,12 +17,16 @@ import com.mortals.xhx.common.code.ProcessStatusEnum; ...@@ -9,12 +17,16 @@ import com.mortals.xhx.common.code.ProcessStatusEnum;
import com.mortals.xhx.common.pdu.user.UserPdu; import com.mortals.xhx.common.pdu.user.UserPdu;
import com.mortals.xhx.feign.user.IUserFeign; import com.mortals.xhx.feign.user.IUserFeign;
import com.mortals.xhx.module.attendance.model.AttendanceLeaveRecordEntity; import com.mortals.xhx.module.attendance.model.AttendanceLeaveRecordEntity;
import com.mortals.xhx.module.attendance.model.AttendanceLeaveRecordQuery;
import com.mortals.xhx.module.attendance.service.AttendanceLeaveRecordService; import com.mortals.xhx.module.attendance.service.AttendanceLeaveRecordService;
import com.mortals.xhx.module.dept.model.DeptQuery; import com.mortals.xhx.module.dept.model.DeptQuery;
import com.mortals.xhx.module.dept.service.DeptService; import com.mortals.xhx.module.dept.service.DeptService;
import com.mortals.xhx.module.workman.model.WorkmanQuery; import com.mortals.xhx.module.workman.model.WorkmanQuery;
import com.mortals.xhx.module.workman.service.WorkmanService; import com.mortals.xhx.module.workman.service.WorkmanService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
...@@ -27,15 +39,14 @@ import java.util.stream.Collectors; ...@@ -27,15 +39,14 @@ import java.util.stream.Collectors;
import static java.util.stream.Collectors.toMap; import static java.util.stream.Collectors.toMap;
/** /**
* * 请假记录信息
* 请假记录信息 *
* * @author zxfei
* @author zxfei * @date 2023-04-07
* @date 2023-04-07 */
*/
@RestController @RestController
@RequestMapping("attendance/leave/record") @RequestMapping("attendance/leave/record")
public class AttendanceLeaveRecordController extends BaseCRUDJsonBodyMappingController<AttendanceLeaveRecordService,AttendanceLeaveRecordEntity,Long> { public class AttendanceLeaveRecordController extends BaseCRUDJsonBodyMappingController<AttendanceLeaveRecordService, AttendanceLeaveRecordEntity, Long> {
@Autowired @Autowired
private ParamService paramService; private ParamService paramService;
...@@ -48,15 +59,15 @@ public class AttendanceLeaveRecordController extends BaseCRUDJsonBodyMappingCont ...@@ -48,15 +59,15 @@ public class AttendanceLeaveRecordController extends BaseCRUDJsonBodyMappingCont
// @Autowired // @Autowired
// private IUserFeign iUserFeign; // private IUserFeign iUserFeign;
public AttendanceLeaveRecordController(){ public AttendanceLeaveRecordController() {
super.setModuleDesc( "请假记录信息"); super.setModuleDesc("请假记录信息");
} }
@Override @Override
protected void init(Map<String, Object> model, Context context) { protected void init(Map<String, Object> model, Context context) {
this.addDict(model, "deptId", deptService.find(new DeptQuery()).stream().collect(toMap(x->x.getId().toString(), y->y.getDeptName(),(o, n)->n))); this.addDict(model, "deptId", deptService.find(new DeptQuery()).stream().collect(toMap(x -> x.getId().toString(), y -> y.getDeptName(), (o, n) -> n)));
this.addDict(model, "approverId", workmanService.find(new WorkmanQuery()).stream().collect(toMap(x->x.getId().toString(), y->y.getName(),(o, n)->n))); this.addDict(model, "approverId", workmanService.find(new WorkmanQuery()).stream().collect(toMap(x -> x.getId().toString(), y -> y.getName(), (o, n) -> n)));
this.addDict(model, "leaveType", paramService.getParamBySecondOrganize("AttendanceLeaveRecord","leaveType")); this.addDict(model, "leaveType", paramService.getParamBySecondOrganize("AttendanceLeaveRecord", "leaveType"));
this.addDict(model, "auditResult", AppealResultEnum.getEnumMap()); this.addDict(model, "auditResult", AppealResultEnum.getEnumMap());
this.addDict(model, "processStatus", ProcessStatusEnum.getEnumMap()); this.addDict(model, "processStatus", ProcessStatusEnum.getEnumMap());
this.addDict(model, "createUserId", userService.find(new UserQuery()).stream().collect(toMap(x -> x.getId().toString(), y -> y.getRealName(), (o, n) -> n))); this.addDict(model, "createUserId", userService.find(new UserQuery()).stream().collect(toMap(x -> x.getId().toString(), y -> y.getRealName(), (o, n) -> n)));
...@@ -79,4 +90,39 @@ public class AttendanceLeaveRecordController extends BaseCRUDJsonBodyMappingCont ...@@ -79,4 +90,39 @@ public class AttendanceLeaveRecordController extends BaseCRUDJsonBodyMappingCont
} }
/**
* 主动同步拉取请假考勤记录
*/
@PostMapping(value = "syncLeaveRecord")
public String syncLeaveRecord(@RequestBody AttendanceLeaveRecordQuery query) {
JSONObject jsonObject = new JSONObject();
String busiDesc = this.getModuleDesc() + "主动同步拉取请假考勤记录";
try {
if (ObjectUtils.isEmpty(query.getStartTimeStart())) throw new AppException("开始时间不能为空");
if (ObjectUtils.isEmpty(query.getEndTimeEnd())) {
query.setEndTimeStart(DateUtil.today());
}
long between = DateUtil.between(DateUtil.parseDate(query.getStartTimeStart()), DateUtil.parseDate(query.getEndTimeEnd()), DateUnit.DAY, true);
if (between > 120) throw new AppException("时间范围不能超过120天");
Context context = this.getContext();
Thread thread = new Thread(new Runnable() {
@Override
public void run() {
service.syncLeaveRecord(query, context);
}
});
ThreadPool.getInstance().execute(thread);
recordSysLog(request, busiDesc + " 【成功】");
jsonObject.put(KEY_RESULT_CODE, VALUE_RESULT_SUCCESS);
jsonObject.put(KEY_RESULT_MSG, busiDesc + " 【成功】");
} catch (Exception e) {
log.error("主动同步拉取请假考勤记录", e);
jsonObject.put(KEY_RESULT_CODE, VALUE_RESULT_FAILURE);
jsonObject.put(KEY_RESULT_MSG, super.convertException(e));
}
return jsonObject.toJSONString();
}
} }
\ No newline at end of file
...@@ -52,6 +52,13 @@ public abstract class AbstractDingTalkService implements IDingPersonService { ...@@ -52,6 +52,13 @@ public abstract class AbstractDingTalkService implements IDingPersonService {
@Value("${dingtalk.AppSecret:''}") @Value("${dingtalk.AppSecret:''}")
protected String appSecret; protected String appSecret;
/**
* oaurl
*/
@Value("${dingtalk.oaScheme:http}")
protected String oaScheme;
/** /**
* oaurl * oaurl
*/ */
......
...@@ -4,6 +4,7 @@ package com.mortals.xhx.module.dingding.personal.service; ...@@ -4,6 +4,7 @@ package com.mortals.xhx.module.dingding.personal.service;
import com.aliyun.dingtalkattendance_1_0.models.GetLeaveRecordsResponseBody; import com.aliyun.dingtalkattendance_1_0.models.GetLeaveRecordsResponseBody;
import com.aliyun.dingtalkworkflow_1_0.models.GetProcessInstanceResponseBody; import com.aliyun.dingtalkworkflow_1_0.models.GetProcessInstanceResponseBody;
import com.aliyun.dingtalkworkflow_1_0.models.ListProcessInstanceIdsResponse; import com.aliyun.dingtalkworkflow_1_0.models.ListProcessInstanceIdsResponse;
import com.aliyun.dingtalkworkflow_1_0.models.ListProcessInstanceIdsResponseBody;
import com.dingtalk.api.response.OapiAttendanceVacationQuotaListResponse; import com.dingtalk.api.response.OapiAttendanceVacationQuotaListResponse;
import com.dingtalk.api.response.OapiV2UserGetResponse; import com.dingtalk.api.response.OapiV2UserGetResponse;
import com.mortals.framework.common.Rest; import com.mortals.framework.common.Rest;
...@@ -88,6 +89,8 @@ public interface IDingPersonService extends IDingTalkService { ...@@ -88,6 +89,8 @@ public interface IDingPersonService extends IDingTalkService {
* @param maxResults 分页参数,每页大小,最多传20。 * @param maxResults 分页参数,每页大小,最多传20。
* @param userIds 发起人id列表 最大列表长度为10 * @param userIds 发起人id列表 最大列表长度为10
*/ */
Rest<ListProcessInstanceIdsResponse> getProcessInstanceIdByUserIds(String processCode,long startTime,long endTime,long nextToken,long maxResults,String userIds) throws Exception; Rest<ListProcessInstanceIdsResponseBody.ListProcessInstanceIdsResponseBodyResult> getProcessInstanceIdByUserIds(String processCode, long startTime, long endTime, Long nextToken, long maxResults, String userIds) throws Exception;
} }
...@@ -74,6 +74,7 @@ dingtalk: ...@@ -74,6 +74,7 @@ dingtalk:
AppSecret: @profiles.dingtalk.appSecret@ AppSecret: @profiles.dingtalk.appSecret@
AesKey: @profiles.dingtalk.aesKey@ AesKey: @profiles.dingtalk.aesKey@
token: @profiles.dingtalk.token@ token: @profiles.dingtalk.token@
oaScheme: @profiles.dingtalk.oaScheme@
oaUrl: @profiles.dingtalk.oaUrl@ oaUrl: @profiles.dingtalk.oaUrl@
opUserId: @profiles.dingtalk.opUserId@ opUserId: @profiles.dingtalk.opUserId@
...@@ -82,7 +82,7 @@ POST {{baseUrl}}//attendance/stat/summary ...@@ -82,7 +82,7 @@ POST {{baseUrl}}//attendance/stat/summary
Authorization: {{authToken}} Authorization: {{authToken}}
Content-Type: application/json Content-Type: application/json
{"summaryTimeStart":"2023-12-01","summaryTimeEnd":"2023-12-31"} {"summaryTimeStart":"2024-01-01","summaryTimeEnd":"2024-12-30"}
###短信设置编辑 ###短信设置编辑
...@@ -101,10 +101,17 @@ GET {{baseUrl}}/test/double?processInstanceId=test1 ...@@ -101,10 +101,17 @@ GET {{baseUrl}}/test/double?processInstanceId=test1
Accept: application/json Accept: application/json
###短信设置删除
GET {{baseUrl}}/att/set/delete?id={{SmsSet_id}}
Accept: application/json
###钉钉请假
POST {{baseUrl}}/attendance/leave/record/syncLeaveRecord
Authorization: {{authToken}}
Content-Type: application/json
{
"startTimeStart":"2023-10-01",
"endTimeEnd":"2023-10-10"
}
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