IPC-610
2024-12-03 2f0120d0c10ac24603936911ee5812d4e71d2740
Wms/WMS.BLL/BllPdaServer/PdaAsnServer.cs
@@ -24,6 +24,7 @@
using System.IO;
using System.Security.Cryptography.X509Certificates;
using System.Net.WebSockets;
using WMS.BLL.SysServer;
namespace WMS.BLL.BllPdaServer
{
@@ -333,6 +334,7 @@
        public string BindNullPallet(PalletBindVm model)
        {
            string strMsg = "";
            string type = model.BindType == "0" ? "PDA" : "叠托机";
            try
            {
                var datetime = Db.GetDate();
@@ -440,7 +442,7 @@
                    LotText = "",
                    SupplierLot = "",
                    InspectStatus = "1",
                    Origin = "PDA",
                    Origin = type,
                    BoxNo = "",
                    BoxNo2 = "",
                    BoxNo3 = "",
@@ -461,6 +463,120 @@
                // 插入操作日志
                new OperationASNServer().AddLogOperationAsn("PDA模块", "空托入库", model.PalletNo, "添加", $"在PDA上添加了空托盘跺", (int)model.CreateUser);
                return strMsg;
            }
            catch (Exception ex)
            {
                Db.Ado.RollbackTran();
                throw ex;
            }
        }
        // 叠托机绑定空托盘
        public string BindNullPallets(PalletsBind model)
        {
            string strMsg = "";
            string type = model.BindType == "0" ? "PDA" : "叠托机";
            try
            {
                var datetime = Db.GetDate();
                //获取托盘绑定信息
                string str = "select * from BllPalletBind where IsDel = '0' and PalletNo = @palletno and Status = '0' ";
                List<PalletBindVm> list = Db.Ado.SqlQuery<PalletBindVm>(str, new
                {
                    palletno = model.PalletNo //托盘号
                });
                //判断是否已绑定该托盘
                if (list.Count > 0)
                {
                    strMsg = "-1:该托盘已被绑定!";
                    return strMsg;
                }
                if (string.IsNullOrEmpty(model.PalletNo))
                {
                    strMsg = "-1:托盘号不可为空!";
                    return strMsg;
                }
                if (model.Qty == null || model.Qty == 0)
                {
                    strMsg = "-1:空托盘数量不可为空!";
                    return strMsg;
                }
                //获取托盘信息
                var pallet = Db.Queryable<SysPallets>().First(a => a.IsDel == "0" && a.PalletNo == model.PalletNo);
                if (pallet == null)
                {
                    strMsg = "-1:托盘信息为空!";
                    return strMsg;
                }
                if (pallet.Status != "0")
                {
                    strMsg = "-1:该托盘正在使用!";
                    return strMsg;
                }
                Db.BeginTran();
                // 插入托盘绑定表
                var modelpb = new BllPalletBind
                {
                    ASNNo = "",
                    ASNDetailNo = 0,
                    TaskNo = "", //任务号
                    PalletNo = model.PalletNo,
                    Qty = (int)model.Qty,
                    Status = "0", //等待执行
                    Type = "1", //0 物料托 1 空托
                    LotNo = "",
                    LotText = "",
                    SupplierLot = "",
                    InspectMark = "0", //0 否 1 是
                    BitPalletMark = "0",
                    IsBale = "0",
                    IsBelt = "0",
                    CreateTime = Db.GetDate()
                };
                var id = Db.Insertable(modelpb).ExecuteReturnIdentity();
                var modelbb = new BllBoxInfo
                {
                    ASNNo = "",
                    ASNDetailNo = null,
                    BindNo = id,
                    PalletNo = model.PalletNo,
                    Status = "1",
                    CompleteTime = DateTime.Now,
                    Qty = (int)model.Qty,
                    FullQty = null,
                    SkuNo = "100099",
                    SkuName = "托盘",
                    LotNo = "",
                    LotText = "",
                    SupplierLot = "",
                    InspectStatus = "1",
                    Origin = type,
                    BoxNo = "",
                    BoxNo2 = "",
                    BoxNo3 = "",
                    InspectMark = "",
                    BitBoxMark = "0",
                    CreateTime = datetime
                };
                Db.Insertable(modelbb).ExecuteCommand();
                // 更改托盘使用状态
                string sqlStr = string.Empty;
                sqlStr = $"update SysPallets set Status = '1' where PalletNo = '{model.PalletNo}';";
                Db.Ado.ExecuteCommand(sqlStr);
                Db.CommitTran();
                // 插入操作日志
                new OperationASNServer().AddLogOperationAsn("PDA模块", "空托入库", model.PalletNo, "添加", $"在PDA上添加了空托盘跺", 1);
                return strMsg;
            }
@@ -1794,7 +1910,7 @@
        #region 产品组托
        public void GetBoxInfoByFuMa(string boxNo,string url)
        public void GetBoxInfoByFuMa(string boxNo,string url,string fuMaTokenUrl,string levelType)
        {
            try
            {
@@ -1865,23 +1981,86 @@
                #endregion
                #region 正式版本
                var token = new Token().GetFuMaToken(fuMaTokenUrl);
                var getParentVal = levelType == "1" ? "true" : "false";
                var getChildrenVal = levelType == "3" ? "true" : "false";
                Dictionary<string, string> paramDic = new Dictionary<string, string>
                {
                    { "Token", token }, //分配的令牌(变量)
                    { "Barcode", boxNo },//要查询的条码
                    { "getParent", getParentVal },//是否查询父码
                    { "getChildren", getChildrenVal } //是否查询子码
                };
                //程序正式发布后放开
                var time1 = DateTime.Now;//发送时间 .ToString("yyyy-MM-dd HH:mm:ss")
                var response = HttpHelper.DoGet(url, "赋码", "获取箱码信息", paramDic);
                var time2 = DateTime.Now;//返回时间 .ToString("yyyy-MM-dd HH:mm:ss")
                ////程序正式发布后放开
                //var time1 = DateTime.Now;//发送时间 .ToString("yyyy-MM-dd HH:mm:ss")
                //var response = HttpHelper.DoPost(url, jsonData, "获取箱码信息", "赋码");
                //var time2 = DateTime.Now;//返回时间 .ToString("yyyy-MM-dd HH:mm:ss")
                //解析返回数据
                var fuMaModel = JsonConvert.DeserializeObject<FuMaGetBoxModel>(response);
                if (fuMaModel.IsSuccess)
                {
                    //赋码返回信息成功状态
                    if (fuMaModel.Product == null || fuMaModel.Barcodes.Count == 0)
                    {
                        throw new Exception("产品信息或箱支信息为空");
                    }
                ////解析返回数据
                //var fuMaModel = JsonConvert.DeserializeObject<FuMaModel>(response);
                //if (fuMaModel.Success == 0)
                //{
                    foreach (var item in fuMaModel.Barcodes)
                    {
                        if (item.Barcode != boxNo)
                        {
                            throw new Exception("获取信息不一致");
                        }
                //}
                //if (fuMaModel.Success == -1)
                //{
                //    throw new Exception($"赋码系统返回状态异常:{fuMaModel.Message}");
                //}
                        var sku = Db.Queryable<SysMaterials>().First(m => m.IsDel == "0" && m.SkuNo == fuMaModel.Product.ProductCode);
                        if (sku == null)
                        {
                            throw new Exception("未查询到箱码中的物料信息");
                        }
                        var boxInfo = new BllBoxInfo()
                        {
                            ASNNo = "",
                            //ASNDetailNo = 0,
                            OrderCode = "",
                            //BindNo = 0,
                            BoxNo = item.Barcode,
                            BoxNo2 = item.Barcode,
                            BoxNo3 = item.Barcode,
                            PalletNo = "",
                            Qty = item.BoxItemQty,
                            FullQty = fuMaModel.BoxItemQty,
                            Status = "0",
                            SkuNo = sku.SkuNo,
                            SkuName = sku.SkuName,
                            LotNo = item.BatchNo,
                            //LotText = "",
                            //SupplierLot = item.SupplierLot,
                            ProductionTime = DateTime.Parse(item.ProductionDate),
                            ExpirationTime = DateTime.Parse(item.ExpirationDate),
                            //CompleteTime = comTime,
                            InspectMark = "0",
                            BitBoxMark = item.Status == "零箱"? "1":"0",
                            InspectStatus = "0",
                            Origin = "赋码",
                            Standard = fuMaModel.Product.Spec,
                            PackageStandard = fuMaModel.Product.PackageSpec,
                            //StoreTime = item.StoreTime,
                            //QtyOrd = item.QtyOrd,
                            //QtyCount = item.QtyCount,
                            CreateUser = 0,
                            CreateTime = comTime,
                        };
                        list.Add(boxInfo);
                    }
                    Db.Insertable(list).ExecuteCommand();
                }
                else
                {
                    //赋码返回信息失败状态
                    throw new Exception($"赋码系统返回状态异常:{fuMaModel.Message}");
                }
                #endregion
            }
@@ -1896,7 +2075,7 @@
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public List<BoxInfoDto> GetBindBoxInfos(BoxInfoVm model)
        public List<BoxInfoDto> GetBindBoxInfos(BoxInfoVm model, string url, string fuMaTokenUrl)
        {
            try
            {
@@ -1916,7 +2095,7 @@
                            var count = Db.Queryable<BllBoxInfo>().Count(m => m.IsDel == "0" && m.Status == "0" && m.BoxNo == model.BoxNo);
                            if (count == 0)
                            {
                                GetBoxInfoByFuMa(model.BoxNo, ""); //从赋码系统获取箱码信息
                                GetBoxInfoByFuMa(model.BoxNo, url, fuMaTokenUrl,"1"); //从赋码系统获取箱码信息
                            }
                        }
                    }
@@ -1953,7 +2132,7 @@
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public List<BoxInfoDto> GetBindBoxInfo2s(BoxInfoVm model)
        public List<BoxInfoDto> GetBindBoxInfo2s(BoxInfoVm model, string url, string fuMaTokenUrl)
        {
            try
            {
@@ -2019,8 +2198,8 @@
                                }
                                else
                                {
                                   // GetBoxInfoByFuMa(model.BoxNo3, ""); //从赋码系统获取箱码信息
                                }
                                    GetBoxInfoByFuMa(model.BoxNo3, url, fuMaTokenUrl,"3"); //从赋码系统获取箱码信息
                                }
                            }
                        }
                    }