Pre Merge pull request !19 from dxfeng/feature/dxf

pull/19/MERGE
dxfeng 3 years ago committed by Gitee
commit 0a2e7ef763
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F

@ -18,6 +18,33 @@ import java.util.stream.Collectors;
* @version: 1.0
*/
public class CompBO {
public static List<CompListDTO> buildCompDTOList(Collection<CompPO> list) {
// 递归添加父级数据
Map<Long, CompPO> poMaps = list.stream().collect(Collectors.toMap(item -> item.getId(), item -> item));
List<CompListDTO> 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<Long, List<CompListDTO>> 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<CompListDTO> buildCompDTOList(Collection<CompPO> list, List<CompPO> filterList) {
// 搜索结果为空,直接返回空
if (CollectionUtils.isEmpty(filterList)) {

@ -20,6 +20,13 @@ public interface CompMapper {
*/
List<CompPO> list();
/**
*
*
* @return
*/
List<CompPO> listByFilter(CompPO compPO);
/**
*
*

@ -176,6 +176,26 @@
<include refid="baseColumns"/>
from jcl_org_comp t where comp_no = #{compNo} AND delete_type = 0
</select>
<select id="listByFilter" parameterType="com.engine.organization.entity.comp.po.CompPO" resultMap="BaseResultMap">
SELECT
<include refid="baseColumns"/>
FROM
jcl_org_comp t
WHERE t.delete_type = 0
<include refid="likeSQL"/>
<if test=" parentCompany != null ">
and t.parent_company = #{parentCompany}
</if>
<if test=" industry != null ">
and t.industry = #{industry}
</if>
<if test=" compPrincipal != null ">
and t.comp_principal = #{compPrincipal}
</if>
<if test=" forbiddenTag != null ">
and t.forbidden_tag = #{forbiddenTag}
</if>
</select>
<update id="updateForbiddenTagById" parameterType="com.engine.organization.entity.sequence.po.SequencePO">
update jcl_org_comp
@ -211,4 +231,49 @@
WHERE id = #{id} AND delete_type = 0
</update>
<sql id="likeSQL">
<if test=" compNo != null and compNo != '' ">
and t.comp_no like CONCAT('%',#{compNo},'%')
</if>
<if test=" compName != null and compName != '' ">
and t.comp_name like CONCAT('%',#{compName},'%')
</if>
<if test=" compNameShort != null and compNameShort != '' ">
and t.comp_name_short like CONCAT('%',#{compNameShort},'%')
</if>
<if test=" orgCode != null and orgCode != '' ">
and t.org_code like CONCAT('%',#{orgCode},'%')
</if>
</sql>
<sql id="likeSQL" databaseId="oracle">
<if test=" compNo != null and compNo != '' ">
and t.comp_no like '%'||#{compNo}||'%'
</if>
<if test=" compName != null and compName != '' ">
and t.comp_name like '%'||#{compName}||'%'
</if>
<if test=" compNameShort != null and compNameShort != '' ">
and t.comp_name_short like '%'||#{compNameShort}||'%'
</if>
<if test=" orgCode != null and orgCode != '' ">
and t.org_code like '%'||#{orgCode}||'%'
</if>
</sql>
<sql id="likeSQL" databaseId="sqlserver">
<if test=" compNo != null and compNo != '' ">
and t.comp_no like '%'+#{compNo}+'%'
</if>
<if test=" compName != null and compName != '' ">
and t.comp_name like '%'+#{compName}+'%'
</if>
<if test=" compNameShort != null and compNameShort != '' ">
and t.comp_name_short like '%'+#{compNameShort}+'%'
</if>
<if test=" orgCode != null and orgCode != '' ">
and t.org_code like '%'+#{orgCode}+'%'
</if>
</sql>
</mapper>

@ -64,7 +64,7 @@
<if test=" showOrder != null ">
and t.show_order = #{showOrder}
</if>
<if test=" showOrder != null ">
<if test=" forbiddenTag != null ">
and t.forbidden_tag = #{forbiddenTag}
</if>
</select>

@ -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");

@ -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<Map<String, Object>> 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<String, Object> 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());

@ -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"));

Loading…
Cancel
Save