|
|
@@ -4,18 +4,26 @@ import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.util.StringUtils;
|
|
|
|
|
|
+import com.uas.platform.b2b.dao.AttachDao;
|
|
|
+import com.uas.platform.b2b.erp.model.RemoteFile;
|
|
|
import com.uas.platform.b2b.erp.model.SaleSampleApproval;
|
|
|
import com.uas.platform.b2b.erp.model.SaleSampleDown;
|
|
|
import com.uas.platform.b2b.erp.model.SaleSampleSend;
|
|
|
import com.uas.platform.b2b.erp.service.SaleSampleDownService;
|
|
|
+import com.uas.platform.b2b.model.Attach;
|
|
|
import com.uas.platform.b2b.model.PurchaseProofingApproval;
|
|
|
import com.uas.platform.b2b.model.PurchaseProofingItem;
|
|
|
import com.uas.platform.b2b.model.PurchaseProofingSend;
|
|
|
|
|
|
@Service
|
|
|
public class SaleSampleDownServiceImpl implements SaleSampleDownService {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private AttachDao attachDao;
|
|
|
|
|
|
@Override
|
|
|
public List<SaleSampleDown> convertPurchaseProofingItems(
|
|
|
@@ -23,7 +31,19 @@ public class SaleSampleDownServiceImpl implements SaleSampleDownService {
|
|
|
List<SaleSampleDown> saleSampleDowns = new ArrayList<SaleSampleDown>();
|
|
|
if(!CollectionUtils.isEmpty(proofingItems)) {
|
|
|
for(PurchaseProofingItem proofingItem : proofingItems) {
|
|
|
- saleSampleDowns.add(new SaleSampleDown(proofingItem));
|
|
|
+ SaleSampleDown sampleDown = new SaleSampleDown(proofingItem);
|
|
|
+ if (StringUtils.hasText(proofingItem.getProofing().getAttach())) {
|
|
|
+ String[] attachIds = proofingItem.getProofing().getAttach().split(",");
|
|
|
+ List<RemoteFile> files = new ArrayList<RemoteFile>();
|
|
|
+ for (String attachId : attachIds) {
|
|
|
+ Attach attach = attachDao.findOne(Long.parseLong(attachId));
|
|
|
+ if (attach != null) {
|
|
|
+ files.add(new RemoteFile(attach));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ sampleDown.setFiles(files);
|
|
|
+ }
|
|
|
+ saleSampleDowns.add(sampleDown);
|
|
|
}
|
|
|
}
|
|
|
return saleSampleDowns;
|
|
|
@@ -59,7 +79,52 @@ public class SaleSampleDownServiceImpl implements SaleSampleDownService {
|
|
|
List<SaleSampleApproval> saleSampleApprovals = new ArrayList<SaleSampleApproval>();
|
|
|
if(!CollectionUtils.isEmpty(proofingApprovals)) {
|
|
|
for(PurchaseProofingApproval proofingApproval : proofingApprovals) {
|
|
|
- saleSampleApprovals.add(new SaleSampleApproval(proofingApproval));
|
|
|
+ SaleSampleApproval approval = new SaleSampleApproval(proofingApproval);
|
|
|
+ if (StringUtils.hasText(proofingApproval.getAttach())) {
|
|
|
+ String[] attachIds = proofingApproval.getAttach().split(",");
|
|
|
+ List<RemoteFile> files = new ArrayList<RemoteFile>();
|
|
|
+ for (String attachId : attachIds) {
|
|
|
+ Attach attach = attachDao.findOne(Long.parseLong(attachId));
|
|
|
+ if (attach != null) {
|
|
|
+ files.add(new RemoteFile(attach));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ approval.setFiles(files);
|
|
|
+ }
|
|
|
+ if (StringUtils.hasText(proofingApproval.getPrdattach())) {
|
|
|
+ String[] attachIds = proofingApproval.getPrdattach().split(",");
|
|
|
+ List<RemoteFile> files = new ArrayList<RemoteFile>();
|
|
|
+ for (String attachId : attachIds) {
|
|
|
+ Attach attach = attachDao.findOne(Long.parseLong(attachId));
|
|
|
+ if (attach != null) {
|
|
|
+ files.add(new RemoteFile(attach));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ approval.setPrdfiles(files);
|
|
|
+ }
|
|
|
+ if (StringUtils.hasText(proofingApproval.getPpdattach())) {
|
|
|
+ String[] attachIds = proofingApproval.getPpdattach().split(",");
|
|
|
+ List<RemoteFile> files = new ArrayList<RemoteFile>();
|
|
|
+ for (String attachId : attachIds) {
|
|
|
+ Attach attach = attachDao.findOne(Long.parseLong(attachId));
|
|
|
+ if (attach != null) {
|
|
|
+ files.add(new RemoteFile(attach));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ approval.setPpdfiles(files);
|
|
|
+ }
|
|
|
+ if (StringUtils.hasText(proofingApproval.getPadattach())) {
|
|
|
+ String[] attachIds = proofingApproval.getPadattach().split(",");
|
|
|
+ List<RemoteFile> files = new ArrayList<RemoteFile>();
|
|
|
+ for (String attachId : attachIds) {
|
|
|
+ Attach attach = attachDao.findOne(Long.parseLong(attachId));
|
|
|
+ if (attach != null) {
|
|
|
+ files.add(new RemoteFile(attach));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ approval.setPadfiles(files);
|
|
|
+ }
|
|
|
+ saleSampleApprovals.add(approval);
|
|
|
}
|
|
|
}
|
|
|
return saleSampleApprovals;
|