Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
H
haoban-manage3.0
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
haoban3.0
haoban-manage3.0
Commits
6026d88d
Commit
6026d88d
authored
Jul 10, 2023
by
guojx
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
活码数据迁移工具类调整
parent
111bc673
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
52 additions
and
228 deletions
+52
-228
HmLinkController.java
...gic/haoban/manage/web/controller/hm/HmLinkController.java
+25
-18
HmQrcodeController.java
...c/haoban/manage/web/controller/hm/HmQrcodeController.java
+27
-23
DataApiHttpUtils.java
...ava/com/gic/haoban/manage/web/utils/DataApiHttpUtils.java
+0
-187
No files found.
haoban-manage3-web/src/main/java/com/gic/haoban/manage/web/controller/hm/HmLinkController.java
View file @
6026d88d
...
...
@@ -10,7 +10,7 @@ import java.util.Map;
import
java.util.stream.Collectors
;
import
com.alibaba.fastjson.JSON
;
import
com.gic.
haoban.manage.web.utils.DataApiHttp
Utils
;
import
com.gic.
web.common.utils.DataApi
Utils
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.lang.StringUtils
;
import
org.apache.logging.log4j.LogManager
;
...
...
@@ -48,7 +48,6 @@ import com.gic.haoban.manage.api.service.hm.HmPageApiService;
import
com.gic.haoban.manage.api.service.hm.HmQrcodeApiService
;
import
com.gic.haoban.manage.api.service.hm.WxUserAddLogApiService
;
import
com.gic.haoban.manage.api.service.out.WelcomeApiService
;
import
com.gic.haoban.manage.api.util.DataHttpUtil
;
import
com.gic.haoban.manage.web.log.LogRecordUserServiceImpl
;
import
com.gic.haoban.manage.web.qo.hm.data.HmLinkChartQO
;
import
com.gic.haoban.manage.web.qo.hm.data.HmLinkClerkListQO
;
...
...
@@ -672,7 +671,7 @@ public class HmLinkController {
if
(
StringUtils
.
isBlank
(
qdto
.
getSortType
()))
{
qdto
.
setSortType
(
"desc"
);
}
jsonObject
.
put
(
"orderByType"
,
DataApi
Http
Utils
.
getOrderByType
(
qdto
.
getSortType
()));
jsonObject
.
put
(
"orderByType"
,
DataApiUtils
.
getOrderByType
(
qdto
.
getSortType
()));
Map
<
String
,
Integer
>
orderByFieldMap
=
new
HashMap
<
String
,
Integer
>(
8
){{
put
(
"createTime"
,
13
);
put
(
"addNumT"
,
6
);
...
...
@@ -682,7 +681,7 @@ public class HmLinkController {
put
(
"clickNumT"
,
10
);
put
(
"clickNum"
,
11
);
}};
jsonObject
.
put
(
"orderByFields"
,
DataApi
Http
Utils
.
getOrderByFields
(
qdto
.
getSortColumn
(),
"createTime"
,
orderByFieldMap
));
jsonObject
.
put
(
"orderByFields"
,
DataApiUtils
.
getOrderByFields
(
qdto
.
getSortColumn
(),
"createTime"
,
orderByFieldMap
));
// jsonObject.put("orderByField", qdto.getSortColumn() + " " + qdto.getSortType());
jsonObject
.
put
(
"pageNum"
,
basePageInfo
.
getPageNum
());
jsonObject
.
put
(
"pageSize"
,
basePageInfo
.
getPageSize
());
...
...
@@ -691,8 +690,8 @@ public class HmLinkController {
// if (page == null) {
// return RestResponse.successResult();
// }
Map
<
String
,
Object
>
res
=
DataApi
Http
Utils
.
http
(
jsonObject
.
toJSONString
(),
StatisticsApolloKeyConstant
.
data_haoban_link_list
);
Page
page
=
DataApi
Http
Utils
.
getPageData
(
res
);
Map
<
String
,
Object
>
res
=
DataApiUtils
.
http
(
jsonObject
.
toJSONString
(),
StatisticsApolloKeyConstant
.
data_haoban_link_list
);
Page
page
=
DataApiUtils
.
getPageData
(
res
);
Page
<
HmLinkListVO
>
retPage
=
EntityUtil
.
changeEntityByJSON
(
Page
.
class
,
page
);
if
(
CollectionUtils
.
isEmpty
(
page
.
getResult
()))
{
...
...
@@ -772,8 +771,8 @@ public class HmLinkController {
JSONObject
param
=
DataStatisticsParamUtils
.
getParamNoPage
(
jsonObject
);
// DataStatisticsParamUtils.responseOne(DataHttpUtil.post(StatisticsApolloKeyConstant.data_haoban_link_overview, param));
// HmLinkStatisticsVO vo = new HmLinkStatisticsVO();
Map
<
String
,
Object
>
res
=
DataApi
Http
Utils
.
http
(
jsonObject
.
toJSONString
(),
StatisticsApolloKeyConstant
.
data_haoban_link_overview
);
return
RestResponse
.
successResult
(
DataApiHttpUtils
.
getDataOne
(
res
));
Map
<
String
,
Object
>
res
=
DataApiUtils
.
http
(
jsonObject
.
toJSONString
(),
StatisticsApolloKeyConstant
.
data_haoban_link_overview
);
return
RestResponse
.
successResult
(
getDataOne
(
res
));
}
// 统计图表
...
...
@@ -807,13 +806,13 @@ public class HmLinkController {
// JSONObject param = DataStatisticsParamUtils.getParamNoPage(jsonObject);
// StatisticsDTO newDTO = DataHttpUtil.post(apolloKey, param);
Map
<
String
,
Object
>
res
=
DataApi
Http
Utils
.
http
(
jsonObject
.
toJSONString
(),
apolloKey
);
List
<
JSONObject
>
resList
=
DataApi
Http
Utils
.
getDataList
(
res
);
Map
<
String
,
Object
>
res
=
DataApiUtils
.
http
(
jsonObject
.
toJSONString
(),
apolloKey
);
List
<
JSONObject
>
resList
=
DataApiUtils
.
getDataList
(
res
);
Map
<
String
,
JSONObject
>
newMap
=
getTrendMapNew
(
resList
);
//
// StatisticsDTO clickDTO = DataHttpUtil.post(clickApolloKey, param);
Map
<
String
,
Object
>
clerkRes
=
DataApi
Http
Utils
.
http
(
jsonObject
.
toJSONString
(),
clickApolloKey
);
List
<
JSONObject
>
clerkResList
=
DataApi
Http
Utils
.
getDataList
(
clerkRes
);
Map
<
String
,
Object
>
clerkRes
=
DataApiUtils
.
http
(
jsonObject
.
toJSONString
(),
clickApolloKey
);
List
<
JSONObject
>
clerkResList
=
DataApiUtils
.
getDataList
(
clerkRes
);
Map
<
String
,
JSONObject
>
clickMap
=
getTrendMapNew
(
clerkResList
);
List
<
JSONObject
>
resultList
=
new
ArrayList
<>();
for
(
String
date
:
dateList
)
{
...
...
@@ -845,17 +844,20 @@ public class HmLinkController {
qo
.
getInFields
().
setEnterpriseId
(
loginUser
.
getEnterpriseId
());
JSONObject
paramJson
=
(
JSONObject
)
JSON
.
toJSON
(
qo
.
getInFields
());
DataApiHttpUtils
.
dealParamJsonClerkSelect
(
paramJson
,
"linkSelect1"
,
"vagueQueryStore"
);
DataApiHttpUtils
.
dealParamJsonClerkSelect
(
paramJson
,
"linkSelect2"
,
"vagueQueryClerk"
);
DataApiHttpUtils
.
dealParamJsonDate
(
paramJson
);
DataApiUtils
.
dealParamJson
(
paramJson
,
"linkSelect1"
,
"vagueQueryStore"
);
DataApiUtils
.
dealParamJson
(
paramJson
,
"linkSelect2"
,
"vagueQueryClerk"
);
DataApiUtils
.
dealParamJson
(
paramJson
,
"startTime"
,
"startDate"
);
DataApiUtils
.
dealParamJson
(
paramJson
,
"endTime"
,
"endDate"
);
Map
<
String
,
Integer
>
orderByFieldMap
=
new
HashMap
<
String
,
Integer
>(
8
){{
put
(
"addNumT"
,
8
);
put
(
"addNum"
,
9
);
}};
DataApiHttpUtils
.
dealParamJsonOrderBy
(
paramJson
,
qo
.
getInFields
().
getOrderByField
(),
"addNum"
,
orderByFieldMap
);
Map
<
String
,
Object
>
res
=
DataApiHttpUtils
.
http
(
paramJson
.
toJSONString
(),
StatisticsApolloKeyConstant
.
data_haoban_link_detail
);
paramJson
.
put
(
"orderByType"
,
DataApiUtils
.
getOrderByType
(
qo
.
getInFields
().
getOrderByField
()));
paramJson
.
put
(
"orderByFields"
,
DataApiUtils
.
getOrderByFields
(
qo
.
getInFields
().
getOrderByField
(),
"addNum"
,
orderByFieldMap
));
Map
<
String
,
Object
>
res
=
DataApiUtils
.
http
(
paramJson
.
toJSONString
(),
StatisticsApolloKeyConstant
.
data_haoban_link_detail
);
return
RestResponse
.
successResult
(
DataApi
Http
Utils
.
getPageData
(
res
));
return
RestResponse
.
successResult
(
DataApiUtils
.
getPageData
(
res
));
}
/**
...
...
@@ -895,4 +897,9 @@ public class HmLinkController {
return
newMap
;
}
public
static
JSONObject
getDataOne
(
Map
<
String
,
Object
>
res
)
{
List
<
JSONObject
>
list
=
DataApiUtils
.
getDataList
(
res
);
return
CollectionUtils
.
isNotEmpty
(
list
)
?
list
.
get
(
0
)
:
null
;
}
}
haoban-manage3-web/src/main/java/com/gic/haoban/manage/web/controller/hm/HmQrcodeController.java
View file @
6026d88d
...
...
@@ -12,7 +12,7 @@ import java.util.stream.Collectors;
import
com.alibaba.fastjson.JSONObject
;
import
com.gic.haoban.manage.api.dto.statistics.StatisticsPage
;
import
com.gic.
haoban.manage.web.utils.DataApiHttp
Utils
;
import
com.gic.
web.common.utils.DataApi
Utils
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.logging.log4j.LogManager
;
...
...
@@ -51,7 +51,6 @@ import com.gic.haoban.manage.api.service.hm.HmClerkRelationApiService;
import
com.gic.haoban.manage.api.service.hm.HmGroupApiService
;
import
com.gic.haoban.manage.api.service.hm.HmQrcodeApiService
;
import
com.gic.haoban.manage.api.service.hm.WxUserAddLogApiService
;
import
com.gic.haoban.manage.api.util.DataHttpUtil
;
import
com.gic.haoban.manage.web.dto.HmOverviewDTO
;
import
com.gic.haoban.manage.web.errCode.HaoBanErrCode
;
import
com.gic.haoban.manage.web.qo.hm.HmBatchModifyQO
;
...
...
@@ -60,7 +59,6 @@ import com.gic.haoban.manage.web.qo.hm.HmQrcodeUpdateQO;
import
com.gic.haoban.manage.web.qo.hm.data.HmDetailClerkListQO
;
import
com.gic.haoban.manage.web.qo.hm.data.HmQrcodeListQO
;
import
com.gic.haoban.manage.web.qo.hm.data.HmTrendQO
;
import
com.gic.haoban.manage.web.utils.statistics.DataStatisticsParamUtils
;
import
com.gic.haoban.manage.web.utils.statistics.DateUtils
;
import
com.gic.haoban.manage.web.vo.hm.HmDetailClerkListVO
;
import
com.gic.haoban.manage.web.vo.hm.HmTrendVO
;
...
...
@@ -205,17 +203,19 @@ public class HmQrcodeController {
JSONObject
paramJson
=
(
JSONObject
)
JSON
.
toJSON
(
hmQrcodeListQO
.
getInFields
());
paramJson
.
put
(
"pageNum"
,
hmQrcodeListQO
.
getPageNo
());
paramJson
.
put
(
"pageSize"
,
hmQrcodeListQO
.
getPageSize
());
DataApiHttpUtils
.
dealParamJsonDate
(
paramJson
);
DataApiUtils
.
dealParamJson
(
paramJson
,
"startTime"
,
"startDate"
);
DataApiUtils
.
dealParamJson
(
paramJson
,
"endTime"
,
"endDate"
);
Map
<
String
,
Integer
>
orderByFieldMap
=
new
HashMap
<
String
,
Integer
>(
8
){{
put
(
"createTime"
,
15
);
put
(
"addNumT"
,
6
);
put
(
"addNum"
,
7
);
}};
DataApiHttpUtils
.
dealParamJsonOrderBy
(
paramJson
,
hmQrcodeListQO
.
getInFields
().
getOrderByField
(),
"createTime"
,
orderByFieldMap
);
//todo guojx 参数调整
Map
<
String
,
Object
>
res
=
DataApiHttpUtils
.
http
(
paramJson
.
toJSONString
(),
StatisticsApolloKeyConstant
.
data_haoban_hm_list
);
List
<
HmQrcodeListDTO
>
data
=
DataApiHttpUtils
.
parsePageList
(
res
,
HmQrcodeListDTO
.
class
);
Page
resPage
=
DataApiHttpUtils
.
getPageData
(
res
);
paramJson
.
put
(
"orderByType"
,
DataApiUtils
.
getOrderByType
(
hmQrcodeListQO
.
getInFields
().
getOrderByField
()));
paramJson
.
put
(
"orderByFields"
,
DataApiUtils
.
getOrderByFields
(
hmQrcodeListQO
.
getInFields
().
getOrderByField
(),
"createTime"
,
orderByFieldMap
));
Map
<
String
,
Object
>
res
=
DataApiUtils
.
http
(
paramJson
.
toJSONString
(),
StatisticsApolloKeyConstant
.
data_haoban_hm_list
);
List
<
HmQrcodeListDTO
>
data
=
DataApiUtils
.
parsePageDataList
(
res
,
HmQrcodeListDTO
.
class
);
Page
resPage
=
DataApiUtils
.
getPageData
(
res
);
StatisticsDTO
statisticsDTO
=
new
StatisticsDTO
();
StatisticsPage
page
=
EntityUtil
.
changeEntityNew
(
StatisticsPage
.
class
,
resPage
);
...
...
@@ -396,8 +396,8 @@ public class HmQrcodeController {
// HmOverviewDTO hmOverviewDTO = JSON.parseObject(JSON.toJSONString(statisticsDTO.getOne()), HmOverviewDTO.class);
JSONObject
paramJson
=
(
JSONObject
)
JSON
.
toJSON
(
hmTrendQO
.
getInFields
());
Map
<
String
,
Object
>
res
=
DataApi
Http
Utils
.
http
(
paramJson
.
toJSONString
(),
StatisticsApolloKeyConstant
.
data_haoban_hm_overview
);
List
<
HmOverviewDTO
>
resList
=
DataApi
HttpUtils
.
parse
List
(
res
,
HmOverviewDTO
.
class
);
Map
<
String
,
Object
>
res
=
DataApiUtils
.
http
(
paramJson
.
toJSONString
(),
StatisticsApolloKeyConstant
.
data_haoban_hm_overview
);
List
<
HmOverviewDTO
>
resList
=
DataApi
Utils
.
parseData
List
(
res
,
HmOverviewDTO
.
class
);
HmOverviewDTO
hmOverviewDTO
=
CollectionUtils
.
isEmpty
(
resList
)
?
null
:
resList
.
get
(
0
);
...
...
@@ -405,20 +405,21 @@ public class HmQrcodeController {
List
<
Map
>
list
=
new
ArrayList
<>();
Map
<
String
,
Object
>
trendRes
=
null
;
DataApiHttpUtils
.
dealParamJsonDate
(
paramJson
);
DataApiUtils
.
dealParamJson
(
paramJson
,
"startTime"
,
"startDate"
);
DataApiUtils
.
dealParamJson
(
paramJson
,
"endTime"
,
"endDate"
);
if
(
type
==
1
)
{
//天
// StatisticsDTO dto = DataHttpUtil.post(StatisticsApolloKeyConstant.data_haoban_hm_trend_d, hmTrendQO);
trendRes
=
DataApi
Http
Utils
.
http
(
paramJson
.
toJSONString
(),
trendRes
=
DataApiUtils
.
http
(
paramJson
.
toJSONString
(),
StatisticsApolloKeyConstant
.
data_haoban_hm_trend_d
);
}
else
if
(
type
==
2
)
{
//月
// StatisticsDTO dto = DataHttpUtil.post(StatisticsApolloKeyConstant.data_haoban_hm_trend_m, hmTrendQO);
trendRes
=
DataApi
Http
Utils
.
http
(
paramJson
.
toJSONString
(),
trendRes
=
DataApiUtils
.
http
(
paramJson
.
toJSONString
(),
StatisticsApolloKeyConstant
.
data_haoban_hm_trend_m
);
}
if
(
trendRes
!=
null
)
{
list
=
JSON
.
parseArray
(
JSON
.
toJSONString
(
DataApi
Http
Utils
.
getDataList
(
trendRes
)),
Map
.
class
);
list
=
JSON
.
parseArray
(
JSON
.
toJSONString
(
DataApiUtils
.
getDataList
(
trendRes
)),
Map
.
class
);
}
if
(
hmTrendVO
==
null
)
{
hmTrendVO
=
new
HmTrendVO
();
...
...
@@ -503,20 +504,23 @@ public class HmQrcodeController {
put
(
"addNumT"
,
9
);
put
(
"addNum"
,
10
);
}};
DataApiHttpUtils
.
dealParamJsonClerkSelect
(
paramJson
,
"storeSelect"
,
"vagueQueryStore"
);
DataApiHttpUtils
.
dealParamJsonClerkSelect
(
paramJson
,
"clerkSelect"
,
"vagueQueryClerk"
);
DataApiHttpUtils
.
dealParamJsonDate
(
paramJson
);
DataApiHttpUtils
.
dealParamJsonOrderBy
(
paramJson
,
hmDetailClerkListQO
.
getInFields
().
getOrderByField
(),
"addNum"
,
orderByFieldMap
);
DataApiUtils
.
dealParamJson
(
paramJson
,
"storeSelect"
,
"vagueQueryStore"
);
DataApiUtils
.
dealParamJson
(
paramJson
,
"clerkSelect"
,
"vagueQueryClerk"
);
DataApiUtils
.
dealParamJson
(
paramJson
,
"startTime"
,
"startDate"
);
DataApiUtils
.
dealParamJson
(
paramJson
,
"endTime"
,
"endDate"
);
paramJson
.
put
(
"orderByType"
,
DataApiUtils
.
getOrderByType
(
hmDetailClerkListQO
.
getInFields
().
getOrderByField
()));
paramJson
.
put
(
"orderByFields"
,
DataApiUtils
.
getOrderByFields
(
hmDetailClerkListQO
.
getInFields
().
getOrderByField
(),
"addNum"
,
orderByFieldMap
));
Map
<
String
,
Object
>
res
=
null
;
Page
page
=
new
Page
();
if
(
hmType
==
1
)
{
// statisticsDTO = DataHttpUtil.post(StatisticsApolloKeyConstant.data_haoban_hm_single_detail, hmDetailClerkListQO);
res
=
DataApi
Http
Utils
.
http
(
paramJson
.
toJSONString
(),
StatisticsApolloKeyConstant
.
data_haoban_hm_single_detail
);
page
.
setResult
(
DataApi
Http
Utils
.
getDataList
(
res
));
res
=
DataApiUtils
.
http
(
paramJson
.
toJSONString
(),
StatisticsApolloKeyConstant
.
data_haoban_hm_single_detail
);
page
.
setResult
(
DataApiUtils
.
getDataList
(
res
));
}
else
if
(
hmType
==
2
)
{
// statisticsDTO = DataHttpUtil.post(StatisticsApolloKeyConstant.data_haoban_hm_many_detail, hmDetailClerkListQO);
res
=
DataApi
Http
Utils
.
http
(
paramJson
.
toJSONString
(),
StatisticsApolloKeyConstant
.
data_haoban_hm_many_detail
);
page
=
DataApi
Http
Utils
.
getPageData
(
res
);
res
=
DataApiUtils
.
http
(
paramJson
.
toJSONString
(),
StatisticsApolloKeyConstant
.
data_haoban_hm_many_detail
);
page
=
DataApiUtils
.
getPageData
(
res
);
}
return
RestResponse
.
successResult
(
page
);
...
...
haoban-manage3-web/src/main/java/com/gic/haoban/manage/web/utils/DataApiHttpUtils.java
deleted
100644 → 0
View file @
111bc673
package
com
.
gic
.
haoban
.
manage
.
web
.
utils
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.ctrip.framework.apollo.Config
;
import
com.ctrip.framework.apollo.ConfigService
;
import
com.gic.api.base.commons.Page
;
import
com.gic.commons.util.EntityUtil
;
import
com.gic.commons.util.HttpClient
;
import
com.gic.commons.webapi.reponse.RestResponse
;
import
com.gic.marketing.api.exception.ErrmsgException
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.lang.StringUtils
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
import
java.util.Collections
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
/**
* 数据组http接口调用工具类
* @Author guojx
* @Date 2023/6/25 14:39
*/
public
class
DataApiHttpUtils
{
private
static
final
Logger
LOGGER
=
LogManager
.
getLogger
(
DataApiHttpUtils
.
class
);
public
static
<
T
>
RestResponse
<
Page
<
T
>>
responsePage
(
Map
<
String
,
Object
>
res
,
Class
clazz
)
{
if
(
isSuccess
(
res
))
{
Page
page
=
getPageData
(
res
);
if
(
CollectionUtils
.
isNotEmpty
(
page
.
getResult
()))
{
Page
<
T
>
resPage
=
EntityUtil
.
changeEntityNew
(
Page
.
class
,
page
);
List
voList
=
JSONObject
.
parseArray
(
JSON
.
toJSONString
(
page
.
getResult
()),
clazz
);
resPage
.
setResult
(
voList
);
return
RestResponse
.
successResult
(
resPage
);
}
return
RestResponse
.
successResult
(
page
);
}
return
errorRes
(
res
);
}
public
static
<
T
>
RestResponse
<
List
<
T
>>
responsePageList
(
Map
<
String
,
Object
>
res
,
Class
clazz
)
{
return
RestResponse
.
successResult
(
parsePageList
(
res
,
clazz
));
}
public
static
<
T
>
List
<
T
>
parsePageList
(
Map
<
String
,
Object
>
res
,
Class
clazz
)
{
Page
page
=
getPageData
(
res
);
if
(
CollectionUtils
.
isNotEmpty
(
page
.
getResult
()))
{
List
voList
=
JSONObject
.
parseArray
(
JSON
.
toJSONString
(
page
.
getResult
()),
clazz
);
return
voList
;
}
return
Collections
.
EMPTY_LIST
;
}
public
static
boolean
isSuccess
(
Map
<
String
,
Object
>
res
)
{
return
res
.
get
(
"errCode"
).
toString
().
equals
(
"0"
);
}
public
static
RestResponse
errorRes
(
Map
<
String
,
Object
>
res
)
{
return
RestResponse
.
failure
(
res
.
get
(
"errCode"
).
toString
(),
res
.
get
(
"errMsg"
).
toString
());
}
public
static
<
T
>
List
<
T
>
parseList
(
Map
<
String
,
Object
>
res
,
Class
clazz
)
{
List
<
JSONObject
>
list
=
getDataList
(
res
);
if
(
CollectionUtils
.
isNotEmpty
(
list
))
{
List
voList
=
JSONObject
.
parseArray
(
JSON
.
toJSONString
(
list
),
clazz
);
return
voList
;
}
return
Collections
.
EMPTY_LIST
;
}
public
static
List
<
JSONObject
>
getDataList
(
Map
<
String
,
Object
>
res
)
{
return
(
List
<
JSONObject
>)
res
.
get
(
"data"
);
}
public
static
JSONObject
getDataOne
(
Map
<
String
,
Object
>
res
)
{
List
<
JSONObject
>
list
=
getDataList
(
res
);
return
CollectionUtils
.
isNotEmpty
(
list
)
?
list
.
get
(
0
)
:
null
;
}
public
static
Page
getPageData
(
Map
<
String
,
Object
>
res
)
{
if
(!
isSuccess
(
res
))
{
throw
new
ErrmsgException
(
res
.
get
(
"errMsg"
).
toString
());
}
JSONObject
data
=
(
JSONObject
)
res
.
get
(
"data"
);
Page
page
=
new
Page
();
page
.
setTotalCount
(
data
.
getIntValue
(
"totalNum"
));
page
.
setPageSize
(
data
.
getIntValue
(
"pageSize"
));
page
.
setCurrentPage
(
data
.
getIntValue
(
"pageNum"
));
List
<
JSONObject
>
list
=
(
List
<
JSONObject
>)
data
.
get
(
"rows"
);
page
.
setResult
(
list
);
return
page
;
}
public
static
JSONObject
getPageOne
(
Map
<
String
,
Object
>
res
)
{
Page
page
=
getPageData
(
res
);
if
(
CollectionUtils
.
isNotEmpty
(
page
.
getResult
()))
{
return
(
JSONObject
)
page
.
getResult
().
get
(
0
);
}
return
new
JSONObject
();
}
public
static
List
<
JSONObject
>
getPageList
(
Map
<
String
,
Object
>
res
)
{
Page
page
=
getPageData
(
res
);
if
(
CollectionUtils
.
isNotEmpty
(
page
.
getResult
()))
{
return
(
List
<
JSONObject
>)
page
.
getResult
();
}
return
Collections
.
EMPTY_LIST
;
}
public
static
Map
<
String
,
Object
>
http
(
String
jsonParam
,
String
apolloKey
)
{
if
(
StringUtils
.
isNotBlank
(
jsonParam
))
{
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
jsonParam
);
dealStoreIdParam
(
jsonObject
);
jsonParam
=
jsonObject
.
toJSONString
();
}
LOGGER
.
info
(
"接口的key:{}"
,
apolloKey
);
Config
config
=
ConfigService
.
getConfig
(
"COMMON.data-api-config"
);
String
value
=
config
.
getProperty
(
apolloKey
,
""
);
if
(
StringUtils
.
isBlank
(
value
))
{
throw
new
ErrmsgException
(
"数据接口配置有误!"
);
}
LOGGER
.
info
(
"{}:Apollo查询的配置信息:{}"
,
apolloKey
,
value
);
String
[]
split
=
value
.
split
(
"\\+\\+\\+\\+"
);
String
url
=
split
[
0
];
String
token
=
split
[
1
];
Map
<
String
,
String
>
head
=
new
HashMap
<>();
head
.
put
(
"Content-Type"
,
"application/json"
);
head
.
put
(
"Authorization"
,
token
);
Map
<
String
,
Object
>
res
=
HttpClient
.
getWinxinResByJson
(
url
,
jsonParam
,
head
);
if
(!
isSuccess
(
res
))
{
throw
new
ErrmsgException
(
res
.
get
(
"errMsg"
).
toString
());
}
LOGGER
.
info
(
"调用接口{},返回结果:{}"
,
url
,
res
);
return
res
;
}
public
static
void
dealStoreIdParam
(
JSONObject
objParam
)
{
if
(
objParam
!=
null
)
{
if
(
objParam
.
containsKey
(
"storeId"
))
{
Object
storeId
=
objParam
.
get
(
"storeId"
);
if
(
storeId
==
null
||
StringUtils
.
isBlank
(
storeId
.
toString
()))
{
objParam
.
remove
(
"storeId"
);
}
}
}
}
public
static
int
getOrderByType
(
String
str
)
{
if
(
StringUtils
.
isBlank
(
str
))
{
return
2
;
}
if
(
str
.
contains
(
"desc"
))
{
return
2
;
}
return
1
;
}
public
static
int
getOrderByFields
(
String
str
,
String
defaultStr
,
Map
<
String
,
Integer
>
map
)
{
if
(
StringUtils
.
isBlank
(
str
))
{
str
=
defaultStr
;
}
str
=
str
.
replace
(
" desc"
,
""
);
str
=
str
.
replace
(
" asc"
,
""
);
str
=
str
.
replace
(
" "
,
""
);
return
map
.
get
(
str
);
}
public
static
void
dealParamJsonDate
(
JSONObject
paramJson
)
{
dealParamJsonClerkSelect
(
paramJson
,
"startTime"
,
"startDate"
);
dealParamJsonClerkSelect
(
paramJson
,
"endTime"
,
"endDate"
);
}
public
static
void
dealParamJsonClerkSelect
(
JSONObject
paramJson
,
String
field
,
String
httpField
)
{
if
(
paramJson
.
containsKey
(
field
))
{
paramJson
.
put
(
httpField
,
paramJson
.
get
(
field
));
}
}
public
static
void
dealParamJsonOrderBy
(
JSONObject
paramJson
,
String
orderByStr
,
String
defaultField
,
Map
<
String
,
Integer
>
orderByFieldMap
)
{
paramJson
.
put
(
"orderByType"
,
getOrderByType
(
orderByStr
));
paramJson
.
put
(
"orderByFields"
,
getOrderByFields
(
orderByStr
,
defaultField
,
orderByFieldMap
));
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment