소스 검색

修复问题

xueyiming 6 달 전
부모
커밋
6124f2abeb
26개의 변경된 파일600개의 추가작업 그리고 409개의 파일을 삭제
  1. 3 0
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/common/constant/MessageConstant.java
  2. 3 0
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/common/constant/RedisConstant.java
  3. 1 1
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/common/constant/WeComConstant.java
  4. 6 8
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/controller/MessageController.java
  5. 3 1
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/controller/WeComController.java
  6. 1 1
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/job/WeComHistoryDataJob.java
  7. 20 6
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/job/WeComHistoryDataJob1.java
  8. 6 5
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/job/WeComMessageDataJob.java
  9. 111 83
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/job/WeComMessageDataJob1.java
  10. 9 0
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/job/WeComStaffDataJob.java
  11. 2 1
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/job/WeComUserDataJob.java
  12. 14 0
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/model/bo/VideoParam.java
  13. 11 0
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/model/po/HistoryMessage.java
  14. 60 0
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/model/po/HistoryMessageExample.java
  15. 14 0
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/model/vo/GuaranteedParam.java
  16. 1 1
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/model/vo/MessageTextParam.java
  17. 25 9
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/service/Impl/MessageAttachmentServiceImpl.java
  18. 6 6
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/service/Impl/MessageServiceImpl.java
  19. 4 2
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/service/MessageAttachmentService.java
  20. 2 2
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/service/MessageService.java
  21. 7 0
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/utils/DateUtil.java
  22. 5 6
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/utils/LarkRobotUtil.java
  23. 280 270
      we-com-server/src/main/resources/mapper/HistoryMessageMapper.xml
  24. 2 2
      we-com-server/src/main/resources/mapper/StaffMapper.xml
  25. 2 3
      we-com-server/src/main/resources/mapper/StaffWithUserMapper.xml
  26. 2 2
      we-com-server/src/main/resources/mybatis-generator-config.xml

+ 3 - 0
we-com-server/src/main/java/com/tzld/piaoquan/wecom/common/constant/MessageConstant.java

@@ -13,5 +13,8 @@ public interface MessageConstant {
 
     String defaultName = "日常push-%s-%s";
 
+    //发送视频数量
+    int MAX_VIDEO_NUM = 3;
+
 
 }

+ 3 - 0
we-com-server/src/main/java/com/tzld/piaoquan/wecom/common/constant/RedisConstant.java

@@ -9,4 +9,7 @@ public interface RedisConstant {
 
     //小程序保底视频列表key
     String GUARANTEED_MINIPROGRAM_KEY = "guaranteed_miniprogram_list";
+
+    //小程序保底视频key
+    String GUARANTEED_MINI_PROGRAM_KEY = "guaranteed_mini_program_%s";
 }

+ 1 - 1
we-com-server/src/main/java/com/tzld/piaoquan/wecom/common/constant/WeComConstant.java

@@ -42,7 +42,7 @@ public interface WeComConstant {
     //获取客户列表
     String GET_WE_COM_EXTERNAL_CONTACT_LIST = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/list";
 
-    //获取客户详情
+    //获取客户详情
     String GET_WE_COM_EXTERNAL_CONTACT_GET = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/get";
 
     //external_userid转换

+ 6 - 8
we-com-server/src/main/java/com/tzld/piaoquan/wecom/controller/MessageController.java

@@ -2,14 +2,13 @@ package com.tzld.piaoquan.wecom.controller;
 
 
 import com.tzld.piaoquan.wecom.common.base.CommonResponse;
-import com.tzld.piaoquan.wecom.model.vo.MessageTextVo;
+import com.tzld.piaoquan.wecom.model.vo.GuaranteedParam;
+import com.tzld.piaoquan.wecom.model.vo.MessageTextParam;
 import com.tzld.piaoquan.wecom.service.MessageAttachmentService;
 import com.tzld.piaoquan.wecom.service.MessageService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
-import java.util.List;
-
 @RestController
 @RequestMapping("/wecom/message")
 public class MessageController {
@@ -22,15 +21,14 @@ public class MessageController {
 
     //创建保底小程序
     @PostMapping("/miniprogram/guaranteed/create")
-    public CommonResponse<Void> createGuaranteedMiniprogram(@RequestBody List<Long> videoIds){
-        messageAttachmentService.createGuaranteedMiniprogram(videoIds);
-        return CommonResponse.success();
+    public CommonResponse<Void> createGuaranteedMiniProgram(@RequestBody GuaranteedParam guaranteedParam){
+        return messageAttachmentService.createGuaranteedMiniProgram(guaranteedParam);
     }
 
     //创建新text 有时限和无时限  新创建覆盖原text 未创建取默认保底
     @PostMapping("/text/create")
-    public CommonResponse<Void> createMessageText(@RequestBody MessageTextVo messageTextVo){
-        messageService.createMessageText(messageTextVo);
+    public CommonResponse<Void> createMessageText(@RequestBody MessageTextParam messageTextParam){
+        messageService.createMessageText(messageTextParam);
         return CommonResponse.success();
     }
 

+ 3 - 1
we-com-server/src/main/java/com/tzld/piaoquan/wecom/controller/WeComController.java

@@ -40,7 +40,9 @@ public class WeComController {
             // 如果是刷新,需返回原echostr
             String echoStr = request.getParameter("echostr");
             // 微信加密签名
-            WXBizMsgCrypt wxcpt = new WXBizMsgCrypt(WeComServerConstant.TOKEN, WeComServerConstant.ENCODING_AES_KEY, WeComServerConstant.CORP_ID);
+            WXBizMsgCrypt wxcpt = new WXBizMsgCrypt(WeComServerConstant.TOKEN,
+                    WeComServerConstant.ENCODING_AES_KEY,
+                    WeComServerConstant.CORP_ID);
 
             String sEchoStr = ""; //需要返回的明文
             PrintWriter out;

+ 1 - 1
we-com-server/src/main/java/com/tzld/piaoquan/wecom/job/WeComHistoryDataJob.java

@@ -139,7 +139,7 @@ public class WeComHistoryDataJob {
                         allExternalUserList.addAll(externalUserList);
                     }
                     insertHistoryMessageList(allExternalUserList, miniprogramRecordList, sendAt);
-                    messageAttachmentService.addMiniprogram(messageAttachmentList);
+                    messageAttachmentService.addMiniProgram(messageAttachmentList);
                 }
             }
         } catch (IOException e) {

+ 20 - 6
we-com-server/src/main/java/com/tzld/piaoquan/wecom/job/WeComHistoryDataJob1.java

@@ -88,6 +88,7 @@ public class WeComHistoryDataJob1 {
     }
 
     public void selectGroupMsgList(Long startTime, Long endTime) {
+        delHistoryMessageList(startTime, endTime);
         try {
             String cursor = "";
             do {
@@ -95,6 +96,7 @@ public class WeComHistoryDataJob1 {
                 JSONObject jsonObject = JSONObject.parseObject(res);
                 Integer errCode = jsonObject.getInteger("errcode");
                 if (errCode != 0) {
+                    LarkRobotUtil.sendMessage("selectGroupMsgList error startTime = " + startTime + "endTime = " + endTime);
                     log.error("selectGroupMsgList error startTime={}, endTime={}", startTime, endTime);
                     return;
                 }
@@ -106,17 +108,17 @@ public class WeComHistoryDataJob1 {
                     JSONObject groupMsg = groupMsgList.getJSONObject(i);
                     JSONArray attachments = groupMsg.getJSONArray("attachments");
                     String msgId = groupMsg.getString("msgid");
+                    Long createTime = groupMsg.getLong("create_time");
                     if (CollectionUtils.isEmpty(attachments)) {
                         continue;
                     }
                     List<MiniprogramRecord> miniprogramRecordList = new ArrayList<>();
                     List<MessageAttachment> messageAttachmentList = new ArrayList<>();
                     for (int j = 0; j < attachments.size(); j++) {
-                        JSONObject attachment = attachments.getJSONObject(j);
-                        if (attachment == null) {
+                        JSONObject miniprogram = attachments.getJSONObject(j).getJSONObject("miniprogram");
+                        if (miniprogram == null) {
                             continue;
                         }
-                        JSONObject miniprogram = attachment.getJSONObject("miniprogram");
                         MiniprogramRecord miniprogramRecord = new MiniprogramRecord();
                         MessageAttachment messageAttachment = new MessageAttachment();
                         String title = miniprogram.getString("title");
@@ -144,14 +146,15 @@ public class WeComHistoryDataJob1 {
                         example.createCriteria().andCarrierIdEqualTo(userId);
                         List<Staff> staffList = staffMapper.selectByExample(example);
                         if (CollectionUtils.isEmpty(staffList)) {
+                            LarkRobotUtil.sendMessage("企微推送报警:userId不存在请检查 " + userId);
                             continue;
                         }
                         List<ExternalUser> externalUsers = selectGroupMsgSendResult(msgId, userId);
                         if (CollectionUtils.isEmpty(externalUsers)) {
                             continue;
                         }
-                        insertHistoryMessageList(staffList.get(0), externalUsers, miniprogramRecordList);
-                        messageAttachmentService.addMiniprogram(messageAttachmentList);
+                        insertHistoryMessageList(staffList.get(0), externalUsers, miniprogramRecordList, createTime);
+                        messageAttachmentService.addMiniProgram(messageAttachmentList);
                     }
                 }
                 String nextCursor = jsonObject.getString("next_cursor");
@@ -161,6 +164,7 @@ public class WeComHistoryDataJob1 {
                 cursor = nextCursor;
             } while (StringUtils.isNotEmpty(cursor));
         } catch (IOException e) {
+            LarkRobotUtil.sendMessage("selectGroupMsgList error" + e);
             log.error("selectGroupMsgList error", e);
         }
     }
@@ -251,8 +255,17 @@ public class WeComHistoryDataJob1 {
         return httpPoolClientDefault.post(url, param.toJSONString());
     }
 
+    private void delHistoryMessageList(Long startTime, Long endTime) {
+        HistoryMessage historyMessage = new HistoryMessage();
+        historyMessage.setIsDelete(1);
+        HistoryMessageExample example = new HistoryMessageExample();
+        example.createCriteria().andCreateTimeBetween(new Date(startTime * 1000), new Date(endTime * 1000));
+        historyMessageMapper.updateByExample(historyMessage, example);
 
-    private void insertHistoryMessageList(Staff staff, List<ExternalUser> externalUsers, List<MiniprogramRecord> miniprogramRecordList) {
+    }
+
+
+    private void insertHistoryMessageList(Staff staff, List<ExternalUser> externalUsers, List<MiniprogramRecord> miniprogramRecordList, Long createTime) {
         if (CollectionUtils.isEmpty(externalUsers) || CollectionUtils.isEmpty(miniprogramRecordList)) {
             return;
         }
@@ -273,6 +286,7 @@ public class WeComHistoryDataJob1 {
                 historyMessage.setUserId(userId);
                 historyMessage.setStaffId(staff.getId());
                 historyMessage.setStatus(status);
+                historyMessage.setCreateTime(new Date(createTime * 1000));
                 historyMessageList.add(historyMessage);
                 if (status == 2) {
                     StaffWithUserExample example = new StaffWithUserExample();

+ 6 - 5
we-com-server/src/main/java/com/tzld/piaoquan/wecom/job/WeComMessageDataJob.java

@@ -83,7 +83,8 @@ public class WeComMessageDataJob {
     //初始化操作
     void init() {
         //历史优质视频获取
-        String sql = String.format("SELECT * FROM loghubods.history_good_video_can_push_user_list where dt = %s;", DateUtil.getBeforeDayDateString());
+        String sql = String.format("SELECT * FROM loghubods.history_good_video_can_push_user_list where dt = %s;",
+                DateUtil.getBeforeDayDateString());
         List<Record> recordList = OdpsUtil.getOdpsData(sql);
         if (CollectionUtils.isEmpty(recordList)) {
             return;
@@ -153,15 +154,15 @@ public class WeComMessageDataJob {
                 continue;
             }
             //落库逻辑
-            List<SendMessage> allSeneMessageList = new ArrayList<>();
+            List<SendMessage> allSendMessageList = new ArrayList<>();
             for (User user : userList) {
                 List<SendMessage> sendMessageList = getSendMessage(user, staffId);
                 if (!CollectionUtils.isEmpty(sendMessageList)) {
-                    allSeneMessageList.addAll(sendMessageList);
+                    allSendMessageList.addAll(sendMessageList);
                 }
             }
-            if (!CollectionUtils.isEmpty(allSeneMessageList)) {
-                sendMessageMapper.insertList(allSeneMessageList);
+            if (!CollectionUtils.isEmpty(allSendMessageList)) {
+                sendMessageMapper.insertList(allSendMessageList);
             }
         }
         //组装好当天要发送的消息后  记录时间  删除保底数据

+ 111 - 83
we-com-server/src/main/java/com/tzld/piaoquan/wecom/job/WeComMessageDataJob1.java

@@ -5,10 +5,13 @@ import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.aliyun.odps.data.Record;
 import com.google.common.collect.Lists;
+import com.tzld.piaoquan.wecom.common.base.CommonResponse;
 import com.tzld.piaoquan.wecom.dao.mapper.*;
 import com.tzld.piaoquan.wecom.model.bo.PushMessage;
+import com.tzld.piaoquan.wecom.model.bo.VideoParam;
 import com.tzld.piaoquan.wecom.model.bo.XxlJobParam;
 import com.tzld.piaoquan.wecom.model.po.*;
+import com.tzld.piaoquan.wecom.model.vo.GuaranteedParam;
 import com.tzld.piaoquan.wecom.service.MessageAttachmentService;
 import com.tzld.piaoquan.wecom.service.MessageService;
 import com.tzld.piaoquan.wecom.utils.*;
@@ -27,7 +30,9 @@ import java.nio.charset.StandardCharsets;
 import java.util.*;
 import java.util.stream.Collectors;
 
+import static com.tzld.piaoquan.wecom.common.constant.MessageConstant.MAX_VIDEO_NUM;
 import static com.tzld.piaoquan.wecom.common.constant.RedisConstant.GUARANTEED_MINIPROGRAM_KEY;
+import static com.tzld.piaoquan.wecom.common.constant.RedisConstant.GUARANTEED_MINI_PROGRAM_KEY;
 import static com.tzld.piaoquan.wecom.common.constant.TimeConstant.MILLISECOND_DAY;
 
 @Log4j2
@@ -58,7 +63,6 @@ public class WeComMessageDataJob1 {
     @Autowired
     SendMessageMapper sendMessageMapper;
 
-    private static final int MAX_VIDEO_NUM = 3;
 
     //发送小程序标题限制字节数
     private static final int MAX_BYTES = 64;
@@ -67,17 +71,14 @@ public class WeComMessageDataJob1 {
     List<PushMessage> goodHistoryPushList = new ArrayList<>();
 
     //保底视频列表
-    List<Long> guaranteedVideoIdList = new ArrayList<>();
-
-    //从缓存中获取的保底视频数量
-    int getGuaranteedVideoIdNum = 0;
-
+    Map<String, List<Long>> guaranteedVideoMap = new HashMap<>();
     Map<String, String> pageMap = new HashMap<>();
 
     //初始化操作
     void init() {
         //历史优质视频获取
-        String sql = String.format("SELECT * FROM loghubods.history_good_video_can_push_user_list where dt = %s;", DateUtil.getBeforeDayDateString());
+        String sql = String.format("SELECT * FROM loghubods.history_good_video_can_push_user_list where dt = %s;",
+                DateUtil.getBeforeDayDateString());
         List<Record> recordList = OdpsUtil.getOdpsData(sql);
         if (CollectionUtils.isEmpty(recordList)) {
             return;
@@ -93,38 +94,48 @@ public class WeComMessageDataJob1 {
         }
         goodHistoryPushList = list;
 
-        getGuaranteedVideoIdNum = 0;
         //保底视频获取
-        List<Long> videoIdList = Objects.requireNonNull(redisTemplate.opsForList().range(GUARANTEED_MINIPROGRAM_KEY, 0, -1))
-                .stream().map(o -> (Integer) o).map(String::valueOf).map(Long::parseLong).collect(Collectors.toList());
-        if (CollectionUtils.isEmpty(videoIdList)) {
-            log.error("推送消息初始化失败,保底数据为空");
-            throw new RuntimeException("保底数据为空");
+
+        String key = String.format(GUARANTEED_MINI_PROGRAM_KEY, DateUtil.getThatDayDateString());
+        String value = (String) redisTemplate.opsForValue().get(key);
+        GuaranteedParam guaranteedParam = JSONObject.parseObject(value, GuaranteedParam.class);
+        if (guaranteedParam == null
+                || CollectionUtils.isEmpty(guaranteedParam.getVideoParamList())) {
+            LarkRobotUtil.sendMessage("保底视频获取异常,请检查" + DateUtil.getThatDayDateString());
+            throw new RuntimeException();
         }
-        List<Long> saveVideoIds = new ArrayList<>();
-        for (Long videoId : videoIdList) {
-            getGuaranteedVideoIdNum++;
-            MessageAttachmentExample example = new MessageAttachmentExample();
-            example.createCriteria().andMiniprogramVideoIdEqualTo(videoId);
-            List<MessageAttachment> messageAttachmentList = messageAttachmentMapper.selectByExample(example);
-            if (CollectionUtils.isEmpty(messageAttachmentList)) {
-                continue;
+        Map<String, List<Long>> videoMap = new HashMap<>();
+        for (VideoParam videoParam : guaranteedParam.getVideoParamList()) {
+            if (StringUtils.isEmpty(videoParam.getCarrierId())) {
+                LarkRobotUtil.sendMessage("保底视频获取异常,CarrierId为空" + DateUtil.getThatDayDateString());
+                throw new RuntimeException();
             }
-            MessageAttachment messageAttachment = messageAttachmentList.get(0);
-            if (messageAttachment.getSendTime() != null
-                    && DateUtil.dateDifference(new Date(), messageAttachment.getSendTime()) < 180 * MILLISECOND_DAY) {
-                continue;
+            if (CollectionUtils.isEmpty(videoParam.getVideoIds()) || videoParam.getVideoIds().size() < MAX_VIDEO_NUM) {
+                LarkRobotUtil.sendMessage("保底视频数量异常,请查看" + guaranteedParam.getDate() + videoParam.getCarrierId());
+                throw new RuntimeException();
             }
-            saveVideoIds.add(videoId);
-            if (saveVideoIds.size() >= MAX_VIDEO_NUM) {
-                break;
+            for (Long videoId : videoParam.getVideoIds()) {
+                MessageAttachmentExample example = new MessageAttachmentExample();
+                example.createCriteria().andMiniprogramVideoIdEqualTo(videoId);
+                List<MessageAttachment> messageAttachmentList = messageAttachmentMapper.selectByExample(example);
+                if (CollectionUtils.isEmpty(messageAttachmentList)) {
+                    LarkRobotUtil.sendMessage("保底视频不存在,请查看videoId=" + videoId);
+                    throw new RuntimeException();
+                }
+                MessageAttachment messageAttachment = messageAttachmentList.get(0);
+                if (messageAttachment.getSendTime() != null
+                        && DateUtil.dateDifference(new Date(), messageAttachment.getSendTime()) < 180 * MILLISECOND_DAY) {
+                    LarkRobotUtil.sendMessage("保底视频半年内已发送,请查看videoId=" + videoId);
+                    throw new RuntimeException();
+                }
             }
+            videoMap.put(videoParam.getCarrierId(), videoParam.getVideoIds());
         }
-        if (saveVideoIds.size() < MAX_VIDEO_NUM) {
-            log.error("推送消息初始化失败,保底数据不足");
-            throw new RuntimeException("保底数据不足");
+        if (!videoMap.containsKey("default")) {
+            LarkRobotUtil.sendMessage("保底视频没有默认组,请查看" + guaranteedParam.getDate());
+            throw new RuntimeException();
         }
-        guaranteedVideoIdList = saveVideoIds;
+        this.guaranteedVideoMap = videoMap;
     }
 
     @XxlJob("assembleSendMessageJob1")
@@ -165,11 +176,25 @@ public class WeComMessageDataJob1 {
             }
         }
         //组装好当天要发送的消息后  记录时间  删除保底数据
-        saveGuaranteedVideoIdList(guaranteedVideoIdList);
+        saveGuaranteedVideoIdList();
         return ReturnT.SUCCESS;
     }
 
-    public void saveGuaranteedVideoIdList(List<Long> videoIdList) {
+    public void saveGuaranteedVideoIdList() {
+        String key = String.format(GUARANTEED_MINI_PROGRAM_KEY, DateUtil.getThatDayDateString());
+        String value = (String) redisTemplate.opsForValue().get(key);
+        GuaranteedParam guaranteedParam = JSONObject.parseObject(value, GuaranteedParam.class);
+        if (guaranteedParam == null || CollectionUtils.isEmpty(guaranteedParam.getVideoParamList())) {
+            return;
+        }
+        List<Long> videoIdList = new ArrayList<>();
+        for (VideoParam videoParam : guaranteedParam.getVideoParamList()) {
+            if (CollectionUtils.isEmpty(videoParam.getVideoIds())) {
+                continue;
+            }
+            videoIdList.addAll(videoParam.getVideoIds());
+        }
+
         MessageAttachmentExample example = new MessageAttachmentExample();
         example.createCriteria().andMiniprogramVideoIdIn(videoIdList);
         List<MessageAttachment> messageAttachmentList = messageAttachmentMapper.selectByExample(example);
@@ -179,11 +204,7 @@ public class WeComMessageDataJob1 {
             updateMessageAttachment.setSendTime(new Date());
             messageAttachmentMapper.updateByPrimaryKeySelective(updateMessageAttachment);
         }
-        log.info("getGuaranteedVideoIdNum={}", getGuaranteedVideoIdNum);
-        //移除从redis中获取的保底数据
-        for (int i = 0; i < getGuaranteedVideoIdNum; i++) {
-            redisTemplate.opsForList().leftPop(GUARANTEED_MINIPROGRAM_KEY);
-        }
+        redisTemplate.delete(key);
     }
 
     public List<SendMessage> getSendMessage(User user, Long staffId) {
@@ -192,60 +213,67 @@ public class WeComMessageDataJob1 {
         criteria.andUserIdEqualTo(user.getId());
         criteria.andIsDeleteEqualTo(0);
         if (staffId != null) {
-            criteria.andUserIdEqualTo(staffId);
+            criteria.andStaffIdEqualTo(staffId);
         }
         List<StaffWithUser> staffWithUserList = staffWithUserMapper.selectByExample(example);
         if (CollectionUtils.isEmpty(staffWithUserList)) {
             return null;
         }
         int n = 0;
-        SendMessage sendMessage = new SendMessage();
-        for (PushMessage pushMessage : goodHistoryPushList) {
-            if (pushMessage.getUserIds().contains(user.getId())) {
-                if (n == 0) {
-                    sendMessage.setVideoId1(pushMessage.getVideoId());
-                }
-                if (n == 1) {
-                    sendMessage.setVideoId2(pushMessage.getVideoId());
-                }
-                if (n == 2) {
-                    sendMessage.setVideoId3(pushMessage.getVideoId());
-                }
-                n++;
-                if (n >= MAX_VIDEO_NUM) {
-                    break;
+
+        List<SendMessage> sendMessageList = new ArrayList<>();
+        for (StaffWithUser staffWithUser : staffWithUserList) {
+            SendMessage sendMessage = new SendMessage();
+            for (PushMessage pushMessage : goodHistoryPushList) {
+                if (pushMessage.getUserIds().contains(user.getId())) {
+                    if (n == 0) {
+                        sendMessage.setVideoId1(pushMessage.getVideoId());
+                    }
+                    if (n == 1) {
+                        sendMessage.setVideoId2(pushMessage.getVideoId());
+                    }
+                    if (n == 2) {
+                        sendMessage.setVideoId3(pushMessage.getVideoId());
+                    }
+                    n++;
+                    if (n >= MAX_VIDEO_NUM) {
+                        break;
+                    }
                 }
             }
-        }
-        //保底数据
-        if (n < MAX_VIDEO_NUM) {
-            for (Long videoId : guaranteedVideoIdList) {
-                if (n == 0) {
-                    sendMessage.setVideoId1(videoId);
-                }
-                if (n == 1) {
-                    sendMessage.setVideoId2(videoId);
-                }
-                if (n == 2) {
-                    sendMessage.setVideoId3(videoId);
-                }
-                n++;
-                if (n >= MAX_VIDEO_NUM) {
-                    break;
+            //保底数据
+            List<Long> guaranteedVideoIdList = guaranteedVideoMap.get(String.valueOf(staffWithUser.getStaffId()));
+            if (CollectionUtils.isEmpty(guaranteedVideoIdList)) {
+                guaranteedVideoIdList = guaranteedVideoMap.get("default");
+            }
+            if (CollectionUtils.isEmpty(guaranteedVideoIdList)) {
+                LarkRobotUtil.sendMessage("组装数据时,保底数据获取异常");
+                throw new RuntimeException();
+            }
+            if (n < MAX_VIDEO_NUM) {
+                for (Long videoId : guaranteedVideoIdList) {
+                    if (n == 0) {
+                        sendMessage.setVideoId1(videoId);
+                    }
+                    if (n == 1) {
+                        sendMessage.setVideoId2(videoId);
+                    }
+                    if (n == 2) {
+                        sendMessage.setVideoId3(videoId);
+                    }
+                    n++;
+                    if (n >= MAX_VIDEO_NUM) {
+                        break;
+                    }
                 }
             }
-        }
-        if (n < MAX_VIDEO_NUM) {
-            log.error("组装数据失败 user={}", user);
-            return null;
-        }
-        List<SendMessage> sendMessageList = new ArrayList<>();
-        for (StaffWithUser staffWithUser : staffWithUserList) {
-            SendMessage newSendMessage = new SendMessage();
-            BeanUtils.copyProperties(sendMessage, newSendMessage);
-            newSendMessage.setStaffId(staffWithUser.getStaffId());
-            newSendMessage.setUserId(staffWithUser.getUserId());
-            sendMessageList.add(newSendMessage);
+            if (n < MAX_VIDEO_NUM) {
+                LarkRobotUtil.sendMessage("组装数据失败 user=" + user);
+                throw new RuntimeException();
+            }
+            sendMessage.setStaffId(staffWithUser.getStaffId());
+            sendMessage.setUserId(staffWithUser.getUserId());
+            sendMessageList.add(sendMessage);
         }
         return sendMessageList;
     }

+ 9 - 0
we-com-server/src/main/java/com/tzld/piaoquan/wecom/job/WeComStaffDataJob.java

@@ -0,0 +1,9 @@
+package com.tzld.piaoquan.wecom.job;
+
+import org.springframework.stereotype.Component;
+
+@Component
+public class WeComStaffDataJob {
+
+    
+}

+ 2 - 1
we-com-server/src/main/java/com/tzld/piaoquan/wecom/job/WeComUserDataJob.java

@@ -188,7 +188,8 @@ public class WeComUserDataJob {
             int sum = 0;
             for (int i = 0; i < page; i++) {
                 String res = getUpdateUser(size, i * size, startTime, endTime, staff.getStaffExtId());
-                log.info("updateUser size={}, i={}, staffExtId = {}, startTime={}, endTime={}, res={}", size, i, staff.getStaffExtId(), startTime, endTime, res);
+                log.info("updateUser size={}, i={}, staffExtId = {}, startTime={}, endTime={}, res={}",
+                        size, i, staff.getStaffExtId(), startTime, endTime, res);
                 if (ObjectUtils.isEmpty(res)) {
                     continue;
                 }

+ 14 - 0
we-com-server/src/main/java/com/tzld/piaoquan/wecom/model/bo/VideoParam.java

@@ -0,0 +1,14 @@
+package com.tzld.piaoquan.wecom.model.bo;
+
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class VideoParam {
+
+    private String carrierId;
+
+    private List<Long> videoIds;
+
+}

+ 11 - 0
we-com-server/src/main/java/com/tzld/piaoquan/wecom/model/po/HistoryMessage.java

@@ -19,6 +19,8 @@ public class HistoryMessage {
 
     private Date sendTime;
 
+    private Integer isDelete;
+
     private Date createTime;
 
     public Long getId() {
@@ -85,6 +87,14 @@ public class HistoryMessage {
         this.sendTime = sendTime;
     }
 
+    public Integer getIsDelete() {
+        return isDelete;
+    }
+
+    public void setIsDelete(Integer isDelete) {
+        this.isDelete = isDelete;
+    }
+
     public Date getCreateTime() {
         return createTime;
     }
@@ -107,6 +117,7 @@ public class HistoryMessage {
         sb.append(", messageId=").append(messageId);
         sb.append(", status=").append(status);
         sb.append(", sendTime=").append(sendTime);
+        sb.append(", isDelete=").append(isDelete);
         sb.append(", createTime=").append(createTime);
         sb.append("]");
         return sb.toString();

+ 60 - 0
we-com-server/src/main/java/com/tzld/piaoquan/wecom/model/po/HistoryMessageExample.java

@@ -596,6 +596,66 @@ public class HistoryMessageExample {
             return (Criteria) this;
         }
 
+        public Criteria andIsDeleteIsNull() {
+            addCriterion("is_delete is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andIsDeleteIsNotNull() {
+            addCriterion("is_delete is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andIsDeleteEqualTo(Integer value) {
+            addCriterion("is_delete =", value, "isDelete");
+            return (Criteria) this;
+        }
+
+        public Criteria andIsDeleteNotEqualTo(Integer value) {
+            addCriterion("is_delete <>", value, "isDelete");
+            return (Criteria) this;
+        }
+
+        public Criteria andIsDeleteGreaterThan(Integer value) {
+            addCriterion("is_delete >", value, "isDelete");
+            return (Criteria) this;
+        }
+
+        public Criteria andIsDeleteGreaterThanOrEqualTo(Integer value) {
+            addCriterion("is_delete >=", value, "isDelete");
+            return (Criteria) this;
+        }
+
+        public Criteria andIsDeleteLessThan(Integer value) {
+            addCriterion("is_delete <", value, "isDelete");
+            return (Criteria) this;
+        }
+
+        public Criteria andIsDeleteLessThanOrEqualTo(Integer value) {
+            addCriterion("is_delete <=", value, "isDelete");
+            return (Criteria) this;
+        }
+
+        public Criteria andIsDeleteIn(List<Integer> values) {
+            addCriterion("is_delete in", values, "isDelete");
+            return (Criteria) this;
+        }
+
+        public Criteria andIsDeleteNotIn(List<Integer> values) {
+            addCriterion("is_delete not in", values, "isDelete");
+            return (Criteria) this;
+        }
+
+        public Criteria andIsDeleteBetween(Integer value1, Integer value2) {
+            addCriterion("is_delete between", value1, value2, "isDelete");
+            return (Criteria) this;
+        }
+
+        public Criteria andIsDeleteNotBetween(Integer value1, Integer value2) {
+            addCriterion("is_delete not between", value1, value2, "isDelete");
+            return (Criteria) this;
+        }
+
         public Criteria andCreateTimeIsNull() {
             addCriterion("create_time is null");
             return (Criteria) this;

+ 14 - 0
we-com-server/src/main/java/com/tzld/piaoquan/wecom/model/vo/GuaranteedParam.java

@@ -0,0 +1,14 @@
+package com.tzld.piaoquan.wecom.model.vo;
+
+import com.tzld.piaoquan.wecom.model.bo.VideoParam;
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class GuaranteedParam {
+
+    private String date;
+
+    private List<VideoParam> videoParamList;
+}

+ 1 - 1
we-com-server/src/main/java/com/tzld/piaoquan/wecom/model/vo/MessageTextVo.java → we-com-server/src/main/java/com/tzld/piaoquan/wecom/model/vo/MessageTextParam.java

@@ -3,7 +3,7 @@ package com.tzld.piaoquan.wecom.model.vo;
 import lombok.Data;
 
 @Data
-public class MessageTextVo {
+public class MessageTextParam {
 
     private String text;
 

+ 25 - 9
we-com-server/src/main/java/com/tzld/piaoquan/wecom/service/Impl/MessageAttachmentServiceImpl.java

@@ -2,22 +2,25 @@ package com.tzld.piaoquan.wecom.service.Impl;
 
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
+import com.tzld.piaoquan.wecom.common.base.CommonResponse;
 import com.tzld.piaoquan.wecom.common.enums.MessageAttachmentTypeEnum;
 import com.tzld.piaoquan.wecom.common.exception.CustomizeException;
 import com.tzld.piaoquan.wecom.dao.mapper.MessageAttachmentMapper;
 import com.tzld.piaoquan.wecom.model.bo.AdPutFlowParam;
 import com.tzld.piaoquan.wecom.model.bo.VideoDetail;
+import com.tzld.piaoquan.wecom.model.bo.VideoParam;
 import com.tzld.piaoquan.wecom.model.po.MessageAttachment;
 import com.tzld.piaoquan.wecom.model.po.MessageAttachmentExample;
 import com.tzld.piaoquan.wecom.model.po.Staff;
+import com.tzld.piaoquan.wecom.model.vo.GuaranteedParam;
 import com.tzld.piaoquan.wecom.service.AccessTokenService;
 import com.tzld.piaoquan.wecom.service.MessageAttachmentService;
 import com.tzld.piaoquan.wecom.utils.DateUtil;
 import com.tzld.piaoquan.wecom.utils.HttpClientUtil;
 import com.tzld.piaoquan.wecom.utils.HttpPoolClient;
+import com.tzld.piaoquan.wecom.utils.LarkRobotUtil;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
-import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.stereotype.Service;
@@ -34,10 +37,12 @@ import java.nio.file.Paths;
 import java.util.*;
 import java.util.concurrent.TimeUnit;
 
+import static com.tzld.piaoquan.wecom.common.constant.MessageConstant.MAX_VIDEO_NUM;
 import static com.tzld.piaoquan.wecom.common.constant.MessageConstant.appid;
 import static com.tzld.piaoquan.wecom.common.constant.OtherServerURL.POST_ADD_TENCENT;
 import static com.tzld.piaoquan.wecom.common.constant.OtherServerURL.POST_VIDEO_DETAIL_URL;
 import static com.tzld.piaoquan.wecom.common.constant.RedisConstant.GUARANTEED_MINIPROGRAM_KEY;
+import static com.tzld.piaoquan.wecom.common.constant.RedisConstant.GUARANTEED_MINI_PROGRAM_KEY;
 import static com.tzld.piaoquan.wecom.common.constant.WeComConstant.POST_WE_COM_MEDIA_UPLOAD;
 import static com.tzld.piaoquan.wecom.common.enums.ExceptionCodeEnum.PARAMS_ERROR;
 
@@ -58,7 +63,7 @@ public class MessageAttachmentServiceImpl implements MessageAttachmentService {
     private RedisTemplate<String, Object> redisTemplate;
 
     @Override
-    public void addMiniprogram(List<MessageAttachment> messageAttachmentList) {
+    public void addMiniProgram(List<MessageAttachment> messageAttachmentList) {
         for (MessageAttachment messageAttachment : messageAttachmentList) {
             MessageAttachmentExample example = new MessageAttachmentExample();
             example.createCriteria()
@@ -76,9 +81,18 @@ public class MessageAttachmentServiceImpl implements MessageAttachmentService {
     }
 
     @Override
-    public void createGuaranteedMiniprogram(List<Long> videoIds) {
-        if (CollectionUtils.isEmpty(videoIds)) {
-            throw new CustomizeException(PARAMS_ERROR);
+    public CommonResponse<Void> createGuaranteedMiniProgram(GuaranteedParam guaranteedParam) {
+        if (guaranteedParam == null
+                || StringUtils.isEmpty(guaranteedParam.getDate())
+                || CollectionUtils.isEmpty(guaranteedParam.getVideoParamList())) {
+            return CommonResponse.create(500, "参数错误");
+        }
+        List<Long> videoIds = new ArrayList<>();
+        for (VideoParam videoParam : guaranteedParam.getVideoParamList()) {
+            if (CollectionUtils.isEmpty(videoParam.getVideoIds()) || videoParam.getVideoIds().size() < MAX_VIDEO_NUM) {
+                LarkRobotUtil.sendMessage("保底视频数量异常,请查看" + guaranteedParam.getDate());
+            }
+            videoIds.addAll(videoParam.getVideoIds());
         }
         Map<Long, VideoDetail> coverMap = getVideoDetail(videoIds);
         List<MessageAttachment> messageAttachmentList = new ArrayList<>();
@@ -86,6 +100,7 @@ public class MessageAttachmentServiceImpl implements MessageAttachmentService {
             MessageAttachment messageAttachment = new MessageAttachment();
             VideoDetail videoDetail = coverMap.get(videoId);
             if (videoDetail == null || StringUtils.isEmpty(videoDetail.getCover()) || StringUtils.isEmpty(videoDetail.getTitle())) {
+                LarkRobotUtil.sendMessage("获取视频详情异常,请查看" + videoId);
                 throw new RuntimeException("获取视频详情异常");
             }
             messageAttachment.setMiniprogramVideoId(videoId);
@@ -95,10 +110,11 @@ public class MessageAttachmentServiceImpl implements MessageAttachmentService {
             messageAttachment.setAppid(appid);
             messageAttachmentList.add(messageAttachment);
         }
-        addMiniprogram(messageAttachmentList);
-        for (Long video : videoIds) {
-            redisTemplate.opsForList().rightPush(GUARANTEED_MINIPROGRAM_KEY, video);
-        }
+        addMiniProgram(messageAttachmentList);
+        String date = guaranteedParam.getDate();
+        String key = String.format(GUARANTEED_MINI_PROGRAM_KEY, date);
+        redisTemplate.opsForValue().set(key, guaranteedParam);
+        return CommonResponse.success();
     }
 
     public Map<Long, VideoDetail> getVideoDetail(List<Long> videoIdList) {

+ 6 - 6
we-com-server/src/main/java/com/tzld/piaoquan/wecom/service/Impl/MessageServiceImpl.java

@@ -3,7 +3,7 @@ package com.tzld.piaoquan.wecom.service.Impl;
 import com.alibaba.fastjson.JSONObject;
 import com.tzld.piaoquan.wecom.common.constant.MessageConstant;
 import com.tzld.piaoquan.wecom.common.exception.CustomizeException;
-import com.tzld.piaoquan.wecom.model.vo.MessageTextVo;
+import com.tzld.piaoquan.wecom.model.vo.MessageTextParam;
 import com.tzld.piaoquan.wecom.service.AccessTokenService;
 import com.tzld.piaoquan.wecom.service.MessageService;
 import com.tzld.piaoquan.wecom.utils.HttpClientUtil;
@@ -69,14 +69,14 @@ public class MessageServiceImpl implements MessageService {
     }
 
     @Override
-    public void createMessageText(MessageTextVo messageTextVo) {
-        if (messageTextVo == null || messageTextVo.getHour() == null) {
+    public void createMessageText(MessageTextParam messageTextParam) {
+        if (messageTextParam == null || messageTextParam.getHour() == null) {
             throw new CustomizeException(PARAMS_ERROR);
         }
-        if (messageTextVo.getHour() == -1) {
-            redisTemplate.opsForValue().set(PUSH_MESSAGE_TEXT, messageTextVo.getText());
+        if (messageTextParam.getHour() == -1) {
+            redisTemplate.opsForValue().set(PUSH_MESSAGE_TEXT, messageTextParam.getText());
         } else {
-            redisTemplate.opsForValue().set(PUSH_MESSAGE_TEXT, messageTextVo.getText(), messageTextVo.getHour(), TimeUnit.HOURS);
+            redisTemplate.opsForValue().set(PUSH_MESSAGE_TEXT, messageTextParam.getText(), messageTextParam.getHour(), TimeUnit.HOURS);
         }
     }
 

+ 4 - 2
we-com-server/src/main/java/com/tzld/piaoquan/wecom/service/MessageAttachmentService.java

@@ -1,15 +1,17 @@
 package com.tzld.piaoquan.wecom.service;
 
+import com.tzld.piaoquan.wecom.common.base.CommonResponse;
 import com.tzld.piaoquan.wecom.model.po.MessageAttachment;
 import com.tzld.piaoquan.wecom.model.po.Staff;
+import com.tzld.piaoquan.wecom.model.vo.GuaranteedParam;
 
 import java.util.List;
 
 public interface MessageAttachmentService {
 
-    void addMiniprogram(List<MessageAttachment> messageAttachmentList);
+    void addMiniProgram(List<MessageAttachment> messageAttachmentList);
 
-    void createGuaranteedMiniprogram(List<Long> videos);
+    CommonResponse<Void> createGuaranteedMiniProgram(GuaranteedParam guaranteedParam);
 
     String getPicMediaId(String cover);
 

+ 2 - 2
we-com-server/src/main/java/com/tzld/piaoquan/wecom/service/MessageService.java

@@ -1,7 +1,7 @@
 package com.tzld.piaoquan.wecom.service;
 
 import com.alibaba.fastjson.JSONObject;
-import com.tzld.piaoquan.wecom.model.vo.MessageTextVo;
+import com.tzld.piaoquan.wecom.model.vo.MessageTextParam;
 
 public interface MessageService {
 
@@ -9,7 +9,7 @@ public interface MessageService {
 
     boolean pushWeComMessage(JSONObject jsonObject);
 
-    void createMessageText(MessageTextVo messageTextVo);
+    void createMessageText(MessageTextParam messageTextParam);
 
     String getMessageText();
 }

+ 7 - 0
we-com-server/src/main/java/com/tzld/piaoquan/wecom/utils/DateUtil.java

@@ -28,6 +28,13 @@ public class DateUtil {
         return dateFormat.format(yesterday);
     }
 
+    public static String getThatDayDateString() {
+        DateTimeFormatter dateFormat = DateTimeFormatter.ofPattern("yyyy-MM-dd");
+        LocalDate today = LocalDate.now();
+        return dateFormat.format(today);
+    }
+
+
     public static String getDayDateString(String pattern) {
         DateTimeFormatter dateFormat = DateTimeFormatter.ofPattern(pattern);
         LocalDate today = LocalDate.now();

+ 5 - 6
we-com-server/src/main/java/com/tzld/piaoquan/wecom/utils/LarkRobotUtil.java

@@ -15,22 +15,22 @@ public class LarkRobotUtil {
 
     private static final String SECRET = "iYGMzvTCIIX35WyPlxB3Lh";
 
-    private static final String URL = "https://open.feishu.cn/open-apis/bot/v2/hook/5cab8414-03c2-4300-83f4-709cec256d12";
+    private static final String URL = "https://open.feishu.cn/open-apis/bot/v2/hook/93787b70-33d3-42c1-beae-c09310c9b38b";
 
     private static final HttpPoolClient httpPoolClientDefault = HttpClientUtil.create(30000, 30000, 2000, 5000, 5, 30000);
 
 
     public static void sendMessage(String msg) {
-        sendMessage("text", msg);
+        sendMessage("text", "企微推送报警:" + msg);
     }
 
     public static void sendMessage(String type, String msg) {
         try {
             long timestamp = System.currentTimeMillis() / 1000;
-            String sign = getSign(timestamp);
+//            String sign = getSign(timestamp);
             JSONObject param = new JSONObject();
-            param.put("timestamp", String.valueOf(timestamp));
-            param.put("sign", sign);
+//            param.put("timestamp", String.valueOf(timestamp));
+//            param.put("sign", sign);
             param.put("msg_type", type);
             JSONObject content = new JSONObject();
             content.put("text", msg);
@@ -41,7 +41,6 @@ public class LarkRobotUtil {
         }
     }
 
-
     private static String getSign(long timestamp) throws NoSuchAlgorithmException, InvalidKeyException {
         //把timestamp+"\n"+密钥当做签名字符串
         String stringToSign = timestamp + "\n" + SECRET;

+ 280 - 270
we-com-server/src/main/resources/mapper/HistoryMessageMapper.xml

@@ -1,285 +1,296 @@
 <?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="com.tzld.piaoquan.wecom.dao.mapper.HistoryMessageMapper">
-    <resultMap id="BaseResultMap" type="com.tzld.piaoquan.wecom.model.po.HistoryMessage">
-        <id column="id" jdbcType="BIGINT" property="id"/>
-        <result column="user_id" jdbcType="BIGINT" property="userId"/>
-        <result column="staff_id" jdbcType="BIGINT" property="staffId"/>
-        <result column="video_id" jdbcType="BIGINT" property="videoId"/>
-        <result column="attachment_idx" jdbcType="INTEGER" property="attachmentIdx"/>
-        <result column="message_id" jdbcType="BIGINT" property="messageId"/>
-        <result column="status" jdbcType="INTEGER" property="status"/>
-        <result column="send_time" jdbcType="TIMESTAMP" property="sendTime"/>
-        <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
-    </resultMap>
-    <sql id="Example_Where_Clause">
-        <where>
-            <foreach collection="oredCriteria" item="criteria" separator="or">
-                <if test="criteria.valid">
-                    <trim prefix="(" prefixOverrides="and" suffix=")">
-                        <foreach collection="criteria.criteria" item="criterion">
-                            <choose>
-                                <when test="criterion.noValue">
-                                    and ${criterion.condition}
-                                </when>
-                                <when test="criterion.singleValue">
-                                    and ${criterion.condition} #{criterion.value}
-                                </when>
-                                <when test="criterion.betweenValue">
-                                    and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
-                                </when>
-                                <when test="criterion.listValue">
-                                    and ${criterion.condition}
-                                    <foreach close=")" collection="criterion.value" item="listItem" open="("
-                                             separator=",">
-                                        #{listItem}
-                                    </foreach>
-                                </when>
-                            </choose>
-                        </foreach>
-                    </trim>
-                </if>
+  <resultMap id="BaseResultMap" type="com.tzld.piaoquan.wecom.model.po.HistoryMessage">
+    <id column="id" jdbcType="BIGINT" property="id" />
+    <result column="user_id" jdbcType="BIGINT" property="userId" />
+    <result column="staff_id" jdbcType="BIGINT" property="staffId" />
+    <result column="video_id" jdbcType="BIGINT" property="videoId" />
+    <result column="attachment_idx" jdbcType="INTEGER" property="attachmentIdx" />
+    <result column="message_id" jdbcType="BIGINT" property="messageId" />
+    <result column="status" jdbcType="INTEGER" property="status" />
+    <result column="send_time" jdbcType="TIMESTAMP" property="sendTime" />
+    <result column="is_delete" jdbcType="INTEGER" property="isDelete" />
+    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
+  </resultMap>
+  <sql id="Example_Where_Clause">
+    <where>
+      <foreach collection="oredCriteria" item="criteria" separator="or">
+        <if test="criteria.valid">
+          <trim prefix="(" prefixOverrides="and" suffix=")">
+            <foreach collection="criteria.criteria" item="criterion">
+              <choose>
+                <when test="criterion.noValue">
+                  and ${criterion.condition}
+                </when>
+                <when test="criterion.singleValue">
+                  and ${criterion.condition} #{criterion.value}
+                </when>
+                <when test="criterion.betweenValue">
+                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
+                </when>
+                <when test="criterion.listValue">
+                  and ${criterion.condition}
+                  <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
+                    #{listItem}
+                  </foreach>
+                </when>
+              </choose>
             </foreach>
-        </where>
-    </sql>
-    <sql id="Update_By_Example_Where_Clause">
-        <where>
-            <foreach collection="example.oredCriteria" item="criteria" separator="or">
-                <if test="criteria.valid">
-                    <trim prefix="(" prefixOverrides="and" suffix=")">
-                        <foreach collection="criteria.criteria" item="criterion">
-                            <choose>
-                                <when test="criterion.noValue">
-                                    and ${criterion.condition}
-                                </when>
-                                <when test="criterion.singleValue">
-                                    and ${criterion.condition} #{criterion.value}
-                                </when>
-                                <when test="criterion.betweenValue">
-                                    and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
-                                </when>
-                                <when test="criterion.listValue">
-                                    and ${criterion.condition}
-                                    <foreach close=")" collection="criterion.value" item="listItem" open="("
-                                             separator=",">
-                                        #{listItem}
-                                    </foreach>
-                                </when>
-                            </choose>
-                        </foreach>
-                    </trim>
-                </if>
-            </foreach>
-        </where>
-    </sql>
-    <sql id="Base_Column_List">
-        id
-        , user_id, staff_id, video_id, attachment_idx, message_id, `status`, send_time,
-    create_time
-    </sql>
-    <select id="selectByExample" parameterType="com.tzld.piaoquan.wecom.model.po.HistoryMessageExample"
-            resultMap="BaseResultMap">
-        select
-        <if test="distinct">
-            distinct
-        </if>
-        <include refid="Base_Column_List"/>
-        from we_com_history_message
-        <if test="_parameter != null">
-            <include refid="Example_Where_Clause"/>
-        </if>
-        <if test="orderByClause != null">
-            order by ${orderByClause}
-        </if>
-        <if test="page != null">
-            limit #{page.offset} , #{page.pageSize}
-        </if>
-    </select>
-    <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
-        select
-        <include refid="Base_Column_List"/>
-        from we_com_history_message
-        where id = #{id,jdbcType=BIGINT}
-    </select>
-    <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
-        delete
-        from we_com_history_message
-        where id = #{id,jdbcType=BIGINT}
-    </delete>
-    <delete id="deleteByExample" parameterType="com.tzld.piaoquan.wecom.model.po.HistoryMessageExample">
-        delete from we_com_history_message
-        <if test="_parameter != null">
-            <include refid="Example_Where_Clause"/>
+          </trim>
         </if>
-    </delete>
-    <insert id="insert" parameterType="com.tzld.piaoquan.wecom.model.po.HistoryMessage">
-        insert into we_com_history_message (id, user_id, staff_id,
-                                            video_id, attachment_idx, message_id,
-                                            `status`, send_time, create_time)
-        values (#{id,jdbcType=BIGINT}, #{userId,jdbcType=BIGINT}, #{staffId,jdbcType=BIGINT},
-                #{videoId,jdbcType=BIGINT}, #{attachmentIdx,jdbcType=INTEGER}, #{messageId,jdbcType=BIGINT},
-                #{status,jdbcType=INTEGER}, #{sendTime,jdbcType=TIMESTAMP}, #{createTime,jdbcType=TIMESTAMP})
-    </insert>
-    <insert id="insertSelective" parameterType="com.tzld.piaoquan.wecom.model.po.HistoryMessage">
-        insert into we_com_history_message
-        <trim prefix="(" suffix=")" suffixOverrides=",">
-            <if test="id != null">
-                id,
-            </if>
-            <if test="userId != null">
-                user_id,
-            </if>
-            <if test="staffId != null">
-                staff_id,
-            </if>
-            <if test="videoId != null">
-                video_id,
-            </if>
-            <if test="attachmentIdx != null">
-                attachment_idx,
-            </if>
-            <if test="messageId != null">
-                message_id,
-            </if>
-            <if test="status != null">
-                `status`,
-            </if>
-            <if test="sendTime != null">
-                send_time,
-            </if>
-            <if test="createTime != null">
-                create_time,
-            </if>
-        </trim>
-        <trim prefix="values (" suffix=")" suffixOverrides=",">
-            <if test="id != null">
-                #{id,jdbcType=BIGINT},
-            </if>
-            <if test="userId != null">
-                #{userId,jdbcType=BIGINT},
-            </if>
-            <if test="staffId != null">
-                #{staffId,jdbcType=BIGINT},
-            </if>
-            <if test="videoId != null">
-                #{videoId,jdbcType=BIGINT},
-            </if>
-            <if test="attachmentIdx != null">
-                #{attachmentIdx,jdbcType=INTEGER},
-            </if>
-            <if test="messageId != null">
-                #{messageId,jdbcType=BIGINT},
-            </if>
-            <if test="status != null">
-                #{status,jdbcType=INTEGER},
-            </if>
-            <if test="sendTime != null">
-                #{sendTime,jdbcType=TIMESTAMP},
-            </if>
-            <if test="createTime != null">
-                #{createTime,jdbcType=TIMESTAMP},
-            </if>
-        </trim>
-    </insert>
-    <select id="countByExample" parameterType="com.tzld.piaoquan.wecom.model.po.HistoryMessageExample"
-            resultType="java.lang.Long">
-        select count(*) from we_com_history_message
-        <if test="_parameter != null">
-            <include refid="Example_Where_Clause"/>
-        </if>
-    </select>
-    <update id="updateByExampleSelective" parameterType="map">
-        update we_com_history_message
-        <set>
-            <if test="record.id != null">
-                id = #{record.id,jdbcType=BIGINT},
-            </if>
-            <if test="record.userId != null">
-                user_id = #{record.userId,jdbcType=BIGINT},
-            </if>
-            <if test="record.staffId != null">
-                staff_id = #{record.staffId,jdbcType=BIGINT},
-            </if>
-            <if test="record.videoId != null">
-                video_id = #{record.videoId,jdbcType=BIGINT},
-            </if>
-            <if test="record.attachmentIdx != null">
-                attachment_idx = #{record.attachmentIdx,jdbcType=INTEGER},
-            </if>
-            <if test="record.messageId != null">
-                message_id = #{record.messageId,jdbcType=BIGINT},
-            </if>
-            <if test="record.status != null">
-                `status` = #{record.status,jdbcType=INTEGER},
-            </if>
-            <if test="record.sendTime != null">
-                send_time = #{record.sendTime,jdbcType=TIMESTAMP},
-            </if>
-            <if test="record.createTime != null">
-                create_time = #{record.createTime,jdbcType=TIMESTAMP},
-            </if>
-        </set>
-        <if test="_parameter != null">
-            <include refid="Update_By_Example_Where_Clause"/>
+      </foreach>
+    </where>
+  </sql>
+  <sql id="Update_By_Example_Where_Clause">
+    <where>
+      <foreach collection="example.oredCriteria" item="criteria" separator="or">
+        <if test="criteria.valid">
+          <trim prefix="(" prefixOverrides="and" suffix=")">
+            <foreach collection="criteria.criteria" item="criterion">
+              <choose>
+                <when test="criterion.noValue">
+                  and ${criterion.condition}
+                </when>
+                <when test="criterion.singleValue">
+                  and ${criterion.condition} #{criterion.value}
+                </when>
+                <when test="criterion.betweenValue">
+                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
+                </when>
+                <when test="criterion.listValue">
+                  and ${criterion.condition}
+                  <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
+                    #{listItem}
+                  </foreach>
+                </when>
+              </choose>
+            </foreach>
+          </trim>
         </if>
-    </update>
-    <update id="updateByExample" parameterType="map">
-        update we_com_history_message
-        set id = #{record.id,jdbcType=BIGINT},
+      </foreach>
+    </where>
+  </sql>
+  <sql id="Base_Column_List">
+    id, user_id, staff_id, video_id, attachment_idx, message_id, `status`, send_time, 
+    is_delete, create_time
+  </sql>
+  <select id="selectByExample" parameterType="com.tzld.piaoquan.wecom.model.po.HistoryMessageExample" resultMap="BaseResultMap">
+    select
+    <if test="distinct">
+      distinct
+    </if>
+    <include refid="Base_Column_List" />
+    from we_com_history_message
+    <if test="_parameter != null">
+      <include refid="Example_Where_Clause" />
+    </if>
+    <if test="orderByClause != null">
+      order by ${orderByClause}
+    </if>
+    <if test="page != null">
+      limit #{page.offset} , #{page.pageSize}
+    </if>
+  </select>
+  <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
+    select 
+    <include refid="Base_Column_List" />
+    from we_com_history_message
+    where id = #{id,jdbcType=BIGINT}
+  </select>
+  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
+    delete from we_com_history_message
+    where id = #{id,jdbcType=BIGINT}
+  </delete>
+  <delete id="deleteByExample" parameterType="com.tzld.piaoquan.wecom.model.po.HistoryMessageExample">
+    delete from we_com_history_message
+    <if test="_parameter != null">
+      <include refid="Example_Where_Clause" />
+    </if>
+  </delete>
+  <insert id="insert" parameterType="com.tzld.piaoquan.wecom.model.po.HistoryMessage">
+    insert into we_com_history_message (id, user_id, staff_id, 
+      video_id, attachment_idx, message_id, 
+      `status`, send_time,
+      create_time)
+    values (#{id,jdbcType=BIGINT}, #{userId,jdbcType=BIGINT}, #{staffId,jdbcType=BIGINT}, 
+      #{videoId,jdbcType=BIGINT}, #{attachmentIdx,jdbcType=INTEGER}, #{messageId,jdbcType=BIGINT}, 
+      #{status,jdbcType=INTEGER}, #{sendTime,jdbcType=TIMESTAMP},
+      #{createTime,jdbcType=TIMESTAMP})
+  </insert>
+  <insert id="insertSelective" parameterType="com.tzld.piaoquan.wecom.model.po.HistoryMessage">
+    insert into we_com_history_message
+    <trim prefix="(" suffix=")" suffixOverrides=",">
+      <if test="id != null">
+        id,
+      </if>
+      <if test="userId != null">
+        user_id,
+      </if>
+      <if test="staffId != null">
+        staff_id,
+      </if>
+      <if test="videoId != null">
+        video_id,
+      </if>
+      <if test="attachmentIdx != null">
+        attachment_idx,
+      </if>
+      <if test="messageId != null">
+        message_id,
+      </if>
+      <if test="status != null">
+        `status`,
+      </if>
+      <if test="sendTime != null">
+        send_time,
+      </if>
+      <if test="isDelete != null">
+        is_delete,
+      </if>
+      <if test="createTime != null">
+        create_time,
+      </if>
+    </trim>
+    <trim prefix="values (" suffix=")" suffixOverrides=",">
+      <if test="id != null">
+        #{id,jdbcType=BIGINT},
+      </if>
+      <if test="userId != null">
+        #{userId,jdbcType=BIGINT},
+      </if>
+      <if test="staffId != null">
+        #{staffId,jdbcType=BIGINT},
+      </if>
+      <if test="videoId != null">
+        #{videoId,jdbcType=BIGINT},
+      </if>
+      <if test="attachmentIdx != null">
+        #{attachmentIdx,jdbcType=INTEGER},
+      </if>
+      <if test="messageId != null">
+        #{messageId,jdbcType=BIGINT},
+      </if>
+      <if test="status != null">
+        #{status,jdbcType=INTEGER},
+      </if>
+      <if test="sendTime != null">
+        #{sendTime,jdbcType=TIMESTAMP},
+      </if>
+      <if test="isDelete != null">
+        #{isDelete,jdbcType=INTEGER},
+      </if>
+      <if test="createTime != null">
+        #{createTime,jdbcType=TIMESTAMP},
+      </if>
+    </trim>
+  </insert>
+  <select id="countByExample" parameterType="com.tzld.piaoquan.wecom.model.po.HistoryMessageExample" resultType="java.lang.Long">
+    select count(*) from we_com_history_message
+    <if test="_parameter != null">
+      <include refid="Example_Where_Clause" />
+    </if>
+  </select>
+  <update id="updateByExampleSelective" parameterType="map">
+    update we_com_history_message
+    <set>
+      <if test="record.id != null">
+        id = #{record.id,jdbcType=BIGINT},
+      </if>
+      <if test="record.userId != null">
         user_id = #{record.userId,jdbcType=BIGINT},
+      </if>
+      <if test="record.staffId != null">
         staff_id = #{record.staffId,jdbcType=BIGINT},
+      </if>
+      <if test="record.videoId != null">
         video_id = #{record.videoId,jdbcType=BIGINT},
+      </if>
+      <if test="record.attachmentIdx != null">
         attachment_idx = #{record.attachmentIdx,jdbcType=INTEGER},
+      </if>
+      <if test="record.messageId != null">
         message_id = #{record.messageId,jdbcType=BIGINT},
+      </if>
+      <if test="record.status != null">
         `status` = #{record.status,jdbcType=INTEGER},
+      </if>
+      <if test="record.sendTime != null">
         send_time = #{record.sendTime,jdbcType=TIMESTAMP},
-        create_time = #{record.createTime,jdbcType=TIMESTAMP}
-        <if test="_parameter != null">
-            <include refid="Update_By_Example_Where_Clause"/>
-        </if>
-    </update>
-    <update id="updateByPrimaryKeySelective" parameterType="com.tzld.piaoquan.wecom.model.po.HistoryMessage">
-        update we_com_history_message
-        <set>
-            <if test="userId != null">
-                user_id = #{userId,jdbcType=BIGINT},
-            </if>
-            <if test="staffId != null">
-                staff_id = #{staffId,jdbcType=BIGINT},
-            </if>
-            <if test="videoId != null">
-                video_id = #{videoId,jdbcType=BIGINT},
-            </if>
-            <if test="attachmentIdx != null">
-                attachment_idx = #{attachmentIdx,jdbcType=INTEGER},
-            </if>
-            <if test="messageId != null">
-                message_id = #{messageId,jdbcType=BIGINT},
-            </if>
-            <if test="status != null">
-                `status` = #{status,jdbcType=INTEGER},
-            </if>
-            <if test="sendTime != null">
-                send_time = #{sendTime,jdbcType=TIMESTAMP},
-            </if>
-            <if test="createTime != null">
-                create_time = #{createTime,jdbcType=TIMESTAMP},
-            </if>
-        </set>
-        where id = #{id,jdbcType=BIGINT}
-    </update>
-    <update id="updateByPrimaryKey" parameterType="com.tzld.piaoquan.wecom.model.po.HistoryMessage">
-        update we_com_history_message
-        set user_id        = #{userId,jdbcType=BIGINT},
-            staff_id       = #{staffId,jdbcType=BIGINT},
-            video_id       = #{videoId,jdbcType=BIGINT},
-            attachment_idx = #{attachmentIdx,jdbcType=INTEGER},
-            message_id     = #{messageId,jdbcType=BIGINT},
-            `status`       = #{status,jdbcType=INTEGER},
-            send_time      = #{sendTime,jdbcType=TIMESTAMP},
-            create_time    = #{createTime,jdbcType=TIMESTAMP}
-        where id = #{id,jdbcType=BIGINT}
-    </update>
+      </if>
+      <if test="record.isDelete != null">
+        is_delete = #{record.isDelete,jdbcType=INTEGER},
+      </if>
+      <if test="record.createTime != null">
+        create_time = #{record.createTime,jdbcType=TIMESTAMP},
+      </if>
+    </set>
+    <if test="_parameter != null">
+      <include refid="Update_By_Example_Where_Clause" />
+    </if>
+  </update>
+  <update id="updateByExample" parameterType="map">
+    update we_com_history_message
+    set id = #{record.id,jdbcType=BIGINT},
+      user_id = #{record.userId,jdbcType=BIGINT},
+      staff_id = #{record.staffId,jdbcType=BIGINT},
+      video_id = #{record.videoId,jdbcType=BIGINT},
+      attachment_idx = #{record.attachmentIdx,jdbcType=INTEGER},
+      message_id = #{record.messageId,jdbcType=BIGINT},
+      `status` = #{record.status,jdbcType=INTEGER},
+      send_time = #{record.sendTime,jdbcType=TIMESTAMP},
+      is_delete = #{record.isDelete,jdbcType=INTEGER},
+      create_time = #{record.createTime,jdbcType=TIMESTAMP}
+    <if test="_parameter != null">
+      <include refid="Update_By_Example_Where_Clause" />
+    </if>
+  </update>
+  <update id="updateByPrimaryKeySelective" parameterType="com.tzld.piaoquan.wecom.model.po.HistoryMessage">
+    update we_com_history_message
+    <set>
+      <if test="userId != null">
+        user_id = #{userId,jdbcType=BIGINT},
+      </if>
+      <if test="staffId != null">
+        staff_id = #{staffId,jdbcType=BIGINT},
+      </if>
+      <if test="videoId != null">
+        video_id = #{videoId,jdbcType=BIGINT},
+      </if>
+      <if test="attachmentIdx != null">
+        attachment_idx = #{attachmentIdx,jdbcType=INTEGER},
+      </if>
+      <if test="messageId != null">
+        message_id = #{messageId,jdbcType=BIGINT},
+      </if>
+      <if test="status != null">
+        `status` = #{status,jdbcType=INTEGER},
+      </if>
+      <if test="sendTime != null">
+        send_time = #{sendTime,jdbcType=TIMESTAMP},
+      </if>
+      <if test="isDelete != null">
+        is_delete = #{isDelete,jdbcType=INTEGER},
+      </if>
+      <if test="createTime != null">
+        create_time = #{createTime,jdbcType=TIMESTAMP},
+      </if>
+    </set>
+    where id = #{id,jdbcType=BIGINT}
+  </update>
+  <update id="updateByPrimaryKey" parameterType="com.tzld.piaoquan.wecom.model.po.HistoryMessage">
+    update we_com_history_message
+    set user_id = #{userId,jdbcType=BIGINT},
+      staff_id = #{staffId,jdbcType=BIGINT},
+      video_id = #{videoId,jdbcType=BIGINT},
+      attachment_idx = #{attachmentIdx,jdbcType=INTEGER},
+      message_id = #{messageId,jdbcType=BIGINT},
+      `status` = #{status,jdbcType=INTEGER},
+      send_time = #{sendTime,jdbcType=TIMESTAMP},
+      is_delete = #{isDelete,jdbcType=INTEGER},
+      create_time = #{createTime,jdbcType=TIMESTAMP}
+    where id = #{id,jdbcType=BIGINT}
+  </update>
 
     <insert id="insertList" parameterType="java.util.List">
         insert into we_com_history_message
@@ -307,5 +318,4 @@
             )
         </foreach>
     </insert>
-
 </mapper>

+ 2 - 2
we-com-server/src/main/resources/mapper/StaffMapper.xml

@@ -106,10 +106,10 @@
   </delete>
   <insert id="insert" parameterType="com.tzld.piaoquan.wecom.model.po.Staff">
     insert into we_com_staff (id, staff_ext_id, carrier_id, 
-      remark, is_delete, create_time, 
+      remark, create_time,
       update_time)
     values (#{id,jdbcType=BIGINT}, #{staffExtId,jdbcType=VARCHAR}, #{carrierId,jdbcType=VARCHAR}, 
-      #{remark,jdbcType=VARCHAR}, #{isDelete,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, 
+      #{remark,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP},
       #{updateTime,jdbcType=TIMESTAMP})
   </insert>
   <insert id="insertSelective" parameterType="com.tzld.piaoquan.wecom.model.po.Staff">

+ 2 - 3
we-com-server/src/main/resources/mapper/StaffWithUserMapper.xml

@@ -105,11 +105,10 @@
     </if>
   </delete>
   <insert id="insert" parameterType="com.tzld.piaoquan.wecom.model.po.StaffWithUser">
-    insert into we_com_staff_with_user (id, staff_id, user_id,
-      is_delete, delete_time, create_time,
+    insert into we_com_staff_with_user (id, staff_id, user_id, delete_time, create_time,
       update_time)
     values (#{id,jdbcType=BIGINT}, #{staffId,jdbcType=BIGINT}, #{userId,jdbcType=BIGINT},
-      #{isDelete,jdbcType=INTEGER}, #{deleteTime,jdbcType=TIMESTAMP}, #{createTime,jdbcType=TIMESTAMP},
+      #{deleteTime,jdbcType=TIMESTAMP}, #{createTime,jdbcType=TIMESTAMP},
       #{updateTime,jdbcType=TIMESTAMP})
   </insert>
   <insert id="insertSelective" parameterType="com.tzld.piaoquan.wecom.model.po.StaffWithUser">

+ 2 - 2
we-com-server/src/main/resources/mybatis-generator-config.xml

@@ -51,10 +51,10 @@
         </javaClientGenerator>
 
 <!--        <table tableName="we_com_alert_message" domainObjectName="AlertMessage" alias=""/>-->
-<!--        <table tableName="we_com_history_message" domainObjectName="HistoryMessage" alias=""/>-->
+        <table tableName="we_com_history_message" domainObjectName="HistoryMessage" alias=""/>
 <!--        <table tableName="we_com_message_attachment" domainObjectName="MessageAttachment" alias=""/>-->
 <!--        <table tableName="we_com_staff" domainObjectName="Staff" alias=""/>-->
-        <table tableName="we_com_staff_with_user" domainObjectName="StaffWithUser" alias=""/>
+<!--        <table tableName="we_com_staff_with_user" domainObjectName="StaffWithUser" alias=""/>-->
 <!--        <table tableName="we_com_send_message" domainObjectName="SendMessage" alias=""/>-->