|
|
|
package com.engine.organization.service.impl;
|
|
|
|
|
|
|
|
|
|
|
|
import com.api.browser.bean.SearchConditionGroup;
|
|
|
|
import com.api.browser.bean.SearchConditionItem;
|
|
|
|
import com.api.browser.bean.SearchConditionOption;
|
|
|
|
import com.cloudstore.eccom.pc.table.WeaTableColumn;
|
|
|
|
import com.cloudstore.eccom.result.WeaResultMsg;
|
|
|
|
import com.engine.core.impl.Service;
|
|
|
|
import com.engine.organization.component.OrganizationWeaTable;
|
|
|
|
import com.engine.organization.entity.TopTab;
|
|
|
|
import com.engine.organization.entity.comp.bo.CompBO;
|
|
|
|
import com.engine.organization.entity.comp.dto.CompListDTO;
|
|
|
|
import com.engine.organization.entity.comp.param.CompSearchParam;
|
|
|
|
import com.engine.organization.entity.comp.po.CompPO;
|
|
|
|
import com.engine.organization.entity.comp.po.ExtendGroupPO;
|
|
|
|
import com.engine.organization.mapper.comp.CompMapper;
|
|
|
|
import com.engine.organization.mapper.comp.ExtendGroupMapper;
|
|
|
|
import com.engine.organization.service.CompService;
|
|
|
|
import com.engine.organization.util.MenuBtn;
|
|
|
|
import com.engine.organization.util.OrganizationAssert;
|
|
|
|
import com.engine.organization.util.OrganizationFormItemUtil;
|
|
|
|
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.general.StringUtil;
|
|
|
|
|
|
|
|
import java.util.*;
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @description: TODO
|
|
|
|
* @author:dxfeng
|
|
|
|
* @createTime: 2022/05/16
|
|
|
|
* @version: 1.0
|
|
|
|
*/
|
|
|
|
public class CompServiceImpl extends Service implements CompService {
|
|
|
|
private CompMapper getCompMapper() {
|
|
|
|
return MapperProxyFactory.getProxy(CompMapper.class);
|
|
|
|
}
|
|
|
|
|
|
|
|
private ExtendGroupMapper getExtendGroupMapper() {
|
|
|
|
return MapperProxyFactory.getProxy(ExtendGroupMapper.class);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Map<String, Object> listPage(CompSearchParam params) {
|
|
|
|
Map<String, Object> datas = new HashMap<>();
|
|
|
|
PageUtil.start(params.getCurrent(), params.getPageSize());
|
|
|
|
CompPO compPO = CompBO.convertParamToPO(params, (long) user.getUID());
|
|
|
|
List<CompPO> list = getCompMapper().list(compPO);
|
|
|
|
PageInfo<CompPO> pageInfo = new PageInfo<>(list, CompPO.class);
|
|
|
|
Collection<CompPO> compPOS = pageInfo.getList();
|
|
|
|
|
|
|
|
// 搜索条件过滤数据
|
|
|
|
List<CompPO> filterList = filterListByParams(compPOS, compPO);
|
|
|
|
|
|
|
|
List<CompListDTO> compListDTOS = CompBO.buildCompDTOList(list, filterList);
|
|
|
|
PageInfo<CompListDTO> pageInfos = new PageInfo<>(compListDTOS, CompListDTO.class);
|
|
|
|
pageInfos.setTotal(pageInfos.getTotal());
|
|
|
|
pageInfos.setPageNum(params.getCurrent());
|
|
|
|
pageInfos.setPageSize(params.getPageSize());
|
|
|
|
|
|
|
|
OrganizationWeaTable<CompListDTO> table = new OrganizationWeaTable<>(user, CompListDTO.class);
|
|
|
|
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);
|
|
|
|
result.putAll(table.makeDataResult());
|
|
|
|
result.success();
|
|
|
|
|
|
|
|
|
|
|
|
datas.put("pageInfo", pageInfos);
|
|
|
|
datas.put("dataKey", result.getResultMap());
|
|
|
|
return datas;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int updateForbiddenTagById(CompSearchParam params) {
|
|
|
|
CompPO compPO = CompPO.builder().id(params.getId()).forbiddenTag(params.getForbiddenTag() ? 0 : 1).build();
|
|
|
|
return getCompMapper().updateForbiddenTagById(compPO);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int deleteByIds(Collection<Long> ids) {
|
|
|
|
OrganizationAssert.notEmpty(ids, "请选择要删除的数据");
|
|
|
|
return getCompMapper().deleteByIds(ids);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Map<String, Object> getSearchCondition(Map<String, Object> params) {
|
|
|
|
Map<String, Object> apiDatas = new HashMap<>();
|
|
|
|
List<SearchConditionGroup> addGroups = new ArrayList<>();
|
|
|
|
List<SearchConditionItem> conditionItems = new ArrayList<>();
|
|
|
|
// 编号
|
|
|
|
SearchConditionItem compNoItem = OrganizationFormItemUtil.inputItem(user, 2, 16, 2, 50, "编号", "compNo");
|
|
|
|
// 名称
|
|
|
|
SearchConditionItem compNameItem = OrganizationFormItemUtil.inputItem(user, 2, 16, 2, 50, "名称", "compName");
|
|
|
|
// 简称
|
|
|
|
SearchConditionItem compNameShortItem = OrganizationFormItemUtil.inputItem(user, 2, 16, 2, 50, "简称", "compNameShort");
|
|
|
|
// TODO
|
|
|
|
// 上级公司
|
|
|
|
SearchConditionItem compBrowserItem = OrganizationFormItemUtil.browserItem(user, 2, 16, 2, false, "上级公司", "161", "parentCompany", "compBrowser");
|
|
|
|
// 组织机构代码
|
|
|
|
SearchConditionItem orgCodeItem = OrganizationFormItemUtil.inputItem(user, 2, 16, 2, 50, "组织机构代码", "orgCode");
|
|
|
|
// 行业
|
|
|
|
SearchConditionItem industryItem = OrganizationFormItemUtil.browserItem(user, 2, 16, 2, false, "行业", "63", "industry", "");
|
|
|
|
// 负责人
|
|
|
|
SearchConditionItem compPrincipalItem = OrganizationFormItemUtil.browserItem(user, 2, 16, 2, false, "负责人", "1", "compPrincipal", "");
|
|
|
|
// 禁用标记
|
|
|
|
List<SearchConditionOption> selectOptions = new ArrayList<>();
|
|
|
|
SearchConditionOption enableOption = new SearchConditionOption("true", "启用");
|
|
|
|
SearchConditionOption disableOption = new SearchConditionOption("false", "禁用");
|
|
|
|
selectOptions.add(enableOption);
|
|
|
|
selectOptions.add(disableOption);
|
|
|
|
SearchConditionItem forbiddenTagItem = OrganizationFormItemUtil.selectItem(user, selectOptions, 2, 16, 6, false, "禁用标记", "forbiddenTag");
|
|
|
|
|
|
|
|
conditionItems.add(compNoItem);
|
|
|
|
conditionItems.add(compNameItem);
|
|
|
|
conditionItems.add(compNameShortItem);
|
|
|
|
conditionItems.add(compBrowserItem);
|
|
|
|
conditionItems.add(orgCodeItem);
|
|
|
|
conditionItems.add(industryItem);
|
|
|
|
conditionItems.add(compPrincipalItem);
|
|
|
|
conditionItems.add(forbiddenTagItem);
|
|
|
|
|
|
|
|
addGroups.add(new SearchConditionGroup("高级搜索条件", true, conditionItems));
|
|
|
|
apiDatas.put("conditions", addGroups);
|
|
|
|
return apiDatas;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Map<String, Object> getHasRight() {
|
|
|
|
Map<String, Object> btnDatas = new HashMap<>();
|
|
|
|
ArrayList<MenuBtn> topMenuList = new ArrayList<>();
|
|
|
|
ArrayList<MenuBtn> rightMenuList = new ArrayList<>();
|
|
|
|
// 新增
|
|
|
|
topMenuList.add(MenuBtn.topMenu_addNew());
|
|
|
|
// 批量删除
|
|
|
|
topMenuList.add(MenuBtn.topMenu_batchDelete());
|
|
|
|
btnDatas.put("topMenu", topMenuList);
|
|
|
|
// 新增
|
|
|
|
rightMenuList.add(MenuBtn.rightMenu_addNew());
|
|
|
|
// 日志
|
|
|
|
rightMenuList.add(MenuBtn.rightMenu_btnLog());
|
|
|
|
btnDatas.put("rightMenu", rightMenuList);
|
|
|
|
return btnDatas;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Map<String, Object> getTabInfo() {
|
|
|
|
Map<String, Object> apiDatas = new HashMap<>();
|
|
|
|
List<TopTab> topTabs = new ArrayList<>();
|
|
|
|
// 基本信息
|
|
|
|
topTabs.add(TopTab.builder().color("#000000").groupId("0").showcount(false).title("基本信息").viewCondition("0").build());
|
|
|
|
// 拓展信息
|
|
|
|
List<ExtendGroupPO> groupPOList = getExtendGroupMapper().listByType("");
|
|
|
|
if (CollectionUtils.isNotEmpty(groupPOList)) {
|
|
|
|
for (ExtendGroupPO groupPO : groupPOList) {
|
|
|
|
topTabs.add(TopTab.builder().color("#000000").groupId(groupPO.getId() + "").showcount(false).title(groupPO.getGroupName()).viewCondition(groupPO.getId() + "").build());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
apiDatas.put("topTabs", topTabs);
|
|
|
|
return apiDatas;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Map<String, Object> getCompForm(Map<String, Object> params) {
|
|
|
|
// operateType 0 查看 1新增 2编辑
|
|
|
|
String operateType = (String) params.get("operateType");
|
|
|
|
long id = Long.parseLong((String) params.get("id"));
|
|
|
|
List<SearchConditionItem> conditionItems = new ArrayList<>();
|
|
|
|
// 编号
|
|
|
|
SearchConditionItem compNoItem = OrganizationFormItemUtil.inputItem(user, 2, 16, 2, 50, "编号", "compNo");
|
|
|
|
// 名称
|
|
|
|
SearchConditionItem compNameItem = OrganizationFormItemUtil.inputItem(user, 2, 16, 2, 50, "名称", "compName");
|
|
|
|
// 简称
|
|
|
|
SearchConditionItem compNameShortItem = OrganizationFormItemUtil.inputItem(user, 2, 16, 2, 50, "简称", "compNameShort");
|
|
|
|
// TODO 自定义按钮
|
|
|
|
// 上级公司
|
|
|
|
SearchConditionItem compBrowserItem = OrganizationFormItemUtil.browserItem(user, 2, 16, 2, false, "上级公司", "161", "parentCompany", "compBrowser");
|
|
|
|
// 组织机构代码
|
|
|
|
SearchConditionItem orgCodeItem = OrganizationFormItemUtil.inputItem(user, 2, 16, 2, 50, "组织机构代码", "orgCode");
|
|
|
|
// 行业
|
|
|
|
SearchConditionItem industryItem = OrganizationFormItemUtil.browserItem(user, 2, 16, 2, false, "行业", "63", "industry", "");
|
|
|
|
// 负责人
|
|
|
|
SearchConditionItem compPrincipalItem = OrganizationFormItemUtil.browserItem(user, 2, 16, 2, false, "负责人", "1", "compPrincipal", "");
|
|
|
|
// 禁用标记
|
|
|
|
List<SearchConditionOption> selectOptions = new ArrayList<>();
|
|
|
|
SearchConditionOption enableOption = new SearchConditionOption("true", "启用");
|
|
|
|
SearchConditionOption disableOption = new SearchConditionOption("false", "禁用");
|
|
|
|
selectOptions.add(enableOption);
|
|
|
|
selectOptions.add(disableOption);
|
|
|
|
SearchConditionItem forbiddenTagItem = OrganizationFormItemUtil.selectItem(user, selectOptions, 2, 16, 6, false, "禁用标记", "forbiddenTag");
|
|
|
|
|
|
|
|
conditionItems.add(compNoItem);
|
|
|
|
conditionItems.add(compNameItem);
|
|
|
|
conditionItems.add(compNameShortItem);
|
|
|
|
conditionItems.add(compBrowserItem);
|
|
|
|
conditionItems.add(orgCodeItem);
|
|
|
|
conditionItems.add(industryItem);
|
|
|
|
conditionItems.add(compPrincipalItem);
|
|
|
|
conditionItems.add(forbiddenTagItem);
|
|
|
|
|
|
|
|
|
|
|
|
HashMap<String, Object> conditionsMap = new HashMap<>();
|
|
|
|
conditionsMap.put("items", conditionItems);
|
|
|
|
conditionsMap.put("title", "基本信息");
|
|
|
|
conditionsMap.put("hide", false);
|
|
|
|
conditionsMap.put("defaultshow", true);
|
|
|
|
|
|
|
|
|
|
|
|
HashMap<String, Object> buttonsMap = new HashMap<>();
|
|
|
|
buttonsMap.put("hasEdit", true);
|
|
|
|
buttonsMap.put("hasSave", true);
|
|
|
|
|
|
|
|
HashMap<String, Object> resultMap = new HashMap<>();
|
|
|
|
resultMap.put("buttons", buttonsMap);
|
|
|
|
resultMap.put("conditions", conditionsMap);
|
|
|
|
resultMap.put("id", id);
|
|
|
|
resultMap.put("tables", null);
|
|
|
|
Map<String, Object> apiDatas = new HashMap<>();
|
|
|
|
|
|
|
|
apiDatas.put("result", resultMap);
|
|
|
|
|
|
|
|
return apiDatas;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 通过搜索条件过滤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;
|
|
|
|
}
|
|
|
|
}
|