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

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

parent 7c8fa494
......@@ -4,6 +4,7 @@ import com.mortals.framework.exception.AppException;
import com.mortals.framework.service.ITask;
import com.mortals.framework.service.ITaskExcuteService;
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.HolidayQuery;
import com.mortals.xhx.module.holiday.service.HolidayService;
......@@ -70,24 +71,36 @@ public class StaffPerformInitDataTaskImpl implements ITaskExcuteService {
if(CollectionUtils.isNotEmpty(allStaff)) {
List<StaffPerformStatEntity> list = new ArrayList<>();
allStaff.stream().forEach(item -> {
StaffPerformStatEntity statEntity = new StaffPerformStatEntity();
statEntity.initAttrValue();
statEntity.setStaffId(item.getId());
statEntity.setStaffName(item.getName());
statEntity.setYear(year);
statEntity.setMonth(month);
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);
boolean flag = true;
if(item.getStatus() == StaffSatusEnum.离职.getValue()) {
if(item.getLeaveDate()!=null){
String leaveDateStr = DateUtils.getStrDate(item.getLeaveDate());
if(DateUtils.StrToDate(leaveDateStr).compareTo(DateUtils.StrToDate(dateStr)) < 0){
//离职日期在统计日期之前不统计
flag = false;
}
}
}
if(flag){
StaffPerformStatEntity statEntity = new StaffPerformStatEntity();
statEntity.initAttrValue();
statEntity.setStaffId(item.getId());
statEntity.setStaffName(item.getName());
statEntity.setYear(year);
statEntity.setMonth(month);
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);
......@@ -99,24 +112,36 @@ public class StaffPerformInitDataTaskImpl implements ITaskExcuteService {
if(CollectionUtils.isNotEmpty(allStaff)) {
List<StaffPerformSummaryEntity> summaryList = new ArrayList<>();
allStaff.stream().forEach(item -> {
StaffPerformSummaryEntity staffPerformSummaryEntity = new StaffPerformSummaryEntity();
staffPerformSummaryEntity.initAttrValue();
staffPerformSummaryEntity.setStaffId(item.getId());
staffPerformSummaryEntity.setStaffName(item.getName());
staffPerformSummaryEntity.setDeptId(item.getDeptId());
staffPerformSummaryEntity.setDeptName(item.getDeptName());
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);
boolean flag = true;
if(item.getStatus() == StaffSatusEnum.离职.getValue()) {
if(item.getLeaveDate()!=null){
String leaveDateStr = DateUtils.getStrDate(item.getLeaveDate());
if(DateUtils.StrToDate(leaveDateStr).compareTo(DateUtils.StrToDate(dateStr)) < 0){
//离职日期在统计日期之前不统计
flag = false;
}
}
}
if(flag) {
StaffPerformSummaryEntity staffPerformSummaryEntity = new StaffPerformSummaryEntity();
staffPerformSummaryEntity.initAttrValue();
staffPerformSummaryEntity.setStaffId(item.getId());
staffPerformSummaryEntity.setStaffName(item.getName());
staffPerformSummaryEntity.setDeptId(item.getDeptId());
staffPerformSummaryEntity.setDeptName(item.getDeptName());
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);
......
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