|
|
@@ -32,7 +32,8 @@
|
|
|
#include "EntityBootStruct.h"
|
|
|
#include "RestfulFunc.h"
|
|
|
|
|
|
-#include "api_manage_regist.h"
|
|
|
+#include "api_manage_list.h"
|
|
|
+#include "api_manufacture_controller.h"
|
|
|
#include "JsonConvertHelper.hpp"
|
|
|
|
|
|
using namespace std;
|
|
|
@@ -2655,6 +2656,7 @@ void CHealthManagerEntity::DeployTerminal(SpReqAnsContext<HealthManagerService_D
|
|
|
pConfig->WriteConfigValue("TerminalDeploy", "ServerIP", NULL);
|
|
|
pConfig->WriteConfigValue("TerminalDeploy", "HeadOfficeMode", NULL);
|
|
|
pConfig->WriteConfigValue("TerminalDeploy", "InstallVersion", NULL);
|
|
|
+ pConfig->WriteConfigValue("TerminalDeploy", "LastInfo", NULL);
|
|
|
}
|
|
|
break;
|
|
|
case DeployStep_FetchCenterSettings:
|
|
|
@@ -2761,6 +2763,7 @@ void CHealthManagerEntity::DeployTerminal(SpReqAnsContext<HealthManagerService_D
|
|
|
|
|
|
bool toRecord(false);
|
|
|
bool fHeadOfficeMode(false);
|
|
|
+ CSimpleStringA matchInfo(true);
|
|
|
|
|
|
if (ctx->Req.param1 == 0) { //走分行服务
|
|
|
CTerminalInfoQuery* pCnn = new CTerminalInfoQuery(this);
|
|
|
@@ -2794,25 +2797,47 @@ void CHealthManagerEntity::DeployTerminal(SpReqAnsContext<HealthManagerService_D
|
|
|
fHeadOfficeMode = true;
|
|
|
HttpClientRequestConfig config(serverIP.GetData());
|
|
|
HttpClientResponseResult result;
|
|
|
- config.SetChildUri(CSimpleStringA(URLPATH_TERMINAL_REGISTER_INFO).Append(terminalNo).GetData());
|
|
|
+ config.SetChildUri(URLPATH_REGISTER_FULL_LIST);
|
|
|
+ config.AppendQuery("terminalNo", terminalNo.GetData());
|
|
|
RestfulClient client = RestfulClient::getInstance();
|
|
|
client.Do(config, result);
|
|
|
- if (result.statusCode == HttpStatusCode::OK) {
|
|
|
-
|
|
|
+ if (result.ConsiderAsSucc()) {
|
|
|
struct CommResponseJson : public MicroServices::API::CommResponse {
|
|
|
JSONCONVERT2OBJECT_MEMEBER_REGISTER(success, errorCode, returnCode, errorMsg, message)
|
|
|
};
|
|
|
CommResponseJson reponseStatus;
|
|
|
|
|
|
- struct RegistInfoJson : public MicroServices::API::Manage::RegistInfo {
|
|
|
- JSONCONVERT2OBJECT_MEMEBER_REGISTER(branchNo, deviceNo, initIP, machineNo, machineType, machineVersion, sites, terminalNo)
|
|
|
+ struct RegistInfoJson : public MicroServices::API::Manage::RegistDetailInfo {
|
|
|
+ JSONCONVERT2OBJECT_MEMEBER_REGISTER(branchNo, deviceNo, initIP, machineNo, machineType, machineVersion, sites, terminalNo, manufactureID, manufacturerName, deviceTye)
|
|
|
} terminalRegistInfo;
|
|
|
|
|
|
Json::Value rawRoot;
|
|
|
- if (GetJsonRootObject(rawRoot, result.content)
|
|
|
- && Json2Object(reponseStatus, rawRoot) && reponseStatus.IsReqBusinessSucc()
|
|
|
- && Json2Object(terminalRegistInfo, rawRoot["data"])) {
|
|
|
-
|
|
|
+ bool testSucc(false);
|
|
|
+ do
|
|
|
+ {
|
|
|
+ if (!GetJsonRootObject(rawRoot, result.content)) {
|
|
|
+ Dbg("%d", __LINE__);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ if (!Json2Object(reponseStatus, rawRoot)) {
|
|
|
+ Dbg("%d", __LINE__);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ if (!reponseStatus.IsReqBusinessSucc()) {
|
|
|
+ Dbg("%d", __LINE__);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ if (!(rawRoot["data"].size() > 0)) {
|
|
|
+ Dbg("%d", __LINE__);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ if (!Json2Object(terminalRegistInfo, rawRoot["data"][0])) {
|
|
|
+ Dbg("%d", __LINE__);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ testSucc = true;
|
|
|
+ } while (false);
|
|
|
+ if (testSucc) {
|
|
|
auto printFunc = [&terminalRegistInfo]() {
|
|
|
Dbg("TerminalNo: %s", terminalRegistInfo.terminalNo.c_str());
|
|
|
Dbg("BranchNo: %s", terminalRegistInfo.branchNo.c_str());
|
|
|
@@ -2822,7 +2847,52 @@ void CHealthManagerEntity::DeployTerminal(SpReqAnsContext<HealthManagerService_D
|
|
|
Dbg("MachineType: %s", terminalRegistInfo.machineType.c_str());
|
|
|
Dbg("MachineVersion: %s", terminalRegistInfo.machineVersion.c_str());
|
|
|
Dbg("Sites: %s", terminalRegistInfo.sites.c_str());
|
|
|
+ Dbg("manufactureID: %s", terminalRegistInfo.manufactureID.c_str());
|
|
|
+ Dbg("manufacturerName: %s", terminalRegistInfo.manufacturerName.c_str());
|
|
|
+ /** Agent: 终端设备型号*/
|
|
|
+ Dbg("deviceTye: %s", terminalRegistInfo.deviceTye.c_str());
|
|
|
};
|
|
|
+
|
|
|
+ printFunc();
|
|
|
+
|
|
|
+ if (!terminalRegistInfo.manufactureID.empty() && terminalRegistInfo.manufacturerName.empty()) {
|
|
|
+ CommResponseJson reponseStatus2;
|
|
|
+ HttpClientResponseResult result2;
|
|
|
+ Json::Value rawRoot2;
|
|
|
+ config.SetChildUri(URLPATH_MANUFACTURE_GET_ALL);
|
|
|
+ config.ResetQuery();
|
|
|
+ client.Do(config, result2);
|
|
|
+ bool fetchManufactureDone(false);
|
|
|
+ if (result2.ConsiderAsSucc() && GetJsonRootObject(rawRoot2, result2.content)
|
|
|
+ && Json2Object(reponseStatus2, rawRoot2) && reponseStatus2.IsReqBusinessSucc()) {
|
|
|
+ struct ManufactureInfoJson : public MicroServices::API::Manufacture::ManufactureInfo {
|
|
|
+ JSONCONVERT2OBJECT_MEMEBER_REGISTER(manufacturerId, manufacturerName)
|
|
|
+ };
|
|
|
+ struct ManufactureList {
|
|
|
+ std::vector<ManufactureInfoJson> data;
|
|
|
+ JSONCONVERT2OBJECT_MEMEBER_REGISTER(data)
|
|
|
+ } manufactureList;
|
|
|
+ if (Json2Object(manufactureList, rawRoot2)) {
|
|
|
+ for (auto it = manufactureList.data.begin(); it != manufactureList.data.end(); ++it) {
|
|
|
+ if (it->manufacturerId.compare(terminalRegistInfo.manufactureID) == 0) {
|
|
|
+ terminalRegistInfo.manufacturerName = it->manufacturerName;
|
|
|
+ Dbg("get manufacturer name: %s", terminalRegistInfo.manufacturerName.c_str());
|
|
|
+ fetchManufactureDone = true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!fetchManufactureDone) {
|
|
|
+ if (reponseStatus2.IsPadded() && !reponseStatus2.IsReqBusinessSucc()) {
|
|
|
+ Dbg("请求失败:%s", reponseStatus2.WhatError().c_str());
|
|
|
+ } else {
|
|
|
+ Dbg("解析返回内容失败:%s", result2.content.c_str());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
printFunc();
|
|
|
|
|
|
if (terminalRegistInfo.terminalNo.empty()) {
|
|
|
@@ -2834,24 +2904,46 @@ void CHealthManagerEntity::DeployTerminal(SpReqAnsContext<HealthManagerService_D
|
|
|
, terminalNo.GetData(), terminalRegistInfo.terminalNo.c_str());
|
|
|
} else {
|
|
|
bool bMatched(true);
|
|
|
+
|
|
|
if (strTerminalType.Compare(terminalRegistInfo.machineType.c_str()) != 0) {
|
|
|
- Dbg("终端类型不匹配!输入为:%s,查询为:%s", strTerminalType.GetData(), terminalRegistInfo.machineType.c_str());
|
|
|
+ if (!matchInfo.IsNullOrEmpty()) { matchInfo += "|"; }
|
|
|
+ matchInfo += CSimpleStringA::Format("终端类型不匹配:[%s]vs[%s]", strTerminalType.GetData(), terminalRegistInfo.machineType.c_str());
|
|
|
bMatched = false;
|
|
|
}
|
|
|
+ if (strVendorName.Compare(terminalRegistInfo.manufacturerName.c_str()) != 0) {
|
|
|
+ if (!matchInfo.IsNullOrEmpty()) { matchInfo += "|"; }
|
|
|
+ matchInfo += CSimpleStringA::Format("设备厂商不匹配:[%s]vs[%s];", strVendorName.GetData(), terminalRegistInfo.manufacturerName.c_str());
|
|
|
+ bMatched = false;
|
|
|
+ }
|
|
|
+ if (strDeviceModel.Compare(terminalRegistInfo.deviceTye.c_str()) != 0) {
|
|
|
+ if (!matchInfo.IsNullOrEmpty()) { matchInfo += "|"; }
|
|
|
+ matchInfo += CSimpleStringA::Format("设备型号不匹配:[%s]vs[%s];", strDeviceModel.GetData(), terminalRegistInfo.deviceTye.c_str());
|
|
|
+ bMatched = false;
|
|
|
+ }
|
|
|
+ /** Agent: 设备编号*/
|
|
|
if (strDeviceSN.Compare(terminalRegistInfo.machineNo.c_str()) != 0) {
|
|
|
- Dbg("设备序列号不匹配!输入为:%s,查询为:%s", strDeviceSN.GetData(), terminalRegistInfo.machineNo.c_str());
|
|
|
+ matchInfo += CSimpleStringA::Format("设备序列号不匹配:[%s]vs[%s];", strDeviceSN.GetData(), terminalRegistInfo.machineNo.c_str());
|
|
|
bMatched = false;
|
|
|
}
|
|
|
/** 其他信息的校验和应用 [Gifur@2022123]*/
|
|
|
- toRecord = true;
|
|
|
+ if (!bMatched) {
|
|
|
+ //tmpResult = Error_DataCheck;
|
|
|
+ tmpMsg = matchInfo;
|
|
|
+ } else {
|
|
|
+ //toRecord = true;
|
|
|
+ }
|
|
|
+ toRecord = true;
|
|
|
}
|
|
|
} else {
|
|
|
if (reponseStatus.IsPadded() && !reponseStatus.IsReqBusinessSucc()) {
|
|
|
tmpResult = Error_DataCheck;
|
|
|
tmpMsg = CSimpleStringA::Format("请求失败:%s", reponseStatus.WhatError().c_str());
|
|
|
+ Dbg(tmpMsg);
|
|
|
} else {
|
|
|
tmpResult = Error_DataCheck;
|
|
|
tmpMsg = CSimpleStringA::Format("解析返回内容失败:%s", result.content.c_str());
|
|
|
+ Dbg(tmpMsg);
|
|
|
+ Dbg("rawRoot[data].size(): %d", rawRoot["data"].size());
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
|
@@ -2875,7 +2967,9 @@ void CHealthManagerEntity::DeployTerminal(SpReqAnsContext<HealthManagerService_D
|
|
|
const ErrorCodeEnum ec1 = pConfig->WriteConfigValue("TerminalDeploy", "Manufacturer", strVendorName);
|
|
|
const ErrorCodeEnum ec2 = pConfig->WriteConfigValue("TerminalDeploy", "ServerIP", serverIP);
|
|
|
const ErrorCodeEnum ec3 = pConfig->WriteConfigValueInt("TerminalDeploy", "HeadOfficeMode", fHeadOfficeMode ? 1 : 0);
|
|
|
-
|
|
|
+ if (!matchInfo.IsNullOrEmpty()) {
|
|
|
+ pConfig->WriteConfigValue("TerminalDeploy", "LastInfo", matchInfo);
|
|
|
+ }
|
|
|
Dbg("record step: %s, %s, %s", SpStrError(ec0), SpStrError(ec1), SpStrError(ec2), SpStrError(ec3));
|
|
|
} while (false);
|
|
|
|
|
|
@@ -2936,7 +3030,7 @@ void CHealthManagerEntity::DeployTerminal(SpReqAnsContext<HealthManagerService_D
|
|
|
inifile_write_str(strRootTmpFile, "Terminal", "SN", strDeviceSN);
|
|
|
}
|
|
|
} else {
|
|
|
- tmpMsg = "找不到对应的备选配置,请确认选择的机型和设备厂商是否正确";
|
|
|
+ tmpMsg = "harewarecfg下找不到对应的备选配置,请确认选择的机型和设备厂商是否正确";
|
|
|
tmpResult = Error_InvalidState;
|
|
|
}
|
|
|
|
|
|
@@ -3337,11 +3431,6 @@ void CHealthManagerEntity::DeployTerminal(SpReqAnsContext<HealthManagerService_D
|
|
|
CSmartPointer<IConfigInfo> pConfig;
|
|
|
GetFunction()->OpenConfig(Config_Cache, pConfig);
|
|
|
pConfig->WriteConfigValue("TerminalDeploy", "InstallVersion", info.InstallVersion.ToString());
|
|
|
- //int nTemp(0);
|
|
|
- //CSmartPointer<IConfigInfo> pConfig;
|
|
|
- //GetFunction()->OpenConfig(Config_Cache, pConfig);
|
|
|
- //pConfig->ReadConfigValueInt("TerminalDeploy", "HeadOfficeMode", nTemp);
|
|
|
- //SP::Module::Comm::Settings::StoreHeadBranchServicesMode(this, (nTemp > 0));
|
|
|
|
|
|
Dbg("received finish install cmd!");
|
|
|
LogWarn(Severity_High, Error_Debug, LOG_WARN_HEALTH_INSTALL_FINISHED, "install finished");
|