Commit 11bbcb58 authored by 赵啸非's avatar 赵啸非

添加钉钉对接流程代码

parent b3d46e7c
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
<profiles.log.path>/home/mortals/app/logs</profiles.log.path> <profiles.log.path>/home/mortals/app/logs</profiles.log.path>
<profiles.log.level>info</profiles.log.level> <profiles.log.level>info</profiles.log.level>
<profiles.publish.path>/home/publish</profiles.publish.path> <profiles.publish.path>/home/publish</profiles.publish.path>
<profiles.source.type>hik</profiles.source.type>
<profiles.hik.host></profiles.hik.host> <profiles.hik.host></profiles.hik.host>
<profiles.hik.protocol></profiles.hik.protocol> <profiles.hik.protocol></profiles.hik.protocol>
<profiles.hik.appKey></profiles.hik.appKey> <profiles.hik.appKey></profiles.hik.appKey>
...@@ -38,8 +39,10 @@ ...@@ -38,8 +39,10 @@
<profiles.dingtalk.opUserId></profiles.dingtalk.opUserId> <profiles.dingtalk.opUserId></profiles.dingtalk.opUserId>
<profiles.webUrl></profiles.webUrl> <profiles.webUrl></profiles.webUrl>
<package.environment>build</package.environment> <package.environment>build</package.environment>
<profiles.nacos.server-addr>127.0.0.1:8848</profiles.nacos.server-addr>
<profiles.nacos.group>DEFAULT_GROUP</profiles.nacos.group> <profiles.nacos.group>DEFAULT_GROUP</profiles.nacos.group>
<profiles.nacos.namespace>smart-gov</profiles.nacos.namespace> <profiles.nacos.namespace>smart-gov</profiles.nacos.namespace>
<skipUi>ture</skipUi>
</properties> </properties>
<profiles> <profiles>
...@@ -47,10 +50,8 @@ ...@@ -47,10 +50,8 @@
<id>develop</id> <id>develop</id>
<properties> <properties>
<profiles.active>develop</profiles.active> <profiles.active>develop</profiles.active>
<profiles.nacos.server-addr>127.0.0.1:8848</profiles.nacos.server-addr>
<profiles.sms.smsSendUrl>http://127.0.0.1:8089/api/index/index</profiles.sms.smsSendUrl> <profiles.sms.smsSendUrl>http://127.0.0.1:8089/api/index/index</profiles.sms.smsSendUrl>
<profiles.sms.apiId>k6BVS1PEbyzcJAE4</profiles.sms.apiId> <profiles.sms.apiId>k6BVS1PEbyzcJAE4</profiles.sms.apiId>
<skipUi>ture</skipUi>
</properties> </properties>
</profile> </profile>
<profile> <profile>
...@@ -58,10 +59,8 @@ ...@@ -58,10 +59,8 @@
<properties> <properties>
<profiles.active>test</profiles.active> <profiles.active>test</profiles.active>
<profiles.server.debug>-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=51750</profiles.server.debug> <profiles.server.debug>-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=51750</profiles.server.debug>
<profiles.nacos.server-addr>192.168.0.252:8848</profiles.nacos.server-addr>
<profiles.sms.smsSendUrl>http://127.0.0.1:8089/api/index/index</profiles.sms.smsSendUrl> <profiles.sms.smsSendUrl>http://127.0.0.1:8089/api/index/index</profiles.sms.smsSendUrl>
<profiles.sms.apiId>k6BVS1PEbyzcJAE4</profiles.sms.apiId> <profiles.sms.apiId>k6BVS1PEbyzcJAE4</profiles.sms.apiId>
<skipUi>ture</skipUi>
</properties> </properties>
</profile> </profile>
...@@ -69,11 +68,9 @@ ...@@ -69,11 +68,9 @@
<id>product</id> <id>product</id>
<properties> <properties>
<profiles.active>product</profiles.active> <profiles.active>product</profiles.active>
<profiles.nacos.server-addr>127.0.0.1:8848</profiles.nacos.server-addr>
<profiles.sms.smsSendUrl>http://127.0.0.1:8089/api/index/index</profiles.sms.smsSendUrl> <profiles.sms.smsSendUrl>http://127.0.0.1:8089/api/index/index</profiles.sms.smsSendUrl>
<profiles.server.debug>-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=51750</profiles.server.debug> <profiles.server.debug>-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=51750</profiles.server.debug>
<profiles.sms.apiId>k6BVS1PEbyzcJAE4</profiles.sms.apiId> <profiles.sms.apiId>k6BVS1PEbyzcJAE4</profiles.sms.apiId>
<skipUi>ture</skipUi>
</properties> </properties>
</profile> </profile>
<profile> <profile>
...@@ -99,8 +96,6 @@ ...@@ -99,8 +96,6 @@
<profiles.dingtalk.token>m3WeuVx5kcTY76kh22uWZOTSu0XjvcwNhd</profiles.dingtalk.token> <profiles.dingtalk.token>m3WeuVx5kcTY76kh22uWZOTSu0XjvcwNhd</profiles.dingtalk.token>
<profiles.dingtalk.opUserId>254868153920685466</profiles.dingtalk.opUserId> <profiles.dingtalk.opUserId>254868153920685466</profiles.dingtalk.opUserId>
<profiles.webUrl>https://ybswxxcx.zwfwhfgjjfzj.yibin.gov.cn/performance-h5</profiles.webUrl> <profiles.webUrl>https://ybswxxcx.zwfwhfgjjfzj.yibin.gov.cn/performance-h5</profiles.webUrl>
<package.environment>build</package.environment>
<skipUi>ture</skipUi>
</properties> </properties>
</profile> </profile>
...@@ -108,17 +103,12 @@ ...@@ -108,17 +103,12 @@
<id>reg</id> <id>reg</id>
<properties> <properties>
<profiles.active>reg</profiles.active> <profiles.active>reg</profiles.active>
<profiles.nacos.server-addr>127.0.0.1:8848</profiles.nacos.server-addr>
<profiles.nacos.group>DEFAULT_GROUP</profiles.nacos.group>
<profiles.nacos.namespace>smart-gov</profiles.nacos.namespace>
<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.hik.host>10.207.153.105:443</profiles.hik.host> <profiles.hik.host>10.207.153.105:443</profiles.hik.host>
<profiles.hik.protocol>https://</profiles.hik.protocol> <profiles.hik.protocol>https://</profiles.hik.protocol>
<profiles.hik.appKey>25594054</profiles.hik.appKey> <profiles.hik.appKey>25594054</profiles.hik.appKey>
<profiles.hik.appSecret>K12IkZoSLxpsJjrUPtfV</profiles.hik.appSecret> <profiles.hik.appSecret>K12IkZoSLxpsJjrUPtfV</profiles.hik.appSecret>
<package.environment>build</package.environment>
<skipUi>true</skipUi>
</properties> </properties>
</profile> </profile>
...@@ -127,16 +117,12 @@ ...@@ -127,16 +117,12 @@
<properties> <properties>
<profiles.active>yanyuan</profiles.active> <profiles.active>yanyuan</profiles.active>
<profiles.nacos.server-addr>172.16.30.245:8848</profiles.nacos.server-addr> <profiles.nacos.server-addr>172.16.30.245:8848</profiles.nacos.server-addr>
<profiles.nacos.group>DEFAULT_GROUP</profiles.nacos.group>
<profiles.nacos.namespace>smart-gov</profiles.nacos.namespace>
<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.hik.host>172.16.30.240:443</profiles.hik.host> <profiles.hik.host>172.16.30.240:443</profiles.hik.host>
<profiles.hik.protocol>https://</profiles.hik.protocol> <profiles.hik.protocol>https://</profiles.hik.protocol>
<profiles.hik.appKey>25444489</profiles.hik.appKey> <profiles.hik.appKey>25444489</profiles.hik.appKey>
<profiles.hik.appSecret>QoBF7sD2zrKHabqmeoEP</profiles.hik.appSecret> <profiles.hik.appSecret>QoBF7sD2zrKHabqmeoEP</profiles.hik.appSecret>
<package.environment>build</package.environment>
<skipUi>true</skipUi>
</properties> </properties>
</profile> </profile>
...@@ -144,12 +130,10 @@ ...@@ -144,12 +130,10 @@
<id>pengxi</id> <id>pengxi</id>
<properties> <properties>
<profiles.active>pengxi</profiles.active> <profiles.active>pengxi</profiles.active>
<profiles.source.type>hik-device</profiles.source.type>
<profiles.nacos.server-addr>192.168.106.6:8848</profiles.nacos.server-addr> <profiles.nacos.server-addr>192.168.106.6:8848</profiles.nacos.server-addr>
<profiles.nacos.group>DEFAULT_GROUP</profiles.nacos.group>
<profiles.nacos.namespace>smart-gov</profiles.nacos.namespace>
<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>
<skipUi>true</skipUi>
</properties> </properties>
</profile> </profile>
...@@ -157,7 +141,6 @@ ...@@ -157,7 +141,6 @@
<id>bzjkq</id> <id>bzjkq</id>
<properties> <properties>
<profiles.active>bzjkq</profiles.active> <profiles.active>bzjkq</profiles.active>
<profiles.nacos.server-addr>127.0.0.1:8848</profiles.nacos.server-addr>
<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>
</properties> </properties>
...@@ -167,12 +150,31 @@ ...@@ -167,12 +150,31 @@
<id>qiling</id> <id>qiling</id>
<properties> <properties>
<profiles.active>qiling</profiles.active> <profiles.active>qiling</profiles.active>
<profiles.nacos.server-addr>127.0.0.1:8848</profiles.nacos.server-addr>
<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>
</properties> </properties>
</profile> </profile>
<profile>
<id>qionglai</id>
<properties>
<profiles.active>qionglai</profiles.active>
<profiles.source.type>dingtalk</profiles.source.type>
<profiles.sms.smsSendUrl>http://sms.wx3.com.cn/api/index/index</profiles.sms.smsSendUrl>
<profiles.sms.apiId>ADsUXLrS81vZDU95</profiles.sms.apiId>
<profiles.dingtalk.domain>https://oapi.dingtalk.com</profiles.dingtalk.domain>
<profiles.dingtalk.oaScheme>http</profiles.dingtalk.oaScheme>
<profiles.dingtalk.oaUrl>https://oapi.dingtalk.com</profiles.dingtalk.oaUrl>
<profiles.dingtalk.agentId>2652674890</profiles.dingtalk.agentId>
<profiles.dingtalk.appKey>dingvbzaw1176pbzo1zx</profiles.dingtalk.appKey>
<profiles.dingtalk.appSecret>jmKqKPDLR3BxdZT_QNX4pm6zDdtbaLI3PtsFymQ6tUle-uKUgmxtr_a6ys3b8v3Y</profiles.dingtalk.appSecret>
<profiles.dingtalk.aesKey>1QcPYuSpAc98OS3qQwwx5HPH85CZDidxF95yBGad2fJ</profiles.dingtalk.aesKey>
<profiles.dingtalk.token>m3WeuVx5kcTY76kh22uWZOTSu0XjvcwNhd</profiles.dingtalk.token>
<profiles.dingtalk.opUserId>254868153920685466</profiles.dingtalk.opUserId>
</properties>
</profile>
</profiles> </profiles>
<dependencies> <dependencies>
......
...@@ -132,7 +132,12 @@ public class TestController { ...@@ -132,7 +132,12 @@ public class TestController {
List<AttendanceRecordHikEntity> attRecords = doorEventsRest.getData().getList().stream().map(item -> { List<AttendanceRecordHikEntity> attRecords = doorEventsRest.getData().getList().stream().map(item -> {
AttendanceRecordHikEntity recordHikEntity = new AttendanceRecordHikEntity(); AttendanceRecordHikEntity recordHikEntity = new AttendanceRecordHikEntity();
recordHikEntity.initAttrValue(); recordHikEntity.initAttrValue();
StaffEntity staffCache = staffService.getExtCache(StrUtil.padPre(item.getJobNo(), 8, "0")); String workNum = item.getJobNo();
if(item.getJobNo().length()<8){
workNum = StrUtil.padPre(item.getJobNo(), 8, "0");
}
StaffEntity staffCache = staffService.getExtCache(workNum);
//StaffEntity staffCache = staffService.getExtCache(StrUtil.padPre(item.getJobNo(), 8, "0"));
if (ObjectUtils.isEmpty(staffCache)) { if (ObjectUtils.isEmpty(staffCache)) {
log.info("staff is null !staffCode:{}", item.getJobNo()); log.info("staff is null !staffCode:{}", item.getJobNo());
return null; return null;
......
package com.mortals.xhx.common.code;
import java.util.LinkedHashMap;
import java.util.Map;
/**
* 考勤来源类型枚举
*
* @author zxfei
*/
public enum AttendSourceTypeEnum {
海康云平台("hik", "海康云平台"),
海康考勤机("hik-device", "海康考勤机"),
钉钉("dingtalk", "钉钉");
private String value;
private String desc;
AttendSourceTypeEnum(String value, String desc) {
this.value = value;
this.desc = desc;
}
public String getValue() {
return this.value;
}
public String getDesc() {
return this.desc;
}
public static AttendSourceTypeEnum getByValue(String value) {
for (AttendSourceTypeEnum typeEnum : AttendSourceTypeEnum.values()) {
if (typeEnum.getValue() == value) {
return typeEnum;
}
}
return null;
}
/**
* 获取Map集合
*
* @param eItem 不包含项
* @return
*/
public static Map<String, String> getEnumMap(String... eItem) {
Map<String, String> resultMap = new LinkedHashMap<>();
for (AttendSourceTypeEnum item : AttendSourceTypeEnum.values()) {
try {
boolean hasE = false;
for (String e : eItem) {
if (e.equals(item.getValue())) {
hasE = true;
break;
}
}
if (!hasE) {
resultMap.put(item.getValue(), item.getDesc());
}
} catch (Exception ex) {
}
}
return resultMap;
}
}
\ No newline at end of file
...@@ -12,7 +12,8 @@ public enum AttendanceTypeEnum { ...@@ -12,7 +12,8 @@ public enum AttendanceTypeEnum {
地点打卡("地点打卡", "地点打卡"), 地点打卡("地点打卡", "地点打卡"),
WiFi打卡("Wi-Fi打卡", "Wi-Fi打卡"), WiFi打卡("Wi-Fi打卡", "Wi-Fi打卡"),
蓝牙打卡("蓝牙打卡", "蓝牙打卡"), 蓝牙打卡("蓝牙打卡", "蓝牙打卡"),
考勤机打卡("考勤机打卡", "考勤机打卡"); 考勤机打卡("考勤机打卡", "考勤机打卡"),
钉钉打卡("钉钉打卡", "钉钉打卡"),;
private String value; private String value;
private String desc; private String desc;
......
...@@ -10,6 +10,7 @@ import java.util.Map; ...@@ -10,6 +10,7 @@ import java.util.Map;
*/ */
public enum SourceEnum { public enum SourceEnum {
海康(1, "海康"), 海康(1, "海康"),
钉钉(3, "钉钉"),
自定义(2, "自定义"); 自定义(2, "自定义");
private Integer value; private Integer value;
private String desc; private String desc;
......
package com.mortals.xhx.daemon.applicationservice; package com.mortals.xhx.daemon.applicationservice;
import com.alibaba.fastjson.JSON;
import com.mortals.framework.springcloud.service.IApplicationStartedService; import com.mortals.framework.springcloud.service.IApplicationStartedService;
import com.mortals.framework.util.ThreadPool; import com.mortals.framework.util.ThreadPool;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.List;
@Component @Component
@Slf4j @Slf4j
public class StartService implements IApplicationStartedService { public class StartService implements IApplicationStartedService {
...@@ -13,8 +17,34 @@ public class StartService implements IApplicationStartedService { ...@@ -13,8 +17,34 @@ public class StartService implements IApplicationStartedService {
@Override @Override
public void start() { public void start() {
ThreadPool.getInstance().init(10); ThreadPool.getInstance().init(10);
//测试 多个返回
int i = 0;
List<String> list = query(i);
log.info(JSON.toJSONString(list));
}
public List<String> query(int i) {
i++;
if (i > 5) {
return new ArrayList<>();
} }
return query(i);
}
@Override @Override
public void stop() { public void stop() {
log.info("停止服务.."); log.info("停止服务..");
......
package com.mortals.xhx.daemon.applicationservice; package com.mortals.xhx.daemon.applicationservice;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.dingtalk.api.response.*;
import com.google.common.collect.Lists;
import com.mortals.framework.common.Rest;
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.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.AttendanceTypeEnum;
import com.mortals.xhx.common.code.YesNoEnum;
import com.mortals.xhx.module.attendance.model.*;
import com.mortals.xhx.module.attendance.service.AttendanceClassService;
import com.mortals.xhx.module.attendance.service.AttendanceGroupService;
import com.mortals.xhx.module.attendance.service.AttendanceGroupStaffService;
import com.mortals.xhx.module.attendance.service.AttendanceRecordHikService;
import com.mortals.xhx.module.dept.model.DeptEntity;
import com.mortals.xhx.module.dept.model.DeptQuery;
import com.mortals.xhx.module.dept.service.DeptService;
import com.mortals.xhx.module.dingding.attendance.service.IDingAttenanceService;
import com.mortals.xhx.module.dingding.personal.service.IDingPersonService;
import com.mortals.xhx.module.hik.person.model.req.org.OrgListReq;
import com.mortals.xhx.module.hik.person.model.rsp.org.OrgDataInfo;
import com.mortals.xhx.module.hik.person.model.rsp.org.OrgInfo;
import com.mortals.xhx.module.staff.model.StaffEntity;
import com.mortals.xhx.module.staff.model.StaffQuery;
import com.mortals.xhx.module.staff.service.StaffService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.util.ObjectUtils;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
@Component @Component
@Slf4j @Slf4j
...@@ -14,13 +48,165 @@ public class StartedService implements IApplicationStartedService { ...@@ -14,13 +48,165 @@ public class StartedService implements IApplicationStartedService {
private UserService userService; private UserService userService;
@Autowired
private StaffService staffService;
@Autowired
private DeptService deptService;
@Autowired
private IDingPersonService dingPersonService;
@Autowired
private IDingAttenanceService dingAttenanceService;
@Autowired
private AttendanceRecordHikService hikService;
@Autowired
private AttendanceGroupService groupService;
@Autowired
private AttendanceGroupStaffService groupStaffService;
@Override @Override
public void start() { public void start() {
log.info("开始服务..[配置已加载完成,并且所有框架都已经初始化]"); log.info("开始服务..[配置已加载完成,并且所有框架都已经初始化]");
//初始执行同步用户与皮肤任务
//获取排班信息
/* Rest<List<OapiAttendanceShiftListResponse.TopMinimalismShiftVo>> rest = dingAttenanceService.getShiftList(0L);
rest.getData();
for (OapiAttendanceShiftListResponse.TopMinimalismShiftVo datum : rest.getData()) {
//获取排班详细信息
dingAttenanceService.getShiftDetail(datum.getId());
}*/
/*
dingPersonService.getPersonsByDept(new PageInfo(), 123716132L);
Rest<OapiV2UserGetResponse.UserGetResponse> rest = dingAttenanceService.getPersonDetail("2850143830605086304");
*/
//保存更新考勤组
PageInfo pageInfo = new PageInfo();
Rest<List<OapiAttendanceGetsimplegroupsResponse.AtGroupForTopVo>> groupRest = dingAttenanceService.getAttendanceGroupList(pageInfo);
if (YesNoEnum.YES.getValue() == groupRest.getCode()) {
List<OapiAttendanceGetsimplegroupsResponse.AtGroupForTopVo> groupList = groupRest.getData();
for (OapiAttendanceGetsimplegroupsResponse.AtGroupForTopVo group : groupList) {
Long groupId = group.getGroupId();
String groupName = group.getGroupName();
Long memberCount = group.getMemberCount();
String type = group.getType();
AttendanceGroupQuery groupQuery = new AttendanceGroupQuery();
groupQuery.setRemark(groupId.toString());
AttendanceGroupEntity attendanceGroupEntity = groupService.selectOne(groupQuery);
if (ObjectUtils.isEmpty(attendanceGroupEntity)) {
attendanceGroupEntity = new AttendanceGroupEntity();
attendanceGroupEntity.initAttrValue();
attendanceGroupEntity.setRemark(groupId.toString());
attendanceGroupEntity.setGroupName(groupName);
attendanceGroupEntity.setPersonNum(memberCount.intValue());
attendanceGroupEntity.setAttendanceType(AttendanceTypeEnum.钉钉打卡.getValue());
attendanceGroupEntity.setCreateTime(new Date());
attendanceGroupEntity.setCreateUserId(1L);
if ("FIXED".equalsIgnoreCase(type)) {
attendanceGroupEntity.setType(1);
} else if ("TURN".equalsIgnoreCase(type)) {
attendanceGroupEntity.setType(2);
} else if ("NONE".equalsIgnoreCase(type)) {
attendanceGroupEntity.setType(3);
}
groupService.save(attendanceGroupEntity);
}
}
}
//保存考勤组人员
// pageInfo = new PageInfo();
AttendanceGroupQuery attendanceGroupQuery = new AttendanceGroupQuery();
attendanceGroupQuery.setAttendanceType(AttendanceTypeEnum.钉钉打卡.getValue());
List<AttendanceGroupEntity> groupEntityList = groupService.find(attendanceGroupQuery);
for (AttendanceGroupEntity attendanceGroupEntity : groupEntityList) {
long groupId = DataUtil.converStr2Long(attendanceGroupEntity.getRemark(), 0L);
Rest<List<String>> groupPersonRest = dingAttenanceService.getGroupPersons(0L, groupId);
if (YesNoEnum.YES.getValue() == groupPersonRest.getCode()) {
log.info("考勤组人员数量:" + groupPersonRest.getData().size());
//获取本地已有考勤人员
AttendanceGroupStaffQuery groupStaffQuery = new AttendanceGroupStaffQuery();
groupStaffQuery.setGroupId(attendanceGroupEntity.getId());
Set<Long> staffIdsSet = groupStaffService.find(groupStaffQuery).stream().map(item -> item.getStaffId()).collect(Collectors.toSet());
List<StaffEntity> staffEntityList = groupPersonRest.getData().stream().map(workNum -> {
StaffEntity extCache = staffService.getExtCache(workNum);
if (!ObjectUtils.isEmpty(extCache)) {
return extCache;
} else {
log.info("未找到员工工号:" + workNum);
return null;
} }
}).collect(Collectors.toList());
/* StaffQuery staffQuery = new StaffQuery();
staffQuery.setWorkNumList(groupPersonRest.getData());
List<StaffEntity> staffEntityList = staffService.find(staffQuery);*/
for (StaffEntity staffEntity : staffEntityList) {
if (!staffIdsSet.contains(staffEntity.getId())) {
AttendanceGroupStaffEntity groupStaffEntity = new AttendanceGroupStaffEntity();
groupStaffEntity.initAttrValue();
groupStaffEntity.setGroupId(attendanceGroupEntity.getId());
groupStaffEntity.setGroupName(attendanceGroupEntity.getGroupName());
groupStaffEntity.setStaffId(staffEntity.getId());
groupStaffEntity.setStaffName(staffEntity.getName());
groupStaffEntity.setRemark("dingTalk");
groupStaffEntity.setCreateTime(new Date());
groupStaffEntity.setCreateUserId(1L);
groupStaffService.save(groupStaffEntity);
}
}
//增量添加
}
}
// //获取考勤组列表
/*
PageInfo pageInfo = new PageInfo();
dingAttenanceService.getAttendanceGroupList(pageInfo);*/
//staffService.syncPersonsByDingTalk(null);
/*
AttendanceRecordHikQuery hikQuery = new AttendanceRecordHikQuery();
hikQuery.setAttendanceDateStart("2025-03-21");
hikQuery.setAttendanceDateEnd("2025-03-21");
hikService.syncDoorEventsFromDingTalk(hikQuery);
*/
}
@Override @Override
public void stop() { public void stop() {
......
package com.mortals.xhx.daemon.task;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import com.mortals.framework.common.Rest;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.service.ICacheService;
import com.mortals.framework.service.ITask;
import com.mortals.framework.service.ITaskExcuteService;
import com.mortals.framework.util.DataUtil;
import com.mortals.xhx.common.code.DwMinorEnum;
import com.mortals.xhx.common.code.YesNoEnum;
import com.mortals.xhx.module.attendance.model.AttendanceRecordHikEntity;
import com.mortals.xhx.module.attendance.service.AttendanceRecordHikService;
import com.mortals.xhx.module.door.model.DoorEntity;
import com.mortals.xhx.module.door.model.DoorQuery;
import com.mortals.xhx.module.door.service.DoorService;
import com.mortals.xhx.module.hik.door.model.req.door.HikDoorEventReq;
import com.mortals.xhx.module.hik.door.model.rsp.door.info.EventInfo;
import com.mortals.xhx.module.hik.door.model.rsp.door.info.StruTime;
import com.mortals.xhx.module.hik.door.service.IHikDoorService;
import com.mortals.xhx.module.staff.model.StaffEntity;
import com.mortals.xhx.module.staff.service.StaffService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.util.Date;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
/**
* 同步获取当天海康门禁事件
*/
@Slf4j
//@Service("SyncDoorsEventByDevicesTask")
public class SyncDoorsEventByDevicesTaskImpl implements ITaskExcuteService {
@Autowired
private AttendanceRecordHikService recordHikService;
@Autowired
private StaffService staffService;
@Autowired
private IHikDoorService hikDoorService;
private Integer day;
@Autowired
private ICacheService cacheService;
@Autowired
private DoorService doorService;
@Override
public void excuteTask(ITask task) throws AppException {
//同步多久时间段的 偏移量为天 默认当天
String excuteParam = task.getExcuteParam();
if (!ObjectUtils.isEmpty(excuteParam)) {
day = DataUtil.converStr2Int(excuteParam, 0);
} else {
day = 0;
}
HikDoorEventReq hikDoorEventReq = new HikDoorEventReq();
//当前时间前一个小时
// Date startTime = DateUtil.offsetHour(new Date(), -1).toJdkDate();
Date startTime = DateUtil.offsetDay(new Date(), -1).toJdkDate();
Date endTime = new Date();
hikDoorEventReq.setStartTime(startTime);
hikDoorEventReq.setEndTime(endTime);
boolean in = true;
if (in) {
List<DoorEntity> doorEntities = doorService.find(new DoorQuery());
for (DoorEntity doorEntity : doorEntities) {
doorService.syncDoorDeviceEvents(doorEntity,hikDoorEventReq);
// syncDoorEvents(doorEntity);
}
}
}
@Override
public void stopTask(ITask task) throws AppException {
}
}
...@@ -14,11 +14,16 @@ import com.mortals.framework.service.ITaskExcuteService; ...@@ -14,11 +14,16 @@ import com.mortals.framework.service.ITaskExcuteService;
import com.mortals.framework.util.DataUtil; import com.mortals.framework.util.DataUtil;
import com.mortals.framework.util.DateUtils; import com.mortals.framework.util.DateUtils;
import com.mortals.xhx.base.system.user.model.UserEntity; import com.mortals.xhx.base.system.user.model.UserEntity;
import com.mortals.xhx.common.code.AttendSourceTypeEnum;
import com.mortals.xhx.common.code.TypeEnum;
import com.mortals.xhx.common.code.YesNoEnum; import com.mortals.xhx.common.code.YesNoEnum;
import com.mortals.xhx.common.key.RedisKey; import com.mortals.xhx.common.key.RedisKey;
import com.mortals.xhx.module.attendance.model.AttendanceRecordHikEntity; import com.mortals.xhx.module.attendance.model.AttendanceRecordHikEntity;
import com.mortals.xhx.module.attendance.model.AttendanceRecordHikQuery; import com.mortals.xhx.module.attendance.model.AttendanceRecordHikQuery;
import com.mortals.xhx.module.attendance.service.AttendanceRecordHikService; import com.mortals.xhx.module.attendance.service.AttendanceRecordHikService;
import com.mortals.xhx.module.attendance.service.work.FixWorkOtherAttendance;
import com.mortals.xhx.module.attendance.service.work.FreedomWorkAttendance;
import com.mortals.xhx.module.dingding.attendance.service.IDingAttenanceService;
import com.mortals.xhx.module.door.model.DoorEntity; import com.mortals.xhx.module.door.model.DoorEntity;
import com.mortals.xhx.module.door.model.DoorQuery; import com.mortals.xhx.module.door.model.DoorQuery;
import com.mortals.xhx.module.door.service.DoorService; import com.mortals.xhx.module.door.service.DoorService;
...@@ -54,8 +59,13 @@ public class SyncDoorsEventTaskImpl implements ITaskExcuteService { ...@@ -54,8 +59,13 @@ public class SyncDoorsEventTaskImpl implements ITaskExcuteService {
@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;
@Autowired
private IDingAttenanceService dingAttenanceService;
@Override @Override
public void excuteTask(ITask task) throws AppException { public void excuteTask(ITask task) throws AppException {
...@@ -76,7 +86,31 @@ public class SyncDoorsEventTaskImpl implements ITaskExcuteService { ...@@ -76,7 +86,31 @@ public class SyncDoorsEventTaskImpl implements ITaskExcuteService {
hikQuery.setAttendanceDateStart(startTime.toDateStr()); hikQuery.setAttendanceDateStart(startTime.toDateStr());
// 获取当天的结束时间 // 获取当天的结束时间
hikQuery.setAttendanceDateEnd(DateUtil.today()); hikQuery.setAttendanceDateEnd(DateUtil.today());
if (!ObjectUtils.isEmpty(hikhost)) {
//todo 根据配置 判断是否海康门禁 钉钉考勤等
if (AttendSourceTypeEnum.海康云平台.getValue().equals(sourceType)) {
//海康云平台
log.info("同步海康云平台门禁事件!");
recordHikService.syncDoorEvents(hikQuery);
} else if (AttendSourceTypeEnum.海康考勤机.getValue().equals(sourceType)) {
//海康考勤机
log.info("同步海康设备上门禁事件!");
HikDoorEventReq hikDoorEventReq = new HikDoorEventReq();
hikDoorEventReq.setStartTime(DateUtil.parseDate(startTime.toDateStr()).toJdkDate());
hikDoorEventReq.setEndTime(DateUtil.endOfDay(new Date()));
List<DoorEntity> doorEntities = doorService.find(new DoorQuery());
for (DoorEntity doorEntity : doorEntities) {
doorService.syncDoorDeviceEvents(doorEntity, hikDoorEventReq);
}
} else if (AttendSourceTypeEnum.钉钉.getValue().equals(sourceType)) {
//钉钉
log.info("同步钉钉考勤事件!");
recordHikService.syncDoorEventsFromDingTalk(hikQuery);
}else {
log.info("未配置考勤源类型!");
}
/* if (!ObjectUtils.isEmpty(hikhost)) {
recordHikService.syncDoorEvents(hikQuery); recordHikService.syncDoorEvents(hikQuery);
} else { } else {
log.info("同步设备上门禁事件!"); log.info("同步设备上门禁事件!");
...@@ -87,7 +121,7 @@ public class SyncDoorsEventTaskImpl implements ITaskExcuteService { ...@@ -87,7 +121,7 @@ public class SyncDoorsEventTaskImpl implements ITaskExcuteService {
for (DoorEntity doorEntity : doorEntities) { for (DoorEntity doorEntity : doorEntities) {
doorService.syncDoorDeviceEvents(doorEntity, hikDoorEventReq); doorService.syncDoorDeviceEvents(doorEntity, hikDoorEventReq);
} }
} }*/
} }
} }
......
...@@ -8,6 +8,7 @@ import com.mortals.framework.service.ICacheService; ...@@ -8,6 +8,7 @@ import com.mortals.framework.service.ICacheService;
import com.mortals.framework.service.ITask; import com.mortals.framework.service.ITask;
import com.mortals.framework.service.ITaskExcuteService; import com.mortals.framework.service.ITaskExcuteService;
import com.mortals.framework.util.ThreadPool; import com.mortals.framework.util.ThreadPool;
import com.mortals.xhx.common.code.AttendSourceTypeEnum;
import com.mortals.xhx.common.utils.AddAttendThread; import com.mortals.xhx.common.utils.AddAttendThread;
import com.mortals.xhx.module.attendance.model.AttendanceLeaveRecordQuery; import com.mortals.xhx.module.attendance.model.AttendanceLeaveRecordQuery;
import com.mortals.xhx.module.attendance.model.AttendanceRecordHikQuery; import com.mortals.xhx.module.attendance.model.AttendanceRecordHikQuery;
...@@ -44,8 +45,8 @@ public class SyncDoorsEventWeekTaskImpl implements ITaskExcuteService { ...@@ -44,8 +45,8 @@ public class SyncDoorsEventWeekTaskImpl implements ITaskExcuteService {
private DoorService doorService; private DoorService doorService;
@Autowired @Autowired
private ICacheService cacheService; private ICacheService cacheService;
@Value("${source.type:''}")
protected String sourceType;
@Value("${dingtalk.domain:}") @Value("${dingtalk.domain:}")
protected String domain; protected String domain;
...@@ -60,12 +61,59 @@ public class SyncDoorsEventWeekTaskImpl implements ITaskExcuteService { ...@@ -60,12 +61,59 @@ public class SyncDoorsEventWeekTaskImpl implements ITaskExcuteService {
AttendanceRecordHikQuery hikEntity = new AttendanceRecordHikQuery(); AttendanceRecordHikQuery hikEntity = new AttendanceRecordHikQuery();
hikEntity.setAttendanceDateStart(DateUtil.format(weekStart, "yyyy-MM-dd")); hikEntity.setAttendanceDateStart(DateUtil.format(weekStart, "yyyy-MM-dd"));
hikEntity.setAttendanceDateEnd(DateUtil.today()); hikEntity.setAttendanceDateEnd(DateUtil.today());
//天数区间分段计算 //天数区间分段计算
DateTime attendStart = DateUtil.parseDate(hikEntity.getAttendanceDateStart()); DateTime attendStart = DateUtil.parseDate(hikEntity.getAttendanceDateStart());
DateTime attendEnd = DateUtil.parseDate(hikEntity.getAttendanceDateEnd()); DateTime attendEnd = DateUtil.parseDate(hikEntity.getAttendanceDateEnd());
Long compare = DateUtil.between(attendEnd, attendStart, DateUnit.DAY); Long compare = DateUtil.between(attendEnd, attendStart, DateUnit.DAY);
if (!ObjectUtils.isEmpty(hikhost)) {
//todo 根据配置 判断是否海康门禁 钉钉考勤等
if (AttendSourceTypeEnum.海康云平台.getValue().equals(sourceType)) {
//海康云平台
log.info("同步海康云平台门禁事件!");
StopWatch stopWatch = new StopWatch("stopwatch attend1");
log.info("考勤计算天数区间:{}", compare);
for (int i = 0; i <= compare.intValue(); i++) {
DateTime curDate = DateUtil.offsetDay(attendStart, i);
log.info("考勤计算日期:{}", curDate.toDateStr());
stopWatch.start("执行本地方法");
hikEntity.setAttendanceDateStart(curDate.toDateStr());
hikEntity.setAttendanceDateEnd(curDate.toDateStr());
recordHikService.syncDoorEvents(hikEntity);
recordHikService.deletFakeRecord(hikEntity, null);
stopWatch.stop();
log.info("考勤计算日期:{} 完成,耗时:{}ms", curDate.toDateStr(), stopWatch.getLastTaskTimeMillis());
}
} else if (AttendSourceTypeEnum.海康考勤机.getValue().equals(sourceType)) {
//海康考勤机
log.info("同步海康设备上门禁事件!");
StopWatch stopWatch = new StopWatch("stopwatch attend1");
log.info("考勤计算天数区间:{}", compare);
for (int i = 0; i <= compare.intValue(); i++) {
DateTime curDate = DateUtil.offsetDay(attendStart, i);
log.info("考勤计算日期:{}", curDate.toDateStr());
stopWatch.start("执行本地方法");
HikDoorEventReq hikDoorEventReq = new HikDoorEventReq();
hikDoorEventReq.setStartTime(curDate.toJdkDate());
hikDoorEventReq.setEndTime(curDate.toJdkDate());
List<DoorEntity> doorEntities = doorService.find(new DoorQuery());
for (DoorEntity doorEntity : doorEntities) {
doorService.syncDoorDeviceEvents(doorEntity, hikDoorEventReq);
}
hikEntity.setAttendanceDateStart(curDate.toDateStr());
hikEntity.setAttendanceDateEnd(curDate.toDateStr());
recordHikService.deletFakeRecord(hikEntity, null);
stopWatch.stop();
log.info("考勤计算日期:{} 完成,耗时:{}ms", curDate.toDateStr(), stopWatch.getLastTaskTimeMillis());
}
} else if (AttendSourceTypeEnum.钉钉.getValue().equals(sourceType)) {
//钉钉
log.info("同步钉钉考勤事件!");
}else {
log.info("未配置考勤源类型!");
}
/* if (!ObjectUtils.isEmpty(hikhost)) {
log.info("同步海康云主机"); log.info("同步海康云主机");
StopWatch stopWatch = new StopWatch("stopwatch attend1"); StopWatch stopWatch = new StopWatch("stopwatch attend1");
log.info("考勤计算天数区间:{}", compare); log.info("考勤计算天数区间:{}", compare);
...@@ -106,7 +154,7 @@ public class SyncDoorsEventWeekTaskImpl implements ITaskExcuteService { ...@@ -106,7 +154,7 @@ public class SyncDoorsEventWeekTaskImpl implements ITaskExcuteService {
log.info("考勤计算日期:{} 完成,耗时:{}ms", curDate.toDateStr(), stopWatch.getLastTaskTimeMillis()); log.info("考勤计算日期:{} 完成,耗时:{}ms", curDate.toDateStr(), stopWatch.getLastTaskTimeMillis());
} }
} }*/
log.info("开始计算及统计最近7天考勤!"); log.info("开始计算及统计最近7天考勤!");
String expire = cacheService.get(KEY_ATTENDANCE_STAT_LOCK_CACHE); String expire = cacheService.get(KEY_ATTENDANCE_STAT_LOCK_CACHE);
if (ObjectUtils.isEmpty(expire)) { if (ObjectUtils.isEmpty(expire)) {
......
...@@ -44,6 +44,9 @@ public class SyncRegisterUserPicTaskImpl implements ITaskExcuteService { ...@@ -44,6 +44,9 @@ public class SyncRegisterUserPicTaskImpl implements ITaskExcuteService {
@Autowired @Autowired
private DoorService doorService; private DoorService doorService;
@Value("${source.type:''}")
protected String sourceType;
@Override @Override
public void excuteTask(ITask task) throws AppException { public void excuteTask(ITask task) throws AppException {
......
package com.mortals.xhx.daemon.task; package com.mortals.xhx.daemon.task;
import cn.hutool.core.date.DateUtil;
import com.mortals.framework.common.Rest; import com.mortals.framework.common.Rest;
import com.mortals.framework.exception.AppException; import com.mortals.framework.exception.AppException;
import com.mortals.framework.service.ITask; import com.mortals.framework.service.ITask;
...@@ -7,6 +8,7 @@ import com.mortals.framework.service.ITaskExcuteService; ...@@ -7,6 +8,7 @@ import com.mortals.framework.service.ITaskExcuteService;
import com.mortals.xhx.base.system.user.model.UserEntity; import com.mortals.xhx.base.system.user.model.UserEntity;
import com.mortals.xhx.base.system.user.model.UserQuery; import com.mortals.xhx.base.system.user.model.UserQuery;
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.YesNoEnum; import com.mortals.xhx.common.code.YesNoEnum;
import com.mortals.xhx.module.attendance.service.AttendanceStatService; import com.mortals.xhx.module.attendance.service.AttendanceStatService;
import com.mortals.xhx.module.attendance.service.AttendanceVacationBalanceService; import com.mortals.xhx.module.attendance.service.AttendanceVacationBalanceService;
...@@ -14,6 +16,9 @@ import com.mortals.xhx.module.dept.model.DeptEntity; ...@@ -14,6 +16,9 @@ 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.service.DeptService; import com.mortals.xhx.module.dept.service.DeptService;
import com.mortals.xhx.module.dingding.personal.service.IDingPersonService; import com.mortals.xhx.module.dingding.personal.service.IDingPersonService;
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.hik.person.model.req.org.OrgListReq; import com.mortals.xhx.module.hik.person.model.req.org.OrgListReq;
import com.mortals.xhx.module.hik.person.model.rsp.org.OrgDataInfo; import com.mortals.xhx.module.hik.person.model.rsp.org.OrgDataInfo;
import com.mortals.xhx.module.hik.person.model.rsp.org.OrgInfo; import com.mortals.xhx.module.hik.person.model.rsp.org.OrgInfo;
...@@ -32,7 +37,7 @@ import java.util.List; ...@@ -32,7 +37,7 @@ import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
* 同步海康用户 * 同步用户
*/ */
@Slf4j @Slf4j
@Service("SyncUserTask") @Service("SyncUserTask")
...@@ -49,8 +54,72 @@ public class SyncUserTaskImpl implements ITaskExcuteService { ...@@ -49,8 +54,72 @@ public class SyncUserTaskImpl implements ITaskExcuteService {
@Value("${hik.host:}") @Value("${hik.host:}")
protected String hikhost; protected String hikhost;
@Value("${source.type:''}")
protected String sourceType;
@Override @Override
public void excuteTask(ITask task) throws AppException { public void excuteTask(ITask task) throws AppException {
if (AttendSourceTypeEnum.海康云平台.getValue().equals(sourceType)) {
log.info("同步部门");
deptService.syncDept(null);
log.info("同步用户");
staffService.syncPersons(null);
log.info("同步钉钉usreId");
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());
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);
if (!ObjectUtils.isEmpty(personByMobile) &&
YesNoEnum.YES.getValue() == personByMobile.getCode()
&& !ObjectUtils.isEmpty(personByMobile.getData())) {
userEntity.setDingUserId(personByMobile.getData());
}
}
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失败");
}
} 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 { try {
if (!ObjectUtils.isEmpty(hikhost)) { if (!ObjectUtils.isEmpty(hikhost)) {
log.info("同步部门"); log.info("同步部门");
...@@ -102,7 +171,7 @@ public class SyncUserTaskImpl implements ITaskExcuteService { ...@@ -102,7 +171,7 @@ public class SyncUserTaskImpl implements ITaskExcuteService {
} }
} catch (Exception e) { } catch (Exception e) {
log.error("同步人事异常", e); log.error("同步人事异常", e);
} }*/
} }
@Override @Override
......
...@@ -169,7 +169,7 @@ public class AttendanceGroupStaffEntity extends AttendanceGroupStaffVo { ...@@ -169,7 +169,7 @@ public class AttendanceGroupStaffEntity extends AttendanceGroupStaffVo {
this.staffName = ""; this.staffName = "";
this.partAttendance = null; this.partAttendance = 1;
this.remark = ""; this.remark = "";
} }
......
...@@ -11,4 +11,7 @@ import com.mortals.xhx.module.attendance.model.AttendanceClassEntity; ...@@ -11,4 +11,7 @@ import com.mortals.xhx.module.attendance.model.AttendanceClassEntity;
*/ */
public interface AttendanceClassService extends ICRUDService<AttendanceClassEntity,Long>{ public interface AttendanceClassService extends ICRUDService<AttendanceClassEntity,Long>{
} }
\ No newline at end of file
...@@ -26,15 +26,12 @@ public interface AttendanceRecordHikService extends ICRUDService<AttendanceRecor ...@@ -26,15 +26,12 @@ public interface AttendanceRecordHikService extends ICRUDService<AttendanceRecor
*/ */
void addAttendanceRecordByQuery(AttendanceRecordHikEntity attendanceRecordHikQuery, Context context) throws Exception; void addAttendanceRecordByQuery(AttendanceRecordHikEntity attendanceRecordHikQuery, Context context) throws Exception;
/** /**
* 根据查询条件生成打卡记录 排除节假日 * 根据查询条件生成打卡记录 排除节假日
* @param attendanceRecordHikQuery * @param attendanceRecordHikQuery
*/ */
void addAttendanceRecordByQueryCustom(AttendanceRecordHikEntity attendanceRecordHikQuery, Context context) throws Exception; void addAttendanceRecordByQueryCustom(AttendanceRecordHikEntity attendanceRecordHikQuery, Context context) throws Exception;
/** /**
* 根据查询条件生成打卡记录 * 根据查询条件生成打卡记录
* @param hikEntity * @param hikEntity
...@@ -65,12 +62,31 @@ public interface AttendanceRecordHikService extends ICRUDService<AttendanceRecor ...@@ -65,12 +62,31 @@ public interface AttendanceRecordHikService extends ICRUDService<AttendanceRecor
*/ */
void buildAllCustomHikRecord(AttendanceRecordHikQuery recordHikQuery,Context context); void buildAllCustomHikRecord(AttendanceRecordHikQuery recordHikQuery,Context context);
/**
* 根据查询条件生成打卡记录
* @param recordHikQuery
* @param context
* @return
*/
Rest<Integer> buildSourceHikRecord(AttendanceRecordHikQuery recordHikQuery, Context context); Rest<Integer> buildSourceHikRecord(AttendanceRecordHikQuery recordHikQuery, Context context);
/**
* 删除虚增考勤记录
* @param recordHikQuery
* @param context
*/
void deletFakeRecord(AttendanceRecordHikQuery recordHikQuery, Context context); void deletFakeRecord(AttendanceRecordHikQuery recordHikQuery, Context context);
/**
* 从海康同步考勤门禁事件
* @param recordHikQuery
*/
void syncDoorEvents(AttendanceRecordHikQuery recordHikQuery); void syncDoorEvents(AttendanceRecordHikQuery recordHikQuery);
/**
* 从钉钉同步考勤门禁事件
* @param recordHikQuery
*/
void syncDoorEventsFromDingTalk(AttendanceRecordHikQuery recordHikQuery);
} }
...@@ -65,4 +65,10 @@ public class AttendanceClassServiceImpl extends AbstractCRUDServiceImpl<Attendan ...@@ -65,4 +65,10 @@ public class AttendanceClassServiceImpl extends AbstractCRUDServiceImpl<Attendan
attendanceClassDetailService.removeList(attendanceClassDetaillist, context); attendanceClassDetailService.removeList(attendanceClassDetaillist, context);
super.removeAfter(ids, context, result); super.removeAfter(ids, context, result);
} }
} }
\ No newline at end of file
...@@ -4,14 +4,17 @@ import cn.hutool.core.date.DateUtil; ...@@ -4,14 +4,17 @@ import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.PageUtil; import cn.hutool.core.util.PageUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.dingtalk.api.response.OapiAttendanceListResponse;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.mortals.framework.common.Rest; import com.mortals.framework.common.Rest;
import com.mortals.framework.model.PageInfo;
import com.mortals.framework.util.StringUtils; import com.mortals.framework.util.StringUtils;
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.service.*; import com.mortals.xhx.module.attendance.service.*;
import com.mortals.xhx.module.attendance.service.work.AttendanceWorkAbstract; import com.mortals.xhx.module.attendance.service.work.AttendanceWorkAbstract;
import com.mortals.xhx.module.attendance.service.work.CommonData; import com.mortals.xhx.module.attendance.service.work.CommonData;
import com.mortals.xhx.module.dingding.attendance.service.IDingAttenanceService;
import com.mortals.xhx.module.hik.door.model.req.door.DoorEventReq; import com.mortals.xhx.module.hik.door.model.req.door.DoorEventReq;
import com.mortals.xhx.module.hik.door.model.rsp.door.DoorEventDataInfo; import com.mortals.xhx.module.hik.door.model.rsp.door.DoorEventDataInfo;
import com.mortals.xhx.module.hik.door.service.IHikDoorService; import com.mortals.xhx.module.hik.door.service.IHikDoorService;
...@@ -71,6 +74,10 @@ public class AttendanceRecordHikServiceImpl extends AbstractCRUDServiceImpl<Atte ...@@ -71,6 +74,10 @@ public class AttendanceRecordHikServiceImpl extends AbstractCRUDServiceImpl<Atte
@Autowired @Autowired
private AttendanceGroupFixedworkSpecialService specialService; private AttendanceGroupFixedworkSpecialService specialService;
@Autowired
private IDingAttenanceService dingAttenanceService;
@Override @Override
public void addAttendanceRecord(AttendanceRecordHikEntity hikEntity, Context context) throws Exception { public void addAttendanceRecord(AttendanceRecordHikEntity hikEntity, Context context) throws Exception {
List<AttendanceRecordHikEntity> hikEntityList = new ArrayList<>(); List<AttendanceRecordHikEntity> hikEntityList = new ArrayList<>();
...@@ -112,12 +119,6 @@ public class AttendanceRecordHikServiceImpl extends AbstractCRUDServiceImpl<Atte ...@@ -112,12 +119,6 @@ public class AttendanceRecordHikServiceImpl extends AbstractCRUDServiceImpl<Atte
Map<Long, AttendanceClassDetailEntity> classDetailEntityMap = attendanceClassDetailService.find(new AttendanceClassDetailQuery()).parallelStream().collect(Collectors.toMap(x -> x.getId(), y -> y, (o, n) -> n)); Map<Long, AttendanceClassDetailEntity> classDetailEntityMap = attendanceClassDetailService.find(new AttendanceClassDetailQuery()).parallelStream().collect(Collectors.toMap(x -> x.getId(), y -> y, (o, n) -> n));
Map<Long, List<AttendanceGroupFixedworkSpecialEntity>> fixedSpecialGroupMap = specialService.find(new AttendanceGroupFixedworkSpecialEntity()).parallelStream().collect(Collectors.groupingBy(x -> x.getFixedWorkId())); Map<Long, List<AttendanceGroupFixedworkSpecialEntity>> fixedSpecialGroupMap = specialService.find(new AttendanceGroupFixedworkSpecialEntity()).parallelStream().collect(Collectors.groupingBy(x -> x.getFixedWorkId()));
//获取当日未处理异常记录
/* AttendanceRecordErrorQuery attendanceRecordErrorQuery = new AttendanceRecordErrorQuery();
attendanceRecordErrorQuery.setErrorDateTimeStart(attendanceRecordHikQuery.getAttendanceDateStart());
attendanceRecordErrorQuery.setErrorDateTimeEnd(attendanceRecordErrorQuery.getActualAttendanceDateTimeEnd());
Map<Long, List<AttendanceRecordErrorEntity>> errorGroupStaffMap = errorService.find(attendanceRecordErrorQuery).parallelStream().collect(Collectors.groupingBy(x -> x.getStaffId()));
*/
String attendanceDateStart = attendanceRecordHikQuery.getAttendanceDateStart(); String attendanceDateStart = attendanceRecordHikQuery.getAttendanceDateStart();
String attendanceDateEnd = attendanceRecordHikQuery.getAttendanceDateEnd(); String attendanceDateEnd = attendanceRecordHikQuery.getAttendanceDateEnd();
...@@ -262,13 +263,13 @@ public class AttendanceRecordHikServiceImpl extends AbstractCRUDServiceImpl<Atte ...@@ -262,13 +263,13 @@ public class AttendanceRecordHikServiceImpl extends AbstractCRUDServiceImpl<Atte
} }
if (!ObjectUtils.isEmpty(updateList)) { if (!ObjectUtils.isEmpty(updateList)) {
if(updateList.size()>100){ if (updateList.size() > 100) {
List<List<AttendanceRecordEntity>> partition = Lists.partition(updateList, 30); List<List<AttendanceRecordEntity>> partition = Lists.partition(updateList, 30);
for (List<AttendanceRecordEntity> attendanceRecordEntities : partition) { for (List<AttendanceRecordEntity> attendanceRecordEntities : partition) {
log.info("更新考勤记录数:" + attendanceRecordEntities.size()); log.info("更新考勤记录数:" + attendanceRecordEntities.size());
attendanceRecordService.update(attendanceRecordEntities); attendanceRecordService.update(attendanceRecordEntities);
} }
}else{ } else {
log.info("更新考勤记录数:" + updateList.size()); log.info("更新考勤记录数:" + updateList.size());
attendanceRecordService.update(updateList); attendanceRecordService.update(updateList);
} }
...@@ -311,7 +312,12 @@ public class AttendanceRecordHikServiceImpl extends AbstractCRUDServiceImpl<Atte ...@@ -311,7 +312,12 @@ public class AttendanceRecordHikServiceImpl extends AbstractCRUDServiceImpl<Atte
//获取考勤打卡时间 //获取考勤打卡时间
Date attendanceDate = item.getAttendanceDate(); Date attendanceDate = item.getAttendanceDate();
//通过工号查询员工信息 //通过工号查询员工信息
StaffEntity staffEntity = staffService.getExtCache(StrUtil.padPre(item.getWorkNum(), 8, "0")); String workNum1 = item.getWorkNum();
if (item.getWorkNum().length() < 8) {
workNum1 = StrUtil.padPre(item.getWorkNum(), 8, "0");
}
StaffEntity staffEntity = staffService.getExtCache(workNum1);
//StaffEntity staffEntity = staffService.getExtCache(StrUtil.padPre(item.getWorkNum(), 8, "0"));
if (ObjectUtils.isEmpty(staffEntity)) { if (ObjectUtils.isEmpty(staffEntity)) {
log.info("staffEntity is null ,workNum:{}", StrUtil.padPre(item.getWorkNum(), 8, "0")); log.info("staffEntity is null ,workNum:{}", StrUtil.padPre(item.getWorkNum(), 8, "0"));
continue; continue;
...@@ -675,27 +681,6 @@ public class AttendanceRecordHikServiceImpl extends AbstractCRUDServiceImpl<Atte ...@@ -675,27 +681,6 @@ public class AttendanceRecordHikServiceImpl extends AbstractCRUDServiceImpl<Atte
public void deletFakeRecord(AttendanceRecordHikQuery recordHikQuery, Context context) { public void deletFakeRecord(AttendanceRecordHikQuery recordHikQuery, Context context) {
//重新拉去的考勤记录,判断是否存在虚增的记录 //重新拉去的考勤记录,判断是否存在虚增的记录
log.info("开始删除虚增的记录!"); log.info("开始删除虚增的记录!");
return;
//只删除多条重复的记录
/* recordHikQuery.setEventSource("当日未有记录虚增考勤记录!");
List<AttendanceRecordHikEntity> fackAttendlist = this.find(recordHikQuery);
if (!ObjectUtils.isEmpty(fackAttendlist)) {
log.info("虚增的记录:{}", fackAttendlist.size());
for (AttendanceRecordHikEntity recordHikEntity : fackAttendlist) {
//判断是否已经重新有新的当日数据,如果有 则删除当前虚增记录
AttendanceRecordHikQuery query = new AttendanceRecordHikQuery();
query.setStaffId(recordHikEntity.getStaffId());
query.setAttendanceDateStart(recordHikEntity.getAttendanceDateStart());
query.setAttendanceDateEnd(recordHikQuery.getAttendanceDateEnd());
query.setIdNotList(Arrays.asList(recordHikEntity.getId()));
int count = this.count(query, context);
if (count > 0) {
//删除当前虚增的记录
log.info("删除虚增的记录:{}", recordHikEntity.getId());
this.remove(recordHikEntity.getId(), context);
}
}
}*/
} }
public void syncDoorEvents(AttendanceRecordHikQuery recordHikQuery) { public void syncDoorEvents(AttendanceRecordHikQuery recordHikQuery) {
...@@ -741,6 +726,92 @@ public class AttendanceRecordHikServiceImpl extends AbstractCRUDServiceImpl<Atte ...@@ -741,6 +726,92 @@ public class AttendanceRecordHikServiceImpl extends AbstractCRUDServiceImpl<Atte
} }
} }
/**
* 同步钉钉
*
* @param hikQuery
*/
@Override
public void syncDoorEventsFromDingTalk(AttendanceRecordHikQuery hikQuery) {
PageInfo pageInfo = new PageInfo();
pageInfo.setBeginIndex(0);
pageInfo.setPrePageResult(50);
List<String> userLists = staffService.find(new StaffQuery()).stream().map(i -> i.getWorkNum()).collect(Collectors.toList());
List<List<String>> partition = Lists.partition(userLists, 10);
for (List<String> userList : partition) {
hikQuery.setAttendanceDateStart(DateUtil.parseDate(hikQuery.getAttendanceDateStart()).toString());
hikQuery.setAttendanceDateEnd(DateUtil.parseDate(hikQuery.getAttendanceDateEnd()).toString());
Rest<List<OapiAttendanceListResponse.Recordresult>> rest = dingAttenanceService.getAttendanceList(pageInfo, userList, hikQuery);
if (rest.getCode() == YesNoEnum.YES.getValue()) {
List<AttendanceRecordHikEntity> attendanceList = rest.getData().stream().map(item -> {
AttendanceRecordHikEntity recordHikEntity = new AttendanceRecordHikEntity();
recordHikEntity.initAttrValue();
if (ObjectUtils.isEmpty(item.getUserId())) {
log.info("jobNo is null ==>{}", JSON.toJSONString(item));
return null;
}
String workNum = item.getUserId();
if(item.getUserId().length()<8){
workNum = StrUtil.padPre(item.getUserId(), 8, "0");
}
StaffEntity staffCache = staffService.getExtCache(workNum);
// StaffEntity staffCache = staffService.getExtCache(StrUtil.padPre(item.getUserId(), 8, "0"));
if (ObjectUtils.isEmpty(staffCache)) {
log.info("staff is null !worknum:{}", item.getUserId());
return null;
}
recordHikEntity.setStaffId(staffCache.getId());
recordHikEntity.setStaffName(staffCache.getName());
recordHikEntity.setWorkNum(staffCache.getWorkNum());
recordHikEntity.setDeptId(staffCache.getDeptId());
recordHikEntity.setDeptName(staffCache.getDeptName());
recordHikEntity.setSalaId(staffCache.getSalaId());
recordHikEntity.setSalaName(staffCache.getSalaName());
recordHikEntity.setPositionId(staffCache.getPositionId());
recordHikEntity.setPositionName(staffCache.getPositionName());
recordHikEntity.setAttendanceDate(item.getUserCheckTime());
//recordHikEntity.setAttendanceAddress(item.getDoorName());
recordHikEntity.setEventSource("钉钉");
recordHikEntity.setRemark(item.getTimeResult());
recordHikEntity.setCreateTime(new Date());
recordHikEntity.setCreateUserName("系统管理员");
recordHikEntity.setCreateUserId(1L);
return recordHikEntity;
}).filter(f -> f != null).collect(Collectors.toList());
if (!ObjectUtils.isEmpty(attendanceList)) {
//单个插入 去掉重复时间段的打卡记录
for (AttendanceRecordHikEntity recordHikEntity : attendanceList) {
try {
this.getDao().insert(recordHikEntity);
} catch (Exception e) {
//log.error("基础考勤数据保存异常", e.getMessage());
}
}
}
log.info("saveRecordList size:{}", attendanceList.size());
} else {
log.info("fail" + rest.getMsg());
}
}
}
private void getDoorEvents(Rest<DoorEventDataInfo> doorEventsRest, DoorEventReq doorEventReq) { private void getDoorEvents(Rest<DoorEventDataInfo> doorEventsRest, DoorEventReq doorEventReq) {
//同步当前考勤数据 //同步当前考勤数据
List<AttendanceRecordHikEntity> attRecords = doorEventsRest.getData().getList().stream().map(item -> { List<AttendanceRecordHikEntity> attRecords = doorEventsRest.getData().getList().stream().map(item -> {
...@@ -751,7 +822,13 @@ public class AttendanceRecordHikServiceImpl extends AbstractCRUDServiceImpl<Atte ...@@ -751,7 +822,13 @@ public class AttendanceRecordHikServiceImpl extends AbstractCRUDServiceImpl<Atte
log.info("jobNo is null ==>{}", JSON.toJSONString(item)); log.info("jobNo is null ==>{}", JSON.toJSONString(item));
return null; return null;
} }
StaffEntity staffCache = staffService.getExtCache(StrUtil.padPre(item.getJobNo(), 8, "0"));
String workNum = item.getJobNo();
if(item.getJobNo().length()<8){
workNum = StrUtil.padPre(item.getJobNo(), 8, "0");
}
StaffEntity staffCache = staffService.getExtCache(workNum);
// StaffEntity staffCache = staffService.getExtCache(StrUtil.padPre(item.getJobNo(), 8, "0"));
if (ObjectUtils.isEmpty(staffCache)) { if (ObjectUtils.isEmpty(staffCache)) {
log.info("staff is null !staffCode:{}", item.getJobNo()); log.info("staff is null !staffCode:{}", item.getJobNo());
return null; return null;
......
package com.mortals.xhx.module.dept.service; package com.mortals.xhx.module.dept.service;
import com.dingtalk.api.response.OapiV2DepartmentListsubResponse;
import com.mortals.framework.common.Rest; import com.mortals.framework.common.Rest;
import com.mortals.framework.exception.AppException; import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context; import com.mortals.framework.model.Context;
...@@ -99,4 +100,9 @@ public interface DeptService extends ICRUDService<DeptEntity, Long> { ...@@ -99,4 +100,9 @@ public interface DeptService extends ICRUDService<DeptEntity, Long> {
*/ */
Rest<String> syncDeptByDevice(Context context); Rest<String> syncDeptByDevice(Context context);
Rest<String> syncDeptByDingTalk(Context context);
void saveSubDepts(Rest<List<OapiV2DepartmentListsubResponse.DeptBaseResponse>> depts);
} }
\ No newline at end of file
package com.mortals.xhx.module.dept.service.impl; package com.mortals.xhx.module.dept.service.impl;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.dingtalk.api.response.OapiV2DepartmentListsubResponse;
import com.mortals.framework.common.Rest; import com.mortals.framework.common.Rest;
import com.mortals.xhx.common.code.EnableEnum; import com.mortals.xhx.common.code.EnableEnum;
import com.mortals.xhx.common.code.EnabledEnum; import com.mortals.xhx.common.code.EnabledEnum;
import com.mortals.xhx.common.code.StaffSatusEnum; import com.mortals.xhx.common.code.StaffSatusEnum;
import com.mortals.xhx.common.code.YesNoEnum; import com.mortals.xhx.common.code.YesNoEnum;
import com.mortals.xhx.module.dingding.personal.service.IDingPersonService;
import com.mortals.xhx.module.hik.person.model.req.org.OrgListReq; import com.mortals.xhx.module.hik.person.model.req.org.OrgListReq;
import com.mortals.xhx.module.hik.person.model.rsp.org.OrgDataInfo; import com.mortals.xhx.module.hik.person.model.rsp.org.OrgDataInfo;
import com.mortals.xhx.module.hik.person.model.rsp.org.OrgInfo; import com.mortals.xhx.module.hik.person.model.rsp.org.OrgInfo;
...@@ -48,6 +50,9 @@ public class DeptServiceImpl extends AbstractCRUDServiceImpl<DeptDao, DeptEntity ...@@ -48,6 +50,9 @@ public class DeptServiceImpl extends AbstractCRUDServiceImpl<DeptDao, DeptEntity
@Autowired @Autowired
private IHikPersonService hikPersonService; private IHikPersonService hikPersonService;
@Autowired
private IDingPersonService dingPersonService;
@Override @Override
protected void saveBefore(DeptEntity entity, Context context) throws AppException { protected void saveBefore(DeptEntity entity, Context context) throws AppException {
if (ObjectUtils.isEmpty(entity.getParentId())) { if (ObjectUtils.isEmpty(entity.getParentId())) {
...@@ -373,4 +378,57 @@ public class DeptServiceImpl extends AbstractCRUDServiceImpl<DeptDao, DeptEntity ...@@ -373,4 +378,57 @@ public class DeptServiceImpl extends AbstractCRUDServiceImpl<DeptDao, DeptEntity
return Rest.ok(); return Rest.ok();
} }
@Override
public Rest<String> syncDeptByDingTalk(Context context) {
Rest<List<OapiV2DepartmentListsubResponse.DeptBaseResponse>> depts = dingPersonService.getDepts(null);
saveSubDepts(depts);
return Rest.ok();
}
@Override
public void saveSubDepts(Rest<List<OapiV2DepartmentListsubResponse.DeptBaseResponse>> depts) {
if (depts.getCode() == YesNoEnum.YES.getValue()) {
List<OapiV2DepartmentListsubResponse.DeptBaseResponse> data = depts.getData();
for (OapiV2DepartmentListsubResponse.DeptBaseResponse dept : data) {
String name = dept.getName();
Long parentId = dept.getParentId();
Long deptId = dept.getDeptId();
DeptEntity deptEntity = this.selectOne(new DeptQuery().deptCode(deptId.toString()));
DeptEntity deptEntityParent = this.selectOne(new DeptQuery().deptCode(parentId.toString()));
//新增
if (ObjectUtils.isEmpty(deptEntity)) {
deptEntity = new DeptEntity();
deptEntity.initAttrValue();
if (!ObjectUtils.isEmpty(deptEntityParent)) {
deptEntity.setParentId(deptEntityParent.getId());
}
deptEntity.setDeptName(name);
deptEntity.setDeptCode(deptId.toString());
// deptEntity.setRemark(orgInfo.getParentOrgIndexCode());
deptEntity.setCreateTime(new Date());
deptEntity.setCreateUserId(1L);
this.save(deptEntity);
} else {
//更新
deptEntity.setDeptName(name);
deptEntity.setDeptCode(deptId.toString());
// deptEntity.setAncestors(orgInfo.getOrgPath());
deptEntity.setUpdateTime(new Date());
deptEntity.setUpdateUserId(1L);
this.update(deptEntity);
}
Boolean createDeptGroup = dept.getCreateDeptGroup();//是否有子部门
if (createDeptGroup) {
//存在子部门 继续调用
Rest<List<OapiV2DepartmentListsubResponse.DeptBaseResponse>> deptSub = dingPersonService.getDepts(deptId);
saveSubDepts(deptSub);
}
}
}
}
} }
...@@ -26,7 +26,7 @@ import java.util.Map; ...@@ -26,7 +26,7 @@ import java.util.Map;
* @date: 2023/7/14 13:49 * @date: 2023/7/14 13:49
*/ */
@Slf4j @Slf4j
public abstract class AbstractDingTalkService implements IDingPersonService { public abstract class AbstractDingTalkService implements IDingTalkService {
/** /**
* AgentId * AgentId
......
package com.mortals.xhx.module.dingding.attendance.service;
import com.dingtalk.api.response.*;
import com.mortals.framework.common.Rest;
import com.mortals.framework.model.PageInfo;
import com.mortals.xhx.module.attendance.model.AttendanceRecordHikQuery;
import com.mortals.xhx.module.dingding.IDingTalkService;
import java.util.List;
public interface IDingAttenanceService extends IDingTalkService {
/**
* 获取打卡结果
*
* @return
*/
Rest<List<OapiAttendanceListResponse.Recordresult>> getAttendanceList(PageInfo pageInfo, List<String> userIdList, AttendanceRecordHikQuery hikQuery);
/**
* 获取考勤组
*
* @param pageInfo
* @return
*/
Rest<List<OapiAttendanceGetsimplegroupsResponse.AtGroupForTopVo>> getAttendanceGroupList(PageInfo pageInfo);
/**
* 获取考勤组人员
*
* @param cursor
* @param groupId
* @return
*/
Rest<List<String>> getGroupPersons(Long cursor, Long groupId);
/**
* 获取班次列表
*
* @param cursor
* @return
*/
Rest<List<OapiAttendanceShiftListResponse.TopMinimalismShiftVo>> getShiftList(Long cursor);
/**
* 获取班次详细
*
* @param shiftId
* @return
*/
Rest<OapiAttendanceShiftQueryResponse.TopShiftVo> getShiftDetail(Long shiftId);
/**
* 获取个人信息详细
* @param userId
* @return
*/
Rest<OapiV2UserGetResponse.UserGetResponse> getPersonDetail(String userId);
}
\ No newline at end of file
package com.mortals.xhx.module.dingding.attendance.service.impl;
import com.alibaba.fastjson.JSON;
import com.dingtalk.api.DefaultDingTalkClient;
import com.dingtalk.api.DingTalkClient;
import com.dingtalk.api.request.*;
import com.dingtalk.api.response.*;
import com.mortals.framework.common.Rest;
import com.mortals.framework.model.PageInfo;
import com.mortals.xhx.module.attendance.model.AttendanceRecordHikQuery;
import com.mortals.xhx.module.dingding.AbstractDingTalkService;
import com.mortals.xhx.module.dingding.attendance.service.IDingAttenanceService;
import com.taobao.api.ApiException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.util.List;
@Service("dingAttendanceService")
@Slf4j
public class DingAttendanceServiceImpl extends AbstractDingTalkService implements IDingAttenanceService {
@Override
public Rest<List<OapiAttendanceListResponse.Recordresult>> getAttendanceList(PageInfo pageInfo, List<String> userIdList, AttendanceRecordHikQuery hikQuery) {
//todo 获取考勤列表
try {
DingTalkClient client = getDingTalkClient("/attendance/list");
OapiAttendanceListRequest req = new OapiAttendanceListRequest();
String attendanceDateStart = hikQuery.getAttendanceDateStart();
String attendanceDateEnd = hikQuery.getAttendanceDateEnd();
req.setWorkDateFrom(attendanceDateStart);
req.setWorkDateTo(attendanceDateEnd);
req.setUserIdList(userIdList);
req.setOffset(Long.valueOf(pageInfo.getBeginIndex() + ""));
req.setLimit(Long.valueOf(pageInfo.getPrePageResult() + ""));
log.info("req:{}", JSON.toJSONString(req));
OapiAttendanceListResponse rsp = client.execute(req, getToken());
// log.info("OapiV2UserGetbymobileResponse:{}", rsp.getBody());
if (rsp.getErrcode() == 0) {
if (rsp.getHasMore()) {
log.info("还有更多数据,递归调用,req:{}", JSON.toJSONString(req));
pageInfo.setCurrPage(pageInfo.getCurrPage() + 1);
Rest<List<OapiAttendanceListResponse.Recordresult>> attendanceList = getAttendanceList(pageInfo, userIdList, hikQuery);
rsp.getRecordresult().addAll(attendanceList.getData());
return Rest.ok("成功", rsp.getRecordresult());
}
return Rest.ok("成功", rsp.getRecordresult());
} else {
log.info("异常数据,rsp error:{}", JSON.toJSONString(rsp));
return Rest.fail(String.format("code:%s,msg:%s", rsp.getErrcode(), rsp.getErrmsg()));
}
} catch (ApiException e) {
log.info("获取考勤列表异常", e);
return Rest.fail(e.getMessage());
}
}
@Override
public Rest<List<OapiAttendanceGetsimplegroupsResponse.AtGroupForTopVo>> getAttendanceGroupList(PageInfo pageInfo) {
//todo 获取考勤组列表
try {
DingTalkClient client = getDingTalkClient("/topapi/attendance/getsimplegroups");
OapiAttendanceGetsimplegroupsRequest req = new OapiAttendanceGetsimplegroupsRequest();
req.setOffset(Long.valueOf(pageInfo.getBeginIndex() + ""));
req.setSize(Long.valueOf(pageInfo.getPrePageResult() + ""));
log.info("req:{}", JSON.toJSONString(req));
OapiAttendanceGetsimplegroupsResponse rsp = client.execute(req, getToken());
log.info("考勤组 Response:{}", rsp.getBody());
if (rsp.getErrcode() == 0) {
if (rsp.getResult().getHasMore()) {
log.info("还有更多数据,递归调用,req:{}", JSON.toJSONString(req));
pageInfo.setCurrPage(pageInfo.getCurrPage() + 1);
Rest<List<OapiAttendanceGetsimplegroupsResponse.AtGroupForTopVo>> rest = getAttendanceGroupList(pageInfo);
rsp.getResult().getGroups().addAll(rest.getData());
return Rest.ok("成功", rsp.getResult().getGroups());
}
return Rest.ok("成功", rsp.getResult().getGroups());
} else {
log.info("异常数据,rsp error:{}", JSON.toJSONString(rsp));
return Rest.fail(String.format("code:%s,msg:%s", rsp.getErrcode(), rsp.getErrmsg()));
}
} catch (ApiException e) {
log.info("获取考勤组异常", e);
return Rest.fail(e.getMessage());
}
}
@Override
public Rest<List<String>> getGroupPersons(Long cursor, Long groupId) {
//todo 获取考勤组人员列表
try {
DingTalkClient client = getDingTalkClient("/topapi/attendance/group/memberusers/list");
OapiAttendanceGroupMemberusersListRequest req = new OapiAttendanceGroupMemberusersListRequest();
req.setCursor(cursor);
req.setOpUserId("manager");
req.setGroupId(groupId);
log.info("req:{}", JSON.toJSONString(req));
OapiAttendanceGroupMemberusersListResponse rsp = client.execute(req, getToken());
log.info("考勤组 Response:{}", rsp.getBody());
if (rsp.getErrcode() == 0) {
if (rsp.getResult().getHasMore()) {
log.info("还有更多数据,递归调用,req:{}", JSON.toJSONString(req));
Rest<List<String>> rest = getGroupPersons(rsp.getResult().getCursor(), groupId);
rsp.getResult().getResult().addAll(rest.getData());
return Rest.ok("成功", rsp.getResult().getResult());
}
return Rest.ok("成功", rsp.getResult().getResult());
} else {
log.info("异常数据,rsp error:{}", JSON.toJSONString(rsp));
return Rest.fail(String.format("code:%s,msg:%s", rsp.getErrcode(), rsp.getErrmsg()));
}
} catch (ApiException e) {
log.info("获取考勤组人员异常", e);
return Rest.fail(e.getMessage());
}
}
public Rest<List<OapiAttendanceShiftListResponse.TopMinimalismShiftVo>> getShiftList(Long cursor) {
//todo 获取班次列表
try {
DingTalkClient client = getDingTalkClient("/topapi/attendance/shift/list");
OapiAttendanceShiftListRequest req = new OapiAttendanceShiftListRequest();
req.setCursor(cursor);
req.setOpUserId("manager");
log.info("req:{}", JSON.toJSONString(req));
OapiAttendanceShiftListResponse rsp = client.execute(req, getToken());
log.info("考勤班次 Response:{}", rsp.getBody());
if (rsp.getErrcode() == 0) {
if (rsp.getResult().getHasMore()) {
log.info("还有更多数据,递归调用,req:{}", JSON.toJSONString(req));
Rest<List<OapiAttendanceShiftListResponse.TopMinimalismShiftVo>> rest = getShiftList(rsp.getResult().getCursor());
rsp.getResult().getResult().addAll(rest.getData());
return Rest.ok("成功", rsp.getResult().getResult());
}
return Rest.ok("成功", rsp.getResult().getResult());
} else {
log.info("异常数据,rsp error:{}", JSON.toJSONString(rsp));
return Rest.fail(String.format("code:%s,msg:%s", rsp.getErrcode(), rsp.getErrmsg()));
}
} catch (ApiException e) {
log.info("获取班次异常", e);
return Rest.fail(e.getMessage());
}
}
public Rest<OapiAttendanceShiftQueryResponse.TopShiftVo> getShiftDetail(Long shiftId) {
//todo 获取班次列表
try {
DingTalkClient client = getDingTalkClient("/topapi/attendance/shift/query");
OapiAttendanceShiftQueryRequest req = new OapiAttendanceShiftQueryRequest();
req.setShiftId(shiftId);
req.setOpUserId("manager");
log.info("req:{}", JSON.toJSONString(req));
OapiAttendanceShiftQueryResponse rsp = client.execute(req, getToken());
log.info("班次详细 Response:{}", rsp.getBody());
if (rsp.getErrcode() == 0) {
return Rest.ok("成功", rsp.getResult());
} else {
log.info("异常数据,rsp error:{}", JSON.toJSONString(rsp));
return Rest.fail(String.format("code:%s,msg:%s", rsp.getErrcode(), rsp.getErrmsg()));
}
} catch (ApiException e) {
log.info("获取班次异常", e);
return Rest.fail(e.getMessage());
}
}
public Rest<OapiV2UserGetResponse.UserGetResponse> getPersonDetail(String userId) {
//todo 获取班次列表
try {
DingTalkClient client = getDingTalkClient("/topapi/v2/user/get");
OapiV2UserGetRequest req = new OapiV2UserGetRequest();
req.setUserid(userId);
log.info("req:{}", JSON.toJSONString(req));
OapiV2UserGetResponse rsp = client.execute(req, getToken());
log.info("个人详细 Response:{}", rsp.getBody());
if (rsp.getErrcode() == 0) {
return Rest.ok("成功", rsp.getResult());
} else {
log.info("异常数据,rsp error:{}", JSON.toJSONString(rsp));
return Rest.fail(String.format("code:%s,msg:%s", rsp.getErrcode(), rsp.getErrmsg()));
}
} catch (ApiException e) {
log.info("获取异常", e);
return Rest.fail(e.getMessage());
}
}
}
\ No newline at end of file
package com.mortals.xhx.module.dingding.personal.service; package com.mortals.xhx.module.dingding.personal.service;
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.ListProcessInstanceIdsResponseBody; 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.OapiV2DepartmentListsubResponse;
import com.dingtalk.api.response.OapiV2UserListResponse;
import com.mortals.framework.common.Rest; import com.mortals.framework.common.Rest;
import com.mortals.framework.model.PageInfo;
import com.mortals.xhx.module.dingding.IDingTalkService; import com.mortals.xhx.module.dingding.IDingTalkService;
import com.mortals.xhx.module.dingding.personal.model.req.workmsg.WorkMsgReq; import com.mortals.xhx.module.dingding.personal.model.req.workmsg.WorkMsgReq;
import com.mortals.xhx.module.hik.person.model.req.org.OrgListReq;
import com.mortals.xhx.module.hik.person.model.req.person.PersonReq; import java.util.List;
import com.mortals.xhx.module.hik.person.model.rsp.org.OrgDataInfo; import java.util.stream.Stream;
import com.mortals.xhx.module.hik.person.model.rsp.person.PersonDataInfo;
import org.apache.poi.ss.formula.functions.T;
/** /**
* 钉钉人事相关服务类 * 钉钉人事相关服务类
...@@ -51,6 +49,7 @@ public interface IDingPersonService extends IDingTalkService { ...@@ -51,6 +49,7 @@ public interface IDingPersonService extends IDingTalkService {
/** /**
* 发送工作消息 * 发送工作消息
*
* @param workMsgReq * @param workMsgReq
* @return * @return
*/ */
...@@ -58,6 +57,7 @@ public interface IDingPersonService extends IDingTalkService { ...@@ -58,6 +57,7 @@ public interface IDingPersonService extends IDingTalkService {
/** /**
* 审批详情 * 审批详情
*
* @param processInstanceId 审批实例ID。 * @param processInstanceId 审批实例ID。
* @return * @return
*/ */
...@@ -65,6 +65,7 @@ public interface IDingPersonService extends IDingTalkService { ...@@ -65,6 +65,7 @@ public interface IDingPersonService extends IDingTalkService {
/** /**
* 查询userid的特定假期余额 * 查询userid的特定假期余额
*
* @param user_id 被查询员工的id集合 多个用,分隔 * @param user_id 被查询员工的id集合 多个用,分隔
* @param leave_code 假期类型编码 * @param leave_code 假期类型编码
* @return * @return
...@@ -73,12 +74,14 @@ public interface IDingPersonService extends IDingTalkService { ...@@ -73,12 +74,14 @@ public interface IDingPersonService extends IDingTalkService {
/** /**
* 根据审批详情处理审批(插入请假数据) * 根据审批详情处理审批(插入请假数据)
*
* @param processInstanceId 实例id * @param processInstanceId 实例id
*/ */
void handleByProcessInstanceId(String processInstanceId); void handleByProcessInstanceId(String processInstanceId);
/** /**
* 根据系统电话查询指定时间的审批表单 * 根据系统电话查询指定时间的审批表单
*
* @param processCode 审批流的唯一码(详见doc下 审批表单列表.txt)。 * @param processCode 审批流的唯一码(详见doc下 审批表单列表.txt)。
* 请假:PROC-2E5C0DFF-3615-4409-A614-A2011FED5D38 * 请假:PROC-2E5C0DFF-3615-4409-A614-A2011FED5D38
* 外出:PROC-56D3ADEE-45A4-47BC-931A-2A0DC067DE32 * 外出:PROC-56D3ADEE-45A4-47BC-931A-2A0DC067DE32
...@@ -92,5 +95,22 @@ public interface IDingPersonService extends IDingTalkService { ...@@ -92,5 +95,22 @@ public interface IDingPersonService extends IDingTalkService {
Rest<ListProcessInstanceIdsResponseBody.ListProcessInstanceIdsResponseBodyResult> 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;
/**
* 根据部门获取用户信息
*
* @param pageInfo
* @param deptId
* @return
*/
List<OapiV2UserListResponse.ListUserResponse> getPersonsByDept(PageInfo pageInfo, Long deptId);
/**
* 根据部门id获取子部门
*
* @return
*/
Rest<List<OapiV2DepartmentListsubResponse.DeptBaseResponse>> getDepts(Long deptId);
} }
...@@ -3,14 +3,9 @@ package com.mortals.xhx.module.dingding.personal.service.impl; ...@@ -3,14 +3,9 @@ package com.mortals.xhx.module.dingding.personal.service.impl;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.aliyun.dingtalkattendance_1_0.Client;
import com.aliyun.dingtalkattendance_1_0.models.GetLeaveRecordsHeaders;
import com.aliyun.dingtalkattendance_1_0.models.GetLeaveRecordsResponse;
import com.aliyun.dingtalkattendance_1_0.models.GetLeaveRecordsResponseBody;
import com.aliyun.dingtalkworkflow_1_0.models.*; import com.aliyun.dingtalkworkflow_1_0.models.*;
import com.aliyun.tea.TeaException; import com.aliyun.tea.TeaException;
import com.aliyun.teautil.models.RuntimeOptions; import com.aliyun.teautil.models.RuntimeOptions;
import com.dingtalk.api.DefaultDingTalkClient;
import com.dingtalk.api.DingTalkClient; import com.dingtalk.api.DingTalkClient;
import com.dingtalk.api.request.*; import com.dingtalk.api.request.*;
import com.dingtalk.api.response.*; import com.dingtalk.api.response.*;
...@@ -19,6 +14,7 @@ import com.google.gson.JsonArray; ...@@ -19,6 +14,7 @@ import com.google.gson.JsonArray;
import com.google.gson.JsonElement; import com.google.gson.JsonElement;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import com.mortals.framework.common.Rest; import com.mortals.framework.common.Rest;
import com.mortals.framework.model.PageInfo;
import com.mortals.xhx.common.code.AppealResultEnum; import com.mortals.xhx.common.code.AppealResultEnum;
import com.mortals.xhx.common.code.LeaveRulesEnum; import com.mortals.xhx.common.code.LeaveRulesEnum;
import com.mortals.xhx.module.attendance.dingmsg.DingCallbackCrypto; import com.mortals.xhx.module.attendance.dingmsg.DingCallbackCrypto;
...@@ -35,8 +31,6 @@ import com.mortals.xhx.module.staff.model.StaffQuery; ...@@ -35,8 +31,6 @@ import com.mortals.xhx.module.staff.model.StaffQuery;
import com.mortals.xhx.module.staff.service.StaffService; import com.mortals.xhx.module.staff.service.StaffService;
import com.taobao.api.ApiException; import com.taobao.api.ApiException;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.logging.Log;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
...@@ -44,10 +38,8 @@ import org.springframework.util.ObjectUtils; ...@@ -44,10 +38,8 @@ import org.springframework.util.ObjectUtils;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Arrays; import java.util.*;
import java.util.Date; import java.util.stream.Stream;
import java.util.HashMap;
import java.util.List;
@Service("dingPersonService") @Service("dingPersonService")
...@@ -223,7 +215,7 @@ public class DingPersonServiceImpl extends AbstractDingTalkService implements ID ...@@ -223,7 +215,7 @@ public class DingPersonServiceImpl extends AbstractDingTalkService implements ID
HashMap<String, String> map = new HashMap<>(); HashMap<String, String> map = new HashMap<>();
listProcessInstanceIdsHeaders.setCommonHeaders(map); listProcessInstanceIdsHeaders.setCommonHeaders(map);
// log.info("oaUrl===>{}",oaUrl); // log.info("oaUrl===>{}",oaUrl);
if(!ObjectUtils.isEmpty(oaUrl)){ if (!ObjectUtils.isEmpty(oaUrl)) {
listProcessInstanceIdsHeaders.getCommonHeaders().put("host", oaUrl); listProcessInstanceIdsHeaders.getCommonHeaders().put("host", oaUrl);
} }
// listProcessInstanceIdsHeaders.getCommonHeaders().put("host", "172.15.28.113:8919"); // listProcessInstanceIdsHeaders.getCommonHeaders().put("host", "172.15.28.113:8919");
...@@ -251,7 +243,7 @@ public class DingPersonServiceImpl extends AbstractDingTalkService implements ID ...@@ -251,7 +243,7 @@ public class DingPersonServiceImpl extends AbstractDingTalkService implements ID
} }
} catch (Exception _err) { } catch (Exception _err) {
TeaException err = new TeaException(_err.getMessage(), _err); TeaException err = new TeaException(_err.getMessage(), _err);
log.error("获取审批实例id列表失败->",_err); log.error("获取审批实例id列表失败->", _err);
if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) { if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
// err 中含有 code 和 message 属性,可帮助开发定位问题 // err 中含有 code 和 message 属性,可帮助开发定位问题
log.error("code = " + com.aliyun.teautil.Common.empty(err.code) + " message = " + com.aliyun.teautil.Common.empty(err.message)); log.error("code = " + com.aliyun.teautil.Common.empty(err.code) + " message = " + com.aliyun.teautil.Common.empty(err.message));
...@@ -262,9 +254,66 @@ public class DingPersonServiceImpl extends AbstractDingTalkService implements ID ...@@ -262,9 +254,66 @@ public class DingPersonServiceImpl extends AbstractDingTalkService implements ID
return Rest.fail("userid为空"); return Rest.fail("userid为空");
} }
}
@Override
public Rest<List<OapiV2DepartmentListsubResponse.DeptBaseResponse>> getDepts(Long deptId) {
try {
DingTalkClient client = getDingTalkClient("/topapi/v2/department/listsub");
OapiV2DepartmentListsubRequest req = new OapiV2DepartmentListsubRequest();
req.setDeptId(deptId);
OapiV2DepartmentListsubResponse rsp = client.execute(req, getToken());
log.info("钉钉返回部门信息:{}", rsp.getBody());
if (rsp.getErrcode() == 0) {
return Rest.ok("成功", rsp.getResult());
} else {
return Rest.fail(String.format("code:%s,msg:%s", rsp.getErrcode(), rsp.getErrmsg()));
}
} catch (ApiException e) {
log.info("查询部门异常", e);
return Rest.fail(e.getMessage());
}
} }
@Override
public List<OapiV2UserListResponse.ListUserResponse> getPersonsByDept(PageInfo pageInfo, Long deptId) {
try {
DingTalkClient client = getDingTalkClient("/topapi/v2/user/list");
OapiV2UserListRequest req = new OapiV2UserListRequest();
req.setCursor(Long.parseLong(pageInfo.getBeginIndex() + ""));
req.setSize(Long.parseLong(pageInfo.getPrePageResult() + ""));
req.setDeptId(deptId);
OapiV2UserListResponse rsp = client.execute(req, getToken());
log.info("钉钉返回用户信息:{}", rsp.getBody());
if (rsp.getErrcode() == 0) {
OapiV2UserListResponse.PageResult result = rsp.getResult();
if (result != null && result.getHasMore()) {
Long nextCursor = result.getNextCursor();
pageInfo.setBeginIndex(nextCursor.intValue());
List<OapiV2UserListResponse.ListUserResponse> list = result.getList();
result.getList().addAll(list);
return result.getList();
}
return result.getList();
} else {
return new ArrayList<>();
}
} catch (ApiException e) {
log.info("查询人员", e);
//return Rest.fail(e.getMessage());
}
return new ArrayList<>();
}
/** /**
* 根据审批实例id查询审批详情 * 根据审批实例id查询审批详情
* *
...@@ -279,7 +328,7 @@ public class DingPersonServiceImpl extends AbstractDingTalkService implements ID ...@@ -279,7 +328,7 @@ public class DingPersonServiceImpl extends AbstractDingTalkService implements ID
getProcessInstanceHeaders.xAcsDingtalkAccessToken = getToken(); getProcessInstanceHeaders.xAcsDingtalkAccessToken = getToken();
HashMap<String, String> map = new HashMap<>(); HashMap<String, String> map = new HashMap<>();
getProcessInstanceHeaders.setCommonHeaders(map); getProcessInstanceHeaders.setCommonHeaders(map);
if(!ObjectUtils.isEmpty(oaUrl)){ if (!ObjectUtils.isEmpty(oaUrl)) {
getProcessInstanceHeaders.getCommonHeaders().put("host", oaUrl); getProcessInstanceHeaders.getCommonHeaders().put("host", oaUrl);
} }
...@@ -351,7 +400,7 @@ public class DingPersonServiceImpl extends AbstractDingTalkService implements ID ...@@ -351,7 +400,7 @@ public class DingPersonServiceImpl extends AbstractDingTalkService implements ID
if (mobileRest.getCode() == Rest.SUCCESS) { if (mobileRest.getCode() == Rest.SUCCESS) {
String mobile = mobileRest.getData(); String mobile = mobileRest.getData();
StaffQuery staffQuery = new StaffQuery(); StaffQuery staffQuery = new StaffQuery();
staffQuery.setStatusList(Arrays.asList(1,2)); staffQuery.setStatusList(Arrays.asList(1, 2));
staffQuery.setPhoneNumber(mobile); staffQuery.setPhoneNumber(mobile);
StaffEntity staffEntity = staffService.selectOne(staffQuery); StaffEntity staffEntity = staffService.selectOne(staffQuery);
if (!ObjectUtils.isEmpty(staffEntity)) { if (!ObjectUtils.isEmpty(staffEntity)) {
...@@ -583,11 +632,9 @@ public class DingPersonServiceImpl extends AbstractDingTalkService implements ID ...@@ -583,11 +632,9 @@ public class DingPersonServiceImpl extends AbstractDingTalkService implements ID
} }
} }
} } else if (result.getResult().compareToIgnoreCase("REFUSE") == 0) { //拒绝审批
else if (result.getResult().compareToIgnoreCase("REFUSE") == 0) { //拒绝审批
leaveRecordEntity.setAuditResult(AppealResultEnum.不通过.getValue()); //拒绝审批 leaveRecordEntity.setAuditResult(AppealResultEnum.不通过.getValue()); //拒绝审批
} } else if (result.equals("")) { //撤销假期审批中result会为空 撤销审批通过后result为AGREE
else if (result.equals("")) { //撤销假期审批中result会为空 撤销审批通过后result为AGREE
if (result.getTasks().size() > 1) { if (result.getTasks().size() > 1) {
log.info("status" + result.getTasks().get(1).getStatus()); log.info("status" + result.getTasks().get(1).getStatus());
if (result.getTasks().get(1).getStatus().compareToIgnoreCase("CANCELED") != 0) { if (result.getTasks().get(1).getStatus().compareToIgnoreCase("CANCELED") != 0) {
...@@ -920,7 +967,7 @@ public class DingPersonServiceImpl extends AbstractDingTalkService implements ID ...@@ -920,7 +967,7 @@ public class DingPersonServiceImpl extends AbstractDingTalkService implements ID
} catch (DingCallbackCrypto.DingTalkEncryptException e) { } catch (DingCallbackCrypto.DingTalkEncryptException e) {
// log.error("钉钉回调解密失败" + e.toString()"); // log.error("钉钉回调解密失败" + e.toString()");
} catch (Exception e) { } catch (Exception e) {
log.error("请假记录表操作异常->" ,e); log.error("请假记录表操作异常->", e);
throw new RuntimeException(e); throw new RuntimeException(e);
} }
...@@ -1000,80 +1047,4 @@ public class DingPersonServiceImpl extends AbstractDingTalkService implements ID ...@@ -1000,80 +1047,4 @@ public class DingPersonServiceImpl extends AbstractDingTalkService implements ID
} }
} }
// public static void main(String[] args) {
// String result = "{\"attachedProcessInstanceIds\":[],\"bizAction\":\"NONE\",\"businessId\":\"202401161705000413779\",\"ccUserIds\":[\"2359336301844466\",\"2352352656711393\",\"254868153920685466\"],\"createTime\":\"2024-01-16T17:05Z\",\"finishTime\":\"2024-01-17T10:15Z\",\"formComponentValues\":[{\"bizAlias\":\"type\",\"componentType\":\"DDSelectField\",\"id\":\"DDSelectField-K2BJK0RV\",\"name\":\"外出类型\"},{\"bizAlias\":\"startTime\",\"componentType\":\"DDDateField\",\"id\":\"DDDateField-K2BJK0RW\",\"name\":\"开始时间\",\"value\":\"2024-01-17\"},{\"bizAlias\":\"finishTime\",\"componentType\":\"DDDateField\",\"id\":\"DDDateField-K2BJK0RX\",\"name\":\"结束时间\",\"value\":\"2024-01-17\"},{\"bizAlias\":\"duration\",\"componentType\":\"NumberField\",\"extValue\":\"{\\\"compressedValue\\\":\\\"1f8b08000000000000009550cb4ec33010fc973d1b94422222df2a2244257a81704088c3ca76a9851b475e1b5445f977d669a141ea05dfe6a1d9f10ca0d0a9e4309ab5d706e442803611ad7bb01441be0ea053c0687db7ea1adcb3e1b228c48cbcf72980ac27766330a66008e400d8f76e7f17fcaeb5bb9c7b535465b5288bfcc4416dfd4cabafeba3a61c123d1995f3e94f85b5cd4455b2c9747aa98227c60774368a228638f34df84ca1f14d80a54793bfbc414746c0a709c4274102ff1846015ba4dbdcecd7d13bec561ae4056ff6e5c347c3231e73af8a9f0659c807b97a8a7999b29eaefd63d5133b0f39f1cf9de5dad02c5f804b25dab6f8ce18c66f8db64c7edd010000\\\",\\\"extension\\\":\\\"{\\\\\\\"tag\\\\\\\":\\\\\\\"\\\\\\\"}\\\",\\\"unit\\\":\\\"DAY\\\",\\\"_from\\\":\\\"2024-01-17\\\",\\\"_overTimeApplyUserId\\\":\\\"01575932040926359398\\\",\\\"pushTag\\\":\\\"\\\",\\\"detailList\\\":[{\\\"classInfo\\\":{\\\"restSections\\\":[],\\\"hasClass\\\":false,\\\"sections\\\":[{\\\"endAcross\\\":0,\\\"startTime\\\":1705451400000,\\\"endTime\\\":1705483800000,\\\"startAcross\\\":0}]},\\\"workDate\\\":1705420800000,\\\"isRest\\\":false,\\\"workTimeMinutes\\\":480,\\\"approveInfo\\\":{\\\"fromAcross\\\":0,\\\"toAcross\\\":0,\\\"fromTime\\\":1705451400000,\\\"durationInDay\\\":1,\\\"durationInHour\\\":8,\\\"toTime\\\":1705483800000}}],\\\"durationInDay\\\":1,\\\"_to\\\":\\\"2024-01-17\\\",\\\"isModifiable\\\":true,\\\"durationInHour\\\":8}\",\"id\":\"NumberField-K2BJK0RY\",\"name\":\"时长\",\"value\":\"1\"},{\"componentType\":\"TextareaField\",\"id\":\"外出事由\",\"name\":\"外出事由\",\"value\":\"市局有事\"},{\"componentType\":\"DDPhotoField\",\"id\":\"图片\",\"name\":\"图片\"}],\"operationRecords\":[{\"date\":\"2024-01-16T17:05Z\",\"result\":\"NONE\",\"type\":\"START_PROCESS_INSTANCE\",\"userId\":\"01575932040926359398\"},{\"date\":\"2024-01-17T09:24Z\",\"result\":\"AGREE\",\"type\":\"EXECUTE_TASK_NORMAL\",\"userId\":\"0355254921955583\"},{\"date\":\"2024-01-17T10:15Z\",\"result\":\"AGREE\",\"type\":\"EXECUTE_TASK_NORMAL\",\"userId\":\"31102532391173290\"},{\"ccUserIds\":[\"2352352656711393\",\"2359336301844466\"],\"date\":\"2024-01-17T10:15Z\",\"remark\":\"\",\"result\":\"NONE\",\"type\":\"PROCESS_CC\",\"userId\":\"01575932040926359398\"},{\"ccUserIds\":[\"254868153920685466\"],\"date\":\"2024-01-17T10:15Z\",\"remark\":\"\",\"result\":\"NONE\",\"type\":\"PROCESS_CC\",\"userId\":\"01575932040926359398\"}],\"originatorDeptId\":\"895306500\",\"originatorDeptName\":\"2B税务大厅-劳务外包人员咨询组\",\"originatorUserId\":\"01575932040926359398\",\"result\":\"agree\",\"status\":\"COMPLETED\",\"tasks\":[{\"activityId\":\"1ebf_7ae5\",\"createTime\":\"2024-01-16T17:05Z\",\"finishTime\":\"2024-01-17T09:24Z\",\"mobileUrl\":\"aflow.dingtalk.com?procInsId=9HLoKgFLTNiz1KO08qc85A07481705395941&taskId=84557347599&businessId=202401161705000413779\",\"pcUrl\":\"aflow.dingtalk.com?procInsId=9HLoKgFLTNiz1KO08qc85A07481705395941&taskId=84557347599&businessId=202401161705000413779\",\"result\":\"AGREE\",\"status\":\"COMPLETED\",\"taskId\":84557347599,\"userId\":\"0355254921955583\"},{\"activityId\":\"075a_e01a\",\"createTime\":\"2024-01-17T09:24Z\",\"finishTime\":\"2024-01-17T10:15Z\",\"mobileUrl\":\"aflow.dingtalk.com?procInsId=9HLoKgFLTNiz1KO08qc85A07481705395941&taskId=84566067197&businessId=202401161705000413779\",\"pcUrl\":\"aflow.dingtalk.com?procInsId=9HLoKgFLTNiz1KO08qc85A07481705395941&taskId=84566067197&businessId=202401161705000413779\",\"result\":\"AGREE\",\"status\":\"COMPLETED\",\"taskId\":84566067197,\"userId\":\"31102532391173290\"}],\"title\":\"李玉洁提交的外出\"}";
// new DingPersonServiceImpl().test(result);
// }
//
//
// private void test(String resultString){
// GetProcessInstanceResponseBody.GetProcessInstanceResponseBodyResult result = JSONObject.parseObject(resultString,GetProcessInstanceResponseBody.GetProcessInstanceResponseBodyResult.class);
// if(result.getTitle().contains("外出")){
// List<GetProcessInstanceResponseBody.GetProcessInstanceResponseBodyResultFormComponentValues> comList = result.getFormComponentValues();
// if(!comList.isEmpty()){
// for (GetProcessInstanceResponseBody.GetProcessInstanceResponseBodyResultFormComponentValues componentValues : comList){
// switch (componentValues.name){
// case "开始时间":
// Date startTime1 = dateFormat(componentValues.getValue(), "yyyy-MM-dd HH:mm", true);
// log.info("开始时间:"+startTime1);
// break;
// case "结束时间":
// Date endTime1 = dateFormat(componentValues.getValue(), "yyyy-MM-dd HH:mm", false);
// log.info("结束时间:"+endTime1);
// break;
// case "时长":
// log.info("时长:"+Integer.parseInt(componentValues.getValue()) + "天");
// break;
// case "外出事由":
// log.info("外出事由:"+componentValues.getValue());
// break;
// case "图片":
// log.info("图片:"+componentValues.getValue());
// break;
// }
// }
// }
// }else if(result.getTitle().contains("出差")) {
// List<GetProcessInstanceResponseBody.GetProcessInstanceResponseBodyResultFormComponentValues> comList = result.getFormComponentValues();
// if (!comList.isEmpty()) {
// for (GetProcessInstanceResponseBody.GetProcessInstanceResponseBodyResultFormComponentValues componentValues : comList) {
// switch (componentValues.name) {
// case "行程":
// Gson gson = new Gson();
// JsonArray jsonArray = gson.fromJson(componentValues.getValue(), JsonArray.class);
// JsonObject jsonObject = jsonArray.get(0).getAsJsonObject(); // 获取第一个对象
// JsonElement rowValueElement = jsonObject.get("rowValue"); // 获取rowValue字段的值
// JsonArray rowValueArray = rowValueElement.getAsJsonArray(); // 获取数组
// for (JsonElement element : rowValueArray) { // 遍历数组中的每个元素
// JsonObject jsonObject1 = element.getAsJsonObject(); // 获取每个元素作为对象
// String label = jsonObject1.get("label").getAsString(); // 获取label字段的值
// String value = jsonObject1.get("value").getAsString();
// if (label.contains("开始时间")) {
// Date startTime1 = dateFormat(value, "yyyy-MM-dd HH:mm", true);
// log.info("开始时间:"+startTime1);
// }
// if (label.contains("结束时间")) {
// Date endTime1 = dateFormat(value, "yyyy-MM-dd HH:mm", false);
// log.info("结束时间:"+endTime1);
// }
// }
//
//
// break;
// case "出差天数":
// log.info("出差天数:"+Integer.parseInt(componentValues.getValue()) + "天");
// break;
// case "出差事由":
// log.info("出差事由:"+componentValues.getValue());
// break;
// case "图片":
// log.info("图片:"+componentValues.getValue());
// break;
// }
// }
// }
// }
// }
} }
...@@ -32,12 +32,12 @@ import java.util.Set; ...@@ -32,12 +32,12 @@ import java.util.Set;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
* DoorService * DoorService
* 门禁设备 service实现 * 门禁设备 service实现
* *
* @author zxfei * @author zxfei
* @date 2023-11-22 * @date 2023-11-22
*/ */
@Service("doorService") @Service("doorService")
@Slf4j @Slf4j
public class DoorServiceImpl extends AbstractCRUDServiceImpl<DoorDao, DoorEntity, Long> implements DoorService { public class DoorServiceImpl extends AbstractCRUDServiceImpl<DoorDao, DoorEntity, Long> implements DoorService {
...@@ -72,7 +72,7 @@ public class DoorServiceImpl extends AbstractCRUDServiceImpl<DoorDao, DoorEntity ...@@ -72,7 +72,7 @@ public class DoorServiceImpl extends AbstractCRUDServiceImpl<DoorDao, DoorEntity
} else { } else {
jobNo = new String(byEmployeeNo).trim(); jobNo = new String(byEmployeeNo).trim();
} }
log.info("jobNo==>{}",jobNo); log.info("jobNo==>{}", jobNo);
//查看考勤状态 //查看考勤状态
int dwMajor = item.getDwMajor();//报警主类型 int dwMajor = item.getDwMajor();//报警主类型
int dwMinor = item.getDwMinor();//报警次类型 int dwMinor = item.getDwMinor();//报警次类型
...@@ -97,7 +97,12 @@ public class DoorServiceImpl extends AbstractCRUDServiceImpl<DoorDao, DoorEntity ...@@ -97,7 +97,12 @@ public class DoorServiceImpl extends AbstractCRUDServiceImpl<DoorDao, DoorEntity
Date attendDate = Date.from(zdt.toInstant()); Date attendDate = Date.from(zdt.toInstant());
StaffEntity staffCache = staffService.getExtCache(StrUtil.padPre(jobNo, 8, "0")); String workNum = jobNo;
if (jobNo.length() < 8) {
workNum = StrUtil.padPre(jobNo, 8, "0");
}
StaffEntity staffCache = staffService.getExtCache(workNum);
// StaffEntity staffCache = staffService.getExtCache(StrUtil.padPre(jobNo, 8, "0"));
if (ObjectUtils.isEmpty(staffCache)) { if (ObjectUtils.isEmpty(staffCache)) {
log.info("staff is null !staffCode:{}", jobNo); log.info("staff is null !staffCode:{}", jobNo);
return null; return null;
......
...@@ -32,8 +32,6 @@ public interface StaffService extends ICRUDCacheService<StaffEntity,Long> { ...@@ -32,8 +32,6 @@ public interface StaffService extends ICRUDCacheService<StaffEntity,Long> {
*/ */
Rest<Void> syncPersons(Context context); Rest<Void> syncPersons(Context context);
/** /**
* 同步人员信息 * 同步人员信息
* @param context * @param context
...@@ -41,6 +39,15 @@ public interface StaffService extends ICRUDCacheService<StaffEntity,Long> { ...@@ -41,6 +39,15 @@ public interface StaffService extends ICRUDCacheService<StaffEntity,Long> {
*/ */
Rest<Void> syncPersonsByDevices(Context context); Rest<Void> syncPersonsByDevices(Context context);
/**
* 同步钉钉人员信息
* @param context
* @return
*/
Rest<Void> syncPersonsByDingTalk(Context context);
/** /**
* 绩效考核授权 * 绩效考核授权
* @param pdu * @param pdu
......
...@@ -3,6 +3,7 @@ package com.mortals.xhx.module.staff.service.impl; ...@@ -3,6 +3,7 @@ package com.mortals.xhx.module.staff.service.impl;
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;
import com.dingtalk.api.response.OapiV2UserListResponse;
import com.mortals.framework.common.Rest; import com.mortals.framework.common.Rest;
import com.mortals.framework.exception.AppException; import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context; import com.mortals.framework.model.Context;
...@@ -10,8 +11,6 @@ import com.mortals.framework.model.PageInfo; ...@@ -10,8 +11,6 @@ import com.mortals.framework.model.PageInfo;
import com.mortals.framework.service.impl.AbstractCRUDCacheServiceImpl; import com.mortals.framework.service.impl.AbstractCRUDCacheServiceImpl;
import com.mortals.framework.util.SecurityUtil; import com.mortals.framework.util.SecurityUtil;
import com.mortals.framework.utils.ServletUtils; import com.mortals.framework.utils.ServletUtils;
import com.mortals.xhx.base.system.idgenerator.service.IdgeneratorService;
import com.mortals.xhx.base.system.idgenerator.service.impl.IdgeneratorServiceImpl;
import com.mortals.xhx.base.system.role.model.RoleUserQuery; import com.mortals.xhx.base.system.role.model.RoleUserQuery;
import com.mortals.xhx.base.system.role.service.RoleUserService; import com.mortals.xhx.base.system.role.service.RoleUserService;
import com.mortals.xhx.base.system.upload.service.UploadService; import com.mortals.xhx.base.system.upload.service.UploadService;
...@@ -20,12 +19,12 @@ import com.mortals.xhx.base.system.user.service.UserService; ...@@ -20,12 +19,12 @@ import com.mortals.xhx.base.system.user.service.UserService;
import com.mortals.xhx.common.code.*; import com.mortals.xhx.common.code.*;
import com.mortals.xhx.common.utils.BeanUtil; import com.mortals.xhx.common.utils.BeanUtil;
import com.mortals.xhx.module.attendance.model.*; import com.mortals.xhx.module.attendance.model.*;
import com.mortals.xhx.module.attendance.service.AttendanceGroupStaffService;
import com.mortals.xhx.module.attendance.service.AttendanceStatService; import com.mortals.xhx.module.attendance.service.AttendanceStatService;
import com.mortals.xhx.module.attendance.service.AttendanceVacationBalanceService; import com.mortals.xhx.module.attendance.service.AttendanceVacationBalanceService;
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.service.DeptService; import com.mortals.xhx.module.dept.service.DeptService;
import com.mortals.xhx.module.dingding.personal.service.IDingPersonService;
import com.mortals.xhx.module.door.model.DoorEntity; import com.mortals.xhx.module.door.model.DoorEntity;
import com.mortals.xhx.module.door.model.DoorQuery; import com.mortals.xhx.module.door.model.DoorQuery;
import com.mortals.xhx.module.door.service.DoorService; import com.mortals.xhx.module.door.service.DoorService;
...@@ -41,13 +40,10 @@ import com.mortals.xhx.module.hik.staff.model.rsp.staff.search.UserInfoSearch; ...@@ -41,13 +40,10 @@ import com.mortals.xhx.module.hik.staff.model.rsp.staff.search.UserInfoSearch;
import com.mortals.xhx.module.hik.staff.model.rsp.staff.search.UserSearchInfo; import com.mortals.xhx.module.hik.staff.model.rsp.staff.search.UserSearchInfo;
import com.mortals.xhx.module.hik.staff.service.IHikStaffService; import com.mortals.xhx.module.hik.staff.service.IHikStaffService;
import com.mortals.xhx.module.staff.dao.StaffDao; import com.mortals.xhx.module.staff.dao.StaffDao;
import com.mortals.xhx.module.staff.dao.ibatis.StaffDaoImpl;
import com.mortals.xhx.module.staff.dao.ibatis.StaffLeaveDaoImpl;
import com.mortals.xhx.module.staff.model.*; import com.mortals.xhx.module.staff.model.*;
import com.mortals.xhx.module.staff.model.vo.StaffCheckAuthorizePdu; import com.mortals.xhx.module.staff.model.vo.StaffCheckAuthorizePdu;
import com.mortals.xhx.module.staff.model.vo.StaffInfoVo; import com.mortals.xhx.module.staff.model.vo.StaffInfoVo;
import com.mortals.xhx.module.staff.service.StaffLeaveService; import com.mortals.xhx.module.staff.service.StaffLeaveService;
import com.mortals.xhx.module.staff.service.StaffPerformStatService;
import com.mortals.xhx.module.staff.service.StaffPerformSummaryService; import com.mortals.xhx.module.staff.service.StaffPerformSummaryService;
import com.mortals.xhx.module.staff.service.StaffService; import com.mortals.xhx.module.staff.service.StaffService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
...@@ -63,8 +59,6 @@ import java.math.BigDecimal; ...@@ -63,8 +59,6 @@ import java.math.BigDecimal;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static com.mortals.xhx.base.system.idgenerator.service.impl.IdgeneratorServiceImpl.IdGeneratorKey.USER_KEY;
/** /**
* StaffService * StaffService
* 员工基本信息 service实现 * 员工基本信息 service实现
...@@ -100,11 +94,18 @@ public class StaffServiceImpl extends AbstractCRUDCacheServiceImpl<StaffDao, Sta ...@@ -100,11 +94,18 @@ public class StaffServiceImpl extends AbstractCRUDCacheServiceImpl<StaffDao, Sta
private IHikFaceService hikFaceService; private IHikFaceService hikFaceService;
@Autowired @Autowired
private StaffPerformSummaryService staffPerformSummaryService; private StaffPerformSummaryService staffPerformSummaryService;
@Autowired
private IDingPersonService dingPersonService;
@Override @Override
protected String getExtKey(StaffEntity data) { protected String getExtKey(StaffEntity data) {
//工号作为redis 扩展key //工号作为redis 扩展key
//return StrUtil.padPre(data.getWorkNum(), 8, "0");
if (data.getWorkNum().length() < 8) {
return StrUtil.padPre(data.getWorkNum(), 8, "0"); return StrUtil.padPre(data.getWorkNum(), 8, "0");
} else {
return data.getWorkNum();
}
} }
@Override @Override
...@@ -185,8 +186,12 @@ public class StaffServiceImpl extends AbstractCRUDCacheServiceImpl<StaffDao, Sta ...@@ -185,8 +186,12 @@ public class StaffServiceImpl extends AbstractCRUDCacheServiceImpl<StaffDao, Sta
if (staffCollect.containsKey(personInfo.getJobNo())) { if (staffCollect.containsKey(personInfo.getJobNo())) {
staffCollect.remove(personInfo.getJobNo()); staffCollect.remove(personInfo.getJobNo());
} }
String workNum = personInfo.getJobNo();
StaffEntity staffEntity = this.getExtCache(StrUtil.padPre(personInfo.getJobNo(), 8, "0")); if (personInfo.getJobNo().length() < 8) {
workNum = StrUtil.padPre(personInfo.getJobNo(), 8, "0");
}
StaffEntity staffEntity = this.getExtCache(workNum);
//StaffEntity staffEntity = this.getExtCache(StrUtil.padPre(personInfo.getJobNo(), 8, "0"));
DeptEntity deptEntity = deptService.selectOne(new DeptQuery().deptCode(personInfo.getOrgIndexCode())); DeptEntity deptEntity = deptService.selectOne(new DeptQuery().deptCode(personInfo.getOrgIndexCode()));
//判断本地数据是否为空 //判断本地数据是否为空
if (ObjectUtils.isEmpty(staffEntity)) { if (ObjectUtils.isEmpty(staffEntity)) {
...@@ -301,15 +306,6 @@ public class StaffServiceImpl extends AbstractCRUDCacheServiceImpl<StaffDao, Sta ...@@ -301,15 +306,6 @@ public class StaffServiceImpl extends AbstractCRUDCacheServiceImpl<StaffDao, Sta
if (count == 0) { if (count == 0) {
staffLeaveService.save(staffLeaveEntity); staffLeaveService.save(staffLeaveEntity);
} }
//考勤人员中有离职的 删除
// List<AttendanceGroupStaffEntity> attendanceGroupStaffEntities = attendanceGroupStaffService.find(new AttendanceGroupStaffQuery().staffId(staff.getId()));
// if (!ObjectUtils.isEmpty(attendanceGroupStaffEntities)) {
// attendanceGroupStaffService.removeList(attendanceGroupStaffEntities,context);
// }
/* Long[] groudStaffIds = attendanceGroupStaffService.find(new AttendanceGroupStaffQuery().staffId(staff.getId())).stream().map(i -> i.getId()).toArray(Long[]::new);
if (!ObjectUtils.isEmpty(groudStaffIds)) {
attendanceGroupStaffService.remove(groudStaffIds, null);
}*/
} }
}); });
} }
...@@ -427,62 +423,10 @@ public class StaffServiceImpl extends AbstractCRUDCacheServiceImpl<StaffDao, Sta ...@@ -427,62 +423,10 @@ public class StaffServiceImpl extends AbstractCRUDCacheServiceImpl<StaffDao, Sta
if (temp == null) { if (temp == null) {
throw new AppException("人员信息ID不正确"); throw new AppException("人员信息ID不正确");
} }
// CheckTypeEnum checkTypeEnum = CheckTypeEnum.getByValue(pdu.getType());
// if (checkTypeEnum == null) {
// throw new AppException("考核类型不正确");
// }
StaffEntity update = new StaffEntity(); StaffEntity update = new StaffEntity();
update.setId(pdu.getStaffId()); update.setId(pdu.getStaffId());
//1.考勤绩效,2.评价绩效,3.办件绩效,4.效能绩效,5.其它绩效,6.投诉绩效 BeanUtils.copyProperties(pdu, update, BeanUtil.getNullPropertyNames(pdu));
// switch (checkTypeEnum) {
// case 考勤绩效:
// if (temp.getAttendCheck() == 1) {
// update.setAttendCheck(0);
// } else {
// update.setAttendCheck(1);
// }
// break;
// case 评价绩效:
// if (temp.getComplainCheck() == 1) {
// update.setComplainCheck(0);
// } else {
// update.setComplainCheck(1);
// }
// if (temp.getReviewCheck() == 1) {
// update.setReviewCheck(0);
// } else {
// update.setReviewCheck(1);
// }
// break;
// case 办件绩效:
// if (temp.getGoworkCheck() == 1) {
// update.setGoworkCheck(0);
// } else {
// update.setGoworkCheck(1);
// }
// break;
// case 效能绩效:
// if (temp.getEffectCheck() == 1) {
// update.setEffectCheck(0);
// } else {
// update.setEffectCheck(1);
// }
// break;
// case 其它绩效:
// if (temp.getOtherCheck() == 1) {
// update.setOtherCheck(0);
// } else {
// update.setOtherCheck(1);
// }
// break;
// default:
// if (temp.getOtherCheck() == 1) {
// update.setOtherCheck(0);
// } else {
// update.setOtherCheck(1);
// }
// }
BeanUtils.copyProperties(pdu,update, BeanUtil.getNullPropertyNames(pdu));
update.setUpdateTime(new Date()); update.setUpdateTime(new Date());
if (context.getUser() != null) { if (context.getUser() != null) {
update.setUpdateUserId(context.getUser().getId()); update.setUpdateUserId(context.getUser().getId());
...@@ -490,13 +434,13 @@ public class StaffServiceImpl extends AbstractCRUDCacheServiceImpl<StaffDao, Sta ...@@ -490,13 +434,13 @@ public class StaffServiceImpl extends AbstractCRUDCacheServiceImpl<StaffDao, Sta
//OtherCheck作为绩效总开关,启用时新增当月绩效初始值,关闭时删除当月绩效数据 //OtherCheck作为绩效总开关,启用时新增当月绩效初始值,关闭时删除当月绩效数据
Calendar calendar = Calendar.getInstance(); Calendar calendar = Calendar.getInstance();
int year = calendar.get(Calendar.YEAR); int year = calendar.get(Calendar.YEAR);
int month = calendar.get(Calendar.MONTH)+1; int month = calendar.get(Calendar.MONTH) + 1;
StaffPerformSummaryQuery summaryQuery = new StaffPerformSummaryQuery(); StaffPerformSummaryQuery summaryQuery = new StaffPerformSummaryQuery();
summaryQuery.setStaffId(temp.getId()); summaryQuery.setStaffId(temp.getId());
summaryQuery.setYear(year); summaryQuery.setYear(year);
summaryQuery.setMonth(month); summaryQuery.setMonth(month);
StaffPerformSummaryEntity tempSummary = staffPerformSummaryService.selectOne(summaryQuery); StaffPerformSummaryEntity tempSummary = staffPerformSummaryService.selectOne(summaryQuery);
if(update.getOtherCheck() == 1){ if (update.getOtherCheck() == 1) {
StaffPerformSummaryEntity staffPerformSummaryEntity = new StaffPerformSummaryEntity(); StaffPerformSummaryEntity staffPerformSummaryEntity = new StaffPerformSummaryEntity();
staffPerformSummaryEntity.initAttrValue(); staffPerformSummaryEntity.initAttrValue();
staffPerformSummaryEntity.setStaffId(temp.getId()); staffPerformSummaryEntity.setStaffId(temp.getId());
...@@ -513,9 +457,9 @@ public class StaffServiceImpl extends AbstractCRUDCacheServiceImpl<StaffDao, Sta ...@@ -513,9 +457,9 @@ public class StaffServiceImpl extends AbstractCRUDCacheServiceImpl<StaffDao, Sta
if (tempSummary == null) { if (tempSummary == null) {
staffPerformSummaryService.save(staffPerformSummaryEntity); staffPerformSummaryService.save(staffPerformSummaryEntity);
} }
}else { } else {
if (tempSummary != null) { if (tempSummary != null) {
staffPerformSummaryService.remove(tempSummary.getId(),null); staffPerformSummaryService.remove(tempSummary.getId(), null);
} }
} }
return dao.update(update); return dao.update(update);
...@@ -567,7 +511,7 @@ public class StaffServiceImpl extends AbstractCRUDCacheServiceImpl<StaffDao, Sta ...@@ -567,7 +511,7 @@ public class StaffServiceImpl extends AbstractCRUDCacheServiceImpl<StaffDao, Sta
searchReq.setPageNo(i); searchReq.setPageNo(i);
searchReq.setPageSize(size); searchReq.setPageSize(size);
Rest<UserSearchInfo> rest = hikStaffService.getPersonList(searchReq, doorEntity); Rest<UserSearchInfo> rest = hikStaffService.getPersonList(searchReq, doorEntity);
log.info("page:{}, 获取人员列表:{}",i, JSON.toJSONString(rest)); log.info("page:{}, 获取人员列表:{}", i, JSON.toJSONString(rest));
if (rest.getCode() == YesNoEnum.YES.getValue()) { if (rest.getCode() == YesNoEnum.YES.getValue()) {
//做差集 更新本地用户为离职员工 //做差集 更新本地用户为离职员工
UserInfoSearch userInfoSearch = rest.getData().getUserInfoSearch(); UserInfoSearch userInfoSearch = rest.getData().getUserInfoSearch();
...@@ -580,7 +524,13 @@ public class StaffServiceImpl extends AbstractCRUDCacheServiceImpl<StaffDao, Sta ...@@ -580,7 +524,13 @@ public class StaffServiceImpl extends AbstractCRUDCacheServiceImpl<StaffDao, Sta
if (staffCollect.containsKey(userInfoItem.getEmployeeNo())) { if (staffCollect.containsKey(userInfoItem.getEmployeeNo())) {
staffCollect.remove(userInfoItem.getEmployeeNo()); staffCollect.remove(userInfoItem.getEmployeeNo());
} }
StaffEntity staffEntity = this.getExtCache(StrUtil.padPre(userInfoItem.getEmployeeNo(), 8, "0"));
String workNum = userInfoItem.getEmployeeNo();
if (userInfoItem.getEmployeeNo().length() < 8) {
workNum = StrUtil.padPre(userInfoItem.getEmployeeNo(), 8, "0");
}
StaffEntity staffEntity = this.getExtCache(workNum);
// StaffEntity staffEntity = this.getExtCache(StrUtil.padPre(userInfoItem.getEmployeeNo(), 8, "0"));
//设置到默认部门 //设置到默认部门
//判断本地数据是否为空 //判断本地数据是否为空
if (ObjectUtils.isEmpty(staffEntity)) { if (ObjectUtils.isEmpty(staffEntity)) {
...@@ -675,6 +625,138 @@ public class StaffServiceImpl extends AbstractCRUDCacheServiceImpl<StaffDao, Sta ...@@ -675,6 +625,138 @@ public class StaffServiceImpl extends AbstractCRUDCacheServiceImpl<StaffDao, Sta
return Rest.ok(); return Rest.ok();
} }
@Override
public Rest<Void> syncPersonsByDingTalk(Context context) {
List<DeptEntity> deptEntityList = deptService.find(new DeptQuery());
StaffQuery staffQuery = new StaffQuery();
Map<String, StaffEntity> staffCollect = this.find(staffQuery).stream().collect(Collectors.toMap(x -> x.getWorkNum(), y -> y, (o, n) -> n));
for (DeptEntity deptEntity : deptEntityList) {
String deptCode = deptEntity.getDeptCode();
PageInfo pageInfo = new PageInfo();
pageInfo.setPrePageResult(50);
List<OapiV2UserListResponse.ListUserResponse> collect = dingPersonService.getPersonsByDept(pageInfo, Long.parseLong(deptCode));
for (OapiV2UserListResponse.ListUserResponse personInfo : collect) {
if (ObjectUtils.isEmpty(personInfo.getUserid())) {
log.info("jobNo is null ==>{}", JSON.toJSONString(personInfo));
continue;
}
if (staffCollect.containsKey(personInfo.getUserid())) {
staffCollect.remove(personInfo.getUserid());
}
String workNum = personInfo.getUserid();
if (personInfo.getUserid().length() < 8) {
workNum = StrUtil.padPre(personInfo.getUserid(), 8, "0");
}
StaffEntity staffEntity = this.getExtCache(workNum);
// StaffEntity staffEntity = this.getExtCache(StrUtil.padPre(personInfo.getUserid(), 8, "0"));
//判断本地数据是否为空
if (ObjectUtils.isEmpty(staffEntity)) {
//新增员工信息
staffEntity = new StaffEntity();
staffEntity.initAttrValue();
staffEntity.setName(personInfo.getName());
//staffEntity.setRemarkId(personInfo.getPersonId());
//staffEntity.setPicUri(personInfo.getPersonPhoto() == null ? "" : personInfo.getPersonPhoto().getPicUri());
// staffEntity.setServerIndexCode(personInfo.getPersonPhoto() == null ? "" : personInfo.getPersonPhoto().getServerIndexCode());
staffEntity.setDeptName(deptEntity.getDeptName());
staffEntity.setDeptId(deptEntity.getId());
// staffEntity.setGender(personInfo.getGender());
staffEntity.setWorkNum(personInfo.getUserid());
staffEntity.setPhoneNumber(personInfo.getMobile());
staffEntity.setCreateUserId(1L);
staffEntity.setCreateTime(new Date());
this.save(staffEntity);
} else {
staffEntity.setStatus(StaffSatusEnum.正式.getValue());
staffEntity.setSource(SourceEnum.钉钉.getValue());
staffEntity.setName(personInfo.getName());
//staffEntity.setRemarkId(personInfo.getPersonId());
//staffEntity.setPicUri(personInfo.getPersonPhoto() == null ? "" : personInfo.getPersonPhoto().getPicUri());
// staffEntity.setServerIndexCode(personInfo.getPersonPhoto() == null ? "" : personInfo.getPersonPhoto().getServerIndexCode());
staffEntity.setDeptName(deptEntity.getDeptName());
staffEntity.setDeptId(deptEntity.getId());
// staffEntity.setGender(personInfo.getGender());
staffEntity.setWorkNum(personInfo.getUserid());
staffEntity.setPhoneNumber(personInfo.getMobile());
staffEntity.setUpdateUserId(1L);
staffEntity.setUpdateTime(new Date());
this.update(staffEntity);
StaffLeaveQuery staffLeaveQuery = new StaffLeaveQuery();
staffLeaveQuery.setWorkNum(staffEntity.getWorkNum());
StaffLeaveEntity staffLeaveEntity = staffLeaveService.selectOne(staffLeaveQuery, null);
if (!ObjectUtils.isEmpty(staffLeaveEntity)) {
staffLeaveService.remove(staffLeaveEntity.getId(), null);
}
}
if (staffCollect.size() > 0) {
//需要将此人员变更为离职
staffCollect.entrySet().stream().forEach(item -> {
String key = item.getKey();
if (!ObjectUtils.isEmpty(key)) {
StaffEntity staff = item.getValue();
staff.setStatus(StaffSatusEnum.离职.getValue());
staff.setLeaveDate(new Date());
staff.setUpdateTime(new Date());
staff.setUpdateUserId(1L);
this.update(staff);
//新增离职人员
StaffLeaveEntity staffLeaveEntity = new StaffLeaveEntity();
staffLeaveEntity.initAttrValue();
staffLeaveEntity.setStaffId(staff.getId());
staffLeaveEntity.setStaffName(staff.getName());
staffLeaveEntity.setGender(staff.getGender());
staffLeaveEntity.setBirthday(staff.getBirthday());
staffLeaveEntity.setPhotoPath(staff.getPhotoPath());
staffLeaveEntity.setPhoneNumber(staff.getPhoneNumber());
staffLeaveEntity.setIdCard(staff.getIdCard());
staffLeaveEntity.setWorkNum(staff.getWorkNum());
staffLeaveEntity.setPoliticalstatus(staff.getPoliticalstatus());
staffLeaveEntity.setDeptId(staff.getDeptId());
staffLeaveEntity.setDeptName(staff.getDeptName());
staffLeaveEntity.setJobId(staff.getPositionId());
staffLeaveEntity.setJobName(staff.getPositionName());
staffLeaveEntity.setStaffType(staff.getStaffType());
staffLeaveEntity.setStatus(StaffSatusEnum.离职.getValue());
staffLeaveEntity.setEntryDate(staff.getCreateTime());
staffLeaveEntity.setLeaveDate(new Date());
staffLeaveEntity.setLeaveReason("");
staffLeaveEntity.setAuditStatus(AuditStatusEnum.通过.getValue());
staffLeaveEntity.setCreateUserId(1L);
staffLeaveEntity.setCreateTime(new Date());
StaffLeaveQuery staffLeaveQuery = new StaffLeaveQuery();
staffLeaveQuery.setWorkNum(staff.getWorkNum());
int count = staffLeaveService.count(staffLeaveQuery, null);
if (count == 0) {
staffLeaveService.save(staffLeaveEntity);
}
}
});
}
}
log.info("部门{}获取人员信息:{}", deptCode, JSON.toJSONString(collect));
}
return null;
}
@Override @Override
public Rest<Void> syncRegisterUsersPhotos() { public Rest<Void> syncRegisterUsersPhotos() {
......
...@@ -56,6 +56,8 @@ hystrix: ...@@ -56,6 +56,8 @@ hystrix:
sms: sms:
smsSendUrl: @profiles.sms.smsSendUrl@ smsSendUrl: @profiles.sms.smsSendUrl@
apiId: @profiles.sms.apiId@ apiId: @profiles.sms.apiId@
source:
type: @profiles.source.type@ # hik:海康云 hik-device:海康考勤机 dingtalk:钉钉考勤
hik: hik:
host: @profiles.hik.host@ host: @profiles.hik.host@
appKey: @profiles.hik.appKey@ appKey: @profiles.hik.appKey@
......
...@@ -50,7 +50,7 @@ Content-Type: application/json ...@@ -50,7 +50,7 @@ Content-Type: application/json
{ {
"attendanceDateStart": "2025-01-01", "attendanceDateStart": "2025-01-01",
"attendanceDateEnd": "2025-01-02" "attendanceDateEnd": "2025-01-31"
} }
###海康考勤打卡记录计算1 ###海康考勤打卡记录计算1
...@@ -58,9 +58,9 @@ POST {{baseUrl}}/attendance/record/hik/addAttendanceRecord ...@@ -58,9 +58,9 @@ POST {{baseUrl}}/attendance/record/hik/addAttendanceRecord
Content-Type: application/json Content-Type: application/json
{ {
"attendanceDateStart": "2025-01-20", "attendanceDateStart": "2025-02-05",
"attendanceDateEnd": "2025-01-21", "attendanceDateEnd": "2025-02-05",
"staffId":317 "staffId":752
} }
...@@ -80,8 +80,8 @@ POST {{baseUrl}}/attendance/record/hik/addAttendanceHikRecordCustom ...@@ -80,8 +80,8 @@ POST {{baseUrl}}/attendance/record/hik/addAttendanceHikRecordCustom
Content-Type: application/json Content-Type: application/json
{ {
"attendanceDateStart": "2024-11-18", "attendanceDateStart": "2025-02-01",
"attendanceDateEnd": "2024-11-26" "attendanceDateEnd": "2025-03-18"
} }
...@@ -90,8 +90,8 @@ POST {{baseUrl}}/attendance/stat/summary ...@@ -90,8 +90,8 @@ POST {{baseUrl}}/attendance/stat/summary
Content-Type: application/json Content-Type: application/json
{ {
"summaryTimeStart": "2024-10-08", "summaryTimeStart": "2025-02-01",
"summaryTimeEnd": "2024-10-31" "summaryTimeEnd": "2025-03-18"
} }
......
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