From b30f65004f5c4b925175884b62006fafeb7cdc40 Mon Sep 17 00:00:00 2001
From: Administrator <admin>
Date: Mon, 29 Nov 2021 09:21:08 +0800
Subject: [PATCH] 组织机构新增,修改内网数据同步
---
src/main/java/org/springblade/modules/system/controller/DeptController.java | 50 ++++++++++++++++++++++++++++++++++++++++++--------
1 files changed, 42 insertions(+), 8 deletions(-)
diff --git a/src/main/java/org/springblade/modules/system/controller/DeptController.java b/src/main/java/org/springblade/modules/system/controller/DeptController.java
index 1b77122..02394cd 100644
--- a/src/main/java/org/springblade/modules/system/controller/DeptController.java
+++ b/src/main/java/org/springblade/modules/system/controller/DeptController.java
@@ -47,6 +47,7 @@
import springfox.documentation.annotations.ApiIgnore;
import javax.validation.Valid;
+import java.util.Arrays;
import java.util.List;
import java.util.Map;
@@ -224,12 +225,46 @@
@ApiOperation(value = "新增或修改", notes = "传入dept")
public R submit(@Valid @RequestBody Dept dept) {
// Information information = new Information();
- //Integer isDeleted = 0;
+ boolean type = false;
+ //如果为修改
+ if (null!=dept.getId()){
+ type = true;
+ }
if (deptService.submit(dept)) {
CacheUtil.clear(SYS_CACHE);
// 返回懒加载树更新节点所需字段
Kv kv = Kv.create().set("id", String.valueOf(dept.getId())).set("tenantId", dept.getTenantId())
.set("deptCategoryName", DictCache.getValue(DictEnum.ORG_CATEGORY, dept.getDeptCategory()));
+ if (!type) {
+ Integer isDeleted = 0;
+ //内网同步新增
+ String ss = "insert into blade_dept(id,parent_id,tenant_id,dept_name,ancestors,dept_category,full_name,sort,remark,is_deleted) values("
+ + "'" + dept.getId() + "'" + ","
+ + "'" + dept.getParentId() + "'" + ","
+ + "'" + dept.getTenantId() + "'" +
+ "," + "'" + dept.getDeptName() + "'" +
+ "," + "'" + dept.getAncestors() + "'" +
+ "," + "'" + dept.getDeptCategory() + "'" +
+ "," + "'" + dept.getFullName() + "'" +
+ "," + "'" + dept.getSort() + "'" +
+ "," + "'" + dept.getRemark() + "'" +
+ "," + "'" + isDeleted + "'" + ")";
+ FtpUtil.sqlFileUpload(ss);
+ }else {
+ //修改
+ //内网同步
+ String s1 =
+ "update blade_dept set parent_id = " + "'" + dept.getParentId() + "'"
+ + ",dept_name = " + "'" + dept.getDeptName() + "'"
+ + ",ancestors = " + "'" + dept.getAncestors() + "'"
+ + ",dept_category = " + "'" + dept.getDeptCategory() + "'"
+ + ",full_name = " + "'" + dept.getFullName() + "'"
+ + ",sort = " + "'" + dept.getSort() + "'"
+ + ",remark = " + "'" + dept.getRemark() + "'"
+ + ",is_deleted = " + "'" + dept.getIsDeleted() + "'"
+ + " " + "where id = " + "'" + dept.getId() + "'";
+ FtpUtil.sqlFileUpload(s1);
+ }
// String id = kv.get("id").toString();
// information.setDepartmentid(id);
// information.setEnterprisename(dept.getDeptName());
@@ -244,13 +279,6 @@
// "," + "'" + information.getDepartmentid() + "'" +
// "," + "'" + information.getStats() + "'"+ ")";
// FtpUtil.sqlFileUpload(s);
-// String ss = "insert into blade_dept(id,parent_id,tenant_id,dept_name,ancestors,dept_category,is_deleted) values(" + "'" + dept.getId() + "'" + "," + "'" + dept.getParentId() + "'" + ","
-// + "'" + dept.getTenantId() + "'" +
-// "," + "'" + information.getEnterprisename() + "'" +
-// "," + "'" + dept.getAncestors() + "'" +
-// "," + "'" + dept.getDeptCategory() + "'" +
-// "," + "'" + isDeleted + "'" + ")";
-// FtpUtil.sqlFileUpload(ss);
return R.fail("操作失败");
}
@@ -262,6 +290,12 @@
@ApiOperation(value = "删除", notes = "传入ids")
public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
CacheUtil.clear(SYS_CACHE);
+ List<String> list = Arrays.asList(ids.split(","));
+ list.forEach(id -> {
+ //内网同步
+ String s1 = "update blade_dept set is_deleted = 1 where id = " + "'" + id + "'";
+ FtpUtil.sqlFileUpload(s1);
+ });
return R.status(deptService.removeDept(ids));
}
--
Gitblit v1.9.3