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> {
//StoryLogin storyLogin = JSONObject.parseObject(s,StoryLogin.class);
//匹配OpenId
//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);
//StoryNovelAction对像参数填充
......
......@@ -9,6 +9,8 @@ import com.lwby.marketing.po.VideoUpload;
import com.lwby.marketing.util.HttpUtil;
import com.lwby.marketing.util.ResultConstant;
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.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
......@@ -17,6 +19,7 @@ import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
/**
* @author songxinyu
......@@ -29,6 +32,10 @@ public class DyVideoController {
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
DyVideoUniversalProcess up;
......@@ -37,48 +44,60 @@ public class DyVideoController {
Map map = new HashMap();
String result = "";
VideoUpload videoUpload = up.get(VideoUpload.class,assembleKey(openId));
Integer platformId = videoUpload.getPlatformId();
String uploadKey = String.format("dv_%s_%d_%s", openId, platformId,videoUpload.getMedia());
if (up.exists(uploadKey)) {
map.put("code", ResultConstant.CALL_BACK_UPED_FAIL);
map.put("message",ResultConstant.CALL_BACK_UPED_MESSAGE);
result = JSONObject.toJSONString(map);
return result;
}
if (Objects.nonNull(videoUpload)) {
Integer platformId = videoUpload.getPlatformId();
String uploadKey = String.format("dv_%s_%d_%s", openId, platformId,videoUpload.getMedia());
if (up.exists(uploadKey)) {
map.put("code", ResultConstant.CALL_BACK_UPED_FAIL);
map.put("message",ResultConstant.CALL_BACK_UPED_MESSAGE);
result = JSONObject.toJSONString(map);
DYVIDEO_SYS_LOG.error("DyVideoController uploadBehavoir uped,uploadKey={}",uploadKey);
return result;
}
JrttAttributeRequest.Ad ad = new JrttAttributeRequest.Ad();
ad.setCallback(videoUpload.getClickId());
JrttAttributeRequest.Ad ad = new JrttAttributeRequest.Ad();
ad.setCallback(videoUpload.getClickId());
JrttAttributeRequest.Context context = new JrttAttributeRequest.Context();
context.setAd(ad);
JrttAttributeRequest.Context context = new JrttAttributeRequest.Context();
context.setAd(ad);
JrttAttributeRequest request = JrttAttributeRequest.builder().context(context).event_type("game_addiction").timestamp(
System.currentTimeMillis()).build();
JrttAttributeRequest request = JrttAttributeRequest.builder().context(context).event_type("game_addiction").timestamp(
System.currentTimeMillis()).build();
String userJson = JSONObject.toJSONString(request);
try {
String ret = HttpUtil.post(ATTRIBUTE_URL, userJson);
Integer resultCode = (Integer) JSON.parseObject(ret).get("code");
if (resultCode == 0) {
map.put("code", ResultConstant.CALL_BACK_SUCCESS);
map.put("message",ResultConstant.CALL_BACK_SUCCESS_MESSAGE);
result = JSONObject.toJSONString(map) ;
//给bi发消息
up.notifyResult(openId,videoUpload);
up.set(uploadKey,60 * 60 * 24 * 7,"1");
String userJson = JSONObject.toJSONString(request);
try {
String ret = HttpUtil.post(ATTRIBUTE_URL, userJson);
Integer resultCode = (Integer) JSON.parseObject(ret).get("code");
if (resultCode == 0) {
map.put("code", ResultConstant.CALL_BACK_SUCCESS);
map.put("message",ResultConstant.CALL_BACK_SUCCESS_MESSAGE);
result = JSONObject.toJSONString(map) ;
//给bi发消息
up.notifyResult(openId,videoUpload);
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("message",ResultConstant.CALL_BACK_FAIL_MESSAGE);
result = JSONObject.toJSONString(map) ;
DYVIDEO_ERROR_LOG.error("DyVideoController uploadBehavoir exception,uploadKey={}",uploadKey,e);
return result;
}
return result;
} catch (Exception e) {
map.put("code", ResultConstant.CALL_BACK_FAIL);
map.put("message",ResultConstant.CALL_BACK_FAIL_MESSAGE);
} else {
map.put("code", ResultConstant.CALL_BACK_NOCACHE_FAIL);
map.put("message",ResultConstant.CALL_BACK_NOCACHE_MESSAGE);
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) {
......
......@@ -48,7 +48,7 @@ public class DyVideoJRTTNotify extends DYNotify {
try {
String result = HttpUtil.post(ATTRIBUTE_URL, userJson);
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;
} catch (Exception e) {
return false;
......
......@@ -5,10 +5,12 @@ public class ResultConstant {
public final static Integer CALL_BACK_SUCCESS = 0;
public final static Integer CALL_BACK_FAIL = 1;
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_FAIL_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