CTU故障信息接口查询,故障上报至WMS,任务下发优化
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | using WIDESEAWCS_Core.BaseRepository; |
| | | using WIDESEAWCS_IBasicInfoRepository; |
| | | using WIDESEAWCS_Model.Models; |
| | | |
| | | namespace WIDESEAWCS_BasicInfoRepository |
| | | { |
| | | public class ErrorInfoRepository : RepositoryBase<Dt_ErrorInfo>, IErrorInfoRepository |
| | | { |
| | | public ErrorInfoRepository(IUnitOfWorkManage unitOfWorkManage) : base(unitOfWorkManage) |
| | | { |
| | | } |
| | | } |
| | | } |
| | |
| | | using HslCommunication.WebSocket; |
| | | using Magicodes.ExporterAndImporter.Core; |
| | | using Magicodes.ExporterAndImporter.Core; |
| | | using Magicodes.ExporterAndImporter.Excel; |
| | | using MathNet.Numerics.Statistics.Mcmc; |
| | | using NPOI.SS.UserModel; |
| | | using NPOI.Util.Collections; |
| | | using OfficeOpenXml.FormulaParsing.Excel.Functions.RefAndLookup; |
| | | using OfficeOpenXml.FormulaParsing.Excel.Functions.Text; |
| | | using NPOI.XSSF.UserModel; |
| | | using SqlSugar; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | using WIDESEA_Core; |
| | | using WIDESEA_Core.Enums; |
| | | using System.Reflection; |
| | | using WIDESEA_DTO.Basic; |
| | | using WIDESEAWCS_Common; |
| | | using WIDESEAWCS_Common.WareHouseEnum; |
| | | using WIDESEAWCS_Common.Helper; |
| | | using WIDESEAWCS_Core; |
| | | using WIDESEAWCS_Core.BaseRepository; |
| | | using WIDESEAWCS_Core.BaseServices; |
| | | using WIDESEAWCS_Core.Helper; |
| | | using WIDESEAWCS_Core.Utilities; |
| | | using WIDESEAWCS_IBasicInfoRepository; |
| | | using WIDESEAWCS_IBasicInfoService; |
| | | using WIDESEAWCS_Model.Models; |
| | |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | string savePath = AppDomain.CurrentDomain.BaseDirectory + $"ExcelExport"; |
| | | IExporter exporter = new ExcelExporter(); |
| | | options.Page = 1; |
| | | options.Rows = 30; |
| | | options.Order = "asc"; |
| | | options.Sort = "id"; |
| | | string savePath = AppDomain.CurrentDomain.BaseDirectory + "ExcelExport"; |
| | | |
| | | string where = string.Empty; |
| | | ISugarQueryable<Dt_LocationInfo> sugarQueryable = BaseDal.Db.Queryable<Dt_LocationInfo>(); |
| | | if (!string.IsNullOrEmpty(options.Wheres)) |
| | | { |
| | | try |
| | | { |
| | | List<SearchParameters> searchParametersList = options.Wheres.DeserializeObject<List<SearchParameters>>(); |
| | | if (searchParametersList?.Any() == true) |
| | | { |
| | | foreach (var param in searchParametersList) |
| | | { |
| | | switch (param.Name) |
| | | { |
| | | // ç¡®ä¿ç®å½åå¨ |
| | | if (!Directory.Exists(savePath)) |
| | | Directory.CreateDirectory(savePath); |
| | | |
| | | } |
| | | } |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | } |
| | | } |
| | | // è·åæ°æ® |
| | | ISugarQueryable<Dt_LocationInfo> query = BaseDal.Db.Queryable<Dt_LocationInfo>(); |
| | | var dataList = query.ToList(); |
| | | var properties = typeof(Dt_LocationInfo).GetProperties(); |
| | | |
| | | |
| | | |
| | | byte[] data = exporter.ExportAsByteArray(sugarQueryable.ToList()).Result; |
| | | |
| | | string fileName = "åºä½ä¿¡æ¯.xlsx"; |
| | | |
| | | FileHelper.WriteFile(savePath, fileName, data); |
| | | |
| | | content = WebResponseContent.Instance.OK(data: savePath + "\\" + fileName); |
| | | string filePath = TExportHelper.GetExport(savePath, properties, dataList); |
| | | return WebResponseContent.Instance.OK(data: filePath); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | |
| | | [Description("AGV任塿¾è¡æ¥å£")] |
| | | AgvTaskFlow, |
| | | /// <summary> |
| | | /// AGVç¶ææ¥è¯¢æ¥å£ |
| | | /// </summary> |
| | | [Description("AGVç¶ææ¥è¯¢æ¥å£")] |
| | | AgvSearchStatus, |
| | | /// <summary> |
| | | /// WMSåºå
¥åºåé¦å®æ |
| | | /// </summary> |
| | | [Description("WMSåºå
¥åºåé¦å®æ")] |
| | |
| | | [Description("WMSæç§å¢ä¸æ¥")] |
| | | WMSLightBack, |
| | | /// <summary> |
| | | /// WMSæ
é䏿¥ |
| | | /// </summary> |
| | | [Description("WMSæ
é䏿¥")] |
| | | WMSErrorBack, |
| | | /// <summary> |
| | | /// äºææç§å¢åå§å |
| | | /// </summary> |
| | | [Description("äºææç§å¢åå§å")] |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Reflection; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | |
| | | namespace WIDESEAWCS_Common.Helper |
| | | { |
| | | public static class AttributeHelper |
| | | { |
| | | /// <summary> |
| | | /// è·å屿§ç ExporterHeader æ¾ç¤ºåç§° |
| | | /// </summary> |
| | | public static string GetExporterDisplayName(PropertyInfo property) |
| | | { |
| | | try |
| | | { |
| | | // è·å ExporterHeaderAttribute ç¹æ§ |
| | | var exporterHeaderAttr = property.GetCustomAttributes() |
| | | .FirstOrDefault(attr => attr.GetType().Name == "ExporterHeaderAttribute"); |
| | | |
| | | if (exporterHeaderAttr != null) |
| | | { |
| | | // 使ç¨åå°è·å DisplayName 屿§ |
| | | var displayNameProp = exporterHeaderAttr.GetType().GetProperty("DisplayName"); |
| | | if (displayNameProp != null) |
| | | { |
| | | var displayName = displayNameProp.GetValue(exporterHeaderAttr) as string; |
| | | if (!string.IsNullOrEmpty(displayName)) |
| | | { |
| | | return displayName; |
| | | } |
| | | } |
| | | |
| | | // æ£æ¥æ¯å¦è¢«å¿½ç¥ |
| | | var isIgnoreProp = exporterHeaderAttr.GetType().GetProperty("IsIgnore"); |
| | | if (isIgnoreProp != null) |
| | | { |
| | | var isIgnore = (bool)isIgnoreProp.GetValue(exporterHeaderAttr); |
| | | if (isIgnore) |
| | | { |
| | | return null; // è¿å null è¡¨ç¤ºå¿½ç¥æ¤å |
| | | } |
| | | } |
| | | } |
| | | } |
| | | catch |
| | | { |
| | | // 妿åºéï¼è¿å屿§å |
| | | } |
| | | |
| | | return property.Name; // é»è®¤è¿å屿§å |
| | | } |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | using NPOI.SS.UserModel; |
| | | using NPOI.Util.Collections; |
| | | using NPOI.XSSF.UserModel; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Reflection; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | |
| | | namespace WIDESEAWCS_Common.Helper |
| | | { |
| | | public static class TExportHelper |
| | | { |
| | | /// <summary> |
| | | /// å¯¼åº |
| | | /// </summary> |
| | | public static string GetExport<T>(string savePath, PropertyInfo[] properties, List<T> dataList) |
| | | { |
| | | string filePath = ""; |
| | | try |
| | | { |
| | | // å建 Excel å·¥ä½ç°¿ |
| | | IWorkbook workbook = new XSSFWorkbook(); |
| | | ISheet sheet = workbook.CreateSheet("x"); |
| | | // åå»ºè¡¨å¤´è¡ |
| | | IRow headerRow = sheet.CreateRow(0); |
| | | sheet.DefaultColumnWidth = 15; |
| | | // è®¾ç½®è¡¨å¤´æ ·å¼ |
| | | ICellStyle headerStyle = workbook.CreateCellStyle(); |
| | | IFont headerFont = workbook.CreateFont(); |
| | | headerFont.Boldweight = (short)FontBoldWeight.Bold; |
| | | headerFont.FontHeightInPoints = 12; |
| | | headerStyle.SetFont(headerFont); |
| | | headerStyle.FillForegroundColor = IndexedColors.LightBlue.Index; |
| | | headerStyle.FillPattern = FillPattern.SolidForeground; |
| | | headerStyle.BorderBottom = BorderStyle.Thin; |
| | | headerStyle.BorderTop = BorderStyle.Thin; |
| | | headerStyle.BorderLeft = BorderStyle.Medium; |
| | | headerStyle.BorderRight = BorderStyle.Medium; |
| | | |
| | | // è®¾ç½®æ°æ®æ ·å¼ |
| | | ICellStyle dataStyle = workbook.CreateCellStyle(); |
| | | dataStyle.BorderBottom = BorderStyle.Thin; |
| | | dataStyle.BorderTop = BorderStyle.Thin; |
| | | dataStyle.BorderLeft = BorderStyle.Thin; |
| | | dataStyle.BorderRight = BorderStyle.Thin; |
| | | |
| | | // å¡«å
表头 |
| | | for (int i = 0; i < properties.Length; i++) |
| | | { |
| | | var columnName = AttributeHelper.GetExporterDisplayName(properties[i]); |
| | | var cell = headerRow.CreateCell(i); |
| | | cell.SetCellValue(columnName); |
| | | cell.CellStyle = headerStyle; |
| | | } |
| | | |
| | | // å¡«å
æ°æ® |
| | | for (int rowIdx = 0; rowIdx < dataList.Count; rowIdx++) |
| | | { |
| | | IRow dataRow = sheet.CreateRow(rowIdx + 1); |
| | | var item = dataList[rowIdx]; |
| | | |
| | | for (int colIdx = 0; colIdx < properties.Length; colIdx++) |
| | | { |
| | | var cell = dataRow.CreateCell(colIdx); |
| | | var value = properties[colIdx].GetValue(item); |
| | | |
| | | // å¤çä¸åç±»åçå¼ |
| | | if (value == null) |
| | | { |
| | | cell.SetCellValue(""); |
| | | } |
| | | else if (value is DateTime dateTime) |
| | | { |
| | | cell.SetCellValue(dateTime.ToString("yyyy-MM-dd HH:mm:ss")); |
| | | } |
| | | else if (value is bool boolValue) |
| | | { |
| | | cell.SetCellValue(boolValue); |
| | | } |
| | | else |
| | | { |
| | | cell.SetCellValue(value.ToString()); |
| | | } |
| | | cell.CellStyle = dataStyle; |
| | | } |
| | | } |
| | | // ä¿åæä»¶ |
| | | string fileName = "x.xlsx"; |
| | | filePath = Path.Combine(savePath, fileName); |
| | | using (var fs = new FileStream(filePath, FileMode.Create, FileAccess.Write)) |
| | | { |
| | | workbook.Write(fs); |
| | | } |
| | | } |
| | | catch (Exception) |
| | | { |
| | | |
| | | throw; |
| | | } |
| | | return filePath; |
| | | } |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | |
| | | namespace WIDESEAWCS_DTO.Agv |
| | | { |
| | | /// <summary> |
| | | /// AGVç¶ææ¥è¯¢ |
| | | /// </summary> |
| | | public class AgvSearchStatusDTO |
| | | { |
| | | /// <summary> |
| | | /// æºå¨äººç¼ç |
| | | /// </summary> |
| | | public string RobotId { get; set; } |
| | | /// <summary> |
| | | /// æºå¨äººåå· |
| | | /// </summary> |
| | | public string RobotType { get; set; } |
| | | /// <summary> |
| | | /// å°å¾ç¼ç |
| | | /// </summary> |
| | | public string MapCode { get; set; } |
| | | /// <summary> |
| | | /// çåºç¼ç |
| | | /// </summary> |
| | | public string FloorNumber { get; set; } |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | |
| | | namespace WIDESEAWCS_DTO.Agv |
| | | { |
| | | public class StatusItem |
| | | { |
| | | /// <summary> |
| | | /// æºå¨äººç¼å· |
| | | /// </summary> |
| | | public string RobotId { get; set; } |
| | | /// <summary> |
| | | /// æç®±å· |
| | | /// </summary> |
| | | public string ContainerCode { get; set; } |
| | | /// <summary> |
| | | /// ç¶æ |
| | | /// </summary> |
| | | public int Status { get; set; } |
| | | /// å½åç¹ä½ |
| | | /// </summary> |
| | | public string NodeCode { get; set; } |
| | | /// ä»»å¡å· |
| | | /// </summary> |
| | | public string MissionCode { get; set; } |
| | | } |
| | | /// <summary> |
| | | /// æºå¨äººç¶æè¿åç»æ |
| | | /// </summary> |
| | | public class AgvStatusContent |
| | | { |
| | | /// <summary> |
| | | /// è¿åæºå¨äººç¶æéå |
| | | /// </summary> |
| | | public List<StatusItem> Data { get; set; } |
| | | /// <summary> |
| | | /// è¿å代ç |
| | | /// </summary> |
| | | public string Code { get; set; } |
| | | /// <summary> |
| | | /// è¿åä¿¡æ¯ |
| | | /// </summary> |
| | | public string Message { get; set; } |
| | | /// <summary> |
| | | /// è¿åç»æ |
| | | /// </summary> |
| | | public bool Success { get; set; } |
| | | } |
| | | } |
| | |
| | | /// </summary> |
| | | public string LIGHTCOLOR { get; set; } |
| | | /// <summary> |
| | | /// 亮ç¯ç¶æï¼1ï¼äº®ï¼2ç |
| | | /// ä¸å¡ç±»å 1ï¼å
¥åºäº®ç¯ 2ï¼åºåºäº®ç¯ |
| | | /// </summary> |
| | | public string ORDERTYPE { get; set; } |
| | | /// <summary> |
| | | /// ä¸å¡ç±»å 1ï¼å
¥åºäº®ç¯ 2ï¼åºåºäº®ç¯ |
| | | /// 亮ç¯ç¶æï¼1ï¼äº®ï¼2ç |
| | | /// </summary> |
| | | public string LIGHTTYPE { get; set; } |
| | | } |
| | |
| | | /// </summary> |
| | | public string TagCode { get; set; } |
| | | } |
| | | public class TaskError |
| | | { |
| | | /// <summary> |
| | | /// æ¶æ¯ID |
| | | /// </summary> |
| | | public int MsgID { get; set; } |
| | | /// <summary> |
| | | /// å·¥ä½ç«ç¼å·(101ã201ã301ã302ã401ã402ã501ã502) |
| | | /// </summary> |
| | | public string StationCode { get; set; } |
| | | /// <summary> |
| | | /// æ
é代ç 大äº0æ è¯æ
é,0æ è¯æ¢å¤ |
| | | /// </summary> |
| | | public int MsgCode { get; set; } |
| | | /// <summary> |
| | | /// æ
éä¿¡æ¯æè¿° |
| | | /// </summary> |
| | | public string Msg { get; set; } |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | using WIDESEAWCS_Core.BaseRepository; |
| | | using WIDESEAWCS_Model.Models; |
| | | |
| | | namespace WIDESEAWCS_IBasicInfoRepository |
| | | { |
| | | public interface IErrorInfoRepository : IRepository<Dt_ErrorInfo> |
| | | { |
| | | } |
| | | } |
| | |
| | | /// <param name="taskModel"></param> |
| | | /// <returns></returns> |
| | | WebResponseContent AgvSendTask(AgvTaskSendDTO taskModel, APIEnum SendTask = APIEnum.AgvSendTask); |
| | | /// <summary> |
| | | /// AGVä»»å¡ç¶æå·æ° |
| | | /// </summary> |
| | | /// <param name="agvUpdateModel"></param> |
| | | /// <returns></returns> |
| | | AgvResponseContent AgvUpdateTask(AgvUpdateDTO agvUpdateModel); |
| | | |
| | | /// <summary> |
| | | /// æ´æ°ä»»å¡ä¿¡æ¯åæ·»å 任塿ç»è®°å½ |
| | |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | EPLightContent ENDWORK(); |
| | | /// <summary> |
| | | /// AGVç¶ææ¥è¯¢è°ç¨åWMSæ
é䏿¥ |
| | | /// </summary> |
| | | void AgvSearchStatus(); |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | 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_ErrorInfo), "å¼å¸¸ä¿¡æ¯")] |
| | | public class Dt_ErrorInfo : BaseEntity |
| | | { |
| | | /// <summary> |
| | | /// ä¸»é® |
| | | /// </summary> |
| | | [SugarColumn(IsPrimaryKey = true, IsIdentity = true, ColumnDescription = "主é®")] |
| | | public int Id { get; set; } |
| | | |
| | | /// <summary> |
| | | /// ç«å°ç¼å· |
| | | /// </summary> |
| | | [SugarColumn(IsNullable = false, Length = 10, ColumnDescription = "ç«å°ç¼å·")] |
| | | public string StationCode { get; set; } |
| | | |
| | | /// <summary> |
| | | /// CTUç¼å· |
| | | /// </summary> |
| | | [SugarColumn(IsNullable = false, Length = 10, ColumnDescription = "CTUç¼å·")] |
| | | public string RobotCode { get; set; } |
| | | |
| | | /// <summary> |
| | | /// éè¯¯ä¿¡æ¯ |
| | | /// </summary> |
| | | [SugarColumn(IsNullable = true, Length = 200, ColumnDescription = "é误信æ¯")] |
| | | public string Message { get; set; } |
| | | } |
| | | } |
| | |
| | | namespace WIDESEAWCS_Model.Models |
| | | { |
| | | /// <summary> |
| | | /// è´§ä½ä¿¡æ¯ |
| | | /// åºä½ä¿¡æ¯ |
| | | /// </summary> |
| | | [SugarTable(nameof(Dt_LocationInfo), "è´§ä½ä¿¡æ¯")] |
| | | [SugarTable(nameof(Dt_LocationInfo), "åºä½ä¿¡æ¯")] |
| | | public class Dt_LocationInfo : BaseEntity |
| | | { |
| | | /// <summary> |
| | | /// ä¸»é® |
| | | /// </summary> |
| | | [ImporterHeader(Name = "主é®")] |
| | | [ExporterHeader(DisplayName = "主é®")] |
| | | [SugarColumn(IsPrimaryKey = true, IsIdentity = true, ColumnDescription = "主é®")] |
| | | public int Id { get; set; } |
| | |
| | | /// <summary> |
| | | /// åºåºç¼å· |
| | | /// </summary> |
| | | [ImporterHeader(IsIgnore = true)] |
| | | [ExporterHeader(IsIgnore = true)] |
| | | [ExporterHeader(DisplayName = "åºåºç¼å·")] |
| | | [SugarColumn(IsNullable = false, ColumnDescription = "åºåºç¼å·")] |
| | | public int WarehouseId { get; set; } |
| | | |
| | |
| | | /// <summary> |
| | | /// è´§ä½ç¶æ |
| | | /// </summary> |
| | | [ImporterHeader(Name = "è´§ä½ç¶æ")] |
| | | [ExporterHeader(DisplayName = "è´§ä½ç¶æ")] |
| | | [ImporterHeader(Name = "è´§ä½ç¶æ(0:空é²;1:éå®;100:æè´§)")] |
| | | [ExporterHeader(DisplayName = "è´§ä½ç¶æ(0:空é²;1:éå®;100:æè´§)")] |
| | | [SugarColumn(IsNullable = true, DefaultValue = "0", ColumnDescription = "è´§ä½ç¶æ")] |
| | | public int LocationStatus { get; set; } |
| | | |
| | | /// <summary> |
| | | /// ç¦ç¨ç¶æ |
| | | /// </summary> |
| | | [ImporterHeader(Name = "ç¦ç¨ç¶æ")] |
| | | [ExporterHeader(DisplayName = "ç¦ç¨ç¶æ")] |
| | | [ImporterHeader(Name = "ç¦ç¨ç¶æ(0:æ£å¸¸;3:ç¦ç¨)")] |
| | | [ExporterHeader(DisplayName = "ç¦ç¨ç¶æ(0:æ£å¸¸;3:ç¦ç¨)")] |
| | | [SugarColumn(IsNullable = true, DefaultValue = "0", ColumnDescription = "ç¦ç¨ç¶æ")] |
| | | public int EnableStatus { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 夿³¨ |
| | | /// </summary> |
| | | [ImporterHeader(Name = "夿³¨")] |
| | | [ExporterHeader(DisplayName = "夿³¨")] |
| | | [SugarColumn(IsNullable = true, Length = 200, ColumnDescription = "夿³¨")] |
| | | public string Remark { get; set; } |
| | |
| | | /// <summary> |
| | | /// æçç±»å |
| | | /// </summary> |
| | | [ImporterHeader(Name = "æçç±»å")] |
| | | [ExporterHeader(IsIgnore =true)] |
| | | [SugarColumn(IsNullable = false, ColumnDescription = "æçç±»å")] |
| | | [ImporterHeader(Name = "æç®±ç±»å")] |
| | | [ExporterHeader(DisplayName = "æç®±ç±»å")] |
| | | [SugarColumn(IsNullable = false, ColumnDescription = "æç®±ç±»å")] |
| | | public int PalletType { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 设å¤ç¼å· |
| | | /// </summary> |
| | | [ImporterHeader(Name = "设å¤ç¼å·")] |
| | | [ExporterHeader(IsIgnore = true)] |
| | | [ExporterHeader(DisplayName = "设å¤ç¼å·")] |
| | | [SugarColumn(IsNullable = false, Length = 50, ColumnDescription = "设å¤ç¼å·")] |
| | | public string DeviceCode { get; set; } |
| | | |
| | |
| | | } |
| | | return content; |
| | | } |
| | | /// <summary> |
| | | /// AGVä½ä¸å®æ |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | [HttpPost, HttpGet, Route("AgvSearchStatus"), AllowAnonymous] |
| | | public void AgvSearchStatus() |
| | | { |
| | | _taskService.AgvSearchStatus(); |
| | | } |
| | | } |
| | | } |
| | |
| | | // 注æï¼http://127.0.0.1:1818 å http://localhost:1818 æ¯ä¸ä¸æ ·ç |
| | | "IPs": "http://127.0.0.1:8080,http://localhost:8080" |
| | | }, |
| | | "ApiLogIgnore": "Export,Get,get", |
| | | "WMSApiAddress": "http://127.0.0.1:9293", //"http://127.0.0.1:9283",æ£å¼ç¯å¢å°å |
| | | "LogDeubgEnable": true, //æ¯å¦è®°å½è°è¯æ¥å¿ |
| | | "PrintSql": false, //æå°SQLè¯å¥ |
| | |
| | | using WIDESEAWCS_Core; |
| | | using WIDESEAWCS_Core.Helper; |
| | | using WIDESEAWCS_DTO.Agv; |
| | | using System.Reflection.Metadata; |
| | | using WIDESEAWCS_Model.Models; |
| | | using WIDESEAWCS_DTO.TaskInfo; |
| | | |
| | | namespace WIDESEAWCS_TaskInfoService |
| | | { |
| | |
| | | return content; |
| | | } |
| | | /// <summary> |
| | | /// AGVä»»å¡ç¶æå·æ°/AGVä»»å¡å®æ |
| | | /// AGVç¶ææ¥è¯¢è°ç¨åWMSæ
é䏿¥ |
| | | /// </summary> |
| | | /// <param name="agvUpdateModel"></param> |
| | | /// <returns></returns> |
| | | public AgvResponseContent AgvUpdateTask(AgvUpdateDTO agvUpdateModel) |
| | | public void AgvSearchStatus() |
| | | { |
| | | return new AgvResponseContent(); |
| | | try |
| | | { |
| | | AgvSearchStatusDTO agvSearchStatusDTO = new AgvSearchStatusDTO(); |
| | | string? apiAddress = _apiInfoRepository.QueryFirst(x => x.ApiCode == APIEnum.AgvSearchStatus.ToString())?.ApiAddress; |
| | | if (string.IsNullOrEmpty(apiAddress)) throw new Exception($"æªæ¾å°AGVç¶ææ¥è¯¢æ¥å£,è¯·æ£æ¥æ¥å£é
ç½®"); |
| | | string? apiErrorBack = _apiInfoRepository.QueryFirst(x => x.ApiCode == APIEnum.WMSErrorBack.ToString())?.ApiAddress; |
| | | if (string.IsNullOrEmpty(apiErrorBack)) throw new Exception($"æªæ¾å°WMSæ
é䏿¥,è¯·æ£æ¥æ¥å£é
ç½®"); |
| | | string request = JsonConvert.SerializeObject(agvSearchStatusDTO, settings); |
| | | string response = HttpHelper.Post(apiAddress, request); |
| | | AgvStatusContent agvContent = response.DeserializeObject<AgvStatusContent>() ?? throw new Exception("AGVç¶ææ¥è¯¢æªè¿åç»æ"); |
| | | |
| | | //è·åæææ
éä¿¡æ¯ |
| | | List <Dt_ErrorInfo> errorInfos = _errorInfoRepository.QueryData(); |
| | | int errorId = errorInfos.Count > 0 ? errorInfos.Max(x => x.Id) : 0; |
| | | List<Dt_ErrorInfo> delErrorInfos = new List<Dt_ErrorInfo>(); |
| | | List<Dt_ErrorInfo> addErrorInfos = new List<Dt_ErrorInfo>(); |
| | | //è·åä»»å¡ä¿¡æ¯ |
| | | List<Dt_Task> tasks = BaseDal.QueryData(); |
| | | if (agvContent.Success) |
| | | { |
| | | foreach (var item in agvContent.Data.Where(x => errorInfos.Select(x => x.RobotCode).Contains(x.RobotId) && x.Status != 7)) |
| | | { |
| | | //䏿¥æ
éæ¢å¤ |
| | | Dt_ErrorInfo errorInfo = errorInfos.FirstOrDefault(x => x.RobotCode == item.RobotId); |
| | | |
| | | delErrorInfos.Add(errorInfo); |
| | | } |
| | | foreach (var item in agvContent.Data.Where(x => !x.MissionCode.IsNullOrEmpty() && !errorInfos.Select(x => x.RobotCode).Contains(x.RobotId) && x.Status == 7)) |
| | | { |
| | | Dt_Task? task = tasks.FirstOrDefault(x=>x.TaskNum == item.MissionCode.ObjToInt() || x.GroupId==item.MissionCode); |
| | | if (task != null) |
| | | { |
| | | Dt_ErrorInfo errorInfo = new Dt_ErrorInfo() |
| | | { |
| | | RobotCode = item.RobotId, |
| | | Message = "æ
é" |
| | | }; |
| | | if (task.TaskType==TaskTypeEnum.Inbound.ObjToInt()) |
| | | { |
| | | errorInfo.StationCode = task.CurrentAddress; |
| | | } |
| | | else |
| | | { |
| | | errorInfo.StationCode = task.NextAddress; |
| | | } |
| | | addErrorInfos.Add(errorInfo); |
| | | } |
| | | } |
| | | } |
| | | //æ°æ®åºæä½ |
| | | _unitOfWorkManage.BeginTran(); |
| | | _errorInfoRepository.DeleteData(delErrorInfos); |
| | | _errorInfoRepository.AddData(addErrorInfos); |
| | | _unitOfWorkManage.CommitTran(); |
| | | List<Dt_ErrorInfo> newErrInfos = _errorInfoRepository.QueryData(x=>x.Id > errorId); |
| | | if (delErrorInfos.Count>0) |
| | | { |
| | | foreach (var item in delErrorInfos) |
| | | { |
| | | TaskError taskError = new TaskError() |
| | | { |
| | | MsgID = item.Id, |
| | | StationCode = item.StationCode, |
| | | MsgCode = 0, |
| | | Msg = "æ¢å¤" |
| | | }; |
| | | string reqErrorBack = JsonConvert.SerializeObject(taskError, settings); |
| | | HttpHelper.Post(apiErrorBack, reqErrorBack); |
| | | } |
| | | } |
| | | if (newErrInfos.Count>0) |
| | | { |
| | | //ä¸ä¼ æ
é |
| | | foreach (var item in newErrInfos) |
| | | { |
| | | TaskError taskError = new TaskError() |
| | | { |
| | | MsgID = item.Id, |
| | | StationCode = item.StationCode, |
| | | MsgCode = 1, |
| | | Msg = item.Message |
| | | }; |
| | | string reqErrorBack = JsonConvert.SerializeObject(taskError, settings); |
| | | HttpHelper.Post(apiErrorBack, reqErrorBack); |
| | | } |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | throw new Exception(ex.Message); |
| | | } |
| | | |
| | | } |
| | | } |
| | | } |
| | |
| | | using Microsoft.AspNetCore.Mvc; |
| | | using Newtonsoft.Json; |
| | | using NPOI.SS.Formula.Functions; |
| | | using NPOI.SS.UserModel; |
| | | using NPOI.XSSF.UserModel; |
| | | using SqlSugar; |
| | | using System.Diagnostics.CodeAnalysis; |
| | | using System.DirectoryServices.Protocols; |
| | |
| | | using WIDESEAWCS_BasicInfoService; |
| | | using WIDESEAWCS_Common; |
| | | using WIDESEAWCS_Common.APIEnum; |
| | | using WIDESEAWCS_Common.Helper; |
| | | using WIDESEAWCS_Common.TaskEnum; |
| | | using WIDESEAWCS_Core; |
| | | using WIDESEAWCS_Core.BaseRepository; |
| | |
| | | private readonly ILocationInfoRepository _locationInfoRepository; |
| | | private readonly ILocationInfoService _locationInfoService; |
| | | private readonly ILocationStatusChangeRecordService _locationStatusChangeRecordService; |
| | | private readonly IErrorInfoRepository _errorInfoRepository; |
| | | |
| | | private Dictionary<string, OrderByType> _taskOrderBy = new() |
| | | { |
| | |
| | | |
| | | public List<int> TaskRelocationTypes => typeof(TaskTypeEnum).GetEnumIndexList().Where(x => x >= 900 && x < 1000).ToList(); |
| | | |
| | | public TaskService(ITaskRepository BaseDal, IMapper mapper, ICacheService cacheService, IRouterService routerService, ITaskExecuteDetailService taskExecuteDetailService, ITaskExecuteDetailRepository taskExecuteDetailRepository, IStationMangerRepository stationMangerRepository, IRouterRepository routerRepository, IApiInfoRepository apiInfoRepository,ILocationInfoRepository locationInfoRepository,IUnitOfWorkManage unitOfWorkManage, ILocationInfoService locationInfoService,ILocationStatusChangeRecordService locationStatusChangeRecordService) : base(BaseDal) |
| | | public TaskService(ITaskRepository BaseDal, IMapper mapper, ICacheService cacheService, IRouterService routerService, ITaskExecuteDetailService taskExecuteDetailService, ITaskExecuteDetailRepository taskExecuteDetailRepository, IStationMangerRepository stationMangerRepository, IRouterRepository routerRepository, IApiInfoRepository apiInfoRepository,ILocationInfoRepository locationInfoRepository,IUnitOfWorkManage unitOfWorkManage, ILocationInfoService locationInfoService,ILocationStatusChangeRecordService locationStatusChangeRecordService,IErrorInfoRepository errorInfoRepository) : base(BaseDal) |
| | | { |
| | | _mapper = mapper; |
| | | _cacheService = cacheService; |
| | |
| | | _unitOfWorkManage = unitOfWorkManage; |
| | | _locationInfoService = locationInfoService; |
| | | _locationStatusChangeRecordService=locationStatusChangeRecordService; |
| | | _errorInfoRepository = errorInfoRepository; |
| | | } |
| | | static object lock_taskReceive = new object(); |
| | | /// <summary> |
| | |
| | | List<Dt_Task> taskOlds = BaseDal.QueryData(x=> taskDTO.Tasks.Select(x => x.TaskDescribe.ContainerCode).Contains(x.PalletCode)); |
| | | List<Dt_LocationInfo> locationInfos = _locationInfoRepository.GetCanOut(taskDTO.Tasks.Select(x=>x.TaskDescribe.ContainerCode).ToList()); |
| | | List<Dt_StationManger> stationMangers = _stationMangerRepository.QueryData(); |
| | | //ä¸åä»»å¡ç» |
| | | string taskGroup= taskDTO.TaskGroupCode.IsNullOrEmpty() ? Guid.NewGuid().ToString().Replace("-","") : taskDTO.TaskGroupCode; |
| | | ////ä¸åä»»å¡ç» |
| | | //string taskGroup= taskDTO.TaskGroupCode.IsNullOrEmpty() ? Guid.NewGuid().ToString().Replace("-","") : taskDTO.TaskGroupCode; |
| | | foreach (var item in taskDTO.Tasks.OrderBy(x=>x.TaskDescribe.ToStationCode)) |
| | | { |
| | | if (item.TaskDescribe.ToStationCode.IsNullOrEmpty()) throw new Exception($"ä»»å¡{item.TaskCode}åºåºç®æ æä½å°ä¸è½ä¸ºç©º"); |
| | |
| | | task.CurrentAddress = locationInfo.LocationCode; |
| | | task.NextAddress = stationManger.PickStationCode; |
| | | task.TargetAddress = stationManger.PickStationCode; |
| | | task.GroupId = taskGroup; |
| | | //task.GroupId = taskGroup; |
| | | task.TaskType = TaskTypeEnum.Outbound.ObjToInt(); |
| | | task.Roadway = locationInfo.RoadwayNo; |
| | | task.DeviceCode = stationManger.CraneCode; |
| | |
| | | "Red" => "4", |
| | | _ => throw new Exception($"æªæ¾å°é¢è²å®ä¹") |
| | | }, |
| | | ORDERTYPE=taskSendLight.Mode.ToString(), |
| | | LIGHTTYPE="1", |
| | | ORDERTYPE="1", |
| | | LIGHTTYPE=taskSendLight.Mode.ToString(), |
| | | } |
| | | }; |
| | | EPLightContent pLightContent = PickOrderInfoRequest(lightSendDTOs); |
| | |
| | | } |
| | | return content; |
| | | } |
| | | public override WebResponseContent Export(PageDataOptions options) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | string savePath = AppDomain.CurrentDomain.BaseDirectory + "ExcelExport"; |
| | | |
| | | // ç¡®ä¿ç®å½åå¨ |
| | | if (!Directory.Exists(savePath)) |
| | | Directory.CreateDirectory(savePath); |
| | | |
| | | // è·åæ°æ® |
| | | ISugarQueryable<Dt_Task> query = BaseDal.Db.Queryable<Dt_Task>(); |
| | | var dataList = query.ToList(); |
| | | var properties = typeof(Dt_Task).GetProperties(); |
| | | |
| | | string filePath = TExportHelper.GetExport(savePath, properties, dataList); |
| | | return WebResponseContent.Instance.OK(data: filePath); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | content = WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | return content; |
| | | } |
| | | } |
| | | } |
| | |
| | |  |
| | | using AutoMapper; |
| | | using NPOI.SS.UserModel; |
| | | using NPOI.XSSF.UserModel; |
| | | using SqlSugar; |
| | | using System.Diagnostics.CodeAnalysis; |
| | | using System.Threading.Tasks; |
| | | using WIDESEAWCS_Common.Helper; |
| | | using WIDESEAWCS_Core; |
| | | using WIDESEAWCS_Core.BaseServices; |
| | | using WIDESEAWCS_Core.Helper; |
| | | using WIDESEAWCS_ITaskInfo_HtyRepository; |
| | | using WIDESEAWCS_ITaskInfo_HtyService; |
| | | using WIDESEAWCS_Model.Models; |
| | |
| | | public Task_HtyService(ITask_HtyRepository BaseDal) : base(BaseDal) |
| | | { |
| | | } |
| | | public override WebResponseContent Export(PageDataOptions options) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | string savePath = AppDomain.CurrentDomain.BaseDirectory + "ExcelExport"; |
| | | |
| | | // ç¡®ä¿ç®å½åå¨ |
| | | if (!Directory.Exists(savePath)) |
| | | Directory.CreateDirectory(savePath); |
| | | |
| | | // è·åæ°æ® |
| | | ISugarQueryable<Dt_Task_Hty> query = BaseDal.Db.Queryable<Dt_Task_Hty>(); |
| | | var dataList = query.ToList(); |
| | | var properties = typeof(Dt_Task_Hty).GetProperties(); |
| | | string filePath = TExportHelper.GetExport(savePath, properties, dataList); |
| | | return WebResponseContent.Instance.OK(data: filePath); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | content = WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | return content; |
| | | } |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | using AutoMapper; |
| | | using Quartz; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | using WIDESEAWCS_IBasicInfoRepository; |
| | | using WIDESEAWCS_ITaskInfoService; |
| | | using WIDESEAWCS_QuartzJob; |
| | | using WIDESEAWCS_QuartzJob.Service; |
| | | |
| | | namespace WIDESEAWCS_Tasks |
| | | { |
| | | [DisallowConcurrentExecution] |
| | | public partial class AGVErrorJob : JobBase, IJob |
| | | { |
| | | public readonly ITaskService _taskService; |
| | | private readonly ITaskExecuteDetailService _taskExecuteDetailService; |
| | | private readonly IRouterService _routerService; |
| | | private readonly IStationMangerRepository _stationMangerRepository; |
| | | private readonly ILocationInfoRepository _locationInfoRepository; |
| | | private readonly IMapper _mapper; |
| | | |
| | | public AGVErrorJob(ITaskService taskService, ITaskExecuteDetailService taskExecuteDetailService, IRouterService routerService, IStationMangerRepository stationMangerRepository, ILocationInfoRepository locationInfoRepository, IMapper mapper) |
| | | { |
| | | _taskService = taskService; |
| | | _taskExecuteDetailService = taskExecuteDetailService; |
| | | _routerService = routerService; |
| | | _stationMangerRepository = stationMangerRepository; |
| | | _locationInfoRepository = locationInfoRepository; |
| | | _mapper = mapper; |
| | | } |
| | | public Task Execute(IJobExecutionContext context) |
| | | { |
| | | try |
| | | { |
| | | _taskService.AgvSearchStatus(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | WriteError(nameof(AGVErrorJob),ex.Message); |
| | | } |
| | | return Task.CompletedTask; |
| | | } |
| | | } |
| | | } |
| | |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | using WIDESEA_DTO.Agv; |
| | | using WIDESEAWCS_Common; |
| | | using WIDESEAWCS_Common.APIEnum; |
| | | using WIDESEAWCS_Common.TaskEnum; |
| | | using WIDESEAWCS_Core; |
| | |
| | | { |
| | | var newTasksOut = _taskService.Db.Queryable<Dt_Task>().Where(x => (x.TaskState == TaskStatusEnum.AGV_Execute.ObjToInt()) && x.TaskType==TaskTypeEnum.Outbound.ObjToInt() && x.DeviceCode == "AGV").ToList().OrderBy(x => x.Grade).ThenBy(x => x.TaskNum).ToList(); |
| | | var newTasksIn = _taskService.Db.Queryable<Dt_Task>().Where(x => (x.TaskState == TaskStatusEnum.AGV_Execute.ObjToInt()) && x.TaskType == TaskTypeEnum.Inbound.ObjToInt() && x.DeviceCode == "AGV").ToList().OrderBy(x => x.Grade).ThenBy(x => x.TaskNum).ToList(); |
| | | var taskDownOut = _taskService.Db.Queryable<Dt_Task>().Where(x => (x.TaskState > TaskStatusEnum.AGV_Execute.ObjToInt()) && x.TaskType == TaskTypeEnum.Outbound.ObjToInt() && x.DeviceCode == "AGV").OrderBy(x => x.TaskNum).ToList(); |
| | | #region åºåºä»»å¡ä¸å |
| | | if (newTasksOut.Count>0) |
| | | { |
| | | List<string> GroupIds = newTasksOut.GroupBy(x => x.GroupId).Select(x => x.Key).ToList(); |
| | | foreach (var GroupId in GroupIds) |
| | | foreach (var GroupTask in newTasksOut.GroupBy(x=>x.NextAddress)) |
| | | { |
| | | var tasks = newTasksOut.Where(x => x.GroupId == GroupId).ToList(); |
| | | var tasks = GroupTask.OrderBy(x => x.TaskNum).ToList(); |
| | | TimeSpan span = DateTime.Now - tasks.FirstOrDefault().CreateDate; |
| | | int taskDownCount = taskDownOut.Where(x => x.NextAddress == GroupTask.Key).Count(); |
| | | if (taskDownCount < (GroupTask.ObjToInt() > 201 ? 4 : 6) && (int)span.TotalSeconds > 20) |
| | | { |
| | | try |
| | | { |
| | | AgvTaskSendDTO agvTaskSend = new AgvTaskSendDTO() |
| | | { |
| | | MissionData = new List<MissionDataItem>() |
| | | }; |
| | | string taskGroupId = Guid.NewGuid().ToString().Replace("-", ""); |
| | | foreach (var task in tasks) |
| | | { |
| | | //è·åç®æ ç¹è´§ä½ |
| | |
| | | Dt_StationManger stationMangerEnd = _stationMangerRepository.QueryFirst(x => x.PickStationCode == task.NextAddress); |
| | | |
| | | if (locationInfoStart == null || stationMangerEnd == null) throw new Exception($"æªæ¾å°ä»»å¡å·${task.TaskNum}èµ·å§ç¹{task.CurrentAddress}æç®æ ç¹{task.NextAddress}ä½ç½®ä¿¡æ¯"); |
| | | agvTaskSend.RequestId = GroupId; |
| | | agvTaskSend.MissionCode = GroupId; |
| | | agvTaskSend.RequestId = taskGroupId; |
| | | agvTaskSend.MissionCode = taskGroupId; |
| | | agvTaskSend.ViewBoardType = "W01"; |
| | | if (task.Grade == 0) |
| | | { |
| | | agvTaskSend.Priority = 99; |
| | | } |
| | | else |
| | | { |
| | | agvTaskSend.Priority = 99 - task.Grade; |
| | | } |
| | | //æç®±åæ¬è¿ä»»å¡ |
| | | MissionDataItem missionDataItem = new MissionDataItem() |
| | | { |
| | |
| | | }; |
| | | agvTaskSend.MissionData.Add(missionDataItem); |
| | | } |
| | | if (tasks.OrderByDescending(x => x.Grade).FirstOrDefault()?.Grade == 0) |
| | | { |
| | | agvTaskSend.Priority = 99; |
| | | } |
| | | else |
| | | { |
| | | agvTaskSend.Priority = 99 - tasks.OrderByDescending(x => x.Grade).FirstOrDefault().Grade; |
| | | } |
| | | tasks.ForEach(x => |
| | | { |
| | | x.GroupId = taskGroupId; |
| | | }); |
| | | //åéAGVä»»å¡ |
| | | WebResponseContent content = _taskService.AgvSendTask(agvTaskSend, APIEnum.AgvSendTask); |
| | | if (!content.Status) |
| | |
| | | } |
| | | } |
| | | } |
| | | } |
| | | #endregion |
| | | #region å
¥åºä»»å¡ä¸å |
| | | if (newTasksIn.Count > 0) |