2022-03-01 18:49:22 +08:00
|
|
|
package com.engine.salary.web;
|
|
|
|
|
|
2022-04-16 15:33:51 +08:00
|
|
|
import com.engine.common.util.ServiceUtil;
|
|
|
|
|
import com.engine.salary.entity.taxdeclaration.dto.TaxDeclarationFormDTO;
|
|
|
|
|
import com.engine.salary.entity.taxdeclaration.dto.TaxDeclarationInfoDTO;
|
|
|
|
|
import com.engine.salary.entity.taxdeclaration.dto.TaxDeclarationListDTO;
|
|
|
|
|
import com.engine.salary.entity.taxdeclaration.param.TaxDeclarationListQueryParam;
|
|
|
|
|
import com.engine.salary.entity.taxdeclaration.param.TaxDeclarationSaveParam;
|
2022-04-18 18:56:17 +08:00
|
|
|
import com.engine.salary.service.TaxDeclarationExcelService;
|
2022-04-16 15:33:51 +08:00
|
|
|
import com.engine.salary.service.TaxDeclarationService;
|
2022-04-18 18:56:17 +08:00
|
|
|
import com.engine.salary.service.impl.TaxDeclarationExcelServiceImpl;
|
2022-04-16 15:33:51 +08:00
|
|
|
import com.engine.salary.service.impl.TaxDeclarationServiceImpl;
|
|
|
|
|
import com.engine.salary.util.ResponseResult;
|
|
|
|
|
import com.engine.salary.util.SalaryDateUtil;
|
|
|
|
|
import com.engine.salary.util.page.PageInfo;
|
|
|
|
|
import com.engine.salary.wrapper.TaxDeclarationWrapper;
|
|
|
|
|
import io.swagger.v3.oas.annotations.parameters.RequestBody;
|
2022-04-18 18:56:17 +08:00
|
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
2022-04-16 15:33:51 +08:00
|
|
|
import weaver.hrm.HrmUserVarify;
|
|
|
|
|
import weaver.hrm.User;
|
|
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
import javax.ws.rs.*;
|
|
|
|
|
import javax.ws.rs.core.Context;
|
|
|
|
|
import javax.ws.rs.core.MediaType;
|
2022-04-18 18:56:17 +08:00
|
|
|
import javax.ws.rs.core.Response;
|
|
|
|
|
import javax.ws.rs.core.StreamingOutput;
|
|
|
|
|
import java.io.UnsupportedEncodingException;
|
|
|
|
|
import java.net.URLEncoder;
|
|
|
|
|
import java.text.ParseException;
|
2022-04-16 15:33:51 +08:00
|
|
|
|
|
|
|
|
|
2022-03-01 18:49:22 +08:00
|
|
|
public class TaxDeclarationController {
|
|
|
|
|
|
2022-04-16 15:33:51 +08:00
|
|
|
// private BaseBean logger = new BaseBean();
|
|
|
|
|
|
|
|
|
|
private TaxDeclarationService getService(User user) {
|
|
|
|
|
return (TaxDeclarationService) ServiceUtil.getService(TaxDeclarationServiceImpl.class, user);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private TaxDeclarationWrapper getTaxDeclarationWrapper(User user) {
|
|
|
|
|
return ServiceUtil.getService(TaxDeclarationWrapper.class, user);
|
|
|
|
|
}
|
2022-04-18 18:56:17 +08:00
|
|
|
private TaxDeclarationExcelService getTaxDeclarationExcelService(User user) {
|
|
|
|
|
return (TaxDeclarationExcelService)ServiceUtil.getService(TaxDeclarationExcelServiceImpl.class, user);
|
|
|
|
|
}
|
2022-04-16 15:33:51 +08:00
|
|
|
/* private TaxDeclarationDetailWrapper getTaxDeclarationDetailWrapper(User user) {
|
|
|
|
|
return ServiceUtil.getService(TaxDeclarationDetailWrapper.class, user);
|
|
|
|
|
}*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//个税申报表列表
|
|
|
|
|
@POST
|
|
|
|
|
@Path("/listPage")
|
|
|
|
|
@Produces(MediaType.APPLICATION_JSON)
|
2022-04-18 18:56:17 +08:00
|
|
|
public String list(@Context HttpServletRequest request, @Context HttpServletResponse response,@RequestBody TaxDeclarationListQueryParam queryParam) throws ParseException {
|
2022-04-16 15:33:51 +08:00
|
|
|
User user = HrmUserVarify.getUser(request, response);
|
2022-04-18 18:56:17 +08:00
|
|
|
queryParam.setFromSalaryMonth(SalaryDateUtil.String2YearMonth(queryParam.getFromSalaryMonthStr()==null?"":queryParam.getFromSalaryMonthStr()));
|
|
|
|
|
queryParam.setEndSalaryMonth(SalaryDateUtil.String2YearMonth(queryParam.getEndSalaryMonthStr()==null?"":queryParam.getEndSalaryMonthStr()));
|
2022-04-16 15:33:51 +08:00
|
|
|
return new ResponseResult<TaxDeclarationListQueryParam, PageInfo<TaxDeclarationListDTO>>().run(getTaxDeclarationWrapper(user)::listPage, queryParam);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//个税申报表表单
|
|
|
|
|
@GET
|
|
|
|
|
@Path("/getForm")
|
|
|
|
|
@Produces(MediaType.APPLICATION_JSON)
|
|
|
|
|
public String getForm(@Context HttpServletRequest request, @Context HttpServletResponse response, @QueryParam(value = "id") Long id) {
|
|
|
|
|
User user = HrmUserVarify.getUser(request, response);
|
|
|
|
|
return new ResponseResult<Long, TaxDeclarationFormDTO>().run(getTaxDeclarationWrapper(user)::getForm, id);
|
|
|
|
|
}
|
|
|
|
|
//个税申报表相关信息
|
|
|
|
|
@GET
|
|
|
|
|
@Path("/getTaxDeclarationInfo")
|
|
|
|
|
@Produces(MediaType.APPLICATION_JSON)
|
|
|
|
|
public String getTaxDeclarationInfo(@Context HttpServletRequest request, @Context HttpServletResponse response,@QueryParam(value = "taxDeclarationId") Long taxDeclarationId) {
|
|
|
|
|
User user = HrmUserVarify.getUser(request, response);
|
|
|
|
|
return new ResponseResult<Long, TaxDeclarationInfoDTO>().run(getTaxDeclarationWrapper(user)::getTaxDeclarationInfoById, taxDeclarationId);
|
|
|
|
|
}
|
|
|
|
|
//个税申报表生成
|
|
|
|
|
@POST
|
|
|
|
|
@Path("/save")
|
|
|
|
|
@Produces(MediaType.APPLICATION_JSON)
|
|
|
|
|
public String save(@Context HttpServletRequest request, @Context HttpServletResponse response,@RequestBody TaxDeclarationSaveParam param) {
|
|
|
|
|
User user = HrmUserVarify.getUser(request, response);
|
|
|
|
|
param.setSalaryMonth(SalaryDateUtil.String2YearMonth(param.getSalaryMonthStr()));
|
|
|
|
|
return new ResponseResult<TaxDeclarationSaveParam, Long>().run(getTaxDeclarationWrapper(user)::save, param);
|
|
|
|
|
}
|
|
|
|
|
//个税申报表详情列表
|
|
|
|
|
/* @GET
|
|
|
|
|
@Path("/detail/list")
|
|
|
|
|
@Produces(MediaType.APPLICATION_JSON)
|
|
|
|
|
public String listTaxDeclarationDetail(@Context HttpServletRequest request, @Context HttpServletResponse response,@RequestBody TaxDeclarationDetailListQueryParam param) {
|
|
|
|
|
User user = HrmUserVerify.getUser(request, response);
|
|
|
|
|
return new ResponseResult<TaxDeclarationDetailListQueryParam, Long>().run(getTaxDeclarationDetailWrapper(user)::listPage, param);
|
|
|
|
|
}*/
|
|
|
|
|
|
2022-04-18 18:56:17 +08:00
|
|
|
//个税申报表相关信息
|
|
|
|
|
@GET
|
|
|
|
|
@Path("/export")
|
|
|
|
|
@Produces(MediaType.APPLICATION_OCTET_STREAM)
|
|
|
|
|
public Response exportTaxDeclaration(@Context HttpServletRequest request, @Context HttpServletResponse response,@QueryParam(value = "taxDeclarationId") Long taxDeclarationId) {
|
|
|
|
|
User user = HrmUserVarify.getUser(request, response);
|
|
|
|
|
XSSFWorkbook workbook = getTaxDeclarationExcelService(user).exportTaxDeclaration(taxDeclarationId);
|
|
|
|
|
|
|
|
|
|
String fileName = "个税申报表";
|
|
|
|
|
try {
|
|
|
|
|
fileName = URLEncoder.encode(fileName + ".xlsx", "UTF-8");
|
|
|
|
|
} catch (UnsupportedEncodingException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
2022-03-01 18:49:22 +08:00
|
|
|
|
2022-04-18 18:56:17 +08:00
|
|
|
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();
|
2022-03-01 18:49:22 +08:00
|
|
|
|
2022-04-18 18:56:17 +08:00
|
|
|
}
|
2022-03-01 18:49:22 +08:00
|
|
|
}
|