|
@@ -512,8 +512,16 @@ public class WbsSynchronousServiceImpl {
|
|
|
Integer nodeNumEnd = 0;
|
|
|
for (Long pId : pIds) {
|
|
|
nodeNumEnd++;
|
|
|
+ List<WbsTreePrivate> list = collect1.get(pId);
|
|
|
+ //排序调整
|
|
|
+ if(wbsTreeSynchronousRecord.getType().contains("7")) {
|
|
|
+ for (WbsTreePrivate wbsTreePrivate : list) {
|
|
|
+ wbsTreePrivateMapper.updateSortByPId(pId, wbsTreePrivate.getSort());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
//更新最新节点
|
|
|
- wbsSynchronousEViSaService.updatePrivate(wbsTreeSynchronousRecord.getCreateUserId(), collect1.get(pId));
|
|
|
+ wbsSynchronousEViSaService.updatePrivate(wbsTreeSynchronousRecord.getCreateUserId(), list);
|
|
|
|
|
|
synchronousRecordMapper.update(null, Wrappers.<WbsTreeSynchronousRecord>lambdaUpdate()
|
|
|
.set(WbsTreeSynchronousRecord::getNodeNumEnd, nodeNumEnd)
|
|
@@ -788,7 +796,15 @@ public class WbsSynchronousServiceImpl {
|
|
|
|
|
|
for (Long pId : pIds) {
|
|
|
nodeNumEnd++;
|
|
|
- wbsSynchronousEViSaService.updateContract(wbsTreeSynchronousRecord.getCreateUserId(), collect1.get(pId));
|
|
|
+ List<WbsTreeContract> list = collect1.get(pId);
|
|
|
+ //排序调整
|
|
|
+ if(wbsTreeSynchronousRecord.getType().contains("7")) {
|
|
|
+ for (WbsTreeContract wbsTreeContract : list) {
|
|
|
+ wbsTreePrivateMapper.updateSortByPId(pId, wbsTreeContract.getSort());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ wbsSynchronousEViSaService.updateContract(wbsTreeSynchronousRecord.getCreateUserId(), list);
|
|
|
synchronousRecordMapper.update(null, Wrappers.<WbsTreeSynchronousRecord>lambdaUpdate()
|
|
|
.set(WbsTreeSynchronousRecord::getNodeNumEnd, nodeNumEnd)
|
|
|
.set(WbsTreeSynchronousRecord::getUpdateTime, DateTime.now())
|
|
@@ -839,6 +855,7 @@ public class WbsSynchronousServiceImpl {
|
|
|
WbsTreePrivate parent = addPrivateParentNodes.get(0);
|
|
|
|
|
|
addPrivateNode.setPId(parent.getPKeyId());
|
|
|
+ addPrivateNode.setAncestorsPId(parent.getAncestorsPId() + "," + addPrivateNode.getPId());
|
|
|
addPrivateNode.setWbsId(parent.getWbsId());
|
|
|
addPrivateNode.setWbsType(parent.getWbsType());
|
|
|
addPrivateNode.setIsAddConceal(0);
|
|
@@ -889,34 +906,52 @@ public class WbsSynchronousServiceImpl {
|
|
|
}
|
|
|
|
|
|
//查询出当前项目所有节点---------------------------------------------------------------------------------------------------
|
|
|
- List<WbsTreePrivate> addList = wbsTreePrivateMapper.selectList(Wrappers.<WbsTreePrivate>lambdaQuery()
|
|
|
- .select(WbsTreePrivate::getPKeyId, WbsTreePrivate::getPId)
|
|
|
- .eq(WbsTreePrivate::getIsDeleted, 0)
|
|
|
- .eq(WbsTreePrivate::getProjectId, addData.get(0).getProjectId()));
|
|
|
-
|
|
|
- addList.addAll(addData);
|
|
|
- //组合祖级路径 根据当前选中节点为开始
|
|
|
- Map<Long, WbsTreePrivate> collect = addList.stream().collect(Collectors.toMap(WbsTreePrivate::getPKeyId, Function.identity()));
|
|
|
-
|
|
|
- addData.forEach(node -> {
|
|
|
- String correctAncestors = createAncestorsPId(node, collect);
|
|
|
- node.setAncestorsPId(correctAncestors);
|
|
|
- });
|
|
|
+// List<WbsTreePrivate> addList = wbsTreePrivateMapper.selectList(Wrappers.<WbsTreePrivate>lambdaQuery()
|
|
|
+// .select(WbsTreePrivate::getPKeyId, WbsTreePrivate::getPId)
|
|
|
+// .eq(WbsTreePrivate::getIsDeleted, 0)
|
|
|
+// .eq(WbsTreePrivate::getProjectId, addData.get(0).getProjectId()));
|
|
|
+//
|
|
|
+// addList.addAll(addData);
|
|
|
+// //组合祖级路径 根据当前选中节点为开始
|
|
|
+// Map<Long, WbsTreePrivate> collect = addList.stream().collect(Collectors.toMap(WbsTreePrivate::getPKeyId, Function.identity()));
|
|
|
+//
|
|
|
+// addData.forEach(node -> {
|
|
|
+// String correctAncestors = createAncestorsPId(node, collect);
|
|
|
+// node.setAncestorsPId(correctAncestors);
|
|
|
+// });
|
|
|
|
|
|
//新增-----------------------------------------------------------------------------------------------------------------
|
|
|
- List<List<WbsTreePrivate>> partition = Lists.partition(addData, 1000);
|
|
|
- Integer count = 0;
|
|
|
- for (List<WbsTreePrivate> data : partition) {
|
|
|
+ Map<Long, List<WbsTreePrivate>> collect = addData.stream().collect(Collectors.groupingBy(WbsTreePrivate::getPId));
|
|
|
+ Set<Long> longs = collect.keySet();
|
|
|
+
|
|
|
+ List<Long> pIds = new ArrayList<>(longs);
|
|
|
+ List<WbsTreePrivate> saveData = new ArrayList<>();
|
|
|
+ //按最小节点批量新增
|
|
|
+ List<List<Long>> partition = Lists.partition(pIds, 100);
|
|
|
+
|
|
|
+ for (List<Long> data : partition) {
|
|
|
+ for (Long datum : data) {
|
|
|
+ List<WbsTreePrivate> list = collect.get(datum);
|
|
|
+ //修改排序
|
|
|
+ if(wbsTreeSynchronousRecord.getType().contains("7")){
|
|
|
+ for (WbsTreePrivate wbsTreePrivate : list) {
|
|
|
+ Integer sort = wbsTreePrivate.getSort();
|
|
|
+ if(sort != null){
|
|
|
+ wbsTreePrivateMapper.updateSortByPId(datum,wbsTreePrivate.getSort());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ boolean b = saveData.addAll(list);
|
|
|
+ }
|
|
|
+
|
|
|
//单个批次一个事务,只会回滚当前批次数据
|
|
|
- Integer i = wbsTreePrivateMapper.insertBatchSomeColumn(data);
|
|
|
+ Integer i = wbsTreePrivateMapper.insertBatchSomeColumn(saveData);
|
|
|
//如果失败 -- - - - - 继续执行 或者把当前节点的p_key_id 记录到某个地方 方便后续处理
|
|
|
if (i == 0) {
|
|
|
List<Long> collect1 = addData.stream().map(WbsTreePrivate::getPKeyId).collect(Collectors.toList());
|
|
|
//这里可以保存到数据库指定错误日志表
|
|
|
- throw new ServiceException("重置表单路径错误:" + StringUtil.join(collect1, ","));
|
|
|
+ throw new ServiceException("添加失败:" + StringUtil.join(collect1, ","));
|
|
|
}
|
|
|
-
|
|
|
- count += i;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -972,7 +1007,7 @@ public class WbsSynchronousServiceImpl {
|
|
|
//TODO
|
|
|
addContractNode.setPId(parent.getPKeyId());
|
|
|
//TODO
|
|
|
- addContractNode.setContractId(parent.getContractId());
|
|
|
+ addContractNode.setAncestorsPId(parent.getAncestorsPId() + "," + addContractNode.getPId());
|
|
|
addContractNode.setContractId(String.valueOf(contractInfo.getId()));
|
|
|
//更新创建时间
|
|
|
addContractNode.setCreateTime(DateTime.now());
|
|
@@ -983,32 +1018,54 @@ public class WbsSynchronousServiceImpl {
|
|
|
|
|
|
|
|
|
//查询出当前项目所有节点---------------------------------------------------------------------------------------------------
|
|
|
- List<WbsTreeContract> addList = wbsTreeContractMapper.selectList(Wrappers.<WbsTreeContract>lambdaQuery()
|
|
|
- .select(WbsTreeContract::getPKeyId, WbsTreeContract::getPId)
|
|
|
- .eq(WbsTreeContract::getIsDeleted, 0)
|
|
|
- .eq(WbsTreeContract::getContractId, contractInfo.getId()));
|
|
|
-
|
|
|
- addList.addAll(addData);
|
|
|
-
|
|
|
-
|
|
|
- //组合祖级路径 根据当前选中节点为开始
|
|
|
- Map<Long, WbsTreeContract> collect = addList.stream().collect(Collectors.toMap(WbsTreeContract::getPKeyId, Function.identity()));
|
|
|
-
|
|
|
- addData.forEach(node -> {
|
|
|
- //通过转换为WbsTreePrivate的方式 去获取祖级节点
|
|
|
- String correctAncestors = createAncestorsPId(node, collect);
|
|
|
- node.setAncestorsPId(correctAncestors);
|
|
|
- });
|
|
|
+// List<WbsTreeContract> addList = wbsTreeContractMapper.selectList(Wrappers.<WbsTreeContract>lambdaQuery()
|
|
|
+// .select(WbsTreeContract::getPKeyId, WbsTreeContract::getPId)
|
|
|
+// .eq(WbsTreeContract::getIsDeleted, 0)
|
|
|
+// .eq(WbsTreeContract::getContractId, contractInfo.getId()));
|
|
|
+//
|
|
|
+// addList.addAll(addData);
|
|
|
+//
|
|
|
+//
|
|
|
+// //组合祖级路径 根据当前选中节点为开始
|
|
|
+// Map<Long, WbsTreeContract> collect = addList.stream().collect(Collectors.toMap(WbsTreeContract::getPKeyId, Function.identity()));
|
|
|
+//
|
|
|
+// addData.forEach(node -> {
|
|
|
+// //通过转换为WbsTreePrivate的方式 去获取祖级节点
|
|
|
+// String correctAncestors = createAncestorsPId(node, collect);
|
|
|
+// node.setAncestorsPId(correctAncestors);
|
|
|
+// });
|
|
|
|
|
|
//新增-----------------------------------------------------------------------------------------------------------------
|
|
|
- List<List<WbsTreeContract>> partition = Lists.partition(addData, 1000);
|
|
|
- for (List<WbsTreeContract> data : partition) {
|
|
|
+ Map<Long, List<WbsTreeContract>> collect = addData.stream().collect(Collectors.groupingBy(WbsTreeContract::getPId));
|
|
|
+ Set<Long> longs = collect.keySet();
|
|
|
+
|
|
|
+ List<Long> pIds = new ArrayList<>(longs);
|
|
|
+ List<WbsTreeContract> saveData = new ArrayList<>();
|
|
|
+ //按最小节点批量新增
|
|
|
+ List<List<Long>> partition = Lists.partition(pIds, 100);
|
|
|
+ for (List<Long> data : partition) {
|
|
|
+ for (Long datum : data) {
|
|
|
+ List<WbsTreeContract> list = collect.get(datum);
|
|
|
+ //修改排序
|
|
|
+ if(wbsTreeSynchronousRecord.getType().contains("7")){
|
|
|
+ for (WbsTreeContract wbsTreeContract : list) {
|
|
|
+ Integer sort = wbsTreeContract.getSort();
|
|
|
+ if(sort != null){
|
|
|
+ wbsTreeContractMapper.updateSortByPId(datum,wbsTreeContract.getSort());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ boolean b = saveData.addAll(list);
|
|
|
+ }
|
|
|
+
|
|
|
//单个批次一个事务,只会回滚当前批次数据
|
|
|
- Integer i = wbsTreeContractMapper.insertBatchSomeColumn(data);
|
|
|
+ Integer i = wbsTreeContractMapper.insertBatchSomeColumn(saveData);
|
|
|
//如果失败 -- - - - - 继续执行 或者把当前节点的p_key_id 记录到某个地方 方便后续处理
|
|
|
if (i == 0) {
|
|
|
List<Long> collect1 = addData.stream().map(WbsTreeContract::getPKeyId).collect(Collectors.toList());
|
|
|
//这里可以保存到数据库指定错误日志表
|
|
|
+ //这里可以保存到数据库指定错误日志表
|
|
|
+ throw new ServiceException("添加失败:" + StringUtil.join(collect1, ","));
|
|
|
}
|
|
|
}
|
|
|
}
|