Commit 10c676d3 by chenweisong

跟新

parent 5561de02
...@@ -9,6 +9,7 @@ import com.keymobile.rest.service.*; ...@@ -9,6 +9,7 @@ import com.keymobile.rest.service.*;
import com.keymobile.rest.vo.*; import com.keymobile.rest.vo.*;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiParam;
import lombok.extern.java.Log;
import org.activiti.engine.*; import org.activiti.engine.*;
import org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl; import org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl;
import org.activiti.engine.repository.Deployment; import org.activiti.engine.repository.Deployment;
...@@ -23,11 +24,14 @@ import org.springframework.web.bind.annotation.*; ...@@ -23,11 +24,14 @@ import org.springframework.web.bind.annotation.*;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@Log
@RestController @RestController
@RequestMapping(path = "/api") @RequestMapping(path = "/api")
public class IndexCtrl { public class IndexCtrl {
@Autowired @Autowired
private ManagementService managementService;
@Autowired
private JobService jobService; private JobService jobService;
@Autowired @Autowired
private ExcelService excelService; private ExcelService excelService;
...@@ -53,9 +57,9 @@ public class IndexCtrl { ...@@ -53,9 +57,9 @@ public class IndexCtrl {
@Value("${app.active-process}") @Value("${app.active-process}")
private String process; private String process;
@ApiOperation(value = "获取首页收数列表") @ApiOperation(value = "获取首页活动列表")
@PostMapping(value = "/task/list") @PostMapping(value = "/task/list")
public ApiResponse getTaskList(@RequestParam Integer pageNo, @RequestParam Integer pageSize, @RequestParam(required = false) @ApiParam(name = "name", value = "收数名称") String name) { public ApiResponse getTaskList(@RequestParam Integer pageNo, @RequestParam Integer pageSize, @RequestParam(required = false) @ApiParam(name = "name", value = "活动名称") String name) {
Page<Job> taskList; Page<Job> taskList;
String orderBy = "descending"; // String orderBy = "descending"; //
String propBy = "id"; // groupBy String propBy = "id"; // groupBy
...@@ -67,55 +71,44 @@ public class IndexCtrl { ...@@ -67,55 +71,44 @@ public class IndexCtrl {
return ApiResponse.ok(ImmutableMap.of("list", taskList.getContent(), "total", taskList.getTotalElements())); return ApiResponse.ok(ImmutableMap.of("list", taskList.getContent(), "total", taskList.getTotalElements()));
} }
@ApiOperation(value = "查看收数") @ApiOperation(value = "查看活动")
@PostMapping(value = "/task/get") @PostMapping(value = "/task/get")
public ApiResponse get(@RequestParam @ApiParam(required = true, name = "taskId", value = "收数id") Long taskId) { public ApiResponse get(@RequestParam @ApiParam(required = true, name = "taskId", value = "活动id") Long taskId) {
Job job = jobService.get(taskId); Job job = jobService.get(taskId);
TwinkleValidator.notNull(job, "活动不存在");
return ApiResponse.ok(job); return ApiResponse.ok(job);
} }
@ApiOperation(value = "补录人员查看自己补录任务") @ApiOperation(value = "补录任务列表及审核任务列表")
@PostMapping(value = "/task/getMyTasks") @PostMapping(value = "/task/getMyTasks")
public ApiResponse getMyTasks() { public ApiResponse getMyTasks() {
List<User> userList = userService.findAllByRole(User.ROLE_NORMAL); User user = userService.getNormalUser();
User curUser = userList.get(0); User audit = userService.getAudit();
List<Excel> excelList = new ArrayList<>(); List<Job> recordList = new ArrayList<>();
// 发起人把流程发送到下一个人 List<Job> auditList = new ArrayList<>();
List<Task> taskList = taskService.createTaskQuery() // 获取任务
.taskAssignee(curUser.getUsername()).list(); List<Task> tasks = taskService.createNativeTaskQuery()
if (taskList.size() > 0) { .sql("SELECT * FROM " + managementService.getTableName(Task.class) + " T WHERE T.ASSIGNEE_ = #{assignee1} OR T.ASSIGNEE_ = #{assignee2}")
Task task = taskList.get(0); .parameter("assignee1", user.getUsername()).parameter("assignee2", audit.getUsername())
.list();
for (Task task : tasks) {
String processId = task.getProcessInstanceId(); String processId = task.getProcessInstanceId();
Job job = jobService.findByProcessId(processId); Job job = jobService.findByProcessId(processId);
if (job.getStatus() != Job.STATUS_COMPLETED) { if (job != null && job.getStatus() != Job.STATUS_COMPLETED) {
excelList = excelService.findAllByJobId(job.getId()); if (task.getTaskDefinitionKey().equals("addData")) {
} recordList.add(job);
} else {
auditList.add(job);
} }
return ApiResponse.ok(excelList);
} }
@ApiOperation(value = "审核人员查看自己任务")
@PostMapping(value = "/task/getMyAudits")
public ApiResponse getMyJudges() {
List<User> userList = userService.findAllByRole(User.ROLE_AUDIT);
User curUser = userList.get(0);
List<Excel> excelList = new ArrayList<>();
// 发起人把流程发送到下一个人
List<Task> taskList = taskService.createTaskQuery()
.taskAssignee(curUser.getUsername()).list();
if (taskList.size() > 0) {
Task task = taskList.get(0);
String processId = task.getProcessInstanceId();
Job job = jobService.findByProcessId(processId);
if (job.getStatus() != Job.STATUS_COMPLETED) {
excelList = excelService.findAllByJobId(job.getId());
} }
return ApiResponse.ok(ImmutableMap.of("recordList", recordList, "auditList", auditList));
} }
return ApiResponse.ok(excelList);
}
@ApiOperation(value = "新建收数")
@ApiOperation(value = "新建活动")
@PostMapping(value = "/task/create") @PostMapping(value = "/task/create")
public ApiResponse createTask(@RequestBody JobForm form) { public ApiResponse createTask(@RequestBody JobForm form) {
TwinkleValidator.notEmpty(form.getName(), "名称不能为空"); TwinkleValidator.notEmpty(form.getName(), "名称不能为空");
...@@ -128,13 +121,11 @@ public class IndexCtrl { ...@@ -128,13 +121,11 @@ public class IndexCtrl {
// 新建excel实例 // 新建excel实例
List<ExcelForm> excelFormList = form.getExcels(); List<ExcelForm> excelFormList = form.getExcels();
excelFormList.forEach(excelForm -> { excelFormList.forEach(excelForm -> {
TwinkleValidator.notEmpty(excelForm.getUserIds(), "补录人不能为空"); TwinkleValidator.notLessThan(excelForm.getUserIdList().size(), 1, "补录人不能为空");
excelForm.setJob(job); excelForm.setJob(job);
Excel excel = excelService.save(excelForm); Excel excel = excelService.save(excelForm);
// 新建补录人员任务关联 // 新建补录人员任务关联
String[] userIds = excelForm.getUserIds().split(","); List<User> userList = userService.findAllByIdIn(excelForm.getUserIdList());
List<Long> userIdList = Arrays.asList(userIds).stream().map(Long::parseLong).collect(Collectors.toList());
List<User> userList = userService.findAllByIdIn(userIdList);
TwinkleValidator.notLessThan(userList.size(), 1, "补录人员不存在"); TwinkleValidator.notLessThan(userList.size(), 1, "补录人员不存在");
userList.forEach(user -> { userList.forEach(user -> {
jobInfoService.save(user, excel); jobInfoService.save(user, excel);
...@@ -143,14 +134,14 @@ public class IndexCtrl { ...@@ -143,14 +134,14 @@ public class IndexCtrl {
return ApiResponse.ok(job.getId()); return ApiResponse.ok(job.getId());
} }
@ApiOperation(value = "修改收数") @ApiOperation(value = "修改活动")
@PostMapping(value = "/task/update") @PostMapping(value = "/task/update")
public ApiResponse updateTask(@RequestBody JobForm form) { public ApiResponse updateTask(@RequestBody JobForm form) {
TwinkleValidator.isFalse((form.getId() == null && form.getId() <= 0), "收数id不能为空"); TwinkleValidator.isFalse((form.getId() == null && form.getId() <= 0), "活动id不能为空");
Job job = jobService.get(form.getId()); Job job = jobService.get(form.getId());
TwinkleValidator.notNull(job, "收数不存在"); TwinkleValidator.notNull(job, "活动不存在");
int status = job.getStatus(); int status = job.getStatus();
TwinkleValidator.isFalse(status != Job.STATUS_UNRELEASED, "收数已经发起"); TwinkleValidator.isFalse(status != Job.STATUS_UNRELEASED, "活动已经发起");
TwinkleValidator.notEmpty(form.getName(), "名称不能为空"); TwinkleValidator.notEmpty(form.getName(), "名称不能为空");
TwinkleValidator.notNull(form.getType(), "类型不能为空"); TwinkleValidator.notNull(form.getType(), "类型不能为空");
TwinkleValidator.isFalse((form.getExcels() == null || form.getExcels().size() == 0), "补录模板不能为空"); TwinkleValidator.isFalse((form.getExcels() == null || form.getExcels().size() == 0), "补录模板不能为空");
...@@ -172,11 +163,11 @@ public class IndexCtrl { ...@@ -172,11 +163,11 @@ public class IndexCtrl {
return ApiResponse.ok(job.getId()); return ApiResponse.ok(job.getId());
} }
@ApiOperation(value = "手动发起收数") @ApiOperation(value = "手动发起活动")
@PostMapping(value = "/task/start") @PostMapping(value = "/task/start")
public ApiResponse startTask(@RequestParam Long taskId) { public ApiResponse startTask(@RequestParam Long taskId) {
Job job = jobService.get(taskId); Job job = jobService.get(taskId);
TwinkleValidator.notNull(job, "收数不存在"); TwinkleValidator.notNull(job, "活动不存在");
// 部署补录流程 // 部署补录流程
Deployment deploy = repositoryService Deployment deploy = repositoryService
.createDeployment() .createDeployment()
...@@ -198,7 +189,7 @@ public class IndexCtrl { ...@@ -198,7 +189,7 @@ public class IndexCtrl {
Task resultTask = taskService.createTaskQuery().processInstanceId(processInstance.getId()). Task resultTask = taskService.createTaskQuery().processInstanceId(processInstance.getId()).
taskInvolvedUser(inputUser).singleResult(); taskInvolvedUser(inputUser).singleResult();
// 根据收数查找需要填写的人 目前只支持一人 // 根据活动查找需要填写的人 目前只支持一人
List<Excel> excelList = job.getExcelList(); List<Excel> excelList = job.getExcelList();
TwinkleValidator.notLessThan(excelList.size(), 1, "补录模板不存在"); TwinkleValidator.notLessThan(excelList.size(), 1, "补录模板不存在");
Excel excel = excelList.get(0); Excel excel = excelList.get(0);
...@@ -209,13 +200,12 @@ public class IndexCtrl { ...@@ -209,13 +200,12 @@ public class IndexCtrl {
} }
@ApiOperation(value = "审核通过收数") @ApiOperation(value = "审核通过活动")
@PostMapping(value = "/task/pass") @PostMapping(value = "/task/pass")
public ApiResponse passTask(@RequestParam Long taskId) { public ApiResponse passTask(@RequestParam Long taskId) {
Job job = jobService.get(taskId); Job job = jobService.get(taskId);
// 完结收数, 流程跑完 // 完结活动, 流程跑完
List<User> judgeList = userService.findAllByRole(User.ROLE_AUDIT); User judge = userService.getAudit();
User judge = judgeList.get(0);
List<Task> taskList = taskService.createTaskQuery().processInstanceId(job.getProcessId()) List<Task> taskList = taskService.createTaskQuery().processInstanceId(job.getProcessId())
.taskAssignee(judge.getUsername()).list(); .taskAssignee(judge.getUsername()).list();
Task task = taskList.get(0); Task task = taskList.get(0);
...@@ -226,13 +216,12 @@ public class IndexCtrl { ...@@ -226,13 +216,12 @@ public class IndexCtrl {
} }
@ApiOperation(value = "审核驳回收数") @ApiOperation(value = "审核驳回活动")
@PostMapping(value = "/task/reject") @PostMapping(value = "/task/reject")
public ApiResponse rejectTask(@RequestParam Long taskId) { public ApiResponse rejectTask(@RequestParam Long taskId) {
Job job = jobService.get(taskId); Job job = jobService.get(taskId);
// 完结收数, 流程跑完 // 完结活动, 流程跑完
List<User> judgeList = userService.findAllByRole(User.ROLE_AUDIT); User judge = userService.getAudit();
User judge = judgeList.get(0);
List<Task> taskList = taskService.createTaskQuery().processInstanceId(job.getProcessId()) List<Task> taskList = taskService.createTaskQuery().processInstanceId(job.getProcessId())
.taskAssignee(judge.getUsername()).list(); .taskAssignee(judge.getUsername()).list();
Task task = taskList.get(0); Task task = taskList.get(0);
...@@ -240,7 +229,7 @@ public class IndexCtrl { ...@@ -240,7 +229,7 @@ public class IndexCtrl {
return ApiResponse.ok(); return ApiResponse.ok();
} }
// @ApiOperation(value = "查看当前收数进度") // @ApiOperation(value = "查看当前活动进度")
// @PostMapping(value = "/task/viewTaskProcess") // @PostMapping(value = "/task/viewTaskProcess")
// public ApiResponse viewTaskProcess(@RequestParam Long taskId) { // public ApiResponse viewTaskProcess(@RequestParam Long taskId) {
// return ApiResponse.ok(); // return ApiResponse.ok();
...@@ -262,8 +251,7 @@ public class IndexCtrl { ...@@ -262,8 +251,7 @@ public class IndexCtrl {
} else { } else {
recordData = recordDataService.save(form); recordData = recordDataService.save(form);
} }
List<User> userList = userService.findAllByRole(User.ROLE_NORMAL); User curUser = userService.getNormalUser();
User curUser = userList.get(0);
Excel excel = excelService.get(form.getExcelId()); Excel excel = excelService.get(form.getExcelId());
Job job = excel.getJob(); Job job = excel.getJob();
String processId = job.getProcessId(); String processId = job.getProcessId();
...@@ -271,9 +259,7 @@ public class IndexCtrl { ...@@ -271,9 +259,7 @@ public class IndexCtrl {
List<Task> taskList = taskService.createTaskQuery().processInstanceId(processId) List<Task> taskList = taskService.createTaskQuery().processInstanceId(processId)
.taskAssignee(curUser.getUsername()).list(); .taskAssignee(curUser.getUsername()).list();
Task task = taskList.get(0); Task task = taskList.get(0);
User judge = userService.getAudit();
List<User> judgeList = userService.findAllByRole(User.ROLE_AUDIT);
User judge = judgeList.get(0);
taskService.complete(task.getId(), ImmutableMap.of("judgeId", judge.getUsername())); taskService.complete(task.getId(), ImmutableMap.of("judgeId", judge.getUsername()));
return ApiResponse.ok(recordData.getId()); return ApiResponse.ok(recordData.getId());
} }
......
...@@ -17,6 +17,17 @@ public class UserService { ...@@ -17,6 +17,17 @@ public class UserService {
return userDao.findAllByRole(role); return userDao.findAllByRole(role);
} }
public User getAudit() {
List<User> userList = userDao.findAllByRole(User.ROLE_AUDIT);
User user = userList.get(0);
return user;
}
public User getNormalUser() {
List<User> userList = userDao.findAllByRole(User.ROLE_NORMAL);
User user = userList.get(0);
return user;
}
public User getManager() { public User getManager() {
List<User> userList = userDao.findAllByRole(User.ROLE_MANAGER); List<User> userList = userDao.findAllByRole(User.ROLE_MANAGER);
......
...@@ -20,10 +20,10 @@ public class ExcelForm { ...@@ -20,10 +20,10 @@ public class ExcelForm {
@ApiModelProperty(name = "id", value = "表格id,修改的时候需要用到") @ApiModelProperty(name = "id", value = "表格id,修改的时候需要用到")
private Long id; private Long id;
@ApiModelProperty(required = true, name = "userIds", value = "补录人员ids, 用逗号隔开") @ApiModelProperty(required = true, name = "userIds", value = "补录人员ids, 用逗号隔开", hidden = true)
private String userIds; private String userIds;
@ApiModelProperty(required = true, name = "userIdList", value = "补录人员id集合", hidden = true) @ApiModelProperty(required = true, name = "userIdList", value = "补录人员id集合")
private List<Long> userIdList; private List<Long> userIdList;
@ApiModelProperty(name = "remark", value = "表格名称", required = true) @ApiModelProperty(name = "remark", value = "表格名称", required = true)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment