组织架构图功能完善

pull/261/head
Chengliang 10 months ago
parent 91ca23bc27
commit 6349b0ce04

@ -47,6 +47,12 @@ public class ChartPO {
// 部门层级
private int departmentDepth;
//账号类型
private String accountType;
//直接上级
private String managerId;
// 在编数
private int onJobNum;
// 编制数

@ -86,5 +86,7 @@ public interface HrmResourceMapper {
*/
List<ResourceChartPO> selectByDepartmentId(@Param("departmentId")Integer departmentId);
List<ResourceChartPO> selectByIdAndStatus(@Param("statusList") List<String> statusList,@Param("departmentId")Integer departmentId);
}

@ -453,4 +453,14 @@
from hrmresource where departmentid = #{departmentId} and status &lt; 4 order by id
</select>
<select id="selectByIdAndStatus" resultType="com.engine.organization.entity.hrmresource.po.ResourceChartPO">
select id,workcode,lastname,sex,departmentid,subcompanyid1,jobtitle,status,mobile
from hrmresource where departmentid = #{departmentId}
AND status IN
<foreach collection="statusList" open="(" item="status" separator="," close=")">
#{status}
</foreach>
order by id
</select>
</mapper>

@ -176,7 +176,7 @@ public interface HrmResourceService {
* @param: [departmentId]
* @return: java.util.Map<java.lang.String,java.lang.Object>
*/
Map<String, Object> chartResourceList(Integer departmentId,String versionId,String dimension);
Map<String, Object> chartResourceList(Integer departmentId,String versionId,String dimension,String statusValue);
}

@ -229,9 +229,27 @@ public class ChartServiceImpl extends Service implements ChartService {
OrganizationAssert.isFalse(StringUtils.isBlank(rootId) || !rootId.startsWith("d_"), SystemEnv.getHtmlLabelName(547440,user.getLanguage()));
String departmentId = rootId.split("_")[1];
String detauleType = Util.null2String(params.get("detauleType"));
//人员性质
String statusValue = Util.null2String(params.get("statusValue"));
//显示模式
String typeValue = Util.null2String(params.get("typeValue"));
//显示人员上下级
boolean isManager = false;
//显示次账号
boolean isBelongTo = true;
if (typeValue.contains("isManager")) {
isManager = true;
}
if (!typeValue.contains("isBelongTo")) {
isBelongTo = false;
}
if (!"chart".equals(detauleType)) {
// 展示列表模块
return ServiceUtil.getService(HrmResourceServiceImpl.class, user).chartResourceList(Integer.parseInt(departmentId), versionId, dimension);
return ServiceUtil.getService(HrmResourceServiceImpl.class, user).chartResourceList(Integer.parseInt(departmentId), versionId, dimension,statusValue);
}
@ -304,19 +322,28 @@ public class ChartServiceImpl extends Service implements ChartService {
// 遍历岗位、查询对应岗位下的人员
if (isRealTime) {
if (isRealDimension) {
sql = "select a.id,a.lastname as name ,a.belongto ,a.companyworkyear from hrmresource a where a.status < 4 and a.departmentid = ? and a.jobtitle = ?";
sql = "select a.id,a.lastname as name,a.belongto ,a.companyworkyear,a.dsporder,a.accounttype from hrmresource a where a.status in ("+statusValue+") and a.departmentid = ? and a.jobtitle = ?";
} else {
sql = "select a.id,a.lastname as name ,a.belongto ,a.companyworkyear from hrmresource a inner join hrmresourcevirtual b on a.id = b.resourceid where a.status < 4 and b.departmentid = ? and a.jobtitle = ?";
sql = "select a.id,a.lastname as name ,a.belongto ,a.companyworkyear,a.accounttype from hrmresource a inner join hrmresourcevirtual b on a.id = b.resourceid where a.status in ("+statusValue+") and b.departmentid = ? and a.jobtitle = ?";
}
} else {
sql = "select a.resourceid as id,a.lastname as name ,a.belongto ,a.companyworkyear from jcl_chart_resource a where a.status < 4 and a.departmentid = ? and a.jobtitleid = ? and versionid = " + versionId;
sql = "select a.resourceid as id,a.lastname as name ,a.belongto ,a.companyworkyear,a.accounttype from jcl_chart_resource a where a.status in ("+statusValue+") and a.departmentid = ? and a.jobtitleid = ? and versionid = " + versionId;
}
if (!isBelongTo) {
sql += " and (a.accounttype = 0 or a.accounttype is null)";
}
if (isRealTime) {
sql += " order by dsporder";
}
for (ChartPO jobTitlePO : jobTitleList) {
resourceNum = 0;
rs.executeQuery(sql, departmentId, jobTitlePO.getFobjid());
String parentId = departmentId + "_" + jobTitlePO.getFobjid();
while (rs.next()) {
ChartPO chartPO = getResourceChartPO(rs.getString("id"), rs.getString("name"), parentId, rs.getString("belongto"), rs.getString("companyworkyear"));
String accountType = Util.null2String(rs.getString("accounttype"));
ChartPO chartPO = getResourceChartPO(rs.getString("id"), rs.getString("name"), parentId, rs.getString("belongto"), rs.getString("companyworkyear"),accountType);
resourceNum++;
dataList.add(chartPO);
}
@ -326,23 +353,46 @@ public class ChartServiceImpl extends Service implements ChartService {
}
departmentChartPO.setHasChildren(CollectionUtils.isNotEmpty(jobTitleList) ? "1" : "0");
} else {
// 直接查询岗位下的人员
// 直接查询部门下的人员
if (isRealTime) {
if (isRealDimension) {
sql = "select a.id,a.lastname as name ,a.belongto ,a.companyworkyear from hrmresource a where a.status < 4 and a.departmentid = ? ";
sql = "select a.id,a.lastname as name ,a.belongto ,a.companyworkyear,a.accounttype,a.managerid from hrmresource a where a.status in ("+statusValue+") and a.departmentid = ? ";
} else {
sql = "select a.id,a.lastname as name ,a.belongto ,a.companyworkyear from hrmresource a inner join hrmresourcevirtual b on a.id = b.resourceid where a.status < 4 and b.departmentid = ? ";
sql = "select a.id,a.lastname as name ,a.belongto ,a.companyworkyear,a.accounttype,b.managerid from hrmresource a inner join hrmresourcevirtual b on a.id = b.resourceid where a.status in ("+statusValue+") and b.departmentid = ? ";
}
} else {
sql = "select a.resourceid as id,a.lastname as name ,a.belongto ,a.companyworkyear from jcl_chart_resource a where a.status < 4 and a.departmentid = ? and versionid = " + versionId;
sql = "select a.resourceid as id,a.lastname as name ,a.belongto ,a.companyworkyear,a.accounttype,a.manager as managerid from jcl_chart_resource a where a.status in ("+statusValue+") and a.departmentid = ? and versionid = " + versionId;
}
if (!isBelongTo) {
sql += " and (a.accounttype = 0 or a.accounttype is null)";
}
if (isRealTime) {
sql += " order by dsporder";
}
rs.executeQuery(sql, departmentId);
List<ChartPO> personList = new ArrayList<>();
while (rs.next()) {
ChartPO chartPO = getResourceChartPO(rs.getString("id"), rs.getString("name"), rootId, rs.getString("belongto"), rs.getString("companyworkyear"));
dataList.add(chartPO);
String accountType = Util.null2String(rs.getString("accounttype"));
String managerId = Util.null2String(rs.getString("managerid"));
ChartPO chartPO = getResourceChartPO(rs.getString("id"), rs.getString("name"), rootId, rs.getString("belongto"), rs.getString("companyworkyear"),accountType);
chartPO.setManagerId(managerId);
personList.add(chartPO);
departmentOnJob++;
}
if(isManager) {
personList.forEach(element -> personList.stream()
.filter(other -> element.getManagerId().equals(other.getId()))
.findFirst()
.ifPresent(matched -> element.setParentId(matched.getId())));
}
dataList.addAll(personList);
}
departmentChartPO.setFonjob(departmentOnJob);
@ -370,7 +420,7 @@ public class ChartServiceImpl extends Service implements ChartService {
* @param companyWorkYear
* @return
*/
private ChartPO getResourceChartPO(String id, String name, String parentId, String belongTo, String companyWorkYear) {
private ChartPO getResourceChartPO(String id, String name, String parentId, String belongTo, String companyWorkYear,String accountType) {
ChartPO chartPO = new ChartPO();
chartPO.setFtype("4");
chartPO.setFobjid(id);
@ -382,6 +432,7 @@ public class ChartServiceImpl extends Service implements ChartService {
chartPO.setHasChildren("0");
chartPO.setBelongto(Util.null2String(belongTo));
chartPO.setCompanyWorkYear(companyWorkYear);
chartPO.setAccountType("1".equals(accountType) ? "次账号" : "主账号");
try {
chartPO.setFleaderimg(new ResourceComInfo().getMessagerUrls(chartPO.getId()));
} catch (Exception e) {

@ -462,7 +462,7 @@ public class HrmResourceServiceImpl extends Service implements HrmResourceServic
}
@Override
public Map<String, Object> chartResourceList(Integer departmentId, String versionId, String dimension) {
public Map<String, Object> chartResourceList(Integer departmentId, String versionId, String dimension,String statusValue) {
Map<String, Object> dataMap = new HashMap<>();
List<ResourceListColumns> resourceListColumns = getTableColumns();
List<ResourceChartPO> resourceChartPOS = new ArrayList<>();
@ -471,10 +471,13 @@ public class HrmResourceServiceImpl extends Service implements HrmResourceServic
if ("0".equals(dimension)) {
if ("0".equals(versionId)) {
//当前数据
resourceChartPOS = getHrmResourceMapper().selectByDepartmentId(departmentId);
List<String> statusList = Arrays.stream(statusValue.split(","))
.map(String::trim)
.collect(Collectors.toList());
resourceChartPOS = getHrmResourceMapper().selectByIdAndStatus(statusList,departmentId);
resourceChartVOS = ResourceChartBO.convertToVO(resourceChartPOS);
} else {
rs.executeQuery("select resourceid,workcode,lastname,sex,department,subcompany,jobtitle,mobile from jcl_chart_resource where departmentid = ? and versionid = ?", departmentId, versionId);
rs.executeQuery("select resourceid,workcode,lastname,sex,department,subcompany,jobtitle,mobile from jcl_chart_resource where status in ("+statusValue+") and departmentid = ? and versionid = ?", departmentId, versionId);
while (rs.next()) {
ResourceChartVO build = ResourceChartVO.builder()
.id((long) Util.getIntValue(rs.getString("resourceid")))
@ -492,7 +495,7 @@ public class HrmResourceServiceImpl extends Service implements HrmResourceServic
}
} else {
rs.executeQuery("select h.id,h.workcode,h.lastname,h.sex,h.departmentid,h.subcompanyid1,h.jobtitle,h.status,h.mobile " +
" from hrmresourcevirtual v inner join hrmresource h on v.resourceid = h.id and v.virtualtype = ? and v.departmentid = ?", dimension, departmentId);
" from hrmresourcevirtual v inner join hrmresource h on v.resourceid = h.id and h.status in ("+statusValue+") and v.virtualtype = ? and v.departmentid = ?", dimension, departmentId);
while (rs.next()) {
ResourceChartPO build = ResourceChartPO.builder()
.id((long) Util.getIntValue(rs.getString("id")))

Loading…
Cancel
Save