From cedc9f2644b2dc7dc59176842c9c7a98bef59d6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=92=B1=E6=B6=9B?= <15850646081@163.com> Date: Tue, 7 Jun 2022 15:43:22 +0800 Subject: [PATCH] =?UTF-8?q?=E8=80=83=E5=8B=A4=E5=92=8C=E7=94=B3=E6=8A=A5?= =?UTF-8?q?=E8=A1=A8=E7=9A=84=E5=88=86=E6=9D=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../param/AttendQuoteQueryParam.java | 2 + .../entity/salarysob/bo/SalarySobBO.java | 3 +- .../salarysob/dto/SalarySobListDTO.java | 4 + .../salary/entity/taxagent/bo/TaxAgentBO.java | 2 +- .../param/TaxDeclarationSaveParam.java | 30 ++-- .../datacollection/AttendQuoteMapper.xml | 6 + .../mapper/salarysob/SalarySobMapper.xml | 3 + .../mapper/taxagent/TaxAgentMapper.java | 7 - .../salary/mapper/taxagent/TaxAgentMapper.xml | 34 +--- .../taxdeclaration/TaxDeclarationMapper.xml | 3 + .../salary/service/SalarySobService.java | 10 ++ .../impl/AddUpSituationServiceImpl.java | 20 +-- .../service/impl/AttendQuoteServiceImpl.java | 32 +++- .../impl/SalaryAcctRecordServiceImpl.java | 2 +- .../service/impl/SalarySobServiceImpl.java | 39 +++++ .../impl/TaxAgentAdminServiceImpl.java | 1 + .../service/impl/TaxAgentBaseServiceImpl.java | 3 +- .../service/impl/TaxAgentServiceImpl.java | 7 +- .../salary/web/TaxDeclarationController.java | 1 - .../salary/wrapper/SalarySobWrapper.java | 6 +- .../salary/wrapper/TaxDeclarationWrapper.java | 156 +++++++++++++----- 21 files changed, 256 insertions(+), 115 deletions(-) diff --git a/src/com/engine/salary/entity/datacollection/param/AttendQuoteQueryParam.java b/src/com/engine/salary/entity/datacollection/param/AttendQuoteQueryParam.java index dffb955f2..0fa0f531e 100644 --- a/src/com/engine/salary/entity/datacollection/param/AttendQuoteQueryParam.java +++ b/src/com/engine/salary/entity/datacollection/param/AttendQuoteQueryParam.java @@ -25,6 +25,8 @@ public class AttendQuoteQueryParam extends BaseQueryParam { private Collection ids; + private Collection salarySobIds; + //薪资所属月 private List salaryYearMonth; } diff --git a/src/com/engine/salary/entity/salarysob/bo/SalarySobBO.java b/src/com/engine/salary/entity/salarysob/bo/SalarySobBO.java index c7823b955..0e0829760 100644 --- a/src/com/engine/salary/entity/salarysob/bo/SalarySobBO.java +++ b/src/com/engine/salary/entity/salarysob/bo/SalarySobBO.java @@ -64,7 +64,7 @@ public class SalarySobBO { * @param salarySobs 薪资账套po * @return */ - public static List convert2ListDTO(Collection salarySobs) { + public static List convert2ListDTO(Collection salarySobs,Map taxAgentIdTONameMap) { if (CollectionUtils.isEmpty(salarySobs)) { return Collections.emptyList(); } @@ -72,6 +72,7 @@ public class SalarySobBO { .map(salarySobPO -> SalarySobListDTO.builder() .id(salarySobPO.getId()) .name(salarySobPO.getName()) + .taxAgentName(taxAgentIdTONameMap.get(salarySobPO.getTaxAgentId())) .salaryCycle(buildSalaryCycle(salarySobPO)) .disable(salarySobPO.getDisable()) .description(salarySobPO.getDescription()) diff --git a/src/com/engine/salary/entity/salarysob/dto/SalarySobListDTO.java b/src/com/engine/salary/entity/salarysob/dto/SalarySobListDTO.java index 4a83f15b6..60e14ab24 100644 --- a/src/com/engine/salary/entity/salarysob/dto/SalarySobListDTO.java +++ b/src/com/engine/salary/entity/salarysob/dto/SalarySobListDTO.java @@ -42,6 +42,10 @@ public class SalarySobListDTO { @TableTitle(title = "账套名称", key = "name", dataIndex = "name") private String name; + @SalaryTableColumn(text = "个税扣缴义务人", width = "10%", column = "taxAgentName") + @TableTitle(title = "个税扣缴义务人", key = "taxAgentName", dataIndex = "taxAgentName") + private String taxAgentName; + @SalaryTableColumn(text = "薪资周期", width = "10%", column = "salaryCycle", transmethod = "com.engine.salary.transmethod.TransMethod.buildSalaryCycle", otherPara = "column:salaryCycleFromDay") @TableTitle(title = "薪资周期", key = "salaryCycle", dataIndex = "salaryCycle") private String salaryCycle; diff --git a/src/com/engine/salary/entity/taxagent/bo/TaxAgentBO.java b/src/com/engine/salary/entity/taxagent/bo/TaxAgentBO.java index 6ee6ef2b7..739066a33 100644 --- a/src/com/engine/salary/entity/taxagent/bo/TaxAgentBO.java +++ b/src/com/engine/salary/entity/taxagent/bo/TaxAgentBO.java @@ -224,7 +224,7 @@ public class TaxAgentBO { } Date now = new Date(); return TaxAgentPO.builder() - .id(saveParam.getId()) +// .id(saveParam.getId()) .name(saveParam.getName()) .description(saveParam.getDescription()) .createTime(now) diff --git a/src/com/engine/salary/entity/taxdeclaration/param/TaxDeclarationSaveParam.java b/src/com/engine/salary/entity/taxdeclaration/param/TaxDeclarationSaveParam.java index 6c8b48efa..33edb1c8e 100644 --- a/src/com/engine/salary/entity/taxdeclaration/param/TaxDeclarationSaveParam.java +++ b/src/com/engine/salary/entity/taxdeclaration/param/TaxDeclarationSaveParam.java @@ -4,31 +4,37 @@ import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; -import weaver.hrm.User; import java.time.YearMonth; /** - * @description: 生成个税申报表参数 - * @author: xiajun - * @modified By: xiajun - * @date: Created in 12/15/21 9:44 AM - * @version:v1.0 - */ + * 生成个税申报表参数 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ @Data @Builder @NoArgsConstructor @AllArgsConstructor public class TaxDeclarationSaveParam { - //薪资所属月") + /** + * 薪资所属月 + */ private YearMonth salaryMonth; - //备注") + /** + * 个税扣缴义务人 + */ + private Long taxAgentId; + + /** + * 备注 + */ private String description; private String salaryMonthStr; - - private User user; - } diff --git a/src/com/engine/salary/mapper/datacollection/AttendQuoteMapper.xml b/src/com/engine/salary/mapper/datacollection/AttendQuoteMapper.xml index 5eddf1410..6138d6348 100644 --- a/src/com/engine/salary/mapper/datacollection/AttendQuoteMapper.xml +++ b/src/com/engine/salary/mapper/datacollection/AttendQuoteMapper.xml @@ -262,6 +262,12 @@ #{id} + + AND t1.salary_sob_id IN + + #{id} + + diff --git a/src/com/engine/salary/mapper/salarysob/SalarySobMapper.xml b/src/com/engine/salary/mapper/salarysob/SalarySobMapper.xml index 9ea7ef119..ef0ad50f3 100644 --- a/src/com/engine/salary/mapper/salarysob/SalarySobMapper.xml +++ b/src/com/engine/salary/mapper/salarysob/SalarySobMapper.xml @@ -123,6 +123,9 @@ #{taxAgentId} + + AND tax_agent_id = #{taxAgentId} + ORDER BY id DESC diff --git a/src/com/engine/salary/mapper/taxagent/TaxAgentMapper.java b/src/com/engine/salary/mapper/taxagent/TaxAgentMapper.java index c35e9822f..b08a14f5f 100644 --- a/src/com/engine/salary/mapper/taxagent/TaxAgentMapper.java +++ b/src/com/engine/salary/mapper/taxagent/TaxAgentMapper.java @@ -27,13 +27,6 @@ public interface TaxAgentMapper { */ TaxAgentPO getById(Long id); - /** - * 新增,插入所有字段 - * - * @param taxAgent 新增的记录 - * @return 返回影响行数 - */ - int insert(TaxAgentPO taxAgent); /** * 新增,忽略null字段 diff --git a/src/com/engine/salary/mapper/taxagent/TaxAgentMapper.xml b/src/com/engine/salary/mapper/taxagent/TaxAgentMapper.xml index 25b1baffd..ed460ef3d 100644 --- a/src/com/engine/salary/mapper/taxagent/TaxAgentMapper.xml +++ b/src/com/engine/salary/mapper/taxagent/TaxAgentMapper.xml @@ -63,37 +63,11 @@ WHERE id = #{id} AND delete_type = 0 - - - INSERT INTO hrsa_tax_agent - - create_time, - creator, - delete_type, - description, - id, - name, - tenant_key, - update_time, - - - #{createTime}, - #{creator}, - #{deleteType}, - #{description}, - #{id}, - #{name}, - #{tenantKey}, - #{updateTime}, - - - - + + + select hrsa_tax_agent_id.currval from dual + INSERT INTO hrsa_tax_agent diff --git a/src/com/engine/salary/mapper/taxdeclaration/TaxDeclarationMapper.xml b/src/com/engine/salary/mapper/taxdeclaration/TaxDeclarationMapper.xml index 0d9b5b529..0a697f133 100644 --- a/src/com/engine/salary/mapper/taxdeclaration/TaxDeclarationMapper.xml +++ b/src/com/engine/salary/mapper/taxdeclaration/TaxDeclarationMapper.xml @@ -62,6 +62,9 @@ #{id} + + AND tax_agent_id = #{taxAgentId} + ORDER BY id DESC diff --git a/src/com/engine/salary/service/SalarySobService.java b/src/com/engine/salary/service/SalarySobService.java index 317b4ec08..4989bc955 100644 --- a/src/com/engine/salary/service/SalarySobService.java +++ b/src/com/engine/salary/service/SalarySobService.java @@ -63,6 +63,14 @@ public interface SalarySobService { */ List listByDisable(Integer disable); + /** + * 获取拥有管理权限的账套 + * @return + */ + List listByAdmin(); + + List listByTaxAgentId(Long taxAgentId); + /** * 根据薪资类型查询薪资账套 * @@ -130,8 +138,10 @@ public interface SalarySobService { /** * 按权限过滤掉无权限的薪资账套 * + * 总管理员拥有权限 * @param salarySobPOS * @return */ List filterByAuthority(List salarySobPOS); + } diff --git a/src/com/engine/salary/service/impl/AddUpSituationServiceImpl.java b/src/com/engine/salary/service/impl/AddUpSituationServiceImpl.java index e62ada0f3..177098d58 100644 --- a/src/com/engine/salary/service/impl/AddUpSituationServiceImpl.java +++ b/src/com/engine/salary/service/impl/AddUpSituationServiceImpl.java @@ -62,7 +62,7 @@ public class AddUpSituationServiceImpl extends Service implements AddUpSituation return ServiceUtil.getService(AddUpDeductionServiceImpl.class, user); } - private TaxAgentService getTaxAgentV2Service(User user) { + private TaxAgentService getTaxAgentService(User user) { return ServiceUtil.getService(TaxAgentServiceImpl.class, user); } private SalaryEmployeeService getSalaryEmployeeService(User user) { @@ -163,12 +163,12 @@ public class AddUpSituationServiceImpl extends Service implements AddUpSituation public PageInfo listPage(AddUpSituationQueryParam queryParam) { long employeeId = user.getUID(); // 未开启分权或是薪酬模块总管理员 - if (!getTaxAgentV2Service(user).isOpenDevolution() || getTaxAgentV2Service(user).isChief(employeeId)) { + if (!getTaxAgentService(user).isOpenDevolution() || getTaxAgentService(user).isChief(employeeId)) { SalaryPageUtil.start(queryParam.getCurrent(), queryParam.getPageSize()); List list = getAddUpSituationMapper().list(queryParam); return new PageInfo<>(list, AddUpSituationDTO.class); } else { - List taxAgentIdsAsAdmin = getTaxAgentV2Service(user).listAllTaxAgentsAsAdmin(employeeId).stream().map(TaxAgentPO::getId).collect(Collectors.toList()); + List taxAgentIdsAsAdmin = getTaxAgentService(user).listAllTaxAgentsAsAdmin(employeeId).stream().map(TaxAgentPO::getId).collect(Collectors.toList()); List list = getAddUpSituationMapper().list(queryParam); list = list.stream().filter(f -> // 作为管理员 @@ -187,12 +187,12 @@ public class AddUpSituationServiceImpl extends Service implements AddUpSituation public PageInfo recordListPage(AddUpSituationQueryParam queryParam) { long employeeId = user.getUID(); // 未开启分权或是薪酬模块总管理员 - if (!getTaxAgentV2Service(user).isOpenDevolution() || getTaxAgentV2Service(user).isChief(employeeId)) { + if (!getTaxAgentService(user).isOpenDevolution() || getTaxAgentService(user).isChief(employeeId)) { SalaryPageUtil.start(queryParam.getCurrent(), queryParam.getPageSize()); List list = getAddUpSituationMapper().recordList(queryParam); return new PageInfo<>(list, AddUpSituationRecordDTO.class); } else { - List taxAgentIdsAsAdmin = getTaxAgentV2Service(user).listAllTaxAgentsAsAdmin(employeeId).stream().map(TaxAgentPO::getId).collect(Collectors.toList()); + List taxAgentIdsAsAdmin = getTaxAgentService(user).listAllTaxAgentsAsAdmin(employeeId).stream().map(TaxAgentPO::getId).collect(Collectors.toList()); List list = getAddUpSituationMapper().recordList(queryParam); // 分页参数 PageInfo dtoPage = SalaryPageUtil.buildPage(queryParam.getCurrent(), queryParam.getPageSize(), AddUpSituationRecordDTO.class); @@ -253,8 +253,8 @@ public class AddUpSituationServiceImpl extends Service implements AddUpSituation List list = biz.list(param); // 开启分权并且不是薪酬模块总管理员 - if (getTaxAgentV2Service(user).isOpenDevolution() && !getTaxAgentV2Service(user).isChief(employeeId)) { - List taxAgentIdsAsAdmin = getTaxAgentV2Service(user).listAllTaxAgentsAsAdmin(employeeId).stream().map(TaxAgentPO::getId).collect(Collectors.toList()); + if (getTaxAgentService(user).isOpenDevolution() && !getTaxAgentService(user).isChief(employeeId)) { + List taxAgentIdsAsAdmin = getTaxAgentService(user).listAllTaxAgentsAsAdmin(employeeId).stream().map(TaxAgentPO::getId).collect(Collectors.toList()); list = list.stream().filter(f -> taxAgentIdsAsAdmin.contains(f.getTaxAgentId()) ).collect(Collectors.toList()); @@ -318,8 +318,8 @@ public class AddUpSituationServiceImpl extends Service implements AddUpSituation List list = biz.recordList(param); // 开启了分权 - if (getTaxAgentV2Service(user).isOpenDevolution() || !getTaxAgentV2Service(user).isChief(employeeId)) { - List taxAgentIdsAsAdmin = getTaxAgentV2Service(user).listAllTaxAgentsAsAdmin(employeeId).stream().map(TaxAgentPO::getId).collect(Collectors.toList()); + if (getTaxAgentService(user).isOpenDevolution() || !getTaxAgentService(user).isChief(employeeId)) { + List taxAgentIdsAsAdmin = getTaxAgentService(user).listAllTaxAgentsAsAdmin(employeeId).stream().map(TaxAgentPO::getId).collect(Collectors.toList()); list = list.stream().filter(f -> // 作为管理员 taxAgentIdsAsAdmin.contains(f.getTaxAgentId()) @@ -546,7 +546,7 @@ public class AddUpSituationServiceImpl extends Service implements AddUpSituation Long currentEmployeeId = (long) user.getUID(); // 获取所有个税扣缴义务人 - Collection taxAgentList = getTaxAgentV2Service(user).listTaxAgentAndEmployeeTree(currentEmployeeId); + Collection taxAgentList = getTaxAgentService(user).listTaxAgentAndEmployeeTree(currentEmployeeId); // 获取租户下所有的人员 List employees = employBiz.listEmployee(); // 已经核算过的不可操作 diff --git a/src/com/engine/salary/service/impl/AttendQuoteServiceImpl.java b/src/com/engine/salary/service/impl/AttendQuoteServiceImpl.java index 345101dc5..bda66290d 100644 --- a/src/com/engine/salary/service/impl/AttendQuoteServiceImpl.java +++ b/src/com/engine/salary/service/impl/AttendQuoteServiceImpl.java @@ -11,24 +11,26 @@ import com.engine.salary.entity.datacollection.param.AttendQuoteDataQueryParam; import com.engine.salary.entity.datacollection.param.AttendQuoteQueryParam; import com.engine.salary.entity.datacollection.po.AttendQuoteDataPO; import com.engine.salary.entity.salaryacct.po.SalaryAcctRecordPO; +import com.engine.salary.entity.salarysob.po.SalarySobPO; import com.engine.salary.enums.salaryaccounting.SalaryAcctRecordStatusEnum; import com.engine.salary.exception.SalaryRunTimeException; import com.engine.salary.mapper.datacollection.AttendQuoteMapper; import com.engine.salary.service.AttendQuoteService; import com.engine.salary.service.SalaryAcctRecordService; +import com.engine.salary.service.SalarySobService; +import com.engine.salary.service.TaxAgentService; import com.engine.salary.util.SalaryDateUtil; +import com.engine.salary.util.SalaryEntityUtil; import com.engine.salary.util.db.MapperProxyFactory; import com.engine.salary.util.page.PageInfo; import com.engine.salary.util.page.SalaryPageUtil; import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.math.NumberUtils; import weaver.hrm.User; import java.time.LocalDate; import java.time.YearMonth; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.concurrent.atomic.AtomicReference; import java.util.stream.Collectors; @@ -43,7 +45,15 @@ public class AttendQuoteServiceImpl extends Service implements AttendQuoteServic } private SalaryAcctRecordService getSalaryAcctRecordService(User user) { - return (SalaryAcctRecordService) ServiceUtil.getService(SalaryAcctRecordServiceImpl.class, user); + return ServiceUtil.getService(SalaryAcctRecordServiceImpl.class, user); + } + + private SalarySobService getSalarySobService(User user) { + return ServiceUtil.getService(SalarySobServiceImpl.class, user); + } + + private TaxAgentService getTaxAgentService(User user) { + return ServiceUtil.getService(TaxAgentServiceImpl.class, user); } @Override @@ -53,8 +63,20 @@ public class AttendQuoteServiceImpl extends Service implements AttendQuoteServic @Override public PageInfo listPage(AttendQuoteQueryParam queryParam) { + long currentEmployeeId = user.getUID(); + + + Boolean needAuth = getTaxAgentService(user).isNeedAuth(currentEmployeeId); + if (needAuth) { + List salarySobPOS = getSalarySobService(user).listByDisable(NumberUtils.INTEGER_ZERO); + Set salarySobIds = SalaryEntityUtil.properties(salarySobPOS, SalarySobPO::getId); + queryParam.setSalarySobIds(salarySobIds); + } + SalaryPageUtil.start(queryParam.getCurrent(), queryParam.getPageSize()); List list = getAttendQuoteMapper().list(queryParam); + + return new PageInfo<>(list, AttendQuoteListDTO.class); } diff --git a/src/com/engine/salary/service/impl/SalaryAcctRecordServiceImpl.java b/src/com/engine/salary/service/impl/SalaryAcctRecordServiceImpl.java index 149e04d23..460131073 100644 --- a/src/com/engine/salary/service/impl/SalaryAcctRecordServiceImpl.java +++ b/src/com/engine/salary/service/impl/SalaryAcctRecordServiceImpl.java @@ -412,7 +412,7 @@ public class SalaryAcctRecordServiceImpl extends Service implements SalaryAcctRe // 薪资所属月所在年的日期范围(第一天~最后一天) LocalDateRange yearRange = SalaryDateUtil.localDate2YearRange(salaryAcctRecordPO.getSalaryMonth()); if (Objects.isNull(yearRange)) { - throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(84026, "参数错误")); + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(84026, "薪资所属月为空")); } // 查询薪资所属月所在年的所有薪资核算记录 List salaryAcctRecordPOS = listBySalaryMonth(yearRange); diff --git a/src/com/engine/salary/service/impl/SalarySobServiceImpl.java b/src/com/engine/salary/service/impl/SalarySobServiceImpl.java index a3f088d79..5e74503b2 100644 --- a/src/com/engine/salary/service/impl/SalarySobServiceImpl.java +++ b/src/com/engine/salary/service/impl/SalarySobServiceImpl.java @@ -128,6 +128,17 @@ public class SalarySobServiceImpl extends Service implements SalarySobService { return filterByAuthority(salarySobPOS); } + @Override + public List listByAdmin() { + List salarySobPOS = salarySobMapper.listSome(SalarySobPO.builder().disable(NumberUtils.INTEGER_ZERO).build()); + return filterByAdmin(salarySobPOS); + } + + @Override + public List listByTaxAgentId(Long taxAgentId) { + return salarySobMapper.listSome(SalarySobPO.builder().disable(NumberUtils.INTEGER_ZERO).taxAgentId(taxAgentId).build()); + } + @Override public List listByIncomeCategory(IncomeCategoryEnum incomeCategory) { return salarySobMapper.listSome(SalarySobPO.builder().incomeCategory(incomeCategory.getValue()).build()); @@ -521,4 +532,32 @@ public class SalarySobServiceImpl extends Service implements SalarySobService { }).collect(Collectors.toList()); } + + public List filterByAdmin(List salarySobPOS) { + long employeeId = user.getUID(); + // 判断是否是“总管理员” + Boolean isChief = getTaxAgentService(user).isChief(employeeId); + // 是否开启分权 + Boolean openDevolution = getTaxAgentService(user).isOpenDevolution(); + // 开启分权后 + // 总管理员都能看见 + // 管理员自己管理的个税下的 + if (!openDevolution) { + return salarySobPOS; + } + // 查询所有的个税扣缴义务人 + Collection taxAgentPOS = getTaxAgentService(user).listAll(); + Set allTaxAgentIds = SalaryEntityUtil.properties(taxAgentPOS, TaxAgentPO::getId); + // 查询个税扣缴义务人的管理员 + List taxAgentAdminPOS = getTaxAgentAdminService(user).listByTaxAgentIds(allTaxAgentIds); + Map> adminMap = SalaryEntityUtil.group2Map(taxAgentAdminPOS, TaxAgentAdminPO::getEmployeeId, TaxAgentAdminPO::getTaxAgentId); + return salarySobPOS.stream().filter(salarySobPO -> { + Set taxAgentIds = adminMap.get(employeeId); + if (CollectionUtils.isEmpty(taxAgentIds)) { + return false; + } + return taxAgentIds.contains(salarySobPO.getTaxAgentId()); + }).collect(Collectors.toList()); + } + } diff --git a/src/com/engine/salary/service/impl/TaxAgentAdminServiceImpl.java b/src/com/engine/salary/service/impl/TaxAgentAdminServiceImpl.java index 503421770..5d6cf042c 100644 --- a/src/com/engine/salary/service/impl/TaxAgentAdminServiceImpl.java +++ b/src/com/engine/salary/service/impl/TaxAgentAdminServiceImpl.java @@ -49,6 +49,7 @@ public class TaxAgentAdminServiceImpl extends Service implements TaxAgentAdminSe .employeeId(e) .createTime(now) .updateTime(now) + .deleteType(0) .creator((long) user.getUID()) .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) .build()) diff --git a/src/com/engine/salary/service/impl/TaxAgentBaseServiceImpl.java b/src/com/engine/salary/service/impl/TaxAgentBaseServiceImpl.java index cd7475f06..25cae8472 100644 --- a/src/com/engine/salary/service/impl/TaxAgentBaseServiceImpl.java +++ b/src/com/engine/salary/service/impl/TaxAgentBaseServiceImpl.java @@ -15,6 +15,7 @@ import com.engine.salary.service.SalaryAcctRecordService; import com.engine.salary.service.TaxAgentBaseService; import com.engine.salary.util.SalaryI18nUtil; import com.engine.salary.util.db.MapperProxyFactory; +import dm.jdbc.util.IdGenerator; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang.StringUtils; import weaver.hrm.User; @@ -79,7 +80,7 @@ public class TaxAgentBaseServiceImpl extends Service implements TaxAgentBaseServ if (base == null) { getTaxAgentBaseMapper().insertIgnoreNull( TaxAgentBasePO.builder() -// .id(IdGenerator.generate()) + .id(IdGenerator.generate()) .devolutionStatus(devolutionStatus) .createTime(now) .updateTime(now) diff --git a/src/com/engine/salary/service/impl/TaxAgentServiceImpl.java b/src/com/engine/salary/service/impl/TaxAgentServiceImpl.java index c83c84a95..fb9ed8e9a 100644 --- a/src/com/engine/salary/service/impl/TaxAgentServiceImpl.java +++ b/src/com/engine/salary/service/impl/TaxAgentServiceImpl.java @@ -37,7 +37,6 @@ import com.engine.salary.util.page.SalaryPageUtil; import com.engine.salary.util.valid.RuntimeTypeEnum; import com.engine.salary.util.valid.ValidUtil; import com.google.common.collect.Lists; -import dm.jdbc.util.IdGenerator; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.BeanUtils; @@ -286,11 +285,11 @@ public class TaxAgentServiceImpl extends Service implements TaxAgentService { // throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(115130, "名称不允许与社保福利代缴机构名称重复")); // } // 保存 - saveParam.setId(IdGenerator.generate()); +// saveParam.setId(IdGenerator.generate()); TaxAgentPO taxAgent = TaxAgentBO.convertToPO(saveParam, (long) user.getUID()); - getTaxAgentMapper().insert(taxAgent); + getTaxAgentMapper().insertIgnoreNull(taxAgent); if (isOpenDevolution) { - getTaxAgentAdminService(user).batchInsert(saveParam.getId(), saveParam.getAdminUserIds()); + getTaxAgentAdminService(user).batchInsert(taxAgent.getId(), saveParam.getAdminUserIds()); } // 记录日志 // SalaryLoggerUtil.recordAddSingleLog(taxAgentLoggerTemplate, diff --git a/src/com/engine/salary/web/TaxDeclarationController.java b/src/com/engine/salary/web/TaxDeclarationController.java index 714f0b45c..9c0ae1f5b 100644 --- a/src/com/engine/salary/web/TaxDeclarationController.java +++ b/src/com/engine/salary/web/TaxDeclarationController.java @@ -93,7 +93,6 @@ public class TaxDeclarationController { public String save(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody TaxDeclarationSaveParam param) { User user = HrmUserVarify.getUser(request, response); param.setSalaryMonth(SalaryDateUtil.String2YearMonth(param.getSalaryMonthStr())); - param.setUser(user); return new ResponseResult(user).run(getTaxDeclarationWrapper(user)::save, param); } diff --git a/src/com/engine/salary/wrapper/SalarySobWrapper.java b/src/com/engine/salary/wrapper/SalarySobWrapper.java index 6bfe3901d..4c2327de2 100644 --- a/src/com/engine/salary/wrapper/SalarySobWrapper.java +++ b/src/com/engine/salary/wrapper/SalarySobWrapper.java @@ -54,7 +54,11 @@ public class SalarySobWrapper extends Service { // 查询薪资账套 PageInfo page = getSalarySobService(user).listPageByParam(queryParam); // 薪资账套po转换成薪资账套列表dto - List salarySobListDTOS = SalarySobBO.convert2ListDTO(page.getList()); + + List taxAgentPOS = getTaxAgentService(user).listAll(); + Map taxAgentIdTONameMap = SalaryEntityUtil.convert2Map(taxAgentPOS, TaxAgentPO::getId, TaxAgentPO::getName); + + List salarySobListDTOS = SalarySobBO.convert2ListDTO(page.getList(),taxAgentIdTONameMap); PageInfo dtoPage = new PageInfo<>(salarySobListDTOS, SalarySobListDTO.class); dtoPage.setTotal(page.getTotal()); dtoPage.setPageNum(page.getPageNum()); diff --git a/src/com/engine/salary/wrapper/TaxDeclarationWrapper.java b/src/com/engine/salary/wrapper/TaxDeclarationWrapper.java index 7a43a05c9..da1565b51 100644 --- a/src/com/engine/salary/wrapper/TaxDeclarationWrapper.java +++ b/src/com/engine/salary/wrapper/TaxDeclarationWrapper.java @@ -54,19 +54,19 @@ import java.util.stream.Collectors; public class TaxDeclarationWrapper extends Service { private TaxDeclarationService getTaxDeclarationService(User user) { - return ServiceUtil.getService(TaxDeclarationServiceImpl.class, user); + return ServiceUtil.getService(TaxDeclarationServiceImpl.class, user); } private TaxAgentService getTaxAgentService(User user) { - return ServiceUtil.getService(TaxAgentServiceImpl.class, user); + return ServiceUtil.getService(TaxAgentServiceImpl.class, user); } private TaxDeclarationDetailService getTaxDeclarationDetailService(User user) { - return ServiceUtil.getService(TaxDeclarationDetailServiceImpl.class, user); + return ServiceUtil.getService(TaxDeclarationDetailServiceImpl.class, user); } private SalaryAcctRecordService getSalaryAcctRecordService(User user) { - return ServiceUtil.getService(SalaryAcctRecordServiceImpl.class, user); + return ServiceUtil.getService(SalaryAcctRecordServiceImpl.class, user); } private TaxDeclarationMapper getTaxDeclarationMapper() { @@ -82,11 +82,11 @@ public class TaxDeclarationWrapper extends Service { } private AddUpSituationService getAddUpSituationService(User user) { - return (AddUpSituationService) ServiceUtil.getService(AddUpSituationServiceImpl.class, user); + return ServiceUtil.getService(AddUpSituationServiceImpl.class, user); } private SalarySobService getSalarySobService(User user) { - return (SalarySobService) ServiceUtil.getService(SalarySobServiceImpl.class, user); + return ServiceUtil.getService(SalarySobServiceImpl.class, user); } private SalaryAcctResultService getSalaryAcctResultService(User user) { @@ -138,18 +138,13 @@ public class TaxDeclarationWrapper extends Service { SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM"); String transformDate = simpleDateFormat.format(taxDeclaration.getSalaryMonth()); // 转换成个税申报表详情dto - formDTO = TaxDeclarationFormDTO.builder() - .salaryMonth(SalaryDateUtil.String2YearMonth(transformDate)) - .taxAgentId(taxDeclaration.getTaxAgentId()) - .taxAgentName(Optional.ofNullable(taxAgent).map(TaxAgentPO::getName).orElse("")) - .description(taxDeclaration.getDescription()) - .build(); + formDTO = TaxDeclarationFormDTO.builder().salaryMonth(SalaryDateUtil.String2YearMonth(transformDate)).taxAgentId(taxDeclaration.getTaxAgentId()).taxAgentName(Optional.ofNullable(taxAgent).map(TaxAgentPO::getName).orElse("")).description(taxDeclaration.getDescription()).build(); } // 转换成前端所需的数据格式 // WeaForm weaForm = SalaryFormatUtil.getInstance().buildForm(TaxDeclarationFormDTO.class, formDTO); // 查询租户所有的个税扣缴义务人 - Collection taxAgentListDTOS =getTaxAgentService(user).listAll(); + Collection taxAgentListDTOS = getTaxAgentService(user).listAll(); // 表单中个税扣缴义务人的可选项 List weaFormOptions = Lists.newArrayListWithExpectedSize(taxAgentListDTOS.size()); for (TaxAgentPO taxAgent : taxAgentListDTOS) { @@ -185,12 +180,9 @@ public class TaxDeclarationWrapper extends Service { String transformDate = simpleDateFormat.format(taxDeclaration.getSalaryMonth()); // 查询个税扣缴义务人 TaxAgentPO taxAgentPO = getTaxAgentService(user).getById(taxDeclaration.getTaxAgentId()); - return TaxDeclarationInfoDTO.builder() - .salaryMonth(SalaryDateUtil.String2YearMonth(transformDate)) - .taxAgentId(taxDeclaration.getTaxAgentId()) - .taxAgentName(Optional.ofNullable(taxAgentPO).map(TaxAgentPO::getName).orElse("")) - .build(); + return TaxDeclarationInfoDTO.builder().salaryMonth(SalaryDateUtil.String2YearMonth(transformDate)).taxAgentId(taxDeclaration.getTaxAgentId()).taxAgentName(Optional.ofNullable(taxAgentPO).map(TaxAgentPO::getName).orElse("")).build(); } + /** * 保存 * @@ -198,55 +190,78 @@ public class TaxDeclarationWrapper extends Service { */ @Transactional(rollbackFor = Exception.class) public void save(TaxDeclarationSaveParam saveParam) { - User user = saveParam.getUser(); + long currentEmployeeId = user.getUID(); + // 薪资所属月的日期范围 LocalDateRange salaryMonthDateRange = SalaryDateUtil.localDate2Range(SalaryDateUtil.localDateToDate(saveParam.getSalaryMonth().atDay(1))); if (Objects.isNull(salaryMonthDateRange)) { - throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(84026, "参数错误")); + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(84026, "薪资所属月参数错误")); } - // 查询薪资所属月已经生成过的个税申报表 - List taxDeclarationPOS = listBySalaryMonthTax(salaryMonthDateRange); + + Long taxAgentId = saveParam.getTaxAgentId(); + + if (Objects.isNull(taxAgentId)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(84026, "请选择个税扣缴义务人")); + } + + //查询个税扣缴义务人 + TaxAgentPO taxAgentPO = getTaxAgentService(user).getById(taxAgentId); + if (Objects.isNull(taxAgentPO)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(84026, "所选个税扣缴义务人不存在")); + } + + //开启分权 + Boolean isNeedAuth = getTaxAgentService(user).isNeedAuth(currentEmployeeId); + if (isNeedAuth) { + Collection taxAgentPOS = getTaxAgentService(user).listAllTaxAgentsAsAdmin(currentEmployeeId); + Set taxAgentIds = SalaryEntityUtil.properties(taxAgentPOS, TaxAgentPO::getId); + if(!taxAgentIds.contains(taxAgentId)){ + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(84026, "无权限操作所选个税扣缴义务人")); + } + } + + //获取个税扣缴义务人下的账套 + List salarySobs = getSalarySobService(user).listByTaxAgentId(taxAgentId); + Set salarySobIds = SalaryEntityUtil.properties(salarySobs, SalarySobPO::getId); + + // 查询薪资所属月个税扣缴义务人已经生成过的个税申报表 + List taxDeclarationPOS = listBySalaryMonthTax(TaxDeclarationPO.builder().salaryMonths(salaryMonthDateRange).taxAgentId(taxAgentId).build()); // 已经生成过个税申报表,不允许再次生成个税申报表 if (CollectionUtils.isNotEmpty(taxDeclarationPOS)) { - throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98873, "{0}已经生成过个税申报表,不允许再次生成") - .replace("{0}", saveParam.getSalaryMonth().toString())); + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98873, "{0}已经生成过个税申报表,不允许再次生成").replace("{0}", saveParam.getSalaryMonth().toString())); } // 查询薪资所属月的薪资核算记录 - List salaryAcctRecordPOS = listBySalaryMonth(salaryMonthDateRange); + List salaryAcctRecordPOS = listBySalaryMonth(SalaryAcctRecordPO.builder().salaryMonths(salaryMonthDateRange).salarySobIds(salarySobIds).build()); // 无薪资核算记录,不允许生成个税申报表 if (CollectionUtils.isEmpty(salaryAcctRecordPOS)) { - throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98874, "{0}无申报数据") - .replace("{0}", saveParam.getSalaryMonth().toString())); + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98874, "{0}无申报数据").replace("{0}", saveParam.getSalaryMonth().toString())); } // 如果存在未归档的,也不允许生成个税申报表 boolean notArchived = salaryAcctRecordPOS.stream().anyMatch(salaryAcctRecordPO -> !Objects.equals(salaryAcctRecordPO.getStatus(), SalaryAcctRecordStatusEnum.ARCHIVED.getValue())); if (notArchived) { - throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98875, "{0}有未归档数据,请全部归档后再申报") - .replace("{0}", saveParam.getSalaryMonth().toString())); + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98875, "{0}有未归档数据,请全部归档后再申报").replace("{0}", saveParam.getSalaryMonth().toString())); } // 如果当前薪资所属月下存在不同的税款所属期,属于异常业务场景,不允许生成个税申报表 Date taxCycle = salaryAcctRecordPOS.get(0).getTaxCycle(); boolean differentTaxCycle = salaryAcctRecordPOS.stream().anyMatch(salaryAcctRecordPO -> salaryAcctRecordPO.getTaxCycle().compareTo(taxCycle) != 0); if (differentTaxCycle) { - throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98876, "{0}存在不同的税款所属期,无法正常生成个税申报表,请调整账套设置,重新核算后再生成个税申报表") - .replace("{0}", saveParam.getSalaryMonth().toString())); + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98876, "{0}存在不同的税款所属期,无法正常生成个税申报表,请调整账套设置,重新核算后再生成个税申报表").replace("{0}", saveParam.getSalaryMonth().toString())); } // 查询薪资核算结果 Set salaryAcctRecordIds = SalaryEntityUtil.properties(salaryAcctRecordPOS, SalaryAcctRecordPO::getId); List salaryAcctResultPOS = getSalaryAcctResultService(user).listBySalaryAcctRecordIds(salaryAcctRecordIds); // 无薪资核算结果,不允许生成个税申报表 if (CollectionUtils.isEmpty(salaryAcctResultPOS)) { - throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98874, "{0}无申报数据") - .replace("{0}", saveParam.getSalaryMonth().toString())); + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98874, "{0}无申报数据").replace("{0}", saveParam.getSalaryMonth().toString())); } // 查询薪资账套 - Set salarySobIds = SalaryEntityUtil.properties(salaryAcctRecordPOS, SalaryAcctRecordPO::getSalarySobId); - List salarySobPOS = getSalarySobService(user).listByIds(salarySobIds); +// Set salarySobIds = SalaryEntityUtil.properties(salaryAcctRecordPOS, SalaryAcctRecordPO::getSalarySobId); +// List salarySobPOS = getSalarySobService(user).listByIds(salarySobIds); // 查询所有薪资项目 List salaryItemPOS = new SalaryItemBiz().listAll(); // 处理要保存的数据 - TaxDeclarationBO.Result result = TaxDeclarationBO.handle(saveParam, taxCycle, user, salaryItemPOS, salarySobPOS, salaryAcctResultPOS); + TaxDeclarationBO.Result result = TaxDeclarationBO.handle(saveParam, taxCycle, user, salaryItemPOS, salarySobs, salaryAcctResultPOS); // 保存个税申报表 if (CollectionUtils.isNotEmpty(result.getNeedInsertTaxDeclarations())) { getTaxDeclarationMapper().batchInsert(result.getNeedInsertTaxDeclarations()); @@ -258,12 +273,71 @@ public class TaxDeclarationWrapper extends Service { // 保存累计情况 if (CollectionUtils.isNotEmpty(result.getNeedInsertAccumulatedSituations())) { Set taxAgentIds = SalaryEntityUtil.properties(result.getNeedInsertTaxDeclarations(), TaxDeclarationPO::getTaxAgentId); - getAddUpSituationService(user).deleteByTaxYearMonthAndTaxAgentIds(SalaryDateUtil.localDate2YearMonth(taxCycle),taxAgentIds); + getAddUpSituationService(user).deleteByTaxYearMonthAndTaxAgentIds(SalaryDateUtil.localDate2YearMonth(taxCycle), taxAgentIds); List> partition = Lists.partition((List) result.getNeedInsertAccumulatedSituations(), 100); partition.forEach(getAddUpSituationMapper()::insertData); } // 更新薪资核算记录的状态 getSalaryAcctRecordService(user).updateStatusByIds(salaryAcctRecordIds, SalaryAcctRecordStatusEnum.DECLARED); +// +// } else { +// +// // 查询薪资所属月已经生成过的个税申报表 +// List taxDeclarationPOS = listBySalaryMonthTax(TaxDeclarationPO.builder().salaryMonths(salaryMonthDateRange).build()); +// // 已经生成过个税申报表,不允许再次生成个税申报表 +// if (CollectionUtils.isNotEmpty(taxDeclarationPOS)) { +// throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98873, "{0}已经生成过个税申报表,不允许再次生成").replace("{0}", saveParam.getSalaryMonth().toString())); +// } +// // 查询薪资所属月的薪资核算记录 +// List salaryAcctRecordPOS = listBySalaryMonth(SalaryAcctRecordPO.builder().salaryMonths(salaryMonthDateRange).build()); +// // 无薪资核算记录,不允许生成个税申报表 +// if (CollectionUtils.isEmpty(salaryAcctRecordPOS)) { +// throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98874, "{0}无申报数据").replace("{0}", saveParam.getSalaryMonth().toString())); +// } +// // 如果存在未归档的,也不允许生成个税申报表 +// boolean notArchived = salaryAcctRecordPOS.stream().anyMatch(salaryAcctRecordPO -> !Objects.equals(salaryAcctRecordPO.getStatus(), SalaryAcctRecordStatusEnum.ARCHIVED.getValue())); +// if (notArchived) { +// throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98875, "{0}有未归档数据,请全部归档后再申报").replace("{0}", saveParam.getSalaryMonth().toString())); +// } +// // 如果当前薪资所属月下存在不同的税款所属期,属于异常业务场景,不允许生成个税申报表 +// Date taxCycle = salaryAcctRecordPOS.get(0).getTaxCycle(); +// boolean differentTaxCycle = salaryAcctRecordPOS.stream().anyMatch(salaryAcctRecordPO -> salaryAcctRecordPO.getTaxCycle().compareTo(taxCycle) != 0); +// if (differentTaxCycle) { +// throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98876, "{0}存在不同的税款所属期,无法正常生成个税申报表,请调整账套设置,重新核算后再生成个税申报表").replace("{0}", saveParam.getSalaryMonth().toString())); +// } +// // 查询薪资核算结果 +// Set salaryAcctRecordIds = SalaryEntityUtil.properties(salaryAcctRecordPOS, SalaryAcctRecordPO::getId); +// List salaryAcctResultPOS = getSalaryAcctResultService(user).listBySalaryAcctRecordIds(salaryAcctRecordIds); +// // 无薪资核算结果,不允许生成个税申报表 +// if (CollectionUtils.isEmpty(salaryAcctResultPOS)) { +// throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98874, "{0}无申报数据").replace("{0}", saveParam.getSalaryMonth().toString())); +// } +// // 查询薪资账套 +// Set salarySobIds = SalaryEntityUtil.properties(salaryAcctRecordPOS, SalaryAcctRecordPO::getSalarySobId); +// List salarySobPOS = getSalarySobService(user).listByIds(salarySobIds); +// +// // 查询所有薪资项目 +// List salaryItemPOS = new SalaryItemBiz().listAll(); +// // 处理要保存的数据 +// TaxDeclarationBO.Result result = TaxDeclarationBO.handle(saveParam, taxCycle, user, salaryItemPOS, salarySobPOS, salaryAcctResultPOS); +// // 保存个税申报表 +// if (CollectionUtils.isNotEmpty(result.getNeedInsertTaxDeclarations())) { +// getTaxDeclarationMapper().batchInsert(result.getNeedInsertTaxDeclarations()); +// } +// // 保存个税申报表明细 +// if (CollectionUtils.isNotEmpty(result.getNeedInsertTaxDeclarationDetails())) { +// getTaxDeclarationDetailService(user).batchSave(result.getNeedInsertTaxDeclarationDetails()); +// } +// // 保存累计情况 +// if (CollectionUtils.isNotEmpty(result.getNeedInsertAccumulatedSituations())) { +// Set taxAgentIds = SalaryEntityUtil.properties(result.getNeedInsertTaxDeclarations(), TaxDeclarationPO::getTaxAgentId); +// getAddUpSituationService(user).deleteByTaxYearMonthAndTaxAgentIds(SalaryDateUtil.localDate2YearMonth(taxCycle), taxAgentIds); +// List> partition = Lists.partition((List) result.getNeedInsertAccumulatedSituations(), 100); +// partition.forEach(getAddUpSituationMapper()::insertData); +// } +// // 更新薪资核算记录的状态 +// getSalaryAcctRecordService(user).updateStatusByIds(salaryAcctRecordIds, SalaryAcctRecordStatusEnum.DECLARED); +// } // 查询个税扣缴义务人 // Set taxAgentIds = SalaryEntityUtil.properties(result.getNeedInsertTaxDeclarations(), TaxDeclarationPO::getTaxAgentId); // List taxAgentPOS = new TaxAgentBiz().listByIds(taxAgentIds); @@ -282,12 +356,12 @@ public class TaxDeclarationWrapper extends Service { }*/ } - public List listBySalaryMonthTax(LocalDateRange salaryMonthDateRange) { - return getTaxDeclarationMapper().listSome(TaxDeclarationPO.builder().salaryMonths(salaryMonthDateRange).build()); + public List listBySalaryMonthTax(TaxDeclarationPO build) { + return getTaxDeclarationMapper().listSome(build); } - public List listBySalaryMonth(LocalDateRange salaryMonthDateRange) { - return getSalaryAcctRecordMapper().listSome(SalaryAcctRecordPO.builder().salaryMonths(salaryMonthDateRange).build()); + public List listBySalaryMonth(SalaryAcctRecordPO po) { + return getSalaryAcctRecordMapper().listSome(po); } }