#include "util.h" int setTarget2(tag_t tag_task, tag_t tag_a) { int ifail = ITK_ok; int master_count = 0, count = 0; int attachment_types = 0; if (tag_a != NULL) { AOM_unlock(tag_a); attachment_types = EPM_target_attachment; printf("开始将版本放入目标\n"); ITKCALL(EPM_add_attachments(tag_task, 1, &(tag_a), &attachment_types)); printf("结束将版本放入目标\n"); return ITK_ok; } } int Sample_confirmation_sheet(EPM_rule_message_t msg) { POM_AM__set_application_bypass(true); tag_t root_task, * attachments; int att_cnt; //获得根节点 EPM_ask_root_task(msg.task, &root_task); //获得根任务下的组件 EPM_ask_attachments(root_task, EPM_target_attachment, &att_cnt, &attachments); //判断参数是否符合要求 char* object_string; std::string names = ""; int bjNum = 0; //遍历任务组件 TC_Is_Represented_By for (int i = 0; i < att_cnt; i++) { if (isTypeOf(attachments[i], "ItemRevision")) { int object_att; tag_t* object; //得到零组件 AOM_ask_value_tags(attachments[i], "items_tag", &object_att, &object); if (object_att == 0) { continue; } char* item_id; int n_referencers; int* levels; tag_t* referencers; char** relations; //得到零组件的引用对象 WSOM_where_referenced(object[0], 1, &n_referencers, &levels, &referencers, &relations); int itemRecision_att; tag_t* itemRecision; //得到引用对象的最新版本 AOM_ask_value_tags(referencers[0], "revision_list", &itemRecision_att, &itemRecision); if (itemRecision_att <= 0) { EMH_store_error_s1(EMH_severity_error, EMH_IDGENERATION_ERROR_BASE, "该清单没有关联物料!"); return EPM_nogo; } ////creation_date //int dataNum; //date_t* time; //int index = 0; //int prefTime = 0; //int prefTimeDay = 0; //int prefTimeHour = 0; //int prefTimeMinute = 0; //for (int j = 0; j < itemRecision_att; j++) { // if (isTypeOf(itemRecision[j], "ItemRevision")) { // AOM_ask_value_dates(itemRecision[j], "creation_date", &dataNum, &time); // int createTime = time->year + time->month; // if (createTime > prefTime) { // prefTime = createTime; // prefTimeDay = time->day; // prefTimeHour = time->hour; // prefTimeMinute = time->minute; // index = j; // } // if (createTime == prefTime) { // if (time->day > prefTimeDay) { // prefTime = createTime; // prefTimeDay = time->day; // prefTimeHour = time->hour; // prefTimeMinute = time->minute; // index = j; // } // if (time->day == prefTimeDay) { // if (time->hour > prefTimeHour) { // prefTime = createTime; // prefTimeDay = time->day; // prefTimeHour = time->hour; // prefTimeMinute = time->minute; // index = j; // } // if (time->hour == prefTimeHour) { // if (time->minute > prefTimeMinute) { // prefTime = createTime; // prefTimeDay = time->day; // prefTimeHour = time->hour; // prefTimeMinute = time->minute; // index = j; // } // } // } // } // } //} //新增物料,判断版本表单是否是待验证状态 if (itemRecision_att == 1) { int form_att; tag_t* forms; AOM_ask_value_tags(itemRecision[0], "IMAN_master_form_rev", &form_att, &forms); printf("form_att====>%d\n", form_att); char* object_string; int fb_att; tag_t* fb; AOM_ask_value_tags(forms[0], "release_status_list", &fb_att, &fb); if (fb_att == 0) { EMH_store_error_s1(EMH_severity_error, EMH_IDGENERATION_ERROR_BASE, "物料版本非待验证状态,请先走物料新增审批流程"); return EPM_nogo; } AOM_ask_value_string(fb[0], "object_string", &object_string); printf("object_string====>%s\n", object_string); if (strcmp(object_string, "待验证") != 0 && strcmp(object_string, "正式") != 0) { EMH_store_error_s1(EMH_severity_error, EMH_IDGENERATION_ERROR_BASE, "物料版本表单状态不是待待验证或正式,不允许发起流程"); return EPM_nogo; } } //已经升版,判断上一版本是否已经发布 //if (itemRecision_att > 1) { // int dataNum; // date_t* time; // AOM_ask_value_dates(itemRecision[index - 1], "date_released", &dataNum, &time); // cout << "time1->year:" << time->year << endl; // if (time->year == 0) { // //没有发布 // EMH_store_error_s1(EMH_severity_error, EMH_IDGENERATION_ERROR_BASE, "请检查物料版本表单状态"); // return EPM_nogo; // } //} int tz_att; tag_t* tz; //得到引用对象的版本关系 TC_Is_Represented_By 找到图纸对象 AOM_ask_value_tags(itemRecision[itemRecision_att-1], "TC_Is_Represented_By", &tz_att, &tz); if (tz_att < 1) { //没有图纸 date_released bjNum = -1; } else { int tzRelease_att; tag_t* tzRelease; //获取图纸对象的版本 AOM_ask_value_tags(tz[0], "revision_list", &tzRelease_att, &tzRelease); int dataNum1; date_t* time1; //判断图纸对象的版本是否发布 AOM_ask_value_dates(tzRelease[tzRelease_att - 1], "date_released", &dataNum1, &time1); printf("1=>\n"); //cout << "time1->year:" << time1->year << endl; if (time1->year == 0) { //没有发布 bjNum = -1; printf("2=>\n"); } else { printf("3=>\n"); //将版本进行发布 /*tag_t release_status = NULL; RELSTAT_create_release_status("TCM Released", &release_status); RELSTAT_add_release_status(release_status, 1, &itemRecision[index], TRUE);*/ //记得开旁路 tag_t task_tag = NULLTAG, root_task_tag = NULLTAG; task_tag = msg.task; setTarget2(root_task, itemRecision[itemRecision_att-1]);//将版本带入目标 } } } } if (bjNum == -1) { char* message = "需要确认图纸存在并已发布!!"; cout << "Exception:" << message << endl; EMH_store_error_s1(EMH_severity_error, EMH_IDGENERATION_ERROR_BASE, message); return EPM_nogo; } POM_AM__set_application_bypass(false); return EPM_go; }