ÏîÄ¿´úÂë/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/PartialTaskService_ConveyorLine.cs
@@ -8,6 +8,7 @@
using WIDESEA_Core;
using WIDESEA_Model.Models;
using WIDESEAWCS_DTO.WCSInfo;
using WIDESEA_DTO.WCSInfo;
namespace WIDESEA_TaskInfoService
{
@@ -25,15 +26,22 @@
            {
                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);
                //switch (lineDTO.stationCode)
                //{
                //    case "102":
                //        content = TransmissionlineRequest(lineDTO);
                //        break;
                //    case "Z1":
                //    case "Z2":
                //    case "Z3":
                //    case "X1":
                //    case "X2":
                //    case "X3":
                //        content = ProductionlineRequest(lineDTO);
                //        break;
                //    default: throw new Exception("未定义站台:" + lineDTO.stationCode);
                //}
            }
            catch (Exception ex)
            {
@@ -97,7 +105,7 @@
        /// <returns></returns>
        public WebResponseContent TransmissionlineRequest(ConveyorLineDTO lineDTO)
        {
            WebResponseContent content = new WebResponseContent();
            WebResponseContent content = new WebResponseContent().OK();
            try
            {
                //if (BaseDal.QueryFirst(x => (x.SourceAddress == lineDTO.stationCode || x.CurrentAddress == lineDTO.stationCode) && x.TaskStatus == InTaskStatusEnum.AGV_InFinish.ObjToInt()) != null)
@@ -106,85 +114,40 @@
                //}
                var task = BaseDal.QueryFirst(x => x.PalletCode == lineDTO.Barcode && x.TaskType == TaskTypeEnum.Inbound.ObjToInt());
                if (task == null) throw new Exception($"未找到托盘号[{lineDTO.Barcode}]的入库任务");
                if (task.TaskState != (int)InTaskStatusEnum.AGV_InFinish) 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();
                if (lineDTO.Spec != 1 || lineDTO.Weight != 500)//检测条件需更改!!!!!!!!!!
                {
                    task.NextAddress = "101";
                    task.TaskState = (int)InTaskStatusEnum.InException;
                    task.Remark = $"托盘[{lineDTO.Barcode}]信息不合格";
                    stockInfo.StockStatus = StockStatusEmun.入库撤销.ObjToInt();
                    //stockInfo.StockStatus = StockStatusEmun.入库撤销.ObjToInt();
                }
                else
                {
                    task.NextAddress = "104";
                    task.CurrentAddress = lineDTO.stationCode;
                    task.Remark = string.Empty;
                    task.TaskState = (int)InTaskStatusEnum.Line_InExecuting;
                    stockInfo.StockStatus = StockStatusEmun.入库确认.ObjToInt();
                    stockInfoDetail.Status = StockStatusEmun.入库确认.ObjToInt();
                }
                #region äº‹åŠ¡
                Db.Ado.BeginTran();
                BaseDal.UpdateData(task);
                Db.Updateable(stockInfo);
                _stockService.StockInfoService.Repository.UpdateData(stockInfo);
                _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 = DateTime.Now;
                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)
            {