#define _CRT_SECURE_NO_WARNINGS
#include "epm_handler_common.h"
#include <vector>
#include <string>
#include "ocilib.h"
#include <map>
#include <string>
#include <iostream>
#include <tccore/item.h>
#include <curl/curl.h>
#include <regex>
#include <fstream>
#include <chrono>
#include <ctime>
#include <memory>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <exception> 
#define ITK_err 919821
using namespace std;

int RB_testquery_ID(EPM_action_message_t msg)
{
	int ifail = ITK_ok;
	int  attachments_num = 0;
	tag_t  rootTask = NULLTAG, * attachments = NULLTAG;
	//获取任务对象
	EPM_ask_root_task(msg.task, &rootTask);
	//获取任务目标对象
	EPM_ask_attachments(rootTask, EPM_target_attachment, &attachments_num, &attachments);
	//获取参数
	char* url = NULL, * name = NULL, * password = NULL;
	char* argflag = NULL, * argvalue = NULL, * arg = NULL;
	int arg_cnt = TC_number_of_arguments(msg.arguments);

	tag_t item;
	//根据id查找零组件
	ITKCALL(ITEM_find_item("JCSY-000011", &item));
	if (item == NULL) {
		// 调用查询构建器，第一步获取查询构建器对象
		tag_t query_tag1 = NULLTAG;
		ITKCALL(QRY_find2("零组件...", &query_tag1));
		if (query_tag1 == NULLTAG)
		{
			printf("没找到 [%s]查询构建器！\n", "零组件...");
			return 0;
		}
		int querynum = 0;
		tag_t* queryresults = NULLTAG;
		char* quvalue[1];
		char* querykey[1];
		quvalue[0] = "零组件 ID";
		querykey[0] = "JCSY-000011";
		ITKCALL(QRY_execute(query_tag1, 1, quvalue, querykey, &querynum, &queryresults));
		if (querynum > 0) {
			item = queryresults[0];
		}
	}
	if (item!=NULL) {
		char* name;
		AOM_ask_value_string(item, "object_string", &name);
		printf("找到零组件了%s\n", name);
	}
	else {
		printf("没有找到零组件\n");
	}
}

