using ivf_tl_Entity.Entity; using ivf_tl_Entity.Entity.balance; using ivf_tl_Entity.Entity.Mark; using ivf_tl_Entity.Entity.Result; using ivf_tl_Entity.Enums; using ivf_tl_Entity.Response; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Net.Http; using System.Net; using System.Text; using System.Threading.Tasks; using System.Diagnostics; namespace ivf_tl_Service.HttpProvider { public class DetailProvider { LogService LogService { get; set; } HttpServiceCall httpServiceCall1 { get; set; } public DetailProvider(HttpServiceCall _httpServiceCall, LogService _logService) { httpServiceCall1 = _httpServiceCall; LogService = _logService; } private void ExLog(Exception ex, string name) { LogService.ExceptionLog(ex, $"DetailProvider.{name}", LogEnum.RunException); } private void ErrorLog(string message, LogEnum logType) { LogService.TLLog($"DetailProvider.{message}", logType); } /// /// 获取图片视频 /// /// /// /// /// public List GetPicturesByRecordIdApi(string tlsn, int housesn, long dishId, List wellList) { string funcName = "GetPicturesByRecordIdApi"; try { string url = "/api/businessManage/pc/resource/getPicturesByRecordId"; string body = JsonConvert.SerializeObject(new { tlSn = tlsn, houseSn = housesn, id = dishId, wellSnList = wellList }); string resultString = httpServiceCall1.callWebService(url, body); ErrorLog(resultString, LogEnum.RunRecord); if (string.IsNullOrEmpty(resultString)) return new List(); ResultEntity> rs = JsonConvert.DeserializeObject>>(resultString); if (!rs.success) { ErrorLog($"{funcName}接口返回失败 {resultString}", LogEnum.RunError); return new List(); } if (rs.data != null) return rs.data; ErrorLog($"{funcName}接口返回成功但是无数据 {resultString}", LogEnum.RunError); return new List(); } catch (Exception ex) { ExLog(ex, funcName); return new List(); } } public List GetRecordDetailApi(string tlsn, int housesn, long dishId, List wellList) { string funcName = "GetRecordDetailApi"; try { string url = "/api/businessManage/pc/resource/getRecordDetail"; string body = JsonConvert.SerializeObject(new { tlSn = tlsn, houseSn = housesn, id = dishId, wellSnList = wellList }); //Debug.WriteLine($"{DateTime.Now.ToString("MM-dd HH:mm:ss.fff")}"); string resultString = httpServiceCall1.callWebService(url, body); //Debug.WriteLine($"{DateTime.Now.ToString("MM-dd HH:mm:ss.fff")}"); if (string.IsNullOrEmpty(resultString)) return new List(); ResultEntity> rs = JsonConvert.DeserializeObject>>(resultString); if (!rs.success) { ErrorLog($"{funcName}接口返回失败 {resultString}", LogEnum.RunError); return new List(); } if (rs.data != null) return rs.data; ErrorLog($"{funcName}接口返回成功但是无数据 {resultString}", LogEnum.RunError); return new List(); } catch (Exception ex) { ExLog(ex, funcName); return new List(); } } /// /// 获取胚胎列表 /// /// /// public List GetCultureRecordByIdApi(long id) { string funcName = "GetCultureRecordByIdApi"; try { string url = "/api/businessManage/pc/embryoCultureRecord/getCultureRecordById"; Dictionary body = new Dictionary(); body.Add("id", id.ToString()); string resultString = httpServiceCall1.callWebService(url, body); if (string.IsNullOrEmpty(resultString)) return new List(); ResultEntity rs = JsonConvert.DeserializeObject>(resultString); if (!rs.success) { ErrorLog($"{funcName}接口返回失败 {resultString}", LogEnum.RunError); return new List(); } if (rs.data != null && rs.data.embryoList != null) return rs.data.embryoList; ErrorLog($"{funcName}接口返回成功但是无数据 {resultString}", LogEnum.RunError); return new List(); } catch (Exception ex) { ExLog(ex, funcName); return new List(); } } /// /// 胚胎去向标记 /// /// /// /// public bool MarkEmbryoDestinationApi(long id, int embryoState) { string funcName = "MarkEmbryoDestinationApi"; try { string url = "/api/businessManage/pc/embryoMark/markEmbryoDestination"; string body = JsonConvert.SerializeObject(new { id = id, state = embryoState, }); string resultString = httpServiceCall1.callWebService(url, body); if (string.IsNullOrEmpty(resultString)) return false; ResultEntity rs = JsonConvert.DeserializeObject>(resultString); if (!rs.success) { ErrorLog($"{funcName}接口返回失败 {resultString}", LogEnum.RunError); return false; } return true; } catch (Exception ex) { ExLog(ex, funcName); return false; } } /// /// 患者培养接口-结束培养 /// /// /// public bool EndCultureRecordApi(long id) { string funcName = "EndCultureRecordApi"; try { string url = "/api/businessManage/pc/embryoCultureRecord/endCultureRecord"; Dictionary body = new Dictionary(); body.Add("id", id.ToString()); string resultString = httpServiceCall1.callWebService(url, body); if (string.IsNullOrEmpty(resultString)) return false; ResultEntity rs = JsonConvert.DeserializeObject>(resultString); if (!rs.success) { ErrorLog($"{funcName}接口返回失败 {resultString}", LogEnum.RunError); return false; } return true; } catch (Exception ex) { ExLog(ex, funcName); return false; } } public List GetEnableMarkModelTypeApi() { string funcName = "GetEnableMarkModelTypeApi"; try { string url = "/api/businessManage/pc/mark/getEnableModels"; string resultString = httpServiceCall1.callWebService(url); if (string.IsNullOrEmpty(resultString)) return new List(); ResultEntity> rs = JsonConvert.DeserializeObject>>(resultString); if (!rs.success) { ErrorLog($"{funcName}接口返回失败:{resultString}", LogEnum.RunError); return new List(); } if (rs.data != null) return rs.data; ErrorLog($"{funcName}接口返回成功但是无数据 {resultString}", LogEnum.RunError); return new List(); } catch (Exception ex) { ExLog(ex, funcName); return new List(); } } public List GetQuickButtonsApi() { string funcName = "GetQuickButtonsApi"; try { string url = "/api/businessManage/pc/photoSearchButton/getButtons"; string body = JsonConvert.SerializeObject(new { types = new List { "QUICK_BUTTON" } }); string resultString = httpServiceCall1.callWebService(url, body); if (string.IsNullOrEmpty(resultString)) return new List(); ResultEntity> rs = JsonConvert.DeserializeObject>>(resultString); if (!rs.success) { ErrorLog($"{funcName}接口返回失败 {resultString}", LogEnum.RunError); return new List(); } if (rs.data.Any() && rs.data.First().button != null && rs.data.First().button.Any()) { return rs.data.First().button; } ErrorLog($"{funcName}接口返回成功但是无数据 {resultString}", LogEnum.RunError); return new List(); } catch (Exception ex) { ExLog(ex, funcName); return new List(); } } public List GetMarkTypeAPi() { string funcName = "GetMarkTypeAPi"; try { string url = "/api/businessManage/pc/mark/getEnableModels"; string resultString = httpServiceCall1.callWebService(url); if (string.IsNullOrEmpty(resultString)) return new List(); ResultEntity> rs = JsonConvert.DeserializeObject>>(resultString); if (!rs.success) { ErrorLog($"{funcName}接口返回失败 {resultString}", LogEnum.RunError); return new List(); } if (rs.data != null) return rs.data; ErrorLog($"{funcName}接口返回成功但是无数据 {resultString}", LogEnum.RunError); return new List(); } catch (Exception ex) { ExLog(ex, funcName); return new List(); } } public List GetEmbryoMarkEntityAPi(long id) { string funcName = "GetEmbryoMarkEntityAPi"; try { string url = "/api/businessManage/pc/mark/getEnableMarkTreeList"; string resultString = httpServiceCall1.callWebService(url, JsonConvert.SerializeObject(new { model = id })); if (string.IsNullOrEmpty(resultString)) return new List(); ResultEntity> rs = JsonConvert.DeserializeObject>>(resultString); if (!rs.success) { ErrorLog($"{funcName}接口返回失败 {resultString}", LogEnum.RunError); return new List(); } if (rs.data != null) return rs.data; ErrorLog($"{funcName}接口返回成功但是无数据 {resultString}", LogEnum.RunError); return new List(); } catch (Exception ex) { ExLog(ex, funcName); return new List(); } } public List GetEmbryoMarkApi(long id) { string funcName = "GetEmbryoMarkApi"; try { string url = "/api/businessManage/pc/embryoMark/getEmbryoMarkByEmbryoId"; Dictionary boyd = new Dictionary(); boyd.Add("id", id.ToString()); string resultString = httpServiceCall1.callWebService(url, boyd); if (string.IsNullOrEmpty(resultString)) return new List(); ResultEntity rs = JsonConvert.DeserializeObject>(resultString); if (!rs.success) { ErrorLog($"{funcName}接口返回失败 {resultString}", LogEnum.RunError); return new List(); } if (rs.data != null && rs.data.embryoMark != null) return rs.data.embryoMark; ErrorLog($"{funcName}接口返回成功但是无数据 {resultString}", LogEnum.RunError); return new List(); } catch (Exception ex) { ExLog(ex, funcName); return new List(); } } public bool SaveMarkApi(EmbryoMarkResponse embryoMarkResponse) { string funcName = "SaveMarkApi"; try { string url = "/api/businessManage/pc/embryoMark/markEmbryoByDevelopTime"; string body = JsonConvert.SerializeObject(embryoMarkResponse); string resultString = httpServiceCall1.callWebService(url, body); if (string.IsNullOrEmpty(resultString)) return false; ResultEntity rs = JsonConvert.DeserializeObject(resultString); if (!rs.success) { ErrorLog($"{funcName}接口返回失败 {resultString}", LogEnum.RunError); return false; } return true; } catch (Exception ex) { ExLog(ex, funcName); return false; } } public string GetImageUrlApi(string tlSn, int houseSn, long id, int layer, int developTime) { string funcName = "GetImageUrlApi"; try { string url = "/api/businessManage/pc/resource/switchVideoLayerByPicture"; string resultString = httpServiceCall1.callWebService(url, JsonConvert.SerializeObject(new { tlSn, houseSn, id, layer, developTime })); if (string.IsNullOrEmpty(resultString)) return null; var rs = JsonConvert.DeserializeObject>(resultString); if (!rs.success) { ErrorLog($"{funcName}接口返回失败 {resultString}", LogEnum.RunError); return null; } return rs.data; } catch (Exception ex) { ExLog(ex, funcName); return null; } } public DetailPicInfo GetDetailPicInfoApi(string tlSn, int houseSn, long id, int layer, int developTime) { string funcName = "GetDetailPicInfoApi"; try { string url = "/api/businessManage/pc/resource/getImageInfo"; string body = JsonConvert.SerializeObject(new { tlSn, houseSn, id, layer, developTime }); if (layer == 9999) body = JsonConvert.SerializeObject(new { tlSn, houseSn, id, developTime }); string resultString = httpServiceCall1.callWebService(url, body); if (string.IsNullOrEmpty(resultString)) return null; var rs = JsonConvert.DeserializeObject>(resultString); if (!rs.success) { ErrorLog($"{funcName}接口返回失败 {resultString}", LogEnum.RunError); return null; } return rs.data; } catch (Exception ex) { ExLog(ex, funcName); return null; } } public List GetVideoTimeLineApi(string tlSn, int houseSn, long id, int layer) { string funcName = "GetVideoTimeLineApi"; try { string url = "/api/businessManage/pc/resource/getVideoTimeLine"; string resultString = httpServiceCall1.callWebService(url, JsonConvert.SerializeObject(new { tlSn, houseSn, id, layer })); if (string.IsNullOrEmpty(resultString)) return null; var rs = JsonConvert.DeserializeObject>>(resultString); if (!rs.success) { ErrorLog($"{funcName}接口返回失败 {resultString}", LogEnum.RunError); return null; } if (rs.data != null && rs.data.Any()) return rs.data; ErrorLog($"{funcName}接口返回成功但是无数据 {resultString}", LogEnum.RunError); return new List(); } catch (Exception ex) { ExLog(ex, funcName); return null; } } public List GetPicTimeButtonsApi() { string funcName = "GetPicTimeButtonsApi"; try { string url = "/api/businessManage/pc/photoSearchButton/getButtons"; string body = JsonConvert.SerializeObject(new { types = new List { "COMMON_BUTTON", "KEY_BUTTON " } }); string resultString = httpServiceCall1.callWebService(url, body); if (string.IsNullOrEmpty(resultString)) return new List(); ResultEntity> rs = JsonConvert.DeserializeObject>>(resultString); if (!rs.success) { ErrorLog($"{funcName}接口返回失败 {resultString}", LogEnum.RunError); return new List(); } if (rs.data != null && rs.data.Any()) return rs.data; ErrorLog($"{funcName}接口返回成功但是无数据 {resultString}", LogEnum.RunError); return new List(); } catch (Exception ex) { ExLog(ex, funcName); return new List(); } } public List GetHouseCropAlarmApi(HouseCropAlarmResponse houseCropAlarmResponse) { string funcName = "GetHouseCropAlarmApi"; try { string url = "/api/tl/control/alarm/getHouseCropAlarm"; string body = JsonConvert.SerializeObject(houseCropAlarmResponse); string resultString = httpServiceCall1.callWebService(url, body); if (string.IsNullOrEmpty(resultString)) return new List(); ResultEntity> rs = JsonConvert.DeserializeObject>>(resultString); if (!rs.success) { ErrorLog($"{funcName}接口返回失败 {resultString}", LogEnum.RunError); return new List(); } if (rs.data != null && rs.data.Any()) return rs.data; return new List(); } catch (Exception ex) { ExLog(ex, funcName); return new List(); } } } }