#include "epm_handler_common.h" #include #include #include //#include "string_helper.cpp" #include #include #include #include using namespace std; #define DOFREE(obj) \ { \ if(obj) \ { \ MEM_free(obj); \ obj = NULL; \ } \ } extern "C" int POM_AM__set_application_bypass(logical bypass); int jl_locomotion_item(EPM_action_message_t msg) { printf("==================将对象移动到指定文件夹下 START =======================\n"); int ifail = EPM_go, count = 0, arg_cnt = 0; tag_t root_task = NULL_TAG; tag_t* attachments = NULL; //获取流程任务 EPM_ask_root_task(msg.task, &root_task); //获取流程任务目标文件夹中的对象 EPM_ask_attachments(root_task, EPM_target_attachment, &count, &attachments); //获取参数个数 arg_cnt = TC_number_of_arguments(msg.arguments); /* if (arg_cnt > 0) { for (int i = 0; i < arg_cnt; i++) { arg = TC_next_argument(msg.arguments); //ITKCALL(ifail = ITK_ask_argument_named_value((const char*)arg, &argflag, &argvalue)); ifail = ITK_ask_argument_named_value((const char*)arg, &argflag, &argvalue); if (stricmp(argflag, "ItemType") == 0) { if (argvalue != NULL) { strcpy(arg1value, argvalue); } } } MEM_free(argflag); MEM_free(argvalue); } */ for (int i = 0; i < count; i++) { int count1 = 0, count2 = 0, count3 = 0; tag_t* target1, * target2, * target3; int itemCount = 0, n_references = 0, items_tagCount = 0, item_mast_rev_count = 0; char * type_class = NULL; //int * levels = NULL; //char **relation_type_name = NULL; * reference_tags = NULL, tag_t spec_relation1 = NULLTAG, spec_relation2 = NULLTAG, spec_relation3 = NULLTAG,spec_relation4 = NULLTAG ; tag_t items_tag = NULL_TAG; //tag_t spec_relation11 , spec_relation21, spec_relation31; tag_t relation1, relation2, relation3; ifail = AOM_ask_value_string(attachments[i], "object_type", &type_class); printf("type_class : %s\n", type_class); //过滤掉非版本对象 if ((strstr(type_class, "Revision") == NULL) || (strstr(type_class, "Master") != NULL) || (strstr(type_class, "master") != NULL) || (strstr(type_class, "BOM") != NULL) || (strstr(type_class, "bom") != NULL) || (strstr(type_class, "Bom") != NULL)) { continue; } //获取对象 ifail = ITEM_ask_item_of_rev(attachments[i], &items_tag); GRM_find_relation_type("Gd6_BGLBJ", &spec_relation1); //变更零部件 GRM_find_relation_type("Gd6_SYXLBJ", &spec_relation2); //受影响零部件 GRM_find_relation_type("Gd6_XGFJ", &spec_relation3); //相关零部件 GRM_find_relation_type("Gd6_GLBGJ", &spec_relation4); //关联变更件(变更相关附件) GRM_list_secondary_objects_only(attachments[i], spec_relation1, &count1, &target1); if (count1!=0) { printf("开始\n"); for (int j = 0; j < count1; j++) { //GRM_find_relation_type("Gd6_GYWJ", &spec_relation11); GRM_create_relation(target1[j], items_tag, spec_relation4, NULLTAG, &relation1); GRM_save_relation(relation1); } printf("结束\n"); } GRM_list_secondary_objects_only(attachments[i], spec_relation2, &count2, &target2); if (count2 != 0) { for (int j = 0; j < count2; j++) { //GRM_find_relation_type("Gd6_GYWJ", &spec_relation21); GRM_create_relation(target2[j], items_tag, spec_relation4, NULLTAG, &relation2); GRM_save_relation(relation2); } } GRM_list_secondary_objects_only(attachments[i], spec_relation3, &count3, &target3); if (count3 != 0) { for (int j = 0; j < count3; j++) { //GRM_find_relation_type("Gd6_GYWJ", &spec_relation31); GRM_create_relation(target3[j], items_tag, spec_relation4, NULLTAG, &relation3); GRM_save_relation(relation3); } } DOFREE(target1); DOFREE(target2); DOFREE(target3); DOFREE(type_class); } DOFREE(attachments); printf("==================将对象移动到指定文件夹下 END =======================\n"); return ITK_ok; }