From f07b0b7e16344b00bc79bdd9be59df03b8e9e6a1 Mon Sep 17 00:00:00 2001 From: andy <1042025947@qq.com> Date: Tue, 2 Jun 2026 16:50:54 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=84=E7=90=86=E8=B4=A2=E5=8A=A1=E5=AF=BC?= =?UTF-8?q?=E5=87=BA=E6=98=BE=E7=A4=BA=E6=8C=87=E5=AE=9A=E5=90=8D=E7=A7=B0?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/core/domain/entity/SysDept.java | 3 ++ .../impl/RzSalaryDetailServiceImpl.java | 33 +++++++++++++++---- .../resources/mapper/system/SysDeptMapper.xml | 11 +++++-- 3 files changed, 38 insertions(+), 9 deletions(-) diff --git a/evo-admin/src/main/java/com/evo/common/core/domain/entity/SysDept.java b/evo-admin/src/main/java/com/evo/common/core/domain/entity/SysDept.java index 6419c53..ede1e15 100644 --- a/evo-admin/src/main/java/com/evo/common/core/domain/entity/SysDept.java +++ b/evo-admin/src/main/java/com/evo/common/core/domain/entity/SysDept.java @@ -57,6 +57,9 @@ public class SysDept extends BaseEntity /** 是否加班 */ private String isOverTime; + /** 是否加班 */ + private String isShowFinancial; + /** 子部门 */ @TableField(exist = false) private List children = new ArrayList(); diff --git a/evo-admin/src/main/java/com/evo/finance/service/impl/RzSalaryDetailServiceImpl.java b/evo-admin/src/main/java/com/evo/finance/service/impl/RzSalaryDetailServiceImpl.java index 032e6db..a99e089 100644 --- a/evo-admin/src/main/java/com/evo/finance/service/impl/RzSalaryDetailServiceImpl.java +++ b/evo-admin/src/main/java/com/evo/finance/service/impl/RzSalaryDetailServiceImpl.java @@ -283,7 +283,7 @@ public class RzSalaryDetailServiceImpl extends ServiceImpl buildExportData(RzSalaryDetail rzSalaryDetail) { // 获取所有部门列表 List deptList = deptMapper.selectList(new LambdaQueryWrapper()); + Map deptNameMap = Collections.emptyMap(); //deptList.stream().collect(Collectors.toMap(SysDept::getDeptId, SysDept::getDeptName)); + for (SysDept dept : deptList) { + deptNameMap.put(dept.getDeptId(), buildDept(dept.getDeptId(), deptList, deptNameMap)); + } //部门列表转换为部门ID到部门名称的映射 - Map deptNameMap = deptList.stream().collect(Collectors.toMap(SysDept::getDeptId, SysDept::getDeptName)); +// Map deptNameMap = deptList.stream().collect(Collectors.toMap(SysDept::getDeptId, SysDept::getDeptName)); //键为部门ID,值为部门名称,用于快速查找父部门为根部门(ID为0)的部门名称 - Map nameAndDeptIdMap = deptList.stream().filter(d -> d.getParentId().equals(0l)).collect(Collectors.toMap(d->String.valueOf(d.getDeptId()), SysDept::getDeptName)); + Map topDeptNameAndDeptIdMap = deptList.stream().filter(d -> d.getParentId().equals(0l)).collect(Collectors.toMap(d->String.valueOf(d.getDeptId()), SysDept::getDeptName)); Map companyNameMap = Collections.emptyMap(); // 过滤出所有非根部门(即parentId不等于0的部门),并为每个部门执行以下操作 deptList.stream().filter(d -> !d.getParentId().equals(0l)).forEach(d ->{ // 将当前部门的祖ID字符串拆分成List以便后续处理 List parentIdList = Collections.asList(d.getAncestors().split(",")); - Iterator it = nameAndDeptIdMap.keySet().iterator(); + Iterator it = topDeptNameAndDeptIdMap.keySet().iterator(); while (it.hasNext()){ String pid = it.next(); if(parentIdList.contains(pid)){ - companyNameMap.put(d.getDeptId(), nameAndDeptIdMap.get(pid)); + companyNameMap.put(d.getDeptId(), topDeptNameAndDeptIdMap.get(pid)); } } }); - nameAndDeptIdMap.entrySet().stream().forEach(d->{ + topDeptNameAndDeptIdMap.entrySet().stream().forEach(d->{ companyNameMap.put(Long.valueOf(d.getKey()), d.getValue()); }); @@ -390,6 +394,21 @@ public class RzSalaryDetailServiceImpl extends ServiceImpl deptList, Map showDeptNameMap){ + if(showDeptNameMap.containsKey(deptList)){ + return showDeptNameMap.get(deptId); + } + SysDept sysDept = deptList.stream().filter(d -> d.getDeptId().equals(deptId)).findFirst().orElse(null); + if(sysDept != null){ + if("1".equals(sysDept.getIsShowFinancial())){ + return sysDept.getDeptName(); + }else{ + return buildDept(sysDept.getParentId(), deptList, showDeptNameMap); + } + } + return null; + } + private List selectRzSalaryDetaiList(RzSalaryDetail rzSalaryDetail) { return getBaseMapper().selectRzSalaryDetailList(rzSalaryDetail); } diff --git a/evo-admin/src/main/resources/mapper/system/SysDeptMapper.xml b/evo-admin/src/main/resources/mapper/system/SysDeptMapper.xml index bbbdf06..2eb5769 100644 --- a/evo-admin/src/main/resources/mapper/system/SysDeptMapper.xml +++ b/evo-admin/src/main/resources/mapper/system/SysDeptMapper.xml @@ -19,10 +19,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + - select d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.leader, d.phone,d.status, d.del_flag,d.is_over_time, d.create_by, d.create_time + select d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.leader, d.phone,d.status, d.del_flag,d.is_over_time, d.is_show_financial, d.create_by, d.create_time from sys_dept d @@ -41,9 +42,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" AND status = #{status} - + AND is_over_time = #{isOverTime} + + AND is_show_financial = #{isShowFinancial} + ${params.dataScope} order by d.parent_id @@ -99,6 +103,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" phone, status, is_over_time, + is_show_financial, create_by, create_time )values( @@ -110,6 +115,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{phone}, #{status}, #{isOverTime}, + #{isShowFinancial}, #{createBy}, sysdate() ) @@ -125,6 +131,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" phone = #{phone}, status = #{status}, is_over_time = #{isOverTime}, + is_show_financial = #{isShowFinancial}, update_by = #{updateBy}, update_time = sysdate()