Commit 2b9f34ca authored by 赵啸非's avatar 赵啸非

添加钉钉对接流程代码

parent 1a468742
...@@ -164,8 +164,8 @@ ...@@ -164,8 +164,8 @@
<profiles.sms.smsSendUrl>http://sms.wx3.com.cn/api/index/index</profiles.sms.smsSendUrl> <profiles.sms.smsSendUrl>http://sms.wx3.com.cn/api/index/index</profiles.sms.smsSendUrl>
<profiles.sms.apiId>ADsUXLrS81vZDU95</profiles.sms.apiId> <profiles.sms.apiId>ADsUXLrS81vZDU95</profiles.sms.apiId>
<profiles.dingtalk.domain>https://oapi.dingtalk.com</profiles.dingtalk.domain> <profiles.dingtalk.domain>https://oapi.dingtalk.com</profiles.dingtalk.domain>
<profiles.dingtalk.oaScheme>http</profiles.dingtalk.oaScheme> <profiles.dingtalk.oaScheme>https</profiles.dingtalk.oaScheme>
<profiles.dingtalk.oaUrl>https://oapi.dingtalk.com</profiles.dingtalk.oaUrl> <profiles.dingtalk.oaUrl>oapi.dingtalk.com</profiles.dingtalk.oaUrl>
<profiles.dingtalk.agentId>2652674890</profiles.dingtalk.agentId> <profiles.dingtalk.agentId>2652674890</profiles.dingtalk.agentId>
<profiles.dingtalk.appKey>dingvbzaw1176pbzo1zx</profiles.dingtalk.appKey> <profiles.dingtalk.appKey>dingvbzaw1176pbzo1zx</profiles.dingtalk.appKey>
<profiles.dingtalk.appSecret>jmKqKPDLR3BxdZT_QNX4pm6zDdtbaLI3PtsFymQ6tUle-uKUgmxtr_a6ys3b8v3Y</profiles.dingtalk.appSecret> <profiles.dingtalk.appSecret>jmKqKPDLR3BxdZT_QNX4pm6zDdtbaLI3PtsFymQ6tUle-uKUgmxtr_a6ys3b8v3Y</profiles.dingtalk.appSecret>
......
package com.mortals.xhx.daemon.applicationservice; package com.mortals.xhx.daemon.applicationservice;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUnit;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
...@@ -9,6 +11,7 @@ import com.mortals.framework.common.Rest; ...@@ -9,6 +11,7 @@ import com.mortals.framework.common.Rest;
import com.mortals.framework.model.PageInfo; import com.mortals.framework.model.PageInfo;
import com.mortals.framework.springcloud.service.IApplicationStartedService; import com.mortals.framework.springcloud.service.IApplicationStartedService;
import com.mortals.framework.util.DataUtil; import com.mortals.framework.util.DataUtil;
import com.mortals.framework.util.ThreadPool;
import com.mortals.xhx.base.system.user.service.UserService; import com.mortals.xhx.base.system.user.service.UserService;
import com.mortals.xhx.common.code.AttendSourceTypeEnum; import com.mortals.xhx.common.code.AttendSourceTypeEnum;
import com.mortals.xhx.common.code.AttendanceTypeEnum; import com.mortals.xhx.common.code.AttendanceTypeEnum;
...@@ -69,16 +72,53 @@ public class StartedService implements IApplicationStartedService { ...@@ -69,16 +72,53 @@ public class StartedService implements IApplicationStartedService {
private AttendanceClassService attendanceClassService; private AttendanceClassService attendanceClassService;
@Autowired @Autowired
private AttendanceClassDetailService attendanceClassDetailService; private AttendanceClassDetailService attendanceClassDetailService;
@Autowired
private AttendanceLeaveRecordService attendanceLeaveRecordService;
private void checkDingDingEvent(DateTime attendStart, DateTime attendEnd, AttendanceRecordHikQuery hikEntity) {
log.info("开始同步钉钉请假事件!");
long between = DateUtil.between(attendStart, attendEnd, DateUnit.DAY, true);
AttendanceLeaveRecordQuery query = new AttendanceLeaveRecordQuery();
query.setStartTimeStart(hikEntity.getAttendanceDateStart());
query.setEndTimeEnd(hikEntity.getAttendanceDateEnd());
// if (between > 120) return;
new Thread(()->{
attendanceLeaveRecordService.syncLeaveRecord(query, null);
}).start();
/* Runnable runnable = new Runnable() {
@Override
public void run() {
attendanceLeaveRecordService.syncLeaveRecord(query, null);
}
};
ThreadPool.getInstance().execute(runnable);*/
}
@Override @Override
public void start() { public void start() {
log.info("开始服务..[配置已加载完成,并且所有框架都已经初始化]"); log.info("开始服务..[配置已加载完成,并且所有框架都已经初始化]");
//deptService.syncDeptByDingTalk(null);
//staffService.syncPersonsByDingTalk(null);
/* String attendStart = "2025-02-01 00:00:00";
groupService.syncGroupByDingTalk(); String attendEnd = "2025-02-26 23:59:59";
AttendanceRecordHikQuery hikQuery = new AttendanceRecordHikQuery();
hikQuery.setAttendanceDateStart(attendStart);
hikQuery.setAttendanceDateEnd(attendEnd);
checkDingDingEvent(DateUtil.parseDateTime(attendStart), DateUtil.parseDateTime(attendEnd), hikQuery);
*/
// groupService.syncGroupByDingTalk();
//获取排班信息 //获取排班信息
/* Rest<List<OapiAttendanceShiftListResponse.TopMinimalismShiftVo>> rest = dingAttenanceService.getShiftList(0L); /* Rest<List<OapiAttendanceShiftListResponse.TopMinimalismShiftVo>> rest = dingAttenanceService.getShiftList(0L);
......
...@@ -66,6 +66,27 @@ public class SyncUserTaskImpl implements ITaskExcuteService { ...@@ -66,6 +66,27 @@ public class SyncUserTaskImpl implements ITaskExcuteService {
log.info("同步用户"); log.info("同步用户");
staffService.syncPersons(null); staffService.syncPersons(null);
log.info("同步钉钉usreId"); log.info("同步钉钉usreId");
syncDingDingUserIds();
} else if (AttendSourceTypeEnum.海康考勤机.getValue().equals(sourceType)) {
log.info("设备直连同步人员信息");
staffService.syncPersonsByDevices(null);
} else if (AttendSourceTypeEnum.钉钉.getValue().equals(sourceType)) {
//钉钉
log.info("同步钉钉部门");
deptService.syncDeptByDingTalk(null);
//同步钉钉人员
staffService.syncPersonsByDingTalk(null);
log.info("同步钉钉usreId");
syncDingDingLocalUserIds();
log.info("钉钉直连同步人员信息");
} else {
log.info("未配置考勤源类型!");
}
}
private void syncDingDingUserIds() {
try { try {
List<UserEntity> userList = userService.getCacheList().stream() List<UserEntity> userList = userService.getCacheList().stream()
.filter(f -> !ObjectUtils.isEmpty(f.getCustomerId())) .filter(f -> !ObjectUtils.isEmpty(f.getCustomerId()))
...@@ -104,29 +125,10 @@ public class SyncUserTaskImpl implements ITaskExcuteService { ...@@ -104,29 +125,10 @@ public class SyncUserTaskImpl implements ITaskExcuteService {
} catch (Exception e) { } catch (Exception e) {
log.error("同步钉钉usreId失败"); log.error("同步钉钉usreId失败");
} }
} else if (AttendSourceTypeEnum.海康考勤机.getValue().equals(sourceType)) {
log.info("设备直连同步人员信息");
staffService.syncPersonsByDevices(null);
} else if (AttendSourceTypeEnum.钉钉.getValue().equals(sourceType)) {
//钉钉
log.info("同步钉钉部门");
deptService.syncDeptByDingTalk(null);
//同步钉钉人员
staffService.syncPersonsByDingTalk(null);
log.info("钉钉直连同步人员信息");
} else {
log.info("未配置考勤源类型!");
} }
/*
try {
if (!ObjectUtils.isEmpty(hikhost)) { private void syncDingDingLocalUserIds() {
log.info("同步部门");
deptService.syncDept(null);
log.info("同步用户");
staffService.syncPersons(null);
log.info("同步钉钉usreId");
try { try {
List<UserEntity> userList = userService.getCacheList().stream() List<UserEntity> userList = userService.getCacheList().stream()
.filter(f -> !ObjectUtils.isEmpty(f.getCustomerId())) .filter(f -> !ObjectUtils.isEmpty(f.getCustomerId()))
...@@ -135,22 +137,10 @@ public class SyncUserTaskImpl implements ITaskExcuteService { ...@@ -135,22 +137,10 @@ public class SyncUserTaskImpl implements ITaskExcuteService {
UserEntity userEntity = new UserEntity(); UserEntity userEntity = new UserEntity();
userEntity.setId(item.getId()); userEntity.setId(item.getId());
String mobile = "";
StaffEntity staffCache = staffService.getCache(item.getCustomerId().toString()); StaffEntity staffCache = staffService.getCache(item.getCustomerId().toString());
if (!ObjectUtils.isEmpty(staffCache) && !ObjectUtils.isEmpty(staffCache.getPhoneNumber())) {
mobile = staffCache.getPhoneNumber();
if (ObjectUtils.isEmpty(item.getMobile())) {
userEntity.setMobile(mobile);
}
}
if (!ObjectUtils.isEmpty(mobile)) { if (!ObjectUtils.isEmpty(staffCache) ) {
Rest<String> personByMobile = dingPersonService.getPersonByMobile(mobile); userEntity.setDingUserId(staffCache.getWorkNum());
if (!ObjectUtils.isEmpty(personByMobile) &&
YesNoEnum.YES.getValue() == personByMobile.getCode()
&& !ObjectUtils.isEmpty(personByMobile.getData())) {
userEntity.setDingUserId(personByMobile.getData());
}
} }
userEntity.setUpdateTime(new Date()); userEntity.setUpdateTime(new Date());
...@@ -165,13 +155,6 @@ public class SyncUserTaskImpl implements ITaskExcuteService { ...@@ -165,13 +155,6 @@ public class SyncUserTaskImpl implements ITaskExcuteService {
} catch (Exception e) { } catch (Exception e) {
log.error("同步钉钉usreId失败"); log.error("同步钉钉usreId失败");
} }
} else {
log.info("设备直连同步人员信息");
staffService.syncPersonsByDevices(null);
}
} catch (Exception e) {
log.error("同步人事异常", e);
}*/
} }
@Override @Override
......
...@@ -106,7 +106,6 @@ public class AttendanceGroupServiceImpl extends AbstractCRUDServiceImpl<Attendan ...@@ -106,7 +106,6 @@ public class AttendanceGroupServiceImpl extends AbstractCRUDServiceImpl<Attendan
String groupName = group.getGroupName(); String groupName = group.getGroupName();
Long memberCount = group.getMemberCount(); Long memberCount = group.getMemberCount();
String type = group.getType(); String type = group.getType();
AttendanceGroupQuery groupQuery = new AttendanceGroupQuery(); AttendanceGroupQuery groupQuery = new AttendanceGroupQuery();
groupQuery.setRemark(groupId.toString()); groupQuery.setRemark(groupId.toString());
AttendanceGroupEntity attendanceGroupEntity = this.selectOne(groupQuery); AttendanceGroupEntity attendanceGroupEntity = this.selectOne(groupQuery);
...@@ -129,30 +128,21 @@ public class AttendanceGroupServiceImpl extends AbstractCRUDServiceImpl<Attendan ...@@ -129,30 +128,21 @@ public class AttendanceGroupServiceImpl extends AbstractCRUDServiceImpl<Attendan
} }
this.save(attendanceGroupEntity); this.save(attendanceGroupEntity);
// //todo 保存考勤组班次
AttendanceGroupFixedworkEntity attendanceGroupFixedworkEntity = fixedworkService.selectOne(new AttendanceGroupFixedworkQuery().groupId(attendanceGroupEntity.getId())); /* AttendanceGroupFixedworkEntity attendanceGroupFixedworkEntity = fixedworkService.selectOne(new AttendanceGroupFixedworkQuery().groupId(attendanceGroupEntity.getId()));
if(ObjectUtils.isEmpty(attendanceGroupFixedworkEntity)){ if(ObjectUtils.isEmpty(attendanceGroupFixedworkEntity)){
//todo 默认班次1 //todo 默认班次1
attendanceGroupFixedworkEntity = new AttendanceGroupFixedworkEntity(); attendanceGroupFixedworkEntity = new AttendanceGroupFixedworkEntity();
attendanceGroupFixedworkEntity.initAttrValue(); attendanceGroupFixedworkEntity.initAttrValue();
attendanceGroupFixedworkEntity.setGroupId(attendanceGroupEntity.getId()); attendanceGroupFixedworkEntity.setGroupId(attendanceGroupEntity.getId());
attendanceGroupFixedworkEntity.setGroupName(attendanceGroupEntity.getGroupName()); attendanceGroupFixedworkEntity.setGroupName(attendanceGroupEntity.getGroupName());
attendanceGroupFixedworkEntity.setMonday(1); attendanceGroupFixedworkEntity.setMonday(1);
attendanceGroupFixedworkEntity.setMondayClassName("早晚"); attendanceGroupFixedworkEntity.setMondayClassName("早晚");
}*/
} }
} }
} }
}
//保存考勤组人员 //保存考勤组人员
AttendanceGroupQuery attendanceGroupQuery = new AttendanceGroupQuery(); AttendanceGroupQuery attendanceGroupQuery = new AttendanceGroupQuery();
......
...@@ -740,19 +740,17 @@ public class AttendanceRecordHikServiceImpl extends AbstractCRUDServiceImpl<Atte ...@@ -740,19 +740,17 @@ public class AttendanceRecordHikServiceImpl extends AbstractCRUDServiceImpl<Atte
List<String> userLists = staffService.find(new StaffQuery()).stream().map(i -> i.getWorkNum()).collect(Collectors.toList()); List<String> userLists = staffService.find(new StaffQuery()).stream().map(i -> i.getWorkNum()).collect(Collectors.toList());
List<List<String>> partition = Lists.partition(userLists, 10); List<List<String>> partition = Lists.partition(userLists, 10);
for (List<String> userList : partition) { for (List<String> userList : partition) {
hikQuery.setAttendanceDateStart(DateUtil.parseDate(hikQuery.getAttendanceDateStart()).toString()); hikQuery.setAttendanceDateStart(DateUtil.parseDate(hikQuery.getAttendanceDateStart()).toString());
hikQuery.setAttendanceDateEnd(DateUtil.parseDate(hikQuery.getAttendanceDateEnd()).toString()); hikQuery.setAttendanceDateEnd(DateUtil.parseDate(hikQuery.getAttendanceDateEnd()).toString());
Rest<List<OapiAttendanceListResponse.Recordresult>> rest = dingAttenanceService.getAttendanceList(pageInfo, userList, hikQuery); Rest<List<OapiAttendanceListResponse.Recordresult>> rest = dingAttenanceService.getAttendanceList(pageInfo, userList, hikQuery);
if (rest.getCode() == YesNoEnum.YES.getValue()) { if (rest.getCode() == YesNoEnum.YES.getValue()) {
List<AttendanceRecordHikEntity> attendanceList = rest.getData().stream().map(item -> {
List<AttendanceRecordHikEntity> attendanceList = rest.getData().stream()
.filter(f-> !"NotSigned".equalsIgnoreCase(f.getTimeResult()))
.map(item -> {
AttendanceRecordHikEntity recordHikEntity = new AttendanceRecordHikEntity(); AttendanceRecordHikEntity recordHikEntity = new AttendanceRecordHikEntity();
recordHikEntity.initAttrValue(); recordHikEntity.initAttrValue();
if (ObjectUtils.isEmpty(item.getUserId())) { if (ObjectUtils.isEmpty(item.getUserId())) {
log.info("jobNo is null ==>{}", JSON.toJSONString(item)); log.info("jobNo is null ==>{}", JSON.toJSONString(item));
return null; return null;
...@@ -762,13 +760,11 @@ public class AttendanceRecordHikServiceImpl extends AbstractCRUDServiceImpl<Atte ...@@ -762,13 +760,11 @@ public class AttendanceRecordHikServiceImpl extends AbstractCRUDServiceImpl<Atte
workNum = StrUtil.padPre(item.getUserId(), 8, "0"); workNum = StrUtil.padPre(item.getUserId(), 8, "0");
} }
StaffEntity staffCache = staffService.getExtCache(workNum); StaffEntity staffCache = staffService.getExtCache(workNum);
// StaffEntity staffCache = staffService.getExtCache(StrUtil.padPre(item.getUserId(), 8, "0")); // StaffEntity staffCache = staffService.getExtCache(StrUtil.padPre(item.getUserId(), 8, "0"));
if (ObjectUtils.isEmpty(staffCache)) { if (ObjectUtils.isEmpty(staffCache)) {
log.info("staff is null !worknum:{}", item.getUserId()); log.info("staff is null !worknum:{}", item.getUserId());
return null; return null;
} }
recordHikEntity.setStaffId(staffCache.getId()); recordHikEntity.setStaffId(staffCache.getId());
recordHikEntity.setStaffName(staffCache.getName()); recordHikEntity.setStaffName(staffCache.getName());
recordHikEntity.setWorkNum(staffCache.getWorkNum()); recordHikEntity.setWorkNum(staffCache.getWorkNum());
......
...@@ -17,6 +17,7 @@ import com.mortals.framework.utils.ServletUtils; ...@@ -17,6 +17,7 @@ import com.mortals.framework.utils.ServletUtils;
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.upload.service.UploadService; import com.mortals.xhx.base.system.upload.service.UploadService;
import com.mortals.xhx.common.code.AttendSourceTypeEnum;
import com.mortals.xhx.common.key.RedisKey; import com.mortals.xhx.common.key.RedisKey;
import com.mortals.xhx.common.keys.RedisCacheKeys; import com.mortals.xhx.common.keys.RedisCacheKeys;
import com.mortals.xhx.common.utils.AddAttendThread; import com.mortals.xhx.common.utils.AddAttendThread;
...@@ -85,6 +86,8 @@ public class AttendanceRecordHikController extends BaseCRUDJsonBodyMappingContro ...@@ -85,6 +86,8 @@ public class AttendanceRecordHikController extends BaseCRUDJsonBodyMappingContro
private ICacheService cacheService; private ICacheService cacheService;
@Value("${hik.host:}") @Value("${hik.host:}")
protected String hikhost; protected String hikhost;
@Value("${source.type:''}")
protected String sourceType;
@Autowired @Autowired
private DoorService doorService; private DoorService doorService;
...@@ -229,12 +232,40 @@ public class AttendanceRecordHikController extends BaseCRUDJsonBodyMappingContro ...@@ -229,12 +232,40 @@ public class AttendanceRecordHikController extends BaseCRUDJsonBodyMappingContro
Long compare = DateUtil.between(attendEnd, attendStart, DateUnit.DAY); Long compare = DateUtil.between(attendEnd, attendStart, DateUnit.DAY);
StopWatch stopWatch = new StopWatch("stopwatch attend1"); StopWatch stopWatch = new StopWatch("stopwatch attend1");
log.info("考勤计算天数区间:{}", compare); log.info("考勤计算天数区间:{}", compare);
new Thread(()->{
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("执行本地方法"); stopWatch.start("执行本地方法");
hikEntity.setAttendanceDateStart(curDate.toDateStr()); hikEntity.setAttendanceDateStart(curDate.toDateStr());
hikEntity.setAttendanceDateEnd(curDate.toDateStr()); hikEntity.setAttendanceDateEnd(curDate.toDateStr());
if (AttendSourceTypeEnum.海康云平台.getValue().equals(sourceType)) {
//海康云平台
log.info("同步海康云平台门禁事件!");
hikService.syncDoorEvents(hikEntity);
hikService.deletFakeRecord(hikEntity, context);
} else if (AttendSourceTypeEnum.海康考勤机.getValue().equals(sourceType)) {
HikDoorEventReq hikDoorEventReq = new HikDoorEventReq();
hikDoorEventReq.setStartTime(DateUtil.parseDate(curDate.toDateStr()).toJdkDate());
hikDoorEventReq.setEndTime(DateUtil.endOfDay(new Date()));
log.info("同步设备上门禁事件!req==>{}", JSON.toJSONString(hikDoorEventReq));
List<DoorEntity> doorEntities = doorService.find(new DoorQuery());
for (DoorEntity doorEntity : doorEntities) {
doorService.syncDoorDeviceEvents(doorEntity, hikDoorEventReq);
}
this.service.deletFakeRecord(hikEntity, null);
} else if (AttendSourceTypeEnum.钉钉.getValue().equals(sourceType)) {
//钉钉
log.info("同步钉钉考勤事件!");
hikService.syncDoorEventsFromDingTalk(hikEntity);
}else {
log.info("未配置考勤源类型!");
}
/*
if (!ObjectUtils.isEmpty(hikhost)) { if (!ObjectUtils.isEmpty(hikhost)) {
hikService.syncDoorEvents(hikEntity); hikService.syncDoorEvents(hikEntity);
hikService.deletFakeRecord(hikEntity, context); hikService.deletFakeRecord(hikEntity, context);
...@@ -248,10 +279,13 @@ public class AttendanceRecordHikController extends BaseCRUDJsonBodyMappingContro ...@@ -248,10 +279,13 @@ public class AttendanceRecordHikController extends BaseCRUDJsonBodyMappingContro
doorService.syncDoorDeviceEvents(doorEntity, hikDoorEventReq); doorService.syncDoorDeviceEvents(doorEntity, hikDoorEventReq);
} }
this.service.deletFakeRecord(hikEntity, null); this.service.deletFakeRecord(hikEntity, null);
} }*/
stopWatch.stop(); stopWatch.stop();
log.info("考勤计算日期:{} 完成,耗时:{}ms", curDate.toDateStr(), stopWatch.getLastTaskTimeMillis()); log.info("考勤计算日期:{} 完成,耗时:{}ms", curDate.toDateStr(), stopWatch.getLastTaskTimeMillis());
} }
}).start();
model.put("message_info", busiDesc + "成功"); model.put("message_info", busiDesc + "成功");
this.recordSysLog(this.request, busiDesc + " 【成功】"); this.recordSysLog(this.request, busiDesc + " 【成功】");
} catch (Exception e) { } catch (Exception e) {
......
...@@ -34,7 +34,7 @@ public class DingAttendanceServiceImpl extends AbstractDingTalkService implement ...@@ -34,7 +34,7 @@ public class DingAttendanceServiceImpl extends AbstractDingTalkService implement
req.setUserIdList(userIdList); req.setUserIdList(userIdList);
req.setOffset(Long.valueOf(pageInfo.getBeginIndex() + "")); req.setOffset(Long.valueOf(pageInfo.getBeginIndex() + ""));
req.setLimit(Long.valueOf(pageInfo.getPrePageResult() + "")); req.setLimit(Long.valueOf(pageInfo.getPrePageResult() + ""));
log.info("req:{}", JSON.toJSONString(req)); //log.info("req:{}", JSON.toJSONString(req));
OapiAttendanceListResponse rsp = client.execute(req, getToken()); OapiAttendanceListResponse rsp = client.execute(req, getToken());
// log.info("OapiV2UserGetbymobileResponse:{}", rsp.getBody()); // log.info("OapiV2UserGetbymobileResponse:{}", rsp.getBody());
...@@ -43,12 +43,9 @@ public class DingAttendanceServiceImpl extends AbstractDingTalkService implement ...@@ -43,12 +43,9 @@ public class DingAttendanceServiceImpl extends AbstractDingTalkService implement
log.info("还有更多数据,递归调用,req:{}", JSON.toJSONString(req)); log.info("还有更多数据,递归调用,req:{}", JSON.toJSONString(req));
pageInfo.setCurrPage(pageInfo.getCurrPage() + 1); pageInfo.setCurrPage(pageInfo.getCurrPage() + 1);
Rest<List<OapiAttendanceListResponse.Recordresult>> attendanceList = getAttendanceList(pageInfo, userIdList, hikQuery); Rest<List<OapiAttendanceListResponse.Recordresult>> attendanceList = getAttendanceList(pageInfo, userIdList, hikQuery);
rsp.getRecordresult().addAll(attendanceList.getData()); rsp.getRecordresult().addAll(attendanceList.getData());
return Rest.ok("成功", rsp.getRecordresult()); return Rest.ok("成功", rsp.getRecordresult());
} }
return Rest.ok("成功", rsp.getRecordresult()); return Rest.ok("成功", rsp.getRecordresult());
} else { } else {
......
...@@ -233,12 +233,13 @@ public class DingPersonServiceImpl extends AbstractDingTalkService implements ID ...@@ -233,12 +233,13 @@ public class DingPersonServiceImpl extends AbstractDingTalkService implements ID
runtimeOptions.setReadTimeout(60000); runtimeOptions.setReadTimeout(60000);
runtimeOptions.setConnectTimeout(60000); runtimeOptions.setConnectTimeout(60000);
ListProcessInstanceIdsResponse rsp = client.listProcessInstanceIdsWithOptions(listProcessInstanceIdsRequest, listProcessInstanceIdsHeaders, runtimeOptions); ListProcessInstanceIdsResponse rsp = client.listProcessInstanceIdsWithOptions(listProcessInstanceIdsRequest, listProcessInstanceIdsHeaders, runtimeOptions);
if (!ObjectUtils.isEmpty(rsp.getBody()) &&
if (rsp.getBody().getSuccess()) { !ObjectUtils.isEmpty(rsp.getBody().getSuccess())&&
// log.info("获取审批实例id列表成功->" + JSONObject.toJSONString(rsp.getBody().getResult())); rsp.getBody().getSuccess()) {
log.info("获取审批实例id列表成功->" + JSONObject.toJSONString(rsp.getBody().getResult()));
return Rest.ok(rsp.getBody().getResult()); return Rest.ok(rsp.getBody().getResult());
} else { } else {
log.info("获取审批实例id列表失败->" + JSONObject.toJSONString(rsp)); // log.info("获取审批实例id列表失败->" + JSONObject.toJSONString(rsp));
return Rest.fail("查询失败:" + rsp.getBody().getSuccess()); return Rest.fail("查询失败:" + rsp.getBody().getSuccess());
} }
} catch (Exception _err) { } catch (Exception _err) {
......
...@@ -2,6 +2,7 @@ package com.mortals.xhx.module.staff.web; ...@@ -2,6 +2,7 @@ package com.mortals.xhx.module.staff.web;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.mortals.framework.annotation.UnAuth; import com.mortals.framework.annotation.UnAuth;
import com.mortals.framework.common.Rest; import com.mortals.framework.common.Rest;
...@@ -13,14 +14,14 @@ import com.mortals.xhx.base.system.param.service.ParamService; ...@@ -13,14 +14,14 @@ import com.mortals.xhx.base.system.param.service.ParamService;
import com.mortals.xhx.common.code.*; import com.mortals.xhx.common.code.*;
import com.mortals.xhx.module.attendance.model.*; import com.mortals.xhx.module.attendance.model.*;
import com.mortals.xhx.module.attendance.model.vo.AttendStatInfo; import com.mortals.xhx.module.attendance.model.vo.AttendStatInfo;
import com.mortals.xhx.module.attendance.service.AttendanceLeaveRecordService; import com.mortals.xhx.module.attendance.service.*;
import com.mortals.xhx.module.attendance.service.AttendanceRecordHikService;
import com.mortals.xhx.module.attendance.service.AttendanceRecordService;
import com.mortals.xhx.module.attendance.service.AttendanceVacationRecordService;
import com.mortals.xhx.module.dept.model.DeptEntity; import com.mortals.xhx.module.dept.model.DeptEntity;
import com.mortals.xhx.module.dept.model.DeptQuery; import com.mortals.xhx.module.dept.model.DeptQuery;
import com.mortals.xhx.module.dept.model.DeptTreeSelect; import com.mortals.xhx.module.dept.model.DeptTreeSelect;
import com.mortals.xhx.module.dept.service.DeptService; import com.mortals.xhx.module.dept.service.DeptService;
import com.mortals.xhx.module.door.model.DoorEntity;
import com.mortals.xhx.module.door.model.DoorQuery;
import com.mortals.xhx.module.hik.door.model.req.door.HikDoorEventReq;
import com.mortals.xhx.module.job.model.JobEntity; import com.mortals.xhx.module.job.model.JobEntity;
import com.mortals.xhx.module.job.model.JobQuery; import com.mortals.xhx.module.job.model.JobQuery;
import com.mortals.xhx.module.job.service.JobService; import com.mortals.xhx.module.job.service.JobService;
...@@ -68,6 +69,12 @@ public class StaffController extends BaseCRUDJsonBodyMappingController<StaffServ ...@@ -68,6 +69,12 @@ public class StaffController extends BaseCRUDJsonBodyMappingController<StaffServ
@Value("${hik.host:}") @Value("${hik.host:}")
protected String hikhost; protected String hikhost;
@Value("${source.type:''}")
protected String sourceType;
@Autowired
private AttendanceGroupService groupService;
public StaffController() { public StaffController() {
super.setModuleDesc("员工基本信息"); super.setModuleDesc("员工基本信息");
...@@ -200,16 +207,37 @@ public class StaffController extends BaseCRUDJsonBodyMappingController<StaffServ ...@@ -200,16 +207,37 @@ public class StaffController extends BaseCRUDJsonBodyMappingController<StaffServ
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();
String busiDesc = this.getModuleDesc() + "同步"; String busiDesc = this.getModuleDesc() + "同步";
try { try {
if (!ObjectUtils.isEmpty(hikhost)) {
if (AttendSourceTypeEnum.海康云平台.getValue().equals(sourceType)) {
//海康云平台
//同步部门 //同步部门
deptService.syncDept(getContext()); deptService.syncDept(getContext());
Rest<Void> rest = this.service.syncPersons(getContext()); Rest<Void> rest = this.service.syncPersons(getContext());
if (rest.getCode() == YesNoEnum.NO.getValue()) { if (rest.getCode() == YesNoEnum.NO.getValue()) {
throw new AppException("同步异常!"); throw new AppException("同步异常!");
} }
}else{ } else if (AttendSourceTypeEnum.海康考勤机.getValue().equals(sourceType)) {
this.service.syncPersonsByDevices(null); this.service.syncPersonsByDevices(null);
} else if (AttendSourceTypeEnum.钉钉.getValue().equals(sourceType)) {
//钉钉
log.info("同步钉钉考勤!");
this.service.syncPersonsByDingTalk(null);
groupService.syncGroupByDingTalk();
}else {
log.info("未配置考勤源类型!");
} }
/* if (!ObjectUtils.isEmpty(hikhost)) {
//同步部门
deptService.syncDept(getContext());
Rest<Void> rest = this.service.syncPersons(getContext());
if (rest.getCode() == YesNoEnum.NO.getValue()) {
throw new AppException("同步异常!");
}
}else{
this.service.syncPersonsByDevices(null);
}*/
recordSysLog(request, busiDesc + " 【成功】"); recordSysLog(request, busiDesc + " 【成功】");
jsonObject.put(KEY_RESULT_CODE, VALUE_RESULT_SUCCESS); jsonObject.put(KEY_RESULT_CODE, VALUE_RESULT_SUCCESS);
jsonObject.put(KEY_RESULT_MSG, busiDesc + " 【成功】"); jsonObject.put(KEY_RESULT_MSG, busiDesc + " 【成功】");
......
...@@ -58,9 +58,8 @@ POST {{baseUrl}}/attendance/record/hik/addAttendanceRecord ...@@ -58,9 +58,8 @@ POST {{baseUrl}}/attendance/record/hik/addAttendanceRecord
Content-Type: application/json Content-Type: application/json
{ {
"attendanceDateStart": "2025-02-05", "attendanceDateStart": "2025-01-01",
"attendanceDateEnd": "2025-02-05", "attendanceDateEnd": "2025-03-24"
"staffId":752
} }
...@@ -80,8 +79,8 @@ POST {{baseUrl}}/attendance/record/hik/addAttendanceHikRecordCustom ...@@ -80,8 +79,8 @@ POST {{baseUrl}}/attendance/record/hik/addAttendanceHikRecordCustom
Content-Type: application/json Content-Type: application/json
{ {
"attendanceDateStart": "2025-02-01", "attendanceDateStart": "2025-01-01",
"attendanceDateEnd": "2025-03-18" "attendanceDateEnd": "2025-03-24"
} }
...@@ -90,8 +89,8 @@ POST {{baseUrl}}/attendance/stat/summary ...@@ -90,8 +89,8 @@ POST {{baseUrl}}/attendance/stat/summary
Content-Type: application/json Content-Type: application/json
{ {
"summaryTimeStart": "2025-02-01", "summaryTimeStart": "2025-03-01",
"summaryTimeEnd": "2025-03-18" "summaryTimeEnd": "2025-03-24"
} }
......
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