fix(material): 优化物料图片上传和更新逻辑,调整上传大小限制
- 将服务器表单最大上传大小调至200MB,支持更大文件上传 - 修改multipart配置,最大文件及请求大小均设为200MB - 优化MaterialControllerService中物料图片处理逻辑 - 如果已存在旧物料且图片字段非空,执行更新图片操作 - 修改MaterialZipImportProcessor中图片上传,增加异常捕获和日志 - 新增图片上传成功后判断,支持新增或更新物料图片记录 - 添加保存和更新操作的成功失败日志反馈
This commit is contained in:
parent
ce415b718a
commit
6b273ded7f
|
|
@ -161,17 +161,24 @@ public class MaterialControllerService {
|
||||||
if (Objects.isNull(bomMaterialDTO)) {
|
if (Objects.isNull(bomMaterialDTO)) {
|
||||||
pics.add(name);
|
pics.add(name);
|
||||||
} else {
|
} else {
|
||||||
WmsMaterial old = materialService.getCurrent(materialNo);
|
|
||||||
String url = fileUploadService.upload(buildFilePath(name), file);
|
String url = fileUploadService.upload(buildFilePath(name), file);
|
||||||
WmsMaterial material = new WmsMaterial()
|
WmsMaterial old = materialService.getCurrent(materialNo);
|
||||||
.setVersion(Objects.isNull(old) ? 1 : old.getVersion() + 1)
|
if (Objects.isNull(old) || StrUtil.isNotBlank(old.getImage())) {
|
||||||
.setNo(bomMaterialDTO.getMaterialNo())
|
WmsMaterial material = new WmsMaterial()
|
||||||
.setDescribe(bomMaterialDTO.getMaterialDesc())
|
.setVersion(Objects.isNull(old) ? 1 : old.getVersion() + 1)
|
||||||
.setDrawingNo(bomMaterialDTO.getDrawingNo())
|
.setNo(bomMaterialDTO.getMaterialNo())
|
||||||
.setImage(url)
|
.setDescribe(bomMaterialDTO.getMaterialDesc())
|
||||||
.setCreateBy(UserUtil.getUserName())
|
.setDrawingNo(bomMaterialDTO.getDrawingNo())
|
||||||
.setCreateTime(LocalDateTime.now());
|
.setImage(url)
|
||||||
materials.add(material);
|
.setCreateBy(UserUtil.getUserName())
|
||||||
|
.setCreateTime(LocalDateTime.now());
|
||||||
|
materials.add(material);
|
||||||
|
} else {
|
||||||
|
old.setImage(url);
|
||||||
|
old.setUpdateBy(UserUtil.getUserName());
|
||||||
|
old.setUpdateTime(LocalDateTime.now());
|
||||||
|
materials.add(old);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (CollectionUtil.isEmpty(pics)) {
|
if (CollectionUtil.isEmpty(pics)) {
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
server:
|
server:
|
||||||
port: 8102
|
port: 8102
|
||||||
tomcat:
|
tomcat:
|
||||||
max-http-form-post-size: 50MB
|
max-http-form-post-size: 200MB
|
||||||
spring:
|
spring:
|
||||||
main:
|
main:
|
||||||
allow-bean-definition-overriding: true
|
allow-bean-definition-overriding: true
|
||||||
|
|
@ -23,8 +23,8 @@ spring:
|
||||||
group: ${spring.profiles.active}
|
group: ${spring.profiles.active}
|
||||||
servlet:
|
servlet:
|
||||||
multipart:
|
multipart:
|
||||||
max-file-size: 30MB
|
max-file-size: 200MB
|
||||||
max-request-size: 50MB
|
max-request-size: 200MB
|
||||||
logging:
|
logging:
|
||||||
level:
|
level:
|
||||||
root: info
|
root: info
|
||||||
|
|
|
||||||
|
|
@ -68,26 +68,39 @@ public class MaterialZipImportProcessor implements BasicProcessor {
|
||||||
if (Objects.isNull(bomMaterialDTO)) {
|
if (Objects.isNull(bomMaterialDTO)) {
|
||||||
omsLogger.error("主数据中未查找到该物料:{}", materialNo);
|
omsLogger.error("主数据中未查找到该物料:{}", materialNo);
|
||||||
} else {
|
} else {
|
||||||
omsLogger.info("添加图纸");
|
String picUrl = "";
|
||||||
WmsMaterial old = materialService.getCurrent(materialNo);
|
|
||||||
WmsMaterial material = new WmsMaterial()
|
|
||||||
.setVersion(Objects.isNull(old) ? 1 : old.getVersion() + 1)
|
|
||||||
.setNo(bomMaterialDTO.getMaterialNo())
|
|
||||||
.setDescribe(bomMaterialDTO.getMaterialDesc())
|
|
||||||
.setDrawingNo(bomMaterialDTO.getDrawingNo())
|
|
||||||
.setCreateBy(userName)
|
|
||||||
.setCreateTime(LocalDateTime.now());
|
|
||||||
try (ByteArrayInputStream isIn = new ByteArrayInputStream(osOut.toByteArray())) {
|
try (ByteArrayInputStream isIn = new ByteArrayInputStream(osOut.toByteArray())) {
|
||||||
String picUrl = fileUploadService.upload(buildFilePath(name), isIn, MediaType.IMAGE_JPEG_VALUE);
|
picUrl = fileUploadService.upload(buildFilePath(name), isIn, MediaType.IMAGE_JPEG_VALUE);
|
||||||
omsLogger.info("上传后的图片地址:{}", picUrl);
|
omsLogger.info("上传后的图片地址:{}", picUrl);
|
||||||
material.setImage(picUrl);
|
} catch (Exception ex) {
|
||||||
|
omsLogger.error("上传图片失败:{}", ex.getMessage());
|
||||||
|
}
|
||||||
|
WmsMaterial old = materialService.getCurrent(materialNo);
|
||||||
|
if (Objects.isNull(old) || StrUtil.isNotBlank(old.getImage())) {
|
||||||
|
omsLogger.info("添加图纸");
|
||||||
|
WmsMaterial material = new WmsMaterial()
|
||||||
|
.setVersion(Objects.isNull(old) ? 1 : old.getVersion() + 1)
|
||||||
|
.setNo(bomMaterialDTO.getMaterialNo())
|
||||||
|
.setDescribe(bomMaterialDTO.getMaterialDesc())
|
||||||
|
.setDrawingNo(bomMaterialDTO.getDrawingNo())
|
||||||
|
.setImage(picUrl)
|
||||||
|
.setCreateBy(userName)
|
||||||
|
.setCreateTime(LocalDateTime.now());
|
||||||
if (materialService.save(material)) {
|
if (materialService.save(material)) {
|
||||||
omsLogger.info("保存成功,id:" + material.getId());
|
omsLogger.info("保存成功,id:" + material.getId());
|
||||||
} else {
|
} else {
|
||||||
omsLogger.error("保存失败");
|
omsLogger.error("保存失败");
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} else {
|
||||||
omsLogger.error("上传图片失败:{}", ex.getMessage());
|
omsLogger.info("更新图纸");
|
||||||
|
old.setImage(picUrl);
|
||||||
|
old.setUpdateBy(userName);
|
||||||
|
old.setUpdateTime(LocalDateTime.now());
|
||||||
|
if (materialService.updateById(old)) {
|
||||||
|
omsLogger.info("更新成功,id:" + old.getId());
|
||||||
|
} else {
|
||||||
|
omsLogger.error("更新失败");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue