|
|
#define _CRT_SECURE_NO_WARNINGS
|
|
|
#include "epm_handler_common.h"
|
|
|
|
|
|
int RB_SendErpItem(EPM_action_message_t msg)
|
|
|
{
|
|
|
printf("=========================对象下发到ERP Start===================\n");
|
|
|
//POM_AM__set_application_bypass(true);
|
|
|
int ifail = ITK_ok;
|
|
|
int attachments_num = 0;
|
|
|
tag_t rootTask = NULLTAG, *attachments = NULLTAG;
|
|
|
//获取任务对象
|
|
|
EPM_ask_root_task(msg.task, &rootTask);
|
|
|
//获取任务目标对象
|
|
|
EPM_ask_attachments(rootTask, EPM_target_attachment, &attachments_num, &attachments);
|
|
|
|
|
|
//获取参数
|
|
|
char *argflag = NULL, *argvalue = NULL, *arg = NULL;
|
|
|
char messageUser[1024] = "", messageResult[1024] = "";
|
|
|
int arg_cnt = TC_number_of_arguments(msg.arguments);
|
|
|
printf("参数个数为:%d\n", arg_cnt);
|
|
|
if (arg_cnt > 0)
|
|
|
{
|
|
|
for (int i = 0; i<arg_cnt; i++)
|
|
|
{
|
|
|
//获取下一个参数(从0开始)
|
|
|
arg = TC_next_argument(msg.arguments);
|
|
|
//获取参数的名称和值
|
|
|
ifail = ITK_ask_argument_named_value((const char*)arg, &argflag, &argvalue);
|
|
|
if (stricmp(argflag, "ownerId") == 0)
|
|
|
{
|
|
|
if (argvalue != NULL)
|
|
|
{
|
|
|
strcpy(messageUser, argvalue);
|
|
|
}
|
|
|
}
|
|
|
else if (stricmp(argflag, "messageResult") == 0)
|
|
|
{
|
|
|
if (argvalue != NULL)
|
|
|
{
|
|
|
strcpy(messageResult, argvalue);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
vector<char *> messageUserValues;
|
|
|
|
|
|
if (strstr(messageUser, ",") != NULL)
|
|
|
{
|
|
|
int vectorValueCount = 0;
|
|
|
char ** vectorValueChar = new char *[64];
|
|
|
split(messageUser, ",", vectorValueChar, &vectorValueCount);
|
|
|
for (int i = 0; i < vectorValueCount; i++)
|
|
|
{
|
|
|
messageUserValues.push_back(vectorValueChar[i]);
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
messageUserValues.push_back(messageUser);
|
|
|
}
|
|
|
|
|
|
int pref_cnt = 0;
|
|
|
char ** pref_vals = NULL;
|
|
|
char* deleteTZRevision = new char[2048];//过滤的图纸版本
|
|
|
//获取首选项的值
|
|
|
PREF_ask_char_values("RB_ItemSendErpProperty", &pref_cnt, &pref_vals);
|
|
|
map<string, string> typePropertyType;
|
|
|
for (int j = 0; j < pref_cnt; j++)
|
|
|
{
|
|
|
if (strstr(pref_vals[j], "-") != NULL)
|
|
|
{
|
|
|
//按照-进行拆分。拆分条件
|
|
|
int valueCount = 0;
|
|
|
char ** valueChar = new char *[64];
|
|
|
//分割字符串
|
|
|
split(pref_vals[j], "-", valueChar, &valueCount);
|
|
|
typePropertyType[valueChar[0]] = valueChar[1];// .insert(std::pair<char*, char*>(valueChar[0], valueChar[1]));
|
|
|
}
|
|
|
//+++获取要过滤的所有版本
|
|
|
else if(strstr(pref_vals[j], "delete=") != NULL){
|
|
|
strcpy(deleteTZRevision,pref_vals[j]);
|
|
|
}
|
|
|
//+++
|
|
|
}
|
|
|
|
|
|
char *tc_root_file = getenv("tc_root"); //C:\Siemens\Teamcenter11
|
|
|
|
|
|
for (int i = 0; i < attachments_num; i++)
|
|
|
{
|
|
|
char *itemType = NULL;
|
|
|
AOM_ask_value_string(attachments[i], "object_type", &itemType);
|
|
|
|
|
|
printf("itemType:%s\n", itemType);
|
|
|
//过滤掉非版本的对象
|
|
|
if ((strstr(itemType, "Revision") == NULL) || (strstr(itemType, "Master") != NULL)
|
|
|
|| (strstr(itemType, "master") != NULL) || (strstr(itemType, "BOM") != NULL) || (strstr(itemType, "bom") != NULL) || (strstr(itemType, "Bom") != NULL))
|
|
|
{
|
|
|
DOFREE(itemType);
|
|
|
continue;
|
|
|
}
|
|
|
//+++过滤版本对象
|
|
|
if (strstr(deleteTZRevision, itemType) != NULL) {
|
|
|
DOFREE(itemType);
|
|
|
continue;
|
|
|
}
|
|
|
//+++
|
|
|
bool isStart = true;
|
|
|
char parameters[100000] = "";//写入到文件的值
|
|
|
strcat(parameters, "getItemPropertys}}");
|
|
|
strcat(parameters, "[");
|
|
|
//获取当前时间
|
|
|
time_t now = time(0);
|
|
|
tm *p = localtime(&now);
|
|
|
|
|
|
char date[128] = "";
|
|
|
sprintf_s(date, "%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 propertyNames = typePropertyType[itemType];
|
|
|
|
|
|
if (propertyNames.c_str() != NULL && propertyNames.size() > 0)
|
|
|
{
|
|
|
printf("propertyNames:%s\n", propertyNames.c_str());
|
|
|
|
|
|
int factoryNum = 0;
|
|
|
char ** factoryValues = NULL;
|
|
|
char * localization_status;
|
|
|
logical master;
|
|
|
//获取工厂
|
|
|
const char * constName = propertyNames.c_str();
|
|
|
char* name = new char[2048];//足够长
|
|
|
strcpy(name, constName);
|
|
|
if (strstr(name, ",") != NULL)
|
|
|
{
|
|
|
//按照,进行拆分。拆分条件
|
|
|
int valueCount = 0;
|
|
|
char ** valueChar = new char *[64];
|
|
|
//分割字符串
|
|
|
split(name, ",", valueChar, &valueCount);
|
|
|
for (int k = 0; k < valueCount; k++)
|
|
|
{
|
|
|
if (strstr(valueChar[k], "=") != NULL)
|
|
|
{
|
|
|
//按照-进行拆分。拆分条件
|
|
|
int valueNum = 0;
|
|
|
char ** values = new char *[64];
|
|
|
//分割字符串
|
|
|
split(valueChar[k], "=", values, &valueNum);
|
|
|
|
|
|
if (strcmp(values[1], "FACTORYNAME") == 0)
|
|
|
{
|
|
|
printf("FACTORYNAME:%s\n", values[0]);
|
|
|
if (strcmp(values[0], "/") != 0)
|
|
|
{
|
|
|
AOM_UIF_ask_localized_value_strings(attachments[i], values[0], "zh_CN", &factoryNum, &factoryValues, &localization_status, &master);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
factoryNum = 1;
|
|
|
factoryValues = new char*[64];
|
|
|
factoryValues[0] = "";
|
|
|
}
|
|
|
//TCGetPropertyValue(attachments[i], "Revision", values[0], &factoryValues);
|
|
|
//AOM_UIF_ask_values(attachments[i], values[0], &factoryNum, &factoryValues);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
//按照-进行拆分。拆分条件
|
|
|
int valueCount = 0;
|
|
|
char ** valueChar = new char *[64];
|
|
|
//分割字符串
|
|
|
split(name, "=", valueChar, &valueCount);
|
|
|
if (strcmp(valueChar[1], "FACTORYNAME") == 0)
|
|
|
{
|
|
|
printf("FACTORYNAME:%s\n", valueChar[0]);
|
|
|
if (strcmp(valueChar[0], "/") != 0)
|
|
|
{
|
|
|
AOM_UIF_ask_localized_value_strings(attachments[i], valueChar[0], "zh_CN", &factoryNum, &factoryValues, &localization_status, &master);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
factoryNum = 1;
|
|
|
factoryValues = new char*[64];
|
|
|
factoryValues[0] = "";
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
printf("factoryNum:%d\n", factoryNum);
|
|
|
|
|
|
if (factoryNum > 0)
|
|
|
{
|
|
|
for (int j = 0; j < factoryNum; j++)
|
|
|
{
|
|
|
|
|
|
printf("factoryValues[j]:%s\n", factoryValues[j]);
|
|
|
if (factoryValues[j] == NULL || strcmp(factoryValues[j], "") == 0)
|
|
|
{
|
|
|
continue;
|
|
|
}
|
|
|
if (isStart)
|
|
|
{
|
|
|
strcat(parameters, "{");
|
|
|
isStart = false;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
strcat(parameters, ",{");
|
|
|
}
|
|
|
|
|
|
//const char * constName = propertyNames.c_str();
|
|
|
//char* name = new char[2048];//足够长
|
|
|
//strcpy(name, constName);
|
|
|
if (strstr(name, ",") != NULL)
|
|
|
{
|
|
|
//按照,进行拆分。拆分条件
|
|
|
int valueCount = 0;
|
|
|
char ** valueChar = new char *[64];
|
|
|
//分割字符串
|
|
|
split(name, ",", valueChar, &valueCount);
|
|
|
for (int k = 0; k < valueCount; k++)
|
|
|
{
|
|
|
if (strstr(valueChar[k], "=") != NULL)
|
|
|
{
|
|
|
//按照-进行拆分。拆分条件
|
|
|
int valueNum = 0;
|
|
|
char ** values = new char *[64];
|
|
|
//分割字符串
|
|
|
split(valueChar[k], "=", values, &valueNum);
|
|
|
|
|
|
strcat(parameters, "\"");
|
|
|
strcat(parameters, values[1] == NULL || strlen(values[1]) == 0 ? "" : values[1]);
|
|
|
strcat(parameters, "\"");
|
|
|
strcat(parameters, ":");
|
|
|
|
|
|
char * item_rev_value = NULL;
|
|
|
TCGetPropertyValue(attachments[i], "Revision", values[0], &item_rev_value);
|
|
|
if (strcmp(values[1], "FACTORYNAME") == 0)
|
|
|
{
|
|
|
item_rev_value = factoryValues[j];
|
|
|
}
|
|
|
if (strcmp(values[1], "INPUTTIME") == 0)
|
|
|
{
|
|
|
item_rev_value = date;
|
|
|
}
|
|
|
if (strcmp(values[1], "VELOCITYOFVIBRATION") == 0)
|
|
|
{
|
|
|
char * zdjsd = NULL;
|
|
|
char * zdsd = NULL;
|
|
|
TCGetPropertyValue(attachments[i], "Revision", "class.110629", &zdjsd);
|
|
|
TCGetPropertyValue(attachments[i], "Revision", "class.110630", &zdsd);
|
|
|
|
|
|
|
|
|
if (zdjsd == NULL)
|
|
|
{
|
|
|
zdjsd = "";
|
|
|
}
|
|
|
|
|
|
if (zdsd == NULL)
|
|
|
{
|
|
|
zdsd = "";
|
|
|
}
|
|
|
|
|
|
if (strcmp(zdjsd, "无") == 0)
|
|
|
{
|
|
|
zdjsd = "";
|
|
|
}
|
|
|
if (strcmp(zdsd, "无") == 0)
|
|
|
{
|
|
|
zdsd = "";
|
|
|
}
|
|
|
|
|
|
if (zdjsd != NULL && strcmp(zdjsd, "") != 0 && strstr(zdjsd, ":") != NULL)
|
|
|
{
|
|
|
|
|
|
int TOLERANCE4Num = 0;
|
|
|
char ** TOLERANCE4values = new char *[64];
|
|
|
//分割字符串
|
|
|
split(zdjsd, ":", TOLERANCE4values, &TOLERANCE4Num);
|
|
|
zdjsd = TOLERANCE4values[0];
|
|
|
}
|
|
|
|
|
|
if (zdsd != NULL && strcmp(zdsd, "") != 0 && strstr(zdsd, ":") != NULL)
|
|
|
{
|
|
|
|
|
|
int TOLERANCE4Num = 0;
|
|
|
char ** TOLERANCE4values = new char *[64];
|
|
|
//分割字符串
|
|
|
split(zdsd, ":", TOLERANCE4values, &TOLERANCE4Num);
|
|
|
zdsd = TOLERANCE4values[0];
|
|
|
}
|
|
|
|
|
|
char revValue[256] = "";
|
|
|
|
|
|
strcat(revValue, zdjsd);
|
|
|
strcat(revValue, zdsd);
|
|
|
item_rev_value = revValue;
|
|
|
|
|
|
/*if (zdjsd != NULL && strcmp(zdjsd, "") != 0 && zdsd != NULL && strcmp(zdsd, "") != 0)
|
|
|
{
|
|
|
if (strcmp(zdjsd, "无") == 0)
|
|
|
{
|
|
|
zdjsd = "";
|
|
|
}
|
|
|
if (strcmp(zdsd, "无") == 0)
|
|
|
{
|
|
|
zdsd = "";
|
|
|
}
|
|
|
char revValue[256] = "";
|
|
|
|
|
|
strcat(revValue, zdjsd);
|
|
|
strcat(revValue, zdsd);
|
|
|
item_rev_value = revValue;
|
|
|
}*/
|
|
|
}
|
|
|
if (strcmp(values[1], "TOLERANCE") == 0)
|
|
|
{
|
|
|
char * TOLERANCE1 = NULL;
|
|
|
char * TOLERANCE2 = NULL;
|
|
|
char * TOLERANCE3 = NULL;
|
|
|
char * TOLERANCE4 = NULL;
|
|
|
TCGetPropertyValue(attachments[i], "Revision", "class.110622", &TOLERANCE1);
|
|
|
TCGetPropertyValue(attachments[i], "Revision", "class.112405", &TOLERANCE2);
|
|
|
TCGetPropertyValue(attachments[i], "Revision", "class.112606", &TOLERANCE3);
|
|
|
TCGetPropertyValue(attachments[i], "Revision", "class.110313", &TOLERANCE4);
|
|
|
if (TOLERANCE1 != NULL && strcmp(TOLERANCE1, "") != 0)
|
|
|
{
|
|
|
item_rev_value = TOLERANCE1;
|
|
|
}
|
|
|
if (TOLERANCE2 != NULL && strcmp(TOLERANCE2, "") != 0)
|
|
|
{
|
|
|
item_rev_value = TOLERANCE2;
|
|
|
}
|
|
|
if (TOLERANCE3 != NULL && strcmp(TOLERANCE3, "") != 0)
|
|
|
{
|
|
|
item_rev_value = TOLERANCE3;
|
|
|
}
|
|
|
if (TOLERANCE4 != NULL && strcmp(TOLERANCE4, "") != 0)
|
|
|
{
|
|
|
item_rev_value = TOLERANCE4;
|
|
|
}
|
|
|
if (item_rev_value != NULL && strcmp(item_rev_value, "") != 0 && strstr(item_rev_value,":") != NULL)
|
|
|
{
|
|
|
|
|
|
int TOLERANCE4Num = 0;
|
|
|
char ** TOLERANCE4values = new char *[64];
|
|
|
//分割字符串
|
|
|
split(item_rev_value, ":", TOLERANCE4values, &TOLERANCE4Num);
|
|
|
item_rev_value = TOLERANCE4values[0];
|
|
|
}
|
|
|
|
|
|
|
|
|
if (strcmp(item_rev_value, "无") == 0)
|
|
|
{
|
|
|
item_rev_value = "";
|
|
|
}
|
|
|
}
|
|
|
if (strcmp(values[1], "FIGURE") == 0)
|
|
|
{
|
|
|
string resultString = item_rev_value;
|
|
|
if (strstr(item_rev_value, "SF-") != NULL)
|
|
|
{
|
|
|
resultString = replace_all_distinct(item_rev_value, "SF-", "");
|
|
|
}
|
|
|
else if (strstr(item_rev_value, "XX-") != NULL)
|
|
|
{
|
|
|
resultString = replace_all_distinct(item_rev_value, "XX-", "");
|
|
|
}
|
|
|
char resultChar[256] = "";
|
|
|
|
|
|
strcpy(resultChar, resultString.c_str());
|
|
|
|
|
|
*(resultChar + strlen(resultString.c_str())) = '\0';
|
|
|
|
|
|
item_rev_value = resultChar;
|
|
|
}
|
|
|
|
|
|
|
|
|
if (strstr(item_rev_value, "\\") != NULL)
|
|
|
{
|
|
|
string resultString = replace_all_distinct(item_rev_value, "\\", "&&");
|
|
|
|
|
|
char resultChar[256] = "";
|
|
|
|
|
|
strcpy(resultChar, resultString.c_str());
|
|
|
|
|
|
*(resultChar + strlen(resultString.c_str())) = '\0';
|
|
|
|
|
|
item_rev_value = resultChar;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (strcmp(item_rev_value, "/") == 0)
|
|
|
{
|
|
|
item_rev_value = "";
|
|
|
}
|
|
|
strcat(parameters, "\"");
|
|
|
strcat(parameters, item_rev_value);
|
|
|
strcat(parameters, "\"");
|
|
|
if (k < valueCount - 1)
|
|
|
{
|
|
|
strcat(parameters, ",");
|
|
|
}
|
|
|
//printf("字符串%s\n", parameters);
|
|
|
|
|
|
DOFREE(item_rev_value);
|
|
|
}
|
|
|
//printf("parameters:%s\n", parameters);
|
|
|
}
|
|
|
valueChar = NULL;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
//按照-进行拆分。拆分条件
|
|
|
int valueCount = 0;
|
|
|
char ** valueChar = new char *[64];
|
|
|
//分割字符串
|
|
|
split(name, "=", valueChar, &valueCount);
|
|
|
|
|
|
strcat(parameters, "\"");
|
|
|
strcat(parameters, valueChar[1] == NULL || strlen(valueChar[1]) == 0 ? "" : valueChar[1]);
|
|
|
strcat(parameters, "\"");
|
|
|
strcat(parameters, ":");
|
|
|
|
|
|
char * item_rev_value = NULL;
|
|
|
TCGetPropertyValue(attachments[i], "Revision", valueChar[0], &item_rev_value);
|
|
|
|
|
|
if (strcmp(valueChar[1], "FACTORYNAME") == 0)
|
|
|
{
|
|
|
item_rev_value = factoryValues[j];
|
|
|
}
|
|
|
if (strcmp(valueChar[1], "INPUTTIME") == 0)
|
|
|
{
|
|
|
item_rev_value = date;
|
|
|
}
|
|
|
if (strcmp(valueChar[1], "VELOCITYOFVIBRATION") == 0)
|
|
|
{
|
|
|
char * zdjsd = NULL;
|
|
|
char * zdsd = NULL;
|
|
|
TCGetPropertyValue(attachments[i], "Revision", "class.110629", &zdjsd);
|
|
|
TCGetPropertyValue(attachments[i], "Revision", "class.110630", &zdsd);
|
|
|
|
|
|
|
|
|
if (zdjsd == NULL)
|
|
|
{
|
|
|
zdjsd = "";
|
|
|
}
|
|
|
|
|
|
if (zdsd == NULL)
|
|
|
{
|
|
|
zdsd = "";
|
|
|
}
|
|
|
|
|
|
if (strcmp(zdjsd, "无") == 0)
|
|
|
{
|
|
|
zdjsd = "";
|
|
|
}
|
|
|
if (strcmp(zdsd, "无") == 0)
|
|
|
{
|
|
|
zdsd = "";
|
|
|
}
|
|
|
|
|
|
|
|
|
if (zdjsd != NULL && strcmp(zdjsd, "") != 0 && strstr(zdjsd, ":") != NULL)
|
|
|
{
|
|
|
|
|
|
int TOLERANCE4Num = 0;
|
|
|
char ** TOLERANCE4values = new char *[64];
|
|
|
//分割字符串
|
|
|
split(zdjsd, ":", TOLERANCE4values, &TOLERANCE4Num);
|
|
|
zdjsd = TOLERANCE4values[0];
|
|
|
}
|
|
|
|
|
|
if (zdsd != NULL && strcmp(zdsd, "") != 0 && strstr(zdsd, ":") != NULL)
|
|
|
{
|
|
|
|
|
|
int TOLERANCE4Num = 0;
|
|
|
char ** TOLERANCE4values = new char *[64];
|
|
|
//分割字符串
|
|
|
split(zdsd, ":", TOLERANCE4values, &TOLERANCE4Num);
|
|
|
zdsd = TOLERANCE4values[0];
|
|
|
}
|
|
|
|
|
|
char revValue[256] = "";
|
|
|
|
|
|
strcat(revValue, zdjsd);
|
|
|
strcat(revValue, zdsd);
|
|
|
item_rev_value = revValue;
|
|
|
|
|
|
/*if (zdjsd != NULL && strcmp(zdjsd, "") != 0 && zdsd != NULL && strcmp(zdsd, "") != 0)
|
|
|
{
|
|
|
if (strcmp(zdjsd, "无") == 0)
|
|
|
{
|
|
|
zdjsd = "";
|
|
|
}
|
|
|
if (strcmp(zdsd, "无") == 0)
|
|
|
{
|
|
|
zdsd = "";
|
|
|
}
|
|
|
char revValue[256] = "";
|
|
|
|
|
|
strcat(revValue, zdjsd);
|
|
|
strcat(revValue, zdsd);
|
|
|
item_rev_value = revValue;
|
|
|
}*/
|
|
|
|
|
|
|
|
|
}
|
|
|
if (strcmp(valueChar[1], "TOLERANCE") == 0)
|
|
|
{
|
|
|
char * TOLERANCE1 = NULL;
|
|
|
char * TOLERANCE2 = NULL;
|
|
|
char * TOLERANCE3 = NULL;
|
|
|
char * TOLERANCE4 = NULL;
|
|
|
TCGetPropertyValue(attachments[i], "Revision", "class.110622", &TOLERANCE1);
|
|
|
TCGetPropertyValue(attachments[i], "Revision", "class.112405", &TOLERANCE2);
|
|
|
TCGetPropertyValue(attachments[i], "Revision", "class.112606", &TOLERANCE3);
|
|
|
TCGetPropertyValue(attachments[i], "Revision", "class.110313", &TOLERANCE4);
|
|
|
if (TOLERANCE1 != NULL && strcmp(TOLERANCE1, "") != 0)
|
|
|
{
|
|
|
item_rev_value = TOLERANCE1;
|
|
|
}
|
|
|
if (TOLERANCE2 != NULL && strcmp(TOLERANCE2, "") != 0)
|
|
|
{
|
|
|
item_rev_value = TOLERANCE2;
|
|
|
}
|
|
|
if (TOLERANCE3 != NULL && strcmp(TOLERANCE3, "") != 0)
|
|
|
{
|
|
|
item_rev_value = TOLERANCE3;
|
|
|
}
|
|
|
if (TOLERANCE4 != NULL && strcmp(TOLERANCE4, "") != 0)
|
|
|
{
|
|
|
item_rev_value = TOLERANCE4;
|
|
|
}
|
|
|
if (item_rev_value != NULL && strcmp(item_rev_value, "") != 0 && strstr(item_rev_value, ":") != NULL)
|
|
|
{
|
|
|
|
|
|
int TOLERANCE4Num = 0;
|
|
|
char ** TOLERANCE4values = new char *[64];
|
|
|
//分割字符串
|
|
|
split(item_rev_value, ":", TOLERANCE4values, &TOLERANCE4Num);
|
|
|
item_rev_value = TOLERANCE4values[0];
|
|
|
}
|
|
|
}
|
|
|
if (strcmp(valueChar[1], "FIGURE") == 0)
|
|
|
{
|
|
|
string resultString = item_rev_value;
|
|
|
if (strstr(item_rev_value, "SF-") != NULL)
|
|
|
{
|
|
|
resultString = replace_all_distinct(item_rev_value, "SF-", "");
|
|
|
}
|
|
|
else if (strstr(item_rev_value, "XX-") != NULL)
|
|
|
{
|
|
|
resultString = replace_all_distinct(item_rev_value, "XX-", "");
|
|
|
}
|
|
|
char resultChar[256] = "";
|
|
|
|
|
|
strcpy(resultChar, resultString.c_str());
|
|
|
|
|
|
*(resultChar + strlen(resultString.c_str())) = '\0';
|
|
|
|
|
|
item_rev_value = resultChar;
|
|
|
}
|
|
|
|
|
|
|
|
|
if (strstr(item_rev_value, "\\") != NULL)
|
|
|
{
|
|
|
string resultString = replace_all_distinct(item_rev_value, "\\", "&&");
|
|
|
|
|
|
char resultChar[256] = "";
|
|
|
|
|
|
strcpy(resultChar, resultString.c_str());
|
|
|
|
|
|
*(resultChar + strlen(resultString.c_str())) = '\0';
|
|
|
|
|
|
item_rev_value = resultChar;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (strcmp(item_rev_value, "/") == 0)
|
|
|
{
|
|
|
item_rev_value = "";
|
|
|
}
|
|
|
|
|
|
strcat(parameters, "\"");
|
|
|
strcat(parameters, item_rev_value);
|
|
|
strcat(parameters, "\"");
|
|
|
DOFREE(item_rev_value);
|
|
|
valueChar = NULL;
|
|
|
}
|
|
|
|
|
|
strcat(parameters, "}");
|
|
|
}
|
|
|
}
|
|
|
DOFREE(constName);
|
|
|
name = NULL;
|
|
|
|
|
|
}
|
|
|
|
|
|
DOFREE(itemType);
|
|
|
strcat(parameters, "]");
|
|
|
|
|
|
//把数据用写入文件
|
|
|
char data_file[SS_MAXPATHLEN] = "";
|
|
|
strcat(data_file, tc_root_file);
|
|
|
strcat(data_file, "\\");
|
|
|
strcat(data_file, date);
|
|
|
strcat(data_file, ".txt");
|
|
|
ofstream file;
|
|
|
file.open(data_file);
|
|
|
file << parameters << endl; // 使用与cout同样的方式进行写入
|
|
|
file.close();
|
|
|
|
|
|
string strResult;
|
|
|
|
|
|
//cmd指令
|
|
|
char cmd[256] = "";
|
|
|
strcpy(cmd, "java -jar \"");
|
|
|
//strcat(cmd, jar_file);
|
|
|
strcat(cmd, tc_root_file);
|
|
|
strcat(cmd, "\\portal\\plugins\\");
|
|
|
strcat(cmd, "RB_SendErp.jar");
|
|
|
strcat(cmd, "\" ");
|
|
|
//传参
|
|
|
cout << data_file << endl;
|
|
|
strcat(cmd, data_file);
|
|
|
//用来传递本流程的流程名称(@分割)
|
|
|
//strcat(cmd,"@");
|
|
|
//strcat(cmd,handler_name);
|
|
|
printf("路径:\n%s\n", cmd);
|
|
|
char buf[8000] = { 0 };
|
|
|
FILE *pf = NULL;
|
|
|
if ((pf = _popen(cmd, "r")) == NULL) {
|
|
|
printf("接口返回:\n%s", "1");
|
|
|
}
|
|
|
|
|
|
while (fgets(buf, sizeof buf, pf)) {
|
|
|
strResult += buf;
|
|
|
}
|
|
|
_pclose(pf);
|
|
|
|
|
|
cout << strResult << endl;
|
|
|
unsigned int iSize = strResult.size();
|
|
|
if (iSize > 0 && strResult[iSize - 1] == '\n' && strlen(parameters) > 0)
|
|
|
{
|
|
|
|
|
|
strResult = strResult.substr(0, iSize - 1);
|
|
|
printf("下发失败\n");
|
|
|
cout << strResult << endl;
|
|
|
if (strcmp(messageResult, "1") == 0)
|
|
|
{
|
|
|
ifail = 1;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
messageUserValues.clear();
|
|
|
vector<char *>().swap(messageUserValues);
|
|
|
MEM_free(attachments);
|
|
|
tc_root_file = NULL;
|
|
|
pref_vals = NULL;
|
|
|
if (ifail == 1)
|
|
|
{
|
|
|
//EMH_store_error_s1(EMH_severity_user_error, EMH_USER_error_base, strResult.c_str());
|
|
|
}
|
|
|
printf("=========================对象下发到ERP End===================\n");
|
|
|
return ifail;
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//int RB_SendErpItem_New(EPM_action_message_t msg)
|
|
|
//{
|
|
|
// printf("=========================对象下发到ERP Start===================\n");
|
|
|
// //POM_AM__set_application_bypass(true);
|
|
|
// int ifail = ITK_ok;
|
|
|
// int attachments_num = 0;
|
|
|
// tag_t rootTask = NULLTAG, * attachments = NULLTAG;
|
|
|
// //获取任务对象
|
|
|
// EPM_ask_root_task(msg.task, &rootTask);
|
|
|
// //获取任务目标对象
|
|
|
// EPM_ask_attachments(rootTask, EPM_target_attachment, &attachments_num, &attachments);
|
|
|
// int pref_cnt = 0;
|
|
|
// char** pref_vals = NULL;
|
|
|
// //获取首选项的值
|
|
|
// PREF_ask_char_values("RB_ItemSendErp_Type_Attr", &pref_cnt, &pref_vals);
|
|
|
// map<string, map<string, string>> itemTypeMap;
|
|
|
// map<string, string> typePropertyType;
|
|
|
// for (int i = 0; i < pref_cnt; i++)
|
|
|
// {
|
|
|
// if (strstr(pref_vals[i], ":") != NULL)
|
|
|
// {
|
|
|
// //按照-进行拆分。拆分条件
|
|
|
// int valueCount = 0;
|
|
|
// char** valueChar = new char* [64];
|
|
|
// //分割字符串
|
|
|
// split(pref_vals[i], ":", valueChar, &valueCount);
|
|
|
// if (strstr(valueChar[1], "|") != NULL)
|
|
|
// {
|
|
|
// int attrCount = 0;
|
|
|
// char** attrChar = new char* [128];
|
|
|
// //分割字符串
|
|
|
// split(valueChar[1], "|", attrChar, &attrCount);
|
|
|
// for (int j = 0; j < attrCount; j++)
|
|
|
// {
|
|
|
// if (strstr(attrChar[j], "=") != NULL)
|
|
|
// {
|
|
|
// int count = 0;
|
|
|
// char** attrs = new char* [64];
|
|
|
// //分割字符串
|
|
|
// split(attrChar[j], "=", attrs, &count);
|
|
|
// typePropertyType[attrs[0]] = attrs[1];
|
|
|
// DOFREE(attrs);
|
|
|
// }
|
|
|
// }
|
|
|
// DOFREE(attrChar);
|
|
|
// }
|
|
|
// itemTypeMap[valueChar[0]] = typePropertyType;
|
|
|
// typePropertyType.clear();
|
|
|
// DOFREE(valueChar);
|
|
|
//
|
|
|
// }
|
|
|
// }
|
|
|
// int unit_pref_cnt = 0;
|
|
|
// char** unit_pref_vals = NULL;
|
|
|
// //获取首选项的值
|
|
|
// PREF_ask_char_values("RB_SEND_UNIT_MATCHING", &unit_pref_cnt, &unit_pref_vals);
|
|
|
// map<string, string> unitMap;
|
|
|
// for (int i = 0; i < unit_pref_cnt; i++)
|
|
|
// {
|
|
|
// if (strstr(unit_pref_vals[i], "=") != NULL)
|
|
|
// {
|
|
|
// //按照-进行拆分。拆分条件
|
|
|
// int valueCount = 0;
|
|
|
// char** valueChar = new char* [64];
|
|
|
// //分割字符串
|
|
|
// split(unit_pref_vals[i], "=", valueChar, &valueCount);
|
|
|
// unitMap[valueChar[0]] = valueChar[1];
|
|
|
// DOFREE(valueChar);
|
|
|
// }
|
|
|
// }
|
|
|
// int smzq_pref_cnt = 0;
|
|
|
// char** smzq_pref_vals = NULL;
|
|
|
// //获取首选项的值
|
|
|
// PREF_ask_char_values("RB3_WL_SMZQ", &smzq_pref_cnt, &smzq_pref_vals);
|
|
|
// map<string, string> smzqMap;
|
|
|
// for (int i = 0; i < smzq_pref_cnt; i++)
|
|
|
// {
|
|
|
// if (strstr(smzq_pref_vals[i], "=") != NULL)
|
|
|
// {
|
|
|
// //按照-进行拆分。拆分条件
|
|
|
// int valueCount = 0;
|
|
|
// char** valueChar = new char* [64];
|
|
|
// //分割字符串
|
|
|
// split(smzq_pref_vals[i], "=", valueChar, &valueCount);
|
|
|
// smzqMap[valueChar[0]] = valueChar[1];
|
|
|
// DOFREE(valueChar);
|
|
|
// }
|
|
|
// }
|
|
|
// int c_sql_value_count = 0;
|
|
|
// char** c_sql_values;
|
|
|
// ITKCALL(PREF_ask_char_values("RB3_SQL_Connect2", &c_sql_value_count, &c_sql_values));
|
|
|
// if (c_sql_value_count != 3)
|
|
|
// {
|
|
|
// printf("首选项 RB3_SQL_Connect2 配置错误 数量%d ", c_sql_value_count);
|
|
|
// return 1;
|
|
|
// }
|
|
|
//
|
|
|
// char* tc_root_file = getenv("tc_root"); //C:\Siemens\Teamcenter11
|
|
|
// //+++
|
|
|
// char parameters[100000] = "";//写入到文件的值
|
|
|
// strcat(parameters, "[");
|
|
|
// //获取当前时间
|
|
|
// time_t now = time(0);
|
|
|
// tm* p = localtime(&now);
|
|
|
// char date[128] = "";
|
|
|
// sprintf_s(date, "%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);
|
|
|
//
|
|
|
// //"tc11","infodba","//172.16.50.40/tc11" "TC12","infodba","172.16.68.13/tc1"
|
|
|
// int status = ConnServer(c_sql_values[1], c_sql_values[2], c_sql_values[0]);
|
|
|
// printf("status:%d\n", status);
|
|
|
// map<string, map<string, int>> classMap;
|
|
|
// for (int i = 0; i < attachments_num; i++)
|
|
|
// {
|
|
|
// char* itemType = NULL;
|
|
|
// AOM_ask_value_string(attachments[i], "object_type", &itemType);
|
|
|
// printf("itemType:%s\n", itemType);
|
|
|
// //过滤掉非版本的对象
|
|
|
// if ((strstr(itemType, "Revision") == NULL) || (strstr(itemType, "Master") != NULL)
|
|
|
// || (strstr(itemType, "master") != NULL) || (strstr(itemType, "BOM") != NULL) || (strstr(itemType, "bom") != NULL) || (strstr(itemType, "Bom") != NULL))
|
|
|
// {
|
|
|
// DOFREE(itemType);
|
|
|
// continue;
|
|
|
// }
|
|
|
// if (itemTypeMap.find(itemType) != itemTypeMap.end()) {
|
|
|
// map<string, string> propMap = itemTypeMap[itemType];
|
|
|
// if (strstr(parameters, "[{") != NULL) {
|
|
|
// strcat(parameters, ",");
|
|
|
// }
|
|
|
// strcat(parameters, "{");
|
|
|
// //采购分类默认值暂定为空
|
|
|
// strcat(parameters, "\"purchaseClassCode\":\"\",");
|
|
|
// tag_t ico_tag = NULLTAG;
|
|
|
// char* classId = NULL;
|
|
|
// map<string, int> attrMap;
|
|
|
// ICS_ask_classification_object(attachments[i], &ico_tag);
|
|
|
// if (ico_tag != NULLTAG) {
|
|
|
// ICS_ico_ask_class(ico_tag, &classId);
|
|
|
// printf(">> classId: %s\n", classId);
|
|
|
// //分类属性名称对应id map存储
|
|
|
// if (classMap.find(classId) == classMap.end()) {
|
|
|
// int count = 0;
|
|
|
// int* ids;
|
|
|
// int* arraySize;
|
|
|
// int* formats;
|
|
|
// int* options;
|
|
|
// char** names;
|
|
|
// char** shortNames;
|
|
|
// char** annotations;
|
|
|
// char** unit;
|
|
|
// char** minValues;
|
|
|
// char** maxValues;
|
|
|
// char** defaultValues;
|
|
|
// char** descriptions;
|
|
|
// ITKCALL(ICS_class_describe_attributes(classId, &count, &ids, &names, &shortNames, &annotations, &arraySize,
|
|
|
// &formats, &unit, &minValues, &maxValues, &defaultValues, &descriptions, &options));
|
|
|
// for (int i = 0; i < count; i++)
|
|
|
// {
|
|
|
// attrMap.insert(pair<string, int>(names[i], ids[i]));
|
|
|
// }
|
|
|
// classMap.insert(pair<string, map<string, int>>(classId, attrMap));
|
|
|
// if (ids != NULL) {
|
|
|
// DOFREE(ids);
|
|
|
// }
|
|
|
// if (arraySize != NULL) {
|
|
|
// DOFREE(arraySize);
|
|
|
// }
|
|
|
// if (formats != NULL) {
|
|
|
// DOFREE(formats);
|
|
|
// }
|
|
|
// if (options != NULL) {
|
|
|
// DOFREE(options);
|
|
|
// }
|
|
|
// if (names != NULL) {
|
|
|
// DOFREE(names);
|
|
|
// }
|
|
|
// if (shortNames != NULL) {
|
|
|
// DOFREE(shortNames);
|
|
|
// }
|
|
|
// if (annotations != NULL) {
|
|
|
// DOFREE(annotations);
|
|
|
// }
|
|
|
// if (unit != NULL) {
|
|
|
// DOFREE(unit);
|
|
|
// }
|
|
|
// if (minValues != NULL) {
|
|
|
// DOFREE(minValues);
|
|
|
// }
|
|
|
// if (maxValues != NULL) {
|
|
|
// DOFREE(maxValues);
|
|
|
// }
|
|
|
// if (defaultValues != NULL) {
|
|
|
// DOFREE(defaultValues);
|
|
|
// }
|
|
|
// if (descriptions != NULL) {
|
|
|
// DOFREE(descriptions);
|
|
|
// }
|
|
|
// }
|
|
|
// else {
|
|
|
// attrMap = classMap[classId];
|
|
|
// }
|
|
|
// }
|
|
|
//
|
|
|
// char* classCode = NULL;
|
|
|
// char* className = NULL;
|
|
|
// char* organization = NULL;
|
|
|
// char* punit = NULL;
|
|
|
// char factoryCode[2048] = "\0";
|
|
|
// //这里写服务名,不能用实例名(名称相同除外)
|
|
|
// if (status)
|
|
|
// {
|
|
|
// printf("提示:中间数据表访问失败\n");
|
|
|
// }
|
|
|
// else {
|
|
|
// char* field1 = NULL;
|
|
|
// char* field2 = NULL;
|
|
|
// int outputColumn = 0, outputValueCount = 0;
|
|
|
// char*** outputValue = NULL;
|
|
|
// printf("提示:中间数据表访问成功\n");
|
|
|
// //物料分类特殊处理,通过数据库表匹配
|
|
|
// char sql[128] = "\0";
|
|
|
// if (strcmp("RB3_LBJRevision", itemType) == 0 || strcmp("RB3_GNZCRevision", itemType) == 0 || strcmp("RB3_GNLBJRevision", itemType) == 0 || strcmp("RB3_GYZYRevision", itemType) == 0) {
|
|
|
// if (strcmp("RB3_LBJRevision", itemType) == 0 && ico_tag != NULLTAG)
|
|
|
// {
|
|
|
// ITKCALL(AOM_UIF_ask_value(attachments[i], "object_name", &field1));
|
|
|
// char* value = NULL;
|
|
|
// ICS_ask_attribute_value(ico_tag, "类别", &value);
|
|
|
// if (value != NULL) {
|
|
|
// int id = attrMap["类别"];
|
|
|
// getClassValue(value, id, &field2);
|
|
|
// DOFREE(value);
|
|
|
// }
|
|
|
// }
|
|
|
// else if (strcmp("RB3_GNZCRevision", itemType) == 0 && ico_tag != NULLTAG)
|
|
|
// {
|
|
|
// char* value = NULL;
|
|
|
// ICS_ask_attribute_value(ico_tag, "产品类别", &value);
|
|
|
// if (value != NULL) {
|
|
|
// int id = attrMap["产品类别"];
|
|
|
// getClassValue(value, id, &field1);
|
|
|
// DOFREE(value);
|
|
|
// }
|
|
|
// ITKCALL(AOM_UIF_ask_value(attachments[i], "object_name", &field2));
|
|
|
// }
|
|
|
// else if (strcmp("RB3_GNLBJRevision", itemType) == 0 && ico_tag != NULLTAG)
|
|
|
// {
|
|
|
// ITKCALL(AOM_UIF_ask_value(attachments[i], "object_name", &field1));
|
|
|
// char* value = NULL;
|
|
|
// ICS_ask_attribute_value(ico_tag, "产品类别", &value);
|
|
|
// if (value != NULL) {
|
|
|
// int id = attrMap["产品类别"];
|
|
|
// getClassValue(value, id, &field2);
|
|
|
// DOFREE(value);
|
|
|
// }
|
|
|
// }
|
|
|
// else if (strcmp("RB3_GYZYRevision", itemType) == 0 && ico_tag != NULLTAG)
|
|
|
// {
|
|
|
// char* new_classId = NULL;
|
|
|
// if (startsWith(classId, '1', '2') || startsWith(classId, '1', '7'))
|
|
|
// {
|
|
|
// new_classId = getFirstStr(classId, 2);
|
|
|
// }
|
|
|
// else
|
|
|
// {
|
|
|
// new_classId = getFirstStr(classId, 4);
|
|
|
// }
|
|
|
// tag_t classTag = NULLTAG;
|
|
|
// char* id = NULL;
|
|
|
// if (new_classId != NULL) {
|
|
|
// ITKCALL(ICS_find_class(new_classId, &classTag));
|
|
|
// if (classTag != NULLTAG)
|
|
|
// {
|
|
|
// ITKCALL(ICS_ask_id_name(classTag, &id, &field1));
|
|
|
// }
|
|
|
// }
|
|
|
// if (id != NULL) {
|
|
|
// DOFREE(id);
|
|
|
// }
|
|
|
// if (classTag != NULL) {
|
|
|
// DOFREE(classTag);
|
|
|
// }
|
|
|
// if (new_classId != NULL) {
|
|
|
// DOFREE(new_classId);
|
|
|
// }
|
|
|
// }
|
|
|
// if (field1 != NULL) {
|
|
|
// if (field1 != NULL && field2 != NULL) {
|
|
|
// sprintf(sql, "select PCLASSCODE,PCLASSNAME,NEW_COLUMN,PUNIT from PLM_ERP_CLASS_TABLE where PFIELD01= '%s' and PFIELD02= '%s'", field1, field2);
|
|
|
// }
|
|
|
// else {
|
|
|
// sprintf(sql, "select PCLASSCODE,PCLASSNAME,NEW_COLUMN,PUNIT from PLM_ERP_CLASS_TABLE where PFIELD01= '%s'", field1);
|
|
|
// }
|
|
|
// }
|
|
|
// }
|
|
|
// else {
|
|
|
// if (strcmp("RB3_ZCRevision", itemType) == 0)
|
|
|
// {
|
|
|
// ITKCALL(AOM_UIF_ask_value(attachments[i], "rb3_zclx", &field1));
|
|
|
// }
|
|
|
// else if (strcmp("RB3_BZJRevision", itemType) == 0 || strcmp("RB3_BZJBJRevision", itemType) == 0
|
|
|
// || strcmp("RB3_YZRevision", itemType) == 0 || strcmp("RB3_GQRevision", itemType) == 0
|
|
|
// || strcmp("RB3_GQBJRevision", itemType) == 0 || strcmp("RB3_GZRevision", itemType) == 0
|
|
|
// || strcmp("RB3_GZBJRevision", itemType) == 0)
|
|
|
// {
|
|
|
// ITKCALL(AOM_UIF_ask_value(attachments[i], "object_name", &field1));
|
|
|
// }
|
|
|
// else if (strcmp("RB3_YCLRevision", itemType) == 0 || strcmp("RB3_SLRevision", itemType) == 0
|
|
|
// || strcmp("RB3_XJRevision", itemType) == 0 || strcmp("RB3_WJTLRevision", itemType) == 0)
|
|
|
// {
|
|
|
// ITKCALL(AOM_UIF_ask_value(attachments[i], "rb3_bjlx", &field1));
|
|
|
// }
|
|
|
// else if (strcmp("RB3_XZCPRevision", itemType) == 0)
|
|
|
// {
|
|
|
// ITKCALL(AOM_UIF_ask_value(attachments[i], "rb3_cplx2", &field1));
|
|
|
// }
|
|
|
// else if (strcmp("RB3_XZLBJRevision", itemType) == 0 && ico_tag != NULLTAG)
|
|
|
// {
|
|
|
// char* value = NULL;
|
|
|
// ICS_ask_attribute_value(ico_tag, "零件类别", &value);
|
|
|
// if (value != NULL) {
|
|
|
// int id = attrMap["零件类别"];
|
|
|
// getClassValue(value, id, &field1);
|
|
|
// DOFREE(value);
|
|
|
// }
|
|
|
// }
|
|
|
// if (field1 != NULL) {
|
|
|
// sprintf(sql, "select PCLASSCODE,PCLASSNAME,NEW_COLUMN,PUNIT from PLM_ERP_CLASS_TABLE where PFIELD01= '%s'", field1);
|
|
|
// }
|
|
|
// }
|
|
|
// if (strcmp("", sql) != 0) {
|
|
|
// printf("提示:sql==%s\n", sql);
|
|
|
// if (QuerySQLNoInputParam(sql, &outputColumn, &outputValueCount, &outputValue) == -1 || outputValueCount == 0)
|
|
|
// {
|
|
|
// printf("提示:物料分类查询 失败, %s \n", sql);
|
|
|
// char sql2[1024] = "\0";
|
|
|
// sprintf(sql2, "select PCLASSCODE,PCLASSNAME,NEW_COLUMN,PUNIT from PLM_ERP_CLASS_TABLE where PFIELD01= '%s'", field1);
|
|
|
// if (QuerySQLNoInputParam(sql2, &outputColumn, &outputValueCount, &outputValue) == -1)
|
|
|
// {
|
|
|
// printf("提示:物料分类查询 失败, %s \n", sql2);
|
|
|
// }
|
|
|
// }
|
|
|
// printf("outputValueCount=%d\n", outputValueCount);
|
|
|
// printf("outputColumn=%d\n", outputColumn);
|
|
|
// //free(sql);
|
|
|
// if (outputValueCount > 0) {
|
|
|
// classCode = outputValue[0][0];
|
|
|
// className = outputValue[0][1];
|
|
|
// organization = outputValue[0][2];
|
|
|
// punit = outputValue[0][3];
|
|
|
// printf("物料分类====%s\n", classCode);
|
|
|
// printf("物料名称====%s\n", className);
|
|
|
// printf("组织====%s\n", organization);
|
|
|
// printf("单位====%s\n", punit);
|
|
|
// }
|
|
|
// }
|
|
|
// //采购分类特殊处理,通过数据库表匹配
|
|
|
// //
|
|
|
// //
|
|
|
// //工厂组织编码特殊处理,通过数据库表匹配
|
|
|
// char** factorys = NULL;
|
|
|
// int factoryCount = 0;
|
|
|
// if (strcmp("RB3_XZCPRevision", itemType) == 0 || strcmp("RB3_XZLBJRevision", itemType) == 0) {
|
|
|
// ITKCALL(AOM_UIF_ask_values(attachments[i], "rb3_xzscgc", &factoryCount, &factorys));
|
|
|
// }
|
|
|
// else if (strcmp("RB3_GNZCRevision", itemType) == 0 || strcmp("RB3_GNLBJRevision", itemType) == 0
|
|
|
// || strcmp("RB3_GYZYRevision", itemType) == 0 || strcmp("RB3_BZJRevision", itemType) == 0) {
|
|
|
// ITKCALL(AOM_UIF_ask_values(attachments[i], "rb3_scgc", &factoryCount, &factorys));
|
|
|
// }
|
|
|
// else if (strcmp("RB3_YCLRevision", itemType) == 0) {
|
|
|
// ITKCALL(AOM_UIF_ask_values(attachments[i], "rb3_sygc1", &factoryCount, &factorys));
|
|
|
// }
|
|
|
// else {
|
|
|
// ITKCALL(AOM_UIF_ask_values(attachments[i], "rb3_scgc1", &factoryCount, &factorys));
|
|
|
// }
|
|
|
// printf("factoryCount=%d\n", factoryCount);
|
|
|
// for (int j = 0; j < factoryCount; j++)
|
|
|
// {
|
|
|
// char*** factoryValue = NULL;
|
|
|
// int factoryColumn = 0, factoryValueCount = 0;
|
|
|
// char factorySql[128] = "\0";
|
|
|
// printf("factorys[j]==%s\n", factorys[j]);
|
|
|
// sprintf(factorySql, "select PFACTORYCODE from PLM_ERP_FACTORY_TABLE where PFACTORY= '%s'", factorys[j]);
|
|
|
// printf("提示:factorySql==%s\n", factorySql);
|
|
|
// if (QuerySQLNoInputParam(factorySql, &factoryColumn, &factoryValueCount, &factoryValue) == -1)
|
|
|
// {
|
|
|
// printf("提示:组织编码查询 失败, %s \n", factorySql);
|
|
|
// }
|
|
|
// printf("factoryValueCount=%d\n", factoryValueCount);
|
|
|
// printf("factoryColumn=%d\n", factoryColumn);
|
|
|
// //free(sql);
|
|
|
// if (factoryValueCount > 0) {
|
|
|
// if (strcmp("", factoryCode) != 0) {
|
|
|
// strcat(factoryCode, ",");
|
|
|
// }
|
|
|
// strcat(factoryCode, factoryValue[0][0]);
|
|
|
// printf("组织编码====%s\n", factoryCode);
|
|
|
// }
|
|
|
// if (factoryValue != NULL) {
|
|
|
// DOFREE(factoryValue);
|
|
|
// }
|
|
|
// }
|
|
|
//
|
|
|
// if (factorys != NULL) {
|
|
|
// DOFREE(factorys);
|
|
|
// }
|
|
|
// if (outputValue != NULL) {
|
|
|
// DOFREE(outputValue);
|
|
|
// }
|
|
|
// if (field1 != NULL) {
|
|
|
// DOFREE(field1);
|
|
|
// }
|
|
|
// if (field2 != NULL) {
|
|
|
// DOFREE(field2);
|
|
|
// }
|
|
|
// }
|
|
|
// if (factoryCode != NULL) {
|
|
|
// strcat(parameters, "\"orgCode\":\"");
|
|
|
// strcat(parameters, factoryCode);
|
|
|
// if (organization != NULL) {
|
|
|
// strcat(parameters, ",");
|
|
|
// strcat(parameters, organization);
|
|
|
// }
|
|
|
// strcat(parameters, "\",");
|
|
|
// }
|
|
|
// strcat(parameters, "\"manageClassCode\":\"");
|
|
|
// if (classCode != NULL) {
|
|
|
// strcat(parameters, classCode);
|
|
|
// }
|
|
|
// strcat(parameters, "\",");
|
|
|
// // 使用迭代器遍历map
|
|
|
// int index = 0;
|
|
|
// for (std::map<string, string>::iterator it = propMap.begin(); it != propMap.end(); ++it) {
|
|
|
// string key = it->first;
|
|
|
// string attr = it->second;
|
|
|
// printf("key: %s \n", key.c_str());
|
|
|
// printf("attr: %s \n", attr.c_str());
|
|
|
// if (strcmp("orgCode", key.c_str()) == 0) {
|
|
|
// index++;
|
|
|
// continue;
|
|
|
// }
|
|
|
// if (strstr(attr.c_str(), ".") != NULL)
|
|
|
// {
|
|
|
// int attrCount = 0;
|
|
|
// char** attrChar = new char* [128];
|
|
|
// char* attrName = new char[2048];//足够长
|
|
|
// strcpy(attrName, attr.c_str());
|
|
|
// printf("attrName: %s \n", attrName);
|
|
|
// //分割字符串
|
|
|
// split(attrName, ".", attrChar, &attrCount);
|
|
|
// char* value = NULL;
|
|
|
// if (strcmp("rev", attrChar[0]) == 0) {
|
|
|
// //单位特殊处理
|
|
|
// if (strcmp("uom_tag", attrChar[1]) == 0)
|
|
|
// {
|
|
|
// tag_t item = NULLTAG;
|
|
|
// ITKCALL(ITEM_ask_item_of_rev(attachments[i], &item));
|
|
|
// tag_t unitTag = NULLTAG;
|
|
|
// ITKCALL(AOM_ask_value_tag(item, attrChar[1], &unitTag));
|
|
|
// if (unitTag != NULL) {
|
|
|
// ITKCALL(AOM_UIF_ask_value(unitTag, "object_string", &value));
|
|
|
// printf("uom_tag: %s \n", value);
|
|
|
// //单位换算
|
|
|
// // 特定物料分类单位换算:滚动体计量单位:L(粒)转WL(万粒);油脂的计量单位:GM(克) 转KG(千克);钢材,钢管计量单位:GM(克)转T(吨)
|
|
|
// if (className != NULL) {
|
|
|
// if (strcmp("滚动体", className) == 0 && strcmp("L(粒)", value) == 0)
|
|
|
// {
|
|
|
// value = "WL(万粒)";
|
|
|
// }
|
|
|
// else if (strcmp("油脂", className) == 0 && strcmp("GM(克)", value) == 0)
|
|
|
// {
|
|
|
// value = "KG(千克)";
|
|
|
// }if ((strcmp("钢材", className) == 0 || strcmp("钢管", className) == 0) && strcmp("GM(克)", value) == 0)
|
|
|
// {
|
|
|
// value = "T(吨)";
|
|
|
// }
|
|
|
// }
|
|
|
// strcat(parameters, "\"");
|
|
|
// strcat(parameters, key.c_str());
|
|
|
// strcat(parameters, "\":\"");
|
|
|
// if (unitMap.find(value) != unitMap.end()) {
|
|
|
// strcat(parameters, unitMap[value].c_str());
|
|
|
// }
|
|
|
// else {
|
|
|
// strcat(parameters, value);
|
|
|
// }
|
|
|
// strcat(parameters, "\"");
|
|
|
// }
|
|
|
// else {
|
|
|
// strcat(parameters, "\"");
|
|
|
// strcat(parameters, key.c_str());
|
|
|
// strcat(parameters, "\":\"");
|
|
|
// if (punit != NULL) {
|
|
|
// strcat(parameters, punit);
|
|
|
// }
|
|
|
// strcat(parameters, "\"");
|
|
|
//
|
|
|
// }
|
|
|
// if (item != NULL) {
|
|
|
// DOFREE(item);
|
|
|
// }
|
|
|
// if (unitTag != NULL) {
|
|
|
// DOFREE(unitTag);
|
|
|
// }
|
|
|
//
|
|
|
// }
|
|
|
// //重量特殊处理
|
|
|
// else if (strcmp("netWeight", key.c_str()) == 0)
|
|
|
// {
|
|
|
// strcat(parameters, "\"netWeightUnitCode\":\"KG\",");
|
|
|
// ITKCALL(AOM_UIF_ask_value(attachments[i], attrChar[1], &value));
|
|
|
// if (value != NULL && strcmp("", value) != 0) {
|
|
|
// double dValue = std::stod(value);
|
|
|
// dValue = dValue * 10000;
|
|
|
// long lValue = static_cast<long>(dValue); // 转换为long
|
|
|
// strcat(parameters, "\"");
|
|
|
// strcat(parameters, key.c_str());
|
|
|
// strcat(parameters, "\":");
|
|
|
// char netWeight[64] = "\0";
|
|
|
// sprintf(netWeight, "%d", lValue);
|
|
|
// strcat(parameters, netWeight);
|
|
|
// }
|
|
|
// else {
|
|
|
// strcat(parameters, "\"");
|
|
|
// strcat(parameters, key.c_str());
|
|
|
// strcat(parameters, "\":0");
|
|
|
// }
|
|
|
// }
|
|
|
// //生命周期特殊处理
|
|
|
// else if (strcmp("material_status", key.c_str()) == 0)
|
|
|
// {
|
|
|
// ITKCALL(AOM_UIF_ask_value(attachments[i], attrChar[1], &value));
|
|
|
// strcat(parameters, "\"");
|
|
|
// strcat(parameters, key.c_str());
|
|
|
// strcat(parameters, "\":\"");
|
|
|
// if (smzqMap.find(value) != smzqMap.end()) {
|
|
|
// strcat(parameters, smzqMap[value].c_str());
|
|
|
// }
|
|
|
// else {
|
|
|
// strcat(parameters, value);
|
|
|
// }
|
|
|
// strcat(parameters, "\"");
|
|
|
// }
|
|
|
// else {
|
|
|
// ITKCALL(AOM_UIF_ask_value(attachments[i], attrChar[1], &value));
|
|
|
// strcat(parameters, "\"");
|
|
|
// strcat(parameters, key.c_str());
|
|
|
// strcat(parameters, "\":\"");
|
|
|
// strcat(parameters, value);
|
|
|
// strcat(parameters, "\"");
|
|
|
// }
|
|
|
// }
|
|
|
// else {
|
|
|
// if (ico_tag != NULLTAG) {
|
|
|
// if (strstr(attrChar[1], "&") != NULL)
|
|
|
// {
|
|
|
// int attrNum = 0;
|
|
|
// char** allAttrs = new char* [128];
|
|
|
// //分割字符串
|
|
|
// split(attrChar[1], "&", allAttrs, &attrNum);
|
|
|
// char values[256] = "";//多个属性拼接
|
|
|
// for (int i = 0; i < attrNum; i++)
|
|
|
// {
|
|
|
// if (attrMap.find(allAttrs[i]) != attrMap.end())
|
|
|
// {
|
|
|
// ICS_ask_attribute_value(ico_tag, allAttrs[i], &value);
|
|
|
// DOFREE(disValue);
|
|
|
// if (value != NULL) {
|
|
|
// int id = attrMap[allAttrs[i]];
|
|
|
// char* disValue;
|
|
|
// getClassValue(value, id, &disValue);
|
|
|
// strcat(values, disValue);
|
|
|
// DOFREE(disValue);
|
|
|
// }
|
|
|
// else {
|
|
|
// strcat(values, "");
|
|
|
// }
|
|
|
// }
|
|
|
// else {
|
|
|
// strcat(values, "");
|
|
|
// }
|
|
|
// }
|
|
|
// strcat(parameters, "\"");
|
|
|
// strcat(parameters, key.c_str());
|
|
|
// strcat(parameters, "\":\"");
|
|
|
// strcat(parameters, values);
|
|
|
// strcat(parameters, "\"");
|
|
|
// DOFREE(allAttrs);
|
|
|
// }
|
|
|
// else {
|
|
|
// //保持架板厚特殊处理
|
|
|
// if (strcmp("CU0261", key.c_str()) == 0)
|
|
|
// {
|
|
|
// if (attrMap.find("保持架板厚(mm)") != attrMap.end())
|
|
|
// {
|
|
|
// attrChar[1] = "保持架板厚(mm)";
|
|
|
// }
|
|
|
// else if (attrMap.find("冲压保持架板厚(mm)") != attrMap.end())
|
|
|
// {
|
|
|
// attrChar[1] = "冲压保持架板厚(mm)";
|
|
|
// }
|
|
|
// else if (attrMap.find("保持架板厚(铁保)") != attrMap.end())
|
|
|
// {
|
|
|
// attrChar[1] = "保持架板厚(铁保)";
|
|
|
// }
|
|
|
// }
|
|
|
// //密封颜色特殊处理
|
|
|
// else if (strcmp("CU0262", key.c_str()) == 0)
|
|
|
// {
|
|
|
// if (attrMap.find("密封颜色") != attrMap.end())
|
|
|
// {
|
|
|
// //printf("1111\n");
|
|
|
// attrChar[1] = "密封颜色";
|
|
|
// }
|
|
|
// else if (attrMap.find("密封颜色(带轮端)") != attrMap.end())
|
|
|
// {
|
|
|
// attrChar[1] = "密封颜色(带轮端)";
|
|
|
// }
|
|
|
// else if (attrMap.find("(内密封件颜色)") != attrMap.end())
|
|
|
// {
|
|
|
// attrChar[1] = "(内密封件颜色)";
|
|
|
// }
|
|
|
// }
|
|
|
// //密封材料特殊处理
|
|
|
// else if (strcmp("CU0263", key.c_str()) == 0)
|
|
|
// {
|
|
|
// if (attrMap.find("密封材料") != attrMap.end())
|
|
|
// {
|
|
|
// //printf("2222\n");
|
|
|
// attrChar[1] = "密封材料";
|
|
|
// }
|
|
|
// else if (attrMap.find("密封材料(带轮端)") != attrMap.end())
|
|
|
// {
|
|
|
// attrChar[1] = "密封材料(带轮端)";
|
|
|
// }
|
|
|
// else if (attrMap.find("(内密封件材料)") != attrMap.end())
|
|
|
// {
|
|
|
// attrChar[1] = "(内密封件材料)";
|
|
|
// }
|
|
|
// }
|
|
|
// //printf("attrChar[1] = %s \n", attrChar[1]);
|
|
|
// if (attrMap.find(attrChar[1]) != attrMap.end())
|
|
|
// {
|
|
|
// ICS_ask_attribute_value(ico_tag, attrChar[1], &value);
|
|
|
// if (value != NULL && strcmp(value,"") != 0 && strcmp(value, " ") != 0) {
|
|
|
// int id = attrMap[attrChar[1]];
|
|
|
// char* disValue;
|
|
|
// getClassValue(value, id, &disValue);
|
|
|
// /* printf("id = %d \n", id);
|
|
|
// printf("disValue = %s \n", disValue);*/
|
|
|
// strcat(parameters, "\"");
|
|
|
// strcat(parameters, key.c_str());
|
|
|
// strcat(parameters, "\":\"");
|
|
|
// strcat(parameters, disValue);
|
|
|
// strcat(parameters, "\"");
|
|
|
// DOFREE(disValue);
|
|
|
// }
|
|
|
// else {
|
|
|
// strcat(parameters, "\"");
|
|
|
// strcat(parameters, key.c_str());
|
|
|
// strcat(parameters, "\":\"\"");
|
|
|
// }
|
|
|
// }
|
|
|
// else {
|
|
|
// strcat(parameters, "\"");
|
|
|
// strcat(parameters, key.c_str());
|
|
|
// strcat(parameters, "\":\"\"");
|
|
|
// }
|
|
|
// }
|
|
|
// }
|
|
|
// else {
|
|
|
// strcat(parameters, "\"");
|
|
|
// strcat(parameters, key.c_str());
|
|
|
// strcat(parameters, "\":\"\"");
|
|
|
// }
|
|
|
// }
|
|
|
// printf("value: %s \n", value);
|
|
|
// DOFREE(value);
|
|
|
// DOFREE(attrChar);
|
|
|
// DOFREE(attrName);
|
|
|
// }
|
|
|
// else {
|
|
|
// if (strcmp("CU0266", key.c_str()) == 0 && strcmp("RB3_LBJRevision", itemType) == 0 && ico_tag != NULLTAG)
|
|
|
// {
|
|
|
// printf("零部件特殊处理\n");
|
|
|
// char* value = NULL;
|
|
|
// if (attrMap.find("类别") != attrMap.end())
|
|
|
// {
|
|
|
// printf("类别 : %s \n", value);
|
|
|
// ICS_ask_attribute_value(ico_tag, "类别", &value);
|
|
|
// if (value != NULL) {
|
|
|
// int id = attrMap["类别"];
|
|
|
// char* disValue;
|
|
|
// getClassValue(value, id, &disValue);
|
|
|
// printf("disValue : %s \n", disValue);
|
|
|
// if (strcmp("C:车工件", disValue) == 0) {
|
|
|
// tag_t parentClass = NULLTAG;
|
|
|
// char* parentClassId = NULL;
|
|
|
// char* parentClassName = NULL;
|
|
|
// ITKCALL(ICS_class_ask_parent(classId, &parentClass, &parentClassId));
|
|
|
// if (parentClass != NULLTAG) {
|
|
|
// ITKCALL(ICS_ask_id_name(parentClass, &parentClassId, &parentClassName));
|
|
|
// strcat(parameters, "\"");
|
|
|
// strcat(parameters, key.c_str());
|
|
|
// strcat(parameters, "\":\"");
|
|
|
// strcat(parameters, parentClassName);
|
|
|
// strcat(parameters, "\"");
|
|
|
// }
|
|
|
// else {
|
|
|
// strcat(parameters, "\"");
|
|
|
// strcat(parameters, key.c_str());
|
|
|
// strcat(parameters, "\":\"\"");
|
|
|
// }
|
|
|
// DOFREE(parentClass);
|
|
|
// DOFREE(parentClassId);
|
|
|
// DOFREE(parentClassName);
|
|
|
// }
|
|
|
// else {
|
|
|
// strcat(parameters, "\"");
|
|
|
// strcat(parameters, key.c_str());
|
|
|
// strcat(parameters, "\":\"\"");
|
|
|
// }
|
|
|
// DOFREE(disValue);
|
|
|
// }
|
|
|
// else {
|
|
|
// strcat(parameters, "\"");
|
|
|
// strcat(parameters, key.c_str());
|
|
|
// strcat(parameters, "\":\"\"");
|
|
|
// }
|
|
|
// }
|
|
|
// else
|
|
|
// {
|
|
|
// strcat(parameters, "\"");
|
|
|
// strcat(parameters, key.c_str());
|
|
|
// strcat(parameters, "\":\"\"");
|
|
|
// }
|
|
|
// DOFREE(value);
|
|
|
// }//重量特殊处理
|
|
|
// else if (strcmp("netWeight", key.c_str()) == 0)
|
|
|
// {
|
|
|
// strcat(parameters, "\"netWeightUnitCode\":\"KG\",");
|
|
|
// strcat(parameters, "\"");
|
|
|
// strcat(parameters, key.c_str());
|
|
|
// strcat(parameters, "\":0");
|
|
|
// }
|
|
|
// else
|
|
|
// {
|
|
|
// printf("key: %s 默认为空值\n", key.c_str());
|
|
|
// strcat(parameters, "\"");
|
|
|
// strcat(parameters, key.c_str());
|
|
|
// strcat(parameters, "\":\"\"");
|
|
|
// }
|
|
|
// }
|
|
|
// if (index < propMap.size() - 1)
|
|
|
// {
|
|
|
// strcat(parameters, ",");
|
|
|
// }
|
|
|
// if (classId != NULL) {
|
|
|
// DOFREE(classId);
|
|
|
// }
|
|
|
// if (ico_tag != NULL) {
|
|
|
// DOFREE(ico_tag);
|
|
|
// }
|
|
|
// if (classCode != NULL) {
|
|
|
// DOFREE(classCode);
|
|
|
// }
|
|
|
// if (className != NULL) {
|
|
|
// DOFREE(className);
|
|
|
// }
|
|
|
// if (organization != NULL) {
|
|
|
// DOFREE(organization);
|
|
|
// }
|
|
|
// if (punit != NULL) {
|
|
|
// DOFREE(punit);
|
|
|
// }
|
|
|
// index++;
|
|
|
// }
|
|
|
// strcat(parameters, "}");
|
|
|
// attrMap.clear();
|
|
|
// }
|
|
|
// DOFREE(itemType);
|
|
|
// }
|
|
|
// DisConnServer();
|
|
|
// strcat(parameters, "]");
|
|
|
// //printf("parameters: %s\n", parameters);
|
|
|
// //把数据用写入文件
|
|
|
// char data_file[SS_MAXPATHLEN] = "";
|
|
|
// strcat(data_file, tc_root_file);
|
|
|
// strcat(data_file, "\\");
|
|
|
// strcat(data_file, date);
|
|
|
// strcat(data_file, ".txt");
|
|
|
// printf("data_file: %s\n", data_file);
|
|
|
// ofstream file;
|
|
|
// file.open(data_file);
|
|
|
// file << parameters << endl; // 使用与cout同样的方式进行写入
|
|
|
// file.close();
|
|
|
//
|
|
|
// string strResult;
|
|
|
//
|
|
|
// //cmd指令
|
|
|
// char cmd[256] = "";
|
|
|
// strcpy(cmd, "java -jar \"");
|
|
|
// strcat(cmd, tc_root_file);
|
|
|
// strcat(cmd, "\\portal\\plugins\\");
|
|
|
// strcat(cmd, "RB_SendErp_New.jar");
|
|
|
// strcat(cmd, "\" ");
|
|
|
// //传参
|
|
|
// //cout << data_file << endl;
|
|
|
// strcat(cmd, data_file);
|
|
|
// //用来传递本流程的流程名称(@分割)
|
|
|
// strcat(cmd, "@WL");
|
|
|
// //printf("路径:\n%s\n", cmd);
|
|
|
// char buf[8000] = { 0 };
|
|
|
// FILE* pf = NULL;
|
|
|
// if ((pf = _popen(cmd, "r")) == NULL) {
|
|
|
// printf("接口返回:\n%s", "1");
|
|
|
// }
|
|
|
//
|
|
|
// while (fgets(buf, sizeof buf, pf)) {
|
|
|
// strResult += buf;
|
|
|
// }
|
|
|
// _pclose(pf);
|
|
|
//
|
|
|
// cout << strResult << endl;
|
|
|
// unsigned int iSize = strResult.size();
|
|
|
// if (iSize > 0 && strResult[iSize - 1] == '\n' && strlen(parameters) > 0)
|
|
|
// {
|
|
|
//
|
|
|
// strResult = strResult.substr(0, iSize - 1);
|
|
|
// printf("下发失败\n");
|
|
|
// cout << strResult << endl;
|
|
|
// }
|
|
|
// printf("ifail: %d\n", ifail);
|
|
|
// if (attachments != NULL) {
|
|
|
// MEM_free(attachments);
|
|
|
// }
|
|
|
// if (pref_vals != NULL) {
|
|
|
// MEM_free(pref_vals);
|
|
|
// }
|
|
|
// //if (tc_root_file != NULL) {
|
|
|
// // MEM_free(tc_root_file);
|
|
|
// //}
|
|
|
// printf("=========================对象下发到ERP End===================\n");
|
|
|
// return ifail;
|
|
|
//}
|
|
|
|
|
|
int RB_SendErpItem_New(EPM_action_message_t msg)
|
|
|
{
|
|
|
printf("=========================对象下发到ERP Start===================\n");
|
|
|
//POM_AM__set_application_bypass(true);
|
|
|
int ifail = ITK_ok;
|
|
|
int attachments_num = 0;
|
|
|
tag_t rootTask = NULLTAG, * attachments = NULLTAG;
|
|
|
//获取任务对象
|
|
|
EPM_ask_root_task(msg.task, &rootTask);
|
|
|
//获取任务目标对象
|
|
|
EPM_ask_attachments(rootTask, EPM_target_attachment, &attachments_num, &attachments);
|
|
|
int pref_cnt = 0;
|
|
|
char** pref_vals = NULL;
|
|
|
//获取首选项的值
|
|
|
PREF_ask_char_values("RB_ItemSendErp_Type_Attr", &pref_cnt, &pref_vals);
|
|
|
map<string, map<string, string>> itemTypeMap;
|
|
|
map<string, string> typePropertyType;
|
|
|
for (int i = 0; i < pref_cnt; i++)
|
|
|
{
|
|
|
if (strstr(pref_vals[i], ":") != NULL)
|
|
|
{
|
|
|
//按照-进行拆分。拆分条件
|
|
|
int valueCount = 0;
|
|
|
char** valueChar = new char* [64];
|
|
|
//分割字符串
|
|
|
split(pref_vals[i], ":", valueChar, &valueCount);
|
|
|
if (strstr(valueChar[1], "|") != NULL)
|
|
|
{
|
|
|
int attrCount = 0;
|
|
|
char** attrChar = new char* [128];
|
|
|
//分割字符串
|
|
|
split(valueChar[1], "|", attrChar, &attrCount);
|
|
|
for (int j = 0; j < attrCount; j++)
|
|
|
{
|
|
|
if (strstr(attrChar[j], "=") != NULL)
|
|
|
{
|
|
|
int count = 0;
|
|
|
char** attrs = new char* [64];
|
|
|
//分割字符串
|
|
|
split(attrChar[j], "=", attrs, &count);
|
|
|
typePropertyType[attrs[0]] = attrs[1];
|
|
|
DOFREE(attrs);
|
|
|
}
|
|
|
}
|
|
|
DOFREE(attrChar);
|
|
|
}
|
|
|
itemTypeMap[valueChar[0]] = typePropertyType;
|
|
|
typePropertyType.clear();
|
|
|
DOFREE(valueChar);
|
|
|
|
|
|
}
|
|
|
}
|
|
|
int unit_pref_cnt = 0;
|
|
|
char** unit_pref_vals = NULL;
|
|
|
//获取首选项的值
|
|
|
PREF_ask_char_values("RB_SEND_UNIT_MATCHING", &unit_pref_cnt, &unit_pref_vals);
|
|
|
map<string, string> unitMap;
|
|
|
for (int i = 0; i < unit_pref_cnt; i++)
|
|
|
{
|
|
|
if (strstr(unit_pref_vals[i], "=") != NULL)
|
|
|
{
|
|
|
//按照-进行拆分。拆分条件
|
|
|
int valueCount = 0;
|
|
|
char** valueChar = new char* [64];
|
|
|
//分割字符串
|
|
|
split(unit_pref_vals[i], "=", valueChar, &valueCount);
|
|
|
unitMap[valueChar[0]] = valueChar[1];
|
|
|
DOFREE(valueChar);
|
|
|
}
|
|
|
}
|
|
|
int smzq_pref_cnt = 0;
|
|
|
char** smzq_pref_vals = NULL;
|
|
|
//获取首选项的值
|
|
|
PREF_ask_char_values("RB3_WL_SMZQ", &smzq_pref_cnt, &smzq_pref_vals);
|
|
|
map<string, string> smzqMap;
|
|
|
for (int i = 0; i < smzq_pref_cnt; i++)
|
|
|
{
|
|
|
if (strstr(smzq_pref_vals[i], "=") != NULL)
|
|
|
{
|
|
|
//按照-进行拆分。拆分条件
|
|
|
int valueCount = 0;
|
|
|
char** valueChar = new char* [64];
|
|
|
//分割字符串
|
|
|
split(smzq_pref_vals[i], "=", valueChar, &valueCount);
|
|
|
smzqMap[valueChar[0]] = valueChar[1];
|
|
|
DOFREE(valueChar);
|
|
|
}
|
|
|
}
|
|
|
int c_sql_value_count = 0;
|
|
|
char** c_sql_values;
|
|
|
ITKCALL(PREF_ask_char_values("RB3_SQL_Connect2", &c_sql_value_count, &c_sql_values));
|
|
|
if (c_sql_value_count != 3)
|
|
|
{
|
|
|
printf("首选项 RB3_SQL_Connect2 配置错误 数量%d ", c_sql_value_count);
|
|
|
return 1;
|
|
|
}
|
|
|
|
|
|
char* tc_root_file = getenv("tc_root"); //C:\Siemens\Teamcenter11
|
|
|
//+++
|
|
|
char parameters[100000] = "";//写入到文件的值
|
|
|
strcat(parameters, "[");
|
|
|
//获取当前时间
|
|
|
time_t now = time(0);
|
|
|
tm* p = localtime(&now);
|
|
|
char date[128] = "";
|
|
|
sprintf_s(date, "%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);
|
|
|
|
|
|
//"tc11","infodba","//172.16.50.40/tc11" "TC12","infodba","172.16.68.13/tc1"
|
|
|
int status = ConnServer(c_sql_values[1], c_sql_values[2], c_sql_values[0]);
|
|
|
printf("status:%d\n", status);
|
|
|
map<string, map<string, int>> classMap;
|
|
|
for (int i = 0; i < attachments_num; i++)
|
|
|
{
|
|
|
char* itemType = NULL;
|
|
|
char* itemId1 = NULL;
|
|
|
AOM_ask_value_string(attachments[i], "item_id", &itemId1);
|
|
|
AOM_ask_value_string(attachments[i], "object_type", &itemType);
|
|
|
printf("itemType:%s\n", itemType);
|
|
|
printf("itemId1:%s\n", itemId1);
|
|
|
DOFREE(itemId1);
|
|
|
//过滤掉非版本的对象
|
|
|
if ((strstr(itemType, "Revision") == NULL) || (strstr(itemType, "Master") != NULL)
|
|
|
|| (strstr(itemType, "master") != NULL) || (strstr(itemType, "BOM") != NULL) || (strstr(itemType, "bom") != NULL) || (strstr(itemType, "Bom") != NULL))
|
|
|
{
|
|
|
DOFREE(itemType);
|
|
|
continue;
|
|
|
}
|
|
|
if (itemTypeMap.find(itemType) != itemTypeMap.end()) {
|
|
|
map<string, string> propMap = itemTypeMap[itemType];
|
|
|
if (strstr(parameters, "[{") != NULL) {
|
|
|
strcat(parameters, ",");
|
|
|
}
|
|
|
strcat(parameters, "{");
|
|
|
tag_t ico_tag = NULLTAG;
|
|
|
char* classId = NULL;
|
|
|
map<string, int> attrMap;
|
|
|
ICS_ask_classification_object(attachments[i], &ico_tag);
|
|
|
if (ico_tag != NULLTAG) {
|
|
|
ICS_ico_ask_class(ico_tag, &classId);
|
|
|
printf(">> classId: %s\n", classId);
|
|
|
//分类属性名称对应id map存储
|
|
|
if (classMap.find(classId) == classMap.end()) {
|
|
|
int count = 0;
|
|
|
int* ids;
|
|
|
int* arraySize;
|
|
|
int* formats;
|
|
|
int* options;
|
|
|
char** names;
|
|
|
char** shortNames;
|
|
|
char** annotations;
|
|
|
char** unit;
|
|
|
char** minValues;
|
|
|
char** maxValues;
|
|
|
char** defaultValues;
|
|
|
char** descriptions;
|
|
|
ITKCALL(ICS_class_describe_attributes(classId, &count, &ids, &names, &shortNames, &annotations, &arraySize,
|
|
|
&formats, &unit, &minValues, &maxValues, &defaultValues, &descriptions, &options));
|
|
|
for (int i = 0; i < count; i++)
|
|
|
{
|
|
|
attrMap.insert(pair<string, int>(names[i], ids[i]));
|
|
|
}
|
|
|
classMap.insert(pair<string, map<string, int>>(classId, attrMap));
|
|
|
if (ids != NULL) {
|
|
|
DOFREE(ids);
|
|
|
}
|
|
|
if (arraySize != NULL) {
|
|
|
DOFREE(arraySize);
|
|
|
}
|
|
|
if (formats != NULL) {
|
|
|
DOFREE(formats);
|
|
|
}
|
|
|
if (options != NULL) {
|
|
|
DOFREE(options);
|
|
|
}
|
|
|
if (names != NULL) {
|
|
|
DOFREE(names);
|
|
|
}
|
|
|
if (shortNames != NULL) {
|
|
|
DOFREE(shortNames);
|
|
|
}
|
|
|
if (annotations != NULL) {
|
|
|
DOFREE(annotations);
|
|
|
}
|
|
|
if (unit != NULL) {
|
|
|
DOFREE(unit);
|
|
|
}
|
|
|
if (minValues != NULL) {
|
|
|
DOFREE(minValues);
|
|
|
}
|
|
|
if (maxValues != NULL) {
|
|
|
DOFREE(maxValues);
|
|
|
}
|
|
|
if (defaultValues != NULL) {
|
|
|
DOFREE(defaultValues);
|
|
|
}
|
|
|
if (descriptions != NULL) {
|
|
|
DOFREE(descriptions);
|
|
|
}
|
|
|
}
|
|
|
else {
|
|
|
attrMap = classMap[classId];
|
|
|
}
|
|
|
}
|
|
|
|
|
|
char* classCode = NULL;
|
|
|
char* cgCode = NULL;
|
|
|
char* className = NULL;
|
|
|
char* organization = NULL;
|
|
|
char* punit = NULL;
|
|
|
char factoryCode[2048] = "\0";
|
|
|
//这里写服务名,不能用实例名(名称相同除外)
|
|
|
if (status)
|
|
|
{
|
|
|
printf("提示:中间数据表访问失败\n");
|
|
|
}
|
|
|
else {
|
|
|
char* field1 = NULL;
|
|
|
char* field2 = NULL;
|
|
|
int outputColumn = 0, outputValueCount = 0;
|
|
|
char*** outputValue = NULL;
|
|
|
printf("提示:中间数据表访问成功\n");
|
|
|
//物料分类特殊处理,通过数据库表匹配
|
|
|
char sql[256] = "\0";
|
|
|
if (strcmp("RB3_LBJRevision", itemType) == 0 || strcmp("RB3_GNZCRevision", itemType) == 0
|
|
|
|| strcmp("RB3_GNLBJRevision", itemType) == 0 || strcmp("RB3_GYZYRevision", itemType) == 0 || strcmp("RB3_YCLRevision", itemType) == 0) {
|
|
|
if (strcmp("RB3_LBJRevision", itemType) == 0 && ico_tag != NULLTAG)
|
|
|
{
|
|
|
ITKCALL(AOM_UIF_ask_value(attachments[i], "object_name", &field1));
|
|
|
char* value = NULL;
|
|
|
ICS_ask_attribute_value(ico_tag, "类别", &value);
|
|
|
if (value != NULL) {
|
|
|
int id = attrMap["类别"];
|
|
|
getClassValue(value, id, &field2);
|
|
|
DOFREE(value);
|
|
|
}
|
|
|
}
|
|
|
else if (strcmp("RB3_GNZCRevision", itemType) == 0 && ico_tag != NULLTAG)
|
|
|
{
|
|
|
char* value = NULL;
|
|
|
ICS_ask_attribute_value(ico_tag, "产品类别", &value);
|
|
|
if (value != NULL) {
|
|
|
int id = attrMap["产品类别"];
|
|
|
getClassValue(value, id, &field1);
|
|
|
DOFREE(value);
|
|
|
}
|
|
|
ITKCALL(AOM_UIF_ask_value(attachments[i], "object_name", &field2));
|
|
|
}
|
|
|
else if (strcmp("RB3_GNLBJRevision", itemType) == 0 && ico_tag != NULLTAG)
|
|
|
{
|
|
|
ITKCALL(AOM_UIF_ask_value(attachments[i], "object_name", &field1));
|
|
|
char* value = NULL;
|
|
|
ICS_ask_attribute_value(ico_tag, "产品类别", &value);
|
|
|
if (value != NULL) {
|
|
|
int id = attrMap["产品类别"];
|
|
|
getClassValue(value, id, &field2);
|
|
|
DOFREE(value);
|
|
|
}
|
|
|
}
|
|
|
else if (strcmp("RB3_GYZYRevision", itemType) == 0 && ico_tag != NULLTAG)
|
|
|
{
|
|
|
char* new_classId = NULL;
|
|
|
if (startsWith(classId, '1', '2') || startsWith(classId, '1', '7'))
|
|
|
{
|
|
|
new_classId = getFirstStr(classId, 2);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
new_classId = getFirstStr(classId, 4);
|
|
|
}
|
|
|
tag_t classTag = NULLTAG;
|
|
|
char* id = NULL;
|
|
|
if (new_classId != NULL) {
|
|
|
ITKCALL(ICS_find_class(new_classId, &classTag));
|
|
|
if (classTag != NULLTAG)
|
|
|
{
|
|
|
ITKCALL(ICS_ask_id_name(classTag, &id, &field1));
|
|
|
}
|
|
|
}
|
|
|
if (id != NULL) {
|
|
|
DOFREE(id);
|
|
|
}
|
|
|
if (classTag != NULL) {
|
|
|
DOFREE(classTag);
|
|
|
}
|
|
|
if (new_classId != NULL) {
|
|
|
DOFREE(new_classId);
|
|
|
}
|
|
|
}
|
|
|
else if (strcmp("RB3_YCLRevision", itemType) == 0 && ico_tag != NULLTAG)
|
|
|
{
|
|
|
ITKCALL(AOM_UIF_ask_value(attachments[i], "rb3_bjlx", &field1));
|
|
|
char* value = NULL;
|
|
|
ICS_ask_attribute_value(ico_tag, "材料形状", &value);
|
|
|
if (value != NULL) {
|
|
|
int id = attrMap["材料形状"];
|
|
|
getClassValue(value, id, &field2);
|
|
|
DOFREE(value);
|
|
|
}
|
|
|
}
|
|
|
if (field1 != NULL) {
|
|
|
if (field1 != NULL && field2 != NULL) {
|
|
|
sprintf(sql, "select PCLASSCODE,PCLASSNAME,NEW_COLUMN,PUNIT from PLM_ERP_CLASS_TABLE where PTYPE= '%s' and PFIELD01= '%s' and PFIELD02= '%s'", itemType, field1, field2);
|
|
|
}
|
|
|
else {
|
|
|
sprintf(sql, "select PCLASSCODE,PCLASSNAME,NEW_COLUMN,PUNIT from PLM_ERP_CLASS_TABLE where PTYPE= '%s' and PFIELD01= '%s'", itemType, field1);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
else {
|
|
|
if (strcmp("RB3_ZCRevision", itemType) == 0)
|
|
|
{
|
|
|
ITKCALL(AOM_UIF_ask_value(attachments[i], "rb3_zclx", &field1));
|
|
|
}
|
|
|
else if (strcmp("RB3_BZJRevision", itemType) == 0 || strcmp("RB3_BZJBJRevision", itemType) == 0
|
|
|
|| strcmp("RB3_YZRevision", itemType) == 0 || strcmp("RB3_GQRevision", itemType) == 0
|
|
|
|| strcmp("RB3_GQBJRevision", itemType) == 0 || strcmp("RB3_GZRevision", itemType) == 0
|
|
|
|| strcmp("RB3_GZBJRevision", itemType) == 0)
|
|
|
{
|
|
|
ITKCALL(AOM_UIF_ask_value(attachments[i], "object_name", &field1));
|
|
|
}
|
|
|
else if (strcmp("RB3_SLRevision", itemType) == 0
|
|
|
|| strcmp("RB3_XJRevision", itemType) == 0 || strcmp("RB3_WJTLRevision", itemType) == 0)
|
|
|
{
|
|
|
ITKCALL(AOM_UIF_ask_value(attachments[i], "rb3_bjlx", &field1));
|
|
|
}
|
|
|
else if (strcmp("RB3_XZCPRevision", itemType) == 0)
|
|
|
{
|
|
|
ITKCALL(AOM_UIF_ask_value(attachments[i], "rb3_cplx2", &field1));
|
|
|
}
|
|
|
else if (strcmp("RB3_XZLBJRevision", itemType) == 0 && ico_tag != NULLTAG)
|
|
|
{
|
|
|
char* value = NULL;
|
|
|
ICS_ask_attribute_value(ico_tag, "零件类别", &value);
|
|
|
if (value != NULL) {
|
|
|
int id = attrMap["零件类别"];
|
|
|
getClassValue(value, id, &field1);
|
|
|
DOFREE(value);
|
|
|
}
|
|
|
}
|
|
|
if (field1 != NULL) {
|
|
|
sprintf(sql, "select PCLASSCODE,PCLASSNAME,NEW_COLUMN,PUNIT from PLM_ERP_CLASS_TABLE where PTYPE= '%s' and PFIELD01= '%s'", itemType, field1);
|
|
|
}
|
|
|
}
|
|
|
if (strcmp("", sql) != 0) {
|
|
|
printf("提示:sql==%s\n", sql);
|
|
|
if (QuerySQLNoInputParam(sql, &outputColumn, &outputValueCount, &outputValue) == -1 || outputValueCount == 0)
|
|
|
{
|
|
|
printf("提示:物料分类查询 失败, %s \n", sql);
|
|
|
char sql2[256] = "\0";
|
|
|
sprintf(sql2, "select PCLASSCODE,PCLASSNAME,NEW_COLUMN,PUNIT from PLM_ERP_CLASS_TABLE where PTYPE= '%s' and PFIELD01= '%s'", itemType, field1);
|
|
|
if (QuerySQLNoInputParam(sql2, &outputColumn, &outputValueCount, &outputValue) == -1)
|
|
|
{
|
|
|
printf("提示:物料分类查询 失败, %s \n", sql2);
|
|
|
}
|
|
|
}
|
|
|
printf("outputValueCount=%d\n", outputValueCount);
|
|
|
printf("outputColumn=%d\n", outputColumn);
|
|
|
//free(sql);
|
|
|
if (outputValueCount > 0) {
|
|
|
classCode = outputValue[0][0];
|
|
|
className = outputValue[0][1];
|
|
|
organization = outputValue[0][2];
|
|
|
punit = outputValue[0][3];
|
|
|
printf("物料分类====%s\n", classCode);
|
|
|
printf("物料名称====%s\n", className);
|
|
|
printf("组织====%s\n", organization);
|
|
|
printf("单位====%s\n", punit);
|
|
|
}
|
|
|
}
|
|
|
//采购分类特殊处理,通过数据库表匹配
|
|
|
//
|
|
|
|
|
|
char* limit_value = NULL;
|
|
|
char* object_name = NULL;
|
|
|
ITKCALL(AOM_UIF_ask_value(attachments[i], "object_name", &object_name));
|
|
|
char* cgField1 = NULL;
|
|
|
char* cgField2= NULL;
|
|
|
char* cgField3 = NULL;
|
|
|
char cgSql[256] = "\0";
|
|
|
char cgSql2[256] = "\0";
|
|
|
if (strcmp("RB3_YZRevision", itemType) == 0 || strcmp("RB3_BZJRevision", itemType) == 0) {
|
|
|
//获取object_name与【字段值2】进行匹配,获取到对应【采购分类编码】进行传递
|
|
|
sprintf(cgSql,
|
|
|
"select PCGCODE from PLM_ERP_CG_TABLE where PTYPE= '%s' and PFIELDVALUE02= '%s'",
|
|
|
itemType, object_name);
|
|
|
}
|
|
|
else if (strcmp("RB3_GQRevision", itemType) == 0) {
|
|
|
/*
|
|
|
获取分类字段【球类别】的值与【字段值2】进行匹配,
|
|
|
再获取【字段3】的值,如果【字段3】为空则直接匹配到对应【采购分类编码】进行传递;
|
|
|
如果有值获取后与【字段值3】进行比对:获取到的值小于第一个数值,即匹配【采购分类编码】的第一个值进行传递;
|
|
|
获取到的值大于等于第一个数值并小于第二个数值,即匹配【采购分类编码】的第二个值进行传递;
|
|
|
获取到的值大于等于第二个数值,即匹配【采购分类编码】的第三个值进行传递;
|
|
|
*/
|
|
|
char* value = NULL;
|
|
|
ICS_ask_attribute_value(ico_tag, "球类别", &value);
|
|
|
if (value != NULL) {
|
|
|
int id = attrMap["球类别"];
|
|
|
getClassValue(value, id, &cgField1);
|
|
|
DOFREE(value);
|
|
|
}
|
|
|
ICS_ask_attribute_value(ico_tag, "球规格", &value);
|
|
|
if (value != NULL) {
|
|
|
int id = attrMap["球规格"];
|
|
|
getClassValue(value, id, &cgField3);
|
|
|
DOFREE(value);
|
|
|
}
|
|
|
sprintf(cgSql,
|
|
|
"select PCGCODE,PFIELDVALUE03 from PLM_ERP_CG_TABLE where PTYPE= '%s' and PFIELDVALUE02= '%s'",
|
|
|
itemType, cgField1);
|
|
|
}
|
|
|
else if (strcmp("RB3_GYZYRevision", itemType) == 0) {
|
|
|
//先根据获取到的【ERP物料分类】匹配【字段值1】,再根据【字段2】的内容获取编码前六位or编码前四位,
|
|
|
//获取的数值与【字段值2】进行匹配,从而获取到对应【采购分类编码】进行传递;
|
|
|
//IN41 IN38 取前4位
|
|
|
char* newClassId = NULL;
|
|
|
if (strcmp("IN41", classCode) == 0 || strcmp("IN38", classCode) == 0) {
|
|
|
newClassId = getFirstStr(classId, 4);
|
|
|
}
|
|
|
else {
|
|
|
newClassId = getFirstStr(classId, 6);
|
|
|
}
|
|
|
sprintf(cgSql,
|
|
|
"select PCGCODE from PLM_ERP_CG_TABLE where PTYPE= '%s' and PFIELDVALUE01= '%s' and PFIELDVALUE02= '%s'",
|
|
|
itemType, classCode, newClassId);
|
|
|
}
|
|
|
else if (strcmp("RB3_GZRevision", itemType) == 0) {
|
|
|
/*
|
|
|
获取对应分类字段【滚动体类型】的值与【字段值2】进行匹配,再获取【字段3】的值,
|
|
|
如果【字段3】为空则直接匹配到对应【采购分类编码】进行传递;
|
|
|
如果有值获取后与【字段值3】进行比对
|
|
|
*/
|
|
|
char* value = NULL;
|
|
|
ICS_ask_attribute_value(ico_tag, "滚动体类型", &value);
|
|
|
if (value != NULL) {
|
|
|
int id = attrMap["滚动体类型"];
|
|
|
getClassValue(value, id, &cgField1);
|
|
|
DOFREE(value);
|
|
|
}
|
|
|
AOM_UIF_ask_value(attachments[i], "rb3_gzzj", &cgField3);
|
|
|
sprintf(cgSql,
|
|
|
"select PCGCODE,PFIELDVALUE03 from PLM_ERP_CG_TABLE where PTYPE= '%s' and PFIELDVALUE02= '%s'",
|
|
|
itemType, cgField1);
|
|
|
}
|
|
|
else if (strcmp("RB3_LBJRevision", itemType) == 0) {
|
|
|
/*
|
|
|
如果为IN04、IN03,获取物料分类倒数第二级,与【字段值2】进行匹配,再获取【字段3】的值,如果【字段3】为空则直接匹配到对应【采购分类编码】进行传递;如果有值获取object_name与【字段值3】进行匹配;再获取【字段4】的值,如果【字段4】为空则直接匹配到对应【采购分类编码】进行传递;如果【字段4】有值,则以字段4的值获取对应分类属性的值,与【字段值4】匹配获取采购分类,比对逻辑参照上述区间数值匹配的逻辑举例说明;
|
|
|
如果为IN08,直接获取分类字段【结构属性】与【字段值3】进行匹配,获取到对应【采购分类编码】进行传递;
|
|
|
如果为IN09、IN24,获取object_name与【字段值2】进行匹配,获取到对应【采购分类编码】进行传递;
|
|
|
*/
|
|
|
|
|
|
if (strcmp("IN04", classCode) == 0 || strcmp("IN03", classCode) == 0) {
|
|
|
tag_t parentClass = NULLTAG;
|
|
|
char* parentClassId = NULL;
|
|
|
char* parentClassName = NULL;
|
|
|
if (strstr(object_name, "外圈") != NULL || strcmp("座圈", object_name) == 0) {
|
|
|
//外形尺寸_外径(mm)
|
|
|
char* value = NULL;
|
|
|
ICS_ask_attribute_value(ico_tag, "外形尺寸_外径(mm)", &value);
|
|
|
if (value != NULL) {
|
|
|
int id = attrMap["外形尺寸_外径(mm)"];
|
|
|
getClassValue(value, id, &cgField3);
|
|
|
DOFREE(value);
|
|
|
}
|
|
|
}
|
|
|
else {
|
|
|
// 外形尺寸_内径(mm)
|
|
|
char* value = NULL;
|
|
|
ICS_ask_attribute_value(ico_tag, "外形尺寸_内径(mm)", &value);
|
|
|
if (value != NULL) {
|
|
|
int id = attrMap["外形尺寸_内径(mm)"];
|
|
|
getClassValue(value, id, &cgField3);
|
|
|
DOFREE(value);
|
|
|
}
|
|
|
}
|
|
|
ITKCALL(ICS_class_ask_parent(classId, &parentClass, &parentClassId));
|
|
|
if (parentClass != NULLTAG) {
|
|
|
ITKCALL(ICS_ask_id_name(parentClass, &parentClassId, &parentClassName));
|
|
|
sprintf(cgSql,
|
|
|
"select PCGCODE,PFIELDVALUE04 from PLM_ERP_CG_TABLE where PTYPE= '%s' and PFIELDVALUE02= '%s' and PFIELDVALUE03= '%s'",
|
|
|
itemType, parentClassName, object_name);
|
|
|
sprintf(cgSql2,
|
|
|
"select PCGCODE,PFIELDVALUE04 from PLM_ERP_CG_TABLE where PTYPE= '%s' and PFIELDVALUE02= '%s'",
|
|
|
itemType, parentClassName);
|
|
|
}
|
|
|
}
|
|
|
else if (strcmp("IN08", classCode) == 0) {
|
|
|
char* value = NULL;
|
|
|
ICS_ask_attribute_value(ico_tag, "保持架类型", &value);
|
|
|
if (value != NULL) {
|
|
|
printf("value=====%s\n", value);
|
|
|
int id = attrMap["保持架类型"];
|
|
|
printf("id=====================%d\n", id);
|
|
|
getClassValue(value, id, &cgField1);
|
|
|
DOFREE(value);
|
|
|
}
|
|
|
ICS_ask_attribute_value(ico_tag, "结构属性", &value);
|
|
|
if (value != NULL) {
|
|
|
printf("value=====%s\n", value);
|
|
|
int id = attrMap["结构属性"];
|
|
|
printf("id=====================%d\n",id);
|
|
|
getClassValue(value, id, &cgField2);
|
|
|
DOFREE(value);
|
|
|
}
|
|
|
sprintf(cgSql,
|
|
|
"select PCGCODE from PLM_ERP_CG_TABLE where PTYPE= '%s' and PFIELDVALUE02= '%s' and PFIELDVALUE03= '%s'",
|
|
|
itemType, cgField1, cgField2);
|
|
|
}
|
|
|
else if (strcmp("IN09", classCode) == 0 || strcmp("IN24", classCode) == 0) {
|
|
|
sprintf(cgSql,
|
|
|
"select PCGCODE from PLM_ERP_CG_TABLE where PTYPE= '%s' and PFIELDVALUE02= '%s'",
|
|
|
itemType, object_name);
|
|
|
}
|
|
|
}
|
|
|
else if (strcmp("RB3_SLRevision", itemType) == 0 || strcmp("RB3_XJRevision", itemType) == 0) {
|
|
|
//直接获取到对应【采购分类编码】进行传递
|
|
|
sprintf(cgSql,
|
|
|
"select PCGCODE from PLM_ERP_CG_TABLE where PTYPE= '%s'",
|
|
|
itemType);
|
|
|
}
|
|
|
else if (strcmp("RB3_YCLRevision", itemType) == 0) {
|
|
|
//直接获取分类字段【材料形状】与【字段值2】进行匹配,再获取【字段3】的值:
|
|
|
//如果【字段3】为空则直接匹配到对应【采购分类编码】进行传递;
|
|
|
//如果【字段3】的值为材料规格,则获取分类字段【材料规格】值与【字段值3】进行比对,
|
|
|
// 比对逻辑参照上述区间数值匹配的逻辑举例说明;
|
|
|
//如果【字段3】的值为用途,则获取分类字段【用途】值与【字段值3】进行匹配,
|
|
|
//再获取【字段4】的值,如果【字段4】为空则直接匹配到对应【采购分类编码】进行传递;
|
|
|
//如果【字段4】有值,则以字段4的值获取对应分类属性的值,与【字段值4】匹配获取采购分类
|
|
|
char* value = NULL;
|
|
|
ICS_ask_attribute_value(ico_tag, "材料形状", &value);
|
|
|
if (value != NULL) {
|
|
|
int id = attrMap["材料形状"];
|
|
|
getClassValue(value, id, &cgField1);
|
|
|
DOFREE(value);
|
|
|
}
|
|
|
ICS_ask_attribute_value(ico_tag, "用途", &value);
|
|
|
if (value != NULL) {
|
|
|
int id = attrMap["用途"];
|
|
|
getClassValue(value, id, &cgField2);
|
|
|
DOFREE(value);
|
|
|
}
|
|
|
ICS_ask_attribute_value(ico_tag, "材料规格", &value);
|
|
|
if (value != NULL) {
|
|
|
int id = attrMap["材料规格"];
|
|
|
getClassValue(value, id, &cgField3);
|
|
|
DOFREE(value);
|
|
|
}
|
|
|
if (strcmp("IN01", classCode) == 0 || strcmp("IN02", classCode) == 0 || strcmp("IN53", classCode) == 0) {
|
|
|
sprintf(cgSql,
|
|
|
"select PCGCODE,PFIELDVALUE04 from PLM_ERP_CG_TABLE where PTYPE= '%s' and PFIELDVALUE02= '%s'",
|
|
|
itemType, cgField1);
|
|
|
}
|
|
|
else {
|
|
|
sprintf(cgSql,
|
|
|
"select PCGCODE,PFIELDVALUE04 from PLM_ERP_CG_TABLE where PTYPE= '%s' and PFIELDVALUE02= '%s' and PFIELDVALUE03= '%s'",
|
|
|
itemType, cgField1, cgField2);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
int cgOutputColumn = 0, cgOutputValueCount = 0;
|
|
|
|
|
|
char*** cgOutputValue = NULL;
|
|
|
|
|
|
if (strcmp("", cgSql) != 0) {
|
|
|
printf("提示:cgSql==%s\n", cgSql);
|
|
|
if (QuerySQLNoInputParam(cgSql, &cgOutputColumn, &cgOutputValueCount, &cgOutputValue) == -1 || cgOutputValueCount == 0)
|
|
|
{
|
|
|
if (cgOutputValue != NULL) {
|
|
|
for (int i1 = 0; i1 < cgOutputValueCount;i1 ++) {
|
|
|
for (int i2 = 0; i2 < cgOutputColumn;i2 ++) {
|
|
|
DOFREE(cgOutputValue[i1][i2]);
|
|
|
}
|
|
|
DOFREE(cgOutputValue[i1]);
|
|
|
}
|
|
|
DOFREE(cgOutputValue);
|
|
|
}
|
|
|
printf("I2 => C=%d,R=%d\n", cgOutputColumn, cgOutputValueCount);
|
|
|
cgOutputColumn = 0;
|
|
|
cgOutputValueCount = 0;
|
|
|
printf("提示:采购分类查询 失败, %s \n", cgSql);
|
|
|
if (QuerySQLNoInputParam(cgSql2, &cgOutputColumn, &cgOutputValueCount, &cgOutputValue) == -1)
|
|
|
{
|
|
|
printf("提示:采购分类查询 失败, %s \n", cgSql2);
|
|
|
}
|
|
|
}
|
|
|
printf("cgOutputValueCount=%d\n", cgOutputValueCount);
|
|
|
printf("cgOutputColumn=%d\n", cgOutputColumn);
|
|
|
//free(sql);
|
|
|
if (cgField3 != NULL && (strcmp("IN04", classCode) == 0 || strcmp("IN03", classCode) == 0)) {
|
|
|
printf("111\n");
|
|
|
char result[32]; // 确保result足够大,以存储结果
|
|
|
// 计算第二个字符的位置
|
|
|
size_t second_char_pos = 2;
|
|
|
if (strstr(cgField3, "φ") != NULL)
|
|
|
{
|
|
|
// 截取第二个字符之后的所有内容
|
|
|
strcpy(result, cgField3 + second_char_pos);
|
|
|
printf("1\n");
|
|
|
}
|
|
|
if (strstr(cgField3, "Φ") != NULL)
|
|
|
{
|
|
|
// 截取第二个字符之后的所有内容
|
|
|
strcpy(result, cgField3 + second_char_pos);
|
|
|
printf("2\n");
|
|
|
}
|
|
|
printf("cgField3====%s\n", result);
|
|
|
double result_num = atof(result); // 转换为整数
|
|
|
if (cgOutputValueCount > 0) {
|
|
|
cgCode = cgOutputValue[0][0];
|
|
|
limit_value = cgOutputValue[0][1];
|
|
|
printf("采购分类====%s\n", cgCode);
|
|
|
printf("值区间====%s\n", limit_value);
|
|
|
if (limit_value != NULL
|
|
|
&& strcmp(limit_value, "") != 0
|
|
|
&& strcmp(limit_value, " ") != 0) {
|
|
|
if (strstr(limit_value, "-") != NULL)
|
|
|
{
|
|
|
//按照-进行拆分。拆分条件
|
|
|
int numCount = 0;
|
|
|
char** numChar = new char* [64];
|
|
|
int valCount = 0;
|
|
|
char** valChar = new char* [64];
|
|
|
//分割字符串
|
|
|
split(limit_value, "-", numChar, &numCount);
|
|
|
split(cgCode, ",", valChar, &valCount);
|
|
|
for (int ii = 0; ii < numCount; ii++)
|
|
|
{
|
|
|
double int_value1 = atof(numChar[ii]);
|
|
|
if (result_num < int_value1) {
|
|
|
cgCode = valChar[ii];
|
|
|
break;
|
|
|
}
|
|
|
else {
|
|
|
if (ii != numCount - 1) {
|
|
|
double int_value2 = atof(numChar[ii + 1]);
|
|
|
if (result_num < int_value2) {
|
|
|
cgCode = valChar[ii + 1];
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
else {
|
|
|
cgCode = valChar[numCount - 1];
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
DOFREE(numChar);
|
|
|
}
|
|
|
}
|
|
|
printf("采购分类====%s\n", cgCode);
|
|
|
}
|
|
|
}
|
|
|
else {
|
|
|
printf("222\n");
|
|
|
if (cgOutputValueCount > 0) {
|
|
|
cgCode = cgOutputValue[0][0];
|
|
|
}
|
|
|
/*if (true) {
|
|
|
return 0;
|
|
|
}*/
|
|
|
printf("333\n");
|
|
|
}
|
|
|
if (object_name != NULL) {
|
|
|
DOFREE(object_name);
|
|
|
}
|
|
|
if (limit_value != NULL) {
|
|
|
DOFREE(limit_value);
|
|
|
}
|
|
|
}
|
|
|
//
|
|
|
//工厂组织编码特殊处理,通过数据库表匹配
|
|
|
char** factorys = NULL;
|
|
|
int factoryCount = 0;
|
|
|
if (strcmp("RB3_XZCPRevision", itemType) == 0 || strcmp("RB3_XZLBJRevision", itemType) == 0) {
|
|
|
ITKCALL(AOM_UIF_ask_values(attachments[i], "rb3_xzscgc", &factoryCount, &factorys));
|
|
|
}
|
|
|
else if (strcmp("RB3_GNZCRevision", itemType) == 0 || strcmp("RB3_GNLBJRevision", itemType) == 0
|
|
|
|| strcmp("RB3_GYZYRevision", itemType) == 0 || strcmp("RB3_BZJRevision", itemType) == 0) {
|
|
|
ITKCALL(AOM_UIF_ask_values(attachments[i], "rb3_scgc", &factoryCount, &factorys));
|
|
|
}
|
|
|
else if (strcmp("RB3_YCLRevision", itemType) == 0) {
|
|
|
ITKCALL(AOM_UIF_ask_values(attachments[i], "rb3_sygc1", &factoryCount, &factorys));
|
|
|
}
|
|
|
else {
|
|
|
ITKCALL(AOM_UIF_ask_values(attachments[i], "rb3_scgc1", &factoryCount, &factorys));
|
|
|
}
|
|
|
printf("factoryCount=%d\n", factoryCount);
|
|
|
for (int j = 0; j < factoryCount; j++)
|
|
|
{
|
|
|
char*** factoryValue = NULL;
|
|
|
int factoryColumn = 0, factoryValueCount = 0;
|
|
|
char factorySql[128] = "\0";
|
|
|
printf("factorys[j]==%s\n", factorys[j]);
|
|
|
sprintf(factorySql, "select PFACTORYCODE from PLM_ERP_FACTORY_TABLE where PFACTORY= '%s'", factorys[j]);
|
|
|
printf("提示:factorySql==%s\n", factorySql);
|
|
|
if (QuerySQLNoInputParam(factorySql, &factoryColumn, &factoryValueCount, &factoryValue) == -1)
|
|
|
{
|
|
|
printf("提示:组织编码查询 失败, %s \n", factorySql);
|
|
|
}
|
|
|
printf("factoryValueCount=%d\n", factoryValueCount);
|
|
|
printf("factoryColumn=%d\n", factoryColumn);
|
|
|
//free(sql);
|
|
|
if (factoryValueCount > 0) {
|
|
|
if (strcmp("", factoryCode) != 0) {
|
|
|
strcat(factoryCode, ",");
|
|
|
}
|
|
|
strcat(factoryCode, factoryValue[0][0]);
|
|
|
printf("组织编码====%s\n", factoryCode);
|
|
|
}
|
|
|
if (factoryValue != NULL) {
|
|
|
DOFREE(factoryValue);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (factorys != NULL) {
|
|
|
DOFREE(factorys);
|
|
|
}
|
|
|
if (outputValue != NULL) {
|
|
|
DOFREE(outputValue);
|
|
|
}
|
|
|
if (field1 != NULL) {
|
|
|
DOFREE(field1);
|
|
|
}
|
|
|
if (field2 != NULL) {
|
|
|
DOFREE(field2);
|
|
|
}
|
|
|
if (cgField1 != NULL) {
|
|
|
DOFREE(cgField1);
|
|
|
}
|
|
|
if (cgField2 != NULL) {
|
|
|
DOFREE(cgField2);
|
|
|
}
|
|
|
if (cgField3 != NULL) {
|
|
|
DOFREE(cgField3);
|
|
|
}
|
|
|
}
|
|
|
if (factoryCode != NULL) {
|
|
|
strcat(parameters, "\"orgCode\":\"");
|
|
|
strcat(parameters, factoryCode);
|
|
|
if (organization != NULL) {
|
|
|
strcat(parameters, ",");
|
|
|
strcat(parameters, organization);
|
|
|
}
|
|
|
strcat(parameters, "\",");
|
|
|
}
|
|
|
strcat(parameters, "\"manageClassCode\":\"");
|
|
|
if (classCode != NULL) {
|
|
|
strcat(parameters, classCode);
|
|
|
}
|
|
|
strcat(parameters, "\",");
|
|
|
strcat(parameters, "\"purchaseClassCode\":\"");
|
|
|
if (cgCode != NULL) {
|
|
|
strcat(parameters, cgCode);
|
|
|
}
|
|
|
strcat(parameters, "\",");
|
|
|
// 使用迭代器遍历map
|
|
|
int index = 0;
|
|
|
for (std::map<string, string>::iterator it = propMap.begin(); it != propMap.end(); ++it) {
|
|
|
string key = it->first;
|
|
|
string attr = it->second;
|
|
|
printf("key: %s \n", key.c_str());
|
|
|
printf("attr: %s \n", attr.c_str());
|
|
|
if (strcmp("orgCode", key.c_str()) == 0) {
|
|
|
index++;
|
|
|
continue;
|
|
|
}
|
|
|
if (strstr(attr.c_str(), ".") != NULL)
|
|
|
{
|
|
|
int attrCount = 0;
|
|
|
char** attrChar = new char* [128];
|
|
|
char* attrName = new char[2048];//足够长
|
|
|
strcpy(attrName, attr.c_str());
|
|
|
printf("attrName: %s \n", attrName);
|
|
|
//分割字符串
|
|
|
split(attrName, ".", attrChar, &attrCount);
|
|
|
char* value = NULL;
|
|
|
if (strcmp("rev", attrChar[0]) == 0) {
|
|
|
//单位特殊处理
|
|
|
if (strcmp("uom_tag", attrChar[1]) == 0)
|
|
|
{
|
|
|
tag_t item = NULLTAG;
|
|
|
ITKCALL(ITEM_ask_item_of_rev(attachments[i], &item));
|
|
|
tag_t unitTag = NULLTAG;
|
|
|
ITKCALL(AOM_ask_value_tag(item, attrChar[1], &unitTag));
|
|
|
if (unitTag != NULL) {
|
|
|
ITKCALL(AOM_UIF_ask_value(unitTag, "object_string", &value));
|
|
|
printf("uom_tag: %s \n", value);
|
|
|
//单位换算
|
|
|
// 特定物料分类单位换算:滚动体计量单位:L(粒)转WL(万粒);油脂的计量单位:GM(克) 转KG(千克);钢材,钢管计量单位:GM(克)转T(吨)
|
|
|
if (className != NULL) {
|
|
|
if (strcmp("滚动体", className) == 0 && strcmp("L(粒)", value) == 0)
|
|
|
{
|
|
|
value = "WL(万粒)";
|
|
|
}
|
|
|
else if (strcmp("油脂", className) == 0 && strcmp("GM(克)", value) == 0)
|
|
|
{
|
|
|
value = "KG(千克)";
|
|
|
}if ((strcmp("钢材", className) == 0 || strcmp("钢管", className) == 0) && strcmp("GM(克)", value) == 0)
|
|
|
{
|
|
|
value = "T(吨)";
|
|
|
}
|
|
|
}
|
|
|
strcat(parameters, "\"");
|
|
|
strcat(parameters, key.c_str());
|
|
|
strcat(parameters, "\":\"");
|
|
|
if (unitMap.find(value) != unitMap.end()) {
|
|
|
strcat(parameters, unitMap[value].c_str());
|
|
|
}
|
|
|
else {
|
|
|
strcat(parameters, value);
|
|
|
}
|
|
|
strcat(parameters, "\"");
|
|
|
}
|
|
|
else {
|
|
|
strcat(parameters, "\"");
|
|
|
strcat(parameters, key.c_str());
|
|
|
strcat(parameters, "\":\"");
|
|
|
if (punit != NULL) {
|
|
|
strcat(parameters, punit);
|
|
|
}
|
|
|
strcat(parameters, "\"");
|
|
|
|
|
|
}
|
|
|
if (item != NULL) {
|
|
|
DOFREE(item);
|
|
|
}
|
|
|
if (unitTag != NULL) {
|
|
|
DOFREE(unitTag);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
//重量特殊处理
|
|
|
else if (strcmp("netWeight", key.c_str()) == 0)
|
|
|
{
|
|
|
strcat(parameters, "\"netWeightUnitCode\":\"KG\",");
|
|
|
ITKCALL(AOM_UIF_ask_value(attachments[i], attrChar[1], &value));
|
|
|
if (value != NULL && strcmp("", value) != 0) {
|
|
|
double dValue = std::stod(value);
|
|
|
dValue = dValue * 10000;
|
|
|
long lValue = static_cast<long>(dValue); // 转换为long
|
|
|
strcat(parameters, "\"");
|
|
|
strcat(parameters, key.c_str());
|
|
|
strcat(parameters, "\":");
|
|
|
char netWeight[64] = "\0";
|
|
|
sprintf(netWeight, "%d", lValue);
|
|
|
strcat(parameters, netWeight);
|
|
|
}
|
|
|
else {
|
|
|
strcat(parameters, "\"");
|
|
|
strcat(parameters, key.c_str());
|
|
|
strcat(parameters, "\":0");
|
|
|
}
|
|
|
}
|
|
|
//生命周期特殊处理
|
|
|
else if (strcmp("material_status", key.c_str()) == 0)
|
|
|
{
|
|
|
ITKCALL(AOM_UIF_ask_value(attachments[i], attrChar[1], &value));
|
|
|
strcat(parameters, "\"");
|
|
|
strcat(parameters, key.c_str());
|
|
|
strcat(parameters, "\":\"");
|
|
|
if (smzqMap.find(value) != smzqMap.end()) {
|
|
|
strcat(parameters, smzqMap[value].c_str());
|
|
|
}
|
|
|
else {
|
|
|
strcat(parameters, value);
|
|
|
}
|
|
|
strcat(parameters, "\"");
|
|
|
}
|
|
|
else {
|
|
|
ITKCALL(AOM_UIF_ask_value(attachments[i], attrChar[1], &value));
|
|
|
strcat(parameters, "\"");
|
|
|
strcat(parameters, key.c_str());
|
|
|
strcat(parameters, "\":\"");
|
|
|
strcat(parameters, value);
|
|
|
strcat(parameters, "\"");
|
|
|
}
|
|
|
}
|
|
|
else {
|
|
|
if (ico_tag != NULLTAG) {
|
|
|
if (strstr(attrChar[1], "&") != NULL)
|
|
|
{
|
|
|
int attrNum = 0;
|
|
|
char** allAttrs = new char* [128];
|
|
|
//分割字符串
|
|
|
split(attrChar[1], "&", allAttrs, &attrNum);
|
|
|
char values[256] = "";//多个属性拼接
|
|
|
for (int i = 0; i < attrNum; i++)
|
|
|
{
|
|
|
if (attrMap.find(allAttrs[i]) != attrMap.end())
|
|
|
{
|
|
|
ICS_ask_attribute_value(ico_tag, allAttrs[i], &value);
|
|
|
if (value != NULL) {
|
|
|
int id = attrMap[allAttrs[i]];
|
|
|
char* disValue;
|
|
|
getClassValue(value, id, &disValue);
|
|
|
strcat(values, disValue);
|
|
|
DOFREE(disValue);
|
|
|
}
|
|
|
else {
|
|
|
strcat(values, "");
|
|
|
}
|
|
|
}
|
|
|
else {
|
|
|
strcat(values, "");
|
|
|
}
|
|
|
}
|
|
|
strcat(parameters, "\"");
|
|
|
strcat(parameters, key.c_str());
|
|
|
strcat(parameters, "\":\"");
|
|
|
strcat(parameters, values);
|
|
|
strcat(parameters, "\"");
|
|
|
DOFREE(allAttrs);
|
|
|
}
|
|
|
else {
|
|
|
//保持架板厚特殊处理
|
|
|
if (strcmp("CU0261", key.c_str()) == 0)
|
|
|
{
|
|
|
if (attrMap.find("保持架板厚(mm)") != attrMap.end())
|
|
|
{
|
|
|
attrChar[1] = "保持架板厚(mm)";
|
|
|
}
|
|
|
else if (attrMap.find("冲压保持架板厚(mm)") != attrMap.end())
|
|
|
{
|
|
|
attrChar[1] = "冲压保持架板厚(mm)";
|
|
|
}
|
|
|
else if (attrMap.find("保持架板厚(铁保)") != attrMap.end())
|
|
|
{
|
|
|
attrChar[1] = "保持架板厚(铁保)";
|
|
|
}
|
|
|
}
|
|
|
//密封颜色特殊处理
|
|
|
else if (strcmp("CU0262", key.c_str()) == 0)
|
|
|
{
|
|
|
if (attrMap.find("密封颜色") != attrMap.end())
|
|
|
{
|
|
|
//printf("1111\n");
|
|
|
attrChar[1] = "密封颜色";
|
|
|
}
|
|
|
else if (attrMap.find("密封颜色(带轮端)") != attrMap.end())
|
|
|
{
|
|
|
attrChar[1] = "密封颜色(带轮端)";
|
|
|
}
|
|
|
else if (attrMap.find("(内密封件颜色)") != attrMap.end())
|
|
|
{
|
|
|
attrChar[1] = "(内密封件颜色)";
|
|
|
}
|
|
|
}
|
|
|
//密封材料特殊处理
|
|
|
else if (strcmp("CU0263", key.c_str()) == 0)
|
|
|
{
|
|
|
if (attrMap.find("密封材料") != attrMap.end())
|
|
|
{
|
|
|
//printf("2222\n");
|
|
|
attrChar[1] = "密封材料";
|
|
|
}
|
|
|
else if (attrMap.find("密封材料(带轮端)") != attrMap.end())
|
|
|
{
|
|
|
attrChar[1] = "密封材料(带轮端)";
|
|
|
}
|
|
|
else if (attrMap.find("(内密封件材料)") != attrMap.end())
|
|
|
{
|
|
|
attrChar[1] = "(内密封件材料)";
|
|
|
}
|
|
|
}
|
|
|
//printf("attrChar[1] = %s \n", attrChar[1]);
|
|
|
if (attrMap.find(attrChar[1]) != attrMap.end())
|
|
|
{
|
|
|
ICS_ask_attribute_value(ico_tag, attrChar[1], &value);
|
|
|
if (value != NULL && strcmp(value, "") != 0 && strcmp(value, " ") != 0) {
|
|
|
int id = attrMap[attrChar[1]];
|
|
|
char* disValue;
|
|
|
getClassValue(value, id, &disValue);
|
|
|
/* printf("id = %d \n", id);
|
|
|
printf("disValue = %s \n", disValue);*/
|
|
|
strcat(parameters, "\"");
|
|
|
strcat(parameters, key.c_str());
|
|
|
strcat(parameters, "\":\"");
|
|
|
strcat(parameters, disValue);
|
|
|
strcat(parameters, "\"");
|
|
|
DOFREE(disValue);
|
|
|
}
|
|
|
else {
|
|
|
strcat(parameters, "\"");
|
|
|
strcat(parameters, key.c_str());
|
|
|
strcat(parameters, "\":\"\"");
|
|
|
}
|
|
|
}
|
|
|
else {
|
|
|
strcat(parameters, "\"");
|
|
|
strcat(parameters, key.c_str());
|
|
|
strcat(parameters, "\":\"\"");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
else {
|
|
|
strcat(parameters, "\"");
|
|
|
strcat(parameters, key.c_str());
|
|
|
strcat(parameters, "\":\"\"");
|
|
|
}
|
|
|
}
|
|
|
printf("value: %s \n", value);
|
|
|
DOFREE(value);
|
|
|
DOFREE(attrChar);
|
|
|
DOFREE(attrName);
|
|
|
}
|
|
|
else {
|
|
|
if (strcmp("CU0266", key.c_str()) == 0 && strcmp("RB3_LBJRevision", itemType) == 0 && ico_tag != NULLTAG)
|
|
|
{
|
|
|
printf("零部件特殊处理\n");
|
|
|
char* value = NULL;
|
|
|
if (attrMap.find("类别") != attrMap.end())
|
|
|
{
|
|
|
printf("类别 : %s \n", value);
|
|
|
ICS_ask_attribute_value(ico_tag, "类别", &value);
|
|
|
if (value != NULL) {
|
|
|
int id = attrMap["类别"];
|
|
|
char* disValue;
|
|
|
getClassValue(value, id, &disValue);
|
|
|
printf("disValue : %s \n", disValue);
|
|
|
if (strcmp("C:车工件", disValue) == 0) {
|
|
|
tag_t parentClass = NULLTAG;
|
|
|
char* parentClassId = NULL;
|
|
|
char* parentClassName = NULL;
|
|
|
ITKCALL(ICS_class_ask_parent(classId, &parentClass, &parentClassId));
|
|
|
if (parentClass != NULLTAG) {
|
|
|
ITKCALL(ICS_ask_id_name(parentClass, &parentClassId, &parentClassName));
|
|
|
strcat(parameters, "\"");
|
|
|
strcat(parameters, key.c_str());
|
|
|
strcat(parameters, "\":\"");
|
|
|
strcat(parameters, parentClassName);
|
|
|
strcat(parameters, "\"");
|
|
|
}
|
|
|
else {
|
|
|
strcat(parameters, "\"");
|
|
|
strcat(parameters, key.c_str());
|
|
|
strcat(parameters, "\":\"\"");
|
|
|
}
|
|
|
DOFREE(parentClass);
|
|
|
DOFREE(parentClassId);
|
|
|
DOFREE(parentClassName);
|
|
|
}
|
|
|
else {
|
|
|
strcat(parameters, "\"");
|
|
|
strcat(parameters, key.c_str());
|
|
|
strcat(parameters, "\":\"\"");
|
|
|
}
|
|
|
DOFREE(disValue);
|
|
|
}
|
|
|
else {
|
|
|
strcat(parameters, "\"");
|
|
|
strcat(parameters, key.c_str());
|
|
|
strcat(parameters, "\":\"\"");
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
strcat(parameters, "\"");
|
|
|
strcat(parameters, key.c_str());
|
|
|
strcat(parameters, "\":\"\"");
|
|
|
}
|
|
|
DOFREE(value);
|
|
|
}//重量特殊处理
|
|
|
else if (strcmp("netWeight", key.c_str()) == 0)
|
|
|
{
|
|
|
strcat(parameters, "\"netWeightUnitCode\":\"KG\",");
|
|
|
strcat(parameters, "\"");
|
|
|
strcat(parameters, key.c_str());
|
|
|
strcat(parameters, "\":0");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
printf("key: %s 默认为空值\n", key.c_str());
|
|
|
strcat(parameters, "\"");
|
|
|
strcat(parameters, key.c_str());
|
|
|
strcat(parameters, "\":\"\"");
|
|
|
}
|
|
|
}
|
|
|
if (index < propMap.size() - 1)
|
|
|
{
|
|
|
strcat(parameters, ",");
|
|
|
}
|
|
|
index++;
|
|
|
}
|
|
|
if (classId != NULL) {
|
|
|
DOFREE(classId);
|
|
|
}
|
|
|
if (ico_tag != NULL) {
|
|
|
DOFREE(ico_tag);
|
|
|
}
|
|
|
if (classCode != NULL) {
|
|
|
DOFREE(classCode);
|
|
|
}
|
|
|
if (cgCode != NULL) {
|
|
|
DOFREE(cgCode);
|
|
|
}
|
|
|
if (className != NULL) {
|
|
|
DOFREE(className);
|
|
|
}
|
|
|
if (organization != NULL) {
|
|
|
DOFREE(organization);
|
|
|
}
|
|
|
if (punit != NULL) {
|
|
|
DOFREE(punit);
|
|
|
}
|
|
|
strcat(parameters, "}");
|
|
|
attrMap.clear();
|
|
|
}
|
|
|
DOFREE(itemType);
|
|
|
}
|
|
|
DisConnServer();
|
|
|
strcat(parameters, "]");
|
|
|
//printf("parameters: %s\n", parameters);
|
|
|
//把数据用写入文件
|
|
|
char data_file[SS_MAXPATHLEN] = "";
|
|
|
strcat(data_file, tc_root_file);
|
|
|
strcat(data_file, "\\");
|
|
|
strcat(data_file, date);
|
|
|
strcat(data_file, ".txt");
|
|
|
printf("data_file: %s\n", data_file);
|
|
|
ofstream file;
|
|
|
file.open(data_file);
|
|
|
file << parameters << endl; // 使用与cout同样的方式进行写入
|
|
|
file.close();
|
|
|
|
|
|
string strResult;
|
|
|
|
|
|
//cmd指令
|
|
|
char cmd[256] = "";
|
|
|
strcpy(cmd, "java -jar \"");
|
|
|
strcat(cmd, tc_root_file);
|
|
|
strcat(cmd, "\\portal\\plugins\\");
|
|
|
strcat(cmd, "RB_SendErp_New.jar");
|
|
|
strcat(cmd, "\" ");
|
|
|
//传参
|
|
|
//cout << data_file << endl;
|
|
|
strcat(cmd, data_file);
|
|
|
//用来传递本流程的流程名称(@分割)
|
|
|
strcat(cmd, "@WL");
|
|
|
//printf("路径:\n%s\n", cmd);
|
|
|
char buf[8000] = { 0 };
|
|
|
FILE* pf = NULL;
|
|
|
if ((pf = _popen(cmd, "r")) == NULL) {
|
|
|
printf("接口返回:\n%s", "1");
|
|
|
}
|
|
|
|
|
|
while (fgets(buf, sizeof buf, pf)) {
|
|
|
strResult += buf;
|
|
|
}
|
|
|
_pclose(pf);
|
|
|
|
|
|
cout << strResult << endl;
|
|
|
unsigned int iSize = strResult.size();
|
|
|
if (iSize > 0 && strResult[iSize - 1] == '\n' && strlen(parameters) > 0)
|
|
|
{
|
|
|
|
|
|
strResult = strResult.substr(0, iSize - 1);
|
|
|
printf("下发失败\n");
|
|
|
cout << strResult << endl;
|
|
|
}
|
|
|
printf("ifail: %d\n", ifail);
|
|
|
if (attachments != NULL) {
|
|
|
MEM_free(attachments);
|
|
|
}
|
|
|
if (pref_vals != NULL) {
|
|
|
MEM_free(pref_vals);
|
|
|
}
|
|
|
//if (tc_root_file != NULL) {
|
|
|
// MEM_free(tc_root_file);
|
|
|
//}
|
|
|
printf("=========================对象下发到ERP End===================\n");
|
|
|
return ifail;
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int RB_SendGX_New(EPM_action_message_t msg)
|
|
|
{
|
|
|
printf("=========================工序下发到ERP Start===================\n");
|
|
|
//POM_AM__set_application_bypass(true);
|
|
|
int ifail = ITK_ok;
|
|
|
int attachments_num = 0;
|
|
|
tag_t rootTask = NULLTAG, * attachments = NULLTAG;
|
|
|
//获取任务对象
|
|
|
EPM_ask_root_task(msg.task, &rootTask);
|
|
|
//获取任务目标对象
|
|
|
EPM_ask_attachments(rootTask, EPM_target_attachment, &attachments_num, &attachments);
|
|
|
|
|
|
char* tc_root_file = getenv("tc_root"); //C:\Siemens\Teamcenter11
|
|
|
//+++
|
|
|
char parameters[20000] = "";//写入到文件的值
|
|
|
strcat(parameters, "{\"data\":[");
|
|
|
//获取当前时间
|
|
|
time_t now = time(0);
|
|
|
tm* p = localtime(&now);
|
|
|
char date[128] = "";
|
|
|
sprintf_s(date, "%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);
|
|
|
map<string, map<string, int>> classMap;
|
|
|
for (int i = 0; i < attachments_num; i++)
|
|
|
{
|
|
|
tag_t bzgx = attachments[i];
|
|
|
tag_t ico_tag = NULLTAG;
|
|
|
char* classId = NULL;
|
|
|
map<string, int> attrMap;
|
|
|
ICS_ask_classification_object(bzgx, &ico_tag);
|
|
|
if (ico_tag != NULLTAG) {
|
|
|
ICS_ico_ask_class(ico_tag, &classId);
|
|
|
printf(">> classId: %s\n", classId);
|
|
|
tag_t parentClass = NULLTAG;
|
|
|
char* parentClassId = NULL;
|
|
|
char* parentClassName = NULL;
|
|
|
ITKCALL(ICS_class_ask_parent(classId, &parentClass, &parentClassId));
|
|
|
if (parentClass != NULLTAG) {
|
|
|
ITKCALL(ICS_ask_id_name(parentClass, &parentClassId, &parentClassName));
|
|
|
if (strcmp("外检", parentClassName) == 0) {
|
|
|
DOFREE(parentClass);
|
|
|
DOFREE(parentClassId);
|
|
|
DOFREE(parentClassName);
|
|
|
DOFREE(classId);
|
|
|
continue;
|
|
|
}
|
|
|
}
|
|
|
DOFREE(parentClass);
|
|
|
DOFREE(parentClassId);
|
|
|
DOFREE(parentClassName);
|
|
|
char* type = NULL;
|
|
|
ITKCALL(AOM_ask_value_string(bzgx, "object_type", &type));
|
|
|
if (strcmp("MEOPRevision", type) != 0) {
|
|
|
if (type != NULL) {
|
|
|
DOFREE(type);
|
|
|
}
|
|
|
continue;
|
|
|
}
|
|
|
if (strstr(parameters, "[{") != NULL) {
|
|
|
strcat(parameters, ",");
|
|
|
}
|
|
|
strcat(parameters, "{");
|
|
|
char* bzgxh = NULL;//rb3_bzgxh
|
|
|
char* object_name = NULL;//object_name
|
|
|
char* bzgs = NULL;//rb3_bzgs
|
|
|
char* cplb = NULL;//产品类别
|
|
|
char* cplb_disValue = NULL;//产品类别显示值
|
|
|
//ITKCALL(AOM_ask_value_string(bzgx, "rb3_bzgxh", &bzgxh));
|
|
|
|
|
|
ITKCALL(AOM_ask_value_string(bzgx, "object_name", &object_name));
|
|
|
ITKCALL(AOM_ask_value_string(bzgx, "rb3_bzgs", &bzgs));
|
|
|
|
|
|
//分类属性名称对应id map存储
|
|
|
if (classMap.find(classId) == classMap.end()) {
|
|
|
int count = 0;
|
|
|
int* ids;
|
|
|
int* arraySize;
|
|
|
int* formats;
|
|
|
int* options;
|
|
|
char** names;
|
|
|
char** shortNames;
|
|
|
char** annotations;
|
|
|
char** unit;
|
|
|
char** minValues;
|
|
|
char** maxValues;
|
|
|
char** defaultValues;
|
|
|
char** descriptions;
|
|
|
ITKCALL(ICS_class_describe_attributes(classId, &count, &ids, &names, &shortNames, &annotations, &arraySize,
|
|
|
&formats, &unit, &minValues, &maxValues, &defaultValues, &descriptions, &options));
|
|
|
for (int i = 0; i < count; i++)
|
|
|
{
|
|
|
attrMap.insert(pair<string, int>(names[i], ids[i]));
|
|
|
}
|
|
|
classMap.insert(pair<string, map<string, int>>(classId, attrMap));
|
|
|
if (ids != NULL) {
|
|
|
DOFREE(ids);
|
|
|
}
|
|
|
if (arraySize != NULL) {
|
|
|
DOFREE(arraySize);
|
|
|
}
|
|
|
if (formats != NULL) {
|
|
|
DOFREE(formats);
|
|
|
}
|
|
|
if (options != NULL) {
|
|
|
DOFREE(options);
|
|
|
}
|
|
|
if (names != NULL) {
|
|
|
DOFREE(names);
|
|
|
}
|
|
|
if (shortNames != NULL) {
|
|
|
DOFREE(shortNames);
|
|
|
}
|
|
|
if (annotations != NULL) {
|
|
|
DOFREE(annotations);
|
|
|
}
|
|
|
if (unit != NULL) {
|
|
|
DOFREE(unit);
|
|
|
}
|
|
|
if (minValues != NULL) {
|
|
|
DOFREE(minValues);
|
|
|
}
|
|
|
if (maxValues != NULL) {
|
|
|
DOFREE(maxValues);
|
|
|
}
|
|
|
if (defaultValues != NULL) {
|
|
|
DOFREE(defaultValues);
|
|
|
}
|
|
|
if (descriptions != NULL) {
|
|
|
DOFREE(descriptions);
|
|
|
}
|
|
|
}
|
|
|
else {
|
|
|
attrMap = classMap[classId];
|
|
|
}
|
|
|
|
|
|
if (attrMap.find("产品类别") != attrMap.end())
|
|
|
{
|
|
|
ICS_ask_attribute_value(ico_tag, "产品类别", &cplb);
|
|
|
if (cplb != NULL) {
|
|
|
int id = attrMap["产品类别"];
|
|
|
getClassValue(cplb, id, &cplb_disValue);
|
|
|
}
|
|
|
}
|
|
|
std::string str = classId;
|
|
|
if (str.length() >= 4) {
|
|
|
str.erase(0, 4); // 去除前4个字符
|
|
|
}
|
|
|
//removeFirstFourChars(classId);
|
|
|
strcat(parameters, "\"standardProcessNumber\":\"");
|
|
|
strcat(parameters, str.c_str());
|
|
|
strcat(parameters, "\",");
|
|
|
strcat(parameters, "\"processName\":\"");
|
|
|
if (cplb_disValue != NULL) {
|
|
|
strcat(parameters, cplb_disValue);
|
|
|
strcat(parameters, "-");
|
|
|
}
|
|
|
strcat(parameters, object_name);
|
|
|
strcat(parameters, "\",");
|
|
|
strcat(parameters, "\"standardWorkingHours\":\"");
|
|
|
strcat(parameters, bzgs);
|
|
|
strcat(parameters, "\",");
|
|
|
strcat(parameters, "\"productCategory\":\"");
|
|
|
if (cplb_disValue != NULL) {
|
|
|
strcat(parameters, cplb_disValue);
|
|
|
}
|
|
|
strcat(parameters, "\"");
|
|
|
strcat(parameters, "}");
|
|
|
if (bzgxh != NULL) {
|
|
|
DOFREE(bzgxh);
|
|
|
}
|
|
|
if (object_name != NULL) {
|
|
|
DOFREE(object_name);
|
|
|
}
|
|
|
if (bzgs != NULL) {
|
|
|
DOFREE(bzgs);
|
|
|
}
|
|
|
if (cplb != NULL) {
|
|
|
DOFREE(cplb);
|
|
|
}
|
|
|
if (cplb_disValue != NULL) {
|
|
|
DOFREE(cplb_disValue);
|
|
|
}
|
|
|
if (classId != NULL) {
|
|
|
DOFREE(classId);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
strcat(parameters, "],\"control\":{\"keydata\":null,\"ifid\": null,\"ifno\":\"TC_to_MDM_BZGX\",\"suser\": null,\"sysid\": null}}");
|
|
|
printf("parameters: %s\n", parameters);
|
|
|
//把数据用写入文件
|
|
|
char data_file[SS_MAXPATHLEN] = "";
|
|
|
strcat(data_file, tc_root_file);
|
|
|
strcat(data_file, "\\");
|
|
|
strcat(data_file, date);
|
|
|
strcat(data_file, ".txt");
|
|
|
printf("data_file: %s\n", data_file);
|
|
|
ofstream file;
|
|
|
file.open(data_file);
|
|
|
file << parameters << endl; // 使用与cout同样的方式进行写入
|
|
|
file.close();
|
|
|
|
|
|
string strResult;
|
|
|
|
|
|
//cmd指令
|
|
|
char cmd[256] = "";
|
|
|
strcpy(cmd, "java -jar \"");
|
|
|
//strcat(cmd, jar_file);
|
|
|
strcat(cmd, tc_root_file);
|
|
|
strcat(cmd, "\\portal\\plugins\\");
|
|
|
strcat(cmd, "RB_SendErp_New.jar");
|
|
|
strcat(cmd, "\" ");
|
|
|
//传参
|
|
|
//cout << data_file << endl;
|
|
|
strcat(cmd, data_file);
|
|
|
//用来传递本流程的流程名称(@分割)
|
|
|
strcat(cmd,"@GX");
|
|
|
////strcat(cmd,handler_name);
|
|
|
//printf("路径:\n%s\n", cmd);
|
|
|
char buf[8000] = { 0 };
|
|
|
FILE* pf = NULL;
|
|
|
if ((pf = _popen(cmd, "r")) == NULL) {
|
|
|
printf("接口返回:\n%s", "1");
|
|
|
}
|
|
|
|
|
|
while (fgets(buf, sizeof buf, pf)) {
|
|
|
strResult += buf;
|
|
|
}
|
|
|
_pclose(pf);
|
|
|
|
|
|
cout << strResult << endl;
|
|
|
unsigned int iSize = strResult.size();
|
|
|
if (iSize > 0 && strResult[iSize - 1] == '\n' && strlen(parameters) > 0)
|
|
|
{
|
|
|
strResult = strResult.substr(0, iSize - 1);
|
|
|
cout << strResult << endl;
|
|
|
if (strstr(strResult.c_str(), "\"code\":200") == NULL)
|
|
|
{
|
|
|
printf("下发失败\n");
|
|
|
|
|
|
}
|
|
|
}
|
|
|
printf("ifail: %d\n", ifail);
|
|
|
if (attachments != NULL) {
|
|
|
MEM_free(attachments);
|
|
|
}
|
|
|
//if (tc_root_file != NULL) {
|
|
|
// MEM_free(tc_root_file);
|
|
|
//}
|
|
|
printf("=========================工序下发到ERP End===================\n");
|
|
|
return ifail;
|
|
|
}
|