|
@@ -2,21 +2,23 @@ package com.dragoninfo.dcuc.auth.sub.business.impl;
|
|
|
|
|
|
import com.dragoninfo.dcuc.app.entity.ApplyInfo;
|
|
|
import com.dragoninfo.dcuc.app.facade.IApplyInfoFacade;
|
|
|
-import com.dragoninfo.dcuc.auth.sub.business.IAttrBusiness;
|
|
|
+import com.dragoninfo.dcuc.app.facade.IServiceResourceFacade;
|
|
|
import com.dragoninfo.dcuc.auth.auth.constance.CommonCons;
|
|
|
-import com.dragoninfo.dcuc.auth.sub.dto.AttrInfoTreeDTO;
|
|
|
-import com.dragoninfo.dcuc.auth.sub.dto.AttrRelAcceptDTO;
|
|
|
+import com.dragoninfo.dcuc.auth.sub.business.IAttrBusiness;
|
|
|
import com.dragoninfo.dcuc.auth.sub.dto.RelSearchDTO;
|
|
|
+import com.dragoninfo.dcuc.auth.sub.dto.ServiceRelSearchDTO;
|
|
|
import com.dragoninfo.dcuc.auth.sub.entity.AttrInfo;
|
|
|
import com.dragoninfo.dcuc.auth.sub.entity.AttrRelInfo;
|
|
|
import com.dragoninfo.dcuc.auth.sub.service.IAttrRelService;
|
|
|
import com.dragoninfo.dcuc.auth.sub.service.IAttrService;
|
|
|
+import com.dragoninfo.dcuc.auth.sub.vo.*;
|
|
|
import com.dragonsoft.duceap.base.entity.http.ResponseStatus;
|
|
|
import com.dragonsoft.duceap.base.enums.BooleanEnum;
|
|
|
import com.dragonsoft.duceap.commons.util.collections.CollectionUtils;
|
|
|
import com.dragonsoft.duceap.commons.util.string.StringUtils;
|
|
|
import com.dragonsoft.duceap.core.search.Searchable;
|
|
|
import com.dragonsoft.duceap.core.search.enums.SearchOperator;
|
|
|
+import org.apache.commons.collections.ListUtils;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.data.domain.Page;
|
|
@@ -25,6 +27,7 @@ import org.springframework.data.domain.PageRequest;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
import java.util.*;
|
|
|
+import java.util.function.Predicate;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
@@ -43,76 +46,121 @@ public class AttrBusinessImpl implements IAttrBusiness {
|
|
|
@Autowired
|
|
|
private IApplyInfoFacade applyInfoFacade;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private IServiceResourceFacade serviceResourceFacade;
|
|
|
+
|
|
|
|
|
|
@Override
|
|
|
- public ResponseStatus attrSave(AttrInfoTreeDTO dto) {
|
|
|
- String name = dto.getName();
|
|
|
- String id = dto.getId();
|
|
|
- List<AttrInfoTreeDTO> child = dto.getChild();
|
|
|
- if(CollectionUtils.isEmpty(child)) {
|
|
|
- return ResponseStatus.fail("属性值不能为空");
|
|
|
- }
|
|
|
- Map<String, List<AttrInfoTreeDTO>> nameMap = child.stream().collect(Collectors.groupingBy(AttrInfoTreeDTO::getName));
|
|
|
- for (List<AttrInfoTreeDTO> value : nameMap.values()) {
|
|
|
- if ((value.size()>1)) {
|
|
|
- return ResponseStatus.fail("属性值重复");
|
|
|
- }
|
|
|
+ public ResponseStatus attrSave(AttrInfoAddVo addVo) {
|
|
|
+ String id = addVo.getId();
|
|
|
+ String name = addVo.getName();
|
|
|
+ String code = addVo.getCode();
|
|
|
+ String pid = addVo.getPid();
|
|
|
+ String ptype = addVo.getPtype();
|
|
|
+ List<AttrInfoAddBaseVo> child = addVo.getChild();
|
|
|
+
|
|
|
+ //新增或修改的属性提交内容校验和重复性校验
|
|
|
+ ResponseStatus responseStatus = attrSaveRepeatCheck(addVo);
|
|
|
+ if (responseStatus != null){
|
|
|
+ return responseStatus;
|
|
|
}
|
|
|
|
|
|
- List<AttrInfoTreeDTO> addList;
|
|
|
- List<AttrInfoTreeDTO> updateList = null;
|
|
|
+ List<AttrInfoAddBaseVo> addList;
|
|
|
+ List<AttrInfoAddBaseVo> updateList = null;
|
|
|
List<String> deleteIdList = null;
|
|
|
+ List<AttrInfo> existChild = null;
|
|
|
AttrInfo parent;
|
|
|
- //新增父级节点
|
|
|
- AttrInfo exist = attrService.checkExist(dto.getPid(), name);
|
|
|
if (StringUtils.isBlank(id)) {
|
|
|
- //查询节点是否存在
|
|
|
- if(null != exist) {
|
|
|
- return ResponseStatus.fail(name + "属性名称已存在");
|
|
|
- }
|
|
|
AttrInfo attrInfo = new AttrInfo();
|
|
|
attrInfo.setName(name);
|
|
|
- attrInfo.setAttrBelongType(dto.getAttrBelongType());
|
|
|
- attrInfo.setAttrType(dto.getAttrType());
|
|
|
+ attrInfo.setCode(code);
|
|
|
+ attrInfo.setPtype(ptype);
|
|
|
+ attrInfo.setType(ptype + CommonCons.PATH_SEP + code);
|
|
|
+ attrInfo.setAttrSubType(addVo.getAttrSubType());
|
|
|
//父节点的pid为数据库中初始数据id
|
|
|
- attrInfo.setPid(dto.getPid());
|
|
|
- attrInfo.setRemark(dto.getRemark());
|
|
|
+ attrInfo.setPid(pid);
|
|
|
parent = attrService.save(attrInfo);
|
|
|
- addList = dto.getChild();
|
|
|
+ addList = addVo.getChild();
|
|
|
} else {
|
|
|
parent = attrService.get(id);
|
|
|
- if(parent == null){
|
|
|
- return ResponseStatus.fail(dto.getName() + "属性不存在,无法更新");
|
|
|
- }
|
|
|
- if(exist !=null && !exist.getId().equals(id)) {
|
|
|
- return ResponseStatus.fail(name + "属性名称已存在");
|
|
|
- }
|
|
|
- List<AttrInfo> existChild = attrService.getByParentId(id);
|
|
|
- Map<Boolean, List<AttrInfoTreeDTO>> collect = Optional.ofNullable(child).orElse(new ArrayList<>())
|
|
|
+ existChild = attrService.getByChildListById(id);
|
|
|
+ Map<Boolean, List<AttrInfoAddBaseVo>> collect = Optional.ofNullable(child).orElse(new ArrayList<>())
|
|
|
.stream()
|
|
|
.collect(Collectors.partitioningBy(item -> StringUtils.isNotBlank(item.getId())));
|
|
|
updateList = collect.get(Boolean.TRUE);
|
|
|
addList = collect.get(Boolean.FALSE);
|
|
|
- Set<String> idSet = updateList.stream().map(AttrInfoTreeDTO::getId).collect(Collectors.toSet());
|
|
|
+ Set<String> idSet = updateList.stream().map(AttrInfoAddBaseVo::getId).collect(Collectors.toSet());
|
|
|
deleteIdList = existChild.stream().map(AttrInfo::getId).filter(item -> !idSet.contains(item)).collect(Collectors.toList());
|
|
|
- updateList.forEach(item->item.setPid(parent.getId()));
|
|
|
- updateList.add(dto);
|
|
|
}
|
|
|
if(CollectionUtils.isNotEmpty(addList)){
|
|
|
batchSaveChild(parent,addList);
|
|
|
}
|
|
|
if(CollectionUtils.isNotEmpty(updateList)){
|
|
|
- batchUpdateAttr(updateList);
|
|
|
+ batchUpdateAttr(parent, name, code, updateList, existChild);
|
|
|
}
|
|
|
if(CollectionUtils.isNotEmpty(deleteIdList)){
|
|
|
- batchDeleteAttr(dto.getAttrBelongType(), dto.getAttrType(),deleteIdList);
|
|
|
+ batchDeleteAttr(deleteIdList);
|
|
|
}
|
|
|
return ResponseStatus.success();
|
|
|
}
|
|
|
|
|
|
+ private ResponseStatus attrSaveRepeatCheck(AttrInfoAddVo addVo) {
|
|
|
+ String name = addVo.getName();
|
|
|
+ String id = addVo.getId();
|
|
|
+ String code = addVo.getCode();
|
|
|
+ String pid = addVo.getPid();
|
|
|
+ List<AttrInfoAddBaseVo> child = addVo.getChild();
|
|
|
+
|
|
|
+ if(CollectionUtils.isEmpty(child)) {
|
|
|
+ return ResponseStatus.fail("属性值列表不能为空");
|
|
|
+ }
|
|
|
+ Map<String, Long> nameCountMap = child
|
|
|
+ .stream()
|
|
|
+ .collect(Collectors.groupingBy(AttrInfoAddBaseVo::getName, Collectors.counting()));
|
|
|
+ boolean nameRepeat = nameCountMap.values().stream().anyMatch(e -> e > 1);
|
|
|
+ if(nameRepeat) {
|
|
|
+ return ResponseStatus.fail("属性值列表中名称重复");
|
|
|
+ }
|
|
|
+ Map<String, Long> codeCountMap = child
|
|
|
+ .stream()
|
|
|
+ .collect(Collectors.groupingBy(AttrInfoAddBaseVo::getCode, Collectors.counting()));
|
|
|
+ boolean codeRepeat = codeCountMap.values().stream().anyMatch(e -> e > 1);
|
|
|
+ if(codeRepeat) {
|
|
|
+ return ResponseStatus.fail("属性值列表中编码重复");
|
|
|
+ }
|
|
|
+ //已存在的属性重复性校验
|
|
|
+ List<AttrInfo> list = attrService.getByChildListById(pid);
|
|
|
+ Predicate<AttrInfo> attrNamePredicate ;
|
|
|
+ Predicate<AttrInfo> attrCodePredicate ;
|
|
|
+ if(StringUtils.isBlank(id)) {
|
|
|
+ attrNamePredicate = (e) -> e.getName().equals(name);
|
|
|
+ attrCodePredicate = (e) -> e.getCode().equals(code);
|
|
|
+ } else {
|
|
|
+ attrNamePredicate = (e) -> e.getName().equals(name) && !e.getId().equals(id);
|
|
|
+ attrCodePredicate = (e) -> e.getCode().equals(code) && !e.getId().equals(id);
|
|
|
+ }
|
|
|
+ boolean attrNameRepeat = list.stream().anyMatch(attrNamePredicate);
|
|
|
+ boolean attrCodeRepeat = list.stream().anyMatch(attrCodePredicate);
|
|
|
+ if(attrNameRepeat) {
|
|
|
+ return ResponseStatus.fail(name + "属性名称已存在");
|
|
|
+ }
|
|
|
+ if(attrCodeRepeat) {
|
|
|
+ return ResponseStatus.fail(name + "属性编码已存在");
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
- public Boolean deleteAllById(String id, String attrBelongType, String attrType) {
|
|
|
- List<AttrInfo> attrInfos = attrService.getByParentId(id);
|
|
|
+ public Boolean deleteAllById(String id) {
|
|
|
+ //内置属性无法删除
|
|
|
+ AttrInfo attrInfo = attrService.get(id);
|
|
|
+ if(null == attrInfo) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ if(BooleanEnum.TRUE.getValue().equals(attrInfo.getBuiltIn())) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ List<AttrInfo> attrInfos = attrService.getByChildListById(id);
|
|
|
List<String> ids = attrInfos
|
|
|
.stream()
|
|
|
.map(AttrInfo::getId)
|
|
@@ -120,90 +168,223 @@ public class AttrBusinessImpl implements IAttrBusiness {
|
|
|
ids.add(id);
|
|
|
attrService.batchDeleteAttrByIds(ids);
|
|
|
//删除属性关联关系
|
|
|
- attrRelService.batchDelRelByAttr(attrBelongType, attrType, ids);
|
|
|
+ attrRelService.batchDelRelByAttr(ids);
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<AttrInfoTreeDTO> getAttrTreeList(String attrType) {
|
|
|
+ public List<AttrInfoTreeVo> getAttrTreeList(String attrSubType) {
|
|
|
Searchable searchable = Searchable.newSearchable();
|
|
|
- searchable.addSearchFilter("attrType", SearchOperator.eq, attrType);
|
|
|
+ searchable.addSearchFilter("attrSubType", SearchOperator.eq, attrSubType);
|
|
|
List<AttrInfo> list = attrService.findList(searchable);
|
|
|
Map<Boolean, List<AttrInfo>> collect = list.stream().collect(Collectors.partitioningBy(item -> StringUtils.isBlank(item.getPid())));
|
|
|
List<AttrInfo> parents = collect.get(Boolean.TRUE);
|
|
|
List<AttrInfo> childes = collect.get(Boolean.FALSE);
|
|
|
- List<AttrInfoTreeDTO> attrInfoTreeDTOS = convertToTree(parents, childes);
|
|
|
- appendParent(attrInfoTreeDTOS);
|
|
|
- return attrInfoTreeDTOS;
|
|
|
+ List<AttrInfoTreeVo> attrInfoTreeVos = convertToTree(parents, childes);
|
|
|
+ appendParent(attrInfoTreeVos);
|
|
|
+ return attrInfoTreeVos;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public Boolean relAdd(AttrRelAcceptDTO dto) {
|
|
|
- List<AttrRelInfo> relInfos = attrRelService.findRelByAttr(dto.getAttrId(),dto.getAttrBelongType(),dto.getAttrType());
|
|
|
- List<String> relExtIds = relInfos.stream().map(AttrRelInfo::getRelId).collect(Collectors.toList());
|
|
|
- List<String> relAddIds = dto.getRelIds();
|
|
|
+ public Boolean relAdd(AttrRelAcceptVo vo) {
|
|
|
+ AttrInfo attrInfo = attrService.get(vo.getAttrId());
|
|
|
+ if(null == attrInfo) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ List<RelAcceptVo> relList = vo.getRelList();
|
|
|
//判断新增和删除
|
|
|
- List<String> addList = relAddIds.stream().filter(item -> !relExtIds.contains(item)).distinct().collect(Collectors.toList());
|
|
|
- List<AttrRelInfo> delList = relInfos.stream().filter(item -> !relAddIds.contains(item.getRelId())).collect(Collectors.toList());
|
|
|
- List<AttrRelInfo> attrRelInfos = addList.stream().map(item -> {
|
|
|
+ List<AttrRelInfo> attrRelInfos = relList.stream().map(item -> {
|
|
|
AttrRelInfo attrRelInfo = new AttrRelInfo();
|
|
|
- attrRelInfo.setAttrBelongType(dto.getAttrBelongType());
|
|
|
- attrRelInfo.setAttrType(dto.getAttrType());
|
|
|
- attrRelInfo.setAttrId(dto.getAttrId());
|
|
|
- attrRelInfo.setRelId(item);
|
|
|
+ attrRelInfo.setAttrType(attrInfo.getType());
|
|
|
+ attrRelInfo.setAttrId(vo.getAttrId());
|
|
|
+ attrRelInfo.setRelId(item.getId());
|
|
|
+ attrRelInfo.setRelCode(item.getCode());
|
|
|
return attrRelInfo;
|
|
|
}).collect(Collectors.toList());
|
|
|
if(CollectionUtils.isNotEmpty(attrRelInfos)){
|
|
|
attrRelService.batchSave(attrRelInfos);
|
|
|
}
|
|
|
- if(CollectionUtils.isNotEmpty(delList)){
|
|
|
- attrRelService.batchDelete(delList);
|
|
|
- }
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<String> attrRelToIds(String attrId, String attrType, String attrBelongType) {
|
|
|
- List<AttrRelInfo> relInfos = attrRelService.findRelByAttr(attrId, attrBelongType, attrType);
|
|
|
- return relInfos.stream().map(AttrRelInfo::getRelId).distinct().collect(Collectors.toList());
|
|
|
+ public Page<ApplyInfoRelVo> relAppPage(RelSearchDTO dto) {
|
|
|
+ PageImpl<ApplyInfoRelVo> emptyPage = new PageImpl<ApplyInfoRelVo>(ListUtils.EMPTY_LIST, PageRequest.of(dto.getPage(), dto.getSize()), 0L);
|
|
|
+ List<AttrRelInfo> relInfos = attrRelService.findRelByAttr(dto.getAttrId());
|
|
|
+ Map<String, String> map = relInfos.stream().collect(Collectors.toMap(AttrRelInfo::getRelId, AttrRelInfo::getId, (oldOne, lastOne) -> lastOne));
|
|
|
+ List<String> appIds = new ArrayList<>(map.keySet());
|
|
|
+ if(CollectionUtils.isEmpty(appIds)) {
|
|
|
+ return emptyPage;
|
|
|
+ }
|
|
|
+ Searchable searchable = Searchable.newSearchable();
|
|
|
+ String name = dto.getName();
|
|
|
+ String code = dto.getCode();
|
|
|
+ String status = dto.getStatus();
|
|
|
+ String appId = dto.getId();
|
|
|
+ if(StringUtils.isNotBlank(appId)) {
|
|
|
+ if (!appIds.contains(appId)) {
|
|
|
+ return emptyPage;
|
|
|
+ }
|
|
|
+ searchable.addSearchFilter("id", SearchOperator.eq, appId);
|
|
|
+ } else {
|
|
|
+ searchable.addSearchFilter("id", SearchOperator.in, appIds);
|
|
|
+ }
|
|
|
+ if(StringUtils.isNotBlank(name)) {
|
|
|
+ searchable.addSearchFilter("apply_name", SearchOperator.like, name);
|
|
|
+ }
|
|
|
+ if(StringUtils.isNotBlank(code)) {
|
|
|
+ searchable.addSearchFilter("apply_code", SearchOperator.like, code);
|
|
|
+ }
|
|
|
+ if(StringUtils.isNotBlank(status)) {
|
|
|
+ searchable.addSearchFilter("apply_status", SearchOperator.eq, status);
|
|
|
+ }
|
|
|
+ searchable.addSearchFilter("deleted", SearchOperator.eq, BooleanEnum.FALSE.value);
|
|
|
+ searchable.setPage(dto.getPage(),dto.getSize());
|
|
|
+ Page<ApplyInfo> page = applyInfoFacade.findApplyList(searchable.toSearchDTO());
|
|
|
+ List<ApplyInfo> content = page.getContent();
|
|
|
+ List<ApplyInfoRelVo> applyInfoVos = content.stream().map(e -> {
|
|
|
+ ApplyInfoRelVo vo = new ApplyInfoRelVo();
|
|
|
+ BeanUtils.copyProperties(e, vo);
|
|
|
+ String attrRelId = map.get(e.getId());
|
|
|
+ vo.setAttrRelId(attrRelId);
|
|
|
+ return vo;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ return new PageImpl<>(applyInfoVos, page.getPageable(), page.getTotalElements());
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public Page<ApplyInfo> relAppPage(RelSearchDTO dto) {
|
|
|
- List<AttrRelInfo> relInfos = attrRelService.findRelByAttr(dto.getAttrId(), dto.getAttrBelongType(), dto.getAttrType());
|
|
|
+ public Page<ApplyInfoVo> notRelAppPage(RelSearchDTO dto) {
|
|
|
+ List<AttrRelInfo> relInfos = attrRelService.findRelByAttr(dto.getAttrId());
|
|
|
List<String> appIds = relInfos.stream().map(AttrRelInfo::getRelId).distinct().collect(Collectors.toList());
|
|
|
- if(CollectionUtils.isEmpty(appIds)) {
|
|
|
- return new PageImpl<>(new ArrayList<>(), PageRequest.of(dto.getPage(),dto.getSize()),0L);
|
|
|
- }
|
|
|
Searchable searchable = Searchable.newSearchable();
|
|
|
String name = dto.getName();
|
|
|
String code = dto.getCode();
|
|
|
String status = dto.getStatus();
|
|
|
+ String appId = dto.getId();
|
|
|
+ if(StringUtils.isNotBlank(appId)) {
|
|
|
+ if(appIds.contains(appId)) {
|
|
|
+ return new PageImpl<ApplyInfoVo>(ListUtils.EMPTY_LIST, PageRequest.of(dto.getPage(), dto.getSize()), 0L);
|
|
|
+ }
|
|
|
+ searchable.addSearchFilter("id", SearchOperator.eq, appId);
|
|
|
+ } else {
|
|
|
+ if(CollectionUtils.isNotEmpty(appIds)) {
|
|
|
+ searchable.addSearchFilter("id", SearchOperator.notIn, appIds);
|
|
|
+ }
|
|
|
+ }
|
|
|
if(StringUtils.isNotBlank(name)) {
|
|
|
searchable.addSearchFilter("apply_name", SearchOperator.like, name);
|
|
|
}
|
|
|
if(StringUtils.isNotBlank(code)) {
|
|
|
- searchable.addSearchFilter("apply_code", SearchOperator.eq, code);
|
|
|
+ searchable.addSearchFilter("apply_code", SearchOperator.like, code);
|
|
|
}
|
|
|
if(StringUtils.isNotBlank(status)) {
|
|
|
searchable.addSearchFilter("apply_status", SearchOperator.eq, status);
|
|
|
}
|
|
|
- searchable.addSearchFilter("id", SearchOperator.in, appIds);
|
|
|
searchable.addSearchFilter("deleted", SearchOperator.eq, BooleanEnum.FALSE.value);
|
|
|
searchable.setPage(dto.getPage(),dto.getSize());
|
|
|
- return applyInfoFacade.findApplyList(searchable.toSearchDTO());
|
|
|
+ Page<ApplyInfo> page = applyInfoFacade.findApplyList(searchable.toSearchDTO());
|
|
|
+ List<ApplyInfo> content = page.getContent();
|
|
|
+ List<ApplyInfoVo> applyInfoVos = content.stream().map(e -> {
|
|
|
+ ApplyInfoVo applyInfoVo = new ApplyInfoVo();
|
|
|
+ BeanUtils.copyProperties(e, applyInfoVo);
|
|
|
+ return applyInfoVo;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ return new PageImpl<>(applyInfoVos, page.getPageable(), page.getTotalElements());
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Page<ServiceRelVo> relServicePage(ServiceRelSearchDTO dto) {
|
|
|
+ List<AttrRelInfo> relInfos = attrRelService.findRelByAttr(dto.getAttrId());
|
|
|
+ Map<String, String> map = relInfos.stream().collect(Collectors.toMap(AttrRelInfo::getRelId, AttrRelInfo::getId, (oldOne, lastOne) -> lastOne));
|
|
|
+ List<String> serviceIds = new ArrayList<>(map.keySet());
|
|
|
+ if(CollectionUtils.isEmpty(serviceIds)) {
|
|
|
+ return new PageImpl<>(new ArrayList<>(), PageRequest.of(dto.getPage(),dto.getSize()),0L);
|
|
|
+ }
|
|
|
+ Searchable searchable = Searchable.newSearchable();
|
|
|
+ String name = dto.getName();
|
|
|
+ String code = dto.getCode();
|
|
|
+ String status = dto.getStatus();
|
|
|
+ String appCode = dto.getAppCode();
|
|
|
+ if(StringUtils.isNotBlank(name)) {
|
|
|
+ searchable.addSearchFilter("service_name", SearchOperator.like, name);
|
|
|
+ }
|
|
|
+ if(StringUtils.isNotBlank(code)) {
|
|
|
+ searchable.addSearchFilter("service_code", SearchOperator.like, code);
|
|
|
+ }
|
|
|
+ if(StringUtils.isNotBlank(status)) {
|
|
|
+ searchable.addSearchFilter("service_status", SearchOperator.eq, status);
|
|
|
+ }
|
|
|
+ if(StringUtils.isNotBlank(appCode)) {
|
|
|
+ searchable.addSearchFilter("app_code", SearchOperator.eq, appCode);
|
|
|
+ }
|
|
|
+
|
|
|
+ searchable.addSearchFilter("id", SearchOperator.in, serviceIds);
|
|
|
+ searchable.addSearchFilter("deleted", SearchOperator.eq, BooleanEnum.FALSE.value);
|
|
|
+ searchable.setPage(dto.getPage(),dto.getSize());
|
|
|
+ Page<com.dragoninfo.dcuc.app.vo.ServiceResourceVo> page = serviceResourceFacade.page(searchable.toSearchDTO());
|
|
|
+ List<com.dragoninfo.dcuc.app.vo.ServiceResourceVo> content = page.getContent();
|
|
|
+ List<ServiceRelVo> collect = content.stream().map(e -> {
|
|
|
+ ServiceRelVo vo = new ServiceRelVo();
|
|
|
+ BeanUtils.copyProperties(e, vo);
|
|
|
+ String attrRelId = map.get(e.getId());
|
|
|
+ vo.setAttrRelId(attrRelId);
|
|
|
+ return vo;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ return new PageImpl<>(collect, page.getPageable(), page.getTotalElements());
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Page<ServiceResourceVo> notRelServicePage(ServiceRelSearchDTO dto) {
|
|
|
+ List<AttrRelInfo> relInfos = attrRelService.findRelByAttr(dto.getAttrId());
|
|
|
+ List<String> serviceIds = relInfos.stream().map(AttrRelInfo::getRelId).distinct().collect(Collectors.toList());
|
|
|
+ Searchable searchable = Searchable.newSearchable();
|
|
|
+ String name = dto.getName();
|
|
|
+ String code = dto.getCode();
|
|
|
+ String status = dto.getStatus();
|
|
|
+ String appCode = dto.getAppCode();
|
|
|
+ if(StringUtils.isNotBlank(name)) {
|
|
|
+ searchable.addSearchFilter("service_name", SearchOperator.like, name);
|
|
|
+ }
|
|
|
+ if(StringUtils.isNotBlank(code)) {
|
|
|
+ searchable.addSearchFilter("service_code", SearchOperator.like, code);
|
|
|
+ }
|
|
|
+ if(StringUtils.isNotBlank(status)) {
|
|
|
+ searchable.addSearchFilter("service_status", SearchOperator.eq, status);
|
|
|
+ }
|
|
|
+ if(StringUtils.isNotBlank(appCode)) {
|
|
|
+ searchable.addSearchFilter("app_code", SearchOperator.eq, appCode);
|
|
|
+ }
|
|
|
+ if(CollectionUtils.isNotEmpty(serviceIds)) {
|
|
|
+ searchable.addSearchFilter("id", SearchOperator.notIn, serviceIds);
|
|
|
+ }
|
|
|
+ searchable.addSearchFilter("deleted", SearchOperator.eq, BooleanEnum.FALSE.value);
|
|
|
+ searchable.setPage(dto.getPage(),dto.getSize());
|
|
|
+ Page<com.dragoninfo.dcuc.app.vo.ServiceResourceVo> page = serviceResourceFacade.page(searchable.toSearchDTO());
|
|
|
+ List<com.dragoninfo.dcuc.app.vo.ServiceResourceVo> content = page.getContent();
|
|
|
+ List<ServiceResourceVo> collect = content.stream().map(e -> {
|
|
|
+ ServiceResourceVo vo = new ServiceResourceVo();
|
|
|
+ BeanUtils.copyProperties(e, vo);
|
|
|
+ return vo;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ return new PageImpl<>(collect, page.getPageable(), page.getTotalElements());
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Boolean delAttrRelResource(String attrRelId) {
|
|
|
+ attrRelService.deleteById(attrRelId);
|
|
|
+ return true;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 树结构dto拼接pid和pName
|
|
|
- * @param attrInfoTreeDTOS
|
|
|
+ * @param attrInfoTrees
|
|
|
*/
|
|
|
- private void appendParent(List<AttrInfoTreeDTO> attrInfoTreeDTOS) {
|
|
|
- for (AttrInfoTreeDTO attrInfoTreeDTO : attrInfoTreeDTOS) {
|
|
|
- String id = attrInfoTreeDTO.getId();
|
|
|
- String name = attrInfoTreeDTO.getName();
|
|
|
- String pid = attrInfoTreeDTO.getPid();
|
|
|
- String pName = attrInfoTreeDTO.getPName();
|
|
|
+ private void appendParent(List<AttrInfoTreeVo> attrInfoTrees) {
|
|
|
+ for (AttrInfoTreeVo treeVo : attrInfoTrees) {
|
|
|
+ String id = treeVo.getId();
|
|
|
+ String name = treeVo.getName();
|
|
|
+ String pid = treeVo.getPid();
|
|
|
+ String pName = treeVo.getPName();
|
|
|
if(StringUtils.isNotBlank(pid)) {
|
|
|
pid = pid + CommonCons.PATH_SEP + id;
|
|
|
} else {
|
|
@@ -215,9 +396,9 @@ public class AttrBusinessImpl implements IAttrBusiness {
|
|
|
} else {
|
|
|
pName = name;
|
|
|
}
|
|
|
- List<AttrInfoTreeDTO> childes = attrInfoTreeDTO.getChild();
|
|
|
+ List<AttrInfoTreeVo> childes = treeVo.getChild();
|
|
|
if(CollectionUtils.isNotEmpty(childes)) {
|
|
|
- for (AttrInfoTreeDTO child : childes) {
|
|
|
+ for (AttrInfoTreeVo child : childes) {
|
|
|
child.setPid(pid);
|
|
|
child.setPName(pName);
|
|
|
}
|
|
@@ -232,50 +413,85 @@ public class AttrBusinessImpl implements IAttrBusiness {
|
|
|
* @param childes
|
|
|
* @return
|
|
|
*/
|
|
|
- private List<AttrInfoTreeDTO> convertToTree(List<AttrInfo> parents, List<AttrInfo> childes) {
|
|
|
+ private List<AttrInfoTreeVo> convertToTree(List<AttrInfo> parents, List<AttrInfo> childes) {
|
|
|
Map<String, List<AttrInfo>> childMap = Optional.ofNullable(childes).orElse(new ArrayList<>())
|
|
|
.stream()
|
|
|
.collect(Collectors.groupingBy(AttrInfo::getPid));
|
|
|
- ArrayList<AttrInfoTreeDTO> dtoParentList = new ArrayList<>();
|
|
|
+ ArrayList<AttrInfoTreeVo> dtoParentList = new ArrayList<>();
|
|
|
for (AttrInfo parent : parents) {
|
|
|
- AttrInfoTreeDTO dto = new AttrInfoTreeDTO();
|
|
|
+ AttrInfoTreeVo dto = new AttrInfoTreeVo();
|
|
|
BeanUtils.copyProperties(parent, dto);
|
|
|
String parentId = parent.getId();
|
|
|
List<AttrInfo> list = childMap.get(parentId);
|
|
|
if(CollectionUtils.isNotEmpty(list)) {
|
|
|
//把子类构造成树
|
|
|
- List<AttrInfoTreeDTO> childDTOs = convertToTree(list, childes);
|
|
|
- dto.setChild(childDTOs);
|
|
|
+ List<AttrInfoTreeVo> childVos = convertToTree(list, childes);
|
|
|
+ dto.setChild(childVos);
|
|
|
}
|
|
|
dtoParentList.add(dto);
|
|
|
}
|
|
|
return dtoParentList;
|
|
|
}
|
|
|
|
|
|
- private void batchDeleteAttr(String attrBelongType, String attrType, List<String> deleteIdList) {
|
|
|
+ private void batchDeleteAttr(List<String> deleteIdList) {
|
|
|
attrService.batchDeleteAttrByIds(deleteIdList);
|
|
|
//根据attrId、attrType删除属性关联关系
|
|
|
- attrRelService.batchDelRelByAttr(attrBelongType, attrType, deleteIdList);
|
|
|
+ attrRelService.batchDelRelByAttr(deleteIdList);
|
|
|
}
|
|
|
|
|
|
- private void batchUpdateAttr(List<AttrInfoTreeDTO> updateList) {
|
|
|
- List<AttrInfo> infoList = new ArrayList<>();
|
|
|
- for (AttrInfoTreeDTO dto : updateList) {
|
|
|
- AttrInfo attrInfo = new AttrInfo();
|
|
|
- BeanUtils.copyProperties(dto,attrInfo);
|
|
|
- infoList.add(attrInfo);
|
|
|
+ /**
|
|
|
+ * 主客体属性提交后更新name、code、type和ptype
|
|
|
+ * @param parent
|
|
|
+ * @param lastName
|
|
|
+ * @param lastCode
|
|
|
+ * @param updateList
|
|
|
+ * @param existChild
|
|
|
+ */
|
|
|
+ private void batchUpdateAttr(AttrInfo parent, String lastName, String lastCode,
|
|
|
+ List<AttrInfoAddBaseVo> updateList, List<AttrInfo> existChild) {
|
|
|
+ String ptype = parent.getPtype() + CommonCons.PATH_SEP + lastCode;
|
|
|
+ Map<String, AttrInfoAddBaseVo> idMap = updateList
|
|
|
+ .stream()
|
|
|
+ .collect(Collectors.toMap(AttrInfoAddBaseVo::getId, e -> e));
|
|
|
+ List<AttrInfo> collect = existChild.stream().filter(e -> {
|
|
|
+ AttrInfoAddBaseVo vo = idMap.get(e.getId());
|
|
|
+ if(null == vo) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ if (!e.getPtype().equals(ptype)) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ return !vo.getCode().equals(e.getCode()) || !vo.getName().equals(e.getName());
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ collect.forEach(e->{
|
|
|
+ AttrInfoAddBaseVo vo = idMap.get(e.getId());
|
|
|
+ String code = vo.getCode();
|
|
|
+ String type = ptype + CommonCons.PATH_SEP + code;
|
|
|
+ e.setName(vo.getName());
|
|
|
+ e.setCode(code);
|
|
|
+ e.setType(type);
|
|
|
+ e.setPtype(ptype);
|
|
|
+ });
|
|
|
+ if(!lastCode.equals(parent.getCode()) || !lastName.equals(parent.getName())) {
|
|
|
+ parent.setName(lastName);
|
|
|
+ parent.setCode(lastCode);
|
|
|
+ parent.setType(ptype);
|
|
|
+ collect.add(parent);
|
|
|
}
|
|
|
- attrService.batchUpdate(infoList);
|
|
|
+ attrService.batchUpdateNameCode(collect);
|
|
|
}
|
|
|
|
|
|
- private void batchSaveChild(AttrInfo parent, List<AttrInfoTreeDTO> addList) {
|
|
|
+ private void batchSaveChild(AttrInfo parent, List<AttrInfoAddBaseVo> addList) {
|
|
|
+ String ptype = parent.getType() + CommonCons.PATH_SEP;
|
|
|
List<AttrInfo> infoList = new ArrayList<>();
|
|
|
- for (AttrInfoTreeDTO dto : addList) {
|
|
|
+ for (AttrInfoAddBaseVo dto : addList) {
|
|
|
AttrInfo attrInfo = new AttrInfo();
|
|
|
- BeanUtils.copyProperties(dto,attrInfo);
|
|
|
- attrInfo.setAttrType(parent.getAttrType());
|
|
|
- attrInfo.setAttrBelongType(parent.getAttrBelongType());
|
|
|
+ attrInfo.setType(ptype + dto.getCode());
|
|
|
+ attrInfo.setAttrSubType(parent.getAttrSubType());
|
|
|
+ attrInfo.setPtype(parent.getType());
|
|
|
attrInfo.setPid(parent.getId());
|
|
|
+ attrInfo.setName(dto.getName());
|
|
|
+ attrInfo.setCode(dto.getCode());
|
|
|
infoList.add(attrInfo);
|
|
|
}
|
|
|
attrService.batchSave(infoList);
|