Commit 10cbbca3 authored by chenyuefang's avatar chenyuefang

update

parent a9e080ae
......@@ -96,11 +96,12 @@ public class CbSummaryServiceImpl extends ServiceImpl<CbSummaryMapper, CbSummary
cbProjectFile.setFileParseStatus(CbProjectConstants.PROJECT_FILE_STATUS_PARSE_FAIL);
cbProjectFile.setFailRemark(e.getMessage());
cbProjectFileMapper.updateById(cbProjectFile);
log.error(projectId+"项目 成本汇总解析失败" + e);
}
// }
});
log.info(projectId+"项目 成本汇总解析成功");
}
/**
......@@ -132,11 +133,19 @@ public class CbSummaryServiceImpl extends ServiceImpl<CbSummaryMapper, CbSummary
transactionTemplate.execute(status -> {
try {
boolean flag = this.saveBatch(addList);
if (!flag) {
throw new ServiceException("导入数据失败");
//分批次插入
if (addList.size() > 1000) {
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
List<CbSummary> cbSummaryList = baseMapper.selectList(
new LambdaQueryWrapper<CbSummary>()
......@@ -161,17 +170,22 @@ public class CbSummaryServiceImpl extends ServiceImpl<CbSummaryMapper, CbSummary
}
cbSummary.setParentId(parent.getId());
}
flag = this.updateBatchById(cbSummaryList);
if (!flag) {
throw new ServiceException("更新数据失败");
//分批次修改
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);
flag = cbProjectFileMapper.updateById(file) > 0;
if (!flag) {
throw new ServiceException("更新文件状态失败");
}
Assert.isTrue(cbProjectFileMapper.updateById(file) > 0, "更新文件状态失败");
} catch (Exception e) {
status.setRollbackOnly();
throw e;
......@@ -211,11 +225,19 @@ public class CbSummaryServiceImpl extends ServiceImpl<CbSummaryMapper, CbSummary
transactionTemplate.execute(status -> {
try {
boolean flag = this.saveBatch(addList);
if (!flag) {
throw new ServiceException("导入数据失败");
//分批次插入
if (addList.size() > 1000) {
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
List<CbSummary> cbSummaryList = baseMapper.selectList(
new LambdaQueryWrapper<CbSummary>()
......@@ -249,14 +271,21 @@ public class CbSummaryServiceImpl extends ServiceImpl<CbSummaryMapper, CbSummary
}
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);
flag = cbProjectFileMapper.updateById(file) > 0;
if (!flag) {
throw new ServiceException("更新文件状态失败");
}
Assert.isTrue(cbProjectFileMapper.updateById(file) > 0, "更新文件状态失败");
} catch (Exception e) {
status.setRollbackOnly();
throw e;
......@@ -307,7 +336,7 @@ public class CbSummaryServiceImpl extends ServiceImpl<CbSummaryMapper, CbSummary
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());
children.setTaxExclusiveExpenseTotal(total.get("taxExclusiveExpenseTotal"));
children.setTaxInclusiveExpenseTotal(total.get("taxInclusiveExpenseTotal"));
......@@ -330,7 +359,7 @@ public class CbSummaryServiceImpl extends ServiceImpl<CbSummaryMapper, CbSummary
} else {
// //递归列表
// childrenList = getProjectSumList(bo);
childrenList.forEach(child->{
childrenList.parallelStream().forEach(child->{
Long count = baseMapper.selectCount(new LambdaQueryWrapper<CbSummary>().eq(CbSummary::getParentId,child.getId()));
if(count>0l){
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