#include "dfl_custom.h" #include #include #include #include #include #include "ado.h" #include #include #include "rapidjson/document.h" #include #include "rapidjson/writer.h" #include #include #include #include #include #include #include "CRUL_server_call_httpserver.h" #define ITK_err 919012 #include "spdlog/spdlog.h" #include "spdlog/sinks/basic_file_sink.h" #include "ocilib.h" #include "util.h" using namespace spdlog; #define PREF_ML_DB "Meling_dbinfo" using namespace std; using namespace rapidjson; string startLog(char* userName) { tag_t current_member = NULLTAG, current_user = NULLTAG; string userId = userName; //获取当前时间 time_t now = time(0); tm* p = localtime(&now); char dateNow[128] = ""; sprintf_s(dateNow, "%04d%02d%02d%02d%02d%02d", 1900 + p->tm_year, p->tm_mon + 1, p->tm_mday, p->tm_hour, p->tm_min, p->tm_sec); string dateString = dateNow; string logPath = "C:/logs/" + userId + "_" + dateString + ".log"; auto file_logger = basic_logger_mt("import_logger", logPath); set_default_logger(file_logger); log("begin connor_import_object"); return logPath; } string uploadMinio(string jarName, string logPath) { char cmd[1024] = ""; strcpy(cmd, "java -jar \""); //strcat(cmd, jar_file); strcat(cmd, getenv("TC_ROOT")); strcat(cmd, "\\bin\\"); strcat(cmd, jarName.c_str()); strcat(cmd, "\" "); string strResult; strcat(cmd, logPath.c_str()); char buf[8000] = { 0 }; log("cmd:\n%s\n", cmd); FILE* pf = NULL; if ((pf = _popen(cmd, "r")) == NULL) { log("接口返回1\n"); } else { log("接口返回2\n"); while (fgets(buf, sizeof buf, pf)) { strResult += buf; } _pclose(pf); } log("strResult:%s\n", strResult.c_str()); return strResult; //return; } int ITK_user_main(int argc, char* argv[]) { int ifail = ITK_ok; char* tc_name, *tc_pwd, *tc_group, *code, *groupId, *projectUid, *uids, *userName; tc_name = (char*)"dcproxy";//ITK_ask_cli_argument("-u="); tc_pwd = (char*)"dcproxy";// ITK_ask_cli_argument("-p="); tc_group = (char*)"";// ITK_ask_cli_argument("-g="); code = ITK_ask_cli_argument("-a="); //编号 groupId = ITK_ask_cli_argument("-b="); //编号 projectUid = ITK_ask_cli_argument("-c="); //编号 uids = ITK_ask_cli_argument("-d="); //编号 userName = ITK_ask_cli_argument("-e="); //编号 ITKCALL(ifail = TC_init_module(tc_name, tc_pwd, tc_group)); if (ifail != ITK_ok) { log("login fail! \n"); return ifail; } else { log("login2222>>>>> \n"); } string logPath = startLog(userName); vector uidVector; vector ccpVector; Split(uids, ":", uidVector); log("uidVector>>>>> %d \n", uidVector.size()); for (int i = 0; i < uidVector.size(); i++) { tag_t ccp; log("idVector[i].c_str() %s \n", uidVector[i].c_str()); ITK__convert_uid_to_tag(uidVector[i].c_str(), &ccp); ccpVector.push_back(ccp); } int url_num = 0; char** url_vals = NULL; PREF_ask_char_values("database_tc", &url_num, &url_vals); string url = url_vals[0]; url.append("/").append(url_vals[2]); log("url ==>%s", url.c_str()); if (ConnServer(url_vals[3], url_vals[4], (char*)url.c_str()) == -1) { log("提示:中间数据表访问失败"); ifail = 1; } readBomMsg(ccpVector, groupId, projectUid, code, userName);//,char * groupName,char* groupUid,char*code //log("产成品UID: {%s} " , uids); string str = uploadMinio("uploadMinio.jar", logPath); //string minioPath = "/plmichi/SapBomLog/" + logPath; //char updateSum[1024] = "update CHINT_BOM_TO_SAP_SUM set \"LOGURL\" = '%s' where code = '%s' "; char selectRxfs[1024]; sprintf(selectRxfs, "update CHINT_BOM_TO_SAP_SUM set \"LOGURL\" = '%s' where code = '%s' ", str.c_str(), code); log("selectRecord3 ===> %s\n", selectRxfs); ExecuteSQLNoInputParam(selectRxfs); ExecuteSQLNoInputParam((char*)"commit"); //上传文件 DisConnServer(); ITK_exit_module(true); spdlog::drop_all(); return ifail; }