|
|
@@ -0,0 +1,144 @@
|
|
|
+package com.mokamrp.privates.controller.pangu;
|
|
|
+
|
|
|
+import com.mokamrp.privates.constant.HttpStatus;
|
|
|
+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.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.pojo.User;
|
|
|
+import com.mokamrp.privates.service.pangu.FosterwxCashAccountScheduleService;
|
|
|
+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.transaction.annotation.Transactional;
|
|
|
+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.multipart.MultipartFile;
|
|
|
+
|
|
|
+import javax.validation.Valid;
|
|
|
+import java.time.LocalDate;
|
|
|
+import java.time.LocalDateTime;
|
|
|
+import java.util.*;
|
|
|
+
|
|
|
+
|
|
|
+/**
|
|
|
+ * <p>
|
|
|
+ * 盘古微信变现任务列表 前端控制器
|
|
|
+ * </p>
|
|
|
+ *
|
|
|
+ * @author leon
|
|
|
+ * @since 2021-10-08
|
|
|
+ */
|
|
|
+@RestController
|
|
|
+@RequestMapping("/pangu/fosterwxCashAccountSchedule")
|
|
|
+@Api(tags = "变现-账号排期")
|
|
|
+public class FosterwxCashAccountScheduleController extends BaseController<FosterwxCashAccountSchedule> {
|
|
|
+
|
|
|
+ public static final String REGEX = ",";
|
|
|
+ @Autowired
|
|
|
+ public FosterwxCashAccountScheduleService fosterwxCashAccountScheduleService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ public FosterwxCashScheduleTaskListService fosterwxCashScheduleTaskListService;
|
|
|
+
|
|
|
+ /*
|
|
|
+ * @fast
|
|
|
+ * 默认生成的控制器所继承的父类中有index/add/edit/del四个基础方法,均为post json请求
|
|
|
+ * 如果需要定制化,需要将BaseController中对应的方法复制到当前控制器,然后进行修改
|
|
|
+ */
|
|
|
+
|
|
|
+ @PostMapping("/list")
|
|
|
+ @ApiOperation(value = "获取列表信息")
|
|
|
+ public Object list(@Valid @RequestBody FosterwxCashAccountScheduleHandle handle, BindingResult bindingResult) {
|
|
|
+ if (bindingResult.hasErrors()) {
|
|
|
+ return AjaxResult.error(HttpStatus.ERROR, bindingResult.getFieldError().getDefaultMessage());
|
|
|
+ }
|
|
|
+ ResHandle<List<FosterwxCashAccountSchedule>> res = fosterwxCashAccountScheduleService.getList(handle);
|
|
|
+ return AjaxResult.success(res);
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/addPro")
|
|
|
+ @ApiOperation(value = "新建按钮")
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public Object addPro(@RequestBody FosterwxCashAccountSchedule fosterwxCashAccountSchedule, @AuthUser User user) {
|
|
|
+ this.onInsert(fosterwxCashAccountSchedule);
|
|
|
+
|
|
|
+ fosterwxCashAccountSchedule.setCreateUid(user.getId());
|
|
|
+ fosterwxCashAccountSchedule.setCreateUser(user.getName());
|
|
|
+ fosterwxCashAccountSchedule.setUpdateUid(user.getId());
|
|
|
+
|
|
|
+ // 待创建
|
|
|
+ fosterwxCashAccountSchedule.setStatus(2);
|
|
|
+ fosterwxCashAccountScheduleService.save(fosterwxCashAccountSchedule);
|
|
|
+
|
|
|
+ return AjaxResult.success("新建成功");
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "导入排期按钮")
|
|
|
+ @PostMapping("/importSchedule")
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public Object importSchedule(@RequestBody MultipartFile file, @AuthUser User user) {
|
|
|
+ Map<String, Object> map = new HashMap<>(16);
|
|
|
+ Map<Integer, String> feild = new HashMap<>(5);
|
|
|
+ feild.put(0, "scheduleDate");
|
|
|
+ feild.put(1, "groupId");
|
|
|
+ feild.put(2, "templateId");
|
|
|
+ List<Map<String, String>> row = new ArrayList<>();
|
|
|
+ VoltaHandle<ArrayList<Map<String, String>>> voltaRes = Analysis.analysis(file, feild);
|
|
|
+ if (voltaRes.getErr() != null) {
|
|
|
+ return AjaxResult.error(voltaRes.getErr());
|
|
|
+ }
|
|
|
+ row = voltaRes.getData();
|
|
|
+
|
|
|
+ for (Map<String, String> detail : row) {
|
|
|
+ FosterwxCashAccountSchedule fosterwxCashAccountSchedule = new FosterwxCashAccountSchedule();
|
|
|
+ fosterwxCashAccountSchedule.setScheduleDate(LocalDate.parse(detail.get("scheduleDate")));
|
|
|
+ fosterwxCashAccountSchedule.setGroupId(Integer.valueOf(detail.get("groupId")));
|
|
|
+ fosterwxCashAccountSchedule.setTemplateId(Integer.valueOf(detail.get("templateId")));
|
|
|
+ fosterwxCashAccountSchedule.setStatus(2);
|
|
|
+ fosterwxCashAccountSchedule.setCreateUid(user.getId());
|
|
|
+ fosterwxCashAccountSchedule.setCreateUser(user.getName());
|
|
|
+ fosterwxCashAccountSchedule.setUpdateUid(user.getId());
|
|
|
+ fosterwxCashAccountSchedule.setCreateAt(LocalDateTime.now());
|
|
|
+ fosterwxCashAccountSchedule.setUpdateAt(LocalDateTime.now());
|
|
|
+
|
|
|
+ fosterwxCashAccountScheduleService.save(fosterwxCashAccountSchedule);
|
|
|
+ }
|
|
|
+
|
|
|
+ return AjaxResult.success("导入排期成功");
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/immediateCreate")
|
|
|
+ @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("立即生成成功");
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/preview")
|
|
|
+ @ApiOperation(value = "预览按钮---缺少老王的方法")
|
|
|
+ public Object priview(FosterwxCashAccountScheduleHandle handle) {
|
|
|
+ // TODO 等老王的接口
|
|
|
+
|
|
|
+ return AjaxResult.success("");
|
|
|
+ }
|
|
|
+
|
|
|
+ @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()));
|
|
|
+
|
|
|
+ return AjaxResult.success("取消任务成功");
|
|
|
+ }
|
|
|
+}
|
|
|
+
|