|
@@ -1,20 +1,25 @@
|
|
|
package cn.iocoder.yudao.module.system.service.saporg;
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
+import cn.hutool.core.collection.CollectionUtil;
|
|
|
+import cn.hutool.core.util.ObjUtil;
|
|
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
|
|
+import cn.iocoder.yudao.module.system.api.dept.DeptSapOrgApi;
|
|
|
+import cn.iocoder.yudao.module.system.api.dept.dto.DeptSapOrgRespDTO;
|
|
|
import cn.iocoder.yudao.module.system.controller.admin.saporg.vo.SapOrgPageReqVO;
|
|
|
import cn.iocoder.yudao.module.system.controller.admin.saporg.vo.SapOrgSaveReqVO;
|
|
|
import cn.iocoder.yudao.module.system.controller.admin.saporg.vo.SapOrgSimpleReqVO;
|
|
|
import cn.iocoder.yudao.module.system.dal.dataobject.saporg.SapOrgDO;
|
|
|
+import cn.iocoder.yudao.module.system.dal.mysql.dept.DeptMapper;
|
|
|
import cn.iocoder.yudao.module.system.dal.mysql.saporg.SapOrgMapper;
|
|
|
+import cn.iocoder.yudao.module.system.service.dept.DeptService;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
-import java.util.Collection;
|
|
|
-import java.util.Collections;
|
|
|
-import java.util.List;
|
|
|
+import java.util.*;
|
|
|
|
|
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
|
|
import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.SAP_ORG_NOT_EXISTS;
|
|
@@ -31,6 +36,13 @@ public class SapOrgServiceImpl implements SapOrgService {
|
|
|
@Resource
|
|
|
private SapOrgMapper sapOrgMapper;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private DeptMapper deptMapper;
|
|
|
+ @Autowired
|
|
|
+ private DeptService deptService;
|
|
|
+ @Autowired
|
|
|
+ private DeptSapOrgApi deptSapOrgApi;
|
|
|
+
|
|
|
@Override
|
|
|
public Long createSapOrg(SapOrgSaveReqVO createReqVO) {
|
|
|
// 插入
|
|
@@ -92,4 +104,31 @@ public class SapOrgServiceImpl implements SapOrgService {
|
|
|
return sapOrgMapper.selectBatchIds(ids);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public List<SapOrgDO> filteredSapOrgList(Long deptId, Integer type, Set<Integer> statuses) {
|
|
|
+ // 筛选部门id及子部门id关联的所有 SAP组织
|
|
|
+ if (ObjUtil.isEmpty(deptId)) {
|
|
|
+ return CollectionUtil.newArrayList();
|
|
|
+ }
|
|
|
+ Set<Long> ids = new HashSet<>();
|
|
|
+ ids = deptService.getChildDeptIdListFromCache(deptId);
|
|
|
+ ids.add(deptId);
|
|
|
+ // 查询当前部门及所有子部门关联的SAP工厂 成本中心 列表
|
|
|
+ List<DeptSapOrgRespDTO> sapOrgS = deptSapOrgApi.getSapOrgListByDeptIds(ids);
|
|
|
+ if (CollUtil.isEmpty(sapOrgS)) {
|
|
|
+ return CollectionUtil.newArrayList();
|
|
|
+ }
|
|
|
+ Set<Long> sapOrgIds = new HashSet<>();
|
|
|
+ sapOrgS.forEach(sapOrg -> {
|
|
|
+ if (ObjUtil.isNotEmpty(sapOrg.getFactoryId())) {
|
|
|
+ sapOrgIds.add(sapOrg.getFactoryId());
|
|
|
+ }
|
|
|
+ if (ObjUtil.isNotEmpty(sapOrg.getCostCenterId())) {
|
|
|
+ sapOrgIds.add(sapOrg.getCostCenterId());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ List<SapOrgDO> sapOrgList = getSapOrgList(sapOrgIds, type, statuses);
|
|
|
+ return sapOrgList;
|
|
|
+ }
|
|
|
+
|
|
|
}
|