Merge pull request 'feature/dxf' (#197) from feature/dxf into develop
Reviewed-on: #197pull/199/head
commit
7ab3436182
@ -0,0 +1,74 @@
|
||||
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 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 MovingTree {
|
||||
public static final String SUB_COMPANY = "subCompany";
|
||||
public static final String DEPARTMENT = "department";
|
||||
|
||||
private String key;
|
||||
private String id;
|
||||
private String title;
|
||||
private String type;
|
||||
private List<MovingTree> children;
|
||||
|
||||
public List<MovingTree> getChildren() {
|
||||
if (null != children) {
|
||||
return children;
|
||||
}
|
||||
children = new ArrayList<>();
|
||||
RecordSet rs = new RecordSet();
|
||||
if (SUB_COMPANY.equals(type)) {
|
||||
String sql = "select id ,subcompanyname from hrmsubcompany where (canceled is null or canceled != 1) and supsubcomid = ? order by showorder desc";
|
||||
rs.executeQuery(sql, key);
|
||||
while (rs.next()) {
|
||||
children.add(MovingTree.builder().key(rs.getString("id")).title(rs.getString("subcompanyname")).type(SUB_COMPANY).build());
|
||||
}
|
||||
sql = "select id,departmentname from hrmdepartment where (canceled is null or canceled != 1) and (supdepid is null or supdepid =0) and subcompanyid1 = ? order by showorder desc";
|
||||
rs.executeQuery(sql, key);
|
||||
while (rs.next()) {
|
||||
children.add(MovingTree.builder().key(rs.getString("id")).title(rs.getString("departmentname")).type(DEPARTMENT).build());
|
||||
}
|
||||
} else if (DEPARTMENT.equals(type)) {
|
||||
String sql = "select id,departmentname from hrmdepartment where (canceled is null or canceled != 1) and supdepid = ? order by showorder desc";
|
||||
rs.executeQuery(sql, key);
|
||||
while (rs.next()) {
|
||||
children.add(MovingTree.builder().key(rs.getString("id")).title(rs.getString("departmentname")).type(DEPARTMENT).build());
|
||||
}
|
||||
}
|
||||
return CollectionUtils.isEmpty(children) ? null : children;
|
||||
}
|
||||
|
||||
public String getKey() {
|
||||
switch (type) {
|
||||
case SUB_COMPANY:
|
||||
return "s" + key;
|
||||
case DEPARTMENT:
|
||||
return "d" + key;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return key;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return key;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue