Commit d5067f60 by chenweisong

更新

parent 6917afe4
package com.keymobile.rest.controller; package com.keymobile.rest.controller;
import com.keymobile.rest.common.bean.ApiResponse; import com.keymobile.rest.common.bean.ApiResponse;
import com.keymobile.rest.model.*;
import com.keymobile.rest.service.TemplateService; import com.keymobile.rest.service.TemplateService;
import com.keymobile.rest.service.ProcessInfoService; import com.keymobile.rest.service.MissionService;
import com.keymobile.rest.service.UserService; import com.keymobile.rest.service.UserService;
import com.keymobile.rest.vo.RecordDataForm; import com.keymobile.rest.vo.RecordDataForm;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
...@@ -12,8 +11,6 @@ import org.activiti.engine.*; ...@@ -12,8 +11,6 @@ import org.activiti.engine.*;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.List;
@Api(value = "模板控制器") @Api(value = "模板控制器")
@RestController @RestController
@RequestMapping(path = "/api") @RequestMapping(path = "/api")
...@@ -24,7 +21,7 @@ public class ExcelController { ...@@ -24,7 +21,7 @@ public class ExcelController {
@Autowired @Autowired
private TemplateService templateService; private TemplateService templateService;
@Autowired @Autowired
private ProcessInfoService processInfoService; private MissionService missionService;
@Autowired @Autowired
private UserService userService; private UserService userService;
@Autowired @Autowired
......
...@@ -8,8 +8,8 @@ import com.keymobile.rest.model.Template; ...@@ -8,8 +8,8 @@ import com.keymobile.rest.model.Template;
import com.keymobile.rest.model.Mission; import com.keymobile.rest.model.Mission;
import com.keymobile.rest.model.User; import com.keymobile.rest.model.User;
import com.keymobile.rest.service.TemplateService; import com.keymobile.rest.service.TemplateService;
import com.keymobile.rest.service.ProcessInfoService; import com.keymobile.rest.service.MissionService;
import com.keymobile.rest.service.AssignmentService; import com.keymobile.rest.service.ActivityService;
import com.keymobile.rest.service.UserService; import com.keymobile.rest.service.UserService;
import com.keymobile.rest.vo.ExcelForm; import com.keymobile.rest.vo.ExcelForm;
import com.keymobile.rest.vo.JobForm; import com.keymobile.rest.vo.JobForm;
...@@ -41,11 +41,11 @@ public class TaskController { ...@@ -41,11 +41,11 @@ public class TaskController {
@Autowired @Autowired
private ManagementService managementService; private ManagementService managementService;
@Autowired @Autowired
private AssignmentService assignmentService; private ActivityService activityService;
@Autowired @Autowired
private TemplateService templateService; private TemplateService templateService;
@Autowired @Autowired
private ProcessInfoService processInfoService; private MissionService missionService;
@Autowired @Autowired
private UserService userService; private UserService userService;
@Autowired @Autowired
...@@ -63,9 +63,9 @@ public class TaskController { ...@@ -63,9 +63,9 @@ public class TaskController {
String orderBy = "descending"; // String orderBy = "descending"; //
String propBy = "id"; // groupBy String propBy = "id"; // groupBy
if (name != null) { if (name != null) {
taskList = assignmentService.findAllByName(name, pageNo, pageSize, orderBy, propBy); taskList = activityService.findAllByName(name, pageNo, pageSize, orderBy, propBy);
} else { } else {
taskList = assignmentService.findAll(pageNo, pageSize, orderBy, propBy); taskList = activityService.findAll(pageNo, pageSize, orderBy, propBy);
} }
return ApiResponse.ok(ImmutableMap.of("list", taskList.getContent(), "total", taskList.getTotalElements())); return ApiResponse.ok(ImmutableMap.of("list", taskList.getContent(), "total", taskList.getTotalElements()));
} }
...@@ -73,7 +73,7 @@ public class TaskController { ...@@ -73,7 +73,7 @@ public class TaskController {
@ApiOperation(value = "查看活动") @ApiOperation(value = "查看活动")
@PostMapping(value = "/get") @PostMapping(value = "/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) {
Activity activity = assignmentService.get(taskId); Activity activity = activityService.get(taskId);
TwinkleValidator.notNull(activity, "活动不存在"); TwinkleValidator.notNull(activity, "活动不存在");
return ApiResponse.ok(activity); return ApiResponse.ok(activity);
} }
...@@ -117,7 +117,7 @@ public class TaskController { ...@@ -117,7 +117,7 @@ public class TaskController {
// 创建人 // 创建人
// User manager = userService.getManager(); // User manager = userService.getManager();
// form.setUser(manager); // form.setUser(manager);
Activity activity = assignmentService.save(form); Activity activity = activityService.save(form);
// 新建excel实例 // 新建excel实例
List<ExcelForm> excelFormList = form.getExcels(); List<ExcelForm> excelFormList = form.getExcels();
excelFormList.forEach(excelForm -> { excelFormList.forEach(excelForm -> {
...@@ -130,7 +130,7 @@ public class TaskController { ...@@ -130,7 +130,7 @@ public class TaskController {
List<User> userList = userService.findAllByIdIn(userIdList); List<User> userList = userService.findAllByIdIn(userIdList);
TwinkleValidator.notLessThan(userList.size(), 1, "补录人员不存在"); TwinkleValidator.notLessThan(userList.size(), 1, "补录人员不存在");
userList.forEach(user -> { userList.forEach(user -> {
processInfoService.save(user, template); missionService.save(user, template);
}); });
}); });
return ApiResponse.ok(activity.getId()); return ApiResponse.ok(activity.getId());
...@@ -140,7 +140,7 @@ public class TaskController { ...@@ -140,7 +140,7 @@ public class TaskController {
@PostMapping(value = "/update") @PostMapping(value = "/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不能为空");
Activity activity = assignmentService.get(form.getId()); Activity activity = activityService.get(form.getId());
TwinkleValidator.notNull(activity, "活动不存在"); TwinkleValidator.notNull(activity, "活动不存在");
// int status = assignment.getStatus(); // int status = assignment.getStatus();
// TwinkleValidator.isFalse(status != Assignment.STATUS_UNRELEASED, "活动已经发起"); // TwinkleValidator.isFalse(status != Assignment.STATUS_UNRELEASED, "活动已经发起");
...@@ -150,7 +150,7 @@ public class TaskController { ...@@ -150,7 +150,7 @@ public class TaskController {
activity.setType(form.getType()); activity.setType(form.getType());
activity.setRemark(form.getRemark()); activity.setRemark(form.getRemark());
activity.setName(form.getName()); activity.setName(form.getName());
assignmentService.update(activity); activityService.update(activity);
// 新建excel实例 // 新建excel实例
List<ExcelForm> excelFormList = form.getExcels(); List<ExcelForm> excelFormList = form.getExcels();
excelFormList.forEach(excelForm -> { excelFormList.forEach(excelForm -> {
...@@ -168,7 +168,7 @@ public class TaskController { ...@@ -168,7 +168,7 @@ public class TaskController {
@ApiOperation(value = "手动发起活动") @ApiOperation(value = "手动发起活动")
@PostMapping(value = "/start") @PostMapping(value = "/start")
public ApiResponse startTask(@RequestParam Long taskId) { public ApiResponse startTask(@RequestParam Long taskId) {
Activity activity = assignmentService.get(taskId); Activity activity = activityService.get(taskId);
TwinkleValidator.notNull(activity, "活动不存在"); TwinkleValidator.notNull(activity, "活动不存在");
// 部署补录流程 // 部署补录流程
Deployment deploy = repositoryService Deployment deploy = repositoryService
...@@ -186,7 +186,7 @@ public class TaskController { ...@@ -186,7 +186,7 @@ public class TaskController {
//启动流程 //启动流程
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(processDefinition.getKey(), variables); ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(processDefinition.getKey(), variables);
// assignment.setProcessId(processInstance.getId()); // assignment.setProcessId(processInstance.getId());
assignmentService.update(activity); activityService.update(activity);
// 发起人把流程发送到下一个人 // 发起人把流程发送到下一个人
Task resultTask = taskService.createTaskQuery().processInstanceId(processInstance.getId()). Task resultTask = taskService.createTaskQuery().processInstanceId(processInstance.getId()).
taskInvolvedUser(inputUser).singleResult(); taskInvolvedUser(inputUser).singleResult();
...@@ -196,7 +196,7 @@ public class TaskController { ...@@ -196,7 +196,7 @@ public class TaskController {
TwinkleValidator.notLessThan(templateList.size(), 1, "补录模板不存在"); TwinkleValidator.notLessThan(templateList.size(), 1, "补录模板不存在");
Template template = templateList.get(0); Template template = templateList.get(0);
List<Mission> missionList = processInfoService.findAllByTemplateId(template.getId()); List<Mission> missionList = missionService.findAllByTemplateId(template.getId());
TwinkleValidator.notLessThan(missionList.size(), 1, "补录人员不存在"); TwinkleValidator.notLessThan(missionList.size(), 1, "补录人员不存在");
taskService.complete(resultTask.getId(), ImmutableMap.of("userId", missionList.get(0).getUser().getUsername())); taskService.complete(resultTask.getId(), ImmutableMap.of("userId", missionList.get(0).getUser().getUsername()));
return ApiResponse.ok(); return ApiResponse.ok();
...@@ -206,7 +206,7 @@ public class TaskController { ...@@ -206,7 +206,7 @@ public class TaskController {
@ApiOperation(value = "审核通过活动") @ApiOperation(value = "审核通过活动")
@PostMapping(value = "/pass") @PostMapping(value = "/pass")
public ApiResponse passTask(@RequestParam Long taskId) { public ApiResponse passTask(@RequestParam Long taskId) {
Activity activity = assignmentService.get(taskId); Activity activity = activityService.get(taskId);
// 完结活动, 流程跑完 // 完结活动, 流程跑完
// User judge = userService.getAudit(); // User judge = userService.getAudit();
// List<Task> taskList = taskService.createTaskQuery().processInstanceId(assignment.getProcessId()) // List<Task> taskList = taskService.createTaskQuery().processInstanceId(assignment.getProcessId())
...@@ -215,7 +215,7 @@ public class TaskController { ...@@ -215,7 +215,7 @@ public class TaskController {
// Task task = taskList.get(0); // Task task = taskList.get(0);
// taskService.complete(task.getId(), ImmutableMap.of("pass", "true")); // taskService.complete(task.getId(), ImmutableMap.of("pass", "true"));
// assignment.setStatus(Assignment.STATUS_COMPLETED); // assignment.setStatus(Assignment.STATUS_COMPLETED);
assignmentService.update(activity); activityService.update(activity);
return ApiResponse.ok(); return ApiResponse.ok();
} }
...@@ -223,7 +223,7 @@ public class TaskController { ...@@ -223,7 +223,7 @@ public class TaskController {
@ApiOperation(value = "审核驳回活动") @ApiOperation(value = "审核驳回活动")
@PostMapping(value = "/reject") @PostMapping(value = "/reject")
public ApiResponse rejectTask(@RequestParam Long taskId) { public ApiResponse rejectTask(@RequestParam Long taskId) {
Activity activity = assignmentService.get(taskId); Activity activity = activityService.get(taskId);
// 完结活动, 流程跑完 // 完结活动, 流程跑完
// User judge = userService.getAudit(); // User judge = userService.getAudit();
// List<Task> taskList = taskService.createTaskQuery().processInstanceId(assignment.getProcessId()) // List<Task> taskList = taskService.createTaskQuery().processInstanceId(assignment.getProcessId())
......
...@@ -10,7 +10,7 @@ import org.springframework.web.bind.annotation.*; ...@@ -10,7 +10,7 @@ import org.springframework.web.bind.annotation.*;
import java.util.*; import java.util.*;
@Api(value = "用户控制器") @Api(value = "用户/机构 控制器")
@RestController @RestController
@RequestMapping(path = "/api") @RequestMapping(path = "/api")
public class UserController { public class UserController {
...@@ -23,8 +23,10 @@ public class UserController { ...@@ -23,8 +23,10 @@ public class UserController {
private Group root = new Group(); private Group root = new Group();
{ {
root.setId(0L); root.setId(Group.ROOT_ID);
root.setName("招商银行"); root.setName(Group.ROOT_NAME);
root.setParentId(Group.ROOT_PARENT_ID);
root.setParentId(Group.ROOT_LEVEL);
} }
@ApiOperation(value = "获取补录范围列表") @ApiOperation(value = "获取补录范围列表")
......
...@@ -5,7 +5,7 @@ import org.springframework.data.domain.Page; ...@@ -5,7 +5,7 @@ import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
public interface AssignmentDao extends JpaRepository<Activity, Long> { public interface ActivityDao extends JpaRepository<Activity, Long> {
Page<Activity> findAll(Pageable pageable); Page<Activity> findAll(Pageable pageable);
......
...@@ -5,10 +5,4 @@ import org.springframework.data.jpa.repository.JpaRepository; ...@@ -5,10 +5,4 @@ import org.springframework.data.jpa.repository.JpaRepository;
public interface DataInfoDao extends JpaRepository<DataInfo, Long> { public interface DataInfoDao extends JpaRepository<DataInfo, Long> {
} }
...@@ -3,15 +3,8 @@ package com.keymobile.rest.dao; ...@@ -3,15 +3,8 @@ package com.keymobile.rest.dao;
import com.keymobile.rest.model.Mission; import com.keymobile.rest.model.Mission;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
import java.util.List;
public interface ProcessInfoDao extends JpaRepository<Mission, Long> { public interface MissionDao extends JpaRepository<Mission, Long> {
List<Mission> findAllByTemplateId(long eid);
List<Mission> findAllByUserId(long uid);
void deleteAllByTemplateId(long eid);
Mission findByTemplateIdAndUserId(long eid, long uid);
} }
package com.keymobile.rest.dao;
import com.keymobile.rest.model.Process;
import org.springframework.data.jpa.repository.JpaRepository;
public interface ProcessDao extends JpaRepository<Process, Long> {
}
...@@ -9,7 +9,5 @@ public interface TemplateDao extends JpaRepository<Template, Long> { ...@@ -9,7 +9,5 @@ public interface TemplateDao extends JpaRepository<Template, Long> {
List<Template> findAllByIdIn(List<Long> ids); List<Template> findAllByIdIn(List<Long> ids);
List<Template> findAllByActivityId(long assignmentId); List<Template> findAllByActivityId(long activityId);
} }
...@@ -6,7 +6,5 @@ import org.springframework.data.jpa.repository.JpaRepository; ...@@ -6,7 +6,5 @@ import org.springframework.data.jpa.repository.JpaRepository;
import java.util.List; import java.util.List;
public interface UserDao extends JpaRepository<User, Long> { public interface UserDao extends JpaRepository<User, Long> {
List<User> findAllByIdIn(List<Long> ids); List<User> findAllByIdIn(List<Long> ids);
} }
...@@ -19,6 +19,11 @@ import java.util.List; ...@@ -19,6 +19,11 @@ import java.util.List;
@Table(name = "t_group") @Table(name = "t_group")
public class Group implements Serializable { public class Group implements Serializable {
public static int ROOT_LEVEL = 0;
public static int ROOT_ID = 0;
public static int ROOT_PARENT_ID = -1;
public static String ROOT_NAME = "招商银行";
@Id @Id
@GeneratedValue(strategy = GenerationType.IDENTITY) @GeneratedValue(strategy = GenerationType.IDENTITY)
private long id; private long id;
......
...@@ -61,9 +61,6 @@ public class Mission implements Serializable { ...@@ -61,9 +61,6 @@ public class Mission implements Serializable {
@OneToOne(fetch = FetchType.EAGER) @OneToOne(fetch = FetchType.EAGER)
private DataInfo dataInfo; private DataInfo dataInfo;
/*
补录数据
*/
@ManyToOne(fetch = FetchType.LAZY) @ManyToOne(fetch = FetchType.LAZY)
@JsonIgnore @JsonIgnore
private Process process; private Process process;
......
package com.keymobile.rest.service; package com.keymobile.rest.service;
import com.keymobile.rest.common.utils.DateUtil; import com.keymobile.rest.common.utils.DateUtil;
import com.keymobile.rest.dao.AssignmentDao; import com.keymobile.rest.dao.ActivityDao;
import com.keymobile.rest.model.Activity; import com.keymobile.rest.model.Activity;
import com.keymobile.rest.vo.JobForm; import com.keymobile.rest.vo.JobForm;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -14,21 +14,21 @@ import org.springframework.stereotype.Service; ...@@ -14,21 +14,21 @@ import org.springframework.stereotype.Service;
import java.sql.Timestamp; import java.sql.Timestamp;
@Service @Service
public class AssignmentService { public class ActivityService {
@Autowired @Autowired
private AssignmentDao assignmentDao; private ActivityDao activityDao;
public Activity get(long id) { public Activity get(long id) {
return assignmentDao.getOne(id); return activityDao.getOne(id);
} }
public Activity update(Activity activity) { public Activity update(Activity activity) {
return assignmentDao.save(activity); return activityDao.save(activity);
} }
public Activity save(Activity activity) { public Activity save(Activity activity) {
return assignmentDao.save(activity); return activityDao.save(activity);
} }
public Activity save(JobForm form) { public Activity save(JobForm form) {
...@@ -41,7 +41,7 @@ public class AssignmentService { ...@@ -41,7 +41,7 @@ public class AssignmentService {
} }
activity.setUser(form.getUser()); activity.setUser(form.getUser());
activity = assignmentDao.save(activity); activity = activityDao.save(activity);
return activity; return activity;
} }
...@@ -51,22 +51,22 @@ public class AssignmentService { ...@@ -51,22 +51,22 @@ public class AssignmentService {
public Page<Activity> findAll(int pageNo, int pageSize) { public Page<Activity> findAll(int pageNo, int pageSize) {
Pageable pageable = convert(pageNo, pageSize); Pageable pageable = convert(pageNo, pageSize);
return assignmentDao.findAll(pageable); return activityDao.findAll(pageable);
} }
public Page<Activity> findAllByName(String name, int pageNo, int pageSize) { public Page<Activity> findAllByName(String name, int pageNo, int pageSize) {
Pageable pageable = convert(pageNo, pageSize); Pageable pageable = convert(pageNo, pageSize);
return assignmentDao.findAllByNameLike(("%" + name + "%"), pageable); return activityDao.findAllByNameLike(("%" + name + "%"), pageable);
} }
public Page<Activity> findAll(int pageNo, int pageSize, String orderBy, String propBy) { public Page<Activity> findAll(int pageNo, int pageSize, String orderBy, String propBy) {
Pageable pageable = convert(pageNo, pageSize, orderBy, propBy); Pageable pageable = convert(pageNo, pageSize, orderBy, propBy);
return assignmentDao.findAll(pageable); return activityDao.findAll(pageable);
} }
public Page<Activity> findAllByName(String name, int pageNo, int pageSize, String orderBy, String propBy) { public Page<Activity> findAllByName(String name, int pageNo, int pageSize, String orderBy, String propBy) {
Pageable pageable = convert(pageNo, pageSize, orderBy, propBy); Pageable pageable = convert(pageNo, pageSize, orderBy, propBy);
return assignmentDao.findAllByNameLike(("%" + name + "%"), pageable); return activityDao.findAllByNameLike(("%" + name + "%"), pageable);
} }
private Pageable convert(int pageNo, int pageSize, String orderBy, String propBy) { private Pageable convert(int pageNo, int pageSize, String orderBy, String propBy) {
......
...@@ -12,10 +12,10 @@ import java.sql.Timestamp; ...@@ -12,10 +12,10 @@ import java.sql.Timestamp;
import java.util.List; import java.util.List;
@Service @Service
public class ProcessInfoService { public class MissionService {
@Autowired @Autowired
private ProcessInfoDao processInfoDao; private MissionDao missionDao;
public Mission save(User user, Template template) { public Mission save(User user, Template template) {
Mission info = new Mission(); Mission info = new Mission();
...@@ -23,23 +23,12 @@ public class ProcessInfoService { ...@@ -23,23 +23,12 @@ public class ProcessInfoService {
info.setUser(user); info.setUser(user);
Timestamp now = Timestamp.valueOf(DateUtil.getDateTime()); Timestamp now = Timestamp.valueOf(DateUtil.getDateTime());
info.setCreateAt(now); info.setCreateAt(now);
info = processInfoDao.save(info); info = missionDao.save(info);
return info; return info;
} }
public List<Mission> findAllByTemplateId(long eid) { public List<Mission> findAllByTemplateId(long eid) {
return processInfoDao.findAllByTemplateId(eid); return null;
} }
public Mission findByTemplateIdAndUserId(long eid, long uid) {
return processInfoDao.findByTemplateIdAndUserId(eid, uid);
}
public List<Mission> findByUserId(long uid) {
return processInfoDao.findAllByUserId(uid);
}
public void deleteAllByTemplateId(long eid) {
processInfoDao.deleteAllByTemplateId(eid);
}
} }
package com.keymobile.rest.service;
import com.keymobile.rest.dao.ProcessDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class ProcessService {
@Autowired
private ProcessDao processDao;
}
...@@ -17,8 +17,8 @@ spring: ...@@ -17,8 +17,8 @@ spring:
jpa: jpa:
show-sql: true show-sql: true
database-platform: org.hibernate.dialect.MySQL5Dialect database-platform: org.hibernate.dialect.MySQL5Dialect
hibernate: # hibernate:
ddl-auto: update # ddl-auto: update
datasource: datasource:
url: jdbc:mysql://47.105.193.165:3306/dev0?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true&serverTimezone=GMT%2B8 url: jdbc:mysql://47.105.193.165:3306/dev0?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true&serverTimezone=GMT%2B8
username: root username: root
......
package com.keymobile; package com.keymobile;
import com.keymobile.rest.service.AssignmentService; import com.keymobile.rest.service.ActivityService;
import org.activiti.engine.*; import org.activiti.engine.*;
import org.activiti.engine.history.HistoricProcessInstance; import org.activiti.engine.history.HistoricProcessInstance;
import org.activiti.engine.history.HistoricProcessInstanceQuery; import org.activiti.engine.history.HistoricProcessInstanceQuery;
...@@ -18,7 +18,7 @@ import java.util.List; ...@@ -18,7 +18,7 @@ import java.util.List;
public class ProcessTest { public class ProcessTest {
@Resource @Resource
private AssignmentService assignmentService; private ActivityService activityService;
@Resource @Resource
private RepositoryService repositoryService; private RepositoryService repositoryService;
@Resource @Resource
......
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