Commit 73768388 by chenweisong

更新

parent 10c676d3
......@@ -85,26 +85,27 @@ public class IndexCtrl {
public ApiResponse getMyTasks() {
User user = userService.getNormalUser();
User audit = userService.getAudit();
List<Job> recordList = new ArrayList<>();
List<Job> auditList = new ArrayList<>();
List<Job> jobList = 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 != null && job.getStatus() != Job.STATUS_COMPLETED) {
if (task.getTaskDefinitionKey().equals("addData")) {
recordList.add(job);
job.setKind(Job.KIND_RECORD);
} else {
auditList.add(job);
job.setKind(Job.KIND_AUDIT);
}
jobList.add(job);
}
}
return ApiResponse.ok(ImmutableMap.of("recordList", recordList, "auditList", auditList));
return ApiResponse.ok(jobList);
}
......@@ -192,6 +193,7 @@ public class IndexCtrl {
// 根据活动查找需要填写的人 目前只支持一人
List<Excel> excelList = job.getExcelList();
TwinkleValidator.notLessThan(excelList.size(), 1, "补录模板不存在");
Excel excel = excelList.get(0);
List<JobInfo> jobInfoList = jobInfoService.findAllByExcelId(excel.getId());
TwinkleValidator.notLessThan(jobInfoList.size(), 1, "补录人员不存在");
......@@ -245,14 +247,16 @@ public class IndexCtrl {
@ApiOperation(value = "填写补录数据")
@PostMapping(value = "/excel/saveData")
public ApiResponse saveRecordData(@RequestBody RecordDataForm form) {
User curUser = userService.getNormalUser();
Excel excel = excelService.get(form.getExcelId());
JobInfo jobInfo = jobInfoService.findByExcelIdAndUserId(form.getExcelId(), curUser.getId());
RecordData recordData;
if (form.getDataId() != null) {
recordData = recordDataService.update(form);
} else {
form.setJobInfo(jobInfo);
recordData = recordDataService.save(form);
}
User curUser = userService.getNormalUser();
Excel excel = excelService.get(form.getExcelId());
Job job = excel.getJob();
String processId = job.getProcessId();
// 发起人把流程发送到下一个人
......
......@@ -13,4 +13,5 @@ public interface JobInfoDao extends JpaRepository<JobInfo, Long> {
void deleteAllByExcelId(long eid);
JobInfo findByExcelIdAndUserId(long eid, long uid);
}
......@@ -23,6 +23,9 @@ import java.util.List;
@Entity
public class Job implements Serializable {
public static int KIND_RECORD = 1;
public static int KIND_AUDIT = 2;
public static int TYPE_AUTO = 2;
public static int TYPE_MANUAL = 1;
......@@ -59,6 +62,7 @@ public class Job implements Serializable {
@Column(name = "start_at")
private Timestamp startAt;
@Column(nullable = false, name = "create_at")
@CreationTimestamp
private Timestamp createAt;
......@@ -69,4 +73,8 @@ public class Job implements Serializable {
@ManyToOne
private User user;
@Transient
private int kind;
}
......@@ -25,6 +25,9 @@ public class RecordData implements Serializable {
@GeneratedValue(strategy = GenerationType.IDENTITY)
private long id;
@Column(nullable = false)
private String datas;
@Column(name = "create_at", nullable = false)
@CreationTimestamp
private Timestamp createAt;
......
......@@ -31,6 +31,10 @@ public class JobInfoService {
return jobInfoDao.findAllByExcelId(eid);
}
public JobInfo findByExcelIdAndUserId(long eid, long uid) {
return jobInfoDao.findByExcelIdAndUserId(eid, uid);
}
public List<JobInfo> findByUserId(long uid) {
return jobInfoDao.findAllByUserId(uid);
}
......
......@@ -12,6 +12,8 @@ import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;
import java.sql.Timestamp;
import java.time.LocalDateTime;
import java.util.Date;
@Service
public class JobService {
......@@ -36,7 +38,13 @@ public class JobService {
job.setName(form.getName());
job.setType(form.getType());
if (form.getType() == Job.TYPE_AUTO) {
job.setStartAt(Timestamp.valueOf(form.getStartAt()));
Timestamp startAt;
try {
startAt = Timestamp.valueOf(form.getStartAt());
} catch (Exception e) {
startAt = Timestamp.valueOf(LocalDateTime.now());
}
job.setStartAt(startAt);
}
job.setUser(form.getUser());
job = jobDao.save(job);
......
......@@ -21,6 +21,8 @@ public class RecordDataService {
public RecordData save(RecordDataForm form) {
RecordData data = new RecordData();
data.setDatas(form.getDataStr());
data.setJobInfo(form.getJobInfo());
Timestamp now = Timestamp.valueOf(DateUtil.getDateTime());
data.setCreateAt(now);
data = recordDataDao.save(data);
......
package com.keymobile.rest.vo;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.keymobile.rest.model.JobInfo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
......@@ -16,8 +18,16 @@ public class RecordDataForm {
@ApiModelProperty(required = true, name = "excelId", value = "当前模板id")
private long excelId;
@ApiModelProperty(required = true, name = "dataList", value = "当前数据数组")
@ApiModelProperty(required = true, name = "dataStr", value = "当前数据字符")
private String dataStr;
@ApiModelProperty(required = true, name = "dataList", value = "当前数据数组", hidden = true)
private List<Object> dataList;
@JsonIgnore
private JobInfo jobInfo;
}
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