组织管理,TreeSelect组件全量接口开发
This commit is contained in:
parent
b74d06bf07
commit
1280b3c6b9
|
|
@ -19,7 +19,8 @@ import java.util.List;
|
|||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Builder
|
||||
public class MovingTree {
|
||||
public class TreeSelect {
|
||||
public static final String COMPANY = "company";
|
||||
public static final String SUB_COMPANY = "subCompany";
|
||||
public static final String DEPARTMENT = "department";
|
||||
|
||||
|
|
@ -27,30 +28,37 @@ public class MovingTree {
|
|||
private String id;
|
||||
private String title;
|
||||
private String type;
|
||||
private List<MovingTree> children;
|
||||
private String icon;
|
||||
private List<TreeSelect> children;
|
||||
|
||||
public List<MovingTree> getChildren() {
|
||||
public List<TreeSelect> getChildren() {
|
||||
if (null != children) {
|
||||
return children;
|
||||
}
|
||||
children = new ArrayList<>();
|
||||
RecordSet rs = new RecordSet();
|
||||
if (SUB_COMPANY.equals(type)) {
|
||||
if (COMPANY.equals(type)) {
|
||||
String sql = "select id ,subcompanyname from hrmsubcompany where (canceled is null or canceled != 1) and (supsubcomid is null or supsubcomid = 0) and companyid = ? order by showorder desc";
|
||||
rs.executeQuery(sql, key);
|
||||
while (rs.next()) {
|
||||
children.add(TreeSelect.builder().key(rs.getString("id")).title(rs.getString("subcompanyname")).type(SUB_COMPANY).build());
|
||||
}
|
||||
} else 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());
|
||||
children.add(TreeSelect.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());
|
||||
children.add(TreeSelect.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());
|
||||
children.add(TreeSelect.builder().key(rs.getString("id")).title(rs.getString("departmentname")).type(DEPARTMENT).build());
|
||||
}
|
||||
}
|
||||
return CollectionUtils.isEmpty(children) ? null : children;
|
||||
|
|
@ -58,6 +66,8 @@ public class MovingTree {
|
|||
|
||||
public String getKey() {
|
||||
switch (type) {
|
||||
case COMPANY:
|
||||
return "c" + key;
|
||||
case SUB_COMPANY:
|
||||
return "s" + key;
|
||||
case DEPARTMENT:
|
||||
|
|
@ -43,6 +43,7 @@ public interface ChartService {
|
|||
|
||||
/**
|
||||
* 组织架构图,版本记录
|
||||
*
|
||||
* @param params 请求参数
|
||||
* @return 数据集合
|
||||
*/
|
||||
|
|
@ -63,4 +64,12 @@ public interface ChartService {
|
|||
* @return
|
||||
*/
|
||||
Map<String, Object> getMovingTree(Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* 获取完整TreeSelect数据
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
Map<String, Object> getFullSelectTree(Map<String, Object> params);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import com.engine.common.util.ServiceUtil;
|
|||
import com.engine.core.impl.Service;
|
||||
import com.engine.organization.entity.chart.ChartPO;
|
||||
import com.engine.organization.entity.chart.CompanyTreePO;
|
||||
import com.engine.organization.entity.chart.MovingTree;
|
||||
import com.engine.organization.entity.chart.TreeSelect;
|
||||
import com.engine.organization.mapper.hrmresource.SystemDataMapper;
|
||||
import com.engine.organization.mapper.jclorgmap.JclOrgMapper;
|
||||
import com.engine.organization.service.ChartService;
|
||||
|
|
@ -477,13 +477,32 @@ public class ChartServiceImpl extends Service implements ChartService {
|
|||
public Map<String, Object> getMovingTree(Map<String, Object> params) {
|
||||
RecordSet rs = new RecordSet();
|
||||
rs.executeQuery("select id,subcompanyname from hrmsubcompany where (canceled is null or canceled != 1) and (supsubcomid is null or supsubcomid = 0)");
|
||||
List<MovingTree> movingTrees = new ArrayList<>();
|
||||
List<TreeSelect> movingTrees = new ArrayList<>();
|
||||
while(rs.next()){
|
||||
movingTrees.add(MovingTree.builder().key(rs.getString("id")).title(rs.getString("subcompanyname")).type(MovingTree.SUB_COMPANY).build());
|
||||
movingTrees.add(TreeSelect.builder().key(rs.getString("id")).title(rs.getString("subcompanyname")).type(TreeSelect.SUB_COMPANY).build());
|
||||
}
|
||||
Map<String, Object> result = new HashMap<>(2);
|
||||
result.put("movingTree", movingTrees);
|
||||
result.put("expandedKeys", movingTrees.stream().map(MovingTree::getKey).collect(Collectors.toList()));
|
||||
result.put("expandedKeys", movingTrees.stream().map(TreeSelect::getKey).collect(Collectors.toList()));
|
||||
result.put("api_status", true);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getFullSelectTree(Map<String, Object> params) {
|
||||
RecordSet rs = new RecordSet();
|
||||
rs.executeQuery("select id,companyname from hrmcompany");
|
||||
TreeSelect companyTree = null;
|
||||
List<String> expandedKeys = new ArrayList<>();
|
||||
if(rs.next()){
|
||||
companyTree = TreeSelect.builder().key(rs.getString("id")).title(rs.getString("companyname")).type(TreeSelect.COMPANY).build();
|
||||
expandedKeys = companyTree.getChildren().stream().map(TreeSelect::getKey).collect(Collectors.toList());
|
||||
expandedKeys.add(companyTree.getKey());
|
||||
}
|
||||
|
||||
Map<String, Object> result = new HashMap<>(2);
|
||||
result.put("selectTree", companyTree);
|
||||
result.put("expandedKeys", expandedKeys);
|
||||
result.put("api_status", true);
|
||||
return result;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -158,6 +158,26 @@ public class OrgChartController {
|
|||
return JSONObject.toJSONString(apidatas);
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("/getFullSelectTree")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public String getFullSelectTree(@Context HttpServletRequest request, @Context HttpServletResponse response) {
|
||||
Map<String, Object> apidatas = new HashMap<>();
|
||||
try {
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
//实例化Service 并调用业务类处理
|
||||
apidatas = getOrgChartWrapper(user).getFullSelectTree(ParamUtil.request2Map(request), user);
|
||||
apidatas.put("api_status", true);
|
||||
} catch (Exception e) {
|
||||
//异常处理
|
||||
e.printStackTrace();
|
||||
apidatas.put("api_status", false);
|
||||
apidatas.put("api_errormsg", "catch exception : " + e.getMessage());
|
||||
}
|
||||
//数据转换
|
||||
return JSONObject.toJSONString(apidatas);
|
||||
}
|
||||
|
||||
/**
|
||||
* 组织架构数据
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -76,4 +76,8 @@ public class OrgChartWrapper extends Service {
|
|||
public Map<String, Object> getMovingTree(Map<String, Object> request2Map, User user) {
|
||||
return getChartService(user).getMovingTree(request2Map);
|
||||
}
|
||||
|
||||
public Map<String, Object> getFullSelectTree(Map<String, Object> request2Map, User user) {
|
||||
return getChartService(user).getFullSelectTree(request2Map);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue