#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>
#include <ae/datasettype.h>
// #include "hx_custom.h"
#include "tc_log.h"
// #include "jk_custom.h"
#include "chint_Handler.h"
#include "tc_util.h"
#include <regex>
#include <ics/ics.h>
#include "ado.h"
#include "ocilib.h"
//#include ""
#include "CRUL_server_call_httpserver.h"
using namespace std;

//http://localhost:8080/api/open/task/modStatus/{{taskUid}}
int chint_updateToPi(EPM_action_message_t msg) {
	int ifail = ITK_ok;

	//流程节点相关
	tag_t root_task = NULLTAG, *sub_tasks = NULL, current_task = NULLTAG, type_tag = NULLTAG;
	int sub_task_count = 0,occur_of_counts = 0;
	tag_t* taskAttches = NULLTAG;
	tag_t cur_task = NULLTAG;

	current_task = msg.task;
	ECHO("=========================================================\n");
	ECHO("chint_updateToPi 开始执行\n");
	ECHO("=========================================================\n");

	EPM_ask_root_task(msg.task, &root_task);
	EPM_ask_sub_tasks(root_task, &sub_task_count, &sub_tasks);
	EPM_ask_attachments(root_task, EPM_target_attachment, &occur_of_counts, &taskAttches);
	int url_num;
	char **url_vals;
	PREF_ask_char_values("CHINT_PIUrl", &url_num, &url_vals);
	string url = "";
	if (url_num > 0) {
		url.append(url_vals[0]).append("/api/open/task/modStatus/");
	}
	for (int count = 0; count < occur_of_counts; count++)
	{
		//ITKCALL(TCTYPE_ask_object_type(taskAttches[count], &type_tag));
		char *type,*piUid;
		tag_t taskTag = taskAttches[count];
		AOM_ask_value_string(taskTag,"object_type",&type);
		if (strcmp(type, "ZT2_YPTask") == 0) {
			AOM_ask_value_string(taskTag,"zt2_YPUID",&piUid);
			url.append(piUid);
			printf("url===>%s\n", url.c_str());
			string result = callHttpGet(url);
		}
	}

	return ifail;
}


