Commit f85d5b1a authored by 廖旭伟's avatar 廖旭伟

绩效汇总数据初始化时不生成已离职员工数据

parent 7c8fa494
...@@ -4,6 +4,7 @@ import com.mortals.framework.exception.AppException; ...@@ -4,6 +4,7 @@ import com.mortals.framework.exception.AppException;
import com.mortals.framework.service.ITask; import com.mortals.framework.service.ITask;
import com.mortals.framework.service.ITaskExcuteService; import com.mortals.framework.service.ITaskExcuteService;
import com.mortals.framework.util.DateUtils; import com.mortals.framework.util.DateUtils;
import com.mortals.xhx.common.code.StaffSatusEnum;
import com.mortals.xhx.module.holiday.model.HolidayEntity; import com.mortals.xhx.module.holiday.model.HolidayEntity;
import com.mortals.xhx.module.holiday.model.HolidayQuery; import com.mortals.xhx.module.holiday.model.HolidayQuery;
import com.mortals.xhx.module.holiday.service.HolidayService; import com.mortals.xhx.module.holiday.service.HolidayService;
...@@ -70,24 +71,36 @@ public class StaffPerformInitDataTaskImpl implements ITaskExcuteService { ...@@ -70,24 +71,36 @@ public class StaffPerformInitDataTaskImpl implements ITaskExcuteService {
if(CollectionUtils.isNotEmpty(allStaff)) { if(CollectionUtils.isNotEmpty(allStaff)) {
List<StaffPerformStatEntity> list = new ArrayList<>(); List<StaffPerformStatEntity> list = new ArrayList<>();
allStaff.stream().forEach(item -> { allStaff.stream().forEach(item -> {
StaffPerformStatEntity statEntity = new StaffPerformStatEntity(); boolean flag = true;
statEntity.initAttrValue(); if(item.getStatus() == StaffSatusEnum.离职.getValue()) {
statEntity.setStaffId(item.getId()); if(item.getLeaveDate()!=null){
statEntity.setStaffName(item.getName()); String leaveDateStr = DateUtils.getStrDate(item.getLeaveDate());
statEntity.setYear(year); if(DateUtils.StrToDate(leaveDateStr).compareTo(DateUtils.StrToDate(dateStr)) < 0){
statEntity.setMonth(month); //离职日期在统计日期之前不统计
statEntity.setDay(dayOfMonth); flag = false;
statEntity.setTotalScore(totalScore); }
statEntity.setCreateUserId(1l); }
statEntity.setCreateTime(new Date()); }
StaffPerformStatQuery tempQuery = new StaffPerformStatQuery(); if(flag){
tempQuery.setStaffId(statEntity.getStaffId()); StaffPerformStatEntity statEntity = new StaffPerformStatEntity();
tempQuery.setYear(statEntity.getYear()); statEntity.initAttrValue();
tempQuery.setMonth(statEntity.getMonth()); statEntity.setStaffId(item.getId());
tempQuery.setDay(statEntity.getDay()); statEntity.setStaffName(item.getName());
StaffPerformStatEntity temp = staffPerformStatService.selectOne(tempQuery); statEntity.setYear(year);
if(temp==null) { statEntity.setMonth(month);
list.add(statEntity); statEntity.setDay(dayOfMonth);
statEntity.setTotalScore(totalScore);
statEntity.setCreateUserId(1l);
statEntity.setCreateTime(new Date());
StaffPerformStatQuery tempQuery = new StaffPerformStatQuery();
tempQuery.setStaffId(statEntity.getStaffId());
tempQuery.setYear(statEntity.getYear());
tempQuery.setMonth(statEntity.getMonth());
tempQuery.setDay(statEntity.getDay());
StaffPerformStatEntity temp = staffPerformStatService.selectOne(tempQuery);
if (temp == null) {
list.add(statEntity);
}
} }
}); });
staffPerformStatService.save(list); staffPerformStatService.save(list);
...@@ -99,24 +112,36 @@ public class StaffPerformInitDataTaskImpl implements ITaskExcuteService { ...@@ -99,24 +112,36 @@ public class StaffPerformInitDataTaskImpl implements ITaskExcuteService {
if(CollectionUtils.isNotEmpty(allStaff)) { if(CollectionUtils.isNotEmpty(allStaff)) {
List<StaffPerformSummaryEntity> summaryList = new ArrayList<>(); List<StaffPerformSummaryEntity> summaryList = new ArrayList<>();
allStaff.stream().forEach(item -> { allStaff.stream().forEach(item -> {
StaffPerformSummaryEntity staffPerformSummaryEntity = new StaffPerformSummaryEntity(); boolean flag = true;
staffPerformSummaryEntity.initAttrValue(); if(item.getStatus() == StaffSatusEnum.离职.getValue()) {
staffPerformSummaryEntity.setStaffId(item.getId()); if(item.getLeaveDate()!=null){
staffPerformSummaryEntity.setStaffName(item.getName()); String leaveDateStr = DateUtils.getStrDate(item.getLeaveDate());
staffPerformSummaryEntity.setDeptId(item.getDeptId()); if(DateUtils.StrToDate(leaveDateStr).compareTo(DateUtils.StrToDate(dateStr)) < 0){
staffPerformSummaryEntity.setDeptName(item.getDeptName()); //离职日期在统计日期之前不统计
staffPerformSummaryEntity.setYear(year); flag = false;
staffPerformSummaryEntity.setMonth(month); }
staffPerformSummaryEntity.setTotalScore(totalScore); }
staffPerformSummaryEntity.setCreateUserId(1l); }
staffPerformSummaryEntity.setCreateTime(new Date()); if(flag) {
StaffPerformSummaryQuery summaryQuery = new StaffPerformSummaryQuery(); StaffPerformSummaryEntity staffPerformSummaryEntity = new StaffPerformSummaryEntity();
summaryQuery.setStaffId(staffPerformSummaryEntity.getStaffId()); staffPerformSummaryEntity.initAttrValue();
summaryQuery.setYear(staffPerformSummaryEntity.getYear()); staffPerformSummaryEntity.setStaffId(item.getId());
summaryQuery.setMonth(staffPerformSummaryEntity.getMonth()); staffPerformSummaryEntity.setStaffName(item.getName());
StaffPerformSummaryEntity tempSummary = staffPerformSummaryService.selectOne(summaryQuery); staffPerformSummaryEntity.setDeptId(item.getDeptId());
if(tempSummary==null){ staffPerformSummaryEntity.setDeptName(item.getDeptName());
summaryList.add(staffPerformSummaryEntity); staffPerformSummaryEntity.setYear(year);
staffPerformSummaryEntity.setMonth(month);
staffPerformSummaryEntity.setTotalScore(totalScore);
staffPerformSummaryEntity.setCreateUserId(1l);
staffPerformSummaryEntity.setCreateTime(new Date());
StaffPerformSummaryQuery summaryQuery = new StaffPerformSummaryQuery();
summaryQuery.setStaffId(staffPerformSummaryEntity.getStaffId());
summaryQuery.setYear(staffPerformSummaryEntity.getYear());
summaryQuery.setMonth(staffPerformSummaryEntity.getMonth());
StaffPerformSummaryEntity tempSummary = staffPerformSummaryService.selectOne(summaryQuery);
if (tempSummary == null) {
summaryList.add(staffPerformSummaryEntity);
}
} }
}); });
staffPerformSummaryService.save(summaryList); staffPerformSummaryService.save(summaryList);
......
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