You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
JINGDIAO_connor_jd/connor_ldy/JD_BOPInfoToMediDatabase.cxx

2951 lines
106 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#pragma warning (disable: 4996)
#pragma warning (disable: 4819)
#include <cstdio>
#include <io.h>
#include <epm/epm.h>
#include <ict/ict_userservice.h>
#include <tccore/item.h>
#include <ae/ae.h>
#include <tc/folder.h>
#include <tccore/aom.h>
#include <sa/sa.h>
#include <tccore/aom_prop.h>
#include <tccore/workspaceobject.h>
#include <tccore//grm.h>
#include <tccore/grmtype.h>
#include <bom/bom.h>
#include <me/me.h>
#include <me/meline.h>
#include <fclasses/tc_date.h>
#include <ics/ics.h>
#include <ics/ics2.h>
#include "tc_util.h"
#include "tc_log.h"
#include <vector>
#include <epm/signoff.h>
#include <iostream>
#include "string_utils.h"
#include "tinyxml.h"
#include "ado.h"
#include <stdio.h>
#include <time.h>
#include "k_util.h"
#include "curl_utils.h"
using namespace std;
#define GUID_LEN 64
struct CHILD
{
tag_t line;
tag_t rev;
tag_t item;
string clone_id;
};
struct FlowBean {
vector<tag_t> flowList;
tag_t flow_split = NULLTAG;
tag_t flow_combine = NULLTAG;
tag_t flow_end = NULLTAG;
char* BEZFL; // ²Î¿¼Ë³Ðò
string PLNFL = ""; // ÐòÁÐ
boolean isMain = true;
boolean isOther = false;
vector<tag_t> flow_combine_list;
};
struct FlowInfo {
string pre_id;
string pre_rev_id;
string suc_id;
string suc_rev_id;
};
struct MaxFlowInfo {
tag_t start_line;
vector<tag_t> all_line;
};
extern "C" int POM_AM__set_application_bypass(logical bypass);
string getGuid() {
char buffer[GUID_LEN] = { 0 };
GUID guid;
if (CoCreateGuid(&guid))
{
return "ERROR";
}
_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]);
return buffer;
}
vector<tag_t> getFlowStartsYH(int num, tag_t* c_line_tags) {
vector<tag_t> starts;
for (int i = 0; i < num; i++) {
tag_t gxLine = c_line_tags[i], * successors, * Mfg0predecessors;
int sucCnt = 0, preCnt = 0;
ITKCALL(AOM_ask_value_tags(gxLine, "Mfg0successors", &sucCnt, &successors));
ITKCALL(AOM_ask_value_tags(gxLine, "Mfg0predecessors", &preCnt, &Mfg0predecessors));
if (preCnt == 0 && sucCnt > 0) {
starts.push_back(gxLine);
}
}
return starts;
}
MaxFlowInfo copy(MaxFlowInfo old_info) {
MaxFlowInfo new_info;
new_info.start_line = old_info.start_line;
for (int num = 0; num < old_info.all_line.size(); num++) {
new_info.all_line.push_back(old_info.all_line[num]);
}
return new_info;
}
void readGXFlow(tag_t gxLine, vector<MaxFlowInfo>& all_line_info, map<string, FlowInfo>& line_info, MaxFlowInfo max_info) {
FlowInfo flow_info;
tag_t* successors, * Mfg0predecessors;
int sucCnt = 0, preCnt = 0;
char* gx_clone_id = NULL;
ITKCALL(AOM_ask_value_tags(gxLine, "Mfg0successors", &sucCnt, &successors));
ITKCALL(AOM_ask_value_tags(gxLine, "Mfg0predecessors", &preCnt, &Mfg0predecessors));
ITKCALL(AOM_ask_value_string(gxLine, "bl_clone_stable_occurrence_id", &gx_clone_id));
string pre_id = "";
string pre_rev_id = "";
string suc_id = "";
string suc_rev_id = "";
if (preCnt > 0) {
for (int g = 0; g < preCnt; g++) {
char* pre_item_id = NULL,
* pre_revision_id = NULL;
tag_t pre_gxRev;
ITKCALL(AOM_ask_value_tag(Mfg0predecessors[g], "bl_line_object", &pre_gxRev));
ITKCALL(AOM_ask_value_string(pre_gxRev, "item_id", &pre_item_id));
ITKCALL(AOM_ask_value_string(pre_gxRev, "item_revision_id", &pre_revision_id));
if (g > 0) {
pre_id.append(";");
pre_rev_id.append(";");
}
pre_id.append(string(pre_item_id));
pre_rev_id.append(string(pre_revision_id));
DOFREE(pre_item_id);
DOFREE(pre_revision_id);
}
}
flow_info.pre_id = pre_id;
flow_info.pre_rev_id = pre_rev_id;
if (sucCnt == 0) {
max_info.all_line.push_back(gxLine);
flow_info.suc_id = suc_id;
flow_info.suc_rev_id = suc_rev_id;
all_line_info.push_back(max_info);
line_info[string(gx_clone_id)] = flow_info;
return;
}
if (sucCnt > 0) {
for (int g = 0; g < sucCnt; g++) {
char* suc_item_id = NULL,
* suc_revision_id = NULL;
tag_t suc_gxRev;
ITKCALL(AOM_ask_value_tag(successors[g], "bl_line_object", &suc_gxRev));
ITKCALL(AOM_ask_value_string(suc_gxRev, "item_id", &suc_item_id));
ITKCALL(AOM_ask_value_string(suc_gxRev, "item_revision_id", &suc_revision_id));
if (g > 0) {
suc_id.append(";");
suc_rev_id.append(";");
}
suc_id.append(string(suc_item_id));
suc_rev_id.append(string(suc_revision_id));
DOFREE(suc_item_id);
DOFREE(suc_revision_id);
}
}
flow_info.suc_id = suc_id;
flow_info.suc_rev_id = suc_rev_id;
line_info[string(gx_clone_id)] = flow_info;
if (sucCnt > 0) {
max_info.all_line.push_back(gxLine);
for (int i = 0; i < sucCnt; i++) {
// ºóÇý¹¤Ðò´æÔÚ¶à¸öÐÂÔö¶àÌõÏß
MaxFlowInfo curr_max_info;
curr_max_info = copy(max_info);
readGXFlow(successors[i], all_line_info, line_info, curr_max_info);
}
}
DOFREE(gx_clone_id);
DOFREE(successors);
DOFREE(Mfg0predecessors);
}
void getMainProcess(tag_t* c_line_tags, int c_line_count, map<string, string>& main_flow, map<string, FlowInfo>& line_info) {
int maxLen = 0;
vector<MaxFlowInfo> all_line_info;
if (c_line_count == 0) {
return;
}
vector<tag_t> startLines = getFlowStartsYH(c_line_count, c_line_tags);
if (startLines.size() > 0) {
char* itemID;
ITKCALL(AOM_ask_value_string(startLines[0], "item_id", &itemID));
WriteLog("ÕÒµ½¹¤ÐòÁ÷Æðʼµã :%s\n", itemID);
DOFREE(itemID);
}
for (int i = 0; i < startLines.size(); i++) {
MaxFlowInfo max_flow_info;
max_flow_info.start_line = startLines[i];
readGXFlow(startLines[i], all_line_info, line_info, max_flow_info);
}
auto it = std::max_element(all_line_info.begin(), all_line_info.end(),
[](const MaxFlowInfo& a, const MaxFlowInfo& b) {
return a.all_line.size() <= b.all_line.size(); // ×¢ÒâÕâÀïÓà <=
// µ± a.size <= b.size ʱ£¬ÈÏΪ a ²»´óÓÚ b
// ËùÒÔµ±Óöµ½ÏàµÈµÄʱ£¬²»»áÌæ»»µ±Ç°µÄ×î´óÖµ
});
if (it != all_line_info.end()) {
WriteLog("Ö÷Á÷³ÌµÄ³¤¶ÈΪ>%d,·ÏßÈçÏ£º\n", it->all_line.size());
for (int i = 0; i < it->all_line.size(); i++) {
char* gx_clone_id = NULL;
char* item_id = NULL;
ITKCALL(AOM_ask_value_string(it->all_line[i], "bl_clone_stable_occurrence_id", &gx_clone_id));
ITKCALL(AOM_ask_value_string(it->all_line[i], "bl_item_item_id", &item_id));
WriteLog("->%s", item_id);
main_flow[gx_clone_id] = gx_clone_id;
DOFREE(gx_clone_id);
DOFREE(item_id);
}
WriteLog("\n");
}
}
// ´æÔÚÎÊÌ⣬¹¤ÐòÃ÷ÏÔ±íµÄÖ÷¼üδȡµ½£¬Ëï×Ó½Úµã»ñÈ¡µ½µÄÊÇ×Ó½ÚµãµÄ¶ÔÏóÐèÒª´¦Àí
string readBOPXML(map<string, map<vector<string>, vector<string>>>& xmlMap, string xmlPath) {
time_t currentTime;
struct tm* timeInfo;
char timeString[80];
// »ñÈ¡µ±Ç°Ê±¼ä
time(&currentTime);
// ½«Ê±¼äת»»Îª±¾µØÊ±¼ä
timeInfo = localtime(&currentTime);
TiXmlDocument* pDoc = new TiXmlDocument();
pDoc->LoadFile(xmlPath.c_str());
//pDoc->Print();
//char labelName[50]="";
//»ñÈ¡¸ù½Úµã
TiXmlElement* pRoot = pDoc->RootElement();
string rootName = pRoot->Value();
TiXmlElement* itemElement = pRoot->FirstChildElement("BOMCONTENTS");//
string t_Item_info = rootName;//
string itemLable = itemElement->Value();//Öмä±í±íÃû
//Ñ­»·±éÀú¸ù½ÚµãϵÄÐֵܽڵã
char type[50] = "";
char sessionId[50] = "";
char transNowTime[50] = "";
char transStatus[50] = "";
char itemId[50] = "";
char itemRev[50] = "";
char itemName[50] = "";
char itemRelease[50] = "";
map<vector<string>, vector<string>> propertyMap;//×Ö¶ÎÃû¼¯ºÏ£¬ÖµµÄ¼¯ºÏ
vector<string> nameVec;
vector<string> valueVec;
TiXmlElement* pChild = itemElement->FirstChildElement();
const char* attribute_value = NULL;
if (pChild != NULL) {
string childLabnelName = pChild->Value();
attribute_value = pChild->Attribute("val");
if (attribute_value == NULL) {
strcpy(sessionId, " ");
}
else {
strcpy(sessionId, attribute_value);
}
string tempValue = sessionId;
nameVec.push_back(childLabnelName);
valueVec.push_back(tempValue);
}
pChild = pChild->NextSiblingElement();
while (true) {
if (pChild != NULL) {
string childLabnelName = pChild->Value();
attribute_value = pChild->Attribute("val");
if (attribute_value == NULL) {
strcpy(sessionId, " ");
}
else {
strcpy(sessionId, attribute_value);
}
string tempValue = sessionId;
//propertyMap[childLabnelName]=tempValue;
if (strcmp("TRANSNO", childLabnelName.c_str()) == 0) {
//ת»»Ê±¼ä, ½«Ê±¼ä°´ÕÕÖ¸¶¨¸ñʽת»»Îª×Ö·û´®
strftime(timeString, sizeof(timeString), sessionId, timeInfo);
// ´òӡת»»ºóµÄʱ¼ä×Ö·û´®
tempValue = timeString;
}
else if (strcmp("SONPZLIST", childLabnelName.c_str()) == 0) {
}
else if (strcmp("SUNPZLIST", childLabnelName.c_str()) == 0) {
}
if (strcmp("SONPZLIST", childLabnelName.c_str()) != 0 && strcmp("SUNPZLIST", childLabnelName.c_str()) != 0) {
nameVec.push_back(childLabnelName);;
valueVec.push_back(tempValue);
}
pChild = pChild->NextSiblingElement();
if (pChild == NULL) {
break;
}
}
}
propertyMap[nameVec] = valueVec;
xmlMap["¸¸"] = propertyMap;
pChild = itemElement->FirstChildElement("SONPZLIST");
vector<string> childNameVec;
vector<string> childValueVec;
map<vector<string>, vector<string>> childPropertyMap;//×Ö¶ÎÃû¼¯ºÏ£¬ÖµµÄ¼¯ºÏ
TiXmlElement* sonChild = pChild;
TiXmlElement* cChild = sonChild->FirstChildElement();
if (cChild != NULL) {
string LabnelName = cChild->Value();
attribute_value = cChild->Attribute("val");
strcpy(sessionId, attribute_value); // ½« str ¸´ÖƸø copy
string tempValue = sessionId;
childNameVec.push_back(LabnelName);
childValueVec.push_back(tempValue);
}
cChild = cChild->NextSiblingElement();
while (true) {
if (cChild != NULL) {
string LabnelName = cChild->Value();
attribute_value = cChild->Attribute("val");
if (attribute_value == NULL) {
strcpy(sessionId, " "); // ½« str ¸´ÖƸø copy
}
else {
strcpy(sessionId, attribute_value); // ½« str ¸´ÖƸø copy
}
string tempValue = sessionId;
childNameVec.push_back(LabnelName);
childValueVec.push_back(tempValue);
}
cChild = cChild->NextSiblingElement();
if (cChild == NULL) {
break;
}
}
childPropertyMap[childNameVec] = childValueVec;
xmlMap["×Ó"] = childPropertyMap;
pChild = itemElement->FirstChildElement("SUNPZLIST");
if (pChild != NULL) {
vector<string> childLevel2NameVec;
vector<string> childLevel2ValueVec;
map<vector<string>, vector<string>> childLevel2PropertyMap;//×Ö¶ÎÃû¼¯ºÏ£¬ÖµµÄ¼¯ºÏ
TiXmlElement* sunChild = pChild;
TiXmlElement* sChild = sunChild->FirstChildElement();
if (sChild != NULL) {
string LabnelName = sChild->Value();
attribute_value = sChild->Attribute("val");
strcpy(sessionId, attribute_value); // ½« str ¸´ÖƸø copy
string tempValue = sessionId;
childLevel2NameVec.push_back(LabnelName);
childLevel2ValueVec.push_back(tempValue);
}
sChild = sChild->NextSiblingElement();
while (true) {
if (sChild != NULL) {
string LabnelName = sChild->Value();
attribute_value = sChild->Attribute("val");
if (attribute_value == NULL) {
strcpy(sessionId, " "); // ½« str ¸´ÖƸø copy
}
else {
strcpy(sessionId, attribute_value); // ½« str ¸´ÖƸø copy
}
string tempValue = sessionId;
childLevel2NameVec.push_back(LabnelName);
childLevel2ValueVec.push_back(tempValue);
}
sChild = sChild->NextSiblingElement();
if (sChild == NULL) {
break;
}
}
childLevel2PropertyMap[childLevel2NameVec] = childLevel2ValueVec;
xmlMap["Ëï"] = childLevel2PropertyMap;
}
delete pDoc;//Ó¦¸ÃÊDZØÒªµÄ
return t_Item_info;
}
string loadXml(string xmlUid, map<string, map<vector<string>, vector<string>>>& xmlMap) {
tag_t bomInfoXml = NULL;
ITK__convert_uid_to_tag(xmlUid.c_str(), &bomInfoXml);
//»ñÈ¡Îļþ
char* temp_dir = getenv("temp");//»ñµÃ»º´æÂ·¾¶
char output_file_xml_temp[SS_MAXPATHLEN] = "";
strcpy(output_file_xml_temp, temp_dir);
strcat(output_file_xml_temp, "\\");
strcat(output_file_xml_temp, xmlUid.c_str());
strcat(output_file_xml_temp, ".xml");
if (access(output_file_xml_temp, 0) == 0) {//´æÔÚ
if (remove(output_file_xml_temp) == 0) {
cout << "exist" << output_file_xml_temp << "delete" << endl;
}
}
POM_AM__set_application_bypass(true);
ITKCALL(AE_export_named_ref(bomInfoXml, "XMLRendering", output_file_xml_temp));
POM_AM__set_application_bypass(false);
string path = output_file_xml_temp;
string tableName = readBOPXML(xmlMap, path);
return tableName;
}
void loadBom(tag_t top_bom_line_tag, map<string, CHILD>& child_level1, map<string, vector<string>>& level1_level2, map<string, CHILD>& child_level2, map<string, vector<CHILD>> &gx_gb_bom, map<string, vector<CHILD>>& gx_gb_zy, map<string, string>& main_flow, map<string, FlowInfo>& line_info) {
int child_count = 0;
tag_t* child_tags = NULLTAG;
//ITKCALL(BOM_line_ask_child_lines(top_bom_line_tag, &child_count, &child_tags));
//ITKCALL(ME_line_ask_child_lines(top_bom_line_tag, &child_count, &child_tags));
ITKCALL(AOM_ask_value_tags(top_bom_line_tag, "Mfg0sub_elements", &child_count, &child_tags));
// ±éÀú¹¤ÒÕϹ¤Ðò²ã¼¶
WriteLog("¹¤Ðò¸öÊýΪ£º%d\n", child_count);
//loadPret(child_tags, child_count);
getMainProcess(child_tags, child_count, main_flow, line_info);
for (int x = 0; x < child_count; x++)
{
char* gx_clone_id = NULL;
CHILD child;
tag_t gx_rev = NULLTAG,
gx_item = NULLTAG,
* gx_child_tags = NULLTAG,
gxgb = NULLTAG,
* child_gbs = NULLTAG;
int gx_child_count = 0,
gb_child_count = 0;
vector<string> child_vec;
vector<CHILD> gb_vec;
ITKCALL(AOM_ask_value_tag(child_tags[x], "bl_line_object", &gx_rev));
ITKCALL(AOM_ask_value_string(child_tags[x], "bl_clone_stable_occurrence_id", &gx_clone_id));
ITEM_ask_item_of_rev(gx_rev, &gx_item);
string gx_key = string(gx_clone_id);
child.item = gx_item;
child.line = child_tags[x];
child.rev = gx_rev;
child.clone_id = gx_key;
child_level1[gx_key] = child;
// ±éÀú¹¤¹¤ÐòÏµĹ¤ÒÕ×ÊÔ´¼°Îļþ
ITKCALL(BOM_line_ask_child_lines(child_tags[x], &gx_child_count, &gx_child_tags));
WriteLog("¹¤Ðòϼ¶¸öÊýΪ£º%d\n", gx_child_count);
//ITKCALL(AOM_ask_value_tags(child_tags[x], "Mfg0sub_elements", &gx_child_count, &gx_child_tags));
for (int y = 0; y < gx_child_count; y++)
{
char* zy_clone_id = NULL;
CHILD gxChild;
tag_t zy_rev = NULLTAG,
zy_Item = NULLTAG;
ITKCALL(AOM_ask_value_tag(gx_child_tags[y], "bl_line_object", &zy_rev));
ITKCALL(AOM_ask_value_string(gx_child_tags[y], "bl_clone_stable_occurrence_id", &zy_clone_id));
string zy_key = string(zy_clone_id);
ITEM_ask_item_of_rev(zy_rev, &zy_Item);
gxChild.item = zy_Item;
gxChild.line = gx_child_tags[y];
gxChild.rev = zy_rev;
gxChild.clone_id = zy_key;
child_level2[zy_key] = gxChild;
child_vec.push_back(zy_key);
DOFREE(zy_clone_id);
}
level1_level2[gx_key] = child_vec;
// ±éÀú¹¤¹¤ÐòÏµĹ¤²½
ITKCALL(AOM_ask_value_tag(child_tags[x], "bl_me_activity_lines", &gxgb));
ITKCALL(AOM_ask_value_tags(gxgb, "me_cl_child_lines", &gb_child_count, &child_gbs));
WriteLog("¹¤²½Ï¼¶ÊýÁ¿£º%d\n", gb_child_count);
if (gb_child_count > 0) {
for (int z = 0; z < gb_child_count; z++) {
char* puid = NULL;
CHILD gbChild;
tag_t gb = NULLTAG,
* gb_zys = NULLTAG;
int tool_cnt = 0;
vector<CHILD> gbzy_vec;
ITKCALL(AOM_ask_value_tag(child_gbs[z], "al_object", &gb));
ITK__convert_tag_to_uid(gb, &puid);
string key = string(gx_clone_id) + string(puid);
ITKCALL(AOM_ask_value_tags(child_gbs[z], "al_activity_tool_bl_list", &tool_cnt, &gb_zys));
if (tool_cnt > 0) {
for (int a = 0; a < tool_cnt; a++) {
CHILD gbzyChild;
tag_t gbzy_rev = NULLTAG,
gbzy_Item = NULLTAG;
ITKCALL(AOM_ask_value_tag(gb_zys[a], "bl_line_object", &gbzy_rev));
ITEM_ask_item_of_rev(gbzy_rev, &gbzy_Item);
gbzyChild.rev = gbzy_rev;
gbzyChild.item = gbzy_Item;
gbzyChild.line = gb_zys[a];
gbzy_vec.push_back(gbzyChild);
}
}
gbChild.item = gb;
gbChild.line = child_gbs[z];
gb_vec.push_back(gbChild);
gx_gb_zy[key] = gbzy_vec;
DOFREE(puid);
DOFREE(gb_zys);
}
}
gx_gb_bom[gx_clone_id] = gb_vec;
DOFREE(child_gbs);
DOFREE(gx_clone_id);
DOFREE(gx_child_tags);
}
DOFREE(child_tags);
}
// ÏÂÔØÊý¾Ý¼¯Îļþµ½Ö¸¶¨µØÖ·²¢·¢Ë͵½FtpÖ¸¶¨Î»ÖÃ
string downloadDataset(tag_t dataset, string ftp_dir, char* type_name, string idAndRev, string username, string pwd) {
tag_t spec_dataset_rev = NULLTAG,
* ref_objects = NULLTAG;
int ref_cnt = 0;
char* dataset_type_name = NULL,
* pathname = NULL,
* origin_file_name = NULL;
string path,
dir,
ftp_url;
ITKCALL(AE_ask_dataset_named_refs(dataset, &ref_cnt, &ref_objects));
ITKCALL(AOM_UIF_ask_value(dataset, "object_type", &dataset_type_name));
for (int jy = 0; jy < ref_cnt; jy++)
{
ITKCALL(IMF_ask_original_file_name2(ref_objects[jy], &origin_file_name));
char temp_file[SS_MAXPATHLEN] = "";
strcpy(temp_file, getenv("TEMP"));
strcat(temp_file, "\\");
strcat(temp_file, origin_file_name);
ITKCALL(IMF_export_file(ref_objects[jy], temp_file));
dir = dir.assign(string(type_name)).append("/").append(string(dataset_type_name)).append("/").append(idAndRev);
ftp_url = ftp_url.assign(ftp_dir).append(dir).append("/");
path = path.assign(ftp_dir).append(dir).append("/").append(string(origin_file_name));
WriteLog("¿ªÊ¼´«µÝFTP£¬ftp_url£º%s£¬temp_file£º%s,path£º%s\,username£º%s\n", ftp_url.c_str(), temp_file, path.c_str(), username.c_str());
int result = sendFileByFtp(ftp_url, temp_file, path, username, pwd);
if (result == 1) {
path = "FTP´«µÝÎļþʧ°Ü£¡";
}
break;
}
DOFREE(pathname);
DOFREE(ref_objects);
DOFREE(origin_file_name);
DOFREE(origin_file_name);
return path;
}
// ¹¤ÒÕ·Ïß¹¤ÐòÃ÷ϸ±í
void insertGyGxBom(string xmlUid, bool &showError, ado ado0, tag_t gy_line, tag_t gy_item, tag_t gy_rev, map<string, CHILD> child_level1, map<string, string> &gx_cloneid_key, map<string, string> main_flow, map<string, FlowInfo> line_info) {
WriteLog("¼Ç¼¹¤ÒÕ·Ïß¹¤ÐòÃ÷ϸ±íÊý¾Ý¿â\n");
int ifail = 0;
//
string sqlStr = "insert into ";
string updateStr = "update ";
string selectStr = "select * from ";
string selectAfterUpdateStr = "select * from ";
string updateWhere = "";
// ¼ÓÔØ¹¤ÒÕ·Ïß¹¤ÐòÃ÷ÏÔ±íÊý¾Ý
// ½âÎöxmlÎļþ
// ´´½¨Ò»¸öXML½á¹¹²¢ÔØÈëÎļþÄÚÈÝ
map<string, map<vector<string>, vector<string>>> xmlMap;//ÎïÁÏÀàÐÍ£¬<×Ö¶ÎÃû£¬ÊôÐÔȡֵ>
string tableName = loadXml(xmlUid, xmlMap);
map<vector<string>, vector<string>> parentPropertyMap = xmlMap["¸¸"];//¸¸¼¶
vector<string> parentNameVec;
vector<string> parentValueVec;
map<vector<string>, vector<string>>::iterator rev_it2;
for (rev_it2 = parentPropertyMap.begin(); rev_it2 != parentPropertyMap.end(); rev_it2++) {
parentNameVec = rev_it2->first;
parentValueVec = rev_it2->second;
}
map<vector<string>, vector<string>> childPropertyMap = xmlMap["×Ó"];//×Ó¼¶
vector<string> childNameVec;
vector<string> childValueVec;
map<vector<string>, vector<string>>::iterator rev_it;
for (rev_it = childPropertyMap.begin(); rev_it != childPropertyMap.end(); rev_it++) {
childNameVec = rev_it->first;
childValueVec = rev_it->second;
}
vector<string> updateVec;
vector<string> selectVec;
vector<string> insertVec;
vector<string> selectAfterUpdateVec;
vector<string> insertClonIdVec;
sqlStr = sqlStr.append(tableName).append("(");
selectStr = selectStr.append(tableName).append(" ");
selectAfterUpdateStr = selectAfterUpdateStr.append(tableName).append(" ");
string valueStr = " VALUES (";
//»ñÈ¡¸¸ÊôÐÔ
string parentColumnStr = "insert into ";
parentColumnStr = parentColumnStr.append(tableName).append(" (");
string parentValueStr = " values(";
for (int j = 0; j < parentNameVec.size(); j++)
{
string columnName = parentNameVec[j];
parentColumnStr = parentColumnStr.append(columnName);
if (j < parentNameVec.size() - 1) {
parentColumnStr = parentColumnStr.append(",");
}
string propertyName = parentValueVec[j];
string tempValue = " ";
string updateValue = "";
if (strcmp(columnName.c_str(), "SESSIONID") == 0) {
tempValue = propertyName;//¹Ì¶¨Öµ
}
else if (strcmp(columnName.c_str(), "TRANSNO") == 0) {
tempValue = propertyName;//ÒÑ´¦Àí
if (updateWhere.length() == 0) {
updateWhere = updateWhere.append(" where ");
updateWhere = updateWhere.append(columnName).append("='").append(tempValue).append("' and ");
selectStr = selectStr.append(" where ");
selectStr = selectStr.append(columnName).append("='").append(tempValue).append("' and ");
selectAfterUpdateStr = selectAfterUpdateStr.append(" where ");
selectAfterUpdateStr = selectAfterUpdateStr.append(columnName).append("='").append(tempValue).append("' and ");
}
else {
updateWhere = updateWhere.append(columnName).append("='").append(tempValue).append("' and ");
selectStr = selectStr.append(columnName).append("='").append(tempValue).append("' and ");
selectAfterUpdateStr = selectAfterUpdateStr.append(columnName).append("='").append(tempValue).append("' and ");
}
}
else if (strcmp(columnName.c_str(), "TRANSSTATUS") == 0) {
//Ê״δ«µÝ¿ÕÖµ
updateValue = propertyName;
updateStr = updateStr.append(tableName).append(" set ").append(columnName).append("='").append(updateValue).append("' ");
selectAfterUpdateStr = selectAfterUpdateStr.append(columnName).append("='").append(updateValue).append("' and ");
}
else if (strcmp(columnName.c_str(), "PPUID") == 0) {
char* puid = NULL;
ITK__convert_tag_to_uid(gy_rev, &puid);
tempValue = puid;
//selectStr = selectStr.append(columnName).append("='").append(tempValue).append("' and ");
if (updateWhere.length() == 0) {
updateWhere = updateWhere.append(" where ");
updateWhere = updateWhere.append(columnName).append("='").append(puid).append("' and ");
selectStr = selectStr.append(" where ");
selectStr = selectStr.append(columnName).append("='").append(tempValue).append("' and ");
selectAfterUpdateStr = selectAfterUpdateStr.append(" where ");
selectAfterUpdateStr = selectAfterUpdateStr.append(columnName).append("='").append(tempValue).append("' and ");
}
else {
updateWhere = updateWhere.append(columnName).append("='").append(puid).append("' and ");
selectStr = selectStr.append(columnName).append("='").append(puid).append("' and ");
selectAfterUpdateStr = selectAfterUpdateStr.append(columnName).append("='").append(puid).append("' and ");
}
DOFREE(puid);
}
else {
vector<string> propertyVec;
Split(propertyName, ".", propertyVec);
if (propertyVec.size() == 2) {
string propertyPosition = propertyVec[0];
tag_t propertyTag = NULL;
if (strcmp("item", propertyPosition.c_str()) == 0) {
propertyTag = gy_item;
}
else if (strcmp("rev", propertyPosition.c_str()) == 0) {
propertyTag = gy_rev;
}
else if (strcmp("bomline", propertyPosition.c_str()) == 0) {
propertyTag = gy_line;
}
string propertyName = propertyVec[1];
char* propertyValue = NULL;
if (strcmp("puid", propertyName.c_str()) == 0) {
ITK__convert_tag_to_uid(propertyTag, &propertyValue);
}
else {
ITKCALL(ifail = AOM_UIF_ask_value(propertyTag, propertyName.c_str(), &propertyValue));
}
EMH_clear_errors();
if (ifail == 0) {
tempValue = propertyValue;
}
else {
showError = true;
WriteLog("ÊôÐÔÒì³££º%s\n", propertyName.c_str());
tempValue = " ";
}
DOFREE(propertyValue);
}
}
parentValueStr = parentValueStr.append("'").append(tempValue).append("'");
if (j < parentNameVec.size() - 1) {
parentValueStr = parentValueStr.append(",");
}
}
map<string, CHILD>::iterator child_it;
for (child_it = child_level1.begin(); child_it != child_level1.end(); child_it++) {
char* type = NULL;
bool isContinue = false;
string childColumnStr = "";
string childSelectStr = "";
string childUpdateSelectStr = "";
string childUpdateWhere = "";
string childValueStr = "";
tag_t line = child_it->second.line;
tag_t item = child_it->second.item;
tag_t rev = child_it->second.rev;
string clone_id = child_it->second.clone_id;
string primay_key = "";
FlowInfo flow_info = line_info[clone_id];
ITKCALL(ifail = AOM_ask_value_string(rev, "object_type", &type));
for (int j = 0; j < childNameVec.size(); j++)
{
string columnName = childNameVec[j];
string propertyName = childValueVec[j];
string tempValue = " ";
bool isInt = false;
if (strcmp(columnName.c_str(), "_FILTERTYPE") == 0) {
if (strcmp(propertyName.c_str(), "ALL") == 0) {
continue;
}
else {
vector<string>typeVec;
Split(propertyName, ";", typeVec);
if (hasElement(typeVec, type) == 0) {
continue;
}
else {
isContinue = true;
break;
}
}
}
else if (strcmp(columnName.c_str(), "CPUID") == 0) {
char* puid = NULL;
ITK__convert_tag_to_uid(rev, &puid);
tempValue = puid;
DOFREE(puid);
childSelectStr = childSelectStr.append(columnName).append("='").append(tempValue).append("' ");
childUpdateSelectStr = childUpdateSelectStr.append(columnName).append("='").append(tempValue).append("' ");
childUpdateWhere = childUpdateWhere.append(columnName).append("='").append(tempValue).append("'");
}
else if (strcmp(columnName.c_str(), "MES_PRE_BP_ID") == 0) {
tempValue = flow_info.pre_id;
}
else if (strcmp(columnName.c_str(), "MES_PRE_BP_VERSION") == 0) {
tempValue = flow_info.pre_rev_id;
}
else if (strcmp(columnName.c_str(), "MES_NEXT_BP_ID") == 0) {
tempValue = flow_info.suc_id;
}
else if (strcmp(columnName.c_str(), "MES_NEXT_BP_VERSION") == 0) {
tempValue = flow_info.suc_rev_id;
}
else if (strcmp(columnName.c_str(), "MES_CRITICAL_PATH") == 0) {
isInt = true;
auto it = main_flow.find(clone_id);
if (it != main_flow.end()) {
tempValue = "1";
}
else {
tempValue = "0";
}
}
else {
vector<string> propertyVec;
Split(propertyName, ".", propertyVec);
if (propertyVec.size() == 2) {
string propertyPosition = propertyVec[0];
tag_t propertyTag = NULL;
if (strcmp("item", propertyPosition.c_str()) == 0) {
propertyTag = item;
}
else if (strcmp("rev", propertyPosition.c_str()) == 0) {
propertyTag = rev;
}
else if (strcmp("bomline", propertyPosition.c_str()) == 0) {
propertyTag = line;
}
string propertyName = propertyVec[1];
char* propertyValue = NULL;
if (strcmp("puid", propertyName.c_str()) == 0) {
ITK__convert_tag_to_uid(propertyTag, &propertyValue);
}
else {
ITKCALL(ifail = AOM_UIF_ask_value(propertyTag, propertyName.c_str(), &propertyValue));
}
EMH_clear_errors();
if (ifail == 0) {
tempValue = propertyValue;
}
else {
showError = true;
WriteLog("ÊôÐÔÒì³££º%s\n", propertyName.c_str());
tempValue = " ";
}
DOFREE(propertyValue);
}
else if (strcmp("key", propertyName.c_str()) == 0) {
primay_key = getGuid();
tempValue = primay_key;
}
else {
tempValue = " ";
}
}
childColumnStr = childColumnStr.append(columnName);
if (j < childNameVec.size() - 1) {
childColumnStr = childColumnStr.append(",");
}
if (isInt) {
childValueStr = childValueStr.append("").append(tempValue);
if (j < childNameVec.size() - 1) {
childValueStr = childValueStr.append(",");
}
}
else {
childValueStr = childValueStr.append("'").append(tempValue);
if (j < childNameVec.size() - 1) {
childValueStr = childValueStr.append("',");
}
else {
childValueStr = childValueStr.append("'");
}
}
}
if (isContinue) {
continue;
}
string insertSql = "";
string selectSql = "";
string updateSelectSql = "";
string updateSql = "";
if (childColumnStr.size() > 0) {
insertSql = insertSql.append(parentColumnStr).append(",").append(childColumnStr).append(")").append(parentValueStr).append(",").append(childValueStr).append(")");
}
else {
insertSql = insertSql.append(parentColumnStr).append(")").append(parentValueStr).append(")");
}
selectSql = selectSql.append(selectStr).append(childSelectStr);
updateSelectSql = updateSelectSql.append(selectAfterUpdateStr).append(childUpdateSelectStr);
updateSql = updateSql.append(updateStr).append(updateWhere).append(childUpdateWhere);
//updateStr = updateStr.append(updateWhere);
insertSql = Utf8ToGbk(insertSql.c_str());
updateSql = Utf8ToGbk(updateSql.c_str());
selectSql = Utf8ToGbk(selectSql.c_str());
updateSelectSql = Utf8ToGbk(updateSelectSql.c_str());
WriteLog("¹¤ÐòÃ÷ϸ²åÈëÓï¾ä£º%s\n", insertSql.c_str());
//WriteLog("¹¤ÐòÃ÷ϸ¸üÐÂÓï¾ä£º%s\n", updateSql.c_str());
WriteLog("¹¤ÐòÃ÷ϸ²éѯÓï¾ä£º%s\n", selectSql.c_str());
//WriteLog("¹¤ÐòÃ÷ϸ¸üкó²éѯÓï¾ä£º%s\n", updateSelectSql.c_str());
insertVec.push_back(insertSql);
updateVec.push_back(updateSql);
selectVec.push_back(selectSql);
selectAfterUpdateVec.push_back(updateSelectSql);
insertClonIdVec.push_back(clone_id);
char sendChar[512] = "";
strcpy(sendChar, insertSql.c_str());
char sendChar2[1024] = "";
strcpy(sendChar2, selectSql.c_str());
int result = ado0.ado_QuerySQLNoInputParam(sendChar2);
bool resultSql = ado0.executeInsert(sendChar2, sendChar, result);
gx_cloneid_key[clone_id] = primay_key;
//if (!resultSql) {
// WriteLog("Êý¾Ý¿âÓï¾ä²åÈëʧ°Ü\n");
//}
DOFREE(type);
}
}
// ¹¤Ðò¹¤²½¹ØÏµ±í
void insertGxGb(string xmlUid, bool& showError, ado ado0, map<string, CHILD> child_level1, map<string, string> gx_cloneid_key, map<string, vector<CHILD>> gx_gbs_bom, map<string, string>& gx_gb_key) {
WriteLog("¼Ç¼¹¤Ðò¹¤²½¹ØÏµ±íÊý¾Ý¿â\n");
int ifail = 0;
char* gx_type = NULL;
vector<string> updateVec;
vector<string> selectVec;
vector<string> insertVec;
vector<string> selectAfterUpdateVec;
vector<string> insertPuidVec;
// ½âÎöxmlÎļþ
// ´´½¨Ò»¸öXML½á¹¹²¢ÔØÈëÎļþÄÚÈÝ
map<string, map<vector<string>, vector<string>>> xmlMap;//ÎïÁÏÀàÐÍ£¬<×Ö¶ÎÃû£¬ÊôÐÔȡֵ>
string tableName = loadXml(xmlUid, xmlMap);
map<vector<string>, vector<string>> parentPropertyMap = xmlMap["¸¸"];//¸¸¼¶
vector<string> parentNameVec;
vector<string> parentValueVec;
map<vector<string>, vector<string>>::iterator rev_it2;
for (rev_it2 = parentPropertyMap.begin(); rev_it2 != parentPropertyMap.end(); rev_it2++) {
parentNameVec = rev_it2->first;
parentValueVec = rev_it2->second;
}
map<vector<string>, vector<string>> childPropertyMap = xmlMap["×Ó"];//×Ó¼¶
vector<string> childNameVec;
vector<string> childValueVec;
map<vector<string>, vector<string>>::iterator rev_it;
for (rev_it = childPropertyMap.begin(); rev_it != childPropertyMap.end(); rev_it++) {
childNameVec = rev_it->first;
childValueVec = rev_it->second;
}
map<string, CHILD>::iterator child_it;
for (child_it = child_level1.begin(); child_it != child_level1.end(); child_it++) {
bool isGxContinue = false;
char* type = NULL;
string sqlStr = "insert into ";
string updateStr = "update ";
string selectStr = "select * from ";
string selectAfterUpdateStr = "select * from ";
string updateWhere = "";
string gx_clone_id = child_it->first;
tag_t gx_line = child_it->second.line;
tag_t gx_item = child_it->second.item;
tag_t gx_rev = child_it->second.rev;
vector<CHILD> gbs = gx_gbs_bom[gx_clone_id];
ITKCALL(ifail = AOM_ask_value_string(gx_rev, "object_type", &gx_type));
sqlStr = sqlStr.append(tableName).append("(");
selectStr = selectStr.append(tableName).append(" ");
selectAfterUpdateStr = selectAfterUpdateStr.append(tableName).append(" ");
string valueStr = " VALUES (";
//»ñÈ¡¸¸ÊôÐÔ
string parentColumnStr = "insert into ";
parentColumnStr = parentColumnStr.append(tableName).append(" (");
string parentValueStr = " values(";
for (int j = 0; j < parentNameVec.size(); j++)
{
string columnName = parentNameVec[j];
parentColumnStr = parentColumnStr.append(columnName);
if (j < parentNameVec.size() - 1) {
parentColumnStr = parentColumnStr.append(",");
}
string propertyName = parentValueVec[j];
string tempValue = " ";
string updateValue = "";
if (strcmp(columnName.c_str(), "_FILTERTYPE") == 0) {
if (strcmp(propertyName.c_str(), "ALL") == 0) {
continue;
}
else {
vector<string>typeVec;
Split(propertyName, ";", typeVec);
if (hasElement(typeVec, gx_type) == 0) {
continue;
}
else {
isGxContinue = true;
break;
}
}
}
else if (strcmp(columnName.c_str(), "SESSIONID") == 0) {
tempValue = propertyName;//¹Ì¶¨Öµ
}
else if (strcmp(columnName.c_str(), "PROCESS_DETAILS_ID") == 0) {
tempValue = gx_cloneid_key[gx_clone_id];// ¹¤ÐòÃ÷ϸ±íID£¨Íâ¼ü£©
}
else if (strcmp(columnName.c_str(), "TRANSNO") == 0) {
tempValue = propertyName;//ÒÑ´¦Àí
if (updateWhere.length() == 0) {
updateWhere = updateWhere.append(" where ");
updateWhere = updateWhere.append(columnName).append("='").append(tempValue).append("' and ");
selectStr = selectStr.append(" where ");
selectStr = selectStr.append(columnName).append("='").append(tempValue).append("' and ");
selectAfterUpdateStr = selectAfterUpdateStr.append(" where ");
selectAfterUpdateStr = selectAfterUpdateStr.append(columnName).append("='").append(tempValue).append("' and ");
}
else {
updateWhere = updateWhere.append(columnName).append("='").append(tempValue).append("' and ");
selectStr = selectStr.append(columnName).append("='").append(tempValue).append("' and ");
selectAfterUpdateStr = selectAfterUpdateStr.append(columnName).append("='").append(tempValue).append("' and ");
}
}
else if (strcmp(columnName.c_str(), "TRANSSTATUS") == 0) {
//Ê״δ«µÝ¿ÕÖµ
updateValue = propertyName;
updateStr = updateStr.append(tableName).append(" set ").append(columnName).append("='").append(updateValue).append("' ");
selectAfterUpdateStr = selectAfterUpdateStr.append(columnName).append("='").append(updateValue).append("' and ");
}
else if (strcmp(columnName.c_str(), "PPUID") == 0) {
char* puid = NULL;
ITK__convert_tag_to_uid(gx_rev, &puid);
tempValue = puid;
//selectStr = selectStr.append(columnName).append("='").append(tempValue).append("' and ");
if (updateWhere.length() == 0) {
updateWhere = updateWhere.append(" where ");
updateWhere = updateWhere.append(columnName).append("='").append(puid).append("' and ");
selectStr = selectStr.append(" where ");
selectStr = selectStr.append(columnName).append("='").append(tempValue).append("' and ");
selectAfterUpdateStr = selectAfterUpdateStr.append(" where ");
selectAfterUpdateStr = selectAfterUpdateStr.append(columnName).append("='").append(tempValue).append("' and ");
}
else {
updateWhere = updateWhere.append(columnName).append("='").append(puid).append("' and ");
selectStr = selectStr.append(columnName).append("='").append(puid).append("' and ");
selectAfterUpdateStr = selectAfterUpdateStr.append(columnName).append("='").append(puid).append("' and ");
}
DOFREE(puid);
}
else {
vector<string> propertyVec;
Split(propertyName, ".", propertyVec);
if (propertyVec.size() == 2) {
string propertyPosition = propertyVec[0];
tag_t propertyTag = NULL;
if (strcmp("item", propertyPosition.c_str()) == 0) {
propertyTag = gx_item;
}
else if (strcmp("rev", propertyPosition.c_str()) == 0) {
propertyTag = gx_rev;
}
else if (strcmp("bomline", propertyPosition.c_str()) == 0) {
propertyTag = gx_line;
}
string propertyName = propertyVec[1];
char* propertyValue = NULL;
if (strcmp("puid", propertyName.c_str()) == 0) {
ITK__convert_tag_to_uid(propertyTag, &propertyValue);
}
else {
ITKCALL(ifail = AOM_UIF_ask_value(propertyTag, propertyName.c_str(), &propertyValue));
}
EMH_clear_errors();
if (ifail == 0) {
tempValue = propertyValue;
}
else {
showError = true;
WriteLog("ÊôÐÔÒì³££º%s\n", propertyName.c_str());
tempValue = " ";
}
DOFREE(propertyValue);
}
}
parentValueStr = parentValueStr.append("'").append(tempValue).append("'");
if (j < parentNameVec.size() - 1) {
parentValueStr = parentValueStr.append(",");
}
}
if (isGxContinue) {
continue;
}
int gb_count = gbs.size();
if (gb_count > 0) {
for (int x = 0; x < gb_count; x++) {
bool isContinue = false;
tag_t gb_line = gbs[x].line;
tag_t gb_item = gbs[x].item;
string childColumnStr = "";
string childSelectStr = "";
string childUpdateSelectStr = "";
string childUpdateWhere = "";
string childValueStr = "";
string gb_puid = "";;
string primay_key = "";
ITKCALL(ifail = AOM_ask_value_string(gb_item, "object_type", &type));
for (int j = 0; j < childNameVec.size(); j++)
{
string columnName = childNameVec[j];
string propertyName = childValueVec[j];
string tempValue = " ";
if (strcmp(columnName.c_str(), "_FILTERTYPE") == 0) {
if (strcmp(propertyName.c_str(), "ALL") == 0) {
continue;
}
else {
vector<string>typeVec;
Split(propertyName, ";", typeVec);
if (hasElement(typeVec, type) == 0) {
continue;
}
else {
isContinue = true;
break;
}
}
}
else if (strcmp(columnName.c_str(), "CPUID") == 0) {
char* puid = NULL;
ITK__convert_tag_to_uid(gb_item, &puid);
tempValue = puid;
gb_puid = string(puid);
childSelectStr = childSelectStr.append(columnName).append("='").append(tempValue).append("' ");
childUpdateSelectStr = childUpdateSelectStr.append(columnName).append("='").append(tempValue).append("' ");
childUpdateWhere = childUpdateWhere.append(columnName).append("='").append(tempValue).append("'");
DOFREE(puid);
}
else {
vector<string> propertyVec;
Split(propertyName, ".", propertyVec);
if (propertyVec.size() == 2) {
string propertyPosition = propertyVec[0];
tag_t propertyTag = NULL;
if (strcmp("item", propertyPosition.c_str()) == 0) {
propertyTag = gb_item;
}
else if (strcmp("bomline", propertyPosition.c_str()) == 0) {
propertyTag = gb_line;
}
string propertyName = propertyVec[1];
char* propertyValue = NULL;
if (strcmp("puid", propertyName.c_str()) == 0) {
ITK__convert_tag_to_uid(propertyTag, &propertyValue);
}
else {
ITKCALL(ifail = AOM_UIF_ask_value(propertyTag, propertyName.c_str(), &propertyValue));
}
EMH_clear_errors();
if (ifail == 0) {
tempValue = propertyValue;
}
else {
showError = true;
WriteLog("ÊôÐÔÒì³££º%s\n", propertyName.c_str());
tempValue = " ";
}
DOFREE(propertyValue);
}
else if (strcmp("key", propertyName.c_str()) == 0) {
primay_key = getGuid();
tempValue = primay_key;
}
else {
tempValue = " ";
}
}
childColumnStr = childColumnStr.append(columnName);
if (j < childNameVec.size() - 1) {
childColumnStr = childColumnStr.append(",");
}
childValueStr = childValueStr.append("'").append(tempValue);
if (j < childNameVec.size() - 1) {
childValueStr = childValueStr.append("',");
}
else {
childValueStr = childValueStr.append("'");
}
}
if (isContinue) {
continue;
}
string insertSql = "";
string selectSql = "";
string updateSelectSql = "";
string updateSql = "";
if (childColumnStr.size() > 0) {
insertSql = insertSql.append(parentColumnStr).append(",").append(childColumnStr).append(")").append(parentValueStr).append(",").append(childValueStr).append(")");
}
else {
insertSql = insertSql.append(parentColumnStr).append(")").append(parentValueStr).append(")");
}
selectSql = selectSql.append(selectStr).append(childSelectStr);
updateSelectSql = updateSelectSql.append(selectAfterUpdateStr).append(childUpdateSelectStr);
updateSql = updateSql.append(updateStr).append(updateWhere).append(childUpdateWhere);
//updateStr = updateStr.append(updateWhere);
insertSql = Utf8ToGbk(insertSql.c_str());
updateSql = Utf8ToGbk(updateSql.c_str());
selectSql = Utf8ToGbk(selectSql.c_str());
updateSelectSql = Utf8ToGbk(updateSelectSql.c_str());
WriteLog("¹¤²½²åÈëÓï¾ä£º%s\n", insertSql.c_str());
//WriteLog("¹¤²½¸üÐÂÓï¾ä£º%s\n", updateSql.c_str());
WriteLog("¹¤²½²éѯÓï¾ä£º%s\n", selectSql.c_str());
//WriteLog("¹¤²½¸üкó²éѯÓï¾ä£º%s\n", updateSelectSql.c_str());
insertVec.push_back(insertSql);
updateVec.push_back(updateSql);
selectVec.push_back(selectSql);
selectAfterUpdateVec.push_back(updateSelectSql);
insertPuidVec.push_back(gx_clone_id + gb_puid);
char sendChar[400] = "";
strcpy(sendChar, insertSql.c_str());
char sendChar2[400] = "";
strcpy(sendChar2, selectSql.c_str());
int result = ado0.ado_QuerySQLNoInputParam(sendChar2);
bool resultSql = ado0.executeInsert(sendChar2, sendChar, result);
string key = gx_clone_id + gb_puid;
gx_gb_key[key] = primay_key;
//if (!resultSql) {
// WriteLog("Êý¾Ý¿âÓï¾ä²åÈëʧ°Ü\n");
//}
}
}
DOFREE(type);
}
DOFREE(gx_type);
//¸üÐÂÊý¾Ý¿â
//for (int i = 0; i < updateVec.size(); i++) {
// int outputColumn = 0, outputValueCount = 0;
// char*** outputValue = NULL;
// string updateSql = updateVec[i];
// string selectSql = selectVec[i];
// string insertSql = insertVec[i];
// string selectUpdate = selectAfterUpdateVec[i];
// string key = insertPuidVec[i];
// char sendChar[400] = "";
// char sendChar2[400] = "";
// char sendChar3[400] = "";
// strcpy(sendChar, updateSql.c_str());
// strcpy(sendChar2, selectSql.c_str());
// strcpy(sendChar3, selectUpdate.c_str());
// int result = ado0.ado_QuerySQLNoInputParam(sendChar2);
// if (result == 0) {
// showError = true;
// WriteLog("¹¤²½²åÈëʧ°Ü£º%s\n", insertSql.c_str());
// }
// else {
// //bool resultSql = ado0.execute2(sendChar2, sendChar, result);
// result = ado0.ado_QuerySQLNoInputParam2(sendChar3, &outputColumn, &outputValueCount, &outputValue);
// if (result == 0) {
// showError = true;
// WriteLog("¹¤²½¸üÐÂʧ°Ü£º%s\n", updateSql.c_str());
// }
// else {
// if (outputValueCount > 0) {
// gx_gb_key[key] = string(outputValue[0][0]);
// }
// }
// }
//}
}
// ¹¤ÒÕ·Ïß-¹¤ÐòÊôÐÔ±í
void insertGyGxProp(string xmlUid, bool& showError, ado ado0, tag_t gy_line, tag_t gy_item, tag_t gy_rev, map<string, CHILD> child_level1, map<string, string> gx_cloneid_key) {
WriteLog("¼Ç¼¹¤ÒÕ·Ïß-¹¤ÐòÊôÐÔ±íÊý¾Ý¿â\n");
int ifail = 0;
char* type = NULL;
//
string sqlStr = "insert into ";
string updateStr = "update ";
string selectStr = "select * from ";
string selectAfterUpdateStr = "select * from ";
string updateWhere = "";
// ¼ÓÔØ¹¤ÒÕ·Ïß¹¤ÐòÃ÷ÏÔ±íÊý¾Ý
// ½âÎöxmlÎļþ
// ´´½¨Ò»¸öXML½á¹¹²¢ÔØÈëÎļþÄÚÈÝ
map<string, map<vector<string>, vector<string>>> xmlMap;//ÎïÁÏÀàÐÍ£¬<×Ö¶ÎÃû£¬ÊôÐÔȡֵ>
string tableName = loadXml(xmlUid, xmlMap);
map<vector<string>, vector<string>> parentPropertyMap = xmlMap["¸¸"];//¸¸¼¶
vector<string> parentNameVec;
vector<string> parentValueVec;
map<vector<string>, vector<string>>::iterator rev_it2;
for (rev_it2 = parentPropertyMap.begin(); rev_it2 != parentPropertyMap.end(); rev_it2++) {
parentNameVec = rev_it2->first;
parentValueVec = rev_it2->second;
}
map<vector<string>, vector<string>> childPropertyMap = xmlMap["×Ó"];//×Ó¼¶
vector<string> childNameVec;
vector<string> childValueVec;
map<vector<string>, vector<string>>::iterator rev_it;
for (rev_it = childPropertyMap.begin(); rev_it != childPropertyMap.end(); rev_it++) {
childNameVec = rev_it->first;
childValueVec = rev_it->second;
}
vector<string> updateVec;
vector<string> selectVec;
vector<string> insertVec;
vector<string> selectAfterUpdateVec;
sqlStr = sqlStr.append(tableName).append("(");
selectStr = selectStr.append(tableName).append(" ");
selectAfterUpdateStr = selectAfterUpdateStr.append(tableName).append(" ");
string valueStr = " VALUES (";
//»ñÈ¡¸¸ÊôÐÔ
string parentColumnStr = "insert into ";
parentColumnStr = parentColumnStr.append(tableName).append(" (");
string parentValueStr = " values(";
for (int j = 0; j < parentNameVec.size(); j++)
{
string columnName = parentNameVec[j];
parentColumnStr = parentColumnStr.append(columnName);
if (j < parentNameVec.size() - 1) {
parentColumnStr = parentColumnStr.append(",");
}
string propertyName = parentValueVec[j];
string tempValue = " ";
string updateValue = "";
if (strcmp(columnName.c_str(), "SESSIONID") == 0) {
tempValue = propertyName;//¹Ì¶¨Öµ
}
else if (strcmp(columnName.c_str(), "TRANSNO") == 0) {
tempValue = propertyName;//ÒÑ´¦Àí
if (updateWhere.length() == 0) {
updateWhere = updateWhere.append(" where ");
updateWhere = updateWhere.append(columnName).append("='").append(tempValue).append("' and ");
selectStr = selectStr.append(" where ");
selectStr = selectStr.append(columnName).append("='").append(tempValue).append("' and ");
selectAfterUpdateStr = selectAfterUpdateStr.append(" where ");
selectAfterUpdateStr = selectAfterUpdateStr.append(columnName).append("='").append(tempValue).append("' and ");
}
else {
updateWhere = updateWhere.append(columnName).append("='").append(tempValue).append("' and ");
selectStr = selectStr.append(columnName).append("='").append(tempValue).append("' and ");
selectAfterUpdateStr = selectAfterUpdateStr.append(columnName).append("='").append(tempValue).append("' and ");
}
}
else if (strcmp(columnName.c_str(), "TRANSSTATUS") == 0) {
//Ê״δ«µÝ¿ÕÖµ
updateValue = propertyName;
updateStr = updateStr.append(tableName).append(" set ").append(columnName).append("='").append(updateValue).append("' ");
selectAfterUpdateStr = selectAfterUpdateStr.append(columnName).append("='").append(updateValue).append("' and ");
}
else if (strcmp(columnName.c_str(), "PPUID") == 0) {
char* puid = NULL;
ITK__convert_tag_to_uid(gy_rev, &puid);
tempValue = puid;
//selectStr = selectStr.append(columnName).append("='").append(tempValue).append("' and ");
if (updateWhere.length() == 0) {
updateWhere = updateWhere.append(" where ");
updateWhere = updateWhere.append(columnName).append("='").append(puid).append("' and ");
selectStr = selectStr.append(" where ");
selectStr = selectStr.append(columnName).append("='").append(tempValue).append("' and ");
selectAfterUpdateStr = selectAfterUpdateStr.append(" where ");
selectAfterUpdateStr = selectAfterUpdateStr.append(columnName).append("='").append(tempValue).append("' and ");
}
else {
updateWhere = updateWhere.append(columnName).append("='").append(puid).append("' and ");
selectStr = selectStr.append(columnName).append("='").append(puid).append("' and ");
selectAfterUpdateStr = selectAfterUpdateStr.append(columnName).append("='").append(puid).append("' and ");
}
DOFREE(puid);
}
else {
vector<string> propertyVec;
Split(propertyName, ".", propertyVec);
if (propertyVec.size() == 2) {
string propertyPosition = propertyVec[0];
tag_t propertyTag = NULL;
if (strcmp("item", propertyPosition.c_str()) == 0) {
propertyTag = gy_item;
}
else if (strcmp("rev", propertyPosition.c_str()) == 0) {
propertyTag = gy_rev;
}
else if (strcmp("bomline", propertyPosition.c_str()) == 0) {
propertyTag = gy_line;
}
string propertyName = propertyVec[1];
char* propertyValue = NULL;
if (strcmp("puid", propertyName.c_str()) == 0) {
ITK__convert_tag_to_uid(propertyTag, &propertyValue);
}
else {
ITKCALL(ifail = AOM_UIF_ask_value(propertyTag, propertyName.c_str(), &propertyValue));
}
EMH_clear_errors();
if (ifail == 0) {
tempValue = propertyValue;
}
else {
showError = true;
WriteLog("ÊôÐÔÒì³££º%s\n", propertyName.c_str());
tempValue = " ";
}
DOFREE(propertyValue);
}
}
parentValueStr = parentValueStr.append("'").append(tempValue).append("'");
if (j < parentNameVec.size() - 1) {
parentValueStr = parentValueStr.append(",");
}
}
map<string, CHILD>::iterator child_it;
for (child_it = child_level1.begin(); child_it != child_level1.end(); child_it++) {
bool isContinue = false;
string childColumnStr = "";
string childSelectStr = "";
string childUpdateSelectStr = "";
string childUpdateWhere = "";
string childValueStr = "";
tag_t line = child_it->second.line;
tag_t item = child_it->second.item;
tag_t rev = child_it->second.rev;
string clone_id = child_it->second.clone_id;
ITKCALL(ifail = AOM_ask_value_string(rev, "object_type", &type));
for (int j = 0; j < childNameVec.size(); j++)
{
string columnName = childNameVec[j];
string propertyName = childValueVec[j];
string tempValue = " ";
if (strcmp(columnName.c_str(), "_FILTERTYPE") == 0) {
if (strcmp(propertyName.c_str(), "ALL") == 0) {
continue;
}
else {
vector<string>typeVec;
Split(propertyName, ";", typeVec);
if (hasElement(typeVec, type) == 0) {
continue;
}
else {
isContinue = true;
break;
}
}
} else if (strcmp(columnName.c_str(), "CPUID") == 0) {
char* puid = NULL;
ITK__convert_tag_to_uid(rev, &puid);
tempValue = puid;
childSelectStr = childSelectStr.append(columnName).append("='").append(tempValue).append("' ");
childUpdateSelectStr = childUpdateSelectStr.append(columnName).append("='").append(tempValue).append("' ");
childUpdateWhere = childUpdateWhere.append(columnName).append("='").append(tempValue).append("'");
DOFREE(puid);
}
else if (strcmp(columnName.c_str(), "PRD_ID") == 0) {
// È¡Ã÷ÏÔ±íÖеÄÖ÷¼ü
WriteLog("Êôclone_id£º%s\n", clone_id.c_str());
tempValue = gx_cloneid_key[clone_id];
WriteLog("Ã÷ÏÔ±íÖеÄÖ÷¼ü£º%s\n", tempValue.c_str());
}
else {
vector<string> propertyVec;
Split(propertyName, ".", propertyVec);
if (propertyVec.size() == 2) {
string propertyPosition = propertyVec[0];
tag_t propertyTag = NULL;
if (strcmp("item", propertyPosition.c_str()) == 0) {
propertyTag = item;
}
else if (strcmp("rev", propertyPosition.c_str()) == 0) {
propertyTag = rev;
}
else if (strcmp("bomline", propertyPosition.c_str()) == 0) {
propertyTag = line;
}
string propertyName = propertyVec[1];
char* propertyValue = NULL;
if (strcmp("puid", propertyName.c_str()) == 0) {
ITK__convert_tag_to_uid(propertyTag, &propertyValue);
}
else {
ITKCALL(ifail = AOM_UIF_ask_value(propertyTag, propertyName.c_str(), &propertyValue));
}
EMH_clear_errors();
if (ifail == 0) {
tempValue = propertyValue;
}
else {
showError = true;
WriteLog("ÊôÐÔÒì³££º%s\n", propertyName.c_str());
tempValue = " ";
}
DOFREE(propertyValue);
}
else if (strcmp("key", propertyName.c_str()) == 0){
tempValue = getGuid();
}
else {
tempValue = " ";
}
}
childColumnStr = childColumnStr.append(columnName);
if (j < childNameVec.size() - 1) {
childColumnStr = childColumnStr.append(",");
}
childValueStr = childValueStr.append("'").append(tempValue);
if (j < childNameVec.size() - 1) {
childValueStr = childValueStr.append("',");
}
else {
childValueStr = childValueStr.append("'");
}
}
if (isContinue) {
continue;
}
string insertSql = "";
string selectSql = "";
string updateSelectSql = "";
string updateSql = "";
if (childColumnStr.size() > 0) {
insertSql = insertSql.append(parentColumnStr).append(",").append(childColumnStr).append(")").append(parentValueStr).append(",").append(childValueStr).append(")");
}
else {
insertSql = insertSql.append(parentColumnStr).append(")").append(parentValueStr).append(")");
}
selectSql = selectSql.append(selectStr).append(childSelectStr);
updateSelectSql = updateSelectSql.append(selectAfterUpdateStr).append(childUpdateSelectStr);
updateSql = updateSql.append(updateStr).append(updateWhere).append(childUpdateWhere);
//updateStr = updateStr.append(updateWhere);
insertSql = Utf8ToGbk(insertSql.c_str());
updateSql = Utf8ToGbk(updateSql.c_str());
selectSql = Utf8ToGbk(selectSql.c_str());
updateSelectSql = Utf8ToGbk(updateSelectSql.c_str());
WriteLog("¹¤ÐòÊôÐÔ²åÈëÓï¾ä£º%s\n", insertSql.c_str());
//WriteLog("¹¤ÐòÊôÐÔ¸üÐÂÓï¾ä£º%s\n", updateSql.c_str());
WriteLog("¹¤ÐòÊôÐÔ²éѯÓï¾ä£º%s\n", selectSql.c_str());
//WriteLog("¹¤ÐòÊôÐÔ¸üкó²éѯÓï¾ä£º%s\n", updateSelectSql.c_str());
insertVec.push_back(insertSql);
updateVec.push_back(updateSql);
selectVec.push_back(selectSql);
selectAfterUpdateVec.push_back(updateSelectSql);
char sendChar[400] = "";
strcpy(sendChar, insertSql.c_str());
char sendChar2[400] = "";
strcpy(sendChar2, selectSql.c_str());
int result = ado0.ado_QuerySQLNoInputParam(sendChar2);
bool resultSql = ado0.executeInsert(sendChar2, sendChar, result);
}
DOFREE(type);
//¸üÐÂÊý¾Ý¿â
/*for (int i = 0; i < updateVec.size(); i++) {
string updateSql = updateVec[i];
string selectSql = selectVec[i];
string insertSql = insertVec[i];
string selectUpdate = selectAfterUpdateVec[i];
char sendChar[200] = "";
char sendChar2[200] = "";
char sendChar3[200] = "";
strcpy(sendChar, updateSql.c_str());
strcpy(sendChar2, selectSql.c_str());
strcpy(sendChar3, selectUpdate.c_str());
int result = ado0.ado_QuerySQLNoInputParam(sendChar2);
if (result == 0) {
showError = true;
WriteLog("¹¤ÐòÊôÐÔ²åÈëʧ°Ü£º%s\n", insertSql.c_str());
}
else {
bool resultSql = ado0.execute2(sendChar2, sendChar, result);
result = ado0.ado_QuerySQLNoInputParam(sendChar3);
if (result == 0) {
showError = true;
WriteLog("¹¤ÐòÊôÐÔ¸üÐÂʧ°Ü£º%s\n", updateSql.c_str());
}
}
}*/
}
// ¹¤Ðò¹¤ÒÕÎļþ
void insertGyGxGywj(string xmlUid, string ftp_dir, string username, string pwd, bool& showError, ado ado0, tag_t gy_line, tag_t gy_item, tag_t gy_rev, map<string, CHILD> child_level1, map<string, vector<string>> level1_level2, map<string, CHILD> child_level2) {
WriteLog("¼Ç¼¹¤Ðò¹¤ÒÕÎļþÊý¾Ý¿â\n");
int ifail = 0;
char* type = NULL;
//
string sqlStr = "insert into ";
string updateStr = "update ";
string selectStr = "select * from ";
string selectAfterUpdateStr = "select * from ";
string updateWhere = "";
// ½âÎöxmlÎļþ
// ´´½¨Ò»¸öXML½á¹¹²¢ÔØÈëÎļþÄÚÈÝ
map<string, map<vector<string>, vector<string>>> xmlMap;//ÎïÁÏÀàÐÍ£¬<×Ö¶ÎÃû£¬ÊôÐÔȡֵ>
string tableName = loadXml(xmlUid, xmlMap);
map<vector<string>, vector<string>> parentPropertyMap = xmlMap["¸¸"];//¸¸¼¶
vector<string> parentNameVec;
vector<string> parentValueVec;
map<vector<string>, vector<string>>::iterator rev_it2;
for (rev_it2 = parentPropertyMap.begin(); rev_it2 != parentPropertyMap.end(); rev_it2++) {
parentNameVec = rev_it2->first;
parentValueVec = rev_it2->second;
}
map<vector<string>, vector<string>> childPropertyMap = xmlMap["×Ó"];//×Ó¼¶
vector<string> childNameVec;
vector<string> childValueVec;
map<vector<string>, vector<string>>::iterator rev_it;
for (rev_it = childPropertyMap.begin(); rev_it != childPropertyMap.end(); rev_it++) {
childNameVec = rev_it->first;
childValueVec = rev_it->second;
}
map<vector<string>, vector<string>> childLevel2PropertyMap = xmlMap["Ëï"];//×Ó¼¶µÄ×Ó¼¶
vector<string> childLevel2NameVec;
vector<string> childLevel2ValueVec;
map<vector<string>, vector<string>>::iterator rev_it_level2;
for (rev_it_level2 = childLevel2PropertyMap.begin(); rev_it_level2 != childLevel2PropertyMap.end(); rev_it_level2++) {
childLevel2NameVec = rev_it_level2->first;
childLevel2ValueVec = rev_it_level2->second;
}
vector<string> updateVec;
vector<string> selectVec;
vector<string> insertVec;
vector<string> selectAfterUpdateVec;
sqlStr = sqlStr.append(tableName).append("(");
selectStr = selectStr.append(tableName).append(" ");
selectAfterUpdateStr = selectAfterUpdateStr.append(tableName).append(" ");
string valueStr = " VALUES (";
//»ñÈ¡¸¸ÊôÐÔ
string parentColumnStr = "insert into ";
parentColumnStr = parentColumnStr.append(tableName).append(" (");
string parentValueStr = " values(";
for (int j = 0; j < parentNameVec.size(); j++)
{
string columnName = parentNameVec[j];
parentColumnStr = parentColumnStr.append(columnName);
if (j < parentNameVec.size() - 1) {
parentColumnStr = parentColumnStr.append(",");
}
string propertyName = parentValueVec[j];
string tempValue = " ";
string updateValue = "";
if (strcmp(columnName.c_str(), "SESSIONID") == 0) {
tempValue = propertyName;//¹Ì¶¨Öµ
}
else if (strcmp(columnName.c_str(), "TRANSNO") == 0) {
tempValue = propertyName;//ÒÑ´¦Àí
if (updateWhere.length() == 0) {
updateWhere = updateWhere.append(" where ");
updateWhere = updateWhere.append(columnName).append("='").append(tempValue).append("' and ");
selectStr = selectStr.append(" where ");
selectStr = selectStr.append(columnName).append("='").append(tempValue).append("' and ");
selectAfterUpdateStr = selectAfterUpdateStr.append(" where ");
selectAfterUpdateStr = selectAfterUpdateStr.append(columnName).append("='").append(tempValue).append("' and ");
}
else {
updateWhere = updateWhere.append(columnName).append("='").append(tempValue).append("' and ");
selectStr = selectStr.append(columnName).append("='").append(tempValue).append("' and ");
selectAfterUpdateStr = selectAfterUpdateStr.append(columnName).append("='").append(tempValue).append("' and ");
}
}
else if (strcmp(columnName.c_str(), "TRANSSTATUS") == 0) {
//Ê״δ«µÝ¿ÕÖµ
updateValue = propertyName;
updateStr = updateStr.append(tableName).append(" set ").append(columnName).append("='").append(updateValue).append("' ");
selectAfterUpdateStr = selectAfterUpdateStr.append(columnName).append("='").append(updateValue).append("' and ");
}
else if (strcmp(columnName.c_str(), "PPUID") == 0) {
char* puid = NULL;
ITK__convert_tag_to_uid(gy_rev, &puid);
tempValue = puid;
//selectStr = selectStr.append(columnName).append("='").append(tempValue).append("' and ");
if (updateWhere.length() == 0) {
updateWhere = updateWhere.append(" where ");
updateWhere = updateWhere.append(columnName).append("='").append(puid).append("' and ");
selectStr = selectStr.append(" where ");
selectStr = selectStr.append(columnName).append("='").append(tempValue).append("' and ");
selectAfterUpdateStr = selectAfterUpdateStr.append(" where ");
selectAfterUpdateStr = selectAfterUpdateStr.append(columnName).append("='").append(tempValue).append("' and ");
}
else {
updateWhere = updateWhere.append(columnName).append("='").append(puid).append("' and ");
selectStr = selectStr.append(columnName).append("='").append(puid).append("' and ");
selectAfterUpdateStr = selectAfterUpdateStr.append(columnName).append("='").append(puid).append("' and ");
}
DOFREE(puid);
}
else {
vector<string> propertyVec;
Split(propertyName, ".", propertyVec);
if (propertyVec.size() == 2) {
string propertyPosition = propertyVec[0];
tag_t propertyTag = NULL;
if (strcmp("item", propertyPosition.c_str()) == 0) {
propertyTag = gy_item;
}
else if (strcmp("rev", propertyPosition.c_str()) == 0) {
propertyTag = gy_rev;
}
else if (strcmp("bomline", propertyPosition.c_str()) == 0) {
propertyTag = gy_line;
}
string propertyName = propertyVec[1];
char* propertyValue = NULL;
if (strcmp("puid", propertyName.c_str()) == 0) {
ITK__convert_tag_to_uid(propertyTag, &propertyValue);
}
else {
ITKCALL(ifail = AOM_UIF_ask_value(propertyTag, propertyName.c_str(), &propertyValue));
}
EMH_clear_errors();
if (ifail == 0) {
tempValue = propertyValue;
}
else {
showError = true;
WriteLog("ÊôÐÔÒì³££º%s\n", propertyName.c_str());
tempValue = " ";
}
DOFREE(propertyValue);
}
}
parentValueStr = parentValueStr.append("'").append(tempValue).append("'");
if (j < parentNameVec.size() - 1) {
parentValueStr = parentValueStr.append(",");
}
}
// »ñÈ¡×Ó¶ÔÏóµÄÊôÐÔ
map<string, CHILD>::iterator child_it;
for (child_it = child_level1.begin(); child_it != child_level1.end(); child_it++) {
bool isContinue = false;
string childColumnStr = "";
string childSelectStr = "";
string childUpdateSelectStr = "";
string childUpdateWhere = "";
string childValueStr = "";
tag_t line = child_it->second.line;
tag_t item = child_it->second.item;
tag_t rev = child_it->second.rev;
string clone_id = child_it->second.clone_id;
vector<string> level2_vec = level1_level2[clone_id];
int level2_cnt = level2_vec.size();
ITKCALL(ifail = AOM_ask_value_string(rev, "object_type", &type));
for (int j = 0; j < childNameVec.size(); j++)
{
string columnName = childNameVec[j];
string propertyName = childValueVec[j];
string tempValue = " ";
if (strcmp(columnName.c_str(), "_FILTERTYPE") == 0) {
if (strcmp(propertyName.c_str(), "ALL") == 0) {
continue;
}
else {
vector<string>typeVec;
Split(propertyName, ";", typeVec);
if (hasElement(typeVec, type) == 0) {
continue;
}
else {
isContinue = true;
break;
}
}
}
else if (strcmp(columnName.c_str(), "CPUID") == 0) {
char* puid = NULL;
ITK__convert_tag_to_uid(rev, &puid);
tempValue = puid;
childSelectStr = childSelectStr.append(columnName).append("='").append(tempValue).append("' and ");
childUpdateSelectStr = childUpdateSelectStr.append(columnName).append("='").append(tempValue).append("' and ");
childUpdateWhere = childUpdateWhere.append(columnName).append("='").append(tempValue).append("' and ");
DOFREE(puid);
}
else {
vector<string> propertyVec;
Split(propertyName, ".", propertyVec);
if (propertyVec.size() == 2) {
string propertyPosition = propertyVec[0];
tag_t propertyTag = NULL;
if (strcmp("item", propertyPosition.c_str()) == 0) {
propertyTag = item;
}
else if (strcmp("rev", propertyPosition.c_str()) == 0) {
propertyTag = rev;
}
else if (strcmp("bomline", propertyPosition.c_str()) == 0) {
propertyTag = line;
}
string propertyName = propertyVec[1];
char* propertyValue = NULL;
if (strcmp("puid", propertyName.c_str()) == 0) {
ITK__convert_tag_to_uid(propertyTag, &propertyValue);
}
else {
ITKCALL(ifail = AOM_UIF_ask_value(propertyTag, propertyName.c_str(), &propertyValue));
}
EMH_clear_errors();
if (ifail == 0) {
tempValue = propertyValue;
}
else {
showError = true;
WriteLog("ÊôÐÔÒì³££º%s\n", propertyName.c_str());
tempValue = " ";
}
DOFREE(propertyValue);
}
else {
tempValue = " ";
}
}
childColumnStr = childColumnStr.append(columnName);
if (j < childNameVec.size() - 1) {
childColumnStr = childColumnStr.append(",");
}
childValueStr = childValueStr.append("'").append(tempValue);
if (j < childNameVec.size() - 1) {
childValueStr = childValueStr.append("',");
}
else {
childValueStr = childValueStr.append("'");
}
}
if (isContinue) {
continue;
}
if (level2_cnt > 0) {
char* zy_type = NULL;
for (int k = 0; k < level2_cnt; k++) {
bool isZyContinue = false;
CHILD level2_child = child_level2[level2_vec[k]];
string childLevel2ColumnStr = "";
string childLevel2SelectStr = "";
string childLevel2UpdateSelectStr = "";
string childLevel2UpdateWhere = "";
string childLevel2ValueStr = "";
tag_t zy_line = level2_child.line;
tag_t zy_item = level2_child.item;
tag_t zy_rev = level2_child.rev;
string zy_clone_id = level2_child.clone_id;
ITKCALL(ifail = AOM_ask_value_string(zy_rev, "object_type", &zy_type));
for (int z = 0; z < childLevel2NameVec.size(); z++)
{
string columnName = childLevel2NameVec[z];
string propertyName = childLevel2ValueVec[z];
string tempValue = " ";
if (strcmp(columnName.c_str(), "_FILTERTYPE") == 0) {
if (strcmp(propertyName.c_str(), "ALL") == 0) {
continue;
}
else {
vector<string>typeVec;
Split(propertyName, ";", typeVec);
if (hasElement(typeVec, zy_type) == 0) {
continue;
}
else {
isZyContinue = true;
break;
}
}
}
else if (strcmp(columnName.c_str(), "SPUID") == 0) {
char* spuid = NULL;
ITK__convert_tag_to_uid(zy_rev, &spuid);
tempValue = spuid;
childLevel2SelectStr = childLevel2SelectStr.append(columnName).append("='").append(tempValue).append("' ");
childLevel2UpdateSelectStr = childLevel2UpdateSelectStr.append(columnName).append("='").append(tempValue).append("' ");
childLevel2UpdateWhere = childLevel2UpdateWhere.append(columnName).append("='").append(tempValue).append("'");
DOFREE(spuid);
}
else if (strcmp(columnName.c_str(), "FILE_PATH") == 0) {
// Êý¾Ý¼¯Í¨¹ýftp´«µÝ
int related_cnt = 0;
char* type_name = NULL,
* item_id = NULL,
* rev_id = NULL;
GRM_relation_t* related_objects = NULL;
ITKCALL(ifail = AOM_ask_value_string(zy_rev, "item_id", &item_id));
ITKCALL(ifail = AOM_ask_value_string(zy_rev, "item_revision_id", &rev_id));
ITKCALL(AOM_ask_value_string(zy_rev, "object_type", &type_name));
//ITKCALL(AOM_UIF_ask_value(zy_rev, "object_type", &type_name));
ITKCALL(GRM_list_all_related_objects(zy_rev, &related_cnt, &related_objects));
string idAndRev = string(item_id) + "-" + string(rev_id);
for (int i = 0; i < related_cnt; i++)
{
// ÅжÏÊÇ·ñΪÊý¾Ý¼¯
if (checkIsTypeOrSubtype(related_objects[i].secondary, "Dataset") == 1)
{
string path = downloadDataset(related_objects[i].secondary, ftp_dir, type_name, idAndRev, username, pwd);
WriteLog("Îļþ·¾¶£º%s\n", path.c_str());
if (tempValue.length() > 0) {
tempValue = tempValue.append(";");
}
tempValue = tempValue.append(path);
}
}
DOFREE(type_name);
DOFREE(item_id);
DOFREE(rev_id);
}
else {
vector<string> propertyVec;
Split(propertyName, ".", propertyVec);
if (propertyVec.size() == 2) {
string propertyPosition = propertyVec[0];
tag_t propertyTag = NULL;
if (strcmp("item", propertyPosition.c_str()) == 0) {
propertyTag = zy_item;
}
else if (strcmp("rev", propertyPosition.c_str()) == 0) {
propertyTag = zy_rev;
}
else if (strcmp("bomline", propertyPosition.c_str()) == 0) {
propertyTag = zy_line;
}
string propertyName = propertyVec[1];
char* propertyValue = NULL;
if (strcmp("puid", propertyName.c_str()) == 0) {
ITK__convert_tag_to_uid(propertyTag, &propertyValue);
}
else {
ITKCALL(ifail = AOM_UIF_ask_value(propertyTag, propertyName.c_str(), &propertyValue));
}
EMH_clear_errors();
if (ifail == 0) {
tempValue = propertyValue;
}
else {
showError = true;
WriteLog("ÊôÐÔÒì³££º%s\n", propertyName.c_str());
tempValue = " ";
}
DOFREE(propertyValue);
}
else {
tempValue = " ";
}
}
childLevel2ColumnStr = childLevel2ColumnStr.append(columnName);
if (z < childLevel2NameVec.size() - 1) {
childLevel2ColumnStr = childLevel2ColumnStr.append(",");
}
childLevel2ValueStr = childLevel2ValueStr.append("'").append(tempValue);
if (z < childLevel2NameVec.size() - 1) {
childLevel2ValueStr = childLevel2ValueStr.append("',");
}
else {
childLevel2ValueStr = childLevel2ValueStr.append("'");
}
}
if (isZyContinue) {
continue;
}
string insertSql = "";
string selectSql = "";
string updateSelectSql = "";
string updateSql = "";
if (parentColumnStr.size() > 0 && childColumnStr.size() > 0 && childLevel2ColumnStr.size() > 0) {
insertSql = insertSql.append(parentColumnStr).append(",").append(childColumnStr).append(",").append(childLevel2ColumnStr).append(")").append(parentValueStr).append(",").append(childValueStr).append(",").append(childLevel2ValueStr).append(")");
}
selectSql = selectSql.append(selectStr).append(childSelectStr).append(childLevel2SelectStr);
updateSelectSql = updateSelectSql.append(selectAfterUpdateStr).append(childUpdateSelectStr).append(childLevel2UpdateSelectStr);
updateSql = updateSql.append(updateStr).append(updateWhere).append(childUpdateWhere).append(childLevel2UpdateWhere);
//updateStr = updateStr.append(updateWhere);
insertSql = Utf8ToGbk(insertSql.c_str());
updateSql = Utf8ToGbk(updateSql.c_str());
selectSql = Utf8ToGbk(selectSql.c_str());
updateSelectSql = Utf8ToGbk(updateSelectSql.c_str());
WriteLog("¹¤ÒÕÎļþ²åÈëÓï¾ä£º%s\n", insertSql.c_str());
//WriteLog("¹¤ÒÕÎļþ¸üÐÂÓï¾ä£º%s\n", updateSql.c_str());
WriteLog("¹¤ÒÕÎļþ²éѯÓï¾ä£º%s\n", selectSql.c_str());
//WriteLog("¹¤ÒÕÎļþ¸üкó²éѯÓï¾ä£º%s\n", updateSelectSql.c_str());
insertVec.push_back(insertSql);
updateVec.push_back(updateSql);
selectVec.push_back(selectSql);
selectAfterUpdateVec.push_back(updateSelectSql);
char sendChar[400] = "";
strcpy(sendChar, insertSql.c_str());
char sendChar2[400] = "";
strcpy(sendChar2, selectSql.c_str());
int result = ado0.ado_QuerySQLNoInputParam(sendChar2);
bool resultSql = ado0.executeInsert(sendChar2, sendChar, result);
}
DOFREE(zy_type);
}
}
DOFREE(type);
//¸üÐÂÊý¾Ý¿â
/*for (int i = 0; i < updateVec.size(); i++) {
string updateSql = updateVec[i];
string selectSql = selectVec[i];
string insertSql = insertVec[i];
string selectUpdate = selectAfterUpdateVec[i];
char sendChar[400] = "";
char sendChar2[400] = "";
char sendChar3[400] = "";
strcpy(sendChar, updateSql.c_str());
strcpy(sendChar2, selectSql.c_str());
strcpy(sendChar3, selectUpdate.c_str());
int result = ado0.ado_QuerySQLNoInputParam(sendChar2);
if (result == 0) {
showError = true;
WriteLog("¹¤ÒÕÎļþ²åÈëʧ°Ü£º%s\n", insertSql.c_str());
}
else {
bool resultSql = ado0.execute2(sendChar2, sendChar, result);
result = ado0.ado_QuerySQLNoInputParam(sendChar3);
if (result == 0) {
showError = true;
WriteLog("¹¤ÒÕÎļþ¸üÐÂʧ°Ü£º%s\n", updateSql.c_str());
}
}
}*/
}
// ¹¤ÒÕ×ÊÔ´
void insertGyGxGyzy(string xmlUid, bool& showError, ado ado0, tag_t gy_line, tag_t gy_item, tag_t gy_rev, map<string, CHILD> child_level1, map<string, vector<string>> level1_level2, map<string, CHILD> child_level2) {
WriteLog("¼Ç¼¹¤ÒÕ×ÊÔ´Êý¾Ý¿â\n");
int ifail = 0;
char* type = NULL;
//
string sqlStr = "insert into ";
string updateStr = "update ";
string selectStr = "select * from ";
string selectAfterUpdateStr = "select * from ";
string updateWhere = "";
// ½âÎöxmlÎļþ
// ´´½¨Ò»¸öXML½á¹¹²¢ÔØÈëÎļþÄÚÈÝ
map<string, map<vector<string>, vector<string>>> xmlMap;//ÎïÁÏÀàÐÍ£¬<×Ö¶ÎÃû£¬ÊôÐÔȡֵ>
string tableName = loadXml(xmlUid, xmlMap);
map<vector<string>, vector<string>> parentPropertyMap = xmlMap["¸¸"];//¸¸¼¶
vector<string> parentNameVec;
vector<string> parentValueVec;
map<vector<string>, vector<string>>::iterator rev_it2;
for (rev_it2 = parentPropertyMap.begin(); rev_it2 != parentPropertyMap.end(); rev_it2++) {
parentNameVec = rev_it2->first;
parentValueVec = rev_it2->second;
}
map<vector<string>, vector<string>> childPropertyMap = xmlMap["×Ó"];//×Ó¼¶
vector<string> childNameVec;
vector<string> childValueVec;
map<vector<string>, vector<string>>::iterator rev_it;
for (rev_it = childPropertyMap.begin(); rev_it != childPropertyMap.end(); rev_it++) {
childNameVec = rev_it->first;
childValueVec = rev_it->second;
}
map<vector<string>, vector<string>> childLevel2PropertyMap = xmlMap["Ëï"];//×Ó¼¶µÄ×Ó¼¶
vector<string> childLevel2NameVec;
vector<string> childLevel2ValueVec;
map<vector<string>, vector<string>>::iterator rev_it_level2;
for (rev_it_level2 = childLevel2PropertyMap.begin(); rev_it_level2 != childLevel2PropertyMap.end(); rev_it_level2++) {
childLevel2NameVec = rev_it_level2->first;
childLevel2ValueVec = rev_it_level2->second;
}
vector<string> updateVec;
vector<string> selectVec;
vector<string> insertVec;
vector<string> selectAfterUpdateVec;
sqlStr = sqlStr.append(tableName).append("(");
selectStr = selectStr.append(tableName).append(" ");
selectAfterUpdateStr = selectAfterUpdateStr.append(tableName).append(" ");
string valueStr = " VALUES (";
//»ñÈ¡¸¸ÊôÐÔ
string parentColumnStr = "insert into ";
parentColumnStr = parentColumnStr.append(tableName).append(" (");
string parentValueStr = " values(";
for (int j = 0; j < parentNameVec.size(); j++)
{
string columnName = parentNameVec[j];
parentColumnStr = parentColumnStr.append(columnName);
if (j < parentNameVec.size() - 1) {
parentColumnStr = parentColumnStr.append(",");
}
string propertyName = parentValueVec[j];
string tempValue = " ";
string updateValue = "";
if (strcmp(columnName.c_str(), "SESSIONID") == 0) {
tempValue = propertyName;//¹Ì¶¨Öµ
}
else if (strcmp(columnName.c_str(), "TRANSNO") == 0) {
tempValue = propertyName;//ÒÑ´¦Àí
if (updateWhere.length() == 0) {
updateWhere = updateWhere.append(" where ");
updateWhere = updateWhere.append(columnName).append("='").append(tempValue).append("' and ");
selectStr = selectStr.append(" where ");
selectStr = selectStr.append(columnName).append("='").append(tempValue).append("' and ");
selectAfterUpdateStr = selectAfterUpdateStr.append(" where ");
selectAfterUpdateStr = selectAfterUpdateStr.append(columnName).append("='").append(tempValue).append("' and ");
}
else {
updateWhere = updateWhere.append(columnName).append("='").append(tempValue).append("' and ");
selectStr = selectStr.append(columnName).append("='").append(tempValue).append("' and ");
selectAfterUpdateStr = selectAfterUpdateStr.append(columnName).append("='").append(tempValue).append("' and ");
}
}
else if (strcmp(columnName.c_str(), "TRANSSTATUS") == 0) {
//Ê״δ«µÝ¿ÕÖµ
updateValue = propertyName;
updateStr = updateStr.append(tableName).append(" set ").append(columnName).append("='").append(updateValue).append("' ");
selectAfterUpdateStr = selectAfterUpdateStr.append(columnName).append("='").append(updateValue).append("' and ");
}
else if (strcmp(columnName.c_str(), "PPUID") == 0) {
char* puid = NULL;
ITK__convert_tag_to_uid(gy_rev, &puid);
tempValue = puid;
//selectStr = selectStr.append(columnName).append("='").append(tempValue).append("' and ");
if (updateWhere.length() == 0) {
updateWhere = updateWhere.append(" where ");
updateWhere = updateWhere.append(columnName).append("='").append(puid).append("' and ");
selectStr = selectStr.append(" where ");
selectStr = selectStr.append(columnName).append("='").append(tempValue).append("' and ");
selectAfterUpdateStr = selectAfterUpdateStr.append(" where ");
selectAfterUpdateStr = selectAfterUpdateStr.append(columnName).append("='").append(tempValue).append("' and ");
}
else {
updateWhere = updateWhere.append(columnName).append("='").append(puid).append("' and ");
selectStr = selectStr.append(columnName).append("='").append(puid).append("' and ");
selectAfterUpdateStr = selectAfterUpdateStr.append(columnName).append("='").append(puid).append("' and ");
}
DOFREE(puid);
}
else {
vector<string> propertyVec;
Split(propertyName, ".", propertyVec);
if (propertyVec.size() == 2) {
string propertyPosition = propertyVec[0];
tag_t propertyTag = NULL;
if (strcmp("item", propertyPosition.c_str()) == 0) {
propertyTag = gy_item;
}
else if (strcmp("rev", propertyPosition.c_str()) == 0) {
propertyTag = gy_rev;
}
else if (strcmp("bomline", propertyPosition.c_str()) == 0) {
propertyTag = gy_line;
}
string propertyName = propertyVec[1];
char* propertyValue = NULL;
if (strcmp("puid", propertyName.c_str()) == 0) {
ITK__convert_tag_to_uid(propertyTag, &propertyValue);
}
else {
ITKCALL(ifail = AOM_UIF_ask_value(propertyTag, propertyName.c_str(), &propertyValue));
}
EMH_clear_errors();
if (ifail == 0) {
tempValue = propertyValue;
}
else {
showError = true;
WriteLog("ÊôÐÔÒì³££º%s\n", propertyName.c_str());
tempValue = " ";
}
DOFREE(propertyValue);
}
}
parentValueStr = parentValueStr.append("'").append(tempValue).append("'");
if (j < parentNameVec.size() - 1) {
parentValueStr = parentValueStr.append(",");
}
}
// »ñÈ¡×Ó¶ÔÏóµÄÊôÐÔ
map<string, CHILD>::iterator child_it;
for (child_it = child_level1.begin(); child_it != child_level1.end(); child_it++) {
bool isContinue = false;
string childColumnStr = "";
string childSelectStr = "";
string childUpdateSelectStr = "";
string childUpdateWhere = "";
string childValueStr = "";
tag_t line = child_it->second.line;
tag_t item = child_it->second.item;
tag_t rev = child_it->second.rev;
string clone_id = child_it->second.clone_id;
vector<string> level2_vec = level1_level2[clone_id];
int level2_cnt = level2_vec.size();
ITKCALL(ifail = AOM_ask_value_string(rev, "object_type", &type));
for (int j = 0; j < childNameVec.size(); j++)
{
string columnName = childNameVec[j];
string propertyName = childValueVec[j];
string tempValue = " ";
if (strcmp(columnName.c_str(), "_FILTERTYPE") == 0) {
if (strcmp(propertyName.c_str(), "ALL") == 0) {
continue;
}
else {
vector<string>typeVec;
Split(propertyName, ";", typeVec);
if (hasElement(typeVec, type) == 0) {
continue;
}
else {
isContinue = true;
break;
}
}
}
else if (strcmp(columnName.c_str(), "CPUID") == 0) {
char* puid = NULL;
ITK__convert_tag_to_uid(rev, &puid);
tempValue = puid;
childSelectStr = childSelectStr.append(columnName).append("='").append(tempValue).append("' and ");
childUpdateSelectStr = childUpdateSelectStr.append(columnName).append("='").append(tempValue).append("' and ");
childUpdateWhere = childUpdateWhere.append(columnName).append("='").append(tempValue).append("' and ");
DOFREE(puid);
}
else {
vector<string> propertyVec;
Split(propertyName, ".", propertyVec);
if (propertyVec.size() == 2) {
string propertyPosition = propertyVec[0];
tag_t propertyTag = NULL;
if (strcmp("item", propertyPosition.c_str()) == 0) {
propertyTag = item;
}
else if (strcmp("rev", propertyPosition.c_str()) == 0) {
propertyTag = rev;
}
else if (strcmp("bomline", propertyPosition.c_str()) == 0) {
propertyTag = line;
}
string propertyName = propertyVec[1];
char* propertyValue = NULL;
if (strcmp("puid", propertyName.c_str()) == 0) {
ITK__convert_tag_to_uid(propertyTag, &propertyValue);
}
else {
ITKCALL(ifail = AOM_UIF_ask_value(propertyTag, propertyName.c_str(), &propertyValue));
}
EMH_clear_errors();
if (ifail == 0) {
tempValue = propertyValue;
}
else {
showError = true;
WriteLog("ÊôÐÔÒì³££º%s\n", propertyName.c_str());
tempValue = " ";
}
DOFREE(propertyValue);
}
else {
tempValue = " ";
}
}
childColumnStr = childColumnStr.append(columnName);
if (j < childNameVec.size() - 1) {
childColumnStr = childColumnStr.append(",");
}
childValueStr = childValueStr.append("'").append(tempValue);
if (j < childNameVec.size() - 1) {
childValueStr = childValueStr.append("',");
}
else {
childValueStr = childValueStr.append("'");
}
}
if (isContinue) {
continue;
}
if (level2_cnt > 0) {
char* zy_type = NULL;
for (int k = 0; k < level2_cnt; k++) {
bool isZyContinue = false;
CHILD level2_child = child_level2[level2_vec[k]];
string childLevel2ColumnStr = "";
string childLevel2SelectStr = "";
string childLevel2UpdateSelectStr = "";
string childLevel2UpdateWhere = "";
string childLevel2ValueStr = "";
tag_t zy_line = level2_child.line;
tag_t zy_item = level2_child.item;
tag_t zy_rev = level2_child.rev;
string zy_clone_id = level2_child.clone_id;
ITKCALL(ifail = AOM_ask_value_string(zy_rev, "object_type", &zy_type));
for (int z = 0; z < childLevel2NameVec.size(); z++)
{
string columnName = childLevel2NameVec[z];
string propertyName = childLevel2ValueVec[z];
string tempValue = " ";
if (strcmp(columnName.c_str(), "_FILTERTYPE") == 0) {
if (strcmp(propertyName.c_str(), "ALL") == 0) {
continue;
}
else {
vector<string>typeVec;
Split(propertyName, ";", typeVec);
if (hasElement(typeVec, zy_type) == 0) {
continue;
}
else {
isZyContinue = true;
break;
}
}
}
else if (strcmp(columnName.c_str(), "SPUID") == 0) {
char* spuid = NULL;
ITK__convert_tag_to_uid(rev, &spuid);
tempValue = spuid;
childLevel2SelectStr = childLevel2SelectStr.append(columnName).append("='").append(tempValue).append("' ");
childLevel2UpdateSelectStr = childLevel2UpdateSelectStr.append(columnName).append("='").append(tempValue).append("' ");
childLevel2UpdateWhere = childLevel2UpdateWhere.append(columnName).append("='").append(tempValue).append("'");
DOFREE(spuid);
}
else {
vector<string> propertyVec;
Split(propertyName, ".", propertyVec);
if (propertyVec.size() == 2) {
string propertyPosition = propertyVec[0];
tag_t propertyTag = NULL;
if (strcmp("item", propertyPosition.c_str()) == 0) {
propertyTag = zy_item;
}
else if (strcmp("rev", propertyPosition.c_str()) == 0) {
propertyTag = zy_rev;
}
else if (strcmp("bomline", propertyPosition.c_str()) == 0) {
propertyTag = zy_line;
}
string propertyName = propertyVec[1];
char* propertyValue = NULL;
if (strcmp("puid", propertyName.c_str()) == 0) {
ITK__convert_tag_to_uid(propertyTag, &propertyValue);
}
else {
ITKCALL(ifail = AOM_UIF_ask_value(propertyTag, propertyName.c_str(), &propertyValue));
}
EMH_clear_errors();
if (ifail == 0) {
tempValue = propertyValue;
}
else {
showError = true;
WriteLog("ÊôÐÔÒì³££º%s\n", propertyName.c_str());
tempValue = " ";
}
DOFREE(propertyValue);
}
else {
tempValue = " ";
}
}
childLevel2ColumnStr = childLevel2ColumnStr.append(columnName);
if (z < childLevel2NameVec.size() - 1) {
childLevel2ColumnStr = childLevel2ColumnStr.append(",");
}
childLevel2ValueStr = childLevel2ValueStr.append("'").append(tempValue);
if (z < childLevel2NameVec.size() - 1) {
childLevel2ValueStr = childLevel2ValueStr.append("',");
}
else {
childLevel2ValueStr = childLevel2ValueStr.append("'");
}
}
if (isZyContinue) {
continue;
}
string insertSql = "";
string selectSql = "";
string updateSelectSql = "";
string updateSql = "";
if (parentColumnStr.size() > 0 && childColumnStr.size() > 0 && childLevel2ColumnStr.size() > 0) {
insertSql = insertSql.append(parentColumnStr).append(",").append(childColumnStr).append(",").append(childLevel2ColumnStr).append(")").append(parentValueStr).append(",").append(childValueStr).append(",").append(childLevel2ValueStr).append(")");
}
selectSql = selectSql.append(selectStr).append(childSelectStr).append(childLevel2SelectStr);
updateSelectSql = updateSelectSql.append(selectAfterUpdateStr).append(childUpdateSelectStr).append(childLevel2UpdateSelectStr);
updateSql = updateSql.append(updateStr).append(updateWhere).append(childUpdateWhere).append(childLevel2UpdateWhere);
//updateStr = updateStr.append(updateWhere);
insertSql = Utf8ToGbk(insertSql.c_str());
updateSql = Utf8ToGbk(updateSql.c_str());
selectSql = Utf8ToGbk(selectSql.c_str());
updateSelectSql = Utf8ToGbk(updateSelectSql.c_str());
WriteLog("²åÈëÓï¾ä£º%s\n", insertSql.c_str());
//WriteLog("¸üÐÂÓï¾ä£º%s\n", updateSql.c_str());
WriteLog("²éѯÓï¾ä£º%s\n", selectSql.c_str());
//WriteLog("¸üкó²éѯÓï¾ä£º%s\n", updateSelectSql.c_str());
insertVec.push_back(insertSql);
updateVec.push_back(updateSql);
selectVec.push_back(selectSql);
selectAfterUpdateVec.push_back(updateSelectSql);
char sendChar[400] = "";
strcpy(sendChar, insertSql.c_str());
char sendChar2[400] = "";
strcpy(sendChar2, selectSql.c_str());
int result = ado0.ado_QuerySQLNoInputParam(sendChar2);
bool resultSql = ado0.executeInsert(sendChar2, sendChar, result);
}
DOFREE(zy_type);
}
}
DOFREE(type);
//¸üÐÂÊý¾Ý¿â
/*for (int i = 0; i < updateVec.size(); i++) {
string updateSql = updateVec[i];
string selectSql = selectVec[i];
string insertSql = insertVec[i];
string selectUpdate = selectAfterUpdateVec[i];
char sendChar[400] = "";
char sendChar2[400] = "";
char sendChar3[400] = "";
strcpy(sendChar, updateSql.c_str());
strcpy(sendChar2, selectSql.c_str());
strcpy(sendChar3, selectUpdate.c_str());
int result = ado0.ado_QuerySQLNoInputParam(sendChar2);
if (result == 0) {
showError = true;
WriteLog("²åÈëʧ°Ü£º%s\n", insertSql.c_str());
}
else {
bool resultSql = ado0.execute2(sendChar2, sendChar, result);
result = ado0.ado_QuerySQLNoInputParam(sendChar3);
if (result == 0) {
showError = true;
WriteLog("¸üÐÂʧ°Ü£º%s\n", updateSql.c_str());
}
}
}*/
}
// ¹¤²½×ÊÔ´
void insertGbzy(string xmlUid, bool& showError, ado ado0, map<string, CHILD> child_level1, map<string, string> gx_gb_key, map<string, vector<CHILD>> gx_gbs_bom, map<string, vector<CHILD>> gx_gb_zy) {
WriteLog("¼Ç¼¹¤²½×ÊÔ´Êý¾Ý¿â\n");
int ifail = 0;
vector<string> updateVec;
vector<string> selectVec;
vector<string> insertVec;
vector<string> selectAfterUpdateVec;
// ½âÎöxmlÎļþ
// ´´½¨Ò»¸öXML½á¹¹²¢ÔØÈëÎļþÄÚÈÝ
map<string, map<vector<string>, vector<string>>> xmlMap;//ÎïÁÏÀàÐÍ£¬<×Ö¶ÎÃû£¬ÊôÐÔȡֵ>
string tableName = loadXml(xmlUid, xmlMap);
map<vector<string>, vector<string>> parentPropertyMap = xmlMap["¸¸"];//¸¸¼¶
vector<string> parentNameVec;
vector<string> parentValueVec;
map<vector<string>, vector<string>>::iterator rev_it2;
for (rev_it2 = parentPropertyMap.begin(); rev_it2 != parentPropertyMap.end(); rev_it2++) {
parentNameVec = rev_it2->first;
parentValueVec = rev_it2->second;
}
map<vector<string>, vector<string>> childPropertyMap = xmlMap["×Ó"];//×Ó¼¶
vector<string> childNameVec;
vector<string> childValueVec;
map<vector<string>, vector<string>>::iterator rev_it;
for (rev_it = childPropertyMap.begin(); rev_it != childPropertyMap.end(); rev_it++) {
childNameVec = rev_it->first;
childValueVec = rev_it->second;
}
map<string, CHILD>::iterator child_it;
for (child_it = child_level1.begin(); child_it != child_level1.end(); child_it++) {
char* gb_type = NULL;
string gx_clone_id = child_it->first;
vector<CHILD> gbs = gx_gbs_bom[gx_clone_id];
int gb_count = gbs.size();
if (gb_count > 0) {
for (int x = 0; x < gb_count; x++) {
bool isGbContinue = false;
tag_t gb_line = gbs[x].line;
tag_t gb_item = gbs[x].item;
char* zy_type = NULL;
string sqlStr = "insert into ";
string updateStr = "update ";
string selectStr = "select * from ";
string selectAfterUpdateStr = "select * from ";
string updateWhere = "";
string gb_puid = "";
ITKCALL(ifail = AOM_ask_value_string(gb_item, "object_type", &gb_type));
sqlStr = sqlStr.append(tableName).append("(");
selectStr = selectStr.append(tableName).append(" ");
selectAfterUpdateStr = selectAfterUpdateStr.append(tableName).append(" ");
string valueStr = " VALUES (";
//»ñÈ¡¸¸ÊôÐÔ
string parentColumnStr = "insert into ";
parentColumnStr = parentColumnStr.append(tableName).append(" (");
string parentValueStr = " values(";
for (int j = 0; j < parentNameVec.size(); j++)
{
string columnName = parentNameVec[j];
parentColumnStr = parentColumnStr.append(columnName);
if (j < parentNameVec.size() - 1) {
parentColumnStr = parentColumnStr.append(",");
}
string propertyName = parentValueVec[j];
string tempValue = " ";
string updateValue = "";
if (strcmp(columnName.c_str(), "_FILTERTYPE") == 0) {
if (strcmp(propertyName.c_str(), "ALL") == 0) {
continue;
}
else {
vector<string>typeVec;
Split(propertyName, ";", typeVec);
if (hasElement(typeVec, gb_type) == 0) {
continue;
}
else {
isGbContinue = true;
break;
}
}
}
else if (strcmp(columnName.c_str(), "SESSIONID") == 0) {
tempValue = propertyName;//¹Ì¶¨Öµ
}
else if (strcmp(columnName.c_str(), "TRANSNO") == 0) {
tempValue = propertyName;//ÒÑ´¦Àí
if (updateWhere.length() == 0) {
updateWhere = updateWhere.append(" where ");
updateWhere = updateWhere.append(columnName).append("='").append(tempValue).append("' and ");
selectStr = selectStr.append(" where ");
selectStr = selectStr.append(columnName).append("='").append(tempValue).append("' and ");
selectAfterUpdateStr = selectAfterUpdateStr.append(" where ");
selectAfterUpdateStr = selectAfterUpdateStr.append(columnName).append("='").append(tempValue).append("' and ");
}
else {
updateWhere = updateWhere.append(columnName).append("='").append(tempValue).append("' and ");
selectStr = selectStr.append(columnName).append("='").append(tempValue).append("' and ");
selectAfterUpdateStr = selectAfterUpdateStr.append(columnName).append("='").append(tempValue).append("' and ");
}
}
else if (strcmp(columnName.c_str(), "TRANSSTATUS") == 0) {
//Ê״δ«µÝ¿ÕÖµ
updateValue = propertyName;
updateStr = updateStr.append(tableName).append(" set ").append(columnName).append("='").append(updateValue).append("' ");
selectAfterUpdateStr = selectAfterUpdateStr.append(columnName).append("='").append(updateValue).append("' and ");
}
else if (strcmp(columnName.c_str(), "PPUID") == 0) {
char* puid = NULL;
ITK__convert_tag_to_uid(gb_item, &puid);
gb_puid = string(puid);
tempValue = puid;
//selectStr = selectStr.append(columnName).append("='").append(tempValue).append("' and ");
if (updateWhere.length() == 0) {
updateWhere = updateWhere.append(" where ");
updateWhere = updateWhere.append(columnName).append("='").append(puid).append("' and ");
selectStr = selectStr.append(" where ");
selectStr = selectStr.append(columnName).append("='").append(tempValue).append("' and ");
selectAfterUpdateStr = selectAfterUpdateStr.append(" where ");
selectAfterUpdateStr = selectAfterUpdateStr.append(columnName).append("='").append(tempValue).append("' and ");
}
else {
updateWhere = updateWhere.append(columnName).append("='").append(puid).append("' and ");
selectStr = selectStr.append(columnName).append("='").append(puid).append("' and ");
selectAfterUpdateStr = selectAfterUpdateStr.append(columnName).append("='").append(puid).append("' and ");
}
DOFREE(puid);
}
else {
vector<string> propertyVec;
Split(propertyName, ".", propertyVec);
if (propertyVec.size() == 2) {
string propertyPosition = propertyVec[0];
tag_t propertyTag = NULL;
if (strcmp("item", propertyPosition.c_str()) == 0) {
propertyTag = gb_item;
}
else if (strcmp("bomline", propertyPosition.c_str()) == 0) {
propertyTag = gb_line;
}
string propertyName = propertyVec[1];
char* propertyValue = NULL;
if (strcmp("puid", propertyName.c_str()) == 0) {
ITK__convert_tag_to_uid(propertyTag, &propertyValue);
}
else {
ITKCALL(ifail = AOM_UIF_ask_value(propertyTag, propertyName.c_str(), &propertyValue));
}
EMH_clear_errors();
if (ifail == 0) {
tempValue = propertyValue;
}
else {
showError = true;
WriteLog("ÊôÐÔÒì³££º%s\n", propertyName.c_str());
tempValue = " ";
}
DOFREE(propertyValue);
}
}
parentValueStr = parentValueStr.append("'").append(tempValue).append("'");
if (j < parentNameVec.size() - 1) {
parentValueStr = parentValueStr.append(",");
}
}
if (isGbContinue) {
continue;
}
string key = gx_clone_id + gb_puid;
string other_key = gx_gb_key[key];
vector<CHILD> gbzys = gx_gb_zy[key];
int gbzy_count = gbzys.size();
if (gbzy_count > 0) {
for (int y = 0; y < gbzy_count; y++) {
bool isContinue = false;
tag_t gbzy_rev = gbzys[y].rev;
tag_t gbzy_item = gbzys[y].item;
tag_t gbzy_line = gbzys[y].line;
string childColumnStr = "";
string childSelectStr = "";
string childUpdateSelectStr = "";
string childUpdateWhere = "";
string childValueStr = "";
ITKCALL(ifail = AOM_ask_value_string(gb_item, "object_type", &zy_type));
for (int j = 0; j < childNameVec.size(); j++)
{
string columnName = childNameVec[j];
string propertyName = childValueVec[j];
string tempValue = " ";
if (strcmp(columnName.c_str(), "_FILTERTYPE") == 0) {
if (strcmp(propertyName.c_str(), "ALL") == 0) {
continue;
}
else {
vector<string>typeVec;
Split(propertyName, ";", typeVec);
if (hasElement(typeVec, zy_type) == 0) {
continue;
}
else {
isContinue = true;
break;
}
}
}
else if (strcmp(columnName.c_str(), "CPUID") == 0) {
char* puid = NULL;
ITK__convert_tag_to_uid(gbzy_rev, &puid);
tempValue = puid;
childSelectStr = childSelectStr.append(columnName).append("='").append(tempValue).append("' ");
childUpdateSelectStr = childUpdateSelectStr.append(columnName).append("='").append(tempValue).append("' ");
childUpdateWhere = childUpdateWhere.append(columnName).append("='").append(tempValue).append("'");
DOFREE(puid);
}
else if (strcmp(columnName.c_str(), "BP_BASIC_PROCESS_ID") == 0) {
tempValue = other_key;
}
else {
vector<string> propertyVec;
Split(propertyName, ".", propertyVec);
if (propertyVec.size() == 2) {
string propertyPosition = propertyVec[0];
tag_t propertyTag = NULL;
if (strcmp("item", propertyPosition.c_str()) == 0) {
propertyTag = gbzy_item;
}
else if (strcmp("rev", propertyPosition.c_str()) == 0) {
propertyTag = gbzy_rev;
}
else if (strcmp("bomline", propertyPosition.c_str()) == 0) {
propertyTag = gbzy_line;
}
string propertyName = propertyVec[1];
char* propertyValue = NULL;
if (strcmp("puid", propertyName.c_str()) == 0) {
ITK__convert_tag_to_uid(propertyTag, &propertyValue);
}
else {
ITKCALL(ifail = AOM_UIF_ask_value(propertyTag, propertyName.c_str(), &propertyValue));
}
EMH_clear_errors();
if (ifail == 0) {
tempValue = propertyValue;
}
else {
showError = true;
WriteLog("ÊôÐÔÒì³££º%s\n", propertyName.c_str());
tempValue = " ";
}
DOFREE(propertyValue);
}
else {
tempValue = " ";
}
}
childColumnStr = childColumnStr.append(columnName);
if (j < childNameVec.size() - 1) {
childColumnStr = childColumnStr.append(",");
}
childValueStr = childValueStr.append("'").append(tempValue);
if (j < childNameVec.size() - 1) {
childValueStr = childValueStr.append("',");
}
else {
childValueStr = childValueStr.append("'");
}
}
if (isContinue) {
continue;
}
string insertSql = "";
string selectSql = "";
string updateSelectSql = "";
string updateSql = "";
if (childColumnStr.size() > 0) {
insertSql = insertSql.append(parentColumnStr).append(",").append(childColumnStr).append(")").append(parentValueStr).append(",").append(childValueStr).append(")");
}
else {
insertSql = insertSql.append(parentColumnStr).append(")").append(parentValueStr).append(")");
}
selectSql = selectSql.append(selectStr).append(childSelectStr);
updateSelectSql = updateSelectSql.append(selectAfterUpdateStr).append(childUpdateSelectStr);
updateSql = updateSql.append(updateStr).append(updateWhere).append(childUpdateWhere);
//updateStr = updateStr.append(updateWhere);
insertSql = Utf8ToGbk(insertSql.c_str());
updateSql = Utf8ToGbk(updateSql.c_str());
selectSql = Utf8ToGbk(selectSql.c_str());
updateSelectSql = Utf8ToGbk(updateSelectSql.c_str());
WriteLog("¹¤²½×ÊÔ´²åÈëÓï¾ä£º%s\n", insertSql.c_str());
//WriteLog("¹¤²½×ÊÔ´¸üÐÂÓï¾ä£º%s\n", updateSql.c_str());
WriteLog("¹¤²½×ÊÔ´²éѯÓï¾ä£º%s\n", selectSql.c_str());
//WriteLog("¹¤²½×ÊÔ´¸üкó²éѯÓï¾ä£º%s\n", updateSelectSql.c_str());
insertVec.push_back(insertSql);
updateVec.push_back(updateSql);
selectVec.push_back(selectSql);
selectAfterUpdateVec.push_back(updateSelectSql);
char sendChar[400] = "";
strcpy(sendChar, insertSql.c_str());
char sendChar2[400] = "";
strcpy(sendChar2, selectSql.c_str());
int result = ado0.ado_QuerySQLNoInputParam(sendChar2);
bool resultSql = ado0.executeInsert(sendChar2, sendChar, result);
}
}
DOFREE(zy_type);
}
}
DOFREE(gb_type);
}
//¸üÐÂÊý¾Ý¿â
/*for (int i = 0; i < updateVec.size(); i++) {
string updateSql = updateVec[i];
string selectSql = selectVec[i];
string insertSql = insertVec[i];
string selectUpdate = selectAfterUpdateVec[i];
char sendChar[200] = "";
char sendChar2[200] = "";
char sendChar3[200] = "";
strcpy(sendChar, updateSql.c_str());
strcpy(sendChar2, selectSql.c_str());
strcpy(sendChar3, selectUpdate.c_str());
int result = ado0.ado_QuerySQLNoInputParam(sendChar2);
if (result == 0) {
showError = true;
WriteLog("¹¤²½×ÊÔ´²åÈëʧ°Ü£º%s\n", insertSql.c_str());
}
else {
bool resultSql = ado0.execute2(sendChar2, sendChar, result);
result = ado0.ado_QuerySQLNoInputParam(sendChar3);
if (result == 0) {
showError = true;
WriteLog("¹¤²½×ÊÔ´¸üÐÂʧ°Ü£º%s\n", updateSql.c_str());
}
}
}*/
}
int JD_BOPInfoToMediDatabase(EPM_action_message_t msg) {
bool showError = false;
nowTime();
time_t now;
struct tm* p;
//»ñÈ¡µ±Ç°Ê±¼ä
time(&now);
//±¾µØ»¯Ê±¼ä£¬¿ÉÒÔϸ·ÖΪÄêÔÂÈÕʱ·ÖÃëµÈ
p = localtime(&now);
createDir();//´´½¨ÈÕ־Ŀ¼
char TC_LOG_FILE[128] = "";
// °ÑÈÕÖ¾Ãû³Æ¸³Óè¸øÄ³±äÁ¿
sprintf_s(TC_LOG_FILE, "%s\\tmplog\\JD_BOPInfoToMediDatabase_log_[%d-%d-%d-%d-%02d-%02d].txt", getenv("TEMP"), 1900 + p->tm_year, p->tm_mon + 1, p->tm_mday, p->tm_hour, p->tm_min, p->tm_sec);
ECHO("´´½¨ÈÕÖ¾Îļþ[%s]\n", TC_LOG_FILE);
CreateLogFile(TC_LOG_FILE);
//Á÷³Ì½ÚµãÏà¹Ø
tag_t root_task = NULLTAG, * sub_tasks = NULL, current_task = NULLTAG, type_tag = NULLTAG;
int arg_cnt = 0, ifail = 0;
char arg1value[1024] = "";//ÎïÁÏÀàÐÍ
char* argflag = NULL, * argvalue = NULL, * arg = NULL;
//µÃµ½´¥·¢´Ëº¯ÊýµÄ½Úµã
current_task = msg.task;
WriteLog("=========================================================\n");
WriteLog("JD_BOPInfoToMediDatabase ¿ªÊ¼Ö´ÐÐ\n");
WriteLog("=========================================================\n");
//»ñÈ¡handlerµÄ²ÎÊýµÄ¸öÊý
arg_cnt = TC_number_of_arguments(msg.arguments);
WriteLog("²ÎÊý¸öÊýΪ£º%d\n", arg_cnt);
if (arg_cnt > 0)
{
for (int i = 0; i < arg_cnt; i++)
{
//»ñÈ¡ÏÂÒ»¸ö²ÎÊý£¨´Ó0¿ªÊ¼£©
arg = TC_next_argument(msg.arguments);
//»ñÈ¡²ÎÊýµÄÃû³ÆºÍÖµ
ITKCALL(ifail = ITK_ask_argument_named_value((const char*)arg, &argflag, &argvalue));
if (stricmp(argflag, "PartItem") == 0)
{
if (argvalue != NULL)
{
strcpy(arg1value, argvalue);
}
}
}
MEM_free(argflag);
MEM_free(argvalue);
}
//ÏÈ»ñÈ¡Ê×Ñ¡ÏîJd_MES_Info_Connect£¬½âÎöÆäÖеÄÓû§Ãû£¬ÃÜÂ룬ÅäÖÃÎļþµÈÐÅÏ¢
vector<string> pref_vec1, pref_vec2;
getPrefStrings1("Jd_MES_Info_Connect", TC_preference_site, pref_vec1);
getPrefStrings1("Jd_MES_FTP_Info_Connect", TC_preference_site, pref_vec2);
string ip = pref_vec1[0];
string databaseName = pref_vec1[1];
string user = pref_vec1[2];
string password = pref_vec1[3];
string xmlUid1 = pref_vec1[4];
string xmlUid2 = pref_vec1[5];
string xmlUid3 = pref_vec1[6];
string xmlUid4 = pref_vec1[7];
string xmlUid5 = pref_vec1[8];
string xmlUid6 = pref_vec1[9];
string ftp_dir = pref_vec2[0];
string username = pref_vec2[1];
string ftp_pwd = pref_vec2[2];
WriteLog("ip:%s\n", ip.c_str());
WriteLog("databaseName:%s\n", databaseName.c_str());
WriteLog("user:%s\n", user.c_str());
WriteLog("password:%s\n", password.c_str());
WriteLog("¹¤ÒÕ·Ïß¹¤ÐòÃ÷ϸ±íxmlUid:%s\n", xmlUid1.c_str());
WriteLog("¹¤Ðò¹¤²½¹ØÏµ±íxmlUid:%s\n", xmlUid2.c_str());
WriteLog("¹¤ÒÕ·Ïß-¹¤ÐòÊôÐÔ±íxmlUid:%s\n", xmlUid3.c_str());
WriteLog("¹¤Ðò¹¤ÒÕÎļþxmlUid:%s\n", xmlUid4.c_str());
WriteLog("¹¤ÒÕ×ÊÔ´xmlUid:%s\n", xmlUid5.c_str());
WriteLog("¹¤²½×ÊÔ´ xmlUid:%s\n", xmlUid6.c_str());
WriteLog("FTPµØÖ·:%s\n", ftp_dir.c_str());
ado ado0;
char userName[100];
strcpy(userName, user.c_str());
char pwd[100];
strcpy(pwd, password.c_str());
string info = "Provider=SQLOLEDB.1;Persist Security Info=False;Initial Catalog=";
info.append(databaseName).append(";Data Source=").append(ip);
WriteLog("Á¬½ÓÐÅÏ¢£º%s\n", info.c_str());
bool log = ado0.open(userName, pwd, info.c_str());
//±éÀúmapËùÓв㼶
string revType = arg1value;
vector<string> revTypeVec;
Split(revType, ";", revTypeVec);
int att_cnt = 0;
tag_t* attachments = NULL;
//»ñÈ¡¸ùÁ÷³Ì½Úµã
tag_t task_tag = msg.task;
tag_t rootTask_tag = NULL;
ifail = EPM_ask_root_task(task_tag, &rootTask_tag);
//»ñȡĿ±êÒýÓöÔÏó
ifail = EPM_ask_attachments(rootTask_tag, EPM_target_attachment, &att_cnt, &attachments);
for (int i = 0; i < att_cnt; i++) {
char* object_TYPE_1 = NULL;
ifail = AOM_ask_value_string(attachments[i], "object_type", &object_TYPE_1);//¶ÔÏóÀàÐÍ
WriteLog("µ±Ç°ÀàÐͶÔÏóΪ %s\n", object_TYPE_1);
string partType = object_TYPE_1;
if (hasElement(revTypeVec, partType) == 0) {
//°üº¬ÀàÐÍ,Á¬½ÓÊý¾Ý¿â
if (log == false) {
WriteLog("µÇ¼³É¹¦\n");
tag_t partItem = NULL;
ITEM_ask_item_of_rev(attachments[i], &partItem);
char* itemType = NULL;
AOM_ask_value_string(partItem, "object_type", &itemType);
//TODO »ñÈ¡BOM½á¹¹
//»ñÈ¡°æ±¾ÏµÄbomÊÓͼ
int bom_num = 0;
tag_t* bom_tags = NULLTAG;
AOM_ask_value_tags(attachments[i], "structure_revisions", &bom_num, &bom_tags);
if (bom_num > 0)
{
tag_t only_bom = bom_tags[0];
tag_t bom_window_tag = NULLTAG, top_bom_line_tag = NULLTAG;
map<string, string> gx_cloneid_key;
map<string, string> gx_gb_key;
map<string, CHILD> child_level1;
map<string, vector<CHILD>> gx_gbs_bom;
map<string, vector<string>> level1_level2;
map<string, CHILD> child_level2;
map<string, vector<CHILD>> gx_gb_zy;
map<string, string> main_flow;
map<string, FlowInfo> line_info;
ITKCALL(ifail = ME_create_bop_window(&bom_window_tag));
ITKCALL(ifail = BOM_set_window_top_line_bvr(bom_window_tag, only_bom, &top_bom_line_tag));
/*ITKCALL(ifail = BOM_create_window(&bom_window_tag));
ITKCALL(ifail = BOM_set_window_top_line_bvr(bom_window_tag, only_bom, &top_bom_line_tag));*/
loadBom(top_bom_line_tag, child_level1, level1_level2, child_level2, gx_gbs_bom, gx_gb_zy, main_flow, line_info);
map<string, CHILD>::iterator it1;
for (it1 = child_level1.begin(); it1 != child_level1.end(); it1++) {
WriteLog("¹¤Ðòclone:%s\n", it1->first.c_str());
}
map<string, vector<CHILD>>::iterator it2;
for (it2 = gx_gbs_bom.begin(); it2 != gx_gbs_bom.end(); it2++) {
WriteLog("¹¤Ðòclone:%s,¹¤²¿ÊýÁ¿:%d\n", it2->first.c_str(), it2->second.size());
}
map<string, vector<string>>::iterator it3;
for (it3 = level1_level2.begin(); it3 != level1_level2.end(); it3++) {
int cnt = it3->second.size();
for (int f = 0; f < cnt; f++) {
WriteLog("¹¤Ðòclone:%s,¹¤Ðòϼ¶clone:%s\n", it3->first.c_str(), it3->second[f].c_str());
}
}
map<string, CHILD>::iterator it4;
for (it4 = child_level2.begin(); it4 != child_level2.end(); it4++) {
WriteLog("¹¤Ðòϼ¶clone:%s\n", it4->first.c_str());
}
map<string, vector<CHILD>>::iterator it5;
for (it5 = gx_gb_zy.begin(); it5 != gx_gb_zy.end(); it5++) {
WriteLog("¹¤Ðòclone¼°¹¤²¿uid:%s,¹¤²¿×ÊÔ´ÊýÁ¿:%d\n", it5->first.c_str(), it5->second.size());
}
map<string, string>::iterator it5_5;
for (it5_5 = main_flow.begin(); it5_5 != main_flow.end(); it5_5++) {
WriteLog("Ö÷·Ïß¹¤Ðòclone:%s\n", it5_5->first.c_str());
}
map<string, FlowInfo>::iterator it5_6;
for (it5_6 = line_info.begin(); it5_6 != line_info.end(); it5_6++) {
WriteLog("¹¤Ðòclone:%s,ǰÇý:%s,ºóÇý:%s\n", it5_6->first.c_str(), it5_6->second.pre_id.c_str(), it5_6->second.suc_id.c_str());
}
insertGyGxBom(xmlUid1, showError, ado0, top_bom_line_tag, partItem, attachments[i], child_level1, gx_cloneid_key, main_flow, line_info);
map<string, string>::iterator it6;
for (it6 = gx_cloneid_key.begin(); it6 != gx_cloneid_key.end(); it6++) {
WriteLog("¹¤Ðògx_cloneid_key,key:%s,val:%s\n", it6->first.c_str(), it6->second.c_str());
}
insertGxGb(xmlUid2, showError, ado0, child_level1, gx_cloneid_key, gx_gbs_bom, gx_gb_key);
map<string, string>::iterator it7;
for (it7 = gx_gb_key.begin(); it7 != gx_gb_key.end(); it7++) {
WriteLog("¹¤Ðògx_gb_key,key:%s,val:%s\n", it7->first.c_str(), it7->second.c_str());
}
insertGyGxProp(xmlUid3, showError, ado0, top_bom_line_tag, partItem, attachments[i], child_level1, gx_cloneid_key);
insertGyGxGywj(xmlUid4, ftp_dir, username, ftp_pwd, showError, ado0, top_bom_line_tag, partItem, attachments[i], child_level1, level1_level2, child_level2);
insertGyGxGyzy(xmlUid5, showError, ado0, top_bom_line_tag, partItem, attachments[i], child_level1, level1_level2, child_level2);
insertGbzy(xmlUid6, showError, ado0, child_level1, gx_gb_key, gx_gbs_bom, gx_gb_zy);
ITKCALL(ifail = ME_close_bop_window(bom_window_tag));//Óпª±ØÓйØ
//ITKCALL(ifail = BOM_close_window(bom_window_tag));//Óпª±ØÓйØ
}
DOFREE(bom_tags);
}
else {
WriteLog("µÇ¼ʧ°Ü====\n");
}
}
DOFREE(object_TYPE_1);
}
ado0.close();
//EMH_clear_errors();
DOFREE(attachments);
//if (showError == true) {
// string logName = "Êý¾ÝÒì³££¬Ïê¼û·þÎñÆ÷ÈÕÖ¾£º";
// logName = logName.append(TC_LOG_FILE);
// EMH_store_error_s1(EMH_severity_warning, EMH_AE_error_base, logName.c_str());
//}
WriteLog("=========================================================\n");
WriteLog("JD_BOPInfoToMediDatabase Íê³É\n");
WriteLog("=========================================================\n");
return 0;
}