|
@@ -22,6 +22,7 @@ import com.ankaibei.workFlow.webadmin.ankaibei.mapper.TaskInfoMapper;
|
|
|
import com.ankaibei.workFlow.webadmin.ankaibei.mapper.UserInfoMapper;
|
|
|
import com.ankaibei.workFlow.webadmin.ankaibei.service.TaskInfoService;
|
|
|
import com.ankaibei.workFlow.webadmin.ankaibei.utils.FlowTaskStart;
|
|
|
+import com.ankaibei.workFlow.webadmin.ankaibei.vo.ManHourInfoVo;
|
|
|
import com.ankaibei.workFlow.webadmin.ankaibei.vo.ResMsg;
|
|
|
import com.ankaibei.workFlow.webadmin.ankaibei.vo.TaskInfoVo;
|
|
|
import org.apache.commons.lang3.ObjectUtils;
|
|
@@ -123,19 +124,7 @@ public class TaskInfoServiceImpl implements TaskInfoService {
|
|
|
Duration duration = Duration.between(startDateTime, endDateTime);
|
|
|
long daysDiff = duration.toDays();
|
|
|
long hoursDiff = duration.toHours() % 24;
|
|
|
- map1.put("duration_ch", daysDiff + "天" + hoursDiff + "时");
|
|
|
- //任务是否已延期:结束时间已过但是未完成的,就是延期
|
|
|
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
- try {
|
|
|
- if (sdf.parse(map1.get("endTime").toString()).before(new Date()) && !TaskStatus.FINISH_ED.getCode().equals(map1.get("taskStatus").toString())) {
|
|
|
- if (!TaskStatus.EXTENSION_ED.getCode().equals(map1.get("taskStatus").toString())) {
|
|
|
- taskInfoMapper.extensionTask(Integer.valueOf(map1.get("taskId").toString()));
|
|
|
- }
|
|
|
- map1.put("taskStatus", TaskStatus.EXTENSION_ED.getCode());
|
|
|
- }
|
|
|
- } catch (ParseException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
+ map1.put("timeConsuming", daysDiff + "天" + hoursDiff + "时");
|
|
|
}
|
|
|
|
|
|
map1.put("taskPriority", TaskPriority.getEnumByCode(map.get("taskPriority")));
|
|
@@ -146,33 +135,98 @@ public class TaskInfoServiceImpl implements TaskInfoService {
|
|
|
@Override
|
|
|
@Transactional
|
|
|
public ResMsg addTaskInfo(TaskInfoEntity taskInfoEntity, List<Long> taskParticipant) {
|
|
|
- if (taskInfoMapper.countByTargetTaskEqualsAndIsDeleteEquals(taskInfoEntity.getTargetTask(), "1") > 1) {
|
|
|
+ if (taskInfoMapper.countByTargetTaskEqualsAndIsDeleteEquals(taskInfoEntity.getTargetTask(), "1") > 0) {
|
|
|
return new ResMsg(CodeEnum.TASK_ALREADY_EXISTS);
|
|
|
}
|
|
|
- if (ObjectUtils.isEmpty(taskInfoEntity.getStartTime()) || ObjectUtils.isEmpty(taskInfoEntity.getEndTime()) || (ObjectUtils.isEmpty(taskInfoEntity.getStartTime()) && ObjectUtils.isEmpty(taskInfoEntity.getEndTime()))) {
|
|
|
+ //判断开始时间和结束时间是否为空
|
|
|
+ if (ObjectUtils.isEmpty(taskInfoEntity.getStartTime()) || ObjectUtils.isEmpty(taskInfoEntity.getEndTime())) {
|
|
|
return new ResMsg(CodeEnum.PARAM_IS_NULL, "请录入任务计划的开始时间和结束时间");
|
|
|
- } else {
|
|
|
- //结束时间在此时之前,就已是延期任务
|
|
|
- if (taskInfoEntity.getEndTime().before(new Date())) {
|
|
|
- taskInfoEntity.setTaskStatus(TaskStatus.EXTENSION_ED.getCode());
|
|
|
+ }
|
|
|
+ StringBuffer str = new StringBuffer();
|
|
|
+ for (Long id : taskParticipant) {
|
|
|
+ str.append(id).append(",");
|
|
|
+ }
|
|
|
+ taskInfoEntity.setTaskParticipant(str.toString());
|
|
|
+ //设置默认值
|
|
|
+ taskInfoEntity.setTaskStatus(TaskStatus.NO_ALLOCATION.getCode());
|
|
|
+ taskInfoEntity.setCreateDate(new Date());
|
|
|
+ taskInfoEntity.setIsDelete(DataIsDeleteEnum.NORMAL.getCode());
|
|
|
+ TaskInfoEntity save = taskInfoMapper.save(taskInfoEntity);
|
|
|
+ return new ResMsg(CodeEnum.OK, save);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ResMsg submitTaskBySave(TaskInfoEntity taskInfoEntity, List<Long> taskParticipant) {
|
|
|
+ ResMsg msg = addTaskInfo(taskInfoEntity, taskParticipant);
|
|
|
+ if (msg.getCode() == CodeEnum.OK.getCode()) {
|
|
|
+ return submitProjectTask((TaskInfoEntity) msg.getData());
|
|
|
+ }
|
|
|
+ return new ResMsg(CodeEnum.OK);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ResMsg submitTaskBatch(ArrayList<TaskInfoEntity> list) {
|
|
|
+ //先判断ID是否为空:不为空就是批量提交的
|
|
|
+ if (ObjectUtils.isNotEmpty(list)) {
|
|
|
+ List<TaskInfoEntity> taskList = taskInfoMapper.findAllById(list.stream().map(TaskInfoEntity::getTaskId).collect(Collectors.toList()));
|
|
|
+ for (TaskInfoEntity taskInfoEntity : taskList) {
|
|
|
+ ResMsg msg = submitProjectTask(taskInfoEntity);
|
|
|
+ if (!"200".equals(msg.getCode())) {
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- if (taskParticipant.size() < 1) {
|
|
|
- //(1 未分配 2已分配 3已延期)
|
|
|
- taskInfoEntity.setTaskStatus(TaskStatus.NO_ALLOCATION.getCode());
|
|
|
- } else {
|
|
|
- taskInfoEntity.setTaskStatus(TaskStatus.ALLOCATION_ED.getCode());
|
|
|
+ return new ResMsg(CodeEnum.OK);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 编辑任务--编辑后保存
|
|
|
+ *
|
|
|
+ * @param taskInfoEntity
|
|
|
+ * @param taskParticipant
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public ResMsg editTask(TaskInfoEntity taskInfoEntity, List<Long> taskParticipant) {
|
|
|
+ if (taskInfoMapper.countByTargetTaskEqualsAndIsDeleteEquals(taskInfoEntity.getTargetTask(), "1") > 0) {
|
|
|
+ return new ResMsg(CodeEnum.TASK_ALREADY_EXISTS);
|
|
|
+ }
|
|
|
+ //判断开始时间和结束时间是否为空
|
|
|
+ if (ObjectUtils.isEmpty(taskInfoEntity.getStartTime()) || ObjectUtils.isEmpty(taskInfoEntity.getEndTime())) {
|
|
|
+ return new ResMsg(CodeEnum.PARAM_IS_NULL, "请录入任务计划的开始时间和结束时间");
|
|
|
}
|
|
|
StringBuffer str = new StringBuffer();
|
|
|
for (Long id : taskParticipant) {
|
|
|
str.append(id).append(",");
|
|
|
}
|
|
|
taskInfoEntity.setTaskParticipant(str.toString());
|
|
|
- taskInfoEntity.setTaskCreator(taskInfoEntity.getTaskCreator());
|
|
|
+ //设置默认值
|
|
|
+ taskInfoEntity.setTaskStatus(TaskStatus.NO_ALLOCATION.getCode());
|
|
|
taskInfoEntity.setCreateDate(new Date());
|
|
|
taskInfoEntity.setIsDelete(DataIsDeleteEnum.NORMAL.getCode());
|
|
|
TaskInfoEntity save = taskInfoMapper.save(taskInfoEntity);
|
|
|
+ return new ResMsg(CodeEnum.OK, save);
|
|
|
+ }
|
|
|
|
|
|
+ /**
|
|
|
+ * 编辑任务--编辑后提交
|
|
|
+ *
|
|
|
+ * @param taskInfoEntity
|
|
|
+ * @param taskParticipant
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public ResMsg submitTaskByEdit(TaskInfoEntity taskInfoEntity, List<Long> taskParticipant) {
|
|
|
+ ResMsg msg = editTask(taskInfoEntity, taskParticipant);
|
|
|
+ if (msg.getCode() == CodeEnum.OK.getCode()) {
|
|
|
+ TaskInfoEntity data = (TaskInfoEntity) msg.getData();
|
|
|
+ return submitProjectTask(data);
|
|
|
+ }
|
|
|
+ return new ResMsg(CodeEnum.OK);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public ResMsg submitProjectTask(TaskInfoEntity taskInfoEntity) {
|
|
|
/**
|
|
|
*调用新增项目任务申请流程的启动
|
|
|
*获取流程开始节点之后的第一个任务节点的数据
|
|
@@ -207,16 +261,18 @@ public class TaskInfoServiceImpl implements TaskInfoService {
|
|
|
stringObjectHashMap.put("task_statements", taskInfoEntity.getTaskStatements());
|
|
|
stringObjectHashMap.put("project_id", taskInfoEntity.getProjectId());
|
|
|
stringObjectHashMap.put("create_date", taskInfoEntity.getCreateDate());
|
|
|
- stringObjectHashMap.put("task_id", save.getTaskId());
|
|
|
+ stringObjectHashMap.put("task_id", taskInfoEntity.getTaskId());
|
|
|
JSONObject masterData = (JSONObject) JSONObject.toJSON(stringObjectHashMap);
|
|
|
Map<String, String> map = flowTaskStart.startAndTakeUserTaskSS(processDefinitionKey, flowTaskCommentDto, null, masterData, null, null).getData();
|
|
|
- save.setFlowTaskStatus(FlowTaskStatus.SUBMITTED);
|
|
|
- save.setProcessInstanceId(map.get("processInstanceId"));
|
|
|
- save.setProcessDefinitionId(map.get("processDefinitionId"));
|
|
|
- taskInfoMapper.save(save);
|
|
|
- return new ResMsg(CodeEnum.OK);
|
|
|
+ taskInfoEntity.setFlowTaskStatus(FlowTaskStatus.SUBMITTED);
|
|
|
+ taskInfoEntity.setTaskStatus(TaskStatus.AUDITING.getCode());
|
|
|
+ taskInfoEntity.setProcessInstanceId(map.get("processInstanceId"));
|
|
|
+ taskInfoEntity.setProcessDefinitionId(map.get("processDefinitionId"));
|
|
|
+ TaskInfoEntity infoEntity = taskInfoMapper.save(taskInfoEntity);
|
|
|
+ return new ResMsg(CodeEnum.OK, infoEntity);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
@Override
|
|
|
public ResMsg deleteTask(List<TaskInfoVo> taskInfoVos) {
|
|
|
// //审批状态 已提交:0; 审批中:1; 被拒绝:2; 已结束:3; 提前停止:4; 已取消:5;
|
|
@@ -261,8 +317,8 @@ public class TaskInfoServiceImpl implements TaskInfoService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public ResMsg findTaskIsFinish(String userId, Integer flowTaskStatus) {
|
|
|
- List<TaskInfoEntity> contains = taskInfoMapper.findAllByTaskParticipantContainsAndFlowTaskStatusEquals(userId, flowTaskStatus);
|
|
|
+ public ResMsg findTaskIsFinish(String userId, Integer taskStatus) {
|
|
|
+ List<TaskInfoEntity> contains = taskInfoMapper.findAllByTaskParticipantContainsAndTaskStatusIsAndIsDeleteIs(userId, taskStatus, DataIsDeleteEnum.NORMAL.getCode());
|
|
|
return new ResMsg(CodeEnum.OK, contains);
|
|
|
}
|
|
|
|