Commit af099e2b authored by 赵啸非's avatar 赵啸非

添加批量新增窗口业务接口

parent fbbf784a
......@@ -17,6 +17,16 @@ public final class Constant {
*/
public static final String HTTP = "http://";
/**
* 站点编号分隔符
*/
public static final String SITE_SPLIT_MARK = "-";
/**
* 站点编号补零位数
*/
public static final Integer SITE_CODE_NUM = 4;
/** 基础代码版本 Z-BASE.MANAGER-S1.0.0 */
public final static String BASEMANAGER_VERSION = "Z-BASE.MANAGER-S1.0.0";
......
......@@ -75,7 +75,7 @@ public class SiteTreeSelect implements Serializable {
.collect(Collectors.toList());
if (!ObjectUtils.isEmpty(collect)) {
this.id = collect.stream().map(item -> item.getId().toString()).collect(Collectors.joining(","));
this.label = collect.stream().map(item -> item.getSiteName().toString()).collect(Collectors.joining(","));
this.label = collect.stream().map(item -> item.getSiteName()).collect(Collectors.joining(","));
this.type = "site";
this.icon = "el-icon-document";
} else {
......
......@@ -2,6 +2,9 @@ package com.mortals.xhx.module.site.service.impl;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context;
import com.mortals.framework.util.DataUtil;
import com.mortals.framework.util.StringUtils;
import com.mortals.xhx.common.key.Constant;
import com.mortals.xhx.module.area.model.AreaEntity;
import com.mortals.xhx.module.area.model.AreaQuery;
import com.mortals.xhx.module.area.model.AreaTreeSelect;
......@@ -49,22 +52,19 @@ public class SiteServiceImpl extends AbstractCRUDServiceImpl<SiteDao, SiteEntity
@Override
protected void saveBefore(SiteEntity entity, Context context) throws AppException {
List<SiteEntity> siteEntities = this.find(new SiteQuery().areaCode(entity.getAreaCode()));
entity.setSiteCode(entity.getAreaCode() + "#" + (siteEntities.size() + 1));
entity.setSiteCode(entity.getAreaCode() + Constant.SITE_SPLIT_MARK + StringUtils.lpad(siteEntities.size() + 1,Constant.SITE_CODE_NUM));
super.saveBefore(entity, context);
}
@Override
public List<SiteTreeSelect> siteTree(Context context) {
Map<String, AreaEntity> areaMap = new HashMap<>();
//查询所有已配置的站点
List<SiteEntity> siteList = this.find(new SiteQuery());
Map<String, SiteEntity> siteMap = this.find(new SiteQuery()).stream().collect(Collectors.toMap(x -> x.getSiteCode(), y -> y, (o, n) -> n));
Map<String, SiteEntity> siteMap = siteList.parallelStream().collect(Collectors.toMap(x -> x.getSiteCode(), y -> y, (o, n) -> n));
//遍历过滤站点树
for (SiteEntity siteEntity : siteList) {
String areaCode = siteEntity.getAreaCode();
AreaEntity areaEntity = areaService.getExtCache(areaCode);
AreaEntity areaEntity = areaService.getExtCache(siteEntity.getAreaCode());
//根据区域添加父节点
if (!ObjectUtils.isEmpty(areaEntity) && !ObjectUtils.isEmpty(areaEntity.getPid())) {
//递归查找父节点并添加
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment