85 lines
1.7 KiB
C++
85 lines
1.7 KiB
C++
|
|
#include <iostream>
|
|
#include <common/inc/sqlite3.h>
|
|
#include "F_WriteData.h"
|
|
#include "bizservice.h"
|
|
#include "f-readdata/normalDataDB.h"
|
|
|
|
|
|
static bool writeDataDb(void *db_handle, const json &cdtjson, json &outjson)
|
|
{
|
|
|
|
return true;
|
|
}
|
|
|
|
void writeDataSrv::Init(initparam_t *param)
|
|
{
|
|
//check data table
|
|
}
|
|
|
|
int writeDataSrv::HandleMsg(const msg_t msg,msg_t &outMsg, handparam_t *param)
|
|
{
|
|
//check param table
|
|
json tmjson, repjson, repjson1,datajson, dataarray;
|
|
int iRet=0;
|
|
|
|
try {
|
|
tmjson = json::parse(msg.payload);
|
|
|
|
auto cdtjson = tmjson["data"]["reqdata"] ;
|
|
bool fRet = writeDataDb(param->pDbHandle, cdtjson, datajson);
|
|
if (fRet){
|
|
for (auto vljson:datajson){
|
|
vljson["metid"]="0";
|
|
vljson["afn"]="04";
|
|
vljson["dataid"]="E0000100";
|
|
vljson["createdtime"] = "2025";
|
|
vljson["source"] = "sys.dbc";
|
|
vljson["databuff"] = "010202";
|
|
dataarray.push_back(vljson);
|
|
}
|
|
repjson["dataarray"] = dataarray;
|
|
repjson["complete"] = "1";
|
|
repjson1["data"] = repjson;
|
|
repjson1["time"] = "2025";
|
|
repjson1["token"] = "11223344";
|
|
}else{
|
|
repjson["dataarray"] = NULL;
|
|
repjson["complete"] = "1";
|
|
repjson1["data"] = repjson;
|
|
repjson1["time"] = "2025";
|
|
repjson1["token"] = "11223344";
|
|
}
|
|
msg_t msg_rep;
|
|
msg_rep.payload = repjson1.dump();
|
|
msg_rep.topic = msg.topic;
|
|
outMsg = msg_rep;
|
|
iRet=1;
|
|
|
|
/*
|
|
if (!WriteResponseMsg(msg_rep)){
|
|
std::cerr << " WriteResponseMsg error " << std::endl;
|
|
iRet=0;
|
|
}else{
|
|
iRet=1;
|
|
}
|
|
*/
|
|
}
|
|
catch(json::parse_error& ex){
|
|
std::cerr << "parse error at byte " << ex.byte << std::endl;
|
|
return 0;
|
|
}
|
|
|
|
return iRet;
|
|
}
|
|
|
|
|
|
|
|
std::string writeDataSrv::GetFID(void)
|
|
{
|
|
return std::string("F-WriteData");
|
|
}
|
|
|
|
|
|
REGISTER_BIZSERVICE("F-WriteData", writeDataSrv);
|