Merge branch 'feature/申报表' into release

# Conflicts:
#	resource/sql/申报表.sql
This commit is contained in:
钱涛 2022-06-10 14:40:14 +08:00
commit f1fac5ae90
20 changed files with 483 additions and 767 deletions

View File

@ -1,66 +0,0 @@
package com.engine.salary.entity.taxdeclaration;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Date;
/**
* 个税申报表
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class TaxDeclaration {
/**
* 创建时间
*/
private Date createTime;
/**
* 创建人
*/
private Long creator;
/**
* 是否已删除0未删除1已删除
*/
private Integer deleteType;
/**
* 备注
*/
private String description;
/**
* 主键id
*/
private Long id;
/**
* 薪资所属月
*/
@JsonFormat(pattern = "yyyy-MM", timezone = "GMT+8")
private Date salaryMonth;
/**
* 个税扣缴义务人id
*/
private Long taxAgentId;
/**
* 税款所属期
*/
private Date taxCycle;
/**
* 租户ID
*/
private String tenantKey;
/**
* 更新时间
*/
private Date updateTime;
/**
* 应税项目1:正常工资薪金所得
*/
private Integer incomeCategory;
}

View File

@ -1,59 +0,0 @@
package com.engine.salary.entity.taxdeclaration;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Date;
/**
* 个税申报表详情
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class TaxDeclarationDetail {
/**
* 创建时间
*/
private Date createTime;
/**
* 创建人
*/
private Long creator;
/**
* 是否已删除0未删除1已删除
*/
private Integer deleteType;
/**
* 人员id
*/
private Long employeeId;
/**
* 字段code
*/
private String fieldCode;
/**
* 字段的值
*/
private String fieldValue;
/**
* 主键id
*/
private Long id;
/**
* 个税申报记录的id
*/
private Long taxDeclarationId;
/**
* 租户ID
*/
private String tenantKey;
/**
* 更新时间
*/
private Date updateTime;
}

View File

@ -630,7 +630,7 @@ public class TaxDeclarationBO {
TaxDeclarationDetailPO taxDeclarationDetailPO = TaxDeclarationDetailPO.builder()
.id(IdGenerator.generate())
.taxDeclarationId(taxDeclaration.getId())
// .employeeType(employeeType)
.employeeType(employeeType)
.employeeId(employeeId)
.fieldCode(fieldCode)
.fieldValue(fieldValue)

View File

@ -15,12 +15,13 @@ import org.apache.commons.lang3.StringUtils;
import java.util.*;
/**
* @description: 个税申报表详情
* @author: xiajun
* @modified By: xiajun
* @date: 2022/3/14 18:31
* @version:v1.0
*/
* 个税申报表详情
* <p>Copyright: Copyright (c) 2022</p>
* <p>Company: 泛微软件</p>
*
* @author qiantao
* @version 1.0
**/
public class TaxDeclarationDetailBO {
/**
@ -43,28 +44,28 @@ public class TaxDeclarationDetailBO {
for (TaxDeclarationEmployeeDTO dto : taxDeclarationEmployeeDTOS) {
Map<String, String> fieldCodeKeyFieldValueMap = SalaryEntityUtil.convert2Map(employeeIdKeyTaxDeclarationDetailPOMap.get(dto.getEmployeeType() + "_" + dto.getEmployeeId()),
TaxDeclarationDetailPO::getFieldCode, TaxDeclarationDetailPO::getFieldValue);
TaxDeclarationWageListDTO taxDeclarationWageListDTO = new TaxDeclarationWageListDTO()
.setCardType(SalaryI18nUtil.getI18nLabel(105564, "居民身份证"))
.setIncome(fieldCodeKeyFieldValueMap.get(TaxDeclarationDataIndexConstant.INCOME))
.setTaxFreeIncome(fieldCodeKeyFieldValueMap.get(TaxDeclarationDataIndexConstant.TAX_FREE_INCOME))
.setEndowmentInsurance(fieldCodeKeyFieldValueMap.get(TaxDeclarationDataIndexConstant.ENDOWMENT_INSURANCE))
.setMedicalInsurance(fieldCodeKeyFieldValueMap.get(TaxDeclarationDataIndexConstant.MEDICAL_INSURANCE))
.setUnemploymentInsurance(fieldCodeKeyFieldValueMap.get(TaxDeclarationDataIndexConstant.UNEMPLOYMENT_INSURANCE))
.setHousingProvidentFund(fieldCodeKeyFieldValueMap.get(TaxDeclarationDataIndexConstant.HOUSING_PROVIDENT_FUND))
.setAddUpChildEducation(fieldCodeKeyFieldValueMap.get(TaxDeclarationDataIndexConstant.ADD_UP_CHILD_EDUCATION))
.setAddUpHousingLoanInterest(fieldCodeKeyFieldValueMap.get(TaxDeclarationDataIndexConstant.ADD_UP_HOUSING_LOAN_INTEREST))
.setAddUpHousingRent(fieldCodeKeyFieldValueMap.get(TaxDeclarationDataIndexConstant.ADD_UP_HOUSING_RENT))
.setAddUpContinuingEducation(fieldCodeKeyFieldValueMap.get(TaxDeclarationDataIndexConstant.ADD_UP_CONTINUING_EDUCATION))
.setAddUpSupportElderly(fieldCodeKeyFieldValueMap.get(TaxDeclarationDataIndexConstant.ADD_UP_SUPPORT_ELDERLY))
.setAddUpIllnessMedical(fieldCodeKeyFieldValueMap.get(TaxDeclarationDataIndexConstant.ADD_UP_ILLNESS_MEDICAL))
.setAddUpInfantCare(fieldCodeKeyFieldValueMap.get(TaxDeclarationDataIndexConstant.ADD_UP_INFANT_CARE))
.setAnnuity(fieldCodeKeyFieldValueMap.get(TaxDeclarationDataIndexConstant.ANNUITY))
.setCommercialHealthInsurance(fieldCodeKeyFieldValueMap.get(TaxDeclarationDataIndexConstant.COMMERCIAL_HEALTH_INSURANCE))
.setTaxDeferredEndowmentInsurance(fieldCodeKeyFieldValueMap.get(TaxDeclarationDataIndexConstant.TAX_DEFERRED_ENDOWMENT_INSURANCE))
.setOther(fieldCodeKeyFieldValueMap.get(TaxDeclarationDataIndexConstant.OTHER))
.setAllowedDonation(fieldCodeKeyFieldValueMap.get(TaxDeclarationDataIndexConstant.ALLOWED_DONATION))
.setTaxDeduction(fieldCodeKeyFieldValueMap.get(TaxDeclarationDataIndexConstant.TAX_DEDUCTION))
.setDescription(fieldCodeKeyFieldValueMap.get(TaxDeclarationDataIndexConstant.DESCRIPTION));
TaxDeclarationWageListDTO taxDeclarationWageListDTO = TaxDeclarationWageListDTO.builder()
.cardType(SalaryI18nUtil.getI18nLabel(105564, "居民身份证"))
.income(fieldCodeKeyFieldValueMap.get(TaxDeclarationDataIndexConstant.INCOME))
.taxFreeIncome(fieldCodeKeyFieldValueMap.get(TaxDeclarationDataIndexConstant.TAX_FREE_INCOME))
.endowmentInsurance(fieldCodeKeyFieldValueMap.get(TaxDeclarationDataIndexConstant.ENDOWMENT_INSURANCE))
.medicalInsurance(fieldCodeKeyFieldValueMap.get(TaxDeclarationDataIndexConstant.MEDICAL_INSURANCE))
.unemploymentInsurance(fieldCodeKeyFieldValueMap.get(TaxDeclarationDataIndexConstant.UNEMPLOYMENT_INSURANCE))
.housingProvidentFund(fieldCodeKeyFieldValueMap.get(TaxDeclarationDataIndexConstant.HOUSING_PROVIDENT_FUND))
.addUpChildEducation(fieldCodeKeyFieldValueMap.get(TaxDeclarationDataIndexConstant.ADD_UP_CHILD_EDUCATION))
.addUpHousingLoanInterest(fieldCodeKeyFieldValueMap.get(TaxDeclarationDataIndexConstant.ADD_UP_HOUSING_LOAN_INTEREST))
.addUpHousingRent(fieldCodeKeyFieldValueMap.get(TaxDeclarationDataIndexConstant.ADD_UP_HOUSING_RENT))
.addUpContinuingEducation(fieldCodeKeyFieldValueMap.get(TaxDeclarationDataIndexConstant.ADD_UP_CONTINUING_EDUCATION))
.addUpSupportElderly(fieldCodeKeyFieldValueMap.get(TaxDeclarationDataIndexConstant.ADD_UP_SUPPORT_ELDERLY))
.addUpIllnessMedical(fieldCodeKeyFieldValueMap.get(TaxDeclarationDataIndexConstant.ADD_UP_ILLNESS_MEDICAL))
.addUpInfantCare(fieldCodeKeyFieldValueMap.get(TaxDeclarationDataIndexConstant.ADD_UP_INFANT_CARE))
.annuity(fieldCodeKeyFieldValueMap.get(TaxDeclarationDataIndexConstant.ANNUITY))
.commercialHealthInsurance(fieldCodeKeyFieldValueMap.get(TaxDeclarationDataIndexConstant.COMMERCIAL_HEALTH_INSURANCE))
.taxDeferredEndowmentInsurance(fieldCodeKeyFieldValueMap.get(TaxDeclarationDataIndexConstant.TAX_DEFERRED_ENDOWMENT_INSURANCE))
.other(fieldCodeKeyFieldValueMap.get(TaxDeclarationDataIndexConstant.OTHER))
.allowedDonation(fieldCodeKeyFieldValueMap.get(TaxDeclarationDataIndexConstant.ALLOWED_DONATION))
.taxDeduction(fieldCodeKeyFieldValueMap.get(TaxDeclarationDataIndexConstant.TAX_DEDUCTION))
.description(fieldCodeKeyFieldValueMap.get(TaxDeclarationDataIndexConstant.DESCRIPTION)).build();
if (dto.getEmployeeType() == null || Objects.equals(dto.getEmployeeType(), EmployeeTypeEnum.ORGANIZATION.getValue())) {
DataCollectionEmployee simpleEmployee = simpleEmployeeMap.get(dto.getEmployeeId());
taxDeclarationWageListDTO.setId(simpleEmployee.getEmployeeId())

View File

@ -1,6 +1,13 @@
package com.engine.salary.entity.taxdeclaration.dto;
import com.cloudstore.eccom.pc.table.WeaTableType;
import com.engine.salary.annotation.SalaryTable;
import com.engine.salary.annotation.SalaryTableColumn;
import com.engine.salary.annotation.TableTitle;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
/**
@ -12,84 +19,113 @@ import lombok.experimental.Accessors;
* @version 1.0
**/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = true)
@SalaryTable(pageId = "a4f85287-e3f9-6612-adn9-7d34564y6rj8", tableType = WeaTableType.CHECKBOX)
public class TaxDeclarationWageListDTO {
//主键id")
//主键id
private Long id;
//人员id")
//人员id
private Long employeeId;
//"工号")
@SalaryTableColumn(text = "工号", width = "10%", column = "jobNum")
@TableTitle(title = "工号", dataIndex = "jobNum", key = "jobNum")
private String jobNum;
//"姓名")
@SalaryTableColumn(text = "姓名", width = "10%", column = "username")
@TableTitle(title = "工号", dataIndex = "jobNum", key = "jobNum")
private String username;
//证件类型")
@SalaryTableColumn(text = "证件类型", width = "10%", column = "cardType")
@TableTitle(title = "工号", dataIndex = "jobNum", key = "jobNum")
private String cardType;
//证件号码")
@SalaryTableColumn(text = "证件号码", width = "10%", column = "cardNum")
private String cardNum;
//本期收入")
@SalaryTableColumn(text = "本期收入", width = "10%", column = "income")
@TableTitle(title = "本期收入", dataIndex = "income", key = "income")
private String income;
//本期免税收入")
@SalaryTableColumn(text = "本期免税收入", width = "10%", column = "taxFreeIncome")
@TableTitle(title = "本期免税收入", dataIndex = "taxFreeIncome", key = "taxFreeIncome")
private String taxFreeIncome;
//"基本养老保险费")
@SalaryTableColumn(text = "基本养老保险费", width = "10%", column = "endowmentInsurance")
@TableTitle(title = "基本养老保险费", dataIndex = "endowmentInsurance", key = "endowmentInsurance")
private String endowmentInsurance;
//"基本医疗保险费")
@SalaryTableColumn(text = "基本医疗保险费", width = "10%", column = "medicalInsurance")
@TableTitle(title = "基本医疗保险费", dataIndex = "medicalInsurance", key = "medicalInsurance")
private String medicalInsurance;
//失业保险费")
@SalaryTableColumn(text = "失业保险费", width = "10%", column = "unemploymentInsurance")
@TableTitle(title = "失业保险费", dataIndex = "unemploymentInsurance", key = "unemploymentInsurance")
private String unemploymentInsurance;
//住房公积金")
@SalaryTableColumn(text = "住房公积金", width = "10%", column = "housingProvidentFund")
@TableTitle(title = "住房公积金", dataIndex = "housingProvidentFund", key = "housingProvidentFund")
private String housingProvidentFund;
//"累计子女教育")
@SalaryTableColumn(text = "累计子女教育", width = "10%", column = "addUpChildEducation")
@TableTitle(title = "累计子女教育", dataIndex = "addUpChildEducation", key = "addUpChildEducation")
private String addUpChildEducation;
//累计住房贷款利息")
@SalaryTableColumn(text = "累计住房贷款利息", width = "10%", column = "addUpHousingLoanInterest")
@TableTitle(title = "累计住房贷款利息", dataIndex = "addUpHousingLoanInterest", key = "addUpHousingLoanInterest")
private String addUpHousingLoanInterest;
//"累计住房租金")
@SalaryTableColumn(text = "累计住房租金", width = "10%", column = "addUpHousingRent")
@TableTitle(title = "累计住房租金", dataIndex = "addUpHousingRent", key = "addUpHousingRent")
private String addUpHousingRent;
//累计继续教育")
@SalaryTableColumn(text = "累计继续教育", width = "10%", column = "addUpContinuingEducation")
@TableTitle(title = "累计继续教育", dataIndex = "addUpContinuingEducation", key = "addUpContinuingEducation")
private String addUpContinuingEducation;
//"累计赡养老人")
@SalaryTableColumn(text = "累计赡养老人", width = "10%", column = "addUpSupportElderly")
@TableTitle(title = "累计赡养老人", dataIndex = "addUpSupportElderly", key = "addUpSupportElderly")
private String addUpSupportElderly;
//"累计大病医疗")
@SalaryTableColumn(text = "累计大病医疗", width = "10%", column = "addUpIllnessMedical")
@TableTitle(title = "累计大病医疗", dataIndex = "addUpIllnessMedical", key = "addUpIllnessMedical")
private String addUpIllnessMedical;
//累计婴幼儿照护")
@SalaryTableColumn(text = "累计婴幼儿照护", width = "10%", column = "addUpInfantCare")
@TableTitle(title = "累计婴幼儿照护", dataIndex = "addUpInfantCare", key = "addUpInfantCare")
private String addUpInfantCare;
//"企业(职业)年金")
@SalaryTableColumn(text = "企业(职业)年金", width = "10%", column = "annuity")
@TableTitle(title = "企业(职业)年金", dataIndex = "annuity", key = "annuity")
private String annuity;
//商业健康保险")
@SalaryTableColumn(text = "商业健康保险", width = "10%", column = "commercialHealthInsurance")
@TableTitle(title = "商业健康保险", dataIndex = "commercialHealthInsurance", key = "commercialHealthInsurance")
private String commercialHealthInsurance;
//"税延养老保险")
@SalaryTableColumn(text = "税延养老保险", width = "10%", column = "taxDeferredEndowmentInsurance")
@TableTitle(title = "税延养老保险", dataIndex = "taxDeferredEndowmentInsurance", key = "taxDeferredEndowmentInsurance")
private String taxDeferredEndowmentInsurance;
//"其他")
@SalaryTableColumn(text = "其他", width = "10%", column = "other")
@TableTitle(title = "其他", dataIndex = "other", key = "other")
private String other;
//"准允扣除的捐赠额")
@SalaryTableColumn(text = "准予扣除的捐赠额", width = "10%", column = "allowedDonation")
@TableTitle(title = "准予扣除的捐赠额", dataIndex = "allowedDonation", key = "allowedDonation")
private String allowedDonation;
//"减免税额")
@SalaryTableColumn(text = "减免税额", width = "10%", column = "taxDeduction")
@TableTitle(title = "减免税额", dataIndex = "taxDeduction", key = "taxDeduction")
private String taxDeduction;
//"备注")
@SalaryTableColumn(text = "备注", width = "10%", column = "description")
@TableTitle(title = "备注", dataIndex = "description", key = "description")
private String description;
}

View File

@ -37,6 +37,11 @@ public class TaxDeclarationDetailPO {
*/
private Long employeeId;
/**
* 人员类型
*/
private Integer employeeType;
/**
* 申报表字段code
*/
@ -73,8 +78,11 @@ public class TaxDeclarationDetailPO {
*/
private Date updateTime;
/**
* 应税项目1:正常工资薪金所得
*/
private Integer incomeCategory;
// /**
// * 应税项目1:正常工资薪金所得
// */
// private Integer incomeCategory;
}

View File

@ -15,6 +15,7 @@
<select id="getEmployeeByIds" resultType="com.engine.salary.entity.datacollection.DataCollectionEmployee">
select e.id as employeeId,
e.lastname as username,
e.certificatenum as idNo,
e.status as status,
e.workcode as workcode,
e.companystartdate as companystartdate,

View File

@ -1,6 +1,6 @@
package com.engine.salary.mapper.taxdeclaration;
import com.engine.salary.entity.taxdeclaration.TaxDeclarationDetail;
import com.engine.salary.entity.taxdeclaration.dto.TaxDeclarationEmployeeDTO;
import com.engine.salary.entity.taxdeclaration.po.TaxDeclarationDetailPO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@ -11,61 +11,23 @@ import java.util.List;
@Mapper
public interface TaxDeclarationDetailMapper {
/**
* 查询所有记录
*
* @return 返回集合没有返回空List
*/
List<TaxDeclarationDetail> listAll();
/**
* 根据主键查询
*
* @param id 主键
* @return 返回记录没有返回null
*/
TaxDeclarationDetail getById(Long id);
* 分页查询人员id
*
* @param taxDeclarationId
* @return
*/
List<TaxDeclarationEmployeeDTO> listPage4EmployeeId(@Param("taxDeclarationId") Long taxDeclarationId);
/**
* 新增插入所有字段
*
* @param taxDeclarationDetail 新增的记录
* @return 返回影响行数
*/
int insert(TaxDeclarationDetail taxDeclarationDetail);
/**
* 新增忽略null字段
*
* @param taxDeclarationDetail 新增的记录
* @return 返回影响行数
*/
int insertIgnoreNull(TaxDeclarationDetail taxDeclarationDetail);
/**
* 修改修改所有字段
*
* @param taxDeclarationDetail 修改的记录
* @return 返回影响行数
*/
int update(TaxDeclarationDetail taxDeclarationDetail);
/**
* 修改忽略null字段
*
* @param taxDeclarationDetail 修改的记录
* @return 返回影响行数
*/
int updateIgnoreNull(TaxDeclarationDetail taxDeclarationDetail);
/**
* 删除记录
*
* @param taxDeclarationDetail 待删除的记录
* @return 返回影响行数
*/
int delete(TaxDeclarationDetail taxDeclarationDetail);
* 查询人员id
*
* @param taxDeclarationId
* @return
*/
List<TaxDeclarationEmployeeDTO> list4EmployeeId(@Param("taxDeclarationId") Long taxDeclarationId);
/**
* 批量插入
@ -78,28 +40,25 @@ public interface TaxDeclarationDetailMapper {
* 统计一共多少人员
*
* @param taxDeclarationId
* @param tenantKey
* @return
*/
int countEmployeeId(@Param("taxDeclarationId") Long taxDeclarationId);
/**
* 分页查询人员id
*
* @param page
* @param taxDeclarationId
* @param tenantKey
* @return
*/
List<Long> listEmployeeId(@Param("taxDeclarationId") Long taxDeclarationId);
/**
* 查询个税申报表明细
*
* @param page
* @param taxDeclarationId
* @param employeeIds
* @return
*/
List<TaxDeclarationDetailPO> listByTaxDeclarationIdAndEmployeeIds(@Param("taxDeclarationId") Long taxDeclarationId, @Param("collection") List<Long> employeeIds);
List<TaxDeclarationDetailPO> listByTaxDeclarationIdAndEmployeeIds(@Param("taxDeclarationId") Long taxDeclarationId, @Param("collection") Collection<Long> employeeIds);
/**
* 根据个税申报表id删除

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.engine.salary.mapper.taxdeclaration.TaxDeclarationDetailMapper">
<resultMap id="BaseResultMap" type="com.engine.salary.entity.taxdeclaration.TaxDeclarationDetail">
<resultMap id="BaseResultMap" type="com.engine.salary.entity.taxdeclaration.po.TaxDeclarationDetailPO">
<result column="create_time" property="createTime"/>
<result column="creator" property="creator"/>
<result column="delete_type" property="deleteType"/>
@ -12,6 +12,7 @@
<result column="tax_declaration_id" property="taxDeclarationId"/>
<result column="tenant_key" property="tenantKey"/>
<result column="update_time" property="updateTime"/>
<result column="employee_type" property="employeeType"/>
</resultMap>
<!-- 表字段 -->
@ -28,23 +29,29 @@
, t.tax_declaration_id
, t.tenant_key
, t.update_time
, t.employee_type
</sql>
<!-- 查询全部 -->
<select id="listAll" resultMap="BaseResultMap">
SELECT
<include refid="baseColumns"/>
FROM hrsa_tax_declaration_detail t
<resultMap id="resultMap" type="com.engine.salary.entity.taxdeclaration.dto.TaxDeclarationEmployeeDTO">
<result column="employee_type" property="employeeType"/>
<result column="employee_id" property="employeeId"/>
</resultMap>
<select id="listPage4EmployeeId" resultMap="resultMap">
SELECT DISTINCT employee_type, employee_id
FROM hrsa_tax_declaration_detail
WHERE delete_type = 0
AND tax_declaration_id = #{taxDeclarationId}
</select>
<!-- 根据主键获取单条记录 -->
<select id="getById" resultMap="BaseResultMap" parameterType="Long">
SELECT
<include refid="baseColumns"/>
FROM hrsa_tax_declaration_detail t
WHERE id = #{id} AND delete_type = 0
<select id="list4EmployeeId" resultMap="resultMap">
SELECT DISTINCT employee_type, employee_id
FROM hrsa_tax_declaration_detail
WHERE delete_type = 0
AND tax_declaration_id = #{taxDeclarationId}
</select>
<select id="countEmployeeId" resultType="int">
SELECT count(DISTINCT employee_id)
FROM hrsa_tax_declaration_detail
@ -72,219 +79,11 @@
</if>
</select>
<!-- 插入全部字段 -->
<insert id="insert" parameterType="com.engine.salary.entity.taxdeclaration.TaxDeclarationDetail"
keyProperty="id" keyColumn="id" useGeneratedKeys="true"
>
INSERT INTO hrsa_tax_declaration_detail
<trim prefix="(" suffix=")" suffixOverrides=",">
create_time,
creator,
delete_type,
employee_id,
field_code,
field_value,
id,
tax_declaration_id,
tenant_key,
update_time,
</trim>
<trim prefix="VALUES (" suffix=")" suffixOverrides=",">
#{createTime},
#{creator},
#{deleteType},
#{employeeId},
#{fieldCode},
#{fieldValue},
#{id},
#{taxDeclarationId},
#{tenantKey},
#{updateTime},
</trim>
</insert>
<insert id="insert" parameterType="com.engine.salary.entity.taxdeclaration.TaxDeclarationDetail" databaseId="oracle"
>
<selectKey keyProperty="id" resultType="long" order="AFTER">
select hrsa_tax_declaration_detail_id.currval from dual
</selectKey>
INSERT INTO hrsa_tax_declaration_detail
<trim prefix="(" suffix=")" suffixOverrides=",">
create_time,
creator,
delete_type,
employee_id,
field_code,
field_value,
id,
tax_declaration_id,
tenant_key,
update_time,
</trim>
<trim prefix="VALUES (" suffix=")" suffixOverrides=",">
#{createTime},
#{creator},
#{deleteType},
#{employeeId},
#{fieldCode},
#{fieldValue},
#{id},
#{taxDeclarationId},
#{tenantKey},
#{updateTime},
</trim>
</insert>
<!-- 插入不为NULL的字段 -->
<insert id="insertIgnoreNull" parameterType="com.engine.salary.entity.taxdeclaration.TaxDeclarationDetail"
keyProperty="id" keyColumn="id" useGeneratedKeys="true"
>
INSERT INTO hrsa_tax_declaration_detail
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="createTime != null">
create_time,
</if>
<if test="creator != null">
creator,
</if>
<if test="deleteType != null">
delete_type,
</if>
<if test="employeeId != null">
employee_id,
</if>
<if test="fieldCode != null">
field_code,
</if>
<if test="fieldValue != null">
field_value,
</if>
<if test="id != null">
id,
</if>
<if test="taxDeclarationId != null">
tax_declaration_id,
</if>
<if test="tenantKey != null">
tenant_key,
</if>
<if test="updateTime != null">
update_time,
</if>
</trim>
<trim prefix="VALUES (" suffix=")" suffixOverrides=",">
<if test="createTime != null">
#{createTime},
</if>
<if test="creator != null">
#{creator},
</if>
<if test="deleteType != null">
#{deleteType},
</if>
<if test="employeeId != null">
#{employeeId},
</if>
<if test="fieldCode != null">
#{fieldCode},
</if>
<if test="fieldValue != null">
#{fieldValue},
</if>
<if test="id != null">
#{id},
</if>
<if test="taxDeclarationId != null">
#{taxDeclarationId},
</if>
<if test="tenantKey != null">
#{tenantKey},
</if>
<if test="updateTime != null">
#{updateTime},
</if>
</trim>
</insert>
<insert id="insertIgnoreNull" parameterType="com.engine.salary.entity.taxdeclaration.TaxDeclarationDetail" databaseId="oracle"
>
<selectKey keyProperty="id" resultType="long" order="AFTER">
select hrsa_tax_declaration_detail_id.currval from dual
</selectKey>
INSERT INTO hrsa_tax_declaration_detail
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="createTime != null">
create_time,
</if>
<if test="creator != null">
creator,
</if>
<if test="deleteType != null">
delete_type,
</if>
<if test="employeeId != null">
employee_id,
</if>
<if test="fieldCode != null">
field_code,
</if>
<if test="fieldValue != null">
field_value,
</if>
<if test="id != null">
id,
</if>
<if test="taxDeclarationId != null">
tax_declaration_id,
</if>
<if test="tenantKey != null">
tenant_key,
</if>
<if test="updateTime != null">
update_time,
</if>
</trim>
<trim prefix="VALUES (" suffix=")" suffixOverrides=",">
<if test="createTime != null">
#{createTime},
</if>
<if test="creator != null">
#{creator},
</if>
<if test="deleteType != null">
#{deleteType},
</if>
<if test="employeeId != null">
#{employeeId},
</if>
<if test="fieldCode != null">
#{fieldCode},
</if>
<if test="fieldValue != null">
#{fieldValue},
</if>
<if test="id != null">
#{id},
</if>
<if test="taxDeclarationId != null">
#{taxDeclarationId},
</if>
<if test="tenantKey != null">
#{tenantKey},
</if>
<if test="updateTime != null">
#{updateTime},
</if>
</trim>
</insert>
<insert id="batchInsert">
INSERT INTO hrsa_tax_declaration_detail
(id, tax_declaration_id, employee_id, field_code, field_value, creator,
create_time, update_time, delete_type, tenant_key)
create_time, update_time, delete_type, tenant_key, employee_type)
VALUES
<foreach collection="collection" item="item" separator=",">
(
@ -297,7 +96,8 @@
#{item.createTime},
#{item.updateTime},
#{item.deleteType},
#{item.tenantKey}
#{item.tenantKey},
#{item.employeeType}
)
</foreach>
</insert>
@ -305,7 +105,7 @@
<insert id="batchInsert" databaseId="oracle">
INSERT INTO hrsa_tax_declaration_detail
(id, tax_declaration_id, employee_id, field_code, field_value, creator,
create_time, update_time, delete_type, tenant_key)
create_time, update_time, delete_type, tenant_key, employee_type)
<foreach collection="collection" item="item" separator="union all">
select
@ -318,7 +118,8 @@
#{item.createTime},
#{item.updateTime},
#{item.deleteType},
#{item.tenantKey}
#{item.tenantKey},
#{item.employeeType}
from dual
</foreach>
</insert>
@ -326,7 +127,7 @@
<foreach collection="collection" item="item" separator=";">
INSERT INTO hrsa_tax_declaration_detail
(id,tax_declaration_id, employee_id, field_code, field_value, creator,
create_time, update_time, delete_type, tenant_key)
create_time, update_time, delete_type, tenant_key, employee_type)
VALUES
(
#{item.id},
@ -338,73 +139,12 @@
#{item.createTime},
#{item.updateTime},
#{item.deleteType},
#{item.tenantKey}
#{item.tenantKey},
#{item.employeeType}
)
</foreach>
</insert>
<!-- 更新,更新全部字段 -->
<update id="update" parameterType="com.engine.salary.entity.taxdeclaration.TaxDeclarationDetail">
UPDATE hrsa_tax_declaration_detail
<set>
create_time=#{createTime},
creator=#{creator},
delete_type=#{deleteType},
employee_id=#{employeeId},
field_code=#{fieldCode},
field_value=#{fieldValue},
tax_declaration_id=#{taxDeclarationId},
tenant_key=#{tenantKey},
update_time=#{updateTime},
</set>
WHERE id = #{id} AND delete_type = 0
</update>
<!-- 更新不为NULL的字段 -->
<update id="updateIgnoreNull" parameterType="com.engine.salary.entity.taxdeclaration.TaxDeclarationDetail">
UPDATE hrsa_tax_declaration_detail
<set>
<if test="createTime != null">
create_time=#{createTime},
</if>
<if test="creator != null">
creator=#{creator},
</if>
<if test="deleteType != null">
delete_type=#{deleteType},
</if>
<if test="employeeId != null">
employee_id=#{employeeId},
</if>
<if test="fieldCode != null">
field_code=#{fieldCode},
</if>
<if test="fieldValue != null">
field_value=#{fieldValue},
</if>
<if test="taxDeclarationId != null">
tax_declaration_id=#{taxDeclarationId},
</if>
<if test="tenantKey != null">
tenant_key=#{tenantKey},
</if>
<if test="updateTime != null">
update_time=#{updateTime},
</if>
</set>
WHERE id = #{id} AND delete_type = 0
</update>
<!-- 根据主键删除记录 -->
<delete id="delete" parameterType="com.engine.salary.entity.taxdeclaration.TaxDeclarationDetail">
UPDATE hrsa_tax_declaration_detail
SET delete_type=1
WHERE id = #{id}
AND delete_type = 0
</delete>
<update id="deleteByTaxDeclarationIds">
UPDATE hrsa_tax_declaration_detail

View File

@ -1,6 +1,5 @@
package com.engine.salary.mapper.taxdeclaration;
import com.engine.salary.entity.taxdeclaration.TaxDeclaration;
import com.engine.salary.entity.taxdeclaration.po.TaxDeclarationPO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@ -18,7 +17,7 @@ public interface TaxDeclarationMapper {
* @param id 主键
* @return 返回记录没有返回null
*/
TaxDeclaration getById(Long id);
TaxDeclarationPO getById(Long id);
/**

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.engine.salary.mapper.taxdeclaration.TaxDeclarationMapper">
<resultMap id="BaseResultMap" type="com.engine.salary.entity.taxdeclaration.TaxDeclaration">
<resultMap id="BaseResultMap" type="com.engine.salary.entity.taxdeclaration.po.TaxDeclarationPO">
<result column="create_time" property="createTime"/>
<result column="creator" property="creator"/>
<result column="delete_type" property="deleteType"/>

View File

@ -33,6 +33,8 @@ public interface SalaryEmployeeService {
DataCollectionEmployee getEmployeeById(Long employeeId);
List<DataCollectionEmployee> getEmployeeByIds(List<Long> simpleEmployeeIds);
/**
* 获取当前登录人的信息
* @param employeeId

View File

@ -1,6 +1,7 @@
package com.engine.salary.service;
import com.engine.salary.entity.taxdeclaration.dto.TaxDeclarationDetailListDTO;
import com.engine.salary.entity.taxdeclaration.dto.TaxDeclarationEmployeeDTO;
import com.engine.salary.entity.taxdeclaration.dto.TaxDeclarationLaborListDTO;
import com.engine.salary.entity.taxdeclaration.dto.TaxDeclarationWageListDTO;
import com.engine.salary.entity.taxdeclaration.param.TaxDeclarationDetailListQueryParam;
@ -8,14 +9,16 @@ import com.engine.salary.entity.taxdeclaration.po.TaxDeclarationDetailPO;
import com.engine.salary.util.page.PageInfo;
import java.util.Collection;
import java.util.List;
/**
* @description: 个税申报表明细
* @author: xiajun
* @modified By: xiajun
* @date: Created in 1/23/22 4:28 PM
* @version:v1.0
*/
* 个税申报表明细
* <p>Copyright: Copyright (c) 2022</p>
* <p>Company: 泛微软件</p>
*
* @author qiantao
* @version 1.0
**/
public interface TaxDeclarationDetailService {
/**
@ -23,19 +26,17 @@ public interface TaxDeclarationDetailService {
*
* @param taxDeclarationId 个税申报表id
* @param employeeIds 人员id
* @param tenantKey 租户key
* @return
*/
//List<TaxDeclarationDetailPO> listByTaxDeclarationIdAndEmployeeIds(Long taxDeclarationId, Collection<Long> employeeIds, String tenantKey);
List<TaxDeclarationDetailPO> listByTaxDeclarationIdAndEmployeeIds(Long taxDeclarationId, Collection<Long> employeeIds);
/**
* 根据列表查询条件查询个税申报列表明细中的人员
*
* @param queryParam 列表查询条件
* @param tenantKey 租户key
* @return
*/
//Page<Long> listPage4EmployeeIdByParam(TaxDeclarationDetailListQueryParam queryParam, String tenantKey);
PageInfo<TaxDeclarationEmployeeDTO> listPage4EmployeeIdByParam(TaxDeclarationDetailListQueryParam queryParam);
/**
* 根据列表查询条件查询个税申报列表明细

View File

@ -2,7 +2,6 @@ package com.engine.salary.service;
import com.engine.salary.entity.salaryacct.po.SalaryAcctRecordPO;
import com.engine.salary.entity.taxagent.po.TaxAgentPO;
import com.engine.salary.entity.taxdeclaration.TaxDeclaration;
import com.engine.salary.entity.taxdeclaration.param.TaxDeclarationListQueryParam;
import com.engine.salary.entity.taxdeclaration.param.TaxDeclarationSaveParam;
import com.engine.salary.entity.taxdeclaration.po.TaxDeclarationPO;
@ -19,7 +18,7 @@ public interface TaxDeclarationService {
List<TaxAgentPO> countByTaxDeclarationId(Collection<Long> taxAgentIds);
//表单
TaxDeclaration getById(Long id);
TaxDeclarationPO getById(Long id);
Map<String, Object> getForm(Map<String, Object> params);

View File

@ -7,13 +7,16 @@ import com.engine.salary.entity.datacollection.DataCollectionEmployee;
import com.engine.salary.entity.salarysob.bo.SalarySobRangeBO;
import com.engine.salary.entity.salarysob.param.SalarySobRangeEmpQueryParam;
import com.engine.salary.entity.salarysob.po.SalarySobRangePO;
import com.engine.salary.mapper.datacollection.EmployMapper;
import com.engine.salary.service.SalaryEmployeeService;
import com.engine.salary.service.SalarySobRangeService;
import com.engine.salary.util.SalaryEntityUtil;
import com.engine.salary.util.db.MapperProxyFactory;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.math.NumberUtils;
import weaver.hrm.User;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Set;
@ -35,6 +38,10 @@ public class SalaryEmployeeServiceImpl extends Service implements SalaryEmployee
return (SalarySobRangeService) ServiceUtil.getService(SalarySobRangeServiceImpl.class, user);
}
private EmployMapper getEmployMapper() {
return MapperProxyFactory.getProxy(EmployMapper.class);
}
@Override
public List<DataCollectionEmployee> listAll() {
return employBiz.listEmployee();
@ -80,4 +87,13 @@ public class SalaryEmployeeServiceImpl extends Service implements SalaryEmployee
public DataCollectionEmployee getEmployeeById(Long employeeId) {
return employBiz.getEmployeeById(employeeId);
}
@Override
public List<DataCollectionEmployee> getEmployeeByIds(List<Long> simpleEmployeeIds) {
if(CollectionUtils.isEmpty(simpleEmployeeIds)){
return new ArrayList<>();
}
return getEmployMapper().getEmployeeByIds(simpleEmployeeIds);
}
}

View File

@ -3,23 +3,33 @@ package com.engine.salary.service.impl;
import com.engine.common.util.ServiceUtil;
import com.engine.core.impl.Service;
import com.engine.salary.entity.datacollection.DataCollectionEmployee;
import com.engine.salary.entity.taxagent.dto.TaxAgentEmployeeDTO;
import com.engine.salary.entity.taxdeclaration.bo.TaxDeclarationBO;
import com.engine.salary.entity.taxdeclaration.bo.TaxDeclarationDetailBO;
import com.engine.salary.entity.taxdeclaration.dto.TaxDeclarationDetailListDTO;
import com.engine.salary.entity.taxdeclaration.dto.TaxDeclarationEmployeeDTO;
import com.engine.salary.entity.taxdeclaration.dto.TaxDeclarationLaborListDTO;
import com.engine.salary.entity.taxdeclaration.dto.TaxDeclarationWageListDTO;
import com.engine.salary.entity.taxdeclaration.param.TaxDeclarationDetailListQueryParam;
import com.engine.salary.entity.taxdeclaration.po.TaxDeclarationDetailPO;
import com.engine.salary.entity.taxdeclaration.po.TaxDeclarationPO;
import com.engine.salary.enums.salaryaccounting.EmployeeTypeEnum;
import com.engine.salary.mapper.taxdeclaration.TaxDeclarationDetailMapper;
import com.engine.salary.service.SalaryEmployeeService;
import com.engine.salary.service.TaxAgentService;
import com.engine.salary.service.TaxDeclarationDetailService;
import com.engine.salary.service.TaxDeclarationService;
import com.engine.salary.util.SalaryEntityUtil;
import com.engine.salary.util.db.MapperProxyFactory;
import com.engine.salary.util.page.PageInfo;
import com.engine.salary.util.page.SalaryPageUtil;
import com.google.common.collect.Lists;
import com.mzlion.core.lang.CollectionUtils;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.BooleanUtils;
import weaver.hrm.User;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.*;
import java.util.stream.Collectors;
/**
* @description: 个税申报表明细
@ -35,30 +45,37 @@ public class TaxDeclarationDetailServiceImpl extends Service implements TaxDecla
}
private SalaryEmployeeService getSalaryEmployeeService() {
return ServiceUtil.getService(SalaryEmployeeServiceImpl.class, user);
}
private TaxDeclarationService getTaxDeclarationService(User user) {
return ServiceUtil.getService(TaxDeclarationServiceImpl.class, user);
}
private TaxAgentService getTaxAgentService(User user) {
return ServiceUtil.getService(TaxAgentServiceImpl.class, user);
}
private SalaryEmployeeService getSalaryEmployeeService(User user) {
return (SalaryEmployeeService) ServiceUtil.getService(SalaryEmployeeServiceImpl.class, user);
}
/*@Override
public List<TaxDeclarationDetailPO> listByTaxDeclarationIdAndEmployeeIds(Long taxDeclarationId, Collection<Long> employeeIds, String tenantKey) {
@Override
public List<TaxDeclarationDetailPO> listByTaxDeclarationIdAndEmployeeIds(Long taxDeclarationId, Collection<Long> employeeIds) {
if (CollectionUtils.isEmpty(employeeIds)) {
return Collections.emptyList();
}
return new LambdaQueryChainWrapper<>(taxDeclarationDetailMapper)
.eq(TaxDeclarationDetailPO::getTenantKey, tenantKey)
.eq(TaxDeclarationDetailPO::getDeleteType, 0)
.eq(TaxDeclarationDetailPO::getTaxDeclarationId, taxDeclarationId)
.in(TaxDeclarationDetailPO::getEmployeeId, employeeIds)
.list();
return getTaxDeclarationDetailMapper().listByTaxDeclarationIdAndEmployeeIds(taxDeclarationId, employeeIds);
}
@Override
public Page<Long> listPage4EmployeeIdByParam(TaxDeclarationDetailListQueryParam queryParam, String tenantKey) {
// 分页参数
Page<Long> page = SalaryPageUtil.buildPage(queryParam.getCurrent(), queryParam.getPageSize());
// 查询个税申报表明细中的人员分页
return taxDeclarationDetailMapper.listEmployeeId(page, queryParam.getTaxDeclarationId(), tenantKey);
public PageInfo<TaxDeclarationEmployeeDTO> listPage4EmployeeIdByParam(TaxDeclarationDetailListQueryParam queryParam) {
SalaryPageUtil.start(queryParam.getCurrent(), queryParam.getPageSize());
List<TaxDeclarationEmployeeDTO> taxDeclarationEmployeeDTOS = getTaxDeclarationDetailMapper().listPage4EmployeeId(queryParam.getTaxDeclarationId());
return new PageInfo<>(taxDeclarationEmployeeDTOS, TaxDeclarationEmployeeDTO.class);
}
*/
@Override
public PageInfo<TaxDeclarationDetailListDTO> listDtoPageByParam(TaxDeclarationDetailListQueryParam queryParam) {
// 查询个税申报表明细的人员
@ -83,12 +100,99 @@ public class TaxDeclarationDetailServiceImpl extends Service implements TaxDecla
@Override
public PageInfo<TaxDeclarationLaborListDTO> listDtoPageByParam4Labor(TaxDeclarationDetailListQueryParam queryParam) {
return null;
}
/**
* 根据权限范围过滤
*
* @param taxDeclarationPO
* @param taxDeclarationEmployeeDTOS
* @return
*/
private List<TaxDeclarationEmployeeDTO> filterByAuthority(TaxDeclarationPO taxDeclarationPO, List<TaxDeclarationEmployeeDTO> taxDeclarationEmployeeDTOS) {
long employeeId = user.getUID();
if (CollectionUtils.isEmpty(taxDeclarationEmployeeDTOS)) {
return Collections.emptyList();
}
// 判断是否开启了分权
Boolean openDevolution = getTaxAgentService(user).isOpenDevolution();
// 是否是总管理员
Boolean isChief = getTaxAgentService(user).isChief(employeeId);
if (BooleanUtils.isFalse(openDevolution) || isChief) {
return taxDeclarationEmployeeDTOS;
}
// 查询权限范围内的人员
List<TaxAgentEmployeeDTO> taxAgentEmployeeDTOS = getTaxAgentService(user).listTaxAgentAndEmployee(employeeId);
Set<String> simpleEmployeeKeySet = SalaryEntityUtil.properties(taxAgentEmployeeDTOS, taxAgentEmployeeDTO -> taxAgentEmployeeDTO.getEmployeeId() + "-" + taxAgentEmployeeDTO.getTaxAgentId());
// 查询权限范围内的外部人员
// List<ExtEmployeePO> extEmployeePOS = extEmployeeService.listCanUseByEmployeeId(employeeId, tenantKey);
// Set<String> extEmployeeKeySet = SalaryEntityUtil.properties(extEmployeePOS, extEmployeePO -> extEmployeePO.getId() + "-" + extEmployeePO.getTaxAgentId());
// 根据权限范围过滤
return taxDeclarationEmployeeDTOS.stream().filter(taxDeclarationEmployeeDTO -> {
if (taxDeclarationEmployeeDTO.getEmployeeType() == null || Objects.equals(taxDeclarationEmployeeDTO.getEmployeeType(), EmployeeTypeEnum.ORGANIZATION.getValue())
&& simpleEmployeeKeySet.contains(taxDeclarationEmployeeDTO.getEmployeeId() + "-" + taxDeclarationPO.getTaxAgentId())) {
return true;
}
// if (Objects.equals(taxDeclarationEmployeeDTO.getEmployeeType(), EmployeeTypeEnum.EXT_EMPLOYEE.getValue())
// && extEmployeeKeySet.contains(taxDeclarationEmployeeDTO.getEmployeeId() + "-" + taxDeclarationPO.getTaxAgentId())) {
// return true;
// }
return false;
}).collect(Collectors.toList());
}
@Override
public PageInfo<TaxDeclarationWageListDTO> listDtoPageByParam4Wage(TaxDeclarationDetailListQueryParam queryParam) {
return null;
// 查询个税申报主表
TaxDeclarationPO taxDeclarationPO = getTaxDeclarationService(user).getById(queryParam.getTaxDeclarationId());
// 查询个税申报表明细的人员
PageInfo<TaxDeclarationEmployeeDTO> employeeIdPage = SalaryPageUtil.buildPage(queryParam.getCurrent(), queryParam.getPageSize());
// 判断是否开启了分权
Boolean openDevolution = getTaxAgentService(user).isOpenDevolution();
// 是否是总管理员
Boolean isChief = getTaxAgentService(user).isChief((long) user.getUID());
if (BooleanUtils.isTrue(openDevolution) && !isChief) {
List<TaxDeclarationEmployeeDTO> taxDeclarationEmployeeDTOS = getTaxDeclarationDetailMapper().list4EmployeeId(queryParam.getTaxDeclarationId());
// 根据权限过滤
taxDeclarationEmployeeDTOS = filterByAuthority(taxDeclarationPO, taxDeclarationEmployeeDTOS);
employeeIdPage.setTotal(taxDeclarationEmployeeDTOS.size());
employeeIdPage.setList(SalaryPageUtil.subList((int) employeeIdPage.getPageNum(), (int) employeeIdPage.getPageSize(), taxDeclarationEmployeeDTOS));
} else {
employeeIdPage = listPage4EmployeeIdByParam(queryParam);
}
PageInfo<TaxDeclarationWageListDTO> dtoPage = SalaryPageUtil.buildPage(queryParam.getCurrent(), queryParam.getPageSize(),TaxDeclarationWageListDTO.class);
dtoPage.setTotal(employeeIdPage.getTotal());
if (CollectionUtils.isNotEmpty(employeeIdPage.getList())) {
List<TaxDeclarationEmployeeDTO> list = employeeIdPage.getList();
// 查询个税申报表明细
Set<Long> employeeIds = SalaryEntityUtil.properties(list, TaxDeclarationEmployeeDTO::getEmployeeId);
List<TaxDeclarationDetailPO> taxDeclarationDetailPOS = listByTaxDeclarationIdAndEmployeeIds(queryParam.getTaxDeclarationId(),
employeeIds);
// 查询人员信息
List<Long> simpleEmployeeIds = list.stream()
.filter(taxDeclarationEmployeeDTO -> Objects.equals(taxDeclarationEmployeeDTO.getEmployeeType(), EmployeeTypeEnum.ORGANIZATION.getValue()))
.map(TaxDeclarationEmployeeDTO::getEmployeeId)
.collect(Collectors.toList());
List<DataCollectionEmployee> simpleEmployees = getSalaryEmployeeService(user).getEmployeeByIds(simpleEmployeeIds);
// 查询人员薪资身份证号码等
// List<SimpleUserInfo> simpleUserInfos = salaryEmployeeService.listByEmployeeIds(simpleEmployeeIds, tenantKey);
// 查询外部人员
// Set<Long> extEmployeeIds = employeeIdPage.getRecords().stream()
// .filter(taxDeclarationEmployeeDTO -> Objects.equals(taxDeclarationEmployeeDTO.getEmployeeType(), EmployeeTypeEnum.EXT_EMPLOYEE.getValue()))
// .map(TaxDeclarationEmployeeDTO::getEmployeeId)
// .collect(Collectors.toSet());
// List<ExtEmployeePO> extEmployees = extEmployeeService.listByIds(extEmployeeIds, tenantKey);
// 转换成列表dto
List<TaxDeclarationWageListDTO> taxDeclarationWageListDTOS = TaxDeclarationDetailBO.convert2ListDTO4Wage(taxDeclarationDetailPOS,
employeeIdPage.getList(), simpleEmployees);
dtoPage.setList(taxDeclarationWageListDTOS);
}
return dtoPage;
}
@Override
@ -104,12 +208,7 @@ public class TaxDeclarationDetailServiceImpl extends Service implements TaxDecla
return Collections.emptyList();
}
// return new LambdaQueryChainWrapper<>(taxDeclarationDetailMapper)
// .eq(TaxDeclarationDetailPO::getTenantKey, tenantKey)
// .eq(TaxDeclarationDetailPO::getDeleteType, 0)
// .eq(TaxDeclarationDetailPO::getTaxDeclarationId, taxDeclarationId)
// .in(TaxDeclarationDetailPO::getEmployeeId, employeeIds)
// .list();
return getTaxDeclarationDetailMapper().listByTaxDeclarationIdAndEmployeeIds(taxDeclarationId, employeeIds);
}

View File

@ -7,28 +7,35 @@ import com.engine.salary.cmd.taxDeclaration.TaxDeclarationGetFormCmd;
import com.engine.salary.cmd.taxDeclaration.TaxDeclarationGetTaxDeclarationInfoCmd;
import com.engine.salary.cmd.taxDeclaration.TaxDeclarationUpdateCmd;
import com.engine.salary.common.LocalDateRange;
import com.engine.salary.entity.datacollection.AddUpSituation;
import com.engine.salary.entity.salaryacct.po.SalaryAcctRecordPO;
import com.engine.salary.entity.salaryacct.po.SalaryAcctResultPO;
import com.engine.salary.entity.salaryitem.po.SalaryItemPO;
import com.engine.salary.entity.salarysob.po.SalarySobPO;
import com.engine.salary.entity.taxagent.po.TaxAgentPO;
import com.engine.salary.entity.taxdeclaration.TaxDeclaration;
import com.engine.salary.entity.taxdeclaration.bo.TaxDeclarationBO;
import com.engine.salary.entity.taxdeclaration.param.TaxDeclarationListQueryParam;
import com.engine.salary.entity.taxdeclaration.param.TaxDeclarationSaveParam;
import com.engine.salary.entity.taxdeclaration.po.TaxDeclarationPO;
import com.engine.salary.enums.salaryaccounting.SalaryAcctRecordStatusEnum;
import com.engine.salary.exception.SalaryRunTimeException;
import com.engine.salary.mapper.datacollection.AddUpSituationMapper;
import com.engine.salary.mapper.salaryacct.SalaryAcctRecordMapper;
import com.engine.salary.mapper.taxdeclaration.TaxDeclarationMapper;
import com.engine.salary.service.AddUpSituationService;
import com.engine.salary.service.TaxAgentService;
import com.engine.salary.service.TaxDeclarationDetailService;
import com.engine.salary.service.TaxDeclarationService;
import com.engine.salary.service.*;
import com.engine.salary.util.SalaryDateUtil;
import com.engine.salary.util.SalaryEntityUtil;
import com.engine.salary.util.SalaryI18nUtil;
import com.engine.salary.util.db.MapperProxyFactory;
import com.engine.salary.util.page.PageInfo;
import com.engine.salary.util.page.SalaryPageUtil;
import com.google.common.collect.Lists;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.BooleanUtils;
import weaver.hrm.User;
import java.util.*;
import java.util.stream.Collectors;
public class TaxDeclarationServiceImpl extends Service implements TaxDeclarationService {
@ -36,6 +43,14 @@ public class TaxDeclarationServiceImpl extends Service implements TaxDeclaration
return MapperProxyFactory.getProxy(TaxDeclarationMapper.class);
}
private SalaryAcctRecordMapper getSalaryAcctRecordMapper() {
return MapperProxyFactory.getProxy(SalaryAcctRecordMapper.class);
}
private AddUpSituationMapper getAddUpSituationMapper() {
return MapperProxyFactory.getProxy(AddUpSituationMapper.class);
}
private TaxDeclarationDetailService getTaxDeclarationDetailService(User user) {
return ServiceUtil.getService(TaxDeclarationDetailServiceImpl.class, user);
}
@ -48,6 +63,21 @@ public class TaxDeclarationServiceImpl extends Service implements TaxDeclaration
return ServiceUtil.getService(TaxAgentServiceImpl.class, user);
}
private SalarySobService getSalarySobService(User user) {
return ServiceUtil.getService(SalarySobServiceImpl.class, user);
}
private SalaryAcctResultService getSalaryAcctResultService(User user) {
return ServiceUtil.getService(SalaryAcctResultServiceImpl.class, user);
}
private SalaryItemService getSalaryItemService(User user) {
return ServiceUtil.getService(SalaryItemServiceImpl.class, user);
}
private SalaryAcctRecordService getSalaryAcctRecordService(User user) {
return ServiceUtil.getService(SalaryAcctRecordServiceImpl.class, user);
}
@Override
public PageInfo<TaxDeclarationPO> listPageByParam(TaxDeclarationListQueryParam queryParam) {
@ -80,7 +110,7 @@ public class TaxDeclarationServiceImpl extends Service implements TaxDeclaration
// 查询个税申报表
SalaryPageUtil.start(queryParam.getCurrent(), queryParam.getPageSize());
List<TaxDeclarationPO> taxDeclarationPOS = getTaxDeclarationMapper().listSome(po);
return new PageInfo<>(taxDeclarationPOS,TaxDeclarationPO.class);
return new PageInfo<>(taxDeclarationPOS, TaxDeclarationPO.class);
}
@ -95,7 +125,7 @@ public class TaxDeclarationServiceImpl extends Service implements TaxDeclaration
//根据id获取TaxDeclaration
@Override
public TaxDeclaration getById(Long id) {
public TaxDeclarationPO getById(Long id) {
return getTaxDeclarationMapper().getById(id);
}
@ -111,8 +141,97 @@ public class TaxDeclarationServiceImpl extends Service implements TaxDeclaration
@Override
public void save(TaxDeclarationSaveParam saveParam) {
//return commandExecutor.execute(new TaxDeclarationSaveCmd(saveParam));
return;
long currentEmployeeId = user.getUID();
// 个税扣缴义务人id
Set<Long> taxAgentIds;
Boolean openDevolution = getTaxAgentService(user).isOpenDevolution();
if (BooleanUtils.isFalse(openDevolution)) {
taxAgentIds = SalaryEntityUtil.properties(getTaxAgentService(user).listAll(), TaxAgentPO::getId);
} else {
taxAgentIds = SalaryEntityUtil.properties(getTaxAgentService(user).listAllTaxAgentsAsAdmin(currentEmployeeId), TaxAgentPO::getId);
}
// 检查是否具有权限
if (CollectionUtils.isEmpty(taxAgentIds)) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0, "对不起,您不具备任何个税扣缴义务人的管理权限"));
}
// 查询个税扣缴义务人
List<TaxAgentPO> taxAgentPOS = getTaxAgentService(user).listByIds(taxAgentIds);
Map<Long, String> taxAgentNameMap = SalaryEntityUtil.convert2Map(taxAgentPOS, TaxAgentPO::getId, TaxAgentPO::getName);
// 薪资所属月的日期范围
LocalDateRange salaryMonthDateRange = SalaryDateUtil.localDate2Range(SalaryDateUtil.localDateToDate(saveParam.getSalaryMonth().atDay(1)));
if (Objects.isNull(salaryMonthDateRange)) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(84026, "薪资所属月参数错误"));
}
// 查询薪资所属月个税扣缴义务人已经生成过的个税申报表
List<TaxDeclarationPO> taxDeclarationPOS = listBySalaryMonthTax(TaxDeclarationPO.builder().salaryMonths(salaryMonthDateRange).taxAgentIds(taxAgentNameMap.keySet()).build());
// 已经生成过个税申报表不允许再次生成个税申报表
if (CollectionUtils.isNotEmpty(taxDeclarationPOS)) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(107986, "{0}在{1}已经生成过个税申报表,不允许再次生成")
.replace("{0}", taxAgentNameMap.get(taxDeclarationPOS.get(0).getTaxAgentId()))
.replace("{1}", saveParam.getSalaryMonth().toString()));
}
// 查询薪资所属月的薪资核算记录
List<SalaryAcctRecordPO> salaryAcctRecordPOS = listBySalaryMonth(SalaryAcctRecordPO.builder().salaryMonths(salaryMonthDateRange).build());
// 无薪资核算记录不允许生成个税申报表
if (CollectionUtils.isEmpty(salaryAcctRecordPOS)) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98874, "{0}无申报数据").replace("{0}", saveParam.getSalaryMonth().toString()));
}
// 查询薪资核算结果
List<SalaryAcctResultPO> salaryAcctResultPOS = getSalaryAcctResultService(user)
.listBySalaryAcctRecordIdsAndTaxAgentIds(SalaryEntityUtil.properties(salaryAcctRecordPOS, SalaryAcctRecordPO::getId), taxAgentIds);
// 无薪资核算结果不允许生成个税申报表
if (CollectionUtils.isEmpty(salaryAcctResultPOS)) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(110093, "{0}无可申报数据")
.replace("{0}", saveParam.getSalaryMonth().toString()));
}
Set<Long> salaryAcctRecordIds = SalaryEntityUtil.properties(salaryAcctResultPOS, SalaryAcctResultPO::getSalaryAcctRecordId);
salaryAcctRecordPOS = salaryAcctRecordPOS.stream().filter(salaryAcctRecordPO -> salaryAcctRecordIds.contains(salaryAcctRecordPO.getId())).collect(Collectors.toList());
// 如果存在未归档的也不允许生成个税申报表
boolean notArchived = salaryAcctRecordPOS.stream().anyMatch(salaryAcctRecordPO -> !Objects.equals(salaryAcctRecordPO.getStatus(), SalaryAcctRecordStatusEnum.ARCHIVED.getValue()));
if (notArchived) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98875, "{0}有未归档数据,请全部归档后再申报")
.replace("{0}", saveParam.getSalaryMonth().toString()));
}
// 如果当前薪资所属月下存在不同的税款所属期属于异常业务场景不允许生成个税申报表
Date taxCycle = salaryAcctRecordPOS.get(0).getTaxCycle();
boolean differentTaxCycle = salaryAcctRecordPOS.stream().anyMatch(salaryAcctRecordPO -> salaryAcctRecordPO.getTaxCycle().compareTo(taxCycle) != 0);
if (differentTaxCycle) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98876, "{0}存在不同的税款所属期,无法正常生成个税申报表,请调整账套设置,重新核算后再生成个税申报表")
.replace("{0}", saveParam.getSalaryMonth().toString()));
}
// 查询薪资账套
Set<Long> salarySobIds = SalaryEntityUtil.properties(salaryAcctRecordPOS, SalaryAcctRecordPO::getSalarySobId);
List<SalarySobPO> salarySobPOS = getSalarySobService(user).listByIds(salarySobIds);
// 查询所有薪资项目
List<SalaryItemPO> salaryItemPOS = getSalaryItemService(user).listAll();
// 处理要保存的数据
TaxDeclarationBO.Result result = TaxDeclarationBO.handle(saveParam, taxCycle, user, salaryItemPOS, salarySobPOS, salaryAcctResultPOS);
// 保存个税申报表
if (CollectionUtils.isNotEmpty(result.getNeedInsertTaxDeclarations())) {
getTaxDeclarationMapper().batchInsert(result.getNeedInsertTaxDeclarations());
}
// 保存个税申报表明细
if (CollectionUtils.isNotEmpty(result.getNeedInsertTaxDeclarationDetails())) {
getTaxDeclarationDetailService(user).batchSave(result.getNeedInsertTaxDeclarationDetails());
}
// 保存累计情况
if (CollectionUtils.isNotEmpty(result.getNeedInsertAddUpSituations())) {
getAddUpSituationService(user).deleteByTaxYearMonthAndTaxAgentIds(SalaryDateUtil.localDate2YearMonth(taxCycle), taxAgentIds);
List<List<AddUpSituation>> partition = Lists.partition((List) result.getNeedInsertAddUpSituations(), 100);
partition.forEach(getAddUpSituationMapper()::insertData);
}
// 更新薪资核算记录的状态
getSalaryAcctRecordService(user).updateStatusByIds(salaryAcctRecordIds, SalaryAcctRecordStatusEnum.DECLARED);
}
@Override
@ -149,4 +268,13 @@ public class TaxDeclarationServiceImpl extends Service implements TaxDeclaration
return getTaxDeclarationMapper().listSome(TaxDeclarationPO.builder().salaryMonths(salaryMonthDateRange).build());
}
public List<TaxDeclarationPO> listBySalaryMonthTax(TaxDeclarationPO build) {
return getTaxDeclarationMapper().listSome(build);
}
public List<SalaryAcctRecordPO> listBySalaryMonth(SalaryAcctRecordPO po) {
return getSalaryAcctRecordMapper().listSome(po);
}
}

View File

@ -33,7 +33,6 @@ import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.text.ParseException;
import java.time.LocalDate;
import java.util.Map;
@Slf4j
@ -103,7 +102,7 @@ public class TaxDeclarationController {
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, Map<String, Object>>(user).run(getTaxDeclarationDetailWrapper(user)::listPage, param);
return new ResponseResult<TaxDeclarationDetailListQueryParam, PageInfo>(user).run(getTaxDeclarationDetailWrapper(user)::listPage, param);
}
//个税申报表相关信息

View File

@ -1,67 +1,64 @@
package com.engine.salary.wrapper;
import com.cloudstore.eccom.pc.table.WeaTableColumn;
import com.cloudstore.eccom.result.WeaResultMsg;
import com.engine.common.util.ServiceUtil;
import com.engine.core.impl.Service;
import com.engine.salary.component.SalaryWeaTable;
import com.engine.salary.entity.taxdeclaration.bo.TaxDeclarationDetailListColumn;
import com.engine.salary.entity.taxdeclaration.dto.TaxDeclarationDetailListDTO;
import com.engine.salary.entity.taxdeclaration.dto.TaxDeclarationWageListDTO;
import com.engine.salary.entity.taxdeclaration.param.TaxDeclarationDetailListQueryParam;
import com.engine.salary.entity.taxdeclaration.po.TaxDeclarationPO;
import com.engine.salary.service.TaxDeclarationDetailService;
import com.engine.salary.service.TaxDeclarationService;
import com.engine.salary.service.impl.TaxDeclarationDetailServiceImpl;
import com.engine.salary.service.impl.TaxDeclarationServiceImpl;
import com.engine.salary.util.page.PageInfo;
import lombok.extern.slf4j.Slf4j;
import weaver.hrm.User;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/** @description: 个税申报表明细
/**
* @description: 个税申报表明细
* @author: xiajun
* @modified By: xiajun
* @date: Created in 1/23/22 6:07 PM
* @version:v1.0*/
* @version:v1.0
*/
@Slf4j
public class TaxDeclarationDetailWrapper extends Service {
private TaxDeclarationDetailService getTaxDeclarationDetailService(User user) {
return (TaxDeclarationDetailService) ServiceUtil.getService(TaxDeclarationDetailServiceImpl.class, user);
return ServiceUtil.getService(TaxDeclarationDetailServiceImpl.class, user);
}
private TaxDeclarationService getTaxDeclarationService(User user) {
return ServiceUtil.getService(TaxDeclarationServiceImpl.class, user);
}
/** 个税申报表明细列表
/**
* 个税申报表明细列表
*
* @param queryParam 列表查询条件
* @return*/
* @return
*/
public Map<String,Object> listPage(TaxDeclarationDetailListQueryParam queryParam) {
PageInfo<TaxDeclarationDetailListDTO> dtoPage = getTaxDeclarationDetailService(user).listDtoPageByParam(queryParam);
// 列表的表头
List<WeaTableColumn> weaTableColumns = TaxDeclarationDetailListColumn.listTableColumn().stream()
.map(weaTableColumnWapper -> (WeaTableColumn) weaTableColumnWapper)
.collect(Collectors.toList());
SalaryWeaTable<TaxDeclarationDetailListDTO> table = new SalaryWeaTable<TaxDeclarationDetailListDTO>(user, TaxDeclarationDetailListDTO.class);
table.setColumns(weaTableColumns);
public PageInfo listPage(TaxDeclarationDetailListQueryParam queryParam) {
dtoPage.setTotal(dtoPage.getPageSize());
dtoPage.setPageNum(queryParam.getCurrent());
dtoPage.setPageSize(queryParam.getPageSize());
TaxDeclarationPO taxDeclarationPO = getTaxDeclarationService(user).getById(queryParam.getTaxDeclarationId());
WeaResultMsg result = new WeaResultMsg(false);
result.putAll(table.makeDataResult());
result.success();
Map<String,Object> datas = new HashMap<>();
datas.put("pageInfo", dtoPage);
datas.put("dataKey",result.getResultMap());
datas.put("pageUid", "taxDeclarationDetailList");
return datas;
// 正常工资薪金所得
// if (Objects.equals(taxDeclarationPO.getIncomeCategory(), IncomeCategoryEnum.WAGES_AND_SALARIES.getValue())) {
PageInfo<TaxDeclarationWageListDTO> dtoPage = getTaxDeclarationDetailService(user).listDtoPageByParam4Wage(queryParam);
// weaTable = SalaryFormatUtil.<TaxDeclarationWageListDTO>getInstance().buildTable(TaxDeclarationWageListDTO.class, dtoPage);
// }
// // 劳务报酬所得
// if (Objects.equals(taxDeclarationPO.getIncomeCategory(), IncomeCategoryEnum.REMUNERATION_FOR_LABOR.getValue())) {
// Page<TaxDeclarationLaborListDTO> dtoPage = taxDeclarationDetailService.listDtoPageByParam4Labor(queryParam, employeeId, tenantKey);
// weaTable = SalaryFormatUtil.<TaxDeclarationLaborListDTO>getInstance().buildTable(TaxDeclarationLaborListDTO.class, dtoPage);
// }
return dtoPage;
}
}

View File

@ -3,16 +3,9 @@ package com.engine.salary.wrapper;
import com.engine.common.util.ServiceUtil;
import com.engine.core.impl.Service;
import com.engine.salary.biz.EmployBiz;
import com.engine.salary.common.LocalDateRange;
import com.engine.salary.component.WeaFormOption;
import com.engine.salary.entity.datacollection.AddUpSituation;
import com.engine.salary.entity.datacollection.DataCollectionEmployee;
import com.engine.salary.entity.salaryacct.po.SalaryAcctRecordPO;
import com.engine.salary.entity.salaryacct.po.SalaryAcctResultPO;
import com.engine.salary.entity.salaryitem.po.SalaryItemPO;
import com.engine.salary.entity.salarysob.po.SalarySobPO;
import com.engine.salary.entity.taxagent.po.TaxAgentPO;
import com.engine.salary.entity.taxdeclaration.TaxDeclaration;
import com.engine.salary.entity.taxdeclaration.bo.TaxDeclarationBO;
import com.engine.salary.entity.taxdeclaration.dto.TaxDeclarationFormDTO;
import com.engine.salary.entity.taxdeclaration.dto.TaxDeclarationInfoDTO;
@ -20,22 +13,17 @@ import com.engine.salary.entity.taxdeclaration.dto.TaxDeclarationListDTO;
import com.engine.salary.entity.taxdeclaration.param.TaxDeclarationListQueryParam;
import com.engine.salary.entity.taxdeclaration.param.TaxDeclarationSaveParam;
import com.engine.salary.entity.taxdeclaration.po.TaxDeclarationPO;
import com.engine.salary.enums.salaryaccounting.SalaryAcctRecordStatusEnum;
import com.engine.salary.exception.SalaryRunTimeException;
import com.engine.salary.mapper.datacollection.AddUpSituationMapper;
import com.engine.salary.mapper.salaryacct.SalaryAcctRecordMapper;
import com.engine.salary.mapper.taxdeclaration.TaxDeclarationMapper;
import com.engine.salary.service.*;
import com.engine.salary.service.impl.*;
import com.engine.salary.service.TaxAgentService;
import com.engine.salary.service.TaxDeclarationService;
import com.engine.salary.service.impl.TaxAgentServiceImpl;
import com.engine.salary.service.impl.TaxDeclarationServiceImpl;
import com.engine.salary.util.SalaryDateUtil;
import com.engine.salary.util.SalaryEntityUtil;
import com.engine.salary.util.SalaryI18nUtil;
import com.engine.salary.util.db.MapperProxyFactory;
import com.engine.salary.util.page.PageInfo;
import com.google.common.collect.Lists;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.BooleanUtils;
import org.springframework.transaction.annotation.Transactional;
import weaver.hrm.User;
import java.text.SimpleDateFormat;
@ -60,42 +48,6 @@ public class TaxDeclarationWrapper extends Service {
return ServiceUtil.getService(TaxAgentServiceImpl.class, user);
}
private TaxDeclarationDetailService getTaxDeclarationDetailService(User user) {
return ServiceUtil.getService(TaxDeclarationDetailServiceImpl.class, user);
}
private SalaryAcctRecordService getSalaryAcctRecordService(User user) {
return ServiceUtil.getService(SalaryAcctRecordServiceImpl.class, user);
}
private TaxDeclarationMapper getTaxDeclarationMapper() {
return MapperProxyFactory.getProxy(TaxDeclarationMapper.class);
}
private SalaryAcctRecordMapper getSalaryAcctRecordMapper() {
return MapperProxyFactory.getProxy(SalaryAcctRecordMapper.class);
}
private AddUpSituationMapper getAddUpSituationMapper() {
return MapperProxyFactory.getProxy(AddUpSituationMapper.class);
}
private AddUpSituationService getAddUpSituationService(User user) {
return ServiceUtil.getService(AddUpSituationServiceImpl.class, user);
}
private SalarySobService getSalarySobService(User user) {
return ServiceUtil.getService(SalarySobServiceImpl.class, user);
}
private SalaryAcctResultService getSalaryAcctResultService(User user) {
return ServiceUtil.getService(SalaryAcctResultServiceImpl.class, user);
}
private SalaryItemService getSalaryItemService(User user) {
return (SalaryItemService) ServiceUtil.getService(SalaryItemServiceImpl.class, user);
}
/**
* 个税申报表列表
*
@ -130,7 +82,7 @@ public class TaxDeclarationWrapper extends Service {
TaxDeclarationFormDTO formDTO = new TaxDeclarationFormDTO();
if (Objects.nonNull(id)) {
// 查询个税申报表
TaxDeclaration taxDeclaration = getTaxDeclarationService(user).getById(id);
TaxDeclarationPO taxDeclaration = getTaxDeclarationService(user).getById(id);
if (Objects.isNull(taxDeclaration)) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98877, "个税申报表不存在或已删除"));
}
@ -173,7 +125,7 @@ public class TaxDeclarationWrapper extends Service {
*/
public TaxDeclarationInfoDTO getTaxDeclarationInfoById(Long id) {
// 查询个税申报表
TaxDeclaration taxDeclaration = getTaxDeclarationService(user).getById(id);
TaxDeclarationPO taxDeclaration = getTaxDeclarationService(user).getById(id);
if (Objects.isNull(taxDeclaration)) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98877, "个税申报表不存在或已删除"));
}
@ -190,107 +142,11 @@ public class TaxDeclarationWrapper extends Service {
*
* @param saveParam 保存参数
*/
@Transactional(rollbackFor = Exception.class)
public void save(TaxDeclarationSaveParam saveParam) {
long currentEmployeeId = user.getUID();
// 个税扣缴义务人id
Set<Long> taxAgentIds;
Boolean openDevolution = getTaxAgentService(user).isOpenDevolution();
if (BooleanUtils.isFalse(openDevolution)) {
taxAgentIds = SalaryEntityUtil.properties(getTaxAgentService(user).listAll(), TaxAgentPO::getId);
} else {
taxAgentIds = SalaryEntityUtil.properties(getTaxAgentService(user).listAllTaxAgentsAsAdmin(currentEmployeeId), TaxAgentPO::getId);
}
// 检查是否具有权限
if (CollectionUtils.isEmpty(taxAgentIds)) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0, "对不起,您不具备任何个税扣缴义务人的管理权限"));
}
// 查询个税扣缴义务人
List<TaxAgentPO> taxAgentPOS = getTaxAgentService(user).listByIds(taxAgentIds);
Map<Long, String> taxAgentNameMap = SalaryEntityUtil.convert2Map(taxAgentPOS, TaxAgentPO::getId, TaxAgentPO::getName);
// 薪资所属月的日期范围
LocalDateRange salaryMonthDateRange = SalaryDateUtil.localDate2Range(SalaryDateUtil.localDateToDate(saveParam.getSalaryMonth().atDay(1)));
if (Objects.isNull(salaryMonthDateRange)) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(84026, "薪资所属月参数错误"));
}
// 查询薪资所属月个税扣缴义务人已经生成过的个税申报表
List<TaxDeclarationPO> taxDeclarationPOS = listBySalaryMonthTax(TaxDeclarationPO.builder().salaryMonths(salaryMonthDateRange).taxAgentIds(taxAgentNameMap.keySet()).build());
// 已经生成过个税申报表不允许再次生成个税申报表
if (CollectionUtils.isNotEmpty(taxDeclarationPOS)) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(107986, "{0}在{1}已经生成过个税申报表,不允许再次生成")
.replace("{0}", taxAgentNameMap.get(taxDeclarationPOS.get(0).getTaxAgentId()))
.replace("{1}", saveParam.getSalaryMonth().toString()));
}
// 查询薪资所属月的薪资核算记录
List<SalaryAcctRecordPO> salaryAcctRecordPOS = listBySalaryMonth(SalaryAcctRecordPO.builder().salaryMonths(salaryMonthDateRange).build());
// 无薪资核算记录不允许生成个税申报表
if (CollectionUtils.isEmpty(salaryAcctRecordPOS)) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98874, "{0}无申报数据").replace("{0}", saveParam.getSalaryMonth().toString()));
}
// 查询薪资核算结果
List<SalaryAcctResultPO> salaryAcctResultPOS = getSalaryAcctResultService(user)
.listBySalaryAcctRecordIdsAndTaxAgentIds(SalaryEntityUtil.properties(salaryAcctRecordPOS, SalaryAcctRecordPO::getId), taxAgentIds);
// 无薪资核算结果不允许生成个税申报表
if (CollectionUtils.isEmpty(salaryAcctResultPOS)) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(110093, "{0}无可申报数据")
.replace("{0}", saveParam.getSalaryMonth().toString()));
}
Set<Long> salaryAcctRecordIds = SalaryEntityUtil.properties(salaryAcctResultPOS, SalaryAcctResultPO::getSalaryAcctRecordId);
salaryAcctRecordPOS = salaryAcctRecordPOS.stream().filter(salaryAcctRecordPO -> salaryAcctRecordIds.contains(salaryAcctRecordPO.getId())).collect(Collectors.toList());
// 如果存在未归档的也不允许生成个税申报表
boolean notArchived = salaryAcctRecordPOS.stream().anyMatch(salaryAcctRecordPO -> !Objects.equals(salaryAcctRecordPO.getStatus(), SalaryAcctRecordStatusEnum.ARCHIVED.getValue()));
if (notArchived) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98875, "{0}有未归档数据,请全部归档后再申报")
.replace("{0}", saveParam.getSalaryMonth().toString()));
}
// 如果当前薪资所属月下存在不同的税款所属期属于异常业务场景不允许生成个税申报表
Date taxCycle = salaryAcctRecordPOS.get(0).getTaxCycle();
boolean differentTaxCycle = salaryAcctRecordPOS.stream().anyMatch(salaryAcctRecordPO -> salaryAcctRecordPO.getTaxCycle().compareTo(taxCycle) != 0);
if (differentTaxCycle) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98876, "{0}存在不同的税款所属期,无法正常生成个税申报表,请调整账套设置,重新核算后再生成个税申报表")
.replace("{0}", saveParam.getSalaryMonth().toString()));
}
// 查询薪资账套
Set<Long> salarySobIds = SalaryEntityUtil.properties(salaryAcctRecordPOS, SalaryAcctRecordPO::getSalarySobId);
List<SalarySobPO> salarySobPOS = getSalarySobService(user).listByIds(salarySobIds);
// 查询所有薪资项目
List<SalaryItemPO> salaryItemPOS = getSalaryItemService(user).listAll();
// 处理要保存的数据
TaxDeclarationBO.Result result = TaxDeclarationBO.handle(saveParam, taxCycle, user, salaryItemPOS, salarySobPOS, salaryAcctResultPOS);
// 保存个税申报表
if (CollectionUtils.isNotEmpty(result.getNeedInsertTaxDeclarations())) {
getTaxDeclarationMapper().batchInsert(result.getNeedInsertTaxDeclarations());
}
// 保存个税申报表明细
if (CollectionUtils.isNotEmpty(result.getNeedInsertTaxDeclarationDetails())) {
getTaxDeclarationDetailService(user).batchSave(result.getNeedInsertTaxDeclarationDetails());
}
// 保存累计情况
if (CollectionUtils.isNotEmpty(result.getNeedInsertAddUpSituations())) {
getAddUpSituationService(user).deleteByTaxYearMonthAndTaxAgentIds(SalaryDateUtil.localDate2YearMonth(taxCycle), taxAgentIds);
List<List<AddUpSituation>> partition = Lists.partition((List) result.getNeedInsertAddUpSituations(), 100);
partition.forEach(getAddUpSituationMapper()::insertData);
}
// 更新薪资核算记录的状态
getSalaryAcctRecordService(user).updateStatusByIds(salaryAcctRecordIds, SalaryAcctRecordStatusEnum.DECLARED);
getTaxDeclarationService(user).save(saveParam);
}
public List<TaxDeclarationPO> listBySalaryMonthTax(TaxDeclarationPO build) {
return getTaxDeclarationMapper().listSome(build);
}
public List<SalaryAcctRecordPO> listBySalaryMonth(SalaryAcctRecordPO po) {
return getSalaryAcctRecordMapper().listSome(po);
}
}