Commit d8026ea9 by chenweisong

更新

parent 3cf5519e
......@@ -174,7 +174,7 @@
</dependencies>
</dependencyManagement>
<build>
<finalName>record-demo</finalName>
<finalName>admin</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
......
......@@ -24,7 +24,6 @@ import org.springframework.web.bind.annotation.*;
import java.sql.Timestamp;
import java.util.*;
import java.util.stream.Collectors;
@Api(description = "活动 控制器")
@RestController
......@@ -91,59 +90,42 @@ public class TaskController {
@ApiOperation(value = "我的任务", notes = "补录任务列表及审核任务列表")
@ApiImplicitParams({
@ApiImplicitParam(name = "userId", value = "用户id", paramType = "query", required = true, dataType = "long")
@ApiImplicitParam(name = "userId", value = "用户id", paramType = "query", required = false, dataType = "long")
})
@PostMapping(value = "/getMyMissions")
public ApiResponse getMyMissions(long userId) {
User user = userService.findById(userId);
TwinkleValidator.notNull(user, "用户不存在");
List<Activity> activityList = 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();
// Activity activity = assignmentService.findByProcessId(processId);
// if (assignment != null && assignment.getStatus() != Assignment.STATUS_COMPLETED) {
// if (task.getTaskDefinitionKey().equals("addData")) {
// assignment.setKind(Assignment.KIND_RECORD);
// } else {
// assignment.setKind(Assignment.KIND_AUDIT);
// }
// activityList.add(activity);
// }
// }
return ApiResponse.ok();
}
@ApiOperation(value = "我的任务", notes = "补录任务列表及审核任务列表")
@PostMapping(value = "/getMyTasks")
public ApiResponse getMyTasks() {
List<Activity> activityList = new ArrayList<>();
public ApiResponse getMyMissions(Long userId) {
// User user = userService.findById(userId);
// TwinkleValidator.notNull(user, "用户不存在");
List<Map> missions = new ArrayList<>();
List<User> userList = userService.findAll();
StringBuilder assigneesBuilder = new StringBuilder();
assigneesBuilder.append("(");
userList.forEach(user -> {
assigneesBuilder.append("'" + user.getUsername() + "'").append(",");
});
String assignees = assigneesBuilder.substring(0, assigneesBuilder.length() - 1) + ")";
// 获取任务
// 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();
// Activity activity = assignmentService.findByProcessId(processId);
// if (assignment != null && assignment.getStatus() != Assignment.STATUS_COMPLETED) {
// if (task.getTaskDefinitionKey().equals("addData")) {
// assignment.setKind(Assignment.KIND_RECORD);
// } else {
// assignment.setKind(Assignment.KIND_AUDIT);
// }
// activityList.add(activity);
// }
// }
String sql = "SELECT * FROM " + managementService.getTableName(Task.class) + " T WHERE T.ASSIGNEE_ in " + assignees;
List<Task> tasks = taskService.createNativeTaskQuery()
.sql(sql)
.list();
for (Task task : tasks) {
String processId = task.getProcessInstanceId();
List<Process> processList = processService.findAllByProcessId(processId);
// Process process = processService.findByProcessIdAndStatus(processId, Process.STATUS_RECORDING);
if (processList.size() != 0) {
Map mission = new HashMap();
mission.put("1", 1);
if (task.getTaskDefinitionKey().equals("addData")) {
} else {
}
missions.add(mission);
}
}
return ApiResponse.ok();
}
......@@ -153,6 +135,7 @@ public class TaskController {
public ApiResponse createTask(@RequestBody TaskForm form) {
TwinkleValidator.notEmpty(form.getName(), "名称不能为空");
TwinkleValidator.notNull(form.getType(), "类型不能为空");
TwinkleValidator.isTrue(form.getExcels() != null && form.getExcels().size() != 0, "补录模板不能为空");
// 创建人 为 manager
User admin = getAdmin();
......@@ -167,6 +150,7 @@ public class TaskController {
// 新建excel实例
List<ExcelForm> excelFormList = form.getExcels();
excelFormList.forEach(excelForm -> {
TwinkleValidator.isNotNULL(excelForm.getScopeId(), "模板scopeId不能为空");
RecordScope scope = recordScopeService.findById(excelForm.getScopeId());
TwinkleValidator.isNotNULL(scope, "补录范围不能为空");
TwinkleValidator.isFalse((StringUtils.isEmpty(excelForm.getUpStreamAddr()) && StringUtils.isNotEmpty(excelForm.getBackStreamAddr())
......@@ -178,7 +162,7 @@ public class TaskController {
// 查找当前补录范围所有的用户
List<User> userList = scope.getUserList();
TwinkleValidator.notLessThan(userList.size(), 1, "补录人员不存在");
TwinkleValidator.notLessThan(userList.size(), 1, "补录人员不存在,所选补录范围需要先绑定用户");
userList.forEach(user -> {
// 创建了一些空白任务
......
......@@ -36,7 +36,19 @@ public class UserController {
@ApiOperation(value = "获取补录人员列表")
@PostMapping(value = "/user/list")
public ApiResponse getUserList() {
List<User> userList = userService.findAll();
List<Map> userList = new ArrayList<>();
List<RecordScope> recordScopeList = recordScopeService.findAll();
recordScopeList.forEach(recordScope -> {
Map map = new HashMap();
map.put("id", recordScope.getId());
map.put("desc", recordScope.getDesc());
map.put("groupId", recordScope.getGroup().getId());
map.put("groupName", recordScope.getGroup().getId());
List<User> users = userService.findAllByGroupId(recordScope.getGroup().getId());
map.put("userList", users);
userList.add(map);
});
// List<User> userList = userService.findAll();
return ApiResponse.ok(userList);
}
......@@ -44,7 +56,22 @@ public class UserController {
@PostMapping(value = "/scope/list")
public ApiResponse getScopeList() {
List<RecordScope> recordScopeList = recordScopeService.findAll();
return ApiResponse.ok(recordScopeList);
List<Map> result = new ArrayList<>();
recordScopeList.forEach(recordScope -> {
Map map = new HashMap();
map.put("id", recordScope.getId());
map.put("desc", recordScope.getDesc());
map.put("groupId", recordScope.getGroup().getId());
map.put("groupName", recordScope.getGroup().getId());
List<User> users = recordScope.getUserList();
User user = null;
if (users.size() >= 1) {
user = users.get(0);
}
map.put("user", user);
result.add(map);
});
return ApiResponse.ok(result);
}
@ApiOperation(value = "补录范围绑定人员")
......@@ -59,10 +86,10 @@ public class UserController {
User user = userService.findById(userId);
TwinkleValidator.notNull(user, "所选用户不存在");
TwinkleValidator.isTrue(scope.getGroup().getId() == user.getGroup().getId(), "所选用户与所选范围不属于同一机构");
List<User> userList = scope.getUserList();
List<User> userList = new ArrayList<>();
userList.add(user);
scope.setUserList(userList);
recordScopeService.update(scope);
recordScopeService.save(scope);
return ApiResponse.ok();
}
......
......@@ -3,6 +3,11 @@ package com.keymobile.rest.dao;
import com.keymobile.rest.model.Process;
import org.springframework.data.jpa.repository.JpaRepository;
import java.util.List;
public interface ProcessDao extends JpaRepository<Process, Long> {
List<Process> findAllByProcessId(String processId);
Process findByProcessIdAndStatus(String processId, int status);
}
......@@ -3,7 +3,6 @@ package com.keymobile.rest.model;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonSetter;
import lombok.Data;
import lombok.NoArgsConstructor;
......@@ -25,10 +24,16 @@ public class RecordScope implements Serializable {
public static int ROLE_RECORD = 1;
public static int ROLE_AUDIT = 2;
public static String ROLE_RECORD_DESC = "补录人员";
public static String ROLE_AUDIT_DESC = "审核人员";
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private long id;
@Column(name = "`desc`", nullable = false, columnDefinition = ("varchar(100) comment '补录角色描述'"))
private String desc;
@Column(nullable = false, columnDefinition = ("integer(2) comment '补录角色'"))
private int role;
......@@ -37,11 +42,12 @@ public class RecordScope implements Serializable {
private Group group;
@ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
@JsonIgnore
@JoinTable(name = "t_user_record_scope", // 用来指定中间表的名称
//用于指定本表在中间表的字段名称,以及中间表依赖的是本表的哪个字段
joinColumns = {@JoinColumn(name = "user_id", referencedColumnName = "id")},
joinColumns = {@JoinColumn(name = "record_scope_id", referencedColumnName = "id")},
//用于指定对方表在中间表的字段名称,以及中间表依赖的是它的哪个字段
inverseJoinColumns = {@JoinColumn(name = "record_scope", referencedColumnName = "id")}
inverseJoinColumns = {@JoinColumn(name = "user_id", referencedColumnName = "id")}
)
private List<User> userList;
}
......@@ -32,7 +32,7 @@ public class Template implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private long id;
private Long id;
@Column(nullable = false, columnDefinition = ("varchar(20) comment '模板名称'"))
private String name;
......@@ -41,16 +41,16 @@ public class Template implements Serializable {
private String config;
@Column(name = "data_at", columnDefinition = ("integer(20) default 1 comment '数据开始行数'"))
private int dataAt;
private Integer dataAt;
@Column(name = "need_audit", columnDefinition = ("integer(2) default 0 comment '需要审核'"))
private int needAudit;
private Integer needAudit;
@Column(name = "need_confirm", columnDefinition = ("integer(2) default 0 comment '需要负责人确认'"))
private int needConfirm;
private Integer needConfirm;
@Column(name = "need_merge", columnDefinition = ("integer(2) default 0 comment '需要数据合并'"))
private int needMerge;
private Integer needMerge;
@Column(name = "up_stream_addr", columnDefinition = ("varchar(100) comment '上游地址'"))
private String upStreamAddr;
......
......@@ -7,7 +7,6 @@ import lombok.NoArgsConstructor;
import javax.persistence.*;
import java.io.Serializable;
import java.util.List;
@JsonIgnoreProperties(value = {"hibernateLazyInitializer", "handler", "fieldHandler"})
@NoArgsConstructor
......@@ -30,5 +29,6 @@ public class User implements Serializable {
* 所属结构id
*/
@ManyToOne(fetch = FetchType.EAGER)
@JsonIgnore
private Group group;
}
......@@ -31,10 +31,6 @@ public class ActivityService {
return activityDao.save(activity);
}
public Activity findByProcessId(String pid) {
return null;
}
public Page<Activity> findAll(int pageNo, int pageSize) {
Pageable pageable = convert(pageNo, pageSize);
return activityDao.findAll(pageable);
......
......@@ -5,6 +5,8 @@ import com.keymobile.rest.model.Process;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class ProcessService {
......@@ -16,4 +18,14 @@ public class ProcessService {
processDao.save(process);
return process;
}
public List<Process> findAllByProcessId(String processId) {
return processDao.findAllByProcessId(processId);
}
public Process findByProcessIdAndStatus(String processId, int status) {
return processDao.findByProcessIdAndStatus(processId, status);
}
}
......@@ -29,10 +29,12 @@ public class RecordScopeService {
RecordScope scope = new RecordScope();
scope.setGroup(group);
scope.setRole(RecordScope.ROLE_RECORD);
scope.setDesc(group.getName() + RecordScope.ROLE_RECORD_DESC);
recordScopeDao.save(scope);
scope = new RecordScope();
scope.setGroup(group);
scope.setRole(RecordScope.ROLE_AUDIT);
scope.setDesc(group.getName() + RecordScope.ROLE_AUDIT_DESC);
recordScopeDao.save(scope);
}
});
......@@ -46,7 +48,7 @@ public class RecordScopeService {
return recordScopeDao.findAll();
}
public void update(RecordScope recordScope) {
public void save(RecordScope recordScope) {
recordScopeDao.save(recordScope);
}
}
......@@ -30,8 +30,8 @@ spring:
max-file-size: 20Mb
max-request-size: 100Mb
redis:
host: 192.168.0.192
# host: 127.0.0.1
# host: 192.168.0.192
host: 127.0.0.1
port: 6379
session:
store-type: redis
......@@ -46,8 +46,8 @@ app:
active-process: MoreSubProcessTest.bpmn
swagger2:
host: localhost:8110
# host: 47.105.236.43/activiti
# host: localhost:8110
host: 47.105.236.43/activiti
security:
permit: true
\ No newline at end of file
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