| | |
| | | excelLoader(list, req); |
| | | loadData(list); |
| | | copyFiles(list); |
| | | publishFiles(list); |
| | | insertMetas(list); |
| | | } |
| | | |
| | |
| | | */ |
| | | private void copyMultiFile(MetaFileEntity mf, List<String> extList) { |
| | | String path = mf.getPath(); |
| | | |
| | | int status = copySingleFile(mf); |
| | | if (status < 1) { |
| | | for (int i = 0, c = extList.size(); i < c; i++) { |
| | |
| | | } |
| | | |
| | | /** |
| | | * 发布文件 |
| | | */ |
| | | private void publishFiles(List<MetaFileEntity> list) { |
| | | for (MetaFileEntity mf : list) { |
| | | if (null != mf.getMsg()) { |
| | | continue; |
| | | } |
| | | switch (mf.getExtName()) { |
| | | case StaticData.MPT: |
| | | linkFiles(mf, StaticData.MPT_EXT, pathHelper.getConfig().getPublishMptPath()); |
| | | break; |
| | | case StaticData.D3DML: |
| | | linkFiles(mf, null, pathHelper.getConfig().getPublish3dmlPath()); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 链接文件 |
| | | */ |
| | | private void linkFiles(MetaFileEntity mf, List<String> exts, String publishPath) { |
| | | String uploadPath = pathHelper.getConfig().getUploadPath(); |
| | | String source = uploadPath + File.separator + mf.getPath(); |
| | | String target = publishPath + File.separator + mf.getName(); |
| | | |
| | | File sourceFile = new File(source); |
| | | if (!sourceFile.exists() || sourceFile.isDirectory()) { |
| | | return; |
| | | } |
| | | |
| | | createFileLink(source, target); |
| | | if (null == exts) { |
| | | return; |
| | | } |
| | | |
| | | for (String ext : exts) { |
| | | File f=new File(source.replace(mf.getExtName(), ext)); |
| | | if (f.exists()&&!f.isDirectory()) { |
| | | createFileLink(source.replace(mf.getExtName(), ext), target.replace(mf.getExtName(), ext)); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 创建文件链接 |
| | | */ |
| | | private void createFileLink(String source, String target) { |
| | | String cmd = String.format("cmd /c mklink \"%s\" \"%s\"", target, source); |
| | | WebHelper.exec(cmd); |
| | | } |
| | | |
| | | /** |
| | | * 插入元数据 |
| | | */ |
| | | private void insertMetas(List<MetaFileEntity> list) { |