//#include "dfl_custom.h" //#include //#include //#include //#include //#include "ado.h" //#include //#include //#include "rapidjson/document.h" //#include //#include "rapidjson/writer.h" //#include //#include //#include //#include "ocilib.h" //#include //#include //#include //#include //#include //#include //#include //#include //#include //using namespace std; //extern "C" int POM_AM__set_application_bypass(logical bypass); ////regex qq_reg("^1ZDB5.*\\d{1,}1000X.*-\\d{5,}$"); //tag_t getPBomTag(tag_t designRev) { // char* object_type; // AOM_ask_value_string(designRev,"object_type",&object_type); // if (strcmp(object_type,"ZT2_Design3DRevision") == 0) { // int num; // tag_t* mantrs; // ITKCALL(AOM_ask_value_tags(designRev, "representation_for", &num, &mantrs)); // return mantrs[0]; // } // else if (strcmp(object_type, "Part Revision") == 0) { // return designRev; // } //} //void getDrawNo(tag_t bom_line,string &drawNo){ // char* bl_desc; // AOM_ask_value_string(bom_line, "bl_rev_object_desc", &bl_desc); // regex qq_reg2("^1ZDB5.*\\d{1,}1000X.*"); // //string item_id = id; // AOM_ask_value_string(bom_line, "bl_rev_object_desc", &bl_desc); // vector descVec1; // Split(bl_desc, " ", descVec1); // printf("bl_desc===>%s\n", bl_desc); // if (descVec1.size() > 1) { // string drawNos = descVec1[1]; // printf("drawNos===>%s\n", descVec1[0].c_str()); // printf("drawNos===>%s\n", drawNos.c_str()); // vector drawNoVec1; // Split(drawNos, "-", drawNoVec1); // if (drawNoVec1.size() > 1) { // drawNo = drawNoVec1[0]; // smatch result; // vector vec2; // Split(drawNo,"_", vec2); // if (vec2.size() > 1) { // drawNo = vec2[0]; // } // bool ret = regex_match(drawNo, result, qq_reg2); // if (ret) { // drawNo = "1ZDB5*10000X"; // } // } // } //} ////遍历PBOM ////void //typedef struct { // string name;//产品型号 低、中、高、调、稳 // string zzmb; // string xh; // string tlth; // string type; // string tl; // string yjgx; // string ejgx; //}FeedRule; // //struct StBomBean { // string currentName;//产品型号 低、中、高、调、稳 // tag_t bomline; // boolean st = false; // boolean istl = false; // boolean flag = true; //第一层级 // vector childs; // //}; // //boolean isSt(tag_t matnr) { // int cnt2, numFac, cnt3; // boolean flag = false; // char** procureType, ** factorys, ** specialProcureType; // AOM_ask_value_strings(matnr, "zt2_SZSpecialProcuretype", &cnt3, &specialProcureType); //为/ // AOM_ask_value_strings(matnr, "zt2_SZProcuretype", &cnt2, &procureType); //包含自制 // AOM_ask_value_strings(matnr, "zt2_SZFactory", &numFac, &factorys); // for (int i = 0; i < numFac; i++) { // if (strcmp(factorys[i], "M060") == 0 && cnt2 > i && cnt3 > i) { // if (strstr(procureType[i], "自制") != NULL && strcmp(specialProcureType[i], "/") == 0) { // flag = true; // } // } // } // return flag; //} //void getBomMessage(vector& stBomlines, tag_t cBomLine, StBomBean &pBean) { // // int c_line_count; // tag_t * c_line_tags; // //char* parentName; // //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; // ITKCALL(AOM_ask_value_tag(cBomLine, "bl_line_object", &cmantr)); // ITKCALL(AOM_ask_value_string(cmantr, "object_name", &cName)); // printf("虚拟件===>%s\n", cName); // StBomBean bean; // bean.bomline = cBomLine; // bean.currentName = cName; // bean.flag = false; // if (c_line_count > 0 && isSt(cmantr)) { // bean.st = true; // //stBomlines.push_back(bean); // pBean.childs.push_back(bean); // } // else if (c_line_count == 0) { // bean.st = true; // // stBomlines.push_back(bean); // pBean.childs.push_back(bean); // } // else { // for (int i = 0; i < c_line_count; i++) { // tag_t c_line_tag = c_line_tags[i]; // getBomMessage(stBomlines, c_line_tag,bean); // } // // stBomlines.push_back(bean); // pBean.childs.push_back(bean); // } //} //void getBomMessage(vector &stBomlines, tag_t cBomLine) { // // int c_line_count; // tag_t * c_line_tags; // //char* parentName; // //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; // ITKCALL(AOM_ask_value_tag(cBomLine, "bl_line_object", &cmantr)); // ITKCALL(AOM_ask_value_string(cmantr, "object_name", &cName)); // StBomBean bean; // bean.bomline = cBomLine; // bean.currentName = cName; // if (c_line_count > 0 && isSt(cmantr)) { // bean.st = true; // stBomlines.push_back(bean); // } // else if (c_line_count == 0) { // bean.st = true; // stBomlines.push_back(bean); // //printf("st = true===>%s\n", cName); // } // else { // printf("虚拟件============>%s\n", cName); // for (int i = 0; i < c_line_count; i++) { // tag_t c_line_tag = c_line_tags[i]; // getBomMessage( stBomlines, c_line_tag, bean); // } // stBomlines.push_back(bean); // printf("虚拟件===========>%d\n", bean.childs.size()); // } //} //void autoFeedLike(tag_t towGxLine, StBomBean& pBean, vector& stBomlines) { // if (!pBean.st) { // printf("pBean.childs==>%d\n", pBean.childs.size()); // for (int i = 0; i < pBean.childs.size(); i++) { // StBomBean& child = pBean.childs[i]; // autoFeedLike(towGxLine, child, stBomlines); // } // } // else if (!pBean.istl) { // // pBean.istl = true; // tag_t newChild; // ITKCALL(BOM_line_copy(towGxLine, pBean.bomline, NULLTAG, &newChild)); // //ITKCALL(AOM_save(newChild)); // } //} //void autoFeedLike(tag_t towGxLine, StBomBean& pBean, string name2, vector& stBomlines) { // // printf(" pBean.childs.size()%d\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()); // if (name2.compare(child.currentName) == 0) { // printf("===================\n"); // autoFeedLike(towGxLine, child, stBomlines); // } // } //} // //void startFeed(tag_t meprocess, vector& stBomlines, FeedRule bean, string name1, string name2) { // 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* bvr_list = NULL; // (ITEM_rev_list_bom_view_revs(meprocess, &bvr_count, &bvr_list)); // printf("bvr_count=%d", bvr_count); // // (BOM_set_window_top_line_bvr(ebom_window, bvr_list[0], &bom_line)); //顶层bom获取 // //bom_line工艺 // int c_line_count; // ITKCALL(BOM_line_ask_all_child_lines(bom_line, &c_line_count, &c_line_tags)); // 一级工序 // //一级工序 // for (int i = 0; i < c_line_count; i++) { // tag_t oneGx = c_line_tags[i], * towGxLines; // int c_cnt = 0; // char* yjName; // tag_t yjGx; // ITKCALL(AOM_ask_value_tag(oneGx, "bl_line_object", &yjGx)); // AOM_ask_value_string(yjGx, "object_name", &yjName); // printf("yjName%s %s \n", yjName, bean.yjgx.c_str()); // if (bean.yjgx.compare(yjName) == 0) { // BOM_line_ask_all_child_lines(oneGx, &c_cnt, &towGxLines); // //二级工序 // for (int j = 0; j < c_cnt; j++) { // tag_t towGxLine = towGxLines[j]; // char* ejName; // tag_t ejGx; // ITKCALL(AOM_ask_value_tag(towGxLine, "bl_line_object", &ejGx)); // AOM_ask_value_string(ejGx, "object_name", &ejName); // printf("ejName%s %s\n", ejName, bean.ejgx.c_str()); // if (bean.ejgx.compare(ejName) == 0) { // printf("stBomlines %d\n", stBomlines.size()); // 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()); // if (stBom.currentName.compare(name1) == 0) { // //if (!stBom.istl && stBom.st && stBom.flag) { // autoFeedLike(towGxLine, stBom, name2, stBomlines); // //stBom.istl = true; // //} // } // } // } // } // } // } // BOM_save_window(ebom_window); // BOM_close_window(ebom_window); //} //void startFeed(tag_t meprocess, vector& stBomlines, FeedRule bean, vector names) { // 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* bvr_list = NULL; // (ITEM_rev_list_bom_view_revs(meprocess, &bvr_count, &bvr_list)); // printf("bvr_count=%d", bvr_count); // // (BOM_set_window_top_line_bvr(ebom_window, bvr_list[0], &bom_line)); //顶层bom获取 // //bom_line工艺 // int c_line_count; // ITKCALL(BOM_line_ask_all_child_lines(bom_line, &c_line_count, &c_line_tags)); // 一级工序 // //一级工序 // for (int i = 0; i < c_line_count; i++) { // tag_t oneGx = c_line_tags[i], * towGxLines; // int c_cnt = 0; // char* yjName; // tag_t yjGx; // ITKCALL(AOM_ask_value_tag(oneGx, "bl_line_object", &yjGx)); // AOM_ask_value_string(yjGx, "object_name", &yjName); // if (bean.yjgx.compare(yjName) == 0) { // BOM_line_ask_all_child_lines(oneGx, &c_cnt, &towGxLines); // //二级工序 // for (int j = 0; j < c_cnt; j++) { // tag_t towGxLine = towGxLines[j]; // char* ejName; // tag_t ejGx; // ITKCALL(AOM_ask_value_tag(towGxLine, "bl_line_object", &ejGx)); // AOM_ask_value_string(ejGx, "object_name", &ejName); // if (bean.ejgx.compare(ejName) == 0) { // for (int t = 0; t < stBomlines.size(); t++) { // StBomBean& stBom = stBomlines[t]; // tag_t newChild; // if (std::find(names.begin(), names.end(), stBom.currentName) != names.end() && stBom.flag) { // printf("stBom.currentName2%s %d\n", stBom.currentName.c_str(), !stBom.istl); // if (!stBom.istl) { // autoFeedLike(towGxLine, stBom, stBomlines); // stBom.istl = true; // } // } // } // } // } // } // } // BOM_save_window(ebom_window); // BOM_close_window(ebom_window); //} //void startFeed(tag_t meprocess, vector& stBomlines, FeedRule bean, string nameLike) { // 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* bvr_list = NULL; // (ITEM_rev_list_bom_view_revs(meprocess, &bvr_count, &bvr_list)); // printf("bvr_count=%d", bvr_count); // // (BOM_set_window_top_line_bvr(ebom_window, bvr_list[0], &bom_line)); //顶层bom获取 // //bom_line工艺 // int c_line_count; // ITKCALL(BOM_line_ask_all_child_lines(bom_line, &c_line_count, &c_line_tags)); // 一级工序 // //一级工序 // for (int i = 0; i < c_line_count; i++) { // tag_t oneGx = c_line_tags[i], * towGxLines; // int c_cnt = 0; // char* yjName; // tag_t yjGx; // ITKCALL(AOM_ask_value_tag(oneGx, "bl_line_object", &yjGx)); // AOM_ask_value_string(yjGx, "object_name", &yjName); // printf("yjName===>%s %s \n", yjName, bean.yjgx.c_str()); // // if (bean.yjgx.compare(yjName) == 0) { // BOM_line_ask_all_child_lines(oneGx, &c_cnt, &towGxLines); // //二级工序 // for (int j = 0; j < c_cnt; j++) { // tag_t towGxLine = towGxLines[j]; // char* ejName; // tag_t ejGx; // ITKCALL(AOM_ask_value_tag(towGxLine, "bl_line_object", &ejGx)); // AOM_ask_value_string(ejGx, "object_name", &ejName); // printf("ejName===>%s \n", ejName); // if (bean.ejgx.compare(ejName) == 0) { // for (int t = 0; t < stBomlines.size(); t++) { // StBomBean& stBom = stBomlines[t]; // tag_t newChild; // //printf("Tlstart===>%s %d %d\n", stBom.currentName.c_str(), stBom.st, !stBom.istl); // //printf("Tlstart===>%d %d\n", ); // printf("stBom.currentName2==>%s %d\n", stBom.currentName.c_str(), !stBom.istl); // if (!nameLike.empty()) { // if (strstr(stBom.currentName.c_str(), nameLike.c_str()) != NULL) { // printf("stBom.currentName2==>%s %d\n", stBom.currentName.c_str(), !stBom.st); // if (!stBom.istl && stBom.flag) { // autoFeedLike(towGxLine, stBom, stBomlines); // stBom.istl = true; // } // } // } // else if (!stBom.istl) { // autoFeedLike(towGxLine, stBom, stBomlines); // stBom.istl = true; // //ITKCALL(BOM_line_copy(towGxLine, stBom.bomline, NULLTAG, &newChild)); // } // //ITKCALL(AOM_save(newChild)); // } // break; // } // } // } // } // BOM_save_window(ebom_window); // BOM_close_window(ebom_window); //} //void AutoFeeding(char * revUid,string &errBuffer) { // string sql = "select MC,ZZMB,XH,TLTH,LX,TL,YJGX,EJGX from CHINT_GYGL_001 WHERE LX is not NULL ORDER BY XH "; // // /*string sql22 = "select CHINT_MATERIAL_SEQ.nextval as sid from dual"; // int colmun2 = 0, count2 = 0; // char*** outputValue2 = NULL; // printf("search1"); // QuerySQLNoInputParam((char*)sql22.c_str(), &colmun2, &count2, &outputValue2);*/ // tag_t matnrRev; // ITK__convert_uid_to_tag(revUid, &matnrRev); // // // tag_t mantr = getPBomTag(matnrRev); // int n_references = 0; // int* levels = 0; // tag_t* references_tag = NULLTAG; // char** relation_type_name = NULL; // //通过引用关系查找到变更单 // ITKCALL(WSOM_where_referenced(mantr, 1, &n_references, &levels, &references_tag, &relation_type_name)); // //boolean hasProcess = false; // int meNum = 0; // tag_t meprocess; // for (int i = 0; i < n_references; i++) // { // char* refType; // tag_t refTag = references_tag[i]; // AOM_ask_value_string(refTag, "object_type", &refType); // if (strcmp(refType, "MEProcessRevision") == 0) { // //hasProcess = true; // //break; // meNum = meNum + 1; // meprocess = refTag; // } // } // if (meNum == 0) { // errBuffer.append("请关联工艺后重新操作.\n"); // return; // } // if (meNum > 1) { // errBuffer.append("请取消多余关联工艺后重新操作.\n"); // return; // } // 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]); // string errorBuff; // //map %s \n", url.c_str()); // if (ConnServer(url_vals[3], url_vals[4], (char*)url.c_str()) == -1) // { // printf("提示:中间数据表访问失败\n"); // //ifail = 1; // } // char selectCPZ[200], selectGyId[200]; // int outputColumn1 = 0, outputValueCount1 = 0; // char*** outputValue1 = NULL; // sprintf(selectGyId, sql.c_str()); // printf("search2 %s \n", selectGyId); // QuerySQLNoInputParam(selectGyId, &outputColumn1, &outputValueCount1, &outputValue1); // printf("search22\n"); // map> drawMap; // map> nameMap; // for (int j = 0; j < outputValueCount1; j++) { // string name = outputValue1[j][0]; // string zzmb = outputValue1[j][1]; // string num = outputValue1[j][2]; // string tlth = outputValue1[j][3]; // string type = outputValue1[j][4]; // string tl = outputValue1[j][5]; // string yjgx = outputValue1[j][6]; // string ejgx = outputValue1[j][7]; // FeedRule ruleBean; // ruleBean.name = name; // ruleBean.zzmb = zzmb; // ruleBean.xh = num; // ruleBean.tlth = tlth; // ruleBean.type = type; // ruleBean.tl = tl; // ruleBean.yjgx = yjgx; // ruleBean.ejgx = ejgx; // if (strstr(zzmb.c_str(),"ZDB") != NULL) { // if (drawMap.count(zzmb) == 0) { // vector feedRuleVec; // feedRuleVec.push_back(ruleBean); // drawMap[zzmb] = feedRuleVec; // } // else { // drawMap[zzmb].push_back(ruleBean); // } // } // else { // if (nameMap.count(zzmb) == 0) { // vector feedRuleVec; // feedRuleVec.push_back(ruleBean); // nameMap[zzmb] = feedRuleVec; // } // else { // nameMap[zzmb].push_back(ruleBean); // } // } // } // // //遍历PBOM // tag_t* bvr_list = NULL, ebom_window, bom_line; // int bvr_count; // ITKCALL(ITEM_rev_list_bom_view_revs(mantr, &bvr_count, &bvr_list)); // ITKCALL(BOM_create_window(&ebom_window)); // ITKCALL(BOM_set_window_top_line(ebom_window, NULL, mantr, NULLTAG, &bom_line)); // // int c_line_count; // tag_t * c_line_tags; // vector stBomlines; // ITKCALL(BOM_line_ask_all_child_lines(bom_line, &c_line_count, &c_line_tags)); // for (int i = 0; i < c_line_count; i++) { // getBomMessage(stBomlines, c_line_tags[i]); // } // POM_AM__set_application_bypass(true); // string drawNo; // getDrawNo(bom_line, drawNo); // printf("制造目标=====>%s\n", drawNo.c_str()); // // // if (drawMap.count(drawNo)>0) { // //图号匹配 // vector beans = drawMap[drawNo]; // printf("beans===>%d\n", beans.size()); // for (int t = 0; t < beans.size(); t++) { // FeedRule bean = beans[t]; // printf("nameMatnr%s\n", bean.tlth.c_str()); // if (bean.tlth.empty()) { // //全投 // printf("beans===>%s %s\n", bean.yjgx.c_str(), bean.ejgx.c_str()); // startFeed(meprocess, stBomlines,bean,""); // } // else{ // //剩下全投 // if (bean.tlth.compare("else") == 0) { // startFeed(meprocess, stBomlines, bean,""); // } // else { // string nameMatnr = bean.tlth; // //按名称模糊匹配投 // // if (strstr(nameMatnr.c_str(),"*") != NULL) { // vector liVec; // string nameLike; // Split(nameMatnr, "*", liVec); // for (int x = 0; x < liVec.size(); x++) { // if (!liVec[x].empty()) { // nameLike = liVec[x]; // } // } // printf("beans===>%s %s\n", bean.yjgx.c_str(), nameLike); // startFeed(meprocess, stBomlines, bean, nameLike); // } // else { // printf("beans===>%s %s\n", bean.yjgx.c_str(), bean.ejgx.c_str()); // //按名称精准匹配投料 // if (strstr(nameMatnr.c_str(), "\\") != NULL) { // vector names; // Split(nameMatnr, "\\", names); // startFeed(meprocess, stBomlines, bean, names[0], names[1]); // } // else { // vector names; // Split(nameMatnr, ";", names); // startFeed(meprocess, stBomlines, bean, names); // } // } // } // } // } // } // else { // //map> nameMap; // map>::iterator it; // //名称模糊匹配 // for (it = nameMap.begin(); it != nameMap.end(); it++) { // string s = it->first; // char* nowName; // 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()); // 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()); // if (bean.tlth.empty()) { // //全投 // //printf("beans===>%s %s\n", bean.yjgx.c_str(), bean.ejgx.c_str()); // startFeed(meprocess, stBomlines, bean, ""); // } // else { // //剩下全投 // if (bean.tlth.compare("else") == 0) { // startFeed(meprocess, stBomlines, bean, ""); // } // else { // string nameMatnr = bean.tlth; // //按名称模糊匹配投 // if (strstr(nameMatnr.c_str(), "*") != NULL) { // vector liVec; // string nameLike; // Split(nameMatnr, "*", liVec); // for (int x = 0; x < liVec.size(); x++) { // if (!liVec[x].empty()) { // nameLike = liVec[x]; // } // } // startFeed(meprocess, stBomlines, bean, nameLike); // } // else { // //按名称精准匹配投料 // if (strstr(nameMatnr.c_str(), "\\") != NULL) { // vector names; // Split(nameMatnr, "\\", names); // printf("beans===>%s %s\n", names[0].c_str(), names[1].c_str()); // startFeed(meprocess, stBomlines, bean, names[0], names[1]); // } // else { // vector names; // Split(nameMatnr, ";", names); // for (int k = 0; k < names.size(); k++) { // printf("k===>%s\n", names[k].c_str()); // } // printf("beans===>%d %d\n", names.size()); // startFeed(meprocess, stBomlines, bean, names); // } // } // } // } // } // } // } // } // // POM_AM__set_application_bypass(false); // ITKCALL(BOM_close_window(ebom_window)); // //readProcessBom(bom_line, errorBuff); // DisConnServer(); //}