importClass(Packages.emro.util.StringUtil);
importClass(java.io.File);
importClass(java.text.SimpleDateFormat);
var _prList = $data.prList;
var exmld = $xmlManager.getDescriptor("attachment");
var AttFileDir = exmld.getDescriptorElement("path.file.store.root").getTextTrim();
var AttFileDirPR = exmld.getDescriptorElement("pr.att.file.root").getTextTrim();
var sdf = new SimpleDateFormat("yyyy.MM.dd HH:mm:ss");
var prRootDir = AttFileDir + AttFileDirPR;
var _fileList = new List();
var _exploredDir = new Array();
for (var i = 0; i < _prList.size(); i++)
{
var _prNo = _prList[i].pr_no;
// 탐색한 Dir 기록 있는지 찾기
var _dirs = _exploredDir.filter(function(data, index, array)
{
return data == _prNo;
});
// 탐색한 기록 있다면 Skip
if (_dirs.length > 0) continue;
// 탐색하는 Dir 기록
_exploredDir.push(_prNo);
var prDir = new File(prRootDir + _prNo);
var _files = prDir.listFiles();
_files.forEach(function(_file, _index, _array)
{
var _fileMap = new Map();
_fileMap.put("pr_no" , _file.getParentFile().getName());
_fileMap.put("file_type", _file.isDirectory() ? "D" : "F");
_fileMap.put("file_path", _file.getPath());
_fileMap.put("file_name", _file.getName());
_fileMap.put("file_size", StringUtil.getFileSizeFormat(_file.length()));
_fileMap.put("flle_dt" , sdf.format(_file.lastModified()));
_fileList.add(_fileMap);
});
}
$data.resultList = _fileList;
service에서 파일탐색, Array, List, filter(중복찾기), forEach(배열탐색) 활용
|
2019.07.16 11:57:42
|
2019.07.16 11:58:24
|
386
|
Aiden
Total of Attached file
0.00 Bytes of 0 files
2017.08.29
2017.06.05
2017.06.01
2017.05.23
2017.05.15