|
|
@@ -1,5 +1,6 @@
|
|
|
package com.uas.platform.b2b.service.impl;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
|
|
|
@@ -14,8 +15,8 @@ import org.springframework.data.jpa.domain.Specification;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
-import org.springframework.util.StringUtils;
|
|
|
|
|
|
+import com.uas.platform.b2b.dao.AttachDao;
|
|
|
import com.uas.platform.b2b.dao.PurchaseProofingApprovalDao;
|
|
|
import com.uas.platform.b2b.dao.PurchaseProofingDao;
|
|
|
import com.uas.platform.b2b.dao.PurchaseProofingItemDao;
|
|
|
@@ -47,6 +48,9 @@ public class PurchaseProofingServiceImpl implements PurchaseProofingService{
|
|
|
@Autowired
|
|
|
private PurchaseProofingApprovalDao purchaseProofingApprovalDao;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private AttachDao attachDao;
|
|
|
+
|
|
|
@Override
|
|
|
public void save(List<PurchaseProofingItem> proofingItems) {
|
|
|
purchaseProofingItemDao.save(proofingItems);
|
|
|
@@ -65,128 +69,120 @@ public class PurchaseProofingServiceImpl implements PurchaseProofingService{
|
|
|
|
|
|
@Override
|
|
|
public void saveAttach(List<Attach> attachs) {
|
|
|
+ List<Attach> validAttachs = new ArrayList<Attach>();
|
|
|
if (!CollectionUtils.isEmpty(attachs)) {
|
|
|
long enUU = SystemSession.getUser().getEnterprise().getUu();
|
|
|
for (Attach attach : attachs) {
|
|
|
List<PurchaseProofing> proofings = purchaseProofingDao.findByEnUUAndCode(enUU, attach.getSourceId());
|
|
|
if (!CollectionUtils.isEmpty(proofings)) {
|
|
|
PurchaseProofing proofing = proofings.get(0);
|
|
|
- String atId = proofing.getAttach();
|
|
|
- if (!StringUtils.hasText(atId))
|
|
|
- atId = "";
|
|
|
- else
|
|
|
- atId += ",";
|
|
|
- atId += attach.getId();
|
|
|
- proofing.setAttach(atId);
|
|
|
- purchaseProofingDao.save(proofing);
|
|
|
+ attach.setRelativeTable("purc$proofing");
|
|
|
+ attach.setRelativeKey(proofing.getId());
|
|
|
+ validAttachs.add(attach);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ if(!CollectionUtils.isEmpty(validAttachs))
|
|
|
+ attachDao.save(validAttachs);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void saveSendAttach(List<Attach> attachs) {
|
|
|
+ List<Attach> validAttachs = new ArrayList<Attach>();
|
|
|
if (!CollectionUtils.isEmpty(attachs)) {
|
|
|
long enUU = SystemSession.getUser().getEnterprise().getUu();
|
|
|
for (Attach attach : attachs) {
|
|
|
List<PurchaseProofingSend> proofingSends = purchaseProofingSendDao.findByProofingItemVendUUAndCode(enUU, attach.getSourceId());
|
|
|
if (!CollectionUtils.isEmpty(proofingSends)) {
|
|
|
PurchaseProofingSend proofingSend = proofingSends.get(0);
|
|
|
- String atId = proofingSend.getAttach();
|
|
|
- if (!StringUtils.hasText(atId))
|
|
|
- atId = "";
|
|
|
- else
|
|
|
- atId += ",";
|
|
|
- atId += attach.getId();
|
|
|
- proofingSend.setAttach(atId);
|
|
|
- purchaseProofingSendDao.save(proofingSend);
|
|
|
+ attach.setRelativeTable("purc$proofingsend");
|
|
|
+ attach.setRelativeKey(proofingSend.getId());
|
|
|
+ validAttachs.add(attach);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ if(!CollectionUtils.isEmpty(validAttachs))
|
|
|
+ attachDao.save(validAttachs);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void saveApprovalAttach(List<Attach> attachs) {
|
|
|
+ List<Attach> validAttachs = new ArrayList<Attach>();
|
|
|
if (!CollectionUtils.isEmpty(attachs)) {
|
|
|
long enUU = SystemSession.getUser().getEnterprise().getUu();
|
|
|
for (Attach attach : attachs) {
|
|
|
List<PurchaseProofingApproval> approvals = purchaseProofingApprovalDao.findByEnUUAndCode(enUU, attach.getSourceId());
|
|
|
if (!CollectionUtils.isEmpty(approvals)) {
|
|
|
PurchaseProofingApproval approval = approvals.get(0);
|
|
|
- String atId = approval.getAttach();
|
|
|
- if (!StringUtils.hasText(atId))
|
|
|
- atId = "";
|
|
|
- else
|
|
|
- atId += ",";
|
|
|
- atId += attach.getId();
|
|
|
- approval.setAttach(atId);
|
|
|
- purchaseProofingApprovalDao.save(approval);
|
|
|
+ attach.setRelativeTable("purc$proofingapproval");
|
|
|
+ attach.setRelativeKey(approval.getId());
|
|
|
+ validAttachs.add(attach);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ if (!CollectionUtils.isEmpty(validAttachs)) {
|
|
|
+ attachDao.save(validAttachs);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void saveApprovalPrdattach(List<Attach> attachs) {
|
|
|
+ List<Attach> validAttachs = new ArrayList<Attach>();
|
|
|
if (!CollectionUtils.isEmpty(attachs)) {
|
|
|
long enUU = SystemSession.getUser().getEnterprise().getUu();
|
|
|
for (Attach attach : attachs) {
|
|
|
List<PurchaseProofingApproval> approvals = purchaseProofingApprovalDao.findByEnUUAndCode(enUU, attach.getSourceId());
|
|
|
if (!CollectionUtils.isEmpty(approvals)) {
|
|
|
PurchaseProofingApproval approval = approvals.get(0);
|
|
|
- String atId = approval.getPrdattach();
|
|
|
- if (!StringUtils.hasText(atId))
|
|
|
- atId = "";
|
|
|
- else
|
|
|
- atId += ",";
|
|
|
- atId += attach.getId();
|
|
|
- approval.setPrdattach(atId);
|
|
|
- purchaseProofingApprovalDao.save(approval);
|
|
|
+ attach.setRelativeTable("purc$proofingapproval_prd");
|
|
|
+ attach.setRelativeKey(approval.getId());
|
|
|
+ validAttachs.add(attach);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ if (!CollectionUtils.isEmpty(validAttachs)) {
|
|
|
+ attachDao.save(validAttachs);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void saveApprovalPadattach(List<Attach> attachs) {
|
|
|
+ List<Attach> validAttachs = new ArrayList<Attach>();
|
|
|
if (!CollectionUtils.isEmpty(attachs)) {
|
|
|
long enUU = SystemSession.getUser().getEnterprise().getUu();
|
|
|
for (Attach attach : attachs) {
|
|
|
List<PurchaseProofingApproval> approvals = purchaseProofingApprovalDao.findByEnUUAndCode(enUU, attach.getSourceId());
|
|
|
if (!CollectionUtils.isEmpty(approvals)) {
|
|
|
PurchaseProofingApproval approval = approvals.get(0);
|
|
|
- String atId = approval.getPadattach();
|
|
|
- if (!StringUtils.hasText(atId))
|
|
|
- atId = "";
|
|
|
- else
|
|
|
- atId += ",";
|
|
|
- atId += attach.getId();
|
|
|
- approval.setPadattach(atId);
|
|
|
- purchaseProofingApprovalDao.save(approval);
|
|
|
+ attach.setRelativeTable("purc$proofingapproval_pad");
|
|
|
+ attach.setRelativeKey(approval.getId());
|
|
|
+ validAttachs.add(attach);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ if (!CollectionUtils.isEmpty(validAttachs)) {
|
|
|
+ attachDao.save(validAttachs);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void saveApprovalPpdattach(List<Attach> attachs) {
|
|
|
+ List<Attach> validAttachs = new ArrayList<Attach>();
|
|
|
if (!CollectionUtils.isEmpty(attachs)) {
|
|
|
long enUU = SystemSession.getUser().getEnterprise().getUu();
|
|
|
for (Attach attach : attachs) {
|
|
|
List<PurchaseProofingApproval> approvals = purchaseProofingApprovalDao.findByEnUUAndCode(enUU, attach.getSourceId());
|
|
|
if (!CollectionUtils.isEmpty(approvals)) {
|
|
|
PurchaseProofingApproval approval = approvals.get(0);
|
|
|
- String atId = approval.getPpdattach();
|
|
|
- if (!StringUtils.hasText(atId))
|
|
|
- atId = "";
|
|
|
- else
|
|
|
- atId += ",";
|
|
|
- atId += attach.getId();
|
|
|
- approval.setPpdattach(atId);
|
|
|
- purchaseProofingApprovalDao.save(approval);
|
|
|
+ attach.setRelativeTable("purc$proofingapproval_ppd");
|
|
|
+ attach.setRelativeKey(approval.getId());
|
|
|
+ validAttachs.add(attach);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ if (!CollectionUtils.isEmpty(validAttachs)) {
|
|
|
+ attachDao.save(validAttachs);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -223,8 +219,8 @@ public class PurchaseProofingServiceImpl implements PurchaseProofingService{
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void send(PurchaseProofingSend proofingSend) {
|
|
|
- send(proofingSend, true);
|
|
|
+ public PurchaseProofingSend send(PurchaseProofingSend proofingSend) {
|
|
|
+ return send(proofingSend, true);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -235,7 +231,7 @@ public class PurchaseProofingServiceImpl implements PurchaseProofingService{
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public void send(PurchaseProofingSend proofingSend, boolean isB2b) {
|
|
|
+ public PurchaseProofingSend send(PurchaseProofingSend proofingSend, boolean isB2b) {
|
|
|
if(isB2b) {//平台上的操作
|
|
|
proofingSend.setDate(new Date());
|
|
|
//设置传输到买方ERP的状态为未上传
|
|
|
@@ -252,7 +248,7 @@ public class PurchaseProofingServiceImpl implements PurchaseProofingService{
|
|
|
if(isB2b)//b2B上操作,报错
|
|
|
throw new IllegalOperatorException("客户打样申请已送样,不可重复送样");
|
|
|
else //卖方ERP的操作数据上传过来,忽略
|
|
|
- return;
|
|
|
+ return null;
|
|
|
}
|
|
|
List<PurchaseProofingSend> proofingSends = purchaseProofingSendDao.findByProofingItemVendUUAndCode(
|
|
|
SystemSession.getUser().getEnterprise().getUu(), proofingSend.getCode());
|
|
|
@@ -260,12 +256,12 @@ public class PurchaseProofingServiceImpl implements PurchaseProofingService{
|
|
|
if(isB2b)//b2B上操作,报错
|
|
|
throw new IllegalOperatorException("送样单号已存在");
|
|
|
else //卖方ERP的操作数据上传过来,忽略
|
|
|
- return;
|
|
|
+ return null;
|
|
|
}
|
|
|
proofingItem.setStatus((short) Status.SEND.value());
|
|
|
proofingSend.setProofingItem(proofingItem);
|
|
|
proofingSend.setSendQty(proofingItem.getQty());
|
|
|
- purchaseProofingSendDao.save(proofingSend);
|
|
|
+ proofingSend = purchaseProofingSendDao.save(proofingSend);
|
|
|
purchaseProofingItemDao.save(proofingItem);
|
|
|
if(proofingItem.getProofing().getUserUU() != null) {
|
|
|
//推送给客户打样申请申请人||客户管理员账号
|
|
|
@@ -274,6 +270,7 @@ public class PurchaseProofingServiceImpl implements PurchaseProofingService{
|
|
|
XingePusher.pushSingleAccountIOS(proofingItem.getProofing().getUserUU().toString(),
|
|
|
"供应商给你送样了 " + "供应商:" + SystemSession.getUser().getEnterprise().getEnName());
|
|
|
}
|
|
|
+ return proofingSend;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -345,5 +342,10 @@ public class PurchaseProofingServiceImpl implements PurchaseProofingService{
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public List<PurchaseProofingSend> findSendsByItemId(Long itemId) {
|
|
|
+ return purchaseProofingSendDao.findByProofingItemId(itemId);
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
}
|