|
|
|
@ -5,17 +5,22 @@ import com.api.browser.bean.BrowserBean;
|
|
|
|
|
import com.api.browser.bean.SearchConditionGroup;
|
|
|
|
|
import com.api.browser.bean.SearchConditionItem;
|
|
|
|
|
import com.api.browser.bean.SearchConditionOption;
|
|
|
|
|
import com.api.hrm.bean.TreeNode;
|
|
|
|
|
import com.cloudstore.eccom.pc.table.WeaTableColumn;
|
|
|
|
|
import com.cloudstore.eccom.result.WeaResultMsg;
|
|
|
|
|
import com.engine.common.util.ServiceUtil;
|
|
|
|
|
import com.engine.core.impl.Service;
|
|
|
|
|
import com.engine.organization.component.OrganizationWeaTable;
|
|
|
|
|
import com.engine.organization.entity.company.bo.CompBO;
|
|
|
|
|
import com.engine.organization.entity.company.po.CompPO;
|
|
|
|
|
import com.engine.organization.entity.department.bo.DepartmentBO;
|
|
|
|
|
import com.engine.organization.entity.department.dto.DepartmentListDTO;
|
|
|
|
|
import com.engine.organization.entity.department.param.DeptSearchParam;
|
|
|
|
|
import com.engine.organization.entity.department.param.QuerySingleDeptListParam;
|
|
|
|
|
import com.engine.organization.entity.department.po.DepartmentPO;
|
|
|
|
|
import com.engine.organization.entity.department.vo.SingleDeptTreeVO;
|
|
|
|
|
import com.engine.organization.entity.searchtree.SearchTree;
|
|
|
|
|
import com.engine.organization.entity.searchtree.SearchTreeParams;
|
|
|
|
|
import com.engine.organization.mapper.comp.CompMapper;
|
|
|
|
|
import com.engine.organization.mapper.department.DepartmentMapper;
|
|
|
|
|
import com.engine.organization.mapper.extend.ExtendGroupMapper;
|
|
|
|
@ -28,6 +33,8 @@ import com.engine.organization.util.db.MapperProxyFactory;
|
|
|
|
|
import com.engine.organization.util.page.Column;
|
|
|
|
|
import com.engine.organization.util.page.PageInfo;
|
|
|
|
|
import com.engine.organization.util.page.PageUtil;
|
|
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
|
|
|
import weaver.conn.RecordSet;
|
|
|
|
|
import weaver.general.StringUtil;
|
|
|
|
|
import weaver.general.Util;
|
|
|
|
|
import weaver.hrm.User;
|
|
|
|
@ -59,6 +66,15 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
|
|
|
|
|
*/
|
|
|
|
|
private static final String JCL_ORG_DEPTEXT_DT1 = "JCL_ORG_DEPTEXT_DT1";
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 左侧树 类型表示
|
|
|
|
|
* <p>
|
|
|
|
|
* 0:集团
|
|
|
|
|
* 1:分部
|
|
|
|
|
* 2:部门
|
|
|
|
|
*/
|
|
|
|
|
private static final String TYPE_GROUP = "0";
|
|
|
|
|
|
|
|
|
|
private DepartmentMapper getDepartmentMapper() {
|
|
|
|
|
return MapperProxyFactory.getProxy(DepartmentMapper.class);
|
|
|
|
|
}
|
|
|
|
@ -83,7 +99,7 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
|
|
|
|
|
//PageUtil.start(param.getCurrent(), param.getPageSize());
|
|
|
|
|
List<DepartmentPO> departmentPOS = MapperProxyFactory.getProxy(DepartmentMapper.class).list();
|
|
|
|
|
PageInfo<DepartmentPO> pageInfo = new PageInfo<>(departmentPOS);
|
|
|
|
|
List<SingleDeptTreeVO> singleDeptTreeVOS = DepartmentBO.buildSingleDeptTreeVOS(departmentPOS,param.getParentComp());
|
|
|
|
|
List<SingleDeptTreeVO> singleDeptTreeVOS = DepartmentBO.buildSingleDeptTreeVOS(departmentPOS, param.getParentComp());
|
|
|
|
|
PageInfo<SingleDeptTreeVO> pageInfos = new PageInfo<>(singleDeptTreeVOS, SingleDeptTreeVO.class);
|
|
|
|
|
pageInfos.setTotal(pageInfo.getTotal());
|
|
|
|
|
pageInfos.setPageNum(param.getCurrent());
|
|
|
|
@ -92,25 +108,54 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
|
|
|
|
|
return pageInfos;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Map<String, Object> getSearchTree(SearchTreeParams params) {
|
|
|
|
|
Map<String, Object> dataMap = new HashMap<>();
|
|
|
|
|
SearchTree topGroup = getTopGroup();
|
|
|
|
|
// 集团
|
|
|
|
|
List<SearchTree> companyList = new ArrayList<>();
|
|
|
|
|
companyList.add(topGroup);
|
|
|
|
|
String keyword = params.getKeyword();
|
|
|
|
|
String type = Util.null2String(params.getType());
|
|
|
|
|
String id = params.getId();
|
|
|
|
|
|
|
|
|
|
List<TreeNode> treeDatas = getFilterCompany(id, type, keyword);
|
|
|
|
|
// 未点击,初始化树结构
|
|
|
|
|
if (StringUtil.isEmpty(type)) {
|
|
|
|
|
dataMap.put("companys", companyList);
|
|
|
|
|
SearchTree rootCompany = getTopGroup();
|
|
|
|
|
rootCompany.setSubs(treeDatas);
|
|
|
|
|
rootCompany.setIsParent(CollectionUtils.isNotEmpty(rootCompany.getSubs()));
|
|
|
|
|
Map<String, Object> rootCompanyMap = new HashMap<>();
|
|
|
|
|
rootCompanyMap.put("rootCompany", rootCompany);
|
|
|
|
|
dataMap.put("datas", rootCompanyMap);
|
|
|
|
|
} else {
|
|
|
|
|
// 根据ID查询
|
|
|
|
|
dataMap.put("datas", treeDatas);
|
|
|
|
|
}
|
|
|
|
|
return dataMap;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Map<String, Object> listPage(DeptSearchParam param) {
|
|
|
|
|
Map<String, Object> datas = new HashMap<>();
|
|
|
|
|
DepartmentPO departmentPO = DepartmentBO.convertParamsToPO(param, (long) user.getUID());
|
|
|
|
|
DepartmentPO departmentPO = DepartmentBO.convertParamsToPO(param, user.getUID());
|
|
|
|
|
boolean filter = isFilter(departmentPO);
|
|
|
|
|
PageInfo<DepartmentListDTO> pageInfos;
|
|
|
|
|
List<DepartmentPO> alltList = getDepartmentMapper().list();
|
|
|
|
|
List<DepartmentPO> allList = getDepartmentMapper().list();
|
|
|
|
|
// 通过子级遍历父级元素
|
|
|
|
|
if (filter) {
|
|
|
|
|
// 根据条件获取元素
|
|
|
|
|
List<DepartmentPO> filteDeptPOs = getDepartmentMapper().listByFilter(departmentPO);
|
|
|
|
|
List<DepartmentPO> filterDeptPOs = getDepartmentMapper().listByFilter(departmentPO);
|
|
|
|
|
// 添加父级元素
|
|
|
|
|
List<DepartmentListDTO> compListDTOS = DepartmentBO.buildDeptDTOList(alltList, filteDeptPOs);
|
|
|
|
|
List<DepartmentListDTO> compListDTOS = DepartmentBO.buildDeptDTOList(allList, filterDeptPOs);
|
|
|
|
|
List<DepartmentListDTO> subList = PageUtil.subList(param.getCurrent(), param.getPageSize(), compListDTOS);
|
|
|
|
|
pageInfos = new PageInfo<>(subList, DepartmentListDTO.class);
|
|
|
|
|
pageInfos.setTotal(compListDTOS.size());
|
|
|
|
|
} else {
|
|
|
|
|
// 组合list
|
|
|
|
|
List<DepartmentListDTO> compListDTOS = DepartmentBO.buildDeptDTOList(alltList);
|
|
|
|
|
List<DepartmentListDTO> compListDTOS = DepartmentBO.buildDeptDTOList(allList);
|
|
|
|
|
List<DepartmentListDTO> subList = PageUtil.subList(param.getCurrent(), param.getPageSize(), compListDTOS);
|
|
|
|
|
pageInfos = new PageInfo<>(subList, DepartmentListDTO.class);
|
|
|
|
|
pageInfos.setTotal(compListDTOS.size());
|
|
|
|
@ -138,7 +183,7 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
|
|
|
|
|
public int saveBaseForm(DeptSearchParam params) {
|
|
|
|
|
List<DepartmentPO> list = getDepartmentMapper().listByNo(Util.null2String(params.getDeptNo()));
|
|
|
|
|
OrganizationAssert.isEmpty(list, "编号不允许重复");
|
|
|
|
|
DepartmentPO departmentPO = DepartmentBO.convertParamsToPO(params, (long) user.getUID());
|
|
|
|
|
DepartmentPO departmentPO = DepartmentBO.convertParamsToPO(params, user.getUID());
|
|
|
|
|
return getDepartmentMapper().insertIgnoreNull(departmentPO);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -152,7 +197,7 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
|
|
|
|
|
public int updateForm(Map<String, Object> params) {
|
|
|
|
|
DeptSearchParam searchParam = JSONObject.parseObject(JSONObject.toJSONString(params), DeptSearchParam.class);
|
|
|
|
|
String groupId = (String) params.get("viewCondition");
|
|
|
|
|
DepartmentPO departmentPO = DepartmentBO.convertParamsToPO(searchParam,user.getUID());
|
|
|
|
|
DepartmentPO departmentPO = DepartmentBO.convertParamsToPO(searchParam, user.getUID());
|
|
|
|
|
int updateCount = 0;
|
|
|
|
|
// 更新主表数据
|
|
|
|
|
updateCount += getDepartmentMapper().updateBaseDept(departmentPO);
|
|
|
|
@ -178,7 +223,7 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
|
|
|
|
|
// 编号
|
|
|
|
|
SearchConditionItem deptNoItem = OrganizationFormItemUtil.inputItem(user, 2, 16, 2, 50, "编号", "deptNo");
|
|
|
|
|
// 名称
|
|
|
|
|
SearchConditionItem deptNameItem = OrganizationFormItemUtil.inputItem(user, 2, 16, 2, 50, "名称", "deptName");
|
|
|
|
|
SearchConditionItem deptNameItem = OrganizationFormItemUtil.inputItem(user, 2, 16, 2, 50, "名称", "departmentName");
|
|
|
|
|
// 简称
|
|
|
|
|
SearchConditionItem deptNameShortItem = OrganizationFormItemUtil.inputItem(user, 2, 16, 2, 50, "简称", "deptNameShort");
|
|
|
|
|
// TODO
|
|
|
|
@ -274,7 +319,7 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
|
|
|
|
|
SearchConditionItem deptNoItem = OrganizationFormItemUtil.inputItem(user, 2, 16, 3, 50, "编号", "deptNo");
|
|
|
|
|
deptNoItem.setRules("required|string");
|
|
|
|
|
// 名称
|
|
|
|
|
SearchConditionItem deptNameItem = OrganizationFormItemUtil.inputItem(user, 2, 16, 3, 50, "名称", "deptName");
|
|
|
|
|
SearchConditionItem deptNameItem = OrganizationFormItemUtil.inputItem(user, 2, 16, 3, 50, "名称", "departmentName");
|
|
|
|
|
deptNameItem.setRules("required|string");
|
|
|
|
|
// 简称
|
|
|
|
|
SearchConditionItem deptNameShortItem = OrganizationFormItemUtil.inputItem(user, 2, 16, 3, 50, "简称", "deptNameShort");
|
|
|
|
@ -328,7 +373,7 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
|
|
|
|
|
// 编号
|
|
|
|
|
SearchConditionItem deptNoItem = OrganizationFormItemUtil.inputItem(user, 2, 16, 1, 50, "编号", "deptNo");
|
|
|
|
|
// 名称
|
|
|
|
|
SearchConditionItem deptNameItem = OrganizationFormItemUtil.inputItem(user, 2, 16, 3, 50, "名称", "deptName");
|
|
|
|
|
SearchConditionItem deptNameItem = OrganizationFormItemUtil.inputItem(user, 2, 16, 3, 50, "名称", "departmentName");
|
|
|
|
|
deptNameItem.setRules("required|string");
|
|
|
|
|
// 简称
|
|
|
|
|
SearchConditionItem deptNameShortItem = OrganizationFormItemUtil.inputItem(user, 2, 16, 3, 50, "简称", "deptNameShort");
|
|
|
|
@ -411,5 +456,115 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取集团
|
|
|
|
|
*
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
private SearchTree getTopGroup() {
|
|
|
|
|
RecordSet rs = new RecordSet();
|
|
|
|
|
String sql = "select * from HrmCompany ";
|
|
|
|
|
rs.executeQuery(sql);
|
|
|
|
|
SearchTree groupTree = new SearchTree();
|
|
|
|
|
groupTree.setCanClick(false);
|
|
|
|
|
groupTree.setCanceled(false);
|
|
|
|
|
groupTree.setCompanyid("1");
|
|
|
|
|
groupTree.setIcon("icon-coms-LargeArea");
|
|
|
|
|
groupTree.setId("0");
|
|
|
|
|
groupTree.setIsVirtual("0");
|
|
|
|
|
while (rs.next()) {
|
|
|
|
|
groupTree.setName(rs.getString("COMPANYNAME"));
|
|
|
|
|
}
|
|
|
|
|
groupTree.setSelected(false);
|
|
|
|
|
groupTree.setType(TYPE_GROUP);
|
|
|
|
|
return groupTree;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 根据keyword查询数据
|
|
|
|
|
*
|
|
|
|
|
* @param id
|
|
|
|
|
* @param type
|
|
|
|
|
* @param keyword
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
private List<TreeNode> getFilterCompany(String id, String type, String keyword) {
|
|
|
|
|
List<TreeNode> compSearchTree = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// 查询部门信息
|
|
|
|
|
Long parentCompId = StringUtil.isEmpty(id) ? null : Long.parseLong(id);
|
|
|
|
|
CompPO compBuild = CompPO.builder().compName(keyword).parentCompany(parentCompId).build();
|
|
|
|
|
List<CompPO> filterComps = getCompMapper().listByFilter(compBuild);
|
|
|
|
|
|
|
|
|
|
Set<CompPO> builderComps = new HashSet<>();
|
|
|
|
|
for (CompPO compPO : filterComps) {
|
|
|
|
|
buildParentComps(compPO, builderComps);
|
|
|
|
|
}
|
|
|
|
|
List<SearchTree> compTrees = builderTreeMode(CompBO.buildSetToSearchTree(builderComps));
|
|
|
|
|
|
|
|
|
|
// 排序,设置是否为叶子节点
|
|
|
|
|
List<TreeNode> collect = compTrees.stream().peek(item ->
|
|
|
|
|
item.setIsParent(CollectionUtils.isNotEmpty(item.getSubs()))
|
|
|
|
|
).sorted(Comparator.comparing(item -> Integer.parseInt(item.getId()))).collect(Collectors.toList());
|
|
|
|
|
if (CollectionUtils.isNotEmpty(collect)) {
|
|
|
|
|
compSearchTree.addAll(collect);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return compSearchTree;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 添加查询元素的父级元素
|
|
|
|
|
*
|
|
|
|
|
* @param compPO
|
|
|
|
|
* @param builderComps
|
|
|
|
|
*/
|
|
|
|
|
private void buildParentComps(CompPO compPO, Set<CompPO> builderComps) {
|
|
|
|
|
builderComps.add(compPO);
|
|
|
|
|
if (isTop(compPO.getParentCompany())) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
CompPO parentComp = getCompMapper().listById(compPO.getParentCompany());
|
|
|
|
|
if (null != parentComp) {
|
|
|
|
|
buildParentComps(parentComp, builderComps);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 处理树层级
|
|
|
|
|
*
|
|
|
|
|
* @param treeList
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
private List<SearchTree> builderTreeMode(List<SearchTree> treeList) {
|
|
|
|
|
Map<String, List<TreeNode>> collects = treeList.stream().collect(Collectors.groupingBy(TreeNode::getPid));
|
|
|
|
|
return treeList.stream().peek(e -> e.setSubs(collects.get(e.getId()))).peek(item -> {
|
|
|
|
|
if (CollectionUtils.isNotEmpty(item.getSubs())) {
|
|
|
|
|
item.setIsParent(true);
|
|
|
|
|
}
|
|
|
|
|
}).filter(item -> isTop(item.getPid())).collect(Collectors.toList());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 判断是为顶层数据
|
|
|
|
|
*
|
|
|
|
|
* @param pid
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
private boolean isTop(Long pid) {
|
|
|
|
|
return null == pid;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 判断是为顶层数据
|
|
|
|
|
*
|
|
|
|
|
* @param pid
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
private boolean isTop(String pid) {
|
|
|
|
|
return StringUtil.isEmpty(pid) || "0".equals(pid);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|