Browse Source

多个来源单据指向同一个附件

git-svn-id: svn+ssh://10.10.101.21/source/platform/platform-b2b@1236 f3bf4e98-0cf0-11e4-a00c-a99a8b9d557d
administrator 10 years ago
parent
commit
6e0a5f8205

+ 9 - 4
src/main/java/com/uas/platform/b2b/service/impl/AttachServiceImpl.java

@@ -85,15 +85,20 @@ public class AttachServiceImpl implements AttachService {
 		Map<String, String> fileMap = uploadZip(uploadItem, parentDir, description);
 		if (fileMap != null) {
 			List<Attach> attachs = new ArrayList<Attach>();
+			String[] sources = null;
 			for (String entry : fileMap.keySet()) {
 				if (entryParams.containsKey(entry)) {
 					File file = new File(fileMap.get(entry));
 					if (file.exists()) {
 						Map<String, Object> params = entryParams.get(entry);
-						Attach attach = new Attach(String.valueOf(params.get("name")), fileMap.get(entry), description, file.length(), new Date());
-						attach = attachDao.save(attach);
-						attach.setSourceId(params.get("sourceId").toString());
-						attachs.add(attach);
+						sources = params.get("sourceId").toString().split(",");// multi sources
+						for (String sr : sources) {
+							Attach attach = new Attach(String.valueOf(params.get("name")), fileMap.get(entry), description, file.length(),
+									new Date());
+							attach = attachDao.save(attach);
+							attach.setSourceId(sr);
+							attachs.add(attach);
+						}
 					}
 				}
 			}