瀏覽代碼

筛选僵尸创意功能

zhaoxian 4 年之前
父節點
當前提交
37082cf209
共有 16 個文件被更改,包括 431 次插入23 次删除
  1. 3 3
      jeecg-boot-base-common/src/main/java/org/jeecg/common/util/DateUtils.java
  2. 31 17
      jeecg-boot-module-system/src/test/java/org/jeecg/SampleTest.java
  3. 2 0
      module-common/src/main/java/cn/com/ctop/common/module/mapper/UserAllocationMapper.java
  4. 7 0
      module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/UserAllocationMapper.xml
  5. 11 1
      module-common/src/main/java/cn/com/ctop/common/module/service/IMessageTemplate.java
  6. 11 0
      module-common/src/main/java/cn/com/ctop/common/module/service/impl/MessageTemplateImpl.java
  7. 2 1
      module-job-bytedance/src/main/java/cn/com/ctop/job/bytedance/handler/WechatAttendanceJob.java
  8. 28 0
      module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouDailyZombieJob.java
  9. 81 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/entity/KuaishouZombieCreative.java
  10. 2 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/KuaishouReportDailyCreativeMapper.java
  11. 15 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/KuaishouZombieCreativeMapper.java
  12. 11 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/KuaishouReportDailyCreativeMapper.xml
  13. 5 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/KuaishouZombieCreativeMapper.xml
  14. 22 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/IKuaishouZombieCreativeService.java
  15. 199 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/KuaishouZombieCreativeServiceImpl.java
  16. 1 1
      module-oa/src/main/java/cn/com/ctop/oa/modules/service/impl/WechatNoListServiceImpl.java

+ 3 - 3
jeecg-boot-base-common/src/main/java/org/jeecg/common/util/DateUtils.java

@@ -1513,14 +1513,14 @@ public class DateUtils extends PropertyEditorSupport {
     }
 
     /**
-     * 获取前一天的日期
+     * 以time为节点,获取前几天的日期 yyyy-MM-dd
      *
      * @param
      * @return java.lang.String
      * @throws
      * @author ZHAOXA
      */
-    public static String getLastDay(String time) {
+    public static String getLastDay(String time, int days) {
         SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
         Calendar calendar = Calendar.getInstance();
         Date date = null;
@@ -1532,7 +1532,7 @@ public class DateUtils extends PropertyEditorSupport {
         calendar.setTime(date);
         int day = calendar.get(Calendar.DATE);
         //                      此处修改为+1则是获取后一天
-        calendar.set(Calendar.DATE, day - 1);
+        calendar.set(Calendar.DATE, day - days);
 
         String lastDay = sdf.format(calendar.getTime());
         return lastDay;

+ 31 - 17
jeecg-boot-module-system/src/test/java/org/jeecg/SampleTest.java

@@ -7,11 +7,16 @@ import cn.com.ctop.common.module.entity.BindAccountLogin;
 import cn.com.ctop.common.module.entity.CtopOauthToken;
 import cn.com.ctop.common.module.entity.UserAllocation;
 import cn.com.ctop.common.module.message.handle.impl.EmailSendMsgHandle;
-import cn.com.ctop.common.module.service.*;
+import cn.com.ctop.common.module.service.IBindAccountLoginService;
+import cn.com.ctop.common.module.service.ICtopOauthTokenService;
+import cn.com.ctop.common.module.service.IUReportExportService;
+import cn.com.ctop.common.module.service.IUReportService;
+import cn.com.ctop.common.module.service.IUserAllocationService;
 import cn.com.ctop.common.module.utils.CtopAdConstant;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouHistoryReportTaskService;
 import cn.com.ctop.kuaishou.modules.graphql.service.IKuaishouWebInterfaceService;
 import cn.com.ctop.kuaishou.modules.report.service.IKuaishouReportDailyAgentService;
+import cn.com.ctop.kuaishou.modules.report.service.IKuaishouZombieCreativeService;
 import cn.com.ctop.toutiao.modules.material.service.IByteDanceAdvertiserDataService;
 import cn.com.ctop.toutiao.modules.report.service.IByteDanceVideoReportDailyService;
 import cn.com.ctop.toutiao.modules.report.service.IBytedanceReportService;
@@ -173,11 +178,11 @@ public class SampleTest {
     public void loadAccountData() {
 //        List<UserAllocation> allocations = allocationService.getByParams(776L,null,0);
 //        for (UserAllocation allocation:allocations) {
-            CtopOauthToken token = tokenService.getTokenByAccountId(93238965516L);
-            for(int i=92;i<100;i++){
-                Date getDate = DateUtils.addDay(new Date(),-i);
-                reportService.getAdvertiserReport(token, getDate, getDate, CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
-            }
+        CtopOauthToken token = tokenService.getTokenByAccountId(93238965516L);
+        for (int i = 92; i < 100; i++) {
+            Date getDate = DateUtils.addDay(new Date(), -i);
+            reportService.getAdvertiserReport(token, getDate, getDate, CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
+        }
 //        }
     }
 
@@ -189,10 +194,10 @@ public class SampleTest {
     IUReportService uReportService;
 
     @Test
-    public void loadBytedanceData(){
+    public void loadBytedanceData() {
         List<CtopOauthToken> tokens = tokenService.selectToutiaoToken();
-        for (CtopOauthToken token:tokens) {
-            for(int i=0;i<20;i++){
+        for (CtopOauthToken token : tokens) {
+            for (int i = 0; i < 20; i++) {
                 Date getDate = DateUtils.addDay(new Date(), -i);
                 String date = DateUtils.formatDate(getDate);
                 bytedanceReportService.bytedanceMaterialReport(token, date, date);
@@ -202,16 +207,16 @@ public class SampleTest {
     }
 
     @Test
-    public void loaddata(){
+    public void loaddata() {
 //        List<UserAllocation> allocations = allocationService.getByParams(643L,null,0);
 //        for (UserAllocation allocation:allocations) {
-            for(int i=0;i<50;i++){
+        for (int i = 0; i < 50; i++) {
 //                CtopOauthToken token = tokenService.getTokenByAccountId(allocation.getAccountId());
-                Date getDate = DateUtils.addDay(new Date(), -i);
-                String date = DateUtils.formatDate(getDate);
+            Date getDate = DateUtils.addDay(new Date(), -i);
+            String date = DateUtils.formatDate(getDate);
 //                bytedanceReportService.bytedanceMaterialReport(token, date, date);
-                videoReportDailyService.videoInfoList(date, date);
-            }
+            videoReportDailyService.videoInfoList(date, date);
+        }
 
 //        }
     }
@@ -221,9 +226,10 @@ public class SampleTest {
 
     @Autowired
     private IByteDanceVideoReportDailyService videoReportDailyService;
+
     @Test
-    public void loadMatData(){
-        List<UserAllocation> allocations = allocationService.getByParams(320L,null,0);
+    public void loadMatData() {
+        List<UserAllocation> allocations = allocationService.getByParams(320L, null, 0);
         countDownLatch = new CountDownLatch(allocations.size());
         executorService = Executors.newFixedThreadPool(2);
         allocations.forEach(allocation -> {
@@ -249,4 +255,12 @@ public class SampleTest {
         }
         XxlJobLogger.log("物料数据同步完成");
     }
+
+    @Autowired
+    private IKuaishouZombieCreativeService kuaishouZombieCreativeService;
+
+    @Test
+    public void checkZombieProject() {
+        kuaishouZombieCreativeService.checkZombieProject();
+    }
 }

+ 2 - 0
module-common/src/main/java/cn/com/ctop/common/module/mapper/UserAllocationMapper.java

@@ -18,6 +18,8 @@ public interface UserAllocationMapper extends BaseMapper<UserAllocation> {
 
     String queryAdvertiserId(@Param("accountId") Long accountId);
 
+    String queryUserIdByAccountId(@Param("accountId") Long accountId);
+
     List<JSONObject> getAccountListByProject(@Param("projectId") Long projectId);
 
     List<JSONObject> getUserIdListByProjectId(@Param("projectId") Long projectId);

+ 7 - 0
module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/UserAllocationMapper.xml

@@ -21,6 +21,13 @@
             ctop_user_allocation
         where account_id=#{accountId}
     </select>
+    <select id="queryUserIdByAccountId" resultType="String">
+        select
+            distinct user_id
+        from
+            ctop_user_allocation
+        where account_id=#{accountId}
+    </select>
 
     <select id="getAccountListByProject" resultType="com.alibaba.fastjson.JSONObject">
        select

+ 11 - 1
module-common/src/main/java/cn/com/ctop/common/module/service/IMessageTemplate.java

@@ -24,5 +24,15 @@ public interface IMessageTemplate {
 
     String getFeishuMaterialRejectTemplate(String projectName, String materialName, String refuseReason);
 
-    String getCreativeOverRunMessage(Long accountId, Integer creativeCount,String authName);
+    String getCreativeOverRunMessage(Long accountId, Integer creativeCount, String authName);
+
+    /**
+     * 获取僵尸创意提醒模板
+     *
+     * @param
+     * @return java.lang.String
+     * @throws
+     * @author ZHAOXA
+     */
+    String getZombieCreativeRemindTemplate(long accountId, String creativeName);
 }

+ 11 - 0
module-common/src/main/java/cn/com/ctop/common/module/service/impl/MessageTemplateImpl.java

@@ -108,4 +108,15 @@ public class MessageTemplateImpl implements IMessageTemplate {
                 .append("如有疑问,请联系产品:吴永前。");
         return text.toString();
     }
+
+    @Override
+    public String getZombieCreativeRemindTemplate(long accountId, String creativeName) {
+        StringBuilder text = new StringBuilder();
+        text.append("创意超限通知:").append("<br/>")
+                .append("您的快手账户:").append(accountId + ",").append("<br/>")
+                .append("授权名称为:" + creativeName).append("<br/>")
+                .append("创意api创建超限。").append("<br/>")
+                .append("如有疑问,请联系产品:吴永前。");
+        return text.toString();
+    }
 }

+ 2 - 1
module-job-bytedance/src/main/java/cn/com/ctop/job/bytedance/handler/WechatAttendanceJob.java

@@ -4,6 +4,7 @@ package cn.com.ctop.job.bytedance.handler;
 import cn.com.ctop.oa.modules.service.IWechatCheckinDataService;
 import cn.com.ctop.oa.modules.service.IWechatUserListService;
 import com.xxl.job.core.biz.model.ReturnT;
+import com.xxl.job.core.enums.NoEn;
 import com.xxl.job.core.handler.annotation.XxlJob;
 import com.xxl.job.core.log.XxlJobLogger;
 import org.jeecg.common.util.DateUtils;
@@ -30,7 +31,7 @@ public class WechatAttendanceJob {
     @XxlJob("wechatAttendanceJob")
     public ReturnT<String> execute(String params) throws Exception {
         XxlJobLogger.log("--------考勤和人员数据入库 start ");
-        String beforeDay = DateUtils.getLastDay(DateUtils.formatDate(new Date()));
+        String beforeDay = DateUtils.getLastDay(DateUtils.formatDate(new Date()), NoEn.NO1.valueInt());
         long starttime = DateUtils.timeToStamp(beforeDay + " 00:00:00");
         long endtime = DateUtils.timeToStamp(beforeDay + " 23:59:59");
         //更新员工打卡明细表

+ 28 - 0
module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouDailyZombieJob.java

@@ -0,0 +1,28 @@
+package cn.com.ctop.job.kuaishou.handler;
+
+import cn.com.ctop.kuaishou.modules.report.service.IKuaishouZombieCreativeService;
+import com.xxl.job.core.biz.model.ReturnT;
+import com.xxl.job.core.handler.annotation.XxlJob;
+import com.xxl.job.core.log.XxlJobLogger;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+/**
+ * 更新僵尸计划数据
+ *
+ * @author jeecg-boot
+ */
+@Component
+public class KuaishouDailyZombieJob {
+    @Autowired
+    private IKuaishouZombieCreativeService kuaishouZombieCreativeService;
+
+    @XxlJob("kuaishouDailyZombie")
+    public ReturnT<String> execute(String param) throws Exception {
+        XxlJobLogger.log("更新僵尸计划数据 start");
+        kuaishouZombieCreativeService.checkZombieProject();
+        XxlJobLogger.log("更新僵尸计划数据 end");
+        return ReturnT.SUCCESS;
+    }
+
+}

+ 81 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/entity/KuaishouZombieCreative.java

@@ -0,0 +1,81 @@
+package cn.com.ctop.kuaishou.modules.report.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import org.jeecgframework.poi.excel.annotation.Excel;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.util.Date;
+
+/**
+ * 僵尸计划记录
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2020-10-14
+ */
+@Data
+@TableName("ctop_kuaishou_zombie_creative")
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value = "ctop_kuaishou_zombie_creative对象", description = "僵尸计划记录")
+public class KuaishouZombieCreative {
+
+    /**
+     * 编号
+     */
+    @TableId(type = IdType.INPUT)
+    @ApiModelProperty(value = "编号")
+    private Integer id;
+    /**
+     * 账户ID
+     */
+    @Excel(name = "账户ID", width = 15)
+    @ApiModelProperty(value = "账户ID")
+    private Long accountId;
+    /**
+     * 创意ID
+     */
+    @Excel(name = "创意ID", width = 15)
+    @ApiModelProperty(value = "创意ID")
+    private Integer creativeId;
+    /**
+     * 创意名称
+     */
+    @Excel(name = "创意名称", width = 15)
+    @ApiModelProperty(value = "创意名称")
+    private String creativeName;
+    /**
+     * 记录时间
+     */
+    private String recordTime;
+    /**
+     * 创建时间
+     */
+    @Excel(name = "创建时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "创建时间")
+    private Date createTime;
+    /**
+     * 修改时间
+     */
+    @Excel(name = "修改时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "修改时间")
+    private Date updateTime;
+    /**
+     * 状态 0-是僵尸计划,1-无效,不是
+     */
+    @Excel(name = "状态 0-待确认,1-是僵尸计划,2-不是僵尸计划", width = 15)
+    @ApiModelProperty(value = "状态 0-待确认,1-是僵尸计划,2-不是僵尸计划")
+    private String status;
+}

+ 2 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/KuaishouReportDailyCreativeMapper.java

@@ -20,4 +20,6 @@ public interface KuaishouReportDailyCreativeMapper extends BaseMapper<KuaishouRe
     KuaiShouCleanMaterialReport calculationMaterialReport(@Param("signature") String signature);
 
     void loadProgramCreativeDailyReport(@Param("accountId") Long accountId, @Param("localPath") String localPath);
+
+    List<JSONObject> checkZombieProject(@Param("date") String date);
 }

+ 15 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/KuaishouZombieCreativeMapper.java

@@ -0,0 +1,15 @@
+package cn.com.ctop.kuaishou.modules.report.mapper;
+
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouZombieCreative;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * 僵尸计划记录
+ *
+ * @author: jeecg-boot
+ * @date: 2020-10-14
+ * @cersion: V1.0
+ */
+public interface KuaishouZombieCreativeMapper extends BaseMapper<KuaishouZombieCreative> {
+
+}

+ 11 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/KuaishouReportDailyCreativeMapper.xml

@@ -281,4 +281,15 @@
         signature = #{signature}
     </select>
 
+
+    <select id="checkZombieProject" resultType="com.alibaba.fastjson.JSONObject">
+      SELECT * FROM
+        (SELECT
+        count(stat_date) as dates ,sum(charge) as charge, account_id as accountId,
+        creative_id as creativeId,creative_name as creativeName
+        FROM ctop_kuaishou_report_daily_creative
+        where stat_date >= #{date}
+        GROUP BY account_id,creative_id) as t
+    where t.dates = 5 and t.charge = 0
+    </select>
 </mapper>

+ 5 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/KuaishouZombieCreativeMapper.xml

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="cn.com.ctop.kuaishou.modules.report.mapper.KuaishouZombieCreativeMapper">
+
+</mapper>

+ 22 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/IKuaishouZombieCreativeService.java

@@ -0,0 +1,22 @@
+package cn.com.ctop.kuaishou.modules.report.service;
+
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouZombieCreative;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * @Description: 僵尸计划记录
+ * @Author: jeecg-boot
+ * @Date: 2020-10-14
+ * @Version: V1.0
+ */
+public interface IKuaishouZombieCreativeService extends IService<KuaishouZombieCreative> {
+    /**
+     * 统计僵尸计划
+     *
+     * @param
+     * @return void
+     * @throws
+     * @author ZHAOXA
+     */
+    void checkZombieProject();
+}

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

@@ -0,0 +1,199 @@
+package cn.com.ctop.kuaishou.modules.report.service.impl;
+
+import cn.com.ctop.common.module.mapper.UserAllocationMapper;
+import cn.com.ctop.common.module.service.IMessageTemplate;
+import cn.com.ctop.common.module.service.ISendMessageService;
+import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouZombieCreative;
+import cn.com.ctop.kuaishou.modules.report.mapper.KuaishouReportDailyCreativeMapper;
+import cn.com.ctop.kuaishou.modules.report.mapper.KuaishouZombieCreativeMapper;
+import cn.com.ctop.kuaishou.modules.report.service.IKuaishouZombieCreativeService;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.xxl.job.core.enums.NoEn;
+import org.jeecg.common.util.DateUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 僵尸计划记录
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2020-10-14
+ */
+@Service
+public class KuaishouZombieCreativeServiceImpl extends ServiceImpl<KuaishouZombieCreativeMapper, KuaishouZombieCreative> implements IKuaishouZombieCreativeService {
+    @Autowired
+    private KuaishouReportDailyCreativeMapper kuaishouReportDailyCreativeMapper;
+    @Autowired
+    private KuaishouZombieCreativeMapper KuaishouZombieCreativeMapper;
+    @Autowired
+    private ISendMessageService sendMessageService;
+    @Autowired
+    private IMessageTemplate messageTemplate;
+    @Autowired
+    private UserAllocationMapper userAllocationMapper;
+
+    /**
+     * 筛选僵尸计划
+     * 逻辑简述:
+     * 1、以当天时间为节点,往前取五天的数据,若创意消耗(花费)都为0,则获取其数据,并insert为待确认状态的僵尸创意。
+     * 2、获取前一天存储的待确认僵尸计划
+     * 3、步骤二和步骤一的数据作比对筛选,若两组数据都含有该创意时,并且为了保证数据的准确性,还需调用API接口获取当天实时消耗明细,
+     * 若消耗不为0,则表明为真正的僵尸创意,3.1更新其状态;3.2同时关停创意;3.3最后发送“关停通知”消息。
+     * 4、步骤二存在,步骤一不存在说明创意已经活跃,更新其状态为“2”已活跃、反之则是新的待确认僵尸创意,作insert操作
+     * 5、insert操作时,考虑到数据重复的问题,需先查询全部僵尸计划,作筛选比对,已有则更新,否则就新增。
+     * **凡insert数据皆为状态0,待确认僵尸创意,且要发送“提醒通知”。
+     *
+     * @param
+     * @return void
+     * @throws
+     * @author ZHAOXA
+     */
+
+    @Override
+    public void checkZombieProject() {
+        //获取五天前的日期 yyyy-MM-dd
+        String date = DateUtils.getLastDay(DateUtils.formatDate(new Date()), NoEn.NO5.valueInt());
+        //查询五天内花费都为0的数据集
+        List<JSONObject> list = kuaishouReportDailyCreativeMapper.checkZombieProject(date);
+        if (Check.isNull(list)) {
+            return;
+        }
+        //查询数据库中前一天存储的待确认僵尸创意集
+        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);
+        if (!Check.isNull(zombieCreatives)) {
+            List<KuaishouZombieCreative> zombiePlans = new ArrayList<>();
+            List<JSONObject> zombieList = new ArrayList<>();
+            //通过账户和创意ID,筛选出确认的僵尸计划
+            zombieCreatives.forEach(zombie -> {
+                list.forEach(obj -> {
+                    if (zombie.getAccountId() - obj.getInteger("accountId") == 0 && zombie.getCreativeId() - obj.getInteger("creativeId") == 0) {
+                        QueryWrapper<KuaishouZombieCreative> wrapper = new QueryWrapper<>();
+                        wrapper.eq("id", zombie.getId());
+                        zombie.setStatus(NoEn.NO1.valueStr());
+                        //3.1更新状态
+                        KuaishouZombieCreativeMapper.update(zombie, wrapper);
+                        //已确认的僵尸计划集
+                        zombiePlans.add(zombie);
+                        zombieList.add(obj);
+                        //TODO 3.3发送创意关停通知
+                        sendMsg(NoEn.NO1.valueStr(), obj.getLong("accountId"), obj.getString("creativeName"));
+                    }
+                });
+            });
+            //过滤掉已确认的僵尸数据,剩余活跃的计划
+            zombieCreatives.removeAll(zombiePlans);
+            //更新计划状态为已活跃
+            zombieCreatives.forEach(zom -> {
+                QueryWrapper<KuaishouZombieCreative> wrapper = new QueryWrapper<>();
+                wrapper.eq("id", zom.getId());
+                //状态 0-待确认,1-是僵尸计划,2-已活跃,不是僵尸计划
+                zom.setStatus(NoEn.NO2.valueStr());
+                KuaishouZombieCreativeMapper.update(zom, wrapper);
+            });
+            //过滤掉已确认的数据,新增新一批的僵尸计划
+            list.removeAll(zombieList);
+            insertorUpdate(list);
+        } else {
+            insertorUpdate(list);
+        }
+    }
+
+    /**
+     * 筛选僵尸计划数据,新增或更新操作
+     *
+     * @param
+     * @return void
+     * @throws
+     * @author ZHAOXA
+     */
+    private void insertorUpdate(List<JSONObject> list) {
+        //查询库中已有的全部数据
+        List<KuaishouZombieCreative> kuaishouZombieCreatives = KuaishouZombieCreativeMapper.selectList(null);
+        if (!Check.isNull(kuaishouZombieCreatives)) {
+            List<KuaishouZombieCreative> updateList = new ArrayList<>();
+            List<JSONObject> toBeDeleted = new ArrayList<>();
+            //待新增的和库中数据对比筛选,选出相同账户和相同创意的数据
+            list.forEach(obj -> {
+                kuaishouZombieCreatives.forEach(zom -> {
+                    if (zom.getAccountId() - obj.getInteger("accountId") == 0 && zom.getCreativeId() - obj.getInteger("creativeId") == 0) {
+                        updateList.add(zom);
+                        toBeDeleted.add(obj);
+                    }
+                });
+            });
+            //已有的数据作更新操作
+            if (!Check.isNull(updateList)) {
+                updateList.forEach(zom -> {
+                    QueryWrapper<KuaishouZombieCreative> wrapper = new QueryWrapper<>();
+                    wrapper.eq("id", zom.getId());
+                    zom.setStatus(NoEn.NO0.valueStr());
+                    zom.setRecordTime(DateUtils.getNowDate(DateUtils.WEB_FORMAT));
+                    KuaishouZombieCreativeMapper.update(zom, wrapper);
+                });
+            }
+            //去除已有的数据,新的数据作insert
+            list.removeAll(toBeDeleted);
+            insert(list);
+        } else {
+            insert(list);
+        }
+    }
+
+    /**
+     * 新增待确认僵尸数据,并发送消息通知
+     * userAllocation
+     *
+     * @param
+     * @return void
+     * @throws
+     * @author ZHAOXA
+     */
+    private void insert(List<JSONObject> list) {
+        list.forEach(obj -> {
+            KuaishouZombieCreative create = new KuaishouZombieCreative();
+            create.setAccountId(obj.getLong("accountId"));
+            create.setCreativeId(obj.getInteger("creativeId"));
+            create.setCreativeName(obj.getString("creativeName"));
+            create.setRecordTime(DateUtils.getNowDate(DateUtils.WEB_FORMAT));
+            //状态 0-待确认,1-是僵尸计划,2-已活跃,不是僵尸计划
+            create.setStatus(NoEn.NO0.valueStr());
+            KuaishouZombieCreativeMapper.insert(create);
+            //TODO 发送待确认通知
+            sendMsg(NoEn.NO1.valueStr(), obj.getLong("accountId"), obj.getString("creativeName"));
+        });
+    }
+
+    /**
+     * 发送消息通知
+     *
+     * @param
+     * @return void
+     * @throws
+     * @author ZHAOXA
+     */
+    private void sendMsg(String type, long accountId, String creativeName) {
+        String userId = userAllocationMapper.queryUserIdByAccountId(accountId);
+        String message = "";
+        if (NoEn.NO1.valueStr().equals(type)) {
+            //提醒通知
+            message = messageTemplate.getZombieCreativeRemindTemplate(accountId, creativeName);
+        } else {
+            //关停通知
+            message = messageTemplate.getZombieCreativeRemindTemplate(accountId, creativeName);
+        }
+        sendMessageService.sendMessage(userId, message);
+    }
+}

+ 1 - 1
module-oa/src/main/java/cn/com/ctop/oa/modules/service/impl/WechatNoListServiceImpl.java

@@ -356,7 +356,7 @@ public class WechatNoListServiceImpl extends ServiceImpl<WechatNoListMapper, Wec
                 Integer dur = Integer.valueOf(attendance.getStateDuration().replace(" min", ""));
                 if (dur - 60 >= 0) {
                     String checkinDate = attendance.getCheckinDate();
-                    String lastDay = DateUtils.getLastDay(checkinDate);
+                    String lastDay = DateUtils.getLastDay(checkinDate, NoEn.NO1.valueInt());
                     Map<String, Object> map = new HashMap<>();
                     map.put("userId", attendance.getUserId());
                     map.put("checkinDate", lastDay);