Merge remote-tracking branch 'origin/develop' into feature/ml

pull/200/head
Mlin 2 years ago
commit 315a67173d

@ -21,6 +21,7 @@ public class CompanyTreePO {
private String title; private String title;
private boolean isLeaf; private boolean isLeaf;
private String key; private String key;
private boolean disabled;
public boolean getIsLeaf() { public boolean getIsLeaf() {
return isLeaf; return isLeaf;
@ -33,4 +34,8 @@ public class CompanyTreePO {
public String getKey() { public String getKey() {
return id; return id;
} }
public String getValue() {
return id;
}
} }

@ -1,5 +1,6 @@
package com.engine.organization.entity.chart; package com.engine.organization.entity.chart;
import com.alibaba.fastjson.annotation.JSONField;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Builder; import lombok.Builder;
import lombok.Data; import lombok.Data;
@ -25,12 +26,17 @@ public class TreeSelect {
public static final String SUB_COMPANY = "1"; public static final String SUB_COMPANY = "1";
public static final String DEPARTMENT = "2"; public static final String DEPARTMENT = "2";
@JSONField(ordinal = 1)
private String key; private String key;
private String id; @JSONField(ordinal = 2)
private String title; private String title;
@JSONField(ordinal = 3)
private String id;
@JSONField(ordinal = 4)
private List<TreeSelect> children;
private String type; private String type;
private String canceled; private String canceled;
private List<TreeSelect> children; private boolean disabled;
private String cancelSql; private String cancelSql;
@ -41,24 +47,24 @@ public class TreeSelect {
children = new ArrayList<>(); children = new ArrayList<>();
RecordSet rs = new RecordSet(); RecordSet rs = new RecordSet();
if (COMPANY.equals(type)) { 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); rs.executeQuery(sql, key);
while (rs.next()) { 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()); 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)) { } 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); rs.executeQuery(sql, key);
while (rs.next()) { 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()); 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); rs.executeQuery(sql, key);
while (rs.next()) { while (rs.next()) {
children.add(TreeSelect.builder().key(rs.getString("id")).title(rs.getString("departmentname")).canceled(rs.getString("canceled")).type(DEPARTMENT).cancelSql(cancelSql).build()); 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)) { } 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); rs.executeQuery(sql, key);
while (rs.next()) { while (rs.next()) {
children.add(TreeSelect.builder().key(rs.getString("id")).title(rs.getString("departmentname")).canceled(rs.getString("canceled")).type(DEPARTMENT).cancelSql(cancelSql).build()); children.add(TreeSelect.builder().key(rs.getString("id")).title(rs.getString("departmentname")).canceled(rs.getString("canceled")).type(DEPARTMENT).cancelSql(cancelSql).build());
@ -82,7 +88,7 @@ public class TreeSelect {
} }
public String getId() { public String getId() {
return key; return getKey();
} }
public String getCanceled() { public String getCanceled() {

@ -467,9 +467,9 @@ public class ChartServiceImpl extends Service implements ChartService {
String sql = getDepartmentTreeSql(versionId, dimension, subCompany); String sql = getDepartmentTreeSql(versionId, dimension, subCompany);
rs.executeQuery(sql); rs.executeQuery(sql);
while (rs.next()) { 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); result.put("api_status", true);
return result; return result;
} }
@ -477,15 +477,17 @@ public class ChartServiceImpl extends Service implements ChartService {
@Override @Override
public Map<String, Object> getMovingTree(Map<String, Object> params) { public Map<String, Object> getMovingTree(Map<String, Object> params) {
RecordSet rs = new RecordSet(); RecordSet rs = new RecordSet();
rs.executeQuery("select id,companyname from hrmcompany");
TreeSelect companyTree = null;
List<String> expandedKeys = new ArrayList<>();
String canceled = Util.null2String(params.get("canceled")); 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"); if(rs.next()){
List<TreeSelect> movingTrees = new ArrayList<>(); companyTree = TreeSelect.builder().key(rs.getString("id")).title(rs.getString("companyname")).type(TreeSelect.COMPANY).cancelSql(canceled).build();
while(rs.next()){ expandedKeys.add(companyTree.getKey());
movingTrees.add(TreeSelect.builder().key(rs.getString("id")).title(rs.getString("subcompanyname")).type(TreeSelect.SUB_COMPANY).cancelSql(canceled).build());
} }
Map<String, Object> result = new HashMap<>(3); Map<String, Object> result = new HashMap<>(3);
result.put("movingTree", movingTrees); result.put("movingTree", Collections.singletonList(companyTree));
result.put("expandedKeys", movingTrees.stream().filter(item -> CollectionUtils.isNotEmpty(item.getChildren())).map(TreeSelect::getKey).collect(Collectors.toList())); result.put("expandedKeys", expandedKeys);
result.put("api_status", true); result.put("api_status", true);
return result; return result;
} }
@ -502,7 +504,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 = companyTree.getChildren().stream().filter(item -> CollectionUtils.isNotEmpty(item.getChildren())).map(TreeSelect::getKey).collect(Collectors.toList());
expandedKeys.add(companyTree.getKey()); expandedKeys.add(companyTree.getKey());
} }
disableTreeItem(Collections.singletonList(companyTree),TreeSelect.DEPARTMENT);
Map<String, Object> result = new HashMap<>(3); Map<String, Object> result = new HashMap<>(3);
result.put("selectTree", companyTree); result.put("selectTree", companyTree);
result.put("expandedKeys", expandedKeys); result.put("expandedKeys", expandedKeys);
@ -510,6 +512,23 @@ public class ChartServiceImpl extends Service implements ChartService {
return result; return result;
} }
/**
*
*
* @param companyTreeList TreeSelect
*/
private void disableTreeItem(List<TreeSelect> companyTreeList, String enableTreeType) {
if (CollectionUtils.isNotEmpty(companyTreeList)) {
for (TreeSelect treeSelect : companyTreeList) {
treeSelect.setDisabled(!enableTreeType.equals(treeSelect.getType()));
List<TreeSelect> children = treeSelect.getChildren();
if (CollectionUtils.isNotEmpty(children)) {
disableTreeItem(children, enableTreeType);
}
}
}
}
private void trueDimension(RecordSetTrans recordSetTrans,String versionId,String currentUser,String currentDate){ private void trueDimension(RecordSetTrans recordSetTrans,String versionId,String currentUser,String currentDate){
RecordSet rs = new RecordSet(); RecordSet rs = new RecordSet();
rs.execute("delete from jcl_chart_subcompany where versionid = "+versionId); rs.execute("delete from jcl_chart_subcompany where versionid = "+versionId);
@ -1272,6 +1291,7 @@ public class ChartServiceImpl extends Service implements ChartService {
if (isCurrentDimension) { 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 = "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 { } 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; 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) { if (isCurrentDimension) {
@ -1282,18 +1302,19 @@ public class ChartServiceImpl extends Service implements ChartService {
} }
} else { } else {
if (isSearchCurrent) { 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 + 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 from hrmdepartment 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, 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) { 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 + "' " + 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 { } 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 + 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) { 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 + "' " + 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; sql += " and versionid = " + versionId;

Loading…
Cancel
Save