|
@@ -2,36 +2,37 @@ package cn.com.ctop.kuaishou.modules.material.service.impl;
|
|
|
|
|
|
import cn.com.ctop.common.module.entity.MaterialInfo;
|
|
import cn.com.ctop.common.module.entity.MaterialInfo;
|
|
import cn.com.ctop.common.module.entity.SysUser;
|
|
import cn.com.ctop.common.module.entity.SysUser;
|
|
-import cn.com.ctop.common.module.mapper.SysUserMapper;
|
|
|
|
import cn.com.ctop.common.module.service.IMaterialAscriptionService;
|
|
import cn.com.ctop.common.module.service.IMaterialAscriptionService;
|
|
import cn.com.ctop.common.module.service.IMaterialInfoService;
|
|
import cn.com.ctop.common.module.service.IMaterialInfoService;
|
|
import cn.com.ctop.common.module.service.ISysUserService;
|
|
import cn.com.ctop.common.module.service.ISysUserService;
|
|
-import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouVideoGet;
|
|
|
|
|
|
+import cn.com.ctop.common.module.service.IUserCompanyService;
|
|
|
|
+import cn.com.ctop.common.module.utils.Check;
|
|
import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouVideoGetService;
|
|
import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouVideoGetService;
|
|
import cn.com.ctop.kuaishou.modules.material.entity.EtlKuaishouVideoInfo;
|
|
import cn.com.ctop.kuaishou.modules.material.entity.EtlKuaishouVideoInfo;
|
|
import cn.com.ctop.kuaishou.modules.material.mapper.EtlKuaishouVideoInfoMapper;
|
|
import cn.com.ctop.kuaishou.modules.material.mapper.EtlKuaishouVideoInfoMapper;
|
|
import cn.com.ctop.kuaishou.modules.material.service.IEtlKuaishouVideoInfoService;
|
|
import cn.com.ctop.kuaishou.modules.material.service.IEtlKuaishouVideoInfoService;
|
|
-import cn.com.ctop.kuaishou.modules.report.mapper.KuaishouReportDailyAccountMapper;
|
|
|
|
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.google.common.collect.Lists;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.jeecg.common.util.DateUtils;
|
|
import org.jeecg.common.util.DateUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
|
|
+import java.util.ArrayList;
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
-import java.util.concurrent.CountDownLatch;
|
|
|
|
import java.util.concurrent.ExecutorService;
|
|
import java.util.concurrent.ExecutorService;
|
|
import java.util.concurrent.Executors;
|
|
import java.util.concurrent.Executors;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 快手视频报表信息
|
|
* 快手视频报表信息
|
|
|
|
+ *
|
|
* @author jeecg-boot
|
|
* @author jeecg-boot
|
|
- * @date 2021-02-20
|
|
|
|
* @version V1.0
|
|
* @version V1.0
|
|
|
|
+ * @date 2021-02-20
|
|
*/
|
|
*/
|
|
@Service
|
|
@Service
|
|
@Slf4j
|
|
@Slf4j
|
|
@@ -46,100 +47,135 @@ public class EtlKuaishouVideoInfoServiceImpl extends ServiceImpl<EtlKuaishouVide
|
|
private ISysUserService sysUserService;
|
|
private ISysUserService sysUserService;
|
|
@Autowired
|
|
@Autowired
|
|
private IMaterialInfoService materialInfoService;
|
|
private IMaterialInfoService materialInfoService;
|
|
- ExecutorService executorService = Executors.newFixedThreadPool(200);
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private IUserCompanyService companyService;
|
|
|
|
+ ExecutorService executorService = Executors.newFixedThreadPool(5);
|
|
|
|
+ ExecutorService videoExecutorService = Executors.newFixedThreadPool(10);
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public void etlKuaishouVideoInfo(String date) {
|
|
public void etlKuaishouVideoInfo(String date) {
|
|
- //1:查询当前日期内的所有存在md5码信息的视频数据
|
|
|
|
- List<KuaiShouVideoGet> videoGets = videoGetService.getVideoInfoGroupBySignature(date);
|
|
|
|
- if(null!=videoGets&&!videoGets.isEmpty()){
|
|
|
|
- CountDownLatch countDownLatch = new CountDownLatch(videoGets.size());
|
|
|
|
- videoGets.forEach(videoGet -> {
|
|
|
|
- executorService.submit(()->{
|
|
|
|
|
|
+ Date startDate = DateUtils.getStartDate(date);
|
|
|
|
+ Date endDate = DateUtils.getEndDate(date);
|
|
|
|
+ List<JSONObject> videoList = videoGetService.getVideoListByDate(startDate, endDate);
|
|
|
|
+ if (Check.isNull(videoList)) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ log.info("日期:{},视频数量:{}", date, videoList.size());
|
|
|
|
+ List<List<JSONObject>> partition = Lists.partition(videoList, 500);
|
|
|
|
+ for (int i = 0; i < partition.size(); i++) {
|
|
|
|
+ List<JSONObject> videos = partition.get(i);
|
|
|
|
+ executorService.submit(() -> {
|
|
|
|
+ List<EtlKuaishouVideoInfo> addList = new ArrayList<>();
|
|
|
|
+ for (int j = 0; j < videos.size(); j++) {
|
|
|
|
+ JSONObject videoJson = videos.get(j);
|
|
|
|
+ if (Check.isNull(videoJson)) {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ String signature = videoJson.getString("signature");
|
|
|
|
+ if (Check.isNull(signature)) {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
try {
|
|
try {
|
|
//1:查询素材名称
|
|
//1:查询素材名称
|
|
EtlKuaishouVideoInfo etlKuaishouVideoInfo = new EtlKuaishouVideoInfo();
|
|
EtlKuaishouVideoInfo etlKuaishouVideoInfo = new EtlKuaishouVideoInfo();
|
|
- MaterialInfo materialInfo = materialInfoService.getMaterialInfoByCode(videoGet.getSignature());
|
|
|
|
- if(null != materialInfo){
|
|
|
|
|
|
+ MaterialInfo materialInfo = materialInfoService.getMaterialInfoByCode(signature);
|
|
|
|
+ if (null != materialInfo) {
|
|
etlKuaishouVideoInfo.setVideoName(materialInfo.getMaterialName());
|
|
etlKuaishouVideoInfo.setVideoName(materialInfo.getMaterialName());
|
|
- }else{
|
|
|
|
- etlKuaishouVideoInfo.setVideoName(videoGet.getPhotoName());
|
|
|
|
|
|
+ } else {
|
|
|
|
+ etlKuaishouVideoInfo.setVideoName(videoJson.getString("photoName"));
|
|
}
|
|
}
|
|
- etlKuaishouVideoInfo.setVideoCode(videoGet.getSignature());
|
|
|
|
- etlKuaishouVideoInfo.setUrl(videoGet.getUrl());
|
|
|
|
- etlKuaishouVideoInfo.setCoverUrl(videoGet.getCoverUrl());
|
|
|
|
- etlKuaishouVideoInfo.setChannelType(videoGet.getChannelType().toString());
|
|
|
|
- if(videoGet.getChannelType() == 0){
|
|
|
|
|
|
+ etlKuaishouVideoInfo.setVideoCode(signature);
|
|
|
|
+ etlKuaishouVideoInfo.setUrl(videoJson.getString("url"));
|
|
|
|
+ etlKuaishouVideoInfo.setCoverUrl(videoJson.getString("coverUrl"));
|
|
|
|
+ String channelType = videoJson.getString("channelType");
|
|
|
|
+ etlKuaishouVideoInfo.setChannelType(channelType);
|
|
|
|
+ if (channelType.equals("0")) {
|
|
etlKuaishouVideoInfo.setChannelName("内部");
|
|
etlKuaishouVideoInfo.setChannelName("内部");
|
|
- }else {
|
|
|
|
|
|
+ } else {
|
|
etlKuaishouVideoInfo.setChannelName("素造");
|
|
etlKuaishouVideoInfo.setChannelName("素造");
|
|
}
|
|
}
|
|
//查询相关设计人员信息
|
|
//查询相关设计人员信息
|
|
- JSONObject ascription = ascriptionService.getDetailByCode(videoGet.getSignature());
|
|
|
|
- if(null!=ascription){
|
|
|
|
- String clipId = ascription.getString("clipId");
|
|
|
|
- if(null!=clipId&&!clipId.trim().equals("")){
|
|
|
|
|
|
+ String clipId = null;
|
|
|
|
+ JSONObject ascription = ascriptionService.getDetailByCode(signature);
|
|
|
|
+ if (null != ascription) {
|
|
|
|
+ clipId = ascription.getString("clipId");
|
|
|
|
+ if (null != clipId && !"".equals(clipId.trim())) {
|
|
etlKuaishouVideoInfo.setClipId(clipId);
|
|
etlKuaishouVideoInfo.setClipId(clipId);
|
|
//根据id查询剪辑所属的设计负责人
|
|
//根据id查询剪辑所属的设计负责人
|
|
SysUser user = sysUserService.getById(clipId);
|
|
SysUser user = sysUserService.getById(clipId);
|
|
- if(null!=user){
|
|
|
|
|
|
+ if (null != user) {
|
|
String roleCode = sysUserService.getRoleCodeByUserId(user.getId());
|
|
String roleCode = sysUserService.getRoleCodeByUserId(user.getId());
|
|
- if(null!=roleCode&&roleCode.trim().equals("designTeamLeader")){
|
|
|
|
|
|
+ if (null != roleCode && "designTeamLeader".equals(roleCode.trim())) {
|
|
etlKuaishouVideoInfo.setDesignTeamLeaderId(user.getId());
|
|
etlKuaishouVideoInfo.setDesignTeamLeaderId(user.getId());
|
|
etlKuaishouVideoInfo.setDesignTeamLeaderName(user.getRealname());
|
|
etlKuaishouVideoInfo.setDesignTeamLeaderName(user.getRealname());
|
|
- }else{
|
|
|
|
|
|
+ } else {
|
|
etlKuaishouVideoInfo.setDesignTeamLeaderId(user.getLeaderId());
|
|
etlKuaishouVideoInfo.setDesignTeamLeaderId(user.getLeaderId());
|
|
etlKuaishouVideoInfo.setDesignTeamLeaderName(user.getLeaderName());
|
|
etlKuaishouVideoInfo.setDesignTeamLeaderName(user.getLeaderName());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
String clipName = ascription.getString("clipName");
|
|
String clipName = ascription.getString("clipName");
|
|
- if(null!=clipName&&!clipName.trim().equals("")){
|
|
|
|
|
|
+ if (null != clipName && !"".equals(clipName.trim())) {
|
|
etlKuaishouVideoInfo.setClipName(clipName);
|
|
etlKuaishouVideoInfo.setClipName(clipName);
|
|
}
|
|
}
|
|
String planId = ascription.getString("planId");
|
|
String planId = ascription.getString("planId");
|
|
- if(null!=planId&&!planId.trim().equals("")){
|
|
|
|
|
|
+ if (null != planId && !"".equals(planId.trim())) {
|
|
etlKuaishouVideoInfo.setPlanId(planId);
|
|
etlKuaishouVideoInfo.setPlanId(planId);
|
|
}
|
|
}
|
|
String planName = ascription.getString("planName");
|
|
String planName = ascription.getString("planName");
|
|
- if(null!=planName&&!planName.trim().equals("")){
|
|
|
|
|
|
+ if (null != planName && !"".equals(planName.trim())) {
|
|
etlKuaishouVideoInfo.setPlanName(planName);
|
|
etlKuaishouVideoInfo.setPlanName(planName);
|
|
}
|
|
}
|
|
String shotId = ascription.getString("shotId");
|
|
String shotId = ascription.getString("shotId");
|
|
- if(null!=shotId&&!shotId.trim().equals("")){
|
|
|
|
|
|
+ if (null != shotId && !"".equals(shotId.trim())) {
|
|
etlKuaishouVideoInfo.setShotId(shotId);
|
|
etlKuaishouVideoInfo.setShotId(shotId);
|
|
}
|
|
}
|
|
String shotName = ascription.getString("shotName");
|
|
String shotName = ascription.getString("shotName");
|
|
- if(null!=shotName&&!shotName.trim().equals("")){
|
|
|
|
|
|
+ if (null != shotName && !"".equals(shotName.trim())) {
|
|
etlKuaishouVideoInfo.setShotName(shotName);
|
|
etlKuaishouVideoInfo.setShotName(shotName);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ if (Check.isNull(clipId)) {
|
|
|
|
+ Long accountId = videoJson.getLong("accountId");
|
|
|
|
+ if (!Check.isNull(accountId)) {
|
|
|
|
+ JSONObject companyJson = companyService.getCompanyInfoByAccountId(accountId);
|
|
|
|
+ if (!Check.isNull(companyJson)) {
|
|
|
|
+ etlKuaishouVideoInfo.setCompanyId(companyJson.getString("companyId"));
|
|
|
|
+ etlKuaishouVideoInfo.setCompanyName(companyJson.getString("companyName"));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ JSONObject companyJson = companyService.getCompanyInfoByUserId(clipId);
|
|
|
|
+ etlKuaishouVideoInfo.setCompanyId(companyJson.getString("companyId"));
|
|
|
|
+ etlKuaishouVideoInfo.setCompanyName(companyJson.getString("companyName"));
|
|
|
|
+ }
|
|
//查询视频初次消耗时间
|
|
//查询视频初次消耗时间
|
|
- String minDate = etlKuaishouVideoInfoMapper.getVideoMinDate(videoGet.getSignature());
|
|
|
|
- if(null!=minDate&&!"".equals(minDate)){
|
|
|
|
- Date getDate = DateUtils.parseDate(minDate,"yyyy-MM-dd");
|
|
|
|
|
|
+ String minDate = etlKuaishouVideoInfoMapper.getVideoMinDate(signature);
|
|
|
|
+ if (null != minDate && !"".equals(minDate)) {
|
|
|
|
+ Date getDate = DateUtils.parseDate(minDate, "yyyy-MM-dd");
|
|
etlKuaishouVideoInfo.setStateDate(getDate);
|
|
etlKuaishouVideoInfo.setStateDate(getDate);
|
|
}
|
|
}
|
|
- etlKuaishouVideoInfoMapper.replaceVideoInfo(etlKuaishouVideoInfo);
|
|
|
|
- }catch (Exception e){
|
|
|
|
|
|
+ addList.add(etlKuaishouVideoInfo);
|
|
|
|
+ } catch (Exception e) {
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
- }finally {
|
|
|
|
- countDownLatch.countDown();
|
|
|
|
}
|
|
}
|
|
- });
|
|
|
|
|
|
+ }
|
|
|
|
+ if (!Check.isNull(addList)) {
|
|
|
|
+ etlKuaishouVideoInfoMapper.addBatch(addList);
|
|
|
|
+
|
|
|
|
+ }
|
|
});
|
|
});
|
|
- try {
|
|
|
|
- countDownLatch.await();
|
|
|
|
- } catch (InterruptedException e) {
|
|
|
|
- e.printStackTrace();
|
|
|
|
- }
|
|
|
|
- log.info("{}数据获取完成",date);
|
|
|
|
}
|
|
}
|
|
|
|
+ log.info("{}数据获取完成", date);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public EtlKuaishouVideoInfo getOneByVideoCode(String signature) {
|
|
public EtlKuaishouVideoInfo getOneByVideoCode(String signature) {
|
|
- QueryWrapper<EtlKuaishouVideoInfo>queryWrapper = new QueryWrapper<>();
|
|
|
|
- queryWrapper.eq("video_code",signature);
|
|
|
|
|
|
+ QueryWrapper<EtlKuaishouVideoInfo> queryWrapper = new QueryWrapper<>();
|
|
|
|
+ queryWrapper.eq("video_code", signature);
|
|
queryWrapper.last("limit 1");
|
|
queryWrapper.last("limit 1");
|
|
return this.getOne(queryWrapper);
|
|
return this.getOne(queryWrapper);
|
|
}
|
|
}
|
|
|
|
+
|
|
}
|
|
}
|