|
|
|
|
|
//#include <string>
|
|
|
//#include <tc\tc_macros.h>
|
|
|
//#include <bom/bom.h>
|
|
|
#include "SendSap.h"
|
|
|
|
|
|
|
|
|
boolean vecContains(vector<string> vec, string str) {
|
|
|
for (int i = 0; i < vec.size(); i++) {
|
|
|
if (tc_strcmp(vec[i].c_str(), str.c_str()) == 0) {
|
|
|
return true;
|
|
|
}
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
int getIcsId(char* codeRemark, char* property) {
|
|
|
tag_t ico = NULLTAG, *attributeList = NULL;
|
|
|
int cnt = 0, *attrIDs;
|
|
|
ITKCALL(ICS_class_ask_attributes(codeRemark, &cnt, &attributeList, &attrIDs));
|
|
|
for (int i = 0; i < cnt; i++) {
|
|
|
char *unctName = NULL, *shortName = NULL, *unctUnit = NULL;
|
|
|
int unctFormat = 0;
|
|
|
ITKCALL(ICS_describe_unct(attrIDs[i], &unctName, &shortName, &unctUnit, &unctFormat));
|
|
|
if (tc_strcmp(unctName, property) == 0) {
|
|
|
return attrIDs[i];
|
|
|
}
|
|
|
}
|
|
|
return -1;
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
* 根据分类属性查询分类对象
|
|
|
* SAPUtil.getICSComp(String codeRemark, int icsId, String value, TCSession session)
|
|
|
*/
|
|
|
tag_t getICSComp(char* codeRemark, int unct, char* query) {
|
|
|
if (unct == -1) {
|
|
|
return NULLTAG;
|
|
|
}
|
|
|
tag_t ico = NULLTAG, *results = NULL;
|
|
|
string qstr = "=";
|
|
|
qstr.append(query);
|
|
|
char* queries = (char*)qstr.c_str();
|
|
|
int cnt = 0;
|
|
|
ITKCALL(ICS_find_class(codeRemark, &ico));
|
|
|
ITKCALL(ICS_search_instances(ico, NULLTAG, 1, &unct, &queries, &cnt, &results));
|
|
|
printf("ICS_search_instances:%d\n", cnt);
|
|
|
if (cnt > 0) {
|
|
|
tag_t wso = NULLTAG;
|
|
|
ITKCALL(ICS_ask_classified_wsobject(results[0], &wso));
|
|
|
return wso;
|
|
|
}
|
|
|
return NULLTAG;
|
|
|
}
|
|
|
/*
|
|
|
* 根据材料标记获得物料
|
|
|
* SAPUtil.getClassPart
|
|
|
*/
|
|
|
tag_t getClassPart(tag_t rev, char* codeRemark, int unct, map<string, tag_t>& by_materials) {
|
|
|
char* zt2_MaterialMark = NULL;
|
|
|
ITKCALL(AOM_ask_value_string(rev, "zt2_MaterialMark", &zt2_MaterialMark));
|
|
|
if (!zt2_MaterialMark || tc_strlen(zt2_MaterialMark) == 0) {
|
|
|
return NULLTAG;
|
|
|
}
|
|
|
if (by_materials.count(zt2_MaterialMark) > 0) {
|
|
|
tag_t comp = by_materials[zt2_MaterialMark];
|
|
|
if (comp == NULLTAG) {
|
|
|
tag_t *contexts2 = NULL;
|
|
|
int num = 0;
|
|
|
ITKCALL(AOM_ask_value_tags(rev, "ZT2_Material", &num, &contexts2));
|
|
|
if (num > 0)
|
|
|
return contexts2[0];
|
|
|
log("查询不到[材料标记]为[%s]的原材料\n", zt2_MaterialMark);
|
|
|
return NULLTAG;
|
|
|
}
|
|
|
return by_materials[zt2_MaterialMark];
|
|
|
}
|
|
|
else {
|
|
|
tag_t comp = getICSComp(codeRemark, unct, zt2_MaterialMark);
|
|
|
if (comp == NULLTAG) {
|
|
|
tag_t *contexts2 = NULL;
|
|
|
int num = 0;
|
|
|
ITKCALL(AOM_ask_value_tags(rev, "ZT2_Material", &num, &contexts2));
|
|
|
if (num > 0)
|
|
|
return contexts2[0];
|
|
|
log("查询不到[材料标记]为[%s]的原材料\n", zt2_MaterialMark);
|
|
|
return NULLTAG;
|
|
|
}
|
|
|
else {
|
|
|
by_materials[zt2_MaterialMark] = comp;
|
|
|
return comp;
|
|
|
}
|
|
|
}
|
|
|
return NULLTAG;
|
|
|
}
|
|
|
|
|
|
tag_t getClassPartDB(tag_t rev, char* groupName, map<string, tag_t>& by_materials, map<string, string>& materials, string& errMsg) {
|
|
|
char* zt2_MaterialMark = NULL;
|
|
|
ITKCALL(AOM_ask_value_string(rev, "zt2_MaterialMark", &zt2_MaterialMark));
|
|
|
if (!zt2_MaterialMark || tc_strlen(zt2_MaterialMark) == 0) {
|
|
|
return NULLTAG;
|
|
|
}
|
|
|
string sql = "select materialno,materialutilization,materialunit FROM \"CHINT_";
|
|
|
if (tc_strcmp(groupName, "M046") == 0) {
|
|
|
sql.append("M043");
|
|
|
}
|
|
|
else {
|
|
|
sql.append(groupName);
|
|
|
}
|
|
|
sql.append("_MATERIAL\" where materialmark='").append(zt2_MaterialMark).append("'");
|
|
|
int outputColumn1 = 0, outputValueCount1 = 0;
|
|
|
char*** outputValue1 = NULL;
|
|
|
log("search3 ===> %s\n", sql.c_str());
|
|
|
QuerySQLNoInputParam((char*)sql.c_str(), &outputColumn1, &outputValueCount1, &outputValue1);
|
|
|
if (outputValueCount1 == 0) {
|
|
|
log("查询不到[材料标记]为[%s]的原材料\n", zt2_MaterialMark);
|
|
|
errMsg.append("查询不到[材料标记]为[").append(zt2_MaterialMark).append("]的原材料\n");
|
|
|
return NULLTAG;
|
|
|
}
|
|
|
materials[zt2_MaterialMark] = outputValue1[0][1];
|
|
|
tag_t find = NULLTAG;
|
|
|
ITKCALL(ITEM_find_item(outputValue1[0][0], &find));
|
|
|
if (find == NULLTAG) {
|
|
|
log("tc中查询不到[ID]为[%s]的原材料\n", zt2_MaterialMark);
|
|
|
errMsg.append("tc中查询不到[ID]为[").append(zt2_MaterialMark).append("]的原材料\n");
|
|
|
return NULLTAG;
|
|
|
}
|
|
|
by_materials[zt2_MaterialMark] = find;
|
|
|
return find;
|
|
|
}
|
|
|
//物料信息排序,zt2_MaterialNo为3开头的在前
|
|
|
void getSort(vector<char*>& materials) {
|
|
|
if (materials.size() < 2)
|
|
|
return;
|
|
|
vector<int> flowInt;
|
|
|
map<int, vector<char*>> flows;
|
|
|
for (char* b : materials) {
|
|
|
int size = 1;
|
|
|
if (b && tc_strlen(b) > 0 && b[0] == '3') {
|
|
|
size = 0;
|
|
|
}
|
|
|
if (flows.count(size) > 0) {
|
|
|
flows[size].push_back(b);
|
|
|
}
|
|
|
else {
|
|
|
vector<char*> flow;
|
|
|
flow.push_back(b);
|
|
|
flowInt.push_back(size);
|
|
|
flows[size] = flow;
|
|
|
}
|
|
|
}
|
|
|
materials.clear();
|
|
|
sort(flowInt.rbegin(), flowInt.rend());
|
|
|
for (vector<int>::iterator it = flowInt.begin(); it != flowInt.end(); it++) {
|
|
|
cout << *it << " ";
|
|
|
if (flows.count(*it) > 0) {
|
|
|
vector<char*> beans = flows[*it];
|
|
|
for (int x = 0; x < beans.size(); x++) {
|
|
|
materials.push_back(beans[x]);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
/*
|
|
|
* 获得Part Revision
|
|
|
* SAPUtil.getSAPPart(TCComponentBOMLine line, TCSession session, String groupName,
|
|
|
StringBuffer buff)
|
|
|
*/
|
|
|
tag_t getSAPPart(tag_t rev, char* groupName) {
|
|
|
char *type = NULL;
|
|
|
ITKCALL(WSOM_ask_object_type2(rev, &type));
|
|
|
if (tc_strcmp(type, "Part Revision") == 0) {
|
|
|
return rev;
|
|
|
}
|
|
|
int num = 0;
|
|
|
tag_t *comps = NULL;
|
|
|
vector<tag_t> parts;
|
|
|
ITKCALL(AOM_ask_value_tags(rev, "representation_for", &num, &comps));
|
|
|
for (int i = 0; i < num; i++) {
|
|
|
char *type2 = NULL;
|
|
|
ITKCALL(WSOM_ask_object_type2(comps[i], &type2));
|
|
|
if (tc_strcmp(type, "Part Revision") == 0 && isTcm2(comps[i])) {
|
|
|
parts.push_back(comps[i]);
|
|
|
}
|
|
|
}
|
|
|
if (parts.size() == 1) {
|
|
|
return parts[0];
|
|
|
}
|
|
|
else if (parts.size() > 1 && tc_strcmp(groupName, "M034") == 0) {
|
|
|
return NULLTAG;
|
|
|
}
|
|
|
|
|
|
char* spec = NULL;
|
|
|
ITKCALL(AOM_ask_value_string(rev, "zt2_Specifications", &spec));
|
|
|
for (int i = 0; i < parts.size(); i++) {
|
|
|
char* zt2_Specifications = NULL;
|
|
|
ITKCALL(AOM_ask_value_string(parts[i], "zt2_Specifications", &zt2_Specifications));
|
|
|
if (tc_strcmp(zt2_Specifications, spec) == 0) {
|
|
|
return parts[i];
|
|
|
}
|
|
|
}
|
|
|
return NULLTAG;
|
|
|
}
|
|
|
/*
|
|
|
* 获得Part Revision
|
|
|
* SAPUtil.getSAPPart(TCComponentBOMLine line, TCSession session, String groupName,
|
|
|
StringBuffer buff)
|
|
|
*/
|
|
|
tag_t getBOMPart(tag_t line, char* groupName) {
|
|
|
tag_t rev = NULLTAG;
|
|
|
ITKCALL(AOM_ask_value_tag(line, "bl_line_object", &rev));
|
|
|
char *type = NULL;
|
|
|
ITKCALL(WSOM_ask_object_type2(rev, &type));
|
|
|
//log("getBOMPart1==>%s", type);
|
|
|
if (tc_strcmp(type, "Part Revision") == 0) {
|
|
|
return rev;
|
|
|
}
|
|
|
int num = 0;
|
|
|
tag_t *comps = NULL;
|
|
|
vector<tag_t> parts;
|
|
|
ITKCALL(AOM_ask_value_tags(rev, "representation_for", &num, &comps));
|
|
|
for (int i = 0; i < num; i++) {
|
|
|
char *type2 = NULL;
|
|
|
ITKCALL(WSOM_ask_object_type2(comps[i], &type2));
|
|
|
//log("getBOMPart2==>%s", type2);
|
|
|
if (tc_strcmp(type2, "Part Revision") == 0 && isTcm2(comps[i])) {
|
|
|
parts.push_back(comps[i]);
|
|
|
}
|
|
|
}
|
|
|
//log("getBOMPart3==>%zd", parts.size());
|
|
|
if (parts.size() == 1) {
|
|
|
return parts[0];
|
|
|
}
|
|
|
else if (parts.size() > 1 && tc_strcmp(groupName, "M034") == 0) {
|
|
|
return NULLTAG;
|
|
|
}
|
|
|
|
|
|
char* spec = NULL;
|
|
|
ITKCALL(AOM_UIF_ask_value(rev, "zt2_Specifications", &spec));
|
|
|
for (int i = 0; i < parts.size(); i++) {
|
|
|
char* zt2_Specifications = NULL;
|
|
|
ITKCALL(AOM_UIF_ask_value(parts[i], "zt2_Specifications", &zt2_Specifications));
|
|
|
if (tc_strcmp(zt2_Specifications, spec) == 0) {
|
|
|
return parts[i];
|
|
|
}
|
|
|
}
|
|
|
char* zt2_TYJNo = NULL, *item_id = NULL;
|
|
|
ITKCALL(AOM_UIF_ask_value(line, "ZT2_TYSpecifications", &zt2_TYJNo));
|
|
|
if (zt2_TYJNo && tc_strlen(zt2_TYJNo) > 0) {
|
|
|
tag_t query_tag = NULLTAG;
|
|
|
ITKCALL(QRY_find2("chint_query_material", &query_tag));
|
|
|
if (query_tag == NULL) {
|
|
|
return NULLTAG;
|
|
|
}
|
|
|
ITKCALL(AOM_UIF_ask_value(rev, "item_id", &item_id));
|
|
|
char *zt2_DrawingNo = NULL;
|
|
|
string qs = "*";
|
|
|
ITKCALL(AOM_UIF_ask_value(rev, "zt2_DrawingNo", &zt2_DrawingNo));
|
|
|
if (zt2_DrawingNo && tc_strlen(zt2_DrawingNo) > 0 && tc_strcmp(item_id, zt2_DrawingNo) != 0) {
|
|
|
qs.append(zt2_DrawingNo);
|
|
|
}
|
|
|
else {
|
|
|
qs.append(item_id);
|
|
|
}
|
|
|
qs.append("*").append(zt2_TYJNo).append("*");
|
|
|
char **qkey = NULL, **qvalue = NULL, *qprop = (char*)qs.c_str();
|
|
|
int num_found = 0;
|
|
|
tag_t *qresult = NULL;
|
|
|
qkey = (char **)MEM_alloc(1 * sizeof(char*));
|
|
|
qvalue = (char **)MEM_alloc(1 * sizeof(char*));
|
|
|
qkey[0] = (char *)MEM_alloc((tc_strlen("描述") + 1)*sizeof(char));
|
|
|
qvalue[0] = (char *)MEM_alloc((tc_strlen(qprop) + 1)*sizeof(char));
|
|
|
tc_strcpy(qkey[0], "描述");
|
|
|
tc_strcpy(qvalue[0], qprop);
|
|
|
ITKCALL(QRY_execute(query_tag, 1, qkey, qvalue, &num_found, &qresult));
|
|
|
log("chint_query_material 描述:%s==>%d", qprop, num_found);
|
|
|
map<string, tag_t> map_revs;
|
|
|
vector<char*> materials;
|
|
|
for (int i = 0; i < num_found; i++) {
|
|
|
if (isTcm2(qresult[i])) {
|
|
|
char *zt2_MaterialNo = NULL;
|
|
|
ITKCALL(AOM_UIF_ask_value(qresult[i], "zt2_MaterialNo", &zt2_MaterialNo));
|
|
|
map_revs[zt2_MaterialNo] = qresult[i];
|
|
|
materials.push_back(zt2_MaterialNo);
|
|
|
}
|
|
|
}
|
|
|
if (materials.size() > 0) {
|
|
|
getSort(materials);
|
|
|
for (int i = 0; i < materials.size(); i++) {
|
|
|
string sql = "select FeatureList from CcemVW_GoodsFeature where GoodsCode = '";
|
|
|
sql.append(materials[i]).append("'");
|
|
|
int outputColumn1 = 0, outputValueCount1 = 0;
|
|
|
char*** outputValue1 = NULL;
|
|
|
QuerySQLNoInputParam((char*)sql.c_str(), &outputColumn1, &outputValueCount1, &outputValue1);
|
|
|
if (outputValueCount1 > 0) {
|
|
|
vector<string> vec;
|
|
|
Split(outputValue1[0][0], ",", vec);
|
|
|
for (int j = 0; j < vec.size(); j++) {
|
|
|
string s = vec[j].substr(0, 5);
|
|
|
if (tc_strcmp(s.c_str(), "F064:") == 0) {
|
|
|
string temp = s.substr(5, s.size() - 5);
|
|
|
if (map_revs.count(temp) > 0) {
|
|
|
return map_revs[temp];
|
|
|
}
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return NULLTAG;
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
* 获得图纸对象
|
|
|
* SAPUtil.getZYDesign(TCComponentItemRevision rev)
|
|
|
*/
|
|
|
tag_t getZYDesign(tag_t rev) {
|
|
|
char *type = NULL;
|
|
|
ITKCALL(WSOM_ask_object_type2(rev, &type));
|
|
|
if (tc_strcmp(type, "ZT2_Design3DRevision") == 0) {
|
|
|
return rev;
|
|
|
}
|
|
|
else if (tc_strcmp(type, "Part Revision") == 0) {
|
|
|
int num = 0;
|
|
|
tag_t *comps = NULL;
|
|
|
ITKCALL(AOM_ask_value_tags(rev, "TC_Is_Represented_By", &num, &comps));
|
|
|
if (num > 0) {
|
|
|
return comps[0];
|
|
|
}
|
|
|
}
|
|
|
return NULLTAG;
|
|
|
}
|
|
|
|
|
|
string getICSProperty(tag_t comp, char* codeRemark, char* prop) {
|
|
|
tag_t ico = NULLTAG, *results = NULL;
|
|
|
ITKCALL(ICS_find_class(codeRemark, &ico));
|
|
|
ITKCALL(ICS_ask_classification_object(comp, &ico));
|
|
|
if (ico == NULLTAG) {
|
|
|
return "";
|
|
|
}
|
|
|
int n_attrs = 0;
|
|
|
char** attr_names = NULL, ** attr_vals = NULL;
|
|
|
ITKCALL(ICS_ask_attributes_of_classification_obj(ico, &n_attrs, &attr_names, &attr_vals));
|
|
|
for (int i = 0; i < n_attrs; i++) {
|
|
|
if (tc_strcmp(attr_names[i], prop) == 0) {
|
|
|
return attr_vals[i];
|
|
|
}
|
|
|
}
|
|
|
return "";
|
|
|
}
|
|
|
|
|
|
char* getZYMENGE(double dw, tag_t material, char* codeMark) {
|
|
|
//double dw = stod(zt2_zt2_DesignWeight);
|
|
|
double lyl = -1, res = 0;
|
|
|
string lylStr = getICSProperty(material, codeMark, "材料利用率");
|
|
|
if (lylStr.size() == 0) {
|
|
|
lyl = 0.85;
|
|
|
}
|
|
|
else {
|
|
|
lyl = stod(lylStr);
|
|
|
}
|
|
|
if (lyl > 0) {
|
|
|
res = dw / lyl;
|
|
|
}
|
|
|
char buffer[16];
|
|
|
sprintf(buffer, "%.3f", res);
|
|
|
log("MENGE1:%f==%s", res, buffer);
|
|
|
return buffer;
|
|
|
}
|
|
|
|
|
|
char* getZYSAPMENGE(tag_t design, tag_t part, tag_t line, boolean isBottom, char* codeMark, string& errMsg) {
|
|
|
//log("getZYSAPMENGE");
|
|
|
char *os = NULL;
|
|
|
ITKCALL(AOM_UIF_ask_value(line, "object_string", &os));
|
|
|
if (isBottom) {
|
|
|
char* ZT2_TYSpecifications = NULL, *ZT2_TYWeight = NULL;
|
|
|
ITKCALL(AOM_UIF_ask_value(line, "ZT2_TYSpecifications", &ZT2_TYSpecifications));
|
|
|
if (ZT2_TYSpecifications && tc_strlen(ZT2_TYSpecifications) > 0) {
|
|
|
ITKCALL(AOM_UIF_ask_value(line, "ZT2_TYWeight", &ZT2_TYWeight));
|
|
|
if (!ZT2_TYWeight || tc_strlen(ZT2_TYWeight) == 0) {
|
|
|
//log("getZYSAPMENGE1");
|
|
|
errMsg.append(os).append("未填写通用件重量;");
|
|
|
return "0";
|
|
|
}
|
|
|
else {
|
|
|
//log("getZYSAPMENGE2");
|
|
|
return getZYMENGE(stod(ZT2_TYWeight), part, codeMark);
|
|
|
}
|
|
|
}
|
|
|
else {// 非通用件
|
|
|
double zt2_DesignWeight = 0;
|
|
|
ITKCALL(AOM_ask_value_double(design, "zt2_DesignWeight", &zt2_DesignWeight));
|
|
|
char* ss = getZYMENGE(zt2_DesignWeight, part, codeMark);
|
|
|
if (tc_strlen(ss) == 0) {
|
|
|
//log("getZYSAPMENGE3");
|
|
|
errMsg.append(os).append("未填写重量(zt2_DesignWeight);");
|
|
|
return "0";
|
|
|
}
|
|
|
//log("getZYSAPMENGE4");
|
|
|
return ss;
|
|
|
}
|
|
|
}
|
|
|
else {
|
|
|
char* bl_quantity = NULL;
|
|
|
ITKCALL(AOM_UIF_ask_value(line, "bl_quantity", &bl_quantity));
|
|
|
if (!bl_quantity || tc_strlen(bl_quantity) == 0) {
|
|
|
//log("getZYSAPMENGE5");
|
|
|
errMsg.append(os).append("数量未填写(bl_quantity)");
|
|
|
return "0";
|
|
|
}
|
|
|
//log("getZYSAPMENGE6");
|
|
|
double dw = stod(bl_quantity);
|
|
|
char buffer[16];
|
|
|
sprintf(buffer, "%.3f", dw);
|
|
|
log("MENGE2:%f==%s", dw, buffer);
|
|
|
return buffer;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
char* getZYSAPMENGE2(string lylStr, tag_t design, tag_t line, boolean isBottom, string& errMsg) {
|
|
|
log("lylStr:%s", lylStr.c_str());
|
|
|
double lyl = -1;
|
|
|
if (lylStr.size() > 0) {
|
|
|
lyl = stod(lylStr.c_str());
|
|
|
}
|
|
|
else {
|
|
|
lyl = 0.85;
|
|
|
}
|
|
|
if (isBottom) {
|
|
|
char* ZT2_TYSpecifications = NULL, *ZT2_TYWeight = NULL;
|
|
|
ITKCALL(AOM_UIF_ask_value(line, "ZT2_TYSpecifications", &ZT2_TYSpecifications));
|
|
|
if (ZT2_TYSpecifications && tc_strlen(ZT2_TYSpecifications) > 0) {
|
|
|
ITKCALL(AOM_UIF_ask_value(line, "ZT2_TYWeight", &ZT2_TYWeight));
|
|
|
if (!ZT2_TYWeight || tc_strlen(ZT2_TYWeight) == 0) {
|
|
|
return "0";
|
|
|
}
|
|
|
}
|
|
|
else {// 非通用件
|
|
|
ITKCALL(AOM_UIF_ask_value(design, "zt2_DesignWeight", &ZT2_TYWeight));
|
|
|
if (!ZT2_TYWeight || tc_strlen(ZT2_TYWeight) == 0) {
|
|
|
char *os = NULL;
|
|
|
ITKCALL(AOM_ask_value_string(design, "object_string", &os));
|
|
|
errMsg.append(os).append("设计重量为空\n");
|
|
|
return "0";
|
|
|
}
|
|
|
}
|
|
|
double dw = stod(ZT2_TYWeight) / lyl;
|
|
|
char buffer[16];
|
|
|
sprintf(buffer, "%.3f", dw);
|
|
|
log("MENGE3:%f==%s", dw, buffer);
|
|
|
return buffer;
|
|
|
}
|
|
|
else {
|
|
|
char* bl_quantity = NULL;
|
|
|
ITKCALL(AOM_UIF_ask_value(line, "bl_quantity", &bl_quantity));
|
|
|
if (!bl_quantity || tc_strlen(bl_quantity) == 0) {
|
|
|
return "0";
|
|
|
}
|
|
|
double dw = stod(bl_quantity);
|
|
|
char buffer[16];
|
|
|
sprintf(buffer, "%.3f", dw);
|
|
|
log("MENGE4:%f==%s", dw, buffer);
|
|
|
return buffer;
|
|
|
}
|
|
|
}
|
|
|
/*
|
|
|
* 中压通用BOM传递SAP 新
|
|
|
* SAPUtil.recurZYGGSAPNoProc
|
|
|
*/
|
|
|
void recurZYGGSAPNoProc(tag_t rev, tag_t partRev, char *groupName, tag_t line, map<string, tag_t>& gy_meops, vector<tag_t>& needTCM_meops,
|
|
|
char* now, vector <_ns1__DT_USCOREPROCESSROUTE_USCORES4_USCOREREQ_LIST>& proclist, vector<string>& bomIsExist,
|
|
|
vector<_ns1__DT_USCOREBOM_USCORES4_USCOREREQ_LIST>& list, char* codeRemark, int unct, map<string, tag_t>& by_materials,
|
|
|
boolean isZT, string& errMsg, map<string, vector<string>>& inCcpMap, vector<string> ccpMaterialMap, vector<string> matr) {
|
|
|
char *line_os = NULL;
|
|
|
ITKCALL(AOM_ask_value_string(line, "object_string", &line_os));
|
|
|
log("recurZYGGSAPNoProc line:%s\n", line_os);
|
|
|
tag_t designRev = getZYDesign(rev);
|
|
|
tag_t meops = NULLTAG;
|
|
|
if (designRev != NULLTAG) {
|
|
|
meops = getProcessTag(designRev, groupName);
|
|
|
}
|
|
|
//log("1");
|
|
|
int bvr_count = 0;
|
|
|
tag_t *bvr_list = NULL;
|
|
|
ITKCALL(ITEM_rev_list_bom_view_revs(designRev, &bvr_count, &bvr_list));//designRev
|
|
|
boolean isLj = false; //判断是否零件
|
|
|
if (bvr_count == 0) {
|
|
|
isLj = true;
|
|
|
}
|
|
|
//tag_t partRev = getBOMPart(line, groupName);
|
|
|
if (partRev == NULLTAG) {
|
|
|
//rev = getSAPPart(designRev, groupName);
|
|
|
partRev = getBOMPart(line, groupName);
|
|
|
}
|
|
|
// 如果图纸下没有物料,则,判断此图纸版本上的属性zt2_Diagram属性,如果此属性为是
|
|
|
//(LOV值,真实值为Y),则不传递此图纸,物料检查也不要报错,跳过此图纸以及子件
|
|
|
char *type = NULL;
|
|
|
ITKCALL(WSOM_ask_object_type2(rev, &type));
|
|
|
if (tc_strcmp(type, "ZT2_Design3DRevision") == 0 && partRev == NULLTAG) {
|
|
|
char *zt2_Diagram = NULL;
|
|
|
ITKCALL(AOM_ask_value_string(rev, "zt2_Diagram", &zt2_Diagram));
|
|
|
if (tc_strcmp(zt2_Diagram, "Y") == 0 || tc_strcmp(zt2_Diagram, "是") == 0) {
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
int c_line_count = 0;
|
|
|
tag_t *c_line_tags = NULL;
|
|
|
ITKCALL(BOM_line_ask_all_child_lines(line, &c_line_count, &c_line_tags));
|
|
|
char *zt2_Source = NULL;
|
|
|
ITKCALL(AOM_UIF_ask_value(rev, "zt2_Source", &zt2_Source));
|
|
|
log("zt2_Source =>%s", zt2_Source);
|
|
|
boolean equals = (zt2_Source && (tc_strcmp(zt2_Source, "外购") == 0 || tc_strcmp(zt2_Source, "S2") == 0));
|
|
|
if (partRev != NULL) {
|
|
|
if (meops == NULL) {
|
|
|
if (!equals && c_line_count > 0) {
|
|
|
log("自制获取工艺路线");
|
|
|
//java中getMrProcess方法已注释只返回null,因此该逻辑已无实际意义
|
|
|
/*TCComponentMEProcessRevision mrProcess = getMrProcess(groupID, session);
|
|
|
TXTUtil.writeTXT(txtPath, "图纸[" + rev + "]工艺信息:" + mrProcess);
|
|
|
if (mrProcess != null) {
|
|
|
SAPUtil.readBopInfo1(mrProcess, partRev, session, now,
|
|
|
txtPath, proclist, groupName, gy_meops, needTCM_meops, false);
|
|
|
}*/
|
|
|
}
|
|
|
}
|
|
|
else {
|
|
|
readBopInfo1YH(meops, partRev, true, gy_meops, needTCM_meops, groupName, now, proclist);
|
|
|
}
|
|
|
}
|
|
|
if (equals) {
|
|
|
if (partRev == NULLTAG) {
|
|
|
return;
|
|
|
}
|
|
|
bvr_count = 0;
|
|
|
tag_t *part_bvr = NULL;
|
|
|
ITKCALL(ITEM_rev_list_bom_view_revs(partRev, &bvr_count, &part_bvr));
|
|
|
if (bvr_count > 0) {
|
|
|
tag_t part_window = NULLTAG, part_line = NULLTAG;
|
|
|
ITKCALL(BOM_create_window(&part_window));
|
|
|
ITKCALL(BOM_set_window_top_line(part_window, NULL, partRev, NULLTAG, &part_line));
|
|
|
int part_line_count = 0;
|
|
|
tag_t *part_line_tags = NULL;
|
|
|
ITKCALL(BOM_line_ask_all_child_lines(part_line, &part_line_count, &part_line_tags));
|
|
|
recurZYGGSAPNoProc(partRev, partRev, groupName, part_line, gy_meops, needTCM_meops, now, proclist, bomIsExist,
|
|
|
list, codeRemark, unct, by_materials, isZT, errMsg, inCcpMap, ccpMaterialMap, matr);
|
|
|
ITKCALL(BOM_close_window(part_window));
|
|
|
}
|
|
|
return;
|
|
|
}
|
|
|
if (partRev != NULLTAG) {
|
|
|
char *zt2_MaterialNo = NULL;
|
|
|
ITKCALL(AOM_ask_value_string(partRev, "zt2_MaterialNo", &zt2_MaterialNo));
|
|
|
if (vecContains(bomIsExist, zt2_MaterialNo)) {
|
|
|
log("%s已存在,过滤\n", zt2_MaterialNo);
|
|
|
return;
|
|
|
}
|
|
|
bomIsExist.push_back(zt2_MaterialNo);
|
|
|
}
|
|
|
if (c_line_count == 0) {
|
|
|
//char* zt2_Source = NULL;
|
|
|
//ITKCALL(AOM_UIF_ask_value(rev, "zt2_Source", &zt2_Source));
|
|
|
if (tc_strcmp(type, "ZT2_Design3DRevision") == 0 && (tc_strcmp(zt2_Source, "自制") == 0 || tc_strcmp(zt2_Source, "S1") == 0)
|
|
|
&& tc_strcmp(groupName, "M035") != 0) {
|
|
|
tag_t comp = NULLTAG;
|
|
|
map<string, string> materials;
|
|
|
if (matr.size() > 1 && tc_strcmp(matr[1].c_str(), "DB") == 0) {
|
|
|
comp = getClassPartDB(rev, groupName, by_materials, materials, errMsg);
|
|
|
}
|
|
|
else {
|
|
|
comp = getClassPart(rev, codeRemark, unct, by_materials);
|
|
|
}
|
|
|
char* os = NULL, *sortno = NULL;
|
|
|
boolean isHaveProcess = false;
|
|
|
if (meops != NULL) {
|
|
|
tag_t meop_window = NULLTAG, meop_line = NULLTAG;
|
|
|
ITKCALL(BOM_create_window(&meop_window));
|
|
|
ITKCALL(BOM_set_window_top_line(meop_window, NULL, meops, NULLTAG, &meop_line));
|
|
|
int meop_line_count = 0;
|
|
|
tag_t *meop_line_tags = NULL;
|
|
|
ITKCALL(BOM_line_ask_all_child_lines(meop_line, &meop_line_count, &meop_line_tags));
|
|
|
for (int i = 0; i < meop_line_count; i++) {
|
|
|
char *bl_sequence_no = NULL;
|
|
|
ITKCALL(AOM_UIF_ask_value(meop_line_tags[i], "bl_sequence_no", &bl_sequence_no));
|
|
|
if (tc_strcmp(bl_sequence_no, "10") == 0) {
|
|
|
tag_t rev2 = NULLTAG;
|
|
|
ITKCALL(AOM_ask_value_tag(meop_line_tags[i], "bl_line_object", &rev2));
|
|
|
ITKCALL(AOM_UIF_ask_value(rev2, "zt2_ClassificationCode", &sortno));
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
ITKCALL(BOM_close_window(meop_window));
|
|
|
isHaveProcess = true;
|
|
|
}
|
|
|
if (!sortno || tc_strlen(sortno) == 0) {
|
|
|
ITKCALL(AOM_ask_value_string(line, "ZT2_ClassificationNo", &sortno));
|
|
|
}
|
|
|
log("工序编码 =>%s", sortno);
|
|
|
char *zt2_MaterialNo = NULL, *zt2_WBSNo = NULL, *zt2_unit = NULL;
|
|
|
ITKCALL(AOM_UIF_ask_value(partRev, "zt2_MaterialNo", &zt2_MaterialNo));
|
|
|
log("zt2_MaterialNo ==>%s", zt2_MaterialNo);
|
|
|
ITKCALL(AOM_UIF_ask_value(partRev, "zt2_WBSNo", &zt2_WBSNo));
|
|
|
_ns1__DT_USCOREBOM_USCORES4_USCOREREQ_LIST_HEAD head;
|
|
|
_ns1__DT_USCOREBOM_USCORES4_USCOREREQ_LIST_ITEMS_ITEM* items_items =
|
|
|
new _ns1__DT_USCOREBOM_USCORES4_USCOREREQ_LIST_ITEMS_ITEM[1];
|
|
|
_ns1__DT_USCOREBOM_USCORES4_USCOREREQ_LIST_ITEMS items;
|
|
|
_ns1__DT_USCOREBOM_USCORES4_USCOREREQ_LIST_ITEMS_ITEM items_item;
|
|
|
tag_t item = NULLTAG;
|
|
|
ITKCALL(ITEM_ask_item_of_rev(partRev, &item));
|
|
|
ITKCALL(AOM_ask_value_string(item, "zt2_unit", &zt2_unit));
|
|
|
//char* unit = getUnti(zt2_unit);
|
|
|
log("str = [%s] \n", zt2_unit);
|
|
|
head.PSPNR = zt2_WBSNo;
|
|
|
head.MATNR = zt2_MaterialNo;
|
|
|
head.BMEIN = zt2_unit;
|
|
|
head.STLAN = (char*)"1";
|
|
|
head.STLAL = (char*)"1";
|
|
|
head.BMENG = (char*)"1";
|
|
|
head.WERKS = groupName;
|
|
|
head.DATUV = now;
|
|
|
char* parnetUid;
|
|
|
ITK__convert_tag_to_uid(partRev, &parnetUid);
|
|
|
head.STKTX = parnetUid;
|
|
|
inCcpMap[parnetUid] = ccpMaterialMap;
|
|
|
|
|
|
items_item.DATUV = now;
|
|
|
items_item.POSTP = (char*)"L";
|
|
|
items_item.POSNR = "0010";
|
|
|
if (!isLj) {
|
|
|
if (!isHaveProcess) {
|
|
|
errMsg.append(line_os).append("缺少工艺路线\n");
|
|
|
}
|
|
|
else if (!sortno || tc_strlen(sortno) == 0) {
|
|
|
char* mos = NULL;
|
|
|
ITKCALL(AOM_ask_value_string(meops, "object_string", &mos));
|
|
|
errMsg.append("请维护").append(mos).append("工艺路线的工序编码\n");
|
|
|
}
|
|
|
}
|
|
|
if (comp != NULLTAG) {
|
|
|
tag_t crev = NULLTAG;
|
|
|
ITKCALL(ITEM_ask_latest_rev(comp, &crev));
|
|
|
ITKCALL(AOM_ask_value_string(crev, "object_string", &os));
|
|
|
log("原材料 =>%s", os);
|
|
|
//tag_t item2;
|
|
|
char *zt2_MaterialNo2 = NULL, *zt2_unit2 = NULL;
|
|
|
ITKCALL(AOM_UIF_ask_value(crev, "zt2_MaterialNo", &zt2_MaterialNo2));
|
|
|
//ITKCALL(ITEM_ask_item_of_rev(comp, &item2));
|
|
|
ITKCALL(AOM_ask_value_string(comp, "zt2_unit", &zt2_unit2));
|
|
|
items_item.IDNRK = zt2_MaterialNo2;
|
|
|
//char* unit22 = getUnti(zt2_unit2);
|
|
|
items_item.MEINS = zt2_unit2;
|
|
|
char *menge = NULL;
|
|
|
menge = (char*)MEM_alloc((16 + 1) * sizeof(char));
|
|
|
if (matr.size() > 1 && tc_strcmp(matr[1].c_str(), "DB") == 0) {
|
|
|
char *zt2_MaterialMark = NULL;
|
|
|
ITKCALL(AOM_UIF_ask_value(rev, "zt2_MaterialMark", &zt2_MaterialMark));
|
|
|
if (materials.count(zt2_MaterialMark) > 0) {
|
|
|
tc_strcpy(menge, getZYSAPMENGE2(materials[zt2_MaterialMark], rev, line, true, errMsg));
|
|
|
}
|
|
|
else {
|
|
|
tc_strcpy(menge, getZYSAPMENGE(rev, crev, line, true, codeRemark, errMsg));
|
|
|
}
|
|
|
}
|
|
|
else {
|
|
|
tc_strcpy(menge, getZYSAPMENGE(rev, crev, line, true, codeRemark, errMsg));
|
|
|
}
|
|
|
items_item.MENGE = menge;
|
|
|
//MEM_free(menge);
|
|
|
}
|
|
|
else {
|
|
|
char* mos = NULL;
|
|
|
ITKCALL(AOM_ask_value_string(rev, "object_string", &mos));
|
|
|
errMsg.append(mos).append("未能匹配到对应的原材料\n");
|
|
|
items_item.IDNRK = "";
|
|
|
items_item.MEINS = "";
|
|
|
items_item.MENGE = "";
|
|
|
}
|
|
|
items_item.SORTF = sortno;
|
|
|
items_item.POTX1 = "";
|
|
|
|
|
|
items_items[0] = items_item;
|
|
|
items.ITEM = items_items;
|
|
|
items.__sizeITEM = 1;/**/
|
|
|
_ns1__DT_USCOREBOM_USCORES4_USCOREREQ_LIST list1;
|
|
|
list1.HEAD = head;
|
|
|
//log("list1.HEAD %s ", list1.HEAD.BMEIN);
|
|
|
list1.ITEMS = items;
|
|
|
log("list %zd ", list.size());
|
|
|
list.push_back(list1);
|
|
|
}
|
|
|
return;
|
|
|
}
|
|
|
if (partRev == NULLTAG) {
|
|
|
ITKCALL(AOM_ask_value_tag(line, "bl_line_object", &partRev));
|
|
|
}
|
|
|
|
|
|
char *os = NULL, *zt2_MaterialNo = NULL, *zt2_WBSNo = NULL, *zt2_unit = NULL;
|
|
|
ITKCALL(AOM_ask_value_string(partRev, "object_string", &os));
|
|
|
ITKCALL(AOM_UIF_ask_value(partRev, "zt2_MaterialNo", &zt2_MaterialNo));
|
|
|
log("zt2_MaterialNo ==>%s", zt2_MaterialNo);
|
|
|
ITKCALL(AOM_UIF_ask_value(partRev, "zt2_WBSNo", &zt2_WBSNo));
|
|
|
_ns1__DT_USCOREBOM_USCORES4_USCOREREQ_LIST_HEAD head;
|
|
|
tag_t item;
|
|
|
ITKCALL(ITEM_ask_item_of_rev(partRev, &item));
|
|
|
ITKCALL(AOM_ask_value_string(item, "zt2_unit", &zt2_unit));
|
|
|
char* unit = getUnti(zt2_unit);
|
|
|
log("str = [%s] \n", unit);
|
|
|
head.PSPNR = zt2_WBSNo;
|
|
|
head.MATNR = zt2_MaterialNo;
|
|
|
head.BMEIN = unit;
|
|
|
head.STLAN = (char*)"1";
|
|
|
head.STLAL = (char*)"1";
|
|
|
head.BMENG = (char*)"1";
|
|
|
head.WERKS = groupName;
|
|
|
head.DATUV = now;
|
|
|
//log("head.MENGE ===>%s", head.MENGE);
|
|
|
char* parnetUid;
|
|
|
ITK__convert_tag_to_uid(partRev, &parnetUid);
|
|
|
head.STKTX = parnetUid;
|
|
|
inCcpMap[parnetUid] = ccpMaterialMap;
|
|
|
|
|
|
_ns1__DT_USCOREBOM_USCORES4_USCOREREQ_LIST_ITEMS_ITEM* items_items =
|
|
|
new _ns1__DT_USCOREBOM_USCORES4_USCOREREQ_LIST_ITEMS_ITEM[c_line_count];
|
|
|
_ns1__DT_USCOREBOM_USCORES4_USCOREREQ_LIST_ITEMS items;
|
|
|
for (int i = 0; i < c_line_count; i++) {
|
|
|
string buff;
|
|
|
_ns1__DT_USCOREBOM_USCORES4_USCOREREQ_LIST_ITEMS_ITEM items_item;
|
|
|
tag_t c_line_tag = c_line_tags[i], rev2;
|
|
|
ITKCALL(AOM_ask_value_tag(c_line_tag, "bl_line_object", &rev2));
|
|
|
tag_t item2, part2 = getBOMPart(c_line_tag, groupName);
|
|
|
char *zt2_MaterialNo2 = NULL, *zt2_unit2 = NULL, *bl_sequence_no = NULL, *sortno = NULL, *ZT2_Remark = NULL, *zt2_SapState = NULL, *type2 = NULL;
|
|
|
// 如果图纸下没有物料,则,判断此图纸版本上的属性zt2_Diagram属性,如果此属性为是
|
|
|
//(LOV值,真实值为Y),则不传递此图纸,物料检查也不要报错,跳过此图纸以及子件
|
|
|
ITKCALL(WSOM_ask_object_type2(rev2, &type2));
|
|
|
if (tc_strcmp(type2, "ZT2_Design3DRevision") == 0) {
|
|
|
|
|
|
}
|
|
|
ITKCALL(AOM_UIF_ask_value(part2, "zt2_MaterialNo", &zt2_MaterialNo2));
|
|
|
ITKCALL(ITEM_ask_item_of_rev(rev2, &item2));
|
|
|
ITKCALL(AOM_ask_value_string(item2, "zt2_unit", &zt2_unit2));
|
|
|
ITKCALL(AOM_UIF_ask_value(c_line_tag, "bl_sequence_no", &bl_sequence_no));
|
|
|
ITKCALL(AOM_UIF_ask_value(c_line_tag, "ZT2_ClassificationNo", &sortno));
|
|
|
ITKCALL(AOM_UIF_ask_value(c_line_tag, "ZT2_Remark", &ZT2_Remark));
|
|
|
ITKCALL(AOM_UIF_ask_value(rev2, "zt2_SapState", &zt2_SapState));
|
|
|
|
|
|
char *menge = NULL;// = getZYSAPMENGE(rev2, NULLTAG, c_line_tag, false, codeRemark, errMsg);
|
|
|
menge = (char*)MEM_alloc((16 + 1) * sizeof(char));
|
|
|
tc_strcpy(menge, getZYSAPMENGE(rev2, NULLTAG, c_line_tag, false, codeRemark, buff));
|
|
|
log("menge ===>%s", menge);
|
|
|
char* unit22 = getUnti(zt2_unit2);
|
|
|
items_item.IDNRK = zt2_MaterialNo2;
|
|
|
//char* unit = unit22;
|
|
|
items_item.MEINS = unit22;
|
|
|
items_item.DATUV = now;
|
|
|
items_item.POSTP = (char*)"L";
|
|
|
items_item.POSNR = bl_sequence_no;
|
|
|
items_item.MENGE = menge;
|
|
|
items_item.SORTF = sortno;
|
|
|
items_item.POTX1 = ZT2_Remark;
|
|
|
log("items_item.MENGE ===>%s", items_item.MENGE);
|
|
|
//MEM_free(menge);
|
|
|
|
|
|
items_items[i] = items_item;
|
|
|
char* os2 = NULL;
|
|
|
ITKCALL(AOM_ask_value_string(rev2, "object_string", &os2));
|
|
|
string msg;
|
|
|
msg.append(os2).append("(父项:").append(os).append("):").append(buff);
|
|
|
log("buff ===>%s", buff.c_str());
|
|
|
if (buff.length() > 0 && tc_strstr(errMsg.c_str(), msg.c_str()) == NULL) {
|
|
|
errMsg.append("\\n").append(msg);
|
|
|
}
|
|
|
if ((tc_strcmp(zt2_SapState, "已传") == 0 || tc_strcmp(zt2_SapState, "2") == 0) && !isZT) {
|
|
|
continue;
|
|
|
}
|
|
|
recurZYGGSAPNoProc(rev2, part2, groupName, c_line_tag, gy_meops, needTCM_meops, now, proclist, bomIsExist,
|
|
|
list, codeRemark, unct, by_materials, isZT, errMsg, inCcpMap, ccpMaterialMap, matr);
|
|
|
}
|
|
|
items.ITEM = items_items;
|
|
|
items.__sizeITEM = c_line_count;
|
|
|
_ns1__DT_USCOREBOM_USCORES4_USCOREREQ_LIST list1;
|
|
|
list1.HEAD = head;
|
|
|
log("list1.HEAD %s ", list1.HEAD.BMEIN);
|
|
|
list1.ITEMS = items;
|
|
|
list.push_back(list1);
|
|
|
}
|
|
|
/*
|
|
|
* 产成品BOM传递
|
|
|
* SAPZYGG2Operation
|
|
|
*/
|
|
|
void SAPZYGG2(vector<tag_t> ccpVector, char* projectNo, char* groupName, char* wbs,
|
|
|
char* now, string& errMsgBuf, char*code, char* transfer, char* userName, char* projectName) {
|
|
|
log("************** SAPZYGG2 **************");
|
|
|
int pref_cnt = 0;
|
|
|
char **pref = NULL;
|
|
|
string codeRemark = "ICM0801";
|
|
|
vector<string> matr;
|
|
|
ITKCALL(PREF_ask_char_values("CHINT_ORG_TechnologyClassification", &pref_cnt, &pref));
|
|
|
for (int i = 0; i < pref_cnt; i++) {
|
|
|
vector<string> v1, v2;
|
|
|
Split(pref[i], ":", v1);
|
|
|
if (tc_strcmp(v1[0].c_str(), groupName) != 0) {
|
|
|
continue;
|
|
|
}
|
|
|
Split(v1[1], ";", v2);
|
|
|
if (v2.size() == 4) {
|
|
|
codeRemark = v2[2];
|
|
|
Split(v2[2], "\\", matr);
|
|
|
}
|
|
|
else if (v2.size() > 2) {
|
|
|
codeRemark = v2[2];
|
|
|
}
|
|
|
}
|
|
|
//记录是否有重复的出厂编号
|
|
|
vector<tag_t> isCheck_FactoryNos;
|
|
|
//记录产成品 对应的 电气BOM集合
|
|
|
map<tag_t, vector<tag_t>> cPart_schemes;
|
|
|
map<tag_t, vector<_ns1__DT_USCOREBOM_USCORES4_USCOREREQ_LIST>> mapList;
|
|
|
map<string, vector<string>> inCcpMap;//记录单元对应的产成品物料编码
|
|
|
string sendMsg;
|
|
|
for (int len = 0; len < ccpVector.size(); len++) {
|
|
|
vector<tag_t> elcBoms;
|
|
|
tag_t rev = ccpVector[len], *factoryNos;
|
|
|
char* revUid;
|
|
|
ITK__convert_tag_to_uid(rev, &revUid);
|
|
|
log("产成品UID:%s", revUid);
|
|
|
ITKCALL(AOM_refresh(rev, FALSE));
|
|
|
int num = 0;
|
|
|
ITKCALL(AOM_ask_value_tags(rev, "ZT2_FactoryNumber", &num, &factoryNos));
|
|
|
log("出厂编号数量 num :%d\n", num);
|
|
|
char *zt2_MaterialNo = NULL;
|
|
|
ITKCALL(AOM_ask_value_string(rev, "zt2_MaterialNo", &zt2_MaterialNo));
|
|
|
|
|
|
vector<_ns1__DT_USCOREFACTORY_USCORENUMBER_USCOREREQ_ITEMS_ITEM> list_Factorys;
|
|
|
getFactoryNoList(projectNo, groupName, wbs, factoryNos, num, rev, list_Factorys);
|
|
|
//传递出厂编号的记录日志信息
|
|
|
log("出厂编号数量:%zd", list_Factorys.size());
|
|
|
logCcbh(list_Factorys);
|
|
|
sendFactoryNo(list_Factorys);
|
|
|
tag_t designRev = NULLTAG;
|
|
|
if (num > 0) {
|
|
|
int n_references = 0;
|
|
|
int* levels = 0;
|
|
|
tag_t* references_tag;
|
|
|
char** relation_type_name = NULL;
|
|
|
//通过出厂编号查找到图纸
|
|
|
ITKCALL(WSOM_where_referenced(factoryNos[0], 1, &n_references, &levels, &references_tag, &relation_type_name));
|
|
|
for (int i = 0; i < n_references; i++) {
|
|
|
if (tc_strcmp(relation_type_name[i], "ZT2_FactoryNumber") == 0) {
|
|
|
char *type2 = NULL;
|
|
|
ITKCALL(WSOM_ask_object_type2(references_tag[i], &type2));
|
|
|
if (tc_strcmp(type2, "ZT2_Design3DRevision") == 0) {
|
|
|
designRev = references_tag[i];
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
tag_t ebom_window = NULLTAG, line = NULLTAG;
|
|
|
ITKCALL(BOM_create_window(&ebom_window));
|
|
|
if (designRev == NULLTAG) {
|
|
|
ITKCALL(BOM_set_window_top_line(ebom_window, NULL, rev, NULLTAG, &line));
|
|
|
}
|
|
|
else {
|
|
|
ITKCALL(BOM_set_window_top_line(ebom_window, NULL, designRev, NULLTAG, &line));
|
|
|
}
|
|
|
vector <_ns1__DT_USCOREBOM_USCORES4_USCOREREQ_LIST> list;
|
|
|
vector <_ns1__DT_USCOREPROCESSROUTE_USCORES4_USCOREREQ_LIST> proclist;
|
|
|
map<string, tag_t> gy_meops; //避免重复工艺路线
|
|
|
vector<tag_t> needTCM_meops;//没用上
|
|
|
vector<string> bomIsExist;
|
|
|
map<string, tag_t> by_materials;
|
|
|
int unct = getIcsId((char*)codeRemark.c_str(), "材料标记");
|
|
|
|
|
|
//tag_t partRev = getBOMPart(line, groupName);
|
|
|
char *ccpMaterialNo = NULL;
|
|
|
ITKCALL(AOM_ask_value_string(rev, "zt2_MaterialNo", &ccpMaterialNo));
|
|
|
tag_t meops = getProcessTag(rev, groupName);
|
|
|
if (meops != NULLTAG) {
|
|
|
readBopInfo1YH(meops, rev, true, gy_meops, needTCM_meops, groupName, now, proclist);
|
|
|
}
|
|
|
else if (meops == NULLTAG && tc_strcmp(groupName, "M040") == 0) {
|
|
|
vector<string> split;
|
|
|
tag_t find = NULLTAG;
|
|
|
Split(zt2_MaterialNo, "-", split);
|
|
|
ITKCALL(ITEM_find_item(split[0].c_str(), &find));
|
|
|
if (find != NULLTAG) {
|
|
|
meops = getProcessTag(find, groupName);
|
|
|
if (meops != NULLTAG) {
|
|
|
readBopInfo1YH(meops, rev, true, gy_meops, needTCM_meops, groupName, now, proclist);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
if (inCcpMap.count(revUid) > 0) {
|
|
|
log("folderName =>%s", zt2_MaterialNo);
|
|
|
inCcpMap[revUid].push_back(ccpMaterialNo);
|
|
|
continue;
|
|
|
}
|
|
|
vector<string> ccpMaterialMap;
|
|
|
ccpMaterialMap.push_back(ccpMaterialNo);
|
|
|
inCcpMap[revUid] = ccpMaterialMap;
|
|
|
string errMsg = "";
|
|
|
recurZYGGSAPNoProc(designRev, rev, groupName, line, gy_meops, needTCM_meops, now, proclist, bomIsExist,
|
|
|
list, (char*)codeRemark.c_str(), unct, by_materials, false, errMsg, inCcpMap, ccpMaterialMap, matr);
|
|
|
//log("errMsg =>%s", errMsg.c_str());
|
|
|
string logmsg = "errMsg =>";
|
|
|
//log2(logmsg.append(errMsg));
|
|
|
logmsg.append(errMsg);
|
|
|
printf("%s\n", logmsg.c_str());
|
|
|
info(logmsg.c_str());
|
|
|
if (errMsg.length() > 0) {
|
|
|
errMsgBuf.append("BOM异常:\\n").append(errMsg);
|
|
|
//
|
|
|
string updateSum = "update CHINT_BOM_TO_SAP_SUM set \"DATASTATUS\" = '数据检查有问题' ,SAPRESULT = 'PLM检查未通过',PLMRESULT = '已发送飞书通知' where code = '%s' ";
|
|
|
char selectRxfs[800];
|
|
|
string timel;
|
|
|
sprintf(selectRxfs, updateSum.c_str(), code);
|
|
|
log("selectRecord2 ===> %s\n", selectRxfs);
|
|
|
ExecuteSQLNoInputParam(selectRxfs);
|
|
|
ExecuteSQLNoInputParam((char*)"commit");
|
|
|
|
|
|
//错误数据已发送飞书提醒
|
|
|
sendNotice(code, errMsgBuf, wbs, userName, projectName);
|
|
|
return;
|
|
|
}
|
|
|
char *zt2_BOMScheme = NULL;
|
|
|
ITKCALL(AOM_UIF_ask_value(rev, "zt2_BOMScheme", &zt2_BOMScheme));
|
|
|
if (list.size() > 0 && strcmp(zt2_BOMScheme, "汇总") == 0) {
|
|
|
char* zt2_Quantity;
|
|
|
ITKCALL(AOM_ask_value_string(rev, "zt2_Quantity", &zt2_Quantity));
|
|
|
if (strstr(zt2_Quantity, "") != 0) {
|
|
|
int quantity = atoi(zt2_Quantity);
|
|
|
if (quantity == 0) {
|
|
|
quantity = 1;
|
|
|
}
|
|
|
int size = list.size();
|
|
|
char* s = new char[10];
|
|
|
_itoa(quantity, s, 10);
|
|
|
list[size - 1].HEAD.BMENG = s;
|
|
|
//head.BMENG = (char*)to_string(quantity).c_str();
|
|
|
}
|
|
|
}
|
|
|
if (list.size() > 0) {
|
|
|
//logBomMsg(list);
|
|
|
mapList[rev] = list;
|
|
|
}
|
|
|
if (proclist.size() > 0) {
|
|
|
logProcessMsg(proclist);// vector <_ns1__DT_USCOREPROCESSROUTE_USCORES4_USCOREREQ_LIST> proclist;
|
|
|
sendProcess(proclist, sendMsg);//proclists.push_back(proclist);//sendProcess(proclist);
|
|
|
}
|
|
|
|
|
|
ITKCALL(BOM_close_window(ebom_window));
|
|
|
}
|
|
|
if (mapList.size() > 0) {
|
|
|
//传递BOM
|
|
|
//logBomMsg(list);
|
|
|
//sendBom(list, sendMsg);
|
|
|
startSplitSend(groupName, mapList, code, wbs, inCcpMap);
|
|
|
//sendBom(list);
|
|
|
}
|
|
|
else {
|
|
|
string time1 = getPlmTime(code);
|
|
|
string updateSum = "update CHINT_BOM_TO_SAP_SUM set datastatus = '没有合法BOM',organizationaltime = '%s',taskstauts = '组织完成',PLMFINISHTIME = SYSDATE where code = '%s' ";
|
|
|
char selectRxfs[800];
|
|
|
string timel;
|
|
|
sprintf(selectRxfs, updateSum.c_str(), time1.c_str(), code);
|
|
|
log("selectRecord2 ===> %s\n", selectRxfs);
|
|
|
ExecuteSQLNoInputParam(selectRxfs);
|
|
|
ExecuteSQLNoInputParam((char*)"commit");
|
|
|
}
|
|
|
|
|
|
|
|
|
} |