Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
saasio
Project
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
reyun
saasio
Commits
340c8d0b
Commit
340c8d0b
authored
Mar 23, 2018
by
carrieyzzhang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
channel campaign name from trackingio
parent
5d91fee8
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
111 additions
and
27 deletions
+111
-27
pom.xml
pom.xml
+2
-1
ComplicatedEventsServiceImpl.java
.../com/reyun/service/impl/ComplicatedEventsServiceImpl.java
+80
-24
EventServiceImpl.java
src/main/java/com/reyun/service/impl/EventServiceImpl.java
+22
-2
VirtualEventImpl.java
src/main/java/com/reyun/service/impl/VirtualEventImpl.java
+4
-0
Constant.java
src/main/java/com/reyun/util/Constant.java
+1
-0
common.properties
src/main/resources/common.properties
+2
-0
No files found.
pom.xml
View file @
340c8d0b
...
...
@@ -61,6 +61,7 @@
<admin.url>
http://localhost:8080
</admin.url>
<receiver.host>
172.31.30.1,172.31.22.39,172.31.22.38,172.31.4.0,172.31.3.123,172.31.16.68,172.31.30.154,172.31.26.177
</receiver.host>
<receiver.port>
8080
</receiver.port>
<trackingio.url>
http://52.80.113.103:8002
</trackingio.url>
<mail.host>
smtp.exmail.qq.com
</mail.host>
...
...
@@ -73,7 +74,7 @@
<report.url>
http://172.31.1.122:9010
</report.url>
<presto.driver>
com.facebook.presto.jdbc.PrestoDriver
</presto.driver>
<presto.url>
jdbc:presto://172.31.
21.99
:18889/hive/default
</presto.url>
<presto.url>
jdbc:presto://172.31.
11.248
:18889/hive/default
</presto.url>
<presto.username>
root
</presto.username>
<profile.table>
kudu.default.profile_
</profile.table>
...
...
src/main/java/com/reyun/service/impl/ComplicatedEventsServiceImpl.java
View file @
340c8d0b
package
com
.
reyun
.
service
.
impl
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.google.common.base.Function
;
import
com.google.common.collect.Lists
;
import
com.google.common.collect.Maps
;
...
...
@@ -243,6 +244,7 @@ public class ComplicatedEventsServiceImpl implements ComplicateEventsService{
//关闭线程池
pool
.
shutdown
();
}
System
.
out
.
println
(
result
);
return
result
;
}
...
...
@@ -298,22 +300,46 @@ public class ComplicatedEventsServiceImpl implements ComplicateEventsService{
//处理数据
JSONObject
responseObject
=
JSONObject
.
fromObject
(
responseJson
);
if
(!
responseObject
.
containsKey
(
"val"
))
{
return
result
;
}
JSONArray
responseValueArray
=
responseObject
.
getJSONArray
(
"val"
);
//cid,campaignid数据转换
/*Map<String, Campaign> campaignMap = new HashMap<>();
Map<String, Channel> channelMap = new HashMap<>();*/
if
(!
CollectionUtils
.
isEmpty
(
responseValueArray
))
{
/*//group by _cid
//cid,campaignid数据转换
Map
<
String
,
String
>
campaignMap
=
new
HashMap
<>();
Map
<
String
,
String
>
channelMap
=
new
HashMap
<>();
//group by _cid or group by _campaignid
if
(
groupArray
.
toString
().
contains
(
FIELD_CID
)
||
groupArray
.
toString
().
contains
(
FIELD_CAMPAIGN_ID
))
{
Account
account
=
accountRepository
.
findOne
(
accountId
);
App
app
=
appRepository
.
findOne
(
appId
);
String
url
=
Constant
.
trackingUrl
+
"/api/"
+
app
.
getId
()
+
"/channel/findchannelcamp4io?appkey="
+
app
.
getAppkey
()
+
"&email="
+
account
.
getEmail
();
String
response
=
HttpClientUtil
.
doHttpGetRequest
(
url
,
"io"
);
if
(!
StringUtil
.
isEmpty
(
response
))
{
try
{
JSONObject
ob
=
JSONObject
.
fromObject
(
response
);
JSONObject
content
=
ob
.
getJSONObject
(
"content"
);
if
(
groupArray
.
toString
().
contains
(
FIELD_CID
))
{
channelMap = channelService.findChannelMapWithDefault(appId, accountId);
JSONObject
channelObject
=
content
.
getJSONObject
(
"channel"
);
ObjectMapper
mapper
=
new
ObjectMapper
();
channelMap
=
mapper
.
readValue
(
channelObject
.
toString
(),
Map
.
class
);
}
//group by _campaignid
if
(
groupArray
.
toString
().
contains
(
FIELD_CAMPAIGN_ID
))
{
campaignMap = campaignService.findCampaignMapWithDefault(appId, accountId);
}*/
JSONObject
campObject
=
content
.
getJSONObject
(
"campaign"
);
ObjectMapper
mapper
=
new
ObjectMapper
();
campaignMap
=
mapper
.
readValue
(
campObject
.
toString
(),
Map
.
class
);
}
}
catch
(
Exception
e
)
{
logger
.
error
(
"fail to get channel or campaign name"
);
}
}
}
//翻译处理
for
(
Object
valElement
:
responseValueArray
)
{
...
...
@@ -322,13 +348,13 @@ public class ComplicatedEventsServiceImpl implements ComplicateEventsService{
val
.
put
(
"ds"
,
"合计"
);
//翻译推广活动或者渠道
/*
if (val.containsKey(FIELD_CID)) {
val.put(FIELD_CID, channelMap.containsKey(val.getString(FIELD_CID)) ? channelMap.get(val.getString(FIELD_CID))
.getName()
: val.getString(FIELD_CID));
if
(
val
.
containsKey
(
FIELD_CID
))
{
val
.
put
(
FIELD_CID
,
channelMap
.
containsKey
(
val
.
getString
(
FIELD_CID
))
?
channelMap
.
get
(
val
.
getString
(
FIELD_CID
))
:
val
.
getString
(
FIELD_CID
));
}
if
(
val
.
containsKey
(
FIELD_CAMPAIGN_ID
))
{
val.put(FIELD_CAMPAIGN_ID, campaignMap.containsKey(val.getString(FIELD_CAMPAIGN_ID)) ? campaignMap.get(val.getString(FIELD_CAMPAIGN_ID))
.getName()
: val.getString(FIELD_CAMPAIGN_ID));
}
*/
val
.
put
(
FIELD_CAMPAIGN_ID
,
campaignMap
.
containsKey
(
val
.
getString
(
FIELD_CAMPAIGN_ID
))
?
campaignMap
.
get
(
val
.
getString
(
FIELD_CAMPAIGN_ID
))
:
val
.
getString
(
FIELD_CAMPAIGN_ID
));
}
result
.
add
(
val
);
}
...
...
@@ -963,23 +989,54 @@ public class ComplicatedEventsServiceImpl implements ComplicateEventsService{
try
{
JSONObject
responseObject
=
JSONObject
.
fromObject
(
responseJson
);
if
(!
responseObject
.
containsKey
(
"val"
))
{
resultMap
.
put
(
"val"
,
valueResult
);
resultMap
.
put
(
"columnkey"
,
columnKeyList
);
resultMap
.
put
(
"name"
,
nameList
);
resultMap
.
put
(
"key"
,
keyList
);
resultMap
.
put
(
"groupfield"
,
groupList
);
resultMap
.
put
(
"selectfield"
,
selectFieldList
);
resultMap
.
put
(
"format"
,
selectList
);
return
resultMap
;
}
JSONArray
responseValueArray
=
responseObject
.
getJSONArray
(
"val"
);
//val
if
(!
CollectionUtils
.
isEmpty
(
responseValueArray
))
{
//cid,campaignid数据转换
/*Map<String, Campaign
> campaignMap = new HashMap<>();
Map<String,
Channel
> channelMap = new HashMap<>();
Map
<
String
,
String
>
campaignMap
=
new
HashMap
<>();
Map
<
String
,
String
>
channelMap
=
new
HashMap
<>();
//group by _cid
//group by _cid or group by _campaignid
if
(
groupArray
.
toString
().
contains
(
FIELD_CID
)
||
groupArray
.
toString
().
contains
(
FIELD_CAMPAIGN_ID
))
{
Account
account
=
accountRepository
.
findOne
(
accountId
);
String
url
=
Constant
.
trackingUrl
+
"/api/"
+
app
.
getId
()
+
"/channel/findchannelcamp4io?appkey="
+
app
.
getAppkey
()
+
"&email="
+
account
.
getEmail
();
String
response
=
HttpClientUtil
.
doHttpGetRequest
(
url
,
"io"
);
if
(!
StringUtil
.
isEmpty
(
response
))
{
try
{
JSONObject
ob
=
JSONObject
.
fromObject
(
response
);
JSONObject
content
=
ob
.
getJSONObject
(
"content"
);
if
(
groupArray
.
toString
().
contains
(
FIELD_CID
))
{
channelMap = channelService.findChannelMapWithDefault(app.getId(), accountId);
JSONObject
channelObject
=
content
.
getJSONObject
(
"channel"
);
ObjectMapper
mapper
=
new
ObjectMapper
();
channelMap
=
mapper
.
readValue
(
channelObject
.
toString
(),
Map
.
class
);
}
//group by _campaignid
if
(
groupArray
.
toString
().
contains
(
FIELD_CAMPAIGN_ID
))
{
campaignMap = campaignService.findCampaignMapWithDefault(app.getId(), accountId);
}*/
JSONObject
campObject
=
content
.
getJSONObject
(
"campaign"
);
ObjectMapper
mapper
=
new
ObjectMapper
();
campaignMap
=
mapper
.
readValue
(
campObject
.
toString
(),
Map
.
class
);
}
}
catch
(
Exception
e
)
{
logger
.
error
(
"fail to get channel or campaign name"
);
}
}
}
//1,处理日期合并(给每个日期的第一行加标注,firstDateRow标示第一行,rowNum标示相同日期行数)
String
firstValueDate
=
""
;
...
...
@@ -1022,15 +1079,15 @@ public class ComplicatedEventsServiceImpl implements ComplicateEventsService{
}
//2翻译推广活动或者渠道
/*
if (val.containsKey(FIELD_CID)) {
if
(
val
.
containsKey
(
FIELD_CID
))
{
String
cid
=
val
.
getString
(
FIELD_CID
);
val.put(FIELD_CID, channelMap.containsKey(cid) ? channelMap.get(cid)
.getName()
: cid);
val
.
put
(
FIELD_CID
,
channelMap
.
containsKey
(
cid
)
?
channelMap
.
get
(
cid
)
:
cid
);
}
if
(
val
.
containsKey
(
FIELD_CAMPAIGN_ID
))
{
String
campaignId
=
val
.
getString
(
FIELD_CAMPAIGN_ID
);
val.put(FIELD_CAMPAIGN_ID, campaignMap.containsKey(campaignId) ? campaignMap.get(campaignId)
.getName()
: campaignId);
}
*/
val
.
put
(
FIELD_CAMPAIGN_ID
,
campaignMap
.
containsKey
(
campaignId
)
?
campaignMap
.
get
(
campaignId
)
:
campaignId
);
}
//添加到val中
...
...
@@ -1111,7 +1168,6 @@ public class ComplicatedEventsServiceImpl implements ComplicateEventsService{
resultMap
.
put
(
"key"
,
keyList
);
resultMap
.
put
(
"groupfield"
,
groupList
);
resultMap
.
put
(
"selectfield"
,
selectFieldList
);
// resultMap.put("totalval", totalValueList);
resultMap
.
put
(
"format"
,
selectList
);
return
resultMap
;
...
...
src/main/java/com/reyun/service/impl/EventServiceImpl.java
View file @
340c8d0b
package
com
.
reyun
.
service
.
impl
;
import
com.fasterxml.jackson.core.JsonParseException
;
import
com.fasterxml.jackson.databind.JsonMappingException
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.google.common.base.Function
;
import
com.google.common.collect.ImmutableMap
;
import
com.google.common.collect.Lists
;
...
...
@@ -7,11 +10,11 @@ import com.google.common.collect.Maps;
import
com.reyun.model.*
;
import
com.reyun.repository.*
;
import
com.reyun.service.*
;
import
com.reyun.util.EventRedisUtil
;
import
com.reyun.util.ValidateUtil
;
import
com.reyun.util.*
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.json.JSONArray
;
import
org.json.JSONException
;
import
org.json.JSONObject
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -19,6 +22,7 @@ import org.springframework.stereotype.Service;
import
org.springframework.util.StringUtils
;
import
javax.annotation.Nullable
;
import
java.io.IOException
;
import
java.math.BigInteger
;
import
java.util.*
;
...
...
@@ -939,10 +943,26 @@ public class EventServiceImpl implements EventService {
List
<
String
>
valueList
=
new
ArrayList
<>(
set
);
String
values
=
String
.
join
(
","
,
set
);
String
url
=
Constant
.
trackingUrl
+
"/api/"
+
appId
+
"/event/find/valuespecail?attrName="
+
attrName
+
"&values="
+
values
;
String
response
=
HttpClientUtil
.
doHttpGetRequest
(
url
,
"io"
);
if
(!
StringUtil
.
isEmpty
(
response
))
{
try
{
JSONObject
ob
=
new
JSONObject
(
response
);
JSONObject
content
=
ob
.
getJSONObject
(
"content"
);
ObjectMapper
mapper
=
new
ObjectMapper
();
result
=
mapper
.
readValue
(
content
.
toString
(),
Map
.
class
);
}
catch
(
Exception
e
)
{
result
.
put
(
"value"
,
valueList
);
}
}
else
{
result
.
put
(
"value"
,
valueList
);
}
}
}
else
{
//查询用户群
List
<
UserGroup
>
userGroupList
=
usergroupService
.
list
(
appId
);
...
...
src/main/java/com/reyun/service/impl/VirtualEventImpl.java
View file @
340c8d0b
...
...
@@ -19,6 +19,7 @@ import com.reyun.service.ConfigParamService;
import
com.reyun.service.EventService
;
import
com.reyun.service.VirtualEventService
;
import
com.reyun.util.PinYinUtil
;
import
com.reyun.util.StringUtil
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.CollectionUtils
;
...
...
@@ -177,6 +178,9 @@ public class VirtualEventImpl implements VirtualEventService {
}
private
String
parseEventList
(
String
events
,
Long
appId
)
{
if
(
StringUtil
.
isEmpty
(
events
))
{
return
""
;
}
String
[]
eventList
=
events
.
split
(
","
);
List
<
String
>
eventArrayList
=
Lists
.
newArrayList
(
eventList
);
...
...
src/main/java/com/reyun/util/Constant.java
View file @
340c8d0b
...
...
@@ -34,6 +34,7 @@ public class Constant {
public
static
String
accountCheckUrl
=
commonBundle
.
getString
(
"account.check.url"
);
public
static
String
reportUrl
=
commonBundle
.
getString
(
"report.url"
);
public
static
String
adminUrl
=
commonBundle
.
getString
(
"admin.url"
);
public
static
String
trackingUrl
=
commonBundle
.
getString
(
"trackingio.url"
);
public
static
String
iscache
=
commonBundle
.
getString
(
"iscache"
);
public
static
String
receiverHost
=
commonBundle
.
getString
(
"receiver.host"
);
public
static
String
receiverPort
=
commonBundle
.
getString
(
"receiver.port"
);
...
...
src/main/resources/common.properties
View file @
340c8d0b
...
...
@@ -9,3 +9,4 @@ report.url=${report.url}
awsneed
=
${awsneed}
iscache
=
${iscache}
admin.url
=
${admin.url}
trackingio.url
=
${trackingio.url}
\ No newline at end of file
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