| | |
| | | using Microsoft.AspNetCore.Mvc; |
| | | using Newtonsoft.Json; |
| | | using SqlSugar; |
| | | using System.Diagnostics; |
| | | using System.DirectoryServices.Protocols; |
| | | using System.Net; |
| | | using System.Reflection.Emit; |
| | |
| | | _locationInfoRepository.UpdateData(dt_LocationInfo); |
| | | //ä¿®æ¹åºåç¶æ |
| | | _stockRepository.UpdateData(stockInfo); |
| | | task.TaskStatus = (int)TaskInStatusEnum.InFinish; |
| | | //å é¤ä»»å¡æ·»å åå² |
| | | BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId > 0 ? OperateTypeEnum.äººå·¥å®æ : OperateTypeEnum.èªå¨å®æ); |
| | | |
| | |
| | | return webResponse.Error($"æªæ¾å°ä»»å¡å·ä¸ºã{taskNum}ãçä»»å¡ä¿¡æ¯"); |
| | | } |
| | | |
| | | // TODO: è¿éåç»éè¦æ·»å å
·ä½çåæ¶ä»»å¡ä¸å¡é»è¾ |
| | | // ä¾å¦ï¼æ´æ°ä»»å¡ç¶æãéæ¾è´§ä½ãéç¥WCSç |
| | | bool res; |
| | | switch (task.TaskType) |
| | | { |
| | | case (int)TaskInboundTypeEnum.Inbound: |
| | | res = task.TaskStatus == TaskInStatusEnum.Line_InExecuting.ObjToInt(); |
| | | break; |
| | | case (int)TaskOutboundTypeEnum.Outbound: |
| | | res = task.TaskStatus == TaskOutStatusEnum.OutNew.ObjToInt(); |
| | | break; |
| | | case (int)TaskRelocationTypeEnum.Relocation: |
| | | res = task.TaskStatus == TaskRelocationStatusEnum.RelocationNew.ObjToInt(); |
| | | break; |
| | | default: |
| | | res = false; |
| | | break; |
| | | } |
| | | if (!res) return WebResponseContent.Instance.Error("ä»»å¡ç¶æå¼å¸¸"); |
| | | |
| | | Dt_StockInfo stockInfo = _stockRepository.QueryFirst(x => x.PalletCode == task.PalletCode); |
| | | |
| | | _unitOfWorkManage.BeginTran(); |
| | | |
| | | int stockmsseg; |
| | | int locationmsseg; |
| | | bool taskmsseg; |
| | | if (task.TaskType == TaskOutboundTypeEnum.Outbound.ObjToInt() || task.TaskType == TaskRelocationTypeEnum.Relocation.ObjToInt()) |
| | | { |
| | | stockmsseg = _stockRepository.Db.Updateable<Dt_StockInfo>() |
| | | .SetColumns(x => x.StockStatus == StockStatusEmun.å
¥åºå®æ.ObjToInt()) |
| | | .Where(x => x.PalletCode == task.PalletCode) |
| | | .ExecuteCommand(); |
| | | locationmsseg = _locationInfoRepository.Db.Updateable<Dt_LocationInfo>() |
| | | .SetColumns(x => x.LocationStatus == LocationStatusEnum.InStock.ObjToInt()) |
| | | .Where(x => x.LocationCode == stockInfo.LocationCode) |
| | | .ExecuteCommand(); |
| | | taskmsseg = BaseDal.DeleteData(task); |
| | | } |
| | | else |
| | | { |
| | | locationmsseg = _locationInfoRepository.Db.Updateable<Dt_LocationInfo>() |
| | | .SetColumns(x => x.LocationStatus == LocationStatusEnum.Free.ObjToInt()) |
| | | .Where(x => x.LocationCode == stockInfo.LocationCode) |
| | | .ExecuteCommand(); |
| | | stockmsseg = _stockRepository.DeleteData(stockInfo).ObjToInt(); |
| | | taskmsseg = BaseDal.DeleteData(task); |
| | | } |
| | | BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId > 0 ? OperateTypeEnum.äººå·¥å®æ : OperateTypeEnum.èªå¨å®æ); |
| | | //è·åæ¥å£è¿è¡è°å |
| | | var ConfigsAPIInfo = _dt_ApiInfoService.GetConfigsByAPIInfo(CateGoryConst.CONFIG_MES_IPAddress, SysConfigConst.WCSCancelinventory); //è·åå°wcså
¨é¨ç±»åçæ¥å£ |
| | | string WCSReceiveTaskAPI = ConfigsAPIInfo.ApiAddress + ConfigsAPIInfo.ApiName; |
| | | if (WCSReceiveTaskAPI == null) |
| | | { |
| | | return webResponse.Error($"ä»»å¡åé¦MESå¤±è´¥ï¼æªé
ç½®MESä»»å¡å®æå馿¥å£"); |
| | | } |
| | | var respon = HttpHelper.Get(WCSReceiveTaskAPI, JsonConvert.SerializeObject(task.TaskNum)); |
| | | if (respon != null) |
| | | { |
| | | var response = JsonConvert.DeserializeObject<ApiResponse<object>>(respon); |
| | | // if (response.Success) |
| | | // { |
| | | // return webResponse.OK(); |
| | | // } |
| | | // else |
| | | // { |
| | | // return webResponse.Error($"è°åæ¥å£å¤±è´¥ï¼åé¦åæ°åå ï¼{response.Message}"); |
| | | // } |
| | | //} |
| | | //else |
| | | //{ |
| | | // return webResponse.Error($"è°åæ¥å£å¤±è´¥ï¼åé¦åæ°ä¸ºç©º"); |
| | | //} |
| | | if (stockmsseg > 0 && locationmsseg > 0 && taskmsseg) |
| | | { |
| | | _unitOfWorkManage.CommitTran(); |
| | | return webResponse.OK("ä»»å¡åæ¶æå"); |
| | | |
| | | } |
| | | |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | return webResponse.Error($"åæ¶ä»»å¡å¤±è´¥ï¼åå ï¼{ex.Message}"); |
| | | } |
| | | _unitOfWorkManage.RollbackTran(); |
| | | return webResponse.Error("ä»»å¡åæ¶å¤±è´¥"); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | |
| | | try |
| | | { |
| | | int result = GetLastPart(locationCode).ObjToInt(); // è¿å "C03" |
| | | Dt_StockInfo dt_StockInfo = _stockRepository.QueryFirst(x => x.LocationCode.StartsWith("SC01") && x.StockStatus == 6); |
| | | int result = GetLastPart(dt_StockInfo.LocationCode).ObjToInt(); // è¿å "C03" |
| | | |
| | | List<Dt_Task> dt_s = new List<Dt_Task>(); |
| | | //çæç§»å¨ä»»å¡ |
| | | Dt_Task dt_Task = new() |
| | | { |
| | | PalletCode = "1111", |
| | | TaskNum = 111, |
| | | PalletCode = dt_StockInfo.PalletCode, |
| | | TaskNum = GetTaskNum(nameof(SequenceEnum.SeqTaskNum)), |
| | | Roadway = "SC01", |
| | | TaskType = TaskOutboundTypeEnum.Outbound.ObjToInt(), |
| | | TaskStatus = TaskOutStatusEnum.OutNew.ObjToInt(), |
| | | SourceAddress = locationCode, |
| | | TargetAddress = "1002", |
| | | CurrentAddress = locationCode, |
| | | NextAddress = "1002", |
| | | SourceAddress = dt_StockInfo.LocationCode, |
| | | TargetAddress = "1006", |
| | | CurrentAddress = dt_StockInfo.LocationCode, |
| | | NextAddress = "1006", |
| | | Grade = 1, |
| | | Creater = "MES", |
| | | Depth = result, |
| | | CreateDate = DateTime.Now, |
| | | MEStaskId = "111", |
| | | MESbusinessId = "123456", |
| | | MESsubPalletCode = "", |
| | | OutboundPlatform = "1001" |
| | | MEStaskId = "EXTASK20251020002", |
| | | MESbusinessId = "EXBUS20251020002", |
| | | MESsubPalletCode = dt_StockInfo.MESsubPalletCode, |
| | | OutboundPlatform = "1005" |
| | | }; |
| | | |
| | | //å建ç»çä¿¡æ¯ |
| | | var dt_Stock = new Dt_StockInfo |
| | | { |
| | | PalletCode = dt_Task.PalletCode, |
| | | PalletType = 1, |
| | | LocationCode = locationCode, |
| | | StockStatus = 6, |
| | | Creater = "WMS", |
| | | CreateDate = DateTime.Now, |
| | | MESsubPalletCode = dt_Task.MESsubPalletCode, |
| | | }; |
| | | ////å建ç»çä¿¡æ¯ |
| | | //var dt_Stock = new Dt_StockInfo |
| | | //{ |
| | | // PalletCode = dt_Task.PalletCode, |
| | | // PalletType = 1, |
| | | // LocationCode = locationCode, |
| | | // StockStatus = 6, |
| | | // Creater = "WMS", |
| | | // CreateDate = DateTime.Now, |
| | | // MESsubPalletCode = dt_Task.MESsubPalletCode, |
| | | //}; |
| | | |
| | | Dt_LocationInfo dt_LocationInfo = _locationInfoRepository.QueryFirst(x => x.LocationCode == locationCode); |
| | | Dt_LocationInfo dt_LocationInfo = _locationInfoRepository.QueryFirst(x => x.LocationCode == dt_StockInfo.LocationCode); |
| | | dt_LocationInfo.LocationStatus = (int)LocationStatusEnum.InStockLock; |
| | | dt_StockInfo.StockStatus = 7; |
| | | |
| | | bool l = _locationInfoRepository.UpdateData(dt_LocationInfo); |
| | | int s = _stockRepository.AddData(dt_Stock); |
| | | bool s = _stockRepository.UpdateData(dt_StockInfo); |
| | | int t = BaseDal.AddData(dt_Task); |
| | | bool ss = s.ObjToBool(); |
| | | bool tt = t.ObjToBool(); |