Browse Source

commoncount统计定时任务增加返回数据为json时的处理

wangyc 7 years ago
parent
commit
73cca0b8c2

+ 6 - 1
src/main/java/com/uas/platform/b2c/prod/product/common/CommonTask.java

@@ -1,5 +1,6 @@
 package com.uas.platform.b2c.prod.product.common;
 
+import com.alibaba.fastjson.JSON;
 import com.uas.platform.b2c.prod.product.common.dao.CommonCountDao;
 import com.uas.platform.b2c.prod.product.common.model.CommonCount;
 import com.uas.platform.core.util.HttpUtil;
@@ -36,7 +37,11 @@ public class CommonTask {
                 try {
                     String responseText = HttpUtil.sendGetRequest(commonCount.getSql(), null).getResponseText();
                     if (!StringUtils.isEmpty(responseText)) {
-                        commonCount.setCount(Double.parseDouble(responseText));
+                        if (responseText.contains("{")) {
+                            commonCount.setCount(JSON.parseObject(responseText).getDouble("count"));
+                        } else {
+                            commonCount.setCount(Double.parseDouble(responseText));
+                        }
                     }
                 } catch (Exception e) {
                 }