Commit 19658779 by chenweisong

更新

parent a6ce3c08
...@@ -28,10 +28,10 @@ ...@@ -28,10 +28,10 @@
<!-- <groupId>org.springframework.boot</groupId>--> <!-- <groupId>org.springframework.boot</groupId>-->
<!-- <artifactId>spring-boot-starter-data-mongodb</artifactId>--> <!-- <artifactId>spring-boot-starter-data-mongodb</artifactId>-->
<!-- </dependency>--> <!-- </dependency>-->
<!-- <dependency>--> <dependency>
<!-- <groupId>org.springframework.cloud</groupId>--> <groupId>org.springframework.cloud</groupId>
<!-- <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>--> <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
<!-- </dependency>--> </dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId> <artifactId>spring-boot-starter-test</artifactId>
......
package com.keymobile.rest.common.conf;
import feign.RetryableException;
import feign.Retryer;
import feign.auth.BasicAuthRequestInterceptor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class FeignClientConfig {
@Value("${security.authUser}")
private String authUser;
@Value("${security.authPwd}")
private String authPwd;
@Bean
public BasicAuthRequestInterceptor getBasicAuthRequestInterceptor() {
return new BasicAuthRequestInterceptor(authUser, authPwd);
}
// @Bean
public Retryer retryer() {
return new Custom();
}
class Custom implements Retryer {
private final int maxAttempts;
private final long backoff;
int attempt;
public Custom() {
this(5000, 6);
}
public Custom(long backoff, int maxAttempts) {
this.backoff = backoff;
this.maxAttempts = maxAttempts;
this.attempt = 1;
}
public void continueOrPropagate(RetryableException e) {
if (attempt++ >= maxAttempts) {
throw e;
}
try {
Thread.sleep(backoff);
} catch (InterruptedException ignored) {
Thread.currentThread().interrupt();
}
}
@Override
public Retryer clone() {
return new Custom(backoff, maxAttempts);
}
}
}
\ No newline at end of file
...@@ -11,7 +11,6 @@ import com.keymobile.rest.service.*; ...@@ -11,7 +11,6 @@ import com.keymobile.rest.service.*;
import com.keymobile.rest.dto.ExcelForm; import com.keymobile.rest.dto.ExcelForm;
import com.keymobile.rest.dto.TaskForm; import com.keymobile.rest.dto.TaskForm;
import com.keymobile.rest.vo.SimpleTask; import com.keymobile.rest.vo.SimpleTask;
import com.keymobile.rest.vo.SimpleTemplate;
import io.swagger.annotations.*; import io.swagger.annotations.*;
import org.activiti.engine.*; import org.activiti.engine.*;
import org.activiti.engine.repository.Deployment; import org.activiti.engine.repository.Deployment;
...@@ -47,7 +46,7 @@ public class TaskController { ...@@ -47,7 +46,7 @@ public class TaskController {
@Autowired @Autowired
private ProcessService processService; private ProcessService processService;
@Autowired @Autowired
private RecordScopeService recordScopeService; private UserTemplateMapperService userTemplateMapperService;
@Autowired @Autowired
...@@ -122,7 +121,7 @@ public class TaskController { ...@@ -122,7 +121,7 @@ public class TaskController {
long templateId = Long.parseLong(assignee.split(":template:")[1]); long templateId = Long.parseLong(assignee.split(":template:")[1]);
String processId = task.getProcessInstanceId(); String processId = task.getProcessInstanceId();
Process process = processService.findByProcessId(processId); Process process = processService.findByProcessId(processId);
Mission mission = missionService.findByProcessIdAndUsernameAndTemplateIdAndStatus(process.getId(), user.getUsername(), templateId, Mission.STATUS_BEGIN); Mission mission = missionService.findByProcessIdAndUsernameAndTemplateIdAndStatusAndType(process.getId(), user.getUsername(), templateId, Mission.STATUS_BEGIN);
mission.setTaskId(task.getId()); mission.setTaskId(task.getId());
missionService.save(mission); missionService.save(mission);
map.put("id", mission.getId()); map.put("id", mission.getId());
...@@ -184,7 +183,7 @@ public class TaskController { ...@@ -184,7 +183,7 @@ public class TaskController {
CommonValidator.isTrue(excelForm.getNeedAudit() != null && excelForm.getNeedAudit() != 0, "模板needAudit不能为空"); CommonValidator.isTrue(excelForm.getNeedAudit() != null && excelForm.getNeedAudit() != 0, "模板needAudit不能为空");
CommonValidator.isTrue(excelForm.getNeedConfirm() != null && excelForm.getNeedConfirm() != 0, "模板needConfirm不能为空"); CommonValidator.isTrue(excelForm.getNeedConfirm() != null && excelForm.getNeedConfirm() != 0, "模板needConfirm不能为空");
RecordScope scope = recordScopeService.findById(excelForm.getScopeId()); UserTemplateMapper scope = userTemplateMapperService.findById(excelForm.getScopeId());
CommonValidator.isTrue(scope != null, "补录范围不能为空"); CommonValidator.isTrue(scope != null, "补录范围不能为空");
CommonValidator.isFalse((StringUtils.isEmpty(excelForm.getUpStreamAddr()) && StringUtils.isNotEmpty(excelForm.getBackStreamAddr()) CommonValidator.isFalse((StringUtils.isEmpty(excelForm.getUpStreamAddr()) && StringUtils.isNotEmpty(excelForm.getBackStreamAddr())
...@@ -197,13 +196,13 @@ public class TaskController { ...@@ -197,13 +196,13 @@ public class TaskController {
final Template finalTemplate = templateService.save(template); final Template finalTemplate = templateService.save(template);
// 查找当前补录范围所有的用户 // 查找当前补录范围所有的用户
List<User> userList = scope.getUserList(); // List<User> userList = scope.getUserList();
CommonValidator.notLessThan(userList.size(), 1, "补录人员不存在,所选补录范围需要先绑定用户"); // CommonValidator.notLessThan(userList.size(), 1, "补录人员不存在,所选补录范围需要先绑定用户");
userList.forEach(user -> { // userList.forEach(user -> {
// 创建了一些空白任务 // // 创建了一些空白任务
missionService.save(user, finalTemplate); // missionService.save(user, finalTemplate);
}); // });
}); });
return ApiResponse.ok(activity.getId()); return ApiResponse.ok(activity.getId());
} }
......
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.common.validator.CommonValidator;
import com.keymobile.rest.model.*;
import com.keymobile.rest.service.*; import com.keymobile.rest.service.*;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
...@@ -13,88 +11,49 @@ import org.springframework.web.bind.annotation.*; ...@@ -13,88 +11,49 @@ import org.springframework.web.bind.annotation.*;
import java.util.*; import java.util.*;
@Api(description = "用户/机构/补录范围 控制器") @Api(description = "用户/用户组/机构 控制器")
@RestController @RestController
@RequestMapping(path = "/api") @RequestMapping(path = "/api")
public class UserController { public class UserController {
@Autowired @Autowired
private UserService userService; private FeignAuthService feignAuthService;
@Autowired
private GroupService groupService;
@Autowired
private RecordScopeService recordScopeService;
private Group root = new Group();
{ @ApiOperation(value = "获取机构树")
root.setId(Group.ROOT_ID); @PostMapping(value = "/orgs")
root.setName(Group.ROOT_NAME); public ApiResponse getOrgs() {
root.setParentId(Group.ROOT_PARENT_ID); return ApiResponse.ok(feignAuthService.getOrgs());
root.setLevel(Group.ROOT_LEVEL);
} }
@ApiOperation(value = "获取补录人员列表")
@PostMapping(value = "/user/list")
public ApiResponse getUserList() {
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> existUsers = recordScope.getUserList();
User user = null;
if (existUsers.size() >= 1) {
user = existUsers.get(0);
}
map.put("bindedUser", user);
List<User> users = userService.findAllByGroupId(recordScope.getGroup().getId());
map.put("userList", users);
userList.add(map);
});
return ApiResponse.ok(userList);
}
@ApiOperation(value = "获取补录范围列表")
@PostMapping(value = "/scope/list")
public ApiResponse getScopeList() {
List<RecordScope> recordScopeList = recordScopeService.findAll();
return ApiResponse.ok(recordScopeList);
}
@ApiOperation(value = "补录范围绑定人员") @ApiOperation(value = "获取机构下的用户")
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(name = "scopeId", value = "补录范围id", paramType = "query", required = true, dataType = "long"), @ApiImplicitParam(name = "orgId", value = "机构id", paramType = "query", required = true, dataType = "long")
@ApiImplicitParam(name = "userId", value = "用户id", paramType = "query", required = true, dataType = "long")
}) })
@PostMapping(value = "/scope/bindUser") @PostMapping(value = "/org/users")
public ApiResponse bindUser(long scopeId, long userId) { public ApiResponse getOrgUsers(long orgId) {
RecordScope scope = recordScopeService.findById(scopeId); List<Map> users = feignAuthService.getUsersByOrgId(orgId);
CommonValidator.notNull(scope, "所选范围不存在"); return ApiResponse.ok(users);
User user = userService.findById(userId);
CommonValidator.notNull(user, "所选用户不存在");
CommonValidator.isTrue(scope.getGroup().getId() == user.getGroup().getId(), "所选用户与所选范围不属于同一机构");
List<User> userList = scope.getUserList();
if (!userList.contains(user)) {
userList.add(user);
scope.setUserList(userList);
recordScopeService.save(scope);
}
return ApiResponse.ok();
} }
@ApiOperation(value = "获取机构列表") @ApiOperation(value = "获取补录范围(用户组)")
@PostMapping(value = "/group/list") @ApiImplicitParams({
public ApiResponse getGroupList() { @ApiImplicitParam(name = "orgId", value = "机构id", paramType = "query", required = true, dataType = "long")
return ApiResponse.ok(getGroupTree()); })
@PostMapping(value = "/groups")
public ApiResponse getUserGroups(long orgId) {
List<Map> userGroups = feignAuthService.getUserGroups(0, orgId);
return ApiResponse.ok(userGroups);
} }
public Group getGroupTree() { @ApiOperation(value = "获取补录范围(用户组)下的用户")
List<Group> children = groupService.findAllByParentId(root.getId()); @ApiImplicitParams({
root.setChildren(children); @ApiImplicitParam(name = "userGroupId", value = "用户组id", paramType = "query", required = true, dataType = "long")
return root; })
@PostMapping(value = "/group/users")
public ApiResponse getGroupUsers(long userGroupId) {
List<Map> users = feignAuthService.getGroupUsers(0, userGroupId);
return ApiResponse.ok(users);
} }
} }
package com.keymobile.rest.dao;
import com.keymobile.rest.model.Group;
import org.springframework.data.jpa.repository.JpaRepository;
import java.util.List;
public interface GroupDao extends JpaRepository<Group, Long> {
List<Group> findAllByParentId(long parentId);
}
package com.keymobile.rest.dao;
import com.keymobile.rest.model.RecordScope;
import org.springframework.data.jpa.repository.JpaRepository;
import java.util.List;
public interface RecordScopeDao extends JpaRepository<RecordScope, Long> {
List<RecordScope> findAllByGroupId(long groupId);
}
...@@ -9,6 +9,4 @@ public interface UserDao extends JpaRepository<User, Long> { ...@@ -9,6 +9,4 @@ public interface UserDao extends JpaRepository<User, Long> {
List<User> findAllByIdIn(List<Long> ids); List<User> findAllByIdIn(List<Long> ids);
List<User> findAllByUsername(String username); List<User> findAllByUsername(String username);
List<User> findAllByGroupId(long groupId);
} }
package com.keymobile.rest.dao;
import com.keymobile.rest.model.UserTemplateMapper;
import org.springframework.data.jpa.repository.JpaRepository;
public interface UserTemplateMapperDao extends JpaRepository<UserTemplateMapper, Long> {
}
package com.keymobile.rest.model; package com.keymobile.rest.model;
import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.CreationTimestamp;
import java.sql.Timestamp; import java.sql.Timestamp;
...@@ -16,8 +13,6 @@ import java.util.List; ...@@ -16,8 +13,6 @@ import java.util.List;
* @name 活动, 任务 * @name 活动, 任务
* @desc 包含一些活动的定义以及绑定一些spreadJs生成的excel模板 * @desc 包含一些活动的定义以及绑定一些spreadJs生成的excel模板
*/ */
@JsonIgnoreProperties(value = {"hibernateLazyInitializer", "handler", "fieldHandler"})
@NoArgsConstructor
@Data @Data
@Entity @Entity
@Table(name = "t_activity") @Table(name = "t_activity")
...@@ -51,12 +46,8 @@ public class Activity implements Serializable { ...@@ -51,12 +46,8 @@ public class Activity implements Serializable {
private Integer freq; private Integer freq;
@Column(nullable = false, name = "create_at") @Column(nullable = false, name = "create_at")
@CreationTimestamp
private Timestamp createAt; private Timestamp createAt;
@OneToMany(fetch = FetchType.EAGER, mappedBy = "activity")
private List<Template> templateList;
/** /**
* 发送人 * 发送人
...@@ -64,6 +55,9 @@ public class Activity implements Serializable { ...@@ -64,6 +55,9 @@ public class Activity implements Serializable {
@ManyToOne @ManyToOne
private User user; private User user;
@OneToMany(fetch = FetchType.EAGER, mappedBy = "activity")
private List<Template> templateList;
/** /**
* 该活动跑过得所有流程 * 该活动跑过得所有流程
*/ */
...@@ -71,7 +65,6 @@ public class Activity implements Serializable { ...@@ -71,7 +65,6 @@ public class Activity implements Serializable {
@JsonIgnore @JsonIgnore
private List<Process> processList; private List<Process> processList;
/** /**
* 该活动跑过得所有任务 * 该活动跑过得所有任务
*/ */
......
package com.keymobile.rest.model; package com.keymobile.rest.model;
import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.CreationTimestamp; import org.hibernate.annotations.CreationTimestamp;
import javax.persistence.*; import javax.persistence.*;
...@@ -13,8 +11,6 @@ import java.sql.Timestamp; ...@@ -13,8 +11,6 @@ import java.sql.Timestamp;
/** /**
* 已经填写的数据实例 * 已经填写的数据实例
*/ */
@JsonIgnoreProperties(value = {"hibernateLazyInitializer", "handler", "fieldHandler"})
@NoArgsConstructor
@Data @Data
@Entity @Entity
@Table(name = "t_data_info") @Table(name = "t_data_info")
...@@ -28,7 +24,6 @@ public class DataInfo implements Serializable { ...@@ -28,7 +24,6 @@ public class DataInfo implements Serializable {
private String data; private String data;
@Column(nullable = false, name = "create_at") @Column(nullable = false, name = "create_at")
@CreationTimestamp
private Timestamp createAt; private Timestamp createAt;
@OneToOne(fetch = FetchType.LAZY) @OneToOne(fetch = FetchType.LAZY)
......
package com.keymobile.rest.model;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.persistence.*;
import java.io.Serializable;
import java.util.List;
/**
* @name 机构
* @desc
*/
@JsonIgnoreProperties(value = {"hibernateLazyInitializer", "handler", "fieldHandler"})
@NoArgsConstructor
@Data
@Entity
@Table(name = "t_group")
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
@GeneratedValue(strategy = GenerationType.IDENTITY)
private long id;
@Column(nullable = false, columnDefinition = ("varchar(20) comment '机构名称'"))
private String name;
@Column(nullable = false, columnDefinition = ("integer(2) default 0 comment '机构层级'"))
private int level = 0;
@Column(name = "parent_id", columnDefinition = ("bigint(22) default 0 comment '父机构id'"))
private long parentId = 0;
/**
* 常见的父子数据结构
* {
* node: {
* id: 0,
* name: "",
* fullName: ""
* },
* subNodes: []
* }
*/
@Transient
private List<Group> children;
}
package com.keymobile.rest.model; package com.keymobile.rest.model;
import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.CreationTimestamp;
import javax.persistence.*; import javax.persistence.*;
import java.io.Serializable; import java.io.Serializable;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.util.List;
/** /**
* 进程&指派人员关系 * 任务流水
*/ */
@JsonIgnoreProperties(value = {"hibernateLazyInitializer", "handler", "fieldHandler"})
@NoArgsConstructor
@Data @Data
@Entity @Entity
@Table(name = "t_mission") @Table(name = "t_mission")
...@@ -32,7 +26,6 @@ public class Mission implements Serializable { ...@@ -32,7 +26,6 @@ public class Mission implements Serializable {
private long id; private long id;
@Column(name = "create_at", nullable = false, columnDefinition = ("DATETIME COMMENT '创建时间'")) @Column(name = "create_at", nullable = false, columnDefinition = ("DATETIME COMMENT '创建时间'"))
@CreationTimestamp
private Timestamp createAt; private Timestamp createAt;
@Column(nullable = false, columnDefinition = ("integer(2) default 1 COMMENT '类型'")) @Column(nullable = false, columnDefinition = ("integer(2) default 1 COMMENT '类型'"))
......
...@@ -2,9 +2,7 @@ package com.keymobile.rest.model; ...@@ -2,9 +2,7 @@ package com.keymobile.rest.model;
import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor;
import javax.persistence.*; import javax.persistence.*;
import java.io.Serializable; import java.io.Serializable;
...@@ -14,8 +12,6 @@ import java.util.List; ...@@ -14,8 +12,6 @@ import java.util.List;
* @name 进程 * @name 进程
* @desc * @desc
*/ */
@JsonIgnoreProperties(value = {"hibernateLazyInitializer", "handler", "fieldHandler"})
@NoArgsConstructor
@Data @Data
@Entity @Entity
@Table(name = "t_process") @Table(name = "t_process")
......
package com.keymobile.rest.model;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.persistence.*;
import java.io.Serializable;
import java.util.List;
/**
* @name 补录范围
* @desc
*/
@JsonIgnoreProperties(value = {"hibernateLazyInitializer", "handler", "fieldHandler"})
@NoArgsConstructor
@Data
@Entity
@Table(name = "t_record_scope")
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;
@ManyToOne(fetch = FetchType.EAGER)
@JsonIgnore
private Group group;
@ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
@JsonIgnore
@JoinTable(name = "t_user_record_scope", // 用来指定中间表的名称
//用于指定本表在中间表的字段名称,以及中间表依赖的是本表的哪个字段
joinColumns = {@JoinColumn(name = "record_scope_id", referencedColumnName = "id")},
//用于指定对方表在中间表的字段名称,以及中间表依赖的是它的哪个字段
inverseJoinColumns = {@JoinColumn(name = "user_id", referencedColumnName = "id")}
)
private List<User> userList;
}
package com.keymobile.rest.model; package com.keymobile.rest.model;
import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.CreationTimestamp;
import javax.persistence.*; import javax.persistence.*;
import java.io.Serializable; import java.io.Serializable;
...@@ -13,8 +10,6 @@ import java.sql.Timestamp; ...@@ -13,8 +10,6 @@ import java.sql.Timestamp;
/** /**
* spreadJs 配置的报表 * spreadJs 配置的报表
*/ */
@JsonIgnoreProperties(value = {"hibernateLazyInitializer", "handler", "fieldHandler"})
@NoArgsConstructor
@Data @Data
@Entity @Entity
@Table(name = "t_template") @Table(name = "t_template")
...@@ -29,7 +24,6 @@ public class Template implements Serializable { ...@@ -29,7 +24,6 @@ public class Template implements Serializable {
public static int NEED_MERGE = 2; public static int NEED_MERGE = 2;
public static int NO_NEED_MERGE = 1; public static int NO_NEED_MERGE = 1;
@Id @Id
@GeneratedValue(strategy = GenerationType.IDENTITY) @GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id; private Long id;
...@@ -62,7 +56,6 @@ public class Template implements Serializable { ...@@ -62,7 +56,6 @@ public class Template implements Serializable {
private String remark; private String remark;
@Column(nullable = false, name = "create_at") @Column(nullable = false, name = "create_at")
@CreationTimestamp
private Timestamp createAt; private Timestamp createAt;
@ManyToOne(fetch = FetchType.LAZY) @ManyToOne(fetch = FetchType.LAZY)
......
package com.keymobile.rest.model; package com.keymobile.rest.model;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor;
import javax.persistence.*; import javax.persistence.*;
import java.io.Serializable; import java.io.Serializable;
@JsonIgnoreProperties(value = {"hibernateLazyInitializer", "handler", "fieldHandler"}) /**
@NoArgsConstructor * 内部用户 例如 发起人 审核人
*/
@Data @Data
@Entity @Entity
@Table(name = "t_user") @Table(name = "t_user")
...@@ -17,6 +15,7 @@ public class User implements Serializable { ...@@ -17,6 +15,7 @@ public class User implements Serializable {
public static int ROLE_NORMAL = 1; public static int ROLE_NORMAL = 1;
public static int ROLE_AUDIT = 2; public static int ROLE_AUDIT = 2;
public static int ROLE_MANAGER = 3;
@Id @Id
@GeneratedValue(strategy = GenerationType.IDENTITY) @GeneratedValue(strategy = GenerationType.IDENTITY)
...@@ -25,10 +24,8 @@ public class User implements Serializable { ...@@ -25,10 +24,8 @@ public class User implements Serializable {
@Column(nullable = false, columnDefinition = ("varchar(100) comment '用户名'")) @Column(nullable = false, columnDefinition = ("varchar(100) comment '用户名'"))
private String username; private String username;
/** @Column(nullable = false, columnDefinition = ("integer(2) comment '角色 1 普通 2 审核人 3 管理人'"))
* 所属结构id private int role;
*/
@ManyToOne(fetch = FetchType.EAGER)
@JsonIgnore
private Group group;
} }
package com.keymobile.rest.model;
import lombok.Data;
import javax.persistence.*;
import java.io.Serializable;
import java.sql.Timestamp;
/**
* @name 用户以及模板绑定记录
* @desc
*/
@Data
@Entity
@Table(name = "t_user_template_mapper")
public class UserTemplateMapper implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private long id;
@Column(nullable = false, columnDefinition = ("bigint(22) comment '用户id'"))
private long userId;
@Column(nullable = false, columnDefinition = ("bigint(22) comment '模板id'"))
private long templateId;
@Column(nullable = false, name = "create_at")
private Timestamp createAt;
}
package com.keymobile.rest.service;
import com.keymobile.rest.common.conf.FeignClientConfig;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
import java.util.Map;
/**
* 查找spring cloud中服务名为authService的服务
*/
@FeignClient(value = "authService", configuration = FeignClientConfig.class)
public interface FeignAuthService {
@GetMapping("/orgs")
Object getOrgs();
@GetMapping("/allOrgs")
List<Map> getAllOrgs();
@GetMapping("/orgs/findByFullName")
List<Map> getOrgByFullName(@RequestParam("orgFullName") String orgFullName);
@GetMapping("/orgs/{orgId}")
Object getOrgById(@PathVariable("orgId") long orgId);
@GetMapping("/users/find")
List<Map> getUsersByOrgId(@RequestParam("orgId") long orgId);
/**
* 获取所有用户组
* domainId 默认为0L
*
* @param domainId
* @return
*/
@GetMapping("/domains/{domainId}/userGroups")
List<Map> getUserGroups(@PathVariable("domainId") long domainId, @RequestParam("orgId") long orgId);
@GetMapping("/domains/{domainId}/userGroups/{userGroupId}/users")
List<Map> getGroupUsers(@PathVariable("domainId") long domainId, @PathVariable("userGroupId") long userGroupId);
}
package com.keymobile.rest.service;
import com.keymobile.rest.dao.GroupDao;
import com.keymobile.rest.model.Group;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class GroupService {
@Autowired
private GroupDao groupDao;
public List<Group> findAllByParentId(long parentId) {
return groupDao.findAllByParentId(parentId);
}
}
...@@ -40,7 +40,7 @@ public class MissionService { ...@@ -40,7 +40,7 @@ public class MissionService {
} }
public Mission findByProcessIdAndUsernameAndTemplateIdAndStatusAndType(long processId, String username, long templateId, int status) { public Mission findByProcessIdAndUsernameAndTemplateIdAndStatusAndType(long processId, String username, long templateId, int status) {
return missionDao.findByProcessIdAndUserUsernameAndTemplateIdAndStatus(processId, username, templateId, status); return missionDao.findByProcessIdAndUserUsernameAndTemplateIdAndStatusAndType(processId, username, templateId, 1, status);
} }
public List<Mission> findAllByTemplateIdAndStatus(long templateId, int status) { public List<Mission> findAllByTemplateIdAndStatus(long templateId, int status) {
......
package com.keymobile.rest.service;
import com.keymobile.rest.dao.GroupDao;
import com.keymobile.rest.dao.RecordScopeDao;
import com.keymobile.rest.model.Group;
import com.keymobile.rest.model.RecordScope;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.PostConstruct;
import java.util.List;
@Service
public class RecordScopeService {
@Autowired
private RecordScopeDao recordScopeDao;
@Autowired
private GroupDao groupDao;
@PostConstruct
private void init() {
List<Group> groupList = groupDao.findAll();
// 每个机构创建两条补录范围供填写
groupList.forEach(group -> {
List<RecordScope> exists = recordScopeDao.findAllByGroupId(group.getId());
if (exists.size() != 2) {
RecordScope scope = new RecordScope();
scope.setGroup(group);
scope.setDesc(group.getName() + RecordScope.ROLE_RECORD_DESC);
recordScopeDao.save(scope);
scope = new RecordScope();
scope.setGroup(group);
scope.setDesc(group.getName() + RecordScope.ROLE_AUDIT_DESC);
recordScopeDao.save(scope);
}
});
}
public RecordScope findById(long id) {
return recordScopeDao.getOne(id);
}
public List<RecordScope> findAll() {
return recordScopeDao.findAll();
}
public void save(RecordScope recordScope) {
recordScopeDao.save(recordScope);
}
}
package com.keymobile.rest.service;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
/**
* 查找spring cloud中服务名为authService的服务
*/
@FeignClient(value = "authService")
public interface UserFeignService {
@GetMapping("/authservice/orgs")
String getAllOrgs();
}
...@@ -17,13 +17,6 @@ public class UserService { ...@@ -17,13 +17,6 @@ public class UserService {
return userDao.findAllByUsername(username); return userDao.findAllByUsername(username);
} }
public List<User> findAllByGroupId(long groupId) {
return userDao.findAllByGroupId(groupId);
}
public List<User> findAllByIdIn(List<Long> ids) {
return userDao.findAllByIdIn(ids);
}
public List<User> findAll() { public List<User> findAll() {
return userDao.findAll(); return userDao.findAll();
......
package com.keymobile.rest.service;
import com.keymobile.rest.dao.UserTemplateMapperDao;
import com.keymobile.rest.model.UserTemplateMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class UserTemplateMapperService {
@Autowired
private UserTemplateMapperDao userTemplateMapperDao;
public UserTemplateMapper findById(long id) {
return userTemplateMapperDao.getOne(id);
}
public List<UserTemplateMapper> findAll() {
return userTemplateMapperDao.findAll();
}
public void save(UserTemplateMapper userTemplateMapper) {
userTemplateMapperDao.save(userTemplateMapper);
}
}
package com.keymobile.rest.vo; package com.keymobile.rest.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.keymobile.rest.common.utils.BeanUtils; import com.keymobile.rest.common.utils.BeanUtils;
import com.keymobile.rest.model.Activity; import com.keymobile.rest.model.Activity;
import com.keymobile.rest.model.Template; import com.keymobile.rest.model.Template;
...@@ -22,6 +23,7 @@ public class SimpleTask { ...@@ -22,6 +23,7 @@ public class SimpleTask {
private Integer freq; private Integer freq;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Timestamp createAt; private Timestamp createAt;
private List<SimpleTemplate> excelList; private List<SimpleTemplate> excelList;
......
package com.keymobile.rest.vo; package com.keymobile.rest.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.keymobile.rest.common.utils.BeanUtils; import com.keymobile.rest.common.utils.BeanUtils;
import com.keymobile.rest.model.Template; import com.keymobile.rest.model.Template;
import lombok.Data; import lombok.Data;
...@@ -15,6 +16,7 @@ public class SimpleTemplate { ...@@ -15,6 +16,7 @@ public class SimpleTemplate {
private String config; private String config;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Timestamp createAt; private Timestamp createAt;
public static SimpleTemplate convert(Template template) { public static SimpleTemplate convert(Template template) {
......
eureka:
client:
healthcheck:
enabled: true
registryFetchIntervalSeconds: 5
region: default
serviceUrl:
defaultZone: http://192.168.0.240:8081/eureka/
enabled: true
instance:
prefer-ip-address: false
hostname: 192.168.0.48
feign:
hystrix:
enabled: true
spring:
application:
name: dataCollector
jpa:
show-sql: false
database-platform: org.hibernate.dialect.MySQL5Dialect
# hibernate:
# ddl-auto: update
datasource:
url: jdbc:mysql://192.168.0.192:3306/cmb_dev?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true&serverTimezone=GMT%2B8
username: test
password: test
hikari:
maximum-pool-size: 3
servlet:
multipart:
max-file-size: 20Mb
max-request-size: 100Mb
redis:
host: 192.168.0.192
# host: 127.0.0.1
port: 6379
session:
store-type: redis
redis:
namespace: cmb_dev
activiti:
check-process-definitions: false #关闭验证自动部署
server:
port: 8110
app:
active-process: MoreSubProcess.bpmn
swagger2:
host: localhost:8110
security:
permit: true
\ No newline at end of file
...@@ -11,18 +11,24 @@ eureka: ...@@ -11,18 +11,24 @@ eureka:
prefer-ip-address: false prefer-ip-address: false
hostname: 192.168.0.48 hostname: 192.168.0.48
feign:
hystrix: hystrix:
enabled: true   command:
   default:
    execution:
     isolation:
      thread:
       timeoutInMilliseconds: 10000
spring: spring:
application: application:
name: dataCollector name: dataCollector
jpa: jpa:
show-sql: true show-sql: false
database-platform: org.hibernate.dialect.MySQL5Dialect database-platform: org.hibernate.dialect.MySQL5Dialect
hibernate: # hibernate:
ddl-auto: update # ddl-auto: update
#47.105.193.165:3306/dev0 192.168.0.192:3306/cmb_dev test test
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
...@@ -35,7 +41,6 @@ spring: ...@@ -35,7 +41,6 @@ spring:
max-request-size: 100Mb max-request-size: 100Mb
redis: redis:
host: 192.168.0.192 host: 192.168.0.192
# host: 127.0.0.1
port: 6379 port: 6379
session: session:
store-type: redis store-type: redis
...@@ -51,7 +56,8 @@ app: ...@@ -51,7 +56,8 @@ app:
swagger2: swagger2:
host: localhost:8110 host: localhost:8110
# host: 47.105.236.43/activiti
security: security:
authUser: root
authPwd: pwd
permit: true 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