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> { protected HttpServletRequest request; public AddUpDeductionPreviewCmd(Map params, User user) { this.user = user; this.params = params; } @Override public BizLogContext getLogContext() { return null; } @Override public Map execute(CommandContext commandContext) { Map apidatas = new HashMap(); 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 { fileInputStream = ImageFileManager.getInputStreamById(Integer.valueOf(imageId)); List addUpDeductions = ExcelParseHelper.parse2Map(fileInputStream, AddUpDeductionDTO.class, 0, 1, 14, "addUpDeductionTemplate.xlsx"); apidatas.put("preview", addUpDeductions); } finally { IOUtils.closeQuietly(fileInputStream); } return apidatas; } }