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.
88 lines
2.3 KiB
88 lines
2.3 KiB
#include "util.h"
|
|
|
|
int bs_bom_transmit_check(EPM_rule_message_t msg)
|
|
{
|
|
POM_AM__set_application_bypass(true);
|
|
tag_t root_task, *attachments;
|
|
int att_cnt;
|
|
|
|
//获得参数列表
|
|
TC_argument_list_t * arguments = msg.arguments;
|
|
//获取参数数目
|
|
int arg_cnt = TC_number_of_arguments(arguments);
|
|
map<string, string> arg_map;
|
|
//遍历参数列表
|
|
for (auto i = 0; i < arg_cnt; i++)
|
|
{
|
|
char *temp_key, *temp_val;
|
|
ITK_ask_argument_named_value(TC_next_argument(arguments), &temp_key, &temp_val);
|
|
//参数以键值对的形式传递到arg_map
|
|
if (temp_val)
|
|
arg_map[temp_key] = temp_val;
|
|
|
|
}
|
|
|
|
//获得根节点
|
|
EPM_ask_root_task(msg.task, &root_task);
|
|
//获得根任务下的组件
|
|
EPM_ask_attachments(root_task, EPM_target_attachment, &att_cnt, &attachments);
|
|
//判断参数是否符合要求
|
|
int taskNum = 0, BOMNum = 0;
|
|
for (int i = 0; i < att_cnt; i++)
|
|
{
|
|
if (isTypeOf(attachments[i], "ItemRevision"))
|
|
{
|
|
taskNum = taskNum + 1;
|
|
|
|
int form_att;
|
|
tag_t *forms;
|
|
AOM_ask_value_tags(attachments[i], "IMAN_master_form_rev", &form_att, &forms);
|
|
|
|
//遍历参数
|
|
for (auto j = arg_map.begin(); j != arg_map.end(); j++)
|
|
{
|
|
//设置属性
|
|
ITKCALL(AOM_set_value_string(forms[0], j->first.c_str(), j->second.c_str()));
|
|
}
|
|
//保存
|
|
AOM_save(forms[0]);
|
|
|
|
//拿到指定参数判断参数值
|
|
if (form_att == 0)
|
|
{
|
|
continue;
|
|
}
|
|
char *cglx, *tscg;
|
|
AOM_ask_value_string(forms[0], "jd2_cglx", &cglx);
|
|
AOM_ask_value_string(forms[0], "jd2_tscg", &tscg);
|
|
cout << "jd2_cglx" << cglx << endl;
|
|
cout << "jd2_tscg" << tscg << endl;
|
|
if (((strcmp(cglx, "E") == 0) && (strcmp(tscg, "") == 0)) || ((strcmp(cglx, "E") == 0) && (strcmp(tscg, "50") == 0)))
|
|
{
|
|
//判断是否有 BOM 版本视图 structure_revisions 如果存在则可以发起流程
|
|
int structure_att;
|
|
tag_t *structures;
|
|
AOM_ask_value_tags(attachments[i], "structure_revisions", &structure_att, &structures);
|
|
if (structures != NULL)
|
|
{
|
|
BOMNum = BOMNum + 1;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
POM_AM__set_application_bypass(false);
|
|
return EMH_store_error_s1(EMH_severity_error, EMH_IDGENERATION_ERROR_BASE, "This material cannot initiate a process");
|
|
}
|
|
}
|
|
|
|
}
|
|
if (taskNum == BOMNum) {
|
|
POM_AM__set_application_bypass(false);
|
|
return EPM_go;
|
|
}
|
|
else {
|
|
POM_AM__set_application_bypass(false);
|
|
return EMH_store_error_s1(EMH_severity_error, EMH_IDGENERATION_ERROR_BASE, "该物料类型需要包含BOM视图");
|
|
}
|
|
|
|
} |