岗位浏览按钮、编制action BUG修复

pull/9/head
dxfeng 3 years ago
parent 9df3349715
commit f26159506a

@ -9,20 +9,22 @@ import com.engine.organization.component.OrganizationWeaTable;
import com.engine.organization.entity.browser.bo.CusBowserTreeBO;
import com.engine.organization.entity.browser.enums.TreeNodeTypeEnum;
import com.engine.organization.entity.browser.po.CusBrowserTree;
import com.engine.organization.entity.company.po.CompPO;
import com.engine.organization.entity.department.po.DepartmentPO;
import com.engine.organization.entity.job.vo.JobBrowserVO;
import com.engine.organization.entity.searchtree.SearchTree;
import com.engine.organization.entity.searchtree.SearchTreeParams;
import com.engine.organization.service.impl.JobServiceImpl;
import com.engine.organization.mapper.comp.CompMapper;
import com.engine.organization.mapper.department.DepartmentMapper;
import com.engine.organization.util.OrganizationFormItemUtil;
import com.engine.organization.util.db.DBType;
import com.engine.organization.util.db.MapperProxyFactory;
import com.engine.organization.util.tree.SearchTreeUtil;
import org.apache.commons.lang.StringUtils;
import weaver.conn.RecordSet;
import weaver.general.Util;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
/**
* @author:dxfeng
@ -38,35 +40,19 @@ public class JobBrowserService extends BrowserService {
Map<String, Object> resultMap = new HashMap<>();
String datatype = Util.null2String(params.get("datatype"));
if ("tree".equals(datatype)) {
List<TreeNode> nodeData = new ArrayList<>();
String id = Util.null2String(params.get("id"));
SearchTreeParams searchTreeParams = new SearchTreeParams();
if (StringUtils.isBlank(id)) {
Map<String, Object> searchTree = new JobServiceImpl().getSearchTree(searchTreeParams);
Map<String, Object> datas = (Map<String, Object>) searchTree.get("datas");
// 集团
SearchTree rootCompany = (SearchTree) datas.get("rootCompany");
nodeData.add(rootCompany);
} else if ("0".equals(id)) {
Map<String, Object> searchTree = new JobServiceImpl().getSearchTree(searchTreeParams);
Map<String, Object> datas = (Map<String, Object>) searchTree.get("datas");
SearchTree rootCompany = (SearchTree) datas.get("rootCompany");
nodeData.addAll(rootCompany.getSubs());
} else {
String[] idArray = id.split("_");
if (idArray.length == 2) {
if (TreeNodeTypeEnum.TYPE_COMP.getName().equals(idArray[0])) {
searchTreeParams.setType(TreeNodeTypeEnum.TYPE_COMP.getValue());
} else if (TreeNodeTypeEnum.TYPE_DEPT.getName().equals(idArray[0])) {
searchTreeParams.setType(TreeNodeTypeEnum.TYPE_DEPT.getValue());
}
searchTreeParams.setId(idArray[1]);
Map<String, Object> searchTree = new JobServiceImpl().getSearchTree(searchTreeParams);
List<TreeNode> datas = (List<TreeNode>) searchTree.get("datas");
TreeNode treeNode = datas.stream().filter(item -> idArray[1].equals(item.getId())).findFirst().orElse(new TreeNode());
nodeData.addAll(treeNode.getSubs());
searchTreeParams.setId(id);
String[] idArray = id.split("_");
if (idArray.length == 2) {
if (TreeNodeTypeEnum.TYPE_COMP.getName().equals(idArray[0])) {
searchTreeParams.setType(TreeNodeTypeEnum.TYPE_COMP.getValue());
} else if (TreeNodeTypeEnum.TYPE_DEPT.getName().equals(idArray[0])) {
searchTreeParams.setType(TreeNodeTypeEnum.TYPE_DEPT.getValue());
}
searchTreeParams.setId(idArray[1]);
}
List<TreeNode> nodeData = getCurrentTreeNode(searchTreeParams);
List<CusBrowserTree> cusBrowserTrees = CusBowserTreeBO.convertSearchTreeToBorwserTree(nodeData);
resultMap.put("datas", cusBrowserTrees);
} else {
@ -140,4 +126,79 @@ public class JobBrowserService extends BrowserService {
}
return sqlWhere;
}
/**
*
*
* @param params
* @return
*/
private List<TreeNode> getCurrentTreeNode(SearchTreeParams params) {
List<TreeNode> treeNodes = new ArrayList<>();
if (StringUtils.isBlank(params.getId())) {
// 集团总部
SearchTree topGroup = SearchTreeUtil.getTopGroup();
topGroup.setIsParent(true);
treeNodes.add(topGroup);
} else {
// 分部存在下级的ID
List<String> compHasSubs = MapperProxyFactory.getProxy(CompMapper.class).hasSubs();
// 部门存在下级的ID
List<String> hasSubDepartment = MapperProxyFactory.getProxy(DepartmentMapper.class).hasSubs();
if ("0".equals(params.getId())) {
List<CompPO> compList = MapperProxyFactory.getProxy(CompMapper.class).listParent();
// 获取顶层分部
compList.stream().sorted(Comparator.comparing(CompPO::getShowOrder)).forEach(item -> buildCompNodes(treeNodes, compHasSubs, item));
} else if ("1".equals(params.getType())) {
// 当前节点下的元素
CompPO compBuild = CompPO.builder().parentCompany(Long.parseLong(params.getId())).forbiddenTag(0).deleteType(0).build();
List<CompPO> compList = MapperProxyFactory.getProxy(CompMapper.class).listByFilter(compBuild, "show_order");
DepartmentPO departmentBuild = DepartmentPO.builder().parentComp(Long.parseLong(params.getId())).forbiddenTag(0).deleteType(0).build();
List<DepartmentPO> departmentList = MapperProxyFactory.getProxy(DepartmentMapper.class).listByFilter(departmentBuild, "show_order");
compList.forEach(item -> buildCompNodes(treeNodes, compHasSubs, item));
departmentList.stream().filter(item -> null == item.getParentDept() || 0 == item.getParentDept()).forEach(item -> buildDeptNodes(treeNodes, hasSubDepartment, item));
} else if ("2".equals(params.getType())) {
DepartmentPO departmentBuild = DepartmentPO.builder().parentDept(Long.parseLong(params.getId())).forbiddenTag(0).deleteType(0).build();
List<DepartmentPO> departmentList = MapperProxyFactory.getProxy(DepartmentMapper.class).listByFilter(departmentBuild, "show_order");
departmentList.forEach(item -> buildDeptNodes(treeNodes, hasSubDepartment, item));
}
}
return treeNodes;
}
/**
*
*
* @param treeNodes
* @param compHasSubs
* @param company
*/
private void buildCompNodes(List<TreeNode> treeNodes, List<String> compHasSubs, CompPO company) {
SearchTree searchTree = new SearchTree();
searchTree.setId(company.getId().toString());
searchTree.setType(TreeNodeTypeEnum.TYPE_COMP.getValue());
searchTree.setName(company.getCompName());
searchTree.setIsParent(compHasSubs.contains(company.getId().toString()));
treeNodes.add(searchTree);
}
/**
*
*
* @param treeNodes
* @param hasSubDepartment
* @param department
*/
private void buildDeptNodes(List<TreeNode> treeNodes, List<String> hasSubDepartment, DepartmentPO department) {
SearchTree searchTree = new SearchTree();
searchTree.setId(department.getId().toString());
searchTree.setName(department.getDeptName());
searchTree.setType(TreeNodeTypeEnum.TYPE_DEPT.getValue());
searchTree.setIsParent(hasSubDepartment.contains(department.getId().toString()));
treeNodes.add(searchTree);
}
}

@ -3,7 +3,6 @@ package com.engine.organization.entity.browser.bo;
import com.api.hrm.bean.TreeNode;
import com.engine.organization.entity.browser.enums.TreeNodeTypeEnum;
import com.engine.organization.entity.browser.po.CusBrowserTree;
import org.apache.commons.collections.CollectionUtils;
import java.util.List;
import java.util.stream.Collectors;
@ -25,8 +24,8 @@ public class CusBowserTreeBO {
List<CusBrowserTree> collect = searchTree.stream().map(item ->
CusBrowserTree.builder()
.domid("sel_" + item.getId())
.hasChild(CollectionUtils.isNotEmpty(item.getSubs()))
.isLeaf(CollectionUtils.isEmpty(item.getSubs()))
.hasChild(item.getIsParent())
.isLeaf(!item.getIsParent())
.isopen(false)
.key(getKey(item))
.name(item.getName())

@ -30,6 +30,8 @@ public interface CompMapper {
List<String> listUsedIds();
List<String> hasSubs();
/**
*
*

@ -239,6 +239,9 @@
<if test="compNameShort != null ">
#{compNameShort},
</if>
<if test="parentCompany != null ">
#{parentCompany},
</if>
<if test="ec_company != null ">
#{ecCompany},
</if>
@ -311,6 +314,9 @@
jcl_org_comp t
WHERE t.delete_type = 0
<include refid="likeSQL"/>
<if test=" compPO.parentCompany != null ">
and t.parent_company = #{compPO.parentCompany}
</if>
<if test=" compPO.ecCompany != null ">
and t.ec_company = #{compPO.ecCompany}
</if>
@ -418,6 +424,17 @@
where t.delete_type = 0
AND comp_no = #{companyNo}
</select>
<select id="hasSubs" resultType="java.lang.String">
select parent_company
from jcl_org_comp
where forbidden_tag = 0
and delete_type = 0
union
select parent_comp
from jcl_org_dept
where forbidden_tag = 0
and delete_type = 0
</select>
<update id="updateForbiddenTagById" parameterType="com.engine.organization.entity.sequence.po.SequencePO">
update jcl_org_comp

@ -134,4 +134,6 @@ public interface DepartmentMapper {
Long getIdByNameAndPid(@Param("departmentName") String departmentName, @Param("parentCompany") Long parentCompany, @Param("parentDepartment") Long parentDepartment);
int checkRepeatNo(@Param("departmentNo") String departmentNo, @Param("id") Long id);
List<String> hasSubs();
}

@ -178,6 +178,12 @@
and t.id != #{id}
</if>
</select>
<select id="hasSubs" resultType="java.lang.String">
select distinct parent_dept
from jcl_org_dept
where forbidden_tag = 0
and delete_type = 0
</select>
<sql id="nullParentDepartment">
and ifnull(parent_dept,0) =
#{parentDepartment}

@ -464,6 +464,11 @@
select job_id
from JCL_ORG_STAFF
where delete_type = 0
union
select field100002
from cus_fielddata
inner join
hrmresource on STATUS &lt; 4
</select>
<select id="listJobsByDepartmentId" resultMap="BaseResultMap">
select

@ -57,10 +57,10 @@
from jcl_org_staff t
where delete_type = 0
<if test="companyId != null">
and comp_id = #{companyId}
and ec_company = #{companyId}
</if>
<if test="departmentId != null">
and dept_id = #{departmentId}
and ec_department = #{departmentId}
</if>
<if test="jobId != null">
and job_id = #{jobId}

@ -62,7 +62,7 @@ public class SearchTreeUtil {
*
* @return
*/
private static SearchTree getTopGroup() {
public static SearchTree getTopGroup() {
RecordSet rs = new RecordSet();
String sql = "select * from HrmCompany ";
rs.executeQuery(sql);

@ -5,7 +5,6 @@ import com.engine.organization.entity.staff.po.StaffPO;
import com.engine.organization.entity.staff.po.StaffsPO;
import com.engine.organization.mapper.staff.StaffMapper;
import com.engine.organization.mapper.staff.StaffsMapper;
import com.engine.organization.util.OrganizationAssert;
import com.engine.organization.util.db.MapperProxyFactory;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
@ -114,7 +113,6 @@ public class StaffChangeAction implements Action {
case "6":// 减员释放,比如离职、调出等
staffPO.setPermanentNum(staffPO.getPermanentNum() - changeNum);
if (staffPO.getPermanentNum() < 0) {
OrganizationAssert.isFalse(staffPO.getPermanentNum() < 0,"调整数量不可大于在编数");
return "调整数量不可大于在编数";
}
break;

Loading…
Cancel
Save