|
|
|
@ -443,22 +443,45 @@ public class GetInformationForExcelServiceImpl extends ServiceImpl<GetInformatio |
|
|
|
String file = equipmentFolderLocation.getBackupFolderPath() + "\\" + num + timestamp1 + "$" + byName; |
|
|
|
num++; |
|
|
|
List<String> list = new ArrayList<>(); |
|
|
|
if (equipmentFolderLocation.getDataRow() == null && equipmentFolderLocation.getInitialLine() != null) { |
|
|
|
try (BufferedReader bufferedReader = new BufferedReader(new FileReader(name))) { |
|
|
|
// 缓存字符流 |
|
|
|
String line; |
|
|
|
int lineCount = 0; |
|
|
|
while ((line = bufferedReader.readLine()) != null) { |
|
|
|
lineCount ++; |
|
|
|
if (lineCount <= equipmentFolderLocation.getInitialLine()) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
// 处理当前行数据 |
|
|
|
try (BufferedReader bufferedReader = new BufferedReader(new FileReader(name))) { |
|
|
|
// 缓存字符流 |
|
|
|
String line; |
|
|
|
int lineCount = 0; |
|
|
|
// 开始跳过行数 |
|
|
|
int initialLine = 0; |
|
|
|
if (equipmentFolderLocation.getInitialLine() != null){ |
|
|
|
initialLine = equipmentFolderLocation.getInitialLine(); |
|
|
|
} |
|
|
|
// 读取行数 |
|
|
|
int dataRow = 0; |
|
|
|
if (equipmentFolderLocation.getDataRow() != null){ |
|
|
|
dataRow = equipmentFolderLocation.getDataRow(); |
|
|
|
} |
|
|
|
// 跳过行数 |
|
|
|
int skipLine = 0; |
|
|
|
if (equipmentFolderLocation.getSkipLine() != null){ |
|
|
|
skipLine = equipmentFolderLocation.getSkipLine(); |
|
|
|
} |
|
|
|
|
|
|
|
int i = 0; |
|
|
|
while ((line = bufferedReader.readLine()) != null) { |
|
|
|
lineCount ++; |
|
|
|
if (lineCount <= initialLine) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
if (skipLine == 0 && dataRow == 0){ |
|
|
|
list.add(line); |
|
|
|
}else { |
|
|
|
if (i == skipLine + dataRow){ |
|
|
|
i = 0; |
|
|
|
} |
|
|
|
if (i < dataRow){ |
|
|
|
list.add(line); |
|
|
|
} |
|
|
|
i++; |
|
|
|
} |
|
|
|
} catch (Exception e) { |
|
|
|
e.printStackTrace(); |
|
|
|
} |
|
|
|
|
|
|
|
for (String s : list) { |
|
|
|
EquipmentDataDetail equipmentDataDetail = new EquipmentDataDetail(); |
|
|
|
if (StringUtils.isNotEmpty(equipmentFolderLocation.getCuttingSymbol())){ |
|
|
|
@ -474,83 +497,130 @@ public class GetInformationForExcelServiceImpl extends ServiceImpl<GetInformatio |
|
|
|
equipmentDataDetail.setItemNo(equipmentFolderLocation.getItemNo()); |
|
|
|
equipmentDataDetail.setFileNo(equipmentFolderLocation.getFileNo()); |
|
|
|
equipmentDataDetail.setCreateDate(new Date()); |
|
|
|
equipmentDataDetail.setNum(index); |
|
|
|
detailList.add(equipmentDataDetail); |
|
|
|
index++; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (equipmentFolderLocation.getInitialLine() != null && equipmentFolderLocation.getDataRow() != null) { |
|
|
|
if (equipmentFolderLocation.getSkipLine() != null) { |
|
|
|
int startLine = equipmentFolderLocation.getInitialLine(); // 第一次读取开始的行数 |
|
|
|
int firstReadLines = equipmentFolderLocation.getDataRow(); |
|
|
|
int columnInterval = equipmentFolderLocation.getSkipLine(); |
|
|
|
try (BufferedReader bufferedReader = new BufferedReader(new FileReader(name))) { |
|
|
|
String line; |
|
|
|
// 第一次读取从第 15 行开始的 41 行数据 |
|
|
|
for (int i = 1; i < startLine; i++) { |
|
|
|
bufferedReader.readLine(); // 跳过前面的行数 |
|
|
|
} |
|
|
|
for (int i = 0; i < firstReadLines; i++) { |
|
|
|
line = bufferedReader.readLine(); |
|
|
|
if (line != null) { |
|
|
|
// 处理当前行数据 |
|
|
|
list.add(line); |
|
|
|
} |
|
|
|
} |
|
|
|
// 移动到下一列 |
|
|
|
for (int i = 0; i < columnInterval; i++) { |
|
|
|
line = bufferedReader.readLine(); |
|
|
|
} |
|
|
|
|
|
|
|
// 每隔 11 行读取往下 41 行的数据 |
|
|
|
while ((line = bufferedReader.readLine()) != null) { |
|
|
|
// 从当前行开始读取指定行数 |
|
|
|
for (int i = 0; i < firstReadLines; i++) { |
|
|
|
if (line != null) { |
|
|
|
// 处理当前行数据 |
|
|
|
list.add(line); |
|
|
|
} |
|
|
|
line = bufferedReader.readLine(); |
|
|
|
} |
|
|
|
// 移动到下一列 |
|
|
|
for (int i = 0; i < columnInterval - 1; i++) { |
|
|
|
line = bufferedReader.readLine(); |
|
|
|
} |
|
|
|
} |
|
|
|
} catch (IOException e) { |
|
|
|
e.printStackTrace(); |
|
|
|
} |
|
|
|
//对数据进行切割封装 |
|
|
|
for (String info : list) { |
|
|
|
EquipmentDataDetail equipmentDataDetail = new EquipmentDataDetail(); |
|
|
|
if (StringUtils.isNotEmpty(equipmentFolderLocation.getCuttingSymbol())){ |
|
|
|
String[] data = info.split(equipmentFolderLocation.getCuttingSymbol()); |
|
|
|
insertByEntity(equipmentDataDetail, new HashMap<>(), data); |
|
|
|
}else { |
|
|
|
equipmentDataDetail.setValue0(info); |
|
|
|
} |
|
|
|
equipmentDataDetail.setEquipmentNo(equipmentFolderLocation.getEquipmentNo()); |
|
|
|
equipmentDataDetail.setBuNo(equipmentFolderLocation.getBuNo()); |
|
|
|
equipmentDataDetail.setSite(equipmentFolderLocation.getSite()); |
|
|
|
equipmentDataDetail.setBatchNo(batchNo); |
|
|
|
equipmentDataDetail.setItemNo(equipmentFolderLocation.getItemNo()); |
|
|
|
equipmentDataDetail.setFileNo(equipmentFolderLocation.getFileNo()); |
|
|
|
equipmentDataDetail.setCreateDate(new Date()); |
|
|
|
if (dataRow != 0 && skipLine != 0){ |
|
|
|
equipmentDataDetail.setGroupValue(group); |
|
|
|
if (groupValue == firstReadLines) { |
|
|
|
if (groupValue == dataRow) { |
|
|
|
group++; |
|
|
|
groupValue = 1; |
|
|
|
} |
|
|
|
groupValue++; |
|
|
|
equipmentDataDetail.setNum(index); |
|
|
|
detailList.add(equipmentDataDetail); |
|
|
|
index++; |
|
|
|
} |
|
|
|
|
|
|
|
equipmentDataDetail.setNum(index); |
|
|
|
detailList.add(equipmentDataDetail); |
|
|
|
index++; |
|
|
|
} |
|
|
|
} catch (Exception e) { |
|
|
|
e.printStackTrace(); |
|
|
|
} |
|
|
|
// 情况1、只存在 initialLine |
|
|
|
// if (equipmentFolderLocation.getDataRow() == null && equipmentFolderLocation.getInitialLine() != null) { |
|
|
|
// try (BufferedReader bufferedReader = new BufferedReader(new FileReader(name))) { |
|
|
|
// // 缓存字符流 |
|
|
|
// String line; |
|
|
|
// int lineCount = 0; |
|
|
|
// while ((line = bufferedReader.readLine()) != null) { |
|
|
|
// if (lineCount < equipmentFolderLocation.getInitialLine()) { |
|
|
|
// continue; |
|
|
|
// } |
|
|
|
// lineCount ++; |
|
|
|
// // 处理当前行数据 |
|
|
|
// list.add(line); |
|
|
|
// } |
|
|
|
// } catch (Exception e) { |
|
|
|
// e.printStackTrace(); |
|
|
|
// } |
|
|
|
// for (String s : list) { |
|
|
|
// EquipmentDataDetail equipmentDataDetail = new EquipmentDataDetail(); |
|
|
|
// if (StringUtils.isNotEmpty(equipmentFolderLocation.getCuttingSymbol())){ |
|
|
|
// String[] data = s.split(equipmentFolderLocation.getCuttingSymbol()); |
|
|
|
// insertByEntity(equipmentDataDetail, new HashMap<>(), data); |
|
|
|
// }else { |
|
|
|
// equipmentDataDetail.setValue0(s); |
|
|
|
// } |
|
|
|
// equipmentDataDetail.setEquipmentNo(equipmentFolderLocation.getEquipmentNo()); |
|
|
|
// equipmentDataDetail.setBuNo(equipmentFolderLocation.getBuNo()); |
|
|
|
// equipmentDataDetail.setSite(equipmentFolderLocation.getSite()); |
|
|
|
// equipmentDataDetail.setBatchNo(batchNo); |
|
|
|
// equipmentDataDetail.setItemNo(equipmentFolderLocation.getItemNo()); |
|
|
|
// equipmentDataDetail.setFileNo(equipmentFolderLocation.getFileNo()); |
|
|
|
// equipmentDataDetail.setCreateDate(new Date()); |
|
|
|
// equipmentDataDetail.setNum(index); |
|
|
|
// detailList.add(equipmentDataDetail); |
|
|
|
// index++; |
|
|
|
// } |
|
|
|
// |
|
|
|
// } |
|
|
|
|
|
|
|
// if (equipmentFolderLocation.getInitialLine() != null && equipmentFolderLocation.getDataRow() != null) { |
|
|
|
// if (equipmentFolderLocation.getSkipLine() != null) { |
|
|
|
// int startLine = equipmentFolderLocation.getInitialLine(); // 第一次读取开始的行数 |
|
|
|
// int firstReadLines = equipmentFolderLocation.getDataRow(); |
|
|
|
// int columnInterval = equipmentFolderLocation.getSkipLine(); |
|
|
|
// try (BufferedReader bufferedReader = new BufferedReader(new FileReader(name))) { |
|
|
|
// String line; |
|
|
|
// // 第一次读取从第 15 行开始的 41 行数据 |
|
|
|
// for (int i = 1; i < startLine; i++) { |
|
|
|
// bufferedReader.readLine(); // 跳过前面的行数 |
|
|
|
// } |
|
|
|
// for (int i = 0; i < firstReadLines; i++) { |
|
|
|
// line = bufferedReader.readLine(); |
|
|
|
// if (line != null) { |
|
|
|
// // 处理当前行数据 |
|
|
|
// list.add(line); |
|
|
|
// } |
|
|
|
// } |
|
|
|
// // 移动到下一列 |
|
|
|
// for (int i = 0; i < columnInterval; i++) { |
|
|
|
// line = bufferedReader.readLine(); |
|
|
|
// } |
|
|
|
// |
|
|
|
// // 每隔 11 行读取往下 41 行的数据 |
|
|
|
// while ((line = bufferedReader.readLine()) != null) { |
|
|
|
// // 从当前行开始读取指定行数 |
|
|
|
// for (int i = 0; i < firstReadLines; i++) { |
|
|
|
// if (line != null) { |
|
|
|
// // 处理当前行数据 |
|
|
|
// list.add(line); |
|
|
|
// } |
|
|
|
// line = bufferedReader.readLine(); |
|
|
|
// } |
|
|
|
// // 移动到下一列 |
|
|
|
// for (int i = 0; i < columnInterval - 1; i++) { |
|
|
|
// line = bufferedReader.readLine(); |
|
|
|
// } |
|
|
|
// } |
|
|
|
// } catch (IOException e) { |
|
|
|
// e.printStackTrace(); |
|
|
|
// } |
|
|
|
// //对数据进行切割封装 |
|
|
|
// for (String info : list) { |
|
|
|
// EquipmentDataDetail equipmentDataDetail = new EquipmentDataDetail(); |
|
|
|
// if (StringUtils.isNotEmpty(equipmentFolderLocation.getCuttingSymbol())){ |
|
|
|
// String[] data = info.split(equipmentFolderLocation.getCuttingSymbol()); |
|
|
|
// insertByEntity(equipmentDataDetail, new HashMap<>(), data); |
|
|
|
// }else { |
|
|
|
// equipmentDataDetail.setValue0(info); |
|
|
|
// } |
|
|
|
// equipmentDataDetail.setEquipmentNo(equipmentFolderLocation.getEquipmentNo()); |
|
|
|
// equipmentDataDetail.setBuNo(equipmentFolderLocation.getBuNo()); |
|
|
|
// equipmentDataDetail.setSite(equipmentFolderLocation.getSite()); |
|
|
|
// equipmentDataDetail.setBatchNo(batchNo); |
|
|
|
// equipmentDataDetail.setItemNo(equipmentFolderLocation.getItemNo()); |
|
|
|
// equipmentDataDetail.setFileNo(equipmentFolderLocation.getFileNo()); |
|
|
|
// equipmentDataDetail.setCreateDate(new Date()); |
|
|
|
// equipmentDataDetail.setGroupValue(group); |
|
|
|
// if (groupValue == firstReadLines) { |
|
|
|
// group++; |
|
|
|
// groupValue = 1; |
|
|
|
// } |
|
|
|
// groupValue++; |
|
|
|
// equipmentDataDetail.setNum(index); |
|
|
|
// detailList.add(equipmentDataDetail); |
|
|
|
// index++; |
|
|
|
// } |
|
|
|
// |
|
|
|
// } |
|
|
|
// } |
|
|
|
if (!detailList.isEmpty()){ |
|
|
|
detailList.get(detailList.size() - 1).setFileValue1(file); |
|
|
|
} |
|
|
|
@ -582,7 +652,7 @@ public class GetInformationForExcelServiceImpl extends ServiceImpl<GetInformatio |
|
|
|
|
|
|
|
//保存数据到对应位置 |
|
|
|
private static void insertByEntity(EquipmentDataDetail equipmentDataDetail, Map<Integer, String> hashMap, String[] strings) { |
|
|
|
if (!hashMap.isEmpty() && hashMap != null) { |
|
|
|
if (hashMap != null && !hashMap.isEmpty()) { |
|
|
|
|
|
|
|
if (hashMap.get(0) != null) { |
|
|
|
equipmentDataDetail.setValue0(hashMap.get(0).trim()); |
|
|
|
|