|
@@ -14,6 +14,7 @@ import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouVideoRelateCreativesS
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
+import com.github.pagehelper.PageInfo;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
@@ -23,25 +24,28 @@ import java.util.Map;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 快手账户策略设置信息表
|
|
* 快手账户策略设置信息表
|
|
|
|
+ *
|
|
* @author jeecg-boot
|
|
* @author jeecg-boot
|
|
- * @date 2021-01-25
|
|
|
|
* @version V1.0
|
|
* @version V1.0
|
|
|
|
+ * @date 2021-01-25
|
|
*/
|
|
*/
|
|
@Service
|
|
@Service
|
|
public class AiKuaishouAdvertiserStrategyServiceImpl extends ServiceImpl<AiKuaishouAdvertiserStrategyMapper, AiKuaishouAdvertiserStrategy> implements IAiKuaishouAdvertiserStrategyService {
|
|
public class AiKuaishouAdvertiserStrategyServiceImpl extends ServiceImpl<AiKuaishouAdvertiserStrategyMapper, AiKuaishouAdvertiserStrategy> implements IAiKuaishouAdvertiserStrategyService {
|
|
- public static final String TEST_CREATIVE_URL= "http://139.186.27.96:31012/ai_historical_missing_material";
|
|
|
|
- public static final String TEST_PROGRAM_CREATIVE_URL= "http://139.186.27.96:31012/ai_programme_new_material";
|
|
|
|
|
|
+ public static final String TEST_CREATIVE_URL = "http://139.186.27.96:31012/ai_historical_missing_material";
|
|
|
|
+ public static final String TEST_PROGRAM_CREATIVE_URL = "http://139.186.27.96:31012/ai_programme_new_material";
|
|
@Autowired
|
|
@Autowired
|
|
private IUserAllocationService userAllocationService;
|
|
private IUserAllocationService userAllocationService;
|
|
@Autowired
|
|
@Autowired
|
|
private IKuaiShouVideoGetService videoGetService;
|
|
private IKuaiShouVideoGetService videoGetService;
|
|
@Autowired
|
|
@Autowired
|
|
private IKuaishouVideoRelateCreativesService relateCreativesService;
|
|
private IKuaishouVideoRelateCreativesService relateCreativesService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private AiKuaishouAdvertiserStrategyMapper kuaishouAdvertiserStrategyMapper;
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public AiKuaishouAdvertiserStrategy getByAccountId(Long accountId) {
|
|
public AiKuaishouAdvertiserStrategy getByAccountId(Long accountId) {
|
|
- QueryWrapper<AiKuaishouAdvertiserStrategy>queryWrapper =new QueryWrapper<>();
|
|
|
|
- queryWrapper.eq("account_id",accountId);
|
|
|
|
|
|
+ QueryWrapper<AiKuaishouAdvertiserStrategy> queryWrapper = new QueryWrapper<>();
|
|
|
|
+ queryWrapper.eq("account_id", accountId);
|
|
queryWrapper.orderByDesc("id");
|
|
queryWrapper.orderByDesc("id");
|
|
queryWrapper.last("limit 1");
|
|
queryWrapper.last("limit 1");
|
|
return this.getOne(queryWrapper);
|
|
return this.getOne(queryWrapper);
|
|
@@ -49,79 +53,85 @@ public class AiKuaishouAdvertiserStrategyServiceImpl extends ServiceImpl<AiKuais
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public Map<String, Object> testCreate(Long accountId) {
|
|
public Map<String, Object> testCreate(Long accountId) {
|
|
- Map<String,Object>result = new HashMap<>();
|
|
|
|
- if(null == accountId||accountId == 0){
|
|
|
|
|
|
+ Map<String, Object> result = new HashMap<>();
|
|
|
|
+ if (null == accountId || accountId == 0) {
|
|
ResultMapUtils.setResultMap(result, StatusCode.COMMON_PARAM_ERROR);
|
|
ResultMapUtils.setResultMap(result, StatusCode.COMMON_PARAM_ERROR);
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
AiKuaishouAdvertiserStrategy aiKuaishouAdvertiserStrategy = this.getByAccountId(accountId);
|
|
AiKuaishouAdvertiserStrategy aiKuaishouAdvertiserStrategy = this.getByAccountId(accountId);
|
|
- if(null == aiKuaishouAdvertiserStrategy||null == aiKuaishouAdvertiserStrategy.getStatus()||aiKuaishouAdvertiserStrategy.getStatus()!=1){
|
|
|
|
|
|
+ if (null == aiKuaishouAdvertiserStrategy || null == aiKuaishouAdvertiserStrategy.getStatus() || aiKuaishouAdvertiserStrategy.getStatus() != 1) {
|
|
ResultMapUtils.setResultMap(result, StatusCode.COMMON_PARAM_ERROR);
|
|
ResultMapUtils.setResultMap(result, StatusCode.COMMON_PARAM_ERROR);
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
UserAllocation allocation = userAllocationService.getByAccountId(accountId);
|
|
UserAllocation allocation = userAllocationService.getByAccountId(accountId);
|
|
- if(null == allocation){
|
|
|
|
|
|
+ if (null == allocation) {
|
|
ResultMapUtils.setResultMap(result, StatusCode.COMMON_PARAM_ERROR);
|
|
ResultMapUtils.setResultMap(result, StatusCode.COMMON_PARAM_ERROR);
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
JSONObject params = new JSONObject();
|
|
JSONObject params = new JSONObject();
|
|
- params.put("account_id",accountId);
|
|
|
|
- params.put("test_video_cnt",1);
|
|
|
|
|
|
+ params.put("account_id", accountId);
|
|
|
|
+ params.put("test_video_cnt", 1);
|
|
String request = null;
|
|
String request = null;
|
|
//程序化
|
|
//程序化
|
|
- if(aiKuaishouAdvertiserStrategy.getOpenProgramCreate() == 1){
|
|
|
|
- request = HttpUtils.httpPostRequest(TEST_PROGRAM_CREATIVE_URL,params,new HashMap<>());
|
|
|
|
- }else{
|
|
|
|
|
|
+ if (aiKuaishouAdvertiserStrategy.getOpenProgramCreate() == 1) {
|
|
|
|
+ request = HttpUtils.httpPostRequest(TEST_PROGRAM_CREATIVE_URL, params, new HashMap<>());
|
|
|
|
+ } else {
|
|
request = HttpUtils.httpPostRequest(TEST_CREATIVE_URL, params, new HashMap<>());
|
|
request = HttpUtils.httpPostRequest(TEST_CREATIVE_URL, params, new HashMap<>());
|
|
}
|
|
}
|
|
JSONObject requestObject = JSONObject.parseObject(request);
|
|
JSONObject requestObject = JSONObject.parseObject(request);
|
|
String message = requestObject.getString("message");
|
|
String message = requestObject.getString("message");
|
|
Integer code = requestObject.getInteger("code");
|
|
Integer code = requestObject.getInteger("code");
|
|
- result.put("code",code);
|
|
|
|
- result.put("message",message);
|
|
|
|
|
|
+ result.put("code", code);
|
|
|
|
+ result.put("message", message);
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public Map<String, Object> aiHistoricalMissingMaterial(Long accountId) {
|
|
public Map<String, Object> aiHistoricalMissingMaterial(Long accountId) {
|
|
- Map<String,Object>result = new HashMap<>();
|
|
|
|
- if(null == accountId||accountId == 0){
|
|
|
|
- ResultMapUtils.setResultMap(result,StatusCode.COMMON_PARAM_ERROR);
|
|
|
|
|
|
+ Map<String, Object> result = new HashMap<>();
|
|
|
|
+ if (null == accountId || accountId == 0) {
|
|
|
|
+ ResultMapUtils.setResultMap(result, StatusCode.COMMON_PARAM_ERROR);
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
AiKuaishouAdvertiserStrategy strategy = this.getByAccountId(accountId);
|
|
AiKuaishouAdvertiserStrategy strategy = this.getByAccountId(accountId);
|
|
- if(null == strategy||strategy.getStatus()!=1){
|
|
|
|
- ResultMapUtils.setResultMap(result,StatusCode.KUAISHOU_AI_STRATEGY_HAS_NOT_EXIST);
|
|
|
|
|
|
+ if (null == strategy || strategy.getStatus() != 1) {
|
|
|
|
+ ResultMapUtils.setResultMap(result, StatusCode.KUAISHOU_AI_STRATEGY_HAS_NOT_EXIST);
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
this.historicalMissingMaterialCreateCreative(strategy);
|
|
this.historicalMissingMaterialCreateCreative(strategy);
|
|
- ResultMapUtils.setResultMap(result,StatusCode.COMMON_SUCCESS);
|
|
|
|
|
|
+ ResultMapUtils.setResultMap(result, StatusCode.COMMON_SUCCESS);
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public List<AiKuaishouAdvertiserStrategy> getAllEffectStrategy() {
|
|
public List<AiKuaishouAdvertiserStrategy> getAllEffectStrategy() {
|
|
- QueryWrapper<AiKuaishouAdvertiserStrategy>queryWrapper= new QueryWrapper<>();
|
|
|
|
- queryWrapper.eq("status",1);
|
|
|
|
|
|
+ QueryWrapper<AiKuaishouAdvertiserStrategy> queryWrapper = new QueryWrapper<>();
|
|
|
|
+ queryWrapper.eq("status", 1);
|
|
queryWrapper.orderByDesc("id");
|
|
queryWrapper.orderByDesc("id");
|
|
return this.list(queryWrapper);
|
|
return this.list(queryWrapper);
|
|
}
|
|
}
|
|
|
|
|
|
- private Map<String,Object> historicalMissingMaterialCreateCreative(AiKuaishouAdvertiserStrategy strategy) {
|
|
|
|
- Map<String,Object>result =new HashMap<>();
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public PageInfo<AiKuaishouAdvertiserStrategy> queryList(AiKuaishouAdvertiserStrategy aiKuaishouAdvertiserStrategy) {
|
|
|
|
+ return new PageInfo<>(kuaishouAdvertiserStrategyMapper.queryList(aiKuaishouAdvertiserStrategy));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private Map<String, Object> historicalMissingMaterialCreateCreative(AiKuaishouAdvertiserStrategy strategy) {
|
|
|
|
+ Map<String, Object> result = new HashMap<>();
|
|
//判定是否单一应用
|
|
//判定是否单一应用
|
|
- if(strategy.getSingleAppid()==1){
|
|
|
|
|
|
+ if (strategy.getSingleAppid() == 1) {
|
|
//TODO 参数拼接
|
|
//TODO 参数拼接
|
|
- Map<String,Object>params =new HashMap<>();
|
|
|
|
|
|
+ Map<String, Object> params = new HashMap<>();
|
|
//1:直接查询历史素材
|
|
//1:直接查询历史素材
|
|
List<JSONObject> materialList = relateCreativesService.getVideoZeroListByMap(params);
|
|
List<JSONObject> materialList = relateCreativesService.getVideoZeroListByMap(params);
|
|
if (Check.isNull(materialList)) {
|
|
if (Check.isNull(materialList)) {
|
|
- ResultMapUtils.setResultMap(result,StatusCode.KUAISHOU_AI_STRATEGY_HAS_NO_HISTORY_MATERIAL);
|
|
|
|
|
|
+ ResultMapUtils.setResultMap(result, StatusCode.KUAISHOU_AI_STRATEGY_HAS_NO_HISTORY_MATERIAL);
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
materialList = videoGetService.getVideoInfoAndImageList(materialList);
|
|
materialList = videoGetService.getVideoInfoAndImageList(materialList);
|
|
//补充遗漏素材
|
|
//补充遗漏素材
|
|
- JSONObject hisMatParams = formatHisMatParams(strategy,materialList,"补充遗漏素材");
|
|
|
|
- }else{
|
|
|
|
|
|
+ JSONObject hisMatParams = formatHisMatParams(strategy, materialList, "补充遗漏素材");
|
|
|
|
+ } else {
|
|
//
|
|
//
|
|
|
|
|
|
}
|
|
}
|
|
@@ -130,10 +140,10 @@ public class AiKuaishouAdvertiserStrategyServiceImpl extends ServiceImpl<AiKuais
|
|
|
|
|
|
private JSONObject formatHisMatParams(AiKuaishouAdvertiserStrategy strategy, List<JSONObject> materialList, String fixString) {
|
|
private JSONObject formatHisMatParams(AiKuaishouAdvertiserStrategy strategy, List<JSONObject> materialList, String fixString) {
|
|
JSONObject result = new JSONObject();
|
|
JSONObject result = new JSONObject();
|
|
- result.put("video",materialList);
|
|
|
|
- result.put("operation_type",1);
|
|
|
|
- result.put("account_id",strategy.getAccountId());
|
|
|
|
- result.put("ai_strategy_remark",fixString);
|
|
|
|
|
|
+ result.put("video", materialList);
|
|
|
|
+ result.put("operation_type", 1);
|
|
|
|
+ result.put("account_id", strategy.getAccountId());
|
|
|
|
+ result.put("ai_strategy_remark", fixString);
|
|
|
|
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|