From 383562c9cf0a5a02dd5d927f71b8fbaf5ef79e77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=92=B1=E6=B6=9B?= <15850646081@163.com> Date: Thu, 12 Sep 2024 11:50:18 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B7=A5=E8=B5=84=E5=8D=95=E3=80=81=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E9=87=87=E9=9B=86=E6=9D=83=E9=99=90=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../salaryBill/dto/SalaryTemplateListDTO.java | 12 ++-- .../salarysob/param/SalarySobQueryParam.java | 4 ++ .../salary/entity/taxagent/po/TaxAgentPO.java | 6 ++ .../engine/salary/mapper/auth/AuthMapper.xml | 26 ++++---- .../salarybill/SalaryTemplateMapper.xml | 3 + .../service/auth/AuthRoleServiceImpl.java | 17 +++--- .../salary/service/auth/AuthServiceImpl.java | 2 - .../impl/AddUpDeductionServiceImpl.java | 8 --- .../impl/AddUpSituationServiceImpl.java | 8 --- .../impl/OtherDeductionServiceImpl.java | 8 --- .../service/impl/SalarySobServiceImpl.java | 5 ++ .../impl/SalaryTemplateServiceImpl.java | 33 +++------- .../service/impl/TaxAgentServiceImpl.java | 8 ++- .../salary/wrapper/SalaryTemplateWrapper.java | 61 +------------------ 14 files changed, 68 insertions(+), 133 deletions(-) diff --git a/src/com/engine/salary/entity/salaryBill/dto/SalaryTemplateListDTO.java b/src/com/engine/salary/entity/salaryBill/dto/SalaryTemplateListDTO.java index 3538a3387..5fdaaef98 100644 --- a/src/com/engine/salary/entity/salaryBill/dto/SalaryTemplateListDTO.java +++ b/src/com/engine/salary/entity/salaryBill/dto/SalaryTemplateListDTO.java @@ -1,15 +1,15 @@ package com.engine.salary.entity.salaryBill.dto; -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.hrmelog.annotation.ElogTransform; +import com.engine.salary.annotation.*; +import com.engine.salary.enums.auth.AuthCheckTypeEnum; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; +import java.util.Set; + /** * @Description: 工资单模板 */ @@ -24,6 +24,7 @@ import lombok.NoArgsConstructor; @SalaryTableOperate(index = "3", text = "操作日志" ) }) @ElogTransform(name = "工资单模板") +@Auth(page = "salaryBill", checkType = AuthCheckTypeEnum.SOB) public class SalaryTemplateListDTO { //主键id @@ -65,4 +66,7 @@ public class SalaryTemplateListDTO { // 薪资账套id private Long salarySobId; + + + private Set opts; } diff --git a/src/com/engine/salary/entity/salarysob/param/SalarySobQueryParam.java b/src/com/engine/salary/entity/salarysob/param/SalarySobQueryParam.java index 52c32eb89..d0555321d 100644 --- a/src/com/engine/salary/entity/salarysob/param/SalarySobQueryParam.java +++ b/src/com/engine/salary/entity/salarysob/param/SalarySobQueryParam.java @@ -5,6 +5,8 @@ import com.engine.salary.enums.auth.AuthFilterTypeEnum; import lombok.Data; import lombok.EqualsAndHashCode; +import java.util.List; + @Data @EqualsAndHashCode(callSuper = true) @@ -20,6 +22,8 @@ public class SalarySobQueryParam extends BaseQueryParam { */ private Long taxAgentId; + private List taxAgentIds; + /** * 数据过滤级别 */ diff --git a/src/com/engine/salary/entity/taxagent/po/TaxAgentPO.java b/src/com/engine/salary/entity/taxagent/po/TaxAgentPO.java index a8b6a2422..f84602b40 100644 --- a/src/com/engine/salary/entity/taxagent/po/TaxAgentPO.java +++ b/src/com/engine/salary/entity/taxagent/po/TaxAgentPO.java @@ -1,6 +1,8 @@ package com.engine.salary.entity.taxagent.po; import com.engine.hrmelog.annotation.ElogTransform; +import com.engine.salary.annotation.Auth; +import com.engine.salary.enums.auth.AuthCheckTypeEnum; import com.thoughtworks.xstream.annotations.XStreamAlias; import com.thoughtworks.xstream.annotations.XStreamAsAttribute; import com.thoughtworks.xstream.annotations.XStreamOmitField; @@ -11,6 +13,7 @@ import lombok.NoArgsConstructor; import java.util.Collection; import java.util.Date; +import java.util.Set; /** * 个税扣缴义务人 hrsa_tax_agent @@ -26,6 +29,7 @@ import java.util.Date; @AllArgsConstructor @ElogTransform(name = "个税扣缴义务人") @XStreamAlias("TaxAgent") +@Auth(page = "", checkType = AuthCheckTypeEnum.TAX,taxAgentIdField = "id") public class TaxAgentPO { /** @@ -107,4 +111,6 @@ public class TaxAgentPO { private Collection ids; + + Set opts; } diff --git a/src/com/engine/salary/mapper/auth/AuthMapper.xml b/src/com/engine/salary/mapper/auth/AuthMapper.xml index f6c482e16..df9ddc0b1 100644 --- a/src/com/engine/salary/mapper/auth/AuthMapper.xml +++ b/src/com/engine/salary/mapper/auth/AuthMapper.xml @@ -37,13 +37,14 @@ @@ -58,13 +59,14 @@ diff --git a/src/com/engine/salary/mapper/salarybill/SalaryTemplateMapper.xml b/src/com/engine/salary/mapper/salarybill/SalaryTemplateMapper.xml index 0d866f7af..b6e9d4003 100644 --- a/src/com/engine/salary/mapper/salarybill/SalaryTemplateMapper.xml +++ b/src/com/engine/salary/mapper/salarybill/SalaryTemplateMapper.xml @@ -369,6 +369,7 @@ t.name, t.replenish_name as replenishName, s.name as salarysob, + s.id as salarySobId, t.use_type as useType, t.description, t.salary_sob_id @@ -402,6 +403,7 @@ t.name, t.replenish_name as replenishName, s.name as salarysob, + s.id as salarySobId, t.use_type as useType, t.description, t.salary_sob_id @@ -435,6 +437,7 @@ t.name, t.replenish_name as replenishName, s.name as salarysob, + s.id as salarySobId, t.use_type as useType, t.description, t.salary_sob_id diff --git a/src/com/engine/salary/service/auth/AuthRoleServiceImpl.java b/src/com/engine/salary/service/auth/AuthRoleServiceImpl.java index 916ba8106..085512c70 100644 --- a/src/com/engine/salary/service/auth/AuthRoleServiceImpl.java +++ b/src/com/engine/salary/service/auth/AuthRoleServiceImpl.java @@ -83,18 +83,21 @@ public class AuthRoleServiceImpl extends Service implements AuthRoleService { @Override public AuthRoleDTO getRole(Long id) { AuthRolePO po = getAuthRoleMapper().getById(id); + if (po == null){ + throw new SalaryRunTimeException("业务线不存在"); + } Long roleId = po.getId(); List authResources = getAuthResourceMapper().listSome(AuthResourcePO.builder().roleId(roleId).build()); List taxAgentIds = new ArrayList<>(); List sobIds = new ArrayList<>(); - authResources.forEach(resource -> { - if (ResourceTargetTypeEnum.TAX_AGENT.getValue().equals(resource.getTargetType())) { - taxAgentIds.add(TaxAgentPO.builder().id(resource.getTarget()).name(resource.getTargetName()).build()); - } else if (ResourceTargetTypeEnum.SOB.getValue().equals(resource.getTargetType())) { - sobIds.add(SalarySobPO.builder().id(resource.getTarget()).name(resource.getTargetName()).build()); - } - }); +// authResources.forEach(resource -> { +// if (ResourceTargetTypeEnum.TAX_AGENT.getValue().equals(resource.getTargetType())) { +// taxAgentIds.add(TaxAgentPO.builder().id(resource.getTarget()).name(resource.getTargetName()).build()); +// } else if (ResourceTargetTypeEnum.SOB.getValue().equals(resource.getTargetType())) { +// sobIds.add(SalarySobPO.builder().id(resource.getTarget()).name(resource.getTargetName()).build()); +// } +// }); return AuthRoleDTO.builder() .id(roleId) diff --git a/src/com/engine/salary/service/auth/AuthServiceImpl.java b/src/com/engine/salary/service/auth/AuthServiceImpl.java index df2752c2d..b8862f028 100644 --- a/src/com/engine/salary/service/auth/AuthServiceImpl.java +++ b/src/com/engine/salary/service/auth/AuthServiceImpl.java @@ -67,7 +67,6 @@ public class AuthServiceImpl extends Service implements AuthService { //给总管理员赋值最大权限 Boolean isChief = getTaxAgentService(user).isChief((long) user.getUID()); -// Boolean isChief = false; if (isChief) { if (filterType == AuthFilterTypeEnum.DATA_OPT) { list.forEach(t -> { @@ -97,7 +96,6 @@ public class AuthServiceImpl extends Service implements AuthService { //给各管理员赋值对应的扣缴义务人权限 List adminTaxAgentIds = getTaxAgentService(user).getAdminTaxAgentIds((long) user.getUID()); -// List adminTaxAgentIds = new ArrayList<>(); if (CollectionUtil.isNotEmpty(adminTaxAgentIds)) { Iterator iterator = list.iterator(); if (checkType == AuthCheckTypeEnum.TAX || checkType == AuthCheckTypeEnum.TAX_EMP) { diff --git a/src/com/engine/salary/service/impl/AddUpDeductionServiceImpl.java b/src/com/engine/salary/service/impl/AddUpDeductionServiceImpl.java index 36db3ed92..55cc9fb38 100644 --- a/src/com/engine/salary/service/impl/AddUpDeductionServiceImpl.java +++ b/src/com/engine/salary/service/impl/AddUpDeductionServiceImpl.java @@ -709,10 +709,6 @@ public class AddUpDeductionServiceImpl extends Service implements AddUpDeduction @Override public AddUpDeductionRecordDTO getAddUpDeduction(AddUpDeductionQueryParam param) { - long uid = user.getUID(); - // 获取所有个税扣缴义务人 - Collection taxAgentList = getTaxAgentService(user).listTaxAgentAndEmployeeTree(uid); - List taxAgentNames = taxAgentList.stream().map(TaxAgentManageRangeEmployeeDTO::getTaxAgentName).collect(Collectors.toList()); ArrayList ids = new ArrayList<>(); ids.add(param.getId()); AddUpDeductionQueryParam build = AddUpDeductionQueryParam.builder().ids(ids).build(); @@ -720,10 +716,6 @@ public class AddUpDeductionServiceImpl extends Service implements AddUpDeduction if (addUpDeductionRecordDTOS == null || addUpDeductionRecordDTOS.size() == 0) { throw new SalaryRunTimeException("该数据不存在!"); } - String taxAgentName = addUpDeductionRecordDTOS.get(0).getTaxAgentName(); - if (!taxAgentNames.contains(taxAgentName)) { - throw new SalaryRunTimeException("您无权查看该数据!"); - } return addUpDeductionRecordDTOS.get(0); } diff --git a/src/com/engine/salary/service/impl/AddUpSituationServiceImpl.java b/src/com/engine/salary/service/impl/AddUpSituationServiceImpl.java index 5851987cf..3ea83beca 100644 --- a/src/com/engine/salary/service/impl/AddUpSituationServiceImpl.java +++ b/src/com/engine/salary/service/impl/AddUpSituationServiceImpl.java @@ -1181,10 +1181,6 @@ public class AddUpSituationServiceImpl extends Service implements AddUpSituation @Override public AddUpSituationRecordDTO getAddUpSituation(AddUpSituationParam addUpSituationParam) { - long uid = user.getUID(); - // 获取所有个税扣缴义务人 - Collection taxAgentList = getTaxAgentService(user).listTaxAgentAndEmployeeTree(uid); - List taxAgentNames = taxAgentList.stream().map(TaxAgentManageRangeEmployeeDTO::getTaxAgentName).collect(Collectors.toList()); ArrayList ids = new ArrayList<>(); ids.add(addUpSituationParam.getId()); AddUpSituationQueryParam build = AddUpSituationQueryParam.builder().ids(ids).build(); @@ -1192,10 +1188,6 @@ public class AddUpSituationServiceImpl extends Service implements AddUpSituation if (list == null || list.size() == 0) { throw new SalaryRunTimeException("该数据不存在!"); } - String taxAgentName = list.get(0).getTaxAgentName(); - if (!taxAgentNames.contains(taxAgentName)) { - throw new SalaryRunTimeException("您无权查看该数据!"); - } return list.get(0); } diff --git a/src/com/engine/salary/service/impl/OtherDeductionServiceImpl.java b/src/com/engine/salary/service/impl/OtherDeductionServiceImpl.java index 95daa72a2..2089476f9 100644 --- a/src/com/engine/salary/service/impl/OtherDeductionServiceImpl.java +++ b/src/com/engine/salary/service/impl/OtherDeductionServiceImpl.java @@ -890,10 +890,6 @@ public class OtherDeductionServiceImpl extends Service implements OtherDeduction @Override public OtherDeductionRecordDTO getOtherDeduction(OtherDeductionParam otherDeductionParam) { - long uid = user.getUID(); - // 获取所有个税扣缴义务人 - Collection taxAgentList = getTaxAgentService(user).listTaxAgentAndEmployeeTree(uid); - List taxAgentNames = taxAgentList.stream().map(TaxAgentManageRangeEmployeeDTO::getTaxAgentName).collect(Collectors.toList()); ArrayList ids = new ArrayList<>(); ids.add(otherDeductionParam.getId()); OtherDeductionQueryParam build = OtherDeductionQueryParam.builder().ids(ids).build(); @@ -903,10 +899,6 @@ public class OtherDeductionServiceImpl extends Service implements OtherDeduction if (list == null || list.size() == 0) { throw new SalaryRunTimeException("该数据不存在!"); } - String taxAgentName = list.get(0).getTaxAgentName(); - if (!taxAgentNames.contains(taxAgentName)) { - throw new SalaryRunTimeException("您无权查看该数据!"); - } return list.get(0); } diff --git a/src/com/engine/salary/service/impl/SalarySobServiceImpl.java b/src/com/engine/salary/service/impl/SalarySobServiceImpl.java index 5c68903a4..626bcbbc5 100644 --- a/src/com/engine/salary/service/impl/SalarySobServiceImpl.java +++ b/src/com/engine/salary/service/impl/SalarySobServiceImpl.java @@ -227,6 +227,11 @@ public class SalarySobServiceImpl extends Service implements SalarySobService { build.setIds(sobTaxLinkPOS.stream().map(SobTaxLinkPO::getTaxAgentId).collect(Collectors.toList())); } + if(CollectionUtil.isNotEmpty(param.getTaxAgentIds())){ + List sobTaxLinkPOS = getSobTaxLinkMapper().listSome(SobTaxLinkPO.builder().taxAgentIds(param.getTaxAgentIds()).build()); + build.setIds(sobTaxLinkPOS.stream().map(SobTaxLinkPO::getTaxAgentId).collect(Collectors.toList())); + } + List list = getSalarySobMapper().listSome(build); return getAuthService(user).auth(list, param.getFilterType(), SalarySobPO.class); } diff --git a/src/com/engine/salary/service/impl/SalaryTemplateServiceImpl.java b/src/com/engine/salary/service/impl/SalaryTemplateServiceImpl.java index f6f7e8b18..aaa2dfcde 100644 --- a/src/com/engine/salary/service/impl/SalaryTemplateServiceImpl.java +++ b/src/com/engine/salary/service/impl/SalaryTemplateServiceImpl.java @@ -27,11 +27,14 @@ import com.engine.salary.entity.salarysob.po.SalarySobEmpFieldPO; import com.engine.salary.entity.salarysob.po.SalarySobItemPO; import com.engine.salary.entity.salarysob.po.SalarySobPO; import com.engine.salary.enums.OperateTypeEnum; +import com.engine.salary.enums.auth.AuthFilterTypeEnum; import com.engine.salary.enums.salarybill.SalaryTemplateWhetherEnum; import com.engine.salary.exception.SalaryRunTimeException; import com.engine.salary.mapper.salarysob.SalarySobEmpFieldMapper; import com.engine.salary.report.entity.po.SalaryStatisticsReportPO; import com.engine.salary.service.*; +import com.engine.salary.service.auth.AuthService; +import com.engine.salary.service.auth.AuthServiceImpl; import com.engine.salary.util.SalaryEntityUtil; import com.engine.salary.util.SalaryI18nUtil; import com.engine.salary.util.db.IdGenerator; @@ -86,6 +89,10 @@ public class SalaryTemplateServiceImpl extends Service implements SalaryTemplate return MapperProxyFactory.getProxy(SalarySobEmpFieldMapper.class); } + public AuthService getAuthService(User user) { + return ServiceUtil.getService(AuthServiceImpl.class, user); + } + @Override public SalaryTemplatePO getById(Long id) { return mapper.getById(id); @@ -492,30 +499,10 @@ public class SalaryTemplateServiceImpl extends Service implements SalaryTemplate @Override public PageInfo listPage(SalaryTemplateQueryParam queryParam) { - List salaryTemplateDTOList = Collections.emptyList(); - // 分权 - 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); - if (org.apache.commons.collections4.CollectionUtils.isNotEmpty(salarySobIds)) { - // 查询 - salaryTemplateDTOList = mapper.listDTO(SalaryTemplatePO.builder() - .salarySobId(queryParam.getSalarySobId()) - .name(queryParam.getName()) - .salarySobIds(salarySobIds).build()); - } else { - return SalaryPageUtil.buildPage(queryParam.getCurrent(), queryParam.getPageSize(), salaryTemplateDTOList, SalaryTemplateListDTO.class); - } - } else { - // 查询 - salaryTemplateDTOList = mapper.listDTO(SalaryTemplatePO.builder().salarySobId(queryParam.getSalarySobId()).name(queryParam.getName()).build()); - } + List salaryTemplateDTOList = mapper.listDTO(SalaryTemplatePO.builder().salarySobId(queryParam.getSalarySobId()).name(queryParam.getName()).build()); + salaryTemplateDTOList = getAuthService(user).auth(salaryTemplateDTOList, AuthFilterTypeEnum.DATA_OPT, SalaryTemplateListDTO.class); - // 分页参数 - PageInfo page = SalaryPageUtil.buildPage(queryParam.getCurrent(), queryParam.getPageSize(), salaryTemplateDTOList, SalaryTemplateListDTO.class); - return page; + return SalaryPageUtil.buildPage(queryParam.getCurrent(), queryParam.getPageSize(), salaryTemplateDTOList, SalaryTemplateListDTO.class); } @Override diff --git a/src/com/engine/salary/service/impl/TaxAgentServiceImpl.java b/src/com/engine/salary/service/impl/TaxAgentServiceImpl.java index 6128fa729..83de92b5f 100644 --- a/src/com/engine/salary/service/impl/TaxAgentServiceImpl.java +++ b/src/com/engine/salary/service/impl/TaxAgentServiceImpl.java @@ -45,6 +45,8 @@ import com.engine.salary.mapper.siaccount.InsuranceAccountBatchMapper; import com.engine.salary.mapper.siarchives.InsuranceBaseInfoMapper; import com.engine.salary.mapper.taxagent.TaxAgentMapper; import com.engine.salary.service.*; +import com.engine.salary.service.auth.AuthService; +import com.engine.salary.service.auth.AuthServiceImpl; import com.engine.salary.sys.entity.vo.UploadConfigResponse; import com.engine.salary.util.SalaryEntityUtil; import com.engine.salary.util.SalaryI18nUtil; @@ -147,6 +149,10 @@ public class TaxAgentServiceImpl extends Service implements TaxAgentService { return MapperProxyFactory.getProxy(InsuranceAccountBatchMapper.class); } + public AuthService getAuthService(User user) { + return ServiceUtil.getService(AuthServiceImpl.class, user); + } + // private PaymentAgencyMapper paymentAgencyMapper; @@ -284,7 +290,7 @@ public class TaxAgentServiceImpl extends Service implements TaxAgentService { public List listAuth(TaxAgentQueryParam queryParam) { List taxAgents = getTaxAgentMapper().listBySome(queryParam); AuthFilterTypeEnum filterType = queryParam.getFilterType(); - return handleForDevolution(taxAgents, (long) user.getUID(), filterType == AuthFilterTypeEnum.QUERY_DATA); + return getAuthService(user).auth(taxAgents, filterType, TaxAgentPO.class); } @Override diff --git a/src/com/engine/salary/wrapper/SalaryTemplateWrapper.java b/src/com/engine/salary/wrapper/SalaryTemplateWrapper.java index 3d04d3341..b78eae261 100644 --- a/src/com/engine/salary/wrapper/SalaryTemplateWrapper.java +++ b/src/com/engine/salary/wrapper/SalaryTemplateWrapper.java @@ -86,67 +86,8 @@ public class SalaryTemplateWrapper extends Service { public PageInfo list(SalaryTemplateQueryParam queryParam) { PageInfo listPage = getSalaryTemplateService(user).listPage(queryParam); return listPage; -// SalaryWeaTable table = new SalaryWeaTable(user, SalaryTemplateListDTO.class); -// -// String fields = " t.id" + -// " , t.name" + -// " , t.replenish_name as replenishName" + -// " , s.name as salarySob" + -// " , t.use_type as useType" + -// " , t.description"; -// -// String from = " from hrsa_salary_template t left join hrsa_salary_sob s on t.salary_sob_id = s.id "; -// -// table.setBackfields(fields); -// table.setSqlform(from); -// table.setSqlwhere(makeSqlWhere(queryParam)); -// table.setSqlorderby("t.id DESC"); -// table.setSqlprimarykey("t.id"); -// table.setSqlisdistinct("false"); -// -// WeaResultMsg result = new WeaResultMsg(false); -// result.putAll(table.makeDataResult()); -// result.success(); -// return result.getResultMap(); - } -// private String makeSqlWhere(SalaryTemplateQueryParam queryParam) { -// DBType dbType = DBType.get(new RecordSet().getDBType()); -// -// String sqlWhere = " t.delete_type = 0 "; -// -// String name = queryParam.getName(); -// if (StringUtils.isNotBlank(name)) { -// sqlWhere += " AND t.name " + dbType.like(name); -// } -// -// Collection ids = queryParam.getIds(); -// -// if (ids != null && ids.size() > 0) { -// sqlWhere += " AND t.id in (" + ids.stream().map(Object::toString).collect(Collectors.joining(",")) + ") "; -// } -// -// Long salarySobId = queryParam.getSalarySobId(); -// -// if (salarySobId != null) { -// sqlWhere += " AND t.salary_sob_id = " + salarySobId; -// } -// -// 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); -// if (CollectionUtils.isNotEmpty(salarySobIds)) { -// sqlWhere += " AND t.salary_sob_id in (" + salarySobIds.stream().map(Object::toString).collect(Collectors.joining(",")) + ") "; -// } else { -// sqlWhere += " AND 1=2 "; -// } -// } -// -// -// return sqlWhere; -// } + } /** * 获取工资单模板基础设置表单