Merge pull request '分部、部门,查看、编辑接口调整' (#83) from feature/dxf into develop

Reviewed-on: #83
pull/86/head
dxfeng 3 years ago
commit bfaa56c606

@ -12,19 +12,17 @@ import com.engine.core.impl.Service;
import com.engine.hrm.service.impl.OrganizationServiceImpl; import com.engine.hrm.service.impl.OrganizationServiceImpl;
import com.engine.organization.component.OrganizationWeaTable; import com.engine.organization.component.OrganizationWeaTable;
import com.engine.organization.entity.DeleteParam; import com.engine.organization.entity.DeleteParam;
import com.engine.organization.entity.TopTab;
import com.engine.organization.entity.company.bo.CompBO; import com.engine.organization.entity.company.bo.CompBO;
import com.engine.organization.entity.company.dto.CompListDTO; import com.engine.organization.entity.company.dto.CompListDTO;
import com.engine.organization.entity.company.param.CompParam; import com.engine.organization.entity.company.param.CompParam;
import com.engine.organization.entity.company.po.CompPO; import com.engine.organization.entity.company.po.CompPO;
import com.engine.organization.entity.department.param.DepartmentMoveParam; 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.LogModuleNameEnum;
import com.engine.organization.enums.OperateTypeEnum; import com.engine.organization.enums.OperateTypeEnum;
import com.engine.organization.exception.OrganizationRunTimeException; import com.engine.organization.exception.OrganizationRunTimeException;
import com.engine.organization.mapper.comp.CompMapper; 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.CompService;
import com.engine.organization.service.ExtService;
import com.engine.organization.thread.OrganizationSyncEc; import com.engine.organization.thread.OrganizationSyncEc;
import com.engine.organization.util.*; import com.engine.organization.util.*;
import com.engine.organization.util.db.MapperProxyFactory; import com.engine.organization.util.db.MapperProxyFactory;
@ -34,13 +32,16 @@ import com.engine.organization.util.page.PageInfo;
import com.engine.organization.util.page.PageUtil; import com.engine.organization.util.page.PageUtil;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import weaver.conn.RecordSet;
import weaver.general.Util; import weaver.general.Util;
import weaver.hrm.User; import weaver.hrm.HrmUserVarify;
import weaver.hrm.company.SubCompanyComInfo; import weaver.hrm.company.SubCompanyComInfo;
import weaver.hrm.definedfield.HrmDeptFieldManagerE9; import weaver.hrm.definedfield.HrmDeptFieldManagerE9;
import weaver.hrm.definedfield.HrmFieldComInfo; import weaver.hrm.definedfield.HrmFieldComInfo;
import weaver.hrm.definedfield.HrmFieldGroupComInfo; import weaver.hrm.definedfield.HrmFieldGroupComInfo;
import weaver.hrm.moduledetach.ManageDetachComInfo;
import weaver.systeminfo.SystemEnv; import weaver.systeminfo.SystemEnv;
import weaver.systeminfo.systemright.CheckSubCompanyRight;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -52,48 +53,13 @@ import java.util.stream.Collectors;
* @version: 1.0 * @version: 1.0
*/ */
public class CompServiceImpl extends Service implements CompService { 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"; private static final String RIGHT_NAME = "Company:All";
private static final String HRM_COMPANY = "hrmsubcompany";
/**
* /titleID
*/
private static final Long GROUP_ID = 1L;
private static CompMapper getCompMapper() { private static CompMapper getCompMapper() {
return MapperProxyFactory.getProxy(CompMapper.class); 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 @Override
public Map<String, Object> listPage(CompParam params) { public Map<String, Object> listPage(CompParam params) {
Map<String, Object> datas = new HashMap<>(); Map<String, Object> datas = new HashMap<>();
@ -105,7 +71,7 @@ public class CompServiceImpl extends Service implements CompService {
CompPO companyPO = CompBO.convertParamToPO(params, user.getUID()); CompPO companyPO = CompBO.convertParamToPO(params, user.getUID());
boolean filter = isFilter(companyPO); boolean filter = isFilter(companyPO);
PageInfo<CompListDTO> pageInfos; PageInfo<CompListDTO> pageInfos;
String orderSql = PageInfoSortUtil.getSortSql(params.getSortParams()," showorder "); String orderSql = PageInfoSortUtil.getSortSql(params.getSortParams(), " showorder ");
List<CompPO> allList = getCompMapper().listAll(orderSql); List<CompPO> allList = getCompMapper().listAll(orderSql);
new DetachUtil(user.getUID()).filterCompanyList(allList); new DetachUtil(user.getUID()).filterCompanyList(allList);
@ -211,43 +177,167 @@ public class CompServiceImpl extends Service implements CompService {
@Override @Override
public Map<String, Object> getCompBaseForm(Map<String, Object> params) { public Map<String, Object> getCompBaseForm(Map<String, Object> params) {
HasRightUtil.hasRight(user, RIGHT_NAME, false); HasRightUtil.hasRight(user, RIGHT_NAME, false);
OrganizationAssert.notNull(params.get("viewAttr"), "请标识操作类型"); Map<String, Object> retMap = new HashMap<>();
// 2编辑 1查看 List<SearchConditionGroup> groupList = new ArrayList<>();
List<SearchConditionItem> itemList;
List<SearchConditionItem> extendItemList = new ArrayList<>();
String id = Util.null2String(params.get("id"));
int viewAttr = Integer.parseInt((String) params.get("viewAttr")); 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<>(); if (2 == viewAttr) {
buttonsMap.put("hasEdit", true); params.put("viewattr", viewAttr);
buttonsMap.put("hasSave", true); groupList = getCompanyConditionGroups(params);
} else {
HrmFieldGroupComInfo HrmFieldGroupComInfo = new HrmFieldGroupComInfo();
HrmFieldComInfo HrmFieldComInfo = new HrmFieldComInfo();
HrmFieldSearchConditionComInfo hrmFieldSearchConditionComInfo = new HrmFieldSearchConditionComInfo();
SearchConditionItem searchConditionItem;
HrmFieldBean hrmFieldBean;
HrmDeptFieldManagerE9 hfm;
try {
hfm = new HrmDeptFieldManagerE9(4);
} catch (Exception e) {
throw new RuntimeException(e);
}
List<SearchConditionGroup> addGroups = new ArrayList<>(); hfm.getCustomData(Util.getIntValue(id));
if ("0".equals(groupId)) { List lsGroup = hfm.getLsGroup();
groupId = GROUP_ID.toString(); for (int tmp = 0; lsGroup != null && tmp < lsGroup.size(); tmp++) {
} String groupId = (String) lsGroup.get(tmp);
List<ExtendTitlePO> extendTitles = getExtendTitleMapper().getTitlesByGroupID(Long.parseLong(groupId), "1"); List lsField = hfm.getLsField(groupId);
if (lsField.size() == 0) {
continue;
}
if (hfm.getGroupCount(lsField) == 0) {
continue;
}
if (!"1".equals(Util.null2String(HrmFieldGroupComInfo.getIsShow(groupId)))) {
continue;
}
String groupLabel = HrmFieldGroupComInfo.getLabel(groupId);
itemList = new ArrayList<>();
for (Object o : lsField) {
String fieldId = (String) o;
String isUse = HrmFieldComInfo.getIsused(fieldId);
if (!"1".equals(isUse)) {
continue;
}
String fieldName = HrmFieldComInfo.getFieldname(fieldId);
String fieldLabel = HrmFieldComInfo.getLabel(fieldId);
String fieldHtmlType = HrmFieldComInfo.getFieldhtmltype(fieldId);
String type = HrmFieldComInfo.getFieldType(fieldId);
String dmlUrl = Util.null2String(HrmFieldComInfo.getFieldDmlurl(fieldId));
String isSystem = HrmFieldComInfo.getIssystem(fieldId);
String fieldValue;
if ("1".equals(isSystem)) {
fieldValue = hfm.getData(fieldName);
} else {
fieldValue = hfm.getData("hrmsubcompanydefined", fieldName);
}
if ("84".equals(fieldId)) {
if (user.getUID() != 1) {
continue;
}
fieldValue = "0".equals(fieldValue) ? "" : fieldValue;
}
if (id.length() > 0 && "subshowid".equals(fieldName)) {
fieldValue = id;
}
hrmFieldBean = new HrmFieldBean();
hrmFieldBean.setFieldid(fieldId);
hrmFieldBean.setFieldname(fieldName);
hrmFieldBean.setFieldlabel(fieldLabel);
hrmFieldBean.setFieldhtmltype(fieldHtmlType);
hrmFieldBean.setType(type);
hrmFieldBean.setIsFormField(true);
hrmFieldBean.setFieldvalue(fieldValue);
hrmFieldBean.setDmlurl(dmlUrl);
hrmFieldBean.setIssystem("1");
searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user);
if (searchConditionItem.getBrowserConditionParam() != null) {
searchConditionItem.getBrowserConditionParam().setViewAttr(viewAttr);
}
if ("showorder".equals(fieldName)) {
searchConditionItem.setPrecision(2);
}
if ("6".equals(fieldHtmlType)) {//附件
Map<String, Object> otherParams1 = new HashMap<>();
otherParams1.put("showOrder", false);
searchConditionItem.setOtherParams(otherParams1);
}
searchConditionItem.setViewAttr(viewAttr);
if ("1".equals(isSystem)) {
itemList.add(searchConditionItem);
} else {
extendItemList.add(searchConditionItem);
}
}
if (CollectionUtils.isNotEmpty(extendTitles)) { int operateLevel;
for (ExtendTitlePO extendTitle : extendTitles) { ManageDetachComInfo manageDetachComInfo = new ManageDetachComInfo();
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() + "", ""); boolean hrmDetachAble = manageDetachComInfo.isUseHrmManageDetach();
if (CollectionUtils.isNotEmpty(items)) { if (hrmDetachAble) {
addGroups.add(new SearchConditionGroup(extendTitle.getTitle(), true, items)); CheckSubCompanyRight checkSubCompanyRight = new CheckSubCompanyRight();
operateLevel = checkSubCompanyRight.ChkComRightByUserRightCompanyId(user.getUID(), "HrmSubCompanyEdit:Edit", Integer.parseInt(id));
} else {
operateLevel = 2;
}
if (tmp == 0 && HrmUserVarify.checkUserRight("HrmSubCompanyEdit:Edit", user) && operateLevel > 0) {
int resourceNum = 0;
String sql;
RecordSet rs = new RecordSet();
sql = "SELECT COUNT(*) FROM hrmresource WHERE subcompanyid1 = " + id + " and ( status =0 or status = 1 or status = 2 or status = 3)";
rs.execute(sql);
if (rs.next()) {
resourceNum = rs.getInt(1);
}
//4:解聘 5:离职 6:退休 7:无效
int resourceNum1 = 0;
sql = "SELECT COUNT(*) FROM hrmresource WHERE subcompanyid1 = " + id + " and status in(4,5,6,7)";
rs.execute(sql);
if (rs.next()) {
resourceNum1 = rs.getInt(1);
}
hrmFieldBean = new HrmFieldBean();
hrmFieldBean.setFieldname("subcomResourceInfo");
hrmFieldBean.setFieldlabel("382428");
hrmFieldBean.setFieldhtmltype("1");
hrmFieldBean.setType("1");
hrmFieldBean.setIsFormField(true);
hrmFieldBean.setFieldvalue(resourceNum + "/" + resourceNum1);
hrmFieldBean.setDmlurl("");
searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user);
searchConditionItem.setViewAttr(viewAttr);
itemList.add(searchConditionItem);
} }
groupList.add(new SearchConditionGroup(SystemEnv.getHtmlLabelNames(groupLabel, user.getLanguage()), true, itemList));
groupList.add(new SearchConditionGroup("拓展信息", true, extendItemList));
} }
} }
HashMap<String, Object> buttonsMap = new HashMap<>();
buttonsMap.put("hasEdit", true);
buttonsMap.put("hasSave", true);
HashMap<String, Object> resultMap = new HashMap<>(); retMap.put("id", id);
resultMap.put("buttons", buttonsMap); retMap.put("conditions", groupList);
resultMap.put("conditions", addGroups); retMap.put("buttons", buttonsMap);
resultMap.put("id", id); List<TopTab> topTabs = new ArrayList<>();
// 拓展页面分组 topTabs.add(TopTab.builder().color("#000000").groupId("4").showcount(false).title("分部信息").viewCondition("4").build());
resultMap.put("tabInfo", getExtService(user).getTabInfo(EXTEND_TYPE, JCL_ORG_COMPEXT)); retMap.put("tabInfo", topTabs);
// 处理明细表
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); Map<String, Object> apiDatas = new HashMap<>();
apiDatas.put("result", retMap);
return apiDatas; return apiDatas;
} }
@ -256,18 +346,79 @@ public class CompServiceImpl extends Service implements CompService {
public Map<String, Object> getCompSaveForm(Map<String, Object> params) { public Map<String, Object> getCompSaveForm(Map<String, Object> params) {
HasRightUtil.hasRight(user, RIGHT_NAME, false); HasRightUtil.hasRight(user, RIGHT_NAME, false);
Map<String, Object> apiDatas = new HashMap<>(); Map<String, Object> apiDatas = new HashMap<>();
List<Map<String, Object>> grouplist = new ArrayList<>(); apiDatas.put("condition", getCompanyConditionGroups(params));
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, "转移到", "164", "company", "compBrowser");
compBrowserItem.setHelpfulTip("在不选择分部情况下,默认转移到集团下一级分部!!!");
condition.add(compBrowserItem);
addGroups.add(new SearchConditionGroup("", true, condition));
return addGroups;
}
@Override
public int moveCompany(DepartmentMoveParam moveParam) {
Integer companyId = moveParam.getId();
Integer targetCompanyId = moveParam.getCompany();
// 判断目标分部是否为它本身以及子元素
Set<Integer> 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), "请勿选择当前分部本身及其子分部");
Map<String, Object> map = new HashMap<>();
map.put("id", companyId.toString());
map.put("supsubcomid", targetCompanyId.toString());
new OrganizationSyncEc(user, LogModuleNameEnum.COMPANY, OperateTypeEnum.UPDATE, map).sync();
return companyId;
}
/**
*
*
* @param companyPO
* @return
*/
private boolean isFilter(CompPO companyPO) {
return StringUtils.isNotBlank(companyPO.getSubCompanyCode()) || StringUtils.isNotBlank(companyPO.getSubCompanyDesc()) || StringUtils.isNotBlank(companyPO.getSubCompanyName()) || null != companyPO.getSupSubComId();
}
/**
* ID
*
* @param disableIds
* @param compPOS
*/
private void addDisableIds(Set<Integer> 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);
}
}
private List<SearchConditionGroup> getCompanyConditionGroups(Map<String, Object> params) {
String id = Util.null2String(params.get("id")); String id = Util.null2String(params.get("id"));
int viewAttr = Util.getIntValue(Util.null2String(params.get("viewattr")), 1); int viewAttr = Util.getIntValue(Util.null2String(params.get("viewattr")), 1);
String addType = Util.null2String(params.get("addType")); String addType = Util.null2String(params.get("addType"));
SubCompanyComInfo subCompanyComInfo = new SubCompanyComInfo(); SubCompanyComInfo subCompanyComInfo = new SubCompanyComInfo();
String supsubcomid = ""; String supSubComId = "";
if ("sibling".equals(addType)) { if ("sibling".equals(addType)) {
supsubcomid = subCompanyComInfo.getSupsubcomid(id); supSubComId = subCompanyComInfo.getSupsubcomid(id);
} else if ("child".equals(addType)) { } else if ("child".equals(addType)) {
supsubcomid = id; supSubComId = id;
} }
if (StringUtils.isNotBlank(addType)) { if (StringUtils.isNotBlank(addType)) {
id = ""; id = "";
@ -287,21 +438,20 @@ public class CompServiceImpl extends Service implements CompService {
hfm.isReturnDecryptData(true); hfm.isReturnDecryptData(true);
hfm.getCustomData(Util.getIntValue(id)); hfm.getCustomData(Util.getIntValue(id));
List lsGroup = hfm.getLsGroup(); List lsGroup = hfm.getLsGroup();
List<SearchConditionGroup> groupList = new ArrayList<>();
for (int tmp = 0; lsGroup != null && tmp < lsGroup.size(); tmp++) { for (int tmp = 0; lsGroup != null && tmp < lsGroup.size(); tmp++) {
String groupId = (String) lsGroup.get(tmp); String groupId = (String) lsGroup.get(tmp);
List lsField = hfm.getLsField(groupId); List lsField = hfm.getLsField(groupId);
boolean groupHide = lsField.size() == 0 || hfm.getGroupCount(lsField) == 0 || !"1".equals(Util.null2String(HrmFieldGroupComInfo.getIsShow(groupId))); boolean groupHide = lsField.size() == 0 || hfm.getGroupCount(lsField) == 0 || !"1".equals(Util.null2String(HrmFieldGroupComInfo.getIsShow(groupId)));
String groupLabel = HrmFieldGroupComInfo.getLabel(groupId); String groupLabel = HrmFieldGroupComInfo.getLabel(groupId);
List<Object> itemList = new ArrayList<>(); List<SearchConditionItem> itemList = new ArrayList<>();
Map<String, Object> groupItem = new HashMap<>(); List<SearchConditionItem> extendItemList = new ArrayList<>();
groupItem.put("title", SystemEnv.getHtmlLabelNames(groupLabel, user.getLanguage())); for (Object o : lsField) {
groupItem.put("hide", groupHide); String fieldId = (String) o;
groupItem.put("defaultshow", true);
for (int j = 0; j < lsField.size(); j++) {
String fieldId = (String) lsField.get(j);
String fieldName = HrmFieldComInfo.getFieldname(fieldId); String fieldName = HrmFieldComInfo.getFieldname(fieldId);
String isUse = HrmFieldComInfo.getIsused(fieldId); String isUse = HrmFieldComInfo.getIsused(fieldId);
String isSystem = HrmFieldComInfo.getIssystem(fieldId);
if (!"1".equals(isUse)) { if (!"1".equals(isUse)) {
continue; continue;
} }
@ -312,9 +462,8 @@ public class CompServiceImpl extends Service implements CompService {
String type = HrmFieldComInfo.getFieldType(fieldId); String type = HrmFieldComInfo.getFieldType(fieldId);
String dmlUrl = Util.null2String(HrmFieldComInfo.getFieldDmlurl(fieldId)); String dmlUrl = Util.null2String(HrmFieldComInfo.getFieldDmlurl(fieldId));
String fieldValue = ""; String fieldValue = "";
if (StringUtils.isNotBlank(addType)) { if (StringUtils.isBlank(addType)) {
} else { if ("1".equals(isSystem)) {
if ("1".equals(HrmFieldComInfo.getIssystem(fieldId))) {
fieldValue = hfm.getData(fieldName); fieldValue = hfm.getData(fieldName);
} else { } else {
fieldValue = hfm.getData("hrmsubcompanydefined", fieldName); fieldValue = hfm.getData("hrmsubcompanydefined", fieldName);
@ -336,8 +485,8 @@ public class CompServiceImpl extends Service implements CompService {
} }
fieldValue = "0".equals(fieldValue) ? "" : fieldValue; fieldValue = "0".equals(fieldValue) ? "" : fieldValue;
} }
if (supsubcomid.length() > 0 && "supsubcomid".equals(fieldName)) { if (supSubComId.length() > 0 && "supsubcomid".equals(fieldName)) {
fieldValue = supsubcomid; fieldValue = supSubComId;
} }
if ("subshowid".equals(fieldName)) { if ("subshowid".equals(fieldName)) {
@ -385,106 +534,16 @@ public class CompServiceImpl extends Service implements CompService {
otherParams1.put("showOrder", false); otherParams1.put("showOrder", false);
searchConditionItem.setOtherParams(otherParams1); searchConditionItem.setOtherParams(otherParams1);
} }
if ("1".equals(isSystem)) {
itemList.add(searchConditionItem); itemList.add(searchConditionItem);
} else {
extendItemList.add(searchConditionItem);
}
} }
} }
groupItem.put("items", itemList); groupList.add(new SearchConditionGroup(SystemEnv.getHtmlLabelNames(groupLabel, user.getLanguage()), true, itemList));
grouplist.add(groupItem); groupList.add(new SearchConditionGroup("拓展信息", true, extendItemList));
} }
apiDatas.put("condition", grouplist); return groupList;
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, "转移到", "164", "company", "compBrowser");
compBrowserItem.setHelpfulTip("在不选择分部情况下,默认转移到集团下一级分部!!!");
condition.add(compBrowserItem);
addGroups.add(new SearchConditionGroup("", true, condition));
return addGroups;
}
@Override
public int moveCompany(DepartmentMoveParam moveParam) {
Integer companyId = moveParam.getId();
Integer targetCompanyId = moveParam.getCompany();
// 判断目标分部是否为它本身以及子元素
Set<Integer> 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), "请勿选择当前分部本身及其子分部");
Map<String, Object> map = new HashMap<>();
map.put("id", companyId.toString());
map.put("supsubcomid", targetCompanyId.toString());
new OrganizationSyncEc(user, LogModuleNameEnum.COMPANY, OperateTypeEnum.UPDATE, map).sync();
return companyId;
}
/**
*
*
* @param companyPO
* @return
*/
private boolean isFilter(CompPO companyPO) {
return StringUtils.isNotBlank(companyPO.getSubCompanyCode()) || StringUtils.isNotBlank(companyPO.getSubCompanyDesc()) || StringUtils.isNotBlank(companyPO.getSubCompanyName()) || null != companyPO.getSupSubComId();
}
/**
*
*
* @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 {
// OrganizationAssert.isTrue(null != codeRuleByType && "1".equals(codeRuleByType.getSerialEnable()), "编号不允许为空");
// compNo = autoCreateCompanyNo();
//}
//return compNo;
return "";
}
///**
// * 自动编号处理
// *
// * @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<Integer> 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);
}
}
} }

@ -12,6 +12,7 @@ import com.engine.core.impl.Service;
import com.engine.hrm.entity.RuleCodeType; import com.engine.hrm.entity.RuleCodeType;
import com.engine.hrm.service.impl.OrganizationServiceImpl; import com.engine.hrm.service.impl.OrganizationServiceImpl;
import com.engine.organization.component.OrganizationWeaTable; import com.engine.organization.component.OrganizationWeaTable;
import com.engine.organization.entity.TopTab;
import com.engine.organization.entity.codesetting.po.CodeRulePO; import com.engine.organization.entity.codesetting.po.CodeRulePO;
import com.engine.organization.entity.company.bo.CompBO; import com.engine.organization.entity.company.bo.CompBO;
import com.engine.organization.entity.company.po.CompPO; import com.engine.organization.entity.company.po.CompPO;
@ -20,7 +21,6 @@ import com.engine.organization.entity.department.dto.DepartmentListDTO;
import com.engine.organization.entity.department.param.*; import com.engine.organization.entity.department.param.*;
import com.engine.organization.entity.department.po.DepartmentPO; import com.engine.organization.entity.department.po.DepartmentPO;
import com.engine.organization.entity.department.vo.SingleDeptTreeVO; import com.engine.organization.entity.department.vo.SingleDeptTreeVO;
import com.engine.organization.entity.extend.po.ExtendTitlePO;
import com.engine.organization.entity.job.bo.JobBO; import com.engine.organization.entity.job.bo.JobBO;
import com.engine.organization.entity.job.po.JobPO; import com.engine.organization.entity.job.po.JobPO;
import com.engine.organization.entity.job.vo.SingleJobTreeVO; import com.engine.organization.entity.job.vo.SingleJobTreeVO;
@ -32,10 +32,8 @@ import com.engine.organization.exception.OrganizationRunTimeException;
import com.engine.organization.mapper.codesetting.CodeRuleMapper; import com.engine.organization.mapper.codesetting.CodeRuleMapper;
import com.engine.organization.mapper.comp.CompMapper; import com.engine.organization.mapper.comp.CompMapper;
import com.engine.organization.mapper.department.DepartmentMapper; import com.engine.organization.mapper.department.DepartmentMapper;
import com.engine.organization.mapper.extend.ExtendTitleMapper;
import com.engine.organization.mapper.job.JobMapper; import com.engine.organization.mapper.job.JobMapper;
import com.engine.organization.service.DepartmentService; import com.engine.organization.service.DepartmentService;
import com.engine.organization.service.ExtService;
import com.engine.organization.thread.JobTriggerRunnable; import com.engine.organization.thread.JobTriggerRunnable;
import com.engine.organization.thread.OrganizationSyncEc; import com.engine.organization.thread.OrganizationSyncEc;
import com.engine.organization.util.*; import com.engine.organization.util.*;
@ -52,12 +50,14 @@ import org.apache.commons.lang.StringUtils;
import weaver.conn.RecordSet; import weaver.conn.RecordSet;
import weaver.general.StringUtil; import weaver.general.StringUtil;
import weaver.general.Util; import weaver.general.Util;
import weaver.hrm.User; import weaver.hrm.HrmUserVarify;
import weaver.hrm.company.DepartmentComInfo; import weaver.hrm.company.DepartmentComInfo;
import weaver.hrm.definedfield.HrmDeptFieldManagerE9; import weaver.hrm.definedfield.HrmDeptFieldManagerE9;
import weaver.hrm.definedfield.HrmFieldComInfo; import weaver.hrm.definedfield.HrmFieldComInfo;
import weaver.hrm.definedfield.HrmFieldGroupComInfo; import weaver.hrm.definedfield.HrmFieldGroupComInfo;
import weaver.hrm.moduledetach.ManageDetachComInfo;
import weaver.systeminfo.SystemEnv; import weaver.systeminfo.SystemEnv;
import weaver.systeminfo.systemright.CheckSubCompanyRight;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -70,34 +70,8 @@ import java.util.stream.Collectors;
**/ **/
public class DepartmentServiceImpl extends Service implements DepartmentService { public class DepartmentServiceImpl extends Service implements DepartmentService {
/**
*
* 1
* 2
* 3
*/
private static final String EXTEND_TYPE = "2";
/**
*
*/
private static final String JCL_ORG_DEPT = "JCL_ORG_DEPT";
/**
*
*/
private static final String JCL_ORG_DEPTEXT = "JCL_ORG_DEPTEXT";
/**
*
*/
private static final String JCL_ORG_DEPTEXT_DT1 = "JCL_ORG_DEPTEXT_DT1";
private static final String RIGHT_NAME = "Department:All"; private static final String RIGHT_NAME = "Department:All";
/**
* titleID
*/
private static final Long GROUP_ID = 2L;
private static DepartmentMapper getDepartmentMapper() { private static DepartmentMapper getDepartmentMapper() {
return MapperProxyFactory.getProxy(DepartmentMapper.class); return MapperProxyFactory.getProxy(DepartmentMapper.class);
} }
@ -110,19 +84,10 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
return MapperProxyFactory.getProxy(CompMapper.class); 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 @Override
public PageInfo<SingleDeptTreeVO> getDeptListByPid(QuerySingleDeptListParam param) { public PageInfo<SingleDeptTreeVO> getDeptListByPid(QuerySingleDeptListParam param) {
//1.查询分部下所有部门 //1.查询分部下所有部门
//PageUtil.start(param.getCurrent(), param.getPageSize());
List<DepartmentPO> departmentPOS = MapperProxyFactory.getProxy(DepartmentMapper.class).listAll("showOrder"); List<DepartmentPO> departmentPOS = MapperProxyFactory.getProxy(DepartmentMapper.class).listAll("showOrder");
PageInfo<DepartmentPO> pageInfo = new PageInfo<>(departmentPOS); PageInfo<DepartmentPO> pageInfo = new PageInfo<>(departmentPOS);
List<SingleDeptTreeVO> singleDeptTreeVOS = DepartmentBO.buildSingleDeptTreeVOS(departmentPOS, param.getParentComp()); List<SingleDeptTreeVO> singleDeptTreeVOS = DepartmentBO.buildSingleDeptTreeVOS(departmentPOS, param.getParentComp());
@ -167,7 +132,7 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
DepartmentPO departmentPO = DepartmentBO.convertParamsToPO(param, user.getUID()); DepartmentPO departmentPO = DepartmentBO.convertParamsToPO(param, user.getUID());
boolean filter = isFilter(departmentPO); boolean filter = isFilter(departmentPO);
PageInfo<DepartmentListDTO> pageInfos; PageInfo<DepartmentListDTO> pageInfos;
String orderSql = PageInfoSortUtil.getSortSql(param.getSortParams()," showorder "); String orderSql = PageInfoSortUtil.getSortSql(param.getSortParams(), " showorder ");
List<DepartmentPO> allList = getDepartmentMapper().listAll(orderSql); List<DepartmentPO> allList = getDepartmentMapper().listAll(orderSql);
new DetachUtil(user.getUID()).filterDepartmentList(allList); new DetachUtil(user.getUID()).filterDepartmentList(allList);
// 通过子级遍历父级元素 // 通过子级遍历父级元素
@ -272,194 +237,162 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
@Override @Override
public Map<String, Object> getDeptBaseForm(Map<String, Object> params) { public Map<String, Object> getDeptBaseForm(Map<String, Object> params) {
OrganizationAssert.notNull(params.get("viewAttr"), "请标识操作类型"); OrganizationAssert.notNull(params.get("viewAttr"), "请标识操作类型");
// 2编辑 1查看 // 2编辑 1查看
int viewAttr = Integer.parseInt((String) params.get("viewAttr")); 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), "1");
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_DEPT : JCL_ORG_DEPTEXT, viewAttr, id, extendTitle.getId().toString(), "");
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_DEPTEXT));
// 处理明细表
resultMap.put("tables", getExtService(user).getExtendTables(user, EXTEND_TYPE, Long.parseLong(groupId), JCL_ORG_DEPTEXT_DT1, id, viewAttr, false));
Map<String, Object> apiDatas = new HashMap<>();
apiDatas.put("result", resultMap);
return apiDatas;
}
@Override
public Map<String, Object> getSaveForm(Map<String, Object> params) {
HasRightUtil.hasRight(user, RIGHT_NAME, false);
Map<String, Object> apiDatas = new HashMap<>();
List<Map<String, Object>> groupList = new ArrayList<>();
Map<String, Object> groupItem;
List<Object> itemList;
List<SearchConditionGroup> groupList = new ArrayList<>();
List<SearchConditionItem> itemList;
List<SearchConditionItem> extendItemList;
String id = Util.null2String(params.get("id")); String id = Util.null2String(params.get("id"));
int viewAttr = Util.getIntValue(Util.null2String(params.get("viewattr")), 1); if (2 == viewAttr) {
String nodeType = Util.null2String(params.get("type")); params.put("viewattr", viewAttr);
String addType = Util.null2String(params.get("addType")); groupList = getDepartmentConditionGroups(params);
DepartmentComInfo departmentComInfo = new DepartmentComInfo(); } else {
String subcompanyid1 = "";
String supDepId = "";
switch (addType) {
case "normal":
if (nodeType.equals("subcompany")) {
subcompanyid1 = id;
} else {
subcompanyid1 = departmentComInfo.getSubcompanyid1(id);
}
break;
case "sibling":
subcompanyid1 = departmentComInfo.getSubcompanyid1(id);
supDepId = departmentComInfo.getDepartmentsupdepid(id);
break;
case "child":
subcompanyid1 = departmentComInfo.getSubcompanyid1(id);
supDepId = id;
break;
}
HrmFieldGroupComInfo HrmFieldGroupComInfo = new HrmFieldGroupComInfo();
HrmFieldComInfo HrmFieldComInfo = new HrmFieldComInfo();
HrmFieldSearchConditionComInfo hrmFieldSearchConditionComInfo = new HrmFieldSearchConditionComInfo();
SearchConditionItem searchConditionItem;
HrmFieldBean hrmFieldBean;
HrmDeptFieldManagerE9 hfm;
try {
hfm = new HrmDeptFieldManagerE9(5);
} catch (Exception e) {
throw new OrganizationRunTimeException("");
}
hfm.isReturnDecryptData(true);
hfm.getCustomData(Util.getIntValue(id));
List lsGroup = hfm.getLsGroup();
for (int tmp = 0; lsGroup != null && tmp < lsGroup.size(); tmp++) {
String groupid = (String) lsGroup.get(tmp);
List lsField = hfm.getLsField(groupid);
boolean groupHide = lsField.size() == 0 || hfm.getGroupCount(lsField) == 0 || !Util.null2String(HrmFieldGroupComInfo.getIsShow(groupid)).equals("1"); HrmFieldGroupComInfo HrmFieldGroupComInfo = new HrmFieldGroupComInfo();
String grouplabel = HrmFieldGroupComInfo.getLabel(groupid); HrmFieldComInfo HrmFieldComInfo = new HrmFieldComInfo();
itemList = new ArrayList<>(); HrmFieldSearchConditionComInfo hrmFieldSearchConditionComInfo = new HrmFieldSearchConditionComInfo();
groupItem = new HashMap<>(); SearchConditionItem searchConditionItem;
groupItem.put("title", SystemEnv.getHtmlLabelNames(grouplabel, user.getLanguage())); HrmFieldBean hrmFieldBean;
groupItem.put("hide", groupHide); HrmDeptFieldManagerE9 hfm;
groupItem.put("defaultshow", true); try {
for (Object o : lsField) { hfm = new HrmDeptFieldManagerE9(5);
String fieldId = (String) o; } catch (Exception e) {
String fieldName = HrmFieldComInfo.getFieldname(fieldId); throw new RuntimeException(e);
String isUse = HrmFieldComInfo.getIsused(fieldId); }
if (!isUse.equals("1")) continue; hfm.getCustomData(Util.getIntValue(id));
int tmpViewAttr = viewAttr; List lsGroup = hfm.getLsGroup();
String rules = ""; for (int tmp = 0; lsGroup != null && tmp < lsGroup.size(); tmp++) {
String fieldLabel = HrmFieldComInfo.getLabel(fieldId); String groupId = (String) lsGroup.get(tmp);
String fieldHtmlType = HrmFieldComInfo.getFieldhtmltype(fieldId); List lsField = hfm.getLsField(groupId);
String type = HrmFieldComInfo.getFieldType(fieldId); if (lsField.size() == 0)
String dmlUrl = Util.null2String(HrmFieldComInfo.getFieldDmlurl(fieldId)); continue;
String fieldValue = ""; if (hfm.getGroupCount(lsField) == 0)
if (StringUtils.isBlank(addType)) { continue;
if (HrmFieldComInfo.getIssystem(fieldId).equals("1")) { if (!"1".equals(Util.null2String(HrmFieldGroupComInfo.getIsShow(groupId)))) continue;
String groupLabel = HrmFieldGroupComInfo.getLabel(groupId);
itemList = new ArrayList<>();
extendItemList = new ArrayList<>();
for (Object o : lsField) {
String fieldId = (String) o;
String isUse = HrmFieldComInfo.getIsused(fieldId);
if (!"1".equals(isUse)) continue;
String fieldName = HrmFieldComInfo.getFieldname(fieldId);
String fieldLabel = HrmFieldComInfo.getLabel(fieldId);
String fieldHtmlType = HrmFieldComInfo.getFieldhtmltype(fieldId);
String type = HrmFieldComInfo.getFieldType(fieldId);
String dmlUrl = Util.null2String(HrmFieldComInfo.getFieldDmlurl(fieldId));
String isSystem = HrmFieldComInfo.getIssystem(fieldId);
String fieldValue;
if ("1".equals(isSystem)) {
fieldValue = hfm.getData(fieldName); fieldValue = hfm.getData(fieldName);
} else { } else {
fieldValue = hfm.getData("hrmdepartmentdefined", fieldName); fieldValue = hfm.getData("hrmdepartmentdefined", fieldName);
} }
}
if (!groupHide && tmpViewAttr == 2 && HrmFieldComInfo.getIsmand(fieldId).equals("1")) { if (id.length() > 0 && "showid".equals(fieldName)) {
tmpViewAttr = 3; fieldValue = id;
if ("1".equals(fieldHtmlType) && "2".equals(type)) {
rules = "required|integer";
} else {
rules = "required|string";
} }
}
if (subcompanyid1.length() > 0 && fieldName.equals("subcompanyid1")) { hrmFieldBean = new HrmFieldBean();
fieldValue = subcompanyid1; hrmFieldBean.setFieldid(fieldId);
} hrmFieldBean.setFieldname(fieldName);
hrmFieldBean.setFieldlabel(fieldLabel);
hrmFieldBean.setFieldhtmltype(fieldHtmlType);
hrmFieldBean.setType(type);
hrmFieldBean.setIsFormField(true);
hrmFieldBean.setFieldvalue(fieldValue);
hrmFieldBean.setDmlurl(dmlUrl);
hrmFieldBean.setIssystem("1");
searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user);
if (searchConditionItem.getBrowserConditionParam() != null) {
searchConditionItem.getBrowserConditionParam().setViewAttr(viewAttr);
}
if ("showorder".equals(fieldName)) {
searchConditionItem.setPrecision(2);
}
if (supDepId.length() > 0 && fieldName.equals("supdepid")) { if ("6".equals(fieldHtmlType)) {//附件
fieldValue = supDepId; Map<String, Object> otherParams1 = new HashMap<>();
} otherParams1.put("showOrder", false);
searchConditionItem.setOtherParams(otherParams1);
}
if (fieldName.equals("showid")) { searchConditionItem.setViewAttr(viewAttr);
if (addType.length() > 0) { if ("1".equals(isSystem)) {
continue; itemList.add(searchConditionItem);
} else { } else {
fieldValue = id; extendItemList.add(searchConditionItem);
tmpViewAttr = 1;
} }
} }
hrmFieldBean = new HrmFieldBean(); int operateLevel;
hrmFieldBean.setFieldid(fieldId); ManageDetachComInfo manageDetachComInfo = new ManageDetachComInfo();
hrmFieldBean.setFieldname(fieldName); boolean hrmDetachAble = manageDetachComInfo.isUseHrmManageDetach();
hrmFieldBean.setFieldlabel(fieldLabel); if (hrmDetachAble) {
hrmFieldBean.setFieldhtmltype(fieldHtmlType); CheckSubCompanyRight checkSubCompanyRight = new CheckSubCompanyRight();
hrmFieldBean.setType(type); DepartmentComInfo departmentComInfo = new DepartmentComInfo();
hrmFieldBean.setIsFormField(true); operateLevel = checkSubCompanyRight.ChkComRightByUserRightCompanyId(user.getUID(), "HrmDepartmentEdit:Edit", Integer.parseInt(departmentComInfo.getSubcompanyid1(id)));
hrmFieldBean.setIssystem("1"); } else {
hrmFieldBean.setFieldvalue(fieldValue); operateLevel = 2;
hrmFieldBean.setDmlurl(dmlUrl);
hrmFieldBean.setViewAttr(tmpViewAttr);
hrmFieldBean.setRules(rules);
if (hrmFieldBean.getFieldname().equals("subcompanyid1") || hrmFieldBean.getFieldname().equals("supdepid")) {
hrmFieldBean.setHideVirtualOrg(true);
}
if (hrmFieldBean.getFieldname().equals("departmentcode")) {
hrmFieldBean.setMultilang(false);
} }
searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user);
if (searchConditionItem != null) { if (tmp == 0 && HrmUserVarify.checkUserRight("HrmDepartmentEdit:Edit", user) && operateLevel > 0) {
searchConditionItem.setLabelcol(8); int resourceNum = 0;
searchConditionItem.setFieldcol(16); RecordSet rs = new RecordSet();
if (fieldName.equals("showorder")) {
searchConditionItem.setPrecision(2); String sql = "SELECT COUNT(*) FROM hrmresource WHERE departmentid = " + id + " and ( status =0 or status = 1 or status = 2 or status = 3)";
} rs.execute(sql);
if (fieldName.equals("showid")) { if (rs.next()) {
Map<String, Object> otherParams = new HashMap<>(); resourceNum = rs.getInt(1);
otherParams.put("hasBorder", true);
searchConditionItem.setOtherParams(otherParams);
} }
if ("6".equals(fieldHtmlType)) {//附件
Map<String, Object> otherParams1 = new HashMap<>(); //4:解聘 5:离职 6:退休 7:无效
otherParams1.put("showOrder", false); int resourceNum1 = 0;
searchConditionItem.setOtherParams(otherParams1); sql = "SELECT COUNT(*) FROM hrmresource WHERE departmentid = " + id + " and status in(4,5,6,7)";
rs.execute(sql);
if (rs.next()) {
resourceNum1 = rs.getInt(1);
} }
hrmFieldBean = new HrmFieldBean();
hrmFieldBean.setFieldname("deptResourceInfo");
hrmFieldBean.setFieldlabel("382428");
hrmFieldBean.setFieldhtmltype("1");
hrmFieldBean.setType("1");
hrmFieldBean.setIsFormField(true);
hrmFieldBean.setFieldvalue(resourceNum + "/" + resourceNum1);
hrmFieldBean.setDmlurl("");
searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user);
searchConditionItem.setViewAttr(viewAttr);
itemList.add(searchConditionItem); itemList.add(searchConditionItem);
} }
groupList.add(new SearchConditionGroup(SystemEnv.getHtmlLabelNames(groupLabel, user.getLanguage()), true, itemList));
groupList.add(new SearchConditionGroup("拓展信息", true, extendItemList));
} }
groupItem.put("items", itemList);
groupList.add(groupItem);
} }
apiDatas.put("condition", groupList);
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", groupList);
resultMap.put("id", id);
List<TopTab> topTabs = new ArrayList<>();
topTabs.add(TopTab.builder().color("#000000").groupId("4").showcount(false).title("部门信息").viewCondition("4").build());
resultMap.put("tabInfo", topTabs);
Map<String, Object> apiDatas = new HashMap<>();
apiDatas.put("result", resultMap);
return apiDatas;
}
@Override
public Map<String, Object> getSaveForm(Map<String, Object> params) {
HasRightUtil.hasRight(user, RIGHT_NAME, false);
Map<String, Object> apiDatas = new HashMap<>();
apiDatas.put("condition", getDepartmentConditionGroups(params));
return apiDatas; return apiDatas;
} }
@ -626,7 +559,7 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
// 更新子部门下岗位的所属分部 // 更新子部门下岗位的所属分部
for (DepartmentPO departmentPO : firstChildDeptList) { for (DepartmentPO departmentPO : firstChildDeptList) {
List<DepartmentPO> deptList = getDepartmentMapper().getDeptListByPId(departmentPO.getId()); List<DepartmentPO> deptList = getDepartmentMapper().getDeptListByPId(departmentPO.getId());
forbiddenChildTag(targetDepartment.getSubCompanyId1(), Util.null2String(targetDepartment.getSubCompanyId1()), deptList); forbiddenChildTag(targetDepartment.getSubCompanyId1(), deptList);
} }
// 原部门删除 // 原部门删除
// DepartmentPO mergeDepartment = getDepartmentMapper().getDeptById(mergeParam.getId()); // DepartmentPO mergeDepartment = getDepartmentMapper().getDeptById(mergeParam.getId());
@ -713,7 +646,7 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
//for (Long hrmResourceId : hrmResourceIds) { //for (Long hrmResourceId : hrmResourceIds) {
//TODO new HrmResourceTriggerRunnable(hrmResourceId).run(); //TODO new HrmResourceTriggerRunnable(hrmResourceId).run();
//} //}
forbiddenChildTag(deptById.getSubCompanyId1(), Util.null2String(deptById.getSubCompanyId1()), deptList); forbiddenChildTag(deptById.getSubCompanyId1(), deptList);
// 递归更新下级部门、岗位 // 递归更新下级部门、岗位
return 1; return 1;
} }
@ -721,20 +654,20 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
/** /**
* id * id
* *
* @param parentComp * @param subCompanyId1
* @param deptList * @param deptList
*/ */
void forbiddenChildTag(Integer parentComp, String ecCompanyId, List<DepartmentPO> deptList) { void forbiddenChildTag(Integer subCompanyId1, List<DepartmentPO> deptList) {
if (CollectionUtils.isNotEmpty(deptList)) { if (CollectionUtils.isNotEmpty(deptList)) {
for (DepartmentPO departmentPO : deptList) { for (DepartmentPO departmentPO : deptList) {
departmentPO.setSubCompanyId1(parentComp); departmentPO.setSubCompanyId1(subCompanyId1);
// 更新EC表部门 // 更新EC表部门
updateEcDepartment(departmentPO); updateEcDepartment(departmentPO);
// 更新组织架构图 // 更新组织架构图
// TODO new DepartmentTriggerRunnable(departmentPO.getId()).run(); // TODO new DepartmentTriggerRunnable(departmentPO.getId()).run();
// 刷新岗位所属分部 // 刷新岗位所属分部
refreshJobComp(departmentPO.getId(), parentComp); refreshJobComp(departmentPO.getId(), subCompanyId1);
// 更新当前部门下的人员 // 更新当前部门下的人员
// String ecDepartmentId = EcHrmRelationUtil.getEcDepartmentId(departmentPO.getId().toString()); // String ecDepartmentId = EcHrmRelationUtil.getEcDepartmentId(departmentPO.getId().toString());
//new RecordSet().executeUpdate("update hrmresource set SUBCOMPANYID1 =? where DEPARTMENTID = ?", ecCompanyId, ecDepartmentId); //new RecordSet().executeUpdate("update hrmresource set SUBCOMPANYID1 =? where DEPARTMENTID = ?", ecCompanyId, ecDepartmentId);
@ -745,7 +678,7 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
//TODO new HrmResourceTriggerRunnable(hrmResourceId).run(); //TODO new HrmResourceTriggerRunnable(hrmResourceId).run();
//} //}
List<DepartmentPO> childList = getDepartmentMapper().getDeptListByPId(departmentPO.getId()); List<DepartmentPO> childList = getDepartmentMapper().getDeptListByPId(departmentPO.getId());
forbiddenChildTag(parentComp, ecCompanyId, childList); forbiddenChildTag(subCompanyId1, childList);
} }
} }
} }
@ -892,7 +825,7 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
map.put("showorder", Util.null2String(departmentPO.getShowOrder())); map.put("showorder", Util.null2String(departmentPO.getShowOrder()));
map.put("departmentcode", departmentPO.getDepartmentCode()); map.put("departmentcode", departmentPO.getDepartmentCode());
map.put("coadjutant", Util.null2String(departmentPO.getCoadjutant())); map.put("coadjutant", Util.null2String(departmentPO.getCoadjutant()));
map.put("id", Util.null2String(departmentPO.getId())); map.put("id", Util.null2String(departmentPO.getId()));
new OrganizationSyncEc(user, LogModuleNameEnum.DEPARTMENT, OperateTypeEnum.UPDATE, map).sync(); new OrganizationSyncEc(user, LogModuleNameEnum.DEPARTMENT, OperateTypeEnum.UPDATE, map).sync();
} }
@ -913,17 +846,6 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
return new OrganizationSyncEc(user, LogModuleNameEnum.DEPARTMENT, OperateTypeEnum.ADD, map).sync(); return new OrganizationSyncEc(user, LogModuleNameEnum.DEPARTMENT, OperateTypeEnum.ADD, map).sync();
} }
/**
* EC
*
* @param id
*/
private void cancelEcDepartment(Long id) {
Map<String, Object> map = new HashMap<>();
map.put("id", id);
map.put("forbiddenTag", 1);
new OrganizationSyncEc(user, LogModuleNameEnum.DEPARTMENT, OperateTypeEnum.CANCELED, map).sync();
}
private void addDisableIds(Set<Integer> disableIds, List<DepartmentPO> deptListByPId) { private void addDisableIds(Set<Integer> disableIds, List<DepartmentPO> deptListByPId) {
for (DepartmentPO departmentPO : deptListByPId) { for (DepartmentPO departmentPO : deptListByPId) {
@ -951,4 +873,154 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
} }
} }
private List<SearchConditionGroup> getDepartmentConditionGroups(Map<String, Object> params) {
List<SearchConditionGroup> groupList = new ArrayList<>();
List<SearchConditionItem> itemList;
List<SearchConditionItem> extendItemList;
String id = Util.null2String(params.get("id"));
int viewAttr = Util.getIntValue(Util.null2String(params.get("viewattr")), 1);
String nodeType = Util.null2String(params.get("type"));
String addType = Util.null2String(params.get("addType"));
DepartmentComInfo departmentComInfo = new DepartmentComInfo();
String subcompanyid1 = "";
String supDepId = "";
switch (addType) {
case "normal":
if ("subcompany".equals(nodeType)) {
subcompanyid1 = id;
} else {
subcompanyid1 = departmentComInfo.getSubcompanyid1(id);
}
break;
case "sibling":
subcompanyid1 = departmentComInfo.getSubcompanyid1(id);
supDepId = departmentComInfo.getDepartmentsupdepid(id);
break;
case "child":
subcompanyid1 = departmentComInfo.getSubcompanyid1(id);
supDepId = id;
break;
default:
break;
}
HrmFieldGroupComInfo HrmFieldGroupComInfo = new HrmFieldGroupComInfo();
HrmFieldComInfo HrmFieldComInfo = new HrmFieldComInfo();
HrmFieldSearchConditionComInfo hrmFieldSearchConditionComInfo = new HrmFieldSearchConditionComInfo();
SearchConditionItem searchConditionItem;
HrmFieldBean hrmFieldBean;
HrmDeptFieldManagerE9 hfm;
try {
hfm = new HrmDeptFieldManagerE9(5);
} catch (Exception e) {
throw new OrganizationRunTimeException("");
}
hfm.isReturnDecryptData(true);
hfm.getCustomData(Util.getIntValue(id));
List lsGroup = hfm.getLsGroup();
for (int tmp = 0; lsGroup != null && tmp < lsGroup.size(); tmp++) {
String groupId = (String) lsGroup.get(tmp);
List lsField = hfm.getLsField(groupId);
boolean groupHide = lsField.size() == 0 || hfm.getGroupCount(lsField) == 0 || !"1".equals(Util.null2String(HrmFieldGroupComInfo.getIsShow(groupId)));
String grouplabel = HrmFieldGroupComInfo.getLabel(groupId);
itemList = new ArrayList<>();
extendItemList = new ArrayList<>();
for (Object o : lsField) {
String fieldId = (String) o;
String fieldName = HrmFieldComInfo.getFieldname(fieldId);
String isUse = HrmFieldComInfo.getIsused(fieldId);
if (!"1".equals(isUse)) continue;
int tmpViewAttr = viewAttr;
String rules = "";
String fieldLabel = HrmFieldComInfo.getLabel(fieldId);
String fieldHtmlType = HrmFieldComInfo.getFieldhtmltype(fieldId);
String type = HrmFieldComInfo.getFieldType(fieldId);
String dmlUrl = Util.null2String(HrmFieldComInfo.getFieldDmlurl(fieldId));
String isSystem = HrmFieldComInfo.getIssystem(fieldId);
String fieldValue = "";
if (StringUtils.isBlank(addType)) {
if ("1".equals(isSystem)) {
fieldValue = hfm.getData(fieldName);
} else {
fieldValue = hfm.getData("hrmdepartmentdefined", fieldName);
}
}
if (!groupHide && tmpViewAttr == 2 && "1".equals(HrmFieldComInfo.getIsmand(fieldId))) {
tmpViewAttr = 3;
if ("1".equals(fieldHtmlType) && "2".equals(type)) {
rules = "required|integer";
} else {
rules = "required|string";
}
}
if (subcompanyid1.length() > 0 && "subcompanyid1".equals(fieldName)) {
fieldValue = subcompanyid1;
}
if (supDepId.length() > 0 && "supdepid".equals(fieldName)) {
fieldValue = supDepId;
}
if ("showid".equals(fieldName)) {
if (addType.length() > 0) {
continue;
} else {
fieldValue = id;
tmpViewAttr = 1;
}
}
hrmFieldBean = new HrmFieldBean();
hrmFieldBean.setFieldid(fieldId);
hrmFieldBean.setFieldname(fieldName);
hrmFieldBean.setFieldlabel(fieldLabel);
hrmFieldBean.setFieldhtmltype(fieldHtmlType);
hrmFieldBean.setType(type);
hrmFieldBean.setIsFormField(true);
hrmFieldBean.setIssystem("1");
hrmFieldBean.setFieldvalue(fieldValue);
hrmFieldBean.setDmlurl(dmlUrl);
hrmFieldBean.setViewAttr(tmpViewAttr);
hrmFieldBean.setRules(rules);
if ("subcompanyid1".equals(hrmFieldBean.getFieldname()) || "supdepid".equals(hrmFieldBean.getFieldname())) {
hrmFieldBean.setHideVirtualOrg(true);
}
if ("departmentcode".equals(hrmFieldBean.getFieldname())) {
hrmFieldBean.setMultilang(false);
}
searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user);
if (searchConditionItem != null) {
searchConditionItem.setLabelcol(8);
searchConditionItem.setFieldcol(16);
if ("showorder".equals(fieldName)) {
searchConditionItem.setPrecision(2);
}
if ("showid".equals(fieldName)) {
Map<String, Object> otherParams = new HashMap<>();
otherParams.put("hasBorder", true);
searchConditionItem.setOtherParams(otherParams);
}
if ("6".equals(fieldHtmlType)) {//附件
Map<String, Object> otherParams1 = new HashMap<>();
otherParams1.put("showOrder", false);
searchConditionItem.setOtherParams(otherParams1);
}
if ("1".equals(isSystem)) {
itemList.add(searchConditionItem);
} else {
extendItemList.add(searchConditionItem);
}
}
}
groupList.add(new SearchConditionGroup(SystemEnv.getHtmlLabelNames(grouplabel, user.getLanguage()), true, itemList));
groupList.add(new SearchConditionGroup("拓展信息", true, extendItemList));
}
return groupList;
}
} }

@ -184,8 +184,7 @@ public class CompController {
try { try {
User user = HrmUserVarify.getUser(request, response); User user = HrmUserVarify.getUser(request, response);
Map<String, Object> params = ParamUtil.request2Map(request); Map<String, Object> params = ParamUtil.request2Map(request);
params.put("viewattr", 2); return ReturnResult.successed(getCompWrapper(user).getCompBaseForm(params));
return ReturnResult.successed(getCompWrapper(user).getCompSaveForm(params));
} catch (Exception e) { } catch (Exception e) {
return ReturnResult.exceptionHandle(e); return ReturnResult.exceptionHandle(e);
} }

Loading…
Cancel
Save