|
|
#define _CRT_SECURE_NO_WARNINGS
|
|
|
#include "epm_handler_common.h"
|
|
|
|
|
|
#include <tc\preferences.h>
|
|
|
#include <epm\epm.h>
|
|
|
#import "C:\Program Files\Common Files\System\ado\msado15.dll" no_namespace rename("EOF","adoEOF")rename("BOF","adoBOF")
|
|
|
|
|
|
#include <tccore\aom.h>
|
|
|
|
|
|
#include <tccore\aom_prop.h>
|
|
|
#include <tccore\item.h>
|
|
|
#include <string>
|
|
|
#include <ict/ict_userservice.h>
|
|
|
|
|
|
#include <map>
|
|
|
#include <vector>
|
|
|
#include<iostream>
|
|
|
#include<stdlib.h>
|
|
|
#pragma warning(disable : 4996)
|
|
|
#include <string>
|
|
|
#include <bom/bom.h>
|
|
|
#include <stdio.h>
|
|
|
#include <objbase.h>
|
|
|
extern "C" int POM_AM__set_application_bypass(logical bypass);
|
|
|
using namespace std;
|
|
|
|
|
|
#define DOFREE(obj) \
|
|
|
{ \
|
|
|
if(obj) \
|
|
|
{ \
|
|
|
MEM_free(obj); \
|
|
|
obj = NULL; \
|
|
|
} \
|
|
|
}
|
|
|
|
|
|
char *MATNR, *WERKS, *STLAN, *STALT, *VBELN, *VBPOS, *BMENG, *POSNR, *POSTP, *IDNRK, *MENGE, *MEINS, *POTX1, *POTX2;
|
|
|
//º¯Êý
|
|
|
void getBomPropertys(EPM_action_message_t msg, int ifail);
|
|
|
void getBomLinePropertys(tag_t top_line,char *type);
|
|
|
void getBomLinePropertysBom(tag_t top_line,string topUUID,char * carModel, _ConnectionPtr m_pConnection);
|
|
|
int countNum = 1;
|
|
|
long countInsertSql = 0;
|
|
|
//int countNumCoe = countNum * 512;
|
|
|
char *parameters;
|
|
|
|
|
|
string getUUid()
|
|
|
{
|
|
|
char buffer[64] = { 0 };
|
|
|
GUID guid;
|
|
|
|
|
|
if ( CoCreateGuid(&guid) )
|
|
|
{
|
|
|
fprintf(stderr, "create guid error\n");
|
|
|
return "";
|
|
|
}
|
|
|
_snprintf(buffer, sizeof(buffer),"%08X-%04X-%04x-%02X%02X-%02X%02X%02X%02X%02X%02X",guid.Data1, guid.Data2, guid.Data3,
|
|
|
guid.Data4[0], guid.Data4[1], guid.Data4[2],guid.Data4[3], guid.Data4[4], guid.Data4[5],guid.Data4[6], guid.Data4[7]);
|
|
|
//printf("guid: %s\n", buffer);
|
|
|
|
|
|
return buffer;
|
|
|
}
|
|
|
|
|
|
int JLCS_05_BOMSendOutSap_Single(EPM_action_message_t msg)
|
|
|
{
|
|
|
printf("¿ªÊ¼Ö´ÐÐ\n");
|
|
|
int ifail = ITK_ok;
|
|
|
|
|
|
parameters = (char*)malloc(100000 * sizeof(char));
|
|
|
strcpy(parameters, "getBomPropertys}}");
|
|
|
//parameters = "getBomPropertys}}";
|
|
|
printf("parameters1:\n%s\n", parameters);
|
|
|
int attachments_num;
|
|
|
int bvr_count;
|
|
|
tag_t rootTask = NULLTAG, *attachments = NULLTAG, top_line = NULLTAG, *children_line = NULLTAG, *bvr_list = NULLTAG;
|
|
|
tag_t bom_window_tag;
|
|
|
char *object_type = NULL;
|
|
|
int count;
|
|
|
|
|
|
char *tc_root_file = getenv("tc_root"); //»ñÈ¡tc_rootµÄ·¾¶==C:\Siemens\Teamcenter11
|
|
|
char jar_file[SS_MAXPATHLEN] = "";
|
|
|
strcpy(jar_file, tc_root_file);
|
|
|
strcat(jar_file, "\\portal\\plugins\\");
|
|
|
strcat(jar_file, "JLCS_05.jar");
|
|
|
|
|
|
|
|
|
//»ñÈ¡ÈÎÎñ¶ÔÏó
|
|
|
EPM_ask_root_task(msg.task, &rootTask);
|
|
|
//»ñÈ¡ÈÎÎñÄ¿±ê¶ÔÏó
|
|
|
EPM_ask_attachments(rootTask, EPM_target_attachment, &attachments_num, &attachments);
|
|
|
//char *temp_dir = getenv("temp"); //C:\Windows\temp
|
|
|
|
|
|
for (int i = 0; i < attachments_num; i++)
|
|
|
{
|
|
|
//»ñÈ¡topline
|
|
|
AOM_ask_value_string(attachments[i], "object_type", &object_type);
|
|
|
printf("object_type=%s \n", object_type);
|
|
|
//¹ýÂ˵ô·Ç°æ±¾µÄ¶ÔÏó
|
|
|
if((strstr(object_type,"Revision") == NULL) || (strstr(object_type,"Master") != NULL)
|
|
|
|| (strstr(object_type,"master") != NULL) || (strstr(object_type,"BOM") != NULL) || (strstr(object_type,"bom") != NULL) || (strstr(object_type,"Bom") != NULL))
|
|
|
{
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
char * puid = NULL;
|
|
|
//»ñÈ¡PUID
|
|
|
ITK__convert_tag_to_uid(attachments[i], &puid);
|
|
|
|
|
|
//strcat(parameters, puid);
|
|
|
//strcat(parameters, "}}");
|
|
|
|
|
|
printf("object_type2=%s \n", object_type);
|
|
|
//if (strcmp("ItemRevision", object_type) == 0) {
|
|
|
|
|
|
ITEM_rev_list_bom_view_revs(attachments[i], &bvr_count, &bvr_list);
|
|
|
//printf("ÊÓͼÊýÁ¿=%d \n", bvr_count);
|
|
|
|
|
|
if (bvr_count == 0) {
|
|
|
continue;
|
|
|
}
|
|
|
//´«²ÎÊôÐÔ
|
|
|
BOM_create_window(&bom_window_tag);
|
|
|
BOM_set_window_top_line_bvr(bom_window_tag, bvr_list[bvr_count - 1], &top_line);
|
|
|
//BOM_ask_window_top_line(bom_window_tag, &top_line);
|
|
|
|
|
|
printf("parameters1:\n%s\n", parameters);
|
|
|
//getBomLinePropertys(top_line,puid);
|
|
|
BOM_line_ask_all_child_lines(top_line, &count, &children_line);
|
|
|
for (int ii = 0; ii < count; ii++)
|
|
|
{
|
|
|
char * object_type = NULL;
|
|
|
//»ñÈ¡°æ±¾
|
|
|
tag_t partItemRevision = NULLTAG, parentItemRevision = NULLTAG;
|
|
|
AOM_ask_value_tag(children_line[ii],"bl_line_object",&partItemRevision);
|
|
|
AOM_ask_value_tag(top_line,"bl_line_object",&parentItemRevision);
|
|
|
//ITKCALL(ITEM_ask_latest_rev(partItem,&partItemRevision));
|
|
|
|
|
|
AOM_ask_value_string(partItemRevision, "object_type", &object_type);
|
|
|
//¹ýÂË·ÇÁã¼þ°æ±¾µÄ¶ÔÏó
|
|
|
if (strcmp("Gd6_PartsRevision", object_type) == 0
|
|
|
|| strcmp("Gd6_BZJRevision", object_type) == 0|| strcmp("Gd6_XZMKCRevision", object_type) == 0) {
|
|
|
int item_mast_rev_count = 0;
|
|
|
tag_t * item_mast_rev = NULLTAG;
|
|
|
//»ñÈ¡°æ±¾±íµ¥
|
|
|
ITKCALL(AOM_ask_value_tags(partItemRevision, "IMAN_master_form_rev", &item_mast_rev_count, &item_mast_rev ) )
|
|
|
|
|
|
//»ñÈ¡toplineÊôÐÔ
|
|
|
//¸¸¼þ´úºÅ
|
|
|
AOM_ask_value_string(parentItemRevision, "item_id", &MATNR);
|
|
|
//¸¸¼þ¹¤³§
|
|
|
WERKS = "6300";
|
|
|
//AOM_ask_value_string(children_line[ii], "bl_formatted_parent_name", &bl_formatted_parent_name);
|
|
|
//BOMÓÃ;
|
|
|
STLAN = "1";
|
|
|
//¿ÉÑ¡BOM
|
|
|
STALT = "1";
|
|
|
//ÏúÊÛµ¥ºÅ
|
|
|
VBELN = "";
|
|
|
//¶©µ¥ÐÐÏîÄ¿
|
|
|
VBPOS = "";
|
|
|
//¸¸¼þÊýÁ¿
|
|
|
AOM_ask_value_string(top_line, "bl_quantity", &BMENG);
|
|
|
//BOMÏîÄ¿ºÅ
|
|
|
AOM_ask_value_string(children_line[ii], "bl_sequence_no", &POSNR);
|
|
|
//ÏîÄ¿Àà±ð
|
|
|
POSTP = "L";
|
|
|
//×Ó¼þ´úºÅ
|
|
|
AOM_ask_value_string(partItemRevision, "item_id", &IDNRK);
|
|
|
//×Ó¼þÊýÁ¿
|
|
|
AOM_ask_value_string(children_line[ii], "bl_quantity", &MENGE);
|
|
|
//×Ó¼þµ¥Î»
|
|
|
AOM_ask_value_string(item_mast_rev[0], "gd6_dw", &MEINS);
|
|
|
//ÅäËÍÇøÓò
|
|
|
AOM_ask_value_string(children_line[0], "Gd6_psqy", &POTX1);
|
|
|
//Éú²ú¹¤Î»/ÅäË͹¤Î»gd6_scgw&gd6_psgw
|
|
|
char * scgw = NULL, * psgw = NULL;
|
|
|
|
|
|
AOM_ask_value_string(children_line[0], "Gd6_scgw", &scgw);
|
|
|
AOM_ask_value_string(children_line[0], "Gd6_psgw", &psgw);
|
|
|
|
|
|
strcat(parameters, MATNR);
|
|
|
strcat(parameters, ",");
|
|
|
strcat(parameters, WERKS);
|
|
|
strcat(parameters, ",");
|
|
|
strcat(parameters, STLAN);
|
|
|
strcat(parameters, ",");
|
|
|
strcat(parameters, STALT);
|
|
|
strcat(parameters, ",");
|
|
|
strcat(parameters, VBELN);
|
|
|
strcat(parameters, ",");
|
|
|
strcat(parameters, VBPOS);
|
|
|
strcat(parameters, ",");
|
|
|
strcat(parameters, BMENG);
|
|
|
strcat(parameters, ",");
|
|
|
strcat(parameters, POSNR);
|
|
|
strcat(parameters, ",");
|
|
|
strcat(parameters, POSTP);
|
|
|
strcat(parameters, ",");
|
|
|
strcat(parameters, IDNRK);
|
|
|
strcat(parameters, ",");
|
|
|
strcat(parameters, MENGE);
|
|
|
strcat(parameters, ",");
|
|
|
strcat(parameters, MEINS);
|
|
|
strcat(parameters, ",");
|
|
|
strcat(parameters, POTX1);
|
|
|
strcat(parameters, ",");
|
|
|
strcat(parameters, scgw);
|
|
|
strcat(parameters, ",");
|
|
|
strcat(parameters, psgw);
|
|
|
strcat(parameters, ",");
|
|
|
strcat(parameters, puid);
|
|
|
strcat(parameters, "}}");
|
|
|
//strcat(parameters, parameter);
|
|
|
printf("parameter:\n%s\n", parameters);
|
|
|
//strcat(parameters, C5_gc);
|
|
|
//strcat(parameters, C5_scgw);
|
|
|
|
|
|
|
|
|
|
|
|
//char cmd[256] = "";
|
|
|
//strcpy(cmd, "java -jar \"");
|
|
|
//strcat(cmd, jar_file);
|
|
|
//strcat(cmd, "\" ");
|
|
|
//´«²Î
|
|
|
//strcat(cmd, parameter);
|
|
|
//printf("·¾¶:\n%s\n", cmd);
|
|
|
//system(cmd);
|
|
|
//countNum++;
|
|
|
}
|
|
|
}
|
|
|
//DOFREE(puid)
|
|
|
|
|
|
//char *strResult = (char*)malloc((strlen(parameters) + 512) * sizeof(int));;
|
|
|
//string strResult;
|
|
|
/*while (fgets(buf, sizeof buf, pf) != NULL) {
|
|
|
printf("%s", buf);
|
|
|
EMH_store_error_s1( EMH_severity_user_error, EMH_USER_error_base,buf);
|
|
|
ifail = 1;
|
|
|
}*/
|
|
|
|
|
|
//}
|
|
|
}
|
|
|
|
|
|
//°ÑÊý¾ÝÓÃдÈëÎļþ
|
|
|
char data_file[SS_MAXPATHLEN] = "";
|
|
|
strcat(data_file,tc_root_file);
|
|
|
strcat(data_file,"\\single_bom.txt");
|
|
|
FILE* fptr;
|
|
|
fptr = fopen(data_file, "w");
|
|
|
fprintf(fptr, "%s", parameters);
|
|
|
fclose(fptr);
|
|
|
|
|
|
char *cmd = (char*)malloc(512 * sizeof(int));
|
|
|
strcpy(cmd, "java -jar \"");
|
|
|
strcat(cmd, jar_file);
|
|
|
strcat(cmd, "\" ");
|
|
|
//´«²Î
|
|
|
strcat(cmd, data_file);
|
|
|
strcat(cmd,"getBomPropertys");
|
|
|
printf("·¾¶:\n%s\n", cmd);
|
|
|
char buf[64] = {0};
|
|
|
FILE *pf = NULL;
|
|
|
if ((pf = _popen(cmd, "r")) == NULL) {
|
|
|
printf("½Ó¿Ú·µ»Ø:\n%s", "1");
|
|
|
}
|
|
|
string strResult;
|
|
|
while (fgets(buf, sizeof buf, pf)) {
|
|
|
strResult += buf;
|
|
|
}
|
|
|
_pclose(pf);
|
|
|
unsigned int iSize = strResult.size();
|
|
|
if (iSize > 0 && strResult[iSize - 1] == '\n')
|
|
|
{
|
|
|
strResult = strResult.substr(0, iSize - 1);
|
|
|
//»ñÈ¡Á÷³Ì×÷Òµ
|
|
|
tag_t job = NULLTAG;
|
|
|
|
|
|
EPM_ask_job(rootTask,&job);
|
|
|
|
|
|
POM_AM__set_application_bypass(true);
|
|
|
//ÉèÖÃÃèÊöÊôÐÔÖµ
|
|
|
//ÏÈlock
|
|
|
AOM_lock(job);
|
|
|
//ÔÙset
|
|
|
AOM_set_value_string(job,"object_desc",strResult.c_str());
|
|
|
//ÔÙsave
|
|
|
AOM_save( job ) ;
|
|
|
//×îºóunlock
|
|
|
AOM_unlock( job ) ;
|
|
|
AOM_refresh( job,FALSE );
|
|
|
POM_AM__set_application_bypass(false);
|
|
|
//EMH_store_error_s1( EMH_severity_user_error, EMH_USER_error_base,strResult.c_str());
|
|
|
//ifail = 1;
|
|
|
}
|
|
|
//system(cmd);
|
|
|
BOM_close_window(bom_window_tag);
|
|
|
DOFREE(bvr_list);
|
|
|
parameters = NULL;
|
|
|
cmd = NULL;
|
|
|
|
|
|
|
|
|
|
|
|
DOFREE(attachments);
|
|
|
tc_root_file = NULL;
|
|
|
DOFREE(children_line);
|
|
|
DOFREE(MATNR);
|
|
|
WERKS = NULL;
|
|
|
STLAN = NULL;
|
|
|
STALT = NULL;
|
|
|
VBELN = NULL;
|
|
|
VBPOS = NULL;
|
|
|
BMENG = NULL;
|
|
|
DOFREE(POSNR);
|
|
|
POSTP = NULL;
|
|
|
DOFREE(IDNRK);
|
|
|
DOFREE(MENGE);
|
|
|
DOFREE(MEINS);
|
|
|
DOFREE(POTX1);
|
|
|
DOFREE(POTX2);
|
|
|
printf("Ö´ÐнáÊø\n");
|
|
|
|
|
|
return ifail;
|
|
|
}
|
|
|
|
|
|
int JLCS_05_BOMSendOutSap(EPM_action_message_t msg)
|
|
|
{
|
|
|
printf("¿ªÊ¼Ö´ÐÐ\n");
|
|
|
int ifail = ITK_ok;
|
|
|
|
|
|
parameters = (char*)malloc(512 * sizeof(char));
|
|
|
strcpy(parameters, "getBomPropertys}}");
|
|
|
//parameters = "getBomPropertys}}";
|
|
|
printf("parameters1:\n%s\n", parameters);
|
|
|
int attachments_num;
|
|
|
int bvr_count;
|
|
|
tag_t rootTask = NULLTAG, *attachments = NULLTAG, top_line = NULLTAG, *children_line = NULLTAG, *bvr_list = NULLTAG;
|
|
|
tag_t bom_window_tag;
|
|
|
char *object_type = NULL;
|
|
|
int count;
|
|
|
|
|
|
char *tc_root_file = getenv("tc_root"); //»ñÈ¡tc_rootµÄ·¾¶==C:\Siemens\Teamcenter11
|
|
|
char jar_file[SS_MAXPATHLEN] = "";
|
|
|
strcpy(jar_file, tc_root_file);
|
|
|
strcat(jar_file, "\\portal\\plugins\\");
|
|
|
strcat(jar_file, "JLCS_05.jar");
|
|
|
|
|
|
|
|
|
//»ñÈ¡ÈÎÎñ¶ÔÏó
|
|
|
EPM_ask_root_task(msg.task, &rootTask);
|
|
|
//»ñÈ¡ÈÎÎñÄ¿±ê¶ÔÏó
|
|
|
EPM_ask_attachments(rootTask, EPM_target_attachment, &attachments_num, &attachments);
|
|
|
//char *temp_dir = getenv("temp"); //C:\Windows\temp
|
|
|
|
|
|
for (int i = 0; i < attachments_num; i++)
|
|
|
{
|
|
|
//»ñÈ¡topline
|
|
|
AOM_ask_value_string(attachments[i], "object_type", &object_type);
|
|
|
printf("object_type=%s \n", object_type);
|
|
|
//¹ýÂ˵ô·Ç°æ±¾µÄ¶ÔÏó
|
|
|
if((strstr(object_type,"Revision") == NULL) || (strstr(object_type,"Master") != NULL)
|
|
|
|| (strstr(object_type,"master") != NULL) || (strstr(object_type,"BOM") != NULL) || (strstr(object_type,"bom") != NULL) || (strstr(object_type,"Bom") != NULL))
|
|
|
{
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
char * puid = NULL;
|
|
|
//»ñÈ¡PUID
|
|
|
ITK__convert_tag_to_uid(attachments[i], &puid);
|
|
|
|
|
|
strcat(parameters, puid);
|
|
|
strcat(parameters, "}}");
|
|
|
|
|
|
printf("object_type2=%s \n", object_type);
|
|
|
//if (strcmp("ItemRevision", object_type) == 0) {
|
|
|
|
|
|
ITEM_rev_list_bom_view_revs(attachments[i], &bvr_count, &bvr_list);
|
|
|
//printf("ÊÓͼÊýÁ¿=%d \n", bvr_count);
|
|
|
|
|
|
if (bvr_count == 0) {
|
|
|
continue;
|
|
|
}
|
|
|
//´«²ÎÊôÐÔ
|
|
|
BOM_create_window(&bom_window_tag);
|
|
|
BOM_set_window_top_line_bvr(bom_window_tag, bvr_list[bvr_count - 1], &top_line);
|
|
|
//BOM_ask_window_top_line(bom_window_tag, &top_line);
|
|
|
|
|
|
printf("parameters1:\n%s\n", parameters);
|
|
|
getBomLinePropertys(top_line,NULL);
|
|
|
|
|
|
char *cmd = (char*)malloc((strlen(parameters) + 512) * sizeof(int));
|
|
|
strcpy(cmd, "java -jar \"");
|
|
|
strcat(cmd, jar_file);
|
|
|
strcat(cmd, "\" ");
|
|
|
//´«²Î
|
|
|
strcat(cmd, parameters);
|
|
|
//printf("·¾¶:\n%s\n", cmd);
|
|
|
char buf[64] = {0};
|
|
|
FILE *pf = NULL;
|
|
|
if ((pf = _popen(cmd, "r")) == NULL) {
|
|
|
printf("½Ó¿Ú·µ»Ø:\n%s", "1");
|
|
|
}
|
|
|
string strResult;
|
|
|
while (fgets(buf, sizeof buf, pf)) {
|
|
|
strResult += buf;
|
|
|
}
|
|
|
_pclose(pf);
|
|
|
unsigned int iSize = strResult.size();
|
|
|
if (iSize > 0 && strResult[iSize - 1] == '\n')
|
|
|
{
|
|
|
strResult = strResult.substr(0, iSize - 1);
|
|
|
//»ñÈ¡Á÷³Ì×÷Òµ
|
|
|
tag_t job = NULLTAG;
|
|
|
|
|
|
EPM_ask_job(rootTask,&job);
|
|
|
|
|
|
POM_AM__set_application_bypass(true);
|
|
|
//ÉèÖÃÃèÊöÊôÐÔÖµ
|
|
|
//ÏÈlock
|
|
|
AOM_lock(job);
|
|
|
//ÔÙset
|
|
|
AOM_set_value_string(job,"object_desc",strResult.c_str());
|
|
|
//ÔÙsave
|
|
|
AOM_save( job ) ;
|
|
|
//×îºóunlock
|
|
|
AOM_unlock( job ) ;
|
|
|
AOM_refresh( job,FALSE );
|
|
|
POM_AM__set_application_bypass(false);
|
|
|
//EMH_store_error_s1( EMH_severity_user_error, EMH_USER_error_base,strResult.c_str());
|
|
|
//ifail = 1;
|
|
|
}
|
|
|
|
|
|
//char *strResult = (char*)malloc((strlen(parameters) + 512) * sizeof(int));;
|
|
|
//string strResult;
|
|
|
/*while (fgets(buf, sizeof buf, pf) != NULL) {
|
|
|
printf("%s", buf);
|
|
|
EMH_store_error_s1( EMH_severity_user_error, EMH_USER_error_base,buf);
|
|
|
ifail = 1;
|
|
|
}*/
|
|
|
_pclose(pf);
|
|
|
//system(cmd);
|
|
|
BOM_close_window(bom_window_tag);
|
|
|
DOFREE(bvr_list);
|
|
|
parameters = NULL;
|
|
|
cmd = NULL;
|
|
|
DOFREE(puid)
|
|
|
//}
|
|
|
}
|
|
|
DOFREE(attachments);
|
|
|
tc_root_file = NULL;
|
|
|
DOFREE(children_line);
|
|
|
DOFREE(MATNR);
|
|
|
WERKS = NULL;
|
|
|
STLAN = NULL;
|
|
|
STALT = NULL;
|
|
|
VBELN = NULL;
|
|
|
VBPOS = NULL;
|
|
|
BMENG = NULL;
|
|
|
DOFREE(POSNR);
|
|
|
POSTP = NULL;
|
|
|
DOFREE(IDNRK);
|
|
|
DOFREE(MENGE);
|
|
|
DOFREE(MEINS);
|
|
|
DOFREE(POTX1);
|
|
|
DOFREE(POTX2);
|
|
|
printf("Ö´ÐнáÊø\n");
|
|
|
|
|
|
return ifail;
|
|
|
}
|
|
|
int Super_Bom_Appent_Data (void *returnValue)
|
|
|
{
|
|
|
printf("=========================ͬ²½³¬¼¶BOM START ===================\n");
|
|
|
countInsertSql = 0;
|
|
|
::CoInitialize(NULL); //³õʼ»¯OLE/COM¿â»·¾³
|
|
|
HRESULT hr = NULL;
|
|
|
_ConnectionPtr m_pConnection; // Êý¾Ý¿â
|
|
|
_RecordsetPtr m_pRecordset; // ÃüÁî
|
|
|
_CommandPtr m_pCommand; // ¼Ç¼
|
|
|
|
|
|
int valueNum=0;
|
|
|
|
|
|
char* server_address;
|
|
|
|
|
|
PREF_ask_char_value("TC11_SqlServer_Link_ITK", valueNum, &server_address);
|
|
|
|
|
|
char *object_type = NULL, * carModel = NULL;
|
|
|
int bvr_count;
|
|
|
tag_t * bvr_list = NULLTAG,bom_window_tag = NULLTAG, top_line = NULLTAG;
|
|
|
tag_t itemRevision = NULLTAG;
|
|
|
|
|
|
ITKCALL(USERARG_get_tag_argument(&itemRevision));
|
|
|
//char *people = NULL;
|
|
|
//USERARG_get_string_argument(&people);
|
|
|
|
|
|
//»ñÈ¡topline
|
|
|
AOM_ask_value_string(itemRevision, "object_type", &object_type);
|
|
|
AOM_ask_value_string(itemRevision, "item_id", &carModel);
|
|
|
printf("object_type=%s \n", object_type);
|
|
|
printf("item_id=%s \n", carModel);
|
|
|
|
|
|
ITEM_rev_list_bom_view_revs(itemRevision, &bvr_count, &bvr_list);
|
|
|
if (bvr_count == 0) {
|
|
|
return 0;
|
|
|
}
|
|
|
hr = m_pConnection.CreateInstance(_uuidof(Connection));//´´½¨Á¬½Ó¶ÔÏóʵÀý
|
|
|
if (SUCCEEDED(hr))
|
|
|
{
|
|
|
/*
|
|
|
Provider=SQLOLEDB.1 ------´ò¿ªÊý¾Ý¿âÓÃoledbµÄ·½Ê½Á¬½Óbai
|
|
|
Persist Security Info ----ÊÇ·ñ±£´æ°²È«ÐÅÏ¢du
|
|
|
User ID-------------------Óû§Ãû
|
|
|
PassWord------------------ÃÜÂëzhi
|
|
|
Initial Catalog-----------Êý¾Ý¿âµÄÃû³Æ»òÕßÊý¾Ý¿âip»òÕßÄ¿dao¼
|
|
|
Data Source---------------Êý¾ÝÔ´
|
|
|
*/
|
|
|
m_pConnection->ConnectionString = (server_address);
|
|
|
//printf("\n==========================================================\n");
|
|
|
hr = m_pConnection->Open("", "", "", adConnectUnspecified);//´ò¿ªÊý¾Ý¿â
|
|
|
if (FAILED(hr))
|
|
|
{
|
|
|
printf("Open Failed!");
|
|
|
return 1;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
//m_pRecordset->Open("","", adOpenKeyset,adLockOptimistic,adCmdText);
|
|
|
//long RecordCount;
|
|
|
//RecordCount=m_pRecordset->Fields->GetItem((long)0)->GetValue();
|
|
|
//ÐÞ¸ÄÊôÐÔΪ¸üÐÂÖÐ(Èç¹û²»´æÔÚ¾ÍÐÂÔö)
|
|
|
long sumrows = 0;
|
|
|
char* selectLable = (char*)calloc(1024, sizeof(char));
|
|
|
sprintf(selectLable,"select count(*) from GD_ORDERBOM_LABLE where ItemID = '%s'",carModel);
|
|
|
m_pRecordset = m_pConnection->Execute(_bstr_t(selectLable), 0, adCmdText);
|
|
|
/*sumrows = m_pRecordset->GetRecordCount();*/
|
|
|
_variant_t vIndex = (long)0;
|
|
|
_variant_t vCount = m_pRecordset->GetCollect(vIndex);
|
|
|
printf("¹²ÓÐ%dÌõ¼Ç¼",vCount.lVal);
|
|
|
sumrows = vCount.lVal;
|
|
|
m_pRecordset->Close();
|
|
|
printf("end =%ld\n",sumrows);
|
|
|
if(sumrows > 0){
|
|
|
//´æÔÚ£¨Ð޸ģ©
|
|
|
char* updateLable = (char*)calloc(1024, sizeof(char));
|
|
|
sprintf(updateLable, "update GD_ORDERBOM_LABLE set Lable = '¸üÐÂÖÐ' where ItemID = '%s'", carModel);
|
|
|
m_pConnection->Execute(_bstr_t(updateLable), 0, adCmdText);
|
|
|
updateLable = NULL;
|
|
|
}
|
|
|
else{
|
|
|
//²»´æÔÚ£¨ÐÂÔö£©
|
|
|
char* insertLable = (char*)calloc(1024, sizeof(char));
|
|
|
sprintf(insertLable, "insert into GD_ORDERBOM_LABLE(ItemID,Lable) values('%s','¸üÐÂÖÐ') ", carModel);
|
|
|
m_pConnection->Execute(_bstr_t(insertLable), 0, adCmdText);
|
|
|
insertLable = NULL;
|
|
|
}
|
|
|
selectLable = NULL;
|
|
|
|
|
|
//ÏÈɾ³ýLableÖеÄÒ»ÐУ¬ÔÙÌí¼Ó¡£
|
|
|
//char* deleteLable = (char*)calloc(1024, sizeof(char));
|
|
|
//sprintf(deleteLable, "delete from GD_ORDERBOM_LABLE where ItemID = '%s'", carModel);
|
|
|
//m_pConnection->Execute(_bstr_t(deleteLable), 0, adCmdText);
|
|
|
//deleteLable = NULL;
|
|
|
//char* insertLable = (char*)calloc(1024, sizeof(char));
|
|
|
//sprintf(insertLable, "insert into GD_ORDERBOM_LABLE(ItemID,Lable) values('%s','¸üÐÂÖÐ') ", carModel);
|
|
|
//m_pConnection->Execute(_bstr_t(insertLable), 0, adCmdText);
|
|
|
//insertLable = NULL;
|
|
|
|
|
|
//ɾ³ýÊý¾Ý¿âÖÐËùÓÐÄÚÈÝ
|
|
|
char* deleteSql = (char*)calloc(1024, sizeof(char));
|
|
|
tag_t partItemRevision = NULLTAG,item = NULLTAG;
|
|
|
sprintf(deleteSql, "delete from GD_ORDERBOM_DATA where carModel = '%s'", carModel);
|
|
|
|
|
|
m_pConnection->Execute(_bstr_t(deleteSql), 0, adCmdText);
|
|
|
//printf("ɾ³ý³É¹¦£¡\n");
|
|
|
//Ìí¼ÓÊý¾Ýgd6_psgw
|
|
|
//´«²ÎÊôÐÔ
|
|
|
BOM_create_window(&bom_window_tag);
|
|
|
BOM_set_window_top_line_bvr(bom_window_tag, bvr_list[bvr_count - 1], &top_line);
|
|
|
|
|
|
string childUUID = carModel;
|
|
|
char * itemId = "";
|
|
|
char * formula = "";
|
|
|
char * itemType = "";
|
|
|
char * sequenceNumber = "";
|
|
|
char * hierarchy = "";
|
|
|
char * quantity = "";
|
|
|
char * psqy = "";
|
|
|
char * scqy = "";
|
|
|
char * psqw = "";
|
|
|
char * scgw = "";
|
|
|
char * name = "";
|
|
|
char * sjzl = "";
|
|
|
char * mz = "";
|
|
|
char * wlfl = "";
|
|
|
char * dw = "";
|
|
|
char * jcjwlh = "";
|
|
|
char * sfqdj = "";
|
|
|
char * gyzy = "";
|
|
|
char * clgg = "";
|
|
|
char * clhd = "";
|
|
|
|
|
|
AOM_ask_value_tag(top_line,"bl_line_object",&partItemRevision);
|
|
|
ITEM_ask_item_of_rev( partItemRevision, &item);
|
|
|
AOM_ask_value_string(item, "object_type", &itemType);
|
|
|
AOM_ask_value_string(top_line, "bl_sequence_no", &sequenceNumber);
|
|
|
AOM_ask_value_string(top_line, "bl_item_item_id", &itemId);
|
|
|
AOM_ask_value_string(top_line, "bl_formula", &formula);
|
|
|
//AOM_ask_value_string(children_line[ii], "bl_level_starting_0", &POTX1);
|
|
|
AOM_ask_value_string(top_line, "bl_quantity", &quantity);
|
|
|
AOM_ask_value_string(top_line, "Gd6_psqy", &psqy);
|
|
|
AOM_ask_value_string(top_line, "Gd6_scqy", &scqy);
|
|
|
AOM_ask_value_string(top_line, "Gd6_psgw", &psqw);
|
|
|
AOM_ask_value_string(top_line, "Gd6_scgw", &scgw);
|
|
|
AOM_ask_value_string(top_line, "bl_item_object_name", &name);
|
|
|
AOM_ask_value_string(top_line, "bl_Gd6_PartsRevisionMaster_gd6_sjzl", &sjzl);
|
|
|
AOM_ask_value_string(top_line, "bl_Gd6_PartsRevisionMaster_gd6_mz", &mz);
|
|
|
AOM_ask_value_string(top_line, "bl_Gd6_PartsRevisionMaster_gd6_wlfl", &wlfl);
|
|
|
AOM_ask_value_string(top_line, "bl_Gd6_PartsRevisionMaster_gd6_dw", &dw);
|
|
|
AOM_ask_value_string(top_line, "bl_Gd6_PartsRevisionMaster_gd6_jcjwlh", &jcjwlh);
|
|
|
AOM_ask_value_string(top_line, "bl_Gd6_PartsRevisionMaster_gd6_sfqdj", &sfqdj);
|
|
|
AOM_ask_value_string(top_line, "bl_Gd6_PartsRevisionMaster_gd6_gyzy", &gyzy);
|
|
|
AOM_ask_value_string(top_line, "bl_Gd6_PartsRevisionMaster_gd6_clgg", &clgg);
|
|
|
AOM_ask_value_string(top_line, "bl_Gd6_PartsRevisionMaster_gd6_clhd", &clhd);
|
|
|
|
|
|
char* insertSql = (char*)calloc(1024, sizeof(char));
|
|
|
sprintf(insertSql, "INSERT INTO GD_ORDERBOM_DATA (carModel,parentID,id,bl_formula,bl_item_type,bl_sequence_no,uid,hierarchy,bl_quantity,psqy,scqy,psgw,scgw,bl_item_object_name,sjzl,mz,wlfl,dw,jcjwlh,sfqdj,gyzy,realParentID,clgg,clhd) VALUES ('%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s')",carModel,"",itemId,formula,itemType,sequenceNumber,childUUID.c_str(),hierarchy,quantity,psqy,scqy,psqw,scgw,name,sjzl,mz,wlfl,dw,jcjwlh,sfqdj,gyzy,"",clgg,clhd);
|
|
|
|
|
|
m_pConnection->Execute(_bstr_t(insertSql), 0, adCmdText);
|
|
|
countInsertSql++;
|
|
|
deleteSql = NULL;
|
|
|
DOFREE(itemId);
|
|
|
DOFREE(formula);
|
|
|
DOFREE(itemType);
|
|
|
DOFREE(sequenceNumber);
|
|
|
hierarchy = NULL;
|
|
|
DOFREE(quantity);
|
|
|
DOFREE(psqy);
|
|
|
DOFREE(scqy);
|
|
|
DOFREE(psqw);
|
|
|
DOFREE(scgw);
|
|
|
DOFREE(name);
|
|
|
DOFREE(sjzl);
|
|
|
DOFREE(mz);
|
|
|
DOFREE(wlfl);
|
|
|
DOFREE(dw);
|
|
|
DOFREE(jcjwlh);
|
|
|
DOFREE(sfqdj);
|
|
|
DOFREE(gyzy);
|
|
|
DOFREE(clgg);
|
|
|
DOFREE(clhd);
|
|
|
insertSql = NULL;
|
|
|
try{
|
|
|
getBomLinePropertysBom(top_line,carModel,carModel,m_pConnection);
|
|
|
//ÅжÏÐÂÔöµÄÌõÄ¿ÊýÊÇ·ñÒ»ÖÂ
|
|
|
long sqlCount = 0;
|
|
|
char* selectCount = (char*)calloc(1024, sizeof(char));
|
|
|
sprintf(selectCount,"select count(*) from GD_ORDERBOM_DATA where carModel = '%s'",carModel);
|
|
|
m_pRecordset = m_pConnection->Execute(_bstr_t(selectCount), 0, adCmdText);
|
|
|
/*sumrows = m_pRecordset->GetRecordCount();*/
|
|
|
_variant_t vIndexCount = (long)0;
|
|
|
_variant_t vCountCount = m_pRecordset->GetCollect(vIndexCount);
|
|
|
printf("¹²ÐÂÔöÁË%dÌõ¼Ç¼\n",countInsertSql);
|
|
|
printf("Êý¾Ý¿âÖÐÓÐ%dÌõ¼Ç¼\n",vCountCount.lVal);
|
|
|
sqlCount = vCountCount.lVal;
|
|
|
m_pRecordset->Close();
|
|
|
if(sqlCount == countInsertSql){
|
|
|
//Ð޸ij¬¼¶BOMµÄ״̬(³É¹¦)
|
|
|
char* updateSql = (char*)calloc(1024, sizeof(char));
|
|
|
sprintf(updateSql, "update GD_ORDERBOM_LABLE set Lable = '¸üгɹ¦',Remark = '' where ItemID = '%s'", carModel);
|
|
|
m_pConnection->Execute(_bstr_t(updateSql), 0, adCmdText);
|
|
|
updateSql = NULL;
|
|
|
}
|
|
|
else{
|
|
|
//Ð޸ij¬¼¶BOMµÄ״̬(ʧ°Ü)
|
|
|
char* updateSql = (char*)calloc(1024, sizeof(char));
|
|
|
sprintf(updateSql, "update GD_ORDERBOM_LABLE set Lable = '¸üÐÂʧ°Ü',Remark = 'ÌõÄ¿Êý²»Ò»ÖÂ' where ItemID = '%s'", carModel);
|
|
|
m_pConnection->Execute(_bstr_t(updateSql), 0, adCmdText);
|
|
|
updateSql = NULL;
|
|
|
}
|
|
|
|
|
|
//ÈÕÖ¾±í
|
|
|
//char *insertLog = (char*)calloc(1024, sizeof(char));
|
|
|
//sprintf(insertLog, "insert into GD_ORDERBOM_LABLE_LOG(ItemID,Lable) VALUES('%s','¸üгɹ¦')",carModel);
|
|
|
//m_pConnection->Execute(_bstr_t(insertLog), 0, adCmdText);
|
|
|
//insertLog = NULL;
|
|
|
}
|
|
|
catch(exception e ){
|
|
|
//Ìí¼Óʧ°ÜÔÒò
|
|
|
char* updateSql = (char*)calloc(1024, sizeof(char));
|
|
|
sprintf(updateSql, "update GD_ORDERBOM_LABLE set Lable = '¸üÐÂʧ°Ü'£¬Remark = '%s' where ItemID = '%s'",e.what() ,carModel);
|
|
|
m_pConnection->Execute(_bstr_t(updateSql), 0, adCmdText);
|
|
|
updateSql = NULL;
|
|
|
//ÈÕÖ¾±í
|
|
|
//char *insertLog = (char*)calloc(1024, sizeof(char));
|
|
|
//sprintf(insertLog, "insert into GD_ORDERBOM_LABLE_LOG(ItemID,Lable,Remark) VALUES('%s','¸üÐÂʧ°Ü','%s')",carModel,e.what() );
|
|
|
//m_pConnection->Execute(_bstr_t(insertLog), 0, adCmdText);
|
|
|
//insertLog = NULL;
|
|
|
std::cout << e.what() << std::endl;
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
printf("Create instance of connection failed!");
|
|
|
return 1;
|
|
|
}
|
|
|
|
|
|
DOFREE(object_type);
|
|
|
DOFREE(server_address);
|
|
|
DOFREE(carModel);
|
|
|
DOFREE(bvr_list);
|
|
|
printf("=========================ͬ²½³¬¼¶BOM END ===================\n");
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
void getBomLinePropertysBom(tag_t top_line,string topUUID,char * carModel, _ConnectionPtr m_pConnection) {
|
|
|
//printf("¿ªÊ¼Ö´ÐÐgetBomLinePropertys\n");
|
|
|
int count;
|
|
|
tag_t *children_line;
|
|
|
ITKCALL(BOM_line_ask_all_child_lines(top_line, &count, &children_line));
|
|
|
//printf("×ÓÐÐ=%d \n", count);
|
|
|
for (int ii = 0; ii < count; ii++)
|
|
|
{
|
|
|
countInsertSql++;
|
|
|
tag_t partItemRevision = NULLTAG,item = NULLTAG;
|
|
|
|
|
|
|
|
|
string childUUID = getUUid();
|
|
|
char * itemId = "";
|
|
|
char * formula = "";
|
|
|
char * itemType = "";
|
|
|
char * sequenceNumber = "";
|
|
|
char * hierarchy = "";
|
|
|
char * quantity = "";
|
|
|
char * psqy = "";
|
|
|
char * scqy = "";
|
|
|
char * psqw = "";
|
|
|
char * scgw = "";
|
|
|
char * name = "";
|
|
|
char * sjzl = "";
|
|
|
char * mz = "";
|
|
|
char * wlfl = "";
|
|
|
char * dw = "";
|
|
|
char * jcjwlh = "";
|
|
|
char * sfqdj = "";
|
|
|
char * gyzy = "";
|
|
|
char * realParentID = "";
|
|
|
char * clgg = "";
|
|
|
char * clhd = "";
|
|
|
ITKCALL(AOM_ask_value_string(top_line,"bl_item_item_id",&realParentID));
|
|
|
ITKCALL(AOM_ask_value_tag(children_line[ii],"bl_line_object",&partItemRevision));
|
|
|
ITKCALL(ITEM_ask_item_of_rev( partItemRevision, &item));
|
|
|
ITKCALL(AOM_ask_value_string(item, "object_type", &itemType));
|
|
|
ITKCALL(AOM_ask_value_string(children_line[ii], "bl_sequence_no", &sequenceNumber));
|
|
|
ITKCALL(AOM_ask_value_string(children_line[ii], "bl_item_item_id", &itemId));
|
|
|
ITKCALL(AOM_ask_value_string(children_line[ii], "bl_formula", &formula));
|
|
|
ITKCALL(AOM_ask_value_string(children_line[ii], "bl_quantity", &quantity));
|
|
|
ITKCALL(AOM_ask_value_string(children_line[ii], "Gd6_psqy", &psqy));
|
|
|
ITKCALL(AOM_ask_value_string(children_line[ii], "Gd6_scqy", &scqy));
|
|
|
ITKCALL(AOM_ask_value_string(children_line[ii], "Gd6_psgw", &psqw));
|
|
|
ITKCALL(AOM_ask_value_string(children_line[ii], "Gd6_scgw", &scgw));
|
|
|
ITKCALL(AOM_ask_value_string(children_line[ii], "bl_item_object_name", &name));
|
|
|
ITKCALL(AOM_ask_value_string(children_line[ii], "bl_Gd6_PartsRevisionMaster_gd6_sjzl", &sjzl));
|
|
|
ITKCALL(AOM_ask_value_string(children_line[ii], "bl_Gd6_PartsRevisionMaster_gd6_mz", &mz));
|
|
|
ITKCALL(AOM_ask_value_string(children_line[ii], "bl_Gd6_PartsRevisionMaster_gd6_wlfl", &wlfl));
|
|
|
ITKCALL(AOM_ask_value_string(children_line[ii], "bl_Gd6_PartsRevisionMaster_gd6_dw", &dw));
|
|
|
ITKCALL(AOM_ask_value_string(children_line[ii], "bl_Gd6_PartsRevisionMaster_gd6_jcjwlh", &jcjwlh));
|
|
|
ITKCALL(AOM_ask_value_string(children_line[ii], "bl_Gd6_PartsRevisionMaster_gd6_sfqdj", &sfqdj));
|
|
|
ITKCALL(AOM_ask_value_string(children_line[ii], "bl_Gd6_PartsRevisionMaster_gd6_gyzy", &gyzy));
|
|
|
ITKCALL(AOM_ask_value_string(children_line[ii], "bl_Gd6_PartsRevisionMaster_gd6_clgg", &clgg));
|
|
|
ITKCALL(AOM_ask_value_string(children_line[ii], "bl_Gd6_PartsRevisionMaster_gd6_clhd", &clhd));
|
|
|
char* insertSql = (char*)calloc(2048, sizeof(char));
|
|
|
sprintf(insertSql, "INSERT INTO GD_ORDERBOM_DATA (carModel,parentID,id,bl_formula,bl_item_type,bl_sequence_no,uid,hierarchy,bl_quantity,psqy,scqy,psgw,scgw,bl_item_object_name,sjzl,mz,wlfl,dw,jcjwlh,sfqdj,gyzy,realParentID,clgg,clhd) VALUES ('%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s')",carModel,topUUID.c_str(),itemId,formula,itemType,sequenceNumber,childUUID.c_str(),hierarchy,quantity,psqy,scqy,psqw,scgw,name,sjzl,mz,wlfl,dw,jcjwlh,sfqdj,gyzy,realParentID,clgg,clhd);
|
|
|
//printf("²åÈësql£¡%s\n",insertSql);
|
|
|
m_pConnection->Execute(_bstr_t(insertSql), 0, adCmdText);
|
|
|
DOFREE(itemId);
|
|
|
DOFREE(formula);
|
|
|
DOFREE(itemType);
|
|
|
DOFREE(sequenceNumber);
|
|
|
hierarchy = NULL;
|
|
|
DOFREE(quantity);
|
|
|
DOFREE(psqy);
|
|
|
DOFREE(scqy);
|
|
|
DOFREE(psqw);
|
|
|
DOFREE(scgw);
|
|
|
DOFREE(name);
|
|
|
DOFREE(sjzl);
|
|
|
DOFREE(mz);
|
|
|
DOFREE(wlfl);
|
|
|
DOFREE(dw);
|
|
|
DOFREE(jcjwlh);
|
|
|
DOFREE(sfqdj);
|
|
|
DOFREE(gyzy);
|
|
|
DOFREE(realParentID);
|
|
|
DOFREE(clgg);
|
|
|
DOFREE(clhd);
|
|
|
insertSql = NULL;
|
|
|
|
|
|
getBomLinePropertysBom(children_line[ii],childUUID,carModel,m_pConnection);
|
|
|
}
|
|
|
|
|
|
DOFREE(children_line);
|
|
|
|
|
|
}
|
|
|
//void getBomPropertys(EPM_action_message_t msg, int ifail) {
|
|
|
//
|
|
|
//
|
|
|
//
|
|
|
//
|
|
|
//}
|
|
|
|
|
|
|
|
|
void getBomLinePropertys(tag_t top_line,char *type) {
|
|
|
//printf("¿ªÊ¼Ö´ÐÐgetBomLinePropertys\n");
|
|
|
int count;
|
|
|
tag_t *children_line;
|
|
|
parameters = (char *)realloc(parameters, (countNum * 512) * sizeof(char));
|
|
|
//char parameter[5120] = "getBomPropertys,";
|
|
|
|
|
|
|
|
|
|
|
|
char *tc_root_file = getenv("tc_root"); //C:\Siemens\Teamcenter11
|
|
|
char jar_file[SS_MAXPATHLEN] = "";
|
|
|
strcpy(jar_file, tc_root_file);
|
|
|
strcat(jar_file, "\\portal\\plugins\\");
|
|
|
strcat(jar_file, "JLCS_05.jar");
|
|
|
|
|
|
BOM_line_ask_all_child_lines(top_line, &count, &children_line);
|
|
|
printf("×ÓÐÐ=%d \n", count);
|
|
|
for (int ii = 0; ii < count; ii++)
|
|
|
{
|
|
|
char * object_type = NULL;
|
|
|
//»ñÈ¡°æ±¾
|
|
|
tag_t partItemRevision = NULLTAG, parentItemRevision = NULLTAG;
|
|
|
AOM_ask_value_tag(children_line[ii],"bl_line_object",&partItemRevision);
|
|
|
AOM_ask_value_tag(top_line,"bl_line_object",&parentItemRevision);
|
|
|
//ITKCALL(ITEM_ask_latest_rev(partItem,&partItemRevision));
|
|
|
|
|
|
AOM_ask_value_string(partItemRevision, "object_type", &object_type);
|
|
|
//¹ýÂË·ÇÁã¼þ°æ±¾µÄ¶ÔÏó
|
|
|
if (strcmp("Gd6_PartsRevision", object_type) == 0
|
|
|
|| strcmp("Gd6_BZJRevision", object_type) == 0|| strcmp("Gd6_XZMKCRevision", object_type) == 0) {
|
|
|
int item_mast_rev_count = 0;
|
|
|
tag_t * item_mast_rev = NULLTAG;
|
|
|
//»ñÈ¡°æ±¾±íµ¥
|
|
|
ITKCALL(AOM_ask_value_tags(partItemRevision, "IMAN_master_form_rev", &item_mast_rev_count, &item_mast_rev ) )
|
|
|
char * wlfl = NULL;
|
|
|
AOM_ask_value_string(item_mast_rev[0], "gd6_wlfl", &wlfl);
|
|
|
if(strcmp("H40", wlfl) == 0){
|
|
|
continue;
|
|
|
}
|
|
|
//»ñÈ¡toplineÊôÐÔ
|
|
|
//¸¸¼þ´úºÅ
|
|
|
AOM_ask_value_string(parentItemRevision, "item_id", &MATNR);
|
|
|
//¸¸¼þ¹¤³§
|
|
|
WERKS = "6300";
|
|
|
//AOM_ask_value_string(children_line[ii], "bl_formatted_parent_name", &bl_formatted_parent_name);
|
|
|
//BOMÓÃ;
|
|
|
STLAN = "1";
|
|
|
//¿ÉÑ¡BOM
|
|
|
STALT = "1";
|
|
|
//ÏúÊÛµ¥ºÅ
|
|
|
VBELN = "";
|
|
|
//¶©µ¥ÐÐÏîÄ¿
|
|
|
VBPOS = "";
|
|
|
//¸¸¼þÊýÁ¿
|
|
|
AOM_ask_value_string(top_line, "bl_quantity", &BMENG);
|
|
|
//BOMÏîÄ¿ºÅ
|
|
|
AOM_ask_value_string(children_line[ii], "bl_sequence_no", &POSNR);
|
|
|
//ÏîÄ¿Àà±ð
|
|
|
POSTP = "L";
|
|
|
//×Ó¼þ´úºÅ
|
|
|
AOM_ask_value_string(partItemRevision, "item_id", &IDNRK);
|
|
|
//×Ó¼þÊýÁ¿
|
|
|
AOM_ask_value_string(children_line[ii], "bl_quantity", &MENGE);
|
|
|
//×Ó¼þµ¥Î»
|
|
|
AOM_ask_value_string(item_mast_rev[0], "gd6_dw", &MEINS);
|
|
|
//ÅäËÍÇøÓò
|
|
|
AOM_ask_value_string(children_line[0], "Gd6_psqy", &POTX1);
|
|
|
//Éú²ú¹¤Î»/ÅäË͹¤Î»gd6_scgw&gd6_psgw
|
|
|
char * scgw = NULL, * psgw = NULL;
|
|
|
|
|
|
AOM_ask_value_string(children_line[0], "Gd6_scgw", &scgw);
|
|
|
AOM_ask_value_string(children_line[0], "Gd6_psgw", &psgw);
|
|
|
|
|
|
strcat(parameters, MATNR);
|
|
|
strcat(parameters, ",");
|
|
|
strcat(parameters, WERKS);
|
|
|
strcat(parameters, ",");
|
|
|
strcat(parameters, STLAN);
|
|
|
strcat(parameters, ",");
|
|
|
strcat(parameters, STALT);
|
|
|
strcat(parameters, ",");
|
|
|
strcat(parameters, VBELN);
|
|
|
strcat(parameters, ",");
|
|
|
strcat(parameters, VBPOS);
|
|
|
strcat(parameters, ",");
|
|
|
strcat(parameters, BMENG);
|
|
|
strcat(parameters, ",");
|
|
|
strcat(parameters, POSNR);
|
|
|
strcat(parameters, ",");
|
|
|
strcat(parameters, POSTP);
|
|
|
strcat(parameters, ",");
|
|
|
strcat(parameters, IDNRK);
|
|
|
strcat(parameters, ",");
|
|
|
strcat(parameters, MENGE);
|
|
|
strcat(parameters, ",");
|
|
|
strcat(parameters, MEINS);
|
|
|
strcat(parameters, ",");
|
|
|
strcat(parameters, POTX1);
|
|
|
strcat(parameters, ",");
|
|
|
strcat(parameters, scgw);
|
|
|
strcat(parameters, ",");
|
|
|
strcat(parameters, psgw);
|
|
|
strcat(parameters, ",");
|
|
|
strcat(parameters, type);
|
|
|
strcat(parameters, "}}");
|
|
|
//strcat(parameters, parameter);
|
|
|
printf("parameter:\n%s\n", parameters);
|
|
|
//strcat(parameters, C5_gc);
|
|
|
//strcat(parameters, C5_scgw);
|
|
|
|
|
|
|
|
|
|
|
|
//char cmd[256] = "";
|
|
|
//strcpy(cmd, "java -jar \"");
|
|
|
//strcat(cmd, jar_file);
|
|
|
//strcat(cmd, "\" ");
|
|
|
//´«²Î
|
|
|
//strcat(cmd, parameter);
|
|
|
//printf("·¾¶:\n%s\n", cmd);
|
|
|
//system(cmd);
|
|
|
countNum++;
|
|
|
}
|
|
|
if(type == NULL){
|
|
|
getBomLinePropertys(children_line[ii],type);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
//---------------------------------------------------¹¤¾ß------------------------------------------------------
|
|
|
|
|
|
//·Ö¸î×Ö·û´®
|
|
|
void split(char *src, const char *separator, char **dest, int *num) {
|
|
|
/*
|
|
|
src Ô´×Ö·û´®µÄÊ×µØÖ·(bufµÄµØÖ·)
|
|
|
separator Ö¸¶¨µÄ·Ö¸î×Ö·û
|
|
|
dest ½ÓÊÕ×Ó×Ö·û´®µÄÊý×é
|
|
|
num ·Ö¸îºó×Ó×Ö·û´®µÄ¸öÊý
|
|
|
*/
|
|
|
char *pNext;
|
|
|
int count = 0;
|
|
|
if (src == NULL || strlen(src) == 0) //Èç¹û´«ÈëµÄµØÖ·Îª¿Õ»ò³¤¶ÈΪ0£¬Ö±½ÓÖÕÖ¹
|
|
|
return;
|
|
|
if (separator == NULL || strlen(separator) == 0) //Èçδָ¶¨·Ö¸îµÄ×Ö·û´®£¬Ö±½ÓÖÕÖ¹
|
|
|
return;
|
|
|
|
|
|
|
|
|
printf("·Ö¸îǰµÄ×Ö·û=======================%s\n",src);
|
|
|
|
|
|
pNext = strtok(src, separator); //±ØÐëʹÓÃ(char *)½øÐÐÇ¿ÖÆÀàÐÍת»»(ËäÈ»²»Ð´ÓеıàÒëÆ÷Öв»»á³öÏÖÖ¸Õë´íÎó)
|
|
|
while (pNext != NULL) {
|
|
|
|
|
|
|
|
|
printf("·Ö¸îºóµÄ×Ö·û=======================%s\n",pNext);
|
|
|
|
|
|
dest[count] = pNext;
|
|
|
++count;
|
|
|
pNext = strtok(NULL, separator); //±ØÐëʹÓÃ(char *)½øÐÐÇ¿ÖÆÀàÐÍת»»
|
|
|
}
|
|
|
*num = count;
|
|
|
}
|