| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281 |
- using ivf_tl_Entity.Entity;
- using ivf_tl_Entity.Entity.balance;
- using ivf_tl_Entity.Entity.BinSetting;
- using ivf_tl_Entity.Entity.Mark;
- using ivf_tl_Entity.Entity.Result;
- using ivf_tl_Entity.Enums;
- using Newtonsoft.Json;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Net;
- using System.Text;
- using System.Threading.Tasks;
- using System.Xml.Linq;
- namespace ivf_tl_Service.HttpProvider
- {
- /// <summary>
- /// 下位机控制软件-TL设备信息接口
- /// </summary>
- public class TLInfoProvider
- {
- LogService LogService { get; set; }
- HttpServiceCall httpServiceCall1 { get; set; }
- public TLInfoProvider(HttpServiceCall _httpServiceCall, LogService _logService)
- {
- httpServiceCall1 = _httpServiceCall;
- LogService = _logService;
- }
- private void ExLog(Exception ex, string name)
- {
- LogService.ExceptionLog(ex, $"TLInfoProvider.{name}", LogEnum.RunException);
- }
- private void MessageLog(string mesage, LogEnum typeLog)
- {
- LogService.TLLog($"TLInfoProvider.{mesage}", typeLog);
- }
- /// <summary>
- /// 修改回显 - 通过id查询TlInfo信息
- /// </summary>
- /// <param name="id"></param>
- /// <returns></returns>
- public TLSettingInfo GetTlInfoById(long id)
- {
- string name = "GetTlInfoById";
- try
- {
- string url = "/api/tl/control/tlInfo/getTlInfoById";
- Dictionary<string, string> body = new Dictionary<string, string>();
- body.Add("id", id.ToString());
- string json = httpServiceCall1.callWebService(url, body);
- if (string.IsNullOrEmpty(json)) return new TLSettingInfo();
- var result = JsonConvert.DeserializeObject<ResultEntity<TLSettingInfo>>(json);
- if (!result.success)
- {
- MessageLog($"{name}服务器返回失败 {json}", LogEnum.RunError);
- return new TLSettingInfo();
- }
- if (result.data != null) return result.data;
- MessageLog($"{name}接口返回成功但是无数据 {json}", LogEnum.RunError);
- return new TLSettingInfo();
- }
- catch (Exception ex)
- {
- ExLog(ex, name);
- return new TLSettingInfo();
- }
- }
- /// <summary>
- /// 修改TL设备信息
- /// </summary>
- /// <param name="address"></param>
- /// <param name="addressId"></param>
- /// <param name="id"></param>
- /// <param name="installTime"></param>
- /// <param name="remark"></param>
- /// <param name="tlName"></param>
- /// <returns></returns>
- public string TLInfoUpdate(string address, long addressId, long id, string installTime, string remark, string tlName, string collectSn, string collectName)
- {
- string name = "TLInfoUpdate";
- try
- {
- string url = "/api/tl/control/tlInfo/update";
- string body = JsonConvert.SerializeObject(new
- {
- address = address,
- addressId = addressId,
- installTime = installTime,
- remark = remark,
- tlName = tlName,
- id = id,
- collectSn,
- collectName
- });
- string json = httpServiceCall1.callWebService(url, body);
- if (string.IsNullOrEmpty(json)) return "服务器返回空";
- var result = JsonConvert.DeserializeObject<ResultEntity<TLSettingInfo>>(json);
- if (!result.success)
- {
- MessageLog($"{name}服务器返回失败 {json}", LogEnum.RunError);
- return result.message;
- }
- return null;
- }
- catch (Exception ex)
- {
- ExLog(ex, name);
- return ex.Message;
- }
- }
- /// <summary>
- /// 获取指定tl的培养中的信息
- /// </summary>
- /// <param name="tlSn"></param>
- /// <returns></returns>
- public EmbryoDataResult GetEmbryoData(string tlSn)
- {
- string name = "GetEmbryoData";
- try
- {
- string url = "/api/businessManage/pc/embryo/embryo/data";
- Dictionary<string, string> body = new Dictionary<string, string>();
- body.Add("tlSn", tlSn);
- string json = httpServiceCall1.callWebService(url, body);
- if (string.IsNullOrEmpty(json)) return new EmbryoDataResult();
- var result = JsonConvert.DeserializeObject<ResultEntity<EmbryoDataResult>>(json);
- if (!result.success)
- {
- MessageLog($"{name}服务器返回失败{json}", LogEnum.RunError);
- return new EmbryoDataResult();
- }
- if (result.data != null) return result.data;
- MessageLog($"{name}接口返回成功但是无数据 {json}", LogEnum.RunError);
- return new EmbryoDataResult();
- }
- catch (Exception ex)
- {
- ExLog(ex, name);
- return new EmbryoDataResult();
- }
- }
- /// <summary>
- /// 患者培养接口 患者管理 - 舱室列表
- /// </summary>
- /// <param name="tlSn"></param>
- /// <returns></returns>
- public GetHouseCultureListResult GetHouseCultureList(string tlSn)
- {
- string name = "GetHouseCultureList";
- try
- {
- string url = "/api/businessManage/pc/embryoCultureRecord/getHouseCultureList";
- Dictionary<string, string> body = new Dictionary<string, string>();
- body.Add("tlSn", tlSn);
- string json = httpServiceCall1.callWebService(url, body);
- if (string.IsNullOrEmpty(json)) return null;
- var result = JsonConvert.DeserializeObject<ResultEntity<GetHouseCultureListResult>>(json);
- if (!result.success)
- {
- MessageLog($"{name}服务器返回失败 {json}", LogEnum.RunError);
- return null;
- }
- if (result.data != null) return result.data;
- MessageLog($"{name}接口返回成功但是无数据 {json}", LogEnum.RunError);
- return null;
- }
- catch (Exception ex)
- {
- ExLog(ex, name);
- return null;
- }
- }
- public List<SettingEntity> GetBinSetting(string tlSn, string houseSn, string startTime, string endTime)
- {
- string name = "getHouseEnviroment";
- try
- {
- string url = "/api/tl/control/houseCollect/getHouseEnviroment";
- string body = JsonConvert.SerializeObject(new { tlSn, houseSn, startTime, endTime });
- string json = httpServiceCall1.callWebService(url, body);
- if (string.IsNullOrEmpty(json)) return null;
- var result = JsonConvert.DeserializeObject<ResultEntity<List<SettingEntity>>>(json);
- if (!result.success)
- {
- MessageLog($"{name}服务器返回失败 {json}", LogEnum.RunError);
- return null;
- }
- if (result.data != null) return result.data;
- MessageLog($"{name}接口返回成功但是无数据 {json}", LogEnum.RunError);
- return null;
- }
- catch (Exception ex)
- {
- ExLog(ex, name);
- return null;
- }
- }
- public HouseChartEntity GetHouseEnvironmentListApi(string tlSn, string houseSn, string startTime, string endTime)
- {
- string name = "GetHouseEnvironmentListApi";
- try
- {
- string url = "/api/tl/control/houseCollect/getHouseEnvironmentList";
- string resultString = httpServiceCall1.callWebService(url, JsonConvert.SerializeObject(new { tlSn, houseSn, startTime, endTime }));
- if (string.IsNullOrEmpty(resultString)) return new HouseChartEntity();
- var rs = JsonConvert.DeserializeObject<ResultEntity<HouseChartEntity>>(resultString);
- if (!rs.success)
- {
- MessageLog($"{name}服务器返回失败 {resultString}", LogEnum.RunError);
- return null;
- }
- if (rs.data != null) return rs.data;
- MessageLog($"{name}接口返回成功但是无数据 {resultString}", LogEnum.RunError);
- return new HouseChartEntity();
- }
- catch (Exception ex)
- {
- ExLog(ex, name);
- return new HouseChartEntity();
- }
- }
- public bool DeleteTlByIdApi(long id)
- {
- string name = "DeleteTlByIdApi";
- try
- {
- string url = "/api/tl/control/tlInfo/deleteTlById";
- string resultString = httpServiceCall1.callWebService(url, new Dictionary<string, string> { { "id", id.ToString() } });
- if (string.IsNullOrEmpty(resultString)) return false;
- var rs = JsonConvert.DeserializeObject<ResultEntity<HouseChartEntity>>(resultString);
- if (!rs.success)
- {
- MessageLog($"{name}服务器返回失败{resultString}", LogEnum.RunError);
- return false;
- }
- return true;
- }
- catch (Exception ex)
- {
- ExLog(ex, name);
- return false;
- }
- }
- public bool HiddenTLByIdAPi(long id)
- {
- string name = "HiddenTLByIdAPi";
- try
- {
- string url = "/api/tl/control/tlInfo/removeTlById";
- string resultString = httpServiceCall1.callWebService(url, new Dictionary<string, string> { { "id", id.ToString() } });
- if (string.IsNullOrEmpty(resultString)) return false;
- var rs = JsonConvert.DeserializeObject<ResultEntity>(resultString);
- if (!rs.success)
- {
- MessageLog($"{name}服务器返回失败{resultString}", LogEnum.RunError);
- return false;
- }
- return true;
- }
- catch (Exception ex)
- {
- ExLog(ex, name);
- return false;
- }
- }
- }
- }
|