Skip to content

Commit 55d4705

Browse files
ekko.wangYouYe
authored andcommitted
http数据源查询失败问题修复
1 parent 7fa772c commit 55d4705

File tree

2 files changed

+20
-22
lines changed

2 files changed

+20
-22
lines changed

lcapDataServer/lcap-server/src/main/java/com/cloudwise/lcap/aop/RequestAspect.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,6 @@ public Object checkAndPerformance(ProceedingJoinPoint point) throws Throwable {
9999
log.info("<=============================");
100100
log.info("Request method:{}, url:{}, param:{}", method, url, bodyStr);
101101

102-
String cookieValue = CookieUtils.getCookieValue(request, cookieName);
103-
if (StringUtils.isEmpty(cookieValue)){
104-
log.error("本地获取cookie为空,cookieName=aops-sessionId不存在");
105-
throw new UnAuthorizedException();
106-
}
107-
108102
Object response = point.proceed();
109103
int status = 0;
110104
HttpServletResponse response1 = attributes.getResponse();

lcapDataServer/lcap-server/src/main/java/com/cloudwise/lcap/dataplateform/core/calcite/http/HttpEnumerable.java

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ public static List<Object[]> buildResponseData(Object object, List<Map<String, O
134134
String fieldName = (String) field.get("fieldName");
135135
String fieldType = (String) field.get("fieldType");
136136
collect.put(fieldName, sort, fieldType);
137-
collect2.put(sort,fieldName);
137+
collect2.put(sort, fieldName);
138138
}
139139

140140

@@ -150,16 +150,13 @@ public static List<Object[]> buildResponseData(Object object, List<Map<String, O
150150
for (Map<String, Object> field : fields) {
151151
int sort = (int) field.get("sort");
152152
Object jsonpath = field.get("jsonpath");
153-
String fieldType = (String)field.get("fieldType");
154153
if (null != jsonpath) {
155154
try {
156155
//对其中一个字段进行jsonpath解析,将当前这个字段的解析结果 作为解析类型
157156
Object transferFieldData = JsonPathUtil.transfer(documentStr, jsonpath.toString());
158157
if (null == transferType && null != transferFieldData) {
159158
transferType = transferFieldData;
160159
}
161-
Class javaClassByName = getJavaClassByName(fieldType);
162-
transferFieldData = getValue(javaClassByName,transferFieldData.toString());
163160
fieldsData.put(sort, transferFieldData);
164161
} catch (Exception e) {
165162
e.printStackTrace();
@@ -187,29 +184,36 @@ public static List<Object[]> buildResponseData(Object object, List<Map<String, O
187184
int fieldSort = 0;
188185
Object[] rowData = new Object[fieldsSize];
189186
for (Integer sort : sorts) {
190-
String fieldName = collect2.get(sort);
191-
String fieldType = collect.get(fieldName, sort);
192-
193-
Object[] columnData = ((net.minidev.json.JSONArray) fieldsData.get(sort)).toArray();
187+
Object fieldData = null;
188+
Object o = fieldsData.get(sort);
189+
if (o instanceof Collection) {
190+
Object[] columnData = ((net.minidev.json.JSONArray) o).toArray();
191+
fieldData = columnData[rowNum];
192+
} else {
193+
fieldData = o;
194+
}
194195
//需要将 fieldData 转换为 fieldType 需要的类型
195-
Object fieldData = columnData[rowNum];
196-
if (null == fieldData){
197-
rowData[fieldSort++] = null;
198-
}else {
199-
Class javaClassByName = getJavaClassByName(fieldType);
200-
rowData[fieldSort++] = getValue(javaClassByName,fieldData.toString());
196+
int i = fieldSort++;
197+
if (null != fieldData) {
198+
String fieldName = collect2.get(sort);
199+
String fieldType = collect.get(fieldName, sort);
200+
try {
201+
Class javaClassByName = getJavaClassByName(fieldType);
202+
rowData[i] = getValue(javaClassByName, fieldData.toString());
203+
} catch (Exception e) {
204+
log.error("数据fieldData:" + fieldData + " 转换类型:" + fieldType + " 异常");
205+
}
201206
}
202207
}
203208
totalRowData.add(rowData);
204209
}
205210
}
206211
} catch (Exception e) {
207-
log.error("http返回值数据解析异常");
212+
log.error("http返回值数据解析异常" + e);
208213
throw new BizException("http返回值数据解析异常");
209214
}
210215
return totalRowData;
211216
}
212217

213218

214-
215219
}

0 commit comments

Comments
 (0)