|
|
|
package com.engine.organization.web;
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
import com.engine.common.util.ParamUtil;
|
|
|
|
import com.engine.common.util.ServiceUtil;
|
|
|
|
import com.engine.organization.util.response.ReturnResult;
|
|
|
|
import com.engine.organization.wrapper.OrgChartWrapper;
|
|
|
|
import weaver.hrm.HrmUserVarify;
|
|
|
|
import weaver.hrm.User;
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
import javax.ws.rs.GET;
|
|
|
|
import javax.ws.rs.Path;
|
|
|
|
import javax.ws.rs.Produces;
|
|
|
|
import javax.ws.rs.core.Context;
|
|
|
|
import javax.ws.rs.core.MediaType;
|
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
|
|
|
public class OrgChartController {
|
|
|
|
public OrgChartWrapper getOrgChartWrapper(User user) {
|
|
|
|
return ServiceUtil.getService(OrgChartWrapper.class, user);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 获取组织维度信息
|
|
|
|
*/
|
|
|
|
@GET
|
|
|
|
@Path("/getCondition")
|
|
|
|
@Produces(MediaType.APPLICATION_JSON)
|
|
|
|
public String getCondition(@Context HttpServletRequest request, @Context HttpServletResponse response) {
|
|
|
|
Map<String, Object> apidatas = new HashMap<>();
|
|
|
|
try {
|
|
|
|
User user = HrmUserVarify.getUser(request, response);
|
|
|
|
//实例化Service 并调用业务类处理
|
|
|
|
apidatas = getOrgChartWrapper(user).getOptionCondition(ParamUtil.request2Map(request), user);
|
|
|
|
} catch (Exception e) {
|
|
|
|
//异常处理
|
|
|
|
e.printStackTrace();
|
|
|
|
apidatas.put("api_status", false);
|
|
|
|
apidatas.put("api_errormsg", "catch exception : " + e.getMessage());
|
|
|
|
}
|
|
|
|
//数据转换
|
|
|
|
return JSONObject.toJSONString(apidatas);
|
|
|
|
}
|
|
|
|
|
|
|
|
@GET
|
|
|
|
@Path("/timeLines")
|
|
|
|
@Produces(MediaType.APPLICATION_JSON)
|
|
|
|
public String searchTimeLines(@Context HttpServletRequest request, @Context HttpServletResponse response) {
|
|
|
|
Map<String, Object> apidatas = new HashMap<>();
|
|
|
|
try {
|
|
|
|
User user = HrmUserVarify.getUser(request, response);
|
|
|
|
apidatas = getOrgChartWrapper(user).searchTimeLines(ParamUtil.request2Map(request), user);
|
|
|
|
} catch (Exception e) {
|
|
|
|
//异常处理
|
|
|
|
e.printStackTrace();
|
|
|
|
apidatas.put("api_status", false);
|
|
|
|
apidatas.put("api_errormsg", "catch exception : " + e.getMessage());
|
|
|
|
}
|
|
|
|
return JSONObject.toJSONString(apidatas);
|
|
|
|
}
|
|
|
|
|
|
|
|
@GET
|
|
|
|
@Path("/getDepartmentDetail")
|
|
|
|
@Produces(MediaType.APPLICATION_JSON)
|
|
|
|
public String getDepartmentDetail(@Context HttpServletRequest request, @Context HttpServletResponse response) {
|
|
|
|
Map<String, Object> apidatas = new HashMap<>();
|
|
|
|
try {
|
|
|
|
User user = HrmUserVarify.getUser(request, response);
|
|
|
|
apidatas = getOrgChartWrapper(user).getDepartmentDetail(ParamUtil.request2Map(request), user);
|
|
|
|
} catch (Exception e) {
|
|
|
|
//异常处理
|
|
|
|
e.printStackTrace();
|
|
|
|
apidatas.put("api_status", false);
|
|
|
|
apidatas.put("api_errormsg", "catch exception : " + e.getMessage());
|
|
|
|
}
|
|
|
|
return JSONObject.toJSONString(apidatas);
|
|
|
|
}
|
|
|
|
|
|
|
|
@GET
|
|
|
|
@Path("/versionRecord")
|
|
|
|
@Produces(MediaType.APPLICATION_JSON)
|
|
|
|
public String versionRecord(@Context HttpServletRequest request, @Context HttpServletResponse response) {
|
|
|
|
Map<String, Object> apidatas = new HashMap<>();
|
|
|
|
try {
|
|
|
|
User user = HrmUserVarify.getUser(request, response);
|
|
|
|
apidatas = getOrgChartWrapper(user).versionRecord(ParamUtil.request2Map(request), user);
|
|
|
|
} catch (Exception e) {
|
|
|
|
//异常处理
|
|
|
|
e.printStackTrace();
|
|
|
|
apidatas.put("api_status", false);
|
|
|
|
apidatas.put("api_errormsg", "catch exception : " + e.getMessage());
|
|
|
|
}
|
|
|
|
return JSONObject.toJSONString(apidatas);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@GET
|
|
|
|
@Path("/getSubCompanyTree")
|
|
|
|
@Produces(MediaType.APPLICATION_JSON)
|
|
|
|
public String getSubCompanyTree(@Context HttpServletRequest request, @Context HttpServletResponse response) {
|
|
|
|
Map<String, Object> apidatas = new HashMap<>();
|
|
|
|
try {
|
|
|
|
User user = HrmUserVarify.getUser(request, response);
|
|
|
|
//实例化Service 并调用业务类处理
|
|
|
|
apidatas = getOrgChartWrapper(user).getSubCompanyTree(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);
|
|
|
|
}
|
|
|
|
|
|
|
|
@GET
|
|
|
|
@Path("/getDepartmentTree")
|
|
|
|
@Produces(MediaType.APPLICATION_JSON)
|
|
|
|
public String getDepartmentTree(@Context HttpServletRequest request, @Context HttpServletResponse response) {
|
|
|
|
Map<String, Object> apidatas = new HashMap<>();
|
|
|
|
try {
|
|
|
|
User user = HrmUserVarify.getUser(request, response);
|
|
|
|
//实例化Service 并调用业务类处理
|
|
|
|
apidatas = getOrgChartWrapper(user).getDepartmentTree(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);
|
|
|
|
}
|
|
|
|
|
|
|
|
@GET
|
|
|
|
@Path("/getMovingTree")
|
|
|
|
@Produces(MediaType.APPLICATION_JSON)
|
|
|
|
public String getMovingTree(@Context HttpServletRequest request, @Context HttpServletResponse response) {
|
|
|
|
Map<String, Object> apidatas = new HashMap<>();
|
|
|
|
try {
|
|
|
|
User user = HrmUserVarify.getUser(request, response);
|
|
|
|
//实例化Service 并调用业务类处理
|
|
|
|
apidatas = getOrgChartWrapper(user).getMovingTree(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);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 组织架构数据
|
|
|
|
*/
|
|
|
|
@GET
|
|
|
|
@Path("/companyData")
|
|
|
|
@Produces(MediaType.APPLICATION_JSON)
|
|
|
|
public String getCompanyData(@Context HttpServletRequest request, @Context HttpServletResponse
|
|
|
|
response) {
|
|
|
|
Map<String, Object> apidatas = new HashMap<>();
|
|
|
|
try {
|
|
|
|
User user = HrmUserVarify.getUser(request, response);
|
|
|
|
//实例化Service 并调用业务类处理
|
|
|
|
apidatas = getOrgChartWrapper(user).getCompanyData(ParamUtil.request2Map(request), user);
|
|
|
|
} catch (Exception e) {
|
|
|
|
//异常处理
|
|
|
|
e.printStackTrace();
|
|
|
|
apidatas.put("api_status", false);
|
|
|
|
apidatas.put("api_errormsg", "catch exception : " + e.getMessage());
|
|
|
|
}
|
|
|
|
//数据转换
|
|
|
|
return JSONObject.toJSONString(apidatas);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 组织透视图
|
|
|
|
*/
|
|
|
|
@GET
|
|
|
|
@Path("/userData")
|
|
|
|
@Produces(MediaType.APPLICATION_JSON)
|
|
|
|
public String getUserData(@Context HttpServletRequest request, @Context HttpServletResponse
|
|
|
|
response) {
|
|
|
|
Map<String, Object> apidatas = new HashMap<String, Object>();
|
|
|
|
try {
|
|
|
|
User user = HrmUserVarify.getUser(request, response);
|
|
|
|
//实例化Service 并调用业务类处理
|
|
|
|
apidatas = getOrgChartWrapper(user).getUserData(ParamUtil.request2Map(request), user);
|
|
|
|
} catch (Exception e) {
|
|
|
|
//异常处理
|
|
|
|
e.printStackTrace();
|
|
|
|
apidatas.put("api_status", false);
|
|
|
|
apidatas.put("api_errormsg", "catch exception : " + e.getMessage());
|
|
|
|
}
|
|
|
|
//数据转换
|
|
|
|
return JSONObject.toJSONString(apidatas);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 异步人员数据
|
|
|
|
*/
|
|
|
|
@GET
|
|
|
|
@Path("/asyncUserData")
|
|
|
|
@Produces(MediaType.APPLICATION_JSON)
|
|
|
|
public String asyncUserData(@Context HttpServletRequest request, @Context HttpServletResponse
|
|
|
|
response) {
|
|
|
|
Map<String, Object> apidatas = new HashMap<String, Object>();
|
|
|
|
try {
|
|
|
|
User user = HrmUserVarify.getUser(request, response);
|
|
|
|
//实例化Service 并调用业务类处理
|
|
|
|
apidatas = getOrgChartWrapper(user).asyncUserData(ParamUtil.request2Map(request), user);
|
|
|
|
} catch (Exception e) {
|
|
|
|
//异常处理
|
|
|
|
e.printStackTrace();
|
|
|
|
apidatas.put("api_status", false);
|
|
|
|
apidatas.put("api_errormsg", "catch exception : " + e.getMessage());
|
|
|
|
}
|
|
|
|
//数据转换
|
|
|
|
return JSONObject.toJSONString(apidatas);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 异步组织数据
|
|
|
|
*/
|
|
|
|
@GET
|
|
|
|
@Path("/asyncCompanyData")
|
|
|
|
@Produces(MediaType.APPLICATION_JSON)
|
|
|
|
public String asyncCompanyData(@Context HttpServletRequest request, @Context HttpServletResponse
|
|
|
|
response) {
|
|
|
|
Map<String, Object> apidatas = new HashMap<String, Object>();
|
|
|
|
try {
|
|
|
|
User user = HrmUserVarify.getUser(request, response);
|
|
|
|
//实例化Service 并调用业务类处理
|
|
|
|
apidatas = getOrgChartWrapper(user).asyncCompanyData(ParamUtil.request2Map(request), user);
|
|
|
|
} catch (Exception e) {
|
|
|
|
//异常处理
|
|
|
|
e.printStackTrace();
|
|
|
|
apidatas.put("api_status", false);
|
|
|
|
apidatas.put("api_errormsg", "catch exception : " + e.getMessage());
|
|
|
|
}
|
|
|
|
//数据转换
|
|
|
|
return JSONObject.toJSONString(apidatas);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 异步组织数据
|
|
|
|
*/
|
|
|
|
@GET
|
|
|
|
@Path("/synchronousData")
|
|
|
|
@Produces(MediaType.APPLICATION_JSON)
|
|
|
|
public ReturnResult synchronousData(@Context HttpServletRequest request, @Context HttpServletResponse
|
|
|
|
response) {
|
|
|
|
try {
|
|
|
|
User user = HrmUserVarify.getUser(request, response);
|
|
|
|
Map<String, Object> params = ParamUtil.request2Map(request);
|
|
|
|
return ReturnResult.successed(getOrgChartWrapper(user).synchronousData(params));
|
|
|
|
} catch (Exception e) {
|
|
|
|
return ReturnResult.exceptionHandle(e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|