Compare commits
2 Commits
b1340f0b8e
...
e53858e7c6
Author | SHA1 | Date |
---|---|---|
youHong.ai | e53858e7c6 | |
youHong.ai | af35223154 |
|
@ -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<HrmResource> selectAll(@ParamMapper("typeOfEmploymentFiled") String typeOfEmploymentField,
|
||||
|
|
|
@ -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<HrmResource> hrmResourceList = mapper.selectAll(typeOfEmploymentField, lastNameEnField);
|
||||
if (Objects.isNull(hrmResourceList) || hrmResourceList.isEmpty()) {
|
||||
throw new CustomerException("查询不到相关人员!");
|
||||
}
|
||||
//List<HrmResourceDto> hrmResourceDtoList = new ArrayList();
|
||||
AtomicReference<HrmResourceDto> currentUser = new AtomicReference<>();
|
||||
/* ******************* 将pojo转换为Dto对象,对节点属性默认值赋值,找出当前用户并设置显示 ******************* */
|
||||
List<HrmResourceDto> 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<HrmResourceDto> 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<Integer> currentUserManagerList = Arrays.stream(currentUserManagerStr.split(","))
|
||||
.map(Integer::parseInt)
|
||||
.collect(Collectors.toList());
|
||||
List<Integer> 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());
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -34,4 +34,14 @@ public class MultipartFile {
|
|||
* 文件大小
|
||||
*/
|
||||
Long fileSize;
|
||||
|
||||
/**
|
||||
* 文件id
|
||||
*/
|
||||
private Integer imageFileId;
|
||||
|
||||
/**
|
||||
* docId
|
||||
*/
|
||||
private Integer docId;
|
||||
}
|
||||
|
|
|
@ -932,6 +932,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);
|
||||
|
|
|
@ -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<OrgChartNodeVo> orgChartTree = orgChartService.getOrgChartTree(user);
|
||||
System.out.println(JSON.toJSONString(orgChartTree));
|
||||
|
|
Loading…
Reference in New Issue