Browse Source

fix: 修复演练记录表、培训记录表导出内容无法换行的问题

zhongwei
liwen 7 months ago
parent
commit
9ffcbe15ca
  1. 10
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/RehearsalRecordServiceImpl.java
  2. 6
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/TrainRecordServiceImpl.java

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

@ -141,14 +141,14 @@ public class RehearsalRecordServiceImpl extends ServiceImpl<RehearsalRecordMappe
public void exportRehearsalRecordData(Long id, HttpServletResponse response) { public void exportRehearsalRecordData(Long id, HttpServletResponse response) {
RehearsalRecordDetailVO rehearsalRecordDetailVO = this.getRecordDetailVOById(id); RehearsalRecordDetailVO rehearsalRecordDetailVO = this.getRecordDetailVOById(id);
// 数据处理 // 数据处理
// 图片 // 时间
if (StringUtils.isNotEmpty(rehearsalRecordDetailVO.getActualStartTime())){ if (StringUtils.isNotEmpty(rehearsalRecordDetailVO.getActualStartTime())){
rehearsalRecordDetailVO.setActualStartTime(TimeUtils.format(rehearsalRecordDetailVO.getActualStartTime())); rehearsalRecordDetailVO.setActualStartTime(TimeUtils.format(rehearsalRecordDetailVO.getActualStartTime()));
} }
if (StringUtils.isNotEmpty(rehearsalRecordDetailVO.getActualEndTime())){ if (StringUtils.isNotEmpty(rehearsalRecordDetailVO.getActualEndTime())){
rehearsalRecordDetailVO.setActualEndTime(TimeUtils.format(rehearsalRecordDetailVO.getActualEndTime())); rehearsalRecordDetailVO.setActualEndTime(TimeUtils.format(rehearsalRecordDetailVO.getActualEndTime()));
} }
// 图片
List<ImageEntity> list = new ArrayList<>(); 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(",");
@ -162,6 +162,12 @@ public class RehearsalRecordServiceImpl extends ServiceImpl<RehearsalRecordMappe
list.add(new ImageEntity()); list.add(new ImageEntity());
} }
rehearsalRecordDetailVO.setImages(list); rehearsalRecordDetailVO.setImages(list);
// 记录:换行符使用\r\n
String standardRecord = rehearsalRecordDetailVO.getRecord().replaceAll("\n", "\r\n");
rehearsalRecordDetailVO.setRecord(standardRecord);
// 评价:换行符使用\r\n
String standardComment = rehearsalRecordDetailVO.getComment().replaceAll("\n", "\r\n");
rehearsalRecordDetailVO.setComment(standardComment);
// 表头年月 // 表头年月
String code = rehearsalRecordDetailVO.getCode(); String code = rehearsalRecordDetailVO.getCode();
rehearsalRecordDetailVO.setYear(code.substring(4, 8)); rehearsalRecordDetailVO.setYear(code.substring(4, 8));

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

@ -157,6 +157,12 @@ public class TrainRecordServiceImpl extends ServiceImpl<TrainRecordMapper, Train
} else { } else {
trainRecordDetailVO.setTrainMethod(TrainMethodEnum.OFFLINE.getDesc()); trainRecordDetailVO.setTrainMethod(TrainMethodEnum.OFFLINE.getDesc());
} }
// 内容:换行符使用\r\n
String standardContent = trainRecordDetailVO.getContent().replaceAll("\n", "\r\n");
trainRecordDetailVO.setContent(standardContent);
// 评价:换行符使用\r\n
String standardCommand = trainRecordDetailVO.getCommand().replaceAll("\n", "\r\n");
trainRecordDetailVO.setCommand(standardCommand);
// 图片 // 图片
if (StringUtils.isNotEmpty(trainRecordDetailVO.getImgPath())) { if (StringUtils.isNotEmpty(trainRecordDetailVO.getImgPath())) {
trainRecordDetailVO.setImages(Arrays.stream(trainRecordDetailVO.getImgPath().split(",")).map(img-> trainRecordDetailVO.setImages(Arrays.stream(trainRecordDetailVO.getImgPath().split(",")).map(img->

Loading…
Cancel
Save