|
|
@@ -1,6 +1,9 @@
|
|
|
package com.uas.eis.service.Impl;
|
|
|
|
|
|
+import com.fasterxml.jackson.core.JsonParser;
|
|
|
+import com.fasterxml.jackson.core.JsonProcessingException;
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
+import com.fasterxml.jackson.databind.node.TextNode;
|
|
|
import com.uas.eis.core.support.TokenProperties;
|
|
|
import com.uas.eis.dao.BaseDao;
|
|
|
import com.uas.eis.sdk.converter.ObjectToMapConverter;
|
|
|
@@ -62,7 +65,8 @@ public class ERPServiceImpl implements ERPService {
|
|
|
if(checkSign || true){
|
|
|
if(map.get("body")!=null){
|
|
|
String body = map.get("body") == null ? "" : map.get("body").toString();
|
|
|
- PurchaseMain purchaseMain = objectMapper.readValue(body, PurchaseMain.class);
|
|
|
+ String body_qczy = unescapeJsonWithJackson(body);
|
|
|
+ PurchaseMain purchaseMain = objectMapper.readValue(body_qczy, PurchaseMain.class);
|
|
|
String purord_num = purchaseMain.getPURORD_NUM();
|
|
|
resultSuccessMsg="采购订单:"+purord_num+"处理成功";
|
|
|
resultErrorMsg="采购订单:"+purord_num+"处理失败,";
|
|
|
@@ -150,4 +154,27 @@ public class ERPServiceImpl implements ERPService {
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
+
|
|
|
+ public static String unescapeJsonWithJackson(String jsonString) {
|
|
|
+ try {
|
|
|
+ ObjectMapper mapper = new ObjectMapper();
|
|
|
+ // 配置解析器允许特殊字符
|
|
|
+ mapper.configure(JsonParser.Feature.ALLOW_UNQUOTED_CONTROL_CHARS, true);
|
|
|
+
|
|
|
+ // 方法1:使用readTree解析后转为字符串
|
|
|
+ String unescaped = mapper.readTree(jsonString).toString();
|
|
|
+ return unescaped;
|
|
|
+ } catch (JsonProcessingException e) {
|
|
|
+ // 如果解析失败,可能是字符串本身,尝试使用TextNode
|
|
|
+ try {
|
|
|
+ ObjectMapper mapper = new ObjectMapper();
|
|
|
+ TextNode textNode = mapper.readValue("\"" + jsonString + "\"", TextNode.class);
|
|
|
+ return textNode.asText();
|
|
|
+ } catch (Exception ex) {
|
|
|
+ return jsonString;
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ return jsonString;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|