Commit 9bbb3038 authored by 廖旭伟's avatar 廖旭伟

Merge remote-tracking branch 'origin/master'

parents 04d19eec b50d5da0
package com.mortals.xhx.module.attendance.service;
import com.mortals.framework.service.ICRUDCacheService;
import com.mortals.framework.service.ICRUDService;
import com.mortals.xhx.module.attendance.model.AttendanceRecordDetailEntity;
import com.mortals.xhx.module.attendance.model.AttendanceRecordQuery;
......@@ -13,7 +14,7 @@ import java.util.List;
* @author zxfei
* @date 2023-04-07
*/
public interface AttendanceRecordDetailService extends ICRUDService<AttendanceRecordDetailEntity,Long>{
public interface AttendanceRecordDetailService extends ICRUDCacheService<AttendanceRecordDetailEntity,Long> {
/**
* 查询每日打卡记录明细
* @param query
......
package com.mortals.xhx.module.attendance.service.impl;
import cn.hutool.core.date.DateUtil;
import com.mortals.framework.service.impl.AbstractCRUDCacheServiceImpl;
import com.mortals.framework.util.DataUtil;
import com.mortals.xhx.module.attendance.model.AttendanceRecordDetailQuery;
import com.mortals.xhx.module.attendance.model.AttendanceRecordQuery;
import com.mortals.xhx.module.attendance.service.AttendanceRecordService;
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;
......@@ -8,7 +14,9 @@ import com.mortals.xhx.module.attendance.dao.AttendanceRecordDetailDao;
import com.mortals.xhx.module.attendance.model.AttendanceRecordDetailEntity;
import com.mortals.xhx.module.attendance.service.AttendanceRecordDetailService;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* AttendanceRecordDetailService
......@@ -18,7 +26,28 @@ import java.util.List;
* @date 2023-04-07
*/
@Service("attendanceRecordDetailService")
public class AttendanceRecordDetailServiceImpl extends AbstractCRUDServiceImpl<AttendanceRecordDetailDao, AttendanceRecordDetailEntity, Long> implements AttendanceRecordDetailService {
public class AttendanceRecordDetailServiceImpl extends AbstractCRUDCacheServiceImpl<AttendanceRecordDetailDao, AttendanceRecordDetailEntity, Long> implements AttendanceRecordDetailService {
@Autowired
private AttendanceRecordService attendanceRecordService;
@Override
public void loadCache() {
//仅读取当日数据
log.info("removeAllCache..." + this.getCacheName());
cacheService.del(this.getCacheName());
log.info("loadCache..." + this.getCacheName());
AttendanceRecordQuery attendanceRecordQuery = new AttendanceRecordQuery();
attendanceRecordQuery.setAttendanceDateStart(DateUtil.today());
attendanceRecordQuery.setAttendanceDateEnd(DateUtil.today());
attendanceRecordService.find(attendanceRecordQuery).parallelStream().forEach(item->{
AttendanceRecordDetailQuery detailQuery = new AttendanceRecordDetailQuery();
detailQuery.setRecordId(item.getId());
this.getDao().getList(detailQuery).parallelStream().forEach(entity->{
this.putCache(entity.getId().toString(), entity);
});
});
}
@Override
public List<AttendanceRecordDetailEntity> getListByWhere(AttendanceRecordQuery query) {
......
......@@ -140,8 +140,6 @@ public class AttendanceRecordErrorServiceImpl extends AbstractCRUDServiceImpl<At
AttendanceSummaryQuery query = new AttendanceSummaryQuery();
query.setStaffId(entity.getStaffId());
query.setSummaryTime(DateUtils.getStrDate(entity.getErrorDateTime()));
// AttendSummaryThread summaryThread = new AttendSummaryThread(attendanceStatService, query);
// ThreadPool.getInstance().execute(summaryThread);
cacheService.lpush(KEY_ATTENDANCE_STAT_CACHE, query);
//立即汇总考勤绩效分数
StaffCheckSummaryQuery checkSummaryQuery = new StaffCheckSummaryQuery();
......@@ -208,7 +206,6 @@ public class AttendanceRecordErrorServiceImpl extends AbstractCRUDServiceImpl<At
if (CollectionUtils.isNotEmpty(list)) {
log.info("重新生成[" + day + "]已处理的绩效考勤核查数据.....");
for (AttendanceRecordErrorEntity entity : list) {
// if (YesNoEnum.YES.getValue() == entity.getProcessStatus()) {
//判断后打绩效
String ruleCode = getRuleCode(entity);
if (!ObjectUtils.isEmpty(ruleCode)) {
......@@ -256,7 +253,6 @@ public class AttendanceRecordErrorServiceImpl extends AbstractCRUDServiceImpl<At
if (!ObjectUtils.isEmpty(delAttendRecords)) {
Long[] delIds = delAttendRecords.stream().map(i -> i.getId()).toArray(Long[]::new);
performAttendRecordService.remove(delIds, context);
//log.info("删除考勤记录成功,size:{}", delIds.length);
}
}
}
......@@ -265,9 +261,7 @@ public class AttendanceRecordErrorServiceImpl extends AbstractCRUDServiceImpl<At
@Override
protected void saveAfter(AttendanceRecordErrorEntity entity, Context context) throws AppException {
super.saveAfter(entity, context);
// if (YesNoEnum.YES.getValue() == entity.getProcessStatus()) {
//判断后打绩效
// log.info("生成绩效考勤核查数据.....");
String ruleCode = getRuleCode(entity);
if (!ObjectUtils.isEmpty(ruleCode)) {
saveAttendPerformRecord(context, entity, ruleCode);
......@@ -278,9 +272,7 @@ public class AttendanceRecordErrorServiceImpl extends AbstractCRUDServiceImpl<At
protected void saveAfter(List<AttendanceRecordErrorEntity> list, Context context) throws AppException {
super.saveAfter(list, context);
if (!ObjectUtils.isEmpty(list)) {
// log.info("生成绩效考勤核查数据.....");
for (AttendanceRecordErrorEntity entity : list) {
// if (YesNoEnum.YES.getValue() == entity.getProcessStatus()) {
//判断后打绩效
String ruleCode = getRuleCode(entity);
if (!ObjectUtils.isEmpty(ruleCode)) {
......@@ -318,7 +310,6 @@ public class AttendanceRecordErrorServiceImpl extends AbstractCRUDServiceImpl<At
leaveRecordQuery.setLeavePersonId(entity.getStaffId());
leaveRecordQuery.setAuditResultList(Arrays.asList(1, 4));
List<AttendanceLeaveRecordEntity> leaveRecordEntities = attendanceLeaveRecordService.find(leaveRecordQuery);
List<AttendanceLeaveRecordEntity> leaveRecords = null;
if (!ObjectUtils.isEmpty(leaveRecordEntities)) {
//判断当日日期中 是否有请假记录
......@@ -472,25 +463,7 @@ public class AttendanceRecordErrorServiceImpl extends AbstractCRUDServiceImpl<At
}
}
}
/*
if (compare < 0) {
//异常时间小于请假结束时间,迟到则计算异常时间与班次班次班时间还有前置时间差值
long tempLate = DateUtil.between(goOffDateTime, entity.getErrorDateTime(), DateUnit.MINUTE, false);
if (tempLate > 0L) {
lateMinList.add(tempLate);
}
}
if (compare >= 0) {
//异常时间小于请假结束时间,迟到则计算异常时间与班次班次班时间还有前置时间差值
long tempLate = DateUtil.between(goOffDateTime, leaveRecord.getEndTime(), DateUnit.MINUTE, false);
if (tempLate > 0L) {
lateMinList.add(tempLate);
}
}*/
}
if (between > 0) {
//todo 跨天
}
......
......@@ -5,6 +5,10 @@ import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context;
import com.mortals.xhx.common.code.*;
import com.mortals.xhx.module.attendance.model.*;
import com.mortals.xhx.module.holiday.model.HolidayEntity;
import com.mortals.xhx.module.holiday.model.HolidayQuery;
import com.mortals.xhx.module.holiday.service.HolidayService;
import com.mortals.xhx.utils.SpringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.util.ObjectUtils;
......@@ -26,6 +30,8 @@ public abstract class AttendanceWorkAbstract {
abstract void initData();
private HolidayService holidayService;
public abstract void doHandleWork(CommonData commonData);
......@@ -136,8 +142,41 @@ public abstract class AttendanceWorkAbstract {
}
protected Boolean checkWorkByHoliday(String date) {
Boolean bool = false;
HolidayQuery holidayQuery = new HolidayQuery();
holidayQuery.setStartTimeStart(date);
holidayQuery.setStartTimeEnd(date);
HolidayEntity holidayEntity = holidayService.selectOne(holidayQuery);
if (!ObjectUtils.isEmpty(holidayEntity)) {
Integer workorholiday = holidayEntity.getWorkorholiday();
if (workorholiday == YesNoEnum.YES.getValue()) {
bool = true;
}
}
return bool;
}
protected Boolean checkHolidayByWorkDay(String date) {
Boolean bool = false;
HolidayQuery holidayQuery = new HolidayQuery();
holidayQuery.setStartTimeStart(date);
holidayQuery.setStartTimeEnd(date);
HolidayEntity holidayEntity = holidayService.selectOne(holidayQuery);
if (!ObjectUtils.isEmpty(holidayEntity)) {
Integer workorholiday = holidayEntity.getWorkorholiday();
if (workorholiday == YesNoEnum.NO.getValue()) {
bool = true;
}
}
return bool;
}
public AttendanceWorkAbstract(int type) {
this.holidayService = SpringUtils.getBean(HolidayService.class);
this.type = type;
}
......
......@@ -32,38 +32,17 @@ public class FixWorkOtherAttendance extends AttendanceWorkAbstract {
private AttendanceGroupFixedworkService attendanceGroupFixedworkService;
private AttendanceClassService attendanceClassService;
private AttendanceClassDetailService attendanceClassDetailService;
private AttendanceGroupFixedworkSpecialService specialService;
private AttendanceRecordService attendanceRecordService;
private AttendanceRecordHikService recordHikService;
private AttendanceRecordErrorService errorService;
private HolidayService holidayService;
private AttendanceLeaveRecordService attendanceLeaveRecordService;
private AttendanceRecordDetailService attendanceRecordDetailService;
private Map<Long, AttendanceClassDetailEntity> classDetailEntityMap;
public FixWorkOtherAttendance(int type) {
super(type);
this.attendanceGroupFixedworkService = SpringUtils.getBean(AttendanceGroupFixedworkService.class);
this.attendanceClassService = SpringUtils.getBean(AttendanceClassService.class);
this.specialService = SpringUtils.getBean(AttendanceGroupFixedworkSpecialService.class);
this.attendanceRecordService = SpringUtils.getBean(AttendanceRecordService.class);
this.recordHikService = SpringUtils.getBean(AttendanceRecordHikService.class);
this.attendanceClassDetailService = SpringUtils.getBean(AttendanceClassDetailService.class);
this.errorService = SpringUtils.getBean(AttendanceRecordErrorService.class);
this.holidayService = SpringUtils.getBean(HolidayService.class);
this.attendanceLeaveRecordService = SpringUtils.getBean(AttendanceLeaveRecordService.class);
this.attendanceRecordDetailService = SpringUtils.getBean(AttendanceRecordDetailService.class);
}
@Override
......@@ -90,11 +69,9 @@ public class FixWorkOtherAttendance extends AttendanceWorkAbstract {
String week = super.getWeek(DateUtil.parseDate(commonData.getDateStr()));
//获取当前日期的详细班次
Long weekClassId = this.getWeekClassId(attendanceGroupFixedworkEntity, week);
//log.info("weekClassId:{}", weekClassId);
//weekClassId为-1 则不在考勤
Boolean checkWorkByHoliday = checkWorkByHoliday(commonData.getDateStr());
Boolean checkHolidayByWorkDay = checkHolidayByWorkDay(commonData.getDateStr());
if (weekClassId == -1L) {
//跳过本次循环
if (!checkWorkByHoliday) {
......@@ -165,7 +142,6 @@ public class FixWorkOtherAttendance extends AttendanceWorkAbstract {
return;
}
}
if (AddWayEnum.时间段.getValue() == specialEntity.getAddWay()) {
Date specialStartTime = specialEntity.getSpecialStartTime();
Date specialEndTime = specialEntity.getSpecialEndTime();
......@@ -336,7 +312,6 @@ public class FixWorkOtherAttendance extends AttendanceWorkAbstract {
if (ObjectUtils.isEmpty(goWorkDate)) {
//goWorkDate为空 缺卡状态
Date goWorkDate1 = attendanceClassDetailEntity.getGoWorkDate();
if (attendanceClassDetailEntity.getGoWorkDateAfter() > 0) {
goWorkDate1 = DateUtil.offsetMinute(goWorkDate1, attendanceClassDetailEntity.getGoWorkDateAfter());
}
......@@ -346,7 +321,6 @@ public class FixWorkOtherAttendance extends AttendanceWorkAbstract {
if (in) {
detail.setGoWorkResult(GoWorkResultEnum.请假.getValue());
}
} else {
boolean in = DateUtil.isIn(goWorkDate, startLeaveTime, endLeaveTime);
if (in) {
......@@ -486,36 +460,7 @@ public class FixWorkOtherAttendance extends AttendanceWorkAbstract {
}
}
private Boolean checkWorkByHoliday(String date) {
Boolean bool = false;
HolidayQuery holidayQuery = new HolidayQuery();
holidayQuery.setStartTimeStart(date);
holidayQuery.setStartTimeEnd(date);
HolidayEntity holidayEntity = holidayService.selectOne(holidayQuery);
if (!ObjectUtils.isEmpty(holidayEntity)) {
Integer workorholiday = holidayEntity.getWorkorholiday();
if (workorholiday == YesNoEnum.YES.getValue()) {
bool = true;
}
}
return bool;
}
private Boolean checkHolidayByWorkDay(String date) {
Boolean bool = false;
HolidayQuery holidayQuery = new HolidayQuery();
holidayQuery.setStartTimeStart(date);
holidayQuery.setStartTimeEnd(date);
HolidayEntity holidayEntity = holidayService.selectOne(holidayQuery);
if (!ObjectUtils.isEmpty(holidayEntity)) {
Integer workorholiday = holidayEntity.getWorkorholiday();
if (workorholiday == YesNoEnum.NO.getValue()) {
bool = true;
}
}
return bool;
}
public static void main(String[] args) {
......
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