|
@@ -1,17 +1,23 @@
|
|
|
package com.mokamrp.privates.controller.pangu;
|
|
package com.mokamrp.privates.controller.pangu;
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.mokamrp.privates.constant.Constants;
|
|
import com.mokamrp.privates.constant.Constants;
|
|
|
import com.mokamrp.privates.constant.HttpMsg;
|
|
import com.mokamrp.privates.constant.HttpMsg;
|
|
|
import com.mokamrp.privates.constant.HttpStatus;
|
|
import com.mokamrp.privates.constant.HttpStatus;
|
|
|
import com.mokamrp.privates.controller.BaseController;
|
|
import com.mokamrp.privates.controller.BaseController;
|
|
|
|
|
+import com.mokamrp.privates.entity.AddHandle;
|
|
|
import com.mokamrp.privates.entity.PostBasePageHandle;
|
|
import com.mokamrp.privates.entity.PostBasePageHandle;
|
|
|
import com.mokamrp.privates.help.AjaxResult;
|
|
import com.mokamrp.privates.help.AjaxResult;
|
|
|
import com.mokamrp.privates.help.Analysis;
|
|
import com.mokamrp.privates.help.Analysis;
|
|
|
import com.mokamrp.privates.interceptor.AuthUser;
|
|
import com.mokamrp.privates.interceptor.AuthUser;
|
|
|
|
|
+import com.mokamrp.privates.mapper.pangu.pojo.FosterwxMobile;
|
|
|
import com.mokamrp.privates.mapper.pangu.pojo.FosterwxTaskList;
|
|
import com.mokamrp.privates.mapper.pangu.pojo.FosterwxTaskList;
|
|
|
|
|
+import com.mokamrp.privates.mapper.pangu.pojo.FosterwxTaskSchedule;
|
|
|
import com.mokamrp.privates.mapper.pojo.User;
|
|
import com.mokamrp.privates.mapper.pojo.User;
|
|
|
|
|
+import com.mokamrp.privates.service.pangu.FosterwxMobileService;
|
|
|
import com.mokamrp.privates.service.pangu.FosterwxTaskListService;
|
|
import com.mokamrp.privates.service.pangu.FosterwxTaskListService;
|
|
|
|
|
+import com.mokamrp.privates.service.pangu.FosterwxTaskScheduleService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.validation.BindingResult;
|
|
import org.springframework.validation.BindingResult;
|
|
@@ -20,10 +26,7 @@ import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
|
|
import javax.validation.Valid;
|
|
import javax.validation.Valid;
|
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
|
-import java.util.ArrayList;
|
|
|
|
|
-import java.util.HashMap;
|
|
|
|
|
-import java.util.List;
|
|
|
|
|
-import java.util.Map;
|
|
|
|
|
|
|
+import java.util.*;
|
|
|
import java.util.concurrent.atomic.AtomicInteger;
|
|
import java.util.concurrent.atomic.AtomicInteger;
|
|
|
|
|
|
|
|
|
|
|
|
@@ -42,6 +45,12 @@ public class FosterwxTaskListController extends BaseController<FosterwxTaskList>
|
|
|
@Autowired
|
|
@Autowired
|
|
|
public FosterwxTaskListService fosterwxTaskListService;
|
|
public FosterwxTaskListService fosterwxTaskListService;
|
|
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private FosterwxTaskScheduleService fosterwxTaskScheduleService;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private FosterwxMobileService fosterwxMobileService;
|
|
|
|
|
+
|
|
|
/*
|
|
/*
|
|
|
* @fast
|
|
* @fast
|
|
|
* 默认生成的控制器所继承的父类中有index/add/edit/del四个基础方法,均为post json请求
|
|
* 默认生成的控制器所继承的父类中有index/add/edit/del四个基础方法,均为post json请求
|
|
@@ -76,6 +85,49 @@ public class FosterwxTaskListController extends BaseController<FosterwxTaskList>
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @PostMapping("/add")
|
|
|
|
|
+ public Object add(@Valid @RequestBody AddHandle<FosterwxTaskList> addHandle, BindingResult bindingResult, @AuthUser User authUser) {
|
|
|
|
|
+ if (bindingResult.hasErrors()) {
|
|
|
|
|
+ return AjaxResult.error(HttpStatus.ERROR, bindingResult.getFieldError().getDefaultMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+ this.onInsert(addHandle.getRaw());
|
|
|
|
|
+ Boolean res = service.save(addHandle.getRaw());
|
|
|
|
|
+
|
|
|
|
|
+ // 获取新插入的数据
|
|
|
|
|
+ LambdaQueryWrapper<FosterwxTaskList> fosterwxTaskListLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
|
|
+ fosterwxTaskListLambdaQueryWrapper.eq(FosterwxTaskList::getTemplateId, addHandle.getRaw().getTemplateId());
|
|
|
|
|
+ fosterwxTaskListLambdaQueryWrapper.eq(FosterwxTaskList::getTaskName, addHandle.getRaw().getTaskName());
|
|
|
|
|
+ fosterwxTaskListLambdaQueryWrapper.last("Limit 1");
|
|
|
|
|
+
|
|
|
|
|
+ FosterwxTaskList fosterwxTaskList = fosterwxTaskListService.getOne(fosterwxTaskListLambdaQueryWrapper);
|
|
|
|
|
+
|
|
|
|
|
+ // 获取绑定了该模板的所有站点和账号
|
|
|
|
|
+ QueryWrapper<FosterwxTaskSchedule> fosterwxTaskScheduleQueryWrapper = new QueryWrapper<>();
|
|
|
|
|
+ fosterwxTaskScheduleQueryWrapper.select("distinct station_id,mobile_code");
|
|
|
|
|
+ fosterwxTaskScheduleQueryWrapper.eq("template_id", addHandle.getRaw().getTemplateId());
|
|
|
|
|
+ List<FosterwxTaskSchedule> fosterwxTaskScheduleList = fosterwxTaskScheduleService.list(fosterwxTaskScheduleQueryWrapper);
|
|
|
|
|
+
|
|
|
|
|
+ for (FosterwxTaskSchedule fosterwxTaskSchedule : fosterwxTaskScheduleList) {
|
|
|
|
|
+ // 判断该站点的账号是否已经养号完成
|
|
|
|
|
+ LambdaQueryWrapper<FosterwxMobile> fosterwxMobileLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
|
|
+ fosterwxMobileLambdaQueryWrapper.eq(FosterwxMobile::getStationId, fosterwxTaskSchedule.getStationId());
|
|
|
|
|
+ fosterwxMobileLambdaQueryWrapper.eq(FosterwxMobile::getMobileCode, fosterwxTaskSchedule.getMobileCode());
|
|
|
|
|
+ fosterwxMobileLambdaQueryWrapper.last("Limit 1");
|
|
|
|
|
+ FosterwxMobile fosterwxMobile = fosterwxMobileService.getOne(fosterwxMobileLambdaQueryWrapper);
|
|
|
|
|
+
|
|
|
|
|
+ // 完成或者封禁的状态下不新增任务
|
|
|
|
|
+ if (Arrays.asList("2,3,4,5".split(",")).contains(fosterwxMobile.getStatus())) continue;
|
|
|
|
|
+
|
|
|
|
|
+ fosterwxTaskScheduleService.insertByTaskDate(fosterwxMobile, authUser, true);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (res) {
|
|
|
|
|
+ return AjaxResult.success(Constants.SUCCESS, res);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ return AjaxResult.error("新增失败", res);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 导入
|
|
* 导入
|
|
|
*
|
|
*
|