新增往期累计字段

This commit is contained in:
钱涛 2023-09-05 11:04:53 +08:00
parent 9867728d2e
commit f245bd2f49
28 changed files with 829 additions and 91 deletions

View File

@ -0,0 +1,3 @@
INSERT INTO hrsa_salary_sob_default_item(id, income_category, sys_salary_item_id, can_edit, can_delete, creator, create_time, update_time, delete_type, tenant_key, sob_default_item_group_id, sorted_index) VALUES (706066600446312885, 1, 674916065864646661, 1, 0, 0, to_date('2022-05-05 16:30:11','yyyy-MM-dd HH24:mi:ss'), to_date('2022-05-05 16:30:11','yyyy-MM-dd HH24:mi:ss'), 0, 'all_teams', 703433961629614119, 5);
/

View File

@ -0,0 +1,9 @@
alter table hrsa_add_up_situation add add_up_taxable_income varchar2(255);
/
alter table hrsa_add_up_situation add actual_add_up_advance_tax varchar2(255);
/
alter table hrsa_add_up_situation add tax_adjustment varchar2(255);
/

View File

@ -0,0 +1,3 @@
INSERT INTO hrsa_salary_sob_default_item(id, income_category, sys_salary_item_id, can_edit, can_delete, creator, create_time, update_time, delete_type, tenant_key, sob_default_item_group_id, sorted_index) VALUES (706066600446312885, 1, 674916065864646661, 1, 0, 0, to_date('2022-05-05 16:30:11','yyyy-MM-dd HH24:mi:ss'), to_date('2022-05-05 16:30:11','yyyy-MM-dd HH24:mi:ss'), 0, 'all_teams', 703433961629614119, 5);
/

View File

@ -0,0 +1,9 @@
alter table hrsa_add_up_situation add add_up_taxable_income varchar2(255);
/
alter table hrsa_add_up_situation add actual_add_up_advance_tax varchar2(255);
/
alter table hrsa_add_up_situation add tax_adjustment varchar2(255);
/

View File

@ -0,0 +1,3 @@
INSERT INTO hrsa_salary_sob_default_item(id, income_category, sys_salary_item_id, can_edit, can_delete, creator, create_time, update_time, delete_type, tenant_key, sob_default_item_group_id, sorted_index) VALUES (706066600446312885, 1, 674916065864646661, 1, 0, 0, to_date('2022-05-05 16:30:11','yyyy-MM-dd HH24:mi:ss'), to_date('2022-05-05 16:30:11','yyyy-MM-dd HH24:mi:ss'), 0, 'all_teams', 703433961629614119, 5);
/

View File

@ -0,0 +1,9 @@
alter table hrsa_add_up_situation add add_up_taxable_income varchar2(255);
/
alter table hrsa_add_up_situation add actual_add_up_advance_tax varchar2(255);
/
alter table hrsa_add_up_situation add tax_adjustment varchar2(255);
/

View File

@ -0,0 +1 @@
INSERT INTO hrsa_salary_sob_default_item(id, income_category, sys_salary_item_id, can_edit, can_delete, creator, create_time, update_time, delete_type, tenant_key, sob_default_item_group_id, sorted_index) VALUES (706066600446312885, 1, 674916065864646661, 1, 0, 0, '2022-03-14 11:32:30', '2022-03-18 16:59:24', 0, 'all_teams', 703433961629614119, 5);

View File

@ -0,0 +1,6 @@
alter table hrsa_add_up_situation add add_up_taxable_income varchar(255)
;
alter table hrsa_add_up_situation add actual_add_up_advance_tax varchar(255)
;
alter table hrsa_add_up_situation add tax_adjustment varchar(255)
;

View File

@ -0,0 +1,2 @@
INSERT INTO hrsa_salary_sob_default_item(id, income_category, sys_salary_item_id, can_edit, can_delete, creator, create_time, update_time, delete_type, tenant_key, sob_default_item_group_id, sorted_index) VALUES (706066600446312885, 1, 674916065864646661, 1, 0, 0, to_date('2022-05-05 16:30:11','yyyy-MM-dd HH24:mi:ss'), to_date('2022-05-05 16:30:11','yyyy-MM-dd HH24:mi:ss'), 0, 'all_teams', 703433961629614119, 5)
/

View File

@ -0,0 +1,6 @@
alter table hrsa_add_up_situation add add_up_taxable_income varchar2(255)
/
alter table hrsa_add_up_situation add actual_add_up_advance_tax varchar2(255)
/
alter table hrsa_add_up_situation add tax_adjustment varchar2(255)
/

View File

@ -0,0 +1,2 @@
INSERT INTO hrsa_salary_sob_default_item(id, income_category, sys_salary_item_id, can_edit, can_delete, creator, create_time, update_time, delete_type, tenant_key, sob_default_item_group_id, sorted_index) VALUES (706066600446312885, 1, 674916065864646661, 1, 0, 0, '2022-03-14 11:32:30', '2022-03-18 16:59:24', 0, 'all_teams', 703433961629614119, 5);
/

View File

@ -0,0 +1,6 @@
alter table hrsa_add_up_situation add add_up_taxable_income varchar(255);
/
alter table hrsa_add_up_situation add actual_add_up_advance_tax varchar(255);
/
alter table hrsa_add_up_situation add tax_adjustment varchar(255);
/

View File

@ -0,0 +1,2 @@
INSERT INTO hrsa_salary_sob_default_item(id, income_category, sys_salary_item_id, can_edit, can_delete, creator, create_time, update_time, delete_type, tenant_key, sob_default_item_group_id, sorted_index) VALUES (706066600446312885, 1, 674916065864646661, 1, 0, 0, '2022-03-14 11:32:30', '2022-03-18 16:59:24', 0, 'all_teams', 703433961629614119, 5)
GO

View File

@ -0,0 +1,6 @@
alter table hrsa_add_up_situation add add_up_taxable_income nvarchar(255)
GO
alter table hrsa_add_up_situation add actual_add_up_advance_tax nvarchar(255)
GO
alter table hrsa_add_up_situation add tax_adjustment nvarchar(255)
GO

View File

@ -0,0 +1,3 @@
INSERT INTO hrsa_salary_sob_default_item(id, income_category, sys_salary_item_id, can_edit, can_delete, creator, create_time, update_time, delete_type, tenant_key, sob_default_item_group_id, sorted_index) VALUES (706066600446312885, 1, 674916065864646661, 1, 0, 0, to_date('2022-05-05 16:30:11','yyyy-MM-dd HH24:mi:ss'), to_date('2022-05-05 16:30:11','yyyy-MM-dd HH24:mi:ss'), 0, 'all_teams', 703433961629614119, 5);
/

View File

@ -0,0 +1,9 @@
alter table hrsa_add_up_situation add add_up_taxable_income varchar2(255);
/
alter table hrsa_add_up_situation add actual_add_up_advance_tax varchar2(255);
/
alter table hrsa_add_up_situation add tax_adjustment varchar2(255);
/

View File

@ -137,6 +137,10 @@ public class SzyhApiConstant {
* 刷新缴款状态 * 刷新缴款状态
*/ */
public static final String GET_SYNC_WITHHOLDING_FEEDBACK = "gateway/iit/payment/getSyncWithholdingFeedback"; public static final String GET_SYNC_WITHHOLDING_FEEDBACK = "gateway/iit/payment/getSyncWithholdingFeedback";
/**
* 企业申报数据明细查询
*/
public static final String GET_COMPANY_INCOMES = "gateway/iit/report/getCompanyIncomes";
/** /**

View File

@ -4,6 +4,7 @@ import com.engine.salary.annotation.Encrypt;
import com.engine.salary.annotation.SalaryFormulaVar; import com.engine.salary.annotation.SalaryFormulaVar;
import com.engine.salary.annotation.SalaryTable; import com.engine.salary.annotation.SalaryTable;
import com.engine.salary.annotation.SalaryTableOperate; import com.engine.salary.annotation.SalaryTableOperate;
import com.engine.salary.enums.datacollection.DataCollectionEmployeeTypeEnum;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Builder; import lombok.Builder;
import lombok.Data; import lombok.Data;
@ -49,6 +50,12 @@ public class AddUpSituation {
*/ */
private Integer year; private Integer year;
/**
* 人员类型
* @see DataCollectionEmployeeTypeEnum
*/
private Integer employeeType;
/** /**
* 累计收入额 * 累计收入额
*/ */
@ -82,6 +89,7 @@ public class AddUpSituation {
*/ */
@SalaryFormulaVar(defaultLabel = "累计子女教育", labelId = 86321, dataType = "number") @SalaryFormulaVar(defaultLabel = "累计子女教育", labelId = 86321, dataType = "number")
@Encrypt @Encrypt
@Deprecated
private String addUpChildEducation; private String addUpChildEducation;
/** /**
@ -89,6 +97,7 @@ public class AddUpSituation {
*/ */
@SalaryFormulaVar(defaultLabel = "累计继续教育", labelId = 86323, dataType = "number") @SalaryFormulaVar(defaultLabel = "累计继续教育", labelId = 86323, dataType = "number")
@Encrypt @Encrypt
@Deprecated
private String addUpContinuingEducation; private String addUpContinuingEducation;
/** /**
@ -96,6 +105,7 @@ public class AddUpSituation {
*/ */
@SalaryFormulaVar(defaultLabel = "累计住房贷款利息", labelId = 86324, dataType = "number") @SalaryFormulaVar(defaultLabel = "累计住房贷款利息", labelId = 86324, dataType = "number")
@Encrypt @Encrypt
@Deprecated
private String addUpHousingLoanInterest; private String addUpHousingLoanInterest;
/** /**
@ -103,6 +113,7 @@ public class AddUpSituation {
*/ */
@SalaryFormulaVar(defaultLabel = "累计住房租金", labelId = 86325, dataType = "number") @SalaryFormulaVar(defaultLabel = "累计住房租金", labelId = 86325, dataType = "number")
@Encrypt @Encrypt
@Deprecated
private String addUpHousingRent; private String addUpHousingRent;
/** /**
@ -110,6 +121,7 @@ public class AddUpSituation {
*/ */
@SalaryFormulaVar(defaultLabel = "累计赡养老人", labelId = 86326, dataType = "number") @SalaryFormulaVar(defaultLabel = "累计赡养老人", labelId = 86326, dataType = "number")
@Encrypt @Encrypt
@Deprecated
private String addUpSupportElderly; private String addUpSupportElderly;
/** /**
@ -117,6 +129,7 @@ public class AddUpSituation {
*/ */
@SalaryFormulaVar(defaultLabel = "累计大病医疗", labelId = 105142, dataType = "number") @SalaryFormulaVar(defaultLabel = "累计大病医疗", labelId = 105142, dataType = "number")
@Encrypt @Encrypt
@Deprecated
private String addUpIllnessMedical; private String addUpIllnessMedical;
/** /**
@ -124,6 +137,7 @@ public class AddUpSituation {
*/ */
@SalaryFormulaVar(defaultLabel = "累计婴幼儿照护", labelId = 117732, dataType = "number") @SalaryFormulaVar(defaultLabel = "累计婴幼儿照护", labelId = 117732, dataType = "number")
@Encrypt @Encrypt
@Deprecated
private String addUpInfantCare; private String addUpInfantCare;
/** /**
@ -131,6 +145,7 @@ public class AddUpSituation {
*/ */
@SalaryFormulaVar(defaultLabel = "累计个人养老金", labelId = 117732, dataType = "number") @SalaryFormulaVar(defaultLabel = "累计个人养老金", labelId = 117732, dataType = "number")
@Encrypt @Encrypt
@Deprecated
private String addUpPrivatePension; private String addUpPrivatePension;
/** /**
@ -175,6 +190,27 @@ public class AddUpSituation {
@Encrypt @Encrypt
private String addUpAdvanceTax; private String addUpAdvanceTax;
/**
* 累计已预扣预缴税额
*/
@SalaryFormulaVar(defaultLabel = "实际累计已预扣预缴税额", labelId = 233557, dataType = "number")
@Encrypt
private String actualAddUpAdvanceTax;
/**
* 累计已预扣预缴税额
*/
@SalaryFormulaVar(defaultLabel = "个税调差", labelId = 233559, dataType = "number")
@Encrypt
private String taxAdjustment;
/**
* 累计应纳税所得额
*/
@SalaryFormulaVar(defaultLabel = "累计应纳税所得额", labelId = 85371, dataType = "number")
@Encrypt
private String addUpTaxableIncome;
/** /**
* 创建时间 * 创建时间
*/ */

View File

@ -17,6 +17,7 @@ import java.util.Date;
@AllArgsConstructor @AllArgsConstructor
@NoArgsConstructor @NoArgsConstructor
@Accessors(chain = true) @Accessors(chain = true)
//hrsa_special_add_deduction
public class SpecialAddDeductionPO { public class SpecialAddDeductionPO {
private Long id; private Long id;

View File

@ -0,0 +1,395 @@
package com.engine.salary.entity.datacollection.response;
import com.engine.salary.entity.taxpayment.response.BaseResponse;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.List;
/**
* 人员专项附加扣除信息查询结果
*
* @author chengliming
* @date 2022-10-27 10:00 AM
**/
@Data
@EqualsAndHashCode(callSuper = true)
public class GetCompanyIncomesResponse extends BaseResponse {
/**
* 返回数据
*/
private Body body;
/**
* 人员专项附加扣除信息查询结果body
**/
@Data
public static class Body {
/**
* 明细
*/
private List<Detail> sfmx;
/**
* 合计
*/
private Sum sfhj;
}
@Data
public static class Detail {
/**
* 是否明细申报
**/
private String sfmxsb;
/**
* 纳税人姓名
**/
private String xm;
/**
* 纳税识别号
**/
private String nsrsbh;
/**
* 证件类型
**/
private String zjlx;
/**
* 证件号码
**/
private String zjhm;
/**
* 非居民个人
**/
private String sffjm;
/**
* 所得项目名称
**/
private String sdxmmc;
/**
* 收入额
**/
private String sre;
/**
* 费用
**/
private String fy;
/**
* 免税收入
**/
private String mssr;
/**
* 财产原值
**/
private String ccyz;
/**
* 投资抵扣
**/
private String tzdk;
/**
* 允许扣除的费用
**/
private String yxkcsf;
/**
* 减计比例
**/
private String jjbl;
/**
* 减除费用
**/
private String jcfy;
/**
* 基本养老保险
**/
private String jbylaobxf;
/**
* 基本医疗保险费
**/
private String jbylbxf;
/**
* 失业保险费
**/
private String sybxf;
/**
* 住房公积金
**/
private String zfgjj;
/**
* 年金
**/
private String nj;
/**
* 商业健康保险
**/
private String syjkbx;
/**
* 税延养老保险
**/
private String syylbx;
/**
* 其它扣除
**/
private String qt;
/**
* 准予扣除的捐赠额
**/
private String zykcjze;
/**
* 累计收入额
**/
private String ljsre;
/**
* 累计减除费用
**/
private String ljjcfy;
/**
* 累计专项扣除
**/
private String ljzxkc;
/**
* 累计子女教育
**/
private String ljznjy;
/**
* 累计赡养老人
**/
private String ljsylr;
/**
* 累计住房贷款利息
**/
private String ljzfdklx;
/**
* 累计住房租金
**/
private String ljzfzj;
/**
* 累计继续教育
**/
private String ljjxjy;
/**
* 累计3岁以下婴幼儿照护支出
**/
private String ljyyezhzc;
/**
* 累计其它扣除
**/
private String ljqtkc;
/**
* 累计准予扣除的捐赠额
**/
private String ljzykcjze;
/**
* 累计个人养老金
**/
private String ljgrylj;
/**
* 应纳税所得额
**/
private String ynssde;
/**
* 税率
**/
private String sl;
/**
* 协定税率
**/
private String xdsl;
/**
* 速算扣除数
**/
private String sskcs;
/**
* 应纳税额
**/
private String ynse;
/**
* 减免税额
**/
private String jmse;
/**
* 已扣缴税额
**/
private String ykjse;
/**
* 应补退税额
**/
private String ybtse;
/**
* 备注
**/
private String bz;
/**
* 分摊年度数
**/
private String ftnds;
/**
* 年减除费用
**/
private String njcfy;
/**
* 应扣缴税额
**/
private String kjse;
/**
* 证券账户号
**/
private String zqzhh;
/**
* 股票代码
**/
private String gpdm;
/**
* 股票名称
**/
private String gpmc;
/**
* 每股计税价格
**/
private String mgjsjg;
/**
* 转让股数
**/
private String zrgs;
/**
* 限售股原值
**/
private String xsgyz;
/**
* 合理税费
**/
private String hlsf;
/**
* 扣除及减除项目合计
**/
private String kcjjcxmhj;
}
/**
* 合计
*/
@Data
public static class Sum {
/**
* 收入额合计
*/
private String srehj;
/**
* 免税收入合计
*/
private String mssrhj;
/**
* 财产原值合计
*/
private String ccyzhj;
/**
* 投资抵扣合计
*/
private String tzdkhj;
/**
* 允许扣除的税费合计
*/
private String yxkcsfhj;
/**
* 基本养老保险费合计
*/
private String jbylaobxfhj;
/**
* 基本医疗保险费合计
*/
private String jbylbxfhj;
/**
* 失业保险费合计
*/
private String sybxfhj;
/**
* 住房公积金合计
*/
private String zfgjjhj;
/**
* 年金合计
*/
private String njhj;
/**
* 商业健康保险合计
*/
private String syjkbxhj;
/**
* 税延养老保险合计
*/
private String syylbxhj;
/**
* 其他扣除合计
*/
private String qthj;
/**
* 准予扣除的捐赠额合计
*/
private String zykcjzehj;
/**
* 累计收入额合计
*/
private String ljsrehj;
/**
* 累计专项扣除合计
*/
private String ljzxkchj;
/**
* 累计子女教育合计
*/
private String ljznjyhj;
/**
* 累计赡养老人合计
*/
private String ljsylrhj;
/**
* 累计住房贷款利息合计
*/
private String ljzfdklxhj;
/**
* 累计住房租金合计
*/
private String ljzfzjhj;
/**
* 累计继续教育合计
*/
private String ljjxjyhj;
/**
* 累计3岁以下婴幼儿照护支出合计
*/
private String ljyyezhzchj;
/**
* 累计其他扣除合计
*/
private String ljqtkchj;
/**
* 累计准予扣除的捐赠额合计
*/
private String ljzykcjzehj;
/**
* 累计个人养老金合计
*/
private String ljgryljhj;
/**
* 应纳税所得额合计
*/
private String ynssdehj;
/**
* 应纳税额合计
*/
private String ynsehj;
/**
* 减免税额合计
*/
private String jmsehj;
/**
* 已扣缴税额合计
*/
private String ykjsehj;
/**
* 应补退税额合计
*/
private String ybtsehj;
}
}

View File

@ -192,9 +192,8 @@ public interface AddUpDeductionService {
/** /**
* 导出反馈失败记录 * 导出反馈失败记录
* *
* @param map
* @param requestId * @param requestId
*/ */
void exportOnlineFeedbackFail(Map<String, Object> map, Long requestId); XSSFWorkbook exportOnlineFeedbackFail(Long requestId);
} }

View File

@ -112,4 +112,12 @@ public interface AddUpSituationService {
* @date 2022/10/31 14:00 * @date 2022/10/31 14:00
*/ */
AddUpSituationRecordDTO getAddUpSituation(AddUpSituationParam addUpSituationParam); AddUpSituationRecordDTO getAddUpSituation(AddUpSituationParam addUpSituationParam);
/**
* 在线获取实际累计已预扣预缴税额
*
* @param param
* @return
*/
Map<String, Object> onlineRequest(AddUpDeductionMonthTaxAgentParam param);
} }

View File

@ -1446,7 +1446,7 @@ public class AddUpDeductionServiceImpl extends Service implements AddUpDeduction
} }
@Override @Override
public void exportOnlineFeedbackFail(Map<String, Object> map, Long requestId) { public XSSFWorkbook exportOnlineFeedbackFail( Long requestId) {
List<List<Object>> rows = new ArrayList<>(); List<List<Object>> rows = new ArrayList<>();
// 表头 // 表头
List<Object> headers = new ArrayList<>(); List<Object> headers = new ArrayList<>();
@ -1476,7 +1476,7 @@ public class AddUpDeductionServiceImpl extends Service implements AddUpDeduction
rows.add(row); rows.add(row);
} }
// 生成表格 // 生成表格
ExcelUtil.genWorkbookV2(rows, ""); return ExcelUtil.genWorkbookV2(rows, "在线获取专项附加扣除失败数据");
} }

View File

@ -1,5 +1,6 @@
package com.engine.salary.service.impl; package com.engine.salary.service.impl;
import com.alibaba.fastjson.JSON;
import com.api.browser.bean.SearchConditionGroup; import com.api.browser.bean.SearchConditionGroup;
import com.api.browser.bean.SearchConditionItem; import com.api.browser.bean.SearchConditionItem;
import com.api.browser.util.ConditionFactory; import com.api.browser.util.ConditionFactory;
@ -8,33 +9,38 @@ import com.api.formmode.mybatis.util.SqlProxyHandle;
import com.engine.common.util.ServiceUtil; import com.engine.common.util.ServiceUtil;
import com.engine.core.impl.Service; import com.engine.core.impl.Service;
import com.engine.salary.biz.AddUpSituationBiz; import com.engine.salary.biz.AddUpSituationBiz;
import com.engine.salary.constant.SzyhApiConstant;
import com.engine.salary.encrypt.EncryptUtil; import com.engine.salary.encrypt.EncryptUtil;
import com.engine.salary.entity.datacollection.AddUpSituation; import com.engine.salary.entity.datacollection.AddUpSituation;
import com.engine.salary.entity.datacollection.DataCollectionEmployee; import com.engine.salary.entity.datacollection.DataCollectionEmployee;
import com.engine.salary.entity.datacollection.bo.DataCollectionBO;
import com.engine.salary.entity.datacollection.dto.AddUpSituationDTO; import com.engine.salary.entity.datacollection.dto.AddUpSituationDTO;
import com.engine.salary.entity.datacollection.dto.AddUpSituationRecordDTO; import com.engine.salary.entity.datacollection.dto.AddUpSituationRecordDTO;
import com.engine.salary.entity.datacollection.param.AddUpSituationDeleteParam; import com.engine.salary.entity.datacollection.param.*;
import com.engine.salary.entity.datacollection.param.AddUpSituationImportParam; import com.engine.salary.entity.datacollection.po.AddUpDeductionRequestPO;
import com.engine.salary.entity.datacollection.param.AddUpSituationParam; import com.engine.salary.entity.datacollection.response.GetCompanyIncomesResponse;
import com.engine.salary.entity.datacollection.param.AddUpSituationQueryParam; import com.engine.salary.entity.employeedeclare.po.EmployeeDeclarePO;
import com.engine.salary.entity.salaryacct.po.SalaryAcctEmployeePO; import com.engine.salary.entity.salaryacct.po.SalaryAcctEmployeePO;
import com.engine.salary.entity.salaryarchive.po.SalaryArchivePO;
import com.engine.salary.entity.taxagent.dto.TaxAgentManageRangeEmployeeDTO; import com.engine.salary.entity.taxagent.dto.TaxAgentManageRangeEmployeeDTO;
import com.engine.salary.entity.taxagent.po.TaxAgentPO; import com.engine.salary.entity.taxagent.po.TaxAgentPO;
import com.engine.salary.entity.taxagent.po.TaxAgentTaxReturnPO;
import com.engine.salary.entity.taxagent.response.SzyhResponseHead;
import com.engine.salary.entity.taxdeclaration.po.TaxDeclarationApiConfigPO;
import com.engine.salary.enums.UserStatusEnum; import com.engine.salary.enums.UserStatusEnum;
import com.engine.salary.enums.employeedeclare.DeclareStatusEnum;
import com.engine.salary.enums.salaryarchive.SalaryArchiveStatusEnum;
import com.engine.salary.enums.taxagent.TaxAgentTaxReturnStatusEnum;
import com.engine.salary.exception.SalaryRunTimeException; import com.engine.salary.exception.SalaryRunTimeException;
import com.engine.salary.mapper.datacollection.AddUpSituationMapper; import com.engine.salary.mapper.datacollection.AddUpSituationMapper;
import com.engine.salary.mapper.employeedeclare.EmployeeDeclareMapper;
import com.engine.salary.mapper.sys.SalarySysConfMapper; import com.engine.salary.mapper.sys.SalarySysConfMapper;
import com.engine.salary.service.AddUpDeductionService; import com.engine.salary.service.*;
import com.engine.salary.service.AddUpSituationService;
import com.engine.salary.service.SalaryEmployeeService;
import com.engine.salary.service.TaxAgentService;
import com.engine.salary.sys.entity.po.SalarySysConfPO; import com.engine.salary.sys.entity.po.SalarySysConfPO;
import com.engine.salary.sys.entity.vo.OrderRuleVO; import com.engine.salary.sys.entity.vo.OrderRuleVO;
import com.engine.salary.sys.service.SalarySysConfService; import com.engine.salary.sys.service.SalarySysConfService;
import com.engine.salary.sys.service.impl.SalarySysConfServiceImpl; import com.engine.salary.sys.service.impl.SalarySysConfServiceImpl;
import com.engine.salary.util.SalaryDateUtil; import com.engine.salary.util.*;
import com.engine.salary.util.SalaryEntityUtil;
import com.engine.salary.util.SalaryI18nUtil;
import com.engine.salary.util.db.MapperProxyFactory; import com.engine.salary.util.db.MapperProxyFactory;
import com.engine.salary.util.excel.ExcelComment; import com.engine.salary.util.excel.ExcelComment;
import com.engine.salary.util.excel.ExcelParseHelper; import com.engine.salary.util.excel.ExcelParseHelper;
@ -43,8 +49,10 @@ import com.engine.salary.util.page.PageInfo;
import com.engine.salary.util.page.SalaryPageUtil; import com.engine.salary.util.page.SalaryPageUtil;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.math.NumberUtils;
import org.apache.poi.util.IOUtils; import org.apache.poi.util.IOUtils;
import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import weaver.file.ImageFileManager; import weaver.file.ImageFileManager;
@ -61,6 +69,7 @@ import java.util.stream.Collectors;
import static com.engine.salary.constant.SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY; import static com.engine.salary.constant.SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY;
@Slf4j
public class AddUpSituationServiceImpl extends Service implements AddUpSituationService { public class AddUpSituationServiceImpl extends Service implements AddUpSituationService {
private EncryptUtil encryptUtil = new EncryptUtil(); private EncryptUtil encryptUtil = new EncryptUtil();
@ -84,12 +93,28 @@ public class AddUpSituationServiceImpl extends Service implements AddUpSituation
return ServiceUtil.getService(SalarySysConfServiceImpl.class, user); return ServiceUtil.getService(SalarySysConfServiceImpl.class, user);
} }
private TaxDeclarationApiConfigService getTaxDeclarationApiConfigService(User user) {
return ServiceUtil.getService(TaxDeclarationApiConfigServiceImpl.class, user);
}
private TaxAgentTaxReturnService getTaxAgentTaxReturnService(User user) {
return ServiceUtil.getService(TaxAgentTaxReturnServiceImpl.class, user);
}
private SalaryArchiveService getSalaryArchiveService(User user) {
return ServiceUtil.getService(SalaryArchiveServiceImpl.class, user);
}
AddUpSituationBiz biz = new AddUpSituationBiz(); AddUpSituationBiz biz = new AddUpSituationBiz();
private SalarySysConfMapper getSalarySysConfMapper() { private SalarySysConfMapper getSalarySysConfMapper() {
return SqlProxyHandle.getProxy(SalarySysConfMapper.class); return SqlProxyHandle.getProxy(SalarySysConfMapper.class);
} }
private EmployeeDeclareMapper getEmployeeDeclareMapper() {
return MapperProxyFactory.getProxy(EmployeeDeclareMapper.class);
}
@Override @Override
public Map<String, Object> getSearchCondition() { public Map<String, Object> getSearchCondition() {
Map<String, Object> apidatas = new HashMap<String, Object>(); Map<String, Object> apidatas = new HashMap<String, Object>();
@ -274,7 +299,7 @@ public class AddUpSituationServiceImpl extends Service implements AddUpSituation
// excel标题 // excel标题
final List<String> title = Arrays.asList("姓名", "个税扣缴义务人", "部门", "手机号", "工号", "证件号码", "入职日期", "累计收入额", "累计减除费用", final List<String> title = Arrays.asList("姓名", "个税扣缴义务人", "部门", "手机号", "工号", "证件号码", "入职日期", "累计收入额", "累计减除费用",
"累计社保个人合计", "累计公积金个人合计", "累计子女教育", "累计继续教育", "累计住房贷款利息", "累计住房租金", "累计赡养老人", "累计社保个人合计", "累计公积金个人合计", "累计子女教育", "累计继续教育", "累计住房贷款利息", "累计住房租金", "累计赡养老人",
"累计大病医疗", "累计企业(职业)年金及其他福利", "累计其他扣除", "累计免税收入", "累计准予扣除的捐赠额", "累计减免税额", "累计已预扣预缴税额", "累计婴幼儿照护","累计个人养老金"); "累计大病医疗", "累计企业(职业)年金及其他福利", "累计其他扣除", "累计免税收入", "累计准予扣除的捐赠额", "累计减免税额", "累计已预扣预缴税额", "累计婴幼儿照护", "累计个人养老金");
//排序配置 //排序配置
OrderRuleVO orderRule = getSalarySysConfService(user).orderRule(); OrderRuleVO orderRule = getSalarySysConfService(user).orderRule();
@ -340,7 +365,7 @@ public class AddUpSituationServiceImpl extends Service implements AddUpSituation
//excel标题 //excel标题
List<String> title = Arrays.asList("姓名", "税款所属期", "个税扣缴义务人", "部门", "手机号", "工号", "累计收入额", "累计减除费用", "累计社保个人合计", List<String> title = Arrays.asList("姓名", "税款所属期", "个税扣缴义务人", "部门", "手机号", "工号", "累计收入额", "累计减除费用", "累计社保个人合计",
"累计公积金个人合计", "累计子女教育", "累计继续教育", "累计住房贷款利息", "累计住房租金", "累计赡养老人", "累计大病医疗", "累计企业(职业)年金及其他福利", "累计公积金个人合计", "累计子女教育", "累计继续教育", "累计住房贷款利息", "累计住房租金", "累计赡养老人", "累计大病医疗", "累计企业(职业)年金及其他福利",
"累计其他扣除", "累计免税收入", "累计准予扣除的捐赠额", "累计减免税额", "累计已预扣预缴税额", "累计婴幼儿照护","累计个人养老金"); "累计其他扣除", "累计免税收入", "累计准予扣除的捐赠额", "累计减免税额", "累计已预扣预缴税额", "累计婴幼儿照护", "累计个人养老金");
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM"); SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM");
//查询详细信息 //查询详细信息
@ -609,7 +634,7 @@ public class AddUpSituationServiceImpl extends Service implements AddUpSituation
// 获取已经核算的数据(获取税款所属期下一个月的数据) // 获取已经核算的数据(获取税款所属期下一个月的数据)
YearMonth nextTaxYearMonth = SalaryDateUtil.String2YearMonth(taxYearMonthStr); YearMonth nextTaxYearMonth = SalaryDateUtil.String2YearMonth(taxYearMonthStr);
String nextTaxYearMonthStr = taxYearMonthStr; String nextTaxYearMonthStr = taxYearMonthStr;
if( !Objects.equals(nextTaxYearMonth.getMonthValue(),12) ){ if (!Objects.equals(nextTaxYearMonth.getMonthValue(), 12)) {
nextTaxYearMonth = nextTaxYearMonth.plusMonths(1); nextTaxYearMonth = nextTaxYearMonth.plusMonths(1);
nextTaxYearMonthStr = nextTaxYearMonth.format(SalaryDateUtil.MONTH_FORMATTER); nextTaxYearMonthStr = nextTaxYearMonth.format(SalaryDateUtil.MONTH_FORMATTER);
} }
@ -693,7 +718,7 @@ public class AddUpSituationServiceImpl extends Service implements AddUpSituation
errorMessageMap.put("message", rowIndex + "员工信息不存在或者存在多个员工"); errorMessageMap.put("message", rowIndex + "员工信息不存在或者存在多个员工");
errorData.add(errorMessageMap); errorData.add(errorMessageMap);
errorSum += 1; errorSum += 1;
}else { } else {
Long employeeId = CollectionUtils.isNotEmpty(employeeSameIds) && employeeSameIds.size() == 1 ? employeeSameIds.get(0).getEmployeeId() : null; Long employeeId = CollectionUtils.isNotEmpty(employeeSameIds) && employeeSameIds.size() == 1 ? employeeSameIds.get(0).getEmployeeId() : null;
po.setEmployeeId(employeeId); po.setEmployeeId(employeeId);
} }
@ -744,7 +769,7 @@ public class AddUpSituationServiceImpl extends Service implements AddUpSituation
// } // }
// 判断是否有核算过 // 判断是否有核算过
if (CollectionUtils.isNotEmpty(salaryAcctEmployees) && !Objects.equals(taxYearMonthStr.split("-")[1], "12") ) { if (CollectionUtils.isNotEmpty(salaryAcctEmployees) && !Objects.equals(taxYearMonthStr.split("-")[1], "12")) {
Optional<SalaryAcctEmployeePO> optionalAcctEmp = salaryAcctEmployees.stream().filter(f -> f.getEmployeeId().equals(po.getEmployeeId()) && f.getTaxAgentId().equals(po.getTaxAgentId())).findFirst(); Optional<SalaryAcctEmployeePO> optionalAcctEmp = salaryAcctEmployees.stream().filter(f -> f.getEmployeeId().equals(po.getEmployeeId()) && f.getTaxAgentId().equals(po.getTaxAgentId())).findFirst();
boolean isExist = list.stream().anyMatch(f -> f.getEmployeeId().equals(po.getEmployeeId()) && f.getTaxAgentId().equals(po.getTaxAgentId())); boolean isExist = list.stream().anyMatch(f -> f.getEmployeeId().equals(po.getEmployeeId()) && f.getTaxAgentId().equals(po.getTaxAgentId()));
if (optionalAcctEmp.isPresent() && isExist) { if (optionalAcctEmp.isPresent() && isExist) {
@ -846,8 +871,8 @@ public class AddUpSituationServiceImpl extends Service implements AddUpSituation
} }
/** /**
* @description 编辑数据
* @return void * @return void
* @description 编辑数据
* @author Harryxzy * @author Harryxzy
* @date 2022/10/27 21:32 * @date 2022/10/27 21:32
*/ */
@ -860,12 +885,12 @@ public class AddUpSituationServiceImpl extends Service implements AddUpSituation
// 获取所有个税扣缴义务人 // 获取所有个税扣缴义务人
Collection<TaxAgentManageRangeEmployeeDTO> taxAgentList = getTaxAgentService(user).listTaxAgentAndEmployeeTree(currentEmployeeId); Collection<TaxAgentManageRangeEmployeeDTO> taxAgentList = getTaxAgentService(user).listTaxAgentAndEmployeeTree(currentEmployeeId);
AddUpSituation byId = biz.getById(addUpSituationParam.getId()); AddUpSituation byId = biz.getById(addUpSituationParam.getId());
if(byId == null){ if (byId == null) {
throw new SalaryRunTimeException("该数据不存在!"); throw new SalaryRunTimeException("该数据不存在!");
} }
Long taxAgentId = byId.getTaxAgentId(); Long taxAgentId = byId.getTaxAgentId();
boolean canEdit = taxAgentList.stream().anyMatch(t -> Objects.equals(t.getTaxAgentId() , taxAgentId)); boolean canEdit = taxAgentList.stream().anyMatch(t -> Objects.equals(t.getTaxAgentId(), taxAgentId));
if(!canEdit){ if (!canEdit) {
//没有编辑权限 //没有编辑权限
throw new SalaryRunTimeException("该个税扣缴义务人无权限编辑此数据!"); throw new SalaryRunTimeException("该个税扣缴义务人无权限编辑此数据!");
} }
@ -873,14 +898,14 @@ public class AddUpSituationServiceImpl extends Service implements AddUpSituation
// 获取已经核算的数据(获取税款所属期下一个月的数据) // 获取已经核算的数据(获取税款所属期下一个月的数据)
YearMonth nextTaxYearMonth = SalaryDateUtil.String2YearMonth(taxYearMonthStr); YearMonth nextTaxYearMonth = SalaryDateUtil.String2YearMonth(taxYearMonthStr);
String nextTaxYearMonthStr = taxYearMonthStr; String nextTaxYearMonthStr = taxYearMonthStr;
if( !Objects.equals(nextTaxYearMonth.getMonthValue(),12) ){ if (!Objects.equals(nextTaxYearMonth.getMonthValue(), 12)) {
nextTaxYearMonth = nextTaxYearMonth.plusMonths(1); nextTaxYearMonth = nextTaxYearMonth.plusMonths(1);
nextTaxYearMonthStr = nextTaxYearMonth.format(SalaryDateUtil.MONTH_FORMATTER); nextTaxYearMonthStr = nextTaxYearMonth.format(SalaryDateUtil.MONTH_FORMATTER);
} }
List<SalaryAcctEmployeePO> salaryAcctEmployees = getAddUpDeductionService(user).getAccountedEmployeeDataByTaxYearMonth(nextTaxYearMonthStr); List<SalaryAcctEmployeePO> salaryAcctEmployees = getAddUpDeductionService(user).getAccountedEmployeeDataByTaxYearMonth(nextTaxYearMonthStr);
// 判断是否有核算过 // 判断是否有核算过
if (CollectionUtils.isNotEmpty(salaryAcctEmployees) && !Objects.equals(taxYearMonthStr.split("-")[1], "12")) { if (CollectionUtils.isNotEmpty(salaryAcctEmployees) && !Objects.equals(taxYearMonthStr.split("-")[1], "12")) {
Optional<SalaryAcctEmployeePO> optionalAcctEmp = salaryAcctEmployees.stream().filter(f -> f.getEmployeeId().equals(addUpSituationParam.getEmployeeId()) && f.getTaxAgentId().equals(addUpSituationParam.getTaxAgentId())).findFirst(); Optional<SalaryAcctEmployeePO> optionalAcctEmp = salaryAcctEmployees.stream().filter(f -> f.getEmployeeId().equals(addUpSituationParam.getEmployeeId()) && f.getTaxAgentId().equals(addUpSituationParam.getTaxAgentId())).findFirst();
if (optionalAcctEmp.isPresent()) { if (optionalAcctEmp.isPresent()) {
throw new SalaryRunTimeException("该年月这条数据已经核算过,不可进行编辑!"); throw new SalaryRunTimeException("该年月这条数据已经核算过,不可进行编辑!");
@ -903,8 +928,8 @@ public class AddUpSituationServiceImpl extends Service implements AddUpSituation
} }
/** /**
* @description 新建数据
* @return void * @return void
* @description 新建数据
* @author Harryxzy * @author Harryxzy
* @date 2022/10/27 22:04 * @date 2022/10/27 22:04
*/ */
@ -947,8 +972,8 @@ public class AddUpSituationServiceImpl extends Service implements AddUpSituation
//筛选导入人员信息可以在人力资源池中匹配到的人员信息 //筛选导入人员信息可以在人力资源池中匹配到的人员信息
boolean employeeSameId = employees.stream().anyMatch(e -> Objects.equals(e.getEmployeeId() , addUpSituationParam.getEmployeeId())); boolean employeeSameId = employees.stream().anyMatch(e -> Objects.equals(e.getEmployeeId(), addUpSituationParam.getEmployeeId()));
if(!employeeSameId){ if (!employeeSameId) {
throw new SalaryRunTimeException("员工信息不存在"); throw new SalaryRunTimeException("员工信息不存在");
} }
po.setEmployeeId(addUpSituationParam.getEmployeeId()); po.setEmployeeId(addUpSituationParam.getEmployeeId());
@ -967,7 +992,7 @@ public class AddUpSituationServiceImpl extends Service implements AddUpSituation
} }
} }
// fixme 分权判断若员工离职后不在扣缴义务人范围内会有异常 // fixme 分权判断若员工离职后不在扣缴义务人范围内会有异常
// if (openDevolution) { // if (openDevolution) {
// Optional<TaxAgentManageRangeEmployeeDTO.TaxAgentEmployee> optionalTaxAgentEmp = taxAgentEmployees.stream().filter(f -> f.getEmployeeId().equals(po.getEmployeeId())).findFirst(); // Optional<TaxAgentManageRangeEmployeeDTO.TaxAgentEmployee> optionalTaxAgentEmp = taxAgentEmployees.stream().filter(f -> f.getEmployeeId().equals(po.getEmployeeId())).findFirst();
// if (!optionalTaxAgentEmp.isPresent()) { // if (!optionalTaxAgentEmp.isPresent()) {
@ -1055,15 +1080,15 @@ public class AddUpSituationServiceImpl extends Service implements AddUpSituation
List<SalaryAcctEmployeePO> salaryAcctEmployees = getAddUpDeductionService(user).getAccountedEmployeeData(format); List<SalaryAcctEmployeePO> salaryAcctEmployees = getAddUpDeductionService(user).getAccountedEmployeeData(format);
// 判断是否有核算过 // 判断是否有核算过
List<Long> deleteList = new ArrayList<>(); List<Long> deleteList = new ArrayList<>();
for(int i=0; i<deleteIds.size(); i++){ for (int i = 0; i < deleteIds.size(); i++) {
Long id = deleteIds.get(i); Long id = deleteIds.get(i);
AddUpSituation byId = biz.getById(id); AddUpSituation byId = biz.getById(id);
if(byId == null){ if (byId == null) {
throw new SalaryRunTimeException("数据不存在或已被删除!"); throw new SalaryRunTimeException("数据不存在或已被删除!");
} }
// 判断是否在个税扣缴义务人范围内 // 判断是否在个税扣缴义务人范围内
Optional<TaxAgentManageRangeEmployeeDTO> first = taxAgentList.stream().filter(m -> Objects.equals(m.getTaxAgentId() , byId.getTaxAgentId())).findFirst(); Optional<TaxAgentManageRangeEmployeeDTO> first = taxAgentList.stream().filter(m -> Objects.equals(m.getTaxAgentId(), byId.getTaxAgentId())).findFirst();
if(!first.isPresent()){ if (!first.isPresent()) {
throw new SalaryRunTimeException("个税扣缴义务人不存在或不在权限范围内"); throw new SalaryRunTimeException("个税扣缴义务人不存在或不在权限范围内");
} }
// 判断用户是否存在 // 判断用户是否存在
@ -1089,23 +1114,23 @@ public class AddUpSituationServiceImpl extends Service implements AddUpSituation
AddUpSituationBiz biz = new AddUpSituationBiz(); AddUpSituationBiz biz = new AddUpSituationBiz();
Date declareMonthDate = new Date(); Date declareMonthDate = new Date();
try { try {
declareMonthDate = (sdf.parse(declareMonthStr+"-01")); declareMonthDate = (sdf.parse(declareMonthStr + "-01"));
}catch (Exception e){ } catch (Exception e) {
throw new SalaryRunTimeException("日期异常"); throw new SalaryRunTimeException("日期异常");
} }
AddUpSituation queryParam = null; AddUpSituation queryParam = null;
if(deleteParam.getTaxAgentId() != null && !deleteParam.getTaxAgentId().isEmpty()){ if (deleteParam.getTaxAgentId() != null && !deleteParam.getTaxAgentId().isEmpty()) {
// 设置了个税扣缴义务人 // 设置了个税扣缴义务人
Long taxAgentId = SalaryEntityUtil.string2Long(deleteParam.getTaxAgentId()); Long taxAgentId = SalaryEntityUtil.string2Long(deleteParam.getTaxAgentId());
boolean canDelete = taxAgentIds.stream().anyMatch(t -> Objects.equals(t , taxAgentId)); boolean canDelete = taxAgentIds.stream().anyMatch(t -> Objects.equals(t, taxAgentId));
if(!canDelete){ if (!canDelete) {
throw new SalaryRunTimeException("个税扣缴义务人不存在或不在权限范围内!"); throw new SalaryRunTimeException("个税扣缴义务人不存在或不在权限范围内!");
} }
ArrayList<Long> tai = new ArrayList<>(); ArrayList<Long> tai = new ArrayList<>();
tai.add(taxAgentId); tai.add(taxAgentId);
queryParam = AddUpSituation.builder().taxYearMonth(declareMonthDate).taxAgentIds(tai).build(); queryParam = AddUpSituation.builder().taxYearMonth(declareMonthDate).taxAgentIds(tai).build();
}else { } else {
queryParam = AddUpSituation.builder().taxYearMonth(declareMonthDate).taxAgentIds(taxAgentIds).build(); queryParam = AddUpSituation.builder().taxYearMonth(declareMonthDate).taxAgentIds(taxAgentIds).build();
} }
@ -1115,7 +1140,7 @@ public class AddUpSituationServiceImpl extends Service implements AddUpSituation
String format = salaryMonthDate.plusMonths(1).atStartOfDay().format(DateTimeFormatter.ofPattern("yyyy-MM")); String format = salaryMonthDate.plusMonths(1).atStartOfDay().format(DateTimeFormatter.ofPattern("yyyy-MM"));
// 获取已经核算的数据 // 获取已经核算的数据
List<SalaryAcctEmployeePO> employees = getAddUpDeductionService(user).getAccountedEmployeeData(format); List<SalaryAcctEmployeePO> employees = getAddUpDeductionService(user).getAccountedEmployeeData(format);
for(AddUpSituation item : list){ for (AddUpSituation item : list) {
if (CollectionUtils.isNotEmpty(employees)) { if (CollectionUtils.isNotEmpty(employees)) {
Optional<SalaryAcctEmployeePO> optionalAcctEmp = employees.stream().filter(f -> f.getEmployeeId().equals(item.getEmployeeId()) && f.getTaxAgentId().equals(item.getTaxAgentId())).findFirst(); Optional<SalaryAcctEmployeePO> optionalAcctEmp = employees.stream().filter(f -> f.getEmployeeId().equals(item.getEmployeeId()) && f.getTaxAgentId().equals(item.getTaxAgentId())).findFirst();
if (optionalAcctEmp.isPresent()) { if (optionalAcctEmp.isPresent()) {
@ -1137,11 +1162,11 @@ public class AddUpSituationServiceImpl extends Service implements AddUpSituation
ids.add(addUpSituationParam.getId()); ids.add(addUpSituationParam.getId());
AddUpSituationQueryParam build = AddUpSituationQueryParam.builder().ids(ids).build(); AddUpSituationQueryParam build = AddUpSituationQueryParam.builder().ids(ids).build();
List<AddUpSituationRecordDTO> list = biz.recordList(build); List<AddUpSituationRecordDTO> list = biz.recordList(build);
if(list == null || list.size()==0){ if (list == null || list.size() == 0) {
throw new SalaryRunTimeException("该数据不存在!"); throw new SalaryRunTimeException("该数据不存在!");
} }
String taxAgentName = list.get(0).getTaxAgentName(); String taxAgentName = list.get(0).getTaxAgentName();
if(!taxAgentNames.contains(taxAgentName)){ if (!taxAgentNames.contains(taxAgentName)) {
throw new SalaryRunTimeException("您无权查看该数据!"); throw new SalaryRunTimeException("您无权查看该数据!");
} }
return list.get(0); return list.get(0);
@ -1150,10 +1175,182 @@ public class AddUpSituationServiceImpl extends Service implements AddUpSituation
@Override @Override
public void batchSave(List<AddUpSituation> list) { public void batchSave(List<AddUpSituation> list) {
if (CollectionUtils.isNotEmpty(list)) { if (CollectionUtils.isNotEmpty(list)) {
list = encryptUtil.encryptList(list,AddUpSituation.class); list = encryptUtil.encryptList(list, AddUpSituation.class);
List<List<AddUpSituation>> partition = Lists.partition(list, 50); List<List<AddUpSituation>> partition = Lists.partition(list, 50);
partition.forEach(getAddUpSituationMapper()::insertData); partition.forEach(getAddUpSituationMapper()::insertData);
} }
} }
@Override
public Map<String, Object> onlineRequest(AddUpDeductionMonthTaxAgentParam param) {
SalaryAssert.notNull(param.getDeclareMonth(), SalaryI18nUtil.getI18nLabel(100586, "税款所属期必传"));
// 获取接口配置
TaxDeclarationApiConfigPO apiConfig = getTaxDeclarationApiConfigService(user).getConfig(true);
// 获取包装类
AddUpDeductionServiceImpl.AddUpDeductionOnlineRequestWrapper requestWrapper = getAddUpDeductionOnlineRequestWrapper(null, apiConfig);
// 获取报税信息
List<TaxAgentTaxReturnPO> taxReturnPOList = getTaxAgentTaxReturnService(user).getByTaxAgentIds(requestWrapper.getTaxAgentMap().keySet());
List<TaxAgentTaxReturnPO> failReturnPOList = taxReturnPOList.stream().filter(e -> !TaxAgentTaxReturnStatusEnum.SUCCESS.getValue().equals(e.getCheckStatus())).collect(Collectors.toList());
SalaryAssert.isFalse(taxReturnPOList.size() == failReturnPOList.size(), SalaryI18nUtil.getI18nLabel(183781, "企业未通过验证,暂时无法获取累计专项附加扣除数据,请先在【个税扣缴义务人】菜单验证企业报税信息"));
Map<String, Object> result = new HashMap<>(1);
if (!failReturnPOList.isEmpty()) {
String failTaxAgentNames = failReturnPOList.stream().map(e -> requestWrapper.getTaxAgentMap().get(e.getTaxAgentId())).collect(Collectors.joining(""));
result.put("msg", String.format(SalaryI18nUtil.getI18nLabel(183782, "%s未通过登记验证无法在线获取数据"), failTaxAgentNames));
}
// 获取报送成功的人员名单
Map<Long, List<EmployeeDeclarePO>> taxAgentEmpDeclareMap = getEmpDeclareMap(requestWrapper.getTaxAgentMap().keySet(), param.getDeclareMonth());
// 开始请求接口获取数据
getQuerySpecialAmountBodies(param, requestWrapper, taxAgentEmpDeclareMap, taxReturnPOList);
return result;
}
private void getQuerySpecialAmountBodies(AddUpDeductionMonthTaxAgentParam param,
AddUpDeductionServiceImpl.AddUpDeductionOnlineRequestWrapper requestWrapper,
Map<Long, List<EmployeeDeclarePO>> taxAgentEmployeeDeclareMap,
List<TaxAgentTaxReturnPO> taxReturnPOList) {
List<AddUpSituation> updateList = new ArrayList<>();
List<AddUpSituation> insertList = new ArrayList<>();
for (TaxAgentTaxReturnPO returnPO : taxReturnPOList) {
if (!TaxAgentTaxReturnStatusEnum.SUCCESS.getValue().equals(returnPO.getCheckStatus())) {
continue;
}
// 发起请求
String taxAgentName = requestWrapper.getTaxAgentMap().get(returnPO.getTaxAgentId());
List<EmployeeDeclarePO> declarePOList = taxAgentEmployeeDeclareMap.getOrDefault(returnPO.getTaxAgentId(), new ArrayList<>());
if (declarePOList.isEmpty()) {
log.info("该主体下没有报送成功的人员,主体名称:{}", taxAgentName);
continue;
}
List<AddUpSituation> poList = getAddUpSituationMapper().listSome((AddUpSituation.builder().taxYearMonth(param.getDeclareMonth()).taxAgentId(returnPO.getTaxAgentId()).build()));
Map<String, AddUpSituation> poMap = SalaryEntityUtil.convert2Map(poList, e -> e.getTaxAgentId() + "-" + e.getEmployeeId());
// 内部员工身份证信息
List<Long> employeeIds = SalaryEntityUtil.properties(requestWrapper.getSalaryArchiveList(), SalaryArchivePO::getEmployeeId, Collectors.toList());
List<DataCollectionEmployee> simpleUserInfos = getSalaryEmployeeService(user).listByIds(employeeIds);
Map<String, DataCollectionEmployee> simpleUserInfoMap = SalaryEntityUtil.convert2Map(simpleUserInfos, DataCollectionEmployee::getIdNo);
for (int i = 1; true; i++) {
GetCompanyIncomesResponse queryResponse = getCompanyIncomes(returnPO, taxAgentName, param, requestWrapper.getApiConfig(), i);
// 校验请求结果
String responseCode = Optional.ofNullable(queryResponse)
.map(GetCompanyIncomesResponse::getHead)
.map(SzyhResponseHead::getCode)
.orElse(null);
List<GetCompanyIncomesResponse.Detail> details = Optional.ofNullable(queryResponse)
.map(GetCompanyIncomesResponse::getBody)
.map(GetCompanyIncomesResponse.Body::getSfmx)
.orElse(null);
if (!SzyhApiConstant.SUCCESS_CODE.equals(responseCode)) {
log.info("getCompanyIncomes error{}", JSON.toJSONString(queryResponse));
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(95828, "服务异常,请稍后重试"));
}
if (CollectionUtils.isEmpty(details)) {
break;
}
Date now = new Date();
for (GetCompanyIncomesResponse.Detail detail : details) {
DataCollectionEmployee simpleUserInfo = simpleUserInfoMap.get(detail.getZjhm());
Long employeeId = Optional.ofNullable(simpleUserInfo)
.map(DataCollectionEmployee::getEmployeeId)
.orElse(0L);
if (poMap.containsKey(returnPO.getTaxAgentId() + "-" + employeeId)) {
AddUpSituation po = poMap.get(returnPO.getTaxAgentId() + "-" + employeeId);
po.setUpdateTime(now);
po.setActualAddUpAdvanceTax(detail.getKjse());
po.setTaxAdjustment(SalaryEntityUtil.string2BigDecimalDefault0(detail.getKjse()).subtract(SalaryEntityUtil.string2BigDecimalDefault0(po.getAddUpAdvanceTax())).toString());
updateList.add(po);
} else {
AddUpSituation po = new AddUpSituation();
// po.setId(IdGenerator.generate());
po.setCreateTime(now);
po.setUpdateTime(now);
po.setCreator(requestWrapper.getCurrentEmployeeId());
po.setDeleteType(NumberUtils.INTEGER_ZERO);
po.setTenantKey(requestWrapper.getTenantKey());
po.setYear(param.getDeclareMonth().getYear());
po.setTaxYearMonth(param.getDeclareMonth());
po.setEmployeeType(0);
po.setTaxAgentId(returnPO.getTaxAgentId());
po.setEmployeeId(employeeId);
po.setAddUpIncome("0");
po.setAddUpSubtraction("0");
po.setAddUpSocialSecurityTotal("0");
po.setAddUpAccumulationFundTotal("0");
po.setAddUpEnterpriseAndOther("0");
po.setAddUpOtherDeduction("0");
po.setAddUpTaxExemptIncome("0");
po.setAddUpAllowedDonation("0");
po.setAddUpTaxSavings("0");
po.setAddUpAdvanceTax("0");
po.setAddUpTaxableIncome("0");
po.setActualAddUpAdvanceTax(detail.getKjse());
po.setTaxAdjustment(detail.getKjse());
insertList.add(po);
}
}
}
}
if (!insertList.isEmpty()) {
List<List<AddUpSituation>> insertPartition = Lists.partition(insertList, 50);
insertPartition.forEach(list -> {
list = encryptUtil.encryptList(list, AddUpSituation.class);
getAddUpSituationMapper().insertData(list);
});
}
if (!updateList.isEmpty()) {
List<List<AddUpSituation>> updatePartition = Lists.partition(updateList, 50);
updatePartition.forEach(list -> {
list = encryptUtil.encryptList(list, AddUpSituation.class);
getAddUpSituationMapper().updateData(list);
});
}
}
private GetCompanyIncomesResponse getCompanyIncomes(TaxAgentTaxReturnPO returnPO,
String taxAgentName,
AddUpDeductionMonthTaxAgentParam param,
TaxDeclarationApiConfigPO apiConfig,
Integer pageNo) {
String url = apiConfig.getHost() + SzyhApiConstant.GET_COMPANY_INCOMES;
Map<String, Object> requestParam = DataCollectionBO.getApiBaseQueryParams(returnPO, taxAgentName, SalaryDateUtil.getFormatYYYYMM(param.getDeclareMonth()));
requestParam.put("pageSize", 1000);
requestParam.put("pageNo", pageNo);
requestParam.put("reportType", 1);
String reqJson = JsonUtil.toJsonString(requestParam);
log.info("getCompanyIncomes params --- \n{}\n", reqJson);
Map<String, String> params = new HashMap<>(1);
Map<String, String> header = SingnatureData.initHeader(params, apiConfig.getAppKey(), apiConfig.getAppSecret());
// 开始请求
String res = HttpUtil.doPost(url, header, reqJson, HttpUtil.JSON_TYPE);
log.info("getCompanyIncomes res --- {}", res);
return JsonUtil.parseObject(res, GetCompanyIncomesResponse.class);
}
private AddUpDeductionServiceImpl.AddUpDeductionOnlineRequestWrapper getAddUpDeductionOnlineRequestWrapper(List<AddUpDeductionRequestPO> requestPOList, TaxDeclarationApiConfigPO apiConfig) {
boolean isOpenDevolution = getTaxAgentService(user).isOpenDevolution();
boolean isChief = getTaxAgentService(user).isChief((long) user.getUID());
List<TaxAgentPO> taxAgents = !isOpenDevolution || isChief ? getTaxAgentService(user).listAll() : (List<TaxAgentPO>) getTaxAgentService(user).listAllTaxAgentsAsAdmin((long) user.getUID());
Set<Long> taxAgentIdSet = SalaryEntityUtil.properties(taxAgents, TaxAgentPO::getId);
// 获取薪资档案
List<SalaryArchivePO> salaryArchiveList = getSalaryArchiveService(user).listByRunStatus(Arrays.asList(
SalaryArchiveStatusEnum.FIXED.getValue(),
SalaryArchiveStatusEnum.SUSPEND.getValue(),
SalaryArchiveStatusEnum.STOP_FROM_SUSPEND.getValue(),
SalaryArchiveStatusEnum.STOP_FROM_PENDING.getValue()));
salaryArchiveList = salaryArchiveList.stream().filter(e -> taxAgentIdSet.contains(e.getTaxAgentId())).collect(Collectors.toList());
AddUpDeductionServiceImpl.AddUpDeductionOnlineRequestWrapper requestWrapper = new AddUpDeductionServiceImpl.AddUpDeductionOnlineRequestWrapper(requestPOList, salaryArchiveList, taxAgents, (long) user.getUID());
requestWrapper.setApiConfig(apiConfig);
return requestWrapper;
}
private Map<Long, List<EmployeeDeclarePO>> getEmpDeclareMap(Collection<Long> taxAgentIds, Date declareMonth) {
List<EmployeeDeclarePO> employeeDeclarePOS = getEmployeeDeclarePOList(taxAgentIds, declareMonth);
SalaryAssert.notEmpty(employeeDeclarePOS, SalaryI18nUtil.getI18nLabel(183783, "暂无人员报送状态为正常的数据,请先报送再获取累计专项附加扣除数据。"));
return employeeDeclarePOS.stream().collect(Collectors.groupingBy(EmployeeDeclarePO::getTaxAgentId));
}
private List<EmployeeDeclarePO> getEmployeeDeclarePOList(Collection<Long> taxAgentIds, Date declareMonth) {
return getEmployeeDeclareMapper().listSome(EmployeeDeclarePO.builder().declareStatus(DeclareStatusEnum.DECLARE_SUCCESS.getValue()).taxCycle(declareMonth).taxAgentIds(taxAgentIds).build());
}
} }

View File

@ -24,10 +24,7 @@ import weaver.hrm.User;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.GET; import javax.ws.rs.*;
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.Context;
import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response; import javax.ws.rs.core.Response;
@ -419,19 +416,41 @@ public class AddUpDeductionController {
return new ResponseResult<AddUpDeductionRequestFailQueryParam, PageInfo<AddUpDeductionRequestFailListDTO>>(user).run(getAddUpDeductionWrapper(user)::onlineFeedbackFail, queryParam); return new ResponseResult<AddUpDeductionRequestFailQueryParam, PageInfo<AddUpDeductionRequestFailListDTO>>(user).run(getAddUpDeductionWrapper(user)::onlineFeedbackFail, queryParam);
} }
// /** /**
// * 在线获取结果导出 * 在线获取结果导出
// * *
// * @return WeaResult 接口返回信息 * @return WeaResult 接口返回信息
// */ */
// @Path("/online/feedback/fail/export") @GET
// @GET @Path("/online/feedback/fail/export")
// @Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_OCTET_STREAM)
// public String exportOnlineFeedbackFail(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestParam Long requestId) { public Response exportOnlineFeedbackFail(@Context HttpServletRequest request, @Context HttpServletResponse response, @QueryParam(value = "requestId") Long requestId) {
// User user = HrmUserVarify.getUser(request, response); try {
// return new ResponseResult<AddUpDeductionRequestFailQueryParam, PageInfo<AddUpDeductionRequestFailListDTO>>(user).run(getAddUpDeductionWrapper(user)::exportOnlineFeedbackFail, queryParam); User user = HrmUserVarify.getUser(request, response);
// return WeaResult.success(addUpDeductionWrapper.exportOnlineFeedbackFail(UserContext.getCurrentEmployeeId(), TenantContext.getCurrentTenantKey(), requestId));
// }
XSSFWorkbook workbook = getAddUpDeductionWrapper(user).exportOnlineFeedbackFail(requestId);
String fileName = "在线获取专项附加扣除失败数据" + LocalDate.now();
try {
fileName = URLEncoder.encode(fileName + ".xlsx", "UTF-8");
} catch (UnsupportedEncodingException e) {
log.error(e.getMessage(), e);
}
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

@ -354,4 +354,17 @@ public class AddUpSituationController {
} }
/**
* 在线获取实际累计已预扣预缴税额
*
* @param param 前端请求参数
* @return WeaResult 接口返回信息
*/
@POST
@Path("/online/actualAddUpAdvanceTax")
@Produces(MediaType.APPLICATION_JSON)
public String onlineRequest(@Context HttpServletRequest request, @Context HttpServletResponse response,@RequestBody AddUpDeductionMonthTaxAgentParam param) {
User user = HrmUserVarify.getUser(request, response);
return new ResponseResult<AddUpDeductionMonthTaxAgentParam, Map<String, Object>>(user).run(getAddUpSituationWrapper(user)::onlineRequest, param);
}
} }

View File

@ -8,6 +8,7 @@ import com.engine.salary.entity.datacollection.dto.AddUpDeductionRecordDTO;
import com.engine.salary.entity.datacollection.dto.AddUpDeductionRequestFailListDTO; import com.engine.salary.entity.datacollection.dto.AddUpDeductionRequestFailListDTO;
import com.engine.salary.entity.datacollection.dto.AddUpDeductionRequestResultDTO; import com.engine.salary.entity.datacollection.dto.AddUpDeductionRequestResultDTO;
import com.engine.salary.entity.datacollection.param.*; import com.engine.salary.entity.datacollection.param.*;
import com.engine.salary.entity.datacollection.po.AddUpDeductionRequestFailPO;
import com.engine.salary.exception.SalaryRunTimeException; import com.engine.salary.exception.SalaryRunTimeException;
import com.engine.salary.service.AddUpDeductionService; import com.engine.salary.service.AddUpDeductionService;
import com.engine.salary.service.SalaryEmployeeService; import com.engine.salary.service.SalaryEmployeeService;
@ -187,37 +188,22 @@ public class AddUpDeductionWrapper extends Service {
return getAddUpDeductionService(user).onlineFeedback(); return getAddUpDeductionService(user).onlineFeedback();
} }
public PageInfo<AddUpDeductionRequestFailListDTO> onlineFeedbackFail( AddUpDeductionRequestFailQueryParam queryParam) { public PageInfo<AddUpDeductionRequestFailListDTO> onlineFeedbackFail(AddUpDeductionRequestFailQueryParam queryParam) {
if (queryParam.getRequestId() == null) { if (queryParam.getRequestId() == null) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(153345, "在线获取的请求ID不可为空")); throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(153345, "在线获取的请求ID不可为空"));
} }
PageInfo<AddUpDeductionRequestFailListDTO> page = getAddUpDeductionService(user).onlineFeedbackFail( queryParam); PageInfo<AddUpDeductionRequestFailListDTO> page = getAddUpDeductionService(user).onlineFeedbackFail(queryParam);
return page; return page;
} }
// public Map<String, Object> exportOnlineFeedbackFail( Long requestId) { public XSSFWorkbook exportOnlineFeedbackFail(Long requestId) {
// List<AddUpDeductionRequestFailPO> poList = getAddUpDeductionService(user).getAddUpDeductionRequestFailPOList(requestId); List<AddUpDeductionRequestFailPO> poList = getAddUpDeductionService(user).getAddUpDeductionRequestFailPOList(requestId);
// if (CollectionUtils.isEmpty(poList)) { if (CollectionUtils.isEmpty(poList)) {
// throw new SalaryRunTimeException(String.format(SalaryI18nUtil.getI18nLabel( 95795, "数据不存在") + "[id:%s]", requestId)); throw new SalaryRunTimeException(String.format(SalaryI18nUtil.getI18nLabel(95795, "数据不存在") + "[id:%s]", requestId));
// } }
// // 构建异步导出参数 return getAddUpDeductionService(user).exportOnlineFeedbackFail(requestId);
// Map<String, Object> map = salaryBatchService.buildeExportParam("exportOnlineFeedbackFail"); }
// map.put("sheetName", SalaryI18nUtil.getI18nLabel( 183778, "在线获取专项附加扣除失败数据"));
// LocalRunnable localRunnable = new LocalRunnable() {
// @Override
// public void execute() {
// try {
// DSTenantKeyThreadVar.tenantKey.set(tenantKey);
// getAddUpDeductionService(user).exportOnlineFeedbackFail(map, requestId);
// } finally {
// DSTenantKeyThreadVar.tenantKey.remove();
// }
// }
// };
// ThreadPoolUtil.execute(localRunnable);
// return map;
// }
//
// public WeaForm getRequestForm() { // public WeaForm getRequestForm() {
// WeaForm weaForm = SalaryFormatUtil.<AddUpDeductionRequestFormDTO>getInstance().buildForm(AddUpDeductionRequestFormDTO.class, new AddUpDeductionRequestFormDTO()); // WeaForm weaForm = SalaryFormatUtil.<AddUpDeductionRequestFormDTO>getInstance().buildForm(AddUpDeductionRequestFormDTO.class, new AddUpDeductionRequestFormDTO());
// WeaFormSalaryItem item = new WeaFormSalaryItem(WeaFormItemType.DATEPICKER, "month", "YYYY-MM", "YYYY-MM"); // WeaFormSalaryItem item = new WeaFormSalaryItem(WeaFormItemType.DATEPICKER, "month", "YYYY-MM", "YYYY-MM");

View File

@ -5,10 +5,7 @@ import com.engine.core.impl.Service;
import com.engine.salary.entity.datacollection.AddUpSituation; import com.engine.salary.entity.datacollection.AddUpSituation;
import com.engine.salary.entity.datacollection.dto.AddUpSituationDTO; import com.engine.salary.entity.datacollection.dto.AddUpSituationDTO;
import com.engine.salary.entity.datacollection.dto.AddUpSituationRecordDTO; import com.engine.salary.entity.datacollection.dto.AddUpSituationRecordDTO;
import com.engine.salary.entity.datacollection.param.AddUpSituationDeleteParam; import com.engine.salary.entity.datacollection.param.*;
import com.engine.salary.entity.datacollection.param.AddUpSituationImportParam;
import com.engine.salary.entity.datacollection.param.AddUpSituationParam;
import com.engine.salary.entity.datacollection.param.AddUpSituationQueryParam;
import com.engine.salary.exception.SalaryRunTimeException; import com.engine.salary.exception.SalaryRunTimeException;
import com.engine.salary.service.AddUpSituationService; import com.engine.salary.service.AddUpSituationService;
import com.engine.salary.service.impl.AddUpSituationServiceImpl; import com.engine.salary.service.impl.AddUpSituationServiceImpl;
@ -169,4 +166,8 @@ public class AddUpSituationWrapper extends Service {
public AddUpSituationRecordDTO getAddUpSituation(AddUpSituationParam addUpSituationParam) { public AddUpSituationRecordDTO getAddUpSituation(AddUpSituationParam addUpSituationParam) {
return getAddUpSituationService(user).getAddUpSituation(addUpSituationParam); return getAddUpSituationService(user).getAddUpSituation(addUpSituationParam);
} }
public Map<String, Object> onlineRequest(AddUpDeductionMonthTaxAgentParam param) {
return getAddUpSituationService(user).onlineRequest(param);
}
} }