薪酬系统-福利台账补缴功能开发v1

This commit is contained in:
sy 2022-09-19 15:13:30 +08:00
parent b0cc2cc19d
commit f54481bbf1
2 changed files with 43 additions and 0 deletions

View File

@ -222,5 +222,10 @@ public interface SIAccountService {
* 预览福利核算导入模板导入的数据
*/
Map<String, Object> preview(InsuranceAcctImportParam insuranceAcctImportParam);
/**
* 导出福利核算-补缴导入模板
*/
XSSFWorkbook exportSupplyImportTemplate(InsuranceAcctDetailImportTemplateParam param);
}

View File

@ -458,4 +458,42 @@ public class SIAccountController {
return new ResponseResult<InsuranceAcctImportParam, Map<String, Object>>(user).run(getService(user)::preview, insuranceAcctImportParam);
}
/**
* 导出福利核算-补缴导入模板
*/
@GET
@Path("/welfare/supplyimporttemplate/export")
@Produces(MediaType.APPLICATION_OCTET_STREAM)
public Response exportSupplyImportTemplate(@Context HttpServletRequest request, @Context HttpServletResponse response) {
try {
InsuranceAcctDetailImportTemplateParam param = new InsuranceAcctDetailImportTemplateParam();
String welfareNames = request.getParameter("welfareNames");
if (StringUtils.isNotBlank(welfareNames)) {
param.setWelfareNames(Arrays.stream(welfareNames.split(",")).map(String::valueOf).collect(Collectors.toList()));
}
User user = HrmUserVarify.getUser(request, response);
XSSFWorkbook workbook = getService(user).exportSupplyImportTemplate(param);
String time = LocalDate.now().toString();
String fileName = "福利核算-补缴导入模板" + time;
try {
fileName = URLEncoder.encode(fileName + ".xlsx", "UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
StreamingOutput output = outputStream -> {
workbook.write(outputStream);
outputStream.flush();
};
response.setContentType("application/octet-stream");
return Response.ok(output).header("Content-disposition", "attachment;filename=" + fileName).header("Cache-Control", "no-cache").build();
} catch (Exception e) {
log.error("福利核算-补缴导入模板导出异常", e);
throw e;
}
}
}