浏览代码

数据标签

zhouzeyu@c-top.com.cn 3 年之前
父节点
当前提交
d857453f10

+ 32 - 8
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/label/controller/LbelController.java

@@ -1,11 +1,11 @@
 package cn.com.ctop.kuaishou.modules.label.controller;
 
 import cn.com.ctop.kuaishou.modules.clean.entity.KuaiShouAccountCleanTemplateInfo;
+import cn.com.ctop.kuaishou.modules.label.service.MaterialLabelService;
 import org.jeecg.common.api.vo.Result;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
+
+import javax.annotation.Resource;
 
 /**
  * @Description: 标签管理
@@ -17,14 +17,38 @@ import org.springframework.web.bind.annotation.RestController;
 @RequestMapping("/label")
 public class LbelController {
 
+    @Resource
+    MaterialLabelService materialTagService;
+    /**
+     * 查询标签
+     *
+     * @param
+     * @return
+     */
+    @GetMapping ("/filterMaterial")
+    public Result createCleanTemplate(){
+        return   materialTagService.filterMaterial();
+    }
+
     /**
      * 查询标签
      *
-     * @param kuaiShouAccountCleanTemplateInfo
+     * @param
+     * @return
+     */
+    @GetMapping ("/materialSpecificationLabel")
+    public Result materialSpecificationLabel(){
+        return   materialTagService.materialSpecificationLabel();
+    }
+
+    /**
+     * 同步标签到ES
+     *
+     * @param
      * @return
      */
-    @PostMapping("/createTemplate")
-    public Result createCleanTemplate(@RequestBody KuaiShouAccountCleanTemplateInfo kuaiShouAccountCleanTemplateInfo){
-        return   null;
+    @GetMapping ("/SynchronousLabel")
+    public Result SynchronousLabel(){
+        return   materialTagService.materialSpecificationLabel();
     }
 }

+ 34 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/label/entity/LabelStandardInfo.java

@@ -0,0 +1,34 @@
+package cn.com.ctop.kuaishou.modules.label.entity;
+
+import lombok.Data;
+
+@Data
+public class LabelStandardInfo {
+    //主键
+    private String id;
+    //素材标识
+    private String signature;
+    //素材产生消耗的最早日期
+    private String chargeDate;
+    //三十天内累计激活数
+    private String activationThirtyDays;
+    //两天内累计激活数
+    private String activationTwoDays;
+    //30天内表单提交数
+    private String formCountThirtyDays;
+    //两天内表单提交数
+    private String formCountTwoDays;
+    //30天内3s完播率
+    private String play3sRatio;
+    //30天内转化率
+    private String conversionRatio;
+    //30天内行为率
+    private String behaviorRation;
+    //30天内次留率
+    private String eventNextDayStayRatio;
+    //创建时间
+    private String createTime;
+    //更新时间
+    private String updateTime;
+
+}

+ 46 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/label/entity/MaterialLabelInfo.java

@@ -0,0 +1,46 @@
+package cn.com.ctop.kuaishou.modules.label.entity;
+
+import cn.com.ctop.common.module.annotation.Document;
+import cn.com.ctop.common.module.annotation.EsId;
+import cn.com.ctop.common.module.annotation.FieId;
+import cn.com.ctop.common.module.enums.AnalyzerType;
+import cn.com.ctop.common.module.enums.FieldType;
+import lombok.Data;
+
+@Data
+@Document(index = "data_labels", type = "lable")
+public class MaterialLabelInfo {
+    @FieId(type = FieldType.KEYWORD)
+    private String id;
+    @FieId(type = FieldType.KEYWORD)
+    private String code;
+    @FieId(type = FieldType.KEYWORD)
+    private String slogansCount;
+    @FieId(type = FieldType.KEYWORD)
+    private String offlineFlag;
+    @FieId(type = FieldType.KEYWORD)
+    private String confirmTime;
+    @FieId(type = FieldType.KEYWORD,analyzer = AnalyzerType.IK_SMART)
+    private String tagCode;
+    @FieId(type = FieldType.KEYWORD,analyzer = AnalyzerType.IK_SMART)
+    private String tagName;
+    @EsId
+    @FieId(type = FieldType.KEYWORD)
+    private String tagId;
+    @FieId(type = FieldType.KEYWORD)
+    private String clipId;
+    @FieId(type = FieldType.KEYWORD)
+    private String shotId;
+    @FieId(type = FieldType.KEYWORD)
+    private String planId;
+    @FieId(type = FieldType.KEYWORD)
+    private String status;
+    @FieId(type = FieldType.KEYWORD)
+    private String userId;
+    @FieId(type = FieldType.KEYWORD)
+    private String materialName;
+    @FieId(type = FieldType.KEYWORD)
+    private String projectId;
+    @FieId(type = FieldType.KEYWORD)
+    private String createTime;
+}

+ 48 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/label/mapper/MaterialLabelMapper.java

@@ -1,5 +1,8 @@
 package cn.com.ctop.kuaishou.modules.label.mapper;
 
+import cn.com.ctop.common.module.entity.TagInfo;
+import cn.com.ctop.kuaishou.modules.label.entity.LabelStandardInfo;
+import cn.com.ctop.kuaishou.modules.label.entity.MaterialLabelInfo;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 
@@ -22,4 +25,49 @@ public interface MaterialLabelMapper {
      * 获取素材产生消耗的最早日期
      */
     String getMaterialFirstDate(@Param("signature")String signature);
+    /**
+     * 查询素材30日数据
+     */
+    LabelStandardInfo getLabermessage(@Param("signature")String signature,@Param("startDate")String startDate,@Param("endDate")String endDate);
+    /**
+     * 查询素材2日数据
+     */
+    LabelStandardInfo getLabermessageByTwoDays(@Param("signature")String signature,@Param("startDate")String startDate,@Param("endDate")String endDate);
+    /**
+     * 保存素材判断标准数据
+     */
+    void saveLabelMessage(LabelStandardInfo LabelStandardInfo);
+    /**
+     * 素材标准数据判断是否存在此素材
+     */
+    LabelStandardInfo  getMaterialRecord(@Param("signature")String signature);
+    /**
+     * 修改素材标准数据
+     */
+    void updateMaterialRecord(LabelStandardInfo LabelStandardInfo);
+    /**
+     * 查询所有标签
+     */
+    List<TagInfo> getTagInfo();
+    /**
+     * 查询所有素材标准数据
+     */
+    List<LabelStandardInfo> getAllMaterialData();
+
+    /**
+     * 保存素材标签数据
+     */
+    void saveMaterialTag(@Param("code")String code,@Param("tagName")String tagName,@Param("tagCode")String tagCode,@Param("tagId")String tagId,@Param("categoryId")String categoryId,@Param("createTime")String createTime);
+
+    /**
+     * 根据素材标识和标签编码查询数据
+     */
+    int getDataByCodeAndSignature(@Param("signature")String code,@Param("tagCode")String tagCode);
+
+    /**
+     * 查询素材数据以及标签
+     */
+    List<MaterialLabelInfo> getMaterialLabelData(@Param("date")String date);
+
+
 }

+ 147 - 8
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/label/mapper/xml/MaterialTagMapper.xml

@@ -3,14 +3,48 @@
 <mapper namespace="cn.com.ctop.kuaishou.modules.label.mapper.MaterialLabelMapper">
 
 
-  <resultMap id="logResultMap" type="cn.com.ctop.kuaishou.modules.clean.entity.KuaiShouAccountCleanLogInfo">
-    <id column="id" property="id"/>
-    <result column="account_id" property="accountId"/>
-    <result column="user_name" property="userName"/>
-    <result column="operation_type" property="operationType"/>
-    <result column="create_time" property="createTime"/>
-    <result column="executive_information" property="executiveInformation"/>
-  </resultMap>
+    <resultMap id="BaseResultMap" type="cn.com.ctop.kuaishou.modules.label.entity.LabelStandardInfo">
+        <id column="id" property="id"/>
+        <result column="signature" property="signature"/>
+        <result column="charge_date" property="chargeDate"/>
+        <result column="activation_thirty_days" property="activationThirtyDays"/>
+        <result column="activation_two_days" property="activationTwoDays"/>
+        <result column="form_count_thirty_days" property="formCountThirtyDays"/>
+        <result column="form_count_two_days" property="formCountTwoDays"/>
+        <result column="play_3s_ratio" property="play3sRatio"/>
+        <result column="conversion_ratio" property="conversionRatio"/>
+        <result column="behavior_ration" property="behaviorRation"/>
+        <result column="event_next_day_stay_ratio" property="eventNextDayStayRatio"/>
+        <result column="create_time" property="createTime"/>
+        <result column="update_time" property="updateTime"/>
+    </resultMap>
+
+
+
+    <resultMap id="TagResultMap" type="cn.com.ctop.common.module.entity.TagInfo">
+        <id column="id" property="id"/>
+        <result column="tag_name" property="tagName"/>
+        <result column="tag_code" property="tagCode"/>
+    </resultMap>
+
+    <resultMap id="MaterialLabelResultMap" type="cn.com.ctop.kuaishou.modules.label.entity.MaterialLabelInfo">
+        <id column="id" property="id"/>
+        <result column="code" property="code"/>
+        <result column="slogansCount" property="slogansCount"/>
+        <result column="offline_flag" property="offlineFlag"/>
+        <result column="confirm_time" property="confirmTime"/>
+        <result column="tag_code" property="tagCode"/>
+        <result column="tag_name" property="tagName"/>
+        <result column="tag_id" property="tagId"/>
+        <result column="clip_id" property="clipId"/>
+        <result column="shot_id" property="shotId"/>
+        <result column="plan_id" property="planId"/>
+        <result column="status" property="status"/>
+        <result column="user_id" property="userId"/>
+        <result column="material_name" property="materialName"/>
+        <result column="project_id" property="projectId"/>
+        <result column="create_time" property="createTime"/>
+</resultMap>
 
     <select id="getMateriaSignature" resultType="String">
         SELECT  signature from ctop_etl_kuaishou_video_base_info t  GROUP BY t.signature
@@ -21,5 +55,110 @@
         SELECT  MIN(stat_date) from ctop_kuaishou_report_daily_material t where t.charge>0 and  t.signature=#{signature}
     </select>
 
+    <select id="getLabermessage"  resultMap="BaseResultMap">
+        SELECT  SUM(activation) as 'activation_thirty_days',SUM(form_count) as 'form_count_thirty_days',
+        SUM(play_3s_ratio*aclick)/SUM(aclick) as 'play_3s_ratio',
+        SUM(activation)/SUM(bclick) as 'conversion_ratio',
+        SUM(bclick)/SUM(aclick) as 'behavior_ration',
+        SUM(event_next_day_stay)/SUM(activation) as 'event_next_day_stay_ratio'
+        from ctop_kuaishou_report_daily_material t
+        where  t.signature=#{signature}
+        and t.stat_date &gt;=#{startDate}
+        and t.stat_date &lt;=#{endDate}
+    </select>
+
+    <select id="getLabermessageByTwoDays"  resultMap="BaseResultMap">
+        SELECT  SUM(activation) as 'activation_two_days',SUM(form_count) as 'form_count_two_days'
+        from ctop_kuaishou_report_daily_material t
+        where  t.signature=#{signature}
+        and t.stat_date &gt;=#{startDate}
+        and t.stat_date &lt;=#{endDate}
+    </select>
+
+    <insert id="saveLabelMessage" parameterType="cn.com.ctop.kuaishou.modules.label.entity.LabelStandardInfo">
+        insert into ctop_label_standard (signature,charge_date,activation_thirty_days,activation_two_days,form_count_thirty_days,
+        form_count_two_days,play_3s_ratio,conversion_ratio,behavior_ration,event_next_day_stay_ratio,create_time,update_time)
+        values
+        (#{signature},#{chargeDate},#{activationThirtyDays},#{activationTwoDays},#{formCountThirtyDays},#{formCountTwoDays},#{play3sRatio},#{conversionRatio},
+        #{behaviorRation},#{eventNextDayStayRatio},#{createTime},#{updateTime})
+    </insert>
+
+    <select id="getMaterialRecord" resultMap="BaseResultMap">
+        select * from ctop_label_standard where signature=#{signature}
+    </select>
+
+    <select id="getAllMaterialData" resultMap="BaseResultMap">
+         select * from ctop_label_standard
+    </select>
+
+    <update id="updateMaterialRecord">
+        update ctop_label_standard set charge_date=#{chargeDate},activation_thirty_days=#{activationThirtyDays},activation_two_days=#{activationTwoDays},
+        form_count_thirty_days=#{formCountThirtyDays},form_count_two_days=#{formCountTwoDays},play_3s_ratio=#{play3sRatio},conversion_ratio=#{conversionRatio},
+        conversionRatio=#{behaviorRation},event_next_day_stay_ratio=#{eventNextDayStayRatio},update_time=#{updateTime} where signature=#{signature}
+    </update>
+
+    <select id="getTagInfo"  resultMap="TagResultMap">
+        select id,tag_name,tag_code from ctop_tag_info t
+    </select>
+
+    <select id="getDataByCodeAndSignature" resultType="int">
+        select count(*) from ctop_material_tag_info t where t.code=#{signature} and t.tag_code=#{tagCode}
+    </select>
+
+    <insert id="saveMaterialTag" >
+        insert into ctop_material_tag_info (code,status,tag_name,tag_code,user_id,tag_id,category_id,create_time) values
+        (#{code},'1',#{tagName},#{tagCode},null,#{tagId},#{categoryId},#{createTime})
+    </insert>
+
+    <select id="getMaterialLabelData" resultMap="MaterialLabelResultMap">
+             SELECT
+             matInfo.id,
+             matInfo. CODE,
+             matInfo.project_id,
+             t.slogansCount,
+             matInfo.offline_flag,
+             matInfo.confirm_time,
+             tagInfo.tag_code,
+             tagInfo.tag_name,
+             tagInfo.id AS 'tag_id',
+             ascription.clip_id,
+             ascription.shot_id,
+             ascription.plan_id,
+             matInfo. STATUS,
+             matInfo.user_id,
+             matInfo.material_name,
+             matInfo.project_id,
+             matInfo.create_time
+             FROM
+             ctop_material_info matInfo
+             LEFT JOIN (
+             SELECT
+                 video_code,
+                 count(*) AS slogansCount
+             FROM
+                 ctop_bytedance_video_slogen_info
+             WHERE
+                 STATUS = 1
+             GROUP BY
+                 video_code
+             ) t ON matInfo. CODE = t.video_code
+             LEFT JOIN (
+             SELECT
+                 id,
+                 t. CODE,
+                 group_concat(tag_code SEPARATOR ';') AS 'tag_code',
+                 group_concat(tag_name SEPARATOR ';') AS 'tag_name'
+             FROM
+                 ctop_material_tag_info t
+             GROUP BY
+                 CODE
+             ) tagInfo ON tagInfo. CODE = matInfo. CODE
+             LEFT JOIN ctop_material_ascription ascription ON matInfo. CODE = ascription.material_id
+             <where>
+                 <if test="date!=null and date!=''">
+                     and (tagInfo.create_time &gt;=#{date} or tagInfo.update_time &gt;=#{date})
+                 </if >
+             </where>
+    </select>
 
 </mapper>

+ 368 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/label/service/impl/MaterialLabelServiceImpl.java

@@ -0,0 +1,368 @@
+package cn.com.ctop.kuaishou.modules.label.service.impl;
+
+import cn.com.ctop.common.module.entity.TagInfo;
+import cn.com.ctop.kuaishou.modules.label.entity.LabelStandardInfo;
+import cn.com.ctop.kuaishou.modules.label.entity.MaterialLabelInfo;
+import cn.com.ctop.kuaishou.modules.label.mapper.MaterialLabelMapper;
+import cn.com.ctop.kuaishou.modules.label.service.MaterialLabelService;
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.api.vo.Result;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.text.SimpleDateFormat;
+import java.util.*;
+
+/**
+ * @Description: 素材标签
+ * @Author: zzy
+ * @Date: 2021-07-30
+ * @Version: V1.0
+ */
+@Service
+@Slf4j
+public class MaterialLabelServiceImpl implements MaterialLabelService {
+
+
+    @Resource
+    MaterialLabelMapper materialLabelMapper;
+
+
+    /**
+     * 清洗各素材指标入库
+     *
+     * @param
+     * @return
+     */
+    @Override
+    public Result filterMaterial() {
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+        Result result = new Result();
+        try {
+            //查询所有素材标签
+            List<String> materiaSignature = materialLabelMapper.getMateriaSignature();
+            if (!materiaSignature.isEmpty()) {
+                materiaSignature.stream().forEach(str -> {
+                    if (!str.isEmpty()) {
+                        //获取素材产生消耗的最早日期
+                        String materialFirstDate = materialLabelMapper.getMaterialFirstDate(str);
+                        if (materialFirstDate != null) {
+                            //获取30天之后的日期
+                            String afterDate = getDateByNumber(materialFirstDate, 30);
+                            //获取2天之后的日期
+                            String afterDate2 = getDateByNumber(materialFirstDate, 2);
+                            //根据日期查询素材各项指标入库
+                            LabelStandardInfo labermessage = materialLabelMapper.getLabermessage(str, materialFirstDate, afterDate);
+                            if (labermessage != null) {
+                                //查询两天内数据
+                                LabelStandardInfo labermessageByTwoDays = materialLabelMapper.getLabermessageByTwoDays(str, materialFirstDate, afterDate2);
+                                if (labermessageByTwoDays.getActivationTwoDays() != null) {
+                                    labermessage.setActivationTwoDays(labermessageByTwoDays.getActivationTwoDays());
+                                }
+                                if (labermessageByTwoDays.getFormCountTwoDays() != null) {
+                                    labermessage.setFormCountTwoDays(labermessageByTwoDays.getFormCountTwoDays());
+                                }
+                                labermessage.setSignature(str);
+                                labermessage.setChargeDate(materialFirstDate);
+                                labermessage.setCreateTime(sdf.format(new Date()));
+                                labermessage.setUpdateTime(sdf.format(new Date()));
+                                //查询素材标签标准表是否存在此素材
+                                LabelStandardInfo materialRecord = materialLabelMapper.getMaterialRecord(str);
+                                if (materialRecord != null) {
+                                    //存在则更新
+                                    materialLabelMapper.updateMaterialRecord(labermessage);
+                                } else {
+                                    //不存在插入
+                                    materialLabelMapper.saveLabelMessage(labermessage);
+                                }
+
+                            }
+                        }
+
+                    }
+
+                });
+            }
+            result.success("success");
+        } catch (Exception e) {
+            result.error500("error");
+            log.info("清洗标签指标数据错误:{}", e.toString());
+        }
+
+        return result;
+    }
+
+    /**
+     * 根据素材指标制定素材标签
+     *
+     * @param
+     * @return
+     */
+    @Override
+    public Result materialSpecificationLabel() {
+        Result result = new Result();
+        Map<String, String> tgaMap = new HashMap<>();
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+
+        try {
+            String date = sdf.format(new Date());
+            //查询所有标签
+            List<TagInfo> tagInfo = materialLabelMapper.getTagInfo();
+            if (!tagInfo.isEmpty()) {
+                tagInfo.stream().forEach(tag -> {
+                    tgaMap.put(tag.getTagName(), tag.getTagCode() + ";" + tag.getId());
+                });
+            }
+            //查询素材标签判断标准数据
+            List<LabelStandardInfo> allMaterialData = materialLabelMapper.getAllMaterialData();
+            if (!allMaterialData.isEmpty()) {
+                allMaterialData.stream().forEach(obj -> {
+                    //三十天内累计激活数
+                    String activationThirtyDays = obj.getActivationThirtyDays();
+                    //两天内累计激活数
+                    String activationTwoDays = obj.getActivationTwoDays();
+                    //30天内表单提交数
+                    String formCountThirtyDays = obj.getFormCountThirtyDays();
+                    //两天内表单提交数
+                    String formCountTwoDays = obj.getFormCountTwoDays();
+                    //30天内3s完播率
+                    String play3sRatio = obj.getPlay3sRatio();
+                    //30天内转化率
+                    String conversionRatio = obj.getConversionRatio();
+                    //30天内行为率
+                    String behaviorRation = obj.getBehaviorRation();
+                    //30天内次留率
+                    String eventNextDayStayRatio = obj.getEventNextDayStayRatio();
+                    //应用下载--合格素材
+                    if (activationThirtyDays != null && formCountThirtyDays != null && Integer.parseInt(activationThirtyDays) >= 100 && Integer.parseInt(formCountThirtyDays) == 0) {
+                        String[] split = tgaMap.get("应用下载--合格素材").split(";");
+                        int count = materialLabelMapper.getDataByCodeAndSignature(obj.getSignature(), split[0]);
+                        //次素材没有打此标签
+                        if (count == 0) {
+                            materialLabelMapper.saveMaterialTag(obj.getSignature(), "应用下载--合格素材", split[0], split[1], "1", date);
+                        }
+                    }
+
+                    //应应用下载--起量快
+                    if (activationTwoDays != null && formCountTwoDays != null && Integer.parseInt(activationTwoDays) >= 96 && Integer.parseInt(formCountTwoDays) == 0) {
+                        String[] split = tgaMap.get("应用下载--起量快").split(";");
+                        int count = materialLabelMapper.getDataByCodeAndSignature(obj.getSignature(), split[0]);
+                        //次素材没有打此标签
+                        if (count == 0) {
+                            materialLabelMapper.saveMaterialTag(obj.getSignature(), "应用下载--起量快", split[0], split[1], "1", date);
+                        }
+                    }
+
+                    //应用下载-高-3s完播率
+                    if (activationThirtyDays != null && play3sRatio != null && Integer.parseInt(activationThirtyDays) >= 100 && Double.parseDouble(play3sRatio) > 0.657) {
+                        String[] split = tgaMap.get("应用下载-高-3s完播率").split(";");
+                        int count = materialLabelMapper.getDataByCodeAndSignature(obj.getSignature(), split[0]);
+                        //次素材没有打此标签
+                        if (count == 0) {
+                            materialLabelMapper.saveMaterialTag(obj.getSignature(), "应用下载-高-3s完播率", split[0], split[1], "1", date);
+                        }
+                    }
+
+                    // 应用下载-低-3s完播率
+                    if (activationThirtyDays != null && play3sRatio != null && Integer.parseInt(activationThirtyDays) >= 100 && Double.parseDouble(play3sRatio) < 0.132) {
+                        String[] split = tgaMap.get("应用下载-低-3s完播率").split(";");
+                        int count = materialLabelMapper.getDataByCodeAndSignature(obj.getSignature(), split[0]);
+                        //次素材没有打此标签
+                        if (count == 0) {
+                            materialLabelMapper.saveMaterialTag(obj.getSignature(), "应用下载-低-3s完播率", split[0], split[1], "1", date);
+                        }
+                    }
+
+                    // 应用下载-高-转化率
+                    if (activationThirtyDays != null && conversionRatio != null && Integer.parseInt(activationThirtyDays) >= 100 && Double.parseDouble(conversionRatio) > 0.366) {
+                        String[] split = tgaMap.get("应用下载-高-转化率").split(";");
+                        int count = materialLabelMapper.getDataByCodeAndSignature(obj.getSignature(), split[0]);
+                        //次素材没有打此标签
+                        if (count == 0) {
+                            materialLabelMapper.saveMaterialTag(obj.getSignature(), "应用下载-高-转化率", split[0], split[1], "1", date);
+                        }
+                    }
+
+                    // 应用下载-低-转化率
+                    if (activationThirtyDays != null && conversionRatio != null && Integer.parseInt(activationThirtyDays) >= 100 && Double.parseDouble(conversionRatio) < 0.009) {
+                        String[] split = tgaMap.get("应用下载-低-转化率").split(";");
+                        int count = materialLabelMapper.getDataByCodeAndSignature(obj.getSignature(), split[0]);
+                        //次素材没有打此标签
+                        if (count == 0) {
+                            materialLabelMapper.saveMaterialTag(obj.getSignature(), "应用下载-低-转化率", split[0], split[1], "1", date);
+                        }
+                    }
+
+                    // 应用下载-高-行为率
+                    if (activationThirtyDays != null && behaviorRation != null && Integer.parseInt(activationThirtyDays) >= 100 && Double.parseDouble(behaviorRation) > 0.059) {
+                        String[] split = tgaMap.get("应用下载-高-行为率").split(";");
+                        int count = materialLabelMapper.getDataByCodeAndSignature(obj.getSignature(), split[0]);
+                        //次素材没有打此标签
+                        if (count == 0) {
+                            materialLabelMapper.saveMaterialTag(obj.getSignature(), "应用下载-高-行为率", split[0], split[1], "1", date);
+                        }
+                    }
+
+                    // 应用下载-低-行为率
+                    if (activationThirtyDays != null && behaviorRation != null && Integer.parseInt(activationThirtyDays) >= 100 && Double.parseDouble(behaviorRation) < 0.003) {
+                        String[] split = tgaMap.get("应用下载-低-行为率").split(";");
+                        int count = materialLabelMapper.getDataByCodeAndSignature(obj.getSignature(), split[0]);
+                        //次素材没有打此标签
+                        if (count == 0) {
+                            materialLabelMapper.saveMaterialTag(obj.getSignature(), "应用下载-低-行为率", split[0], split[1], "1", date);
+                        }
+                    }
+
+                    // 应用下载-高-次留率
+                    if (activationThirtyDays != null && eventNextDayStayRatio != null && Integer.parseInt(activationThirtyDays) >= 100 && Double.parseDouble(eventNextDayStayRatio) > 0.453) {
+                        String[] split = tgaMap.get("应用下载-高-次留率").split(";");
+                        int count = materialLabelMapper.getDataByCodeAndSignature(obj.getSignature(), split[0]);
+                        //次素材没有打此标签
+                        if (count == 0) {
+                            materialLabelMapper.saveMaterialTag(obj.getSignature(), "应用下载-高-次留率", split[0], split[1], "1", date);
+                        }
+                    }
+
+                    // 应用下载-低-次留率
+                    if (activationThirtyDays != null && eventNextDayStayRatio != null && Integer.parseInt(activationThirtyDays) >= 100 && Double.parseDouble(eventNextDayStayRatio) == 0.000) {
+                        String[] split = tgaMap.get("应用下载-低-次留率").split(";");
+                        int count = materialLabelMapper.getDataByCodeAndSignature(obj.getSignature(), split[0]);
+                        //次素材没有打此标签
+                        if (count == 0) {
+                            materialLabelMapper.saveMaterialTag(obj.getSignature(), "应用下载-低-次留率", split[0], split[1], "1", date);
+                        }
+                    }
+
+
+                    // 表单提交--合格素材
+                    if (formCountThirtyDays != null && activationThirtyDays != null && Integer.parseInt(formCountThirtyDays) >= 20 && Integer.parseInt(activationThirtyDays) == 0) {
+                        String[] split = tgaMap.get("表单提交--合格素材").split(";");
+                        int count = materialLabelMapper.getDataByCodeAndSignature(obj.getSignature(), split[0]);
+                        //次素材没有打此标签
+                        if (count == 0) {
+                            materialLabelMapper.saveMaterialTag(obj.getSignature(), "表单提交--合格素材", split[0], split[1], "1", date);
+                        }
+                    }
+
+                    // 表单提交--起量快
+                    if (formCountTwoDays != null && activationTwoDays != null && Integer.parseInt(formCountTwoDays) >= 30 && Integer.parseInt(activationTwoDays) == 0) {
+                        String[] split = tgaMap.get("表单提交--起量快").split(";");
+                        int count = materialLabelMapper.getDataByCodeAndSignature(obj.getSignature(), split[0]);
+                        //次素材没有打此标签
+                        if (count == 0) {
+                            materialLabelMapper.saveMaterialTag(obj.getSignature(), "表单提交--起量快", split[0], split[1], "1", date);
+                        }
+                    }
+
+                    // 表单提交-低-3s完播率
+                    if (formCountThirtyDays != null && play3sRatio != null && Integer.parseInt(formCountThirtyDays) >= 20 && Double.parseDouble(play3sRatio) < 0.157) {
+                        String[] split = tgaMap.get("表单提交-低-3s完播率").split(";");
+                        int count = materialLabelMapper.getDataByCodeAndSignature(obj.getSignature(), split[0]);
+                        //次素材没有打此标签
+                        if (count == 0) {
+                            materialLabelMapper.saveMaterialTag(obj.getSignature(), "表单提交-低-3s完播率", split[0], split[1], "1", date);
+                        }
+                    }
+
+                    // 表单提交-高-3s完播率
+                    if (formCountThirtyDays != null && play3sRatio != null && Integer.parseInt(formCountThirtyDays) >= 20 && Double.parseDouble(play3sRatio) > 0.515) {
+                        String[] split = tgaMap.get("表单提交-高-3s完播率").split(";");
+                        int count = materialLabelMapper.getDataByCodeAndSignature(obj.getSignature(), split[0]);
+                        //次素材没有打此标签
+                        if (count == 0) {
+                            materialLabelMapper.saveMaterialTag(obj.getSignature(), "表单提交-高-3s完播率", split[0], split[1], "1", date);
+                        }
+                    }
+
+                    // 表单提交-低-转化率
+                    if (formCountThirtyDays != null && conversionRatio != null && Integer.parseInt(formCountThirtyDays) >= 20 && Double.parseDouble(conversionRatio) < 0.017) {
+                        String[] split = tgaMap.get("表单提交-低-转化率").split(";");
+                        int count = materialLabelMapper.getDataByCodeAndSignature(obj.getSignature(), split[0]);
+                        //次素材没有打此标签
+                        if (count == 0) {
+                            materialLabelMapper.saveMaterialTag(obj.getSignature(), "表单提交-低-转化率", split[0], split[1], "1", date);
+                        }
+                    }
+
+
+                    // 表单提交-高-转化率
+                    if (formCountThirtyDays != null && conversionRatio != null && Integer.parseInt(formCountThirtyDays) >= 20 && Double.parseDouble(conversionRatio) > 0.159) {
+                        String[] split = tgaMap.get("表单提交-高-转化率").split(";");
+                        int count = materialLabelMapper.getDataByCodeAndSignature(obj.getSignature(), split[0]);
+                        //次素材没有打此标签
+                        if (count == 0) {
+                            materialLabelMapper.saveMaterialTag(obj.getSignature(), "表单提交-高-转化率", split[0], split[1], "1", date);
+                        }
+                    }
+
+                    // 表单提交-低-行为率
+                    if (formCountThirtyDays != null && behaviorRation != null && Integer.parseInt(formCountThirtyDays) >= 20 && Double.parseDouble(behaviorRation) < 0.004) {
+                        String[] split = tgaMap.get("表单提交-低-行为率").split(";");
+                        int count = materialLabelMapper.getDataByCodeAndSignature(obj.getSignature(), split[0]);
+                        //次素材没有打此标签
+                        if (count == 0) {
+                            materialLabelMapper.saveMaterialTag(obj.getSignature(), "表单提交-低-行为率", split[0], split[1], "1", date);
+                        }
+                    }
+
+                    // 表单提交-高-行为率
+                    if (formCountThirtyDays != null && behaviorRation != null && Integer.parseInt(formCountThirtyDays) >= 20 && Double.parseDouble(behaviorRation) > 0.015) {
+                        String[] split = tgaMap.get("表单提交-高-行为率").split(";");
+                        int count = materialLabelMapper.getDataByCodeAndSignature(obj.getSignature(), split[0]);
+                        //次素材没有打此标签
+                        if (count == 0) {
+                            materialLabelMapper.saveMaterialTag(obj.getSignature(), "表单提交-高-行为率", split[0], split[1], "1", date);
+                        }
+                    }
+
+                });
+            }
+            result.success("success");
+        } catch (Exception e) {
+            result.error500("error");
+            log.info("素材规定标签失败:{}", e.toString());
+        }
+        return result;
+
+    }
+    /**
+     * 同步标签到ES
+     *
+     * @param
+     * @return
+     */
+    @Override
+    public Result SynchronousLabel() {
+        Result result = new Result();
+        try {
+            List<MaterialLabelInfo> materialLabelData = materialLabelMapper.getMaterialLabelData(null);
+            if(!materialLabelData.isEmpty()){
+
+            }
+        }catch (Exception e){
+            log.info("同步标签至ES失败:{}",e.toString());
+        }
+        return null;
+    }
+
+
+    /**
+     * 获取指定日期number天之后之前的日期
+     *
+     * @param
+     * @return
+     */
+    public String getDateByNumber(String date, int number) {
+        Calendar calc = Calendar.getInstance();
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+        String AfterDate = null;
+        try {
+            calc.setTime(sdf.parse(date));
+            calc.add(Calendar.DAY_OF_MONTH, number);
+            AfterDate = sdf.format(calc.getTime());
+        } catch (Exception e) {
+            log.info("获取日期失败:{}", e.toString());
+        }
+        return AfterDate;
+    }
+}

+ 0 - 80
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/label/service/impl/MaterialTagServiceImpl.java

@@ -1,80 +0,0 @@
-package cn.com.ctop.kuaishou.modules.label.service.impl;
-
-import cn.com.ctop.kuaishou.modules.label.mapper.MaterialLabelMapper;
-import cn.com.ctop.kuaishou.modules.label.service.MaterialTagService;
-import lombok.extern.slf4j.Slf4j;
-import org.jeecg.common.api.vo.Result;
-import org.springframework.stereotype.Service;
-
-import javax.annotation.Resource;
-import java.text.SimpleDateFormat;
-import java.util.Calendar;
-import java.util.List;
-
-/**
- * @Description: 素材标签
- * @Author: zzy
- * @Date: 2021-07-30
- * @Version: V1.0
- */
-@Service
-@Slf4j
-public class MaterialTagServiceImpl implements MaterialTagService {
-
-
-    @Resource
-    MaterialLabelMapper materialLabelMapper;
-
-
-    /**
-     * 清洗各素材指标入库
-     *
-     * @param
-     * @return
-     */
-    @Override
-    public Result filterMaterial() {
-
-        try {
-            //查询所有素材标签
-            List<String> materiaSignature = materialLabelMapper.getMateriaSignature();
-            if(!materiaSignature.isEmpty()){
-                materiaSignature.stream().forEach(str->{
-                    if(!str.isEmpty()){
-                        //获取素材产生消耗的最早日期
-                        String materialFirstDate = materialLabelMapper.getMaterialFirstDate(str);
-                        //获取30天之后的日期
-                        String afterDate = getDateByNumber(materialFirstDate, -30);
-                        //查询素材各项指标入库
-                        
-                    }
-
-                });
-            }
-        }catch (Exception e){
-
-        }
-
-
-        return null;
-    }
-    /**
-     * 获取指定日期number天之后之前的日期
-     *
-     * @param
-     * @return
-     */
-    public String getDateByNumber(String date,int number){
-        Calendar calc = Calendar.getInstance();
-        SimpleDateFormat sdf  = new SimpleDateFormat("yyyy-MM-dd");
-        String AfterDate=null;
-        try {
-            calc.setTime(sdf.parse(date));
-            calc.add(calc.DATE, number);
-            AfterDate=sdf.format(calc.getTime());
-        }catch (Exception e){
-            log.info("获取日期失败:{}",e.toString());
-        }
-        return AfterDate;
-    }
-}