You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

583 lines
30KB

  1. using HealthMonitor.Common.helper;
  2. using HealthMonitor.Model.Config;
  3. using HealthMonitor.Service.Resolver;
  4. using Microsoft.Extensions.Logging;
  5. using Microsoft.Extensions.Options;
  6. using Newtonsoft.Json.Linq;
  7. using Newtonsoft.Json;
  8. using System;
  9. using System.Collections.Generic;
  10. using System.Linq;
  11. using System.Text;
  12. using System.Threading.Tasks;
  13. using HealthMonitor.Model.Service;
  14. using TelpoDataService.Util.Entities.GpsCard;
  15. using TelpoDataService.Util;
  16. using TelpoDataService.Util.Clients;
  17. using TelpoDataService.Util.Models;
  18. using TelpoDataService.Util.QueryObjects;
  19. using HealthMonitor.Service.Cache;
  20. using HealthMonitor.Model.Cache;
  21. namespace HealthMonitor.Service.Biz
  22. {
  23. public class IotWebApiService
  24. {
  25. private readonly ServiceConfig _configService;
  26. private readonly ILogger<IotWebApiService> _logger;
  27. private readonly PersonCacheManager _personCacheMgr;
  28. private readonly HttpHelper _httpHelper = default!;
  29. private readonly GpsCardAccessorClient<GpsPerson> _gpsPersonApiClient;
  30. public IotWebApiService(ILogger<IotWebApiService> logger, HttpHelper httpHelper, GpsCardAccessorClient<GpsPerson> gpsPersonApiClient, IOptions<ServiceConfig> optConfigService, PersonCacheManager personCacheMgr)
  31. {
  32. _configService = optConfigService.Value;
  33. _httpHelper=httpHelper;
  34. _logger = logger;
  35. _personCacheMgr = personCacheMgr;
  36. _gpsPersonApiClient = gpsPersonApiClient;
  37. }
  38. /// <summary>
  39. /// 平台下发血压标定参数
  40. /// </summary>
  41. /// <param name="bpsCalibrationConfig"></param>
  42. /// <returns></returns>
  43. public async Task<bool> SetBloodPressCalibrationConfigAsync(BloodPressCalibrationConfigModel bpsCalibrationConfig)
  44. {
  45. #if DEBUG
  46. var flag = true;
  47. #else
  48. //systolicCalibrationValue = 0, //收缩压标定值,值为0 表示不生效
  49. //diastolicCalibrationValue 0, //舒张压标定值,值为0表示不生效
  50. //systolicIncValue = 0, //收缩压显示增量,值为0 表示不生效
  51. //diastolicIncValue = 0 //舒张压显示增量,值为0 表示不生效
  52. var flag = false;
  53. try
  54. {
  55. var url = $"{_configService.IotWebApiUrl}Command/SetBloodPressCalibrationConfig";
  56. List<KeyValuePair<string, string>> headers = new()
  57. {
  58. new KeyValuePair<string, string>("AuthKey", "key1")
  59. };
  60. var res = await _httpHelper.HttpToPostAsync(url, bpsCalibrationConfig, headers).ConfigureAwait(false);
  61. _logger.LogInformation($"向{bpsCalibrationConfig.Imei}下发增量值数据:{JsonConvert.SerializeObject(bpsCalibrationConfig)},响应:{res}");
  62. var resJToken = JsonConvert.DeserializeObject(res ?? string.Empty) as JToken;
  63. flag= resJToken?["message"]?.ToString().Equals("ok") ?? false;
  64. }
  65. catch (Exception ex)
  66. {
  67. _logger.LogError($"{nameof(SetBloodPressCalibrationConfigAsync)} 下发血压增量值异常:{ex.Message}, {ex.StackTrace}");
  68. }
  69. #endif
  70. return flag;
  71. }
  72. /** 取消
  73. /// <summary>
  74. /// 更新 gps_person remark和缓存
  75. /// </summary>
  76. /// <param name="imei"></param>
  77. /// <param name="systolicRefValue"></param>
  78. /// <param name="diastolicRefValue"></param>
  79. /// <returns></returns>
  80. public async Task<bool> UpdatePersonRemarksAsync(string imei,int systolicRefValue,int diastolicRefValue)
  81. {
  82. var flag = false;
  83. try
  84. {
  85. GeneralParam condition = new ()
  86. {
  87. Filters = new List<QueryFilterCondition> {
  88. new QueryFilterCondition {
  89. Key=nameof(GpsDevice.Serialno),
  90. Value=imei,
  91. Operator= QueryOperatorEnum.Equal,
  92. ValueType=QueryValueTypeEnum.String
  93. }
  94. },
  95. OrderBys = new List<OrderByCondition> { new OrderByCondition { Key = "serialno", IsDesc = true } }
  96. };
  97. var person = await _gpsPersonApiClient.GetFirstAsync(condition, new RequestHeader() { RequestId = $"{imei}" }).ConfigureAwait(false);
  98. //// 若remark为空,更新person remark字段
  99. //if (string.IsNullOrWhiteSpace(person?.Remarks))
  100. //{
  101. // var newRemarkData = new
  102. // {
  103. // imei,
  104. // time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  105. // commandValue = new
  106. // {
  107. // systolicCalibrationValue = systolicRefValue, //收缩压标定值,值为0 表示不生效
  108. // diastolicCalibrationValue = diastolicRefValue, //舒张压标定值,值为0表示不生效
  109. // systolicIncValue = 0, //收缩压显示增量,值为0 表示不生效
  110. // diastolicIncValue = 0 //舒张压显示增量,值为0 表示不生效
  111. // }
  112. // };
  113. // person!.Remarks = $"is_blood_press:{JsonConvert.SerializeObject(newRemarkData)}|";
  114. // await _gpsPersonApiClient.UpdateAsync(person, new RequestHeader() { RequestId = $"{imei}" }).ConfigureAwait(false);
  115. // _logger.LogInformation($"更新Person remarks字段|{person.Remarks}");
  116. // // 更新缓存
  117. // var url = $"{_configService.IotWebApiUrl}Device/UpdatePersonInfoCache?imei={imei}";
  118. // List<KeyValuePair<string, string>> headers = new()
  119. // {
  120. // new KeyValuePair<string, string>("AuthKey", "key1")
  121. // };
  122. // var res = await _httpHelper.HttpToGetAsync(url, headers).ConfigureAwait(false);
  123. // _logger.LogInformation($"{imei} 更新缓存{nameof(UpdatePersonRemarksAsync)},响应:{res}");
  124. // var resJToken = JsonConvert.DeserializeObject(res ?? string.Empty) as JToken;
  125. // flag = resJToken?["message"]?.ToString().Equals("ok") ?? false;
  126. //}
  127. var newRemarkData = new
  128. {
  129. imei,
  130. time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  131. commandValue = new
  132. {
  133. systolicCalibrationValue = systolicRefValue, //收缩压标定值,值为0 表示不生效
  134. diastolicCalibrationValue = diastolicRefValue, //舒张压标定值,值为0表示不生效
  135. systolicIncValue = 0, //收缩压显示增量,值为0 表示不生效
  136. diastolicIncValue = 0 //舒张压显示增量,值为0 表示不生效
  137. }
  138. };
  139. person!.Remarks = $"is_blood_press:{JsonConvert.SerializeObject(newRemarkData)}|";
  140. await _gpsPersonApiClient.UpdateAsync(person, new RequestHeader() { RequestId = $"{imei}" }).ConfigureAwait(false);
  141. _logger.LogInformation($"更新Person remarks字段|{person.Remarks}");
  142. // 更新缓存
  143. var url = $"{_configService.IotWebApiUrl}Device/UpdatePersonInfoCache?imei={imei}";
  144. List<KeyValuePair<string, string>> headers = new()
  145. {
  146. new KeyValuePair<string, string>("AuthKey", "key1")
  147. };
  148. var res = await _httpHelper.HttpToGetAsync(url, headers).ConfigureAwait(false);
  149. _logger.LogInformation($"{imei} 更新缓存{nameof(UpdatePersonRemarksAsync)},响应:{res}");
  150. var resJToken = JsonConvert.DeserializeObject(res ?? string.Empty) as JToken;
  151. flag = resJToken?["message"]?.ToString().Equals("ok") ?? false;
  152. }
  153. catch (Exception ex)
  154. {
  155. _logger.LogError($"{nameof(UpdatePersonRemarksAsync)} 更新个人信息异常:{ex.Message}, {ex.StackTrace}");
  156. }
  157. return flag;
  158. }
  159. */
  160. ///// <summary>
  161. ///// 初次开通更新 gps_person remark和对应的缓存
  162. ///// </summary>
  163. ///// <param name="imei"></param>
  164. ///// <param name="systolicRefValue"></param>
  165. ///// <param name="diastolicRefValue"></param>
  166. ///// <param name="systolicIncValue"></param>
  167. ///// <param name="diastolicIncValue"></param>
  168. ///// <returns></returns>
  169. //public async Task<bool> UpdatePersonRemarksAsync0(string imei, int systolicRefValue, int diastolicRefValue,int systolicIncValue,int diastolicIncValue)
  170. //{
  171. // var flag = false;
  172. // try
  173. // {
  174. // GeneralParam condition = new()
  175. // {
  176. // Filters = new List<QueryFilterCondition> {
  177. // new QueryFilterCondition {
  178. // Key=nameof(GpsDevice.Serialno),
  179. // Value=imei,
  180. // Operator= QueryOperatorEnum.Equal,
  181. // ValueType=QueryValueTypeEnum.String
  182. // }
  183. // },
  184. // OrderBys = new List<OrderByCondition> { new OrderByCondition { Key = "serialno", IsDesc = true } }
  185. // };
  186. // var person = await _gpsPersonApiClient.GetFirstAsync(condition, new RequestHeader() { RequestId = $"{imei}" }).ConfigureAwait(false);
  187. // // 若remark为空,更新person remark字段
  188. // if (string.IsNullOrWhiteSpace(person?.Remarks))
  189. // {
  190. // var newRemarkData = new
  191. // {
  192. // imei,
  193. // time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  194. // commandValue = new
  195. // {
  196. // systolicCalibrationValue = systolicRefValue, //收缩压标定值,值为0 表示不生效
  197. // diastolicCalibrationValue = diastolicRefValue, //舒张压标定值,值为0表示不生效
  198. // systolicIncValue, //收缩压显示增量,值为0 表示不生效
  199. // diastolicIncValue //舒张压显示增量,值为0 表示不生效
  200. // }
  201. // };
  202. // person!.Remarks = $"is_blood_press:{JsonConvert.SerializeObject(newRemarkData)}|";
  203. // await _gpsPersonApiClient.UpdateAsync(person, new RequestHeader() { RequestId = $"{imei}" }).ConfigureAwait(false);
  204. // _logger.LogInformation($"更新Person remarks字段|{person.Remarks}");
  205. // // 更新缓存
  206. // var personCache = await _personCacheMgr.GetDeviceGpsPersonCacheObjectBySerialNoAsync(new Guid().ToString(), imei).ConfigureAwait(false);
  207. // if (personCache != null)
  208. // {
  209. // //personCache.Person.Remarks = person!.Remarks;
  210. // personCache["person"]!["remarks"] = person!.Remarks;
  211. // bool cacheFlag= await _personCacheMgr.UpdateDeviceGpsPersonCacheObjectBySerialNoAsync(personCache, imei);
  212. // // flag = true;
  213. // if (cacheFlag)
  214. // {
  215. // flag = true;
  216. // _logger.LogInformation($"{imei} 更新缓存{nameof(UpdatePersonRemarksAsync)}成功,{JsonConvert.SerializeObject(personCache)}");
  217. // }
  218. // else
  219. // {
  220. // flag = false;
  221. // _logger.LogInformation($"{imei} 更新缓存{nameof(UpdatePersonRemarksAsync)}失败,{JsonConvert.SerializeObject(personCache)}");
  222. // }
  223. // }
  224. // //var url = $"{_configService.IotWebApiUrl}Device/UpdatePersonInfoCache?imei={imei}";
  225. // //List<KeyValuePair<string, string>> headers = new()
  226. // //{
  227. // // new KeyValuePair<string, string>("AuthKey", "key1")
  228. // //};
  229. // //var res = await _httpHelper.HttpToGetAsync(url, headers).ConfigureAwait(false);
  230. // //_logger.LogInformation($"{imei} 更新缓存{nameof(UpdatePersonRemarksAsync)},响应:{res}");
  231. // //var resJToken = JsonConvert.DeserializeObject(res ?? string.Empty) as JToken;
  232. // //flag = resJToken?["message"]?.ToString().Equals("ok") ?? false;
  233. // }
  234. // }
  235. // catch (Exception ex)
  236. // {
  237. // _logger.LogError($"{nameof(UpdatePersonRemarksAsync)} 更新个人信息异常:{ex.Message}, {ex.StackTrace}");
  238. // }
  239. // return flag;
  240. //}
  241. /**
  242. /// <summary>
  243. /// 更新 gps_person remark缓存和数据库
  244. /// </summary>
  245. /// <param name="imei"></param>
  246. /// <param name="systolicRefValue"></param>
  247. /// <param name="diastolicRefValue"></param>
  248. /// <param name="systolicIncValue"></param>
  249. /// <param name="diastolicIncValue"></param>
  250. /// <param name="isInitRemakers">是否初始化,即清空remakers</param>
  251. /// <returns></returns>
  252. public async Task<bool> UpdatePersonRemarksAsync(string imei, int systolicRefValue, int diastolicRefValue, int systolicIncValue, int diastolicIncValue, bool isInitRemakers=false)
  253. {
  254. var flag = false;
  255. try
  256. {
  257. // 保证实时性,先更新缓存,再更新数据库
  258. var personCache = await _personCacheMgr.GetDeviceGpsPersonCacheObjectBySerialNoAsync(new Guid().ToString(), imei).ConfigureAwait(false);
  259. if (personCache == null)
  260. {
  261. _logger.LogInformation($"{imei} -- Person remarks数据异常,检查缓存和数据库");
  262. }
  263. else if (string.IsNullOrWhiteSpace(personCache["person"]!["remarks"]!.ToString()))
  264. {
  265. var newRemarkData = new
  266. {
  267. imei,
  268. time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  269. commandValue = new
  270. {
  271. systolicCalibrationValue = systolicRefValue, //收缩压标定值,值为0 表示不生效
  272. diastolicCalibrationValue = diastolicRefValue, //舒张压标定值,值为0表示不生效
  273. systolicIncValue, //收缩压显示增量,值为0 表示不生效
  274. diastolicIncValue //舒张压显示增量,值为0 表示不生效
  275. }
  276. };
  277. var newRemarkStr = isInitRemakers ? string.Empty:$"is_blood_press:{JsonConvert.SerializeObject(newRemarkData)}|";
  278. personCache["person"]!["remarks"] = newRemarkStr;
  279. bool cacheFlag = await _personCacheMgr.UpdateDeviceGpsPersonCacheObjectBySerialNoAsync(personCache, imei);
  280. if (cacheFlag)
  281. {
  282. GeneralParam condition = new()
  283. {
  284. Filters = new List<QueryFilterCondition> {
  285. new QueryFilterCondition {
  286. Key=nameof(GpsDevice.Serialno),
  287. Value=imei,
  288. Operator= QueryOperatorEnum.Equal,
  289. ValueType=QueryValueTypeEnum.String
  290. }
  291. },
  292. OrderBys = new List<OrderByCondition> { new OrderByCondition { Key = "serialno", IsDesc = true } }
  293. };
  294. _logger.LogInformation($"{imei} 更新缓存{nameof(UpdatePersonRemarksAsync)}成功,{JsonConvert.SerializeObject(personCache)}");
  295. // 读取数据库
  296. var person = await _gpsPersonApiClient.GetFirstAsync(condition, new RequestHeader() { RequestId = $"{imei}" }).ConfigureAwait(false);
  297. // 更新字段
  298. person!.Remarks = newRemarkStr;
  299. await _gpsPersonApiClient.UpdateAsync(person, new RequestHeader() { RequestId = $"{imei}" }).ConfigureAwait(false);
  300. _logger.LogInformation($"{imei} 更新Person remarks字段|{person.Remarks}");
  301. }
  302. else
  303. {
  304. _logger.LogInformation($"{imei} 更新缓存和数据库{nameof(UpdatePersonRemarksAsync)}失败,{JsonConvert.SerializeObject(personCache)}");
  305. }
  306. flag = cacheFlag;
  307. }
  308. }
  309. catch (Exception ex)
  310. {
  311. _logger.LogError($"{nameof(UpdatePersonRemarksAsync)} {imei}--更新个人信息异常:{ex.Message}, {ex.StackTrace}");
  312. }
  313. return flag;
  314. }
  315. */
  316. /// <summary>
  317. ///// 更新 gps_person remark缓存和数据库
  318. ///// </summary>
  319. ///// <param name="imei"></param>
  320. ///// <param name="systolicRefValue"></param>
  321. ///// <param name="diastolicRefValue"></param>
  322. ///// <param name="systolicIncValue"></param>
  323. ///// <param name="diastolicIncValue"></param>
  324. ///// <param name="remarks"></param>
  325. ///// <returns></returns>
  326. //public async Task<bool> UpdatePersonRemarksAsync(string imei, int systolicRefValue, int diastolicRefValue, int systolicIncValue, int diastolicIncValue, string remarks= "is_blood_press")
  327. //{
  328. // var flag = false;
  329. // try
  330. // {
  331. // // 保证实时性,先更新缓存,再更新数据库
  332. // var personCache = await _personCacheMgr.GetDeviceGpsPersonCacheObjectBySerialNoAsync(new Guid().ToString(), imei).ConfigureAwait(false);
  333. // if (personCache == null)
  334. // {
  335. // _logger.LogInformation($"{imei} -- Person remarks数据异常,检查缓存和数据库");
  336. // }
  337. // else if (string.IsNullOrWhiteSpace(personCache["person"]!["remarks"]!.ToString()))
  338. // {
  339. // var newRemarkData = new
  340. // {
  341. // imei,
  342. // time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  343. // commandValue = new
  344. // {
  345. // systolicCalibrationValue = systolicRefValue, //收缩压标定值,值为0 表示不生效
  346. // diastolicCalibrationValue = diastolicRefValue, //舒张压标定值,值为0表示不生效
  347. // systolicIncValue, //收缩压显示增量,值为0 表示不生效
  348. // diastolicIncValue //舒张压显示增量,值为0 表示不生效
  349. // }
  350. // };
  351. // var newRemarkStr = $"{remarks}:{JsonConvert.SerializeObject(newRemarkData)}|";
  352. // personCache["person"]!["remarks"] = newRemarkStr;
  353. // bool cacheFlag = await _personCacheMgr.UpdateDeviceGpsPersonCacheObjectBySerialNoAsync(personCache, imei);
  354. // if (cacheFlag)
  355. // {
  356. // GeneralParam condition = new()
  357. // {
  358. // Filters = new List<QueryFilterCondition> {
  359. // new QueryFilterCondition {
  360. // Key=nameof(GpsDevice.Serialno),
  361. // Value=imei,
  362. // Operator= QueryOperatorEnum.Equal,
  363. // ValueType=QueryValueTypeEnum.String
  364. // }
  365. // },
  366. // OrderBys = new List<OrderByCondition> { new OrderByCondition { Key = "serialno", IsDesc = true } }
  367. // };
  368. // _logger.LogInformation($"{imei} 更新缓存{nameof(UpdatePersonRemarksAsync)}成功,{JsonConvert.SerializeObject(personCache)}");
  369. // // 读取数据库
  370. // var person = await _gpsPersonApiClient.GetFirstAsync(condition, new RequestHeader() { RequestId = $"{imei}" }).ConfigureAwait(false);
  371. // // 更新字段
  372. // person!.Remarks = newRemarkStr;
  373. // await _gpsPersonApiClient.UpdateAsync(person, new RequestHeader() { RequestId = $"{imei}" }).ConfigureAwait(false);
  374. // _logger.LogInformation($"{imei} 更新Person remarks字段|{person.Remarks}");
  375. // }
  376. // else
  377. // {
  378. // _logger.LogInformation($"{imei} 更新缓存和数据库{nameof(UpdatePersonRemarksAsync)}失败,{JsonConvert.SerializeObject(personCache)}");
  379. // }
  380. // flag = cacheFlag;
  381. // }
  382. // }
  383. // catch (Exception ex)
  384. // {
  385. // _logger.LogError($"{nameof(UpdatePersonRemarksAsync)} {imei}--更新个人信息异常:{ex.Message}, {ex.StackTrace}");
  386. // }
  387. // return flag;
  388. //}
  389. /// 更新 gps_person remark缓存和数据库
  390. /// </summary>
  391. /// <param name="imei"></param>
  392. /// <param name="systolicRefValue"></param>
  393. /// <param name="diastolicRefValue"></param>
  394. /// <param name="systolicIncValue"></param>
  395. /// <param name="diastolicIncValue"></param>
  396. /// <param name="remarks"></param>
  397. /// <returns></returns>
  398. public async Task<bool> UpdatePersonRemarksAsync(string imei, int systolicRefValue, int diastolicRefValue, int systolicIncValue, int diastolicIncValue, string remarks = "is_blood_press")
  399. {
  400. var flag = false;
  401. try
  402. {
  403. // 保证实时性,先更新缓存,再更新数据库
  404. var personCache = await _personCacheMgr.GetDeviceGpsPersonCacheObjectBySerialNoAsync(new Guid().ToString(), imei).ConfigureAwait(false);
  405. if (personCache == null)
  406. {
  407. _logger.LogInformation($"{imei} -- Person remarks数据异常,检查缓存和数据库");
  408. }
  409. else
  410. {
  411. var newRemarkData = new
  412. {
  413. imei,
  414. time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  415. commandValue = new
  416. {
  417. systolicCalibrationValue = systolicRefValue, //收缩压标定值,值为0 表示不生效
  418. diastolicCalibrationValue = diastolicRefValue, //舒张压标定值,值为0表示不生效
  419. systolicIncValue, //收缩压显示增量,值为0 表示不生效
  420. diastolicIncValue //舒张压显示增量,值为0 表示不生效
  421. }
  422. };
  423. var newRemarkStr = $"{remarks}:{JsonConvert.SerializeObject(newRemarkData)}|";
  424. personCache["person"]!["remarks"] = newRemarkStr;
  425. bool cacheFlag = await _personCacheMgr.UpdateDeviceGpsPersonCacheObjectBySerialNoAsync(personCache, imei);
  426. if (cacheFlag)
  427. {
  428. GeneralParam condition = new()
  429. {
  430. Filters = new List<QueryFilterCondition> {
  431. new QueryFilterCondition {
  432. Key=nameof(GpsDevice.Serialno),
  433. Value=imei,
  434. Operator= QueryOperatorEnum.Equal,
  435. ValueType=QueryValueTypeEnum.String
  436. }
  437. },
  438. OrderBys = new List<OrderByCondition> { new OrderByCondition { Key = "serialno", IsDesc = true } }
  439. };
  440. _logger.LogInformation($"{imei} 更新缓存{nameof(UpdatePersonRemarksAsync)}成功,{JsonConvert.SerializeObject(personCache)}");
  441. // 读取数据库
  442. var person = await _gpsPersonApiClient.GetFirstAsync(condition, new RequestHeader() { RequestId = $"{imei}" }).ConfigureAwait(false);
  443. // 更新字段
  444. person!.Remarks = newRemarkStr;
  445. await _gpsPersonApiClient.UpdateAsync(person, new RequestHeader() { RequestId = $"{imei}" }).ConfigureAwait(false);
  446. _logger.LogInformation($"{imei} 更新Person remarks字段|{person.Remarks}");
  447. }
  448. else
  449. {
  450. _logger.LogInformation($"{imei} 更新缓存和数据库{nameof(UpdatePersonRemarksAsync)}失败,{JsonConvert.SerializeObject(personCache)}");
  451. }
  452. flag = cacheFlag;
  453. }
  454. // else if (string.IsNullOrWhiteSpace(personCache["person"]!["remarks"]!.ToString()))
  455. //else if (personCache?["person"]!["remarks"]!.ToString()!=null)
  456. //{
  457. // var newRemarkData = new
  458. // {
  459. // imei,
  460. // time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  461. // commandValue = new
  462. // {
  463. // systolicCalibrationValue = systolicRefValue, //收缩压标定值,值为0 表示不生效
  464. // diastolicCalibrationValue = diastolicRefValue, //舒张压标定值,值为0表示不生效
  465. // systolicIncValue, //收缩压显示增量,值为0 表示不生效
  466. // diastolicIncValue //舒张压显示增量,值为0 表示不生效
  467. // }
  468. // };
  469. // var newRemarkStr = $"{remarks}:{JsonConvert.SerializeObject(newRemarkData)}|";
  470. // personCache["person"]!["remarks"] = newRemarkStr;
  471. // bool cacheFlag = await _personCacheMgr.UpdateDeviceGpsPersonCacheObjectBySerialNoAsync(personCache, imei);
  472. // if (cacheFlag)
  473. // {
  474. // GeneralParam condition = new()
  475. // {
  476. // Filters = new List<QueryFilterCondition> {
  477. // new QueryFilterCondition {
  478. // Key=nameof(GpsDevice.Serialno),
  479. // Value=imei,
  480. // Operator= QueryOperatorEnum.Equal,
  481. // ValueType=QueryValueTypeEnum.String
  482. // }
  483. // },
  484. // OrderBys = new List<OrderByCondition> { new OrderByCondition { Key = "serialno", IsDesc = true } }
  485. // };
  486. // _logger.LogInformation($"{imei} 更新缓存{nameof(UpdatePersonRemarksAsync)}成功,{JsonConvert.SerializeObject(personCache)}");
  487. // // 读取数据库
  488. // var person = await _gpsPersonApiClient.GetFirstAsync(condition, new RequestHeader() { RequestId = $"{imei}" }).ConfigureAwait(false);
  489. // // 更新字段
  490. // person!.Remarks = newRemarkStr;
  491. // await _gpsPersonApiClient.UpdateAsync(person, new RequestHeader() { RequestId = $"{imei}" }).ConfigureAwait(false);
  492. // _logger.LogInformation($"{imei} 更新Person remarks字段|{person.Remarks}");
  493. // }
  494. // else
  495. // {
  496. // _logger.LogInformation($"{imei} 更新缓存和数据库{nameof(UpdatePersonRemarksAsync)}失败,{JsonConvert.SerializeObject(personCache)}");
  497. // }
  498. // flag = cacheFlag;
  499. //}
  500. }
  501. catch (Exception ex)
  502. {
  503. _logger.LogError($"{nameof(UpdatePersonRemarksAsync)} {imei}--更新个人信息异常:{ex.Message}, {ex.StackTrace}");
  504. }
  505. return flag;
  506. }
  507. /** 取消
  508. public async Task<bool> UpdatePersonInfoCacheAsync(string imei)
  509. {
  510. var flag = false;
  511. try
  512. {
  513. var url = $"{_configService.IotWebApiUrl}Device/UpdatePersonInfoCache?imei={imei}";
  514. List<KeyValuePair<string, string>> headers = new()
  515. {
  516. new KeyValuePair<string, string>("AuthKey", "key1")
  517. };
  518. var res = await _httpHelper.HttpToGetAsync(url, headers).ConfigureAwait(false);
  519. _logger.LogInformation($"{imei} 更新缓存{nameof(UpdatePersonInfoCacheAsync)},响应:{res}");
  520. var resJToken = JsonConvert.DeserializeObject(res ?? string.Empty) as JToken;
  521. flag = resJToken?["message"]?.ToString().Equals("ok") ?? false;
  522. }
  523. catch (Exception ex)
  524. {
  525. _logger.LogError($"{nameof(UpdatePersonInfoCacheAsync)} 更新缓存异常:{ex.Message}, {ex.StackTrace}");
  526. }
  527. return flag;
  528. }
  529. */
  530. }
  531. }