Merge branch 'master' of http://115.159.85.185:8098/r/RuiShengZhiNeng/GaoPuLiTiKu
| | |
| | | using System.Linq; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | using WIDESEAWCS_Core; |
| | | using WIDESEAWCS_Core.BaseRepository; |
| | | using WIDESEAWCS_Core.BaseServices; |
| | | using WIDESEAWCS_Core.Helper; |
| | | using WIDESEAWCS_DTO; |
| | | using WIDESEAWCS_DTO.RGV.FOURBOT; |
| | | using WIDESEAWCS_IBasicInfoService; |
| | | using WIDESEAWCS_Model.Models; |
| | | |
| | |
| | | { |
| | | public class ApiInfoService : ServiceBase<Dt_ApiInfo, IRepository<Dt_ApiInfo>>, IApiInfoService |
| | | { |
| | | public ApiInfoService(IRepository<Dt_ApiInfo> BaseDal) : base(BaseDal) |
| | | private readonly IInterfaceLogService _interfaceLogService; |
| | | public ApiInfoService(IRepository<Dt_ApiInfo> BaseDal, IInterfaceLogService interfaceLogService) : base(BaseDal) |
| | | { |
| | | _interfaceLogService = interfaceLogService; |
| | | } |
| | | |
| | | public IRepository<Dt_ApiInfo> Repository => BaseDal; |
| | | |
| | | /// <summary> |
| | | /// Postæ¥å£è¯·æ± |
| | | /// </summary> |
| | | /// <param name="apiCode">æ¥å£ç¼å·</param> |
| | | /// <param name="requestParameters">请æ±å
容</param> |
| | | /// <param name="remark">夿³¨</param> |
| | | /// <param name="isAdd">æ¯å¦æ·»å æ¥å¿</param> |
| | | /// <returns></returns> |
| | | public WebResponseContent PostInterfaceRequest(string apiCode, string requestParameters, string remark, bool isAdd = true) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | string response = string.Empty; |
| | | Dt_ApiInfo? apiInfo = null; |
| | | try |
| | | { |
| | | apiInfo = BaseDal.QueryFirst(x => x.ApiCode == apiCode) ?? throw new Exception($"æªæ¾å°{remark}æ¥å£é
置信æ¯ï¼è¯·æ£æ¥æ¥å£é
ç½®"); |
| | | response = HttpHelper.Post(apiInfo.ApiAddress, requestParameters); |
| | | if (apiInfo.Remark.Contains("åå车")) |
| | | { |
| | | FOURBOTReturn fOURBOTReturn = response.DeserializeObject<FOURBOTReturn>(); |
| | | if (fOURBOTReturn == null) throw new Exception($"{apiInfo.Remark}ååºå
容转æ¢å®ä½å¤±è´¥ï¼"); |
| | | if (fOURBOTReturn.returnCode != 0) throw new Exception(fOURBOTReturn.returnUserMsg); |
| | | content.Data = fOURBOTReturn; |
| | | } |
| | | else if (apiInfo.Remark.Contains("å¯ä¹å£«")) |
| | | { |
| | | |
| | | } |
| | | else if (apiInfo.Remark.Contains("海康")) |
| | | { |
| | | |
| | | } |
| | | else if (apiInfo.Remark.Contains("WMS")) |
| | | { |
| | | |
| | | } |
| | | content.OK(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | content.Error(ex.Message); |
| | | } |
| | | finally |
| | | { |
| | | if (isAdd && !string.IsNullOrEmpty(response) && apiInfo != null) |
| | | { |
| | | Dt_InterfaceLog interfaceLog = new Dt_InterfaceLog() |
| | | { |
| | | ApiCode = apiCode, |
| | | RequestParameters = requestParameters, |
| | | ApiAddress = apiInfo.ApiAddress, |
| | | ApiName = apiInfo.ApiName, |
| | | PushFrequency = 1, |
| | | PushState = content.Status ? 1 : 2, |
| | | Requestor = "WCS", |
| | | Recipient = apiInfo.Remark, |
| | | ResponseParameters = response, |
| | | Creater = "System", |
| | | Remark = content.Status ? remark : content.Message, |
| | | }; |
| | | _interfaceLogService.Repository.AddData(interfaceLog); |
| | | } |
| | | } |
| | | return content; |
| | | } |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | using Microsoft.AspNetCore.Mvc; |
| | | using Newtonsoft.Json; |
| | | using SqlSugar; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | using WIDESEAWCS_Core; |
| | | using WIDESEAWCS_Core.BaseRepository; |
| | | using WIDESEAWCS_Core.BaseServices; |
| | | using WIDESEAWCS_IBasicInfoService; |
| | | using WIDESEAWCS_Model.Models; |
| | | |
| | | |
| | | namespace WIDESEAWCS_BasicInfoService |
| | | { |
| | | public class InterfaceLogService : ServiceBase<Dt_InterfaceLog, IRepository<Dt_InterfaceLog>>, IInterfaceLogService |
| | | { |
| | | public InterfaceLogService(IRepository<Dt_InterfaceLog> BaseDal) : base(BaseDal) |
| | | { |
| | | } |
| | | |
| | | public IRepository<Dt_InterfaceLog> Repository => BaseDal; |
| | | /// <summary> |
| | | /// æ·»å æ¥å¿ |
| | | /// </summary> |
| | | /// <param name="ApiCode">æ¥å£ç¼å·</param> |
| | | /// <param name="ApiName">æ¥å£åç§°</param> |
| | | /// <param name="ApiAddress">æ¥å£å°å</param> |
| | | /// <param name="Requestor">è¯·æ±æ¹</param> |
| | | /// <param name="RequestParameters">请æ±å
容</param> |
| | | /// <param name="Recipient">æ¥æ¶æ¹</param> |
| | | /// <param name="ResponseParameters">ååºå
容</param> |
| | | /// <param name="Add">æ¯å¦æ·»å </param> |
| | | /// <returns></returns> |
| | | public WebResponseContent AddInterfaceLog(string ApiCode, string ApiName, string ApiAddress, string Requestor, string RequestParameters, string Recipient, string ResponseParameters, bool Add) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | content.Error(ex.Message); |
| | | } |
| | | return content; |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | if (rGVLocationInfo == null) break; |
| | | Dt_Task dt_Task = new() |
| | | { |
| | | Grade = 1, |
| | | Grade = 66, |
| | | PalletCode = locationInfo.PalletCode, |
| | | Roadway = locationInfo.RoadwayNo, |
| | | TaskState = TaskStatusEnum.RGV_NewMoveTask.ObjToInt(), |
| | |
| | | using System.Linq; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | using WIDESEAWCS_Core; |
| | | using WIDESEAWCS_Core.BaseRepository; |
| | | using WIDESEAWCS_Core.BaseServices; |
| | | using WIDESEAWCS_Model.Models; |
| | |
| | | public interface IApiInfoService : IService<Dt_ApiInfo> |
| | | { |
| | | public IRepository<Dt_ApiInfo> Repository { get; } |
| | | |
| | | /// <summary> |
| | | /// Postæ¥å£è¯·æ± |
| | | /// </summary> |
| | | /// <param name="apiCode">æ¥å£ç¼å·</param> |
| | | /// <param name="requestParameters">请æ±å
容</param> |
| | | /// <param name="remark">夿³¨</param> |
| | | /// <param name="isAdd">æ¯å¦æ·»å æ¥å¿</param> |
| | | /// <returns></returns> |
| | | public WebResponseContent PostInterfaceRequest(string apiCode, string requestParameters, string remark, bool isAdd = true); |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | using WIDESEAWCS_Core; |
| | | using WIDESEAWCS_Core.BaseRepository; |
| | | using WIDESEAWCS_Core.BaseServices; |
| | | using WIDESEAWCS_Model.Models; |
| | | |
| | | |
| | | namespace WIDESEAWCS_IBasicInfoService |
| | | { |
| | | public interface IInterfaceLogService : IService<Dt_InterfaceLog> |
| | | { |
| | | public IRepository<Dt_InterfaceLog> Repository { get; } |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | public string ApiAddress { get; set; } |
| | | |
| | | /// <summary> |
| | | /// æ¨éæ¬¡æ° |
| | | /// </summary> |
| | | [SugarColumn(IsNullable = false, ColumnDescription = "è´§ä½è¡")] |
| | | public int PushFrequency { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 夿³¨ |
| | | /// </summary> |
| | | [SugarColumn(IsNullable = true, Length = 50, ColumnDescription = "夿³¨")] |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | using SqlSugar; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | using WIDESEAWCS_Core.DB.Models; |
| | | |
| | | namespace WIDESEAWCS_Model.Models |
| | | { |
| | | [SugarTable(nameof(Dt_InterfaceLog), "æ¥å£æ¥å¿")] |
| | | public class Dt_InterfaceLog : BaseEntity |
| | | { |
| | | /// <summary> |
| | | /// ä¸»é® |
| | | /// </summary> |
| | | [SugarColumn(IsPrimaryKey = true, IsIdentity = true, ColumnDescription = "主é®")] |
| | | public int Id { get; set; } |
| | | |
| | | /// <summary> |
| | | /// æ¥å£ç¼å· |
| | | /// </summary> |
| | | [SugarColumn(IsNullable = true, Length = 50, ColumnDescription = "æ¥å£ç¼å·")] |
| | | public string ApiCode { get; set; } |
| | | |
| | | /// <summary> |
| | | /// æ¥å£åç§° |
| | | /// </summary> |
| | | [SugarColumn(IsNullable = true, Length = 50, ColumnDescription = "æ¥å£åç§°")] |
| | | public string ApiName { get; set; } |
| | | |
| | | /// <summary> |
| | | /// æ¥å£å°å |
| | | /// </summary> |
| | | [SugarColumn(IsNullable = true, Length = 200, ColumnDescription = "æ¥å£å°å")] |
| | | public string ApiAddress { get; set; } |
| | | |
| | | /// <summary> |
| | | /// æ¨éæ¬¡æ° |
| | | /// </summary> |
| | | [SugarColumn(IsNullable = false, ColumnDescription = "æ¨é次æ°")] |
| | | public int PushFrequency { get; set; } = 0; |
| | | |
| | | /// <summary> |
| | | /// æ¨éç¶æ |
| | | /// 0æªæ¨é |
| | | /// 1æ¨éæå |
| | | /// 2æ¨é失败 |
| | | /// </summary> |
| | | [SugarColumn(IsNullable = false, ColumnDescription = "æ¨éç¶æ")] |
| | | public int PushState { get; set; } = 0; |
| | | |
| | | /// <summary> |
| | | /// è¯·æ±æ¹ |
| | | /// </summary> |
| | | [SugarColumn(IsNullable = true, Length = 50, ColumnDescription = "è¯·æ±æ¹")] |
| | | public string Requestor { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 请æ±å
容 |
| | | /// </summary> |
| | | [SugarColumn(IsNullable = true, Length = int.MaxValue, ColumnDescription = "请æ±å
容")] |
| | | public string RequestParameters { get; set; } |
| | | |
| | | /// <summary> |
| | | /// æ¥æ¶æ¹ |
| | | /// </summary> |
| | | [SugarColumn(IsNullable = true, Length = 50, ColumnDescription = "æ¥æ¶æ¹")] |
| | | public string Recipient { get; set; } |
| | | |
| | | /// <summary> |
| | | /// ååºå
容 |
| | | /// </summary> |
| | | [SugarColumn(IsNullable = true, Length = int.MaxValue, ColumnDescription = "ååºå
容")] |
| | | public string ResponseParameters { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 夿³¨ |
| | | /// </summary> |
| | | [SugarColumn(IsNullable = true, Length = 100, ColumnDescription = "夿³¨")] |
| | | public string Remark { get; set; } |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | using Microsoft.AspNetCore.Mvc; |
| | | using WIDESEAWCS_Core.BaseController; |
| | | using WIDESEAWCS_IBasicInfoService; |
| | | using WIDESEAWCS_Model.Models; |
| | | |
| | | namespace WIDESEAWCS_Server.Controllers.BasicInfo |
| | | { |
| | | /// <summary> |
| | | ///æ¥å£ä¿¡æ¯ |
| | | /// </summary> |
| | | [Route("api/InterfaceLog")] |
| | | [ApiController] |
| | | public class InterfaceLogController : ApiBaseController<IInterfaceLogService, Dt_InterfaceLog> |
| | | { |
| | | public InterfaceLogController(IInterfaceLogService service) : base(service) |
| | | { |
| | | |
| | | } |
| | | |
| | | |
| | | } |
| | | } |
| | |
| | | { |
| | | task.ExceptionMessage = Rgv.content.errorReason; |
| | | var Error = _taskErrorMessageService.Repository.QueryFirst(x => x.ErrorCode == Rgv.content.errorCode && x.DeviceType == (int)deviceTypeEnum); |
| | | if (Error != null) |
| | | if (task.TaskType == (int)TaskTypeEnum.CPOutbound && task.TaskState == (int)TaskStatusEnum.Execut && Rgv.content.errorCode == 1330003)//æååºåºä»»å¡ä¸ååå馿é»ç¢æï¼ä¿®æ¹ä»»å¡ç¶æä¸ºæ°å»ºéæ°æ¥è¯¢é»ç¢æå
³ç³» |
| | | { |
| | | task.ExceptionMessage = Error.ExceptionMessage; |
| | | MatchCollection matches = Regex.Matches(Rgv.content.errorReason, @"\(([^)]+)\)"); |
| | | if (matches.Count > 0) |
| | | task.ExceptionMessage = ReplacePlaceholders(Rgv.content.errorReason, Error.ExceptionMessage); |
| | | ErrorTaskFeedback(task, true, Error.ErrorCode.ToString()); |
| | | task.TaskState = (int)TaskStatusEnum.New; |
| | | BaseDal.UpdateData(task); |
| | | } |
| | | else |
| | | ErrorTaskFeedback(task, true); |
| | | { |
| | | if (Error != null) |
| | | { |
| | | task.ExceptionMessage = Error.ExceptionMessage; |
| | | MatchCollection matches = Regex.Matches(Rgv.content.errorReason, @"\(([^)]+)\)"); |
| | | if (matches.Count > 0) |
| | | task.ExceptionMessage = ReplacePlaceholders(Rgv.content.errorReason, Error.ExceptionMessage); |
| | | ErrorTaskFeedback(task, true, Error.ErrorCode.ToString()); |
| | | } |
| | | else |
| | | ErrorTaskFeedback(task, true); |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | /// <param name="tasks"></param> |
| | | public void IsMoveTask(List<Dt_Task> tasks) |
| | | { |
| | | |
| | | object requestData = null; // æ·»å åéè®°å½è¯·æ±æ°æ® |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | Dt_ApiInfo? apiInfo = _apiInfoService.Repository.QueryFirst(x => x.ApiCode == nameof(GetBlockPodContentDto)) ?? throw new Exception("æªæ¾å°æ¹éè·åé»ç¢æçå
³ç³»æ¥å£é
置信æ¯ï¼è¯·æ£æ¥æ¥å£é
ç½®"); |
| | | List<Dt_Task> dt_Tasks = new List<Dt_Task>(); |
| | | var PalletCodes = tasks.Select(x => x.PalletCode).ToList(); |
| | | //GetBlockPodContentDto content = new GetBlockPodContentDto(); |
| | | var request = new GetBlockPodContentListDto |
| | | { |
| | | content = new List<GetBlockPodContentDto> |
| | |
| | | } |
| | | } |
| | | }; |
| | | requestData = request; // ä¿åè¯·æ±æ°æ®ç¨äºæ¥å¿ |
| | | //content.candidatePodIDs = tasks.Select(x => x.PalletCode).ToList(); |
| | | //string response = HttpHelper.Post("http://127.0.0.1:4523/m2/6165241-5857331-default/440906899?apifoxApiId=440906899", request.Serialize()); |
| | | |
| | | string response = HttpHelper.Post(apiInfo.ApiAddress, request.Serialize()); |
| | | FOURBOTReturn fOURBOTReturn = response.DeserializeObject<FOURBOTReturn>(); |
| | | content.OK(data: fOURBOTReturn); |
| | | content = _apiInfoService.PostInterfaceRequest(nameof(GetBlockPodContentDto), request.Serialize(), "æ¹éè·åé»ç¢æçå
³ç³»"); |
| | | if (!content.Status) |
| | | { |
| | | foreach (var item in tasks) |
| | | { |
| | | item.ExceptionMessage = content.Message; |
| | | } |
| | | _taskService.UpdateData(tasks); |
| | | return; |
| | | } |
| | | FOURBOTReturn fOURBOTReturn = content.Data as FOURBOTReturn; |
| | | if (fOURBOTReturn.returnCode == 0) |
| | | { |
| | | //ReturnBlockPodResultDto getBlockPod = fOURBOTReturn.data as ReturnBlockPodResultDto ?? throw new Exception("æªè·åå°é»ç¢æçå
³ç³»æ°æ®"); |
| | | var dataJson = fOURBOTReturn.data.ToString(); |
| | | if (string.IsNullOrEmpty(dataJson)) |
| | | { |
| | | foreach (var item in tasks) |
| | | { |
| | | item.ExceptionMessage = "è·åé»ç¢æçå
³ç³»å¤±è´¥ï¼"; |
| | | } |
| | | _taskService.UpdateData(tasks); |
| | | return; |
| | | } |
| | | ReturnBlockPodResultDto? getBlockPod = JsonConvert.DeserializeObject<ReturnBlockPodResultDto>(dataJson); |
| | | if (getBlockPod == null) |
| | | { |
| | | foreach (var item in tasks) |
| | | { |
| | | item.ExceptionMessage = "é»ç¢æçå
³ç³»æ°æ®è½¬æ¢å®ä½å¤±è´¥ï¼"; |
| | | } |
| | | _taskService.UpdateData(tasks); |
| | | return; |
| | | } |
| | | if (getBlockPod.Result.Count == 0) |
| | | { |
| | | throw new Exception("æªè·åå°é»ç¢æçå
³ç³»æ°æ®"); |
| | | foreach (var item in tasks) |
| | | { |
| | | item.ExceptionMessage = "æªè·åå°é»ç¢æçå
³ç³»æ°æ®ï¼"; |
| | | } |
| | | _taskService.UpdateData(tasks); |
| | | return; |
| | | } |
| | | foreach (var Result in getBlockPod.Result) |
| | | { |
| | |
| | | } |
| | | finally |
| | | { |
| | | _trackloginfoService.AddTrackLog(requestData, content, "å¤çåºåºä»»å¡æ¯å¦éè¦ç§»åº", "", ""); |
| | | //_trackloginfoService.AddTrackLog(requestData, content, "å¤çåºåºä»»å¡æ¯å¦éè¦ç§»åº", "", ""); |
| | | } |
| | | } |
| | | #endregion |