|
|
#include "util.h"
|
|
|
#include "test.h"
|
|
|
|
|
|
void sendMessage(string user_id,string messag,string method);
|
|
|
int ChintSendMessage(tag_t task)
|
|
|
{
|
|
|
LINFO<<"ChintSendMessage发送文本信息";
|
|
|
char *task_type,*user_id,*job_name,*task_userID;
|
|
|
ITKCALL(AOM_ask_value_string(task,"task_type",&task_type));
|
|
|
//printf("task_type:%s\r\n",task_type);
|
|
|
LINFO<<"节点task_type["<<task_type<<"]";
|
|
|
POM_get_user_id(&user_id);
|
|
|
LINFO<<"当前登录用户ID["<<user_id<<"]";
|
|
|
tag_t user;
|
|
|
char *sub_task_object_type;
|
|
|
ITKCALL( AOM_ask_value_string( task , "object_type" , &sub_task_object_type ));
|
|
|
LINFO<<"节点Object_type["<<sub_task_object_type<<"]";
|
|
|
ITKCALL(AOM_ask_value_string(task,"object_name",&job_name));
|
|
|
tag_t workflow;
|
|
|
|
|
|
LINFO<<"节点名称:"<<job_name;
|
|
|
stringstream id;
|
|
|
if(strcmp(task_type,"EPMDoTask")==0)
|
|
|
{
|
|
|
LINFO<<"DO节点";
|
|
|
tag_t user;
|
|
|
ITKCALL(EPM_ask_responsible_party(task,&user));
|
|
|
ITKCALL(EPM_ask_parent_task(task,&workflow));
|
|
|
if(user==NULL)
|
|
|
{
|
|
|
ITKCALL(AOM_ask_value_string(workflow,"object_name",&job_name));
|
|
|
LINFO<<"节点["<<job_name<<"]未指派责任人";
|
|
|
return 0;
|
|
|
}
|
|
|
ITKCALL(POM_ask_user_id(user,&task_userID));
|
|
|
|
|
|
id<<task_userID;
|
|
|
}else if(( strstr( sub_task_object_type , "ReviewTask" ) != NULL )||( strstr( sub_task_object_type , "AcknowledgeTask" )!= NULL))
|
|
|
{
|
|
|
LINFO<<"审核/认可节点";
|
|
|
EPM_ask_parent_task(task,&workflow);
|
|
|
tag_t tmp_select_signoff_task;
|
|
|
ITKCALL( EPM_ask_sub_task( task , EPM_select_signoff_team_task , &tmp_select_signoff_task ));
|
|
|
int user_count=0;
|
|
|
tag_t user,*signoffs;
|
|
|
ITKCALL(EPM_ask_task_reviewers_users(tmp_select_signoff_task,&user_count,&signoffs));
|
|
|
if(user_count==0)
|
|
|
{
|
|
|
LINFO<<"当前节点未指派用户->"<<job_name;
|
|
|
return 0;
|
|
|
}else if(user_count>0)
|
|
|
{
|
|
|
id.str("");
|
|
|
for(int i=0;i<user_count;i++)
|
|
|
{
|
|
|
if(signoffs[i]==NULL)
|
|
|
{
|
|
|
printf("为空\r\n");
|
|
|
continue;
|
|
|
}
|
|
|
ITKCALL(POM_ask_user_id(signoffs[i],&task_userID));
|
|
|
id<<task_userID;
|
|
|
if(i!=(user_count-1))
|
|
|
{
|
|
|
id<<";";
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}else if(strcmp(task_type,"EPMPerformSignoffTask")==0 || strcmp(task_type,"EPMSelectSignoffTask")==0)
|
|
|
{
|
|
|
tag_t parent_task;
|
|
|
ITKCALL(EPM_ask_parent_task(task,&parent_task));
|
|
|
ITKCALL(AOM_ask_value_string(parent_task,"object_name",&job_name));
|
|
|
EPM_ask_parent_task(parent_task,&workflow);
|
|
|
LINFO<<"父节点名称:"<<job_name;
|
|
|
LINFO<<"签审节点";
|
|
|
int user_count=0;
|
|
|
tag_t user,*signoffs;
|
|
|
ITKCALL(EPM_ask_task_reviewers_users(task,&user_count,&signoffs));
|
|
|
if(user_count==0)
|
|
|
{
|
|
|
LINFO<<"当前节点未指派用户->"<<job_name;
|
|
|
return 0;
|
|
|
}else if(user_count>0)
|
|
|
{
|
|
|
id.str("");
|
|
|
for(int i=0;i<user_count;i++)
|
|
|
{
|
|
|
ITKCALL(POM_ask_user_id(signoffs[i],&task_userID));
|
|
|
id<<task_userID;
|
|
|
if(i!=(user_count-1))
|
|
|
{
|
|
|
id<<";";
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|
|
|
LINFO<<"用户ID:"<<id.str();
|
|
|
EPM_ask_root_task(task,&workflow);
|
|
|
ITKCALL(AOM_ask_value_string(workflow,"job_name",&job_name));
|
|
|
printf("name:%s\r\n",job_name);
|
|
|
string name = job_name;
|
|
|
printf("name1:%s\r\n",name.c_str());
|
|
|
if(name.find("\\")!=string::npos)
|
|
|
{
|
|
|
name=name.replace(name.find("\\"),1,"-");
|
|
|
}
|
|
|
if(name.find("/")!=string::npos)
|
|
|
{
|
|
|
name=name.replace(name.find("/"),1,"-");
|
|
|
}
|
|
|
printf("name3:%s\r\n",name);
|
|
|
|
|
|
|
|
|
//printf("即将要发送的用户ID:%s\r\n",user_id);
|
|
|
string mess = "您有一个待处理的工作流程(";
|
|
|
mess.append(name);
|
|
|
mess.append("),请尽快登陆PLM系统处理。");
|
|
|
sendMessage(id.str().c_str(),mess,"ChintSendMessage");
|
|
|
//sendMessage("wblicj",mess,"ChintSendMessage");
|
|
|
LINFO<<"ChintSendMessage文本信息发送结束";
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
void sendMessage(string user_id,string messag,string method)
|
|
|
{
|
|
|
char cmd[256] = "";
|
|
|
string filesStr;
|
|
|
filesStr.append("\"");
|
|
|
filesStr.append(messag);
|
|
|
filesStr.append("\"");
|
|
|
char * tc_root_dir = getenv("TC_ROOT");
|
|
|
string execStr;
|
|
|
execStr.append("cmd.exe /c java -jar ");
|
|
|
execStr.append(tc_root_dir);
|
|
|
execStr.append("\\bin\\DesignTask.jar ");
|
|
|
execStr.append(method);
|
|
|
execStr.append(" ");
|
|
|
execStr.append(user_id);
|
|
|
execStr.append(" ");
|
|
|
execStr.append(filesStr);
|
|
|
LINFO<<"调用jar="<<execStr.c_str();
|
|
|
printf("\n%s\n", execStr.c_str());
|
|
|
system(execStr.c_str());
|
|
|
|
|
|
} |