Commit 10c676d3 by chenweisong

跟新

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