|
|
|
@ -26,7 +26,6 @@ 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.crm.Maint.SectorInfoComInfo;
|
|
|
|
|
import weaver.general.StringUtil;
|
|
|
|
|
import weaver.general.Util;
|
|
|
|
@ -75,25 +74,27 @@ public class CompServiceImpl extends Service implements CompService {
|
|
|
|
|
@Override
|
|
|
|
|
public Map<String, Object> listPage(CompSearchParam params) {
|
|
|
|
|
Map<String, Object> datas = new HashMap<>();
|
|
|
|
|
PageUtil.start(params.getCurrent(), params.getPageSize());
|
|
|
|
|
List<CompPO> parentList = getCompMapper().listParent();
|
|
|
|
|
|
|
|
|
|
List<CompPO> list = new ArrayList<>();
|
|
|
|
|
list.addAll(parentList);
|
|
|
|
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(parentList)) {
|
|
|
|
|
// 递归查询子数据
|
|
|
|
|
getChildPOs(parentList, list);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CompPO compPO = CompBO.convertParamToPO(params, (long) user.getUID());
|
|
|
|
|
// 搜索条件过滤数据
|
|
|
|
|
List<CompPO> filterList = filterListByParams(list, compPO);
|
|
|
|
|
boolean filter = isFilter(compPO);
|
|
|
|
|
PageInfo<CompListDTO> pageInfos;
|
|
|
|
|
List<CompPO> alltList = getCompMapper().list();
|
|
|
|
|
// 通过子级遍历父级元素
|
|
|
|
|
if (filter) {
|
|
|
|
|
// 根据条件获取元素
|
|
|
|
|
List<CompPO> filterCompPOs = getCompMapper().listByFilter(compPO);
|
|
|
|
|
// 添加父级元素
|
|
|
|
|
List<CompListDTO> compListDTOS = CompBO.buildCompDTOList(alltList, filterCompPOs);
|
|
|
|
|
List<CompListDTO> subList = PageUtil.subList(params.getCurrent(), params.getPageSize(), compListDTOS);
|
|
|
|
|
pageInfos = new PageInfo<>(subList, CompListDTO.class);
|
|
|
|
|
pageInfos.setTotal(compListDTOS.size());
|
|
|
|
|
} else {
|
|
|
|
|
// 组合list
|
|
|
|
|
List<CompListDTO> compListDTOS = CompBO.buildCompDTOList(alltList);
|
|
|
|
|
List<CompListDTO> subList = PageUtil.subList(params.getCurrent(), params.getPageSize(), compListDTOS);
|
|
|
|
|
pageInfos = new PageInfo<>(subList, CompListDTO.class);
|
|
|
|
|
pageInfos.setTotal(compListDTOS.size());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<CompListDTO> compListDTOS = CompBO.buildCompDTOList(list, filterList);
|
|
|
|
|
PageInfo<CompListDTO> pageInfo = new PageInfo<>(compListDTOS);
|
|
|
|
|
PageInfo<CompListDTO> pageInfos = new PageInfo<>(compListDTOS, CompListDTO.class);
|
|
|
|
|
pageInfos.setTotal(pageInfo.getTotal());
|
|
|
|
|
pageInfos.setPageNum(params.getCurrent());
|
|
|
|
|
pageInfos.setPageSize(params.getPageSize());
|
|
|
|
|
|
|
|
|
@ -262,10 +263,8 @@ public class CompServiceImpl extends Service implements CompService {
|
|
|
|
|
// 简称
|
|
|
|
|
SearchConditionItem compNameShortItem = OrganizationFormItemUtil.inputItem(user, 2, 16, 3, 50, "简称", "compNameShort");
|
|
|
|
|
compNameShortItem.setRules("required|string");
|
|
|
|
|
// TODO 自定义按钮
|
|
|
|
|
// 上级公司
|
|
|
|
|
SearchConditionItem compBrowserItem = OrganizationFormItemUtil.browserItem(user, 2, 16, 3, false, "上级公司", "161", "parentCompany", "compBrowser");
|
|
|
|
|
compBrowserItem.setRules("required|string");
|
|
|
|
|
SearchConditionItem compBrowserItem = OrganizationFormItemUtil.browserItem(user, 2, 16, 2, false, "上级公司", "161", "parentCompany", "compBrowser");
|
|
|
|
|
// 组织机构代码
|
|
|
|
|
SearchConditionItem orgCodeItem = OrganizationFormItemUtil.inputItem(user, 2, 16, 3, 50, "组织机构代码", "orgCode");
|
|
|
|
|
orgCodeItem.setRules("required|string");
|
|
|
|
@ -293,50 +292,14 @@ public class CompServiceImpl extends Service implements CompService {
|
|
|
|
|
return apiDatas;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 递归获取子级数据
|
|
|
|
|
* 是否为搜索查询
|
|
|
|
|
*
|
|
|
|
|
* @param parentList
|
|
|
|
|
* @param list
|
|
|
|
|
*/
|
|
|
|
|
private void getChildPOs(List<CompPO> parentList, List<CompPO> list) {
|
|
|
|
|
List<Long> ids = parentList.stream().map(CompPO::getId).collect(Collectors.toList());
|
|
|
|
|
List<CompPO> listchild = getCompMapper().listChild(ids);
|
|
|
|
|
if (CollectionUtils.isNotEmpty(listchild)) {
|
|
|
|
|
list.addAll(listchild);
|
|
|
|
|
getChildPOs(listchild, list);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 通过搜索条件过滤list数据
|
|
|
|
|
*
|
|
|
|
|
* @param compPOS
|
|
|
|
|
* @param compPO
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
private List<CompPO> filterListByParams(Collection<CompPO> compPOS, CompPO compPO) {
|
|
|
|
|
// 搜索后的数据
|
|
|
|
|
List<CompPO> filterList = new ArrayList<>();
|
|
|
|
|
// 筛选数据
|
|
|
|
|
for (Iterator<CompPO> iterator = compPOS.iterator(); iterator.hasNext(); ) {
|
|
|
|
|
CompPO next = iterator.next();
|
|
|
|
|
boolean isAdd = (StringUtil.isEmpty(compPO.getCompName()) || next.getCompName().contains(compPO.getCompName())) // 名称
|
|
|
|
|
&& (StringUtil.isEmpty(compPO.getCompNo()) || next.getCompNo().contains(compPO.getCompNo()))//编号
|
|
|
|
|
&& (StringUtil.isEmpty(compPO.getCompNameShort()) || next.getCompNameShort().contains(compPO.getCompNameShort()))//简称
|
|
|
|
|
&& (null == compPO.getParentCompany() || next.getParentCompany().equals(compPO.getParentCompany()))//上级公司
|
|
|
|
|
&& (StringUtil.isEmpty(compPO.getOrgCode()) || next.getOrgCode().contains(compPO.getOrgCode()))//组织机构代码
|
|
|
|
|
&& (null == compPO.getIndustry() || next.getIndustry().equals(compPO.getIndustry()))//行业
|
|
|
|
|
&& (null == compPO.getCompPrincipal() || next.getCompPrincipal().equals(compPO.getCompPrincipal()))//负责人
|
|
|
|
|
&& (null == compPO.getForbiddenTag() || next.getForbiddenTag().equals(compPO.getForbiddenTag()));//禁用标记
|
|
|
|
|
if (isAdd) {
|
|
|
|
|
filterList.add(next);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
return filterList;
|
|
|
|
|
private boolean isFilter(CompPO compPO) {
|
|
|
|
|
return !(StringUtil.isEmpty(compPO.getCompName()) && StringUtil.isEmpty(compPO.getCompNo()) && null == compPO.getParentCompany() && StringUtil.isEmpty(compPO.getOrgCode()) && null == compPO.getIndustry() && null == compPO.getCompPrincipal() && null == compPO.getForbiddenTag());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -380,10 +343,12 @@ public class CompServiceImpl extends Service implements CompService {
|
|
|
|
|
SearchConditionItem compBrowserItem = OrganizationFormItemUtil.browserItem(user, 2, 16, 2, false, "上级公司", "161", "parentCompany", "compBrowser");
|
|
|
|
|
// 组织机构代码
|
|
|
|
|
SearchConditionItem orgCodeItem = OrganizationFormItemUtil.inputItem(user, 2, 16, 2, 50, "组织机构代码", "orgCode");
|
|
|
|
|
orgCodeItem.setRules("required|string");
|
|
|
|
|
// 行业
|
|
|
|
|
SearchConditionItem industryItem = OrganizationFormItemUtil.browserItem(user, 2, 16, 2, false, "行业", "63", "industry", "");
|
|
|
|
|
// 负责人
|
|
|
|
|
SearchConditionItem compPrincipalItem = OrganizationFormItemUtil.browserItem(user, 2, 16, 2, false, "负责人", "1", "compPrincipal", "");
|
|
|
|
|
compPrincipalItem.setRules("required|string");
|
|
|
|
|
// 说明
|
|
|
|
|
SearchConditionItem descriptionItem = OrganizationFormItemUtil.textareaItem(user, 2, 16, true, 2, 60, "说明", "description");
|
|
|
|
|
|
|
|
|
|