diff --git a/src/main/java/com/zcloud/flow/util/GJSendMessageUtil.java b/src/main/java/com/zcloud/flow/util/GJSendMessageUtil.java index ae575cad..0137ae24 100644 --- a/src/main/java/com/zcloud/flow/util/GJSendMessageUtil.java +++ b/src/main/java/com/zcloud/flow/util/GJSendMessageUtil.java @@ -5,6 +5,7 @@ import cn.hutool.http.HttpResponse; import cn.hutool.http.HttpUtil; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; +import com.alibaba.fastjson.TypeReference; import com.zcloud.flow.util.dto.UserDTO; import lombok.extern.apachecommons.CommonsLog; import lombok.extern.slf4j.Slf4j; @@ -12,6 +13,7 @@ import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; import java.util.*; +import java.util.stream.Collectors; /** * 工匠学院 @@ -67,9 +69,14 @@ public class GJSendMessageUtil { e.printStackTrace(); throw new RuntimeException("网络通信异常"); } - if (!"1".equals(paramDataMap.get("code"))) { - System.out.println("工匠学院通信异常 ===> " + paramDataMap.get("message")); - throw new RuntimeException("工匠学院异常,请联系学院老师"); + Map _body = JSONObject.parseObject(body, new TypeReference>() {}); + Map data = JSONObject.parseObject(_body.get("data"), new TypeReference>() {}); + if (!"1".equals(_body.get("code"))) { + throw new RuntimeException(_body.get("message")); + } + if (!data.get("syncUserTotal").equals(data.get("syncSuccessCount"))){ + String errorMsg = JSONObject.parseArray(data.get("msgList"), Map.class).stream().map(e -> "[" + e.get("msg") + "]").collect(Collectors.joining()); + throw new RuntimeException("错误信息:" + errorMsg); } System.out.println("=========================="); System.out.println(body); @@ -109,6 +116,7 @@ public class GJSendMessageUtil { .header(TIMESTAMP_HEADER, timestamp) .form("param", paramDataRsaEncrypt) .execute(); + System.out.println(response.body()); return response.body(); }