From d3618b61ce7bbb7b5886e50dad43bbd5f9f98665 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=86=AC=E9=98=B3?= Date: Tue, 6 Feb 2024 17:38:11 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E8=AE=A1=E5=88=92=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E5=AE=8C=E6=88=90=E5=8A=9F=E8=83=BD=E5=BC=80?= =?UTF-8?q?=E5=8F=91=202=E3=80=81=E6=AD=A6=E6=B1=89=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E6=8A=95=E6=96=99=E5=A2=9E=E5=8A=A0=E9=80=BB=E8=BE=91=EF=BC=9A?= =?UTF-8?q?=E5=88=A4=E6=96=AD=E7=89=A9=E6=96=99=E8=A7=86=E5=9B=BE=E6=98=AF?= =?UTF-8?q?=E5=90=A6=E4=B8=BA=E5=A4=96=E8=B4=AD=EF=BC=8C=E5=A6=82=E6=9E=9C?= =?UTF-8?q?=E6=98=AF=E5=A4=96=E8=B4=AD=EF=BC=8C=E5=88=99=E6=8A=95=E6=96=99?= =?UTF-8?q?=E5=81=9C=E6=AD=A2=EF=BC=8C=E4=B8=8D=E5=86=8D=E5=B1=95=E5=BC=80?= =?UTF-8?q?=203=E3=80=81=E5=A4=87=E4=BB=B6=E5=8C=85=E5=B7=A5=E8=89=BA?= =?UTF-8?q?=E8=B7=AF=E7=BA=BF=E6=8C=87=E6=B4=BE=E5=92=8C=E6=8A=95=E6=96=99?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E5=BC=80=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- General/General/AutoFeeding.cpp | 77 ++-- General/General/CloneProcess.cpp | 451 +++++++++++++--------- General/General/General.vcxproj | 20 +- General/General/chint_add_to_workflow.cpp | 196 ++++++++++ General/General/epm_handler_common.h | 5 +- General/General/epm_register_handler.cpp | 8 + General/General/string_utils.cxx | 38 +- 7 files changed, 579 insertions(+), 216 deletions(-) diff --git a/General/General/AutoFeeding.cpp b/General/General/AutoFeeding.cpp index aae048c..cebb8a6 100644 --- a/General/General/AutoFeeding.cpp +++ b/General/General/AutoFeeding.cpp @@ -155,10 +155,11 @@ void getBomMessage(vector& stBomlines, tag_t cBomLine, StBomBean &pBe //ITKCALL(AOM_ask_value_tag(pBomLine, "bl_line_object", &mantr)); //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; - char* cName; + tag_t cmantr = NULLTAG; + char* cName = NULL, * zt2_SZProcuretype = NULL; ITKCALL(AOM_ask_value_tag(cBomLine, "bl_line_object", &cmantr)); ITKCALL(AOM_ask_value_string(cmantr, "object_name", &cName)); + ITKCALL(AOM_ask_value_string(cmantr, "zt2_SZProcuretype", &zt2_SZProcuretype)); //外购不再展开投料 printf("虚拟件===>%s\n", cName); StBomBean bean; bean.bomline = cBomLine; @@ -174,7 +175,7 @@ void getBomMessage(vector& stBomlines, tag_t cBomLine, StBomBean &pBe // stBomlines.push_back(bean); pBean.childs.push_back(bean); } - else { + else if (tc_strcmp(zt2_SZProcuretype, "外购") != 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); @@ -191,10 +192,11 @@ void getBomMessage(vector &stBomlines, tag_t cBomLine) { //ITKCALL(AOM_ask_value_tag(pBomLine, "bl_line_object", &mantr)); //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; - char* cName; + tag_t cmantr = NULLTAG; + char* cName = NULL, * zt2_SZProcuretype = NULL; ITKCALL(AOM_ask_value_tag(cBomLine, "bl_line_object", &cmantr)); ITKCALL(AOM_ask_value_string(cmantr, "object_name", &cName)); + ITKCALL(AOM_ask_value_string(cmantr, "zt2_SZProcuretype", &zt2_SZProcuretype)); //外购不再展开投料 StBomBean bean; bean.bomline = cBomLine; bean.currentName = cName; @@ -207,7 +209,7 @@ void getBomMessage(vector &stBomlines, tag_t cBomLine) { stBomlines.push_back(bean); //printf("st = true===>%s\n", cName); } - else { + else if (tc_strcmp(zt2_SZProcuretype, "外购") != 0) { //虚拟件向下展开 //实体件直接投料 printf("虚拟件============>%s\n", cName); for (int i = 0; i < c_line_count; i++) { @@ -215,7 +217,7 @@ void getBomMessage(vector &stBomlines, tag_t cBomLine) { getBomMessage(stBomlines, c_line_tag, bean); } stBomlines.push_back(bean); - printf("虚拟件===========>%d\n", bean.childs.size()); + printf("虚拟件===========>%zd\n", bean.childs.size()); } } //虚拟向下展开,实体投料 @@ -228,7 +230,7 @@ void autoFeedLike(tag_t towGxLine, StBomBean& pBean, vector& stBomlin qty = "1"; } double x = atof(qty); - printf("pBean.childs==>%d %s \n", pBean.childs.size(), qty); + printf("pBean.childs==>%zd %s \n", pBean.childs.size(), qty); for (int i = 0; i < pBean.childs.size(); i++) { StBomBean& child = pBean.childs[i]; autoFeedLike(towGxLine, child, stBomlines, xnQty*x); @@ -256,7 +258,7 @@ void autoFeedLike(tag_t towGxLine, StBomBean& pBean, vector& stBomlin } ITKCALL(BOM_line_copy(towGxLine, pBean.bomline, NULLTAG, &newChild)); printf("bl_quantity==>%s\n", bl_quantity.c_str()); - AOM_lock(newChild); // bl_occ_type + ITKCALL(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())); @@ -269,7 +271,7 @@ void autoFeedLike(tag_t towGxLine, StBomBean& pBean, vector& stBomlin void autoFeedLike(tag_t towGxLine, StBomBean& pBean, string name2, vector& stBomlines) { //子项名称模糊匹配 - printf(" pBean.childs.size()%d\n", pBean.childs.size()); + printf(" pBean.childs.size()%zd\n", pBean.childs.size()); for (int i = 0; i < pBean.childs.size(); i++) { StBomBean& child = pBean.childs[i]; printf("child.currentName%s %s \n", child.currentName.c_str(), name2.c_str()); @@ -341,12 +343,11 @@ void startFeed(tag_t meprocess, vector& stBomlines, FeedRule bean, st AOM_ask_value_string(ejGx, "object_name", &ejName); printf("ejName%s %s\n", ejName, bean.ejgx.c_str()); if (bean.ejgx.compare(ejName) == 0) { - printf("stBomlines %d\n", stBomlines.size()); + printf("stBomlines %zd\n", stBomlines.size()); cutGxLine(towGxLine); for (int t = 0; t < stBomlines.size(); t++) { StBomBean& stBom = stBomlines[t]; - tag_t newChild; - printf("stBom.currentName==>%s %d\n", stBom.currentName.c_str(), stBom.childs.size()); + printf("stBom.currentName==>%s %zd\n", stBom.currentName.c_str(), stBom.childs.size()); if (stBom.currentName.compare(name1) == 0) { //if (!stBom.istl && stBom.st && stBom.flag) { autoFeedLike(towGxLine, stBom, name2, stBomlines); @@ -519,7 +520,7 @@ void AutoFeedBom(tag_t mantr,tag_t meprocess, if (drawMap.count(drawNo) > 0) { //图号匹配 vector beans = drawMap[drawNo]; - printf("beans===>%d\n", beans.size()); + printf("beans===>%zd\n", beans.size()); for (int t = 0; t < beans.size(); t++) { FeedRule bean = beans[t]; if (bean.tlth.empty()) { @@ -574,7 +575,7 @@ void AutoFeedBom(tag_t mantr,tag_t meprocess, AOM_ask_value_string(mantr, "object_name", &nowName); if (strstr(nowName, s.c_str()) != NULL) { vector beans = nameMap[s]; - printf("beans===>%d\n", beans.size()); + printf("beans===>%zd\n", beans.size()); for (int t = 0; t < beans.size(); t++) { FeedRule bean = beans[t]; printf("beans===>%s %s\n", bean.yjgx.c_str(), bean.ejgx.c_str()); @@ -626,17 +627,17 @@ void AutoFeedBom(tag_t mantr,tag_t meprocess, ITKCALL(BOM_close_window(ebom_window)); } -void readPbomMsg(tag_t bom_line,string &errBuffer, - map> drawMap, map> nameMap,char *loginId) { +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; ITKCALL(AOM_ask_value_tag(bom_line, "bl_line_object", &rev)); - AOM_ask_value_string(rev, "item_id", &id); - AOM_ask_value_string(rev, "object_name", &objName); - if (c_line_count > 0 && (isSt(rev)|| strstr(objName, "变压器") != NULL)) { + ITKCALL(AOM_ask_value_string(rev, "item_id", &id)); + ITKCALL(AOM_ask_value_string(rev, "object_name", &objName)); + if (c_line_count > 0 && (isSt(rev) || strstr(objName, "变压器") != NULL || isback)) { int n_references = 0; int* levels = 0; @@ -647,13 +648,13 @@ void readPbomMsg(tag_t bom_line,string &errBuffer, //boolean hasProcess = false; int meNum = 0; tag_t meprocess; - AOM_ask_value_tag(rev, "owning_user", &user); - AOM_ask_value_string(user, "user_id", &duser); + ITKCALL(AOM_ask_value_tag(rev, "owning_user", &user)); + ITKCALL(AOM_ask_value_string(user, "user_id", &duser)); for (int i = 0; i < n_references; i++) { char* refType; tag_t refTag = references_tag[i]; - AOM_ask_value_string(refTag, "object_type", &refType); + ITKCALL(AOM_ask_value_string(refTag, "object_type", &refType)); if (strcmp(refType, "MEProcessRevision") == 0) { //hasProcess = true; //break; @@ -677,7 +678,7 @@ void readPbomMsg(tag_t bom_line,string &errBuffer, //} } for (int i = 0; i < c_line_count; i++) { - readPbomMsg(c_line_tags[i], errBuffer, drawMap, nameMap, loginId); + readPbomMsg(c_line_tags[i], errBuffer, drawMap, nameMap, loginId, false); } } @@ -762,6 +763,32 @@ 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)); + 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 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; + } + } + } + } //遍历BOM获取所有要投料的 tag_t* bvr_list = NULL, ebom_window, bom_line; @@ -770,7 +797,7 @@ int AutoFeeding(void *returnValue) { 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); + readPbomMsg(bom_line, errBuffer, drawMap, nameMap, loginId, isback); ITKCALL(BOM_close_window(ebom_window)); diff --git a/General/General/CloneProcess.cpp b/General/General/CloneProcess.cpp index 62e063d..8605251 100644 --- a/General/General/CloneProcess.cpp +++ b/General/General/CloneProcess.cpp @@ -357,12 +357,12 @@ void getGxbmMap(tag_t processTag, map& gxDocMap, map& gxDocMap, map 0) { - AOM_lock(oneGx); + ITKCALL(AOM_lock(oneGx)); TimeBean tbean = timebeans[gxbm1]; ITKCALL(AOM_set_value_string(oneGx, "bl_ZT2_FirstOPRevision_zt2_ArtificialTime", tbean.rgsj.c_str())); ITKCALL(AOM_set_value_string(oneGx, "bl_ZT2_FirstOPRevision_zt2_MachineTime", tbean.jqsj.c_str())); ITKCALL(AOM_set_value_string(oneGx, "bl_ZT2_FirstOPRevision_zt2_ReadinessTime", tbean.zbsj.c_str())); ITKCALL(AOM_set_value_string(oneGx, "bl_ZT2_FirstOPRevision_zt2_ProCycle", tbean.zrsczq.c_str())); - AOM_save(oneGx); - AOM_unlock(oneGx); + ITKCALL(AOM_save(oneGx)); + ITKCALL(AOM_unlock(oneGx)); } int c_cnt = 0; - BOM_line_ask_all_child_lines(oneGx, &c_cnt, &towGxLines); + ITKCALL(BOM_line_ask_all_child_lines(oneGx, &c_cnt, &towGxLines)); for (int j = 0; j < c_cnt; j++) { tag_t towGxLine = towGxLines[j]; tag_t towGx; char* gxbm2; ITKCALL(AOM_ask_value_string(towGxLine, "bl_ZT2_FirstOPRevision_zt2_ClassificationCode", &gxbm2)); if (timebeans.count(gxbm2) > 0) { - AOM_lock(towGxLine); + ITKCALL(AOM_lock(towGxLine)); TimeBean tbean = timebeans[gxbm2]; ITKCALL(AOM_set_value_string(towGxLine, "bl_ZT2_FirstOPRevision_zt2_ArtificialTime", tbean.rgsj.c_str())); ITKCALL(AOM_set_value_string(towGxLine, "bl_ZT2_FirstOPRevision_zt2_MachineTime", tbean.jqsj.c_str())); ITKCALL(AOM_set_value_string(towGxLine, "bl_ZT2_FirstOPRevision_zt2_ReadinessTime", tbean.zbsj.c_str())); ITKCALL(AOM_set_value_string(towGxLine, "bl_ZT2_FirstOPRevision_zt2_ProCycle", tbean.zrsczq.c_str())); - AOM_save(towGxLine); - AOM_unlock(towGxLine); + ITKCALL(AOM_save(towGxLine)); + ITKCALL(AOM_unlock(towGxLine)); } - char *name; + char* name = NULL; ITKCALL(AOM_ask_value_tag(towGxLine, "bl_line_object", &towGx)); - AOM_ask_value_string(towGx, "object_name", &name); + ITKCALL(AOM_ask_value_string(towGx, "object_name", &name)); //设置质检项 //setZljyx(gxbm2,th, lastId, name, towGx); if (flBeanMap.count(gxbm2) > 0) { vector beansVec = flBeanMap[gxbm2]; - printf("beansVec===>%d\n", beansVec.size()); + printf("beansVec===>%zd\n", beansVec.size()); if (beansVec.size() > 0) { tag_t axqPmatnr; - AOM_ask_value_tag(towGxLine, "bl_line_object", &axqPmatnr); - (ITEM_rev_list_bom_view_revs(axqPmatnr, &bvr_count, &bvr_list)); + 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; - ITEM_ask_item_of_rev(axqPmatnr, &pitem); + ITKCALL(ITEM_ask_item_of_rev(axqPmatnr, &pitem)); ITKCALL(PS_create_bom_view(NULL, NULL, NULL, pitem, &newView)); - AOM_save(newView); + ITKCALL(AOM_save(newView)); ITKCALL(PS_create_bvr(newView, NULL, NULL, FALSE, axqPmatnr, &newViewBvr)); - AOM_save(newViewBvr); - AOM_save(axqPmatnr); + ITKCALL(AOM_save(newViewBvr)); + ITKCALL(AOM_save(axqPmatnr)); } } //投辅料 @@ -430,16 +430,16 @@ void getGxbmMap(tag_t processTag, map& gxDocMap, map& gxDocMap, map& gxDocMap, map timebeans) { int bvr_count = 0; - tag_t ebom_window = NULLTAG; - tag_t bom_line = NULLTAG; - tag_t item_tag = NULLTAG, *c_line_tags; - (BOM_create_window(&ebom_window)); + tag_t ebom_window = NULLTAG, bom_line = NULLTAG, item_tag = NULLTAG, *c_line_tags = NULLTAG; + ITKCALL(BOM_create_window(&ebom_window)); tag_t* bvr_list = NULL; - (ITEM_rev_list_bom_view_revs(processTag, &bvr_count, &bvr_list)); + ITKCALL(ITEM_rev_list_bom_view_revs(processTag, &bvr_count, &bvr_list)); printf("bvr_count=%d", bvr_count); - (BOM_set_window_top_line_bvr(ebom_window, bvr_list[0], &bom_line)); //顶层bom获取 + ITKCALL(BOM_set_window_top_line_bvr(ebom_window, bvr_list[0], &bom_line)); //顶层bom获取 //bom_line工艺 int c_line_count; ITKCALL(BOM_line_ask_all_child_lines(bom_line, &c_line_count, &c_line_tags)); // 一级工序 @@ -468,39 +466,39 @@ void getGxbmMap(tag_t processTag, map& gxDocMap, map 0) { - AOM_lock(oneGx); + ITKCALL(AOM_lock(oneGx)); TimeBean tbean = timebeans[gxbm1]; ITKCALL(AOM_set_value_string(oneGx, "bl_ZT2_FirstOPRevision_zt2_ArtificialTime", tbean.rgsj.c_str())); ITKCALL(AOM_set_value_string(oneGx, "bl_ZT2_FirstOPRevision_zt2_MachineTime", tbean.jqsj.c_str())); ITKCALL(AOM_set_value_string(oneGx, "bl_ZT2_FirstOPRevision_zt2_ReadinessTime", tbean.zbsj.c_str())); ITKCALL(AOM_set_value_string(oneGx, "bl_ZT2_FirstOPRevision_zt2_ProCycle", tbean.zrsczq.c_str())); - AOM_save(oneGx); - AOM_unlock(oneGx); + ITKCALL(AOM_save(oneGx)); + ITKCALL(AOM_unlock(oneGx)); } int c_cnt = 0; - BOM_line_ask_all_child_lines(oneGx, &c_cnt, &towGxLines); + ITKCALL(BOM_line_ask_all_child_lines(oneGx, &c_cnt, &towGxLines)); for (int j = 0; j < c_cnt; j++) { tag_t towGxLine = towGxLines[j]; tag_t towGx; char* gxbm2; ITKCALL(AOM_ask_value_string(towGxLine, "bl_ZT2_FirstOPRevision_zt2_ClassificationCode", &gxbm2)); if (timebeans.count(gxbm2) > 0) { - AOM_lock(towGxLine); + ITKCALL(AOM_lock(towGxLine)); TimeBean tbean = timebeans[gxbm2]; ITKCALL(AOM_set_value_string(towGxLine, "bl_ZT2_FirstOPRevision_zt2_ArtificialTime", tbean.rgsj.c_str())); ITKCALL(AOM_set_value_string(towGxLine, "bl_ZT2_FirstOPRevision_zt2_MachineTime", tbean.jqsj.c_str())); ITKCALL(AOM_set_value_string(towGxLine, "bl_ZT2_FirstOPRevision_zt2_ReadinessTime", tbean.zbsj.c_str())); ITKCALL(AOM_set_value_string(towGxLine, "bl_ZT2_FirstOPRevision_zt2_ProCycle", tbean.zrsczq.c_str())); - AOM_save(towGxLine); - AOM_unlock(towGxLine); + ITKCALL(AOM_save(towGxLine)); + ITKCALL(AOM_unlock(towGxLine)); } ITKCALL(AOM_ask_value_tag(towGxLine, "bl_line_object", &towGx)); gxDocMap[gxbm2] = towGx; } } - BOM_close_window(ebom_window); + ITKCALL(BOM_close_window(ebom_window)); } //查询ID @@ -559,9 +557,9 @@ tag_t clone_process_from_template(char* process_item_id, boolean isXq, string pr tag_t revision_tag = NULLTAG; ITKCALL(ITEM_ask_latest_rev(item_tag, &revision_tag)); char* nameOld, *item_revision_id; - AOM_ask_value_string(revision_tag, "item_revision_id", &item_revision_id); - AOM_ask_value_string(revision_tag, "object_name", &nameOld); - MEBOM_init_module(); + ITKCALL(AOM_ask_value_string(revision_tag, "item_revision_id", &item_revision_id)); + ITKCALL(AOM_ask_value_string(revision_tag, "object_name", &nameOld)); + ITKCALL(MEBOM_init_module()); tag_t window_tag = NULLTAG; ITKCALL(ME_create_bop_window(&window_tag)); @@ -783,9 +781,9 @@ boolean isXn(tag_t matnr) { //获取分类属性 判断是否整除 string getClassVal(tag_t top_rev_tag, string& errMessage, ByqBean &bean) { //, string className - tag_t top_classificationObject, item; + tag_t top_classificationObject = NULLTAG, item = NULLTAG; ITKCALL(ITEM_ask_item_of_rev(top_rev_tag, &item)); - ICS_ask_classification_object(item, &top_classificationObject); + ITKCALL(ICS_ask_classification_object(item, &top_classificationObject)); if (top_classificationObject == NULL_TAG) { errMessage.append("顶层对象没有发送到分类\n"); @@ -796,8 +794,7 @@ string getClassVal(tag_t top_rev_tag, string& errMessage, ByqBean &bean) { //ICS_ask_id_name(top_class_tag, &top_class_id, &top_class_name); printf("BOM TOP LINE CLASS ID = %s | NAME = %s \n", top_class_id, top_class_name); int n_attrs; - char** attr_names; - char** attr_vals; + char** attr_names = NULL, ** attr_vals = NULL; ITKCALL(ICS_ask_attributes_of_classification_obj(top_classificationObject, &n_attrs, &attr_names, &attr_vals)); cout << n_attrs << endl; // int num = 1; @@ -998,7 +995,7 @@ boolean isTcmOnNot(tag_t process) { } return flag; } -void readProcessBom(tag_t bom_line, string& errorBuff,boolean &flag,tag_t &topProcess,string ¬TcmBuff) { +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; @@ -1021,116 +1018,127 @@ void readProcessBom(tag_t bom_line, string& errorBuff,boolean &flag,tag_t &topPr { char* refType; tag_t refTag = references_tag[i]; - AOM_ask_value_string(refTag, "object_type", &refType); + ITKCALL(AOM_ask_value_string(refTag, "object_type", &refType)); if (strcmp(refType, "MEProcessRevision") == 0) { hasProcess = true; break; } } + printf("hasProcess==%d\n", hasProcess); if (!hasProcess) { - char* bl_desc,*itemID; - AOM_ask_value_string(mantr, "item_id", &itemID); - { - if (strstr(objName, "变压器") != NULL) { - tag_t *byqRev; - string tmpGyId; - char *uid; - int cnt3 = 0; - AOM_ask_value_tags(mantr, "TC_Is_Represented_By", &cnt3, &byqRev); - ByqBean bean; - ITK__convert_tag_to_uid(byqRev[0], &uid); - printf("objName%s %s\n", objName, uid); - string cpxh = getClassVal(byqRev[0], errorBuff, bean); - char* thId; - AOM_ask_value_string(byqRev[0],"item_id",& thId); - printf("cpxh===>%s\n", cpxh.c_str()); - tag_t processTag = NULLTAG; - if (strstr(objName, "线圈") == NULL) { - vector idVec; - Split2(thId, "-", idVec); - processTag = getTmpProcess(cpxh, "1ZDB300000P", errorBuff, tmpGyId, false, "", idVec[1]); - topProcess = processTag; - if (processTag != NULLTAG) { - save_representation2(processTag, mantr, "IMAN_METarget"); - } + char* bl_desc = NULL, * itemID = NULL; + ITKCALL(AOM_ask_value_string(mantr, "item_id", &itemID)); + printf("back==%zd\n", back.size()); + if (back.size() > 0) { + vector backs; + Split2(back, "@", backs); + tag_t processTag = NULLTAG; + string tmpGyId; + processTag = getTmpProcess(backs[0], backs[1], errorBuff, tmpGyId, false, "", ""); + topProcess = processTag; + if (processTag != NULLTAG) { + printf("save_representation2\n"); + save_representation2(processTag, mantr, "IMAN_METarget"); + } + } + else if (strstr(objName, "变压器") != NULL) { + tag_t* byqRev = NULLTAG; + string tmpGyId; + char* uid = NULL; + int cnt3 = 0; + ITKCALL(AOM_ask_value_tags(mantr, "TC_Is_Represented_By", &cnt3, &byqRev)); + ByqBean bean; + ITK__convert_tag_to_uid(byqRev[0], &uid); + printf("objName%s %s\n", objName, uid); + string cpxh = getClassVal(byqRev[0], errorBuff, bean); + 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) { + vector idVec; + Split2(thId, "-", idVec); + processTag = getTmpProcess(cpxh, "1ZDB300000P", errorBuff, tmpGyId, false, "", idVec[1]); + topProcess = processTag; + if (processTag != NULLTAG) { + save_representation2(processTag, mantr, "IMAN_METarget"); } } - else { - AOM_ask_value_string(bom_line, "bl_rev_object_desc", &bl_desc); - vector descVec1; - Split2(bl_desc, " ", descVec1); - if (descVec1.size() > 1) { - string drawNos = descVec1[1]; - vector drawNoVec1; - Split2(drawNos, "-", drawNoVec1); - if (drawNoVec1.size() > 1) { - string wordNo = drawNoVec1[1]; //工程号 拼接1ZDB300000P 查找分类属性 - string drawNo = drawNoVec1[0]; //图号 - if (drawNoVec1.size() == 3) { - drawNo = drawNoVec1[0].append("-").append(drawNoVec1[1]); - wordNo = drawNoVec1[2]; + } + else { + ITKCALL(AOM_ask_value_string(bom_line, "bl_rev_object_desc", &bl_desc)); + vector descVec1; + Split2(bl_desc, " ", descVec1); + if (descVec1.size() > 1) { + string drawNos = descVec1[1]; + vector drawNoVec1; + Split2(drawNos, "-", drawNoVec1); + if (drawNoVec1.size() > 1) { + string wordNo = drawNoVec1[1]; //工程号 拼接1ZDB300000P 查找分类属性 + string drawNo = drawNoVec1[0]; //图号 + if (drawNoVec1.size() == 3) { + drawNo = drawNoVec1[0].append("-").append(drawNoVec1[1]); + wordNo = drawNoVec1[2]; + } + string byqId = "1ZDB300000P-", tmpGyId; + tag_t byqTag = NULLTAG, byqRev = NULLTAG, processTag = NULLTAG; + byqId.append(wordNo); + ITKCALL(ITEM_find_item(byqId.c_str(), &byqTag)); + ITKCALL(ITEM_ask_latest_rev(byqTag, &byqRev)); + ByqBean bean; + string cpxh = getClassVal(byqRev, errorBuff, bean); + printf("cpxh===>%s\n", cpxh.c_str()); + if (strstr(objName, "线圈") == NULL) { + processTag = getTmpProcess(cpxh, drawNo, errorBuff, tmpGyId, false, "", wordNo); + if (processTag != NULLTAG) { + save_representation2(processTag, mantr, "IMAN_METarget"); } - string byqId = "1ZDB300000P-", tmpGyId; - tag_t byqTag, byqRev; - byqId.append(wordNo); - ITKCALL(ITEM_find_item(byqId.c_str(), &byqTag)); - ITKCALL(ITEM_ask_latest_rev(byqTag, &byqRev)); - ByqBean bean; - string cpxh = getClassVal(byqRev, errorBuff, bean); - printf("cpxh===>%s\n", cpxh.c_str()); - tag_t processTag = NULLTAG; - if (strstr(objName, "线圈") == NULL) { - processTag = getTmpProcess(cpxh, drawNo, errorBuff, tmpGyId, false, "", wordNo); - if (processTag != NULLTAG) { - save_representation2(processTag, mantr, "IMAN_METarget"); + } + else { + string xqfs; + if (strstr(objName, "低压线圈") != NULL) { + //当前XXX线圈未在变压器参数表中维护绕线方式分类属性,请前往维护 + if (bean.dyxq.empty()) { + errorBuff.append("当前低压线圈未在变压器参数表中维护绕线方式分类属性,请前往维护\n"); + return; } + xqfs = bean.dyxq; } - else { - string xqfs; - if (strstr(objName, "低压线圈") != NULL) { - //当前XXX线圈未在变压器参数表中维护绕线方式分类属性,请前往维护 - if (bean.dyxq.empty()) { - errorBuff.append("当前低压线圈未在变压器参数表中维护绕线方式分类属性,请前往维护\n"); - return; - } - xqfs = bean.dyxq; - } - else if (strstr(objName, "中压线圈") != NULL) { - //当前XXX线圈未在变压器参数表中维护绕线方式分类属性,请前往维护 - if (bean.zyxq.empty()) { - errorBuff.append("当前中压线圈未在变压器参数表中维护绕线方式分类属性,请前往维护\n"); - return; - } - xqfs = bean.zyxq; + else if (strstr(objName, "中压线圈") != NULL) { + //当前XXX线圈未在变压器参数表中维护绕线方式分类属性,请前往维护 + if (bean.zyxq.empty()) { + errorBuff.append("当前中压线圈未在变压器参数表中维护绕线方式分类属性,请前往维护\n"); + return; } - else if (strstr(objName, "高压线圈") != NULL) { - //当前XXX线圈未在变压器参数表中维护绕线方式分类属性,请前往维护 - if (bean.gyxq.empty()) { - errorBuff.append("当前高压线圈未在变压器参数表中维护绕线方式分类属性,请前往维护\n"); - return; - } - xqfs = bean.gyxq; - } - else if (strstr(objName, "调压线圈") != NULL) { - //当前XXX线圈未在变压器参数表中维护绕线方式分类属性,请前往维护 - if (bean.tyxq.empty()) { - errorBuff.append("当前调压线圈未在变压器参数表中维护绕线方式分类属性,请前往维护\n"); - return; - } - xqfs = bean.tyxq; + xqfs = bean.zyxq; + } + else if (strstr(objName, "高压线圈") != NULL) { + //当前XXX线圈未在变压器参数表中维护绕线方式分类属性,请前往维护 + if (bean.gyxq.empty()) { + errorBuff.append("当前高压线圈未在变压器参数表中维护绕线方式分类属性,请前往维护\n"); + return; } - else if (strstr(objName, "稳压线圈") != NULL) { - //当前XXX线圈未在变压器参数表中维护绕线方式分类属性,请前往维护 - if (bean.wyxq.empty()) { - errorBuff.append("当前稳压线圈未在变压器参数表中维护绕线方式分类属性,请前往维护\n"); - return; - } - xqfs = bean.wyxq; + xqfs = bean.gyxq; + } + else if (strstr(objName, "调压线圈") != NULL) { + //当前XXX线圈未在变压器参数表中维护绕线方式分类属性,请前往维护 + if (bean.tyxq.empty()) { + errorBuff.append("当前调压线圈未在变压器参数表中维护绕线方式分类属性,请前往维护\n"); + return; } - processTag = getTmpProcess(cpxh, drawNo, errorBuff, tmpGyId, true, xqfs, wordNo); - if (processTag != NULLTAG) { - save_representation2(processTag, mantr, "IMAN_METarget"); + xqfs = bean.tyxq; + } + else if (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"); } } } @@ -1138,9 +1146,10 @@ void readProcessBom(tag_t bom_line, string& errorBuff,boolean &flag,tag_t &topPr } } } + 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); + readProcessBom(c_line_tag, errorBuff, flag, topProcess, notTcmBuff, ""); } } @@ -1157,7 +1166,7 @@ tag_t getProcess(tag_t designRev) { { char* refType; tag_t refTag = references_tag[i]; - AOM_ask_value_string(refTag, "object_type", &refType); + ITKCALL(AOM_ask_value_string(refTag, "object_type", &refType)); if (strcmp(refType, "MEProcessRevision") == 0) { hasProcess = true; process = refTag; @@ -1176,17 +1185,17 @@ int CloneTempProcess(void *returnValue) 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; + tag_t item_tag = NULLTAG, *c_line_tags = NULLTAG; (BOM_create_window(&ebom_window)); tag_t* bvr_list = NULL; - (ITEM_rev_list_bom_view_revs(designRev, &bvr_count, &bvr_list)); + ITKCALL(ITEM_rev_list_bom_view_revs(designRev, &bvr_count, &bvr_list)); printf("bvr_count=%d", bvr_count); - (BOM_set_window_top_line_bvr(ebom_window, bvr_list[0], &bom_line)); //顶层bom获取 + ITKCALL(BOM_set_window_top_line_bvr(ebom_window, bvr_list[0], &bom_line)); //顶层bom获取 string errorBuff; string notTcmBuff; char *bl_desc; - AOM_ask_value_string(bom_line, "bl_rev_object_desc", &bl_desc); + ITKCALL(AOM_ask_value_string(bom_line, "bl_rev_object_desc", &bl_desc)); int n_references = 0; int* levels = 0; @@ -1200,32 +1209,128 @@ int CloneTempProcess(void *returnValue) { char* refType; tag_t refTag = references_tag[i]; - AOM_ask_value_string(refTag, "object_type", &refType); + ITKCALL(AOM_ask_value_string(refTag, "object_type", &refType)); if (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,*topId; - AOM_ask_value_string(designRev, "object_name", &objName); - AOM_ask_value_string(designRev, "item_id", &topId); + 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物料 - if (strstr(objName, "变压器") != NULL) { + //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; + int* b_levels = 0; + tag_t* b_refs_tag = NULLTAG; + char** b_rel_name = NULL, * pcode = NULL; + string cpxh = ""; + //判断当前物料对象是否在“产成品”文件夹(ZT2_ProjectFolder)中 + ITKCALL(ITEM_ask_item_of_rev(designRev, &item_tag)); + ITKCALL(WSOM_where_referenced2(item_tag, 1, &b_refs, &b_levels, &b_refs_tag, &b_rel_name)); + for (int i = 0; i < b_refs; i++) { + char* ref_type = NULL; + ITKCALL(AOM_ask_value_string(b_refs_tag[i], "object_type", &ref_type)); + printf("ref_type:%s\n", ref_type); + if (tc_strcmp(ref_type, "ZT2_ProjectFolder") != 0) + continue; + int n_projs = 0; + tag_t* projs = NULLTAG; + ITKCALL(AOM_ask_value_tags(b_refs_tag[i], "contents", &n_projs, &projs)); + for (int j = 0; j < n_projs; j++) { + int n_drows = 0; + tag_t proj_rev = NULLTAG, * drows = NULLTAG; + ITKCALL(ITEM_ask_latest_rev(projs[j], &proj_rev)); + ITKCALL(AOM_ask_value_tags(proj_rev, "TC_Is_Represented_By", &n_drows, &drows)); + printf("n_drows:%d\n", n_drows); + if (n_drows == 0) + continue; + ByqBean bean; + cpxh = getClassVal(drows[0], errorBuff, bean); + isback = true; + break; + } + if (isback) + break; + } + backs.append(cpxh).append("@").append(tuhao); + /*string sql = "select a.GYID from CHINT_WORKHOUR_WhProductXH a,CHINT_WORKHOUR_WhGYRule b "; + sql.append("where a.COMPANYCODE=b.COMPANYCODE and a.ProductZu=b.ProductZu ") + .append("and a.COMPANYCODE='").append(group_name) + .append("' and a.ProductXH='").append(cpxh) + .append("' and b.TuHao='").append(tuhao) + .append("'"); + int outputColumn = 0, outputValueCount = 0; + char*** outputValue = NULL, sqlc[1024]; + tc_strcpy(sqlc, sql.c_str()); + QuerySQLNoInputParam(sqlc, &outputColumn, &outputValueCount, &outputValue); + if (outputValueCount > 0) { + gyid = outputValue[0][0]; + } + for (int i = 0; i < outputValueCount; i++) { + + }*/ + } + else if (strstr(objName, "变压器") != NULL) { tag_t *topMatnrs,*pMaterials; int num = 0, num2=0; - AOM_ask_value_tags(designRev, "TC_Is_Represented_By", &num, &topMatnrs); + ITKCALL(AOM_ask_value_tags(designRev, "TC_Is_Represented_By", &num, &topMatnrs)); printf("num===>%d\n", num); if (num >= 1) { tag_t tzRev = topMatnrs[0]; - AOM_ask_value_tags(tzRev, "representation_for", &num2, &pMaterials); + ITKCALL(AOM_ask_value_tags(tzRev, "representation_for", &num2, &pMaterials)); for (int x = 0; x < num2; x++) { char *pId,*zt2_ifpbom; tag_t pMatr = pMaterials[x]; - AOM_ask_value_string(pMatr, "item_id", &pId); - AOM_ask_value_string(pMatr, "zt2_ifpbom", &zt2_ifpbom); + 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) { tag_t process = getProcess(pMatr); if (process != NULLTAG) { @@ -1263,31 +1368,19 @@ int CloneTempProcess(void *returnValue) errorBuff = "当前选中的物料已经存在工艺路线.\n"; } } - printf("mapByq===>%d\n", mapByq.size()); + printf("mapByq===>%zd\n", mapByq.size()); if (hasProcess) { errorBuff = "当前选中的物料已经存在工艺路线.\n"; - }else if ((strcmp(bl_desc, "") == 0 || strstr(bl_desc,"-")==NULL)&& strstr(objName, "变压器") == NULL) { + }else if ((strcmp(bl_desc, "") == 0 || strstr(bl_desc,"-")==NULL) && strstr(objName, "变压器") == NULL && !isback) { errorBuff = "当前选中的物料版本没有图号信息,请检查.\n"; } else { POM_AM__set_application_bypass(true); - int url_num = 0; - char** url_vals = NULL; - 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; - } tag_t topProcess = NULLTAG; boolean flag = false; printf("errorBuff==>%s\n", errorBuff.c_str()); - readProcessBom(bom_line, errorBuff, flag, topProcess, notTcmBuff); + readProcessBom(bom_line, errorBuff, flag, topProcess, notTcmBuff, backs); if (topProcess != NULLTAG) { map::iterator it; for (it = mapByq.begin(); it != mapByq.end(); it++) { @@ -1296,18 +1389,18 @@ int CloneTempProcess(void *returnValue) save_representation2(topProcess, matnrPrev, "IMAN_METarget"); } } - DisConnServer(); if (!flag) { errorBuff = "当前选中的PBOM没有实件,无需做工艺路线."; } POM_AM__set_application_bypass(false); } + DisConnServer(); errorBuff.append(notTcmBuff); if (errorBuff.empty()) { errorBuff = "succ"; } printf("errorBuff==>%s\n", errorBuff.c_str()); - BOM_close_window(ebom_window); + 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/General.vcxproj b/General/General/General.vcxproj index 1e34225..82a4ac8 100644 --- a/General/General/General.vcxproj +++ b/General/General/General.vcxproj @@ -23,32 +23,32 @@ Win32Proj General General - 10.0.19041.0 + 10.0 DynamicLibrary true - v141 + v143 Unicode DynamicLibrary true - v141 + v143 Unicode DynamicLibrary false - v141 + v143 true Unicode DynamicLibrary false - v141 + v143 true Unicode @@ -130,18 +130,18 @@ MaxSpeed true true - WIN32;NDEBUG;_CONSOLE;IPLIB=none;%(PreprocessorDefinitions) + WIN32;NDEBUG;_USRDLL;_CONSOLE;IPLIB=none;%(PreprocessorDefinitions) false - D:\curl-7.84.0\curl-7.84.0\builds\libcurl-vc15-x64-release-dll-ipv6-sspi-schannel\include;D:\include13\11\11\include;D:\include13\11\11\include_cpp;D:\dflittk\oci\include;%(AdditionalIncludeDirectories) + Z:\TC_install\ZhengTai\c\libcurl-vc15-x64-release-dll-ipv6-sspi-schannel\include;Z:\TC_install\YSR\c\TC11.6\include;Z:\TC_install\YSR\c\TC11.6\include_cpp;Z:\TC_install\YSR\c\clib\OCI\include;Z:\TC_install\ZhengTai\c\libxl\include;%(AdditionalIncludeDirectories) Windows true true true - D:\include13\11\11\lib\*.lib;%(AdditionalDependencies) - D:\include13\11\11\lib - libuser_exits.ar.lib + Z:\TC_install\YSR\c\TC11.6\lib\*.lib;Z:\TC_install\ZhengTai\c\libxl\lib\*.lib;%(AdditionalDependencies) + Z:\TC_install\YSR\c\TC11.6\lib;Z:\TC_install\ZhengTai\c\libxl\lib;%(AdditionalLibraryDirectories) + libuser_exits.ar.lib;%(IgnoreSpecificDefaultLibraries) diff --git a/General/General/chint_add_to_workflow.cpp b/General/General/chint_add_to_workflow.cpp index e33c331..30cf4aa 100644 --- a/General/General/chint_add_to_workflow.cpp +++ b/General/General/chint_add_to_workflow.cpp @@ -314,6 +314,202 @@ int CHINT_task_complete(EPM_action_message_t msg) { } return ifail; } + +int CHINT_yptask_complete(EPM_action_message_t msg) { + + ECHO("=========================================================\n"); + 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; + 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; + + ITKCALL(PREF_ask_char_values("CHINT_yptask_complete", &url_num, &url_vals)); + if (url_num == 0) { + printf("CHINT_yptask_complete首选项配置不正确\n"); + return ifail; + } + Split(url_vals[0], ";", prefVec); + + 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)); + ITKCALL(EPM_ask_attachments(root_task, EPM_target_attachment, &targetCnt, &targets)); + + //获取当前用户任务列表 + ITKCALL(POM_get_user(&userName, &userTag)); + ITKCALL(EPM_ask_assigned_tasks(userTag, 2, &numl, &task_list)); + printf("task_list===>%d\n", numl); + ITKCALL(QRY_find2("查询项目", &query)); + + printf("targetCnt===>%d\n", targetCnt); + for (int t = 0; t < targetCnt; t++) { + tag_t rev = targets[t], item = NULLTAG; + char* id = NULL, *type = NULL, *name = NULL; + bool finish = true; + ITKCALL(WSOM_ask_object_type2(rev, &type)); + ITKCALL(WSOM_ask_name2(rev, &name)); + ITKCALL(AOM_ask_value_string(rev, "item_id", &id)); + for (int p = 0; finish && p < prefVec.size(); p++) { + vector split, types, tasks; + Split(prefVec[p], "=", split); + if (tc_strstr(split[0].c_str(), type) == nullptr) { + //若首选项不包含该对象类型则跳过 + continue; + } + printf("pref===>%s\n", prefVec[p].c_str()); + int index = -1; + Split(split[0], "&", types); + if (p == 0) + printf("types===>%zd\n", types.size()); + for (int i = 0; i < types.size(); i++) { + if (tc_strstr(types[i].c_str(), type) != nullptr) { + if (tc_strcmp(types[i].c_str(), type) == 0) { + index = i; + break; + } + else if (tc_strcmp("ZT2_Design3DRevision", type) == 0) { + //类型如果为ZT2_Design3DRevision,需判断id是否包含首选项中-后的子字符串 + vector sp; + Split(types[i], "-", sp); + if (tc_strstr(id, sp[1].c_str()) != NULL) { + index = i; + break; + } + } + else { + //部分类型不仅需要匹配类型,还要匹配名称 + string typeStr = type; + typeStr.append("-").append(name); + if (tc_strcmp(types[i].c_str(), typeStr.c_str()) == 0) { + index = i; + break; + } + } + } + } + printf("index===>%d\n", index); + if (index < 0) { + continue; + } + + //调用查询(查询项目,“zt2_WBSNo”-WBS号,“zt2_ProjectCode”-工程编号)查找对应的项目(ZT2_ProjectItem) + printf("query\n"); + tag_t* projects = NULLTAG; + char* zt2_WBSNo = NULL, * zt2_ProjectNo = NULL; + ITKCALL(ITEM_ask_item_of_rev(rev, &item)); + ITKCALL(AOM_ask_value_string(item, "zt2_WBSNo", &zt2_WBSNo)); + ITKCALL(AOM_ask_value_string(item, "zt2_ProjectNo", &zt2_ProjectNo)); + char* qry_entries[2] = { "WBS号", "工程编号" }, * qry_values[2] = { zt2_WBSNo, zt2_ProjectNo }; + int queryCnt = 0; + ITKCALL(QRY_execute(query, 2, qry_entries, qry_values, &queryCnt, &projects)); + printf("queryCnt===>%d\n", queryCnt); + if (queryCnt == 0) { + printf("未找到项目对象\n"); + finish = false; + break; + } + + //根据当前任务流程目标下的item类型,在定义好的首选项中查询另外的对象版本是否已发布 + //(对象存在项目文件夹“1 - 电磁设计”和“2 - 组件布置图”) + tag_t* projectFolder = NULLTAG, * folders = NULLTAG; + int pfolderCnt = 0, folderCnt = 0; + ITKCALL(AOM_ask_value_tags(projects[0], "IMAN_reference", &pfolderCnt, &projectFolder)); + if (pfolderCnt == 0) { + printf("未找到项目执行文件夹\n"); + finish = false; + break; + } + ITKCALL(AOM_ask_value_tags(projectFolder[0], "contents", &folderCnt, &folders)); + for (int f = 0; f < folderCnt; f++) { + char* folderName = NULL; + ITKCALL(WSOM_ask_name2(folders[f], &folderName)); + if (tc_strcmp(folderName, "1-电磁设计") == 0 || tc_strcmp(folderName, "2-组件布置图") == 0) { + tag_t* subItems = NULLTAG, subRev = NULLTAG; + int subCnt = 0; + ITKCALL(AOM_ask_value_tags(folders[f], "contents", &subCnt, &subItems)); + for (int j = 0; j < subCnt; j++) { + char* subType = NULL, * subId = NULL, * subName = NULL; + ITKCALL(ITEM_ask_latest_rev(subItems[j], &subRev)); + ITKCALL(WSOM_ask_object_type2(subRev, &subType)); + ITKCALL(WSOM_ask_name2(subRev, &subName)); + ITKCALL(AOM_ask_value_string(subRev, "item_id", &subId)); + for (int i = 0; i < types.size(); i++) { + if (i != index && tc_strstr(types[i].c_str(), subType) != NULL) { + if (tc_strcmp(types[i].c_str(), subType) == 0) { + tag_t* status = NULLTAG; + int statusCnt = 0; + ITKCALL(WSOM_status_ask_effectivities(subRev, &statusCnt, &status)); + if (statusCnt == 0) { + printf("No Status===>%s\n", subId); + goto ENDCOMPLETE; + } + break; + } + else if (tc_strcmp("ZT2_Design3DRevision", subType) == 0) { + //类型如果为ZT2_Design3DRevision,需判断id是否包含首选项中-后的子字符串 + vector sp; + Split(types[i], "-", sp); + if (tc_strstr(subId, sp[1].c_str()) != NULL) { + tag_t* status = NULLTAG; + int statusCnt = 0; + ITKCALL(WSOM_status_ask_effectivities(subRev, &statusCnt, &status)); + if (statusCnt == 0) { + printf("No Status===>%s\n", subId); + goto ENDCOMPLETE; + } + break; + } + } + else { + //部分类型不仅需要匹配类型,还要匹配名称 + string typeStr = subType; + typeStr.append("-").append(subName); + if (tc_strcmp(types[i].c_str(), typeStr.c_str()) == 0) { + tag_t* status = NULLTAG; + int statusCnt = 0; + ITKCALL(WSOM_status_ask_effectivities(subRev, &statusCnt, &status)); + if (statusCnt == 0) { + printf("No Status===>%s\n", subId); + goto ENDCOMPLETE; + } + break; + } + } + } + } + } + } + } + + char* projectId = NULL; + ITKCALL(AOM_ask_value_string(projects[0], "item_id", &projectId)); + Split(split[1], "&", tasks); + for (int i = 0; i < tasks.size(); i++) { + string projName = projectId; + projName.append("-").append(tasks[i]); + printf("projName %s \n", projName.c_str()); + for (int j = 0; j < numl; j++) { + tag_t taskTag = task_list[j]; + char* taskName; + ITKCALL(AOM_ask_value_string(taskTag, "job_name", &taskName)); + printf("taskName %s \n", taskName); + if (strstr(taskName, projName.c_str()) != NULL) { + ITKCALL(EPM_set_task_result(taskTag, EPM_RESULT_Completed)); + ITKCALL(EPM_trigger_action(taskTag, EPM_complete_action, "")); + finish = false; + } + } + } + ENDCOMPLETE: + printf("ENDCOMPLETE\n"); + break; + } + } + return ifail; +} int chint_CheckTable_State(EPM_action_message_t msg) { int ifail = ITK_ok; diff --git a/General/General/epm_handler_common.h b/General/General/epm_handler_common.h index a2b9646..aca5934 100644 --- a/General/General/epm_handler_common.h +++ b/General/General/epm_handler_common.h @@ -56,6 +56,8 @@ int CHINT_SavePost(METHOD_message_t* msg, va_list args); bool isTcm(tag_t mantr); bool isBomViewTcm(tag_t mantr); void TCMAndOwner(tag_t matnrTop); + +int CHINT_yptask_complete(EPM_action_message_t msg); //user service end #ifdef __cplusplus } @@ -85,6 +87,7 @@ void TCMAndOwner(tag_t matnrTop); #define S_LSChange "临时更改" #define BL_QUANTITY "bl_quantity" #define BL_LINE_OBJECT "bl_line_object" +/* #define ITKCALL( argument ) \ { \ int retcode = argument; \ @@ -97,4 +100,4 @@ void TCMAndOwner(tag_t matnrTop); printf( " in file ["__FILE__"], line [%d]\n\n", __LINE__ ); \ if (s != 0) MEM_free (s); \ } \ -} \ No newline at end of file +}*/ \ No newline at end of file diff --git a/General/General/epm_register_handler.cpp b/General/General/epm_register_handler.cpp index 6a20517..a657546 100644 --- a/General/General/epm_register_handler.cpp +++ b/General/General/epm_register_handler.cpp @@ -232,6 +232,14 @@ extern DLLAPI int USERSERVICE_custom_register_handlers(int *decision, va_list ar else { printf("Registering action handler CHINT_task_complete failed %d\n", ifail); } + ifail = EPM_register_action_handler("CHINT_yptask_complete", "CHINT_yptask_complete", (EPM_action_handler_t)CHINT_yptask_complete); + if (ifail == 0) { + printf("Registering action handler CHINT_yptask_complete successful\n"); + } + else { + printf("Registering action handler CHINT_yptask_complete failed %d\n", ifail); + } + ifail = EPM_register_action_handler("CHINT_cossheet_upgrade", "CHINT_cossheet_upgrade", (EPM_action_handler_t)CHINT_cossheet_upgrade); if (ifail == 0) { printf("Registering action handler CHINT_cossheet_upgrade successful\n"); diff --git a/General/General/string_utils.cxx b/General/General/string_utils.cxx index 9f6b79a..72328ee 100644 --- a/General/General/string_utils.cxx +++ b/General/General/string_utils.cxx @@ -28,7 +28,7 @@ $HISTORY$ #include "string_utils.h" -void Split( string strArg, string spliter, vector &ans ) +/*void Split(string strArg, string spliter, vector& ans) { ans.clear(); size_t index0; @@ -50,7 +50,43 @@ void Split( string strArg, string spliter, vector &ans ) break; } } +}*/ + +void Split(string strArg, string spliter, vector& ans) +{ + ans.clear(); + size_t index0; + string one_arg; + if (strArg.size() < 1) { + ans.push_back(strArg); + return; + } + if (strArg.find_first_not_of(' ') == string::npos) + strArg = ""; + while (strArg.size() > 0) + { + index0 = strArg.find(spliter); + //printf(" index0:%d", (int)index0); + if (index0 != string::npos) + { + if (index0 == 0) { + strArg = strArg.substr(index0 + spliter.size()); + ans.push_back(""); + } + else { + one_arg = strArg.substr(0, index0); + strArg = strArg.substr(index0 + spliter.size()); + ans.push_back(one_arg); + } + } + else + { + ans.push_back(strArg); + break; + } + } } + char* GSTR_clone( char **dst, const char *src ) { char *retVal = NULL;