Browse Source

fix: 解决表格导出无图片时内容为空的问题

zhongwei
liwen 11 months ago
parent
commit
8cd1740352
  1. 7
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CarMaintenanceServiceImpl.java
  2. 7
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CarUsedRecordServiceImpl.java
  3. 7
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/ConferenceRecordServiceImpl.java
  4. 7
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/RehearsalRecordServiceImpl.java
  5. 7
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/TrainRecordServiceImpl.java
  6. BIN
      hzims-service/safeproduct/src/main/resources/template/演练记录表.docx
  7. BIN
      hzims-service/safeproduct/src/main/resources/template/用车记录单.docx
  8. BIN
      hzims-service/safeproduct/src/main/resources/template/车辆检查表.docx

7
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CarMaintenanceServiceImpl.java

@ -121,16 +121,19 @@ public class CarMaintenanceServiceImpl extends ServiceImpl<CarMaintenanceMapper,
CarMaintenanceDetailVO carMaintenanceDetailVO = this.getCarMaintenance(id); CarMaintenanceDetailVO carMaintenanceDetailVO = this.getCarMaintenance(id);
// 数据处理 // 数据处理
// 图片 // 图片
List<ImageEntity> list = new ArrayList<>();
if (StringUtils.isNotEmpty(carMaintenanceDetailVO.getImgPath())) { if (StringUtils.isNotEmpty(carMaintenanceDetailVO.getImgPath())) {
String[] imgArr = carMaintenanceDetailVO.getImgPath().split(","); String[] imgArr = carMaintenanceDetailVO.getImgPath().split(",");
List<ImageEntity> list = new ArrayList<>();
for (String img : imgArr) { for (String img : imgArr) {
ImageEntity imageEntity = new ImageEntity(BaseUtil.imgToByte(savePath + ImageEntity imageEntity = new ImageEntity(BaseUtil.imgToByte(savePath +
BaseUtil.downloadFileByUrl(img, savePath)), 180, 150); BaseUtil.downloadFileByUrl(img, savePath)), 180, 150);
list.add(imageEntity); list.add(imageEntity);
} }
carMaintenanceDetailVO.setImages(list); } else {
// 添加空的ImageEntity,防止数据填入时显示"{{"
list.add(new ImageEntity());
} }
carMaintenanceDetailVO.setImages(list);
// 表头年月 // 表头年月
String code = carMaintenanceDetailVO.getCode(); String code = carMaintenanceDetailVO.getCode();
carMaintenanceDetailVO.setYear(code.substring(4, 8)); carMaintenanceDetailVO.setYear(code.substring(4, 8));

7
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CarUsedRecordServiceImpl.java

@ -118,16 +118,19 @@ public class CarUsedRecordServiceImpl extends ServiceImpl<CarUsedRecordMapper, C
CarUsedRecordDetailVO carUsedRecordDetailVO = this.getCarUsedRecord(id); CarUsedRecordDetailVO carUsedRecordDetailVO = this.getCarUsedRecord(id);
// 数据处理 // 数据处理
// 图片 // 图片
List<ImageEntity> list = new ArrayList<>();
if (StringUtils.isNotEmpty(carUsedRecordDetailVO.getImgPath())) { if (StringUtils.isNotEmpty(carUsedRecordDetailVO.getImgPath())) {
String[] imgArr = carUsedRecordDetailVO.getImgPath().split(","); String[] imgArr = carUsedRecordDetailVO.getImgPath().split(",");
List<ImageEntity> list = new ArrayList<>();
for (String img : imgArr) { for (String img : imgArr) {
ImageEntity imageEntity = new ImageEntity(BaseUtil.imgToByte(savePath + ImageEntity imageEntity = new ImageEntity(BaseUtil.imgToByte(savePath +
BaseUtil.downloadFileByUrl(img, savePath)), 180, 150); BaseUtil.downloadFileByUrl(img, savePath)), 180, 150);
list.add(imageEntity); list.add(imageEntity);
} }
carUsedRecordDetailVO.setImages(list); } else {
// 添加空的ImageEntity,防止数据填入时显示"{{"
list.add(new ImageEntity());
} }
carUsedRecordDetailVO.setImages(list);
// 表头年月 // 表头年月
String code = carUsedRecordDetailVO.getCode(); String code = carUsedRecordDetailVO.getCode();
carUsedRecordDetailVO.setYear(code.substring(4, 8)); carUsedRecordDetailVO.setYear(code.substring(4, 8));

7
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/ConferenceRecordServiceImpl.java

@ -109,16 +109,19 @@ public class ConferenceRecordServiceImpl extends ServiceImpl<ConferenceRecordMap
conferenceRecordDetailVO.setYear(code.substring(4, 8)); conferenceRecordDetailVO.setYear(code.substring(4, 8));
conferenceRecordDetailVO.setMonth(code.substring(8, 10)); conferenceRecordDetailVO.setMonth(code.substring(8, 10));
// 图片 // 图片
List<ImageEntity> list = new ArrayList<>();
if (StringUtils.isNotEmpty(conferenceRecordDetailVO.getImgPath())) { if (StringUtils.isNotEmpty(conferenceRecordDetailVO.getImgPath())) {
String[] imgArr = conferenceRecordDetailVO.getImgPath().split(","); String[] imgArr = conferenceRecordDetailVO.getImgPath().split(",");
List<ImageEntity> list = new ArrayList<>();
for (String img : imgArr) { for (String img : imgArr) {
ImageEntity imageEntity = new ImageEntity(BaseUtil.imgToByte(savePath + ImageEntity imageEntity = new ImageEntity(BaseUtil.imgToByte(savePath +
BaseUtil.downloadFileByUrl(img, savePath)), 180, 150); BaseUtil.downloadFileByUrl(img, savePath)), 180, 150);
list.add(imageEntity); list.add(imageEntity);
} }
conferenceRecordDetailVO.setImages(list); } else {
// 添加空的ImageEntity,防止数据填入时显示"{{"
list.add(new ImageEntity());
} }
conferenceRecordDetailVO.setImages(list);
Map<String, Object> params = BaseUtil.obj2Map(conferenceRecordDetailVO); Map<String, Object> params = BaseUtil.obj2Map(conferenceRecordDetailVO);
String templateFile = "template/会议记录表" + SafeProductConstant.DOCX_SUFFIX; String templateFile = "template/会议记录表" + SafeProductConstant.DOCX_SUFFIX;
String wordPath = savePath + "/会议记录表" + SafeProductConstant.DOCX_SUFFIX; String wordPath = savePath + "/会议记录表" + SafeProductConstant.DOCX_SUFFIX;

7
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/RehearsalRecordServiceImpl.java

@ -140,16 +140,19 @@ public class RehearsalRecordServiceImpl extends ServiceImpl<RehearsalRecordMappe
RehearsalRecordDetailVO rehearsalRecordDetailVO = this.getRecordDetailVOById(id); RehearsalRecordDetailVO rehearsalRecordDetailVO = this.getRecordDetailVOById(id);
// 数据处理 // 数据处理
// 图片 // 图片
List<ImageEntity> list = new ArrayList<>();
if (StringUtils.isNotEmpty(rehearsalRecordDetailVO.getImgPath())) { if (StringUtils.isNotEmpty(rehearsalRecordDetailVO.getImgPath())) {
String[] imgArr = rehearsalRecordDetailVO.getImgPath().split(","); String[] imgArr = rehearsalRecordDetailVO.getImgPath().split(",");
List<ImageEntity> list = new ArrayList<>();
for (String img : imgArr) { for (String img : imgArr) {
ImageEntity imageEntity = new ImageEntity(BaseUtil.imgToByte(savePath + ImageEntity imageEntity = new ImageEntity(BaseUtil.imgToByte(savePath +
BaseUtil.downloadFileByUrl(img, savePath)), 180, 150); BaseUtil.downloadFileByUrl(img, savePath)), 180, 150);
list.add(imageEntity); list.add(imageEntity);
} }
rehearsalRecordDetailVO.setImages(list); } else {
// 添加空的ImageEntity,防止数据填入时显示"{{"
list.add(new ImageEntity());
} }
rehearsalRecordDetailVO.setImages(list);
// 表头年月 // 表头年月
String code = rehearsalRecordDetailVO.getCode(); String code = rehearsalRecordDetailVO.getCode();
rehearsalRecordDetailVO.setYear(code.substring(4, 8)); rehearsalRecordDetailVO.setYear(code.substring(4, 8));

7
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/TrainRecordServiceImpl.java

@ -153,16 +153,19 @@ public class TrainRecordServiceImpl extends ServiceImpl<TrainRecordMapper, Train
trainRecordDetailVO.setTrainMethod(TrainMethodEnum.OFFLINE.getDesc()); trainRecordDetailVO.setTrainMethod(TrainMethodEnum.OFFLINE.getDesc());
} }
// 图片 // 图片
List<ImageEntity> list = new ArrayList<>();
if (StringUtils.isNotEmpty(trainRecordDetailVO.getImgPath())) { if (StringUtils.isNotEmpty(trainRecordDetailVO.getImgPath())) {
String[] imgArr = trainRecordDetailVO.getImgPath().split(","); String[] imgArr = trainRecordDetailVO.getImgPath().split(",");
List<ImageEntity> list = new ArrayList<>();
for (String img : imgArr) { for (String img : imgArr) {
ImageEntity imageEntity = new ImageEntity(BaseUtil.imgToByte(savePath + ImageEntity imageEntity = new ImageEntity(BaseUtil.imgToByte(savePath +
BaseUtil.downloadFileByUrl(img, savePath)), 180, 150); BaseUtil.downloadFileByUrl(img, savePath)), 180, 150);
list.add(imageEntity); list.add(imageEntity);
} }
trainRecordDetailVO.setImages(list); } else {
// 添加空的ImageEntity,防止数据填入时显示"{{"
list.add(new ImageEntity());
} }
trainRecordDetailVO.setImages(list);
// 表头年月 // 表头年月
String code = trainRecordDetailVO.getCode(); String code = trainRecordDetailVO.getCode();
trainRecordDetailVO.setYear(code.substring(4, 8)); trainRecordDetailVO.setYear(code.substring(4, 8));

BIN
hzims-service/safeproduct/src/main/resources/template/演练记录表.docx

Binary file not shown.

BIN
hzims-service/safeproduct/src/main/resources/template/用车记录单.docx

Binary file not shown.

BIN
hzims-service/safeproduct/src/main/resources/template/车辆检查表.docx

Binary file not shown.
Loading…
Cancel
Save