Browse Source

修改异常日志

chenw 7 years ago
parent
commit
c41efe1e09

+ 6 - 3
applications/transfers/transfers-server/src/main/java/com/usoftchina/saas/transfers/task/SendPurchaseEndTask.java

@@ -12,6 +12,7 @@ import com.usoftchina.saas.transfers.dto.MessageInfo;
 import com.usoftchina.saas.transfers.utils.SendUtil;
 import com.usoftchina.saas.utils.CollectionUtils;
 import com.usoftchina.saas.utils.JsonUtils;
+import com.usoftchina.saas.utils.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -65,11 +66,13 @@ public class SendPurchaseEndTask extends Executable {
             //添加身份ID
             String url = b2bConfig.getCommon() + purchaseEndUrl + "?access_id=" + companyDTO.getUu();
             //发送给b2b
-            boolean success = SendUtil.sendToB2B(url, JSON.toJSONString(purchaseDetailEndList), companyDTO.getAccessKey());
-            if (success) {
+            String message = SendUtil.sendToB2B(url, JSON.toJSONString(purchaseDetailEndList), companyDTO.getAccessKey());
+            if (StringUtils.isEmpty(message)) {
+                LOGGER.info("采购单结案/反结案上传成功, id={}", messageInfo.getBizId());
                 purchaseApi.updateB2BStatus(Long.parseLong(messageInfo.getBizId()), "已上传");
             } else {
-                throw new Exception("上传失败");
+                LOGGER.info("采购单结案/反结案上传失败, id={}, error Message={}", messageInfo.getBizId(), message);
+                throw new Exception(message);
             }
         }
 

+ 6 - 2
applications/transfers/transfers-server/src/main/java/com/usoftchina/saas/transfers/task/SendPurchaseInResTask.java

@@ -16,6 +16,7 @@ import com.usoftchina.saas.transfers.utils.SendUtil;
 import com.usoftchina.saas.utils.BeanMapper;
 import com.usoftchina.saas.utils.JsonUtils;
 import com.usoftchina.saas.utils.ObjectUtils;
+import com.usoftchina.saas.utils.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -68,10 +69,13 @@ public class SendPurchaseInResTask extends Executable {
         List<PurchaseProdInOut> data = new ArrayList<PurchaseProdInOut>();
         data.add(b2bPurchaseProdInOut);
 
-        boolean success = SendUtil.sendToB2B(url, JSON.toJSONString(data), companyDTO.getAccessKey());
-        if (success) {
+        String message = SendUtil.sendToB2B(url, JSON.toJSONString(data), companyDTO.getAccessKey());
+        if (StringUtils.isEmpty(message)) {
             LOGGER.info("采购验收单(反过账)上传成功, id={}", messageInfo.getBizId());
             prodInOutApi.updateB2BStatus(Long.parseLong(messageInfo.getBizId()), "已上传");
+        }else {
+            LOGGER.info("采购验收单(反过账)上传失败, id={}, error Message={}", messageInfo.getBizId(), message);
+            throw new Exception(message);
         }
     }
 

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

@@ -18,6 +18,7 @@ import com.usoftchina.saas.transfers.utils.SendUtil;
 import com.usoftchina.saas.utils.BeanMapper;
 import com.usoftchina.saas.utils.JsonUtils;
 import com.usoftchina.saas.utils.ObjectUtils;
+import com.usoftchina.saas.utils.StringUtils;
 import com.usoftchina.saas.utils.http.HttpUtil;
 import com.usoftchina.saas.utils.http.HttpUtil.Response;
 import org.slf4j.Logger;
@@ -73,13 +74,13 @@ public class SendPurchaseInTask extends Executable{
         //将数据改为B2B数据格式
         List<PurchaseProdInOut> data = new ArrayList<PurchaseProdInOut>();
         data.add(b2bPurchaseProdInOut);
-        boolean success = SendUtil.sendToB2B(url, JSON.toJSONString(data), companyDTO.getAccessKey());
-        if (success) {
+        String message = SendUtil.sendToB2B(url, JSON.toJSONString(data), companyDTO.getAccessKey());
+        if (StringUtils.isEmpty(message)) {
             LOGGER.info("采购验收单上传成功, id={}", messageInfo.getBizId());
             prodInOutApi.updateB2BStatus(Long.parseLong(messageInfo.getBizId()), "已上传");
         } else {
-            LOGGER.info("采购验收单上传失败, id={}", messageInfo.getBizId());
-            throw new Exception("上传失败");
+            LOGGER.info("采购验收单上传失败, id={},error Message={}", messageInfo.getBizId(), message);
+            throw new Exception(message);
         }
     }
 

+ 6 - 2
applications/transfers/transfers-server/src/main/java/com/usoftchina/saas/transfers/task/SendPurchaseOutResTask.java

@@ -16,6 +16,7 @@ import com.usoftchina.saas.transfers.utils.SendUtil;
 import com.usoftchina.saas.utils.BeanMapper;
 import com.usoftchina.saas.utils.JsonUtils;
 import com.usoftchina.saas.utils.ObjectUtils;
+import com.usoftchina.saas.utils.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -68,10 +69,13 @@ public class SendPurchaseOutResTask extends Executable {
         List<PurchaseProdInOut> data = new ArrayList<PurchaseProdInOut>();
         data.add(b2bPurchaseProdInOut);
 
-        boolean success = SendUtil.sendToB2B(url, JSON.toJSONString(data), companyDTO.getAccessKey());
-        if (success) {
+        String message = SendUtil.sendToB2B(url, JSON.toJSONString(data), companyDTO.getAccessKey());
+        if (StringUtils.isEmpty(message)) {
             LOGGER.info("采购验退单(反过账)上传成功, id={}", messageInfo.getBizId());
             prodInOutApi.updateB2BStatus(Long.parseLong(messageInfo.getBizId()), "已上传");
+        }else {
+            LOGGER.info("采购验退单(反过账)上传失败, id={}, error Message={}", messageInfo.getBizId(), message);
+            throw new Exception(message);
         }
     }
 

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

@@ -16,6 +16,7 @@ import com.usoftchina.saas.transfers.utils.SendUtil;
 import com.usoftchina.saas.utils.BeanMapper;
 import com.usoftchina.saas.utils.JsonUtils;
 import com.usoftchina.saas.utils.ObjectUtils;
+import com.usoftchina.saas.utils.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -69,13 +70,13 @@ public class SendPurchaseOutTask extends Executable{
         List<PurchaseProdInOut> data = new ArrayList<PurchaseProdInOut>();
         data.add(b2bPurchaseProdInOut);
 
-        boolean success = SendUtil.sendToB2B(url, JSON.toJSONString(data), companyDTO.getAccessKey());
-        if (success) {
+        String message = SendUtil.sendToB2B(url, JSON.toJSONString(data), companyDTO.getAccessKey());
+        if (StringUtils.isEmpty(message)) {
             LOGGER.info("采购验退单上传成功, id={}", messageInfo.getBizId());
             prodInOutApi.updateB2BStatus(Long.parseLong(messageInfo.getBizId()), "已上传");
         } else {
-            LOGGER.info("采购验退单上传失败, id={}", messageInfo.getBizId());
-            throw new Exception("上传失败");
+            LOGGER.info("采购验退单上传失败, id={}, error Message={}", messageInfo.getBizId(), message);
+            throw new Exception(message);
         }
     }
 

+ 5 - 3
applications/transfers/transfers-server/src/main/java/com/usoftchina/saas/transfers/task/SendPurchaseTask.java

@@ -74,11 +74,13 @@ public class SendPurchaseTask extends Executable {
             //将数据改为B2B数据格式
             List<Purchase> data = new ArrayList<Purchase>();
             data.add(b2bPurchase);
-            boolean success = SendUtil.sendToB2B(url, JSON.toJSONString(data), companyDTO.getAccessKey());
-            if (success) {
+            String message = SendUtil.sendToB2B(url, JSON.toJSONString(data), companyDTO.getAccessKey());
+            if (StringUtils.isEmpty(message)) {
+                LOGGER.info("采购单上传成功, id={}", messageInfo.getBizId());
                 purchaseApi.updateB2BStatus(Long.parseLong(messageInfo.getBizId()), "已上传");
             }else{
-                throw new Exception("处理失败");
+                LOGGER.info("采购单上传失败, id={}, error Message={}", messageInfo.getBizId(), message);
+                throw new Exception(message);
             }
         }
 

+ 3 - 3
applications/transfers/transfers-server/src/main/java/com/usoftchina/saas/transfers/utils/SendUtil.java

@@ -26,17 +26,17 @@ public class SendUtil {
      * @return
      * @throws Exception
      */
-    public static boolean sendToB2B(String url, String data, String accessSecretKey) throws Exception {
+    public static String sendToB2B(String url, String data, String accessSecretKey) throws Exception {
         Map<String, String> params = new HashMap<String, String>();
         params.put("data", data);
         LOGGER.info("url={}, accessSecretKey={}", url, accessSecretKey);
         LOGGER.info("data={}", data);
         Response response = HttpUtil.sendPostRequest(url, params, true, accessSecretKey);
         if (response.getStatusCode() == 200){
-            return true;
+            return null;
         }else {
             LOGGER.info("error Message: {}", response.getResponseText());
-            return false;
+            return response.getResponseText();
         }
     }