|
@@ -246,6 +246,7 @@ public class WbsSynchronousServiceImpl {
|
|
|
ProjectInfo tempProject = projectInfoMapper.selectOne(Wrappers.<ProjectInfo>lambdaQuery()
|
|
|
.eq(ProjectInfo::getId, wbsTreeSynchronousRecord.getTemplateId()));
|
|
|
|
|
|
+ List<WbsTreePrivate> addData = new ArrayList<>();
|
|
|
List<WbsTreePrivate> editData = new ArrayList<>();
|
|
|
|
|
|
for (String primaryKeyId : nodeIds) {
|
|
@@ -512,7 +513,8 @@ public class WbsSynchronousServiceImpl {
|
|
|
switch (i) {
|
|
|
//添加表单
|
|
|
case 1:
|
|
|
- insertPrivateForm(wbsTreeSynchronousRecord, wbsTreePrivates, addPrivateNodes);
|
|
|
+ List<WbsTreePrivate> list = insertPrivateForm(wbsTreeSynchronousRecord, wbsTreePrivates, addPrivateNodes);
|
|
|
+ addData.addAll(list);
|
|
|
updateEViSa(collect, wbsTreeSynchronousRecord.getTemplateId(), projectInfo.getId(), templateNodes, addPrivateNodes);
|
|
|
break;
|
|
|
//清表
|
|
@@ -541,17 +543,32 @@ public class WbsSynchronousServiceImpl {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ Set<Long> pIdsNew = new HashSet<>();
|
|
|
+ Map<Long, List<WbsTreePrivate>> addMap = addData.stream().collect(Collectors.groupingBy(WbsTreePrivate::getPId));
|
|
|
+ pIdsNew.addAll(addMap.keySet());
|
|
|
+
|
|
|
+
|
|
|
//更新数据的同时统计最小节点数量
|
|
|
Map<Long, List<WbsTreePrivate>> collect1 = editData.stream().collect(Collectors.groupingBy(WbsTreePrivate::getPId));
|
|
|
- Set<Long> pIds = collect1.keySet();
|
|
|
+ pIdsNew.addAll(collect1.keySet());
|
|
|
Integer nodeNumEnd = 0;
|
|
|
- for (Long pId : pIds) {
|
|
|
+ //修改需要操作的数量
|
|
|
+ synchronousRecordMapper.update(null, Wrappers.<WbsTreeSynchronousRecord>lambdaUpdate()
|
|
|
+ .set(WbsTreeSynchronousRecord::getNodeNum, pIdsNew.size())
|
|
|
+ .set(WbsTreeSynchronousRecord::getUpdateTime, DateTime.now())
|
|
|
+ .eq(WbsTreeSynchronousRecord::getId, wbsTreeSynchronousRecord.getId()));
|
|
|
+ for (Long pId : pIdsNew) {
|
|
|
nodeNumEnd++;
|
|
|
+ //新增数据
|
|
|
+ List<WbsTreePrivate> addList = addMap.get(pId);
|
|
|
+ if (CollectionUtil.isNotEmpty(addList)) {
|
|
|
+ wbsSynchronousEViSaService.insertPrivateForm(wbsTreeSynchronousRecord, addList, pId);
|
|
|
+ }
|
|
|
List<WbsTreePrivate> list = collect1.get(pId);
|
|
|
-
|
|
|
- //更新最新节点
|
|
|
- wbsSynchronousEViSaService.updatePrivate(wbsTreeSynchronousRecord.getType(), pId, wbsTreeSynchronousRecord.getCreateUserId(), list);
|
|
|
-
|
|
|
+ if(CollectionUtil.isNotEmpty(list)){
|
|
|
+ //更新最新节点
|
|
|
+ wbsSynchronousEViSaService.updatePrivate(wbsTreeSynchronousRecord.getType(), pId, wbsTreeSynchronousRecord.getCreateUserId(), list);
|
|
|
+ }
|
|
|
synchronousRecordMapper.update(null, Wrappers.<WbsTreeSynchronousRecord>lambdaUpdate()
|
|
|
.set(WbsTreeSynchronousRecord::getNodeNumEnd, nodeNumEnd)
|
|
|
.set(WbsTreeSynchronousRecord::getUpdateTime, DateTime.now())
|
|
@@ -871,7 +888,11 @@ public class WbsSynchronousServiceImpl {
|
|
|
|
|
|
//需要记录历史html的表单
|
|
|
Map<Long, List<WbsTreeContract>> collect3 = oldHtml.stream().collect(Collectors.groupingBy(WbsTreeContract::getPId));
|
|
|
-
|
|
|
+ //修改需要操作的数量
|
|
|
+ synchronousRecordMapper.update(null, Wrappers.<WbsTreeSynchronousRecord>lambdaUpdate()
|
|
|
+ .set(WbsTreeSynchronousRecord::getNodeNum, pIdsNew.size())
|
|
|
+ .set(WbsTreeSynchronousRecord::getUpdateTime, DateTime.now())
|
|
|
+ .eq(WbsTreeSynchronousRecord::getId, wbsTreeSynchronousRecord.getId()));
|
|
|
for (Long pId : pIdsNew) {
|
|
|
nodeNumEnd++;
|
|
|
|
|
@@ -937,7 +958,7 @@ public class WbsSynchronousServiceImpl {
|
|
|
* @param wbsTreePrivates 当前项目对应节点的子节点
|
|
|
* @param addPrivateNodes 需要新增的节点
|
|
|
*/
|
|
|
- public void insertPrivateForm(WbsTreeSynchronousRecord wbsTreeSynchronousRecord, List<WbsTreePrivate> wbsTreePrivates, List<WbsTreePrivate> addPrivateNodes) {
|
|
|
+ public List<WbsTreePrivate> insertPrivateForm(WbsTreeSynchronousRecord wbsTreeSynchronousRecord, List<WbsTreePrivate> wbsTreePrivates, List<WbsTreePrivate> addPrivateNodes) {
|
|
|
List<WbsTreePrivate> addData = new ArrayList<>();
|
|
|
|
|
|
//------------------------------------------------新增-------------------------------------------------------------------------
|
|
@@ -1014,73 +1035,8 @@ public class WbsSynchronousServiceImpl {
|
|
|
e.printStackTrace();
|
|
|
throw new ServiceException("重置表单路径错误");
|
|
|
}
|
|
|
-
|
|
|
- //新增-----------------------------------------------------------------------------------------------------------------
|
|
|
- Map<Long, List<WbsTreePrivate>> collect = addData.stream().collect(Collectors.groupingBy(WbsTreePrivate::getPId));
|
|
|
- Set<Long> longs = collect.keySet();
|
|
|
-
|
|
|
- List<Long> pIds = new ArrayList<>(longs);
|
|
|
- //按最小节点批量新增
|
|
|
- List<List<Long>> partition = Lists.partition(pIds, 100);
|
|
|
- int sum = 0;
|
|
|
- for (List<Long> data : partition) {
|
|
|
- for (Long pId : data) {
|
|
|
- List<WbsTreePrivate> list = collect.get(pId);
|
|
|
- //排序调整
|
|
|
- if (wbsTreeSynchronousRecord.getType().contains("7")) {
|
|
|
- list.sort(Comparator.comparingInt(WbsTreePrivate::getSort));
|
|
|
- //获取节点下的当前表单
|
|
|
- List<WbsTreePrivate> resourceData = wbsTreePrivateMapper.selectList(Wrappers.<WbsTreePrivate>lambdaQuery()
|
|
|
- .select(WbsTreePrivate::getPKeyId, WbsTreePrivate::getSort)
|
|
|
- .eq(WbsTreePrivate::getPId, pId)
|
|
|
- .eq(WbsTreePrivate::getIsDeleted, 0)
|
|
|
- .orderByAsc(WbsTreePrivate::getSort));
|
|
|
- if (CollectionUtil.isNotEmpty(resourceData)) {
|
|
|
- for (int i = 0; i < resourceData.size(); i++) {
|
|
|
- resourceData.get(i).setSort(i + 1);
|
|
|
- }
|
|
|
- //修改排序为连续排序
|
|
|
- wbsTreePrivateMapper.updateSortBatchByPKeyId(resourceData);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- for (WbsTreePrivate wbsTreePrivate : list) {
|
|
|
- wbsTreePrivateMapper.updateSortByPId(pId, wbsTreePrivate.getSort());
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- //单个批次一个事务,只会回滚当前批次数据
|
|
|
- Integer i = wbsTreePrivateMapper.insertBatchSomeColumn(list);
|
|
|
- //如果失败 -- - - - - 继续执行 或者把当前节点的p_key_id 记录到某个地方 方便后续处理
|
|
|
- if (i == 0) {
|
|
|
- List<Long> collect1 = addData.stream().map(WbsTreePrivate::getPKeyId).collect(Collectors.toList());
|
|
|
- //这里可以保存到数据库指定错误日志表
|
|
|
- throw new ServiceException("添加失败:" + StringUtil.join(collect1, ","));
|
|
|
- } else {
|
|
|
- //排序调整-连续排序
|
|
|
- if (wbsTreeSynchronousRecord.getType().contains("7")) {
|
|
|
- //获取节点下的当前表单
|
|
|
- List<WbsTreePrivate> resourceData = wbsTreePrivateMapper.selectList(Wrappers.<WbsTreePrivate>lambdaQuery()
|
|
|
- .select(WbsTreePrivate::getPKeyId, WbsTreePrivate::getSort)
|
|
|
- .eq(WbsTreePrivate::getPId, pId)
|
|
|
- .eq(WbsTreePrivate::getIsDeleted, 0)
|
|
|
- .orderByAsc(WbsTreePrivate::getSort));
|
|
|
- if (CollectionUtil.isNotEmpty(resourceData)) {
|
|
|
- for (int j = 0; j < resourceData.size(); j++) {
|
|
|
- resourceData.get(j).setSort(j + 1);
|
|
|
- }
|
|
|
- //修改排序为连续排序
|
|
|
- wbsTreePrivateMapper.updateSortBatchByPKeyId(resourceData);
|
|
|
- }
|
|
|
- }
|
|
|
- synchronousRecordMapper.update(null, Wrappers.<WbsTreeSynchronousRecord>lambdaUpdate()
|
|
|
- .set(WbsTreeSynchronousRecord::getNodeNumEnd, sum++)
|
|
|
- .set(WbsTreeSynchronousRecord::getUpdateTime, DateTime.now())
|
|
|
- .eq(WbsTreeSynchronousRecord::getId, wbsTreeSynchronousRecord.getId()));
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
}
|
|
|
+ return addData;
|
|
|
}
|
|
|
|
|
|
/**
|