diff --git a/src/com/engine/salary/biz/SpecialAddDeductionBiz.java b/src/com/engine/salary/biz/SpecialAddDeductionBiz.java index c505a964e..ab63a4540 100644 --- a/src/com/engine/salary/biz/SpecialAddDeductionBiz.java +++ b/src/com/engine/salary/biz/SpecialAddDeductionBiz.java @@ -1,6 +1,7 @@ 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; @@ -37,10 +38,18 @@ public class SpecialAddDeductionBiz extends BaseBean { } } - public List listByDeclareMonthAndTaxAgentIds(Date declareMonth, List taxAgentIds) { + public List listByParam(SpecialAddDeductionQueryParam param) { try (SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession()) { SpecialAddDeductionMapper mapper = sqlSession.getMapper(SpecialAddDeductionMapper.class); - List pos = mapper.listByDeclareMonthAndTaxAgentIds(declareMonth, taxAgentIds); + 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); } } @@ -107,7 +116,7 @@ public class SpecialAddDeductionBiz extends BaseBean { ArrayList::new) ); // 查询已有数据 - List list = listByDeclareMonthAndTaxAgentIds(po.getDeclareMonth(), null); + List list = listByTaxAgentIds(null); // 待修改的 本地已存在则更新【交集】 List updateList = list.stream() .map(m -> finalPos.stream() diff --git a/src/com/engine/salary/entity/datacollection/dto/SpecialAddDeductionRecordDTO.java b/src/com/engine/salary/entity/datacollection/dto/SpecialAddDeductionRecordDTO.java index d35dc4574..a7cb63bac 100644 --- a/src/com/engine/salary/entity/datacollection/dto/SpecialAddDeductionRecordDTO.java +++ b/src/com/engine/salary/entity/datacollection/dto/SpecialAddDeductionRecordDTO.java @@ -31,12 +31,6 @@ public class SpecialAddDeductionRecordDTO { @SalaryTableColumn(column = "id", display = false) private Long id; - //申报月份 - @JsonFormat(pattern = "yyyy-MM", timezone = "GMT+8") - @SalaryTableColumn(text = "申报月份", width = "10%", column = "declareMonth", transmethod = "com.engine.salary.transmethod.TransMethod.timeToMoth") - @TableTitle(title = "申报月份", dataIndex = "declareMonth", key = "declareMonth") - private Date declareMonth; - //员工id private Long employeeId; diff --git a/src/com/engine/salary/entity/datacollection/param/SpecialAddDeductionImportParam.java b/src/com/engine/salary/entity/datacollection/param/SpecialAddDeductionImportParam.java index 231c49af7..d221c7a69 100644 --- a/src/com/engine/salary/entity/datacollection/param/SpecialAddDeductionImportParam.java +++ b/src/com/engine/salary/entity/datacollection/param/SpecialAddDeductionImportParam.java @@ -22,9 +22,6 @@ public class SpecialAddDeductionImportParam { //上传文件id String imageId; - //税款所属期 - String declareMonth; - //个税扣缴义务人 String taxAgentId; diff --git a/src/com/engine/salary/entity/datacollection/param/SpecialAddDeductionParam.java b/src/com/engine/salary/entity/datacollection/param/SpecialAddDeductionParam.java index 8ef0b4816..76408c9d4 100644 --- a/src/com/engine/salary/entity/datacollection/param/SpecialAddDeductionParam.java +++ b/src/com/engine/salary/entity/datacollection/param/SpecialAddDeductionParam.java @@ -19,9 +19,6 @@ public class SpecialAddDeductionParam { // 主键id private Long id; - // 申报月份 - private String declareMonth; - // 员工id private Long employeeId; diff --git a/src/com/engine/salary/entity/datacollection/param/SpecialAddDeductionQueryParam.java b/src/com/engine/salary/entity/datacollection/param/SpecialAddDeductionQueryParam.java index 6ab00f45f..a9e887bb7 100644 --- a/src/com/engine/salary/entity/datacollection/param/SpecialAddDeductionQueryParam.java +++ b/src/com/engine/salary/entity/datacollection/param/SpecialAddDeductionQueryParam.java @@ -27,10 +27,6 @@ public class SpecialAddDeductionQueryParam extends BaseQueryParam { //主键id private Long id; - //申报年月 - private List declareMonth; - private List declareMonthDate; - //姓名 private String username; diff --git a/src/com/engine/salary/entity/datacollection/po/SpecialAddDeductionPO.java b/src/com/engine/salary/entity/datacollection/po/SpecialAddDeductionPO.java index 8c1570af7..32cfe786b 100644 --- a/src/com/engine/salary/entity/datacollection/po/SpecialAddDeductionPO.java +++ b/src/com/engine/salary/entity/datacollection/po/SpecialAddDeductionPO.java @@ -28,11 +28,6 @@ public class SpecialAddDeductionPO { */ private Long taxAgentId; - /** - * 申报年月 - */ - private Date declareMonth; - /** * 子女教育 */ diff --git a/src/com/engine/salary/mapper/datacollection/SpecialAddDeductionMapper.java b/src/com/engine/salary/mapper/datacollection/SpecialAddDeductionMapper.java index 501189979..8d097b221 100644 --- a/src/com/engine/salary/mapper/datacollection/SpecialAddDeductionMapper.java +++ b/src/com/engine/salary/mapper/datacollection/SpecialAddDeductionMapper.java @@ -1,5 +1,4 @@ package com.engine.salary.mapper.datacollection; -import java.util.Date; import com.engine.salary.entity.datacollection.dto.SpecialAddDeductionListDTO; import com.engine.salary.entity.datacollection.dto.SpecialAddDeductionRecordDTO; @@ -22,8 +21,7 @@ public interface SpecialAddDeductionMapper { List listDtoByParam(@Param("param") SpecialAddDeductionQueryParam param); - List listByDeclareMonthAndTaxAgentIds(@Param("declareMonth") Date declareMonth, - @Param("taxAgentIds") List taxAgentIds); + List listByTaxAgentIds(@Param("taxAgentIds") List taxAgentIds); List listByParam(@Param("param") SpecialAddDeductionQueryParam param); diff --git a/src/com/engine/salary/mapper/datacollection/SpecialAddDeductionMapper.xml b/src/com/engine/salary/mapper/datacollection/SpecialAddDeductionMapper.xml index 01cdbc987..657985390 100644 --- a/src/com/engine/salary/mapper/datacollection/SpecialAddDeductionMapper.xml +++ b/src/com/engine/salary/mapper/datacollection/SpecialAddDeductionMapper.xml @@ -7,7 +7,6 @@ - @@ -26,7 +25,6 @@ t1.id, t1.employee_id, t1.tax_agent_id, - t1.declare_month, t1.children_education, t1.continuing_education, t1.housing_loan_interest, @@ -43,7 +41,6 @@ t1.id, - t1.declare_month, t1.employee_id, t2.id AS tax_agent_id, t2.name AS tax_agent_name, @@ -81,15 +78,6 @@ OR e.workcode like CONCAT('%',#{param.keyword},'%') ) - - - - AND t1.declare_month = #{param.declareMonthDate[0]} - - - AND (t1.declare_month BETWEEN #{param.declareMonthDate[0]} AND #{param.declareMonthDate[1]}) - - AND e.lastname like CONCAT('%',#{param.username},'%') @@ -144,15 +132,6 @@ ) - - - AND t1.declare_month = #{param.declareMonthDate[0]} - - - AND (t1.declare_month BETWEEN #{param.declareMonthDate[0]} AND #{param.declareMonthDate[1]}) - - - AND e.lastname like '%'||#{param.username}||'%' @@ -205,15 +184,6 @@ ) - - - AND t1.declare_month = #{param.declareMonthDate[0]} - - - AND (t1.declare_month BETWEEN #{param.declareMonthDate[0]} AND #{param.declareMonthDate[1]}) - - - AND e.lastname like '%'+#{param.username}+'%' @@ -268,9 +238,6 @@ tax_agent_id, - - declare_month, - children_education, @@ -313,9 +280,6 @@ #{taxAgentId,jdbcType=BIGINT}, - - #{declareMonth,jdbcType=TIMESTAMP}, - #{childrenEducation,jdbcType=VARCHAR}, @@ -363,9 +327,6 @@ tax_agent_id = #{taxAgentId,jdbcType=BIGINT}, - - declare_month = #{declareMonth,jdbcType=TIMESTAMP}, - children_education = #{childrenEducation,jdbcType=VARCHAR}, @@ -424,13 +385,6 @@ - - - - when id = #{item.id,jdbcType=BIGINT} then #{item.declareMonth,jdbcType=TIMESTAMP} - - - @@ -525,13 +479,12 @@ insert into hrsa_special_add_deduction - (employee_id, tax_agent_id, declare_month, children_education, continuing_education, + (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.declareMonth,jdbcType=TIMESTAMP}, #{item.childrenEducation,jdbcType=VARCHAR}, #{item.continuingEducation,jdbcType=VARCHAR}, #{item.housingLoanInterest,jdbcType=VARCHAR}, #{item.housingRent,jdbcType=VARCHAR}, #{item.supportingElder,jdbcType=VARCHAR}, #{item.seriousIllnessTreatment,jdbcType=VARCHAR}, @@ -560,7 +513,7 @@ - select from hrsa_special_add_deduction t1 @@ -570,7 +523,6 @@ t1.delete_type = 0 AND t2.delete_type = 0 AND e.status not in (7) and (e.accounttype is null or e.accounttype = 0) - and declare_month=#{declareMonth,jdbcType=TIMESTAMP} AND t1.tax_agent_id IN @@ -592,7 +544,7 @@ AND e.status not in (7) and (e.accounttype is null or e.accounttype = 0) - order by t1.declare_month desc + order by t1.create_time desc diff --git a/src/com/engine/salary/service/impl/SpecialAddDeductionServiceImpl.java b/src/com/engine/salary/service/impl/SpecialAddDeductionServiceImpl.java index f658c66cb..ae3214328 100644 --- a/src/com/engine/salary/service/impl/SpecialAddDeductionServiceImpl.java +++ b/src/com/engine/salary/service/impl/SpecialAddDeductionServiceImpl.java @@ -15,11 +15,11 @@ import com.engine.salary.entity.datacollection.param.SpecialAddDeductionParam; import com.engine.salary.entity.datacollection.param.SpecialAddDeductionQueryParam; import com.engine.salary.entity.datacollection.po.SpecialAddDeductionPO; import com.engine.salary.entity.salaryacct.po.SalaryAcctEmployeePO; +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; @@ -29,10 +29,8 @@ 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.SalaryDateUtil; import com.engine.salary.util.SalaryEntityUtil; import com.engine.salary.util.SalaryI18nUtil; -import com.engine.salary.util.db.MapperProxyFactory; import com.engine.salary.util.excel.ExcelComment; import com.engine.salary.util.excel.ExcelParseHelper; import com.engine.salary.util.excel.ExcelUtil; @@ -59,8 +57,8 @@ import static com.engine.salary.constant.SalaryDefaultTenantConstant.DEFAULT_TEN public class SpecialAddDeductionServiceImpl extends Service implements SpecialAddDeductionService { - private SpecialAddDeductionMapper getSpecialAddDeductionMapper() { - return MapperProxyFactory.getProxy(SpecialAddDeductionMapper.class); + private SpecialAddDeductionBiz getSpecialAddDeductionMapper() { + return new SpecialAddDeductionBiz(); } private TaxAgentService getTaxAgentService(User user) { @@ -91,13 +89,6 @@ public class SpecialAddDeductionServiceImpl extends Service implements SpecialAd @Override public PageInfo listPage(SpecialAddDeductionQueryParam queryParam) { - //申报月份 - List declareMonth = queryParam.getDeclareMonth(); - if (CollectionUtils.isNotEmpty(declareMonth)) { - queryParam.setDeclareMonth(declareMonth.stream().map(e -> e + "-01 00:00:00").collect(Collectors.toList())); - queryParam.setDeclareMonthDate(declareMonth.stream().map(e -> e + "-01 00:00:00").map(SalaryDateUtil::dateStrToLocalTime).collect(Collectors.toList())); - } - //排序配置 OrderRuleVO orderRule = getSalarySysConfService(user).orderRule(); queryParam.setOrderRule(orderRule); @@ -106,16 +97,10 @@ public class SpecialAddDeductionServiceImpl extends Service implements SpecialAd Boolean needAuth = getTaxAgentService(user).isNeedAuth(employeeId); if (needAuth) { - List taxAgentIdsAsAdmin = getTaxAgentService(user) - .listAllTaxAgentsAsAdmin(employeeId).stream().map(TaxAgentPO::getId).collect(Collectors.toList()); - if (CollectionUtils.isEmpty(taxAgentIdsAsAdmin)) { - return new PageInfo<>(SpecialAddDeductionListDTO.class); - } - queryParam.setTaxAgentIds(taxAgentIdsAsAdmin); + putQueryRange(queryParam, employeeId); } SalaryPageUtil.start(queryParam.getCurrent(), queryParam.getPageSize()); List list = getSpecialAddDeductionMapper().listByParam(queryParam); - SpecialAddDeductionEncrypt.decrypt(list); return new PageInfo<>(list, SpecialAddDeductionListDTO.class); } @@ -123,29 +108,35 @@ public class SpecialAddDeductionServiceImpl extends Service implements SpecialAd public PageInfo recordListPage(SpecialAddDeductionQueryParam queryParam) { long employeeId = user.getUID(); - //申报月份 - List declareMonth = queryParam.getDeclareMonth(); - if (CollectionUtils.isNotEmpty(declareMonth)) { - queryParam.setDeclareMonth(declareMonth.stream().map(e -> e + "-01 00:00:00").collect(Collectors.toList())); - queryParam.setDeclareMonthDate(declareMonth.stream().map(e -> e + "-01 00:00:00").map(SalaryDateUtil::dateStrToLocalTime).collect(Collectors.toList())); - } - Boolean needAuth = getTaxAgentService(user).isNeedAuth(employeeId); if (needAuth) { - List taxAgentIdsAsAdmin = getTaxAgentService(user) - .listAllTaxAgentsAsAdmin(employeeId).stream().map(TaxAgentPO::getId) - .collect(Collectors.toList()); - if (CollectionUtils.isEmpty(taxAgentIdsAsAdmin)) { - return new PageInfo<>(SpecialAddDeductionRecordDTO.class); - } - queryParam.setTaxAgentIds(taxAgentIdsAsAdmin); + putQueryRange(queryParam, employeeId); } SalaryPageUtil.start(queryParam.getCurrent(), queryParam.getPageSize()); - List list = getSpecialAddDeductionMapper().listDtoByParam(queryParam); - SpecialAddDeductionEncrypt.decrypt(list); + List list = getSpecialAddDeductionMapper().listDTOByParam(queryParam); return new PageInfo<>(list, SpecialAddDeductionRecordDTO.class); } + private void putQueryRange(SpecialAddDeductionQueryParam queryParam, long employeeId) { + 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) { @@ -188,8 +179,6 @@ public class SpecialAddDeductionServiceImpl extends Service implements SpecialAd //excel文件id String imageId = Util.null2String(importParam.getImageId()); Validate.notBlank(imageId, "imageId为空"); - //税款所属期 - String declareMonthStr = Util.null2String(importParam.getDeclareMonth()); //个税扣缴义务人 String taxAgentId = Util.null2String(importParam.getTaxAgentId()); @@ -207,14 +196,9 @@ public class SpecialAddDeductionServiceImpl extends Service implements SpecialAd List employees = employBiz.listEmployee(); // 获取所有个税扣缴义务人 Collection taxAgentList = getTaxAgentService(user).listTaxAgentAndEmployeeTree(currentEmployeeId); - //税款所属期 - Date declareMonth = SalaryDateUtil.stringToDate(declareMonthStr + "-01"); - // 获取已经核算的数据 - List salaryAcctEmployees = getAddUpDeductionService(user) - .getAccountedEmployeeData(declareMonthStr); // 查询已有数据 List list = getSpecialAddDeductionMapper() - .listByDeclareMonthAndTaxAgentIds(declareMonth, null); + .listByTaxAgentIds(null); // 错误excel内容 List errorData = new ArrayList<>(); @@ -231,7 +215,7 @@ public class SpecialAddDeductionServiceImpl extends Service implements SpecialAd .createTime(now) .updateTime(now) .creator((long) user.getUID()) - .declareMonth(declareMonth).build(); + .build(); //异常点数量 int errorSum = 0; @@ -328,25 +312,6 @@ public class SpecialAddDeductionServiceImpl extends Service implements SpecialAd //fixme 分权判断 -// - // 判断是否有核算过 - if (CollectionUtils.isNotEmpty(salaryAcctEmployees)) { - SpecialAddDeductionPO finalPo = po; - Optional optionalAcctEmp = - salaryAcctEmployees.stream() - .filter(f -> f.getEmployeeId().equals(finalPo.getEmployeeId()) && f.getTaxAgentId().equals(finalPo.getTaxAgentId())) - .findFirst(); - boolean isExist = list.stream() - .anyMatch(f -> f.getEmployeeId().equals(finalPo.getEmployeeId()) && f.getTaxAgentId().equals(finalPo.getTaxAgentId())); - if (optionalAcctEmp.isPresent() && isExist) { - Map errorMessageMap = new HashMap(); - errorMessageMap.put("message", rowIndex + "该年月这条数据已经核算过,不可导入"); - errorData.add(errorMessageMap); - errorSum += 1; - } - } - - if (errorSum == 0) { successCount += 1; // 合格数据 @@ -373,20 +338,14 @@ public class SpecialAddDeductionServiceImpl extends Service implements SpecialAd private void checkImportParam(SpecialAddDeductionImportParam importParam) { //excel文件id String imageId = Util.null2String(importParam.getImageId()); - //税款所属期 - String declareMonthStr = Util.null2String(importParam.getDeclareMonth()); //个税扣缴义务人 String taxAgentId = Util.null2String(importParam.getTaxAgentId()); if (StringUtils.isBlank(imageId)) { throw new SalaryRunTimeException("文件不存在"); } - if (StringUtils.isBlank(declareMonthStr)) { - throw new SalaryRunTimeException("税款所属期为空"); - } } - /** * 导出 * @@ -416,15 +375,7 @@ public class SpecialAddDeductionServiceImpl extends Service implements SpecialAd OrderRuleVO orderRule = getSalarySysConfService(user).orderRule(); param.setOrderRule(orderRule); - //申报月份 - List declareMonth = param.getDeclareMonth(); - if (CollectionUtils.isNotEmpty(declareMonth)) { - param.setDeclareMonth(declareMonth.stream().map(e -> e + "-01 00:00:00").collect(Collectors.toList())); - param.setDeclareMonthDate(declareMonth.stream().map(e -> e + "-01 00:00:00").map(SalaryDateUtil::dateStrToLocalTime).collect(Collectors.toList())); - } - List list = getSpecialAddDeductionMapper().listByParam(param); - SpecialAddDeductionEncrypt.decrypt(list); // 开启分权并且不是薪酬模块总管理员 if (getTaxAgentService(user).isOpenDevolution() && !getTaxAgentService(user).isChief(employeeId)) { List taxAgentIdsAsAdmin = getTaxAgentService(user).listAllTaxAgentsAsAdmin(employeeId).stream().map(TaxAgentPO::getId).collect(Collectors.toList()); @@ -492,19 +443,13 @@ public class SpecialAddDeductionServiceImpl extends Service implements SpecialAd //构建参数 param.setEmployeeId(po.getEmployeeId()); - //申报月份 - List declareMonth = param.getDeclareMonth(); - if (CollectionUtils.isNotEmpty(declareMonth)) { - param.setDeclareMonth(declareMonth.stream().map(e -> e + "-01 00:00:00").collect(Collectors.toList())); - param.setDeclareMonthDate(declareMonth.stream().map(e -> e + "-01 00:00:00").map(SalaryDateUtil::dateStrToLocalTime).collect(Collectors.toList())); - } //获取操作按钮资源 List> rowList = getExcelRowDetailList(param); //获取excel - return ExcelUtil.genWorkbook(rowList, "其他免税扣除明细"); + return ExcelUtil.genWorkbook(rowList, "专项附加扣除明细"); } @@ -516,18 +461,17 @@ public class SpecialAddDeductionServiceImpl extends Service implements SpecialAd */ private List> getExcelRowDetailList(SpecialAddDeductionQueryParam param) { //excel标题 - List title = Arrays.asList("姓名", "申报月份", "个税扣缴义务人", "部门", "手机号", "工号", "子女教育", "继续教育", "住房贷款利息", "住房租金", "赡养老人", "大病医疗", "婴幼儿照护"); + List title = Arrays.asList("姓名", "个税扣缴义务人", "部门", "手机号", "工号", "子女教育", "继续教育", "住房贷款利息", "住房租金", "赡养老人", "大病医疗", "婴幼儿照护"); SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM"); //查询详细信息 - List list = getSpecialAddDeductionMapper().listDtoByParam(param); + List list = getSpecialAddDeductionMapper().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.getDeclareMonth() == null ? "" : formatter.format(dto.getDeclareMonth()))); cellList.add(Util.null2String(dto.getTaxAgentName())); cellList.add(Util.null2String(dto.getDepartmentName())); cellList.add(Util.null2String(dto.getMobile())); @@ -556,12 +500,11 @@ public class SpecialAddDeductionServiceImpl extends Service implements SpecialAd throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100342, "参数有误:申报月份必传")); } SpecialAddDeductionBiz SpecialAddDeductionBiz = new SpecialAddDeductionBiz(); - return SpecialAddDeductionBiz.listByDeclareMonthAndTaxAgentIds(SalaryDateUtil.toDateStartOfMonth(declareMonth), null); + return SpecialAddDeductionBiz.listByTaxAgentIds(null); } @Override public void editData(SpecialAddDeductionParam specialAddDeductionParam) { - String declareMonthStr = specialAddDeductionParam.getDeclareMonth(); SpecialAddDeductionBiz SpecialAddDeductionBiz = new SpecialAddDeductionBiz(); Long currentEmployeeId = (long) user.getUID(); @@ -573,24 +516,11 @@ public class SpecialAddDeductionServiceImpl extends Service implements SpecialAd 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("该个税扣缴义务人无权限编辑此数据!"); } - // 获取已经核算的数据 - List salaryAcctEmployees = - getAddUpDeductionService(user).getAccountedEmployeeData(declareMonthStr); - // 判断是否有核算过 - if (CollectionUtils.isNotEmpty(salaryAcctEmployees)) { - Optional optionalAcctEmp = - salaryAcctEmployees.stream() - .filter(f -> f.getEmployeeId().equals(specialAddDeductionParam.getEmployeeId()) && f.getTaxAgentId().equals(specialAddDeductionParam.getTaxAgentId())) - .findFirst(); - if (optionalAcctEmp.isPresent()) { - throw new SalaryRunTimeException("该年月这条数据已经核算过,不可进行编辑!"); - } - } ArrayList updateList = new ArrayList<>(); SpecialAddDeductionPO build = SpecialAddDeductionPO.builder() .id(specialAddDeductionParam.getId()) @@ -613,18 +543,12 @@ public class SpecialAddDeductionServiceImpl extends Service implements SpecialAd SalarySysConfPO salarySysConfPO = getSalarySysConfMapper().getOneByCode("matchEmployeeMode"); String confValue = (salarySysConfPO != null && salarySysConfPO.getConfValue() != null && !"".equals(salarySysConfPO.getConfValue())) ? salarySysConfPO.getConfValue() : "0"; - //税款所属期 - String declareMonthStr = Util.null2String(specialAddDeductionParam.getDeclareMonth()); //人员信息 List employees = employBiz.listEmployee(); // 获取所有个税扣缴义务人 Collection taxAgentList = getTaxAgentService(user).listTaxAgentAndEmployeeTree(currentEmployeeId); - //税款所属期 - Date declareMonth = SalaryDateUtil.stringToDate(declareMonthStr + "-01"); - // 获取已经核算的数据 - List salaryAcctEmployees = getAddUpDeductionService(user).getAccountedEmployeeData(declareMonthStr); // 查询已有数据 - List list = getSpecialAddDeductionMapper().listByDeclareMonthAndTaxAgentIds(declareMonth, null); + List list = getSpecialAddDeductionMapper().listByTaxAgentIds(null); //合规数据 List insertData = new ArrayList<>(); Date now = new Date(); @@ -634,7 +558,7 @@ public class SpecialAddDeductionServiceImpl extends Service implements SpecialAd .createTime(now) .updateTime(now) .creator((long) user.getUID()) - .declareMonth(declareMonth).build(); + .build(); //筛选导入人员信息可以在人力资源池中匹配到的人员信息 boolean employeeSameId = employees.stream() @@ -656,8 +580,7 @@ public class SpecialAddDeductionServiceImpl extends Service implements SpecialAd throw new SalaryRunTimeException("个税扣缴义务人不存在或不在权限范围内"); } } - - //商业健康保险 + //数据填充 po.setContinuingEducation(specialAddDeductionParam.getContinuingEducation()) .setChildrenEducation(specialAddDeductionParam.getChildrenEducation()) .setHousingLoanInterest(specialAddDeductionParam.getHousingLoanInterest()) @@ -666,20 +589,6 @@ public class SpecialAddDeductionServiceImpl extends Service implements SpecialAd .setSeriousIllnessTreatment(specialAddDeductionParam.getSeriousIllnessTreatment()) .setInfantCare(specialAddDeductionParam.getInfantCare()); //fixme 分权判断 - - // 判断是否有核算过 - if (CollectionUtils.isNotEmpty(salaryAcctEmployees)) { - SpecialAddDeductionPO finalPo = po; - Optional optionalAcctEmp = - salaryAcctEmployees.stream() - .filter(f -> f.getEmployeeId().equals(finalPo.getEmployeeId()) && f.getTaxAgentId().equals(finalPo.getTaxAgentId())) - .findFirst(); - boolean isExist = list.stream() - .anyMatch(f -> f.getEmployeeId().equals(finalPo.getEmployeeId()) && f.getTaxAgentId().equals(finalPo.getTaxAgentId())); - if (optionalAcctEmp.isPresent() && isExist) { - throw new SalaryRunTimeException("该年月这条数据已经核算过,不可导入"); - } - } insertData.add(po); //入库 SpecialAddDeductionBiz.handleImportData(insertData); @@ -756,7 +665,7 @@ public class SpecialAddDeductionServiceImpl extends Service implements SpecialAd taxAgentIds = tai; } // 获取所有想要删除的数据 - List list = specialAddDeductionBiz.listByDeclareMonthAndTaxAgentIds(declareMonthDate, taxAgentIds); + List list = specialAddDeductionBiz.listByTaxAgentIds(taxAgentIds); // 获取已经核算的数据 List salaryAcctEmployees = getAddUpDeductionService(user) .getAccountedEmployeeData(declareMonthStr); diff --git a/src/com/engine/salary/web/SpecialAddDeductionController.java b/src/com/engine/salary/web/SpecialAddDeductionController.java index 3fb80b286..49416aa62 100644 --- a/src/com/engine/salary/web/SpecialAddDeductionController.java +++ b/src/com/engine/salary/web/SpecialAddDeductionController.java @@ -202,11 +202,6 @@ public class SpecialAddDeductionController { if (StringUtils.isNotBlank(id)) { param.setId(Long.valueOf(id)); } - String declareMonth = request.getParameter("declareMonth"); - if (StringUtils.isNotBlank(declareMonth)) { - param.setDeclareMonth(Arrays.stream(declareMonth.split(",")).map(e -> e + "-01 00:00:00").collect(Collectors.toList())); - param.setDeclareMonthDate(Arrays.stream(declareMonth.split(",")).map(e -> e + "-01 00:00:00").map(SalaryDateUtil::dateStrToLocalTime).collect(Collectors.toList())); - } String username = request.getParameter("username"); if (StringUtils.isNotBlank(username)) { diff --git a/src/com/engine/salary/wrapper/SpecialAddDeductionWrapper.java b/src/com/engine/salary/wrapper/SpecialAddDeductionWrapper.java index feb244d3f..270022b3f 100644 --- a/src/com/engine/salary/wrapper/SpecialAddDeductionWrapper.java +++ b/src/com/engine/salary/wrapper/SpecialAddDeductionWrapper.java @@ -53,9 +53,9 @@ public class SpecialAddDeductionWrapper extends Service { ConditionFactory conditionFactory = new ConditionFactory(user); //条件组 - List addGroups = new ArrayList(); + List addGroups = new ArrayList<>(); - List conditionItems = new ArrayList(); + List conditionItems = new ArrayList<>(); //文本输入框 SearchConditionItem username = conditionFactory.createCondition(ConditionType.INPUT, 25034, "username");