|
@@ -6,10 +6,8 @@ import cn.com.ctop.common.module.service.ICtopOauthTokenService;
|
|
|
import cn.com.ctop.common.module.utils.Check;
|
|
|
import cn.com.ctop.common.module.utils.LoadFileUtil;
|
|
|
import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouCrowdPack;
|
|
|
-import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouCrowdPackageRel;
|
|
|
import cn.com.ctop.kuaishou.modules.ai.mapper.KuaishouCrowdPackMapper;
|
|
|
import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouCrowdPackService;
|
|
|
-import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouCrowdPackageRelService;
|
|
|
import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
|
|
|
import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouPopulationService;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
@@ -46,9 +44,6 @@ public class KuaishouCrowdPackServiceImpl extends ServiceImpl<KuaishouCrowdPackM
|
|
|
private KuaishouCrowdPackMapper crowdPackMapper;
|
|
|
|
|
|
@Autowired
|
|
|
- private IKuaishouCrowdPackageRelService relService;
|
|
|
-
|
|
|
- @Autowired
|
|
|
private ICtopOauthTokenService tokenService;
|
|
|
|
|
|
@Autowired
|
|
@@ -69,6 +64,10 @@ public class KuaishouCrowdPackServiceImpl extends ServiceImpl<KuaishouCrowdPackM
|
|
|
Long total = crowdPackMapper.getTotal(kuaishouCrowdPack.getStatus(), kuaishouCrowdPack.getAccountName(), kuaishouCrowdPack.getOrientationName());
|
|
|
PageHelper.startPage(pageNo, pageSize, false);
|
|
|
List<JSONObject> list = crowdPackMapper.queryPageList(kuaishouCrowdPack.getStatus(), kuaishouCrowdPack.getAccountName(), kuaishouCrowdPack.getOrientationName());
|
|
|
+ for (JSONObject object : list) {
|
|
|
+ Long count = crowdPackMapper.queryProjectCount(object.getString("signature"));
|
|
|
+ object.put("projectCount", Check.isNull(count) ? 0 : count);
|
|
|
+ }
|
|
|
PageInfo pageInfo = new PageInfo(list);
|
|
|
pageInfo.setTotal(total);
|
|
|
return Result.ok(pageInfo);
|
|
@@ -79,6 +78,10 @@ public class KuaishouCrowdPackServiceImpl extends ServiceImpl<KuaishouCrowdPackM
|
|
|
StringBuffer path = new StringBuffer();
|
|
|
path.append(downloadPath).append(DateUtils.getNowDate(DateUtils.WEB_FORMAT)).append("/").append(UUID.randomUUID().toString()).append("/");
|
|
|
log.info("-------下载到服务器地址:{}", path.toString());
|
|
|
+ if (!url.contains("http")) {
|
|
|
+ url = "https:".concat(url);
|
|
|
+ }
|
|
|
+ System.out.println(url);
|
|
|
String newFileUrl = LoadFileUtil.downLoadFromUrl(url, path.toString());
|
|
|
String md5 = null;
|
|
|
try {
|
|
@@ -86,6 +89,15 @@ public class KuaishouCrowdPackServiceImpl extends ServiceImpl<KuaishouCrowdPackM
|
|
|
} catch (IOException e) {
|
|
|
log.error("获取MD5签名失败", e);
|
|
|
}
|
|
|
+ QueryWrapper<KuaishouCrowdPack> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper.eq("account_id", accountId);
|
|
|
+ queryWrapper.eq("signature", md5);
|
|
|
+ queryWrapper.eq("data_status", 1);
|
|
|
+ queryWrapper.last("limit 1");
|
|
|
+ KuaishouCrowdPack one = crowdPackMapper.selectOne(queryWrapper);
|
|
|
+ if (!Check.isNull(one)) {
|
|
|
+ return Result.error("本账户已上传过该人群包,人群包名为:" + one.getOrientationName());
|
|
|
+ }
|
|
|
CtopOauthToken token = tokenService.getTokenByAccountId(accountId);
|
|
|
JSONObject jsonObject = iKuaishouPopulationService.updatePopulation(token, type, orientationName, newFileUrl);
|
|
|
LoadFileUtil.delFile(newFileUrl);
|
|
@@ -96,6 +108,7 @@ public class KuaishouCrowdPackServiceImpl extends ServiceImpl<KuaishouCrowdPackM
|
|
|
crowdPack.setUrl(url);
|
|
|
crowdPack.setMessage(jsonObject.getString("message"));
|
|
|
crowdPack.setStatDate(DateUtils.formatDate(new Date()));
|
|
|
+ crowdPack.setDataStatus(1);
|
|
|
this.save(crowdPack);
|
|
|
} else {
|
|
|
KuaishouCrowdPack crowdPack = new KuaishouCrowdPack();
|
|
@@ -103,6 +116,7 @@ public class KuaishouCrowdPackServiceImpl extends ServiceImpl<KuaishouCrowdPackM
|
|
|
crowdPack.setUrl(url);
|
|
|
crowdPack.setMessage(jsonObject.getString("message"));
|
|
|
crowdPack.setStatDate(DateUtils.formatDate(new Date()));
|
|
|
+ crowdPack.setDataStatus(1);
|
|
|
this.save(crowdPack);
|
|
|
return Result.error(jsonObject.getString("message"));
|
|
|
}
|
|
@@ -113,7 +127,6 @@ public class KuaishouCrowdPackServiceImpl extends ServiceImpl<KuaishouCrowdPackM
|
|
|
@Override
|
|
|
public Result<Object> accountPush(JSONObject request) {
|
|
|
JSONArray accountIds = request.getJSONArray("accountIds");
|
|
|
- List<Long> longs = accountIds.toJavaList(Long.class);
|
|
|
Long orientationId = request.getLong("orientationId");
|
|
|
Long accountId = request.getLong("accountId");
|
|
|
CtopOauthToken token = tokenService.getTokenByAccountId(accountId);
|
|
@@ -123,32 +136,29 @@ public class KuaishouCrowdPackServiceImpl extends ServiceImpl<KuaishouCrowdPackM
|
|
|
KuaishouCrowdPack kuaishouCrowdPack = crowdPackMapper.selectOne(wrapper);
|
|
|
JSONObject jsonObject = iKuaishouPopulationService.pushAccountsPopulation(token, orientationId, accountIds);
|
|
|
if (jsonObject.getInteger("code") == 0) {
|
|
|
+ List<KuaishouCrowdPack> list = new ArrayList<>();
|
|
|
JSONObject data = jsonObject.getJSONObject("data");
|
|
|
if (!Check.isNull(data)) {
|
|
|
JSONArray success = data.getJSONArray("success");
|
|
|
- List<KuaishouCrowdPackageRel> relList = new ArrayList<>();
|
|
|
for (Object account : success) {
|
|
|
- KuaishouCrowdPackageRel rel = new KuaishouCrowdPackageRel();
|
|
|
- rel.setAccountId((Long) account);
|
|
|
- rel.setTgtAccountId(accountId);
|
|
|
- rel.setMessage("OK");
|
|
|
- rel.setStatDate(DateUtils.formatDate(new Date()));
|
|
|
- rel.setOrientationId(orientationId);
|
|
|
- rel.setOrientationName(kuaishouCrowdPack.getOrientationName());
|
|
|
- relList.add(rel);
|
|
|
+ kuaishouCrowdPack.setAccountId((Long) account);
|
|
|
+ kuaishouCrowdPack.setMessage("PUSH OK");
|
|
|
+ kuaishouCrowdPack.setStatDate(DateUtils.formatDate(new Date()));
|
|
|
+ list.add(kuaishouCrowdPack);
|
|
|
}
|
|
|
JSONArray fail = data.getJSONArray("fail");
|
|
|
for (Object account : fail) {
|
|
|
- KuaishouCrowdPackageRel rel = new KuaishouCrowdPackageRel();
|
|
|
- rel.setAccountId((Long) account);
|
|
|
- rel.setTgtAccountId(accountId);
|
|
|
- rel.setMessage(jsonObject.getString("message"));
|
|
|
- rel.setStatDate(DateUtils.formatDate(new Date()));
|
|
|
- rel.setOrientationId(orientationId);
|
|
|
- rel.setOrientationName(kuaishouCrowdPack.getOrientationName());
|
|
|
- relList.add(rel);
|
|
|
+ kuaishouCrowdPack.setAccountId((Long) account);
|
|
|
+ kuaishouCrowdPack.setMessage("推送失败");
|
|
|
+ kuaishouCrowdPack.setStatDate(DateUtils.formatDate(new Date()));
|
|
|
+ kuaishouCrowdPack.setStatus(null);
|
|
|
+ kuaishouCrowdPack.setType(null);
|
|
|
+ kuaishouCrowdPack.setCoverNum(null);
|
|
|
+ kuaishouCrowdPack.setRecordSize(null);
|
|
|
+ kuaishouCrowdPack.setMatchSize(null);
|
|
|
+ list.add(kuaishouCrowdPack);
|
|
|
}
|
|
|
- relService.saveBatch(relList);
|
|
|
+ crowdPackMapper.replaceBatch(list);
|
|
|
}
|
|
|
}
|
|
|
return Result.ok("success");
|
|
@@ -175,7 +185,38 @@ public class KuaishouCrowdPackServiceImpl extends ServiceImpl<KuaishouCrowdPackM
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public Result<Object> queryRel(String type, Long orientationId, Long accountId, Integer pageNo, Integer pageSize) {
|
|
|
- return null;
|
|
|
+ public Result<Object> queryRel(String type, String signature, Integer pageNo, Integer pageSize) {
|
|
|
+ PageHelper.startPage(pageNo, pageSize);
|
|
|
+ List<JSONObject> list = null;
|
|
|
+ if ("1".equals(type)) {
|
|
|
+ list = crowdPackMapper.queryRelProject(signature);
|
|
|
+ } else {
|
|
|
+ list = crowdPackMapper.queryRelAccounts(signature);
|
|
|
+ }
|
|
|
+ PageInfo pageInfo = new PageInfo(list);
|
|
|
+ return Result.ok(pageInfo);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Result<Object> queryFailReason(Long orientationId, Integer pageNo, Integer pageSize) {
|
|
|
+ PageHelper.startPage(pageNo, pageSize);
|
|
|
+ List<JSONObject> list = crowdPackMapper.queryFailReason(orientationId);
|
|
|
+ PageInfo pageInfo = new PageInfo(list);
|
|
|
+ return Result.ok(pageInfo);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Result<Object> updateDataStatus(KuaishouCrowdPack kuaishouCrowdPack) {
|
|
|
+ CtopOauthToken token = tokenService.getTokenByAccountId(kuaishouCrowdPack.getAccountId());
|
|
|
+ JSONObject object = iKuaishouPopulationService.deletePopulation(kuaishouCrowdPack.getAccountId(), kuaishouCrowdPack.getOrientationId(), token.getAccessToken());
|
|
|
+ if (!Check.isNull(object)) {
|
|
|
+ kuaishouCrowdPack.setMessage(object.getString("data"));
|
|
|
+ if (object.getInteger("code") == 0) {
|
|
|
+ if (this.updateById(kuaishouCrowdPack)) {
|
|
|
+ return Result.ok("删除成功");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return Result.ok("删除失败");
|
|
|
}
|
|
|
}
|