20200706-zlp-1
主题整合学习
This commit is contained in:
@ -5,6 +5,7 @@ import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.ruoyi.project.benyi.domain.ByDayFlowDetail;
|
||||
import com.ruoyi.project.benyi.domain.ByTheme;
|
||||
import com.ruoyi.project.system.domain.SysDept;
|
||||
import com.ruoyi.project.system.domain.SysMenu;
|
||||
|
||||
@ -50,6 +51,14 @@ public class TreeSelect implements Serializable
|
||||
this.children = byDayFlowDetail.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
//下拉树构造器
|
||||
public TreeSelect(ByTheme bytheme) {
|
||||
|
||||
this.id = bytheme.getId();
|
||||
this.label = bytheme.getName();
|
||||
this.children = bytheme.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public Long getId()
|
||||
{
|
||||
return id;
|
||||
|
@ -44,6 +44,15 @@ public class ByThemeController extends BaseController {
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取部门下拉树列表
|
||||
*/
|
||||
@GetMapping("/treeselect")
|
||||
public AjaxResult treeselect(ByTheme byTheme) {
|
||||
List<ByTheme> byThemeDetails = byThemeService.selectByThemeListTree(byTheme);
|
||||
return AjaxResult.success(byThemeService.buildThemeTreeSelect(byThemeDetails));
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出主题整合列表
|
||||
*/
|
||||
|
@ -5,6 +5,9 @@ import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import com.ruoyi.framework.aspectj.lang.annotation.Excel;
|
||||
import com.ruoyi.framework.web.domain.BaseEntity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 主题整合对象 by_theme
|
||||
*
|
||||
@ -43,6 +46,12 @@ public class ByTheme extends BaseEntity {
|
||||
@Excel(name = "适用班级")
|
||||
private String classid;
|
||||
|
||||
/** 树状父类ID */
|
||||
private Long parentId;
|
||||
|
||||
/** 树状子类 */
|
||||
private List<ByTheme> children = new ArrayList<ByTheme>();
|
||||
|
||||
/**
|
||||
* 序号
|
||||
*/
|
||||
@ -97,6 +106,22 @@ public class ByTheme extends BaseEntity {
|
||||
return sort;
|
||||
}
|
||||
|
||||
public Long getParentId() {
|
||||
return parentId;
|
||||
}
|
||||
|
||||
public void setParentId(Long parentId) {
|
||||
this.parentId = parentId;
|
||||
}
|
||||
|
||||
public List<ByTheme> getChildren() {
|
||||
return children;
|
||||
}
|
||||
|
||||
public void setChildren(List<ByTheme> children) {
|
||||
this.children = children;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
|
||||
@ -107,6 +132,7 @@ public class ByTheme extends BaseEntity {
|
||||
.append("classid", getClassid())
|
||||
.append("sort", getSort())
|
||||
.append("createTime", getCreateTime())
|
||||
.append("parentid", getParentId())
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
@ -27,6 +27,14 @@ public interface ByThemeMapper {
|
||||
*/
|
||||
public List<ByTheme> selectByThemeList(ByTheme byTheme);
|
||||
|
||||
/**
|
||||
* 查询一日流程树
|
||||
*
|
||||
* @param byTheme 一日流程
|
||||
* @return 一日流程树集合
|
||||
*/
|
||||
public List<ByTheme> selectByThemeListTree(ByTheme byTheme);
|
||||
|
||||
/**
|
||||
* 新增主题整合
|
||||
*
|
||||
|
@ -2,6 +2,7 @@ package com.ruoyi.project.benyi.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.ruoyi.framework.web.domain.TreeSelect;
|
||||
import com.ruoyi.project.benyi.domain.ByTheme;
|
||||
|
||||
/**
|
||||
@ -27,6 +28,30 @@ public interface IByThemeService {
|
||||
*/
|
||||
public List<ByTheme> selectByThemeList(ByTheme byTheme);
|
||||
|
||||
/**
|
||||
* 查询一日流程列表树
|
||||
*
|
||||
* @param byTheme 一日流程
|
||||
* @return 一日流程树集合
|
||||
*/
|
||||
public List<ByTheme> selectByThemeListTree(ByTheme byTheme);
|
||||
|
||||
/**
|
||||
* 构建前端所需要树结构
|
||||
*
|
||||
* @param byThemes 部门列表
|
||||
* @return 树结构列表
|
||||
*/
|
||||
public List<ByTheme> buildThemeDetailTree(List<ByTheme> byThemes);
|
||||
|
||||
/**
|
||||
* 构建前端所需要下拉树结构
|
||||
*
|
||||
* @param byThemes 部门列表
|
||||
* @return 下拉树结构列表
|
||||
*/
|
||||
public List<TreeSelect> buildThemeTreeSelect(List<ByTheme> byThemes);
|
||||
|
||||
/**
|
||||
* 新增主题整合
|
||||
*
|
||||
|
@ -1,8 +1,13 @@
|
||||
package com.ruoyi.project.benyi.service.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.framework.web.domain.TreeSelect;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.ruoyi.project.benyi.mapper.ByThemeMapper;
|
||||
@ -42,6 +47,100 @@ public class ByThemeServiceImpl implements IByThemeService {
|
||||
return byThemeMapper.selectByThemeList(byTheme);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询一日流程列表树
|
||||
*
|
||||
* @param byTheme 一日流程
|
||||
* @return 一日流程树集合
|
||||
*/
|
||||
@Override
|
||||
public List<ByTheme> selectByThemeListTree(ByTheme byTheme) {
|
||||
return byThemeMapper.selectByThemeListTree(byTheme);
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建前端所需要树结构
|
||||
*
|
||||
* @param byThemes 部门列表
|
||||
* @return 树结构列表
|
||||
*/
|
||||
@Override
|
||||
public List<ByTheme> buildThemeDetailTree(List<ByTheme> byThemes) {
|
||||
//System.out.println("start---");
|
||||
List<ByTheme> returnList = new ArrayList<ByTheme>();
|
||||
List<Long> tempList = new ArrayList<Long>();
|
||||
for (ByTheme item : byThemes) {
|
||||
tempList.add(item.getId());
|
||||
}
|
||||
for (Iterator<ByTheme> iterator = byThemes.iterator(); iterator.hasNext(); ) {
|
||||
ByTheme item = (ByTheme) iterator.next();
|
||||
//System.out.println("test==="+!tempList.contains(byDayFlowDetail.getParentId()));
|
||||
// 如果是顶级节点, 遍历该父节点的所有子节点
|
||||
if (!tempList.contains(item.getParentId())) {
|
||||
recursionFn(byThemes, item);
|
||||
returnList.add(item);
|
||||
}
|
||||
}
|
||||
if (returnList.isEmpty()) {
|
||||
returnList = byThemes;
|
||||
}
|
||||
return returnList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建前端所需要下拉树结构
|
||||
*
|
||||
* @param byThemes 部门列表
|
||||
* @return 下拉树结构列表
|
||||
*/
|
||||
@Override
|
||||
public List<TreeSelect> buildThemeTreeSelect(List<ByTheme> byThemes) {
|
||||
List<ByTheme> byThemeTrees = buildThemeDetailTree(byThemes);
|
||||
return byThemeTrees.stream().map(TreeSelect::new).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 递归列表
|
||||
*/
|
||||
private void recursionFn(List<ByTheme> list, ByTheme t) {
|
||||
// 得到子节点列表
|
||||
List<ByTheme> childList = getChildList(list, t);
|
||||
t.setChildren(childList);
|
||||
for (ByTheme tChild : childList) {
|
||||
if (hasChild(list, tChild)) {
|
||||
// 判断是否有子节点
|
||||
Iterator<ByTheme> it = childList.iterator();
|
||||
while (it.hasNext()) {
|
||||
ByTheme n = (ByTheme) it.next();
|
||||
recursionFn(list, n);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 得到子节点列表
|
||||
*/
|
||||
private List<ByTheme> getChildList(List<ByTheme> list, ByTheme t) {
|
||||
List<ByTheme> tlist = new ArrayList<ByTheme>();
|
||||
Iterator<ByTheme> it = list.iterator();
|
||||
while (it.hasNext()) {
|
||||
ByTheme n = (ByTheme) it.next();
|
||||
if (StringUtils.isNotNull(n.getParentId()) && n.getParentId().longValue() == t.getId().longValue()) {
|
||||
//System.out.println("parentid="+n.getParentId().longValue()+"---"+t.getId().longValue());
|
||||
tlist.add(n);
|
||||
}
|
||||
}
|
||||
return tlist;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否有子节点
|
||||
*/
|
||||
private boolean hasChild(List<ByTheme> list, ByTheme t) {
|
||||
return getChildList(list, t).size() > 0 ? true : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增主题整合
|
||||
*
|
||||
|
@ -10,6 +10,7 @@
|
||||
<result property="content" column="content"/>
|
||||
<result property="communicate" column="communicate"/>
|
||||
<result property="classid" column="classid"/>
|
||||
<result property="parentId" column="parent_id"/>
|
||||
<result property="sort" column="sort"/>
|
||||
<result property="createTime" column="create_time"/>
|
||||
</resultMap>
|
||||
@ -18,13 +19,31 @@
|
||||
select id, name, content, communicate, classid, sort, create_time from by_theme
|
||||
</sql>
|
||||
|
||||
<sql id="selectByThemeVoTree">
|
||||
select dict_value+9999 id, 0 parent_id,dict_label name,dict_sort sort from sys_dict_data where dict_type='sys_yebjlx' and dict_label !='托班(2-3岁)'
|
||||
union all
|
||||
select id, classid+9999, name, sort from by_theme
|
||||
order by sort
|
||||
</sql>
|
||||
|
||||
<select id="selectByThemeListTree" parameterType="ByTheme" resultMap="ByThemeResult">
|
||||
<include refid="selectByThemeVoTree"/>
|
||||
<where>
|
||||
<if test="name != null and name != ''">and name like concat('%', #{name}, '%')</if>
|
||||
<if test="content != null and content != ''">and content = #{content}</if>
|
||||
<if test="communicate != null and communicate != ''">and communicate = #{communicate}</if>
|
||||
<if test="classid != null and classid != ''">and classid = #{classid}</if>
|
||||
<if test="sort != null ">and sort = #{sort}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectByThemeList" parameterType="ByTheme" resultMap="ByThemeResult">
|
||||
<include refid="selectByThemeVo"/>
|
||||
<where>
|
||||
<if test="name != null and name != ''">and name like concat('%', #{name}, '%')</if>
|
||||
<if test="content != null and content != ''">and content = #{content}</if>
|
||||
<if test="communicate != null and communicate != ''">and communicate = #{communicate}</if>
|
||||
<if test="classid != null and classid != ''">and classid = #{classid}</if>
|
||||
<if test="parentId != null and parentId != ''">and parent_id = #{parentId}</if>
|
||||
<if test="sort != null ">and sort = #{sort}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
Reference in New Issue
Block a user