Browse Source

前端定制化逻辑接口重构

master
niohe·erbao 1 year ago
parent
commit
fff8527a93
3 changed files with 48 additions and 101 deletions
  1. +2
    -9
      pmapi/src/main/java/com/ningdatech/pmapi/organization/controller/DingOrganizationController.java
  2. +44
    -90
      pmapi/src/main/java/com/ningdatech/pmapi/organization/manage/OrganizationManage.java
  3. +2
    -2
      pmapi/src/main/java/com/ningdatech/pmapi/organization/model/po/ReqSynthesizePO.java

+ 2
- 9
pmapi/src/main/java/com/ningdatech/pmapi/organization/controller/DingOrganizationController.java View File

@@ -6,7 +6,6 @@ import com.ningdatech.pmapi.organization.manage.OrganizationManage;
import com.ningdatech.pmapi.organization.model.po.ReqOrganizationListPO;
import com.ningdatech.pmapi.organization.model.po.ReqSynthesizePO;
import com.ningdatech.pmapi.organization.model.vo.KeyTreeVO;
import com.ningdatech.pmapi.organization.model.vo.OrganizationSynthesizeTreeVO;
import com.ningdatech.pmapi.organization.model.vo.OrganizationTreeVO;
import com.ningdatech.pmapi.organization.model.vo.ResOrganizationListVO;
import io.swagger.annotations.Api;
@@ -50,15 +49,9 @@ public class DingOrganizationController {
return organizationManage.getChildOrganizationList(parentCode);
}

@ApiOperation("综合列表筛选")
@PostMapping("/synthesize-list")
public List<OrganizationSynthesizeTreeVO> organizationSynthesizeList(@Valid @RequestBody ReqSynthesizePO request) {
return organizationManage.organizationSynthesizeList(request);
}

@ApiOperation("组织树状列表筛选")
@ApiOperation("组织树状列表筛选(前端定制化接口不可复用)")
@PostMapping("/tree-list")
public List<KeyTreeVO> treeVOList(@Valid @RequestBody ReqSynthesizePO request) {
return organizationManage.treeVOList(request);
return organizationManage.treeRubbishVOList(request);
}
}

+ 44
- 90
pmapi/src/main/java/com/ningdatech/pmapi/organization/manage/OrganizationManage.java View File

@@ -13,8 +13,6 @@ import com.ningdatech.pmapi.organization.model.entity.DingOrganization;
import com.ningdatech.pmapi.organization.model.po.ReqOrganizationListPO;
import com.ningdatech.pmapi.organization.model.po.ReqSynthesizePO;
import com.ningdatech.pmapi.organization.model.vo.KeyTreeVO;
import com.ningdatech.pmapi.organization.model.vo.OrganizationSynthesizeTreeVO;
import com.ningdatech.pmapi.organization.model.vo.OrganizationSynthesizeTreeVO.OrganizationMemberInfo;
import com.ningdatech.pmapi.organization.model.vo.OrganizationTreeVO;
import com.ningdatech.pmapi.organization.model.vo.ResOrganizationListVO;
import com.ningdatech.pmapi.organization.service.IDingEmployeeInfoService;
@@ -26,7 +24,6 @@ import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
@@ -110,106 +107,63 @@ public class OrganizationManage {
}).collect(Collectors.toList());
}

public List<OrganizationSynthesizeTreeVO> organizationSynthesizeList(ReqSynthesizePO request) {
String parentCode = request.getParentCode();
Boolean needMember = request.getNeedMember();
public List<KeyTreeVO> treeRubbishVOList(ReqSynthesizePO request) {
String organizationCode = request.getOrganizationCode();

List<OrganizationTreeVO> childOrganizationList = getChildOrganizationList(parentCode);

List<OrganizationSynthesizeTreeVO> organizationSynthesizeTreeVOList = childOrganizationList.stream().map(r -> {
OrganizationSynthesizeTreeVO organizationSynthesizeTreeVO = new OrganizationSynthesizeTreeVO();
organizationSynthesizeTreeVO.setName(r.getName());
organizationSynthesizeTreeVO.setOrganizationCode(r.getOrganizationCode());
organizationSynthesizeTreeVO.setParentCode(r.getParentCode());
return organizationSynthesizeTreeVO;
}).collect(Collectors.toList());

if (needMember && organizationSynthesizeTreeVOList.size() > 0) {
List<String> organizationCodeList = organizationSynthesizeTreeVOList.stream()
.map(OrganizationSynthesizeTreeVO::getOrganizationCode).collect(Collectors.toList());
List<DingEmployeeInfo> dingEmployeeInfoList = iDingEmployeeInfoService.list(Wrappers.lambdaQuery(DingEmployeeInfo.class)
.eq(DingEmployeeInfo::getMainJob, "true")
.in(DingEmployeeInfo::getOrganizationCode, organizationCodeList));

Map<String, List<DingEmployeeInfo>> organizationCodeGroupMap = dingEmployeeInfoList.stream()
.collect(Collectors.groupingBy(DingEmployeeInfo::getOrganizationCode));

for (OrganizationSynthesizeTreeVO organizationSynthesizeTreeVO : organizationSynthesizeTreeVOList) {
String organizationCode = organizationSynthesizeTreeVO.getOrganizationCode();
List<DingEmployeeInfo> dingEmployeeInfoGroupList = organizationCodeGroupMap.get(organizationCode);
if (CollUtil.isNotEmpty(dingEmployeeInfoGroupList)) {
List<OrganizationMemberInfo> organizationMemberInfoList = dingEmployeeInfoGroupList.stream().map(r -> {
OrganizationMemberInfo organizationMemberInfo = new OrganizationMemberInfo();
organizationMemberInfo.setEmployeeCode(r.getEmployeeCode());
organizationMemberInfo.setName(r.getEmployeeName());
return organizationMemberInfo;
}).collect(Collectors.toList());
organizationSynthesizeTreeVO.setMemberList(organizationMemberInfoList);
}
}
List<DingOrganization> dingOrganizationList = new ArrayList<>();
List<String> organizationCodeList = new ArrayList<>();
if (StrUtils.isBlank(organizationCode)) {
organizationCodeList = dingOrganizationProperties.getDeptVisibleScopes();
} else {
organizationCodeList = CollectionUtil.toList(organizationCode);
}
dingOrganizationList = iDingOrganizationService.list(Wrappers.lambdaQuery(DingOrganization.class)
.in(DingOrganization::getOrganizationCode, organizationCodeList));

return organizationSynthesizeTreeVOList;
}

public List<KeyTreeVO> treeVOList(ReqSynthesizePO request) {
String parentCode = request.getParentCode();
Boolean needMember = request.getNeedMember();

List<OrganizationTreeVO> childOrganizationList = getChildOrganizationList(parentCode);

List<KeyTreeVO> orgKeyTreeVOList = childOrganizationList.stream().map(r -> {
List<KeyTreeVO> orgKeyTreeVOList = dingOrganizationList.stream().map(r -> {
KeyTreeVO keyTreeVO = new KeyTreeVO();
keyTreeVO.setTitle(r.getName());
keyTreeVO.setTitle(r.getOrganizationName());
keyTreeVO.setKey(r.getOrganizationCode());
keyTreeVO.setType("ORGANIZATION");
return keyTreeVO;
}).collect(Collectors.toList());
treeVOList(request.getNeedMember(), orgKeyTreeVOList);
return orgKeyTreeVOList;
}

if (StringUtils.isNotBlank(parentCode) && needMember){
List<DingEmployeeInfo> dingEmployeeInfoList = iDingEmployeeInfoService.list(Wrappers.lambdaQuery(DingEmployeeInfo.class)
.eq(DingEmployeeInfo::getMainJob, "true")
.eq(DingEmployeeInfo::getOrganizationCode, parentCode));
List<KeyTreeVO> memberChildren = dingEmployeeInfoList.stream().map(r -> {
KeyTreeVO child = new KeyTreeVO();
child.setKey(r.getEmployeeCode());
child.setTitle(r.getEmployeeName());
child.setType("MEMBER");
return child;
public void treeVOList(Boolean needMember, List<KeyTreeVO> basicOrgKeyTreeVOList) {
for (KeyTreeVO basicOrgKeyTreeVO : basicOrgKeyTreeVOList) {
String parentCode = basicOrgKeyTreeVO.getKey();
List<OrganizationTreeVO> childOrganizationList = getChildOrganizationList(parentCode);

List<KeyTreeVO> orgKeyTreeVOList = childOrganizationList.stream().map(r -> {
KeyTreeVO keyTreeVO = new KeyTreeVO();
keyTreeVO.setTitle(r.getName());
keyTreeVO.setKey(r.getOrganizationCode());
keyTreeVO.setType("ORGANIZATION");
return keyTreeVO;
}).collect(Collectors.toList());

if (CollUtil.isNotEmpty(memberChildren)) {
orgKeyTreeVOList.addAll(memberChildren);
if (StringUtils.isNotBlank(parentCode) && needMember) {
List<DingEmployeeInfo> dingEmployeeInfoList = iDingEmployeeInfoService.list(Wrappers.lambdaQuery(DingEmployeeInfo.class)
.eq(DingEmployeeInfo::getMainJob, "true")
.eq(DingEmployeeInfo::getOrganizationCode, parentCode));

List<KeyTreeVO> memberChildren = dingEmployeeInfoList.stream().map(r -> {
KeyTreeVO child = new KeyTreeVO();
child.setKey(r.getEmployeeCode());
child.setTitle(r.getEmployeeName());
child.setType("MEMBER");
return child;
}).collect(Collectors.toList());

if (CollUtil.isNotEmpty(memberChildren)) {
orgKeyTreeVOList.addAll(memberChildren);
}
}
basicOrgKeyTreeVO.setChildren(orgKeyTreeVOList);
}
}

// if (needMember && orgKeyTreeVOList.size() > 0) {
// List<String> organizationCodeList = orgKeyTreeVOList.stream()
// .map(KeyTreeVO::getKey).collect(Collectors.toList());
// List<DingEmployeeInfo> dingEmployeeInfoList = iDingEmployeeInfoService.list(Wrappers.lambdaQuery(DingEmployeeInfo.class)
// .eq(DingEmployeeInfo::getMainJob, "true")
// .in(DingEmployeeInfo::getOrganizationCode, organizationCodeList));
//
// Map<String, List<DingEmployeeInfo>> organizationCodeGroupMap = dingEmployeeInfoList.stream()
// .collect(Collectors.groupingBy(DingEmployeeInfo::getOrganizationCode));
//
// for (KeyTreeVO keyTreeVO : orgKeyTreeVOList) {
// String organizationCode = keyTreeVO.getKey();
// List<DingEmployeeInfo> dingEmployeeInfoGroupList = organizationCodeGroupMap.get(organizationCode);
// if (CollUtil.isNotEmpty(dingEmployeeInfoGroupList)) {
// List<KeyTreeVO> memberChildren = dingEmployeeInfoGroupList.stream().map(r -> {
// KeyTreeVO child = new KeyTreeVO();
// child.setKey(r.getEmployeeCode());
// child.setTitle(r.getEmployeeName());
// child.setType("MEMBER");
// return child;
// }).collect(Collectors.toList());
// keyTreeVO.setChildren(memberChildren);
// }
// }
// }

return orgKeyTreeVOList;
}
}

+ 2
- 2
pmapi/src/main/java/com/ningdatech/pmapi/organization/model/po/ReqSynthesizePO.java View File

@@ -15,8 +15,8 @@ import javax.validation.constraints.NotBlank;
@ApiModel("单位列表综合筛选请求")
public class ReqSynthesizePO {

@ApiModelProperty("组织code")
private String parentCode;
@ApiModelProperty("组织code")
private String organizationCode;

@ApiModelProperty("是否需要组织成员列表")
private Boolean needMember = false;


Loading…
Cancel
Save