1
647556386
2025-12-17 7a096b516a913c1be1b0b879553330537a3e464e
1
已添加3个文件
已修改4个文件
468 ■■■■■ 文件已修改
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_Common/OrderEnum/TakeStockStatusEnum.cs 68 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_Core/CodeConfigEnum/RuleCodeEnum.cs 9 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_ITaskInfoService/ITaskService.cs 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_Model/Models/Inbound/Dt_TakeStockOrder.cs 62 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_Model/Models/Inbound/Dt_TakeStockOrderDetail.cs 125 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_Outbound.cs 185 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/TaskInfo/TaskController.cs 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ÏîÄ¿´úÂë/WMSÎÞ²Ö´¢°æ/WIDESEA_WMSServer/WIDESEA_Common/OrderEnum/TakeStockStatusEnum.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,68 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace WIDESEA_Common.OrderEnum
{
    /// <summary>
    /// ç›˜ç‚¹çŠ¶æ€
    /// </summary>
    public enum TakeStockStatusEnum
    {
        /// <summary>
        /// æœªç›˜ç‚¹
        /// </summary>
        [Description("未盘点")]
        æœªç›˜ç‚¹ = 0,
        /// <summary>
        /// ç›˜ç‚¹ä¸­
        /// </summary>
        [Description("盘点中")]
        ç›˜ç‚¹ä¸­ = 1,
        /// <summary>
        /// ç›˜ç‚¹å®Œæˆ
        /// </summary>
        [Description("盘点完成")]
        ç›˜ç‚¹å®Œæˆ = 2,
        /// <summary>
        /// ç›˜ç‚¹å…³é—­
        /// </summary>
        [Description("盘点关闭")]
        ç›˜ç‚¹å…³é—­ = 3,
    }
    /// <summary>
    /// ç›˜ç‚¹æ˜Žç»†çŠ¶æ€
    /// </summary>
    public enum TakeStockDetailStatusEnum
    {
        /// <summary>
        /// æœªç›˜ç‚¹
        /// </summary>
        [Description("未盘点")]
        æœªç›˜ç‚¹ = 0,
        /// <summary>
        /// ç›˜ç‚¹ä¸­
        /// </summary>
        [Description("盘点出库中")]
        ç›˜ç‚¹å‡ºåº“中 = 1,
        /// <summary>
        /// ç›˜ç‚¹å‡ºåº“完成
        /// </summary>
        [Description("盘点出库完成")]
        ç›˜ç‚¹å‡ºåº“完成 = 2,
        /// <summary>
        /// ç›˜ç‚¹å®Œæˆ
        /// </summary>
        [Description("盘点完成")]
        ç›˜ç‚¹å®Œæˆ = 3
    }
}
ÏîÄ¿´úÂë/WMSÎÞ²Ö´¢°æ/WIDESEA_WMSServer/WIDESEA_Core/CodeConfigEnum/RuleCodeEnum.cs
@@ -51,6 +51,13 @@
        [Description("调拨单号编码规则")]
        AllocateOrderCodeRule,
        NewBarcodeRule
        NewBarcodeRule,
        /// <summary>
        /// ç›˜ç‚¹å•号编码规则
        /// </summary>
        [Description("盘点单号编码规则")]
        PDCodeRule
    }
}
ÏîÄ¿´úÂë/WMSÎÞ²Ö´¢°æ/WIDESEA_WMSServer/WIDESEA_ITaskInfoService/ITaskService.cs
@@ -54,5 +54,12 @@
        Task<WebResponseContent> GenerateOutboundBatchTasksAsync(int orderDetailId, decimal batchQuantity, string outStation);
        Task<WebResponseContent> GenerateAllocatOutboundTask(int orderDetailId, List<StockSelectViewDTO> stockSelectViews, string station);
        /// <summary>
        /// åº“存盘点
        /// </summary>
        /// <param name="stockViews"></param>
        /// <returns></returns>
       Task <WebResponseContent> TakeOutbound(List<StockViewDTO> stockViews,string outStation);
    }
}
ÏîÄ¿´úÂë/WMSÎÞ²Ö´¢°æ/WIDESEA_WMSServer/WIDESEA_Model/Models/Inbound/Dt_TakeStockOrder.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,62 @@
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WIDESEA_Core.Attributes;
using WIDESEA_Core.CodeConfigEnum;
using WIDESEA_Core.DB.Models;
using WIDESEA_Core.Enums;
namespace WIDESEA_Model.Models
{
    /// <summary>
    /// ç›˜ç‚¹å•
    /// </summary>
    [SugarTable(nameof(Dt_TakeStockOrder), "盘点单")]
    public class Dt_TakeStockOrder : BaseEntity
    {
        /// <summary>
        /// ä¸»é”®
        /// </summary>
        [SugarColumn(IsPrimaryKey = true, IsIdentity = true, ColumnDescription = "主键")]
        public int Id { get; set; }
        /// <summary>
        /// ç›˜ç‚¹å•号
        /// </summary>
        [SugarColumn(IsNullable = false, Length = 50, ColumnDescription = "盘点单号")]
        public string OrderNo { get; set; }
        /// <summary>
        /// ä»“库主键
        /// </summary>
        [SugarColumn(IsNullable = false, ColumnDescription = "所属仓库")]
        public int WarehouseId { get; set; }
        /// <summary>
        /// ç›˜ç‚¹çŠ¶æ€
        /// </summary>
        [SugarColumn(IsNullable = false, ColumnDescription = "盘点状态")]
        public int TakeStockStatus { get; set; }
        /// <summary>
        /// å¤‡æ³¨
        /// </summary>
        [SugarColumn(IsNullable = true, Length = 500, ColumnDescription = "备注")]
        public string Remark { get; set; }
        /// <summary>
        /// å¤‡æ³¨
        /// </summary>
        [SugarColumn(IsNullable = true, Length = 500, ColumnDescription = "所含盘点托盘")]
        public string AllPalletCode { get; set; }
        /// <summary>
        /// ç›˜ç‚¹æ˜Žç»†
        /// </summary>
        [PropertyValidate("盘点明细", NotNullAndEmpty = true), Navigate(NavigateType.OneToMany, nameof(Dt_TakeStockOrderDetail.TakeStockId), nameof(Id))]
        public List<Dt_TakeStockOrderDetail> Details { get; set; }
    }
}
ÏîÄ¿´úÂë/WMSÎÞ²Ö´¢°æ/WIDESEA_WMSServer/WIDESEA_Model/Models/Inbound/Dt_TakeStockOrderDetail.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,125 @@
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WIDESEA_Core.DB.Models;
namespace WIDESEA_Model.Models
{
    /// <summary>
    /// ç›˜ç‚¹å•明细
    /// </summary>
    [SugarTable(nameof(Dt_TakeStockOrderDetail), "盘点单明细")]
    public class Dt_TakeStockOrderDetail : BaseEntity
    {
        /// <summary>
        /// ä¸»é”®
        /// </summary>
        [SugarColumn(IsPrimaryKey = true, IsIdentity = true, ColumnDescription = "主键")]
        public int Id { get; set; }
        /// <summary>
        /// ç›˜ç‚¹å•主键
        /// </summary>
        [SugarColumn(IsNullable = false, ColumnDescription = "盘点单主键")]
        public int TakeStockId { get; set; }
        /// <summary>
        /// ç‰©æ–™ç¼–码
        /// </summary>
        [SugarColumn(IsNullable = false, Length = 50, ColumnDescription = "物料编码")]
        public string MaterielCode { get; set; }
        /// <summary>
        /// ç‰©æ–™åç§°
        /// </summary>
        [SugarColumn(IsNullable = false, Length = 200, ColumnDescription = "物料名称")]
        public string MaterielName { get; set; }
        /// <summary>
        /// æ‰¹æ¬¡å·
        /// </summary>
        [SugarColumn(IsNullable = false, Length = 50, ColumnDescription = "批次号")]
        public string BatchNo { get; set; }
        /// <summary>
        /// ç‰©æ–™è§„æ ¼
        /// </summary>
        [SugarColumn(IsNullable = true, Length = 200, ColumnDescription = "物料规格")]
        public string MaterielSpec { get; set; }
        /// <summary>
        /// åŽŸä»“ä½
        /// </summary>
        [SugarColumn(IsNullable = true, Length = 50, ColumnDescription = "原仓位")]
        public string LocationCode { get; set; }
        /// <summary>
        /// ç›˜ç‚¹æ‰˜ç›˜
        /// </summary>
        [SugarColumn(IsNullable = true, Length = 50, ColumnDescription = "盘点托盘")]
        public string TakePalletCode { get; set; }
        /// <summary>
        /// ç›˜ç‚¹æ˜Žç»†çŠ¶æ€
        /// </summary>
        [SugarColumn(IsNullable = true, ColumnDescription = "盘点明细状态")]
        public int TakeDetalStatus { get; set; }
        /// <summary>
        /// å•位
        /// </summary>
        [SugarColumn(IsNullable = true, Length = 50, ColumnDescription = "单位")]
        public string Unit { get; set; }
        /// <summary>
        /// è´¦é¢æ•°é‡
        /// </summary>
        [SugarColumn(IsNullable = true, ColumnDescription = "账面数量")]
        public decimal SysQty { get; set; }
        /// <summary>
        /// å®žç›˜æ•°é‡
        /// </summary>
        [SugarColumn(IsNullable = true, ColumnDescription = "实盘数量")]
        public decimal Qty { get; set; }
        /// <summary>
        /// å¤‡æ³¨
        /// </summary>
        [SugarColumn(IsNullable = true, Length = 500, ColumnDescription = "备注")]
        public string Remark { get; set; }
        /// <summary>
        /// æ¡ç 
        /// </summary>
        [SugarColumn(IsNullable = true, Length = 50, ColumnDescription = "条码")]
        public string barcode { get; set; }
        /// <summary>
        /// ç‰©æ–™ä»“库
        /// </summary>
        [SugarColumn(IsNullable = true, Length = 20, ColumnDescription = "物料仓库")]
        public string WarehouseCode { get; set; }
        /// <summary>
        /// åŽ‚åŒº
        /// </summary>
        [SugarColumn(IsNullable = true, Length = 10, ColumnDescription = "厂区")]
        public string FactoryArea { get; set; }
        /// <summary>
        /// ä¾›åº”商编号
        /// </summary>
        [SugarColumn(IsNullable = true, Length = 20, ColumnDescription = "供应商编号")]
        public string SupplyCode { get; set; }
        /// <summary>
        /// ç›˜ç‚¹å•单据
        /// </summary>
        [SugarColumn(IsNullable = true, Length = 50, ColumnDescription = "盘点单单据")]
        public string TakeStockNo { get; set; }
    }
}
ÏîÄ¿´úÂë/WMSÎÞ²Ö´¢°æ/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_Outbound.cs
@@ -2,6 +2,7 @@
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using OfficeOpenXml.FormulaParsing.Excel.Functions.RefAndLookup;
using SqlSugar;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
@@ -16,9 +17,13 @@
using WIDESEA_Common.StockEnum;
using WIDESEA_Common.TaskEnum;
using WIDESEA_Core;
using WIDESEA_Core.CodeConfigEnum;
using WIDESEA_Core.DB;
using WIDESEA_Core.Helper;
using WIDESEA_Core.Seed;
using WIDESEA_DTO.Basic;
using WIDESEA_DTO.Stock;
using WIDESEA_IBasicService;
using WIDESEA_Model.Models;
using WIDESEA_Model.Models.Basic;
using WIDESEA_Model.Models.Check;
@@ -1098,6 +1103,186 @@
        #endregion
        /// <summary>
        /// é€‰å®šåº“存生成盘点单出库
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public async Task<WebResponseContent> TakeOutbound(List<StockViewDTO> stockViews, string outStation)
        {
            WebResponseContent content = new WebResponseContent();
            try
            {
                List<int> ids = stockViews.Select(x => x.StockId).ToList();
                //获取库存
                List<Dt_StockInfo> stockInfos = _stockRepository.Db.Queryable<Dt_StockInfo>().Where(x => ids.Contains(x.Id)).Includes(x => x.Details).ToList();
                if (stockInfos.Count != stockViews.Count)
                {
                    StockViewDTO? stockViewDTO = stockViews.FirstOrDefault(x => !stockInfos.Select(x => x.PalletCode).ToList().Contains(x.PalletCode));
                    return content.Error($"未找到{stockViewDTO?.PalletCode}库存");
                }
                //获取货位
                List<string> locStrs = stockInfos.Select(x => x.LocationCode).ToList();
                List<Dt_LocationInfo> locationInfos = (List<Dt_LocationInfo>)_locationInfoService.Db.Queryable<Dt_LocationInfo>().Where(x => locStrs.Contains(x.LocationCode));
                if (stockInfos.Count != locationInfos.Count)
                {
                    string? locStr = locStrs.FirstOrDefault(x => !locationInfos.Select(x => x.LocationCode).ToList().Contains(x));
                    return content.Error($"未找到{locStr}货位数据");
                }
                Dt_TakeStockOrder takeStockOrder = new Dt_TakeStockOrder()
                {
                    WarehouseId = stockInfos.FirstOrDefault().WarehouseId,
                    TakeStockStatus = TakeStockStatusEnum.盘点中.ObjToInt(),
                    OrderNo = CreateCodeByRule(nameof(RuleCodeEnum.PDCodeRule)),
                    Details = new List<Dt_TakeStockOrderDetail>()
                };
                foreach (var item in stockInfos)
                {
                    if (item.Details.Count <= 0)
                    {
                        return content.Error($"未找到{item.PalletCode}库存明细数据");
                    }
                    Dt_LocationInfo? locationInfo = locationInfos.FirstOrDefault(x => x.LocationCode == item.LocationCode);
                    if (locationInfo == null && (locationInfo.EnableStatus == EnableStatusEnum.Disable.ObjToInt() || locationInfo.EnableStatus != EnableStatusEnum.Normal.ObjToInt()) && locationInfo.LocationStatus != LocationStatusEnum.InStock.ObjToInt() && item.StockStatus != StockStatusEmun.入库完成.ObjToInt())
                    {
                        content.Error($"{item.PalletCode}货位或库存状态不满足出库条件");
                    }
                }
                List<Dt_Task> tasks = GetTasks(stockInfos, TaskTypeEnum.OutInventory,outStation);
                if (tasks == null || tasks.Count <= 0)
                {
                    return content.Error($"生成任务失败");
                }
                stockInfos.ForEach(x =>
                {
                    x.StockStatus = StockStatusEmun.出库锁定.ObjToInt();
                });
                tasks.ForEach(x =>
                {
                    x.OrderNo = takeStockOrder.OrderNo;
                });
                locationInfos.ForEach(x =>
                {
                    x.LocationStatus = LocationStatusEnum.Lock.ObjToInt();
                });
                _unitOfWorkManage.BeginTran();
                //更新库存状态
                _stockRepository.UpdateData(stockInfos);
                BaseDal.Db.InsertNav(takeStockOrder);
                //新建任务
                BaseDal.AddData(tasks);
                _locationInfoService.UpdateData(locationInfos);
                _unitOfWorkManage.CommitTran();
                TaskModel esstask = new TaskModel()
                {
                    taskType = "carry",
                    taskGroupCode = "",
                    groupPriority = 0,
                    tasks = new List<TasksType>()
                };
                foreach (var task in tasks)
                {
                    esstask.
                       tasks.Add(new TasksType
                       {
                           taskCode = task.TaskNum.ToString(),
                           taskPriority = 0,
                           taskDescribe = new TaskDescribeType
                           {
                               containerCode = task.PalletCode,
                               containerType = "CT_KUBOT_STANDARD",
                               fromLocationCode = task.SourceAddress ?? "",
                               toStationCode = "",
                               toLocationCode = task.TargetAddress,
                               deadline = 0,
                               storageTag = ""
                           }
                       }
                   );
                }
                var result = await _eSSApiService.CreateTaskAsync(esstask);
                _logger.LogInformation("创建任务PalletOutboundTask è¿”回:  " + result);
                if (result)
                {
                    return WebResponseContent.Instance.OK();
                }
                else
                {
                    return WebResponseContent.Instance.Error("下发机器人任务失败!");
                }
                content.OK();
            }
            catch (Exception ex)
            {
                _unitOfWorkManage.RollbackTran();
                content.Error(ex.Message);
            }
            return content;
        }
        /// <summary>
        /// å•据生成方法
        /// </summary>
        static object lock_code = new object();
        public string CreateCodeByRule(string ruleCode)
        {
            lock (lock_code)
            {
                string code = string.Empty;
                DateTime dateTime = DateTime.Now;
                DateTime now = DateTime.Now;
                try
                {
                    if (string.IsNullOrEmpty(ruleCode))
                        throw new ArgumentNullException(nameof(ruleCode));
                    SqlSugarClient sugarClient = new SqlSugarClient(new ConnectionConfig
                    {
                        IsAutoCloseConnection = true,
                        DbType = DbType.SqlServer,
                        ConnectionString = DBContext.ConnectionString
                    });
                    Dt_CodeRuleConfig codeRuleConfig = sugarClient.Queryable<Dt_CodeRuleConfig>().Where(x => x.RuleCode == ruleCode).First();
                    if (codeRuleConfig == null)
                        throw new ArgumentNullException(nameof(codeRuleConfig));
                    if (codeRuleConfig.ModifyDate != null)
                    {
                        dateTime = Convert.ToDateTime(codeRuleConfig.ModifyDate);
                    }
                    else
                    {
                        dateTime = Convert.ToDateTime(codeRuleConfig.CreateDate);
                    }
                    if (now.Year == dateTime.Year && now.Month == dateTime.Month && now.Day == dateTime.Day)
                    {
                        now = dateTime;
                        codeRuleConfig.CurrentVal = Convert.ToInt32(codeRuleConfig.CurrentVal) + 1;
                    }
                    else
                    {
                        codeRuleConfig.CurrentVal = 1;
                    }
                    codeRuleConfig.ModifyDate = DateTime.Now;
                    code = codeRuleConfig.StartStr + codeRuleConfig.Format;
                    code = code.Replace($"[{CodeFormatTypeEnum.YYYY}]", now.Year.ToString().PadLeft(4, '0'));
                    code = code.Replace($"[{CodeFormatTypeEnum.MM}]", now.Month.ToString().PadLeft(2, '0'));
                    code = code.Replace($"[{CodeFormatTypeEnum.DD}]", now.Day.ToString().PadLeft(2, '0'));
                    code = code.Replace($"[{CodeFormatTypeEnum.ST}]", codeRuleConfig.StartStr?.ToString() ?? "");
                    code = code.Replace($"[{CodeFormatTypeEnum.NUM}]", codeRuleConfig.CurrentVal.ToString().PadLeft(codeRuleConfig.Length, '0'));
                    Dictionary<string, object> keyValuePairs = new Dictionary<string, object>() { { nameof(codeRuleConfig.CurrentVal), codeRuleConfig.CurrentVal }, { nameof(codeRuleConfig.Id), codeRuleConfig.Id }, { nameof(codeRuleConfig.ModifyDate), DateTime.Now } };
                    sugarClient.Updateable(keyValuePairs).AS(MainDb.CodeRuleConfig).WhereColumns(nameof(codeRuleConfig.Id)).ExecuteCommand();
                    sugarClient.Updateable(codeRuleConfig);
    }
                catch (Exception ex)
                {
                }
                return code;
            }
        }
    }
}
ÏîÄ¿´úÂë/WMSÎÞ²Ö´¢°æ/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/TaskInfo/TaskController.cs
@@ -108,6 +108,18 @@
            return await Service.GenerateOutboundBatchTasksAsync(data.orderDetailId,data.batchQuantity, data.outboundPlatform);
        }
        /// <summary>
        /// ç›˜ç‚¹åº“存出库
        /// </summary>
        /// <param name="stockViews"></param>
        /// <param name="outStation"></param>
        /// <returns></returns>
        [HttpPost, HttpGet, Route("TakeOutbound"), AllowAnonymous]
        public async Task<WebResponseContent> TakeOutbound([FromBody] List<StockViewDTO> stockViews, string outStation)
        {
            return await Service.TakeOutbound(stockViews, outStation);
        }
        
    }
}