Commit 494272f1 authored by 赵啸非's avatar 赵啸非

添加统计

parent c6dbaedc
...@@ -190,7 +190,10 @@ public class LoginController extends BaseCRUDJsonBodyMappingController<UserServi ...@@ -190,7 +190,10 @@ public class LoginController extends BaseCRUDJsonBodyMappingController<UserServi
JSONObject data = new JSONObject(); JSONObject data = new JSONObject();
String token = authTokenService.getToken(request); String token = authTokenService.getToken(request);
HomeStatInfo homeStatInfo = new HomeStatInfo();
HomeStatInfo homeStatInfo = cacheService.get(RedisKey.KEY_HOME_STAT_CACHE, HomeStatInfo.class);
/* HomeStatInfo homeStatInfo = new HomeStatInfo();
StaffQuery staffQuery = new StaffQuery(); StaffQuery staffQuery = new StaffQuery();
...@@ -207,8 +210,8 @@ public class LoginController extends BaseCRUDJsonBodyMappingController<UserServi ...@@ -207,8 +210,8 @@ public class LoginController extends BaseCRUDJsonBodyMappingController<UserServi
homeStatInfo.setTotalDeptNum(totalDeptNum); homeStatInfo.setTotalDeptNum(totalDeptNum);
AttendanceRecordHikQuery hikQuery = new AttendanceRecordHikQuery(); AttendanceRecordHikQuery hikQuery = new AttendanceRecordHikQuery();
/* hikQuery.setAttendanceDateStart(DateUtil.beginOfMonth(new Date()).toDateStr()); *//* hikQuery.setAttendanceDateStart(DateUtil.beginOfMonth(new Date()).toDateStr());
hikQuery.setAttendanceDateEnd(DateUtil.today()); */ hikQuery.setAttendanceDateEnd(DateUtil.today()); *//*
hikQuery.setAttendanceDateStart(DateUtil.yesterday().toDateStr()); hikQuery.setAttendanceDateStart(DateUtil.yesterday().toDateStr());
hikQuery.setAttendanceDateEnd(DateUtil.yesterday().toDateStr()); hikQuery.setAttendanceDateEnd(DateUtil.yesterday().toDateStr());
...@@ -222,17 +225,17 @@ public class LoginController extends BaseCRUDJsonBodyMappingController<UserServi ...@@ -222,17 +225,17 @@ public class LoginController extends BaseCRUDJsonBodyMappingController<UserServi
//获取当月打卡人数,如果存在 //获取当月打卡人数,如果存在
/* Long totalCache = cacheService.hget(RedisKey.KEY_ATTENC_TOTOAL_CACHE, DateUtil.format(new Date(), "yyyy-MM"), Long.class); *//* Long totalCache = cacheService.hget(RedisKey.KEY_ATTENC_TOTOAL_CACHE, DateUtil.format(new Date(), "yyyy-MM"), Long.class);
if (ObjectUtils.isEmpty(totalCache)) { if (ObjectUtils.isEmpty(totalCache)) {
totalCache = recordHikService.find(hikQuery).parallelStream().map(item -> item.getStaffId()).distinct().count(); totalCache = recordHikService.find(hikQuery).parallelStream().map(item -> item.getStaffId()).distinct().count();
cacheService.hset(RedisKey.KEY_ATTENC_TOTOAL_CACHE, DateUtil.format(new Date(), "yyyy-MM"), totalCache); cacheService.hset(RedisKey.KEY_ATTENC_TOTOAL_CACHE, DateUtil.format(new Date(), "yyyy-MM"), totalCache);
}*/ }*//*
/* Long totalCache = cacheService.hget(RedisKey.KEY_ATTENC_TOTOAL_CACHE, DateUtil.yesterday().toDateStr(), Long.class); *//* Long totalCache = cacheService.hget(RedisKey.KEY_ATTENC_TOTOAL_CACHE, DateUtil.yesterday().toDateStr(), Long.class);
if (ObjectUtils.isEmpty(totalCache)) { if (ObjectUtils.isEmpty(totalCache)) {
totalCache = recordHikService.find(hikQuery).parallelStream().map(item -> item.getStaffId()).distinct().count(); totalCache = recordHikService.find(hikQuery).parallelStream().map(item -> item.getStaffId()).distinct().count();
cacheService.hset(RedisKey.KEY_ATTENC_TOTOAL_CACHE, DateUtil.yesterday().toDateStr(), totalCache); cacheService.hset(RedisKey.KEY_ATTENC_TOTOAL_CACHE, DateUtil.yesterday().toDateStr(), totalCache);
}*/ }*//*
//迟到次数 //迟到次数
...@@ -260,14 +263,14 @@ public class LoginController extends BaseCRUDJsonBodyMappingController<UserServi ...@@ -260,14 +263,14 @@ public class LoginController extends BaseCRUDJsonBodyMappingController<UserServi
.count(); .count();
/* AttendanceVacationRecordQuery vacationRecordQuery = new AttendanceVacationRecordQuery(); *//* AttendanceVacationRecordQuery vacationRecordQuery = new AttendanceVacationRecordQuery();
vacationRecordQuery.setCreateTimeStart(DateUtil.beginOfMonth(new Date()).toDateStr()); vacationRecordQuery.setCreateTimeStart(DateUtil.beginOfMonth(new Date()).toDateStr());
vacationRecordQuery.setCreateTimeEnd(DateUtil.today()); vacationRecordQuery.setCreateTimeEnd(DateUtil.today());
int levealPersonNum = vacationRecordService.count(vacationRecordQuery, getContext());*/ int levealPersonNum = vacationRecordService.count(vacationRecordQuery, getContext());*//*
AttendanceLeaveRecordQuery leaveRecordQuery = new AttendanceLeaveRecordQuery(); AttendanceLeaveRecordQuery leaveRecordQuery = new AttendanceLeaveRecordQuery();
/* leaveRecordQuery.setCreateTimeStart(DateUtil.beginOfMonth(new Date()).toDateStr()); *//* leaveRecordQuery.setCreateTimeStart(DateUtil.beginOfMonth(new Date()).toDateStr());
leaveRecordQuery.setCreateTimeEnd(DateUtil.today());*/ leaveRecordQuery.setCreateTimeEnd(DateUtil.today());*//*
leaveRecordQuery.setCreateTimeStart(DateUtil.yesterday().toDateStr()); leaveRecordQuery.setCreateTimeStart(DateUtil.yesterday().toDateStr());
leaveRecordQuery.setCreateTimeEnd(DateUtil.yesterday().toDateStr()); leaveRecordQuery.setCreateTimeEnd(DateUtil.yesterday().toDateStr());
leaveRecordQuery.setProcessStatus(ProcessStatusEnum.已处理.getValue()); leaveRecordQuery.setProcessStatus(ProcessStatusEnum.已处理.getValue());
...@@ -275,12 +278,12 @@ public class LoginController extends BaseCRUDJsonBodyMappingController<UserServi ...@@ -275,12 +278,12 @@ public class LoginController extends BaseCRUDJsonBodyMappingController<UserServi
//总打卡记录 //总打卡记录
/* long totalAttend = attendanceRecordEntities.parallelStream().flatMap(item -> item.getAttendanceRecordDetailList().parallelStream()).count(); *//* long totalAttend = attendanceRecordEntities.parallelStream().flatMap(item -> item.getAttendanceRecordDetailList().parallelStream()).count();
long lackOfCardsAttend = attendanceRecordEntities.parallelStream() long lackOfCardsAttend = attendanceRecordEntities.parallelStream()
.flatMap(item -> item.getAttendanceRecordDetailList().stream()) .flatMap(item -> item.getAttendanceRecordDetailList().stream())
.filter(f -> GoWorkResultEnum.缺卡.getValue() == f.getGoWorkResult() || OffWorkResultEnum.缺卡.getValue() == f.getOffWorkResult()) .filter(f -> GoWorkResultEnum.缺卡.getValue() == f.getGoWorkResult() || OffWorkResultEnum.缺卡.getValue() == f.getOffWorkResult())
.count();*/ .count();*//*
//异常考勤记录 //异常考勤记录
//未考勤 //未考勤
// long noAtt=lackOfCards; // long noAtt=lackOfCards;
...@@ -298,7 +301,7 @@ public class LoginController extends BaseCRUDJsonBodyMappingController<UserServi ...@@ -298,7 +301,7 @@ public class LoginController extends BaseCRUDJsonBodyMappingController<UserServi
homeStatInfo.setLatePersonNum(beLate); homeStatInfo.setLatePersonNum(beLate);
homeStatInfo.setLeftEarlyPersonNum(leaveEarly); homeStatInfo.setLeftEarlyPersonNum(leaveEarly);
homeStatInfo.setMissCardPersonNum(lackOfCards); homeStatInfo.setMissCardPersonNum(lackOfCards);
homeStatInfo.setAttendPersonNum(totalAttendPersonNum); homeStatInfo.setAttendPersonNum(totalAttendPersonNum);*/
data.put("homeStat", homeStatInfo); data.put("homeStat", homeStatInfo);
data.put("token", token); data.put("token", token);
......
...@@ -26,4 +26,7 @@ public class RedisKey { ...@@ -26,4 +26,7 @@ public class RedisKey {
/** 考勤统计 **/ /** 考勤统计 **/
public static final String KEY_ATTENDANCE_STAT_CACHE = "attendance:stat"; public static final String KEY_ATTENDANCE_STAT_CACHE = "attendance:stat";
public static final String KEY_HOME_STAT_CACHE = "attendance:home:stat";
} }
...@@ -15,6 +15,7 @@ import com.mortals.xhx.common.code.YesNoEnum; ...@@ -15,6 +15,7 @@ import com.mortals.xhx.common.code.YesNoEnum;
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.AttendanceStatService;
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;
...@@ -46,23 +47,30 @@ public class SyncDoorsEventAfterTaskImpl implements ITaskExcuteService { ...@@ -46,23 +47,30 @@ public class SyncDoorsEventAfterTaskImpl implements ITaskExcuteService {
@Autowired @Autowired
private IHikDoorService hikDoorService; private IHikDoorService hikDoorService;
@Autowired
private AttendanceStatService attendanceStatService;
@Override @Override
public void excuteTask(ITask task) throws AppException { public void excuteTask(ITask task) throws AppException {
// syncDoorEvents(); // syncDoorEvents();
//判断时间段 不在时间段的 不做计算 //判断时间段 不在时间段的 不做计算
//早上9点 子晚上8点 计算 //早上9点 子晚上8点 计算
Date beginDateTime=DateUtil.parseDateTime(DateUtil.today()+" 09:00:00"); Date beginDateTime = DateUtil.parseDateTime(DateUtil.today() + " 09:00:00");
Date endDateTime=DateUtil.parseDateTime(DateUtil.today()+" 20:30:00"); Date endDateTime = DateUtil.parseDateTime(DateUtil.today() + " 20:30:00");
boolean in = DateUtil.isIn(new Date(), beginDateTime, endDateTime); boolean in = DateUtil.isIn(new Date(), beginDateTime, endDateTime);
if(in){ if (in) {
calculateAttendByDay(); calculateAttendByDay();
} }
//统计当日
log.info("统计当日考勤");
attendanceStatService.homeStat(null);
log.info("统计当日考勤结束");
} }
private void calculateAttendByDay() { private void calculateAttendByDay() {
Context context = new Context(); Context context = new Context();
UserEntity userEntity = new UserEntity(); UserEntity userEntity = new UserEntity();
...@@ -115,7 +123,7 @@ public class SyncDoorsEventAfterTaskImpl implements ITaskExcuteService { ...@@ -115,7 +123,7 @@ public class SyncDoorsEventAfterTaskImpl implements ITaskExcuteService {
doorEventReq.setPageNo(i); doorEventReq.setPageNo(i);
doorEventReq.setPageSize(1000); doorEventReq.setPageSize(1000);
doorEventsRest = hikDoorService.getDoorEvents(doorEventReq); doorEventsRest = hikDoorService.getDoorEvents(doorEventReq);
// log.info("doorEventsRest:{} msg:{},page:{}", doorEventsRest.getCode(), doorEventsRest.getMsg(), doorEventReq.getPageNo()); // log.info("doorEventsRest:{} msg:{},page:{}", doorEventsRest.getCode(), doorEventsRest.getMsg(), doorEventReq.getPageNo());
getDoorEvents(doorEventsRest); getDoorEvents(doorEventsRest);
} }
} }
......
...@@ -24,4 +24,8 @@ public interface AttendanceStatService extends ICRUDService<AttendanceStatEntity ...@@ -24,4 +24,8 @@ public interface AttendanceStatService extends ICRUDService<AttendanceStatEntity
void doAttendanceSummary(AttendanceSummaryQuery query); void doAttendanceSummary(AttendanceSummaryQuery query);
Result<AttendanceStatEntity> findExt(AttendanceSummaryQuery params, PageInfo pageInfo, Context context) throws AppException; Result<AttendanceStatEntity> findExt(AttendanceSummaryQuery params, PageInfo pageInfo, Context context) throws AppException;
void homeStat(Context context) throws AppException;
} }
\ No newline at end of file
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