Merge remote-tracking branch 'origin/master'

master
yangwl 3 years ago
commit 5eb5482097

@ -56,6 +56,22 @@ public class FileController {
return R.failed("获取图纸路径失败:"+e.getMessage()); return R.failed("获取图纸路径失败:"+e.getMessage());
} }
} }
/**
* -
* @return
*/
@ResponseBody
@RequestMapping(method = RequestMethod.GET, value = "/getPdfPathByItem")
public R getPdfPathByItemBo(String itemBo) {
try {
if(StringUtils.isBlank(itemBo)){
throw new BaseException("物料编码不能为空!");
}
return R.ok(fileService.getFilePathsByItemBo(itemBo));
}catch (Exception e){
return R.failed("获取图纸路径失败:"+e.getMessage());
}
}
/** /**
* *

@ -8,4 +8,5 @@ import java.util.Map;
public interface FileService { public interface FileService {
Map<String,String> getFilePaths(String sfc) throws Exception; Map<String,String> getFilePaths(String sfc) throws Exception;
Map<String,String> getFilePathsByItemBo(String itemBo) throws Exception;
} }

@ -61,4 +61,35 @@ public class FileServiceImpl implements FileService {
return pathMap; return pathMap;
} }
@Override
public Map<String, String> getFilePathsByItemBo(String itemBo) throws IOException {
String path="/"+ StringUtil.trimHandle(itemBo)+"_"+StringUtil.trimRevision(itemBo)+"/";
FTPClient connect = null;
Map<String,String> pathMap = new HashMap<>();
try {
connect = cappFtpClient.login();
connect.changeWorkingDirectory(path);
connect.enterLocalPassiveMode();
FTPFile[] files = connect.listFiles();
if(files!=null){
for (int i = 0; i < files.length; i++) {
if(files[i].isFile()){
String filename=files[i].getName();
pathMap.put(filename,path+filename);
}
}
}
connect.disconnect();
}catch (Exception e){
ExceptionUtil.throwException(e);
}finally {
if (connect!=null&&connect.isConnected()){
connect.logout();
connect.disconnect();
}
}
return pathMap;
}
} }

Loading…
Cancel
Save