Browse Source

消息处理类调整

chenw 7 years ago
parent
commit
f25365476b

+ 1 - 1
applications/transfers/transfers-server/src/main/java/com/usoftchina/saas/transfers/config/B2BConfig.java

@@ -6,7 +6,7 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
  * @Author chenwei
  * @Date 2019/01/15
  */
-@ConfigurationProperties(prefix = "b2b.baseUrl")
+@ConfigurationProperties(prefix = "b2b.baseurl")
 public class B2BConfig {
 
     private String inquiry;

+ 22 - 9
applications/transfers/transfers-server/src/main/java/com/usoftchina/saas/transfers/service/ReceiveService.java

@@ -30,16 +30,28 @@ public class ReceiveService {
 
     @Autowired
     private SendService sendService;
+    @Autowired
+    private SendProductTask sendProductTask;
+    @Autowired
+    private SendPurchaseEndTask sendPurchaseEndTask;
+    @Autowired
+    private SendPurchaseOutResTask sendPurchaseOutResTask;
+    @Autowired
+    private SendPurchaseOutTask sendPurchaseOutTask;
+    @Autowired
+    private SendPurchaseInResTask sendPurchaseInResTask;
+    @Autowired
+    private SendPurchaseInTask sendPurchaseInTask;
+    @Autowired
+    private SendPurchaseTask sendPurchaseTask;
 
     @Autowired
     private BrokerMessageLogMapper brokerMessageLogMapper;
 
     private Logger logger = LoggerFactory.getLogger(getClass());
 
-    private final static String EXCHANGE = "saas_trade_dev_exchange";
     private final static String DLEXCHANGE = "saas_trade_dev_dlexchange";
     private final static String QUEUE = "saas_trade_dev_queue";
-    private final static String DLQUEUE = "saas_trade_dev_dlqueue";
     private final static String ROUTINGKEY = "saas_trade_dev_dl.*";
 
 
@@ -66,25 +78,25 @@ public class ReceiveService {
         try {
            switch(BillCodeSeq.valueOf(info.getBizType())) {
                case PURCHASE:       //采购单上传
-                   task = new SendPurchaseTask();
+                   task = sendPurchaseTask;
                    break;
                case PURCHASEIN:     //采购验收单过账
-                   task = new SendPurchaseInTask();
+                   task = sendPurchaseInTask;
                    break;
                case PURCHASEINRES:     //采购验收单反过账
-                   task = new SendPurchaseInResTask();
+                   task = sendPurchaseInResTask;
                    break;
                case PURCHASEOUT:    //采购延退单过账
-                   task = new SendPurchaseOutTask();
+                   task = sendPurchaseOutTask;
                    break;
                case PURCHASEOUTRES:     //采购验收单反过账
-                   task = new SendPurchaseOutResTask();
+                   task = sendPurchaseOutResTask;
                    break;
                case PRODUCT:        //物料库上传
-                   task = new SendProductTask();
+                   task = sendProductTask;
                    break;
                case PURCHASEEND:    //采购单结案
-                   task = new SendPurchaseEndTask();
+                   task = sendPurchaseEndTask;
                    break;
                default:
                    break;
@@ -115,6 +127,7 @@ public class ReceiveService {
 
         //ACK,确认一条消息已经被消费
         channel.basicAck(deliveryTag,multiple);
+        logger.info("消息成功消费,MessageInfo={}",info);
         //重新返回队列 重新消费
         //channel.basicNack(deliveryTag,false,true);
     }

+ 3 - 1
applications/transfers/transfers-server/src/main/java/com/usoftchina/saas/transfers/task/SendProductTask.java

@@ -13,6 +13,7 @@ import com.usoftchina.saas.utils.JsonUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
 
 import java.util.*;
 import java.util.concurrent.CountDownLatch;
@@ -22,6 +23,7 @@ import java.util.concurrent.CountDownLatch;
  * @Author chenwei
  * @Date 2019/01/09
  */
+@Component
 public class SendProductTask extends Executable{
 
     @Autowired
@@ -39,7 +41,7 @@ public class SendProductTask extends Executable{
     public void execute(MessageInfo messageInfo) {
         Long enUU = companyApi.getCompanyById(messageInfo.getCompanyId()).getData().getUu();
         //需要上传的物料信息
-        List<ProductUploadDTO> productUploadDTOList = productApi.getUploadData().getData();
+        List<ProductUploadDTO> productUploadDTOList = productApi.getUploadData(messageInfo.getCompanyId()).getData();
         //上传结果反馈
         List<Long> successIds = new ArrayList<Long>();
         List<Long> failedIds = new ArrayList<Long>();

+ 8 - 1
applications/transfers/transfers-server/src/main/java/com/usoftchina/saas/transfers/task/SendPurchaseEndTask.java

@@ -5,6 +5,7 @@ import com.usoftchina.saas.inquiry.po.purchase.PurchaseDetailEnd;
 import com.usoftchina.saas.purchase.api.PurchaseApi;
 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;
 import com.usoftchina.saas.transfers.utils.SendUtil;
 import com.usoftchina.saas.utils.CollectionUtils;
@@ -12,6 +13,8 @@ import com.usoftchina.saas.utils.JsonUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.context.properties.EnableConfigurationProperties;
+import org.springframework.stereotype.Component;
 
 import java.math.BigDecimal;
 import java.util.ArrayList;
@@ -22,12 +25,16 @@ import java.util.List;
  * @Author chenwei
  * @Date 2019/01/15
  */
+@Component
+@EnableConfigurationProperties(B2BConfig.class)
 public class SendPurchaseEndTask extends Executable {
 
     @Autowired
     private PurchaseApi purchaseApi;
     @Autowired
     private CompanyApi companyApi;
+    @Autowired
+    private B2BConfig b2bConfig;
 
     private static final Logger LOGGER = LoggerFactory.getLogger(SendPurchaseEndTask.class);
     private final String purchaseEndUrl = "/erp/purchase/end";
@@ -54,7 +61,7 @@ public class SendPurchaseEndTask extends Executable {
                 purchaseDetailEndList.add(purchaseDetailEnd);
             }
             //发送给b2b
-            boolean success = SendUtil.sendToB2B(purchaseEndUrl, JsonUtils.toJsonString(purchaseDetailEndList), accessSecretKey);
+            boolean success = SendUtil.sendToB2B(b2bConfig.getCommon() + purchaseEndUrl, JsonUtils.toJsonString(purchaseDetailEndList), accessSecretKey);
             if (success) {
                 purchaseApi.updateB2BStatus(Long.parseLong(messageInfo.getBizId()), "已上传");
             }

+ 4 - 0
applications/transfers/transfers-server/src/main/java/com/usoftchina/saas/transfers/task/SendPurchaseInResTask.java

@@ -16,6 +16,8 @@ import com.usoftchina.saas.utils.JsonUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.context.properties.EnableConfigurationProperties;
+import org.springframework.stereotype.Component;
 
 import java.math.BigDecimal;
 import java.util.List;
@@ -25,6 +27,8 @@ import java.util.List;
  * @Author chenwei
  * @Date 2019/01/16
  */
+@Component
+@EnableConfigurationProperties(B2BConfig.class)
 public class SendPurchaseInResTask extends Executable {
 
     @Autowired

+ 4 - 0
applications/transfers/transfers-server/src/main/java/com/usoftchina/saas/transfers/task/SendPurchaseInTask.java

@@ -20,6 +20,8 @@ import com.usoftchina.saas.utils.http.HttpUtil.Response;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.context.properties.EnableConfigurationProperties;
+import org.springframework.stereotype.Component;
 
 import java.math.BigDecimal;
 import java.util.HashMap;
@@ -31,6 +33,8 @@ import java.util.Map;
  * @author: chenwei
  * @create: 2019-01-016 16:53
  **/
+@Component
+@EnableConfigurationProperties(B2BConfig.class)
 public class SendPurchaseInTask extends Executable{
 
     @Autowired

+ 4 - 0
applications/transfers/transfers-server/src/main/java/com/usoftchina/saas/transfers/task/SendPurchaseOutResTask.java

@@ -16,6 +16,8 @@ import com.usoftchina.saas.utils.JsonUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.context.properties.EnableConfigurationProperties;
+import org.springframework.stereotype.Component;
 
 import java.math.BigDecimal;
 import java.util.List;
@@ -25,6 +27,8 @@ import java.util.List;
  * @Author chenwei
  * @Date 2019/01/16
  */
+@Component
+@EnableConfigurationProperties(B2BConfig.class)
 public class SendPurchaseOutResTask extends Executable {
     @Autowired
     private CompanyApi companyApi;

+ 4 - 0
applications/transfers/transfers-server/src/main/java/com/usoftchina/saas/transfers/task/SendPurchaseOutTask.java

@@ -16,6 +16,8 @@ import com.usoftchina.saas.utils.JsonUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.context.properties.EnableConfigurationProperties;
+import org.springframework.stereotype.Component;
 
 import java.math.BigDecimal;
 import java.util.List;
@@ -25,6 +27,8 @@ import java.util.List;
  * @author: chewnei
  * @create: 2019-01-016 18:53
  **/
+@Component
+@EnableConfigurationProperties(B2BConfig.class)
 public class SendPurchaseOutTask extends Executable{
 
     @Autowired

+ 4 - 0
applications/transfers/transfers-server/src/main/java/com/usoftchina/saas/transfers/task/SendPurchaseTask.java

@@ -22,6 +22,8 @@ import com.usoftchina.saas.utils.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.context.properties.EnableConfigurationProperties;
+import org.springframework.stereotype.Component;
 
 import java.math.BigDecimal;
 import java.util.List;
@@ -30,6 +32,8 @@ import java.util.List;
  * @author: guq
  * @create: 2019-01-08 13:45
  **/
+@Component
+@EnableConfigurationProperties(B2BConfig.class)
 public class SendPurchaseTask extends Executable {
 
     @Autowired