leon 5 лет назад
Родитель
Сommit
c922fe9134

+ 28 - 26
src/main/java/com/mokamrp/privates/controller/pangu/FosterwxMobileController.java

@@ -98,36 +98,38 @@ public class FosterwxMobileController extends BaseController<FosterwxMobile> {
         return ajaxResult;
     }
 
-    @PutMapping("/edit")
-    @Transactional(rollbackFor = Exception.class)
-    public Object edit(@Valid @RequestBody EditHandle<FosterwxMobile> editHandle, @AuthUser User authUser) {
-        FosterwxMobile fosterwxMobile = editHandle.getRaw();
-        FosterwxMobile oldVO = fosterwxMobileService.getById(editHandle.getIds());
-        // 新增账号
-        fosterwxMobileService.update(fosterwxMobile,new QueryWrapper<FosterwxMobile>().eq("id",editHandle.getIds()));
-        fosterwxMobile = fosterwxMobileService.getById(editHandle.getIds());
-        // 判断开始做任务时间是否设置了
-        AjaxResult ajaxResult = null;
-        if (null != fosterwxMobile.getTaskStartAt()) {
-            if (fosterwxMobile.getWxStatus() != 2) {
-                ajaxResult = fosterwxTaskScheduleService.insertByTaskDate(fosterwxMobile, authUser, false);
+    @PostMapping("/editPro")
+    public Object editPro(@Valid @RequestBody EditHandle<FosterwxMobile> editHandle, @AuthUser User authUser) {
+        String[] ids = editHandle.getIds().split(",");
+        for (String id : ids){
+            FosterwxMobile fosterwxMobile = editHandle.getRaw();
+            FosterwxMobile oldVO = fosterwxMobileService.getById(id);
+            // 新增账号
+            fosterwxMobileService.update(fosterwxMobile,new QueryWrapper<FosterwxMobile>().eq("id",id));
+            fosterwxMobile = fosterwxMobileService.getById(id);
+            // 判断开始做任务时间是否设置了
+            AjaxResult ajaxResult = null;
+            if (null != fosterwxMobile.getTaskStartAt()) {
+                if (fosterwxMobile.getWxStatus() != 2) {
+                    ajaxResult = fosterwxTaskScheduleService.insertByTaskDate(fosterwxMobile, authUser, false);
+                }
+            }
+            // 判断微信状态是否更新为封禁
+            if (fosterwxMobile.getWxStatus() == 2 && oldVO.getWxStatus() == 1) {
+                ajaxResult = fosterwxTaskScheduleService.deleteByDate(fosterwxMobile, authUser);
+            }
+            // 判断微信状态是否更新为正常
+            if (fosterwxMobile.getWxStatus() == 1 && oldVO.getWxStatus() == 2) {
+                ajaxResult = fosterwxTaskScheduleService.insertByTaskDate(fosterwxMobile, authUser, true);
+            }
+            if (ajaxResult != null){
+                return AjaxResult.error(id+"账号批量操作中出现错误");
             }
         }
+        return AjaxResult.success("更新账号成功");
+    }
 
-        // 判断微信状态是否更新为封禁
-        if (fosterwxMobile.getWxStatus() == 2 && oldVO.getWxStatus() == 1) {
-            ajaxResult = fosterwxTaskScheduleService.deleteByDate(fosterwxMobile, authUser);
-        }
-
-        // 判断微信状态是否更新为正常
-        if (fosterwxMobile.getWxStatus() == 1 && oldVO.getWxStatus() == 2) {
-            ajaxResult = fosterwxTaskScheduleService.insertByTaskDate(fosterwxMobile, authUser, true);
-        }
-
-        if (null == ajaxResult) return AjaxResult.success("更新账号成功");
 
-        return ajaxResult;
-    }
 
     /*
      *@Leon 以下接口为站点负责人后台页面接口,需要独立登陆才可访问

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

@@ -5,6 +5,7 @@ import com.mokamrp.privates.mapper.pangu.pojo.FosterwxStation;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.mokamrp.privates.entity.PostBasePageHandle;
 
+import java.util.List;
 import java.util.Map;
 
 /**

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

@@ -174,6 +174,6 @@ public class FosterwxTaskScheduleServiceImpl extends ServiceImpl<FosterwxTaskSch
             fosterwxTaskScheduleMapper.updateById(updateVO);
         }
 
-        return AjaxResult.success("修改成功");
+        return null;
     }
 }

+ 40 - 0
src/main/java/com/mokamrp/privates/tast/pangu/SyncFosterwxTask.java

@@ -0,0 +1,40 @@
+package com.mokamrp.privates.tast.pangu;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.mokamrp.privates.entity.PostBasePageHandle;
+import com.mokamrp.privates.mapper.data.pojo.PanCSLTRecord;
+import com.mokamrp.privates.mapper.data.pojo.PanCSTQRecord;
+import com.mokamrp.privates.mapper.pangu.pojo.FosterwxStation;
+import com.mokamrp.privates.mapper.pangu.pojo.PromoteQrcodePoolRecord;
+import com.mokamrp.privates.service.data.PanCSLTRecordService;
+import com.mokamrp.privates.service.data.PanCSTQRecordService;
+import com.mokamrp.privates.service.pangu.FosterwxStationService;
+import com.mokamrp.privates.service.pangu.FosterwxTaskScheduleService;
+import com.mokamrp.privates.service.pangu.PromoteQrcodePoolRecordService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.stereotype.Component;
+
+import java.util.List;
+
+@Component
+public class SyncFosterwxTask {
+
+    @Autowired
+    public FosterwxTaskScheduleService fosterwxTaskScheduleService;
+
+    @Autowired
+    public FosterwxStationService fosterwxStationService;
+
+    @Scheduled(cron = "0 */30 * * * ?")
+    public void execute() {
+        System.out.println("[cronjob]:同步微信养号任务到REDIS");
+        PostBasePageHandle postBasePageHandle = new PostBasePageHandle();
+        postBasePageHandle.setPage(1);
+        postBasePageHandle.setPagesize(9999999);
+        List<FosterwxStation> fosterwxStationList = fosterwxStationService.list();
+        for (FosterwxStation fosterwxStation : fosterwxStationList){
+            fosterwxTaskScheduleService.getList(postBasePageHandle,"",fosterwxStation.getId(),"2021-07-24");
+        }
+    }
+}