|
|
@@ -338,6 +338,68 @@ namespace HealthMonitor.Service.Biz |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public async Task<bool> SetFetalConfigMockAsync(string serialno, int modeStatus = 0, int maxValue = 0, int minValue = 0, |
|
|
|
int highFreqSampleTimes=0,int highFreqSampleInterval=0,int stopHighFreqSampleCount=0,int triggerHighFreqHigh=0,int triggerHighFreqLow=0) |
|
|
|
{ |
|
|
|
try |
|
|
|
{ |
|
|
|
#region 读取缓存 |
|
|
|
// db7.HashGet("TELPO#GPSDEVICE_WATCH_CONFIG_HASH","861281060086083_0067") |
|
|
|
var watchConfig = await _deviceCacheMgr.GetGpsDeviceWatchConfigCacheObjectBySerialNoAsync(serialno, "0067"); |
|
|
|
if (watchConfig == null) |
|
|
|
{ |
|
|
|
return false; |
|
|
|
} |
|
|
|
#endregion |
|
|
|
|
|
|
|
#region 获取B端 Token |
|
|
|
string tokenAuthData = await getAccessToken2(serialno).ConfigureAwait(false); |
|
|
|
if (tokenAuthData == null) |
|
|
|
{ |
|
|
|
return false; |
|
|
|
} |
|
|
|
#endregion |
|
|
|
_logger.LogInformation($" SetFetalConfig Token TelpoManufactorId: {tokenAuthData}"); |
|
|
|
#region 发送到B端 |
|
|
|
List<KeyValuePair<string, string>> headers = new() |
|
|
|
{ |
|
|
|
new KeyValuePair<string, string>("AccessToken", tokenAuthData) |
|
|
|
}; |
|
|
|
|
|
|
|
watchConfig["mode"] = modeStatus; |
|
|
|
watchConfig["triggerHighFreqHigh"] = maxValue == 0 ? (int)watchConfig["triggerHighFreqHigh"]! : maxValue; |
|
|
|
watchConfig["triggerHighFreqLow"] = minValue == 0 ? (int)watchConfig["triggerHighFreqLow"]! : minValue; |
|
|
|
watchConfig["highFreqSampleTimes"]= highFreqSampleTimes == 0 ? (int)watchConfig["highFreqSampleTimes"]! : highFreqSampleTimes; |
|
|
|
watchConfig["highFreqSampleInterval"] = highFreqSampleInterval == 0 ? (int)watchConfig["highFreqSampleInterval"]! : highFreqSampleInterval; |
|
|
|
watchConfig["stopHighFreqSampleCount"] = stopHighFreqSampleCount == 0 ? (int)watchConfig["stopHighFreqSampleCount"]! : stopHighFreqSampleCount; |
|
|
|
watchConfig["triggerHighFreqHigh"] = triggerHighFreqHigh == 0 ? (int)watchConfig["triggerHighFreqHigh"]! : triggerHighFreqHigh; |
|
|
|
watchConfig["triggerHighFreqLow"] = triggerHighFreqLow == 0 ? (int)watchConfig["triggerHighFreqLow"]! : triggerHighFreqLow; |
|
|
|
var data = watchConfig; |
|
|
|
|
|
|
|
var setUrl = $"{_configService.IotCore}/SetFetalConfig"; |
|
|
|
_logger.LogInformation($"{setUrl} 请求 {JsonConvert.SerializeObject(JsonConvert.SerializeObject(data))}"); |
|
|
|
var res = await _httpHelper.HttpToPostAsync(setUrl, data, headers).ConfigureAwait(false); |
|
|
|
_logger.LogInformation($"{setUrl} 响应 {res}"); |
|
|
|
var resJToken = JsonConvert.DeserializeObject(res ?? string.Empty) as JToken; |
|
|
|
return resJToken?["message"]?.ToString().Equals("ok") ?? false; |
|
|
|
//response.Flag = resJToken?["message"]?.ToString().Equals("ok") ?? false; |
|
|
|
//response.Flag = Convert.ToBoolean(resJToken?["succeed"]?.ToString()); |
|
|
|
//if (!response.Flag) |
|
|
|
//{ |
|
|
|
// response.Message = resJToken?["message"]?.ToString()!; |
|
|
|
//} |
|
|
|
#endregion |
|
|
|
} |
|
|
|
catch (Exception ex) |
|
|
|
{ |
|
|
|
_logger.LogError($"{nameof(SetFetalConfig)} 下发胎心检测参数异常:{ex.Message}, {ex.StackTrace}"); |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary> |
|
|
|
/// 下发胎心数据 |
|
|
|
/// </summary> |
|
|
|