|
@@ -1,19 +1,29 @@
|
|
|
package com.dragoninfo.dcuc.app.service.sub.impl;
|
|
|
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
+import com.dragoninfo.dcuc.app.entity.ApplyInfo;
|
|
|
import com.dragoninfo.dcuc.app.entity.sub.AppDataResourceInfo;
|
|
|
import com.dragoninfo.dcuc.app.mapper.sub.AppDataResourceInfoMapper;
|
|
|
+import com.dragoninfo.dcuc.app.service.IApplyInfoService;
|
|
|
import com.dragoninfo.dcuc.app.service.sub.IAppDataResourceInfoService;
|
|
|
-import com.dragonsoft.duceap.commons.util.string.StringUtils;
|
|
|
+import com.dragoninfo.dcuc.app.vo.AppDataResourcePageVo;
|
|
|
+import com.dragoninfo.dcuc.common.utils.DcucBeanUtil;
|
|
|
+import com.dragoninfo.dcuc.user.entity.org.OrgInfo;
|
|
|
+import com.dragoninfo.dcuc.user.facade.org.IOrgInfoFacade;
|
|
|
import com.dragonsoft.duceap.base.entity.search.SearchDTO;
|
|
|
+import com.dragonsoft.duceap.commons.util.string.StringUtils;
|
|
|
import com.dragonsoft.duceap.core.search.Searchable;
|
|
|
+import org.apache.commons.collections4.CollectionUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.data.domain.Page;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
-import java.util.List;
|
|
|
+import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
+import java.util.stream.Stream;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
@@ -29,6 +39,12 @@ public class AppDataResourceInfoServiceImpl implements IAppDataResourceInfoServi
|
|
|
@Autowired
|
|
|
private AppDataResourceInfoMapper appDataResourceInfoMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private IApplyInfoService applyInfoService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IOrgInfoFacade orgInfoFacade;
|
|
|
+
|
|
|
@Transactional(rollbackFor = Throwable.class)
|
|
|
@Override
|
|
|
public void saveAll(List<AppDataResourceInfo> resourceInfoList) {
|
|
@@ -92,4 +108,87 @@ public class AppDataResourceInfoServiceImpl implements IAppDataResourceInfoServi
|
|
|
queryWrapper.eq(AppDataResourceInfo::getResourceCode, resourceCode);
|
|
|
return appDataResourceInfoMapper.selectOne(queryWrapper);
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<AppDataResourceInfo> getByIds(List<String> ids) {
|
|
|
+ if (CollectionUtils.isEmpty(ids)) {
|
|
|
+ return Collections.emptyList();
|
|
|
+ }
|
|
|
+ LambdaQueryWrapper<AppDataResourceInfo> query = Wrappers.lambdaQuery();
|
|
|
+ query.in(AppDataResourceInfo::getId, ids);
|
|
|
+ return appDataResourceInfoMapper.selectList(query);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Page<AppDataResourcePageVo> pageSearch(SearchDTO searchDTO) {
|
|
|
+ Searchable searchable = Searchable.toSearchable(searchDTO);
|
|
|
+ Page<AppDataResourceInfo> page = appDataResourceInfoMapper.pagingBySearchable(searchable);
|
|
|
+ Page<AppDataResourcePageVo> pageVos = DcucBeanUtil.createCopyToObjectPage(page, AppDataResourcePageVo.class, (s, t) -> {
|
|
|
+ String labelName = Stream.of(s.getDataLabelOneName(), s.getDataLabelTwoName(),
|
|
|
+ s.getDataLabelThreeName(), s.getDataLabelFourName(),
|
|
|
+ s.getDataLabelFiveName()).filter(StringUtils::isNotBlank)
|
|
|
+ .collect(Collectors.joining(StrUtil.COMMA));
|
|
|
+ t.setLabelName(labelName);
|
|
|
+ return t;
|
|
|
+ });
|
|
|
+
|
|
|
+ // 查询应用名和机构名
|
|
|
+ List<String> appCodes = pageVos.stream()
|
|
|
+ .map(AppDataResourcePageVo::getApplicationCode)
|
|
|
+ .distinct()
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ List<ApplyInfo> appInfos = applyInfoService.getListByCodes(appCodes);
|
|
|
+
|
|
|
+ Map<String, ApplyInfo> appInfoMap = appInfos.stream()
|
|
|
+ .collect(Collectors.toMap(ApplyInfo::getApplyCode, e -> e));
|
|
|
+
|
|
|
+ // 查询机构名称
|
|
|
+ Set<String> orgCodeSet = new HashSet<>();
|
|
|
+ pageVos.stream().forEach(e -> {
|
|
|
+ orgCodeSet.add(e.getManageDeptCode());
|
|
|
+ orgCodeSet.add(e.getAuthorityDeptCode());
|
|
|
+ });
|
|
|
+
|
|
|
+ List<OrgInfo> orgInfos = orgInfoFacade.getOrgsByCodes(new ArrayList<>(orgCodeSet));
|
|
|
+ Map<String, OrgInfo> orgInMap = orgInfos.stream()
|
|
|
+ .collect(Collectors.toMap(OrgInfo::getCode, e -> e));
|
|
|
+
|
|
|
+ // 设置Vo字段名称
|
|
|
+ pageVos.stream().forEach(e -> {
|
|
|
+ String appName = Optional.ofNullable(appInfoMap.get(e.getApplicationCode()))
|
|
|
+ .map(ApplyInfo::getApplyName)
|
|
|
+ .orElse(null);
|
|
|
+ e.setApplicationCodeName(appName);
|
|
|
+
|
|
|
+ String authorityDeptCode = e.getAuthorityDeptCode();
|
|
|
+ String authorityDeptName = Optional.ofNullable(orgInMap.get(authorityDeptCode))
|
|
|
+ .map(OrgInfo::getFullName)
|
|
|
+ .orElse(null);
|
|
|
+ e.setAuthorityDeptName(authorityDeptName);
|
|
|
+
|
|
|
+ String manageDeptCode = e.getManageDeptCode();
|
|
|
+ String manageDeptName = Optional.ofNullable(orgInMap.get(manageDeptCode))
|
|
|
+ .map(OrgInfo::getFullName)
|
|
|
+ .orElse(null);
|
|
|
+ e.setManageDeptName(manageDeptName);
|
|
|
+ });
|
|
|
+
|
|
|
+ return pageVos;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public AppDataResourceInfo getById(String id) {
|
|
|
+ if (StringUtils.isBlank(id)) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ return appDataResourceInfoMapper.selectById(id);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void deleteById(String id) {
|
|
|
+ if (StringUtils.isBlank(id)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ appDataResourceInfoMapper.deleteById(id);
|
|
|
+ }
|
|
|
}
|