|
@@ -1,15 +1,16 @@
|
|
|
package com.usoftchina.saas.transfers.task;
|
|
package com.usoftchina.saas.transfers.task;
|
|
|
|
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
import com.usoftchina.saas.account.api.AccountApi;
|
|
import com.usoftchina.saas.account.api.AccountApi;
|
|
|
import com.usoftchina.saas.account.api.CompanyApi;
|
|
import com.usoftchina.saas.account.api.CompanyApi;
|
|
|
import com.usoftchina.saas.account.dto.AccountDTO;
|
|
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.Purchase;
|
|
|
import com.usoftchina.saas.inquiry.po.purchase.PurchaseDetail;
|
|
import com.usoftchina.saas.inquiry.po.purchase.PurchaseDetail;
|
|
|
import com.usoftchina.saas.purchase.api.PurchaseApi;
|
|
import com.usoftchina.saas.purchase.api.PurchaseApi;
|
|
|
import com.usoftchina.saas.purchase.dto.PurchaseDTO;
|
|
import com.usoftchina.saas.purchase.dto.PurchaseDTO;
|
|
|
import com.usoftchina.saas.purchase.dto.PurchaseDetailDTO;
|
|
import com.usoftchina.saas.purchase.dto.PurchaseDetailDTO;
|
|
|
import com.usoftchina.saas.purchase.dto.PurchaseFormDTO;
|
|
import com.usoftchina.saas.purchase.dto.PurchaseFormDTO;
|
|
|
|
|
+import com.usoftchina.saas.transfers.utils.SendUtil;
|
|
|
import com.usoftchina.saas.utils.BeanMapper;
|
|
import com.usoftchina.saas.utils.BeanMapper;
|
|
|
import com.usoftchina.saas.utils.JsonUtils;
|
|
import com.usoftchina.saas.utils.JsonUtils;
|
|
|
import com.usoftchina.saas.utils.ObjectUtils;
|
|
import com.usoftchina.saas.utils.ObjectUtils;
|
|
@@ -23,6 +24,7 @@ import org.springframework.boot.test.context.SpringBootTest;
|
|
|
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
|
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
|
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -32,22 +34,20 @@ import java.util.List;
|
|
|
@SpringBootTest
|
|
@SpringBootTest
|
|
|
@RunWith(SpringJUnit4ClassRunner.class)
|
|
@RunWith(SpringJUnit4ClassRunner.class)
|
|
|
@EnableAutoConfiguration
|
|
@EnableAutoConfiguration
|
|
|
-public class SendTaskTest {
|
|
|
|
|
|
|
+public class SendPurchaseTaskTest {
|
|
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private PurchaseApi purchaseApi;
|
|
private PurchaseApi purchaseApi;
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private AccountApi accountApi;
|
|
private AccountApi accountApi;
|
|
|
- @Autowired
|
|
|
|
|
- private CompanyApi companyApi;
|
|
|
|
|
|
|
|
|
|
- private static final Logger LOGGER = LoggerFactory.getLogger(SendTaskTest.class);
|
|
|
|
|
|
|
+ private static final Logger LOGGER = LoggerFactory.getLogger(SendPurchaseTaskTest.class);
|
|
|
|
|
|
|
|
@Test
|
|
@Test
|
|
|
- public void testA_purchaseTask(){
|
|
|
|
|
|
|
+ public void testA_purchaseTask() throws Exception {
|
|
|
|
|
|
|
|
- AccountDTO accountDTO = accountApi.getAccountById(67L).getData();
|
|
|
|
|
- PurchaseFormDTO purchaseFormDTO = purchaseApi.getFormData(169L).getData();
|
|
|
|
|
|
|
+ AccountDTO accountDTO = accountApi.getAccountById(65L).getData();
|
|
|
|
|
+ PurchaseFormDTO purchaseFormDTO = purchaseApi.getFormData(1922L).getData();
|
|
|
if (!ObjectUtils.isEmpty(purchaseFormDTO)){
|
|
if (!ObjectUtils.isEmpty(purchaseFormDTO)){
|
|
|
//采购单主表数据
|
|
//采购单主表数据
|
|
|
PurchaseDTO purchaseDTO = purchaseFormDTO.getMain();
|
|
PurchaseDTO purchaseDTO = purchaseFormDTO.getMain();
|
|
@@ -62,6 +62,17 @@ public class SendTaskTest {
|
|
|
|
|
|
|
|
LOGGER.info("PurchaseDetailDTO={}, b2bPurchaseDetailList={}", JsonUtils.toJsonString(purchaseFormDTO.getItems()), JsonUtils.toJsonString(b2bPurchaseDetailList));
|
|
LOGGER.info("PurchaseDetailDTO={}, b2bPurchaseDetailList={}", JsonUtils.toJsonString(purchaseFormDTO.getItems()), JsonUtils.toJsonString(b2bPurchaseDetailList));
|
|
|
|
|
|
|
|
|
|
+ //添加身份ID
|
|
|
|
|
+ String url = "http://test-b2b.uuzcc.cn/erp/purchase" + "?access_id=" + 10050689;
|
|
|
|
|
+ //将数据改为B2B数据格式
|
|
|
|
|
+ List<Purchase> data = new ArrayList<Purchase>();
|
|
|
|
|
+ data.add(b2bPurchase);
|
|
|
|
|
+ boolean success = SendUtil.sendToB2B(url, JSON.toJSONString(data), "bece5de0b15742d69738819b4e008ac8");
|
|
|
|
|
+ if (success){
|
|
|
|
|
+ LOGGER.info("上传成功!");
|
|
|
|
|
+ } else {
|
|
|
|
|
+ LOGGER.info("上传失败!");
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -71,10 +82,6 @@ public class SendTaskTest {
|
|
|
b2bPurchase.setEm_mobile(accountDTO.getMobile());
|
|
b2bPurchase.setEm_mobile(accountDTO.getMobile());
|
|
|
b2bPurchase.setEm_name(accountDTO.getRealname());
|
|
b2bPurchase.setEm_name(accountDTO.getRealname());
|
|
|
b2bPurchase.setEm_uu(accountDTO.getUu());
|
|
b2bPurchase.setEm_uu(accountDTO.getUu());
|
|
|
-
|
|
|
|
|
- CompanyDTO companyDTO = companyApi.getCompanyById(1L).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_rate(new BigDecimal(purchaseDTO.getPu_rate()).floatValue());
|
|
|
b2bPurchase.setPu_remark(purchaseDTO.getPu_remark());
|
|
b2bPurchase.setPu_remark(purchaseDTO.getPu_remark());
|
|
|
b2bPurchase.setPu_auditman(purchaseDTO.getPu_auditman());
|
|
b2bPurchase.setPu_auditman(purchaseDTO.getPu_auditman());
|