相关方人员审批 - 完善报错信息及错误提示

xuyifeng-0724-人员中台对接-dev
water_xu 2024-07-10 14:17:46 +08:00
parent 862d5ce345
commit e7a80afd1d
1 changed files with 11 additions and 3 deletions

View File

@ -5,6 +5,7 @@ import cn.hutool.http.HttpResponse;
import cn.hutool.http.HttpUtil; import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import com.zcloud.flow.util.dto.UserDTO; import com.zcloud.flow.util.dto.UserDTO;
import lombok.extern.apachecommons.CommonsLog; import lombok.extern.apachecommons.CommonsLog;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@ -12,6 +13,7 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.*; import java.util.*;
import java.util.stream.Collectors;
/** /**
* *
@ -67,9 +69,14 @@ public class GJSendMessageUtil {
e.printStackTrace(); e.printStackTrace();
throw new RuntimeException("网络通信异常"); throw new RuntimeException("网络通信异常");
} }
if (!"1".equals(paramDataMap.get("code"))) { Map<String, String> _body = JSONObject.parseObject(body, new TypeReference<Map<String, String>>() {});
System.out.println("工匠学院通信异常 ===> " + paramDataMap.get("message")); Map<String, String> data = JSONObject.parseObject(_body.get("data"), new TypeReference<Map<String, String>>() {});
throw new RuntimeException("工匠学院异常,请联系学院老师"); 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("==========================");
System.out.println(body); System.out.println(body);
@ -109,6 +116,7 @@ public class GJSendMessageUtil {
.header(TIMESTAMP_HEADER, timestamp) .header(TIMESTAMP_HEADER, timestamp)
.form("param", paramDataRsaEncrypt) .form("param", paramDataRsaEncrypt)
.execute(); .execute();
System.out.println(response.body());
return response.body(); return response.body();
} }