Merge branch 'feature/djp' into develop
commit
58f3aedf9d
@ -0,0 +1,13 @@
|
|||||||
|
package com.api.organization.web;
|
||||||
|
|
||||||
|
import javax.ws.rs.Path;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @className: OrgChartController
|
||||||
|
* @author: dengjp
|
||||||
|
* @date: 2022/7/7
|
||||||
|
* @description: 组织架构图
|
||||||
|
**/
|
||||||
|
@Path("/bs/hrmorganization/orgchart")
|
||||||
|
public class OrgChartController extends com.engine.organization.web.OrgChartController {
|
||||||
|
}
|
@ -0,0 +1,19 @@
|
|||||||
|
package com.engine.organization.service;
|
||||||
|
|
||||||
|
import weaver.hrm.User;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @className: OrgChartService
|
||||||
|
* @author: dengjp
|
||||||
|
* @date: 2022/7/7
|
||||||
|
* @description: 组织架构图Service
|
||||||
|
**/
|
||||||
|
public interface OrgChartService {
|
||||||
|
Map<String, Object> getOptionCondition(Map<String, Object> request2Map, User user);
|
||||||
|
|
||||||
|
Map<String, Object> getCompanyData(Map<String, Object> request2Map, User user);
|
||||||
|
|
||||||
|
Map<String, Object> getUserData(Map<String, Object> request2Map, User user);
|
||||||
|
}
|
@ -0,0 +1,249 @@
|
|||||||
|
package com.engine.organization.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.date.DateField;
|
||||||
|
import cn.hutool.core.date.DateUtil;
|
||||||
|
import com.engine.core.impl.Service;
|
||||||
|
import com.engine.organization.service.OrgChartService;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import weaver.conn.RecordSet;
|
||||||
|
import weaver.hrm.User;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @className: OrgChartServiceImpl
|
||||||
|
* @author: dengjp
|
||||||
|
* @date: 2022/7/7
|
||||||
|
* @description: 组织架构图ServiceImpl
|
||||||
|
**/
|
||||||
|
public class OrgChartServiceImpl extends Service implements OrgChartService {
|
||||||
|
@Override
|
||||||
|
public Map<String, Object> getOptionCondition(Map<String, Object> request2Map, User user) {
|
||||||
|
RecordSet rs = new RecordSet();
|
||||||
|
String type = (String) request2Map.get("type");
|
||||||
|
rs.executeQuery("select id, companyname from HrmCompanyVirtual order by id");
|
||||||
|
Map<String, Object> result = new HashMap<>();
|
||||||
|
List<Map<String, Object>> fclasslist = new ArrayList<>();
|
||||||
|
Map<String, Object> defaultItem = new HashMap<>();
|
||||||
|
defaultItem.put("id", "0");
|
||||||
|
defaultItem.put("companyname", "行政维度");
|
||||||
|
fclasslist.add(defaultItem);
|
||||||
|
while(rs.next()) {
|
||||||
|
Map<String, Object> item = new HashMap<>();
|
||||||
|
item.put("id", rs.getString("id"));
|
||||||
|
item.put("companyname", rs.getString("companyname"));
|
||||||
|
fclasslist.add(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
rs.executeQuery("select id, fnumber, fname from jcl_org_map " +("company".equals(type) ? "where ftype in (0, 1, 2)" : "") +" order by ftype , id ");
|
||||||
|
List<Map<String, Object>> companylist = new ArrayList<>();
|
||||||
|
Map<String, Object> defaultCompanyItem = new HashMap<>();
|
||||||
|
defaultCompanyItem.put("id", "0");
|
||||||
|
defaultCompanyItem.put("fname", "集团");
|
||||||
|
companylist.add(defaultCompanyItem);
|
||||||
|
while(rs.next()) {
|
||||||
|
Map<String, Object> item = new HashMap<>();
|
||||||
|
item.put("id", rs.getString("id"));
|
||||||
|
item.put("fnumber", rs.getString("fnumber"));
|
||||||
|
item.put("fname", rs.getString("fname"));
|
||||||
|
companylist.add(item);
|
||||||
|
}
|
||||||
|
result.put("api_status", true);
|
||||||
|
result.put("fclasslist", fclasslist);
|
||||||
|
result.put("companylist", companylist);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, Object> getCompanyData(Map<String, Object> request2Map, User user) {
|
||||||
|
String date = (String) request2Map.get("date"); // 数据日期
|
||||||
|
if(StringUtils.isBlank(date)) {
|
||||||
|
date = DateUtil.format( DateUtil.offset(new Date() , DateField.DAY_OF_MONTH, 1), "yyyy-MM-dd");
|
||||||
|
}
|
||||||
|
|
||||||
|
String fclass = (String) request2Map.get("fclass"); // 维度
|
||||||
|
String root = (String) request2Map.get("root"); // 根节点
|
||||||
|
String level = (String) request2Map.get("level"); // 显示层级
|
||||||
|
if(StringUtils.isBlank(level)) {
|
||||||
|
level = "3";
|
||||||
|
}
|
||||||
|
|
||||||
|
String fisvitual = (String) request2Map.get("fisvitual"); // 是否显示虚拟组织
|
||||||
|
if(StringUtils.isBlank(fisvitual)) {
|
||||||
|
fisvitual = "0";
|
||||||
|
}
|
||||||
|
|
||||||
|
String whereSql = " where 1 = 1 ";
|
||||||
|
whereSql += " and (fdatebegin <= '"+ date +"' and fdateend >= '"+ date +"') or (fdatebegin <= '"+ date +"' and fdateend is null ) ";
|
||||||
|
whereSql += " and fclass = " + fclass +" ";
|
||||||
|
|
||||||
|
if("0".equals(fisvitual)) {
|
||||||
|
whereSql += " and fisvitual = 0 ";
|
||||||
|
}else {
|
||||||
|
whereSql += " and fisvitual in (0, 1) ";
|
||||||
|
}
|
||||||
|
|
||||||
|
String whereItemSql = " ";
|
||||||
|
if("0".equals(root)) { // 集团的情况
|
||||||
|
whereItemSql += " and ftype = 0 ";
|
||||||
|
} else {
|
||||||
|
whereItemSql += " and id = '" + root +"' ";
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取根节点
|
||||||
|
RecordSet rs = new RecordSet();
|
||||||
|
rs.executeQuery("select id, fname, ftype, fparentid from jcl_org_map " + whereSql + whereItemSql);
|
||||||
|
List<Map<String, Object>> list = new ArrayList<>();
|
||||||
|
String id = null;
|
||||||
|
if(rs.next()) {
|
||||||
|
Map<String, Object> item = new HashMap<>();
|
||||||
|
id = rs.getString("id");
|
||||||
|
item.put("id", rs.getString("id"));
|
||||||
|
item.put("fname", rs.getString("fname"));
|
||||||
|
item.put("ftype", rs.getString("ftype"));
|
||||||
|
item.put("parentId", null);
|
||||||
|
list.add(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
int currentLevel = 1;
|
||||||
|
if(currentLevel + 1 <= Integer.parseInt(level)) {
|
||||||
|
findCompanyItemByParantId(id, currentLevel + 1, level, rs, list, whereSql);
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, Object> result = new HashMap<>();
|
||||||
|
result.put("api_status", true);
|
||||||
|
result.put("data", list);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void findCompanyItemByParantId(String id, int currentLevel, String level, RecordSet rs, List<Map<String, Object>> list, String whereSql) {
|
||||||
|
rs.executeQuery("select id, fname, ftype, fparentid from jcl_org_map " + whereSql + " and fparentid = " + id);
|
||||||
|
List<Map<String, Object>> currentList = new ArrayList<>();
|
||||||
|
while(rs.next()) {
|
||||||
|
Map<String, Object> item = new HashMap<>();
|
||||||
|
item.put("id", rs.getString("id"));
|
||||||
|
item.put("fname", rs.getString("fname"));
|
||||||
|
item.put("ftype", rs.getString("ftype"));
|
||||||
|
item.put("parentId", rs.getString("fparentid"));
|
||||||
|
currentList.add(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
list.addAll(currentList);
|
||||||
|
|
||||||
|
for (Map<String, Object> stringObjectMap : currentList) {
|
||||||
|
if(currentLevel + 1 <= Integer.parseInt(level)) {
|
||||||
|
findCompanyItemByParantId((String) stringObjectMap.get("id"), currentLevel + 1, level, rs, list, whereSql);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, Object> getUserData(Map<String, Object> request2Map, User user) {
|
||||||
|
String date = (String) request2Map.get("date"); // 数据日期
|
||||||
|
if(StringUtils.isBlank(date)) {
|
||||||
|
date = DateUtil.format( DateUtil.offset(new Date() , DateField.DAY_OF_MONTH, 1), "yyyy-MM-dd");
|
||||||
|
}
|
||||||
|
|
||||||
|
String fclass = (String) request2Map.get("fclass"); // 维度
|
||||||
|
String root = (String) request2Map.get("root"); // 根节点
|
||||||
|
String level = (String) request2Map.get("level"); // 显示层级
|
||||||
|
if(StringUtils.isBlank(level)) {
|
||||||
|
level = "3";
|
||||||
|
}
|
||||||
|
|
||||||
|
String fisvitual = (String) request2Map.get("fisvitual"); // 是否显示虚拟组织
|
||||||
|
if(StringUtils.isBlank(fisvitual)) {
|
||||||
|
fisvitual = "0";
|
||||||
|
}
|
||||||
|
|
||||||
|
String whereSql = " where 1 = 1 ";
|
||||||
|
whereSql += " and (t.fdatebegin <= '"+ date +"' and t.fdateend >= '"+ date +"') or (t.fdatebegin <= '"+ date +"' and t.fdateend is null ) ";
|
||||||
|
whereSql += " and t.fclass = " + fclass +" ";
|
||||||
|
|
||||||
|
if("0".equals(fisvitual)) {
|
||||||
|
whereSql += " and t.fisvitual = 0 ";
|
||||||
|
}else {
|
||||||
|
whereSql += " and t.fisvitual in (0, 1) ";
|
||||||
|
}
|
||||||
|
|
||||||
|
String whereItemSql = " ";
|
||||||
|
if("0".equals(root)) { // 集团的情况
|
||||||
|
whereItemSql += " and t.ftype = 0 ";
|
||||||
|
} else {
|
||||||
|
whereItemSql += " and t.id = '" + root +"' ";
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取根节点
|
||||||
|
RecordSet rs = new RecordSet();
|
||||||
|
rs.executeQuery("select t.id, t.fname, t.ftype, t.fparentid, t.fleadername, t.fleaderimg, t.fleaderjob, t.fplan, t.fonjob from jcl_org_map t " + whereSql + whereItemSql);
|
||||||
|
List<Map<String, Object>> list = new ArrayList<>();
|
||||||
|
String id = null;
|
||||||
|
if(rs.next()) {
|
||||||
|
Map<String, Object> item = new HashMap<>();
|
||||||
|
id = rs.getString("id");
|
||||||
|
item.put("id", rs.getString("id"));
|
||||||
|
item.put("fname", rs.getString("fname"));
|
||||||
|
item.put("ftype", rs.getString("ftype"));
|
||||||
|
item.put("parentId", null);
|
||||||
|
item.put("fleadername", rs.getString("fleadername"));
|
||||||
|
item.put("fleaderimg", rs.getString("fleaderimg"));
|
||||||
|
item.put("fleaderjob", rs.getString("fleaderjob"));
|
||||||
|
item.put("fplan", rs.getString("fplan"));
|
||||||
|
item.put("fonjob", rs.getString("fonjob"));
|
||||||
|
list.add(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
int currentLevel = 1;
|
||||||
|
if(currentLevel + 1 <= Integer.parseInt(level)) {
|
||||||
|
findUserItemByParantId(id, currentLevel + 1, level, rs, list, whereSql);
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, Object> result = new HashMap<>();
|
||||||
|
result.put("api_status", true);
|
||||||
|
result.put("data", list);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void findUserItemByParantId(String id, int currentLevel, String level, RecordSet rs, List<Map<String, Object>> list, String whereSql) {
|
||||||
|
rs.executeQuery("select t.id, t.fname, t.ftype, t.fparentid, t.fleadername, t.fleaderimg, t.fleaderjob, t.fplan, t.fonjob, t.fnumber from jcl_org_map t " + whereSql + " and t.fparentid = " + id);
|
||||||
|
List<Map<String, Object>> currentList = new ArrayList<>();
|
||||||
|
while(rs.next()) {
|
||||||
|
Map<String, Object> item = new HashMap<>();
|
||||||
|
item.put("id", rs.getString("id"));
|
||||||
|
item.put("fname", rs.getString("fname"));
|
||||||
|
item.put("ftype", rs.getString("ftype"));
|
||||||
|
item.put("parentId", rs.getString("fparentid"));
|
||||||
|
item.put("fleadername", rs.getString("fleadername"));
|
||||||
|
item.put("fleaderimg", rs.getString("fleaderimg"));
|
||||||
|
item.put("fleaderjob", rs.getString("fleaderjob"));
|
||||||
|
item.put("fplan", rs.getString("fplan"));
|
||||||
|
item.put("fonjob", rs.getString("fonjob"));
|
||||||
|
item.put("fnumber", rs.getString("fnumber"));
|
||||||
|
currentList.add(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Map<String, Object> stringObjectMap : currentList) {
|
||||||
|
if("4".equals(stringObjectMap.get("ftype"))) { // 员工信息
|
||||||
|
rs.executeQuery("select id, mobile, homeaddress from hrmresource where id = ? ", stringObjectMap.get("fnumber"));
|
||||||
|
if(rs.next()) {
|
||||||
|
stringObjectMap.put("mobile", rs.getString("mobile"));
|
||||||
|
stringObjectMap.put("address", rs.getString("homeaddress"));
|
||||||
|
}
|
||||||
|
rs.executeQuery("select departmentname from hrmresource hrm \n" +
|
||||||
|
"left join hrmdepartment d\n" +
|
||||||
|
"on hrm.departmentid = d.id\n" +
|
||||||
|
"where hrm.id = ? ", stringObjectMap.get("fnumber"));
|
||||||
|
if(rs.next()) {
|
||||||
|
stringObjectMap.put("department", rs.getString("departmentname"));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
if(currentLevel + 1 <= Integer.parseInt(level)) {
|
||||||
|
findUserItemByParantId((String) stringObjectMap.get("id"), currentLevel + 1, level, rs, list, whereSql);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
list.addAll(currentList);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,100 @@
|
|||||||
|
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.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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @className: OrgChartController
|
||||||
|
* @author: dengjp
|
||||||
|
* @date: 2022/7/7
|
||||||
|
* @description: 组织架构图
|
||||||
|
**/
|
||||||
|
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<String,Object>();
|
||||||
|
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("/companyData")
|
||||||
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
|
public String getCompanyData(@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).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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,34 @@
|
|||||||
|
package com.engine.organization.wrapper;
|
||||||
|
|
||||||
|
import com.engine.common.util.ServiceUtil;
|
||||||
|
import com.engine.core.impl.Service;
|
||||||
|
import com.engine.organization.service.OrgChartService;
|
||||||
|
import com.engine.organization.service.impl.OrgChartServiceImpl;
|
||||||
|
import weaver.hrm.User;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @className: OrgChartWrapper
|
||||||
|
* @author: dengjp
|
||||||
|
* @date: 2022/7/7
|
||||||
|
* @description: 组织架构图Wrapper
|
||||||
|
**/
|
||||||
|
public class OrgChartWrapper extends Service {
|
||||||
|
private OrgChartService getOrgChartService(User user) {
|
||||||
|
return ServiceUtil.getService(OrgChartServiceImpl.class, user);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public Map<String, Object> getOptionCondition(Map<String, Object> request2Map, User user) {
|
||||||
|
return getOrgChartService(user).getOptionCondition(request2Map, user);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, Object> getCompanyData(Map<String, Object> request2Map, User user) {
|
||||||
|
return getOrgChartService(user).getCompanyData(request2Map, user);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, Object> getUserData(Map<String, Object> request2Map, User user) {
|
||||||
|
return getOrgChartService(user).getUserData(request2Map, user);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue