2022-03-09 16:40:14 +08:00
|
|
|
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.entity.datacollection.dto.AddUpDeductionDTO;
|
|
|
|
|
import com.engine.salary.entity.datacollection.param.AddUpDeductionImportParam;
|
|
|
|
|
import com.engine.salary.util.excel.ExcelParseHelper;
|
|
|
|
|
import org.apache.commons.lang3.Validate;
|
|
|
|
|
import org.apache.poi.util.IOUtils;
|
|
|
|
|
import weaver.file.ImageFileManager;
|
|
|
|
|
import weaver.general.Util;
|
|
|
|
|
import weaver.hrm.User;
|
|
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
import java.io.InputStream;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
|
public class AddUpDeductionPreviewCmd extends AbstractCommonCommand<Map<String, Object>> {
|
|
|
|
|
|
|
|
|
|
protected HttpServletRequest request;
|
|
|
|
|
|
|
|
|
|
public AddUpDeductionPreviewCmd(Map<String, Object> params, User user) {
|
|
|
|
|
this.user = user;
|
|
|
|
|
this.params = params;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public BizLogContext getLogContext() {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Map<String, Object> execute(CommandContext commandContext) {
|
|
|
|
|
Map<String, Object> apidatas = new HashMap<String, Object>();
|
|
|
|
|
AddUpDeductionBiz addUpDeductionBiz = new AddUpDeductionBiz();
|
|
|
|
|
|
|
|
|
|
//导入参数
|
|
|
|
|
AddUpDeductionImportParam importParam = (AddUpDeductionImportParam) params.get("importParam");
|
|
|
|
|
//excel文件id
|
|
|
|
|
String imageId = Util.null2String(importParam.getImageId());
|
|
|
|
|
Validate.notBlank(imageId, "imageId为空");
|
|
|
|
|
|
|
|
|
|
InputStream fileInputStream = null;
|
|
|
|
|
try {
|
2022-04-26 13:36:16 +08:00
|
|
|
fileInputStream = ImageFileManager.getInputStreamById(Integer.valueOf(imageId));
|
2022-04-28 18:27:25 +08:00
|
|
|
List<AddUpDeductionDTO> addUpDeductions = ExcelParseHelper.parse2Map(fileInputStream, AddUpDeductionDTO.class, 0, 1, 13, "addUpDeductionTemplate.xlsx");
|
2022-03-09 16:40:14 +08:00
|
|
|
apidatas.put("preview", addUpDeductions);
|
|
|
|
|
} finally {
|
|
|
|
|
IOUtils.closeQuietly(fileInputStream);
|
|
|
|
|
}
|
|
|
|
|
return apidatas;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|