You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
117 lines
3.9 KiB
117 lines
3.9 KiB
#include"kutil.h"
|
|
#include "ado.h"
|
|
#define debug true
|
|
#define ITK_err 919012
|
|
|
|
int LY_AutoAssign(EPM_action_message_t msg) {
|
|
int ifail = ITK_ok, arg_cnt = 0, att_cnt = 0, task_count = 0;
|
|
char* arg = NULL, * argflag = NULL, * argvalue = NULL;
|
|
tag_t* attachments = NULLTAG, task_tag = NULLTAG, rootTask_tag = NULLTAG, * task_tags = NULLTAG;
|
|
vector<string> values;
|
|
set<string> sh_set;
|
|
getPrefStrings("LY_PRType_Person_Mapping", TC_preference_site, values);
|
|
//拿到当前节点
|
|
task_tag = msg.task;
|
|
if (task_tag == NULLTAG) {
|
|
goto end;
|
|
}
|
|
ITKCALL(ifail = EPM_ask_root_task(task_tag, &rootTask_tag));
|
|
//获取目标下所有对象
|
|
ITKCALL(ifail = EPM_ask_attachments(rootTask_tag, EPM_target_attachment, &att_cnt, &attachments));
|
|
if (att_cnt == 0) {
|
|
goto end;
|
|
}
|
|
|
|
for (int i = 0; i < att_cnt; i++)
|
|
{
|
|
char* object_type = NULL;
|
|
AOM_ask_value_string(attachments[i], "object_type", &object_type);
|
|
if (strcmp("LY6_JHPRRevision", object_type) == 0 || strcmp("LY6_LYPRRevision", object_type) == 0) {
|
|
char* problem_type = NULL;
|
|
char* company_value = NULL;
|
|
AOM_ask_value_string(attachments[i], "ly6_company", &company_value);
|
|
AOM_ask_value_string(attachments[i], "ly6_problemType", &problem_type);
|
|
/*for each (string problem in values)
|
|
{
|
|
vector<string> split;
|
|
Split(problem.c_str(), "=", split);
|
|
if (split.size() == 2 && strcmp(split[0].c_str(),problem_type) == 0) {
|
|
if (sh_set.insert(split[1]).second == false) {
|
|
continue;
|
|
}
|
|
}
|
|
}*/
|
|
for each (string company in values)
|
|
{
|
|
vector<string> split;
|
|
vector<string> split2;
|
|
Split(company.c_str(), ":", split);
|
|
if (split[0].empty()) {
|
|
EMH_store_error_s2(EMH_severity_error, ITK_err, "首选项配置错误", company.c_str());
|
|
goto end;
|
|
}
|
|
//公司属性相同
|
|
if (split.size() == 2 && strcmp(split[0].c_str(), company_value) == 0) {
|
|
Split(split[1].c_str(), "=", split2);
|
|
if (split2.size() == 2) {
|
|
//问题类型为空
|
|
if (split2[0].empty()) {
|
|
if (sh_set.insert(split2[1]).second == false) {
|
|
continue;
|
|
}
|
|
}
|
|
//问题类型不为空,且相同
|
|
else if (strcmp(split2[0].c_str(), problem_type) == 0) {
|
|
if (sh_set.insert(split2[1]).second == false) {
|
|
continue;
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
char* task_type = NULL;
|
|
WSOM_ask_object_type2(task_tag, &task_type);
|
|
printf("当前节点的类型为:%s\n", task_type);
|
|
if (strcmp("EPMReviewTask", task_type) == 0 || strcmp("EPMAcknowledgeTask", task_type) == 0) {
|
|
char* object_name = NULL;
|
|
int mem_cnt = 0, signoff_cnt = 0;
|
|
tag_t user_tag = NULLTAG, login_group = NULLTAG, * members = NULLTAG, * signoffs = NULLTAG, select_signoff_tag = NULLTAG;
|
|
AOM_ask_value_string(task_tag, "object_name", &object_name);//对象名称
|
|
EPM_ask_sub_task(task_tag, "select-signoff-team", &select_signoff_tag);
|
|
printf("当前节点的名称为:%s\n", object_name);
|
|
|
|
int attachments_num = 0, * attach_type; tag_t* attachmentTags;
|
|
EPM_ask_all_attachments(select_signoff_tag, &attachments_num, &attachmentTags, &attach_type);
|
|
if (attachments_num > 0) {
|
|
goto end;
|
|
}
|
|
|
|
for (set<string>::iterator it = sh_set.begin(); it != sh_set.end(); it++) {
|
|
printf("添加:%s\n", it->c_str());
|
|
ITKCALL(SA_find_user2(it->c_str(), &user_tag));
|
|
ITKCALL(SA_ask_user_login_group(user_tag, &login_group));
|
|
ITKCALL(SA_find_groupmembers(user_tag, login_group, &mem_cnt, &members));
|
|
ITKCALL(EPM_create_adhoc_signoff(select_signoff_tag, members[0], &signoff_cnt, &signoffs));
|
|
}
|
|
if (sh_set.size() > 0) {
|
|
ITKCALL(EPM_set_adhoc_signoff_selection_done(select_signoff_tag, true));
|
|
}
|
|
DOFREE(object_name);
|
|
DOFREE(members);
|
|
DOFREE(signoffs);
|
|
}
|
|
if (strcmp("EPMDoTask", task_type) == 0 || strcmp("EPMConditionTask", task_type) == 0) {
|
|
tag_t user_tag = NULLTAG;
|
|
for (set<string>::iterator it = sh_set.begin(); it != sh_set.end(); it++) {
|
|
ITKCALL(SA_find_user2(it->c_str(), &user_tag));
|
|
ITKCALL(EPM_assign_responsible_party(task_tag, user_tag));//设置编制节点的责任方
|
|
}
|
|
}
|
|
end:
|
|
DOFREE(attachments);
|
|
return ifail;
|
|
} |