weaver-hrm-salary/src/com/engine/salary/cmd/datacollection/AddUpDeductionExportDetailC...

67 lines
2.4 KiB
Java

package com.engine.salary.cmd.datacollection;
import com.engine.common.biz.AbstractCommonCommand;
import com.engine.common.entity.BizLogContext;
import com.engine.core.interceptor.CommandContext;
import com.engine.salary.biz.AddUpDeductionBiz;
import com.engine.salary.biz.EmployBiz;
import com.engine.salary.entity.datacollection.AddUpDeduction;
import com.engine.salary.entity.datacollection.DataCollectionEmployee;
import com.engine.salary.entity.datacollection.param.AddUpDeductionQueryParam;
import com.engine.salary.exception.SalaryRunTimeException;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import weaver.hrm.User;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
public class AddUpDeductionExportDetailCmd extends AbstractCommonCommand<XSSFWorkbook> {
public AddUpDeductionExportDetailCmd(Map<String, Object> params, User user) {
this.user = user;
this.params = params;
}
@Override
public BizLogContext getLogContext() {
return null;
}
@Override
public XSSFWorkbook execute(CommandContext commandContext) {
AddUpDeductionQueryParam queryParam = (AddUpDeductionQueryParam) params.get("addUpDeductionQueryParam");
EmployBiz employBiz = new EmployBiz();
AddUpDeductionBiz biz = new AddUpDeductionBiz();
Long id = queryParam.getAccumulatedSpecialAdditionalDeductionId();
if (id == null) {
throw new SalaryRunTimeException("id不能为空");
}
AddUpDeduction po = biz.getById(id);
if (po == null) {
throw new SalaryRunTimeException(String.format("累计专项附加扣除不存在"+"[id:%s]", id));
}
List<DataCollectionEmployee> employeeList = employBiz.getEmployeeByIds(Collections.singletonList(po.getEmployeeId()));
if (CollectionUtils.isEmpty(employeeList)) {
throw new SalaryRunTimeException("员工信息不存在");
}
//查询参数
queryParam.setEmployeeId(po.getEmployeeId());
//申报月份
List<String> declareMonth = queryParam.getDeclareMonth();
if (CollectionUtils.isNotEmpty(declareMonth)) {
queryParam.setDeclareMonth(declareMonth.stream().map(e -> e + "-01 00:00:00").collect(Collectors.toList()));
}
XSSFWorkbook workbook = biz.exportDetail(queryParam);
return workbook;
}
}