diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/TrainRecordServiceImpl.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/TrainRecordServiceImpl.java index a5dbbc8..c51b5b2 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/TrainRecordServiceImpl.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/TrainRecordServiceImpl.java @@ -28,10 +28,7 @@ import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import javax.servlet.http.HttpServletResponse; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.stream.Collectors; /** @@ -141,7 +138,7 @@ public class TrainRecordServiceImpl extends ServiceImpl list = new ArrayList<>(); if (StringUtils.isNotEmpty(trainRecordDetailVO.getImgPath())) { - String[] imgArr = trainRecordDetailVO.getImgPath().split(","); - for (String img : imgArr) { - ImageEntity imageEntity = new ImageEntity(BaseUtil.imgToByte(savePath + - BaseUtil.downloadFileByUrl(img, savePath)), 180, 150); - list.add(imageEntity); - } + trainRecordDetailVO.setImages(Arrays.stream(trainRecordDetailVO.getImgPath().split(",")).map(img-> + new ImageEntity(BaseUtil.imgToByte(savePath + BaseUtil.downloadFileByUrl(img, savePath)), 180, 150) + ).collect(Collectors.toList())); } else { // 添加空的ImageEntity,防止数据填入时显示"{{" - list.add(new ImageEntity()); + trainRecordDetailVO.setImages(Collections.singletonList(new ImageEntity())); } - trainRecordDetailVO.setImages(list); // 表头年月 String code = trainRecordDetailVO.getCode(); trainRecordDetailVO.setYear(code.substring(4, 8));