|
|
|
@ -2,7 +2,6 @@ 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;
|
|
|
|
@ -12,13 +11,13 @@ 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.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.mapper.codesetting.CodeRuleMapper;
|
|
|
|
|
import com.engine.organization.entity.extend.po.ExtendGroupPO;
|
|
|
|
|
import com.engine.organization.mapper.comp.CompMapper;
|
|
|
|
|
import com.engine.organization.mapper.extend.ExtMapper;
|
|
|
|
|
import com.engine.organization.mapper.extend.ExtendGroupMapper;
|
|
|
|
|
import com.engine.organization.service.CompService;
|
|
|
|
|
import com.engine.organization.service.ExtService;
|
|
|
|
@ -31,11 +30,10 @@ 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.crm.Maint.SectorInfoComInfo;
|
|
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
|
|
|
import weaver.general.StringUtil;
|
|
|
|
|
import weaver.general.Util;
|
|
|
|
|
import weaver.hrm.User;
|
|
|
|
|
import weaver.hrm.resource.ResourceComInfo;
|
|
|
|
|
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
@ -54,6 +52,10 @@ public class CompServiceImpl extends Service implements CompService {
|
|
|
|
|
* 3:岗位
|
|
|
|
|
*/
|
|
|
|
|
private static final String EXTEND_TYPE = "1";
|
|
|
|
|
/**
|
|
|
|
|
* 主表表名
|
|
|
|
|
*/
|
|
|
|
|
private static final String JCL_ORG_COMP = "JCL_ORG_COMP";
|
|
|
|
|
/**
|
|
|
|
|
* 主表拓展表
|
|
|
|
|
*/
|
|
|
|
@ -65,6 +67,11 @@ public class CompServiceImpl extends Service implements CompService {
|
|
|
|
|
|
|
|
|
|
private static final String RIGHT_NAME = "Company:All";
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 公司/分部主表title指定ID
|
|
|
|
|
*/
|
|
|
|
|
private static final Long GROUP_ID = -1L;
|
|
|
|
|
|
|
|
|
|
private CompMapper getCompMapper() {
|
|
|
|
|
return MapperProxyFactory.getProxy(CompMapper.class);
|
|
|
|
|
}
|
|
|
|
@ -126,14 +133,19 @@ public class CompServiceImpl extends Service implements CompService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public int saveBaseComp(CompSearchParam params) {
|
|
|
|
|
public int saveBaseComp(Map<String, Object> params) {
|
|
|
|
|
HasRightUtil.hasRight(user, RIGHT_NAME, false);
|
|
|
|
|
// 自动编号
|
|
|
|
|
params.setCompNo(CodeRuleUtil.generateCode(RuleCodeType.SUBCOMPANY, params.getCompNo()));
|
|
|
|
|
List<CompPO> list = getCompMapper().listByNo(Util.null2String(params.getCompNo()));
|
|
|
|
|
String compNo = (String) params.get("comp_no");
|
|
|
|
|
compNo = CodeRuleUtil.generateCode(RuleCodeType.SUBCOMPANY, compNo);
|
|
|
|
|
List<CompPO> list = getCompMapper().listByNo(Util.null2String(compNo));
|
|
|
|
|
OrganizationAssert.isEmpty(list, "编号不允许重复");
|
|
|
|
|
CompPO compPO = CompBO.convertParamToPO(params, (long) user.getUID());
|
|
|
|
|
return getCompMapper().insertIgnoreNull(compPO);
|
|
|
|
|
params.put("comp_no", compNo);
|
|
|
|
|
params.put("forbidden_tag", 0);
|
|
|
|
|
params.put("creator", user.getUID());
|
|
|
|
|
params.put("delete_type", 0);
|
|
|
|
|
params.put("create_time", new Date());
|
|
|
|
|
params.put("update_time", new Date());
|
|
|
|
|
return MapperProxyFactory.getProxy(ExtMapper.class).insertExt(JCL_ORG_COMP, params);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@ -149,9 +161,12 @@ public class CompServiceImpl extends Service implements CompService {
|
|
|
|
|
CompSearchParam searchParam = JSONObject.parseObject(JSONObject.toJSONString(params), CompSearchParam.class);
|
|
|
|
|
String groupId = (String) params.get("viewCondition");
|
|
|
|
|
CompPO compPO = CompBO.convertParamToPO(searchParam, (long) user.getUID());
|
|
|
|
|
if ("0".equals(groupId)) {
|
|
|
|
|
groupId = GROUP_ID.toString();
|
|
|
|
|
}
|
|
|
|
|
int updateCount = 0;
|
|
|
|
|
// 更新主表数据
|
|
|
|
|
updateCount += getCompMapper().updateBaseComp(compPO);
|
|
|
|
|
updateCount += getExtService(user).updateExtForm(user, EXTEND_TYPE, JCL_ORG_COMP, params, groupId, compPO.getId());
|
|
|
|
|
// 更新主表拓展表
|
|
|
|
|
updateCount += getExtService(user).updateExtForm(user, EXTEND_TYPE, JCL_ORG_COMPEXT, params, groupId, compPO.getId());
|
|
|
|
|
//更新明细表
|
|
|
|
@ -228,10 +243,14 @@ public class CompServiceImpl extends Service implements CompService {
|
|
|
|
|
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, getExtService(user).getExtForm(user, EXTEND_TYPE, JCL_ORG_COMPEXT, viewAttr, id, groupId)));
|
|
|
|
|
if ("0".equals(groupId)) {
|
|
|
|
|
groupId = GROUP_ID.toString();
|
|
|
|
|
}
|
|
|
|
|
List<ExtendGroupPO> extendGroupPOS = getExtendGroupMapper().listGroupByPid(Long.parseLong(groupId));
|
|
|
|
|
if (CollectionUtils.isNotEmpty(extendGroupPOS)) {
|
|
|
|
|
for (ExtendGroupPO extendGroupPO : extendGroupPOS) {
|
|
|
|
|
addGroups.add(new SearchConditionGroup(extendGroupPO.getGroupName(), true, getExtService(user).getExtForm(user, EXTEND_TYPE + "", Integer.parseInt(groupId) >= 0 ? JCL_ORG_COMPEXT : JCL_ORG_COMP, viewAttr, id, extendGroupPO.getId().toString())));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
HashMap<String, Object> resultMap = new HashMap<>();
|
|
|
|
@ -255,91 +274,17 @@ public class CompServiceImpl extends Service implements CompService {
|
|
|
|
|
HasRightUtil.hasRight(user, RIGHT_NAME, false);
|
|
|
|
|
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");
|
|
|
|
|
// 判断是否开启自动编号
|
|
|
|
|
CodeRulePO codeRuleByType = MapperProxyFactory.getProxy(CodeRuleMapper.class).getCodeRuleByType(RuleCodeType.SUBCOMPANY.getValue());
|
|
|
|
|
if (null != codeRuleByType && "1".equals(codeRuleByType.getSerialEnable())) {
|
|
|
|
|
compNoItem.setViewAttr(2);
|
|
|
|
|
compNoItem.setHelpfulTip("编号为空,则按照指定规则自动生成编号");
|
|
|
|
|
compNoItem.setRules("");
|
|
|
|
|
List<ExtendGroupPO> extendGroupPOS = getExtendGroupMapper().listGroupByPid(GROUP_ID);
|
|
|
|
|
if (CollectionUtils.isNotEmpty(extendGroupPOS)) {
|
|
|
|
|
for (ExtendGroupPO extendGroupPO : extendGroupPOS) {
|
|
|
|
|
addGroups.add(new SearchConditionGroup(extendGroupPO.getGroupName(), true, getExtService(user).getExtSaveForm(user, EXTEND_TYPE + "", JCL_ORG_COMP, 2, extendGroupPO.getId().toString(), "comp_no", RuleCodeType.SUBCOMPANY.getValue())));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
getSameFormItem(conditionItems, compNoItem, null);
|
|
|
|
|
addGroups.add(new SearchConditionGroup("基本信息", true, conditionItems));
|
|
|
|
|
apiDatas.put("condition", addGroups);
|
|
|
|
|
|
|
|
|
|
return apiDatas;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 新增、编辑表单,相同属性
|
|
|
|
|
*
|
|
|
|
|
* @param conditionItems
|
|
|
|
|
* @param compNoItem
|
|
|
|
|
*/
|
|
|
|
|
private void getSameFormItem(List<SearchConditionItem> conditionItems, SearchConditionItem compNoItem, Long id) {
|
|
|
|
|
// 名称
|
|
|
|
|
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");
|
|
|
|
|
// 上级公司
|
|
|
|
|
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");
|
|
|
|
|
// 行业
|
|
|
|
|
SearchConditionItem industryItem = OrganizationFormItemUtil.browserItem(user, 2, 16, 2, false, "行业", "63", "industry", "");
|
|
|
|
|
// 负责人
|
|
|
|
|
SearchConditionItem compPrincipalItem = OrganizationFormItemUtil.browserItem(user, 2, 16, 3, false, "负责人", "1", "compPrincipal", "");
|
|
|
|
|
compPrincipalItem.setRules("required|string");
|
|
|
|
|
// 说明
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
if (null == id) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
// 赋值
|
|
|
|
|
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());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 是否为搜索查询
|
|
|
|
@ -358,45 +303,4 @@ public class CompServiceImpl extends Service implements CompService {
|
|
|
|
|
&& null == compPO.getForbiddenTag());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 浏览按钮类型赋值转换
|
|
|
|
|
*
|
|
|
|
|
* @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;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 基本信息基础表单
|
|
|
|
|
*
|
|
|
|
|
* @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");
|
|
|
|
|
getSameFormItem(conditionItems, compNoItem, id);
|
|
|
|
|
// 查看,全部置位只读
|
|
|
|
|
if (1 == viewAttr) {
|
|
|
|
|
for (SearchConditionItem item : conditionItems) {
|
|
|
|
|
item.setViewAttr(viewAttr);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return conditionItems;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|