| | |
| | | using OfficeOpenXml.FormulaParsing.Excel.Functions.RefAndLookup; |
| | | using SqlSugar; |
| | | using System; |
| | | using System.Collections; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Reflection.Metadata; |
| | | using System.Text; |
| | | using System.Text.RegularExpressions; |
| | | using System.Threading.Tasks; |
| | | using WIDESEA_Common.CommonEnum; |
| | | using WIDESEA_Common.LocationEnum; |
| | | using WIDESEA_Common.MaterielEnum; |
| | | using WIDESEA_Common.OrderEnum; |
| | | using WIDESEA_Common.StockEnum; |
| | | using WIDESEA_Common.TaskEnum; |
| | |
| | | using WIDESEA_Core; |
| | | using WIDESEA_Core.Helper; |
| | | using WIDESEA_DTO; |
| | | using WIDESEA_DTO.Basic; |
| | | using WIDESEA_DTO.Task; |
| | | using WIDESEA_External.Model; |
| | | using WIDESEA_Model.Models; |
| | | |
| | | namespace WIDESEA_TaskInfoService |
| | | { |
| | | public partial class TaskService |
| | | { |
| | | /// <summary> |
| | | /// ç³è¯·å
¥åºä»»å¡(PDA使ç¨ï¼ä»
æçç»å®å
¥åºç«å°ï¼ä¸åé
è´§ä½) |
| | | /// </summary> |
| | | /// <param name="saveModel"></param> |
| | | /// <returns></returns> |
| | | public WebResponseContent RequestInboundTask(SaveModel saveModel) |
| | | { |
| | | try |
| | | { |
| | | var palletCode = saveModel.MainData["barcode"].ToString(); |
| | | var warehouseId = saveModel.MainData["warehouseId"].ObjToInt(); |
| | | var stationCode = saveModel.MainData["startPoint"].ToString(); |
| | | Dt_Warehouse warehouse = _basicRepository.WarehouseRepository.QueryFirst(x => x.WarehouseId == warehouseId); |
| | | if (warehouse == null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"æªæ¾å°åºåº"); |
| | | } |
| | | |
| | | Dt_Task task = Repository.QueryFirst(x => x.PalletCode == palletCode && x.WarehouseId == warehouseId); |
| | | if (task != null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"该æçå·²çæä»»å¡"); |
| | | } |
| | | |
| | | if (Repository.QueryFirst(x => x.SourceAddress == stationCode && x.TaskStatus == TaskStatusEnum.New.ObjToInt()) != null && warehouse.WarehouseCode != WarehouseEnum.HA60.ToString()) |
| | | { |
| | | return WebResponseContent.Instance.Error($"该ç«ç¹å·²ææªæ§è¡çä»»å¡"); |
| | | } |
| | | |
| | | Dt_StockInfo stockInfo = _stockRepository.StockInfoRepository.Db.Queryable<Dt_StockInfo>().Where(x=>x.PalletCode== palletCode).Includes(x=>x.Details).First(); |
| | | if (stockInfo == null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"æªæ¾å°ç»çä¿¡æ¯"); |
| | | } |
| | | if (stockInfo.StockStatus != StockStatusEmun.ç»çæå.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.æå¨ç»çæå.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.æ£é宿.ObjToInt()) |
| | | { |
| | | return WebResponseContent.Instance.Error($"该æçç¶æä¸æ£ç¡®,ä¸å¯ç³è¯·å
¥åº"); |
| | | } |
| | | if (!string.IsNullOrEmpty(stockInfo.LocationCode)) |
| | | { |
| | | return WebResponseContent.Instance.Error($"该æçå·²ç»å®è´§ä½"); |
| | | } |
| | | if (warehouseId != stockInfo.WarehouseId) |
| | | { |
| | | return WebResponseContent.Instance.Error($"ä»åºä¸æ£ç¡®"); |
| | | } |
| | | if (warehouse.WarehouseCode == WarehouseEnum.HA60.ToString()) |
| | | { |
| | | Dt_LocationInfo locationInfo = _basicRepository.LocationInfoRepository.QueryFirst(x => x.WarehouseId == warehouseId); |
| | | if (locationInfo == null) return WebResponseContent.Instance.Error($"æªæ¾å°å½ååºåºè´§ä½ä¿¡æ¯"); |
| | | return DeviceRequestInboundTask(stationCode, locationInfo.RoadwayNo, palletCode); |
| | | } |
| | | else |
| | | { |
| | | Dt_Task newTask = new Dt_Task() |
| | | { |
| | | CurrentAddress = stationCode, |
| | | Grade = 0, |
| | | NextAddress = "", |
| | | PalletCode = palletCode, |
| | | Roadway = "", |
| | | SourceAddress = stationCode, |
| | | TargetAddress = "", |
| | | TaskType = TaskTypeEnum.Inbound.ObjToInt(), |
| | | TaskStatus = TaskStatusEnum.New.ObjToInt(), |
| | | WarehouseId = stockInfo.WarehouseId, |
| | | PalletType = stockInfo.PalletType, |
| | | MaterielCode = stockInfo.Details.Where(x => x.StockId == stockInfo.Id).FirstOrDefault()?.MaterielCode, |
| | | Quantity = (float)stockInfo.Details.Where(x => x.StockId == stockInfo.Id).FirstOrDefault()?.StockQuantity, |
| | | }; |
| | | //è·åæ¯å¦åå¨å
¥åºå |
| | | Dt_InboundOrder? inboundOrder = null; |
| | | if (stockInfo!=null && stockInfo.Details.Count>0) |
| | | { |
| | | string? orderNo = stockInfo.Details.FirstOrDefault()?.OrderNo ?? ""; |
| | | inboundOrder =_inboundOrderService.Repository.QueryFirst(x => x.InboundOrderNo == orderNo && x.OrderStatus < InOrderStatusEnum.å
¥åºå®æ.ObjToInt()); |
| | | if (inboundOrder!=null) |
| | | { |
| | | newTask.OrderNo = inboundOrder.InboundOrderNo; |
| | | } |
| | | } |
| | | |
| | | if (inboundOrder != null) |
| | | { |
| | | if (inboundOrder.OrderType == InOrderTypeEnum.Allocat.ObjToInt()) |
| | | { |
| | | newTask.TaskType = TaskTypeEnum.InAllocate.ObjToInt(); |
| | | newTask.OrderNo = inboundOrder.InboundOrderNo; |
| | | } |
| | | else if (inboundOrder.OrderType == InOrderTypeEnum.Return.ObjToInt()) |
| | | { |
| | | newTask.TaskType = TaskTypeEnum.ProductionReturn.ObjToInt(); |
| | | newTask.OrderNo = inboundOrder.InboundOrderNo; |
| | | } |
| | | } |
| | | if (stockInfo.StockStatus == StockStatusEmun.æå¨ç»çæå.ObjToInt()) |
| | | { |
| | | stockInfo.StockStatus = StockStatusEmun.æå¨ç»çå
¥åºç¡®è®¤.ObjToInt(); |
| | | } |
| | | else if (stockInfo.StockStatus == StockStatusEmun.æ£é宿.ObjToInt()) |
| | | { |
| | | stockInfo.StockStatus = StockStatusEmun.å
¥åºç¡®è®¤.ObjToInt(); |
| | | newTask.TaskType = TaskTypeEnum.InPick.ObjToInt(); |
| | | } |
| | | else |
| | | { |
| | | stockInfo.StockStatus = StockStatusEmun.å
¥åºç¡®è®¤.ObjToInt(); |
| | | } |
| | | |
| | | if (warehouse.WarehouseCode==WarehouseEnum.HA57.ToString()) |
| | | { |
| | | Dt_Task dt_TaskMesReturn = BaseDal.QueryFirst(x=>x.TaskType==TaskTypeEnum.MesMatReturn.ObjToInt() && x.TaskStatus!=TaskStatusEnum.SC_Executing.ObjToInt()); |
| | | if (dt_TaskMesReturn!=null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"éæä»»å¡æ£æ§è¡"); |
| | | } |
| | | } |
| | | _unitOfWorkManage.BeginTran(); |
| | | int taskId = BaseDal.AddData(newTask); |
| | | newTask.TaskId = taskId; |
| | | _stockRepository.StockInfoRepository.UpdateData(stockInfo); |
| | | _unitOfWorkManage.CommitTran(); |
| | | PushTasksToWCS(new List<Dt_Task> { newTask }); |
| | | return WebResponseContent.Instance.OK(data: newTask); |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | return WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// å
¥ç©ºç®± |
| | | /// </summary> |
| | | /// <param name="barcode"></param> |
| | | /// <param name="address"></param> |
| | | /// <param name="WarehouseId"></param> |
| | | /// <returns></returns> |
| | | public WebResponseContent InEmpty(string barcode, string address, int WarehouseId) |
| | | { |
| | | try |
| | | { |
| | | Dt_Warehouse warehouse = _basicRepository.WarehouseRepository.QueryFirst(x => x.WarehouseId == WarehouseId); |
| | | if (warehouse == null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"æªæ¾å°åºåº"); |
| | | } |
| | | Dt_StockInfo stockInfo = _stockRepository.StockInfoRepository.QueryFirst(x => x.PalletCode == barcode && x.StockStatus != StockStatusEmun.åºåºå®æ.ObjToInt()); |
| | | if (stockInfo != null) throw new Exception($"æçå·å·²åå¨"); |
| | | stockInfo = new Dt_StockInfo() |
| | | { |
| | | PalletCode = barcode, |
| | | StockStatus = StockStatusEmun.å
¥åºç¡®è®¤.ObjToInt(), |
| | | WarehouseId = WarehouseId, |
| | | PalletType = PalletTypeEnum.Empty.ObjToInt(), |
| | | Details = new List<Dt_StockInfoDetail>() |
| | | }; |
| | | Dt_LocationInfo locationInfo = _basicRepository.LocationInfoRepository.QueryFirst(x => x.WarehouseId == WarehouseId); |
| | | if (locationInfo == null) return WebResponseContent.Instance.Error($"æªæ¾å°å½ååºåºè´§ä½ä¿¡æ¯"); |
| | | locationInfo = _basicService.LocationInfoService.AssignLocation(locationInfo.RoadwayNo, ((PalletTypeEnum)stockInfo.PalletType).ObjToInt(), stockInfo.WarehouseId); |
| | | if (locationInfo == null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"è´§ä½åé
失败,æªæ¾å°å¯åé
è´§ä½"); |
| | | } |
| | | |
| | | Dt_Task newTask = new Dt_Task() |
| | | { |
| | | CurrentAddress = address, |
| | | Grade = 0, |
| | | NextAddress = locationInfo.LocationCode, |
| | | PalletCode = barcode, |
| | | Roadway = locationInfo.RoadwayNo, |
| | | SourceAddress = address, |
| | | TargetAddress = locationInfo.LocationCode, |
| | | TaskType = TaskTypeEnum.InEmpty.ObjToInt(), |
| | | TaskStatus = TaskStatusEnum.New.ObjToInt(), |
| | | WarehouseId = stockInfo.WarehouseId, |
| | | PalletType = stockInfo.PalletType |
| | | }; |
| | | locationInfo.LocationStatus = LocationStatusEnum.Lock.ObjToInt(); |
| | | _unitOfWorkManage.BeginTran(); |
| | | int taskId = BaseDal.AddData(newTask); |
| | | newTask.TaskId = taskId; |
| | | _basicRepository.LocationInfoRepository.UpdateData(locationInfo); |
| | | _stockRepository.StockInfoRepository.AddData(stockInfo); |
| | | _unitOfWorkManage.CommitTran(); |
| | | PushTasksToWCS(new List<Dt_Task> { newTask }); |
| | | PutFinish(address, newTask.PalletCode, newTask.TaskNum.ToString()); |
| | | return WebResponseContent.Instance.OK(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | return WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | /// <param name="qty"></param> |
| | | /// <param name="address"></param> |
| | | /// <param name="WarehouseId"></param> |
| | | /// <param name="barcode"></param> |
| | | /// <returns></returns> |
| | | public WebResponseContent OutEmpty(int qty, string address, int WarehouseId, string barcode) |
| | | { |
| | | try |
| | | { |
| | | Dt_Warehouse warehouse = _basicRepository.WarehouseRepository.QueryFirst(x => x.WarehouseId == WarehouseId); |
| | | if (warehouse == null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"æªæ¾å°åºåº"); |
| | | } |
| | | List<Dt_StockInfo> stockInfos = null; |
| | | if (string.IsNullOrEmpty(barcode)) |
| | | { |
| | | stockInfos = _stockRepository.StockInfoRepository.QueryData(x => x.WarehouseId == WarehouseId && x.PalletType == PalletTypeEnum.Empty.ObjToInt() && x.StockStatus == StockStatusEmun.å
¥åºå®æ.ObjToInt(), qty, nameof(Dt_StockInfo.CreateDate)); |
| | | } |
| | | else |
| | | { |
| | | stockInfos = _stockRepository.StockInfoRepository.QueryData(x => x.WarehouseId == WarehouseId && x.PalletType == PalletTypeEnum.Empty.ObjToInt() && x.StockStatus == StockStatusEmun.å
¥åºå®æ.ObjToInt() && x.PalletCode == barcode); |
| | | if (stockInfos.Count == 0) return WebResponseContent.Instance.Error($"{warehouse.WarehouseName}æªæ¾å°ç©ºç®±ã{barcode}ã"); |
| | | } |
| | | |
| | | if (stockInfos.Count < qty) return WebResponseContent.Instance.Error($"{warehouse.WarehouseName}空箱åºåä¸è¶³,åºåæ°ã{stockInfos.Count}ã"); |
| | | List<Dt_Task> tasks = GetTasks(stockInfos, TaskTypeEnum.OutEmpty); |
| | | stockInfos.ForEach(x => |
| | | { |
| | | x.StockStatus = StockStatusEmun.åºåºéå®.ObjToInt(); |
| | | }); |
| | | tasks.ForEach(x => |
| | | { |
| | | x.TargetAddress = address; |
| | | x.NextAddress = address; |
| | | }); |
| | | _unitOfWorkManage.BeginTran(); |
| | | BaseDal.AddData(tasks); |
| | | _stockRepository.StockInfoRepository.UpdateData(stockInfos); |
| | | _unitOfWorkManage.CommitTran(); |
| | | PushTasksToWCS(tasks); |
| | | return WebResponseContent.Instance.OK(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | return WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | /// <param name="stationCode"></param> |
| | | /// <param name="roadwayNo"></param> |
| | | /// <param name="palletCode"></param> |
| | | /// <returns></returns> |
| | | public WebResponseContent DeviceRequestInboundTask(string stationCode, string roadwayNo, string palletCode,string materielBoxCode = "") |
| | | { |
| | | try |
| | | { |
| | | Dt_Task task = Repository.QueryFirst(x => x.PalletCode == palletCode); |
| | | if (task != null) |
| | | { |
| | | PushTasksToWCS(new List<Dt_Task> { task }); |
| | | return WebResponseContent.Instance.OK($"该æçå·²çæä»»å¡", _mapper.Map<WMSTaskDTO>(task)); |
| | | } |
| | | |
| | | if (Repository.QueryFirst(x => x.SourceAddress == stationCode && x.TaskStatus == TaskStatusEnum.New.ObjToInt()) != null && stationCode != "8005")//è¾
æä»ä¸éå¶å
¥åºä»»å¡ |
| | | { |
| | | return WebResponseContent.Instance.Error($"该ç«ç¹å·²ææªæ§è¡çä»»å¡"); |
| | | } |
| | | if (!string.IsNullOrEmpty(materielBoxCode)) |
| | | { |
| | | _unitOfWorkManage.BeginTran(); |
| | | WebResponseContent responseGroup = _inboundOrderService.MaterielPPorGM(materielBoxCode); |
| | | if (!responseGroup.Status) |
| | | { |
| | | return WebResponseContent.Instance.Error($"{responseGroup.Message}"); |
| | | } |
| | | Dt_StockInfo stockInfoPPorGM = responseGroup.Data as Dt_StockInfo ?? null; |
| | | if (stockInfoPPorGM==null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"ç»çæ°æ®è½¬æ¢å¤±è´¥"); |
| | | } |
| | | Dt_LocationInfo? locationInfoPPorGM = _basicService.LocationInfoService.AssignLocation(roadwayNo, stockInfoPPorGM.PalletType, stockInfoPPorGM.WarehouseId); |
| | | if (locationInfoPPorGM == null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"è´§ä½åé
失败,æªæ¾å°å¯åé
è´§ä½"); |
| | | } |
| | | Dt_Task newTaskPPorGM = new Dt_Task() |
| | | { |
| | | CurrentAddress = stationCode, |
| | | Grade = 0, |
| | | NextAddress = locationInfoPPorGM.LocationCode, |
| | | PalletCode = stockInfoPPorGM.PalletCode, |
| | | Roadway = roadwayNo, |
| | | SourceAddress = stationCode, |
| | | TargetAddress = locationInfoPPorGM.LocationCode, |
| | | TaskType = TaskTypeEnum.Inbound.ObjToInt(), |
| | | TaskStatus = TaskStatusEnum.New.ObjToInt(), |
| | | WarehouseId = stockInfoPPorGM.WarehouseId, |
| | | PalletType = stockInfoPPorGM.PalletType, |
| | | TaskLength= stockInfoPPorGM.StockLength |
| | | }; |
| | | |
| | | //è·åæ¯å¦åå¨å
¥åºå |
| | | Dt_InboundOrder? inboundOrderPPorGM = null; |
| | | if (stockInfoPPorGM != null && stockInfoPPorGM.Details.Count > 0) |
| | | { |
| | | string? orderNo = stockInfoPPorGM.Details.FirstOrDefault()?.OrderNo ?? ""; |
| | | inboundOrderPPorGM = _inboundOrderService.Repository.QueryFirst(x => x.InboundOrderNo == orderNo && x.OrderStatus < InOrderStatusEnum.å
¥åºå®æ.ObjToInt()); |
| | | } |
| | | |
| | | if (inboundOrderPPorGM != null) |
| | | { |
| | | if (inboundOrderPPorGM.OrderType == InOrderTypeEnum.Allocat.ObjToInt()) |
| | | { |
| | | newTaskPPorGM.TaskType = TaskTypeEnum.InAllocate.ObjToInt(); |
| | | } |
| | | else if (inboundOrderPPorGM.OrderType == InOrderTypeEnum.Return.ObjToInt()) |
| | | { |
| | | newTaskPPorGM.TaskType = TaskTypeEnum.ProductionReturn.ObjToInt(); |
| | | } |
| | | } |
| | | stockInfoPPorGM.StockStatus = StockStatusEmun.å
¥åºç¡®è®¤.ObjToInt(); |
| | | LocationStatusEnum lastStatusPPorGM = (LocationStatusEnum)locationInfoPPorGM.LocationStatus; |
| | | _recordService.LocationStatusChangeRecordSetvice.AddLocationStatusChangeRecord(locationInfoPPorGM, lastStatusPPorGM, LocationStatusEnum.Lock, LocationChangeType.InboundAssignLocation); |
| | | _basicService.LocationInfoService.UpdateLocationStatus(locationInfoPPorGM, newTaskPPorGM.PalletType, LocationStatusEnum.Lock, newTaskPPorGM.WarehouseId); |
| | | int taskIdPPorGM = BaseDal.AddData(newTaskPPorGM); |
| | | newTaskPPorGM.TaskId = taskIdPPorGM; |
| | | _stockRepository.StockInfoRepository.Db.InsertNav(stockInfoPPorGM).Include(x => x.Details).ExecuteCommand(); |
| | | _unitOfWorkManage.CommitTran(); |
| | | WMSTaskDTO wMSTaskDTOPPorGM = _mapper.Map<WMSTaskDTO>(newTaskPPorGM); |
| | | |
| | | PushTasksToWCS(new List<Dt_Task> { newTaskPPorGM }); |
| | | return WebResponseContent.Instance.OK(data: wMSTaskDTOPPorGM); |
| | | } |
| | | Dt_StockInfo stockInfo = _stockRepository.StockInfoRepository.Db.Queryable<Dt_StockInfo>().Where(x => x.PalletCode == palletCode).Includes(x => x.Details).First(); |
| | | if (stockInfo == null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"æªæ¾å°ç»çä¿¡æ¯"); |
| | | } |
| | | if (stockInfo.StockStatus != StockStatusEmun.ç»çæå.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.æå¨ç»çæå.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.åºåºå®æ.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.æ£é宿.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.éåº.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.MESéåº.ObjToInt()) |
| | | { |
| | | return WebResponseContent.Instance.Error($"该æçç¶æä¸æ£ç¡®,ä¸å¯ç³è¯·å
¥åº"); |
| | | } |
| | | if (!string.IsNullOrEmpty(stockInfo.LocationCode)) |
| | | { |
| | | return WebResponseContent.Instance.Error($"该æçå·²ç»å®è´§ä½"); |
| | | } |
| | | |
| | | Dt_LocationInfo? locationInfo = _basicService.LocationInfoService.AssignLocation(roadwayNo, stockInfo.PalletType, stockInfo.WarehouseId); |
| | | if (locationInfo == null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"è´§ä½åé
失败,æªæ¾å°å¯åé
è´§ä½"); |
| | | } |
| | | |
| | | Dt_Task newTask = new Dt_Task() |
| | | { |
| | | CurrentAddress = stationCode, |
| | | Grade = 0, |
| | | NextAddress = locationInfo.LocationCode, |
| | | PalletCode = palletCode, |
| | | Roadway = roadwayNo, |
| | | SourceAddress = stationCode, |
| | | TargetAddress = locationInfo.LocationCode, |
| | | TaskType = TaskTypeEnum.Inbound.ObjToInt(), |
| | | TaskStatus = TaskStatusEnum.New.ObjToInt(), |
| | | WarehouseId = stockInfo.WarehouseId, |
| | | PalletType = stockInfo.PalletType, |
| | | }; |
| | | |
| | | //è·åæ¯å¦åå¨å
¥åºå |
| | | Dt_InboundOrder? inboundOrder = null; |
| | | if (stockInfo != null && stockInfo.Details.Count > 0) |
| | | { |
| | | string? orderNo = stockInfo.Details.FirstOrDefault()?.OrderNo ?? ""; |
| | | inboundOrder = _inboundOrderService.Repository.QueryFirst(x => x.InboundOrderNo == orderNo && x.OrderStatus < InOrderStatusEnum.å
¥åºå®æ.ObjToInt()); |
| | | } |
| | | |
| | | if (inboundOrder != null) |
| | | { |
| | | if (inboundOrder.OrderType == InOrderTypeEnum.Allocat.ObjToInt()) |
| | | { |
| | | newTask.TaskType = TaskTypeEnum.InAllocate.ObjToInt(); |
| | | } |
| | | else if (inboundOrder.OrderType == InOrderTypeEnum.Return.ObjToInt()) |
| | | { |
| | | newTask.TaskType = TaskTypeEnum.ProductionReturn.ObjToInt(); |
| | | } |
| | | } |
| | | if (stockInfo.StockStatus == StockStatusEmun.æå¨ç»çæå.ObjToInt()) |
| | | { |
| | | stockInfo.StockStatus = StockStatusEmun.æå¨ç»çå
¥åºç¡®è®¤.ObjToInt(); |
| | | } |
| | | else if (stockInfo.StockStatus == StockStatusEmun.MESéåº.ObjToInt()) |
| | | { |
| | | newTask.TaskType = TaskTypeEnum.MesMatReturn.ObjToInt(); |
| | | } |
| | | else if (stockInfo.StockStatus == StockStatusEmun.æ£é宿.ObjToInt()) |
| | | { |
| | | newTask.TaskType = TaskTypeEnum.InPick.ObjToInt(); |
| | | } |
| | | else |
| | | { |
| | | stockInfo.StockStatus = StockStatusEmun.å
¥åºç¡®è®¤.ObjToInt(); |
| | | } |
| | | |
| | | LocationStatusEnum lastStatus = (LocationStatusEnum)locationInfo.LocationStatus; |
| | | _unitOfWorkManage.BeginTran(); |
| | | _recordService.LocationStatusChangeRecordSetvice.AddLocationStatusChangeRecord(locationInfo, lastStatus, LocationStatusEnum.Lock, LocationChangeType.InboundAssignLocation); |
| | | _basicService.LocationInfoService.UpdateLocationStatus(locationInfo, newTask.PalletType, LocationStatusEnum.Lock, newTask.WarehouseId); |
| | | int taskId = BaseDal.AddData(newTask); |
| | | newTask.TaskId = taskId; |
| | | _stockRepository.StockInfoRepository.UpdateData(stockInfo); |
| | | _unitOfWorkManage.CommitTran(); |
| | | WMSTaskDTO wMSTaskDTO = _mapper.Map<WMSTaskDTO>(newTask); |
| | | |
| | | PushTasksToWCS(new List<Dt_Task> { newTask }); |
| | | if (newTask.WarehouseId == 5) PutFinish(stationCode.ToString(),newTask.PalletCode, newTask.TaskNum.ToString()); |
| | | return WebResponseContent.Instance.OK(data: wMSTaskDTO); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | return WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// ä»
ç³è¯·ä»»å¡ï¼è®©WCSæ ¹æ®è·¯ç±ç¡®å®ä¸ä¸å°å |
| | | /// </summary> |
| | |
| | | { |
| | | return WebResponseContent.Instance.Error($"æªæ¾å°ç»çä¿¡æ¯"); |
| | | } |
| | | if (stockInfo.StockStatus != StockStatusEmun.éåº.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.MESéåº.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.MES空æéåº.ObjToInt()) |
| | | if (stockInfo.StockStatus != StockStatusEmun.MES使éåº.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.MES空æéåº.ObjToInt()) |
| | | { |
| | | return WebResponseContent.Instance.Error($"该æçç¶æä¸æ£ç¡®,ä¸å¯ç³è¯·å
¥åº"); |
| | | } |
| | |
| | | { |
| | | stockInfo.StockStatus = StockStatusEmun.æå¨ç»çå
¥åºç¡®è®¤.ObjToInt(); |
| | | } |
| | | else if (stockInfo.StockStatus == StockStatusEmun.MESéåº.ObjToInt()) |
| | | { |
| | | newTask.TaskType = TaskTypeEnum.MesMatReturn.ObjToInt(); |
| | | } |
| | | else if (stockInfo.StockStatus == StockStatusEmun.MES空æéåº.ObjToInt()) |
| | | { |
| | | //todo å°æçææ¶æªå¯ç¨ |
| | | if (stockInfo.PalletType == PalletTypeEnum.MediumPallet.ObjToInt()) |
| | | { |
| | | newTask.TaskType = TaskTypeEnum.MesPalletLargeReturn.ObjToInt(); |
| | | } |
| | | else |
| | | { |
| | | newTask.TaskType = TaskTypeEnum.MesPalletSmallReturn.ObjToInt(); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | stockInfo.StockStatus = StockStatusEmun.å
¥åºç¡®è®¤.ObjToInt(); |
| | |
| | | return WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// |
| | | /// åæç³è¯·å
¥åº |
| | | /// </summary> |
| | | /// <param name="stationCode"></param> |
| | | /// <param name="palletCode"></param> |
| | | /// <param name="staions"></param> |
| | | /// <param name="heightType"></param> |
| | | /// <param name="stationCode">èµ·å§ç«ç¹</param> |
| | | /// <param name="palletCode">æç</param> |
| | | /// <returns></returns> |
| | | public WebResponseContent DeviceRequestInboundTaskByRoadways(string stationCode, string palletCode, List<string> staions, int heightType) |
| | | public WebResponseContent RequestYLWMSTaskSimple(string stationCode, string palletCode) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | Dt_Task task = Repository.QueryFirst(x => x.PalletCode == palletCode); |
| | | if (task != null) |
| | | { |
| | | PushTasksToWCS(new List<Dt_Task> { task }); |
| | | return WebResponseContent.Instance.OK($"该æçå·²çæä»»å¡", _mapper.Map<WMSTaskDTO>(task)); |
| | | return content.OK($"该æçå·²çæä»»å¡", _mapper.Map<WMSTaskDTO>(task)); |
| | | } |
| | | |
| | | if (Repository.QueryFirst(x => x.SourceAddress == stationCode && x.TaskStatus == TaskStatusEnum.New.ObjToInt()) != null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"该ç«ç¹å·²ææªæ§è¡çä»»å¡"); |
| | | return content.Error($"该ç«ç¹å·²ææªæ§è¡çä»»å¡"); |
| | | } |
| | | |
| | | string roadwayNo = AssignRoadwayNo(staions, palletCode, heightType); |
| | | |
| | | Dt_StockInfo stockInfo = _stockRepository.StockInfoRepository.QueryFirst(x => x.PalletCode == palletCode); |
| | | if (stockInfo == null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"æªæ¾å°ç»çä¿¡æ¯"); |
| | | return content.Error($"æªæ¾å°ç»çä¿¡æ¯"); |
| | | } |
| | | if (stockInfo.StockStatus != StockStatusEmun.ç»çæå.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.æå¨ç»çæå.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.åºåºå®æ.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.æ£é宿.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.éåº.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.MESéåº.ObjToInt()) |
| | | if (stockInfo.StockStatus != StockStatusEmun.æå¨ç»çæå.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.ç»çæå.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.èåéåº.ObjToInt()) |
| | | { |
| | | return WebResponseContent.Instance.Error($"该æçç¶æä¸æ£ç¡®,ä¸å¯ç³è¯·å
¥åº"); |
| | | return content.Error($"该æçç¶æä¸æ£ç¡®,ä¸å¯ç³è¯·å
¥åº"); |
| | | } |
| | | if (!string.IsNullOrEmpty(stockInfo.LocationCode)) |
| | | //åé
å··é |
| | | string rowWay = AssignYLRoadwayNo(stockInfo.PalletCode); |
| | | if (string.IsNullOrEmpty(rowWay)) |
| | | { |
| | | return WebResponseContent.Instance.Error($"该æçå·²ç»å®è´§ä½"); |
| | | return content.Error($"æªæ¾å°å¯åé
å··é"); |
| | | } |
| | | |
| | | //çæä»»å¡ |
| | | Dt_Task newTask = new Dt_Task() |
| | | { |
| | | CurrentAddress = stationCode, |
| | | Grade = 0, |
| | | NextAddress = "", |
| | | PalletCode = palletCode, |
| | | Roadway = roadwayNo, |
| | | Roadway = rowWay, |
| | | SourceAddress = stationCode, |
| | | TargetAddress = roadwayNo, |
| | | TaskType = TaskTypeEnum.Inbound.ObjToInt(), |
| | | TargetAddress = "", |
| | | TaskType = stationCode=="307" ? TaskTypeEnum.PaperOldYLBackInbound.ObjToInt() : TaskTypeEnum.Inbound.ObjToInt(), |
| | | TaskStatus = TaskStatusEnum.New.ObjToInt(), |
| | | WarehouseId = stockInfo.WarehouseId, |
| | | PalletType = stockInfo.PalletType, |
| | | TaskLength = (int)stockInfo.MaterielWide |
| | | }; |
| | | |
| | | //æ´æ°ç¶æ |
| | | if (stockInfo.StockStatus == StockStatusEmun.æå¨ç»çæå.ObjToInt()) |
| | | { |
| | | stockInfo.StockStatus = StockStatusEmun.æå¨ç»çå
¥åºç¡®è®¤.ObjToInt(); |
| | | } |
| | | else if (stockInfo.StockStatus == StockStatusEmun.MESéåº.ObjToInt()) |
| | | { |
| | | newTask.TaskType = TaskTypeEnum.MesMatReturn.ObjToInt(); |
| | | } |
| | | else |
| | | { |
| | | stockInfo.StockStatus = StockStatusEmun.å
¥åºç¡®è®¤.ObjToInt(); |
| | | } |
| | | |
| | | //æ°æ®æ´æ° |
| | | _unitOfWorkManage.BeginTran(); |
| | | int taskId = BaseDal.AddData(newTask); |
| | | newTask.TaskId = taskId; |
| | | _stockRepository.StockInfoRepository.UpdateData(stockInfo); |
| | | _unitOfWorkManage.CommitTran(); |
| | | WMSTaskDTO wMSTaskDTO = _mapper.Map<WMSTaskDTO>(newTask); |
| | | |
| | | PushTasksToWCS(new List<Dt_Task> { newTask }); |
| | | //if (newTask.WarehouseId == 5) PutFinish(stationCode); |
| | | return WebResponseContent.Instance.OK(data: wMSTaskDTO); |
| | | WMSTaskDTO wMSTaskDTO = _mapper.Map<WMSTaskDTO>(newTask); |
| | | return content.OK(data: wMSTaskDTO); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | return WebResponseContent.Instance.Error(ex.Message); |
| | | content.Error(ex.Message); |
| | | } |
| | | return content; |
| | | } |
| | | /// <summary> |
| | | /// åæè¯·æ±ç»ç |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public WebResponseContent YLPurchaseBoxing(string palletCode) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | Dt_StockInfo stockInfoOld = _stockRepository.StockInfoRepository.QueryFirst(x => x.PalletCode == palletCode); |
| | | if (stockInfoOld != null && stockInfoOld.MaterielInvOrgId==MaterielInvOrgEnum.æ°å.ObjToInt()) |
| | | { |
| | | return content.OK($"æ°å临æ¶å
¥åº{stockInfoOld.PalletCode}"); |
| | | } |
| | | else if (stockInfoOld != null && stockInfoOld.MaterielInvOrgId==MaterielInvOrgEnum.èå.ObjToInt() && stockInfoOld.StockStatus == StockStatusEmun.èåéåº.ObjToInt()) |
| | | { |
| | | return content.OK($"èå临æ¶éåº{stockInfoOld.PalletCode}"); |
| | | } |
| | | else if (stockInfoOld != null) |
| | | { |
| | | return content.Error($"æ¡ç {stockInfoOld.PalletCode}ä¿¡æ¯å·²åå¨"); |
| | | } |
| | | |
| | | //è·åéè´ä¿¡æ¯ |
| | | Dt_PurchaseBSTOrderDetail purchaseBSTOrderDetail = _purchaseBSTOrderDetailRepository.QueryFirst(x=>x.Barcode== palletCode); |
| | | if (purchaseBSTOrderDetail == null) |
| | | { |
| | | return content.Error($"æªæ¾å°æ¡ç {palletCode}éè´ä¿¡æ¯"); |
| | | } |
| | | if (purchaseBSTOrderDetail.PurchaseBSTOrderDetailStatus!=InOrderStatusEnum.æªå¼å§.ObjToInt()) |
| | | { |
| | | return content.Error($"éè´{purchaseBSTOrderDetail.Barcode}ä¿¡æ¯å·²å
¥åºæå
¥åºä¸"); |
| | | } |
| | | else |
| | | { |
| | | purchaseBSTOrderDetail.PurchaseBSTOrderDetailStatus = InOrderStatusEnum.å
¥åºä¸.ObjToInt(); |
| | | } |
| | | //è·åéè´ä¸»å |
| | | Dt_PurchaseBSTOrder purchaseBSTOrder = _purchaseBSTOrderRepository.QueryFirst(x=>x.Id==purchaseBSTOrderDetail.PurchaseBSTOrderId); |
| | | //è·åç©æ |
| | | Dt_MaterielInfo materielInfo = _basicRepository.MaterielInfoRepository.QueryFirst(x => x.MaterialSourceId == purchaseBSTOrderDetail.MaterialId); |
| | | //çæåºåç»çä¿¡æ¯ |
| | | Dt_StockInfo stockInfo = new Dt_StockInfo() |
| | | { |
| | | MaterielInvOrgId = materielInfo.MaterielInvOrgId, |
| | | PalletCode = purchaseBSTOrderDetail.Barcode, |
| | | LocationCode = "", |
| | | PalletType = 1, |
| | | WarehouseId = materielInfo.WarehouseId, |
| | | StockAttribute = materielInfo.MaterielSourceType, |
| | | StockStatus = StockStatusEmun.ç»çæå.ObjToInt(), |
| | | MaterielSpec = materielInfo.MaterielSpec, |
| | | Unit = materielInfo.MaterielUnit, |
| | | MaterielThickness = purchaseBSTOrderDetail.MaterialThick, |
| | | MaterielWide = purchaseBSTOrderDetail.MaterialWide, |
| | | MaterielWeight = purchaseBSTOrderDetail.DeliveryQty, |
| | | MaterielCode = materielInfo.MaterielCode, |
| | | MaterielName = materielInfo.MaterielName, |
| | | StockLength= purchaseBSTOrderDetail.ProcurementLength, |
| | | MaterielId= purchaseBSTOrderDetail.MaterialId |
| | | }; |
| | | if (purchaseBSTOrderDetail.MaterialWide > 1200) |
| | | { |
| | | stockInfo.PalletType = 2; |
| | | } |
| | | _unitOfWorkManage.BeginTran(); |
| | | //æ°å¢ç»çä¿¡æ¯ |
| | | _stockRepository.StockInfoRepository.AddData(stockInfo); |
| | | if (purchaseBSTOrder.PurchaseOrderStatus==InOrderStatusEnum.æªå¼å§.ObjToInt()) |
| | | { |
| | | purchaseBSTOrder.PurchaseOrderStatus = InOrderStatusEnum.å
¥åºä¸.ObjToInt(); |
| | | _purchaseBSTOrderRepository.UpdateData(purchaseBSTOrder); |
| | | } |
| | | _purchaseBSTOrderDetailRepository.UpdateData(purchaseBSTOrderDetail); |
| | | _unitOfWorkManage.CommitTran(); |
| | | content.OK("è¯·æ±æå"); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | content.Error(ex.Message); |
| | | } |
| | | return content; |
| | | |
| | | } |
| | | public string AssignYLRoadwayNo(string palletCode) |
| | | { |
| | | try |
| | | { |
| | | Dt_StockInfo stockInfo = _stockRepository.StockInfoRepository.QueryFirst(x => x.PalletCode == palletCode); |
| | | if (stockInfo==null) |
| | | { |
| | | throw new Exception($"ç»çåºåä¸åå¨"); |
| | | } |
| | | Dt_Warehouse warehouse = _basicRepository.WarehouseRepository.QueryFirst(x => x.WarehouseId == stockInfo.WarehouseId); |
| | | |
| | | if (warehouse == null) |
| | | { |
| | | throw new Exception($"æªæ¾å°å··é对åºä»åºä¿¡æ¯"); |
| | | } |
| | | |
| | | string roadwayNo = ""; |
| | | |
| | | if (stockInfo.MaterielInvOrgId==MaterielInvOrgEnum.æ°å.ObjToInt()) |
| | | { |
| | | //éå¶ç´å¾ |
| | | if (stockInfo.MaterielThickness >= 300 && stockInfo.MaterielThickness <= 1300 && stockInfo.MaterielWide >= 700 && stockInfo.MaterielWide <= 2700) |
| | | { |
| | | bool LayerLimit = false; |
| | | if (stockInfo.MaterielThickness >= 800) |
| | | { |
| | | LayerLimit = true; |
| | | } |
| | | //è·ååé
|
| | | List<LocationCount> locationCounts = Db.Queryable<Dt_LocationInfo>().Where(x => x.WarehouseId == warehouse.WarehouseId && x.LocationStatus == LocationStatusEnum.Free.ObjToInt() && (x.EnableStatus == EnableStatusEnum.OnlyIn.ObjToInt() || x.EnableStatus == EnableStatusEnum.Normal.ObjToInt()) && x.RoadwayNo.Contains("YLDual")).GroupBy(x => x.RoadwayNo).Select(x => new LocationCount { RoadwayNo = x.RoadwayNo, Count = SqlFunc.AggregateCount(x) }).ToList(); |
| | | |
| | | roadwayNo = HandleRoadway(locationCounts, warehouse); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | //éå¶ |
| | | if (stockInfo.MaterielThickness >= 800 && stockInfo.MaterielThickness <= 1500 && stockInfo.MaterielWide >= 700 && stockInfo.MaterielWide <= 2500) |
| | | { |
| | | bool LayerLimit = false; |
| | | if (stockInfo.MaterielThickness>1300) |
| | | { |
| | | LayerLimit = true; |
| | | } |
| | | //è·ååé
|
| | | List<LocationCount> locationCounts = Db.Queryable<Dt_LocationInfo>().Where(x => x.WarehouseId == warehouse.WarehouseId && x.LocationStatus == LocationStatusEnum.Free.ObjToInt() && (x.EnableStatus == EnableStatusEnum.OnlyIn.ObjToInt() || x.EnableStatus == EnableStatusEnum.Normal.ObjToInt()) && x.RoadwayNo.Contains("YL") && !x.RoadwayNo.Contains("YLDual") && (LayerLimit ? x.Columns>=56 : x.Columns<=55)).GroupBy(x => x.RoadwayNo).Select(x => new LocationCount { RoadwayNo = x.RoadwayNo, Count = SqlFunc.AggregateCount(x) }).ToList(); |
| | | if (stockInfo.MaterielWide > 2200) |
| | | { |
| | | locationCounts = Db.Queryable<Dt_LocationInfo>().Where(x => x.WarehouseId == warehouse.WarehouseId && x.LocationStatus == LocationStatusEnum.Free.ObjToInt() && (x.EnableStatus == EnableStatusEnum.OnlyIn.ObjToInt() || x.EnableStatus == EnableStatusEnum.Normal.ObjToInt()) && x.RoadwayNo == "SC02_YL" && (LayerLimit ? x.Columns >= 56 : x.Columns <= 55)).GroupBy(x => x.RoadwayNo).Select(x => new LocationCount { RoadwayNo = x.RoadwayNo, Count = SqlFunc.AggregateCount(x) }).ToList(); |
| | | } |
| | | |
| | | roadwayNo = HandleRoadway(locationCounts, warehouse); |
| | | } |
| | | } |
| | | |
| | | return !string.IsNullOrEmpty(roadwayNo) ? (roadwayNo) : throw new Exception("æªæ¾å°å¯åé
å··é"); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | throw new Exception(ex.Message); |
| | | } |
| | | } |
| | | |
| | | //å¤çåé
å··é 任塿°é |
| | | public string HandleRoadway(List<LocationCount> locationCounts, Dt_Warehouse warehouse) |
| | | { |
| | | //å··éä»»å¡åé
æ°é |
| | | List<LocationCount> useLocationCounts = Db.Queryable<Dt_Task>().Where(x => x.WarehouseId == warehouse.WarehouseId |
| | | && locationCounts.Select(j => j.RoadwayNo).Distinct().Contains(x.Roadway) |
| | | && TaskInboundTypes.Contains(x.TaskType)).GroupBy(x => x.Roadway).Select(x => new LocationCount { RoadwayNo = x.Roadway, Count = SqlFunc.AggregateCount(x) }).ToList(); |
| | | foreach (var item in locationCounts) |
| | | { |
| | | LocationCount? count = useLocationCounts.FirstOrDefault(x => x.RoadwayNo == item.RoadwayNo); |
| | | if (count != null) |
| | | { |
| | | item.Count -= count.Count; |
| | | } |
| | | } |
| | | return locationCounts.Where(x => x.Count > 0).OrderByDescending(x => x.Count).FirstOrDefault()?.RoadwayNo ?? ""; |
| | | } |
| | | /// <summary> |
| | | /// å
¥åºå®æ |
| | | /// </summary> |
| | | public WebResponseContent InboundTaskCompleted(Dt_Task task) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | Dt_Warehouse warehouse = _basicRepository.WarehouseRepository.QueryFirst(x => x.WarehouseId == task.WarehouseId); |
| | | if (warehouse.WarehouseCode == WarehouseEnum.LLDCP.ToString() || warehouse.WarehouseCode == WarehouseEnum.LLDFL.ToString()) //æå/è¾
æå®æ |
| | | { |
| | | Dt_LocationInfo locationInfoEnd = _basicService.LocationInfoService.Repository.QueryFirst(x => x.LocationCode == task.TargetAddress); |
| | | if (locationInfoEnd == null) |
| | | { |
| | | return content.Error($"æªæ¾å°å¯¹åºçç»ç¹è´§ä½ä¿¡æ¯"); |
| | | } |
| | | Dt_AGVStationInfo agvstation = _agvStationInfoRepository.QueryFirst(x => x.AGVStationCode == task.SourceAddress && ( x.StationArea == AGVStationAreaEnum.AreaA.ObjToInt() || x.StationArea == AGVStationAreaEnum.AreaC.ObjToInt())); |
| | | if (agvstation != null) |
| | | { |
| | | agvstation.IsOccupied = WhetherEnum.False.ObjToInt(); |
| | | } |
| | | Dt_ProStockInfo proStockInfo = _stockRepository.ProStockInfoRepository.Db.Queryable<Dt_ProStockInfo>().Where(x => x.PalletCode == task.PalletCode).Includes(x=>x.proStockInfoDetails).First(); |
| | | if (proStockInfo != null && proStockInfo.StockStatus == StockStatusEmun.MES空æéåº.ObjToInt()) |
| | | { |
| | | task.TaskStatus = TaskStatusEnum.Finish.ObjToInt(); |
| | | _unitOfWorkManage.BeginTran(); |
| | | if (agvstation != null) |
| | | { |
| | | _agvStationInfoRepository.UpdateData(agvstation); |
| | | } |
| | | proStockInfo.LocationCode = locationInfoEnd.LocationCode; |
| | | proStockInfo.StockStatus = StockStatusEmun.å
¥åºå®æ.ObjToInt(); |
| | | _stockRepository.ProStockInfoRepository.UpdateData(proStockInfo); |
| | | _basicService.LocationInfoService.UpdateLocationStatus(locationInfoEnd, proStockInfo.PalletType, LocationStatusEnum.InStock, proStockInfo.WarehouseId); |
| | | BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId > 0 ? WIDESEA_Core.Enums.OperateTypeEnum.äººå·¥å®æ : WIDESEA_Core.Enums.OperateTypeEnum.èªå¨å®æ); |
| | | _unitOfWorkManage.CommitTran(); |
| | | } |
| | | else if (proStockInfo != null && proStockInfo.StockStatus == StockStatusEmun.æå¨ç»çå
¥åºç¡®è®¤.ObjToInt()) |
| | | { |
| | | task.TaskStatus = TaskStatusEnum.Finish.ObjToInt(); |
| | | proStockInfo.proStockInfoDetails.ForEach(x => |
| | | { |
| | | x.ProStockDetailStatus = StockStatusEmun.å
¥åºå®æ.ObjToInt(); |
| | | }); |
| | | _unitOfWorkManage.BeginTran(); |
| | | if (agvstation != null) |
| | | { |
| | | _agvStationInfoRepository.UpdateData(agvstation); |
| | | } |
| | | proStockInfo.LocationCode = locationInfoEnd.LocationCode; |
| | | proStockInfo.StockStatus = StockStatusEmun.å
¥åºå®æ.ObjToInt(); |
| | | _stockRepository.ProStockInfoRepository.UpdateData(proStockInfo); |
| | | _stockRepository.ProStockInfoDetailRepository.UpdateData(proStockInfo.proStockInfoDetails); |
| | | _basicService.LocationInfoService.UpdateLocationStatus(locationInfoEnd, proStockInfo.PalletType, LocationStatusEnum.InStock, proStockInfo.WarehouseId); |
| | | BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId > 0 ? WIDESEA_Core.Enums.OperateTypeEnum.äººå·¥å®æ : WIDESEA_Core.Enums.OperateTypeEnum.èªå¨å®æ); |
| | | _unitOfWorkManage.CommitTran(); |
| | | } |
| | | else |
| | | { |
| | | return content.Error($"æªæ¾å°å¯¹åºåºåä¿¡æ¯"); |
| | | } |
| | | } |
| | | else//åæåºå®æ |
| | | { |
| | | //è·ååºå |
| | | Dt_StockInfo stockInfo = _stockService.StockInfoService.Repository.QueryFirst(x => x.PalletCode == task.PalletCode); |
| | | if (stockInfo == null) |
| | | { |
| | | return content.Error($"æªæ¾å°å¯¹åºåºåä¿¡æ¯"); |
| | | } |
| | | //è·åè´§ä½ä¿¡æ¯ |
| | | Dt_LocationInfo locationInfoEnd = _basicService.LocationInfoService.Repository.QueryFirst(x => x.LocationCode == task.TargetAddress); |
| | | if (locationInfoEnd == null) |
| | | { |
| | | return content.Error($"æªæ¾å°å¯¹åºçç»ç¹è´§ä½ä¿¡æ¯"); |
| | | } |
| | | //æ´æ°ç¶æ |
| | | task.TaskStatus = TaskStatusEnum.Finish.ObjToInt(); |
| | | _unitOfWorkManage.BeginTran(); |
| | | if (task.TaskType == TaskTypeEnum.InPick.ObjToInt()) |
| | | { |
| | | Dt_LocationInfo locationInfoStart = _basicService.LocationInfoService.Repository.QueryFirst(x => x.LocationCode == task.SourceAddress); |
| | | _basicService.LocationInfoService.UpdateLocationStatus(locationInfoStart, stockInfo.PalletType, LocationStatusEnum.Free, stockInfo.WarehouseId); |
| | | } |
| | | stockInfo.LocationCode = locationInfoEnd.LocationCode; |
| | | stockInfo.StockStatus = StockStatusEmun.å
¥åºå®æ.ObjToInt(); |
| | | _stockService.StockInfoService.Repository.UpdateData(stockInfo); |
| | | _basicService.LocationInfoService.UpdateLocationStatus(locationInfoEnd, stockInfo.PalletType, LocationStatusEnum.InStock, stockInfo.WarehouseId); |
| | | BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId > 0 ? WIDESEA_Core.Enums.OperateTypeEnum.äººå·¥å®æ : WIDESEA_Core.Enums.OperateTypeEnum.èªå¨å®æ); |
| | | //䏿¥èåERP |
| | | if (stockInfo.MaterielInvOrgId == MaterielInvOrgEnum.èå.ObjToInt()) |
| | | { |
| | | int Qty = Convert.ToInt32(stockInfo.MaterielWeight); |
| | | BSTPurchaseUpModel bSTPurchaseUpModel = new BSTPurchaseUpModel() |
| | | { |
| | | Barcode = stockInfo.PalletCode, |
| | | BarcodeQty = Qty, |
| | | Rfid = stockInfo.PalletCode, |
| | | RfidUpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") |
| | | }; |
| | | BSTResponse bSTResponse = _invokeERPService.BSTPurchaseUp(bSTPurchaseUpModel).DeserializeObject<BSTResponse>(); |
| | | if (bSTResponse.Code == 500) |
| | | { |
| | | throw new Exception($"BST䏿ERP忥å
¥åºä¿¡æ¯å¤±è´¥,é误信æ¯ï¼{bSTResponse.Msg}"); |
| | | } |
| | | } |
| | | _unitOfWorkManage.CommitTran(); |
| | | } |
| | | return content.OK(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | content.Error(ex.Message); |
| | | } |
| | | return content; |
| | | } |
| | | /// <summary> |
| | | /// åé
æåå··é |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public string AssignCPRoadwayNo() |
| | | { |
| | | try |
| | | { |
| | | string roadwayNo = ""; |
| | | //è·åå··éå¯åé
çè´§ä½æ°é |
| | | List<LocationCount> locationCounts = Db.Queryable<Dt_LocationInfo>().Where(x => x.WarehouseId == WarehouseEnum.LLDCP.ObjToInt() && x.LocationStatus == LocationStatusEnum.Free.ObjToInt() && (x.EnableStatus == EnableStatusEnum.OnlyIn.ObjToInt() || x.EnableStatus == EnableStatusEnum.Normal.ObjToInt()) && x.RoadwayNo.Contains("CP")).GroupBy(x => x.RoadwayNo).Select(x => new LocationCount { RoadwayNo = x.RoadwayNo, Count = SqlFunc.AggregateCount(x) }).ToList(); |
| | | //çéå½åå
¥åºä»»å¡ä¸å·²åé
å··é任塿°é |
| | | List<LocationCount> useLocationCounts = Db.Queryable<Dt_Task>().Where(x => (x.WarehouseId == WarehouseEnum.LLDCP.ObjToInt()|| x.WarehouseId == WarehouseEnum.LLDFL.ObjToInt()) |
| | | && locationCounts.Select(j=>j.RoadwayNo).Distinct().Contains(x.Roadway) |
| | | && TaskInboundTypes.Contains(x.TaskType)).GroupBy(x => x.Roadway).Select(x => new LocationCount { RoadwayNo = x.Roadway, Count = SqlFunc.AggregateCount(x) }).ToList(); |
| | | foreach (var item in locationCounts) |
| | | { |
| | | LocationCount? count = useLocationCounts.FirstOrDefault(x => x.RoadwayNo == item.RoadwayNo); |
| | | if (count!=null) |
| | | { |
| | | item.Count -= count.Count; |
| | | } |
| | | } |
| | | //éè¿å¯ç¨è´§ä½æ°éæåºï¼æå¤çä¼å
åé
|
| | | roadwayNo = locationCounts.Where(x=>x.Count>0).OrderByDescending(x => x.Count).FirstOrDefault()?.RoadwayNo ?? ""; |
| | | return !string.IsNullOrEmpty(roadwayNo) ? (roadwayNo) : throw new Exception("æªæ¾å°å¯åé
å··é"); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | throw new Exception(ex.Message); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// å
¥åºä»»å¡ç³è¯·åé
è´§ä½ |
| | | /// </summary> |
| | |
| | | { |
| | | return WebResponseContent.Instance.OK(data: task.TargetAddress); |
| | | } |
| | | |
| | | //åé
è´§ä½ |
| | | Dt_LocationInfo? locationInfo = _basicService.LocationInfoService.AssignLocation(roadwayNo, task.PalletType, task.WarehouseId); |
| | | if (locationInfo == null) |
| | | { |
| | |
| | | { |
| | | task.TaskStatus = TaskStatusEnum.SC_Execute.ObjToInt(); |
| | | } |
| | | |
| | | |
| | | LocationStatusEnum lastStatus = (LocationStatusEnum)locationInfo.LocationStatus; |
| | | |
| | | //æ´æ°éå®è´§ä½ |
| | | _unitOfWorkManage.BeginTran(); |
| | | _recordService.LocationStatusChangeRecordSetvice.AddLocationStatusChangeRecord(locationInfo, lastStatus, LocationStatusEnum.Lock, LocationChangeType.InboundAssignLocation); |
| | | _basicService.LocationInfoService.UpdateLocationStatus(locationInfo, task.PalletType, LocationStatusEnum.Lock, task.WarehouseId); |
| | |
| | | return WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// |
| | | /// 空æ¡ååº |
| | | /// </summary> |
| | | /// <param name="taskNum"></param> |
| | | /// <param name="roadwayNo"></param> |
| | | /// <param name="heightType"></param> |
| | | /// <returns></returns> |
| | | public WebResponseContent AssignInboundTaskLocationByHeight(int taskNum, string roadwayNo, int heightType) |
| | | { |
| | | try |
| | | { |
| | | Dt_Task task = BaseDal.QueryFirst(x => x.TaskNum == taskNum); |
| | | if (task == null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"æªæ¾å°è¯¥å
¥åºä»»å¡"); |
| | | } |
| | | |
| | | if (_basicRepository.LocationInfoRepository.QueryFirst(x => x.LocationCode == task.TargetAddress) != null) |
| | | { |
| | | return WebResponseContent.Instance.OK(data: task.TargetAddress); |
| | | } |
| | | |
| | | Dt_LocationInfo? locationInfo = _basicService.LocationInfoService.AssignLocation(roadwayNo, task.PalletType, task.WarehouseId, heightType: heightType); |
| | | if (locationInfo == null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"è´§ä½åé
失败,æªæ¾å°å¯åé
è´§ä½"); |
| | | } |
| | | |
| | | task.Roadway = roadwayNo; |
| | | task.TargetAddress = locationInfo.LocationCode; |
| | | task.TaskStatus = TaskStatusEnum.SC_Execute.ObjToInt(); |
| | | |
| | | LocationStatusEnum lastStatus = (LocationStatusEnum)locationInfo.LocationStatus; |
| | | |
| | | _unitOfWorkManage.BeginTran(); |
| | | _recordService.LocationStatusChangeRecordSetvice.AddLocationStatusChangeRecord(locationInfo, lastStatus, LocationStatusEnum.Lock, LocationChangeType.InboundAssignLocation); |
| | | _basicService.LocationInfoService.UpdateLocationStatus(locationInfo, task.PalletType, LocationStatusEnum.Lock, task.WarehouseId); |
| | | BaseDal.UpdateData(task); |
| | | _unitOfWorkManage.CommitTran(); |
| | | return WebResponseContent.Instance.OK(data: locationInfo.LocationCode); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | return WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | } |
| | | public readonly string[] OutStartPonits = { "5230", "5237", "5244" }; |
| | | /// <summary> |
| | | /// æå使éåºå
¥ä» |
| | | /// </summary> |
| | | /// <param name="barCode"></param> |
| | | /// <param name="startPoint"></param> |
| | | /// <returns></returns> |
| | | public WebResponseContent BackProductTask(string barCode, string startPoint) |
| | | public WebResponseContent EmptyBackTask(string barCode, string startPoint) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | string palletCode = @"^C\d{5}$"; // æ£åè¡¨è¾¾å¼ |
| | | bool isValid = Regex.IsMatch(barCode, palletCode); |
| | | if (!isValid) |
| | | { |
| | | return content.Error($"æ¡ç æ ¼å¼é误{barCode}"); |
| | | } |
| | | if (!OutStartPonits.Contains(startPoint)) |
| | | //string palletCode = @"^C\d{5}$"; // æ£åè¡¨è¾¾å¼ |
| | | //bool isValid = Regex.IsMatch(barCode, palletCode); |
| | | //if (!isValid) |
| | | //{ |
| | | // return content.Error($"æ¡ç æ ¼å¼é误{barCode}"); |
| | | //} |
| | | Dt_AGVStationInfo agvstation = _agvStationInfoRepository.QueryFirst(x=>x.AGVStationCode==startPoint); |
| | | if (agvstation==null) |
| | | { |
| | | return content.Error($"èµ·ç¹é误{startPoint}"); |
| | | } |
| | | //夿å½åç¹ä½æ¯å¦éå¤ |
| | | Dt_Task taskOldPoint = BaseDal.QueryFirst(x=>x.SourceAddress==startPoint && (x.TaskStatus == TaskStatusEnum.New.ObjToInt()||x.TaskStatus==TaskStatusEnum.Line_Execute.ObjToInt()|| x.TaskStatus == TaskStatusEnum.Line_Executing.ObjToInt() || x.TaskStatus == TaskStatusEnum.AGV_Takeing.ObjToInt())); |
| | | Dt_Task taskOldPoint = BaseDal.QueryFirst(x => x.SourceAddress == startPoint &&( x.TaskStatus == TaskStatusEnum.New.ObjToInt() || x.TaskStatus==TaskStatusEnum.AGV_Executing.ObjToInt())); |
| | | if (taskOldPoint != null) |
| | | { |
| | | return content.Error($"ç«ç¹{startPoint}å·²åå¨ä»»å¡"); |
| | |
| | | Dt_Task taskOld = BaseDal.QueryFirst(x => x.PalletCode == barCode); |
| | | if (taskOld != null) |
| | | { |
| | | return content.Error($"è¶æ¡{barCode}ä»»å¡å·²åå¨"); |
| | | return content.Error($"æç{barCode}ä»»å¡å·²åå¨"); |
| | | } |
| | | //è·åè¶æ¡ä½æ |
| | | Dt_ProStockInfo proStockInfo = _stockRepository.ProStockInfoRepository.Db.Queryable<Dt_ProStockInfo>().Where(x=>x.PalletCode== barCode).Includes(x=>x.proStockInfoDetails).First(); |
| | | if (proStockInfo==null) |
| | | Dt_ProStockInfo proStockInfoOld = _stockRepository.ProStockInfoRepository.QueryFirst(x => x.PalletCode == barCode); |
| | | if (proStockInfoOld!=null) |
| | | { |
| | | return content.Error($"æªæ¾å°{barCode}è¶æ¡ä¿¡æ¯"); |
| | | return content.Error($"æç{barCode}å·²åå¨"); |
| | | } |
| | | if (proStockInfo.proStockInfoDetails==null || proStockInfo.proStockInfoDetails.Count<=0) |
| | | //åé
å··é |
| | | string roadWay=AssignCPRoadwayNo(); |
| | | |
| | | Dt_ProStockInfo proStockInfo = new Dt_ProStockInfo() |
| | | { |
| | | return content.Error($"{barCode}è¶æ¡ä¿¡æ¯ä¸ºç©º"); |
| | | } |
| | | if (proStockInfo.StockStatus!=StockStatusEmun.åºåºå®æ.ObjToInt()) |
| | | { |
| | | return content.Error($"{barCode}è¶æ¡ä¿¡æ¯ç¶æå¼å¸¸"); |
| | | } |
| | | //è·åæåå¹³åº |
| | | Dt_Warehouse warehouse = _basicRepository.WarehouseRepository.QueryFirst(x => x.WarehouseCode == WarehouseEnum.HA101.ToString()); |
| | | if (proStockInfo.WarehouseId != warehouse.WarehouseId && proStockInfo.LocationCode!= "æåå
è£
æ£è´§åº") |
| | | { |
| | | return content.Error($"{barCode}è¶æ¡ä¿¡æ¯ä¸å¨æ£è´§åº"); |
| | | } |
| | | //è·åå½åçåºå屿§ |
| | | Dt_Warehouse? warePoint = null; |
| | | switch (proStockInfo.ProStockAttribute) |
| | | { |
| | | case (int)ProStockAttributeEnum.æå: |
| | | warePoint = _basicRepository.WarehouseRepository.QueryFirst(x => x.WarehouseCode == WarehouseEnum.HA71.ToString()); |
| | | break; |
| | | case (int)ProStockAttributeEnum.å°¾æ°: |
| | | warePoint = _basicRepository.WarehouseRepository.QueryFirst(x => x.WarehouseCode == WarehouseEnum.HA72.ToString()); |
| | | break; |
| | | case (int)ProStockAttributeEnum.ç å: |
| | | warePoint = _basicRepository.WarehouseRepository.QueryFirst(x => x.WarehouseCode == WarehouseEnum.HA73.ToString()); |
| | | break; |
| | | default: |
| | | throw new Exception($"æªæ¾å°{barCode}è¶æ¡ä¿¡æ¯åºå屿§"); |
| | | } |
| | | Dt_Warehouse warehouseLocation = _basicRepository.WarehouseRepository.QueryFirst(x => x.WarehouseCode == WarehouseEnum.HA71.ToString()); |
| | | Dt_LocationInfo locationInfo = _basicRepository.LocationInfoRepository.QueryFirst(x => x.WarehouseId == warehouseLocation.WarehouseId); |
| | | if (locationInfo == null) |
| | | { |
| | | return content.Error($"æªæ¾å°{warehouse.WarehouseCode}è´§ä½ä¿¡æ¯"); |
| | | } |
| | | proStockInfo.StockStatus = StockStatusEmun.æå使ååº.ObjToInt(); |
| | | proStockInfo.proStockInfoDetails.ForEach(x => |
| | | { |
| | | x.ProOutDetailStatus = StockStatusEmun.æå使ååº.ObjToInt(); |
| | | }); |
| | | PalletCode=barCode, |
| | | ProStockAttribute=ProStockAttributeEnum.空æ.ObjToInt(), |
| | | PalletType=1, |
| | | LocationCode="", |
| | | WarehouseId= WarehouseEnum.LLDFL.ObjToInt(), |
| | | StockStatus=StockStatusEmun.MES空æéåº.ObjToInt() |
| | | }; |
| | | |
| | | Dt_Task newTask = new Dt_Task() |
| | | { |
| | | CurrentAddress = startPoint, |
| | | Grade = 0, |
| | | NextAddress = "", |
| | | PalletCode = proStockInfo.PalletCode, |
| | | Roadway = locationInfo.RoadwayNo, |
| | | PalletCode = barCode, |
| | | Roadway = roadWay, |
| | | SourceAddress = startPoint, |
| | | TargetAddress = "", |
| | | TaskType = TaskTypeEnum.InProductBack.ObjToInt(), |
| | | TaskType = TaskTypeEnum.EmptyProductBack.ObjToInt(), |
| | | TaskStatus = TaskStatusEnum.New.ObjToInt(), |
| | | WarehouseId = warePoint.WarehouseId, |
| | | PalletType = proStockInfo.PalletType, |
| | | MaterielCode = proStockInfo.proStockInfoDetails.Where(x => x.ProStockId == proStockInfo.Id).FirstOrDefault()?.ProductCode, |
| | | Quantity = (float)proStockInfo.proStockInfoDetails.Where(x => x.ProStockId == proStockInfo.Id).Sum(x => x.StockPcsQty) |
| | | WarehouseId = WarehouseEnum.LLDFL.ObjToInt(), |
| | | PalletType = 1 |
| | | }; |
| | | _unitOfWorkManage.BeginTran(); |
| | | int taskId = BaseDal.AddData(newTask); |
| | | _stockRepository.ProStockInfoRepository.AddData(proStockInfo); |
| | | newTask.TaskId = taskId; |
| | | _stockRepository.ProStockInfoRepository.UpdateData(proStockInfo); |
| | | _stockRepository.ProStockInfoDetailRepository.UpdateData(proStockInfo.proStockInfoDetails); |
| | | _unitOfWorkManage.CommitTran(); |
| | | //æ¨éä»»å¡ |
| | | PushTasksToWCS(new List<Dt_Task> { newTask },"AGV"); |
| | | content.OK("åéæå"); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | content.Error(ex.Message); |
| | | } |
| | | return content; |
| | | } |
| | | private readonly static object _lockerFLorCP = new object(); |
| | | /// <summary> |
| | | /// è¾
æ/æå临æ¶å
¥åº |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public WebResponseContent InboundFLOrCPTask(string barCode, string startPoint,string matCode,int matCount) |
| | | { |
| | | lock (_lockerFLorCP) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | //string palletCode = @"^C\d{5}$"; // æ£åè¡¨è¾¾å¼ |
| | | //bool isValid = Regex.IsMatch(barCode, palletCode); |
| | | //if (!isValid) |
| | | //{ |
| | | // return content.Error($"æ¡ç æ ¼å¼é误{barCode}"); |
| | | //} |
| | | //è·åç©æ |
| | | Dt_MaterielInfo materielInfo = _basicRepository.MaterielInfoRepository.QueryFirst(x => x.MaterielCode == matCode && x.MaterielInvOrgId == MaterielInvOrgEnum.æ°å.ObjToInt() && (x.WarehouseId==WarehouseEnum.LLDCP.ObjToInt() || x.WarehouseId == WarehouseEnum.LLDFL.ObjToInt())); |
| | | if (materielInfo == null) |
| | | { |
| | | return content.Error($"æªæ¾å°ç©æä¿¡æ¯{matCode}"); |
| | | } |
| | | Dt_AGVStationInfo agvstation = _agvStationInfoRepository.QueryFirst(x => x.AGVStationCode == startPoint); |
| | | if (agvstation == null) |
| | | { |
| | | return content.Error($"èµ·ç¹é误{startPoint}"); |
| | | } |
| | | //夿å½åç¹ä½æ¯å¦éå¤ |
| | | Dt_Task taskOldPoint = BaseDal.QueryFirst(x => x.SourceAddress == startPoint && (x.TaskStatus == TaskStatusEnum.New.ObjToInt() || x.TaskStatus == TaskStatusEnum.AGV_Executing.ObjToInt())); |
| | | if (taskOldPoint != null) |
| | | { |
| | | return content.Error($"ç«ç¹{startPoint}å·²åå¨ä»»å¡"); |
| | | } |
| | | Dt_Task taskOld = BaseDal.QueryFirst(x => x.PalletCode == barCode); |
| | | if (taskOld != null) |
| | | { |
| | | return content.Error($"æç{barCode}ä»»å¡å·²åå¨"); |
| | | } |
| | | Dt_ProStockInfo proStockInfoOld = _stockRepository.ProStockInfoRepository.QueryFirst(x => x.PalletCode == barCode); |
| | | if (proStockInfoOld != null) |
| | | { |
| | | return content.Error($"æç{barCode}å·²åå¨"); |
| | | } |
| | | //åé
å··é |
| | | string roadWay = AssignCPRoadwayNo(); |
| | | |
| | | //è·åæååº |
| | | WarehouseEnum warehouseEnum = materielInfo.MaterielSourceType == MaterielTypeEnum.æå.ObjToInt() ? WarehouseEnum.LLDCP : WarehouseEnum.LLDFL; |
| | | Dt_ProStockInfoDetail proStockInfoDetail = new Dt_ProStockInfoDetail() |
| | | { |
| | | ProductCode = materielInfo.MaterielCode, |
| | | ProductName= materielInfo.MaterielName, |
| | | ProductSpec=materielInfo.MaterielSpec, |
| | | ProductUnit=materielInfo.MaterielUnit, |
| | | StockQty = matCount, |
| | | ProStockDetailStatus = StockStatusEmun.æå¨ç»çå
¥åºç¡®è®¤.ObjToInt() |
| | | }; |
| | | Dt_ProStockInfo proStockInfo = new Dt_ProStockInfo() |
| | | { |
| | | PalletCode = barCode, |
| | | ProStockAttribute = materielInfo.MaterielSourceType, |
| | | PalletType = 1, |
| | | LocationCode = "", |
| | | WarehouseId = warehouseEnum.ObjToInt(), |
| | | StockStatus = StockStatusEmun.æå¨ç»çå
¥åºç¡®è®¤.ObjToInt(), |
| | | proStockInfoDetails = new List<Dt_ProStockInfoDetail> { proStockInfoDetail } |
| | | }; |
| | | |
| | | Dt_Task newTask = new Dt_Task() |
| | | { |
| | | CurrentAddress = startPoint, |
| | | Grade = 0, |
| | | NextAddress = "", |
| | | PalletCode = barCode, |
| | | Roadway = roadWay, |
| | | SourceAddress = startPoint, |
| | | TargetAddress = "", |
| | | TaskType = TaskTypeEnum.Inbound.ObjToInt(), |
| | | TaskStatus = TaskStatusEnum.New.ObjToInt(), |
| | | WarehouseId = warehouseEnum.ObjToInt(), |
| | | PalletType = 1 |
| | | }; |
| | | _unitOfWorkManage.BeginTran(); |
| | | int taskId = BaseDal.AddData(newTask); |
| | | BaseDal.Db.InsertNav(proStockInfo).Include(x => x.proStockInfoDetails).ExecuteCommand(); |
| | | newTask.TaskId = taskId; |
| | | _unitOfWorkManage.CommitTran(); |
| | | //æ¨éä»»å¡ |
| | | PushTasksToWCS(new List<Dt_Task> { newTask }, "AGV"); |
| | | content.OK("åéæå"); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | content.Error(ex.Message); |
| | | } |
| | | return content; |
| | | } |
| | | } |
| | | /// <summary> |
| | | /// å°å·ä½æéæä»»å¡ |
| | | /// </summary> |
| | | public WebResponseContent PrintBackInbound(SaveModel saveModel) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | var barcode = saveModel.MainData["palletCode"].ToString(); |
| | | var warehouseId = saveModel.MainData["warehouseId"].ObjToInt(); |
| | | var materSn = saveModel.MainData["materSn"]; |
| | | //ç´å¾ |
| | | var thickness = saveModel.MainData["thickness"].ObjToInt(); |
| | | var weight = saveModel.MainData["weight"].ObjToInt(); |
| | | var address = saveModel.MainData["address"].ToString(); |
| | | //å¹
宽 |
| | | var wide = saveModel.MainData["wide"].ObjToInt(); |
| | | Dt_MaterielInfo? materielInfo = _basicRepository.MaterielInfoRepository.QueryFirst(x => x.MaterielCode == materSn); |
| | | if (materielInfo == null) |
| | | { |
| | | return content.Error("æªæ¾å°ç©æä¿¡æ¯"); |
| | | } |
| | | Dt_StockInfo stockInfoOld = _stockRepository.StockInfoRepository.QueryFirst(x => x.PalletCode == barcode); |
| | | if (stockInfoOld != null) |
| | | { |
| | | return content.Error("æçä¿¡æ¯å·²åå¨"); |
| | | } |
| | | //çæåºåç»çä¿¡æ¯ |
| | | Dt_StockInfo stockInfo = new Dt_StockInfo() |
| | | { |
| | | MaterielInvOrgId = materielInfo.MaterielInvOrgId, |
| | | PalletCode = barcode, |
| | | LocationCode = "", |
| | | PalletType = 1, |
| | | WarehouseId = warehouseId, |
| | | StockAttribute = materielInfo.MaterielSourceType, |
| | | StockStatus = StockStatusEmun.æå¨ç»çå
¥åºç¡®è®¤.ObjToInt(), |
| | | MaterielSpec = materielInfo.MaterielSpec, |
| | | Unit = materielInfo.MaterielUnit, |
| | | MaterielThickness = thickness, |
| | | MaterielWide = wide, |
| | | MaterielWeight = weight, |
| | | MaterielCode = materielInfo.MaterielCode, |
| | | MaterielName = materielInfo.MaterielName, |
| | | }; |
| | | if (wide > 1200) |
| | | { |
| | | stockInfo.PalletType = 2; |
| | | } |
| | | |
| | | //çæå°å·ä½æéæä»»å¡ |
| | | Dt_Task newTask = new Dt_Task() |
| | | { |
| | | CurrentAddress = address, |
| | | Grade = 0, |
| | | NextAddress = "", |
| | | PalletCode = barcode, |
| | | Roadway = "", |
| | | SourceAddress = address, |
| | | TargetAddress = "", |
| | | TaskType = TaskTypeEnum.PrintYLBackInbound.ObjToInt(), |
| | | TaskStatus = TaskStatusEnum.New.ObjToInt(), |
| | | WarehouseId = warehouseId, |
| | | PalletType = 1, |
| | | TaskLength= wide |
| | | }; |
| | | _unitOfWorkManage.BeginTran(); |
| | | int taskId = BaseDal.AddData(newTask); |
| | | _stockRepository.StockInfoRepository.AddData(stockInfo); |
| | | newTask.TaskId = taskId; |
| | | _unitOfWorkManage.CommitTran(); |
| | | //æ¨éä»»å¡ |
| | | PushTasksToWCS(new List<Dt_Task> { newTask }); |
| | |
| | | return content; |
| | | } |
| | | /// <summary> |
| | | /// 空æ¡ååº |
| | | /// å°å·ä¸æä»»å¡ |
| | | /// </summary> |
| | | public WebResponseContent EmptyBackTask(string barCode, string startPoint) |
| | | public WebResponseContent PrintInbound(SaveModel saveModel) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | string palletCode = @"^C\d{5}$"; // æ£åè¡¨è¾¾å¼ |
| | | bool isValid = Regex.IsMatch(barCode, palletCode); |
| | | if (!isValid) |
| | | var barcode = saveModel.MainData["palletCode"].ToString(); |
| | | var warehouseId = saveModel.MainData["warehouseId"].ObjToInt(); |
| | | var materSn = saveModel.MainData["materSn"]; |
| | | //ç´å¾ |
| | | var thickness = saveModel.MainData["thickness"].ObjToInt(); |
| | | var weight = saveModel.MainData["weight"].ObjToInt(); |
| | | var address = saveModel.MainData["address"].ToString(); |
| | | //å¹
宽 |
| | | var wide = saveModel.MainData["wide"].ObjToInt(); |
| | | Dt_MaterielInfo? materielInfo = _basicRepository.MaterielInfoRepository.QueryFirst(x => x.MaterielCode == materSn); |
| | | if (materielInfo == null) |
| | | { |
| | | return content.Error($"æ¡ç æ ¼å¼é误{barCode}"); |
| | | return content.Error("æªæ¾å°ç©æä¿¡æ¯"); |
| | | } |
| | | if (!OutStartPonits.Contains(startPoint)) |
| | | if (materielInfo.MaterielSourceType!=MaterielTypeEnum.åæå.ObjToInt()) |
| | | { |
| | | return content.Error($"èµ·ç¹é误{startPoint}"); |
| | | return content.Error($"æªæ¾å°ç©æ{materielInfo.MaterielCode}åæåä¿¡æ¯"); |
| | | } |
| | | //夿å½åç¹ä½æ¯å¦éå¤ |
| | | Dt_Task taskOldPoint = BaseDal.QueryFirst(x => x.SourceAddress == startPoint && (x.TaskStatus == TaskStatusEnum.New.ObjToInt() || x.TaskStatus == TaskStatusEnum.Line_Execute.ObjToInt() || x.TaskStatus == TaskStatusEnum.Line_Executing.ObjToInt())); |
| | | //if (taskOldPoint != null) |
| | | //{ |
| | | // return content.Error($"ç«ç¹{startPoint}å·²åå¨ä»»å¡"); |
| | | //} |
| | | Dt_Task taskOld = BaseDal.QueryFirst(x => x.PalletCode == barCode); |
| | | if (taskOld != null) |
| | | Dt_StockInfo stockInfoOld = _stockRepository.StockInfoRepository.QueryFirst(x => x.PalletCode == barcode); |
| | | if (stockInfoOld != null) |
| | | { |
| | | return content.Error($"è¶æ¡{barCode}ä»»å¡å·²åå¨"); |
| | | return content.Error("æçä¿¡æ¯å·²åå¨"); |
| | | } |
| | | //if (_stockRepository.ProStockInfoRepository.QueryFirst(x => x.PalletCode == barCode) != null) |
| | | //{ |
| | | // return content.Error($"è¶æ¡{barCode}åºåä¿¡æ¯å·²åå¨"); |
| | | //} |
| | | //todo:临æ¶è§£ç» |
| | | Dt_ProStockInfo proStockInfo = _stockRepository.ProStockInfoRepository.QueryFirst(x => x.PalletCode == barCode); |
| | | if (_stockRepository.ProStockInfoRepository.QueryFirst(x => x.PalletCode == barCode) != null) |
| | | //çæåºåç»çä¿¡æ¯ |
| | | Dt_StockInfo stockInfo = new Dt_StockInfo() |
| | | { |
| | | proStockInfo.PalletCode = proStockInfo.PalletCode + ":" + DateTime.Now.ToString("MM/dd"); |
| | | MaterielInvOrgId = materielInfo.MaterielInvOrgId, |
| | | PalletCode = barcode, |
| | | LocationCode = "", |
| | | PalletType = 1, |
| | | WarehouseId = warehouseId, |
| | | StockAttribute = materielInfo.MaterielSourceType, |
| | | StockStatus = StockStatusEmun.æå¨ç»çå
¥åºç¡®è®¤.ObjToInt(), |
| | | MaterielSpec = materielInfo.MaterielSpec, |
| | | Unit = materielInfo.MaterielUnit, |
| | | MaterielThickness = thickness, |
| | | MaterielWide = wide, |
| | | MaterielWeight = weight, |
| | | MaterielCode = materielInfo.MaterielCode, |
| | | MaterielName = materielInfo.MaterielName, |
| | | }; |
| | | if (wide > 1200) |
| | | { |
| | | stockInfo.PalletType = 2; |
| | | } |
| | | //è·åæåå¹³åº |
| | | Dt_Warehouse warehouse = _basicRepository.WarehouseRepository.QueryFirst(x => x.WarehouseCode == WarehouseEnum.HA101.ToString()); |
| | | |
| | | //çæå°å·åæåå
¥åºä»»å¡ |
| | | Dt_Task newTask = new Dt_Task() |
| | | { |
| | | CurrentAddress = startPoint, |
| | | CurrentAddress = address, |
| | | Grade = 0, |
| | | NextAddress = "", |
| | | PalletCode = barCode, |
| | | Roadway = "CL01_CP", |
| | | SourceAddress = startPoint, |
| | | PalletCode = barcode, |
| | | Roadway = "", |
| | | SourceAddress = address, |
| | | TargetAddress = "", |
| | | TaskType = TaskTypeEnum.EmptyProductBack.ObjToInt(), |
| | | TaskType = TaskTypeEnum.PrintYLInbound.ObjToInt(), |
| | | TaskStatus = TaskStatusEnum.New.ObjToInt(), |
| | | WarehouseId = warehouse.WarehouseId, |
| | | PalletType = 1 |
| | | WarehouseId = warehouseId, |
| | | PalletType = 1, |
| | | TaskLength = wide |
| | | }; |
| | | _unitOfWorkManage.BeginTran(); |
| | | int taskId = BaseDal.AddData(newTask); |
| | | if (proStockInfo!=null) |
| | | { |
| | | _stockRepository.ProStockInfoRepository.UpdateData(proStockInfo); |
| | | } |
| | | _stockRepository.StockInfoRepository.AddData(stockInfo); |
| | | newTask.TaskId = taskId; |
| | | _unitOfWorkManage.CommitTran(); |
| | | //æ¨éä»»å¡ |
| | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | content.Error(ex.Message); |
| | | } |
| | | return content; |