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

添加站点参数

parent b98e35f4
......@@ -21,6 +21,7 @@ import com.mortals.xhx.module.site.model.SiteBusinessQuery;
import com.mortals.xhx.module.site.model.SiteBusinessTreeSelect;
import com.mortals.xhx.module.site.service.SiteBusinessService;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -84,9 +85,65 @@ public class SiteBusinessServiceImpl extends AbstractCRUDCacheServiceImpl<SiteBu
}
params.setIdNotList(notIdSet.stream().collect(Collectors.toList()));
}
return super.findBefore(params, pageInfo, context);
}
/**
* @param entity
* @param pageInfo
* @param context
* @return
* @throws AppException
*/
@Override
public Result<SiteBusinessEntity> find(SiteBusinessEntity entity, PageInfo pageInfo, Context context) throws AppException {
SiteBusinessEntity params = this.findBefore(entity, pageInfo, context);
Result<SiteBusinessEntity> result = this.dao.getList(params, pageInfo);
return super.findBefore(params, pageInfo, context);
List<SiteBusinessEntity> list = result.getList();
//重新内存分页
list = MemoryPagination.pagination(list, params.getSize() == -1 ? list.size() : params.getSize(), params.getPage());
if (!ObjectUtils.isEmpty(params.getIdNotList())) {
//排除掉已经存在的ids
log.info("idNotList:{}", JSON.toJSONString(params.getIdNotList()));
Iterator<SiteBusinessEntity> iterator = list.iterator();
while (iterator.hasNext()) {
SiteBusinessQuery siteBusinessQuery = new SiteBusinessQuery();
SiteBusinessEntity item = iterator.next();
siteBusinessQuery.siteId(item.getSiteId());
siteBusinessQuery.setParentId(item.getBusinessId());
int count = this.count(siteBusinessQuery, context);
if (count > 0) {
siteBusinessQuery.setIdNotList(params.getIdNotList());
List<SiteBusinessEntity> childs = this.find(siteBusinessQuery);
if (ObjectUtils.isEmpty(childs)) {
//子节点已经全部选中,删除父节点
iterator.remove();
pageInfo.setTotalResult(pageInfo.getTotalResult() - 1);
} else {
childs.stream().forEach(item1 -> {
buildChildBusiness(item1);
});
item.setChildren(childs);
}
}
buildChildBusiness(item);
}
} else {
list.stream().peek(item -> {
SiteBusinessQuery siteBusinessQuery = new SiteBusinessQuery();
List<SiteBusinessEntity> childs = this.find(siteBusinessQuery.siteId(item.getSiteId()).parentId(item.getBusinessId()));
childs.stream().forEach(item1 -> {
buildChildBusiness(item1);
});
item.setChildren(childs);
buildChildBusiness(item);
}).count();
}
result.setList(list);
// this.findAfter(entity, pageInfo, context, result.getList());
return result;
}
@Override
......
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