#pragma warning (disable: 4996) 
#pragma warning (disable: 4819) 
#pragma warning (disable: 4995) 

#include <tc/tc.h>
#include "epm_handler_common.h"

#include <ict/ict_userservice.h>
#include <tccore/custom.h>
#include <epm/epm_toolkit_tc_utils.h>
#include <tccore/aom.h>
#include <tccore/aom_prop.h>
#include <tccore/item.h>
#include <bom/bom.h>
#include "ps/ps.h";
#include "ps/vrule.h"
#include "sstream"
#include <tccore/grm.h>
#include "epm/epm.h"
#include "sa/sa.h"
#include "libxl.h"
#include <map>
#include "epm/signoff.h"
#include <ctime>
#include <vector>
#include <locale>
#include <codecvt>
#include "ae/dataset.h"
#include <iostream>
#include <stdlib.h>
#include <tccore/aom.h>
#include <tc/emh.h>
#include <ict/ict_userservice.h>
#include <tc/tc.h>
#include <tccore/tctype.h>
#include <sa/tcfile.h>
#include <ss/ss_errors.h>
extern "C" int POM_AM__set_application_bypass(logical bypass);
using namespace std;
double stringToNum( string str)
{
	istringstream iss(str);
	double num;
	iss >> num;
	return num;    
}

char * mem_char(char *x)
{
	if(x!=NULL)
						{
							MEM_free(x);
							x=NULL;
						}
	return x;
}

tag_t * mem_tag(tag_t *x)
{
	if(x!=NULL)
						{
							MEM_free(x);
							x=NULL;
						}
	return x;
}
void  insertMap(tag_t targetRev,map<tag_t, string>&targetmap)
{
	targetmap.clear();
	int ifail=0;
	int bom_num=0;
	tag_t * bom_tags=NULLTAG;
	ITKCALL(ifail=AOM_ask_value_tags(targetRev,"structure_revisions",&bom_num,&bom_tags));
	if(bom_num>0)
	{
		tag_t only_bom=bom_tags[0];
		tag_t bom_window_tag = NULLTAG,top_bom_line_tag =NULLTAG,rev_tag = NULLTAG,item_tag =NULLTAG;
		ITKCALL(ifail = BOM_create_window(&bom_window_tag));
		ITKCALL(ifail = BOM_set_window_top_line_bvr(bom_window_tag,only_bom,&top_bom_line_tag));
		int child_count=0;tag_t *child_tags=NULLTAG;
		ITKCALL(ifail =  BOM_line_ask_all_child_lines(top_bom_line_tag,&child_count,&child_tags));
		for(int n=0;n<child_count;n++)
		{

			char * item_id=NULL;
			char *item_rev_id=NULL;
			char *bl_sequence_no=NULL;
			tag_t map_rev=NULL;
			ITKCALL(ifail = AOM_ask_value_string(child_tags[n],"bl_item_item_id",&item_id));
			ITKCALL(ifail = AOM_ask_value_string(child_tags[n],"bl_rev_item_revision_id",&item_rev_id));
			ITKCALL(ifail = AOM_ask_value_string(child_tags[n],"bl_sequence_no",&bl_sequence_no));
			ITKCALL(ifail = ITEM_find_rev(item_id,item_rev_id,&map_rev));
			targetmap.insert(pair<tag_t,string>(map_rev,bl_sequence_no));
			item_id=mem_char(item_id);
			bl_sequence_no=mem_char(bl_sequence_no);
			item_rev_id=mem_char(item_rev_id);
		}
		child_tags=mem_tag(child_tags);
		ITKCALL(ifail = BOM_save_window(bom_window_tag));//要保存，否则修改属性后bom视图不会保存
		ITKCALL(ifail = BOM_close_window(bom_window_tag));//有开必有关
	}

	bom_tags=mem_tag(bom_tags);
}

void setBomlineProperty(tag_t old_line,tag_t new_line,string attribute_name)
{
	int ifail=0;
	try
	{
		cout<<"开始设置属性------------"<<attribute_name<<endl;
		int attribute,attr_mode;
		BOM_line_look_up_attribute(attribute_name.c_str(),&attribute);
		cout<<attribute_name<<"--------attribute-------->"<<attribute<<endl;
		BOM_line_ask_attribute_mode(attribute,&attr_mode);
		cout<<attribute_name<<"-----attr_mode-------->"<<attr_mode<<endl;
		char* value=NULL;
		tag_t bluom=NULL;
			AOM_ask_value_string(old_line,"bl_item_item_id",&value);
		cout<<"id------------"<<value<<endl;
		if(attr_mode==4)
		{
			AOM_ask_value_tag(old_line,attribute_name.c_str(),&bluom);
		}else
		{
			ITKCALL(ifail=AOM_ask_value_string(old_line,attribute_name.c_str(),&value));
	
		cout<<"值"<<value<<endl;
		}
	
			
		string valueString=value;
		switch (attr_mode)
		{
		case BOM_attribute_mode_double:
			BOM_line_set_attribute_double(new_line,attribute,stringToNum(valueString));
			break;
		case BOM_attribute_mode_int:
			BOM_line_set_attribute_int(new_line,attribute,stringToNum(valueString));
			break;
		case BOM_attribute_mode_logical:
			if(valueString=="true")
			{
				BOM_line_set_attribute_logical(new_line,attribute,true);
			}else
			{
				BOM_line_set_attribute_logical(new_line,attribute,true);
			}
			break;
		case BOM_attribute_mode_string:
			
			
	
			if(strcmp(attribute_name.c_str(),"bl_part_source")==0)
			{
				if(strcmp(valueString.c_str(),"自制")==0)
				{
					ITKCALL(ifail=BOM_line_set_attribute_string(new_line,attribute,"Make"));
				}else if(strcmp(valueString.c_str(),"外购")==0)
				{
					ITKCALL(ifail=BOM_line_set_attribute_string(new_line,attribute,"Buy"));
				}
					
					
			}else
			{
					ITKCALL(ifail=BOM_line_set_attribute_string(new_line,attribute,valueString.c_str()));
			}
			break;
		case BOM_attribute_mode_tag:
			cout<<"属性是对象类型"<<endl;
			
				ITKCALL(ifail=BOM_line_set_attribute_tag(new_line,attribute,bluom));
			break;
		}}
		catch (exception e)
		{
			cout<<attribute_name<<"设置错误"<<endl;
		}

	


};

int jk_upgrade_version(EPM_action_message_t msg)
{
	cout<<"开始升版操作-----------"<<endl;
	int ifail = ITK_ok,  i = 0, att_cnt = 0;
	tag_t task_tag = NULLTAG, rootTask_tag = NULLTAG, *attachments = NULL;
	char * object_TYPE_1 = NULL;
	map<tag_t,string> map1;//存放上一个发布EBOM版本的所有一级BOMLine和查找编号
	map<tag_t,string> map2;//存放最新发布MBOM版本的所有一级BOMLine和查找编号
	map<tag_t,tag_t> map3;//存放上一个发布EBOM版本的所有一级BOMLine和最新发布MBOM版本的所有一级BOMLine
	map<tag_t,string> map4;//存放最新EBOM版本的所有一级BOMLine和对应的id
	//获取当前触发的任务
	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 (i = 0; i < att_cnt; i++) {
		ITKCALL(ifail = AOM_ask_value_string(attachments[i], "object_type", &object_TYPE_1));//对象类型
		
		cout << object_TYPE_1<<endl;
		if(strcmp("JK8MaterialRevision",object_TYPE_1)==0||strcmp("物料版本",object_TYPE_1)==0)
		{
			//获取当前EBOM的上一个版本
			cout<<"属于物料版本，开始升版"<<endl;
			tag_t item;
			ITKCALL(ifail=ITEM_ask_item_of_rev(attachments[i],&item));
			int rev_num=0;
			tag_t *revsTag=NULLTAG;
			
			AOM_ask_value_tags(item,"revision_list",&rev_num,&revsTag);
			tag_t targetRev=revsTag[rev_num-2];//上一个发布版本
		
			
			insertMap(targetRev,map1);
		

			insertMap(attachments[i],map4);
			

			int actualNum=0;
			tag_t *actualtags=NULLTAG;
			int mbom_num=0;
			//获取EBOM的MBOM关系下的所有MBOM版本对象20190411MBOM关系下挂的是对象
			ITKCALL(ifail=AOM_ask_value_tags(targetRev,"JK8MBOMRelation",&actualNum,&actualtags));
			for (int j=0;j<actualNum;j++)
			{
				map2.clear();
				map3.clear();
				tag_t * mbom_tag=NULLTAG;
				tag_t latest_rev;
				ITEM_ask_latest_rev(actualtags[j],&latest_rev);
				ITKCALL(ifail = AOM_ask_value_tags(latest_rev,"structure_revisions",&mbom_num,&mbom_tag));
				tag_t only_bom=mbom_tag[0];
				tag_t bom_window_tag = NULLTAG,top_bom_line_tag =NULLTAG,rev_tag = NULLTAG,item_tag =NULLTAG;
				ITKCALL(ifail = BOM_create_window(&bom_window_tag));
				ITKCALL(ifail = BOM_set_window_top_line_bvr(bom_window_tag,only_bom,&top_bom_line_tag));
				int child_count=0;tag_t *child_tags=NULLTAG;
				ITKCALL(ifail =  BOM_line_ask_all_child_lines(top_bom_line_tag,&child_count,&child_tags));
				for(int n=0;n<child_count;n++)
				{
					char * item_id=NULL;
					char *item_rev_id=NULL;
					char *bl_sequence_no=NULL;
					tag_t map2_rev=NULL;
					ITKCALL(ifail = AOM_ask_value_string(child_tags[n],"bl_item_item_id",&item_id));
					ITKCALL(ifail = AOM_ask_value_string(child_tags[n],"bl_rev_item_revision_id",&item_rev_id));
					ITKCALL(ifail = AOM_ask_value_string(child_tags[n],"bl_sequence_no",&bl_sequence_no));
					ITKCALL(ifail = ITEM_find_rev(item_id,item_rev_id,&map2_rev));

					map2.insert(pair<tag_t,string>(map2_rev,bl_sequence_no));
					
					map<tag_t,string>::iterator rev_it;
					for( rev_it = map1.begin(); rev_it != map1.end(); rev_it++ )
					{

						char *object_string=NULL;
						tag_t tag1=rev_it->first;
						string map1_sequence_no=rev_it->second;
						tag_t tag2=map2_rev;
						AOM_ask_value_string(tag1,"object_string",&object_string);
						cout<<"map2键"<<object_string<<endl;
						AOM_ask_value_string(tag2,"object_string",&object_string);
						cout<<"map2值"<<object_string<<endl;
						if(strcmp(map1_sequence_no.c_str(),bl_sequence_no)==0)
						{
							map3.insert(pair<tag_t,tag_t>(rev_it->first,map2_rev));//存放上一个版本的ebomline对应的版本，mbom关系下的mbomline对应的版本
							break;
						}


					}
					

					
					item_id=mem_char(item_id);
					item_rev_id=mem_char(item_rev_id);
					bl_sequence_no=mem_char(bl_sequence_no);
				}
				ITKCALL(ifail = BOM_save_window(bom_window_tag));//要保存，否则修改属性后bom视图不会保存
				ITKCALL(ifail = BOM_close_window(bom_window_tag));//有开必有关

			
				//ITEM_rev_delete_bvr()
				tag_t newRev=NULLTAG;
				ITKCALL(ifail =ITEM_copy_rev(latest_rev,NULL,&newRev));//升版
				
				//TODO 获取MBOM的所有层级和属性信息，存储起来

				//TODO 删除MBOM下的BOM视图，比较EBOM和MBOM后，重新搭起来
				//					BOM_line_cut();
				
				tag_t win,top_line;
				BOM_create_window(&win);
				BOM_set_window_pack_all(win,false);
				BOM_set_window_top_line(win, NULL, latest_rev, NULL, &top_line);

				//TODO 删除升版后的bom视图
			/*	int cnt=0;
				tag_t *tags=NULLTAG;
				AOM_ask_value_tags(newRev, "structure_revisions", &cnt, &tags);

				ITEM_rev_delete_bvr(newRev,tags[0]);*/
				tag_t win_new,top_line_new;
				BOM_create_window(&win_new);
				BOM_set_window_pack_all(win_new,false);
				BOM_set_window_top_line(win_new, NULL, newRev, NULL, &top_line_new);
				int top_line_new_count=0;
				tag_t *top_line_new_child_tags=NULLTAG;
				BOM_line_ask_all_child_lines(top_line_new,&top_line_new_count,&top_line_new_child_tags);
				for (int e=0;e<top_line_new_count;e++)
				{
//					POM_AM__set_application_bypass(true);
					ITKCALL(ifail=BOM_line_cut(top_line_new_child_tags[e]));
					BOM_save_window(win_new);
				}
				
			

				if(top_line==NULLTAG)
				{
					cout<<"cant find structure";
				}
//				tag_t view_type;
//				ITKCALL(ifail=PS_ask_bom_view_type(only_bom,&view_type));
				cout<<"map4.size()--------->"<<map4.size()<<endl;
//						if(true)
//			{
//				return 0;
//			}
				map<tag_t,string>::iterator rev_map4;
				for( rev_map4 = map4.begin(); rev_map4 != map4.end(); rev_map4++ )
				{
					tag_t rev=rev_map4->first;
					char  * newEBOM_id=NULL;
					if(rev!=NULL)
					{
						ITKCALL(ifail = AOM_ask_value_string(rev,"object_string",&newEBOM_id));
						cout<<"newEBOM_id-------->"<<newEBOM_id<<endl;
						ITKCALL(ifail = AOM_ask_value_string(rev,"item_id",&newEBOM_id));
					}else
					{
						cout<<"wrong"<<endl;
						return 0;
					}
					
					map<tag_t,tag_t>::iterator rev_map3;
					int map3_size=0;
					for( rev_map3 = map3.begin(); rev_map3 != map3.end(); rev_map3++ )
					{
						map3_size++;
						tag_t ebom_rev=rev_map3->first;
						char * ebom_id=NULL;
						char * mbom_id=NULL;
						tag_t mbom_rev=rev_map3->second;
						ITKCALL(ifail = AOM_ask_value_string(ebom_rev,"item_id",&ebom_id));//TODO bomline上的属性
						ITKCALL(ifail = AOM_ask_value_string(mbom_rev,"item_id",&mbom_id));
						cout<<"map3_size------------>"<<map3_size<<endl;
						cout<<"比较newEBOM_id---------->"<<newEBOM_id<<endl;
						cout<<"比较ebom_id---------->"<<ebom_id<<endl;
						cout<<"比较mbom_id---------->"<<mbom_id<<endl;
						if(strcmp(newEBOM_id,ebom_id)==0)//如果两个bomline的id相同，考虑是直接复制还是复制自身
						{
							int mbom_child_count=0;tag_t *mbom_child_tags=NULLTAG;
							ITKCALL(ifail =  BOM_line_ask_all_child_lines(top_line,&mbom_child_count,&mbom_child_tags));
							if(strcmp(ebom_id,mbom_id)==0)//如果不是选配，就先剪切在复制ebomline
							{
								for (int n=0;n<mbom_child_count;n++)
								{
									tag_t mbom_child=mbom_child_tags[n];
									char *mbomline_item_id=NULL;
								
									AOM_ask_value_string(mbom_child,"bl_item_item_id",&mbomline_item_id);
									if(strcmp(mbomline_item_id,mbom_id)==0)
									{
										cout<<"mbom上存在ebomline，只需复制------"<<endl;
										//TODO 复制EBOMLINE到MBOM上
										tag_t win1,top_line1;
										BOM_create_window(&win1);
										BOM_set_window_pack_all(win1,false);
										BOM_set_window_top_line(win1, NULL, attachments[i], NULL, &top_line1);
										int top_line1_child_count=0;
										tag_t *top_line1_child_tags=NULLTAG;
										BOM_line_ask_all_child_lines(top_line1,&top_line1_child_count,&top_line1_child_tags);
//										ITKCALL(ifail=BOM_line_cut(mbom_child));
//											BOM_save_window(win);
										for(int m=0;m<top_line1_child_count;m++)
										{
											tag_t top_line1_child_tag=top_line1_child_tags[m];
											char *top_line1_child_tag_id=NULL;
											AOM_ask_value_string(top_line1,"bl_item_item_id",&top_line1_child_tag_id);
												cout<<"顶层id----》"<<top_line1_child_tag_id<<endl;
											AOM_ask_value_string(top_line1,"bl_rev_item_revision_id",&top_line1_child_tag_id);
												cout<<"顶层版本----》"<<top_line1_child_tag_id<<endl;
											AOM_ask_value_string(top_line1_child_tag,"bl_quantity",&top_line1_child_tag_id);
											cout<<"数量-----》"<<top_line1_child_tag_id<<endl;
											AOM_ask_value_string(top_line1_child_tag,"bl_item_item_id",&top_line1_child_tag_id);
											
											if(strcmp(top_line1_child_tag_id,mbomline_item_id)==0)
											{
												cout<<"将ebomline复制到mbomline"<<endl;
												tag_t new_line;
//												ITKCALL(ifail=BOM_line_copy(top_line_new,top_line1_child_tag,view_type,&new_line));
												ITKCALL(ifail=BOM_line_copy(top_line_new,top_line1_child_tag,NULL,&new_line));
//												setBomlineProperty(top_line1_child_tag,new_line,"bl_quantity");
												BOM_save_window(win_new);
												setBomlineProperty(top_line1_child_tag,new_line,"bl_sequence_no");
												setBomlineProperty(top_line1_child_tag,new_line,"bl_part_source");
												
											
												BOM_save_window(win_new);
													BOM_save_window(win);
												BOM_save_window(win1);
												top_line1_child_tag_id=mem_char(top_line1_child_tag_id);
												
												break;
											}
											top_line1_child_tag_id=mem_char(top_line1_child_tag_id);
										}
										top_line1_child_tags=mem_tag(top_line1_child_tags);
										BOM_save_window(win1);
										BOM_close_window(win1);
											BOM_save_window(win_new);
										mbomline_item_id=mem_char(mbomline_item_id);
										break;
									}
									mbomline_item_id=mem_char(mbomline_item_id);
								}
								
							
							}else//如果是选配的顶层，就把mbom自身的bomline先剪切再复制
							{
								cout<<"选配产生的，需将上一个版本的mbomline复制过来，并把ebomline的属性复制过来即可"<<endl;
								for (int n=0;n<mbom_child_count;n++)
								{
									tag_t mbom_child=mbom_child_tags[n];
									char *mbomline_item_id=NULL;
									AOM_ask_value_string(mbom_child,"bl_item_item_id",&mbomline_item_id);
									if(strcmp(mbomline_item_id,mbom_id)==0)
									{
										tag_t new_line;
										

										ITKCALL(ifail=BOM_line_copy(top_line_new,mbom_child,NULL,&new_line));
//										setBomlineProperty(mbom_child,new_line,"bl_quantity");
										BOM_save_window(win_new);
										setBomlineProperty(mbom_child,new_line,"bl_sequence_no");
									setBomlineProperty(mbom_child,new_line,"bl_part_source");
										BOM_save_window(win_new);
//										ITKCALL(ifail=BOM_line_cut(mbom_child));
//										BOM_save_window(win);
										//TODO 复制ebomline的属性到mbom上(数量，查找编号，度量单位bl_uom，自制/外购，仓库jk8Warehouse1，供应类型jk8SupplyType1)
										//TODO 遍历EBOM，只要里面有bomline的id和map3的键相同，就把其属性复制过来
										int bom_num=0;
	tag_t * bom_tags=NULLTAG;
	ITKCALL(ifail=AOM_ask_value_tags(attachments[i],"structure_revisions",&bom_num,&bom_tags));
	if(bom_num>0)
	{
		tag_t only_bom_new=bom_tags[0];
		tag_t bom_window_tag_new = NULLTAG,top_bom_line_tag_new =NULLTAG;
//		rev_tag = NULLTAG,item_tag =NULLTAG;
		ITKCALL(ifail = BOM_create_window(&bom_window_tag_new));
		ITKCALL(ifail = BOM_set_window_top_line_bvr(bom_window_tag_new,only_bom_new,&top_bom_line_tag_new));
		int child_count_new=0;tag_t *child_tags_new=NULLTAG;
		ITKCALL(ifail =  BOM_line_ask_all_child_lines(top_bom_line_tag_new,&child_count_new,&child_tags_new));
		for(int n1=0;n1<child_count_new;n1++)
		{

			char * item_id=NULL;
			char *item_rev_id=NULL;
			ITKCALL(ifail = AOM_ask_value_string(child_tags_new[n1],"bl_item_item_id",&item_id));
			ITKCALL(ifail = AOM_ask_value_string(child_tags_new[n1],"bl_rev_item_revision_id",&item_rev_id));
			if(strcmp(newEBOM_id,item_id)==0)
			{
				tag_t ebomlineTag=child_tags_new[n1];

				setBomlineProperty(ebomlineTag,new_line,"bl_sequence_no");
				setBomlineProperty(ebomlineTag,new_line,"bl_quantity");
				setBomlineProperty(ebomlineTag,new_line,"jk8Warehouse1");
				setBomlineProperty(ebomlineTag,new_line,"jk8SupplyType1");
				setBomlineProperty(ebomlineTag,new_line,"bl_uom");
				setBomlineProperty(ebomlineTag,new_line,"bl_part_source");

				BOM_save_window(win_new);


				item_id=mem_char(item_id);
				item_rev_id=mem_char(item_rev_id);
				break;
			}
			item_id=mem_char(item_id);
			item_rev_id=mem_char(item_rev_id);
		}
		child_tags_new=mem_tag(child_tags_new);
		ITKCALL(ifail = BOM_save_window(bom_window_tag_new));//要保存，否则修改属性后bom视图不会保存
		ITKCALL(ifail = BOM_close_window(bom_window_tag_new));//有开必有关
	}

	bom_tags=mem_tag(bom_tags);




									/*	setBomlineProperty(mbom_child,new_line,"bl_quantity");
										setBomlineProperty(mbom_child,new_line,"bl_sequence_no");
										setBomlineProperty(mbom_child,new_line,"bl_part_source");
										setBomlineProperty(mbom_child,new_line,"bl_uom");*/
										BOM_save_window(win_new);
								

										

//											BOM_line_set_attribute_double
										mbomline_item_id=mem_char(mbomline_item_id);
										break;
									}
									mbomline_item_id=mem_char(mbomline_item_id);
								}
								
							}
								break;
						}else//如果ebomline上的bomline在mbom上不存在就直接复制复制过来
						{
							cout<<"mbomline不存在此line"<<endl;
							if(map3_size==map3.size())
							{
								tag_t win2,top_line2;
								BOM_create_window(&win2);
								BOM_set_window_pack_all(win2,false);
								BOM_set_window_top_line(win2, NULL, attachments[i], NULL, &top_line2);
								int top_line2_child_count=0;
								tag_t * top_line2_child_tags=NULLTAG;
								BOM_line_ask_all_child_lines(top_line2,&top_line2_child_count,&top_line2_child_tags);
								for(int d=0;d<top_line2_child_count;d++)
								{
									tag_t top_line2_child_tag=top_line2_child_tags[d];
									char *top_line2_child_tag_id=NULL;
									AOM_ask_value_string(top_line2_child_tag,"bl_item_item_id",&top_line2_child_tag_id);
									if(strcmp(top_line2_child_tag_id,newEBOM_id)==0)
									{
										cout<<"这是新增的bomline"<<endl;
										tag_t new_line;
										ITKCALL(ifail=BOM_line_copy(top_line_new,top_line2_child_tag,NULL,&new_line));
//									setBomlineProperty(top_line2_child_tag,new_line,"bl_quantity");
										BOM_save_window(win_new);
										setBomlineProperty(top_line2_child_tag,new_line,"bl_sequence_no");
										setBomlineProperty(top_line2_child_tag,new_line,"bl_part_source");
										BOM_save_window(win_new);
										top_line2_child_tag_id=mem_char(top_line2_child_tag_id);
										break;
									}
									top_line2_child_tag_id=mem_char(top_line2_child_tag_id);
								}
								top_line2_child_tags=mem_tag(top_line2_child_tags);
								BOM_save_window(win2);
								BOM_close_window(win2);


							
							}
						}
						
					}
				
				
//					BOM_line_add(top_line, NULL, l->rev, NULL, &line);

				}
				
				BOM_save_window(win);
				BOM_save_window(win_new);
				cout<<"保存"<<endl;
				BOM_close_window(win);
				BOM_close_window(win_new);
				cout<<"关闭"<<endl;
				mbom_tag=mem_tag(mbom_tag);
			}
			revsTag=mem_tag(revsTag);
			cout<<"清空前"<<endl;
			actualtags=mem_tag(actualtags);
			cout<<"清空"<<endl;
		}else
		{
			cout<<"不是物料版本"<<endl;
			continue;
		}
		
		
	}
	cout<<"清空缓存object_TYPE_1"<<endl;
	object_TYPE_1=mem_char(object_TYPE_1);
	cout<<"清空缓存reference_attachment"<<endl;
	attachments=mem_tag(attachments);
	cout<<"执行结束--------"<<endl;
	return 0;
}
