Commit a240198c by chenweisong

更新

parent 367302b4
...@@ -34,7 +34,7 @@ public class IndexCtrl { ...@@ -34,7 +34,7 @@ public class IndexCtrl {
@Autowired @Autowired
private RecordDataService recordDataService; private RecordDataService recordDataService;
@Autowired @Autowired
private RecordInfoService recordInfoService; private JobInfoService jobInfoService;
@Autowired @Autowired
private UserService userService; private UserService userService;
@Autowired @Autowired
...@@ -100,8 +100,7 @@ public class IndexCtrl { ...@@ -100,8 +100,7 @@ public class IndexCtrl {
public ApiResponse createTask(@RequestBody JobForm form) { public ApiResponse createTask(@RequestBody JobForm form) {
TwinkleValidator.notEmpty(form.getName(), "名称不能为空"); TwinkleValidator.notEmpty(form.getName(), "名称不能为空");
TwinkleValidator.notNull(form.getType(), "类型不能为空"); TwinkleValidator.notNull(form.getType(), "类型不能为空");
TwinkleValidator.notLessThan(form.getExcels().size(), 1, "补录模板不能为空"); TwinkleValidator.isFalse((form.getExcels() == null || form.getExcels().size() == 0), "补录模板不能为空");
TwinkleValidator.notEmpty(form.getUserIds(), "补录人不能为空");
// 创建人 // 创建人
User manager = userService.getManager(); User manager = userService.getManager();
form.setUser(manager); form.setUser(manager);
...@@ -109,15 +108,16 @@ public class IndexCtrl { ...@@ -109,15 +108,16 @@ 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(), "补录人不能为空");
excelForm.setJob(job); excelForm.setJob(job);
Excel excel = excelService.save(excelForm); Excel excel = excelService.save(excelForm);
// 新建补录人员任务关联 // 新建补录人员任务关联
String[] userIds = form.getUserIds().split(","); String[] userIds = excelForm.getUserIds().split(",");
List<Long> userIdList = Arrays.asList(userIds).stream().map(Long::parseLong).collect(Collectors.toList()); List<Long> userIdList = Arrays.asList(userIds).stream().map(Long::parseLong).collect(Collectors.toList());
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 -> {
recordInfoService.save(user, excel); jobInfoService.save(user, excel);
}); });
}); });
return ApiResponse.ok(job.getId()); return ApiResponse.ok(job.getId());
...@@ -126,12 +126,14 @@ public class IndexCtrl { ...@@ -126,12 +126,14 @@ public class IndexCtrl {
@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.notEmpty(form.getName(), "名称不能为空"); TwinkleValidator.isFalse((form.getId() == null && form.getId() <= 0), "收数id不能为空");
TwinkleValidator.notNull(form.getType(), "类型不能为空");
TwinkleValidator.notLessThan(form.getExcels().size(), 1, "补录模板不能为空");
TwinkleValidator.notNull(form.getId(), "收数id不能为空");
Job job = jobService.get(form.getId()); Job job = jobService.get(form.getId());
TwinkleValidator.notNull(job, "收数不存在"); TwinkleValidator.notNull(job, "收数不存在");
int status = job.getStatus();
TwinkleValidator.isFalse(status != Job.STATUS_UNRELEASED, "收数已经发起");
TwinkleValidator.notEmpty(form.getName(), "名称不能为空");
TwinkleValidator.notNull(form.getType(), "类型不能为空");
TwinkleValidator.isFalse((form.getExcels() == null || form.getExcels().size() == 0), "补录模板不能为空");
job.setType(form.getType()); job.setType(form.getType());
job.setRemark(form.getRemark()); job.setRemark(form.getRemark());
job.setName(form.getName()); job.setName(form.getName());
...@@ -145,7 +147,7 @@ public class IndexCtrl { ...@@ -145,7 +147,7 @@ public class IndexCtrl {
excel.setConfig(excelForm.getConfig()); excel.setConfig(excelForm.getConfig());
excel.setRemark(excelForm.getRemark()); excel.setRemark(excelForm.getRemark());
excel.setDataAt(excelForm.getDataAt()); excel.setDataAt(excelForm.getDataAt());
recordInfoService.deleteAllByExcelId(excel.getId()); excelService.update(excel);
}); });
return ApiResponse.ok(job.getId()); return ApiResponse.ok(job.getId());
} }
...@@ -171,18 +173,18 @@ public class IndexCtrl { ...@@ -171,18 +173,18 @@ public class IndexCtrl {
//启动流程 //启动流程
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(processDefinition.getKey(), variables); ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(processDefinition.getKey(), variables);
job.setProcessId(processInstance.getId()); job.setProcessId(processInstance.getId());
jobService.update(job);
// 发起人把流程发送到下一个人 // 发起人把流程发送到下一个人
Task resultTask = taskService.createTaskQuery().processInstanceId(processInstance.getId()). Task resultTask = taskService.createTaskQuery().processInstanceId(processInstance.getId()).
taskInvolvedUser(inputUser).singleResult(); taskInvolvedUser(inputUser).singleResult();
// 根据收数查找需要填写的人 目前只支持一人 // 根据收数查找需要填写的人 目前只支持一人
List<Excel> excelList = excelService.findAllByJobId(taskId); 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);
List<RecordInfo> recordInfoList = recordInfoService.findAllByExcelId(excel.getId()); List<JobInfo> jobInfoList = jobInfoService.findAllByExcelId(excel.getId());
TwinkleValidator.notLessThan(recordInfoList.size(), 1, "补录人员不存在"); TwinkleValidator.notLessThan(jobInfoList.size(), 1, "补录人员不存在");
taskService.complete(resultTask.getId(), ImmutableMap.of("userId", recordInfoList.get(0).getUser().getUsername())); taskService.complete(resultTask.getId(), ImmutableMap.of("userId", jobInfoList.get(0).getUser().getUsername()));
return ApiResponse.ok(); return ApiResponse.ok();
} }
......
package com.keymobile.rest.dao; package com.keymobile.rest.dao;
import com.keymobile.rest.model.RecordInfo; import com.keymobile.rest.model.JobInfo;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
import java.util.List; import java.util.List;
public interface RecordInfoDao extends JpaRepository<RecordInfo, Long> { public interface JobInfoDao extends JpaRepository<JobInfo, Long> {
List<RecordInfo> findAllByExcelId(long eid); List<JobInfo> findAllByExcelId(long eid);
List<RecordInfo> findAllByUserId(long uid); List<JobInfo> findAllByUserId(long uid);
void deleteAllByExcelId(long eid); void deleteAllByExcelId(long eid);
......
...@@ -42,12 +42,7 @@ public class Excel implements Serializable { ...@@ -42,12 +42,7 @@ public class Excel implements Serializable {
@CreationTimestamp @CreationTimestamp
private Timestamp createAt; private Timestamp createAt;
// 级别游离关联, 当加载的时候急加载这个对象 @ManyToOne(fetch = FetchType.LAZY)
@ManyToOne(cascade = CascadeType.DETACH, fetch = FetchType.EAGER)
@JsonIgnore @JsonIgnore
private Job job; private Job job;
@OneToMany
@JsonIgnore
private List<RecordInfo> recordInfoList;
} }
...@@ -30,9 +30,8 @@ public class Job implements Serializable { ...@@ -30,9 +30,8 @@ public class Job implements Serializable {
public static int STATUS_UNRELEASED = 1; public static int STATUS_UNRELEASED = 1;
public static int STATUS_COMPLETED = 3; public static int STATUS_COMPLETED = 3;
public static int JUDGE_NEED = 2; public static int AUDIT_NEED = 1;
public static int JUDGE_NO_NEED = 1; public static int AUDIT_NO_NEED = 2;
@Id @Id
@GeneratedValue(strategy = GenerationType.IDENTITY) @GeneratedValue(strategy = GenerationType.IDENTITY)
...@@ -41,19 +40,18 @@ public class Job implements Serializable { ...@@ -41,19 +40,18 @@ public class Job implements Serializable {
@Column(nullable = false) @Column(nullable = false)
private String name; private String name;
@Column @Column(nullable = false)
private int type = 1; private int type = 1;
@Column @Column(nullable = false)
private int status = 1; private int status = 1;
@Column @Column(nullable = false)
private int judge = 2; private int audit = 1;
@Column @Column
private String remark; private String remark;
@Column(name = "process_id") @Column(name = "process_id")
private String processId; private String processId;
...@@ -65,8 +63,8 @@ public class Job implements Serializable { ...@@ -65,8 +63,8 @@ public class Job implements Serializable {
@CreationTimestamp @CreationTimestamp
private Timestamp createAt; private Timestamp createAt;
@OneToMany(fetch = FetchType.EAGER)
@JoinTable(name = "excel", joinColumns = {@JoinColumn(name = "job_id")}, inverseJoinColumns = {@JoinColumn(name = "id")}) @OneToMany(fetch = FetchType.EAGER, mappedBy = "job")
private List<Excel> excelList; private List<Excel> excelList;
@ManyToOne @ManyToOne
......
...@@ -20,25 +20,23 @@ import java.util.List; ...@@ -20,25 +20,23 @@ import java.util.List;
@AllArgsConstructor @AllArgsConstructor
@Data @Data
@Entity @Entity
public class RecordInfo implements Serializable { public class JobInfo implements Serializable {
@Id @Id
@GeneratedValue(strategy = GenerationType.IDENTITY) @GeneratedValue(strategy = GenerationType.IDENTITY)
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 @CreationTimestamp
private Timestamp createAt; private Timestamp createAt;
@OneToMany @OneToOne
@JsonIgnore
List<RecordData> recordDataList;
@ManyToOne
private Excel excel; private Excel excel;
@OneToOne @OneToOne
private User user; private User user;
@OneToMany(mappedBy = "jobInfo", fetch = FetchType.EAGER)
List<RecordData> recordDataList;
} }
package com.keymobile.rest.model; package com.keymobile.rest.model;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
...@@ -24,12 +25,11 @@ public class RecordData implements Serializable { ...@@ -24,12 +25,11 @@ public class RecordData implements Serializable {
@GeneratedValue(strategy = GenerationType.IDENTITY) @GeneratedValue(strategy = GenerationType.IDENTITY)
private long id; private long id;
@Column(name = "create_at", nullable = false, columnDefinition = "DATETIME COMMENT '创建时间'") @Column(name = "create_at", nullable = false)
@CreationTimestamp @CreationTimestamp
private Timestamp createAt; private Timestamp createAt;
@ManyToOne @ManyToOne(fetch = FetchType.LAZY)
private RecordInfo recordInfo; @JsonIgnore
private JobInfo jobInfo;
} }
...@@ -33,6 +33,10 @@ public class ExcelService { ...@@ -33,6 +33,10 @@ public class ExcelService {
return excelDao.getOne(id); return excelDao.getOne(id);
} }
public void update(Excel excel) {
excelDao.save(excel);
}
public List<Excel> findAllByIdIn(List<Long> ids) { public List<Excel> findAllByIdIn(List<Long> ids) {
return excelDao.findAllByIdIn(ids); return excelDao.findAllByIdIn(ids);
} }
......
...@@ -3,7 +3,7 @@ package com.keymobile.rest.service; ...@@ -3,7 +3,7 @@ package com.keymobile.rest.service;
import com.keymobile.activiti.utils.DateUtil; import com.keymobile.activiti.utils.DateUtil;
import com.keymobile.rest.dao.*; import com.keymobile.rest.dao.*;
import com.keymobile.rest.model.Excel; import com.keymobile.rest.model.Excel;
import com.keymobile.rest.model.RecordInfo; import com.keymobile.rest.model.JobInfo;
import com.keymobile.rest.model.User; import com.keymobile.rest.model.User;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -12,30 +12,30 @@ import java.sql.Timestamp; ...@@ -12,30 +12,30 @@ import java.sql.Timestamp;
import java.util.List; import java.util.List;
@Service @Service
public class RecordInfoService { public class JobInfoService {
@Autowired @Autowired
private RecordInfoDao recordInfoDao; private JobInfoDao jobInfoDao;
public RecordInfo save(User user, Excel excel) { public JobInfo save(User user, Excel excel) {
RecordInfo info = new RecordInfo(); JobInfo info = new JobInfo();
info.setExcel(excel); info.setExcel(excel);
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 = recordInfoDao.save(info); info = jobInfoDao.save(info);
return info; return info;
} }
public List<RecordInfo> findAllByExcelId(long eid) { public List<JobInfo> findAllByExcelId(long eid) {
return recordInfoDao.findAllByExcelId(eid); return jobInfoDao.findAllByExcelId(eid);
} }
public List<RecordInfo> findByUserId(long uid) { public List<JobInfo> findByUserId(long uid) {
return recordInfoDao.findAllByUserId(uid); return jobInfoDao.findAllByUserId(uid);
} }
public void deleteAllByExcelId(long eid) { public void deleteAllByExcelId(long eid) {
recordInfoDao.deleteAllByExcelId(eid); jobInfoDao.deleteAllByExcelId(eid);
} }
} }
...@@ -32,7 +32,7 @@ public class JobService { ...@@ -32,7 +32,7 @@ public class JobService {
Timestamp now = Timestamp.valueOf(DateUtil.getDateTime()); Timestamp now = Timestamp.valueOf(DateUtil.getDateTime());
job.setCreateAt(now); job.setCreateAt(now);
job.setStatus(Job.STATUS_UNRELEASED); job.setStatus(Job.STATUS_UNRELEASED);
job.setJudge(Job.JUDGE_NEED); job.setAudit(Job.AUDIT_NEED);
job.setName(form.getName()); job.setName(form.getName());
job.setType(form.getType()); job.setType(form.getType());
if (form.getType() == Job.TYPE_AUTO) { if (form.getType() == Job.TYPE_AUTO) {
......
...@@ -19,6 +19,9 @@ public class ExcelForm { ...@@ -19,6 +19,9 @@ 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, 用逗号隔开")
private String userIds;
@ApiModelProperty(name = "remark", value = "表格名称", required = true) @ApiModelProperty(name = "remark", value = "表格名称", required = true)
private String name; private String name;
...@@ -28,7 +31,7 @@ public class ExcelForm { ...@@ -28,7 +31,7 @@ public class ExcelForm {
@ApiModelProperty(name = "remark", value = "表格描述") @ApiModelProperty(name = "remark", value = "表格描述")
private String remark; private String remark;
@ApiModelProperty(name = "dataAt", value = "数据开始", required = true) @ApiModelProperty(name = "dataAt", value = "数据开始", required = true, example = "1")
private Integer dataAt; private Integer dataAt;
@JsonIgnore @JsonIgnore
......
...@@ -6,6 +6,7 @@ import io.swagger.annotations.ApiModel; ...@@ -6,6 +6,7 @@ import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import java.util.ArrayList;
import java.util.List; import java.util.List;
@Data @Data
...@@ -22,8 +23,8 @@ public class JobForm { ...@@ -22,8 +23,8 @@ public class JobForm {
@ApiModelProperty(name = "remark", value = "收数描述") @ApiModelProperty(name = "remark", value = "收数描述")
private String remark; private String remark;
@ApiModelProperty(required = true, name = "type", value = "收数类型 1手动 2自动") @ApiModelProperty(required = true, name = "type", value = "收数类型 1手动 2自动", example = "1")
private int type = 1; private Integer type;
// @ApiModelProperty(name = "startAt", value = "自动发起需要提写的时间") // @ApiModelProperty(name = "startAt", value = "自动发起需要提写的时间")
@JsonIgnore @JsonIgnore
...@@ -32,9 +33,6 @@ public class JobForm { ...@@ -32,9 +33,6 @@ public class JobForm {
@ApiModelProperty(required = true, name = "excels", value = "新建的模板配置数组") @ApiModelProperty(required = true, name = "excels", value = "新建的模板配置数组")
private List<ExcelForm> excels; private List<ExcelForm> excels;
@ApiModelProperty(required = true, name = "userIds", value = "补录人员ids, 用逗号隔开")
private String userIds;
@JsonIgnore @JsonIgnore
private User user; private User user;
} }
...@@ -11,8 +11,8 @@ spring: ...@@ -11,8 +11,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/test?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true&serverTimezone=GMT%2B8 url: jdbc:mysql://47.105.193.165:3306/test?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true&serverTimezone=GMT%2B8
username: root username: root
...@@ -52,7 +52,7 @@ app: ...@@ -52,7 +52,7 @@ app:
active-process: RecordStandardProcess.bpmn active-process: RecordStandardProcess.bpmn
swagger2: swagger2:
host: localhost:8110 # host: localhost:8110
host: 47.105.236.43/activiti host: 47.105.236.43/activiti
......
...@@ -51,7 +51,7 @@ public class ProcessTest { ...@@ -51,7 +51,7 @@ public class ProcessTest {
// .complete("32502"); // .complete("32502");
} }
@Test // @Test
public void zhuguan() { public void zhuguan() {
// try { // try {
......
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