2022-04-18 20:24:43 +08:00
|
|
|
package com.engine.salary.web;
|
|
|
|
|
|
|
|
|
|
import com.engine.common.util.ServiceUtil;
|
|
|
|
|
import com.engine.salary.entity.siexport.param.InsuranceExportParam;
|
|
|
|
|
import com.engine.salary.enums.siaccount.PaymentStatusEnum;
|
|
|
|
|
import com.engine.salary.service.SIAccountService;
|
|
|
|
|
import com.engine.salary.service.impl.SIAccountServiceImpl;
|
2022-04-19 12:19:06 +08:00
|
|
|
import com.engine.salary.wrapper.SIExportWrapper;
|
2022-04-18 20:24:43 +08:00
|
|
|
import io.swagger.v3.oas.annotations.parameters.RequestBody;
|
|
|
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
|
|
|
import weaver.hrm.HrmUserVarify;
|
|
|
|
|
import weaver.hrm.User;
|
|
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
import javax.ws.rs.POST;
|
|
|
|
|
import javax.ws.rs.Path;
|
|
|
|
|
import javax.ws.rs.Produces;
|
|
|
|
|
import javax.ws.rs.core.Context;
|
|
|
|
|
import javax.ws.rs.core.MediaType;
|
|
|
|
|
import javax.ws.rs.core.Response;
|
|
|
|
|
import javax.ws.rs.core.StreamingOutput;
|
|
|
|
|
import java.io.UnsupportedEncodingException;
|
|
|
|
|
import java.net.URLEncoder;
|
|
|
|
|
import java.time.LocalDate;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @Author weaver_cl
|
|
|
|
|
* @Description: TODO
|
|
|
|
|
* @Date 2022/4/18
|
|
|
|
|
* @Version V1.0
|
|
|
|
|
**/
|
|
|
|
|
public class SIExportController {
|
|
|
|
|
|
|
|
|
|
public SIAccountService getService(User user) {
|
|
|
|
|
return ServiceUtil.getService(SIAccountServiceImpl.class, user);
|
|
|
|
|
}
|
|
|
|
|
|
2022-04-19 12:19:06 +08:00
|
|
|
public SIExportWrapper getSIExportWrapper(User user) {
|
|
|
|
|
return ServiceUtil.getService(SIExportWrapper.class,user);
|
2022-04-18 20:24:43 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@POST
|
|
|
|
|
@Path("/common/export")
|
|
|
|
|
@Produces(MediaType.APPLICATION_OCTET_STREAM)
|
|
|
|
|
public Response exportAccount(@Context HttpServletRequest request, @Context HttpServletResponse response,
|
|
|
|
|
@RequestBody InsuranceExportParam param) {
|
|
|
|
|
User user = HrmUserVarify.getUser(request, response);
|
2022-04-19 12:19:06 +08:00
|
|
|
XSSFWorkbook workbook = getSIExportWrapper(user).exportAccount(PaymentStatusEnum.COMMON.getValue(),param);
|
2022-04-18 20:24:43 +08:00
|
|
|
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();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@POST
|
|
|
|
|
@Path("/supplementary/export")
|
|
|
|
|
@Produces(MediaType.APPLICATION_OCTET_STREAM)
|
|
|
|
|
public Response exportSupplementary(@Context HttpServletRequest request, @Context HttpServletResponse response,
|
|
|
|
|
@RequestBody InsuranceExportParam param) {
|
|
|
|
|
User user = HrmUserVarify.getUser(request, response);
|
2022-04-19 12:19:06 +08:00
|
|
|
XSSFWorkbook workbook = getSIExportWrapper(user).exportAccount(PaymentStatusEnum.REPAIR.getValue(),param);
|
2022-04-18 20:24:43 +08:00
|
|
|
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();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@POST
|
|
|
|
|
@Path("/overView/export")
|
|
|
|
|
@Produces(MediaType.APPLICATION_OCTET_STREAM)
|
|
|
|
|
public Response exportOverView(@Context HttpServletRequest request, @Context HttpServletResponse response,
|
|
|
|
|
@RequestBody InsuranceExportParam param) {
|
|
|
|
|
User user = HrmUserVarify.getUser(request, response);
|
2022-04-19 12:19:06 +08:00
|
|
|
XSSFWorkbook workbook = getSIExportWrapper(user).exportOverView(param);
|
2022-04-18 20:24:43 +08:00
|
|
|
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();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|