|
|
#include"kutil.h"
|
|
|
|
|
|
#define debug true
|
|
|
#define ITK_err 919012
|
|
|
#define RAYCUS_PLM_TO_SAP_Bom "Raycus_Plm_To_Sap_Bom"
|
|
|
#define RAYCUS_CONFIG_BOM_FIELDS "Raycus_Config_Bom_Fields"
|
|
|
|
|
|
#define RAYCUS_PLM_TO_SAP_Bom_REVISE "Raycus_Plm_To_Sap_Bom_Revise"
|
|
|
#define RAYCUS_CONFIG_BOM_FIELDS_REVISE "Raycus_Config_Bom_Fields_Revise"
|
|
|
|
|
|
#define RAYCUS_PLM_TO_SAP_FBBom "Raycus_Plm_To_Sap_Fbbom"
|
|
|
#define RAYCUS_CONFIG_FBBOM_FIELDS "Raycus_Config_Fbbom_Fields"
|
|
|
#define RAYCUS_MBOM_Check_BOMLINE "MBOM_Check_BOMLINE"
|
|
|
#define RAYCUS_CONFIG_BZGX_FIELDS "Raycus_Config_Bzgx_Fields"
|
|
|
#define RAYCUS_PLM_TO_SAP_BZGX "Raycus_Plm_To_Sap_Bzgx"
|
|
|
typedef struct {
|
|
|
string send_name;
|
|
|
string type;
|
|
|
string title;
|
|
|
string prop_type;
|
|
|
string prop_name;
|
|
|
string default;
|
|
|
} Config;
|
|
|
|
|
|
typedef struct {
|
|
|
tag_t rev_tag; //版本标记
|
|
|
tag_t bom_tag; //bom标记
|
|
|
string id; //id
|
|
|
string sequence;//查找编号
|
|
|
string revision_id;//版本
|
|
|
string rev_type; //对象类型
|
|
|
string flag; //标记(新增:A,修改:U,删除:D)
|
|
|
} BomlineType;
|
|
|
|
|
|
tag_t getBomProp(tag_t rev, vector<BomlineType>& lines);
|
|
|
boolean compareProps(BomlineType lines1, BomlineType lines2, vector<string> checkBomPorps);
|
|
|
int parseConfigs(vector<string> pref_values, vector<Config>& son_configs, vector<Config>& title_configs);
|
|
|
string read_data(tag_t bomline_tag, vector<Config> configs,tag_t parentline_tag);
|
|
|
|
|
|
//发送BOM到SAP
|
|
|
int PLM_MBOM_TO_SAP_NEW(EPM_action_message_t msg) {
|
|
|
int ifail = ITK_ok, arg_cnt = 0, att_cnt= 0, bvr_count = 0,count = 0;
|
|
|
char* arg = NULL,* argflag = NULL, *argvalue = NULL, toJar[1000] = "";
|
|
|
tag_t* attachments = NULLTAG,task_tag = NULLTAG, rootTask_tag,* bvr_list = NULLTAG, bom_window_tag, top_line;
|
|
|
string type, jsonStr;
|
|
|
vector<string> types, urlPrefs, fieldPrefs,return_vector;
|
|
|
vector<Config> son_configs,title_configs;
|
|
|
|
|
|
time_t now = time(0);
|
|
|
tm* p = localtime(&now);
|
|
|
char date[128] = "", fileDate[128] = "";
|
|
|
char* tc_root_file = getenv("tc_root"); //C:\Siemens\Teamcenter11
|
|
|
char data_file[SS_MAXPATHLEN] = "" , data_file_return[SS_MAXPATHLEN] = "",data_file_error[SS_MAXPATHLEN] = "";
|
|
|
ofstream file;
|
|
|
|
|
|
WriteLog(debug, "开始执行:传递BOM到SAP (PLM_MBOM_TO_SAP_NEW) ...");
|
|
|
arg_cnt = TC_number_of_arguments(msg.arguments);
|
|
|
if (arg_cnt > 0) {
|
|
|
for (int i = 0; i < arg_cnt; i++) {
|
|
|
arg = TC_next_argument(msg.arguments);
|
|
|
ITKCALL(ifail = ITK_ask_argument_named_value(arg, &argflag, &argvalue));
|
|
|
if (strcmp(argflag, "type") == 0) {
|
|
|
type.assign(argvalue);
|
|
|
}
|
|
|
MEM_free(argflag);
|
|
|
MEM_free(argvalue);
|
|
|
}
|
|
|
}
|
|
|
else {
|
|
|
EMH_store_error_s1(EMH_severity_error, ITK_err, "未配置流程参数");
|
|
|
ifail = 1;
|
|
|
goto end;
|
|
|
}
|
|
|
{
|
|
|
Split(type, ",", types);
|
|
|
if (types.size() == 0) {
|
|
|
EMH_store_error_s1(EMH_severity_error, ITK_err, "未配置流程参数:-type");
|
|
|
goto end;
|
|
|
}
|
|
|
}
|
|
|
//拿到当前节点
|
|
|
task_tag = msg.task;
|
|
|
if (task_tag == NULLTAG) {
|
|
|
goto end;
|
|
|
}
|
|
|
ITKCALL(ifail = EPM_ask_root_task(task_tag, &rootTask_tag));
|
|
|
//获取目标下所有对象
|
|
|
ITKCALL(ifail = EPM_ask_attachments(rootTask_tag, EPM_target_attachment, &att_cnt, &attachments));
|
|
|
if (att_cnt == 0) {
|
|
|
goto end;
|
|
|
}
|
|
|
|
|
|
//解析首选项
|
|
|
{
|
|
|
getPrefStrings(RAYCUS_PLM_TO_SAP_Bom, TC_preference_site, urlPrefs);
|
|
|
if (urlPrefs.size() != 3)
|
|
|
{
|
|
|
WriteLog(debug, "首选项配置错误");
|
|
|
EMH_store_error_s2(EMH_severity_error,
|
|
|
ITK_err,
|
|
|
"首选项配置错误",
|
|
|
RAYCUS_PLM_TO_SAP_Bom);
|
|
|
ifail = ITK_err;
|
|
|
goto end;
|
|
|
}
|
|
|
getPrefStrings(RAYCUS_CONFIG_BOM_FIELDS, TC_preference_site, fieldPrefs);
|
|
|
parseConfigs(fieldPrefs, son_configs,title_configs);
|
|
|
if (son_configs.size() == 0 && title_configs.size() == 0)
|
|
|
{
|
|
|
WriteLog(debug, "首选项配置错误");
|
|
|
EMH_store_error_s2(EMH_severity_error,
|
|
|
ITK_err,
|
|
|
"首选项配置错误",
|
|
|
RAYCUS_CONFIG_BOM_FIELDS);
|
|
|
ifail = ITK_err;
|
|
|
goto end;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
for (int i = 0; i < att_cnt; i++)
|
|
|
{
|
|
|
tag_t attachment = attachments[i];
|
|
|
for each (string type in types)
|
|
|
{
|
|
|
if (!isTypeOf(attachment, type.c_str()))
|
|
|
{
|
|
|
continue;
|
|
|
}
|
|
|
char* ifSend;
|
|
|
tag_t item = NULLTAG, * revisions;
|
|
|
int rev_count = 0;
|
|
|
//判断属性字段“MBOM已传递(r9_ISTOSAP_MBOM)”如果值为Y,则不下发;值为N且版本数量为1,提取接口字段属性
|
|
|
AOM_ask_value_string(attachment,"r9_ISTOSAP_MBOM1",&ifSend);
|
|
|
if (strstr(ifSend, "Y") != NULL) {
|
|
|
continue;
|
|
|
}
|
|
|
ITEM_ask_item_of_rev(attachment, &item);
|
|
|
ITEM_find_revisions(item, "*", &rev_count, &revisions);
|
|
|
printf("版本数量为:%d\n", rev_count);
|
|
|
printf("是否下发的值为:%s\n", ifSend);
|
|
|
if (strstr(ifSend, "Y") == NULL && rev_count == 1) {
|
|
|
ITEM_rev_list_bom_view_revs(attachments[i], &bvr_count, &bvr_list);
|
|
|
BOM_create_window(&bom_window_tag);
|
|
|
BOM_set_window_top_line_bvr(bom_window_tag, bvr_list[bvr_count - 1], &top_line);
|
|
|
char* cglx,*tscglx = NULL;
|
|
|
AOM_ask_value_string(attachment,"r9_CGLX",&cglx);
|
|
|
AOM_ask_value_string(attachment, "r9_TXCGLX", &tscglx);
|
|
|
printf("采购类型的值为:%s\n", cglx);
|
|
|
if (cglx != NULL && strstr(cglx,"F") != NULL && (tscglx == NULL || strlen(tscglx) == 0)) {
|
|
|
break;
|
|
|
}
|
|
|
printf("开始得到数据\n");
|
|
|
jsonStr.append("{\"esbInfo\":{\"requestTime\":\"");
|
|
|
//获取当前时间
|
|
|
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);
|
|
|
jsonStr.append(date).append("\",\"instId\": \"\",\"attr2\": \"\",\"attr1\": \"\",\"attr3\":\"\"},\"requestInfo\": {\"ITEM\": [");
|
|
|
tag_t* children_line = NULLTAG;
|
|
|
BOM_line_ask_all_child_lines(top_line, &count, &children_line);
|
|
|
printf("子BOM的数量为%d",count);
|
|
|
for (int ii = 0; ii < count; ii++) {
|
|
|
jsonStr.append("{");
|
|
|
string son_value = read_data(children_line[ii], son_configs, top_line);
|
|
|
jsonStr.append(son_value);
|
|
|
//删除从pos开始的n个字符,比如erase(0,1)就是删除第一个字符
|
|
|
jsonStr.erase(jsonStr.size() - 1, 1);
|
|
|
jsonStr.append("},");
|
|
|
}
|
|
|
printf("开始添加title");
|
|
|
jsonStr.erase(jsonStr.size() - 1, 1);
|
|
|
jsonStr.append("],");
|
|
|
//添加抬头属性
|
|
|
jsonStr.append("\"header\":[{");
|
|
|
string title_value = read_data(top_line, title_configs,NULL);
|
|
|
jsonStr.append(title_value);
|
|
|
jsonStr.erase(jsonStr.size() - 1, 1);
|
|
|
jsonStr.append("}]}}@@");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
printf("数据位:%s", jsonStr.c_str());
|
|
|
if (jsonStr.empty()) {
|
|
|
goto end;
|
|
|
}
|
|
|
//把数据用写入文件
|
|
|
strcat(data_file, "C:\\PLM\\bomtoSapData");
|
|
|
strcat(data_file, "\\");
|
|
|
sprintf_s(fileDate, "%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);
|
|
|
strcat(data_file, fileDate);
|
|
|
strcat(data_file, ".txt");
|
|
|
|
|
|
strcat(data_file_return, "C:\\PLM\\bomtoSapData");
|
|
|
strcat(data_file_return, "\\");
|
|
|
sprintf_s(fileDate, "%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);
|
|
|
strcat(data_file_return, fileDate);
|
|
|
strcat(data_file_return, "return.txt");
|
|
|
|
|
|
strcat(data_file_error, "C:\\PLM\\bomtoSapData");
|
|
|
strcat(data_file_error, "\\");
|
|
|
strcat(data_file_error, fileDate);
|
|
|
strcat(data_file_error, "error.xlsx");
|
|
|
|
|
|
file.open(data_file);
|
|
|
file << jsonStr << endl; // 使用与cout同样的方式进行写入
|
|
|
file.close();
|
|
|
//--------------------------------------------
|
|
|
strcat(toJar, "java -jar C:\\PLM\\bomtoSap.jar ");
|
|
|
strcat(toJar, data_file);//json文件的地址
|
|
|
strcat(toJar, " ");
|
|
|
strcat(toJar, urlPrefs[0].c_str());//接口地址
|
|
|
strcat(toJar, " ");
|
|
|
strcat(toJar, urlPrefs[1].c_str());//http basic认证的用户名
|
|
|
strcat(toJar, " ");
|
|
|
strcat(toJar, urlPrefs[2].c_str());//http basic认证的密码
|
|
|
|
|
|
char buf[8000] = { 0 };
|
|
|
FILE* pf = NULL;
|
|
|
if ((pf = _popen(toJar, "r")) == NULL) {
|
|
|
printf("接口返回:\n%s", "1");
|
|
|
}
|
|
|
/*处理返回数据
|
|
|
1.当SAP返回值为成功时, TC物料属性字段““MBOM已传递(r9_ISTOSAP_MBOM)”值为Y;
|
|
|
2. 当SAP返回值为失败时, TC物料属性字段““MBOM已传递(r9_ISTOSAP_MBOM)值为N,并将失败原因填入“失败原因”字段;*/
|
|
|
char* return_data;
|
|
|
return_data = getfileall(data_file_return);
|
|
|
if (return_data == NULL) {
|
|
|
for (int i = 0; i < att_cnt; i++)
|
|
|
{
|
|
|
tag_t attachment = attachments[i];
|
|
|
POM_AM__set_application_bypass(true);
|
|
|
AOM_lock(attachment);
|
|
|
AOM_set_value_string(attachment, "r9_ISTOSAP_MBOM1", "Y");
|
|
|
AOM_save(attachment);
|
|
|
AOM_unlock(attachment);
|
|
|
AOM_refresh(attachment, FALSE);
|
|
|
POM_AM__set_application_bypass(false);
|
|
|
}
|
|
|
goto end;
|
|
|
}
|
|
|
Split(return_data, "@@", return_vector);
|
|
|
for (int i = 0; i < att_cnt; i++)
|
|
|
{
|
|
|
tag_t attachment = attachments[i];
|
|
|
char* item_id;
|
|
|
AOM_ask_value_string(attachment, "item_id", &item_id);
|
|
|
for each (string type in types)
|
|
|
{
|
|
|
int istosap = 0;
|
|
|
if (!isTypeOf(attachment, type.c_str()))
|
|
|
{
|
|
|
continue;
|
|
|
}
|
|
|
for each (string id in return_vector)
|
|
|
{
|
|
|
if (strstr(id.c_str(),item_id) != NULL) {
|
|
|
//更改版本中是否以下发为“是”
|
|
|
POM_AM__set_application_bypass(true);
|
|
|
//先lock
|
|
|
AOM_lock(attachment);
|
|
|
//再set
|
|
|
AOM_set_value_string(attachment, "r9_FailReason", id.c_str());
|
|
|
AOM_set_value_string(attachment, "r9_ISTOSAP_MBOM1", "N");
|
|
|
//再save
|
|
|
AOM_save(attachment);
|
|
|
//最后unlock
|
|
|
AOM_unlock(attachment);
|
|
|
AOM_refresh(attachment, FALSE);
|
|
|
POM_AM__set_application_bypass(false);
|
|
|
istosap = 1;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
if (istosap == 0) {
|
|
|
POM_AM__set_application_bypass(true);
|
|
|
AOM_lock(attachment);
|
|
|
AOM_set_value_string(attachment, "r9_ISTOSAP_MBOM1", "Y");
|
|
|
AOM_save(attachment);
|
|
|
AOM_unlock(attachment);
|
|
|
AOM_refresh(attachment, FALSE);
|
|
|
POM_AM__set_application_bypass(false);
|
|
|
}
|
|
|
}
|
|
|
DOFREE(item_id);
|
|
|
}
|
|
|
|
|
|
//data_file_error
|
|
|
end:
|
|
|
DOFREE(attachments);
|
|
|
types.clear();
|
|
|
WriteLog(debug, "执行结束:传递BOM到SAP (PLM_MBOM_TO_SAP_NEW)...");
|
|
|
return ifail;
|
|
|
}
|
|
|
|
|
|
int PLM_MBOM_TO_SAP_Revise(EPM_action_message_t msg) {
|
|
|
int ifail = ITK_ok,arg_cnt = 0,att_cnt = 0;
|
|
|
char* arg = NULL,* argflag = NULL,* argvalue = NULL, * object_type = NULL, toJar[1000] = "";
|
|
|
string type,jsonStr;
|
|
|
vector<string> types, urlPrefs, fieldPrefs, checkBomPorps;
|
|
|
vector<Config> son_configs, title_configs; vector<string> return_vector;
|
|
|
tag_t* attachments = NULLTAG, task_tag = NULLTAG, rootTask_tag = NULLTAG,
|
|
|
relation_type2 = NULLTAG, relation_type1 = NULLTAG,relation_type3 = NULLTAG;
|
|
|
time_t now = time(0);
|
|
|
tm* p = localtime(&now);
|
|
|
char date[128] = "", fileDate[128] = "";
|
|
|
char data_file[SS_MAXPATHLEN] = "", data_file_return[SS_MAXPATHLEN] = "";
|
|
|
ofstream file;
|
|
|
|
|
|
WriteLog(debug, "开始执行:传递BOM到SAP修改 (PLM_MBOM_TO_SAP_Revise) ...\n");
|
|
|
arg_cnt = TC_number_of_arguments(msg.arguments);
|
|
|
if (arg_cnt > 0) {
|
|
|
for (int i = 0; i < arg_cnt; i++) {
|
|
|
arg = TC_next_argument(msg.arguments);
|
|
|
ITKCALL(ifail = ITK_ask_argument_named_value(arg, &argflag, &argvalue));
|
|
|
if (strcmp(argflag, "type") == 0) {
|
|
|
type.assign(argvalue);
|
|
|
}
|
|
|
MEM_free(argflag);
|
|
|
MEM_free(argvalue);
|
|
|
}
|
|
|
}
|
|
|
else {
|
|
|
EMH_store_error_s1(EMH_severity_error, ITK_err, "未配置流程参数");
|
|
|
ifail = 1;
|
|
|
goto end;
|
|
|
}
|
|
|
{
|
|
|
Split(type, ",", types);
|
|
|
if (types.size() == 0) {
|
|
|
EMH_store_error_s1(EMH_severity_error, ITK_err, "未配置流程参数:-type");
|
|
|
goto end;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//拿到当前节点
|
|
|
task_tag = msg.task;
|
|
|
if (task_tag == NULLTAG) {
|
|
|
goto end;
|
|
|
}
|
|
|
ITKCALL(ifail = EPM_ask_root_task(task_tag, &rootTask_tag));
|
|
|
//获取目标下所有对象
|
|
|
ITKCALL(ifail = EPM_ask_attachments(rootTask_tag, EPM_target_attachment, &att_cnt, &attachments));
|
|
|
if (att_cnt == 0) {
|
|
|
goto end;
|
|
|
}
|
|
|
//解析首选项
|
|
|
{
|
|
|
getPrefStrings(RAYCUS_PLM_TO_SAP_Bom_REVISE, TC_preference_site, urlPrefs);
|
|
|
if (urlPrefs.size() != 3)
|
|
|
{
|
|
|
WriteLog(debug, "首选项配置错误");
|
|
|
EMH_store_error_s2(EMH_severity_error,
|
|
|
ITK_err,
|
|
|
"首选项配置错误",
|
|
|
RAYCUS_PLM_TO_SAP_Bom_REVISE);
|
|
|
ifail = ITK_err;
|
|
|
goto end;
|
|
|
}
|
|
|
getPrefStrings(RAYCUS_CONFIG_BOM_FIELDS_REVISE, TC_preference_site, fieldPrefs);
|
|
|
parseConfigs(fieldPrefs, son_configs, title_configs);
|
|
|
if (son_configs.size() == 0 || title_configs.size() == 0)
|
|
|
{
|
|
|
WriteLog(debug, "首选项配置错误");
|
|
|
EMH_store_error_s2(EMH_severity_error,
|
|
|
ITK_err,
|
|
|
"首选项配置错误",
|
|
|
RAYCUS_CONFIG_BOM_FIELDS_REVISE);
|
|
|
ifail = ITK_err;
|
|
|
goto end;
|
|
|
}
|
|
|
getPrefStrings(RAYCUS_MBOM_Check_BOMLINE, TC_preference_site, checkBomPorps);
|
|
|
if (checkBomPorps.size() < 1) {
|
|
|
WriteLog(debug, "首选项配置错误");
|
|
|
EMH_store_error_s2(EMH_severity_error,
|
|
|
ITK_err,
|
|
|
"首选项配置错误",
|
|
|
RAYCUS_MBOM_Check_BOMLINE);
|
|
|
ifail = ITK_err;
|
|
|
goto end;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//寻找关系
|
|
|
ITKCALL(ifail = GRM_find_relation_type("R9_ProblemItem", &relation_type1));
|
|
|
if (relation_type1 == NULLTAG) {
|
|
|
WriteLog(debug, "未能找关系类型R9_ProblemItem!");
|
|
|
EMH_store_error_s1(EMH_severity_error, ITK_err, "未能找关系类型R9_ProblemItem!");
|
|
|
goto end;
|
|
|
}
|
|
|
ITKCALL(ifail = GRM_find_relation_type("R9_ProblemSolutionItem", &relation_type2));
|
|
|
if (relation_type2 == NULLTAG) {
|
|
|
WriteLog(debug, "未能找关系类型R9_ProblemSolutionItem!");
|
|
|
EMH_store_error_s1(EMH_severity_error, ITK_err, "未能找关系类型R9_ProblemSolutionItem!");
|
|
|
goto end;
|
|
|
}
|
|
|
ITKCALL(ifail = GRM_find_relation_type("IMAN_reference", &relation_type3));
|
|
|
if (relation_type3 == NULLTAG) {
|
|
|
WriteLog(debug, "未能找关系类型IMAN_reference!");
|
|
|
EMH_store_error_s1(EMH_severity_error, ITK_err, "未能找关系类型IMAN_reference!");
|
|
|
goto end;
|
|
|
}
|
|
|
|
|
|
for (int i = 0; i < att_cnt; i++)
|
|
|
{
|
|
|
tag_t attachment = attachments[i], *relation1_tag,*relation2_tag;
|
|
|
int relation_type1_count = 0, relation_type2_count = 0;
|
|
|
char* item_id1, * item_id2, * item_rev1, * item_rev2,*item_type1,* item_type2;
|
|
|
vector<tag_t> itemRevs2; vector<tag_t> itemRevs1; vector<BomlineType> revs;
|
|
|
//判断是否为R9_ECNRevision
|
|
|
if (isTypeOf(attachment, "R9_ECNRevision")) {
|
|
|
GRM_list_secondary_objects_only(attachment, relation_type1, &relation_type1_count, &relation1_tag);
|
|
|
GRM_list_secondary_objects_only(attachment, relation_type2, &relation_type2_count, &relation2_tag);
|
|
|
//检查问题项和解决方案项文件夹是否存在物料号相同,版本不同的BOM数据版本(关系下放的是对象版本)
|
|
|
for (int m = 0; m < relation_type1_count;m++) {
|
|
|
AOM_ask_value_string(relation1_tag[m],"item_id", &item_id1);
|
|
|
AOM_ask_value_string(relation1_tag[m], "item_revision_id", &item_rev1);
|
|
|
AOM_ask_value_string(relation1_tag[m], "object_type", &item_type1);
|
|
|
for (int n = 0; n < relation_type2_count; n++) {
|
|
|
AOM_ask_value_string(relation2_tag[n], "item_id", &item_id2);
|
|
|
AOM_ask_value_string(relation2_tag[n], "item_revision_id", &item_rev2);
|
|
|
AOM_ask_value_string(relation2_tag[n], "object_type", &item_type2);
|
|
|
if (strcmp(item_id1, item_id2) == 0 && strcmp(item_rev1, item_rev2) != 0 && strcmp(item_type1, item_type2) == 0) {
|
|
|
//id相同、版本不同,(类型相同)记录下版本
|
|
|
itemRevs2.push_back(relation2_tag[n]);
|
|
|
itemRevs1.push_back(relation1_tag[m]);
|
|
|
BomlineType rev;
|
|
|
rev.rev_tag = relation2_tag[n];
|
|
|
rev.id = item_id2;
|
|
|
revs.push_back(rev);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
//对比BOM的差异
|
|
|
for (int i = 0; i < itemRevs1.size(); i++) {
|
|
|
tag_t rev1 = itemRevs1[i];
|
|
|
tag_t rev2 = itemRevs2[i];
|
|
|
for each (string type in types)
|
|
|
{
|
|
|
if (isTypeOf(rev2, type.c_str()) && isTypeOf(rev1, type.c_str()))
|
|
|
{
|
|
|
/*先判断BOM层级是否已经传递过SAP:属性字段“MBOM已传递(r9_ISTOSAP_MBOM)”如果值为true,则不下发;
|
|
|
值为false且版本数量≥2,提取接口字段属性,以JSON格式传递给SAP。*/
|
|
|
char* ifSend;
|
|
|
tag_t item, * revisions;
|
|
|
int rev_count = 0;
|
|
|
AOM_ask_value_string(rev2, "r9_ISTOSAP_MBOM1", &ifSend);
|
|
|
ITEM_ask_item_of_rev(rev2, &item);
|
|
|
ITEM_find_revisions(item, "*", &rev_count, &revisions);
|
|
|
if (strstr(ifSend, "Y") == NULL && rev_count > 1) {
|
|
|
int relation_type3_count = 0,snapshot_count = 0;
|
|
|
tag_t *relation3_tag = NULLTAG,*snapshot_tags = NULLTAG;
|
|
|
vector<BomlineType> lines1;
|
|
|
//vector<BomlineType> lines1_compare;
|
|
|
vector<BomlineType> lines2;
|
|
|
vector<BomlineType> sendDatas;
|
|
|
vector<BomlineType> waitCompare;
|
|
|
getBomProp(rev1, lines1);
|
|
|
tag_t top_line = getBomProp(rev2, lines2);
|
|
|
char* cglx = NULL, * tscglx = NULL;
|
|
|
AOM_ask_value_string(attachment, "r9_CGLX", &cglx);
|
|
|
AOM_ask_value_string(attachment, "r9_TXCGLX", &tscglx);
|
|
|
printf("采购类型的值为:%s\n", cglx);
|
|
|
if (cglx != NULL && strstr(cglx, "F") != NULL && (tscglx == NULL || strlen(tscglx) == 0)) {
|
|
|
break;
|
|
|
}
|
|
|
GRM_list_secondary_objects_only(rev1, relation_type3, &relation_type3_count, &relation3_tag);
|
|
|
for (int j = 0; j < relation_type3_count; j++)
|
|
|
{
|
|
|
char* object_name;
|
|
|
AOM_ask_value_string(relation3_tag[j], "object_name", &object_name);
|
|
|
if (strcmp("MySnapshot",object_name) == 0) {
|
|
|
AOM_ask_value_tags(relation3_tag[j], "contents", &snapshot_count, &snapshot_tags);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
//for each (BomlineType line in lines1_compare)
|
|
|
//{
|
|
|
// map<string, string> maps;
|
|
|
// for (int j = 0; j < snapshot_count; j++)
|
|
|
// {
|
|
|
// char *item_id = NULL,*rev_id = NULL;
|
|
|
// AOM_ask_value_string(snapshot_tags[j], "item_id", &item_id);
|
|
|
// AOM_ask_value_string(snapshot_tags[j], "item_revision_id", &rev_id);
|
|
|
// maps.insert(pair<string, string>(item_id, rev_id));
|
|
|
// }
|
|
|
// map<string, string>::iterator it = maps.find(line.id);
|
|
|
// if (it != maps.end()) {
|
|
|
// //line.revision_id = it->second;
|
|
|
// line.revision_id.assign(it->second);
|
|
|
// printf("版本为%s\n", line.revision_id.c_str());
|
|
|
// lines1.push_back(line);
|
|
|
// }
|
|
|
//}
|
|
|
for (int h = 0; h < lines1.size(); h++)
|
|
|
{
|
|
|
map<string, string> maps;
|
|
|
for (int j = 0; j < snapshot_count; j++)
|
|
|
{
|
|
|
char *item_id = NULL,*rev_id = NULL;
|
|
|
AOM_ask_value_string(snapshot_tags[j], "item_id", &item_id);
|
|
|
AOM_ask_value_string(snapshot_tags[j], "item_revision_id", &rev_id);
|
|
|
maps.insert(pair<string, string>(item_id, rev_id));
|
|
|
}
|
|
|
map<string, string>::iterator it = maps.find(lines1[h].id);
|
|
|
if (it != maps.end()) {
|
|
|
//line.revision_id = it->second;
|
|
|
lines1[h].revision_id = it->second;
|
|
|
}
|
|
|
}
|
|
|
//比较删除
|
|
|
for each (BomlineType line1 in lines1)
|
|
|
{
|
|
|
int count = 0;
|
|
|
for each (BomlineType line2 in lines2)
|
|
|
{
|
|
|
if (strcmp(line1.id.c_str(),line2.id.c_str()) == 0
|
|
|
//&& strcmp(line1.revision_id.c_str(), line2.revision_id.c_str()) == 0
|
|
|
&& strcmp(line1.sequence.c_str(), line2.sequence.c_str()) == 0) {
|
|
|
break;
|
|
|
}
|
|
|
else {
|
|
|
count++;
|
|
|
}
|
|
|
}
|
|
|
if (count == lines2.size()) {
|
|
|
//这是删除的
|
|
|
line1.flag = "D";
|
|
|
sendDatas.push_back(line1);
|
|
|
}
|
|
|
}
|
|
|
//比较新增和修改
|
|
|
for each (BomlineType line2 in lines2)
|
|
|
{
|
|
|
int count = 0;
|
|
|
for each (BomlineType line1 in lines1)
|
|
|
{
|
|
|
if (strcmp(line1.id.c_str(), line2.id.c_str()) == 0
|
|
|
&& strcmp(line1.sequence.c_str(), line2.sequence.c_str()) == 0) {
|
|
|
printf("这是ID相同的数据:%s\n", line2.id.c_str());
|
|
|
printf("两个版本为%s---%s\n", line1.revision_id.c_str(), line2.revision_id.c_str());
|
|
|
if (strcmp(line1.revision_id.c_str(), line2.revision_id.c_str()) == 0) {
|
|
|
//待比较属性的
|
|
|
waitCompare.push_back(line2);
|
|
|
break;
|
|
|
}
|
|
|
else {
|
|
|
printf("这是改变版本的数据:%s\n", line2.id.c_str());
|
|
|
//这是修改的
|
|
|
line2.flag = "U";
|
|
|
sendDatas.push_back(line2);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
else {
|
|
|
count++;
|
|
|
}
|
|
|
}
|
|
|
if (count == lines1.size()) {
|
|
|
//这是新增的
|
|
|
line2.flag = "A";
|
|
|
sendDatas.push_back(line2);
|
|
|
}
|
|
|
}
|
|
|
//比较BOM属性
|
|
|
for each (BomlineType com in waitCompare)
|
|
|
{
|
|
|
for each (BomlineType line1 in lines1)
|
|
|
{
|
|
|
if (strcmp(line1.id.c_str(), com.id.c_str()) == 0
|
|
|
&& strcmp(line1.revision_id.c_str(), com.revision_id.c_str()) == 0
|
|
|
&& strcmp(line1.sequence.c_str(), com.sequence.c_str()) == 0) {
|
|
|
boolean compare = compareProps(line1, com, checkBomPorps);
|
|
|
if (compare) {
|
|
|
com.flag = "U";
|
|
|
sendDatas.push_back(com);
|
|
|
}
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
//转换成json
|
|
|
jsonStr.append("{\"esbInfo\":{\"requestTime\":\"");
|
|
|
//获取当前时间
|
|
|
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);
|
|
|
jsonStr.append(date).append("\",\"instId\": \"\",\"attr2\": \"\",\"attr1\": \"\",\"attr3\":\"\"},\"requestInfo\": {\"ITEM\": [");
|
|
|
for each (BomlineType send in sendDatas)
|
|
|
{
|
|
|
jsonStr.append("{");
|
|
|
string son_value = read_data(send.bom_tag, son_configs, top_line);
|
|
|
jsonStr.append(son_value);
|
|
|
//删除从pos开始的n个字符,比如erase(0,1)就是删除第一个字符
|
|
|
jsonStr.append("\"i_flag\": \"");
|
|
|
jsonStr.append(send.flag);
|
|
|
jsonStr.append("\"},");
|
|
|
//jsonStr.erase(jsonStr.size() - 1, 1);
|
|
|
//jsonStr.append("},");
|
|
|
}
|
|
|
jsonStr.erase(jsonStr.size() - 1, 1);
|
|
|
jsonStr.append("],");
|
|
|
//添加抬头属性
|
|
|
jsonStr.append("\"header\":[{");
|
|
|
string title_value = read_data(top_line, title_configs,NULL);
|
|
|
jsonStr.append(title_value);
|
|
|
jsonStr.erase(jsonStr.size() - 1, 1);
|
|
|
jsonStr.append("}]}}@@");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
if (jsonStr.empty()) {
|
|
|
goto end;
|
|
|
}
|
|
|
//把数据用写入文件
|
|
|
strcat(data_file, "C:\\PLM\\bomtoSapData");
|
|
|
strcat(data_file, "\\");
|
|
|
sprintf_s(fileDate, "%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);
|
|
|
strcat(data_file, fileDate);
|
|
|
strcat(data_file, ".txt");
|
|
|
|
|
|
strcat(data_file_return, "C:\\PLM\\bomtoSapData");
|
|
|
strcat(data_file_return, "\\");
|
|
|
sprintf_s(fileDate, "%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);
|
|
|
strcat(data_file_return, fileDate);
|
|
|
strcat(data_file_return, "return.txt");
|
|
|
|
|
|
file.open(data_file);
|
|
|
file << jsonStr << endl; // 使用与cout同样的方式进行写入
|
|
|
file.close();
|
|
|
//--------------------------------------------
|
|
|
strcat(toJar, "java -jar C:\\PLM\\bomtoSap.jar ");
|
|
|
strcat(toJar, data_file);//json文件的地址
|
|
|
strcat(toJar, " ");
|
|
|
strcat(toJar, urlPrefs[0].c_str());//接口地址
|
|
|
strcat(toJar, " ");
|
|
|
strcat(toJar, urlPrefs[1].c_str());//http basic认证的用户名
|
|
|
strcat(toJar, " ");
|
|
|
strcat(toJar, urlPrefs[2].c_str());//http basic认证的密码
|
|
|
|
|
|
char buf[8000] = { 0 };
|
|
|
FILE* pf = NULL;
|
|
|
if ((pf = _popen(toJar, "r")) == NULL) {
|
|
|
printf("接口返回:\n%s", "1");
|
|
|
}
|
|
|
//处理返回数据(错误日志放到当前用户的newstuff)
|
|
|
/*处理返回数据
|
|
|
1.当SAP返回值为成功时, TC物料属性字段““MBOM已传递(r9_ISTOSAP_MBOM)”值为Y;
|
|
|
2. 当SAP返回值为失败时, TC物料属性字段““MBOM已传递(r9_ISTOSAP_MBOM)值为N,并将失败原因填入“失败原因”字段;*/
|
|
|
char* return_data;
|
|
|
return_data = getfileall(data_file_return);
|
|
|
if (return_data == NULL) {
|
|
|
for (int i = 0; i < att_cnt; i++)
|
|
|
{
|
|
|
tag_t attachment = attachments[i];
|
|
|
POM_AM__set_application_bypass(true);
|
|
|
AOM_lock(attachment);
|
|
|
AOM_set_value_string(attachment, "r9_ISTOSAP_MBOM1", "Y");
|
|
|
AOM_save(attachment);
|
|
|
AOM_unlock(attachment);
|
|
|
AOM_refresh(attachment, FALSE);
|
|
|
POM_AM__set_application_bypass(false);
|
|
|
}
|
|
|
goto end;
|
|
|
}
|
|
|
Split(return_data, "@@", return_vector);
|
|
|
for (int i = 0; i < att_cnt; i++)
|
|
|
{
|
|
|
tag_t attachment = attachments[i];
|
|
|
char* item_id;
|
|
|
AOM_ask_value_string(attachment, "item_id", &item_id);
|
|
|
for each (string type in types)
|
|
|
{
|
|
|
int istosap = 0;
|
|
|
if (!isTypeOf(attachment, type.c_str()))
|
|
|
{
|
|
|
continue;
|
|
|
}
|
|
|
for each (string id in return_vector)
|
|
|
{
|
|
|
if (strstr(id.c_str(), item_id) != NULL) {
|
|
|
//更改版本中是否以下发为“是”
|
|
|
POM_AM__set_application_bypass(true);
|
|
|
//先lock
|
|
|
AOM_lock(attachment);
|
|
|
//再set
|
|
|
AOM_set_value_string(attachment, "r9_FailReason", id.c_str());
|
|
|
AOM_set_value_string(attachment, "r9_ISTOSAP_MBOM1", "N");
|
|
|
//再save
|
|
|
AOM_save(attachment);
|
|
|
//最后unlock
|
|
|
AOM_unlock(attachment);
|
|
|
AOM_refresh(attachment, FALSE);
|
|
|
POM_AM__set_application_bypass(false);
|
|
|
istosap = 1;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
if (istosap == 0) {
|
|
|
POM_AM__set_application_bypass(true);
|
|
|
AOM_lock(attachment);
|
|
|
AOM_set_value_string(attachment, "r9_ISTOSAP_MBOM1", "Y");
|
|
|
AOM_save(attachment);
|
|
|
AOM_unlock(attachment);
|
|
|
AOM_refresh(attachment, FALSE);
|
|
|
POM_AM__set_application_bypass(false);
|
|
|
}
|
|
|
}
|
|
|
DOFREE(item_id);
|
|
|
}
|
|
|
|
|
|
end:
|
|
|
DOFREE(attachments);
|
|
|
DOFREE(object_type);
|
|
|
types.clear();
|
|
|
WriteLog(debug, "执行结束:传递BOM到SAP修改 (PLM_MBOM_TO_SAP_Revise)...");
|
|
|
return ifail;
|
|
|
}
|
|
|
|
|
|
int PLM_FBMBOM_TO_SAP(EPM_action_message_t msg) {
|
|
|
int ifail = ITK_ok, arg_cnt = 0, att_cnt = 0, bvr_count = 0, count = 0;
|
|
|
char* arg = NULL, * argflag = NULL, * argvalue = NULL, toJar[1000] = "";
|
|
|
tag_t* attachments = NULLTAG, task_tag = NULLTAG, rootTask_tag, * bvr_list = NULLTAG, bom_window_tag, top_line;
|
|
|
string type, jsonStr;
|
|
|
vector<string> types, urlPrefs, fieldPrefs, return_vector;
|
|
|
vector<Config> son_configs, title_configs;
|
|
|
|
|
|
time_t now = time(0);
|
|
|
tm* p = localtime(&now);
|
|
|
char date[128] = "", fileDate[128] = "";
|
|
|
char* tc_root_file = getenv("tc_root"); //C:\Siemens\Teamcenter11
|
|
|
char data_file[SS_MAXPATHLEN] = "", data_file_return[SS_MAXPATHLEN] = "";
|
|
|
ofstream file;
|
|
|
|
|
|
WriteLog(debug, "开始执行:传递BOM到SAP (PLM_FBMBOM_TO_SAP) ...");
|
|
|
arg_cnt = TC_number_of_arguments(msg.arguments);
|
|
|
if (arg_cnt > 0) {
|
|
|
for (int i = 0; i < arg_cnt; i++) {
|
|
|
arg = TC_next_argument(msg.arguments);
|
|
|
ITKCALL(ifail = ITK_ask_argument_named_value(arg, &argflag, &argvalue));
|
|
|
if (strcmp(argflag, "type") == 0) {
|
|
|
type.assign(argvalue);
|
|
|
}
|
|
|
MEM_free(argflag);
|
|
|
MEM_free(argvalue);
|
|
|
}
|
|
|
}
|
|
|
else {
|
|
|
EMH_store_error_s1(EMH_severity_error, ITK_err, "未配置流程参数");
|
|
|
ifail = 1;
|
|
|
goto end;
|
|
|
}
|
|
|
{
|
|
|
Split(type, ",", types);
|
|
|
if (types.size() == 0) {
|
|
|
EMH_store_error_s1(EMH_severity_error, ITK_err, "未配置流程参数:-type");
|
|
|
goto end;
|
|
|
}
|
|
|
}
|
|
|
//拿到当前节点
|
|
|
task_tag = msg.task;
|
|
|
if (task_tag == NULLTAG) {
|
|
|
goto end;
|
|
|
}
|
|
|
ITKCALL(ifail = EPM_ask_root_task(task_tag, &rootTask_tag));
|
|
|
//获取目标下所有对象
|
|
|
ITKCALL(ifail = EPM_ask_attachments(rootTask_tag, EPM_target_attachment, &att_cnt, &attachments));
|
|
|
if (att_cnt == 0) {
|
|
|
goto end;
|
|
|
}
|
|
|
|
|
|
//解析首选项
|
|
|
{
|
|
|
getPrefStrings(RAYCUS_PLM_TO_SAP_FBBom, TC_preference_site, urlPrefs);
|
|
|
if (urlPrefs.size() != 3)
|
|
|
{
|
|
|
WriteLog(debug, "首选项配置错误");
|
|
|
EMH_store_error_s2(EMH_severity_error,
|
|
|
ITK_err,
|
|
|
"首选项配置错误",
|
|
|
RAYCUS_PLM_TO_SAP_FBBom);
|
|
|
ifail = ITK_err;
|
|
|
goto end;
|
|
|
}
|
|
|
getPrefStrings(RAYCUS_CONFIG_FBBOM_FIELDS, TC_preference_site, fieldPrefs);
|
|
|
parseConfigs(fieldPrefs, son_configs, title_configs);
|
|
|
if (son_configs.size() == 0 || title_configs.size() == 0)
|
|
|
{
|
|
|
WriteLog(debug, "首选项配置错误");
|
|
|
EMH_store_error_s2(EMH_severity_error,
|
|
|
ITK_err,
|
|
|
"首选项配置错误",
|
|
|
RAYCUS_CONFIG_FBBOM_FIELDS);
|
|
|
ifail = ITK_err;
|
|
|
goto end;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
for (int i = 0; i < att_cnt; i++)
|
|
|
{
|
|
|
tag_t attachment = attachments[i];
|
|
|
for each (string type in types)
|
|
|
{
|
|
|
if (!isTypeOf(attachment, type.c_str()))
|
|
|
{
|
|
|
continue;
|
|
|
}
|
|
|
char* ifSend;
|
|
|
tag_t item = NULLTAG, * revisions;
|
|
|
int rev_count = 0;
|
|
|
//判断属性字段“MBOM已传递(r9_ISTOSAP_MBOM)”如果值为Y,则不下发;值为N且版本数量为1,提取接口字段属性
|
|
|
AOM_ask_value_string(attachment, "r9_ISTOSAP_MBOM1", &ifSend);
|
|
|
if (strstr(ifSend, "Y") != NULL) {
|
|
|
continue;
|
|
|
}
|
|
|
char* cglx, * tscglx = NULL;
|
|
|
AOM_ask_value_string(attachment, "r9_CGLX", &cglx);
|
|
|
AOM_ask_value_string(attachment, "r9_TXCGLX", &tscglx);
|
|
|
printf("采购类型的值为:%s\n", cglx);
|
|
|
if (cglx != NULL && strstr(cglx, "F") != NULL && (tscglx == NULL || strlen(tscglx) == 0)) {
|
|
|
break;
|
|
|
}
|
|
|
ITEM_rev_list_bom_view_revs(attachments[i], &bvr_count, &bvr_list);
|
|
|
BOM_create_window(&bom_window_tag);
|
|
|
BOM_set_window_top_line_bvr(bom_window_tag, bvr_list[bvr_count - 1], &top_line);
|
|
|
|
|
|
jsonStr.append("{\"esbInfo\":{\"requestTime\":\"");
|
|
|
//获取当前时间
|
|
|
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);
|
|
|
jsonStr.append(date).append("\",\"instId\": \"\",\"attr2\": \"\",\"attr1\": \"\",\"attr3\":\"\"},\"requestInfo\": {\"ITEM\": [");
|
|
|
tag_t* children_line = NULLTAG;
|
|
|
BOM_line_ask_all_child_lines(top_line, &count, &children_line);
|
|
|
for (int ii = 0; ii < count; ii++) {
|
|
|
jsonStr.append("{");
|
|
|
string son_value = read_data(children_line[ii], son_configs, top_line);
|
|
|
jsonStr.append(son_value);
|
|
|
//删除从pos开始的n个字符,比如erase(0,1)就是删除第一个字符
|
|
|
jsonStr.erase(jsonStr.size() - 1, 1);
|
|
|
jsonStr.append("},");
|
|
|
}
|
|
|
jsonStr.erase(jsonStr.size() - 1, 1);
|
|
|
jsonStr.append("],");
|
|
|
//添加抬头属性
|
|
|
string title_value = read_data(top_line, title_configs, NULL);
|
|
|
jsonStr.append(title_value);
|
|
|
jsonStr.erase(jsonStr.size() - 1, 1);
|
|
|
jsonStr.append("}}@@");
|
|
|
|
|
|
}
|
|
|
}
|
|
|
if (jsonStr.empty()) {
|
|
|
goto end;
|
|
|
}
|
|
|
//把数据用写入文件
|
|
|
strcat(data_file, "C:\\PLM\\bomtoSapData");
|
|
|
strcat(data_file, "\\");
|
|
|
sprintf_s(fileDate, "%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);
|
|
|
strcat(data_file, fileDate);
|
|
|
strcat(data_file, ".txt");
|
|
|
|
|
|
strcat(data_file_return, "C:\\PLM\\bomtoSapData");
|
|
|
strcat(data_file_return, "\\");
|
|
|
sprintf_s(fileDate, "%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);
|
|
|
strcat(data_file_return, fileDate);
|
|
|
strcat(data_file_return, "return.txt");
|
|
|
|
|
|
file.open(data_file);
|
|
|
file << jsonStr << endl; // 使用与cout同样的方式进行写入
|
|
|
file.close();
|
|
|
//--------------------------------------------
|
|
|
strcat(toJar, "java -jar C:\\PLM\\bomtoSap.jar ");
|
|
|
strcat(toJar, data_file);//json文件的地址
|
|
|
strcat(toJar, " ");
|
|
|
strcat(toJar, urlPrefs[0].c_str());//接口地址
|
|
|
strcat(toJar, " ");
|
|
|
strcat(toJar, urlPrefs[1].c_str());//http basic认证的用户名
|
|
|
strcat(toJar, " ");
|
|
|
strcat(toJar, urlPrefs[2].c_str());//http basic认证的密码
|
|
|
|
|
|
char buf[8000] = { 0 };
|
|
|
FILE* pf = NULL;
|
|
|
if ((pf = _popen(toJar, "r")) == NULL) {
|
|
|
printf("接口返回:\n%s", "1");
|
|
|
}
|
|
|
/*处理返回数据
|
|
|
1.当SAP返回值为成功时, TC物料属性字段““MBOM已传递(r9_ISTOSAP_MBOM)”值为Y;
|
|
|
2. 当SAP返回值为失败时, TC物料属性字段““MBOM已传递(r9_ISTOSAP_MBOM)值为N,并将失败原因填入“失败原因”字段;*/
|
|
|
char* return_data;
|
|
|
return_data = getfileall(data_file_return);
|
|
|
if (return_data == NULL) {
|
|
|
for (int i = 0; i < att_cnt; i++)
|
|
|
{
|
|
|
tag_t attachment = attachments[i];
|
|
|
POM_AM__set_application_bypass(true);
|
|
|
AOM_lock(attachment);
|
|
|
AOM_set_value_string(attachment, "r9_ISTOSAP_MBOM", "Y");
|
|
|
AOM_save(attachment);
|
|
|
AOM_unlock(attachment);
|
|
|
AOM_refresh(attachment, FALSE);
|
|
|
POM_AM__set_application_bypass(false);
|
|
|
}
|
|
|
goto end;
|
|
|
}
|
|
|
Split(return_data, "@@", return_vector);
|
|
|
for (int i = 0; i < att_cnt; i++)
|
|
|
{
|
|
|
tag_t attachment = attachments[i];
|
|
|
char* item_id;
|
|
|
AOM_ask_value_string(attachment, "item_id", &item_id);
|
|
|
for each (string type in types)
|
|
|
{
|
|
|
int istosap = 0;
|
|
|
if (!isTypeOf(attachment, type.c_str()))
|
|
|
{
|
|
|
continue;
|
|
|
}
|
|
|
for each (string id in return_vector)
|
|
|
{
|
|
|
if (strstr(id.c_str(), item_id) != NULL) {
|
|
|
//更改版本中是否以下发为“是”
|
|
|
POM_AM__set_application_bypass(true);
|
|
|
//先lock
|
|
|
AOM_lock(attachment);
|
|
|
//再set
|
|
|
AOM_set_value_string(attachment, "r9_FailReason", id.c_str());
|
|
|
AOM_set_value_string(attachment, "r9_ISTOSAP_MBOM", "N");
|
|
|
//再save
|
|
|
AOM_save(attachment);
|
|
|
//最后unlock
|
|
|
AOM_unlock(attachment);
|
|
|
AOM_refresh(attachment, FALSE);
|
|
|
POM_AM__set_application_bypass(false);
|
|
|
istosap = 1;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
if (istosap == 0) {
|
|
|
POM_AM__set_application_bypass(true);
|
|
|
AOM_lock(attachment);
|
|
|
AOM_set_value_string(attachment, "r9_ISTOSAP_MBOM", "Y");
|
|
|
AOM_save(attachment);
|
|
|
AOM_unlock(attachment);
|
|
|
AOM_refresh(attachment, FALSE);
|
|
|
POM_AM__set_application_bypass(false);
|
|
|
}
|
|
|
}
|
|
|
DOFREE(item_id);
|
|
|
}
|
|
|
|
|
|
end:
|
|
|
DOFREE(attachments);
|
|
|
types.clear();
|
|
|
WriteLog(debug, "执行结束:传递BOM到SAP (PLM_FBMBOM_TO_SAP)...");
|
|
|
return ifail;
|
|
|
}
|
|
|
|
|
|
int PLM_BZGX_TO_SAP(EPM_action_message_t msg) {
|
|
|
int ifail = ITK_ok, arg_cnt = 0, att_cnt = 0, bvr_count = 0, count = 0;
|
|
|
char* arg = NULL, * argflag = NULL, * argvalue = NULL, toJar[1000] = "";
|
|
|
tag_t* attachments = NULLTAG, task_tag = NULLTAG, rootTask_tag, * bvr_list = NULLTAG, bom_window_tag, top_line = NULLTAG;
|
|
|
string type, jsonStr;
|
|
|
vector<string> types, urlPrefs, fieldPrefs, return_vector;
|
|
|
vector<Config> son_configs, title_configs;
|
|
|
|
|
|
time_t now = time(0);
|
|
|
tm* p = localtime(&now);
|
|
|
char date[128] = "", fileDate[128] = "";
|
|
|
char* tc_root_file = getenv("tc_root"); //C:\Siemens\Teamcenter11
|
|
|
char data_file[SS_MAXPATHLEN] = "", data_file_return[SS_MAXPATHLEN] = "";
|
|
|
ofstream file;
|
|
|
|
|
|
WriteLog(debug, "开始执行:传递标准工序到SAP (PLM_BZGX_TO_SAP) ...");
|
|
|
arg_cnt = TC_number_of_arguments(msg.arguments);
|
|
|
if (arg_cnt > 0) {
|
|
|
for (int i = 0; i < arg_cnt; i++) {
|
|
|
arg = TC_next_argument(msg.arguments);
|
|
|
ITKCALL(ifail = ITK_ask_argument_named_value(arg, &argflag, &argvalue));
|
|
|
if (strcmp(argflag, "type") == 0) {
|
|
|
type.assign(argvalue);
|
|
|
}
|
|
|
MEM_free(argflag);
|
|
|
MEM_free(argvalue);
|
|
|
}
|
|
|
}
|
|
|
else {
|
|
|
EMH_store_error_s1(EMH_severity_error, ITK_err, "未配置流程参数");
|
|
|
ifail = 1;
|
|
|
goto end;
|
|
|
}
|
|
|
{
|
|
|
Split(type, ",", types);
|
|
|
if (types.size() == 0) {
|
|
|
EMH_store_error_s1(EMH_severity_error, ITK_err, "未配置流程参数:-type");
|
|
|
goto end;
|
|
|
}
|
|
|
}
|
|
|
//拿到当前节点
|
|
|
task_tag = msg.task;
|
|
|
if (task_tag == NULLTAG) {
|
|
|
goto end;
|
|
|
}
|
|
|
ITKCALL(ifail = EPM_ask_root_task(task_tag, &rootTask_tag));
|
|
|
//获取目标下所有对象
|
|
|
ITKCALL(ifail = EPM_ask_attachments(rootTask_tag, EPM_target_attachment, &att_cnt, &attachments));
|
|
|
if (att_cnt == 0) {
|
|
|
goto end;
|
|
|
}
|
|
|
|
|
|
//解析首选项
|
|
|
{
|
|
|
getPrefStrings(RAYCUS_PLM_TO_SAP_BZGX, TC_preference_site, urlPrefs);
|
|
|
if (urlPrefs.size() != 3)
|
|
|
{
|
|
|
WriteLog(debug, "首选项配置错误");
|
|
|
EMH_store_error_s2(EMH_severity_error,
|
|
|
ITK_err,
|
|
|
"首选项配置错误",
|
|
|
RAYCUS_PLM_TO_SAP_BZGX);
|
|
|
ifail = ITK_err;
|
|
|
goto end;
|
|
|
}
|
|
|
getPrefStrings(RAYCUS_CONFIG_BZGX_FIELDS, TC_preference_site, fieldPrefs);
|
|
|
parseConfigs(fieldPrefs, son_configs, title_configs);
|
|
|
if (son_configs.size() == 0 && title_configs.size() == 0)
|
|
|
{
|
|
|
WriteLog(debug, "首选项配置错误");
|
|
|
EMH_store_error_s2(EMH_severity_error,
|
|
|
ITK_err,
|
|
|
"首选项配置错误",
|
|
|
RAYCUS_CONFIG_BZGX_FIELDS);
|
|
|
ifail = ITK_err;
|
|
|
goto end;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
for (int i = 0; i < att_cnt; i++)
|
|
|
{
|
|
|
tag_t attachment = attachments[i];
|
|
|
for each (string type in types)
|
|
|
{
|
|
|
if (!isTypeOf(attachment, type.c_str()))
|
|
|
{
|
|
|
continue;
|
|
|
}
|
|
|
char* ifSend;
|
|
|
tag_t item = NULLTAG, * revisions;
|
|
|
int rev_count = 0;
|
|
|
AOM_ask_value_string(attachment, "r9_ISTOSAP_BZGX", &ifSend);
|
|
|
if (strstr(ifSend, "Y") != NULL) {
|
|
|
continue;
|
|
|
}
|
|
|
ITEM_ask_item_of_rev(attachment, &item);
|
|
|
ITEM_find_revisions(item, "*", &rev_count, &revisions);
|
|
|
printf("版本数量为:%d\n", rev_count);
|
|
|
if (strstr(ifSend, "Y") == NULL && rev_count == 1) {
|
|
|
jsonStr.append("{\"esbInfo\":{\"requestTime\":\"");
|
|
|
//获取当前时间
|
|
|
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);
|
|
|
jsonStr.append(date).append("\",\"instId\": \"\",\"attr2\": \"\",\"attr1\": \"\",\"attr3\":\"\"},\"requestInfo\": {");
|
|
|
//添加抬头属性
|
|
|
for (int i = 0; i < title_configs.size(); i++)
|
|
|
{
|
|
|
tag_t data_tag = NULLTAG;
|
|
|
char *prop_value;
|
|
|
Config config = title_configs[i];
|
|
|
jsonStr.append("\"").append(config.send_name).append("\":\"");
|
|
|
if (strcmp(config.prop_type.c_str(), "item") == 0) {
|
|
|
data_tag = item;
|
|
|
}
|
|
|
else if (strcmp(config.prop_type.c_str(), "rev") == 0) {
|
|
|
data_tag = attachment;
|
|
|
}
|
|
|
ITKCALL(ifail = AOM_ask_value_string(data_tag, config.prop_name.c_str(), &prop_value));
|
|
|
jsonStr.append(prop_value);
|
|
|
jsonStr.append("\",");
|
|
|
}
|
|
|
jsonStr.erase(jsonStr.size() - 1, 1);
|
|
|
jsonStr.append("}}@@");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
if (jsonStr.empty()) {
|
|
|
goto end;
|
|
|
}
|
|
|
//把数据用写入文件
|
|
|
strcat(data_file, "C:\\PLM\\bomtoSapData");
|
|
|
strcat(data_file, "\\");
|
|
|
sprintf_s(fileDate, "%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);
|
|
|
strcat(data_file, fileDate);
|
|
|
strcat(data_file, ".txt");
|
|
|
|
|
|
strcat(data_file_return, "C:\\PLM\\bomtoSapData");
|
|
|
strcat(data_file_return, "\\");
|
|
|
sprintf_s(fileDate, "%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);
|
|
|
strcat(data_file_return, fileDate);
|
|
|
strcat(data_file_return, "return.txt");
|
|
|
|
|
|
file.open(data_file);
|
|
|
file << jsonStr << endl; // 使用与cout同样的方式进行写入
|
|
|
file.close();
|
|
|
//--------------------------------------------
|
|
|
strcat(toJar, "java -jar C:\\PLM\\bomtoSap.jar ");
|
|
|
strcat(toJar, data_file);//json文件的地址
|
|
|
strcat(toJar, " ");
|
|
|
strcat(toJar, urlPrefs[0].c_str());//接口地址
|
|
|
strcat(toJar, " ");
|
|
|
strcat(toJar, urlPrefs[1].c_str());//http basic认证的用户名
|
|
|
strcat(toJar, " ");
|
|
|
strcat(toJar, urlPrefs[2].c_str());//http basic认证的密码
|
|
|
strcat(toJar, " 标准工序");
|
|
|
|
|
|
char buf[8000] = { 0 };
|
|
|
FILE* pf = NULL;
|
|
|
if ((pf = _popen(toJar, "r")) == NULL) {
|
|
|
printf("接口返回:\n%s", "1");
|
|
|
}
|
|
|
/*处理返回数据
|
|
|
1.当SAP返回值为成功时, TC物料属性字段““MBOM已传递(r9_ISTOSAP_MBOM)”值为Y;
|
|
|
2. 当SAP返回值为失败时, TC物料属性字段““MBOM已传递(r9_ISTOSAP_MBOM)值为N,并将失败原因填入“失败原因”字段;*/
|
|
|
char* return_data;
|
|
|
return_data = getfileall(data_file_return);
|
|
|
if (return_data == NULL) {
|
|
|
for (int i = 0; i < att_cnt; i++)
|
|
|
{
|
|
|
tag_t attachment = attachments[i];
|
|
|
POM_AM__set_application_bypass(true);
|
|
|
AOM_lock(attachment);
|
|
|
AOM_set_value_string(attachment, "r9_ISTOSAP_BZGX", "Y");
|
|
|
AOM_save(attachment);
|
|
|
AOM_unlock(attachment);
|
|
|
AOM_refresh(attachment, FALSE);
|
|
|
POM_AM__set_application_bypass(false);
|
|
|
}
|
|
|
goto end;
|
|
|
}
|
|
|
Split(return_data, "@@", return_vector);
|
|
|
for (int i = 0; i < att_cnt; i++)
|
|
|
{
|
|
|
tag_t attachment = attachments[i];
|
|
|
char* item_id;
|
|
|
AOM_ask_value_string(attachment, "item_id", &item_id);
|
|
|
for each (string type in types)
|
|
|
{
|
|
|
int istosap = 0;
|
|
|
if (!isTypeOf(attachment, type.c_str()))
|
|
|
{
|
|
|
continue;
|
|
|
}
|
|
|
for each (string id in return_vector)
|
|
|
{
|
|
|
if (strstr(id.c_str(), item_id) != NULL) {
|
|
|
//更改版本中是否以下发为“是”
|
|
|
POM_AM__set_application_bypass(true);
|
|
|
//先lock
|
|
|
AOM_lock(attachment);
|
|
|
//再set
|
|
|
AOM_set_value_string(attachment, "r9_FailReason", id.c_str());
|
|
|
AOM_set_value_string(attachment, "r9_ISTOSAP_BZGX", "N");
|
|
|
//再save
|
|
|
AOM_save(attachment);
|
|
|
//最后unlock
|
|
|
AOM_unlock(attachment);
|
|
|
AOM_refresh(attachment, FALSE);
|
|
|
POM_AM__set_application_bypass(false);
|
|
|
istosap = 1;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
if (istosap == 0) {
|
|
|
POM_AM__set_application_bypass(true);
|
|
|
AOM_lock(attachment);
|
|
|
AOM_set_value_string(attachment, "r9_ISTOSAP_BZGX", "Y");
|
|
|
AOM_save(attachment);
|
|
|
AOM_unlock(attachment);
|
|
|
AOM_refresh(attachment, FALSE);
|
|
|
POM_AM__set_application_bypass(false);
|
|
|
}
|
|
|
}
|
|
|
DOFREE(item_id);
|
|
|
}
|
|
|
|
|
|
end:
|
|
|
DOFREE(attachments);
|
|
|
types.clear();
|
|
|
WriteLog(debug, "执行结束:传递标准工序到SAP (PLM_BZGX_TO_SAP)...");
|
|
|
return ifail;
|
|
|
}
|
|
|
|
|
|
boolean compareProps(BomlineType lines1, BomlineType lines2, vector<string> checkBomPorps) {
|
|
|
for each (string var in checkBomPorps)
|
|
|
{
|
|
|
char* value1 = NULL,*value2 = NULL;
|
|
|
AOM_ask_value_string(lines1.bom_tag,var.c_str(),&value1);
|
|
|
AOM_ask_value_string(lines2.bom_tag, var.c_str(), &value2);
|
|
|
if (strcmp(value1,value2) != 0) {
|
|
|
return true;
|
|
|
}
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
tag_t getBomProp(tag_t rev,vector<BomlineType>& lines) {
|
|
|
int viewNum = 0;
|
|
|
tag_t* viewTag = NULL_TAG, rev_tag = NULLTAG;
|
|
|
BomlineType son_line;
|
|
|
char* item_id = NULL, *bl_sequence = NULL,*item_revision_id = NULL;
|
|
|
|
|
|
//判断是否包含BOM视图
|
|
|
AOM_ask_value_tags(rev, "structure_revisions", &viewNum, &viewTag);
|
|
|
if (viewNum <= 0)
|
|
|
{
|
|
|
DOFREE(viewTag);
|
|
|
}
|
|
|
//创建BOMWindow
|
|
|
tag_t top_line = NULLTAG, window = NULLTAG;
|
|
|
BOM_create_window(&window);
|
|
|
//设置顶层BOM
|
|
|
BOM_set_window_top_line(window, NULLTAG, rev, NULLTAG, &top_line);
|
|
|
int count;
|
|
|
tag_t* children_line = NULLTAG;
|
|
|
BOM_line_ask_all_child_lines(top_line, &count, &children_line);
|
|
|
for (int i = 0; i < count; i++)
|
|
|
{
|
|
|
AOM_ask_value_tag(children_line[i], "bl_line_object", &rev_tag);
|
|
|
AOM_ask_value_string(children_line[i], "bl_item_item_id", &item_id);
|
|
|
AOM_ask_value_string(children_line[i], "bl_sequence_no", &bl_sequence);
|
|
|
AOM_ask_value_string(rev_tag, "item_revision_id", &item_revision_id);
|
|
|
son_line.rev_tag = rev_tag;
|
|
|
son_line.id = item_id;
|
|
|
son_line.sequence = bl_sequence;
|
|
|
son_line.revision_id = item_revision_id;
|
|
|
son_line.bom_tag = children_line[i];
|
|
|
lines.push_back(son_line);
|
|
|
}
|
|
|
return top_line;
|
|
|
}
|
|
|
|
|
|
int parseConfigs(vector<string> pref_values, vector<Config>& son_configs, vector<Config>& title_configs)
|
|
|
{
|
|
|
for (int i = 0; i < pref_values.size(); i++)
|
|
|
{
|
|
|
string prop_config;
|
|
|
vector<string> prop_configs;
|
|
|
vector<string> defaults;
|
|
|
string send_name;
|
|
|
string type;
|
|
|
string title;
|
|
|
string prop_type;
|
|
|
string prop_name;
|
|
|
string default;
|
|
|
prop_config.assign(pref_values[i]);
|
|
|
int ind = prop_config.find_first_of(';');
|
|
|
//有默认值时
|
|
|
if (ind != string::npos)
|
|
|
{
|
|
|
Split(prop_config.substr(0, ind), "=", prop_configs);
|
|
|
Split(prop_config.substr(ind + 1), "=", defaults);
|
|
|
if (defaults.size() != 2)
|
|
|
{
|
|
|
WriteLog(debug, "首选项配置有误:%s", pref_values[i].c_str());
|
|
|
continue;
|
|
|
}
|
|
|
default = defaults[1];
|
|
|
|
|
|
}
|
|
|
//没有默认值时
|
|
|
else
|
|
|
{
|
|
|
Split(prop_config, "=", prop_configs);
|
|
|
}
|
|
|
if (prop_configs.size() != 5 && prop_configs.size() != 3) {
|
|
|
WriteLog(debug, "首选项配置有误:%s", pref_values[i].c_str());
|
|
|
continue;
|
|
|
}
|
|
|
send_name = prop_configs[0];
|
|
|
type = prop_configs[1];
|
|
|
title = prop_configs[2];
|
|
|
if (prop_configs.size() == 5) {
|
|
|
prop_type = prop_configs[3];
|
|
|
prop_name = prop_configs[4];
|
|
|
}
|
|
|
Config config;
|
|
|
config.send_name = send_name;
|
|
|
config.type = type;
|
|
|
config.title = title;
|
|
|
config.prop_name = prop_name;
|
|
|
config.prop_type = prop_type;
|
|
|
config.default = default;
|
|
|
if (strcmp(title.c_str(), "son") == 0)
|
|
|
{
|
|
|
son_configs.push_back(config);
|
|
|
}
|
|
|
else if (strcmp(title.c_str(), "title") == 0) {
|
|
|
title_configs.push_back(config);
|
|
|
}
|
|
|
else {
|
|
|
WriteLog(debug, "首选项配置有误:%s", pref_values[i].c_str());
|
|
|
continue;
|
|
|
}
|
|
|
}
|
|
|
return ITK_ok;
|
|
|
}
|
|
|
|
|
|
string read_data(tag_t bomline_tag, vector<Config> configs, tag_t parentline_tag )
|
|
|
{
|
|
|
int ifail = ITK_ok;
|
|
|
tag_t owning_user = NULLTAG, rev_tag, item_tag, data_tag = NULLTAG;
|
|
|
char* object_string = NULL, * creation_date = NULL, * prop_value = NULL, ** values = NULL, * localization_statuses;
|
|
|
int int_value;
|
|
|
double double_value;
|
|
|
logical master;
|
|
|
string jsonStr;
|
|
|
for (int i = 0; i < configs.size(); i++)
|
|
|
{
|
|
|
Config config = configs[i];
|
|
|
string value;
|
|
|
int num = 0;
|
|
|
jsonStr.append("\"").append(config.send_name).append("\":\"");
|
|
|
if (strcmp(config.default.c_str(), "") != 0)
|
|
|
{
|
|
|
if (strcmp(config.default.c_str(), "空") != 0) {
|
|
|
jsonStr.append(config.default);
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
AOM_ask_value_tag(bomline_tag, "bl_line_object", &rev_tag);
|
|
|
ITEM_ask_item_of_rev(rev_tag, &item_tag);
|
|
|
if (strcmp(config.prop_type.c_str(), "item") == 0) {
|
|
|
data_tag = item_tag;
|
|
|
}
|
|
|
else if (strcmp(config.prop_type.c_str(), "rev") == 0) {
|
|
|
data_tag = rev_tag;
|
|
|
}
|
|
|
else if (strcmp(config.prop_type.c_str(), "bom") == 0) {
|
|
|
data_tag = bomline_tag;
|
|
|
}
|
|
|
printf("要传的字段为:%s\n", config.send_name.c_str());
|
|
|
if (strcmp(config.type.c_str(), "string") == 0)
|
|
|
{
|
|
|
if (strcmp(config.send_name.c_str(), "menge") == 0 && parentline_tag != NULL) {
|
|
|
float two = 1; char* quantity, strff[21];
|
|
|
AOM_ask_value_string(bomline_tag, "bl_quantity", &quantity);
|
|
|
if (quantity != NULL && strlen(quantity) != 0) {
|
|
|
two = atof(quantity);
|
|
|
}
|
|
|
tag_t parRev_tag;
|
|
|
AOM_ask_value_tag(parentline_tag, "bl_line_object", &parRev_tag);
|
|
|
ITKCALL(ifail = AOM_ask_value_int(parRev_tag, "r9_bmeng", &int_value));
|
|
|
if (int_value == 0) {
|
|
|
sprintf(strff, "%.2f", two);
|
|
|
value.append(strff);
|
|
|
}
|
|
|
else {
|
|
|
float sum;
|
|
|
//float one = atof(prop_value);
|
|
|
float one = (float)int_value;
|
|
|
sum = one * two;
|
|
|
sprintf(strff, "%.2f", sum);
|
|
|
value.append(strff);
|
|
|
}
|
|
|
}
|
|
|
else {
|
|
|
ITKCALL(ifail = AOM_ask_value_string(data_tag, config.prop_name.c_str(), &prop_value));
|
|
|
if (strcmp("每个", prop_value) == 0 && strcmp("bl_item_uom_tag", config.prop_name.c_str()) == 0) {
|
|
|
value.append("PC");
|
|
|
}
|
|
|
else if (strcmp("stlal", config.send_name.c_str()) == 0) {
|
|
|
int center;
|
|
|
center = atoi(prop_value);
|
|
|
if (center > 0 && center < 10) {
|
|
|
value.append("0");
|
|
|
}
|
|
|
value.append(prop_value);
|
|
|
}
|
|
|
else if (strcmp("bl_sequence_no", config.prop_name.c_str()) == 0) {
|
|
|
int center;
|
|
|
center = atoi(prop_value);
|
|
|
if (center > 9 && center < 100) {
|
|
|
value.append("00");
|
|
|
}
|
|
|
else if (center > 99 && center < 1000) {
|
|
|
value.append("0");
|
|
|
}
|
|
|
value.append(prop_value);
|
|
|
}
|
|
|
else{
|
|
|
value.append(prop_value);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|
|
|
else if (strcmp(config.type.c_str(), "lov") == 0)
|
|
|
{
|
|
|
ITKCALL(ifail = AOM_UIF_ask_localized_value_strings(data_tag, config.prop_name.c_str(), "zh_CN", &num, &values, &localization_statuses, &master));
|
|
|
WriteLog(debug, "此时的lov显示值:%s", values[0]);
|
|
|
value.append(values[0]);
|
|
|
}
|
|
|
else if (strcmp(config.type.c_str(), "int") == 0) {
|
|
|
printf("类型为%s==属性名为%s\n",config.prop_type.c_str(), config.prop_name.c_str());
|
|
|
int center;
|
|
|
ITKCALL(ifail = AOM_ask_value_int(data_tag, config.prop_name.c_str(), ¢er));
|
|
|
char strDst[256] = { 0 };
|
|
|
_itoa(center, strDst, 10);
|
|
|
value.append(strDst);
|
|
|
}
|
|
|
else if (strcmp(config.type.c_str(), "double") == 0) {
|
|
|
ITKCALL(ifail = AOM_ask_value_double(data_tag, config.prop_name.c_str(), &double_value));
|
|
|
char dstr[20];
|
|
|
sprintf(dstr, "%.2lf", double_value);//将d 保留2位小数赋值给dstr
|
|
|
value.append(dstr);
|
|
|
}
|
|
|
jsonStr.append(value);
|
|
|
}
|
|
|
jsonStr.append("\",");
|
|
|
}
|
|
|
return jsonStr;
|
|
|
}
|
|
|
|