|  | @@ -1152,13 +1152,14 @@ void CResistAlarmMng::JudgeAlarm(CResistAlarmMng* pService, CONVERT_RESIST_OVER_
 | 
	
		
			
				|  |  |  	}
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -void CResistAlarmMng::JudgeAlarm(CResistAlarmMng* pService, FRICTION_OVER_LIMIT_INFO* pAlarmSet, time_t show_time, int show_val, eDaoChaPosi posi, eUpOrDownInfo eUpOrDown, void* pMoMpInfo)
 | 
	
		
			
				|  |  | +void CResistAlarmMng::JudgeAlarm(CResistAlarmMng* pService, FRICTION_OVER_LIMIT_INFO* pAlarmSet, time_t show_time, int showval, eDaoChaPosi posi, eUpOrDownInfo eUpOrDown, void* pMoMpInfo)
 | 
	
		
			
				|  |  |  {
 | 
	
		
			
				|  |  |  	if (pAlarmSet == nullptr || pAlarmSet->enable == false) return;
 | 
	
		
			
				|  |  |  	auto pInfo = (ST_MOMP_INFO*)pMoMpInfo;
 | 
	
		
			
				|  |  |  	
 | 
	
		
			
				|  |  |  	bool bNew = false;
 | 
	
		
			
				|  |  |  	ALARM_INFO* pAlarmInfo = nullptr;
 | 
	
		
			
				|  |  | +	int show_val = showval < 0 ? -showval : showval;
 | 
	
		
			
				|  |  |  	bool bAlarm = false, bWarn = false; int alarm_value = show_val, alarm_refer; time_t alarm_time = show_time;
 | 
	
		
			
				|  |  |  	CTime ctAlarmTime = CTime(alarm_time / 1000);
 | 
	
		
			
				|  |  |  	eLowHigh loworhigh = eLowHigh::LH_UNKNOWN; //0:最小值  1:最大值
 | 
	
	
		
			
				|  | @@ -1600,6 +1601,15 @@ void CResistAlarmMng::JudgeAlarm(CResistAlarmMng* pService, RETENSION_FORCE_DROP
 | 
	
		
			
				|  |  |  			pService->m_lstUnConfirmAlarm.push_back(pAlarmInfo);
 | 
	
		
			
				|  |  |  		}
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +		//send
 | 
	
		
			
				|  |  | +		if (bNew) //不再推送
 | 
	
		
			
				|  |  | +		{
 | 
	
		
			
				|  |  | +			rapidjson::StringBuffer buffer;
 | 
	
		
			
				|  |  | +			auto ret = AlarmInfo2Pack(pAlarmInfo, buffer);
 | 
	
		
			
				|  |  | +			const char* output = buffer.GetString();
 | 
	
		
			
				|  |  | +			CAppService::Instance()->GetMgServer()->SendToAllClient(output, buffer.GetLength());
 | 
	
		
			
				|  |  | +		}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  		//主动推送315
 | 
	
		
			
				|  |  |  		if (bNew)
 | 
	
		
			
				|  |  |  		{
 | 
	
	
		
			
				|  | @@ -1665,6 +1675,8 @@ void CResistAlarmMng::JudgeAlarm(CResistAlarmMng* pService, RETENSION_FORCE_DROP
 | 
	
		
			
				|  |  |  							ctAlarmTime.GetAsSystemTime(pAlarm->recoveryTime);
 | 
	
		
			
				|  |  |  						}
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +						//TODO 发送给客户端
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  						g_p315ClientManager->GetTcpClient()->SendAlarmData(pAlarmInfo->zzjno, 2, CTime(pAlarmInfo->time).GetTime(), ctAlarmTime.GetTime(),
 | 
	
		
			
				|  |  |  							pAlarmInfo->type, posi == eSuoBiPosi::SB_FIX ? eDaoChaPosi::DCP_FIX : eDaoChaPosi::DCP_INVERT, pAlarmInfo->level, pAlarm->loworhigh,
 | 
	
		
			
				|  |  |  							TIEDA_ACQ_VALUE(pAlarm->val, TIEDA_VAL_STATE::TVS_AFTER_MOVE), TIEDA_ACQ_VALUE(pAlarm->refer_val, TIEDA_VAL_STATE::TVS_AFTER_MOVE), 0);
 | 
	
	
		
			
				|  | @@ -3348,14 +3360,146 @@ void CResistAlarmMng::ThreadProcMove(DWORD_PTR param)
 | 
	
		
			
				|  |  |  void CResistAlarmMng::ThreadProcMoveFromDB(DWORD_PTR param)
 | 
	
		
			
				|  |  |  {
 | 
	
		
			
				|  |  |  	auto pService = (CResistAlarmMng*)param;
 | 
	
		
			
				|  |  | -	auto ctNow = CTime::GetCurrentTime();
 | 
	
		
			
				|  |  | +	auto ctLast = CTime::GetCurrentTime();
 | 
	
		
			
				|  |  |  	Sleep(2000);
 | 
	
		
			
				|  |  |  	auto pDBConn = CDBConnectPool::Instance()->GetConnection();
 | 
	
		
			
				|  |  |  	do 
 | 
	
		
			
				|  |  |  	{
 | 
	
		
			
				|  |  |  		Sleep(100);   //每100ms 获取一次
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | +		string table_today = fmt::format("rm_move_{:0>4}{:0>2}", ctLast.GetYear(), ctLast.GetMonth());
 | 
	
		
			
				|  |  | +		auto ctNow = CTime::GetCurrentTime();
 | 
	
		
			
				|  |  | +		//加载数据
 | 
	
		
			
				|  |  | +		CString sql = fmt::format("SELECT mo,mp,show_time,start_time,end_time,curr_val,show_val,\
 | 
	
		
			
				|  |  | +			idx,posi,mark,type,sunroof FROM {} WHERE show_time >= '{}' ORDER BY show_time ASC;", table_today, ctLast.Format("%Y-%m-%d %H:%M:%S")).c_str();
 | 
	
		
			
				|  |  | +		ctLast = ctNow;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +       COdbcStatement stmt;
 | 
	
		
			
				|  |  | +	   if (!CDBConnectPool::Instance()->DBQuery(stmt, sql))
 | 
	
		
			
				|  |  | +	   {
 | 
	
		
			
				|  |  | +		   ASSERT(0);
 | 
	
		
			
				|  |  | +		   continue;
 | 
	
		
			
				|  |  | +	   }
 | 
	
		
			
				|  |  | +	   //绑定数据
 | 
	
		
			
				|  |  | +	   int nCol = 1;
 | 
	
		
			
				|  |  | +	   char mo[51], mp[51];
 | 
	
		
			
				|  |  | +	   TIMESTAMP_STRUCT show_time, start_time, end_time;
 | 
	
		
			
				|  |  | +	   int curr_val, show_val;
 | 
	
		
			
				|  |  | +	   uint8_t idx, posi, type, sunroof;
 | 
	
		
			
				|  |  | +	   char mark[100];
 | 
	
		
			
				|  |  | +	   stmt.BindCharCol(nCol++, mo, sizeof(mo));
 | 
	
		
			
				|  |  | +	   stmt.BindCharCol(nCol++, mp, sizeof(mp));
 | 
	
		
			
				|  |  | +	   stmt.BindTimeStampCol(nCol++, &show_time);
 | 
	
		
			
				|  |  | +	   stmt.BindTimeStampCol(nCol++, &start_time);
 | 
	
		
			
				|  |  | +	   stmt.BindTimeStampCol(nCol++, &end_time);
 | 
	
		
			
				|  |  | +	   stmt.BindIntCol(nCol++, &curr_val);
 | 
	
		
			
				|  |  | +	   stmt.BindIntCol(nCol++, &show_val);
 | 
	
		
			
				|  |  | +	   stmt.BindTinyIntCol(nCol++, &idx);
 | 
	
		
			
				|  |  | +	   stmt.BindTinyIntCol(nCol++, &posi);
 | 
	
		
			
				|  |  | +	   stmt.BindCharCol(nCol++, mark, sizeof(mark));
 | 
	
		
			
				|  |  | +	   stmt.BindTinyIntCol(nCol++, &type);
 | 
	
		
			
				|  |  | +	   stmt.BindTinyIntCol(nCol++, &sunroof);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +	   ST_MOMP_INFO* pMompInfo = nullptr;
 | 
	
		
			
				|  |  | +	   auto mg_315_server = g_p315ClientManager->GetTcpClient();
 | 
	
		
			
				|  |  | +	   int nCount = 0;
 | 
	
		
			
				|  |  | +	   //获取数据
 | 
	
		
			
				|  |  | +	   do
 | 
	
		
			
				|  |  | +	   {
 | 
	
		
			
				|  |  | +		   if (stmt.FetchNext() != 0) break;
 | 
	
		
			
				|  |  | +		   //类型条件语句
 | 
	
		
			
				|  |  | +		   auto ePosi = (eDaoChaPosi)posi;
 | 
	
		
			
				|  |  | +		   auto eType = (ePowerName)type;
 | 
	
		
			
				|  |  | +		   if (pMompInfo == nullptr || pMompInfo->mo.compare(mo) != 0 || pMompInfo->mp.compare(mp) != 0)
 | 
	
		
			
				|  |  | +			   pMompInfo = CMonitorObjectMng::Instance()->GetMoMpInfo(string(mo) + "." + mp);
 | 
	
		
			
				|  |  | +		   if (pMompInfo == nullptr) continue;
 | 
	
		
			
				|  |  | +		   CTime ctAlarm = CTime(show_time.year, show_time.month, show_time.day, show_time.hour, show_time.minute, show_time.second);
 | 
	
		
			
				|  |  | +		   time_t show_time_t = ctAlarm.GetTime() * 1000
 | 
	
		
			
				|  |  | +			   + show_time.fraction / 1000000;
 | 
	
		
			
				|  |  | +		   nCount++;
 | 
	
		
			
				|  |  | +		   switch (eType)
 | 
	
		
			
				|  |  | +		   {
 | 
	
		
			
				|  |  | +		   case ePowerName::PN_LOCK:
 | 
	
		
			
				|  |  | +		   {
 | 
	
		
			
				|  |  | +			   //报警判断
 | 
	
		
			
				|  |  | +			   if (ePosi == eDaoChaPosi::DCP_FIX)
 | 
	
		
			
				|  |  | +			   {
 | 
	
		
			
				|  |  | +				   auto pFixSuobiOverInfo = (SUOBI_OVER_LIMIT_INFO*)pService->Find(mo, mp, (uint8_t)eSuoBiPosi::SB_FIX, eZL_ALARMTYPE::SUOBI_LOCK_LIMIT);
 | 
	
		
			
				|  |  | +				   JudgeAlarm(pService, pFixSuobiOverInfo, show_time_t, show_val, eSuoBiPosi::SB_FIX, mo, mp, pMompInfo->zzjno);
 | 
	
		
			
				|  |  | +			   }
 | 
	
		
			
				|  |  | +			   else if (ePosi == eDaoChaPosi::DCP_INVERT)
 | 
	
		
			
				|  |  | +			   {
 | 
	
		
			
				|  |  | +				   auto pInvertSuobiOverInfo = (SUOBI_OVER_LIMIT_INFO*)pService->Find(mo, mp, (uint8_t)eSuoBiPosi::SB_INVERT, eZL_ALARMTYPE::SUOBI_LOCK_LIMIT);
 | 
	
		
			
				|  |  | +				   JudgeAlarm(pService, pInvertSuobiOverInfo, show_time_t, show_val, eSuoBiPosi::SB_INVERT, mo, mp, pMompInfo->zzjno);
 | 
	
		
			
				|  |  | +			   }
 | 
	
		
			
				|  |  | +		   }
 | 
	
		
			
				|  |  | +			   break;
 | 
	
		
			
				|  |  | +		   case ePowerName::PN_RETENTION:
 | 
	
		
			
				|  |  | +		   {
 | 
	
		
			
				|  |  | +			   if (ePosi == eDaoChaPosi::DCP_FIX)
 | 
	
		
			
				|  |  | +			   {
 | 
	
		
			
				|  |  | +				   auto pFixConstRetensionForceWaveInfo = (RETENSION_FORCE_DROP*)pService->Find(mo, mp, (uint8_t)eSuoBiPosi::SB_FIX, eZL_ALARMTYPE::RETENSION_FORCE);
 | 
	
		
			
				|  |  | +				   JudgeAlarm(pService, pFixConstRetensionForceWaveInfo, show_time_t, show_val, eSuoBiPosi::SB_FIX, mo, mp, pMompInfo);
 | 
	
		
			
				|  |  | +			   }
 | 
	
		
			
				|  |  | +			   else if (ePosi == eDaoChaPosi::DCP_INVERT)
 | 
	
		
			
				|  |  | +			   {
 | 
	
		
			
				|  |  | +				   auto pInvertConstRetensionForceWaveInfo = (RETENSION_FORCE_DROP*)pService->Find(mo, mp, (uint8_t)eSuoBiPosi::SB_INVERT, eZL_ALARMTYPE::RETENSION_FORCE);
 | 
	
		
			
				|  |  | +				   JudgeAlarm(pService, pInvertConstRetensionForceWaveInfo, show_time_t, show_val, eSuoBiPosi::SB_INVERT, mo, mp, pMompInfo);
 | 
	
		
			
				|  |  | +			   }
 | 
	
		
			
				|  |  | +		   }
 | 
	
		
			
				|  |  | +			   break;
 | 
	
		
			
				|  |  | +		   case ePowerName::PN_MOVE:
 | 
	
		
			
				|  |  | +		   {
 | 
	
		
			
				|  |  | +			   //转换阻力报警设置项
 | 
	
		
			
				|  |  | +			   auto pConvertResistOverLimitInfo =
 | 
	
		
			
				|  |  | +				   (CONVERT_RESIST_OVER_LIMIT*)pService->Find(mo, mp, 2, eZL_ALARMTYPE::CONVERT_LIMIT);
 | 
	
		
			
				|  |  | +			   if (ePosi == eDaoChaPosi::DCP_FIX2INVERT)
 | 
	
		
			
				|  |  | +			   {
 | 
	
		
			
				|  |  | +				   //更新状态
 | 
	
		
			
				|  |  | +				   CMonitorObjectMng::Instance()->UpdateZZJEPOS(string(mo) + "." + mp, DAOCHA_POSITION::MP_INVERT);
 | 
	
		
			
				|  |  | +				   SPDLOG_INFO("{}:{} 更新到反位", mo, mp);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +				   if (pMompInfo->out_name.find("定扳反") != -1)
 | 
	
		
			
				|  |  | +						JudgeAlarm(pService, pConvertResistOverLimitInfo, show_time_t, show_val, ePosi, eUpOrDownInfo::UOD_DOWN, mo, mp, pMompInfo->zzjno);
 | 
	
		
			
				|  |  | +				   else if (pMompInfo->in_name.find("定扳反") != -1)
 | 
	
		
			
				|  |  | +					   JudgeAlarm(pService, pConvertResistOverLimitInfo, show_time_t, show_val, ePosi, eUpOrDownInfo::UOD_UP, mo, mp, pMompInfo->zzjno);
 | 
	
		
			
				|  |  | +			   }
 | 
	
		
			
				|  |  | +			   else if (ePosi == eDaoChaPosi::DCP_INVERT2FIX)
 | 
	
		
			
				|  |  | +			   {
 | 
	
		
			
				|  |  | +				   //更新状态
 | 
	
		
			
				|  |  | +				   CMonitorObjectMng::Instance()->UpdateZZJEPOS(string(mo) + "." + mp, DAOCHA_POSITION::MP_FIX);
 | 
	
		
			
				|  |  | +				   SPDLOG_INFO("{}:{} 更新到定位", mo, mp);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +				   if (pMompInfo->out_name.find("反扳定") != -1)
 | 
	
		
			
				|  |  | +					   JudgeAlarm(pService, pConvertResistOverLimitInfo, show_time_t, show_val, ePosi, eUpOrDownInfo::UOD_DOWN, mo, mp, pMompInfo->zzjno);
 | 
	
		
			
				|  |  | +				   else if (pMompInfo->in_name.find("反扳定") != -1)
 | 
	
		
			
				|  |  | +					   JudgeAlarm(pService, pConvertResistOverLimitInfo, show_time_t, show_val, ePosi, eUpOrDownInfo::UOD_UP, mo, mp, pMompInfo->zzjno);
 | 
	
		
			
				|  |  | +			   }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +				//TODO发送315曲线
 | 
	
		
			
				|  |  | +				// mg_315_server->SendCurveData(pMompInfo->zzjno, posi, 1, true, mapData, it.tmStart, it.tmEnd);
 | 
	
		
			
				|  |  | +		   }
 | 
	
		
			
				|  |  | +			   break;
 | 
	
		
			
				|  |  | +		   case ePowerName::PN_FRICTION:
 | 
	
		
			
				|  |  | +		   {
 | 
	
		
			
				|  |  | +			   //摩擦力
 | 
	
		
			
				|  |  | +			   auto pAlarmSet = (FRICTION_OVER_LIMIT_INFO*)pService->Find(mo, mp, 2, eZL_ALARMTYPE::FRICTION_OVER_LIMIT);
 | 
	
		
			
				|  |  | +			   JudgeAlarm(pService, pAlarmSet, show_time_t, show_val, eDaoChaPosi::DCP_UNKNOWN, show_val < 0 ? eUpOrDownInfo::UOD_DOWN : eUpOrDownInfo::UOD_UP, pMompInfo);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +			   //TODO发送315曲线
 | 
	
		
			
				|  |  | +			   //mg_315_server->SendCurveData(pMompInfo->zzjno, posi, 1, true, mapData, it.tmStart, it.tmEnd);
 | 
	
		
			
				|  |  | +		   }
 | 
	
		
			
				|  |  | +			   break;
 | 
	
		
			
				|  |  | +		   default:
 | 
	
		
			
				|  |  | +			   SPDLOG_WARN("[扳动数据有误]{}:{} type:{}", mo, mp, type);
 | 
	
		
			
				|  |  | +			   ASSERT(0);
 | 
	
		
			
				|  |  | +			   break;
 | 
	
		
			
				|  |  | +		   }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +	   } while (true);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +	   stmt.Close();
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +	   SPDLOG_INFO("外部加载扳动数据:{}条 语句:{}", nCount, sql);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  	} while (pService->m_bWork);
 | 
	
		
			
				|  |  |  	CDBConnectPool::Instance()->FreeConnection(pDBConn);
 |