Commit 0f00935d authored by 宋新宇's avatar 宋新宇

Merge branch '8-抖小更改' into 'release_20240411'

抖小更改及监测

See merge request !46
parents c78b83d6 ca88cc4c
...@@ -38,7 +38,7 @@ public class ParameterSetupDyVideoFlow extends NodeFlow<StoryNovelAction> { ...@@ -38,7 +38,7 @@ public class ParameterSetupDyVideoFlow extends NodeFlow<StoryNovelAction> {
//StoryLogin storyLogin = JSONObject.parseObject(s,StoryLogin.class); //StoryLogin storyLogin = JSONObject.parseObject(s,StoryLogin.class);
//匹配OpenId //匹配OpenId
//VideoUpload videoUpload = JSONObject.parseObject(s,VideoUpload.class); //VideoUpload videoUpload = JSONObject.parseObject(s,VideoUpload.class);
VideoUpload videoUpload = up.getOld(VideoUpload.class,assembleKey(openId)); VideoUpload videoUpload = up.get(VideoUpload.class,assembleKey(openId));
action.setVideoUpload(videoUpload); action.setVideoUpload(videoUpload);
//StoryNovelAction对像参数填充 //StoryNovelAction对像参数填充
......
...@@ -9,6 +9,8 @@ import com.lwby.marketing.po.VideoUpload; ...@@ -9,6 +9,8 @@ import com.lwby.marketing.po.VideoUpload;
import com.lwby.marketing.util.HttpUtil; import com.lwby.marketing.util.HttpUtil;
import com.lwby.marketing.util.ResultConstant; import com.lwby.marketing.util.ResultConstant;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
...@@ -17,6 +19,7 @@ import org.springframework.web.bind.annotation.RestController; ...@@ -17,6 +19,7 @@ import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Objects;
/** /**
* @author songxinyu * @author songxinyu
...@@ -29,6 +32,10 @@ public class DyVideoController { ...@@ -29,6 +32,10 @@ public class DyVideoController {
public static final String ATTRIBUTE_URL = "https://analytics.oceanengine.com/api/v2/conversion"; public static final String ATTRIBUTE_URL = "https://analytics.oceanengine.com/api/v2/conversion";
private static final Logger DYVIDEO_SYS_LOG = LoggerFactory.getLogger("dyvideo.sys");
private static final Logger DYVIDEO_ERROR_LOG = LoggerFactory.getLogger("dyvideo.error");
@Resource @Resource
DyVideoUniversalProcess up; DyVideoUniversalProcess up;
...@@ -37,48 +44,60 @@ public class DyVideoController { ...@@ -37,48 +44,60 @@ public class DyVideoController {
Map map = new HashMap(); Map map = new HashMap();
String result = ""; String result = "";
VideoUpload videoUpload = up.get(VideoUpload.class,assembleKey(openId)); VideoUpload videoUpload = up.get(VideoUpload.class,assembleKey(openId));
Integer platformId = videoUpload.getPlatformId(); if (Objects.nonNull(videoUpload)) {
String uploadKey = String.format("dv_%s_%d_%s", openId, platformId,videoUpload.getMedia()); Integer platformId = videoUpload.getPlatformId();
if (up.exists(uploadKey)) { String uploadKey = String.format("dv_%s_%d_%s", openId, platformId,videoUpload.getMedia());
map.put("code", ResultConstant.CALL_BACK_UPED_FAIL); if (up.exists(uploadKey)) {
map.put("message",ResultConstant.CALL_BACK_UPED_MESSAGE); map.put("code", ResultConstant.CALL_BACK_UPED_FAIL);
result = JSONObject.toJSONString(map); map.put("message",ResultConstant.CALL_BACK_UPED_MESSAGE);
return result; result = JSONObject.toJSONString(map);
} DYVIDEO_SYS_LOG.error("DyVideoController uploadBehavoir uped,uploadKey={}",uploadKey);
return result;
}
JrttAttributeRequest.Ad ad = new JrttAttributeRequest.Ad(); JrttAttributeRequest.Ad ad = new JrttAttributeRequest.Ad();
ad.setCallback(videoUpload.getClickId()); ad.setCallback(videoUpload.getClickId());
JrttAttributeRequest.Context context = new JrttAttributeRequest.Context(); JrttAttributeRequest.Context context = new JrttAttributeRequest.Context();
context.setAd(ad); context.setAd(ad);
JrttAttributeRequest request = JrttAttributeRequest.builder().context(context).event_type("game_addiction").timestamp( JrttAttributeRequest request = JrttAttributeRequest.builder().context(context).event_type("game_addiction").timestamp(
System.currentTimeMillis()).build(); System.currentTimeMillis()).build();
String userJson = JSONObject.toJSONString(request); String userJson = JSONObject.toJSONString(request);
try { try {
String ret = HttpUtil.post(ATTRIBUTE_URL, userJson); String ret = HttpUtil.post(ATTRIBUTE_URL, userJson);
Integer resultCode = (Integer) JSON.parseObject(ret).get("code"); Integer resultCode = (Integer) JSON.parseObject(ret).get("code");
if (resultCode == 0) { if (resultCode == 0) {
map.put("code", ResultConstant.CALL_BACK_SUCCESS); map.put("code", ResultConstant.CALL_BACK_SUCCESS);
map.put("message",ResultConstant.CALL_BACK_SUCCESS_MESSAGE); map.put("message",ResultConstant.CALL_BACK_SUCCESS_MESSAGE);
result = JSONObject.toJSONString(map) ; result = JSONObject.toJSONString(map) ;
//给bi发消息 //给bi发消息
up.notifyResult(openId,videoUpload); up.notifyResult(openId,videoUpload);
up.set(uploadKey,60 * 60 * 24 * 7,"1"); up.set(uploadKey,60 * 60 * 24 * 7,"1");
} else { } else {
map.put("code", ResultConstant.CALL_BACK_FAIL);
map.put("message",ResultConstant.CALL_BACK_FAIL_MESSAGE);
result = JSONObject.toJSONString(map) ;
DYVIDEO_SYS_LOG.error("DyVideoController uploadBehavoir send back fail,uploadKey={},code={}",uploadKey,resultCode);
}
} catch (Exception e) {
map.put("code", ResultConstant.CALL_BACK_FAIL); map.put("code", ResultConstant.CALL_BACK_FAIL);
map.put("message",ResultConstant.CALL_BACK_FAIL_MESSAGE); map.put("message",ResultConstant.CALL_BACK_FAIL_MESSAGE);
result = JSONObject.toJSONString(map) ; result = JSONObject.toJSONString(map) ;
DYVIDEO_ERROR_LOG.error("DyVideoController uploadBehavoir exception,uploadKey={}",uploadKey,e);
return result;
} }
return result; } else {
} catch (Exception e) { map.put("code", ResultConstant.CALL_BACK_NOCACHE_FAIL);
map.put("code", ResultConstant.CALL_BACK_FAIL); map.put("message",ResultConstant.CALL_BACK_NOCACHE_MESSAGE);
map.put("message",ResultConstant.CALL_BACK_FAIL_MESSAGE);
result = JSONObject.toJSONString(map) ; result = JSONObject.toJSONString(map) ;
return result; DYVIDEO_SYS_LOG.error("DyVideoController uploadBehavoir no cache,videoUpload={}",JSONObject.toJSONString(videoUpload));
} }
return result;
} }
public String assembleKey(String openId) { public String assembleKey(String openId) {
......
...@@ -48,7 +48,7 @@ public class DyVideoJRTTNotify extends DYNotify { ...@@ -48,7 +48,7 @@ public class DyVideoJRTTNotify extends DYNotify {
try { try {
String result = HttpUtil.post(ATTRIBUTE_URL, userJson); String result = HttpUtil.post(ATTRIBUTE_URL, userJson);
Integer resultCode = (Integer) JSON.parseObject(result).get("code"); Integer resultCode = (Integer) JSON.parseObject(result).get("code");
DYVIDEO_SYS_LOG.info("DyVideoJRTTNotify.video.{}.upload,userId={},channel={},platform={}",eventType,na.getUserId(),na.getChannelId(),na.getPlatformId()); DYVIDEO_SYS_LOG.info("DyVideoJRTTNotify.video.{}.upload,userId={},channel={},platform={},code={}",eventType,na.getUserId(),na.getChannelId(),na.getPlatformId(),resultCode);
return resultCode == 0; return resultCode == 0;
} catch (Exception e) { } catch (Exception e) {
return false; return false;
......
...@@ -5,10 +5,12 @@ public class ResultConstant { ...@@ -5,10 +5,12 @@ public class ResultConstant {
public final static Integer CALL_BACK_SUCCESS = 0; public final static Integer CALL_BACK_SUCCESS = 0;
public final static Integer CALL_BACK_FAIL = 1; public final static Integer CALL_BACK_FAIL = 1;
public final static Integer CALL_BACK_UPED_FAIL = 2; public final static Integer CALL_BACK_UPED_FAIL = 2;
public final static Integer CALL_BACK_NOCACHE_FAIL = 3;
public final static String CALL_BACK_SUCCESS_MESSAGE = "上报成功"; public final static String CALL_BACK_SUCCESS_MESSAGE = "上报成功";
public final static String CALL_BACK_FAIL_MESSAGE = "上报失败"; public final static String CALL_BACK_FAIL_MESSAGE = "上报失败";
public final static String CALL_BACK_UPED_MESSAGE = "已上报一次"; public final static String CALL_BACK_UPED_MESSAGE = "已上报一次";
public final static String CALL_BACK_NOCACHE_MESSAGE = "无点击缓存,用户超过7天";
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment