From af3522315401efaa6fd0a6256511f533bfc4ffad Mon Sep 17 00:00:00 2001 From: "youHong.ai" <774495953@qq.com> Date: Tue, 6 Dec 2022 17:01:48 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BA=A2=E4=BA=A2=E4=B8=8A?= =?UTF-8?q?=E4=BC=A0=E9=99=84=E4=BB=B6=E7=9A=84=E5=AE=9E=E4=BD=93=E7=B1=BB?= =?UTF-8?q?=EF=BC=8C=E6=B7=BB=E5=8A=A0=E9=99=84=E4=BB=B6docid=E5=92=8Cimag?= =?UTF-8?q?efileid?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../orgchart/mapper/OrgChartMapper.java | 3 +- .../orgchart/service/OrgChartService.java | 72 ++++++------------- .../commons/config/entity/MultipartFile.java | 10 +++ .../config/service/DealWithMapping.java | 2 + .../java/youhong/ai/pcn/TestOrganization.java | 2 +- 5 files changed, 35 insertions(+), 54 deletions(-) diff --git a/src/main/java/com/api/youhong/ai/pcn/organization/orgchart/mapper/OrgChartMapper.java b/src/main/java/com/api/youhong/ai/pcn/organization/orgchart/mapper/OrgChartMapper.java index 5cc7118..c89e166 100644 --- a/src/main/java/com/api/youhong/ai/pcn/organization/orgchart/mapper/OrgChartMapper.java +++ b/src/main/java/com/api/youhong/ai/pcn/organization/orgchart/mapper/OrgChartMapper.java @@ -1,6 +1,5 @@ package com.api.youhong.ai.pcn.organization.orgchart.mapper; -import aiyh.utils.annotation.recordset.CaseConversion; import aiyh.utils.annotation.recordset.ParamMapper; import aiyh.utils.annotation.recordset.Select; import aiyh.utils.annotation.recordset.SqlMapper; @@ -45,7 +44,7 @@ public interface OrgChartMapper { " inner join hrmjobtitles job on hrm.JOBTITLE = job.id " + " inner join cus_fielddata cus on cus.ID = hrm.ID " + " and cus.SCOPE = 'HrmCustomFieldByInfoType' " + - " and cus.SCOPEID = -1 " + + " and cus.SCOPEID = 1 " + " inner join hrmdepartment dept on dept.id = hrm.DEPARTMENTID " + "where hrm.status in (0, 1)") List selectAll(@ParamMapper("typeOfEmploymentFiled") String typeOfEmploymentField, diff --git a/src/main/java/com/api/youhong/ai/pcn/organization/orgchart/service/OrgChartService.java b/src/main/java/com/api/youhong/ai/pcn/organization/orgchart/service/OrgChartService.java index e2745d6..a696908 100644 --- a/src/main/java/com/api/youhong/ai/pcn/organization/orgchart/service/OrgChartService.java +++ b/src/main/java/com/api/youhong/ai/pcn/organization/orgchart/service/OrgChartService.java @@ -1,6 +1,7 @@ package com.api.youhong.ai.pcn.organization.orgchart.service; import aiyh.utils.Util; +import aiyh.utils.excention.CustomerException; import cn.hutool.core.lang.Assert; import com.api.youhong.ai.pcn.organization.orgchart.dto.HrmResourceDto; import com.api.youhong.ai.pcn.organization.orgchart.mapper.OrgChartMapper; @@ -45,28 +46,17 @@ public class OrgChartService { String lastNameEnField = Util.getCusConfigValue("lastNameEnField"); Assert.notBlank(lastNameEnField, "config [lastNameEnField] is null or blank!"); List hrmResourceList = mapper.selectAll(typeOfEmploymentField, lastNameEnField); + if (Objects.isNull(hrmResourceList) || hrmResourceList.isEmpty()) { + throw new CustomerException("查询不到相关人员!"); + } //List hrmResourceDtoList = new ArrayList(); AtomicReference currentUser = new AtomicReference<>(); /* ******************* 将pojo转换为Dto对象,对节点属性默认值赋值,找出当前用户并设置显示 ******************* */ - List hrmResourceDtoList = hrmResourceList.stream() - .map(struct::hrmResourceToDto) - .peek(item -> Builder.startSet(item) - .with(HrmResourceDto::setShow, 0) - .with(HrmResourceDto::setShowBrother, 0) - .with(HrmResourceDto::setShowChildren, 0) - .endSet()) - .collect(Collectors.toList()); - hrmResourceDtoList.stream() - .filter(item -> item.getId() == userId) - .forEach(item -> { - Builder.startSet(item) - .with(HrmResourceDto::setShow, 1) - .with(HrmResourceDto::setShowBrother, 1) - .with(HrmResourceDto::setShowChildren, 1) - .with(HrmResourceDto::setCurrent, true) - .endSet(); - currentUser.set(item); - }); + List hrmResourceDtoList = hrmResourceList.stream().map(struct::hrmResourceToDto).peek(item -> Builder.startSet(item).with(HrmResourceDto::setShow, 0).with(HrmResourceDto::setShowBrother, 0).with(HrmResourceDto::setShowChildren, 0).endSet()).collect(Collectors.toList()); + hrmResourceDtoList.stream().filter(item -> item.getId() == userId).forEach(item -> { + Builder.startSet(item).with(HrmResourceDto::setShow, 1).with(HrmResourceDto::setShowBrother, 1).with(HrmResourceDto::setShowChildren, 1).with(HrmResourceDto::setCurrent, true).endSet(); + currentUser.set(item); + }); Assert.notNull(currentUser, "not find current login user info!"); /* ******************* 查找当前登陆人员的所有上级 ******************* */ String currentUserManagerStr = currentUser.get().getManagerStr(); @@ -74,16 +64,9 @@ public class OrgChartService { currentUserManagerStr = ""; } currentUserManagerStr = Util.removeSeparator(currentUserManagerStr, ","); - List currentUserManagerList = Arrays.stream(currentUserManagerStr.split(",")) - .map(Integer::parseInt) - .collect(Collectors.toList()); + List currentUserManagerList = Arrays.stream(currentUserManagerStr.split(",")).map(Integer::parseInt).collect(Collectors.toList()); /* ******************* 对当前用户的所有直接上级设置标识 ******************* */ - hrmResourceDtoList.stream() - .filter(item -> currentUserManagerList.contains(item.getId())) - .forEach(item -> Builder.startSet(item) - .with(HrmResourceDto::setShowChildren, 1) - .with(HrmResourceDto::setCurrentParent, true) - .endSet()); + hrmResourceDtoList.stream().filter(item -> currentUserManagerList.contains(item.getId())).forEach(item -> Builder.startSet(item).with(HrmResourceDto::setShowChildren, 1).with(HrmResourceDto::setCurrentParent, true).endSet()); /* ******************* 查询当前用户的是否全部展示或显示小红点的配置信息 ******************* */ ShowPointOrAll showPointOrAll = mapper.selectShowPointOrAll(userId); @@ -92,34 +75,21 @@ public class OrgChartService { /* ******************* 转换dto为Vo并且设置根节点标识 ******************* */ orgChartNodeVoList = hrmResourceDtoList.stream() .map(struct::hrmResourceDtoToVo) + .peek(item -> item.setType(-1)) .collect(Collectors.toList()); } else { /* ******************* 转换dto为Vo并且设置根节点标识 ******************* */ - orgChartNodeVoList = hrmResourceDtoList.stream() - .map(struct::hrmResourceDtoToVo) - .peek(item -> { - if (showPointOrAll.isShowAll()) { - Builder.startSet(item) - .with(OrgChartNodeVo::setShow, 1) - .with(OrgChartNodeVo::setShowBrother, 1) - .with(OrgChartNodeVo::setShowChildren, 1) - .endSet(); - } - if (!showPointOrAll.isShowType()) { - item.setType(-1); - } - }) - .collect(Collectors.toList()); + orgChartNodeVoList = hrmResourceDtoList.stream().map(struct::hrmResourceDtoToVo).peek(item -> { + if (showPointOrAll.isShowAll()) { + Builder.startSet(item).with(OrgChartNodeVo::setShow, 1).with(OrgChartNodeVo::setShowBrother, 1).with(OrgChartNodeVo::setShowChildren, 1).endSet(); + } + if (!showPointOrAll.isShowType()) { + item.setType(-1); + } + }).collect(Collectors.toList()); } - return Util.listToTree(orgChartNodeVoList, OrgChartNodeVo::getId, - OrgChartNodeVo::getManagerId, OrgChartNodeVo::getChildren, - OrgChartNodeVo::setChildren, - parentId -> parentId == null || parentId <= 0) - .stream() - .peek(item -> item.setIsRoot(true)) - .peek(item -> recursionChildrenNums(item, 0)) - .collect(Collectors.toList()); + return Util.listToTree(orgChartNodeVoList, OrgChartNodeVo::getId, OrgChartNodeVo::getManagerId, OrgChartNodeVo::getChildren, OrgChartNodeVo::setChildren, parentId -> parentId == null || parentId <= 0).stream().peek(item -> item.setIsRoot(true)).peek(item -> recursionChildrenNums(item, 0)).collect(Collectors.toList()); } diff --git a/src/main/java/weaver/xiao/commons/config/entity/MultipartFile.java b/src/main/java/weaver/xiao/commons/config/entity/MultipartFile.java index 0e8e73f..ae4f4a9 100644 --- a/src/main/java/weaver/xiao/commons/config/entity/MultipartFile.java +++ b/src/main/java/weaver/xiao/commons/config/entity/MultipartFile.java @@ -34,4 +34,14 @@ public class MultipartFile { * 文件大小 */ Long fileSize; + + /** + * 文件id + */ + private Integer imageFileId; + + /** + * docId + */ + private Integer docId; } diff --git a/src/main/java/weaver/xiao/commons/config/service/DealWithMapping.java b/src/main/java/weaver/xiao/commons/config/service/DealWithMapping.java index a2ea70f..def909f 100644 --- a/src/main/java/weaver/xiao/commons/config/service/DealWithMapping.java +++ b/src/main/java/weaver/xiao/commons/config/service/DealWithMapping.java @@ -893,6 +893,8 @@ public class DealWithMapping extends ToolUtil { MultipartFile multipartFile = new MultipartFile(); InputStream fileInputStream = ImageFileManager.getInputStreamById(docImageFile.getImageFileId()); multipartFile.setFileKey(paramName); + multipartFile.setImageFileId(docImageFile.getImageFileId()); + multipartFile.setDocId(docImageFile.getDocId()); multipartFile.setStream(fileInputStream); multipartFile.setFileName(docImageFile.getImageFileName()); multipartFile.setFileSize(docImageFile.getFileSize() / 1024); diff --git a/src/test/java/youhong/ai/pcn/TestOrganization.java b/src/test/java/youhong/ai/pcn/TestOrganization.java index a275676..8638add 100644 --- a/src/test/java/youhong/ai/pcn/TestOrganization.java +++ b/src/test/java/youhong/ai/pcn/TestOrganization.java @@ -195,7 +195,7 @@ public class TestOrganization extends BaseTest { @Test public void testOrgChart() { - User user = new User(88); + User user = new User(84); OrgChartService orgChartService = new OrgChartService(); List orgChartTree = orgChartService.getOrgChartTree(user); System.out.println(JSON.toJSONString(orgChartTree));