| | |
| | | using MailKit.Search; |
| | | using Microsoft.AspNetCore.Http; |
| | | using Microsoft.AspNetCore.Mvc; |
| | | using Microsoft.Extensions.Logging; |
| | | using OfficeOpenXml.FormulaParsing.Excel.Functions.DateTime; |
| | |
| | | using System.Linq; |
| | | using System.Reflection; |
| | | using System.Reflection.Metadata; |
| | | using System.Security.Cryptography.X509Certificates; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | using WIDESEA_Common.LocationEnum; |
| | |
| | | using WIDESEA_Core.Helper; |
| | | using WIDESEA_DTO.Inbound; |
| | | using WIDESEA_DTO.Task; |
| | | using WIDESEA_IStockService; |
| | | using WIDESEA_ITaskInfoService; |
| | | using WIDESEA_Model.Models; |
| | | using static WIDESEA_ITaskInfoService.ITaskService; |
| | | |
| | |
| | | { |
| | | public partial class TaskService |
| | | { |
| | | public static List<string> InStationareaList = new List<string>() { "1113", "1114", "1115", "1116", "1117", "1118", "1119", "1120", "1121", "1122" ,"1123"}; |
| | | //å
¥åºï¼ç©ºçååº |
| | | public ApiResponse AddInStoreDoc(MES_InTask mES_In) |
| | | { |
| | | WriteLog.GetLog("æ¥æ¶MESå
¥åºä»»å¡ä¸å").Write($"åæ°ï¼{mES_In.ToJson()}", $"任塿¥æ¶åæ°"); |
| | | WriteLog.Write_Log("MES_æ¥æ¶å
¥åºä»»å¡ä¸å", $"任塿¥æ¶åæ°", "æ¥æ¶åæ°", $"åæ°ï¼{mES_In.ToJson()}"); |
| | | ApiResponse apiResponse = new ApiResponse(); |
| | | try |
| | | { |
| | |
| | | if (string.IsNullOrWhiteSpace(mES_In.endPosition)) return apiResponse.Error("ç®æ ä½ç½®ä¸è½ä¸ºç©º"); |
| | | if (string.IsNullOrWhiteSpace(mES_In.containerType)) return apiResponse.Error("è½½å
·ç±»åä¸è½ä¸ºç©º"); //è½½å
·ç±»åï¼å¸æ-1ï¼æ¾å¸å·-2ï¼æå-1 |
| | | |
| | | Dt_Task setask = BaseDal.QueryData(x => x.PalletCode == mES_In.containerNo).FirstOrDefault(); |
| | | if (setask != null) return apiResponse.Error($"WMSå·²æå½åä»»å¡ï¼ä¸å¯éå¤ä¸åï¼æçç¼å·ï¼{mES_In.containerNo}"); |
| | | |
| | | // 夿ä¸åçæçç¼å·æ¯å¦åºåæçç¼å·æéå¤ |
| | | if (_stockInfoService.IsContainerNoExist(mES_In.containerNo)) return apiResponse.Error($"å½ååºä½å·²æè¯¥æçç¼å·ï¼æçç¼å·ï¼{mES_In.containerNo}"); |
| | | Dt_Warehouse dt_Warehouse = _warehouseService.QueryWarehouse(mES_In.warehouseNo); |
| | | if (dt_Warehouse == null) return apiResponse.Error($"WMSæªè½æ¥è¯¢é对åºä»åºï¼ä»åºç¼ç ï¼{mES_In.warehouseNo}"); |
| | | int LocationType = 1; |
| | | if (dt_Warehouse.WarehouseType == (int)WarehouseEnum.YMYL) |
| | | string Roadway = "0"; |
| | | |
| | | string SourceAddress = mES_In.startPosition; |
| | | string TargetAddress = ""; |
| | | string CurrentAddress = mES_In.startPosition; |
| | | string NextAddress = ""; |
| | | int WarehouseId = dt_Warehouse.WarehouseId; |
| | | |
| | | |
| | | if (dt_Warehouse.WarehouseCode == mES_In.endPosition) |
| | | { |
| | | if (mES_In.containerType == "2") LocationType = 2; |
| | | if (dt_Warehouse.WarehouseType == (int)WarehouseEnum.YMYL) |
| | | { |
| | | if (mES_In.containerType == "2") LocationType = 2; |
| | | } |
| | | else if (dt_Warehouse.WarehouseType == (int)WarehouseEnum.YMCP) |
| | | { |
| | | LocationType = 3; |
| | | } |
| | | Roadway = _locationInfoService.AccessingTunnel(dt_Warehouse.WarehouseId, LocationType); |
| | | if (Roadway == "0") return apiResponse.Error($"WMSæªè½æ¥è¯¢é对åºå··éç¼å·ï¼ä»åºç¼ç ï¼{mES_In.warehouseNo}"); |
| | | //è·å对åºPLCç«å°ä¿¡æ¯ |
| | | Dt_roadwayinfo _Roadwayinfo = _roadWayinfoService.QbtainPlatform(Roadway); |
| | | NextAddress = _Roadwayinfo.InStationCode; |
| | | } |
| | | |
| | | string Roadway = _locationInfoService.AccessingTunnel(dt_Warehouse.WarehouseId, LocationType); |
| | | if (Roadway == "") return apiResponse.Error($"WMSæªè½æ¥è¯¢é对åºå··éç¼å·ï¼ä»åºç¼ç ï¼{mES_In.warehouseNo}"); |
| | | |
| | | //è·å对åºPLCç«å°ä¿¡æ¯ |
| | | Dt_roadwayinfo _Roadwayinfo = _roadWayinfoService.QbtainPlatform(Roadway); |
| | | |
| | | else |
| | | { |
| | | if (dt_Warehouse.WarehouseType == (int)WarehouseEnum.YMYL) |
| | | { |
| | | Roadway="1"; |
| | | } |
| | | else if (dt_Warehouse.WarehouseType == (int)WarehouseEnum.YMCP) |
| | | { |
| | | Roadway = "2"; |
| | | } |
| | | TargetAddress = mES_In.endPosition; |
| | | NextAddress = mES_In.endPosition; |
| | | } |
| | | |
| | | Dt_Task task = new Dt_Task(); |
| | | task.TaskNum = mES_In.transNo; |
| | |
| | | task.Roadway = Roadway; |
| | | task.TaskType = (int)TaskTypeEnum.Inbound; |
| | | task.TaskStatus = (int)InTaskStatusEnum.InNew; |
| | | task.SourceAddress = mES_In.startPosition; |
| | | task.TargetAddress = ""; |
| | | task.CurrentAddress = mES_In.startPosition; |
| | | task.NextAddress = _Roadwayinfo.InStationCode; |
| | | task.WarehouseId = dt_Warehouse.WarehouseId; |
| | | task.SourceAddress = SourceAddress; |
| | | task.TargetAddress = TargetAddress; |
| | | task.CurrentAddress = CurrentAddress; |
| | | task.NextAddress = NextAddress; |
| | | task.WarehouseId = WarehouseId; |
| | | task.OrderNo = mES_In.transDate.ToString(); |
| | | task.Grade = 1; |
| | | task.Creater = "MES"; |
| | | task.CreateDate = DateTime.Now; |
| | | |
| | | Dt_StockInfo dt_StockInfo = new Dt_StockInfo(); |
| | | dt_StockInfo.PalletCode = task.PalletCode; |
| | | dt_StockInfo.PalletType = task.PalletType; |
| | | dt_StockInfo.WarehouseId = task.WarehouseId; |
| | | dt_StockInfo.StockStatus = (int)StockStatusEmun.å
¥åºä¸; |
| | | dt_StockInfo.Creater = "MWS"; |
| | | dt_StockInfo.CreateDate = DateTime.Now; |
| | | int taskid=BaseDal.AddData(task); |
| | | |
| | | _unitOfWorkManage.BeginTran(); |
| | | BaseDal.AddData(task); |
| | | _stockInfoService.Repository.AddData(dt_StockInfo); |
| | | _unitOfWorkManage.CommitTran(); |
| | | WriteLog.GetLog("æ¥æ¶MESå
¥åºä»»å¡ä¸å").Write($"åæ°ï¼{mES_In.containerNo}", $"å
¥åºä»»å¡æ·»å æå"); |
| | | return apiResponse.OK(); |
| | | //å建任å¡åï¼å¤ææ¯å¦æ¯äº§çº¿ååºçä»»å¡ |
| | | if (!InStationareaList.Contains(task.SourceAddress)) |
| | | { |
| | | WriteLog.Write_Log("MES_æ¥æ¶å
¥åºä»»å¡ä¸å", $"åé¦ä¿¡æ¯", "æå", $"任塿·»å æåï¼æçæ¡ç ï¼{task.PalletCode}"); |
| | | return apiResponse.OK(); |
| | | } |
| | | else |
| | | { |
| | | WCSginseng result = PLC_IssueTasks( |
| | | taskid, // 䏿¯task.Taskid |
| | | task.WarehouseId, |
| | | task.TaskNum, |
| | | task.PalletCode, |
| | | int.Parse(task.PalletType), |
| | | task.CurrentAddress, |
| | | task.NextAddress, |
| | | ""); |
| | | if (result.IsSuccess) |
| | | { |
| | | Dt_Task deltaskin = BaseDal.QueryData(x => x.TaskId == taskid).FirstOrDefault(); |
| | | deltaskin.TaskStatus = (int)InTaskStatusEnum.PLC_InExecuting; |
| | | string Result = MesInTaskStatusEnum.Start.GetDescription(); |
| | | BaseDal.UpdateData(deltaskin); |
| | | //è°å䏿¸¸ç³»ç»åé¦å¼å§ä»»å¡ |
| | | InStoreDocCallback(task.TaskNum, Result, "æä½æå", task.PalletCode, ""); |
| | | return apiResponse.OK(); |
| | | } |
| | | else |
| | | { |
| | | Dt_Task deltask= BaseDal.QueryData(x => x.TaskId == taskid).FirstOrDefault(); |
| | | BaseDal.DeleteData(deltask); |
| | | return apiResponse.Error($"ä¸åä»»å¡å¤±è´¥ï¼ä¸åWCS失败ï¼åå ï¼{result.Message}"); |
| | | } |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | WriteLog.GetLog("æ¥æ¶MESå
¥åºä»»å¡ä¸å").Write($"åå ï¼{ex.Message}", $"å
¥åºä»»å¡æ·»å "); |
| | | WriteLog.Write_Log("MES_æ¥æ¶å
¥åºä»»å¡ä¸å", $"åé¦ä¿¡æ¯", "失败", $"任塿·»å å¤±è´¥ï¼æçæ¡ç ï¼{mES_In.containerNo},ç³»ç»åºéåå ï¼{ex.Message}"); |
| | | return apiResponse.Error($"WMS任塿·»å é误ï¼åå ï¼{ex.Message}"); |
| | | } |
| | | |
| | |
| | | //åºåºä»»å¡ |
| | | public ApiResponse AddOutStoreDoc(MES_InTask mES_In) |
| | | { |
| | | WriteLog.GetLog("æ¥æ¶MESåºåºä»»å¡ä¸å").Write($"åæ°ï¼{mES_In.ToJson()}", $"任塿¥æ¶åæ°"); |
| | | WriteLog.Write_Log("MES_æ¥æ¶MESåºåºä»»å¡ä¸å", $"任塿¥æ¶åæ°", "æ¥æ¶åæ°", $"åæ°ï¼{mES_In.ToJson()}"); |
| | | |
| | | ApiResponse apiResponse = new ApiResponse(); |
| | | try |
| | | { |
| | |
| | | if (string.IsNullOrWhiteSpace(mES_In.containerNo)) return apiResponse.Error("æçç ä¸è½ä¸ºç©º"); |
| | | if (string.IsNullOrWhiteSpace(mES_In.endPosition)) return apiResponse.Error("ç®æ ä½ç½®ä¸è½ä¸ºç©º"); |
| | | |
| | | |
| | | Dt_StockInfo dt_Stock=_stockInfoService.Repository.QueryData(x=>x.PalletCode== mES_In.containerNo && x.StockStatus== (int)StockStatusEmun.å·²å
¥åº).FirstOrDefault(); |
| | | // å½åä»»å¡mES_In.endPositionç®æ ä½ç½®1113 - 1122 |
| | | var restrictedPositions = new List<string> { "1113", "1114", "1115", "1116", "1117", "1118", "1119", "1120", "1121", "1122", "1123" }; |
| | | bool isRestrictedPosition = restrictedPositions.Contains(mES_In.endPosition); |
| | | if (isRestrictedPosition) |
| | | { |
| | | bool hasExistingTask = BaseDal.QueryData(x => x.TargetAddress == mES_In.endPosition).Any(); |
| | | if (hasExistingTask) |
| | | { |
| | | // ç®æ ä½ç½®å¨1113-1122èå´å
çå¤çé»è¾ |
| | | return apiResponse.Error($"å½åæå»ç®æ ä½ç½®{mES_In.endPosition}çä»»å¡ï¼è¯·éæ°æä½"); |
| | | } |
| | | } |
| | | Dt_StockInfo dt_Stock=_stockInfoService.Repository.QueryData(x=>x.PalletCode== mES_In.containerNo).FirstOrDefault(); |
| | | if (dt_Stock == null) return apiResponse.Error($"WMSæªè½æ¥æ¾é该æçæ¡ç çåºåè´§ä½ä¿¡æ¯ï¼æ¡ç ï¼{mES_In.containerNo}"); |
| | | |
| | | Dt_LocationInfo dt_LocationInfo = _locationInfoService.Repository.QueryData(x => x.LocationCode == dt_Stock.LocationCode && x.LocationStatus== (int)LocationStatusEnum.InStock).FirstOrDefault(); |
| | | if (dt_LocationInfo == null) return apiResponse.Error($"WMSæªè½æ¥æ¾é该æçæ¡ç çåºåè´§ä½ä¿¡æ¯ï¼æ¡ç ï¼{mES_In.containerNo}ï¼æªæ¾å°è´§ä½å·ï¼{dt_Stock.LocationCode}"); |
| | | if(dt_Stock.StockStatus == (int)StockStatusEmun.å·²å
¥åº) |
| | | { |
| | | Dt_LocationInfo dt_LocationInfo = _locationInfoService.Repository.QueryData(x => x.LocationCode == dt_Stock.LocationCode && x.LocationStatus == (int)LocationStatusEnum.InStock).FirstOrDefault(); |
| | | if (dt_LocationInfo == null) return apiResponse.Error($"WMSæªè½æ¥æ¾é该æçæ¡ç çåºåè´§ä½ä¿¡æ¯ï¼æ¡ç ï¼{mES_In.containerNo}ï¼æªæ¾å°è´§ä½å·ï¼{dt_Stock.LocationCode}"); |
| | | |
| | | Dt_roadwayinfo _Roadwayinfo = _roadWayinfoService.QbtainPlatform(dt_LocationInfo.RoadwayNo); |
| | | Dt_roadwayinfo _Roadwayinfo = _roadWayinfoService.QbtainPlatform(dt_LocationInfo.RoadwayNo); |
| | | |
| | | Dt_Task task = new Dt_Task(); |
| | | task.TaskNum = mES_In.transNo; |
| | | task.PalletCode = dt_Stock.PalletCode; |
| | | task.PalletType = dt_Stock.PalletType; |
| | | task.Roadway = dt_LocationInfo.RoadwayNo; |
| | | task.TaskType = (int)TaskTypeEnum.Outbound; |
| | | task.TaskStatus = (int)OutTaskStatusEnum.OutNew; |
| | | task.SourceAddress = dt_LocationInfo.LocationCode; |
| | | task.TargetAddress = mES_In.endPosition; |
| | | task.CurrentAddress = dt_LocationInfo.LocationCode; |
| | | task.NextAddress = _Roadwayinfo.OutSCStationCode; |
| | | task.WarehouseId = dt_LocationInfo.WarehouseId; |
| | | task.OrderNo = mES_In.transDate.ToString(); |
| | | task.Grade = 1; |
| | | task.Creater = "MES"; |
| | | task.CreateDate = DateTime.Now; |
| | | Dt_Task setask = BaseDal.QueryData(x => x.PalletCode == mES_In.containerNo).FirstOrDefault(); |
| | | if (setask != null) return apiResponse.Error($"WMSå·²æå½åä»»å¡ï¼ä¸å¯éå¤ä¸åï¼æçç¼å·ï¼{mES_In.containerNo}"); |
| | | |
| | | dt_Stock.StockStatus = (int)StockStatusEmun.åºåºä¸; |
| | | dt_LocationInfo.LocationStatus = (int)LocationStatusEnum.Lock; |
| | | Dt_Task task = new Dt_Task(); |
| | | task.TaskNum = mES_In.transNo; |
| | | task.PalletCode = dt_Stock.PalletCode; |
| | | task.PalletType = dt_Stock.PalletType; |
| | | task.Roadway = dt_LocationInfo.RoadwayNo; |
| | | task.TaskType = (int)TaskTypeEnum.Outbound; |
| | | task.TaskStatus = (int)OutTaskStatusEnum.OutNew; |
| | | task.SourceAddress = dt_LocationInfo.LocationCode; |
| | | task.TargetAddress = mES_In.endPosition; |
| | | task.CurrentAddress = dt_LocationInfo.LocationCode; |
| | | task.NextAddress = _Roadwayinfo.OutSCStationCode; |
| | | task.WarehouseId = dt_LocationInfo.WarehouseId; |
| | | task.OrderNo = mES_In.transDate.ToString(); |
| | | task.Grade = 1; |
| | | task.Creater = "MES"; |
| | | task.CreateDate = DateTime.Now; |
| | | |
| | | _unitOfWorkManage.BeginTran(); |
| | | BaseDal.AddData(task); |
| | | _stockInfoService.Repository.UpdateData(dt_Stock); |
| | | _locationInfoService.Repository.UpdateData(dt_LocationInfo); |
| | | _unitOfWorkManage.CommitTran(); |
| | | dt_Stock.StockStatus = (int)StockStatusEmun.åºåºä¸; |
| | | dt_LocationInfo.LocationStatus = (int)LocationStatusEnum.Lock; |
| | | |
| | | WriteLog.GetLog("æ¥æ¶MESåºåºä»»å¡ä¸å").Write($"æ·»å æåï¼æçæ¡ç ï¼{dt_Stock.PalletCode}", $"åºåºä»»å¡æ·»å "); |
| | | return apiResponse.OK(); |
| | | _unitOfWorkManage.BeginTran(); |
| | | BaseDal.AddData(task); |
| | | _stockInfoService.Repository.UpdateData(dt_Stock); |
| | | _locationInfoService.Repository.UpdateData(dt_LocationInfo); |
| | | _unitOfWorkManage.CommitTran(); |
| | | |
| | | |
| | | WriteLog.Write_Log("MES_æ¥æ¶MESåºåºä»»å¡ä¸å", $"åºåºä»»å¡æ·»å ", "æå", $"æ·»å æåï¼æçæ¡ç ï¼{dt_Stock.PalletCode}"); |
| | | return apiResponse.OK(); |
| | | }else if(dt_Stock.StockStatus == (int)StockStatusEmun.ç§»åºéå®) |
| | | { |
| | | Dt_LocationInfo dt_LocationInfo = _locationInfoService.Repository.QueryData(x => x.LocationCode == dt_Stock.LocationCode && x.LocationStatus == (int)LocationStatusEnum.Lock).FirstOrDefault(); |
| | | if (dt_LocationInfo == null) return apiResponse.Error($"WMSæªè½æ¥æ¾é该æçæ¡ç çåºåè´§ä½ä¿¡æ¯ï¼æ¡ç ï¼{mES_In.containerNo}ï¼æªæ¾å°è´§ä½å·ï¼{dt_Stock.LocationCode}"); |
| | | |
| | | Dt_roadwayinfo _Roadwayinfo = _roadWayinfoService.QbtainPlatform(dt_LocationInfo.RoadwayNo); |
| | | |
| | | Dt_Task task = new Dt_Task(); |
| | | task.TaskNum = mES_In.transNo; |
| | | task.PalletCode = dt_Stock.PalletCode; |
| | | task.PalletType = dt_Stock.PalletType; |
| | | task.Roadway = dt_LocationInfo.RoadwayNo; |
| | | task.TaskType = (int)TaskTypeEnum.Outbound; |
| | | task.TaskStatus = (int)OutTaskStatusEnum.OutWait; |
| | | task.SourceAddress = dt_LocationInfo.LocationCode; |
| | | task.TargetAddress = mES_In.endPosition; |
| | | task.CurrentAddress = dt_LocationInfo.LocationCode; |
| | | task.NextAddress = _Roadwayinfo.OutSCStationCode; |
| | | task.WarehouseId = dt_LocationInfo.WarehouseId; |
| | | task.OrderNo = mES_In.transDate.ToString(); |
| | | task.Grade = 1; |
| | | task.Creater = "MES"; |
| | | task.CreateDate = DateTime.Now; |
| | | |
| | | _unitOfWorkManage.BeginTran(); |
| | | BaseDal.AddData(task); |
| | | _unitOfWorkManage.CommitTran(); |
| | | WriteLog.Write_Log("MES_æ¥æ¶MESåºåºä»»å¡ä¸å", $"åºåºä»»å¡æ·»å ", "æå", $"æ·»å æåï¼æçæ¡ç ï¼{dt_Stock.PalletCode}"); |
| | | return apiResponse.OK(); |
| | | |
| | | } |
| | | else |
| | | { |
| | | WriteLog.Write_Log("MES_æ¥æ¶MESåºåºä»»å¡ä¸å", $"åºåºä»»å¡æ·»å ", $"失败,æçæ¡ç ï¼{dt_Stock.PalletCode}", $"åºåç¶æé误ï¼è¯·æ¥çWMSç³»ç»åºå,åºåç¶æï¼{dt_Stock.StockStatus}"); |
| | | return apiResponse.Error("åºåç¶æé误ï¼è¯·æ¥çWMSç³»ç»åºå"); |
| | | } |
| | | |
| | | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | WriteLog.GetLog("æ¥æ¶MESåºåºä»»å¡ä¸å").Write($"åå ï¼{ex.Message}", $"åºåºä»»å¡æ·»å "); |
| | | WriteLog.Write_Log("MES_æ¥æ¶MESåºåºä»»å¡ä¸å", $"åºåºä»»å¡æ·»å ", "失败", $"任塿·»å å¤±è´¥ï¼æçæ¡ç ï¼{mES_In.containerNo},ç³»ç»åºéåå ï¼{ex.Message}"); |
| | | return apiResponse.Error($"WMS任塿·»å é误ï¼åå ï¼{ex.Message}"); |
| | | } |
| | | } |
| | |
| | | //å¨ä½æ¥è¯¢æ¥å£ |
| | | public ApiResponse GetLocationByContainer(MES_InTask mES_In) |
| | | { |
| | | WriteLog.Write_Log("MES_å¨ä½æ¥è¯¢æ¥å£", $"å¨ä½æ¥è¯¢æ¥å£", "åæ°", $"æçæ¡ç ï¼{mES_In.ToJson()}"); |
| | | |
| | | ApiResponse apiResponse = new ApiResponse(); |
| | | try |
| | | { |
| | | if (string.IsNullOrWhiteSpace(mES_In.containerNo)) return apiResponse.Error("æçç ä¸è½ä¸ºç©º"); |
| | | Dt_StockInfo dt_Stock = _stockInfoService.Repository.QueryData(x => x.PalletCode == mES_In.containerNo).FirstOrDefault(); |
| | | Dt_StockInfo dt_Stock = _stockInfoService.Repository.QueryData(x => x.PalletCode == mES_In.containerNo &&x.StockStatus==(int)StockStatusEmun.å·²å
¥åº).FirstOrDefault(); |
| | | if (dt_Stock == null) return apiResponse.Error($"WMSæªè½æ¥æ¾é该æçæ¡ç çåºåè´§ä½ä¿¡æ¯ï¼æ¡ç ï¼{mES_In.containerNo}"); |
| | | Dt_LocationInfo dt_LocationInfo = _locationInfoService.Repository.QueryData(x => x.LocationCode == dt_Stock.LocationCode).FirstOrDefault(); |
| | | if (dt_LocationInfo == null) return apiResponse.Error($"WMSæªè½æ¥æ¾é该æçæ¡ç çåºåè´§ä½ä¿¡æ¯ï¼æ¡ç ï¼{mES_In.containerNo}ï¼æªæ¾å°è´§ä½å·ï¼{dt_Stock.LocationCode}"); |
| | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | WriteLog.GetLog("å¨ä½æ¥è¯¢æ¥å£").Write($"åå ï¼{ex.Message}", $"å¨ä½æ¥è¯¢æ¥è¯¢å¤±è´¥"); |
| | | WriteLog.Write_Log("MES_å¨ä½æ¥è¯¢æ¥å£", $"å¨ä½æ¥è¯¢æ¥å£", "æ¥è¯¢å¤±è´¥", $"æçæ¡ç ï¼{mES_In.ToJson()}"); |
| | | return apiResponse.Error($"WMSå¨ä½æ¥è¯¢é误ï¼åå ï¼{ex.Message}"); |
| | | } |
| | | |
| | |
| | | //任塿¥è¯¢æ¥å£ |
| | | public ApiResponse GetTaskInfo(MES_InTask mES_In) |
| | | { |
| | | WriteLog.Write_Log("MES_任塿¥è¯¢æ¥å£", $"任塿¥è¯¢æ¥å£", "åæ°", $"æ¥æ¶çåæ°ï¼{mES_In.ToJson()}"); |
| | | ApiResponse apiResponse = new ApiResponse(); |
| | | try |
| | | { |
| | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | WriteLog.GetLog("任塿¥è¯¢æ¥å£").Write($"åå ï¼{ex.Message}", $"任塿¥è¯¢å¤±è´¥"); |
| | | WriteLog.Write_Log("MES_任塿¥è¯¢æ¥å£", $"任塿¥è¯¢æ¥å£", "失败", $"æ¡ç ï¼{mES_In.transNo}ï¼åå ï¼{ex.Message}"); |
| | | return apiResponse.Error($"WMS任塿¥è¯¢æ¥å£é误ï¼åå ï¼{ex.Message}"); |
| | | } |
| | | } |
| | |
| | | { |
| | | if (string.IsNullOrWhiteSpace(mES_In.transNo)) return apiResponse.Error("åæ®ç¼å·ä¸è½ä¸ºç©º"); |
| | | Dt_Task dt_Task = BaseDal.QueryData(x => x.TaskNum == mES_In.transNo).FirstOrDefault(); |
| | | if (dt_Task == null) return apiResponse.Error($"WMSæªè½æ¥æ¾é对åºåæ®ä»»å¡ï¼æ¡ç ï¼{mES_In.transNo}"); |
| | | if(dt_Task.TaskStatus== (int)InTaskStatusEnum.InNew || dt_Task.TaskStatus == (int)OutTaskStatusEnum.OutNew) |
| | | if (dt_Task == null) { |
| | | WriteLog.Write_Log("MES_ä»»å¡åæ¶æ¥å£", $"ä»»å¡åæ¶æ¥å£", "æå", $"åæ®ç¼å·ï¼{mES_In.transNo}ï¼æ³¨æï¼ï¼WMSæªè½æ¥æ¾é对åºåæ®ä»»å¡"); |
| | | return apiResponse.OK(); |
| | | //return apiResponse.Error($"WMSæªè½æ¥æ¾é对åºåæ®ä»»å¡ï¼æ¡ç ï¼{mES_In.transNo}"); |
| | | } |
| | | if(dt_Task.TaskStatus== (int)InTaskStatusEnum.InNew) |
| | | { |
| | | BaseDal.DeleteData(dt_Task); |
| | | return apiResponse.OK(); |
| | | }else if(dt_Task.TaskStatus == (int)OutTaskStatusEnum.OutNew) |
| | | { |
| | | Dt_StockInfo dt_StockInfo = _stockInfoService.Repository.QueryData(x => x.PalletCode == dt_Task.PalletCode).FirstOrDefault(); |
| | | Dt_LocationInfo dt_LocationInfo= _locationInfoService.Repository.QueryData(x=>x.LocationCode== dt_StockInfo.LocationCode).FirstOrDefault(); |
| | | dt_StockInfo.StockStatus = (int)StockStatusEmun.å·²å
¥åº; |
| | | dt_LocationInfo.LocationStatus = (int)LocationStatusEnum.InStock; |
| | | |
| | | _stockInfoService.Repository.UpdateData(dt_StockInfo); |
| | | _locationInfoService.Repository.UpdateData(dt_LocationInfo); |
| | | BaseDal.DeleteData(dt_Task); |
| | | WriteLog.Write_Log("MES_ä»»å¡åæ¶æ¥å£", $"ä»»å¡åæ¶æ¥å£", "æå", $"åæ®ç¼å·ï¼{mES_In.transNo}"); |
| | | return apiResponse.OK(); |
| | | } |
| | | else |
| | | { |
| | | WriteLog.Write_Log("MES_ä»»å¡åæ¶æ¥å£", $"ä»»å¡åæ¶æ¥å£", "失败", $"åæ®ç¼å·ï¼{mES_In.transNo},ä»»å¡å·²ç»å¨æ§è¡ä¸ï¼ä¸å¯åæ¶"); |
| | | return apiResponse.Error("ä»»å¡å·²ç»å¨æ§è¡ä¸ï¼ä¸å¯åæ¶"); |
| | | } |
| | | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | WriteLog.GetLog("ä»»å¡åæ¶æ¥å£").Write($"åå ï¼{ex.Message}", $"ä»»å¡åæ¶å¤±è´¥"); |
| | | WriteLog.Write_Log("MES_ä»»å¡åæ¶æ¥å£", $"ä»»å¡åæ¶æ¥å£", "失败", $"åæ®ç¼å·ï¼{mES_In.transNo}ï¼åå ï¼{ex.Message}"); |
| | | return apiResponse.Error($"WMSä»»å¡åæ¶æ¥å£é误ï¼åå ï¼{ex.Message}"); |
| | | } |
| | | } |
| | | |
| | | //å
¥åºä»»å¡å馿¥å£ |
| | | public MES_parameter InStoreDocCallback(string TransNo, string Result, string ResultMsg, string ContainerNo, string LocationCode) |
| | | { |
| | | MES_parameter mES_Parame= new MES_parameter(); |
| | | try |
| | | { |
| | | MesInResultResponse mesInResult = new MesInResultResponse(); |
| | | mesInResult.TransNo = TransNo; |
| | | mesInResult.Result = Result; |
| | | mesInResult.ResultMsg = ResultMsg; |
| | | mesInResult.ContainerNo = ContainerNo; |
| | | mesInResult.LocationCode = LocationCode; |
| | | mES_Parame = HttpHelper.Post<MES_parameter>(MES_InReporttask, mesInResult, "å
¥åºä»»å¡æ±æ¥"); |
| | | |
| | | WriteLog.Write_Log("MES_å
¥åºä»»å¡å馿¥å£", $"å
¥åºä»»å¡å馿¥å£", "æå", $"订åç¼å·ï¼{TransNo}ï¼æ§è¡ç»æï¼{Result}ï¼æ§è¡ç»ææè¿°ï¼{ResultMsg}ï¼æçæ¡ç ï¼{ContainerNo}ï¼åºä½ç¼å·ï¼{LocationCode}ï¼ä¸ä¼ çåæ°ï¼{mesInResult.ToJson()}ï¼åä¼ çåæ°ï¼{mES_Parame.ToJson()}"); |
| | | return mES_Parame; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | mES_Parame.Result = "N"; |
| | | mES_Parame.ResultMsg= $"å
¥åºï¼WMSç³»ç»ä¸ä¼ 失败,åå ï¼{ex.Message}"; |
| | | WriteLog.Write_Log("MES_å
¥åºä»»å¡å馿¥å£", $"å
¥åºä»»å¡å馿¥å£", "失败", $"订åç¼å·ï¼{TransNo}ï¼æ§è¡ç»æï¼{Result}ï¼æ§è¡ç»ææè¿°ï¼{ResultMsg}ï¼æçæ¡ç ï¼{ContainerNo}ï¼åºä½ç¼å·ï¼{LocationCode}ï¼ä¸ä¼ 失败ï¼åå :{ex.Message}"); |
| | | return mES_Parame; |
| | | } |
| | | |
| | | } |
| | | //åºåºä»»å¡å馿¥å£ |
| | | public MES_parameter OutStoreDocCallback(string TransNo,string Result,string ResultMsg) |
| | | { |
| | | MES_parameter mES_Parame = new MES_parameter(); |
| | | try |
| | | { |
| | | MesOutResultResponse mesInResult = new MesOutResultResponse(); |
| | | mesInResult.TransNo = TransNo; |
| | | mesInResult.Result = Result; |
| | | mesInResult.ResultMsg = ResultMsg; |
| | | mES_Parame = HttpHelper.Post<MES_parameter>(MES_OutReporttask, mesInResult, "åºåºä»»å¡æ±æ¥"); |
| | | WriteLog.Write_Log("MES_åºåºä»»å¡å馿¥å£", $"åºåºä»»å¡å馿¥å£", "æå", $"订åç¼å·ï¼{TransNo}ï¼æ§è¡ç»æï¼{Result}ï¼æ§è¡ç»ææè¿°ï¼{ResultMsg}ï¼ä¸ä¼ çåæ°ï¼{mesInResult.ToJson()}ï¼åä¼ çåæ°ï¼{mES_Parame.ToJson()}"); |
| | | return mES_Parame; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | mES_Parame.Result = "N"; |
| | | mES_Parame.ResultMsg = $"åºåºï¼WMSç³»ç»ä¸ä¼ 失败,åå ï¼{ex.Message}"; |
| | | WriteLog.Write_Log("MES_åºåºä»»å¡å馿¥å£", $"åºåºä»»å¡å馿¥å£", "失败", $"订åç¼å·ï¼{TransNo}ï¼æ§è¡ç»æï¼{Result}ï¼æ§è¡ç»ææè¿°ï¼{ResultMsg}ï¼ä¸ä¼ 失败ï¼åå :{ex.Message}"); |
| | | return mES_Parame; |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// å¨ä½å¼å¨ç³è¯· |
| | | /// </summary> |
| | | /// <param name="ContainerNo">æçæ¡ç </param> |
| | | /// <param name="OriginalLocationCode">åå¨ä½</param> |
| | | /// <param name="NewLocationCode">æ°å¨ä½</param> |
| | | /// <returns></returns> |
| | | public MES_parameter ApplicationChangeStorageLocation(string ContainerNo,string OriginalLocationCode,string NewLocationCode) |
| | | { |
| | | MES_parameter mES_Parame = new MES_parameter(); |
| | | try |
| | | { |
| | | MES_Storagelocation Storagelocation = new MES_Storagelocation(); |
| | | Storagelocation.ContainerNo = ContainerNo; |
| | | Storagelocation.OriginalLocationCode = OriginalLocationCode; |
| | | Storagelocation.NewLocationCode = NewLocationCode; |
| | | mES_Parame = HttpHelper.Post<MES_parameter>(MES_InventoryUpdateApply, Storagelocation, "å¨ä½å¼å¨ç³è¯·"); |
| | | WriteLog.Write_Log("MES_å¨ä½å¼å¨ç³è¯·", $"å¨ä½å¼å¨ç³è¯·", "æå", $"æçæ¡ç ï¼{ContainerNo}ï¼ååºä½ï¼{OriginalLocationCode}ï¼æ°åºä½ï¼{NewLocationCode}ï¼ä¸ä¼ çåæ°ï¼{Storagelocation.ToJson()}ï¼åä¼ çåæ°ï¼{mES_Parame.ToJson()}"); |
| | | return mES_Parame; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | mES_Parame.Result = "N"; |
| | | mES_Parame.ResultMsg = $"å¨ä½å¼å¨ç³è¯·ï¼WMSç³»ç»è°å失败,åå ï¼{ex.Message}"; |
| | | WriteLog.Write_Log("MES_å¨ä½å¼å¨ç³è¯·", $"å¨ä½å¼å¨ç³è¯·", "失败", $"æçæ¡ç ï¼{ContainerNo}ï¼ååºä½ï¼{OriginalLocationCode}ï¼æ°åºä½ï¼{NewLocationCode}ï¼ä¸ä¼ 失败ï¼åå :{ex.Message}"); |
| | | return mES_Parame; |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// å¨ä½å¼å¨ |
| | | /// </summary> |
| | | /// <param name="ContainerNo">æçæ¡ç </param> |
| | | /// <param name="OriginalLocationCode">åå¨ä½</param> |
| | | /// <param name="NewLocationCode">æ°å¨ä½</param> |
| | | /// <returns></returns> |
| | | public MES_parameter AbnormalStorageLocation(string ContainerNo, string OriginalLocationCode, string NewLocationCode) |
| | | { |
| | | MES_parameter mES_Parame = new MES_parameter(); |
| | | try |
| | | { |
| | | MES_Storagelocation Storagelocation = new MES_Storagelocation(); |
| | | Storagelocation.ContainerNo = ContainerNo; |
| | | Storagelocation.OriginalLocationCode = OriginalLocationCode; |
| | | Storagelocation.NewLocationCode = NewLocationCode; |
| | | mES_Parame = HttpHelper.Post<MES_parameter>(MES_InventoryUpdateCallback, Storagelocation, "å¨ä½å¼å¨"); |
| | | WriteLog.Write_Log("MES_å¨ä½å¼å¨ä¸ä¼ ", $"å¨ä½å¼å¨ä¸ä¼ ", "æå", $"æçæ¡ç ï¼{ContainerNo}ï¼ååºä½ï¼{OriginalLocationCode}ï¼æ°åºä½ï¼{NewLocationCode}ï¼ä¸ä¼ çåæ°ï¼{Storagelocation.ToJson()}ï¼åä¼ çåæ°ï¼{mES_Parame.ToJson()}"); |
| | | return mES_Parame; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | mES_Parame.Result = "N"; |
| | | mES_Parame.ResultMsg = $"å¨ä½å¼å¨ï¼WMSç³»ç»è°å失败,åå ï¼{ex.Message}"; |
| | | WriteLog.Write_Log("MES_å¨ä½å¼å¨ä¸ä¼ ", $"å¨ä½å¼å¨ä¸ä¼ ", "失败", $"æçæ¡ç ï¼{ContainerNo}ï¼ååºä½ï¼{OriginalLocationCode}ï¼æ°åºä½ï¼{NewLocationCode}ï¼ä¸ä¼ 失败ï¼åå :{ex.Message}"); |
| | | return mES_Parame; |
| | | } |
| | | } |
| | | /// <summary> |
| | | /// ä»»å¡å¼å¸¸ |
| | | /// </summary> |
| | | /// <param name="TransNo">åæ®ç¼å·</param> |
| | | /// <param name="EquipmentType">设å¤ç±»å</param> |
| | | /// <param name="EquipmentNumber">设å¤ç¼ç </param> |
| | | /// <param name="ErrorInfo">å¼å¸¸æ¥æ</param>MES_TaskErrorInfoCallback |
| | | /// <returns></returns> |
| | | public MES_parameter ToMES_TaskException(string TransNo,string EquipmentType,string EquipmentNumber,string ErrorInfo) |
| | | { |
| | | MES_parameter mES_Parame = new MES_parameter(); |
| | | try |
| | | { |
| | | MES_TaskException Storagelocation = new MES_TaskException(); |
| | | Storagelocation.TransNo = TransNo; |
| | | Storagelocation.EquipmentType = EquipmentType; |
| | | Storagelocation.EquipmentNumber = EquipmentNumber; |
| | | Storagelocation.ErrorInfo = ErrorInfo; |
| | | mES_Parame = HttpHelper.Post<MES_parameter>(MES_TaskErrorInfoCallback, Storagelocation, "ä»»å¡å¼å¸¸"); |
| | | WriteLog.Write_Log("MES_ä»»å¡å¼å¸¸", $"ä»»å¡å¼å¸¸", "æå", $"åæ®ç¼å·ï¼{TransNo}ï¼è®¾å¤ç±»åï¼{EquipmentType}ï¼è®¾å¤ç¼ç ï¼{EquipmentNumber}ï¼å¼å¸¸æ¥æ{ErrorInfo}ï¼ï¼ä¸ä¼ çåæ°ï¼{Storagelocation.ToJson()}ï¼åä¼ çåæ°ï¼{mES_Parame.ToJson()}"); |
| | | return mES_Parame; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | mES_Parame.Result = "N"; |
| | | mES_Parame.ResultMsg = $"ä»»å¡å¼å¸¸ï¼WMSç³»ç»è°å失败,åå ï¼{ex.Message}"; |
| | | WriteLog.Write_Log("MES_ä»»å¡å¼å¸¸", $"ä»»å¡å¼å¸¸", "失败", $"åæ®ç¼å·ï¼{TransNo}ï¼è®¾å¤ç±»åï¼{EquipmentType}ï¼è®¾å¤ç¼ç ï¼{EquipmentNumber}ï¼å¼å¸¸æ¥æ{ErrorInfo}ï¼ä¸ä¼ 失败ï¼åå :{ex.Message}"); |
| | | return mES_Parame; |
| | | } |
| | | } |
| | | } |
| | | } |