|
|
@ -1,6 +1,8 @@ |
|
|
|
package org.nl.wms.sch.task_manage; |
|
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil; |
|
|
|
import cn.hutool.core.io.FileUtil; |
|
|
|
import cn.hutool.core.util.ObjectUtil; |
|
|
|
import cn.hutool.core.util.StrUtil; |
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
import lombok.SneakyThrows; |
|
|
@ -36,18 +38,16 @@ public class AutoQueryFilePath { |
|
|
|
|
|
|
|
@SneakyThrows |
|
|
|
public void run() { |
|
|
|
List<SchBaseVehiclematerialgroup> schBaseVehiclematerialgroups = iSchBaseVehiclematerialgroupService.selectMaterialPathIsEmpty(); |
|
|
|
if(StrUtil.isEmpty(materialUrl)){ |
|
|
|
List<String> materials = iSchBaseVehiclematerialgroupService.selectMaterialPathIsEmpty(); |
|
|
|
if(StrUtil.isEmpty(materialUrl)) { |
|
|
|
Param byCode = sysParamService.findByCode(GeneralDefinition.MATERIAL_URL); |
|
|
|
materialUrl = byCode.getValue(); |
|
|
|
directory = new File(materialUrl); |
|
|
|
} |
|
|
|
if (StrUtil.isNotEmpty(materialUrl)) { |
|
|
|
schBaseVehiclematerialgroups.stream().forEach(schBaseVehiclematerialgroup -> { |
|
|
|
if (directory.exists() && directory.isDirectory()) { |
|
|
|
selectMaterialPath(directory, schBaseVehiclematerialgroup); |
|
|
|
} |
|
|
|
}); |
|
|
|
if (ObjectUtil.isNotEmpty(directory) && CollUtil.isNotEmpty(materials)) { |
|
|
|
if (directory.exists() && directory.isDirectory()) { |
|
|
|
selectMaterialPath(directory, materials); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@ -55,19 +55,20 @@ public class AutoQueryFilePath { |
|
|
|
/** |
|
|
|
* 查找物料图片路径 |
|
|
|
*/ |
|
|
|
public void selectMaterialPath(File directory,SchBaseVehiclematerialgroup schBaseVehiclematerialgroup) { |
|
|
|
public void selectMaterialPath(File directory,List<String> materials) { |
|
|
|
File[] files = directory.listFiles(); |
|
|
|
if (files != null) { |
|
|
|
for (File file : files) { |
|
|
|
if (file.isDirectory()) { |
|
|
|
selectMaterialPath(file,schBaseVehiclematerialgroup); |
|
|
|
} else if (file.isFile() && file.getName().substring(0, file.getName().lastIndexOf('.')).equals(schBaseVehiclematerialgroup.getMaterial_id())) { |
|
|
|
selectMaterialPath(file,materials); |
|
|
|
} else if (file.isFile() && CollUtil.contains(materials, file.getName().substring(0, file.getName().lastIndexOf('.')))) { |
|
|
|
String material = file.getName().substring(0, file.getName().lastIndexOf('.')); |
|
|
|
File parentFile = file.getParentFile(); |
|
|
|
if(parentFile != null) { |
|
|
|
String name = parentFile.getName(); |
|
|
|
if (StrUtil.isNotEmpty(name)) { |
|
|
|
iSchBaseVehiclematerialgroupService.update(Wrappers.lambdaUpdate(SchBaseVehiclematerialgroup.class) |
|
|
|
.eq(SchBaseVehiclematerialgroup::getGroup_id, schBaseVehiclematerialgroup.getGroup_id()) |
|
|
|
.eq(SchBaseVehiclematerialgroup::getMaterial_id, material) |
|
|
|
.set(SchBaseVehiclematerialgroup::getMaterial_path, parentFile.getPath() + "\\" + name + "_large.png")); |
|
|
|
break; |
|
|
|
} |
|
|
|