From ceb0ebb1f77774fe783ca44dd228f32b37c8029a Mon Sep 17 00:00:00 2001 From: Harryxzy Date: Fri, 30 Aug 2024 10:28:44 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A2=86=E6=82=A6=20=E6=8A=A5=E8=A1=A8?= =?UTF-8?q?=E5=88=86=E6=9D=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../salary/service/LySalaryReportService.java | 5 ++ .../impl/LySalaryReportServiceImpl.java | 55 +++++++++++++++++++ .../impl/LySocialReportServiceImpl.java | 19 +++++++ .../engine/salary/web/LySalaryController.java | 18 ++++++ .../salary/wrapper/LySalaryWrapper.java | 13 +++++ 5 files changed, 110 insertions(+) diff --git a/src/com/engine/salary/service/LySalaryReportService.java b/src/com/engine/salary/service/LySalaryReportService.java index a4bc6aaca..00bf452bc 100644 --- a/src/com/engine/salary/service/LySalaryReportService.java +++ b/src/com/engine/salary/service/LySalaryReportService.java @@ -3,6 +3,7 @@ package com.engine.salary.service; import com.engine.salary.entity.ly.param.LySalaryReportQueryParam; import com.engine.salary.entity.ly.po.LySalaryReportPO; import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import weaver.hrm.User; import java.util.List; import java.util.Map; @@ -91,4 +92,8 @@ public interface LySalaryReportService { * @return */ XSSFWorkbook exportSalaryReport(LySalaryReportQueryParam param); + + Boolean lyReportPermission(User user); + + List getCanManageFrztByUid(User user); } diff --git a/src/com/engine/salary/service/impl/LySalaryReportServiceImpl.java b/src/com/engine/salary/service/impl/LySalaryReportServiceImpl.java index 6a78b4539..1d8f670af 100644 --- a/src/com/engine/salary/service/impl/LySalaryReportServiceImpl.java +++ b/src/com/engine/salary/service/impl/LySalaryReportServiceImpl.java @@ -34,6 +34,7 @@ import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.math.NumberUtils; import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import weaver.conn.RecordSet; import weaver.general.BaseBean; import weaver.hrm.User; @@ -454,6 +455,14 @@ public class LySalaryReportServiceImpl extends Service implements LySalaryReport // 获取本月是否已有报表数据 List lySalaryReportPOS = listBySalaryMonth(salaryMonthDate); + + // 分权 + // 是否是薪酬总管理员 + boolean isChief = getTaxAgentService(user).isChief((long) user.getUID()); + if (!isChief) { + List canManageFrztByUid = getCanManageFrztByUid(user); + lySalaryReportPOS = lySalaryReportPOS.stream().filter(po -> canManageFrztByUid.contains(po.getFfgsqc())).collect(Collectors.toList()); + } if (StringUtils.isNotBlank(param.getFfgsqc())) { lySalaryReportPOS = lySalaryReportPOS.stream().filter(lySalaryReportPO -> lySalaryReportPO.getFfgsqc().contains(param.getFfgsqc())).collect(Collectors.toList()); } @@ -542,6 +551,14 @@ public class LySalaryReportServiceImpl extends Service implements LySalaryReport // 获取本月是否已有报表数据 List lySalaryReportPOS = listBySalaryMonth(salaryMonthDate); + // 分权 + // 是否是薪酬总管理员 + boolean isChief = getTaxAgentService(user).isChief((long) user.getUID()); + if (!isChief) { + List canManageFrztByUid = getCanManageFrztByUid(user); + lySalaryReportPOS = lySalaryReportPOS.stream().filter(po -> canManageFrztByUid.contains(po.getFfgsqc())).collect(Collectors.toList()); + } + return buildSumData(lySalaryReportPOS); } @@ -651,4 +668,42 @@ public class LySalaryReportServiceImpl extends Service implements LySalaryReport //获取excel return ExcelUtilPlus.genWorkbookWithChildTitleColumn(rows, "薪酬统计报表", true); } + + @Override + public Boolean lyReportPermission(User user) { + List canManageFrztByUid = getCanManageFrztByUid(user); + if (CollectionUtils.isNotEmpty(canManageFrztByUid)) { + return true; + } else { + return false; + } + } + + public List getCanManageFrztByUid(User user) { + if (user == null) { + return Collections.emptyList(); + } + RecordSet rs = new RecordSet(); + rs.execute("select frzt,ncbbqxry from uf_frzt "); + HashMap> frztInfoMap = new HashMap<>(); + while (rs.next()) { + String frzt = rs.getString("frzt"); + String ncbbqxry = rs.getString("ncbbqxry"); + if (StringUtils.isNotBlank(frzt) && StringUtils.isNotBlank(ncbbqxry)) { + List ryList = Arrays.stream(ncbbqxry.split(",")).filter(NumberUtils::isCreatable).map(Long::valueOf).collect(Collectors.toList()); + if (CollectionUtils.isNotEmpty(ryList)) { + frztInfoMap.put(frzt, ryList); + } + } + } + // 获取当前用户能够管理哪些法人主体下的数据 + List resultList = new ArrayList<>(); + for(Map.Entry> entry : frztInfoMap.entrySet()) { + List ryList = entry.getValue(); + if (ryList.contains(Long.valueOf(user.getUID()))) { + resultList.add(entry.getKey()); + } + } + return resultList; + } } diff --git a/src/com/engine/salary/service/impl/LySocialReportServiceImpl.java b/src/com/engine/salary/service/impl/LySocialReportServiceImpl.java index 9bd39d84d..3f47355e9 100644 --- a/src/com/engine/salary/service/impl/LySocialReportServiceImpl.java +++ b/src/com/engine/salary/service/impl/LySocialReportServiceImpl.java @@ -53,6 +53,10 @@ public class LySocialReportServiceImpl extends Service implements LySocialReport return MapperProxyFactory.getProxy(LySocialReportMapper.class); } + private LySalaryReportService getLySalaryReportService(User user) { + return ServiceUtil.getService(LySalaryReportServiceImpl.class, user); + } + private SalaryAcctRecordService getSalaryAcctRecordService(User user) { return ServiceUtil.getService(SalaryAcctRecordServiceImpl.class, user); } @@ -441,6 +445,13 @@ public class LySocialReportServiceImpl extends Service implements LySocialReport if (StringUtils.isNotBlank(param.getFfgsqc())) { lySocialReportPOS = lySocialReportPOS.stream().filter(lySalaryReportPO -> lySalaryReportPO.getGmgsqc().contains(param.getFfgsqc())).collect(Collectors.toList()); } + // 分权 + // 是否是薪酬总管理员 + boolean isChief = getTaxAgentService(user).isChief((long) user.getUID()); + if (!isChief) { + List canManageFrztByUid = getLySalaryReportService(user).getCanManageFrztByUid(user); + lySocialReportPOS = lySocialReportPOS.stream().filter(po -> canManageFrztByUid.contains(po.getGmgsqc())).collect(Collectors.toList()); + } PageInfo pageInfo = SalaryPageUtil.buildPage(param.getCurrent(), param.getPageSize()); if (param.isExport()) { // 是导出 @@ -538,6 +549,14 @@ public class LySocialReportServiceImpl extends Service implements LySocialReport // 获取本月是否已有报表数据 List lySocialReportPOS = listBySalaryMonth(salaryMonthDate); + + // 分权 + // 是否是薪酬总管理员 + boolean isChief = getTaxAgentService(user).isChief((long) user.getUID()); + if (!isChief) { + List canManageFrztByUid = getLySalaryReportService(user).getCanManageFrztByUid(user); + lySocialReportPOS = lySocialReportPOS.stream().filter(po -> canManageFrztByUid.contains(po.getGmgsqc())).collect(Collectors.toList()); + } return buildSumData(lySocialReportPOS); } diff --git a/src/com/engine/salary/web/LySalaryController.java b/src/com/engine/salary/web/LySalaryController.java index fc6df107c..fb21dcf2a 100644 --- a/src/com/engine/salary/web/LySalaryController.java +++ b/src/com/engine/salary/web/LySalaryController.java @@ -39,6 +39,24 @@ public class LySalaryController { return ServiceUtil.getService(LySalaryWrapper.class, user); } + + + /** + * 领悦报表权限 + * + * @param request + * @param response + * @param param + * @return + */ + @POST + @Path("/salaryReport/lyPermission") + @Produces(MediaType.APPLICATION_JSON) + public String lyReportPermission(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody LySalaryReportQueryParam param) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult(user).run(getLySalaryWrapper(user)::lyReportPermission, user); + } + //---------------------------------------------------------薪酬汇总报表start------------------------------------------ /** diff --git a/src/com/engine/salary/wrapper/LySalaryWrapper.java b/src/com/engine/salary/wrapper/LySalaryWrapper.java index d09908347..d7a80e38c 100644 --- a/src/com/engine/salary/wrapper/LySalaryWrapper.java +++ b/src/com/engine/salary/wrapper/LySalaryWrapper.java @@ -123,4 +123,17 @@ public class LySalaryWrapper extends Service { public void genPZ(LyPZGenParam queryParam) { getLyPZService(user).genPZ(queryParam); } + + + /** + * 领悦报表权限 + * @param user + */ + public Boolean lyReportPermission(User user) { + return getLySalaryReportService(user).lyReportPermission(user); + } + + public List getCanManageFrztByUid(User user) { + return getLySalaryReportService(user).getCanManageFrztByUid(user); + } }