feature/dxf #176

Merged
dxfeng merged 3 commits from feature/dxf into develop 2 years ago

@ -26,4 +26,7 @@ public interface ChartService {
Map<String, Object> asyncCompanyData(Map<String, Object> params); Map<String, Object> asyncCompanyData(Map<String, Object> params);
Map<String, Object> getDepartmentDetail(Map<String, Object> params);
} }

@ -1,17 +1,18 @@
package com.engine.organization.service.impl; package com.engine.organization.service.impl;
import com.engine.common.util.ServiceUtil;
import com.engine.core.impl.Service; import com.engine.core.impl.Service;
import com.engine.organization.entity.chart.ChartPO; import com.engine.organization.entity.chart.ChartPO;
import com.engine.organization.service.ChartService; import com.engine.organization.service.ChartService;
import com.engine.organization.util.HasRightUtil; import com.engine.organization.util.HasRightUtil;
import com.engine.organization.util.OrganizationAssert;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import weaver.conn.RecordSet; import weaver.conn.RecordSet;
import weaver.general.Util; import weaver.general.Util;
import java.util.ArrayList; import java.util.*;
import java.util.HashMap; import java.util.stream.Collectors;
import java.util.List;
import java.util.Map;
/** /**
* @author:dxfeng * @author:dxfeng
@ -162,6 +163,100 @@ public class ChartServiceImpl extends Service implements ChartService {
return result; return result;
} }
@Override
public Map<String, Object> getDepartmentDetail(Map<String, Object> params) {
String rootId = Util.null2String(params.get("rootId"));
OrganizationAssert.isFalse(StringUtils.isBlank(rootId) || !rootId.startsWith("d_"), "数据有误,未查询到对应数据");
String departmentId = rootId.split("_")[1];
String detauleType = Util.null2String(params.get("detauleType"));
if(!"chart".equals(detauleType)){
return ServiceUtil.getService(HrmResourceServiceImpl.class, user).chartResourceList(Integer.parseInt(departmentId));
}
// 维度
String dimension = Util.null2String(params.get("fclass"));
dimension = StringUtils.isBlank(dimension) ? "0" : dimension;
// 初始化表名
initTableNameByClass(dimension);
List<ChartPO> dataList = new ArrayList<>();
List<ChartPO> resourceList = new ArrayList<>();
Set<String> jobTitleSet = new HashSet<>();
RecordSet rs = new RecordSet();
// TODO 查询当前实际的数据
String sql;
// 查询当当前部门下的人员
if ("0".equals(dimension)) {
sql = "select a.id,a.lastname as 'name' ,a.jobtitle from hrmresource a where a.departmentid = '" + departmentId + "'";
} else {
sql = "select a.id,a.lastname as 'name' ,a.jobtitle from hrmresource a inner join hrmresourcevirtual b on a.id = b.resourceid where b.departmentid = '" + departmentId + "'";
}
rs.executeQuery(sql);
while (rs.next()){
String jobTitle = Util.null2String(rs.getString("jobtitle"));
ChartPO chartPO = new ChartPO();
chartPO.setFtype("4");
chartPO.setFobjid(rs.getString("id"));
chartPO.setFname(rs.getString("name"));
// 岗位处理后的ID
chartPO.setParentId(departmentId + "_" + jobTitle);
chartPO.setExpand("1");
chartPO.setHasChildren("0");
resourceList.add(chartPO);
jobTitleSet.add(jobTitle);
}
Map<String, List<ChartPO>> resourceMap = resourceList.stream().collect(Collectors.groupingBy(ChartPO::getParentId));
// 查询人员的岗位
if(CollectionUtils.isNotEmpty(jobTitleSet)) {
sql = "select a.id,a.jobtitlename as 'name' from hrmjobtitles a where a.id in(" + StringUtils.join(jobTitleSet, ",") + ")";
rs.executeQuery(sql);
while (rs.next()){
ChartPO chartPO = new ChartPO();
chartPO.setFtype("3");
chartPO.setFobjid(rs.getString("id"));
chartPO.setId(departmentId + "_" + chartPO.getFobjid());
chartPO.setFname(rs.getString("name"));
// 岗位处理后的ID
chartPO.setParentId(rootId);
chartPO.setExpand("1");
chartPO.setHasChildren("1");
dataList.add(chartPO);
// 避免出现人员没有上级岗位的情况
List<ChartPO> chartPOS = resourceMap.get(chartPO.getId());
if (CollectionUtils.isNotEmpty(chartPOS)) {
dataList.addAll(chartPOS);
}
}
}
// 查询部门本身
sql = "select a.id,a.departmentname as 'name' from " + DEPARTMENT_TABLE + " a where id = '" + departmentId + "'";
rs.executeQuery(sql);
if(rs.next()){
ChartPO chartPO = new ChartPO();
chartPO.setFtype("2");
chartPO.setFobjid(departmentId);
chartPO.setId(rootId);
chartPO.setFname(rs.getString("name"));
// 岗位处理后的ID
chartPO.setParentId(rootId);
chartPO.setExpand("1");
chartPO.setHasChildren(CollectionUtils.isNotEmpty(dataList) ? "1" : "0");
dataList.add(chartPO);
}
Map<String, Object> result = new HashMap<>();
result.put("api_status", true);
result.put("data", dataList);
return result;
}
/** /**
* ,SQL * ,SQL
* *

@ -63,8 +63,22 @@ public class OrgChartController {
return JSONObject.toJSONString(apidatas); 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 @GET

@ -60,4 +60,8 @@ public class OrgChartWrapper extends Service {
public Map<String, Object> searchTimeLines(Map<String, Object> request2Map, User user) { public Map<String, Object> searchTimeLines(Map<String, Object> request2Map, User user) {
return getOrgChartService(user).searchTimeLines(request2Map); return getOrgChartService(user).searchTimeLines(request2Map);
} }
public Map<String, Object> getDepartmentDetail(Map<String, Object> request2Map, User user) {
return getChartService(user).getDepartmentDetail(request2Map);
}
} }

Loading…
Cancel
Save