Преглед изворни кода

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

leon пре 4 година
родитељ
комит
b78f728b15

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

@@ -1,5 +1,6 @@
 package com.mokamrp.privates.controller.pangu;
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.mokamrp.privates.constant.HttpStatus;
 import com.mokamrp.privates.controller.BaseController;
 import com.mokamrp.privates.entity.ResHandle;
@@ -9,6 +10,7 @@ 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.pojo.User;
 import com.mokamrp.privates.service.pangu.FosterwxCashAccountScheduleService;
 import com.mokamrp.privates.service.pangu.FosterwxCashScheduleTaskListService;
@@ -136,7 +138,15 @@ public class FosterwxCashAccountScheduleController extends BaseController<Foster
     @PostMapping("/cancelTask")
     @ApiOperation(value = "取消任务按钮")
     public Object cancelTask(FosterwxCashAccountScheduleHandle handle, @AuthUser User user) {
-        Arrays.asList(handle.getIds().split(REGEX)).forEach(id -> fosterwxCashScheduleTaskListService.cancelTask(Integer.valueOf(id), user.getId()));
+        Arrays.asList(handle.getIds().split(REGEX)).forEach(id -> {
+            LambdaQueryWrapper<FosterwxCashScheduleTaskList> fosterwxCashScheduleTaskListLambdaQueryWrapper = new LambdaQueryWrapper<>();
+            fosterwxCashScheduleTaskListLambdaQueryWrapper.eq(FosterwxCashScheduleTaskList::getScheduleId, id);
+            fosterwxCashScheduleTaskListLambdaQueryWrapper.notIn(FosterwxCashScheduleTaskList::getStatus, 3, 5, 6);
+
+            List<FosterwxCashScheduleTaskList> fosterwxCashScheduleTaskLists = fosterwxCashScheduleTaskListService.list(fosterwxCashScheduleTaskListLambdaQueryWrapper);
+            fosterwxCashScheduleTaskLists.forEach(fosterwxCashScheduleTaskList -> fosterwxCashScheduleTaskListService.cancelTask(fosterwxCashScheduleTaskList.getId(), user.getId()));
+
+        });
 
         return AjaxResult.success("取消任务成功");
     }

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

@@ -2,12 +2,15 @@ package com.mokamrp.privates.controller.pangu;
 
 import com.mokamrp.privates.constant.HttpStatus;
 import com.mokamrp.privates.controller.BaseController;
-import com.mokamrp.privates.entity.PostBasePageHandle;
 import com.mokamrp.privates.entity.ResHandle;
+import com.mokamrp.privates.entity.pangu.FosterwxCashScheduleTaskListHandle;
 import com.mokamrp.privates.help.AjaxResult;
+import com.mokamrp.privates.interceptor.AuthUser;
 import com.mokamrp.privates.mapper.pangu.pojo.FosterwxCashScheduleTaskList;
+import com.mokamrp.privates.mapper.pojo.User;
 import com.mokamrp.privates.service.pangu.FosterwxCashScheduleTaskListService;
 import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.validation.BindingResult;
 import org.springframework.web.bind.annotation.PostMapping;
@@ -16,6 +19,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
 import javax.validation.Valid;
+import java.util.Arrays;
 import java.util.List;
 
 
@@ -32,6 +36,8 @@ import java.util.List;
 @Api(tags = "变现-任务列表")
 public class FosterwxCashScheduleTaskListController extends BaseController<FosterwxCashScheduleTaskList> {
 
+    public static final String REGEX = ",";
+
     @Autowired
     public FosterwxCashScheduleTaskListService fosterwxCashScheduleTaskListService;
 
@@ -42,14 +48,29 @@ public class FosterwxCashScheduleTaskListController extends BaseController<Foste
      */
 
     @PostMapping("/list")
-    public Object list(@Valid @RequestBody PostBasePageHandle postBasePageHandle, BindingResult bindingResult) {
+    @ApiOperation(value = "获取任务列表")
+    public Object list(@Valid @RequestBody FosterwxCashScheduleTaskListHandle handle, BindingResult bindingResult) {
         if (bindingResult.hasErrors()) {
             return AjaxResult.error(HttpStatus.ERROR, bindingResult.getFieldError().getDefaultMessage());
         }
-        ResHandle<List<FosterwxCashScheduleTaskList>> res = fosterwxCashScheduleTaskListService.getList(postBasePageHandle);
+        ResHandle<List<FosterwxCashScheduleTaskList>> res = fosterwxCashScheduleTaskListService.getList(handle);
         return AjaxResult.success(res);
     }
 
+    @PostMapping("/cancelTask")
+    @ApiOperation(value = "取消任务按钮")
+    public Object cancelTask(FosterwxCashScheduleTaskListHandle handle, @AuthUser User user) {
+        Arrays.asList(handle.getIds().split(REGEX)).forEach(id -> fosterwxCashScheduleTaskListService.cancelTask(Integer.valueOf(id), user.getId()));
+
+        return AjaxResult.success("取消任务成功");
+    }
 
+    @PostMapping("/reCreate")
+    @ApiOperation("重新生成")
+    public Object reCreate(FosterwxCashScheduleTaskList fosterwxCashScheduleTaskList) {
+        //TODO 等typer接口
+
+        return AjaxResult.success("重新生成成功");
+    }
 }
 

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

@@ -1,7 +1,9 @@
 package com.mokamrp.privates.entity.pangu;
 
-import com.baomidou.mybatisplus.extension.activerecord.Model;
 import lombok.Data;
+import lombok.NonNull;
+
+import java.time.LocalDate;
 
 /**
  * <p>
@@ -12,7 +14,7 @@ import lombok.Data;
  * @since 2021-10-08
  */
 @Data
-public class FosterwxCashAccountScheduleHandle extends Model<FosterwxCashAccountScheduleHandle> {
+public class FosterwxCashAccountScheduleHandle {
     private Integer page;
     private Integer pageSize;
     private Integer id;
@@ -21,4 +23,5 @@ public class FosterwxCashAccountScheduleHandle extends Model<FosterwxCashAccount
     private Integer createUid;
     private String createUser;
     private String ids;
+    private LocalDate scheduleDate;
 }

+ 28 - 0
src/main/java/com/mokamrp/privates/entity/pangu/FosterwxCashScheduleTaskListHandle.java

@@ -0,0 +1,28 @@
+package com.mokamrp.privates.entity.pangu;
+
+import lombok.Data;
+
+import java.time.LocalDateTime;
+
+/**
+ * <p>
+ * 盘古微信变现排期任务列表
+ * </p>
+ *
+ * @author leon
+ * @since 2021-10-08
+ */
+@Data
+public class FosterwxCashScheduleTaskListHandle {
+    private Integer page;
+    private Integer pageSize;
+    private Integer id;
+    private Integer templateId;
+    private Integer groupId;
+    private Integer taskType;
+    private Integer status;
+    private LocalDateTime sendTimeFrom;
+    private LocalDateTime sendTimeTo;
+    private Integer createUid;
+    private String ids;
+}

+ 5 - 4
src/main/java/com/mokamrp/privates/mapper/pangu/FosterwxCashScheduleTaskListMapper.java

@@ -1,10 +1,11 @@
 package com.mokamrp.privates.mapper.pangu;
 
-import com.mokamrp.privates.mapper.pangu.pojo.FosterwxCashScheduleTaskList;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import org.springframework.stereotype.Component;
+import com.mokamrp.privates.mapper.pangu.pojo.FosterwxCashScheduleTaskList;
 import org.apache.ibatis.annotations.Param;
+import org.springframework.stereotype.Component;
+
 import java.util.List;
 
 /**
@@ -17,5 +18,5 @@ import java.util.List;
  */
 @Component
 public interface FosterwxCashScheduleTaskListMapper extends BaseMapper<FosterwxCashScheduleTaskList> {
-    public List<FosterwxCashScheduleTaskList> getList(Page<FosterwxCashScheduleTaskList> pageObj);
+    public List<FosterwxCashScheduleTaskList> getList(@Param("ew") LambdaQueryWrapper<FosterwxCashScheduleTaskList> fosterwxCashScheduleTaskListLambdaQueryWrapper, @Param("limit") Integer page, @Param("offset") Integer offset);
 }

+ 20 - 1
src/main/java/com/mokamrp/privates/mapper/pangu/FosterwxCashScheduleTaskListMapper.xml

@@ -26,6 +26,25 @@
         id, schedule_id, template_id, group_id, task_type, remark, task_content, status, err_info, send_time, create_uid, update_uid, create_at, update_at
     </sql>
     <select id="getList" resultType="com.mokamrp.privates.mapper.pangu.pojo.FosterwxCashScheduleTaskList">
-        SELECT * FROM pan_fosterwx_cash_schedule_task_list
+        SELECT
+            task_list.id,
+            task_template.template_name,
+            mobile_group.group_name,
+            task_list.task_type,
+            task_list.remark,
+            task_list.task_content,
+            task_list.`status`,
+            task_list.err_info,
+            task_list.create_user,
+            task_list.send_time
+        FROM
+            pan_fosterwx_cash_schedule_task_list task_list
+                LEFT JOIN pan_fosterwx_cash_task_template task_template ON task_template.id = task_list.template_id
+                LEFT JOIN pan_fosterwx_cash_mobile_group mobile_group ON task_list.group_id = mobile_group.id
+        <where>
+            ${ew.sqlSegment}
+        </where>
+        order by task_list.id desc
+        limit #{limit} offset #{offset}
     </select>
 </mapper>

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

@@ -1,8 +1,8 @@
 package com.mokamrp.privates.service.pangu;
 
 import com.baomidou.mybatisplus.extension.service.IService;
-import com.mokamrp.privates.entity.PostBasePageHandle;
 import com.mokamrp.privates.entity.ResHandle;
+import com.mokamrp.privates.entity.pangu.FosterwxCashScheduleTaskListHandle;
 import com.mokamrp.privates.mapper.pangu.pojo.FosterwxCashScheduleTaskList;
 
 import java.util.List;
@@ -17,7 +17,7 @@ import java.util.List;
  */
 public interface FosterwxCashScheduleTaskListService extends IService<FosterwxCashScheduleTaskList> {
     //.@leon 获取数据列表
-    public ResHandle<List<FosterwxCashScheduleTaskList>> getList(PostBasePageHandle handle);
+    public ResHandle<List<FosterwxCashScheduleTaskList>> getList(FosterwxCashScheduleTaskListHandle handle);
 
 
     /**

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

@@ -8,10 +8,10 @@ import com.mokamrp.privates.mapper.pangu.FosterwxCashAccountScheduleMapper;
 import com.mokamrp.privates.mapper.pangu.pojo.FosterwxCashAccountSchedule;
 import com.mokamrp.privates.mapper.pangu.pojo.FosterwxCashTaskList;
 import com.mokamrp.privates.service.pangu.FosterwxCashAccountScheduleService;
+import com.mokamrp.privates.service.pangu.FosterwxCashTaskTemplateService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
-import java.util.ArrayList;
 import java.util.List;
 
 /**
@@ -28,6 +28,9 @@ public class FosterwxCashAccountScheduleServiceImpl extends ServiceImpl<Fosterwx
     @Autowired
     public FosterwxCashAccountScheduleMapper fosterwxCashAccountScheduleMapper;
 
+    @Autowired
+    public FosterwxCashTaskTemplateService fosterwxCashTaskTemplateService;
+
     /**
      * 获取数据列表 支持分页
      * @param handle
@@ -37,6 +40,7 @@ public class FosterwxCashAccountScheduleServiceImpl extends ServiceImpl<Fosterwx
         Integer pagesize = handle.getPageSize();
         Integer page = handle.getPage();
         LambdaQueryWrapper<FosterwxCashAccountSchedule> fosterwxCashAccountScheduleLambdaQueryWrapper = new LambdaQueryWrapper<>();
+        fosterwxCashAccountScheduleLambdaQueryWrapper.eq(FosterwxCashAccountSchedule::getScheduleDate, handle.getScheduleDate());
         // 任务模板
         if (null != handle.getTemplateId())
             fosterwxCashAccountScheduleLambdaQueryWrapper.eq(FosterwxCashAccountSchedule::getTemplateId, handle.getTemplateId());
@@ -66,10 +70,9 @@ public class FosterwxCashAccountScheduleServiceImpl extends ServiceImpl<Fosterwx
 
         if (null != fosterwxCashAccountSchedule) {
             // 根据任务模板id获取任务模板详情
-            // TODO 需要老王那边配合写个方法
-            List<FosterwxCashTaskList> fosterwxCashTaskLists = new ArrayList<>();
+            ResHandle<List<FosterwxCashTaskList>> resHandle = fosterwxCashTaskTemplateService.getTaskByTemplateId(fosterwxCashAccountSchedule.getId());
 
-            fosterwxCashTaskLists.forEach(fosterwxCashTaskList -> {
+            resHandle.getList().forEach(fosterwxCashTaskList -> {
 
             });
         }

+ 25 - 13
src/main/java/com/mokamrp/privates/service/pangu/impl/FosterwxCashScheduleTaskListServiceImpl.java

@@ -1,10 +1,9 @@
 package com.mokamrp.privates.service.pangu.impl;
 
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.mokamrp.privates.entity.PostBasePageHandle;
 import com.mokamrp.privates.entity.ResHandle;
+import com.mokamrp.privates.entity.pangu.FosterwxCashScheduleTaskListHandle;
 import com.mokamrp.privates.mapper.pangu.FosterwxCashScheduleTaskListMapper;
 import com.mokamrp.privates.mapper.pangu.pojo.FosterwxCashScheduleTaskList;
 import com.mokamrp.privates.service.pangu.FosterwxCashScheduleTaskListService;
@@ -33,14 +32,30 @@ public class FosterwxCashScheduleTaskListServiceImpl extends ServiceImpl<Fosterw
      * @param handle
      * @return
      */
-    public ResHandle<List<FosterwxCashScheduleTaskList>> getList(PostBasePageHandle handle) {
-        Integer pagesize = handle.getPagesize();
+    public ResHandle<List<FosterwxCashScheduleTaskList>> getList(FosterwxCashScheduleTaskListHandle handle) {
+        Integer pagesize = handle.getPageSize();
         Integer page = handle.getPage();
-        Page<FosterwxCashScheduleTaskList> pageObj = new Page<FosterwxCashScheduleTaskList>(page, pagesize);
-        List<FosterwxCashScheduleTaskList> list = fosterwxCashScheduleTaskListMapper.getList(pageObj);
+        LambdaQueryWrapper<FosterwxCashScheduleTaskList> fosterwxCashScheduleTaskListLambdaQueryWrapper = new LambdaQueryWrapper<>();
+        // 任务模板名称
+        if (null != handle.getTemplateId())
+            fosterwxCashScheduleTaskListLambdaQueryWrapper.eq(FosterwxCashScheduleTaskList::getTemplateId, handle.getTemplateId());
+        // 创建人
+        if (null != handle.getCreateUid())
+            fosterwxCashScheduleTaskListLambdaQueryWrapper.eq(FosterwxCashScheduleTaskList::getCreateUid, handle.getCreateUid());
+        // 状态
+        if (null != handle.getStatus())
+            fosterwxCashScheduleTaskListLambdaQueryWrapper.eq(FosterwxCashScheduleTaskList::getStatus, handle.getStatus());
+        // 发送日期
+        if (null != handle.getSendTimeFrom() && null != handle.getSendTimeTo())
+            fosterwxCashScheduleTaskListLambdaQueryWrapper.between(FosterwxCashScheduleTaskList::getSendTime, handle.getSendTimeFrom(), handle.getSendTimeTo());
+        // 账号分组
+        if (null != handle.getGroupId())
+            fosterwxCashScheduleTaskListLambdaQueryWrapper.eq(FosterwxCashScheduleTaskList::getGroupId, handle.getGroupId());
+
+        List<FosterwxCashScheduleTaskList> list = fosterwxCashScheduleTaskListMapper.getList(fosterwxCashScheduleTaskListLambdaQueryWrapper, pagesize, (page - 1) * pagesize);
         ResHandle<List<FosterwxCashScheduleTaskList>> res = new ResHandle<>();
         res.setList(list);
-        res.setTotal(pageObj.getTotal());
+        res.setTotal(Long.valueOf(fosterwxCashScheduleTaskListMapper.selectCount(fosterwxCashScheduleTaskListLambdaQueryWrapper)));
         return res;
     }
 
@@ -51,14 +66,11 @@ public class FosterwxCashScheduleTaskListServiceImpl extends ServiceImpl<Fosterw
      */
     @Override
     public void cancelTask(Integer id, Integer userId) {
-        LambdaQueryWrapper<FosterwxCashScheduleTaskList> fosterwxCashScheduleTaskListLambdaQueryWrapper = new LambdaQueryWrapper<>();
-        fosterwxCashScheduleTaskListLambdaQueryWrapper.eq(FosterwxCashScheduleTaskList::getScheduleId, id);
-        fosterwxCashScheduleTaskListLambdaQueryWrapper.notIn(FosterwxCashScheduleTaskList::getStatus, 3, 5, 6);
-
-        fosterwxCashScheduleTaskListMapper.update(new FosterwxCashScheduleTaskList() {{
+        fosterwxCashScheduleTaskListMapper.updateById(new FosterwxCashScheduleTaskList() {{
+            setId(id);
             setStatus(6);
             setUpdateUid(userId);
             setUpdateAt(LocalDateTime.now());
-        }}, fosterwxCashScheduleTaskListLambdaQueryWrapper);
+        }});
     }
 }

+ 30 - 0
src/main/java/com/mokamrp/privates/task/pangu/SyncCreateCashTask.java

@@ -0,0 +1,30 @@
+package com.mokamrp.privates.task.pangu;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.mokamrp.privates.mapper.pangu.pojo.FosterwxCashAccountSchedule;
+import com.mokamrp.privates.service.pangu.FosterwxCashAccountScheduleService;
+import net.javacrumbs.shedlock.core.SchedulerLock;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.Scheduled;
+
+import java.time.LocalDate;
+import java.util.List;
+
+/**
+ * 每天五点定时生成第二天的任务列表
+ */
+public class SyncCreateCashTask {
+    @Autowired
+    private FosterwxCashAccountScheduleService fosterwxCashAccountScheduleService;
+
+    @Scheduled(cron = "0 0 17 * * ?")
+    @SchedulerLock(name = "pangu:SyncCreateCashTask", lockAtLeastForString = "PT5S", lockAtMostForString = "PT15M")
+    public void execute() {
+        // 获取明天日期
+        LocalDate nextDay = LocalDate.now().plusDays(1);
+
+        List<FosterwxCashAccountSchedule> fosterwxCashAccountSchedules = fosterwxCashAccountScheduleService.list(new LambdaQueryWrapper<FosterwxCashAccountSchedule>().eq(FosterwxCashAccountSchedule::getScheduleDate, nextDay));
+
+        fosterwxCashAccountSchedules.forEach(fosterwxCashAccountSchedule -> fosterwxCashAccountScheduleService.createTask(fosterwxCashAccountSchedule.getId()));
+    }
+}