From 1bc2743dc70b245ae7cfdf80c7f24d2f63ae3997 Mon Sep 17 00:00:00 2001
From: dfdg <2710245601@qq.com>
Date: Thu, 28 Aug 2025 16:20:23 +0800
Subject: [PATCH] =?UTF-8?q?=E5=90=8C=E6=AD=A5=E9=94=A6=E6=B5=AA=E4=BA=91?=
=?UTF-8?q?=E6=A8=A1=E5=9D=97?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
ruoyi-modules/pom.xml | 1 +
ruoyi-modules/ruoyi-synjinlangyun/Dockerfile | 27 ++++
ruoyi-modules/ruoyi-synjinlangyun/pom.xml | 123 +++++++++++++++
.../RuoYiSynjinlangyunApplication.java | 23 +++
.../synjinlangyun/client/J60870Client.java | 58 +++++++
.../listener/J60870ClientListener.java | 21 +++
.../src/main/resources/application.yml | 34 ++++
.../src/main/resources/banner.txt | 10 ++
.../src/main/resources/logback-plus.xml | 28 ++++
.../org/dromara/system/domain/SysDept.java | 26 +++-
.../dromara/system/domain/bo/SysDeptBo.java | 35 ++++-
.../dromara/system/domain/vo/SysDeptVo.java | 42 ++++-
.../dubbo/RemoteTaskAssigneeServiceImpl.java | 2 +-
.../service/impl/SysDeptServiceImpl.java | 145 +++++++++++++++---
14 files changed, 537 insertions(+), 38 deletions(-)
create mode 100644 ruoyi-modules/ruoyi-synjinlangyun/Dockerfile
create mode 100644 ruoyi-modules/ruoyi-synjinlangyun/pom.xml
create mode 100644 ruoyi-modules/ruoyi-synjinlangyun/src/main/java/org/dromara/synjinlangyun/RuoYiSynjinlangyunApplication.java
create mode 100644 ruoyi-modules/ruoyi-synjinlangyun/src/main/java/org/dromara/synjinlangyun/client/J60870Client.java
create mode 100644 ruoyi-modules/ruoyi-synjinlangyun/src/main/java/org/dromara/synjinlangyun/listener/J60870ClientListener.java
create mode 100644 ruoyi-modules/ruoyi-synjinlangyun/src/main/resources/application.yml
create mode 100644 ruoyi-modules/ruoyi-synjinlangyun/src/main/resources/banner.txt
create mode 100644 ruoyi-modules/ruoyi-synjinlangyun/src/main/resources/logback-plus.xml
diff --git a/ruoyi-modules/pom.xml b/ruoyi-modules/pom.xml
index 490c704..9fb79ce 100644
--- a/ruoyi-modules/pom.xml
+++ b/ruoyi-modules/pom.xml
@@ -14,6 +14,7 @@
ruoyi-job
ruoyi-resource
ruoyi-workflow
+ ruoyi-synjinlangyun
ruoyi-modules
diff --git a/ruoyi-modules/ruoyi-synjinlangyun/Dockerfile b/ruoyi-modules/ruoyi-synjinlangyun/Dockerfile
new file mode 100644
index 0000000..4f0cf29
--- /dev/null
+++ b/ruoyi-modules/ruoyi-synjinlangyun/Dockerfile
@@ -0,0 +1,27 @@
+# 贝尔实验室 Spring 官方推荐镜像 JDK下载地址 https://bell-sw.com/pages/downloads/
+FROM bellsoft/liberica-openjdk-rocky:17.0.15-cds
+#FROM bellsoft/liberica-openjdk-rocky:21.0.7-cds
+#FROM findepi/graalvm:java17-native
+
+LABEL maintainer="Lion Li"
+
+RUN mkdir -p /ruoyi/synjinlangyun/logs \
+ /ruoyi/synjinlangyun/temp \
+ /ruoyi/skywalking/agent
+
+WORKDIR /ruoyi/synjinlangyun
+
+ENV SERVER_PORT=9201 LANG=C.UTF-8 LC_ALL=C.UTF-8 JAVA_OPTS=""
+
+EXPOSE ${SERVER_PORT}
+
+ADD ./target/ruoyi-synjinlangyun.jar ./app.jar
+
+SHELL ["/bin/bash", "-c"]
+
+ENTRYPOINT java -Djava.security.egd=file:/dev/./urandom -Dserver.port=${SERVER_PORT} \
+ #-Dskywalking.agent.service_name=ruoyi-synjinlangyun \
+ #-javaagent:/ruoyi/skywalking/agent/skywalking-agent.jar \
+ -XX:+HeapDumpOnOutOfMemoryError -XX:+UseZGC ${JAVA_OPTS} \
+ -jar app.jar
+
diff --git a/ruoyi-modules/ruoyi-synjinlangyun/pom.xml b/ruoyi-modules/ruoyi-synjinlangyun/pom.xml
new file mode 100644
index 0000000..0d371de
--- /dev/null
+++ b/ruoyi-modules/ruoyi-synjinlangyun/pom.xml
@@ -0,0 +1,123 @@
+
+
+
+ org.dromara
+ ruoyi-modules
+ ${revision}
+
+ 4.0.0
+
+ ruoyi-synjinlangyun
+
+
+ ruoyi-synjinlangyun同步锦浪云模块
+
+
+
+
+
+ org.dromara
+ ruoyi-common-nacos
+
+
+
+ org.dromara
+ ruoyi-common-sentinel
+
+
+
+
+ org.dromara
+ ruoyi-common-log
+
+
+
+ org.dromara
+ ruoyi-common-service-impl
+
+
+
+ org.dromara
+ ruoyi-common-doc
+
+
+
+ org.dromara
+ ruoyi-common-web
+
+
+
+ org.dromara
+ ruoyi-common-mybatis
+
+
+
+ org.dromara
+ ruoyi-common-dubbo
+
+
+
+ org.dromara
+ ruoyi-common-seata
+
+
+
+ org.dromara
+ ruoyi-common-idempotent
+
+
+
+ org.dromara
+ ruoyi-common-tenant
+
+
+
+ org.dromara
+ ruoyi-common-security
+
+
+
+ org.dromara
+ ruoyi-common-translation
+
+
+
+ org.dromara
+ ruoyi-common-sensitive
+
+
+
+ org.dromara
+ ruoyi-common-encrypt
+
+
+ org.openmuc
+ j60870
+ 1.4.0
+
+
+
+
+
+
+ ${project.artifactId}
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+ ${spring-boot.version}
+
+
+
+ repackage
+
+
+
+
+
+
+
+
+
diff --git a/ruoyi-modules/ruoyi-synjinlangyun/src/main/java/org/dromara/synjinlangyun/RuoYiSynjinlangyunApplication.java b/ruoyi-modules/ruoyi-synjinlangyun/src/main/java/org/dromara/synjinlangyun/RuoYiSynjinlangyunApplication.java
new file mode 100644
index 0000000..bc398ff
--- /dev/null
+++ b/ruoyi-modules/ruoyi-synjinlangyun/src/main/java/org/dromara/synjinlangyun/RuoYiSynjinlangyunApplication.java
@@ -0,0 +1,23 @@
+package org.dromara.synjinlangyun;
+
+
+import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.context.metrics.buffering.BufferingApplicationStartup;
+
+/**
+ * 同步锦浪云模块
+ *
+ * @author ruoyi
+ */
+@EnableDubbo
+@SpringBootApplication
+public class RuoYiSynjinlangyunApplication {
+ public static void main(String[] args) {
+ SpringApplication application = new SpringApplication(RuoYiSynjinlangyunApplication.class);
+ application.setApplicationStartup(new BufferingApplicationStartup(2048));
+ application.run(args);
+ System.out.println("(♥◠‿◠)ノ゙ 同步锦浪云模块启动成功 ლ(´ڡ`ლ)゙ ");
+ }
+}
diff --git a/ruoyi-modules/ruoyi-synjinlangyun/src/main/java/org/dromara/synjinlangyun/client/J60870Client.java b/ruoyi-modules/ruoyi-synjinlangyun/src/main/java/org/dromara/synjinlangyun/client/J60870Client.java
new file mode 100644
index 0000000..fd4a490
--- /dev/null
+++ b/ruoyi-modules/ruoyi-synjinlangyun/src/main/java/org/dromara/synjinlangyun/client/J60870Client.java
@@ -0,0 +1,58 @@
+package org.dromara.synjinlangyun.client;
+
+import org.dromara.synjinlangyun.listener.J60870ClientListener;
+import org.openmuc.j60870.ClientConnectionBuilder;
+import org.openmuc.j60870.Connection;
+
+import java.io.IOException;
+import java.net.InetAddress;
+
+public class J60870Client implements Runnable {
+
+ //监听类
+ private J60870ClientListener listener;
+ //连接类
+ private Connection connection;
+ //连接参数
+ private ClientConnectionBuilder clientConnectionBuilder;
+
+
+ public J60870Client() throws IOException{
+ try {
+ //获取server对象,从站的IP地址对象
+ InetAddress address = InetAddress.getByName("127.0.0.1");
+
+ //创建连接参数对象
+ clientConnectionBuilder = new ClientConnectionBuilder(address);
+ //设置socket的连接超时时间
+ clientConnectionBuilder.setConnectionTimeout(60000);
+
+
+ }catch (Exception e){
+ e.printStackTrace();
+ }
+ }
+
+ @Override
+ public void run() {
+ try {
+ //主站与从站连接
+ connection = clientConnectionBuilder.build();
+
+ //配置数据回调类
+ listener = new J60870ClientListener();
+ connection.startDataTransfer(listener);
+ }catch (Exception e){
+ e.printStackTrace();
+ }
+ }
+
+ //关闭连接
+ public void disconnect(){
+ try {
+ this.connection.close();
+ }catch (Exception e){
+ e.printStackTrace();
+ }
+ }
+}
diff --git a/ruoyi-modules/ruoyi-synjinlangyun/src/main/java/org/dromara/synjinlangyun/listener/J60870ClientListener.java b/ruoyi-modules/ruoyi-synjinlangyun/src/main/java/org/dromara/synjinlangyun/listener/J60870ClientListener.java
new file mode 100644
index 0000000..59003e4
--- /dev/null
+++ b/ruoyi-modules/ruoyi-synjinlangyun/src/main/java/org/dromara/synjinlangyun/listener/J60870ClientListener.java
@@ -0,0 +1,21 @@
+package org.dromara.synjinlangyun.listener;
+
+import org.openmuc.j60870.ASdu;
+import org.openmuc.j60870.ConnectionEventListener;
+
+import java.io.IOException;
+
+public class J60870ClientListener implements ConnectionEventListener {
+
+ //监听从站发来的数据
+ @Override
+ public void newASdu(ASdu aSdu) {
+ System.out.println(aSdu.toString());
+ }
+
+ //监听连接关闭
+ @Override
+ public void connectionClosed(IOException e) {
+ e.printStackTrace();
+ }
+}
diff --git a/ruoyi-modules/ruoyi-synjinlangyun/src/main/resources/application.yml b/ruoyi-modules/ruoyi-synjinlangyun/src/main/resources/application.yml
new file mode 100644
index 0000000..6de9f86
--- /dev/null
+++ b/ruoyi-modules/ruoyi-synjinlangyun/src/main/resources/application.yml
@@ -0,0 +1,34 @@
+# Tomcat
+server:
+ port: 9202
+
+# Spring
+spring:
+ application:
+ # 应用名称
+ name: ruoyi-synjinlangyun
+ profiles:
+ # 环境配置
+ active: @profiles.active@
+
+--- # nacos 配置
+spring:
+ cloud:
+ nacos:
+ # nacos 服务地址
+ server-addr: @nacos.server@
+ username: @nacos.username@
+ password: @nacos.password@
+ discovery:
+ # 注册组
+ group: @nacos.discovery.group@
+ namespace: ${spring.profiles.active}
+ config:
+ # 配置组
+ group: @nacos.config.group@
+ namespace: ${spring.profiles.active}
+ config:
+ import:
+ - optional:nacos:application-common.yml
+ - optional:nacos:datasource.yml
+ - optional:nacos:${spring.application.name}.yml
diff --git a/ruoyi-modules/ruoyi-synjinlangyun/src/main/resources/banner.txt b/ruoyi-modules/ruoyi-synjinlangyun/src/main/resources/banner.txt
new file mode 100644
index 0000000..fbd45f5
--- /dev/null
+++ b/ruoyi-modules/ruoyi-synjinlangyun/src/main/resources/banner.txt
@@ -0,0 +1,10 @@
+Spring Boot Version: ${spring-boot.version}
+Spring Application Name: ${spring.application.name}
+ _ _
+ (_) | |
+ _ __ _ _ ___ _ _ _ ______ ___ _ _ ___ | |_ ___ _ __ ___
+| '__|| | | | / _ \ | | | || ||______|/ __|| | | |/ __|| __| / _ \| '_ ` _ \
+| | | |_| || (_) || |_| || | \__ \| |_| |\__ \| |_ | __/| | | | | |
+|_| \__,_| \___/ \__, ||_| |___/ \__, ||___/ \__| \___||_| |_| |_|
+ __/ | __/ |
+ |___/ |___/
\ No newline at end of file
diff --git a/ruoyi-modules/ruoyi-synjinlangyun/src/main/resources/logback-plus.xml b/ruoyi-modules/ruoyi-synjinlangyun/src/main/resources/logback-plus.xml
new file mode 100644
index 0000000..00d3089
--- /dev/null
+++ b/ruoyi-modules/ruoyi-synjinlangyun/src/main/resources/logback-plus.xml
@@ -0,0 +1,28 @@
+
+
+
+
+
+
+
+
+
+
+ ${console.log.pattern}
+ utf-8
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/domain/SysDept.java b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/domain/SysDept.java
index 71a5517..e6d5319 100644
--- a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/domain/SysDept.java
+++ b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/domain/SysDept.java
@@ -38,6 +38,16 @@ public class SysDept extends TenantEntity {
*/
private Long parentId;
+ /**
+ * 项目ID
+ */
+ private Long projectId;
+
+ /**
+ * 分包公司ID
+ */
+ private Long contractorId;
+
/**
* 部门名称
*/
@@ -85,9 +95,19 @@ public class SysDept extends TenantEntity {
private String ancestors;
/**
- * 子菜单
+ * 是否隐藏(0隐藏 1显示)
*/
- @TableField(exist = false)
- private List children = new ArrayList<>();
+ private String isShow;
+
+ /**
+ * 部门类型
+ */
+ private String deptType;
+
+// /**
+// * 子菜单
+// */
+// @TableField(exist = false)
+// private List children = new ArrayList<>();
}
diff --git a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/domain/bo/SysDeptBo.java b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/domain/bo/SysDeptBo.java
index 0d8ac84..701a209 100644
--- a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/domain/bo/SysDeptBo.java
+++ b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/domain/bo/SysDeptBo.java
@@ -1,10 +1,7 @@
package org.dromara.system.domain.bo;
import io.github.linpeilie.annotations.AutoMapper;
-import jakarta.validation.constraints.Email;
-import jakarta.validation.constraints.NotBlank;
-import jakarta.validation.constraints.NotNull;
-import jakarta.validation.constraints.Size;
+import jakarta.validation.constraints.*;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.dromara.common.mybatis.core.domain.BaseEntity;
@@ -31,6 +28,21 @@ public class SysDeptBo extends BaseEntity {
*/
private Long parentId;
+ /**
+ * 项目id
+ */
+ private Long projectId;
+
+ /**
+ * 项目部门项目id
+ */
+ private Long rowProjectId;
+
+ /**
+ * 分包公司ID
+ */
+ private Long contractorId;
+
/**
* 部门名称
*/
@@ -74,8 +86,19 @@ public class SysDeptBo extends BaseEntity {
private String status;
/**
- * 归属部门id(部门树)
+ * 是否隐藏(0隐藏 1显示)
*/
- private Long belongDeptId;
+ @Pattern(regexp = "^[01]$", message = "isShow字段值必须是0或1")
+ private String isShow;
+
+ /**
+ * 部门类型
+ */
+ @NotBlank(message = "部门类型不能为空")
+ private String deptType;
+// /**
+// * 归属部门id(部门树)
+// */
+// private Long belongDeptId;
}
diff --git a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/domain/vo/SysDeptVo.java b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/domain/vo/SysDeptVo.java
index 5163cbf..455d980 100644
--- a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/domain/vo/SysDeptVo.java
+++ b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/domain/vo/SysDeptVo.java
@@ -6,6 +6,8 @@ import io.github.linpeilie.annotations.AutoMapper;
import lombok.Data;
import org.dromara.common.excel.annotation.ExcelDictFormat;
import org.dromara.common.excel.convert.ExcelDictConvert;
+//import org.dromara.contractor.domain.vo.SubContractorVo;
+//import org.dromara.project.domain.vo.project.BusProjectVo;
import org.dromara.system.domain.SysDept;
import java.io.Serial;
@@ -43,6 +45,31 @@ public class SysDeptVo implements Serializable {
*/
private String parentName;
+ /**
+ * 父部门信息
+ */
+ private SysDeptVo parent;
+
+ /**
+ * 项目id
+ */
+ private Long projectId;
+
+ /**
+ * 分包公司ID
+ */
+ private Long contractorId;
+
+ /**
+ * 未绑定项目信息
+ */
+// private List projectList;
+//
+// /**
+// * 未绑定分包信息
+// */
+// private List contractorList;
+
/**
* 祖级列表
*/
@@ -95,15 +122,22 @@ public class SysDeptVo implements Serializable {
@ExcelDictFormat(dictType = "sys_normal_disable")
private String status;
+ /**
+ * 部门类型
+ */
+ @ExcelProperty(value = "部门类型", converter = ExcelDictConvert.class)
+ @ExcelDictFormat(dictType = "sys_dept_type")
+ private String deptType;
+
/**
* 创建时间
*/
@ExcelProperty(value = "创建时间")
private Date createTime;
- /**
- * 子菜单
- */
- private List children = new ArrayList<>();
+// /**
+// * 子菜单
+// */
+// private List children = new ArrayList<>();
}
diff --git a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/dubbo/RemoteTaskAssigneeServiceImpl.java b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/dubbo/RemoteTaskAssigneeServiceImpl.java
index 87d1c6e..f634138 100644
--- a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/dubbo/RemoteTaskAssigneeServiceImpl.java
+++ b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/dubbo/RemoteTaskAssigneeServiceImpl.java
@@ -105,7 +105,7 @@ public class RemoteTaskAssigneeServiceImpl implements RemoteTaskAssigneeService
Map params = bo.getParams();
params.put("beginTime", taskQuery.getBeginTime());
params.put("endTime", taskQuery.getEndTime());
- bo.setBelongDeptId(Convert.toLong(taskQuery.getGroupId()));
+// bo.setBelongDeptId(Convert.toLong(taskQuery.getGroupId()));
TableDataInfo page = deptService.selectPageDeptList(bo, pageQuery);
// 使用封装的字段映射方法进行转换
List handlers = RemoteTaskAssigneeVo.convertToHandlerList(page.getRows(),
diff --git a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/SysDeptServiceImpl.java b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/SysDeptServiceImpl.java
index 7107b4a..4936e7a 100644
--- a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/SysDeptServiceImpl.java
+++ b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/SysDeptServiceImpl.java
@@ -19,10 +19,12 @@ import org.dromara.common.mybatis.helper.DataBaseHelper;
import org.dromara.common.redis.utils.CacheUtils;
import org.dromara.common.satoken.utils.LoginHelper;
import org.dromara.system.domain.SysDept;
+import org.dromara.system.domain.SysPost;
import org.dromara.system.domain.SysRole;
import org.dromara.system.domain.SysUser;
import org.dromara.system.domain.bo.SysDeptBo;
import org.dromara.system.domain.vo.SysDeptVo;
+import org.dromara.system.domain.vo.SysPostVo;
import org.dromara.system.mapper.SysDeptMapper;
import org.dromara.system.mapper.SysRoleMapper;
import org.dromara.system.mapper.SysUserMapper;
@@ -37,6 +39,8 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
/**
* 部门管理 服务实现
@@ -90,7 +94,6 @@ public class SysDeptServiceImpl implements ISysDeptService {
}
private LambdaQueryWrapper buildQueryWrapper(SysDeptBo bo) {
- Map params = bo.getParams();
LambdaQueryWrapper lqw = Wrappers.lambdaQuery();
lqw.eq(SysDept::getDelFlag, SystemConstants.NORMAL);
lqw.eq(ObjectUtil.isNotNull(bo.getDeptId()), SysDept::getDeptId, bo.getDeptId());
@@ -98,22 +101,37 @@ public class SysDeptServiceImpl implements ISysDeptService {
lqw.like(StringUtils.isNotBlank(bo.getDeptName()), SysDept::getDeptName, bo.getDeptName());
lqw.like(StringUtils.isNotBlank(bo.getDeptCategory()), SysDept::getDeptCategory, bo.getDeptCategory());
lqw.eq(StringUtils.isNotBlank(bo.getStatus()), SysDept::getStatus, bo.getStatus());
- lqw.between(params.get("beginTime") != null && params.get("endTime") != null,
- SysDept::getCreateTime, params.get("beginTime"), params.get("endTime"));
+ lqw.eq(StringUtils.isNotBlank(bo.getStatus()), SysDept::getStatus, bo.getStatus());
+ lqw.eq(StringUtils.isNotBlank(bo.getIsShow()), SysDept::getIsShow, bo.getIsShow());
+ lqw.eq(StringUtils.isNotBlank(bo.getDeptType()), SysDept::getDeptType, bo.getDeptType());
lqw.orderByAsc(SysDept::getAncestors);
lqw.orderByAsc(SysDept::getParentId);
lqw.orderByAsc(SysDept::getOrderNum);
lqw.orderByAsc(SysDept::getDeptId);
- if (ObjectUtil.isNotNull(bo.getBelongDeptId())) {
- //部门树搜索
- lqw.and(x -> {
- Long parentId = bo.getBelongDeptId();
- List deptList = baseMapper.selectListByParentId(parentId);
- List deptIds = StreamUtils.toList(deptList, SysDept::getDeptId);
- deptIds.add(parentId);
- x.in(SysDept::getDeptId, deptIds);
- });
- }
+// Map params = bo.getParams();
+// LambdaQueryWrapper lqw = Wrappers.lambdaQuery();
+// lqw.eq(SysDept::getDelFlag, SystemConstants.NORMAL);
+// lqw.eq(ObjectUtil.isNotNull(bo.getDeptId()), SysDept::getDeptId, bo.getDeptId());
+// lqw.eq(ObjectUtil.isNotNull(bo.getParentId()), SysDept::getParentId, bo.getParentId());
+// lqw.like(StringUtils.isNotBlank(bo.getDeptName()), SysDept::getDeptName, bo.getDeptName());
+// lqw.like(StringUtils.isNotBlank(bo.getDeptCategory()), SysDept::getDeptCategory, bo.getDeptCategory());
+// lqw.eq(StringUtils.isNotBlank(bo.getStatus()), SysDept::getStatus, bo.getStatus());
+// lqw.between(params.get("beginTime") != null && params.get("endTime") != null,
+// SysDept::getCreateTime, params.get("beginTime"), params.get("endTime"));
+// lqw.orderByAsc(SysDept::getAncestors);
+// lqw.orderByAsc(SysDept::getParentId);
+// lqw.orderByAsc(SysDept::getOrderNum);
+// lqw.orderByAsc(SysDept::getDeptId);
+// if (ObjectUtil.isNotNull(bo.getBelongDeptId())) {
+// //部门树搜索
+// lqw.and(x -> {
+// Long parentId = bo.getBelongDeptId();
+// List deptList = baseMapper.selectListByParentId(parentId);
+// List deptIds = StreamUtils.toList(deptList, SysDept::getDeptId);
+// deptIds.add(parentId);
+// x.in(SysDept::getDeptId, deptIds);
+// });
+// }
return lqw;
}
@@ -128,19 +146,98 @@ public class SysDeptServiceImpl implements ISysDeptService {
if (CollUtil.isEmpty(depts)) {
return CollUtil.newArrayList();
}
- return TreeBuildUtils.buildMultiRoot(
- depts,
- SysDeptVo::getDeptId,
- SysDeptVo::getParentId,
- (node, treeNode) -> treeNode
- .setId(node.getDeptId())
- .setParentId(node.getParentId())
- .setName(node.getDeptName())
- .setWeight(node.getOrderNum())
- .putExtra("disabled", SystemConstants.DISABLE.equals(node.getStatus()))
- );
+ // 获取当前列表中每一个节点的parentId,然后在列表中查找是否有id与其parentId对应,若无对应,则表明此时节点列表中,该节点在当前列表中属于顶级节点
+ List> treeList = CollUtil.newArrayList();
+ for (SysDeptVo d : depts) {
+ Long parentId = d.getParentId();
+ SysDeptVo sysDeptVo = StreamUtils.findFirst(depts, it -> it.getDeptId().longValue() == parentId);
+ if (ObjectUtil.isNull(sysDeptVo)) {
+ List> trees = TreeBuildUtils.build(depts, parentId, (dept, tree) -> {
+ tree.setId(dept.getDeptId())
+ .setParentId(dept.getParentId())
+ .setName(dept.getDeptName())
+ .setWeight(dept.getOrderNum())
+ .putExtra("disabled", SystemConstants.DISABLE.equals(dept.getStatus()));
+ tree.putExtra("deptType", dept.getDeptType());
+ }
+ );
+ Tree tree = StreamUtils.findFirst(trees, it -> it.getId().longValue() == d.getDeptId());
+ treeList.add(tree);
+ }
+ }
+ return treeList;
+// if (CollUtil.isEmpty(depts)) {
+// return CollUtil.newArrayList();
+// }
+// return TreeBuildUtils.buildMultiRoot(
+// depts,
+// SysDeptVo::getDeptId,
+// SysDeptVo::getParentId,
+// (node, treeNode) -> treeNode
+// .setId(node.getDeptId())
+// .setParentId(node.getParentId())
+// .setName(node.getDeptName())
+// .setWeight(node.getOrderNum())
+// .putExtra("disabled", SystemConstants.DISABLE.equals(node.getStatus()))
+// );
}
+ //TODO 同步xinnengyuan的service
+
+// /**
+// * 构建前端所需要下拉树结构
+// *
+// * @param projectId 项目id
+// * @return 下拉树结构列表
+// */
+// @Override
+// public List> buildDeptTreeByProjectId(Long projectId) {
+// SysDept dept = baseMapper.selectOne(
+// new LambdaQueryWrapper<>(SysDept.class)
+// .eq(SysDept::getProjectId, projectId)
+// .eq(SysDept::getDeptType, SysDeptTypeEnum.PROJECT.getCode())
+// .eq(SysDept::getStatus, SystemConstants.NORMAL)
+// );
+// if (dept == null) {
+// return List.of();
+// }
+// List deptIds = Stream.concat(
+// Arrays.stream(dept.getAncestors().split(","))
+// .filter(StringUtils::isNotBlank)
+// .map(Long::parseLong),
+// Stream.of(dept.getDeptId())
+// ).toList();
+// List deptVoList = baseMapper.selectVoByIds(deptIds);
+// List postVos = postMapper.selectVoList(
+// new LambdaQueryWrapper<>(SysPost.class)
+// .in(SysPost::getDeptId, deptIds)
+// .eq(SysPost::getStatus, SystemConstants.NORMAL)
+// );
+// Map> postVoMap = postVos.stream().collect(Collectors.groupingBy(SysPostVo::getDeptId));
+// // 获取当前列表中每一个节点的parentId,然后在列表中查找是否有id与其parentId对应,若无对应,则表明此时节点列表中,该节点在当前列表中属于顶级节点
+// List> treeList = CollUtil.newArrayList();
+// for (SysDeptVo d : deptVoList) {
+// Long parentId = d.getParentId();
+// SysDeptVo sysDeptVo = StreamUtils.findFirst(deptVoList, it -> it.getDeptId().longValue() == parentId);
+// if (ObjectUtil.isNull(sysDeptVo)) {
+// List> trees = TreeBuildUtils.build(deptVoList, parentId, (deptVo, tree) -> {
+// Long deptId = deptVo.getDeptId();
+// tree.setId(deptId)
+// .setParentId(deptVo.getParentId())
+// .setName(deptVo.getDeptName())
+// .setWeight(deptVo.getOrderNum())
+// .putExtra("disabled", SystemConstants.DISABLE.equals(deptVo.getStatus()));
+// tree.putExtra("deptType", deptVo.getDeptType());
+// tree.putExtra("postVoList", postVoMap.get(deptId));
+// }
+// );
+// Tree tree = StreamUtils.findFirst(trees, it -> it.getId().longValue() == d.getDeptId());
+// treeList.add(tree);
+// }
+// }
+// return treeList;
+// }
+
/**
* 根据角色ID查询部门树信息
*