Commit 15d2a115 authored by 赵啸非's avatar 赵啸非

添加适配直连考勤机定时任务代码

parent c993d21a
package com.mortals.xhx.daemon.task;
import cn.hutool.http.HttpUtil;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.service.ITask;
import com.mortals.framework.service.ITaskExcuteService;
import com.mortals.framework.utils.ServletUtils;
import com.mortals.xhx.base.system.upload.service.UploadService;
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.face.model.req.img.ImgReq;
import com.mortals.xhx.module.hik.face.service.IHikFaceService;
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 org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
import org.springframework.web.multipart.MultipartFile;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.util.List;
import java.util.stream.Collectors;
......@@ -38,11 +38,25 @@ public class SyncRegisterUserPicTaskImpl implements ITaskExcuteService {
@Autowired
private StaffService staffService;
@Value("${hik.host:}")
protected String hikhost;
@Autowired
private DoorService doorService;
@Override
public void excuteTask(ITask task) throws AppException {
log.info("同步员工照片任务");
syncRegisterUsersPhotos();
if (!ObjectUtils.isEmpty(hikhost)) {
staffService.syncRegisterUsersPhotos();
} else {
List<DoorEntity> doorEntities = doorService.find(new DoorQuery());
for (DoorEntity doorEntity : doorEntities) {
//todo 直连设备
}
}
// syncRegisterUsersPhotos();
log.info("同步员工任务照片完成");
}
......@@ -53,7 +67,6 @@ public class SyncRegisterUserPicTaskImpl implements ITaskExcuteService {
.filter(item -> ObjectUtils.isEmpty(item.getPhotoPath()))
.filter(item -> !ObjectUtils.isEmpty(item.getPicUri())).collect(Collectors.toList());
for (StaffEntity staff : staffList) {
ImgReq imgReq = new ImgReq();
imgReq.setServerIndexCode(staff.getServerIndexCode());
......
......@@ -23,6 +23,7 @@ import com.mortals.xhx.module.staff.service.StaffLeaveService;
import com.mortals.xhx.module.staff.service.StaffService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
......@@ -47,10 +48,13 @@ public class SyncUserTaskImpl implements ITaskExcuteService {
private IHikPersonService hikPersonService;
@Autowired
private IDingPersonService dingPersonService;
@Value("${hik.host:}")
protected String hikhost;
@Override
public void excuteTask(ITask task) throws AppException {
try {
if (!ObjectUtils.isEmpty(hikhost)) {
log.info("同步部门");
deptService.syncDept(null);
log.info("同步用户");
......@@ -94,6 +98,17 @@ public class SyncUserTaskImpl implements ITaskExcuteService {
} catch (Exception e) {
log.error("同步钉钉usreId失败");
}
} else {
//todo 设备直连
deptService.syncDeptByDevice(null);
staffService.syncPersonsByDevices(null);
}
} catch (Exception e) {
log.error("同步人事异常", e);
}
......
......@@ -91,4 +91,12 @@ public interface DeptService extends ICRUDService<DeptEntity, Long> {
*/
Rest<String> syncDept(Context context);
/**
* 通过设备同步部门信息
* @param context
* @return
*/
Rest<String> syncDeptByDevice(Context context);
}
\ No newline at end of file
......@@ -341,4 +341,12 @@ public class DeptServiceImpl extends AbstractCRUDServiceImpl<DeptDao, DeptEntity
return Rest.ok();
}
@Override
public Rest<String> syncDeptByDevice(Context context) {
//todo
return Rest.ok();
}
}
package com.mortals.xhx.module.door.model;
import java.util.List;
import java.util.ArrayList;
import java.math.BigDecimal;
import cn.hutool.core.date.DateUtil;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.mortals.framework.annotation.Excel;
import com.mortals.framework.model.BaseEntityLong;
import com.mortals.xhx.module.door.model.vo.DoorVo;
import lombok.Data;
/**
* 门禁设备实体对象
*
* @author zxfei
* @date 2023-11-22
*/
* 门禁设备实体对象
*
* @author zxfei
* @date 2024-03-18
*/
@Data
public class DoorEntity extends DoorVo {
private static final long serialVersionUID = 1L;
......@@ -35,6 +43,18 @@ public class DoorEntity extends DoorVo {
* 密码
*/
private String password;
/**
* 所属部门id
*/
private String deptId;
/**
* 所属部门名称
*/
private String deptName;
/**
* 备注
*/
private String remark;
@Override
public int hashCode() {
return this.getId().hashCode();
......@@ -58,5 +78,8 @@ public class DoorEntity extends DoorVo {
this.port = 0;
this.username = "";
this.password = "";
this.deptId = "";
this.deptName = "";
this.remark = "";
}
}
\ No newline at end of file
package com.mortals.xhx.module.door.model;
import java.util.List;
import com.mortals.xhx.module.door.model.DoorEntity;
/**
* 门禁设备查询对象
*
* @author zxfei
* @date 2023-11-22
*/
* 门禁设备查询对象
*
* @author zxfei
* @date 2024-03-18
*/
public class DoorQuery extends DoorEntity {
/** 开始 序号,主键,自增长 */
private Long idStart;
......@@ -106,6 +106,21 @@ public class DoorQuery extends DoorEntity {
/** 结束 修改时间 */
private String updateTimeEnd;
/** 所属部门id */
private List<String> deptIdList;
/** 所属部门id排除列表 */
private List <String> deptIdNotList;
/** 所属部门名称 */
private List<String> deptNameList;
/** 所属部门名称排除列表 */
private List <String> deptNameNotList;
/** 备注 */
private List<String> remarkList;
/** 备注排除列表 */
private List <String> remarkNotList;
/** OR条件集合,列表项之间是OR,项内容之间是AND,如:(list[0].1 and list[0].2) or (list[1].3 and list[1].4) */
private List<DoorQuery> orConditionList;
......@@ -662,6 +677,102 @@ public class DoorQuery extends DoorEntity {
this.updateTimeEnd = updateTimeEnd;
}
/**
* 获取 所属部门id
* @return deptIdList
*/
public List<String> getDeptIdList(){
return this.deptIdList;
}
/**
* 设置 所属部门id
* @param deptIdList
*/
public void setDeptIdList(List<String> deptIdList){
this.deptIdList = deptIdList;
}
/**
* 获取 所属部门id
* @return deptIdNotList
*/
public List<String> getDeptIdNotList(){
return this.deptIdNotList;
}
/**
* 设置 所属部门id
* @param deptIdNotList
*/
public void setDeptIdNotList(List<String> deptIdNotList){
this.deptIdNotList = deptIdNotList;
}
/**
* 获取 所属部门名称
* @return deptNameList
*/
public List<String> getDeptNameList(){
return this.deptNameList;
}
/**
* 设置 所属部门名称
* @param deptNameList
*/
public void setDeptNameList(List<String> deptNameList){
this.deptNameList = deptNameList;
}
/**
* 获取 所属部门名称
* @return deptNameNotList
*/
public List<String> getDeptNameNotList(){
return this.deptNameNotList;
}
/**
* 设置 所属部门名称
* @param deptNameNotList
*/
public void setDeptNameNotList(List<String> deptNameNotList){
this.deptNameNotList = deptNameNotList;
}
/**
* 获取 备注
* @return remarkList
*/
public List<String> getRemarkList(){
return this.remarkList;
}
/**
* 设置 备注
* @param remarkList
*/
public void setRemarkList(List<String> remarkList){
this.remarkList = remarkList;
}
/**
* 获取 备注
* @return remarkNotList
*/
public List<String> getRemarkNotList(){
return this.remarkNotList;
}
/**
* 设置 备注
* @param remarkNotList
*/
public void setRemarkNotList(List<String> remarkNotList){
this.remarkNotList = remarkNotList;
}
/**
* 设置 序号,主键,自增长
* @param id
......@@ -975,6 +1086,63 @@ public class DoorQuery extends DoorEntity {
}
/**
* 设置 所属部门id
* @param deptId
*/
public DoorQuery deptId(String deptId){
setDeptId(deptId);
return this;
}
/**
* 设置 所属部门id
* @param deptIdList
*/
public DoorQuery deptIdList(List<String> deptIdList){
this.deptIdList = deptIdList;
return this;
}
/**
* 设置 所属部门名称
* @param deptName
*/
public DoorQuery deptName(String deptName){
setDeptName(deptName);
return this;
}
/**
* 设置 所属部门名称
* @param deptNameList
*/
public DoorQuery deptNameList(List<String> deptNameList){
this.deptNameList = deptNameList;
return this;
}
/**
* 设置 备注
* @param remark
*/
public DoorQuery remark(String remark){
setRemark(remark);
return this;
}
/**
* 设置 备注
* @param remarkList
*/
public DoorQuery remarkList(List<String> remarkList){
this.remarkList = remarkList;
return this;
}
/**
* 获取 OR条件集合,列表项之间是OR,项内容之间是AND,如:(list[0].1 and list[0].2) or (list[1].3 and list[1].4)
* @return orConditionList
......
......@@ -51,11 +51,6 @@ public class DoorServiceImpl extends AbstractCRUDServiceImpl<DoorDao, DoorEntity
@Autowired
private IHikDoorService hikDoorService;
private Integer day;
@Autowired
private ICacheService cacheService;
@Override
public Rest<Void> syncDoorDeviceEvents(DoorEntity doorEntity, HikDoorEventReq hikDoorEventReq) {
......
......@@ -53,4 +53,10 @@ public interface StaffService extends ICRUDCacheService<StaffEntity,Long> {
*/
void doUpdateSala();
/**
* 通过海康云同步用户 照片
* @return
*/
Rest<Void> syncRegisterUsersPhotos();
}
\ No newline at end of file
......@@ -1175,29 +1175,6 @@ ADD COLUMN `salaId` bigint(20) COMMENT '所属大厅' AFTER `deptName`,
ADD COLUMN `salaName` varchar(128) COMMENT '所属大厅名称' AFTER `salaId`;
-- ----------------------------
2024-02-29
-- ----------------------------
-- ----------------------------
-- 门禁设备表
-- ----------------------------
DROP TABLE IF EXISTS `mortals_xhx_door`;
CREATE TABLE mortals_xhx_door(
`id` bigint(20) AUTO_INCREMENT COMMENT '序号,主键,自增长',
`deviceName` varchar(64) COMMENT '设备名称',
`deviceCode` varchar(64) COMMENT '设备编码',
`ip` varchar(64) COMMENT 'Ip地址',
`port` int(9) COMMENT '端口',
`username` varchar(64) COMMENT '用户名',
`password` varchar(64) COMMENT '密码',
`createTime` datetime COMMENT '创建时间',
`createUserId` bigint(20) COMMENT '创建用户',
`updateUserId` bigint(20) COMMENT '更新用户',
`updateTime` datetime COMMENT '修改时间',
PRIMARY KEY (`id`)
,KEY `deviceCode` (`deviceCode`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='门禁设备';
-- ------------------
-- 2024-03-12
-- 绩效表增加人员大厅字段
......@@ -1271,3 +1248,30 @@ ALTER TABLE `mortals_xhx_staff_perform_stat`
ALTER TABLE `mortals_xhx_staff_perform_summary`
ADD COLUMN `salaId` bigint(20) DEFAULT NULL COMMENT '所属大厅' AFTER `deptName`,
ADD COLUMN `salaName` varchar(128) DEFAULT NULL COMMENT '所属大厅名称' AFTER `salaId`;
-- ----------------------------
2024-03-18
-- ----------------------------
-- ----------------------------
-- 门禁设备表
-- ----------------------------
DROP TABLE IF EXISTS `mortals_xhx_door`;
CREATE TABLE mortals_xhx_door(
`id` bigint(20) AUTO_INCREMENT COMMENT '序号,主键,自增长',
`deviceName` varchar(64) COMMENT '设备名称',
`deviceCode` varchar(64) COMMENT '设备编码',
`ip` varchar(64) COMMENT 'Ip地址',
`port` int(9) COMMENT '端口',
`username` varchar(64) COMMENT '用户名',
`password` varchar(64) COMMENT '密码',
`createTime` datetime COMMENT '创建时间',
`createUserId` bigint(20) COMMENT '创建用户',
`updateUserId` bigint(20) COMMENT '更新用户',
`updateTime` datetime COMMENT '修改时间',
`deptId` bigint (20) COMMENT '所属部门id',
`deptName` varchar(64) COMMENT '所属部门名称',
`remark` varchar(256) COMMENT '备注',
PRIMARY KEY (`id`)
,KEY `deviceCode` (`deviceCode`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='门禁设备';
No preview for this file type
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