拖拽逻辑代码优化
This commit is contained in:
parent
3619fe5ac3
commit
af4a2c87ef
|
|
@ -683,7 +683,7 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
|
|||
String supId = "";
|
||||
String ftype = "";
|
||||
String querySupIdSql;
|
||||
OrganizationAssert.isFalse("s".equals(sourceType) && "d".equals(targetType), "分部不能转移到部门下");
|
||||
// OrganizationAssert.isFalse("s".equals(sourceType) && "d".equals(targetType), "分部不能转移到部门下");
|
||||
OrganizationAssert.isFalse("-1".equals(dragPostion), "分部、部门不能转移至与集团平级");
|
||||
if ("s".equals(targetType)) {// 分部
|
||||
querySupIdSql = "select companyId as supComId,supsubcomid as supId,'s' as ftype from hrmsubcompany where id = ?";
|
||||
|
|
@ -697,63 +697,66 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
|
|||
supComId = Util.null2String(recordSet.getString("supComId"));
|
||||
ftype = Util.null2String(recordSet.getString("ftype"));
|
||||
}
|
||||
if ("1".equals(dragPostion)) {
|
||||
|
||||
if ("s".equals(targetType)) {
|
||||
OrganizationAssert.isFalse("0".equals(supId), "部门不能拖拽至集团下");
|
||||
// 转移到分部外
|
||||
deptById.setSubCompanyId1(Util.getIntValue(supId));
|
||||
deptById.setSupDepId(null);
|
||||
} else {
|
||||
// 转移到部门外
|
||||
List<DepartmentPO> deptListByPId = getDepartmentMapper().getDeptListByPId(Util.getIntValue(supId));
|
||||
Set<Integer> disableIds = new HashSet<>();
|
||||
disableIds.add(Util.getIntValue(sourceKey.substring(1)));
|
||||
if (CollectionUtils.isNotEmpty(deptListByPId)) {
|
||||
addDisableIds(disableIds, deptListByPId);
|
||||
if ("s".equals(sourceType)) {// 拖拽源是分部
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("id", sourceId);
|
||||
if ("0".equals(dragPostion)) {//内部
|
||||
OrganizationAssert.isFalse("d".equals(targetType), "分部不能拖拽至部门下");
|
||||
if ("c".equals(targetType)) {// 集团下(上级分部为0)
|
||||
params.put("supsubcomid", "0");
|
||||
}else if ("s".equals(targetType)){
|
||||
params.put("supsubcomid", targetId);//上下级关系
|
||||
}
|
||||
}else{//外部
|
||||
if("s".equals(targetType)){// 分部外(平级)
|
||||
params.put("supsubcomid",supId);
|
||||
}else{// 部门外(找上级)
|
||||
OrganizationAssert.isFalse("d".equals(ftype), "分部不能拖拽至部门下");
|
||||
params.put("supsubcomid",supId);
|
||||
}
|
||||
// OrganizationAssert.isFalse(disableIds.contains(Util.getIntValue(targetId)), "请勿选择当前部门本身及其子部门");
|
||||
deptById.setSupDepId(Util.getIntValue(supId));
|
||||
// DepartmentPO parentDepartment = getDepartmentMapper().getDeptById(Util.getIntValue(supId) == 0 ? Util.getIntValue(supComId) : Util.getIntValue(supId));
|
||||
// deptById.setSubCompanyId1(parentDepartment.getSubCompanyId1());
|
||||
deptById.setSubCompanyId1(Util.getIntValue(supComId));
|
||||
}
|
||||
} else {
|
||||
if ("s".equals(targetType)) {
|
||||
// 转移到分部下
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("id", sourceId);
|
||||
params.put("supsubcomid", targetId);
|
||||
new OrganizationSyncEc(user, LogModuleNameEnum.COMPANY, OperateTypeEnum.UPDATE, params).sync();
|
||||
if ("d".equals(sourceType)) {
|
||||
deptById.setSupDepId(0);
|
||||
deptById.setSubCompanyId1("s".equals(ftype) ? Util.getIntValue(targetId) : Util.getIntValue(supComId));
|
||||
new OrganizationSyncEc(user, LogModuleNameEnum.COMPANY, OperateTypeEnum.UPDATE, params).sync();
|
||||
} else {//拖拽源是部门
|
||||
List<DepartmentPO> deptListByPId;
|
||||
Set<Integer> disableIds = new HashSet<>();
|
||||
if ("0".equals(dragPostion)) {//内部
|
||||
OrganizationAssert.isFalse("c".equals(targetType), "部门不能拖拽至集团下");
|
||||
if("s".equals(targetType)){
|
||||
deptById.setSubCompanyId1(Util.getIntValue(targetId));
|
||||
deptById.setSupDepId(null);
|
||||
}else{
|
||||
deptListByPId = getDepartmentMapper().getDeptListByPId(Util.getIntValue(targetId));
|
||||
disableIds.add(Util.getIntValue(sourceKey.substring(1)));
|
||||
if (CollectionUtils.isNotEmpty(deptListByPId)) {
|
||||
addDisableIds(disableIds, deptListByPId);
|
||||
}
|
||||
OrganizationAssert.isFalse("d".equals(targetType) && disableIds.contains(Util.getIntValue(targetId)), "请勿选择当前部门本身及其子部门");
|
||||
deptById.setSupDepId(Util.getIntValue(targetId));
|
||||
DepartmentPO parentDepartment = getDepartmentMapper().getDeptById(Util.getIntValue(targetId));
|
||||
deptById.setSubCompanyId1(parentDepartment.getSubCompanyId1());
|
||||
}
|
||||
} else if ("c".equals(targetType)) {
|
||||
OrganizationAssert.isFalse("d".equals(sourceType), "部门不能拖拽到集团下");
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("id", sourceId);
|
||||
params.put("supsubcomid", "0");
|
||||
new OrganizationSyncEc(user, LogModuleNameEnum.COMPANY, OperateTypeEnum.UPDATE, params).sync();
|
||||
} else {
|
||||
// 转移到部门下
|
||||
List<DepartmentPO> deptListByPId = getDepartmentMapper().getDeptListByPId(Util.getIntValue(targetId));
|
||||
Set<Integer> disableIds = new HashSet<>();
|
||||
disableIds.add(Util.getIntValue(sourceKey.substring(1)));
|
||||
if (CollectionUtils.isNotEmpty(deptListByPId)) {
|
||||
addDisableIds(disableIds, deptListByPId);
|
||||
}else{//外部
|
||||
if("s".equals(targetType)){
|
||||
OrganizationAssert.isFalse("0".equals(supId), "部门不能拖拽至集团下");
|
||||
deptById.setSubCompanyId1(Util.getIntValue(supId));
|
||||
deptById.setSupDepId(null);
|
||||
}else{
|
||||
// 转移到部门外
|
||||
deptListByPId = getDepartmentMapper().getDeptListByPId(Util.getIntValue(supId));
|
||||
disableIds.add(Util.getIntValue(sourceKey.substring(1)));
|
||||
if (CollectionUtils.isNotEmpty(deptListByPId)) {
|
||||
addDisableIds(disableIds, deptListByPId);
|
||||
}
|
||||
deptById.setSupDepId(Util.getIntValue(supId));
|
||||
deptById.setSubCompanyId1(Util.getIntValue(supComId));
|
||||
}
|
||||
OrganizationAssert.isFalse("d".equals(targetType) && disableIds.contains(Util.getIntValue(targetId)), "请勿选择当前部门本身及其子部门");
|
||||
deptById.setSupDepId(Util.getIntValue(targetId));
|
||||
DepartmentPO parentDepartment = getDepartmentMapper().getDeptById(Util.getIntValue(targetId));
|
||||
deptById.setSubCompanyId1(parentDepartment.getSubCompanyId1());
|
||||
}
|
||||
// 更新EC部门
|
||||
updateEcDepartment(deptById);
|
||||
// 刷新岗位分部
|
||||
List<DepartmentPO> deptList = getDepartmentMapper().getDeptListByPId(deptById.getId());
|
||||
forbiddenChildTag(deptById.getSubCompanyId1(), deptList);
|
||||
}
|
||||
// 更新EC部门
|
||||
updateEcDepartment(deptById);
|
||||
// 刷新岗位分部
|
||||
List<DepartmentPO> deptList = getDepartmentMapper().getDeptListByPId(deptById.getId());
|
||||
forbiddenChildTag(deptById.getSubCompanyId1(), deptList);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import com.api.browser.bean.SearchConditionGroup;
|
|||
import com.engine.common.util.ServiceUtil;
|
||||
import com.engine.organization.annotation.Log;
|
||||
import com.engine.organization.entity.DeleteParam;
|
||||
import com.engine.organization.entity.company.po.CompPO;
|
||||
import com.engine.organization.entity.department.param.*;
|
||||
import com.engine.organization.entity.department.po.DepartmentPO;
|
||||
import com.engine.organization.entity.department.vo.SingleDeptTreeVO;
|
||||
|
|
@ -12,6 +13,7 @@ import com.engine.organization.entity.job.vo.SingleJobTreeVO;
|
|||
import com.engine.organization.entity.searchtree.SearchTreeParams;
|
||||
import com.engine.organization.enums.LogModuleNameEnum;
|
||||
import com.engine.organization.enums.OperateTypeEnum;
|
||||
import com.engine.organization.mapper.comp.CompMapper;
|
||||
import com.engine.organization.mapper.department.DepartmentMapper;
|
||||
import com.engine.organization.service.DepartmentService;
|
||||
import com.engine.organization.service.impl.DepartmentServiceImpl;
|
||||
|
|
@ -44,6 +46,9 @@ public class DepartmentWrapper extends OrganizationWrapper {
|
|||
private DepartmentMapper getDepartmentMapper() {
|
||||
return MapperProxyFactory.getProxy(DepartmentMapper.class);
|
||||
}
|
||||
private CompMapper getCompMapper() {
|
||||
return MapperProxyFactory.getProxy(CompMapper.class);
|
||||
}
|
||||
|
||||
public ReturnResult getDeptListByPid(QuerySingleDeptListParam param) {
|
||||
PageInfo<SingleDeptTreeVO> singleDeptTreeVOS = getDepartmentService(user).getDeptListByPid(param);
|
||||
|
|
@ -267,12 +272,23 @@ public class DepartmentWrapper extends OrganizationWrapper {
|
|||
* @param moveParam
|
||||
* @return
|
||||
*/
|
||||
@Log(operateType = OperateTypeEnum.MOVE, operateDesc = "拖拽转移部门", operateModule = LogModuleNameEnum.DEPARTMENT)
|
||||
@Log(operateType = OperateTypeEnum.MOVE, operateDesc = "拖拽转移部门或分部", operateModule = LogModuleNameEnum.DEPARTMENT)
|
||||
public int dragDepartment(DepartmentDragParam departmentDragParam) {
|
||||
DepartmentPO departmentPO = getDepartmentMapper().getDeptById(Util.getIntValue(Util.null2String(departmentDragParam.getSourcekey()).substring(1)));
|
||||
int moveDepartment = getDepartmentService(user).dragDepartment(departmentDragParam);
|
||||
writeOperateLog(new Object() {
|
||||
}.getClass(), departmentPO.getDepartmentName(), JSON.toJSONString(departmentDragParam), departmentPO, getDepartmentMapper().getDeptById(departmentPO.getId()));
|
||||
String type = departmentDragParam.getSourcekey().substring(0,1);
|
||||
String sourceId = departmentDragParam.getSourcekey().substring(1);
|
||||
int moveDepartment = 0;
|
||||
if("d".equals(type)) {
|
||||
DepartmentPO departmentPO = getDepartmentMapper().getDeptById(Integer.valueOf(sourceId));
|
||||
moveDepartment = getDepartmentService(user).dragDepartment(departmentDragParam);
|
||||
writeOperateLog(new Object() {
|
||||
}.getClass(), departmentPO.getDepartmentName(), JSON.toJSONString(departmentDragParam), departmentPO, getDepartmentMapper().getDeptById(departmentPO.getId()));
|
||||
}else{
|
||||
CompPO compPO = getCompMapper().listById(Integer.valueOf(sourceId));
|
||||
moveDepartment = getDepartmentService(user).dragDepartment(departmentDragParam);
|
||||
CompPO newcompPO = getCompMapper().listById(Integer.valueOf(sourceId));
|
||||
writeOperateLog(new Object() {
|
||||
}.getClass(), compPO.getSubCompanyName(), JSON.toJSONString(departmentDragParam), compPO, newcompPO);
|
||||
}
|
||||
return moveDepartment;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue