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

66 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.AddUpSituationBiz;
import com.engine.salary.biz.EmployBiz;
import com.engine.salary.entity.datacollection.AddUpSituation;
import com.engine.salary.entity.datacollection.DataCollectionEmployee;
import com.engine.salary.entity.datacollection.param.AddUpSituationQueryParam;
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 AddUpSituationExportDetailCmd extends AbstractCommonCommand<XSSFWorkbook> {
public AddUpSituationExportDetailCmd(Map<String, Object> params, User user) {
this.user = user;
this.params = params;
}
@Override
public BizLogContext getLogContext() {
return null;
}
@Override
public XSSFWorkbook execute(CommandContext commandContext) {
AddUpSituationQueryParam queryParam = (AddUpSituationQueryParam) params.get("queryParam");
AddUpSituationBiz biz = new AddUpSituationBiz();
EmployBiz employBiz = new EmployBiz();
Long id = queryParam.getAccumulatedSituationId();
if (id == null) {
throw new SalaryRunTimeException("id不能为空");
}
AddUpSituation 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> taxYearMonths = queryParam.getTaxYearMonth();
if (CollectionUtils.isNotEmpty(taxYearMonths)) {
queryParam.setTaxYearMonth(taxYearMonths.stream().map(e -> e + "-01 00:00:00").collect(Collectors.toList()));
}
XSSFWorkbook workbook = biz.exportDetail(queryParam);
return workbook;
}
}