|
@@ -1,5 +1,8 @@
|
|
|
package com.jeeplus.modules.cg.reservemanagementcenter.reserveManage.service;
|
|
|
|
|
|
+import com.alibaba.excel.EasyExcel;
|
|
|
+import com.alibaba.excel.read.builder.ExcelReaderBuilder;
|
|
|
+import com.alibaba.excel.read.builder.ExcelReaderSheetBuilder;
|
|
|
import com.google.common.collect.Maps;
|
|
|
import com.jeeplus.common.utils.DateUtils;
|
|
|
import com.jeeplus.common.utils.StringUtils;
|
|
@@ -18,6 +21,7 @@ import com.jeeplus.modules.sg.managementcenter.materialinfo.util.MaterialInfoUti
|
|
|
import com.jeeplus.modules.sg.raiseCapitalDesign.entity.CableSectionData;
|
|
|
import com.jeeplus.modules.sg.raiseCapitalDesign.entity.CableSectionInfo;
|
|
|
import com.jeeplus.modules.sg.raiseCapitalDesign.service.RaiseCapitalDesignService;
|
|
|
+import com.jeeplus.modules.sys.listener.*;
|
|
|
import org.activiti.engine.TaskService;
|
|
|
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
|
|
|
import org.apache.poi.ss.usermodel.Row;
|
|
@@ -146,25 +150,54 @@ public class ReserveSummaryProcessService extends CrudService<ReserveSummaryProc
|
|
|
*/
|
|
|
@Transactional(readOnly = false)
|
|
|
public void saveData(MultipartFile file,String projectReserveId,String proName) throws IOException, InvalidFormatException {
|
|
|
- ImportExcel module = new ImportExcel(file,1,"模块表");
|
|
|
- Row row = module.getRow(0);
|
|
|
- Object obj = module.getCellValue(row, 1);
|
|
|
- if(obj==null){
|
|
|
- throw new RuntimeException("找不到项目名称!");
|
|
|
- }
|
|
|
-
|
|
|
- String projectName = ((String) obj).trim();
|
|
|
+// ImportExcel module = new ImportExcel(file,1,"模块表");
|
|
|
+// Row row = module.getRow(0);
|
|
|
+// Object obj = module.getCellValue(row, 1);
|
|
|
+// if(obj==null){
|
|
|
+// throw new RuntimeException("找不到项目名称!");
|
|
|
+// }
|
|
|
+
|
|
|
+ // 获取上传的MultipartFile文件
|
|
|
+ MultipartFile excelFile = file;
|
|
|
+ //使用EasyExcel创建ExcelReaderBuilder
|
|
|
+ ExcelReaderBuilder excelReaderBuilder = EasyExcel.read(excelFile.getInputStream());
|
|
|
+ excelReaderBuilder.headRowNumber(0); // 指定标题行的索引为0
|
|
|
+ // 获取第一个工作表(通常索引为0)的ExcelReaderSheetBuilder
|
|
|
+ ExcelReaderSheetBuilder sheetBuilder = excelReaderBuilder.sheet("模块表");
|
|
|
+ // 设置自定义的读取监听器,用于处理Excel数据
|
|
|
+ ExcelDataListener listener = new ExcelDataListener();
|
|
|
+ sheetBuilder.registerReadListener(listener);
|
|
|
+
|
|
|
+ // 启动读取操作
|
|
|
+ sheetBuilder.doRead();
|
|
|
+ // 读取到的项目名称
|
|
|
+ String projectName = listener.getProjectName();
|
|
|
if (!proName.equals(projectName)){
|
|
|
throw new RuntimeException("上传文件的项目名称与改流程的项目名称不匹配!");
|
|
|
}
|
|
|
+
|
|
|
//删除对应项目名称的甲供材信息
|
|
|
mapper.deleteMaterial(projectName);
|
|
|
//清空redis中的在线开甲供材信息
|
|
|
Jedis jedis = ReserveRedisUtils.getJedis();
|
|
|
jedis.del(projectReserveId);
|
|
|
|
|
|
- ImportExcel pick = new ImportExcel(file,7,"领料清单");
|
|
|
- List<MaterialInfo> materialInfos = MaterialInfoUtil.getCbData(pick,projectName); //获取领料清单数据
|
|
|
+ // 获取领料清单工作表
|
|
|
+ ExcelReaderBuilder materialReaderBuilder = EasyExcel.read(excelFile.getInputStream());
|
|
|
+ ExcelReaderSheetBuilder materialBuilder = materialReaderBuilder.sheet("领料清单");
|
|
|
+ ExcelMaterialInfoListener infoListener = new ExcelMaterialInfoListener();
|
|
|
+ materialBuilder.registerReadListener(infoListener);
|
|
|
+ // 启动读取操作
|
|
|
+ materialBuilder.doRead();
|
|
|
+ // 获取从第7行开始的B到J列的值
|
|
|
+ List<MaterialInfo> materialInfos = infoListener.getData();
|
|
|
+ materialInfos.forEach(ma->{
|
|
|
+ ma.setProjectName(projectName);
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
+// ImportExcel pick = new ImportExcel(file,7,"领料清单");
|
|
|
+// List<MaterialInfo> materialInfos = MaterialInfoUtil.getCbData(pick,projectName); //获取领料清单数据
|
|
|
List<MaterialInfo> materialInfoList = new ArrayList<>();
|
|
|
for (MaterialInfo materialInfo : materialInfos) {
|
|
|
if (materialInfo.getTotalCount()>0){
|
|
@@ -176,62 +209,95 @@ public class ReserveSummaryProcessService extends CrudService<ReserveSummaryProc
|
|
|
saveList(list);
|
|
|
//获取电缆分段表的数据,将数据存入到redis中
|
|
|
// ImportUtil importUtil = new ImportUtil(file, 0, 5);
|
|
|
- ImportExcel importUtil = new ImportExcel(file,3,"电缆分段表");
|
|
|
- int lastRow = importUtil.getLastDataRowNum();
|
|
|
- //获取指定的列数据 YJV22-3×400mm²单元格下的行数据
|
|
|
- List<CableSectionInfo> cableFourHundredList = new ArrayList<>();
|
|
|
- List<CableSectionInfo> cableThreeHundredList = new ArrayList<>(); //YJV22-3×300mm²
|
|
|
- List<CableSectionInfo> cableTwoHundredFortyList = new ArrayList<>(); //YJV22-3×240mm²
|
|
|
- List<CableSectionInfo> cableSeventyList = new ArrayList<>(); //YJV22-3×70mm²
|
|
|
- for (int i=2;i<=lastRow;i++){
|
|
|
- Row infoRow = importUtil.getRow(i);
|
|
|
- CableSectionInfo hundredInfo = new CableSectionInfo();
|
|
|
- if (StringUtils.isNotBlank(importUtil.getCellValue(infoRow,0).toString()) && !importUtil.getCellValue(infoRow,0).toString().equals("总长(km):")){
|
|
|
- hundredInfo.setDestination(importUtil.getCellValue(infoRow,0).toString());
|
|
|
- hundredInfo.setPathLength(importUtil.getCellValue(infoRow,1).toString());
|
|
|
- hundredInfo.setUpperRod(importUtil.getCellValue(infoRow,2).toString());
|
|
|
- hundredInfo.setArrival(importUtil.getCellValue(infoRow,3).toString());
|
|
|
- hundredInfo.setIncomingEquipment(importUtil.getCellValue(infoRow,4).toString());
|
|
|
- hundredInfo.setCoefficient(importUtil.getCellValue(infoRow,5).toString());
|
|
|
- hundredInfo.setElectricalChief(importUtil.getCellValue(infoRow,6).toString());
|
|
|
- cableFourHundredList.add(hundredInfo);
|
|
|
- }
|
|
|
|
|
|
- if (StringUtils.isNotBlank(importUtil.getCellValue(infoRow,8).toString())&& !importUtil.getCellValue(infoRow,0).toString().equals("总长(km):")){
|
|
|
- CableSectionInfo hundredAndTwenty = new CableSectionInfo();
|
|
|
- hundredAndTwenty.setDestination(importUtil.getCellValue(infoRow,8).toString());
|
|
|
- hundredAndTwenty.setPathLength(importUtil.getCellValue(infoRow,9).toString());
|
|
|
- hundredAndTwenty.setUpperRod(importUtil.getCellValue(infoRow,10).toString());
|
|
|
- hundredAndTwenty.setArrival(importUtil.getCellValue(infoRow,11).toString());
|
|
|
- hundredAndTwenty.setIncomingEquipment(importUtil.getCellValue(infoRow,12).toString());
|
|
|
- hundredAndTwenty.setCoefficient(importUtil.getCellValue(infoRow,13).toString());
|
|
|
- hundredAndTwenty.setElectricalChief(importUtil.getCellValue(infoRow,14).toString());
|
|
|
- cableThreeHundredList.add(hundredAndTwenty);
|
|
|
- }
|
|
|
-
|
|
|
- if (StringUtils.isNotBlank(importUtil.getCellValue(infoRow,16).toString())&& !importUtil.getCellValue(infoRow,0).toString().equals("总长(km):")){
|
|
|
- CableSectionInfo hundredAndTwenty = new CableSectionInfo();
|
|
|
- hundredAndTwenty.setDestination(importUtil.getCellValue(infoRow,16).toString());
|
|
|
- hundredAndTwenty.setPathLength(importUtil.getCellValue(infoRow,17).toString());
|
|
|
- hundredAndTwenty.setUpperRod(importUtil.getCellValue(infoRow,18).toString());
|
|
|
- hundredAndTwenty.setArrival(importUtil.getCellValue(infoRow,19).toString());
|
|
|
- hundredAndTwenty.setIncomingEquipment(importUtil.getCellValue(infoRow,20).toString());
|
|
|
- hundredAndTwenty.setCoefficient(importUtil.getCellValue(infoRow,21).toString());
|
|
|
- hundredAndTwenty.setElectricalChief(importUtil.getCellValue(infoRow,22).toString());
|
|
|
- cableTwoHundredFortyList.add(hundredAndTwenty);
|
|
|
- }
|
|
|
- if (StringUtils.isNotBlank(importUtil.getCellValue(infoRow,24).toString())&& !importUtil.getCellValue(infoRow,0).toString().equals("总长(km):")){
|
|
|
- CableSectionInfo hundredAndTwenty = new CableSectionInfo();
|
|
|
- hundredAndTwenty.setDestination(importUtil.getCellValue(infoRow,24).toString());
|
|
|
- hundredAndTwenty.setPathLength(importUtil.getCellValue(infoRow,25).toString());
|
|
|
- hundredAndTwenty.setUpperRod(importUtil.getCellValue(infoRow,26).toString());
|
|
|
- hundredAndTwenty.setArrival(importUtil.getCellValue(infoRow,27).toString());
|
|
|
- hundredAndTwenty.setIncomingEquipment( importUtil.getCellValue(infoRow,28).toString());
|
|
|
- hundredAndTwenty.setCoefficient(importUtil.getCellValue(infoRow,29).toString());
|
|
|
- hundredAndTwenty.setElectricalChief(importUtil.getCellValue(infoRow,30).toString());
|
|
|
- cableSeventyList.add(hundredAndTwenty);
|
|
|
- }
|
|
|
- }
|
|
|
+ ExcelReaderBuilder cableFourReaderBuilder = EasyExcel.read(excelFile.getInputStream());
|
|
|
+ ExcelReaderSheetBuilder cableFourBuilder = cableFourReaderBuilder.sheet("电缆分段表");
|
|
|
+ CableFourListener cableFourListener = new CableFourListener();
|
|
|
+ cableFourBuilder.registerReadListener(cableFourListener);
|
|
|
+ // 启动读取操作
|
|
|
+ cableFourBuilder.doRead();
|
|
|
+ List<CableSectionInfo> cableFourHundredList = cableFourListener.getData();
|
|
|
+
|
|
|
+ ExcelReaderBuilder cableThreeReaderBuilder = EasyExcel.read(excelFile.getInputStream());
|
|
|
+ ExcelReaderSheetBuilder cableThreeBuilder = cableThreeReaderBuilder.sheet("电缆分段表");
|
|
|
+ CableThreeListener cableThreeListener = new CableThreeListener();
|
|
|
+ cableThreeBuilder.registerReadListener(cableThreeListener);
|
|
|
+ // 启动读取操作
|
|
|
+ cableThreeBuilder.doRead();
|
|
|
+ List<CableSectionInfo> cableThreeHundredList = cableThreeListener.getData(); //YJV22-3×300mm²
|
|
|
+
|
|
|
+ ExcelReaderBuilder cableTwoReaderBuilder = EasyExcel.read(excelFile.getInputStream());
|
|
|
+ ExcelReaderSheetBuilder cableTwoBuilder = cableTwoReaderBuilder.sheet("电缆分段表");
|
|
|
+ CableTwoListener cableTwoListener = new CableTwoListener();
|
|
|
+ cableTwoBuilder.registerReadListener(cableTwoListener);
|
|
|
+ // 启动读取操作
|
|
|
+ cableTwoBuilder.doRead();
|
|
|
+ List<CableSectionInfo> cableTwoHundredFortyList = cableTwoListener.getData(); //YJV22-3×240mm²
|
|
|
+
|
|
|
+ ExcelReaderBuilder cableSevenReaderBuilder = EasyExcel.read(excelFile.getInputStream());
|
|
|
+ ExcelReaderSheetBuilder cableSevenBuilder = cableSevenReaderBuilder.sheet("电缆分段表");
|
|
|
+ CableSevenListener cableSevenListener = new CableSevenListener();
|
|
|
+ cableSevenBuilder.registerReadListener(cableSevenListener);
|
|
|
+ // 启动读取操作
|
|
|
+ cableSevenBuilder.doRead();
|
|
|
+ List<CableSectionInfo> cableSeventyList = cableSevenListener.getData(); ////YJV22-3×70mm²
|
|
|
+
|
|
|
+// ImportExcel importUtil = new ImportExcel(file,3,"电缆分段表");
|
|
|
+// int lastRow = importUtil.getLastDataRowNum();
|
|
|
+ //获取指定的列数据 YJV22-3×400mm²单元格下的行数据
|
|
|
+// List<CableSectionInfo> cableFourHundredList = new ArrayList<>();
|
|
|
+// List<CableSectionInfo> cableThreeHundredList = new ArrayList<>(); //YJV22-3×300mm²
|
|
|
+// List<CableSectionInfo> cableTwoHundredFortyList = new ArrayList<>(); //YJV22-3×240mm²
|
|
|
+// List<CableSectionInfo> cableSeventyList = new ArrayList<>(); //YJV22-3×70mm²
|
|
|
+// for (int i=2;i<=lastRow;i++){
|
|
|
+// Row infoRow = importUtil.getRow(i);
|
|
|
+// CableSectionInfo hundredInfo = new CableSectionInfo();
|
|
|
+// if (StringUtils.isNotBlank(importUtil.getCellValue(infoRow,0).toString()) && !importUtil.getCellValue(infoRow,0).toString().equals("总长(km):")){
|
|
|
+// hundredInfo.setDestination(importUtil.getCellValue(infoRow,0).toString());
|
|
|
+// hundredInfo.setPathLength(importUtil.getCellValue(infoRow,1).toString());
|
|
|
+// hundredInfo.setUpperRod(importUtil.getCellValue(infoRow,2).toString());
|
|
|
+// hundredInfo.setArrival(importUtil.getCellValue(infoRow,3).toString());
|
|
|
+// hundredInfo.setIncomingEquipment(importUtil.getCellValue(infoRow,4).toString());
|
|
|
+// hundredInfo.setCoefficient(importUtil.getCellValue(infoRow,5).toString());
|
|
|
+// hundredInfo.setElectricalChief(importUtil.getCellValue(infoRow,6).toString());
|
|
|
+// cableFourHundredList.add(hundredInfo);
|
|
|
+// }
|
|
|
+//
|
|
|
+// if (StringUtils.isNotBlank(importUtil.getCellValue(infoRow,8).toString())&& !importUtil.getCellValue(infoRow,0).toString().equals("总长(km):")){
|
|
|
+// CableSectionInfo hundredAndTwenty = new CableSectionInfo();
|
|
|
+// hundredAndTwenty.setDestination(importUtil.getCellValue(infoRow,8).toString());
|
|
|
+// hundredAndTwenty.setPathLength(importUtil.getCellValue(infoRow,9).toString());
|
|
|
+// hundredAndTwenty.setUpperRod(importUtil.getCellValue(infoRow,10).toString());
|
|
|
+// hundredAndTwenty.setArrival(importUtil.getCellValue(infoRow,11).toString());
|
|
|
+// hundredAndTwenty.setIncomingEquipment(importUtil.getCellValue(infoRow,12).toString());
|
|
|
+// hundredAndTwenty.setCoefficient(importUtil.getCellValue(infoRow,13).toString());
|
|
|
+// hundredAndTwenty.setElectricalChief(importUtil.getCellValue(infoRow,14).toString());
|
|
|
+// cableThreeHundredList.add(hundredAndTwenty);
|
|
|
+// }
|
|
|
+//
|
|
|
+// if (StringUtils.isNotBlank(importUtil.getCellValue(infoRow,16).toString())&& !importUtil.getCellValue(infoRow,0).toString().equals("总长(km):")){
|
|
|
+// CableSectionInfo hundredAndTwenty = new CableSectionInfo();
|
|
|
+// hundredAndTwenty.setDestination(importUtil.getCellValue(infoRow,16).toString());
|
|
|
+// hundredAndTwenty.setPathLength(importUtil.getCellValue(infoRow,17).toString());
|
|
|
+// hundredAndTwenty.setUpperRod(importUtil.getCellValue(infoRow,18).toString());
|
|
|
+// hundredAndTwenty.setArrival(importUtil.getCellValue(infoRow,19).toString());
|
|
|
+// hundredAndTwenty.setIncomingEquipment(importUtil.getCellValue(infoRow,20).toString());
|
|
|
+// hundredAndTwenty.setCoefficient(importUtil.getCellValue(infoRow,21).toString());
|
|
|
+// hundredAndTwenty.setElectricalChief(importUtil.getCellValue(infoRow,22).toString());
|
|
|
+// cableTwoHundredFortyList.add(hundredAndTwenty);
|
|
|
+// }
|
|
|
+// if (StringUtils.isNotBlank(importUtil.getCellValue(infoRow,24).toString())&& !importUtil.getCellValue(infoRow,0).toString().equals("总长(km):")){
|
|
|
+// CableSectionInfo hundredAndTwenty = new CableSectionInfo();
|
|
|
+// hundredAndTwenty.setDestination(importUtil.getCellValue(infoRow,24).toString());
|
|
|
+// hundredAndTwenty.setPathLength(importUtil.getCellValue(infoRow,25).toString());
|
|
|
+// hundredAndTwenty.setUpperRod(importUtil.getCellValue(infoRow,26).toString());
|
|
|
+// hundredAndTwenty.setArrival(importUtil.getCellValue(infoRow,27).toString());
|
|
|
+// hundredAndTwenty.setIncomingEquipment( importUtil.getCellValue(infoRow,28).toString());
|
|
|
+// hundredAndTwenty.setCoefficient(importUtil.getCellValue(infoRow,29).toString());
|
|
|
+// hundredAndTwenty.setElectricalChief(importUtil.getCellValue(infoRow,30).toString());
|
|
|
+// cableSeventyList.add(hundredAndTwenty);
|
|
|
+// }
|
|
|
+// }
|
|
|
CableSectionData cableSectionData = new CableSectionData();
|
|
|
cableSectionData.setCableFourHundredList(cableFourHundredList);
|
|
|
cableSectionData.setCableThreeHundredList(cableThreeHundredList);
|