Commit b7455b29 authored by dll's avatar dll

更新考勤汇总

parents bab6820f 2afbf419
......@@ -26,9 +26,10 @@ const instance = axios.create({
instance.interceptors.request.use(config => {
// 获取当前页面的主机名和端口号
// const hostname = location.hostname;
const hostname = location.hostname;
const baseURL =config.baseURL;
//const port = location.port;
// const port =process.env.VUE_APP_PORTAL_PORT=='undefined'?'11078':process.env.VUE_APP_PORTAL_PORT;
// const port = location.port;
const port =process.env.VUE_APP_PORTAL_PORT=='undefined'?'11078':process.env.VUE_APP_PORTAL_PORT;
// 测试用
//http://192.168.0.98:11039
......@@ -41,8 +42,8 @@ instance.interceptors.request.use(config => {
//const hostname = '192.168.0.116'
//const port = '17500'
const hostname = '192.168.0.116'
const port = '17500'
// const hostname = '192.168.0.116'
// const port = '17500'
// const hostname = '192.168.0.98'
// const port = '11039'
......
......@@ -28,6 +28,8 @@
<profiles.log.path>/mortals/app/logs</profiles.log.path>
<profiles.log.level>info</profiles.log.level>
<profiles.publish.path>/home/publish</profiles.publish.path>
<profiles.sms.smsSendUrl>http://127.0.0.1:8089/api/index/index</profiles.sms.smsSendUrl>
<profiles.sms.apiId>k6BVS1PEbyzcJAE4</profiles.sms.apiId>
<profiles.hik.host>8.136.255.30:8001</profiles.hik.host>
<profiles.hik.appKey>25128371</profiles.hik.appKey>
<profiles.hik.appSecret>2m9RcPJOKq5j2QPQM4v5</profiles.hik.appSecret>
......@@ -52,7 +54,6 @@
<profiles.log.level>INFO</profiles.log.level>
<profiles.sms.smsSendUrl>http://127.0.0.1:8089/api/index/index</profiles.sms.smsSendUrl>
<profiles.sms.apiId>k6BVS1PEbyzcJAE4</profiles.sms.apiId>
<profiles.sms.type>3</profiles.sms.type>
<profiles.hik.host>8.136.255.30:8001</profiles.hik.host>
<profiles.hik.appKey>25128371</profiles.hik.appKey>
<profiles.hik.appSecret>2m9RcPJOKq5j2QPQM4v5</profiles.hik.appSecret>
......@@ -74,8 +75,6 @@
<profiles.log.level>INFO</profiles.log.level>
<profiles.sms.smsSendUrl>http://127.0.0.1:8089/api/index/index</profiles.sms.smsSendUrl>
<profiles.sms.apiId>k6BVS1PEbyzcJAE4</profiles.sms.apiId>
<profiles.sms.type>3</profiles.sms.type>
<profiles.hik.host>8.136.255.30:8001</profiles.hik.host>
<profiles.hik.appKey>25128371</profiles.hik.appKey>
<profiles.hik.appSecret>2m9RcPJOKq5j2QPQM4v5</profiles.hik.appSecret>
......
......@@ -34,7 +34,7 @@ import java.util.Map;
@Component
@Slf4j
@Order(1)
@Profile({"default", "develop", "test"})
@Profile({"default", "develop", "test1"})
public class WebLogAspect {
@Pointcut("execution(public * com.mortals..*Controller.*(..))")
public void webLog() {
......
package com.mortals.xhx.daemon.task;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.PageUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.mortals.framework.common.Rest;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.service.ITask;
import com.mortals.framework.service.ITaskExcuteService;
import com.mortals.xhx.common.code.YesNoEnum;
import com.mortals.xhx.module.attendance.model.AttendanceRecordHikEntity;
import com.mortals.xhx.module.attendance.model.AttendanceRecordHikQuery;
import com.mortals.xhx.module.attendance.service.AttendanceRecordHikService;
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.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.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
import java.time.Year;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
/**
* 同步获取当天海康门禁事件
*/
@Slf4j
@Service("SyncDoorsEventTask")
public class SyncDoorsEventTaskImpl implements ITaskExcuteService {
@Autowired
private AttendanceRecordHikService recordHikService;
@Autowired
private StaffService staffService;
@Autowired
private IHikDoorService hikDoorService;
@Override
public void excuteTask(ITask task) throws AppException {
DoorEventReq doorEventReq = new DoorEventReq();
List<Integer> eventTypes = new ArrayList<>();
eventTypes.add(196885);
eventTypes.add(196887);
eventTypes.add(196893);
eventTypes.add(196888);
eventTypes.add(196889);
eventTypes.add(196890);
eventTypes.add(196891);
doorEventReq.setEventTypes(eventTypes);
// 获取当天的开始时间
Date todayStart = DateUtil.beginOfDay(new Date());
// 获取当天的结束时间
Date todayEnd = DateUtil.endOfDay(new Date());
doorEventReq.setStartTime(todayStart);
doorEventReq.setEndTime(todayEnd);
doorEventReq.setPageNo(1);
doorEventReq.setPageSize(1);
Rest<DoorEventDataInfo> doorEventsRest = hikDoorService.getDoorEvents(doorEventReq);
log.info("doorEventsRest:{} msg:{}", doorEventsRest.getCode(), doorEventsRest.getMsg());
if (doorEventsRest.getCode() == YesNoEnum.YES.getValue()) {
//分页获取考勤数据
Integer total = doorEventsRest.getData().getTotal();
int pageCount = PageUtil.totalPage(total, 1000);
for (int i = 1; i <= pageCount; i++) {
doorEventReq.setPageNo(i);
doorEventReq.setPageSize(1000);
doorEventsRest = hikDoorService.getDoorEvents(doorEventReq);
log.info("doorEventsRest:{} msg:{},page:{}", doorEventsRest.getCode(), doorEventsRest.getMsg(),doorEventReq.getPageNo());
getDoorEvents( doorEventsRest);
}
}
}
private void getDoorEvents( Rest<DoorEventDataInfo> doorEventsRest) {
//同步当前考勤数据
List<AttendanceRecordHikEntity> attRecords = doorEventsRest.getData().getList().stream().map(item -> {
AttendanceRecordHikEntity recordHikEntity = new AttendanceRecordHikEntity();
recordHikEntity.initAttrValue();
StaffEntity staffCache = staffService.getExtCache(item.getJobNo());
if (ObjectUtils.isEmpty(staffCache)) return null;
recordHikEntity.setStaffId(staffCache.getId());
recordHikEntity.setStaffName(staffCache.getName());
recordHikEntity.setWorkNum(staffCache.getWorkNum());
recordHikEntity.setDeptId(staffCache.getDeptId());
recordHikEntity.setDeptName(staffCache.getDeptName());
recordHikEntity.setPositionId(staffCache.getPositionId());
recordHikEntity.setPositionName(staffCache.getPositionName());
recordHikEntity.setAttendanceDate(item.getEventTime());
recordHikEntity.setAttendanceAddress(item.getDoorName());
recordHikEntity.setEventSource("门禁点");
recordHikEntity.setRemark(item.getEventId());
recordHikEntity.setCreateTime(new Date());
recordHikEntity.setCreateUserName("system");
recordHikEntity.setCreateUserId(1L);
return recordHikEntity;
}).collect(Collectors.toList());
log.info("attRecords size:{}", attRecords.size());
List<String> eventIds = attRecords.parallelStream().map(i -> i.getRemark()).collect(Collectors.toList());
//查询当天考勤记录是否有重复的 有的 则不添加
AttendanceRecordHikQuery recordHikQuery = new AttendanceRecordHikQuery();
recordHikQuery.setAttendanceDateStart(DateUtil.format(DateUtil.beginOfDay(new Date()), "yyyy-MM-dd"));
recordHikQuery.setAttendanceDateEnd(DateUtil.format(DateUtil.beginOfDay(new Date()), "yyyy-MM-dd"));
recordHikQuery.setRemarkList(eventIds);
Set<String> eventIdSet = recordHikService.find(recordHikQuery).parallelStream().map(i -> i.getRemark()).collect(Collectors.toSet());
List<AttendanceRecordHikEntity> saveRecordList = attRecords.stream().filter(f -> !eventIdSet.contains(f.getRemark())).collect(Collectors.toList());
if (!ObjectUtils.isEmpty(saveRecordList)) {
recordHikService.save(saveRecordList);
}
log.info("saveRecordList size:{}", saveRecordList.size());
}
@Override
public void stopTask(ITask task) throws AppException {
}
public static void main(String[] args) {
// 获取当前时间的小时数
int hour = DateUtil.hour(new Date(), true);
// 获取当前时间所在小时的开始时间和结束时间
Date startTime = DateUtil.beginOfHour(new Date());
Date endTime = DateUtil.endOfHour(new Date());
// 格式化时间为指定格式
String startTimeStr = DateUtil.format(startTime, "yyyy-MM-dd HH:00:00");
String endTimeStr = DateUtil.format(endTime, "yyyy-MM-dd HH:59:59");
// 输出结果
System.out.println("当前时间所在小时的开始时间:" + startTimeStr);
System.out.println("当前时间所在小时的结束时间:" + endTimeStr);
}
}
......@@ -5,7 +5,6 @@ import com.alibaba.fastjson.JSONObject;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.service.ITask;
import com.mortals.framework.service.ITaskExcuteService;
import com.mortals.xhx.busiz.hik.ArtemisPostTest;
import com.mortals.xhx.busiz.rsp.DeptHikData;
import com.mortals.xhx.busiz.rsp.ListDept;
import com.mortals.xhx.busiz.rsp.ListItem;
......@@ -16,6 +15,9 @@ import com.mortals.xhx.module.attendance.model.AttendanceVacationBalanceEntity;
import com.mortals.xhx.module.dept.dao.ibatis.DeptDaoImpl;
import com.mortals.xhx.module.dept.model.DeptEntity;
import com.mortals.xhx.module.dept.service.DeptService;
import com.mortals.xhx.module.hik.person.model.req.org.OrgListReq;
import com.mortals.xhx.module.hik.person.model.req.person.PersonReq;
import com.mortals.xhx.module.hik.person.service.IHikPersonService;
import com.mortals.xhx.module.staff.dao.ibatis.StaffDaoImpl;
import com.mortals.xhx.module.staff.model.StaffEntity;
import com.mortals.xhx.module.staff.service.StaffService;
......@@ -51,22 +53,20 @@ public class SyncUserTaskImpl implements ITaskExcuteService {
@Autowired
private AttendanceVacationBalanceDaoImpl balanceDao;
@Autowired
private AttendanceRecordDaoImpl attendanceRecordDao;
@Autowired
private AttendanceRecordDetailDaoImpl attendanceRecordDetailDao;
@Autowired
private AttendanceRecordErrorDaoImpl attendanceRecordErrorDao;
private IHikPersonService hikPersonService;
@Override
public void excuteTask(ITask task) throws AppException {
log.info("同步用户--部门");
try {
//部门同步
String resultDept = ArtemisPostTest.callPostApiGetDeptList();
//String resultDept = ArtemisPostTest.callPostApiGetDeptList();
OrgListReq orgListReq = new OrgListReq();
orgListReq.setPageNo(1);
orgListReq.setPageSize(1000);
String resultDept = hikPersonService.getOrgListTrans(orgListReq);
JSONObject jsonObjectDept = JSON.parseObject(resultDept);
JSONObject jsonObjectDept1 = jsonObjectDept.getJSONObject("data");
DeptHikData deptHikData = JSONObject.parseObject(jsonObjectDept1.toJSONString(), DeptHikData.class);
......@@ -109,7 +109,12 @@ public class SyncUserTaskImpl implements ITaskExcuteService {
}
}
//同步员工
String resultPerson = ArtemisPostTest.callPostApiGetPersonList();
//String resultPerson = ArtemisPostTest.callPostApiGetPersonList();
PersonReq personReq = new PersonReq();
personReq.setPageNo(1);
personReq.setPageSize(1000);
String resultPerson = hikPersonService.getPersonListTrans(personReq);
JSONObject jsonObject = JSON.parseObject(resultPerson);
JSONObject jsonObject1 = jsonObject.getJSONObject("data");
PersonHikData personHikData = JSONObject.parseObject(jsonObject1.toJSONString(), PersonHikData.class);
......@@ -231,7 +236,7 @@ public class SyncUserTaskImpl implements ITaskExcuteService {
staffEntity1.setPhoneNumber(String.valueOf(list.getPhoneNo()));
}
service.update(staffEntity1);
if (Objects.nonNull(statEntity)){
if (Objects.nonNull(statEntity)) {
statEntity.initAttrValue();
statEntity.setStaffId(staffEntity1.getId());
statEntity.setStaffName(staffEntity1.getName());
......
......@@ -3,6 +3,8 @@ package com.mortals.xhx.module.attendance.model;
import java.util.Date;
import java.util.List;
import java.util.ArrayList;
import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.mortals.framework.annotation.Excel;
import com.mortals.framework.model.BaseEntityLong;
......@@ -64,6 +66,8 @@ public class AttendanceRecordErrorEntity extends AttendanceRecordErrorVo {
/**
* 上下班时间
*/
@JsonFormat(pattern = "HH:mm")
@JSONField(format = "HH:mm")
private Date goOffDateTime;
/**
* 异常时间
......@@ -468,4 +472,4 @@ public class AttendanceRecordErrorEntity extends AttendanceRecordErrorVo {
this.remark = "";
}
}
\ No newline at end of file
}
package com.mortals.xhx.module.attendance.model.vo;
import com.mortals.framework.model.BaseEntityLong;
import com.mortals.xhx.module.attendance.model.AttendanceRecordErrorEntity;
import lombok.Data;
import java.util.ArrayList;
import java.util.List;
/**
......@@ -9,6 +11,12 @@ import java.util.List;
* @author zxfei
* @date 2023-04-08
*/
@Data
public class AttendanceRecordErrorVo extends BaseEntityLong {
}
\ No newline at end of file
/**
* 上班or下班
*/
private String goOrOff;
}
package com.mortals.xhx.module.attendance.model.vo;
import com.mortals.framework.model.BaseEntityLong;
import com.mortals.xhx.module.attendance.model.AttendanceStatEntity;
import java.util.ArrayList;
import com.mortals.xhx.module.attendance.model.AttendanceStaffStatEntity;
import lombok.Data;
import java.util.List;
/**
* 考勤汇总信息视图对象
......@@ -9,6 +10,13 @@ import java.util.List;
* @author zxfei
* @date 2023-04-08
*/
@Data
public class AttendanceStatVo extends BaseEntityLong {
private List<AttendanceStaffStatEntity> attendanceStaffStatEntities;
private String startTime;
private String endTime;
}
\ No newline at end of file
package com.mortals.xhx.module.attendance.service;
import com.mortals.framework.model.Context;
import com.mortals.framework.service.ICRUDService;
import com.mortals.xhx.module.attendance.model.AttendanceRecordHikEntity;
/**
* AttendanceRecordHikService
*
......@@ -11,4 +13,10 @@ import com.mortals.xhx.module.attendance.model.AttendanceRecordHikEntity;
*/
public interface AttendanceRecordHikService extends ICRUDService<AttendanceRecordHikEntity,Long>{
}
\ No newline at end of file
/**
* 将原始数据导入打卡记录表
* @param entity
*/
public void addAttendanceRecord(AttendanceRecordHikEntity entity, Context context) throws Exception;
}
......@@ -50,8 +50,8 @@ public class AttendanceRecordServiceImpl extends AbstractCRUDServiceImpl<Attenda
if(!ObjectUtils.isEmpty(entity.getAttendanceRecordDetailList())){
entity.getAttendanceRecordDetailList().stream().peek(item->{
item.setRecordId(entity.getId());
item.setCreateUser(context.getUser().getLoginName());
item.setCreateUserId(context.getUser().getId());
item.setCreateUser(context==null?"admin":context.getUser().getLoginName());
item.setCreateUserId(context==null?1L:context.getUser().getId());
item.setCreateTime(new Date());
}).count();
attendanceRecordDetailService.save(entity.getAttendanceRecordDetailList());
......@@ -66,11 +66,11 @@ public class AttendanceRecordServiceImpl extends AbstractCRUDServiceImpl<Attenda
attendanceRecordDetailService.remove(attendanceRecordDetailIds,context);
entity.getAttendanceRecordDetailList().stream().peek(item ->{
item.setRecordId(entity.getId());
item.setCreateUser(context.getUser().getLoginName());
item.setCreateUserId(context.getUser().getId());
item.setCreateUser(context==null?"admin":context.getUser().getLoginName());
item.setCreateUserId(context==null?1L:context.getUser().getId());
item.setCreateTime(new Date());
item.setUpdateUser(context.getUser().getLoginName());
item.setUpdateUserId(context.getUser().getId());
item.setUpdateUser(context==null?"admin":context.getUser().getLoginName());
item.setUpdateUserId(context==null?1L:context.getUser().getId());
item.setUpdateTime(new Date());
}).count();
attendanceRecordDetailService.save(entity.getAttendanceRecordDetailList());
......
package com.mortals.xhx.module.attendance.service.impl;
import com.mortals.framework.model.PageInfo;
import com.mortals.xhx.module.attendance.model.AttendanceStaffStatEntity;
import com.mortals.xhx.module.attendance.model.AttendanceStaffStatQuery;
import com.mortals.xhx.module.attendance.service.AttendanceStaffStatService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.mortals.framework.service.impl.AbstractCRUDServiceImpl;
import com.mortals.framework.exception.AppException;
......@@ -6,14 +12,114 @@ import com.mortals.framework.model.Context;
import com.mortals.xhx.module.attendance.dao.AttendanceStatDao;
import com.mortals.xhx.module.attendance.model.AttendanceStatEntity;
import com.mortals.xhx.module.attendance.service.AttendanceStatService;
import java.util.List;
/**
* AttendanceStatService
* 考勤汇总信息 service实现
*
* @author zxfei
* @date 2023-04-08
*/
* AttendanceStatService
* 考勤汇总信息 service实现
*
* @author zxfei
* @date 2023-04-08
*/
@Service("attendanceStatService")
public class AttendanceStatServiceImpl extends AbstractCRUDServiceImpl<AttendanceStatDao, AttendanceStatEntity, Long> implements AttendanceStatService {
@Autowired
private AttendanceStaffStatService attendanceStaffStatService;
@Override
protected void findAfter(AttendanceStatEntity entity, Context context, List<AttendanceStatEntity> list) throws AppException {
//开始时间
String startYears =entity.getStartTime().split("-",0)[0];
Long startYear = Long.valueOf(startYears);
String startMonths = entity.getStartTime().split("-",0)[1];
Long startMonth =Long.valueOf(startMonths);
String startDays= entity.getStartTime().split("-",0)[2];
Long startDay =Long.valueOf(startDays);
//结束时间
String endYears =entity.getEndTime().split("-",0)[0];
Long endYear = Long.valueOf(endYears);
String endMonths = entity.getEndTime().split("-",0)[1];
Long endMonth =Long.valueOf(endMonths);
String endDays= entity.getEndTime().split("-",0)[2];
Long endDay =Long.valueOf(endDays);
list.forEach(item -> {
AttendanceStaffStatQuery staffStatQuery = new AttendanceStaffStatQuery();
staffStatQuery.setStaffId(entity.getStaffId());
if (startYear==endYear){
staffStatQuery.setYear(startYear.intValue());
}else {
staffStatQuery.setYearStart(startYear.intValue());
staffStatQuery.setYearEnd(endYear.intValue());
}
if (startMonth==endMonth){
staffStatQuery.setMonth(startMonth.intValue());
}else {
staffStatQuery.setMonthStart(startMonth.intValue());
staffStatQuery.setMonthEnd(startMonth.intValue());
}
if (startDay==endDay){
staffStatQuery.setDay(startDay.intValue());
}else {
staffStatQuery.setDayStart(startDay.intValue());
staffStatQuery.setDayEnd(startDay.intValue());
}
//比较 year month day todo
// staffStatQuery.setYear(year);//相等
// staffStatQuery.setYearStart();
// staffStatQuery.setYearEnd();
//month and day 同上
List<AttendanceStaffStatEntity> attendanceStaffStatEntities = attendanceStaffStatService.find(staffStatQuery);
item.setAttendanceStaffStatEntities(attendanceStaffStatEntities);
});
super.findAfter(entity, context, list);
}
@Override
protected void findAfter(AttendanceStatEntity params, PageInfo pageInfo, Context context, List<AttendanceStatEntity> list) throws AppException {
//开始时间
String startYears =params.getStartTime().split("-",0)[0];
Long startYear = Long.valueOf(startYears);
String startMonths = params.getStartTime().split("-",0)[1];
Long startMonth =Long.valueOf(startMonths);
String startDays= params.getStartTime().split("-",0)[2];
Long startDay =Long.valueOf(startDays);
//结束时间
String endYears =params.getEndTime().split("-",0)[0];
Long endYear = Long.valueOf(endYears);
String endMonths = params.getEndTime().split("-",0)[1];
Long endMonth =Long.valueOf(endMonths);
String endDays= params.getEndTime().split("-",0)[2];
Long endDay =Long.valueOf(endDays);
list.forEach(item -> {
AttendanceStaffStatQuery staffStatQuery = new AttendanceStaffStatQuery();
staffStatQuery.setStaffId(item.getStaffId());
if (startYear==endYear){
staffStatQuery.setYear(startYear.intValue());
}else {
staffStatQuery.setYearStart(startYear.intValue());
staffStatQuery.setYearEnd(endYear.intValue());
}
if (startMonth==endMonth){
staffStatQuery.setMonth(startMonth.intValue());
}else {
staffStatQuery.setMonthStart(startMonth.intValue());
staffStatQuery.setMonthEnd(endMonth.intValue());
}
if (startDay==endDay){
staffStatQuery.setDay(startDay.intValue());
}else {
staffStatQuery.setDayStart(startDay.intValue());
staffStatQuery.setDayEnd(endDay.intValue());
}
//比较 year month day todo
// staffStatQuery.setYear(year);//相等
// staffStatQuery.setYearStart();
// staffStatQuery.setYearEnd();
//month and day 同上
List<AttendanceStaffStatEntity> attendanceStaffStatEntities = attendanceStaffStatService.find(staffStatQuery);
item.setAttendanceStaffStatEntities(attendanceStaffStatEntities);
});
super.findAfter(params, pageInfo, context, list);
}
}
\ No newline at end of file
......@@ -23,6 +23,7 @@ import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import org.apache.commons.lang3.ArrayUtils;
import com.mortals.framework.util.StringUtils;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
import com.alibaba.fastjson.JSONObject;
......@@ -52,6 +53,9 @@ public class AttendanceRecordErrorController extends BaseCRUDJsonBodyMappingCont
@Autowired
private AttendanceClassService attendanceClassService;
@Autowired
private AttendanceClassDetailService classDetailService;
@Autowired
private AttendanceRecordService attendanceRecordService;
......@@ -76,7 +80,7 @@ public class AttendanceRecordErrorController extends BaseCRUDJsonBodyMappingCont
}
@PostMapping({"disposeError"})
@PostMapping(value = "disposeError")
public Rest<String> disposeError(@RequestBody AttendanceRecordErrorEntity query) {
Rest<String> ret = new Rest();
Context context = this.getContext();
......@@ -84,6 +88,7 @@ public class AttendanceRecordErrorController extends BaseCRUDJsonBodyMappingCont
query.setOperDateTime(new Date());
query.setProcessStatus(1);
errorService.update(query);
DateUtils.convertTime2Str(query.getErrorDateTime().getTime(),DateUtils.P_yyyy_MM_dd);
AttendanceRecordQuery attendanceRecordQuery = new AttendanceRecordQuery();
attendanceRecordQuery.setStaffId(query.getStaffId());
......@@ -94,21 +99,54 @@ public class AttendanceRecordErrorController extends BaseCRUDJsonBodyMappingCont
detailQuery.setRecordId(attendanceRecordEntity.getId());
detailQuery.setShiftsId(query.getShiftsId());
List<AttendanceRecordDetailEntity> attendanceRecordDetailEntity = attendanceRecordDetailService.find(detailQuery);
for (AttendanceRecordDetailEntity recordDetailEntity : attendanceRecordDetailEntity) {
Date goWorkDate = recordDetailEntity.getGoWorkDate();
Date offWorkDate = recordDetailEntity.getOffWorkDate();
if (goWorkDate.getTime()==query.getErrorDateTime().getTime()){
recordDetailEntity.setGoWorkResult(query.getErrorStatus());
if (query.getProcessResult().contains("正常")){
if (goWorkDate.getTime()==query.getGoOffDateTime().getTime()){
recordDetailEntity.setGoWorkResult(1);
}
if (offWorkDate.getTime()==query.getGoOffDateTime().getTime()){
recordDetailEntity.setOffWorkResult(1);
}
}
if (offWorkDate.getTime()==query.getErrorDateTime().getTime()){
recordDetailEntity.setOffWorkResult(query.getErrorStatus());
if (query.getProcessResult().contains("早退")){
if (offWorkDate.getTime()==query.getGoOffDateTime().getTime()){
recordDetailEntity.setOffWorkResult(5);
}
}
if (query.getProcessResult().contains("迟到")){
if (goWorkDate.getTime()==query.getGoOffDateTime().getTime()){
recordDetailEntity.setGoWorkResult(4);
}
}
attendanceRecordDetailService.update(recordDetailEntity);
}
return Rest.ok();
}
@Override
protected int editAfter(Long id, Map<String, Object> model, AttendanceRecordErrorEntity entity, Context context) throws AppException {
this.addDict(model, "errorStatus", paramService.getParamBySecondOrganize("AttendanceRecordError","errorStatus"));
return super.editAfter(id, model, entity, context);
}
@Override
protected void doListAfter(AttendanceRecordErrorEntity query, List<AttendanceRecordErrorEntity> list, Context context) throws AppException {
for (AttendanceRecordErrorEntity errorEntity : list) {
Long shiftsId = errorEntity.getShiftsId();
AttendanceClassDetailEntity attendanceClassDetailEntity = classDetailService.selectOne(new AttendanceClassDetailQuery().id(shiftsId));
if (errorEntity.getGoOffDateTime().getTime()==attendanceClassDetailEntity.getGoWorkDate().getTime()){
errorEntity.setGoOrOff("上班");
}
if (errorEntity.getGoOffDateTime().getTime()==attendanceClassDetailEntity.getOffWorkDate().getTime()){
errorEntity.setGoOrOff("下班");
}
}
super.doListAfter(query, list, context);
}
}
package com.mortals.xhx.module.attendance.web;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.base.system.param.service.ParamService;
import com.mortals.xhx.module.attendance.model.AttendanceClassQuery;
import com.mortals.xhx.module.attendance.model.AttendanceGroupQuery;
import com.mortals.xhx.module.attendance.service.AttendanceClassService;
import com.mortals.xhx.module.attendance.service.AttendanceGroupService;
import com.mortals.xhx.module.dept.model.DeptQuery;
import com.mortals.xhx.module.dept.service.DeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
......@@ -36,14 +42,26 @@ public class AttendanceStatController extends BaseCRUDJsonBodyMappingController<
@Autowired
private ParamService paramService;
@Autowired
private AttendanceGroupService attendanceGroupService;
@Autowired
private DeptService deptService;
@Autowired
private AttendanceClassService attendanceClassService;
public AttendanceStatController(){
super.setModuleDesc( "考勤汇总信息");
}
@Override
protected void init(Map<String, Object> model, Context context) {
this.addDict(model,"deptId",deptService.find(new DeptQuery()).stream().collect(Collectors.toMap(x->x.getId().toString(), y->y.getDeptName())));
this.addDict(model,"groupId",attendanceGroupService.find(new AttendanceGroupQuery()).stream().collect(Collectors.toMap(x->x.getId().toString(), y->y.getGroupName())));
this.addDict(model,"classId",attendanceClassService.find(new AttendanceClassQuery()).stream().collect(Collectors.toMap(x->x.getId().toString(), y->y.getClassName())));
super.init(model, context);
}
}
\ No newline at end of file
}
package com.mortals.xhx.module.hik;
import com.hikvision.artemis.sdk.config.ArtemisConfig;
import org.springframework.beans.factory.annotation.Value;
import java.util.HashMap;
import java.util.Map;
public abstract class AbstractHikService {
@Value("${hik.host:''}")
protected String host;
@Value("${hik.appKey:''}")
protected String appKey;
@Value("${hik.appSecret:''}")
protected String appSecret;
@Value("${hik.protocol:http://}")
protected String protocol;
public String ARTEMIS_PATH = "/artemis";
protected Map<String, String> path = new HashMap<>(2);
protected ArtemisConfig getArtemisConfig() {
ArtemisConfig config = new ArtemisConfig();
config.setHost(host);
config.setAppKey(appKey); // 秘钥appkey
config.setAppSecret(appSecret);// 秘钥appSecret
return config;
}
}
package com.mortals.xhx.module.hik;
import lombok.Data;
/**
* 海康请求基础类
* @author:
* @date: 2023/4/12 17:57
*/
@Data
public class BaseReq {
}
package com.mortals.xhx.module.hik;
public class HikApiRest<T> {
private T data;
private String code;
private String msg;
public T getData() {
return data;
}
public void setData(T data) {
this.data = data;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
}
package com.mortals.xhx.module.hik.door.model.req.door;
import com.alibaba.fastjson.annotation.JSONField;
import com.mortals.xhx.module.hik.BaseReq;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
@Data
public class DoorEventReq extends BaseReq implements Serializable {
/**
* 当前页
*/
private Integer pageNo;
/**
* 每页大小
*/
private Integer pageSize;
private String doorName;
private String sort;
/**
* 事件类型,参考[附录D2.1 门禁事件]
* @[软件产品-综合安防管理平台-附录-附录D 事件列表-附录D2 一卡通事件-附录D2.1 门禁事件]
*/
private List<Integer> eventTypes;
private List<String> readerDevIndexCodes;
private String personName;
private String doorRegionIndexCode;
@JSONField(format = "yyyy-MM-dd'T'HH:mm:ssXXX")
private Date receiveStartTime;
@JSONField(format = "yyyy-MM-dd'T'HH:mm:ssXXX")
private Date receiveEndTime;
@JSONField(format = "yyyy-MM-dd'T'HH:mm:ssXXX")
private Date startTime;
@JSONField(format = "yyyy-MM-dd'T'HH:mm:ssXXX")
private Date endTime;
private List<String> doorIndexCodes;
private String order;
}
package com.mortals.xhx.module.hik.door.model.rsp.door;
import lombok.Data;
import java.util.List;
@Data
public class DoorEventDataInfo {
private List<DoorEventInfo> list;
private Integer total;
private Integer totalPage;
private Integer pageNo;
}
package com.mortals.xhx.module.hik.door.model.rsp.door;
import com.alibaba.fastjson.annotation.JSONField;
import lombok.Data;
import java.util.Date;
@Data
public class DoorEventInfo{
private String eventId;
private String orgName;
private String svrIndexCode;
private String doorName;
private String orgIndexCode;
private String doorIndexCode;
private Integer eventType;
private String devIndexCode;
private String identityCardUri;
private String readerDevName;
private String devName;
private String cardNo;
private String personName;
@JSONField(format = "yyyy-MM-dd'T'HH:mm:ssXXX")
private Date receiveTime;
private String studentId;
private String readerDevIndexCode;
private String certNo;
private String doorRegionIndexCode;
private Integer inAndOutType;
private String picUri;
private String jobNo;
@JSONField(format = "yyyy-MM-dd'T'HH:mm:ssXXX")
private Date eventTime;
private String eventName;
private String personId;
}
\ No newline at end of file
package com.mortals.xhx.module.hik.door.service;
import com.mortals.framework.common.Rest;
import com.mortals.xhx.module.hik.door.model.req.door.DoorEventReq;
import com.mortals.xhx.module.hik.door.model.rsp.door.DoorEventDataInfo;
/**
* 海康门禁接口对接类
*
* @author:
* @date: 2023/4/12 17:47
*/
public interface IHikDoorService {
/**
* 获取门禁事件
*
* @author:
* @date: 2023/4/13 10:24
*/
Rest<DoorEventDataInfo> getDoorEvents(DoorEventReq doorEventReq);
}
package com.mortals.xhx.module.hik.door.service.impl;
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.xhx.module.hik.AbstractHikService;
import com.mortals.xhx.module.hik.HikApiRest;
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.service.IHikDoorService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.Map;
/**
* 海康人员接口类
*
* @author: zxfei
* @date: 2023/4/12 17:51
*/
@Service("hikDoorService")
@Slf4j
public class HikDoorServiceImpl extends AbstractHikService implements IHikDoorService {
@Override
public Rest<DoorEventDataInfo> getDoorEvents(DoorEventReq doorEventReq) {
ArtemisConfig config = getArtemisConfig();
String getCamsApi = ARTEMIS_PATH + "/api/acs/v2/door/events";
Map<String, String> path = new HashMap<>(2);
path.put(protocol, getCamsApi);
try {
log.info("door events req=>{}", JSON.toJSONString(doorEventReq));
String respJson = ArtemisHttpUtil.doPostStringArtemis(config, path, JSON.toJSONString(doorEventReq), null, null, "application/json");
// log.info("door events error resp=>{}", respJson);
HikApiRest<DoorEventDataInfo> rest = JSON.parseObject(respJson, new TypeReference<HikApiRest<DoorEventDataInfo>>() {
});
log.info("door events resp=>{}", rest.getCode());
if ("0".equals(rest.getCode())) {
return Rest.ok(rest.getData());
} else {
return Rest.fail(rest.getMsg());
}
} catch (Exception e) {
log.error("获取门禁事件异常", e);
return Rest.fail(e.getMessage());
}
}
}
package com.mortals.xhx.module.hik.person.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.person.model.req.person;
import com.mortals.xhx.module.hik.BaseReq;
import lombok.Data;
import java.io.Serializable;
@Data
public class PersonReq extends BaseReq implements Serializable {
/**
* 当前页
*/
private Integer pageNo;
/**
* 每页大小
*/
private Integer pageSize;
}
package com.mortals.xhx.module.hik.person.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.person.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.person.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.person.model.rsp.person;
import com.alibaba.fastjson.annotation.JSONField;
import lombok.Data;
import java.util.Date;
@Data
public class PersonInfo{
private int gender;
private String orgPath;
private String orgPathName;
private String orgIndexCode;
@JSONField(format = "yyyy-MM-dd'T'HH:mm:ssXXX")
private Date updateTime;
private String certificateNo;
private String phoneNo;
private String personName;
private PersonPhoto personPhoto;
@JSONField(format = "yyyy-MM-dd'T'HH:mm:ssXXX")
private Date createTime;
private String jobNo;
private String personId;
private int certificateType;
}
\ No newline at end of file
package com.mortals.xhx.module.hik.person.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
package com.mortals.xhx.module.hik.person.service;
import com.mortals.framework.common.Rest;
import com.mortals.xhx.module.hik.person.model.req.org.OrgListReq;
import com.mortals.xhx.module.hik.person.model.req.person.PersonReq;
import com.mortals.xhx.module.hik.person.model.rsp.org.OrgDataInfo;
import com.mortals.xhx.module.hik.person.model.rsp.person.PersonDataInfo;
/**
* 海康人员接口对接类
*
* @author:
* @date: 2023/4/12 17:47
*/
public interface IHikPersonService {
/**
* 获取人员接口
*
* @param personReq
* @return
*/
Rest<PersonDataInfo> getPersonList(PersonReq personReq);
/**
* 获取人员接口透传
*
* @param personReq
* @return
*/
String getPersonListTrans(PersonReq personReq);
/**
* 获取组织接口
*
* @param orgListReq
* @return
*/
Rest<OrgDataInfo> getOrgList(OrgListReq orgListReq);
/**
* 透传原始数据
*
* @param orgListReq
* @return
*/
String getOrgListTrans(OrgListReq orgListReq);
}
package com.mortals.xhx.module.hik.person.service.impl;
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.xhx.module.hik.AbstractHikService;
import com.mortals.xhx.module.hik.HikApiRest;
import com.mortals.xhx.module.hik.person.model.req.org.OrgListReq;
import com.mortals.xhx.module.hik.person.model.req.person.PersonReq;
import com.mortals.xhx.module.hik.person.model.rsp.org.OrgDataInfo;
import com.mortals.xhx.module.hik.person.model.rsp.person.PersonDataInfo;
import com.mortals.xhx.module.hik.person.service.IHikPersonService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.Map;
/**
* 海康人员接口类
*
* @author: zxfei
* @date: 2023/4/12 17:51
*/
@Service("hikPersonService")
@Slf4j
public class HikPersonServiceImpl extends AbstractHikService implements IHikPersonService {
@Override
public Rest<PersonDataInfo> getPersonList(PersonReq personReq) {
ArtemisConfig config = getArtemisConfig();
String getCamsApi = ARTEMIS_PATH + "/api/resource/v1/person/personList";
Map<String, String> path = new HashMap<>(2);
path.put(protocol, getCamsApi);
try {
String respJson = ArtemisHttpUtil.doPostStringArtemis(config, path, JSON.toJSONString(personReq), null, null, "application/json");
HikApiRest<PersonDataInfo> rest = JSON.parseObject(respJson, new TypeReference<HikApiRest<PersonDataInfo>>() {
});
if ("0".equals(rest.getCode())) {
return Rest.ok(rest.getData());
} else {
log.info("person error resp=>{}", respJson);
return Rest.fail(rest.getMsg());
}
} catch (Exception e) {
log.error("获取人员异常", e);
return Rest.fail(e.getMessage());
}
}
@Override
public String getPersonListTrans(PersonReq personReq) {
ArtemisConfig config = getArtemisConfig();
String getCamsApi = ARTEMIS_PATH + "/api/resource/v1/person/personList";
Map<String, String> path = new HashMap<>(2);
path.put(protocol, getCamsApi);
try {
return ArtemisHttpUtil.doPostStringArtemis(config, path, JSON.toJSONString(personReq), null, null, "application/json");
} catch (Exception e) {
log.error("获取人员异常", e);
return JSON.toJSONString(Rest.fail(e.getMessage()));
}
}
@Override
public Rest<OrgDataInfo> getOrgList(OrgListReq orgListReq) {
ArtemisConfig config = getArtemisConfig();
String getCamsApi = ARTEMIS_PATH + "/api/resource/v1/org/orgList";
Map<String, String> path = new HashMap<>(2);
path.put(protocol, getCamsApi);
try {
String respJson = ArtemisHttpUtil.doPostStringArtemis(config, path, JSON.toJSONString(orgListReq), null, null, "application/json");
HikApiRest<OrgDataInfo> rest = JSON.parseObject(respJson, new TypeReference<HikApiRest<OrgDataInfo>>() {
});
if ("0".equals(rest.getCode())) {
return Rest.ok(rest.getData());
} else {
log.info("org list error resp=>{}", respJson);
return Rest.fail(rest.getMsg());
}
} catch (Exception e) {
log.error("org list error ", e);
return Rest.fail(e.getMessage());
}
}
@Override
public String getOrgListTrans(OrgListReq orgListReq) {
ArtemisConfig config = getArtemisConfig();
String getCamsApi = ARTEMIS_PATH + "/api/resource/v1/org/orgList";
Map<String, String> path = new HashMap<>(2);
path.put(protocol, getCamsApi);
try {
return ArtemisHttpUtil.doPostStringArtemis(config, path, JSON.toJSONString(orgListReq), null, null, "application/json");
} catch (Exception e) {
log.error("org list error ", e);
return JSON.toJSONString(Rest.fail(e.getMessage()));
}
}
}
......@@ -56,7 +56,6 @@ hystrix:
sms:
smsSendUrl: @profiles.sms.smsSendUrl@
apiId: @profiles.sms.apiId@
type: @profiles.sms.type@
hik:
host: @profiles.hik.host@
appKey: @profiles.hik.appKey@
......
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