Prechádzať zdrojové kódy

#IQRV #comment [Healthmanager] 配置重启流程梳理

gifur 4 rokov pred
rodič
commit
69183a5d9a

+ 1 - 1
Module/mod_healthmanager/EntityBootStruct.h

@@ -119,7 +119,7 @@ struct OperatingStep : public BootStep
 
 struct TerminalDeployStep : public BootStep
 {
-    TerminalDeployStep(const CSimpleStringA& sectionPosix)
+    TerminalDeployStep(const CSimpleStringA& noUsed)
         : BootStep(CSimpleStringA("TerminalDeploy"))
     {
     }

+ 12 - 2
Module/mod_healthmanager/HealthManagerFSM.cpp

@@ -197,7 +197,7 @@ ErrorCodeEnum CHealthManagerFSM::Initial()
     CSimpleStringA sysinfoPath = "";
 
 #if defined(RVC_OS_LINUX)
-    if (m_sysInfo.strMachineType.Compare("RVC.Stand2S") != 0) {
+    if (!m_sysInfo.strMachineType.IsNullOrEmpty() && m_sysInfo.strMachineType.Compare("RVC.Stand2S") != 0) {
         CSimpleStringA strErrMsg = CSimpleStringA::Format("当前版本不支持此机型:%s", (LPCTSTR)m_sysInfo.strMachineType);
         SP::Module::Comm::LogErrorNotiyStruct notifyItem(Error_NotSupport, 0);
         SP::Module::Comm::LogNotiyMessageStruct notifyMsg(strErrMsg);
@@ -1276,6 +1276,10 @@ int CHealthManagerFSM::WaitDeamonFinish()
 		//Sleep(5000);
 	}
 
+	/** 添加此操作以让状态机停留在s0状态 [Gifur@20211017]*/
+	if (mCofigMode) {
+		return 1;
+	}
 	return 0;
 }
 int CHealthManagerFSM::DoInitialization()
@@ -2077,9 +2081,15 @@ void CHealthManagerFSM::DeviceReConnect()
 
 int CHealthManagerFSM::QuitFrameworkAndSaveInfo(RebootTriggerEnum eTrigger, RebootWayEnum eWay)
 {
+	LOG_FUNCTION();
+
 	CSmartPointer<IEntityFunction> pFunc = GetEntityBase()->GetFunction();
 	CSmartPointer<IEntityFunctionPrivilege> pFuncPrivilege = pFunc.ConvertCase<IEntityFunctionPrivilege>();
-	Dbg("quit framework and info %d,%d.", eTrigger, eWay);
+	if (pFuncPrivilege == NULL) {
+		Dbg("has no privilege");
+		return (int)(Error_NoPrivilege);
+	}
+	Dbg("quit framework and info %d, %d.", eTrigger, eWay);
 	const auto result = pFuncPrivilege->Reboot(eTrigger, eWay);
 	return (int)result;
 }

+ 7 - 1
Module/mod_healthmanager/HealthManagerFSM.h

@@ -189,7 +189,7 @@ public:
 	,m_bAccessAuth(false),m_bACFailed(false),m_pInitClient(NULL),m_bInitSuc(false),m_bInitFail(false)
 	, m_bIdleToMaintain(false), m_custMngerState(0), m_pDevCtrlClient(NULL), m_bHasAuthEver(false)
 	, m_checkCode(""), m_accessAuthCheckMD5(0), m_havReceiveMD5OK(0), m_bFirstAccessAuth(true), m_bEverAuthSucWithDevice(false)
-	, m_bIEBeforeHealth(false), m_hasCfgGpioInRootIni(false), m_csErrEntity("") {}
+	, m_bIEBeforeHealth(false), m_hasCfgGpioInRootIni(false), m_csErrEntity(""), mCofigMode(false) {}
 	~CHealthManagerFSM(){}
 	virtual ErrorCodeEnum OnInit();
 	virtual ErrorCodeEnum OnExit();
@@ -231,6 +231,10 @@ public:
 	void s11_on_exit();
 	unsigned int s11_on_event(FSMEvent* pEvt);
 
+	void SetConfigMode(bool inConfig = true) {
+		mCofigMode = inConfig;
+	}
+
 	ErrorCodeEnum Initial();
 
 	//¸Ãº¯Êý½¨Òé·ÏÆú
@@ -306,6 +310,8 @@ private:
 	DeviceControlService_ClientBase *m_pDevCtrlClient;
 	HANDLE m_hMD5OKEvt;
 	CSystemStaticInfo m_sysInfo;
+
+	bool mCofigMode;
 };
 
 struct WaitDeamonFinishTask : public ITaskSp

+ 4 - 1
Module/mod_healthmanager/HealthManager_def_g.h

@@ -249,6 +249,9 @@ struct HealthManagerService_DeployTerminal_Req
 	int currStep;
 	int preStep;
 	int nextStep;
+	unsigned int additional;
+	bool restartApp;
+	bool restartPC;
 	unsigned int param1;
 	unsigned int param2;
 	CSimpleStringA param3;
@@ -259,7 +262,7 @@ struct HealthManagerService_DeployTerminal_Req
 
 	void Serialize(SpBuffer &Buf)
 	{
-		auto & buf = Buf & currStep & preStep & nextStep & param1 & param2 & param3 & param4 & param5 & array1 & array2;
+		auto & buf = Buf & currStep & preStep & nextStep & additional & restartApp & restartPC & param1 & param2 & param3 & param4 & param5 & array1 & array2;
 	}
 
 };

+ 4 - 0
Module/mod_healthmanager/Healthmanager.xml

@@ -117,6 +117,10 @@
         <param name="currStep" type="int" />
         <param name="preStep" type="int" />
         <param name="nextStep" type="int" />
+        <!--0:没有其他操作;1:重命名root.ini-->
+        <param name="additional" type="uint"/>
+        <param name="restartApp" type="bool"/>
+        <param name="restartPC" type="bool"/>
         <param name="param1" type="uint"/>
         <param name="param2" type="uint" />
         <param name="param3" type="string" />

+ 66 - 70
Module/mod_healthmanager/mod_healthmanager.cpp

@@ -199,8 +199,8 @@ void CHealthManagerEntity::OnStarted()
         int count = 1;
         osutil_detect_unique_app(relates, array_size(relates), &count, processes);
         if (count > 0) {
+			Dbg("to kill guardian process which is seem alive.");
             osutil_terminate_related_process(relates, array_size(relates));
-			Dbg("need to kill guardian process");
         }
 
 		if (curStep >= 0) {
@@ -223,9 +223,11 @@ void CHealthManagerEntity::OnStarted()
 			switch (i) {
 			case 1: //root.ini配置完成后需要继续进行配置,下载集中配置和初始化
 			{
+				Dbg("Second Boot Step.");
                 LOG_ASSERT(!machineType.IsNullOrEmpty());
                 std::shared_ptr<TerminalDeploySecondStep> secSteper(nullptr);
                 secSteper = std::make_shared<TerminalDeploySecondStep>(machineType);
+				secSteper->LoadConfig(configPath);
                 result = secSteper->StartStartupEntities(this);
                 if (result != Error_Succeed) {
                     return;
@@ -2281,11 +2283,13 @@ void CHealthManagerEntity::DeployTerminal(SpReqAnsContext<HealthManagerService_D
             } else if (terminalNo.Compare(info.TerminalNo) != 0) {
                 result = Error_MisMatched;
             } else {
+
                 ErrorCodeEnum ec(Error_Succeed);
-                CSmartPointer<IConfigInfo> pConfig;
-                GetFunction()->OpenConfig(Config_Cache, pConfig);
+
                 do {
                     Dbg("record to cache...");
+                    CSmartPointer<IConfigInfo> pConfig;
+                    GetFunction()->OpenConfig(Config_Cache, pConfig);
                     const ErrorCodeEnum ec0 = pConfig->WriteConfigValue("TerminalDeploy", "TerminalNo", terminalNo);
                     const ErrorCodeEnum ec1 = pConfig->WriteConfigValue("TerminalDeploy", "Manufacturer", vendorType);
                     const ErrorCodeEnum ec2 = pConfig->WriteConfigValue("TerminalDeploy", "ServerIP", serverIP);
@@ -2349,16 +2353,6 @@ void CHealthManagerEntity::DeployTerminal(SpReqAnsContext<HealthManagerService_D
                 } while (false);
 
                 ctx->Ans.param2 = serverIP;
-                ctx->Ans.nextStep = ctx->Req.nextStep;
-				if (tmpResult == 0) {
-                    pConfig->WriteConfigValueInt("TerminalDeploy", "CurrStep", ctx->Req.nextStep);
-                    pConfig->WriteConfigValueInt("TerminalDeploy", "CurrState", DEPLOYSTATE_NOTINIT);
-				} else {
-                    pConfig->WriteConfigValueInt("TerminalDeploy", "CurrStep", ctx->Req.currStep);
-                    pConfig->WriteConfigValueInt("TerminalDeploy", "CurrState", DEPLOYSTATE_FAILED);
-				}
-                ctx->Ans.result = tmpResult;
-                ctx->Ans.additionalMsg = tmpMsg;
             }
 
         } else {
@@ -2380,9 +2374,6 @@ void CHealthManagerEntity::DeployTerminal(SpReqAnsContext<HealthManagerService_D
         }
 
         ErrorCodeEnum ec(Error_Succeed);
-        CSmartPointer<IConfigInfo> pConfig;
-        GetFunction()->OpenConfig(Config_Cache, pConfig);
-
         Dbg("to connect centersetting...%s::%d", serverIP.GetData(), nPort);
         auto pCenterSettingClient = new CenterSettingService_ClientBase(this);
         ec = pCenterSettingClient->Connect();
@@ -2390,7 +2381,6 @@ void CHealthManagerEntity::DeployTerminal(SpReqAnsContext<HealthManagerService_D
             tmpMsg = CSimpleStringA::Format("连接集中配置模块失败: %s", SpStrError(ec));
             pCenterSettingClient->SafeDelete();
             Dbg("connect to centersetting failed: %s", SpStrError(ec));
-            tmpResult = ec;
         } else {
             CenterSettingService_Download_Req req = {};
             req.strAddr = serverIP;
@@ -2401,23 +2391,12 @@ void CHealthManagerEntity::DeployTerminal(SpReqAnsContext<HealthManagerService_D
             ec = pCenterSettingClient->Download(req, ans, 10000);
             if (ec != Error_Succeed) {
                 tmpMsg = CSimpleStringA::Format("下载集中配置文件请求失败: %s", SpStrError(ec));
-                tmpResult = ec;
                 Dbg("to download failed: %s", SpStrError(ec));
             }
             pCenterSettingClient->GetFunction()->CloseSession();
         }
-
+		tmpResult = ec;
         ctx->Ans.param2 = serverIP;
-        ctx->Ans.nextStep = ctx->Req.nextStep;
-        if (tmpResult == 0) {
-            pConfig->WriteConfigValueInt("TerminalDeploy", "CurrStep", ctx->Req.nextStep);
-            pConfig->WriteConfigValueInt("TerminalDeploy", "CurrState", DEPLOYSTATE_NOTINIT);
-        } else {
-            pConfig->WriteConfigValueInt("TerminalDeploy", "CurrStep", ctx->Req.currStep);
-            pConfig->WriteConfigValueInt("TerminalDeploy", "CurrState", DEPLOYSTATE_FAILED);
-        }
-        ctx->Ans.result = tmpResult;
-        ctx->Ans.additionalMsg = tmpMsg;
     }
     break;
     case DeployStep_AccessAuthorize:
@@ -2475,23 +2454,10 @@ void CHealthManagerEntity::DeployTerminal(SpReqAnsContext<HealthManagerService_D
         }
 
         ctx->Ans.param2 = serverIP;
-        ctx->Ans.nextStep = ctx->Req.nextStep;
-        if (tmpResult == 0) {
-            pConfig->WriteConfigValueInt("TerminalDeploy", "CurrStep", ctx->Req.nextStep);
-            pConfig->WriteConfigValueInt("TerminalDeploy", "CurrState", DEPLOYSTATE_NOTINIT);
-        } else {
-            pConfig->WriteConfigValueInt("TerminalDeploy", "CurrStep", ctx->Req.currStep);
-            pConfig->WriteConfigValueInt("TerminalDeploy", "CurrState", DEPLOYSTATE_FAILED);
-        }
-        ctx->Ans.result = tmpResult;
-        ctx->Ans.additionalMsg = tmpMsg;
     }
     break;
     case DeployStep_MediaConfig:
     {
-        CSmartPointer<IConfigInfo> pConfig;
-		GetFunction()->OpenConfig(Config_Cache, pConfig);
-
         CSimpleStringA strRootTmpFile;
         CSimpleStringA strRootIniFullPath;
 		tmpResult = GetTmpRootFilePath(strRootIniFullPath, strRootTmpFile);
@@ -2531,45 +2497,75 @@ void CHealthManagerEntity::DeployTerminal(SpReqAnsContext<HealthManagerService_D
                 }
             }
 		}
-
-		///**TODO(Gifur@10/16/2021): 抽出来作为一个步骤 */
-		if (Error_Succeed == tmpResult) {
-			Dbg("to covert root.ini");
-            fileutil_copy_file(strRootIniFullPath, strRootTmpFile);
-            fileutil_delete_file(strRootTmpFile);
-			if (!ExistsFileA(strRootIniFullPath)) {
-				tmpResult = Error_IO;
-			} else {
-				Dbg("root.ini has been coverted!");
-			}
-		}
-
-        ctx->Ans.nextStep = ctx->Req.nextStep;
-        if (tmpResult == 0) {
-            pConfig->WriteConfigValueInt("TerminalDeploy", "CurrStep", ctx->Req.nextStep);
-            pConfig->WriteConfigValueInt("TerminalDeploy", "CurrState", DEPLOYSTATE_NOTINIT);
-        } else {
-            pConfig->WriteConfigValueInt("TerminalDeploy", "CurrStep", ctx->Req.currStep);
-            pConfig->WriteConfigValueInt("TerminalDeploy", "CurrState", DEPLOYSTATE_FAILED);
-        }
-        ctx->Ans.result = tmpResult;
-        ctx->Ans.additionalMsg = tmpMsg;
     }
     break;
     case DeployStep_Finished:
     {
-        ErrorCodeEnum ec(Error_Succeed);
-        CSmartPointer<IConfigInfo> pConfig;
-        GetFunction()->OpenConfig(Config_Cache, pConfig);
-        pConfig->WriteConfigValueInt("TerminalDeploy", "CurrStep", ctx->Req.currStep);
-        pConfig->WriteConfigValueInt("TerminalDeploy", "CurrState", DEPLOYSTATE_DONE);
+		result = Error_Succeed;
     }
     break;
     default:
         result = Error_MisMatched;
         break;
     }
+
+	bool restartApp(false), restartPC(false);
+
+	if (result == Error_Succeed) {
+        CSmartPointer<IConfigInfo> pConfig;
+        GetFunction()->OpenConfig(Config_Cache, pConfig);
+        if (tmpResult == 0) {
+
+			if (ctx->Req.additional == 1) //重命名 root.ini
+			{
+                CSimpleStringA strRootTmpFile;
+                CSimpleStringA strRootIniFullPath;
+                tmpResult = GetTmpRootFilePath(strRootIniFullPath, strRootTmpFile);
+				if (!ExistsFileA(strRootTmpFile)) {
+                    tmpMsg = "临时配置文件不存在,无法加载配置文件,请重置后重新进行配置!";
+                    tmpResult = Error_NotExist;
+				} else {
+                    Dbg("rename tmp file to root.ini..");
+                    fileutil_copy_file(strRootIniFullPath, strRootTmpFile);
+                    fileutil_delete_file(strRootTmpFile);
+                    if (!ExistsFileA(strRootIniFullPath)) {
+                        tmpResult = Error_IO;
+                    } else {
+                        Dbg("root.ini has been renamed!");
+                    }
+				}
+			}
+
+            pConfig->WriteConfigValueInt("TerminalDeploy", "CurrStep", ctx->Req.nextStep);
+            pConfig->WriteConfigValueInt("TerminalDeploy", "CurrState", DEPLOYSTATE_NOTINIT);
+
+			restartApp = ctx->Req.restartApp;
+			restartPC = ctx->Req.restartPC;
+
+        } else {
+            pConfig->WriteConfigValueInt("TerminalDeploy", "CurrStep", ctx->Req.currStep);
+            pConfig->WriteConfigValueInt("TerminalDeploy", "CurrState", DEPLOYSTATE_FAILED);
+        }
+	}
+
+    ctx->Ans.result = tmpResult;
+    ctx->Ans.additionalMsg = tmpMsg;
+	ctx->Ans.nextStep = ctx->Req.nextStep;
     ctx->Answer(result);
+
+	if (restartPC) {
+        tmpResult = m_fsm.QuitFrameworkAndSaveInfo(RebootTrigger_ManualLocal, RebootWay_OS);
+        if (tmpResult != 0) {
+            tmpMsg = CSimpleStringA::Format("重启设备失败(%s),请手动重启", SpStrError((ErrorCodeEnum)tmpResult));
+            Dbg(tmpMsg);
+        }
+	} else if (restartApp) {
+        tmpResult = m_fsm.QuitFrameworkAndSaveInfo(RebootTrigger_ManualLocal, RebootWay_Framework);
+        if (tmpResult != 0) {
+            tmpMsg = CSimpleStringA::Format("重启应用失败(%s),请手动重启", SpStrError((ErrorCodeEnum)tmpResult));
+            Dbg(tmpMsg);
+        }
+	}
 }
 
 

+ 5 - 4
Module/mod_healthmanager/mod_healthmanager.h

@@ -108,10 +108,12 @@ public:
 		int curStep(0);
 		bool isNeedConfig = IsNotConfigMode(curStep);
 
-		if (!isNeedConfig) {
+		if (isNeedConfig) {
+            m_fsm.SetConfigMode(true);
+		} else {
 			DoRestart();
-			eErrCode = m_fsm.Init(this);
-		}
+        }
+		eErrCode = m_fsm.Init(this);
 
 		GetFunction()->SubscribeLog(m_uuidUpdate,this,Log_Event,Severity_Middle,Error_IgnoreAll,-1,"UpgradeManager");
 		GetFunction()->SubscribeLog(m_uuidAccessAuth,this,Log_Event,Severity_Middle,Error_IgnoreAll,-1,"AccessAuthorization");
@@ -225,7 +227,6 @@ public:
 	 */
 	bool IsNotConfigMode(int& stepMode);
 
-
 private:
 
 	CHealthManagerFSM m_fsm;

+ 32 - 32
addin/res/ManagerDesktop/guide.html

@@ -106,15 +106,15 @@
                 </div>
             </div>
             <div class="clearboth"></div>
-            <div id="guide_initparam_page" style="margin: 0px auto; width: 1000px; padding-top: 133px; display: none;">
-                <div id="guide_initparam_content" style="margin:0 auto;position:absolute;">
+            <div id="guide_init_param_page" style="margin: 0px auto; width: 1000px; padding-top: 133px; display: none;">
+                <div id="guide_init_param_content" style="margin:0 auto;position:absolute;">
                     <div class="guide_table_top">&nbsp;</div>
                     <div class="margin_bottom_box2 color_background_white" style="min-height:556px;">
                         <div style="padding-top:20px;height:48px;" class="border_bottom" align="center">
                             <div class="guide_sub_tip" style="font-size:18px;">基本信息录入</div>
                         </div>
-                        <div id="initparam_content" style="max-height: 510px; width: 998px;">
-                            <div class="clearboth" style="padding-top:30px;" id="guide_initparam_server_ip">
+                        <div id="init_param_content" style="max-height: 510px; width: 998px;">
+                            <div class="clearboth" style="padding-top:30px;" id="guide_init_param_server_ip">
                                 <div class="pull-left" style="width:330px;">
                                     <div class="text-right guide_input_label">分行服务 IP
                                     </div>
@@ -125,78 +125,78 @@
                                         oncontextmenu="return false;" maxlength="16" value="55.14.131.137">
                                 </div>
                             </div>
-                            <div id="guide_initparam_ip_check" class="pull-left margin-left-10"
+                            <div id="guide_init_param_ip_check" class="pull-left margin-left-10"
                                 style="display:block;margin-top: 5px;">
                                 <button id="ip_connect_check" style="color: #F37253;">连通性测试</button>
                             </div>
-                            <div id="guide_initparam_ip_tips" class="clearboth">
+                            <div id="guide_init_param_ip_tips" class="clearboth">
                                 <div class="pull-left" style="width:330px;">&nbsp;</div>
                                 <div class="pull-left">
-                                    <div class="text-left guide_error hide" id="text_guide_initparam_ip_tips"></div>
+                                    <div class="text-left guide_error hide" id="text_guide_init_param_ip_tips"></div>
                                 </div>
                             </div>
-                            <div id="gui_initparam_audio_output_outfree_div" class="clearboth" style="padding-top:14px;">
+                            <div id="gui_init_param_audio_output_outfree_div" class="clearboth" style="padding-top:14px;">
                                 <div class="pull-left" style="width:330px;">
                                     <div class="text-right guide_input_label">设备厂商</div>
                                 </div>
                                 <div class="controls text-left">
-                                    <div id="gui_initparam_vendor" class="select_on_normal vendor_seleceed_save_btn"
+                                    <div id="gui_init_param_vendor" class="select_on_normal vendor_seleceed_save_btn"
                                         onclick="SelectItem(this)" value="None"></div>
-                                    <div id="gui_initparam_vendor_list" class="select_list hide">
-                                        <div id="gui_initparam_vendor_list_item_0" option="CW" class="select_medium">
+                                    <div id="gui_init_param_vendor_list" class="select_list hide">
+                                        <div id="gui_init_param_vendor_list_item_0" option="CW" class="select_medium">
                                             恒银金融
                                         </div>
-                                        <div id="gui_initparam_vendor_list_item_1" option="KEBA" class="select_medium">
+                                        <div id="gui_init_param_vendor_list_item_1" option="KEBA" class="select_medium">
                                             中钞科堡
                                         </div>
-                                        <div id="gui_initparam_vendor_list_item_2" option="GRG" class="select_medium">
+                                        <div id="gui_init_param_vendor_list_item_2" option="GRG" class="select_medium">
                                             广电运通
                                         </div>
-                                        <div id="gui_initparam_vendor_list_item_3" option="NANTIAN" class="select_medium">
+                                        <div id="gui_init_param_vendor_list_item_3" option="NANTIAN" class="select_medium">
                                             云南南天
                                         </div>
-                                        <div id="gui_initparam_vendor_list_item_4" option="GWI" class="select_medium">
+                                        <div id="gui_init_param_vendor_list_item_4" option="GWI" class="select_medium">
                                             长城信息
                                         </div>
                                     </div>
                                 </div>
                             </div>
-                            <div id="gui_initparam_machine_type_div" class="clearboth" style="padding-top:30px;">
+                            <div id="gui_init_param_machine_type_div" class="clearboth" style="padding-top:30px;">
                                 <div class="pull-left" style="width:330px;">
                                     <div class="text-right guide_input_label">终端机型</div>
                                 </div>
                                 <div class="controls text-left">
-                                    <div id="gui_initparam_machine_type" class="select_on_normal btn_disabled"
+                                    <div id="gui_init_param_machine_type" class="select_on_normal btn_disabled"
                                         onclick="SelectItem(this)" value="RVC.Stand2S">柜式双屏大机</div>
-                                    <div id="gui_initparam_machine_type_list" class="select_list hide">
-                                        <div id="gui_initparam_machine_type_list_item_0" option="RVC.Stand2S" class="select_medium">
+                                    <div id="gui_init_param_machine_type_list" class="select_list hide">
+                                        <div id="gui_init_param_machine_type_list_item_0" option="RVC.Stand2S" class="select_medium">
                                             柜式双屏大机
                                         </div>
                                     </div>
                                 </div>
                             </div>
-                            <div class="clearboth" style="padding-top:30px;" id="guide_initparam_terminal_no">
+                            <div class="clearboth" style="padding-top:30px;" id="guide_init_param_terminal_no">
                                 <div class="pull-left" style="width:330px;">
                                     <div class="text-right guide_input_label">终端号
                                     </div>
                                 </div>
                                 <div class="pull-left input_normal text-left">
-                                    <input id="guide_initparam_terminalno" type="text" autocomplete="off" placeholder=""
+                                    <input id="guide_init_param_terminalno" type="text" autocomplete="off" placeholder=""
                                         onfocus="showInputBorder(this)" onblur="hideInputBorder(this)"
                                         oncontextmenu="return false;" maxlength="10" value="7555980103">
                                 </div>
                             </div>
-                            <div id="guide_initparam_terminalno_tips" class="clearboth">
+                            <div id="guide_init_param_terminalno_tips" class="clearboth">
                                 <div class="pull-left" style="width:330px;">&nbsp;</div>
                                 <div class="pull-left">
-                                    <div class="text-left guide_error hide" id="text_guide_initparam_terminalno_tips"></div>
+                                    <div class="text-left guide_error hide" id="text_guide_init_param_terminalno_tips"></div>
                                 </div>
                             </div>
                             <div class="clearboth" style="height:45px;"></div>
-                            <div id="captive_initparam_btns">
-                                <div id="guide_initparam_btns" class="clearboth" align="center"
+                            <div id="captive_init_param_btns">
+                                <div id="guide_init_param_btns" class="clearboth" align="center"
                                     style="margin-top:50px;margin-bottom:50px;">
-                                    <div id="guide_initparam_next"
+                                    <div id="guide_init_param_next"
                                         style="position: relative;" class="btn_normal_long">
                                         确定</div>
                                 </div>
@@ -247,7 +247,7 @@
                                 <div class="pull-left" style="width:330px;">&nbsp;</div>
                                 <div class="pull-left">
                                     <div class="text-left guide_input_descript" id="text_guide_sync_centersetting_port_tips">
-                                        分行集中配置下载端口通常为:1024
+                                        分行集中配置下载端口通常配置为:1024
                                     </div>
                                 </div>
                             </div>
@@ -270,7 +270,7 @@
                     <div class="guide_table_top">&nbsp;</div>
                     <div class="margin_bottom_box2 color_background_white" style="min-height:556px;">
                         <div style="padding-top:20px;height:48px;" class="border_bottom" align="center">
-                            <div class="guide_sub_tip" style="font-size:18px;">终端认证</div>
+                            <div class="guide_sub_tip" style="font-size:18px;">终端准入</div>
                         </div>
                         <div id="access_authorize_content" style="max-height: 510px; width: 998px;">
                             <div class="clearboth" style="padding-top:30px;" id="guide_access_authorize_server_ip">
@@ -305,7 +305,7 @@
                                 <div class="pull-left" style="width:330px;">&nbsp;</div>
                                 <div class="pull-left">
                                     <div class="text-left guide_input_descript" id="text_guide_access_authorize_port_tips">
-                                        分行终端初始化端口通常为:1031
+                                        分行终端初始化端口通常配置为:1031
                                     </div>
                                 </div>
                             </div>
@@ -372,7 +372,7 @@
                                     <div class="pull-left" style="width:330px;">&nbsp;</div>
                                     <div class="pull-left">
                                         <div class="text-left guide_input_descript" id="text_guide_media_config_audio_ouput_outfree_tips">
-                                            提示:信创设备一般将<strong>话筒扬声器</strong>识别为<strong>内置音频</strong>,如果列表中有识别到内置音频,此处请选择它
+                                            提示:信创设备一般将<strong>话筒扬声器</strong>识别为<strong>内置音频</strong>,如果上述列表中有内置音频,此时请选择它
                                         </div>
                                     </div>
                                 </div>
@@ -418,7 +418,7 @@
                                     <div class="pull-left" style="width:330px;">&nbsp;</div>
                                     <div class="pull-left">
                                         <div class="text-left guide_input_descript" id="text_guide_media_config_audio_ouput_outfree_tips">
-                                            提示:信创设备一般将<strong>话筒麦克风</strong>识别为<strong>内置音频</strong>,如果列表中有识别到内置音频,此处请选择它
+                                            提示:信创设备一般将<strong>话筒麦克风</strong>识别为<strong>内置音频</strong>,如果上述列表中有内置音频,此时请选择它
                                         </div>
                                     </div>
                                 </div>
@@ -440,7 +440,7 @@
                     <div class="guide_table_bottom">&nbsp;</div>
                 </div>
             </div>
-            <div id="guide_finish_page" style="margin: 0px auto; width: 1000px; padding-top: 280px; display: block;">
+            <div id="guide_finish_page" style="margin: 0px auto; width: 1000px; padding-top: 280px; display: none;">
                 <div id="guide_finish_containter" style="margin:0 auto;position:relative;">
                     <div style="margin: 0 auto;width:1000px;position:absolute" class="captive_guide">
                         <div class="guide_step_finish_title"style="padding-top:120px; font-size:28px; font-weight:bold; color:#32CD32;">

+ 91 - 38
addin/res/ManagerDesktop/js/guide.js

@@ -1,10 +1,19 @@
 var CONST = {
-DeployStep_Begin : 0,
-DeployStep_GetTerminalInfo : 1,
-DeployStep_FetchCenterSettings : 2,
-DeployStep_AccessAuthorize : 3,
-DeployStep_MediaConfig : 4,
-DeployStep_Finished : 5
+    DeployStep_Begin : 0,
+    DeployStep_GetTerminalInfo : 1,
+    DeployStep_FetchCenterSettings : 2,
+    DeployStep_AccessAuthorize : 3,
+    DeployStep_MediaConfig : 4,
+    DeployStep_Finished : 5
+};
+
+var SETCTION = {
+    BEGIN:'start',
+    GETTERMINAL_INFO:'init_param',
+    CENTERSETTINGS:'sync_centersetting',
+    ACCESS_AUTHORIZE:'access_authorize',
+    MEDIA_CONFIG:'media_config',
+    FINSHED:'finish',
 };
 
 var MEDIA_TYPE = {
@@ -29,12 +38,11 @@ var VENDOR = {
 };
 
 $(function () {
-
     
     RVC.GuideController = RVC.Object.extend({
         hideAllPage: function () {
             $('#guide_start_page').hide();
-            $('#guide_initparam_page').hide();
+            $('#guide_init_param_page').hide();
             $('#guide_sync_centersetting_page').hide();
             $('#guide_access_authorize_page').hide();
             $('#guide_media_config_page').hide();
@@ -61,19 +69,19 @@ $(function () {
                     $('body').scrollLeft(($('body').width() - $(window).width()) / 2);
                 }, 1000)
             }
-            $('#guide_initparam_page').css('padding-top', adjustHeight + 'px');
+            $('#guide_init_param_page').css('padding-top', adjustHeight + 'px');
         },
         beginInstall: function() {
             this.gotoPage(CONST.DeployStep_GetTerminalInfo);
         },
-        gotoPage: function(nextStep) {
+        getPage: function(step) {
             var select_page = '';
-            switch(nextStep) {
+            switch(step) {
                 case CONST.DeployStep_Begin:
                     select_page = 'guide_start_page';
                     break;
                 case CONST.DeployStep_GetTerminalInfo :
-                    select_page = 'guide_initparam_page';
+                    select_page = 'guide_init_param_page';
                     break;
                 case CONST.DeployStep_FetchCenterSettings:
                     select_page = 'guide_sync_centersetting_page';
@@ -90,14 +98,42 @@ $(function () {
                 default:
                 break;
             }
+            return select_page;
+        },
 
+        checkPageAvailable: function(step) {
+            const select_page = this.getPage(step);
             if(select_page !== '') {
-                this.hideAllPage();
+                return true;
+            } else {
+                return false;
+            }
+        },
+
+        preLoadPage: function(step) {
+            this.hideAllPage();
+            switch(step) {
+                case CONST.DeployStep_MediaConfig:
+                    FulfillMediaDeviceList();
+                    break;
+                default:
+                    break;
+            }
+        },
+        postLoadPage: function(step) {
+
+        },
+        gotoPage: function(nextStep) {
+
+            var select_page = this.getPage(nextStep);
+
+            if(select_page !== '') {
+                this.preLoadPage(nextStep);
                 $('#' + select_page).show();
+                this.postLoadPage(nextStep);
             } else {
                 utilShowToast('无法识别步骤标识:' + nextStep, 3000);
             }
-
         },
         sectOverPass: function() {
 
@@ -150,17 +186,17 @@ $(function () {
 
         function showErrTips(val) {
             setTimeout(function () {
-                $('#text_guide_initparam_ip_tips').addClass('hide');
+                $('#text_guide_init_param_ip_tips').addClass('hide');
             }, 3000);
-            $('#text_guide_initparam_ip_tips').removeClass('hide')
+            $('#text_guide_init_param_ip_tips').removeClass('hide')
             .removeClass('guide_input_descript').addClass('guide_error').html(val);
         }
 
         function showSuccTips(val) {
             setTimeout(function () {
-                $('#text_guide_initparam_ip_tips').addClass('hide');
+                $('#text_guide_init_param_ip_tips').addClass('hide');
             }, 3000);
-            $('#text_guide_initparam_ip_tips').removeClass('hide')
+            $('#text_guide_init_param_ip_tips').removeClass('hide')
             .removeClass('guide_error').addClass('guide_input_descript').html(val);
         }
 
@@ -171,10 +207,8 @@ $(function () {
 
         RVC.DeviceControlEntityCtrl.TestConnectivity(req, function(ret) {
             if(ret.errorCode === 0) {
-                console.log('Ping 返回成功');
                 let result = JSON.parse(ret[RVC.EntityController.sigResponseUUID])
                 if(result.result == 0) {
-                    console.log(ip + ' 可正常连通');
                     showSuccTips('可正常连通');
                 } else {
                     console.log(result.additionalMsg);
@@ -182,7 +216,6 @@ $(function () {
                 }
             } else {
                 let tips = ip + ' 测试连接失败:' + ErrorCodeStringfy(ret.errorCode);
-                console.error(tips);
                 showErrTips(tips);
             }
         });
@@ -195,7 +228,7 @@ $(function () {
             req.preStep = CONST.DeployStep_MediaConfig;
             req.currStep = CONST.DeployStep_FetchCenterSettings;
             req.nextStep = CONST.DeployStep_AccessAuthorize;
-        } else {
+        } else { //准入验证
             req.preStep = CONST.DeployStep_FetchCenterSettings;
             req.currStep = CONST.DeployStep_AccessAuthorize;
             req.nextStep = CONST.DeployStep_Finished;
@@ -204,6 +237,9 @@ $(function () {
         req.param1 = parseInt(port, 10);
         req.param2 = 0;
         req.param3 = server_ip;
+        req.additional = 0;
+        req.restartApp = false;
+        req.restartPC = false;
         req.param4 = '';
         req.param5 = '';
         req.array1 = [0];
@@ -215,7 +251,7 @@ $(function () {
             if(ret.errorCode === 0) {
                 let result = JSON.parse(ret[RVC.EntityController.sigResponseUUID])
                 if(result.result == 0) {
-                    utilStartAlertDialog("操作成功", function() {
+                    utilStartAlertDialog("操作成功,进入下一步", function() {
                         RVC.GuideController.gotoPage(result.nextStep);
                     });
                 } else {
@@ -240,6 +276,9 @@ $(function () {
         req.param5 = '';
         req.array1 = [0];
         req.array2 = [''];
+        req.additional = 0;
+        req.restartApp = false;
+        req.restartPC = false;
 
         utilStartSubmitDialog();
         RVC.HealthmanagerEntityCtrl.DeployTerminal(req, function(ret) {
@@ -247,7 +286,7 @@ $(function () {
             if(ret.errorCode === 0) {
                 let result = JSON.parse(ret[RVC.EntityController.sigResponseUUID])
                 if(result.result == 0) {
-                    utilStartAlertDialog("操作成功", function() {
+                    utilStartAlertDialog("操作成功,进入下一步", function() {
                         RVC.GuideController.gotoPage(result.nextStep);
                     });
 
@@ -311,7 +350,7 @@ $(function () {
     function FulfillMediaDeviceList(flag)
     {
         let req = new Request();
-        req.type = 6; //不需要摄像头配置
+        req.type = 6; //1,2,4不需要摄像头配置
         req.interest = 0;
         req.reserverd1 = 0;
         req.reserverd2 = '';
@@ -402,6 +441,9 @@ $(function () {
         req.preStep = CONST.DeployStep_GetTerminalInfo;
         req.currStep = CONST.DeployStep_MediaConfig;
         req.nextStep = CONST.DeployStep_FetchCenterSettings;
+        req.additional = 1; //重命名root.ini
+        req.restartApp = true;
+        req.restartPC = false;
         req.param1 = 0;
         req.param2 = 0;
         req.param3 = '';
@@ -416,7 +458,7 @@ $(function () {
             if(ret.errorCode === 0) {
                 let result = JSON.parse(ret[RVC.EntityController.sigResponseUUID])
                 if(result.result == 0) {
-                    utilStartAlertDialog("操作成功", function() {
+                    utilStartAlertDialog("操作成功,进入下一步", function() {
                         RVC.GuideController.gotoPage(result.nextStep);
                     });
                 } else {
@@ -429,15 +471,15 @@ $(function () {
 
     }
 
-    $(document).on('click', '#guide_initparam_ip_check #ip_connect_check', function(){
+    $(document).on('click', '#guide_init_param_ip_check #ip_connect_check', function(){
         var ip = $('#guide_server_ip').val();
         console.log('ip: ' + ip);
         IPConnectableTest(ip);
     });
 
-    $(document).on('click', '#guide_initparam_next', function() {
+    $(document).on('click', '#guide_init_param_next', function() {
         const ip = $('#guide_server_ip').val();
-        const terminalno = $('#guide_initparam_terminalno').val();
+        const terminalno = $('#guide_init_param_terminalno').val();
         if(!isValidIpAddress(ip)) {
             utilStartAlertDialog("无效IP格式");
             return;
@@ -447,7 +489,7 @@ $(function () {
             return;
         }
 
-        var vendorType = $('#gui_initparam_vendor').attr('value');
+        var vendorType = $('#gui_init_param_vendor').attr('value');
         if(vendorType === '' || vendorType === 'None') {
             utilStartAlertDialog("请选择设备厂商");
             return;
@@ -481,20 +523,31 @@ $(function () {
         SaveMediaDeviceConfig();
     });
 
-    if (window.location.href.indexOf('guide.html') !== -1) {
-        RVC.GuideController.resizeWindow();
-        RVC.Scroll.initScroll('#initparam_content');
-    }
     if (window.addEventListener) {
         window.addEventListener('resize', RVC.GuideController.resizeWindow, false);
     } else {
         window.attachEvent('resize', RVC.GuideController.resizeWindow);
     }
-    setTimeout(RVC.GuideController.resizeWindow, 200);
 
     RVC.CameraConfigEntity.init();
-    FulfillMediaDeviceList();
 
-    RVC.GuideController.hideAllPage();
-    $('#guide_start_page').show();
+    if (window.location.href.indexOf('guide.html') !== -1) {
+        RVC.GuideController.resizeWindow();
+        RVC.Scroll.initScroll('#init_param_content');
+
+        var hash = window.location.href.split('#')[1];
+        if(hash && IsDigital(hash)) {
+            var step = parseInt(hash, 10);
+            if(RVC.GuideController.checkPageAvailable(step)) {
+                utilStartAlertDialog('点击确认继续上次的配置', function() {
+                    RVC.GuideController.gotoPage(step);
+                });
+            }
+        } else {
+            RVC.GuideController.gotoPage(CONST.DeployStep_Begin);
+        }
+    }
+
+    setTimeout(RVC.GuideController.resizeWindow, 200);
+
 });