Commit d0051f1b authored by chenyuefang's avatar chenyuefang

成本汇总导入修改

parent 7d0f01ac
...@@ -134,7 +134,7 @@ public class CbSummaryController extends BaseController { ...@@ -134,7 +134,7 @@ public class CbSummaryController extends BaseController {
*/ */
@PostMapping("/analysisData") @PostMapping("/analysisData")
public void analysisData(Long projectId){ public void analysisData(Long projectId){
cbSummaryService.importCbProject(projectId); cbSummaryService.importCbSummary(projectId);
} }
} }
...@@ -53,6 +53,12 @@ public class CbSummaryCostAccountImportListener extends AnalysisEventListener<Cb ...@@ -53,6 +53,12 @@ public class CbSummaryCostAccountImportListener extends AnalysisEventListener<Cb
failureMsg.append("<br/>").append("第" + sort + "条数据序号为空"); failureMsg.append("<br/>").append("第" + sort + "条数据序号为空");
return; return;
} }
//成本科目不能为空
if (StringUtil.isBlank(importVo.getCbName())) {
failureNum++;
failureMsg.append("<br/>").append("第" + sort + "条数据成本科目为空");
return;
}
//父级数据处理 //父级数据处理
if (sort == 1) { if (sort == 1) {
...@@ -74,7 +80,7 @@ public class CbSummaryCostAccountImportListener extends AnalysisEventListener<Cb ...@@ -74,7 +80,7 @@ public class CbSummaryCostAccountImportListener extends AnalysisEventListener<Cb
@Override @Override
public String getAnalysis() { public String getAnalysis() {
if (failureNum > 0) { if (failureNum > 0) {
failureMsg.insert(0, "失败原因:共 " + failureNum + " 条数据格式不正确,错误如下:"); failureMsg.insert(0, "共 " + failureNum + " 条数据格式不正确,错误如下:");
throw new ServiceException(failureMsg.toString()); throw new ServiceException(failureMsg.toString());
} else { } else {
successMsg.insert(0, "成本科目汇总数据已全部解析成功!共 " + getList().size() + " 条"); successMsg.insert(0, "成本科目汇总数据已全部解析成功!共 " + getList().size() + " 条");
......
package com.dsk.cscec.listener; package com.dsk.cscec.listener;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.excel.context.AnalysisContext; import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener; import com.alibaba.excel.event.AnalysisEventListener;
import com.dsk.common.excel.ExcelListener; import com.dsk.common.excel.ExcelListener;
...@@ -42,8 +43,12 @@ public class CbSummaryProjectImportListener extends AnalysisEventListener<CbSumm ...@@ -42,8 +43,12 @@ public class CbSummaryProjectImportListener extends AnalysisEventListener<CbSumm
@Override @Override
public void invoke(CbSummaryProjectImportVo importVo, AnalysisContext context) { public void invoke(CbSummaryProjectImportVo importVo, AnalysisContext context) {
//第一个序号不能为空? todo //名称不能为空
if (StringUtil.isBlank(importVo.getCbName())) {
failureNum++;
failureMsg.append("<br/>").append("第" + sort + "条数据名称为空");
return;
}
//添加父级数据 //添加父级数据
if (sort == 0) { if (sort == 0) {
CbSummaryProjectImportVo firstVo = new CbSummaryProjectImportVo(); CbSummaryProjectImportVo firstVo = new CbSummaryProjectImportVo();
...@@ -63,8 +68,12 @@ public class CbSummaryProjectImportListener extends AnalysisEventListener<CbSumm ...@@ -63,8 +68,12 @@ public class CbSummaryProjectImportListener extends AnalysisEventListener<CbSumm
//按sort倒序取number不为空的最大level //按sort倒序取number不为空的最大level
Object[] objects = resultList.stream().sorted(Comparator.comparingInt(CbSummaryProjectImportVo::getSort).reversed()) Object[] objects = resultList.stream().sorted(Comparator.comparingInt(CbSummaryProjectImportVo::getSort).reversed())
.filter(vo -> StringUtil.isNotBlank(vo.getNumber())).limit(1).map(CbSummaryProjectImportVo::getLevel).toArray(); .filter(vo -> StringUtil.isNotBlank(vo.getNumber())).limit(1).map(CbSummaryProjectImportVo::getLevel).toArray();
//数据序号错误 todo //数据序号错误
if (ObjectUtil.isEmpty(objects)) {
failureNum++;
failureMsg.append("<br/>").append("第" + sort + "条数据序号错误");
return;
}
Integer lastLevel = (Integer) objects[0]; Integer lastLevel = (Integer) objects[0];
importVo.setLevel(lastLevel + 1); importVo.setLevel(lastLevel + 1);
...@@ -75,8 +84,6 @@ public class CbSummaryProjectImportListener extends AnalysisEventListener<CbSumm ...@@ -75,8 +84,6 @@ public class CbSummaryProjectImportListener extends AnalysisEventListener<CbSumm
} }
// failureNum++;
// failureMsg.append("<br/>").append(failureNum);
resultList.add(importVo); resultList.add(importVo);
} }
...@@ -93,7 +100,7 @@ public class CbSummaryProjectImportListener extends AnalysisEventListener<CbSumm ...@@ -93,7 +100,7 @@ public class CbSummaryProjectImportListener extends AnalysisEventListener<CbSumm
@Override @Override
public String getAnalysis() { public String getAnalysis() {
if (failureNum > 0) { if (failureNum > 0) {
failureMsg.insert(0, "失败原因:共 " + failureNum + " 条数据格式不正确,错误如下:"); failureMsg.insert(0, "共 " + failureNum + " 条数据格式不正确,错误如下:");
throw new ServiceException(failureMsg.toString()); throw new ServiceException(failureMsg.toString());
} else { } else {
successMsg.insert(0, "项目汇总数据已全部解析成功!共 " + getList().size() + " 条"); successMsg.insert(0, "项目汇总数据已全部解析成功!共 " + getList().size() + " 条");
......
...@@ -16,5 +16,6 @@ public interface CbProjectFileMapper extends BaseMapper<CbProjectFile> { ...@@ -16,5 +16,6 @@ public interface CbProjectFileMapper extends BaseMapper<CbProjectFile> {
List<CbProjectFile> selectAnalysisList(@Param("projectId") Long projectId,@Param("cbType") Integer cbType,@Param("cbStage") Integer cbStage); List<CbProjectFile> selectAnalysisList(@Param("projectId") Long projectId,@Param("cbType") Integer cbType,@Param("cbStage") Integer cbStage);
int removeById(@Param("id") Long id);
} }
...@@ -2,7 +2,6 @@ package com.dsk.cscec.service; ...@@ -2,7 +2,6 @@ package com.dsk.cscec.service;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.dsk.common.core.domain.R; import com.dsk.common.core.domain.R;
import com.dsk.cscec.domain.CbProjectFile;
import com.dsk.cscec.domain.CbSummary; import com.dsk.cscec.domain.CbSummary;
import com.dsk.cscec.domain.bo.CbSummaryActualBo; import com.dsk.cscec.domain.bo.CbSummaryActualBo;
import com.dsk.cscec.domain.bo.CbSummaryActualListBo; import com.dsk.cscec.domain.bo.CbSummaryActualListBo;
...@@ -26,7 +25,7 @@ public interface CbSummaryService extends IService<CbSummary> { ...@@ -26,7 +25,7 @@ public interface CbSummaryService extends IService<CbSummary> {
* 项目汇总导入 * 项目汇总导入
* @param projectId * @param projectId
*/ */
void importCbProject(Long projectId); void importCbSummary(Long projectId);
/** /**
* 获取一级名称/成本科目列表 * 获取一级名称/成本科目列表
......
...@@ -7,6 +7,14 @@ ...@@ -7,6 +7,14 @@
del_flag, create_by, create_time, update_by, update_time del_flag, create_by, create_time, update_by, update_time
FROM cb_project_file FROM cb_project_file
WHERE ((del_flag = 0 and file_parse_status in (1,3)) or del_flag = 1) WHERE ((del_flag = 0 and file_parse_status in (1,3)) or del_flag = 1)
and project_id=#{projectId} and cb_stage =#{cbStage} and cb_type = #{cbType} and project_id=#{projectId}
<if test="cbStage != null">
and cb_stage =#{cbStage}
</if>
and cb_type = #{cbType}
</select> </select>
<update id="removeById">
UPDATE cb_project_file SET del_flag=2 WHERE id=#{id}
</update>
</mapper> </mapper>
\ No newline at end of file
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