#include "jk_custom.h"
#include "tc_log.h"
#include <res/res_itk.h>

typedef struct{
	string jk8ProductType;//产品类型
	string 	jk8ProductModNO;// 产品型号
	string 	jk8ProductIdentifyNO;// 识别号
	string 	jk8ProductName;// 产品名称
	string 	jk8BaseMeterManufactor;// 基表厂家   5
	string 	jk8ICCardType;// IC卡型号
	string 	jk8CircBoardModNO;// 线路板型号
	string 	jk8ProgramFeatures;// 程序特征
	string 	jk8InsteadType;// 替代型号
	string 	jk8FunctionOverview;// 功能概述  10
	string 	jk8CustSpecRequirements;// 客户特殊要求
	//string 	jk8U8NO;// U8编码号  （去掉）
	string 	jk8Valve;// 阀门
	string 	jk8EncryptType;// 加密类型
	string 	jk8Applicant;// 申请人
	string 	jk8RecordDate;// 登记日期
	string 	jk8ApplyMarket;// 适用市场
	string 	jk8BMManfMatched;// 配套基表厂家

	string jk8ProjectName;//项目名称
	string jk8ProjectNO;//项目编号  19

	string jk8Status;// 状态    //2018.6.4新加4属性
	string jk8ValveType;// 阀门类型
	string jk8CommunicateMode;// 通信方式
	string jk8PowerSupplyMode;// 供电类型  23

	//2019.07.31
	string jk8GasType;//气体种类
	string jk8AlaDectRelation;//报警部分与检测部分的关系
	string jk8UsePlace;//使用场所
	string jk8OutputSignal;//输出信号种类
	string jk8ProFeatNum;//产品特征号

	//2020-03-31
	string jk8Manufacturer;//生产厂家
	string jk8CommunicateMode2;//通信方式2

}JK_SUMMARY_STRUCT;


typedef struct{
	string	jk8Companylogo;//公司标识
	string 	jk8MeasureType;// 计量方式
	string 	jk8CommunicateMode;// 通讯方式
	string 	jk8Application;// 应用范围
	string 	jk8PCBNO;// pcb编码   5
	string  jk8Projectname;//项目名称
}JK_SUMMARY_PCB_STRUCT;


extern "C" int POM_AM__set_application_bypass(logical bypass);
/**
* 获取四张扩展表的属性
*
*/
void JK_get_form_prop(tag_t form_tag,JK_SUMMARY_STRUCT &bean,char *form_type){
//	char * form_value[28];
//	int prop_count = 28;
	//2020-03-31
	char * form_value[30];
	int prop_count = 30;
	WriteLog_jk("开始获取单张表属性 \n");
	tag_t user_tag =NULLTAG;
	ITKCALL(AOM_ask_value_tag(form_tag,"owning_user",&user_tag));
	if(user_tag!=NULLTAG)
	{
		ITKCALL(AOM_ask_value_string(user_tag,"user_name",&form_value[13]))
	}else{
		form_value[13] = (char *)MEM_alloc(sizeof(char)*128);//申请人
	}
	form_value[14] = (char *)MEM_alloc(sizeof(char)*128);//登记日期
	//ITKCALL(AOM_ask_value_string(form_tag,"jk8RecordDate",&form_value[14]));// 登记日期
	time_t now;
	struct tm *p;
	time(&now);
	p = localtime(&now);
	sprintf(form_value[14], "%d年%d月%d日", 1900+p->tm_year,p->tm_mon+1 ,p->tm_mday );
	if(strcmp(form_type , "JK8CotlerPModAppForm")==0){//控制器表单(产品型号)

		for (int i = 0; i < prop_count; i++)
		{
			if((i!=4)&&(i!=9)&&1<i<17||i==20||i==22){
				form_value[i] = (char *)MEM_alloc(sizeof(char)*128);
				strcpy(form_value[i],"");// 状态  默认为空
			}

		}

		ITKCALL(AOM_ask_value_string(form_tag,"jk8ProductModNO",&form_value[1]));// 产品型号
		//ITKCALL(AOM_ask_value_string(form_tag,"jk8ProductIdentifyNO",&form_value[2]));// 识别号
		ITKCALL(AOM_ask_value_string(form_tag,"jk8BMManufactor",&form_value[4]));// 基表厂家
		ITKCALL(AOM_ask_value_string(form_tag,"jk8FunctionOverview",&form_value[9]));// 功能概述
		ITKCALL(AOM_ask_value_string(form_tag,"jk8ProjectName",&form_value[17]));// 项目名称
		ITKCALL(AOM_ask_value_string(form_tag,"jk8ProjectNO",&form_value[18]));// 项目编号
		form_value[19] = (char *)MEM_alloc(sizeof(char)*128);
		strcpy(form_value[19],"");// 状态  默认为空
	//	ITKCALL(AOM_ask_value_string(form_tag,"jk8ValveType",&form_value[20]));// 阀门类型
		ITKCALL(AOM_ask_value_string(form_tag,"jk8CommunicateMode",&form_value[21]));// 通信方式
	//	ITKCALL(AOM_ask_value_string(form_tag,"jk8PowerSupplyMode",&form_value[22]));// 供电方式

	}else if(strcmp(form_type , "JK8ColPIdenNOAppForm")==0){//控制器产品识别号
		for (int i = 0; i < prop_count; i++)
		{
			if(2<i<17){
				form_value[i] = (char *)MEM_alloc(sizeof(char)*128);
				strcpy(form_value[i],"");// 状态  默认为空
			}

		}
		ITKCALL(AOM_ask_value_string(form_tag,"jk8ProductModNO",&form_value[1]));// 产品型号
		ITKCALL(AOM_ask_value_string(form_tag,"jk8ProductIdentifyNO",&form_value[2]));// 识别号
		ITKCALL(AOM_ask_value_string(form_tag,"jk8ProjectName",&form_value[17]));// 项目名称
		ITKCALL(AOM_ask_value_string(form_tag,"jk8ProjectNO",&form_value[18]));// 项目编号
		form_value[19] = (char *)MEM_alloc(sizeof(char)*128);
		strcpy(form_value[19],"");// 状态  默认为空
		ITKCALL(AOM_ask_value_string(form_tag,"jk8ValveType",&form_value[20]));// 阀门类型
		ITKCALL(AOM_ask_value_string(form_tag,"jk8CommunicateMode",&form_value[21]));// 通信方式
		ITKCALL(AOM_ask_value_string(form_tag,"jk8PowerSupplyMode",&form_value[22]));// 供电方式
		form_value[23] = (char *)MEM_alloc(sizeof(char)*128);
		strcpy(form_value[23],"");//气体种类代号   默认为空
		form_value[24] = (char *)MEM_alloc(sizeof(char)*128);
		strcpy(form_value[24],"");//使用场所   默认为空
		form_value[25] = (char *)MEM_alloc(sizeof(char)*128);
		strcpy(form_value[25],"");//报警部分与检测部分的关系   默认为空
		form_value[26] = (char *)MEM_alloc(sizeof(char)*128);
		strcpy(form_value[26],"");//输出信号种类   默认为空
		form_value[27] = (char *)MEM_alloc(sizeof(char)*128);
		strcpy(form_value[27],"");//产品特征号   默认为空

	}
	else if(strcmp(form_type , "JK8ALPModAppForm")==0)//2019.07.31报警器产品型号
	{
		for (int i = 0; i < prop_count; i++)
		{
			if(i!=1&&i!=3&&i!=13&&i!=14&&i!=17&&i!=18&&i!=23&&i!=24&&i!=25&&i!=26&&i!=27){
				form_value[i] = (char *)MEM_alloc(sizeof(char)*128);
				strcpy(form_value[i],"");// 状态  默认为空
			}

		}



//		ITKCALL(AOM_ask_value_string(form_tag,"jk8ProductType",&form_value[0]));//产品类型
		ITKCALL(AOM_ask_value_string(form_tag,"jk8ProductModNO",&form_value[1]));// 产品型号
//		ITKCALL(AOM_ask_value_string(form_tag,"jk8ProductIdentifyNO",&form_value[2]));// 识别号
		ITKCALL(AOM_ask_value_string(form_tag,"jk8ProductName",&form_value[3]));// 产品名称
//		ITKCALL(AOM_ask_value_string(form_tag,"jk8BMManufactor",&form_value[4]));// 基表厂家
//		ITKCALL(AOM_ask_value_string(form_tag,"jk8ICCardType",&form_value[5]));// IC卡型号
//		ITKCALL(AOM_ask_value_string(form_tag,"jk8CircBoardModNO",&form_value[6]));// 线路板型号
//		ITKCALL(AOM_ask_value_string(form_tag,"jk8ProgramFeatures",&form_value[7]));// 程序特征
//		ITKCALL(AOM_ask_value_string(form_tag,"jk8InsteadType",&form_value[8]));// 替代型号
//		ITKCALL(AOM_ask_value_string(form_tag,"jk8FunctionOverview",&form_value[9]));// 功能概述
//		ITKCALL(AOM_ask_value_string(form_tag,"jk8CustSpecRequirements",&form_value[10]));// 客户特殊要求
		//ITKCALL(AOM_ask_value_string(attachments[i],"jk8U8NO",&form_value));// U8编码号  （去掉）
//		ITKCALL(AOM_ask_value_string(form_tag,"jk8Valve",&form_value[11]));// 阀门
//		ITKCALL(AOM_ask_value_string(form_tag,"jk8EncryptType",&form_value[12]));// 加密类型
		//
		//ITKCALL(AOM_ask_value_string(form_tag,"jk8Applicant",&form_value[13]));// 申请人
		

//		ITKCALL(AOM_ask_value_string(form_tag,"jk8ApplyMarket",&form_value[15]));// 适用市场
//		ITKCALL(AOM_ask_value_string(form_tag,"jk8BMManfMatched",&form_value[16]));// 配套基表厂家
		ITKCALL(AOM_ask_value_string(form_tag,"jk8ProjectName",&form_value[17]));// 项目名称
		ITKCALL(AOM_ask_value_string(form_tag,"jk8ProjectNO",&form_value[18]));// 项目编号





		ITKCALL(AOM_ask_value_string(form_tag,"jk8GasType",&form_value[23]));// 气体种类
		ITKCALL(AOM_ask_value_string(form_tag,"jk8UsePlace",&form_value[24]));// 使用场所
		ITKCALL(AOM_ask_value_string(form_tag,"jk8AlaDectRelation",&form_value[25]));// 报警部分与检测部分的关系
		ITKCALL(AOM_ask_value_string(form_tag,"jk8OutputSignal",&form_value[26]));// 输出信号种类
		ITKCALL(AOM_ask_value_string(form_tag,"jk8ProFeatNum",&form_value[27]));// 产品特征号


	}
	// 2020-03-31
	
	else if(strcmp(form_type , "JK8WarnerNPModINOAppForm")==0)//报警器产品型号识别号申请表
	{
		for (int i = 0; i < prop_count; i++)
		{
			if(i!=1&&i!=3&&i!=13&&i!=14&&i!=17&&i!=18&&i!=23&&i!=24&&i!=25&&i!=26&&i!=27){
				form_value[i] = (char *)MEM_alloc(sizeof(char)*128);
				strcpy(form_value[i],"");// 状态  默认为空
			}

		}



//		ITKCALL(AOM_ask_value_string(form_tag,"jk8ProductType",&form_value[0]));//产品类型
		ITKCALL(AOM_ask_value_string(form_tag,"jk8ProductModNO",&form_value[1]));// 产品型号
//		ITKCALL(AOM_ask_value_string(form_tag,"jk8ProductIdentifyNO",&form_value[2]));// 识别号
		ITKCALL(AOM_ask_value_string(form_tag,"jk8ProductName",&form_value[3]));// 产品名称
//		ITKCALL(AOM_ask_value_string(form_tag,"jk8BMManufactor",&form_value[4]));// 基表厂家
//		ITKCALL(AOM_ask_value_string(form_tag,"jk8ICCardType",&form_value[5]));// IC卡型号
//		ITKCALL(AOM_ask_value_string(form_tag,"jk8CircBoardModNO",&form_value[6]));// 线路板型号
//		ITKCALL(AOM_ask_value_string(form_tag,"jk8ProgramFeatures",&form_value[7]));// 程序特征
//		ITKCALL(AOM_ask_value_string(form_tag,"jk8InsteadType",&form_value[8]));// 替代型号
//		ITKCALL(AOM_ask_value_string(form_tag,"jk8FunctionOverview",&form_value[9]));// 功能概述
//		ITKCALL(AOM_ask_value_string(form_tag,"jk8CustSpecRequirements",&form_value[10]));// 客户特殊要求
		//ITKCALL(AOM_ask_value_string(attachments[i],"jk8U8NO",&form_value));// U8编码号  （去掉）
//		ITKCALL(AOM_ask_value_string(form_tag,"jk8Valve",&form_value[11]));// 阀门
//		ITKCALL(AOM_ask_value_string(form_tag,"jk8EncryptType",&form_value[12]));// 加密类型
		//
		//ITKCALL(AOM_ask_value_string(form_tag,"jk8Applicant",&form_value[13]));// 申请人
		

//		ITKCALL(AOM_ask_value_string(form_tag,"jk8ApplyMarket",&form_value[15]));// 适用市场
//		ITKCALL(AOM_ask_value_string(form_tag,"jk8BMManfMatched",&form_value[16]));// 配套基表厂家
		ITKCALL(AOM_ask_value_string(form_tag,"jk8ProjectName",&form_value[17]));// 项目名称
		ITKCALL(AOM_ask_value_string(form_tag,"jk8ProjectNO",&form_value[18]));// 项目编号





		ITKCALL(AOM_ask_value_string(form_tag,"jk8GasType",&form_value[23]));// 气体种类
		ITKCALL(AOM_ask_value_string(form_tag,"jk8UsePlace",&form_value[24]));// 使用场所
		ITKCALL(AOM_ask_value_string(form_tag,"jk8AlaDectRelation",&form_value[25]));// 报警部分与检测部分的关系
		ITKCALL(AOM_ask_value_string(form_tag,"jk8OutputSignal",&form_value[26]));// 输出信号种类
		ITKCALL(AOM_ask_value_string(form_tag,"jk8ProFeatNum",&form_value[27]));// 产品特征号

		ITKCALL(AOM_ask_value_string(form_tag,"jk8Manufacturer",&form_value[28]));// 生产厂家
		ITKCALL(AOM_ask_value_string(form_tag,"jk8ProductType",&form_value[0]));// 产品类型
		ITKCALL(AOM_ask_value_string(form_tag,"jk8CommunicateMode2",&form_value[29]));// 通信方式2


	}
	else if(strcmp(form_type , "JK8WarnerNPINOAppForm")==0)//报警器产品识别号申请表
	{
		for (int i = 0; i < prop_count; i++)
		{
			if(i!=1&&i!=3&&i!=13&&i!=14&&i!=17&&i!=18&&i!=23&&i!=24&&i!=25&&i!=26&&i!=27){
				form_value[i] = (char *)MEM_alloc(sizeof(char)*128);
				strcpy(form_value[i],"");// 状态  默认为空
			}

		}



//		ITKCALL(AOM_ask_value_string(form_tag,"jk8ProductType",&form_value[0]));//产品类型
		ITKCALL(AOM_ask_value_string(form_tag,"jk8ProductModNO",&form_value[1]));// 产品型号
//		ITKCALL(AOM_ask_value_string(form_tag,"jk8ProductIdentifyNO",&form_value[2]));// 识别号
		ITKCALL(AOM_ask_value_string(form_tag,"jk8ProductName",&form_value[3]));// 产品名称
//		ITKCALL(AOM_ask_value_string(form_tag,"jk8BMManufactor",&form_value[4]));// 基表厂家
//		ITKCALL(AOM_ask_value_string(form_tag,"jk8ICCardType",&form_value[5]));// IC卡型号
//		ITKCALL(AOM_ask_value_string(form_tag,"jk8CircBoardModNO",&form_value[6]));// 线路板型号
//		ITKCALL(AOM_ask_value_string(form_tag,"jk8ProgramFeatures",&form_value[7]));// 程序特征
//		ITKCALL(AOM_ask_value_string(form_tag,"jk8InsteadType",&form_value[8]));// 替代型号
//		ITKCALL(AOM_ask_value_string(form_tag,"jk8FunctionOverview",&form_value[9]));// 功能概述
//		ITKCALL(AOM_ask_value_string(form_tag,"jk8CustSpecRequirements",&form_value[10]));// 客户特殊要求
		//ITKCALL(AOM_ask_value_string(attachments[i],"jk8U8NO",&form_value));// U8编码号  （去掉）
//		ITKCALL(AOM_ask_value_string(form_tag,"jk8Valve",&form_value[11]));// 阀门
//		ITKCALL(AOM_ask_value_string(form_tag,"jk8EncryptType",&form_value[12]));// 加密类型
		//
		//ITKCALL(AOM_ask_value_string(form_tag,"jk8Applicant",&form_value[13]));// 申请人
		

//		ITKCALL(AOM_ask_value_string(form_tag,"jk8ApplyMarket",&form_value[15]));// 适用市场
//		ITKCALL(AOM_ask_value_string(form_tag,"jk8BMManfMatched",&form_value[16]));// 配套基表厂家
		ITKCALL(AOM_ask_value_string(form_tag,"jk8ProjectName",&form_value[17]));// 项目名称
		ITKCALL(AOM_ask_value_string(form_tag,"jk8ProjectNO",&form_value[18]));// 项目编号





		ITKCALL(AOM_ask_value_string(form_tag,"jk8GasType",&form_value[23]));// 气体种类
		ITKCALL(AOM_ask_value_string(form_tag,"jk8UsePlace",&form_value[24]));// 使用场所
		ITKCALL(AOM_ask_value_string(form_tag,"jk8AlaDectRelation",&form_value[25]));// 报警部分与检测部分的关系
		ITKCALL(AOM_ask_value_string(form_tag,"jk8OutputSignal",&form_value[26]));// 输出信号种类
		ITKCALL(AOM_ask_value_string(form_tag,"jk8ProFeatNum",&form_value[27]));// 产品特征号

		ITKCALL(AOM_ask_value_string(form_tag,"jk8Manufacturer",&form_value[28]));// 生产厂家
		ITKCALL(AOM_ask_value_string(form_tag,"jk8ProductType",&form_value[0]));// 产品类型
		ITKCALL(AOM_ask_value_string(form_tag,"jk8CommunicateMode2",&form_value[29]));// 通信方式2

	}
	else//其他表单类型，包括新产品型号与识别号申请表，识别号申请表，衍生号申请表，特殊要求申请表
	{
		cout<<"2---"<<endl;
		ITKCALL(AOM_ask_value_string(form_tag,"jk8ProductType",&form_value[0]));//产品类型
		ITKCALL(AOM_ask_value_string(form_tag,"jk8ProductModNO",&form_value[1]));// 产品型号
		ITKCALL(AOM_ask_value_string(form_tag,"jk8ProductIdentifyNO",&form_value[2]));// 识别号
		ITKCALL(AOM_ask_value_string(form_tag,"jk8ProductName",&form_value[3]));// 产品名称
		ITKCALL(AOM_ask_value_string(form_tag,"jk8BMManufactor",&form_value[4]));// 基表厂家
		ITKCALL(AOM_ask_value_string(form_tag,"jk8ICCardType",&form_value[5]));// IC卡型号
		ITKCALL(AOM_ask_value_string(form_tag,"jk8CircBoardModNO",&form_value[6]));// 线路板型号
		ITKCALL(AOM_ask_value_string(form_tag,"jk8ProgramFeatures",&form_value[7]));// 程序特征
		ITKCALL(AOM_ask_value_string(form_tag,"jk8InsteadType",&form_value[8]));// 替代型号
		ITKCALL(AOM_ask_value_string(form_tag,"jk8FunctionOverview",&form_value[9]));// 功能概述
		ITKCALL(AOM_ask_value_string(form_tag,"jk8CustSpecRequirements",&form_value[10]));// 客户特殊要求
		//ITKCALL(AOM_ask_value_string(attachments[i],"jk8U8NO",&form_value));// U8编码号  （去掉）
		ITKCALL(AOM_ask_value_string(form_tag,"jk8Valve",&form_value[11]));// 阀门
		ITKCALL(AOM_ask_value_string(form_tag,"jk8EncryptType",&form_value[12]));// 加密类型
		//ITKCALL(AOM_ask_value_string(form_tag,"jk8Applicant",&form_value[13]));// 申请人
		

		ITKCALL(AOM_ask_value_string(form_tag,"jk8ApplyMarket",&form_value[15]));// 适用市场
		ITKCALL(AOM_ask_value_string(form_tag,"jk8BMManfMatched",&form_value[16]));// 配套基表厂家
		ITKCALL(AOM_ask_value_string(form_tag,"jk8ProjectName",&form_value[17]));// 项目名称
		ITKCALL(AOM_ask_value_string(form_tag,"jk8ProjectNO",&form_value[18]));// 项目编号

		form_value[19] = (char *)MEM_alloc(sizeof(char)*128);
		strcpy(form_value[19],"");// 状态  默认为空
		form_value[20] = (char *)MEM_alloc(sizeof(char)*128);
		strcpy(form_value[20],"");// 状态  默认为空
		form_value[21] = (char *)MEM_alloc(sizeof(char)*128);
		strcpy(form_value[21],"");// 状态  默认为空
		form_value[22] = (char *)MEM_alloc(sizeof(char)*128);
		strcpy(form_value[22],"");// 状态  默认为空
		form_value[23] = (char *)MEM_alloc(sizeof(char)*128);
		strcpy(form_value[23],"");//气体种类代号   默认为空
		form_value[24] = (char *)MEM_alloc(sizeof(char)*128);
		strcpy(form_value[24],"");//使用场所   默认为空
		form_value[25] = (char *)MEM_alloc(sizeof(char)*128);
		strcpy(form_value[25],"");//报警部分与检测部分的关系   默认为空
		form_value[26] = (char *)MEM_alloc(sizeof(char)*128);
		strcpy(form_value[26],"");//输出信号种类   默认为空
		form_value[27] = (char *)MEM_alloc(sizeof(char)*128);
		strcpy(form_value[27],"");//产品特征号   默认为空
		form_value[28] = (char *)MEM_alloc(sizeof(char)*128);
		strcpy(form_value[28],"");//产品特征号   默认为空
		form_value[29] = (char *)MEM_alloc(sizeof(char)*128);
		strcpy(form_value[29],"");//产品特征号   默认为空
		cout<<"3---"<<endl;
		//ITKCALL(AOM_ask_value_string(form_tag,"jk8ValveType",&form_value[20]));// 阀门类型
		//ITKCALL(AOM_ask_value_string(form_tag,"jk8CommunicateMode",&form_value[21]));// 通信方式
		//ITKCALL(AOM_ask_value_string(form_tag,"jk8PowerSupplyMode",&form_value[22]));// 供电方式
	}

	


	{
		if(strcmp(form_type , "JK8NPModINOAppForm")==0){//新产品型号与识别号申请表
			char * jk8ProductType1 =NULL;
			ITKCALL(AOM_ask_value_string(form_tag,"jk8ProductType1",&jk8ProductType1));//产品类型
			if(strcmp(jk8ProductType1,"民用表")==0  ){
				bean.jk8ProductType.assign("tb1");//产品类型
			}else if(strcmp(jk8ProductType1,"流量计")==0 || strcmp(jk8ProductType1,"工业表")==0){
				bean.jk8ProductType.assign("tb2");
			}else if(strcmp(form_value[0],"采集器")==0){
				bean.jk8ProductType.assign("tb3");//产品类型
			}else if(strcmp(form_value[0],"阀门")==0){
				bean.jk8ProductType.assign("tb4");//产品类型
			}else if(strcmp(form_value[0],"集中器")==0){
				bean.jk8ProductType.assign("tb5");//产品类型
			}else if(strcmp(form_value[0],"充值宝")==0){
				bean.jk8ProductType.assign("tb6");//产品类型
			}else if(strcmp(form_value[0],"手持机")==0){
				bean.jk8ProductType.assign("tb7");//产品类型
			}else if(strcmp(form_value[0],"读卡器")==0){
				bean.jk8ProductType.assign("tb8");//产品类型
			}else if(strcmp(form_value[0],"模组")==0){
				bean.jk8ProductType.assign("tb9");//产品类型
			}else if(strcmp(form_value[0],"控制器")==0){
				bean.jk8ProductType.assign("tb10");//产品类型
			}else{
				bean.jk8ProductType.assign("tb11");//产品类型
			}
			if(jk8ProductType1 != NULL){
				MEM_free(jk8ProductType1);
				jk8ProductType1 = NULL;
			}
		}else if(strcmp(form_type , "JK8CotlerPModAppForm")==0){ //控制器产品型号
			bean.jk8ProductType.assign("tb10");//产品类型
		}else if(strcmp(form_type , "JK8ColPIdenNOAppForm")==0){//控制器识别号
			bean.jk8ProductType.assign("tb10");//产品类型
		}else if(strcmp(form_type , "JK8ALPModAppForm")==0){//报警器产品型号
			bean.jk8ProductType.assign("tb12");//产品类型
		}else{
			bean.jk8ProductType.assign(form_value[0]);//产品类型
		}
		bean.jk8ProductModNO.assign(form_value[1]);// 产品型号
		bean.jk8ProductIdentifyNO.assign(form_value[2]);// 识别号
		bean.jk8ProductName.assign(form_value[3]);// 产品名称
		bean.jk8BaseMeterManufactor.assign(form_value[4]);// 基表厂家   5
		bean.jk8ICCardType.assign(form_value[5]);// IC卡型号
		bean.jk8CircBoardModNO.assign(form_value[6]);// 线路板型号
		bean.jk8ProgramFeatures.assign(form_value[7]);// 程序特征
		bean.jk8InsteadType.assign(form_value[8]);// 替代型号
		bean.jk8FunctionOverview.assign(form_value[9]);// 功能概述  10
		bean.jk8CustSpecRequirements.assign(form_value[10]);
		//bean.jk8U8NO.assign(form_value[0]);// U8编码号  （去掉）
		bean.jk8Valve.assign(form_value[11]);// 阀门
		bean.jk8EncryptType.assign(form_value[12]);// 加密类型
		bean.jk8Applicant.assign(form_value[13]);// 申请人
		bean.jk8RecordDate.assign(form_value[14]);// 登记日期
		bean.jk8ApplyMarket.assign(form_value[15]);// 适用市场
		bean.jk8BMManfMatched.assign(form_value[16]);// 配套基表厂家

		bean.jk8ProjectName.assign(form_value[17]);// 项目名称
		bean.jk8ProjectNO.assign(form_value[18]);// 项目编号
		bean.jk8Status.assign(form_value[19]);// 状态
		bean.jk8ValveType.assign(form_value[20]);// 阀门类型
		bean.jk8CommunicateMode.assign(form_value[21]); // 通信方式
		bean.jk8PowerSupplyMode.assign(form_value[22]);// 供电方式

		//2019.07.31 气体种类  
		bean.jk8GasType.assign(form_value[23]);
		bean.jk8UsePlace.assign(form_value[24]);
		bean.jk8AlaDectRelation.assign(form_value[25]);
		bean.jk8OutputSignal.assign(form_value[26]);
		bean.jk8ProFeatNum.assign(form_value[27]);
		// 2020-03-31
		bean.jk8Manufacturer.assign(form_value[28]);
		bean.jk8CommunicateMode2.assign(form_value[29]);
	}

	//释放资源
	for(int i = 0 ;i <prop_count;i++){
		if(form_value[i]!=NULL){
			MEM_free(form_value[i]);
			form_value[i] = NULL;
		}
	}
}

/**
*
* 获取汇总表的属性
*
*/
void JK_get_summary_form_prop(tag_t form_tag,vector<JK_SUMMARY_STRUCT> &bean_vec,int * isOk){
//	int prop_count = 28;
//	int count[28],sum_count =0;
//	char ** form_value[28];
	// 20200331
	int prop_count = 30;
	int count[30],sum_count =0;
	char ** form_value[30];
	//POM_AM__set_application_bypass(true);
	*isOk = 1;
	WriteLog_jk("获取汇总表单【%d】的属性\n",form_tag);
	printf("获取汇总表单【%d】的属性\n",form_tag);
	ITKCALL(AOM_ask_value_strings(form_tag,"jk8ProductType",&count[0],&form_value[0]));//产品类型
	sum_count = count[0];
	ITKCALL(AOM_ask_value_strings(form_tag,"jk8ProductModNO",&count[1],&form_value[1]));// 产品型号
	ITKCALL(AOM_ask_value_strings(form_tag,"jk8ProductIdentifyNO",&count[2],&form_value[2]));// 识别号
	ITKCALL(AOM_ask_value_strings(form_tag,"jk8ProductName",&count[3],&form_value[3]));// 产品名称
	ITKCALL(AOM_ask_value_strings(form_tag,"jk8BaseMeterManufactor",&count[4],&form_value[4]));// 基表厂家
	ITKCALL(AOM_ask_value_strings(form_tag,"jk8ICCardType",&count[5],&form_value[5]));// IC卡型号
	ITKCALL(AOM_ask_value_strings(form_tag,"jk8CircBoardModNO",&count[6],&form_value[6]));// 线路板型号
	ITKCALL(AOM_ask_value_strings(form_tag,"jk8ProgramFeatures",&count[7],&form_value[7]));// 程序特征
	ITKCALL(AOM_ask_value_strings(form_tag,"jk8InsteadType",&count[8],&form_value[8]));// 替代型号
	ITKCALL(AOM_ask_value_strings(form_tag,"jk8FunctionOverview",&count[9],&form_value[9]));// 功能概述
	ITKCALL(AOM_ask_value_strings(form_tag,"jk8CustSpecRequirements",&count[10],&form_value[10]));// 客户特殊要求
	//ITKCALL(AOM_ask_value_string(attachments[i],"jk8U8NO",&form_value));// U8编码号  （去掉）
	ITKCALL(AOM_ask_value_strings(form_tag,"jk8Valve",&count[11],&form_value[11]));// 阀门
	ITKCALL(AOM_ask_value_strings(form_tag,"jk8EncryptType",&count[12],&form_value[12]));// 加密类型
	ITKCALL(AOM_ask_value_strings(form_tag,"jk8Applicant",&count[13],&form_value[13]));// 申请人
	ITKCALL(AOM_ask_value_strings(form_tag,"jk8RecordDate",&count[14],&form_value[14]));// 登记日期
	ITKCALL(AOM_ask_value_strings(form_tag,"jk8ApplyMarket",&count[15],&form_value[15]));// 适用市场
	ITKCALL(AOM_ask_value_strings(form_tag,"jk8BMManfMatched",&count[16],&form_value[16]));// 配套基表厂家

	ITKCALL(AOM_ask_value_strings(form_tag,"jk8ProjectName",&count[17],&form_value[17]));// 项目名称
	ITKCALL(AOM_ask_value_strings(form_tag,"jk8ProjectNO",&count[18],&form_value[18]));// 项目编号

	ITKCALL(AOM_ask_value_strings(form_tag,"jk8Status",&count[19],&form_value[19]));// 项目名称
	ITKCALL(AOM_ask_value_strings(form_tag,"jk8ValveType",&count[20],&form_value[20]));// 项目编号
	ITKCALL(AOM_ask_value_strings(form_tag,"jk8CommunicateMode",&count[21],&form_value[21]));// 项目名称
	ITKCALL(AOM_ask_value_strings(form_tag,"jk8PowerSupplyMode",&count[22],&form_value[22]));// 项目编号
	//2019.07.31
	ITKCALL(AOM_ask_value_strings(form_tag,"jk8GasType",&count[23],&form_value[23]));// 气体种类
	ITKCALL(AOM_ask_value_strings(form_tag,"jk8AlaDectRelation",&count[24],&form_value[24]));// 报警部分与检测部分的关系
	ITKCALL(AOM_ask_value_strings(form_tag,"jk8UsePlace",&count[25],&form_value[25]));// 使用场所
	ITKCALL(AOM_ask_value_strings(form_tag,"jk8OutputSignal",&count[26],&form_value[26]));// 输出信号种类
	ITKCALL(AOM_ask_value_strings(form_tag,"jk8ProFeatNum",&count[27],&form_value[27]));// 产品特征号
	//2020-03-31
	ITKCALL(AOM_ask_value_strings(form_tag,"jk8Manufacturer",&count[28],&form_value[28]));// 生产厂家
	ITKCALL(AOM_ask_value_strings(form_tag,"jk8CommunicateMode2",&count[29],&form_value[29]));// 通信方式2
	for(int i  = 0 ;i < (prop_count-1);i++){
		if(count[i] !=count[i+1]){
			*isOk = 0;
			WriteLog_jk("汇总表单属性不正确=>\n");
			printf("属性不正确=>\n");
		}
	}
	printf("222222222222222222=>\n");
	if( *isOk ==1){
		printf("3333333333333333=>\n");
		for(int i = 0 ;i <sum_count;i++ ){
			JK_SUMMARY_STRUCT bean ;
			bean.jk8ProductType.assign(form_value[0][i]);//产品类型
			bean.jk8ProductModNO.assign(form_value[1][i]);// 产品型号
			bean.jk8ProductIdentifyNO.assign(form_value[2][i]);// 识别号
			bean.jk8ProductName.assign(form_value[3][i]);// 产品名称
			bean.jk8BaseMeterManufactor.assign(form_value[4][i]);// 基表厂家   5
			bean.jk8ICCardType.assign(form_value[5][i]);// IC卡型号
			bean.jk8CircBoardModNO.assign(form_value[6][i]);// 线路板型号
			bean.jk8ProgramFeatures.assign(form_value[7][i]);// 程序特征
			bean.jk8InsteadType.assign(form_value[8][i]);// 替代型号
			bean.jk8FunctionOverview.assign(form_value[9][i]);// 功能概述  10
			bean.jk8CustSpecRequirements.assign(form_value[10][i]);// 客户特殊要求
			//bean.jk8U8NO.assign(form_value[0][i]);// U8编码号  （去掉）
			bean.jk8Valve.assign(form_value[11][i]);// 阀门
			bean.jk8EncryptType.assign(form_value[12][i]);// 加密类型
			bean.jk8Applicant.assign(form_value[13][i]);// 申请人
			bean.jk8RecordDate.assign(form_value[14][i]);// 登记日期
			bean.jk8ApplyMarket.assign(form_value[15][i]);// 适用市场
			bean.jk8BMManfMatched.assign(form_value[16][i]);// 配套基表厂家

			bean.jk8ProjectName.assign(form_value[17][i]);// 项目名称
			bean.jk8ProjectNO.assign(form_value[18][i]);// 项目编号

			bean.jk8Status.assign(form_value[19][i]);// 状态
			bean.jk8ValveType.assign(form_value[20][i]);// 阀门类型
			bean.jk8CommunicateMode.assign(form_value[21][i]);// 通信方式
			bean.jk8PowerSupplyMode.assign(form_value[22][i]);// 供电类型
			//2019.07.31
			bean.jk8GasType.assign(form_value[23][i]);// 气体种类
			bean.jk8AlaDectRelation.assign(form_value[24][i]);// 报警部分
			bean.jk8UsePlace.assign(form_value[25][i]);// 使用场所
			bean.jk8OutputSignal.assign(form_value[26][i]);// 输出信号种类
			bean.jk8ProFeatNum.assign(form_value[27][i]);// 产品特征号
			//2020-03-31
			bean.jk8Manufacturer.assign(form_value[28][i]);// 生产厂家
			bean.jk8CommunicateMode2.assign(form_value[29][i]);// 通信方式2

			bean_vec.push_back(bean);
		}
	}
	printf("444444444444444=>\n");
	for(int i = 0 ;i < prop_count; i++){
		for(int j = 0;j < count[i];j++){
			MEM_free(form_value[i][j]);
			form_value[i][j] =NULL;
		}
		MEM_free(form_value[i]);
		form_value[i] = NULL;
	}
	//POM_AM__set_application_bypass(false);
	printf("555555555555=>\n");

}

/**
*	设置汇总表属性
*/
void JK_set_summary_form_prop(tag_t form_tag,vector<JK_SUMMARY_STRUCT> bean_vec){
	WriteLog_jk("开始设置汇总表属性\n");
	int i = 0,j=0 ;
	int prop_count = 30;
	char ** values[30];
	if(bean_vec.size() > 0){
		for(i = 0 ;i < prop_count;i++){
			values[i] =(char**) MEM_alloc(sizeof(char*)*bean_vec.size());
			for(j =0;j < bean_vec.size();j++){
				values[i][j] = (char *) MEM_alloc(sizeof(char)*256);
			}
		}
		for(i = 0 ;i < bean_vec.size();i++){
			JK_SUMMARY_STRUCT bean = bean_vec[i];
			strcpy(values[0][i],bean.jk8ProductType.c_str());
			strcpy(values[1][i],bean.jk8ProductModNO.c_str());// 产品型号
			strcpy(values[2][i],bean.jk8ProductIdentifyNO.c_str());// 识别号
			strcpy(values[3][i],bean.jk8ProductName.c_str());// 产品名称
			strcpy(values[4][i],bean.jk8BaseMeterManufactor.c_str());// 基表厂家   5
			strcpy(values[5][i],bean.jk8ICCardType.c_str());// IC卡型号
			strcpy(values[6][i],bean.jk8CircBoardModNO.c_str());// 线路板型号
			strcpy(values[7][i],bean.jk8ProgramFeatures.c_str());// 程序特征
			strcpy(values[8][i],bean.jk8InsteadType.c_str());;// 替代型号
			strcpy(values[9][i],bean.jk8FunctionOverview.c_str());// 功能概述  10
			strcpy(values[10][i],bean.jk8CustSpecRequirements.c_str());// 客户特殊要求
			//bean.jk8U8NO.c_str());// U8编码号  （去掉）
			strcpy(values[11][i],bean.jk8Valve.c_str());// 阀门
			strcpy(values[12][i],bean.jk8EncryptType.c_str());// 加密类型
			strcpy(values[13][i],bean.jk8Applicant.c_str());// 申请人
			strcpy(values[14][i],bean.jk8RecordDate.c_str());// 登记日期
			strcpy(values[15][i],bean.jk8ApplyMarket.c_str());// 适用市场
			strcpy(values[16][i],bean.jk8BMManfMatched.c_str());// 配套基表厂家

			strcpy(values[17][i],bean.jk8ProjectName.c_str());// 项目名称
			strcpy(values[18][i],bean.jk8ProjectNO.c_str());// 项目编号

			strcpy(values[19][i],bean.jk8Status.c_str());// 状态
			strcpy(values[20][i],bean.jk8ValveType.c_str());// 阀门类型
			strcpy(values[21][i],bean.jk8CommunicateMode.c_str());// 通信方式
			strcpy(values[22][i],bean.jk8PowerSupplyMode.c_str());// 供电类型

			strcpy(values[23][i],bean.jk8GasType.c_str());// 气体种类
			strcpy(values[24][i],bean.jk8UsePlace.c_str());// 使用场所
			strcpy(values[25][i],bean.jk8AlaDectRelation.c_str());// 报警部分
			strcpy(values[26][i],bean.jk8OutputSignal.c_str());// 输出信号种类
			strcpy(values[27][i],bean.jk8ProFeatNum.c_str());// 产品特征号

			// 2020-03-31
			strcpy(values[28][i],bean.jk8Manufacturer.c_str());// 生产厂家
			strcpy(values[29][i],bean.jk8CommunicateMode2.c_str());// 通信方式2

		}
	}
	
	ITKCALL(AOM_set_value_strings(form_tag,"jk8ProductType",bean_vec.size(),values[0]));//产品类型
	ITKCALL(AOM_set_value_strings(form_tag,"jk8ProductModNO",bean_vec.size(),values[1]));// 产品型号
	ITKCALL(AOM_set_value_strings(form_tag,"jk8ProductIdentifyNO",bean_vec.size(),values[2]));// 识别号
	ITKCALL(AOM_set_value_strings(form_tag,"jk8ProductName",bean_vec.size(),values[3]));// 产品名称
	ITKCALL(AOM_set_value_strings(form_tag,"jk8BaseMeterManufactor",bean_vec.size(),values[4]));// 基表厂家
	ITKCALL(AOM_set_value_strings(form_tag,"jk8ICCardType",bean_vec.size(),values[5]));// IC卡型号
	ITKCALL(AOM_set_value_strings(form_tag,"jk8CircBoardModNO",bean_vec.size(),values[6]));// 线路板型号
	ITKCALL(AOM_set_value_strings(form_tag,"jk8ProgramFeatures",bean_vec.size(),values[7]));// 程序特征
	ITKCALL(AOM_set_value_strings(form_tag,"jk8InsteadType",bean_vec.size(),values[8]));// 替代型号
	ITKCALL(AOM_set_value_strings(form_tag,"jk8FunctionOverview",bean_vec.size(),values[9]));// 功能概述
	ITKCALL(AOM_set_value_strings(form_tag,"jk8CustSpecRequirements",bean_vec.size(),values[10]));// 客户特殊要求
	//ITKCALL(AOM_ask_value_string(attachments[i],"jk8U8NO",&form_value));// U8编码号  （去掉）
	ITKCALL(AOM_set_value_strings(form_tag,"jk8Valve",bean_vec.size(),values[11]));// 阀门
	ITKCALL(AOM_set_value_strings(form_tag,"jk8EncryptType",bean_vec.size(),values[12]));// 加密类型
	ITKCALL(AOM_set_value_strings(form_tag,"jk8Applicant",bean_vec.size(),values[13]));// 申请人
	ITKCALL(AOM_set_value_strings(form_tag,"jk8RecordDate",bean_vec.size(),values[14]));// 登记日期
	ITKCALL(AOM_set_value_strings(form_tag,"jk8ApplyMarket",bean_vec.size(),values[15]));// 适用市场
	ITKCALL(AOM_set_value_strings(form_tag,"jk8BMManfMatched",bean_vec.size(),values[16]));// 配套基表厂家

	ITKCALL(AOM_set_value_strings(form_tag,"jk8ProjectName",bean_vec.size(),values[17]));// 项目名称
	ITKCALL(AOM_set_value_strings(form_tag,"jk8ProjectNO",bean_vec.size(),values[18]));// 项目编号

	ITKCALL(AOM_set_value_strings(form_tag,"jk8Status",bean_vec.size(),values[19]));// 状态
	ITKCALL(AOM_set_value_strings(form_tag,"jk8ValveType",bean_vec.size(),values[20]));// 阀门类型
	ITKCALL(AOM_set_value_strings(form_tag,"jk8CommunicateMode",bean_vec.size(),values[21]));// 通信方式
	ITKCALL(AOM_set_value_strings(form_tag,"jk8PowerSupplyMode",bean_vec.size(),values[22]));// 供电类型
	
	//2019.07.31
	ITKCALL(AOM_set_value_strings(form_tag,"jk8GasType",bean_vec.size(),values[23]));// 气体种类
	ITKCALL(AOM_set_value_strings(form_tag,"jk8UsePlace",bean_vec.size(),values[24]));// 使用场所
	ITKCALL(AOM_set_value_strings(form_tag,"jk8AlaDectRelation",bean_vec.size(),values[25]));// 报警部分
	ITKCALL(AOM_set_value_strings(form_tag,"jk8OutputSignal",bean_vec.size(),values[26]));// 输出信号种类
	ITKCALL(AOM_set_value_strings(form_tag,"jk8ProFeatNum",bean_vec.size(),values[27]));// 产品特征号

	// 2020-03-31
	ITKCALL(AOM_set_value_strings(form_tag,"jk8Manufacturer",bean_vec.size(),values[28]));// 生产厂家
	ITKCALL(AOM_set_value_strings(form_tag,"jk8CommunicateMode2",bean_vec.size(),values[29]));// 通信方式2

	ITKCALL(AOM_save(form_tag));
	ITKCALL(AOM_refresh(form_tag,false));
	ITKCALL(AOM_unlock(form_tag,0));
	WriteLog_jk("传递汇总表结束,保存数据完成\n");
	printf("------------传递汇总表0000-----------------");

	//释放资源
	/*for(i = 0 ;i <prop_count;i++){
	for(j =0;j < bean_vec.size();j++){
	MEM_free(values[i][j]);
	values[i][j] = NULL;
	}
	MEM_free(values[i]);
	values[i] = NULL;
	}*/
	printf("------------传递汇总表1111-----------------");
}

/**
* 产品汇总表
*/
int JK_summary_form(EPM_rule_message_t msg)
{
	char tc_log_file_name[512];
	time_t				now;
	struct				tm *p;
	time(&now);
	p = localtime(&now);

	//sprintf(startDate,"%04d-%d-%02d 00:00", 1900+p->tm_year,p->tm_mon+1 ,p->tm_mday);
	//sprintf(endDate,"%04d-%d-%02d 23:59", 1900+p->tm_year,p->tm_mon+1 ,p->tm_mday);
	sprintf(tc_log_file_name, "%s\\jk_hzb_log_[%d-%d-%d-%d-%02d].txt",getenv("TEMP"),1900+p->tm_year,p->tm_mon+1 ,p->tm_mday,p->tm_hour,p->tm_min  );
	printf("tc_log_file_name=%s\n",tc_log_file_name);
	CreateLogFile_jk(tc_log_file_name);

	EPM_decision_t decision = EPM_go;
	int ifail = ITK_ok,arg_cnt = 0,i = 0,att_cnt = 0;
	tag_t task_tag = NULLTAG ,rootTask_tag = NULLTAG, *attachments =NULL,summary_form_tag = NULLTAG;
	char *arg = NULL,*argflag = NULL, *argvalue = NULL,type_class[WSO_object_type_size_c+1] ="\0",*form_value = NULL;
	vector<JK_SUMMARY_STRUCT> bean_vec;
	//用来获取汇总表的PUID
	vector<string> pref_vec;
	getPrefStrings("JK_SQB_FORM_PUID",TC_preference_site, pref_vec);
	if(pref_vec.size() > 0){
		ITK__convert_uid_to_tag(pref_vec[0].c_str(),&summary_form_tag);
		if(summary_form_tag == NULLTAG){
			WriteLog_jk("PUID[%s]不能转换成对象\n",pref_vec[0].c_str());
			CloseLog_jk();
			printf("PUID[%s]不能转换成对象\n",pref_vec[0].c_str());
			return EPM_nogo;
		}
		printf("找到了汇总表\n");
		int isOk = 1;
		logical  is_reserved;
		POM_AM__set_application_bypass(true);
		ITKCALL(RES_is_checked_out(summary_form_tag,&is_reserved));
		if (is_reserved)
		{
			WriteLog_jk("汇总表签出,开始签入\n");
			ITKCALL(RES_checkin(summary_form_tag));
		}
		ITKCALL(AOM_lock(summary_form_tag));
		ITKCALL(AOM_refresh(summary_form_tag,false));
		POM_AM__set_application_bypass(false);
		JK_get_summary_form_prop(summary_form_tag,bean_vec,&isOk);
		if(isOk == 0){
			ITKCALL(AOM_unlock(summary_form_tag));
			printf("PUID[%s]表单属性不正确\n",pref_vec[0].c_str());
			WriteLog_jk("PUID[%s]表单属性不正确\n",pref_vec[0].c_str());
			CloseLog_jk();
			return EPM_nogo;
		}
	}else{
		printf("请配置首选项[connor_custSummaryFormPUID]\n");
		WriteLog_jk("请配置首选项[connor_custSummaryFormPUID]\n");
		CloseLog_jk();
		return EPM_nogo;
	}

	//获取当前触发的任务
	task_tag = msg.task;
	//获取根流程节点
	ITKCALL(ifail = EPM_ask_root_task(task_tag, &rootTask_tag));
	//获取目标引用对象
	ITKCALL(ifail = EPM_ask_attachments(rootTask_tag, EPM_target_attachment, &att_cnt, &attachments));
	//循环目标对象
	for(i = 0;i < att_cnt ; i++){
		//获取对象的类型
		/**********************************************
		*	对象类型：JK8DerPIdenNOAppForm
		*	对象类型：JK8SpecPINOAppForm
		*	对象类型：JK8NewPIdenNOAppForm
		*	对象类型：JK8NPModINOAppForm
		*	对象类型：JK8ExtPIdenNOAppForm
		**********************************************/
		ITKCALL( WSOM_ask_object_type(attachments[i], type_class));
		WriteLog_jk("对象类型：%s \n",type_class);
		printf("对象类型：%s \n",type_class);
		if(strcmp(type_class,"JK8DerPIdenNOAppForm") ==0 //衍生产品识别号申请表
			||strcmp(type_class,"JK8SpecPINOAppForm") ==0 //特殊要求产品识别号申请表
			||strcmp(type_class,"JK8NewPIdenNOAppForm") ==0 //新产品识别号申请表
			||strcmp(type_class,"JK8ExtPIdenNOAppForm") ==0 //扩展产品识别号申请表  //2017.12.4增加申请表
			||strcmp(type_class,"JK8NPModINOAppForm") ==0//新产品型号与识别号申请表
			||strcmp(type_class,"JK8CotlerPModAppForm") ==0//控制器产品型号申请表//2018.1.20 新增申请表
			||strcmp(type_class,"JK8ColPIdenNOAppForm") ==0//控制器识别号申请表//2018.6.4 新增申请表
			||strcmp(type_class,"JK8ALPModAppForm") ==0//2019.07.31 新增报警器产品型号申请表
			//2020-03-31
			||strcmp(type_class,"JK8WarnerNPModINOAppForm") ==0   // 报警器产品型号识别号申请表
			||strcmp(type_class,"JK8WarnerNPINOAppForm") ==0           // 报警器产品识别号申请表
			)
		{
			WriteLog_jk("对象类型符合,开始执行代码 \n");
			char *name_fo;
			ITKCALL(AOM_ask_value_string(attachments[i],"object_name",&name_fo));
			WriteLog_jk("对象名称：%s \n",name_fo);

			char *sbhstr,*cpxhstr;
			if(strcmp(type_class,"JK8CotlerPModAppForm") ==0){
				ITKCALL(AOM_ask_value_string(attachments[i],"jk8ProductModNO",&cpxhstr));// 产品型号
				if(strcmp(cpxhstr,"") ==0){
					printf("产品型号为空,无法传递\n");
					ITKCALL(AOM_unlock(summary_form_tag));
					WriteLog_jk("产品型号为空,无法传递\n");
					CloseLog_jk();
					return EPM_nogo;
				}	
			}
			else if(strcmp(type_class,"JK8ALPModAppForm") ==0){
				ITKCALL(AOM_ask_value_string(attachments[i],"jk8ProductModNO",&cpxhstr));// 产品型号
				if(strcmp(cpxhstr,"") ==0){
					printf("产品型号为空,无法传递\n");
					ITKCALL(AOM_unlock(summary_form_tag));
					WriteLog_jk("产品型号为空,无法传递\n");
					CloseLog_jk();
					return EPM_nogo;
				}	
			}
			
			else{
				ITKCALL(AOM_ask_value_string(attachments[i],"jk8ProductIdentifyNO",&sbhstr));// 识别号

				if(strcmp(sbhstr,"") ==0){
					printf("识别号为空,无法传递\n");
					ITKCALL(AOM_unlock(summary_form_tag));
					WriteLog_jk("识别号为空,无法传递\n");
					CloseLog_jk();
					return EPM_nogo;
				}
			}

			JK_SUMMARY_STRUCT bean ;
			//获取单张表的属性
			JK_get_form_prop(attachments[i],bean,type_class);
			cout<<"单张属性获取完毕"<<endl;
			bean_vec.push_back(bean);
		}

	}

	POM_AM__set_application_bypass(true);
	JK_set_summary_form_prop(summary_form_tag,bean_vec);
	printf("------------传递汇总表2222-----------------");
	POM_AM__set_application_bypass(false);

	if(attachments!=NULL)
	{
		MEM_free(attachments);
		attachments = NULL;
	}
	WriteLog_jk("------------传递汇总表结束-----------------");
	CloseLog_jk();
	printf("------------传递汇总表完成-----------------");
	return decision;
}






/**
*	设置汇总表属性pcb
*/
void JK_set_summary_pcb_form_prop(tag_t form_tag,vector<JK_SUMMARY_PCB_STRUCT> bean_vec){
	int i = 0,j=0 ;
	int prop_count = 6;
	char ** values[6];
	if(bean_vec.size() > 0){
		for(i = 0 ;i < prop_count;i++){
			values[i] =(char**) MEM_alloc(sizeof(char*)*bean_vec.size());
			for(j =0;j < bean_vec.size();j++){
				values[i][j] = (char *) MEM_alloc(sizeof(char)*256);
			}
		}
		for(i = 0 ;i < bean_vec.size();i++){
			JK_SUMMARY_PCB_STRUCT bean = bean_vec[i];
			strcpy(values[0][i],bean.jk8PCBNO.c_str());//pcb编码
			strcpy(values[1][i],bean.jk8Companylogo.c_str());// 公司标识
			strcpy(values[2][i],bean.jk8MeasureType.c_str());// 计量原理
			strcpy(values[3][i],bean.jk8CommunicateMode.c_str());// 通讯方式
			strcpy(values[4][i],bean.jk8Application.c_str());// 应用范围  5
			strcpy(values[5][i],bean.jk8Projectname.c_str());
		}
	}
	ITKCALL(AOM_lock(form_tag));
	ITKCALL(AOM_set_value_strings(form_tag,"jk8PCBNO",bean_vec.size(),values[0]));//pcb编码
	ITKCALL(AOM_set_value_strings(form_tag,"jk8Companylogo",bean_vec.size(),values[1]));//公司标识
	ITKCALL(AOM_set_value_strings(form_tag,"jk8MeasureType",bean_vec.size(),values[2]));// 计量原理
	ITKCALL(AOM_set_value_strings(form_tag,"jk8CommunicateMode",bean_vec.size(),values[3]));// 通讯方式
	ITKCALL(AOM_set_value_strings(form_tag,"jk8Application",bean_vec.size(),values[4]));// 应用范围
	ITKCALL(AOM_set_value_strings(form_tag,"jk8Projectname",bean_vec.size(),values[5]));// 应用范围

	ITKCALL(AOM_save(form_tag));
	ITKCALL(AOM_unlock(form_tag,0));
	printf("------------传递汇总表0000-----------------");

	//释放资源
	for(i = 0 ;i <prop_count;i++){
		for(j =0;j < bean_vec.size();j++){
			if(values[i][j]!=NULL){
				MEM_free(values[i][j]);
				values[i][j] = NULL;
			}

		}
		if(values[i]!=NULL){
			MEM_free(values[i]);
			values[i] = NULL;
		}
	}
	printf("------------传递汇总表1111-----------------");
}



/**
* 获取2张扩展表的属性
*	pcb
*/
void JK_get_pcb_form_prop(tag_t form_tag,JK_SUMMARY_PCB_STRUCT &bean,char *form_type){
	char * form_value[5];
	int prop_count = 5;
	ITKCALL(AOM_ask_value_string(form_tag,"jk8PCBNO",&form_value[0]));//pcb编码
	ITKCALL(AOM_ask_value_string(form_tag,"jk8Companylogo",&form_value[1]));// 公司标识
	ITKCALL(AOM_ask_value_string(form_tag,"jk8MeasureType",&form_value[2]));// 计量原理
	ITKCALL(AOM_ask_value_string(form_tag,"jk8CommunicateMode",&form_value[3]));// 通讯方式
	ITKCALL(AOM_ask_value_string(form_tag,"jk8Application",&form_value[4]));// 应用范围
	ITKCALL(AOM_ask_value_string(form_tag,"jk8Projectname",&form_value[5]));// 项目名称


	bean.jk8PCBNO.assign(form_value[0]);// 产品型号
	bean.jk8Companylogo.assign(form_value[1]);// 产品型号
	bean.jk8MeasureType.assign(form_value[2]);// 识别号
	bean.jk8CommunicateMode.assign(form_value[3]);// 产品名称
	bean.jk8Application.assign(form_value[4]);// 基表厂家   5
	bean.jk8Projectname.assign(form_value[5]);// 项目名称

	//释放资源
	for(int i = 0 ;i <prop_count;i++){
		if(form_value[i]!=NULL){
			MEM_free(form_value[i]);
			form_value[i] = NULL;
		}
	}
}



/**
*
* 获取汇总表的属性 pcb
*
*/
void JK_get_summary_pcb_form_prop(tag_t form_tag,vector<JK_SUMMARY_PCB_STRUCT> &bean_vec,int * isOk){
	int prop_count = 6;
	int count[6],sum_count =0;
	char ** form_value[6];
	//POM_AM__set_application_bypass(true);
	*isOk = 1;
	printf("获取汇总表单【%d】的属性\n",form_tag);
	ITKCALL(AOM_ask_value_strings(form_tag,"jk8PCBNO",&count[0],&form_value[0]));//PCB编码
	sum_count = count[0];
	ITKCALL(AOM_ask_value_strings(form_tag,"jk8Companylogo",&count[1],&form_value[1]));// 公司标识
	ITKCALL(AOM_ask_value_strings(form_tag,"jk8MeasureType",&count[2],&form_value[2]));// 计量原理
	ITKCALL(AOM_ask_value_strings(form_tag,"jk8CommunicateMode",&count[3],&form_value[3]));// 通讯方式
	ITKCALL(AOM_ask_value_strings(form_tag,"jk8Application",&count[4],&form_value[4]));// 应用范围
	ITKCALL(AOM_ask_value_strings(form_tag,"jk8Projectname",&count[5],&form_value[5]));// 项目名称
	for(int i  = 0 ;i < (prop_count-1);i++){
		if(count[i] !=count[i+1]){
			*isOk = 0;
			printf("属性不正确=>\n");
		}
	}
	printf("222222222222222222=>\n");
	if( *isOk ==1){
		printf("3333333333333333=>\n");
		for(int i = 0 ;i <sum_count;i++ ){
			JK_SUMMARY_PCB_STRUCT bean ;
			bean.jk8PCBNO.assign(form_value[0][i]);//PCB编码
			bean.jk8Companylogo.assign(form_value[1][i]);// 公司标识
			bean.jk8MeasureType.assign(form_value[2][i]);// 计量原理
			bean.jk8CommunicateMode.assign(form_value[3][i]);// 通讯方式
			bean.jk8Application.assign(form_value[4][i]);// 应用范围   5
			bean.jk8Projectname.assign(form_value[5][i]);// 项目名称   6

			bean_vec.push_back(bean);
		}
	}
	printf("444444444444444=>\n");
	for(int i = 0 ;i < prop_count; i++){
		for(int j = 0;j < count[i];j++){
			if(form_value[i][j]!=NULL){
				MEM_free(form_value[i][j]);
				form_value[i][j] =NULL;
			}
		}
		if(form_value[i]!=NULL){
			MEM_free(form_value[i]);
			form_value[i] = NULL;
		}
	}
	//POM_AM__set_application_bypass(false);
	printf("555555555555=>\n");

}


/**
* pcb汇总表
*/
int JK_summary_pcb_form(EPM_rule_message_t msg)
{
	EPM_decision_t decision = EPM_go;
	int ifail = ITK_ok,arg_cnt = 0,i = 0,att_cnt = 0;
	tag_t task_tag = NULLTAG ,rootTask_tag = NULLTAG, *attachments =NULL,summary_form_tag = NULLTAG;
	char *arg = NULL,*argflag = NULL, *argvalue = NULL,type_class[WSO_object_type_size_c+1] ="\0",*form_value = NULL;
	vector<JK_SUMMARY_PCB_STRUCT> bean_vec;
	//用来获取汇总表的PUID
	vector<string> pref_vec;
	getPrefStrings("JK_PCBReg_uid",TC_preference_site, pref_vec);
	if(pref_vec.size() > 0){
		ITK__convert_uid_to_tag(pref_vec[0].c_str(),&summary_form_tag);
		if(summary_form_tag == NULLTAG){
			printf("PUID[%s]不能转换成对象\n",pref_vec[0].c_str());
			return EPM_nogo;
		}
		printf("找到了汇总表\n");
		int isOk = 1;
		JK_get_summary_pcb_form_prop(summary_form_tag,bean_vec,&isOk);
		if(isOk == 0){
			printf("PUID[%s]表单属性不正确\n",pref_vec[0].c_str());
			return EPM_nogo;
		}
	}else{
		printf("请配置首选项[JK_PCBReg_uid]\n");
		return EPM_nogo;
	}

	//获取当前触发的任务
	task_tag = msg.task;
	//获取根流程节点
	ITKCALL(ifail = EPM_ask_root_task(task_tag, &rootTask_tag));
	//获取目标引用对象
	ITKCALL(ifail = EPM_ask_attachments(rootTask_tag, EPM_target_attachment, &att_cnt, &attachments));
	//循环目标对象
	for(i = 0;i < att_cnt ; i++){
		//获取对象的类型
		/**********************************************
		*	对象类型：JK8PCBNOAppForm
		*	对象类型：JK8SpecPINOAppForm
		**********************************************/
		ITKCALL( WSOM_ask_object_type(attachments[i], type_class));
		printf("对象类型：%s \n",type_class);
		if(strcmp(type_class,"JK8PCBNOAppForm") ==0 //PCB编码申请表
			||strcmp(type_class,"JK8DerPCBNOAppForm") ==0 )//衍生PCB编码申请表
		{
			char *sbhstr;
			ITKCALL(AOM_ask_value_string(attachments[i],"jk8PCBNO",&sbhstr));// 识别号
			if(strcmp(sbhstr,"") ==0){
				printf("识别号为空,无法传递\n");
				return EPM_nogo;
			}
			JK_SUMMARY_PCB_STRUCT bean ;
			//获取单张表的属性
			JK_get_pcb_form_prop(attachments[i],bean,type_class);
			bean_vec.push_back(bean);
		}

	}

	POM_AM__set_application_bypass(true);
	JK_set_summary_pcb_form_prop(summary_form_tag,bean_vec);
	printf("------------传递汇总表2222-----------------");
	POM_AM__set_application_bypass(false);

	if(attachments!=NULL)
	{
		MEM_free(attachments);
		attachments = NULL;
	}
	printf("------------传递汇总表完成-----------------");
	return decision;
}












/**
* 
* 发送邮件
*
*/
int JK_send_email(EPM_action_message_t msg){
	int ifail = 0, att_cnt = 0 ,i =0,compare=0; 
	tag_t task_tag =NULLTAG , rootTask_tag =NULLTAG , *attachments =NULL;
	char wuliao[10240] = "\0", * itemName = NULL, * itemID = NULL ,* itemUser = NULL,*jk8SpecModel=NULL,*jk8TechModel=NULL; 
	//vector<string> emailNameVec ;
	printf( "\n ----------发送邮箱开始---------\n");
	//获取配置的发送到
	//getPrefStrings("JK_SendEmailName_Option",TC_preference_site,emailNameVec);

	//获得参数配置-SignName  邮箱1;邮箱2
	char arg1value[1024] = "",arg2value[1024] = "",arg3value[1024]="",arg4value[1024]="",
		signcounter_info[1024] = "", *value = NULL;
	char *argflag =NULL,*argvalue=NULL ,*arg = NULL;
	BOOL bypass = FALSE;
	int arg_cnt = 0;
	char emailName[1024] = "";
	char title[256] = "";


	arg_cnt = TC_number_of_arguments(msg.arguments);
	ECHO("参数个数为：%d\n",arg_cnt);
	POM_AM__set_application_bypass(true);
	if (arg_cnt > 0)
	{
		for (i=0;i<arg_cnt;i++)
		{
			arg = TC_next_argument(msg.arguments);
			ifail = ITK_ask_argument_named_value((const char*)arg, &argflag, &argvalue);
			printf("参数1：%s \n",argflag);
			printf("参数2：%s \n",argvalue);
			if (stricmp(argflag, "addr") == 0)
			{
				if(argvalue != NULL)
				{
					strcpy(emailName,argvalue);

					printf("参数邮箱：%s \n",emailName);



				}
			}else if(stricmp(argflag, "title") == 0){
				if(argvalue != NULL)
				{
					strcpy(title,argvalue);

					printf("标题：%s \n",title);



				}
			}



		}
		MEM_free(argflag);
		MEM_free(argvalue);
	}
	printf("222222222222222222222\n");
	//获取当前触发的任务
	task_tag = msg.task;


	//获取根流程节点
	ITKCALL(ifail = EPM_ask_root_task(task_tag, &rootTask_tag));

	//获取目标引用对象
	ITKCALL(ifail = EPM_ask_attachments(rootTask_tag, EPM_target_attachment, &att_cnt, &attachments));
	//循环目标对象

	strcat(wuliao,"{");
	for(i = 0;i < att_cnt ; i++){
		tag_t item_tag = NULLTAG;
		tag_t form_tag = NULLTAG;
		//判断是否是item
		if(checkIsTypeOrSubtype(attachments[i],"Item")){
			item_tag = attachments[i];
		}
		//判断是否是itemRevision
		if(checkIsTypeOrSubtype(attachments[i],"ItemRevision") ){
			//通过版本获取item
			ITEM_ask_item_of_rev(attachments[i],&item_tag);
			int formcount;
			tag_t * formTagS;
			AOM_ask_value_tags(attachments[i],"IMAN_master_form_rev",&formcount,&formTagS);
			if(formcount>0){
				form_tag = formTagS[0];
				printf("-----------------获得---------------------\n");
			}

		}
		if(stricmp(title, "") != 0){
			if(item_tag != NULLTAG){
				tag_t owning_user = NULLTAG;
				AOM_ask_value_string(item_tag,"item_id",&itemID);//获取对象的item_id
				AOM_ask_value_string(item_tag,"object_name",&itemName);//获取对象的名称
				AOM_ask_value_tag(item_tag,"owning_user",&owning_user);//获取对象的所有者
				ITKCALL(AOM_ask_value_string(owning_user,"user_name",&itemUser))
					strcat(wuliao,"[编码:");
				strcat(wuliao,itemID);
				strcat(wuliao," 名称:");
				strcat(wuliao,itemName);
				strcat(wuliao," 所有者:");
				strcat(wuliao,itemUser);
				strcat(wuliao,"]");
				//strcat(itemNames,itemName);
				if(itemID !=NULL){
					MEM_free(itemID);
					itemID =NULL;
				}

				if(itemName !=NULL){
					MEM_free(itemName);
					itemName =NULL;
				}
				if(itemUser !=NULL){
					MEM_free(itemUser);
					itemUser =NULL;
				}

			}



		}else{
			if(item_tag != NULLTAG&&form_tag!=NULLTAG){
				tag_t owning_user = NULLTAG;
				AOM_ask_value_string(item_tag,"item_id",&itemID);//获取对象的item_id
				AOM_ask_value_string(item_tag,"object_name",&itemName);//获取对象的名称
				AOM_ask_value_tag(item_tag,"owning_user",&owning_user);//获取对象的所有者
				ITKCALL(AOM_ask_value_string(owning_user,"user_name",&itemUser))
					AOM_ask_value_string(form_tag,"jk8SpecModel",&jk8SpecModel);//获取表单的规格型号
				AOM_ask_value_string(form_tag,"jk8TechModel",&jk8TechModel);//获取对象的技术型号


				//TODO 通过判断E-U8物料的名称是否以“E-8”开头来决定是否发邮件
				compare=strncmp(itemID,"E-8",3);
				if(compare == 0){
					ECHO("物料为E-U8物料不发送邮件");
					if(itemID !=NULL){
						MEM_free(itemID);
						itemID =NULL;
					}

					if(itemName !=NULL){
						MEM_free(itemName);
						itemName =NULL;
					}
					if(itemUser !=NULL){
						MEM_free(itemUser);
						itemUser =NULL;
					}
					if(jk8SpecModel !=NULL){
						MEM_free(jk8SpecModel);
						jk8SpecModel =NULL;
					}
					if(jk8TechModel !=NULL){
						MEM_free(jk8TechModel);
						jk8TechModel =NULL;
					}

					continue;
					//return 0;

				}


				strcat(wuliao,"[编码:");
				strcat(wuliao,itemID);
				strcat(wuliao," 名称:");
				strcat(wuliao,itemName);
				strcat(wuliao," 规格型号:");
				strcat(wuliao,jk8SpecModel);
				strcat(wuliao," 技术型号：:");
				strcat(wuliao,jk8TechModel);
				strcat(wuliao," 申请者:");
				strcat(wuliao,itemUser);
				strcat(wuliao,"]");
				//strcat(itemNames,itemName);
				if(itemID !=NULL){
					MEM_free(itemID);
					itemID =NULL;
				}

				if(itemName !=NULL){
					MEM_free(itemName);
					itemName =NULL;
				}
				if(itemUser !=NULL){
					MEM_free(itemUser);
					itemUser =NULL;
				}
				if(jk8SpecModel !=NULL){
					MEM_free(jk8SpecModel);
					jk8SpecModel =NULL;
				}
				if(jk8TechModel !=NULL){
					MEM_free(jk8TechModel);
					jk8TechModel =NULL;
				}
			}
		}


	}
	strcat(wuliao,"}");





	char cmd[20560] = "\0"; 
	char * tc_root_dir = getenv("tc_root");
	char  jar_file[2560] = "\0";
	if(stricmp(title, "") != 0){
		strcpy(jar_file, tc_root_dir);
		strcat(jar_file, "\\bin\\");
		strcat(jar_file, "JK_Email.jar");

		strcpy( cmd, "java -jar " );
		strcat(cmd , " \"");
		strcat(cmd ,jar_file);
		strcat( cmd, "\" \"" ); 
		strcat( cmd, title ); 
		//strcat( cmd, "\" \"" );
		//strcat( cmd, itemNames ); 
		/*if(emailNameVec.size() > 0){
		strcat( cmd, "\" \"" );
		strcat( cmd , emailNameVec[0].c_str());
		}*/
		//printf( "\n 首选项邮箱 %s\n",emailNameVec[0].c_str() );
		if(emailName!=NULL){
			strcat( cmd, "\" \"" );
			strcat( cmd , emailName);
		}
		strcat( cmd, "\" \"" ); 
		strcat( cmd, wuliao ); 
		strcat( cmd,"\"");
		printf( "\n%s\n",cmd );
	}else{
		strcpy(jar_file, tc_root_dir);
		strcat(jar_file, "\\bin\\");
		strcat(jar_file, "JK_SendEmail.jar");

		strcpy( cmd, "java -jar " );
		strcat(cmd , " \"");
		strcat(cmd ,jar_file);
		strcat( cmd, "\" \"" ); 
		strcat( cmd, wuliao ); 
		//strcat( cmd, "\" \"" );
		//strcat( cmd, itemNames ); 
		/*if(emailNameVec.size() > 0){
		strcat( cmd, "\" \"" );
		strcat( cmd , emailNameVec[0].c_str());
		}*/
		//printf( "\n 首选项邮箱 %s\n",emailNameVec[0].c_str() );
		if(emailName!=NULL){
			strcat( cmd, "\" \"" );
			strcat( cmd , emailName);
		}
		strcat( cmd,"\"");
	}
	printf( "\n%s\n",cmd );
	system( cmd );




	if(attachments !=NULL){
		MEM_free(attachments);
		attachments = NULL;
	}

	return 0;
}

/**
* 
* 发送邮件
*
*/
int JK_send_email_2(EPM_action_message_t msg){
	int ifail = 0, att_cnt = 0 ,i =0,compare=0; 
	tag_t task_tag =NULLTAG , rootTask_tag =NULLTAG ;
	char wuliao[10240] = "\0";// * itemName = NULL, * itemID = NULL ,* itemUser = NULL,*jk8SpecModel=NULL,*jk8TechModel=NULL; 
	//vector<string> emailNameVec ;
	printf( "\n ----------发送邮箱开始---------\n");
	//获取配置的发送到
	//getPrefStrings("JK_SendEmailName_Option",TC_preference_site,emailNameVec);

	//获得参数配置-SignName  邮箱1;邮箱2
	char arg1value[1024] = "",arg2value[1024] = "",arg3value[1024]="",arg4value[1024]="",
		signcounter_info[1024] = "", *value = NULL;
	char *argflag =NULL,*argvalue=NULL ,*arg = NULL;
	BOOL bypass = FALSE;
	int arg_cnt = 0;
	char emailName[1024] = "";
	char title[256] = "";
	char *my_job_name =NULL,*my_task_name=NULL,*template_name = NULL;
	tag_t temp_task_tag =NULLTAG;

	arg_cnt = TC_number_of_arguments(msg.arguments);
	ECHO("参数个数为：%d\n",arg_cnt);
	POM_AM__set_application_bypass(true);
	if (arg_cnt > 0)
	{
		for (i=0;i<arg_cnt;i++)
		{
			arg = TC_next_argument(msg.arguments);
			ifail = ITK_ask_argument_named_value((const char*)arg, &argflag, &argvalue);
			printf("参数1：%s \n",argflag);
			printf("参数2：%s \n",argvalue);
			if (stricmp(argflag, "addr") == 0)
			{
				if(argvalue != NULL)
				{
					strcpy(emailName,argvalue);
					printf("参数邮箱：%s \n",emailName);
				}
			}else if(stricmp(argflag, "title") == 0){
				if(argvalue != NULL)
				{
					strcpy(title,argvalue);
					printf("标题：%s \n",title);
				}
			}
		}
		MEM_free(argflag);
		MEM_free(argvalue);
	}
	printf("222222222222222222222\n");
	//获取当前触发的任务
	task_tag = msg.task;
	AOM_ask_value_string(task_tag,"job_name",&my_job_name);
	AOM_ask_value_string(task_tag,"object_name",&my_task_name);

	//获取根流程节点
	ITKCALL(ifail = EPM_ask_root_task(task_tag, &rootTask_tag));
	AOM_ask_value_tag(rootTask_tag,"task_template",&temp_task_tag);
	AOM_ask_value_string(temp_task_tag,"object_name",&template_name);


	//循环目标对象
	//	if(strcmp(template_name,"LCM_007")==0 
	//		|| strcmp(template_name,"LCM_009")==0
	//		|| strcmp(template_name,"LCM_016")==0
	//		|| strcmp(template_name,"LCM_025")==0
	//		|| strcmp(template_name,"LCM_026")==0
	//		|| strcmp(template_name,"LCM_027")==0){
	sprintf(wuliao,"%s(%s)",my_job_name,my_task_name);
	char cmd[20560] = "\0"; 
	char * tc_root_dir = getenv("tc_root");
	char  jar_file[2560] = "\0";
	strcpy(jar_file, tc_root_dir);
	strcat(jar_file, "\\bin\\");
	strcat(jar_file, "JK_SendMail20180102.jar");

	strcpy( cmd, "java -jar " );
	strcat(cmd , " \"");
	strcat(cmd ,jar_file);
	strcat( cmd, "\" \"" ); 
	strcat( cmd, title ); 
	strcat( cmd, "\" \"" );
	strcat( cmd , emailName);
	strcat( cmd, "\" \"" ); 
	strcat( cmd, wuliao ); 
	strcat( cmd,"\"");
	system( cmd );
	//	}

	if(my_job_name!=NULL){
		MEM_free(my_job_name);
		my_job_name =NULL;
	}
	if(my_task_name!=NULL){
		MEM_free(my_task_name);
		my_task_name =NULL;
	}
	if(template_name!=NULL){
		MEM_free(template_name);
		template_name =NULL;
	}


	return 0;
}


/**
*
* 设置权限
*
*/
void JK_set_owing_usre_and_group(tag_t obj_tag,tag_t user_tag,tag_t group_tag){
	ITKCALL(AOM_refresh(obj_tag,0));
	ITKCALL(AOM_lock(obj_tag));
	ITKCALL(AOM_set_ownership(obj_tag,user_tag,group_tag));
	ITKCALL(AOM_save(obj_tag));
	ITKCALL(AOM_unlock(obj_tag));

}

void removeReleaseStatusByName1(string statusName,tag_t rootTask,vector<tag_t> revVec,int num){
	tag_t release_status =NULLTAG;
	tag_t * attachments = NULL;
	int *att_types=NULL;
	int ifail = 0;
	att_types = (int*) MEM_alloc (sizeof(int) * ( revVec.size() ));
	attachments = (tag_t*) MEM_alloc (sizeof(tag_t) * ( revVec.size() ));
	//制定目标，数组转换
	for ( int indx = 0; indx < revVec.size(); indx++ )
	{
		att_types[indx] = EPM_target_attachment;//EPM_reference_attachment;
		attachments[indx] = revVec[indx];
	}
	//把所有的版本都添加到流程中
	printf("1ifail=>%d\n",ifail);
	ITKCALL(ifail=EPM_add_attachments(rootTask,revVec.size(),attachments,att_types));
	printf("2ifail=>%d\n",ifail);
	ITKCALL(ifail =CR_create_release_status(statusName.c_str(),&release_status));
	printf("4ifail=>%d\n",ifail);
	if(release_status!=NULLTAG){
		POM_AM__set_application_bypass(true);
		//可能有多次基线的情况，所以要删除所有的基线状态
		for(int n=0;n<num;n++)
		{
		ITKCALL(ifail =EPM_remove_status_from_targets(release_status,rootTask));//删除目标下对象的状态
			
		}
		printf("6ifail=>%d\n",ifail);
		POM_AM__set_application_bypass(false); 
	}
	if(att_types)										
	{											
		MEM_free(att_types);							
		att_types = NULL;								
	}
	if(attachments)										
	{											
		MEM_free(attachments);							
		attachments = NULL;								
	}

}

void removeRevFromTask1(tag_t rootTask,vector<tag_t> revVec){
	cout<<"enter  removeRevFromTask "<<endl;
	tag_t * attachments = NULL;
	
	attachments = (tag_t*) MEM_alloc (sizeof(tag_t) * ( revVec.size() ));
	//制定目标，数组转换
	for ( int indx = 0; indx < revVec.size(); indx++ )
	{
		attachments[indx] = revVec[indx];
	}
	cout<<"mark1--"<<endl;
	POM_AM__set_application_bypass(true);
	ITKCALL(EPM_remove_attachments(rootTask,revVec.size(),attachments));
	POM_AM__set_application_bypass(false);
		cout<<"mark2--"<<endl;
	if(attachments)										
	{											
		MEM_free(attachments);							
		attachments = NULL;								
	}
}
/**
* 
* 转移权限并且删除基线状态
*
*/
int JK_change_qx(EPM_action_message_t msg){
	int ifail = 0 , 
		i = 0 ,
		j = 0 , 
		att_cnt = 0,
		spec_cnt = 0,
		attach_cnt = 0;
	tag_t task_tag = NULLTAG , 
		root_task_tag = NULLTAG ,
		*attachments =NULL,
		owning_user =NULL,
		owning_group =NULL;
	int release_status_num=0;
			int release_status_num_temp=0;
	vector<tag_t> target_vec;
//		*specification_tags = NULL,
//		*attach_tags =NULL;
	POM_AM__set_application_bypass(true);
	task_tag = msg.task;
	ITKCALL(ifail = EPM_ask_root_task(task_tag, &root_task_tag));
	//获取目标引用对象
	ITKCALL(ifail = EPM_ask_attachments(root_task_tag, EPM_target_attachment, &att_cnt, &attachments));
	ITKCALL(ifail = AOM_ask_value_tag(root_task_tag,"owning_user",&owning_user));
	ITKCALL(ifail = AOM_ask_value_tag(root_task_tag,"owning_group",&owning_group));
	//循环目标对象
	for(i = 0 ;i < att_cnt ;i ++)
	{
		if(checkIsTypeOrSubtype(attachments[i],"ItemRevision")){
			

			tag_t *xgwj_tags = NULL;
			tag_t *release_status = NULL;
			
			//tag_t xgwj_tag = NULLTAG;
			int xgwj_count = 0;
			//TODO 先获取attachments[i]的类型，根据类型，再判断用哪个类型
			char *object_type=NULL;
			AOM_ask_value_string(attachments[i],"object_type",&object_type);
			cout<<"object_type-------------"<<object_type<<endl;
			if(strcmp(object_type,"TX2RJGGPSBRevision")==0)
			{
				ITKCALL(ifail = AOM_ask_value_tags(attachments[i],"TX2ReleaseFileRelation",&xgwj_count,&xgwj_tags));
			}else
			{
				ITKCALL(ifail = AOM_ask_value_tags(attachments[i],"JK8RelatedFiles",&xgwj_count,&xgwj_tags));
			}
			if(object_type!=NULL)
			{
				MEM_free(object_type);
				object_type=NULL;
			}

			for(int w = 0;w< xgwj_count;w++)
			{
				JK_set_owing_usre_and_group(xgwj_tags[w],owning_user,owning_group);
				//TODO 2018.5.16用户可能对对象进行了多次基线（比如分阶段和整个项目的），所以要删除所有的基线状态
				AOM_ask_value_tags(xgwj_tags[w],"release_status_list",&release_status_num_temp,&release_status);
				if(release_status_num<release_status_num_temp)
				{
					release_status_num=release_status_num_temp;
				}

				//TODO 2018.4.28删除"基线"状态
				target_vec.push_back(xgwj_tags[w]);
				//2018.4.18 去除转移对象下挂的数据集的权限
//				ITKCALL(AOM_ask_value_tags(xgwj_tags[w],"IMAN_specification",&spec_cnt,&specification_tags));
//				ITKCALL(AOM_ask_value_tags(xgwj_tags[w],"TC_Attaches",&attach_cnt,&attach_tags));
//				//给IMAN_specification关系下的文件赋予权限
//				for(j = 0;j < spec_cnt;j++){
//					JK_set_owing_usre_and_group(specification_tags[j],owning_user,owning_group);
//				}
//				//给TC_Attaches关系下的文件赋予权限
//				for(j = 0;j < attach_cnt;j++){
//					JK_set_owing_usre_and_group(attach_tags[j],owning_user,owning_group);
//				}
//
//				if(specification_tags !=NULL){
//					MEM_free(specification_tags);
//					specification_tags =NULL;
//				}
//
//				if(attach_tags !=NULL){
//					MEM_free(attach_tags);
//					attach_tags =NULL;
//				}
			}
			if(xgwj_tags == NULL){
				MEM_free(xgwj_tags);
				xgwj_tags =NULL;
			}
			if(release_status == NULL){
				MEM_free(release_status);
				release_status =NULL;
			}
		}
	}
	//TODO 2018.4.28
	POM_AM__set_application_bypass(true);
	//	removeReleaseStatus("删除状态流程",target_vec);
	cout<<"mark1"<<endl;
	removeReleaseStatusByName1("Baselined",root_task_tag,target_vec,release_status_num);
	cout<<"mark2"<<endl;
	removeRevFromTask1(root_task_tag,target_vec);
	cout<<"mark3"<<endl;
	POM_AM__set_application_bypass(false);
	cout<<"mark4"<<endl;

	if(attachments != NULL){
		MEM_free(attachments);
		attachments = NULL;
	}
	POM_AM__set_application_bypass(false);
	return 0;
}


/**
* 调用JAR汇总费用信息
*
*/
void summary_fee(char * excelPath, char * logPath){

	char cmd[1028] = "\0"; 
	char * tc_root_dir = getenv("tc_root");
	char  jar_file[256] = "\0";
	strcpy(jar_file, tc_root_dir);
	strcat(jar_file, "\\bin\\");
	strcat(jar_file, "JK_SummaryFee.jar");

	strcpy( cmd, "java -jar " );
	strcat(cmd , " \"");
	strcat(cmd ,jar_file);
	strcat( cmd, "\" \"" ); 
	strcat( cmd, excelPath ); 

	strcat( cmd, "\" \"" );
	strcat( cmd , logPath);

	strcat( cmd,"\"");
	printf( "\n%s\n",cmd );
	system( cmd );
}



int create_summary_fee_file(char *file_content,char *item_id, char **file_name)
{
	time_t now;
	struct tm *p;
	FILE *filePtr = NULL;

	char *temp_dir = getenv("TEMP");
	char local_path[MAX_PATH] = "";

	time(&now);
	p = localtime(&now);
	if(temp_dir[strlen(temp_dir) - 1] == '\\')
	{
		sprintf_s(local_path, "%s%s-%d-%d-%d-%d-%d-%d.dat", temp_dir,item_id,
			1900+p->tm_year,p->tm_mon+1 ,p->tm_mday+1 ,p->tm_hour,p->tm_min ,p->tm_sec);
	}
	else
	{
		sprintf_s(local_path, "%s\\%s-%d-%d-%d-%d-%d-%d.dat", temp_dir,item_id,
			1900+p->tm_year,p->tm_mon+1 ,p->tm_mday+1 ,p->tm_hour,p->tm_min ,p->tm_sec);
	}

	if((filePtr = fopen(local_path, "wt")) == NULL)
	{
		printf("Can not create the temp dat file!\n");
		return -1;
	}
	*file_name = (char *)MEM_alloc(sizeof(char)*512);
	strcpy((*file_name), local_path);

	fwrite(file_content, sizeof(char), strlen(file_content), filePtr);
	fclose(filePtr);

	return ITK_ok;
}


int summary_free_msexcel(tag_t dataset, char *dat_file, char *ext)
{
	tag_t spec_dataset_rev = NULLTAG,
		ref_object = NULLTAG;

	AE_reference_type_t reference_type;

	AE_ask_dataset_latest_rev(dataset, &spec_dataset_rev);

	char ref_name[WSO_name_size_c + 1] = "excel";
	AE_ask_dataset_named_ref(spec_dataset_rev, ref_name, &reference_type, &ref_object);
	if(reference_type == AE_PART_OF)
	{
		char pathname[SS_MAXPATHLEN] = "";
		IMF_ask_file_pathname(ref_object, SS_WNT_MACHINE, pathname);
		char origin_file_name[IMF_filename_size_c + 1] = "";
		IMF_ask_original_file_name(ref_object, origin_file_name);

		char new_ds_name[WSO_name_size_c + 1] = "";
		char *new_file_name = USER_new_file_name(new_ds_name, ref_name, ext, 0);
		char *temp_dir = getenv("temp");
		char temp_file[SS_MAXPATHLEN] = "";
		strcpy(temp_file, temp_dir);
		strcat(temp_file, "\\");
		strcat(temp_file, new_file_name);

		IMF_export_file(ref_object, temp_file);


		int   iCnt;
		char *user_lib_env,pTempStr[500];
		char local_path[MAX_PATH] = "";
		/*char cmd[256] = "";

		strcpy( cmd, "SubstMacros-MSExcel.wsf" );
		strcat( cmd, " \"" ); 
		strcat( cmd, temp_file ); 
		strcat( cmd, "\" \"" );
		strcat( cmd, dat_file ); 
		strcat( cmd, "\"" );
		printf( "\n%s\n",cmd );
		system( cmd );
		*/
		summary_fee(temp_file,dat_file);

		//strcpy(user_lib_env, local_path);


		tag_t new_file_tag = NULLTAG;
		IMF_file_t file_descriptor;	
		IMF_import_file(temp_file, new_file_name, SS_BINARY, &new_file_tag, &file_descriptor);
		IMF_set_original_file_name(new_file_tag, origin_file_name);
		IMF_close_file(file_descriptor);
		AOM_save(new_file_tag);
		AOM_unlock(new_file_tag);

		AOM_lock(spec_dataset_rev);
		//CALL(AOM_load (dataset));
		//CALL(AOM_load(spec_dataset_rev));
		AE_remove_dataset_named_ref_by_tag(spec_dataset_rev, ref_name, ref_object);
		AE_add_dataset_named_ref(spec_dataset_rev, ref_name, AE_PART_OF, new_file_tag);
		AOM_save(spec_dataset_rev);
		AOM_unlock(spec_dataset_rev);
	}
	return ITK_ok;
}


/**
*  汇总物料信息
*
*
*
*/
int JK_matereial_summary_fee(EPM_action_message_t msg){
	int ifail =0,
		att_cnt = 0,
		excelCnt = 0;
	tag_t task_tag = NULLTAG,
		root_task_tag = NULLTAG,
		* attachments =NULL,
		* excelTags =NULL;
	char *dataset_type = NULL;
	task_tag = msg.task;
	POM_AM__set_application_bypass(true);
	ITKCALL(ifail = EPM_ask_root_task(task_tag, &root_task_tag));
	//获取目标引用对象
	ITKCALL(ifail = EPM_ask_attachments(root_task_tag, EPM_target_attachment, &att_cnt, &attachments));

	for(int i = 0;i < att_cnt;i++){
		tag_t taskTag = attachments[i];
		if(checkIsTypeOrSubtype(taskTag,"JK8BOMCostEstmRevision")){
			ITKCALL(ifail = AOM_ask_value_tags(taskTag,"IMAN_specification",&excelCnt,&excelTags)); 

			for(int j = 0 ;j < excelCnt;j++){
				AOM_ask_value_string(excelTags[j],"object_type",&dataset_type);
				char *data_file = NULL;
				create_summary_fee_file("","费用汇总日志", &data_file);
				if( data_file == NULL )
				{
					continue;
				}
				ECHO("\n 创建文本文件%s",data_file);


				if(strcmp(dataset_type, "MSExcel") ==0 )
				{
					summary_free_msexcel(excelTags[j],data_file,"xls");
				}
				else if(strcmp(dataset_type, "MSExcelX") ==0)
				{
					summary_free_msexcel(excelTags[j],data_file,"xlsx");
				}

				if(dataset_type!=NULL){
					MEM_free(dataset_type);
					dataset_type = NULL;
				}
			}

			if(excelTags!=NULL)
			{
				MEM_free(excelTags);
				excelTags =NULL;
			}
		}

	}
	if(attachments!= NULL){
		MEM_free(attachments);
		attachments = NULL;
	}

	POM_AM__set_application_bypass(false);
	return 0;
}



/*******************************************************
*
* 获取子TOP Bomline属性的属性
*
********************************************************/
void JK_get_bomline_props(tag_t top_line_tag,char errs[10240],char cherrs[10240])
{
	int ifail = 0 ,
		i = 0,
		status_count = 0 ,
		c_line_count = 0 ,
		rev_form_cnt = 0 ,
		isra_cou=0,
		isra_cou_form=0;
	tag_t rev_tag =NULLTAG,
		item_tag = NULLTAG,
		bom_window_tag = NULLTAG,
		*c_line_tags = NULL,
		*rev_form_tags = NULL,
		*isra_tags = NULL,
		*isra_tags_form = NULL;

	char item_id[ITEM_id_size_c + 1] = "\0",
		rev_id[ITEM_id_size_c + 1]  = "\0",
		*user_name = NULL,
		*jk8_mjshl = NULL,
		create_date_str[32] = "\0",
		person_name[SA_person_name_size_c + 1]  = "\0";

	//因为生产代码权限控制的缘故，需要在此处开旁路
	POM_AM__set_application_bypass(true);

	printf("1111");
	ITKCALL(AOM_ask_value_tag(top_line_tag,"bl_line_object",&rev_tag));//获取BOMLINE关联的版本
	ITKCALL(ITEM_ask_item_of_rev(rev_tag,&item_tag));
	ITKCALL(ITEM_ask_id(item_tag,item_id));//物料编码

	printf("判断是否发布%s\n",item_id);
	ITKCALL(AOM_ask_value_tags(rev_tag,"release_status_list",&isra_cou,&isra_tags));//判断是否发布
	if(isra_cou==0){
		printf("%s未发布\n",item_id);
		strcat(errs,"[");
		strcat(errs,item_id);
		strcat(errs,"]");
	}else{
		//20200427如果是整机才检查，组件就不检查
		//20200429如果是开发状态，就不做检查

		ITKCALL(ITEM_ask_rev_id(rev_tag,rev_id));//获取版本号
		//20200318
		char* object_type_release=NULL;
		logical develop=false;
		for (int f=0;f<isra_cou;f++){
			AOM_ask_value_string(isra_tags[f],"object_name",&object_type_release);
			if(strcmp(object_type_release,"JK8Develop")==0 || strcmp(object_type_release,"jk8Develop")==0){
				
				develop=true;
				break;				
			}
		}
		if(develop==false)
		{
			for (int f=0;f<isra_cou;f++){
				AOM_ask_value_string(isra_tags[f],"object_name",&object_type_release);
				if(strcmp(object_type_release,"jk8Checking")==0 || strcmp(object_type_release,"JK8Checking")==0){

					printf("%s发布状态\n",item_id);
					strcat(cherrs,"[");
					strcat(cherrs,item_id);
					strcat(cherrs,"]");
					break;				
				}
			}
		}

		
		if(object_type_release!=NULL)
		{
			MEM_free(object_type_release);
			object_type_release=NULL;
		}
		//ITKCALL(AOM_ask_value_tags(rev_tag,"IMAN_master_form_rev",&rev_form_cnt,&rev_form_tags)); //不判断表单
		//if(rev_form_cnt>0){
		//	ITKCALL(AOM_ask_value_tags(rev_form_tags[0],"release_status_list",&isra_cou_form,&isra_tags_form));//判断表单是否发布
		//	if(isra_cou_form==0){
		//		printf("%s表单未发布\n",item_id);
		//		strcat(errs,"[");
		//		strcat(errs,item_id);
		//		strcat(errs,"]表单");
		//	}
		//	if(isra_tags_form!=NULL){
		//		MEM_free(isra_tags_form);
		//		isra_tags_form =NULL;
		//	}
		//}
		//if(rev_form_tags!=NULL){
		//	MEM_free(rev_form_tags);
		//	rev_form_tags =NULL;
		//}
	}
	ITKCALL(BOM_line_ask_all_child_lines(top_line_tag,&c_line_count,&c_line_tags));
	if(c_line_count == 0){
		printf("没有BOM结构");
		POM_AM__set_application_bypass(false);
		return;
	}
	
	for (int i = 0; i < c_line_count; i++)
	{
		cout<<"2----"<<endl;
		JK_get_bomline_props( c_line_tags[i],errs,cherrs);
	}
	POM_AM__set_application_bypass(false);
	if(c_line_tags!=NULL){
		MEM_free(c_line_tags);
		c_line_tags =NULL;
	}


}



int JK_Bom_is_release(EPM_rule_message_t msg){

	printf("===================================\n");
	printf("根据BOM子件是否发布,限制流程发起 开始\n");
	printf("===================================\n");

	//参数定义
	int ifail = EPM_go , 
		arg_cnt = 0 , 
		i = 0 ,
		att_cnt = 0,
		c_line_count=0;

	tag_t task_tag  = NULLTAG , 
		root_task_tag =NULLTAG , 
		*attachments = NULL,
		bom_window_tag = NULLTAG,
		top_line_tag=NULLTAG,
		*c_line_tags=NULL,
		rev_tag=NULL,
		item_tag=NULL;

	char * argflag = NULL ,
		*argvalue =NULL ,

		*arg = NULL , 
		arg_value[1024] = "\0",
	material_type[1024] = "\0",
		type_class[WSO_object_type_size_c+1] ="\0",
		all_errs[10240]="\0",
		check_errs[10240]="\0",  // 20200318
		item_id[ITEM_id_size_c + 1] = "\0";

	logical is_debug = false;

	//记录错误信息
	map<string,int> errMap;

	vector<string> type_vec;


	//获取handler参数的个数
	arg_cnt = TC_number_of_arguments(msg.arguments);
	ECHO("参数个数为：%d\n",arg_cnt);
	if (arg_cnt > 0)
	{
		for (i=0;i<arg_cnt;i++)
		{
			
			//获取下一个参数（从0开始）
			arg = TC_next_argument(msg.arguments);
			//获取参数的名称和值
			ITK_ask_argument_named_value((const char*)arg, &argflag, &argvalue);
			//需要检查哪些对象的类型
			if (stricmp(argflag, "include_type") == 0)
			{
				if(argvalue != NULL)
				{
					strcpy(arg_value,argvalue);
					Split(arg_value,"/",type_vec);
				}else{

					string key_id;
					key_id.assign("缺少include_type参数");
					errMap.insert(pair<string,int>(key_id,HANDLER_ARGUMENT_ERROR));
				}
			}
			if (stricmp(argflag, "material_type") == 0)
			{
				if(argvalue != NULL)
				{
					strcpy(material_type,argvalue);
				}
			}
		}
		MEM_free(argflag);
		MEM_free(argvalue);
	}

	//获取目标对象
	task_tag = msg.task;
	if(task_tag == NULLTAG)
	{

		return EPM_nogo;
	}
	EPM_ask_root_task(task_tag, &root_task_tag);
	EPM_ask_attachments(root_task_tag, EPM_target_attachment, &att_cnt, &attachments);
	for(i = 0 ;i < att_cnt;i++){
		char errs[1024]="\0";
		char cherrs[1024]="\0";  //20200318
		tag_t target_tag = attachments[i];
		//获取对象的类型 PSBOMViewRevision
		ITKCALL( WSOM_ask_object_type(target_tag, type_class));
		ECHO("对象类型%s\n",type_class);
		string type_str ;
		type_str.assign(type_class);
		vector<string>::iterator it;
		it = find(type_vec.begin(),type_vec.end(),type_str);
		if(it == type_vec.end()){
			ECHO("此类型不包含在include_type中 跳过\n");
			continue;
		}
		POM_AM__set_application_bypass(true);
		ITKCALL(BOM_create_window(&bom_window_tag));//创建window视图
		ITKCALL(BOM_set_window_top_line_bvr(bom_window_tag,target_tag,&top_line_tag));//获取顶层bomline
		ITKCALL(BOM_line_ask_all_child_lines(top_line_tag,&c_line_count,&c_line_tags));
		ITKCALL(AOM_ask_value_tag(top_line_tag,"bl_line_object",&rev_tag));//获取BOMLINE关联的版本
		ITKCALL(ITEM_ask_item_of_rev(rev_tag,&item_tag));
		ITKCALL(ITEM_ask_id(item_tag,item_id));//物料编码
		if(c_line_count == 0){
			printf("没有BOM结构\n");
		}else{
			printf("有BOM结构 数量%d\n",c_line_count);
			for (int t = 0; t < c_line_count; t++)
			{
				printf("开始遍历对象%s\n",item_id);
				POM_AM__set_application_bypass(true);
				cout<<"1----"<<endl;
				JK_get_bomline_props(c_line_tags[t],errs,cherrs);   //20200318
				POM_AM__set_application_bypass(false);
			}

		}
		if(strcmp(errs,"\0")!=0){
			strcat(all_errs,"存在对象{");
			strcat(all_errs,item_id);
			strcat(all_errs,"}下关联子件");
			strcat(all_errs,errs);
			strcat(all_errs,"未发布!\n");
		}
		//20200318
		if(strcmp(cherrs,"\0")!=0){
			strcat(check_errs,"存在对象{");
			strcat(check_errs,item_id);
			strcat(check_errs,"}下关联子件");
			strcat(check_errs,cherrs);
			strcat(check_errs,"处于验证状态!\n");
		}
		if(c_line_tags!=NULL)
		{
			MEM_free(c_line_tags);
			c_line_tags =NULL;
		}
		ITKCALL(BOM_close_window(bom_window_tag));
	}


	if(strcmp(all_errs,"\0")!=0){
		ifail=EPM_nogo;
		printf("错误:%s\n",all_errs);
		EMH_store_error_s1(EMH_severity_information,278701,all_errs);//错误弹窗
	}
	//如果是整机，任何子阶有验证状态的物料 则整机的流程编制无法完成
	if(strcmp(material_type,"1")==0)
	{
		if(strcmp(check_errs,"\0")!=0){
			ifail=EPM_nogo;
			printf("错误:%s\n",check_errs);
			EMH_store_error_s1(EMH_severity_information,278701,check_errs);//错误弹窗
		}
	}
	

	if(attachments!=NULL)
	{
		MEM_free(attachments);
		attachments =NULL;
	}


	return ifail;


}

