| | |
| | | using WIDESEA_Core; |
| | | using WIDESEA_Model.Models; |
| | | using WIDESEAWCS_DTO.WCSInfo; |
| | | using WIDESEA_DTO.WCSInfo; |
| | | |
| | | namespace WIDESEA_TaskInfoService |
| | | { |
| | |
| | | { |
| | | string ConveyorLineID = AppSettings.Configuration[nameof(ConveyorLineID)]; |
| | | if (!ConveyorLineID.Split(",").Contains(lineDTO.stationCode)) throw new Exception($"æªæ¾å°è¾é线ç¼å·[{lineDTO.stationCode}]çä¿¡æ¯"); |
| | | switch (lineDTO.stationCode) |
| | | { |
| | | case "102": |
| | | content = TransmissionlineRequest(lineDTO); |
| | | break; |
| | | case "1001": |
| | | content = ProductionlineRequest(lineDTO); |
| | | break; |
| | | } |
| | | content = TransmissionlineRequest(lineDTO); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | |
| | | //{ |
| | | // throw new Exception($"å½åå
¥åºç«å°[{lineDTO.stationCode}]å·²æä¸æ¡ä»»å¡"); |
| | | //} |
| | | var task = BaseDal.QueryFirst(x => x.PalletCode == lineDTO.Barcode && x.TaskType == TaskTypeEnum.Inbound.ObjToInt()); |
| | | var task = BaseDal.QueryFirst(x => x.PalletCode == lineDTO.Barcode); |
| | | if (task == null) throw new Exception($"æªæ¾å°æçå·[{lineDTO.Barcode}]çå
¥åºä»»å¡"); |
| | | if (task.TaskType == TaskTypeEnum.PalletInbound.ObjToInt()) |
| | | { |
| | | task.NextAddress = "1004"; |
| | | task.CurrentAddress = lineDTO.stationCode; |
| | | task.TaskState = (int)InTaskStatusEnum.Line_InExecuting; |
| | | BaseDal.UpdateData(task); |
| | | return content; |
| | | } |
| | | if (task.TaskType != TaskTypeEnum.Inbound.ObjToInt()) throw new Exception($"æªæ¾å°æçå·[{lineDTO.Barcode}]çå
¥åºä»»å¡"); |
| | | |
| | | //if (task.TaskState != (int)InTaskStatusEnum.AGV_InFinish) throw new Exception($"æçå·[{lineDTO.Barcode}]çå
¥åºä»»å¡ç¶æä¸å¹é
"); |
| | | |
| | | Dt_StockInfo stockInfo = _stockService.StockInfoService.Repository.GetStockInfo(lineDTO.Barcode); |
| | | (bool, string) result = CheckRequestInbound(lineDTO.stationCode, lineDTO.Barcode, true, stockInfo); |
| | | if (!result.Item1) return content = WebResponseContent.Instance.Error(result.Item2); |
| | | |
| | | Dt_StockInfoDetail stockInfoDetail = stockInfo.Details.FirstOrDefault(); |
| | | Dt_StockInfoDetail? stockInfoDetail = stockInfo.Details.FirstOrDefault(); |
| | | |
| | | if (lineDTO.Spec != 1 || lineDTO.Weight != 500)//æ£æµæ¡ä»¶éæ´æ¹ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ |
| | | if (/*lineDTO.Spec != 1 ||*/ lineDTO.Weight > 1500)//æ£æµæ¡ä»¶éæ´æ¹ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ |
| | | { |
| | | task.NextAddress = "101"; |
| | | task.TaskState = (int)InTaskStatusEnum.InException; |
| | | task.Remark = $"æç[{lineDTO.Barcode}]ä¿¡æ¯ä¸åæ ¼"; |
| | | //task.NextAddress = "101"; |
| | | //task.TaskState = (int)InTaskStatusEnum.InException; |
| | | task.Remark = $"æç[{lineDTO.Barcode}]è¶
é"; |
| | | //task.Remark = $"æç[{lineDTO.Barcode}]ä¿¡æ¯ä¸åæ ¼"; |
| | | //stockInfo.StockStatus = StockStatusEmun.å
¥åºæ¤é.ObjToInt(); |
| | | } |
| | | else |
| | | { |
| | | task.NextAddress = "104"; |
| | | task.NextAddress = "1004"; |
| | | task.CurrentAddress = lineDTO.stationCode; |
| | | task.Remark=string.Empty; |
| | | task.Remark = string.Empty; |
| | | task.TaskState = (int)InTaskStatusEnum.Line_InExecuting; |
| | | stockInfo.StockStatus = StockStatusEmun.å
¥åºç¡®è®¤.ObjToInt(); |
| | | stockInfoDetail.Status = StockStatusEmun.å
¥åºç¡®è®¤.ObjToInt(); |
| | | if (stockInfoDetail != null) stockInfoDetail.Status = StockStatusEmun.å
¥åºç¡®è®¤.ObjToInt(); |
| | | } |
| | | |
| | | #region äºå¡ |
| | | Db.Ado.BeginTran(); |
| | | BaseDal.UpdateData(task); |
| | | _stockService.StockInfoService.Repository.UpdateData(stockInfo); |
| | | _stockService.StockInfoDetailService.Repository.UpdateData(stockInfoDetail); |
| | | if (stockInfoDetail != null) _stockService.StockInfoDetailService.Repository.UpdateData(stockInfoDetail); |
| | | //Db.Updateable(stockInfo).ExecuteCommand(); |
| | | Db.Ado.CommitTran(); |
| | | #endregion |
| | | if (!string.IsNullOrEmpty(task.Remark)) throw new Exception(task.Remark); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | Db.Ado.RollbackTran(); |
| | | content.Error(ex.Message); |
| | | } |
| | | return content; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 产线ç³è¯· |
| | | /// </summary> |
| | | /// <param name="lineDTO"></param> |
| | | /// <returns></returns> |
| | | public WebResponseContent ProductionlineRequest(ConveyorLineDTO lineDTO) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | var task = BaseDal.QueryFirst(x => x.PalletCode == lineDTO.Barcode); |
| | | if (task != null && task.TaskType == TaskTypeEnum.Inbound.ObjToInt()) |
| | | return content.OK(data: task); |
| | | if (task != null) throw new Exception($"æçå·[{lineDTO.Barcode}]å·²åå¨ä»»å¡"); |
| | | Dt_StockInfo stockInfo = _stockService.StockInfoService.Repository.GetStockInfo(lineDTO.Barcode); |
| | | (bool, string) result = CheckRequestInbound(lineDTO.stationCode, lineDTO.Barcode, true, stockInfo); |
| | | if (!result.Item1) return content = WebResponseContent.Instance.Error(result.Item2); |
| | | var StockInfoDetails = stockInfo.Details.Where(x => x.StockId == stockInfo.Id).ToList(); |
| | | #region çæå
¥åºä»»å¡ |
| | | Dt_Task dt_Task = new Dt_Task() |
| | | { |
| | | CurrentAddress = lineDTO.stationCode, |
| | | NextAddress = "SC01", |
| | | SourceAddress = lineDTO.stationCode, |
| | | TargetAddress = "SC01", |
| | | CreateDate = DateTime.Now, |
| | | Creater = "System", |
| | | PalletCode = lineDTO.Barcode, |
| | | OrderNo = StockInfoDetails.Count() == 1 ? StockInfoDetails.First().OrderNo : null, |
| | | Roadway = "SC01", |
| | | TaskNum = Convert.ToInt32(DateTime.Now.ToString("HHmmss")), |
| | | TaskState = InTaskStatusEnum.InNew.ObjToInt(), |
| | | TaskType = TaskTypeEnum.Inbound.ObjToInt(), |
| | | }; |
| | | dt_Task.Dispatchertime = dt_Task.CreateDate; |
| | | Db.Ado.BeginTran(); |
| | | BaseDal.AddData(dt_Task); |
| | | task = BaseDal.QueryFirst(x => x.PalletCode == lineDTO.Barcode && x.TaskType == TaskTypeEnum.Inbound.ObjToInt()); |
| | | //content.Data = dt_Task; |
| | | Db.Ado.CommitTran(); |
| | | if (task != null) return content.OK(data: task); |
| | | #endregion |
| | | } |
| | | catch (Exception ex) |
| | | { |