Commit 499884ff authored by huangjie's avatar huangjie

Merge branch 'V20231129-中建一局二公司' of http://192.168.60.201/root/dsk-operate-sys...

Merge branch 'V20231129-中建一局二公司' of http://192.168.60.201/root/dsk-operate-sys into V20231129-中建一局二公司
parents 8096c3eb 2f5dc459
......@@ -49,39 +49,42 @@ public class DataAnalysisComponent {
*/
@Async
public void quantitySummaryDataAnalysis(CbProjectBaseBo bo) throws Exception {
//查询工料汇总导入文件
List<CbProjectFile> fileList = projectFileService.selectAnalysisList(bo.getProjectId(), CbProjectConstants.CB_TYPE_QUANTITY_SUMMARY, bo.getCbStage());
if (ObjectUtils.isEmpty(fileList)) return;
//文件处理
for (CbProjectFile file : fileList) {
//文件下载
InputStream inputStream = ossService.downFileIO(file.getFileOssId());
if (ObjectUtil.isNull(inputStream)) {
file.setFileParseStatus(3);
file.setFailRemark("文件数据不存在");
projectFileService.updateById(file);
break;
}
//解析数据
List<CbQuantitySummary> importList = new ExcelUtils<>(CbQuantitySummary.class).importExcelAllSheet(inputStream, 1);
if (importList.isEmpty()) {
file.setFileParseStatus(3);
file.setFailRemark("表格中不存在待导入数据!");
projectFileService.updateById(file);
break;
}
List<CbQuantitySummary> quantitySummaryList = importList.stream().parallel()
.filter(item -> !ObjectUtils.isEmpty(item.getCbName()))
.peek(item -> {
item.setProjectId(bo.getProjectId());
item.setCbStage(bo.getCbStage());
item.setCbProjectFileId(file.getId());
}).collect(Collectors.toList());
if (quantitySummaryList.isEmpty()) {
throw new ServiceException("表格中不存在有效数据!");
}
transactionTemplate.execute(status -> {
try {
try {
//文件下载
InputStream inputStream = ossService.downFileIO(file.getFileOssId());
if (ObjectUtil.isNull(inputStream)) {
file.setFileParseStatus(3);
file.setFailRemark("文件数据不存在");
projectFileService.updateById(file);
break;
}
//解析数据
List<CbQuantitySummary> importList = new ExcelUtils<>(CbQuantitySummary.class).importExcelAllSheet(inputStream, 1);
if (importList.isEmpty()) {
file.setFileParseStatus(3);
file.setFailRemark("表格中不存在待导入数据!");
projectFileService.updateById(file);
break;
}
List<CbQuantitySummary> quantitySummaryList = importList.stream().parallel()
.filter(item -> !ObjectUtils.isEmpty(item.getCbName()))
.peek(item -> {
item.setProjectId(bo.getProjectId());
item.setCbStage(bo.getCbStage());
item.setCbProjectFileId(file.getId());
}).collect(Collectors.toList());
if (quantitySummaryList.isEmpty()) {
throw new ServiceException("表格中不存在有效数据!");
}
transactionTemplate.execute(status -> {
try {
// //分批次插入
// if (quantitySummaryList.size() > 1000) {
// int index = 0;
......@@ -100,23 +103,29 @@ public class DataAnalysisComponent {
// throw new ServiceException("数据插入失败!");
// }
// }
boolean a = quantitySummaryService.batchInsert(quantitySummaryList);
if (!a) {
throw new ServiceException("数据插入失败!");
}
file.setFileParseStatus(2);
boolean b = projectFileService.updateById(file);
if (!b) {
throw new ServiceException("文件状态更新失败!");
boolean a = quantitySummaryService.batchInsert(quantitySummaryList);
if (!a) {
throw new ServiceException("数据插入失败!");
}
file.setFileParseStatus(2);
boolean b = projectFileService.updateById(file);
if (!b) {
throw new ServiceException("文件状态更新失败!");
}
} catch (Exception e) {
status.setRollbackOnly();
file.setFileParseStatus(3);
file.setFailRemark(e.getMessage());
projectFileService.updateById(file);
}
} catch (Exception e) {
status.setRollbackOnly();
file.setFileParseStatus(3);
file.setFailRemark(e.getMessage());
projectFileService.updateById(file);
}
return Boolean.TRUE;
});
return Boolean.TRUE;
});
} catch (Exception e) {
file.setFileParseStatus(3);
file.setFailRemark(e.getMessage());
projectFileService.updateById(file);
}
}
}
}
......@@ -87,7 +87,7 @@ public class CbSummaryProjectImportListener extends AnalysisEventListener<CbSumm
//判断上一条数据level是否与当前一致或为上一级
Optional<CbSummaryProjectImportVo> max = resultList.stream().max(Comparator.comparing(CbSummaryProjectImportVo::getSort));
CbSummaryProjectImportVo preImportVo = null;
if (!max.isPresent()) {
if (max.isPresent()) {
preImportVo = max.get();
} else {
throw new ServiceException("'序号'列数据错误,无法匹配层级!");
......
......@@ -22,6 +22,7 @@ import com.dsk.cscec.domain.vo.CbProjectOtherImportVo;
import com.dsk.cscec.domain.vo.CbProjectOtherVo;
import com.dsk.cscec.listener.CbProjectExpenseSummaryImportListener;
import com.dsk.cscec.listener.CbProjectOtherImportListener;
import com.dsk.cscec.mapper.CbProjectFileMapper;
import com.dsk.cscec.mapper.CbProjectOtherMapper;
import com.dsk.cscec.service.*;
import com.dsk.system.service.ISysOssService;
......@@ -54,6 +55,8 @@ public class CbProjectOtherServiceImpl extends ServiceImpl<CbProjectOtherMapper,
private ISysOssService ossService;
@Resource
private CbProjectExpenseSummaryService projectExpenseSummaryService;
@Resource
private CbProjectFileMapper projectFileMapper;
@SneakyThrows
@Override
......@@ -164,11 +167,7 @@ public class CbProjectOtherServiceImpl extends ServiceImpl<CbProjectOtherMapper,
Integer cbStage = baseBo.getCbStage();
Assert.notNull(projectId, "项目信息不能为空");
// 查询其他费用导入文件
List<CbProjectFile> projectFileList = projectFileService.list(Wrappers.<CbProjectFile>lambdaQuery()
.eq(CbProjectFile::getProjectId, baseBo.getProjectId())
.eq(CbProjectFile::getCbType, CbProjectConstants.CB_TYPE_SCENE_EXPENSE)
.eq(CbProjectFile::getCbStage, baseBo.getCbStage())
.in(CbProjectFile::getFileParseStatus, Arrays.asList(0)));
List<CbProjectFile> projectFileList = projectFileMapper.selectAnalysisList(projectId, CbProjectConstants.CB_TYPE_OTHER_PROJECT, cbStage);
if (ObjectUtils.isEmpty(projectFileList)) {
return;
}
......@@ -196,7 +195,6 @@ public class CbProjectOtherServiceImpl extends ServiceImpl<CbProjectOtherMapper,
//解析数据
ExcelResult<CbProjectOtherImportVo> importVoExcelResult =
ExcelUtil.importExcel(inputStream, CbProjectOtherImportVo.class,new CbProjectOtherImportListener(projectId, fileId));
log.info(importVoExcelResult.getAnalysis());
List<CbProjectOtherImportVo> importVoList = importVoExcelResult.getList();
if (CollectionUtil.isEmpty(importVoList)) {
//解析失败
......@@ -262,7 +260,6 @@ public class CbProjectOtherServiceImpl extends ServiceImpl<CbProjectOtherMapper,
//解析数据
ExcelResult<CbProjectExpenseSummaryImportVo> importVoExcelResult =
ExcelUtil.importExcel(inputStream, CbProjectExpenseSummaryImportVo.class,new CbProjectExpenseSummaryImportListener(projectId, cbStage));
log.info(importVoExcelResult.getAnalysis());
List<CbProjectExpenseSummaryImportVo> importVoList = importVoExcelResult.getList();
if (CollectionUtil.isEmpty(importVoList)) {
//解析失败
......
......@@ -17,12 +17,11 @@
id, project_id, cb_stage, cb_type, file_name, file_oss_id, file_oss_url, file_parse_status, fail_remark,
del_flag, create_by, create_time, update_by, update_time
FROM cb_project_file
WHERE (del_flag = 0 and file_parse_status = 1
and project_id=#{projectId}
WHERE del_flag = 0 and file_parse_status in (1,3) and project_id=#{projectId}
<if test="cbStage != null">
and cb_stage =#{cbStage}
</if>
and cb_type = #{cbType})
and cb_type = #{cbType}
</select>
<update id="removeById">
......
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