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-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-03-11 11:08:50 +08:00
import com.engine.salary.service.AttendQuoteService ;
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 09:55:58 +08:00
AttendQuoteBiz biz = new AttendQuoteBiz ( ) ;
AttendQuoteDataBiz dataBiz = new AttendQuoteDataBiz ( ) ;
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
@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.删除考核数据对应的考核值
// List<Long> attendQuoteDataIds = attendQuoteDatas.stream().map(AttendQuoteDataPO::getId).collect(Collectors.toList());
// attendQuoteDataValueMapper.deleteByAttendQuoteDataIds(CollectionUtils.isEmpty(attendQuoteDataIds) ? Collections.singletonList(0L) : attendQuoteDataIds, tenantKey);
//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 ;
}
// @Override
// public WeaForm getSyncForm(Long employeeId, String tenantKey) {
//
// List<WeaFormOption> salarySobOptions = Lists.newArrayList();
// List<SalarySobPO> salarySobs = new LambdaQueryChainWrapper<>(salarySobMapper)
// .eq(SalarySobPO::getTenantKey, tenantKey)
// .eq(SalarySobPO::getDeleteType, 0)
// .list();
// salarySobs.forEach(e -> {
// salarySobOptions.add(new WeaFormOption(e.getId().toString(), e.getName()));
// });
//
// // 构建表单
// WeaForm weaForm = FormatManager.<AttendQuoteSyncDataFormDTO>getInstance().genForm(AttendQuoteSyncDataFormDTO.class, AttendQuoteSyncDataFormDTO.builder().salarySobOptions(salarySobOptions).build());
//
// WeaFormItem descriptionItem = weaForm.getItems().get("description");
// Map<String, Object> otherParams = Maps.newHashMap();
// otherParams.put("showCount", true);
// otherParams.put("placeholder", SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 85987, "请输入"));
// descriptionItem.setOtherParams(otherParams);
// weaForm.getItems().put("description", descriptionItem);
//
// WeaFormItem salaryYearMonthItem = weaForm.getItems().get("salaryYearMonth");
// otherParams = Maps.newHashMap();
// otherParams.put("type", "month");
// salaryYearMonthItem.setOtherParams(otherParams);
// weaForm.getItems().put("salaryYearMonth", salaryYearMonthItem);
//
// return weaForm;
// }
//
// @Override
// public Map<String, Object> getSalaryCycleAndAttendCycle(YearMonth salaryYearMonth, Long salarySobId, Long currentEmployeeId, String currentTenantKey) {
//
// SalarySobCycleDTO salarySobCycleDTO = salarySobService.getSalarySobCycle(salarySobId, salaryYearMonth, currentTenantKey);
//
// LocalDateRange salaryCycleRange = salarySobCycleDTO.getSalaryCycle();
// LocalDateRange attendCycleRange = salarySobCycleDTO.getAttendCycle();
//
// Map<String, Object> salaryCycleAndAttendCycle = new HashMap<>(2);
// salaryCycleAndAttendCycle.put("salaryCycle", salaryCycleRange.getFromDate() + " ~ " + salaryCycleRange.getEndDate());
// salaryCycleAndAttendCycle.put("attendCycle", attendCycleRange.getFromDate() + " ~ " + attendCycleRange.getEndDate());
//
// return salaryCycleAndAttendCycle;
// }
//
// @Override
// public List<Map<String, Object>> selectSalarySobList(Long currentEmployeeId, String currentTenantKey) {
// List<SalarySobPO> salarySobs = new LambdaQueryChainWrapper<>(salarySobMapper)
// .eq(SalarySobPO::getTenantKey, TenantContext.getCurrentTenantKey())
// .eq(SalarySobPO::getDeleteType, 0)
// .list();
//
// return CollectionUtils.emptyIfNull(salarySobs).stream().map(m -> {
// Map<String, Object> map = new HashMap<>(2);
// map.put("id", String.valueOf(m.getId()));
// map.put("content", m.getName());
// return map;
// }).collect(Collectors.toList());
// }
2022-03-11 11:08:50 +08:00
}