|
|
|
|
package com.engine.organization.service.impl;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
import com.api.browser.bean.BrowserBean;
|
|
|
|
|
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.extend.bo.ExtendInfoBO;
|
|
|
|
|
import com.engine.organization.entity.extend.po.ExtendInfoPO;
|
|
|
|
|
import com.engine.organization.mapper.comp.CompExtDTMapper;
|
|
|
|
|
import com.engine.organization.mapper.comp.CompExtMapper;
|
|
|
|
|
import com.engine.organization.mapper.comp.CompMapper;
|
|
|
|
|
import com.engine.organization.mapper.extend.ExtendGroupMapper;
|
|
|
|
|
import com.engine.organization.mapper.extend.ExtendInfoMapper;
|
|
|
|
|
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.crm.Maint.SectorInfoComInfo;
|
|
|
|
|
import weaver.general.StringUtil;
|
|
|
|
|
import weaver.general.Util;
|
|
|
|
|
import weaver.hrm.resource.ResourceComInfo;
|
|
|
|
|
|
|
|
|
|
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 {
|
|
|
|
|
/**
|
|
|
|
|
* 分组类型
|
|
|
|
|
* 1:分部
|
|
|
|
|
* 2:部门
|
|
|
|
|
* 3:岗位
|
|
|
|
|
*/
|
|
|
|
|
private static final String EXTEND_TYPE = "1";
|
|
|
|
|
/**
|
|
|
|
|
* 主表拓展表
|
|
|
|
|
*/
|
|
|
|
|
private static final String JCL_ORG_COMPEXT = "JCL_ORG_COMPEXT";
|
|
|
|
|
/**
|
|
|
|
|
* 明细表拓展表
|
|
|
|
|
*/
|
|
|
|
|
private static final String JCL_ORG_COMPEXT_DT1 = "JCL_ORG_COMPEXT_DT1";
|
|
|
|
|
|
|
|
|
|
private CompMapper getCompMapper() {
|
|
|
|
|
return MapperProxyFactory.getProxy(CompMapper.class);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private ExtendGroupMapper getExtendGroupMapper() {
|
|
|
|
|
return MapperProxyFactory.getProxy(ExtendGroupMapper.class);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private ExtendInfoMapper getExtendInfoMapper() {
|
|
|
|
|
return MapperProxyFactory.getProxy(ExtendInfoMapper.class);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private CompExtDTMapper getCompExtDTMapper() {
|
|
|
|
|
return MapperProxyFactory.getProxy(CompExtDTMapper.class);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private CompExtMapper getCompExtMapper() {
|
|
|
|
|
return MapperProxyFactory.getProxy(CompExtMapper.class);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@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();
|
|
|
|
|
PageInfo<CompPO> pageInfo = new PageInfo<>(parentList);
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
List<CompListDTO> compListDTOS = CompBO.buildCompDTOList(list, filterList);
|
|
|
|
|
PageInfo<CompListDTO> pageInfos = new PageInfo<>(compListDTOS, CompListDTO.class);
|
|
|
|
|
pageInfos.setTotal(pageInfo.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 saveBaseComp(CompSearchParam params) {
|
|
|
|
|
List<CompPO> list = getCompMapper().listByNo(Util.null2String(params.getCompNo()));
|
|
|
|
|
OrganizationAssert.isEmpty(list, "编号不允许重复");
|
|
|
|
|
CompPO compPO = CompBO.convertParamToPO(params, (long) user.getUID());
|
|
|
|
|
return getCompMapper().insertIgnoreNull(compPO);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@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 updateComp(Map<String, Object> params) {
|
|
|
|
|
CompSearchParam searchParam = JSONObject.parseObject(JSONObject.toJSONString(params), CompSearchParam.class);
|
|
|
|
|
String groupId = (String) params.get("viewCondition");
|
|
|
|
|
int updateBaseComp = 0;
|
|
|
|
|
CompPO compPO = CompBO.convertParamToPO(searchParam, (long) user.getUID());
|
|
|
|
|
if (StringUtil.isEmpty(groupId) || "0".equals(groupId)) {
|
|
|
|
|
// 更新主表数据
|
|
|
|
|
updateBaseComp = getCompMapper().updateBaseComp(compPO);
|
|
|
|
|
} else {
|
|
|
|
|
List<ExtendInfoPO> extInfoPOList = getExtendInfoMapper().listFields(EXTEND_TYPE, groupId, JCL_ORG_COMPEXT);
|
|
|
|
|
List<String> extFields = extInfoPOList.stream().map(ExtendInfoPO::getFieldName).collect(Collectors.toList());
|
|
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
|
|
|
for (String dtField : extFields) {
|
|
|
|
|
map.put(dtField, params.get(dtField));
|
|
|
|
|
}
|
|
|
|
|
// 判断更新还是插入
|
|
|
|
|
int count = getCompExtMapper().countCompExtById(JCL_ORG_COMPEXT, searchParam.getId());
|
|
|
|
|
if (count > 0) {
|
|
|
|
|
map.put("update_time", compPO.getUpdateTime());
|
|
|
|
|
updateBaseComp = getCompExtMapper().updateCompExt(JCL_ORG_COMPEXT, compPO.getId(), map);
|
|
|
|
|
} else {
|
|
|
|
|
map.put("creator", compPO.getCreator());
|
|
|
|
|
map.put("delete_type", compPO.getDeleteType());
|
|
|
|
|
map.put("create_time", compPO.getCreateTime());
|
|
|
|
|
map.put("update_time", compPO.getUpdateTime());
|
|
|
|
|
map.put("id", compPO.getId());
|
|
|
|
|
updateBaseComp = getCompExtMapper().insertCompExt(JCL_ORG_COMPEXT, map);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 获取分部明细表的所有拓展列
|
|
|
|
|
List<ExtendInfoPO> dtInfoPOList = getExtendInfoMapper().listFields(EXTEND_TYPE, "", JCL_ORG_COMPEXT_DT1);
|
|
|
|
|
List<String> dtFields = dtInfoPOList.stream().map(ExtendInfoPO::getFieldName).collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
|
List<Map<String, Object>> insertList = new ArrayList<>();
|
|
|
|
|
// 删除明细表数据
|
|
|
|
|
getCompExtDTMapper().deleteByMainID(JCL_ORG_COMPEXT_DT1, compPO.getId());
|
|
|
|
|
// 处理明细表数据
|
|
|
|
|
int rowNum = Util.getIntValue((String) params.get("rownum"));
|
|
|
|
|
for (int i = 0; i < rowNum; i++) {
|
|
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
|
|
|
for (String dtField : dtFields) {
|
|
|
|
|
map.put(dtField, params.get(dtField + "_" + i));
|
|
|
|
|
}
|
|
|
|
|
map.put("mainid", compPO.getId());
|
|
|
|
|
map.put("creator", compPO.getCreator());
|
|
|
|
|
map.put("delete_type", compPO.getDeleteType());
|
|
|
|
|
map.put("create_time", compPO.getCreateTime());
|
|
|
|
|
map.put("update_time", compPO.getUpdateTime());
|
|
|
|
|
insertList.add(map);
|
|
|
|
|
}
|
|
|
|
|
// 更新拓展表数据
|
|
|
|
|
for (Map<String, Object> map : insertList) {
|
|
|
|
|
getCompExtDTMapper().insertCompExtDT(JCL_ORG_COMPEXT_DT1, map);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return updateBaseComp;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@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> getCompBaseForm(Map<String, Object> params) {
|
|
|
|
|
OrganizationAssert.notNull(params.get("viewAttr"), "请标识操作类型");
|
|
|
|
|
|
|
|
|
|
// 2编辑 1查看
|
|
|
|
|
int viewAttr = Integer.parseInt((String) params.get("viewAttr"));
|
|
|
|
|
long id = Long.parseLong((String) params.get("id"));
|
|
|
|
|
String groupId = (String) params.get("viewCondition");
|
|
|
|
|
|
|
|
|
|
HashMap<String, Object> buttonsMap = new HashMap<>();
|
|
|
|
|
buttonsMap.put("hasEdit", true);
|
|
|
|
|
buttonsMap.put("hasSave", true);
|
|
|
|
|
|
|
|
|
|
List<SearchConditionGroup> addGroups = new ArrayList<>();
|
|
|
|
|
if (StringUtil.isEmpty(groupId) || "0".equals(groupId)) {
|
|
|
|
|
addGroups.add(new SearchConditionGroup("基本信息", true, getBaseForm(viewAttr, id)));
|
|
|
|
|
} else {
|
|
|
|
|
addGroups.add(new SearchConditionGroup(getExtendGroupMapper().getGroupNameById(groupId), true, getExtForm(viewAttr, id, groupId)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
HashMap<String, Object> resultMap = new HashMap<>();
|
|
|
|
|
resultMap.put("buttons", buttonsMap);
|
|
|
|
|
resultMap.put("conditions", addGroups);
|
|
|
|
|
resultMap.put("id", id);
|
|
|
|
|
resultMap.put("tabInfo", getTabInfo());
|
|
|
|
|
resultMap.put("tables", getExtendTables(id, viewAttr, false));
|
|
|
|
|
Map<String, Object> apiDatas = new HashMap<>();
|
|
|
|
|
|
|
|
|
|
apiDatas.put("result", resultMap);
|
|
|
|
|
|
|
|
|
|
return apiDatas;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Map<String, Object> getCompSaveForm() {
|
|
|
|
|
Map<String, Object> apiDatas = new HashMap<>();
|
|
|
|
|
List<SearchConditionGroup> addGroups = new ArrayList<>();
|
|
|
|
|
List<SearchConditionItem> conditionItems = new ArrayList<>();
|
|
|
|
|
// 编号
|
|
|
|
|
SearchConditionItem compNoItem = OrganizationFormItemUtil.inputItem(user, 2, 16, 3, 50, "编号", "compNo");
|
|
|
|
|
compNoItem.setRules("required|string");
|
|
|
|
|
// 名称
|
|
|
|
|
SearchConditionItem compNameItem = OrganizationFormItemUtil.inputItem(user, 2, 16, 3, 50, "名称", "compName");
|
|
|
|
|
compNameItem.setRules("required|string");
|
|
|
|
|
// 简称
|
|
|
|
|
SearchConditionItem compNameShortItem = OrganizationFormItemUtil.inputItem(user, 2, 16, 3, 50, "简称", "compNameShort");
|
|
|
|
|
compNameShortItem.setRules("required|string");
|
|
|
|
|
// 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", "");
|
|
|
|
|
// 说明
|
|
|
|
|
SearchConditionItem descriptionItem = OrganizationFormItemUtil.textareaItem(user, 2, 16, true, 2, 60, "说明", "description");
|
|
|
|
|
|
|
|
|
|
conditionItems.add(compNoItem);
|
|
|
|
|
conditionItems.add(compNameItem);
|
|
|
|
|
conditionItems.add(compNameShortItem);
|
|
|
|
|
conditionItems.add(compBrowserItem);
|
|
|
|
|
conditionItems.add(orgCodeItem);
|
|
|
|
|
conditionItems.add(industryItem);
|
|
|
|
|
conditionItems.add(compPrincipalItem);
|
|
|
|
|
conditionItems.add(descriptionItem);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
addGroups.add(new SearchConditionGroup("基本信息", true, conditionItems));
|
|
|
|
|
apiDatas.put("condition", addGroups);
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 处理明细表
|
|
|
|
|
*
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
private List<Map<String, Object>> getExtendTables(long id, int viewAttr, boolean showLabel) {
|
|
|
|
|
List<Map<String, Object>> tables = new ArrayList<>();
|
|
|
|
|
// 查询所有分布模块,拓展明细表信息
|
|
|
|
|
List<ExtendInfoPO> infoPOList = getExtendInfoMapper().listFields(EXTEND_TYPE, "", JCL_ORG_COMPEXT_DT1);
|
|
|
|
|
Map<Long, List<ExtendInfoPO>> groupMap = infoPOList.stream().collect(Collectors.groupingBy(ExtendInfoPO::getExtendGroupId));
|
|
|
|
|
// 遍历Map,组装数据
|
|
|
|
|
for (Map.Entry<Long, List<ExtendInfoPO>> entry : groupMap.entrySet()) {
|
|
|
|
|
Map<String, Object> tableMap = new HashMap<>();
|
|
|
|
|
tableMap.put("hide", false);
|
|
|
|
|
tableMap.put("tabname", getExtendGroupMapper().getGroupNameById(entry.getKey() + ""));
|
|
|
|
|
Map<String, Object> tabinfoMap = new HashMap<>();
|
|
|
|
|
tabinfoMap.put("columns", ExtendInfoBO.convertInfoListToTable(entry.getValue(), viewAttr, showLabel));
|
|
|
|
|
tabinfoMap.put("rownum", "rownum");
|
|
|
|
|
|
|
|
|
|
String fields = entry.getValue().stream().map(ExtendInfoPO::getFieldName).collect(Collectors.joining(","));
|
|
|
|
|
tabinfoMap.put("datas", getCompExtDTMapper().listCompExtDT(JCL_ORG_COMPEXT_DT1, id, fields));
|
|
|
|
|
tableMap.put("tabinfo", tabinfoMap);
|
|
|
|
|
tables.add(tableMap);
|
|
|
|
|
}
|
|
|
|
|
return tables;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 浏览按钮类型赋值转换
|
|
|
|
|
*
|
|
|
|
|
* @param id
|
|
|
|
|
* @param name
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
private List<Map<String, Object>> creatReplaceDatas(Object id, Object name) {
|
|
|
|
|
List<Map<String, Object>> datas = new ArrayList<>();
|
|
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
|
|
|
map.put("id", id);
|
|
|
|
|
map.put("name", name);
|
|
|
|
|
datas.add(map);
|
|
|
|
|
return datas;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 拓展页面分组
|
|
|
|
|
*
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
private List<TopTab> getTabInfo() {
|
|
|
|
|
List<TopTab> topTabs = new ArrayList<>();
|
|
|
|
|
// 基本信息
|
|
|
|
|
topTabs.add(TopTab.builder().color("#000000").groupId("0").showcount(false).title("基本信息").viewCondition("0").build());
|
|
|
|
|
|
|
|
|
|
List<ExtendInfoPO> infoPOList = getExtendInfoMapper().listFields(EXTEND_TYPE, "", JCL_ORG_COMPEXT);
|
|
|
|
|
List<Long> extendGroups = infoPOList.stream().map(ExtendInfoPO::getExtendGroupId).collect(Collectors.toList());
|
|
|
|
|
// 拓展信息
|
|
|
|
|
if (CollectionUtils.isNotEmpty(extendGroups)) {
|
|
|
|
|
for (Long groupId : extendGroups) {
|
|
|
|
|
topTabs.add(TopTab.builder().color("#000000").groupId(groupId + "").showcount(false).title(getExtendGroupMapper().getGroupNameById(groupId + "")).viewCondition(groupId + "").build());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return topTabs;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 基本信息基础表单
|
|
|
|
|
*
|
|
|
|
|
* @param viewAttr
|
|
|
|
|
* @param id
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
private List<SearchConditionItem> getBaseForm(int viewAttr, long id) {
|
|
|
|
|
List<SearchConditionItem> conditionItems = new ArrayList<>();
|
|
|
|
|
// 编号
|
|
|
|
|
SearchConditionItem compNoItem = OrganizationFormItemUtil.inputItem(user, 2, 16, 1, 50, "编号", "compNo");
|
|
|
|
|
// 名称
|
|
|
|
|
SearchConditionItem compNameItem = OrganizationFormItemUtil.inputItem(user, 2, 16, 3, 50, "名称", "compName");
|
|
|
|
|
compNameItem.setRules("required|string");
|
|
|
|
|
// 简称
|
|
|
|
|
SearchConditionItem compNameShortItem = OrganizationFormItemUtil.inputItem(user, 2, 16, 3, 50, "简称", "compNameShort");
|
|
|
|
|
compNameShortItem.setRules("required|string");
|
|
|
|
|
// 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", "");
|
|
|
|
|
// 说明
|
|
|
|
|
SearchConditionItem descriptionItem = OrganizationFormItemUtil.textareaItem(user, 2, 16, true, 2, 60, "说明", "description");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
conditionItems.add(compNoItem);
|
|
|
|
|
conditionItems.add(compNameItem);
|
|
|
|
|
conditionItems.add(compNameShortItem);
|
|
|
|
|
conditionItems.add(compBrowserItem);
|
|
|
|
|
conditionItems.add(orgCodeItem);
|
|
|
|
|
conditionItems.add(industryItem);
|
|
|
|
|
conditionItems.add(compPrincipalItem);
|
|
|
|
|
conditionItems.add(descriptionItem);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 编辑、查看状态赋值,设置只读状态
|
|
|
|
|
|
|
|
|
|
// 赋值
|
|
|
|
|
CompPO compPO = getCompMapper().listById(id);
|
|
|
|
|
OrganizationAssert.notNull(compPO, "数据不存在或数据已删除");
|
|
|
|
|
compNoItem.setValue(compPO.getCompNo());
|
|
|
|
|
compNameItem.setValue(compPO.getCompName());
|
|
|
|
|
compNameShortItem.setValue(compPO.getCompNameShort());
|
|
|
|
|
|
|
|
|
|
// compBrowserItem
|
|
|
|
|
if (null != compPO.getParentCompany()) {
|
|
|
|
|
BrowserBean compBrowserBean = compBrowserItem.getBrowserConditionParam();
|
|
|
|
|
compBrowserBean.setReplaceDatas(creatReplaceDatas(compPO.getParentCompany(), getCompMapper().listById(compPO.getParentCompany()).getCompName()));
|
|
|
|
|
compBrowserItem.setBrowserConditionParam(compBrowserBean);
|
|
|
|
|
}
|
|
|
|
|
orgCodeItem.setValue(compPO.getOrgCode());
|
|
|
|
|
// industryItem
|
|
|
|
|
BrowserBean industryBean = industryItem.getBrowserConditionParam();
|
|
|
|
|
industryBean.setReplaceDatas(creatReplaceDatas(compPO.getIndustry(), new SectorInfoComInfo().getSectorInfoname(compPO.getIndustry() + "")));
|
|
|
|
|
industryItem.setBrowserConditionParam(industryBean);
|
|
|
|
|
try {
|
|
|
|
|
// compPrincipalItem
|
|
|
|
|
BrowserBean PrincipalBean = compPrincipalItem.getBrowserConditionParam();
|
|
|
|
|
PrincipalBean.setReplaceDatas(creatReplaceDatas(compPO.getCompPrincipal(), new ResourceComInfo().getLastname(compPO.getCompPrincipal() + "")));
|
|
|
|
|
compPrincipalItem.setBrowserConditionParam(PrincipalBean);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
throw new RuntimeException(e);
|
|
|
|
|
}
|
|
|
|
|
descriptionItem.setValue(compPO.getDescription());
|
|
|
|
|
|
|
|
|
|
// 查看,全部置位只读
|
|
|
|
|
if (1 == viewAttr) {
|
|
|
|
|
for (SearchConditionItem item : conditionItems) {
|
|
|
|
|
item.setViewAttr(viewAttr);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return conditionItems;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 根据viewCondition获取拓展表单
|
|
|
|
|
*
|
|
|
|
|
* @param viewAttr
|
|
|
|
|
* @param id
|
|
|
|
|
* @param groupId
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
private List<SearchConditionItem> getExtForm(int viewAttr, long id, String groupId) {
|
|
|
|
|
List<SearchConditionItem> conditionItems = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
// 2编辑 1查看
|
|
|
|
|
OrganizationAssert.notNull(groupId, "请选择对应的拓展页");
|
|
|
|
|
List<ExtendInfoPO> infoPOList = getExtendInfoMapper().listFields(EXTEND_TYPE, groupId, JCL_ORG_COMPEXT);
|
|
|
|
|
String fields = infoPOList.stream().map(ExtendInfoPO::getFieldName).collect(Collectors.joining(","));
|
|
|
|
|
Map<String, Object> compExtMap = getCompExtMapper().listCompExt(JCL_ORG_COMPEXT, fields, id);
|
|
|
|
|
|
|
|
|
|
// 组装拓展页内容
|
|
|
|
|
for (ExtendInfoPO extendInfoPO : infoPOList) {
|
|
|
|
|
SearchConditionItem item = null;
|
|
|
|
|
switch (ExtendInfoBO.getFieldhtmltype(extendInfoPO.getControlType() + "")) {
|
|
|
|
|
case INPUT:
|
|
|
|
|
item = OrganizationFormItemUtil.inputItem(user, 2, 16, 1, 50, extendInfoPO.getFieldNameDesc(), extendInfoPO.getFieldName());
|
|
|
|
|
item.setValue(compExtMap.get(extendInfoPO.getFieldName()));
|
|
|
|
|
break;
|
|
|
|
|
case TEXTAREA:
|
|
|
|
|
item = OrganizationFormItemUtil.textareaItem(user, 2, 16, true, 1, 60, extendInfoPO.getFieldNameDesc(), extendInfoPO.getFieldName());
|
|
|
|
|
item.setValue(compExtMap.get(extendInfoPO.getFieldName()));
|
|
|
|
|
break;
|
|
|
|
|
case BROWSER:
|
|
|
|
|
// TODO
|
|
|
|
|
// item=OrganizationFormItemUtil.browserItem()
|
|
|
|
|
break;
|
|
|
|
|
case CHECKBOX:
|
|
|
|
|
item = OrganizationFormItemUtil.checkboxItem(user, 2, 16, 1, true, extendInfoPO.getFieldNameDesc(), extendInfoPO.getFieldName());
|
|
|
|
|
item.setValue(compExtMap.get(extendInfoPO.getFieldName()));
|
|
|
|
|
break;
|
|
|
|
|
case SELECT:
|
|
|
|
|
// TODO
|
|
|
|
|
// item = OrganizationFormItemUtil.selectItem();
|
|
|
|
|
break;
|
|
|
|
|
case FILEUPLOAD:
|
|
|
|
|
case TEXT:
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
if (null != item) {
|
|
|
|
|
// 根据viewAttr设置编辑或只读
|
|
|
|
|
item.setViewAttr(viewAttr);
|
|
|
|
|
// 是否必填
|
|
|
|
|
if (1 == extendInfoPO.getIsrequired()) {
|
|
|
|
|
item.setViewAttr(3);
|
|
|
|
|
item.setRules("required|string");
|
|
|
|
|
}
|
|
|
|
|
conditionItems.add(item);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return conditionItems;
|
|
|
|
|
}
|
|
|
|
|
}
|