Commit 10cbbca3 authored by chenyuefang's avatar chenyuefang

update

parent a9e080ae
...@@ -96,11 +96,12 @@ public class CbSummaryServiceImpl extends ServiceImpl<CbSummaryMapper, CbSummary ...@@ -96,11 +96,12 @@ public class CbSummaryServiceImpl extends ServiceImpl<CbSummaryMapper, CbSummary
cbProjectFile.setFileParseStatus(CbProjectConstants.PROJECT_FILE_STATUS_PARSE_FAIL); cbProjectFile.setFileParseStatus(CbProjectConstants.PROJECT_FILE_STATUS_PARSE_FAIL);
cbProjectFile.setFailRemark(e.getMessage()); cbProjectFile.setFailRemark(e.getMessage());
cbProjectFileMapper.updateById(cbProjectFile); cbProjectFileMapper.updateById(cbProjectFile);
log.error(projectId+"项目 成本汇总解析失败" + e);
} }
// } // }
}); });
log.info(projectId+"项目 成本汇总解析成功");
} }
/** /**
...@@ -132,11 +133,19 @@ public class CbSummaryServiceImpl extends ServiceImpl<CbSummaryMapper, CbSummary ...@@ -132,11 +133,19 @@ public class CbSummaryServiceImpl extends ServiceImpl<CbSummaryMapper, CbSummary
transactionTemplate.execute(status -> { transactionTemplate.execute(status -> {
try { try {
boolean flag = this.saveBatch(addList); //分批次插入
if (!flag) { if (addList.size() > 1000) {
throw new ServiceException("导入数据失败"); int index = 0;
int total = addList.size();
while (index < total) {
List<CbSummary> divideList = addList.subList(index, Math.min(index += 1000, total));
Assert.isTrue(this.saveBatch(divideList), "数据插入失败");
}
} else {
Assert.isTrue(this.saveBatch(addList), "数据插入失败");
} }
//处理父级id //处理父级id
List<CbSummary> cbSummaryList = baseMapper.selectList( List<CbSummary> cbSummaryList = baseMapper.selectList(
new LambdaQueryWrapper<CbSummary>() new LambdaQueryWrapper<CbSummary>()
...@@ -161,17 +170,22 @@ public class CbSummaryServiceImpl extends ServiceImpl<CbSummaryMapper, CbSummary ...@@ -161,17 +170,22 @@ public class CbSummaryServiceImpl extends ServiceImpl<CbSummaryMapper, CbSummary
} }
cbSummary.setParentId(parent.getId()); cbSummary.setParentId(parent.getId());
} }
//分批次修改
flag = this.updateBatchById(cbSummaryList); if (cbSummaryList.size() > 1000) {
if (!flag) { int index = 0;
throw new ServiceException("更新数据失败"); int total = cbSummaryList.size();
while (index < total) {
List<CbSummary> divideList = cbSummaryList.subList(index, Math.min(index += 1000, total));
Assert.isTrue(this.updateBatchById(divideList), "更新数据失败");
}
} else {
Assert.isTrue(this.updateBatchById(cbSummaryList), "更新数据失败");
} }
//修改文件状态为解析成功 //修改文件状态为解析成功
file.setFileParseStatus(CbProjectConstants.PROJECT_FILE_STATUS_PARSE_SUCCESS); file.setFileParseStatus(CbProjectConstants.PROJECT_FILE_STATUS_PARSE_SUCCESS);
flag = cbProjectFileMapper.updateById(file) > 0; Assert.isTrue(cbProjectFileMapper.updateById(file) > 0, "更新文件状态失败");
if (!flag) {
throw new ServiceException("更新文件状态失败");
}
} catch (Exception e) { } catch (Exception e) {
status.setRollbackOnly(); status.setRollbackOnly();
throw e; throw e;
...@@ -211,11 +225,19 @@ public class CbSummaryServiceImpl extends ServiceImpl<CbSummaryMapper, CbSummary ...@@ -211,11 +225,19 @@ public class CbSummaryServiceImpl extends ServiceImpl<CbSummaryMapper, CbSummary
transactionTemplate.execute(status -> { transactionTemplate.execute(status -> {
try { try {
boolean flag = this.saveBatch(addList); //分批次插入
if (!flag) { if (addList.size() > 1000) {
throw new ServiceException("导入数据失败"); int index = 0;
int total = addList.size();
while (index < total) {
List<CbSummary> divideList = addList.subList(index, Math.min(index += 1000, total));
Assert.isTrue(this.saveBatch(divideList), "数据插入失败");
}
} else {
Assert.isTrue(this.saveBatch(addList), "数据插入失败");
} }
//处理父级id //处理父级id
List<CbSummary> cbSummaryList = baseMapper.selectList( List<CbSummary> cbSummaryList = baseMapper.selectList(
new LambdaQueryWrapper<CbSummary>() new LambdaQueryWrapper<CbSummary>()
...@@ -249,14 +271,21 @@ public class CbSummaryServiceImpl extends ServiceImpl<CbSummaryMapper, CbSummary ...@@ -249,14 +271,21 @@ public class CbSummaryServiceImpl extends ServiceImpl<CbSummaryMapper, CbSummary
} }
cbSummary.setParentId(parent.getId()); cbSummary.setParentId(parent.getId());
} }
//分批次修改
this.updateBatchById(cbSummaryList); if (cbSummaryList.size() > 1000) {
int index = 0;
int total = cbSummaryList.size();
while (index < total) {
List<CbSummary> divideList = cbSummaryList.subList(index, Math.min(index += 1000, total));
Assert.isTrue(this.updateBatchById(divideList), "更新数据失败");
}
} else {
Assert.isTrue(this.updateBatchById(cbSummaryList), "更新数据失败");
}
//修改文件状态为解析成功 //修改文件状态为解析成功
file.setFileParseStatus(CbProjectConstants.PROJECT_FILE_STATUS_PARSE_SUCCESS); file.setFileParseStatus(CbProjectConstants.PROJECT_FILE_STATUS_PARSE_SUCCESS);
flag = cbProjectFileMapper.updateById(file) > 0; Assert.isTrue(cbProjectFileMapper.updateById(file) > 0, "更新文件状态失败");
if (!flag) {
throw new ServiceException("更新文件状态失败");
}
} catch (Exception e) { } catch (Exception e) {
status.setRollbackOnly(); status.setRollbackOnly();
throw e; throw e;
...@@ -307,7 +336,7 @@ public class CbSummaryServiceImpl extends ServiceImpl<CbSummaryMapper, CbSummary ...@@ -307,7 +336,7 @@ public class CbSummaryServiceImpl extends ServiceImpl<CbSummaryMapper, CbSummary
List<CbSummaryActualListVo> childrenList = baseMapper.getByParentId(bo.getId(), bo.getExpenseDate()); List<CbSummaryActualListVo> childrenList = baseMapper.getByParentId(bo.getId(), bo.getExpenseDate());
//截至本月费用汇总 //截至本月费用汇总
childrenList.forEach(children -> { childrenList.parallelStream().forEach(children -> {
Map<String, BigDecimal> total = cbSummaryActualMapper.getTotal(children.getId(), bo.getExpenseDate()); Map<String, BigDecimal> total = cbSummaryActualMapper.getTotal(children.getId(), bo.getExpenseDate());
children.setTaxExclusiveExpenseTotal(total.get("taxExclusiveExpenseTotal")); children.setTaxExclusiveExpenseTotal(total.get("taxExclusiveExpenseTotal"));
children.setTaxInclusiveExpenseTotal(total.get("taxInclusiveExpenseTotal")); children.setTaxInclusiveExpenseTotal(total.get("taxInclusiveExpenseTotal"));
...@@ -330,7 +359,7 @@ public class CbSummaryServiceImpl extends ServiceImpl<CbSummaryMapper, CbSummary ...@@ -330,7 +359,7 @@ public class CbSummaryServiceImpl extends ServiceImpl<CbSummaryMapper, CbSummary
} else { } else {
// //递归列表 // //递归列表
// childrenList = getProjectSumList(bo); // childrenList = getProjectSumList(bo);
childrenList.forEach(child->{ childrenList.parallelStream().forEach(child->{
Long count = baseMapper.selectCount(new LambdaQueryWrapper<CbSummary>().eq(CbSummary::getParentId,child.getId())); Long count = baseMapper.selectCount(new LambdaQueryWrapper<CbSummary>().eq(CbSummary::getParentId,child.getId()));
if(count>0l){ if(count>0l){
child.setHasChildren(1); child.setHasChildren(1);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment