//#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 // //extern "C" int POM_AM__set_application_bypass(logical bypass); ////正则判断是否为 线圈 "1ZDB581000X-00055"; 线圈申请P物料 //regex qq_reg("^1ZDB5.*\\d{1,}1000X.*"); //\\d{5,}$ //struct newCBean //{ // int num; // tag_t cLine; //}; //struct EBomBean //{ // boolean istop = false; // vector topCcp; // tag_t eRev; //原来的e物料 // tag_t eBomline; //Ebom行 // vector pRev; //另存的P物料 // tag_t pBomline = NULL; //PBOM // tag_t designRev; //E物料的图纸 // vector parentBean; //遍历EBOM时候的父级 // vector c_lines; //EBOM中的子件 只有线圈用 //}; // ///* //primaryTag版本 //secondTag数据集 //relationType关系 //*/ //string Sql2 = "select t.PrhName,t.PrdLine,t.PrdNo,t.PrdFeatureCode,t.FeatureName,t.PrdCanInput,t.PrdSign from CcemVW_Prd t where t.prhcode = '%s' order by t.PrdNo"; //string Sql1 = "select t.PmpcPrhCode, t.PmpcPType,t.PmpcMType from CcemVW_Pmpc t where t.PmpcCode='%s'"; //string m_code1 = "230101001"; //string m_code2 = "220103001"; // //struct PRD //{ // string prdFeatureCode; // string featureName; //}; //struct PMPC //{ // string m_code; // string pmpcPrhCode; // string pmpcPType; // string pmpcMType; //}; //PMPC pmpc; //vector prds; //void save_representation2222(tag_t primaryTag, tag_t secondTag, char* relationType) //{ // // //POM_AM__set_application_bypass(true); // tag_t typeTag = NULLTAG; // ITKCALL(GRM_find_relation_type(relationType, &typeTag)); // // ITKCALL(AOM_refresh(primaryTag, TRUE)); // ITKCALL(AOM_refresh(secondTag, TRUE)); // tag_t relationTag = NULLTAG; // ITKCALL(GRM_create_relation(primaryTag, secondTag, typeTag, NULLTAG, &relationTag));//如果关系已经存在,那么就是增加对象 // // ITKCALL(GRM_save_relation(relationTag));//很必要 // ITKCALL(AOM_save(primaryTag)); // ITKCALL(AOM_save(secondTag)); // ITKCALL(AOM_refresh(primaryTag, FALSE)); // ITKCALL(AOM_refresh(secondTag, FALSE)); // //POM_AM__set_application_bypass(false); // //} //void replaceBom(tag_t newTopLine, tag_t newChild) { // int c_line_count, cnt2, numFac; // tag_t* c_line_tags; // char* uid1; // ITK__convert_tag_to_uid(newChild, &uid1); // ITKCALL(BOM_line_ask_all_child_lines(newTopLine, &c_line_count, &c_line_tags)); // for (int t = 0; t < c_line_count; t++) { // tag_t c_line_tag = c_line_tags[t], eRev; // ITKCALL(AOM_ask_value_tag(c_line_tag, "bl_line_object", &eRev)); // char* uid2; // ITK__convert_tag_to_uid(eRev, &uid2); // if (strcmp(uid2, uid1) == 0) { // BOM_line_replace(c_line_tag, NULLTAG, newChild, NULLTAG); // } // } // //} //string sql_query = "select FeatureList from CcemVW_GoodsFeature where GoodsCode ='%s' "; //void saveAsCycle(EBomBean& childPm, map& map,tag_t& topPrev) { // tag_t tcType, newItem, newRev; // char* newId; // if (childPm.parentBean.size() > 0) { // saveAsCycle(childPm.parentBean[0], map, topPrev); // } // printf("1===>%d\n", childPm.pRev.size()); // char* eRevUid, * zt2_ifpbom; // AOM_ask_value_string(childPm.eRev, "zt2_ifpbom", &zt2_ifpbom); // if (strcmp(zt2_ifpbom, "P") == 0) { // if (childPm.pRev.size() == 0) { // childPm.pRev.push_back(childPm.eRev); // } // return; // } // ITK__convert_tag_to_uid(childPm.eRev, &eRevUid); // if (childPm.pRev.size() == 0) { // if (map.count(eRevUid) > 0) { // childPm.pRev.push_back(map[eRevUid]); // } // else { // char* newid = NULL; // logical isModified = FALSE; // tag_t item_type_tag; // TCTYPE_ask_type("Item", &item_type_tag); // ITKCALL(USER_new_item_id(NULLTAG, item_type_tag, &isModified, &newid)); // /*ITKCALL(NR_next_value("MEProcess", "item_id", NULLTAG, "", "", "", // NULLTAG, "", "", &next_id));*/ // printf("next_id==>%s\n", newid); // ITKCALL(ITEM_copy_item(childPm.eRev, newid, NULL, &newItem, &newRev)); // //ITKCALL(AOM_set_value_string(newRev, "zt2_PMaterial", "PBOM")); // char* matnrNo; // AOM_ask_value_string(childPm.eRev, "zt2_MaterialNo", &matnrNo); // AOM_lock(newRev); // // AOM_set_value_string(newRev, "zt2_ifpbom", "P"); // AOM_set_value_string(newRev, "zt2_MaterialNo", matnrNo); // AOM_save(newRev); // AOM_unlock(newRev); // if (topPrev == NULLTAG) { // topPrev = newRev; // } // childPm.pRev.push_back(newRev); // map[eRevUid] = newRev; // int num = 0, revNum = 0, tagNum = 0; // tag_t* mantrs, dsuser, * structure_revisions, * bom_view_tags; // AOM_ask_value_tags(childPm.eRev, "TC_Is_Represented_By", &num, &mantrs); // if (num > 0) { // AOM_ask_value_tags(newRev, "structure_revisions", &revNum, &structure_revisions); // AOM_ask_value_tags(newRev, "bom_view_tags", &tagNum, &bom_view_tags); // AOM_ask_value_tag(mantrs[0], "owning_user", &dsuser); // tag_t defGroup; // ITKCALL(AOM_ask_value_tag(dsuser, "default_group", &defGroup)); // ITKCALL(AOM_set_ownership(newItem, dsuser, defGroup)); // ITKCALL(AOM_set_ownership(newRev, dsuser, defGroup)); // if (revNum > 0) { // ITKCALL(AOM_set_ownership(structure_revisions[0], dsuser, defGroup)); // } // if (tagNum > 0) { // ITKCALL(AOM_set_ownership(bom_view_tags[0], dsuser, defGroup)); // } // } // } // } // if (childPm.parentBean.size() > 0) { // EBomBean parentBean = childPm.parentBean[0]; // vector pRevs = parentBean.pRev; // if (pRevs.size() > 0) { // int bvr_count = 0, c_line_count; // tag_t ebom_window = NULLTAG; // tag_t bom_line = NULLTAG, * c_line_tags; // (BOM_create_window(&ebom_window)); // tag_t* bvr_list = NULL; // (ITEM_rev_list_bom_view_revs(pRevs[0], &bvr_count, &bvr_list)); // printf("bvr_count=%d\n", bvr_count); // // (BOM_set_window_top_line_bvr(ebom_window, bvr_list[0], &bom_line)); //顶层bom获取 // //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)); // // for (int ind = 0; ind < c_line_count; ind++) { // tag_t c_line_tag = c_line_tags[ind], mantr; // AOM_ask_value_tag(c_line_tag, "bl_line_object", &mantr); // char* eRevUid2; // ITK__convert_tag_to_uid(mantr, &eRevUid2); // if (strcmp(eRevUid2, eRevUid) == 0) { // if (childPm.pRev.size() > 0) { // printf("eRevUid===>%s\n", eRevUid); // ITKCALL(BOM_line_replace(c_line_tag, NULLTAG, childPm.pRev[0], NULLTAG)); // } // } // } // BOM_save_window(ebom_window); // BOM_close_window(ebom_window); // } // } //} //void getSpecs(tag_t rev, vector& vec) { // tag_t* comps; // int cnt; // /*AOM_ask_value_string(line, "ZT2_TYSpecifications", &ZT2_TYSpecifications); // if (strcmp(ZT2_TYSpecifications, "") == 0) {*/ // AOM_ask_value_tags(rev, "representation_for", &cnt, &comps); // char* zt2_Specifications; // //if (cnt == 0) { // AOM_ask_value_string(rev, "zt2_Specifications", &zt2_Specifications); // vec.push_back(zt2_Specifications); // // //} // //} //} //string insertSql = "insert into chint_material(\"Code\",\"PUID\",\"PmpcCode\",\"GoodsCode\",\"GoodsName\",\"UnitCode\",\"CompanyCode\",\"BpNo\",\"Spec\",\"TeRe\",\"State\",\"User\",\"Time\",\"Condition\",\"Info\") values('%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s',to_date('%s','yyyy-mm-dd HH24:mi:ss'),'%s','%s')"; //tag_t send1(tag_t rev, string now, // char* user_id, vector& jsons, string groupId, string spec, char* nameNum, char* idss, tag_t dcproxy) { // //map>::iterator it; // //for (it = general_maps.begin(); it != general_maps.end(); it++) { // char* item_id, * object_name, * zt2_DrawingNo1, * zt2_MaterialMark, * zt2_ProductModel // , * object_desc, * zt2_SurfaceTreatment, * zt2_Source; // AOM_ask_value_string(rev, "item_id", &item_id); //groupId // AOM_ask_value_string(rev, "object_name", &object_name); // AOM_ask_value_string(rev, "zt2_DrawingNo", &zt2_DrawingNo1); // AOM_ask_value_string(rev, "zt2_MaterialMark", &zt2_MaterialMark); // AOM_ask_value_string(rev, "zt2_ProductModel", &zt2_ProductModel); // AOM_ask_value_string(rev, "object_desc", &object_desc); // AOM_ask_value_string(rev, "zt2_SurfaceTreatment", &zt2_SurfaceTreatment); // AOM_UIF_ask_value(rev, "zt2_Source", &zt2_Source); // PMPC m_pmpc; // vector m_prds; // //if (strcmp(item_id, "1ZDB") == 0) { // m_prds = prds; // m_pmpc = pmpc; // printf("m_pmpc\n"); // //} // string pmpcCode = m_pmpc.m_code; // string prhCode = m_pmpc.pmpcPrhCode; // string pmpcType = m_pmpc.pmpcMType; // printf("pmpcType===>%s\n", pmpcType.c_str()); // if (pmpcType.length() == 0) { // return NULLTAG; // } // string goodsCode = ""; // 申请时为空 // string prefixName = nameNum; // string goodsName = prefixName.append(object_name);//rev.getProperty("object_name"); // string unitCode = "ST"; // 默认件,真实值ST // string companyCode = groupId; // string mp = "M"; // if (strcmp(zt2_Source, "外购") == 0) { // mp = "P"; // pmpcType = m_pmpc.pmpcPType; // } // string bpNo = item_id;//rev.getProperty("item_id"); // 非必填 // string zt2_DrawingNo = zt2_DrawingNo1;//rev.getProperty("zt2_DrawingNo"); // if (!zt2_DrawingNo.empty()) { // if (strcmp(item_id, zt2_DrawingNo1) != 0) // bpNo = zt2_DrawingNo1; // } // vector vec2; // if (strstr(bpNo.c_str(), "-") != NULL) { // Split(bpNo, "-", vec2); // bpNo = vec2[0].append("-").append(idss).append("-").append(vec2[1]); // } // string materialMark = zt2_MaterialMark;//rev.getProperty("zt2_MaterialMark"); // 非必填 // // if (materialMark.compare("--") == 0) { // materialMark = ""; // } // // 产品型号 //所属产品 // string productModel = zt2_ProductModel;//rev.getProperty("zt2_ProductModel"); // string teRe = ""; // string state = ""; // 申请时为空 // string wbs = ""; // string product = ""; // string user = user_id; // string time = now; // string condition = "审核中";// 默认审核中 // string desc = object_desc;// properties[5];//rev.getProperty("object_desc"); // //for (int i = 0; i < specs.size(); i++) { // string json = "{"; // 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); // char* projn = ""; // if (count2 > 0) { // projn = outputValue2[0][0]; // } // printf("projn===>%s\n", projn); // json.append("\"Code\":\"").append(projn).append("\","); // //string spec = specs[i]; // 非必填 // string feature = "\"Feature\":{"; // for (int j = 0; j < m_prds.size(); j++) { // PRD prd = m_prds[j]; // //System.out.println(prd.prdFeatureCode + "-" + prd.featureName); // if (strstr(prd.featureName.c_str(), "材质") != NULL) { // feature.append("\"").append(prd.prdFeatureCode).append("\":\"") // .append(zt2_MaterialMark).append("\","); // } // else if (strstr(prd.featureName.c_str(), "名称") != NULL) { // feature.append("\"").append(prd.prdFeatureCode).append("\":\"") // .append(goodsName).append("\","); // } // else if (strstr(prd.featureName.c_str(), "型号") != NULL || strstr(prd.featureName.c_str(), "规格") != NULL) { // feature.append("\"").append(prd.prdFeatureCode).append("\":\"") // .append(spec).append("\","); // } // else if (strstr(prd.featureName.c_str(), "图样代号") != NULL) { // feature.append("\"").append(prd.prdFeatureCode).append("\":\"") // .append(bpNo).append("\","); // } // else if (strstr(prd.featureName.c_str(), "所属产品") != NULL) { // feature.append("\"").append(prd.prdFeatureCode).append("\":\"") // .append(zt2_ProductModel).append("\","); // } // else { // feature.append("\"").append(prd.prdFeatureCode).append("\":\"").append("\","); // } // } // // if (strcmp(zt2_SurfaceTreatment, "") != 0) { // feature.append("\"").append("F067").append("\":\"").append(zt2_SurfaceTreatment).append("\""); // } // else { // feature = feature.substr(0, feature.length() - 1); // } // //feature.substr(0, feature.length()); // feature.append("},"); // string data = json; // data.append("\"Data\":[{"); // data.append("\"PrhCode").append("\":\"").append(prhCode).append("\","); // data.append("\"PmpcCode").append("\":\"").append(pmpcCode).append("\","); // data.append("\"PmpcType").append("\":\"").append(pmpcType).append("\","); // data.append("\"UnitCode").append("\":\"").append(unitCode).append("\","); // data.append("\"CompanyCode").append("\":\"").append(companyCode).append("\","); // data.append("\"UserCode").append("\":\"").append(user).append("\","); // data.append("\"MP").append("\":\"").append(mp).append("\","); // data.append(feature); // data.append("\"ProductGroupCode").append("\":\"").append("\","); // data.append("\"AssistUnitCode").append("\":\"").append("\","); // data.append("\"UnitQty").append("\":\"").append("\","); // data.append("\"AssistUnitQty").append("\":\"").append("\","); // data.append("\"Desc").append("\":\"").append(desc).append("\""); // data.append("}]}"); // jsons.push_back(data); // tag_t newItem, newRev, pitem; // ITKCALL(ITEM_create_item(NULL, goodsName.c_str(), "Part", NULL, &newItem, &newRev)); // AOM_lock(newItem); // AOM_lock(newRev); // ITKCALL(AOM_set_value_string(newRev, "zt2_Factory", groupId.c_str())); // ITKCALL(AOM_set_value_string(newRev, "object_desc", spec.c_str())); // ITKCALL(AOM_set_value_string(newRev, "zt2_ClassificationCode", "230101001")); // char* zt2_unit, * newUid; // ITK__convert_tag_to_uid(newRev, &newUid); // ITEM_ask_item_of_rev(rev, &pitem); // ITKCALL(AOM_ask_value_string(pitem, "zt2_unit", &zt2_unit)); // ITKCALL(AOM_set_value_string(newItem, "zt2_unit", zt2_unit)); // // tag_t defGroup; // ITKCALL(AOM_ask_value_tag(dcproxy, "default_group", &defGroup)); // ITKCALL(AOM_set_ownership(newItem, dcproxy, defGroup)); // ITKCALL(AOM_set_ownership(newRev, dcproxy, defGroup)); // AOM_save(newRev); // AOM_unlock(newRev); // AOM_save(newItem); // AOM_unlock(newItem); // char selectGyId[400]; // sprintf(selectGyId, insertSql.c_str(), projn, newUid, pmpcCode.c_str(), "", goodsName.c_str(), "ST", companyCode.c_str(), // bpNo.c_str(), spec.c_str(), "", "", user_id, now.c_str(), "审核中", ""); // ExecuteSQLNoInputParam(selectGyId); // return newRev; // /*uid = ""; // Object params[] = new Object[15]; // params[0] = code; // params[1] = uid; // params[2] = pmpcCode; // params[3] = goodsCode; // params[4] = goodsName; // params[5] = unitCode; // params[6] = companyCode; // params[7] = bpNo; // params[8] = spec; // params[9] = teRe; // params[10] = state; // params[11] = user; // params[12] = time; // params[13] = condition; // params[14] = "";*/ //} ////添加A项线圈的子行 //void addToAmatnr(tag_t* c_line_tags, int c_line_count, int len, tag_t newPAmatnr) { // // tag_t mantr = newPAmatnr, ebom_window, bom_line; // tag_t* bvr_list = NULL; // int bvr_count; // ITKCALL(ITEM_rev_list_bom_view_revs(mantr, &bvr_count, &bvr_list)); // if (bvr_count == 0) { // tag_t newView, newViewBvr, pitem; // ITEM_ask_item_of_rev(mantr, &pitem); // ITKCALL(PS_create_bom_view(NULL, NULL, NULL, pitem, &newView)); // AOM_save(newView); // ITKCALL(PS_create_bvr(newView, NULL, NULL, FALSE, mantr, &newViewBvr)); // AOM_save(newViewBvr); // AOM_save(mantr); // } // ITKCALL(BOM_create_window(&ebom_window)); // ITKCALL(BOM_set_window_top_line(ebom_window, NULL, mantr, NULLTAG, &bom_line)); // // for (int i = 0; i < c_line_count; i++) { // tag_t newChild; // char* oldQty, * seqNo; // ITKCALL(BOM_line_copy(bom_line, c_line_tags[i], NULLTAG, &newChild)); // AOM_ask_value_string(c_line_tags[i], "bl_quantity", &oldQty); // AOM_ask_value_string(c_line_tags[i], "bl_sequence_no", &seqNo); // int blQty = atoi(oldQty); // int num = blQty / len; // string numNew = to_string(num); // AOM_lock(newChild); // AOM_set_value_string(newChild, "bl_quantity", numNew.c_str()); // AOM_set_value_string(newChild, "bl_sequence_no", seqNo); // AOM_save(newChild); // AOM_unlock(newChild); // } // // ITKCALL(BOM_save_window(ebom_window)); // ITKCALL(BOM_close_window(ebom_window)); //} //char* G2U222(const char* gb2312) //{ // int len = MultiByteToWideChar(CP_ACP, 0, gb2312, -1, NULL, 0); // wchar_t* wstr = new wchar_t[len + 1]; // memset(wstr, 0, len + 1); // MultiByteToWideChar(CP_ACP, 0, gb2312, -1, wstr, len); // len = WideCharToMultiByte(CP_UTF8, 0, wstr, -1, NULL, 0, NULL, NULL); // char* str = new char[len + 1]; // memset(str, 0, len + 1); // WideCharToMultiByte(CP_UTF8, 0, wstr, -1, str, len, NULL, NULL); // if (wstr) delete[] wstr; // return str; //} ////childPm存放线圈的E物料,P物料 //void replaceBom(EBomBean& childPm, map& map, int len, tag_t dcproxy,tag_t &topPrev) { // // vector parentBeans = childPm.parentBean; // // //另存P物料 放到关系文件夹下 // saveAsCycle(childPm, map, topPrev); // // printf("saveAsCycle OVER \n"); // tag_t owning_group, owning_user; // char* grpId, * user_id; // int num = 0; // tag_t* mantrs, designRev; // string errBuff; // ITKCALL(AOM_ask_value_tags(childPm.eRev, "TC_Is_Represented_By", &num, &mantrs)); // if (num > 0) { // tag_t tzRev = mantrs[0]; // ITKCALL(AOM_ask_value_tag(tzRev, "owning_user", &owning_user)); // ITKCALL(AOM_ask_value_tag(tzRev, "owning_group", &owning_group)); // ITKCALL(AOM_ask_value_string(owning_group, "name", &grpId)); // ITKCALL(AOM_ask_value_string(owning_user, "user_id", &user_id)); // vector specs; // getSpecs(tzRev, specs); // printf("获取规格结束 \n"); // time_t now; // struct tm* p; // time(&now); // p = localtime(&now); // char buffer[80]; // sprintf_s(buffer, "%04d%02d%02d %02d:%02d:%02d", 1900 + p->tm_year, p->tm_mon + 1, p->tm_mday, p->tm_hour, p->tm_min, p->tm_sec); // string now1 = buffer; // vector jsons; // char* names[5] = { "A相","B相","C相","D相","E相" }; // char* idss[5] = { "A","B","C","D","E" }; // tag_t axqPmatnr = childPm.pRev[0]; //另存的线圈P物料 // // int bvr_count = 0, c_line_count; // tag_t ebom_window = NULLTAG; // tag_t bom_line = NULLTAG, * c_line_tags; // tag_t* bvr_list = NULL; // (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(PS_create_bom_view(NULL, NULL, NULL, pitem, &newView)); // AOM_save(newView); // ITKCALL(PS_create_bvr(newView, NULL, NULL, FALSE, axqPmatnr, &newViewBvr)); // AOM_save(newViewBvr); // AOM_save(axqPmatnr); // tag_t dsuser, * structure_revisions, * bom_view_tags; // AOM_ask_value_tag(tzRev, "owning_user", &dsuser); // tag_t defGroup; // ITKCALL(AOM_ask_value_tag(dsuser, "default_group", &defGroup)); // ITKCALL(AOM_set_ownership(newView, dsuser, defGroup)); // ITKCALL(AOM_set_ownership(newViewBvr, dsuser, defGroup)); // //return; // (ITEM_rev_list_bom_view_revs(axqPmatnr, &bvr_count, &bvr_list)); // } // (BOM_create_window(&ebom_window)); // (BOM_set_window_top_line_bvr(ebom_window, bvr_list[0], &bom_line)); //顶层bom获取 // //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)); // printf("int===>%d\n", len); // vector newPAmatnrs; // for (int i = 0; i < len; i++) { // //创建A项物料 // printf("names[i]===>%s\n", names[i]); // tag_t newPAmatnr = send1(tzRev, now1, user_id, jsons, grpId, specs[0], names[i], idss[i], dcproxy); // newPAmatnrs.push_back(newPAmatnr); // addToAmatnr(c_line_tags, c_line_count, len, newPAmatnr); // //ITKCALL(BOM_line_add(bom_line, NULLTAG, newPAmatnr, NULLTAG, &bomLineAdd)); // } // for (int i = 0; i < c_line_count; i++) { // ITKCALL(BOM_line_cut(c_line_tags[i])); // } // for (int t = 0; t < newPAmatnrs.size(); t++) { // tag_t bomLineAdd; // ITKCALL(BOM_line_add(bom_line, NULLTAG, newPAmatnrs[t], NULLTAG, &bomLineAdd)); // } // //ITKCALL(AOM_save(bom_line)); // ITKCALL(BOM_save_window(ebom_window)); // ITKCALL(BOM_close_window(ebom_window)); // for (int i = 0; i < jsons.size(); i++) { // printf("jsons ===> %s \n", jsons[i].c_str()); // string url = "http://10.128.20.35:9002/Post/PLM_Goods"; // string jsonUf = G2U222(jsons[i].c_str()); // //string msg = callHttpserver(jsonUf, url); // } // } //} ////获取分类属性 判断是否整除 //int getClassVal2(tag_t topItem, string& errMessage) { // tag_t top_classificationObject; // ICS_ask_classification_object(topItem, &top_classificationObject); // if (top_classificationObject == NULL_TAG) // { // errMessage.append("顶层对象没有发送到分类\n"); // return 0; // } // char* top_class_id = NULL, * top_class_name = NULL; // //ICS_ask_class_of_classification_obj(top_classificationObject, &top_class_tag); // //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; // ITKCALL(ICS_ask_attributes_of_classification_obj(top_classificationObject, &n_attrs, &attr_names, &attr_vals)); // cout << n_attrs << endl; // int num = 1; // for (int ii = 0; ii < n_attrs; ii++) // { // printf("attr_names[ii]==>%sTTT\n", attr_names[ii]); // printf("attr_vals[ii]==>%sTTT\n", attr_vals[ii]); // if (strcmp(attr_names[ii], "相数") == 0) { // if (strcmp(attr_vals[ii], "") == 0) { // errMessage.append("分类属性相数为空,请检查。\n"); // return 0; // } // else { // printf("111[ii]==TTT\n"); // if (strstr(attr_vals[ii], "3") != NULL) { // num = 3; // } // else if (strstr(attr_vals[ii], "1") != NULL) { // num = 1; // } // else if (strstr(attr_vals[ii], "5") != NULL) { // num = 5; // } // //num = atoi(attr_vals[ii]); // } // break; // } // } // return num; //} //void recyReadEBom(tag_t pLine, EBomBean parentBean, vector& beans, int len, tag_t pErev, string& errBuff) { // // int c_line_count, cnt2, numFac, cnt3; // tag_t* c_line_tags; // ITKCALL(BOM_line_ask_all_child_lines(pLine, &c_line_count, &c_line_tags)); // char* sffc, * name, * pRevId, ** sealeds, ** factorys, ** procureType; // ITKCALL(AOM_ask_value_string(pErev, "item_id", &pRevId)); // ITKCALL(AOM_ask_value_string(pErev, "object_name", &name)); // ITKCALL(AOM_ask_value_string(pErev, "zt2_State", &sffc)); // if (strcmp(sffc, "D1") == 0 || strcmp(sffc, "封存") == 0) { // errBuff.append("物料:").append(pRevId).append("/").append(name).append("已封存无法转换PBOM.\n"); // //return; // } // AOM_ask_value_strings(pErev, "zt2_SZProcuretype", &cnt3, &procureType); //包含自制 // AOM_ask_value_strings(pErev, "zt2_SZSealedornot", &cnt2, &sealeds); // AOM_ask_value_strings(pErev, "zt2_SZFactory", &numFac, &factorys); // for (int i = 0; i < numFac; i++) { // if (strcmp(factorys[i], "M060") == 0 && cnt2 > i) { // if (strcmp(sealeds[i], "Y") == 0) { // errBuff.append("物料:").append(pRevId).append("/").append(name).append("已封存无法转换PBOM.\n"); // //return; // } // if (cnt3 > i && strcmp(procureType[i], "/") == 0) { // errBuff.append("物料:").append(pRevId).append("/").append(name).append("物料不可用无法转换PBOM.\n"); // } // } // } // printf("c_line_count%d===>\n", c_line_count); // for (int i = 0; i < c_line_count; i++) { // // tag_t c_line_tag = c_line_tags[i], eRev; // ITKCALL(AOM_ask_value_tag(c_line_tag, "bl_line_object", &eRev)); // EBomBean cBean; // cBean.eRev = eRev; // cBean.eBomline = c_line_tag; // cBean.parentBean.push_back(parentBean); // //获取图纸对象 // //如果判断正则表达式通过 加到beans下最后检查整除并搭建 // int num = 0; // tag_t* mantrs; // ITKCALL(AOM_ask_value_tags(eRev, "TC_Is_Represented_By", &num, &mantrs)); // if (num == 1) { // char* id; // AOM_ask_value_string(mantrs[0], "item_id", &id); // string item_id = id; // smatch result; // bool ret = regex_match(item_id, result, qq_reg); // if (ret) { // char* zt2_ifpbom; // AOM_ask_value_string(eRev, "zt2_ifpbom", &zt2_ifpbom); // if (zt2_ifpbom != NULL && strcmp(zt2_ifpbom, "P") == 0) { // continue; // } // int cc_cnt; // tag_t* cc_lines; // BOM_line_ask_all_child_lines(c_line_tag, &cc_cnt, &cc_lines); // printf("cc_cnt===> %d item_id ==> %s \n", cc_cnt, id); // for (int tt = 0; tt < cc_cnt; tt++) { // tag_t cc_line = cc_lines[tt], c_eRev; // char* bl_quantity, * pId, * c_pId; // AOM_ask_value_string(eRev, "item_id", &pId); // AOM_ask_value_string(cc_line, "bl_quantity", &bl_quantity); // ITKCALL(AOM_ask_value_tag(cc_line, "bl_line_object", &c_eRev)); // 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) { // errBuff.append("P类物料:").append(pId).append("下子件").append(c_pId) // .append("无法整除,请检查。").append("\n"); // } // else { // int blQty = atoi(bl_quantity); // if (blQty % len != 0) { // errBuff.append("P类物料:").append(pId).append("下子件").append(c_pId) // .append("无法整除,请检查。").append("\n"); // } // else { // newCBean aBean; // aBean.num = blQty / len; // aBean.cLine = cc_line; // cBean.c_lines.push_back(aBean); // } // } // } // beans.push_back(cBean); // continue; // } // } // recyReadEBom(c_line_tag, cBean, beans, len, eRev, errBuff); // //判断子件数量是否整除 线圈数量 // } // //} //tag_t findDcUser() { // tag_t* tags; // tag_t query = NULLTAG; // //查询所有符合的物料编码 // ITKCALL(QRY_find2("__WEB_find_user", &query)); // if (query == NULLTAG) { // cout << "没有找到当前查询" << endl; // } // int cnt; // char** qry_entries1, ** qry_values2; // QRY_find_user_entries(query, &cnt, &qry_entries1, &qry_values2); // char* qry_values[1] = { "dcproxy" }; // int n_found; // ITKCALL(QRY_execute(query, 1, qry_entries1, qry_values, &n_found, &tags)); // if (n_found == 0) { // return NULLTAG; // } // else { // return tags[0]; // } //} // //class E2PBean //以class 开头 //{ //public: // string key;//wbs号+物料号组成的标识 // tag_t pMantr; // p物料 发布升版,没发布更新,取最新版本 (不带P的移除添加) // string revId = ""; // tag_t eMantr; // e物料 //public: // //定义成员函数 // void isSameKey(string newKey) // { // if (key.compare(newKey) == 0) { // //一样的 // } // } // //}; //struct EBomUpBean //{ // string matnrNo; // tag_t bomline; // vector parentBean; //遍历EBOM时候的父级 // vector c_lines; //EBOM中的子件 只有线圈用 //}; ////遍历EBOM 存放所有EBOM的 //void updatePbomCycle(tag_t eLine,string &errBuff,int len, EBomUpBean &upBean) { // int c_line_count; // tag_t *c_line_tags; // ITKCALL(BOM_line_ask_all_child_lines(eLine, &c_line_count, &c_line_tags)); // //printf("upBean===>%s\n", upBean.matnrNo.c_str()); // for (int i = 0; i < c_line_count; i++) { // char* ifpBom,*matnrNo; // tag_t c_line_tag = c_line_tags[i], eRev; // ITKCALL(AOM_ask_value_tag(c_line_tag, "bl_line_object", &eRev)); // AOM_ask_value_string(eRev, "zt2_ifpbom", &ifpBom); // AOM_ask_value_string(eRev, "zt2_MaterialNo", &matnrNo); // // EBomUpBean cBean; // cBean.matnrNo = matnrNo; // //printf("CChild===>%s\n", matnrNo); // cBean.bomline = c_line_tag; // int num = 0; // tag_t* mantrs; // ITKCALL(AOM_ask_value_tags(eRev, "TC_Is_Represented_By", &num, &mantrs)); // if (num == 1) { // char* id; // AOM_ask_value_string(mantrs[0], "item_id", &id); // string item_id = id; // smatch result; // bool ret = regex_match(item_id, result, qq_reg); // if (ret) { // char* zt2_ifpbom; // AOM_ask_value_string(eRev, "zt2_ifpbom", &zt2_ifpbom); // if (zt2_ifpbom != NULL && strcmp(zt2_ifpbom, "P") == 0) { // continue; // } // int cc_cnt; // tag_t* cc_lines; // BOM_line_ask_all_child_lines(c_line_tag, &cc_cnt, &cc_lines); // printf("cc_cnt===> %d item_id ==> %s \n", cc_cnt, id); // for (int tt = 0; tt < cc_cnt; tt++) { // tag_t cc_line = cc_lines[tt], c_eRev; // char* bl_quantity, * pId, * c_pId; // AOM_ask_value_string(eRev, "item_id", &pId); // AOM_ask_value_string(cc_line, "bl_quantity", &bl_quantity); // ITKCALL(AOM_ask_value_tag(cc_line, "bl_line_object", &c_eRev)); // 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) { // errBuff.append("P类物料:").append(pId).append("下子件").append(c_pId) // .append("无法整除,请检查。").append("\n"); // } // else { // int blQty = atoi(bl_quantity); // if (blQty % len != 0) { // errBuff.append("P类物料:").append(pId).append("下子件").append(c_pId) // .append("无法整除,请检查。").append("\n"); // } // else { // newCBean aBean; // aBean.num = blQty / len; // aBean.cLine = cc_line; // cBean.c_lines.push_back(aBean); // } // } // } // //beans.push_back(cBean); // //continue; // } // } // updatePbomCycle(c_line_tag, errBuff, len, cBean); // upBean.parentBean.push_back(cBean); // } //} //boolean checkName(char* name) { // // if (strstr(name, "A相") != NULL || strstr(name, "B相") != NULL || strstr(name, "C相") != NULL // || strstr(name, "E相") != NULL || strstr(name, "D相") != NULL ) { // return true; // } // else { // return false; // } // //} //tag_t saveAsUpdate(tag_t eRev, char *uid,tag_t pLine) { // char* newid = NULL; // logical isModified = FALSE; // tag_t item_type_tag, newItem, newRev; // TCTYPE_ask_type("Item", &item_type_tag); // ITKCALL(USER_new_item_id(NULLTAG, item_type_tag, &isModified, &newid)); // /*ITKCALL(NR_next_value("MEProcess", "item_id", NULLTAG, "", "", "", // NULLTAG, "", "", &next_id));*/ // printf("next_id==>%s\n", newid); // ITKCALL(ITEM_copy_item(eRev, newid, NULL, &newItem, &newRev)); // //ITKCALL(AOM_set_value_string(newRev, "zt2_PMaterial", "PBOM")); // char* matnrNo; // AOM_ask_value_string(eRev, "zt2_MaterialNo", &matnrNo); // AOM_lock(newRev); // // AOM_set_value_string(newRev, "zt2_ifpbom", "P"); // AOM_set_value_string(newRev, "zt2_MaterialNo", matnrNo); // AOM_save(newRev); // AOM_unlock(newRev); // // int num = 0, revNum = 0, tagNum = 0; // tag_t* mantrs, dsuser, * structure_revisions, * bom_view_tags; // AOM_ask_value_tags(eRev, "TC_Is_Represented_By", &num, &mantrs); // if (num > 0) { // AOM_ask_value_tags(newRev, "structure_revisions", &revNum, &structure_revisions); // AOM_ask_value_tags(newRev, "bom_view_tags", &tagNum, &bom_view_tags); // AOM_ask_value_tag(mantrs[0], "owning_user", &dsuser); // tag_t defGroup; // ITKCALL(AOM_ask_value_tag(dsuser, "default_group", &defGroup)); // ITKCALL(AOM_set_ownership(newItem, dsuser, defGroup)); // ITKCALL(AOM_set_ownership(newRev, dsuser, defGroup)); // if (revNum > 0) { // ITKCALL(AOM_set_ownership(structure_revisions[0], dsuser, defGroup)); // } // if (tagNum > 0) { // ITKCALL(AOM_set_ownership(bom_view_tags[0], dsuser, defGroup)); // } // } // { // //ITKCALL(BOM_line_replace(newChild, NULLTAG, newRev, NULLTAG)); // int bvr_count = 0, c_line_count; // tag_t ebom_window = NULLTAG; // tag_t bom_line = NULLTAG, * c_line_tags; // (BOM_create_window(&ebom_window)); // tag_t* bvr_list = NULL; // (ITEM_rev_list_bom_view_revs(pLine, &bvr_count, &bvr_list)); // printf("bvr_count=%d\n", bvr_count); // // (BOM_set_window_top_line_bvr(ebom_window, bvr_list[0], &bom_line)); //顶层bom获取 // //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)); // // for (int ind = 0; ind < c_line_count; ind++) { // tag_t c_line_tag = c_line_tags[ind], mantr; // AOM_ask_value_tag(c_line_tag, "bl_line_object", &mantr); // char* eRevUid2; // ITK__convert_tag_to_uid(mantr, &eRevUid2); // if (strcmp(eRevUid2, uid) == 0) { // ITKCALL(BOM_line_replace(c_line_tag, NULLTAG, newRev, NULLTAG)); // } // } // BOM_save_window(ebom_window); // BOM_close_window(ebom_window); // } // return newRev; //} //tag_t saveAsUpdate(tag_t eRev,tag_t newChild) { // char* newid = NULL; // logical isModified = FALSE; // tag_t item_type_tag, newItem, newRev; // TCTYPE_ask_type("Item", &item_type_tag); // ITKCALL(USER_new_item_id(NULLTAG, item_type_tag, &isModified, &newid)); // /*ITKCALL(NR_next_value("MEProcess", "item_id", NULLTAG, "", "", "", // NULLTAG, "", "", &next_id));*/ // printf("next_id==>%s\n", newid); // ITKCALL(ITEM_copy_item(eRev, newid, NULL, &newItem, &newRev)); // //ITKCALL(AOM_set_value_string(newRev, "zt2_PMaterial", "PBOM")); // char* matnrNo; // AOM_ask_value_string(eRev, "zt2_MaterialNo", &matnrNo); // AOM_lock(newRev); // // AOM_set_value_string(newRev, "zt2_ifpbom", "P"); // AOM_set_value_string(newRev, "zt2_MaterialNo", matnrNo); // AOM_save(newRev); // AOM_unlock(newRev); // // int num = 0, revNum = 0, tagNum = 0; // tag_t* mantrs, dsuser, * structure_revisions, * bom_view_tags; // AOM_ask_value_tags(eRev, "TC_Is_Represented_By", &num, &mantrs); // if (num > 0) { // AOM_ask_value_tags(newRev, "structure_revisions", &revNum, &structure_revisions); // AOM_ask_value_tags(newRev, "bom_view_tags", &tagNum, &bom_view_tags); // AOM_ask_value_tag(mantrs[0], "owning_user", &dsuser); // tag_t defGroup; // ITKCALL(AOM_ask_value_tag(dsuser, "default_group", &defGroup)); // ITKCALL(AOM_set_ownership(newItem, dsuser, defGroup)); // ITKCALL(AOM_set_ownership(newRev, dsuser, defGroup)); // if (revNum > 0) { // ITKCALL(AOM_set_ownership(structure_revisions[0], dsuser, defGroup)); // } // if (tagNum > 0) { // ITKCALL(AOM_set_ownership(bom_view_tags[0], dsuser, defGroup)); // } // } // { // ITKCALL(BOM_line_replace(newChild, NULLTAG, newRev, NULLTAG)); // //int bvr_count = 0, c_line_count; // //tag_t ebom_window = NULLTAG; // //tag_t bom_line = NULLTAG, * c_line_tags; // //(BOM_create_window(&ebom_window)); // //tag_t* bvr_list = NULL; // //(ITEM_rev_list_bom_view_revs(pRevs[0], &bvr_count, &bvr_list)); // //printf("bvr_count=%d\n", bvr_count); // // //(BOM_set_window_top_line_bvr(ebom_window, bvr_list[0], &bom_line)); //顶层bom获取 // ////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)); // // //for (int ind = 0; ind < c_line_count; ind++) { // // tag_t c_line_tag = c_line_tags[ind], mantr; // // AOM_ask_value_tag(c_line_tag, "bl_line_object", &mantr); // // char* eRevUid2; // // ITK__convert_tag_to_uid(mantr, &eRevUid2); // // if (strcmp(eRevUid2, eRevUid) == 0) { // // if (childPm.pRev.size() > 0) { // // printf("eRevUid===>%s\n", eRevUid); // // ITKCALL(BOM_line_replace(c_line_tag, NULLTAG, childPm.pRev[0], NULLTAG)); // // } // // } // //} // //BOM_save_window(ebom_window); // //BOM_close_window(ebom_window); // } // return newRev; //} // //void createAXxq(tag_t eRev,tag_t pRev,int len, tag_t dcproxy) { // tag_t owning_group, owning_user; // char* grpId, * user_id; // int num = 0; // tag_t* mantrs, designRev; // string errBuff; // ITKCALL(AOM_ask_value_tags(eRev, "TC_Is_Represented_By", &num, &mantrs)); // if (num > 0) { // tag_t tzRev = mantrs[0]; // ITKCALL(AOM_ask_value_tag(tzRev, "owning_user", &owning_user)); // ITKCALL(AOM_ask_value_tag(tzRev, "owning_group", &owning_group)); // ITKCALL(AOM_ask_value_string(owning_group, "name", &grpId)); // ITKCALL(AOM_ask_value_string(owning_user, "user_id", &user_id)); // vector specs; // getSpecs(tzRev, specs); // printf("获取规格结束 \n"); // time_t now; // struct tm* p; // time(&now); // p = localtime(&now); // char buffer[80]; // sprintf_s(buffer, "%04d%02d%02d %02d:%02d:%02d", 1900 + p->tm_year, p->tm_mon + 1, p->tm_mday, p->tm_hour, p->tm_min, p->tm_sec); // string now1 = buffer; // vector jsons; // char* names[5] = { "A相","B相","C相","D相","E相" }; // char* idss[5] = { "A","B","C","D","E" }; // tag_t axqPmatnr = pRev; //另存的线圈P物料 // // int bvr_count = 0, c_line_count; // tag_t ebom_window = NULLTAG; // tag_t bom_line = NULLTAG, * c_line_tags; // tag_t* bvr_list = NULL; // (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(PS_create_bom_view(NULL, NULL, NULL, pitem, &newView)); // AOM_save(newView); // ITKCALL(PS_create_bvr(newView, NULL, NULL, FALSE, axqPmatnr, &newViewBvr)); // AOM_save(newViewBvr); // AOM_save(axqPmatnr); // //return; // tag_t dsuser, * structure_revisions, * bom_view_tags; // AOM_ask_value_tag(tzRev, "owning_user", &dsuser); // tag_t defGroup; // ITKCALL(AOM_ask_value_tag(dsuser, "default_group", &defGroup)); // ITKCALL(AOM_set_ownership(newView, dsuser, defGroup)); // ITKCALL(AOM_set_ownership(newViewBvr, dsuser, defGroup)); // (ITEM_rev_list_bom_view_revs(axqPmatnr, &bvr_count, &bvr_list)); // } // (BOM_create_window(&ebom_window)); // (BOM_set_window_top_line_bvr(ebom_window, bvr_list[0], &bom_line)); //顶层bom获取 // //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)); // printf("int===>%d\n", len); // vector newPAmatnrs; // for (int i = 0; i < len; i++) { // //创建A项物料 // printf("names[i]===>%s\n", names[i]); // tag_t newPAmatnr = send1(tzRev, now1, user_id, jsons, grpId, specs[0], names[i], idss[i], dcproxy); // newPAmatnrs.push_back(newPAmatnr); // addToAmatnr(c_line_tags, c_line_count, len, newPAmatnr); // //ITKCALL(BOM_line_add(bom_line, NULLTAG, newPAmatnr, NULLTAG, &bomLineAdd)); // } // for (int i = 0; i < c_line_count; i++) { // ITKCALL(BOM_line_cut(c_line_tags[i])); // } // for (int t = 0; t < newPAmatnrs.size(); t++) { // tag_t bomLineAdd; // ITKCALL(BOM_line_add(bom_line, NULLTAG, newPAmatnrs[t], NULLTAG, &bomLineAdd)); // } // //ITKCALL(AOM_save(bom_line)); // ITKCALL(BOM_save_window(ebom_window)); // ITKCALL(BOM_close_window(ebom_window)); // for (int i = 0; i < jsons.size(); i++) { // printf("jsons ===> %s \n", jsons[i].c_str()); // string url = "http://10.128.20.35:9002/Post/PLM_Goods"; // string jsonUf = G2U222(jsons[i].c_str()); // //string msg = callHttpserver(jsonUf, url); // } // } //} // //void startUpdate(EBomUpBean upBean,tag_t bom_line,int len,tag_t dcproxy) { // vector vecs = upBean.parentBean; // int c_line_count = 0; // tag_t* c_line_tags; // vector matnrVec; // map pBomMap; // ITKCALL(BOM_line_ask_all_child_lines(bom_line, &c_line_count, &c_line_tags)); // for (int i = 0; i < c_line_count; i++) { // char* ifpBom, * matnrNo,* name; // tag_t c_line_tag = c_line_tags[i], eRev; // ITKCALL(AOM_ask_value_tag(c_line_tag, "bl_line_object", &eRev)); // AOM_ask_value_string(eRev, "zt2_ifpbom", &ifpBom); // AOM_ask_value_string(eRev, "zt2_MaterialNo", &matnrNo); // AOM_ask_value_string(eRev, "object_name", &name); // printf("zt2_MaterialNo ===>%s ifpBom==>%s\n", matnrNo, ifpBom); // if (strcmp(ifpBom, "P") == 0) { // matnrVec.push_back(matnrNo); // pBomMap[matnrNo] = c_line_tag; // //BOM_line_cut(c_line_tag); // } // else if(!checkName(name)){ // BOM_line_cut(c_line_tag);//pBomMap[matnrNo] = c_line_tag; // } // } // //移除所有非P 再从EBOM复制 // printf("vecs===>%d\n", vecs.size()); // for (int i = 0; i < vecs.size(); i++) { // EBomUpBean cupBean = vecs[i]; // // if (std::find(matnrVec.begin(), matnrVec.end(), cupBean.matnrNo) != matnrVec.end()) { // tag_t c_line_tag = pBomMap[cupBean.matnrNo]; // tag_t c_Rev,bomView=NULLTAG; // ITKCALL(AOM_ask_value_tag(c_line_tag, "bl_line_object", &c_Rev)); // boolean flagAs = false; // { // int structs = 0, statusNum = 0; // tag_t* structure_revisions, * release_status_list; // AOM_ask_value_tags(c_Rev, "structure_revisions", &structs, &structure_revisions); // if (structs > 0) { // AOM_ask_value_tags(structure_revisions[0], "release_status_list", &statusNum, &release_status_list); // if (statusNum > 0) { // tag_t* mantrsAs, dsuser, pBomTop,* bvr_list; // int revNum=0, num=0, bvr_count=0; // ITEM_copy_rev(c_Rev, NULL, &pBomTop); // flagAs = true; // AOM_ask_value_tags(c_Rev, "TC_Is_Represented_By", &num, &mantrsAs); // AOM_ask_value_tag(mantrsAs[0], "owning_user", &dsuser); // tag_t defGroup; // ITKCALL(AOM_ask_value_tag(dsuser, "default_group", &defGroup)); // ITKCALL(AOM_set_ownership(pBomTop, dsuser, defGroup)); // if (num > 0) { // AOM_ask_value_tags(pBomTop, "structure_revisions", &revNum, &structure_revisions); // if (revNum > 0) { // ITKCALL(AOM_set_ownership(structure_revisions[0], dsuser, defGroup)); // } // } // (BOM_create_window(&bomView)); // (ITEM_rev_list_bom_view_revs(pBomTop, &bvr_count, &bvr_list)); // printf("bvr_count=%d \n", bvr_count); // if (bvr_count == 0) { // //errBuff.append("不存在EBOM请检查\n"); // } // ITKCALL(BOM_set_window_top_line_bvr(bomView, bvr_list[0], &c_line_tag)); //顶层bom获取 // } // } // } // printf("matnrVec ===>%s\n", cupBean.matnrNo.c_str()); // startUpdate(cupBean, c_line_tag,len, dcproxy); // if (bomView!=NULLTAG&& flagAs) { // BOM_save_window(bomView); // BOM_close_window(bomView); // } // } // else{ // boolean flagLc = false; // char* seq; // printf("matnrVecNotP===>%s\n", cupBean.matnrNo.c_str()); // tag_t cline = cupBean.bomline; // tag_t newChild; // ITKCALL(BOM_line_copy(bom_line, cline, NULLTAG, &newChild)); // AOM_ask_value_string(cline, "bl_sequence_no", &seq); // AOM_lock(newChild); // AOM_set_value_string(newChild, "bl_sequence_no", seq); // AOM_save(newChild); // AOM_unlock(newChild); // tag_t c_Rev; // ITKCALL(AOM_ask_value_tag(cline, "bl_line_object", &c_Rev)); // // vector ccBeans = cupBean.parentBean; // //线圈装配 // for (int j = 0; j < ccBeans.size(); j++) { // EBomUpBean ccBean = ccBeans[j]; // if (ccBean.c_lines.size() > 0) { // //要另存操作 // char* uid; // tag_t cc_Rev; // tag_t newPrev = saveAsUpdate(c_Rev, newChild); // ITKCALL(AOM_ask_value_tag(ccBean.bomline, "bl_line_object", &cc_Rev)); // ITK__convert_tag_to_uid(cc_Rev, &uid); // tag_t cc_PRev = saveAsUpdate(cc_Rev, uid, newPrev); // createAXxq(cc_Rev, cc_PRev, len, dcproxy); // } // } // // } // } //} //void copyBomLine(tag_t matnrTop,tag_t otherPbom) { // tag_t ebom_window, ebom_window2, *bvr_list, * bvr_list2, bom_line, bom_line2,* c_line_tags,* c_line_tags2; // int bvr_count = 0, bvr_count2=0, c_line_count, c_line_count2; // (BOM_create_window(&ebom_window)); // (ITEM_rev_list_bom_view_revs(matnrTop, &bvr_count, &bvr_list)); // printf("bvr_count=%d \n", bvr_count); // if (bvr_count == 0) { // //errBuff.append("不存在EBOM请检查\n"); // } // ITKCALL(BOM_set_window_top_line_bvr(ebom_window, bvr_list[0], &bom_line)); //顶层bom获取 // printf("顶层bom获取\n"); // //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)); // // // (ITEM_rev_list_bom_view_revs(otherPbom, &bvr_count2, &bvr_list2)); // if (bvr_count2 == 0) { // tag_t newView, newViewBvr,pitem; // ITEM_ask_item_of_rev(otherPbom, &pitem); // ITKCALL(PS_create_bom_view(NULL, NULL, NULL, pitem, &newView)); // AOM_save(newView); // ITKCALL(PS_create_bvr(newView, NULL, NULL, FALSE, otherPbom, &newViewBvr)); // AOM_save(newViewBvr); // AOM_save(otherPbom); // int num = 0; // tag_t dsuser, * structure_revisions, * bom_view_tags,* mantrs; // ITKCALL(AOM_ask_value_tags(otherPbom, "TC_Is_Represented_By", &num, &mantrs)); // if (num == 1) { // AOM_ask_value_tag(mantrs[0], "owning_user", &dsuser); // tag_t defGroup; // ITKCALL(AOM_ask_value_tag(dsuser, "default_group", &defGroup)); // ITKCALL(AOM_set_ownership(newView, dsuser, defGroup)); // ITKCALL(AOM_set_ownership(newViewBvr, dsuser, defGroup)); // } // //return; // (ITEM_rev_list_bom_view_revs(otherPbom, &bvr_count2, &bvr_list2)); // } // (BOM_create_window(&ebom_window2)); // (BOM_set_window_top_line_bvr(ebom_window2, bvr_list2[0], &bom_line2)); //顶层bom获取 // ITKCALL(BOM_line_ask_all_child_lines(bom_line2, &c_line_count2, &c_line_tags2)); // for (int i = 0; i < c_line_count2; i++) { // BOM_line_cut(c_line_tags2[i]); // } // for (int i = 0; i < c_line_count; i++) { // tag_t newChild; // ITKCALL(BOM_line_copy(bom_line2, c_line_tags[i], NULLTAG, &newChild)); // } // //tag_t newChild; // //ITKCALL(BOM_line_copy(bom_line2, c_line_tags[i], NULLTAG, &newChild)); // // ITKCALL(BOM_save_window(ebom_window2)); // BOM_close_window(ebom_window2); // BOM_close_window(ebom_window); //} // //void EbomToPMethod(char* revUid, string& errBuffer) { // int ifail = ITK_ok; // char* sql = NULL; // tag_t matnrRev1; // ITK__convert_uid_to_tag(revUid, &matnrRev1); // // if (open("PLMUser", "PLMUser", "BDP2020", "10.128.20.35")) { // printf("链接SQLSERVER失败\n"); // } // else { // printf("链接SQLSERVER成功\n"); // } // { // char selectRecord[200], selectRecord1[200]; // sprintf(selectRecord, Sql1.c_str(), m_code1.c_str()); // printf("执行查询 %s\n", selectRecord); // int outputColumn = 0, outputValueCount = 0; // char*** outputValue = NULL; // ado_QuerySQLNoInputParam(selectRecord, &outputColumn, &outputValueCount, &outputValue); // prds.clear(); // string pmpcPrhCode, pmpcPType, pmpcMType; // for (int j = 0; j < outputValueCount; j++) { // pmpcPrhCode = outputValue[j][0]; // pmpcPType = outputValue[j][1]; // pmpcMType = outputValue[j][2]; // pmpc.m_code = m_code1; // pmpc.pmpcPrhCode = pmpcPrhCode; // pmpc.pmpcPType = pmpcPType; // pmpc.pmpcMType = pmpcMType; // printf("pmpcMType====>%s\n", outputValue[j][2]); // } // sprintf(selectRecord1, Sql2.c_str(), pmpcPrhCode.c_str()); // int outputColumn1 = 0, outputValueCount1 = 0; // char*** outputValue1 = NULL; // printf("执行查询 %s\n", selectRecord1); // ado_QuerySQLNoInputParam(selectRecord1, &outputColumn1, &outputValueCount1, &outputValue1); // for (int j = 0; j < outputValueCount1; j++) { // string prdFeatureCode = outputValue1[j][3]; // string featureName = outputValue1[j][4]; // PRD prd; // prd.prdFeatureCode = prdFeatureCode; // prd.featureName = featureName; // prds.push_back(prd); // } // } // close(); // //遍历design BOM 获取物料信息 // 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; // // int num = 0, num2 = 0; // tag_t* mantrs, designRev; // string errBuff; // ITKCALL(AOM_ask_value_tags(matnrRev1, "TC_Is_Represented_By", &num, &mantrs)); // int len = 1; // if (num == 1) { // designRev = mantrs[0]; // char* itemId; // AOM_ask_value_string(designRev, "item_id", &itemId); // vector vec2; // Split(itemId, "-", vec2); // string idTop = "1ZDB300000P"; // if (vec2.size() > 0) { // idTop = idTop.append("-").append(vec2[1]); // } // tag_t topItem, topDesginRev; // ITEM_find_item(idTop.c_str(), &topItem); // ITEM_ask_latest_rev(topItem, &topDesginRev); // len = getClassVal2(topItem, errBuff); // printf("len%d\n", len); // if (len > 0) { // boolean isUpdate = false; // // tag_t* bvr_list = NULL, * topMatnrs; // ITKCALL(AOM_ask_value_tags(topDesginRev, "representation_for", &num2, &topMatnrs)); // //tag_t matnrTop = NULLTAG; // printf("num2===>%d\n", num2); // map wlbmMap; // for (int t = 0; t < num2; t++) { // char* isPm, * zt2_MaterialNo, * zt2_WBSNo; // AOM_ask_value_string(topMatnrs[t], "zt2_WBSNo", &zt2_WBSNo); // AOM_ask_value_string(topMatnrs[t], "zt2_MaterialNo", &zt2_MaterialNo); // AOM_ask_value_string(topMatnrs[t], "zt2_ifpbom", &isPm); // string key = ""; // key.append(zt2_WBSNo).append(zt2_MaterialNo); // // if (wlbmMap.count(key) > 0) { // E2PBean &bean = wlbmMap[key]; // if (strcmp(isPm,"P") == 0) { // char* revId; // AOM_ask_value_string(topMatnrs[t], "item_revision_id", &revId); // if (strcmp(revId, bean.revId.c_str()) > 0) { // bean.pMantr = topMatnrs[t]; // bean.revId = revId; // } // } // else { // printf("1\n"); // bean.eMantr = topMatnrs[t]; // } // } // else { // E2PBean bean; // bean.key = key; // if (strcmp(isPm, "P") == 0) { // char* revId; // AOM_ask_value_string(topMatnrs[t],"item_revision_id", &revId); // bean.pMantr = topMatnrs[t]; // bean.revId = revId; // } // else { // printf("2\n"); // bean.eMantr = topMatnrs[t]; // } // wlbmMap[key] = bean; // } // if (strcmp(isPm, "P") == 0) { // isUpdate = true; // } // } // POM_AM__set_application_bypass(true); // tag_t dcproxy = findDcUser(); // if(!isUpdate && wlbmMap.size()>0){ // printf("wlbmMap.size()===>%d\n", wlbmMap.size()); // map::iterator it; // //名称模糊匹配 // tag_t matnrTop = NULLTAG; // string keyNum = ""; // //第一个创建,其他复制就行 // for (it = wlbmMap.begin(); it != wlbmMap.end(); it++) { // string s = it->first; // keyNum = s; // E2PBean tagBean = wlbmMap[s]; // printf("tagBean.key.c_str()=%s \n", tagBean.key.c_str()); //tagBean.key.c_str() // matnrTop = tagBean.eMantr; // break; // } // char* uida; // ITK__convert_tag_to_uid(matnrTop, &uida); // printf("uida=%s \n", uida); // //只有E物料新建的逻辑 // (BOM_create_window(&ebom_window)); // (ITEM_rev_list_bom_view_revs(matnrTop, &bvr_count, &bvr_list)); // printf("bvr_count=%d \n", bvr_count); // if (bvr_count == 0) { // errBuff.append("不存在EBOM请检查\n"); // } // ITKCALL(BOM_set_window_top_line_bvr(ebom_window, bvr_list[0], &bom_line)); //顶层bom获取 // printf("顶层bom获取\n"); // EBomBean topBean; // topBean.eRev = matnrTop; // topBean.eBomline = bom_line; // //遍历EBOM获取P物料 // vector beans; // recyReadEBom(bom_line, topBean, beans, len, matnrTop, errBuff); // printf("read end %d\n", beans.size()); // // BOM_close_window(ebom_window); // //搭建BOM // // printf("buff %s==>\n", errBuff.c_str()); // tag_t topPrev = NULLTAG; // if (errBuff.empty()) { // map map; // // 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]); // printf("url ==> %s \n", url.c_str()); // if (ConnServer(url_vals[3], url_vals[4], (char*)url.c_str()) == -1) // { // printf("提示:中间数据表访问失败\n"); // ifail = 1; // } // for (int t = 0; t < beans.size(); t++) { // replaceBom(beans[t], map, len, dcproxy, topPrev); // } // DisConnServer(); // } // {//多个直接复制 // map::iterator it2; // for (it2 = wlbmMap.begin(); it2 != wlbmMap.end(); it2++) { // string ss = it2->first; // tag_t eMantr = wlbmMap[ss].eMantr; // if (keyNum.compare(ss) == 0) { // continue; // } // char* newid = NULL; // logical isModified = FALSE; // tag_t item_type_tag, newRev, newItem; // TCTYPE_ask_type("Item", &item_type_tag); // ITKCALL(USER_new_item_id(NULLTAG, item_type_tag, &isModified, &newid)); // /*ITKCALL(NR_next_value("MEProcess", "item_id", NULLTAG, "", "", "", // NULLTAG, "", "", &next_id));*/ // printf("next_id==>%s\n", newid); // ITKCALL(ITEM_copy_item(eMantr, newid, NULL, &newItem, &newRev)); // //ITKCALL(AOM_set_value_string(newRev, "zt2_PMaterial", "PBOM")); // char* matnrNo; // AOM_ask_value_string(eMantr, "zt2_MaterialNo", &matnrNo); // AOM_lock(newRev); // AOM_set_value_string(newRev, "zt2_ifpbom", "P"); // AOM_set_value_string(newRev, "zt2_MaterialNo", matnrNo); // AOM_save(newRev); // AOM_unlock(newRev); // copyBomLine(topPrev, newRev); // } // } // } // else { // //更新逻辑 遍历Ebom 不带P的和带P的 // tag_t matnrTop = NULLTAG; // tag_t pBomTop = NULLTAG; // map::iterator it; // //第一个创建,其他复制就行 // string keyNum = ""; // for (it = wlbmMap.begin(); it != wlbmMap.end(); it++) { // string s = it->first; // keyNum = s; // //printf("newRev===>%s\n", tagBean.revId.c_str()); // E2PBean tagBean = wlbmMap[s]; // matnrTop = tagBean.eMantr; // pBomTop = tagBean.pMantr; // //判断版本视图是否发布,如果发布了,升版 // int structs = 0, statusNum=0; // tag_t *structure_revisions,* release_status_list; // AOM_ask_value_tags(pBomTop, "structure_revisions", &structs, &structure_revisions); // if (structs > 0) { // AOM_ask_value_tags(structure_revisions[0], "release_status_list", &statusNum, &release_status_list); // if (statusNum > 0) { // tag_t *mantrsAs, dsuser; // int revNum; // ITEM_copy_rev(pBomTop, NULL, &pBomTop); // AOM_ask_value_tags(matnrTop, "TC_Is_Represented_By", &num, &mantrsAs); // AOM_ask_value_tag(mantrsAs[0], "owning_user", &dsuser); // tag_t defGroup; // ITKCALL(AOM_ask_value_tag(dsuser, "default_group", &defGroup)); // ITKCALL(AOM_set_ownership(pBomTop, dsuser, defGroup)); // if (num > 0) { // AOM_ask_value_tags(pBomTop, "structure_revisions", &revNum, &structure_revisions); // if (revNum > 0) { // ITKCALL(AOM_set_ownership(structure_revisions[0], dsuser, defGroup)); // } // } // // } // } // break; // } // (BOM_create_window(&ebom_window)); // (ITEM_rev_list_bom_view_revs(matnrTop, &bvr_count, &bvr_list)); // printf("bvr_count=%d \n", bvr_count); // if (bvr_count == 0) { // errBuff.append("不存在EBOM请检查\n"); // } // ITKCALL(BOM_set_window_top_line_bvr(ebom_window, bvr_list[0], &bom_line)); //顶层bom获取 // printf("顶层bom获取\n"); // EBomUpBean upBean; // upBean.bomline = bom_line; // updatePbomCycle(bom_line, errBuff,len, upBean); // tag_t ebom_window2, * bvr_list2, bom_line2; // int bvr_count2 = 0; // char* revIdP; // (BOM_create_window(&ebom_window2)); // (ITEM_rev_list_bom_view_revs(pBomTop, &bvr_count2, &bvr_list2)); // AOM_ask_value_string(pBomTop,"item_revision_id",&revIdP); // printf("bvr_count=%d revIdP==>%s \n", bvr_count2, revIdP); // if (bvr_count2 == 0) { // errBuff.append("不存在EBOM请检查\n"); // } // ITKCALL(BOM_set_window_top_line_bvr(ebom_window2, bvr_list2[0], &bom_line2)); //顶层bom获取 // // 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]); // printf("url ==> %s \n", url.c_str()); // if (ConnServer(url_vals[3], url_vals[4], (char*)url.c_str()) == -1) // { // printf("提示:中间数据表访问失败\n"); // ifail = 1; // } // startUpdate(upBean, bom_line2, len, dcproxy); // DisConnServer(); // // BOM_save_window(ebom_window2); // BOM_close_window(ebom_window2); // // BOM_close_window(ebom_window); // printf("keyNum===>%s\n", keyNum.c_str()); // map::iterator it2; // for (it2 = wlbmMap.begin(); it2 != wlbmMap.end(); it2++) { // string ss = it2->first; // E2PBean tagBean = wlbmMap[ss]; // printf("ss===>%s\n", ss.c_str()); // if (keyNum.compare(ss) == 0) { // continue; // } // tag_t newRev = tagBean.pMantr; // printf("newRev===>%s\n", tagBean.revId.c_str()); // int structs = 0, statusNum = 0; // tag_t* structure_revisions, * release_status_list; // AOM_ask_value_tags(newRev, "structure_revisions", &structs, &structure_revisions); // if (structs > 0) { // AOM_ask_value_tags(structure_revisions[0], "release_status_list", &statusNum, &release_status_list); // if (statusNum > 0) { // int revNum = 0; // tag_t *mantrsAs, dsuser; // ITKCALL(ITEM_copy_rev(newRev, NULL, &newRev)); // AOM_ask_value_tags(matnrTop, "TC_Is_Represented_By", &num, &mantrsAs); // AOM_ask_value_tag(mantrs[0], "owning_user", &dsuser); // tag_t defGroup; // ITKCALL(AOM_ask_value_tag(dsuser, "default_group", &defGroup)); // ITKCALL(AOM_set_ownership(newRev, dsuser, defGroup)); // if (num > 0) { // AOM_ask_value_tags(newRev, "structure_revisions", &revNum, &structure_revisions); // if (revNum > 0) { // ITKCALL(AOM_set_ownership(structure_revisions[0], dsuser, defGroup)); // } // } // } // } // copyBomLine(pBomTop, newRev); // } // } // // POM_AM__set_application_bypass(false); // } // } // string buff = errBuff; // if (buff.empty()) { // buff = "succ"; // } // printf("buff===>%s\n", buff.c_str()); // /**((char**)returnValue) = (char*)MEM_alloc((strlen(buff.c_str()) + 1) * sizeof(char)); // tc_strcpy(*((char**)returnValue), buff.c_str());*/ // return; //}