package org.springblade.mdm.commons.service; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; /** * 机床路径转换器,从Z盘这种目录转换为网络目录格式入:\\192.168.233.2\Workshop */ @Component public class MachineDirTranslator { @Autowired private DirTransProperties transProperties; public String trans(String path){ if(StringUtils.isBlank(transProperties.getTargetDirPrefix()) || !StringUtils.startsWithIgnoreCase(path,transProperties.getOriDirPrefix())){ return path; } String finalDir = transProperties.getTargetDirPrefix()+StringUtils.removeStartIgnoreCase(path,transProperties.getOriDirPrefix()); return finalDir; } }