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.

65 lines
2.0 KiB

#include "util.h"
#include <boost/algorithm/string/predicate.hpp>
#include <boost/lexical_cast.hpp>
void checkCGLX(tag_t bomline, bool *flag) {
int child_cnt;
tag_t *childrens;
ITKCALL(BOM_line_ask_child_lines(bomline, &child_cnt, &childrens));
if (child_cnt == 0) {
return;
}
for (int i = 0;i < child_cnt;i++) {
char *cglx, *item_id, *rev_id;
tag_t rev, *form;
int form_cnt;
AOM_ask_value_string(childrens[i], "bl_item_item_id", &item_id);
AOM_ask_value_string(childrens[i], "bl_rev_item_revision_id",
&rev_id);
ITEM_find_rev(item_id, rev_id, &rev);
AOM_ask_value_tags(rev, "IMAN_master_form_rev", &form_cnt, &form);
AOM_ask_value_string(form[0], "jd2_cglx", &cglx);
cout << "check item_id:" << item_id << endl;
cout << "cglx:" << cglx << endl;
*flag = *flag&&tc_strlen(cglx) > 0;
if (!*flag) {
return;
}
checkCGLX(childrens[i], flag);
}
}
int jd_check_99_cglx(EPM_rule_message_t msg) {
int att_cnt;
tag_t root_task, *attachments;
EPM_ask_root_task(msg.task, &root_task);
EPM_ask_attachments(root_task, EPM_target_attachment, &att_cnt, &attachments);
for (int i = 0;i < att_cnt;i++) {
char *item_id;
AOM_ask_value_string(attachments[i], "item_id", &item_id);
cout << "item_id:" << item_id << endl;
if (!isTypeOf(attachments[i], "ItemRevision") || !boost::starts_with(item_id, "99")) {
continue;
}
tag_t window, top_line, item, *childrens;
int child_cnt;
ITKCALL(ITEM_ask_item_of_rev(attachments[i], &item));
ITKCALL(BOM_create_window(&window));
ITKCALL(BOM_set_window_top_line(window, item, attachments[i], NULLTAG, &top_line));
ITKCALL(BOM_line_ask_child_lines(top_line, &child_cnt, &childrens));
if (child_cnt == 0) {
continue;
}
bool flag = true;
checkCGLX(top_line, &flag);
ITKCALL(BOM_close_window(window));
cout << "flag:" << boolalpha << flag << endl;
if (!flag) {
return EMH_store_error_s1(EMH_severity_error, EMH_IDGENERATION_ERROR_BASE, "包含未填写采购类型的物料,请检查");
}
}
return EPM_go;
}