From cdb4e24ac952978ea7a23fc5da93c69200774401 Mon Sep 17 00:00:00 2001 From: "lidy@connor.net.cn" Date: Thu, 24 Apr 2025 10:14:20 +0800 Subject: [PATCH] =?UTF-8?q?20250424=201ZDB300000P-=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E5=89=8D=E4=B8=8A=E4=BC=A0=E5=A4=87=E4=BB=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- General/General/CHINT_Ecn_SendOA.cxx | 14 +- General/General/Check_range.cpp | 62 +++- General/General/CloneProcess.cpp | 325 ++++++++++++------ General/General/DtoEBOM2.cpp | 12 +- General/General/EbomToPMethod.cpp | 68 ++-- General/General/General.cpp | 17 + General/General/HXC_create_item_post.cpp | 1 + General/General/chintSignChange.cpp | 2 +- General/General/chint_add_to_workflow.cpp | 4 +- General/General/chint_changenotice.cpp | 73 +++- General/General/chint_changenoticebm.cpp | 71 +++- .../General/chint_check_materialstatus.cpp | 29 +- General/General/epm_handler_common.h | 2 + General/General/epm_register_handler.cpp | 12 + General/General/tc_util.h | 5 +- 15 files changed, 505 insertions(+), 192 deletions(-) diff --git a/General/General/CHINT_Ecn_SendOA.cxx b/General/General/CHINT_Ecn_SendOA.cxx index f9b7a02..c1f71f5 100644 --- a/General/General/CHINT_Ecn_SendOA.cxx +++ b/General/General/CHINT_Ecn_SendOA.cxx @@ -355,12 +355,22 @@ int CHINT_ECN_SendOA(EPM_action_message_t msg) { string userCode = readXmlId(userXML); char *json_to_char = cJSON_Print(paramValue); + //lidy20250211 &转义 + vector v1; + Split(json_to_char, "&", v1); + string json_str = ""; + for (int i = 0; i < v1.size(); i++) { + if (json_str.size() > 0) + json_str.append("&"); + json_str.append(v1[i]); + } + WriteLog("\nworkflowCode=EH_TE_ChangeNotice\nuserCode=%s\nfinishStart=true\n", userCode.c_str()); //WriteLog("组织之后的JSON\n %s\n", json_to_char); string msg = "组织之后的JSON\n"; - msg.append(json_to_char).append("\n"); + msg.append(json_str).append("\n"); WriteLog2(msg.c_str()); - string returnMsg = ecnSendOA(userCode.c_str(), json_to_char, url); + string returnMsg = ecnSendOA(userCode.c_str(), json_str, 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())); diff --git a/General/General/Check_range.cpp b/General/General/Check_range.cpp index 7641249..232ba12 100644 --- a/General/General/Check_range.cpp +++ b/General/General/Check_range.cpp @@ -45,6 +45,8 @@ using namespace libxl; typedef struct{ string ITEM_ID;//id号 }PROPERTY_STRUCT; +void Split(string strArg, string spliter, vector &ans); + string ws2s(const std::wstring& wstr) { @@ -136,26 +138,32 @@ int chint_getChgOrde(EPM_action_message_t msg) { int occur_of_counts; tag_t *taskAttches; //获取属性 - EPM_ask_root_task(msg.task, &root_task); - EPM_ask_attachments(root_task, EPM_target_attachment, &occur_of_counts, &taskAttches); + ITKCALL(EPM_ask_root_task(msg.task, &root_task)); + ITKCALL(EPM_ask_attachments(root_task, EPM_target_attachment, &occur_of_counts, &taskAttches)); for (int count = 0; count < occur_of_counts; count++) { tag_t changeTag = taskAttches[count]; - TCTYPE_ask_object_type(changeTag, &type_tag); - ifail = TCTYPE_ask_class_name(type_tag, type_class); + ITKCALL(TCTYPE_ask_object_type(changeTag, &type_tag)); + ITKCALL(ifail = TCTYPE_ask_class_name(type_tag, type_class)); printf("type_class : %s", type_class); if (strcmp(type_class, "ZT2_Change")==0) { - tag_t oGroup,user; - char * plant, *projn,*pcod,*chgorder,*duser,*chginfo; + tag_t oGroup = NULLTAG, user = NULLTAG; + char * plant = NULL, *projn = NULL, *pcod = NULL, *chgorder = NULL, *duser = NULL, *userid = NULL, *chginfo = NULL; string jsonStr, creationStr, zt2_ChangeStr; date_t creation_date, zt2_ChangeDate; jsonStr.append("[{"); - AOM_ask_value_tag(changeTag,"owning_group", &oGroup); - AOM_ask_value_string(oGroup, "name", &plant); - AOM_ask_value_string(changeTag, "zt2_WBSNo", &projn); - AOM_ask_value_string(changeTag, "zt2_ContractNo", &pcod); - AOM_ask_value_string(changeTag, "item_id", &chgorder); - AOM_ask_value_tag(changeTag, "owning_user", &user); - AOM_ask_value_string(user,"user_name",&duser); + ITKCALL(AOM_ask_value_tag(changeTag,"owning_group", &oGroup)); + ITKCALL(AOM_ask_value_string(oGroup, "name", &plant)); + ITKCALL(AOM_ask_value_string(changeTag, "zt2_WBSNo", &projn)); + ITKCALL(AOM_ask_value_string(changeTag, "zt2_ContractNo", &pcod)); + ITKCALL(AOM_ask_value_string(changeTag, "item_id", &chgorder)); + ITKCALL(AOM_ask_value_tag(changeTag, "owning_user", &user)); + ITKCALL(AOM_ask_value_string(user,"user_name",&duser)); + ITKCALL(AOM_ask_value_string(user, "user_id", &userid)); + + //lidy20250114项目名称:获取更改通知单本身属性zt2_ContractName中的值。若未填写,则给空值 + char *zt2_ContractName = NULL; + ITKCALL(AOM_ask_value_string(changeTag, "zt2_ContractName", &zt2_ContractName)); + jsonStr.append("\"plant\":\""); jsonStr.append(plant); jsonStr.append("\","); @@ -168,22 +176,29 @@ int chint_getChgOrde(EPM_action_message_t msg) { jsonStr.append(pcod); jsonStr.append("\","); + jsonStr.append("\"string\":\""); + jsonStr.append(zt2_ContractName ? zt2_ContractName : ""); + jsonStr.append("\","); + jsonStr.append("\"chgorder\":\""); jsonStr.append(chgorder); jsonStr.append("\","); jsonStr.append("\"duser\":\""); jsonStr.append(duser); + jsonStr.append("("); + jsonStr.append(userid); + jsonStr.append(")"); jsonStr.append("\","); - AOM_ask_value_date(changeTag, "creation_date", &creation_date);//zt2_ChangeDate + ITKCALL(AOM_ask_value_date(changeTag, "creation_date", &creation_date));//zt2_ChangeDate creationStr.append(to_string(creation_date.year)).append("-"). append(to_string(creation_date.month+1)).append("-"). append(to_string(creation_date.day)).append(" "). append(to_string(creation_date.hour)).append(":"). append(to_string(creation_date.minute)).append(":").append(to_string(creation_date.second)); - AOM_ask_value_date(changeTag, "zt2_ChangeDate", &zt2_ChangeDate);//zt2_ChangeDate + ITKCALL(AOM_ask_value_date(changeTag, "zt2_ChangeDate", &zt2_ChangeDate));//zt2_ChangeDate zt2_ChangeStr.append(to_string(creation_date.year)).append("-"). append(to_string(creation_date.month+1)).append("-"). append(to_string(creation_date.day)).append(" "). @@ -197,14 +212,23 @@ int chint_getChgOrde(EPM_action_message_t msg) { jsonStr.append(zt2_ChangeStr); jsonStr.append("\","); char **depment; int numdes; - string depments; - AOM_ask_value_strings(changeTag, "zt2_ChangeUnit1",&numdes, &depment); - for (int i = 0; i < numdes; i++) { + string depments = ""; + ITKCALL(AOM_ask_value_strings(changeTag, "zt2_ChangeUnit1",&numdes, &depment)); + /*for (int i = 0; i < numdes; i++) { if (i > 0) { depments.append(";"); } depments.append(depment[i]); + }*/ + printf("depment[0]==>%s", depment[0]); + vector split; + Split(depment[0], " ", split); + for (int i = 0; i < split.size(); i++) { + if (i > 0) + depments.append(";"); + depments.append(split[i]); } + printf("depments==>%s", depments.c_str()); int num2; tag_t* second; jsonStr.append("\"depment\":\""); jsonStr.append(depments); @@ -220,7 +244,7 @@ int chint_getChgOrde(EPM_action_message_t msg) { jsonStr.append("\""); jsonStr.append("}]"); string mes = callHttpserver2(jsonStr, "SendMesChange.jar"); - printf("mes==> %s ", mes.c_str()); + printf("mes==>%s", mes.c_str()); } } diff --git a/General/General/CloneProcess.cpp b/General/General/CloneProcess.cpp index 8fa9e00..ca3b6b9 100644 --- a/General/General/CloneProcess.cpp +++ b/General/General/CloneProcess.cpp @@ -90,12 +90,16 @@ void save_representation2(tag_t primaryTag, tag_t secondTag, char* relationType) ITKCALL(AOM_refresh(primaryTag, TRUE)); ITKCALL(AOM_refresh(secondTag, TRUE)); + (AOM_lock(primaryTag)); + (AOM_lock(secondTag)); tag_t relationTag = NULLTAG; ITKCALL(GRM_create_relation(primaryTag, secondTag, typeTag, NULLTAG, &relationTag));//如果关系已经存在,那么就是增加对象 ITKCALL(GRM_save_relation(relationTag));//很必要 (AOM_save(primaryTag)); + (AOM_unlock(primaryTag)); (AOM_save(secondTag)); + (AOM_unlock(secondTag)); ITKCALL(AOM_refresh(primaryTag, FALSE)); ITKCALL(AOM_refresh(secondTag, FALSE)); } @@ -340,15 +344,13 @@ void setZljyx(string gxbm2, string th, string lastId, string name, tag_t towGx) if (beans.size()>0) { tag_t *tableRow; ITKCALL(ITEM_create_item(NULL, objName.c_str(), "ZT2_QCHECK", NULL, &item, &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)); (AOM_save(rev)); - (AOM_unlock(rev)); + (AOM_unlock(rev));//20241211 (AOM_save(item)); - (AOM_unlock(item)); + (AOM_unlock(item));//20241211 for (int i = 0; i < beans.size(); i++) { tag_t table = tableRow[i]; (AOM_lock(table)); @@ -360,6 +362,7 @@ void setZljyx(string gxbm2, string th, string lastId, string name, tag_t towGx) (AOM_unlock(table)); } (AOM_save(towGx)); + (AOM_unlock(towGx)); save_representation2(towGx, item, "ZT2_QualityCheckRelation"); } @@ -424,23 +427,26 @@ void getGxbmMap(tag_t processTag, map& gxDocMap, map beansVec = flBeanMap[gxbm2]; printf("beansVec===>%zd\n", beansVec.size()); if (beansVec.size() > 0) { - tag_t axqPmatnr; + tag_t axqPmatnr = NULLTAG; ITKCALL(AOM_ask_value_tag(towGxLine, "bl_line_object", &axqPmatnr)); ITKCALL(ITEM_rev_list_bom_view_revs(axqPmatnr, &bvr_count, &bvr_list)); printf("bvr_count=%d\n", bvr_count); if (bvr_count == 0) { - tag_t newView, newViewBvr, pitem; + tag_t newView = NULLTAG, newViewBvr = NULLTAG, pitem = NULLTAG; ITKCALL(ITEM_ask_item_of_rev(axqPmatnr, &pitem)); ITKCALL(PS_create_bom_view(NULL, NULL, NULL, pitem, &newView)); (AOM_save(newView)); + (AOM_unlock(newView));//20241211 ITKCALL(PS_create_bvr(newView, NULL, NULL, FALSE, axqPmatnr, &newViewBvr)); (AOM_save(newViewBvr)); + (AOM_unlock(newViewBvr));//20241211 (AOM_save(axqPmatnr)); + (AOM_unlock(axqPmatnr));//20241211 } } //投辅料 for (int n = 0; n < beansVec.size(); n++) { - tag_t cLine; + tag_t cLine = NULLTAG; FlBean cBean = beansVec[n]; if (cBean.flTag == NULLTAG) { continue; @@ -795,7 +801,7 @@ boolean isXn(tag_t matnr) { return flag; } //获取分类属性 判断是否整除 -string getClassVal(tag_t top_rev_tag, string& errMessage, ByqBean &bean) { +string getClassVal(tag_t top_rev_tag, string& errMessage, ByqBean &bean, map& cmap) { //, string className tag_t top_classificationObject = NULLTAG, item = NULLTAG; ITKCALL(ITEM_ask_item_of_rev(top_rev_tag, &item)); @@ -827,7 +833,10 @@ string getClassVal(tag_t top_rev_tag, string& errMessage, ByqBean &bean) { } //break; } - else if (strcmp(attr_names[ii], "低压线圈绕线方式") == 0) { + else { + cmap[attr_names[ii]] = attr_vals[ii]; + } + /*else if (strcmp(attr_names[ii], "低压线圈绕线方式") == 0) { if (strcmp(attr_vals[ii], "") == 0) { //errMessage.append("分类属性低压线圈绕线方式为空,请检查。\n"); //return ""; @@ -876,7 +885,7 @@ string getClassVal(tag_t top_rev_tag, string& errMessage, ByqBean &bean) { bean.wyxq = attr_vals[ii];//cpxh = (attr_vals[ii]); } //break; - } + }*/ //五柱铁心 cout << attr_names[ii] << "\t" << attr_vals[ii] << endl; @@ -1013,18 +1022,19 @@ boolean isTcmOnNot(tag_t process) { } void readProcessBom(tag_t bom_line, string& errorBuff, boolean &flag, tag_t &topProcess, string ¬TcmBuff, string back) { - int c_line_count; - tag_t mantr, *c_line_tags; + int c_line_count = 0; + tag_t mantr = NULLTAG, *c_line_tags = NULLTAG; + char *os = NULL, *objName = NULL; + ITKCALL(AOM_ask_value_string(bom_line, "object_string", &os)); + printf("readProcessBom:%s\n", os); 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)); - char *objName; - AOM_ask_value_string(mantr, "object_name", &objName); + ITKCALL(AOM_ask_value_string(mantr, "object_name", &objName)); if (c_line_count > 0 && (isXn(mantr) || strstr(objName, "变压器") != NULL)) { printf("实体\n"); flag = true; //检查是否有工艺路线 - int n_references = 0; - int* levels = 0; + int n_references = 0, * levels = 0; tag_t* references_tag = NULLTAG; char** relation_type_name = NULL; //通过引用关系查找到变更单 @@ -1041,6 +1051,7 @@ void readProcessBom(tag_t bom_line, string& errorBuff, boolean &flag, tag_t &top } } printf("hasProcess==%d\n", hasProcess); + map cmap1, cmap2; if (!hasProcess) { char* bl_desc = NULL, *itemID = NULL; ITKCALL(AOM_ask_value_string(mantr, "item_id", &itemID)); @@ -1057,7 +1068,7 @@ void readProcessBom(tag_t bom_line, string& errorBuff, boolean &flag, tag_t &top save_representation2(processTag, mantr, "IMAN_METarget"); } } - else if (strstr(objName, "变压器") != NULL) { + else if (tc_strstr(objName, "变压器") != NULL) { tag_t* byqRev = NULLTAG; string tmpGyId; char* uid = NULL; @@ -1066,12 +1077,12 @@ void readProcessBom(tag_t bom_line, string& errorBuff, boolean &flag, tag_t &top ByqBean bean; ITK__convert_tag_to_uid(byqRev[0], &uid); printf("objName%s %s\n", objName, uid); - string cpxh = getClassVal(byqRev[0], errorBuff, bean); + string cpxh = getClassVal(byqRev[0], errorBuff, bean, cmap2); char* thId = NULL; ITKCALL(AOM_ask_value_string(byqRev[0], "item_id", &thId)); printf("cpxh===>%s\n", cpxh.c_str()); tag_t processTag = NULLTAG; - if (strstr(objName, "线圈") == NULL) { + if (tc_strstr(objName, "线圈") == NULL) { vector idVec; Split2(thId, "-", idVec); processTag = getTmpProcess(cpxh, "1ZDB300000P", errorBuff, tmpGyId, false, "", idVec[1]); @@ -1099,12 +1110,21 @@ void readProcessBom(tag_t bom_line, string& errorBuff, boolean &flag, tag_t &top string byqId = "1ZDB300000P-", tmpGyId; tag_t byqTag = NULLTAG, byqRev = NULLTAG, processTag = NULLTAG; byqId.append(wordNo); + printf("byqId===>%s\n", byqId.c_str()); ITKCALL(ITEM_find_item(byqId.c_str(), &byqTag)); ITKCALL(ITEM_ask_latest_rev(byqTag, &byqRev)); + int ics_num = 0; + char** ics_vals = NULL; + ITKCALL(PREF_ask_char_values("CHINT_WHRX", &ics_num, &ics_vals)); + for (int i = 0; i < ics_num; i++) { + vector v1; + Split(ics_vals[i], "=", v1); + cmap1[v1[0]] = v1[1]; + } ByqBean bean; - string cpxh = getClassVal(byqRev, errorBuff, bean); + string cpxh = getClassVal(byqRev, errorBuff, bean, cmap2); printf("cpxh===>%s\n", cpxh.c_str()); - if (strstr(objName, "线圈") == NULL) { + if (tc_strstr(objName, "线圈") == NULL) { processTag = getTmpProcess(cpxh, drawNo, errorBuff, tmpGyId, false, "", wordNo); if (processTag != NULLTAG) { save_representation2(processTag, mantr, "IMAN_METarget"); @@ -1112,7 +1132,21 @@ void readProcessBom(tag_t bom_line, string& errorBuff, boolean &flag, tag_t &top } else { string xqfs; - if (strstr(objName, "低压线圈") != NULL) { + map::iterator it; + for (it = cmap1.begin(); it != cmap1.end(); it++) { + string key = it->first; + if (tc_strstr(objName, key.c_str()) != NULL) { + //当前XXX线圈未在变压器参数表中维护绕线方式分类属性,请前往维护 + if (cmap2[cmap1[key]].empty()) { + errorBuff.append("当前").append(key) + .append("未在变压器参数表中维护绕线方式分类属性,请前往维护\n"); + return; + } + xqfs = cmap2[cmap1[key]]; + break; + } + } + /*if (tc_strstr(objName, "低压线圈") != NULL) { //当前XXX线圈未在变压器参数表中维护绕线方式分类属性,请前往维护 if (bean.dyxq.empty()) { errorBuff.append("当前低压线圈未在变压器参数表中维护绕线方式分类属性,请前往维护\n"); @@ -1120,7 +1154,7 @@ void readProcessBom(tag_t bom_line, string& errorBuff, boolean &flag, tag_t &top } xqfs = bean.dyxq; } - else if (strstr(objName, "中压线圈") != NULL) { + else if (tc_strstr(objName, "中压线圈") != NULL) { //当前XXX线圈未在变压器参数表中维护绕线方式分类属性,请前往维护 if (bean.zyxq.empty()) { errorBuff.append("当前中压线圈未在变压器参数表中维护绕线方式分类属性,请前往维护\n"); @@ -1128,7 +1162,7 @@ void readProcessBom(tag_t bom_line, string& errorBuff, boolean &flag, tag_t &top } xqfs = bean.zyxq; } - else if (strstr(objName, "高压线圈") != NULL) { + else if (tc_strstr(objName, "高压线圈") != NULL) { //当前XXX线圈未在变压器参数表中维护绕线方式分类属性,请前往维护 if (bean.gyxq.empty()) { errorBuff.append("当前高压线圈未在变压器参数表中维护绕线方式分类属性,请前往维护\n"); @@ -1136,7 +1170,7 @@ void readProcessBom(tag_t bom_line, string& errorBuff, boolean &flag, tag_t &top } xqfs = bean.gyxq; } - else if (strstr(objName, "调压线圈") != NULL) { + else if (tc_strstr(objName, "调压线圈") != NULL) { //当前XXX线圈未在变压器参数表中维护绕线方式分类属性,请前往维护 if (bean.tyxq.empty()) { errorBuff.append("当前调压线圈未在变压器参数表中维护绕线方式分类属性,请前往维护\n"); @@ -1144,14 +1178,14 @@ void readProcessBom(tag_t bom_line, string& errorBuff, boolean &flag, tag_t &top } xqfs = bean.tyxq; } - else if (strstr(objName, "稳压线圈") != NULL) { + else if (tc_strstr(objName, "稳压线圈") != NULL) { //当前XXX线圈未在变压器参数表中维护绕线方式分类属性,请前往维护 if (bean.wyxq.empty()) { errorBuff.append("当前稳压线圈未在变压器参数表中维护绕线方式分类属性,请前往维护\n"); return; } xqfs = bean.wyxq; - } + }*/ processTag = getTmpProcess(cpxh, drawNo, errorBuff, tmpGyId, true, xqfs, wordNo); if (processTag != NULLTAG) { save_representation2(processTag, mantr, "IMAN_METarget"); @@ -1162,7 +1196,7 @@ void readProcessBom(tag_t bom_line, string& errorBuff, boolean &flag, tag_t &top } } } - printf("sub readProcessBom\n"); + //printf("sub readProcessBom\n"); for (int i = 0; i < c_line_count; i++) { tag_t c_line_tag = c_line_tags[i]; readProcessBom(c_line_tag, errorBuff, flag, topProcess, notTcmBuff, ""); @@ -1191,30 +1225,37 @@ tag_t getProcess(tag_t designRev) { } return process; } -int CloneTempProcess(void *returnValue) -{ - // 记录开始时间点 - auto start = std::chrono::high_resolution_clock::now(); - int ifail = ITK_ok; - char* sql = NULL, *revUid; - tag_t designRev; - ITKCALL(ifail = USERARG_get_string_argument(&revUid)); - ITK__convert_uid_to_tag(revUid, &designRev); + +void CloneProcess(tag_t designRev, vector> back_prefs, string& errorBuff, string& notTcmBuff) { int bvr_count = 0, c_line_count; - tag_t ebom_window = NULLTAG; - tag_t bom_line = NULLTAG; - tag_t item_tag = NULLTAG, *c_line_tags = NULLTAG; - ITKCALL(BOM_create_window(&ebom_window)); + tag_t ebom_window = NULLTAG, bom_line = NULLTAG, item_tag = NULLTAG, *c_line_tags = NULLTAG; tag_t* bvr_list = NULL; + ITKCALL(BOM_create_window(&ebom_window)); 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获取 - string errorBuff; - string notTcmBuff; - char *bl_desc; + //string errorBuff, notTcmBuff; + char *bl_desc = NULL; ITKCALL(AOM_ask_value_string(bom_line, "bl_rev_object_desc", &bl_desc)); + boolean isback = false; + tag_t meProcess = NULLTAG; + char* objName = NULL, *topId = NULL; + string backs = "", tuhao; + ITKCALL(AOM_ask_value_string(designRev, "object_name", &objName)); + ITKCALL(AOM_ask_value_string(designRev, "item_id", &topId)); + printf("CloneProcess=%s", topId); + for (int i = 0; i < back_prefs.size(); i++) { + for (int j = 0; j < back_prefs.size(); j++) { + if (tc_strstr(objName, back_prefs[i][j].c_str()) != NULL) { + tuhao = back_prefs[i][j]; + isback = true; + break; + } + } + } + + map mapByq; int n_references = 0; int* levels = 0; tag_t* references_tag = NULLTAG; @@ -1228,61 +1269,12 @@ int CloneTempProcess(void *returnValue) char* refType; tag_t refTag = references_tag[i]; ITKCALL(AOM_ask_value_string(refTag, "object_type", &refType)); - if (strcmp(refType, "MEProcessRevision") == 0) { + if (tc_strcmp(refType, "MEProcessRevision") == 0) { hasProcess = true; processTagTop = refTag; break; } } - 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]); - - //map %s \n", url.c_str()); - if (ConnServer(url_vals[3], url_vals[4], (char*)url.c_str()) == -1) - { - printf("提示:中间数据表访问失败\n"); - ifail = 1; - } - boolean isback = false; - tag_t meProcess = NULLTAG; - 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)); - map mapByq; - //如果是产成品的话, 判断是否存在多个P物料 - //20240203备件包工艺路线指派 - int back_num = 0; - char** back_vals = NULL, *group_name = NULL; - tag_t group = NULLTAG; - string tuhao; - 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; 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) { - tuhao = backs[j]; - isback = true; - break; - } - } - if (isback) - break; - } - } if (isback) { isback = false; int b_refs = 0; @@ -1311,7 +1303,8 @@ int CloneTempProcess(void *returnValue) if (n_drows == 0) continue; ByqBean bean; - cpxh = getClassVal(drows[0], errorBuff, bean); + map cmap; + cpxh = getClassVal(drows[0], errorBuff, bean, cmap); isback = true; break; } @@ -1349,7 +1342,7 @@ int CloneTempProcess(void *returnValue) 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 (tc_strcmp(pId, topId) != 0 && tc_strcmp(zt2_ifpbom, "P") == 0) { tag_t process = getProcess(pMatr); if (process != NULLTAG) { meProcess = process; @@ -1386,8 +1379,40 @@ int CloneTempProcess(void *returnValue) //errorBuff = "当前选中的物料已经存在工艺路线.\n"; } } + else if (!isXn(designRev)) { + //lidy20241018增加向上找实件指派工艺的逻辑 + vector feeds; + //getParents(designRev, 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); + } + } + printf("mapByq===>%zd\n", mapByq.size()); - if ((strcmp(bl_desc, "") == 0 || strstr(bl_desc, "-") == NULL) && strstr(objName, "变压器") == NULL && !isback) { + if ((tc_strcmp(bl_desc, "") == 0 || tc_strstr(bl_desc, "-") == NULL) && tc_strstr(objName, "变压器") == NULL && !isback) { errorBuff = "当前选中的物料版本没有图号信息,请检查.\n"; } else { @@ -1424,6 +1449,109 @@ int CloneTempProcess(void *returnValue) } POM_AM__set_application_bypass(false); } + ITKCALL(BOM_close_window(ebom_window)); +} + +int CloneTempProcess(void *returnValue) +{ + // 记录开始时间点 + auto start = std::chrono::high_resolution_clock::now(); + int ifail = ITK_ok; + char* sql = NULL, *revUid; + tag_t designRev; + ITKCALL(ifail = USERARG_get_string_argument(&revUid)); + ITK__convert_uid_to_tag(revUid, &designRev); + + string errorBuff = "", notTcmBuff = ""; + + 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]); + + //map %s \n", url.c_str()); + if (ConnServer(url_vals[3], url_vals[4], (char*)url.c_str()) == -1) + { + printf("提示:中间数据表访问失败\n"); + ifail = 1; + } + //如果是产成品的话, 判断是否存在多个P物料 + //20240203备件包工艺路线指派 + int back_num = 0; + char** back_vals = NULL, *group_name = NULL; + tag_t group = NULLTAG; + string tuhao; + 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)); + vector> back_prefs; + //首选项格式:组名:匹配字段1;匹配字段2 + 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); + back_prefs.push_back(backs); + } + } + + boolean isback = false; + char* objName = NULL, *topId = NULL; + ITKCALL(AOM_ask_value_string(designRev, "object_name", &objName)); + ITKCALL(AOM_ask_value_string(designRev, "item_id", &topId)); + for (int i = 0; i < back_prefs.size(); i++) { + for (int j = 0; j < back_prefs.size(); j++) { + if (tc_strstr(objName, back_prefs[i][j].c_str()) != NULL) { + tuhao = back_prefs[i][j]; + isback = true; + break; + } + } + } + + if (isback || strstr(objName, "变压器") != NULL) { + CloneProcess(designRev, back_prefs, errorBuff, notTcmBuff); + } + else if (!isXn(designRev)) { + //lidy20241018增加向上找实件指派工艺的逻辑 + vector feeds; + getParents(designRev, 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); + CloneProcess(feed, back_prefs, errorBuff, notTcmBuff); + } + } + else { + CloneProcess(designRev, back_prefs, errorBuff, notTcmBuff); + } // 记录结束时间点 @@ -1442,7 +1570,6 @@ int CloneTempProcess(void *returnValue) errorBuff = "succ"; } printf("errorBuff==>%s\n", errorBuff.c_str()); - ITKCALL(BOM_close_window(ebom_window)); *((char**)returnValue) = (char*)MEM_alloc((strlen(errorBuff.c_str()) + 1) * sizeof(char)); tc_strcpy(*((char**)returnValue), errorBuff.c_str()); return ifail; diff --git a/General/General/DtoEBOM2.cpp b/General/General/DtoEBOM2.cpp index c7bf62b..8e1abfe 100644 --- a/General/General/DtoEBOM2.cpp +++ b/General/General/DtoEBOM2.cpp @@ -664,6 +664,9 @@ void recyReadBom(tag_t bom_line, tag_t designRev, NodeBean& pBean, string& errBu } return; } + boolean flagMat = false; + //根据图纸获取物料信息 + askLineVal(pBean, bom_line, designRev, errBuff, flagMat); tag_t tagUser; char *tagId; @@ -683,9 +686,6 @@ void recyReadBom(tag_t bom_line, tag_t designRev, NodeBean& pBean, string& errBu //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) { @@ -1459,9 +1459,12 @@ string createEbom(NodeBean topBean, boolean isTop, string &hasChange, map& map, int len, tag_t dcpro ITEM_ask_item_of_rev(axqPmatnr, &pitem); ITKCALL(PS_create_bom_view(NULL, NULL, NULL, pitem, &newView)); AOM_save(newView); + (AOM_unlock(newView));//20241211 ITKCALL(PS_create_bvr(newView, NULL, NULL, FALSE, axqPmatnr, &newViewBvr)); AOM_save(newViewBvr); + (AOM_unlock(newViewBvr));//20241211 AOM_save(axqPmatnr); + (AOM_unlock(axqPmatnr));//20241211 tag_t dsuser, *structure_revisions, *bom_view_tags; ITKCALL(AOM_ask_value_tag(tzRev, "owning_user", &dsuser)); tag_t defGroup; @@ -805,7 +811,7 @@ void recyReadEBom(tag_t pLine, EBomBean parentBean, vector& beans, int //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; + char* bl_quantity = NULL, *pId = NULL, *c_pId, *remark = NULL, *bl_line_name = NULL; 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)); @@ -813,7 +819,7 @@ void recyReadEBom(tag_t pLine, EBomBean parentBean, vector& beans, int ITKCALL(AOM_ask_value_tag(cc_line, "bl_line_object", &c_eRev)); 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) { + if (tc_strcmp(bl_quantity, "") == 0) { errBuff.append("P类物料:").append(pId).append("下子件").append(c_pId) .append("无法整除,请检查。").append("\n"); } @@ -822,7 +828,7 @@ void recyReadEBom(tag_t pLine, EBomBean parentBean, vector& beans, int printf("markMsg===> %s \n", markMsg.c_str()); if (markMsg.length() == 0) { int blQty = atoi(bl_quantity); - if (blQty % len != 0 && strstr(bl_line_name,"线")==NULL) { + if (blQty % len != 0 && tc_strstr(bl_line_name, "线") == NULL) { errBuff.append("P类物料:").append(pId).append("下子件").append(c_pId) .append("无法整除,请检查。").append("\n"); } @@ -835,7 +841,7 @@ void recyReadEBom(tag_t pLine, EBomBean parentBean, vector& beans, int } else { int blQty = atoi(bl_quantity); - if (blQty % markMsg.length() != 0 && strstr(bl_line_name, "线") == NULL) { + if (blQty % markMsg.length() != 0 && tc_strstr(bl_line_name, "线") == NULL) { errBuff.append("P类物料:").append(pId).append("下子件").append(c_pId) .append("无法整除,请检查。").append("\n"); } @@ -957,7 +963,7 @@ void updatePbomCycle(tag_t eLine, string &errBuff, int len, EBomUpBean &upBean) ITKCALL(AOM_ask_value_string(c_eRev, "item_id", &c_pId)); ITKCALL(AOM_ask_value_string(cc_line, "ZT2_Remark", &remark)); printf("c_pId===> %s bl_quantity ==> %s len==> %d \n", c_pId, bl_quantity, len); - if (strcmp("bl_quantity", "") == 0) { + if (tc_strcmp("bl_quantity", "") == 0) { errBuff.append("P类物料:").append(pId).append("下子件").append(c_pId) .append("无法整除,请检查。").append("\n"); } @@ -966,7 +972,7 @@ void updatePbomCycle(tag_t eLine, string &errBuff, int len, EBomUpBean &upBean) printf("markMsg===> %s \n", markMsg.c_str()); if (markMsg.length() == 0) { int blQty = atoi(bl_quantity); - if (blQty % len != 0 && strstr(bl_line_name, "线") == NULL) { + if (blQty % len != 0 && tc_strstr(bl_line_name, "线") == NULL) { errBuff.append("P类物料:").append(pId).append("下子件").append(c_pId) .append("无法整除,请检查。").append("\n"); } @@ -980,7 +986,7 @@ void updatePbomCycle(tag_t eLine, string &errBuff, int len, EBomUpBean &upBean) } else { int blQty = atoi(bl_quantity); - if (blQty % markMsg.length() != 0 && strstr(bl_line_name, "线") == NULL) { + if (blQty % markMsg.length() != 0 && tc_strstr(bl_line_name, "线") == NULL) { errBuff.append("P类物料:").append(pId).append("下子件").append(c_pId) .append("无法整除,请检查。").append("\n"); } @@ -1159,23 +1165,26 @@ void createAXxq(tag_t eRev, tag_t pRev, int len, tag_t dcproxy) { int bvr_count = 0, c_line_count; tag_t ebom_window = NULLTAG; - tag_t bom_line = NULLTAG, *c_line_tags; + tag_t bom_line = NULLTAG, *c_line_tags = NULLTAG; tag_t* bvr_list = NULL; ITKCALL(ITEM_rev_list_bom_view_revs(axqPmatnr, &bvr_count, &bvr_list)); WriteTcLog("bvr_count=%d\n", bvr_count); if (bvr_count == 0) { - tag_t newView, newViewBvr, pitem; + tag_t newView = NULLTAG, newViewBvr = NULLTAG, pitem = NULLTAG; ITEM_ask_item_of_rev(axqPmatnr, &pitem); ITKCALL(PS_create_bom_view(NULL, NULL, NULL, pitem, &newView)); AOM_save(newView); + (AOM_unlock(newView));//20241211 ITKCALL(PS_create_bvr(newView, NULL, NULL, FALSE, axqPmatnr, &newViewBvr)); AOM_save(newViewBvr); + (AOM_unlock(newViewBvr));//20241211 AOM_save(axqPmatnr); + (AOM_unlock(axqPmatnr));//20241211 //return; - tag_t dsuser, *structure_revisions, *bom_view_tags; + tag_t dsuser = NULLTAG, *structure_revisions = NULLTAG, *bom_view_tags = NULLTAG; ITKCALL(AOM_ask_value_tag(tzRev, "owning_user", &dsuser)); - tag_t defGroup; + tag_t defGroup = NULLTAG; ITKCALL(AOM_ask_value_tag(dsuser, "default_group", &defGroup)); ITKCALL(AOM_set_ownership(newView, dsuser, defGroup)); ITKCALL(AOM_set_ownership(newViewBvr, dsuser, defGroup)); @@ -1221,19 +1230,22 @@ void createAXxq(tag_t eRev, tag_t pRev, int len, tag_t dcproxy) { //添加A项线圈的子行 void addToAmatnrUp(vector vecs, int len, tag_t newPAmatnr, boolean lastFlag) { - tag_t mantr = newPAmatnr, ebom_window, bom_line; + tag_t mantr = newPAmatnr, ebom_window = NULLTAG, bom_line = NULLTAG; tag_t* bvr_list = NULL; int bvr_count; POM_AM__set_application_bypass(true); ITKCALL(ITEM_rev_list_bom_view_revs(mantr, &bvr_count, &bvr_list)); if (bvr_count == 0) { - tag_t newView, newViewBvr, pitem; + tag_t newView = NULLTAG, newViewBvr = NULLTAG, pitem = NULLTAG; ITKCALL(ITEM_ask_item_of_rev(mantr, &pitem)); ITKCALL(PS_create_bom_view(NULL, NULL, NULL, pitem, &newView)); (AOM_save(newView)); + (AOM_unlock(newView));//20241211 ITKCALL(PS_create_bvr(newView, NULL, NULL, FALSE, mantr, &newViewBvr)); (AOM_save(newViewBvr)); + (AOM_unlock(newViewBvr));//20241211 (AOM_save(mantr)); + (AOM_unlock(mantr));//20241211 } ITKCALL(BOM_create_window(&ebom_window)); ITKCALL(BOM_set_window_top_line(ebom_window, NULL, mantr, NULLTAG, &bom_line)); @@ -1320,9 +1332,8 @@ map getEBomMesg(EBomUpBean upBean) { EBomUpBean cBean = childs[i]; double qtyPXn = 1; string matnrNo = cBean.matnrNo; - printf("matnrNo====> %s\n", matnrNo.c_str()); string cnt = cBean.blQuantity; - if (strcmp(cnt.c_str(), "") != 0) { + if (tc_strcmp(cnt.c_str(), "") != 0) { qtyPXn = atof(cnt.c_str()); //atof(oldQty); } if (eMap.count(matnrNo) > 0) { @@ -1331,6 +1342,7 @@ map getEBomMesg(EBomUpBean upBean) { else { eMap[matnrNo] = qtyPXn; } + printf("getEBomMesg====> %s == %f\n", matnrNo.c_str(), eMap[matnrNo]); } return eMap; } @@ -1349,7 +1361,6 @@ void getPBomMsg(tag_t bom_line, map& bomMsgMap) { char *matnrNo, *cnt, *objName; ITKCALL(AOM_ask_value_tag(c_line_tags[t], BL_LINE_OBJECT, &c_Rev)); ITKCALL(AOM_ask_value_string(c_Rev, MATERIALNO, &matnrNo)); - printf("zt2_MaterialNo===>%s\n", matnrNo); double qtyPXn = 1; ITKCALL(AOM_ask_value_string(c_line_tags[t], BL_QUANTITY, &cnt)); if (strcmp(cnt, "") != 0) { @@ -1361,6 +1372,7 @@ void getPBomMsg(tag_t bom_line, map& bomMsgMap) { else { bomMsgMap[matnrNo] = qtyPXn; } + printf("zt2_MaterialNo===>%s == %f\n", matnrNo, bomMsgMap[matnrNo]); } } /** @@ -1395,7 +1407,6 @@ map getPBomMsg(tag_t mantrRev, bool& flag, vector& termCo double qtyPXn = 1; ITKCALL(AOM_ask_value_string(c_line_tags[t], "bl_quantity", &cnt)); ITKCALL(AOM_ask_value_string(c_Rev, OBJECT_NAME, &objName)); - printf("zt2_MaterialNo===>%s objName ===> %s\n", matnrNo, objName); if (checkName(objName)) { termCoils.push_back(c_Rev); getPBomMsg(c_line_tags[t], bomMsgMap); @@ -1410,6 +1421,7 @@ map getPBomMsg(tag_t mantrRev, bool& flag, vector& termCo else { bomMsgMap[matnrNo] = qtyPXn; } + printf("getPBomMsg===>%s objName===> %s == %f\n", matnrNo, objName, bomMsgMap[matnrNo]); } ITKCALL(BOM_close_window(ebom_window)); return bomMsgMap; @@ -1425,12 +1437,16 @@ boolean combEAndDbom(map dMap, map eMap) { for (it = dMap.begin(); it != dMap.end(); it++) { string s = it->first; double dnum = dMap[s]; + printf("combEAndDbom:%s == %d == ", s.c_str(), dnum); if (eMap.count(s) == 0) { + printf("0\n"); return true; } else if (dnum != eMap[s]) { + printf("%d\n", eMap[s]); return true; } + printf("\n"); } return false; } @@ -1568,7 +1584,7 @@ void startUpdate(EBomUpBean upBean, tag_t pBomTag, int len, tag_t dcproxy, ITKCALL(AOM_ask_value_string(eRev, "object_name", &name)); //移除PBOM printf("zt2_MaterialNo ===>%s ifpBom==>%s\n", matnrNo, ifpBom); - if (strcmp(ifpBom, "P") == 0) { + if (tc_strcmp(ifpBom, "P") == 0) { //A项线圈是不带P的 matnrVec.push_back(matnrNo); pBomMap[matnrNo] = c_line_tag; @@ -1626,6 +1642,13 @@ void startUpdate(EBomUpBean upBean, tag_t pBomTag, int len, tag_t dcproxy, ITKCALL(BOM_save_window(bomView)); ITKCALL(BOM_close_window(bomView)); } + tag_t cline = cupBean.bomline; + char* qty = NULL; + ITKCALL(AOM_ask_value_string(cline, "bl_quantity", &qty)); + (AOM_lock(c_line_tag)); + ITKCALL(AOM_set_value_string(c_line_tag, "bl_quantity", qty)); + (AOM_save(c_line_tag)); + (AOM_unlock(c_line_tag)); //printf("i2===>%d\n", i); } else { @@ -1722,13 +1745,16 @@ void copyBomLine(tag_t matnrTop, tag_t otherPbom) { ITKCALL(ITEM_rev_list_bom_view_revs(otherPbom, &bvr_count2, &bvr_list2)); if (bvr_count2 == 0) { - tag_t newView, newViewBvr, pitem; + tag_t newView = NULLTAG, newViewBvr = NULLTAG, pitem = NULLTAG; ITKCALL(ITEM_ask_item_of_rev(otherPbom, &pitem)); ITKCALL(PS_create_bom_view(NULL, NULL, NULL, pitem, &newView)); (AOM_save(newView)); + (AOM_unlock(newView));//20241211 ITKCALL(PS_create_bvr(newView, NULL, NULL, FALSE, otherPbom, &newViewBvr)); (AOM_save(newViewBvr)); + (AOM_unlock(newViewBvr));//20241211 (AOM_save(otherPbom)); + (AOM_unlock(otherPbom));//20241211 //return; ITKCALL(ITEM_rev_list_bom_view_revs(otherPbom, &bvr_count2, &bvr_list2)); } diff --git a/General/General/General.cpp b/General/General/General.cpp index 4fffb63..cb08c66 100644 --- a/General/General/General.cpp +++ b/General/General/General.cpp @@ -2,5 +2,22 @@ // #include "stdafx.h" +#include "tc_util.h" +#include "epm_handler_common.h" +int AddReleasedStatus(void *) +{ + tag_t object = NULLTAG, release_status = NULLTAG; + char* status = NULL; + + ITKCALL(USERARG_get_tag_argument(&object)); + ITKCALL(USERARG_get_string_argument(&status)); + ITKCALL(RELSTAT_create_release_status(status, &release_status)); + ITKCALL(RELSTAT_add_release_status(release_status, 1, &object, NULL)); + + //if (object) { MEM_free(&object); object = NULL; } + //if (release_status) { MEM_free(release_status); release_status = NULL; } + + return ITK_ok; +} diff --git a/General/General/HXC_create_item_post.cpp b/General/General/HXC_create_item_post.cpp index 106a65a..9909016 100644 --- a/General/General/HXC_create_item_post.cpp +++ b/General/General/HXC_create_item_post.cpp @@ -182,6 +182,7 @@ int HXC_create_item_post(METHOD_message_t* msg , va_list va) ITKCALL(status=(FL_insert(folders2[w],*item_tag,999))); //保存 ITKCALL(status=AOM_save(folders2[w])); + (AOM_unlock(folders2[w]));//20241211 POM_AM__set_application_bypass(false); } } diff --git a/General/General/chintSignChange.cpp b/General/General/chintSignChange.cpp index 6a9cf7f..eb7d4bc 100644 --- a/General/General/chintSignChange.cpp +++ b/General/General/chintSignChange.cpp @@ -109,7 +109,7 @@ int create_dataset(char *type_name, const char *name, tag_t excelTag) ITKCALL(ifail=AOM_save(spec_dataset_rev)); ITKCALL(ifail=AOM_unlock(spec_dataset_rev)); - ITKCALL(AOM_save(excelTag)); + //ITKCALL(AOM_save(excelTag)); return 0; } string GenerateGuid() diff --git a/General/General/chint_add_to_workflow.cpp b/General/General/chint_add_to_workflow.cpp index 17cbad8..4a89e38 100644 --- a/General/General/chint_add_to_workflow.cpp +++ b/General/General/chint_add_to_workflow.cpp @@ -343,7 +343,7 @@ int CHINT_task_complete(EPM_action_message_t msg) { char *taskName = NULL; ITKCALL(AOM_ask_value_string(taskTag, "job_name", &taskName)); printf("taskName %s \n", taskName); - if (tc_strstr(taskName, projName.c_str()) != NULL) { + if (tc_strstr(taskName, projName.c_str()) != NULL && tc_strcmp(taskName, jobName) != 0) { ITKCALL(EPM_set_task_result(taskTag, EPM_RESULT_Completed)); ITKCALL(EPM_trigger_action(taskTag, EPM_complete_action, "")); } @@ -358,7 +358,9 @@ int CHINT_task_complete(EPM_action_message_t msg) { if (tasklists.size() > 0) { string json = "{\"projectcode\":\""; json.append(zt2_ProjectCode).append("\",\"tasklists\":[").append(tasklists).append("]}"); + printf("json %s \n", json.c_str()); + //yp_query(yp_url, json); thread newThread(yp_query, yp_url, json); newThread.detach(); } diff --git a/General/General/chint_changenotice.cpp b/General/General/chint_changenotice.cpp index c809331..0f8b293 100644 --- a/General/General/chint_changenotice.cpp +++ b/General/General/chint_changenotice.cpp @@ -42,10 +42,47 @@ #include "CRUL_server_call_httpserver.h" #include "common_itk_util.h" #include +#include // for std::isspace #define EPM_HANDLER_COMMON #define MAX_PATH_LENGTH 200 #define MAX_PRINTLINE_LENGTH 400000 + + + +std::string removeWhitespace1(const std::string& str) { + std::string result; + result.reserve(str.size()); // 预留空间以提高性能 + + // 使用 std::copy_if 和 std::isspace 来过滤掉空白字符 + std::copy_if(str.begin(), str.end(), std::back_inserter(result), + [](unsigned char ch) { return !std::isspace(ch); }); + + return result; +} + +// 转义json字符串 +void escapeJson1(std::string& str) { + int len = str.length(); + int newLen = len; + for (int i = 0; i < len; i++) { + if (str[i] == '"' || str[i] == '\\') { + newLen++; + } + } + std::string escapedStr; + escapedStr.reserve(newLen); + for (int i = 0; i < len; i++) { + if (str[i] == '"' || str[i] == '\\') { + escapedStr.push_back('\\'); + } + escapedStr.push_back(str[i]); + } + str = escapedStr; +} + + + char* utog(const char* src_str) { int len = MultiByteToWideChar(CP_UTF8, 0, src_str, -1, NULL, 0); @@ -295,10 +332,16 @@ int chint_changenotice(EPM_action_message_t msg) { json = cJSON_Print(top); printf("json================%s\n", json); + string result; + result.append(json); + escapeJson1(result); + + string result1 = removeWhitespace1(result); + printf("result1=============%s\n", result1.c_str()); // lidy20240829新接口 string cmd = "java -jar \""; - cmd.append(getenv("TC_ROOT")).append("\\bin\\uploadMinio.jar\" FS \"").append(json).append("\""); + cmd.append(getenv("TC_ROOT")).append("\\bin\\uploadMinio.jar\" FS \"").append(result1).append("\""); printf("cmd==>%s", cmd.c_str()); FILE* pf = NULL; string strResult; @@ -323,20 +366,20 @@ int chint_changenotice(EPM_action_message_t msg) { 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, WriteCallback); - // 设置写入数据的目标缓冲区 - - 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, gtou(json)); - res = curl_easy_perform(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, WriteCallback); + // 设置写入数据的目标缓冲区 + + 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, gtou(json)); + res = curl_easy_perform(curl); } curl_easy_cleanup(curl);*/ diff --git a/General/General/chint_changenoticebm.cpp b/General/General/chint_changenoticebm.cpp index 43430dc..d0c9134 100644 --- a/General/General/chint_changenoticebm.cpp +++ b/General/General/chint_changenoticebm.cpp @@ -42,10 +42,43 @@ #include "CRUL_server_call_httpserver.h" #include "common_itk_util.h" #include +#include // for std::isspace +#include +#include #define EPM_HANDLER_COMMON #define MAX_PATH_LENGTH 200 #define MAX_PRINTLINE_LENGTH 400000 +std::string removeWhitespace(const std::string& str) { + std::string result; + result.reserve(str.size()); // 预留空间以提高性能 + + // 使用 std::copy_if 和 std::isspace 来过滤掉空白字符 + std::copy_if(str.begin(), str.end(), std::back_inserter(result), + [](unsigned char ch) { return !std::isspace(ch); }); + + return result; +} + +// 转义json字符串 +void escapeJson2(std::string& str) { + int len = str.length(); + int newLen = len; + for (int i = 0; i < len; i++) { + if (str[i] == '"' || str[i] == '\\') { + newLen++; + } + } + std::string escapedStr; + escapedStr.reserve(newLen); + for (int i = 0; i < len; i++) { + if (str[i] == '"' || str[i] == '\\') { + escapedStr.push_back('\\'); + } + escapedStr.push_back(str[i]); + } + str = escapedStr; +} char* concat(char** s, int size) { int length = 0; @@ -340,10 +373,18 @@ int chint_changenoticebm(EPM_action_message_t msg) { json = cJSON_Print(top); printf("json================%s\n", json); + string result; + result.append(json); + escapeJson2(result); + + string result1 = removeWhitespace(result); + printf("result1=============%s\n", result1.c_str()); // lidy20240829新接口 string cmd = "java -jar \""; - cmd.append(getenv("TC_ROOT")).append("\\bin\\uploadMinio.jar\" FS \"").append(json).append("\""); + cmd.append(getenv("TC_ROOT")).append("\\bin\\uploadMinio.jar\" FS \"").append(result1).append("\""); + + printf("cmd==>%s", cmd.c_str()); FILE* pf = NULL; string strResult; @@ -368,20 +409,20 @@ int chint_changenoticebm(EPM_action_message_t msg) { 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_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);*/ diff --git a/General/General/chint_check_materialstatus.cpp b/General/General/chint_check_materialstatus.cpp index 2e41de1..86f6e3c 100644 --- a/General/General/chint_check_materialstatus.cpp +++ b/General/General/chint_check_materialstatus.cpp @@ -91,6 +91,7 @@ int chint_check_materialstatus(EPM_action_message_t msg) { std::map tyMap; //封存集合 std::map fcMap; + POM_AM__set_application_bypass(true); for (int i = 0; i < att_cnt; i++) { tag_t target = NULLTAG; @@ -101,7 +102,7 @@ int chint_check_materialstatus(EPM_action_message_t msg) { ITKCALL(AOM_ask_value_string(target, "object_type", &objectType)); //物料 printf("objectType======%s\n", objectType); - if (strcmp(objectType, "Part Revision") == 0) { + if (tc_strcmp(objectType, "Part Revision") == 0) { //获取物料编码和物料名称 char* zt2_MaterialNo = NULL; char* object_name = NULL; @@ -110,12 +111,12 @@ 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 (tc_strstr(tyStr, "停用")) { //放入停用map tyMap[zt2_MaterialNo] = object_name; continue; } - else if (strstr(zt2_State, "封存")) { + else if (tc_strstr(zt2_State, "封存")) { //放入封存map fcMap[zt2_MaterialNo] = object_name; continue; @@ -124,7 +125,7 @@ int chint_check_materialstatus(EPM_action_message_t msg) { } //物料bom :获取第一层 - if (strcmp(objectType, "BOMView Revision") == 0) { + if (tc_strcmp(objectType, "BOMView Revision") == 0) { //获取第一层 ////遍历子BOM获取属性 //tag_t window_0_; @@ -166,7 +167,7 @@ int chint_check_materialstatus(EPM_action_message_t msg) { ITKCALL(AOM_ask_value_string(rev, "object_type", &objectType_rev)); //物料 - if (strcmp(objectType_rev, "Part Revision") == 0) { + if (tc_strcmp(objectType_rev, "Part Revision") == 0) { //获取物料编码和物料名称 char* zt2_MaterialNo = NULL; char* object_name = NULL; @@ -175,19 +176,17 @@ int chint_check_materialstatus(EPM_action_message_t msg) { ITKCALL(AOM_ask_value_string(rev, "object_desc", &tyStr)); ITKCALL(AOM_UIF_ask_value(rev, "zt2_State", &zt2_State)); - if (strstr(zt2_State, "封存")) { + if (tc_strstr(zt2_State, "封存")) { //放入封存map fcMap[zt2_MaterialNo] = object_name; - } - else if (strstr(tyStr, "停用")) { + else if (tc_strstr(tyStr, "停用")) { //放入停用map tyMap[zt2_MaterialNo] = object_name; - } - } } + ITKCALL(BOM_close_window(bom_window_tag));//BOM_close_window } ////图纸 //if (strcmp(objectType, "ZT2_Design3DRevision") == 0) { @@ -233,7 +232,7 @@ int chint_check_materialstatus(EPM_action_message_t msg) { //图纸 - if (strcmp(objectType, "ZT2_Design3DRevision") == 0) { + if (tc_strcmp(objectType, "ZT2_Design3DRevision") == 0) { //获取关系文件夹下的物料 int wlNum; tag_t* wlTags; @@ -245,7 +244,7 @@ int chint_check_materialstatus(EPM_action_message_t msg) { 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) { + if (tc_strcmp(objectType_rev, "Part Revision") == 0) { //获取物料编码和物料名称 char* zt2_MaterialNo = NULL; char* object_name = NULL; @@ -254,13 +253,13 @@ int chint_check_materialstatus(EPM_action_message_t msg) { 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, "停用")) { + if (tc_strstr(tyStr, "停用")) { //放入停用map tyMap[zt2_MaterialNo] = object_name; printf("00000000000000000000000000\n"); continue; } - else if (strstr(zt2_State, "封存")) { + else if (tc_strstr(zt2_State, "封存")) { //放入封存map fcMap[zt2_MaterialNo] = object_name; printf("11111111111111111111111111\n"); @@ -269,8 +268,8 @@ int chint_check_materialstatus(EPM_action_message_t msg) { } } } - } + POM_AM__set_application_bypass(false); //收集完map数据,进行拼接报错 string errMsg = ""; for (auto it = tyMap.begin(); it != tyMap.end(); it++) { diff --git a/General/General/epm_handler_common.h b/General/General/epm_handler_common.h index cae6f1d..81080b9 100644 --- a/General/General/epm_handler_common.h +++ b/General/General/epm_handler_common.h @@ -72,6 +72,8 @@ int CHINT_CHANGEITEM_TO_SRM(EPM_action_message_t msg); int CHINT_CHANGEBOM_TO_SRM(EPM_action_message_t msg); int CHINT_CHANGETZCG_TO_SRM(EPM_action_message_t msg); EPM_decision_t chint_csh_check(EPM_rule_message_t msg); + +int AddReleasedStatus(void *); //user service end #ifdef __cplusplus } diff --git a/General/General/epm_register_handler.cpp b/General/General/epm_register_handler.cpp index d3b0c9a..d518f1e 100644 --- a/General/General/epm_register_handler.cpp +++ b/General/General/epm_register_handler.cpp @@ -526,6 +526,18 @@ extern DLLAPI int USERSERVICE_custom_register_methods(int *decision, va_list arg } MEM_free(argumentList); } + { + /*添加状态*/ + USER_function_t functionPtr = AddReleasedStatus; + int numberOfArguments = 2; + int returnValueType = USERARG_VOID_TYPE; + int *argumentList = (int*)MEM_alloc(numberOfArguments * sizeof(int)); + argumentList[0] = USERARG_TAG_TYPE; + argumentList[1] = USERARG_STRING_TYPE; + ITKCALL(USERSERVICE_register_method("AddReleasedStatus", functionPtr, numberOfArguments, argumentList, returnValueType)); + printf("Registering AddReleasedStatus finished\n"); + MEM_free(argumentList); + } return ITK_ok; } diff --git a/General/General/tc_util.h b/General/General/tc_util.h index 38a5ecd..8e16e0b 100644 --- a/General/General/tc_util.h +++ b/General/General/tc_util.h @@ -86,4 +86,7 @@ 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 +char* U2G(const char* utf8); + +void getParents(tag_t matnrRev, vector& feeds, vector> back_prefs); +void getNewRev(string wm, bool isp, vector feeds, map& revMap, map& feedMap); \ No newline at end of file