#pragma warning (disable: 4996) #pragma warning (disable: 4819) #pragma warning (disable: 4995) #include #include "epm_handler_common.h" #include #include #include #include #include #include #include #include "ps/ps.h"; #include "ps/vrule.h" #include "sstream" #include #include "epm/epm.h" #include "sa/sa.h" #include "libxl.h" #include #include "epm/signoff.h" #include #include #include #include #include "ae/dataset.h" #include #include #include #include #include #include #include #include #include #include #include #include #include "tchar.h" #include #include "common_itk_util.h" using namespace libxl; extern "C" int POM_AM__set_application_bypass(logical bypass); int loop(tag_t top_bom_line_tag,map &rev_map) { int ifail=0; int child_count = 0; tag_t * child_tags = NULL; tag_t child_rev_tag=NULL; char * child_item_id = NULL; // date_t p;//创建日期 ITKCALL(ifail = BOM_line_ask_all_child_lines(top_bom_line_tag,&child_count,&child_tags)); for(int x=0;x(child_rev_tag,"")); //把BOM视图也加进来 int num=0; tag_t *bomTags=NULLTAG; AOM_ask_value_tags(child_rev_tag,"structure_revisions",&num,&bomTags); if(num>0) { rev_map.insert(pair(bomTags[0],"")); MEM_free(bomTags); bomTags=NULL; } } } loop(child_tag,rev_map); } if(child_tags!=NULL) { MEM_free(child_tags); child_tags=NULL; } if(child_item_id!=NULL) { MEM_free(child_item_id); child_item_id=NULL; } return 0; } int jk_add_attatchments(EPM_action_message_t msg) { cout<<"把成品下面新生成的基板组件和控制器组件及其BOM视图带入流程中"< rev_map; map bom_map; string errorMessage=""; //获取当前触发的任务 task_tag = msg.task; //获取根流程节点 ifail = EPM_ask_root_task(task_tag, &rootTask_tag); //获取目标引用对象 ifail = EPM_ask_attachments(rootTask_tag, EPM_target_attachment, &att_cnt, &attachments); for(int i = 0; i < att_cnt; i++ ) { //获得对象类型的系统方法 ITKCALL(TCTYPE_ask_object_type(attachments[i], &type_tag)); ITKCALL(ifail = TCTYPE_ask_class_name(type_tag, type_class)); ECHO("type_class : %s\n",type_class); //必须为版本或者是bom,为什么把版本加到集合中? if(((strstr(type_class,"Revision") == NULL) || (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))){ bom_map.insert(pair(attachments[i],"")); } } //遍历BOM结构 map::iterator bom_it; for( bom_it = bom_map.begin(); bom_it != bom_map.end(); bom_it++ ) { tag_t bom_window_tag = NULLTAG,top_bom_line_tag =NULLTAG,rev_tag = NULLTAG; ITKCALL(ifail = BOM_create_window(&bom_window_tag)); ITKCALL(ifail = BOM_set_window_top_line_bvr(bom_window_tag,bom_it->first,&top_bom_line_tag)); if(top_bom_line_tag != NULLTAG){ /*ITKCALL(ifail = AOM_ask_value_tag(top_bom_line_tag,"bl_line_object",&rev_tag)); //判断一下顶层有没有发布,没发布放到map集合中 AOM_ask_value_string(rev_tag,"item_id",&item_id); string item_id_string=item_id; if(item_id_string.length()==12) { rev_map.insert(pair(rev_tag,""));//把顶层放到集合中 }*/ loop(top_bom_line_tag,rev_map); } ITKCALL(ifail = BOM_save_window(bom_window_tag));//要保存,否则修改属性后bom视图不会保存 ITKCALL(ifail = BOM_close_window(bom_window_tag));//有开必有关 } //将map集合中的所有版本带入到流程目标下 vector target_vec; map::iterator rev_it; for( rev_it = rev_map.begin(); rev_it != rev_map.end(); rev_it++ ) { target_vec.push_back(rev_it->first); } int *att_types=NULL; att_types = (int*) MEM_alloc (sizeof(int) * ( target_vec.size() )); attachments = (tag_t*) MEM_alloc (sizeof(tag_t) * ( target_vec.size() )); //制定目标,数组转换 for ( int indx = 0; indx < target_vec.size(); indx++ ) { att_types[indx] = EPM_target_attachment;//EPM_reference_attachment; attachments[indx] = target_vec[indx]; } //把所有的版本都添加到流程中 printf("1ifail=>%d\n",ifail); ITKCALL(ifail=EPM_add_attachments(rootTask_tag,target_vec.size(),attachments,att_types)); if(att_types) { MEM_free(att_types); att_types = NULL; } if(item_id!=NULL) { MEM_free(item_id); item_id=NULL; } if(attachments!=NULL) { MEM_free(attachments); attachments=NULL; } return 0; }