|
|
|
@ -10,6 +10,7 @@ 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.po.CompPO;
|
|
|
|
|
import com.engine.organization.entity.department.bo.DepartmentBO;
|
|
|
|
@ -23,6 +24,7 @@ import com.engine.organization.entity.job.po.JobPO;
|
|
|
|
|
import com.engine.organization.entity.job.vo.SingleJobTreeVO;
|
|
|
|
|
import com.engine.organization.entity.searchtree.SearchTree;
|
|
|
|
|
import com.engine.organization.entity.searchtree.SearchTreeParams;
|
|
|
|
|
import com.engine.organization.mapper.codesetting.CodeRuleMapper;
|
|
|
|
|
import com.engine.organization.mapper.comp.CompMapper;
|
|
|
|
|
import com.engine.organization.mapper.department.DepartmentMapper;
|
|
|
|
|
import com.engine.organization.mapper.extend.ExtendTitleMapper;
|
|
|
|
@ -40,6 +42,7 @@ import com.engine.organization.util.page.PageInfo;
|
|
|
|
|
import com.engine.organization.util.page.PageUtil;
|
|
|
|
|
import com.engine.organization.util.tree.SearchTreeUtil;
|
|
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
|
|
import weaver.general.StringUtil;
|
|
|
|
|
import weaver.general.Util;
|
|
|
|
|
import weaver.hrm.User;
|
|
|
|
@ -188,10 +191,13 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
|
|
|
|
|
public int saveBaseForm(Map<String, Object> params) {
|
|
|
|
|
HasRightUtil.hasRight(user, RIGHT_NAME, false);
|
|
|
|
|
String deptNo = (String) params.get("dept_no");
|
|
|
|
|
deptNo = CodeRuleUtil.generateCode(RuleCodeType.DEPARTMENT, deptNo);
|
|
|
|
|
List<DepartmentPO> list = getDepartmentMapper().listByNo(Util.null2String(deptNo));
|
|
|
|
|
OrganizationAssert.isEmpty(list, "编号不允许重复");
|
|
|
|
|
// 判断是否开启自动编号
|
|
|
|
|
deptNo = repeatDetermine(deptNo);
|
|
|
|
|
params.put("dept_no", deptNo);
|
|
|
|
|
if (StringUtils.isBlank((String) params.get("show_order"))) {
|
|
|
|
|
int maxShowOrder = getCompMapper().getMaxShowOrder();
|
|
|
|
|
params.put("show_order", maxShowOrder + 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return getExtService(user).updateExtForm(user, EXTEND_TYPE, JCL_ORG_DEPT, params, "", null);
|
|
|
|
|
}
|
|
|
|
@ -211,6 +217,13 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
|
|
|
|
|
if ("0".equals(groupId)) {
|
|
|
|
|
groupId = GROUP_ID.toString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String oldDeptNo = getDepartmentMapper().getDeptById(searchParam.getId()).getDeptNo();
|
|
|
|
|
String deptNo = searchParam.getDeptNo();
|
|
|
|
|
if (!oldDeptNo.equals(deptNo)) {
|
|
|
|
|
deptNo = repeatDetermine(deptNo);
|
|
|
|
|
params.put("dept_no", deptNo);
|
|
|
|
|
}
|
|
|
|
|
int updateCount = 0;
|
|
|
|
|
// 更新主表数据
|
|
|
|
|
updateCount += getExtService(user).updateExtForm(user, EXTEND_TYPE, JCL_ORG_DEPT, params, "", searchParam.getId());
|
|
|
|
@ -296,7 +309,10 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
|
|
|
|
|
List<ExtendTitlePO> extendTitles = getExtendTitleMapper().getTitlesByGroupID(Long.parseLong(groupId));
|
|
|
|
|
if (CollectionUtils.isNotEmpty(extendTitles)) {
|
|
|
|
|
for (ExtendTitlePO extendTitle : extendTitles) {
|
|
|
|
|
addGroups.add(new SearchConditionGroup(extendTitle.getTitle(), true, getExtService(user).getExtForm(user, EXTEND_TYPE + "", GROUP_ID.equals(Long.parseLong(groupId)) ? JCL_ORG_DEPT : JCL_ORG_DEPTEXT, viewAttr, id, extendTitle.getId().toString(), "dept_no")));
|
|
|
|
|
List<SearchConditionItem> items = getExtService(user).getExtForm(user, EXTEND_TYPE + "", GROUP_ID.equals(Long.parseLong(groupId)) ? JCL_ORG_DEPT : JCL_ORG_DEPTEXT, viewAttr, id, extendTitle.getId().toString(), "dept_no");
|
|
|
|
|
if (CollectionUtils.isNotEmpty(items)) {
|
|
|
|
|
addGroups.add(new SearchConditionGroup(extendTitle.getTitle(), true, items));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -324,7 +340,10 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
|
|
|
|
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(extendTitles)) {
|
|
|
|
|
for (ExtendTitlePO extendTitle : extendTitles) {
|
|
|
|
|
addGroups.add(new SearchConditionGroup(extendTitle.getTitle(), true, getExtService(user).getExtSaveForm(user, EXTEND_TYPE + "", JCL_ORG_DEPT, 2, extendTitle.getId().toString(), "dept_no", RuleCodeType.DEPARTMENT.getValue())));
|
|
|
|
|
List<SearchConditionItem> items = getExtService(user).getExtSaveForm(user, EXTEND_TYPE + "", JCL_ORG_DEPT, 2, extendTitle.getId().toString(), "dept_no", RuleCodeType.DEPARTMENT.getValue());
|
|
|
|
|
if (CollectionUtils.isNotEmpty(items)) {
|
|
|
|
|
addGroups.add(new SearchConditionGroup(extendTitle.getTitle(), true, items));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
apiDatas.put("condition", addGroups);
|
|
|
|
@ -430,12 +449,12 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
|
|
|
|
|
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");
|
|
|
|
|
SearchConditionItem deptBrowserItem = OrganizationFormItemUtil.browserItem(user, 2, 16, 2, false, "请选择部门", "161", "department", "deptBrowser");
|
|
|
|
|
SearchConditionItem compBrowserItem = OrganizationFormItemUtil.browserItem(user, 2, 16, 2, false, "选择分部", "161", "company", "compBrowser");
|
|
|
|
|
SearchConditionItem deptBrowserItem = OrganizationFormItemUtil.browserItem(user, 2, 16, 2, false, "选择部门", "161", "department", "deptBrowser");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<SearchConditionOption> selectOptions = new ArrayList<>();
|
|
|
|
|
SearchConditionOption compOption = new SearchConditionOption("0", "公司/分部");
|
|
|
|
|
SearchConditionOption compOption = new SearchConditionOption("0", "分部");
|
|
|
|
|
SearchConditionOption deptOption = new SearchConditionOption("1", "部门");
|
|
|
|
|
selectOptions.add(compOption);
|
|
|
|
|
selectOptions.add(deptOption);
|
|
|
|
@ -458,7 +477,7 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
|
|
|
|
|
// 0:公司/分部 1:部门
|
|
|
|
|
if ("0".equals(moveParam.getMoveType())) {
|
|
|
|
|
Long company = moveParam.getCompany();
|
|
|
|
|
OrganizationAssert.notNull(company, "请选择要转移到的公司/分部");
|
|
|
|
|
OrganizationAssert.notNull(company, "请选择要转移到的分部");
|
|
|
|
|
deptById.setParentComp(company);
|
|
|
|
|
deptById.setParentDept(null);
|
|
|
|
|
} else if ("1".equals(moveParam.getMoveType())) {
|
|
|
|
@ -535,4 +554,37 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 判断编号是否重复
|
|
|
|
|
*
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
private String repeatDetermine(String deptNo) {
|
|
|
|
|
CodeRulePO codeRuleByType = MapperProxyFactory.getProxy(CodeRuleMapper.class).getCodeRuleByType(RuleCodeType.SUBCOMPANY.getValue());
|
|
|
|
|
if (StringUtils.isNotBlank(deptNo)) {
|
|
|
|
|
deptNo = CodeRuleUtil.generateCode(RuleCodeType.DEPARTMENT, deptNo);
|
|
|
|
|
List<DepartmentPO> list = getDepartmentMapper().listByNo(Util.null2String(deptNo));
|
|
|
|
|
OrganizationAssert.isEmpty(list, "编号不允许重复");
|
|
|
|
|
} else {
|
|
|
|
|
if (null != codeRuleByType && "1".equals(codeRuleByType.getSerialEnable())) {
|
|
|
|
|
deptNo = autoCreateCompanyNo();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return deptNo;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 自动编号处理
|
|
|
|
|
*
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
private String autoCreateCompanyNo() {
|
|
|
|
|
String generateCode = CodeRuleUtil.generateCode(RuleCodeType.DEPARTMENT, "");
|
|
|
|
|
List<DepartmentPO> list = getDepartmentMapper().listByNo(Util.null2String(generateCode));
|
|
|
|
|
if (CollectionUtils.isNotEmpty(list)) {
|
|
|
|
|
generateCode = autoCreateCompanyNo();
|
|
|
|
|
}
|
|
|
|
|
return generateCode;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|