|
|
@ -6,6 +6,8 @@ import java.util.HashMap; |
|
|
import java.util.Map; |
|
|
import java.util.Map; |
|
|
import java.util.stream.Collectors; |
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
|
|
|
import com.techsor.datacenter.business.util.CommonUtil; |
|
|
|
|
|
import org.apache.commons.collections.MapUtils; |
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
import org.apache.poi.ss.usermodel.Row; |
|
|
import org.apache.poi.ss.usermodel.Row; |
|
|
import org.apache.poi.ss.usermodel.Sheet; |
|
|
import org.apache.poi.ss.usermodel.Sheet; |
|
|
@ -100,15 +102,6 @@ public class AsyncExcelProcessingService { |
|
|
BasicSpace space = new BasicSpace(); |
|
|
BasicSpace space = new BasicSpace(); |
|
|
space.setSpaceId(oldSpace.getSpaceId()); |
|
|
space.setSpaceId(oldSpace.getSpaceId()); |
|
|
|
|
|
|
|
|
// 处理旧图片
|
|
|
|
|
|
String oldImagesIntroduction = oldSpace.getImagesIntroduction(); |
|
|
|
|
|
if(StringUtils.isNotBlank(oldImagesIntroduction)) { |
|
|
|
|
|
Map<String, S3FileInfoEntity> oldImages = JSON.parseObject(oldImagesIntroduction, new TypeReference<Map<String, S3FileInfoEntity>>() {}); |
|
|
|
|
|
for (Map.Entry<String, S3FileInfoEntity> entry : oldImages.entrySet()) { |
|
|
|
|
|
commonOpt.deleteS3File(entry.getValue().getS3Path()); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/**20250515需求,直接更新旧数据,不用保留原来的文件**/ |
|
|
/**20250515需求,直接更新旧数据,不用保留原来的文件**/ |
|
|
Map<String, S3FileInfoEntity> newImagesMap = new HashMap<>(); |
|
|
Map<String, S3FileInfoEntity> newImagesMap = new HashMap<>(); |
|
|
|
|
|
|
|
|
@ -130,7 +123,17 @@ public class AsyncExcelProcessingService { |
|
|
baseDir.resolve("img"), currentUnix, languageType, storageS3FolderImage, s3FileMapping); |
|
|
baseDir.resolve("img"), currentUnix, languageType, storageS3FolderImage, s3FileMapping); |
|
|
setImgDescription(newImagesMap, img3Name, img3Description); |
|
|
setImgDescription(newImagesMap, img3Name, img3Description); |
|
|
|
|
|
|
|
|
|
|
|
if (MapUtils.isNotEmpty(newImagesMap)) { |
|
|
space.setImagesIntroduction(JSON.toJSONString(newImagesMap)); |
|
|
space.setImagesIntroduction(JSON.toJSONString(newImagesMap)); |
|
|
|
|
|
// 处理旧图片
|
|
|
|
|
|
String oldImagesIntroduction = oldSpace.getImagesIntroduction(); |
|
|
|
|
|
if(StringUtils.isNotBlank(oldImagesIntroduction)) { |
|
|
|
|
|
Map<String, S3FileInfoEntity> oldImages = JSON.parseObject(oldImagesIntroduction, new TypeReference<Map<String, S3FileInfoEntity>>() {}); |
|
|
|
|
|
for (Map.Entry<String, S3FileInfoEntity> entry : oldImages.entrySet()) { |
|
|
|
|
|
commonOpt.deleteS3File(entry.getValue().getS3Path()); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// 处理PDF
|
|
|
// 处理PDF
|
|
|
processAndSetPdfEquipment(space, oldSpace, row, columnIndices, languageType, baseDir, currentUnix, "buildingDevice", |
|
|
processAndSetPdfEquipment(space, oldSpace, row, columnIndices, languageType, baseDir, currentUnix, "buildingDevice", |
|
|
@ -146,7 +149,9 @@ public class AsyncExcelProcessingService { |
|
|
processAndSetPdfEquipment(space, oldSpace, row, columnIndices, languageType, baseDir, currentUnix, "otherDevice", |
|
|
processAndSetPdfEquipment(space, oldSpace, row, columnIndices, languageType, baseDir, currentUnix, "otherDevice", |
|
|
"getPdfOtherEquipment", "setPdfOtherEquipment", s3FileMapping, storageS3FolderPdf); |
|
|
"getPdfOtherEquipment", "setPdfOtherEquipment", s3FileMapping, storageS3FolderPdf); |
|
|
|
|
|
|
|
|
|
|
|
if (CommonUtil.hasAnyOtherFieldNotEmpty(space, "spaceId")) { |
|
|
basicSpaceMapperExt.updateByPrimaryKeySelective(space); |
|
|
basicSpaceMapperExt.updateByPrimaryKeySelective(space); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -181,15 +186,6 @@ public class AsyncExcelProcessingService { |
|
|
private void processAndSetPdfEquipment(BasicSpace space, SpacePageVO oldSpace, Row row, Map<String, Integer> columnIndices, |
|
|
private void processAndSetPdfEquipment(BasicSpace space, SpacePageVO oldSpace, Row row, Map<String, Integer> columnIndices, |
|
|
Integer languageType, Path baseDir, long currentUnix, String equipmentType, |
|
|
Integer languageType, Path baseDir, long currentUnix, String equipmentType, |
|
|
String getterMethod, String setterMethod, Map<String, String> s3FileMapping, String storageS3FolderPdf) throws Exception { |
|
|
String getterMethod, String setterMethod, Map<String, String> s3FileMapping, String storageS3FolderPdf) throws Exception { |
|
|
// 获取旧设备数据
|
|
|
|
|
|
String oldPdfEquipment = (String) oldSpace.getClass().getMethod(getterMethod).invoke(oldSpace); |
|
|
|
|
|
if (StringUtils.isNotBlank(oldPdfEquipment)) { |
|
|
|
|
|
Map<String, S3FileInfoEntity> oldPdfEquipmentMap = JSON.parseObject(oldPdfEquipment, new TypeReference<Map<String, S3FileInfoEntity>>() {}); |
|
|
|
|
|
for (Map.Entry<String, S3FileInfoEntity> entry : oldPdfEquipmentMap.entrySet()) { |
|
|
|
|
|
commonOpt.deleteS3File(entry.getValue().getS3Path()); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 处理文件
|
|
|
// 处理文件
|
|
|
/**20250515需求,直接更新旧数据,不用保留原来的文件**/ |
|
|
/**20250515需求,直接更新旧数据,不用保留原来的文件**/ |
|
|
Map<String, S3FileInfoEntity> newPdfEquipmentMap = new HashMap<>(); |
|
|
Map<String, S3FileInfoEntity> newPdfEquipmentMap = new HashMap<>(); |
|
|
@ -197,8 +193,19 @@ public class AsyncExcelProcessingService { |
|
|
commonOpt.getCellValue(row.getCell(columnIndices.get(msgLanguageChange.getParameterMapByCode(languageType, equipmentType)))), |
|
|
commonOpt.getCellValue(row.getCell(columnIndices.get(msgLanguageChange.getParameterMapByCode(languageType, equipmentType)))), |
|
|
baseDir.resolve("pdf"), currentUnix, languageType, storageS3FolderPdf, s3FileMapping); |
|
|
baseDir.resolve("pdf"), currentUnix, languageType, storageS3FolderPdf, s3FileMapping); |
|
|
|
|
|
|
|
|
|
|
|
if (MapUtils.isNotEmpty(newPdfEquipmentMap)) { |
|
|
// 设置更新后的设备数据
|
|
|
// 设置更新后的设备数据
|
|
|
space.getClass().getMethod(setterMethod, String.class).invoke(space, JSON.toJSONString(newPdfEquipmentMap)); |
|
|
space.getClass().getMethod(setterMethod, String.class).invoke(space, JSON.toJSONString(newPdfEquipmentMap)); |
|
|
|
|
|
|
|
|
|
|
|
// 删除旧设备数据
|
|
|
|
|
|
String oldPdfEquipment = (String) oldSpace.getClass().getMethod(getterMethod).invoke(oldSpace); |
|
|
|
|
|
if (StringUtils.isNotBlank(oldPdfEquipment)) { |
|
|
|
|
|
Map<String, S3FileInfoEntity> oldPdfEquipmentMap = JSON.parseObject(oldPdfEquipment, new TypeReference<Map<String, S3FileInfoEntity>>() {}); |
|
|
|
|
|
for (Map.Entry<String, S3FileInfoEntity> entry : oldPdfEquipmentMap.entrySet()) { |
|
|
|
|
|
commonOpt.deleteS3File(entry.getValue().getS3Path()); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -248,15 +255,6 @@ public class AsyncExcelProcessingService { |
|
|
BasicMonitoringAsset asset = new BasicMonitoringAsset(); |
|
|
BasicMonitoringAsset asset = new BasicMonitoringAsset(); |
|
|
asset.setEquipmentId(oldAsset.getAssetId()); |
|
|
asset.setEquipmentId(oldAsset.getAssetId()); |
|
|
|
|
|
|
|
|
// 处理图片
|
|
|
|
|
|
String oldImagesIntroduction = oldAsset.getImagesIntroduction(); |
|
|
|
|
|
if(StringUtils.isNotBlank(oldImagesIntroduction)) { |
|
|
|
|
|
Map<String, S3FileInfoEntity> oldImages = JSON.parseObject(oldImagesIntroduction, new TypeReference<Map<String, S3FileInfoEntity>>() {}); |
|
|
|
|
|
for (Map.Entry<String, S3FileInfoEntity> entry : oldImages.entrySet()) { |
|
|
|
|
|
commonOpt.deleteS3File(entry.getValue().getS3Path()); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Map<String, S3FileInfoEntity> newImagesMap = new HashMap<>(); |
|
|
Map<String, S3FileInfoEntity> newImagesMap = new HashMap<>(); |
|
|
|
|
|
|
|
|
String img1Description = commonOpt.getCellValue(row.getCell(columnIndices.get(msgLanguageChange.getParameterMapByCode(languageType, "img1Description")))); |
|
|
String img1Description = commonOpt.getCellValue(row.getCell(columnIndices.get(msgLanguageChange.getParameterMapByCode(languageType, "img1Description")))); |
|
|
@ -277,7 +275,17 @@ public class AsyncExcelProcessingService { |
|
|
baseDir.resolve("img"), currentUnix, languageType, storageS3FolderImage, s3FileMapping); |
|
|
baseDir.resolve("img"), currentUnix, languageType, storageS3FolderImage, s3FileMapping); |
|
|
setImgDescription(newImagesMap, img3Name, img3Description); |
|
|
setImgDescription(newImagesMap, img3Name, img3Description); |
|
|
|
|
|
|
|
|
|
|
|
if (MapUtils.isNotEmpty(newImagesMap)) { |
|
|
asset.setImagesIntroduction(JSON.toJSONString(newImagesMap)); |
|
|
asset.setImagesIntroduction(JSON.toJSONString(newImagesMap)); |
|
|
|
|
|
// 处理图片
|
|
|
|
|
|
String oldImagesIntroduction = oldAsset.getImagesIntroduction(); |
|
|
|
|
|
if(StringUtils.isNotBlank(oldImagesIntroduction)) { |
|
|
|
|
|
Map<String, S3FileInfoEntity> oldImages = JSON.parseObject(oldImagesIntroduction, new TypeReference<Map<String, S3FileInfoEntity>>() {}); |
|
|
|
|
|
for (Map.Entry<String, S3FileInfoEntity> entry : oldImages.entrySet()) { |
|
|
|
|
|
commonOpt.deleteS3File(entry.getValue().getS3Path()); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// 处理PDF
|
|
|
// 处理PDF
|
|
|
processAndSetPdfEquipment(asset, oldAsset, row, columnIndices, languageType, baseDir, currentUnix, "userManual", |
|
|
processAndSetPdfEquipment(asset, oldAsset, row, columnIndices, languageType, baseDir, currentUnix, "userManual", |
|
|
@ -286,7 +294,9 @@ public class AsyncExcelProcessingService { |
|
|
"getPdfDeviceImage", "setPdfDeviceImage", s3FileMapping, storageS3FolderPdf); |
|
|
"getPdfDeviceImage", "setPdfDeviceImage", s3FileMapping, storageS3FolderPdf); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (CommonUtil.hasAnyOtherFieldNotEmpty(asset, "equipmentId")) { |
|
|
basicMonitoringAssetMapperExt.updateByPrimaryKeySelective(asset); |
|
|
basicMonitoringAssetMapperExt.updateByPrimaryKeySelective(asset); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -309,23 +319,24 @@ public class AsyncExcelProcessingService { |
|
|
private void processAndSetPdfEquipment(BasicMonitoringAsset asset, MonitoringAssetPageVO oldAsset, Row row, Map<String, Integer> columnIndices, |
|
|
private void processAndSetPdfEquipment(BasicMonitoringAsset asset, MonitoringAssetPageVO oldAsset, Row row, Map<String, Integer> columnIndices, |
|
|
Integer languageType, Path baseDir, long currentUnix, String equipmentType, |
|
|
Integer languageType, Path baseDir, long currentUnix, String equipmentType, |
|
|
String getterMethod, String setterMethod, Map<String, String> s3FileMapping, String storageS3FolderPdf) throws Exception { |
|
|
String getterMethod, String setterMethod, Map<String, String> s3FileMapping, String storageS3FolderPdf) throws Exception { |
|
|
// 获取旧设备数据
|
|
|
|
|
|
String oldPdfEquipment = (String) oldAsset.getClass().getMethod(getterMethod).invoke(oldAsset); |
|
|
|
|
|
if (StringUtils.isNotBlank(oldPdfEquipment)) { |
|
|
|
|
|
Map<String, S3FileInfoEntity> oldPdfEquipmentMap = JSON.parseObject(oldPdfEquipment, new TypeReference<Map<String, S3FileInfoEntity>>() {}); |
|
|
|
|
|
for (Map.Entry<String, S3FileInfoEntity> entry : oldPdfEquipmentMap.entrySet()) { |
|
|
|
|
|
commonOpt.deleteS3File(entry.getValue().getS3Path()); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 处理文件
|
|
|
// 处理文件
|
|
|
Map<String, S3FileInfoEntity> newPdfEquipmentMap = new HashMap<>(); |
|
|
Map<String, S3FileInfoEntity> newPdfEquipmentMap = new HashMap<>(); |
|
|
commonOpt.processFile(newPdfEquipmentMap, |
|
|
commonOpt.processFile(newPdfEquipmentMap, |
|
|
commonOpt.getCellValue(row.getCell(columnIndices.get(msgLanguageChange.getParameterMapByCode(languageType, equipmentType)))), |
|
|
commonOpt.getCellValue(row.getCell(columnIndices.get(msgLanguageChange.getParameterMapByCode(languageType, equipmentType)))), |
|
|
baseDir.resolve("pdf"), currentUnix, languageType, storageS3FolderPdf, s3FileMapping); |
|
|
baseDir.resolve("pdf"), currentUnix, languageType, storageS3FolderPdf, s3FileMapping); |
|
|
|
|
|
if (MapUtils.isNotEmpty(newPdfEquipmentMap)) { |
|
|
// 设置更新后的设备数据
|
|
|
// 设置更新后的设备数据
|
|
|
asset.getClass().getMethod(setterMethod, String.class).invoke(asset, JSON.toJSONString(newPdfEquipmentMap)); |
|
|
asset.getClass().getMethod(setterMethod, String.class).invoke(asset, JSON.toJSONString(newPdfEquipmentMap)); |
|
|
|
|
|
|
|
|
|
|
|
// 删除旧设备数据
|
|
|
|
|
|
String oldPdfEquipment = (String) oldAsset.getClass().getMethod(getterMethod).invoke(oldAsset); |
|
|
|
|
|
if (StringUtils.isNotBlank(oldPdfEquipment)) { |
|
|
|
|
|
Map<String, S3FileInfoEntity> oldPdfEquipmentMap = JSON.parseObject(oldPdfEquipment, new TypeReference<Map<String, S3FileInfoEntity>>() {}); |
|
|
|
|
|
for (Map.Entry<String, S3FileInfoEntity> entry : oldPdfEquipmentMap.entrySet()) { |
|
|
|
|
|
commonOpt.deleteS3File(entry.getValue().getS3Path()); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|