From 477df79cd114dbb124d2e12aa43a11f961ef35b3 Mon Sep 17 00:00:00 2001 From: dxfeng Date: Wed, 25 May 2022 09:54:14 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=86=E9=83=A8=E5=88=97=E8=A1=A8=E5=88=86?= =?UTF-8?q?=E9=A1=B5=20=E6=98=8E=E7=BB=86=E8=A1=A8=E5=AD=97=E6=AE=B5?= =?UTF-8?q?=E5=B1=95=E7=A4=BA=20BUG=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../organization/entity/comp/bo/CompBO.java | 27 ++++++ .../organization/mapper/comp/CompMapper.java | 7 ++ .../organization/mapper/comp/CompMapper.xml | 65 ++++++++++++++ .../mapper/department/DepartmentMapper.xml | 2 +- .../service/impl/CompServiceImpl.java | 85 ++++++------------- .../service/impl/ExtServiceImpl.java | 23 ++++- .../service/impl/SequenceServiceImpl.java | 1 + 7 files changed, 145 insertions(+), 65 deletions(-) diff --git a/src/com/engine/organization/entity/comp/bo/CompBO.java b/src/com/engine/organization/entity/comp/bo/CompBO.java index c23e8dee..4b70dbf7 100644 --- a/src/com/engine/organization/entity/comp/bo/CompBO.java +++ b/src/com/engine/organization/entity/comp/bo/CompBO.java @@ -18,6 +18,33 @@ import java.util.stream.Collectors; * @version: 1.0 */ public class CompBO { + + public static List buildCompDTOList(Collection list) { + + // 递归添加父级数据 + Map poMaps = list.stream().collect(Collectors.toMap(item -> item.getId(), item -> item)); + + + List dtoList = list.stream().map(e -> CompListDTO.builder() + .id(e.getId()) + .compNo(e.getCompNo()) + .compName(e.getCompName()) + .compNameShort(e.getCompNameShort()) + .parentCompany(e.getParentCompany()) + .parentCompName(null == poMaps.get(e.getParentCompany()) ? "" : poMaps.get(e.getParentCompany()).getCompName()) + .orgCode(e.getOrgCode()) + .industry(new SectorInfoComInfo().getSectorInfoname(e.getIndustry() + "")) + .compPrincipal(getUserNameById(e.getCompPrincipal() + "")) + .forbiddenTag(e.getForbiddenTag()) + .build() + ).collect(Collectors.toList()); + Map> collects = dtoList.stream().filter(item -> null != item.getParentCompany() && 0 != item.getParentCompany()).collect(Collectors.groupingBy(CompListDTO::getParentCompany)); + return dtoList.stream().map(e -> { + e.setChildren(collects.get(e.getId())); + return e; + }).filter(item -> null == item.getParentCompany() || 0 == item.getParentCompany()).collect(Collectors.toList()); + } + public static List buildCompDTOList(Collection list, List filterList) { // 搜索结果为空,直接返回空 if (CollectionUtils.isEmpty(filterList)) { diff --git a/src/com/engine/organization/mapper/comp/CompMapper.java b/src/com/engine/organization/mapper/comp/CompMapper.java index 1139155c..addd2c09 100644 --- a/src/com/engine/organization/mapper/comp/CompMapper.java +++ b/src/com/engine/organization/mapper/comp/CompMapper.java @@ -20,6 +20,13 @@ public interface CompMapper { */ List list(); + /** + * 根据搜索条件查询数据 + * + * @return + */ + List listByFilter(CompPO compPO); + /** * 获取顶级数据 * diff --git a/src/com/engine/organization/mapper/comp/CompMapper.xml b/src/com/engine/organization/mapper/comp/CompMapper.xml index 263836cb..38296611 100644 --- a/src/com/engine/organization/mapper/comp/CompMapper.xml +++ b/src/com/engine/organization/mapper/comp/CompMapper.xml @@ -176,6 +176,26 @@ from jcl_org_comp t where comp_no = #{compNo} AND delete_type = 0 + update jcl_org_comp @@ -211,4 +231,49 @@ WHERE id = #{id} AND delete_type = 0 + + + and t.comp_no like CONCAT('%',#{compNo},'%') + + + and t.comp_name like CONCAT('%',#{compName},'%') + + + and t.comp_name_short like CONCAT('%',#{compNameShort},'%') + + + and t.org_code like CONCAT('%',#{orgCode},'%') + + + + + + and t.comp_no like '%'||#{compNo}||'%' + + + and t.comp_name like '%'||#{compName}||'%' + + + and t.comp_name_short like '%'||#{compNameShort}||'%' + + + and t.org_code like '%'||#{orgCode}||'%' + + + + + + and t.comp_no like '%'+#{compNo}+'%' + + + and t.comp_name like '%'+#{compName}+'%' + + + and t.comp_name_short like '%'+#{compNameShort}+'%' + + + and t.org_code like '%'+#{orgCode}+'%' + + + \ No newline at end of file diff --git a/src/com/engine/organization/mapper/department/DepartmentMapper.xml b/src/com/engine/organization/mapper/department/DepartmentMapper.xml index 9b022ad2..d8804f61 100644 --- a/src/com/engine/organization/mapper/department/DepartmentMapper.xml +++ b/src/com/engine/organization/mapper/department/DepartmentMapper.xml @@ -64,7 +64,7 @@ and t.show_order = #{showOrder} - + and t.forbidden_tag = #{forbiddenTag} diff --git a/src/com/engine/organization/service/impl/CompServiceImpl.java b/src/com/engine/organization/service/impl/CompServiceImpl.java index 848ef467..aac49022 100644 --- a/src/com/engine/organization/service/impl/CompServiceImpl.java +++ b/src/com/engine/organization/service/impl/CompServiceImpl.java @@ -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 listPage(CompSearchParam params) { Map datas = new HashMap<>(); - PageUtil.start(params.getCurrent(), params.getPageSize()); - List parentList = getCompMapper().listParent(); - - List list = new ArrayList<>(); - list.addAll(parentList); - - if (CollectionUtils.isNotEmpty(parentList)) { - // 递归查询子数据 - getChildPOs(parentList, list); - } - CompPO compPO = CompBO.convertParamToPO(params, (long) user.getUID()); - // 搜索条件过滤数据 - List filterList = filterListByParams(list, compPO); + boolean filter = isFilter(compPO); + PageInfo pageInfos; + List alltList = getCompMapper().list(); + // 通过子级遍历父级元素 + if (filter) { + // 根据条件获取元素 + List filterCompPOs = getCompMapper().listByFilter(compPO); + // 添加父级元素 + List compListDTOS = CompBO.buildCompDTOList(alltList, filterCompPOs); + List subList = PageUtil.subList(params.getCurrent(), params.getPageSize(), compListDTOS); + pageInfos = new PageInfo<>(subList, CompListDTO.class); + pageInfos.setTotal(compListDTOS.size()); + } else { + // 组合list + List compListDTOS = CompBO.buildCompDTOList(alltList); + List subList = PageUtil.subList(params.getCurrent(), params.getPageSize(), compListDTOS); + pageInfos = new PageInfo<>(subList, CompListDTO.class); + pageInfos.setTotal(compListDTOS.size()); + } - List compListDTOS = CompBO.buildCompDTOList(list, filterList); - PageInfo pageInfo = new PageInfo<>(compListDTOS); - PageInfo 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 parentList, List list) { - List ids = parentList.stream().map(CompPO::getId).collect(Collectors.toList()); - List listchild = getCompMapper().listChild(ids); - if (CollectionUtils.isNotEmpty(listchild)) { - list.addAll(listchild); - getChildPOs(listchild, list); - } - } - - - /** - * 通过搜索条件过滤list数据 - * - * @param compPOS * @param compPO * @return */ - private List filterListByParams(Collection compPOS, CompPO compPO) { - // 搜索后的数据 - List filterList = new ArrayList<>(); - // 筛选数据 - for (Iterator 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"); diff --git a/src/com/engine/organization/service/impl/ExtServiceImpl.java b/src/com/engine/organization/service/impl/ExtServiceImpl.java index fc2b4edc..7bdb6612 100644 --- a/src/com/engine/organization/service/impl/ExtServiceImpl.java +++ b/src/com/engine/organization/service/impl/ExtServiceImpl.java @@ -27,6 +27,8 @@ import java.util.stream.Collectors; */ public class ExtServiceImpl extends Service implements ExtService { + private static final Integer BROWSER_TYPE = 3; + private ExtendInfoMapper getExtendInfoMapper() { return MapperProxyFactory.getProxy(ExtendInfoMapper.class); } @@ -82,8 +84,17 @@ public class ExtServiceImpl extends Service implements ExtService { tabinfoMap.put("columns", ExtendInfoBO.convertInfoListToTable(user, entry.getValue(), viewAttr, showLabel)); tabinfoMap.put("rownum", "rownum"); - String fields = entry.getValue().stream().map(ExtendInfoPO::getFieldName).collect(Collectors.joining(",")); - tabinfoMap.put("datas", getExtDTMapper().listCompExtDT(tableName, id, fields)); + // 浏览按钮添加filespan字段 + String fields = entry.getValue().stream().map(item -> { + if (BROWSER_TYPE == item.getControlType()) { + return item.getFieldName() + "," + item.getFieldName() + "span"; + } + return item.getFieldName(); + }).collect(Collectors.joining(",")); + // 去除null 元素 + List> maps = getExtDTMapper().listCompExtDT(tableName, id, fields); + maps.removeIf(Objects::isNull); + tabinfoMap.put("datas", maps); tableMap.put("tabinfo", tabinfoMap); tables.add(tableMap); } @@ -147,10 +158,14 @@ public class ExtServiceImpl extends Service implements ExtService { getExtDTMapper().deleteByMainID(tableName, id); // 处理明细表数据 int rowNum = Util.getIntValue((String) params.get("rownum")); + rowNum = 5; for (int i = 0; i < rowNum; i++) { Map map = new HashMap<>(); - for (String dtField : dtFields) { - map.put(dtField, params.get(dtField + "_" + i)); + for (ExtendInfoPO extendInfoPO : dtInfoPOList) { + if (BROWSER_TYPE == extendInfoPO.getControlType()) { + map.put(extendInfoPO.getFieldName() + "span", params.get(extendInfoPO.getFieldName() + "span_" + i)); + } + map.put(extendInfoPO.getFieldName(), params.get(extendInfoPO.getFieldName() + "_" + i)); } map.put("mainid", id); map.put("creator", user.getUID()); diff --git a/src/com/engine/organization/service/impl/SequenceServiceImpl.java b/src/com/engine/organization/service/impl/SequenceServiceImpl.java index d33aafaa..58e22368 100644 --- a/src/com/engine/organization/service/impl/SequenceServiceImpl.java +++ b/src/com/engine/organization/service/impl/SequenceServiceImpl.java @@ -109,6 +109,7 @@ public class SequenceServiceImpl extends Service implements SequenceService { sequenceNoCondition.setRules("required|string"); SearchConditionItem descriptionCondition = OrganizationFormItemUtil.textareaItem(user, 2, 17, true, 2, 60, "描述说明", "description"); SearchConditionItem browserItem = OrganizationFormItemUtil.browserItem(user, 2, 17, 3, false, "等级方案", "161", "schemeId", "schemeBrowser"); + browserItem.setRules("required|string"); // 编辑状态下赋值操作 String id = Util.null2String(params.get("id"));