| | |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | using AutoMapper; |
| | | using OfficeOpenXml.FormulaParsing.Excel.Functions.DateTime; |
| | | using OfficeOpenXml.FormulaParsing.Excel.Functions.Text; |
| | | using SqlSugar; |
| | | using WIDESEAWCS_Core; |
| | |
| | | { |
| | | public IRepository<Dt_Parameters> Repository => BaseDal; |
| | | private readonly IRepository<Sys_User> _user; |
| | | private readonly IRepository<Dt_AlarmResetHsy> _alarm; |
| | | private readonly IRepository<Dt_CustomIPaddress> _cunstomip; |
| | | |
| | | public ParametersService(IRepository<Dt_Parameters> BaseDal, IRepository<Sys_User> user) : base(BaseDal) |
| | | public ParametersService(IRepository<Dt_Parameters> BaseDal, IRepository<Sys_User> user, IRepository<Dt_AlarmResetHsy> alarm, IRepository<Dt_CustomIPaddress> cunstomip) : base(BaseDal) |
| | | { |
| | | _user = user; |
| | | _user = user; |
| | | _alarm = alarm; |
| | | _cunstomip = cunstomip; |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// èªå¨æ§å¶ä¼¸ç¼©æç伸åºå缩åé度 |
| | | /// èªå¨æ§å¶è¦ææºæç伸åºå缩åé度 |
| | | /// </summary> |
| | | /// <param name="ExtendedState">伸/åºç¶æ</param> |
| | | /// <returns></returns> |
| | | public WebResponseContent automation(string ExtendedState) |
| | | public WebResponseContent automation(string ExtendedState, string LocalIP) |
| | | { |
| | | |
| | | try |
| | | { |
| | | |
| | | //æ ¹æ®int.TryParse(AppSettings.Get("DepartmentID")读åå°å½åæ¯è½¨éå ï¼ææäººé½åªè½æä½å½å |
| | | if (!int.TryParse(AppSettings.Get("DepartmentID"), out int deid)) |
| | | ////æ ¹æ®int.TryParse(AppSettings.Get("DepartmentID")读åå°å½åæ¯è½¨éå ï¼ææäººé½åªè½æä½å½å |
| | | //if (!int.TryParse(AppSettings.Get("DepartmentID"), out int deid)) |
| | | //{ |
| | | // return new WebResponseContent { Status = false, Message = "é
置项 DepartmentID æ æ³è½¬æ¢ä¸ºæ´æ°" }; |
| | | //}; |
| | | |
| | | //var devices = GetDevicesByDeptId(deid); |
| | | //å
æ¥è¯¢è®¾å¤ipé
置表ï¼Dt_CustomIPaddressï¼ï¼çæ¯å¦æé
ç½®ï¼æ²¡æå°±æç¤ºä»é
ç½® |
| | | var customip=_cunstomip.QueryData(x=>x.IPaddress==LocalIP).FirstOrDefault(); |
| | | if (customip == null) |
| | | { |
| | | return new WebResponseContent { Status = false, Message = "é
置项 DepartmentID æ æ³è½¬æ¢ä¸ºæ´æ°" }; |
| | | }; |
| | | return new WebResponseContent { Status = false, Message = "ä½ è¿æ²¡æé
置该轨éç«çIPå°å,请å
é
ç½®å¨æä½" }; |
| | | } |
| | | var deid = customip.StationID; |
| | | var devices = GetDevicesByDeptId(deid); |
| | | |
| | | |
| | | |
| | | |
| | | //æ¾å°Dt_Parametersä¸çææ°ä¸æ¡æ°æ® |
| | | var para = BaseDal.QueryData().Where(x => x.Deptid == deid).OrderByDescending(x => x.CreateDate).FirstOrDefault(); |
| | |
| | | int rigtpostition = (int)para.RightPosition;//å³ä¼¸åºä½ç½® |
| | | string message = ""; |
| | | |
| | | var alarm = _alarm.QueryData(x => x.ResetStatus == true && x.Deptid == deid && !x.AlarmContent.Contains("éç¢")); // æé¤ AlarmContent å
å« "éç¢s" çè®°å½.ToList(); |
| | | if (alarm.Count > 0) |
| | | { |
| | | return new WebResponseContent { Status = true, Message = "è¦ææºææ¥è¦ï¼è¯·å
å¤ä½" }; |
| | | } |
| | | |
| | | |
| | | try |
| | | { |
| | | |
| | | if (devices.Value.left.Communicator.Read<bool>("M117")) |
| | | { |
| | | |
| | |
| | | } |
| | | try |
| | | { |
| | | |
| | | |
| | | if (devices.Value.right.Communicator.Read<bool>("M117")) |
| | | { |
| | | return new WebResponseContent { Status = true, Message = "ç°å¨æ£å¨è¿è¡ä¸ï¼çå¾
æä½å®æ" }; |
| | |
| | | { |
| | | if (devices.Value.left.Communicator.Read<float>("D80")>= liftPosition-5)//å°è¾¾æå¤§ä½ç½®) |
| | | { |
| | | message += "左伸缩æå°è¾¾ç®æ ä½ç½®ï¼"; |
| | | message += "å·¦è¦ææºæå°è¾¾ç®æ ä½ç½®ï¼"; |
| | | } |
| | | else |
| | | { |
| | |
| | | { |
| | | if (devices.Value.right.Communicator.Read<float>("D80") >= rigtpostition-5) |
| | | { |
| | | message += "å³ä¼¸ç¼©æå°è¾¾ç®æ ä½ç½®ï¼"; |
| | | message += "å³è¦ææºæå°è¾¾ç®æ ä½ç½®ï¼"; |
| | | } |
| | | else |
| | | { |
| | |
| | | { |
| | | if (devices.Value.left.Communicator.Read<bool>("M115")) //å°è¾¾åç¹ä½ |
| | | { |
| | | message += "左伸缩æå·²å°åç¹ï¼"; |
| | | message += "å·¦è¦ææºæå·²å°åç¹ï¼"; |
| | | } |
| | | else |
| | | { |
| | |
| | | { |
| | | if (devices.Value.right.Communicator.Read<bool>("M115")) |
| | | { |
| | | message += "å³ä¼¸ç¼©æå·²å°åç¹ï¼"; |
| | | message += "å³è¦ææºæå·²å°åç¹ï¼"; |
| | | } |
| | | else |
| | | { |
| | |
| | | |
| | | |
| | | /// <summary> |
| | | /// æå¨æ§å¶ï¼ä¼¸ç¼©æç缩åå伸åºé度 |
| | | /// æå¨æ§å¶ï¼è¦ææºæç缩åå伸åºé度 |
| | | /// </summary> |
| | | /// <param name="position">伸缩æçä½ç½®ï¼å·¦å³ï¼</param> |
| | | /// <param name="position">è¦ææºæçä½ç½®ï¼å·¦å³ï¼</param> |
| | | /// <param name="ExtendedState">伸/ç¼©ç¶æ</param> |
| | | /// <returns></returns> |
| | | /// |
| | | public WebResponseContent ManualOperation(string position, string ExtendedState) |
| | | public WebResponseContent ManualOperation(string position, string ExtendedState, string LocalIP) |
| | | { |
| | | try |
| | | { |
| | | if (!int.TryParse(AppSettings.Get("DepartmentID"), out int deid)) |
| | | var customip = _cunstomip.QueryData(x => x.IPaddress == LocalIP).FirstOrDefault(); |
| | | if (customip == null) |
| | | { |
| | | return new WebResponseContent { Status = false, Message = "é
置项 DepartmentID æ æ³è½¬æ¢ä¸ºæ´æ°" }; |
| | | return new WebResponseContent { Status = false, Message = "ä½ è¿æ²¡æé
置该轨éç«çIPå°å,请å
é
ç½®å¨æä½" }; |
| | | } |
| | | var deid = customip.StationID; |
| | | var devices = GetDevicesByDeptId(deid); |
| | | |
| | | //俩个plcå·¦å³åä¸ä¸ª |
| | |
| | | //bool canLeft = true, |
| | | // canRight = true; |
| | | string message = ""; |
| | | var alarm = _alarm.QueryData(x => x.ResetStatus == true && x.Deptid == deid && !x.AlarmContent.Contains("éç¢")); // æé¤ AlarmContent å
å« "éç¢s" çè®°å½.ToList(); |
| | | if (alarm.Count > 0) |
| | | { |
| | | return new WebResponseContent { Status = true, Message = "è¦ææºææ¥è¦ï¼è¯·å
å¤ä½" }; |
| | | } |
| | | |
| | | try |
| | | { |
| | | |
| | | //var alarmSignals = new[] { "M109", "M111", "M110", "M120" }; |
| | | //if (alarmSignals.Any(signal => devices.Value.left.Communicator.Read<bool>(signal))) |
| | | //{ |
| | | // return new WebResponseContent { Status = true, Message = "è¦ææºææ¥è¦ï¼è¯·å
å¤ä½" }; |
| | | //} |
| | | if (devices.Value.left.Communicator.Read<bool>("M117")) //é»è®¤æ¯flase |
| | | { |
| | | |
| | |
| | | } |
| | | try |
| | | { |
| | | |
| | | |
| | | if (devices.Value.right.Communicator.Read<bool>("M117")) |
| | | { |
| | | return new WebResponseContent { Status = true, Message = "ç°å¨æ£å¨è¿è¡ä¸ï¼çå¾
æä½å®æ" }; |
| | |
| | | { |
| | | if (devices.Value.left.Communicator.Read<float>("D80") >= liftPosition - 5) //å°è¾¾ç®æ ä½ç½® |
| | | { |
| | | message += "左伸缩æå°è¾¾ç®æ ä½ç½®ï¼"; |
| | | message += "å·¦è¦ææºæå°è¾¾ç®æ ä½ç½®ï¼"; |
| | | } |
| | | else |
| | | { |
| | |
| | | devices.Value.left.Communicator.Write<bool>("M100", false); // éæ¾æé® |
| | | |
| | | |
| | | Console.WriteLine($"{position}伸缩ææå¨ä¼¸åº{ext}"); |
| | | Console.WriteLine($"{position}è¦ææºææå¨ä¼¸åº{ext}"); |
| | | } |
| | | |
| | | } |
| | |
| | | { |
| | | if (devices.Value.left.Communicator.Read<bool>("M115"))//缩åçæ¶å夿) |
| | | { |
| | | message += "左伸缩æå·²å°åç¹ï¼"; |
| | | message += "å·¦è¦ææºæå·²å°åç¹ï¼"; |
| | | } |
| | | else |
| | | { |
| | | //devices.Value.left.Communicator.Write<int>("D1004", liftPosition);//伸åºä½ç½® |
| | | devices.Value.left.Communicator.Write<int>("D1004", liftPosition);//伸åºä½ç½® |
| | | devices.Value.left.Communicator.Write<int>("D1000", ext);//å·¦PLCæå¨ä¼¸åºç¼©åé度 |
| | | devices.Value.left.Communicator.Write<bool>("M101", true); |
| | | Thread.Sleep(100); // çå¾
100msï¼æ¨¡ææé®æä¸ï¼ |
| | | devices.Value.left.Communicator.Write<bool>("M101", false); // éæ¾æé® |
| | | Console.WriteLine($"{position}伸缩ææå¨ç¼©å{ext}"); |
| | | Console.WriteLine($"{position}è¦ææºææå¨ç¼©å{ext}"); |
| | | } |
| | | |
| | | } |
| | |
| | | { |
| | | if (devices.Value.right.Communicator.Read<float>("D80") >= rigtpostition - 5) |
| | | { |
| | | message += "å³ä¼¸ç¼©æå°è¾¾ç®æ ä½ç½®ï¼"; |
| | | message += "å³è¦ææºæå°è¾¾ç®æ ä½ç½®ï¼"; |
| | | } |
| | | else |
| | | { |
| | |
| | | devices.Value.right.Communicator.Write<bool>("M100", true); |
| | | Thread.Sleep(100); // çå¾
100msï¼æ¨¡ææé®æä¸ï¼ |
| | | devices.Value.right.Communicator.Write<bool>("M100", false); // éæ¾æé® |
| | | Console.WriteLine($"{position}伸缩ææå¨ä¼¸åº{ret}"); |
| | | Console.WriteLine($"{position}è¦ææºææå¨ä¼¸åº{ret}"); |
| | | } |
| | | |
| | | |
| | |
| | | { |
| | | if (devices.Value.right.Communicator.Read<bool>("M115")) |
| | | { |
| | | message += "å³ä¼¸ç¼©æå·²å°åç¹ï¼"; |
| | | message += "å³è¦ææºæå·²å°åç¹ï¼"; |
| | | } |
| | | else |
| | | { |
| | | //devices.Value.right.Communicator.Write<int>("D1004", rigtpostition);//伸åºä½ç½® |
| | | devices.Value.right.Communicator.Write<int>("D1004", rigtpostition);//伸åºä½ç½® |
| | | devices.Value.right.Communicator.Write<int>("D1000", ret);//å³PLCæå¨ä¼¸åºç¼©åé度 |
| | | devices.Value.right.Communicator.Write<bool>("M101", true); |
| | | Thread.Sleep(100); // çå¾
100msï¼æ¨¡ææé®æä¸ï¼ |
| | | devices.Value.right.Communicator.Write<bool>("M101", false); // éæ¾æé® |
| | | Console.WriteLine($"{position}伸缩ææå¨ç¼©å{ret}"); |
| | | Console.WriteLine($"{position}è¦ææºææå¨ç¼©å{ret}"); |
| | | } |
| | | |
| | | } |
| | |
| | | |
| | | |
| | | /// <summary> |
| | | /// æ ¹æ®ç¨æ·æ·»å é度 |
| | | /// æ ¹æ®å½åæºæ¢°ipå°åæ¥æ·»å é度 |
| | | /// </summary> |
| | | /// <param name="entity"></param> |
| | | /// <returns></returns> |
| | | public WebResponseContent AddSpeed(SpeedDTO entity) |
| | | public WebResponseContent AddSpeed(SpeedDTO entity,string LocalIP) |
| | | { |
| | | try |
| | | { |
| | | // è·åå½åç»å½ç¨æ· |
| | | var user = _user.QueryData(x => x.UserName == entity.account).FirstOrDefault(); |
| | | // 夿ï¼å¦æä¸æ¯ç®¡çå && Dept_Id 为空ï¼åæç¤ºé误 |
| | | if (user.UserName != "admin" && user.Dept_Id == null) |
| | | // // è·åå½åç»å½ç¨æ· |
| | | // var user = _user.QueryData(x => x.UserName == entity.account).FirstOrDefault(); |
| | | //// 夿ï¼å¦æä¸æ¯ç®¡çå && Dept_Id 为空ï¼åæç¤ºé误 |
| | | // if (user.UserName != "admin" && user.Dept_Id == null) |
| | | // { |
| | | // return new WebResponseContent { Status = false, Message = "ä½ çè´¦å·æ²¡æè®¾ç½®è½¨éç«å·ï¼æ æ³æ·»å ï¼è¯·è系管çå" }; |
| | | // } |
| | | |
| | | //var dept = user.Dept_Id; |
| | | |
| | | //// è·åé
ç½®æä»¶ä¸ç DepartmentIDï¼ç®¡çåä¸ç¨ï¼ |
| | | //if (!int.TryParse(AppSettings.Get("DepartmentID"), out int deid)) |
| | | //{ |
| | | // return new WebResponseContent |
| | | // { |
| | | // Status = false, |
| | | // Message = "é
置项 DepartmentID æ æ³è½¬æ¢ä¸ºæ´æ°" |
| | | // }; |
| | | //} |
| | | |
| | | |
| | | //// 夿æ¯å¦ä¸ºç®¡çåè´¦å· |
| | | //bool isAdmin = user?.UserName?.Equals("admin") == true; //妿å½åç¨æ·ä¸ä¸ºç©ºï¼ä¸ç¨æ·åæ¯ "admin"ï¼å°±è®¤ä¸ºè¿ä¸ªç¨æ·æ¯ç®¡çå |
| | | |
| | | //å»è¯»å对åºè®¾å¤çipå°å |
| | | var customip = _cunstomip.QueryData(x => x.IPaddress == LocalIP).FirstOrDefault(); |
| | | if (customip == null) |
| | | { |
| | | return new WebResponseContent { Status = false, Message = "ä½ çè´¦å·æ²¡æè®¾ç½®è½¨éç«å·ï¼æ æ³æ·»å ï¼è¯·è系管çå" }; |
| | | return new WebResponseContent { Status = false, Message = "ä½ è¿æ²¡æé
置该轨éç«çIPå°å,请å
é
ç½®å¨æä½" }; |
| | | } |
| | | |
| | | var dept = user.Dept_Id; |
| | | var deid = customip.StationID; |
| | | |
| | | // è·åé
ç½®æä»¶ä¸ç DepartmentIDï¼ç®¡çåä¸ç¨ï¼ |
| | | if (!int.TryParse(AppSettings.Get("DepartmentID"), out int deid)) |
| | | { |
| | | return new WebResponseContent |
| | | { |
| | | Status = false, |
| | | Message = "é
置项 DepartmentID æ æ³è½¬æ¢ä¸ºæ´æ°" |
| | | }; |
| | | } |
| | | |
| | | |
| | | // 夿æ¯å¦ä¸ºç®¡çåè´¦å· |
| | | bool isAdmin = user?.UserName?.Equals("admin") == true; //妿å½åç¨æ·ä¸ä¸ºç©ºï¼ä¸ç¨æ·åæ¯ "admin"ï¼å°±è®¤ä¸ºè¿ä¸ªç¨æ·æ¯ç®¡çå |
| | | |
| | | // æ ¹æ®æ¯å¦æ¯ç®¡çåå³å®ä½¿ç¨åªä¸ª Deptid |
| | | var parmet = new Dt_Parameters |
| | | { |
| | | ExtendSpeed = entity.ExtendSpeed, |
| | |
| | | ManualExtend = entity.ManualExtend, |
| | | ManualRetraction = entity.ManualRetraction, |
| | | LeftPosition = entity.LeftPosition, |
| | | RightPosition = entity.RightPosition, |
| | | Deptid = isAdmin ? deid : dept.GetValueOrDefault()//妿å½åç¨æ·æ¯ç®¡çåï¼å°±ç¨é
ç½®æä»¶ä¸ç DepartmentIDï¼å¦åç¨ä¼ å
¥ç entity åæ°ä¸ç Deptid |
| | | RightPosition = entity.RightPosition, |
| | | //Deptid = isAdmin ? deid : dept.GetValueOrDefault()//妿å½åç¨æ·æ¯ç®¡çåï¼å°±ç¨é
ç½®æä»¶ä¸ç DepartmentIDï¼å¦åç¨ä¼ å
¥ç entity åæ°ä¸ç Deptid |
| | | Deptid = deid |
| | | }; |
| | | // æ·»å æ°æ® |
| | | AddData(parmet); |
| | |
| | | ///å½èªå¨ä¼¸åºéè¦æåæ¶ï¼æåæé® |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public WebResponseContent PauseButton() |
| | | public WebResponseContent PauseButton(string LocalIP) |
| | | { |
| | | try |
| | | { |
| | | //æ ¹æ®int.TryParse(AppSettings.Get("DepartmentID")读åå°å½åæ¯è½¨éå ï¼ææäººé½åªè½æä½å½å |
| | | if (!int.TryParse(AppSettings.Get("DepartmentID"), out int deid)) |
| | | ////æ ¹æ®int.TryParse(AppSettings.Get("DepartmentID")读åå°å½åæ¯è½¨éå ï¼ææäººé½åªè½æä½å½å |
| | | //if (!int.TryParse(AppSettings.Get("DepartmentID"), out int deid)) |
| | | //{ |
| | | // return new WebResponseContent { Status = false, Message = "é
置项 DepartmentID æ æ³è½¬æ¢ä¸ºæ´æ°" }; |
| | | //}; |
| | | //var devices = GetDevicesByDeptId(deid); |
| | | var customip = _cunstomip.QueryData(x => x.IPaddress == LocalIP).FirstOrDefault(); |
| | | if (customip == null) |
| | | { |
| | | return new WebResponseContent { Status = false, Message = "é
置项 DepartmentID æ æ³è½¬æ¢ä¸ºæ´æ°" }; |
| | | }; |
| | | return new WebResponseContent { Status = false, Message = "ä½ è¿æ²¡æé
置该轨éç«çIPå°å,请å
é
ç½®å¨æä½" }; |
| | | } |
| | | var deid = customip.StationID; |
| | | var devices = GetDevicesByDeptId(deid); |
| | | |
| | | try |
| | | { |
| | | devices.Value.left.Communicator.Write<bool>("M104", true); |
| | |
| | | |
| | | |
| | | /// <summary> |
| | | /// è·åå½åç¨åºææ°ç伸缩æé度 |
| | | /// è·åå½åç¨åºææ°çè¦ææºæé度 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public WebResponseContent BackfillSpeed() |
| | | public WebResponseContent BackfillSpeed(string LocalIP) |
| | | { |
| | | try |
| | | { |
| | | if (!int.TryParse(AppSettings.Get("DepartmentID"), out int deid)) |
| | | { |
| | | return new WebResponseContent { Status = false, Message = "é
置项 DepartmentID æ æ³è½¬æ¢ä¸ºæ´æ°" }; |
| | | //if (!int.TryParse(AppSettings.Get("DepartmentID"), out int deid)) |
| | | //{ |
| | | // return new WebResponseContent { Status = false, Message = "é
置项 DepartmentID æ æ³è½¬æ¢ä¸ºæ´æ°" }; |
| | | |
| | | //} |
| | | var customip = _cunstomip.QueryData(x => x.IPaddress == LocalIP).FirstOrDefault(); |
| | | if (customip == null) |
| | | { |
| | | return new WebResponseContent { Status = false, Message = "ä½ è¿æ²¡æé
置该轨éç«çIPå°å,请å
é
ç½®å¨æä½" }; |
| | | } |
| | | var deid = customip.StationID; |
| | | var para = BaseDal.QueryData().Where(x => x.Deptid == deid).OrderByDescending(x => x.CreateDate).FirstOrDefault(); |
| | | if (para == null) |
| | | { |
| | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// è·åå½å伸缩æçä½ç½®(èªå¨) |
| | | /// è·åå½åè¦ææºæçä½ç½®(èªå¨) |
| | | /// </summary> |
| | | /// <param name="ExtendedState"></param> |
| | | /// <returns></returns> |
| | |
| | | |
| | | var deviceslift = devices.Value.left.Communicator.Read<float>("D80"); |
| | | var devicesright = devices.Value.right.Communicator.Read<float>("D80"); |
| | | Console.WriteLine($"å½åå·¦å³ä¼¸ç¼©æè¿åé度åå«ä¸ºä¸º{deviceslift}"); |
| | | Console.WriteLine($"å½åå·¦å³è¦ææºæè¿åé度åå«ä¸ºä¸º{deviceslift}"); |
| | | |
| | | |
| | | return new WebResponseContent |