|
|
@ -101,19 +101,23 @@ public class TaskDefinitionServiceImpl extends BaseServiceImpl implements TaskDe |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
List<TaskDefinitionLog> taskDefinitionLogs = JSONUtils.toList(taskDefinitionJson, TaskDefinitionLog.class); |
|
|
|
List<TaskDefinitionLog> taskDefinitionLogs = JSONUtils.toList(taskDefinitionJson, TaskDefinitionLog.class); |
|
|
|
|
|
|
|
if (taskDefinitionLogs.isEmpty()) { |
|
|
|
|
|
|
|
logger.error("taskDefinitionJson invalid: {}", taskDefinitionJson); |
|
|
|
|
|
|
|
putMsg(result, Status.DATA_IS_NOT_VALID, taskDefinitionJson); |
|
|
|
|
|
|
|
return result; |
|
|
|
|
|
|
|
} |
|
|
|
int totalSuccessNumber = 0; |
|
|
|
int totalSuccessNumber = 0; |
|
|
|
List<Long> totalSuccessCode = new ArrayList<>(); |
|
|
|
List<Long> totalSuccessCode = new ArrayList<>(); |
|
|
|
List<TaskDefinitionLog> taskDefinitionLogsList = new ArrayList<>(); |
|
|
|
Date now = new Date(); |
|
|
|
for (TaskDefinitionLog taskDefinitionLog : taskDefinitionLogs) { |
|
|
|
for (TaskDefinitionLog taskDefinitionLog : taskDefinitionLogs) { |
|
|
|
checkTaskDefinition(result, taskDefinitionLog); |
|
|
|
checkTaskDefinition(result, taskDefinitionLog); |
|
|
|
if (result.get(Constants.STATUS) == DATA_IS_NOT_VALID |
|
|
|
if (result.get(Constants.STATUS) == DATA_IS_NOT_VALID |
|
|
|
|| result.get(Constants.STATUS) == Status.PROCESS_NODE_S_PARAMETER_INVALID) { |
|
|
|
|| result.get(Constants.STATUS) == Status.PROCESS_NODE_S_PARAMETER_INVALID) { |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
|
taskDefinitionLog.setProjectCode(projectCode); |
|
|
|
taskDefinitionLog.setProjectCode(projectCode); |
|
|
|
taskDefinitionLog.setUserId(loginUser.getId()); |
|
|
|
taskDefinitionLog.setUserId(loginUser.getId()); |
|
|
|
taskDefinitionLog.setVersion(1); |
|
|
|
taskDefinitionLog.setVersion(1); |
|
|
|
Date now = new Date(); |
|
|
|
|
|
|
|
taskDefinitionLog.setCreateTime(now); |
|
|
|
taskDefinitionLog.setCreateTime(now); |
|
|
|
taskDefinitionLog.setUpdateTime(now); |
|
|
|
taskDefinitionLog.setUpdateTime(now); |
|
|
|
long code = 0L; |
|
|
|
long code = 0L; |
|
|
@ -127,19 +131,18 @@ public class TaskDefinitionServiceImpl extends BaseServiceImpl implements TaskDe |
|
|
|
} |
|
|
|
} |
|
|
|
taskDefinitionLog.setOperator(loginUser.getId()); |
|
|
|
taskDefinitionLog.setOperator(loginUser.getId()); |
|
|
|
taskDefinitionLog.setOperateTime(now); |
|
|
|
taskDefinitionLog.setOperateTime(now); |
|
|
|
taskDefinitionLogsList.add(taskDefinitionLog); |
|
|
|
|
|
|
|
totalSuccessCode.add(code); |
|
|
|
totalSuccessCode.add(code); |
|
|
|
totalSuccessNumber++; |
|
|
|
totalSuccessNumber++; |
|
|
|
} |
|
|
|
} |
|
|
|
int insert = taskDefinitionMapper.batchInsert(taskDefinitionLogsList); |
|
|
|
int insert = taskDefinitionMapper.batchInsert(taskDefinitionLogs); |
|
|
|
int logInsert = taskDefinitionLogMapper.batchInsert(taskDefinitionLogsList); |
|
|
|
int logInsert = taskDefinitionLogMapper.batchInsert(taskDefinitionLogs); |
|
|
|
if ((logInsert & insert) == 0) { |
|
|
|
if ((logInsert & insert) == 0) { |
|
|
|
putMsg(result, Status.CREATE_TASK_DEFINITION_ERROR); |
|
|
|
putMsg(result, Status.CREATE_TASK_DEFINITION_ERROR); |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
|
Map<String, Object> resData = new HashMap<>(); |
|
|
|
Map<String, Object> resData = new HashMap<>(); |
|
|
|
resData.put("total", totalSuccessNumber); |
|
|
|
resData.put("total", totalSuccessNumber); |
|
|
|
resData.put("code",totalSuccessCode); |
|
|
|
resData.put("code", totalSuccessCode); |
|
|
|
putMsg(result, Status.SUCCESS); |
|
|
|
putMsg(result, Status.SUCCESS); |
|
|
|
result.put(Constants.DATA_LIST, resData); |
|
|
|
result.put(Constants.DATA_LIST, resData); |
|
|
|
return result; |
|
|
|
return result; |
|
|
@ -190,9 +193,9 @@ public class TaskDefinitionServiceImpl extends BaseServiceImpl implements TaskDe |
|
|
|
List<ProcessTaskRelation> processTaskRelationList = processTaskRelationMapper.queryByTaskCode(taskCode); |
|
|
|
List<ProcessTaskRelation> processTaskRelationList = processTaskRelationMapper.queryByTaskCode(taskCode); |
|
|
|
if (!processTaskRelationList.isEmpty()) { |
|
|
|
if (!processTaskRelationList.isEmpty()) { |
|
|
|
Set<Long> processDefinitionCodes = processTaskRelationList |
|
|
|
Set<Long> processDefinitionCodes = processTaskRelationList |
|
|
|
.stream() |
|
|
|
.stream() |
|
|
|
.map(ProcessTaskRelation::getProcessDefinitionCode) |
|
|
|
.map(ProcessTaskRelation::getProcessDefinitionCode) |
|
|
|
.collect(Collectors.toSet()); |
|
|
|
.collect(Collectors.toSet()); |
|
|
|
putMsg(result, Status.PROCESS_TASK_RELATION_EXIST, StringUtils.join(processDefinitionCodes, ",")); |
|
|
|
putMsg(result, Status.PROCESS_TASK_RELATION_EXIST, StringUtils.join(processDefinitionCodes, ",")); |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
@ -234,7 +237,7 @@ public class TaskDefinitionServiceImpl extends BaseServiceImpl implements TaskDe |
|
|
|
TaskDefinitionLog taskDefinitionToUpdate = JSONUtils.parseObject(taskDefinitionJson, TaskDefinitionLog.class); |
|
|
|
TaskDefinitionLog taskDefinitionToUpdate = JSONUtils.parseObject(taskDefinitionJson, TaskDefinitionLog.class); |
|
|
|
checkTaskDefinition(result, taskDefinitionToUpdate); |
|
|
|
checkTaskDefinition(result, taskDefinitionToUpdate); |
|
|
|
if (result.get(Constants.STATUS) == DATA_IS_NOT_VALID |
|
|
|
if (result.get(Constants.STATUS) == DATA_IS_NOT_VALID |
|
|
|
|| result.get(Constants.STATUS) == Status.PROCESS_NODE_S_PARAMETER_INVALID) { |
|
|
|
|| result.get(Constants.STATUS) == Status.PROCESS_NODE_S_PARAMETER_INVALID) { |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
|
Integer version = taskDefinitionLogMapper.queryMaxVersionForDefinition(taskCode); |
|
|
|
Integer version = taskDefinitionLogMapper.queryMaxVersionForDefinition(taskCode); |
|
|
@ -338,5 +341,28 @@ public class TaskDefinitionServiceImpl extends BaseServiceImpl implements TaskDe |
|
|
|
Integer userId) { |
|
|
|
Integer userId) { |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public Map<String, Object> genTaskCodeList(User loginUser, Integer genNum) { |
|
|
|
|
|
|
|
Map<String, Object> result = new HashMap<>(); |
|
|
|
|
|
|
|
if (genNum == null || genNum < 1 || genNum > 100) { |
|
|
|
|
|
|
|
logger.error("the genNum must be great than 1 and less than 100"); |
|
|
|
|
|
|
|
putMsg(result, Status.DATA_IS_NOT_VALID, genNum); |
|
|
|
|
|
|
|
return result; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
List<Long> taskCodes = new ArrayList<>(); |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
for (int i = 0; i < genNum; i++) { |
|
|
|
|
|
|
|
taskCodes.add(SnowFlakeUtils.getInstance().nextId()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} catch (SnowFlakeException e) { |
|
|
|
|
|
|
|
logger.error("Task code get error, ", e); |
|
|
|
|
|
|
|
putMsg(result, Status.INTERNAL_SERVER_ERROR_ARGS, "Error generating task definition code"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
putMsg(result, Status.SUCCESS); |
|
|
|
|
|
|
|
// return processDefinitionCode
|
|
|
|
|
|
|
|
result.put(Constants.DATA_LIST, taskCodes); |
|
|
|
|
|
|
|
return result; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|