From 9d29f993db401936a6e6f72be26ebb81d191c454 Mon Sep 17 00:00:00 2001 From: "lidy@connor.net.cn" Date: Fri, 18 Oct 2024 18:30:33 +0800 Subject: [PATCH] =?UTF-8?q?20241018=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 | 5 +- General/General/CHINT_Ecn_SendOA.cxx | 22 +- .../General/CRUL_server_call_httpserver.cpp | 24 ++ General/General/CRUL_server_call_httpserver.h | 3 +- General/General/CloneProcess.cpp | 2 +- General/General/DtoEBOM2.cpp | 178 ++++++++++----- General/General/EbomToPMethod.cpp | 28 ++- General/General/chint_add_to_workflow.cpp | 98 +++++--- General/General/chint_changenotice.cpp | 24 +- General/General/chint_changenoticebm.cpp | 24 +- General/General/common_itk_util.c | 12 + General/General/common_itk_util.h | 1 + General/General/tc_log.cxx | 11 + General/General/tc_log.h | 1 + 15 files changed, 495 insertions(+), 149 deletions(-) diff --git a/General/General/AutoFeeding.cpp b/General/General/AutoFeeding.cpp index 9a41857..d3313c4 100644 --- a/General/General/AutoFeeding.cpp +++ b/General/General/AutoFeeding.cpp @@ -100,7 +100,7 @@ void getDrawNo(tag_t bom_line, string &drawNo) { drawNo = drawNoVec1[0]; smatch result; /*if (drawNoVec1.size() == 3) { - drawNo = drawNo.append(); + drawNo = drawNo.append(); }*/ bool ret = regex_match(drawNo, result, qq_reg2); if (ret) { @@ -132,12 +132,12 @@ struct StBomBean { }; /* - 0:外购;1:自制实体;2:自制虚拟 +0:外购;1:自制实体;2:自制虚拟 */ int isSt(tag_t matnr) { int cnt2, numFac, cnt3; int flag = 1; - char** procureType, ** factorys, ** specialProcureType,*objName; + char** procureType, ** factorys, ** specialProcureType, *objName; 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)); @@ -155,7 +155,7 @@ int isSt(tag_t matnr) { } } } - + return flag; } void getBomMessage(vector& stBomlines, tag_t cBomLine, StBomBean &pBean) { @@ -167,7 +167,7 @@ void getBomMessage(vector& stBomlines, tag_t cBomLine, StBomBean &pBe //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; ITKCALL(AOM_ask_value_tag(cBomLine, "bl_line_object", &cmantr)); ITKCALL(AOM_ask_value_string(cmantr, "object_name", &cName)); //ITKCALL(AOM_UIF_ask_value(cmantr, "zt2_SZProcuretype", &zt2_SZProcuretype)); //外购不再展开投料 @@ -202,7 +202,7 @@ 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, *os = 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)); @@ -233,8 +233,8 @@ void autoFeedLike(tag_t towGxLine, StBomBean& pBean, vector& stBomlin if (!pBean.st) { char* qty; tag_t line = pBean.bomline; - ITKCALL(AOM_ask_value_string(line,"bl_quantity",&qty)); - if (strcmp(qty,"") == 0) { + ITKCALL(AOM_ask_value_string(line, "bl_quantity", &qty)); + if (strcmp(qty, "") == 0) { qty = "1"; } double x = atof(qty); @@ -256,9 +256,9 @@ void autoFeedLike(tag_t towGxLine, StBomBean& pBean, vector& stBomlin //auto time1 = std::chrono::high_resolution_clock::now(); //std::chrono::duration elapsed1 = time1 - start; //printf("time1:%f\n", elapsed1.count()); - + char *bl_qty = NULL; - ITKCALL(AOM_ask_value_string(pBean.bomline,"bl_quantity",&bl_qty)); + 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; @@ -283,10 +283,10 @@ void autoFeedLike(tag_t towGxLine, StBomBean& pBean, vector& stBomlin //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_set_value_string(newChild, "bl_occ_type", "MEConsumed")); (AOM_save(newChild)); (AOM_unlock(newChild)); DOFREE(c_line_tags); @@ -320,7 +320,8 @@ void autoFeedLike(tag_t towGxLine, StBomBean& pBean, string name2, vector& stBomlines, FeedRule bean, st 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 = 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++) { tag_t oneGx = c_line_tags[i], *towGxLines; int c_cnt = 0; @@ -414,10 +415,10 @@ void startFeed(tag_t meprocess, vector& stBomlines, FeedRule bean, ve 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++) { tag_t oneGx = c_line_tags[i], *towGxLines; int c_cnt = 0; @@ -468,10 +469,10 @@ void startFeed(tag_t meprocess, vector& stBomlines, FeedRule bean, st 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++) { tag_t oneGx = c_line_tags[i], *towGxLines = NULL; int c_cnt = 0; @@ -544,7 +545,7 @@ void startFeed(tag_t meprocess, vector& stBomlines, FeedRule bean, st } //map> drawMap; //map> nameMap; -void AutoFeedBom(tag_t mantr,tag_t meprocess, +void AutoFeedBom(tag_t mantr, tag_t meprocess, map> drawMap, map> nameMap) { //遍历PBOM tag_t* bvr_list = NULL, ebom_window, bom_line; @@ -682,13 +683,13 @@ void AutoFeedBom(tag_t mantr,tag_t meprocess, ITKCALL(BOM_close_window(ebom_window)); } -void readPbomMsg(tag_t bom_line, string &errBuffer, map> drawMap, +void readPbomMsg(tag_t bom_line, string &errBuffer, map> drawMap, map> nameMap, char *loginId, boolean isback) { int c_line_count; tag_t * c_line_tags; ITKCALL(BOM_line_ask_all_child_lines(bom_line, &c_line_count, &c_line_tags)); tag_t rev; - char *id,*objName; + char *id, *objName; 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)); @@ -698,7 +699,7 @@ void readPbomMsg(tag_t bom_line, string &errBuffer, map int n_references = 0; int* levels = 0; tag_t* references_tag = NULLTAG, user; - char** relation_type_name = NULL,*duser; + char** relation_type_name = NULL, *duser; //通过引用关系查找到变更单 ITKCALL(WSOM_where_referenced(rev, 1, &n_references, &levels, &references_tag, &relation_type_name)); //boolean hasProcess = false; @@ -718,7 +719,7 @@ void readPbomMsg(tag_t bom_line, string &errBuffer, map meprocess = refTag; } } - printf("loginUser===>%s,ownerUser===>%s\n",loginId, duser); + printf("loginUser===>%s,ownerUser===>%s\n", loginId, duser); //if (strcmp(duser, loginId) == 0) { if (meNum == 0) { errBuffer.append(id).append(":请关联工艺后重新操作.\n"); @@ -745,6 +746,95 @@ void readPbomMsg(tag_t bom_line, string &errBuffer, map readPbomMsg(c_line_tags[i], errBuffer, drawMap, nameMap, loginId, false); } } +//判断是否为备件包 +bool isBack(char* objName, vector> back_prefs) { + boolean isback = false; + for (int i = 0; i < back_prefs.size() && !isback; i++) { + vector backs = back_prefs[i]; + for (int j = 0; j < back_prefs.size(); j++) { + if (tc_strstr(objName, backs[j].c_str()) != NULL) { + isback = true; + break; + } + } + } + return isback; +} + +void AutoFeeding(tag_t matnrRev, vector> back_prefs, string &errBuffer, + map> drawMap, map> nameMap, char *loginId) { + + tag_t mantr = getPBomTag(matnrRev); + //lidy20240203备件包工艺路线指派 + char *objName = NULL; + ITKCALL(AOM_ask_value_string(mantr, "object_name", &objName)); + //首选项格式:组名:匹配字段1;匹配字段2 + boolean isback = isBack(objName, back_prefs); + + //遍历BOM获取所有要投料的 + tag_t* bvr_list = NULLTAG, ebom_window = NULLTAG, bom_line = NULLTAG; + int bvr_count = 0; + ITKCALL(ITEM_rev_list_bom_view_revs(mantr, &bvr_count, &bvr_list)); + ITKCALL(BOM_create_window(&ebom_window)); + ITKCALL(BOM_set_window_top_line(ebom_window, NULL, mantr, NULLTAG, &bom_line)); + + readPbomMsg(bom_line, errBuffer, drawMap, nameMap, loginId, isback); + + ITKCALL(BOM_close_window(ebom_window)); +} + +void getParents(tag_t matnrRev, vector& feeds, vector> back_prefs) { + int n_parents = 0, *levels; + tag_t* parents = NULLTAG; + ITKCALL(PS_where_used_all(matnrRev, 1, &n_parents, &levels, &parents)); + for (int i = 0; i < n_parents; i++) { + char* type = NULL; + ITKCALL(AOM_ask_value_string(parents[i], "object_type", &type)); + if (tc_strcmp(type, "MEProcessRevision") == 0) { + continue; + } + else if (tc_strcmp(type, "Part Revision") != 0) { + getParents(parents[i], feeds, back_prefs); + continue; + } + char *objName = NULL; + ITKCALL(AOM_ask_value_string(parents[i], "object_name", &objName)); + int st = isSt(parents[i]); + if (st == 1 || tc_strstr(objName, "变压器") != NULL || isBack(objName, back_prefs)) { + feeds.push_back(parents[i]); + } + else if (st == 0) { + //如果找到外购,就停止继续遍历,这条线就退出 + continue; + } + else { + getParents(parents[i], feeds, back_prefs); + } + } +} + +void getNewRev(string wm, bool isp, vector feeds, map& revMap, map& feedMap) { + for (int j = 0; j < feeds.size(); j++) { + char *isP2 = NULL; + ITKCALL(AOM_ask_value_string(feeds[j], "zt2_ifpbom", &isP2)); + if (tc_strcmp(isP2, isp ? "P" : "") == 0) { + char *zt2_MaterialNo2 = NULL, *zt2_WBSNo2 = NULL; + ITKCALL(AOM_ask_value_string(feeds[j], "zt2_WBSNo", &zt2_WBSNo2)); + ITKCALL(AOM_ask_value_string(feeds[j], "zt2_MaterialNo", &zt2_MaterialNo2)); + string wm2 = zt2_WBSNo2; + wm2.append("&").append(zt2_MaterialNo2); + if (wm2 == wm) { + date_t date; + ITKCALL(AOM_ask_value_date(feeds[j], "creation_date", &date)); + string date_s = getDateString(date); + if (revMap.count(wm) == 0 || date_s > revMap[wm]) { + revMap[wm] = date_s; + feedMap[wm] = feeds[j]; + } + } + } + } +} //int EbomToPMethod(void *returnValue); int AutoFeeding(void *returnValue) { @@ -759,7 +849,7 @@ int AutoFeeding(void *returnValue) { printf("search1"); QuerySQLNoInputParam((char*)sql22.c_str(), &colmun2, &count2, &outputValue2);*/ POM_AM__set_application_bypass(true); - char *loginId; + char *loginId = NULL; ITKCALL(POM_get_user_id(&loginId)); int ifail = ITK_ok; tag_t matnrRev; @@ -768,8 +858,7 @@ int AutoFeeding(void *returnValue) { ITK__convert_uid_to_tag(revUid, &matnrRev); string errBuffer; - tag_t mantr = getPBomTag(matnrRev); - + int url_num = 0; char** url_vals = NULL; ITKCALL(PREF_ask_char_values("database_tc", &url_num, &url_vals)); @@ -831,43 +920,65 @@ int AutoFeeding(void *returnValue) { } } } - //20240203备件包工艺路线指派 - boolean isback = false; int back_num = 0; - char** back_vals = NULL, * group_name = NULL, * objName = NULL; - ITKCALL(AOM_ask_value_string(mantr, "object_name", &objName)); + char** back_vals = NULL, *group_name = NULL; tag_t group = NULLTAG; vector group_names; ITKCALL(POM_ask_group(&group_name, &group)); Split(group_name, ".", group_names); printf("group_name=======%s\n", group_names[0].c_str()); ITKCALL(PREF_ask_char_values("CHINT_PROCESS_RULE", &back_num, &back_vals)); - //首选项格式:组名:匹配字段1;匹配字段2 - for (int i = 0; i < back_num && isback; i++) { + vector> back_prefs; + for (int i = 0; i < back_num; i++) { vector group_backs; Split(back_vals[i], ":", group_backs); if (tc_strcmp(group_backs[0].c_str(), group_names[0].c_str()) == 0) { vector backs; Split(group_backs[1], ";", backs); - for (int j = 0; j < backs.size(); j++) { - if (tc_strstr(objName, backs[j].c_str()) != NULL) { - isback = true; - break; - } - } + back_prefs.push_back(backs); } } + char *objName = NULL; + ITKCALL(AOM_ask_value_string(matnrRev, "object_name", &objName)); - //遍历BOM获取所有要投料的 - tag_t* bvr_list = NULL, ebom_window, bom_line; - int bvr_count; - ITKCALL(ITEM_rev_list_bom_view_revs(mantr, &bvr_count, &bvr_list)); - ITKCALL(BOM_create_window(&ebom_window)); - ITKCALL(BOM_set_window_top_line(ebom_window, NULL, mantr, NULLTAG, &bom_line)); - - readPbomMsg(bom_line, errBuffer, drawMap, nameMap, loginId, isback); + if (isSt(matnrRev) == 0) { + errBuffer.append("请选择自制件"); + } + else if (isSt(matnrRev) == 1 || tc_strstr(objName, "变压器") != NULL || isBack(objName, back_prefs)) { + AutoFeeding(matnrRev, back_prefs, errBuffer, drawMap, nameMap, loginId); + } + else { + //lidy20240807若选中对象为虚拟件,需要向上找到最终的E或者P物料进行投料 + vector feeds; + getParents(matnrRev, feeds, back_prefs); + map revMap; + map feedMap; + for (int i = 0; i < feeds.size(); i++) { + //如果是E就找P,如果有P就投p,如果没p就找最新的e + char *os = NULL, *zt2_MaterialNo = NULL, *zt2_WBSNo = NULL; + ITKCALL(AOM_ask_value_string(feeds[i], "object_string", &os)); + printf("feeds===>%s\n", os); + ITKCALL(AOM_ask_value_string(feeds[i], "zt2_WBSNo", &zt2_WBSNo)); + ITKCALL(AOM_ask_value_string(feeds[i], "zt2_MaterialNo", &zt2_MaterialNo)); + string wm = zt2_WBSNo; + wm.append("&").append(zt2_MaterialNo); + if (feedMap.count(wm) > 0) { + continue; + } + getNewRev(wm, true, feeds, revMap, feedMap); + if (revMap.count(wm) == 0) { + getNewRev(wm, false, feeds, revMap, feedMap); + } + } + for (auto it = feedMap.begin(); it != feedMap.end(); ++it) { + tag_t feed = it->second; + char *os = NULL; + ITKCALL(AOM_ask_value_string(feed, "object_string", &os)); + printf("feed===>%s\n", os); + AutoFeeding(feed, back_prefs, errBuffer, drawMap, nameMap, loginId); + } + } - ITKCALL(BOM_close_window(ebom_window)); POM_AM__set_application_bypass(false); auto end = std::chrono::high_resolution_clock::now(); diff --git a/General/General/CHINT_CHANGEBOM_TO_SRM.cxx b/General/General/CHINT_CHANGEBOM_TO_SRM.cxx index 08362b2..b6beafe 100644 --- a/General/General/CHINT_CHANGEBOM_TO_SRM.cxx +++ b/General/General/CHINT_CHANGEBOM_TO_SRM.cxx @@ -271,7 +271,10 @@ int CHINT_CHANGEBOM_TO_SRM(EPM_action_message_t msg) { xml.append(json_to_char); xml.append(""); //WriteLog("\nworkflowCode=EH_TE_ChangeNotice\nuserCode=%s\nfinishStart=true\n", userCode.c_str()); - WriteLog("组织之后的XMLJSON:\n%s\n", xml.c_str()); + string msg = "组织之后的XMLJSON:\n"; + msg.append(xml); + //WriteLog("组织之后的XMLJSON:\n%s\n", xml.c_str()); + WriteLog2(msg.c_str()); string returnMsg = "";// ecnSendOA(userCode.c_str(), json_to_char, url); for (int i = 0; i < urls.size(); i++) { returnMsg.append(ecnSendSRM(xml, urls[i])); diff --git a/General/General/CHINT_Ecn_SendOA.cxx b/General/General/CHINT_Ecn_SendOA.cxx index 0c84fed..f9b7a02 100644 --- a/General/General/CHINT_Ecn_SendOA.cxx +++ b/General/General/CHINT_Ecn_SendOA.cxx @@ -114,7 +114,12 @@ cJSON* getEHDepart(string ecnCode, string section, string &uuid) { if (i == 0) { vector uuidVec; Split(outputValue1[i][4],";", uuidVec); - printf("outputValue %zd===> %s\n", uuidVec.size(), uuidVec[1].c_str()); + if (uuidVec.size() > 1) { + printf("outputValue %zd===> %s\n", uuidVec.size(), uuidVec[1].c_str()); + } + else { + printf("outputValue %zd===> %s\n", uuidVec.size(), outputValue1[i][4]); + } if (uuidVec.size() > 1 && strstr(uuidVec[1].c_str(),"null") == NULL) { uuid = uuidVec[1]; } @@ -351,7 +356,10 @@ int CHINT_ECN_SendOA(EPM_action_message_t msg) { 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); + //WriteLog("组织之后的JSON\n %s\n", json_to_char); + string msg = "组织之后的JSON\n"; + msg.append(json_to_char).append("\n"); + WriteLog2(msg.c_str()); string returnMsg = ecnSendOA(userCode.c_str(), json_to_char, url); WriteLog("回传信息\n %s\n", returnMsg.c_str()); if (!returnMsg.empty()) { @@ -510,13 +518,16 @@ int CHINT_CHANGEITEM_TO_SRM(EPM_action_message_t msg) { ecnuid = uid; } } + ref_cnt = 0; bool iffilechange = false; tag_t *afters = NULLTAG; ITKCALL(AOM_ask_value_tags(taskTag, "ZT2_ChangeAfter", &ref_cnt, &afters)); + //printf("ZT2_ChangeAfter ===>%d\n", ref_cnt); for (int i = 0; i < ref_cnt; i++) { char *type = NULL; ITKCALL(WSOM_ask_object_type2(afters[i], &type)); - if (tc_strcmp(type, "ZT2_Desiqn3DRevision") == 0 || tc_strcmp(type, "ZT2_ProcureRevision") == 0) { + //printf("type ===>%s\n", type); + if (tc_strcmp(type, "ZT2_Design3DRevision") == 0 || tc_strcmp(type, "ZT2_ProcureRevision") == 0) { iffilechange = true; break; } @@ -610,7 +621,10 @@ int CHINT_CHANGEITEM_TO_SRM(EPM_action_message_t msg) { xml.append(""); //WriteLog("\nworkflowCode=EH_TE_ChangeNotice\nuserCode=%s\nfinishStart=true\n", userCode.c_str()); - WriteLog("组织之后的XMLJSON:\n%s\n", xml.c_str()); + string msg = "组织之后的XMLJSON:\n"; + msg.append(xml); + //WriteLog("组织之后的XMLJSON:\n%s\n", xml.c_str()); + WriteLog2(msg.c_str()); string returnMsg = "";// ecnSendOA(userCode.c_str(), json_to_char, url); for (int i = 0; i < urls.size(); i++) { returnMsg.append(ecnSendSRM(xml, urls[i]));//.append("\n") diff --git a/General/General/CRUL_server_call_httpserver.cpp b/General/General/CRUL_server_call_httpserver.cpp index 2a5ae77..fc1837f 100644 --- a/General/General/CRUL_server_call_httpserver.cpp +++ b/General/General/CRUL_server_call_httpserver.cpp @@ -463,4 +463,28 @@ string ecnSendSRM(string entityParamValues, string url) { printf("ecnSendSRM Msg===>%s\n", msgVal.c_str()); return msgVal; +} + +void yp_query(char* yp_url, string json) { + printf("yp_query:\n%s\nyp_url:\n%s\n", json.c_str(), yp_url); + CURL *curl = curl_easy_init(); + std::stringstream out; + + curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "POST"); + curl_easy_setopt(curl, CURLOPT_URL, yp_url); + curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L); + curl_easy_setopt(curl, CURLOPT_DEFAULT_PROTOCOL, "https"); + + struct curl_slist *headers = NULL; + headers = curl_slist_append(headers, "Content-Type: application/json"); + curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers); + curl_easy_setopt(curl, CURLOPT_POSTFIELDS, G2U(json.c_str())); + + curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data); + curl_easy_setopt(curl, CURLOPT_WRITEDATA, &out); + + CURLcode ret = curl_easy_perform(curl); + string str_json = U2G(out.str().c_str()); + curl_easy_cleanup(curl); + printf("yp_query return Msg===>%s\n", str_json.c_str()); } \ No newline at end of file diff --git a/General/General/CRUL_server_call_httpserver.h b/General/General/CRUL_server_call_httpserver.h index 722acee..152d5e0 100644 --- a/General/General/CRUL_server_call_httpserver.h +++ b/General/General/CRUL_server_call_httpserver.h @@ -12,4 +12,5 @@ string getUserIdOA(string email, string url); string getUserIdOAUUID(string uuid, string url); string getAssignFromYP(string url); void updatePiProject(string json, string url); -string ecnSendSRM(string entityParamValues, string url); \ No newline at end of file +string ecnSendSRM(string entityParamValues, string url); +void yp_query(char* yp_url, string json); \ No newline at end of file diff --git a/General/General/CloneProcess.cpp b/General/General/CloneProcess.cpp index 98a0055..8fa9e00 100644 --- a/General/General/CloneProcess.cpp +++ b/General/General/CloneProcess.cpp @@ -253,7 +253,7 @@ string getJdbVal(string name, string yqz, string checkcode, string draw, string int outputColumn2 = 0, outputValueCount2 = 0; char*** outputValue2 = NULL; QuerySQLNoInputParam(selectRxfs3, &outputColumn2, &outputValueCount2, &outputValue2); - if (outputValueCount1 > 0) { + if (outputValueCount2 > 0) { val = outputValue2[0][0]; } } diff --git a/General/General/DtoEBOM2.cpp b/General/General/DtoEBOM2.cpp index dfccbd3..c7bf62b 100644 --- a/General/General/DtoEBOM2.cpp +++ b/General/General/DtoEBOM2.cpp @@ -115,25 +115,29 @@ string& replace_all2(string& str, const string& old_value, const string& new_v return str; } tag_t getSapPart(tag_t designRevLine, tag_t designRev, string& errBuff, NodeBean& bean) { + auto start = std::chrono::high_resolution_clock::now(); int num = 0; tag_t* mantrs; char *type, *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) { + if (tc_strcmp(type, "Part Revision") == 0) { return designRev; } - ITKCALL(AOM_ask_value_tags(designRev, "representation_for", &num, &mantrs)); //printf("num===>%d\n", num); vector parts; - if (strstr(item_id, "1ZDB300000P") != NULL) { + auto bomtime = std::chrono::high_resolution_clock::now(); + std::chrono::duration elapsed = bomtime - start; + printf("getSapPart1:%f\n", elapsed.count()); + if (tc_strstr(item_id, "1ZDB300000P") != NULL) { + ITKCALL(AOM_ask_value_tags(designRev, "representation_for", &num, &mantrs)); map partsCcp; for (int i = 0; i < num; i++) { char* type, *zt2_ifpbom, *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) { // + if (tc_strstr(type, "Part") != NULL && tc_strcmp(zt2_ifpbom, "P") != 0) { // tag_t matnrItem; ITKCALL(ITEM_ask_item_of_rev(mantrs[i], &matnrItem)); partsCcp[itemId] = matnrItem; @@ -147,6 +151,10 @@ tag_t getSapPart(tag_t designRevLine, tag_t designRev, string& errBuff, NodeBean }*/ } } + bomtime = std::chrono::high_resolution_clock::now(); + elapsed = bomtime - start; + printf("getSapPart1num%d:%f\n", num, elapsed.count()); + map::iterator it; for (it = partsCcp.begin(); it != partsCcp.end(); it++) { string s = it->first; @@ -160,20 +168,27 @@ tag_t getSapPart(tag_t designRevLine, tag_t designRev, string& errBuff, NodeBean bean.ccps.push_back(partRevLast); } } + bomtime = std::chrono::high_resolution_clock::now(); + elapsed = bomtime - start; + printf("getSapPart1it%zd:%f\n", partsCcp.size(), elapsed.count()); } - else { + else if (tc_strstr(item_id, "2ZDB") == NULL) { + ITKCALL(AOM_ask_value_tags(designRev, "representation_for", &num, &mantrs)); map partsCcp; for (int i = 0; i < num; i++) { char* type, *zt2_ifpbom, *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) { // + if (tc_strstr(type, "Part") != NULL && tc_strcmp(zt2_ifpbom, "P") != 0) { // tag_t matnrItem; ITKCALL(ITEM_ask_item_of_rev(mantrs[i], &matnrItem)); partsCcp[itemId] = matnrItem; } } + bomtime = std::chrono::high_resolution_clock::now(); + elapsed = bomtime - start; + printf("getSapPart2num%d:%f\n", num, elapsed.count()); map::iterator it; for (it = partsCcp.begin(); it != partsCcp.end(); it++) { string s = it->first; @@ -183,6 +198,9 @@ tag_t getSapPart(tag_t designRevLine, tag_t designRev, string& errBuff, NodeBean //} parts.push_back(partRevLast); } + bomtime = std::chrono::high_resolution_clock::now(); + elapsed = bomtime - start; + printf("getSapPart2it%zd:%f\n", partsCcp.size(), elapsed.count()); } if (parts.size() == 1) { return parts[0]; @@ -200,7 +218,11 @@ tag_t getSapPart(tag_t designRevLine, tag_t designRev, string& errBuff, NodeBean //} ITKCALL(AOM_ask_value_string(designRevLine, "ZT2_TYSpecifications", &zt2_TYJNo)); ITKCALL(AOM_ask_value_string(designRev, "zt2_Specifications", &spec)); - if (strcmp(zt2_TYJNo, "") != 0) { + + bomtime = std::chrono::high_resolution_clock::now(); + elapsed = bomtime - start; + printf("getSapPart2:%f\n", elapsed.count()); + if (tc_strcmp(zt2_TYJNo, "") != 0) { string qryVal; tag_t query = NULLTAG, *tags; map map_revs; @@ -219,6 +241,7 @@ tag_t getSapPart(tag_t designRevLine, tag_t designRev, string& errBuff, NodeBean map_revs[zt2_MaterialNo] = rev; } } + vector keySet = KeySet(map_revs); sort(keySet.begin(), keySet.end(), myCompare); for (int i = 0; i < keySet.size(); i++) { @@ -238,7 +261,11 @@ tag_t getSapPart(tag_t designRevLine, tag_t designRev, string& errBuff, NodeBean if (vals[k].rfind("F064:", 0) == 0) { string temp = replace_all2(vals[k], "F064:", ""); printf("temp===>%s\n", temp.c_str()); - if (strstr(zt2_TYJNo, temp.c_str()) != NULL) { + if (tc_strstr(zt2_TYJNo, temp.c_str()) != NULL) { + bomtime = std::chrono::high_resolution_clock::now(); + elapsed = bomtime - start; + printf("getSapPart3:%f\n", elapsed.count()); + return map_revs[materialNo]; } break; @@ -246,7 +273,7 @@ tag_t getSapPart(tag_t designRevLine, tag_t designRev, string& errBuff, NodeBean } } } - if (!strcmp(zt2_Diagram, "Y") == 0 && !strcmp(zt2_Diagram, "是") == 0) { + if (!tc_strcmp(zt2_Diagram, "Y") == 0 && !tc_strcmp(zt2_Diagram, "是") == 0) { string buffErr = ""; buffErr.append("缺少物料编码[找不到与通用件规格相匹配的物料-(*").append(searchId) .append("*").append(zt2_TYJNo).append(")];\n"); @@ -258,11 +285,41 @@ tag_t getSapPart(tag_t designRevLine, tag_t designRev, string& errBuff, NodeBean } } + if (tc_strstr(item_id, "2ZDB") != NULL) { + ITKCALL(AOM_ask_value_tags(designRev, "representation_for", &num, &mantrs)); + map partsCcp; + for (int i = 0; i < num; i++) { + char* type, *zt2_ifpbom, *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 (tc_strstr(type, "Part") != NULL && tc_strcmp(zt2_ifpbom, "P") != 0) { // + tag_t matnrItem; + ITKCALL(ITEM_ask_item_of_rev(mantrs[i], &matnrItem)); + partsCcp[itemId] = matnrItem; + } + } + bomtime = std::chrono::high_resolution_clock::now(); + elapsed = bomtime - start; + printf("getSapPart2num%d:%f\n", num, elapsed.count()); + map::iterator it; + for (it = partsCcp.begin(); it != partsCcp.end(); it++) { + string s = it->first; + tag_t partLast = partsCcp[s], partRevLast; + ITKCALL(ITEM_ask_latest_rev(partLast, &partRevLast)); + //if (parts.size() == 0) { + //} + parts.push_back(partRevLast); + } + bomtime = std::chrono::high_resolution_clock::now(); + elapsed = bomtime - start; + printf("getSapPart2it%zd:%f\n", partsCcp.size(), elapsed.count()); + } for (int i = 0; i < parts.size(); i++) { tag_t part = parts[i]; char* specPart; ITKCALL(AOM_ask_value_string(part, "zt2_Specifications", &specPart)); - if (strcmp(specPart, spec) == 0) { + if (tc_strcmp(specPart, spec) == 0) { return part; } /*String spec2 = parts.get(i).getProperty("zt2_Specifications"); @@ -270,7 +327,10 @@ tag_t getSapPart(tag_t designRevLine, tag_t designRev, string& errBuff, NodeBean return parts.get(i); }*/ } - if (!strcmp(zt2_Diagram, "Y") == 0 && !strcmp(zt2_Diagram, "是") == 0) { + bomtime = std::chrono::high_resolution_clock::now(); + elapsed = bomtime - start; + printf("getSapPart4:%f\n", elapsed.count()); + if (!tc_strcmp(zt2_Diagram, "Y") == 0 && !tc_strcmp(zt2_Diagram, "是") == 0) { //errBuff.append("缺少物料编码[找不到相同规格的物料(").append(spec).append(")];"); string buffErr = ""; buffErr.append("缺少物料编码[找不到相同规格的物料(").append(spec).append(")];"); @@ -398,7 +458,11 @@ void askLineVal(NodeBean& bean, tag_t bom_line, tag_t designRev, string& errBuff bean.bl_sequence_no = bl_sequence_no; } //根据图纸获取物料 包含通用件的逻辑 + auto start = std::chrono::high_resolution_clock::now(); tag_t part = getSapPart(bom_line, designRev, errBuff, bean); + auto bomtime = std::chrono::high_resolution_clock::now(); + std::chrono::duration elapsed = bomtime - start; + printf("getSapPart:%f\n", elapsed.count()); //printf("11111111\n"); if (part != NULLTAG) { //BOM_writer @@ -569,14 +633,12 @@ void getAllXnj(vector xnzjbVec, int maxNum, int &xxt, * @param dbName 原材料展开数据库信息 * @param loginUserId 用户信息 */ -void recyReadBom(tag_t bom_line, NodeBean& pBean, string& errBuff, string dbName, char *loginUserId) +void recyReadBom(tag_t bom_line, tag_t designRev, NodeBean& pBean, string& errBuff, string dbName, char *loginUserId) { - int c_line_count; - char* uid, *type, *zt2_Diagram, *source, *itemId, *object_name; - //图纸版本、子行 - tag_t designRev, *c_line_tags; - ITKCALL(AOM_ask_value_tag(bom_line, "bl_line_object", &designRev)); - //printf("1222"); + int c_line_count = 0; + char *itemId = NULL, *uid = NULL, *type = NULL, *zt2_Diagram = NULL, *source = NULL, *object_name = NULL, *os = NULL; + tag_t *c_line_tags; + ITKCALL(AOM_ask_value_string(designRev, "item_id", &itemId)); ITK__convert_tag_to_uid(designRev, &uid); //printf("revUid===>%s\n", uid); pBean.revUid = uid; @@ -603,9 +665,6 @@ void recyReadBom(tag_t bom_line, NodeBean& pBean, string& errBuff, string dbName return; } - boolean flagMat = false; - //根据图纸获取物料信息 - askLineVal(pBean, bom_line, designRev, errBuff, flagMat); tag_t tagUser; char *tagId; ITKCALL(AOM_ask_value_tag(designRev, "owning_user", &tagUser)); @@ -618,30 +677,41 @@ void recyReadBom(tag_t bom_line, NodeBean& pBean, string& errBuff, string dbName if (strcmp(type, "ZT2_XNZJBRevision") == 0) { return; } - //外购 不展开子件 - if (strstr(itemId, "2ZD") != NULL || strstr(itemId, "4ZD") != NULL) { - if (!flagMat) { - pBean.isOutBuy = true; - return; + if (bom_line != NULLTAG) { + //图纸版本、子行 + ITKCALL(AOM_ask_value_string(bom_line, "object_string", &os)); + //ITKCALL(AOM_ask_value_tag(bom_line, "bl_line_object", &designRev)); + //printf("1222"); + + boolean flagMat = false; + //根据图纸获取物料信息 + askLineVal(pBean, bom_line, designRev, errBuff, flagMat); + //外购 不展开子件 + if (strstr(itemId, "2ZD") != NULL || strstr(itemId, "4ZD") != NULL) { + if (!flagMat) { + pBean.isOutBuy = true; + return; + } } - } - if (strstr(itemId, "1ZD") != NULL) { - ITKCALL(AOM_ask_value_string(designRev, "zt2_Source", &source)); - if (strcmp(source, "S2") == 0 || strcmp(source, "外购") == 0) { - pBean.isOutBuy = true; - return; + if (strstr(itemId, "1ZD") != NULL) { + ITKCALL(AOM_ask_value_string(designRev, "zt2_Source", &source)); + if (strcmp(source, "S2") == 0 || strcmp(source, "外购") == 0) { + pBean.isOutBuy = true; + return; + } } - } - /*ITKCALL(BOM_line_ask_all_child_lines(bom_line, &c_line_count, &c_line_tags)); - for (int i = 0; i < c_line_count; i++) { + /*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; ITKCALL(BOM_line_is_packed(c_line_tags[i], &flag)); if (flag) { - ITKCALL(BOM_line_unpack(c_line_tags[i])); + ITKCALL(BOM_line_unpack(c_line_tags[i])); + } } + AOM_refresh(bom_line, FALSE);*/ + ITKCALL(BOM_line_ask_all_child_lines(bom_line, &c_line_count, &c_line_tags)); } - 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)) { @@ -664,7 +734,6 @@ void recyReadBom(tag_t bom_line, NodeBean& pBean, string& errBuff, string dbName if (found == std::string::npos) { errBuff.append(buffErr); } - } for (int t = 0; t < outputValueCount1; t++) { string materialno = outputValue1[t][0]; @@ -698,13 +767,13 @@ void recyReadBom(tag_t bom_line, NodeBean& pBean, string& errBuff, string dbName if (suppressed) { continue; } - char* os = NULL; - ITKCALL(AOM_ask_value_string(c_line_tags[i], "object_string", &os)); + char* os2 = NULL; + ITKCALL(AOM_ask_value_string(c_line_tags[i], "object_string", &os2)); //修改过之后之前已经是解包的状态了 logical flag; char *remark; ITKCALL(BOM_line_is_packed(c_line_tags[i], &flag)); - printf("flag1=%d==>%s\n", flag, os); + printf("flag1=%d==>%s\n", flag, os2); ITKCALL(AOM_ask_value_string(c_line_tags[i], "ZT2_Remark", &remark)); //printf("recyReadBom:%s\n", remark); if (flag) { @@ -747,7 +816,7 @@ void recyReadBom(tag_t bom_line, NodeBean& pBean, string& errBuff, string dbName cBean.packNum = count + 1; cBean.topNum = atoi(topNum); cBean.remark = remark; - recyReadBom(c_line_tags[i], cBean, errBuff, dbName, loginUserId); + recyReadBom(c_line_tags[i], c_Rev, cBean, errBuff, dbName, loginUserId); pBean.childs.push_back(cBean); } @@ -782,7 +851,7 @@ void recyReadBom(tag_t bom_line, NodeBean& pBean, string& errBuff, string dbName cBean.revUid = cUid; cBean.designRev = c_Rev; cBean.remark = remark; - recyReadBom(c_line_tags[i], cBean, errBuff, dbName, loginUserId); + recyReadBom(c_line_tags[i], c_Rev, cBean, errBuff, dbName, loginUserId); pBean.childs.push_back(cBean); } } @@ -800,7 +869,7 @@ void recyReadBom(tag_t bom_line, NodeBean& pBean, string& errBuff, string dbName * @param dbName 原材料展开的数据表 * @param idVector 需要D转E的BOM类别 */ -void recyReadBom(tag_t bom_line, NodeBean& pBean, string& errBuff, string dbName, vector idVector) +void recyReadBom2(tag_t bom_line, NodeBean& pBean, string& errBuff, string dbName, vector idVector) { int c_line_count; char* uid, *type, *zt2_Diagram, *source, *itemId, *object_name; @@ -967,7 +1036,7 @@ void recyReadBom(tag_t bom_line, NodeBean& pBean, string& errBuff, string dbName cBean.packNum = count + 1; cBean.topNum = atoi(topNum); cBean.remark = remark; - recyReadBom(c_line_tags[i], cBean, errBuff, dbName, idVector); + recyReadBom2(c_line_tags[i], cBean, errBuff, dbName, idVector); pBean.childs.push_back(cBean); } @@ -993,7 +1062,7 @@ void recyReadBom(tag_t bom_line, NodeBean& pBean, string& errBuff, string dbName cBean.revUid = cUid; cBean.designRev = c_Rev; cBean.remark = remark; - recyReadBom(c_line_tags[i], cBean, errBuff, dbName, idVector); + recyReadBom2(c_line_tags[i], cBean, errBuff, dbName, idVector); pBean.childs.push_back(cBean); } } @@ -1064,7 +1133,7 @@ void getAllXnj(vector xnzjbVec, int maxNum, int &xxt, xxt = xxt + 1; cBean.bl_sequence_no = lastnum; cBean.remark = remark; - recyReadBom(cc_line_tags[j], cBean, errBuff, dbName, idVector); + recyReadBom2(cc_line_tags[j], cBean, errBuff, dbName, idVector); pBean.childs.push_back(cBean); } printf("xnzjbVec2 ===> %d ==>%d \n", xnzjbVec2.size(), qtyPXn); @@ -1135,7 +1204,7 @@ void getAllXnj(vector xnzjbVec, int maxNum, int &xxt, cBean.bl_sequence_no = lastnum; cBean.remark = remark; //非虚拟件的继续原逻辑展开 - recyReadBom(cc_line_tags[j], cBean, errBuff, dbName, loginUserId); + recyReadBom(cc_line_tags[j], c_Rev, cBean, errBuff, dbName, loginUserId); pBean.childs.push_back(cBean); } printf("xnzjbVec2 ===> %d ==>%d \n", xnzjbVec2.size(), qtyPXn); @@ -1642,9 +1711,10 @@ int DbomToEMethod(void* returnValue) { tag_t* bvr_list = NULL; ITKCALL(ITEM_rev_list_bom_view_revs(designRev, &bvr_count, &bvr_list)); printf("bvr_count=%d", bvr_count); - - ITKCALL(BOM_set_window_top_line_bvr(ebom_window, bvr_list[0], &bom_line)); //顶层bom获取 - printf("顶层bom获取\n"); + if (bvr_count > 0) { + ITKCALL(BOM_set_window_top_line_bvr(ebom_window, bvr_list[0], &bom_line)); //顶层bom获取 + printf("顶层bom获取\n"); + } //(BOM_line_ask_all_child_lines(bom_line, &c_line_count, &c_line_tags)); NodeBean topBean; @@ -1683,7 +1753,7 @@ int DbomToEMethod(void* returnValue) { printf("dbName===%s\n", dbName.c_str()); ITKCALL(POM_get_user_id(&loginUserId)); - recyReadBom(bom_line, topBean, errBuff, dbName, loginUserId); + recyReadBom(bom_line, designRev, topBean, errBuff, dbName, loginUserId); DisConnServer(); ITKCALL(BOM_close_window(ebom_window)); auto time2 = std::chrono::high_resolution_clock::now(); @@ -1882,7 +1952,7 @@ int DbomToEMethodUser(void* returnValue) { elapsed = time1 - start; printf("time1:%f\n", elapsed.count()); - recyReadBom(bom_line, topBean, errBuff, dbName, idVector); + recyReadBom2(bom_line, topBean, errBuff, dbName, idVector); auto time2 = std::chrono::high_resolution_clock::now(); elapsed = time2 - start; printf("time2:%f\n", elapsed.count()); diff --git a/General/General/EbomToPMethod.cpp b/General/General/EbomToPMethod.cpp index ace55cf..0facd88 100644 --- a/General/General/EbomToPMethod.cpp +++ b/General/General/EbomToPMethod.cpp @@ -1527,6 +1527,7 @@ tag_t saveAsMaterial(EBomUpBean topBean, boolean isTop, */ void startUpdate(EBomUpBean upBean, tag_t pBomTag, int len, tag_t dcproxy, boolean isTop, string &hasChange, map& saveAsMap) { + auto start = std::chrono::high_resolution_clock::now(); //记录的EBOM下面的子件 printf("startUpdate===>%s\n", upBean.matnrNo.c_str()); vector vecs = upBean.parentBean; @@ -1552,6 +1553,10 @@ void startUpdate(EBomUpBean upBean, tag_t pBomTag, int len, tag_t dcproxy, //原来没有PBOM return; } + auto bomtime = std::chrono::high_resolution_clock::now(); + std::chrono::duration elapsed = bomtime - start; + printf("startUpdate1 %s:%f\n", upBean.matnrNo.c_str(), elapsed.count()); + ITKCALL(BOM_set_window_top_line_bvr(ebom_window2, bvr_list2[0], &bom_line)); //顶层bom获取 ITKCALL(BOM_line_ask_all_child_lines(bom_line, &c_line_count, &c_line_tags)); for (int i = 0; i < c_line_count; i++) { @@ -1576,6 +1581,9 @@ void startUpdate(EBomUpBean upBean, tag_t pBomTag, int len, tag_t dcproxy, ITKCALL(BOM_line_cut(c_line_tag));//pBomMap[matnrNo] = c_line_tag; } } + bomtime = std::chrono::high_resolution_clock::now(); + elapsed = bomtime - start; + printf("startUpdate2 %s:%f\n", upBean.matnrNo.c_str(), elapsed.count()); //移除所有非P 再从EBOM复制 printf("xqTagVec===>%d\n", xqTagVec.size()); POM_AM__set_application_bypass(true); @@ -1596,15 +1604,18 @@ void startUpdate(EBomUpBean upBean, tag_t pBomTag, int len, tag_t dcproxy, } addToAmatnrUp(vecs, len, newPAmatnr, lastFlag); } + bomtime = std::chrono::high_resolution_clock::now(); + elapsed = bomtime - start; + printf("startUpdate3 %s:%f\n", upBean.matnrNo.c_str(), elapsed.count()); if (xqTagVec.size() == 0) { //不是线圈 移除后复制 printf("vecs===>%zd\n", vecs.size()); for (int i = 0; i < vecs.size(); i++) { - printf("i===>%d\n", i); + //printf("i===>%d\n", i); EBomUpBean cupBean = vecs[i]; //重新复制 if (std::find(matnrVec.begin(), matnrVec.end(), cupBean.matnrNo) != matnrVec.end()) { - printf("matnrVec ===>%s\n", cupBean.matnrNo.c_str()); + //printf("matnrVec ===>%s\n", cupBean.matnrNo.c_str()); tag_t c_line_tag = pBomMap[cupBean.matnrNo], bomView = NULLTAG, childPTag = NULLTAG; boolean flagAs = false; @@ -1615,12 +1626,12 @@ void startUpdate(EBomUpBean upBean, tag_t pBomTag, int len, tag_t dcproxy, ITKCALL(BOM_save_window(bomView)); ITKCALL(BOM_close_window(bomView)); } - printf("i2===>%d\n", i); + //printf("i2===>%d\n", i); } else { boolean flagLc = false; char* seq = NULL, *ZT2_Remark = NULL; - printf("matnrVecNotP===>%s\n", cupBean.matnrNo.c_str()); + //printf("matnrVecNotP===>%s\n", cupBean.matnrNo.c_str()); tag_t cline = cupBean.bomline, newChild = NULLTAG; ITKCALL(BOM_line_copy(bom_line, cline, NULLTAG, &newChild)); if (newChild == NULLTAG) { @@ -1655,6 +1666,9 @@ void startUpdate(EBomUpBean upBean, tag_t pBomTag, int len, tag_t dcproxy, } } } + bomtime = std::chrono::high_resolution_clock::now(); + elapsed = bomtime - start; + printf("startUpdate4 %s:%f\n", upBean.matnrNo.c_str(), elapsed.count()); for (int i = 0; i < matnrVec.size(); i++) { bool cut = true; for (int j = 0; j < vecs.size(); j++) { @@ -1669,11 +1683,17 @@ void startUpdate(EBomUpBean upBean, tag_t pBomTag, int len, tag_t dcproxy, ITKCALL(BOM_line_cut(c_line_tag)); } }/**/ + bomtime = std::chrono::high_resolution_clock::now(); + elapsed = bomtime - start; + printf("startUpdate5 %s:%f\n", upBean.matnrNo.c_str(), elapsed.count()); } //移除所有非P 再从EBOM复制 ITKCALL(BOM_save_window(ebom_window2)); ITKCALL(BOM_close_window(ebom_window2)); + bomtime = std::chrono::high_resolution_clock::now(); + elapsed = bomtime - start; + printf("startUpdate6 %s:%f\n", upBean.matnrNo.c_str(), elapsed.count()); printf("startUpdate end===>%s\n", upBean.matnrNo.c_str()); } /** diff --git a/General/General/chint_add_to_workflow.cpp b/General/General/chint_add_to_workflow.cpp index 7a1f17b..17cbad8 100644 --- a/General/General/chint_add_to_workflow.cpp +++ b/General/General/chint_add_to_workflow.cpp @@ -32,6 +32,7 @@ #include #include #include +#include // #include "hx_custom.h" #include "tc_log.h" // #include "jk_custom.h" @@ -202,6 +203,7 @@ void addToFlow(tag_t bom_line,tag_t rootTask_tag, map &uidMap) { int target = EPM_target_attachment; //版本有BOM视图且发布 ITKCALL(AOM_ask_value_tags(rev, "structure_revisions", &structs, &structure_revisions)); + printf("structs===>%d\n", structs); if (structs > 0) { int statusNum = 0, statusNum2=0; char *revUid = NULL, *bomUid = NULL; @@ -211,6 +213,7 @@ void addToFlow(tag_t bom_line,tag_t rootTask_tag, map &uidMap) { if (uidMap.count(revUid) == 0) { uidMap[revUid] = "1"; ITKCALL(AOM_ask_value_tags(rev, "release_status_list", &statusNum, &release_status_list2)); + printf("statusNum===>%d\n", statusNum); if (statusNum > 0) { //已发布的版本放在引用关系 ITKCALL(EPM_add_attachments(rootTask_tag, 1, &rev, &reference)); @@ -219,6 +222,7 @@ void addToFlow(tag_t bom_line,tag_t rootTask_tag, map &uidMap) { tag_t *stageTags; int stageNum = 0; ITKCALL(AOM_ask_value_tags(rev, "process_stage_list", &stageNum, &stageTags)); + printf("stageNum===>%d\n", stageNum); if (stageNum > 0) { //已有流程的版本放在引用关系 ITKCALL(EPM_add_attachments(rootTask_tag, 1, &rev, &reference)); @@ -235,11 +239,13 @@ void addToFlow(tag_t bom_line,tag_t rootTask_tag, map &uidMap) { //printf("bomUid:%s\n", bomUid); statusNum = 0; ITKCALL(AOM_ask_value_tags(struct_revision, "release_status_list", &statusNum, &release_status_list)); + printf("statusNum2===>%d\n", statusNum); if (statusNum==0 && uidMap.count(bomUid)==0) { uidMap[bomUid] = "1"; tag_t *stageTags; int stageNum = 0; ITKCALL(AOM_ask_value_tags(struct_revision, "process_stage_list", &stageNum, &stageTags)); + printf("stageNum2===>%d\n", stageNum); if (stageNum > 0) { ITKCALL(EPM_add_attachments(rootTask_tag, 1, &struct_revision, &reference)); } @@ -253,11 +259,12 @@ void addToFlow(tag_t bom_line,tag_t rootTask_tag, map &uidMap) { int c_line_count; tag_t * c_line_tags; ITKCALL(BOM_line_ask_all_child_lines(bom_line, &c_line_count, &c_line_tags)); + printf("c_line_count===>%d\n", c_line_count); for (int num = 0; num < c_line_count; num++) { addToFlow(c_line_tags[num], rootTask_tag, uidMap); } - } + string getPrefVal(char *url_vals,char *itemId) { vector taskComps; string name; @@ -272,6 +279,7 @@ string getPrefVal(char *url_vals,char *itemId) { } return name; } + int CHINT_task_complete(EPM_action_message_t msg) { int ifail = ITK_ok; @@ -282,21 +290,23 @@ int CHINT_task_complete(EPM_action_message_t msg) { int sub_task_count = 0, occur_of_counts = 0; tag_t* taskAttches = NULLTAG; tag_t cur_task = NULLTAG; - char* jobName; + char* jobName = NULL; current_task = msg.task; - AOM_ask_value_string(current_task, "job_name", &jobName); - EPM_ask_root_task(msg.task, &root_task); - EPM_ask_sub_tasks(root_task, &sub_task_count, &sub_tasks); - EPM_ask_attachments(root_task, EPM_target_attachment, &occur_of_counts, &taskAttches); + 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)); int url_num = 0; - char** url_vals = NULL,*uid; - PREF_ask_char_values("CHINT_TaskComplete", &url_num, &url_vals); - char* userName; - int numl; - tag_t workContents,userTag,*task_list; + char** url_vals = NULL, *uid = NULL, *yp_url = NULL; + ITKCALL(PREF_ask_char_values("CHINT_TaskComplete", &url_num, &url_vals)); + ITKCALL(PREF_ask_char_value("CHINT_YPTaskURL", 0, &yp_url)); + + char* userName = NULL; + int numl = 0; + tag_t workContents = NULLTAG, userTag = NULLTAG, *task_list = NULLTAG; //EPM_inbox_query - POM_get_user(&userName, &userTag); - ITKCALL(EPM_ask_assigned_tasks(userTag, 2, &numl,&task_list)); + ITKCALL(POM_get_user(&userName, &userTag)); + ITKCALL(EPM_ask_assigned_tasks(userTag, 2, &numl, &task_list)); printf("提示:uid%d\n", numl); //获取当前节点信息 00089 和 ID前缀 vectornameVec; @@ -315,26 +325,42 @@ int CHINT_task_complete(EPM_action_message_t msg) { printf("n_found===>%d\n", n_found); for (int t = 0; t < n_found; t++) { - tag_t rev = tags[t]; - char *id; - AOM_ask_value_string(rev, "item_id", &id); + tag_t pItem = tags[t]; + char *zt2_ProjectCode = NULL; + string tasklists = ""; + //通过项目ID属性item_id找工作列表任务的逻辑改成通过项目属性“zt2_ProjectCode”查找 + ITKCALL(AOM_ask_value_string(pItem, "zt2_ProjectCode", &zt2_ProjectCode)); string names = getPrefVal(url_vals[0], (char*)projectVec[0].c_str()); vector nameVec; Split(names,"&", nameVec); for (int i = 0; i < nameVec.size(); i++) { - string projName = id; + string projName = zt2_ProjectCode; projName.append("-").append(nameVec[i]); printf("projName %s \n", projName.c_str()); + bool find = true; for (int j = 0; j < numl; j++) { tag_t taskTag = task_list[j]; - char *taskName; - AOM_ask_value_string(taskTag, "job_name", &taskName); + char *taskName = NULL; + ITKCALL(AOM_ask_value_string(taskTag, "job_name", &taskName)); printf("taskName %s \n", taskName); - if (strstr(taskName, projName.c_str())!=NULL) { + if (tc_strstr(taskName, projName.c_str()) != NULL) { ITKCALL(EPM_set_task_result(taskTag, EPM_RESULT_Completed)); ITKCALL(EPM_trigger_action(taskTag, EPM_complete_action, "")); } } + if (find) { + //有数据需要完成计划任务但是实际要执行任务里没有的,需要单独调用查询执行处理,不需要等待接口返回 + if (tasklists.size() > 0) + tasklists.append(","); + tasklists.append("{\"taskname\": \"").append(nameVec[i]).append("\"}"); + } + } + if (tasklists.size() > 0) { + string json = "{\"projectcode\":\""; + json.append(zt2_ProjectCode).append("\",\"tasklists\":[").append(tasklists).append("]}"); + + thread newThread(yp_query, yp_url, json); + newThread.detach(); } } return ifail; @@ -346,7 +372,7 @@ int CHINT_yptask_complete(EPM_action_message_t msg) { ECHO("CHINT_yptask_complete 开始执行\n"); ECHO("=========================================================\n"); int ifail = ITK_ok, sub_task_count = 0, targetCnt = 0, url_num = 0, numl = 0; - char** url_vals = NULL, * userName = NULL; + char** url_vals = NULL, * userName = NULL, *yp_url = NULL; tag_t root_task = NULLTAG, * sub_tasks = NULL, current_task = NULLTAG, type_tag = NULLTAG; tag_t* targets = NULLTAG, userTag = NULLTAG, * task_list = NULLTAG, query = NULLTAG; vector prefVec; @@ -358,6 +384,8 @@ int CHINT_yptask_complete(EPM_action_message_t msg) { } Split(url_vals[0], ";", prefVec); + ITKCALL(PREF_ask_char_value("CHINT_YPTaskURL", 0, &yp_url)); + current_task = msg.task; ITKCALL(EPM_ask_root_task(msg.task, &root_task)); ITKCALL(EPM_ask_sub_tasks(root_task, &sub_task_count, &sub_tasks)); @@ -373,6 +401,7 @@ int CHINT_yptask_complete(EPM_action_message_t msg) { for (int t = 0; t < targetCnt; t++) { tag_t rev = targets[t], item = NULLTAG; char* id = NULL, *type = NULL, *name = NULL; + string tasklists = ""; bool finish = true; ITKCALL(WSOM_ask_object_type2(rev, &type)); ITKCALL(WSOM_ask_name2(rev, &name)); @@ -508,14 +537,15 @@ int CHINT_yptask_complete(EPM_action_message_t msg) { } } } - - char* projectId = NULL; - ITKCALL(AOM_ask_value_string(projects[0], "item_id", &projectId)); + //通过项目ID属性item_id找工作列表任务的逻辑改成通过项目属性“zt2_ProjectCode”查找 + char* zt2_ProjectCode = NULL; + ITKCALL(AOM_ask_value_string(projects[0], "zt2_ProjectCode", &zt2_ProjectCode)); Split(split[1], "&", tasks); for (int i = 0; i < tasks.size(); i++) { - string projName = projectId; + string projName = zt2_ProjectCode; projName.append("-").append(tasks[i]); printf("projName %s \n", projName.c_str()); + bool find = true; for (int j = 0; j < numl; j++) { tag_t taskTag = task_list[j]; char* taskName; @@ -525,8 +555,22 @@ int CHINT_yptask_complete(EPM_action_message_t msg) { ITKCALL(EPM_set_task_result(taskTag, EPM_RESULT_Completed)); ITKCALL(EPM_trigger_action(taskTag, EPM_complete_action, "")); finish = false; + find = false; } } + if (find) { + //有数据需要完成计划任务但是实际要执行任务里没有的,需要单独调用查询执行处理,不需要等待接口返回 + if (tasklists.size() > 0) + tasklists.append(","); + tasklists.append("{\"taskname\": \"").append(tasks[i]).append("\"}"); + } + } + if (tasklists.size() > 0) { + string json = "{\"projectcode\":\""; + json.append(zt2_ProjectCode).append("\",\"tasklists\":[").append(tasklists).append("]}"); + + thread newThread(yp_query, yp_url, json); + newThread.detach(); } ENDCOMPLETE: printf("ENDCOMPLETE\n"); @@ -822,6 +866,7 @@ int chint_add_to_workflow(EPM_action_message_t msg) { ITKCALL(AOM_ask_value_string(comp, "item_id", &itemId)); ITKCALL(ITEM_ask_item_of_rev(comp, &itemTag)); if (itemMap.count(itemId) == 0) { + printf("itemId===>%s\n", itemId); itemMap[itemId] = itemTag; } } @@ -833,6 +878,7 @@ int chint_add_to_workflow(EPM_action_message_t msg) { for (it = itemMap.begin(); it != itemMap.end(); it++) { string s = it->first; tag_t part = itemMap[s]; + printf("itemMap===>%s\n", s.c_str()); //遍历BOM获取所有要投料的 tag_t* bvr_list = NULL, ebom_window = NULL, bom_line = NULL, partRev = NULL; @@ -925,7 +971,7 @@ int chint_remove_other_deisgndata(EPM_action_message_t msg) { char *revtype = NULL; ITKCALL(AOM_ask_value_string(refs[i], "object_type", &revtype)); printf("revtype===>%s\n", revtype); - if (tc_strcmp(type, "Part Revision") != 0) { + if (tc_strcmp(revtype, "Part Revision") != 0) { ITKCALL(AOM_ask_value_tag(taskTag, "owning_user", &tagUser)); break; } diff --git a/General/General/chint_changenotice.cpp b/General/General/chint_changenotice.cpp index c26442f..c809331 100644 --- a/General/General/chint_changenotice.cpp +++ b/General/General/chint_changenotice.cpp @@ -296,12 +296,28 @@ int chint_changenotice(EPM_action_message_t msg) { printf("json================%s\n", json); - + // lidy20240829新接口 + string cmd = "java -jar \""; + cmd.append(getenv("TC_ROOT")).append("\\bin\\uploadMinio.jar\" FS \"").append(json).append("\""); + printf("cmd==>%s", cmd.c_str()); + FILE* pf = NULL; + string strResult; + char buf2[8000] = { 0 }; + if ((pf = _popen(cmd.c_str(), "r")) == NULL) { + printf("接口返回1\n"); + } + else { + printf("接口返回2\n"); + while (fgets(buf2, sizeof buf2, pf)) { + strResult += buf2; + } + _pclose(pf); + } //调用接口 - CURL* curl; + /*CURL* curl; CURLcode res; char readBuffer[10000]; memset(readBuffer, 0, 10000); @@ -322,10 +338,10 @@ int chint_changenotice(EPM_action_message_t msg) { curl_easy_setopt(curl, CURLOPT_POSTFIELDS, gtou(json)); res = curl_easy_perform(curl); } - curl_easy_cleanup(curl); + curl_easy_cleanup(curl);*/ - char* gbk_readBuffer = utog(readBuffer); + char* gbk_readBuffer = utog(strResult.c_str()); printf("json================%s\n", gbk_readBuffer); cJSON* result_json = cJSON_Parse(gbk_readBuffer); cJSON* code = cJSON_GetObjectItem(result_json, "code"); diff --git a/General/General/chint_changenoticebm.cpp b/General/General/chint_changenoticebm.cpp index c29f1dd..43430dc 100644 --- a/General/General/chint_changenoticebm.cpp +++ b/General/General/chint_changenoticebm.cpp @@ -341,12 +341,28 @@ int chint_changenoticebm(EPM_action_message_t msg) { printf("json================%s\n", json); - + // lidy20240829新接口 + string cmd = "java -jar \""; + cmd.append(getenv("TC_ROOT")).append("\\bin\\uploadMinio.jar\" FS \"").append(json).append("\""); + printf("cmd==>%s", cmd.c_str()); + FILE* pf = NULL; + string strResult; + char buf2[8000] = { 0 }; + if ((pf = _popen(cmd.c_str(), "r")) == NULL) { + printf("接口返回1\n"); + } + else { + printf("接口返回2\n"); + while (fgets(buf2, sizeof buf2, pf)) { + strResult += buf2; + } + _pclose(pf); + } //调用接口 - CURL* curl; + /*CURL* curl; CURLcode res; char readBuffer[10000]; memset(readBuffer, 0, 10000); @@ -367,10 +383,10 @@ int chint_changenoticebm(EPM_action_message_t msg) { curl_easy_setopt(curl, CURLOPT_POSTFIELDS, gtoubm(json)); res = curl_easy_perform(curl); } - curl_easy_cleanup(curl); + curl_easy_cleanup(curl);*/ - char* gbk_readBuffer = utogbm(readBuffer); + char* gbk_readBuffer = utogbm(strResult.c_str()); printf("json================%s\n", gbk_readBuffer); cJSON* result_json = cJSON_Parse(gbk_readBuffer); cJSON* code = cJSON_GetObjectItem(result_json, "code"); diff --git a/General/General/common_itk_util.c b/General/General/common_itk_util.c index 2fcbb74..6a700aa 100644 --- a/General/General/common_itk_util.c +++ b/General/General/common_itk_util.c @@ -243,6 +243,18 @@ void WriteLog(const char* format, ...) } } +void WriteLog2(const char* msg) { + printf("%s\n", msg); + if (logFile) { + //info(msg); + fprintf(logFile, "%s\n", msg); + fflush(logFile); + } + else { + printf("*!Error!*: Log File Not Exist\n"); + } +} + void CloseLog(void) { if(logFile) diff --git a/General/General/common_itk_util.h b/General/General/common_itk_util.h index 3460dd4..e15625d 100644 --- a/General/General/common_itk_util.h +++ b/General/General/common_itk_util.h @@ -26,6 +26,7 @@ extern "C" { //void ECHO(char *format, ...); void CreateLogFile(char* FunctionName, char **fullname); void WriteLog(const char* format, ...); +void WriteLog2(const char* msg); void CloseLog(void); //void set_bypass(logical bypass); //void current_time( date_t * date_tag ); diff --git a/General/General/tc_log.cxx b/General/General/tc_log.cxx index 3f944f6..e2023ca 100644 --- a/General/General/tc_log.cxx +++ b/General/General/tc_log.cxx @@ -174,3 +174,14 @@ string getNow(char* format) { } return str; } + +string getDateString(date_t date) { + string str = ""; + str.append(to_string(date.year)).append("-"). + append(to_string(date.month + 1)).append("-"). + append(to_string(date.day)).append(" "). + append(to_string(date.hour)).append(":"). + append(to_string(date.minute)).append(":"). + append(to_string(date.second)); + return str; +} diff --git a/General/General/tc_log.h b/General/General/tc_log.h index 6b19dd2..94da795 100644 --- a/General/General/tc_log.h +++ b/General/General/tc_log.h @@ -26,6 +26,7 @@ string getNow(char* format); //int CompareDate( date_t date1, date_t date2 ); //int GetRandomTempFile( char tempFile[256] ); //logical IsItemRevisionType( char object_type[WSO_name_size_c + 1] ); +string getDateString(date_t date); #ifdef __cplusplus }