Przeglądaj źródła

素材库数据展示

zhaoxian 4 lat temu
rodzic
commit
12799e11ff

+ 81 - 20
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/MaterialInfoController.java

@@ -2,13 +2,33 @@ package org.jeecg.modules.ctop.controller;
 
 import cn.com.ctop.common.module.annotation.AutoLog;
 import cn.com.ctop.common.module.constant.CtopRoleCodeConstant;
-import cn.com.ctop.common.module.entity.*;
+import cn.com.ctop.common.module.entity.ByteDanceCleanMaterialReport;
+import cn.com.ctop.common.module.entity.KuaiShouCleanMaterialReport;
+import cn.com.ctop.common.module.entity.MaterialAscription;
+import cn.com.ctop.common.module.entity.MaterialCutFrame;
+import cn.com.ctop.common.module.entity.MaterialImageInfo;
+import cn.com.ctop.common.module.entity.MaterialInfo;
+import cn.com.ctop.common.module.entity.MaterialParameter;
+import cn.com.ctop.common.module.entity.MaterialTag;
+import cn.com.ctop.common.module.entity.Project;
 import cn.com.ctop.common.module.enums.MaterialSupplierEnum;
-import cn.com.ctop.common.module.service.*;
+import cn.com.ctop.common.module.service.IByteDanceCleanMaterialReportService;
+import cn.com.ctop.common.module.service.IKuaiShouCleanMaterialReportService;
+import cn.com.ctop.common.module.service.IMaterialAscriptionService;
+import cn.com.ctop.common.module.service.IMaterialCutFrameService;
+import cn.com.ctop.common.module.service.IMaterialImageInfoService;
+import cn.com.ctop.common.module.service.IMaterialInfoService;
+import cn.com.ctop.common.module.service.IMaterialParameterService;
+import cn.com.ctop.common.module.service.IMaterialTagService;
+import cn.com.ctop.common.module.service.IMessageTemplate;
+import cn.com.ctop.common.module.service.IProjectService;
+import cn.com.ctop.common.module.service.ISendMessageService;
+import cn.com.ctop.common.module.service.IVideoWatermarkTaskService;
 import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.common.module.utils.CloudVideoProcessUtil;
 import cn.com.ctop.common.module.utils.JsonUtil;
 import cn.com.ctop.common.module.utils.KuaishouInterfaceConstant;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouReportDailyMaterialService;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@@ -25,13 +45,24 @@ import org.jeecg.common.util.DateUtils;
 import org.jeecg.modules.ctop.service.IProjectMemberService;
 import org.jeecg.modules.system.service.ISysRoleService;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.*;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
 
 import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
 import java.net.URLDecoder;
 import java.text.ParseException;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
 
 /**
  * 素材信息
@@ -65,6 +96,8 @@ public class MaterialInfoController {
     private IProjectMemberService memberService;
     @Autowired
     private IMaterialImageInfoService iMaterialImageInfoService;
+    @Autowired
+    private IKuaiShouReportDailyMaterialService kuaiShouReportDailyMaterialService;
 
 
     @GetMapping("/supplierWatermark")
@@ -309,40 +342,40 @@ public class MaterialInfoController {
     }
 
     @GetMapping(value = "/listV2")
-    public Map<String,Object> queryPageList(String type,Integer status,Long projectId,String materialName,String code,
-                                                     String startDate,String endDate,String tagCode,
-                                                     @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
-                                                     @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
+    public Map<String, Object> queryPageList(String type, Integer status, Long projectId, String materialName, String code,
+                                             String startDate, String endDate, String tagCode,
+                                             @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+                                             @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
         LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
-        List<Long>projectIds = null;
+        List<Long> projectIds = null;
         String userId = user.getId();
         String roleCode = roleService.getRoleCodeByUserId(userId);
-        if(null == tagCode||tagCode.trim().equals("")){
+        if (null == tagCode || tagCode.trim().equals("")) {
             tagCode = null;
         }
-        if (CtopRoleCodeConstant.COMMON_ROLE_CODE_ADMIN.equals(roleCode) || "operator".equals(roleCode) || "kuaishouOperationManager".equals(roleCode) || "operationAssistant".equals(roleCode) || "touTiaoOperationManager".equals(roleCode) || roleCode.contains("sale")){
+        if (CtopRoleCodeConstant.COMMON_ROLE_CODE_ADMIN.equals(roleCode) || "operator".equals(roleCode) || "kuaishouOperationManager".equals(roleCode) || "operationAssistant".equals(roleCode) || "touTiaoOperationManager".equals(roleCode) || roleCode.contains("sale")) {
             //查询所有
-            if(null!=projectId&&projectId!=0){
+            if (null != projectId && projectId != 0) {
                 projectIds = new ArrayList<>();
                 projectIds.add(projectId);
             }
-            return materialInfoService.getListByParams(tagCode,type,status,projectIds,materialName,code,startDate,endDate,null,pageNo,pageSize);
-        }else if ("designTeamLeader".equals(roleCode) || "planeLeader".equals(roleCode) || "plane".equals(roleCode) || "plan".equals(roleCode) || "shot".equals(roleCode)){
+            return materialInfoService.getListByParams(tagCode, type, status, projectIds, materialName, code, startDate, endDate, null, pageNo, pageSize);
+        } else if ("designTeamLeader".equals(roleCode) || "planeLeader".equals(roleCode) || "plane".equals(roleCode) || "plan".equals(roleCode) || "shot".equals(roleCode)) {
             //查询自己所在项目下的数据
-            if(null == projectId||projectId == 0){
+            if (null == projectId || projectId == 0) {
                 projectIds = memberService.selectProjectsByUserId(userId);
-            }else{
+            } else {
                 projectIds = new ArrayList<>();
                 projectIds.add(projectId);
             }
-            return materialInfoService.getListByParams(tagCode,type,status,projectIds,materialName,code,startDate,endDate,null,pageNo,pageSize);
-        }else{
+            return materialInfoService.getListByParams(tagCode, type, status, projectIds, materialName, code, startDate, endDate, null, pageNo, pageSize);
+        } else {
             //查询自己上传的视频
-            if(null!=projectId&&projectId!=0){
+            if (null != projectId && projectId != 0) {
                 projectIds = new ArrayList<>();
                 projectIds.add(projectId);
             }
-            return materialInfoService.getListByParams(tagCode,type,status,projectIds,materialName,code,startDate,endDate,userId,pageNo,pageSize);
+            return materialInfoService.getListByParams(tagCode, type, status, projectIds, materialName, code, startDate, endDate, userId, pageNo, pageSize);
         }
     }
 
@@ -726,4 +759,32 @@ public class MaterialInfoController {
         result.setResult(pageList);
         return result;
     }
+
+    /**
+     * 统计素材总消耗数据
+     *
+     * @param
+     * @return org.jeecg.common.api.vo.Result<com.baomidou.mybatisplus.core.metadata.IPage < cn.com.ctop.common.module.entity.MaterialInfo>>
+     * @throws KuaishouReportDailyMaterial
+     * @author ZHAOXA
+     */
+    @PostMapping(value = "/getMaterialTotalCharge")
+    public Result<List<JSONObject>> getMaterialTotalCharge(@RequestBody List<String> list) {
+        Result<List<JSONObject>> result = new Result<>();
+        try {
+            if (Check.isNull(list)) {
+                result.setMessage("请输入素材消息");
+                result.setSuccess(false);
+                return result;
+            }
+            List<JSONObject> arr = kuaiShouReportDailyMaterialService.getMaterialTotalCharge(list);
+            result.success("查询成功!");
+            result.setResult(arr);
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+            result.error500("查询失败");
+        }
+        return result;
+    }
+
 }

+ 3 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/KuaiShouCreativeMapper.java

@@ -1,6 +1,7 @@
 package cn.com.ctop.kuaishou.modules.batch.mapper;
 
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouCreative;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import org.apache.ibatis.annotations.Param;
 
@@ -19,4 +20,6 @@ public interface KuaiShouCreativeMapper extends BaseMapper<KuaiShouCreative> {
     Integer checkCreativeCount(@Param("accountId") Long accountId, @Param("unitId") Long unitId);
 
     Integer getCreateCount(Long accountId, String startTime);
+
+    List<JSONObject> checkZombieProject(String date);
 }

+ 5 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/KuaiShouReportDailyMaterialMapper.java

@@ -3,6 +3,7 @@ package cn.com.ctop.kuaishou.modules.batch.mapper;
 import cn.com.ctop.kuaishou.modules.report.entity.KuaiShouReportDailyMaterial;
 import cn.com.ctop.kuaishou.modules.report.entity.KuaiShouReportDailyMaterialVo;
 import cn.com.ctop.kuaishou.modules.report.entity.VideoGetvo;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import org.apache.ibatis.annotations.Param;
 
@@ -23,4 +24,8 @@ public interface KuaiShouReportDailyMaterialMapper extends BaseMapper<KuaiShouRe
     VideoGetvo getVideoGetByPhotoId(@Param("photoId") Long photoId);
 
     List<KuaiShouReportDailyMaterialVo> getPhotoListByDate(@Param("statDate") String statDate);
+
+    List<JSONObject> getMaterialTotalCharge(@Param("list") List<String> list);
+
+    List<JSONObject> getByteDanceMaterialTotalCharge(List<String> list);
 }

+ 24 - 1
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaiShouCreativeMapper.xml

@@ -103,5 +103,28 @@
    AND create_channel = 1;
     </select>
 
-
+    <select id="checkZombieProject" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+        t1.id,
+        t1.account_id AS accountId,
+        t1.creative_id AS creativeId,
+        t1.creative_name AS creativeName,
+        t1.campaign_id AS campaignId,
+        t4.campaign_name AS campaignName,
+        t1.unit_id AS unitId,
+        t5.unit_name AS unitName,
+        t3.id AS projectId,
+        t3.project_name AS projectName,
+        t2.user_id AS userId
+        FROM
+        ctop_kuaishou_creative t1
+        LEFT JOIN ctop_user_allocation t2 ON t1.account_id = t2.account_id
+        LEFT JOIN ctop_project t3 ON t2.project_id = t3.id
+        LEFT JOIN ctop_kuaishou_campaign t4 ON t1.campaign_id = t4.campaign_id
+        LEFT JOIN ctop_kuaishou_group t5 ON t1.unit_id = t5.unit_id
+        WHERE
+        creative_create_time &lt;= #{date}
+        AND t1. STATUS = 42
+        and t1.put_status = 1
+    </select>
 </mapper>

+ 34 - 10
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaiShouReportDailyMaterialMapper.xml

@@ -108,16 +108,16 @@
     </insert>
 
     <select id="getPhotoList" resultType="cn.com.ctop.kuaishou.modules.report.entity.KuaiShouReportDailyMaterialVo">
-           select
-           id as id,
-           photo_id as photoId
-           from
-           ctop_kuaishou_report_daily_material
-           where account_id = #{accountId}
-           <if test="statDate != null and statDate != '' ">
-               and stat_date = #{statDate}
-           </if>
-           group by photo_id
+        select
+        id as id,
+        photo_id as photoId
+        from
+        ctop_kuaishou_report_daily_material
+        where account_id = #{accountId}
+        <if test="statDate != null and statDate != '' ">
+            and stat_date = #{statDate}
+        </if>
+        group by photo_id
 
     </select>
 
@@ -143,5 +143,29 @@
       limit 1
     </select>
 
+    <select id="getMaterialTotalCharge" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+        signature,
+        sum(charge) as kuaishouCharges
+        FROM ctop_kuaishou_report_daily_material
+        WHERE signature IN
+        <foreach item="item" index="index" collection="list" open="(" separator="," close=")">
+            #{item}
+        </foreach>
+        GROUP BY signature
+    </select>
+
+    <select id="getByteDanceMaterialTotalCharge" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+        signature,
+        sum(cost) as bytedanceCharges
+        FROM ctop_bytedance_video_report_daily
+        WHERE signature IN
+        <foreach item="item" index="index" collection="list" open="(" separator="," close=")">
+            #{item}
+        </foreach>
+        GROUP BY signature
+    </select>
+
 
 </mapper>

+ 13 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaiShouReportDailyMaterialService.java

@@ -1,8 +1,11 @@
 package cn.com.ctop.kuaishou.modules.batch.service;
 
 import cn.com.ctop.kuaishou.modules.report.entity.KuaiShouReportDailyMaterial;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.extension.service.IService;
 
+import java.util.List;
+
 /**
  * @Description: 素材
  * @Author: jeecg-boot
@@ -11,4 +14,14 @@ import com.baomidou.mybatisplus.extension.service.IService;
  */
 public interface IKuaiShouReportDailyMaterialService extends IService<KuaiShouReportDailyMaterial> {
 
+    /**
+     * 统计素材总消耗数据
+     *
+     * @param
+     * @return javax.json.JsonArray
+     * @throws
+     * @author ZHAOXA
+     */
+
+    List<JSONObject> getMaterialTotalCharge(List<String> list);
 }

+ 28 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouReportDailyMaterialServiceImpl.java

@@ -1,11 +1,16 @@
 package cn.com.ctop.kuaishou.modules.batch.service.impl;
 
+import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouReportDailyMaterialMapper;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouReportDailyMaterialService;
 import cn.com.ctop.kuaishou.modules.report.entity.KuaiShouReportDailyMaterial;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.List;
+
 /**
  * 素材
  *
@@ -16,4 +21,27 @@ import org.springframework.stereotype.Service;
 @Service
 public class KuaiShouReportDailyMaterialServiceImpl extends ServiceImpl<KuaiShouReportDailyMaterialMapper, KuaiShouReportDailyMaterial> implements IKuaiShouReportDailyMaterialService {
 
+    @Autowired
+    private KuaiShouReportDailyMaterialMapper kuaiShouReportDailyMaterialMapper;
+
+    @Override
+    public List<JSONObject> getMaterialTotalCharge(List<String> list) {
+        //统计快手总消耗数据
+        List<JSONObject> kuaishous = kuaiShouReportDailyMaterialMapper.getMaterialTotalCharge(list);
+        //统计抖音总消耗数据
+        List<JSONObject> bytedances = kuaiShouReportDailyMaterialMapper.getByteDanceMaterialTotalCharge(list);
+        if (!Check.isNull(kuaishous) && !Check.isNull(bytedances)) {
+            kuaishous.forEach(kuaishou -> {
+                bytedances.forEach(bytedance -> {
+                    if (kuaishou.getString("signature").equals(bytedance.getString("signature"))) {
+                        kuaishou.put("douyinCharges", bytedance.getBigDecimal("bytedanceCharges"));
+                    }
+                });
+            });
+        }
+        if (Check.isNull(kuaishous)) {
+            return bytedances;
+        }
+        return kuaishous;
+    }
 }

+ 25 - 8
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/KuaishouZombieCreativeServiceImpl.java

@@ -9,6 +9,8 @@ import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.common.module.utils.HttpUtils;
 import cn.com.ctop.common.module.utils.KuaishouInterfaceConstant;
 import cn.com.ctop.common.module.utils.PropertiesUtils;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouCreative;
+import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouCreativeMapper;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouUpdateService;
 import cn.com.ctop.kuaishou.modules.report.entity.KuaishouZombieCreative;
 import cn.com.ctop.kuaishou.modules.report.mapper.KuaishouReportDailyCreativeMapper;
@@ -41,7 +43,9 @@ public class KuaishouZombieCreativeServiceImpl extends ServiceImpl<KuaishouZombi
     @Autowired
     private KuaishouReportDailyCreativeMapper kuaishouReportDailyCreativeMapper;
     @Autowired
-    private KuaishouZombieCreativeMapper KuaishouZombieCreativeMapper;
+    private KuaishouZombieCreativeMapper kuaishouZombieCreativeMapper;
+    @Autowired
+    private KuaiShouCreativeMapper kuaiShouCreativeMapper;
     @Autowired
     private ISendMessageService sendMessageService;
     @Autowired
@@ -76,14 +80,18 @@ public class KuaishouZombieCreativeServiceImpl extends ServiceImpl<KuaishouZombi
         String date = DateUtils.getLastDay(DateUtils.formatDate(new Date()), NoEn.NO5.valueInt());
         //查询五天内花费都为0的数据集
         List<JSONObject> list = kuaishouReportDailyCreativeMapper.checkZombieProject(date);
-        if (Check.isNull(list)) {
+        //查询审核未通过且超过5天的创意集
+        List<JSONObject> olist = kuaiShouCreativeMapper.checkZombieProject(date);
+        if (Check.isNull(list) && Check.isNull(olist)) {
             return;
+        } else {
+            list.addAll(olist);
         }
         //查询数据库中前一天存储的待确认僵尸创意集
         Map<String, Object> map = new HashMap<>();
         map.put("record_time", DateUtils.getLastDay(DateUtils.formatDate(new Date()), NoEn.NO1.valueInt()));
         map.put("status", NoEn.NO0.valueStr());
-        List<KuaishouZombieCreative> zombieCreatives = KuaishouZombieCreativeMapper.selectByMap(map);
+        List<KuaishouZombieCreative> zombieCreatives = kuaishouZombieCreativeMapper.selectByMap(map);
         if (!Check.isNull(zombieCreatives)) {
             List<KuaishouZombieCreative> zombiePlans = new ArrayList<>();
             List<JSONObject> zombieList = new ArrayList<>();
@@ -110,7 +118,16 @@ public class KuaishouZombieCreativeServiceImpl extends ServiceImpl<KuaishouZombi
                             zombie.setStatus(NoEn.NO2.valueStr());
                         }
                         //3.3更新状态
-                        KuaishouZombieCreativeMapper.update(zombie, wrapper);
+                        kuaishouZombieCreativeMapper.update(zombie, wrapper);
+                        //校验数据为审核未通过数据,并将投放状态设为“暂停”
+                        if (Check.isNull(obj.getInteger("dates"))) {
+                            QueryWrapper<KuaiShouCreative> creativeWrapper = new QueryWrapper<>();
+                            creativeWrapper.eq("id", obj.getString("id"));
+                            KuaiShouCreative creative = new KuaiShouCreative();
+                            //投放状态 1:投放中;2:暂停
+                            creative.setPutStatus(NoEn.NO2.valueInt());
+                            kuaiShouCreativeMapper.update(creative, creativeWrapper);
+                        }
                     }
                 });
             });
@@ -122,7 +139,7 @@ public class KuaishouZombieCreativeServiceImpl extends ServiceImpl<KuaishouZombi
                 wrapper.eq("id", zom.getId());
                 //状态 0-待确认,1-是僵尸计划,2-已活跃,不是僵尸计划
                 zom.setStatus(NoEn.NO2.valueStr());
-                KuaishouZombieCreativeMapper.update(zom, wrapper);
+                kuaishouZombieCreativeMapper.update(zom, wrapper);
             });
             //过滤掉已确认的数据,新增新一批的僵尸计划
             list.removeAll(zombieList);
@@ -142,7 +159,7 @@ public class KuaishouZombieCreativeServiceImpl extends ServiceImpl<KuaishouZombi
      */
     private void insertorUpdate(List<JSONObject> list) {
         //查询库中已有的全部数据
-        List<KuaishouZombieCreative> kuaishouZombieCreatives = KuaishouZombieCreativeMapper.selectList(null);
+        List<KuaishouZombieCreative> kuaishouZombieCreatives = kuaishouZombieCreativeMapper.selectList(null);
         if (!Check.isNull(kuaishouZombieCreatives)) {
             List<KuaishouZombieCreative> updateList = new ArrayList<>();
             List<JSONObject> toBeDeleted = new ArrayList<>();
@@ -162,7 +179,7 @@ public class KuaishouZombieCreativeServiceImpl extends ServiceImpl<KuaishouZombi
                     wrapper.eq("id", zom.getId());
                     zom.setStatus(NoEn.NO0.valueStr());
                     zom.setRecordTime(DateUtils.getNowDate(DateUtils.WEB_FORMAT));
-                    KuaishouZombieCreativeMapper.update(zom, wrapper);
+                    kuaishouZombieCreativeMapper.update(zom, wrapper);
                 });
             }
             //去除已有的数据,新的数据作insert
@@ -191,7 +208,7 @@ public class KuaishouZombieCreativeServiceImpl extends ServiceImpl<KuaishouZombi
             create.setRecordTime(DateUtils.getNowDate(DateUtils.WEB_FORMAT));
             //状态 0-待确认,1-是僵尸计划,2-已活跃,不是僵尸计划
             create.setStatus(NoEn.NO0.valueStr());
-            KuaishouZombieCreativeMapper.insert(create);
+            kuaishouZombieCreativeMapper.insert(create);
             sendMsg(NoEn.NO1.valueStr(), obj);
         });
     }