|
@@ -597,6 +597,7 @@ public class WbsSynchronousServiceImpl {
|
|
|
//获取当前项目所有合同---------------------------------------------------------------------------------------------------
|
|
|
List<ContractInfo> contractInfos = contractInfoMapper.selectContractIdByProjectId(String.valueOf(wbsTreeSynchronousRecord.getProjectId()));
|
|
|
|
|
|
+ List<WbsTreeContract> addData = new ArrayList<>();
|
|
|
List<WbsTreeContract> editData = new ArrayList<>();
|
|
|
List<WbsTreeContract> oldHtml = new ArrayList<>();
|
|
|
StringBuilder errorMsg = new StringBuilder("");
|
|
@@ -812,7 +813,7 @@ public class WbsSynchronousServiceImpl {
|
|
|
switch (i) {
|
|
|
//添加表单
|
|
|
case 1:
|
|
|
- insertContractForm(wbsTreeSynchronousRecord, contractInfo, wbsTreeContracts, addContractNode);
|
|
|
+ addData.addAll(insertContractForm(wbsTreeSynchronousRecord, contractInfo, wbsTreeContracts, addContractNode));
|
|
|
//如果同时选择新增表单和其他的同步类型 在操作其他类型的时候需要添加新的表单
|
|
|
// if (CollectionUtil.isNotEmpty(addContractNode)) {
|
|
|
// editContractNodes.addAll(addContractNode.stream().filter(f -> f.getType() == 2).collect(Collectors.toList()));
|
|
@@ -837,20 +838,38 @@ public class WbsSynchronousServiceImpl {
|
|
|
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- //合同段同步同时记录数量
|
|
|
+ Set<Long> pIdsNew = new HashSet<>();
|
|
|
+ //新增数据
|
|
|
+ Map<Long, List<WbsTreeContract>> collect2 = addData.stream().collect(Collectors.groupingBy(WbsTreeContract::getPId));
|
|
|
+ if(CollectionUtil.isNotEmpty(addData)){
|
|
|
+ pIdsNew.addAll(collect2.keySet());
|
|
|
+ }
|
|
|
+ //修改数据
|
|
|
Map<Long, List<WbsTreeContract>> collect1 = editData.stream().collect(Collectors.groupingBy(WbsTreeContract::getPId));
|
|
|
- Set<Long> pIds = collect1.keySet();
|
|
|
+ if(CollectionUtil.isNotEmpty(editData)){
|
|
|
+ pIdsNew.addAll(collect1.keySet());
|
|
|
+ }
|
|
|
+ //计数 同步节点数量 按最小节点统计
|
|
|
Integer nodeNumEnd = 0;
|
|
|
|
|
|
- Map<Long, List<WbsTreeContract>> collect2 = oldHtml.stream().collect(Collectors.groupingBy(WbsTreeContract::getPId));
|
|
|
+ //需要记录历史html的表单
|
|
|
+ Map<Long, List<WbsTreeContract>> collect3 = oldHtml.stream().collect(Collectors.groupingBy(WbsTreeContract::getPId));
|
|
|
|
|
|
- for (Long pId : pIds) {
|
|
|
+ for (Long pId : pIdsNew) {
|
|
|
nodeNumEnd++;
|
|
|
- List<WbsTreeContract> list = collect1.get(pId);
|
|
|
- List<WbsTreeContract> oldHtmlPId = collect2.get(pId);
|
|
|
|
|
|
- wbsSynchronousEViSaService.updateContract(wbsTreeSynchronousRecord.getType(), pId, wbsTreeSynchronousRecord.getCreateUserId(), list, oldHtmlPId);
|
|
|
+ //新增数据
|
|
|
+ List<WbsTreeContract> addContractNode = collect2.get(pId);
|
|
|
+ if(CollectionUtil.isNotEmpty(addContractNode)){
|
|
|
+ wbsSynchronousEViSaService.insertContractForm(wbsTreeSynchronousRecord, addContractNode ,pId);
|
|
|
+ }
|
|
|
+
|
|
|
+ List<WbsTreeContract> list = collect1.get(pId);
|
|
|
+ if(CollectionUtil.isNotEmpty(list)){
|
|
|
+ //历史html 只会在更新数据的时候取记录
|
|
|
+ List<WbsTreeContract> oldHtmlPId = collect3.get(pId);
|
|
|
+ wbsSynchronousEViSaService.updateContract(wbsTreeSynchronousRecord.getType(), pId, wbsTreeSynchronousRecord.getCreateUserId(), list, oldHtmlPId);
|
|
|
+ }
|
|
|
synchronousRecordMapper.update(null, Wrappers.<WbsTreeSynchronousRecord>lambdaUpdate()
|
|
|
.set(WbsTreeSynchronousRecord::getNodeNumEnd, nodeNumEnd)
|
|
|
.set(WbsTreeSynchronousRecord::getUpdateTime, DateTime.now())
|
|
@@ -1043,7 +1062,7 @@ public class WbsSynchronousServiceImpl {
|
|
|
* @param wbsTreeContracts 当前合同节点数据
|
|
|
* @param addContractNodes 新增节点数据
|
|
|
*/
|
|
|
- public void insertContractForm(WbsTreeSynchronousRecord wbsTreeSynchronousRecord, ContractInfo contractInfo, List<WbsTreeContract> wbsTreeContracts, List<WbsTreeContract> addContractNodes) {
|
|
|
+ public List<WbsTreeContract> insertContractForm(WbsTreeSynchronousRecord wbsTreeSynchronousRecord, ContractInfo contractInfo, List<WbsTreeContract> wbsTreeContracts, List<WbsTreeContract> addContractNodes) {
|
|
|
List<WbsTreeContract> addData = new ArrayList<>();
|
|
|
|
|
|
|
|
@@ -1093,91 +1112,7 @@ public class WbsSynchronousServiceImpl {
|
|
|
}
|
|
|
addData.addAll(addContractNodes);
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
- //查询出当前项目所有节点---------------------------------------------------------------------------------------------------
|
|
|
-// 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);
|
|
|
-// });
|
|
|
-
|
|
|
- //新增-----------------------------------------------------------------------------------------------------------------
|
|
|
- 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 pId : data) {
|
|
|
- List<WbsTreeContract> list = collect.get(pId);
|
|
|
- //排序调整
|
|
|
- if (wbsTreeSynchronousRecord.getType().contains("7")) {
|
|
|
- list.sort(Comparator.comparingInt(WbsTreeContract::getSort));
|
|
|
- //获取节点下的当前表单
|
|
|
- List<WbsTreeContract> resourceData = wbsTreeContractMapper.selectList(Wrappers.<WbsTreeContract>lambdaQuery()
|
|
|
- .select(WbsTreeContract::getPKeyId, WbsTreeContract::getSort)
|
|
|
- .eq(WbsTreeContract::getPId, pId)
|
|
|
- .eq(WbsTreeContract::getIsDeleted, 0)
|
|
|
- .orderByAsc(WbsTreeContract::getSort));
|
|
|
- if (CollectionUtil.isNotEmpty(resourceData)) {
|
|
|
- for (int i = 0; i < resourceData.size(); i++) {
|
|
|
- resourceData.get(i).setSort(i + 1);
|
|
|
- }
|
|
|
- //修改排序为连续排序
|
|
|
- wbsTreeContractMapper.updateSortBatchByPKeyId(resourceData);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- for (WbsTreeContract wbsTreePrivate : list) {
|
|
|
- wbsTreeContractMapper.updateSortByPId(pId, wbsTreePrivate.getSort());
|
|
|
- }
|
|
|
- }
|
|
|
- boolean b = saveData.addAll(list);
|
|
|
-
|
|
|
-
|
|
|
- //单个批次一个事务,只会回滚当前批次数据
|
|
|
- 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, ","));
|
|
|
- } else {
|
|
|
- //排序调整
|
|
|
- if (wbsTreeSynchronousRecord.getType().contains("7")) {
|
|
|
- //获取节点下的当前表单
|
|
|
- List<WbsTreeContract> resourceData = wbsTreeContractMapper.selectList(Wrappers.<WbsTreeContract>lambdaQuery()
|
|
|
- .select(WbsTreeContract::getPKeyId, WbsTreeContract::getSort)
|
|
|
- .eq(WbsTreeContract::getPId, pId)
|
|
|
- .eq(WbsTreeContract::getIsDeleted, 0)
|
|
|
- .orderByAsc(WbsTreeContract::getSort));
|
|
|
- if (CollectionUtil.isNotEmpty(resourceData)) {
|
|
|
- for (int j = 0; i < resourceData.size(); j++) {
|
|
|
- resourceData.get(j).setSort(j + 1);
|
|
|
- }
|
|
|
- //修改排序为连续排序
|
|
|
- wbsTreeContractMapper.updateSortBatchByPKeyId(resourceData);
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ return addData;
|
|
|
}
|
|
|
|
|
|
|