feat: 图纸导入调整,如果导入的是图片,则每次都新增版本,如果是excel则逻辑不变
This commit is contained in:
parent
a5ab1f9538
commit
1e2e8cdb88
|
|
@ -161,26 +161,17 @@ public class MaterialControllerService {
|
||||||
if (Objects.isNull(bomMaterialDTO)) {
|
if (Objects.isNull(bomMaterialDTO)) {
|
||||||
pics.add(name);
|
pics.add(name);
|
||||||
} else {
|
} else {
|
||||||
WmsMaterial wmsMaterial = materialService.getCurrent(materialNo);
|
WmsMaterial old = materialService.getCurrent(materialNo);
|
||||||
if (Objects.isNull(wmsMaterial) || wmsMaterial.getComplete())
|
String url = fileUploadService.upload(buildFilePath(name), file);
|
||||||
{
|
WmsMaterial material = new WmsMaterial()
|
||||||
wmsMaterial = new WmsMaterial()
|
.setVersion(Objects.isNull(old) ? 1 : old.getVersion() + 1)
|
||||||
.setId(null)
|
|
||||||
.setVersion(Objects.isNull(wmsMaterial) ? 1 : wmsMaterial.getVersion() + 1)
|
|
||||||
.setNo(bomMaterialDTO.getMaterialNo())
|
.setNo(bomMaterialDTO.getMaterialNo())
|
||||||
.setDescribe(bomMaterialDTO.getMaterialDesc())
|
.setDescribe(bomMaterialDTO.getMaterialDesc())
|
||||||
.setDrawingNo(bomMaterialDTO.getDrawingNo())
|
.setDrawingNo(bomMaterialDTO.getDrawingNo())
|
||||||
|
.setImage(url)
|
||||||
.setCreateBy(UserUtil.getUserName())
|
.setCreateBy(UserUtil.getUserName())
|
||||||
.setCreateTime(LocalDateTime.now());
|
.setCreateTime(LocalDateTime.now());
|
||||||
}else{
|
materials.add(material);
|
||||||
wmsMaterial.setDescribe(bomMaterialDTO.getMaterialDesc());
|
|
||||||
wmsMaterial.setDrawingNo(bomMaterialDTO.getDrawingNo());
|
|
||||||
wmsMaterial.setUpdateBy(UserUtil.getUserName());
|
|
||||||
wmsMaterial.setUpdateTime(LocalDateTime.now());
|
|
||||||
}
|
|
||||||
String url = fileUploadService.upload(buildFilePath(name), file);
|
|
||||||
wmsMaterial.setImage(url);
|
|
||||||
materials.add(wmsMaterial);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (CollectionUtil.isEmpty(pics)) {
|
if (CollectionUtil.isEmpty(pics)) {
|
||||||
|
|
|
||||||
|
|
@ -43,9 +43,9 @@ public class MaterialZipImportProcessor implements BasicProcessor {
|
||||||
@Override
|
@Override
|
||||||
public ProcessResult process(TaskContext context) throws Exception {
|
public ProcessResult process(TaskContext context) throws Exception {
|
||||||
OmsLogger omsLogger = context.getOmsLogger();
|
OmsLogger omsLogger = context.getOmsLogger();
|
||||||
List<String> params=StrUtil.split(context.getInstanceParams(), "|");
|
List<String> params = StrUtil.split(context.getInstanceParams(), "|");
|
||||||
String zipUrl=params.get(0);
|
String zipUrl = params.get(0);
|
||||||
String userName= params.get(1);
|
String userName = params.get(1);
|
||||||
if (StrUtil.isBlank(zipUrl)) {
|
if (StrUtil.isBlank(zipUrl)) {
|
||||||
omsLogger.error("无效的zip地址");
|
omsLogger.error("无效的zip地址");
|
||||||
return new ProcessResult(false, "无效的zip地址");
|
return new ProcessResult(false, "无效的zip地址");
|
||||||
|
|
@ -54,7 +54,7 @@ public class MaterialZipImportProcessor implements BasicProcessor {
|
||||||
ZipEntry entry;
|
ZipEntry entry;
|
||||||
while ((entry = zis.getNextEntry()) != null) {
|
while ((entry = zis.getNextEntry()) != null) {
|
||||||
String name = entry.getName();
|
String name = entry.getName();
|
||||||
omsLogger.info("开始处理文件:{}",name);
|
omsLogger.info("开始处理文件:{}", name);
|
||||||
if (!entry.isDirectory()) {
|
if (!entry.isDirectory()) {
|
||||||
ByteArrayOutputStream osOut = new ByteArrayOutputStream();
|
ByteArrayOutputStream osOut = new ByteArrayOutputStream();
|
||||||
byte[] buffer = new byte[1024];
|
byte[] buffer = new byte[1024];
|
||||||
|
|
@ -68,34 +68,25 @@ public class MaterialZipImportProcessor implements BasicProcessor {
|
||||||
if (Objects.isNull(bomMaterialDTO)) {
|
if (Objects.isNull(bomMaterialDTO)) {
|
||||||
omsLogger.error("主数据中未查找到该物料:{}", materialNo);
|
omsLogger.error("主数据中未查找到该物料:{}", materialNo);
|
||||||
} else {
|
} else {
|
||||||
WmsMaterial wmsMaterial = materialService.getCurrent(materialNo);
|
|
||||||
if (Objects.isNull(wmsMaterial) || wmsMaterial.getComplete()) {
|
|
||||||
omsLogger.info("添加图纸");
|
omsLogger.info("添加图纸");
|
||||||
wmsMaterial = new WmsMaterial()
|
WmsMaterial old = materialService.getCurrent(materialNo);
|
||||||
.setId(null)
|
WmsMaterial material = new WmsMaterial()
|
||||||
.setVersion(Objects.isNull(wmsMaterial) ? 1 : wmsMaterial.getVersion() + 1)
|
.setVersion(Objects.isNull(old) ? 1 : old.getVersion() + 1)
|
||||||
.setNo(bomMaterialDTO.getMaterialNo())
|
.setNo(bomMaterialDTO.getMaterialNo())
|
||||||
.setDescribe(bomMaterialDTO.getMaterialDesc())
|
.setDescribe(bomMaterialDTO.getMaterialDesc())
|
||||||
.setDrawingNo(bomMaterialDTO.getDrawingNo())
|
.setDrawingNo(bomMaterialDTO.getDrawingNo())
|
||||||
.setCreateBy(userName)
|
.setCreateBy(userName)
|
||||||
.setCreateTime(LocalDateTime.now());
|
.setCreateTime(LocalDateTime.now());
|
||||||
} else {
|
try (ByteArrayInputStream isIn = new ByteArrayInputStream(osOut.toByteArray())) {
|
||||||
omsLogger.info("更新图纸");
|
|
||||||
wmsMaterial.setDescribe(bomMaterialDTO.getMaterialDesc());
|
|
||||||
wmsMaterial.setDrawingNo(bomMaterialDTO.getDrawingNo());
|
|
||||||
wmsMaterial.setUpdateBy(userName);
|
|
||||||
wmsMaterial.setUpdateTime(LocalDateTime.now());
|
|
||||||
}
|
|
||||||
try(ByteArrayInputStream isIn = new ByteArrayInputStream(osOut.toByteArray())) {
|
|
||||||
String picUrl = fileUploadService.upload(buildFilePath(name), isIn, MediaType.IMAGE_JPEG_VALUE);
|
String picUrl = fileUploadService.upload(buildFilePath(name), isIn, MediaType.IMAGE_JPEG_VALUE);
|
||||||
omsLogger.info("上传后的图片地址:{}", picUrl);
|
omsLogger.info("上传后的图片地址:{}", picUrl);
|
||||||
wmsMaterial.setImage(picUrl);
|
material.setImage(picUrl);
|
||||||
if (materialService.saveOrUpdate(wmsMaterial)){
|
if (materialService.save(material)) {
|
||||||
omsLogger.info("保存成功,id:"+wmsMaterial.getId());
|
omsLogger.info("保存成功,id:" + material.getId());
|
||||||
}else {
|
} else {
|
||||||
omsLogger.error("保存失败");
|
omsLogger.error("保存失败");
|
||||||
}
|
}
|
||||||
}catch (Exception ex){
|
} catch (Exception ex) {
|
||||||
omsLogger.error("上传图片失败:{}", ex.getMessage());
|
omsLogger.error("上传图片失败:{}", ex.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -109,7 +100,7 @@ public class MaterialZipImportProcessor implements BasicProcessor {
|
||||||
}
|
}
|
||||||
|
|
||||||
private String buildFilePath(String fileName) {
|
private String buildFilePath(String fileName) {
|
||||||
String fileType="." + FilenameUtils.getExtension(fileName);
|
String fileType = "." + FilenameUtils.getExtension(fileName);
|
||||||
return StrUtil.format("admin/task/{}/{}/{}{}", LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMdd"))
|
return StrUtil.format("admin/task/{}/{}/{}{}", LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMdd"))
|
||||||
, RandomUtil.randomString(4), IdUtil.fastUUID(), fileType);
|
, RandomUtil.randomString(4), IdUtil.fastUUID(), fileType);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue