|
|
@@ -1,9 +1,12 @@
|
|
|
package com.xunmei.core.resumption.service.impl;
|
|
|
|
|
|
+import cn.hutool.core.collection.CollectionUtil;
|
|
|
import cn.hutool.core.map.MapUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.xunmei.common.core.constant.SecurityConstants;
|
|
|
import com.xunmei.common.core.utils.IDHelper;
|
|
|
import com.xunmei.common.core.web.page.TableDataInfo;
|
|
|
import com.xunmei.core.resumption.domain.AppRule;
|
|
|
@@ -19,14 +22,16 @@ import com.xunmei.core.resumption.dto.appRulePoint.AppRulePointDto;
|
|
|
import com.xunmei.core.resumption.service.IAppRuleItemService;
|
|
|
import com.xunmei.core.resumption.service.IAppRulePointService;
|
|
|
import com.xunmei.core.resumption.vo.appRuleItem.AppRuleItemPageVo;
|
|
|
+import com.xunmei.core.resumption.vo.appRuleItem.RuleTreeItem;
|
|
|
+import com.xunmei.system.api.Eto.OrgListByTypesConditionEto;
|
|
|
+import com.xunmei.system.api.RemoteOrgService;
|
|
|
+import com.xunmei.system.api.domain.SysOrg;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
@@ -49,6 +54,8 @@ public class AppRuleItemServiceImpl extends ServiceImpl<AppRuleItemMapper, AppRu
|
|
|
// private SysDictDetailService sysDictDetailService;
|
|
|
|
|
|
@Resource
|
|
|
+ RemoteOrgService remoteOrgService;
|
|
|
+ @Resource
|
|
|
private AppRuleMapper appRuleMapper;
|
|
|
|
|
|
@Override
|
|
|
@@ -77,16 +84,12 @@ public class AppRuleItemServiceImpl extends ServiceImpl<AppRuleItemMapper, AppRu
|
|
|
|
|
|
saveOrUpdate(item);
|
|
|
final List<AppRulePointDto> pointDtoList = appRuleItemDto.getPointDtoList();
|
|
|
- Map<Object, Object> hashMap = new HashMap<>();
|
|
|
+ Set<String> hashMap = new HashSet<>();
|
|
|
for (AppRulePointDto appRulePointDto : pointDtoList) {
|
|
|
- if (hashMap.containsKey(appRulePointDto.getPointNum())) {
|
|
|
- throw new RuntimeException("检查要点编号重复!");
|
|
|
- }
|
|
|
- hashMap.put(appRulePointDto.getPointNum(), appRulePointDto.getPointName());
|
|
|
- if (hashMap.containsKey(appRulePointDto.getPointName())) {
|
|
|
- throw new RuntimeException("检查要点名称重复!");
|
|
|
+ if (hashMap.contains(appRulePointDto.getName())) {
|
|
|
+ throw new RuntimeException("履职内容重复!");
|
|
|
}
|
|
|
- hashMap.put(appRulePointDto.getPointName(), appRulePointDto.getPointNum());
|
|
|
+ hashMap.add(appRulePointDto.getName());
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -177,7 +180,44 @@ public class AppRuleItemServiceImpl extends ServiceImpl<AppRuleItemMapper, AppRu
|
|
|
appRulePointMapper.deleteByMap(MapUtil.of("item_id", id));
|
|
|
return true;
|
|
|
}
|
|
|
+ @Override
|
|
|
+ public List<RuleTreeItem> getRuleTree(Long orgId) {
|
|
|
+ List<RuleTreeItem> tree=new ArrayList<>();
|
|
|
+ List<SysOrg> orgs= remoteOrgService
|
|
|
+ .listByTypes(OrgListByTypesConditionEto.builder().orgId(orgId).orgTypes(Arrays.asList("1","2","3","4","11")).build(), SecurityConstants.INNER)
|
|
|
+ .getData();
|
|
|
+ if(ObjectUtil.isNull(orgs)){
|
|
|
+ return tree;
|
|
|
+ }
|
|
|
+ Map<Long,SysOrg> orgMap= orgs.stream().collect(Collectors.toMap(o->o.getId(),o->o));
|
|
|
+ List<SysOrg> tops= orgs.stream().filter(o->!orgMap.containsKey(o.getParentId())).collect(Collectors.toList());
|
|
|
+ if(CollectionUtil.isEmpty(tops)){
|
|
|
+ return tree;
|
|
|
+ }
|
|
|
+ List<Long> orgIds= orgs.stream().map(o->o.getId()).collect(Collectors.toList());
|
|
|
+ List<AppRule> rules= appRuleMapper.selectList(new LambdaQueryWrapper<AppRule>().in(AppRule::getOrgId,orgIds)) ;
|
|
|
+
|
|
|
+ tree= tops.stream().map(o->generateTree(o,orgs,rules)).collect(Collectors.toList());
|
|
|
+
|
|
|
+ return tree;
|
|
|
+ }
|
|
|
+
|
|
|
+ private RuleTreeItem generateTree(SysOrg parent,List<SysOrg> allOrg,List<AppRule> allRule){
|
|
|
+ RuleTreeItem item=RuleTreeItem.builder().isRule(false).id(parent.getId()).label(parent.getName()).children(new ArrayList<>()).build();
|
|
|
+ List<RuleTreeItem> ruleItems= allRule.stream().filter(r->ObjectUtil.equal(r.getOrgId(),parent.getId()))
|
|
|
+ .map(o->RuleTreeItem.builder().isRule(true).id(o.getId()).label(o.getName()).orgType(o.getOrgType()).build())
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ item.getChildren().addAll(ruleItems);
|
|
|
|
|
|
+ List<SysOrg> children= allOrg.stream()
|
|
|
+ .filter(o->ObjectUtil.equal(o.getParentId(),parent.getId()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ for (SysOrg child : children) {
|
|
|
+ item.getChildren().add(generateTree(child,allOrg,allRule));
|
|
|
+ }
|
|
|
+
|
|
|
+ return item;
|
|
|
+ }
|
|
|
// @Override
|
|
|
// public SysDictListDto dict() {
|
|
|
// final SysDictListDto dto = new SysDictListDto();
|