From e0118806726fd4a4a3d2b7a31cce08fd9888bc56 Mon Sep 17 00:00:00 2001 From: dxfeng Date: Mon, 31 Jul 2023 10:02:38 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E7=BB=84=E7=BB=87=E7=AE=A1=E7=90=86?= =?UTF-8?q?=EF=BC=8C=E6=A0=91=E7=BB=93=E6=9E=84=E7=A6=81=E7=94=A8=E9=9D=9E?= =?UTF-8?q?=E9=83=A8=E9=97=A8=E8=8A=82=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../organization/entity/chart/TreeSelect.java | 1 + .../service/impl/ChartServiceImpl.java | 19 ++++++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/com/engine/organization/entity/chart/TreeSelect.java b/src/com/engine/organization/entity/chart/TreeSelect.java index fed41471..cd7099f7 100644 --- a/src/com/engine/organization/entity/chart/TreeSelect.java +++ b/src/com/engine/organization/entity/chart/TreeSelect.java @@ -31,6 +31,7 @@ public class TreeSelect { private String type; private String canceled; private List children; + private boolean disabled; private String cancelSql; diff --git a/src/com/engine/organization/service/impl/ChartServiceImpl.java b/src/com/engine/organization/service/impl/ChartServiceImpl.java index 15f23a14..3d0c6cb5 100644 --- a/src/com/engine/organization/service/impl/ChartServiceImpl.java +++ b/src/com/engine/organization/service/impl/ChartServiceImpl.java @@ -501,7 +501,7 @@ public class ChartServiceImpl extends Service implements ChartService { expandedKeys = companyTree.getChildren().stream().filter(item -> CollectionUtils.isNotEmpty(item.getChildren())).map(TreeSelect::getKey).collect(Collectors.toList()); expandedKeys.add(companyTree.getKey()); } - + disableTreeItem(Collections.singletonList(companyTree),TreeSelect.DEPARTMENT); Map result = new HashMap<>(3); result.put("selectTree", companyTree); result.put("expandedKeys", expandedKeys); @@ -509,6 +509,23 @@ public class ChartServiceImpl extends Service implements ChartService { return result; } + /** + * 树节点是否禁用 + * + * @param companyTreeList TreeSelect组件数据集合 + */ + private void disableTreeItem(List companyTreeList, String enableTreeType) { + if (CollectionUtils.isNotEmpty(companyTreeList)) { + for (TreeSelect treeSelect : companyTreeList) { + treeSelect.setDisabled(!enableTreeType.equals(treeSelect.getType())); + List children = treeSelect.getChildren(); + if (CollectionUtils.isNotEmpty(children)) { + disableTreeItem(children, enableTreeType); + } + } + } + } + private void trueDimension(RecordSetTrans recordSetTrans,String versionId,String currentUser,String currentDate){ RecordSet rs = new RecordSet(); rs.execute("delete from jcl_chart_subcompany where versionid = "+versionId); From ea4a3201aa1244444c38bf6193c71b3a167a419b Mon Sep 17 00:00:00 2001 From: dxfeng Date: Mon, 31 Jul 2023 10:55:20 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E7=BB=84=E7=BB=87=E7=AE=A1=E7=90=86?= =?UTF-8?q?=EF=BC=8C=E6=9E=B6=E6=9E=84=E5=9B=BE=E9=83=A8=E9=97=A8=E6=A0=91?= =?UTF-8?q?=E9=80=89=E6=8B=A9=E6=95=B0=E6=8D=AE=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/com/engine/organization/entity/chart/CompanyTreePO.java | 1 + .../engine/organization/service/impl/ChartServiceImpl.java | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/com/engine/organization/entity/chart/CompanyTreePO.java b/src/com/engine/organization/entity/chart/CompanyTreePO.java index 9a358082..6b3520cc 100644 --- a/src/com/engine/organization/entity/chart/CompanyTreePO.java +++ b/src/com/engine/organization/entity/chart/CompanyTreePO.java @@ -21,6 +21,7 @@ public class CompanyTreePO { private String title; private boolean isLeaf; private String key; + private boolean disabled; public boolean getIsLeaf() { return isLeaf; diff --git a/src/com/engine/organization/service/impl/ChartServiceImpl.java b/src/com/engine/organization/service/impl/ChartServiceImpl.java index 3d0c6cb5..cf7aa53d 100644 --- a/src/com/engine/organization/service/impl/ChartServiceImpl.java +++ b/src/com/engine/organization/service/impl/ChartServiceImpl.java @@ -466,9 +466,9 @@ public class ChartServiceImpl extends Service implements ChartService { String sql = getDepartmentTreeSql(versionId, dimension, subCompany); rs.executeQuery(sql); while (rs.next()) { - departmentTree.add(CompanyTreePO.builder().id(rs.getString("id")).pId(rs.getString("pId")).value(rs.getString("value")).title(rs.getString("title")).isLeaf(judgeTreeLeaf(versionId, dimension, rs.getString("id"))).build()); + departmentTree.add(CompanyTreePO.builder().id(rs.getString("id")).pId(rs.getString("pId")).disabled(!rs.getString("id").startsWith("d")).value(rs.getString("value")).title(rs.getString("title")).isLeaf(judgeTreeLeaf(versionId, dimension, rs.getString("id"))).build()); } - result.put("companyTree", departmentTree); + result.put("departmentTree", departmentTree); result.put("api_status", true); return result; } From 9a6f0a845ee6782275c92effb982cc219932e8f5 Mon Sep 17 00:00:00 2001 From: dxfeng Date: Mon, 31 Jul 2023 17:45:42 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E7=BB=84=E7=BB=87=E7=AE=A1=E7=90=86?= =?UTF-8?q?=EF=BC=8C=E6=9E=B6=E6=9E=84=E5=9B=BE=E6=A0=91=E6=8E=92=E5=BA=8F?= =?UTF-8?q?=E3=80=81BUG=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../entity/chart/CompanyTreePO.java | 4 +++ .../organization/entity/chart/TreeSelect.java | 19 +++++++++----- .../service/impl/ChartServiceImpl.java | 26 +++++++++++-------- 3 files changed, 31 insertions(+), 18 deletions(-) diff --git a/src/com/engine/organization/entity/chart/CompanyTreePO.java b/src/com/engine/organization/entity/chart/CompanyTreePO.java index 6b3520cc..c5c3dd1e 100644 --- a/src/com/engine/organization/entity/chart/CompanyTreePO.java +++ b/src/com/engine/organization/entity/chart/CompanyTreePO.java @@ -34,4 +34,8 @@ public class CompanyTreePO { public String getKey() { return id; } + + public String getValue() { + return id; + } } diff --git a/src/com/engine/organization/entity/chart/TreeSelect.java b/src/com/engine/organization/entity/chart/TreeSelect.java index cd7099f7..8e3da768 100644 --- a/src/com/engine/organization/entity/chart/TreeSelect.java +++ b/src/com/engine/organization/entity/chart/TreeSelect.java @@ -1,5 +1,6 @@ package com.engine.organization.entity.chart; +import com.alibaba.fastjson.annotation.JSONField; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; @@ -25,12 +26,16 @@ public class TreeSelect { public static final String SUB_COMPANY = "1"; public static final String DEPARTMENT = "2"; + @JSONField(ordinal = 1) private String key; - private String id; + @JSONField(ordinal = 2) private String title; + @JSONField(ordinal = 3) + private String id; + @JSONField(ordinal = 4) + private List children; private String type; private String canceled; - private List children; private boolean disabled; private String cancelSql; @@ -42,24 +47,24 @@ public class TreeSelect { children = new ArrayList<>(); RecordSet rs = new RecordSet(); if (COMPANY.equals(type)) { - String sql = "select id ,subcompanyname ,canceled from hrmsubcompany where " + getCancelSqlStr() + " and (supsubcomid is null or supsubcomid = 0) and companyid = ? order by showorder"; + String sql = "select id ,subcompanyname ,canceled from hrmsubcompany where " + getCancelSqlStr() + " and (supsubcomid is null or supsubcomid = 0) and companyid = ? order by showorder,id"; rs.executeQuery(sql, key); while (rs.next()) { children.add(TreeSelect.builder().key(rs.getString("id")).title(rs.getString("subcompanyname")).canceled(rs.getString("canceled")).type(SUB_COMPANY).cancelSql(cancelSql).build()); } } else if (SUB_COMPANY.equals(type)) { - String sql = "select id ,subcompanyname ,canceled from hrmsubcompany where " + getCancelSqlStr() + " and supsubcomid = ? order by showorder"; + String sql = "select id ,subcompanyname ,canceled from hrmsubcompany where " + getCancelSqlStr() + " and supsubcomid = ? order by showorder,id"; rs.executeQuery(sql, key); while (rs.next()) { children.add(TreeSelect.builder().key(rs.getString("id")).title(rs.getString("subcompanyname")).canceled(rs.getString("canceled")).type(SUB_COMPANY).cancelSql(cancelSql).build()); } - sql = "select id,departmentname ,canceled from hrmdepartment where " + getCancelSqlStr() + " and (supdepid is null or supdepid =0) and subcompanyid1 = ? order by showorder"; + sql = "select id,departmentname ,canceled from hrmdepartment where " + getCancelSqlStr() + " and (supdepid is null or supdepid =0) and subcompanyid1 = ? order by showorder,id"; rs.executeQuery(sql, key); while (rs.next()) { children.add(TreeSelect.builder().key(rs.getString("id")).title(rs.getString("departmentname")).canceled(rs.getString("canceled")).type(DEPARTMENT).cancelSql(cancelSql).build()); } } else if (DEPARTMENT.equals(type)) { - String sql = "select id,departmentname ,canceled from hrmdepartment where " + getCancelSqlStr() + " and supdepid = ? order by showorder"; + String sql = "select id,departmentname ,canceled from hrmdepartment where " + getCancelSqlStr() + " and supdepid = ? order by showorder,id"; rs.executeQuery(sql, key); while (rs.next()) { children.add(TreeSelect.builder().key(rs.getString("id")).title(rs.getString("departmentname")).canceled(rs.getString("canceled")).type(DEPARTMENT).cancelSql(cancelSql).build()); @@ -83,7 +88,7 @@ public class TreeSelect { } public String getId() { - return key; + return getKey(); } public String getCanceled() { diff --git a/src/com/engine/organization/service/impl/ChartServiceImpl.java b/src/com/engine/organization/service/impl/ChartServiceImpl.java index cf7aa53d..eb5ec065 100644 --- a/src/com/engine/organization/service/impl/ChartServiceImpl.java +++ b/src/com/engine/organization/service/impl/ChartServiceImpl.java @@ -476,15 +476,17 @@ public class ChartServiceImpl extends Service implements ChartService { @Override public Map getMovingTree(Map params) { RecordSet rs = new RecordSet(); + rs.executeQuery("select id,companyname from hrmcompany"); + TreeSelect companyTree = null; + List expandedKeys = new ArrayList<>(); String canceled = Util.null2String(params.get("canceled")); - rs.executeQuery("select id,subcompanyname,canceled from hrmsubcompany where (canceled is null or canceled != 1) and (supsubcomid is null or supsubcomid = 0) order by showorder"); - List movingTrees = new ArrayList<>(); - while(rs.next()){ - movingTrees.add(TreeSelect.builder().key(rs.getString("id")).title(rs.getString("subcompanyname")).type(TreeSelect.SUB_COMPANY).cancelSql(canceled).build()); + if(rs.next()){ + companyTree = TreeSelect.builder().key(rs.getString("id")).title(rs.getString("companyname")).type(TreeSelect.COMPANY).cancelSql(canceled).build(); + expandedKeys.add(companyTree.getKey()); } Map result = new HashMap<>(3); - result.put("movingTree", movingTrees); - result.put("expandedKeys", movingTrees.stream().filter(item -> CollectionUtils.isNotEmpty(item.getChildren())).map(TreeSelect::getKey).collect(Collectors.toList())); + result.put("movingTree", Collections.singletonList(companyTree)); + result.put("expandedKeys", expandedKeys); result.put("api_status", true); return result; } @@ -1288,6 +1290,7 @@ public class ChartServiceImpl extends Service implements ChartService { if (isCurrentDimension) { sql = "select " + dbType.concat("d", "id") + "as id, id as value, departmentname as title, " + dbType.concat("d", "supdepid") + " as pId from hrmdepartmentvirtual where (canceled is null or canceled != '1') and " + dbType.ifNull("supdepid", "0") + " = " + subCompany; } + sql += " order by showorder,id "; } else { sql = "select " + dbType.concat("d", "departmentid") + "as id, departmentid as value, departmentname as title, " + dbType.concat("d", "supdepartmentid") + " as pId from jcl_chart_department where (canceled is null or canceled != '1') and " + dbType.ifNull("supdepartmentid", "0") + " = " + subCompany; if (isCurrentDimension) { @@ -1298,18 +1301,19 @@ public class ChartServiceImpl extends Service implements ChartService { } } else { if (isSearchCurrent) { - sql = "select id as id, id as value, subcompanyname as title, supsubcomid as pId from hrmsubcompany where (canceled is null or canceled != '1') and " + dbType.ifNull("supsubcomid", "0") + " = " + subCompany + - " union select " + dbType.concat("d", "id") + "as id, id as value, departmentname as title, subcompanyid1 as pId from hrmdepartment where (canceled is null or canceled != '1') and " + dbType.ifNull("subcompanyid1", "0") + " = " + subCompany; + sql = "select id as id, id as value, subcompanyname as title, supsubcomid as pId, showorder from hrmsubcompany where (canceled is null or canceled != '1') and " + dbType.ifNull("supsubcomid", "0") + " = " + subCompany + + " union select " + dbType.concat("d", "id") + "as id, id as value, departmentname as title, subcompanyid1 as pId, showorder from hrmdepartment where (canceled is null or canceled != '1') and (supdepid is null or supdepid =0) and " + dbType.ifNull("subcompanyid1", "0") + " = " + subCompany; if (isCurrentDimension) { sql = "select id as id, id as value, subcompanyname as title, supsubcomid as pId from hrmsubcompanyvirtual where (canceled is null or canceled != '1') and " + dbType.ifNull("supsubcomid", "0") + " = " + subCompany + " and companyid = '" + dimension + "' " + - " union select " + dbType.concat("d", "id") + "as id, id as value, departmentname as title, subcompanyid1 as pId from hrmdepartmentvirtual where (canceled is null or canceled != '1') and " + dbType.ifNull("subcompanyid1", "0") + " = " + subCompany; + " union select " + dbType.concat("d", "id") + "as id, id as value, departmentname as title, subcompanyid1 as pId from hrmdepartmentvirtual where (canceled is null or canceled != '1') and (supdepid is null or supdepid =0) and" + dbType.ifNull("subcompanyid1", "0") + " = " + subCompany; } + sql += " order by showorder,id "; } else { sql = "select subcompanyid as id, subcompanyid as value, subcompanyname as title, supsubcompanyid as pId from jcl_chart_subcompany where (canceled is null or canceled != '1') and " + dbType.ifNull("supsubcompanyid", "0") + " = " + subCompany + - " union select " + dbType.concat("d", "subcompanyid") + "as id, subcompanyid as value, departmentname as title, subcompanyid as pId from jcl_chart_department where (canceled is null or canceled != '1') and " + dbType.ifNull("subcompanyid", "0") + " = " + subCompany; + " union select " + dbType.concat("d", "subcompanyid") + "as id, subcompanyid as value, departmentname as title, subcompanyid as pId from jcl_chart_department where (canceled is null or canceled != '1') and (supdepartmentid is null or supdepartmentid =0) and " + dbType.ifNull("subcompanyid", "0") + " = " + subCompany; if (isCurrentDimension) { sql = "select subcompanyvirtualid as id, subcompanyvirtualid as value, subcompanyname as title, supsubcompanyid as pId from jcl_chart_subcompanyvirtual where (canceled is null or canceled != '1') and " + dbType.ifNull("supsubcompanyid", "0") + " = " + subCompany + " and companyid = '" + dimension + "' " + - " union select " + dbType.concat("d", "departmentvirtualid") + "as id, departmentvirtualid as value, departmentname as title, subcompanyid as pId from jcl_chart_departmentvirtual where (canceled is null or canceled != '1') and " + dbType.ifNull("subcompanyid", "0") + " = " + subCompany; + " union select " + dbType.concat("d", "departmentvirtualid") + "as id, departmentvirtualid as value, departmentname as title, subcompanyid as pId from jcl_chart_departmentvirtual where (canceled is null or canceled != '1') and (supdepid is null or supdepid =0) and" + dbType.ifNull("subcompanyid", "0") + " = " + subCompany; } // 添加时间轴条件 sql += " and versionid = " + versionId;