Commit 367302b4 by chenweisong

更新

parent d28f3f12
......@@ -15,7 +15,6 @@ import org.activiti.engine.repository.Deployment;
import org.activiti.engine.repository.ProcessDefinition;
import org.activiti.engine.runtime.ProcessInstance;
import org.activiti.engine.task.Task;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.Page;
......@@ -102,6 +101,7 @@ public class IndexCtrl {
TwinkleValidator.notEmpty(form.getName(), "名称不能为空");
TwinkleValidator.notNull(form.getType(), "类型不能为空");
TwinkleValidator.notLessThan(form.getExcels().size(), 1, "补录模板不能为空");
TwinkleValidator.notEmpty(form.getUserIds(), "补录人不能为空");
// 创建人
User manager = userService.getManager();
form.setUser(manager);
......@@ -112,14 +112,40 @@ public class IndexCtrl {
excelForm.setJob(job);
Excel excel = excelService.save(excelForm);
// 新建补录人员任务关联
if (StringUtils.isNotEmpty(form.getUserIds())) {
String[] userIds = form.getUserIds().split(",");
List<Long> userIdList = Arrays.asList(userIds).stream().map(Long::parseLong).collect(Collectors.toList());
List<User> userList = userService.findAllByIdIn(userIdList);
userList.forEach(user -> {
recordInfoService.save(user, excel);
});
}
String[] userIds = form.getUserIds().split(",");
List<Long> userIdList = Arrays.asList(userIds).stream().map(Long::parseLong).collect(Collectors.toList());
List<User> userList = userService.findAllByIdIn(userIdList);
TwinkleValidator.notLessThan(userList.size(), 1, "补录人员不存在");
userList.forEach(user -> {
recordInfoService.save(user, excel);
});
});
return ApiResponse.ok(job.getId());
}
@ApiOperation(value = "修改收数")
@PostMapping(value = "/task/update")
public ApiResponse updateTask(@RequestBody JobForm form) {
TwinkleValidator.notEmpty(form.getName(), "名称不能为空");
TwinkleValidator.notNull(form.getType(), "类型不能为空");
TwinkleValidator.notLessThan(form.getExcels().size(), 1, "补录模板不能为空");
TwinkleValidator.notNull(form.getId(), "收数id不能为空");
Job job = jobService.get(form.getId());
TwinkleValidator.notNull(job, "收数不存在");
job.setType(form.getType());
job.setRemark(form.getRemark());
job.setName(form.getName());
jobService.update(job);
// 新建excel实例
List<ExcelForm> excelFormList = form.getExcels();
excelFormList.forEach(excelForm -> {
Excel excel = excelService.get(excelForm.getId());
TwinkleValidator.notNull(excel, "模板不存在");
excel.setName(excelForm.getName());
excel.setConfig(excelForm.getConfig());
excel.setRemark(excelForm.getRemark());
excel.setDataAt(excelForm.getDataAt());
recordInfoService.deleteAllByExcelId(excel.getId());
});
return ApiResponse.ok(job.getId());
}
......
......@@ -10,4 +10,7 @@ public interface RecordInfoDao extends JpaRepository<RecordInfo, Long> {
List<RecordInfo> findAllByExcelId(long eid);
List<RecordInfo> findAllByUserId(long uid);
void deleteAllByExcelId(long eid);
}
......@@ -27,8 +27,14 @@ public class Excel implements Serializable {
private long id;
@Column(nullable = false)
private String name;
@Column(nullable = false)
private String config;
@Column(nullable = false, name = "data_at")
private Integer dataAt;
@Column
private String remark;
......
......@@ -50,9 +50,14 @@ public class Job implements Serializable {
@Column
private int judge = 2;
@Column
private String remark;
@Column(name = "process_id")
private String processId;
// 报送频度 按年 按年 按周 按月 按日 自动推送
@Column(name = "start_at")
private Timestamp startAt;
......@@ -60,7 +65,8 @@ public class Job implements Serializable {
@CreationTimestamp
private Timestamp createAt;
@OneToMany
@OneToMany(fetch = FetchType.EAGER)
@JoinTable(name = "excel", joinColumns = {@JoinColumn(name = "job_id")}, inverseJoinColumns = {@JoinColumn(name = "id")})
private List<Excel> excelList;
@ManyToOne
......
......@@ -28,8 +28,6 @@ public class RecordData implements Serializable {
@CreationTimestamp
private Timestamp createAt;
@ManyToOne
private RecordInfo recordInfo;
......
......@@ -32,5 +32,4 @@ public class User implements Serializable {
@Column
private int role;
}
......@@ -18,6 +18,8 @@ public class ExcelService {
public Excel save(ExcelForm form) {
Excel excel = new Excel();
excel.setName(form.getName());
excel.setDataAt(form.getDataAt());
excel.setConfig(form.getConfig());
excel.setRemark(form.getRemark());
excel.setJob(form.getJob());
......
......@@ -34,4 +34,8 @@ public class RecordInfoService {
public List<RecordInfo> findByUserId(long uid) {
return recordInfoDao.findAllByUserId(uid);
}
public void deleteAllByExcelId(long eid) {
recordInfoDao.deleteAllByExcelId(eid);
}
}
......@@ -16,12 +16,21 @@ import java.sql.Timestamp;
@ApiModel
public class ExcelForm {
@ApiModelProperty(name = "id", value = "表格id,修改的时候需要用到")
private Long id;
@ApiModelProperty(name = "remark", value = "表格名称", required = true)
private String name;
@ApiModelProperty(name = "config", value = "表格配置", required = true)
private String config;
@ApiModelProperty(name = "remark", value = "表格描述")
private String remark;
@ApiModelProperty(name = "dataAt", value = "数据开始", required = true)
private Integer dataAt;
@JsonIgnore
private Job job;
}
......@@ -12,19 +12,27 @@ import java.util.List;
@ApiModel
public class JobForm {
@ApiModelProperty(name = "id", value = "收数id,修改的时候需要用到")
private Long id;
@ApiModelProperty(required = true, name = "name", value = "收数名称")
private String name;
@ApiModelProperty(name = "remark", value = "收数描述")
private String remark;
@ApiModelProperty(required = true, name = "type", value = "收数类型 1手动 2自动")
private int type = 1;
@ApiModelProperty(name = "startAt", value = "自动发起需要提写的时间")
// @ApiModelProperty(name = "startAt", value = "自动发起需要提写的时间")
@JsonIgnore
private String startAt;
@ApiModelProperty(name = "excels", value = "新建的模板配置数组")
@ApiModelProperty(required = true, name = "excels", value = "新建的模板配置数组")
private List<ExcelForm> excels;
@ApiModelProperty(name = "userIds", value = "补录人员ids, 用逗号隔开")
@ApiModelProperty(required = true, name = "userIds", value = "补录人员ids, 用逗号隔开")
private String userIds;
@JsonIgnore
......
......@@ -11,8 +11,8 @@ spring:
jpa:
show-sql: true
database-platform: org.hibernate.dialect.MySQL5Dialect
# hibernate:
# ddl-auto: update
hibernate:
ddl-auto: update
datasource:
url: jdbc:mysql://47.105.193.165:3306/test?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true&serverTimezone=GMT%2B8
username: root
......@@ -52,7 +52,7 @@ app:
active-process: RecordStandardProcess.bpmn
swagger2:
# host: localhost:8110
host: localhost:8110
host: 47.105.236.43/activiti
......
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