|
|
#include "util.h"
|
|
|
|
|
|
|
|
|
bool startsWith(const char* str, const char* prefix) {
|
|
|
return strncmp(str, prefix, strlen(prefix)) == 0;
|
|
|
}
|
|
|
|
|
|
bool endsWith(const char* str, const char* suffix) {
|
|
|
if (!str || !suffix)
|
|
|
return str == suffix;
|
|
|
|
|
|
size_t lenStr = strlen(str);
|
|
|
size_t lenSuffix = strlen(suffix);
|
|
|
|
|
|
if (lenSuffix > lenStr)
|
|
|
return false;
|
|
|
|
|
|
return strncmp(str + lenStr - lenSuffix, suffix, lenSuffix) == 0;
|
|
|
}
|
|
|
|
|
|
bool isJD2_BJRevision(const char* type) {
|
|
|
return startsWith(type, "JD2") && endsWith(type, "BJRevision");
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
* 获取包含中文字符的字符串长度
|
|
|
*/
|
|
|
int getCharLength(char str[])
|
|
|
{
|
|
|
int count = 0;
|
|
|
for (int i = 0; str[i]; i++)
|
|
|
{
|
|
|
if (str[i] < 0) i++;
|
|
|
count++;
|
|
|
}
|
|
|
return count;
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
* 选中对象版本发起任意流程时,检查版本净重
|
|
|
*/
|
|
|
int jd_check_jz(EPM_rule_message_t msg) {
|
|
|
printf("Sample_confirmation_sheet is begin! \n");
|
|
|
int ifail = ITK_ok,
|
|
|
result_tag = EPM_go;
|
|
|
tag_t rootTask = NULLTAG;
|
|
|
int attachmentCount = 0;
|
|
|
tag_t* attachmentTags = NULL,
|
|
|
attachmentTag = NULLTAG;
|
|
|
char* type = NULL,
|
|
|
* name = NULL,
|
|
|
* jz = NULL;
|
|
|
int form_cnt = 0;
|
|
|
tag_t* forms = NULL;
|
|
|
|
|
|
ITKCALL(ifail = EPM_ask_root_task(msg.task, &rootTask));
|
|
|
ITKCALL(ifail = EPM_ask_attachments(rootTask, EPM_target_attachment, &attachmentCount, &attachmentTags));
|
|
|
//便利所有的流程目标下的对象
|
|
|
for (int i = 0; i < attachmentCount; i++) {
|
|
|
attachmentTag = attachmentTags[i];//PartRevisionMaster
|
|
|
|
|
|
ITKCALL(ifail = AOM_ask_value_string(attachmentTag, "object_type", &type));
|
|
|
ITKCALL(ifail = AOM_ask_value_string(attachmentTag, "object_name", &name));
|
|
|
printf(">>>当前流程下对象的类型为==[%s]\n", type);
|
|
|
//获取版本对象下的表单
|
|
|
ITKCALL(ifail = AOM_ask_value_tags(attachmentTag, "IMAN_master_form_rev", &form_cnt, &forms));
|
|
|
|
|
|
//==========================下面是检查特定版本类型(JD2_XXBJRevision)下的表单属性:净重===========================================================================================================
|
|
|
if (isJD2_BJRevision(type)) {
|
|
|
//检查版本表单是否存在属性:jd2_jz
|
|
|
ITKCALL(ifail = AOM_ask_value_string(forms[0], "jd2_jz", &jz));
|
|
|
printf("获取净重属性的ifail结果 = [%d] \n", ifail);
|
|
|
if (ifail != 0 && ifail != 2) {
|
|
|
//未获取到净重属性,流程正常发起
|
|
|
printf("未获取到净重属性,流程正常发起 \n");
|
|
|
continue;
|
|
|
}else {
|
|
|
if (jz != NULL && stricmp(jz, "") == 0) {
|
|
|
//弹出弹窗提示,且终止流程
|
|
|
printf(">>>部件净重为空,不允许发起流程,请检查!!\n");
|
|
|
char* message = "部件净重为空,不允许发起流程,请检查!!";
|
|
|
cout << "Exception:" << message << endl;
|
|
|
EMH_store_error_s1(EMH_severity_error, EMH_IDGENERATION_ERROR_BASE, message);
|
|
|
result_tag = EPM_nogo;
|
|
|
break;
|
|
|
}else if (jz != NULL && stricmp(jz, "0.001") < 0) {
|
|
|
//弹出弹窗提示,且终止流程
|
|
|
printf(">>>部件净重小于0.001,不允许发起流程,请检查!!\n");
|
|
|
char* message = "部件净重小于0.001,不允许发起流程,请检查!!";
|
|
|
cout << "Exception:" << message << endl;
|
|
|
EMH_store_error_s1(EMH_severity_error, EMH_IDGENERATION_ERROR_BASE, message);
|
|
|
result_tag = EPM_nogo;
|
|
|
break;
|
|
|
}else {
|
|
|
//正常发起流程
|
|
|
printf(">>>净重=[%s],允许发起流程!\n",jz);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
else {
|
|
|
printf(">>>当前流程下对象[%s]类型为[%s],类型非部件类型:JD2_[XX]BJRevision,不必检查净重!!\n", name,type);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
MEM_free(forms);
|
|
|
MEM_free(name);
|
|
|
MEM_free(type);
|
|
|
MEM_free(attachmentTags);
|
|
|
return result_tag;
|
|
|
}
|
|
|
|
|
|
|