From 85392df07800b588675211549d6bf90cff10e0ee Mon Sep 17 00:00:00 2001
From: xiangpei <xiangpei@timesnew.cn>
Date: 星期六, 31 八月 2024 17:43:52 +0800
Subject: [PATCH] 平台调整优化
---
ycl-server/src/main/java/com/ycl/platform/service/impl/PlatformServiceImpl.java | 41 +++++++++++++++++++++++++++++++----------
1 files changed, 31 insertions(+), 10 deletions(-)
diff --git a/ycl-server/src/main/java/com/ycl/platform/service/impl/PlatformServiceImpl.java b/ycl-server/src/main/java/com/ycl/platform/service/impl/PlatformServiceImpl.java
index 3f33e78..4f9937c 100644
--- a/ycl-server/src/main/java/com/ycl/platform/service/impl/PlatformServiceImpl.java
+++ b/ycl-server/src/main/java/com/ycl/platform/service/impl/PlatformServiceImpl.java
@@ -10,7 +10,11 @@
import com.ycl.platform.mapper.PlatformMapper;
import com.ycl.platform.service.PlatformService;
import com.ycl.system.Result;
+import com.ycl.system.entity.SysDictData;
import com.ycl.system.page.PageUtil;
+import com.ycl.system.service.ISysDictTypeService;
+import com.ycl.system.service.impl.SysDictDataServiceImpl;
+import com.ycl.system.service.impl.SysDictTypeServiceImpl;
import org.ehcache.core.util.CollectionUtil;
import org.springframework.stereotype.Service;
import lombok.RequiredArgsConstructor;
@@ -18,10 +22,12 @@
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils;
+import org.springframework.util.StringUtils;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
+import java.util.Map;
import java.util.stream.Collectors;
/**
@@ -35,6 +41,8 @@
public class PlatformServiceImpl extends ServiceImpl<PlatformMapper, Platform> implements PlatformService {
private final PlatformMapper platformMapper;
+ private final SysDictDataServiceImpl dictDataService;
+ private final ISysDictTypeService dictTypeService;
/**
* 娣诲姞
@@ -49,7 +57,8 @@
Date now = new Date();
entity.setCreateTime(now);
entity.setUpdateTime(now);
- entity.setArea(form.getAreaList().stream().collect(Collectors.joining(",")));
+ String area = form.getAreaList().stream().collect(Collectors.joining(","));
+ entity.setArea(area);
baseMapper.insert(entity);
// if (! CollectionUtils.isEmpty(form.getDeployList())) {
// List<Platform> childList = form.getDeployList().stream().map(deploy -> {
@@ -78,6 +87,8 @@
// 涓虹┖鎶汭llegalArgumentException锛屽仛鍏ㄥ眬寮傚父澶勭悊
Assert.notNull(entity, "璁板綍涓嶅瓨鍦�");
BeanUtils.copyProperties(form, entity);
+ String area = form.getAreaList().stream().collect(Collectors.joining(","));
+ entity.setArea(area);
baseMapper.updateById(entity);
return Result.ok("淇敼鎴愬姛");
}
@@ -112,17 +123,27 @@
@Override
public Result page(PlatformQuery query) {
List<PlatformVO> list = baseMapper.getPage(query);
- List<PlatformVO> parentList = list.stream().filter(item -> item.getParentId() == 0).collect(Collectors.toList());
- List<PlatformVO> resultList = new ArrayList<>(4);
- for (PlatformVO parent : parentList) {
- List<PlatformVO> childList = list.stream().filter(item -> item.getParentId().equals(parent.getId())).collect(Collectors.toList());
-
- parent.setChildNum(childList.size());
- resultList.add(parent);
- resultList.addAll(childList);
+// List<PlatformVO> parentList = list.stream().filter(item -> item.getParentId() == 0).collect(Collectors.toList());
+ List<SysDictData> areaCodeList = dictTypeService.selectDictDataByType("area_code");
+ Map<String, String> dictMap = areaCodeList.stream().collect(Collectors.toMap(SysDictData::getDictValue, SysDictData::getDictLabel));
+ for (PlatformVO platform : list) {
+ String[] areaList = platform.getArea().split(",");
+ List<String> areas = new ArrayList<>();
+ for (String s : areaList) {
+ String label = dictMap.get(s);
+ if (StringUtils.hasText(label)) {
+ areas.add(label);
+ }
+ }
+ platform.setArea(areas.stream().collect(Collectors.joining("銆�")));
+// List<PlatformVO> childList = list.stream().filter(item -> item.getParentId().equals(parent.getId())).collect(Collectors.toList());
+//
+// parent.setChildNum(childList.size());
+// resultList.add(parent);
+// resultList.addAll(childList);
}
// 鍓嶇涓嶇敤灞曠ず鍒嗛〉
- return Result.ok().data(resultList).total(0);
+ return Result.ok().data(list).total(0);
}
/**
--
Gitblit v1.8.0