kazelee
2025-05-09 24180a4a19e29ad39ccf61f4b31f03d0f594c99c
抽检功能部分接口与后台功能开发,待完善测试
5个文件已添加
6个文件已修改
1个文件已删除
156 ■■■■■ 已修改文件
.vs/HH.WCS.Mobox3.DSZSH/FileContentIndex/6f64c2b7-09d5-4b3c-9a79-72745b90527c.vsidx 补丁 | 查看 | 原始文档 | blame | 历史
.vs/HH.WCS.Mobox3.DSZSH/FileContentIndex/9cdebdd3-1654-41dc-894c-c2dd9e6fc6e0.vsidx 补丁 | 查看 | 原始文档 | blame | 历史
.vs/HH.WCS.Mobox3.DSZSH/FileContentIndex/bed55563-1884-46d9-8f7f-fb19ae6beec5.vsidx 补丁 | 查看 | 原始文档 | blame | 历史
Consts/TaskName.cs 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Controllers/MoboxController.cs 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Dtos/Request/MoboxRequest.cs 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
HH.WCS.Mobox3.DSZSH.csproj 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
Models/TN_Check_Order.cs 25 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Models/TN_Order_Task.cs 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ServiceCore/CheckCore.cs 70 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Services/MoboxService.cs 24 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
config/config.json 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
.vs/HH.WCS.Mobox3.DSZSH/FileContentIndex/6f64c2b7-09d5-4b3c-9a79-72745b90527c.vsidx
Binary files differ
.vs/HH.WCS.Mobox3.DSZSH/FileContentIndex/9cdebdd3-1654-41dc-894c-c2dd9e6fc6e0.vsidx
Binary files differ
.vs/HH.WCS.Mobox3.DSZSH/FileContentIndex/bed55563-1884-46d9-8f7f-fb19ae6beec5.vsidx
Binary files differ
Consts/TaskName.cs
@@ -6,6 +6,7 @@
namespace HH.WCS.Mobox3.DSZSH.Consts {
    public class TaskName {
        public const string 抽检 = "抽检";
        public const string 好运箱_满箱下线入库 = "好运箱-满箱下线入库";
        public const string 好运箱_空箱上线 = "好运箱-空箱上线";
        public const string 好运箱_空箱入库 = "好运箱-空箱入库";
Controllers/MoboxController.cs
@@ -118,6 +118,16 @@
                return BuildSimpleResult(-1, $"不合法的容器类型:'{locCntrRel.S_CNTR_CODE}'");
            }
        }
        /// <summary>
        /// 创建抽检单(可能由PDA/WMS自行完成)
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public SimpleResult CreateCheckOrder(CreateCheckOrderInfo model) {
            return MoboxService.CreateCheckOrder(model);
        }
        #endregion
        #region Mobox 接口
Dtos/Request/MoboxRequest.cs
@@ -93,6 +93,14 @@
        }
        public class EmptyOnlineGoodpackInfo : StartCntEndInfo { }
        public class CreateCheckOrderInfo {
            public string CgId { get; set; }
            public string ItemName { get; set; }
            public string BatchNo { get; set; }
            public string Qty { get; set; }
            public string EndArea { get; set; }
        }
        #endregion
        #region WMS 数据
HH.WCS.Mobox3.DSZSH.csproj
@@ -237,10 +237,13 @@
    <Compile Include="Helpers\ResultHelper.cs" />
    <Compile Include="Helpers\DbHelper.cs" />
    <Compile Include="Models\DebugModel.cs" />
    <Compile Include="Models\TN_Check_Order.cs" />
    <Compile Include="Models\TN_Inbound_Order.cs" />
    <Compile Include="Models\TN_Order_Task.cs" />
    <Compile Include="Models\TN_Outbound_Order.cs" />
    <Compile Include="Models\TN_Outbound_Detail.cs" />
    <Compile Include="Models\TN_Outbound_Task.cs" />
    <Compile Include="ServiceCore\CheckCore.cs" />
    <Compile Include="ServiceCore\OutboundCore.cs" />
    <Compile Include="Services\DebugService.cs" />
    <Compile Include="Devices\BaseModbusDevice.cs" />
@@ -290,7 +293,6 @@
  <ItemGroup>
    <None Include=".editorconfig" />
    <None Include="App.config" />
    <None Include="config\config.comment.json" />
    <None Include="config\config.json">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </None>
Models/TN_Check_Order.cs
New file
@@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SqlSugar;
namespace HH.WCS.Mobox3.DSZSH.Models {
    /// <summary>
    /// 抽检单
    /// </summary>
    [SugarTable("TN_Check_Order")]
    public class TN_Check_Order : BaseModel {
        public string S_CG_ID { get; set; }
        public string S_ITEM_NAME { get; set; }
        public string S_BATCH_NO { get; set; }
        public int N_QTY { get; set; }
        public string S_END_AREA { get; set; }
        /// <summary>
        /// 抽检单状态:0未执行 1执行中 2完成
        /// </summary>
        public int N_B_STATE { get; set; } = 0;
    }
}
Models/TN_Order_Task.cs
New file
@@ -0,0 +1,11 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HH.WCS.Mobox3.DSZSH.Models {
    public class TN_Order_Task {
    }
}
ServiceCore/CheckCore.cs
New file
@@ -0,0 +1,70 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using HH.WCS.Mobox3.DSZSH.Consts;
using HH.WCS.Mobox3.DSZSH.Helpers;
using HH.WCS.Mobox3.DSZSH.Helpers.Model;
using HH.WCS.Mobox3.DSZSH.Models;
namespace HH.WCS.Mobox3.DSZSH.ServiceCore {
    /// <summary>
    /// 定时轮询任务:抽检业务核心
    /// </summary>
    public class CheckCore {
        /// <summary>
        /// 轮询查看抽检单是否有执行中的项目
        /// </summary>
        public void CheckOrderState() {
            var db = DbHelper.GetDbClient();
            try {
                var orderList = db.Queryable<TN_Check_Order>()
                    .Where(c => c.N_B_STATE == 0)
                    .OrderBy(c => c.T_CREATE).ToList();
                using (var tran = db.Ado.UseTran()) {
                    foreach (var order in orderList) {
                        var startLocList = db.Queryable<TN_Location, TN_Loc_Container, TN_CG_Detail>
                            ((l, c, d) => l.S_CODE == c.S_LOC_CODE && c.S_CNTR_CODE == d.S_CNTR_CODE)
                            .Where((l, c, d) => d.S_CG_ID == order.S_CG_ID && d.S_BATCH_NO == order.S_BATCH_NO)
                            .Select((l, c) => new { Location = l, Container = c })
                            .Take(order.N_QTY).ToList(); // 获取指定数量的货位数,随机抽取故无需排序
                        if (startLocList.Count < order.N_QTY) {
                            LogHelper.Info($"轮询 | 当前可抽检的物料数量 {startLocList.Count} 无法满足抽检单数量 {order.N_QTY} 要求");
                            return;
                        }
                        var endLocList = db.Queryable<TN_Location>()
                            .Where(l => l.S_AREA_CODE == order.S_END_AREA)
                            .Where(ExprHelper.LocIsFree)
                            .Where(ExprHelper.LocIsEmpty)
                            .Take(order.N_QTY).ToList(); // 获取指定数量的货位数
                        if (endLocList.Count < order.N_QTY) {
                            LogHelper.Info($"轮询 | 终点区域可用货位 {startLocList.Count} 无法满足抽检单数量 {order.N_QTY} 要求");
                            return;
                        }
                        // TODO 参考出库,如果要求任务顺序也要新创建表存储,有需求再更新
                        for (var i = 0; i < order.N_QTY; i++) {
                            if (!TaskHelper.LogCreateTask(startLocList[i].Location.S_CODE, startLocList[i].Container.S_CNTR_CODE,
                                endLocList[i].S_CODE, TaskName.抽检)) {
                                tran.RollbackTran();
                            }
                        }
                        order.N_B_STATE = 1;
                        db.Updateable<TN_Check_Order>(endLocList).UpdateColumns(c => c.N_B_STATE);
                        tran.CommitTran();
                    }
                }
            }
            catch (Exception ex) {
                LogHelper.InfoEx(ex);
            }
        }
    }
}
Services/MoboxService.cs
@@ -382,6 +382,30 @@
                return BuildSimpleEx(ex);
            }
        }
        public static SimpleResult CreateCheckOrder(CreateCheckOrderInfo model) {
            var db = DbHelper.GetDbClient();
            try {
                var order = new TN_Check_Order {
                    S_CG_ID = model.CgId,
                    S_ITEM_NAME = model.ItemName,
                    S_BATCH_NO = model.BatchNo,
                    N_QTY = model.Qty,
                    S_END_AREA = model.EndArea,
                };
                if (db.Insertable<TN_Check_Order>(order).ExecuteCommand() > 0) {
                    return BuildSimpleResult(0, "插入抽检单成功:" + JsonConvert.SerializeObject(order));
                }
                else {
                    return BuildSimpleResult(2, "插入抽检单失败:" + JsonConvert.SerializeObject(order));
                }
            }
            catch (Exception ex) {
                return BuildSimpleEx(ex);
            }
        }
        #endregion
        #region Mobox 功能
config/config.json
@@ -98,6 +98,9 @@
            "EndAreas": [ "HJQ1" ]
        },
        {
            "Name": "抽检"
        }
        {
            "Name": "成品胶出库"
        },
        {