|
|
@@ -1,11 +1,14 @@
|
|
|
package com.usoftchina.saas.transfers.task;
|
|
|
|
|
|
+import com.usoftchina.saas.account.api.AccountApi;
|
|
|
import com.usoftchina.saas.account.api.CompanyApi;
|
|
|
+import com.usoftchina.saas.account.dto.AccountDTO;
|
|
|
import com.usoftchina.saas.account.dto.CompanyDTO;
|
|
|
import com.usoftchina.saas.inquiry.po.purchase.Purchase;
|
|
|
import com.usoftchina.saas.inquiry.po.purchase.PurchaseDetail;
|
|
|
import com.usoftchina.saas.purchase.api.PurchaseApi;
|
|
|
import com.usoftchina.saas.purchase.dto.PurchaseDTO;
|
|
|
+import com.usoftchina.saas.purchase.dto.PurchaseDetailDTO;
|
|
|
import com.usoftchina.saas.purchase.dto.PurchaseFormDTO;
|
|
|
import com.usoftchina.saas.transfers.config.B2BConfig;
|
|
|
import com.usoftchina.saas.transfers.dto.MessageInfo;
|
|
|
@@ -18,6 +21,7 @@ import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
|
+import java.math.BigDecimal;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
@@ -31,6 +35,8 @@ public class SendPurchaseTask extends Executable {
|
|
|
@Autowired
|
|
|
private CompanyApi companyApi;
|
|
|
@Autowired
|
|
|
+ private AccountApi accountApi;
|
|
|
+ @Autowired
|
|
|
private PurchaseApi purchaseApi;
|
|
|
@Autowired
|
|
|
private B2BConfig b2bConfig;
|
|
|
@@ -41,14 +47,19 @@ public class SendPurchaseTask extends Executable {
|
|
|
@Override
|
|
|
public void execute(MessageInfo messageInfo) throws Exception {
|
|
|
CompanyDTO companyDTO = companyApi.getCompanyById(messageInfo.getCompanyId()).getData();
|
|
|
+ AccountDTO accountDTO = accountApi.getAccountById(messageInfo.getUserId()).getData();
|
|
|
PurchaseFormDTO purchaseFormDTO = purchaseApi.getFormData(Long.parseLong(messageInfo.getBizId())).getData();
|
|
|
if (!ObjectUtils.isEmpty(purchaseFormDTO)){
|
|
|
//采购单主表数据
|
|
|
PurchaseDTO purchaseDTO = purchaseFormDTO.getMain();
|
|
|
Purchase b2bPurchase = BeanMapper.map(purchaseDTO, Purchase.class);
|
|
|
- //b2bPurchase.setVe_uu(0L);
|
|
|
+ convertPurchase(purchaseDTO, b2bPurchase, accountDTO, messageInfo.getCompanyId());
|
|
|
+ LOGGER.info("purchaseDTO={}, b2bPurchase={}", JsonUtils.toJsonString(purchaseDTO), JsonUtils.toJsonString(b2bPurchase));
|
|
|
//采购单明细表数据
|
|
|
List<PurchaseDetail> b2bPurchaseDetailList = BeanMapper.mapList(purchaseFormDTO.getItems(), PurchaseDetail.class);
|
|
|
+ convertPurchaseDetail(purchaseFormDTO.getItems(), b2bPurchaseDetailList);
|
|
|
+ LOGGER.info("PurchaseDetailDTO={}, b2bPurchaseDetailList={}", JsonUtils.toJsonString(purchaseFormDTO.getItems()), JsonUtils.toJsonString(b2bPurchaseDetailList));
|
|
|
+
|
|
|
b2bPurchase.setPurchaseDetails(b2bPurchaseDetailList);
|
|
|
|
|
|
sendPurchaseToB2B(b2bConfig.getCommon() + purchaseUrl, Long.parseLong(messageInfo.getBizId()), JsonUtils.toJsonString(b2bPurchase), companyDTO.getAccessKey());
|
|
|
@@ -57,6 +68,32 @@ public class SendPurchaseTask extends Executable {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ private void convertPurchase(PurchaseDTO purchaseDTO, Purchase b2bPurchase, AccountDTO accountDTO, Long companyId) {
|
|
|
+ //人员信息
|
|
|
+ b2bPurchase.setEm_email(accountDTO.getEmail());
|
|
|
+ b2bPurchase.setEm_mobile(accountDTO.getMobile());
|
|
|
+ b2bPurchase.setEm_name(accountDTO.getRealname());
|
|
|
+ b2bPurchase.setEm_uu(accountDTO.getUu());
|
|
|
+
|
|
|
+ CompanyDTO companyDTO = companyApi.getCompanyById(companyId).getData();
|
|
|
+ b2bPurchase.setPu_cop(companyDTO.getName());
|
|
|
+ b2bPurchase.setVe_uu(ObjectUtils.getLongValue(purchaseDTO.getPu_venduu()));
|
|
|
+ b2bPurchase.setPu_rate(new BigDecimal(purchaseDTO.getPu_rate()).floatValue());
|
|
|
+ b2bPurchase.setPu_remark(purchaseDTO.getPu_remark());
|
|
|
+ b2bPurchase.setPu_auditman(purchaseDTO.getPu_auditman());
|
|
|
+ b2bPurchase.setPu_recordman(purchaseDTO.getCreatorName());
|
|
|
+ b2bPurchase.setPu_shipaddresscode(purchaseDTO.getPu_shipaddresscode());
|
|
|
+ b2bPurchase.setPu_id(purchaseDTO.getId());
|
|
|
+ }
|
|
|
+
|
|
|
+ private void convertPurchaseDetail(List<PurchaseDetailDTO> items, List<PurchaseDetail> b2bPurchaseDetailList){
|
|
|
+ for (int i = 0; i < items.size(); i++) {
|
|
|
+ PurchaseDetailDTO purchaseDetailDTO = items.get(i);
|
|
|
+ PurchaseDetail b2bPurchaseDetail = b2bPurchaseDetailList.get(i);
|
|
|
+ b2bPurchaseDetail.setPd_detno(new BigDecimal(purchaseDetailDTO.getPd_detno()).shortValue());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 发送http请求
|
|
|
* @param bizId
|