#define _CRT_SECURE_NO_WARNINGS #include "epm_handler_common.h" int ML_CreateSumProcess(EPM_action_message_t msg) { printf("=========================创建多个流程 Start===================\n"); auto startTime = std::chrono::high_resolution_clock::now(); int ifail = ITK_ok; int attachments_num = 0; tag_t rootTask = NULLTAG, *attachments = NULLTAG; //获取任务对象 EPM_ask_root_task(msg.task, &rootTask); //获取任务目标对象 EPM_ask_attachments(rootTask, EPM_target_attachment, &attachments_num, &attachments); int sub_task_count = 0; tag_t * sub_tasks = NULLTAG; //得到根流程下的所有的一级节点 EPM_ask_sub_tasks(rootTask, &sub_task_count, &sub_tasks); char * processName = NULL; EPM_ask_name2(rootTask, &processName); cout << "流程名称" << processName << endl; map> nodeUserMap; //获取流程节点及负责人 POM_AM__set_application_bypass(true); for (int i = 0; i < sub_task_count; i++) { char * cur_task_name = NULL; //获取节点名称 EPM_ask_name2(sub_tasks[i], &cur_task_name); cout << "流程节点名称" << cur_task_name << endl; int perform_count = 0, *attach_type = 0; tag_t * perform_attaches = NULLTAG; //EPM_ask_all_attachments(sub_tasks[i], &perform_count, &perform_attaches, &attach_type); AOM_ask_value_tags(sub_tasks[i], "valid_signoffs", &perform_count, &perform_attaches); printf("EPM_signoff_attachment Counts = %d\n", perform_count); vector nodeUser; for (int j = 0; j < perform_count; j++) { /*tag_t memberTag = NULLTAG; SIGNOFF_TYPE_t memberType; EPM_signoff_decision_t signoff_decision; date_t decision_date; char *comments = NULL; EPM_ask_signoff_member(perform_attaches[j], &memberTag, &memberType); EPM_ask_signoff_decision(perform_attaches[j], &signoff_decision, &comments, &decision_date); if (memberType == SIGNOFF_GROUPMEMBER) { tag_t user_tag = NULLTAG; SA_ask_groupmember_user(memberTag, &user_tag); nodeUser.push_back(user_tag); } DOFREE(comments);*/ //通知人 tag_t user_tag = NULLTAG; AOM_ask_value_tag(perform_attaches[j], "fnd0Assignee", &user_tag); if (user_tag != NULL_TAG) { nodeUser.push_back(user_tag); } } nodeUserMap[cur_task_name] = nodeUser; DOFREE(cur_task_name); DOFREE(perform_attaches); } tag_t template_tag = NULLTAG; EPM_find_template2(processName, PROCESS_TEMPLATE, &template_tag); for (int i = 1; i < attachments_num; i++) { char *itemType = NULL; char *objectString = NULL; AOM_ask_value_string(attachments[i], "object_type", &itemType); AOM_ask_value_string(attachments[i], "object_string", &objectString); printf("type_class : %s \r\n", itemType); //过滤掉非版本的对象 if ((strstr(itemType, "Revision") == NULL) || (strstr(itemType, "Master") != NULL) || (strstr(itemType, "master") != NULL) || (strstr(itemType, "BOM") != NULL) || (strstr(itemType, "bom") != NULL) || (strstr(itemType, "Bom") != NULL)) { DOFREE(itemType); DOFREE(objectString); continue; } int size = 1; tag_t new_process = NULLTAG; int *tagType = (int *)MEM_alloc(1024 * sizeof(int));//EPM_reference_attachment tag_t * itemTag = (tag_t *)MEM_alloc(1024 * sizeof(tag_t)); tagType[0] = EPM_target_attachment; itemTag[0] = attachments[i]; char name[256]; sprintf(name, "%s : %s", processName, objectString); //移除流程目标下的对象 EPM_remove_attachments(rootTask, 1, itemTag); EPM_create_process(name, "", template_tag, size, itemTag, tagType, &new_process); int cnt_task = 0; tag_t * tasks = NULLTAG; tag_t newRootTask = NULLTAG; //指派流程节点负责人 //AOM_ask_value_tags(new_process, "child_tasks", &cnt_task, &tasks); //EPM_ask_root_task(new_process, &newRootTask); //EPM_ask_sub_tasks(newRootTask, &cnt_task, &tasks); //EPM_ask_tasks(new_process, EPM_started, &cnt_task, &tasks); //for (int jj = 0; jj < cnt_task; jj++) //{ // char * tmp_sub_task_name = NULL, *sub_task_object_type = NULL; // //流程节点的名称 // ITKCALL(EPM_ask_name2(tasks[jj], &tmp_sub_task_name)); // printf("流程节点的名称%s=====================\n", tmp_sub_task_name); // //流程节点的类型 // ITKCALL(AOM_ask_value_string(tasks[jj], "object_type", &sub_task_object_type)); // printf("父任务任务名称%s=====================\n", sub_task_object_type); // //如果是签审节点 ,或通知节点 // if ((strstr(sub_task_object_type, "ReviewTask") != NULL) || (strstr(sub_task_object_type, "AcknowledgeTask") != NULL)) // { // vector nodeOwner; // for (map>::iterator ii = nodeUserMap.begin(); ii != nodeUserMap.end(); ii++) // { // if (strcmp(ii->first, tmp_sub_task_name) == 0) // { // nodeOwner = ii->second; // } // } // //vector nodeOwner = nodeUserMap[tmp_sub_task_name]; // if (nodeOwner.size() > 0) // { // printf("设置流程负责人%s=====================\n", sub_task_object_type); // create_adhoc_signoff(tasks[jj], nodeOwner); // } // else // { // printf("未找到流程负责人%s=====================\n", sub_task_object_type); // } // } // DOFREE(tmp_sub_task_name); // DOFREE(sub_task_object_type); //} //EPM_ask_tasks(new_process, EPM_unassigned, &cnt_task, &tasks); //for (int jj = 0; jj < cnt_task; jj++) //{ // char * tmp_sub_task_name = NULL, *sub_task_object_type = NULL; // //流程节点的名称 // ITKCALL(EPM_ask_name2(tasks[jj], &tmp_sub_task_name)); // printf("流程节点的名称%s=====================\n", tmp_sub_task_name); // //流程节点的类型 // ITKCALL(AOM_ask_value_string(tasks[jj], "object_type", &sub_task_object_type)); // printf("父任务任务名称%s=====================\n", sub_task_object_type); // //如果是签审节点 ,或通知节点 // if ((strstr(sub_task_object_type, "ReviewTask") != NULL) || (strstr(sub_task_object_type, "AcknowledgeTask") != NULL)) // { // vector nodeOwner; // for (map>::iterator ii = nodeUserMap.begin(); ii != nodeUserMap.end(); ii++) // { // if (strcmp(ii->first, tmp_sub_task_name) == 0) // { // nodeOwner = ii->second; // } // } // //vector nodeOwner = nodeUserMap[tmp_sub_task_name]; // if (nodeOwner.size() > 0) // { // printf("设置流程负责人%s=====================\n", sub_task_object_type); // create_adhoc_signoff(tasks[jj], nodeOwner); // } // else // { // printf("未找到流程负责人%s=====================\n", sub_task_object_type); // } // } // DOFREE(tmp_sub_task_name); // DOFREE(sub_task_object_type); //} DOFREE(itemType); DOFREE(tasks); } POM_AM__set_application_bypass(false); nodeUserMap.clear(); map>().swap(nodeUserMap); DOFREE(attachments); DOFREE(sub_tasks); DOFREE(processName); auto stopTime = std::chrono::high_resolution_clock::now(); auto duration = std::chrono::duration_cast(stopTime - startTime); //std::cout << "ML_CreateSumProcess用时:" << duration.count() / 1000 << std::endl; string usetime = "ML_CreateSumProcess用时:"; usetime.append(std::to_string(duration.count() / 1000)); WriteLog(true, usetime.c_str()); printf("=========================创建多个流程 End===================\n"); return 0; }