Просмотр исходного кода

Merge branch 'test' of http://git.mokasz.com/marketing/moka-private into test

leon 4 лет назад
Родитель
Сommit
ff3004a88a

+ 6 - 1
src/main/java/com/mokamrp/privates/controller/pangu/FosterwxCashAccountScheduleController.java

@@ -127,7 +127,12 @@ public class FosterwxCashAccountScheduleController extends BaseController<Foster
     @Transactional(rollbackFor = Exception.class)
     @ApiOperation(value = "立即生成----缺少typer的接口")
     public Object immediateCreate(FosterwxCashAccountScheduleHandle handle) {
-        Arrays.asList(handle.getIds().split(REGEX)).forEach(id -> fosterwxCashAccountScheduleService.createTask(Integer.valueOf(id)));
+        Arrays.asList(handle.getIds().split(REGEX)).forEach(id -> {
+            List<FosterwxCashScheduleTaskList> newsList = fosterwxCashAccountScheduleService.createTask(Integer.valueOf(id));
+            // 由于不能浪费公众号发文为 需要整合起来一起发送
+            // 调用typer生成链接
+            fosterwxCashScheduleTaskListService.create(newsList);
+        });
 
         return AjaxResult.success("立即生成成功");
     }

+ 7 - 7
src/main/java/com/mokamrp/privates/controller/pangu/FosterwxCashScheduleTaskListController.java

@@ -65,12 +65,12 @@ public class FosterwxCashScheduleTaskListController extends BaseController<Foste
         return AjaxResult.success("取消任务成功");
     }
 
-    @PostMapping("/reCreate")
-    @ApiOperation("重新生成")
-    public Object reCreate(FosterwxCashScheduleTaskList fosterwxCashScheduleTaskList) {
-        fosterwxCashScheduleTaskListService.create(fosterwxCashScheduleTaskList);
-
-        return AjaxResult.success("重新生成成功");
-    }
+    // @PostMapping("/reCreate")
+    // @ApiOperation("重新生成")
+    // public Object reCreate(FosterwxCashScheduleTaskList fosterwxCashScheduleTaskList) {
+    //     fosterwxCashScheduleTaskListService.create(fosterwxCashScheduleTaskList);
+    //
+    //     return AjaxResult.success("重新生成成功");
+    // }
 }
 

+ 1 - 1
src/main/java/com/mokamrp/privates/entity/pangu/FosterwxCashAccountScheduleHandle.java

@@ -17,7 +17,7 @@ public class FosterwxCashAccountScheduleHandle {
     private Integer page;
     private Integer pageSize;
     private Integer id;
-    private Integer type;
+    private Integer type = 1;
     private Integer groupId;
     private Integer templateId;
     private Integer createUid;

+ 2 - 2
src/main/java/com/mokamrp/privates/service/pangu/FosterwxCashAccountScheduleService.java

@@ -4,7 +4,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
 import com.mokamrp.privates.entity.ResHandle;
 import com.mokamrp.privates.entity.pangu.FosterwxCashAccountScheduleHandle;
 import com.mokamrp.privates.mapper.pangu.pojo.FosterwxCashAccountSchedule;
-import com.mokamrp.privates.mapper.pojo.User;
+import com.mokamrp.privates.mapper.pangu.pojo.FosterwxCashScheduleTaskList;
 
 import java.util.List;
 
@@ -25,5 +25,5 @@ public interface FosterwxCashAccountScheduleService extends IService<FosterwxCas
      * @param id
      *
      */
-    void createTask(Integer id);
+    List<FosterwxCashScheduleTaskList> createTask(Integer id);
 }

+ 2 - 2
src/main/java/com/mokamrp/privates/service/pangu/FosterwxCashScheduleTaskListService.java

@@ -29,9 +29,9 @@ public interface FosterwxCashScheduleTaskListService extends IService<FosterwxCa
 
     /**
      * 生成任务 正常生成 | 生成失败|检测到公众号封禁重新生成链接
-     * @param fosterwxCashScheduleTaskList
+     * @param newsList
      */
-    void create(FosterwxCashScheduleTaskList fosterwxCashScheduleTaskList);
+    void create(List<FosterwxCashScheduleTaskList> newsList);
 
     /**
      * 获取被封禁的任务

+ 14 - 4
src/main/java/com/mokamrp/privates/service/pangu/impl/FosterwxCashAccountScheduleServiceImpl.java

@@ -16,6 +16,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import java.time.LocalDateTime;
+import java.util.ArrayList;
 import java.util.List;
 
 /**
@@ -46,6 +47,7 @@ public class FosterwxCashAccountScheduleServiceImpl extends ServiceImpl<Fosterwx
      * @param handle
      * @return
      */
+    @Override
     public ResHandle<List<FosterwxCashAccountSchedule>> getList(FosterwxCashAccountScheduleHandle handle) {
         Integer pagesize = handle.getPageSize();
         Integer page = handle.getPage();
@@ -54,6 +56,7 @@ public class FosterwxCashAccountScheduleServiceImpl extends ServiceImpl<Fosterwx
         fosterwxCashAccountScheduleLambdaQueryWrapper.eq(FosterwxCashAccountSchedule::getScheduleDate, handle.getScheduleDate());
         // 任务类型 1:个微任务 2:企微任务
         fosterwxCashAccountScheduleLambdaQueryWrapper.eq(FosterwxCashAccountSchedule::getType, handle.getType());
+
         // 任务模板
         if (null != handle.getTemplateId())
             fosterwxCashAccountScheduleLambdaQueryWrapper.eq(FosterwxCashAccountSchedule::getTemplateId, handle.getTemplateId());
@@ -79,13 +82,17 @@ public class FosterwxCashAccountScheduleServiceImpl extends ServiceImpl<Fosterwx
      *
      */
     @Override
-    public void createTask(Integer id) {
+    public List<FosterwxCashScheduleTaskList> createTask(Integer id) {
         FosterwxCashAccountSchedule fosterwxCashAccountSchedule = fosterwxCashAccountScheduleMapper.selectById(id);
 
         if (null != fosterwxCashAccountSchedule) {
+            // 该接口由立即生成和任务链接生成失败后两种调用方式 因此 在生成任务之前要删除旧任务
+            fosterwxCashScheduleTaskListMapper.delete(new LambdaQueryWrapper<FosterwxCashScheduleTaskList>().eq(FosterwxCashScheduleTaskList::getScheduleId, id));
+
             // 根据任务模板id获取任务模板详情
             ResHandle<List<FosterwxCashTaskList>> resHandle = fosterwxCashTaskTemplateService.getTaskByTemplateId(fosterwxCashAccountSchedule.getTemplateId());
 
+            List<FosterwxCashScheduleTaskList> newsList = new ArrayList<>();
             resHandle.getList().forEach(fosterwxCashTaskList -> {
                 // 创建任务
                 FosterwxCashScheduleTaskList fosterwxCashScheduleTaskList = new FosterwxCashScheduleTaskList();
@@ -96,7 +103,6 @@ public class FosterwxCashAccountScheduleServiceImpl extends ServiceImpl<Fosterwx
                 fosterwxCashScheduleTaskList.setTaskType(fosterwxCashTaskList.getTaskType());
                 fosterwxCashScheduleTaskList.setRemark(fosterwxCashTaskList.getRemark());
                 fosterwxCashScheduleTaskList.setTaskContent("");
-                //TODO 传递组别 随机获取ghid
                 fosterwxCashScheduleTaskList.setGhId("");
                 fosterwxCashScheduleTaskList.setStatus(1);
                 fosterwxCashScheduleTaskList.setErrInfo("");
@@ -109,14 +115,18 @@ public class FosterwxCashAccountScheduleServiceImpl extends ServiceImpl<Fosterwx
 
                 fosterwxCashScheduleTaskListMapper.insert(fosterwxCashScheduleTaskList);
 
-                // 调用typer生成链接
-                fosterwxCashScheduleTaskListService.create(fosterwxCashScheduleTaskList);
+                if (4 != fosterwxCashTaskList.getTaskType()) {
+                    newsList.add(fosterwxCashScheduleTaskList);
+                }
             });
 
             // 任务列表创建完成后 账号排期状态设置成正常
             fosterwxCashAccountSchedule.setStatus(1);
             fosterwxCashAccountSchedule.setUpdateAt(LocalDateTime.now());
             fosterwxCashAccountScheduleMapper.updateById(fosterwxCashAccountSchedule);
+
+            return newsList;
         }
+        return null;
     }
 }

+ 14 - 11
src/main/java/com/mokamrp/privates/service/pangu/impl/FosterwxCashScheduleTaskListServiceImpl.java

@@ -10,7 +10,6 @@ import com.mokamrp.privates.mapper.pangu.pojo.FosterwxCashScheduleTaskList;
 import com.mokamrp.privates.service.pangu.FosterwxCashScheduleTaskListService;
 import com.mokamrp.privates.service.pangu.FosterwxCashTaskListService;
 import com.mokamrp.privates.utils.pangu.redis.task.TaskRedis;
-import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -89,20 +88,24 @@ public class FosterwxCashScheduleTaskListServiceImpl extends ServiceImpl<Fosterw
 
     /**
      * 生成任务 正常生成 | 生成失败|检测到公众号封禁重新生成链接
-     * @param fosterwxCashScheduleTaskList
+     * @param newsList
      */
     @Override
-    public void create(FosterwxCashScheduleTaskList fosterwxCashScheduleTaskList) {
-        // 状态
-        fosterwxCashScheduleTaskList.setStatus(1);
-        // 失败原因
-        fosterwxCashScheduleTaskList.setErrInfo("");
-
-        fosterwxCashScheduleTaskListMapper.updateById(fosterwxCashScheduleTaskList);
+    public void create(List<FosterwxCashScheduleTaskList> newsList) {
+        for (int i = 0; i < newsList.size(); i++) {
+            FosterwxCashScheduleTaskList fosterwxCashScheduleTaskList = newsList.get(i);
+            // 状态
+            fosterwxCashScheduleTaskList.setStatus(1);
+            // 失败原因
+            fosterwxCashScheduleTaskList.setErrInfo("");
+            //TODO 传递组id 随机获取ghid
+            fosterwxCashScheduleTaskList.setGhId("");
 
-        fosterwxCashScheduleTaskList.setFosterwxCashTaskList(fosterwxCashTaskListService.getById(fosterwxCashScheduleTaskList.getTaskId()));
+            fosterwxCashScheduleTaskListMapper.updateById(fosterwxCashScheduleTaskList);
+            fosterwxCashScheduleTaskList.setFosterwxCashTaskList(fosterwxCashTaskListService.getById(fosterwxCashScheduleTaskList.getTaskId()));
+        }
 
-        taskRedis.createUrlByTyper(JSON.toJSONString(fosterwxCashScheduleTaskList));
+        taskRedis.createUrlByTyper(JSON.toJSONString(newsList));
     }
 
     /**

+ 12 - 3
src/main/java/com/mokamrp/privates/task/pangu/SyncCreateCashTask.java

@@ -19,6 +19,7 @@ import org.springframework.stereotype.Component;
 import org.springframework.web.client.RestTemplate;
 
 import java.time.LocalDate;
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -50,7 +51,15 @@ public class SyncCreateCashTask {
 
         List<FosterwxCashAccountSchedule> fosterwxCashAccountSchedules = fosterwxCashAccountScheduleService.list(new LambdaQueryWrapper<FosterwxCashAccountSchedule>().eq(FosterwxCashAccountSchedule::getScheduleDate, nextDay).eq(FosterwxCashAccountSchedule::getStatus, 2));
 
-        fosterwxCashAccountSchedules.forEach(fosterwxCashAccountSchedule -> fosterwxCashAccountScheduleService.createTask(fosterwxCashAccountSchedule.getId()));
+        List<FosterwxCashScheduleTaskList> newsList = new ArrayList<>();
+        fosterwxCashAccountSchedules.forEach(fosterwxCashAccountSchedule -> {
+            List<FosterwxCashScheduleTaskList> list = fosterwxCashAccountScheduleService.createTask(fosterwxCashAccountSchedule.getId());
+            newsList.addAll(list);
+        });
+
+        // 由于不能浪费公众号发文为 需要整合起来一起发送
+        // 调用typer生成链接
+        fosterwxCashScheduleTaskListService.create(newsList);
     }
 
     /**
@@ -101,9 +110,9 @@ public class SyncCreateCashTask {
         fosterwxCashScheduleTaskLists.forEach(fosterwxCashScheduleTaskList -> {
             // 飞书通知消息设置
             content.add(getJsonArray("任务ID:" + fosterwxCashScheduleTaskList.getId() + " 公众号: " + fosterwxCashScheduleTaskList.getGhId() + " 发送时间:" + fosterwxCashScheduleTaskList.getSendTime()));
-            // 重新创建
-            fosterwxCashScheduleTaskListService.create(fosterwxCashScheduleTaskList);
         });
+        // 重新创建
+        fosterwxCashScheduleTaskListService.create(fosterwxCashScheduleTaskLists);
 
         if (content.size() > 0) {
             JSONObject post = new JSONObject();