个税对接,个税申报接口

This commit is contained in:
钱涛 2023-08-14 20:29:19 +08:00
parent b1817142b0
commit 090b100784
10 changed files with 200 additions and 97 deletions

View File

@ -7,7 +7,7 @@ create table hrsa_employee_declare_record
delete_type int default 0, delete_type int default 0,
tenant_key varchar2(10), tenant_key varchar2(10),
tax_agent_id number, tax_agent_id number,
tax_cycle varchar2(10), tax_cycle date,
request_id varchar2(100) request_id varchar2(100)
); );
/ /
@ -21,7 +21,7 @@ create table hrsa_employee_declare
delete_type int default 0, delete_type int default 0,
tenant_key varchar2(10), tenant_key varchar2(10),
tax_agent_id number, tax_agent_id number,
tax_cycle varchar2(10), tax_cycle date,
employee_id number, employee_id number,
employee_type number, employee_type number,
employee_name varchar2(100), employee_name varchar2(100),

View File

@ -0,0 +1,51 @@
create table hrsa_employee_declare_record
(
id number primary key ,
create_time date,
update_time date,
creator number,
delete_type int default 0,
tenant_key varchar2(10),
tax_agent_id number,
tax_cycle date,
request_id varchar2(100)
);
/
create table hrsa_employee_declare
(
id number primary key ,
create_time date,
update_time date,
creator number,
delete_type int default 0,
tenant_key varchar2(10),
tax_agent_id number,
tax_cycle date,
employee_id number,
employee_type number,
employee_name varchar2(100),
job_num varchar2(100),
card_type number,
card_num varchar2(100),
gender varchar2(100),
birthday date,
employment_status number,
mobile varchar2(100),
employment_type number,
employment_first_year varchar2(100),
employment_date date,
dismiss_date date,
disability number,
disability_card_no varchar2(100),
lonely_old number,
martyr_dependents number,
martyr_dependents_card_no varchar2(100),
deduct_expenses number,
successfully_declared number,
new_employee_info number,
declare_status number,
declare_error_msg varchar2(1000)
);
/

View File

@ -7,7 +7,7 @@ create table hrsa_employee_declare_record
delete_type int default 0, delete_type int default 0,
tenant_key varchar2(10), tenant_key varchar2(10),
tax_agent_id number, tax_agent_id number,
tax_cycle varchar2(10), tax_cycle date,
request_id varchar2(100) request_id varchar2(100)
); );
/ /
@ -21,7 +21,7 @@ create table hrsa_employee_declare
delete_type int default 0, delete_type int default 0,
tenant_key varchar2(10), tenant_key varchar2(10),
tax_agent_id number, tax_agent_id number,
tax_cycle varchar2(10), tax_cycle date,
employee_id number, employee_id number,
employee_type number, employee_type number,
employee_name varchar2(100), employee_name varchar2(100),

View File

@ -7,7 +7,7 @@ create table hrsa_employee_declare_record
delete_type int default 0 comment '是否删除' , delete_type int default 0 comment '是否删除' ,
tenant_key varchar(10) comment '租户KEY' , tenant_key varchar(10) comment '租户KEY' ,
tax_agent_id bigint comment '个税扣缴义务人' , tax_agent_id bigint comment '个税扣缴义务人' ,
tax_cycle varchar(10) comment '˰¿îËùÊôÆÚ' , tax_cycle datetime comment '˰¿îËùÊôÆÚ' ,
request_id varchar(100) comment '供应商第三方系统翻译的requestid' request_id varchar(100) comment '供应商第三方系统翻译的requestid'
) )
; ;
@ -21,7 +21,7 @@ create table hrsa_employee_declare
delete_type int default 0 comment '是否删除' , delete_type int default 0 comment '是否删除' ,
tenant_key varchar(10) comment '租户KEY' , tenant_key varchar(10) comment '租户KEY' ,
tax_agent_id bigint comment '个税扣缴义务人ID' , tax_agent_id bigint comment '个税扣缴义务人ID' ,
tax_cycle varchar(10) comment '˰¿îËùÊôÆÚ' , tax_cycle datetime comment '˰¿îËùÊôÆÚ' ,
employee_id bigint comment '人员id' , employee_id bigint comment '人员id' ,
employee_type tinyint comment '人员类型' , employee_type tinyint comment '人员类型' ,
employee_name varchar(100) comment '姓名' , employee_name varchar(100) comment '姓名' ,

View File

@ -7,7 +7,7 @@ create table hrsa_employee_declare_record
delete_type int default 0, delete_type int default 0,
tenant_key varchar2(10), tenant_key varchar2(10),
tax_agent_id number, tax_agent_id number,
tax_cycle varchar2(10), tax_cycle date,
request_id varchar2(100) request_id varchar2(100)
) )
/ /
@ -21,7 +21,7 @@ create table hrsa_employee_declare
delete_type int default 0, delete_type int default 0,
tenant_key varchar2(10), tenant_key varchar2(10),
tax_agent_id number, tax_agent_id number,
tax_cycle varchar2(10), tax_cycle date,
employee_id number, employee_id number,
employee_type number, employee_type number,
employee_name varchar2(100), employee_name varchar2(100),

View File

@ -7,7 +7,7 @@ create table hrsa_employee_declare_record
delete_type int default 0, delete_type int default 0,
tenant_key varchar(10), tenant_key varchar(10),
tax_agent_id bigint, tax_agent_id bigint,
tax_cycle varchar(10), tax_cycle timestamp,
request_id varchar(100) request_id varchar(100)
); );
/ /
@ -21,7 +21,7 @@ create table hrsa_employee_declare
delete_type int default 0, delete_type int default 0,
tenant_key varchar(10), tenant_key varchar(10),
tax_agent_id bigint, tax_agent_id bigint,
tax_cycle varchar(10), tax_cycle timestamp,
employee_id bigint, employee_id bigint,
employee_type smallint, employee_type smallint,
employee_name varchar(100), employee_name varchar(100),

View File

@ -7,7 +7,7 @@ create table hrsa_employee_declare_record
delete_type int default 0, delete_type int default 0,
tenant_key nvarchar(10), tenant_key nvarchar(10),
tax_agent_id bigint, tax_agent_id bigint,
tax_cycle nvarchar(10), tax_cycle datetime,
request_id nvarchar(100) request_id nvarchar(100)
) )
GO GO
@ -21,7 +21,7 @@ create table hrsa_employee_declare
delete_type int default 0, delete_type int default 0,
tenant_key nvarchar(10), tenant_key nvarchar(10),
tax_agent_id bigint, tax_agent_id bigint,
tax_cycle nvarchar(10), tax_cycle datetime,
employee_id bigint, employee_id bigint,
employee_type tinyint, employee_type tinyint,
employee_name nvarchar(100), employee_name nvarchar(100),

View File

@ -7,7 +7,7 @@ create table hrsa_employee_declare_record
delete_type int default 0, delete_type int default 0,
tenant_key varchar2(10), tenant_key varchar2(10),
tax_agent_id number, tax_agent_id number,
tax_cycle varchar2(10), tax_cycle date,
request_id varchar2(100) request_id varchar2(100)
); );
/ /
@ -21,7 +21,7 @@ create table hrsa_employee_declare
delete_type int default 0, delete_type int default 0,
tenant_key varchar2(10), tenant_key varchar2(10),
tax_agent_id number, tax_agent_id number,
tax_cycle varchar2(10), tax_cycle date,
employee_id number, employee_id number,
employee_type number, employee_type number,
employee_name varchar2(100), employee_name varchar2(100),

View File

@ -1,21 +1,22 @@
package com.engine.salary.web; package com.engine.salary.web;
import com.engine.common.util.ServiceUtil; import com.engine.common.util.ServiceUtil;
import com.engine.salary.entity.taxdeclaration.dto.*; import com.engine.salary.entity.taxdeclaration.dto.AbnormalEmployeeListDTO;
import com.engine.salary.entity.taxdeclaration.dto.TaxDeclarationInfoDTO;
import com.engine.salary.entity.taxdeclaration.dto.TaxDeclarationRateDTO;
import com.engine.salary.entity.taxdeclaration.dto.TaxDeclarationTabDTO;
import com.engine.salary.entity.taxdeclaration.param.*; import com.engine.salary.entity.taxdeclaration.param.*;
import com.engine.salary.service.TaxDeclarationExcelService; import com.engine.salary.service.TaxDeclarationExcelService;
import com.engine.salary.service.TaxDeclarationService; import com.engine.salary.service.TaxDeclarationService;
import com.engine.salary.service.impl.TaxDeclarationExcelServiceImpl; import com.engine.salary.service.impl.TaxDeclarationExcelServiceImpl;
import com.engine.salary.service.impl.TaxDeclarationServiceImpl; import com.engine.salary.service.impl.TaxDeclarationServiceImpl;
import com.engine.salary.util.ResponseResult; import com.engine.salary.util.ResponseResult;
import com.engine.salary.util.SalaryDateUtil;
import com.engine.salary.util.page.PageInfo; import com.engine.salary.util.page.PageInfo;
import com.engine.salary.wrapper.TaxDeclarationDetailWrapper; import com.engine.salary.wrapper.TaxDeclarationDetailWrapper;
import com.engine.salary.wrapper.TaxDeclarationWrapper; import com.engine.salary.wrapper.TaxDeclarationWrapper;
import com.engine.salary.wrapper.TaxDeclareRecordWrapper; import com.engine.salary.wrapper.TaxDeclareRecordWrapper;
import io.swagger.v3.oas.annotations.parameters.RequestBody; import io.swagger.v3.oas.annotations.parameters.RequestBody;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import weaver.hrm.HrmUserVarify; import weaver.hrm.HrmUserVarify;
import weaver.hrm.User; import weaver.hrm.User;
@ -24,14 +25,9 @@ import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.*; import javax.ws.rs.*;
import javax.ws.rs.core.Context; import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType; 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.text.ParseException;
import java.time.LocalDate;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.Map;
@Slf4j @Slf4j
@ -58,90 +54,147 @@ public class TaxDeclarationController {
} }
//个税申报表列表 // //个税申报表列表
// @POST
// @Path("/list")
// @Produces(MediaType.APPLICATION_JSON)
// public String list(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody TaxDeclarationListQueryParam queryParam) throws ParseException {
// User user = HrmUserVarify.getUser(request, response);
// queryParam.setFromSalaryMonth(SalaryDateUtil.stringToDate(queryParam.getFromSalaryMonthStr() == null ? "" : queryParam.getFromSalaryMonthStr()));
// queryParam.setEndSalaryMonth(SalaryDateUtil.stringToDate(queryParam.getEndSalaryMonthStr() == null ? "" : queryParam.getEndSalaryMonthStr()));
// return new ResponseResult<TaxDeclarationListQueryParam, PageInfo<TaxDeclarationListDTO>>(user).run(getTaxDeclarationWrapper(user)::listPage, queryParam);
// }
//
// @POST
// @Path("/withDrawTaxDeclaration")
// @Produces(MediaType.APPLICATION_JSON)
// public String deleteTaxDeclaration(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody TaxDeclarationSaveParam param) {
// User user = HrmUserVarify.getUser(request, response);
// return new ResponseResult<Long, String>(user).run(getTaxDeclarationWrapper(user)::withDrawTaxDeclaration, param.getTaxDeclarationId());
// }
//
//
// //个税申报表表单
// @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>(user).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>(user).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>(user).run(getTaxDeclarationWrapper(user)::save, param);
// }
//
// //个税申报表详情列表
// @POST
// @Path("/detail/list")
// @Produces(MediaType.APPLICATION_JSON)
// public String listTaxDeclarationDetail(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody TaxDeclarationDetailListQueryParam param) {
// User user = HrmUserVarify.getUser(request, response);
// param.setTaxDeclarationId(Long.parseLong(param.getTaxDeclarationIdStr()));
// return new ResponseResult<TaxDeclarationDetailListQueryParam, PageInfo>(user).run(getTaxDeclarationDetailWrapper(user)::listPage, param);
// }
//
// //个税申报表相关信息
// @GET
// @Path("/export")
// @Produces(MediaType.APPLICATION_OCTET_STREAM)
// public Response exportTaxDeclaration(@Context HttpServletRequest request, @Context HttpServletResponse response, @QueryParam(value = "taxDeclarationId") Long taxDeclarationId) {
// try {
// User user = HrmUserVarify.getUser(request, response);
// XSSFWorkbook workbook = getTaxDeclarationExcelService(user).exportTaxDeclaration(taxDeclarationId);
//
// String fileName = "个税申报表" + LocalDate.now();
// 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;
// }
// }
/**
* 个税申报表列表
*
* @param queryParam 查询条件
* @return
*/
@POST @POST
@Path("/list") @Path("/list")
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
public String list(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody TaxDeclarationListQueryParam queryParam) throws ParseException { public String listTaxDeclaration(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody TaxDeclarationListQueryParam queryParam) {
User user = HrmUserVarify.getUser(request, response); User user = HrmUserVarify.getUser(request, response);
queryParam.setFromSalaryMonth(SalaryDateUtil.stringToDate(queryParam.getFromSalaryMonthStr() == null ? "" : queryParam.getFromSalaryMonthStr())); return new ResponseResult<TaxDeclarationListQueryParam, PageInfo>(user).run(getTaxDeclareRecordWrapper(user)::listPage, queryParam);
queryParam.setEndSalaryMonth(SalaryDateUtil.stringToDate(queryParam.getEndSalaryMonthStr() == null ? "" : queryParam.getEndSalaryMonthStr()));
return new ResponseResult<TaxDeclarationListQueryParam, PageInfo<TaxDeclarationListDTO>>(user).run(getTaxDeclarationWrapper(user)::listPage, queryParam);
} }
@POST /**
@Path("/withDrawTaxDeclaration") * 个税申报表表单
@Produces(MediaType.APPLICATION_JSON) *
public String deleteTaxDeclaration(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody TaxDeclarationSaveParam param) { * @param id 个税申报记录id
User user = HrmUserVarify.getUser(request, response); * @return
return new ResponseResult<Long, String>(user).run(getTaxDeclarationWrapper(user)::withDrawTaxDeclaration, param.getTaxDeclarationId()); */
}
//个税申报表表单
@GET @GET
@Path("/getForm") @Path("/getForm")
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
public String getForm(@Context HttpServletRequest request, @Context HttpServletResponse response, @QueryParam(value = "id") Long id) { public String getForm(@Context HttpServletRequest request, @Context HttpServletResponse response,@QueryParam(value = "id") Long id) {
User user = HrmUserVarify.getUser(request, response); User user = HrmUserVarify.getUser(request, response);
return new ResponseResult<Long, TaxDeclarationFormDTO>(user).run(getTaxDeclarationWrapper(user)::getForm, id); return new ResponseResult<Long, Map>(user).run(getTaxDeclareRecordWrapper(user)::getForm, id);
} }
//个税申报表相关信息 /**
* 个税申报表相关信息
*
* @param id 个税申报记录id
* @return
*/
@GET @GET
@Path("/getTaxDeclarationInfo") @Path("/getTaxDeclarationInfo")
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
public String getTaxDeclarationInfo(@Context HttpServletRequest request, @Context HttpServletResponse response, @QueryParam(value = "taxDeclarationId") Long taxDeclarationId) { public String getTaxDeclarationInfo(@Context HttpServletRequest request, @Context HttpServletResponse response,@QueryParam(value = "id") Long id) {
User user = HrmUserVarify.getUser(request, response); User user = HrmUserVarify.getUser(request, response);
return new ResponseResult<Long, TaxDeclarationInfoDTO>(user).run(getTaxDeclarationWrapper(user)::getTaxDeclarationInfoById, taxDeclarationId); return new ResponseResult<Long, TaxDeclarationInfoDTO>(user).run(getTaxDeclareRecordWrapper(user)::getTaxDeclarationInfoById, id);
} }
//个税申报表生成 /**
@POST * 个税申报表生成
*
* @param saveParam 保存参数
* @return
*/
@Path("/save") @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>(user).run(getTaxDeclarationWrapper(user)::save, param);
}
//个税申报表详情列表
@POST @POST
@Path("/detail/list")
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
public String listTaxDeclarationDetail(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody TaxDeclarationDetailListQueryParam param) { public String saveTaxDeclaration(@Context HttpServletRequest request, @Context HttpServletResponse response,@RequestBody TaxDeclarationSaveParam saveParam) {
User user = HrmUserVarify.getUser(request, response); User user = HrmUserVarify.getUser(request, response);
param.setTaxDeclarationId(Long.parseLong(param.getTaxDeclarationIdStr())); return new ResponseResult<TaxDeclarationSaveParam, String>(user).run(getTaxDeclareRecordWrapper(user)::save, saveParam);
return new ResponseResult<TaxDeclarationDetailListQueryParam, PageInfo>(user).run(getTaxDeclarationDetailWrapper(user)::listPage, param);
}
//个税申报表相关信息
@GET
@Path("/export")
@Produces(MediaType.APPLICATION_OCTET_STREAM)
public Response exportTaxDeclaration(@Context HttpServletRequest request, @Context HttpServletResponse response, @QueryParam(value = "taxDeclarationId") Long taxDeclarationId) {
try {
User user = HrmUserVarify.getUser(request, response);
XSSFWorkbook workbook = getTaxDeclarationExcelService(user).exportTaxDeclaration(taxDeclarationId);
String fileName = "个税申报表" + LocalDate.now();
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;
}
} }

View File

@ -209,19 +209,18 @@ public class TaxDeclareRecordWrapper extends Service {
} }
} }
// /** /**
// * 获取个税申报记录的表单 * 获取个税申报记录的表单
// * *
// * @param id * @param id
// * @param tenantKey * @return
// * @return */
// */ public Map getForm(Long id) {
// public WeaForm getForm(Long id) {
// TaxDeclareRecordFormDTO formDTO = new TaxDeclareRecordFormDTO(); // TaxDeclareRecordFormDTO formDTO = new TaxDeclareRecordFormDTO();
// formDTO.setTaxAgentRange(TaxAgentRangeEnum.SELECT_TAX_AGENT); // formDTO.setTaxAgentRange(TaxAgentRangeEnum.SELECT_TAX_AGENT);
// // 判断当前是否开启了分权 // // 判断当前是否开启了分权
// Boolean openDevolution = taxAgentService.isOpenDevolution(tenantKey); // Boolean openDevolution = taxAgentService.isOpenDevolution();
// Boolean isChief = taxAgentService.isChief(employeeId); // Boolean isChief = taxAgentService.isChief((long)user.getUID());
// // 转换成前端所需的数据格式 // // 转换成前端所需的数据格式
// WeaForm weaForm = SalaryFormatUtil.<TaxDeclareRecordFormDTO>getInstance().buildForm(TaxDeclareRecordFormDTO.class, formDTO); // WeaForm weaForm = SalaryFormatUtil.<TaxDeclareRecordFormDTO>getInstance().buildForm(TaxDeclareRecordFormDTO.class, formDTO);
// weaForm.getItems().forEach((k, v) -> { // weaForm.getItems().forEach((k, v) -> {
@ -239,8 +238,8 @@ public class TaxDeclareRecordWrapper extends Service {
// v.getOptions().remove(0); // v.getOptions().remove(0);
// } // }
// }); // });
// return weaForm; return new HashMap();
// } }
/** /**
* 获取个税申报记录下的个税申报表TAB * 获取个税申报记录下的个税申报表TAB