|
|
#define _CRT_SECURE_NO_WARNINGS
|
|
|
#include "epm_handler_common.h"
|
|
|
|
|
|
int ML_ItemParentIsRelease(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;
|
|
|
//获取任务对象
|
|
|
EPM_ask_root_task(msg.task, &rootTask);
|
|
|
//获取任务目标对象
|
|
|
EPM_ask_attachments(rootTask, EPM_target_attachment, &attachments_num, &attachments);
|
|
|
|
|
|
char *argflag = NULL, *argvalue = NULL, *arg = NULL;
|
|
|
char arg1value[1024] = "", arg2value[1024] = "", arg3value[1024] = "", arg4value[1024] = "";
|
|
|
//获取参数
|
|
|
int arg_cnt = TC_number_of_arguments(msg.arguments);
|
|
|
printf("参数个数为:%d\n", arg_cnt);
|
|
|
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)
|
|
|
{
|
|
|
//strcmp("","");
|
|
|
if (argvalue != NULL)
|
|
|
{
|
|
|
strcpy(arg1value, argvalue);
|
|
|
}
|
|
|
}
|
|
|
else if (stricmp(argflag, "referenced") == 0)
|
|
|
{
|
|
|
if (argvalue != NULL)
|
|
|
{
|
|
|
strcpy(arg2value, argvalue);
|
|
|
}
|
|
|
}
|
|
|
else if (stricmp(argflag, "checkItemType") == 0)
|
|
|
{
|
|
|
if (argvalue != NULL)
|
|
|
{
|
|
|
strcpy(arg3value, argvalue);
|
|
|
}
|
|
|
}
|
|
|
//else if (stricmp(argflag, "IgnoresItemRevision") == 0)
|
|
|
//{
|
|
|
// if (argvalue != NULL)
|
|
|
// {
|
|
|
// strcpy(arg4value, argvalue);
|
|
|
// }
|
|
|
//}
|
|
|
}
|
|
|
DOFREE(argflag);
|
|
|
DOFREE(argvalue);
|
|
|
DOFREE(arg);
|
|
|
}
|
|
|
|
|
|
vector<char *> itemTypeValues;
|
|
|
|
|
|
if (strstr(arg1value, ",") != NULL)
|
|
|
{
|
|
|
int vectorValueCount = 0;
|
|
|
char ** vectorValueChar = new char *[64];
|
|
|
split(arg1value, ",", vectorValueChar, &vectorValueCount);
|
|
|
for (int i = 0; i < vectorValueCount; i++)
|
|
|
{
|
|
|
itemTypeValues.push_back(vectorValueChar[i]);
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
itemTypeValues.push_back(arg1value);
|
|
|
}
|
|
|
|
|
|
vector<char *> referencedValues;
|
|
|
|
|
|
if (strstr(arg2value, ",") != NULL)
|
|
|
{
|
|
|
int vectorValueCount = 0;
|
|
|
char ** vectorValueChar = new char *[64];
|
|
|
split(arg2value, ",", vectorValueChar, &vectorValueCount);
|
|
|
for (int i = 0; i < vectorValueCount; i++)
|
|
|
{
|
|
|
referencedValues.push_back(vectorValueChar[i]);
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
referencedValues.push_back(arg2value);
|
|
|
}
|
|
|
|
|
|
vector<char *> checkItemTypeValues;
|
|
|
|
|
|
if (strstr(arg3value, ",") != NULL)
|
|
|
{
|
|
|
int vectorValueCount = 0;
|
|
|
char ** vectorValueChar = new char *[64];
|
|
|
split(arg3value, ",", vectorValueChar, &vectorValueCount);
|
|
|
for (int i = 0; i < vectorValueCount; i++)
|
|
|
{
|
|
|
checkItemTypeValues.push_back(vectorValueChar[i]);
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
checkItemTypeValues.push_back(arg3value);
|
|
|
}
|
|
|
|
|
|
//vector<char *> IgnoresItemRevisions;
|
|
|
|
|
|
//if (strstr(arg4value, ",") != NULL)
|
|
|
//{
|
|
|
// int vectorValueCount = 0;
|
|
|
// char ** vectorValueChar = new char *[64];
|
|
|
// split(arg4value, ",", vectorValueChar, &vectorValueCount);
|
|
|
// for (int i = 0; i < vectorValueCount; i++)
|
|
|
// {
|
|
|
// IgnoresItemRevisions.push_back(vectorValueChar[i]);
|
|
|
// }
|
|
|
//}
|
|
|
//else
|
|
|
//{
|
|
|
// IgnoresItemRevisions.push_back(arg4value);
|
|
|
//}
|
|
|
//for (auto IgnoresItemRevision : IgnoresItemRevisions)
|
|
|
//{
|
|
|
// printf("IgnoresItemRevisions:%s\n", IgnoresItemRevision);
|
|
|
//}
|
|
|
POM_AM__set_application_bypass(true);
|
|
|
char resultString[100000] = "";
|
|
|
for (int i = 0; i < attachments_num; i++)
|
|
|
{
|
|
|
char *itemType = NULL;
|
|
|
|
|
|
AOM_ask_value_string(attachments[i], "object_type", &itemType);
|
|
|
printf("type_class : %s \r\n", itemType);
|
|
|
//过滤掉非文件夹的对象
|
|
|
if (!count(itemTypeValues, itemType))
|
|
|
{
|
|
|
DOFREE(itemType);
|
|
|
continue;
|
|
|
}
|
|
|
//判断文件下的对象是否发布
|
|
|
//AOM_ask_value_tags(attachments[i], arg2value, &num, &tags);
|
|
|
for (auto referencedValue : referencedValues) {
|
|
|
printf("referencedValue : %s \r\n", referencedValue);
|
|
|
int num = 0;
|
|
|
tag_t * tags = NULLTAG;
|
|
|
AOM_ask_value_tags(attachments[i], referencedValue, &num, &tags);
|
|
|
printf("关系下的对象数量 : %d \r\n", num);
|
|
|
if (num <= 0)
|
|
|
{
|
|
|
//ifail = 2;
|
|
|
if (strcmp(arg1value, "Folder") == 0)
|
|
|
{
|
|
|
strcat(resultString, "没有提交交付物,无法完成任务!");
|
|
|
strcat(resultString, "\n");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
strcat(resultString, referencedValue);
|
|
|
strcat(resultString, "关系下不包含任何对象!");
|
|
|
strcat(resultString, "\n");
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
for (int j = 0; j < num; j++)
|
|
|
{
|
|
|
char *objectType = NULL;
|
|
|
|
|
|
AOM_ask_value_string(tags[j], "object_type", &objectType);
|
|
|
printf("objectType : %s \r\n", objectType);
|
|
|
if (strcmp(arg3value, "") != 0)
|
|
|
{
|
|
|
if (!count(checkItemTypeValues, objectType))
|
|
|
{
|
|
|
DOFREE(objectType);
|
|
|
continue;
|
|
|
}
|
|
|
}
|
|
|
tag_t revisions = tags[j];
|
|
|
if (strstr(objectType, "Revision") == NULL)
|
|
|
{
|
|
|
ITEM_ask_latest_rev(tags[j], &revisions);
|
|
|
}
|
|
|
int n_references = 0;
|
|
|
int * levels = 0;
|
|
|
tag_t * reference_tags = NULL_TAG;
|
|
|
//获取父级
|
|
|
PS_where_used_all(revisions, 1, &n_references, &levels, &reference_tags);
|
|
|
printf("父级数量 : %d \r\n", n_references);
|
|
|
|
|
|
char * objectString = NULL;
|
|
|
|
|
|
AOM_ask_value_string(revisions, "object_string", &objectString);
|
|
|
for (int k = 0; k < n_references; k++)
|
|
|
{
|
|
|
|
|
|
char *itemString = NULL, *id = NULL;
|
|
|
|
|
|
WSOM_ask_id_string(reference_tags[k], &id);
|
|
|
if (strstr(id, "-") != NULL) {
|
|
|
continue;
|
|
|
}
|
|
|
AOM_ask_value_string(reference_tags[k], "object_string", &itemString);
|
|
|
char * parentObjectType = NULL;
|
|
|
AOM_ask_value_string(reference_tags[k], "object_type", &parentObjectType);
|
|
|
printf("parentObjectType : %s \r\n", parentObjectType);
|
|
|
////过滤忽略的父级
|
|
|
//bool tempbool = count(IgnoresItemRevisions, parentObjectType);
|
|
|
//printf("tempbool:%d\n", tempbool);
|
|
|
//if (count(IgnoresItemRevisions, parentObjectType))
|
|
|
//{
|
|
|
// printf("忽略%s\n", itemString);
|
|
|
// DOFREE(parentObjectType);
|
|
|
// DOFREE(itemString);
|
|
|
// continue;
|
|
|
//}
|
|
|
char * status = NULL;
|
|
|
//判断发布状态
|
|
|
int releaseCount = 0;
|
|
|
tag_t * releaseTags = NULL;
|
|
|
if (strcmp(parentObjectType, "ML8_RefrigeratorRevision") == 0 || strcmp(parentObjectType, "ML8_WashingRevision") == 0 ||
|
|
|
strcmp(parentObjectType, "ML8_ColdRevision") == 0 || strcmp(parentObjectType, "ML8_OthersRevision") == 0)
|
|
|
{
|
|
|
//获取版本上ml8_MaterialStatus属性的值
|
|
|
AOM_ask_value_string(reference_tags[k], "ml8_MaterialStatus", &status);
|
|
|
|
|
|
//判断子件是否发布
|
|
|
AOM_ask_value_tags(reference_tags[k], "release_status_list", &releaseCount, &releaseTags);
|
|
|
|
|
|
}
|
|
|
else if (strcmp(parentObjectType, "ML8_PartRevision") == 0)
|
|
|
{
|
|
|
//获取对象上ml8_Status属性的值
|
|
|
tag_t referenceItem_tag = NULL_TAG;
|
|
|
ITEM_ask_item_of_rev(reference_tags[k], &referenceItem_tag);
|
|
|
AOM_ask_value_string(referenceItem_tag, "ml8_Status", &status);
|
|
|
//判断子件是否发布
|
|
|
AOM_ask_value_tags(reference_tags[k], "release_status_list", &releaseCount, &releaseTags);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
printf("忽略%s类型\n", parentObjectType);
|
|
|
goto free;
|
|
|
}
|
|
|
bool isReplaced = false;
|
|
|
if (releaseCount > 0)
|
|
|
{
|
|
|
for (int kk = 0; kk < releaseCount; kk++)
|
|
|
{
|
|
|
char * releaseString = NULL;
|
|
|
AOM_ask_value_string(releaseTags[kk], "object_name", &releaseString);
|
|
|
|
|
|
printf("releaseString : %s \r\n", releaseString);
|
|
|
|
|
|
if (strcmp(releaseString, "ML8_Replaced") == 0)
|
|
|
{
|
|
|
isReplaced = true;
|
|
|
DOFREE(releaseString);
|
|
|
break;
|
|
|
}
|
|
|
DOFREE(releaseString);
|
|
|
}
|
|
|
}
|
|
|
printf("status : %s \r\n", status);
|
|
|
//if (strcmp(status, "冻结") != 0 && !isReplaced)
|
|
|
//if (strcmp(status, "FreezePart") != 0 && strcmp(status, "冻结") != 0 && !isReplaced)//20230928添加BOM时限制添加冻结、限用物料处理步骤
|
|
|
if (strcmp(status, "FreezePart") != 0 && strcmp(status, "ObsoletePart") != 0 && !isReplaced)//20250116海外要求增加废止状态
|
|
|
{
|
|
|
strcat(resultString, "物料ID为:");
|
|
|
strcat(resultString, objectString);
|
|
|
strcat(resultString, "的父级ID:");
|
|
|
strcat(resultString, itemString);
|
|
|
strcat(resultString, "\n");
|
|
|
ifail = 1;
|
|
|
}
|
|
|
free:
|
|
|
DOFREE(releaseTags);
|
|
|
DOFREE(itemString);
|
|
|
DOFREE(parentObjectType);
|
|
|
DOFREE(status);
|
|
|
}
|
|
|
DOFREE(objectType);
|
|
|
DOFREE(reference_tags);
|
|
|
}
|
|
|
}
|
|
|
DOFREE(tags);
|
|
|
}
|
|
|
DOFREE(itemType);
|
|
|
}
|
|
|
POM_AM__set_application_bypass(false);
|
|
|
itemTypeValues.clear();
|
|
|
vector<char *>().swap(itemTypeValues);
|
|
|
referencedValues.clear();
|
|
|
vector<char *>().swap(referencedValues);
|
|
|
checkItemTypeValues.clear();
|
|
|
vector<char *>().swap(checkItemTypeValues);
|
|
|
DOFREE(attachments);
|
|
|
if (ifail == 1)
|
|
|
{
|
|
|
strcat(resultString, "状态为非冻结!");
|
|
|
EMH_store_error_s1(EMH_severity_user_error, EMH_USER_error_base, resultString);
|
|
|
}
|
|
|
/*else if (ifail == 2)
|
|
|
{
|
|
|
ifail = 1;
|
|
|
EMH_store_error_s1(EMH_severity_user_error, EMH_USER_error_base, resultString);
|
|
|
}*/
|
|
|
|
|
|
auto stopTime = std::chrono::high_resolution_clock::now();
|
|
|
auto duration = std::chrono::duration_cast<std::chrono::microseconds>(stopTime - startTime);
|
|
|
//std::cout << "ML_ItemParentIsRelease用时:" << duration.count() / 1000 << std::endl;
|
|
|
string usetime = "ML_ItemParentIsRelease用时:";
|
|
|
usetime.append(std::to_string(duration.count() / 1000));
|
|
|
WriteLog(true, usetime.c_str());
|
|
|
printf("=========================判断文件夹下对象的父级是否发布 End===================\n");
|
|
|
return ifail;
|
|
|
} |