公司/分部 列表接口

pull/9/MERGE
dxfeng 3 years ago
parent 5e8041348a
commit 5b088ce146

@ -32,10 +32,10 @@ public class CompBO {
.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().filter(item -> null == item.getParentCompany() || 0 == item.getParentCompany()).map(e -> {
return dtoList.stream().map(e -> {
e.setChildren(collects.get(e.getId()));
return e;
}).collect(Collectors.toList());
}).filter(item -> null == item.getParentCompany() || 0 == item.getParentCompany()).collect(Collectors.toList());
}
public static CompPO convertParamToPO(CompSearchParam param, Long employeeId) {

@ -38,48 +38,6 @@
, t.update_time
</sql>
<sql id="paramSql">
<if test="compNo != null and compNo !='' ">
and comp_no like CONCAT('%',#{compNo},'%')
</if>
<if test="compName != null and compName !='' ">
and comp_name like CONCAT('%',#{compName},'%')
</if>
<if test="compNameShort != null and compNameShort !='' ">
and comp_name_short like CONCAT('%',#{compNameShort},'%')
</if>
<if test="orgCode != null and orgCode !='' ">
and org_code like CONCAT('%',#{orgCode},'%')
</if>
</sql>
<!-- <sql id="paramSql" databaseId="oracle">-->
<!-- <if test="compNo != null and compNo !='' ">-->
<!-- and comp_no like '%'||#{compNo}||'%'-->
<!-- </if>-->
<!-- <if test="compName != null and compName !='' ">-->
<!-- and comp_name like '%'||#{compName}||'%'-->
<!-- </if>-->
<!-- <if test="compNameShort != null and compNameShort !='' ">-->
<!-- and comp_name_short like '%'||#{compNameShort}||'%'-->
<!-- </if>-->
<!-- <if test="orgCode != null and orgCode !='' ">-->
<!-- and org_code like '%'||#{orgCode}||'%'-->
<!-- </if>-->
<!-- </sql>-->
<!-- <sql id="paramSql" databaseId="sqlserver">-->
<!-- <if test="compNo != null and compNo !='' ">-->
<!-- and comp_no like '%'+#{compNo}+'%'-->
<!-- </if>-->
<!-- <if test="compName != null and compName !='' ">-->
<!-- and comp_name like '%'+#{compName}+'%'-->
<!-- </if>-->
<!-- <if test="compNameShort != null and compNameShort !='' ">-->
<!-- and comp_name_short like '%'+#{compNameShort}+'%'-->
<!-- </if>-->
<!-- <if test="orgCode != null and orgCode !='' ">-->
<!-- and org_code like '%'+#{orgCode}+'%'-->
<!-- </if>-->
<!-- </sql>-->
<select id="list" resultMap="BaseResultMap" parameterType="com.engine.organization.entity.comp.po.CompPO">
SELECT
@ -87,19 +45,6 @@
FROM
jcl_org_comp t
WHERE t.delete_type = 0
<if test="parentCompany != null and parentCompany !='' ">
and parent_company = #{parentCompany}
</if>
<if test="compPrincipal != null and compPrincipal !='' ">
and comp_principal = #{compPrincipal}
</if>
<if test="industry != null and industry !='' ">
and industry = #{industry}
</if>
<if test="forbiddenTag != null and forbiddenTag !='' ">
and forbidden_tag = #{forbiddenTag}
</if>
<include refid="paramSql"/>
</select>
<select id="listByNo" parameterType="com.engine.organization.entity.comp.po.CompPO" resultMap="BaseResultMap">

@ -21,6 +21,7 @@ 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 weaver.general.StringUtil;
import java.util.*;
import java.util.stream.Collectors;
@ -38,16 +39,24 @@ public class CompServiceImpl extends Service implements CompService {
@Override
public Map<String, Object> listPage(CompSearchParam params) {
Map<String,Object> datas = new HashMap<>();
Map<String, Object> datas = new HashMap<>();
PageUtil.start(params.getCurrent(), params.getPageSize());
List<CompPO> list = getCompMapper().list(CompBO.convertParamToPO(params,(long) user.getUID()));
List<CompPO> list = getCompMapper().list(CompBO.convertParamToPO(params, (long) user.getUID()));
PageInfo<CompPO> pageInfo = new PageInfo<>(list, CompPO.class);
Collection<CompPO> compPOS = pageInfo.getList();
//
List<CompListDTO> compListDTOS = CompBO.buildCompDTOList(compPOS);
// 搜索条件过滤数据
List<CompPO> filterList = filterListByParams(compPOS, params);
// 递归添加父级数据
Map<Long, CompPO> poMaps = list.stream().collect(Collectors.toMap(item -> item.getId(), item -> item));
List<CompPO> addedList = new ArrayList<>();
for (CompPO po : filterList) {
dealParentData(addedList, po, poMaps);
}
List<CompListDTO> compListDTOS = CompBO.buildCompDTOList(addedList);
PageInfo<CompListDTO> pageInfos = new PageInfo<>(compListDTOS, CompListDTO.class);
pageInfos.setTotal(pageInfo.getTotal());
pageInfos.setTotal(pageInfos.getTotal());
pageInfos.setPageNum(params.getCurrent());
pageInfos.setPageSize(params.getPageSize());
@ -55,6 +64,7 @@ public class CompServiceImpl extends Service implements CompService {
List<Column> columns = pageInfos.getColumns();
List<WeaTableColumn> weaTableColumn = columns.stream().map(v -> new WeaTableColumn("100", v.getTitle(), v.getKey())).collect(Collectors.toList());
table.setColumns(weaTableColumn);
WeaResultMsg result = new WeaResultMsg(false);
@ -63,7 +73,7 @@ public class CompServiceImpl extends Service implements CompService {
datas.put("pageInfo", pageInfos);
datas.put("dataKey",result.getResultMap());
datas.put("dataKey", result.getResultMap());
return datas;
}
@ -101,11 +111,11 @@ public class CompServiceImpl extends Service implements CompService {
SearchConditionItem compPrincipalItem = OrganizationFormItemUtil.inputItem(user, 2, 16, 2, 50, "负责人", "compPrincipal");
// 禁用标记
List<SearchConditionOption> selectOptions = new ArrayList<>();
SearchConditionOption enableOption = new SearchConditionOption("0","启用");
SearchConditionOption disableOption = new SearchConditionOption("1","禁用");
SearchConditionOption enableOption = new SearchConditionOption("0", "启用");
SearchConditionOption disableOption = new SearchConditionOption("1", "禁用");
selectOptions.add(enableOption);
selectOptions.add(disableOption);
SearchConditionItem forbiddenTagItem= OrganizationFormItemUtil.selectItem(user,selectOptions,2,16,6,false,"禁用标记","forbiddenTag");
SearchConditionItem forbiddenTagItem = OrganizationFormItemUtil.selectItem(user, selectOptions, 2, 16, 6, false, "禁用标记", "forbiddenTag");
conditionItems.add(compNoItem);
conditionItems.add(compNameItem);
@ -125,4 +135,43 @@ public class CompServiceImpl extends Service implements CompService {
public Map<String, Object> getHasRight() {
return MenuBtn.getCommonBtnDatas();
}
private List<CompPO> filterListByParams(Collection<CompPO> compPOS, CompSearchParam params) {
// 搜索后的数据
List<CompPO> filterList = new ArrayList<>();
// 筛选数据
for (Iterator<CompPO> iterator = compPOS.iterator(); iterator.hasNext(); ) {
CompPO next = iterator.next();
boolean isAdd = (StringUtil.isEmpty(params.getCompName()) || next.getCompName().contains(params.getCompName())) // 名称
&& (StringUtil.isEmpty(params.getCompNo()) || next.getCompNo().contains(params.getCompNo()))//编号
&& (StringUtil.isEmpty(params.getCompNameShort()) || next.getCompNameShort().contains(params.getCompNameShort()))//简称
&& (null == params.getParentCompany() || next.getParentCompany().equals(params.getParentCompany()))//上级公司
&& (StringUtil.isEmpty(params.getOrgCode()) || next.getOrgCode().contains(params.getOrgCode()))//组织机构代码
&& (null == params.getIndustry() || next.getIndustry().equals(params.getIndustry()))//行业
&& (null == params.getCompPrincipal() || next.getCompPrincipal().equals(params.getCompPrincipal()))//负责人
&& (null == params.getForbiddenTag() || next.getForbiddenTag().equals(params.getForbiddenTag()));//禁用标记
if (isAdd) {
filterList.add(next);
}
}
return filterList;
}
/**
*
*
* @param addedList
* @param po
* @param poMaps
*/
private void dealParentData(List<CompPO> addedList, CompPO po, Map<Long, CompPO> poMaps) {
if (!addedList.contains(po)) {
addedList.add(po);
}
CompPO parentCompPO = poMaps.get(po.getParentCompany());
if (null != parentCompPO) {
dealParentData(addedList, parentCompPO, poMaps);
}
}
}

Loading…
Cancel
Save