dengjunjie
6 天以前 4f39dcc195f28fa275fc2d065fbf1bf6a46c21b7
´úÂë¹ÜÀí/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/PartialTaskService_Inbound.cs
@@ -8,11 +8,23 @@
using WIDESEA_Core;
using WIDESEA_Model.Models;
using WIDESEA_Core.Helper;
using Microsoft.Extensions.Logging;
using System.Net.Http.Headers;
using System.Security.Policy;
using Newtonsoft.Json;
namespace WIDESEA_TaskInfoService
{
    public partial class TaskService
    {
        /// <summary>
        /// WCS IP地址
        /// </summary>
        public string url = AppSettings.Configuration["WCS"];
        /// <summary>
        /// AGV IP地址
        /// </summary>
        public string AGVurl = AppSettings.Configuration["AGV"];
        /// <summary>
        /// PDA申请入库--堆垛机立库入库
        /// </summary>
@@ -36,7 +48,7 @@
            {
                return WebResponseContent.Instance.Error("未找到该任务类型业务");
            }
            return WebResponseContent.Instance.Error("错误");
            return WebResponseContent.Instance.Error($"错误");
        }
        /// <summary>
@@ -56,7 +68,7 @@
            }
            catch (Exception ex)
            {
                content = WebResponseContent.Instance.Error(ex.Message);
                content = WebResponseContent.Instance.Error($"{ex.Message}");
            }
            return content;
        }
@@ -79,7 +91,7 @@
            }
            catch (Exception ex)
            {
                content = WebResponseContent.Instance.Error(ex.Message);
                content = WebResponseContent.Instance.Error($"{ex.Message}");
            }
            return content;
        }
@@ -99,13 +111,15 @@
            WebResponseContent content = new WebResponseContent();
            try
            {
                Dt_LocationInfo? locationInfo = _basicService.LocationInfoService.AssignLocation(stationCode, taskType);
                _unitOfWorkManage.BeginTran();
                Dt_LocationInfo? locationInfo = _basicService.LocationInfoService.AssignLocation(ref stationCode, taskType);
                if (locationInfo != null)
                {
                    List<Dt_Task> tasks = new List<Dt_Task>();
                    Dt_Task task = new()
                    {
                        CurrentAddress = stationCode,
                        Grade = 0,
                        Grade = 2,
                        PalletCode = palletCode,
                        NextAddress = locationInfo.LocationCode,
                        Roadway = locationInfo.RoadwayNo,
@@ -113,36 +127,65 @@
                        TargetAddress = locationInfo.LocationCode,
                        TaskStatus = InTaskStatusEnum.InNew.ObjToInt(),
                        TaskType = taskType,
                        Depth = locationInfo.Depth,
                    };
                    BaseDal.AddData(task);
                    int beforeStatus = locationInfo.LocationStatus;
                    locationInfo.LocationStatus = LocationStatusEnum.PalletLock.ObjToInt();
                    if (isUpdateStock)
                    {
                        locationInfo.LocationStatus = LocationStatusEnum.Lock.ObjToInt();
                        if (locationInfo.Depth == 2)
                        {
                            _basicService.LocationInfoService.UpdateLocationLock(locationInfo, task.TaskNum, StockChangeType.Inbound.ObjToInt(), false);
                        }
                        if (stockInfo != null && stockInfo.Details != null && stockInfo.Details.Count > 0)
                        {
                            orderNo = stockInfo.Details.FirstOrDefault()?.OrderNo ?? "";
                            stockInfo.StockStatus = StockStatusEmun.入库确认.ObjToInt();
                            stockInfo.Details.ForEach(x =>
                            {
                                x.Status = StockStatusEmun.入库确认.ObjToInt();
                            });
                            _stockService.StockInfoService.Repository.UpdateData(stockInfo);
                            _stockService.StockInfoDetailService.Repository.UpdateData(stockInfo.Details);
                        }
                        else
                        {
                            return content = WebResponseContent.Instance.Error("未找到库存信息");
                            return content.Error("未找到库存信息");
                        }
                    }
                    else
                    {
                        locationInfo.LocationStatus = LocationStatusEnum.PalletLock.ObjToInt();
                        if (locationInfo.Depth == 2)
                        {
                            _basicService.LocationInfoService.UpdateLocationLock(locationInfo, task.TaskNum, StockChangeType.Inbound.ObjToInt(), false);
                        }
                        task.Grade = 1;
                    }
                    _basicService.LocationInfoService.Repository.UpdateData(locationInfo);
                    tasks.Add(task);
                    _recordService.LocationStatusChangeRecordSetvice.AddLocationStatusChangeRecord(locationInfo, beforeStatus, StockChangeType.Inbound.ObjToInt(), orderNo, task.TaskNum);
                    return content = WebResponseContent.Instance.OK();
                    var response = HttpHelper.Post<WebResponseContent>(url + "ReceiveTask/", tasks, "入库任务下发");
                    if (!response.Status)
                    {
                        _unitOfWorkManage.RollbackTran();
                        return content.Error($"{response.Message}");
                    }
                    _unitOfWorkManage.CommitTran();
                    return content.OK();
                }
                return content = WebResponseContent.Instance.Error("未找到可分配货位");
                return content.Error("未找到可分配货位");
            }
            catch (Exception ex)
            {
                content = WebResponseContent.Instance.Error(ex.Message);
                _unitOfWorkManage.RollbackTran();
                content.Error(ex.Message);
            }
            return content;
        }
@@ -159,40 +202,43 @@
        {
            if (BaseDal.QueryFirst(x => x.PalletCode == palletCode) != null)
            {
                return (false, "该托盘号已有任务");
                return (false, "该托盘号已有任务!");
            }
            if (BaseDal.QueryFirst(x => (x.SourceAddress == stationCode || x.CurrentAddress == stationCode) && x.TaskStatus == InTaskStatusEnum.InNew.ObjToInt()) != null)
            Dt_RoadwayInfo roadwayInfo = _basicService.RoadwayInfoService.Repository.QueryFirst(x => x.InStationCode == stationCode) ?? throw new Exception("未找到该站台对应的巷道,请检查基础配置信息!");
            if (BaseDal.QueryFirst(x => (x.SourceAddress == roadwayInfo.InSCStationCode || x.CurrentAddress == roadwayInfo.InSCStationCode) && x.TaskStatus == InTaskStatusEnum.InNew.ObjToInt()) != null)
            {
                return (false, "当前入库站台已有一条新建任务");
                return (false, "当前入库站台已有一条新建任务!");
            }
            if (isCheckStock)
            {
                if (stockInfo == null)
                {
                    return (false, "未找到组盘信息");
                    return (false, "未找到组盘信息!");
                }
                if (stockInfo.StockStatus != StockStatusEmun.组盘暂存.ObjToInt())
                {
                    return (false, "该组盘状态不可入库");
                    return (false, "该组盘状态不可入库!");
                }
                if (!string.IsNullOrEmpty(stockInfo.LocationCode))
                {
                    return (false, "该托盘已绑定货位");
                    return (false, "该托盘已绑定货位!");
                }
                if (stockInfo.Details == null || stockInfo.Details.Count == 0)
                {
                    return (false, "没有库存明细信息");
                    return (false, "没有库存明细信息!");
                }
            }
            else
            {
                if (_stockService.StockInfoService.Repository.QueryFirst(x => x.PalletCode == palletCode) != null)
                {
                    return (false, "该托盘已存在库内");
                    return (false, "该托盘已存在库内!");
                }
            }
            return (true, "成功");
            return (true, "成功!");
        }