From ddfec8755db29415b3e0e3ed9bc19669a15cb12f Mon Sep 17 00:00:00 2001 From: zouxk Date: Fri, 22 May 2020 15:02:30 +0800 Subject: [PATCH] 5/22 --- HEZON_ITK/bs_sap.cpp | 191 +++++++++++------------------ HEZON_ITK/epm_handler_common.h | 2 + HEZON_ITK/epm_register_handler.cxx | 14 +++ HEZON_ITK/jd_batch_process.cpp | 3 +- HEZON_ITK/jd_check_99_bomyt.cpp | 11 +- HEZON_ITK/util.h | 1 + 6 files changed, 96 insertions(+), 126 deletions(-) diff --git a/HEZON_ITK/bs_sap.cpp b/HEZON_ITK/bs_sap.cpp index 2f0a761..3365dd3 100644 --- a/HEZON_ITK/bs_sap.cpp +++ b/HEZON_ITK/bs_sap.cpp @@ -1,7 +1,6 @@ #include "util.h" -int bs_sap_material(EPM_action_message_t msg) -{ +int bs_sap_material(EPM_action_message_t msg) { printf("start sap material\n"); int ifail = ITK_ok, att_count; tag_t rootTask, *attachments, relation_type; @@ -15,25 +14,21 @@ int bs_sap_material(EPM_action_message_t msg) TC_argument_list_t * arguments = msg.arguments; int arg_cnt = TC_number_of_arguments(arguments), status = 0; POM_AM__set_application_bypass(true); - map paras,rel_map; + map paras, rel_map; map prop_map; vector rel_vec; - for (auto i = 0; i < arg_cnt; i++) - { + 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); paras[temp_key] = temp_val; } string d0 = "D00", d1 = "D0"; - for(int i=0;i<67;i++) - { - if(i>8) - { - - class_map[1000+i] = d1 + to_string(i + 1); - }else - { + for (int i = 0;i < 67;i++) { + if (i > 8) { + + class_map[1000 + i] = d1 + to_string(i + 1); + } else { class_map[1000 + i] = d0 + to_string(i + 1); } } @@ -41,24 +36,20 @@ int bs_sap_material(EPM_action_message_t msg) PREF_ask_char_values("connor_sap", &pref_cnt, &pref_vals); split(pref_vals[4], ",", &rel_vec); - for(int i=0;i temp_vec; split(rel_vec[i], "=", &temp_vec); - if(temp_vec.size()==2) - { + if (temp_vec.size() == 2) { rel_map[temp_vec[0]] = temp_vec[1]; } } vector rel_vec2; split(pref_vals[5], ",", &rel_vec2); - for (int i = 0; i temp_vec; split(rel_vec2[i], "=", &temp_vec); - if (temp_vec.size() == 2) - { + if (temp_vec.size() == 2) { prop_map[temp_vec[0]] = temp_vec[1]; } } @@ -87,24 +78,19 @@ int bs_sap_material(EPM_action_message_t msg) // prop_map["GEWEI"] = "jd2_zldw"; // prop_map["CLASS"] = "jd2_wllx"; printf("start111\n"); - for (int i = 0; i < att_count; i++) - { - if (isTypeOf(attachments[i], "Form")) - { - int rel_cnt,*levels; - tag_t *rels,rev=NULLTAG,form; + for (int i = 0; i < att_count; i++) { + if (isTypeOf(attachments[i], "Form")) { + int rel_cnt, *levels; + tag_t *rels, rev = NULLTAG, form; char **relations; form = attachments[i]; WSOM_where_referenced2(form, 1, &rel_cnt, &levels, &rels, &relations); - for(int j=0;j ^dic = gcnew System::Collections::Generic::Dictionary(); - for (auto j = prop_map.begin(); j != prop_map.end(); j++) - { - char *val=""; + for (auto j = prop_map.begin(); j != prop_map.end(); j++) { + char *val = ""; string temp_val; - - if (j->second == "item_id") - { + + if (j->second == "item_id") { AOM_ask_value_string(rev, j->second.c_str(), &val); temp_val = val; - } - else if (j->second == "release_status_list") { + } else if (j->second == "release_status_list") { // int status_cnt; // tag_t *rel_status; // AOM_ask_value_tags(form, j->second.c_str(), &status_cnt, &rel_status); @@ -130,13 +113,10 @@ int bs_sap_material(EPM_action_message_t msg) // AOM_UIF_ask_value(rel_status[status_cnt - 1], "object_string", &val); // temp_val = rel_map[val]; temp_val = paras["status"]; - }else if(j->second=="jd2_dldw") - { + } else if (j->second == "jd2_dldw") { AOM_UIF_ask_value(form, j->second.c_str(), &val); temp_val = val; - } - else - { + } else { tag_t lov; AOM_ask_lov(form, j->second.c_str(), &lov); if (lov) @@ -149,17 +129,14 @@ int bs_sap_material(EPM_action_message_t msg) } tag_t class_obj; ICS_ask_classification_object(rev, &class_obj); - if (class_obj) - { + if (class_obj) { char ***vals; - int cnt, *ids,*val_count; + int cnt, *ids, *val_count; ICS_ico_ask_attributes(class_obj, &cnt, &ids, &val_count, &vals); - for(int j=0;jsend_material(url, user, password, dic)); printf("result:%s\n", result.c_str()); - if(result.length()&&result[0]=='E') - { + if (result.length() && result[0] == 'E') { char *val; AOM_ask_value_string(rev, "item_id", &val); stringstream err; @@ -181,7 +157,6 @@ int bs_sap_material(EPM_action_message_t msg) return 1; } - } } @@ -191,24 +166,21 @@ int bs_sap_material(EPM_action_message_t msg) } -void get_bom(System::Collections::Generic::List^> ^a_list,tag_t line,char *werks,char *stlan,string pid, tag_t relation_type,boolean is_hl,boolean is_judge) -{ +void get_bom(System::Collections::Generic::List^> ^a_list, tag_t line, char *werks, char *stlan, string pid, tag_t relation_type, boolean is_hl, boolean is_judge) { int line_cnt; tag_t *lines; BOM_line_ask_child_lines(line, &line_cnt, &lines); char *id; AOM_UIF_ask_value(line, "bl_item_item_id", &id); - if(a_list->Count==0) - { - pid = pid.length()>0?pid:id; + if (a_list->Count == 0) { + pid = pid.length() > 0 ? pid : id; int index = pid.find('-'); if (index != -1) pid = pid.substr(index + 1); } - for (int j = 0; j < line_cnt; j++) - { + for (int j = 0; j < line_cnt; j++) { System::Collections::Generic::Dictionary ^dic = gcnew System::Collections::Generic::Dictionary(); - dic["MATNR"] = convert_to_cstring(pid.length()>0?pid.c_str():id); + dic["MATNR"] = convert_to_cstring(pid.length() > 0 ? pid.c_str() : id); dic["WERKS"] = convert_to_cstring(werks); dic["STLAN"] = convert_to_cstring(stlan); dic["BMENG"] = "1"; @@ -226,8 +198,8 @@ void get_bom(System::Collections::Generic::List(index + 3)) - { + if (index != -1 && quantity.length() > (index + 3)) { quantity = quantity.substr(0, index + 3); } - }else - { + } else { AOM_ask_value_string(lines[j], "bl_quantity", &val); quantity = val; } dic["MENGE"] = convert_to_cstring(quantity.c_str()); - if(is_judge){ - if (rel_cnt) - { + if (is_judge) { + if (rel_cnt) { AOM_ask_value_string(rels[0], "jd2_cglx", &val1); AOM_ask_value_string(rels[0], "jd2_tscg", &val2); } char *obj_str; AOM_ask_value_string(lines[j], "object_string", &obj_str); - if (tc_strcmp(val1, "F") == 0 && tc_strcmp(val2, "50") == 0) - { - printf("has f50:%s\n",obj_str); + if (tc_strcmp(val1, "F") == 0 && tc_strcmp(val2, "50") == 0) { + printf("has f50:%s\n", obj_str); continue; } - if (tc_strcmp(val1, "F") == 0 && tc_strcmp(val2, "10") == 0) - { + if (tc_strcmp(val1, "F") == 0 && tc_strcmp(val2, "10") == 0) { printf("has f10:%s\n", obj_str); a_list->Add(dic); continue; } - if (tc_strcmp(val1, "F") == 0 && tc_strlen(val2) == 0) - { + if (tc_strcmp(val1, "F") == 0 && tc_strlen(val2) == 0) { printf("has fempty:%s\n", obj_str); a_list->Add(dic); continue; } - if (tc_strcmp(val1, "E") == 0 && tc_strlen(val2) == 0) - { + if (tc_strcmp(val1, "E") == 0 && tc_strlen(val2) == 0) { printf("has fempty:%s\n", obj_str); a_list->Add(dic); continue; } - if (tc_strcmp(val1, "E") == 0 && tc_strcmp(val2, "50") == 0) - { + if (tc_strcmp(val1, "E") == 0 && tc_strcmp(val2, "50") == 0) { printf("has e50:%s\n", obj_str); - - if(pid.length()>0) - { - printf("obj:%s pid:%s\n",obj_str,pid.c_str()); - }else - { + + if (pid.length() > 0) { + printf("obj:%s pid:%s\n", obj_str, pid.c_str()); + } else { printf("obj:%s pid:%s\n", obj_str, id); } - get_bom(a_list, lines[j], werks, stlan, pid.length()>0 ? pid : id, relation_type, child_is_hl, is_judge); + get_bom(a_list, lines[j], werks, stlan, pid.length() > 0 ? pid : id, relation_type, child_is_hl, is_judge); continue; } // if (tc_strcmp(val1, "F") == 0 && tc_strlen(val2) == 0) @@ -308,12 +269,11 @@ void get_bom(System::Collections::Generic::ListAdd(dic); - get_bom(a_list, lines[j], werks, stlan,"",relation_type, child_is_hl, is_judge); + get_bom(a_list, lines[j], werks, stlan, "", relation_type, child_is_hl, is_judge); } } -int bs_sap_bom(EPM_action_message_t msg) -{ +int bs_sap_bom(EPM_action_message_t msg) { printf("start sap bom2\n"); int ifail = ITK_ok, att_count; tag_t rootTask, *attachments, relation_type, win; @@ -328,8 +288,7 @@ int bs_sap_bom(EPM_action_message_t msg) POM_AM__set_application_bypass(true); map paras; - for (auto i = 0; i < arg_cnt; i++) - { + 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); paras[temp_key] = temp_val; @@ -342,10 +301,8 @@ int bs_sap_bom(EPM_action_message_t msg) String^ password = convert_to_cstring(pref_vals[3]); bool has_99 = false; BOM_create_window(&win); - for (int i = 0; i < att_count; i++) - { - if (isTypeOf(attachments[i], "PSBOMViewRevision")) - { + for (int i = 0; i < att_count; i++) { + if (isTypeOf(attachments[i], "PSBOMViewRevision")) { tag_t top_line, rev; char *id; BOM_set_window_top_line_bvr(win, attachments[i], &top_line); @@ -355,23 +312,20 @@ int bs_sap_bom(EPM_action_message_t msg) if (rev == NULLTAG) continue; AOM_ask_value_string(rev, "item_id", &id); - if(id[0]=='9'&&id[1]=='9') - { + if (id[0] == '9'&&id[1] == '9') { has_99 = true; break; } } } printf("has _99:%d\n", has_99); - for (int i = 0; i < att_count; i++) - { - if (isTypeOf(attachments[i], "PSBOMViewRevision")) - { + for (int i = 0; i < att_count; i++) { + if (isTypeOf(attachments[i], "PSBOMViewRevision")) { printf("execute\n"); int rel_cnt, line_cnt; System::Collections::Generic::List^> ^a_list = gcnew System::Collections::Generic::List^>(); tag_t top_line, *lines, rev, *rels; - char *id, *werks, *stlan,*hl; + char *id, *werks, *stlan, *hl; BOM_set_window_top_line_bvr(win, attachments[i], &top_line); if (top_line == NULLTAG) continue; @@ -380,10 +334,8 @@ int bs_sap_bom(EPM_action_message_t msg) continue; GRM_list_secondary_objects_only(rev, relation_type, &rel_cnt, &rels); AOM_ask_value_string(rev, "item_id", &id); - if(has_99) - { - if (id[0] != '9' || id[1] != '9') - { + if (has_99) { + if (id[0] != '9' || id[1] != '9') { printf("not 99:%s\n", id); continue; @@ -394,16 +346,15 @@ int bs_sap_bom(EPM_action_message_t msg) AOM_ask_value_string(rels[0], "jd2_gc", &werks); AOM_ask_value_string(rels[0], "jd2_BOMyt", &stlan); AOM_UIF_ask_value(rev, "jd2_ishl", &hl); - boolean is_hl = tc_strcmp(hl,"ÊÇ")?false:true; - - if (tc_strlen(werks)==0||tc_strlen(stlan)==0) + boolean is_hl = tc_strcmp(hl, "ÊÇ") ? false : true; + + if (tc_strlen(werks) == 0 || tc_strlen(stlan) == 0) continue; boolean is_judege = id[0] == '9'&&id[1] == '9'; - get_bom(a_list, top_line, werks, stlan,"", relation_type,is_hl,is_judege); + get_bom(a_list, top_line, werks, stlan, "", relation_type, is_hl, is_judege); string result = ConvertToString(test->send_bom(url, user, password, a_list)); printf("result:%s\n", result.c_str()); - if(result.length()&&result[0]=='E') - { + if (result.length() && result[0] == 'E') { BOM_close_window(win); POM_AM__set_application_bypass(false); EMH_store_error_s1(EMH_severity_error, EMH_ATTR_error_base, result.c_str()); diff --git a/HEZON_ITK/epm_handler_common.h b/HEZON_ITK/epm_handler_common.h index 7c60b96..c9dfea7 100644 --- a/HEZON_ITK/epm_handler_common.h +++ b/HEZON_ITK/epm_handler_common.h @@ -50,6 +50,8 @@ int jd_schedule_joint(EPM_action_message_t msg); int jd_batch_process(EPM_action_message_t msg); int jd_add_attachments(EPM_action_message_t msg); int jd_check_99_bomyt(EPM_rule_message_t msg); +int jd_send_mail(EPM_action_message_t msg); +int jd_get_target(EPM_action_message_t msg); ////��������Ϣǩ��汾������ȥ //int qtmc_sign_ir(EPM_action_message_t msg); diff --git a/HEZON_ITK/epm_register_handler.cxx b/HEZON_ITK/epm_register_handler.cxx index fddd19a..6b8ec6b 100644 --- a/HEZON_ITK/epm_register_handler.cxx +++ b/HEZON_ITK/epm_register_handler.cxx @@ -168,6 +168,20 @@ extern DLLAPI int CUST_init_module(int *decision, va_list args) printf("register jd_check_99_bomyt successfully\n"); } + ifail = EPM_register_action_handler("jd_send_mail", "jd_send_mail", + (EPM_action_handler_t)jd_send_mail); + if (ifail) { + printf("register jd_send_mail failed\n"); + } else { + printf("register jd_send_mail successfully\n"); + } + ifail = EPM_register_action_handler("jd_get_target", "jd_get_target", + (EPM_action_handler_t)jd_get_target); + if (ifail) { + printf("register jd_get_target failed\n"); + } else { + printf("register jd_get_target successfully\n"); + } //if(ifail == ITK_ok) //{ // fprintf(stdout,"Registering action handler qtmc-sign-ir completed!\n"); diff --git a/HEZON_ITK/jd_batch_process.cpp b/HEZON_ITK/jd_batch_process.cpp index ed30741..4ca4989 100644 --- a/HEZON_ITK/jd_batch_process.cpp +++ b/HEZON_ITK/jd_batch_process.cpp @@ -87,8 +87,9 @@ int jd_batch_process(EPM_action_message_t msg) { EPM_ask_root_task(msg.task, &rootTask); EPM_ask_job(msg.task, &job); EPM_ask_attachments(rootTask, EPM_target_attachment, &att_count, &attachments); - if (att_count < 2) + if (att_count < 2) { return 0; + } printf("att_count:%d\n", att_count); AOM_ask_value_tag(job, "process_template", &process_template); vector process_vec; diff --git a/HEZON_ITK/jd_check_99_bomyt.cpp b/HEZON_ITK/jd_check_99_bomyt.cpp index ad9d953..352f7d4 100644 --- a/HEZON_ITK/jd_check_99_bomyt.cpp +++ b/HEZON_ITK/jd_check_99_bomyt.cpp @@ -103,18 +103,19 @@ int jd_check_99_bomyt(EPM_rule_message_t msg) { AOM_ask_value_string(attachments[i], "object_string", &name); printf("name=====>%s\n", name); if (is_begin_with(name, "99")) { - tag_t form = NULLTAG; + tag_t *forms; + int form_cnt; if (isTypeOf(attachments[i], "ItemRevision")) { - AOM_ask_value_tag(attachments[i], "IMAN_master_form_rev", &form); + AOM_ask_value_tags(attachments[i], "IMAN_master_form_rev", &form_cnt, &forms); } else if (isTypeOf(attachments[i], "Item")) { tag_t *revs; int rev_cnt; AOM_ask_value_tags(attachments[i], "revision_list", &rev_cnt, &revs); - AOM_ask_value_tag(revs[rev_cnt - 1], "IMAN_master_form_rev", &form); + AOM_ask_value_tags(revs[rev_cnt - 1], "IMAN_master_form_rev", &form_cnt, &forms); } - if (form != NULLTAG) { + if (form_cnt > 0) { char *prop; - AOM_ask_value_string(form, "jd2_BOMyt", &prop); + AOM_ask_value_string(forms[0], "jd2_BOMyt", &prop); if (tc_strcmp(prop, "5") == 0) { ifail = EPM_go; } diff --git a/HEZON_ITK/util.h b/HEZON_ITK/util.h index f85530c..20e2937 100644 --- a/HEZON_ITK/util.h +++ b/HEZON_ITK/util.h @@ -51,6 +51,7 @@ #include "tchar.h" #include "ics/ics.h" #include "ics/ics2.h" +#include #using "./declib.dll" using namespace std;