Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -178,6 +178,13 @@ public class SysDictItem implements TreeNode {
|
||||
@TableField(exist = false)
|
||||
private List<SysDictItem> childrenList;
|
||||
|
||||
/**
|
||||
* 是否还有子集
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
@ApiModelProperty(value = "是否还有子集")
|
||||
private boolean hasChild;
|
||||
|
||||
@Override
|
||||
public String obtainTreeNodeId() {
|
||||
return id;
|
||||
|
||||
+7
-1
@@ -40,11 +40,17 @@ public class InConditionImpl extends AbstractConditionBase {
|
||||
}
|
||||
}
|
||||
for (String s : list) {
|
||||
in.append("find_in_set('").append(s).append("', ").append(fieldName).append(") > 0");
|
||||
in.append(DocumentSplitCommon.INSTR_BEGIN).append(fieldName).append(",").append("'").append(s).append("'").append(")");
|
||||
if (list.indexOf(s) != list.size() -1){
|
||||
in.append(DocumentSplitCommon.OR);
|
||||
}
|
||||
}
|
||||
// for (String s : list) {
|
||||
// in.append("find_in_set('").append(s).append("', ").append(fieldName).append(") > 0");
|
||||
// if (list.indexOf(s) != list.size() -1){
|
||||
// in.append(DocumentSplitCommon.OR);
|
||||
// }
|
||||
// }
|
||||
in.append("))");
|
||||
return in.toString();
|
||||
}
|
||||
|
||||
+12
-10
@@ -29,29 +29,31 @@ public class LawsDictTreeController {
|
||||
private DictTreeService dictTreeService;
|
||||
|
||||
@AutoLog(value = "树形结构-获取一级树")
|
||||
@ApiOperation(value = "树形结构-零部件树", notes = "树形结构-零部件树")
|
||||
@ApiOperation(value = "树形结构-获取一级树", notes = "树形结构-获取一级树")
|
||||
@GetMapping("/page")
|
||||
public Result<TreePage<SysDictItem>> queryTreeList(
|
||||
@RequestParam(name = "nodeName", required = false, defaultValue = "") @ApiParam("一级节点名称") String nodeName,
|
||||
@RequestParam("dictId") @ApiParam("字典编码") String dictId,
|
||||
@RequestParam(name = "pageNo", defaultValue = "1") @ApiParam("页码") Integer pageNo,
|
||||
@RequestParam(name = "pageSize", defaultValue = "10") @ApiParam("页面大小") Integer pageSize) {
|
||||
TreePage<SysDictItem> list = dictTreeService.queryTreeList(nodeName, pageNo, pageSize);
|
||||
TreePage<SysDictItem> list = dictTreeService.queryTreeList(nodeName, dictId, pageNo, pageSize);
|
||||
return Result.OK(list);
|
||||
}
|
||||
|
||||
@AutoLog(value = "树形结构-零部件树选中回显")
|
||||
@ApiOperation(value = "树形结构-零部件树选中回显", notes = "树形结构-零部件树选中回显")
|
||||
@AutoLog(value = "树形结构-通用树形选中回显")
|
||||
@ApiOperation(value = "树形结构-通用树形选中回显", notes = "树形结构-通用树形选中回显")
|
||||
@PostMapping("/echo")
|
||||
public Result<List<SysDictItem>> queryEcho(@RequestBody Map<String, String> selectNodeCodes) {
|
||||
List<SysDictItem> list = dictTreeService.queryEcho(selectNodeCodes.get("selectNodeCodes"));
|
||||
public Result<List<SysDictItem>> queryEcho(@RequestBody Map<String, String> map) {
|
||||
List<SysDictItem> list = dictTreeService.queryEcho(map.get("selectNodeCodes"), map.get("dictId"));
|
||||
return Result.OK(list);
|
||||
}
|
||||
|
||||
@AutoLog(value = "树形结构-零部件树历史数据处理")
|
||||
@ApiOperation(value = "树形结构-零部件树历史数据处理", notes = "树形结构-零部件树历史数据处理")
|
||||
@AutoLog(value = "树形结构-获取子集")
|
||||
@ApiOperation(value = "树形结构-获取子集", notes = "树形结构-获取子集")
|
||||
@GetMapping("/getChild")
|
||||
public Result<List<SysDictItem>> getChild(@RequestParam("dictItemId") String dictItemId) {
|
||||
return Result.OK(dictTreeService.getChild(dictItemId));
|
||||
public Result<List<SysDictItem>> getChild(@RequestParam("dictItemId") String dictItemId,
|
||||
@RequestParam("dictId") @ApiParam("字典编码") String dictId) {
|
||||
return Result.OK(dictTreeService.getChild(dictItemId, dictId));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package com.jero.modules.laws.standard.entity;
|
||||
|
||||
import com.jero.modules.system.service.TreeNode;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -11,6 +13,8 @@ import java.util.stream.Collectors;
|
||||
* @Date: 2024/1/19 15:24
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class TreePage<T extends TreeNode> {
|
||||
|
||||
private List<T> records;
|
||||
|
||||
+50
-6
@@ -1,5 +1,8 @@
|
||||
package com.jero.modules.laws.standard.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.jero.modules.laws.standard.entity.TreePage;
|
||||
import com.jero.modules.system.entity.SysDictItem;
|
||||
import com.jero.modules.system.service.ISysDictItemService;
|
||||
@@ -7,7 +10,9 @@ import com.jero.modules.system.service.ISysDictService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
public class DictTreeService {
|
||||
@@ -18,15 +23,54 @@ public class DictTreeService {
|
||||
@Resource
|
||||
private ISysDictItemService dictItemService;
|
||||
|
||||
public TreePage<SysDictItem> queryTreeList(String nodeName, Integer pageNo, Integer pageSize) {
|
||||
return null;
|
||||
public TreePage<SysDictItem> queryTreeList(String nodeName, String dictId, Integer pageNo, Integer pageSize) {
|
||||
LambdaQueryWrapper<SysDictItem> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(SysDictItem::getDictId, dictId);
|
||||
queryWrapper.eq(SysDictItem::getParentId, "0");
|
||||
if (nodeName != null && !nodeName.isEmpty()) {
|
||||
queryWrapper.like(SysDictItem::getItemText, nodeName);
|
||||
}
|
||||
Page<SysDictItem> page = new Page<>(pageNo, pageSize);
|
||||
IPage<SysDictItem> pageList = dictItemService.page(page, queryWrapper);
|
||||
|
||||
List<String> dictItemIds = pageList.getRecords().stream().map(SysDictItem::getId).collect(Collectors.toList());
|
||||
// 判断有没有子级
|
||||
queryWrapper.clear();
|
||||
queryWrapper.eq(SysDictItem::getDictId, dictId);
|
||||
queryWrapper.in(SysDictItem::getParentId, dictItemIds);
|
||||
List<SysDictItem> childList = dictItemService.list(queryWrapper);
|
||||
pageList.getRecords().forEach(item -> {
|
||||
if (childList.stream().anyMatch(child -> child.getParentId().equals(item.getId()))) {
|
||||
item.setHasChild(true);
|
||||
}
|
||||
});
|
||||
return new TreePage<>(pageList.getRecords(), pageList.getTotal(), pageList.getSize(), pageList.getCurrent());
|
||||
}
|
||||
|
||||
public List<SysDictItem> queryEcho(String selectNodeCodes) {
|
||||
return null;
|
||||
public List<SysDictItem> queryEcho(String selectNodeCodes, String dictId) {
|
||||
LambdaQueryWrapper<SysDictItem> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(SysDictItem::getDictId, dictId);
|
||||
queryWrapper.in(SysDictItem::getItemValue, Arrays.asList(selectNodeCodes.split(",")));
|
||||
return dictItemService.list(queryWrapper);
|
||||
}
|
||||
|
||||
public List<SysDictItem> getChild(String dictItemId) {
|
||||
return null;
|
||||
public List<SysDictItem> getChild(String dictItemId, String dictId) {
|
||||
LambdaQueryWrapper<SysDictItem> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(SysDictItem::getDictId, dictId);
|
||||
queryWrapper.eq(SysDictItem::getParentId, dictItemId);
|
||||
List<SysDictItem> list = dictItemService.list(queryWrapper);
|
||||
|
||||
List<String> dictItemIds = list.stream().map(SysDictItem::getId).collect(Collectors.toList());
|
||||
// 判断有没有子级
|
||||
queryWrapper.clear();
|
||||
queryWrapper.eq(SysDictItem::getDictId, dictId);
|
||||
queryWrapper.in(SysDictItem::getParentId, dictItemIds);
|
||||
List<SysDictItem> childList = dictItemService.list(queryWrapper);
|
||||
list.forEach(item -> {
|
||||
if (childList.stream().anyMatch(child -> child.getParentId().equals(item.getId()))) {
|
||||
item.setHasChild(true);
|
||||
}
|
||||
});
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user