服务端的TigerApi 框架,基于.NET6 2024 版本
Ben Lin
2025-02-13 c6494a547258df9180f181dc00d6e4dd1633ec36
更新数据库配置和出货逻辑

在 `BizSettings.json` 文件中:
* 修改 `Databases` 配置:
* 将 `Main` 数据库的 `DbType` 从 `SqlServer` 改为 `MySql`,并更新 `ConnectionString`。
* 更新 `YadaU9C` 数据库的 `ConnectionString`。
* 修改 `IsUseDbCache` 配置,从 `true` 改为 `false`。

在 `YadaPacking.cs` 文件中:
* 在 `namespace Tiger.Business.MES.Transaction` 中:
* 在 `action.CatchExceptionWithLog` 后添加 `debug.Log` 调试日志。
* 修改获取出货状态的逻辑:
* 注释掉原查询语句,改为获取所有相关出货记录,并根据状态和日期筛选。
* 增加旧出货量和待出货箱数的计算。
* 更新 `IsPrintCustomerLabel` 的判断逻辑。
* 将旧出货量缓存到 `Context` 中。
* 在 `ShipingInfo` 中增加 `OldShipQty` 属性,并更新 `ShipQty` 的计算逻辑。

在 `PositionParameter.cs` 文件中:
* 在 `ShipingInfo` 类中增加 `OldShipQty` 属性。
已修改2个文件
20 ■■■■ 文件已修改
Tiger.Business.MES/Transaction/YadaPacking.cs 19 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Model.Net/Entitys/MES/ParameterEntity/PositionParameter.cs 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Business.MES/Transaction/YadaPacking.cs
@@ -302,7 +302,7 @@
                ResetNode();
                //action.CatchExceptionWithLog(ex, $"包装工序:提交操作数据异常");
                action.CatchExceptionWithLog(ex, Biz.L("MES.Transaction.PackingNode.SubmitException"));
            }
            debug.Log(new StackFrame(true), "***** 9", info => { ConsoleExt.WriteLine(info.ToString()); });
            return SetOutPutMqttMsg(action, input.Locale);
@@ -403,10 +403,15 @@
                    debug.Log(new StackFrame(true), "***** 11", info => { ConsoleExt.WriteLine(info.ToString()); });
                    //获取出货状态
                    var ship = U9CDB.Queryable<mes_ShipList>().Where(q => q.MoDoc == CurBatch.WO.ORDER_NO && q.Status == 2 && SqlFunc.DateIsSame(q.BusinessDate, DateTime.Now)).First();
                    //var ship = U9CDB.Queryable<mes_ShipList>().Where(q => q.MoDoc == CurBatch.WO.ORDER_NO && q.Status == 2 && SqlFunc.DateIsSame(q.BusinessDate, DateTime.Now)).First();
                    var ships = U9CDB.Queryable<mes_ShipList>().Where(q => q.MoDoc == CurBatch.WO.ORDER_NO).ToList();
                    var shippingOrders = ships.Where(q=> q.Status != 2).Select(x=>x.ShipDoc).ToList();
                    var oldShipment = ships.Any(q => q.Status != 2) ? ships.Where(x => x.Status != 2).Sum(t => t.ShipQty) : 0;
                    var ship = ships.Where(q => q.Status == 2 && q.BusinessDate.Date == DateTime.Now.Date).FirstOrDefault();
                    decimal CurShipQty = 0;
                    int WaitShipmentCarton = 0;
                    int WaitShipment = 0;
                    int oWaitShipmentCarton = 0;
                    if (ship.IsNullOrEmpty()) { IsPrintCustomerLabel = false; }
                    else
                    {
@@ -416,14 +421,17 @@
                        var list = MainDB.Ado.UseStoredProcedure().GetDataTable("SP_MES_GET_NODE_BATCH_COUNT", pars).AsEnumerable().ToList();
                        if (!list.IsNullOrEmpty())
                        {
                            var sublist = list.Where(q=> shippingOrders.Contains(q["SHIPPING_ORDER"]) && q["ProdDate"].ToString() != "Whole").ToList();
                            oWaitShipmentCarton = sublist.IsNullOrEmpty() ? 0 : sublist.Sum(q => q["WaitShipmentCarton"].ToInt32());
                            var batchCount = list.Where(q => q["ProdDate"].ToString() == "Whole").FirstOrDefault();
                            WaitShipmentCarton = batchCount["WaitShipmentCarton"].ToInt32();
                            WaitShipmentCarton = batchCount["WaitShipmentCarton"].ToInt32()- oWaitShipmentCarton;
                            WaitShipment = batchCount["WaitShipment"].ToInt32();
                            IsPrintCustomerLabel = batchCount.IsNullOrEmpty() ? IsPrintCustomerLabel : batchCount["WaitShipment"].ToInt32() >= ship.ShipQty ? false : true;
                            IsPrintCustomerLabel = batchCount.IsNullOrEmpty() ? IsPrintCustomerLabel : batchCount["WaitShipment"].ToInt32() - oldShipment >= ship.ShipQty ? false : true;
                        }
                    }
                    ShippingOrder = IsPrintCustomerLabel ? ship?.ShipDoc ?? "" : "";
                    //缓存出货数量
                    Context.SetOrAdd("CuroldShipment", oldShipment);
                    Context.SetOrAdd("CurShipQty", CurShipQty);
                    //缓存出货箱数
                    Context.SetOrAdd("CurWaitShipmentCarton", WaitShipmentCarton);
@@ -973,7 +981,8 @@
                action.Data = new ShipingInfo()
                {
                    IsPrintCustomerLabel = IsPrintCustomerLabel,
                    ShipQty = Context.GetOrDefault("CurWaitShipment").ToInt32() >= Context.GetOrDefault("CurShipQty").ToInt32() ? CurBatch.Batch.PLAN_QTY - Context.GetOrDefault("CurShipQty").ToInt32() : Context.GetOrDefault("CurShipQty").ToInt32()
                    OldShipQty = Context.GetOrDefault("CuroldShipment").ToInt32(),
                    ShipQty = Context.GetOrDefault("CurWaitShipment").ToInt32() - Context.GetOrDefault("CuroldShipment").ToInt32() >= Context.GetOrDefault("CurShipQty").ToInt32() ? CurBatch.Batch.PLAN_QTY - Context.GetOrDefault("CuroldShipment").ToInt32() - Context.GetOrDefault("CurShipQty").ToInt32() : Context.GetOrDefault("CurShipQty").ToInt32()
                };
            }
            catch (Exception ex)
Tiger.Model.Net/Entitys/MES/ParameterEntity/PositionParameter.cs
@@ -336,6 +336,7 @@
    public class ShipingInfo
    {
        public bool IsPrintCustomerLabel { get; set; }
        public int OldShipQty { get; set; }
        public int ShipQty { get; set; }
    }