Commit ef048dd1 authored by 赵啸非's avatar 赵啸非

同步人员方法添加

parent 55225d82
package com.mortals.xhx.module.hik.staff.model.req.org;
import lombok.Data;
@Data
public class OrgListReq{
private String orgName;
private String orgIndexCodes;
private int pageNo;
private int pageSize;
}
\ No newline at end of file
package com.mortals.xhx.module.hik.staff.model.req.person;
package com.mortals.xhx.module.hik.staff.model.req.staff;
import com.mortals.xhx.module.hik.BaseReq;
import lombok.Data;
......@@ -7,7 +7,7 @@ import java.io.Serializable;
@Data
public class PersonReq extends BaseReq implements Serializable {
public class StaffReq extends BaseReq implements Serializable {
/**
* 当前页
......
package com.mortals.xhx.module.hik.staff.model.rsp.org;
import lombok.Data;
import java.util.List;
@Data
public class OrgDataInfo {
private List<OrgInfo> list;
private Integer total;
private Integer totalPage;
private Integer pageNo;
}
package com.mortals.xhx.module.hik.staff.model.rsp.org;
import lombok.Data;
@Data
public class OrgInfo {
private String orgName;
private String orgNo;
private String orgPath;
private String parentOrgIndexCode;
private String orgIndexCode;
private String updateTime;
private String parentOrgName;
}
\ No newline at end of file
package com.mortals.xhx.module.hik.staff.model.rsp.person;
import lombok.Data;
import java.util.List;
@Data
public class PersonDataInfo {
private List<PersonInfo> list;
private Integer total;
private Integer totalPage;
private Integer pageNo;
}
package com.mortals.xhx.module.hik.staff.model.rsp.person;
import com.alibaba.fastjson.annotation.JSONField;
import lombok.Data;
import java.util.Date;
@Data
public class PersonInfo{
private String personId;
private String personName;
private int gender;
private String orgPath;
private String orgIndexCode;
private String orgName;
private int certificateType;
private String certificateNo;
@JSONField(format = "yyyy-MM-dd'T'HH:mm:ssXXX")
private Date updateTime;
private String phoneNo;
private PersonPhoto personPhoto;
private String jobNo;
}
\ No newline at end of file
package com.mortals.xhx.module.hik.staff.model.rsp.person;
import lombok.Data;
@Data
public class PersonPhoto{
private String personPhotoIndexCode;
private String picUri;
private String personId;
private String serverIndexCode;
}
\ No newline at end of file
......@@ -3,7 +3,7 @@ package com.mortals.xhx.module.hik.staff.service;
import com.mortals.framework.common.Rest;
import com.mortals.xhx.module.door.model.DoorEntity;
import com.mortals.xhx.module.hik.staff.model.req.person.PersonReq;
import com.mortals.xhx.module.hik.staff.model.req.staff.StaffReq;
import com.mortals.xhx.module.hik.staff.model.rsp.person.PersonDataInfo;
import com.mortals.xhx.module.hik.staff.model.rsp.staff.search.UserSearchInfo;
......@@ -21,7 +21,7 @@ public interface IHikStaffService {
* @param personReq
* @return
*/
Rest<UserSearchInfo> getPersonList(PersonReq personReq, DoorEntity doorEntity);
Rest<UserSearchInfo> getPersonList(StaffReq personReq, DoorEntity doorEntity);
......
......@@ -3,16 +3,12 @@ package com.mortals.xhx.module.hik.staff.service.impl;
import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
import com.hikvision.artemis.sdk.ArtemisHttpUtil;
import com.hikvision.artemis.sdk.config.ArtemisConfig;
import com.mortals.framework.common.Rest;
import com.mortals.framework.exception.AppException;
import com.mortals.xhx.hikdoor.Acs.AcsMain;
import com.mortals.xhx.hikdoor.NetSDKDemo.HCNetSDK;
import com.mortals.xhx.module.door.model.DoorEntity;
import com.mortals.xhx.module.hik.AbstractHikService;
import com.mortals.xhx.module.hik.HikApiRest;
import com.mortals.xhx.module.hik.staff.model.req.person.PersonReq;
import com.mortals.xhx.module.hik.staff.model.req.staff.StaffReq;
import com.mortals.xhx.module.hik.staff.model.rsp.person.PersonDataInfo;
import com.mortals.xhx.module.hik.staff.model.rsp.staff.search.UserSearchInfo;
import com.mortals.xhx.module.hik.staff.service.IHikStaffService;
......@@ -22,8 +18,6 @@ import org.json.JSONObject;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
/**
* 海康人员接口类
......@@ -37,7 +31,7 @@ public class HikStaffServiceImpl extends AbstractHikService implements IHikStaff
//查询所有人员
@Override
public Rest<UserSearchInfo> getPersonList(PersonReq personReq, DoorEntity doorEntity) {
public Rest<UserSearchInfo> getPersonList(StaffReq personReq, DoorEntity doorEntity) {
//todo 新的链接设备
HCNetSDK hCNetSDK = createSDKInstance();
initLoadSdk(hCNetSDK);
......
......@@ -23,10 +23,18 @@ import com.mortals.xhx.module.attendance.service.AttendanceVacationBalanceServic
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.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.person.model.req.person.PersonReq;
import com.mortals.xhx.module.hik.person.model.rsp.person.PersonDataInfo;
import com.mortals.xhx.module.hik.person.model.rsp.person.PersonInfo;
import com.mortals.xhx.module.hik.person.service.IHikPersonService;
import com.mortals.xhx.module.hik.staff.model.req.staff.StaffReq;
import com.mortals.xhx.module.hik.staff.model.rsp.staff.search.UserInfoItem;
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.service.IHikStaffService;
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;
......@@ -70,17 +78,20 @@ public class StaffServiceImpl extends AbstractCRUDCacheServiceImpl<StaffDao, Sta
@Autowired
private IHikPersonService hikPersonService;
@Autowired
private IHikStaffService hikStaffService;
@Autowired
private AttendanceStatService attendanceStatService;
@Autowired
private AttendanceVacationBalanceService balanceService;
@Autowired
private IdgeneratorService idgeneratorService;
@Autowired
private StaffLeaveService staffLeaveService;
@Autowired
private AttendanceGroupStaffService attendanceGroupStaffService;
@Autowired
private DoorService doorService;
@Override
protected String getExtKey(StaffEntity data) {
......@@ -133,6 +144,126 @@ public class StaffServiceImpl extends AbstractCRUDCacheServiceImpl<StaffDao, Sta
@Override
public Rest<Void> syncPersons(Context context) {
log.info("同步人员!");
//todo 门禁获取人员
List<DoorEntity> doorEntities = doorService.find(new DoorQuery());
for (DoorEntity doorEntity : doorEntities) {
StaffReq staffReq = new StaffReq();
Rest<UserSearchInfo> rest = hikStaffService.getPersonList(staffReq, doorEntity);
if(rest.getCode()==YesNoEnum.YES.getValue()){
//做差集 更新本地用户为离职员工
StaffQuery staffQuery = new StaffQuery();
staffQuery.setSource(1);
staffQuery.setStatusNotList(Arrays.asList(StaffSatusEnum.离职.getValue()));
Map<String, StaffEntity> staffCollect = this.find(staffQuery).stream().collect(Collectors.toMap(x -> x.getWorkNum(), y -> y, (o, n) -> n));
UserInfoSearch userInfoSearch = rest.getData().getUserInfoSearch();
List<UserInfoItem> userInfoList = userInfoSearch.getUserInfo();
for (UserInfoItem userInfoItem : userInfoList) {
if (ObjectUtils.isEmpty(userInfoItem.getEmployeeNo())) {
log.info("EmployeeNo is null ==>{}", JSON.toJSONString(userInfoItem));
continue;
}
if (staffCollect.containsKey(userInfoItem.getEmployeeNo())) {
staffCollect.remove(userInfoItem.getEmployeeNo());
}
StaffEntity staffEntity = this.getExtCache(StrUtil.padPre(userInfoItem.getEmployeeNo(), 8, "0"));
DeptEntity deptEntity = deptService.selectOne(new DeptQuery().deptCode(userInfoItem.getBelongGroup()));
//判断本地数据是否为空
if (ObjectUtils.isEmpty(staffEntity)) {
//新增员工信息
staffEntity = new StaffEntity();
staffEntity.initAttrValue();
if (!ObjectUtils.isEmpty(deptEntity)) {
staffEntity.setDeptId(deptEntity.getId());
}
staffEntity.setName(userInfoItem.getName());
staffEntity.setDeptName(userInfoItem.getBelongGroup());
staffEntity.setGender("male".equals(userInfoItem.getGender())?1:2);
staffEntity.setWorkNum(userInfoItem.getEmployeeNo());
staffEntity.setCreateUserId(1L);
staffEntity.setCreateTime(new Date());
this.save(staffEntity);
} else {
//更新
if (!ObjectUtils.isEmpty(deptEntity)) {
staffEntity.setDeptId(deptEntity.getId());
}
staffEntity.setName(userInfoItem.getName());
staffEntity.setDeptName(userInfoItem.getBelongGroup());
staffEntity.setGender("male".equals(userInfoItem.getGender())?1:2);
staffEntity.setWorkNum(userInfoItem.getEmployeeNo());
staffEntity.setUpdateUserId(1L);
staffEntity.setUpdateTime(new Date());
this.update(staffEntity);
}
}
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.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.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);
}
//考勤人员中有离职的 删除
// 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);
}
}
});
}
}else{
}
}
/*
PersonReq personReq = new PersonReq();
personReq.setPageNo(1);
......@@ -247,14 +378,14 @@ public class StaffServiceImpl extends AbstractCRUDCacheServiceImpl<StaffDao, Sta
// 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);
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);
}
}
});
}
}
}*/
return Rest.ok();
}
......@@ -344,7 +475,6 @@ public class StaffServiceImpl extends AbstractCRUDCacheServiceImpl<StaffDao, Sta
}
@Override
protected StaffEntity findBefore(StaffEntity params, PageInfo pageInfo, Context context) throws AppException {
if (params.getDeptId() != null) {
......
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