Prechádzať zdrojové kódy

监测链接预警发送消息

yangzian 3 rokov pred
rodič
commit
8cbeda3ab3

+ 2 - 1
jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/advertise/mapper/xml/MonitorBytedanceActionTrackUrlMapper.xml

@@ -36,8 +36,9 @@
         FROM
             ctop_bytedance_advertise_plan
         WHERE action_track_url is NOT NULL
+            and opt_status = 'AD_STATUS_ENABLE'
             and account_id = #{accountId}
-          and DATE_FORMAT(create_time,'%Y-%m-%d') = DATE_FORMAT(NOW(),'%Y-%m-%d')
+          and DATE_FORMAT(start_time,'%Y-%m-%d') = DATE_FORMAT(NOW(),'%Y-%m-%d')
     </select>
 
 

+ 12 - 6
jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/advertise/service/impl/MonitorBytedanceServiceImpl.java

@@ -20,6 +20,7 @@ import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
 import java.text.MessageFormat;
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
 import java.util.Set;
@@ -149,6 +150,7 @@ public class MonitorBytedanceServiceImpl implements IMonitorBytedanceService {
         //查询 配置的点击监测链接
         List<MonitorBytedanceAdVo> accountList = monitorBytedanceActionTrackUrlMapper.getAccountActionTrackUrl(accountId,"1",null);
         for (MonitorBytedanceAdVo accountInfo : accountList) {
+            /*
             //1:校验 账户自动投放配置中 监测链接
             //查询账户配置中的 转化id
             List<MonitorBytedanceAdVo> converId = monitorBytedanceActionTrackUrlMapper.getBytedancStrategyAcctionId(accountInfo.getAccountId());
@@ -165,13 +167,15 @@ public class MonitorBytedanceServiceImpl implements IMonitorBytedanceService {
                     //发送预警消息
                     sendEnterpriseWeiXinMessage(accountInfo);
                     log.info("accountId:=={}==目标转化id:{}=====第三方点击监测链接与自动投放配置不一致,已发送企业微信通知============",accountInfo.getAccountId(),converId.get(0).getConvertId());
+                    continue;
                 }
             }
-
+*/
             //2:校验 拉取后台计划 监测链接
             //根据账户 查询头条计划中的 点击监测链接
             List<MonitorBytedanceAdVo> actionTrackUrlList = monitorBytedanceActionTrackUrlMapper.getBytedancPlanActionTrackUrl(Long.valueOf(accountInfo.getAccountId()));
             if (!Check.isNull(actionTrackUrlList)){
+                List<String> planList = new ArrayList<>();
                 for (MonitorBytedanceAdVo actiontrackUrl : actionTrackUrlList) {
                     //配置中的 点击监测链接 != 创建计划中的 点击监测链接
                     if (!StringUtils.equals(accountInfo.getActionTrackUrl(),actiontrackUrl.getActionTrackUrl())){
@@ -179,11 +183,13 @@ public class MonitorBytedanceServiceImpl implements IMonitorBytedanceService {
                         CtopOauthToken token = tokenService.getTokenByAccountId(Long.valueOf(accountInfo.getAccountId()));
                         marketingServiceImpl.updPlanStatus(token, Arrays.asList(Long.valueOf(actiontrackUrl.getPlanId())),"disable");
                         log.info("accountId:=={}==计划id:{}=====第三方点击监测链接不一致,计划已【关停】============",accountInfo.getAccountId(),actiontrackUrl.getPlanId());
-                        //发送预警消息
-                        sendEnterpriseWeiXinMessage(accountInfo);
-                        log.info("accountId:=={}==计划id:{}=====第三方点击监测链接不一致,已发送企业微信通知============",accountInfo.getAccountId(),actiontrackUrl.getPlanId());
+                        planList.add(actiontrackUrl.getPlanId());
                     }
                 }
+                //发送预警消息
+                accountInfo.setPlanIdList(planList);
+                sendEnterpriseWeiXinMessage(accountInfo);
+                log.info("accountId:=={}==计划id:{}=====第三方点击监测链接不一致,已发送企业微信通知============",accountInfo.getAccountId(),accountInfo.getPlanIdList());
             }
             log.info("accountId:=={}====已创建的计划暂时没有第三方点击监测链接============",accountInfo.getAccountId());
         }
@@ -195,10 +201,10 @@ public class MonitorBytedanceServiceImpl implements IMonitorBytedanceService {
      * 发送 点击监测链接 预警消息
      */
     public void sendEnterpriseWeiXinMessage(MonitorBytedanceAdVo accountInfo){
-        String message =  "{0},您好!您所运营的账户:{1},点击监测链接配置有差异,已关停请及时修改!";
+        String message =  "{0},您好!您所运营的账户:{1},其中的广告计划id:{2},监测链接设置有误,已关停请及时修改!";
         //发送微信通知
         JSONObject jsonObject =  monitorBytedanceActionTrackUrlMapper.getWChatIdByUserId("80e747cdea6f41dbbc8cde23046fd4e0");
-        String msg = MessageFormat.format(message,accountInfo.getOperateUserName(),String.valueOf(accountInfo.getAccountId()));
+        String msg = MessageFormat.format(message,accountInfo.getOperateUserName(),String.valueOf(accountInfo.getAccountId()),String.join(",",accountInfo.getPlanIdList()));
         corpWexinUtils.sendMessageByWeChatId(jsonObject,msg);
     }
 

+ 2 - 0
jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/advertise/vo/MonitorBytedanceAdVo.java

@@ -3,6 +3,7 @@ package org.jeecg.modules.bytedance.advertise.vo;
 import lombok.Data;
 
 import java.io.Serializable;
+import java.util.List;
 
 /**
  * @author zianY
@@ -30,4 +31,5 @@ public class MonitorBytedanceAdVo implements Serializable {
 
     //计划id
     private String planId;
+    private List<String> planIdList;
 }