|
|
#include "epm_handler_common.h"
|
|
|
|
|
|
int ML_ChideIsEnabled(EPM_action_message_t msg)
|
|
|
{
|
|
|
printf("=========================物料启用判断 Start===================\n");
|
|
|
auto startTime = std::chrono::high_resolution_clock::now();
|
|
|
int ifail = ITK_ok;
|
|
|
int attachments_num = 0;
|
|
|
tag_t rootTask = NULLTAG, *attachments = NULLTAG, user_tag = NULLTAG;
|
|
|
//获取任务对象
|
|
|
EPM_ask_root_task(msg.task, &rootTask);
|
|
|
//获取任务目标对象
|
|
|
EPM_ask_attachments(rootTask, EPM_target_attachment, &attachments_num, &attachments);
|
|
|
|
|
|
//获取参数
|
|
|
char *argflag = NULL, *argvalue = NULL, *arg = NULL, *user_name = NULL;
|
|
|
char item_type[1024] = "", referenced[1024] = "", check_item_type[1024] = "";
|
|
|
int arg_cnt = TC_number_of_arguments(msg.arguments);
|
|
|
printf("参数个数为:%d\n", arg_cnt);
|
|
|
ITKCALL(ifail = POM_get_user(&user_name, &user_tag));
|
|
|
if (arg_cnt > 0)
|
|
|
{
|
|
|
for (int i = 0; i < arg_cnt; i++)
|
|
|
{
|
|
|
//获取下一个参数(从0开始)
|
|
|
arg = TC_next_argument(msg.arguments);
|
|
|
//获取参数的名称和值
|
|
|
ifail = ITK_ask_argument_named_value((const char*)arg, &argflag, &argvalue);
|
|
|
if (stricmp(argflag, "itemType") == 0)
|
|
|
{
|
|
|
if (argvalue != NULL)
|
|
|
{
|
|
|
strcpy(item_type, argvalue);
|
|
|
}
|
|
|
}
|
|
|
else if (stricmp(argflag, "referenced") == 0)
|
|
|
{
|
|
|
//strcmp("","");
|
|
|
if (argvalue != NULL)
|
|
|
{
|
|
|
strcpy(referenced, argvalue);
|
|
|
}
|
|
|
}
|
|
|
else if (stricmp(argflag, "checkItemType") == 0)
|
|
|
{
|
|
|
//strcmp("","");
|
|
|
if (argvalue != NULL)
|
|
|
{
|
|
|
strcpy(check_item_type, argvalue);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
DOFREE(argflag);
|
|
|
DOFREE(argvalue);
|
|
|
DOFREE(arg);
|
|
|
}
|
|
|
printf("itemType=%s\n", item_type);
|
|
|
printf("referenced=%s\n", referenced);
|
|
|
printf("checkItemType=%s\n", check_item_type);
|
|
|
vector<char *> check_item_type_values;
|
|
|
if (strstr(check_item_type, ",") != NULL)
|
|
|
{
|
|
|
int vectorValueCount = 0;
|
|
|
char ** vectorValueChar = new char *[64];
|
|
|
split(check_item_type, ",", vectorValueChar, &vectorValueCount);
|
|
|
for (int i = 0; i < vectorValueCount; i++)
|
|
|
{
|
|
|
char temp[64] = "";
|
|
|
strcat(temp,vectorValueChar[i]);
|
|
|
strcat(temp,"Revision");
|
|
|
check_item_type_values.push_back(vectorValueChar[i]);
|
|
|
check_item_type_values.push_back(temp);
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
char temp[64] = "";
|
|
|
strcat(temp, check_item_type);
|
|
|
strcat(temp, "Revision");
|
|
|
check_item_type_values.push_back(check_item_type);
|
|
|
check_item_type_values.push_back(temp);
|
|
|
}
|
|
|
char result[1024] = "";
|
|
|
for (int i = 0; i < attachments_num; i++)
|
|
|
{
|
|
|
char *itemType = NULL;
|
|
|
|
|
|
ITKCALL(ifail = AOM_ask_value_string(attachments[i], "object_type", &itemType));
|
|
|
printf("object_type : %s \r\n", itemType);
|
|
|
if (strcmp(item_type, itemType) != 0)
|
|
|
{
|
|
|
DOFREE(itemType);
|
|
|
continue;
|
|
|
}
|
|
|
//printf("获取关系\n");
|
|
|
tag_t relation_tag = NULLTAG;
|
|
|
//获取关系
|
|
|
ITKCALL(ifail = GRM_find_relation_type(referenced, &relation_tag));
|
|
|
if (relation_tag != NULLTAG)
|
|
|
{
|
|
|
int rfCount = 0;
|
|
|
tag_t * rfTags = NULL;
|
|
|
ITKCALL(ifail = GRM_list_secondary_objects_only(attachments[i], relation_tag, &rfCount, &rfTags));
|
|
|
printf("关系下对象数量:%d\n",rfCount);
|
|
|
for (int j = 0; j < rfCount; j++)
|
|
|
{
|
|
|
//printf("遍历关系下对象\n");
|
|
|
printf("\n");
|
|
|
char *itemType2 = NULL;
|
|
|
ITKCALL(ifail = AOM_ask_value_string(rfTags[j], "object_type", &itemType2));
|
|
|
//char rev_type[64] = "";
|
|
|
//strcat(rev_type, itemType2);
|
|
|
//strcat(rev_type, "Revision");
|
|
|
printf("当前类型:%s\n",itemType2);
|
|
|
if (!count(check_item_type_values, itemType2))
|
|
|
{
|
|
|
DOFREE(itemType2);
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
tag_t rev = NULLTAG;
|
|
|
tag_t * temp_rev = NULL;
|
|
|
int num = 0;
|
|
|
printf("itemType2=%s\n", itemType2);
|
|
|
if (strstr(itemType2, "Revision"))
|
|
|
{
|
|
|
//printf("当前是版本对象\n");
|
|
|
rev = rfTags[j];
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
//printf("当前不是版本对象\n");
|
|
|
//获取最新版本
|
|
|
ITKCALL(ifail = AOM_ask_value_tags(rfTags[j], "revision_list", &num, &temp_rev));
|
|
|
rev = temp_rev[num - 1];
|
|
|
}
|
|
|
tag_t * child_revs = NULL;
|
|
|
ITKCALL(ifail = AOM_ask_value_tags(rev,"ps_children",&num, &child_revs));
|
|
|
printf("版本子集数量=%d\n",num);
|
|
|
if (num > 0)
|
|
|
{
|
|
|
for (int ii = 0; ii < num; ii++)
|
|
|
{
|
|
|
char * prop = "";
|
|
|
char * object_string = "";
|
|
|
tag_t item = NULLTAG;
|
|
|
ITKCALL(ifail = AOM_ask_value_tag(child_revs[ii], "items_tag", &item));
|
|
|
//ITKCALL(ifail = AOM_ask_value_string(item, "object_desc", &prop));
|
|
|
ITKCALL(ifail = AOM_ask_value_string(item, "ml8_Status", &prop));
|
|
|
ITKCALL(ifail = AOM_ask_value_string(item, "object_string", &object_string));
|
|
|
printf("当前对象:%s\n",object_string);
|
|
|
//if (strcmp(prop, "冻结") == 0)
|
|
|
//if (strcmp(prop, "冻结") == 0 || strcmp(prop, "FreezePart") == 0)//20230928添加BOM时限制添加冻结、限用物料处理步骤
|
|
|
if (strcmp(prop, "ObsoletePart") == 0 || strcmp(prop, "FreezePart") == 0)//20250116海外要求增加废止状态
|
|
|
{
|
|
|
printf("属性值为冻结\n");
|
|
|
strcat(result, object_string);
|
|
|
strcat(result, "属于冻结状态,不能启用\n");
|
|
|
}
|
|
|
DOFREE(prop);
|
|
|
DOFREE(object_string);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
DOFREE(temp_rev);
|
|
|
DOFREE(child_revs);
|
|
|
}
|
|
|
DOFREE(rfTags);
|
|
|
DOFREE(itemType);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
if (strcmp(result, "") != 0)
|
|
|
{
|
|
|
EMH_store_error_s1(EMH_severity_user_error, EMH_USER_error_base, result);
|
|
|
ifail = 1;
|
|
|
}
|
|
|
|
|
|
auto stopTime = std::chrono::high_resolution_clock::now();
|
|
|
auto duration = std::chrono::duration_cast<std::chrono::microseconds>(stopTime - startTime);
|
|
|
//std::cout << "ML_ChideIsEnabled用时:" << duration.count() / 1000 << std::endl;
|
|
|
string usetime = "ML_ChideIsEnabled用时:";
|
|
|
usetime.append(std::to_string(duration.count() / 1000));
|
|
|
WriteLog(true, usetime.c_str());
|
|
|
printf("=========================物料启用判断 End====================\n");
|
|
|
return ifail;
|
|
|
} |