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
194e9060
Commit
194e9060
authored
Nov 30, 2023
by
guojx
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
趋势图
parent
e89082f9
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
209 additions
and
1 deletions
+209
-1
DataController.java
...gic/haoban/manage/web/controller/data/DataController.java
+80
-1
DateFillUtils.java
...n/java/com/gic/haoban/manage/web/utils/DateFillUtils.java
+126
-0
dubbo-haoban-manage-wx.xml
...ge3-wx/src/main/webapp/WEB-INF/dubbo-haoban-manage-wx.xml
+3
-0
No files found.
haoban-manage3-wx/src/main/java/com/gic/haoban/manage/web/controller/data/DataController.java
View file @
194e9060
...
...
@@ -5,19 +5,27 @@ 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.api.base.commons.ServiceResponse
;
import
com.gic.commons.util.DataApiUtils
;
import
com.gic.commons.util.EntityUtil
;
import
com.gic.commons.util.GlobalVar
;
import
com.gic.commons.util.HttpClient
;
import
com.gic.commons.webapi.reponse.RestResponse
;
import
com.gic.enterprise.api.dto.EnterpriseSettingDTO
;
import
com.gic.enterprise.api.dto.EnterpriseSourceChannelDTO
;
import
com.gic.enterprise.api.dto.data.DataIndexEvaluateLogDTO
;
import
com.gic.enterprise.api.dto.data.DataIndexExplainDTO
;
import
com.gic.enterprise.api.enums.PlatformChannelEnum
;
import
com.gic.enterprise.api.enums.PlatformEnum
;
import
com.gic.enterprise.api.service.EnterpriseChannelApiService
;
import
com.gic.enterprise.api.service.EnterpriseService
;
import
com.gic.enterprise.api.service.data.DataIndexApiService
;
import
com.gic.enterprise.service.CustomSettingApiService
;
import
com.gic.haoban.manage.web.qo.data.DataIndexExplainVO
;
import
com.gic.haoban.manage.web.qo.data.DataIndexQO
;
import
com.gic.haoban.manage.web.qo.data.DataMemberExtendQO
;
import
com.gic.haoban.manage.web.qo.data.HandleQO
;
import
com.gic.haoban.manage.web.utils.DateFillUtils
;
import
com.gic.haoban.manage.web.utils.StoreAuthUtils
;
import
com.gic.haoban.manage.web.vo.data.DataMemberExtendVO
;
import
org.apache.commons.collections.CollectionUtils
;
...
...
@@ -45,6 +53,10 @@ public class DataController {
private
DataIndexApiService
dataIndexApiService
;
@Autowired
private
CustomSettingApiService
customSettingApiService
;
@Autowired
private
EnterpriseChannelApiService
enterpriseChannelApiService
;
@Autowired
private
EnterpriseService
enterpriseService
;
private
String
isProd
()
{
Config
config
=
ConfigService
.
getConfig
(
"COMMON.gic-properties"
);
...
...
@@ -138,6 +150,43 @@ public class DataController {
jsonObject
.
put
(
"storeId"
,
storeIdList
.
stream
().
collect
(
Collectors
.
joining
(
","
)));
}
Map
<
String
,
Object
>
res
=
DataApiUtils
.
http
(
jsonObject
.
toJSONString
(),
qo
.
getApolloKey
());
String
apolloKey
=
qo
.
getApolloKey
();
boolean
isNeedFill
=
(
apolloKey
.
contains
(
"custom"
)
||
apolloKey
.
contains
(
"month"
)
||
apolloKey
.
contains
(
"day"
)
||
apolloKey
.
contains
(
"week"
))
&&
jsonObject
.
containsKey
(
"storeGroup"
)
&&
(
jsonObject
.
getInteger
(
"storeGroup"
)
==
3
||
jsonObject
.
getInteger
(
"storeGroup"
)
==
4
||
jsonObject
.
getInteger
(
"storeGroup"
)
==
2
);
if
(
isNeedFill
)
{
List
<
JSONObject
>
resultList
=
DataApiUtils
.
getDataList
(
res
);
List
<
String
>
dateTypeList
=
null
;
if
(
apolloKey
.
contains
(
"day"
))
{
dateTypeList
=
DateFillUtils
.
getDay
(
jsonObject
.
getString
(
"bizDate"
));
}
else
if
(
apolloKey
.
contains
(
"month"
))
{
dateTypeList
=
DateFillUtils
.
getMonth
(
jsonObject
.
getString
(
"startDate"
).
substring
(
0
,
7
));
}
else
if
(
apolloKey
.
contains
(
"week"
))
{
dateTypeList
=
DateFillUtils
.
getWeek
(
jsonObject
.
getString
(
"startDate"
));
}
else
if
(
apolloKey
.
contains
(
"custom"
))
{
dateTypeList
=
DateFillUtils
.
getCustom
(
jsonObject
.
getString
(
"startDate"
),
jsonObject
.
getString
(
"endDate"
));
}
if
(
CollectionUtils
.
isNotEmpty
(
dateTypeList
))
{
List
<
JSONObject
>
fillList
=
new
ArrayList
<>();
Map
<
String
,
JSONObject
>
fillMap
=
resultList
.
stream
().
collect
(
Collectors
.
toMap
(
e
->
e
.
getString
(
"bizDate"
),
e
->
e
));
for
(
String
dateTemp
:
dateTypeList
)
{
if
(
fillMap
.
get
(
dateTemp
)
!=
null
)
{
fillList
.
add
(
fillMap
.
get
(
dateTemp
));
}
else
{
JSONObject
fillJson
=
new
JSONObject
();
fillJson
.
put
(
"bizDate"
,
dateTemp
);
fillList
.
add
(
fillJson
);
}
}
return
RestResponse
.
successResult
(
fillList
);
}
}
return
RestResponse
.
successResult
(
res
.
get
(
"data"
));
}
...
...
@@ -185,12 +234,42 @@ public class DataController {
public
RestResponse
listChannelData
(
String
enterpriseId
)
{
Page
<
JSONObject
>
page
=
customSettingApiService
.
page
(
"tab_gic_channel_platform_dict"
,
""
,
1
,
1000
).
getResult
();
PlatformChannelEnum
[]
values
=
PlatformChannelEnum
.
values
();
Set
<
String
>
hasAuthSet
=
new
HashSet
<>();
for
(
PlatformChannelEnum
value
:
values
)
{
boolean
enable
=
true
;
// 微信渠道,pos渠道,其他渠道默认开通
if
(
PlatformEnum
.
WECHAT
.
equals
(
value
.
getBelongPlatform
())
||
PlatformEnum
.
POS
.
equals
(
value
.
getBelongPlatform
())
||
PlatformEnum
.
OTHER
.
equals
(
value
.
getBelongPlatform
())){
continue
;
}
else
if
(
PlatformChannelEnum
.
C_WEIMOB
==
value
){
//渠道查询判断是否开通
EnterpriseSettingDTO
enterpriseSettingDTO
=
enterpriseService
.
getEnterpriseSettingByEnterpriseId
(
enterpriseId
);
if
(
enterpriseSettingDTO
==
null
||
enterpriseSettingDTO
.
getEnterpriseSettingId
()
==
null
)
{
enable
=
false
;
}
//没开通微盟
if
(
enterpriseSettingDTO
.
getBackgroundMode
()
==
0
)
{
enable
=
false
;
}
}
else
{
// 抖音天猫渠道
ServiceResponse
<
EnterpriseSourceChannelDTO
>
response
=
enterpriseChannelApiService
.
getEnterpriseSourceChannel
(
enterpriseId
,
value
.
getChannelCodeOld
(),
1
);
if
(!
response
.
isSuccess
()
||
response
.
getResult
()==
null
){
enable
=
false
;
}
}
if
(
enable
)
{
hasAuthSet
.
add
(
value
.
getChannelCode
());
}
}
if
(
page
!=
null
)
{
List
<
JSONObject
>
list
=
page
.
getResult
();
List
<
JSONObject
>
result
=
new
ArrayList
<>();
for
(
JSONObject
json
:
list
)
{
if
(
"c_wechat_work"
.
equals
(
json
.
getString
(
"channelCode"
))
||
"c_wechat_gh"
.
equals
(
json
.
getString
(
"channelCode"
)))
{
||
"c_wechat_gh"
.
equals
(
json
.
getString
(
"channelCode"
))
||
!
hasAuthSet
.
contains
(
json
.
getString
(
"channelCode"
)))
{
continue
;
}
json
.
put
(
"dataChannelPre"
,
channelMap
().
get
(
json
.
getString
(
"channelCode"
)));
...
...
haoban-manage3-wx/src/main/java/com/gic/haoban/manage/web/utils/DateFillUtils.java
0 → 100644
View file @
194e9060
package
com
.
gic
.
haoban
.
manage
.
web
.
utils
;
import
com.alibaba.fastjson.JSONObject
;
import
com.gic.commons.util.DataApiUtils
;
import
lombok.extern.slf4j.Slf4j
;
import
java.text.SimpleDateFormat
;
import
java.util.ArrayList
;
import
java.util.Calendar
;
import
java.util.List
;
import
java.util.Map
;
/**
* @Author guojx
* @Date 2023/11/29 10:49
*/
@Slf4j
public
class
DateFillUtils
{
public
static
List
<
String
>
getDay
(
String
date
)
{
List
<
String
>
dateList
=
new
ArrayList
<>();
try
{
Calendar
calendar
=
Calendar
.
getInstance
();
SimpleDateFormat
df
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
calendar
.
setTime
(
df
.
parse
(
date
));
calendar
.
add
(
Calendar
.
DATE
,
-
29
);
String
temp
=
df
.
format
(
calendar
.
getTime
());
while
(
temp
.
compareTo
(
date
)
<=
0
)
{
dateList
.
add
(
temp
.
substring
(
5
));
calendar
.
add
(
Calendar
.
DATE
,
1
);
temp
=
df
.
format
(
calendar
.
getTime
());
}
}
catch
(
Exception
e
)
{
log
.
error
(
"时间匹配调整:{}"
,
e
.
getMessage
(),
e
);
}
return
dateList
;
}
public
static
List
<
String
>
getCustom
(
String
start
,
String
end
)
{
List
<
String
>
dateList
=
new
ArrayList
<>();
try
{
Calendar
calendar
=
Calendar
.
getInstance
();
SimpleDateFormat
df
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
calendar
.
setTime
(
df
.
parse
(
start
));
String
temp
=
df
.
format
(
calendar
.
getTime
());
while
(
temp
.
compareTo
(
end
)
<=
0
)
{
dateList
.
add
(
temp
.
substring
(
5
));
calendar
.
add
(
Calendar
.
DATE
,
1
);
temp
=
df
.
format
(
calendar
.
getTime
());
}
}
catch
(
Exception
e
)
{
log
.
error
(
"时间匹配调整:{}"
,
e
.
getMessage
(),
e
);
}
return
dateList
;
}
public
static
List
<
String
>
getWeek
(
String
date
)
{
List
<
String
>
dateList
=
new
ArrayList
<>();
try
{
Calendar
calendar
=
Calendar
.
getInstance
();
SimpleDateFormat
df
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
calendar
.
setTime
(
df
.
parse
(
date
));
calendar
.
add
(
Calendar
.
WEEK_OF_YEAR
,
-
11
);
String
temp
=
df
.
format
(
calendar
.
getTime
());
JSONObject
jsonObject
=
new
JSONObject
();
jsonObject
.
put
(
"pageNum"
,
1
);
jsonObject
.
put
(
"pageSize"
,
20
);
jsonObject
.
put
(
"startDate"
,
temp
);
jsonObject
.
put
(
"endDate"
,
date
);
Map
<
String
,
Object
>
res
=
DataApiUtils
.
http
(
jsonObject
.
toJSONString
(),
"data_pub_date_week"
);
List
<
JSONObject
>
list
=
DataApiUtils
.
getPageList
(
res
);
for
(
JSONObject
json
:
list
)
{
dateList
.
add
(
json
.
getString
(
"weekYear"
));
}
log
.
info
(
"week data:{}"
,
list
);
}
catch
(
Exception
e
)
{
log
.
error
(
"时间匹配调整:{}"
,
e
.
getMessage
(),
e
);
}
return
dateList
;
}
public
static
List
<
String
>
getYear
(
String
date
)
{
List
<
String
>
dateList
=
new
ArrayList
<>();
Integer
year
=
Integer
.
parseInt
(
date
);
Integer
min
=
year
-
11
;
for
(
int
i
=
min
;
i
<=
year
;
i
++)
{
dateList
.
add
(
i
+
""
);
}
return
dateList
;
}
public
static
List
<
String
>
getMonth
(
String
date
)
{
List
<
String
>
dateList
=
new
ArrayList
<>();
try
{
Calendar
calendar
=
Calendar
.
getInstance
();
SimpleDateFormat
df
=
new
SimpleDateFormat
(
"yyyy-MM"
);
calendar
.
setTime
(
df
.
parse
(
date
));
calendar
.
add
(
Calendar
.
MONTH
,
-
11
);
String
temp
=
df
.
format
(
calendar
.
getTime
());
while
(
temp
.
compareTo
(
date
)
<=
0
)
{
dateList
.
add
(
temp
);
calendar
.
add
(
Calendar
.
MONTH
,
1
);
temp
=
df
.
format
(
calendar
.
getTime
());
}
}
catch
(
Exception
e
)
{
log
.
error
(
"时间匹配调整:{}"
,
e
.
getMessage
(),
e
);
}
return
dateList
;
}
public
static
void
main
(
String
[]
args
)
{
log
.
info
(
""
+
JSONObject
.
toJSONString
(
getWeek
(
"2023-11-27"
)));
}
}
haoban-manage3-wx/src/main/webapp/WEB-INF/dubbo-haoban-manage-wx.xml
View file @
194e9060
...
...
@@ -162,4 +162,7 @@
timeout=
"10000"
retries=
"0"
check=
"false"
/>
<dubbo:reference
id=
"dataIndexApiService"
interface=
"com.gic.enterprise.api.service.data.DataIndexApiService"
timeout=
"10000"
retries=
"0"
check=
"false"
/>
<dubbo:reference
id=
"enterpriseChannelApiService"
interface=
"com.gic.enterprise.api.service.EnterpriseChannelApiService"
timeout=
"10000"
retries=
"0"
check=
"false"
/>
</beans>
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