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

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

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

+ 18 - 8
src/main/java/com/mokamrp/privates/controller/pangu/FosterwxCashAccountScheduleController.java

@@ -6,15 +6,16 @@ import com.mokamrp.privates.controller.BaseController;
 import com.mokamrp.privates.entity.ResHandle;
 import com.mokamrp.privates.entity.VoltaHandle;
 import com.mokamrp.privates.entity.pangu.FosterwxCashAccountScheduleHandle;
+import com.mokamrp.privates.entity.pangu.FosterwxCashScheduleTaskListHandle;
 import com.mokamrp.privates.help.AjaxResult;
 import com.mokamrp.privates.help.Analysis;
 import com.mokamrp.privates.interceptor.AuthUser;
 import com.mokamrp.privates.mapper.pangu.pojo.FosterwxCashAccountSchedule;
 import com.mokamrp.privates.mapper.pangu.pojo.FosterwxCashScheduleTaskList;
-import com.mokamrp.privates.mapper.pangu.pojo.FosterwxCashTaskList;
 import com.mokamrp.privates.mapper.pojo.User;
 import com.mokamrp.privates.service.pangu.FosterwxCashAccountScheduleService;
 import com.mokamrp.privates.service.pangu.FosterwxCashScheduleTaskListService;
+import com.mokamrp.privates.service.pangu.FosterwxCashTaskListService;
 import com.mokamrp.privates.service.pangu.FosterwxCashTaskTemplateService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
@@ -56,6 +57,9 @@ public class FosterwxCashAccountScheduleController extends BaseController<Foster
     @Autowired
     public FosterwxCashTaskTemplateService fosterwxCashTaskTemplateService;
 
+    @Autowired
+    public FosterwxCashTaskListService fosterwxCashTaskListService;
+
     /*
      * @fast
      * 默认生成的控制器所继承的父类中有index/add/edit/del四个基础方法,均为post json请求
@@ -125,8 +129,8 @@ public class FosterwxCashAccountScheduleController extends BaseController<Foster
 
     @PostMapping("/immediateCreate")
     @Transactional(rollbackFor = Exception.class)
-    @ApiOperation(value = "立即生成")
-    public Object immediateCreate(FosterwxCashAccountScheduleHandle handle) {
+    @ApiOperation(value = "生成")
+    public Object immediateCreate(@RequestBody FosterwxCashAccountScheduleHandle handle) {
         Arrays.asList(handle.getIds().split(REGEX)).forEach(id -> {
             List<FosterwxCashScheduleTaskList> newsList = fosterwxCashAccountScheduleService.createTask(Integer.valueOf(id));
             // 由于不能浪费公众号发文为 需要整合起来一起发送
@@ -134,20 +138,26 @@ public class FosterwxCashAccountScheduleController extends BaseController<Foster
             fosterwxCashScheduleTaskListService.create(newsList);
         });
 
-        return AjaxResult.success("立即生成成功");
+        return AjaxResult.success("生成成功");
     }
 
     @PostMapping("/preview")
-    @ApiOperation(value = "预览按钮")
-    public Object priview(FosterwxCashAccountScheduleHandle handle) {
-        ResHandle<List<FosterwxCashTaskList>> resHandle = fosterwxCashTaskTemplateService.getTaskByTemplateId(handle.getTemplateId());
+    @ApiOperation(value = "预览按钮 只需要传任务排期的id")
+    public Object priview(@RequestBody FosterwxCashAccountScheduleHandle handle) {
+        FosterwxCashScheduleTaskListHandle fosterwxCashScheduleTaskListHandle = new FosterwxCashScheduleTaskListHandle();
+        fosterwxCashScheduleTaskListHandle.setPage(1);
+        fosterwxCashScheduleTaskListHandle.setPageSize(100000);
+        fosterwxCashScheduleTaskListHandle.setScheduleId(handle.getId());
+        ResHandle<List<FosterwxCashScheduleTaskList>> resHandle = fosterwxCashScheduleTaskListService.getList(fosterwxCashScheduleTaskListHandle);
+
+        resHandle.getList().forEach(fosterwxCashScheduleTaskList -> fosterwxCashScheduleTaskList.setFosterwxCashTaskList(fosterwxCashTaskListService.getById(fosterwxCashScheduleTaskList.getTaskId())));
 
         return AjaxResult.success(resHandle);
     }
 
     @PostMapping("/cancelTask")
     @ApiOperation(value = "取消任务按钮")
-    public Object cancelTask(FosterwxCashAccountScheduleHandle handle, @AuthUser User user) {
+    public Object cancelTask(@RequestBody FosterwxCashAccountScheduleHandle handle, @AuthUser User user) {
         Arrays.asList(handle.getIds().split(REGEX)).forEach(id -> {
             fosterwxCashAccountScheduleService.updateById(new FosterwxCashAccountSchedule() {{
                 setId(Integer.valueOf(id));

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

@@ -59,7 +59,7 @@ public class FosterwxCashScheduleTaskListController extends BaseController<Foste
 
     @PostMapping("/cancelTask")
     @ApiOperation(value = "取消任务按钮")
-    public Object cancelTask(FosterwxCashScheduleTaskListHandle handle, @AuthUser User user) {
+    public Object cancelTask(@RequestBody FosterwxCashScheduleTaskListHandle handle, @AuthUser User user) {
         Arrays.asList(handle.getIds().split(REGEX)).forEach(id -> fosterwxCashScheduleTaskListService.cancelTask(Integer.valueOf(id), user.getId()));
 
         return AjaxResult.success("取消任务成功");

+ 1 - 0
src/main/java/com/mokamrp/privates/service/pangu/impl/FosterwxCashAccountScheduleServiceImpl.java

@@ -104,6 +104,7 @@ public class FosterwxCashAccountScheduleServiceImpl extends ServiceImpl<Fosterwx
                 fosterwxCashScheduleTaskList.setRemark(fosterwxCashTaskList.getRemark());
                 fosterwxCashScheduleTaskList.setTaskContent("");
                 fosterwxCashScheduleTaskList.setGhId("");
+                fosterwxCashScheduleTaskList.setSendUrl("");
                 fosterwxCashScheduleTaskList.setStatus(1);
                 fosterwxCashScheduleTaskList.setErrInfo("");
                 fosterwxCashScheduleTaskList.setSendTime(LocalDateTime.of(fosterwxCashAccountSchedule.getScheduleDate(), fosterwxCashTaskList.getSendAt()));

+ 4 - 1
src/main/java/com/mokamrp/privates/service/pangu/impl/FosterwxCashScheduleTaskListServiceImpl.java

@@ -101,6 +101,7 @@ public class FosterwxCashScheduleTaskListServiceImpl extends ServiceImpl<Fosterw
         if (newsList.isEmpty()) return;
 
         String ghid = "";
+        Integer groupId = newsList.get(0).getGroupId();
         FosterwxCashOasBox fosterwxCashOasBox = fosterwxCashOasBoxService.getRandOas(newsList.get(0).getGroupId());
         if (null != fosterwxCashOasBox) {
             ghid = fosterwxCashOasBox.getGhId();
@@ -127,6 +128,8 @@ public class FosterwxCashScheduleTaskListServiceImpl extends ServiceImpl<Fosterw
             fosterwxCashScheduleTaskList.setErrInfo("");
             // 分配的公众号
             fosterwxCashScheduleTaskList.setGhId(ghid);
+            // 发文链接
+            fosterwxCashScheduleTaskList.setSendUrl("");
 
             fosterwxCashScheduleTaskListMapper.updateById(fosterwxCashScheduleTaskList);
             fosterwxCashScheduleTaskList.setFosterwxCashTaskList(fosterwxCashTaskListService.getById(fosterwxCashScheduleTaskList.getTaskId()));
@@ -135,7 +138,7 @@ public class FosterwxCashScheduleTaskListServiceImpl extends ServiceImpl<Fosterw
             newsList.remove(i);
             i--;
         }
-        fosterwxCashOasBoxService.addSendTextCnt(newsList.get(0).getGroupId(), ghid);
+        fosterwxCashOasBoxService.addSendTextCnt(groupId, ghid);
         taskRedis.createUrlByTyper(JSON.toJSONString(tempList));
         tempList.clear();
     }

+ 19 - 0
src/main/java/com/mokamrp/privates/task/pangu/SyncFosterwxCash.java

@@ -3,6 +3,7 @@ package com.mokamrp.privates.task.pangu;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.mokamrp.privates.mapper.pangu.pojo.FosterwxCashScheduleTaskList;
 import com.mokamrp.privates.service.pangu.FosterwxCashScheduleTaskListService;
+import com.mokamrp.privates.utils.pangu.redis.task.TaskRedis;
 import lombok.extern.slf4j.Slf4j;
 import net.javacrumbs.shedlock.core.SchedulerLock;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -27,6 +28,9 @@ public class SyncFosterwxCash {
     @Autowired
     private FosterwxCashScheduleTaskListService fosterwxCashScheduleTaskListService;
 
+    @Autowired
+    private TaskRedis taskRedis;
+
     /**
      * 每隔一分钟扫描今天待发送以及已经发送的任务
      */
@@ -44,4 +48,19 @@ public class SyncFosterwxCash {
 
         stringRedisTemplate.opsForHash().put("pan_fosterwx_cash_group_id:", null, null);
     }
+
+    /**
+     * 定时同步typer已经生成的url
+     */
+    @Scheduled(cron = "20 */1 * * * ?")
+    @SchedulerLock(name = "pangu:SyncCreatedUrlInfo", lockAtLeastForString = "PT5S", lockAtMostForString = "PT15M")
+    public void syncCreatedUrlInfo() {
+        String urlInfo = taskRedis.getPanguCashTaskInfo();
+        while (urlInfo != null) {
+            // 根据获取的信息保存到本地数据库
+            // TODO 需要根据typer返回的redis结构具体生成
+
+            urlInfo = taskRedis.getPanguCashTaskInfo();
+        }
+    }
 }

+ 5 - 1
src/main/java/com/mokamrp/privates/utils/pangu/redis/task/TaskRedis.java

@@ -19,8 +19,12 @@ public class TaskRedis {
      * @param json
      */
     public void createUrlByTyper(String json) {
-
         // 把数据存放到redis缓存中
         stringRedisTemplate.opsForList().leftPush(PANGU_CASH_TASK_INFO, json);
     }
+
+    public String getPanguCashTaskInfo() {
+        // 获取生成链接的结果
+        return stringRedisTemplate.opsForList().rightPop(PANGU_CASH_CREATED_URL);
+    }
 }