diff --git a/resource/sql/Oracle常见问题.txt b/resource/sql/Oracle常见问题.txt index 8725b72ea..e7550cf71 100644 --- a/resource/sql/Oracle常见问题.txt +++ b/resource/sql/Oracle常见问题.txt @@ -9,9 +9,11 @@ Oracle数据库中常见报错问题 -- 删除原表HRSA_SALARY_TEMPLATE数据 delete from HRSA_SALARY_TEMPLATE; + alter TABLE HRSA_SALARY_TEMPLATE MODIFY SALARY_ITEM_SETTING NULL; alter table HRSA_SALARY_TEMPLATE modify salary_item_setting long; alter table HRSA_SALARY_TEMPLATE modify salary_item_setting CLOB; insert into HRSA_SALARY_TEMPLATE select * from HRSA_SALARY_TEMPLAT_TEMPT ; + alter TABLE HRSA_SALARY_TEMPLATE MODIFY SALARY_ITEM_SETTING NOT NULL; drop table HRSA_SALARY_TEMPLAT_TEMPT; diff --git a/src/com/api/salary/web/AddUpDeductionController.java b/src/com/api/salary/web/AddUpDeductionController.java index 37b454324..6e89b73c7 100644 --- a/src/com/api/salary/web/AddUpDeductionController.java +++ b/src/com/api/salary/web/AddUpDeductionController.java @@ -1,5 +1,9 @@ package com.api.salary.web; +import com.engine.salary.entity.datacollection.param.SpecialAddDeductionParam; +import com.huawei.shade.com.alibaba.fastjson.JSON; +import com.huawei.shade.com.alibaba.fastjson.serializer.SerializerFeature; + import javax.ws.rs.Path; @Path("/bs/hrmsalary/addUpDeduction") diff --git a/src/com/api/salary/web/SpecialAddDeductionController.java b/src/com/api/salary/web/SpecialAddDeductionController.java new file mode 100644 index 000000000..61afb7017 --- /dev/null +++ b/src/com/api/salary/web/SpecialAddDeductionController.java @@ -0,0 +1,8 @@ +package com.api.salary.web; + +import javax.ws.rs.Path; + +@Path("/bs/hrmsalary/specialAddDeduction") +public class SpecialAddDeductionController extends com.engine.salary.web.SpecialAddDeductionController { + +} diff --git a/src/com/engine/salary/biz/SpecialAddDeductionBiz.java b/src/com/engine/salary/biz/SpecialAddDeductionBiz.java new file mode 100644 index 000000000..cece96e18 --- /dev/null +++ b/src/com/engine/salary/biz/SpecialAddDeductionBiz.java @@ -0,0 +1,172 @@ +package com.engine.salary.biz; + +import com.engine.salary.encrypt.datacollection.SpecialAddDeductionEncrypt; +import com.engine.salary.entity.datacollection.dto.SpecialAddDeductionListDTO; +import com.engine.salary.entity.datacollection.dto.SpecialAddDeductionRecordDTO; +import com.engine.salary.entity.datacollection.param.SpecialAddDeductionQueryParam; +import com.engine.salary.entity.datacollection.po.SpecialAddDeductionPO; +import com.engine.salary.mapper.datacollection.SpecialAddDeductionMapper; +import com.engine.salary.util.db.MapperProxyFactory; +import com.engine.salary.util.page.SalaryPageUtil; +import com.google.common.collect.Lists; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.ibatis.session.SqlSession; +import weaver.conn.mybatis.MyBatisFactory; +import weaver.general.BaseBean; + +import java.util.*; +import java.util.stream.Collectors; + +public class SpecialAddDeductionBiz extends BaseBean { + private SpecialAddDeductionMapper mapper() { + return MapperProxyFactory.getProxy(SpecialAddDeductionMapper.class); + } + + /** + * 根据id获取 + * + * @param id + * @return + */ + public SpecialAddDeductionPO getById(Long id) { + try (SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession()) { + SpecialAddDeductionMapper mapper = sqlSession.getMapper(SpecialAddDeductionMapper.class); + SpecialAddDeductionPO byId = mapper.getById(id); + return SpecialAddDeductionEncrypt.decrypt(byId); + } + } + + public List listDTOByParam(SpecialAddDeductionQueryParam param) { + List specialAddDeductionRecordDTOS = mapper().listDtoByParam(param); + return SpecialAddDeductionEncrypt.decrypt(specialAddDeductionRecordDTOS); + } + + + public List listByParam(SpecialAddDeductionQueryParam param) { + List specialAddDeductionListDTOS = mapper().listByParam(param); + return SpecialAddDeductionEncrypt.decrypt(specialAddDeductionListDTOS); + } + + public List listByTaxAgentIds(List taxAgentIds) { + try (SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession()) { + SpecialAddDeductionMapper mapper = sqlSession.getMapper(SpecialAddDeductionMapper.class); + List pos = mapper.listByTaxAgentIds(taxAgentIds); + return SpecialAddDeductionEncrypt.decrypt(pos); + } + } + + + /** + * 批量插入 + * + * @param param + * @return + */ + public void batchSave(List param) { + if (CollectionUtils.isEmpty(param)) { + return; + } + try (SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession()) { + SpecialAddDeductionMapper mapper = sqlSession.getMapper(SpecialAddDeductionMapper.class); + SpecialAddDeductionEncrypt.encrypt(param); + List> partition = Lists.partition(param, 100); + partition.forEach(mapper::batchInsert); + sqlSession.commit(); + } + } + + /** + * 批量插入 + * + * @param param + * @return + */ + public void batchUpdate(List param) { + if (CollectionUtils.isEmpty(param)) { + return; + } + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SpecialAddDeductionMapper mapper = sqlSession.getMapper(SpecialAddDeductionMapper.class); + SpecialAddDeductionEncrypt.encrypt(param); + List> partition = Lists.partition(param, 100); + partition.forEach(mapper::updateBatchSelective); + sqlSession.commit(); + } finally { + sqlSession.close(); + } + } + + + /** + * 处理导入数据 + * + * @param pos + */ + public void handleImportData(List pos) { + if (CollectionUtils.isEmpty(pos)) { + return; + } + SpecialAddDeductionPO po = pos.get(0); + // 多条相同人的则以第一条为准,如果逆序排列(用于重复的则以最后一条为准)Collections.reverse(pos); + // 去重(通过记录的唯一条件(申报月份,人员id,个税扣缴义务人id)拼接) + List finalPos = pos.stream() + .collect(Collectors.collectingAndThen( + Collectors.toCollection(() -> + new TreeSet<>(Comparator.comparing(f -> f.getEmployeeId() + "-" + f.getTaxAgentId()))), + ArrayList::new) + ); + // 查询已有数据 + List list = listByTaxAgentIds(null); + // 待修改的 本地已存在则更新【交集】 + List updateList = list.stream() + .map(m -> finalPos.stream() + .filter(p -> (p.getEmployeeId() + "-" + p.getTaxAgentId()).equals(m.getEmployeeId() + "-" + m.getTaxAgentId())) + .findFirst() + .map(t -> t.setId(m.getId())) + .orElse(null) + ).filter(Objects::nonNull).collect(Collectors.toList()); + // 待新增的 导入比本地多,则新增【差集(导入 - local)】 + List saveList = finalPos.stream() + .filter(m -> list.stream().noneMatch(p -> (p.getEmployeeId() + "-" + p.getTaxAgentId()).equals(m.getEmployeeId() + "-" + m.getTaxAgentId())) + ).filter(Objects::nonNull).collect(Collectors.toList()); + + // 修改 + if (CollectionUtils.isNotEmpty(updateList)) { + batchUpdate(updateList); + } + // 保存 + if (CollectionUtils.isNotEmpty(saveList)) { + batchSave(saveList); + } + } + + + /** + * @return void + * @description 批量删除 + */ + public void batchDeleteByIds(List deleteIds) { + if (CollectionUtils.isEmpty(deleteIds)) { + return; + } + try (SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession()) { + SpecialAddDeductionMapper mapper = sqlSession.getMapper(SpecialAddDeductionMapper.class); + List> partition = Lists.partition(deleteIds, 100); + partition.forEach(mapper::deleteByIds); + sqlSession.commit(); + } + } + + public List getByEmployeeId(List employeeIds, Long taxAgentId) { + if (CollectionUtils.isEmpty(employeeIds)) { + employeeIds = Collections.emptyList(); + } + return mapper().getByEmployeeIds(employeeIds, taxAgentId) + .stream() + .filter(Objects::nonNull) + .filter(s -> s.getEmployeeId() != null) + .map(SpecialAddDeductionEncrypt::decrypt) + .collect(Collectors.toList()); + } +} diff --git a/src/com/engine/salary/encrypt/datacollection/SpecialAddDeductionEncrypt.java b/src/com/engine/salary/encrypt/datacollection/SpecialAddDeductionEncrypt.java new file mode 100644 index 000000000..c6169219c --- /dev/null +++ b/src/com/engine/salary/encrypt/datacollection/SpecialAddDeductionEncrypt.java @@ -0,0 +1,97 @@ +package com.engine.salary.encrypt.datacollection; + +import com.engine.salary.encrypt.AESEncryptUtil; +import com.engine.salary.entity.datacollection.dto.SpecialAddDeductionRecordDTO; +import com.engine.salary.entity.datacollection.po.SpecialAddDeductionPO; + +import java.lang.reflect.Field; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import java.util.stream.Collectors; + +/** + * hrsa_special_add_deduction: 加解密 + * 字段: + * children_education + * continuing_education + * housing_loan_interest + * housing_rent + * supporting_elder + * serious_illness_treatment + * infant_care + */ +public class SpecialAddDeductionEncrypt { + private static final List FIELDS = Arrays.asList( + "childrenEducation", "continuingEducation", "supportingElder", "housingLoanInterest", + "housingRent", "seriousIllnessTreatment", "infantCare"); + + public static T encrypt(T obj) { + if (obj == null) { + return obj; + } + if(obj instanceof List) { + return encrypt(obj); + } + Class clazz = obj.getClass(); + Field[] fields = clazz.getDeclaredFields(); + for (Field field : fields) { + field.setAccessible(true); + if (FIELDS.contains(field.getName())) { + try { + Object o = field.get(obj); + if (o instanceof String) { + Object value = AESEncryptUtil.encrypt((String)o); + field.set(obj, value); + } + } catch (IllegalAccessException e) { + //ignore + } + } + } + return obj; + } + + public static List encrypt(List list) { + if (list == null || list.isEmpty()) { + return list; + } + return list.stream().map(SpecialAddDeductionEncrypt::encrypt) + .collect(Collectors.toList()); + } + + public static T decrypt(T obj) { + if (obj == null) { + return obj; + } + if(obj instanceof List) { + return encrypt(obj); + } + Class clazz = obj.getClass(); + Field[] fields = clazz.getDeclaredFields(); + for (Field field : fields) { + field.setAccessible(true); + if (FIELDS.contains(field.getName())) { + try { + Object o = field.get(obj); + if (o instanceof String) { + Object value = AESEncryptUtil.decrypt((String)o); + field.set(obj, value); + } + } catch (IllegalAccessException e) { + //ignore + } + } + } + return obj; + } + + public static List decrypt(List list) { + if (list == null || list.isEmpty()) { + return list; + } + return list.stream().map(SpecialAddDeductionEncrypt::decrypt) + .collect(Collectors.toList()); + } +} diff --git a/src/com/engine/salary/entity/datacollection/dto/SpecialAddDeductionListDTO.java b/src/com/engine/salary/entity/datacollection/dto/SpecialAddDeductionListDTO.java new file mode 100644 index 000000000..8b86b6281 --- /dev/null +++ b/src/com/engine/salary/entity/datacollection/dto/SpecialAddDeductionListDTO.java @@ -0,0 +1,131 @@ +package com.engine.salary.entity.datacollection.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.SalaryTableOperate; +import com.engine.salary.annotation.TableTitle; +import com.engine.salary.util.excel.ExcelProperty; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 数据采集-专项附加扣除列表 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author lfc + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@SalaryTable(pageId = "a4f85287-e3f9-6612-adn9-7d06e54y6rj8", tableType = WeaTableType.CHECKBOX, operates = { + @SalaryTableOperate(text = "查看明细") +}) +public class SpecialAddDeductionListDTO { + + + //主键id + @SalaryTableColumn(column = "id", display = false) + private Long id; + + //员工id + private Long employeeId; + + //姓名 + @SalaryTableColumn(text = "姓名", width = "10%", column = "username") + @TableTitle(title = "姓名", dataIndex = "username", key = "username") + @ExcelProperty(index = 0) + private String username; + + //个税扣缴义务人 + @SalaryTableColumn(text = "个税扣缴义务人", width = "10%", column = "taxAgentName") + @TableTitle(title = "个税扣缴义务人", dataIndex = "taxAgentName", key = "taxAgentName") + @ExcelProperty(index = 1) + private String taxAgentName; + + /** + * 个税扣缴义务人id + */ + private Long taxAgentId; + + //部门 + @SalaryTableColumn(text = "部门", width = "10%", column = "departmentName") + @TableTitle(title = "部门", dataIndex = "departmentName", key = "departmentName") + @ExcelProperty(index = 2) + private String departmentName; + + //手机号 + @SalaryTableColumn(text = "手机号", width = "10%", column = "mobile") + @TableTitle(title = "手机号", dataIndex = "mobile", key = "mobile") + @ExcelProperty(index = 3) + private String mobile; + + //工号 + @SalaryTableColumn(text = "工号", width = "10%", column = "jobNum") + @TableTitle(title = "工号", dataIndex = "jobNum", key = "jobNum") + @ExcelProperty(index = 4) + private String jobNum; + + //证件号码 + @SalaryTableColumn(text = "证件号码", width = "10%", column = "idNo") + @TableTitle(title = "证件号码", dataIndex = "idNo", key = "idNo") + @ExcelProperty(index = 5) + private String idNo; + + //入职日期 + @ExcelProperty(index = 6) + @SalaryTableColumn(text = "入职日期", width = "10%", column = "hiredate") + @TableTitle(title = "入职日期", dataIndex = "hiredate", key = "hiredate") + private String hiredate; + + //子女教育 + @ExcelProperty(index = 7) + @SalaryTableColumn(text = "子女教育", width = "10%", column = "childrenEducation") + @TableTitle(title = "子女教育", dataIndex = "childrenEducation", key = "childrenEducation") + private String childrenEducation; + + //继续教育 + @ExcelProperty(index = 8) + @SalaryTableColumn(text = "继续教育", width = "10%", column = "continuingEducation") + @TableTitle(title = "继续教育", dataIndex = "continuingEducation", key = "continuingEducation") + private String continuingEducation; + + //住房贷款利息 + @ExcelProperty(index = 9) + @SalaryTableColumn(text = "住房贷款利息", width = "10%", column = "housingLoanInterest") + @TableTitle(title = "住房贷款利息", dataIndex = "housingLoanInterest", key = "housingLoanInterest") + private String housingLoanInterest; + + //住房租金 + @ExcelProperty(index = 10) + @SalaryTableColumn(text = "住房租金", width = "10%", column = "housingRent") + @TableTitle(title = "住房租金", dataIndex = "housingRent", key = "housingRent") + private String housingRent; + + //赡养老人 + @ExcelProperty(index = 11) + @SalaryTableColumn(text = "赡养老人", width = "10%", column = "supportingElder") + @TableTitle(title = "赡养老人", dataIndex = "supportingElder", key = "supportingElder") + private String supportingElder; + + //大病医疗 + @ExcelProperty(index = 12) + @SalaryTableColumn(text = "大病医疗", width = "10%", column = "seriousIllnessTreatment") + @TableTitle(title = "大病医疗", dataIndex = "seriousIllnessTreatment", key = "seriousIllnessTreatment") + private String seriousIllnessTreatment; + + //婴幼儿照护 + @ExcelProperty(index = 13) + @SalaryTableColumn(text = "婴幼儿照护", width = "10%", column = "infantCare") + @TableTitle(title = "婴幼儿照护", dataIndex = "infantCare", key = "infantCare") + private String infantCare; + + @SalaryTableColumn(text = "操作", width = "20%", column = "operate") + @TableTitle(title = "操作", dataIndex = "operate", key = "operate") + private String operate; +} diff --git a/src/com/engine/salary/entity/datacollection/dto/SpecialAddDeductionRecordDTO.java b/src/com/engine/salary/entity/datacollection/dto/SpecialAddDeductionRecordDTO.java new file mode 100644 index 000000000..a7cb63bac --- /dev/null +++ b/src/com/engine/salary/entity/datacollection/dto/SpecialAddDeductionRecordDTO.java @@ -0,0 +1,100 @@ +package com.engine.salary.entity.datacollection.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 com.fasterxml.jackson.annotation.JsonFormat; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Date; + +/** + * 其他免税扣除记录列表 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@SalaryTable(pageId = "a4f85287-e3f9-6612-adn9-7d98e54y6rj8", tableType = WeaTableType.CHECKBOX) +public class SpecialAddDeductionRecordDTO { + + //主键id + @SalaryTableColumn(column = "id", display = false) + private Long id; + + //员工id + private Long employeeId; + + private String username; + + //个税扣缴义务人 + @SalaryTableColumn(text = "个税扣缴义务人", width = "10%", column = "taxAgentName") + @TableTitle(title = "个税扣缴义务人", dataIndex = "taxAgentName", key = "taxAgentName") + private String taxAgentName; + /** + * 个税扣缴义务人id + */ + private Long taxAgentId; + + + //部门 + @SalaryTableColumn(text = "部门", width = "10%", column = "departmentName") + @TableTitle(title = "部门", dataIndex = "departmentName", key = "departmentName") + private String departmentName; + + //手机号 + @SalaryTableColumn(text = "手机号", width = "10%", column = "mobile") + @TableTitle(title = "手机号", dataIndex = "mobile", key = "mobile") + private String mobile; + + private String idNo; + + //工号 + @SalaryTableColumn(text = "工号", width = "10%", column = "jobNum") + @TableTitle(title = "工号", dataIndex = "jobNum", key = "jobNum") + private String jobNum; + + //子女教育 + @SalaryTableColumn(text = "子女教育", width = "10%", column = "childrenEducation") + @TableTitle(title = "子女教育", dataIndex = "childrenEducation", key = "childrenEducation") + private String childrenEducation; + + //继续教育 + @SalaryTableColumn(text = "继续教育", width = "10%", column = "continuingEducation") + @TableTitle(title = "继续教育", dataIndex = "continuingEducation", key = "continuingEducation") + private String continuingEducation; + + //住房贷款利息 + @SalaryTableColumn(text = "住房贷款利息", width = "10%", column = "housingLoanInterest") + @TableTitle(title = "住房贷款利息", dataIndex = "housingLoanInterest", key = "housingLoanInterest") + private String housingLoanInterest; + + //住房租金 + @SalaryTableColumn(text = "住房租金", width = "10%", column = "housingRent") + @TableTitle(title = "住房租金", dataIndex = "housingRent", key = "housingRent") + private String housingRent; + + //赡养老人 + @SalaryTableColumn(text = "赡养老人", width = "10%", column = "supportingElder") + @TableTitle(title = "赡养老人", dataIndex = "supportingElder", key = "supportingElder") + private String supportingElder; + + //大病医疗 + @SalaryTableColumn(text = "大病医疗", width = "10%", column = "seriousIllnessTreatment") + @TableTitle(title = "大病医疗", dataIndex = "seriousIllnessTreatment", key = "seriousIllnessTreatment") + private String seriousIllnessTreatment; + + //大病医疗 + @SalaryTableColumn(text = "婴幼儿照护", width = "10%", column = "infantCare") + @TableTitle(title = "婴幼儿照护", dataIndex = "infantCare", key = "infantCare") + private String infantCare; +} diff --git a/src/com/engine/salary/entity/datacollection/param/AddDeductionAutoAddParam.java b/src/com/engine/salary/entity/datacollection/param/AddDeductionAutoAddParam.java new file mode 100644 index 000000000..ba14a6f02 --- /dev/null +++ b/src/com/engine/salary/entity/datacollection/param/AddDeductionAutoAddParam.java @@ -0,0 +1,17 @@ +package com.engine.salary.entity.datacollection.param; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @description 数据采集-专项附加扣除一键累计参数 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class AddDeductionAutoAddParam { + String yearMonth = ""; +} diff --git a/src/com/engine/salary/entity/datacollection/param/SpecialAddDeductionImportParam.java b/src/com/engine/salary/entity/datacollection/param/SpecialAddDeductionImportParam.java new file mode 100644 index 000000000..d221c7a69 --- /dev/null +++ b/src/com/engine/salary/entity/datacollection/param/SpecialAddDeductionImportParam.java @@ -0,0 +1,28 @@ +package com.engine.salary.entity.datacollection.param; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 数据采集-累计专项附加扣除导入参数 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author lfc + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SpecialAddDeductionImportParam { + + //上传文件id + String imageId; + + //个税扣缴义务人 + String taxAgentId; + +} diff --git a/src/com/engine/salary/entity/datacollection/param/SpecialAddDeductionParam.java b/src/com/engine/salary/entity/datacollection/param/SpecialAddDeductionParam.java new file mode 100644 index 000000000..76408c9d4 --- /dev/null +++ b/src/com/engine/salary/entity/datacollection/param/SpecialAddDeductionParam.java @@ -0,0 +1,80 @@ +package com.engine.salary.entity.datacollection.param; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @author Harryxzy + * @date 2022/10/26 9:50 + * @description 数据采集-其他免税扣除 编辑参数 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SpecialAddDeductionParam { + + // 主键id + private Long id; + + // 员工id + private Long employeeId; + + private String username; + + // 个税扣缴义务人 + private String taxAgentName; + + // 个税扣缴义务人id + private Long taxAgentId; + + // 部门 + private String departmentName; + + // 手机号 + private String mobile; + + private String idNo; + + // 工号 + private String jobNum; + + /** + * 子女教育 + */ + private String childrenEducation; + + /** + * 继续教育 + */ + private String continuingEducation; + + /** + * 住房贷款利息 + */ + private String housingLoanInterest; + + /** + * 住房租金 + */ + private String housingRent; + + /** + * 赡养老人 + */ + private String supportingElder; + + /** + * 大病医疗 + */ + private String seriousIllnessTreatment; + + /** + * 婴幼儿照护 + */ + private String infantCare; + + +} diff --git a/src/com/engine/salary/entity/datacollection/param/SpecialAddDeductionQueryParam.java b/src/com/engine/salary/entity/datacollection/param/SpecialAddDeductionQueryParam.java new file mode 100644 index 000000000..a9e887bb7 --- /dev/null +++ b/src/com/engine/salary/entity/datacollection/param/SpecialAddDeductionQueryParam.java @@ -0,0 +1,57 @@ +package com.engine.salary.entity.datacollection.param; + +import com.engine.salary.common.BaseQueryParam; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Collection; +import java.util.Date; +import java.util.List; + + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//数据采集-其他免税扣除查询参数 +public class SpecialAddDeductionQueryParam extends BaseQueryParam { + + //主键id + private Collection ids; + + //关键字(姓名、部门、工号) + private String keyword; + + //主键id + private Long id; + + //姓名 + private String username; + + //员工id + private Long employeeId; + + //个税扣缴义务人的主键id + private Long taxAgentId; + private Collection taxAgentIds; + + //部门id + private List departmentIds; + + //工号 + private String jobNum; + + //证件号 + private String idNo; + + //入职日期 + private List hiredate; + + //手机号 + private String mobile; + + //其他免税扣除id(获取明细) + private Long specialAddDeductionId; +} diff --git a/src/com/engine/salary/entity/datacollection/param/SpecialAddDeductionRecordDeleteParam.java b/src/com/engine/salary/entity/datacollection/param/SpecialAddDeductionRecordDeleteParam.java new file mode 100644 index 000000000..58332b91a --- /dev/null +++ b/src/com/engine/salary/entity/datacollection/param/SpecialAddDeductionRecordDeleteParam.java @@ -0,0 +1,25 @@ +package com.engine.salary.entity.datacollection.param; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * @author lfc + * @description 专项附加扣-除删除参数 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SpecialAddDeductionRecordDeleteParam { + + // 删除id + private List ids; + + // 个税扣缴义务人 + private String taxAgentId; +} diff --git a/src/com/engine/salary/entity/datacollection/po/SpecialAddDeductionPO.java b/src/com/engine/salary/entity/datacollection/po/SpecialAddDeductionPO.java new file mode 100644 index 000000000..32cfe786b --- /dev/null +++ b/src/com/engine/salary/entity/datacollection/po/SpecialAddDeductionPO.java @@ -0,0 +1,90 @@ +package com.engine.salary.entity.datacollection.po; + +import java.util.Date; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +/** + * 数据采集-专项附加扣除表 + */ +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +@Accessors(chain = true) +public class SpecialAddDeductionPO { + private Long id; + + /** + * 人员信息表的主键id + */ + private Long employeeId; + + /** + * 个税扣缴义务人的主键id + */ + private Long taxAgentId; + + /** + * 子女教育 + */ + private String childrenEducation; + + /** + * 继续教育 + */ + private String continuingEducation; + + /** + * 住房贷款利息 + */ + private String housingLoanInterest; + + /** + * 住房租金 + */ + private String housingRent; + + /** + * 赡养老人 + */ + private String supportingElder; + + /** + * 大病医疗 + */ + private String seriousIllnessTreatment; + + /** + * 婴幼儿照护 + */ + private String infantCare; + + /** + * 创建时间 + */ + private Date createTime; + + /** + * 更新时间 + */ + private Date updateTime; + + /** + * 创建人 + */ + private Long creator; + + /** + * 是否已删除。0:未删除、1:已删除 + */ + private Integer deleteType; + + /** + * 租户ID + */ + private String tenantKey; +} \ No newline at end of file diff --git a/src/com/engine/salary/entity/salaryarchive/bo/SalaryArchiveExcelBO.java b/src/com/engine/salary/entity/salaryarchive/bo/SalaryArchiveExcelBO.java index 4e8062365..41bba094d 100644 --- a/src/com/engine/salary/entity/salaryarchive/bo/SalaryArchiveExcelBO.java +++ b/src/com/engine/salary/entity/salaryarchive/bo/SalaryArchiveExcelBO.java @@ -123,6 +123,7 @@ public class SalaryArchiveExcelBO extends Service { salaryArchiveErr = SalaryI18nUtil.getI18nLabel(101723, "该员工的薪资档案记录有误,请检查"); numberErr = SalaryI18nUtil.getI18nLabel(100581, "请输入数字"); + } /** diff --git a/src/com/engine/salary/mapper/datacollection/AddUpDeductionMapper.java b/src/com/engine/salary/mapper/datacollection/AddUpDeductionMapper.java index 15c1953af..6aedf838c 100644 --- a/src/com/engine/salary/mapper/datacollection/AddUpDeductionMapper.java +++ b/src/com/engine/salary/mapper/datacollection/AddUpDeductionMapper.java @@ -1,4 +1,5 @@ package com.engine.salary.mapper.datacollection; +import java.util.Date; import com.engine.salary.entity.datacollection.AddUpDeduction; import com.engine.salary.entity.datacollection.DataCollectionEmployee; @@ -61,6 +62,8 @@ public interface AddUpDeductionMapper { */ void updateData(@Param("collection") List updateList); + void updateDataAndDeclareMonth(@Param("collection") List updateList); + List recordList(@Param("param") AddUpDeductionQueryParam param); @@ -71,4 +74,8 @@ public interface AddUpDeductionMapper { * @date 2022/10/27 9:54 */ void deleteData(@Param("collection")List longs); + + int countByDeclareAfter(@Param("minDeclareMonth") Date minDeclareMonth, + @Param("maxDeclareMonth") Date maxDeclareMonth, + @Param("taxAgentIds") List taxAgentIds); } \ No newline at end of file diff --git a/src/com/engine/salary/mapper/datacollection/AddUpDeductionMapper.xml b/src/com/engine/salary/mapper/datacollection/AddUpDeductionMapper.xml index e90fdc37a..ebd2b723f 100644 --- a/src/com/engine/salary/mapper/datacollection/AddUpDeductionMapper.xml +++ b/src/com/engine/salary/mapper/datacollection/AddUpDeductionMapper.xml @@ -1,6 +1,24 @@ + + add_up_child_education, + add_up_continuing_education, + add_up_housing_loan_interest, + add_up_housing_rent, + add_up_support_elderly, + create_time, + creator, + declare_month, + delete_type, + employee_id, + id, + tax_agent_id, + tenant_key, + update_time, + add_up_illness_medical, + add_up_infant_care + @@ -553,6 +571,73 @@ + + update hrsa_add_up_deduction + + + + + when id=#{item.id} then #{item.addUpChildEducation} + + + + + + + when id=#{item.id} then #{item.addUpContinuingEducation} + + + + + + + when id=#{item.id} then #{item.addUpHousingLoanInterest} + + + + + + + when id=#{item.id} then #{item.addUpHousingRent} + + + + + + + when id=#{item.id} then #{item.addUpSupportElderly} + + + + + + + when id=#{item.id} then #{item.addUpIllnessMedical} + + + + + + + when id=#{item.id} then #{item.addUpInfantCare} + + + + + + + when id=#{item.id} then #{item.declareMonth} + + + + + where + id in + + #{item.id} + + + - + \ No newline at end of file diff --git a/src/com/engine/salary/mapper/datacollection/SpecialAddDeductionMapper.java b/src/com/engine/salary/mapper/datacollection/SpecialAddDeductionMapper.java new file mode 100644 index 000000000..995612ae7 --- /dev/null +++ b/src/com/engine/salary/mapper/datacollection/SpecialAddDeductionMapper.java @@ -0,0 +1,35 @@ +package com.engine.salary.mapper.datacollection; + +import com.engine.salary.entity.datacollection.dto.SpecialAddDeductionListDTO; +import com.engine.salary.entity.datacollection.dto.SpecialAddDeductionRecordDTO; +import com.engine.salary.entity.datacollection.param.SpecialAddDeductionQueryParam; +import com.engine.salary.entity.datacollection.po.SpecialAddDeductionPO; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +public interface SpecialAddDeductionMapper { + int insertSelective(SpecialAddDeductionPO record); + + int updateByPrimaryKeySelective(SpecialAddDeductionPO record); + + SpecialAddDeductionPO getById(Long id); + + int updateBatchSelective(@Param("list") List list); + + int batchInsert(@Param("list") List list); + + List listDtoByParam(@Param("param") SpecialAddDeductionQueryParam param); + + List listByTaxAgentIds(@Param("taxAgentIds") List taxAgentIds); + + List listByParam(@Param("param") SpecialAddDeductionQueryParam param); + + int deleteByIds(@Param("ids")List id); + + + List getByEmployeeIds(@Param("employeeIds") List employeeIds, + @Param("taxAgentId") Long taxAgentId); + + List listAll(); +} \ No newline at end of file diff --git a/src/com/engine/salary/mapper/datacollection/SpecialAddDeductionMapper.xml b/src/com/engine/salary/mapper/datacollection/SpecialAddDeductionMapper.xml new file mode 100644 index 000000000..1464a979e --- /dev/null +++ b/src/com/engine/salary/mapper/datacollection/SpecialAddDeductionMapper.xml @@ -0,0 +1,693 @@ + + + + + + + + + + + + + + + + + + + + + + + + + t1.id, + t1.employee_id, + t1.tax_agent_id, + t1.children_education, + t1.continuing_education, + t1.housing_loan_interest, + t1.housing_rent, + t1.supporting_elder, + t1.serious_illness_treatment, + t1.infant_care, + t1.create_time, + t1.update_time, + t1.creator, + t1.delete_type, + t1.tenant_key + + + + t1.id, + t1.employee_id, + t2.id AS tax_agent_id, + t2.name AS tax_agent_name, + e.lastname as username, + e.certificatenum as idNo, + d.departmentname AS departmentName, + e.mobile, + e.workcode as job_num, + e.companystartdate as hiredate, + t1.children_education, + t1.continuing_education, + t1.housing_loan_interest, + t1.housing_rent, + t1.serious_illness_treatment, + t1.supporting_elder, + t1.infant_care + + + + + AND t1.id IN + + #{id} + + + + AND t1.id = #{param.specialAddDeductionId} + + + AND t1.employee_id = #{param.employeeId} + + + + AND + ( + e.lastname like CONCAT('%',#{param.keyword},'%') + OR d.departmentname like CONCAT('%',#{param.keyword},'%') + OR e.workcode like CONCAT('%',#{param.keyword},'%') + ) + + + + AND e.lastname like CONCAT('%',#{param.username},'%') + + + + AND t1.tax_agent_id = #{param.taxAgentId} + + + AND t1.tax_agent_id IN + + #{id} + + + + + AND d.id IN + + #{id} + + + + + AND e.workcode like CONCAT('%',#{param.jobNum},'%') + + + + AND (e.companystartdate BETWEEN #{param.hiredate[0]} AND #{param.hiredate[1]}) + + + + AND e.mobile like CONCAT('%',#{param.mobile},'%') + + + + + AND t1.id IN + + #{id} + + + + AND t1.id = #{param.specialAddDeductionId} + + + AND t1.employee_id = #{param.employeeId} + + + + AND + ( + e.lastname like '%'||#{param.keyword}||'%' + OR d.departmentname like '%'||#{param.keyword}||'%' + OR e.workcode like '%'||#{param.keyword}||'%' + ) + + + + AND e.lastname like '%'||#{param.username}||'%' + + + + AND t1.tax_agent_id = #{param.taxAgentId} + + + AND t1.tax_agent_id IN + + #{id} + + + + AND d.id IN + + #{id} + + + + + AND e.workcode like '%'||#{param.jobNum}||'%' + + + + AND (e.companystartdate BETWEEN #{param.hiredate[0]} AND #{param.hiredate[1]}) + + + + AND e.mobile like '%'||#{param.mobile}||'%' + + + + + AND t1.id IN + + #{id} + + + + AND t1.id = #{param.specialAddDeductionId} + + + AND t1.employee_id = #{param.employeeId} + + + + AND + ( + e.lastname like '%'+#{param.keyword}+'%' + OR d.departmentname like '%'+#{param.keyword}+'%' + OR e.workcode like '%'+#{param.keyword}+'%' + ) + + + + AND e.lastname like '%'+#{param.username}+'%' + + + + AND t1.tax_agent_id = #{param.taxAgentId} + + + AND t1.tax_agent_id IN + + #{id} + + + + AND d.id IN + + #{id} + + + + + AND e.workcode like '%'+#{param.jobNum}+'%' + + + + AND (e.companystartdate BETWEEN #{param.hiredate[0]} AND #{param.hiredate[1]}) + + + + AND e.mobile like '%'+#{param.mobile}+'%' + + + + + + + insert into hrsa_special_add_deduction + + + employee_id, + + + tax_agent_id, + + + children_education, + + + continuing_education, + + + housing_loan_interest, + + + housing_rent, + + + supporting_elder, + + + serious_illness_treatment, + + + infant_care, + + + create_time, + + + update_time, + + + creator, + + delete_type, + + tenant_key, + + + + + #{employeeId,jdbcType=BIGINT}, + + + #{taxAgentId,jdbcType=BIGINT}, + + + #{childrenEducation,jdbcType=VARCHAR}, + + + #{continuingEducation,jdbcType=VARCHAR}, + + + #{housingLoanInterest,jdbcType=VARCHAR}, + + + #{housingRent,jdbcType=VARCHAR}, + + + #{supportingElder,jdbcType=VARCHAR}, + + + #{seriousIllnessTreatment,jdbcType=VARCHAR}, + + + #{infantCare,jdbcType=VARCHAR}, + + + #{createTime,jdbcType=TIMESTAMP}, + + + #{updateTime,jdbcType=TIMESTAMP}, + + + #{creator,jdbcType=BIGINT}, + + 0, + + #{tenantKey,jdbcType=VARCHAR}, + + + + + + select hrsa_special_a_d_id.currval from dual + + insert into hrsa_special_add_deduction + + + employee_id, + + + tax_agent_id, + + + children_education, + + + continuing_education, + + + housing_loan_interest, + + + housing_rent, + + + supporting_elder, + + + serious_illness_treatment, + + + infant_care, + + + create_time, + + + update_time, + + + creator, + + delete_type, + + tenant_key, + + + + + #{employeeId,jdbcType=BIGINT}, + + + #{taxAgentId,jdbcType=BIGINT}, + + + #{childrenEducation,jdbcType=VARCHAR}, + + + #{continuingEducation,jdbcType=VARCHAR}, + + + #{housingLoanInterest,jdbcType=VARCHAR}, + + + #{housingRent,jdbcType=VARCHAR}, + + + #{supportingElder,jdbcType=VARCHAR}, + + + #{seriousIllnessTreatment,jdbcType=VARCHAR}, + + + #{infantCare,jdbcType=VARCHAR}, + + + #{createTime,jdbcType=TIMESTAMP}, + + + #{updateTime,jdbcType=TIMESTAMP}, + + + #{creator,jdbcType=BIGINT}, + + 0, + + #{tenantKey,jdbcType=VARCHAR}, + + + + + + update hrsa_special_add_deduction + + + employee_id = #{employeeId,jdbcType=BIGINT}, + + + tax_agent_id = #{taxAgentId,jdbcType=BIGINT}, + + + children_education = #{childrenEducation,jdbcType=VARCHAR}, + + + continuing_education = #{continuingEducation,jdbcType=VARCHAR}, + + + housing_loan_interest = #{housingLoanInterest,jdbcType=VARCHAR}, + + + housing_rent = #{housingRent,jdbcType=VARCHAR}, + + + supporting_elder = #{supportingElder,jdbcType=VARCHAR}, + + + serious_illness_treatment = #{seriousIllnessTreatment,jdbcType=VARCHAR}, + + + infant_care = #{infantCare,jdbcType=VARCHAR}, + + + create_time = #{createTime,jdbcType=TIMESTAMP}, + + + update_time = #{updateTime,jdbcType=TIMESTAMP}, + + + creator = #{creator,jdbcType=BIGINT}, + + + delete_type = #{deleteType,jdbcType=INTEGER}, + + + tenant_key = #{tenantKey,jdbcType=VARCHAR}, + + + where id = #{id,jdbcType=BIGINT} + + + + + update hrsa_special_add_deduction + + + + + when id = #{item.id,jdbcType=BIGINT} then #{item.employeeId,jdbcType=BIGINT} + + + + + + + when id = #{item.id,jdbcType=BIGINT} then #{item.taxAgentId,jdbcType=BIGINT} + + + + + + + when id = #{item.id,jdbcType=BIGINT} then #{item.childrenEducation,jdbcType=VARCHAR} + + + + + + + when id = #{item.id,jdbcType=BIGINT} then #{item.continuingEducation,jdbcType=VARCHAR} + + + + + + + when id = #{item.id,jdbcType=BIGINT} then #{item.housingLoanInterest,jdbcType=VARCHAR} + + + + + + + when id = #{item.id,jdbcType=BIGINT} then #{item.housingRent,jdbcType=VARCHAR} + + + + + + + when id = #{item.id,jdbcType=BIGINT} then #{item.supportingElder,jdbcType=VARCHAR} + + + + + + + when id = #{item.id,jdbcType=BIGINT} then #{item.seriousIllnessTreatment,jdbcType=VARCHAR} + + + + + + + when id = #{item.id,jdbcType=BIGINT} then #{item.infantCare,jdbcType=VARCHAR} + + + + + + + when id = #{item.id,jdbcType=BIGINT} then #{item.createTime,jdbcType=TIMESTAMP} + + + + + + + when id = #{item.id,jdbcType=BIGINT} then #{item.updateTime,jdbcType=TIMESTAMP} + + + + + + + when id = #{item.id,jdbcType=BIGINT} then #{item.creator,jdbcType=BIGINT} + + + + + + + when id = #{item.id,jdbcType=BIGINT} then #{item.deleteType,jdbcType=INTEGER} + + + + + + + when id = #{item.id,jdbcType=BIGINT} then #{item.tenantKey,jdbcType=VARCHAR} + + + + + where id in + + #{item.id,jdbcType=BIGINT} + + + + + + insert into hrsa_special_add_deduction + (employee_id, tax_agent_id, children_education, continuing_education, + housing_loan_interest, housing_rent, supporting_elder, serious_illness_treatment, + infant_care, create_time, update_time, creator, delete_type, tenant_key) + values + + (#{item.employeeId,jdbcType=BIGINT}, #{item.taxAgentId,jdbcType=BIGINT}, + #{item.childrenEducation,jdbcType=VARCHAR}, #{item.continuingEducation,jdbcType=VARCHAR}, + #{item.housingLoanInterest,jdbcType=VARCHAR}, #{item.housingRent,jdbcType=VARCHAR}, + #{item.supportingElder,jdbcType=VARCHAR}, #{item.seriousIllnessTreatment,jdbcType=VARCHAR}, + #{item.infantCare,jdbcType=VARCHAR}, #{item.createTime,jdbcType=TIMESTAMP}, + #{item.updateTime,jdbcType=TIMESTAMP}, + #{item.creator,jdbcType=BIGINT}, 0, #{item.tenantKey,jdbcType=VARCHAR}) + + + + + insert into hrsa_special_add_deduction + (employee_id, tax_agent_id, children_education, continuing_education, + housing_loan_interest, housing_rent, supporting_elder, serious_illness_treatment, + infant_care, create_time, update_time, creator, delete_type, tenant_key) + + select + #{item.employeeId,jdbcType=BIGINT}, #{item.taxAgentId,jdbcType=BIGINT}, + #{item.childrenEducation,jdbcType=VARCHAR}, #{item.continuingEducation,jdbcType=VARCHAR}, + #{item.housingLoanInterest,jdbcType=VARCHAR}, #{item.housingRent,jdbcType=VARCHAR}, + #{item.supportingElder,jdbcType=VARCHAR}, #{item.seriousIllnessTreatment,jdbcType=VARCHAR}, + #{item.infantCare,jdbcType=VARCHAR}, #{item.createTime,jdbcType=TIMESTAMP}, + #{item.updateTime,jdbcType=TIMESTAMP}, + #{item.creator,jdbcType=BIGINT}, 0, #{item.tenantKey,jdbcType=VARCHAR} + from dual + + + + + + + + + + + update hrsa_special_add_deduction + set delete_type = 1 + where id in ( + + #{id} + + ) and delete_type = 0 + + + + + + \ No newline at end of file diff --git a/src/com/engine/salary/mapper/salaryacct/SalaryAcctRecordMapper.java b/src/com/engine/salary/mapper/salaryacct/SalaryAcctRecordMapper.java index 4d53cff06..eda9abadb 100644 --- a/src/com/engine/salary/mapper/salaryacct/SalaryAcctRecordMapper.java +++ b/src/com/engine/salary/mapper/salaryacct/SalaryAcctRecordMapper.java @@ -1,10 +1,12 @@ package com.engine.salary.mapper.salaryacct; +import com.engine.salary.common.LocalDateRange; import com.engine.salary.entity.salaryacct.po.SalaryAcctRecordPO; import org.apache.ibatis.annotations.Param; import java.util.Collection; import java.util.List; +import java.util.Set; public interface SalaryAcctRecordMapper { @@ -71,4 +73,5 @@ public interface SalaryAcctRecordMapper { */ void deleteByIds(@Param("ids") Collection ids); + List listByCreateDate(@Param(value = "createRange") LocalDateRange createRange, @Param(value = "salarySobIds") Set salarySobIds); } \ No newline at end of file diff --git a/src/com/engine/salary/mapper/salaryacct/SalaryAcctRecordMapper.xml b/src/com/engine/salary/mapper/salaryacct/SalaryAcctRecordMapper.xml index 5e1e0b404..123da569a 100644 --- a/src/com/engine/salary/mapper/salaryacct/SalaryAcctRecordMapper.xml +++ b/src/com/engine/salary/mapper/salaryacct/SalaryAcctRecordMapper.xml @@ -117,6 +117,25 @@ ORDER BY id DESC + diff --git a/src/com/engine/salary/mapper/sys/SalarySysConfMapper.java b/src/com/engine/salary/mapper/sys/SalarySysConfMapper.java index 2b3596f74..36e3a4d37 100644 --- a/src/com/engine/salary/mapper/sys/SalarySysConfMapper.java +++ b/src/com/engine/salary/mapper/sys/SalarySysConfMapper.java @@ -2,6 +2,7 @@ package com.engine.salary.mapper.sys; import com.engine.salary.sys.entity.po.SalarySysConfPO; +import java.util.Date; import java.util.List; public interface SalarySysConfMapper { @@ -64,4 +65,12 @@ public interface SalarySysConfMapper { SalarySysConfPO getOneByCode(String confKey); int countByCode(String confKey); + + /** + * @description 获取个税申报功能重启时间 + * @return Date + * @author Harryxzy + * @date 2022/11/9 21:09 + */ + Date getTaxDeclarationRebootDate(); } \ No newline at end of file diff --git a/src/com/engine/salary/mapper/sys/SalarySysConfMapper.xml b/src/com/engine/salary/mapper/sys/SalarySysConfMapper.xml index 221900da7..3d0c299c4 100644 --- a/src/com/engine/salary/mapper/sys/SalarySysConfMapper.xml +++ b/src/com/engine/salary/mapper/sys/SalarySysConfMapper.xml @@ -233,5 +233,8 @@ WHERE delete_type = 0 AND conf_key = #{confKey} + \ No newline at end of file diff --git a/src/com/engine/salary/service/AddUpDeductionService.java b/src/com/engine/salary/service/AddUpDeductionService.java index 1b4a7aba7..d65082de7 100644 --- a/src/com/engine/salary/service/AddUpDeductionService.java +++ b/src/com/engine/salary/service/AddUpDeductionService.java @@ -12,6 +12,7 @@ import com.engine.salary.util.page.PageInfo; import org.apache.poi.xssf.usermodel.XSSFWorkbook; import java.time.YearMonth; +import java.util.Date; import java.util.List; import java.util.Map; @@ -147,4 +148,11 @@ public interface AddUpDeductionService { * @date 2022/10/31 11:33 */ AddUpDeductionRecordDTO getAddUpDeduction(AddUpDeductionQueryParam id); + + /** + * 自动累计专项附加扣除 + * @return void + * @author lfc + */ + String autoAddAll(Date yearMonth); } diff --git a/src/com/engine/salary/service/SalaryArchiveService.java b/src/com/engine/salary/service/SalaryArchiveService.java index c2ee80e3b..296a31fb7 100644 --- a/src/com/engine/salary/service/SalaryArchiveService.java +++ b/src/com/engine/salary/service/SalaryArchiveService.java @@ -215,4 +215,8 @@ public interface SalaryArchiveService { String cancelStop(Collection ids); + /** + * 处理异常数据 + */ + Map handleRepeatData(); } diff --git a/src/com/engine/salary/service/SpecialAddDeductionService.java b/src/com/engine/salary/service/SpecialAddDeductionService.java new file mode 100644 index 000000000..d2f893323 --- /dev/null +++ b/src/com/engine/salary/service/SpecialAddDeductionService.java @@ -0,0 +1,105 @@ +package com.engine.salary.service; + +import com.engine.salary.entity.datacollection.dto.SpecialAddDeductionListDTO; +import com.engine.salary.entity.datacollection.dto.SpecialAddDeductionRecordDTO; +import com.engine.salary.entity.datacollection.param.*; +import com.engine.salary.entity.datacollection.po.SpecialAddDeductionPO; +import com.engine.salary.util.page.PageInfo; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + +import java.time.YearMonth; +import java.util.Date; +import java.util.List; +import java.util.Map; + +/** + * 数据采集-其他免税扣除 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author lfc + * @version 1.0 + **/ +public interface SpecialAddDeductionService { + + /** + * 通过id获取单条专项扣除记录 + * + * @param id + * @return + */ + SpecialAddDeductionPO getById(Long id); + + /** + * 数据采集-其他免税扣除列表 + * + * @param queryParam + * @return + */ + PageInfo listPage(SpecialAddDeductionQueryParam queryParam); + + /** + * 获取数据采集-其他免税扣除详情 + * + * @param queryParam + * @return + */ + PageInfo recordListPage(SpecialAddDeductionQueryParam queryParam); + + /** + * 导出 + * + */ + XSSFWorkbook export(SpecialAddDeductionQueryParam queryParam, boolean isTemplate); + + /** + * 导出详情 + * + */ + XSSFWorkbook exportDetail(SpecialAddDeductionQueryParam queryParam); + + /** + * 预览 + */ + Map preview(SpecialAddDeductionImportParam importParam); + + /** + * 导入数据 + */ + Map importData(SpecialAddDeductionImportParam importParam); + + + + /** + * 获取其他免税扣除数据 + * + * @param declareMonth + * @param employeeIds + * @return + */ + List getSpecialAddDeductionList(YearMonth declareMonth, List employeeIds, Long taxAgentId); + + /** + * 编辑数据 + */ + void editData(SpecialAddDeductionParam SpecialAddDeductionParam); + + /** + * 新增数据 + */ + void createData(SpecialAddDeductionParam SpecialAddDeductionParam); + + /** + * 删除所选数据 + */ + void deleteSelectData(SpecialAddDeductionRecordDeleteParam deleteParam); + + /** + * 一键清空数据 + */ + void deleteAllData(SpecialAddDeductionRecordDeleteParam deleteParam); + + List getSpecialAddDeductionPOByEmployee(List employeeId, Long taxAgentId); + + SpecialAddDeductionRecordDTO getRecordById(Long id); +} diff --git a/src/com/engine/salary/service/impl/AddUpDeductionServiceImpl.java b/src/com/engine/salary/service/impl/AddUpDeductionServiceImpl.java index e7086f94c..9e70182e7 100644 --- a/src/com/engine/salary/service/impl/AddUpDeductionServiceImpl.java +++ b/src/com/engine/salary/service/impl/AddUpDeductionServiceImpl.java @@ -1,5 +1,7 @@ package com.engine.salary.service.impl; +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.StrUtil; import com.api.browser.bean.SearchConditionGroup; import com.api.browser.bean.SearchConditionItem; import com.api.browser.util.ConditionFactory; @@ -10,6 +12,7 @@ import com.engine.core.impl.Service; import com.engine.salary.biz.AddUpDeductionBiz; import com.engine.salary.biz.EmployBiz; import com.engine.salary.common.LocalDateRange; +import com.engine.salary.encrypt.datacollection.AddUpDeductionEncrypt; import com.engine.salary.encrypt.datacollection.AddUpDeductionRecordStrDTOEncrypt; import com.engine.salary.encrypt.datacollection.AddUpDeductionStrDTOEncrypt; import com.engine.salary.entity.datacollection.AddUpDeduction; @@ -20,6 +23,7 @@ import com.engine.salary.entity.datacollection.param.AddUpDeductionImportParam; import com.engine.salary.entity.datacollection.param.AddUpDeductionQueryParam; import com.engine.salary.entity.datacollection.param.AddUpDeductionRecordDeleteParam; import com.engine.salary.entity.datacollection.param.AddUpDeductionRecordParam; +import com.engine.salary.entity.datacollection.po.SpecialAddDeductionPO; import com.engine.salary.entity.salaryacct.po.SalaryAcctEmployeePO; import com.engine.salary.entity.salaryacct.po.SalaryAcctRecordPO; import com.engine.salary.entity.taxagent.bo.TaxAgentBO; @@ -57,13 +61,14 @@ import weaver.general.Util; import weaver.hrm.User; import java.io.InputStream; +import java.math.BigDecimal; import java.text.SimpleDateFormat; -import java.time.LocalDate; -import java.time.YearMonth; +import java.time.*; import java.util.*; import java.util.stream.Collectors; import static com.engine.salary.constant.SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY; + /** * 累计专项 *

Copyright: Copyright (c) 2022

@@ -99,7 +104,11 @@ public class AddUpDeductionServiceImpl extends Service implements AddUpDeduction } private SalarySysConfService getSalarySysConfService(User user) { - return ServiceUtil.getService(SalarySysConfServiceImpl.class, user); + return ServiceUtil.getService(SalarySysConfServiceImpl.class, user); + } + + private SpecialAddDeductionService getSpecialAddDeductionService(User user) { + return ServiceUtil.getService(SpecialAddDeductionServiceImpl.class, user); } @Override @@ -283,7 +292,7 @@ public class AddUpDeductionServiceImpl extends Service implements AddUpDeduction errorMessageMap.put("message", rowIndex + "员工信息不存在或者存在多个员工"); errorData.add(errorMessageMap); errorSum += 1; - }else{ + } else { Long employeeId = CollectionUtils.isNotEmpty(employeeSameIds) && employeeSameIds.size() == 1 ? employeeSameIds.get(0).getEmployeeId() : null; addUpDeduction.setEmployeeId(employeeId); } @@ -401,12 +410,12 @@ public class AddUpDeductionServiceImpl extends Service implements AddUpDeduction // 获取所有个税扣缴义务人 Collection taxAgentList = getTaxAgentService(user).listTaxAgentAndEmployeeTree(currentEmployeeId); AddUpDeduction byId = addUpDeductionBiz.getById(addUpDeduction.getId()); - if(byId == null){ + if (byId == null) { throw new SalaryRunTimeException("该数据不存在!"); } Long taxAgentId = byId.getTaxAgentId(); - boolean canEdit = taxAgentList.stream().anyMatch(t -> t.getTaxAgentId() == taxAgentId); - if(!canEdit){ + boolean canEdit = taxAgentList.stream().anyMatch(t -> Objects.equals(t.getTaxAgentId() , taxAgentId)); + if (!canEdit) { //没有编辑权限 throw new SalaryRunTimeException("该个税扣缴义务人无权限编辑此数据!"); } @@ -436,7 +445,7 @@ public class AddUpDeductionServiceImpl extends Service implements AddUpDeduction //税款所属期 String declareMonthStr = addUpDeductionRecordParam.getDeclareMonth(); - if(declareMonthStr == ""){ + if (declareMonthStr .equals("")) { throw new SalaryRunTimeException("税款所属期不能为空!"); } // 获取所有个税扣缴义务人 @@ -464,7 +473,7 @@ public class AddUpDeductionServiceImpl extends Service implements AddUpDeduction .updateTime(now) .creator((long) user.getUID()) .declareMonth(declareMonth).build(); - boolean employeeSameId = employees.stream().anyMatch(e -> e.getEmployeeId() == addUpDeductionRecordParam.getEmployeeId()); + boolean employeeSameId = employees.stream().anyMatch(e -> Objects.equals(e.getEmployeeId() , addUpDeductionRecordParam.getEmployeeId())); if (!employeeSameId) { throw new SalaryRunTimeException("员工信息不存在"); } @@ -485,7 +494,7 @@ public class AddUpDeductionServiceImpl extends Service implements AddUpDeduction } } - //fixme 分权判断 + //fixme 分权判断 // if (openDevolution) { // Optional optionalTaxAgentEmp = taxAgentEmployees.stream().filter(f -> f.getEmployeeId().equals(addUpDeduction.getEmployeeId())).findFirst(); // if (!optionalTaxAgentEmp.isPresent()) { @@ -541,15 +550,15 @@ public class AddUpDeductionServiceImpl extends Service implements AddUpDeduction List salaryAcctEmployees = getAccountedEmployeeData(declareMonthStr); // 判断是否有核算过 List deleteList = new ArrayList<>(); - for(int i=0; i first = taxAgentList.stream().filter(m -> m.getTaxAgentId() == byId.getTaxAgentId()).findFirst(); - if(!first.isPresent()){ + Optional first = taxAgentList.stream().filter(m -> Objects.equals(m.getTaxAgentId() , byId.getTaxAgentId())).findFirst(); + if (!first.isPresent()) { throw new SalaryRunTimeException("个税扣缴义务人不存在或不在权限范围内"); } // 判断用户是否存在 @@ -575,33 +584,33 @@ public class AddUpDeductionServiceImpl extends Service implements AddUpDeduction AddUpDeductionBiz addUpDeductionBiz = new AddUpDeductionBiz(); ArrayList declareMonthDate = new ArrayList<>(); try { - declareMonthDate.add(sdf.parse(declareMonthStr+"-01")); - }catch (Exception e){ + declareMonthDate.add(sdf.parse(declareMonthStr + "-01")); + } catch (Exception e) { throw new SalaryRunTimeException("日期异常"); } AddUpDeductionQueryParam queryParam = null; - if(deleteParam.getTaxAgentId() != null && (!deleteParam.getTaxAgentId().equals(""))){ + if (deleteParam.getTaxAgentId() != null && (!deleteParam.getTaxAgentId().equals(""))) { // 设置了个税扣缴义务人 Long taxAgentId = SalaryEntityUtil.string2Long(deleteParam.getTaxAgentId()); - boolean canDelete = taxAgentIds.stream().anyMatch(t -> t == taxAgentId); - if(!canDelete){ + boolean canDelete = taxAgentIds.stream().anyMatch(t -> Objects.equals(t , taxAgentId)); + if (!canDelete) { throw new SalaryRunTimeException("个税扣缴义务人不存在或不在权限范围内!"); } ArrayList tai = new ArrayList<>(); tai.add(taxAgentId); - queryParam = AddUpDeductionQueryParam.builder().declareMonthDate(declareMonthDate).taxAgentIds(tai).build(); - }else { + queryParam = AddUpDeductionQueryParam.builder().declareMonthDate(declareMonthDate).taxAgentIds(tai).build(); + } else { queryParam = AddUpDeductionQueryParam.builder().declareMonthDate(declareMonthDate).taxAgentIds(taxAgentIds).build(); } // 获取所有想要删除的数据 List list = addUpDeductionBiz.list(queryParam); // 获取已经核算的数据 List salaryAcctEmployees = getAccountedEmployeeData(declareMonthStr); - for(AddUpDeductionDTO item : list){ + for (AddUpDeductionDTO item : list) { if (CollectionUtils.isNotEmpty(salaryAcctEmployees)) { Optional optionalAcctEmp = salaryAcctEmployees.stream().filter(f -> f.getEmployeeId().equals(item.getEmployeeId()) && f.getTaxAgentId().equals(item.getTaxAgentId())).findFirst(); if (optionalAcctEmp.isPresent()) { - throw new SalaryRunTimeException("员工:"+item.getUsername()+",在该年月中已完成核算并归档,不能进行一键清空!"); + throw new SalaryRunTimeException("员工:" + item.getUsername() + ",在该年月中已完成核算并归档,不能进行一键清空!"); } } } @@ -619,16 +628,164 @@ public class AddUpDeductionServiceImpl extends Service implements AddUpDeduction ids.add(param.getId()); AddUpDeductionQueryParam build = AddUpDeductionQueryParam.builder().ids(ids).build(); List addUpDeductionRecordDTOS = new AddUpDeductionBiz().recordList(build); - if(addUpDeductionRecordDTOS==null || addUpDeductionRecordDTOS.size()==0){ + if (addUpDeductionRecordDTOS == null || addUpDeductionRecordDTOS.size() == 0) { throw new SalaryRunTimeException("该数据不存在!"); } String taxAgentName = addUpDeductionRecordDTOS.get(0).getTaxAgentName(); - if(!taxAgentNames.contains(taxAgentName)){ + if (!taxAgentNames.contains(taxAgentName)) { throw new SalaryRunTimeException("您无权查看该数据!"); } return addUpDeductionRecordDTOS.get(0); } + @Override + public String autoAddAll(Date yearMonth) { + int uid = user.getUID(); + Boolean isChief = getTaxAgentService(user).isChief((long) uid); + Collection taxAgents; + if (isChief) { + taxAgents = getTaxAgentService(user).listAll(); + } else { + taxAgents = getTaxAgentService(user).listAllTaxAgentsAsAdmin((long) uid); + } + LocalDateTime yearMonthTime = DateUtil.toLocalDateTime(yearMonth); + //设置时间到下一年1月1号 + Instant instant = yearMonthTime.plusYears(1L) + .withMonth(1).withDayOfMonth(1) + .atZone(ZoneOffset.systemDefault()).toInstant(); + Date nextYearStart = Date.from(instant); + int countByDeclareAfter = getAddUpDeductionMapper() + .countByDeclareAfter(yearMonth, nextYearStart, + taxAgents.stream().map(TaxAgentPO::getId).collect(Collectors.toList()) + ); + if (countByDeclareAfter > 0) { + throw new SalaryRunTimeException("无法累计,请检查当前累计年度内该月后是否有累计专项附加扣除记录!"); + } + List updateList = new ArrayList<>(); + List insertList = new ArrayList<>(); + List errorMessages = new ArrayList<>(); + List accountedEmployeeData = + getAccountedEmployeeData(DateUtil.format(yearMonth, "yyyy-MM")); + for (TaxAgentPO taxAgent : taxAgents) { + Collection employeeIds = getTaxAgentService(user) + .listEmployeeIdsInTaxAgent(taxAgent.getId()); + List employeePOs = getSpecialAddDeductionService(user) + .getSpecialAddDeductionPOByEmployee(null, taxAgent.getId()); + + + //获取上月员工数据,用于累加 + LocalDateTime lastMonthDateTime = yearMonthTime.minusMonths(1); + YearMonth lastMonth = YearMonth.of(lastMonthDateTime.getYear(), lastMonthDateTime.getMonth()); + Map> lastEmpInfo = getEmpInfoByYearMonth(taxAgent, employeePOs, lastMonth); + + //获取当月员工数据,用于更新 + YearMonth currentMonth = YearMonth.of(yearMonthTime.getYear(), yearMonthTime.getMonth()); + Map> currentEmpInfo = getEmpInfoByYearMonth(taxAgent, employeePOs, currentMonth); + + employeePOs.forEach(employeePO -> { + Long employeeId = employeePO.getEmployeeId(); + // 如果该员工当前月份已经核算,不做累计 + SalaryAcctEmployeePO anyAccountedEmployee = accountedEmployeeData.stream() + .filter(e -> e.getEmployeeId().equals(employeeId)) + .filter(e -> e.getTaxAgentId().equals(taxAgent.getId())) + .findAny().orElse(null); + if (anyAccountedEmployee != null) { + errorMessages.add(employeeId); + return; + } + AddUpDeduction addUpDeduction = Optional.ofNullable(lastEmpInfo.get(employeeId)) + .flatMap(list -> list.stream().findFirst()) + .orElseGet(AddUpDeduction::new); + this.combine(addUpDeduction, employeePO); + + addUpDeduction.setEmployeeId(employeeId); + addUpDeduction.setTaxAgentId(taxAgent.getId()); + addUpDeduction.setDeclareMonth(DateUtil.beginOfMonth(yearMonth)); + addUpDeduction.setCreator((long) user.getUID()); + addUpDeduction.setTenantKey(DEFAULT_TENANT_KEY); + + //确认当期是否有已经累计的记录 + AddUpDeduction oldInfo = Optional.ofNullable(currentEmpInfo.get(employeeId)) + .flatMap(c -> c.stream().findFirst()) + .orElse(null); + if (oldInfo == null) { + addUpDeduction.setCreateTime(yearMonth); + addUpDeduction.setUpdateTime(yearMonth); + insertList.add(AddUpDeductionEncrypt.encryptAddUpDeduction(addUpDeduction)); + } else { + addUpDeduction.setId(oldInfo.getId()); + addUpDeduction.setCreateTime(oldInfo.getCreateTime()); + addUpDeduction.setUpdateTime(yearMonth); + updateList.add(AddUpDeductionEncrypt.encryptAddUpDeduction(addUpDeduction)); + } + }); + } + Lists.partition(insertList, 100) + .forEach(l -> getAddUpDeductionMapper().insertData((List) l)); + Lists.partition(updateList, 100) + .forEach(l -> getAddUpDeductionMapper().updateDataAndDeclareMonth((List) l)); + if (!errorMessages.isEmpty()) { + String userNames = getSalaryEmployeeService(user) + .listByIds(errorMessages) + .stream() + .map(DataCollectionEmployee::getUsername) + .collect(Collectors.joining(",")); + return "一键累计完成!员工" + userNames + "在该年月已核算归档,跳过本次累计"; + } + return "一键累计完成!"; + } + + /** + * 对每个扣除项做加法 + * + * @param addUpDeduction 上次记录 + * @param employeePO 专项附加扣除值 + */ + private void combine(AddUpDeduction addUpDeduction, SpecialAddDeductionPO employeePO) { + final String zero = "0"; + String childEducation = Optional.ofNullable(addUpDeduction.getAddUpChildEducation()).orElse(zero); + addUpDeduction.setAddUpChildEducation(plus(childEducation, employeePO.getChildrenEducation())); + + String continuingEducation = Optional.ofNullable(addUpDeduction.getAddUpContinuingEducation()).orElse(zero); + addUpDeduction.setAddUpContinuingEducation(plus(continuingEducation, employeePO.getContinuingEducation())); + + String housingLoanInterest = Optional.ofNullable(addUpDeduction.getAddUpHousingLoanInterest()).orElse(zero); + addUpDeduction.setAddUpHousingLoanInterest(plus(housingLoanInterest, employeePO.getHousingLoanInterest())); + + String housingRent = Optional.ofNullable(addUpDeduction.getAddUpHousingRent()).orElse(zero); + addUpDeduction.setAddUpHousingRent(plus(housingRent, employeePO.getHousingRent())); + + String supportElderly = Optional.ofNullable(addUpDeduction.getAddUpSupportElderly()).orElse(zero); + addUpDeduction.setAddUpSupportElderly(plus(supportElderly, employeePO.getSupportingElder())); + + String illnessMedical = Optional.ofNullable(addUpDeduction.getAddUpIllnessMedical()).orElse(zero); + addUpDeduction.setAddUpIllnessMedical(plus(illnessMedical, employeePO.getSeriousIllnessTreatment())); + + String infantCare = Optional.ofNullable(addUpDeduction.getAddUpInfantCare()).orElse(zero); + addUpDeduction.setAddUpInfantCare(plus(infantCare, employeePO.getInfantCare())); + } + + private String plus(String var0, String var1) { + if (StrUtil.isEmpty(var0)) { + var0 = "0"; + } + if (StrUtil.isEmpty(var1)) { + var1 = "0"; + } + return new BigDecimal(var0) + .add(new BigDecimal(var1)) + .toString(); + } + + private Map> getEmpInfoByYearMonth(TaxAgentPO taxAgent, List employeePOs, YearMonth lastMonth) { + List addUpDeductionList = getAddUpDeductionList(lastMonth, + employeePOs.stream().map(SpecialAddDeductionPO::getEmployeeId).collect(Collectors.toList()), + taxAgent.getId()); + return addUpDeductionList.stream() + .filter(addUpDeduction -> taxAgent.getId().equals(addUpDeduction.getTaxAgentId())) + .collect(Collectors.groupingBy(AddUpDeduction::getEmployeeId)); + } + private void checkImportParam(AddUpDeductionImportParam importParam) { @@ -906,7 +1063,7 @@ public class AddUpDeductionServiceImpl extends Service implements AddUpDeduction } List list = new AddUpDeductionBiz().list(queryParam); - for(AddUpDeductionDTO dto : list) { + for (AddUpDeductionDTO dto : list) { Map resultMap = new HashMap<>(); resultMap.put("username", Util.null2String(dto.getUsername())); resultMap.put("departmentName", Util.null2String(dto.getDepartmentName())); diff --git a/src/com/engine/salary/service/impl/AddUpSituationServiceImpl.java b/src/com/engine/salary/service/impl/AddUpSituationServiceImpl.java index 94d770e82..ee52107f4 100644 --- a/src/com/engine/salary/service/impl/AddUpSituationServiceImpl.java +++ b/src/com/engine/salary/service/impl/AddUpSituationServiceImpl.java @@ -846,7 +846,7 @@ public class AddUpSituationServiceImpl extends Service implements AddUpSituation throw new SalaryRunTimeException("该数据不存在!"); } Long taxAgentId = byId.getTaxAgentId(); - boolean canEdit = taxAgentList.stream().anyMatch(t -> t.getTaxAgentId() == taxAgentId); + boolean canEdit = taxAgentList.stream().anyMatch(t -> Objects.equals(t.getTaxAgentId() , taxAgentId)); if(!canEdit){ //没有编辑权限 throw new SalaryRunTimeException("该个税扣缴义务人无权限编辑此数据!"); @@ -922,7 +922,7 @@ public class AddUpSituationServiceImpl extends Service implements AddUpSituation //筛选导入人员信息可以在人力资源池中匹配到的人员信息 - boolean employeeSameId = employees.stream().anyMatch(e -> e.getEmployeeId() == addUpSituationParam.getEmployeeId()); + boolean employeeSameId = employees.stream().anyMatch(e -> Objects.equals(e.getEmployeeId() , addUpSituationParam.getEmployeeId())); if(!employeeSameId){ throw new SalaryRunTimeException("员工信息不存在"); } @@ -1033,7 +1033,7 @@ public class AddUpSituationServiceImpl extends Service implements AddUpSituation throw new SalaryRunTimeException("数据不存在或已被删除!"); } // 判断是否在个税扣缴义务人范围内 - Optional first = taxAgentList.stream().filter(m -> m.getTaxAgentId() == byId.getTaxAgentId()).findFirst(); + Optional first = taxAgentList.stream().filter(m -> Objects.equals(m.getTaxAgentId() , byId.getTaxAgentId())).findFirst(); if(!first.isPresent()){ throw new SalaryRunTimeException("个税扣缴义务人不存在或不在权限范围内"); } @@ -1069,7 +1069,7 @@ public class AddUpSituationServiceImpl extends Service implements AddUpSituation if(deleteParam.getTaxAgentId() != null && (!deleteParam.getTaxAgentId().equals(""))){ // 设置了个税扣缴义务人 Long taxAgentId = SalaryEntityUtil.string2Long(deleteParam.getTaxAgentId()); - boolean canDelete = taxAgentIds.stream().anyMatch(t -> t == taxAgentId); + boolean canDelete = taxAgentIds.stream().anyMatch(t -> Objects.equals(t , taxAgentId)); if(!canDelete){ throw new SalaryRunTimeException("个税扣缴义务人不存在或不在权限范围内!"); } diff --git a/src/com/engine/salary/service/impl/FormulaRunServiceImpl.java b/src/com/engine/salary/service/impl/FormulaRunServiceImpl.java index 3f7e13f67..6beac534d 100644 --- a/src/com/engine/salary/service/impl/FormulaRunServiceImpl.java +++ b/src/com/engine/salary/service/impl/FormulaRunServiceImpl.java @@ -1,12 +1,14 @@ package com.engine.salary.service.impl; import com.engine.core.impl.Service; +import com.engine.salary.encrypt.AESEncryptUtil; import com.engine.salary.entity.datacollection.DataCollectionEmployee; import com.engine.salary.entity.salaryformula.ExpressFormula; import com.engine.salary.entity.salaryformula.po.FormulaVar; import com.engine.salary.enums.salaryformula.ReferenceTypeEnum; import com.engine.salary.formlua.entity.parameter.DataType; import com.engine.salary.service.FormulaRunService; +import com.engine.salary.sys.enums.OpenEnum; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; @@ -56,6 +58,8 @@ public class FormulaRunServiceImpl extends Service implements FormulaRunService String extendParam = expressFormula.getExtendParam(); String sqlReturnKey = ""; String datasourceId = ""; + String openDecrypt = ""; + String result = ""; try { JsonNode jsonNode = objectMapper.readTree(extendParam); //返回值配置 @@ -71,6 +75,11 @@ public class FormulaRunServiceImpl extends Service implements FormulaRunService datasourceId = datasourceIdNode.asText(); } } + //是否需要解密 + JsonNode decrypt = jsonNode.get("openDecrypt"); + if (decrypt != null) { + openDecrypt = decrypt.asText().trim(); + } } catch (JsonProcessingException e) { log.error("express execute fail, sql extendParam parse fail", e); } @@ -89,18 +98,22 @@ public class FormulaRunServiceImpl extends Service implements FormulaRunService RecordSetDataSource rs = new RecordSetDataSource(datasourceId); if (rs.executeSql(sql)) { if (rs.next()) { - return rs.getString(sqlReturnKey); + result = rs.getString(sqlReturnKey); } } } else { RecordSet rs = new RecordSet(); if (rs.execute(sql)) { if (rs.next()) { - return rs.getString(sqlReturnKey); + result = rs.getString(sqlReturnKey); } } } - return StringUtils.EMPTY; + + if (OpenEnum.OPEN.getValue().equals(openDecrypt)) { + result = AESEncryptUtil.decrypt(result); + } + return result; } private Object runFormula(ExpressFormula expressFormula, List formulaVars) throws Exception { diff --git a/src/com/engine/salary/service/impl/OtherDeductionServiceImpl.java b/src/com/engine/salary/service/impl/OtherDeductionServiceImpl.java index 6edd8bddf..1529e9966 100644 --- a/src/com/engine/salary/service/impl/OtherDeductionServiceImpl.java +++ b/src/com/engine/salary/service/impl/OtherDeductionServiceImpl.java @@ -567,7 +567,7 @@ public class OtherDeductionServiceImpl extends Service implements OtherDeduction throw new SalaryRunTimeException("该数据不存在!"); } Long taxAgentId = byId.getTaxAgentId(); - boolean canEdit = taxAgentList.stream().anyMatch(t -> t.getTaxAgentId() == taxAgentId); + boolean canEdit = taxAgentList.stream().anyMatch(t -> Objects.equals(t.getTaxAgentId() , taxAgentId)); if(!canEdit){ //没有编辑权限 throw new SalaryRunTimeException("该个税扣缴义务人无权限编辑此数据!"); @@ -622,7 +622,7 @@ public class OtherDeductionServiceImpl extends Service implements OtherDeduction .declareMonth(declareMonth).build(); //筛选导入人员信息可以在人力资源池中匹配到的人员信息 - boolean employeeSameId = employees.stream().anyMatch(e -> e.getEmployeeId() == otherDeductionParam.getEmployeeId()); + boolean employeeSameId = employees.stream().anyMatch(e -> Objects.equals(e.getEmployeeId() , otherDeductionParam.getEmployeeId())); if(!employeeSameId){ throw new SalaryRunTimeException("员工信息不存在"); } @@ -701,7 +701,7 @@ public class OtherDeductionServiceImpl extends Service implements OtherDeduction throw new SalaryRunTimeException("数据不存在或已被删除!"); } // 判断是否在个税扣缴义务人范围内 - Optional first = taxAgentList.stream().filter(m -> m.getTaxAgentId() == byId.getTaxAgentId()).findFirst(); + Optional first = taxAgentList.stream().filter(m -> Objects.equals(m.getTaxAgentId() , byId.getTaxAgentId())).findFirst(); if(!first.isPresent()){ throw new SalaryRunTimeException("个税扣缴义务人不存在或不在权限范围内"); } @@ -737,7 +737,7 @@ public class OtherDeductionServiceImpl extends Service implements OtherDeduction if(deleteParam.getTaxAgentId() != null && (!deleteParam.getTaxAgentId().equals(""))){ // 设置了个税扣缴义务人 Long taxAgentId = SalaryEntityUtil.string2Long(deleteParam.getTaxAgentId()); - boolean canDelete = taxAgentIds.stream().anyMatch(t -> t == taxAgentId); + boolean canDelete = taxAgentIds.stream().anyMatch(t -> Objects.equals(t , taxAgentId)); if(!canDelete){ throw new SalaryRunTimeException("个税扣缴义务人不存在或不在权限范围内!"); } diff --git a/src/com/engine/salary/service/impl/SIArchivesServiceImpl.java b/src/com/engine/salary/service/impl/SIArchivesServiceImpl.java index 8bc1b33e7..a55f1d8f8 100644 --- a/src/com/engine/salary/service/impl/SIArchivesServiceImpl.java +++ b/src/com/engine/salary/service/impl/SIArchivesServiceImpl.java @@ -186,8 +186,14 @@ public class SIArchivesServiceImpl extends Service implements SIArchivesService private void handleHistoryData(long currentEmployeeId) { //如果触发历史数据处理,则进行一次全量增员 if (siArchivesBiz.createOldInsuranceBaseInfo(currentEmployeeId)) { - //全量增员 - allStayAddToPay(); + + //批量增员 + List allBaseInfoList = getInsuranceBaseInfoMapper().listAll(); + Collection stayAddIds = allBaseInfoList.stream().filter(f->f.getRunStatus().equals(EmployeeStatusEnum.STAY_ADD.getValue())) + .map(InsuranceArchivesBaseInfoPO::getId).collect(Collectors.toList()); + if (stayAddIds.size() > 0) { + stayAddToPay(stayAddIds); + } } } @@ -742,9 +748,14 @@ public class SIArchivesServiceImpl extends Service implements SIArchivesService */ @Override public Map allStayDelToStop() { + long currentEmployeeId = user.getUID(); List allBaseInfoList = getInsuranceBaseInfoMapper().listAll(); if (allBaseInfoList.size() > 0) { - Collection stayDelIds = allBaseInfoList.stream().filter(f->f.getRunStatus().equals(EmployeeStatusEnum.STAY_DEL.getValue())) + //筛选当前人员可管辖(个税扣缴义务人)范围 + Collection taxAgentList = getTaxAgentService(user).listAllTaxAgents(currentEmployeeId); + List paymentOrganizationList = taxAgentList.stream().map(TaxAgentPO::getId).collect(Collectors.toList()); + + Collection stayDelIds = allBaseInfoList.stream().filter(f->f.getRunStatus().equals(EmployeeStatusEnum.STAY_DEL.getValue()) && paymentOrganizationList.contains(f.getPaymentOrganization())) .map(InsuranceArchivesBaseInfoPO::getId).collect(Collectors.toList()); if (stayDelIds.size() > 0) { return stayDelToStop(stayDelIds); @@ -835,7 +846,7 @@ public class SIArchivesServiceImpl extends Service implements SIArchivesService } return flag; }) - .map(InsuranceArchivesFundSchemePO::getEmployeeId).collect(Collectors.toList()); + .map(InsuranceArchivesFundSchemePO::getId).collect(Collectors.toList()); List finalToStopFundIds = toStopFundIds; toPayBaseInfoIdList = (List) CollectionUtils.union(toPayBaseInfoIdList, baseInfoPOList.stream().filter(f -> finalToStopFundIds.contains(f.getFundArchivesId())).map(InsuranceArchivesBaseInfoPO::getId).collect(Collectors.toList())); @@ -856,7 +867,7 @@ public class SIArchivesServiceImpl extends Service implements SIArchivesService } return flag; }) - .map(InsuranceArchivesOtherSchemePO::getEmployeeId).collect(Collectors.toList()); + .map(InsuranceArchivesOtherSchemePO::getId).collect(Collectors.toList()); List finalToStopOtherIds = toStopOtherIds; toPayBaseInfoIdList = (List) CollectionUtils.union(toPayBaseInfoIdList, baseInfoPOList.stream().filter(f -> finalToStopOtherIds.contains(f.getOtherArchivesId())).map(InsuranceArchivesBaseInfoPO::getId).collect(Collectors.toList())); @@ -914,9 +925,14 @@ public class SIArchivesServiceImpl extends Service implements SIArchivesService */ @Override public Map allStayAddToPay() { + long currentEmployeeId = user.getUID(); List allBaseInfoList = getInsuranceBaseInfoMapper().listAll(); if (allBaseInfoList.size() > 0) { - Collection stayAddIds = allBaseInfoList.stream().filter(f->f.getRunStatus().equals(EmployeeStatusEnum.STAY_ADD.getValue())) + //筛选当前人员可管辖(个税扣缴义务人)范围 + Collection taxAgentList = getTaxAgentService(user).listAllTaxAgents(currentEmployeeId); + List paymentOrganizationList = taxAgentList.stream().map(TaxAgentPO::getId).collect(Collectors.toList()); + + Collection stayAddIds = allBaseInfoList.stream().filter(f->f.getRunStatus().equals(EmployeeStatusEnum.STAY_ADD.getValue()) && paymentOrganizationList.contains(f.getPaymentOrganization())) .map(InsuranceArchivesBaseInfoPO::getId).collect(Collectors.toList()); if (stayAddIds.size() > 0) { return stayAddToPay(stayAddIds); diff --git a/src/com/engine/salary/service/impl/SISchemeServiceImpl.java b/src/com/engine/salary/service/impl/SISchemeServiceImpl.java index 005422310..90db8c674 100644 --- a/src/com/engine/salary/service/impl/SISchemeServiceImpl.java +++ b/src/com/engine/salary/service/impl/SISchemeServiceImpl.java @@ -898,6 +898,15 @@ public class SISchemeServiceImpl extends Service implements SISchemeService { errorMessageMap.put("message", rowIndex + SalaryI18nUtil.getI18nLabel(100322, "社保方案不存在")); excelComments.add(errorMessageMap); isError = true; + } else if (StringUtils.isNotBlank((String) socialMap.get(SalaryI18nUtil.getI18nLabel(91323, "社保方案名称"))) + && schemeNameIdMap.get((String) socialMap.get(SalaryI18nUtil.getI18nLabel(91323, "社保方案名称"))) != null + && !getInsuranceSchemeMapper().getById(schemeNameIdMap.get((String) socialMap.get(SalaryI18nUtil.getI18nLabel(91323, "社保方案名称")))).getWelfareType().equals(WelfareTypeEnum.SOCIAL_SECURITY.getValue())) { + + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", rowIndex + SalaryI18nUtil.getI18nLabel(100322, "社保方案不属于社保福利类型")); + excelComments.add(errorMessageMap); + isError = true; + } else { insuranceArchivesSocialSchemePO = buildSocialPO(employeeId, welfareMap, singleAccount, schemeNameIdMap, paymentNameIdMap, creator); } @@ -906,15 +915,32 @@ public class SISchemeServiceImpl extends Service implements SISchemeService { errorMessageMap.put("message", rowIndex + SalaryI18nUtil.getI18nLabel(100323, "公积金方案不存在")); excelComments.add(errorMessageMap); isError = true; - } else { + } else if (StringUtils.isNotBlank((String) fundMap.get(SalaryI18nUtil.getI18nLabel(91485, "公积金方案名称"))) + && schemeNameIdMap.get((String) fundMap.get(SalaryI18nUtil.getI18nLabel(91485, "公积金方案名称"))) != null + && !getInsuranceSchemeMapper().getById(schemeNameIdMap.get((String) fundMap.get(SalaryI18nUtil.getI18nLabel(91485, "公积金方案名称")))).getWelfareType().equals(WelfareTypeEnum.ACCUMULATION_FUND.getValue())) { + + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", rowIndex + SalaryI18nUtil.getI18nLabel(100322, "公积金方案不属于公积金福利类型")); + excelComments.add(errorMessageMap); + isError = true; + + }else { insuranceArchivesFundSchemePO = buildFundPO(employeeId, welfareMap, singleAccount, schemeNameIdMap, paymentNameIdMap, creator); } - if (StringUtils.isNotBlank((String) fundMap.get(SalaryI18nUtil.getI18nLabel(91496, "其他福利方案名称"))) && schemeNameIdMap.get((String) fundMap.get(SalaryI18nUtil.getI18nLabel(91496, "其他福利方案名称"))) == null) { + if (StringUtils.isNotBlank((String) otherMap.get(SalaryI18nUtil.getI18nLabel(91496, "其他福利方案名称"))) && schemeNameIdMap.get((String) otherMap.get(SalaryI18nUtil.getI18nLabel(91496, "其他福利方案名称"))) == null) { Map errorMessageMap = Maps.newHashMap(); errorMessageMap.put("message", rowIndex + SalaryI18nUtil.getI18nLabel(100324, "其他福利方案不存在")); excelComments.add(errorMessageMap); isError = true; - } else { + } else if (StringUtils.isNotBlank((String) otherMap.get(SalaryI18nUtil.getI18nLabel(91496, "其他福利方案名称"))) + && schemeNameIdMap.get((String) otherMap.get(SalaryI18nUtil.getI18nLabel(91496, "其他福利方案名称"))) != null + && !getInsuranceSchemeMapper().getById(schemeNameIdMap.get((String) otherMap.get(SalaryI18nUtil.getI18nLabel(91496, "其他福利方案名称")))).getWelfareType().equals(WelfareTypeEnum.OTHER.getValue())) { + + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", rowIndex + SalaryI18nUtil.getI18nLabel(100322, "其他福利方案不属于其他福利类型")); + excelComments.add(errorMessageMap); + isError = true; + }else { insuranceArchivesOtherSchemePO = buildOtherPO(employeeId, welfareMap, singleAccount, schemeNameIdMap, paymentNameIdMap, creator); } /**************校验申报基数**************/ diff --git a/src/com/engine/salary/service/impl/SalaryAcctCalculateServiceImpl.java b/src/com/engine/salary/service/impl/SalaryAcctCalculateServiceImpl.java index c272b65f9..c793713d9 100644 --- a/src/com/engine/salary/service/impl/SalaryAcctCalculateServiceImpl.java +++ b/src/com/engine/salary/service/impl/SalaryAcctCalculateServiceImpl.java @@ -198,7 +198,19 @@ public class SalaryAcctCalculateServiceImpl extends Service implements SalaryAcc if (salaryItemIdKeySalarySobItemPOMap.containsKey(salaryItemId)) { // 转换成薪资核算结果po SalaryAcctResultTempPO salaryAcctResultTempPO = new SalaryAcctResultTempPO() - .setSalaryAcctRecordId(salaryAcctEmployeePO.getSalaryAcctRecordId()).setSalaryAcctEmpId(salaryAcctEmployeePO.getId()).setEmployeeId(salaryAcctEmployeePO.getEmployeeId()).setTaxAgentId(salaryAcctEmployeePO.getTaxAgentId()).setSalarySobId(salaryAcctEmployeePO.getSalarySobId()).setSalaryItemId(salaryItemPO.getId()).setResultValue(resultValue).setCalculateKey(salaryAcctCalculateBO.getCalculateKey()).setCreator((long) user.getUID()).setCreateTime(now).setUpdateTime(now).setTenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY).setDeleteType(0); + .setSalaryAcctRecordId(salaryAcctEmployeePO.getSalaryAcctRecordId()) + .setSalaryAcctEmpId(salaryAcctEmployeePO.getId()) + .setEmployeeId(salaryAcctEmployeePO.getEmployeeId()) + .setTaxAgentId(salaryAcctEmployeePO.getTaxAgentId()) + .setSalarySobId(salaryAcctEmployeePO.getSalarySobId()) + .setSalaryItemId(salaryItemPO.getId()) + .setResultValue(resultValue) + .setCalculateKey(salaryAcctCalculateBO.getCalculateKey()) + .setCreator((long) user.getUID()) + .setCreateTime(now) + .setUpdateTime(now) + .setTenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) + .setDeleteType(0); salaryAcctResultTempPOS.add(salaryAcctResultTempPO); } } diff --git a/src/com/engine/salary/service/impl/SalaryAcctRecordServiceImpl.java b/src/com/engine/salary/service/impl/SalaryAcctRecordServiceImpl.java index da52c4415..5f9ff6c7d 100644 --- a/src/com/engine/salary/service/impl/SalaryAcctRecordServiceImpl.java +++ b/src/com/engine/salary/service/impl/SalaryAcctRecordServiceImpl.java @@ -16,6 +16,9 @@ import com.engine.salary.enums.salarysob.IncomeCategoryEnum; import com.engine.salary.exception.SalaryRunTimeException; import com.engine.salary.mapper.salaryacct.SalaryAcctRecordMapper; import com.engine.salary.service.*; +import com.engine.salary.sys.enums.TaxDeclarationFunctionEnum; +import com.engine.salary.sys.service.SalarySysConfService; +import com.engine.salary.sys.service.impl.SalarySysConfServiceImpl; import com.engine.salary.util.SalaryDateUtil; import com.engine.salary.util.SalaryEntityUtil; import com.engine.salary.util.SalaryI18nUtil; @@ -65,6 +68,10 @@ public class SalaryAcctRecordServiceImpl extends Service implements SalaryAcctRe return ServiceUtil.getService(SalarySendServiceImpl.class, user); } + private SalarySysConfService getSalarySysConfService(User user){ + return ServiceUtil.getService(SalarySysConfServiceImpl.class,user); + } + // private SalaryCheckResultService salaryCheckResultService; // // private SalaryCheckResultDetailService salaryCheckResultDetailService; @@ -85,6 +92,7 @@ public class SalaryAcctRecordServiceImpl extends Service implements SalaryAcctRe return ServiceUtil.getService(SalaryAcctReportServiceImpl.class, user); } + @Override public SalaryAcctRecordPO getById(Long id) { return getSalaryAcctRecordMapper().getById(id); @@ -296,39 +304,137 @@ public class SalaryAcctRecordServiceImpl extends Service implements SalaryAcctRe //获取账套下的所有核算结果 List salaryAcctRecords = listByTaxCycle(taxCycleYearRange,salarySobIds); - // 如果某个月(税款所属期)还未申报,不可以新建之后月份的薪资核算 - SalaryAcctRecordPO notDeclaredSalaryAcctRecordPO = salaryAcctRecords.stream() - .filter(e -> !Objects.equals(e.getStatus(), SalaryAcctRecordStatusEnum.DECLARED.getValue()) - && e.getTaxCycle().before(SalaryDateUtil.localDateToDate(salarySobCycleDTO.getTaxCycle().atDay(1)))) - .findAny() - .orElse(null); - if (Objects.nonNull(notDeclaredSalaryAcctRecordPO)) { - throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98751, "税款所属期{0}的薪资核算结果还未申报,不能新建税款所属期{1}的薪资核算") - .replace("{0}", SalaryDateUtil.localDate2YearMonth(notDeclaredSalaryAcctRecordPO.getTaxCycle()).toString()) - .replace("{1}", salarySobCycleDTO.getTaxCycle().toString())); + // 获取个税申报功能状态 + TaxDeclarationFunctionEnum taxDeclarationFunctionEnum = getSalarySysConfService(user).getTaxDeclaration(); + + if(taxDeclarationFunctionEnum.getValue().equals(TaxDeclarationFunctionEnum.CLOSURE.getValue())){ + // 关闭了个税申报功能 + // 如果某个月(薪资所属期)还未归档,不可以新建之后月份的薪资核算 + SalaryAcctRecordPO notArchivedSalaryAcctRecordPO = salaryAcctRecords.stream() + .filter(e -> Objects.equals(e.getStatus(), SalaryAcctRecordStatusEnum.NOT_ARCHIVED.getValue()) + && e.getSalaryMonth().before(SalaryDateUtil.localDateToDate(salarySobCycleDTO.getSalaryMonth().atDay(1)))) + .findAny() + .orElse(null); + if(Objects.nonNull(notArchivedSalaryAcctRecordPO)){ + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98754, "薪资所属期{0}的薪资核算结果还未归档,不能新建薪资所属期{1}的薪资核算") + .replace("{0}",SalaryDateUtil.localDate2YearMonth(notArchivedSalaryAcctRecordPO.getTaxCycle()).toString()) + .replace("{1}",salarySobCycleDTO.getTaxCycle().toString())); + } + // 如果有某个月(薪资所属期)已经归档了,不可以新建之前月份的薪资核算 + SalaryAcctRecordPO havaSalaryAcctRecordPO = salaryAcctRecords.stream() + .filter(e -> Objects.equals(e.getStatus(), SalaryAcctRecordStatusEnum.ARCHIVED.getValue()) + && e.getTaxCycle().after(SalaryDateUtil.localDateToDate(salarySobCycleDTO.getSalaryMonth().atDay(1)))) + .findAny() + .orElse(null); + if(Objects.nonNull(havaSalaryAcctRecordPO)){ + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98755, "薪资所属期{0}的薪资核算结果已经归档,不能新建薪资所属期{1}的薪资核算") + .replace("{0}",SalaryDateUtil.localDate2YearMonth(havaSalaryAcctRecordPO.getSalaryMonth()).toString()) + .replace("{1}",salarySobCycleDTO.getSalaryMonth().toString())); + } + } - // 如果某个月(税款所属期)已经归档了,不可以新建之前月份的薪资核算 - SalaryAcctRecordPO hasArchivedSalaryAcctRecordPO = salaryAcctRecords.stream() - .filter(e -> Objects.equals(e.getStatus(), SalaryAcctRecordStatusEnum.ARCHIVED.getValue()) - && e.getTaxCycle().after(SalaryDateUtil.localDateToDate(salarySobCycleDTO.getTaxCycle().atDay(1)))) - .findAny() - .orElse(null); - if (Objects.nonNull(hasArchivedSalaryAcctRecordPO)) { - throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98752, "税款所属期{0}的薪资核算结果已经归档,不能新建税款所属期{1}的薪资核算") - .replace("{0}", SalaryDateUtil.localDate2YearMonth(hasArchivedSalaryAcctRecordPO.getTaxCycle()).toString()) - .replace("{1}", salarySobCycleDTO.getTaxCycle().toString())); + if(taxDeclarationFunctionEnum.getValue().equals(TaxDeclarationFunctionEnum.OPEN.getValue())){ + // 开启了个税申报功能 + // 如果某个月(税款所属期)已经归档了,不可以新建之前月份的薪资核算 + SalaryAcctRecordPO hasArchivedSalaryAcctRecordPO = salaryAcctRecords.stream() + .filter(e -> Objects.equals(e.getStatus(), SalaryAcctRecordStatusEnum.ARCHIVED.getValue()) + && e.getTaxCycle().after(SalaryDateUtil.localDateToDate(salarySobCycleDTO.getTaxCycle().atDay(1)))) + .findAny() + .orElse(null); + if (Objects.nonNull(hasArchivedSalaryAcctRecordPO)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98752, "税款所属期{0}的薪资核算结果已经归档,不能新建税款所属期{1}的薪资核算") + .replace("{0}", SalaryDateUtil.localDate2YearMonth(hasArchivedSalaryAcctRecordPO.getTaxCycle()).toString()) + .replace("{1}", salarySobCycleDTO.getTaxCycle().toString())); + } + // 如果某个月(税款所属期)还未申报,不可以新建之后月份的薪资核算 + SalaryAcctRecordPO notDeclaredSalaryAcctRecordPO = salaryAcctRecords.stream() + .filter(e -> !Objects.equals(e.getStatus(), SalaryAcctRecordStatusEnum.DECLARED.getValue()) + && e.getTaxCycle().before(SalaryDateUtil.localDateToDate(salarySobCycleDTO.getTaxCycle().atDay(1)))) + .findAny() + .orElse(null); + if (Objects.nonNull(notDeclaredSalaryAcctRecordPO)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98751, "税款所属期{0}的薪资核算结果还未申报,不能新建税款所属期{1}的薪资核算") + .replace("{0}", SalaryDateUtil.localDate2YearMonth(notDeclaredSalaryAcctRecordPO.getTaxCycle()).toString()) + .replace("{1}", salarySobCycleDTO.getTaxCycle().toString())); + } + // 如果某个月(税款所属期)已经申报了,不可以新建本月以及之前月份的薪资核算 + SalaryAcctRecordPO hasDeclaredSalaryAcctRecordPO = salaryAcctRecords.stream() + .filter(e -> Objects.equals(e.getStatus(), SalaryAcctRecordStatusEnum.DECLARED.getValue()) + && e.getTaxCycle().compareTo(SalaryDateUtil.localDateToDate(salarySobCycleDTO.getTaxCycle().atDay(1))) >= 0) + .findAny() + .orElse(null); + if (Objects.nonNull(hasDeclaredSalaryAcctRecordPO)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98753, "税款所属期{0}的薪资核算结果已经申报,不能新建税款所属期{1}的薪资核算") + .replace("{0}", SalaryDateUtil.localDate2YearMonth(hasDeclaredSalaryAcctRecordPO.getTaxCycle()).toString()) + .replace("{1}", salarySobCycleDTO.getTaxCycle().toString())); + } } - // 如果某个月(税款所属期)已经申报了,不可以新建本月以及之前月份的薪资核算 - SalaryAcctRecordPO hasDeclaredSalaryAcctRecordPO = salaryAcctRecords.stream() - .filter(e -> Objects.equals(e.getStatus(), SalaryAcctRecordStatusEnum.DECLARED.getValue()) - && e.getTaxCycle().compareTo(SalaryDateUtil.localDateToDate(salarySobCycleDTO.getTaxCycle().atDay(1))) >= 0) - .findAny() - .orElse(null); - if (Objects.nonNull(hasDeclaredSalaryAcctRecordPO)) { - throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98753, "税款所属期{0}的薪资核算结果已经申报,不能新建税款所属期{1}的薪资核算") - .replace("{0}", SalaryDateUtil.localDate2YearMonth(hasDeclaredSalaryAcctRecordPO.getTaxCycle()).toString()) - .replace("{1}", salarySobCycleDTO.getTaxCycle().toString())); + if(taxDeclarationFunctionEnum.getValue().equals(TaxDeclarationFunctionEnum.REBOOT.getValue())){ + // 重启了个税申报功能(不去校验重启之前是否申报数据) + // 如果某个月(薪资所属期)还未归档,不可以新建之后月份的薪资核算 + SalaryAcctRecordPO notArchivedSalaryAcctRecordPO = salaryAcctRecords.stream() + .filter(e -> Objects.equals(e.getStatus(), SalaryAcctRecordStatusEnum.NOT_ARCHIVED.getValue()) + && e.getSalaryMonth().before(SalaryDateUtil.localDateToDate(salarySobCycleDTO.getSalaryMonth().atDay(1)))) + .findAny() + .orElse(null); + if(Objects.nonNull(notArchivedSalaryAcctRecordPO)){ + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98754, "薪资所属期{0}的薪资核算结果还未归档,不能新建薪资所属期{1}的薪资核算") + .replace("{0}",SalaryDateUtil.localDate2YearMonth(notArchivedSalaryAcctRecordPO.getTaxCycle()).toString()) + .replace("{1}",salarySobCycleDTO.getTaxCycle().toString())); + } + // 如果某个月(税款所属期)已经归档了,不可以新建之前月份的薪资核算 + SalaryAcctRecordPO hasArchivedSalaryAcctRecordPO = salaryAcctRecords.stream() + .filter(e -> Objects.equals(e.getStatus(), SalaryAcctRecordStatusEnum.ARCHIVED.getValue()) + && e.getTaxCycle().after(SalaryDateUtil.localDateToDate(salarySobCycleDTO.getTaxCycle().atDay(1)))) + .findAny() + .orElse(null); + if (Objects.nonNull(hasArchivedSalaryAcctRecordPO)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98752, "税款所属期{0}的薪资核算结果已经归档,不能新建税款所属期{1}的薪资核算") + .replace("{0}", SalaryDateUtil.localDate2YearMonth(hasArchivedSalaryAcctRecordPO.getTaxCycle()).toString()) + .replace("{1}", salarySobCycleDTO.getTaxCycle().toString())); + } + // 如果某个月(税款所属期)还未申报,不可以新建之后月份的薪资核算 + //获取账套下从重启月至所在年的最后一天的所有核算结果 + Date taxDeclarationRebootDate = getSalarySysConfService(user).getTaxDeclarationRebootDate(); + if(taxDeclarationRebootDate == null){ + throw new SalaryRunTimeException("个税申报功能异常"); + } + + LocalDateRange taxCycleRebootYearRange = LocalDateRange.builder() + .fromDate(taxDeclarationRebootDate) + .endDate(SalaryDateUtil.getLastDayOfYear(taxDeclarationRebootDate)) + .build(); +// List salaryAcctRebootRecords = listByTaxCycle(taxCycleRebootYearRange,salarySobIds); + List salaryAcctRebootRecords = listByCreateDate(taxCycleRebootYearRange,salarySobIds); + SalaryAcctRecordPO notDeclaredSalaryAcctRecordPO = salaryAcctRebootRecords.stream() + .filter(e -> !Objects.equals(e.getStatus(), SalaryAcctRecordStatusEnum.DECLARED.getValue()) + && e.getTaxCycle().before(SalaryDateUtil.localDateToDate(salarySobCycleDTO.getTaxCycle().atDay(1)))) + .findAny() + .orElse(null); + if (Objects.nonNull(notDeclaredSalaryAcctRecordPO)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98751, "税款所属期{0}的薪资核算结果还未申报,不能新建税款所属期{1}的薪资核算") + .replace("{0}", SalaryDateUtil.localDate2YearMonth(notDeclaredSalaryAcctRecordPO.getTaxCycle()).toString()) + .replace("{1}", salarySobCycleDTO.getTaxCycle().toString())); + } + + // 如果某个月(税款所属期)已经申报了,不可以新建本月以及之前月份的薪资核算 + SalaryAcctRecordPO hasDeclaredSalaryAcctRecordPO = salaryAcctRecords.stream() + .filter(e -> Objects.equals(e.getStatus(), SalaryAcctRecordStatusEnum.DECLARED.getValue()) + && e.getTaxCycle().compareTo(SalaryDateUtil.localDateToDate(salarySobCycleDTO.getTaxCycle().atDay(1))) >= 0) + .findAny() + .orElse(null); + if (Objects.nonNull(hasDeclaredSalaryAcctRecordPO)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98753, "税款所属期{0}的薪资核算结果已经申报,不能新建税款所属期{1}的薪资核算") + .replace("{0}", SalaryDateUtil.localDate2YearMonth(hasDeclaredSalaryAcctRecordPO.getTaxCycle()).toString()) + .replace("{1}", salarySobCycleDTO.getTaxCycle().toString())); + } + } + + } + + private List listByCreateDate(LocalDateRange taxCycleRebootYearRange, Set salarySobIds) { + return getSalaryAcctRecordMapper().listByCreateDate(taxCycleRebootYearRange,salarySobIds); } @@ -454,7 +560,7 @@ public class SalaryAcctRecordServiceImpl extends Service implements SalaryAcctRe throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(84026, "薪资所属月为空")); } // 查询税款所在年的该个税扣缴义务人所有薪资核算记录 - //获取账套所属个税扣缴义务人的核算记录 + // 获取账套所属个税扣缴义务人的核算记录 SalarySobPO salarySobPO = getSalarySobService(user).getById(salaryAcctRecordPO.getSalarySobId()); Long taxAgentId = salarySobPO.getTaxAgentId(); //查询扣缴义务人下的所有账套 @@ -474,8 +580,22 @@ public class SalaryAcctRecordServiceImpl extends Service implements SalaryAcctRe } //撤回工资单 getSalarySendService(user).revokeSalaryBill(salaryAcctRecordId); - //删除个税申报表(个税申报表、个税申报表详情、往期累计情况) - getTaxDeclarationService(user).delete(salaryAcctRecordPO); + + TaxDeclarationFunctionEnum taxDeclaration = getSalarySysConfService(user).getTaxDeclaration(); + +// if(taxDeclaration.getValue().equals(TaxDeclarationFunctionEnum.OPEN.getValue())){ + // 开启了个税申报功能 + // 删除个税申报表(个税申报表、个税申报表详情、往期累计情况) + getTaxDeclarationService(user).delete(salaryAcctRecordPO); +// }else if(taxDeclaration.getValue().equals(TaxDeclarationFunctionEnum.REBOOT.getValue())){ +// // 重启个税申报功能 +// Date taxDeclarationRebootDateTemp = getSalarySysConfService(user).getTaxDeclarationRebootDate(); +// Date taxDeclarationRebootDate = SalaryDateUtil.getFirstDayDateOfMonthWithMinutesAndSeconds(taxDeclarationRebootDateTemp); +// if(!taxDeclarationRebootDate.after(salaryAcctRecordPO.getTaxCycle())){ +// // 删除个税申报表(个税申报表、个税申报表详情、往期累计情况) +// getTaxDeclarationService(user).delete(salaryAcctRecordPO); +// } +// } // 更新薪资核算记录的状态 salaryAcctRecordPO.setStatus(SalaryAcctRecordStatusEnum.NOT_ARCHIVED.getValue()); salaryAcctRecordPO.setUpdateTime(new Date()); diff --git a/src/com/engine/salary/service/impl/SalaryAcctReportServiceImpl.java b/src/com/engine/salary/service/impl/SalaryAcctReportServiceImpl.java index 334221f35..e02c2aeac 100644 --- a/src/com/engine/salary/service/impl/SalaryAcctReportServiceImpl.java +++ b/src/com/engine/salary/service/impl/SalaryAcctReportServiceImpl.java @@ -1,19 +1,27 @@ package com.engine.salary.service.impl; +import com.engine.common.util.ServiceUtil; import com.engine.core.impl.Service; import com.engine.salary.encrypt.AESEncryptUtil; import com.engine.salary.encrypt.report.SalaryAcctResultReportPOEncrypt; import com.engine.salary.entity.report.po.SalaryAcctResultReportPO; import com.engine.salary.mapper.report.SalaryAcctResultReportMapper; import com.engine.salary.service.SalaryAcctReportService; +import com.engine.salary.sys.entity.po.SalarySysConfPO; +import com.engine.salary.sys.enums.OpenEnum; +import com.engine.salary.sys.service.SalarySysConfService; +import com.engine.salary.sys.service.impl.SalarySysConfServiceImpl; import com.engine.salary.util.db.MapperProxyFactory; import com.google.common.collect.Lists; import org.apache.commons.collections4.CollectionUtils; +import weaver.hrm.User; import java.util.Collection; import java.util.List; import java.util.stream.Collectors; +import static com.engine.salary.sys.constant.SalarySysConstant.DISPLAY_EMP_INFO_REPORT; + /** * 薪资报表 *

Copyright: Copyright (c) 2022

@@ -28,6 +36,11 @@ public class SalaryAcctReportServiceImpl extends Service implements SalaryAcctRe return MapperProxyFactory.getProxy(SalaryAcctResultReportMapper.class); } + + private SalarySysConfService getSalarySysConfService(User user) { + return ServiceUtil.getService(SalarySysConfServiceImpl.class, user); + } + /** * 薪酬解密方法 * @@ -61,7 +74,11 @@ public class SalaryAcctReportServiceImpl extends Service implements SalaryAcctRe @Override public void batchSave(Collection pos) { if (CollectionUtils.isNotEmpty(pos)) { - SalaryAcctResultReportPOEncrypt.encryptList(pos); + SalarySysConfPO disPlay = getSalarySysConfService(user).getOneByCode(DISPLAY_EMP_INFO_REPORT); + //默认不显示,关闭状态 + if (disPlay == null || OpenEnum.OFF.getValue().equals(disPlay.getConfValue())) { + SalaryAcctResultReportPOEncrypt.encryptList(pos); + } // List> partition = Lists.partition((List) pos, 100); // partition.forEach(getSalaryAcctResultReportMapper()::batchInsert); diff --git a/src/com/engine/salary/service/impl/SalaryArchiveServiceImpl.java b/src/com/engine/salary/service/impl/SalaryArchiveServiceImpl.java index 30d2d2d85..9eccd455f 100644 --- a/src/com/engine/salary/service/impl/SalaryArchiveServiceImpl.java +++ b/src/com/engine/salary/service/impl/SalaryArchiveServiceImpl.java @@ -1,6 +1,6 @@ package com.engine.salary.service.impl; -import com.api.formmode.mybatis.util.SqlProxyHandle; +import com.cloudstore.dev.api.util.Util_DataCache; import com.engine.common.util.ServiceUtil; import com.engine.core.impl.Service; import com.engine.salary.biz.*; @@ -26,9 +26,9 @@ import com.engine.salary.enums.taxagent.TaxAgentEmpChangeModuleEnum; import com.engine.salary.exception.SalaryRunTimeException; import com.engine.salary.mapper.archive.SalaryArchiveItemMapper; import com.engine.salary.mapper.archive.SalaryArchiveMapper; -import com.engine.salary.mapper.sys.SalarySysConfMapper; import com.engine.salary.service.*; import com.engine.salary.sys.entity.vo.OrderRuleVO; +import com.engine.salary.sys.enums.OpenEnum; import com.engine.salary.sys.service.SalarySysConfService; import com.engine.salary.sys.service.impl.SalarySysConfServiceImpl; import com.engine.salary.util.SalaryDateUtil; @@ -62,6 +62,7 @@ import weaver.hrm.User; import java.io.InputStream; import java.util.*; +import java.util.concurrent.atomic.AtomicInteger; import java.util.regex.Pattern; import java.util.stream.Collectors; @@ -118,11 +119,6 @@ public class SalaryArchiveServiceImpl extends Service implements SalaryArchiveSe return ServiceUtil.getService(SalaryArchiveItemServiceImpl.class, user); } - - private SalarySysConfMapper getSalarySysConfMapper() { - return SqlProxyHandle.getProxy(SalarySysConfMapper.class); - } - @Override public SalaryArchivePO getById(Long salaryArchiveId) { return salaryArchiveMapper.getById(salaryArchiveId); @@ -131,10 +127,10 @@ public class SalaryArchiveServiceImpl extends Service implements SalaryArchiveSe @Override public List listSome(SalaryArchivePO po) { Collection ids = po.getIds(); - if(CollectionUtils.isNotEmpty(ids)){ + if (CollectionUtils.isNotEmpty(ids)) { List list = new ArrayList<>(); List> partition = Lists.partition((List) ids, 1000); - partition.forEach(idss->{ + partition.forEach(idss -> { po.setIds(idss); list.addAll(getSalaryArchiveMapper().listSome(po)); }); @@ -142,10 +138,10 @@ public class SalaryArchiveServiceImpl extends Service implements SalaryArchiveSe } Collection employeeIds = po.getEmployeeIds(); - if(CollectionUtils.isNotEmpty(employeeIds)){ + if (CollectionUtils.isNotEmpty(employeeIds)) { List list = new ArrayList<>(); List> partition = Lists.partition((List) employeeIds, 1000); - partition.forEach(emps->{ + partition.forEach(emps -> { po.setEmployeeIds(emps); list.addAll(getSalaryArchiveMapper().listSome(po)); }); @@ -160,13 +156,24 @@ public class SalaryArchiveServiceImpl extends Service implements SalaryArchiveSe public PageInfo listPage(SalaryArchiveQueryParam queryParam) { long currentEmployeeId = user.getUID(); - - // 1.历史数据处理 - handleHistory(currentEmployeeId); - // 2.待停薪自动处理 - handleSuspendData(currentEmployeeId); - // 3.增量数据处理 - handleChangeData(currentEmployeeId); + /** + * 异步处理档案数据 + */ + String handleable = Util.null2String(Util_DataCache.getObjVal("salaryArchiveHandleable")); + if (StringUtils.isBlank(handleable) || OpenEnum.OPEN.getValue().equals(handleable)) { + new Thread() { + public void run() { + Util_DataCache.setObjVal("salaryArchiveHandleable", "0"); + // 1.历史数据处理 + handleHistory(currentEmployeeId); + // 2.待停薪自动处理 + handleSuspendData(currentEmployeeId); + // 3.增量数据处理 + handleChangeData(currentEmployeeId); + Util_DataCache.setObjVal("salaryArchiveHandleable", "1"); + } + }.start(); + } Boolean needAuth = getTaxAgentService(user).isNeedAuth(currentEmployeeId); @@ -1107,9 +1114,9 @@ public class SalaryArchiveServiceImpl extends Service implements SalaryArchiveSe } List oldList = listSome(SalaryArchivePO.builder() - .ids(ids) - .runStatus(SalaryArchiveStatusEnum.PENDING.getValue()) - .build()); + .ids(ids) + .runStatus(SalaryArchiveStatusEnum.PENDING.getValue()) + .build()); if (CollectionUtils.isEmpty(oldList)) { @@ -1192,9 +1199,9 @@ public class SalaryArchiveServiceImpl extends Service implements SalaryArchiveSe throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(145969, "没有可以操作的记录")); } List oldList = listSome(SalaryArchivePO.builder() - .ids(ids) - .runStatus(SalaryArchiveStatusEnum.SUSPEND.getValue()) - .build()); + .ids(ids) + .runStatus(SalaryArchiveStatusEnum.SUSPEND.getValue()) + .build()); if (CollectionUtils.isEmpty(oldList)) { throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(145969, "档案不存在!")); @@ -1241,9 +1248,9 @@ public class SalaryArchiveServiceImpl extends Service implements SalaryArchiveSe } List oldList = listSome(SalaryArchivePO.builder() - .ids(ids) - .runStatus(SalaryArchiveStatusEnum.SUSPEND.getValue()) - .build()); + .ids(ids) + .runStatus(SalaryArchiveStatusEnum.SUSPEND.getValue()) + .build()); List unableList = oldList.stream().filter(f -> Objects.nonNull(f.getPayEndDate()) && !f.getPayEndDate().after(new Date())).collect(Collectors.toList()); if (CollectionUtils.isNotEmpty(unableList)) { throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(115789, "最后发薪日必须晚于今天")); @@ -1286,4 +1293,27 @@ public class SalaryArchiveServiceImpl extends Service implements SalaryArchiveSe return StringUtils.EMPTY; } + @Override + public Map handleRepeatData() { + Map result = new HashMap<>(); + + //获取所有薪资档案 + List list = getSalaryArchiveMapper().listSome(SalaryArchivePO.builder().runStatus(SalaryArchiveStatusEnum.PENDING.getValue()).build()); + AtomicInteger num = new AtomicInteger(); + if (CollectionUtils.isNotEmpty(list)) { + Map> maps = SalaryEntityUtil.group2Map(list, k -> k.getTaxAgentId() + "-" + k.getEmployeeId()); + maps.forEach((key, pos) -> { + if (pos.size() > 1) { + for (int i = 1; i < pos.size(); i++) { + SalaryArchivePO salaryArchivePO = pos.get(i); + getSalaryArchiveMapper().delete(salaryArchivePO); + num.getAndIncrement(); + } + } + }); + } + result.put("共处理", num.get()); + return result; + } + } diff --git a/src/com/engine/salary/service/impl/SpecialAddDeductionServiceImpl.java b/src/com/engine/salary/service/impl/SpecialAddDeductionServiceImpl.java new file mode 100644 index 000000000..df9b604be --- /dev/null +++ b/src/com/engine/salary/service/impl/SpecialAddDeductionServiceImpl.java @@ -0,0 +1,670 @@ +package com.engine.salary.service.impl; + +import com.api.formmode.mybatis.util.SqlProxyHandle; +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.salary.biz.EmployBiz; +import com.engine.salary.biz.SpecialAddDeductionBiz; +import com.engine.salary.encrypt.datacollection.SpecialAddDeductionEncrypt; +import com.engine.salary.entity.datacollection.DataCollectionEmployee; +import com.engine.salary.entity.datacollection.dto.SpecialAddDeductionListDTO; +import com.engine.salary.entity.datacollection.dto.SpecialAddDeductionRecordDTO; +import com.engine.salary.entity.datacollection.param.*; +import com.engine.salary.entity.datacollection.po.SpecialAddDeductionPO; +import com.engine.salary.entity.taxagent.dto.TaxAgentEmployeeTaxAgentDTO; +import com.engine.salary.entity.taxagent.dto.TaxAgentManageRangeEmployeeDTO; +import com.engine.salary.entity.taxagent.po.TaxAgentPO; +import com.engine.salary.enums.UserStatusEnum; +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.mapper.datacollection.SpecialAddDeductionMapper; +import com.engine.salary.mapper.sys.SalarySysConfMapper; +import com.engine.salary.service.AddUpDeductionService; +import com.engine.salary.service.SalaryEmployeeService; +import com.engine.salary.service.SpecialAddDeductionService; +import com.engine.salary.service.TaxAgentService; +import com.engine.salary.sys.entity.po.SalarySysConfPO; +import com.engine.salary.sys.entity.vo.OrderRuleVO; +import com.engine.salary.sys.service.SalarySysConfService; +import com.engine.salary.sys.service.impl.SalarySysConfServiceImpl; +import com.engine.salary.util.SalaryEntityUtil; +import com.engine.salary.util.SalaryI18nUtil; +import com.engine.salary.util.db.MapperProxyFactory; +import com.engine.salary.util.excel.ExcelParseHelper; +import com.engine.salary.util.excel.ExcelUtil; +import com.engine.salary.util.page.PageInfo; +import com.engine.salary.util.page.SalaryPageUtil; +import com.google.common.collect.Maps; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.Validate; +import org.apache.poi.util.IOUtils; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import weaver.file.ImageFileManager; +import weaver.general.Util; +import weaver.hrm.User; + +import java.io.InputStream; +import java.text.SimpleDateFormat; +import java.time.YearMonth; +import java.util.*; +import java.util.stream.Collectors; + +import static com.engine.salary.constant.SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY; + +public class SpecialAddDeductionServiceImpl extends Service implements SpecialAddDeductionService { + + private SpecialAddDeductionBiz getSpecialAddDeductionBiz() { + return new SpecialAddDeductionBiz(); + } + + private SpecialAddDeductionMapper getSpecialAddDeductionMapper() { + return MapperProxyFactory.getProxy(SpecialAddDeductionMapper.class); + } + + private TaxAgentService getTaxAgentService(User user) { + return ServiceUtil.getService(TaxAgentServiceImpl.class, user); + } + + private AddUpDeductionService getAddUpDeductionService(User user) { + return ServiceUtil.getService(AddUpDeductionServiceImpl.class, user); + } + + private SalaryEmployeeService getSalaryEmployeeService(User user) { + return ServiceUtil.getService(SalaryEmployeeServiceImpl.class, user); + } + + private SalarySysConfMapper getSalarySysConfMapper() { + return SqlProxyHandle.getProxy(SalarySysConfMapper.class); + } + + private SalarySysConfService getSalarySysConfService(User user) { + return ServiceUtil.getService(SalarySysConfServiceImpl.class, user); + } + + @Override + public SpecialAddDeductionPO getById(Long id) { + return getSpecialAddDeductionBiz().getById(id); + } + + + @Override + public PageInfo listPage(SpecialAddDeductionQueryParam queryParam) { + //排序配置 + OrderRuleVO orderRule = getSalarySysConfService(user).orderRule(); + queryParam.setOrderRule(orderRule); + + long employeeId = user.getUID(); + + Boolean needAuth = getTaxAgentService(user).isNeedAuth(employeeId); + if (needAuth) { + putQueryRange(queryParam); + } + SalaryPageUtil.start(queryParam.getCurrent(), queryParam.getPageSize()); + List list = getSpecialAddDeductionMapper().listByParam(queryParam); + SpecialAddDeductionEncrypt.decrypt(list); + return new PageInfo<>(list, SpecialAddDeductionListDTO.class); + } + + @Override + public PageInfo recordListPage(SpecialAddDeductionQueryParam queryParam) { + long employeeId = user.getUID(); + + Boolean needAuth = getTaxAgentService(user).isNeedAuth(employeeId); + if (needAuth) { + putQueryRange(queryParam); + } + SalaryPageUtil.start(queryParam.getCurrent(), queryParam.getPageSize()); + List list = getSpecialAddDeductionMapper().listDtoByParam(queryParam); + SpecialAddDeductionEncrypt.decrypt(list); + + return new PageInfo<>(list, SpecialAddDeductionRecordDTO.class); + } + + private void putQueryRange(SpecialAddDeductionQueryParam queryParam) { + Long employeeId = (long) user.getUID(); + List taxAgentIdsAsAdmin = getTaxAgentService(user) + .listAllTaxAgentsAsAdmin(employeeId).stream().map(TaxAgentPO::getId) + .collect(Collectors.toList()); + if (CollectionUtils.isEmpty(taxAgentIdsAsAdmin)) { + // 不是个税扣缴义务人管理员,限定搜索范围为当前登录人 + List taxAgentIdsAsEmployee = getTaxAgentService(user) + .listAllTaxAgentsAsRange(Collections.singletonList(employeeId)) + .stream().filter(t -> t.getEmployeeId().equals(employeeId)) + .map(TaxAgentEmployeeTaxAgentDTO::getTaxAgentIds) + .flatMap(Collection::stream) + .collect(Collectors.toList()); + queryParam.setTaxAgentIds(taxAgentIdsAsEmployee); + queryParam.setEmployeeId(employeeId); + } else { + //管理员设置相应的个税扣缴义务人来筛选 + queryParam.setTaxAgentIds(taxAgentIdsAsAdmin); + } + } + + + @Override + public Map preview(SpecialAddDeductionImportParam importParam) { + Map apidatas = new HashMap(); + + //excel文件id + String imageId = Util.null2String(importParam.getImageId()); + Validate.notBlank(imageId, "imageId为空"); + + InputStream fileInputStream = null; + try { + fileInputStream = ImageFileManager.getInputStreamById(Integer.parseInt(imageId)); + List SpecialAddDeductions = + ExcelParseHelper.parse2Map(fileInputStream, SpecialAddDeductionListDTO.class, 0, 1, 14, + "SpecialAddDeductionTemplate.xlsx"); + apidatas.put("preview", SpecialAddDeductions); + } finally { + IOUtils.closeQuietly(fileInputStream); + } + return apidatas; + } + + + public Map importData(SpecialAddDeductionImportParam importParam) { + + Boolean openDevolution = getTaxAgentService(user).isOpenDevolution(); + + long currentEmployeeId = user.getUID(); + Map apidatas = new HashMap(); + EmployBiz employBiz = new EmployBiz(); + SpecialAddDeductionBiz SpecialAddDeductionBiz = new SpecialAddDeductionBiz(); + + //查询对于人员信息导入筛选的全局配置 + SalarySysConfPO salarySysConfPO = getSalarySysConfMapper().getOneByCode("matchEmployeeMode"); + String confValue = (salarySysConfPO != null && salarySysConfPO.getConfValue() != null && !"".equals(salarySysConfPO.getConfValue())) ? salarySysConfPO.getConfValue() : "0"; + + //检验参数 + checkImportParam(importParam); + + //excel文件id + String imageId = Util.null2String(importParam.getImageId()); + Validate.notBlank(imageId, "imageId为空"); + //个税扣缴义务人 + String taxAgentId = Util.null2String(importParam.getTaxAgentId()); + + InputStream fileInputStream = null; + try { + fileInputStream = ImageFileManager.getInputStreamById(Integer.parseInt(imageId)); + List SpecialAddDeductions = ExcelParseHelper.parse2Map(fileInputStream, SpecialAddDeductionListDTO.class, 0, 1, 14, "SpecialAddDeductionTemplate.xlsx"); + + int total = SpecialAddDeductions.size(); + int index = 0; + int successCount = 0; + int errorCount = 0; + + //人员信息 + List employees = employBiz.listEmployee(); + // 获取所有个税扣缴义务人 + Collection taxAgentList = getTaxAgentService(user).listTaxAgentAndEmployeeTree(currentEmployeeId); + // 查询已有数据 + List list = getSpecialAddDeductionBiz() + .listByTaxAgentIds(null); + + // 错误excel内容 + List errorData = new ArrayList<>(); + //合规数据 + List eligibleData = new ArrayList<>(); + + for (int i = 0; i < SpecialAddDeductions.size(); i++) { + SpecialAddDeductionListDTO dto = SpecialAddDeductions.get(i); + + Date now = new Date(); + //待插入数据库对象 + SpecialAddDeductionPO po = SpecialAddDeductionPO.builder() + .tenantKey(DEFAULT_TENANT_KEY) + .createTime(now) + .updateTime(now) + .creator((long) user.getUID()) + .build(); + + //异常点数量 + int errorSum = 0; + + //行号 + String rowIndex = String.format("第%s行", i + 2); + + //相同的姓名 + String userName = dto.getUsername(); + String deparmentName = dto.getDepartmentName(); + String mobile = dto.getMobile(); + String workcode = dto.getJobNum(); + List employeeSameIds = new ArrayList<>(); + + //筛选导入人员信息可以在人力资源池中匹配到的人员信息 + List emps = getSalaryEmployeeService(user) + .matchImportEmployee(employees, userName, deparmentName, mobile, workcode, null); + //含在职和离职,选在职数据 + if (CollectionUtils.isNotEmpty(emps) && emps.size() > 1) { + employeeSameIds = emps.stream() + .filter(e -> UserStatusEnum.getNormalStatus().contains(e.getStatus())) + .map(DataCollectionEmployee::getEmployeeId) + .collect(Collectors.toList()); + } + if (CollectionUtils.isNotEmpty(emps) && emps.size() == 1) { + employeeSameIds = emps.stream() + .map(DataCollectionEmployee::getEmployeeId) + .collect(Collectors.toList()); + } + + //当人员信息导入筛选的全局配置为"0"时,姓名才是必填项 + if (StringUtils.isBlank(userName) && "0".equals(confValue)) { + //姓名 不能为空 + //错误消息对象 + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", rowIndex + "姓名不能为空"); + errorData.add(errorMessageMap); + errorSum += 1; + } else if (CollectionUtils.isEmpty(employeeSameIds) || employeeSameIds.size() > 1) { + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", rowIndex + "员工信息不存在或者存在多个员工"); + errorData.add(errorMessageMap); + errorSum += 1; + } else { + Long employeeId = CollectionUtils.isNotEmpty(employeeSameIds) && employeeSameIds.size() == 1 ? employeeSameIds.get(0) : null; + if (employeeId != null && employeeId > 0) { + po.setEmployeeId(employeeId); + } else { + //姓名错误,系统内不存在该姓名 + Map errorMessageMap = new HashMap<>(); + errorMessageMap.put("message", rowIndex + "姓名错误,系统内不存在该姓名"); + errorData.add(errorMessageMap); + errorSum += 1; + } + } + + + String taxAgentName = dto.getTaxAgentName(); + if (StringUtils.isBlank(taxAgentName)) { + //个税扣缴义务人不能为空 + Map errorMessageMap = new HashMap<>(); + errorMessageMap.put("message", rowIndex + "个税扣缴义务人不能为空"); + errorData.add(errorMessageMap); + errorSum += 1; + } else { + Optional optionalTemp = taxAgentList.stream().filter(m -> m.getTaxAgentName().equals(taxAgentName)).findFirst(); + if (optionalTemp.isPresent()) { + if (StringUtils.isNotEmpty(taxAgentId) && !optionalTemp.get().getTaxAgentId().equals(Long.valueOf(taxAgentId))) { + //个税扣缴义务人与导入时选择的不一致 + Map errorMessageMap = new HashMap<>(); + errorMessageMap.put("message", rowIndex + "个税扣缴义务人与导入时选择的不一致"); + errorData.add(errorMessageMap); + errorSum += 1; + } else { + po.setTaxAgentId(optionalTemp.get().getTaxAgentId()); + } + } else { + //个税扣缴义务人不存在 + Map errorMessageMap = new HashMap<>(); + errorMessageMap.put("message", rowIndex + "个税扣缴义务人不存在或不在权限范围内"); + errorData.add(errorMessageMap); + errorSum += 1; + } + } + + // 核心字段, 前端没有传入的项目用空值覆盖 + po.setInfantCare(dto.getInfantCare() == null ? "" : dto.getInfantCare()) + .setSeriousIllnessTreatment(dto.getSeriousIllnessTreatment() == null ? "" : dto.getSeriousIllnessTreatment()) + .setSupportingElder(dto.getSupportingElder() == null ? "" : dto.getSupportingElder()) + .setHousingRent(dto.getHousingRent() == null ? "" : dto.getHousingRent()) + .setHousingLoanInterest(dto.getHousingLoanInterest() == null ? "" : dto.getHousingLoanInterest()) + .setContinuingEducation(dto.getContinuingEducation() == null ? "" : dto.getContinuingEducation()) + .setChildrenEducation(dto.getChildrenEducation() == null ? "" : dto.getChildrenEducation()); + + + //fixme 分权判断 + if (errorSum == 0) { + successCount += 1; + // 合格数据 + eligibleData.add(po); + } else { + errorCount += 1; + // 添加错误数据 + } + } + + //入库 + SpecialAddDeductionBiz.handleImportData(eligibleData); + + apidatas.put("successCount", successCount); + apidatas.put("errorCount", errorCount); + apidatas.put("errorData", errorData); + + } finally { + IOUtils.closeQuietly(fileInputStream); + } + return apidatas; + } + + private void checkImportParam(SpecialAddDeductionImportParam importParam) { + //excel文件id + String imageId = Util.null2String(importParam.getImageId()); + //个税扣缴义务人 + String taxAgentId = Util.null2String(importParam.getTaxAgentId()); + + if (StringUtils.isBlank(imageId)) { + throw new SalaryRunTimeException("文件不存在"); + } + } + + /** + * 导出 + * + * @param param + * @param isTemplate + * @return + */ + public XSSFWorkbook export(SpecialAddDeductionQueryParam param, boolean isTemplate) { + + //获取操作按钮资源 + List> rowList = getExcelRowList(param, isTemplate); + + //获取excel + return ExcelUtil.genWorkbook(rowList, "专项附加免税扣除"); + } + + + /** + * 获取excel数据行 + * + * @return 导出数据行集合 + */ + private List> getExcelRowList(SpecialAddDeductionQueryParam param, boolean isTemplate) { + long employeeId = user.getUID(); + //excel标题 + List title = Arrays.asList("姓名", "个税扣缴义务人", "部门", "手机号", "工号", "证件号码", "入职日期", "子女教育", "继续教育", "住房贷款利息", "住房租金", "赡养老人", "大病医疗", "婴幼儿照护"); + + List> rowList = new ArrayList<>(); + rowList.add(title); + if (!isTemplate) { + // 非下载导入模版,查询数据填充 + List> dataRowList = queryInfoForExcel(param, rowList); + rowList.addAll(dataRowList); + } + return rowList; + } + + + /** + * 导出详情列表 + * + * @param param + * @return + */ + public XSSFWorkbook exportDetail(SpecialAddDeductionQueryParam param) { + + SpecialAddDeductionBiz biz = new SpecialAddDeductionBiz(); + EmployBiz employBiz = new EmployBiz(); + + Long id = param.getSpecialAddDeductionId(); + if (id == null) { + throw new SalaryRunTimeException("id不能为空"); + } + + SpecialAddDeductionPO po = biz.getById(id); + if (po == null) { + throw new SalaryRunTimeException(String.format("专项附加扣除不存在" + "[id:%s]", id)); + } + + List employeeList = employBiz.getEmployeeByIds(Collections.singletonList(po.getEmployeeId())); + if (CollectionUtils.isEmpty(employeeList)) { + throw new SalaryRunTimeException("员工信息不存在"); + } + + //构建参数 + param.setEmployeeId(po.getEmployeeId()); + + + //获取操作按钮资源 + List> rowList = getExcelRowDetailList(param); + + //获取excel + return ExcelUtil.genWorkbook(rowList, "专项附加扣除明细"); + } + + + /** + * 导出详情 + * + * @param param + * @return + */ + private List> getExcelRowDetailList(SpecialAddDeductionQueryParam param) { + //excel标题 + List title = Arrays.asList("姓名", "个税扣缴义务人", "部门", "手机号", "工号", "子女教育", "继续教育", "住房贷款利息", "住房租金", "赡养老人", "大病医疗", "婴幼儿照护"); + + SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM"); + //查询详细信息 + List list = getSpecialAddDeductionBiz().listDTOByParam(param); + SpecialAddDeductionEncrypt.decrypt(list); + final List> dataRowList = Optional.ofNullable(list) + .map(List::stream) + .map(operatorStream -> operatorStream.map(dto -> { + List cellList = new ArrayList<>(); + cellList.add(Util.null2String(dto.getUsername())); + cellList.add(Util.null2String(dto.getTaxAgentName())); + cellList.add(Util.null2String(dto.getDepartmentName())); + cellList.add(Util.null2String(dto.getMobile())); + cellList.add(Util.null2String(dto.getJobNum())); + cellList.add(Util.null2String(dto.getChildrenEducation())); + cellList.add(Util.null2String(dto.getContinuingEducation())); + cellList.add(Util.null2String(dto.getHousingLoanInterest())); + cellList.add(Util.null2String(dto.getHousingRent())); + cellList.add(Util.null2String(dto.getSupportingElder())); + cellList.add(Util.null2String(dto.getSeriousIllnessTreatment())); + cellList.add(Util.null2String(dto.getInfantCare())); + return cellList; + }).collect(Collectors.toList())) + .orElse(Collections.emptyList()); + + List> rowList = new ArrayList<>(); + rowList.add(title); + rowList.addAll(dataRowList); + return rowList; + } + + + @Override + public List getSpecialAddDeductionList(YearMonth declareMonth, List employeeIds, Long taxAgentId) { + if (declareMonth == null) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100342, "参数有误:申报月份必传")); + } + SpecialAddDeductionBiz SpecialAddDeductionBiz = new SpecialAddDeductionBiz(); + return SpecialAddDeductionBiz.listByTaxAgentIds(null); + } + + @Override + public void editData(SpecialAddDeductionParam specialAddDeductionParam) { + SpecialAddDeductionBiz SpecialAddDeductionBiz = new SpecialAddDeductionBiz(); + Long currentEmployeeId = (long) user.getUID(); + // 获取所有个税扣缴义务人 + Collection taxAgentList = + getTaxAgentService(user).listTaxAgentAndEmployeeTree(currentEmployeeId); + SpecialAddDeductionPO byId = SpecialAddDeductionBiz.getById(specialAddDeductionParam.getId()); + if (byId == null) { + throw new SalaryRunTimeException("该数据不存在!"); + } + //管理员可以编辑该扣缴义务人数据,其他人可以编辑本人数据 + boolean canEdit = byId.getEmployeeId().equals((long) user.getUID()) + || taxAgentList.stream().anyMatch(t -> Objects.equals(t.getTaxAgentId(), byId.getTaxAgentId())); + if (!canEdit) { + //没有编辑权限 + throw new SalaryRunTimeException("该个税扣缴义务人无权限编辑此数据!"); + } + ArrayList updateList = new ArrayList<>(); + SpecialAddDeductionPO build = SpecialAddDeductionPO.builder() + .id(specialAddDeductionParam.getId()) + .childrenEducation(specialAddDeductionParam.getChildrenEducation()) + .continuingEducation(specialAddDeductionParam.getContinuingEducation()) + .housingLoanInterest(specialAddDeductionParam.getHousingLoanInterest()) + .housingRent(specialAddDeductionParam.getHousingRent()) + .infantCare(specialAddDeductionParam.getInfantCare()) + .supportingElder(specialAddDeductionParam.getSupportingElder()) + .seriousIllnessTreatment(specialAddDeductionParam.getSeriousIllnessTreatment()) + .build(); + updateList.add(build); + SpecialAddDeductionBiz.batchUpdate(updateList); + } + + @Override + public void createData(SpecialAddDeductionParam specialAddDeductionParam) { + long currentEmployeeId = user.getUID(); + Boolean openDevolution = getTaxAgentService(user).isOpenDevolution(); + SpecialAddDeductionBiz SpecialAddDeductionBiz = new SpecialAddDeductionBiz(); + EmployBiz employBiz = new EmployBiz(); + //查询对于人员信息导入筛选的全局配置 + SalarySysConfPO salarySysConfPO = getSalarySysConfMapper().getOneByCode("matchEmployeeMode"); + String confValue = (salarySysConfPO != null && salarySysConfPO.getConfValue() != null && !"".equals(salarySysConfPO.getConfValue())) ? salarySysConfPO.getConfValue() : "0"; + + //人员信息 + List employees = employBiz.listEmployee(); + // 获取所有个税扣缴义务人 + Collection taxAgentList = getTaxAgentService(user).listTaxAgentAndEmployeeTree(currentEmployeeId); + // 查询已有数据 + List list = getSpecialAddDeductionBiz().listByTaxAgentIds(null); + //合规数据 + List insertData = new ArrayList<>(); + Date now = new Date(); + //待插入数据库对象 + SpecialAddDeductionPO po = SpecialAddDeductionPO.builder() + .tenantKey(DEFAULT_TENANT_KEY) + .createTime(now) + .updateTime(now) + .creator((long) user.getUID()) + .build(); + + //筛选导入人员信息可以在人力资源池中匹配到的人员信息 + boolean employeeSameId = employees.stream() + .anyMatch(e -> Objects.equals(e.getEmployeeId(), specialAddDeductionParam.getEmployeeId())); + if (!employeeSameId) { + throw new SalaryRunTimeException("员工信息不存在"); + } + po.setEmployeeId(specialAddDeductionParam.getEmployeeId()); + String taxAgentName = specialAddDeductionParam.getTaxAgentName(); + if (StringUtils.isBlank(taxAgentName)) { + //个税扣缴义务人不能为空 + throw new SalaryRunTimeException("个税扣缴义务人不能为空"); + } else { + Optional optionalTemp = taxAgentList.stream().filter(m -> m.getTaxAgentName().equals(taxAgentName)).findFirst(); + if (optionalTemp.isPresent()) { + po.setTaxAgentId(optionalTemp.get().getTaxAgentId()); + } else { + //个税扣缴义务人不存在或不在权限范围内 + throw new SalaryRunTimeException("个税扣缴义务人不存在或不在权限范围内"); + } + } + //数据填充 + po.setContinuingEducation(specialAddDeductionParam.getContinuingEducation()) + .setChildrenEducation(specialAddDeductionParam.getChildrenEducation()) + .setHousingLoanInterest(specialAddDeductionParam.getHousingLoanInterest()) + .setHousingRent(specialAddDeductionParam.getHousingRent()) + .setSupportingElder(specialAddDeductionParam.getSupportingElder()) + .setSeriousIllnessTreatment(specialAddDeductionParam.getSeriousIllnessTreatment()) + .setInfantCare(specialAddDeductionParam.getInfantCare()); + //fixme 分权判断 + insertData.add(po); + //入库 + SpecialAddDeductionBiz.handleImportData(insertData); + } + + @Override + public void deleteSelectData(SpecialAddDeductionRecordDeleteParam deleteParam) { + long currentEmployeeId = user.getUID(); + // 获取所有个税扣缴义务人 + Collection taxAgentList = + getTaxAgentService(user).listTaxAgentAndEmployeeTree(currentEmployeeId); + SpecialAddDeductionBiz SpecialAddDeductionBiz = new SpecialAddDeductionBiz(); + List deleteIds = deleteParam.getIds(); + List deleteList = new ArrayList<>(); + for (Long id : deleteIds) { + SpecialAddDeductionPO byId = SpecialAddDeductionBiz.getById(id); + if (byId == null) { + throw new SalaryRunTimeException("数据不存在或已被删除!"); + } + // 判断是否在个税扣缴义务人范围内 + boolean isNotInRegion = + taxAgentList.stream() + .noneMatch(m -> Objects.equals(m.getTaxAgentId(), byId.getTaxAgentId())); + if (isNotInRegion) { + throw new SalaryRunTimeException("个税扣缴义务人不存在或不在权限范围内"); + } + deleteList.add(byId.getId()); + } + SpecialAddDeductionBiz.batchDeleteByIds(deleteList); + } + + @Override + public void deleteAllData(SpecialAddDeductionRecordDeleteParam deleteParam) { + // 获取所有个税扣缴义务人 + Collection taxAgentList = + getTaxAgentService(user).listTaxAgentAndEmployeeTree((long) user.getUID()); + List taxAgentIds = taxAgentList.stream() + .map(TaxAgentManageRangeEmployeeDTO::getTaxAgentId) + .collect(Collectors.toList()); + SpecialAddDeductionBiz specialAddDeductionBiz = new SpecialAddDeductionBiz(); + + if (deleteParam.getTaxAgentId() != null && (!deleteParam.getTaxAgentId().equals(""))) { + // 设置了个税扣缴义务人 + Long taxAgentId = SalaryEntityUtil.string2Long(deleteParam.getTaxAgentId()); + boolean canDelete = taxAgentIds.stream().anyMatch(t -> Objects.equals(t, taxAgentId)); + if (!canDelete) { + throw new SalaryRunTimeException("个税扣缴义务人不存在或不在权限范围内!"); + } + ArrayList tai = new ArrayList<>(); + tai.add(taxAgentId); + taxAgentIds = tai; + } + // 获取所有想要删除的数据 + List list = specialAddDeductionBiz.listByTaxAgentIds(taxAgentIds); + List deleteIds = list.stream().map(SpecialAddDeductionPO::getId).collect(Collectors.toList()); + specialAddDeductionBiz.batchDeleteByIds(deleteIds); + } + + @Override + public List getSpecialAddDeductionPOByEmployee(List employeeId, Long taxAgentId) { + return getSpecialAddDeductionBiz().getByEmployeeId(employeeId, taxAgentId); + } + + @Override + public SpecialAddDeductionRecordDTO getRecordById(Long id) { + return getSpecialAddDeductionBiz() + .listDTOByParam(SpecialAddDeductionQueryParam.builder().specialAddDeductionId(id).build()) + .stream().findFirst().orElse(null); + } + + private List> queryInfoForExcel(SpecialAddDeductionQueryParam param, List> rowList) { + //排序配置 + OrderRuleVO orderRule = getSalarySysConfService(user).orderRule(); + param.setOrderRule(orderRule); + + if (getTaxAgentService(user).isOpenDevolution()) { + putQueryRange(param); + } + List list = getSpecialAddDeductionBiz().listByParam(param); + final List> dataRowList = Optional.ofNullable(list) + .map(List::stream) + .map(operatorStream -> operatorStream.map(dto -> { + List cellList = new ArrayList<>(); + cellList.add(Util.null2String(dto.getUsername())); + cellList.add(Util.null2String(dto.getTaxAgentName())); + cellList.add(Util.null2String(dto.getDepartmentName())); + cellList.add(Util.null2String(dto.getMobile())); + cellList.add(Util.null2String(dto.getJobNum())); + cellList.add(Util.null2String(dto.getIdNo())); + cellList.add(Util.null2String(dto.getHiredate())); + cellList.add(Util.null2String(dto.getChildrenEducation())); + cellList.add(Util.null2String(dto.getContinuingEducation())); + cellList.add(Util.null2String(dto.getHousingLoanInterest())); + cellList.add(Util.null2String(dto.getHousingRent())); + cellList.add(Util.null2String(dto.getSupportingElder())); + cellList.add(Util.null2String(dto.getSeriousIllnessTreatment())); + cellList.add(Util.null2String(dto.getInfantCare())); + return cellList; + }).collect(Collectors.toList())) + .orElse(Collections.emptyList()); + return dataRowList; + } +} diff --git a/src/com/engine/salary/sys/constant/SalarySysConstant.java b/src/com/engine/salary/sys/constant/SalarySysConstant.java index 4800e1e61..79dab2119 100644 --- a/src/com/engine/salary/sys/constant/SalarySysConstant.java +++ b/src/com/engine/salary/sys/constant/SalarySysConstant.java @@ -32,6 +32,11 @@ public class SalarySysConstant { */ public static final String OPEN_ACCT_RESULT_SUM = "OPEN_ACCT_RESULT_SUM"; + /** + * 是否显示脱敏表人员信息 + */ + public static final String DISPLAY_EMP_INFO_REPORT = "DISPLAY_EMP_INFO_REPORT"; + /** * 应用设置是否开启加密 */ @@ -45,4 +50,9 @@ public class SalarySysConstant { */ public static final String AES_ENCRYPT_IN_PROGRESS = "AES_ENCRYPT_IN_PROGRESS"; public static final String ENCRYPT_IN_PROGRESS = "ENCRYPT_PROGRESS_"; + + /** + * 需要申报功能 + */ + public static final String TAX_DECLARATION_FUNCTION = "taxDeclarationFunction"; } diff --git a/src/com/engine/salary/sys/entity/param/AppSettingSaveParam.java b/src/com/engine/salary/sys/entity/param/AppSettingSaveParam.java index e235ad139..c62cb40a7 100644 --- a/src/com/engine/salary/sys/entity/param/AppSettingSaveParam.java +++ b/src/com/engine/salary/sys/entity/param/AppSettingSaveParam.java @@ -1,6 +1,7 @@ package com.engine.salary.sys.entity.param; import com.engine.salary.sys.enums.OpenEnum; +import com.engine.salary.util.valid.DataCheck; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; @@ -32,6 +33,7 @@ public class AppSettingSaveParam { * * @see OpenEnum */ + @DataCheck(require = true,message = "是否开启核算结果合计列?") private String openAcctResultSum; /** @@ -39,4 +41,16 @@ public class AppSettingSaveParam { */ private String isOpenEncrypt; + /** + * 是否关闭个税申报 + */ + private String operateTaxDeclaration; + + /** + * 是否显示脱敏表人员信息 + * @see OpenEnum + */ + @DataCheck(require = true,message = "是否显示脱敏表人员信息?") + private String displayEmpInfoReport; + } diff --git a/src/com/engine/salary/sys/entity/vo/AppSettingVO.java b/src/com/engine/salary/sys/entity/vo/AppSettingVO.java index cfa2dbc77..9a1175ca5 100644 --- a/src/com/engine/salary/sys/entity/vo/AppSettingVO.java +++ b/src/com/engine/salary/sys/entity/vo/AppSettingVO.java @@ -39,5 +39,17 @@ public class AppSettingVO { */ private String isOpenEncrypt; + /** + * 是否开启个税申报功能 + */ + private String isOpenTaxDeclaration; + + + + /** + * 是否显示脱敏表人员信息 + * @see OpenEnum + */ + private String displayEmpInfoReport; } diff --git a/src/com/engine/salary/sys/enums/TaxDeclarationFunctionEnum.java b/src/com/engine/salary/sys/enums/TaxDeclarationFunctionEnum.java index c76be7f95..325c5463e 100644 --- a/src/com/engine/salary/sys/enums/TaxDeclarationFunctionEnum.java +++ b/src/com/engine/salary/sys/enums/TaxDeclarationFunctionEnum.java @@ -12,9 +12,9 @@ import org.apache.commons.lang3.StringUtils; * @version 1.0 **/ public enum TaxDeclarationFunctionEnum implements BaseEnum { - OPEN("OPEN", "开启", 1), - CLOSURE("CLOSURE", "关闭", 1), - REBOOT("REBOOT", "重启", 1); + OPEN("1", "开启申报功能", 1), + CLOSURE("0", "关闭申报功能", 1), + REBOOT("2", "重启", 1); private String value; diff --git a/src/com/engine/salary/sys/service/SalarySysConfService.java b/src/com/engine/salary/sys/service/SalarySysConfService.java index de1fd16ae..87b3323e9 100644 --- a/src/com/engine/salary/sys/service/SalarySysConfService.java +++ b/src/com/engine/salary/sys/service/SalarySysConfService.java @@ -7,6 +7,7 @@ import com.engine.salary.sys.entity.vo.AppSettingVO; import com.engine.salary.sys.entity.vo.OrderRuleVO; import com.engine.salary.sys.enums.TaxDeclarationFunctionEnum; +import java.util.Date; import java.util.List; import java.util.Map; @@ -29,6 +30,12 @@ public interface SalarySysConfService { */ boolean operateTaxDeclarationFunction(TaxDeclarationFunctionEnum flag); + /** + * 是否关闭了个税申报功能 + * @return BOOLEAN + */ + TaxDeclarationFunctionEnum getTaxDeclaration(); + SalarySysConfPO getOneByCode(String code); List listSome(SalarySysConfPO build); @@ -67,5 +74,18 @@ public interface SalarySysConfService { */ Map saveEncryptSetting(AppSettingSaveParam appSettingSaveParam); + /** + * 加密进度 + * @param progressId + * @return + */ Map getEncryptProgress(String progressId); + + /** + * @description 获取个税申报功能重启日期 + * @return Date + * @author Harryxzy + * @date 2022/11/9 21:07 + */ + Date getTaxDeclarationRebootDate(); } diff --git a/src/com/engine/salary/sys/service/impl/SalarySysConfServiceImpl.java b/src/com/engine/salary/sys/service/impl/SalarySysConfServiceImpl.java index efd8e42c0..40a269b3f 100644 --- a/src/com/engine/salary/sys/service/impl/SalarySysConfServiceImpl.java +++ b/src/com/engine/salary/sys/service/impl/SalarySysConfServiceImpl.java @@ -4,9 +4,11 @@ import com.api.formmode.mybatis.util.SqlProxyHandle; import com.cloudstore.dev.api.util.Util_DataCache; import com.engine.core.impl.Service; import com.engine.salary.encrypt.AESEncryptUtil; +import com.engine.salary.encrypt.datacollection.SpecialAddDeductionEncrypt; import com.engine.salary.entity.datacollection.AddUpDeduction; import com.engine.salary.entity.datacollection.AddUpSituation; import com.engine.salary.entity.datacollection.po.OtherDeductionPO; +import com.engine.salary.entity.datacollection.po.SpecialAddDeductionPO; import com.engine.salary.entity.salaryacct.po.ExcelAcctResultPO; import com.engine.salary.entity.salaryacct.po.SalaryAcctResultPO; import com.engine.salary.entity.salaryarchive.po.SalaryArchiveItemPO; @@ -22,6 +24,7 @@ import com.engine.salary.mapper.archive.SalaryArchiveItemMapper; import com.engine.salary.mapper.datacollection.AddUpDeductionMapper; import com.engine.salary.mapper.datacollection.AddUpSituationMapper; import com.engine.salary.mapper.datacollection.OtherDeductionMapper; +import com.engine.salary.mapper.datacollection.SpecialAddDeductionMapper; import com.engine.salary.mapper.salaryacct.ExcelAcctResultMapper; import com.engine.salary.mapper.salaryacct.SalaryAcctResultMapper; import com.engine.salary.mapper.siaccount.InsuranceAccountBatchMapper; @@ -127,6 +130,10 @@ public class SalarySysConfServiceImpl extends Service implements SalarySysConfSe return MapperProxyFactory.getProxy(AddUpSituationMapper.class); } + private SpecialAddDeductionMapper getSpecialAddDeductionMapper() { + return MapperProxyFactory.getProxy(SpecialAddDeductionMapper.class); + } + static SalarySysConfServiceImpl salarySysConfService = new SalarySysConfServiceImpl(); /** @@ -138,9 +145,9 @@ public class SalarySysConfServiceImpl extends Service implements SalarySysConfSe @Override public boolean operateTaxDeclarationFunction(TaxDeclarationFunctionEnum flag) { Date date = new Date(); - SalarySysConfPO taxDeclarationFunction = getSalarySysConfMapper().getOneByCode("taxDeclarationFunction"); + SalarySysConfPO taxDeclarationFunction = getSalarySysConfMapper().getOneByCode(TAX_DECLARATION_FUNCTION); if (taxDeclarationFunction == null) { - taxDeclarationFunction = SalarySysConfPO.builder().id(IdGenerator.generate()).confKey("taxDeclarationFunction").confValue(flag.getValue()).title(flag.getDefaultLabel()).module("taxDeclaration").orderWeight(0).createTime(date).updateTime(date).deleteType(0).build(); + taxDeclarationFunction = SalarySysConfPO.builder().id(IdGenerator.generate()).confKey(TAX_DECLARATION_FUNCTION).confValue(flag.getValue()).title(flag.getDefaultLabel()).module("taxDeclaration").orderWeight(0).createTime(date).updateTime(date).deleteType(0).build(); getSalarySysConfMapper().insertIgnoreNull(taxDeclarationFunction); } else { TaxDeclarationFunctionEnum oldFunctionEnum = TaxDeclarationFunctionEnum.parseByValue(taxDeclarationFunction.getConfValue()); @@ -154,10 +161,10 @@ public class SalarySysConfServiceImpl extends Service implements SalarySysConfSe taxDeclarationFunction.setTitle(flag.getDefaultLabel()); taxDeclarationFunction.setUpdateTime(new Date()); } - //重启 + //重启 (从关闭到开启) if (flag == TaxDeclarationFunctionEnum.OPEN && oldFunctionEnum == TaxDeclarationFunctionEnum.CLOSURE) { - taxDeclarationFunction.setConfValue(flag.getValue()); - taxDeclarationFunction.setTitle(flag.getDefaultLabel()); + taxDeclarationFunction.setConfValue(TaxDeclarationFunctionEnum.REBOOT.getValue()); + taxDeclarationFunction.setTitle(TaxDeclarationFunctionEnum.REBOOT.getDefaultLabel()); taxDeclarationFunction.setUpdateTime(new Date()); } getSalarySysConfMapper().updateIgnoreNull(taxDeclarationFunction); @@ -165,6 +172,23 @@ public class SalarySysConfServiceImpl extends Service implements SalarySysConfSe return true; } + /** + * @description 获取申报功能状态 + * @return Boolean + * @author Harryxzy + * @date 2022/11/7 17:05 + */ + public TaxDeclarationFunctionEnum getTaxDeclaration(){ + SalarySysConfPO taxDeclarationFunction = salarySysConfService.getOneByCode(TAX_DECLARATION_FUNCTION); + if(taxDeclarationFunction == null){ + // 默认开启 + return TaxDeclarationFunctionEnum.OPEN; + } + TaxDeclarationFunctionEnum taxDeclarationFunctionEnum = TaxDeclarationFunctionEnum.parseByValue(taxDeclarationFunction.getConfValue()); + return taxDeclarationFunctionEnum; + } + + @Override public SalarySysConfPO getOneByCode(String code) { return getSalarySysConfMapper().getOneByCode(code); @@ -298,6 +322,7 @@ public class SalarySysConfServiceImpl extends Service implements SalarySysConfSe public void saveAppSetting(AppSettingSaveParam param) { String openAcctResultSum = param.getOpenAcctResultSum(); saveSettingByType(openAcctResultSum, OPEN_ACCT_RESULT_SUM, "开启核算结果合并", "app"); + saveSettingByType(param.getDisplayEmpInfoReport(), DISPLAY_EMP_INFO_REPORT, "是否显示脱敏表人员信息", "app"); } @Override @@ -364,6 +389,12 @@ public class SalarySysConfServiceImpl extends Service implements SalarySysConfSe return resultMap; } + @Override + public Date getTaxDeclarationRebootDate() { + Date date = getSalarySysConfMapper().getTaxDeclarationRebootDate(); + return date; + } + /** * 保存或者修改应用设置 * @@ -410,14 +441,32 @@ public class SalarySysConfServiceImpl extends Service implements SalarySysConfSe case OPEN_APPLICATION_ENCRYPT: appSettingVO.setIsOpenEncrypt(salarySysConfPO.getConfValue()); break; + case DISPLAY_EMP_INFO_REPORT: + appSettingVO.setDisplayEmpInfoReport(salarySysConfPO.getConfValue()); + break; default: break; } }); } + + List taxDeclarationFunction = getSalarySysConfMapper().listSome(SalarySysConfPO.builder().deleteType(0).confKey(TAX_DECLARATION_FUNCTION).build()); + if(taxDeclarationFunction == null || taxDeclarationFunction.size() == 0 || (taxDeclarationFunction.get(0).getConfValue().equals(TaxDeclarationFunctionEnum.REBOOT.getValue()))){ + // 默认开启报税功能 或者重启状态时前端展示开启 + appSettingVO.setIsOpenTaxDeclaration("1"); + }else { + appSettingVO.setIsOpenTaxDeclaration(taxDeclarationFunction.get(0).getConfValue()); + } //默认加密开启 if (StringUtils.isEmpty(appSettingVO.getIsOpenEncrypt())) { - appSettingVO.setIsOpenEncrypt("1"); + appSettingVO.setIsOpenEncrypt(OpenEnum.OPEN.getValue()); + } + + /** + * 默认不显示 + */ + if (StringUtils.isEmpty(appSettingVO.getDisplayEmpInfoReport())) { + appSettingVO.setDisplayEmpInfoReport(OpenEnum.OFF.getValue()); } return appSettingVO; } @@ -865,14 +914,41 @@ public class SalarySysConfServiceImpl extends Service implements SalarySysConfSe } return 1; }); - int flag = submit.get() + submit1.get() + submit2.get() + submit3.get() + submit4.get() + submit5.get() + submit6.get() + submit7.get() + submit8.get() + submit9.get() + submit10.get() + submit11.get() + submit12.get(); - if (flag == 13) { + Future submit13 = fixedThreadPool.submit(() -> { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + List addUpSituations = getSpecialAddDeductionMapper().listAll(); + if (CollectionUtils.isNotEmpty(addUpSituations)) { + addUpSituations.forEach(po -> { + if (OpenEnum.OFF.getValue().equals(isOpenEncrypt)) { + SpecialAddDeductionEncrypt.decrypt(po); + } else { + SpecialAddDeductionEncrypt.encrypt(po); + } + }); + List> partition = Lists.partition(addUpSituations, 50); + SpecialAddDeductionMapper mapper = sqlSession.getMapper(SpecialAddDeductionMapper.class); + partition.forEach(mapper::updateBatchSelective); + sqlSession.commit(); + baseBean.writeLog("hrsa_special_add_deduction"); + } + } catch (Exception e) { + sqlSession.rollback(); + baseBean.writeLog("hrsa_special_add_deduction:", e.getMessage()); + return 0; + } finally { + sqlSession.close(); + } + return 1; + }); + int flag = submit.get() + submit1.get() + submit2.get() + submit3.get() + submit4.get() + submit5.get() + submit6.get() + submit7.get() + submit8.get() + submit9.get() + submit10.get() + submit11.get() + submit12.get() + submit13.get(); + if (flag == 14) { Util_DataCache.setObjVal(ENCRYPT_IN_PROGRESS + progressId, "success", 30); } else { Util_DataCache.setObjVal(ENCRYPT_IN_PROGRESS + progressId, "fail", 30); } Util_DataCache.clearVal(AES_ENCRYPT_IN_PROGRESS); - return flag == 13; + return flag == 14; } catch (Exception e) { Util_DataCache.setObjVal(ENCRYPT_IN_PROGRESS + progressId, "fail", 30); Util_DataCache.clearVal(AES_ENCRYPT_IN_PROGRESS); diff --git a/src/com/engine/salary/util/SalaryDateUtil.java b/src/com/engine/salary/util/SalaryDateUtil.java index 90d3504bb..c34b18dbc 100644 --- a/src/com/engine/salary/util/SalaryDateUtil.java +++ b/src/com/engine/salary/util/SalaryDateUtil.java @@ -240,6 +240,17 @@ public class SalaryDateUtil { cal.set(Calendar.DAY_OF_MONTH, last); return cal.getTime(); } + public static Date getFirstDayDateOfMonthWithMinutesAndSeconds(final Date date) { + final Calendar cal = Calendar.getInstance(); + cal.setTime(date); + final int last = cal.getActualMinimum(Calendar.DAY_OF_MONTH); + cal.set(Calendar.DAY_OF_MONTH, last); + cal.set(Calendar.HOUR_OF_DAY, 0); + cal.set(Calendar.MINUTE, 0); + cal.set(Calendar.SECOND, 0); + cal.set(Calendar.MILLISECOND, 0); + return cal.getTime(); + } public static Date getLastDayOfMonth(final Date date) { final Calendar cal = Calendar.getInstance(); @@ -265,6 +276,9 @@ public class SalaryDateUtil { return cal.getTime(); } + + + public static String getMonthBegin(String specifiedDay) { int year; int month; diff --git a/src/com/engine/salary/web/AddUpDeductionController.java b/src/com/engine/salary/web/AddUpDeductionController.java index 894fbc81d..5d421153e 100644 --- a/src/com/engine/salary/web/AddUpDeductionController.java +++ b/src/com/engine/salary/web/AddUpDeductionController.java @@ -1,13 +1,13 @@ package com.engine.salary.web; +import cn.hutool.core.date.DateTime; +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.StrUtil; import com.engine.common.util.ParamUtil; import com.engine.common.util.ServiceUtil; import com.engine.salary.entity.datacollection.dto.AddUpDeductionDTO; import com.engine.salary.entity.datacollection.dto.AddUpDeductionRecordDTO; -import com.engine.salary.entity.datacollection.param.AddUpDeductionImportParam; -import com.engine.salary.entity.datacollection.param.AddUpDeductionQueryParam; -import com.engine.salary.entity.datacollection.param.AddUpDeductionRecordDeleteParam; -import com.engine.salary.entity.datacollection.param.AddUpDeductionRecordParam; +import com.engine.salary.entity.datacollection.param.*; import com.engine.salary.util.ResponseResult; import com.engine.salary.util.page.PageInfo; import com.engine.salary.wrapper.AddUpDeductionWrapper; @@ -340,4 +340,27 @@ public class AddUpDeductionController { } + /** + * 一键自动累计 + * @return + */ + @POST + @Path("/autoAddAll") + @Produces(MediaType.APPLICATION_JSON) + public String autoAddAll(@Context HttpServletRequest request, @Context HttpServletResponse response, + @RequestBody AddDeductionAutoAddParam param) { + DateTime date = null; + if (StrUtil.isNotEmpty(param.getYearMonth())) { + try { + date = DateUtil.parse(param.getYearMonth(), "yyyy-MM"); + } catch (Exception e) { + //ignore + // 放在service中处理,这里处理了页面上收不到 + } + } else { + date = DateUtil.beginOfMonth(new Date()); + } + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getAddUpDeductionWrapper(user)::autoAddAll, date); + } } diff --git a/src/com/engine/salary/web/SalaryArchiveController.java b/src/com/engine/salary/web/SalaryArchiveController.java index a7724f325..f5fbfcaae 100644 --- a/src/com/engine/salary/web/SalaryArchiveController.java +++ b/src/com/engine/salary/web/SalaryArchiveController.java @@ -896,4 +896,15 @@ public class SalaryArchiveController { /******** 个税扣缴义务人调整记录 end ***********************************************************************************************/ + + + + @GET + @Path("/handleRepeatData") + @Produces(MediaType.APPLICATION_JSON) + public String SingleTaxAgentAdjustRecordList(@Context HttpServletRequest request, @Context HttpServletResponse response) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getSalaryArchiveWrapper(user)::handleRepeatData); + } + } diff --git a/src/com/engine/salary/web/SalarySystemConfigController.java b/src/com/engine/salary/web/SalarySystemConfigController.java index 2b20dc209..5c03047de 100644 --- a/src/com/engine/salary/web/SalarySystemConfigController.java +++ b/src/com/engine/salary/web/SalarySystemConfigController.java @@ -51,16 +51,16 @@ public class SalarySystemConfigController { * * @param request * @param response - * @param flag + * @param param * @return */ @POST @Path("/operateTaxDeclarationFunction") @Produces(MediaType.APPLICATION_JSON) - public String operateTaxDeclarationFunction(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody String flag) { + public String operateTaxDeclarationFunction(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody AppSettingSaveParam param) { User user = HrmUserVarify.getUser(request, response); - return new ResponseResult(user).run(getSalarySystemConfigWrapper(user)::operateTaxDeclarationFunction, TaxDeclarationFunctionEnum.parseByValue(flag)); + return new ResponseResult(user).run(getSalarySystemConfigWrapper(user)::operateTaxDeclarationFunction, TaxDeclarationFunctionEnum.parseByValue(param.getOperateTaxDeclaration())); } /** diff --git a/src/com/engine/salary/web/SpecialAddDeductionController.java b/src/com/engine/salary/web/SpecialAddDeductionController.java new file mode 100644 index 000000000..7b6f0eb45 --- /dev/null +++ b/src/com/engine/salary/web/SpecialAddDeductionController.java @@ -0,0 +1,332 @@ +package com.engine.salary.web; + +import com.engine.common.util.ServiceUtil; +import com.engine.salary.entity.datacollection.dto.SpecialAddDeductionListDTO; +import com.engine.salary.entity.datacollection.dto.SpecialAddDeductionRecordDTO; +import com.engine.salary.entity.datacollection.param.*; +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.util.ResponseResult; +import com.engine.salary.util.page.PageInfo; +import com.engine.salary.wrapper.SpecialAddDeductionWrapper; +import io.swagger.v3.oas.annotations.parameters.RequestBody; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import org.jetbrains.annotations.Nullable; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; + +import javax.security.sasl.SaslException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.StreamingOutput; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.time.LocalDate; +import java.util.Arrays; +import java.util.Date; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * 数据采集-专项附加扣除 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author lfc + **/ +@Slf4j +public class SpecialAddDeductionController { + + private SpecialAddDeductionWrapper getSpecialAddDeductionWrapper(User user) { + return ServiceUtil.getService(SpecialAddDeductionWrapper.class, user); + } + + /** + * 数据采集-专项附加扣除列表的高级搜索 + * + * @return + */ + @GET + @Path("/getSearchCondition") + @Produces(MediaType.APPLICATION_JSON) + public String getSearchCondition(@Context HttpServletRequest request, @Context HttpServletResponse response) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult, Map>(user).run(getSpecialAddDeductionWrapper(user)::getSearchCondition); + } + + + @POST + @Path("/list") + @Produces(MediaType.APPLICATION_JSON) + public String list(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SpecialAddDeductionQueryParam queryParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getSpecialAddDeductionWrapper(user)::list, queryParam); + } + + + @POST + @Path("/getSpecialAddDeduction") + @Produces(MediaType.APPLICATION_JSON) + public String getDetailList(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SpecialAddDeductionQueryParam param) { + User user = HrmUserVarify.getUser(request, response); + Long id = param.getId(); + return new ResponseResult(user).run(getSpecialAddDeductionWrapper(user)::getRecordById, id); + } + + @POST + @Path("/getDetailList") + @Produces(MediaType.APPLICATION_JSON) + public String getSpecialAddDeduction(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SpecialAddDeductionQueryParam queryParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getSpecialAddDeductionWrapper(user)::getDetailList, queryParam); + } + + + @GET + @Path("/downloadTemplate") + @Produces(MediaType.APPLICATION_OCTET_STREAM) + public Response getAll(@Context HttpServletRequest request, @Context HttpServletResponse response) { + try { + User user = HrmUserVarify.getUser(request, response); + SpecialAddDeductionQueryParam param = buildParam(request); + + XSSFWorkbook workbook = getSpecialAddDeductionWrapper(user).downloadTemplate(param); + String fileName = "专项附加扣除导入模板" + LocalDate.now(); + try { + fileName = URLEncoder.encode(fileName + ".xlsx", "UTF-8"); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + + StreamingOutput output = outputStream -> { + workbook.write(outputStream); + outputStream.flush(); + }; + response.setContentType("application/octet-stream"); + return Response.ok(output).header("Content-disposition", "attachment;filename=" + fileName).header("Cache-Control", "no-cache").build(); + + } catch (Exception e) { + log.error("专项附加扣除导入模板异常", e); + throw e; + } + } + + + /** + * 导出 + * + * @param + * @return + */ + @GET + @Path("/export") + @Produces(MediaType.APPLICATION_OCTET_STREAM) + public Response export(@Context HttpServletRequest request, @Context HttpServletResponse response) { + try { + User user = HrmUserVarify.getUser(request, response); + + SpecialAddDeductionQueryParam param = buildParam(request); + + XSSFWorkbook workbook = getSpecialAddDeductionWrapper(user).export(param); + + String fileName = null; + try { + fileName = URLEncoder.encode("专项附加扣除" + LocalDate.now() + ".xlsx", "UTF-8"); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + + StreamingOutput output = outputStream -> { + workbook.write(outputStream); + outputStream.flush(); + }; + + response.setContentType("application/octet-stream"); + return Response.ok(output) + .header("Content-disposition", "attachment;filename=" + fileName) + .header("Cache-Control", "no-cache").build(); + } catch (Exception e) { + log.error("专项附加扣除导出异常", e); + throw e; + } + } + + + @GET + @Path("/exportDetail") + @Produces(MediaType.APPLICATION_OCTET_STREAM) + public Response exportDetail(@Context HttpServletRequest request, @Context HttpServletResponse response) { + try { + User user = HrmUserVarify.getUser(request, response); + + SpecialAddDeductionQueryParam param = buildParam(request); + + XSSFWorkbook workbook = getSpecialAddDeductionWrapper(user).exportDetail(param); + + String fileName = "专项附加扣除明细" + LocalDate.now(); + try { + fileName = URLEncoder.encode(fileName + ".xlsx", "UTF-8"); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + + StreamingOutput output = outputStream -> { + workbook.write(outputStream); + outputStream.flush(); + }; + + response.setContentType("application/octet-stream"); + return Response.ok(output) + .header("Content-disposition", "attachment;filename=" + fileName) + .header("Cache-Control", "no-cache").build(); + } catch (Exception e) { + log.error("专项附加扣除明细导出异常", e); + throw e; + } + + } + + @Nullable + private SpecialAddDeductionQueryParam buildParam(HttpServletRequest request) { + SpecialAddDeductionQueryParam param = new SpecialAddDeductionQueryParam(); + String ids = request.getParameter("ids"); + if (StringUtils.isNotBlank(ids)) { + param.setIds(Arrays.stream(ids.split(",")).map(Long::valueOf).collect(Collectors.toList())); + } + String keyword = request.getParameter("keyword"); + if (StringUtils.isNotBlank(keyword)) { + param.setKeyword(keyword); + } + String id = request.getParameter("id"); + if (StringUtils.isNotBlank(id)) { + param.setId(Long.valueOf(id)); + } + + String username = request.getParameter("username"); + if (StringUtils.isNotBlank(username)) { + param.setUsername(username); + } + String employeeId = request.getParameter("employeeId"); + if (StringUtils.isNotBlank(employeeId)) { + param.setEmployeeId(Long.valueOf(employeeId)); + } + String taxAgentId = request.getParameter("taxAgentId"); + if (StringUtils.isNotBlank(taxAgentId)) { + param.setTaxAgentId(Long.valueOf(taxAgentId)); + } + String departmentIds = request.getParameter("departmentIds"); + if (StringUtils.isNotBlank(departmentIds)) { + param.setDepartmentIds(Arrays.stream(departmentIds.split(",")).map(Long::valueOf).collect(Collectors.toList())); + } + String jobNum = request.getParameter("jobNum"); + if (StringUtils.isNotBlank(jobNum)) { + param.setJobNum(jobNum); + } + String idNo = request.getParameter("idNo"); + if (StringUtils.isNotBlank(idNo)) { + param.setIdNo(idNo); + } + String hiredate = request.getParameter("hiredate"); + if (StringUtils.isNotBlank(hiredate)) { + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); + List dates = Arrays.stream(hiredate.split(",")).map(d -> { + try { + return format.parse(d); + } catch (ParseException e) { + e.printStackTrace(); + } + return null; + }).collect(Collectors.toList()); + param.setHiredate(dates); + } + String mobile = request.getParameter("mobile"); + if (StringUtils.isNotBlank(mobile)) { + param.setMobile(mobile); + } + String otherTaxExemptDeductionId = request.getParameter("otherTaxExemptDeductionId"); + if (StringUtils.isNotBlank(otherTaxExemptDeductionId)) { + param.setSpecialAddDeductionId(Long.valueOf(otherTaxExemptDeductionId)); + } + return param; + } + + @POST + @Path("/preview") + @Produces(MediaType.APPLICATION_JSON) + public String preview(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SpecialAddDeductionImportParam importParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getSpecialAddDeductionWrapper(user)::preview, importParam); + } + + @POST + @Path("/importData") + @Produces(MediaType.APPLICATION_JSON) + public String importAddUpDeduction(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SpecialAddDeductionImportParam importParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getSpecialAddDeductionWrapper(user)::importData, importParam); + } + + /** + * @return String + * @description 编辑专项附加扣除 + * @author Harryxzy + * @date 2022/10/26 9:41 + */ + @POST + @Path("/editData") + @Produces(MediaType.APPLICATION_JSON) + public String editOtherDeduction(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SpecialAddDeductionParam otherDeductionParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getSpecialAddDeductionWrapper(user)::editData, otherDeductionParam); + } + + /** + * @return String + * @description 新建专项附加扣除 + * @author lfc + */ + @POST + @Path("/createData") + @Produces(MediaType.APPLICATION_JSON) + public String createSpecialAddDeduction(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SpecialAddDeductionParam specialAddDeductionParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getSpecialAddDeductionWrapper(user)::createData, specialAddDeductionParam); + } + + /** + * @return String + * @description 删除所选专项附加扣除 + * @author lfc + */ + @POST + @Path("/deleteSelectData") + @Produces(MediaType.APPLICATION_JSON) + public String deleteSelectOtherDeduction(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SpecialAddDeductionRecordDeleteParam deleteParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getSpecialAddDeductionWrapper(user)::deleteSelectData, deleteParam); + } + + /** + * @return null + * @description 一键清空专项附加扣除 + * @author lfc + */ + @POST + @Path("/deleteAllData") + @Produces(MediaType.APPLICATION_JSON) + public String deleteAllOtherDeduction(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SpecialAddDeductionRecordDeleteParam deductionRecordDeleteParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getSpecialAddDeductionWrapper(user)::deleteAllData, deductionRecordDeleteParam); + } +} diff --git a/src/com/engine/salary/wrapper/AddUpDeductionWrapper.java b/src/com/engine/salary/wrapper/AddUpDeductionWrapper.java index bf50b1960..84c45384e 100644 --- a/src/com/engine/salary/wrapper/AddUpDeductionWrapper.java +++ b/src/com/engine/salary/wrapper/AddUpDeductionWrapper.java @@ -19,10 +19,13 @@ import com.engine.salary.service.impl.TaxAgentServiceImpl; import com.engine.salary.util.SalaryDateUtil; import com.engine.salary.util.SalaryI18nUtil; import com.engine.salary.util.page.PageInfo; +import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import weaver.general.BaseBean; import weaver.hrm.User; +import java.util.Date; import java.util.List; import java.util.Map; import java.util.stream.Collectors; @@ -35,8 +38,12 @@ import java.util.stream.Collectors; * @author qiantao * @version 1.0 **/ +@Slf4j public class AddUpDeductionWrapper extends Service { + private final BaseBean baseBean = new BaseBean(); + private final Boolean isLog = "true".equals(baseBean.getPropValue("hrmSalary", "log")); + private AddUpDeductionService getAddUpDeductionService(User user) { return ServiceUtil.getService(AddUpDeductionServiceImpl.class, user); } @@ -148,7 +155,7 @@ public class AddUpDeductionWrapper extends Service { } public void createAddUpDeduction(AddUpDeductionRecordParam addUpDeductionRecordParam) { - getAddUpDeductionService(user).createAddUpDeduction(addUpDeductionRecordParam); + getAddUpDeductionService(user).createAddUpDeduction(addUpDeductionRecordParam); } public void deleteSelectAddUpDeduction(AddUpDeductionRecordDeleteParam deleteParam) { @@ -162,4 +169,14 @@ public class AddUpDeductionWrapper extends Service { public AddUpDeductionRecordDTO getAddUpDeduction(AddUpDeductionQueryParam param) { return getAddUpDeductionService(user).getAddUpDeduction(param); } + + public String autoAddAll(Date yearMonth) { + if (isLog) { + log.info("一键累计, 操作人 「{}」", user.getUsername()); + } + if (yearMonth == null) { + throw new SalaryRunTimeException("一键累计传入日期格式错误"); + } + return getAddUpDeductionService(user).autoAddAll(yearMonth); + } } diff --git a/src/com/engine/salary/wrapper/SalaryArchiveWrapper.java b/src/com/engine/salary/wrapper/SalaryArchiveWrapper.java index 596808e3a..bd230481c 100644 --- a/src/com/engine/salary/wrapper/SalaryArchiveWrapper.java +++ b/src/com/engine/salary/wrapper/SalaryArchiveWrapper.java @@ -15,7 +15,6 @@ import com.engine.salary.entity.salaryarchive.param.*; import com.engine.salary.entity.salaryarchive.po.SalaryArchiveDimissionPO; import com.engine.salary.entity.salaryarchive.po.SalaryArchiveItemPO; import com.engine.salary.entity.salaryarchive.po.SalaryArchivePO; -import com.engine.salary.entity.salaryarchive.po.SalaryArchiveTaxAgentPO; import com.engine.salary.entity.salaryitem.po.SalaryItemPO; import com.engine.salary.entity.taxagent.dto.TaxAgentListDTO; import com.engine.salary.entity.taxagent.po.TaxAgentPO; @@ -323,16 +322,8 @@ public class SalaryArchiveWrapper extends Service { throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100465, "薪资档案员工信息不存在")); } - // 获取当前已生效个税扣缴义务人 - List taxAgentList = getSalaryArchiveService(user).getCurrentEffectiveTaxAgentList(Collections.singletonList(salaryArchiveId)); - // 获取所有个税扣缴义务人 - Collection taxAgentLists = getTaxAgentService(user).findAll(); - String taxAgent = ""; - if (CollectionUtils.isNotEmpty(taxAgentList)) { - SalaryArchiveTaxAgentPO salaryArchiveTaxAgent = taxAgentList.get(0); - Optional taxAgentOptional = taxAgentLists.stream().filter(f -> f.getId().equals(salaryArchiveTaxAgent.getTaxAgentId())).findFirst(); - taxAgent = taxAgentOptional.isPresent() ? taxAgentOptional.get().getName() : taxAgent; - } + Long taxAgentId = po.getTaxAgentId(); + TaxAgentPO taxAgent = getTaxAgentService(user).getById(taxAgentId); // 1.基本信息表单 Map baseInfo = new HashMap<>(); @@ -343,7 +334,7 @@ public class SalaryArchiveWrapper extends Service { .position(employee.getJobtitleName() == null ? "" : employee.getJobtitleName()) .hiredate(employee.getCompanystartdate()) .mobile(employee.getMobile()) - .taxAgent(taxAgent) + .taxAgent(taxAgent.getName()) .build(); baseInfo.put("employee", build); @@ -422,31 +413,6 @@ public class SalaryArchiveWrapper extends Service { return importTypes; } -// /** -// * 导出薪资档案 -// * -// * @param queryParam -// * @param employeeId -// * @param tenantKey -// * @return -// */ -// public Map exportList(SalaryArchiveQueryParam queryParam, Long employeeId, String tenantKey) { -// // 构建异步导出参数 -// Map map = salaryBatchService.buildeExportParam("exportSalaryArchive"); -// String username = UserContext.getCurrentUser().getUsername(); -// String eteamsId = TenantRpcContext.getEteamsId(); -// taskExecutor.execute(() -> { -// try { -// DSTenantKeyThreadVar.tenantKey.set(tenantKey); -// getSalaryArchiveService(user).exportList(map, username, eteamsId, queryParam, employeeId, tenantKey); -// } finally { -// DSTenantKeyThreadVar.tenantKey.remove(); -// } -// }); -// -// return map; -// } -// /** * 下载导入模板 @@ -561,15 +527,6 @@ public class SalaryArchiveWrapper extends Service { return getSalaryArchiveExcelService(user).processInit(importData); } - -// public Map importSalaryArchiveSalaryItemAdjust(SalaryArchiveImportActionParam importData) { -// importData.setListType("FIXED"); -// importData.setImportType("salaryItemAdjust"); -// importData.setAddData(true); -// return getSalaryArchiveExcelService(user).processInit(importData); -// } - - /** * 停薪 * @@ -581,4 +538,7 @@ public class SalaryArchiveWrapper extends Service { } + public Map handleRepeatData() { + return getSalaryArchiveService(user).handleRepeatData(); + } } diff --git a/src/com/engine/salary/wrapper/SalarySystemConfigWrapper.java b/src/com/engine/salary/wrapper/SalarySystemConfigWrapper.java index b3a6fbc61..0dd40eee4 100644 --- a/src/com/engine/salary/wrapper/SalarySystemConfigWrapper.java +++ b/src/com/engine/salary/wrapper/SalarySystemConfigWrapper.java @@ -17,7 +17,6 @@ import com.engine.salary.util.page.SalaryPageUtil; import com.engine.salary.util.valid.RuntimeTypeEnum; import com.engine.salary.util.valid.ValidUtil; import org.apache.commons.lang3.StringUtils; -import tebie.applib.api.O; import weaver.general.BaseBean; import weaver.hrm.User; @@ -134,7 +133,6 @@ public class SalarySystemConfigWrapper extends Service { } public Map saveEncryptSetting(AppSettingSaveParam param) { - ValidUtil.doValidator(param); return getSalarySysConfService(user).saveEncryptSetting(param); } diff --git a/src/com/engine/salary/wrapper/SpecialAddDeductionWrapper.java b/src/com/engine/salary/wrapper/SpecialAddDeductionWrapper.java new file mode 100644 index 000000000..9edb7ecaa --- /dev/null +++ b/src/com/engine/salary/wrapper/SpecialAddDeductionWrapper.java @@ -0,0 +1,203 @@ +package com.engine.salary.wrapper; + +import com.api.browser.bean.SearchConditionGroup; +import com.api.browser.bean.SearchConditionItem; +import com.api.browser.util.ConditionFactory; +import com.api.browser.util.ConditionType; +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.salary.entity.datacollection.dto.SpecialAddDeductionListDTO; +import com.engine.salary.entity.datacollection.dto.SpecialAddDeductionRecordDTO; +import com.engine.salary.entity.datacollection.param.*; +import com.engine.salary.entity.datacollection.po.SpecialAddDeductionPO; +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.service.SalaryEmployeeService; +import com.engine.salary.service.SpecialAddDeductionService; +import com.engine.salary.service.TaxAgentService; +import com.engine.salary.service.impl.SalaryEmployeeServiceImpl; +import com.engine.salary.service.impl.SpecialAddDeductionServiceImpl; +import com.engine.salary.service.impl.TaxAgentServiceImpl; +import com.engine.salary.util.SalaryI18nUtil; +import com.engine.salary.util.page.PageInfo; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import weaver.hrm.User; + +import java.util.*; + +/** + * 专项附加扣除 + */ +public class SpecialAddDeductionWrapper extends Service { + private SpecialAddDeductionService getSpecialAddDeductionService(User user) { + return ServiceUtil.getService(SpecialAddDeductionServiceImpl.class, user); + } + private TaxAgentService getTaxAgentV2Service(User user) { + return ServiceUtil.getService(TaxAgentServiceImpl.class, user); + } + private SalaryEmployeeService getSalaryEmployeeService(User user) { + return ServiceUtil.getService(SalaryEmployeeServiceImpl.class, user); + } + /** + * 数据采集-专项附加扣除列表的高级搜索 + * + * @return + */ + public Map getSearchCondition() { + Map apidatas = new HashMap<>(); + ConditionFactory conditionFactory = new ConditionFactory(user); + + //条件组 + List addGroups = new ArrayList<>(); + + List conditionItems = new ArrayList<>(); + + //文本输入框 + SearchConditionItem username = conditionFactory.createCondition(ConditionType.INPUT, 25034, "username"); + username.setInputType("input"); + username.setColSpan(2);//定义一行显示条件数,默认值为2,当值为1时标识该条件单独占一行 + username.setFieldcol(16); //条件输入框所占宽度,默认值18 + username.setLabelcol(8); + username.setViewAttr(2); // 编辑权限 1:只读,2:可编辑, 3:必填 默认2 + username.setLabel("姓名"); //设置文本值 这个将覆盖多语言标签的值 + conditionItems.add(username); + + SearchConditionItem departmentName = conditionFactory.createCondition(ConditionType.BROWSER, 502227, "departmentName", "4"); + departmentName.setInputType("browser"); + departmentName.setColSpan(2); + departmentName.setFieldcol(16); + departmentName.setLabelcol(8); + departmentName.setViewAttr(2); + departmentName.setIsQuickSearch(false); + departmentName.setLabel("部门"); + conditionItems.add(departmentName); + + + SearchConditionItem jobNum = conditionFactory.createCondition(ConditionType.INPUT, 25034, "jobNum"); + jobNum.setInputType("input"); + jobNum.setColSpan(2); + jobNum.setFieldcol(16); + jobNum.setLabelcol(8); + jobNum.setViewAttr(2); + jobNum.setLabel("工号"); + conditionItems.add(jobNum); + + addGroups.add(new SearchConditionGroup("常用条件", true, conditionItems)); + + apidatas.put("condition", addGroups); + return apidatas; + } + + /** + * 数据采集-专项附加扣除列表(分页) + * + * @param queryParam + * @return + */ + public PageInfo list(SpecialAddDeductionQueryParam queryParam) { + return getSpecialAddDeductionService(user).listPage(queryParam); + + } + + /** + * 数据采集-专项附加扣除详情列表(分页) + * + * @param queryParam + * @return + */ + public PageInfo getDetailList(SpecialAddDeductionQueryParam queryParam) { + Long id = queryParam.getSpecialAddDeductionId(); + + SpecialAddDeductionPO po = getSpecialAddDeductionService(user).getById(id); + if (po == null) { + throw new SalaryRunTimeException(String.format(SalaryI18nUtil.getI18nLabel(100415, "专项附加扣除不存在") + "[id:%s]", id)); + } + queryParam.setEmployeeId(po.getEmployeeId()); + + return getSpecialAddDeductionService(user).recordListPage(queryParam); + } + + /** + * 导出-专项附加扣除列表 + * + * @param queryParam + * @return + */ + public XSSFWorkbook export(SpecialAddDeductionQueryParam queryParam) { + return getSpecialAddDeductionService(user).export(queryParam, false); + } + + /** + * 导出-专项附加扣除详情列表 + * + * @param queryParam + * @return + */ + public XSSFWorkbook exportDetail(SpecialAddDeductionQueryParam queryParam) { + Long id = queryParam.getSpecialAddDeductionId(); + SpecialAddDeductionPO po = getSpecialAddDeductionService(user).getById(id); + if (po == null) { + throw new SalaryRunTimeException(String.format(SalaryI18nUtil.getI18nLabel( 100415, "专项附加扣除不存在") + "[id:%s]", id)); + } + return getSpecialAddDeductionService(user).exportDetail(queryParam); + } + + /** + * 下载导入模板 + * + * @param queryParam + * @return + */ + public XSSFWorkbook downloadTemplate(SpecialAddDeductionQueryParam queryParam) { + return getSpecialAddDeductionService(user).export(queryParam, true); + } + + /** + * 预览 + */ + public Map preview(SpecialAddDeductionImportParam importParam){ + return getSpecialAddDeductionService(user).preview(importParam); + } + + /** + * 导入数据 + */ + public Map importData(SpecialAddDeductionImportParam importParam){ + return getSpecialAddDeductionService(user).importData(importParam); + } + + /** + * 编辑数据 + */ + public void editData(SpecialAddDeductionParam specialAddDeductionParam) { + getSpecialAddDeductionService(user).editData(specialAddDeductionParam); + } + + + /** + * 新增数据 + */ + public void createData(SpecialAddDeductionParam specialAddDeductionParam) { + getSpecialAddDeductionService(user).createData(specialAddDeductionParam); + } + + /** + * 删除所选数据 + */ + public void deleteSelectData(SpecialAddDeductionRecordDeleteParam deleteParam) { + getSpecialAddDeductionService(user).deleteSelectData(deleteParam); + } + + /** + * 一键清空所有数据 + */ + public void deleteAllData(SpecialAddDeductionRecordDeleteParam deleteParam) { + getSpecialAddDeductionService(user).deleteAllData(deleteParam); + } + + public SpecialAddDeductionRecordDTO getRecordById(Long id) { + if (id == null) { + throw new SalaryRunTimeException("专项附加扣除主键[id]必传"); + } + return getSpecialAddDeductionService(user).getRecordById(id); + } +}