From bdcac11b43b324d21efb29b81e443c5a57a47b64 Mon Sep 17 00:00:00 2001 From: "lidy@connor.net.cn" Date: Fri, 12 Jul 2024 15:53:11 +0800 Subject: [PATCH] =?UTF-8?q?20240712=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 | 57 ++++---- General/General/CHINT_CHANGEBOM_TO_SRM.cxx | 11 +- General/General/CHINT_CSH_CHECK.cxx | 126 ++++++++++++++++++ General/General/CHINT_Ecn_SendOA.cxx | 12 +- .../General/CRUL_server_call_httpserver.cpp | 30 +++++ General/General/CRUL_server_call_httpserver.h | 3 +- General/General/CloneProcess.cpp | 4 +- General/General/General.vcxproj | 1 + General/General/General.vcxproj.filters | 3 + General/General/epm_handler_common.h | 1 + General/General/epm_register_handler.cpp | 9 ++ 11 files changed, 221 insertions(+), 36 deletions(-) create mode 100644 General/General/CHINT_CSH_CHECK.cxx diff --git a/General/General/AutoFeeding.cpp b/General/General/AutoFeeding.cpp index e6b8d5b..a57f363 100644 --- a/General/General/AutoFeeding.cpp +++ b/General/General/AutoFeeding.cpp @@ -131,10 +131,12 @@ struct StBomBean { vector childs; }; - -boolean isSt(tag_t matnr) { +/* + 0:外购;1:自制实体;2:自制虚拟 +*/ +int isSt(tag_t matnr) { int cnt2, numFac, cnt3; - boolean flag = false; + int flag = 1; 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)); //包含自制 @@ -142,8 +144,14 @@ boolean isSt(tag_t matnr) { //AOM_ask_value_string(matnr, "object_name",&objName); for (int i = 0; i < numFac; i++) { if (tc_strcmp(factorys[i], "M060") == 0 && cnt2 > i && cnt3 > i) { - if (tc_strstr(procureType[i], "自制") != NULL && tc_strcmp(specialProcureType[i], "/") == 0) { - flag = true; + if (tc_strstr(procureType[i], "外购") != NULL) {//自制 + flag = 0; + } + else if (tc_strcmp(specialProcureType[i], "/") == 0) { + flag = 1; + } + else { + flag = 2; } } } @@ -162,28 +170,26 @@ 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_UIF_ask_value(cmantr, "zt2_SZProcuretype", &zt2_SZProcuretype)); //外购不再展开投料 + //ITKCALL(AOM_UIF_ask_value(cmantr, "zt2_SZProcuretype", &zt2_SZProcuretype)); //外购不再展开投料 printf("虚拟件===>%s\n", cName); StBomBean bean; bean.bomline = cBomLine; bean.currentName = cName; bean.flag = false; - if (c_line_count > 0 && isSt(cmantr)) { - bean.st = true; - //stBomlines.push_back(bean); - pBean.childs.push_back(bean); - } - else if (c_line_count == 0) { + int f = isSt(cmantr); + //1、程序判断物料版本采购类型是什么,如果是外购,那么这个物料进行投料,有没有子件都一样处理 + //2、如果是自制,那么判断特殊采购类型,如果是虚拟,那么此物料不投料,继续展开BOM子件判断,如果没有子,那么此物料也算不需要投料的。如果是/,那么将此物料进行投料。 + if (f == 0 || f == 1) { + //外购和自制实体不看子级直接投本体 bean.st = true; - // stBomlines.push_back(bean); pBean.childs.push_back(bean); } - else if (tc_strcmp(zt2_SZProcuretype, "外购") != 0) { + else if (c_line_count > 0) { + //自制虚拟有子级就投子级 for (int i = 0; i < c_line_count; i++) { tag_t c_line_tag = c_line_tags[i]; getBomMessage(stBomlines, c_line_tag, bean); } - // stBomlines.push_back(bean); pBean.childs.push_back(bean); } } @@ -200,29 +206,26 @@ void getBomMessage(vector &stBomlines, tag_t cBomLine) { 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_UIF_ask_value(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; - if (c_line_count > 0 && isSt(cmantr)) { - bean.st = true; - stBomlines.push_back(bean); - } - else if (c_line_count == 0) { + int f = isSt(cmantr); + //1、程序判断物料版本采购类型是什么,如果是外购,那么这个物料进行投料,有没有子件都一样处理 + //2、如果是自制,那么判断特殊采购类型,如果是虚拟,那么此物料不投料,继续展开BOM子件判断,如果没有子,那么此物料也算不需要投料的。如果是/,那么将此物料进行投料。 + if (f == 0 || f == 1) { + //外购和自制实体不看子级直接投本体 bean.st = true; stBomlines.push_back(bean); - //printf("st = true===>%s\n", cName); } - else if (tc_strcmp(zt2_SZProcuretype, "外购") != 0) { - //虚拟件向下展开 //实体件直接投料 - printf("虚拟件============>%s\n", cName); + else if (c_line_count > 0) { + //自制虚拟有子级就投子级 for (int i = 0; i < c_line_count; i++) { tag_t c_line_tag = c_line_tags[i]; getBomMessage(stBomlines, c_line_tag, bean); } stBomlines.push_back(bean); - printf("虚拟件===========>%zd\n", bean.childs.size()); } } //虚拟向下展开,实体投料 @@ -688,7 +691,7 @@ 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) || tc_strstr(objName, "变压器") != NULL || isback)) { + if (c_line_count > 0 && (isSt(rev) == 1 || tc_strstr(objName, "变压器") != NULL || isback)) { auto start = std::chrono::high_resolution_clock::now(); int n_references = 0; diff --git a/General/General/CHINT_CHANGEBOM_TO_SRM.cxx b/General/General/CHINT_CHANGEBOM_TO_SRM.cxx index 2eca61b..92515f6 100644 --- a/General/General/CHINT_CHANGEBOM_TO_SRM.cxx +++ b/General/General/CHINT_CHANGEBOM_TO_SRM.cxx @@ -261,11 +261,16 @@ int CHINT_CHANGEBOM_TO_SRM(EPM_action_message_t msg) { 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); + //lidy20240710 + string xml = ""); + 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 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])); + returnMsg.append(ecnSendOA(xml, urls[i])); } WriteLog("回传信息\n %s\n", returnMsg.c_str()); if (!returnMsg.empty()) { diff --git a/General/General/CHINT_CSH_CHECK.cxx b/General/General/CHINT_CSH_CHECK.cxx new file mode 100644 index 0000000..9ca7119 --- /dev/null +++ b/General/General/CHINT_CSH_CHECK.cxx @@ -0,0 +1,126 @@ + +#include "epm/epm.h" +#include +#include +#include +#include +#include "ocilib.h" +#include "string_utils.h" +#include "epm_handler_common.h" + +string getCshVal2(string name, string code) { + + string strResult = "", schVal = ""; + //cmd指令 + char cmd[256] = ""; + strcpy(cmd, "java -jar \""); + //strcat(cmd, jar_file); + strcat(cmd, getenv("TC_ROOT")); + strcat(cmd, "\\bin\\findCshSql.jar"); + strcat(cmd, "\" \""); + strcat(cmd, name.c_str()); + strcat(cmd, "\" \""); + strcat(cmd, code.c_str()); + strcat(cmd, "\""); + printf("cmd:%s\n", cmd); + char buf[8000] = { 0 }; + FILE* pf = NULL; + if ((pf = _popen(cmd, "r")) == NULL) { + printf("接口返回1"); + } + + while (fgets(buf, sizeof buf, pf)) { + strResult += buf; + } + printf("接口返回:%s", strResult.c_str()); + _pclose(pf); + + return strResult; +} + +EPM_decision_t chint_csh_check(EPM_rule_message_t msg) { + printf("********************* chint_csh_check is comming ! *********************\n"); + + EPM_decision_t customError = EPM_go; + + int url_num = 0; + char** url_vals = NULL; + ITKCALL(PREF_ask_char_values("database_tc", &url_num, &url_vals)); + string url = url_vals[0]; + url.append("/").append(url_vals[2]); + printf("url ==> %s \n", url.c_str()); + if (ConnServer(url_vals[3], url_vals[4], (char*)url.c_str()) == -1) + { + ITKCALL(EMH_store_error_s1(EMH_severity_user_error, EMH_USER_error_base, "错误:TC数据库连接失败")); + customError = EPM_nogo; + return customError; + } + + tag_t pRoot = NULLTAG; + ITKCALL(EPM_ask_root_task(msg.task, &pRoot)); + int target_count = 0; + tag_t *targets = NULL; + ITKCALL(EPM_ask_attachments(pRoot, EPM_target_attachment, &target_count, &targets)); + //map map; + string msgs = ""; + for (int t = 0; t < target_count; t++) { + char* type = NULL; + ITKCALL(WSOM_ask_object_type2(targets[t], &type)); + if (tc_strcmp(type, "ZT2_Design3DRevision") != 0) { + continue; + } + char* item_id = NULL; + ITKCALL(AOM_ask_value_string(targets[t], "item_id", &item_id)); + string id = item_id; + //总装图号为前四位+300000P 拼接-后的尾缀 + string topID = id.substr(0, 4); + topID.append("300000P").append(id.substr(11)); + tag_t top_classificationObject = NULLTAG, topItem = NULLTAG; + ITKCALL(ITEM_find_item(topID.c_str(), &topItem)); + ITKCALL(ICS_ask_classification_object(topItem, &top_classificationObject)); + if (top_classificationObject == NULLTAG) { + msgs.append(id).append("总装图未发送分类;\n"); + continue; + } + //找到总装图的分类属性:是否参数化设计,如果值为是,则进行下述的判断逻辑,如果为否,则跳过,无法检查 + int n_attrs; + char** attr_names = NULL, ** attr_vals = NULL; + ITKCALL(ICS_ask_attributes_of_classification_obj(top_classificationObject, &n_attrs, &attr_names, &attr_vals)); + for (int ii = 0; ii < n_attrs; ii++) { + if (strcmp(attr_names[ii], "是否参数化设计") == 0) { + if (strcmp(attr_vals[ii], "是") == 0) { + char selectRxfs[200]; + sprintf(selectRxfs, "select param_code from CHINT_CSH_CHECK_RULE where drawingno='%s'", id.substr(0, 11).c_str()); + int outputColumn3 = 0, outputValueCount3 = 0; + char*** outputValue3 = NULL; + printf("search CHINT_CSH_CHECK_RULE ===> %s\n", selectRxfs); + QuerySQLNoInputParam(selectRxfs, &outputColumn3, &outputValueCount3, &outputValue3); + if (outputValueCount3 == 0) { + //errs.append(id).append(","); + msgs.append(id).append("图纸未查询到参数代号;\n"); + } + else { + string errs = ""; + for (int i = 0; i < outputValueCount3; i++) { + string val = getCshVal2(id.substr(12).c_str(), outputValue3[i][0]); + if (val.size() == 0) { + errs.append(outputValue3[i][0]).append(";"); + } + } + if (errs.size() > 0) { + msgs.append(id).append("图纸所需的参数化数据:").append(errs).append("缺少数据,请先去参数化软件提交后,再执行流程提交;\n"); + } + } + } + break; + } + } + } + printf("msgs:%s\n", msgs.c_str()); + DisConnServer(); + if (msgs.size() > 0) { + ITKCALL(EMH_store_error_s1(EMH_severity_user_error, 919502, msgs.c_str())); + customError = EPM_nogo; + } + return customError; +} \ No newline at end of file diff --git a/General/General/CHINT_Ecn_SendOA.cxx b/General/General/CHINT_Ecn_SendOA.cxx index f8cb9d6..b44ce36 100644 --- a/General/General/CHINT_Ecn_SendOA.cxx +++ b/General/General/CHINT_Ecn_SendOA.cxx @@ -556,11 +556,17 @@ int CHINT_CHANGEITEM_TO_SRM(EPM_action_message_t msg) { 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); + //lidy20240710 + string xml = ""); + 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 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"); + returnMsg.append(ecnSendOA(xml, urls[i])).append("\n"); } WriteLog("回传信息\n %s\n", returnMsg.c_str()); if (!returnMsg.empty()) { diff --git a/General/General/CRUL_server_call_httpserver.cpp b/General/General/CRUL_server_call_httpserver.cpp index 543f862..fe35310 100644 --- a/General/General/CRUL_server_call_httpserver.cpp +++ b/General/General/CRUL_server_call_httpserver.cpp @@ -391,4 +391,34 @@ void updatePiProject(string json,string url) { string str_json = out.str(); curl_easy_cleanup(curl); printf("str_json===>%s\n", str_json.c_str()); +} +/*PLM推送变更通知单数据流信息 +*/ +string ecnSendOA(string entityParamValues, string url) { + CURL* curl; + CURLcode res; + std::stringstream out; + curl = curl_easy_init(); + if (curl) { + curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "POST"); + curl_easy_setopt(curl, CURLOPT_URL, url.c_str()); + curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L); + curl_easy_setopt(curl, CURLOPT_DEFAULT_PROTOCOL, "https"); + curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data); + curl_easy_setopt(curl, CURLOPT_WRITEDATA, &out); + struct curl_slist *headers = NULL; + headers = curl_slist_append(headers, "Content-Type: application/xml"); + curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers); + curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, false); + curl_easy_setopt(curl, CURLOPT_POSTFIELDS, G2U(entityParamValues.c_str())); + res = curl_easy_perform(curl); + //curl_easy_strerror + printf("res=%d\n", res); + } + string str_json = out.str(); + curl_easy_cleanup(curl); + printf("return Msg===>%s\n", str_json.c_str()); + string returnMsg = readXmlMSG(str_json); + + return returnMsg; } \ 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 e00654a..9244134 100644 --- a/General/General/CRUL_server_call_httpserver.h +++ b/General/General/CRUL_server_call_httpserver.h @@ -11,4 +11,5 @@ string readXmlEmailId(string xmlMsg); string getUserIdOA(string email, string url); string getUserIdOAUUID(string uuid, string url); string getAssignFromYP(string url); -void updatePiProject(string json, string url); \ No newline at end of file +void updatePiProject(string json, string url); +string ecnSendOA(string entityParamValues, string url); \ No newline at end of file diff --git a/General/General/CloneProcess.cpp b/General/General/CloneProcess.cpp index 7559bb1..98a0055 100644 --- a/General/General/CloneProcess.cpp +++ b/General/General/CloneProcess.cpp @@ -116,7 +116,7 @@ void updateTemGxCode(tag_t processTag, map temGxMap) { for (int i = 0; i < c_line_count; i++) { tag_t oneGxLine = c_line_tags[i], *towGxLines, oneGx, gxItem; char* gxbm1; - AOM_ask_value_string(oneGxLine, "bl_ZT2_FirstOPRevision_zt2_ClassificationCode", &gxbm1); + ITKCALL(AOM_ask_value_string(oneGxLine, "bl_ZT2_FirstOPRevision_zt2_ClassificationCode", &gxbm1)); printf("gxbm1===>%s\n", gxbm1); if (temGxMap.count(gxbm1) > 0) { @@ -143,7 +143,7 @@ void updateTemGxCode(tag_t processTag, map temGxMap) { } int c_cnt = 0; - BOM_line_ask_all_child_lines(oneGxLine, &c_cnt, &towGxLines); + ITKCALL(BOM_line_ask_all_child_lines(oneGxLine, &c_cnt, &towGxLines)); for (int j = 0; j < c_cnt; j++) { tag_t towGxLine = towGxLines[j]; tag_t towGx, gxItem2; diff --git a/General/General/General.vcxproj b/General/General/General.vcxproj index 71c8c5d..a55bd74 100644 --- a/General/General/General.vcxproj +++ b/General/General/General.vcxproj @@ -187,6 +187,7 @@ + diff --git a/General/General/General.vcxproj.filters b/General/General/General.vcxproj.filters index 4a88b56..86a211d 100644 --- a/General/General/General.vcxproj.filters +++ b/General/General/General.vcxproj.filters @@ -242,5 +242,8 @@ 婧愭枃浠 + + 婧愭枃浠 + \ No newline at end of file diff --git a/General/General/epm_handler_common.h b/General/General/epm_handler_common.h index d47792f..68027db 100644 --- a/General/General/epm_handler_common.h +++ b/General/General/epm_handler_common.h @@ -70,6 +70,7 @@ 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); +EPM_decision_t chint_csh_check(EPM_rule_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 a058311..26b2c94 100644 --- a/General/General/epm_register_handler.cpp +++ b/General/General/epm_register_handler.cpp @@ -347,6 +347,15 @@ extern DLLAPI int USERSERVICE_custom_register_handlers(int *decision, va_list ar printf("Registering action handler CHINT_CHANGEBOM_TO_SRM failed %d\n", ifail); } + //检查目标下版本指定关系的数据集是否为空 + ITKCALL(ifail = EPM_register_rule_handler("chint_csh_check", "", chint_csh_check)); + if (ifail == 0) { + printf("Registering rule handler chint_csh_check successful\n"); + } + else { + printf("Registering rule handler chint_csh_check failed %d\n", ifail); + } + return ifail; } //