| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376 |
- 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 System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Security.Policy;
- using System.Text;
- using System.Threading.Tasks;
- namespace ivf_tl_Service.HttpProvider
- {
- public class DishProvider
- {
- LogService LogService { get; set; }
- HttpServiceCall httpServiceCall1 { get; set; }
- public DishProvider(HttpServiceCall _httpServiceCall, LogService _logService)
- {
- httpServiceCall1 = _httpServiceCall;
- LogService = _logService;
- }
- private void ExLog(Exception ex, string name)
- {
- LogService.ExceptionLog(ex, $"DishProvider.{name}", LogEnum.RunException);
- }
- private void ErrorLog(string message, LogEnum logType)
- {
- LogService.TLLog($"DishProvider.{message}", logType);
- }
- /// <summary>
- /// 设备管理 - 设备列表
- /// </summary>
- /// <returns></returns>
- public List<TLInfo> GetTlInfoList()
- {
- string funcName = "GetTlInfoList";
- string resultString = string.Empty;
- try
- {
- string url = "/api/businessManage/pc/embryoCultureRecord/getTlInfoList";
- resultString = httpServiceCall1.callWebService(url);
- if (string.IsNullOrEmpty(resultString)) return new List<TLInfo>();
- var result = JsonConvert.DeserializeObject<ResultEntity<List<TLInfo>>>(resultString);
- if (!result.success)
- {
- ErrorLog($"{funcName}接口返回失败 {resultString}", LogEnum.RunError);
- return new List<TLInfo>();
- }
- if (result.data != null) return result.data;
- ErrorLog($"{funcName}接口返回成功但是无数据 {resultString}", LogEnum.RunError);
- return new List<TLInfo>();
- }
- catch (Exception ex)
- {
- ExLog(ex, $"{funcName}:[resultString:{resultString}]");
- return new List<TLInfo>();
- }
- }
- /// <summary>
- /// 患者培养接口 开始培养-添加患者信息
- /// </summary>
- /// <param name="dish"></param>
- /// <returns></returns>
- public string StartDish(Dish dish)
- {
- string name = "StartDish";
- try
- {
- string url = "/api/businessManage/pc/embryoCultureRecord/addCultureRecord";
- string body = JsonConvert.SerializeObject(dish);
- string json = httpServiceCall1.callWebService(url, body);
- if (string.IsNullOrEmpty(json)) return "服务器返回空";
- var result = JsonConvert.DeserializeObject<ResultEntity>(json);
- if (!result.success)
- {
- ErrorLog($"{name}服务器返回失败 {json}", LogEnum.RunError);
- return result.message;
- }
- return null;
- }
- catch (Exception ex)
- {
- ExLog(ex, name);
- return ex.Message;
- }
- }
- /// <summary>
- /// 患者培养接口 编辑患者信息
- /// </summary>
- /// <param name="body"></param>
- /// <returns></returns>
- public string UpDataDish(string body)
- {
- string name = "UpDataDish";
- try
- {
- string url = "/api/businessManage/pc/embryoCultureRecord/updateCultureRecord";
- string json = httpServiceCall1.callWebService(url, body);
- if (string.IsNullOrEmpty(json)) return "服务器返回空";
- var result = JsonConvert.DeserializeObject<ResultEntity>(json);
- if (!result.success)
- {
- ErrorLog($"{name}服务器返回失败 {json}", LogEnum.RunError);
- return result.message;
- }
- return null;
- }
- catch (Exception ex)
- {
- ExLog(ex, name);
- return ex.Message;
- }
- }
- /// <summary>
- /// 舱室平衡接口 舱室列表-开始平衡
- /// </summary>
- /// <param name="dish"></param>
- /// <returns></returns>
- public string StartBalance(string tlSn, int houseSn)
- {
- string name = "StartBalance";
- try
- {
- string url = "/api/businessManage/pc/balance/startBalance";
- string body = JsonConvert.SerializeObject(new { tlSn = tlSn, houseSn = houseSn });
- string json = httpServiceCall1.callWebService(url, body);
- if (string.IsNullOrEmpty(json)) return "服务器返回空";
- var result = JsonConvert.DeserializeObject<ResultEntity>(json);
- if (!result.success)
- {
- ErrorLog($"{name}服务器返回失败 {json}", LogEnum.RunError);
- return result.message;
- }
- return null;
- }
- catch (Exception ex)
- {
- ExLog(ex, name);
- return ex.Message;
- }
- }
- /// <summary>
- /// 舱室平衡接口 舱室列表-结束平衡
- /// </summary>
- /// <param name="dish"></param>
- /// <returns></returns>
- public string StopBalance(long id)
- {
- string name = "StopBalance";
- try
- {
- string url = "/api/businessManage/pc/balance/stopBalance";
- string body = JsonConvert.SerializeObject(new { id = id });
- string json = httpServiceCall1.callWebService(url, body);
- if (string.IsNullOrEmpty(json)) return "服务器返回空";
- var result = JsonConvert.DeserializeObject<ResultEntity>(json);
- if (!result.success)
- {
- ErrorLog($"{name}服务器返回失败 {json}", LogEnum.RunError);
- return result.message;
- }
- return null;
- }
- catch (Exception ex)
- {
- ExLog(ex, name);
- return ex.Message;
- }
- }
- public List<PictureEntity> GetNewPicApi(string tlsn, int housesn, List<long> wellList)
- {
- string name = "GetNewPicApi";
- try
- {
- string url = "/api/businessManage/pc/resource/getEmbryosLastPictures";
- string body = JsonConvert.SerializeObject(new
- {
- tlSn = tlsn,
- houseSn = housesn,
- embryoIds = wellList,
- });
- string json = httpServiceCall1.callWebService(url, body);
- if (string.IsNullOrEmpty(json)) return new List<PictureEntity>();
- var result = JsonConvert.DeserializeObject<ResultEntity<List<PictureEntity>>>(json);
- if (!result.success)
- {
- ErrorLog($"{name}服务器返回失败 {json}", LogEnum.RunError);
- return new List<PictureEntity>();
- }
- if (result.data != null && result.data.Any()) return result.data;
- ErrorLog($"{name}接口返回成功但是无数据 {json}", LogEnum.RunError);
- return new List<PictureEntity>();
- }
- catch (Exception ex)
- {
- ExLog(ex, name);
- return new List<PictureEntity>();
- }
- }
- /// <summary>
- /// 患者培养接口 培养记录 - 分页查询
- /// </summary>
- /// <returns></returns>
- public DishRecordResult SearchDishRecordApi(SearchDishRecordResponse searchDishRecord)
- {
- string funcName = "SearchDishRecordApi";
- try
- {
- string url = "/api/businessManage/pc/embryoCultureRecord/getEmbryoCultureRecord";
- string body = JsonConvert.SerializeObject(searchDishRecord, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore });
- string resultString = httpServiceCall1.callWebService(url, body);
- if (string.IsNullOrEmpty(resultString)) return new DishRecordResult() { IsSuccess = false };
- var rs = JsonConvert.DeserializeObject<ResultEntity<DishRecordResult>>(resultString);
- if (!rs.success)
- {
- ErrorLog($"{funcName}接口返回失败 {resultString}", LogEnum.RunError);
- return new DishRecordResult() { IsSuccess = false };
- }
- if (rs.data != null) return rs.data;
- ErrorLog($"{funcName}接口返回成功但是无数据 {resultString}", LogEnum.RunError);
- return new DishRecordResult();
- }
- catch (Exception ex)
- {
- ExLog(ex, funcName);
- return new DishRecordResult() { IsSuccess = false };
- }
- }
- /// <summary>
- /// 患者培养接口 培养记录 - 查询数量
- /// </summary>
- /// <returns></returns>
- public AlarmHistoryNumResult SearchDishRecordNumApi(SearchDishRecordResponse searchDishRecord)
- {
- string funcName = "SearchDishRecordNumApi";
- try
- {
- string url = "/api/businessManage/pc/embryoCultureRecord/getEmbryoCultureRecordNum";
- string body = JsonConvert.SerializeObject(searchDishRecord, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore });
- string resultString = httpServiceCall1.callWebService(url, body);
- if (string.IsNullOrEmpty(resultString)) return new AlarmHistoryNumResult();
- var rs = JsonConvert.DeserializeObject<ResultEntity<AlarmHistoryNumResult>>(resultString);
- if (!rs.success)
- {
- ErrorLog($"{funcName}接口返回失败 {resultString}", LogEnum.RunError);
- return new AlarmHistoryNumResult();
- }
- if (rs.data != null) return rs.data;
- ErrorLog($"{funcName}接口返回成功但是无数据 {resultString}", LogEnum.RunError);
- return new AlarmHistoryNumResult();
- }
- catch (Exception ex)
- {
- ExLog(ex, funcName);
- return new AlarmHistoryNumResult();
- }
- }
- /// <summary>
- /// 患者培养接口 患者管理 - 详情
- /// </summary>
- /// <returns></returns>
- public Dish GetDishByIdApi(long id)
- {
- string funcName = "GetDishByIdApi";
- try
- {
- string url = "/api/businessManage/pc/embryoCultureRecord/getCultureRecordById";
- Dictionary<string, string> body = new Dictionary<string, string> { { "id", id.ToString() } };
- string resultString = httpServiceCall1.callWebService(url, body);
- if (string.IsNullOrEmpty(resultString)) return new Dish();
- var rs = JsonConvert.DeserializeObject<ResultEntity<Dish>>(resultString);
- if (!rs.success)
- {
- ErrorLog($"{funcName}接口返回失败 {resultString}", LogEnum.RunError);
- return new Dish();
- }
- if (rs.data != null) return rs.data;
- ErrorLog($"{funcName}接口返回成功但是无数据 {resultString}", LogEnum.RunError);
- return new Dish();
- }
- catch (Exception ex)
- {
- ExLog(ex, funcName);
- return new Dish();
- }
- }
- public string DeleteDishRecordApi(long id)
- {
- string name = "DeleteDishRecordApi";
- try
- {
- string url = "/api/businessManage/pc/embryoCultureRecord/deleteEmbryoCultureRecord";
- Dictionary<string, string> body = new Dictionary<string, string>() { { "id", id.ToString() } };
- string json = httpServiceCall1.callWebService(url, body);
- if (string.IsNullOrEmpty(json)) return "服务器返回空";
- var result = JsonConvert.DeserializeObject<ResultEntity>(json);
- if (!result.success)
- {
- ErrorLog($"{name}服务器返回失败 {json}", LogEnum.RunError);
- return result.message;
- }
- return null;
- }
- catch (Exception ex)
- {
- ExLog(ex, name);
- return ex.Message;
- }
- }
- public byte[] GetImageByte(string imageUrl)
- {
- string funcName = "GetImageByte";
- try
- {
- return httpServiceCall1.GetImageByteApi(imageUrl);
- }
- catch (Exception ex)
- {
- ExLog(ex, funcName);
- return null;
- }
- }
- public ReportMarkData GetCultureRecordDetailByIdApi(long id)
- {
- string funcName = "GetCultureRecordDetailByIdApi";
- try
- {
- string url = "/api/businessManage/pc/embryoCultureRecord/getCultureRecordDetailById";
- Dictionary<string, string> body = new Dictionary<string, string>();
- body.Add("id", id.ToString());
- string resultString = httpServiceCall1.callWebService(url, body);
- if (string.IsNullOrEmpty(resultString)) return null;
- ResultEntity<ReportMarkData> rs = JsonConvert.DeserializeObject<ResultEntity<ReportMarkData>>(resultString);
- if (!rs.success)
- {
- ErrorLog($"{funcName}接口返回失败 {resultString}", LogEnum.RunError);
- return null;
- }
- if (rs.data != null) return rs.data;
- ErrorLog($"{funcName}接口返回成功但是无数据 {resultString}", LogEnum.RunError);
- return null;
- }
- catch (Exception ex)
- {
- ExLog(ex, funcName);
- return null;
- }
- }
- }
- }
|