yanps
3 days ago
16 changed files with 307 additions and 73 deletions
@ -0,0 +1,80 @@ |
|||||
|
package org.nl.wms.sch.task_manage; |
||||
|
|
||||
|
import cn.hutool.core.io.FileUtil; |
||||
|
import cn.hutool.core.util.StrUtil; |
||||
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
||||
|
import lombok.SneakyThrows; |
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
import org.nl.system.service.param.dao.Param; |
||||
|
import org.nl.system.service.param.impl.SysParamServiceImpl; |
||||
|
import org.nl.wms.sch.group.service.ISchBaseVehiclematerialgroupService; |
||||
|
import org.nl.wms.sch.group.service.dao.SchBaseVehiclematerialgroup; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.stereotype.Component; |
||||
|
|
||||
|
import java.io.File; |
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* 查询物料图片路径 |
||||
|
* |
||||
|
* @author LENOVO |
||||
|
*/ |
||||
|
@Slf4j |
||||
|
@Component |
||||
|
public class AutoQueryFilePath { |
||||
|
|
||||
|
@Autowired |
||||
|
private ISchBaseVehiclematerialgroupService iSchBaseVehiclematerialgroupService; |
||||
|
|
||||
|
@Autowired |
||||
|
private SysParamServiceImpl sysParamService; |
||||
|
|
||||
|
private String materialUrl = null; |
||||
|
|
||||
|
private File directory = null; |
||||
|
|
||||
|
@SneakyThrows |
||||
|
public void run() { |
||||
|
List<SchBaseVehiclematerialgroup> schBaseVehiclematerialgroups = 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); |
||||
|
} |
||||
|
}); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 查找物料图片路径 |
||||
|
*/ |
||||
|
public void selectMaterialPath(File directory,SchBaseVehiclematerialgroup schBaseVehiclematerialgroup) { |
||||
|
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())) { |
||||
|
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()) |
||||
|
.set(SchBaseVehiclematerialgroup::getMaterial_path, parentFile.getPath() + "\\" + name + "_large.png")); |
||||
|
break; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
} |
Loading…
Reference in new issue