Merge remote-tracking branch 'origin/develop' into feature/ml
commit
50ee698cc2
@ -0,0 +1,106 @@
|
|||||||
|
package com.engine.organization.entity.chart;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import org.apache.commons.collections.CollectionUtils;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import weaver.conn.RecordSet;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author:dxfeng
|
||||||
|
* @createTime: 2023/07/25
|
||||||
|
* @version: 1.0
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Builder
|
||||||
|
public class TreeSelect {
|
||||||
|
public static final String COMPANY = "0";
|
||||||
|
public static final String SUB_COMPANY = "1";
|
||||||
|
public static final String DEPARTMENT = "2";
|
||||||
|
|
||||||
|
private String key;
|
||||||
|
private String id;
|
||||||
|
private String title;
|
||||||
|
private String type;
|
||||||
|
private String canceled;
|
||||||
|
private List<TreeSelect> children;
|
||||||
|
|
||||||
|
private String cancelSql;
|
||||||
|
|
||||||
|
public List<TreeSelect> getChildren() {
|
||||||
|
if (null != children) {
|
||||||
|
return children;
|
||||||
|
}
|
||||||
|
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";
|
||||||
|
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";
|
||||||
|
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";
|
||||||
|
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";
|
||||||
|
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());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return CollectionUtils.isEmpty(children) ? null : children;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getKey() {
|
||||||
|
switch (type) {
|
||||||
|
case COMPANY:
|
||||||
|
return "c" + key;
|
||||||
|
case SUB_COMPANY:
|
||||||
|
return "s" + key;
|
||||||
|
case DEPARTMENT:
|
||||||
|
return "d" + key;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return key;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getId() {
|
||||||
|
return key;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCanceled() {
|
||||||
|
if (StringUtils.isBlank(canceled)) {
|
||||||
|
return "0";
|
||||||
|
}
|
||||||
|
return canceled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCancelSql() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getCancelSqlStr() {
|
||||||
|
if (StringUtils.isNotBlank(cancelSql) && "1".equals(cancelSql)) {
|
||||||
|
return " 1=1 ";
|
||||||
|
} else {
|
||||||
|
return " (canceled is null or canceled != 1) ";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue