2022-03-11 11:08:50 +08:00
|
|
|
|
package com.engine.salary.service.impl;
|
|
|
|
|
|
|
|
|
|
|
|
import com.engine.core.impl.Service;
|
2022-03-15 09:55:58 +08:00
|
|
|
|
import com.engine.salary.biz.AttendQuoteBiz;
|
|
|
|
|
|
import com.engine.salary.biz.AttendQuoteDataBiz;
|
2022-03-15 14:18:04 +08:00
|
|
|
|
import com.engine.salary.biz.AttendQuoteDataValueBiz;
|
2022-03-11 11:08:50 +08:00
|
|
|
|
import com.engine.salary.cmd.datacollection.AttendQuoteListCmd;
|
2022-03-15 09:55:58 +08:00
|
|
|
|
import com.engine.salary.entity.datacollection.dto.AttendQuoteListDTO;
|
|
|
|
|
|
import com.engine.salary.entity.datacollection.param.AttendQuoteDataQueryParam;
|
|
|
|
|
|
import com.engine.salary.entity.datacollection.param.AttendQuoteQueryParam;
|
|
|
|
|
|
import com.engine.salary.entity.datacollection.po.AttendQuoteDataPO;
|
|
|
|
|
|
import com.engine.salary.exception.SalaryRunTimeException;
|
2022-04-21 14:15:56 +08:00
|
|
|
|
import com.engine.salary.mapper.datacollection.AttendQuoteMapper;
|
2022-03-11 11:08:50 +08:00
|
|
|
|
import com.engine.salary.service.AttendQuoteService;
|
2022-04-21 14:15:56 +08:00
|
|
|
|
import com.engine.salary.util.db.MapperProxyFactory;
|
|
|
|
|
|
import com.engine.salary.util.page.PageInfo;
|
|
|
|
|
|
import com.engine.salary.util.page.PageUtil;
|
2022-03-15 09:55:58 +08:00
|
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
2022-03-11 11:08:50 +08:00
|
|
|
|
|
2022-03-15 09:55:58 +08:00
|
|
|
|
import java.util.Collection;
|
|
|
|
|
|
import java.util.List;
|
2022-03-11 11:08:50 +08:00
|
|
|
|
import java.util.Map;
|
2022-03-15 09:55:58 +08:00
|
|
|
|
import java.util.stream.Collectors;
|
2022-03-11 11:08:50 +08:00
|
|
|
|
|
|
|
|
|
|
public class AttendQuoteServiceImpl extends Service implements AttendQuoteService {
|
|
|
|
|
|
|
2022-03-15 14:18:04 +08:00
|
|
|
|
private AttendQuoteBiz biz = new AttendQuoteBiz();
|
|
|
|
|
|
private AttendQuoteDataBiz dataBiz = new AttendQuoteDataBiz();
|
|
|
|
|
|
private AttendQuoteDataValueBiz dataValueBiz = new AttendQuoteDataValueBiz();
|
2022-04-21 14:15:56 +08:00
|
|
|
|
private AttendQuoteMapper getAttendQuoteMapper() {
|
|
|
|
|
|
return MapperProxyFactory.getProxy(AttendQuoteMapper.class);
|
|
|
|
|
|
}
|
2022-03-15 09:55:58 +08:00
|
|
|
|
|
2022-03-11 11:08:50 +08:00
|
|
|
|
@Override
|
|
|
|
|
|
public Map<String, Object> list(Map<String, Object> params) {
|
|
|
|
|
|
return commandExecutor.execute(new AttendQuoteListCmd(params, user));
|
|
|
|
|
|
}
|
2022-03-15 09:55:58 +08:00
|
|
|
|
|
2022-04-21 14:15:56 +08:00
|
|
|
|
@Override
|
|
|
|
|
|
public PageInfo<AttendQuoteListDTO> listPage(AttendQuoteQueryParam queryParam) {
|
|
|
|
|
|
PageUtil.start(queryParam.getCurrent(), queryParam.getPageSize());
|
|
|
|
|
|
List<AttendQuoteListDTO> list = getAttendQuoteMapper().list(queryParam);
|
|
|
|
|
|
return new PageInfo<>(list);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-03-15 09:55:58 +08:00
|
|
|
|
@Override
|
|
|
|
|
|
public String delete(Collection<Long> ids) {
|
|
|
|
|
|
if (CollectionUtils.isEmpty(ids)) {
|
|
|
|
|
|
throw new SalaryRunTimeException("参数错误");
|
|
|
|
|
|
}
|
|
|
|
|
|
List<AttendQuoteListDTO> attendQuotes = biz.list(AttendQuoteQueryParam.builder().ids(ids).build());
|
|
|
|
|
|
if (CollectionUtils.isEmpty(attendQuotes)) {
|
|
|
|
|
|
throw new SalaryRunTimeException("要删除的数据不存在或已删除");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
List<AttendQuoteListDTO> accountingAttendQuotes = attendQuotes.stream().filter(e -> e.getSalaryAccountingStatus().equals(1)).collect(Collectors.toList());
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(accountingAttendQuotes)) {
|
|
|
|
|
|
throw new SalaryRunTimeException("已经核算完成的数据不能删除");
|
|
|
|
|
|
}
|
|
|
|
|
|
List<Long> unAccountingIds = attendQuotes.stream().filter(e -> e.getSalaryAccountingStatus().equals(0)).map(AttendQuoteListDTO::getId).collect(Collectors.toList());
|
|
|
|
|
|
// 1.删除未核算的考勤引用
|
|
|
|
|
|
biz.deleteByIds(unAccountingIds);
|
|
|
|
|
|
|
|
|
|
|
|
List<AttendQuoteDataPO> attendQuoteDatas = dataBiz.listSome(AttendQuoteDataQueryParam.builder().unAccountingIds(unAccountingIds).build());
|
|
|
|
|
|
// 2.删除考核引用对应的考核数据
|
|
|
|
|
|
dataBiz.deleteByAttendQuoteIds(unAccountingIds);
|
|
|
|
|
|
|
|
|
|
|
|
// 3.删除考核数据对应的考核值
|
2022-03-15 14:18:04 +08:00
|
|
|
|
List<Long> attendQuoteDataIds = attendQuoteDatas.stream().map(AttendQuoteDataPO::getId).collect(Collectors.toList());
|
|
|
|
|
|
dataValueBiz.deleteByAttendQuoteDataIds(attendQuoteDataIds);
|
2022-03-15 09:55:58 +08:00
|
|
|
|
|
|
|
|
|
|
//todo 日志
|
|
|
|
|
|
// attendQuotes.forEach(e -> {
|
|
|
|
|
|
// SalaryLoggerUtil.recordDeleteSingleLog(attendQuoteLoggerTemplate,
|
|
|
|
|
|
// e.getId(),
|
|
|
|
|
|
// SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 85367, "考勤引用"),
|
|
|
|
|
|
// SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 100412, "删除考勤引用"),
|
|
|
|
|
|
// SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 100412, "删除考勤引用") +
|
|
|
|
|
|
// ":[" + SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 87614, "薪资所属月") + ":" + e.getSalaryYearMonth() + "," +
|
|
|
|
|
|
// SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 87615, "关联账套") + ":" + e.getSalarySobName() + "]",
|
|
|
|
|
|
// e);
|
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-03-11 11:08:50 +08:00
|
|
|
|
}
|