修改BC数据
This commit is contained in:
parent
4e3e60950d
commit
4c1f2399af
Binary file not shown.
@ -38,7 +38,11 @@ bool UActorUEJSComponent::JsMessageDispatch(const FString& message)
|
|||||||
OnJsMessageCallbackDelegate.Broadcast(result);
|
OnJsMessageCallbackDelegate.Broadcast(result);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return Scenario->Load();
|
|
||||||
|
const FString rwbs = jsonObject->GetStringField(TEXT("rwbs"));
|
||||||
|
const FString rq = jsonObject->GetStringField(TEXT("rq"));
|
||||||
|
const FString bc = jsonObject->GetStringField(TEXT("bc"));
|
||||||
|
return Scenario->LoadMissionData(rwbs, rq, bc);
|
||||||
}
|
}
|
||||||
else if (TEXT("LoadScenarioTask") == func) {
|
else if (TEXT("LoadScenarioTask") == func) {
|
||||||
|
|
||||||
@ -52,7 +56,11 @@ bool UActorUEJSComponent::JsMessageDispatch(const FString& message)
|
|||||||
});
|
});
|
||||||
|
|
||||||
const FString year = jsonObject->GetStringField(TEXT("year"));
|
const FString year = jsonObject->GetStringField(TEXT("year"));
|
||||||
return Scenario->LoadRWBS(TCHAR_TO_UTF8(*year));
|
if (year.IsEmpty())
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return Scenario->LoadRWBS(year);
|
||||||
}
|
}
|
||||||
else if (TEXT("SelectScenarioTask") == func) {
|
else if (TEXT("SelectScenarioTask") == func) {
|
||||||
auto Scenario = TDMScenario::Create();
|
auto Scenario = TDMScenario::Create();
|
||||||
@ -65,6 +73,10 @@ bool UActorUEJSComponent::JsMessageDispatch(const FString& message)
|
|||||||
});
|
});
|
||||||
|
|
||||||
const FString task = jsonObject->GetStringField(TEXT("task"));
|
const FString task = jsonObject->GetStringField(TEXT("task"));
|
||||||
|
if (task.IsEmpty())
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
return Scenario->LoadBCSJ(task);
|
return Scenario->LoadBCSJ(task);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,11 +12,29 @@
|
|||||||
#include "DMRunnable.h"
|
#include "DMRunnable.h"
|
||||||
#include "UEDMPlugin.h"
|
#include "UEDMPlugin.h"
|
||||||
|
|
||||||
struct SQLData
|
struct BCData
|
||||||
{
|
{
|
||||||
int64 timestamp;
|
int64 timestamp;
|
||||||
int32 bc;
|
int32 bc;
|
||||||
std::string yxr;
|
FString yxr;
|
||||||
|
int32 count;
|
||||||
|
FString jx;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct HKBData
|
||||||
|
{
|
||||||
|
FString bdid;
|
||||||
|
FString jx; //型号
|
||||||
|
FString jh; //机号
|
||||||
|
FString qc_dh; //编号
|
||||||
|
FString zy; //阵营
|
||||||
|
FString dwjc; //单位简称
|
||||||
|
FString dwdm; //单位代码
|
||||||
|
FString fxsj_ly; //数据来源
|
||||||
|
FString hc_dm; //后舱代号
|
||||||
|
FString hc_xm; //后舱姓名
|
||||||
|
FString txbg_sk; //体系摧毁时刻
|
||||||
|
FString rwlx; //执行任务
|
||||||
};
|
};
|
||||||
|
|
||||||
FString GBKToUTF8(const char* gbkStr)
|
FString GBKToUTF8(const char* gbkStr)
|
||||||
@ -68,22 +86,24 @@ std::string UTF8ToGBK(const FString& str)
|
|||||||
return std::string(gbkStr.begin(), gbkStr.end());
|
return std::string(gbkStr.begin(), gbkStr.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
TSharedPtr<FJsonObject> ConvertSQLDataToJson(const SQLData& data)
|
TSharedPtr<FJsonObject> ConvertSQLDataToJson(const BCData& data)
|
||||||
{
|
{
|
||||||
TSharedPtr<FJsonObject> JsonObject = MakeShareable(new FJsonObject());
|
TSharedPtr<FJsonObject> JsonObject = MakeShareable(new FJsonObject());
|
||||||
|
|
||||||
JsonObject->SetNumberField("timestamp", data.timestamp);
|
JsonObject->SetNumberField("timestamp", data.timestamp);
|
||||||
JsonObject->SetNumberField("bc", data.bc);
|
JsonObject->SetNumberField("bc", data.bc);
|
||||||
JsonObject->SetStringField("yxr", FString(data.yxr.c_str()));
|
JsonObject->SetStringField("yxr", data.yxr);
|
||||||
|
JsonObject->SetNumberField("count", data.count);
|
||||||
|
JsonObject->SetStringField("jx", data.jx);
|
||||||
|
|
||||||
return JsonObject;
|
return JsonObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
FString ConvertSQLDataVectorToJson(const FString& response, const std::vector<SQLData>& dataVector)
|
FString ConvertSQLDataVectorToJson(const FString& response, const std::vector<BCData>& dataVector)
|
||||||
{
|
{
|
||||||
TArray<TSharedPtr<FJsonValue>> JsonArray;
|
TArray<TSharedPtr<FJsonValue>> JsonArray;
|
||||||
|
|
||||||
for (const SQLData& data : dataVector)
|
for (const BCData& data : dataVector)
|
||||||
{
|
{
|
||||||
TSharedPtr<FJsonObject> JsonObject = ConvertSQLDataToJson(data);
|
TSharedPtr<FJsonObject> JsonObject = ConvertSQLDataToJson(data);
|
||||||
JsonArray.Add(MakeShareable(new FJsonValueObject(JsonObject)));
|
JsonArray.Add(MakeShareable(new FJsonValueObject(JsonObject)));
|
||||||
@ -100,8 +120,6 @@ FString ConvertSQLDataVectorToJson(const FString& response, const std::vector<SQ
|
|||||||
return JsonString;
|
return JsonString;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
FString ConvertRWBSVectorToJson(const FString& response, const std::vector<FString>& dataVector)
|
FString ConvertRWBSVectorToJson(const FString& response, const std::vector<FString>& dataVector)
|
||||||
{
|
{
|
||||||
TArray<TSharedPtr<FJsonValue>> JsonArray;
|
TArray<TSharedPtr<FJsonValue>> JsonArray;
|
||||||
@ -122,6 +140,51 @@ FString ConvertRWBSVectorToJson(const FString& response, const std::vector<FStri
|
|||||||
return JsonString;
|
return JsonString;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FString ConvertHKBDataVectorToJson(const FString& response, const std::vector<HKBData>& dataVector)
|
||||||
|
{
|
||||||
|
TArray<TSharedPtr<FJsonValue>> JsonArray;
|
||||||
|
|
||||||
|
for (const HKBData& data : dataVector)
|
||||||
|
{
|
||||||
|
TSharedPtr<FJsonObject> JsonObject = MakeShareable(new FJsonObject());
|
||||||
|
|
||||||
|
JsonObject->SetStringField(TEXT("BDID"), data.bdid);
|
||||||
|
JsonObject->SetStringField(TEXT("型号"), data.jx);
|
||||||
|
JsonObject->SetStringField(TEXT("机号"), data.jh);
|
||||||
|
JsonObject->SetStringField(TEXT("编号"), data.qc_dh);
|
||||||
|
JsonObject->SetStringField(TEXT("阵营"), data.zy);
|
||||||
|
JsonObject->SetStringField(TEXT("单位简称"), data.dwjc);
|
||||||
|
JsonObject->SetStringField(TEXT("单位代码"), data.dwdm);
|
||||||
|
JsonObject->SetStringField(TEXT("数据来源"), data.fxsj_ly);
|
||||||
|
JsonObject->SetStringField(TEXT("后舱代号"), data.hc_dm);
|
||||||
|
JsonObject->SetStringField(TEXT("后舱姓名"), data.hc_xm);
|
||||||
|
JsonObject->SetStringField(TEXT("体系摧毁时刻"), data.txbg_sk);
|
||||||
|
JsonObject->SetStringField(TEXT("执行任务"), data.rwlx);
|
||||||
|
|
||||||
|
FString leftString;
|
||||||
|
FString rightString;
|
||||||
|
bool is = data.txbg_sk.Split(" ", &leftString, &rightString);
|
||||||
|
if (is)
|
||||||
|
{
|
||||||
|
JsonObject->SetStringField(TEXT("体系摧毁文本信息"), rightString);
|
||||||
|
}
|
||||||
|
|
||||||
|
JsonObject->SetStringField(TEXT("体系摧毁文本颜色"), FColor(255, 0, 0, 255).ToString());
|
||||||
|
|
||||||
|
JsonArray.Add(MakeShareable(new FJsonValueObject(JsonObject)));
|
||||||
|
}
|
||||||
|
|
||||||
|
TSharedPtr<FJsonObject> RootObject = MakeShareable(new FJsonObject());
|
||||||
|
RootObject->SetArrayField("data", JsonArray);
|
||||||
|
RootObject->SetStringField("type", response);
|
||||||
|
|
||||||
|
FString JsonString;
|
||||||
|
TSharedRef<TJsonWriter<TCHAR>> Writer = TJsonWriterFactory<TCHAR>::Create(&JsonString);
|
||||||
|
FJsonSerializer::Serialize(RootObject.ToSharedRef(), Writer);
|
||||||
|
|
||||||
|
return JsonString;
|
||||||
|
}
|
||||||
|
|
||||||
TDMScenario::TDMScenario()
|
TDMScenario::TDMScenario()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -136,11 +199,10 @@ TSharedPtr<TDMScenario> TDMScenario::Create()
|
|||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TDMScenario::LoadRWBS(const std::string& year)
|
bool TDMScenario::LoadRWBS(const FString& year)
|
||||||
{
|
{
|
||||||
std::string sSQL = "select distinct RWBS from kzdk.rw_jbqk where to_char(ksrq, 'yyyy') = '" + year + "'";
|
FString query = FString::Format(TEXT("select distinct RWBS from kzdk.rw_jbqk where to_char(ksrq, 'yyyy') ='{0}';"), { year });
|
||||||
|
std::string sSQL = UTF8ToGBK(query);
|
||||||
UE_LOG(LogUEDMPlugin, Log, TEXT("SQL=%s"), UTF8_TO_TCHAR(sSQL.c_str()));
|
|
||||||
|
|
||||||
TSharedPtr<FSQLCommand> sqlCommand = MakeShareable(new FSQLCommand);
|
TSharedPtr<FSQLCommand> sqlCommand = MakeShareable(new FSQLCommand);
|
||||||
sqlCommand->Type = ESQLType::SELECT;
|
sqlCommand->Type = ESQLType::SELECT;
|
||||||
@ -184,14 +246,15 @@ bool TDMScenario::LoadRWBS(const std::string& year)
|
|||||||
}
|
}
|
||||||
dmRunnable->ExcuteSQL(sqlCommand);
|
dmRunnable->ExcuteSQL(sqlCommand);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TDMScenario::LoadBCSJ(const FString& rwbs)
|
bool TDMScenario::LoadBCSJ(const FString& rwbs)
|
||||||
{
|
{
|
||||||
FString query = FString::Format(TEXT("select RQ, BC, YXR from kzdk.RW_BCSJ where RWBS = '{0}' order by rq, bc asc;"),
|
FString query = FString::Format(TEXT("select a.RQ,a.BC,a.YXR, "
|
||||||
{ rwbs });
|
"(select count(b.bdid) from kzdk.rw_fxjc b where b.rwbs = '{0}' and b.rq = a.rq and b.bc = a.bc), "
|
||||||
std::string sSQL = UTF8ToGBK(query) ;
|
"(select LISTAGG(distinct c.jx, ',') from kzdk.rw_fxjc c where c.rwbs = '{0}' and c.rq = a.rq and c.bc = a.bc) "
|
||||||
|
"from kzdk.RW_BCSJ a where a.RWBS = '{0}' order by a.rq, a.bc asc; "), { rwbs });
|
||||||
|
std::string sSQL = UTF8ToGBK(query);
|
||||||
|
|
||||||
TSharedPtr<FSQLCommand> sqlCommand = MakeShareable(new FSQLCommand);
|
TSharedPtr<FSQLCommand> sqlCommand = MakeShareable(new FSQLCommand);
|
||||||
sqlCommand->Type = ESQLType::SELECT;
|
sqlCommand->Type = ESQLType::SELECT;
|
||||||
@ -201,91 +264,45 @@ bool TDMScenario::LoadBCSJ(const FString& rwbs)
|
|||||||
sdint8 out_c1 = 0;
|
sdint8 out_c1 = 0;
|
||||||
sdint4 out_c2 = 0;
|
sdint4 out_c2 = 0;
|
||||||
sdbyte out_c3[20] = { 0 };
|
sdbyte out_c3[20] = { 0 };
|
||||||
|
sdint4 out_c4 = 0;
|
||||||
|
sdbyte out_c5[128] = { 0 };
|
||||||
slength out_c1_ind = 0;
|
slength out_c1_ind = 0;
|
||||||
slength out_c2_ind = 0;
|
slength out_c2_ind = 0;
|
||||||
slength out_c3_ind = 0;
|
slength out_c3_ind = 0;
|
||||||
|
slength out_c4_ind = 0;
|
||||||
|
slength out_c5_ind = 0;
|
||||||
dpi_bind_col(content, 1, DSQL_C_TIMESTAMP, &out_c1, sizeof(out_c1), &out_c1_ind);
|
dpi_bind_col(content, 1, DSQL_C_TIMESTAMP, &out_c1, sizeof(out_c1), &out_c1_ind);
|
||||||
dpi_bind_col(content, 2, DSQL_C_SLONG, &out_c2, sizeof(out_c2), &out_c2_ind);
|
dpi_bind_col(content, 2, DSQL_C_SLONG, &out_c2, sizeof(out_c2), &out_c2_ind);
|
||||||
dpi_bind_col(content, 3, DSQL_C_NCHAR, &out_c3, sizeof(out_c3), &out_c3_ind);
|
dpi_bind_col(content, 3, DSQL_C_NCHAR, &out_c3, sizeof(out_c3), &out_c3_ind);
|
||||||
|
dpi_bind_col(content, 4, DSQL_C_SLONG, &out_c4, sizeof(out_c4), &out_c4_ind);
|
||||||
|
dpi_bind_col(content, 5, DSQL_C_NCHAR, &out_c5, sizeof(out_c5), &out_c5_ind);
|
||||||
ulength row_num = 0;
|
ulength row_num = 0;
|
||||||
|
|
||||||
std::vector<SQLData> tables;
|
std::vector<BCData> tables;
|
||||||
while (dpi_fetch(content, &row_num) != DSQL_NO_DATA)
|
while (dpi_fetch(content, &row_num) != DSQL_NO_DATA)
|
||||||
{
|
{
|
||||||
tables.push_back({ out_c1, out_c2, (char*)out_c3 });
|
tables.push_back({ out_c1, out_c2, GBKToUTF8((const char*)out_c3), out_c4, GBKToUTF8((const char*)out_c5) });
|
||||||
UE_LOG(LogUEDMPlugin, Log, TEXT("RQ=%llu, BC=%d YXR=%s"), out_c1, out_c2, UTF8_TO_TCHAR((char*)out_c3));
|
UE_LOG(LogUEDMPlugin, Log, TEXT("RQ=%llu, BC=%d YXR=%s"), out_c1, out_c2, UTF8_TO_TCHAR((char*)out_c3));
|
||||||
}
|
}
|
||||||
TSharedPtr<SQLResult> Result = MakeShareable(new SelectResult<SQLData>(std::move(tables)));
|
TSharedPtr<SQLResult> Result = MakeShareable(new SelectResult<BCData>(std::move(tables)));
|
||||||
return Result;
|
|
||||||
};
|
|
||||||
|
|
||||||
TSharedPtr<TDMScenario> self = AsShared();
|
|
||||||
sqlCommand->OnQueryCompleted.BindLambda([self](TSharedPtr<SQLResult> Result)
|
|
||||||
{
|
|
||||||
if (!Result)
|
|
||||||
{
|
|
||||||
UE_LOG(LogUEDMPlugin, Error, TEXT("TDMScenario::LoadBCSJ failed, Result is nullptr"));
|
|
||||||
}
|
|
||||||
SelectResult<SQLData>* sqlData = static_cast<SelectResult<SQLData>*>(Result.Get());
|
|
||||||
if (!sqlData->succes)
|
|
||||||
{
|
|
||||||
UE_LOG(LogUEDMPlugin, Error, TEXT("TDMScenario::LoadBCSJ failed"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
FString jsonString = ConvertSQLDataVectorToJson(TEXT("SelectScenarioTaskResponse"), sqlData->table);
|
|
||||||
bool success = self->OnQueryCompleted.ExecuteIfBound(jsonString);
|
|
||||||
UE_LOG(LogUEDMPlugin, Error, TEXT("TDMScenario::Query OnQueryCompleted.ExecuteIfBound %d"), success);
|
|
||||||
});
|
|
||||||
|
|
||||||
auto dmRunnable = FUEDMPluginModule::GetDMRunnable();
|
|
||||||
if (nullptr == dmRunnable)
|
|
||||||
{
|
|
||||||
UE_LOG(LogUEDMPlugin, Error, TEXT("TDMScenario::Query dm runnable is nullptr"));
|
|
||||||
}
|
|
||||||
dmRunnable->ExcuteSQL(sqlCommand);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool TDMScenario::Load()
|
|
||||||
{
|
|
||||||
TSharedPtr<FSQLCommand> sqlCommand = MakeShareable(new FSQLCommand);
|
|
||||||
sqlCommand->Type = ESQLType::SELECT;
|
|
||||||
sqlCommand->SQL = "select RQ,BC,YXR from kzdk.RW_BCSJ order by rq ,bc asc;";
|
|
||||||
sqlCommand->select = [](void* content)
|
|
||||||
{
|
|
||||||
sdint8 out_c1 = 0;
|
|
||||||
sdint4 out_c2 = 0;
|
|
||||||
sdbyte out_c3[20] = { 0 };
|
|
||||||
slength out_c1_ind = 0;
|
|
||||||
slength out_c2_ind = 0;
|
|
||||||
slength out_c3_ind = 0;
|
|
||||||
dpi_bind_col(content, 1, DSQL_C_TIMESTAMP, &out_c1, sizeof(out_c1), &out_c1_ind);
|
|
||||||
dpi_bind_col(content, 2, DSQL_C_SLONG, &out_c2, sizeof(out_c2), &out_c2_ind);
|
|
||||||
dpi_bind_col(content, 3, DSQL_C_NCHAR, &out_c3, sizeof(out_c3), &out_c3_ind);
|
|
||||||
ulength row_num = 0;
|
|
||||||
|
|
||||||
std::vector<SQLData> tables;
|
|
||||||
while (dpi_fetch(content, &row_num) != DSQL_NO_DATA)
|
|
||||||
{
|
|
||||||
tables.push_back({ out_c1, out_c2, (char*)out_c3 });
|
|
||||||
UE_LOG(LogUEDMPlugin, Log, TEXT("RQ=%llu, BC=%d YXR=%s"), out_c1, out_c2, UTF8_TO_TCHAR((char*)out_c3));
|
|
||||||
}
|
|
||||||
TSharedPtr<SQLResult> Result = MakeShareable(new SelectResult<SQLData>(std::move(tables)));
|
|
||||||
return Result;
|
return Result;
|
||||||
};
|
};
|
||||||
|
|
||||||
TSharedPtr<TDMScenario> self = AsShared();
|
TSharedPtr<TDMScenario> self = AsShared();
|
||||||
sqlCommand->OnQueryCompleted.BindLambda([self](TSharedPtr<SQLResult> Result)
|
sqlCommand->OnQueryCompleted.BindLambda([self](TSharedPtr<SQLResult> Result)
|
||||||
{
|
{
|
||||||
SelectResult<SQLData>* sqlData = static_cast<SelectResult<SQLData>*>(Result.Get());
|
if (!Result)
|
||||||
|
{
|
||||||
|
UE_LOG(LogUEDMPlugin, Error, TEXT("TDMScenario::LoadBCSJ failed, Result is nullptr"));
|
||||||
|
}
|
||||||
|
SelectResult<BCData>* sqlData = static_cast<SelectResult<BCData>*>(Result.Get());
|
||||||
if (!sqlData->succes)
|
if (!sqlData->succes)
|
||||||
{
|
{
|
||||||
UE_LOG(LogUEDMPlugin, Error, TEXT("TDMScenario::Load failed"));
|
UE_LOG(LogUEDMPlugin, Error, TEXT("TDMScenario::LoadBCSJ failed"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
FString jsonString = ConvertSQLDataVectorToJson(TEXT("LoadScenarioResponse"), sqlData->table);
|
FString jsonString = ConvertSQLDataVectorToJson(TEXT("SelectScenarioTaskResponse"), sqlData->table);
|
||||||
bool success = self->OnQueryCompleted.ExecuteIfBound(jsonString);
|
bool success = self->OnQueryCompleted.ExecuteIfBound(jsonString);
|
||||||
UE_LOG(LogUEDMPlugin, Error, TEXT("TDMScenario::Query OnQueryCompleted.ExecuteIfBound %d"), success);
|
UE_LOG(LogUEDMPlugin, Error, TEXT("TDMScenario::Query OnQueryCompleted.ExecuteIfBound %d"), success);
|
||||||
});
|
});
|
||||||
@ -299,7 +316,7 @@ bool TDMScenario::Load()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TDMScenario::LoadMissionData(const FString& rwbs, const FString& rq, const FString& bc)
|
bool TDMScenario::LoadMissionData(const FString& rwbs, const FString& rq, const FString& bc)
|
||||||
{
|
{
|
||||||
UE_LOG(LogUEDMPlugin, Log, TEXT("LoadMissionData Begin"));
|
UE_LOG(LogUEDMPlugin, Log, TEXT("LoadMissionData Begin"));
|
||||||
|
|
||||||
@ -308,20 +325,111 @@ void TDMScenario::LoadMissionData(const FString& rwbs, const FString& rq, const
|
|||||||
LoadDMMBData(rwbs, rq, bc);
|
LoadDMMBData(rwbs, rq, bc);
|
||||||
|
|
||||||
UE_LOG(LogUEDMPlugin, Log, TEXT("LoadMissionData End"));
|
UE_LOG(LogUEDMPlugin, Log, TEXT("LoadMissionData End"));
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TDMScenario::LoadHKBData(const FString& rwbs, const FString& rq, const FString& bc)
|
void TDMScenario::LoadHKBData(const FString& rwbs, const FString& rq, const FString& bc)
|
||||||
{
|
{
|
||||||
std::string sSQL = "select bdid, jx, jh, qc_dh, zy, dwjc, dwdm, fxsj_ly, hc_dm, hc_xm, txbg_sk, RWLX from kzdk.RW_FXJC where RWBS = " +
|
FString query = FString::Format(TEXT("select bdid, jx, jh, qc_dh, zy, dwjc, dwdm, fxsj_ly, hc_dm, hc_xm, txbg_sk, RWLX from kzdk.RW_FXJC"
|
||||||
std::string(TCHAR_TO_UTF8(*rwbs)) + " and RQ = to_date('" +
|
" where RWBS = '{0}' and RQ = to_date('{1}', 'yyyy-mm-dd') and BC = {2};"), { rwbs, rq, bc });
|
||||||
std::string(TCHAR_TO_UTF8(*rq)) + "', 'yyyy-mm-dd') and BC = " + std::string(TCHAR_TO_UTF8(*bc));
|
std::string sSQL = UTF8ToGBK(query);
|
||||||
|
|
||||||
|
TSharedPtr<FSQLCommand> sqlCommand = MakeShareable(new FSQLCommand);
|
||||||
|
sqlCommand->Type = ESQLType::SELECT;
|
||||||
|
sqlCommand->SQL = sSQL;
|
||||||
|
sqlCommand->select = [](void* content)
|
||||||
|
{
|
||||||
|
sdbyte out_c1[40] = { 0 };
|
||||||
|
sdbyte out_c2[30] = { 0 };
|
||||||
|
sdbyte out_c3[50] = { 0 };
|
||||||
|
sdbyte out_c4[20] = { 0 };
|
||||||
|
sdbyte out_c5[200] = { 0 };
|
||||||
|
sdbyte out_c6[200] = { 0 };
|
||||||
|
sdbyte out_c7[200] = { 0 };
|
||||||
|
sdbyte out_c8[20] = { 0 };
|
||||||
|
sdbyte out_c9[20] = { 0 };
|
||||||
|
sdbyte out_c10[30] = { 0 };
|
||||||
|
dpi_timestamp_t out_c11;
|
||||||
|
sdbyte out_c12[20] = { 0 };
|
||||||
|
slength out_c1_ind = 0;
|
||||||
|
slength out_c2_ind = 0;
|
||||||
|
slength out_c3_ind = 0;
|
||||||
|
slength out_c4_ind = 0;
|
||||||
|
slength out_c5_ind = 0;
|
||||||
|
slength out_c6_ind = 0;
|
||||||
|
slength out_c7_ind = 0;
|
||||||
|
slength out_c8_ind = 0;
|
||||||
|
slength out_c9_ind = 0;
|
||||||
|
slength out_c10_ind = 0;
|
||||||
|
slength out_c11_ind = 0;
|
||||||
|
slength out_c12_ind = 0;
|
||||||
|
dpi_bind_col(content, 1, DSQL_C_NCHAR, &out_c1, sizeof(out_c1), &out_c1_ind);
|
||||||
|
dpi_bind_col(content, 2, DSQL_C_NCHAR, &out_c2, sizeof(out_c2), &out_c2_ind);
|
||||||
|
dpi_bind_col(content, 3, DSQL_C_NCHAR, &out_c3, sizeof(out_c3), &out_c3_ind);
|
||||||
|
dpi_bind_col(content, 4, DSQL_C_NCHAR, &out_c4, sizeof(out_c4), &out_c4_ind);
|
||||||
|
dpi_bind_col(content, 5, DSQL_C_NCHAR, &out_c5, sizeof(out_c5), &out_c5_ind);
|
||||||
|
dpi_bind_col(content, 6, DSQL_C_NCHAR, &out_c6, sizeof(out_c6), &out_c6_ind);
|
||||||
|
dpi_bind_col(content, 7, DSQL_C_NCHAR, &out_c7, sizeof(out_c7), &out_c7_ind);
|
||||||
|
dpi_bind_col(content, 8, DSQL_C_NCHAR, &out_c8, sizeof(out_c8), &out_c8_ind);
|
||||||
|
dpi_bind_col(content, 9, DSQL_C_NCHAR, &out_c9, sizeof(out_c9), &out_c9_ind);
|
||||||
|
dpi_bind_col(content, 10, DSQL_C_NCHAR, &out_c10, sizeof(out_c10), &out_c10_ind);
|
||||||
|
dpi_bind_col(content, 11, DSQL_C_TIMESTAMP, &out_c11, sizeof(out_c11), &out_c11_ind);
|
||||||
|
dpi_bind_col(content, 12, DSQL_C_NCHAR, &out_c12, sizeof(out_c12), &out_c12_ind);
|
||||||
|
ulength row_num = 0;
|
||||||
|
|
||||||
|
std::vector<HKBData> tables;
|
||||||
|
while (dpi_fetch(content, &row_num) != DSQL_NO_DATA)
|
||||||
|
{
|
||||||
|
|
||||||
|
FString st = FString::Format(TEXT("{0}-{1}-{2} {3}:{4}:{5}"), { out_c11.year, out_c11.month, out_c11.day, out_c11.hour, out_c11.minute, out_c11.second });
|
||||||
|
|
||||||
|
tables.push_back({ GBKToUTF8((char*)out_c1), GBKToUTF8((char*)out_c2), GBKToUTF8((char*)out_c3), GBKToUTF8((char*)out_c4),
|
||||||
|
GBKToUTF8((char*)out_c5), GBKToUTF8((char*)out_c6), GBKToUTF8((char*)out_c7), GBKToUTF8((char*)out_c8),
|
||||||
|
GBKToUTF8((char*)out_c9), GBKToUTF8((char*)out_c10), st, GBKToUTF8((char*)out_c12) });
|
||||||
|
UE_LOG(LogUEDMPlugin, Log, TEXT("RQ=%llu, BC=%d YXR=%s"), out_c1, out_c2, UTF8_TO_TCHAR((char*)out_c3));
|
||||||
|
}
|
||||||
|
TSharedPtr<SQLResult> Result = MakeShareable(new SelectResult<HKBData>(std::move(tables)));
|
||||||
|
return Result;
|
||||||
|
};
|
||||||
|
|
||||||
|
TSharedPtr<TDMScenario> self = AsShared();
|
||||||
|
sqlCommand->OnQueryCompleted.BindLambda([self](TSharedPtr<SQLResult> Result)
|
||||||
|
{
|
||||||
|
SelectResult<HKBData>* sqlData = static_cast<SelectResult<HKBData>*>(Result.Get());
|
||||||
|
if (!sqlData->succes)
|
||||||
|
{
|
||||||
|
UE_LOG(LogUEDMPlugin, Error, TEXT("TDMScenario::Query failed"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
FString jsonString = ConvertHKBDataVectorToJson(TEXT("HKB-Base"), sqlData->table);
|
||||||
|
bool success = self->OnLoadCompleted.ExecuteIfBound(jsonString);
|
||||||
|
UE_LOG(LogUEDMPlugin, Error, TEXT("TDMScenario::Query OnLoadCompleted.ExecuteIfBound %d"), success);
|
||||||
|
});
|
||||||
|
|
||||||
|
auto dmRunnable = FUEDMPluginModule::GetDMRunnable();
|
||||||
|
if (nullptr == dmRunnable)
|
||||||
|
{
|
||||||
|
UE_LOG(LogUEDMPlugin, Error, TEXT("TDMScenario::Query dm runnable is nullptr"));
|
||||||
|
}
|
||||||
|
dmRunnable->ExcuteSQL(sqlCommand);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TDMScenario::LoadKkwqsyList(const FString& bdid, const FString& qrxg, const FString& qcdh, const FString& zy)
|
bool TDMScenario::LoadKkwqsyList(const FString& bdid, const FString& qrxg, const FString& qcdh, const FString& zy)
|
||||||
{
|
{
|
||||||
std::string sSQL = "select dx, fsbh, GJ_JL, GJ_FW, gj_sk, GJTS, DMZYSK, ZD_JSSK, gjxg_qrmb, dx, MZYXX, FS_JH from kzdk.rw_fxjc_wqsy where sjlx = '空空' and gjxg_qrxg = " +
|
//FString query = FString::Format(TEXT("select bdid, jx, jh, qc_dh, zy, dwjc, dwdm, fxsj_ly, hc_dm, hc_xm, txbg_sk, RWLX from kzdk.RW_FXJC"
|
||||||
std::string(TCHAR_TO_UTF8(*qrxg)) + " and bdid = " +
|
// " where RWBS = '{0}' and RQ = to_date('{1}', 'yyyy-mm-dd') and BC = {2};"), { rwbs, rq, bc });
|
||||||
std::string(TCHAR_TO_UTF8(*bdid));
|
//std::string sSQL = UTF8ToGBK(query);
|
||||||
|
|
||||||
|
//TSharedPtr<FSQLCommand> sqlCommand = MakeShareable(new FSQLCommand);
|
||||||
|
//sqlCommand->Type = ESQLType::SELECT;
|
||||||
|
//sqlCommand->SQL = sSQL;
|
||||||
|
//sqlCommand->select = [](void* content)
|
||||||
|
|
||||||
|
// std::string sSQL = "select dx, fsbh, GJ_JL, GJ_FW, gj_sk, GJTS, DMZYSK, ZD_JSSK, gjxg_qrmb, dx, MZYXX, FS_JH from kzdk.rw_fxjc_wqsy where sjlx = '空空' and gjxg_qrxg = " +
|
||||||
|
// std::string(TCHAR_TO_UTF8(*qrxg)) + " and bdid = " +
|
||||||
|
// std::string(TCHAR_TO_UTF8(*bdid));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -3,9 +3,9 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "CoreMinimal.h"
|
#include "CoreMinimal.h"
|
||||||
#include <string>
|
|
||||||
|
|
||||||
DECLARE_DELEGATE_OneParam(FOnSQLCompleted, FString);
|
DECLARE_DELEGATE_OneParam(FOnSQLCompleted, FString);
|
||||||
|
DECLARE_DELEGATE_OneParam(FOnLoadCompleted, FString);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -19,17 +19,16 @@ public:
|
|||||||
static TSharedPtr<TDMScenario> Create();
|
static TSharedPtr<TDMScenario> Create();
|
||||||
|
|
||||||
// 加载任务标识
|
// 加载任务标识
|
||||||
bool LoadRWBS(const std::string& year);
|
bool LoadRWBS(const FString& year);
|
||||||
|
|
||||||
// 加载波次
|
// 加载波次
|
||||||
bool LoadBCSJ(const FString& rwbs);
|
bool LoadBCSJ(const FString& rwbs);
|
||||||
bool Load();
|
|
||||||
|
|
||||||
// 加载任务数据
|
// 加载任务数据
|
||||||
//rwbs:任务标识
|
//rwbs:任务标识
|
||||||
//rq:日期
|
//rq:日期
|
||||||
//bc:波次
|
//bc:波次
|
||||||
void LoadMissionData(const FString& rwbs, const FString& rq, const FString& bc);
|
bool LoadMissionData(const FString& rwbs, const FString& rq, const FString& bc);
|
||||||
|
|
||||||
// 加载航空兵数据
|
// 加载航空兵数据
|
||||||
void LoadHKBData(const FString& rwbs, const FString& rq, const FString& bc);
|
void LoadHKBData(const FString& rwbs, const FString& rq, const FString& bc);
|
||||||
@ -49,4 +48,5 @@ public:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
FOnSQLCompleted OnQueryCompleted;
|
FOnSQLCompleted OnQueryCompleted;
|
||||||
|
FOnLoadCompleted OnLoadCompleted;
|
||||||
};
|
};
|
||||||
|
@ -8,6 +8,8 @@
|
|||||||
#include "DMRunnable.h"
|
#include "DMRunnable.h"
|
||||||
#include "DPI.h"
|
#include "DPI.h"
|
||||||
|
|
||||||
|
#include "DMScenario.h"
|
||||||
|
|
||||||
#define LOCTEXT_NAMESPACE "FUEDMPluginModule"
|
#define LOCTEXT_NAMESPACE "FUEDMPluginModule"
|
||||||
|
|
||||||
DEFINE_LOG_CATEGORY(LogUEDMPlugin);
|
DEFINE_LOG_CATEGORY(LogUEDMPlugin);
|
||||||
@ -18,6 +20,14 @@ void FUEDMPluginModule::StartupModule()
|
|||||||
{
|
{
|
||||||
// This code will execute after your module is loaded into memory; the exact timing is specified in the .uplugin file per-module
|
// This code will execute after your module is loaded into memory; the exact timing is specified in the .uplugin file per-module
|
||||||
dmRunnable_ = new FDMRunnable();
|
dmRunnable_ = new FDMRunnable();
|
||||||
|
|
||||||
|
//auto Scenario = TDMScenario::Create();
|
||||||
|
//Scenario->OnQueryCompleted.BindLambda([this](const FString& result)
|
||||||
|
// {
|
||||||
|
|
||||||
|
// });
|
||||||
|
|
||||||
|
//Scenario->LoadRWBS("2019");
|
||||||
}
|
}
|
||||||
|
|
||||||
void FUEDMPluginModule::ShutdownModule()
|
void FUEDMPluginModule::ShutdownModule()
|
||||||
|
@ -21,7 +21,7 @@ bool UUEJSBlueprintFunctionLibrary::JsMessageDispatch(const FString& message)
|
|||||||
if (TEXT("LoadTask") == func)
|
if (TEXT("LoadTask") == func)
|
||||||
{
|
{
|
||||||
auto Scenario = TDMScenario::Create();
|
auto Scenario = TDMScenario::Create();
|
||||||
Scenario->Load();
|
//Scenario->Load();
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -26,8 +26,6 @@ public:
|
|||||||
UPROPERTY(BlueprintAssignable)
|
UPROPERTY(BlueprintAssignable)
|
||||||
FJsMessageCallbackDelegate OnJsMessageCallbackDelegate;
|
FJsMessageCallbackDelegate OnJsMessageCallbackDelegate;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// Called when the game starts
|
// Called when the game starts
|
||||||
virtual void BeginPlay() override;
|
virtual void BeginPlay() override;
|
||||||
@ -35,6 +33,4 @@ protected:
|
|||||||
public:
|
public:
|
||||||
// Called every frame
|
// Called every frame
|
||||||
virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
|
virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user