|
@@ -785,6 +785,7 @@ public class WbsTreeServiceImpl extends BaseServiceImpl<WbsTreeMapper, WbsTree>
|
|
|
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
+ @Deprecated
|
|
|
public String submitWbsTreeInProject(WbsTreeContractDTO pawDTO) {
|
|
|
String wbsTreeIds = pawDTO.getWbsTreeIds();
|
|
|
String[] ids = wbsTreeIds.split(",");
|
|
@@ -1070,6 +1071,297 @@ public class WbsTreeServiceImpl extends BaseServiceImpl<WbsTreeMapper, WbsTree>
|
|
|
return "2";
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public Boolean submitWbsTreeInProject1(WbsTreeContractDTO pawDTO) {
|
|
|
+ String wbsTreeIds = pawDTO.getWbsTreeIds();
|
|
|
+ String[] ids = wbsTreeIds.split(",");
|
|
|
+ List<String> idList = Arrays.asList(ids);
|
|
|
+ //入参ids
|
|
|
+ List<String> idList1 = idList.stream().filter(string -> !string.isEmpty()).collect(Collectors.toList());
|
|
|
+
|
|
|
+ //当前项目存在的引用ids
|
|
|
+ List<String> idList2 = new ArrayList<>();
|
|
|
+
|
|
|
+ //当前公有引用ids
|
|
|
+ if (pawDTO.getReferenceType().equals("public")) {
|
|
|
+ List<WbsTreePrivate> wbsTreePrivates = wbsTreePrivateMapper.selectList(Wrappers.<WbsTreePrivate>query().lambda()
|
|
|
+ .eq(WbsTreePrivate::getWbsId, pawDTO.getWbsId())
|
|
|
+ .eq(WbsTreePrivate::getProjectId, pawDTO.getProjectId())
|
|
|
+ .eq(WbsTreePrivate::getType, 1)
|
|
|
+ );
|
|
|
+ wbsTreePrivates.stream().forEach(wbsTreePrivate -> {
|
|
|
+ idList2.add(String.valueOf(wbsTreePrivate.getId()));
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ //当前私有引用ids
|
|
|
+ else if (pawDTO.getReferenceType().equals("private")) {
|
|
|
+ List<WbsTreePrivate> wbsTreePrivates2 = wbsTreePrivateMapper.selectList(Wrappers.<WbsTreePrivate>query().lambda()
|
|
|
+ .eq(WbsTreePrivate::getWbsId, pawDTO.getPrimaryKeyId())
|
|
|
+ .eq(WbsTreePrivate::getProjectId, pawDTO.getProjectId())
|
|
|
+ .eq(WbsTreePrivate::getType, 1)
|
|
|
+ );
|
|
|
+ wbsTreePrivates2.stream().forEach(wbsTreePrivate -> {
|
|
|
+ idList2.add(String.valueOf(wbsTreePrivate.getId()));
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ //需要新增的节点ids
|
|
|
+ List<String> saveIds = idList1.stream().filter(f -> !idList2.contains(f)).collect(Collectors.toList());
|
|
|
+ //需要删除的节点ids
|
|
|
+ List<String> delIds = idList2.stream().filter(f -> !idList1.contains(f)).collect(Collectors.toList());
|
|
|
+
|
|
|
+ if (saveIds.size() == 0 && delIds.size() == 0) {
|
|
|
+ //节点id未变,只进行节点下的元素表的同步
|
|
|
+ if (pawDTO.getReferenceType().equals("public")) {
|
|
|
+ //公有同步新增元素表
|
|
|
+ //获取公有wbs树新增的元素表
|
|
|
+ List<WbsTree> allNodeList = findAllNodeList(wbsTreeIds);
|
|
|
+ List<WbsTree> wbsTreeListAll = new ArrayList<>();
|
|
|
+
|
|
|
+ //获取公有wbs树所有的元素表
|
|
|
+ if (allNodeList != null) {
|
|
|
+ List<WbsTree> wbsTreeList = wbsTreeMapper.selectList(Wrappers.<WbsTree>query().lambda()
|
|
|
+ .eq(WbsTree::getWbsId, pawDTO.getWbsId())
|
|
|
+ .eq(WbsTree::getType, 2)
|
|
|
+ );
|
|
|
+ wbsTreeListAll.addAll(wbsTreeList);
|
|
|
+ }
|
|
|
+
|
|
|
+ //公有元素表的id
|
|
|
+ List<Long> collect1 = wbsTreeListAll.stream().map(WbsTree::getId).collect(Collectors.toList());
|
|
|
+ List<String> collect2 = collect1.stream().map(String::valueOf).collect(Collectors.toList());
|
|
|
+
|
|
|
+ //获取项目私有wbs树下当前所有的元素表
|
|
|
+ List<WbsTreePrivate> wbsTreePrivates1 = wbsTreePrivateMapper.selectList(Wrappers.<WbsTreePrivate>query().lambda()
|
|
|
+ .eq(WbsTreePrivate::getWbsId, pawDTO.getWbsId())
|
|
|
+ .eq(WbsTreePrivate::getProjectId, pawDTO.getProjectId())
|
|
|
+ .eq(WbsTreePrivate::getType, 2)
|
|
|
+ );
|
|
|
+
|
|
|
+ //私有下元素表id
|
|
|
+ List<Long> collect3 = wbsTreePrivates1.stream().map(WbsTreePrivate::getId).collect(Collectors.toList());
|
|
|
+ List<String> collect4 = collect3.stream().map(String::valueOf).collect(Collectors.toList());
|
|
|
+
|
|
|
+ List<String> diffRent1 = WbsTreeContractServiceImpl.getDiffrent(collect2, collect4);
|
|
|
+
|
|
|
+ if (diffRent1.size() == 0) {
|
|
|
+ //当wbsTreeIds == "" 时 1.在第一次新增未选择wbs树时 2.同步新增的元素表时
|
|
|
+ throw new ServiceException("未检测到当前引用的wbs树下有新增的元素表信息");
|
|
|
+
|
|
|
+ } else {
|
|
|
+ if (collect2.size() > collect4.size()) {
|
|
|
+ //公有同步元素表
|
|
|
+ diffRent1.stream().forEach(tableId -> {
|
|
|
+ WbsTree wbsTree = wbsTreeMapper.selectById(tableId);
|
|
|
+ Long snowId1 = SnowFlakeUtil.getId();
|
|
|
+ wbsTreePrivateMapper.insertCombination1(snowId1, wbsTree, pawDTO.getWbsType(), pawDTO.getProjectId());
|
|
|
+ });
|
|
|
+
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }else if (pawDTO.getReferenceType().equals("private")) {
|
|
|
+ //私有同步新增元素表
|
|
|
+ //获取所私有引用项目的新增的元素表 根据primaryKeyId获取对象信息
|
|
|
+ WbsTreePrivate wbsTreePrivate = wbsTreePrivateMapper.selectOne(Wrappers.<WbsTreePrivate>query().lambda()
|
|
|
+ .eq(WbsTreePrivate::getPKeyId, pawDTO.getPrimaryKeyId()));
|
|
|
+
|
|
|
+ //获取所私有引用项目的wbs树的全部元素表
|
|
|
+ List<WbsTreePrivate> wbsTreePrivates = wbsTreePrivateMapper.selectList(Wrappers.<WbsTreePrivate>query().lambda()
|
|
|
+ .eq(WbsTreePrivate::getWbsId, wbsTreePrivate.getWbsId())
|
|
|
+ .eq(WbsTreePrivate::getProjectId, wbsTreePrivate.getProjectId())
|
|
|
+ .eq(WbsTreePrivate::getType, 2)
|
|
|
+ );
|
|
|
+
|
|
|
+ //当前新增表单的id
|
|
|
+ List<Long> collect1 = wbsTreePrivates.stream().map(WbsTreePrivate::getId).collect(Collectors.toList());
|
|
|
+ List<String> collect2 = collect1.stream().map(String::valueOf).collect(Collectors.toList());
|
|
|
+
|
|
|
+ //获取当前项目私有wbs树下当前所有的元素表
|
|
|
+ List<WbsTreePrivate> wbsTreePrivates1 = wbsTreePrivateMapper.selectList(Wrappers.<WbsTreePrivate>query().lambda()
|
|
|
+ .eq(WbsTreePrivate::getWbsId, pawDTO.getPrimaryKeyId())
|
|
|
+ .eq(WbsTreePrivate::getProjectId, pawDTO.getProjectId())
|
|
|
+ .eq(WbsTreePrivate::getType, 2)
|
|
|
+ );
|
|
|
+
|
|
|
+ //当前存在的表单的id
|
|
|
+ List<Long> collect3 = wbsTreePrivates1.stream().map(WbsTreePrivate::getId).collect(Collectors.toList());
|
|
|
+ List<String> collect4 = collect3.stream().map(String::valueOf).collect(Collectors.toList());
|
|
|
+
|
|
|
+ List<String> diffRent1 = WbsTreeContractServiceImpl.getDiffrent(collect2, collect4);
|
|
|
+
|
|
|
+ if (diffRent1.size() == 0) {
|
|
|
+ throw new ServiceException("未检测到当前引用的wbs树下有新增的元素表信息");
|
|
|
+
|
|
|
+ } else {
|
|
|
+ if (collect2.size() > collect4.size()) {
|
|
|
+ //私有同步元素表
|
|
|
+ List<WbsTreePrivate> lists = new ArrayList<>();
|
|
|
+
|
|
|
+ diffRent1.stream().forEach(tableId -> {
|
|
|
+ List<WbsTreePrivate> wbsTreePrivates3 = wbsTreePrivateMapper.selectList(Wrappers.<WbsTreePrivate>query().lambda()
|
|
|
+ .eq(WbsTreePrivate::getId, tableId)
|
|
|
+ .eq(WbsTreePrivate::getWbsId, wbsTreePrivate.getWbsId())
|
|
|
+ .eq(WbsTreePrivate::getProjectId, wbsTreePrivate.getProjectId())
|
|
|
+ .eq(WbsTreePrivate::getType, 2)
|
|
|
+ );
|
|
|
+ lists.addAll(wbsTreePrivates3);
|
|
|
+ });
|
|
|
+
|
|
|
+ lists.stream().forEach(list -> {
|
|
|
+ list.setPKeyId(SnowFlakeUtil.getId());
|
|
|
+ list.setWbsId(pawDTO.getPrimaryKeyId());
|
|
|
+ list.setProjectId(pawDTO.getProjectId());
|
|
|
+ });
|
|
|
+
|
|
|
+ wbsTreePrivateService.saveBatch(lists, 10000);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ } else {
|
|
|
+ //节点id改变,进行新增或删除节点以及该节点下的元素表
|
|
|
+ //1.删除
|
|
|
+ if (delIds.size() > 0) {
|
|
|
+ if (pawDTO.getReferenceType().equals("public")) {
|
|
|
+ List<Long> ids1 = delIds.stream().map(Long::parseLong).collect(Collectors.toList());
|
|
|
+ //判断是否被合同段引用
|
|
|
+ List<WbsTreeContract> wbsTreeContract = wbsTreeContractMapper.selectList(Wrappers.<WbsTreeContract>query().lambda()
|
|
|
+ .eq(WbsTreeContract::getWbsId, pawDTO.getWbsId())
|
|
|
+ .eq(WbsTreeContract::getProjectId, pawDTO.getProjectId())
|
|
|
+ .eq(WbsTreeContract::getParentId, 0)
|
|
|
+ );
|
|
|
+
|
|
|
+ if (wbsTreeContract.size() > 0) {
|
|
|
+ List<ContractInfo> contractInfoArrayList = new ArrayList<>();
|
|
|
+ wbsTreeContract.stream().forEach(list -> {
|
|
|
+ ContractInfo contractInfos = contractInfoMapper.selectOne(Wrappers.<ContractInfo>query().lambda()
|
|
|
+ .eq(ContractInfo::getId, list.getContractId())
|
|
|
+ );
|
|
|
+ contractInfoArrayList.add(contractInfos);
|
|
|
+ });
|
|
|
+ List<String> names = contractInfoArrayList.stream().map(ContractInfo::getContractName).collect(Collectors.toList());
|
|
|
+ if (wbsTreeContract.size() > 0) {
|
|
|
+ String join = StringUtils.join(names, ",");
|
|
|
+ throw new ServiceException(StringUtil.format("当前项目wbs树已被 {} 引用中,删除失败", join));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ baseMapper.deleteBatch(ids1, pawDTO.getWbsId(), pawDTO.getProjectId());
|
|
|
+ baseMapper.deleteBatch2(ids1, pawDTO.getWbsId(), pawDTO.getProjectId());
|
|
|
+
|
|
|
+ } else if (pawDTO.getReferenceType().equals("private")) {
|
|
|
+ List<Long> ids2 = delIds.stream().map(Long::parseLong).collect(Collectors.toList());
|
|
|
+ //判断是否被合同段引用
|
|
|
+ List<WbsTreeContract> wbsTreeContract = wbsTreeContractMapper.selectList(Wrappers.<WbsTreeContract>query().lambda()
|
|
|
+ .eq(WbsTreeContract::getWbsId, pawDTO.getPrimaryKeyId())
|
|
|
+ .eq(WbsTreeContract::getProjectId, pawDTO.getProjectId())
|
|
|
+ .eq(WbsTreeContract::getParentId, 0)
|
|
|
+ );
|
|
|
+
|
|
|
+ if (wbsTreeContract.size() > 0) {
|
|
|
+ List<ContractInfo> contractInfoArrayList = new ArrayList<>();
|
|
|
+ wbsTreeContract.stream().forEach(list -> {
|
|
|
+ ContractInfo contractInfos = contractInfoMapper.selectOne(Wrappers.<ContractInfo>query().lambda()
|
|
|
+ .eq(ContractInfo::getId, list.getContractId())
|
|
|
+ );
|
|
|
+ contractInfoArrayList.add(contractInfos);
|
|
|
+ });
|
|
|
+ List<String> names = contractInfoArrayList.stream().map(ContractInfo::getContractName).collect(Collectors.toList());
|
|
|
+ if (wbsTreeContract.size() > 0) {
|
|
|
+ String join = StringUtils.join(names, ",");
|
|
|
+ throw new ServiceException(StringUtil.format("当前项目wbs树已被 {} 引用中,删除失败", join));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ baseMapper.deleteBatch(ids2, pawDTO.getPrimaryKeyId(), pawDTO.getProjectId());
|
|
|
+ baseMapper.deleteBatch2(ids2, pawDTO.getPrimaryKeyId(), pawDTO.getProjectId());
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ //2.新增
|
|
|
+ if (saveIds.size() > 0) {
|
|
|
+
|
|
|
+ //数据初始化节点-引用公有
|
|
|
+ List<WbsTreePrivate> insertData = new ArrayList<>();
|
|
|
+ //数据初始化节点-引用私有
|
|
|
+ List<WbsTreePrivate> insertData2 = new ArrayList<>();
|
|
|
+
|
|
|
+ if (pawDTO.getReferenceType().equals("public")) {
|
|
|
+ //引用公有
|
|
|
+ //查询所有公共节点、表 saveIds=新增的节点id
|
|
|
+ List<WbsTree> addListData = new ArrayList<>();
|
|
|
+ //查询出当前wbs树下所有节点、表信息
|
|
|
+ List<WbsTree> treesAll = baseMapper.selectList(Wrappers.<WbsTree>query().lambda()
|
|
|
+ .eq(WbsTree::getWbsId, pawDTO.getWbsId()));
|
|
|
+
|
|
|
+ for (WbsTree wbsTree : treesAll) {
|
|
|
+ for (String id : saveIds) {
|
|
|
+ if (Long.parseLong(id) == (wbsTree.getId())) {
|
|
|
+ //节点
|
|
|
+ addListData.add(wbsTree);
|
|
|
+ } else if (Long.parseLong(id) == (wbsTree.getParentId()) && wbsTree.getType() == 2) {
|
|
|
+ //表
|
|
|
+ addListData.add(wbsTree);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ addListData.stream().forEach(tree -> {
|
|
|
+ WbsTreePrivate wbsTreePrivate2 = getWbsTreePrivate1(tree, pawDTO);
|
|
|
+ insertData.add(wbsTreePrivate2);
|
|
|
+ });
|
|
|
+
|
|
|
+ } else if (pawDTO.getReferenceType().equals("private")) {
|
|
|
+ //引用私有
|
|
|
+ //查询所有私有节点、表 saveIds=新增的节点id
|
|
|
+ List<WbsTreePrivate> addListData = new ArrayList<>();
|
|
|
+
|
|
|
+ //查询出当前wbs树下所有节点、表信息
|
|
|
+ List<WbsTreePrivate> wbsTreePrivates = wbsTreePrivateMapper.selectNodeAndTable(null, pawDTO.getWbsId(), pawDTO.getReferencePrivateWbsProjectId());
|
|
|
+
|
|
|
+ for (WbsTreePrivate wbsTreePrivate : wbsTreePrivates) {
|
|
|
+ for (String id : saveIds) {
|
|
|
+ if (Long.parseLong(id) == (wbsTreePrivate.getId())) {
|
|
|
+ //节点
|
|
|
+ addListData.add(wbsTreePrivate);
|
|
|
+ } else if (Long.parseLong(id) == (wbsTreePrivate.getParentId()) && wbsTreePrivate.getType() == 2) {
|
|
|
+ //表
|
|
|
+ addListData.add(wbsTreePrivate);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ addListData.stream().forEach(tree -> {
|
|
|
+ WbsTreePrivate wbsTreePrivate2 = getWbsTreePrivate2(tree, pawDTO);
|
|
|
+ insertData2.add(wbsTreePrivate2);
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ //新增
|
|
|
+ if (pawDTO.getReferenceType().equals("public")) {
|
|
|
+ wbsTreePrivateService.saveBatch(insertData, 10000);
|
|
|
+ projectInfoMapper.updateTemplateIdById(pawDTO.getProjectId(), pawDTO.getWbsId(), "public");
|
|
|
+ } else if (pawDTO.getReferenceType().equals("private")) {
|
|
|
+ wbsTreePrivateService.saveBatch(insertData2, 10000);
|
|
|
+ projectInfoMapper.updateTemplateIdById(pawDTO.getProjectId(), pawDTO.getPrimaryKeyId(), "private");
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
public List<WbsTree> findAllNodeList(String wbsTreeIds) {
|
|
|
if (StringUtils.isNotEmpty(wbsTreeIds)) {
|
|
|
String[] ids = wbsTreeIds.split(",");
|