|
|
|
|
package com.engine.organization.service.impl;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
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.common.util.ServiceUtil;
|
|
|
|
|
import com.engine.core.impl.Service;
|
|
|
|
|
import com.engine.hrm.entity.RuleCodeType;
|
|
|
|
|
import com.engine.organization.component.OrganizationWeaTable;
|
|
|
|
|
import com.engine.organization.entity.DeleteParam;
|
|
|
|
|
import com.engine.organization.entity.codesetting.po.CodeRulePO;
|
|
|
|
|
import com.engine.organization.entity.company.bo.CompBO;
|
|
|
|
|
import com.engine.organization.entity.company.dto.CompListDTO;
|
|
|
|
|
import com.engine.organization.entity.company.param.CompSearchParam;
|
|
|
|
|
import com.engine.organization.entity.company.po.CompPO;
|
|
|
|
|
import com.engine.organization.entity.department.param.DepartmentMoveParam;
|
|
|
|
|
import com.engine.organization.entity.extend.po.ExtendTitlePO;
|
|
|
|
|
import com.engine.organization.enums.LogModuleNameEnum;
|
|
|
|
|
import com.engine.organization.enums.OperateTypeEnum;
|
|
|
|
|
import com.engine.organization.mapper.codesetting.CodeRuleMapper;
|
|
|
|
|
import com.engine.organization.mapper.comp.CompMapper;
|
|
|
|
|
import com.engine.organization.mapper.extend.ExtendTitleMapper;
|
|
|
|
|
import com.engine.organization.service.CompService;
|
|
|
|
|
import com.engine.organization.service.ExtService;
|
|
|
|
|
import com.engine.organization.thread.OrganizationRunable;
|
|
|
|
|
import com.engine.organization.util.*;
|
|
|
|
|
import com.engine.organization.util.coderule.CodeRuleUtil;
|
|
|
|
|
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.collections.CollectionUtils;
|
|
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
|
|
import weaver.general.StringUtil;
|
|
|
|
|
import weaver.general.Util;
|
|
|
|
|
import weaver.hrm.User;
|
|
|
|
|
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @description:
|
|
|
|
|
* @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_COMP = "JCL_ORG_COMP";
|
|
|
|
|
/**
|
|
|
|
|
* 主表拓展表
|
|
|
|
|
*/
|
|
|
|
|
private static final String JCL_ORG_COMPEXT = "JCL_ORG_COMPEXT";
|
|
|
|
|
/**
|
|
|
|
|
* 明细表拓展表
|
|
|
|
|
*/
|
|
|
|
|
private static final String JCL_ORG_COMPEXT_DT1 = "JCL_ORG_COMPEXT_DT1";
|
|
|
|
|
|
|
|
|
|
private static final String RIGHT_NAME = "Company:All";
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 公司/分部主表title指定ID
|
|
|
|
|
*/
|
|
|
|
|
private static final Long GROUP_ID = 1L;
|
|
|
|
|
|
|
|
|
|
private static CompMapper getCompMapper() {
|
|
|
|
|
return MapperProxyFactory.getProxy(CompMapper.class);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private ExtendTitleMapper getExtendTitleMapper() {
|
|
|
|
|
return MapperProxyFactory.getProxy(ExtendTitleMapper.class);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private ExtService getExtService(User user) {
|
|
|
|
|
return ServiceUtil.getService(ExtServiceImpl.class, user);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Map<String, Object> listPage(CompSearchParam params) {
|
|
|
|
|
Map<String, Object> datas = new HashMap<>();
|
|
|
|
|
boolean hasRight = HasRightUtil.hasRight(user, RIGHT_NAME, true);
|
|
|
|
|
datas.put("hasRight", hasRight);
|
|
|
|
|
if (!hasRight) {
|
|
|
|
|
return datas;
|
|
|
|
|
}
|
|
|
|
|
CompPO compPO = CompBO.convertParamToPO(params, (long) user.getUID());
|
|
|
|
|
boolean filter = isFilter(compPO);
|
|
|
|
|
PageInfo<CompListDTO> pageInfos;
|
|
|
|
|
String orderSql = PageInfoSortUtil.getSortSql(params.getSortParams());
|
|
|
|
|
List<CompPO> allList = getCompMapper().list(orderSql);
|
|
|
|
|
// 通过子级遍历父级元素
|
|
|
|
|
if (filter) {
|
|
|
|
|
// 根据条件获取元素
|
|
|
|
|
List<CompPO> filterCompPOs = getCompMapper().listByFilter(compPO, orderSql);
|
|
|
|
|
// 添加父级元素
|
|
|
|
|
List<CompListDTO> compListDTOS = CompBO.buildCompDTOList(allList, 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(allList);
|
|
|
|
|
List<CompListDTO> subList = PageUtil.subList(params.getCurrent(), params.getPageSize(), compListDTOS);
|
|
|
|
|
pageInfos = new PageInfo<>(subList, CompListDTO.class);
|
|
|
|
|
pageInfos.setTotal(compListDTOS.size());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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 Long saveBaseComp(Map<String, Object> params) {
|
|
|
|
|
HasRightUtil.hasRight(user, RIGHT_NAME, false);
|
|
|
|
|
String compNo = (String) params.get("comp_no");
|
|
|
|
|
// 判断是否开启自动编号
|
|
|
|
|
compNo = repeatDetermine(compNo);
|
|
|
|
|
params.put("comp_no", compNo);
|
|
|
|
|
if (null == params.get("show_order") || StringUtils.isBlank(params.get("show_order").toString())) {
|
|
|
|
|
Integer maxShowOrder = getCompMapper().getMaxShowOrder();
|
|
|
|
|
if (null == maxShowOrder) {
|
|
|
|
|
maxShowOrder = 0;
|
|
|
|
|
}
|
|
|
|
|
params.put("show_order", maxShowOrder + 1);
|
|
|
|
|
}
|
|
|
|
|
Long id = getExtService(user).updateExtForm(user, EXTEND_TYPE, JCL_ORG_COMP, params, "", null);
|
|
|
|
|
params.put("id", id);
|
|
|
|
|
new Thread(new OrganizationRunable(user, LogModuleNameEnum.COMPANY, OperateTypeEnum.ADD, params)).start();
|
|
|
|
|
return id;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public int updateForbiddenTagById(CompSearchParam params) {
|
|
|
|
|
HasRightUtil.hasRight(user, RIGHT_NAME, false);
|
|
|
|
|
CompPO compPO = CompPO.builder().id(params.getId()).forbiddenTag(params.getForbiddenTag() ? 0 : 1).build();
|
|
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
|
|
|
map.put("id", compPO.getId());
|
|
|
|
|
map.put("forbiddenTag", compPO.getForbiddenTag());
|
|
|
|
|
new Thread(new OrganizationRunable(user, LogModuleNameEnum.COMPANY, OperateTypeEnum.CANCELED, map)).start();
|
|
|
|
|
return getCompMapper().updateForbiddenTagById(compPO);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Long updateComp(Map<String, Object> params) {
|
|
|
|
|
HasRightUtil.hasRight(user, RIGHT_NAME, false);
|
|
|
|
|
CompSearchParam searchParam = JSONObject.parseObject(JSONObject.toJSONString(params), CompSearchParam.class);
|
|
|
|
|
String groupId = (String) params.get("viewCondition");
|
|
|
|
|
if ("0".equals(groupId)) {
|
|
|
|
|
groupId = GROUP_ID.toString();
|
|
|
|
|
}
|
|
|
|
|
String oldCompNo = getCompMapper().listById(searchParam.getId()).getCompNo();
|
|
|
|
|
String compNo = searchParam.getCompNo();
|
|
|
|
|
if (!oldCompNo.equals(compNo)) {
|
|
|
|
|
compNo = repeatDetermine(compNo);
|
|
|
|
|
params.put("comp_no", compNo);
|
|
|
|
|
}
|
|
|
|
|
new Thread(new OrganizationRunable(user, LogModuleNameEnum.COMPANY, OperateTypeEnum.UPDATE, params)).start();
|
|
|
|
|
// 更新主表数据
|
|
|
|
|
getExtService(user).updateExtForm(user, EXTEND_TYPE, JCL_ORG_COMP, params, "", searchParam.getId());
|
|
|
|
|
// 更新主表拓展表
|
|
|
|
|
getExtService(user).updateExtForm(user, EXTEND_TYPE, JCL_ORG_COMPEXT, params, groupId, searchParam.getId());
|
|
|
|
|
//更新明细表
|
|
|
|
|
getExtService(user).updateExtDT(user, EXTEND_TYPE, JCL_ORG_COMPEXT_DT1, params, searchParam.getId());
|
|
|
|
|
|
|
|
|
|
return searchParam.getId();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public int deleteByIds(Collection<Long> ids) {
|
|
|
|
|
HasRightUtil.hasRight(user, RIGHT_NAME, false);
|
|
|
|
|
OrganizationAssert.notEmpty(ids, "请选择要删除的数据");
|
|
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
|
|
|
map.put("id", StringUtils.join(ids, ","));
|
|
|
|
|
new Thread(new OrganizationRunable(user, LogModuleNameEnum.COMPANY, OperateTypeEnum.CANCELED, map)).start();
|
|
|
|
|
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");
|
|
|
|
|
// 上级公司
|
|
|
|
|
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() {
|
|
|
|
|
return MenuBtn.getDatasNoBtnColum();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Map<String, Object> getCompBaseForm(Map<String, Object> params) {
|
|
|
|
|
HasRightUtil.hasRight(user, RIGHT_NAME, false);
|
|
|
|
|
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 ("0".equals(groupId)) {
|
|
|
|
|
groupId = GROUP_ID.toString();
|
|
|
|
|
}
|
|
|
|
|
List<ExtendTitlePO> extendTitles = getExtendTitleMapper().getTitlesByGroupID(Long.parseLong(groupId));
|
|
|
|
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(extendTitles)) {
|
|
|
|
|
for (ExtendTitlePO extendTitle : extendTitles) {
|
|
|
|
|
List<SearchConditionItem> items = getExtService(user).getExtForm(user, EXTEND_TYPE + "", GROUP_ID.equals(Long.parseLong(groupId)) ? JCL_ORG_COMP : JCL_ORG_COMPEXT, viewAttr, id, extendTitle.getId() + "", "");
|
|
|
|
|
if (CollectionUtils.isNotEmpty(items)) {
|
|
|
|
|
addGroups.add(new SearchConditionGroup(extendTitle.getTitle(), true, items));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
HashMap<String, Object> resultMap = new HashMap<>();
|
|
|
|
|
resultMap.put("buttons", buttonsMap);
|
|
|
|
|
resultMap.put("conditions", addGroups);
|
|
|
|
|
resultMap.put("id", id);
|
|
|
|
|
// 拓展页面分组
|
|
|
|
|
resultMap.put("tabInfo", getExtService(user).getTabInfo(EXTEND_TYPE, JCL_ORG_COMPEXT));
|
|
|
|
|
// 处理明细表
|
|
|
|
|
resultMap.put("tables", getExtService(user).getExtendTables(user, EXTEND_TYPE, Long.parseLong(groupId), JCL_ORG_COMPEXT_DT1, id, viewAttr, false));
|
|
|
|
|
Map<String, Object> apiDatas = new HashMap<>();
|
|
|
|
|
|
|
|
|
|
apiDatas.put("result", resultMap);
|
|
|
|
|
|
|
|
|
|
return apiDatas;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Map<String, Object> getCompSaveForm() {
|
|
|
|
|
HasRightUtil.hasRight(user, RIGHT_NAME, false);
|
|
|
|
|
Map<String, Object> apiDatas = new HashMap<>();
|
|
|
|
|
List<SearchConditionGroup> addGroups = new ArrayList<>();
|
|
|
|
|
List<ExtendTitlePO> extendTitles = getExtendTitleMapper().getTitlesByGroupID(GROUP_ID);
|
|
|
|
|
if (CollectionUtils.isNotEmpty(extendTitles)) {
|
|
|
|
|
for (ExtendTitlePO extendTitle : extendTitles) {
|
|
|
|
|
List<SearchConditionItem> items = getExtService(user).getExtSaveForm(user, EXTEND_TYPE + "", JCL_ORG_COMP, 2, extendTitle.getId() + "", "comp_no", RuleCodeType.SUBCOMPANY.getValue());
|
|
|
|
|
if (CollectionUtils.isNotEmpty(items)) {
|
|
|
|
|
addGroups.add(new SearchConditionGroup(extendTitle.getTitle(), true, items));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
apiDatas.put("condition", addGroups);
|
|
|
|
|
return apiDatas;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<SearchConditionGroup> getMoveForm() {
|
|
|
|
|
List<SearchConditionGroup> addGroups = new ArrayList<>();
|
|
|
|
|
List<SearchConditionItem> condition = new ArrayList<>();
|
|
|
|
|
SearchConditionItem compBrowserItem = OrganizationFormItemUtil.browserItem(user, 2, 16, 2, false, "转移到", "161", "company", "compBrowser");
|
|
|
|
|
condition.add(compBrowserItem);
|
|
|
|
|
addGroups.add(new SearchConditionGroup("", true, condition));
|
|
|
|
|
return addGroups;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public int moveCompany(DepartmentMoveParam moveParam) {
|
|
|
|
|
Long targetCompanyId = moveParam.getCompany();
|
|
|
|
|
OrganizationAssert.notNull(targetCompanyId, "请选择要转移到的分部");
|
|
|
|
|
Long companyId = moveParam.getId();
|
|
|
|
|
// 判断目标分部是否为它本身以及子元素
|
|
|
|
|
Set<Long> disableIds = new HashSet<>();
|
|
|
|
|
disableIds.add(companyId);
|
|
|
|
|
List<CompPO> compPOS = getCompMapper().listChild(DeleteParam.builder().ids(companyId.toString()).build().getIds());
|
|
|
|
|
if (CollectionUtils.isNotEmpty(compPOS)) {
|
|
|
|
|
addDisableIds(disableIds, compPOS);
|
|
|
|
|
}
|
|
|
|
|
OrganizationAssert.isFalse(disableIds.contains(targetCompanyId), "请勿选择当前分部本身及其子分部");
|
|
|
|
|
CompPO compPO = getCompMapper().listById(companyId);
|
|
|
|
|
compPO.setParentCompany(targetCompanyId);
|
|
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
|
|
|
map.put("id", compPO.getId());
|
|
|
|
|
map.put("parent_company", compPO.getParentCompany());
|
|
|
|
|
map.put("comp_no", compPO.getCompNo());
|
|
|
|
|
map.put("comp_name_short", compPO.getCompNameShort());
|
|
|
|
|
map.put("comp_name", compPO.getCompName());
|
|
|
|
|
map.put("show_order", compPO.getShowOrder());
|
|
|
|
|
new Thread(new OrganizationRunable(user, LogModuleNameEnum.COMPANY, OperateTypeEnum.UPDATE, map)).start();
|
|
|
|
|
return getCompMapper().updateBaseComp(compPO);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 是否为搜索查询
|
|
|
|
|
*
|
|
|
|
|
* @param compPO
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
private boolean isFilter(CompPO compPO) {
|
|
|
|
|
return !(StringUtil.isEmpty(compPO.getCompName())
|
|
|
|
|
&& StringUtil.isEmpty(compPO.getCompNo())
|
|
|
|
|
&& StringUtil.isEmpty(compPO.getCompNameShort())
|
|
|
|
|
&& StringUtil.isEmpty(compPO.getOrgCode())
|
|
|
|
|
&& null == compPO.getParentCompany()
|
|
|
|
|
&& null == compPO.getIndustry()
|
|
|
|
|
&& null == compPO.getCompPrincipal()
|
|
|
|
|
&& null == compPO.getForbiddenTag());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 判断编号是否重复
|
|
|
|
|
*
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public static String repeatDetermine(String compNo) {
|
|
|
|
|
CodeRulePO codeRuleByType = MapperProxyFactory.getProxy(CodeRuleMapper.class).getCodeRuleByType(RuleCodeType.SUBCOMPANY.getValue());
|
|
|
|
|
if (StringUtils.isNotBlank(compNo)) {
|
|
|
|
|
compNo = CodeRuleUtil.generateCode(RuleCodeType.SUBCOMPANY, compNo);
|
|
|
|
|
List<CompPO> list = getCompMapper().listByNo(Util.null2String(compNo));
|
|
|
|
|
OrganizationAssert.isEmpty(list, "编号不允许重复");
|
|
|
|
|
} else {
|
|
|
|
|
if (null != codeRuleByType && "1".equals(codeRuleByType.getSerialEnable())) {
|
|
|
|
|
compNo = autoCreateCompanyNo();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return compNo;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 自动编号处理
|
|
|
|
|
*
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
private static String autoCreateCompanyNo() {
|
|
|
|
|
String generateCode = CodeRuleUtil.generateCode(RuleCodeType.SUBCOMPANY, "");
|
|
|
|
|
List<CompPO> list = getCompMapper().listByNo(Util.null2String(generateCode));
|
|
|
|
|
if (CollectionUtils.isNotEmpty(list)) {
|
|
|
|
|
generateCode = autoCreateCompanyNo();
|
|
|
|
|
}
|
|
|
|
|
return generateCode;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 添加子元素ID
|
|
|
|
|
*
|
|
|
|
|
* @param disableIds
|
|
|
|
|
* @param compPOS
|
|
|
|
|
*/
|
|
|
|
|
private void addDisableIds(Set<Long> disableIds, List<CompPO> compPOS) {
|
|
|
|
|
for (CompPO compPO : compPOS) {
|
|
|
|
|
disableIds.add(compPO.getId());
|
|
|
|
|
List<CompPO> childCompPOS = getCompMapper().listChild(DeleteParam.builder().ids(compPO.getId().toString()).build().getIds());
|
|
|
|
|
addDisableIds(disableIds, childCompPOS);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|