|
@@ -1,26 +1,25 @@
|
|
|
package com.mokamrp.privates.controller.pangu;
|
|
package com.mokamrp.privates.controller.pangu;
|
|
|
|
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
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.ResHandle;
|
|
import com.mokamrp.privates.entity.ResHandle;
|
|
|
import com.mokamrp.privates.entity.VoltaHandle;
|
|
import com.mokamrp.privates.entity.VoltaHandle;
|
|
|
import com.mokamrp.privates.entity.pangu.FosterwxCashAccountScheduleHandle;
|
|
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.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.FosterwxCashAccountSchedule;
|
|
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.mapper.pojo.User;
|
|
|
-import com.mokamrp.privates.service.pangu.FosterwxCashAccountScheduleService;
|
|
|
|
|
-import com.mokamrp.privates.service.pangu.FosterwxCashScheduleTaskListService;
|
|
|
|
|
|
|
+import com.mokamrp.privates.service.pangu.*;
|
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
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;
|
|
|
-import org.springframework.web.bind.annotation.PostMapping;
|
|
|
|
|
-import org.springframework.web.bind.annotation.RequestBody;
|
|
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
|
|
import javax.validation.Valid;
|
|
import javax.validation.Valid;
|
|
@@ -49,6 +48,15 @@ public class FosterwxCashAccountScheduleController extends BaseController<Foster
|
|
|
@Autowired
|
|
@Autowired
|
|
|
public FosterwxCashScheduleTaskListService fosterwxCashScheduleTaskListService;
|
|
public FosterwxCashScheduleTaskListService fosterwxCashScheduleTaskListService;
|
|
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ public FosterwxCashTaskTemplateService fosterwxCashTaskTemplateService;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ public FosterwxCashTaskListService fosterwxCashTaskListService;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ public FosterwxCashWorkwxTaskCatalogService fosterwxCashWorkwxTaskCatalogService;
|
|
|
|
|
+
|
|
|
/*
|
|
/*
|
|
|
* @fast
|
|
* @fast
|
|
|
* 默认生成的控制器所继承的父类中有index/add/edit/del四个基础方法,均为post json请求
|
|
* 默认生成的控制器所继承的父类中有index/add/edit/del四个基础方法,均为post json请求
|
|
@@ -66,7 +74,7 @@ public class FosterwxCashAccountScheduleController extends BaseController<Foster
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@PostMapping("/addPro")
|
|
@PostMapping("/addPro")
|
|
|
- @ApiOperation(value = "新建按钮")
|
|
|
|
|
|
|
+ @ApiOperation(value = "新建按钮 个微企微用type区分")
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public Object addPro(@RequestBody FosterwxCashAccountSchedule fosterwxCashAccountSchedule, @AuthUser User user) {
|
|
public Object addPro(@RequestBody FosterwxCashAccountSchedule fosterwxCashAccountSchedule, @AuthUser User user) {
|
|
|
this.onInsert(fosterwxCashAccountSchedule);
|
|
this.onInsert(fosterwxCashAccountSchedule);
|
|
@@ -77,20 +85,23 @@ public class FosterwxCashAccountScheduleController extends BaseController<Foster
|
|
|
|
|
|
|
|
// 待创建
|
|
// 待创建
|
|
|
fosterwxCashAccountSchedule.setStatus(2);
|
|
fosterwxCashAccountSchedule.setStatus(2);
|
|
|
|
|
+
|
|
|
fosterwxCashAccountScheduleService.save(fosterwxCashAccountSchedule);
|
|
fosterwxCashAccountScheduleService.save(fosterwxCashAccountSchedule);
|
|
|
|
|
|
|
|
return AjaxResult.success("新建成功");
|
|
return AjaxResult.success("新建成功");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- @ApiOperation(value = "导入排期按钮")
|
|
|
|
|
|
|
+ @ApiOperation(value = "导入排期按钮 新加一个type字段 加在url后面传输")
|
|
|
@PostMapping("/importSchedule")
|
|
@PostMapping("/importSchedule")
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public Object importSchedule(@RequestBody MultipartFile file, @AuthUser User user) {
|
|
|
|
|
|
|
+ public Object importSchedule(@RequestParam(defaultValue = "1") Integer type, @RequestBody MultipartFile file, @AuthUser User user) {
|
|
|
Map<String, Object> map = new HashMap<>(16);
|
|
Map<String, Object> map = new HashMap<>(16);
|
|
|
Map<Integer, String> feild = new HashMap<>(5);
|
|
Map<Integer, String> feild = new HashMap<>(5);
|
|
|
feild.put(0, "scheduleDate");
|
|
feild.put(0, "scheduleDate");
|
|
|
feild.put(1, "groupId");
|
|
feild.put(1, "groupId");
|
|
|
feild.put(2, "templateId");
|
|
feild.put(2, "templateId");
|
|
|
|
|
+ feild.put(3, "groupNumEveryTime|default");
|
|
|
|
|
+ feild.put(4, "messageInterval|default");
|
|
|
List<Map<String, String>> row = new ArrayList<>();
|
|
List<Map<String, String>> row = new ArrayList<>();
|
|
|
VoltaHandle<ArrayList<Map<String, String>>> voltaRes = Analysis.analysis(file, feild);
|
|
VoltaHandle<ArrayList<Map<String, String>>> voltaRes = Analysis.analysis(file, feild);
|
|
|
if (voltaRes.getErr() != null) {
|
|
if (voltaRes.getErr() != null) {
|
|
@@ -100,10 +111,17 @@ public class FosterwxCashAccountScheduleController extends BaseController<Foster
|
|
|
|
|
|
|
|
for (Map<String, String> detail : row) {
|
|
for (Map<String, String> detail : row) {
|
|
|
FosterwxCashAccountSchedule fosterwxCashAccountSchedule = new FosterwxCashAccountSchedule();
|
|
FosterwxCashAccountSchedule fosterwxCashAccountSchedule = new FosterwxCashAccountSchedule();
|
|
|
|
|
+
|
|
|
fosterwxCashAccountSchedule.setScheduleDate(LocalDate.parse(detail.get("scheduleDate")));
|
|
fosterwxCashAccountSchedule.setScheduleDate(LocalDate.parse(detail.get("scheduleDate")));
|
|
|
fosterwxCashAccountSchedule.setGroupId(Integer.valueOf(detail.get("groupId")));
|
|
fosterwxCashAccountSchedule.setGroupId(Integer.valueOf(detail.get("groupId")));
|
|
|
fosterwxCashAccountSchedule.setTemplateId(Integer.valueOf(detail.get("templateId")));
|
|
fosterwxCashAccountSchedule.setTemplateId(Integer.valueOf(detail.get("templateId")));
|
|
|
fosterwxCashAccountSchedule.setStatus(2);
|
|
fosterwxCashAccountSchedule.setStatus(2);
|
|
|
|
|
+ fosterwxCashAccountSchedule.setType(type);
|
|
|
|
|
+ // 企微任务的情况
|
|
|
|
|
+ if (2 == type) {
|
|
|
|
|
+ fosterwxCashAccountSchedule.setGroupNumEveryTime(Integer.valueOf(detail.get("groupNumEveryTime")));
|
|
|
|
|
+ fosterwxCashAccountSchedule.setMessageInterval(Integer.valueOf(detail.get("messageInterval")));
|
|
|
|
|
+ }
|
|
|
fosterwxCashAccountSchedule.setCreateUid(user.getId());
|
|
fosterwxCashAccountSchedule.setCreateUid(user.getId());
|
|
|
fosterwxCashAccountSchedule.setCreateUser(user.getName());
|
|
fosterwxCashAccountSchedule.setCreateUser(user.getName());
|
|
|
fosterwxCashAccountSchedule.setUpdateUid(user.getId());
|
|
fosterwxCashAccountSchedule.setUpdateUid(user.getId());
|
|
@@ -118,25 +136,59 @@ public class FosterwxCashAccountScheduleController extends BaseController<Foster
|
|
|
|
|
|
|
|
@PostMapping("/immediateCreate")
|
|
@PostMapping("/immediateCreate")
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@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)));
|
|
|
|
|
-
|
|
|
|
|
- return AjaxResult.success("立即生成成功");
|
|
|
|
|
|
|
+ @ApiOperation(value = "生成")
|
|
|
|
|
+ public Object immediateCreate(@RequestBody FosterwxCashAccountScheduleHandle handle) {
|
|
|
|
|
+ Arrays.asList(handle.getIds().split(REGEX)).forEach(id -> {
|
|
|
|
|
+ List<FosterwxCashScheduleTaskList> newsList = fosterwxCashAccountScheduleService.createTask(Integer.valueOf(id));
|
|
|
|
|
+ // 由于不能浪费公众号发文为 需要整合起来一起发送
|
|
|
|
|
+ // 调用typer生成链接
|
|
|
|
|
+ fosterwxCashScheduleTaskListService.create(newsList);
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ return AjaxResult.success("生成成功");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@PostMapping("/preview")
|
|
@PostMapping("/preview")
|
|
|
- @ApiOperation(value = "预览按钮---缺少老王的方法")
|
|
|
|
|
- public Object priview(FosterwxCashAccountScheduleHandle handle) {
|
|
|
|
|
- // TODO 等老王的接口
|
|
|
|
|
-
|
|
|
|
|
- return AjaxResult.success("");
|
|
|
|
|
|
|
+ @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 -> {
|
|
|
|
|
+ // 个微任务的情况
|
|
|
|
|
+ if (fosterwxCashScheduleTaskList.getType() == 1) {
|
|
|
|
|
+ fosterwxCashScheduleTaskList.setFosterwxCashTaskList(fosterwxCashTaskListService.getById(fosterwxCashScheduleTaskList.getTaskId()));
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // 企微任务
|
|
|
|
|
+ fosterwxCashScheduleTaskList.setFosterwxCashWorkwxTaskListList(fosterwxCashWorkwxTaskCatalogService.getTaskByTemplateId(fosterwxCashScheduleTaskList.getTemplateId()));
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ return AjaxResult.success(resHandle);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@PostMapping("/cancelTask")
|
|
@PostMapping("/cancelTask")
|
|
|
@ApiOperation(value = "取消任务按钮")
|
|
@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()));
|
|
|
|
|
|
|
+ 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));
|
|
|
|
|
+ setStatus(0);
|
|
|
|
|
+ setUpdateAt(LocalDateTime.now());
|
|
|
|
|
+ setUpdateUid(user.getId());
|
|
|
|
|
+ }});
|
|
|
|
|
+
|
|
|
|
|
+ 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("取消任务成功");
|
|
return AjaxResult.success("取消任务成功");
|
|
|
}
|
|
}
|