|
|
@ -57,22 +57,25 @@ public class GetInformationForExcelServiceImpl extends ServiceImpl<GetInformatio |
|
|
public void saveByExcel() { |
|
|
public void saveByExcel() { |
|
|
//获取每一个文件夹路径 |
|
|
//获取每一个文件夹路径 |
|
|
List<EquipmentFolderLocation> locationList = equipmentFolderLocationService |
|
|
List<EquipmentFolderLocation> locationList = equipmentFolderLocationService |
|
|
.lambdaQuery().ne(EquipmentFolderLocation::getSuffix,"RS232/RS485") |
|
|
|
|
|
|
|
|
.lambdaQuery() |
|
|
|
|
|
.ne(EquipmentFolderLocation::getSuffix,"RS232/RS485") |
|
|
|
|
|
.ne(EquipmentFolderLocation::getSuffix,"PLC") |
|
|
|
|
|
.eq(EquipmentFolderLocation::getId,56) |
|
|
.list(); |
|
|
.list(); |
|
|
if (CollectionUtils.isEmpty(locationList)) { |
|
|
if (CollectionUtils.isEmpty(locationList)) { |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
//创建线程池 |
|
|
//创建线程池 |
|
|
ExecutorService executorService = Executors.newFixedThreadPool(locationList.size());//线程池的最大数量为文件夹的个数 |
|
|
ExecutorService executorService = Executors.newFixedThreadPool(locationList.size());//线程池的最大数量为文件夹的个数 |
|
|
for (EquipmentFolderLocation excel : locationList) { |
|
|
|
|
|
|
|
|
for (EquipmentFolderLocation location : locationList) { |
|
|
executorService.submit(() -> { |
|
|
executorService.submit(() -> { |
|
|
try { |
|
|
try { |
|
|
if (StringUtils.isNotEmpty(excel.getFolderPath())) { |
|
|
|
|
|
|
|
|
if (StringUtils.isNotEmpty(location.getFolderPath())) { |
|
|
//对文件夹下的文件进行读取并保存 |
|
|
//对文件夹下的文件进行读取并保存 |
|
|
saveInformation(excel); |
|
|
|
|
|
|
|
|
saveInformation(location); |
|
|
} |
|
|
} |
|
|
} catch (Exception e) { |
|
|
} catch (Exception e) { |
|
|
e.printStackTrace(); |
|
|
|
|
|
|
|
|
log.error("获取文件夹下的文件信息异常:{}", e.getMessage()); |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
@ -136,6 +139,10 @@ public class GetInformationForExcelServiceImpl extends ServiceImpl<GetInformatio |
|
|
if (files == null || files.length == 0) { |
|
|
if (files == null || files.length == 0) { |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
|
|
|
Map<String,List<File>> map = new HashMap<>(); |
|
|
|
|
|
map.put("img",new ArrayList<>()); |
|
|
|
|
|
map.put("excel",new ArrayList<>()); |
|
|
|
|
|
map.put("txt",new ArrayList<>()); |
|
|
//图片 |
|
|
//图片 |
|
|
List<String> imageFiles = new ArrayList<>(); |
|
|
List<String> imageFiles = new ArrayList<>(); |
|
|
//创建一个list用来存储所有的的excel(csv)文件路径 |
|
|
//创建一个list用来存储所有的的excel(csv)文件路径 |
|
|
@ -155,12 +162,15 @@ public class GetInformationForExcelServiceImpl extends ServiceImpl<GetInformatio |
|
|
if (s.equals(type)) { |
|
|
if (s.equals(type)) { |
|
|
if (s.equals("jpg") || s.equals("png") || s.equals("gif")) { |
|
|
if (s.equals("jpg") || s.equals("png") || s.equals("gif")) { |
|
|
imageFiles.add(fileName); |
|
|
imageFiles.add(fileName); |
|
|
|
|
|
map.get("img").add(file); |
|
|
} |
|
|
} |
|
|
if (s.equals("csv") || s.equals("xls") || s.equals("xlsx")) { |
|
|
if (s.equals("csv") || s.equals("xls") || s.equals("xlsx")) { |
|
|
excelName.add(equipmentFolderLocation.getFolderPath() + File.separator + fileName); |
|
|
excelName.add(equipmentFolderLocation.getFolderPath() + File.separator + fileName); |
|
|
|
|
|
map.get("excel").add(file); |
|
|
} |
|
|
} |
|
|
if (s.equals("txt") || s.equals("tff")) { |
|
|
if (s.equals("txt") || s.equals("tff")) { |
|
|
txtName.add(equipmentFolderLocation.getFolderPath() + File.separator + fileName); |
|
|
txtName.add(equipmentFolderLocation.getFolderPath() + File.separator + fileName); |
|
|
|
|
|
map.get("txt").add(file); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
@ -203,7 +213,7 @@ public class GetInformationForExcelServiceImpl extends ServiceImpl<GetInformatio |
|
|
equipmentFolderLocation.setBatchDate("1"); |
|
|
equipmentFolderLocation.setBatchDate("1"); |
|
|
} |
|
|
} |
|
|
int time = Integer.parseInt(equipmentFolderLocation.getBatchDate()); |
|
|
int time = Integer.parseInt(equipmentFolderLocation.getBatchDate()); |
|
|
Long finalTime = date.getTime() - createDate.getTime(); |
|
|
|
|
|
|
|
|
long finalTime = date.getTime() - createDate.getTime(); |
|
|
if (finalTime / 1000 > time) { |
|
|
if (finalTime / 1000 > time) { |
|
|
batchNo = (Integer)resultList.get(0).get("batchNo"); |
|
|
batchNo = (Integer)resultList.get(0).get("batchNo"); |
|
|
//对应的不是第一次新增的情况下如果批次号不为空的情况下那么草果规定时间 批次号就加一,下次获取的时候就可以直接引用 |
|
|
//对应的不是第一次新增的情况下如果批次号不为空的情况下那么草果规定时间 批次号就加一,下次获取的时候就可以直接引用 |
|
|
@ -424,8 +434,10 @@ public class GetInformationForExcelServiceImpl extends ServiceImpl<GetInformatio |
|
|
throw new RuntimeException("读取设备信息为配置"); |
|
|
throw new RuntimeException("读取设备信息为配置"); |
|
|
} |
|
|
} |
|
|
String data = list.get(i).get(equipmentFolderLocation.getExcelCompareFieldsY()-1); |
|
|
String data = list.get(i).get(equipmentFolderLocation.getExcelCompareFieldsY()-1); |
|
|
|
|
|
if (org.springframework.util.StringUtils.hasText(data)){ |
|
|
String[] split = data.split(equipmentFolderLocation.getCuttingSymbol()); |
|
|
String[] split = data.split(equipmentFolderLocation.getCuttingSymbol()); |
|
|
insertByEntity(equipmentDataDetail, new HashMap<>(), split); |
|
|
insertByEntity(equipmentDataDetail, new HashMap<>(), split); |
|
|
|
|
|
} |
|
|
}else { |
|
|
}else { |
|
|
insertByEntity(equipmentDataDetail, list.get(i), null); |
|
|
insertByEntity(equipmentDataDetail, list.get(i), null); |
|
|
} |
|
|
} |
|
|
|