Commit 5475c19a by chenweisong

更新

parent 8b029989
package com.keymobile.rest.controller;
import com.google.common.collect.ImmutableMap;
import com.keymobile.rest.common.bean.ApiResponse;
import com.keymobile.rest.common.utils.DateUtil;
import com.keymobile.rest.model.DataInfo;
import com.keymobile.rest.model.Mission;
import com.keymobile.rest.model.Template;
import com.keymobile.rest.service.DataInfoService;
import com.keymobile.rest.service.TemplateService;
import com.keymobile.rest.service.MissionService;
import com.keymobile.rest.service.UserService;
import io.swagger.annotations.*;
import org.activiti.engine.*;
import org.activiti.engine.task.Task;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.sql.Timestamp;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Api(description = "模板 控制器")
@RestController
@RequestMapping(path = "/api")
......@@ -17,6 +29,8 @@ public class ExcelController {
@Autowired
private TemplateService templateService;
@Autowired
private DataInfoService dataInfoService;
@Autowired
private MissionService missionService;
@Autowired
private UserService userService;
......@@ -31,24 +45,35 @@ public class ExcelController {
})
@PostMapping(value = "/excel/saveData")
public ApiResponse saveRecordData(long excelId, String dataStr) {
// User curUser = userService.getNormalUser();
// Template template = excelService.get(form.getExcelId());
// ProcessInfo processInfo = jobInfoService.findByExcelIdAndUserId(form.getExcelId(), curUser.getId());
// DataInfo dataInfo;
// if (form.getDataId() != null) {
// dataInfo = recordDataService.update(form);
// } else {
// form.setProcessInfo(processInfo);
// dataInfo = recordDataService.save(form);
// }
// Assignment assignment = template.getAssignment();
// String processId = assignment.getProcessId();
// // 发起人把流程发送到下一个人
// List<Task> taskList = taskService.createTaskQuery().processInstanceId(processId)
// .taskAssignee(curUser.getUsername()).list();
// Task task = taskList.get(0);
// User judge = userService.getAudit();
// taskService.complete(task.getId(), ImmutableMap.of("judgeId", judge.getUsername()));
// excelId 其实就是当前得missionId
Mission mission = missionService.findById(excelId);
Template template = mission.getTemplate();
DataInfo dataInfo = new DataInfo();
Timestamp now = Timestamp.valueOf(DateUtil.getDateTime());
dataInfo.setCreateAt(now);
dataInfo.setData(dataStr);
dataInfo.setMission(mission);
dataInfoService.save(dataInfo);
String processId = mission.getProcess().getProcessId();
String taskId = mission.getTaskId();
// 发起人把流程发送到下一个人
Task task = taskService.createTaskQuery().processInstanceId(processId).taskId(taskId)
.singleResult();
Map vars = new HashMap<>();
if (template.getNeedAudit() == Template.NEED_AUDIT) {
vars.put("sign", true);
vars.put("inputDataApply", "审核人");
vars.put("applySign", template.getNeedConfirm() == Template.NEED_CONFIRM);
} else {
vars.put("_ACTIVITI_SKIP_EXPRESSION_ENABLED", true);
vars.put("sign", false);
vars.put("inputDataApply", "");
vars.put("applySign", template.getNeedConfirm() == Template.NEED_CONFIRM);
}
taskService.complete(task.getId(), vars);
return ApiResponse.ok();
}
......
......@@ -112,21 +112,31 @@ public class TaskController {
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")) {
Process process = processService.findByProcessId(processId);
List<Mission> missionList = process.getMissionList();
if (process != null && missionList.size() > 0) {
missionList.forEach(mission -> {
// 只能查看得时候更新这个人属于这个进行得任务id
mission.setTaskId(task.getId());
missionService.save(mission);
} else {
Map map = new HashMap();
map.put("id", mission.getId());
map.put("userId", mission.getUser().getId());
map.put("username", mission.getUser().getUsername());
map.put("excelList", Arrays.asList(mission.getTemplate()));
}
missions.add(mission);
if (task.getTaskDefinitionKey().equals("dataEntrySubTask")) {
map.put("kind", 1);
} else {
map.put("kind", 2);
}
missions.add(map);
});
}
return ApiResponse.ok();
}
return ApiResponse.ok(missions);
}
......@@ -150,11 +160,17 @@ public class TaskController {
// 新建excel实例
List<ExcelForm> excelFormList = form.getExcels();
excelFormList.forEach(excelForm -> {
TwinkleValidator.isNotNULL(excelForm.getScopeId(), "模板scopeId不能为空");
TwinkleValidator.isTrue(excelForm.getName() != null, "模板名称不能为空");
TwinkleValidator.isTrue(excelForm.getConfig() != null, "模板配置config不能为空");
TwinkleValidator.isTrue(excelForm.getScopeId() != null && excelForm.getScopeId() != 0, "模板scopeId不能为空");
TwinkleValidator.isTrue(excelForm.getNeedAudit() != null && excelForm.getNeedAudit() != 0, "模板needAudit不能为空");
TwinkleValidator.isTrue(excelForm.getNeedConfirm() != null && excelForm.getNeedConfirm() != 0, "模板needConfirm不能为空");
RecordScope scope = recordScopeService.findById(excelForm.getScopeId());
TwinkleValidator.isNotNULL(scope, "补录范围不能为空");
TwinkleValidator.isTrue(scope != null, "补录范围不能为空");
TwinkleValidator.isFalse((StringUtils.isEmpty(excelForm.getUpStreamAddr()) && StringUtils.isNotEmpty(excelForm.getBackStreamAddr())
|| (StringUtils.isNotEmpty(excelForm.getUpStreamAddr()) && StringUtils.isEmpty(excelForm.getBackStreamAddr()))), "上游地址和回流地址需同时填写或者同时为空");
excelForm.setActivity(finalActivity);
Template template = BeanUtils.convertTo(excelForm, new Template());
template.setCreateAt(now);
......@@ -187,7 +203,7 @@ public class TaskController {
Activity activity = activityService.get(taskId);
TwinkleValidator.notNull(activity, "活动不存在");
// 根据活动查找需要填写的人 目前只支持一人
List<Template> templateList = activity.getTemplateList();
List<Template> templateList = activity.getExcelList();
TwinkleValidator.notLessThan(templateList.size(), 1, "补录模板不存在");
// 部署补录流程
......@@ -206,12 +222,14 @@ public class TaskController {
String inputUser = activity.getUser().getUsername();
Map<String, Object> variables = new HashMap<>();
variables.put("inputUser", inputUser);
//启动流程
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(processDefinition.getKey(), variables);
Process process = new Process();
process.setProcessId(processInstance.getId());
process.setActivity(activity);
// 新建当前任务进程,但是先不绑定missions
process.setMissionList(null);
process.setStatus(Process.STATUS_BEGIN);
processService.save(process);
......@@ -224,18 +242,18 @@ public class TaskController {
//直接提交标准到下个节点
taskService.claim(resultTask.getId(), inputUser);
//保存审批意见
taskService.addComment(resultTask.getId(), processInstance.getId(), "");
taskService.addComment(resultTask.getId(), processInstance.getId(), "发起人启动分发任务");
List<String> userNameList = new ArrayList<>();
List<Mission> allMissions = new ArrayList<>();
// 所有模板绑定的人查找任务, 现在基本都是补录任务
templateList.forEach(template -> {
List<Mission> missionList = missionService.findAllByTemplateIdAndStatus(template.getId(), Mission.STATUS_BEGIN);
// 当前所有任务的参与人员
missionList.forEach(mission -> {
mission.setProcess(process);
// 更新mission
missionService.save(mission);
User user = mission.getUser();
userNameList.add(user.getUsername());
......@@ -245,13 +263,12 @@ public class TaskController {
process.setMissionList(allMissions);
processService.save(process);
Map<String, Object> vars = new HashMap<>();
// 如果是开始录入环节,需要给出子任务录入人员
// 分发录入任务
if (resultTask.getTaskDefinitionKey().contains("startEntry")) {
vars.put("candiateUserList", userNameList);
}
//审批任务
// 提交任务,并把补录人任务划分好
taskService.complete(resultTask.getId(), vars);
return ApiResponse.ok();
}
......
......@@ -44,6 +44,12 @@ public class UserController {
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);
......@@ -56,22 +62,7 @@ public class UserController {
@PostMapping(value = "/scope/list")
public ApiResponse getScopeList() {
List<RecordScope> recordScopeList = recordScopeService.findAll();
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);
return ApiResponse.ok(recordScopeList);
}
@ApiOperation(value = "补录范围绑定人员")
......@@ -99,7 +90,6 @@ public class UserController {
return ApiResponse.ok(getGroupTree());
}
public Group getGroupTree() {
List<Group> children = groupService.findAllByParentId(root.getId());
root.setChildren(children);
......
......@@ -7,7 +7,6 @@ import java.util.List;
public interface ProcessDao extends JpaRepository<Process, Long> {
List<Process> findAllByProcessId(String processId);
Process findByProcessIdAndStatus(String processId, int status);
Process findByProcessId(String processId);
}
......@@ -53,7 +53,7 @@ public class Activity implements Serializable {
private Timestamp createAt;
@OneToMany(fetch = FetchType.EAGER, mappedBy = "activity")
private List<Template> templateList;
private List<Template> excelList;
/*
发送人
......
......@@ -36,10 +36,12 @@ public class Mission implements Serializable {
@CreationTimestamp
private Timestamp createAt;
@Column(nullable = false, columnDefinition = ("integer(2) default 1 COMMENT '类型'"))
private int type;
@Column(columnDefinition = ("varchar(20) COMMENT '当前activiti任务id'"))
private String taskId;
@Column(nullable = false, columnDefinition = ("integer(2) default 1 COMMENT '状态'"))
private int status;
......
......@@ -33,7 +33,7 @@ public class Process implements Serializable {
/*
activiti运行中的流程实例id
*/
@Column(name = "process_id", columnDefinition = ("varchar(100) comment '当前活动在跑进程 id'"))
@Column(name = "process_id", unique = true, columnDefinition = ("varchar(100) comment '当前活动在跑进程 id'"))
private String processId;
@Column(nullable = false, columnDefinition = ("integer(2) default 0 comment '进程状态'"))
......
......@@ -20,14 +20,14 @@ import java.sql.Timestamp;
@Table(name = "t_template")
public class Template implements Serializable {
public static int NEED_AUDIT = 1;
public static int NO_NEED_AUDIT = 2;
public static int NEED_AUDIT = 2;
public static int NO_NEED_AUDIT = 1;
public static int NEED_CONFIRM = 1;
public static int NO_NEED_CONFIRM = 2;
public static int NEED_CONFIRM = 2;
public static int NO_NEED_CONFIRM = 1;
public static int NEED_MERGE = 1;
public static int NO_NEED_MERGE = 2;
public static int NEED_MERGE = 2;
public static int NO_NEED_MERGE = 1;
@Id
......@@ -43,13 +43,13 @@ public class Template implements Serializable {
@Column(name = "data_at", columnDefinition = ("integer(20) default 1 comment '数据开始行数'"))
private Integer dataAt;
@Column(name = "need_audit", columnDefinition = ("integer(2) default 0 comment '需要审核'"))
@Column(name = "need_audit", columnDefinition = ("integer(2) default 1 comment '需要审核'"))
private Integer needAudit;
@Column(name = "need_confirm", columnDefinition = ("integer(2) default 0 comment '需要负责人确认'"))
@Column(name = "need_confirm", columnDefinition = ("integer(2) default 1 comment '需要负责人确认'"))
private Integer needConfirm;
@Column(name = "need_merge", columnDefinition = ("integer(2) default 0 comment '需要数据合并'"))
@Column(name = "need_merge", columnDefinition = ("integer(2) default 1 comment '需要数据合并'"))
private Integer needMerge;
@Column(name = "up_stream_addr", columnDefinition = ("varchar(100) comment '上游地址'"))
......
......@@ -18,18 +18,8 @@ public class DataInfoService {
return dataInfoDao.getOne(id);
}
// public DataInfo save(RecordDataForm form) {
// DataInfo data = new DataInfo();
// data.setMission(form.getMission());
// Timestamp now = Timestamp.valueOf(DateUtil.getDateTime());
// data.setCreateAt(now);
// data = dataInfoDao.save(data);
// return data;
// }
// public DataInfo update(RecordDataForm form) {
// DataInfo data = this.get(form.getDataId());
// data = dataInfoDao.save(data);
// return data;
// }
public DataInfo save(DataInfo dataInfo) {
dataInfoDao.save(dataInfo);
return dataInfo;
}
}
......@@ -34,6 +34,10 @@ public class MissionService {
return mission;
}
public Mission findById(long missionId) {
return missionDao.getOne(missionId);
}
public List<Mission> findAllByTemplateIdAndStatus(long templateId, int status) {
return missionDao.findAllByTemplateIdAndStatus(templateId, status);
}
......
......@@ -13,19 +13,13 @@ public class ProcessService {
@Autowired
private ProcessDao processDao;
public Process save(Process process) {
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);
public Process findByProcessId(String processId) {
return processDao.findByProcessId(processId);
}
}
......@@ -30,16 +30,16 @@ public class ExcelForm {
@ApiModelProperty(name = "remark", value = "表格描述")
private String remark;
@ApiModelProperty(name = "dataAt", value = "数据开始行数", example = "1")
@ApiModelProperty(name = "dataAt", value = "数据开始行数 列如 1", example = "1")
private Integer dataAt;
@ApiModelProperty(name = "needAudit", value = "需要审核", required = true, example = "1")
@ApiModelProperty(name = "needAudit", value = "需要审核 1 不需要 2 需要", required = true, example = "1")
private Integer needAudit;
@ApiModelProperty(name = "needConfirm", value = "需要负责人确认", required = true, example = "1")
@ApiModelProperty(name = "needConfirm", value = "需要负责人确认 1 不需要 2 需要", required = true, example = "1")
private Integer needConfirm;
@ApiModelProperty(name = "needMerge", value = "需要数据合并", example = "1")
@ApiModelProperty(name = "needMerge", value = "需要数据合并 1 不需要 2 需要", example = "1")
private Integer needMerge;
@ApiModelProperty(name = "upStreamAddr", value = "上游地址 与 回流地址 同时填写")
......
......@@ -15,6 +15,7 @@
<subProcess activiti:exclusive="true" id="entrySubprocess" name="录入子流程" triggeredByEvent="false">
<multiInstanceLoopCharacteristics activiti:collection="candiateUserList" activiti:elementVariable="candiateUser" isSequential="false">
<completionCondition>
<!-- 这里表示当完成数和总数相等的时候到下一步 -->
<![CDATA[${nrOfCompletedInstances/nrOfInstances >= 1}]]>
</completionCondition>
</multiInstanceLoopCharacteristics>
......
......@@ -15,7 +15,7 @@ spring:
application:
name: activiti
jpa:
show-sql: true
show-sql: false
database-platform: org.hibernate.dialect.MySQL5Dialect
hibernate:
ddl-auto: update
......@@ -43,7 +43,7 @@ server:
port: 8110
app:
active-process: MoreSubProcessTest.bpmn
active-process: MoreSubProcessTestV2.bpmn
swagger2:
host: localhost:8110
......
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