From 252607536cdbf86032abd76e33d3686d4ecd56e7 Mon Sep 17 00:00:00 2001 From: "lidy@connor.net.cn" Date: Mon, 8 Jul 2024 14:15:53 +0800 Subject: [PATCH] =?UTF-8?q?20240708=E4=BB=A3=E7=A0=81=E4=B8=8A=E4=BC=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- General/General/AutoFeeding.cpp | 211 +++++---- General/General/CHINT_CHANGEBOM_TO_SRM.cxx | 291 +++++++++++++ General/General/CHINT_Ecn_SendOA.cxx | 239 +++++++++- General/General/CloneProcess.cpp | 323 ++++++++------ General/General/DtoEBOM2.cpp | 366 ++++++++++++---- General/General/EbomToPMethod.cpp | 288 ++++++++----- General/General/General.vcxproj | 3 + General/General/General.vcxproj.filters | 9 + General/General/chint_changenotice.cpp | 59 ++- General/General/chint_changenoticebm.cpp | 408 ++++++++++++++++++ .../General/chint_check_materialstatus.cpp | 91 ++-- General/General/chint_ecn_signoff.cxx | 109 +++-- General/General/epm_handler_common.h | 5 + General/General/epm_register_handler.cpp | 51 ++- General/General/getBomDetails.cxx | 281 ++++++++++++ General/General/tc_log.cxx | 21 +- General/General/tc_log.h | 1 + General/General/tc_util.h | 3 + 18 files changed, 2261 insertions(+), 498 deletions(-) create mode 100644 General/General/CHINT_CHANGEBOM_TO_SRM.cxx create mode 100644 General/General/chint_changenoticebm.cpp create mode 100644 General/General/getBomDetails.cxx diff --git a/General/General/AutoFeeding.cpp b/General/General/AutoFeeding.cpp index cebb8a6..e6b8d5b 100644 --- a/General/General/AutoFeeding.cpp +++ b/General/General/AutoFeeding.cpp @@ -38,13 +38,16 @@ #include "tc_util.h" #include #include +#include #include "ado.h" #include "ocilib.h" using namespace std; +vector cutVec; + tag_t getPBomTag(tag_t designRev) { char* object_type; - AOM_ask_value_string(designRev, "object_type", &object_type); + ITKCALL(AOM_ask_value_string(designRev, "object_type", &object_type)); if (strcmp(object_type, "ZT2_Design3DRevision") == 0) { int num; tag_t* mantrs; @@ -80,10 +83,10 @@ void SplitTest(string strArg, string spliter, vector &ans) } void getDrawNo(tag_t bom_line, string &drawNo) { char* bl_desc; - AOM_ask_value_string(bom_line, "bl_rev_object_desc", &bl_desc); + ITKCALL(AOM_ask_value_string(bom_line, "bl_rev_object_desc", &bl_desc)); regex qq_reg2("^1ZDB5.*\\d{1,}1000X.*"); //string item_id = id; - AOM_ask_value_string(bom_line, "bl_rev_object_desc", &bl_desc); + ITKCALL(AOM_ask_value_string(bom_line, "bl_rev_object_desc", &bl_desc)); vector descVec1; SplitTest(bl_desc, " ", descVec1); printf("bl_desc===>%s\n", bl_desc); @@ -133,13 +136,13 @@ boolean isSt(tag_t matnr) { int cnt2, numFac, cnt3; boolean flag = false; char** procureType, ** factorys, ** specialProcureType,*objName; - AOM_ask_value_strings(matnr, "zt2_SZSpecialProcuretype", &cnt3, &specialProcureType); //为/ - AOM_ask_value_strings(matnr, "zt2_SZProcuretype", &cnt2, &procureType); //包含自制 - AOM_ask_value_strings(matnr, "zt2_SZFactory", &numFac, &factorys); + ITKCALL(AOM_ask_value_strings(matnr, "zt2_SZSpecialProcuretype", &cnt3, &specialProcureType)); //为/ + ITKCALL(AOM_ask_value_strings(matnr, "zt2_SZProcuretype", &cnt2, &procureType)); //包含自制 + ITKCALL(AOM_ask_value_strings(matnr, "zt2_SZFactory", &numFac, &factorys)); //AOM_ask_value_string(matnr, "object_name",&objName); for (int i = 0; i < numFac; i++) { - if (strcmp(factorys[i], "M060") == 0 && cnt2 > i && cnt3 > i) { - if (strstr(procureType[i], "自制") != NULL && strcmp(specialProcureType[i], "/") == 0) { + if (tc_strcmp(factorys[i], "M060") == 0 && cnt2 > i && cnt3 > i) { + if (tc_strstr(procureType[i], "自制") != NULL && tc_strcmp(specialProcureType[i], "/") == 0) { flag = true; } } @@ -159,7 +162,7 @@ void getBomMessage(vector& stBomlines, tag_t cBomLine, StBomBean &pBe char* cName = NULL, * zt2_SZProcuretype = NULL; ITKCALL(AOM_ask_value_tag(cBomLine, "bl_line_object", &cmantr)); ITKCALL(AOM_ask_value_string(cmantr, "object_name", &cName)); - ITKCALL(AOM_ask_value_string(cmantr, "zt2_SZProcuretype", &zt2_SZProcuretype)); //外购不再展开投料 + ITKCALL(AOM_UIF_ask_value(cmantr, "zt2_SZProcuretype", &zt2_SZProcuretype)); //外购不再展开投料 printf("虚拟件===>%s\n", cName); StBomBean bean; bean.bomline = cBomLine; @@ -193,10 +196,12 @@ void getBomMessage(vector &stBomlines, tag_t cBomLine) { //ITKCALL(AOM_ask_value_string(mantr, "object_name", &parentName)); ITKCALL(BOM_line_ask_all_child_lines(cBomLine, &c_line_count, &c_line_tags)); tag_t cmantr = NULLTAG; - char* cName = NULL, * zt2_SZProcuretype = NULL; + char* cName = NULL, * zt2_SZProcuretype = NULL, *os = NULL; + ITKCALL(AOM_ask_value_string(cBomLine, "object_string", &os)); ITKCALL(AOM_ask_value_tag(cBomLine, "bl_line_object", &cmantr)); ITKCALL(AOM_ask_value_string(cmantr, "object_name", &cName)); - ITKCALL(AOM_ask_value_string(cmantr, "zt2_SZProcuretype", &zt2_SZProcuretype)); //外购不再展开投料 + ITKCALL(AOM_UIF_ask_value(cmantr, "zt2_SZProcuretype", &zt2_SZProcuretype)); //外购不再展开投料 + printf("getBomMessage==>%s\n", os); StBomBean bean; bean.bomline = cBomLine; bean.currentName = cName; @@ -221,11 +226,11 @@ void getBomMessage(vector &stBomlines, tag_t cBomLine) { } } //虚拟向下展开,实体投料 -void autoFeedLike(tag_t towGxLine, StBomBean& pBean, vector& stBomlines,double xnQty) { +void autoFeedLike(tag_t towGxLine, StBomBean& pBean, vector& stBomlines, double xnQty) { if (!pBean.st) { char* qty; tag_t line = pBean.bomline; - AOM_ask_value_string(line,"bl_quantity",&qty); + ITKCALL(AOM_ask_value_string(line,"bl_quantity",&qty)); if (strcmp(qty,"") == 0) { qty = "1"; } @@ -237,16 +242,20 @@ void autoFeedLike(tag_t towGxLine, StBomBean& pBean, vector& stBomlin } } else if (!pBean.istl) { + auto start = std::chrono::high_resolution_clock::now(); pBean.istl = true; - tag_t newChild; - tag_t *c_line_tags; - int c_line_count; + tag_t newChild = NULLTAG; + tag_t *c_line_tags = NULLTAG; + int c_line_count = 0; ITKCALL(BOM_line_ask_all_child_lines(towGxLine, &c_line_count, &c_line_tags)); // 一级工序 - string bl_seq = to_string((c_line_count+1) * 10); - char *bl_qty; + string bl_seq = to_string((c_line_count + 1) * 10); + //auto time1 = std::chrono::high_resolution_clock::now(); + //std::chrono::duration elapsed1 = time1 - start; + //printf("time1:%f\n", elapsed1.count()); - AOM_ask_value_string(pBean.bomline,"bl_quantity",&bl_qty); + char *bl_qty = NULL; + ITKCALL(AOM_ask_value_string(pBean.bomline,"bl_quantity",&bl_qty)); double x = atof(bl_qty); double xx = xnQty * x; string bl_quantity = bl_qty; @@ -256,16 +265,35 @@ void autoFeedLike(tag_t towGxLine, StBomBean& pBean, vector& stBomlin else { bl_quantity = to_string(xx); } + //auto time2 = std::chrono::high_resolution_clock::now(); + //std::chrono::duration elapsed2 = time2 - time1; + //printf("%s,time2:%f\n", bl_quantity.c_str(), elapsed2.count()); + ITKCALL(BOM_line_copy(towGxLine, pBean.bomline, NULLTAG, &newChild)); - printf("bl_quantity==>%s\n", bl_quantity.c_str()); - ITKCALL(AOM_lock(newChild)); // bl_occ_type + char *uid = NULL, *os = NULL, *os2 = NULL; + ITKCALL(AOM_ask_value_string(newChild, "object_string", &uid)); + ITKCALL(AOM_ask_value_string(pBean.bomline, "object_string", &os)); + ITKCALL(AOM_ask_value_string(towGxLine, "object_string", &os2)); + //ITKCALL(POM_tag_to_uid(towGxLine, &os2)); + //ITKCALL(POM_tag_to_uid(pBean.bomline, &os)); + //ITKCALL(POM_tag_to_uid(newChild, &uid)); + printf("%s:%s:%s:bl_quantity==>%s\n", os2, os, uid, bl_quantity.c_str()); + (AOM_lock(newChild)); // bl_occ_type //设置事例类型 ITKCALL(AOM_set_value_string(newChild, "bl_sequence_no", bl_seq.c_str())); ITKCALL(AOM_set_value_string(newChild, "bl_quantity", bl_quantity.c_str())); ITKCALL(AOM_set_value_string(newChild,"bl_occ_type","MEConsumed")); - ITKCALL(AOM_save(newChild)); - ITKCALL(AOM_unlock(newChild)); + (AOM_save(newChild)); + (AOM_unlock(newChild)); + DOFREE(c_line_tags); + DOFREE(bl_qty); + DOFREE(uid); + DOFREE(os); + DOFREE(os2); + auto end = std::chrono::high_resolution_clock::now(); + std::chrono::duration elapsed = end - start; + printf("autoFeedLike time:%f\n", elapsed.count()); } } void autoFeedLike(tag_t towGxLine, StBomBean& pBean, string name2, vector& stBomlines) { @@ -285,25 +313,31 @@ void autoFeedLike(tag_t towGxLine, StBomBean& pBean, string name2, vector& stBomlines, FeedRule bean, st tag_t ebom_window = NULLTAG; tag_t bom_line = NULLTAG; tag_t item_tag = NULLTAG, *c_line_tags; - (BOM_create_window(&ebom_window)); + ITKCALL(BOM_create_window(&ebom_window)); tag_t* bvr_list = NULL; - (ITEM_rev_list_bom_view_revs(meprocess, &bvr_count, &bvr_list)); + ITKCALL(ITEM_rev_list_bom_view_revs(meprocess, &bvr_count, &bvr_list)); printf("bvr_count=%d", bvr_count); - (BOM_set_window_top_line_bvr(ebom_window, bvr_list[0], &bom_line)); //顶层bom获取 + ITKCALL(BOM_set_window_top_line_bvr(ebom_window, bvr_list[0], &bom_line)); //顶层bom获取 //bom_line工艺 - int c_line_count; + int c_line_count = 0; ITKCALL(BOM_line_ask_all_child_lines(bom_line, &c_line_count, &c_line_tags)); // 一级工序 //一级工序 for (int i = 0; i < c_line_count; i++) { @@ -330,17 +364,17 @@ void startFeed(tag_t meprocess, vector& stBomlines, FeedRule bean, st char* yjName; tag_t yjGx; ITKCALL(AOM_ask_value_tag(oneGx, "bl_line_object", &yjGx)); - AOM_ask_value_string(yjGx, "object_name", &yjName); + ITKCALL(AOM_ask_value_string(yjGx, "object_name", &yjName)); printf("yjName%s %s \n", yjName, bean.yjgx.c_str()); if (bean.yjgx.compare(yjName) == 0) { - BOM_line_ask_all_child_lines(oneGx, &c_cnt, &towGxLines); + ITKCALL(BOM_line_ask_all_child_lines(oneGx, &c_cnt, &towGxLines)); //二级工序 for (int j = 0; j < c_cnt; j++) { tag_t towGxLine = towGxLines[j]; char* ejName; tag_t ejGx; ITKCALL(AOM_ask_value_tag(towGxLine, "bl_line_object", &ejGx)); - AOM_ask_value_string(ejGx, "object_name", &ejName); + ITKCALL(AOM_ask_value_string(ejGx, "object_name", &ejName)); printf("ejName%s %s\n", ejName, bean.ejgx.c_str()); if (bean.ejgx.compare(ejName) == 0) { printf("stBomlines %zd\n", stBomlines.size()); @@ -359,8 +393,10 @@ void startFeed(tag_t meprocess, vector& stBomlines, FeedRule bean, st } } } - BOM_save_window(ebom_window); - BOM_close_window(ebom_window); + ITKCALL(BOM_save_window(ebom_window)); + ITKCALL(BOM_close_window(ebom_window)); + DOFREE(bvr_list); + DOFREE(c_line_tags); } //匹配一级工序和二级工序,名称 void startFeed(tag_t meprocess, vector& stBomlines, FeedRule bean, vector names) { @@ -368,12 +404,12 @@ void startFeed(tag_t meprocess, vector& stBomlines, FeedRule bean, ve tag_t ebom_window = NULLTAG; tag_t bom_line = NULLTAG; tag_t item_tag = NULLTAG, *c_line_tags; - (BOM_create_window(&ebom_window)); + ITKCALL(BOM_create_window(&ebom_window)); tag_t* bvr_list = NULL; - (ITEM_rev_list_bom_view_revs(meprocess, &bvr_count, &bvr_list)); + ITKCALL(ITEM_rev_list_bom_view_revs(meprocess, &bvr_count, &bvr_list)); printf("bvr_count=%d", bvr_count); - (BOM_set_window_top_line_bvr(ebom_window, bvr_list[0], &bom_line)); //顶层bom获取 + ITKCALL(BOM_set_window_top_line_bvr(ebom_window, bvr_list[0], &bom_line)); //顶层bom获取 //bom_line工艺 int c_line_count; ITKCALL(BOM_line_ask_all_child_lines(bom_line, &c_line_count, &c_line_tags)); // 一级工序 @@ -384,16 +420,16 @@ void startFeed(tag_t meprocess, vector& stBomlines, FeedRule bean, ve char* yjName; tag_t yjGx; ITKCALL(AOM_ask_value_tag(oneGx, "bl_line_object", &yjGx)); - AOM_ask_value_string(yjGx, "object_name", &yjName); + ITKCALL(AOM_ask_value_string(yjGx, "object_name", &yjName)); if (bean.yjgx.compare(yjName) == 0) { - BOM_line_ask_all_child_lines(oneGx, &c_cnt, &towGxLines); + ITKCALL(BOM_line_ask_all_child_lines(oneGx, &c_cnt, &towGxLines)); //二级工序 for (int j = 0; j < c_cnt; j++) { tag_t towGxLine = towGxLines[j]; char* ejName; tag_t ejGx; ITKCALL(AOM_ask_value_tag(towGxLine, "bl_line_object", &ejGx)); - AOM_ask_value_string(ejGx, "object_name", &ejName); + ITKCALL(AOM_ask_value_string(ejGx, "object_name", &ejName)); if (bean.ejgx.compare(ejName) == 0) { cutGxLine(towGxLine); for (int t = 0; t < stBomlines.size(); t++) { @@ -403,7 +439,7 @@ void startFeed(tag_t meprocess, vector& stBomlines, FeedRule bean, ve printf("stBom.currentName2%s %d\n", stBom.currentName.c_str(), !stBom.istl); if (!stBom.istl) { //投料 未投料的 - autoFeedLike(towGxLine, stBom, stBomlines,1); + autoFeedLike(towGxLine, stBom, stBomlines, 1); stBom.istl = true; } } @@ -412,31 +448,33 @@ void startFeed(tag_t meprocess, vector& stBomlines, FeedRule bean, ve } } } - BOM_save_window(ebom_window); - BOM_close_window(ebom_window); + ITKCALL(BOM_save_window(ebom_window)); + ITKCALL(BOM_close_window(ebom_window)); + DOFREE(bvr_list); + DOFREE(c_line_tags); } -void startFeed(tag_t meprocess, vector& stBomlines, FeedRule bean, string nameLike) { +void startFeed(tag_t meprocess, vector& stBomlines, FeedRule bean, string nameLike) {//89 int bvr_count = 0; tag_t ebom_window = NULLTAG; tag_t bom_line = NULLTAG; tag_t item_tag = NULLTAG, *c_line_tags; - (BOM_create_window(&ebom_window)); + ITKCALL(BOM_create_window(&ebom_window)); tag_t* bvr_list = NULL; - (ITEM_rev_list_bom_view_revs(meprocess, &bvr_count, &bvr_list)); + ITKCALL(ITEM_rev_list_bom_view_revs(meprocess, &bvr_count, &bvr_list)); printf("bvr_count=%d", bvr_count); - (BOM_set_window_top_line_bvr(ebom_window, bvr_list[0], &bom_line)); //顶层bom获取 + ITKCALL(BOM_set_window_top_line_bvr(ebom_window, bvr_list[0], &bom_line)); //顶层bom获取 //bom_line工艺 int c_line_count; ITKCALL(BOM_line_ask_all_child_lines(bom_line, &c_line_count, &c_line_tags)); // 一级工序 //一级工序 for (int i = 0; i < c_line_count; i++) { - tag_t oneGx = c_line_tags[i], *towGxLines; + tag_t oneGx = c_line_tags[i], *towGxLines = NULL; int c_cnt = 0; - char* yjName; - tag_t yjGx; + char* yjName = NULL; + tag_t yjGx = NULLTAG; ITKCALL(AOM_ask_value_tag(oneGx, "bl_line_object", &yjGx)); - AOM_ask_value_string(yjGx, "object_name", &yjName); + ITKCALL(AOM_ask_value_string(yjGx, "object_name", &yjName)); printf("yjName===>%s %s \n", yjName, bean.yjgx.c_str()); boolean falg = false; if (strstr(bean.yjgx.c_str(), "*") != NULL) { @@ -453,14 +491,14 @@ void startFeed(tag_t meprocess, vector& stBomlines, FeedRule bean, st } } if (bean.yjgx.compare(yjName) == 0 || falg) { - BOM_line_ask_all_child_lines(oneGx, &c_cnt, &towGxLines); + ITKCALL(BOM_line_ask_all_child_lines(oneGx, &c_cnt, &towGxLines)); //二级工序 for (int j = 0; j < c_cnt; j++) { tag_t towGxLine = towGxLines[j]; - char* ejName; - tag_t ejGx; + char* ejName = NULL; + tag_t ejGx = NULLTAG; ITKCALL(AOM_ask_value_tag(towGxLine, "bl_line_object", &ejGx)); - AOM_ask_value_string(ejGx, "object_name", &ejName); + ITKCALL(AOM_ask_value_string(ejGx, "object_name", &ejName)); printf("ejName===>%s \n", ejName); if (bean.ejgx.compare(ejName) == 0) { cutGxLine(towGxLine); @@ -474,13 +512,13 @@ void startFeed(tag_t meprocess, vector& stBomlines, FeedRule bean, st if (strstr(stBom.currentName.c_str(), nameLike.c_str()) != NULL) { printf("stBom.currentName2==>%s %d\n", stBom.currentName.c_str(), !stBom.st); if (!stBom.istl && stBom.flag) { - autoFeedLike(towGxLine, stBom, stBomlines,1); + autoFeedLike(towGxLine, stBom, stBomlines, 1); stBom.istl = true; } } } else if (!stBom.istl) { - autoFeedLike(towGxLine, stBom, stBomlines,1); + autoFeedLike(towGxLine, stBom, stBomlines, 1); stBom.istl = true; //ITKCALL(BOM_line_copy(towGxLine, stBom.bomline, NULLTAG, &newChild)); } @@ -491,8 +529,14 @@ void startFeed(tag_t meprocess, vector& stBomlines, FeedRule bean, st } } } - BOM_save_window(ebom_window); - BOM_close_window(ebom_window); + auto start = std::chrono::high_resolution_clock::now(); + ITKCALL(BOM_save_window(ebom_window)); + ITKCALL(BOM_close_window(ebom_window)); + auto end = std::chrono::high_resolution_clock::now(); + std::chrono::duration elapsed1 = end - start; + printf("BOM_save_window time:%f\n", elapsed1.count()); + DOFREE(bvr_list); + DOFREE(c_line_tags); } //map> drawMap; //map> nameMap; @@ -520,17 +564,17 @@ void AutoFeedBom(tag_t mantr,tag_t meprocess, if (drawMap.count(drawNo) > 0) { //图号匹配 vector beans = drawMap[drawNo]; - printf("beans===>%zd\n", beans.size()); + printf("beans1===>%zd\n", beans.size()); for (int t = 0; t < beans.size(); t++) { FeedRule bean = beans[t]; if (bean.tlth.empty()) { //全投 - printf("beans===>%s %s\n", bean.yjgx.c_str(), bean.ejgx.c_str()); + printf("beans2===>%s %s\n", bean.yjgx.c_str(), bean.ejgx.c_str()); startFeed(meprocess, stBomlines, bean, ""); } else { //剩下全投 - printf("beans===>%s\n", bean.tlth.c_str()); + printf("beans3===>%s\n", bean.tlth.c_str()); if (bean.tlth.compare("else") == 0) { startFeed(meprocess, stBomlines, bean, ""); } @@ -538,6 +582,7 @@ void AutoFeedBom(tag_t mantr,tag_t meprocess, string nameMatnr = bean.tlth; //按名称模糊匹配投 if (strstr(nameMatnr.c_str(), "*") != NULL) { + printf("beans4\n"); vector liVec; string nameLike; SplitTest(nameMatnr, "*", liVec); @@ -551,11 +596,13 @@ void AutoFeedBom(tag_t mantr,tag_t meprocess, else { //按名称精准匹配投料 if (strstr(nameMatnr.c_str(), "\\") != NULL) { + printf("beans5\n"); vector names; SplitTest(nameMatnr, "\\", names); startFeed(meprocess, stBomlines, bean, names[0], names[1]); } else { + printf("beans6\n"); vector names; SplitTest(nameMatnr, ";", names); startFeed(meprocess, stBomlines, bean, names); @@ -575,10 +622,10 @@ void AutoFeedBom(tag_t mantr,tag_t meprocess, AOM_ask_value_string(mantr, "object_name", &nowName); if (strstr(nowName, s.c_str()) != NULL) { vector beans = nameMap[s]; - printf("beans===>%zd\n", beans.size()); + printf("beans7===>%zd\n", beans.size()); for (int t = 0; t < beans.size(); t++) { FeedRule bean = beans[t]; - printf("beans===>%s %s\n", bean.yjgx.c_str(), bean.ejgx.c_str()); + printf("beans8===>%s %s\n", bean.yjgx.c_str(), bean.ejgx.c_str()); if (bean.tlth.empty()) { //全投 startFeed(meprocess, stBomlines, bean, ""); @@ -586,12 +633,14 @@ void AutoFeedBom(tag_t mantr,tag_t meprocess, else { //剩下全投 if (bean.tlth.compare("else") == 0) { + printf("beans9\n"); startFeed(meprocess, stBomlines, bean, ""); } else { string nameMatnr = bean.tlth; //按名称模糊匹配投 if (strstr(nameMatnr.c_str(), "*") != NULL) { + printf("beans10\n"); vector liVec; string nameLike; SplitTest(nameMatnr, "*", liVec); @@ -605,12 +654,14 @@ void AutoFeedBom(tag_t mantr,tag_t meprocess, else { //按名称精准匹配投料 if (strstr(nameMatnr.c_str(), "\\") != NULL) { + printf("beans11\n"); vector names; SplitTest(nameMatnr, "\\", names); printf("beans===>%s %s\n", names[0].c_str(), names[1].c_str()); startFeed(meprocess, stBomlines, bean, names[0], names[1]); } else { + printf("beans12\n"); vector names; SplitTest(nameMatnr, ";", names); startFeed(meprocess, stBomlines, bean, names); @@ -637,7 +688,8 @@ void readPbomMsg(tag_t bom_line, string &errBuffer, map ITKCALL(AOM_ask_value_tag(bom_line, "bl_line_object", &rev)); ITKCALL(AOM_ask_value_string(rev, "item_id", &id)); ITKCALL(AOM_ask_value_string(rev, "object_name", &objName)); - if (c_line_count > 0 && (isSt(rev) || strstr(objName, "变压器") != NULL || isback)) { + if (c_line_count > 0 && (isSt(rev) || tc_strstr(objName, "变压器") != NULL || isback)) { + auto start = std::chrono::high_resolution_clock::now(); int n_references = 0; int* levels = 0; @@ -676,6 +728,14 @@ void readPbomMsg(tag_t bom_line, string &errBuffer, map AutoFeedBom(rev, meprocess, drawMap, nameMap); } //} + auto end = std::chrono::high_resolution_clock::now(); + std::chrono::duration elapsed1 = end - start; + printf("readPbomMsg time:%f\n", elapsed1.count()); + } + else { + char *os = NULL; + ITKCALL(AOM_ask_value_string(bom_line, "object_string", &os)); + printf("readPbomMsg else===>%s\n", os); } for (int i = 0; i < c_line_count; i++) { readPbomMsg(c_line_tags[i], errBuffer, drawMap, nameMap, loginId, false); @@ -684,19 +744,22 @@ void readPbomMsg(tag_t bom_line, string &errBuffer, map //int EbomToPMethod(void *returnValue); int AutoFeeding(void *returnValue) { + printf("******************* AutoFeeding start *******************\n"); + auto start = std::chrono::high_resolution_clock::now(); string sql = "select MC,ZZMB,XH,TLTH,LX,TL,YJGX,EJGX from CHINT_GYGL_001 WHERE LX is not NULL ORDER BY XH "; + cutVec.clear(); /*string sql22 = "select CHINT_MATERIAL_SEQ.nextval as sid from dual"; int colmun2 = 0, count2 = 0; char*** outputValue2 = NULL; printf("search1"); QuerySQLNoInputParam((char*)sql22.c_str(), &colmun2, &count2, &outputValue2);*/ char *loginId; - POM_get_user_id(&loginId); + ITKCALL(POM_get_user_id(&loginId)); int ifail = ITK_ok; tag_t matnrRev; char *revUid; - ITKCALL(ifail = USERARG_get_string_argument(&revUid)); + ITKCALL(USERARG_get_string_argument(&revUid)); ITK__convert_uid_to_tag(revUid, &matnrRev); string errBuffer; @@ -704,7 +767,7 @@ int AutoFeeding(void *returnValue) { int url_num = 0; char** url_vals = NULL; - PREF_ask_char_values("database_tc", &url_num, &url_vals); + ITKCALL(PREF_ask_char_values("database_tc", &url_num, &url_vals)); string url = url_vals[0]; url.append("/").append(url_vals[2]); string errorBuff; @@ -800,7 +863,11 @@ int AutoFeeding(void *returnValue) { readPbomMsg(bom_line, errBuffer, drawMap, nameMap, loginId, isback); ITKCALL(BOM_close_window(ebom_window)); - + + auto end = std::chrono::high_resolution_clock::now(); + // 计算时间间隔 + std::chrono::duration elapsed = end - start; + printf("用时:%f\n", elapsed.count()); //readProcessBom(bom_line, errorBuff); string buff = errBuffer; diff --git a/General/General/CHINT_CHANGEBOM_TO_SRM.cxx b/General/General/CHINT_CHANGEBOM_TO_SRM.cxx new file mode 100644 index 0000000..2eca61b --- /dev/null +++ b/General/General/CHINT_CHANGEBOM_TO_SRM.cxx @@ -0,0 +1,291 @@ +#include +#include +#include +#include "epm_handler_common.h" +#include +#include +#include "common_itk_util.h" +#include "tc_util.h" +#include +#include +#include "CRUL_server_call_httpserver.h" +#include "ocilib.h" +#include "cJSON.h" +using namespace std; + + + +string getTime() +{ + stringstream ss; + time_t t = time(0); + tm* local = localtime(&t); + ss << local->tm_year + 1900 << '-'; + if (local->tm_mon < 9) + ss << "0"; + ss << local->tm_mon + 1 << '-'; + if (local->tm_mday < 10) + ss << "0"; + ss << local->tm_mday << ' '; + if (local->tm_hour < 10) + ss << "0"; + ss << local->tm_hour << ':'; + if (local->tm_min < 10) + ss << "0"; + ss << local->tm_min << ':'; + if (local->tm_sec<10) + ss << "0"; + ss << local->tm_sec; + return ss.str(); +} + +//变更对象发送到OA +int CHINT_CHANGEBOM_TO_SRM(EPM_action_message_t msg) { + + int ifail = ITK_ok; + ECHO("=========================================================\n"); + ECHO("CHINT_CHANGEBOM_TO_SRM 开始执行\n"); + ECHO("=========================================================\n"); + tag_t root_task = NULLTAG, *sub_tasks = NULL, current_task = NULLTAG, type_tag = NULLTAG; + int sub_task_count = 0, occur_of_counts = 0, url_num; + tag_t* taskAttches = NULLTAG; + tag_t cur_task = NULLTAG; + char* jobName = NULL, **url_vals = NULL; + current_task = msg.task; + ITKCALL(AOM_ask_value_string(current_task, "job_name", &jobName)); + ITKCALL(EPM_ask_root_task(msg.task, &root_task)); + ITKCALL(EPM_ask_sub_tasks(root_task, &sub_task_count, &sub_tasks)); + ITKCALL(EPM_ask_attachments(root_task, EPM_target_attachment, &occur_of_counts, &taskAttches)); + + //获取url地址 + int url_cnt = 0; + char** url = NULL, *urlId = NULL;// + ITKCALL(PREF_ask_char_values("CHINT_ChangeBOMURL", &url_cnt, &url)); + vector urls; + for (int i = 0; i < url_cnt; i++) { + vector vec1, vec2; + Split(url[i], "=", vec1); + Split(vec1[0], ":", vec2); + if (tc_strcmp(vec2[0].c_str(), "1") == 0) { + urls.push_back(vec1[1]); + } + } + if (urls.size() == 0) { + printf("CHINT_ChangeURL首选项中未找到可用地址\n"); + return ifail; + } + ITKCALL(PREF_ask_char_value("CHINT_OAUserID_RUL", 0, &urlId)); + char* log_file = NULL; + CreateLogFile("CHINT_CHANGEBOM_TO_SRM", &log_file); // + //获取当前流程目标 + //获取登陆组 + tag_t group; + char *groupName, *taskUid; + ITKCALL(POM_ask_group(&groupName, &group)); + ITKCALL(AOM_ask_value_string(group, PROP_GROUP_NAME, &groupName)); + ITK__convert_tag_to_uid(msg.task, &taskUid); //流程uid + for (int count = 0; count < occur_of_counts; count++) { + char *type; + tag_t taskTag = taskAttches[count]; + ITKCALL(AOM_ask_value_string(taskTag, "object_type", &type)); + if (strcmp(type, "ZT2_Change") == 0) { + int ref_cnt = 0; + tag_t *refs = NULLTAG; + ITKCALL(AOM_ask_value_tags(taskTag, "IMAN_reference", &ref_cnt, &refs)); + string ecnuid = ""; + tag_t bomec = NULLTAG; + for (int i = 0; i < ref_cnt; i++) { + char *type = NULL; + ITKCALL(WSOM_ask_object_type2(refs[i], &type)); + if (tc_strcmp(type, "ZT2_BOMEC") == 0) { + bomec = refs[i]; + break; + } + } + if (bomec == NULLTAG) { + continue; + } + //如果当前流程目标下的变更单,对应的影响分析如果仅包含技术工艺,无其他部门,则不需要触发此handler + char *item_id = NULL; + ITKCALL(AOM_ask_value_string(taskTag, "item_id", &item_id)); + //获取属性 查询数据库填写JSON + int property1Cnt = 0, property2Cnt = 0, property3Cnt = 0, property4Cnt = 0, property5Cnt = 0, + property6Cnt = 0, property7Cnt = 0, property8Cnt = 0, property9Cnt = 0, property10Cnt = 0, + property11Cnt = 0, property12Cnt = 0, property13Cnt = 0, property14Cnt = 0, index = 0; + char* zt2_ContractName = NULL, *zt2_WBSNo = NULL, + **zt2_property1 = NULL, **zt2_property2 = NULL, **zt2_property3 = NULL, **zt2_property4 = NULL, **zt2_property5 = NULL, + **zt2_property6 = NULL, **zt2_property7 = NULL, **zt2_property8 = NULL, **zt2_property9 = NULL, **zt2_property10 = NULL, + **zt2_property11 = NULL, **zt2_property12 = NULL, **zt2_property13 = NULL, **zt2_property14 = NULL; + date_t changeDate; + ITKCALL(AOM_ask_value_string(taskTag, "zt2_WBSNo", &zt2_WBSNo));//wbs号 + ITKCALL(AOM_ask_value_string(taskTag, "zt2_ContractName", &zt2_ContractName)); // 合同名称 + ITKCALL(AOM_UIF_ask_values(bomec, "zt2_property1", &property1Cnt, &zt2_property1));// + ITKCALL(AOM_ask_value_strings(bomec, "zt2_property2", &property2Cnt, &zt2_property2));// + ITKCALL(AOM_UIF_ask_values(bomec, "zt2_property3", &property3Cnt, &zt2_property3));// + ITKCALL(AOM_UIF_ask_values(bomec, "zt2_property4", &property4Cnt, &zt2_property4));// + ITKCALL(AOM_UIF_ask_values(bomec, "zt2_property5", &property5Cnt, &zt2_property5));// + ITKCALL(AOM_UIF_ask_values(bomec, "zt2_property6", &property6Cnt, &zt2_property6));// + ITKCALL(AOM_UIF_ask_values(bomec, "zt2_property7", &property7Cnt, &zt2_property7));// + ITKCALL(AOM_UIF_ask_values(bomec, "zt2_property8", &property8Cnt, &zt2_property8));// + ITKCALL(AOM_UIF_ask_values(bomec, "zt2_property9", &property9Cnt, &zt2_property9));// + ITKCALL(AOM_UIF_ask_values(bomec, "zt2_property10", &property10Cnt, &zt2_property10));// + ITKCALL(AOM_ask_value_strings(bomec, "zt2_property11", &property11Cnt, &zt2_property11));// + ITKCALL(AOM_ask_value_strings(bomec, "zt2_property12", &property12Cnt, &zt2_property12));// + ITKCALL(AOM_ask_value_strings(bomec, "zt2_property13", &property13Cnt, &zt2_property13));// + ITKCALL(AOM_UIF_ask_values(bomec, "zt2_property13", &property14Cnt, &zt2_property14));// + if (property1Cnt > index) index = property1Cnt; + if (property2Cnt > index) index = property2Cnt; + if (property3Cnt > index) index = property3Cnt; + if (property4Cnt > index) index = property4Cnt; + if (property5Cnt > index) index = property5Cnt; + if (property6Cnt > index) index = property6Cnt; + if (property7Cnt > index) index = property7Cnt; + if (property8Cnt > index) index = property8Cnt; + if (property9Cnt > index) index = property9Cnt; + if (property10Cnt > index) index = property10Cnt; + if (property11Cnt > index) index = property11Cnt; + if (property12Cnt > index) index = property12Cnt; + if (property13Cnt > index) index = property13Cnt; + if (property14Cnt > index) index = property14Cnt; + + //ITKCALL(POM_get_user_id(&userId)); + tag_t user = NULLTAG; + char* userId = NULL; + ITKCALL(AOM_ask_value_tag(taskTag, "owning_user", &user)); + ITKCALL(AOM_ask_value_string(user, "user_id", &userId)); + string date = getTime(); + //json添加字段 + /*S_ProductFeature 产品特性 字符串 A; B; C + S_GCFeeature 过程特性 字符串 A; B; C*/ + //cJSON_AddStringToObject(paramValue, S_GCDM, groupName);//工厂 + cJSON* datas = cJSON_CreateArray(); + for (int i = 0; i < index; i++) { + cJSON* data = cJSON_CreateObject(); + if (i < property1Cnt) { + cJSON_AddStringToObject(data, "ZCITEM", zt2_property1[i]); + } + else { + cJSON_AddStringToObject(data, "ZCITEM", ""); + } + cJSON_AddStringToObject(data, "ZCORDER", item_id); + cJSON_AddStringToObject(data, "POSID", zt2_WBSNo); + cJSON_AddStringToObject(data, "WERKS", groupName); + cJSON_AddStringToObject(data, "POST1", zt2_ContractName); + if (i < property2Cnt) { + cJSON_AddStringToObject(data, "ZCFLAG", zt2_property2[i]); + } + else { + cJSON_AddStringToObject(data, "ZCFLAG", ""); + } + if (i < property3Cnt) { + cJSON_AddStringToObject(data, "MATNR", zt2_property3[i]); + } + else { + cJSON_AddStringToObject(data, "MATNR", ""); + } + if (i < property4Cnt) { + cJSON_AddStringToObject(data, "MAKTX", zt2_property4[i]); + } + else { + cJSON_AddStringToObject(data, "MAKTX", ""); + } + if (i < property5Cnt) { + cJSON_AddStringToObject(data, "ZOLD_IDNRK", zt2_property5[i]); + } + else { + cJSON_AddStringToObject(data, "ZOLD_IDNRK", ""); + } + if (i < property6Cnt) { + cJSON_AddStringToObject(data, "ZOLD_MAKTX", zt2_property6[i]); + } + else { + cJSON_AddStringToObject(data, "ZOLD_MAKTX", ""); + } + if (i < property7Cnt) { + cJSON_AddStringToObject(data, "ZOLD_UNIT", zt2_property7[i]); + } + else { + cJSON_AddStringToObject(data, "ZOLD_UNIT", ""); + } + if (i < property8Cnt) { + cJSON_AddStringToObject(data, "ZNEW_IDNRK", zt2_property8[i]); + } + else { + cJSON_AddStringToObject(data, "ZNEW_IDNRK", ""); + } + if (i < property9Cnt) { + cJSON_AddStringToObject(data, "ZNEW_MAKTX", zt2_property9[i]); + } + else { + cJSON_AddStringToObject(data, "ZNEW_MAKTX", ""); + } + if (i < property10Cnt) { + cJSON_AddStringToObject(data, "ZNEW_UNIT", zt2_property10[i]); + } + else { + cJSON_AddStringToObject(data, "ZNEW_UNIT", ""); + } + if (i < property11Cnt) { + cJSON_AddStringToObject(data, "ZZYYDL", zt2_property11[i]); + } + else { + cJSON_AddStringToObject(data, "ZZYYDL", ""); + } + if (i < property12Cnt) { + cJSON_AddStringToObject(data, "ZZYYXL", zt2_property12[i]); + } + else { + cJSON_AddStringToObject(data, "ZZYYXL", ""); + } + if (i < property13Cnt) { + cJSON_AddStringToObject(data, "ZPRO_TYPE", zt2_property13[i]); + } + else { + cJSON_AddStringToObject(data, "ZPRO_TYPE", ""); + } + if (i < property14Cnt) { + cJSON_AddStringToObject(data, "ZPRO_DES", zt2_property14[i]); + } + else { + cJSON_AddStringToObject(data, "ZPRO_DES", ""); + } + cJSON_AddStringToObject(data, "ZNAME", userId); + cJSON_AddStringToObject(data, "ZDATE", date.c_str()); + + cJSON_AddItemToArray(datas, data); + } + + string email = userId; + email.append("@chint.com"); + string userXML = getUserIdOA(email, urlId); + string userCode = readXmlId(userXML); + + char *json_to_char = cJSON_Print(datas); + WriteLog("\nworkflowCode=EH_TE_ChangeNotice\nuserCode=%s\nfinishStart=true\n", userCode.c_str()); + WriteLog("组织之后的JSON\n %s\n", json_to_char); + string returnMsg = "";// ecnSendOA(userCode.c_str(), json_to_char, url); + for (int i = 0; i < urls.size(); i++) { + returnMsg.append(ecnSendOA(userCode.c_str(), json_to_char, urls[i])); + } + WriteLog("回传信息\n %s\n", returnMsg.c_str()); + if (!returnMsg.empty()) { + ITKCALL(EMH_store_error_s1(EMH_severity_user_error, EMH_USER_error_base, returnMsg.c_str())); + } + } + + } + CloseLog(); + //string str = uploadMinio("uploadMinio.jar", log_file); + char date_string[MAX_PATH_LENGTHE], logFileName[MAX_PATH_LENGTHE];; + time_t now; + struct tm *p; + time(&now); + //current_time(&status_now); + p = localtime(&now); + memset(date_string, 0, sizeof(date_string)); + sprintf(date_string, "%4d%02d%02d%02d%02d%02d", 1900 + p->tm_year, p->tm_mon + 1, p->tm_mday, p->tm_hour, p->tm_min, p->tm_sec); + sprintf(logFileName, "%s\\%s_%s.log", LOG_PATH, taskUid, date_string); + //file_xcopy_stod(log_file, logFileName); + //printf("str %s \n", str.c_str()); + return ifail; +} \ No newline at end of file diff --git a/General/General/CHINT_Ecn_SendOA.cxx b/General/General/CHINT_Ecn_SendOA.cxx index 3ce9238..f8cb9d6 100644 --- a/General/General/CHINT_Ecn_SendOA.cxx +++ b/General/General/CHINT_Ecn_SendOA.cxx @@ -213,23 +213,18 @@ int CHINT_ECN_SendOA(EPM_action_message_t msg) { return ifail; } //获取url地址 - char* url, *userId, *urlId;// + char* url = NULL, *urlId = NULL;// ITKCALL(PREF_ask_char_value("CHINT_ECNSendOAUrl", 0, &url)); ITKCALL(PREF_ask_char_value("CHINT_OAUserID_RUL", 0, &urlId)); char* log_file = NULL; CreateLogFile("CHINT_ECN_SendOA", &log_file); // //获取当前流程目标 connectSql(); - ITKCALL(POM_get_user_id(&userId)); - string email = userId; - email.append("@chint.com"); - string userXML = getUserIdOA(email, urlId); //获取登陆组 tag_t group; char *groupName, *taskUid; ITKCALL(POM_ask_group(&groupName, &group)); ITKCALL(AOM_ask_value_string(group, PROP_GROUP_NAME, &groupName)); - string userCode = readXmlId(userXML); ITK__convert_tag_to_uid(msg.task, &taskUid); //流程uid for (int count = 0; count < occur_of_counts; count++) { char *type; @@ -306,7 +301,15 @@ int CHINT_ECN_SendOA(EPM_action_message_t msg) { cJSON_AddStringToObject(paramValue, "S_ContractName", contractName); ITKCALL(DATE_date_to_string(changeDate, "%Y-%m-%d", &changeDateStr)); cJSON_AddStringToObject(paramValue, "T_MaterialDate", changeDateStr); - cJSON_AddStringToObject(paramValue, "S_FFBM", changeUnits[0]); + vector split; + Split(changeUnits[0], " ", split); + string ffbm = ""; + for (int i = 0; i < split.size(); i++) { + if (i > 0) + ffbm.append(";"); + ffbm.append(split[i]); + } + cJSON_AddStringToObject(paramValue, "S_FFBM", ffbm.c_str());//changeUnits[0] //EH_DrawingInformation图样信息 cJSON* infomations = getDrawingInform(taskTag); cJSON_AddItemToObject(paramValue, "EH_DrawingInformation", infomations); @@ -334,9 +337,20 @@ int CHINT_ECN_SendOA(EPM_action_message_t msg) { cJSON_AddStringToObject(paramValue, "S_XSZXZRR", xszxUUid.c_str()); cJSON_AddStringToObject(paramValue, "S_CWBZRR", cwbUUid.c_str()); + //ITKCALL(POM_get_user_id(&userId)); + tag_t user = NULLTAG; + char* userId = NULL; + ITKCALL(AOM_ask_value_tag(taskTag, "owning_user", &user)); + ITKCALL(AOM_ask_value_string(user, "user_id", &userId)); + string email = userId; + email.append("@chint.com"); + string userXML = getUserIdOA(email, urlId); + string userCode = readXmlId(userXML); + char *json_to_char = cJSON_Print(paramValue); - string returnMsg = ecnSendOA(userCode.c_str(), json_to_char, url); + WriteLog("\nworkflowCode=EH_TE_ChangeNotice\nuserCode=%s\nfinishStart=true\n", userCode.c_str()); WriteLog("组织之后的JSON\n %s\n", json_to_char); + string returnMsg = ecnSendOA(userCode.c_str(), json_to_char, url); WriteLog("回传信息\n %s\n", returnMsg.c_str()); if (!returnMsg.empty()) { ITKCALL(EMH_store_error_s1(EMH_severity_user_error, EMH_USER_error_base, returnMsg.c_str())); @@ -360,4 +374,213 @@ int CHINT_ECN_SendOA(EPM_action_message_t msg) { file_xcopy_stod(log_file, logFileName); //printf("str %s \n", str.c_str()); return ifail; +} + +//PLM推送变更通知单数据流信息 +int CHINT_CHANGEITEM_TO_SRM(EPM_action_message_t msg) { + + int ifail = ITK_ok; + ECHO("=========================================================\n"); + ECHO("CHINT_CHANGEITEM_TO_SRM 开始执行\n"); + ECHO("=========================================================\n"); + tag_t root_task = NULLTAG, *sub_tasks = NULL, current_task = NULLTAG, type_tag = NULLTAG; + int sub_task_count = 0, occur_of_counts = 0, url_num; + tag_t* taskAttches = NULLTAG; + tag_t cur_task = NULLTAG; + char* jobName = NULL, **url_vals = NULL; + current_task = msg.task; + ITKCALL(AOM_ask_value_string(current_task, "job_name", &jobName)); + ITKCALL(EPM_ask_root_task(msg.task, &root_task)); + ITKCALL(EPM_ask_sub_tasks(root_task, &sub_task_count, &sub_tasks)); + ITKCALL(EPM_ask_attachments(root_task, EPM_target_attachment, &occur_of_counts, &taskAttches)); + + //获取url地址 + int url_cnt = 0; + char** url = NULL, *urlId = NULL;// + ITKCALL(PREF_ask_char_values("CHINT_ChangeURL", &url_cnt, &url)); + vector urls; + for (int i = 0; i < url_cnt; i++) { + vector vec1, vec2; + Split(url[i], "=", vec1); + Split(vec1[0], ":", vec2); + if (tc_strcmp(vec2[0].c_str(), "1") == 0) { + urls.push_back(vec1[1]); + } + } + if (urls.size() == 0) { + printf("CHINT_ChangeURL首选项中未找到可用地址\n"); + return ifail; + } + ITKCALL(PREF_ask_char_value("CHINT_OAUserID_RUL", 0, &urlId)); + char* log_file = NULL; + CreateLogFile("CHINT_CHANGEITEM_TO_SRM", &log_file); // + //获取当前流程目标 + //获取登陆组 + tag_t group; + char *groupName, *taskUid; + ITKCALL(POM_ask_group(&groupName, &group)); + ITKCALL(AOM_ask_value_string(group, PROP_GROUP_NAME, &groupName)); + ITK__convert_tag_to_uid(msg.task, &taskUid); //流程uid + for (int count = 0; count < occur_of_counts; count++) { + char *type; + tag_t taskTag = taskAttches[count]; + ITKCALL(AOM_ask_value_string(taskTag, "object_type", &type)); + if (strcmp(type, "ZT2_Change") == 0) { + //如果当前流程目标下的变更单,对应的影响分析如果仅包含技术工艺,无其他部门,则不需要触发此handler + char *itemId = NULL; + ITKCALL(AOM_ask_value_string(taskTag, "item_id", &itemId)); + printf("id ===>%s\n", itemId); + //获取属性 查询数据库填写JSON + int unitCnt, processCnt = 0; + char* changeType, *productModel, + *productName, *fileName, *contractNo, *contractName, + *changeDateStr, **changeUnits, *changeRequestNo, **processTypes, + *wbsno = NULL, *owninguser = NULL, *releasedate = NULL; + date_t changeDate; + ITKCALL(AOM_ask_value_string(taskTag, "zt2_WBSNo", &wbsno));//wbs号 + ITKCALL(AOM_UIF_ask_value(taskTag, "owning_user", &owninguser));//变更发起人 + ITKCALL(AOM_UIF_ask_value(taskTag, "date_released", &releasedate));//发布时间 + ITKCALL(AOM_ask_value_string(taskTag, "zt2_ChangeType", &changeType));//变更类型 + ITKCALL(AOM_ask_value_string(taskTag, "zt2_ProductModel", &productModel));//产品型号 + ITKCALL(AOM_ask_value_string(taskTag, "zt2_ProductName", &productName)); // 产品名称 + ITKCALL(AOM_ask_value_string(taskTag, "zt2_FileName", &fileName)); // 文件代号及名称 + ITKCALL(AOM_ask_value_string(taskTag, "zt2_ContractNo", &contractNo)); // 合同代号 + ITKCALL(AOM_ask_value_string(taskTag, "zt2_ContractName", &contractName)); // 合同名称 + ITKCALL(AOM_ask_value_date(taskTag, "zt2_ChangeDate", &changeDate)); // 变更实施日期 + ITKCALL(AOM_ask_value_strings(taskTag, "zt2_ChangeUnit1", &unitCnt, &changeUnits)); // 合同名称 + ITKCALL(AOM_ask_value_string(taskTag, "zt2_ChangRequestNo", &changeRequestNo)); // 更改通知单号 + ITKCALL(AOM_ask_value_strings(taskTag, PROP_PROCESS, &processCnt, &processTypes)); + cJSON* paramValue = cJSON_CreateObject(); + //json添加字段 + /*S_ProductFeature 产品特性 字符串 A; B; C + S_GCFeeature 过程特性 字符串 A; B; C*/ + //cJSON_AddStringToObject(paramValue, S_GCDM, groupName);//工厂 + cJSON_AddStringToObject(paramValue, "wbsno", wbsno); + cJSON_AddStringToObject(paramValue, "owninguser", owninguser); + cJSON_AddStringToObject(paramValue, "factory", groupName); + int ref_cnt = 0; + tag_t *refs = NULLTAG; + ITKCALL(AOM_ask_value_tags(taskTag, "IMAN_reference", &ref_cnt, &refs)); + string ecnuid = ""; + bool ifbomchange = false; + for (int i = 0; i < ref_cnt; i++) { + char *type = NULL; + ITKCALL(WSOM_ask_object_type2(refs[i], &type)); + if (tc_strcmp(type, "ZT2_BOMEC") == 0) { + ifbomchange = true; + } + else if (tc_strcmp(type, "MSExcelX") == 0) { + char* uid = NULL; + ITK__convert_tag_to_uid(refs[i], &uid); + ecnuid = uid; + } + } + cJSON_AddStringToObject(paramValue, "ifbomchange", ifbomchange ? "Y" : "N"); + cJSON_AddStringToObject(paramValue, "iffilechange", ecnuid.size() > 0 ? "Y" : "N"); + cJSON_AddStringToObject(paramValue, "ecnuid", ecnuid.c_str()); + cJSON_AddStringToObject(paramValue, "releasedate", releasedate); + + string productFeature, changeTypeStr; + if (processCnt > 0) { + char *type = processTypes[0]; + if (strcmp(type, "Y") == 0) { + productFeature = S_Product; + } + else { + productFeature = S_Process; + } + } + if (strstr(changeType, S_ZSChange) != NULL) { + changeTypeStr = S_ZSChange; + } + else { + changeTypeStr = S_LSChange; + } + cJSON_AddStringToObject(paramValue, "S_ChangeTypes", changeTypeStr.c_str()); + cJSON_AddStringToObject(paramValue, "S_ProductFeature", productFeature.c_str()); + cJSON_AddStringToObject(paramValue, "S_ProductNumber", productModel); + cJSON_AddStringToObject(paramValue, "S_ProductName", productName); + cJSON_AddStringToObject(paramValue, "S_Pcodename", fileName); + cJSON_AddStringToObject(paramValue, "S_Contractcode", contractNo); + cJSON_AddStringToObject(paramValue, "S_ContractName", contractName); + ITKCALL(DATE_date_to_string(changeDate, "%Y-%m-%d", &changeDateStr)); + cJSON_AddStringToObject(paramValue, "T_MaterialDate", changeDateStr); + vector split; + Split(changeUnits[0], " ", split); + string ffbm = ""; + for (int i = 0; i < split.size(); i++) { + if (i > 0) + ffbm.append(";"); + ffbm.append(split[i]); + } + cJSON_AddStringToObject(paramValue, "S_FFBM", ffbm.c_str());//changeUnits[0] + cJSON_AddStringToObject(paramValue, "S_FFBMOther", ""); + cJSON_AddStringToObject(paramValue, "S_ChangeCode", itemId);//更改申请单号 + cJSON_AddStringToObject(paramValue, "S_PLMCode", taskUid); + cJSON_AddStringToObject(paramValue, "S_ChangeNotificationCode", changeRequestNo); + //EH_DrawingInformation图样信息 + cJSON* infomations = getDrawingInform(taskTag); + cJSON_AddItemToObject(paramValue, "EH_DrawingInformation", infomations); + string jsbUUid = "", gybUUid = "", zlbUUid = "", + scbUUid = "", cgbUUid = "", xszxUUid = "", cwbUUid = ""; + cJSON* jsbZx = getEHDepart(itemId, "技术部", jsbUUid); + cJSON_AddItemToObject(paramValue, "EH_JSBZX", jsbZx); + cJSON* gybZx = getEHDepart(itemId, "工艺部", gybUUid); + cJSON_AddItemToObject(paramValue, "EH_GYBZX", gybZx); + cJSON* zlbZx = getEHDepart(itemId, "质量部", zlbUUid); + cJSON_AddItemToObject(paramValue, "EH_ZLBZX", zlbZx); + cJSON* scbZx = getEHDepart(itemId, "生产部", scbUUid); + cJSON_AddItemToObject(paramValue, "EH_SCBZX", scbZx); + cJSON* cgbZx = getEHDepart(itemId, "采购部", cgbUUid); + cJSON_AddItemToObject(paramValue, "EH_CGBZX", cgbZx); + cJSON* saleCenter = getEHDepart(itemId, "销售中心", xszxUUid); + cJSON_AddItemToObject(paramValue, "EH_XSZXZX", saleCenter); + cJSON* cwbZx = getEHDepart(itemId, "财务部", cwbUUid); + cJSON_AddItemToObject(paramValue, "EH_CWBZX", cwbZx); + cJSON_AddStringToObject(paramValue, "S_JSBZRR", jsbUUid.c_str()); + cJSON_AddStringToObject(paramValue, "S_GYBZRR", gybUUid.c_str()); + cJSON_AddStringToObject(paramValue, "S_ZLBZRR", zlbUUid.c_str()); + cJSON_AddStringToObject(paramValue, "S_SCBZRR", scbUUid.c_str()); + cJSON_AddStringToObject(paramValue, "S_CGBZRR", cgbUUid.c_str()); + cJSON_AddStringToObject(paramValue, "S_XSZXZRR", xszxUUid.c_str()); + cJSON_AddStringToObject(paramValue, "S_CWBZRR", cwbUUid.c_str()); + + //ITKCALL(POM_get_user_id(&userId)); + tag_t user = NULLTAG; + char* userId = NULL; + ITKCALL(AOM_ask_value_tag(taskTag, "owning_user", &user)); + ITKCALL(AOM_ask_value_string(user, "user_id", &userId)); + string email = userId; + email.append("@chint.com"); + string userXML = getUserIdOA(email, urlId); + string userCode = readXmlId(userXML); + + char *json_to_char = cJSON_Print(paramValue); + WriteLog("\nworkflowCode=EH_TE_ChangeNotice\nuserCode=%s\nfinishStart=true\n", userCode.c_str()); + WriteLog("组织之后的JSON\n %s\n", json_to_char); + string returnMsg = "";// ecnSendOA(userCode.c_str(), json_to_char, url); + for (int i = 0; i < urls.size(); i++) { + returnMsg.append(ecnSendOA(userCode.c_str(), json_to_char, urls[i])).append("\n"); + } + WriteLog("回传信息\n %s\n", returnMsg.c_str()); + if (!returnMsg.empty()) { + ITKCALL(EMH_store_error_s1(EMH_severity_user_error, EMH_USER_error_base, returnMsg.c_str())); + } + } + + } + CloseLog(); + //string str = uploadMinio("uploadMinio.jar", log_file); + char date_string[MAX_PATH_LENGTHE], logFileName[MAX_PATH_LENGTHE];; + time_t now; + struct tm *p; + time(&now); + //current_time(&status_now); + p = localtime(&now); + memset(date_string, 0, sizeof(date_string)); + sprintf(date_string, "%4d%02d%02d%02d%02d%02d", 1900 + p->tm_year, p->tm_mon + 1, p->tm_mday, p->tm_hour, p->tm_min, p->tm_sec); + sprintf(logFileName, "%s\\%s_%s.log", LOG_PATH, taskUid, date_string); + file_xcopy_stod(log_file, logFileName); + //printf("str %s \n", str.c_str()); + return ifail; } \ No newline at end of file diff --git a/General/General/CloneProcess.cpp b/General/General/CloneProcess.cpp index 887ebbe..7559bb1 100644 --- a/General/General/CloneProcess.cpp +++ b/General/General/CloneProcess.cpp @@ -45,6 +45,8 @@ #include #include #include +#include +#include using namespace std; typedef struct { @@ -68,7 +70,7 @@ typedef struct { }TemGxBean; struct FlBean { - tag_t flTag=NULLTAG; + tag_t flTag = NULLTAG; string blQty; }; string getCshVal(string name, string code); @@ -92,8 +94,8 @@ void save_representation2(tag_t primaryTag, tag_t secondTag, char* relationType) ITKCALL(GRM_create_relation(primaryTag, secondTag, typeTag, NULLTAG, &relationTag));//如果关系已经存在,那么就是增加对象 ITKCALL(GRM_save_relation(relationTag));//很必要 - ITKCALL(AOM_save(primaryTag)); - ITKCALL(AOM_save(secondTag)); + (AOM_save(primaryTag)); + (AOM_save(secondTag)); ITKCALL(AOM_refresh(primaryTag, FALSE)); ITKCALL(AOM_refresh(secondTag, FALSE)); } @@ -108,7 +110,7 @@ void updateTemGxCode(tag_t processTag, map temGxMap) { printf("bvr_count=%d", bvr_count); ITKCALL(BOM_set_window_top_line_bvr(ebom_window, bvr_list[0], &bom_line)); //顶层bom获取 - //bom_line工艺 + //bom_line工艺 int c_line_count; ITKCALL(BOM_line_ask_all_child_lines(bom_line, &c_line_count, &c_line_tags)); // 一级工序 for (int i = 0; i < c_line_count; i++) { @@ -120,21 +122,21 @@ void updateTemGxCode(tag_t processTag, map temGxMap) { if (temGxMap.count(gxbm1) > 0) { char* oldName; TemGxBean temGxBean = temGxMap[gxbm1]; - ITKCALL(AOM_lock(oneGxLine)); + (AOM_lock(oneGxLine)); ITKCALL(AOM_set_value_string(oneGxLine, "bl_ZT2_FirstOPRevision_zt2_ClassificationCode", temGxBean.temGxCode.c_str())); - ITKCALL(AOM_save(oneGxLine)); + (AOM_save(oneGxLine)); AOM_unlock(oneGxLine); ITKCALL(AOM_ask_value_tag(oneGxLine, "bl_line_object", &oneGx)); ITKCALL(ITEM_ask_item_of_rev(oneGx, &gxItem)); - ITKCALL(AOM_lock(gxItem)); + (AOM_lock(gxItem)); ITKCALL(AOM_ask_value_string(gxItem, "object_name", &oldName)); ITKCALL(AOM_set_value_string(gxItem, "object_name", temGxBean.temGxName.c_str())); - ITKCALL(AOM_save(gxItem)); - ITKCALL(AOM_unlock(gxItem)); - ITKCALL(AOM_lock(oneGx)); + (AOM_save(gxItem)); + (AOM_unlock(gxItem)); + (AOM_lock(oneGx)); ITKCALL(AOM_set_value_string(oneGx, "object_name", temGxBean.temGxName.c_str())); - ITKCALL(AOM_save(oneGx)); - ITKCALL(AOM_unlock(oneGx)); + (AOM_save(oneGx)); + (AOM_unlock(oneGx)); printf("oldName===>%s\n", oldName); printf("temGxName===>%s\n", temGxBean.temGxName.c_str()); printf("temGxCode===>%s\n", temGxBean.temGxCode.c_str()); @@ -158,20 +160,20 @@ void updateTemGxCode(tag_t processTag, map temGxMap) { char* oldName, *oldName2; ITKCALL(AOM_ask_value_tag(towGxLine, "bl_line_object", &towGx)); ITKCALL(ITEM_ask_item_of_rev(towGx, &gxItem2)); - ITKCALL(AOM_lock(gxItem2)); + (AOM_lock(gxItem2)); ITKCALL(AOM_ask_value_string(gxItem2, "object_name", &oldName)); ITKCALL(AOM_set_value_string(gxItem2, "object_name", temGxBean.temGxName.c_str())); - ITKCALL(AOM_save(gxItem2)); - ITKCALL(AOM_unlock(gxItem2)); + (AOM_save(gxItem2)); + (AOM_unlock(gxItem2)); ITKCALL(AOM_ask_value_string(gxItem2, "object_name", &oldName2)); printf("oldName===>%s\n", oldName); printf("oldName2===>%s\n", oldName2); printf("temGxName===>%s\n", temGxBean.temGxName.c_str()); printf("temGxCode===>%s\n", temGxBean.temGxCode.c_str()); - ITKCALL(AOM_lock(towGx)); + (AOM_lock(towGx)); ITKCALL(AOM_set_value_string(towGx, "object_name", temGxBean.temGxName.c_str())); - ITKCALL(AOM_save(towGx)); - ITKCALL(AOM_unlock(towGx)); + (AOM_save(towGx)); + (AOM_unlock(towGx)); } @@ -179,13 +181,17 @@ void updateTemGxCode(tag_t processTag, map temGxMap) { } BOM_close_window(ebom_window); } -string getCshVal(string name,string code) { +map cshMap; +string getCshVal(string name, string code) { - string strResult; - string schVal = ""; + string strResult = "", schVal = ""; + schVal.append(name).append("@").append(code); + if (cshMap.count(schVal) > 0) { + return cshMap[schVal]; + } //cmd指令 char cmd[256] = ""; - strcpy(cmd, "java -jar "); + strcpy(cmd, "java -jar \""); //strcat(cmd, jar_file); strcat(cmd, getenv("TC_ROOT")); strcat(cmd, "\\bin\\findCshSql.jar"); @@ -193,6 +199,7 @@ string getCshVal(string name,string code) { strcat(cmd, name.c_str()); strcat(cmd, "\" \""); strcat(cmd, code.c_str()); + strcat(cmd, "\""); printf("路径:\n%s\n", cmd); char buf[8000] = { 0 }; FILE* pf = NULL; @@ -203,17 +210,19 @@ string getCshVal(string name,string code) { while (fgets(buf, sizeof buf, pf)) { strResult += buf; } + printf("接口返回:\n%s", strResult.c_str()); _pclose(pf); - vector vec; - Split(strResult,"CSHVAL:[",vec); + /*vector vec; + Split(strResult, "CSHVAL:[", vec); if (vec.size() > 0) { Split(vec[1], "]", vec); schVal = vec[0]; - } - - return schVal; + }*/ + cshMap[schVal] = strResult; + + return strResult; } -string getJdbVal(string name,string yqz,string checkcode,string draw,string modelVersion,string code,string checkCode) { +string getJdbVal(string name, string yqz, string checkcode, string draw, string modelVersion, string code, string checkCode) { string drawingno = draw.append("-").append(name); string getCode = "select checkno,NUMBEROFCHECKS from CHINT_CHECK_TITLE WHERE drawingno = '%s' and modelversion='%s' order by NUMBEROFCHECKS desc "; string getNo = "select NO from CHINT_CHECK_DETAILS_TEMPLATE where code ='%s' and modelversion = '%s' and checkCode = '%s' "; @@ -257,11 +266,12 @@ typedef struct { string mentDesc; string mentResult; }JYXBean; -void setZljyx(string gxbm2, string th,string lastId,string name,tag_t towGx) { +void setZljyx(string gxbm2, string th, string lastId, string name, tag_t towGx) { + auto start = std::chrono::high_resolution_clock::now(); string code; printf("th == >%s \n", th.c_str()); - if (strstr(th.c_str(),"-") != NULL) { + if (strstr(th.c_str(), "-") != NULL) { vector vec; Split(th, "-", vec); code.append(vec[0]).append("-").append("X"); @@ -281,6 +291,7 @@ void setZljyx(string gxbm2, string th,string lastId,string name,tag_t towGx) { QuerySQLNoInputParam(selectRxfs, &outputColumn1, &outputValueCount1, &outputValue1); printf("search result ===> %d\n", outputValueCount1); vector< JYXBean> beans; + cshMap.clear(); for (int num = 0; num < outputValueCount1; num++) { //TarGXCODE\", \"TarGXNAME\", \"TemGXCODE\", \"TemGXNAME @@ -299,12 +310,13 @@ void setZljyx(string gxbm2, string th,string lastId,string name,tag_t towGx) { bean.mentDesc = cqmanagementdesc; bean.mentNo = cqmanagementno; bean.no = cqmodelnno; + bean.mentResult = ""; if (cqmanagementresult.empty()) { if (datasource.compare("校对表") == 0) { - // string getCode = "select code,NUMBEROFCHECKS from CHINT_CHECK_TITLE WHERE drawingno = '?' order by NUMBEROFCHECKS desc "; + // string getCode = "select code,NUMBEROFCHECKS from CHINT_CHECK_TITLE WHERE drawingno = '?' order by NUMBEROFCHECKS desc "; if (checkline.compare("要求值") == 0 && !checkcode.empty()) { - bean.mentResult = getJdbVal(lastId,"designresult", checkcode, drawingno, modelversion,code, checkcode); //designresult,PROOFREADRESULT + bean.mentResult = getJdbVal(lastId, "designresult", checkcode, drawingno, modelversion, code, checkcode); //designresult,PROOFREADRESULT } else if (checkline.compare("设计值") == 0 && !checkcode.empty()) { bean.mentResult = getJdbVal(lastId, "PROOFREADRESULT", checkcode, drawingno, modelversion, code, checkcode); @@ -324,36 +336,39 @@ void setZljyx(string gxbm2, string th,string lastId,string name,tag_t towGx) { tag_t item, rev; string objName = "质量检验-"; objName.append(name); - + if (beans.size()>0) { tag_t *tableRow; ITKCALL(ITEM_create_item(NULL, objName.c_str(), "ZT2_QCHECK", NULL, &item, &rev)); - ITKCALL(AOM_save(item)); - ITKCALL(AOM_save(rev)); - ITKCALL(AOM_lock(item)); - ITKCALL(AOM_lock(rev)); + (AOM_save(item)); + (AOM_save(rev)); + (AOM_lock(item)); + (AOM_lock(rev)); ITKCALL(AOM_insert_table_rows(rev, "zt2_QCHECKS", 0, beans.size(), &tableRow)); - ITKCALL(AOM_save(rev)); - ITKCALL(AOM_unlock(rev)); - ITKCALL(AOM_save(item)); - ITKCALL(AOM_unlock(item)); + (AOM_save(rev)); + (AOM_unlock(rev)); + (AOM_save(item)); + (AOM_unlock(item)); for (int i = 0; i < beans.size(); i++) { tag_t table = tableRow[i]; - ITKCALL(AOM_lock(table)); - ITKCALL(AOM_set_value_string(table,"zt2_code", beans[i].no.c_str())); + (AOM_lock(table)); + ITKCALL(AOM_set_value_string(table, "zt2_code", beans[i].no.c_str())); ITKCALL(AOM_set_value_string(table, "zt2_jjxbh", beans[i].mentNo.c_str())); ITKCALL(AOM_set_value_string(table, "zt2_jyxmc", beans[i].mentDesc.c_str())); ITKCALL(AOM_set_value_string(table, "zt2_jyxsjjg", beans[i].mentResult.c_str())); - ITKCALL(AOM_save(table)); - ITKCALL(AOM_unlock(table)); + (AOM_save(table)); + (AOM_unlock(table)); } - ITKCALL(AOM_save(towGx)); + (AOM_save(towGx)); save_representation2(towGx, item, "ZT2_QualityCheckRelation"); } + auto setZljyx = std::chrono::high_resolution_clock::now(); + std::chrono::duration elapsed = setZljyx - start; + printf("setZljyx:%f\n", elapsed.count()); } void getGxbmMap(tag_t processTag, map& gxDocMap, map timebeans, - map> flBeanMap,string th,string lastId) { + map> flBeanMap, string th, string lastId) { int bvr_count = 0; tag_t ebom_window = NULLTAG; tag_t bom_line = NULLTAG; @@ -364,24 +379,24 @@ void getGxbmMap(tag_t processTag, map& gxDocMap, map 0) { - ITKCALL(AOM_lock(oneGx)); + (AOM_lock(oneGx)); TimeBean tbean = timebeans[gxbm1]; ITKCALL(AOM_set_value_string(oneGx, "bl_ZT2_FirstOPRevision_zt2_ArtificialTime", tbean.rgsj.c_str())); ITKCALL(AOM_set_value_string(oneGx, "bl_ZT2_FirstOPRevision_zt2_MachineTime", tbean.jqsj.c_str())); ITKCALL(AOM_set_value_string(oneGx, "bl_ZT2_FirstOPRevision_zt2_ReadinessTime", tbean.zbsj.c_str())); ITKCALL(AOM_set_value_string(oneGx, "bl_ZT2_FirstOPRevision_zt2_ProCycle", tbean.zrsczq.c_str())); - ITKCALL(AOM_save(oneGx)); - ITKCALL(AOM_unlock(oneGx)); + (AOM_save(oneGx)); + (AOM_unlock(oneGx)); } int c_cnt = 0; ITKCALL(BOM_line_ask_all_child_lines(oneGx, &c_cnt, &towGxLines)); @@ -391,20 +406,20 @@ void getGxbmMap(tag_t processTag, map& gxDocMap, map 0) { - ITKCALL(AOM_lock(towGxLine)); + (AOM_lock(towGxLine)); TimeBean tbean = timebeans[gxbm2]; ITKCALL(AOM_set_value_string(towGxLine, "bl_ZT2_FirstOPRevision_zt2_ArtificialTime", tbean.rgsj.c_str())); ITKCALL(AOM_set_value_string(towGxLine, "bl_ZT2_FirstOPRevision_zt2_MachineTime", tbean.jqsj.c_str())); ITKCALL(AOM_set_value_string(towGxLine, "bl_ZT2_FirstOPRevision_zt2_ReadinessTime", tbean.zbsj.c_str())); ITKCALL(AOM_set_value_string(towGxLine, "bl_ZT2_FirstOPRevision_zt2_ProCycle", tbean.zrsczq.c_str())); - ITKCALL(AOM_save(towGxLine)); - ITKCALL(AOM_unlock(towGxLine)); + (AOM_save(towGxLine)); + (AOM_unlock(towGxLine)); } char* name = NULL; ITKCALL(AOM_ask_value_tag(towGxLine, "bl_line_object", &towGx)); ITKCALL(AOM_ask_value_string(towGx, "object_name", &name)); //设置质检项 - setZljyx(gxbm2,th, lastId, name, towGx); + setZljyx(gxbm2, th, lastId, name, towGx); if (flBeanMap.count(gxbm2) > 0) { vector beansVec = flBeanMap[gxbm2]; printf("beansVec===>%zd\n", beansVec.size()); @@ -417,10 +432,10 @@ void getGxbmMap(tag_t processTag, map& gxDocMap, map& gxDocMap, map& gxDocMap, map& gxDocMap, map 0) { - ITKCALL(AOM_lock(oneGx)); + (AOM_lock(oneGx)); TimeBean tbean = timebeans[gxbm1]; ITKCALL(AOM_set_value_string(oneGx, "bl_ZT2_FirstOPRevision_zt2_ArtificialTime", tbean.rgsj.c_str())); ITKCALL(AOM_set_value_string(oneGx, "bl_ZT2_FirstOPRevision_zt2_MachineTime", tbean.jqsj.c_str())); ITKCALL(AOM_set_value_string(oneGx, "bl_ZT2_FirstOPRevision_zt2_ReadinessTime", tbean.zbsj.c_str())); ITKCALL(AOM_set_value_string(oneGx, "bl_ZT2_FirstOPRevision_zt2_ProCycle", tbean.zrsczq.c_str())); - ITKCALL(AOM_save(oneGx)); - ITKCALL(AOM_unlock(oneGx)); + (AOM_save(oneGx)); + (AOM_unlock(oneGx)); } int c_cnt = 0; ITKCALL(BOM_line_ask_all_child_lines(oneGx, &c_cnt, &towGxLines)); @@ -486,14 +501,14 @@ void getGxbmMap(tag_t processTag, map& gxDocMap, map 0) { - ITKCALL(AOM_lock(towGxLine)); + (AOM_lock(towGxLine)); TimeBean tbean = timebeans[gxbm2]; ITKCALL(AOM_set_value_string(towGxLine, "bl_ZT2_FirstOPRevision_zt2_ArtificialTime", tbean.rgsj.c_str())); ITKCALL(AOM_set_value_string(towGxLine, "bl_ZT2_FirstOPRevision_zt2_MachineTime", tbean.jqsj.c_str())); ITKCALL(AOM_set_value_string(towGxLine, "bl_ZT2_FirstOPRevision_zt2_ReadinessTime", tbean.zbsj.c_str())); ITKCALL(AOM_set_value_string(towGxLine, "bl_ZT2_FirstOPRevision_zt2_ProCycle", tbean.zrsczq.c_str())); - ITKCALL(AOM_save(towGxLine)); - ITKCALL(AOM_unlock(towGxLine)); + (AOM_save(towGxLine)); + (AOM_unlock(towGxLine)); } ITKCALL(AOM_ask_value_tag(towGxLine, "bl_line_object", &towGx)); gxDocMap[gxbm2] = towGx; @@ -503,8 +518,8 @@ void getGxbmMap(tag_t processTag, map& gxDocMap, map tmpProcessMap; //存放的是二级工序编码对应的二级工序版本 模板的 - //vector timeVec; - //工艺模板 + //vector timeVec; + //工艺模板 map beanMap; //根据数据库配置修改工时 getGxbmMap(revision_tag, tmpProcessMap, beanMap); @@ -693,9 +708,9 @@ tag_t clone_process_from_template(char* process_item_id, boolean isXq, string pr string materialno = outputValue3[j][0]; string ejbm = outputValue3[j][1]; string quantity = outputValue3[j][2]; - tag_t fltag,flRev; - ITEM_find_item(materialno.c_str(),&fltag); - ITEM_ask_latest_rev(fltag,&flRev); + tag_t fltag, flRev; + ITEM_find_item(materialno.c_str(), &fltag); + ITEM_ask_latest_rev(fltag, &flRev); printf("materialno%s ejbm==%sEnd\n", materialno.c_str(), ejbm.c_str()); FlBean bean; bean.blQty = quantity; @@ -711,28 +726,28 @@ tag_t clone_process_from_template(char* process_item_id, boolean isXq, string pr } } - getGxbmMap(clone_tag, newProcessMap, beanMap, flBeanMap,th, lastId); + getGxbmMap(clone_tag, newProcessMap, beanMap, flBeanMap, th, lastId); map::iterator it; //复制“工艺守则”、“工序作业指导书” 旧逻辑 /*for (it = tmpProcessMap.begin(); it != tmpProcessMap.end(); it++) { - string gxbm = it->first; - tag_t tmpGx = it->second; - if (newProcessMap.count(gxbm) != 0) { - tag_t* procGuidBooks, *processRules; - int cnt2 = 0, cnt3 = 0; - tag_t newGx = newProcessMap[gxbm]; - ITKCALL(AOM_ask_value_tags(tmpGx, "ZT2_ProcGuidBookRelation", &cnt2, &procGuidBooks)); - ITKCALL(AOM_ask_value_tags(tmpGx, "ZT2_ProcessRuleRelation", &cnt3, &processRules)); - AOM_lock(newGx); - if (cnt2 > 0) { - ITKCALL(AOM_set_value_tags(newGx, "ZT2_ProcGuidBookRelation", cnt2, procGuidBooks)); - } - if (cnt3 > 0) { - ITKCALL(AOM_set_value_tags(newGx, "ZT2_ProcessRuleRelation", cnt3, processRules)); - } - AOM_save(newGx); - AOM_unlock(newGx); - } + string gxbm = it->first; + tag_t tmpGx = it->second; + if (newProcessMap.count(gxbm) != 0) { + tag_t* procGuidBooks, *processRules; + int cnt2 = 0, cnt3 = 0; + tag_t newGx = newProcessMap[gxbm]; + ITKCALL(AOM_ask_value_tags(tmpGx, "ZT2_ProcGuidBookRelation", &cnt2, &procGuidBooks)); + ITKCALL(AOM_ask_value_tags(tmpGx, "ZT2_ProcessRuleRelation", &cnt3, &processRules)); + AOM_lock(newGx); + if (cnt2 > 0) { + ITKCALL(AOM_set_value_tags(newGx, "ZT2_ProcGuidBookRelation", cnt2, procGuidBooks)); + } + if (cnt3 > 0) { + ITKCALL(AOM_set_value_tags(newGx, "ZT2_ProcessRuleRelation", cnt3, processRules)); + } + AOM_save(newGx); + AOM_unlock(newGx); + } }*/ //复制“工艺守则”、“工序作业指导书” 2023/12/19新增逻辑 CHINT_PROCESS_SOP_RULE 表中查询 for (it = newProcessMap.begin(); it != newProcessMap.end(); it++) { @@ -740,23 +755,23 @@ tag_t clone_process_from_template(char* process_item_id, boolean isXq, string pr tag_t newGx = it->second; queryProcessRule((char*)xqfs.c_str(), isXq, (char*)gxbm.c_str(), newGx); /*if (newProcessMap.count(gxbm) != 0) { - tag_t* procGuidBooks, *processRules; - int cnt2 = 0, cnt3 = 0; - if (isXq) { - sprintf(selectGyId, sqlGxTime2.c_str(), productZu.c_str(), process_item_id, xqfs.c_str()); - } - tag_t newGx = newProcessMap[gxbm]; - ITKCALL(AOM_ask_value_tags(tmpGx, "ZT2_ProcGuidBookRelation", &cnt2, &procGuidBooks)); - ITKCALL(AOM_ask_value_tags(tmpGx, "ZT2_ProcessRuleRelation", &cnt3, &processRules)); - AOM_lock(newGx); - if (cnt2 > 0) { - ITKCALL(AOM_set_value_tags(newGx, "ZT2_ProcGuidBookRelation", cnt2, procGuidBooks)); - } - if (cnt3 > 0) { - ITKCALL(AOM_set_value_tags(newGx, "ZT2_ProcessRuleRelation", cnt3, processRules)); - } - AOM_save(newGx); - AOM_unlock(newGx); + tag_t* procGuidBooks, *processRules; + int cnt2 = 0, cnt3 = 0; + if (isXq) { + sprintf(selectGyId, sqlGxTime2.c_str(), productZu.c_str(), process_item_id, xqfs.c_str()); + } + tag_t newGx = newProcessMap[gxbm]; + ITKCALL(AOM_ask_value_tags(tmpGx, "ZT2_ProcGuidBookRelation", &cnt2, &procGuidBooks)); + ITKCALL(AOM_ask_value_tags(tmpGx, "ZT2_ProcessRuleRelation", &cnt3, &processRules)); + AOM_lock(newGx); + if (cnt2 > 0) { + ITKCALL(AOM_set_value_tags(newGx, "ZT2_ProcGuidBookRelation", cnt2, procGuidBooks)); + } + if (cnt3 > 0) { + ITKCALL(AOM_set_value_tags(newGx, "ZT2_ProcessRuleRelation", cnt3, processRules)); + } + AOM_save(newGx); + AOM_unlock(newGx); }*/ } //} @@ -854,7 +869,7 @@ string getClassVal(tag_t top_rev_tag, string& errMessage, ByqBean &bean) { } else if (strcmp(attr_names[ii], "稳压线圈绕线方式") == 0) { if (strcmp(attr_vals[ii], "") == 0) { - // errMessage.append("分类属性稳压线圈绕线方式为空,请检查。\n"); + // errMessage.append("分类属性稳压线圈绕线方式为空,请检查。\n"); //return ""; } else { @@ -894,7 +909,7 @@ void Split2(string strArg, string spliter, vector& ans) } } } -tag_t getTmpProcess(string cpxh, string th, string& errBuff, string& oldGyId, boolean isXq, string xqfs,string lastId) { +tag_t getTmpProcess(string cpxh, string th, string& errBuff, string& oldGyId, boolean isXq, string xqfs, string lastId) { char selectCPZ[300], selectGyId[200]; sprintf(selectCPZ, sqlCpxh.c_str(), cpxh.c_str()); int outputColumn = 0, outputValueCount = 0; @@ -1004,7 +1019,7 @@ void readProcessBom(tag_t bom_line, string& errorBuff, boolean &flag, tag_t &top ITKCALL(BOM_line_ask_all_child_lines(bom_line, &c_line_count, &c_line_tags)); char *objName; AOM_ask_value_string(mantr, "object_name", &objName); - if (c_line_count > 0 && (isXn(mantr)|| strstr(objName, "变压器") != NULL)) { + if (c_line_count > 0 && (isXn(mantr) || strstr(objName, "变压器") != NULL)) { printf("实体\n"); flag = true; //检查是否有工艺路线 @@ -1027,7 +1042,7 @@ void readProcessBom(tag_t bom_line, string& errorBuff, boolean &flag, tag_t &top } printf("hasProcess==%d\n", hasProcess); if (!hasProcess) { - char* bl_desc = NULL, * itemID = NULL; + char* bl_desc = NULL, *itemID = NULL; ITKCALL(AOM_ask_value_string(mantr, "item_id", &itemID)); printf("back==%zd\n", back.size()); if (back.size() > 0) { @@ -1178,6 +1193,8 @@ tag_t getProcess(tag_t designRev) { } int CloneTempProcess(void *returnValue) { + // 记录开始时间点 + auto start = std::chrono::high_resolution_clock::now(); int ifail = ITK_ok; char* sql = NULL, *revUid; tag_t designRev; @@ -1187,7 +1204,7 @@ int CloneTempProcess(void *returnValue) tag_t ebom_window = NULLTAG; tag_t bom_line = NULLTAG; tag_t item_tag = NULLTAG, *c_line_tags = NULLTAG; - (BOM_create_window(&ebom_window)); + ITKCALL(BOM_create_window(&ebom_window)); tag_t* bvr_list = NULL; ITKCALL(ITEM_rev_list_bom_view_revs(designRev, &bvr_count, &bvr_list)); printf("bvr_count=%d", bvr_count); @@ -1232,7 +1249,7 @@ int CloneTempProcess(void *returnValue) } boolean isback = false; tag_t meProcess = NULLTAG; - char* objName = NULL, * topId = NULL; + char* objName = NULL, *topId = NULL; string backs = ""; ITKCALL(AOM_ask_value_string(designRev, "object_name", &objName)); ITKCALL(AOM_ask_value_string(designRev, "item_id", &topId)); @@ -1240,7 +1257,7 @@ int CloneTempProcess(void *returnValue) //如果是产成品的话, 判断是否存在多个P物料 //20240203备件包工艺路线指派 int back_num = 0; - char** back_vals = NULL, * group_name = NULL; + char** back_vals = NULL, *group_name = NULL; tag_t group = NULLTAG; string tuhao; vector group_names; @@ -1262,7 +1279,7 @@ int CloneTempProcess(void *returnValue) break; } } - if(isback) + if (isback) break; } } @@ -1271,7 +1288,7 @@ int CloneTempProcess(void *returnValue) int b_refs = 0; int* b_levels = 0; tag_t* b_refs_tag = NULLTAG; - char** b_rel_name = NULL, * pcode = NULL; + char** b_rel_name = NULL, *pcode = NULL; string cpxh = ""; //判断当前物料对象是否在“产成品”文件夹(ZT2_ProjectFolder)中 ITKCALL(ITEM_ask_item_of_rev(designRev, &item_tag)); @@ -1287,7 +1304,7 @@ int CloneTempProcess(void *returnValue) ITKCALL(AOM_ask_value_tags(b_refs_tag[i], "contents", &n_projs, &projs)); for (int j = 0; j < n_projs; j++) { int n_drows = 0; - tag_t proj_rev = NULLTAG, * drows = NULLTAG; + tag_t proj_rev = NULLTAG, *drows = NULLTAG; ITKCALL(ITEM_ask_latest_rev(projs[j], &proj_rev)); ITKCALL(AOM_ask_value_tags(proj_rev, "TC_Is_Represented_By", &n_drows, &drows)); printf("n_drows:%d\n", n_drows); @@ -1304,35 +1321,35 @@ int CloneTempProcess(void *returnValue) backs.append(cpxh).append("@").append(tuhao); /*string sql = "select a.GYID from CHINT_WORKHOUR_WhProductXH a,CHINT_WORKHOUR_WhGYRule b "; sql.append("where a.COMPANYCODE=b.COMPANYCODE and a.ProductZu=b.ProductZu ") - .append("and a.COMPANYCODE='").append(group_name) - .append("' and a.ProductXH='").append(cpxh) - .append("' and b.TuHao='").append(tuhao) - .append("'"); + .append("and a.COMPANYCODE='").append(group_name) + .append("' and a.ProductXH='").append(cpxh) + .append("' and b.TuHao='").append(tuhao) + .append("'"); int outputColumn = 0, outputValueCount = 0; char*** outputValue = NULL, sqlc[1024]; tc_strcpy(sqlc, sql.c_str()); QuerySQLNoInputParam(sqlc, &outputColumn, &outputValueCount, &outputValue); if (outputValueCount > 0) { - gyid = outputValue[0][0]; + gyid = outputValue[0][0]; } for (int i = 0; i < outputValueCount; i++) { }*/ } else if (strstr(objName, "变压器") != NULL) { - tag_t *topMatnrs,*pMaterials; - int num = 0, num2=0; + tag_t *topMatnrs, *pMaterials; + int num = 0, num2 = 0; ITKCALL(AOM_ask_value_tags(designRev, "TC_Is_Represented_By", &num, &topMatnrs)); printf("num===>%d\n", num); if (num >= 1) { tag_t tzRev = topMatnrs[0]; ITKCALL(AOM_ask_value_tags(tzRev, "representation_for", &num2, &pMaterials)); for (int x = 0; x < num2; x++) { - char *pId,*zt2_ifpbom; + char *pId, *zt2_ifpbom; tag_t pMatr = pMaterials[x]; ITKCALL(AOM_ask_value_string(pMatr, "item_id", &pId)); ITKCALL(AOM_ask_value_string(pMatr, "zt2_ifpbom", &zt2_ifpbom)); - if (strcmp(pId, topId) != 0 && strcmp(zt2_ifpbom,"P")==0) { + if (strcmp(pId, topId) != 0 && strcmp(zt2_ifpbom, "P") == 0) { tag_t process = getProcess(pMatr); if (process != NULLTAG) { meProcess = process; @@ -1355,7 +1372,7 @@ int CloneTempProcess(void *returnValue) save_representation2(meProcess, matnrPrev, "IMAN_METarget"); } printf("=======\n"); - errorBuff = "当前选中的物料已经存在工艺路线.\n"; + //errorBuff = "当前选中的物料已经存在工艺路线.\n"; } else if (processTagTop != NULLTAG) { map::iterator it; @@ -1366,22 +1383,34 @@ int CloneTempProcess(void *returnValue) tag_t matnrPrev = mapByq[s]; save_representation2(processTagTop, matnrPrev, "IMAN_METarget"); } - errorBuff = "当前选中的物料已经存在工艺路线.\n"; + //errorBuff = "当前选中的物料已经存在工艺路线.\n"; } } printf("mapByq===>%zd\n", mapByq.size()); - if (hasProcess) { - errorBuff = "当前选中的物料已经存在工艺路线.\n"; - }else if ((strcmp(bl_desc, "") == 0 || strstr(bl_desc,"-")==NULL) && strstr(objName, "变压器") == NULL && !isback) { + if ((strcmp(bl_desc, "") == 0 || strstr(bl_desc, "-") == NULL) && strstr(objName, "变压器") == NULL && !isback) { errorBuff = "当前选中的物料版本没有图号信息,请检查.\n"; } else { + if (hasProcess) { + //errorBuff = "当前选中的物料已经存在工艺路线.\n"; + } POM_AM__set_application_bypass(true); tag_t topProcess = NULLTAG; boolean flag = false; printf("errorBuff==>%s\n", errorBuff.c_str()); + // 记录开始时间点 + auto start1 = std::chrono::high_resolution_clock::now(); readProcessBom(bom_line, errorBuff, flag, topProcess, notTcmBuff, backs); + // 记录结束时间点 + auto end1 = std::chrono::high_resolution_clock::now(); + + // 计算时间差,转换为秒 + auto duration1 = std::chrono::duration_cast(end1 - start1); + double elapsed_seconds1 = duration1.count(); + + // 输出耗时(秒) + std::cout << "Function call took " << elapsed_seconds1 << " seconds." << std::endl; if (topProcess != NULLTAG) { map::iterator it; for (it = mapByq.begin(); it != mapByq.end(); it++) { @@ -1395,6 +1424,18 @@ int CloneTempProcess(void *returnValue) } POM_AM__set_application_bypass(false); } + + + // 记录结束时间点 + auto end = std::chrono::high_resolution_clock::now(); + + // 计算时间差,转换为秒 + auto duration = std::chrono::duration_cast(end - start); + double elapsed_seconds = duration.count(); + + // 输出耗时(秒) + std::cout << "Function call took " << elapsed_seconds << " seconds." << std::endl; + DisConnServer(); errorBuff.append(notTcmBuff); if (errorBuff.empty()) { diff --git a/General/General/DtoEBOM2.cpp b/General/General/DtoEBOM2.cpp index 00449ab..dfccbd3 100644 --- a/General/General/DtoEBOM2.cpp +++ b/General/General/DtoEBOM2.cpp @@ -33,6 +33,7 @@ #include #include // #include "hx_custom.h" +#include #include #include "tc_log.h" // #include "jk_custom.h" @@ -53,6 +54,7 @@ struct NodeBean vector ccps;//产成品 int xnNum = 1;//虚拟件数量累乘 boolean isOutBuy = false;//记录是否外购、或者权限不是自己的 + string remark; //备注 }; bool isTcm(tag_t mantr) { int releaseCount = 0; @@ -116,8 +118,8 @@ tag_t getSapPart(tag_t designRevLine, tag_t designRev, string& errBuff, NodeBean int num = 0; tag_t* mantrs; char *type, *item_id; - AOM_ask_value_string(designRev, "object_type", &type); - AOM_ask_value_string(designRev, "item_id", &item_id); + ITKCALL(AOM_ask_value_string(designRev, "object_type", &type)); + ITKCALL(AOM_ask_value_string(designRev, "item_id", &item_id)); if (strcmp(type, "Part Revision") == 0) { return designRev; } @@ -128,12 +130,12 @@ tag_t getSapPart(tag_t designRevLine, tag_t designRev, string& errBuff, NodeBean map partsCcp; for (int i = 0; i < num; i++) { char* type, *zt2_ifpbom, *itemId; - AOM_ask_value_string(mantrs[i], "object_type", &type); - AOM_ask_value_string(mantrs[i], "zt2_ifpbom", &zt2_ifpbom); - AOM_ask_value_string(mantrs[i], "item_id", &itemId); + ITKCALL(AOM_ask_value_string(mantrs[i], "object_type", &type)); + ITKCALL(AOM_ask_value_string(mantrs[i], "zt2_ifpbom", &zt2_ifpbom)); + ITKCALL(AOM_ask_value_string(mantrs[i], "item_id", &itemId)); if (strstr(type, "Part") != NULL && strcmp(zt2_ifpbom, "P") != 0) { // tag_t matnrItem; - ITEM_ask_item_of_rev(mantrs[i], &matnrItem); + ITKCALL(ITEM_ask_item_of_rev(mantrs[i], &matnrItem)); partsCcp[itemId] = matnrItem; //partsCcp.push_back(); /*if (parts.size()==0) { @@ -149,7 +151,7 @@ tag_t getSapPart(tag_t designRevLine, tag_t designRev, string& errBuff, NodeBean for (it = partsCcp.begin(); it != partsCcp.end(); it++) { string s = it->first; tag_t partLast = partsCcp[s], partRevLast; - ITEM_ask_latest_rev(partLast, &partRevLast); + ITKCALL(ITEM_ask_latest_rev(partLast, &partRevLast)); if (parts.size() == 0) { parts.push_back(partRevLast); } @@ -163,12 +165,12 @@ tag_t getSapPart(tag_t designRevLine, tag_t designRev, string& errBuff, NodeBean map partsCcp; for (int i = 0; i < num; i++) { char* type, *zt2_ifpbom, *itemId; - AOM_ask_value_string(mantrs[i], "object_type", &type); - AOM_ask_value_string(mantrs[i], "zt2_ifpbom", &zt2_ifpbom); - AOM_ask_value_string(mantrs[i], "item_id", &itemId); + ITKCALL(AOM_ask_value_string(mantrs[i], "object_type", &type)); + ITKCALL(AOM_ask_value_string(mantrs[i], "zt2_ifpbom", &zt2_ifpbom)); + ITKCALL(AOM_ask_value_string(mantrs[i], "item_id", &itemId)); if (strstr(type, "Part") != NULL && strcmp(zt2_ifpbom, "P") != 0) { // tag_t matnrItem; - ITEM_ask_item_of_rev(mantrs[i], &matnrItem); + ITKCALL(ITEM_ask_item_of_rev(mantrs[i], &matnrItem)); partsCcp[itemId] = matnrItem; } } @@ -176,7 +178,7 @@ tag_t getSapPart(tag_t designRevLine, tag_t designRev, string& errBuff, NodeBean for (it = partsCcp.begin(); it != partsCcp.end(); it++) { string s = it->first; tag_t partLast = partsCcp[s], partRevLast; - ITEM_ask_latest_rev(partLast, &partRevLast); + ITKCALL(ITEM_ask_latest_rev(partLast, &partRevLast)); //if (parts.size() == 0) { //} parts.push_back(partRevLast); @@ -259,7 +261,7 @@ tag_t getSapPart(tag_t designRevLine, tag_t designRev, string& errBuff, NodeBean for (int i = 0; i < parts.size(); i++) { tag_t part = parts[i]; char* specPart; - AOM_ask_value_string(part, "zt2_Specifications", &specPart); + ITKCALL(AOM_ask_value_string(part, "zt2_Specifications", &specPart)); if (strcmp(specPart, spec) == 0) { return part; } @@ -285,6 +287,84 @@ tag_t getSapPart(tag_t designRevLine, tag_t designRev, string& errBuff, NodeBean }*/ } +/** +* 检查part子项 +* @param bom_line part的BOM +* @param errBuff 记录错误信息 +*/ +void checkPart(tag_t bom_line, string& errBuff) { + tag_t part = NULLTAG; + ITKCALL(AOM_ask_value_tag(bom_line, "bl_line_object", &part)); + char* name, *partId, **sealeds, **factorys, *matnr, **procureType; + ITKCALL(AOM_refresh(part, false)); + ITKCALL(AOM_ask_value_string(part, "object_name", &name)); + //printf("name%s\n", name); + int cnt2, numFac, cnt3; + //检查物料是否可用 + ITKCALL(AOM_ask_value_string(part, "item_id", &partId)); + ITKCALL(AOM_ask_value_string(part, "zt2_MaterialNo", &matnr)); + if (strcmp(matnr, "") == 0) { + string buffErr = ""; + buffErr.append("物料:").append(partId).append("/").append(name).append("没有物料编码.\n"); + size_t found = errBuff.find(buffErr); + if (found == std::string::npos) { + errBuff.append(buffErr); + } + //errBuff.append("物料:").append(partId).append("/").append(name).append("没有物料编码.\n"); + //return; + } + boolean numFlag = true; + ITKCALL(AOM_ask_value_strings(part, "zt2_SZSealedornot", &cnt2, &sealeds)); + ITKCALL(AOM_ask_value_strings(part, "zt2_SZFactory", &numFac, &factorys)); + ITKCALL(AOM_ask_value_strings(part, "zt2_SZProcuretype", &cnt3, &procureType)); //包含自制 + for (int i = 0; i < numFac; i++) { + if (strcmp(factorys[i], "M060") == 0) { + numFlag = false; + } + if (strcmp(factorys[i], "M060") == 0 && cnt2 > i) { + if (strcmp(sealeds[i], "Y") == 0) { + //errBuff.append("物料:").append(partId).append("/").append(name).append("已封存无法转换EBOM.\n"); + string buffErr = ""; + buffErr.append("物料:").append(partId).append("/").append(name).append("已封存无法转换EBOM.\n"); + size_t found = errBuff.find(buffErr); + if (found == std::string::npos) { + errBuff.append(buffErr); + } + } + //if (cnt3 > i && strstr(procureType[i], "自制") != NULL) { + // flagMat = true; + //} + } + } + char*objName; + ITKCALL(AOM_ask_value_string(part, OBJECT_NAME, &objName)); + if (numFlag && strstr(objName, CCP_NAME) == NULL) {// || (strstr(partId,"2ZD")!=NULL|| strstr(partId, "4ZD") != NULL) + string buffErr = ""; + buffErr.append("物料:").append(partId).append("/").append(name).append("物料视图没有维护,请检查.\n"); + size_t found = errBuff.find(buffErr); + if (found == std::string::npos) { + errBuff.append(buffErr); + } + //errBuff.append("物料:").append(partId).append("/").append(name).append("物料视图没有维护,请检查.\n"); + } + char *sffc = NULL; + ITKCALL(AOM_ask_value_string(part, "zt2_State", &sffc)); + if (strcmp(sffc, "D1") == 0 || strcmp(sffc, "封存") == 0) { + string buffErr = ""; + buffErr.append("物料:").append(partId).append("/").append(name).append("已封存无法转换EBOM.\n"); + size_t found = errBuff.find(buffErr); + if (found == std::string::npos) { + errBuff.append(buffErr); + } + } + int c_line_count = 0; + tag_t *c_line_tags = NULL; + ITKCALL(BOM_line_ask_all_child_lines(bom_line, &c_line_count, &c_line_tags)); + for (int i = 0; i < c_line_count; i++) { + checkPart(c_line_tags[i], errBuff); + } +} + /** * 遍历DBOM * @param bom_line DBOM的父级 @@ -293,6 +373,7 @@ tag_t getSapPart(tag_t designRevLine, tag_t designRev, string& errBuff, NodeBean * @param designRev 图纸版本 * @param flagMat 是否外购 */ + void askLineVal(NodeBean& bean, tag_t bom_line, tag_t designRev, string& errBuff, boolean &flagMat) { char* bl_quantity, *bl_plmxml_occ_xform, *bl_sequence_no, *sffc; ITKCALL(AOM_ask_value_string(bom_line, "bl_sequence_no", &bl_sequence_no)); @@ -324,7 +405,7 @@ void askLineVal(NodeBean& bean, tag_t bom_line, tag_t designRev, string& errBuff char* name, *partId, **sealeds, **factorys, *matnr, **procureType; ITKCALL(AOM_refresh(part, false)); ITKCALL(AOM_ask_value_string(part, "object_name", &name)); - printf("name%s\n", name); + //printf("name%s\n", name); int cnt2, numFac, cnt3; //检查物料是否可用 ITKCALL(AOM_ask_value_string(part, "item_id", &partId)); @@ -363,7 +444,7 @@ void askLineVal(NodeBean& bean, tag_t bom_line, tag_t designRev, string& errBuff } } char*objName; - AOM_ask_value_string(part, OBJECT_NAME, &objName); + ITKCALL(AOM_ask_value_string(part, OBJECT_NAME, &objName)); if (numFlag && strstr(objName, CCP_NAME) == NULL) {// || (strstr(partId,"2ZD")!=NULL|| strstr(partId, "4ZD") != NULL) string buffErr = ""; buffErr.append("物料:").append(partId).append("/").append(name).append("物料视图没有维护,请检查.\n"); @@ -383,11 +464,21 @@ void askLineVal(NodeBean& bean, tag_t bom_line, tag_t designRev, string& errBuff } } bean.mantr = part; + /* + tag_t ebom_window = NULLTAG, line = NULLTAG; + ITKCALL(BOM_create_window(&ebom_window)); + ITKCALL(BOM_set_window_top_line(ebom_window, NULL, part, NULLTAG, &line)); + int c_line_count = 0; + tag_t *c_line_tags = NULL; + ITKCALL(BOM_line_ask_all_child_lines(line, &c_line_count, &c_line_tags)); + for (int i = 0; i < c_line_count; i++) { + checkPart(c_line_tags[i], errBuff); + }*/ } else { char *partId, *name; - AOM_ask_value_string(designRev, "item_id", &partId); - AOM_ask_value_string(designRev, "object_name", &name); + ITKCALL(AOM_ask_value_string(designRev, "item_id", &partId)); + ITKCALL(AOM_ask_value_string(designRev, "object_name", &name)); string buffErr = ""; buffErr.append("图纸:").append(partId).append("/").append(name).append("下未找到物料对象.\n"); @@ -407,8 +498,8 @@ void askLineVal(NodeBean& bean, tag_t bom_line, tag_t designRev, string& errBuff */ string getTyjZl(tag_t bom_line, string materialutilization, tag_t desginRev, string &errMessage) { char *ZT2_TYSpecifications, *ZT2_TYWeight, *item_id; - AOM_ask_value_string(bom_line, "item_id", &item_id); - AOM_ask_value_string(bom_line, "ZT2_TYSpecifications", &ZT2_TYSpecifications); + ITKCALL(AOM_ask_value_string(bom_line, "bl_item_item_id", &item_id)); + ITKCALL(AOM_ask_value_string(bom_line, "ZT2_TYSpecifications", &ZT2_TYSpecifications)); double lyl = 0.85; char strff[21]; if (!materialutilization.empty()) { @@ -416,7 +507,7 @@ string getTyjZl(tag_t bom_line, string materialutilization, tag_t desginRev, str } if (strcmp(ZT2_TYSpecifications, "") == 0) { double weight = 0; - AOM_ask_value_double(desginRev, "zt2_DesignWeight", &weight); + ITKCALL(AOM_ask_value_double(desginRev, "zt2_DesignWeight", &weight)); if (weight == 0) { errMessage.append(item_id).append("未填写设计重量;\n"); return "0"; @@ -425,7 +516,7 @@ string getTyjZl(tag_t bom_line, string materialutilization, tag_t desginRev, str sprintf(strff, "%.3f", two); } else { - AOM_ask_value_string(bom_line, "ZT2_TYWeight", &ZT2_TYWeight); + ITKCALL(AOM_ask_value_string(bom_line, "ZT2_TYWeight", &ZT2_TYWeight)); if (strcmp(ZT2_TYWeight, "") == 0) { errMessage.append(item_id).append("未填写通用件重量;\n"); return "0"; @@ -541,16 +632,15 @@ void recyReadBom(tag_t bom_line, NodeBean& pBean, string& errBuff, string dbName return; } } - - ITKCALL(BOM_line_ask_all_child_lines(bom_line, &c_line_count, &c_line_tags)); + /*ITKCALL(BOM_line_ask_all_child_lines(bom_line, &c_line_count, &c_line_tags)); for (int i = 0; i < c_line_count; i++) { logical flag; - BOM_line_is_packed(c_line_tags[i], &flag); + ITKCALL(BOM_line_is_packed(c_line_tags[i], &flag)); if (flag) { - BOM_line_unpack(c_line_tags[i]); + ITKCALL(BOM_line_unpack(c_line_tags[i])); } } - AOM_refresh(bom_line, FALSE); + AOM_refresh(bom_line, FALSE);*/ ITKCALL(BOM_line_ask_all_child_lines(bom_line, &c_line_count, &c_line_tags)); //转换时原材料展开逻辑 if (c_line_count == 0 && !dbName.empty() && (strstr(itemId, "1ZD") != NULL || @@ -590,6 +680,7 @@ void recyReadBom(tag_t bom_line, NodeBean& pBean, string& errBuff, string dbName cBean.bl_sequence_no = "10"; cBean.bl_plmxml_occ_xform = ""; cBean.mantr = materialRev; + cBean.remark = ""; pBean.childs.push_back(cBean); } } @@ -600,45 +691,62 @@ void recyReadBom(tag_t bom_line, NodeBean& pBean, string& errBuff, string dbName //检查是否线圈 regex qq_reg2("^1ZDB5.*\\d{1,}1000X.*"); bool ret = regex_match(item_id, result, qq_reg2); + vector uidVec; for (int i = 0; i < c_line_count; i++) { logical suppressed; ITKCALL(AOM_ask_value_logical(c_line_tags[i], "bl_is_occ_suppressed", &suppressed)); if (suppressed) { continue; } + char* os = NULL; + ITKCALL(AOM_ask_value_string(c_line_tags[i], "object_string", &os)); //修改过之后之前已经是解包的状态了 logical flag; + char *remark; ITKCALL(BOM_line_is_packed(c_line_tags[i], &flag)); - //printf("flag===>%d\n", flag); + printf("flag1=%d==>%s\n", flag, os); + ITKCALL(AOM_ask_value_string(c_line_tags[i], "ZT2_Remark", &remark)); + //printf("recyReadBom:%s\n", remark); if (flag) { int count = 0; char *topNum; ITKCALL(AOM_ask_value_string(c_line_tags[i], "bl_quantity", &topNum)); tag_t* packLines; ITKCALL(BOM_line_ask_packed_lines(c_line_tags[i], &count, &packLines)); - for (int t = 0; t < count; t++) { + printf("packLines:%d\n", count); + /*for (int t = 0; t < count; t++) { tag_t c_Rev; ITKCALL(AOM_ask_value_tag(packLines[t], "bl_line_object", &c_Rev)); char* cUid; ITK__convert_tag_to_uid(c_Rev, &cUid); + //if (find(uidVec.begin(), uidVec.end(), cUid) != uidVec.end()) { + // continue; + //} + //uidVec.push_back(cUid); NodeBean cBean; cBean.revUid = cUid; cBean.designRev = c_Rev; cBean.packNum = count + 1; cBean.topNum = atoi(topNum); + cBean.remark = remark; recyReadBom(c_line_tags[i], cBean, errBuff, dbName, loginUserId); pBean.childs.push_back(cBean); - } + }*/ AOM_refresh(c_line_tags[i], FALSE); tag_t c_Rev; ITKCALL(AOM_ask_value_tag(c_line_tags[i], "bl_line_object", &c_Rev)); char* cUid; ITK__convert_tag_to_uid(c_Rev, &cUid); + /*if (find(uidVec.begin(), uidVec.end(), cUid) != uidVec.end()) { + continue; + } + uidVec.push_back(cUid);*/ NodeBean cBean; cBean.revUid = cUid; cBean.designRev = c_Rev; cBean.packNum = count + 1; cBean.topNum = atoi(topNum); + cBean.remark = remark; recyReadBom(c_line_tags[i], cBean, errBuff, dbName, loginUserId); pBean.childs.push_back(cBean); @@ -646,30 +754,34 @@ void recyReadBom(tag_t bom_line, NodeBean& pBean, string& errBuff, string dbName else { //检查E转P时的拆分逻辑 tag_t c_Rev; - char *seqNo, *c_type, *remark, *bl_quantity, *bl_line_name; + char *seqNo, *c_type, *bl_quantity, *bl_line_name; ITKCALL(AOM_ask_value_tag(c_line_tags[i], "bl_line_object", &c_Rev)); char* id; - AOM_ask_value_string(c_Rev, "item_id", &id); + ITKCALL(AOM_ask_value_string(c_Rev, "item_id", &id)); //获取BOM行的REMARK if (ret) { - AOM_ask_value_string(c_line_tags[i], "ZT2_Remark", &remark); - AOM_ask_value_string(c_line_tags[i], "bl_quantity", &bl_quantity); - AOM_ask_value_string(c_line_tags[i], "bl_line_name", &bl_line_name); + ITKCALL(AOM_ask_value_string(c_line_tags[i], "bl_quantity", &bl_quantity)); + ITKCALL(AOM_ask_value_string(c_line_tags[i], "bl_line_name", &bl_line_name)); getRemarkMsg(remark, xsLen, errBuff, bl_quantity, itemId, id, bl_line_name); } //新增逻辑 当前对象类型为ZT2_XNZJB 虚拟组件包时 进行削层处理 数量*虚拟层数量 - AOM_ask_value_string(c_Rev, "object_type", &c_type); + ITKCALL(AOM_ask_value_string(c_Rev, "object_type", &c_type)); if (strcmp(c_type, "ZT2_XNZJBRevision") == 0) { xnzjbVec.push_back(c_line_tags[i]); continue; } - AOM_ask_value_string(c_line_tags[i], "bl_sequence_no", &seqNo); + ITKCALL(AOM_ask_value_string(c_line_tags[i], "bl_sequence_no", &seqNo)); maxSeqNo = seqNo; char* cUid; ITK__convert_tag_to_uid(c_Rev, &cUid); + /*if (find(uidVec.begin(), uidVec.end(), cUid) != uidVec.end()) { + continue; + } + uidVec.push_back(cUid);*/ NodeBean cBean; cBean.revUid = cUid; cBean.designRev = c_Rev; + cBean.remark = remark; recyReadBom(c_line_tags[i], cBean, errBuff, dbName, loginUserId); pBean.childs.push_back(cBean); } @@ -705,7 +817,7 @@ void recyReadBom(tag_t bom_line, NodeBean& pBean, string& errBuff, string dbName ITKCALL(AOM_ask_value_string(designRev, "object_name", &object_name)); //printf("type===>%s\n", type); if (strcmp(type, "ZT2_Design3DRevision") == 0) { - AOM_ask_value_string(designRev, "zt2_Diagram", &zt2_Diagram); + ITKCALL(AOM_ask_value_string(designRev, "zt2_Diagram", &zt2_Diagram)); if (strcmp(zt2_Diagram, "Y") == 0 || strcmp(zt2_Diagram, "是") == 0) { return; } @@ -740,28 +852,28 @@ void recyReadBom(tag_t bom_line, NodeBean& pBean, string& errBuff, string dbName } } if (strstr(itemId, "1ZD") != NULL) { - AOM_ask_value_string(designRev, "zt2_Source", &source); + ITKCALL(AOM_ask_value_string(designRev, "zt2_Source", &source)); if (strcmp(source, "S2") == 0 || strcmp(source, "外购") == 0) { return; } } - ITKCALL(BOM_line_ask_all_child_lines(bom_line, &c_line_count, &c_line_tags)); + /*ITKCALL(BOM_line_ask_all_child_lines(bom_line, &c_line_count, &c_line_tags)); for (int i = 0; i < c_line_count; i++) { logical flag; - BOM_line_is_packed(c_line_tags[i], &flag); + ITKCALL(BOM_line_is_packed(c_line_tags[i], &flag)); if (flag) { - BOM_line_unpack(c_line_tags[i]); + ITKCALL(BOM_line_unpack(c_line_tags[i])); } } - AOM_refresh(bom_line, FALSE); + (AOM_refresh(bom_line, FALSE));*/ ITKCALL(BOM_line_ask_all_child_lines(bom_line, &c_line_count, &c_line_tags)); //转换时原材料展开逻辑 if (c_line_count == 0 && !dbName.empty() && (strstr(itemId, "1ZD") != NULL || strstr(itemId, "2ZD") != NULL || strstr(itemId, "4ZD") != NULL)) { //原材料展开 char *zt2_MaterialMark; - AOM_ask_value_string(designRev, "zt2_MaterialMark", &zt2_MaterialMark); + ITKCALL(AOM_ask_value_string(designRev, "zt2_MaterialMark", &zt2_MaterialMark)); //String zt2_MaterialMark = rev.getProperty("zt2_MaterialMark") string sql = "select materialno, materialutilization, materialunit FROM %s where materialmark = '%s'"; char selectRxfs[500]; @@ -785,8 +897,8 @@ void recyReadBom(tag_t bom_line, NodeBean& pBean, string& errBuff, string dbName string materialutilization = outputValue1[t][1]; string materialunit = outputValue1[t][2]; tag_t material, materialRev; - ITEM_find_item(materialno.c_str(), &material); - ITEM_ask_latest_rev(material, &materialRev); + ITKCALL(ITEM_find_item(materialno.c_str(), &material)); + ITKCALL(ITEM_ask_latest_rev(material, &materialRev)); string bl_qty = getTyjZl(bom_line, materialutilization, designRev, errBuff); printf("bl_qty%s\n", bl_qty.c_str()); NodeBean cBean; @@ -794,50 +906,67 @@ void recyReadBom(tag_t bom_line, NodeBean& pBean, string& errBuff, string dbName cBean.bl_sequence_no = "10"; cBean.bl_plmxml_occ_xform = ""; cBean.mantr = materialRev; + cBean.remark = ""; pBean.childs.push_back(cBean); } } string maxSeqNo; vector xnzjbVec; + vector uidVec; for (int i = 0; i < c_line_count; i++) { logical suppressed; - AOM_ask_value_logical(c_line_tags[i], "bl_is_occ_suppressed", &suppressed); + char *remark; + ITKCALL(AOM_ask_value_string(c_line_tags[i], "ZT2_Remark", &remark)); + //printf("recyReadBom2:%s\n", remark); + ITKCALL(AOM_ask_value_logical(c_line_tags[i], "bl_is_occ_suppressed", &suppressed)); if (suppressed) { continue; } //修改过之后之前已经是解包的状态了 logical flag; - BOM_line_is_packed(c_line_tags[i], &flag); - //printf("flag===>%d\n", flag); + ITKCALL(BOM_line_is_packed(c_line_tags[i], &flag)); + printf("flag2===>%d\n", flag); if (flag) { int count = 0; char *topNum; - AOM_ask_value_string(c_line_tags[i], "bl_quantity", &topNum); + ITKCALL(AOM_ask_value_string(c_line_tags[i], "bl_quantity", &topNum)); tag_t* packLines; - BOM_line_ask_packed_lines(c_line_tags[i], &count, &packLines); - for (int t = 0; t < count; t++) { + ITKCALL(BOM_line_ask_packed_lines(c_line_tags[i], &count, &packLines)); + printf("packLines:%d\n", count); + /*for (int t = 0; t < count; t++) { tag_t c_Rev; ITKCALL(AOM_ask_value_tag(packLines[t], "bl_line_object", &c_Rev)); char* cUid; ITK__convert_tag_to_uid(c_Rev, &cUid); + //打包 + //if (find(uidVec.begin(), uidVec.end(), cUid) != uidVec.end()) { + // continue; + //} + //uidVec.push_back(cUid); NodeBean cBean; cBean.revUid = cUid; cBean.designRev = c_Rev; cBean.packNum = count + 1; cBean.topNum = atoi(topNum); + cBean.remark = remark; recyReadBom(c_line_tags[i], cBean, errBuff, dbName, idVector); pBean.childs.push_back(cBean); - } + }*/ AOM_refresh(c_line_tags[i], FALSE); tag_t c_Rev; ITKCALL(AOM_ask_value_tag(c_line_tags[i], "bl_line_object", &c_Rev)); char* cUid; ITK__convert_tag_to_uid(c_Rev, &cUid); + /*if (find(uidVec.begin(), uidVec.end(), cUid) != uidVec.end()) { + continue; + } + uidVec.push_back(cUid);*/ NodeBean cBean; cBean.revUid = cUid; cBean.designRev = c_Rev; cBean.packNum = count + 1; cBean.topNum = atoi(topNum); + cBean.remark = remark; recyReadBom(c_line_tags[i], cBean, errBuff, dbName, idVector); pBean.childs.push_back(cBean); @@ -847,18 +976,23 @@ void recyReadBom(tag_t bom_line, NodeBean& pBean, string& errBuff, string dbName char *seqNo, *c_type; ITKCALL(AOM_ask_value_tag(c_line_tags[i], "bl_line_object", &c_Rev)); //新增逻辑 当前对象类型为ZT2_XNZJB 虚拟组件包时 进行削层处理 数量*虚拟层数量 - AOM_ask_value_string(c_Rev, "object_type", &c_type); + ITKCALL(AOM_ask_value_string(c_Rev, "object_type", &c_type)); if (strcmp(c_type, "ZT2_XNZJBRevision") == 0) { xnzjbVec.push_back(c_line_tags[i]); continue; } - AOM_ask_value_string(c_line_tags[i], "bl_sequence_no", &seqNo); + ITKCALL(AOM_ask_value_string(c_line_tags[i], "bl_sequence_no", &seqNo)); maxSeqNo = seqNo; char* cUid; ITK__convert_tag_to_uid(c_Rev, &cUid); + /*if (find(uidVec.begin(), uidVec.end(), cUid) != uidVec.end()) { + continue; + } + uidVec.push_back(cUid);*/ NodeBean cBean; cBean.revUid = cUid; cBean.designRev = c_Rev; + cBean.remark = remark; recyReadBom(c_line_tags[i], cBean, errBuff, dbName, idVector); pBean.childs.push_back(cBean); } @@ -889,7 +1023,7 @@ void getAllXnj(vector xnzjbVec, int maxNum, int &xxt, ITKCALL(BOM_line_ask_all_child_lines(c_line_tag, &cc_line_count, &cc_line_tags)); char *cnt, *c_type; int qtyPXn = 1; - AOM_ask_value_string(c_line_tag, "bl_quantity", &cnt); + ITKCALL(AOM_ask_value_string(c_line_tag, "bl_quantity", &cnt)); if (strcmp(cnt, "") != 0) { qtyPXn = atoi(cnt); } @@ -897,11 +1031,13 @@ void getAllXnj(vector xnzjbVec, int maxNum, int &xxt, vector xnzjbVec2; for (int j = 0; j < cc_line_count; j++) { tag_t c_Rev; - char *itemId, *object_name; + char *itemId, *object_name, *remark; ITKCALL(AOM_ask_value_tag(cc_line_tags[j], "bl_line_object", &c_Rev)); - AOM_ask_value_string(c_Rev, "object_type", &c_type); - AOM_ask_value_string(c_Rev, "item_id", &itemId); - AOM_ask_value_string(c_Rev, "object_name", &object_name); + ITKCALL(AOM_ask_value_string(c_Rev, "object_type", &c_type)); + ITKCALL(AOM_ask_value_string(c_Rev, "item_id", &itemId)); + ITKCALL(AOM_ask_value_string(c_Rev, "object_name", &object_name)); + ITKCALL(AOM_ask_value_string(cc_line_tags[j], "ZT2_Remark", &remark)); + //printf("getAllXnj:%s\n", remark); if (strcmp(c_type, "ZT2_XNZJBRevision") == 0) { printf("itemId===>%s\n", itemId); xnzjbVec2.push_back(cc_line_tags[j]); @@ -927,6 +1063,7 @@ void getAllXnj(vector xnzjbVec, int maxNum, int &xxt, string lastnum = to_string(srqNum); xxt = xxt + 1; cBean.bl_sequence_no = lastnum; + cBean.remark = remark; recyReadBom(cc_line_tags[j], cBean, errBuff, dbName, idVector); pBean.childs.push_back(cBean); } @@ -955,7 +1092,7 @@ void getAllXnj(vector xnzjbVec, int maxNum, int &xxt, ITKCALL(BOM_line_ask_all_child_lines(c_line_tag, &cc_line_count, &cc_line_tags)); char *cnt, *c_type; int qtyPXn = 1; - AOM_ask_value_string(c_line_tag, "bl_quantity", &cnt); + ITKCALL(AOM_ask_value_string(c_line_tag, "bl_quantity", &cnt)); if (strcmp(cnt, "") != 0) { //虚拟件的BOM数量 qtyPXn = atoi(cnt); @@ -964,11 +1101,13 @@ void getAllXnj(vector xnzjbVec, int maxNum, int &xxt, vector xnzjbVec2; for (int j = 0; j < cc_line_count; j++) { tag_t c_Rev; - char *itemId, *object_name; + char *itemId, *object_name, *remark; ITKCALL(AOM_ask_value_tag(cc_line_tags[j], "bl_line_object", &c_Rev)); - AOM_ask_value_string(c_Rev, "object_type", &c_type); - AOM_ask_value_string(c_Rev, "item_id", &itemId); - AOM_ask_value_string(c_Rev, "object_name", &object_name); + ITKCALL(AOM_ask_value_string(c_Rev, "object_type", &c_type)); + ITKCALL(AOM_ask_value_string(c_Rev, "item_id", &itemId)); + ITKCALL(AOM_ask_value_string(c_Rev, "object_name", &object_name)); + ITKCALL(AOM_ask_value_string(cc_line_tags[j], "ZT2_Remark", &remark)); + //printf("getAllXnj2:%s\n", remark); if (strcmp(c_type, "ZT2_XNZJBRevision") == 0) { printf("itemId===>%s\n", itemId); xnzjbVec2.push_back(cc_line_tags[j]); @@ -994,6 +1133,7 @@ void getAllXnj(vector xnzjbVec, int maxNum, int &xxt, string lastnum = to_string(srqNum); xxt = xxt + 1; cBean.bl_sequence_no = lastnum; + cBean.remark = remark; //非虚拟件的继续原逻辑展开 recyReadBom(cc_line_tags[j], cBean, errBuff, dbName, loginUserId); pBean.childs.push_back(cBean); @@ -1025,13 +1165,13 @@ string GBKToUTF8(const std::string& strGBK) string proProcessCreate(tag_t rev, string process_name) { tag_t template_tag = NULLTAG; - EPM_find_template2(process_name.c_str(), PROCESS_TEMPLATE, &template_tag); + ITKCALL(EPM_find_template2(process_name.c_str(), PROCESS_TEMPLATE, &template_tag)); tag_t new_process = NULLTAG; int *tagType = (int *)MEM_alloc(1024 * sizeof(int));//EPM_reference_attachment tag_t * itemTag = (tag_t *)MEM_alloc(1024 * sizeof(tag_t)); tagType[0] = EPM_target_attachment; itemTag[0] = rev; - EPM_create_process("快速发布", "", template_tag, 1, itemTag, tagType, &new_process); + ITKCALL(EPM_create_process("快速发布", "", template_tag, 1, itemTag, tagType, &new_process)); return "1"; } @@ -1039,11 +1179,11 @@ boolean firstRevision(tag_t designRev, tag_t mantr) { char *revId; int revNum = 0, statusNum = 0; tag_t *structure_revisions; - AOM_ask_value_string(designRev, "item_revision_id", &revId); - AOM_ask_value_tags(mantr, "structure_revisions", &revNum, &structure_revisions); + ITKCALL(AOM_ask_value_string(designRev, "item_revision_id", &revId)); + ITKCALL(AOM_ask_value_tags(mantr, "structure_revisions", &revNum, &structure_revisions)); if (revNum > 0) { tag_t struct_revision = structure_revisions[0], *release_status_list; - AOM_ask_value_tags(struct_revision, "release_status_list", &statusNum, &release_status_list); + ITKCALL(AOM_ask_value_tags(struct_revision, "release_status_list", &statusNum, &release_status_list)); if (statusNum == 0) { return false; } @@ -1112,6 +1252,7 @@ map getBomMsg(tag_t mantrRev, bool& flag) { ITKCALL(AOM_ask_value_tag(c_line_tags[t], "bl_line_object", &c_Rev)); ITKCALL(AOM_ask_value_string(c_Rev, "zt2_MaterialNo", &matnrNo)); printf("zt2_MaterialNo===>%s\n", matnrNo); + int qtyPXn = 1; ITKCALL(AOM_ask_value_string(c_line_tags[t], "bl_quantity", &cnt)); if (strcmp(cnt, "") != 0) { @@ -1240,8 +1381,11 @@ string createEbom(NodeBean topBean, boolean isTop, string &hasChange, map 0) { - string num = cBean.bl_quantity; - num = to_string(cBean.topNum / cBean.packNum); + //string num = cBean.bl_quantity; + string num = to_string(cBean.topNum);//cBean.topNum / cBean.packNum + printf("cBean.Num:%d==%d\n", cBean.topNum, cBean.packNum); ITKCALL(AOM_set_value_string(cLine, "bl_quantity", num.c_str())); } else { @@ -1314,6 +1459,10 @@ string createEbom(NodeBean topBean, boolean isTop, string &hasChange, map elapsed = time1 - start; + printf("time1:%f\n", elapsed.count()); string dbName; int url_num2 = 0; char** url_vals2 = NULL; @@ -1529,6 +1686,9 @@ int DbomToEMethod(void* returnValue) { recyReadBom(bom_line, topBean, errBuff, dbName, loginUserId); DisConnServer(); ITKCALL(BOM_close_window(ebom_window)); + auto time2 = std::chrono::high_resolution_clock::now(); + elapsed = time2 - start; + printf("time2:%f\n", elapsed.count()); //搭建BOM POM_AM__set_application_bypass(true); printf("error %s \n", errBuff.c_str()); @@ -1572,6 +1732,7 @@ int DbomToEMethod(void* returnValue) { printf("dMap[%d]", dMap.size());*/ map dMap = getDBomMesg(topBean); for (int t = 0; t < topBean.ccps.size(); t++) { + auto sub = std::chrono::high_resolution_clock::now(); tag_t mantr = topBean.ccps[t]; boolean flagChange = true; bool flag = false; @@ -1620,6 +1781,9 @@ int DbomToEMethod(void* returnValue) { ITKCALL(ITEM_ask_latest_rev(topItem, &topRev)); copyEBomLine(topRev, mantr); } + auto sub1 = std::chrono::high_resolution_clock::now(); + elapsed = sub1 - sub; + printf("sub1:%f\n", elapsed.count()); } } errBuff = "succ"; @@ -1633,6 +1797,10 @@ int DbomToEMethod(void* returnValue) { close(); printf("释放数据库成功\n"); printf("子line数量 %d \n", topBean.childs.size()); + // 计算时间间隔 + auto end = std::chrono::high_resolution_clock::now(); + elapsed = end - start; + printf("用时:%f\n", elapsed.count()); string buff = errBuff; *((char**)returnValue) = (char*)MEM_alloc((strlen(buff.c_str()) + 1) * sizeof(char)); tc_strcpy(*((char**)returnValue), buff.c_str()); @@ -1643,6 +1811,7 @@ int DbomToEMethod(void* returnValue) { * 区别在于需要通过首选项进行D转E,没有配置的不转换 */ int DbomToEMethodUser(void* returnValue) { + auto start = std::chrono::high_resolution_clock::now(); int ifail = ITK_ok; char *sql = NULL, *revUid; tag_t designRev; @@ -1660,13 +1829,16 @@ int DbomToEMethodUser(void* returnValue) { tag_t ebom_window = NULLTAG; tag_t bom_line = NULLTAG; tag_t item_tag = NULLTAG, *c_line_tags; - (BOM_create_window(&ebom_window)); + ITKCALL(BOM_create_window(&ebom_window)); tag_t* bvr_list = NULL; - (ITEM_rev_list_bom_view_revs(designRev, &bvr_count, &bvr_list)); + ITKCALL(ITEM_rev_list_bom_view_revs(designRev, &bvr_count, &bvr_list)); printf("bvr_count=%d", bvr_count); - (BOM_set_window_top_line_bvr(ebom_window, bvr_list[0], &bom_line)); //顶层bom获取 + ITKCALL(BOM_set_window_top_line_bvr(ebom_window, bvr_list[0], &bom_line)); //顶层bom获取 printf("顶层bom获取\n"); + auto bomtime = std::chrono::high_resolution_clock::now(); + std::chrono::duration elapsed = bomtime - start; + printf("bomtime:%f\n", elapsed.count()); //(BOM_line_ask_all_child_lines(bom_line, &c_line_count, &c_line_tags)); NodeBean topBean; @@ -1675,7 +1847,7 @@ int DbomToEMethodUser(void* returnValue) { int url_num = 0; char** url_vals = NULL; - PREF_ask_char_values("database_tc", &url_num, &url_vals); + ITKCALL(PREF_ask_char_values("database_tc", &url_num, &url_vals)); string url = url_vals[0]; url.append("/").append(url_vals[2]); @@ -1686,10 +1858,13 @@ int DbomToEMethodUser(void* returnValue) { printf("提示:中间数据表访问失败\n"); ifail = 1; } + auto ConnServer = std::chrono::high_resolution_clock::now(); + elapsed = ConnServer - start; + printf("ConnServer:%f\n", elapsed.count()); string dbName; int url_num2 = 0, url_num3 = 0; char** url_vals2 = NULL, **url_vals3 = NULL; - PREF_ask_char_values("CHINT_MATERIAL_RAW", &url_num2, &url_vals2); + ITKCALL(PREF_ask_char_values("CHINT_MATERIAL_RAW", &url_num2, &url_vals2)); for (int t = 0; t < url_num2; t++) { vector vec; Split(url_vals2[t], ":", vec); @@ -1698,15 +1873,21 @@ int DbomToEMethodUser(void* returnValue) { } } //配置哪些ID类别需要D转E - PREF_ask_char_values("CHINT_M060_KJTOSAP", &url_num3, &url_vals3); + ITKCALL(PREF_ask_char_values("CHINT_M060_KJTOSAP", &url_num3, &url_vals3)); vector idVector; if (url_num3 > 0) { Split(url_vals3[0], ";", idVector); } + auto time1 = std::chrono::high_resolution_clock::now(); + elapsed = time1 - start; + printf("time1:%f\n", elapsed.count()); recyReadBom(bom_line, topBean, errBuff, dbName, idVector); + auto time2 = std::chrono::high_resolution_clock::now(); + elapsed = time2 - start; + printf("time2:%f\n", elapsed.count()); DisConnServer(); - BOM_close_window(ebom_window); + ITKCALL(BOM_close_window(ebom_window)); //搭建BOM POM_AM__set_application_bypass(true); printf("error %s \n", errBuff.c_str()); @@ -1725,6 +1906,9 @@ int DbomToEMethodUser(void* returnValue) { } errBuff = "succ"; } + auto time3 = std::chrono::high_resolution_clock::now(); + elapsed = time3 - start; + printf("time3:%f\n", elapsed.count()); POM_AM__set_application_bypass(false); diff --git a/General/General/EbomToPMethod.cpp b/General/General/EbomToPMethod.cpp index 0d7b729..ace55cf 100644 --- a/General/General/EbomToPMethod.cpp +++ b/General/General/EbomToPMethod.cpp @@ -32,6 +32,7 @@ #include #include #include +#include // #include "hx_custom.h" #include "tc_log.h" // #include "jk_custom.h" @@ -159,7 +160,7 @@ void saveAsCycle(EBomBean& childPm, map& map, tag_t& topPrev) { char* newid = NULL; logical isModified = FALSE; tag_t item_type_tag; - TCTYPE_ask_type("Item", &item_type_tag); + ITKCALL(TCTYPE_ask_type("Item", &item_type_tag)); ITKCALL(USER_new_item_id(NULLTAG, item_type_tag, &isModified, &newid)); /*ITKCALL(NR_next_value("MEProcess", "item_id", NULLTAG, "", "", "", NULLTAG, "", "", &next_id));*/ @@ -167,11 +168,11 @@ void saveAsCycle(EBomBean& childPm, map& map, tag_t& topPrev) { ITKCALL(ITEM_copy_item(childPm.eRev, newid, NULL, &newItem, &newRev)); //ITKCALL(AOM_set_value_string(newRev, "zt2_PMaterial", "PBOM")); char* matnrNo; - AOM_ask_value_string(childPm.eRev, "zt2_MaterialNo", &matnrNo); + ITKCALL(AOM_ask_value_string(childPm.eRev, "zt2_MaterialNo", &matnrNo)); AOM_lock(newRev); - AOM_set_value_string(newRev, "zt2_ifpbom", "P"); - AOM_set_value_string(newRev, "zt2_MaterialNo", matnrNo); + ITKCALL(AOM_set_value_string(newRev, "zt2_ifpbom", "P")); + ITKCALL(AOM_set_value_string(newRev, "zt2_MaterialNo", matnrNo)); AOM_save(newRev); AOM_unlock(newRev); if (topPrev == NULLTAG) { @@ -181,11 +182,11 @@ void saveAsCycle(EBomBean& childPm, map& map, tag_t& topPrev) { map[eRevUid] = newRev; int num = 0, revNum = 0, tagNum = 0; tag_t* mantrs, dsuser, *structure_revisions, *bom_view_tags; - AOM_ask_value_tags(childPm.eRev, "TC_Is_Represented_By", &num, &mantrs); + ITKCALL(AOM_ask_value_tags(childPm.eRev, "TC_Is_Represented_By", &num, &mantrs)); if (num > 0) { - AOM_ask_value_tags(newRev, "structure_revisions", &revNum, &structure_revisions); - AOM_ask_value_tags(newRev, "bom_view_tags", &tagNum, &bom_view_tags); - AOM_ask_value_tag(mantrs[0], "owning_user", &dsuser); + ITKCALL(AOM_ask_value_tags(newRev, "structure_revisions", &revNum, &structure_revisions)); + ITKCALL(AOM_ask_value_tags(newRev, "bom_view_tags", &tagNum, &bom_view_tags)); + ITKCALL(AOM_ask_value_tag(mantrs[0], "owning_user", &dsuser)); tag_t defGroup; ITKCALL(AOM_ask_value_tag(dsuser, "default_group", &defGroup)); ITKCALL(AOM_set_ownership(newItem, dsuser, defGroup)); @@ -207,18 +208,18 @@ void saveAsCycle(EBomBean& childPm, map& map, tag_t& topPrev) { int bvr_count = 0, c_line_count; tag_t ebom_window = NULLTAG; tag_t bom_line = NULLTAG, *c_line_tags; - (BOM_create_window(&ebom_window)); + ITKCALL(BOM_create_window(&ebom_window)); tag_t* bvr_list = NULL; - (ITEM_rev_list_bom_view_revs(pRevs[0], &bvr_count, &bvr_list)); + ITKCALL(ITEM_rev_list_bom_view_revs(pRevs[0], &bvr_count, &bvr_list)); printf("bvr_count=%d\n", bvr_count); - (BOM_set_window_top_line_bvr(ebom_window, bvr_list[0], &bom_line)); //顶层bom获取 + ITKCALL(BOM_set_window_top_line_bvr(ebom_window, bvr_list[0], &bom_line)); //顶层bom获取 //ITKCALL(AOM_ask_value_tag(bom_line, "bl_line_object", &mantr)); ITKCALL(BOM_line_ask_all_child_lines(bom_line, &c_line_count, &c_line_tags)); for (int ind = 0; ind < c_line_count; ind++) { tag_t c_line_tag = c_line_tags[ind], mantr; - AOM_ask_value_tag(c_line_tag, "bl_line_object", &mantr); + ITKCALL(AOM_ask_value_tag(c_line_tag, "bl_line_object", &mantr)); char* eRevUid2; ITK__convert_tag_to_uid(mantr, &eRevUid2); if (strcmp(eRevUid2, eRevUid) == 0) { @@ -228,8 +229,8 @@ void saveAsCycle(EBomBean& childPm, map& map, tag_t& topPrev) { } } } - BOM_save_window(ebom_window); - BOM_close_window(ebom_window); + ITKCALL(BOM_save_window(ebom_window)); + ITKCALL(BOM_close_window(ebom_window)); } } } @@ -238,10 +239,10 @@ void getSpecs(tag_t rev, vector &vec) { int cnt; /*AOM_ask_value_string(line, "ZT2_TYSpecifications", &ZT2_TYSpecifications); if (strcmp(ZT2_TYSpecifications, "") == 0) {*/ - AOM_ask_value_tags(rev, "representation_for", &cnt, &comps); + ITKCALL(AOM_ask_value_tags(rev, "representation_for", &cnt, &comps)); char* zt2_Specifications; //if (cnt == 0) { - AOM_ask_value_string(rev, "zt2_Specifications", &zt2_Specifications); + ITKCALL(AOM_ask_value_string(rev, "zt2_Specifications", &zt2_Specifications)); vec.push_back(zt2_Specifications); // //} //} @@ -416,7 +417,7 @@ tag_t send1(tag_t rev, string now, ITKCALL(AOM_set_value_string(newRev, "zt2_ClassificationCode", "230101001")); char* zt2_unit, *newUid; ITK__convert_tag_to_uid(newRev, &newUid); - ITEM_ask_item_of_rev(rev, &pitem); + ITKCALL(ITEM_ask_item_of_rev(rev, &pitem)); ITKCALL(AOM_ask_value_string(pitem, "zt2_unit", &zt2_unit)); ITKCALL(AOM_set_value_string(newItem, "zt2_unit", zt2_unit)); @@ -488,7 +489,7 @@ void addToAmatnr(tag_t *c_line_tags, int c_line_count, int len, tag_t newPAmatnr ITKCALL(ITEM_rev_list_bom_view_revs(mantr, &bvr_count, &bvr_list)); if (bvr_count == 0) { tag_t newView, newViewBvr, pitem; - ITEM_ask_item_of_rev(mantr, &pitem); + ITKCALL(ITEM_ask_item_of_rev(mantr, &pitem)); ITKCALL(PS_create_bom_view(NULL, NULL, NULL, pitem, &newView)); AOM_save(newView); ITKCALL(PS_create_bvr(newView, NULL, NULL, FALSE, mantr, &newViewBvr)); @@ -499,33 +500,33 @@ void addToAmatnr(tag_t *c_line_tags, int c_line_count, int len, tag_t newPAmatnr ITKCALL(BOM_create_window(&ebom_window)); ITKCALL(BOM_set_window_top_line(ebom_window, NULL, mantr, NULLTAG, &bom_line)); char *name; - AOM_ask_value_string(mantr,"object_name",&name); + ITKCALL(AOM_ask_value_string(mantr,"object_name",&name)); string xqType = getXqName(name); //ABCDE for (int i = 0; i < c_line_count; i++) { tag_t newChild; char* oldQty,*seqNo,*remark,*bl_line_name; - AOM_ask_value_string(c_line_tags[i], "ZT2_Remark", &remark); + ITKCALL(AOM_ask_value_string(c_line_tags[i], "ZT2_Remark", &remark)); string msg = getRemarkMsg(remark,len); int xqLen = len; if (msg.length()>0) { xqLen = msg.length(); - if (strstr(msg.c_str(), xqType.c_str())==NULL) { + if (tc_strstr(msg.c_str(), xqType.c_str()) == NULL) { continue; } } ITKCALL(BOM_line_copy(bom_line, c_line_tags[i], NULLTAG, &newChild)); - AOM_ask_value_string(c_line_tags[i], "bl_quantity", &oldQty); - AOM_ask_value_string(c_line_tags[i], "bl_sequence_no", &seqNo); - AOM_ask_value_string(c_line_tags[i], "bl_line_name", &bl_line_name); + ITKCALL(AOM_ask_value_string(c_line_tags[i], "bl_quantity", &oldQty)); + ITKCALL(AOM_ask_value_string(c_line_tags[i], "bl_sequence_no", &seqNo)); + ITKCALL(AOM_ask_value_string(c_line_tags[i], "bl_line_name", &bl_line_name)); if (lastFlag && strstr(bl_line_name, "线") != NULL) { double blQty = atof(oldQty); int num = blQty / xqLen; double fmodVal = fmod(blQty, xqLen); double lastVal = num + fmodVal; string numNew = to_string(lastVal); - AOM_lock(newChild); - AOM_set_value_string(newChild, "bl_quantity", numNew.c_str()); - AOM_set_value_string(newChild, "bl_sequence_no", seqNo); + (AOM_lock(newChild)); + ITKCALL(AOM_set_value_string(newChild, "bl_quantity", numNew.c_str())); + ITKCALL(AOM_set_value_string(newChild, "bl_sequence_no", seqNo)); AOM_save(newChild); AOM_unlock(newChild); } @@ -534,8 +535,8 @@ void addToAmatnr(tag_t *c_line_tags, int c_line_count, int len, tag_t newPAmatnr int num = blQty / xqLen; string numNew = to_string(num); AOM_lock(newChild); - AOM_set_value_string(newChild, "bl_quantity", numNew.c_str()); - AOM_set_value_string(newChild, "bl_sequence_no", seqNo); + ITKCALL(AOM_set_value_string(newChild, "bl_quantity", numNew.c_str())); + ITKCALL(AOM_set_value_string(newChild, "bl_sequence_no", seqNo)); AOM_save(newChild); AOM_unlock(newChild); } @@ -645,8 +646,20 @@ void replaceBom(EBomBean& childPm, map& map, int len, tag_t dcpro ITKCALL(BOM_line_cut(c_line_tags[i])); } for (int t = 0; t < newPAmatnrs.size(); t++) { - tag_t bomLineAdd; + tag_t bomLineAdd = NULLTAG; ITKCALL(BOM_line_add(bom_line, NULLTAG, newPAmatnrs[t], NULLTAG, &bomLineAdd)); + char *name = NULL; + ITKCALL(AOM_ask_value_string(newPAmatnrs[t], "object_name", &name)); + string seqNo = ""; + if (tc_strstr(name, "A相") != NULL) { + seqNo = "10"; + }else if (tc_strstr(name, "B相") != NULL) { + seqNo = "20"; + } + else if(tc_strstr(name, "C相") != NULL) { + seqNo = "30"; + } + ITKCALL(AOM_set_value_string(bomLineAdd, "bl_sequence_no", seqNo.c_str())); } //ITKCALL(AOM_save(bom_line)); ITKCALL(BOM_save_window(ebom_window)); @@ -664,7 +677,7 @@ void replaceBom(EBomBean& childPm, map& map, int len, tag_t dcpro //获取分类属性 判断是否整除 int getClassVal2(tag_t topItem, string& errMessage) { tag_t top_classificationObject; - ICS_ask_classification_object(topItem, &top_classificationObject); + ITKCALL(ICS_ask_classification_object(topItem, &top_classificationObject)); if (top_classificationObject == NULL_TAG) { errMessage.append("顶层对象没有发送到分类\n"); @@ -739,9 +752,9 @@ void recyReadEBom(tag_t pLine, EBomBean parentBean, vector& beans, int errBuff.append("物料:").append(pRevId).append("/").append(name).append("已封存无法转换PBOM.\n"); //return; } - AOM_ask_value_strings(pErev, "zt2_SZProcuretype", &cnt3, &procureType); //包含自制 - AOM_ask_value_strings(pErev, "zt2_SZSealedornot", &cnt2, &sealeds); - AOM_ask_value_strings(pErev, "zt2_SZFactory", &numFac, &factorys); + ITKCALL(AOM_ask_value_strings(pErev, "zt2_SZProcuretype", &cnt3, &procureType)); //包含自制 + ITKCALL(AOM_ask_value_strings(pErev, "zt2_SZSealedornot", &cnt2, &sealeds)); + ITKCALL(AOM_ask_value_strings(pErev, "zt2_SZFactory", &numFac, &factorys)); boolean flagWh = false; //检查物料是否符合条件 for (int i = 0; i < numFac; i++) { @@ -774,31 +787,31 @@ void recyReadEBom(tag_t pLine, EBomBean parentBean, vector& beans, int ITKCALL(AOM_ask_value_tags(eRev, "TC_Is_Represented_By", &num, &mantrs)); if (num > 0) { char* id; - AOM_ask_value_string(mantrs[0], "item_id", &id); + ITKCALL(AOM_ask_value_string(mantrs[0], "item_id", &id)); string item_id = id; smatch result;//regex qq_reg("^1ZDB5.*\\d{1,}1000X.*"); bool ret = regex_match(item_id, result, qq_reg); if (ret) { char *zt2_ifpbom; - AOM_ask_value_string(eRev, "zt2_ifpbom", &zt2_ifpbom); + ITKCALL(AOM_ask_value_string(eRev, "zt2_ifpbom", &zt2_ifpbom)); if (zt2_ifpbom != NULL && strcmp(zt2_ifpbom, "P") == 0) { continue; } int cc_cnt; tag_t* cc_lines; - BOM_line_ask_all_child_lines(c_line_tag, &cc_cnt, &cc_lines); + ITKCALL(BOM_line_ask_all_child_lines(c_line_tag, &cc_cnt, &cc_lines)); //线圈下对象检查是否可以整除 取总装图分类属性线圈项数 新增逻辑 拆解ZT2_Remark上包含ABC的 //12.4新增 物料下子件名称带 线 的,11.3 分成3,3,5.3 for (int tt = 0; tt < cc_cnt; tt++) { tag_t cc_line = cc_lines[tt], c_eRev; char* bl_quantity, *pId, *c_pId,*remark,*bl_line_name; - AOM_ask_value_string(eRev, "item_id", &pId); - AOM_ask_value_string(cc_line, "bl_quantity", &bl_quantity); - AOM_ask_value_string(cc_line, "ZT2_Remark", &remark); - AOM_ask_value_string(cc_line, "bl_line_name", &bl_line_name); + ITKCALL(AOM_ask_value_string(eRev, "item_id", &pId)); + ITKCALL(AOM_ask_value_string(cc_line, "bl_quantity", &bl_quantity)); + ITKCALL(AOM_ask_value_string(cc_line, "ZT2_Remark", &remark)); + ITKCALL(AOM_ask_value_string(cc_line, "bl_line_name", &bl_line_name)); ITKCALL(AOM_ask_value_tag(cc_line, "bl_line_object", &c_eRev)); - AOM_ask_value_string(c_eRev, "item_id", &c_pId); + ITKCALL(AOM_ask_value_string(c_eRev, "item_id", &c_pId)); printf("c_pId===> %s bl_quantity ==> %s len==> %d \n", c_pId, bl_quantity, len); if (strcmp("bl_quantity", "") == 0) { errBuff.append("P类物料:").append(pId).append("下子件").append(c_pId) @@ -856,7 +869,7 @@ tag_t findDcUser() { } int cnt; char** qry_entries1, **qry_values2; - QRY_find_user_entries(query, &cnt, &qry_entries1, &qry_values2); + ITKCALL(QRY_find_user_entries(query, &cnt, &qry_entries1, &qry_values2)); char * qry_values[1] = { "dcproxy" }; int n_found; ITKCALL(QRY_execute(query, 1, qry_entries1, qry_values, &n_found, &tags)); @@ -1003,7 +1016,7 @@ tag_t saveAsUpdate(tag_t eRev, char *uid, tag_t pLine) { char* newid = NULL; logical isModified = FALSE; tag_t item_type_tag, newItem, newRev; - TCTYPE_ask_type("Item", &item_type_tag); + ITKCALL(TCTYPE_ask_type("Item", &item_type_tag)); ITKCALL(USER_new_item_id(NULLTAG, item_type_tag, &isModified, &newid)); /*ITKCALL(NR_next_value("MEProcess", "item_id", NULLTAG, "", "", "", NULLTAG, "", "", &next_id));*/ @@ -1011,21 +1024,21 @@ tag_t saveAsUpdate(tag_t eRev, char *uid, tag_t pLine) { ITKCALL(ITEM_copy_item(eRev, newid, NULL, &newItem, &newRev)); //ITKCALL(AOM_set_value_string(newRev, "zt2_PMaterial", "PBOM")); char* matnrNo; - AOM_ask_value_string(eRev, "zt2_MaterialNo", &matnrNo); + ITKCALL(AOM_ask_value_string(eRev, "zt2_MaterialNo", &matnrNo)); AOM_lock(newRev); - AOM_set_value_string(newRev, "zt2_ifpbom", "P"); - AOM_set_value_string(newRev, "zt2_MaterialNo", matnrNo); + ITKCALL(AOM_set_value_string(newRev, "zt2_ifpbom", "P")); + ITKCALL(AOM_set_value_string(newRev, "zt2_MaterialNo", matnrNo)); AOM_save(newRev); AOM_unlock(newRev); int num = 0, revNum = 0, tagNum = 0; tag_t* mantrs, dsuser, *structure_revisions, *bom_view_tags; - AOM_ask_value_tags(eRev, "TC_Is_Represented_By", &num, &mantrs); + ITKCALL(AOM_ask_value_tags(eRev, "TC_Is_Represented_By", &num, &mantrs)); if (num > 0) { - AOM_ask_value_tags(newRev, "structure_revisions", &revNum, &structure_revisions); - AOM_ask_value_tags(newRev, "bom_view_tags", &tagNum, &bom_view_tags); - AOM_ask_value_tag(mantrs[0], "owning_user", &dsuser); + ITKCALL(AOM_ask_value_tags(newRev, "structure_revisions", &revNum, &structure_revisions)); + ITKCALL(AOM_ask_value_tags(newRev, "bom_view_tags", &tagNum, &bom_view_tags)); + ITKCALL(AOM_ask_value_tag(mantrs[0], "owning_user", &dsuser)); tag_t defGroup; ITKCALL(AOM_ask_value_tag(dsuser, "default_group", &defGroup)); ITKCALL(AOM_set_ownership(newItem, dsuser, defGroup)); @@ -1042,26 +1055,26 @@ tag_t saveAsUpdate(tag_t eRev, char *uid, tag_t pLine) { int bvr_count = 0, c_line_count; tag_t ebom_window = NULLTAG; tag_t bom_line = NULLTAG, *c_line_tags; - (BOM_create_window(&ebom_window)); + ITKCALL(BOM_create_window(&ebom_window)); tag_t* bvr_list = NULL; - (ITEM_rev_list_bom_view_revs(pLine, &bvr_count, &bvr_list)); + ITKCALL(ITEM_rev_list_bom_view_revs(pLine, &bvr_count, &bvr_list)); printf("bvr_count=%d\n", bvr_count); - (BOM_set_window_top_line_bvr(ebom_window, bvr_list[0], &bom_line)); //顶层bom获取 + ITKCALL(BOM_set_window_top_line_bvr(ebom_window, bvr_list[0], &bom_line)); //顶层bom获取 //ITKCALL(AOM_ask_value_tag(bom_line, "bl_line_object", &mantr)); ITKCALL(BOM_line_ask_all_child_lines(bom_line, &c_line_count, &c_line_tags)); for (int ind = 0; ind < c_line_count; ind++) { tag_t c_line_tag = c_line_tags[ind], mantr; - AOM_ask_value_tag(c_line_tag, "bl_line_object", &mantr); + ITKCALL(AOM_ask_value_tag(c_line_tag, "bl_line_object", &mantr)); char* eRevUid2; ITK__convert_tag_to_uid(mantr, &eRevUid2); if (strcmp(eRevUid2, uid) == 0) { ITKCALL(BOM_line_replace(c_line_tag, NULLTAG, newRev, NULLTAG)); } } - BOM_save_window(ebom_window); - BOM_close_window(ebom_window); + ITKCALL(BOM_save_window(ebom_window)); + ITKCALL(BOM_close_window(ebom_window)); } return newRev; } @@ -1074,7 +1087,7 @@ tag_t saveAsUpdate(tag_t eRev, tag_t newChild) { char* newid = NULL; logical isModified = FALSE; tag_t item_type_tag, newItem, newRev; - TCTYPE_ask_type("Item", &item_type_tag); + ITKCALL(TCTYPE_ask_type("Item", &item_type_tag)); ITKCALL(USER_new_item_id(NULLTAG, item_type_tag, &isModified, &newid)); /*ITKCALL(NR_next_value("MEProcess", "item_id", NULLTAG, "", "", "", NULLTAG, "", "", &next_id));*/ @@ -1082,21 +1095,21 @@ tag_t saveAsUpdate(tag_t eRev, tag_t newChild) { ITKCALL(ITEM_copy_item(eRev, newid, NULL, &newItem, &newRev)); //ITKCALL(AOM_set_value_string(newRev, "zt2_PMaterial", "PBOM")); char* matnrNo; - AOM_ask_value_string(eRev, "zt2_MaterialNo", &matnrNo); + ITKCALL(AOM_ask_value_string(eRev, "zt2_MaterialNo", &matnrNo)); AOM_lock(newRev); - AOM_set_value_string(newRev, "zt2_ifpbom", "P"); - AOM_set_value_string(newRev, "zt2_MaterialNo", matnrNo); + ITKCALL(AOM_set_value_string(newRev, "zt2_ifpbom", "P")); + ITKCALL(AOM_set_value_string(newRev, "zt2_MaterialNo", matnrNo)); AOM_save(newRev); AOM_unlock(newRev); int num = 0, revNum = 0, tagNum = 0; tag_t* mantrs, dsuser, *structure_revisions, *bom_view_tags; - AOM_ask_value_tags(eRev, "TC_Is_Represented_By", &num, &mantrs); + ITKCALL(AOM_ask_value_tags(eRev, "TC_Is_Represented_By", &num, &mantrs)); if (num > 0) { - AOM_ask_value_tags(newRev, "structure_revisions", &revNum, &structure_revisions); - AOM_ask_value_tags(newRev, "bom_view_tags", &tagNum, &bom_view_tags); - AOM_ask_value_tag(mantrs[0], "owning_user", &dsuser); + ITKCALL(AOM_ask_value_tags(newRev, "structure_revisions", &revNum, &structure_revisions)); + ITKCALL(AOM_ask_value_tags(newRev, "bom_view_tags", &tagNum, &bom_view_tags)); + ITKCALL(AOM_ask_value_tag(mantrs[0], "owning_user", &dsuser)); tag_t defGroup; ITKCALL(AOM_ask_value_tag(dsuser, "default_group", &defGroup)); ITKCALL(AOM_set_ownership(newItem, dsuser, defGroup)); @@ -1217,13 +1230,16 @@ void addToAmatnrUp(vector vecs, int len, tag_t newPAmatnr, boolean l tag_t newView, newViewBvr, pitem; ITKCALL(ITEM_ask_item_of_rev(mantr, &pitem)); ITKCALL(PS_create_bom_view(NULL, NULL, NULL, pitem, &newView)); - ITKCALL(AOM_save(newView)); + (AOM_save(newView)); ITKCALL(PS_create_bvr(newView, NULL, NULL, FALSE, mantr, &newViewBvr)); - ITKCALL(AOM_save(newViewBvr)); - ITKCALL(AOM_save(mantr)); + (AOM_save(newViewBvr)); + (AOM_save(mantr)); } ITKCALL(BOM_create_window(&ebom_window)); ITKCALL(BOM_set_window_top_line(ebom_window, NULL, mantr, NULLTAG, &bom_line)); + char *os = NULL; + ITKCALL(AOM_ask_value_string(bom_line, "object_string", &os)); + printf("bom_line====>%s\n", os); char *name; ITKCALL(AOM_ask_value_string(mantr, "object_name", &name)); string xqType = getXqName(name); //ABCDE @@ -1237,7 +1253,7 @@ void addToAmatnrUp(vector vecs, int len, tag_t newPAmatnr, boolean l int xqLen = len; if (msg.length() > 0) { xqLen = msg.length(); - if (strstr(msg.c_str(), xqType.c_str()) != NULL) { + if (strstr(msg.c_str(), xqType.c_str()) == NULL) { continue; } } @@ -1245,6 +1261,9 @@ void addToAmatnrUp(vector vecs, int len, tag_t newPAmatnr, boolean l if (newChild == NULLTAG) { continue; } + char *os2 = NULL; + ITKCALL(AOM_ask_value_string(newChild, "object_string", &os2)); + printf("newChild====>%s ", os2); ITKCALL(AOM_ask_value_string(cline, "bl_quantity", &oldQty)); ITKCALL(AOM_ask_value_string(cline, "bl_sequence_no", &seqNo)); ITKCALL(AOM_ask_value_string(cline, "bl_line_name", &bl_line_name)); @@ -1254,21 +1273,35 @@ void addToAmatnrUp(vector vecs, int len, tag_t newPAmatnr, boolean l double fmodVal = fmod(blQty, xqLen); double lastVal = num + fmodVal; string numNew = to_string(lastVal); - ITKCALL(AOM_lock(newChild)); - ITKCALL(AOM_set_value_string(newChild, "bl_quantity", numNew.c_str())); + printf("numNew1====> %s\n", numNew.c_str()); + (AOM_lock(newChild)); + int result = 0; + ITKCALL(result = AOM_set_value_string(newChild, "bl_quantity", numNew.c_str())); + if (result != 0) { + int iblQty = atoi(oldQty); + //double fmodVal = fmod(blQty, xqLen); + int val = iblQty / xqLen + iblQty % xqLen; + numNew = to_string(val); + printf("numNew1====> %s >>> %s\n", numNew.c_str(), vecs[i].blQuantity.c_str()); + ITKCALL(AOM_set_value_string(newChild, "bl_quantity", numNew.c_str())); + //ITKCALL(AOM_set_value_string(newChild, "bl_quantity", vecs[i].blQuantity.c_str())); + } ITKCALL(AOM_set_value_string(newChild, "bl_sequence_no", seqNo)); - ITKCALL(AOM_save(newChild)); - ITKCALL(AOM_unlock(newChild)); + ITKCALL(AOM_set_value_string(newChild, "ZT2_Remark", remark)); + (AOM_save(newChild)); + (AOM_unlock(newChild)); } else { int blQty = atoi(oldQty); - int num = blQty / len; + int num = blQty / xqLen; string numNew = to_string(num); - ITKCALL(AOM_lock(newChild)); + printf("numNew2====> %s\n", numNew.c_str()); + (AOM_lock(newChild)); ITKCALL(AOM_set_value_string(newChild, "bl_quantity", numNew.c_str())); ITKCALL(AOM_set_value_string(newChild, "bl_sequence_no", seqNo)); - ITKCALL(AOM_save(newChild)); - ITKCALL(AOM_unlock(newChild)); + ITKCALL(AOM_set_value_string(newChild, "ZT2_Remark", remark)); + (AOM_save(newChild)); + (AOM_unlock(newChild)); } } @@ -1409,12 +1442,12 @@ boolean combEAndDbom(map dMap, map eMap) { void changeCoilOwner(tag_t newPMantr, tag_t oldPMantr) { tag_t dsuser, *oldRevisions; int revNum = 0, revNumOld = 0; - AOM_ask_value_tags(newPMantr, "structure_revisions", &revNumOld, &oldRevisions); + ITKCALL(AOM_ask_value_tags(newPMantr, "structure_revisions", &revNumOld, &oldRevisions)); if (revNumOld > 0) { - AOM_ask_value_tag(oldRevisions[0], "owning_user", &dsuser); + ITKCALL(AOM_ask_value_tag(oldRevisions[0], "owning_user", &dsuser)); tag_t defGroup, *structure_revisions; ITKCALL(AOM_ask_value_tag(dsuser, "default_group", &defGroup)); - AOM_ask_value_tags(newPMantr, "structure_revisions", &revNum, &structure_revisions); + ITKCALL(AOM_ask_value_tags(newPMantr, "structure_revisions", &revNum, &structure_revisions)); if (revNum > 0) { ITKCALL(AOM_set_ownership(structure_revisions[0], dsuser, defGroup)); } @@ -1469,7 +1502,7 @@ tag_t saveAsMaterial(EBomUpBean topBean, boolean isTop, } for (int i = 0; i < termCoils.size(); i++) { char* itemId; - AOM_ask_value_string(termCoils[i], "item_id", &itemId); + ITKCALL(AOM_ask_value_string(termCoils[i], "item_id", &itemId)); printf("=======itemId====== %s \n", itemId); if (isTcm(termCoils[i]) && isBomViewTcm(termCoils[i])) { tag_t newPMantr; @@ -1485,7 +1518,7 @@ tag_t saveAsMaterial(EBomUpBean topBean, boolean isTop, /** * 更新PBOM逻辑 * @param upBean EBOM结构 - * @param bom_line PBOM顶层 + * @param pBomTag PBOM顶层 * @param len 拆分数量 * @param dcproxy dcproxy用户 * @param isTop 是否最上层 @@ -1534,14 +1567,14 @@ void startUpdate(EBomUpBean upBean, tag_t pBomTag, int len, tag_t dcproxy, //A项线圈是不带P的 matnrVec.push_back(matnrNo); pBomMap[matnrNo] = c_line_tag; - //BOM_line_cut(c_line_tag); - } - else if (!checkName(name)) { - ITKCALL(BOM_line_cut(c_line_tag));//pBomMap[matnrNo] = c_line_tag; + //ITKCALL(BOM_line_cut(c_line_tag)); } else if (checkName(name)) { xqTagVec.push_back(c_line_tag); } + else { + ITKCALL(BOM_line_cut(c_line_tag));//pBomMap[matnrNo] = c_line_tag; + } } //移除所有非P 再从EBOM复制 printf("xqTagVec===>%d\n", xqTagVec.size()); @@ -1572,13 +1605,11 @@ void startUpdate(EBomUpBean upBean, tag_t pBomTag, int len, tag_t dcproxy, //重新复制 if (std::find(matnrVec.begin(), matnrVec.end(), cupBean.matnrNo) != matnrVec.end()) { printf("matnrVec ===>%s\n", cupBean.matnrNo.c_str()); - tag_t c_line_tag = pBomMap[cupBean.matnrNo]; - tag_t c_Rev, bomView = NULLTAG; - ITKCALL(AOM_ask_value_tag(c_line_tag, "bl_line_object", &c_Rev)); + tag_t c_line_tag = pBomMap[cupBean.matnrNo], bomView = NULLTAG, childPTag = NULLTAG; boolean flagAs = false; - tag_t childPTag; ITKCALL(AOM_ask_value_tag(c_line_tag, BL_LINE_OBJECT, &childPTag)); + //ITKCALL(BOM_line_cut(c_line_tag)); startUpdate(cupBean, childPTag, len, dcproxy, isTop, hasChange, saveAsMap); if (bomView != NULLTAG && flagAs) { ITKCALL(BOM_save_window(bomView)); @@ -1588,20 +1619,21 @@ void startUpdate(EBomUpBean upBean, tag_t pBomTag, int len, tag_t dcproxy, } else { boolean flagLc = false; - char* seq; + char* seq = NULL, *ZT2_Remark = NULL; printf("matnrVecNotP===>%s\n", cupBean.matnrNo.c_str()); - tag_t cline = cupBean.bomline; - tag_t newChild; + tag_t cline = cupBean.bomline, newChild = NULLTAG; ITKCALL(BOM_line_copy(bom_line, cline, NULLTAG, &newChild)); if (newChild == NULLTAG) { printf(" newChild === NULLTAG 没有权限修改BOM视图 \n"); continue; } ITKCALL(AOM_ask_value_string(cline, "bl_sequence_no", &seq)); - ITKCALL(AOM_lock(newChild)); + ITKCALL(AOM_ask_value_string(cline, "ZT2_Remark", &ZT2_Remark)); + (AOM_lock(newChild)); ITKCALL(AOM_set_value_string(newChild, "bl_sequence_no", seq)); - ITKCALL(AOM_save(newChild)); - ITKCALL(AOM_unlock(newChild)); + ITKCALL(AOM_set_value_string(newChild, "ZT2_Remark", ZT2_Remark)); + (AOM_save(newChild)); + (AOM_unlock(newChild)); tag_t c_Rev; ITKCALL(AOM_ask_value_tag(cline, "bl_line_object", &c_Rev)); @@ -1623,6 +1655,20 @@ void startUpdate(EBomUpBean upBean, tag_t pBomTag, int len, tag_t dcproxy, } } } + for (int i = 0; i < matnrVec.size(); i++) { + bool cut = true; + for (int j = 0; j < vecs.size(); j++) { + if (tc_strcmp(vecs[j].matnrNo.c_str(), matnrVec[i].c_str()) == 0) { + cut = false; + break; + } + } + if (cut) { + printf(" cut === %s\n", matnrVec[i].c_str()); + tag_t c_line_tag = pBomMap[matnrVec[i]]; + ITKCALL(BOM_line_cut(c_line_tag)); + } + }/**/ } //移除所有非P 再从EBOM复制 @@ -1659,10 +1705,10 @@ void copyBomLine(tag_t matnrTop, tag_t otherPbom) { tag_t newView, newViewBvr, pitem; ITKCALL(ITEM_ask_item_of_rev(otherPbom, &pitem)); ITKCALL(PS_create_bom_view(NULL, NULL, NULL, pitem, &newView)); - ITKCALL(AOM_save(newView)); + (AOM_save(newView)); ITKCALL(PS_create_bvr(newView, NULL, NULL, FALSE, otherPbom, &newViewBvr)); - ITKCALL(AOM_save(newViewBvr)); - ITKCALL(AOM_save(otherPbom)); + (AOM_save(newViewBvr)); + (AOM_save(otherPbom)); //return; ITKCALL(ITEM_rev_list_bom_view_revs(otherPbom, &bvr_count2, &bvr_list2)); } @@ -1675,7 +1721,7 @@ void copyBomLine(tag_t matnrTop, tag_t otherPbom) { } for (int i = 0; i < c_line_count; i++) { tag_t newChild = NULLTAG; - char *bl_seqNo = NULL; + char *bl_seqNo = NULL, *ZT2_Remark = NULL; ITKCALL(BOM_line_copy(bom_line2, c_line_tags[i], NULLTAG, &newChild)); char* pos = NULL; @@ -1683,8 +1729,10 @@ void copyBomLine(tag_t matnrTop, tag_t otherPbom) { printf("copyBomLine:%s\n", pos); ITKCALL(AOM_ask_value_string(c_line_tags[i], "bl_sequence_no", &bl_seqNo)); + ITKCALL(AOM_ask_value_string(c_line_tags[i], "ZT2_Remark", &ZT2_Remark)); AOM_lock(newChild); ITKCALL(AOM_set_value_string(newChild, "bl_sequence_no", bl_seqNo)); + ITKCALL(AOM_set_value_string(newChild, "ZT2_Remark", ZT2_Remark)); AOM_save(newChild); //最后unlock AOM_unlock(newChild); @@ -1699,6 +1747,7 @@ void copyBomLine(tag_t matnrTop, tag_t otherPbom) { //EBOM转PBOM int EbomToPMethod(void* returnValue) { + auto start = std::chrono::high_resolution_clock::now(); int ifail = ITK_ok; char *sql = NULL, *revUid; tag_t matnrRev1; @@ -1750,6 +1799,9 @@ int EbomToPMethod(void* returnValue) { } } close(); + auto time1 = std::chrono::high_resolution_clock::now(); + std::chrono::duration elapsed = time1 - start; + printf("time1:%f\n", elapsed.count()); //遍历design BOM 获取物料信息 int bvr_count = 0, c_line_count; tag_t ebom_window = NULLTAG; @@ -1797,7 +1849,7 @@ int EbomToPMethod(void* returnValue) { ITKCALL(AOM_ask_value_string(topMatnrs[t], "zt2_ifpbom", &isPm)); string key = ""; key.append(zt2_WBSNo).append(zt2_MaterialNo); - printf("key===>%d\n", key.c_str()); + printf("key===>%s\n", key.c_str()); if (wlbmMap.count(key) > 0) { E2PBean &bean = wlbmMap[key]; @@ -1841,6 +1893,10 @@ int EbomToPMethod(void* returnValue) { isUpdate = true; } } + auto time2 = std::chrono::high_resolution_clock::now(); + elapsed = time2 - start; + printf("time2:%f\n", elapsed.count()); + POM_AM__set_application_bypass(true); tag_t dcproxy = findDcUser(); //创建PBOM原来逻辑 @@ -1881,8 +1937,11 @@ int EbomToPMethod(void* returnValue) { recyReadEBom(bom_line, topBean, beans, len, matnrTop, errBuff); printf("read end %d\n", beans.size()); - BOM_close_window(ebom_window); + ITKCALL(BOM_close_window(ebom_window)); //搭建BOM + auto time3 = std::chrono::high_resolution_clock::now(); + elapsed = time3 - start; + printf("time3:%f\n", elapsed.count()); printf("buff %s==>\n", errBuff.c_str()); tag_t topPrev = NULLTAG; @@ -1904,8 +1963,13 @@ int EbomToPMethod(void* returnValue) { replaceBom(beans[t], map, len, dcproxy, topPrev); } DisConnServer(); + auto time4 = std::chrono::high_resolution_clock::now(); + elapsed = time4 - start; + printf("time4:%f\n", elapsed.count()); + //多个产成品直接复制BOM for (it2 = wlbmMap.begin(); it2 != wlbmMap.end(); it2++) { + auto sub = std::chrono::high_resolution_clock::now(); string ss = it2->first; tag_t eMantr = wlbmMap[ss].eMantr; if (keyNum.compare(ss) == 0) { @@ -1949,6 +2013,9 @@ int EbomToPMethod(void* returnValue) { } //复制一份 copyBomLine(topPrev, newRev); + auto sub1 = std::chrono::high_resolution_clock::now(); + elapsed = sub1 - sub; + printf("sub1:%f\n", elapsed.count()); } } } @@ -1981,7 +2048,10 @@ int EbomToPMethod(void* returnValue) { upBean.bomline = bom_line; //遍历获取EBOM信息 updatePbomCycle(bom_line, errBuff, len, upBean); - + + auto time3 = std::chrono::high_resolution_clock::now(); + elapsed = time3 - start; + printf("time3:%f\n", elapsed.count()); //ITKCALL(BOM_set_window_top_line_bvr(ebom_window2, bvr_list2[0], &bom_line2)); //顶层bom获取 int url_num = 0; char** url_vals = NULL; @@ -2000,6 +2070,10 @@ int EbomToPMethod(void* returnValue) { startUpdate(upBean, pBomTop, len, dcproxy, true, hasChange, saveAsMap); DisConnServer(); //保存PBOM + auto time4 = std::chrono::high_resolution_clock::now(); + elapsed = time4 - start; + printf("time4:%f\n", elapsed.count()); + //ITKCALL(BOM_save_window(ebom_window2)); ////ITKCALL(AOM_unlock(ebom_window2)); //ITKCALL(BOM_close_window(ebom_window2)); @@ -2010,6 +2084,7 @@ int EbomToPMethod(void* returnValue) { printf("keyNum===>%s\n", keyNum.c_str()); map::iterator it2; for (it2 = wlbmMap.begin(); it2 != wlbmMap.end(); it2++) { + auto sub = std::chrono::high_resolution_clock::now(); string ss = it2->first; E2PBean tagBean = wlbmMap[ss]; printf("ss===>%s\n", ss.c_str()); @@ -2054,6 +2129,9 @@ int EbomToPMethod(void* returnValue) { ITKCALL(AOM_ask_value_string(newRev, "object_string", &nos)); printf("copyBomLine:%s ==> %s\n", pos, nos); copyBomLine(newP, newRev); + auto sub1 = std::chrono::high_resolution_clock::now(); + elapsed = sub1 - sub; + printf("sub1:%f\n", elapsed.count()); } } @@ -2065,6 +2143,10 @@ int EbomToPMethod(void* returnValue) { buff = "succ"; } CloseTcLog(); + // 计算时间间隔 + auto end = std::chrono::high_resolution_clock::now(); + elapsed = end - start; + printf("用时:%f\n", elapsed.count()); *((char**)returnValue) = (char*)MEM_alloc((strlen(buff.c_str()) + 1) * sizeof(char)); tc_strcpy(*((char**)returnValue), buff.c_str()); return ifail; diff --git a/General/General/General.vcxproj b/General/General/General.vcxproj index f0d97a9..71c8c5d 100644 --- a/General/General/General.vcxproj +++ b/General/General/General.vcxproj @@ -181,7 +181,9 @@ + + @@ -215,6 +217,7 @@ + diff --git a/General/General/General.vcxproj.filters b/General/General/General.vcxproj.filters index 565b1fd..4a88b56 100644 --- a/General/General/General.vcxproj.filters +++ b/General/General/General.vcxproj.filters @@ -233,5 +233,14 @@ 婧愭枃浠 + + 婧愭枃浠 + + + 婧愭枃浠 + + + 婧愭枃浠 + \ No newline at end of file diff --git a/General/General/chint_changenotice.cpp b/General/General/chint_changenotice.cpp index 65942eb..bd1aa74 100644 --- a/General/General/chint_changenotice.cpp +++ b/General/General/chint_changenotice.cpp @@ -41,6 +41,7 @@ #include #include "CRUL_server_call_httpserver.h" #include "common_itk_util.h" +#include #define EPM_HANDLER_COMMON #define MAX_PATH_LENGTH 200 #define MAX_PRINTLINE_LENGTH 400000 @@ -133,7 +134,7 @@ int chint_changenotice(EPM_action_message_t msg) { tag_t task_tag = NULL_TAG, root_task_tag = NULLTAG, - * attachments;; + *attachments;; task_tag = msg.task; int att_cnt = 0, ifail = 0; int c_sql_value_count = 0; @@ -154,7 +155,7 @@ int chint_changenotice(EPM_action_message_t msg) { for (int j = 0; j < c_sql_value_count; j++) { /*值:第一行为通知信息。 - 其余行为通知的人员,“组真实值”:“邮箱域名前缀”,多个用户之间用“; ”隔开。 + 其余行为通知的人员,“组真实值”:“邮箱域名前缀”,多个用户之间用“; ”隔开。 例:用户“邵俊齐”所在的组真实值为M060,邮箱为shaojq@chint.com, 则值为M060 : shaojq*/ if (j != 0) { @@ -162,7 +163,7 @@ int chint_changenotice(EPM_action_message_t msg) { feishuSplit(c_sql_values[j], ":", ans); prefMap[ans[0]] = ans[1]; } - + } WriteLog4(true, "首选项条数:%d", prefMap.size()); for (int i = 0; i < att_cnt; i++) @@ -231,7 +232,7 @@ int chint_changenotice(EPM_action_message_t msg) { vector usersVector; - + feishuSplit(users, ";", usersVector); @@ -239,21 +240,55 @@ int chint_changenotice(EPM_action_message_t msg) { cJSON* new_string = cJSON_CreateString(usersVector[h].c_str()); cJSON_AddItemToArray(emails, new_string); } - + + + //找项目信息 + + + //拼接content tag_t user; - char* duser,* itemId; + char* duser, *itemId; + char* zt2_WBSNo, *zt2_ContractName; AOM_ask_value_string(tagt, "item_id", &itemId); + AOM_ask_value_string(tagt, "zt2_WBSNo", &zt2_WBSNo); + AOM_ask_value_string(tagt, "zt2_ContractName", &zt2_ContractName); + + string th = ""; + int wlNum; tag_t* wlTags; + ITKCALL(AOM_ask_value_tags(tagt, "ZT2_ChangeAfter", &wlNum, &wlTags)); + printf("wlNum======%d\n", wlNum); + for (int j = 0; j < wlNum; j++) { + char* thType; + AOM_ask_value_string(wlTags[j], "object_type", &thType); + if (strcmp(thType, "ZT2_Design3DRevision") == 0) { + char* thid; + AOM_ask_value_string(wlTags[j], "item_id", &thid); + th.append(thid).append(";"); + } + + } + printf("th======%s\n", th); + AOM_ask_value_tag(tagt, "owning_user", &user); AOM_ask_value_string(user, "user_name", &duser); - contentStr.append(duser).append(" 发起的").append(itemId).append(c_sql_values[0]); + + //获取当前时间 + + auto now = std::chrono::system_clock::now(); + std::time_t time = std::chrono::system_clock::to_time_t(now); + std::tm* ptm = std::localtime(&time); + char buf[128]; + strftime(buf, sizeof(buf), "%Y.%m.%d", ptm); + printf("time===%s\n", buf); + contentStr.append(duser).append(" 发起的").append(itemId).append(c_sql_values[0]).append("(").append(th).append("-").append(zt2_WBSNo).append("-").append(zt2_ContractName).append(") 发起人:").append(duser).append("发布时间:").append(buf); cJSON_AddStringToObject(top, "content", contentStr.c_str()); - + //sms cJSON_AddStringToObject(top, "sms", "false"); - - - + + + cJSON_AddItemToObject(top, "emails", emails); cJSON_AddItemToObject(top, "mobiles", mobiles); @@ -307,7 +342,7 @@ int chint_changenotice(EPM_action_message_t msg) { } - + diff --git a/General/General/chint_changenoticebm.cpp b/General/General/chint_changenoticebm.cpp new file mode 100644 index 0000000..c29f1dd --- /dev/null +++ b/General/General/chint_changenoticebm.cpp @@ -0,0 +1,408 @@ +#include "cJSON.h" + +#include +#include "epm_handler_common.h" +#include +#include +#include +#include +#include +#include +#include +#include "ps/ps.h"; +#include "ps/vrule.h" +#include "sstream" +#include +#include "epm/epm.h" +#include "sa/sa.h" +#include "libxl.h" +#include +#include "epm/signoff.h" +#include +#include +#include +#include +#include "ae/dataset.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "chint_Handler.h" +#include +#include +#include "ado.h" +#include "ocilib.h" +#include +#include "CRUL_server_call_httpserver.h" +#include "common_itk_util.h" +#include +#define EPM_HANDLER_COMMON +#define MAX_PATH_LENGTH 200 +#define MAX_PRINTLINE_LENGTH 400000 + + +char* concat(char** s, int size) { + int length = 0; + for (int i = 0; i < size; i++) { + length += strlen(s[i]); + } + char* result = new char[length + 1]; + int index = 0; + for (int i = 0; i < size; i++) { + int len = strlen(s[i]); + memcpy(result + index, s[i], len); + index += len; + } + result[length] = '\0'; + return result; +} + +char* utogbm(const char* src_str) +{ + int len = MultiByteToWideChar(CP_UTF8, 0, src_str, -1, NULL, 0); + wchar_t* wszGBK = (wchar_t*)MEM_alloc((len + 1) * sizeof(wchar_t)); + memset(wszGBK, 0, len * 2 + 2); + MultiByteToWideChar(CP_UTF8, 0, src_str, -1, wszGBK, len); + len = WideCharToMultiByte(CP_ACP, 0, wszGBK, -1, NULL, 0, NULL, NULL); + char* szGBK = (char*)MEM_alloc((len + 1) * sizeof(char)); + + memset(szGBK, 0, len + 1); + WideCharToMultiByte(CP_ACP, 0, wszGBK, -1, szGBK, len, NULL, NULL); + return szGBK; +} + +char* gtoubm(const char* src_str) +{ + int len = MultiByteToWideChar(CP_ACP, 0, src_str, -1, NULL, 0); + wchar_t* wstr = (wchar_t*)MEM_alloc((len + 1) * sizeof(wchar_t)); + memset(wstr, 0, len + 1); + MultiByteToWideChar(CP_ACP, 0, src_str, -1, wstr, len); + len = WideCharToMultiByte(CP_UTF8, 0, wstr, -1, NULL, 0, NULL, NULL); + char* str = (char*)MEM_alloc((len + 1) * sizeof(char)); + + memset(str, 0, len + 1); + WideCharToMultiByte(CP_UTF8, 0, wstr, -1, str, len, NULL, NULL); + return str; +} + + +// 写入回调函数实现 +size_t WriteCallbackbm(void* contents, size_t size, size_t nmemb, void* userp) { + size_t totalSize = size * nmemb; + char* buffer = (char*)userp; + + // 追加内容到缓冲区 + strncat(buffer, (char*)contents, totalSize); + + return totalSize; // 返回实际接收的字节数 +} + +void feishuSplitbm(string strArg, string spliter, vector& ans) +{ + ans.clear(); + size_t index0 = 0; + string one_arg; + if (strArg.find_first_not_of(' ') == string::npos) + strArg = ""; + while (strArg.size() > 0) + { + index0 = strArg.find_first_of(spliter); + if (index0 != string::npos) + { + one_arg = strArg.substr(0, index0); + strArg = strArg.substr(index0 + 1); + ans.push_back(one_arg); + } + else + { + ans.push_back(strArg); + break; + } + } +} + + +void WriteLogbm(logical debug, const char* format, ...) +{ + va_list arg; + char tmp[MAX_PRINTLINE_LENGTH]; + char date_string[MAX_PATH_LENGTH]; + time_t now; + struct tm* p; + + //get the message + memset(tmp, 0, sizeof(tmp)); + va_start(arg, format); + vsprintf(tmp, format, arg); + va_end(arg); + //----------print to command window for trace--------// + //printf("%s\n", tmp); + printf("%s\n", tmp); + //print message to log file + TC_write_syslog("%s\n", tmp); +} +int chint_changenoticebm(EPM_action_message_t msg) { + + tag_t task_tag = NULL_TAG, + root_task_tag = NULLTAG, + *attachments;; + task_tag = msg.task; + int att_cnt = 0, ifail = 0; + int c_sql_value_count = 0; + char** c_sql_values = NULL; + ITKCALL(PREF_ask_char_values("CHINT_ChangeNoticeBM", &c_sql_value_count, &c_sql_values)); + + WriteLogbm(true, "------------------------------------------------------------------------------------"); + WriteLogbm(true, "========================="); + WriteLogbm(true, "chint_changenoticebm start"); + WriteLogbm(true, "========================="); + + EPM_ask_root_task(task_tag, &root_task_tag); + EPM_ask_attachments(root_task_tag, EPM_target_attachment, &att_cnt, &attachments); + WriteLogbm(true, "流程目标下的对象数量:%d", att_cnt); + + //分割首选项 + string finalUsers = ""; + std::map prefMap;//统计集合 + std::map zt2_ChangeUnit1Map;//zt2_ChangeUnit1 map + for (int j = 0; j < c_sql_value_count; j++) { + + /*触发handler后获取当前流程目标下 “ZT2_Change”对象的item属性更改单发放部门“zt2_ChangeUnit1” + 与首选项“CHINT_ChangeNoticeBM”中的已定义的值(“ | ”后面的值)进行匹配 + ,(“ | ”前面的值与变更单所有者所在的组真实值匹配)并以飞书通知的形式通知给相关 的人员。 + 通知信息:由“变更申请人”发起的 + ”更改单号” + 首选项第一行的内容+(项目名称 - 项目wbs号 - 图号:xx; xx)*/ + if (j != 0) { + vector ans; + feishuSplitbm(c_sql_values[j], "|", ans); + prefMap[ans[0]] = ans[1]; + } + + } + WriteLogbm(true, "首选项条数:%d", prefMap.size()); + for (int i = 0; i < att_cnt; i++) + { + tag_t tagt = NULLTAG; + tagt = attachments[i]; + char* type, *zt2_ChangeUnit1; + //获取版本下的数据集 + int dataset_num = 0; + tag_t* dataset_tags = NULL; + char* tempValue = NULL; + char taskpuid[56] = "\0"; + ITK__convert_tag_to_uid(task_tag, &tempValue); + tc_strcpy(taskpuid, tempValue); + ITKCALL(AOM_ask_value_string(tagt, "object_type", &type)); + printf("object_type=%s\n", type); + //获取当前登入人组 + //char* groupName = NULL; + //tag_t t_group = NULLTAG; + //ITKCALL(POM_ask_group(&groupName, &t_group)); + //printf("g=%s\n", groupName); + //获取当前登入人的名称和id + + tag_t group; + char* group_name; + AOM_ask_value_tag(tagt, "owning_group", &group); + AOM_ask_value_string(group, "name", &group_name); + + + char* name; + char* id; + tag_t user; + POM_get_user(&name, &user); + POM_get_user_id(&id); + printf("name================%s\n", name); + printf("id================%s\n", id); + printf("group_name================%s\n", group_name); + string users = ""; + //判断组是否在首选项中存在 + for (auto it = prefMap.begin(); it != prefMap.end(); it++) { + //当前组和首选项中组匹配 + if (strcmp(it->first.c_str(), group_name) == 0) { + users = it->second; + break; + } + } + + printf("users================%s\n", users.c_str()); + if (strcmp(users.c_str(), "") != 0) { + //判断目标下是否存在 ZT2_Change + + if (strcmp("ZT2_Change", type) == 0) { + //获取zt2_ChangeUnit1的值 + int num; char** getValues; + ITKCALL(AOM_UIF_ask_values(tagt, "zt2_ChangeUnit1", &num, &getValues)); + zt2_ChangeUnit1 = concat(getValues, num); + printf("zt2_ChangeUnit1===========%s\n", zt2_ChangeUnit1); + //分割";" + vector zt2_ChangeUnit1Ans; + feishuSplitbm(users, ";", zt2_ChangeUnit1Ans); + for (int z = 0; z < zt2_ChangeUnit1Ans.size(); z++) { + vector tempSplit; + feishuSplitbm(zt2_ChangeUnit1Ans[z], ":", tempSplit); + zt2_ChangeUnit1Map[tempSplit[0]] = tempSplit[1]; + } + printf("zt2_ChangeUnit1Map===========%d\n", zt2_ChangeUnit1Map.size()); + //遍历zt2_ChangeUnit1Map,把zt2_ChangeUnit1中与首选项匹配 + for (auto it = zt2_ChangeUnit1Map.begin(); it != zt2_ChangeUnit1Map.end(); it++) { + //当前组和首选项中组匹配 + if (strstr(zt2_ChangeUnit1, it->first.c_str())) { + finalUsers.append(it->second).append(","); + } + } + printf("finalUsers===========%s\n", finalUsers.c_str()); + + if (strcmp(finalUsers.c_str(), "") != 0) { + + + //拼接json + char* json = NULL; + string contentStr; + cJSON* top = cJSON_CreateObject(); + cJSON* emails = cJSON_CreateArray(); + cJSON* mobiles = cJSON_CreateArray(); + + + + //拼接emails + vector usersVector; + + + + std::map tempMap;//zt2_ChangeUnit1 map + //取唯一先放入map里 + feishuSplitbm(finalUsers, ",", usersVector); + for (int h = 0; h < usersVector.size(); h++) { + tempMap[usersVector[h].c_str()] = usersVector[h].c_str(); + } + + for (auto it = tempMap.begin(); it != tempMap.end(); it++) { + //当前组和首选项中组匹配 + cJSON* new_string = cJSON_CreateString(it->first.c_str()); + cJSON_AddItemToArray(emails, new_string); + } + + //找项目信息 + + + + //拼接content + tag_t user; + char* duser, *itemId; + char* zt2_WBSNo, *zt2_ContractName; + AOM_ask_value_string(tagt, "item_id", &itemId); + AOM_ask_value_string(tagt, "zt2_WBSNo", &zt2_WBSNo); + AOM_ask_value_string(tagt, "zt2_ContractName", &zt2_ContractName); + + string th = ""; + int wlNum; tag_t* wlTags; + ITKCALL(AOM_ask_value_tags(tagt, "ZT2_ChangeAfter", &wlNum, &wlTags)); + printf("wlNum======%d\n", wlNum); + for (int j = 0; j < wlNum; j++) { + char* thType; + AOM_ask_value_string(wlTags[j], "object_type", &thType); + if (strcmp(thType, "ZT2_Design3DRevision") == 0) { + char* thid; + AOM_ask_value_string(wlTags[j], "item_id", &thid); + th.append(thid).append(";"); + } + + } + printf("th======%s\n", th); + + AOM_ask_value_tag(tagt, "owning_user", &user); + AOM_ask_value_string(user, "user_name", &duser); + //获取当前时间 + + auto now = std::chrono::system_clock::now(); + std::time_t time = std::chrono::system_clock::to_time_t(now); + std::tm* ptm = std::localtime(&time); + char buf[128]; + strftime(buf, sizeof(buf), "%Y.%m.%d", ptm); + printf("time===%s\n", buf); + contentStr.append(duser).append(" 发起的").append(itemId).append(c_sql_values[0]).append("(").append(th).append("-").append(zt2_WBSNo).append("-").append(zt2_ContractName).append(") 发起人:").append(duser).append("发布时间:").append(buf); + cJSON_AddStringToObject(top, "content", contentStr.c_str()); + + //sms + cJSON_AddStringToObject(top, "sms", "false"); + + + + cJSON_AddItemToObject(top, "emails", emails); + cJSON_AddItemToObject(top, "mobiles", mobiles); + + json = cJSON_Print(top); + + printf("json================%s\n", json); + + + + + + //调用接口 + CURL* curl; + CURLcode res; + char readBuffer[10000]; + memset(readBuffer, 0, 10000); + curl = curl_easy_init(); + if (curl) { + curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "POST"); + curl_easy_setopt(curl, CURLOPT_URL, "http://10.128.10.170/api/feishu/Message/sendMessages"); + curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L); + curl_easy_setopt(curl, CURLOPT_DEFAULT_PROTOCOL, "https"); + struct curl_slist* headers = NULL; + curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallbackbm); + // 设置写入数据的目标缓冲区 + + curl_easy_setopt(curl, CURLOPT_WRITEDATA, readBuffer); + headers = curl_slist_append(headers, "Content-Type: application/json"); + curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers); + //const char* data = "{\"emails\":[\"shaojq@chint.com\",\"zouy5@chint.com\"],\"mobiles\":[],\"sms\":false,\"content\":\"项目编号:P2303344售前资料已经获取完毕,请 登陆PLM系统查看。\"}"; + curl_easy_setopt(curl, CURLOPT_POSTFIELDS, gtoubm(json)); + res = curl_easy_perform(curl); + } + curl_easy_cleanup(curl); + + + char* gbk_readBuffer = utogbm(readBuffer); + printf("json================%s\n", gbk_readBuffer); + cJSON* result_json = cJSON_Parse(gbk_readBuffer); + cJSON* code = cJSON_GetObjectItem(result_json, "code"); + + int code_int = code->valueint; + + if (code_int != 0) { + printf("发送飞书失败\n"); + } + + } + + + + } + + } + + + + + + + + + + } + + + DOFREE(attachments); + WriteLogbm(true, "========================="); + WriteLogbm(true, "chint_changenoticebm end"); + WriteLogbm(true, "========================="); + return ifail; +} \ No newline at end of file diff --git a/General/General/chint_check_materialstatus.cpp b/General/General/chint_check_materialstatus.cpp index f97a6a9..2e41de1 100644 --- a/General/General/chint_check_materialstatus.cpp +++ b/General/General/chint_check_materialstatus.cpp @@ -72,10 +72,10 @@ int chint_check_materialstatus(EPM_action_message_t msg) { tag_t task_tag = NULL_TAG, root_task_tag = NULLTAG, - * attachments;; + *attachments;; task_tag = msg.task; int att_cnt = 0, ifail = 0; - + int count = 1; WriteLog5(true, "------------------------------------------------------------------------------------"); @@ -96,12 +96,12 @@ int chint_check_materialstatus(EPM_action_message_t msg) { tag_t target = NULLTAG; target = attachments[i]; char* objectType = NULL; - char* fcStr = NULL,* tyStr = NULL,* zt2_State = NULL; + char* fcStr = NULL, *tyStr = NULL, *zt2_State = NULL; //三种处理逻辑 物料 物料bom 图纸 ITKCALL(AOM_ask_value_string(target, "object_type", &objectType)); //物料 printf("objectType======%s\n", objectType); - if (strcmp(objectType,"Part Revision") == 0) { + if (strcmp(objectType, "Part Revision") == 0) { //获取物料编码和物料名称 char* zt2_MaterialNo = NULL; char* object_name = NULL; @@ -110,7 +110,7 @@ int chint_check_materialstatus(EPM_action_message_t msg) { ITKCALL(AOM_ask_value_string(target, "object_desc", &tyStr)); ITKCALL(AOM_UIF_ask_value(target, "zt2_State", &zt2_State)); printf("tyStr======%s\n", tyStr); - if (strstr(tyStr,"停用")) { + if (strstr(tyStr, "停用")) { //放入停用map tyMap[zt2_MaterialNo] = object_name; continue; @@ -153,7 +153,7 @@ int chint_check_materialstatus(EPM_action_message_t msg) { tag_t* childs; int childNum; ITKCALL(BOM_line_ask_child_lines(top_line_tag, &childNum, &childs)); - + printf("childNum======%d\n", childNum); for (int i = 0; i < childNum; i++) { tag_t rev = NULLTAG; @@ -174,15 +174,16 @@ int chint_check_materialstatus(EPM_action_message_t msg) { ITKCALL(AOM_ask_value_string(rev, "zt2_MaterialNo", &zt2_MaterialNo)); ITKCALL(AOM_ask_value_string(rev, "object_desc", &tyStr)); ITKCALL(AOM_UIF_ask_value(rev, "zt2_State", &zt2_State)); - if (strstr(tyStr, "停用")) { - //放入停用map - tyMap[zt2_MaterialNo] = object_name; - continue; - } - else if (strstr(zt2_State, "封存")) { + + if (strstr(zt2_State, "封存")) { //放入封存map fcMap[zt2_MaterialNo] = object_name; - continue; + + } + else if (strstr(tyStr, "停用")) { + //放入停用map + tyMap[zt2_MaterialNo] = object_name; + } } @@ -235,36 +236,36 @@ int chint_check_materialstatus(EPM_action_message_t msg) { if (strcmp(objectType, "ZT2_Design3DRevision") == 0) { //获取关系文件夹下的物料 - int wlNum; tag_t* wlTags; - ITKCALL(AOM_ask_value_tags(target, "representation_for", &wlNum, &wlTags)); - printf("wlNum======%d\n", wlNum); - for (int j = 0; j < wlNum; j++) { - //获取rev属性判断 - char* objectType_rev = NULL; - ITKCALL(AOM_ask_value_string(wlTags[j], "object_type", &objectType_rev)); - //物料 - printf("objectType_rev======%s\n", objectType_rev); - if (strcmp(objectType_rev, "Part Revision") == 0) { - //获取物料编码和物料名称 - char* zt2_MaterialNo = NULL; - char* object_name = NULL; - ITKCALL(AOM_ask_value_string(wlTags[j], "object_name", &object_name)); - ITKCALL(AOM_ask_value_string(wlTags[j], "zt2_MaterialNo", &zt2_MaterialNo)); - ITKCALL(AOM_ask_value_string(wlTags[j], "object_desc", &tyStr)); - ITKCALL(AOM_UIF_ask_value(wlTags[j], "zt2_State", &zt2_State)); - printf("zt2_State======%s\n", zt2_State); - if (strstr(tyStr, "停用")) { - //放入停用map - tyMap[zt2_MaterialNo] = object_name; - printf("00000000000000000000000000\n"); - continue; - } - else if (strstr(zt2_State, "封存")) { - //放入封存map - fcMap[zt2_MaterialNo] = object_name; - printf("11111111111111111111111111\n"); - continue; - } + int wlNum; tag_t* wlTags; + ITKCALL(AOM_ask_value_tags(target, "representation_for", &wlNum, &wlTags)); + printf("wlNum======%d\n", wlNum); + for (int j = 0; j < wlNum; j++) { + //获取rev属性判断 + char* objectType_rev = NULL; + ITKCALL(AOM_ask_value_string(wlTags[j], "object_type", &objectType_rev)); + //物料 + printf("objectType_rev======%s\n", objectType_rev); + if (strcmp(objectType_rev, "Part Revision") == 0) { + //获取物料编码和物料名称 + char* zt2_MaterialNo = NULL; + char* object_name = NULL; + ITKCALL(AOM_ask_value_string(wlTags[j], "object_name", &object_name)); + ITKCALL(AOM_ask_value_string(wlTags[j], "zt2_MaterialNo", &zt2_MaterialNo)); + ITKCALL(AOM_ask_value_string(wlTags[j], "object_desc", &tyStr)); + ITKCALL(AOM_UIF_ask_value(wlTags[j], "zt2_State", &zt2_State)); + printf("zt2_State======%s\n", zt2_State); + if (strstr(tyStr, "停用")) { + //放入停用map + tyMap[zt2_MaterialNo] = object_name; + printf("00000000000000000000000000\n"); + continue; + } + else if (strstr(zt2_State, "封存")) { + //放入封存map + fcMap[zt2_MaterialNo] = object_name; + printf("11111111111111111111111111\n"); + continue; + } } } } @@ -275,7 +276,7 @@ int chint_check_materialstatus(EPM_action_message_t msg) { for (auto it = tyMap.begin(); it != tyMap.end(); it++) { errMsg.append(std::to_string(count++)).append(".").append(it->first).append("-").append(it->second).append(":物料已停用\n"); } - + for (auto it = fcMap.begin(); it != fcMap.end(); it++) { errMsg.append(std::to_string(count++)).append(".").append(it->first).append("-").append(it->second).append(":物料已封存\n"); } @@ -284,7 +285,7 @@ int chint_check_materialstatus(EPM_action_message_t msg) { EMH_store_error_s1(EMH_severity_error, EMH_USER_error_base, errMsg.c_str()); //错误弹窗 return -1; } - + if (tyMap.size() > 0) { EMH_store_error_s1(EMH_severity_warning, EMH_USER_error_base, errMsg.c_str()); //错误弹窗 diff --git a/General/General/chint_ecn_signoff.cxx b/General/General/chint_ecn_signoff.cxx index 57e843d..7c1fe00 100644 --- a/General/General/chint_ecn_signoff.cxx +++ b/General/General/chint_ecn_signoff.cxx @@ -143,6 +143,61 @@ int chint_ecn_signoff(EPM_action_message_t msg) { EMH_store_error(EMH_severity_error, ifail); return ifail; } + //lidy20240531不是指派了dcproxy 那么会签就取这个节点对应人员的会签时间 + int cnt = 0; + tag_t ptask = NULLTAG, flow = NULLTAG, *sub_tasks = NULLTAG, hq_task = NULLTAG; + //ITKCALL(EPM_ask_parent_task(msg.task, &flow)); + ITKCALL(EPM_ask_root_task(msg.task, &flow)); + ITKCALL(EPM_ask_sub_tasks(flow, &cnt, &sub_tasks)); + for (int i = 0; i < cnt; i++) { + char *os = NULL; + ITKCALL(AOM_ask_value_string(sub_tasks[i], "object_name", &os)); + printf("sub_tasks:%s\n", os); + if (tc_strcmp(os, "会签") == 0) { + int cnt2 = 0; + tag_t *sub_tasks2 = NULLTAG; + ITKCALL(EPM_ask_sub_tasks(sub_tasks[i], &cnt2, &sub_tasks2)); + for (int j = 0; j < cnt2; j++) { + char *type = NULL; + ITKCALL(WSOM_ask_object_type2(sub_tasks2[j], &type)); + if (tc_strcmp(type, "EPMPerformSignoffTask") == 0) { + hq_task = sub_tasks2[j]; + } + } + break; + } + } + int num = 0; + tag_t responsibleParty = NULLTAG, *signoff_attachments = NULLTAG; + //ITKCALL(EPM_ask_responsible_party(msg.task, &responsibleParty)); + bool dcproxy = false; + string huiqian = ""; + if (hq_task != NULLTAG) { + ITKCALL(AOM_ask_value_tags(hq_task, "signoff_attachments", &num, &signoff_attachments)); + printf("signoff_attachments:%d\n", num); + for (int i = 0; i < num; i++) { + SIGNOFF_TYPE_t type; + EPM_signoff_decision_t decision; + tag_t member = NULLTAG, user = NULLTAG; + date_t date; + char *comment = NULL; + ITKCALL(EPM_ask_signoff_member(signoff_attachments[i], &member, &type)); + ITKCALL(EPM_ask_signoff_decision(signoff_attachments[i], &decision, &comment, &date)); + char *mem = NULL, *dates = NULL; + ITKCALL(AOM_ask_value_tag(member, "user", &user)); + ITKCALL(AOM_UIF_ask_value(user, "user_name", &mem)); + if (tc_strcmp(mem, "dcproxy") == 0) { + dcproxy = true; + break; + } + ITKCALL(DATE_date_to_string(date, "%Y-%m-%d", &dates));// %H-%M-%S + printf("decision:%s==%s\n", mem, dates); + if (huiqian.size() > 0) + huiqian.append(" "); + huiqian.append(mem).append(dates); + } + } + ITKCALL(EPM_ask_root_task(msg.task, &root_task)); ITKCALL(EPM_ask_attachments(root_task, EPM_target_attachment, &occur_of_counts, &targets)); for (int t = 0; t < occur_of_counts; t++) { @@ -151,9 +206,6 @@ int chint_ecn_signoff(EPM_action_message_t msg) { if (tc_strcmp(type, "ZT2_Change") != 0) { continue; } - char* id = NULL; - ITKCALL(AOM_ask_value_string(targets[t], "item_id", &id)); - printf("id ===>%s\n", id); /*if (tc_strcmp(task_name, "会签") == 0) { ITKCALL(AOM_set_value_string(targets[t], "zt2_Countersign", name.c_str())); char now_date_str[128 + 1] = { "\0" }; @@ -163,31 +215,40 @@ int chint_ecn_signoff(EPM_action_message_t msg) { printf("now_date_str ===>%s\n", now_date_str); ITKCALL(AOM_set_value_string(targets[t], "zt2_CountersignTime", now_date_str)); }*/ - string sql = "select \"principal\" FROM CHINT_ECN_NOTIFICATION where \"result\"='是' and \"ecncode\"='"; - sql.append(id).append("'"); - int outputColumn1 = 0, outputValueCount1 = 0; - char*** outputValue1 = NULL; - printf("sql ===>%s\n", sql.c_str()); - QuerySQLNoInputParam((char*)sql.c_str(), &outputColumn1, &outputValueCount1, &outputValue1); - vector name_vec; - for (int i = 0; i < outputValueCount1; i++) { - vector names; - if (tc_strstr(outputValue1[i][0], ":") == NULL) { - Split(outputValue1[i][0], ";", names); + char* id = NULL; + ITKCALL(AOM_ask_value_string(targets[t], "item_id", &id)); + printf("id ===>%s\n", id); + string name = ""; + if (dcproxy) { + vector name_vec; + string sql = "select \"principal\",\"coudata\" FROM CHINT_ECN_NOTIFICATION where \"result\"='是' and \"ecncode\"='"; + sql.append(id).append("'"); + int outputColumn1 = 0, outputValueCount1 = 0; + char*** outputValue1 = NULL; + printf("sql ===>%s\n", sql.c_str()); + QuerySQLNoInputParam((char*)sql.c_str(), &outputColumn1, &outputValueCount1, &outputValue1); + for (int i = 0; i < outputValueCount1; i++) { + vector names; + if (tc_strstr(outputValue1[i][0], ":") == NULL) { + Split(outputValue1[i][0], ";", names); + } + else { + Split(outputValue1[i][0], ":", names); + } + string name_date = names[0].append(outputValue1[i][1]); + if (find(name_vec.begin(), name_vec.end(), name_date) == name_vec.end()) + name_vec.push_back(name_date); } - else { - Split(outputValue1[i][0], ":", names); + for (int i = 0; i < name_vec.size(); i++) { + if (name.size() > 0) + name.append(" "); + name.append(name_vec[i]); } - if (find(name_vec.begin(), name_vec.end(), names[0]) == name_vec.end()) - name_vec.push_back(names[0]); + printf("name ===>%s\n", name.c_str()); } - string name = ""; - for (int i = 0; i < name_vec.size(); i++) { - if (name.size() > 0) - name.append(" "); - name.append(name_vec[i]); + else { + name.append(huiqian); } - printf("name ===>%s\n", name.c_str()); tag_t *datasets = NULL; int cnt = 0; diff --git a/General/General/epm_handler_common.h b/General/General/epm_handler_common.h index 4db2bcc..d47792f 100644 --- a/General/General/epm_handler_common.h +++ b/General/General/epm_handler_common.h @@ -65,6 +65,11 @@ int chint_ecn_assign(EPM_action_message_t msg); int CHINT_DRAWING_TO_SRM(EPM_action_message_t msg); int chint_changenotice(EPM_action_message_t msg); int chint_check_materialstatus(EPM_action_message_t msg); +int chint_changenoticebm(EPM_action_message_t msg); + +int getBomDetails(void *returnValue); +int CHINT_CHANGEITEM_TO_SRM(EPM_action_message_t msg); +int CHINT_CHANGEBOM_TO_SRM(EPM_action_message_t msg); //user service end #ifdef __cplusplus } diff --git a/General/General/epm_register_handler.cpp b/General/General/epm_register_handler.cpp index 7c6d33c..a058311 100644 --- a/General/General/epm_register_handler.cpp +++ b/General/General/epm_register_handler.cpp @@ -320,6 +320,33 @@ extern DLLAPI int USERSERVICE_custom_register_handlers(int *decision, va_list ar printf("Registering action handler chint_check_materialstatus failed %d\n", ifail); } + //飞书通知bm + ITKCALL(ifail = EPM_register_action_handler("chint_changenoticebm", "chint_changenoticebm", (EPM_action_handler_t)chint_changenoticebm)); + if (ifail == 0) { + printf("Registering action handler chint_changenoticebm successful\n"); + } + else { + printf("Registering action handler chint_changenoticebm failed %d\n", ifail); + } + + //PLM推送变更通知单数据流信息 + ITKCALL(ifail = EPM_register_action_handler("CHINT_CHANGEITEM_TO_SRM", "CHINT_CHANGEITEM_TO_SRM", (EPM_action_handler_t)CHINT_CHANGEITEM_TO_SRM)); + if (ifail == 0) { + printf("Registering action handler CHINT_CHANGEITEM_TO_SRM successful\n"); + } + else { + printf("Registering action handler CHINT_CHANGEITEM_TO_SRM failed %d\n", ifail); + } + + //PLM推送BOM差异表数据流信息 + ITKCALL(ifail = EPM_register_action_handler("CHINT_CHANGEBOM_TO_SRM", "CHINT_CHANGEBOM_TO_SRM", (EPM_action_handler_t)CHINT_CHANGEBOM_TO_SRM)); + if (ifail == 0) { + printf("Registering action handler CHINT_CHANGEBOM_TO_SRM successful\n"); + } + else { + printf("Registering action handler CHINT_CHANGEBOM_TO_SRM failed %d\n", ifail); + } + return ifail; } // @@ -329,7 +356,7 @@ extern DLLAPI int USERSERVICE_custom_register_methods(int *decision, va_list arg { { //2023 12 27 新增项目更新后操作 METHOD_id_t mth_tag; - METHOD_find_method("Item", "IMAN_save", &mth_tag); + ITKCALL(METHOD_find_method("Item", "IMAN_save", &mth_tag)); if (mth_tag.id != 0) { METHOD_add_action(mth_tag, METHOD_post_action_type, (METHOD_function_t)CHINT_SavePost, NULL); printf("注册ItemRevision函数成功!\n"); @@ -459,6 +486,28 @@ extern DLLAPI int USERSERVICE_custom_register_methods(int *decision, va_list arg } MEM_free(argumentList); } + { + //武汉组织BOM汇总清单接口改为C组织数据 + int numberOfArguments = 1; + int returnValueType = USERARG_STRING_TYPE; + int *argumentList = NULL; + USER_function_t functionPtr = NULL; + functionPtr = getBomDetails; + argumentList = (int*)MEM_alloc(numberOfArguments * sizeof(int)); + argumentList[0] = USERARG_STRING_TYPE; + + int status = USERSERVICE_register_method("getBomDetails", functionPtr, + numberOfArguments, argumentList, returnValueType); + if (status == ITK_ok) + { + printf("Registering getBomDetails finished\n"); + } + else + { + printf("Registering getBomDetails failed %d\n", status); + } + MEM_free(argumentList); + } return ITK_ok; } diff --git a/General/General/getBomDetails.cxx b/General/General/getBomDetails.cxx new file mode 100644 index 0000000..aa3d4da --- /dev/null +++ b/General/General/getBomDetails.cxx @@ -0,0 +1,281 @@ + +#include "epm_handler_common.h" +#include +#include +#include +#include +#include +#include +#include "cJSON.h" +#include "tc_log.h" +#include "tc_util.h" +using namespace std; + +/** +* 判断是不是外购件 +* +* @param material 物料 +* @return 是否外购件 +*/ +boolean isOutBuy(tag_t material) { + int factory = 0, procure = 0; + char **zt2_SZFactory = NULL, **zt2_SZProcuretype = NULL; + ITKCALL(AOM_UIF_ask_values(material, "zt2_SZFactory", &factory, &zt2_SZFactory)); + ITKCALL(AOM_UIF_ask_values(material, "zt2_SZProcuretype", &procure, &zt2_SZProcuretype)); + for (int i = 0; i < factory; i++) { + if (tc_strcmp(zt2_SZFactory[i], "M060") == 0 && procure > i && tc_strcmp(zt2_SZProcuretype[i], "外购") == 0) { + return true; + } + } + return false; +} + +/** +* 遍历工艺BOM获取辅料信息 +* +* @param parentLine 父BOM行 +* @param itemRevOfBOMLine BOM行对应的版本 +* @param materialMap Map 物料编码-数量 +* @param qty 数量累乘 +* @param level BOM层级 +*/ +void getProcessBomMsg(tag_t parentLine, tag_t itemRevOfBOMLine, map& materialMap, vector& materialVec, double qty, int level) { + + char *material = NULL; + //ITKCALL(AOM_UIF_ask_value(itemRevOfBOMLine, "zt2_MaterialNo", &material)); + ITK__convert_tag_to_uid(itemRevOfBOMLine, &material); + WriteTcLog("GetBomDetails getProcessBomMsg = %s", material); + char *blQty = NULL; + double qtyDouble = 1.0; + ITKCALL(AOM_UIF_ask_value(parentLine, "bl_quantity", &blQty)); + if (blQty && tc_strlen(blQty) > 0) { + qtyDouble = atof(blQty); + } + // 0为工艺层,1、2为工序层,3为辅料层 + if (level == 3) { + char *bl_occ_type = NULL; + ITKCALL(AOM_UIF_ask_value(parentLine, "bl_occ_type", &bl_occ_type)); + if (tc_strcmp(bl_occ_type, "Fu Liao") != 0) + return; + char *materialNo = NULL; + ITKCALL(AOM_UIF_ask_value(itemRevOfBOMLine, "zt2_MaterialNo", &materialNo)); + if (materialMap.count(materialNo) > 0) { + double q = materialMap[materialNo]; + materialMap[materialNo] = q + qty * qtyDouble; + } + else { + materialVec.push_back(materialNo); + materialMap[materialNo] = qty * qtyDouble; + } + } + else { + //获取当前层级数量,然后累乘 + int c_line_count = 0; + tag_t* c_line_tags = NULLTAG; + ITKCALL(BOM_line_ask_all_child_lines(parentLine, &c_line_count, &c_line_tags)); + for (int i = 0; i < c_line_count; i++) { + tag_t rev2 = NULLTAG; + ITKCALL(AOM_ask_value_tag(c_line_tags[i], "bl_line_object", &rev2)); + getProcessBomMsg(c_line_tags[i], rev2, materialMap, materialVec, qty * qtyDouble, level + 1); + } + } +} + +/** +* 遍历BOM获取底层信息 +* +* @param parentLine 父BOM行 +* @param itemRevOfBOMLine BOM行对应的版本 +* @param materialMap Map 物料编码-数量 +* @param qty 数量累乘 +*/ +void getChildBomMsg(tag_t parentLine, tag_t itemRevOfBOMLine, map& materialMap, vector& materialVec, double qty) { + + char *material = NULL; + ITKCALL(AOM_UIF_ask_value(itemRevOfBOMLine, "zt2_MaterialNo", &material)); + //ITK__convert_tag_to_uid(itemRevOfBOMLine, &material); + WriteTcLog("GetBomDetails getChildBomMsg = %s", material); + int n_references = 0; + int* levels = 0; + tag_t* references_tag; + char** relation_type_name = NULL; + //通过出厂编号查找到图纸 + ITKCALL(WSOM_where_referenced(itemRevOfBOMLine, 1, &n_references, &levels, &references_tag, &relation_type_name)); + tag_t procModel = NULLTAG; + for (int i = 0; i < n_references; i++) { + if (tc_strcmp(relation_type_name[i], "IMAN_METarget") == 0) { + procModel = references_tag[i]; + break; + } + } + if (procModel != NULLTAG) { + WriteTcLog("procModel != NULLTAG"); + tag_t bom_window = NULLTAG, topLine = NULLTAG; + ITKCALL(BOM_create_window(&bom_window)); + ITKCALL(BOM_set_window_top_line(bom_window, NULL, procModel, NULLTAG, &topLine)); + getProcessBomMsg(topLine, procModel, materialMap, materialVec, 1.0, 0); + ITKCALL(BOM_close_window(bom_window)); + } + char *blQty = NULL; + double qtyDouble = 1.0; + ITKCALL(AOM_UIF_ask_value(parentLine, "bl_quantity", &blQty)); + if (blQty && tc_strlen(blQty) > 0) { + qtyDouble = atof(blQty); + } + // 数量为0,为底层数据 + int c_line_count = 0; + tag_t* c_line_tags = NULLTAG; + ITKCALL(BOM_line_ask_all_child_lines(parentLine, &c_line_count, &c_line_tags)); + WriteTcLog("GetBomDetails c_line_count = %d", c_line_count); + if (c_line_count == 0) { + if (!isOutBuy(itemRevOfBOMLine)) + return; + if (materialMap.count(material) > 0) { + double q = materialMap[material]; + materialMap[material] = q + qty * qtyDouble; + } + else { + materialVec.push_back(material); + materialMap[material] = qty * qtyDouble; + } + } + else { + WriteTcLog("GetBomDetails 开始遍历"); + for (int i = 0; i < c_line_count; i++) { + tag_t rev2 = NULLTAG; + ITKCALL(AOM_ask_value_tag(c_line_tags[i], "bl_line_object", &rev2)); + getChildBomMsg(c_line_tags[i], rev2, materialMap, materialVec, qty * qtyDouble); + } + WriteTcLog("GetBomDetails 结束遍历"); + } +} + +//武汉组织BOM汇总清单接口改为C组织数据 +int getBomDetails(void *returnValue) { + string log_path = getenv("TEMP"); + log_path.append("\\getBomDetails").append(getNow("yyyyMMddHHmmss")).append(".log"); + CreateTcLogFile(log_path.c_str()); + WriteTcLog("******************* getBomDetails start2 %s *******************", getNow("LOG").c_str()); + + int ifail = ITK_ok; + char* jsonObject = NULL; + ITKCALL(USERARG_get_string_argument(&jsonObject)); + WriteTcLog("GetBomDetails 入参===>%s", jsonObject); + cJSON* jsonObject1 = cJSON_Parse(jsonObject); + //产成品物料编码 WBS号 + char* wbsNo = cJSON_GetObjectItem(jsonObject1, "wbsno")->valuestring; + char* materialNo = cJSON_GetObjectItem(jsonObject1, "ccpmaterialno")->valuestring; + //返回信息 + cJSON* result = cJSON_CreateObject(); + cJSON_AddStringToObject(result, "wbsno", wbsNo); + cJSON_AddStringToObject(result, "ccpmaterialno", materialNo); + //查询物料 + tag_t query_tag = NULLTAG; + ITKCALL(QRY_find2("chint_query_material_getbomdetails", &query_tag));//chint_query_material_test + if (query_tag == NULL) { + printf("Could not found query:chint_query_material_getbomdetails\n"); + cJSON_AddStringToObject(result, "code", "500"); + cJSON_AddStringToObject(result, "msg", "Could not found query:chint_query_material_getbomdetails"); + return ifail; + } + char **qkey = NULL, **qvalue = NULL; + int num_found = 0;//查询结果数量 + tag_t *modelObjects = NULL;//查询结果集 + const char *key1 = "materialno", *key2 = "wbsno";//WBS No//WBS号 + qkey = (char **)MEM_alloc(2 * sizeof(char*)); + qvalue = (char **)MEM_alloc(2 * sizeof(char*)); + qkey[0] = (char *)MEM_alloc((tc_strlen(key1) + 1)*sizeof(char)); + qvalue[0] = (char *)MEM_alloc((tc_strlen(materialNo) + 1)*sizeof(char)); + tc_strcpy(qkey[0], key1); + tc_strcpy(qvalue[0], materialNo); + qkey[1] = (char *)MEM_alloc((tc_strlen(key2) + 1)*sizeof(char)); + qvalue[1] = (char *)MEM_alloc((tc_strlen(wbsNo) + 1)*sizeof(char)); + tc_strcpy(qkey[1], key2); + tc_strcpy(qvalue[1], wbsNo); + ITKCALL(QRY_execute(query_tag, 2, qkey, qvalue, &num_found, &modelObjects)); + WriteTcLog("GetBomDetails 查询===>%d", num_found); + if (num_found == 0) { + //没有查询到产成品 返回500 + cJSON_AddStringToObject(result, "code", "500"); + cJSON_AddStringToObject(result, "msg", "数据组织失败"); + } + else { + //查询到产成品 返回200 如果有P物料,获取P物料 + cJSON_AddStringToObject(result, "code", "200"); + cJSON_AddStringToObject(result, "msg", "成功组织数据"); + //BOM全展开 获取到底层物料 数量累乘 相同物料合并数量 物料查询查的版本 + tag_t ccpRevision = NULLTAG; + //如果有P物料遍历P物料的BOM + for (int i = 0; i < num_found; i++) { + char *os = NULL, *ifPbom = NULL; + //ITKCALL(AOM_UIF_ask_value(modelObjects[i], "object_string", &os)); + ITK__convert_tag_to_uid(modelObjects[i], &os); + WriteTcLog("GetBomDetails 查询===>%s", os); + ITKCALL(AOM_UIF_ask_value(modelObjects[i], "zt2_ifpbom", &ifPbom)); + if (tc_strcmp(ifPbom, "P") == 0) { + ccpRevision = modelObjects[i]; + break; + } + } + if (ccpRevision == NULLTAG) + ccpRevision = modelObjects[0]; + //遍历 + char *ztQuantity = NULL; + ITKCALL(AOM_UIF_ask_value(ccpRevision, "zt2_Quantity", &ztQuantity)); + if (!ztQuantity || tc_strlen(ztQuantity) == 0) { + DOFREE(ztQuantity); + ztQuantity = (char *)MEM_alloc(2 * sizeof(char)); + tc_strcpy(ztQuantity, "1"); + } + tag_t bom_window = NULLTAG, topLine = NULLTAG; + ITKCALL(BOM_create_window(&bom_window)); + ITKCALL(BOM_set_window_top_line(bom_window, NULL, ccpRevision, NULLTAG, &topLine)); + map materialMap; + vector materialVec; + getChildBomMsg(topLine, ccpRevision, materialMap, materialVec, 1.0); + ITKCALL(BOM_close_window(bom_window)); + //信息搭建JSON + cJSON* array = cJSON_CreateArray(); + cJSON_AddStringToObject(result, "ccpquantity", ztQuantity); + cJSON* factoryno = cJSON_GetObjectItem(jsonObject1, "factoryno"); + if (factoryno) { + cJSON_AddStringToObject(result, "factoryno", factoryno->valuestring); + } + else { + cJSON_AddStringToObject(result, "factoryno", ""); + } + WriteTcLog("GetBomDetails materialVec===>%zd", materialVec.size()); + //map::iterator it; + //for (it = materialMap.begin(); it != materialMap.end(); it++) { + for (int i = 0; i < materialVec.size(); i++) { + //string key = it->first; + string key = materialVec[i]; + double qty = materialMap[key]; + cJSON* object = cJSON_CreateObject(); + char no_str[4] = ""; + sprintf(no_str, "%03d", i + 1); + cJSON_AddStringToObject(object, "no", no_str); + cJSON_AddStringToObject(object, "materialno", key.c_str()); + char qty_str[16] = ""; + sprintf(qty_str, "%.3f", qty); + cJSON_AddStringToObject(object, "quantity", qty_str); + cJSON_AddItemToArray(array, object); + } + cJSON_AddItemToObject(result, "contents", array); + } + char *json_to_char = cJSON_Print(result); + string msg = "GetBomDetails json_to_char===>"; + msg.append(json_to_char); + WriteTcLog2(msg); + + //string buff = ""; + *((char**)returnValue) = (char*)MEM_alloc((tc_strlen(json_to_char) + 1) * sizeof(char)); + tc_strcpy(*((char**)returnValue), json_to_char); + //WriteTcLog("GetBomDetails 返回"); + cJSON_Delete(result); + cJSON_Delete(jsonObject1); + //WriteTcLog("GetBomDetails log关闭"); + CloseTcLog(); + //printf("GetBomDetails end"); + return ifail; +} \ No newline at end of file diff --git a/General/General/tc_log.cxx b/General/General/tc_log.cxx index 476eecc..3f944f6 100644 --- a/General/General/tc_log.cxx +++ b/General/General/tc_log.cxx @@ -14,9 +14,9 @@ #include #include -#include #include #include +#include using namespace std; // #ifdef WIN32 @@ -103,6 +103,17 @@ void WriteTcLog(const char* format, ...) } } +void WriteTcLog2(string msg) { + if (log_file) { + printf("%s\n", msg.c_str()); + fprintf(log_file, "%s\n", msg.c_str()); + fflush(log_file); + } + else { + printf("*!Error!*: Log File Not Exist\n"); + } +} + void CloseTcLog(void) { if(log_file) @@ -153,5 +164,13 @@ string getNow(char* format) { .append(getNum(tm_t->tm_min)).append(":") .append(getNum(tm_t->tm_sec)); } + else if (tc_strcmp(format, "yyyyMMddHHmmss") == 0) {//yyyy-MM-dd HH:mi:ss + str.append(to_string(tm_t->tm_year + 1900)) + .append(getNum(tm_t->tm_mon + 1)) + .append(getNum(tm_t->tm_mday)) + .append(getNum(tm_t->tm_hour)) + .append(getNum(tm_t->tm_min)) + .append(getNum(tm_t->tm_sec)); + } return str; } diff --git a/General/General/tc_log.h b/General/General/tc_log.h index 95615bb..6b19dd2 100644 --- a/General/General/tc_log.h +++ b/General/General/tc_log.h @@ -17,6 +17,7 @@ extern "C" { void CreateTcLogFile(const char* logFileName); void WriteTcLog(const char* format, ...); +void WriteTcLog2(string msg); void CloseTcLog(void); void log_open(void); void log_close(void); diff --git a/General/General/tc_util.h b/General/General/tc_util.h index 97c86f6..38a5ecd 100644 --- a/General/General/tc_util.h +++ b/General/General/tc_util.h @@ -84,3 +84,6 @@ void ECHO(char *format, ...); } int ITEM_list_all_revs_alpha(tag_t item_tag,int *rev_cnt,tag_t **revs); + +char* G2U(const char* gb2312); +char* U2G(const char* utf8); \ No newline at end of file