| | |
| | | entity.setName(oldName); |
| | | entity.setTab(tab); |
| | | entity.setGuid(md5); |
| | | String subPath = PathHelper.getUploadPath() + File.separator + md5; |
| | | String subPath = PathHelper.getUploadPath() + File.separator + md5 + FileHelper.getExtension(oldName); |
| | | entity.setPath(subPath); |
| | | entity.setSizes(sizes); |
| | | if (ue != null) { |
| | |
| | | /** |
| | | * 上传Excel附件 |
| | | */ |
| | | public List<KeyValueEntity> uploadXlsAnnex(List<MetaEntity> ms, List<MetaFileEntity> list, String path) { |
| | | public List<KeyValueEntity> uploadXlsAnnex(UserEntity ue, List<MetaEntity> ms, List<MetaFileEntity> list, String path) { |
| | | List<String> files = getAttachFiles(list, path); |
| | | if (files.size() == 0) { |
| | | return null; |
| | |
| | | |
| | | List<KeyValueEntity> rs = new ArrayList<>(); |
| | | for (MetaEntity meta : ms) { |
| | | int rows = uploadXlsAnnex(meta, files); |
| | | int rows = uploadXlsAnnex(ue, meta, files); |
| | | rs.add(new KeyValueEntity(meta.getName(), String.valueOf(rows))); |
| | | } |
| | | |
| | |
| | | /** |
| | | * 上传Excel附件 |
| | | */ |
| | | private int uploadXlsAnnex(MetaEntity meta, List<String> files) { |
| | | private int uploadXlsAnnex(UserEntity ue, MetaEntity meta, List<String> files) { |
| | | List<?> list = queryXlsData(meta); |
| | | if (null == list || list.size() == 0) { |
| | | return 0; |
| | | } |
| | | |
| | | Field field = getAnnexField(list.get(0), meta); |
| | | String folder = meta.getName().split(".")[0].trim().toLowerCase() + File.separator; |
| | | String folder = meta.getName().split("\\.")[0].trim().toLowerCase() + File.separator; |
| | | |
| | | int rows = 0; |
| | | for (Object obj : list) { |
| | |
| | | } |
| | | |
| | | BaseEntity be = (BaseEntity) obj; |
| | | rows += insertXlsAnnex(be, files); |
| | | rows += insertXlsAnnex(ue, be, files, file); |
| | | } |
| | | |
| | | return rows; |
| | |
| | | * 查找附件文件 |
| | | */ |
| | | private String findAnnexFile(String name, String folder, List<String> files) { |
| | | name = File.separator + name.split(".")[0].toLowerCase(); |
| | | name = File.separator + name.split("\\.")[0].trim().toLowerCase(); |
| | | for (String file : files) { |
| | | if (file.toLowerCase().contains(folder) && file.toLowerCase().contains(name)) { |
| | | return file; |
| | |
| | | /** |
| | | * 插入Excel附件 |
| | | */ |
| | | private int insertXlsAnnex(BaseEntity be, List<String> files) { |
| | | private int insertXlsAnnex(UserEntity ue, BaseEntity be, List<String> files, String file) { |
| | | |
| | | |
| | | files.remove(file); |
| | | |
| | | return 1; |
| | | } |
| | | |
| | | private AttachEntity getAttachEntity(UserEntity ue, String file) { |
| | | AttachEntity entity = new AttachEntity(); |
| | | // entity.setTab(tabName); |
| | | // entity.setTabGuid(eventid); |
| | | // entity.setName(fileName); |
| | | // entity.setGuid(md5); |
| | | // String subPath = PathHelper.getUploadPath() + File.separator + md5+ FileHelper.getExtension(fileName); |
| | | // entity.setPath(subPath); |
| | | // entity.setSizes(sizes); |
| | | // if (ue != null) { |
| | | // entity.setCreateUser(ue.getId()); |
| | | // } |
| | | |
| | | return entity; |
| | | } |
| | | } |