chengsc
2024-10-15 86985a3e211ab4cc1e94a696c15a6f77d21c462a
Wms/WMS.BLL/BllPdaServer/PdaAsnServer.cs
@@ -30,16 +30,33 @@
        private static readonly SqlSugarScope Db = DataContext.Db;
        // 获取单据列表
        public List<ArrivalNoticeDto> GetArrivalNotices(ArrivalNoticeVm model)
        public List<string> GetArrivalNotices(ArrivalNoticeVm model)
        {
            string sqlString = string.Empty;
            try
            {
                // 未关单的单据
                sqlString = $"select * from BllArrivalNotice where Type in ({model.Type}) and Status != '3' and Status != '4'  and IsDel='0' order by CreateTime;";
                var modelList = Db.Ado.SqlQuery<ArrivalNoticeDto>(sqlString);
                //sqlString = $"select * from BllArrivalNotice where Type in ({model.Type}) and Status != '3' and Status != '4'  and IsDel='0' order by CreateTime;";
                //var modelList = Db.Ado.SqlQuery<ArrivalNoticeDto>(sqlString);
                return modelList;
                //model.Type:单据类型 在这里代表前端页签类型:即标签页签:贴标物料; 数量页签:不贴表物料,原因:懒得加参数
                var data = Db.Queryable<BllArrivalNotice>().Where(m => m.IsDel == "0" && m.Status != "3" && m.Status != "4").Select(m=>m.ASNNo).ToList();
                var list = new List<string>();
                if (model.Type == "0")//0贴标
                {
                    list = Db.Queryable<BllArrivalNoticeDetail>().Where(m =>m.IsDel == "0" && data.Contains(m.ASNNo) && !string.IsNullOrWhiteSpace(m.PackagNo)).Select(m => m.ASNNo).Distinct().ToList();
                }
                else if(model.Type == "1")//1不贴标
                {
                    list = Db.Queryable<BllArrivalNoticeDetail>().Where(m => m.IsDel == "0" && data.Contains(m.ASNNo) && string.IsNullOrWhiteSpace(m.PackagNo)).Select(m=>m.ASNNo).Distinct().ToList();
                }
                else
                {
                    throw new Exception("页签类型参数错误");
                }
                return list;
            }
            catch (Exception ex)
            {
@@ -1699,9 +1716,73 @@
                var data = new { BoxNo = boxNo };
                var jsonData = JsonConvert.SerializeObject(data);
                #region 测试版本
                //读取json文件,添加数据
                var ss = AppDomain.CurrentDomain.BaseDirectory;
                string filePath = Path.Combine(ss, "CreateBoxInfo.json");
                string json = File.ReadAllText(filePath);
                var person = JsonConvert.DeserializeObject<List<BllBoxInfo>>(json);
                var comTime = DateTime.Now;
                //添加箱码信息表中  //暂时这些写--添加数据,后续需要和赋码系统对接后 根据明确返回的数据格式更改
                foreach (var item in person)
                {
                    if (item.BoxNo!= boxNo)
                    {
                        continue;
                    }
                    var sku = Db.Queryable<SysMaterials>().First(m=>m.IsDel =="0" && m.SkuNo == item.SkuNo);
                    if (sku == null)
                    {
                        continue;
                    }
                    var boxInfo = new BllBoxInfo()
                    {
                        ASNNo = "",
                        //ASNDetailNo = 0,
                        OrderCode = "",
                        //BindNo = 0,
                        BoxNo = item.BoxNo,
                        BoxNo2 = item.BoxNo2,
                        BoxNo3 = item.BoxNo3,
                        PalletNo = "",
                        Qty = item.Qty,
                        FullQty = item.FullQty,
                        Status = "0",
                        SkuNo = item.SkuNo,
                        SkuName = sku.SkuName,
                        LotNo = item.LotNo,
                        LotText = item.LotText,
                        SupplierLot = item.SupplierLot,
                        ProductionTime = item.ProductionTime,
                        ExpirationTime = item.ExpirationTime,
                        //CompleteTime = comTime,
                        InspectMark = item.InspectMark,
                        BitBoxMark = item.BitBoxMark,
                        InspectStatus = item.InspectStatus,
                        Origin = "赋码",
                        Standard = item.Standard,
                        PackageStandard = item.PackageStandard,
                        StoreTime = item.StoreTime,
                        QtyOrd = item.QtyOrd,
                        QtyCount = item.QtyCount,
                        CreateUser = 0,
                        CreateTime = comTime,
                    };
                    list.Add(boxInfo);
                }
                Db.Insertable(list).ExecuteCommand();
                #endregion
                #region 正式版本
                ////程序正式发布后放开
                //var time1 = DateTime.Now;//发送时间 .ToString("yyyy-MM-dd HH:mm:ss")
                //var response = HttpHelper.DoPost(url, jsonData,"获取箱码信息", "赋码");
                //var response = HttpHelper.DoPost(url, jsonData, "获取箱码信息", "赋码");
                //var time2 = DateTime.Now;//返回时间 .ToString("yyyy-MM-dd HH:mm:ss")
                ////解析返回数据 
@@ -1709,55 +1790,13 @@
                //if (fuMaModel.Success == 0)
                //{
                    var datas = Assembly.GetExecutingAssembly();
                var s = "0";
                    //string filePath = "Assembly.GetExecutingAssembly()";
                    //string json = File.ReadAllText(filePath);
                    //var person = JsonConvert.DeserializeObject<BllBoxInfo>(json);
                    //var comTime = DateTime.Now;
                    ////添加箱码信息表中  //暂时这些写--添加数据,后续需要和赋码系统对接后 根据明确返回的数据格式更改
                    //var boxInfo = new BllBoxInfo()
                    //{
                    //    ASNNo = "",
                    //    //ASNDetailNo = 0,
                    //    OrderCode = "",
                    //    //BindNo = 0,
                    //    BoxNo = person.BoxNo,
                    //    BoxNo2 = "",
                    //    BoxNo3 = "",
                    //    PalletNo = "",
                    //    Qty = 0,
                    //    FullQty = 0,
                    //    Status = "0",
                    //    SkuNo = "",
                    //    SkuName = "",
                    //    LotNo = "",
                    //    LotText = "",
                    //    SupplierLot = "",
                    //    ProductionTime = DateTime.Now,
                    //    ExpirationTime = DateTime.Now,
                    //    //CompleteTime = comTime,
                    //    InspectMark = "0",
                    //    BitBoxMark = "0",
                    //    InspectStatus = "0",
                    //    Origin = "赋码",
                    //    Standard = "box.Standard",
                    //    PackageStandard = "box.PackageStandard",
                    //    StoreTime = DateTime.Now,
                    //    CreateUser = 0,
                    //    CreateTime = comTime,
                    //};
                    //Db.Insertable(boxInfo).ExecuteCommand();
                //}
                //if (fuMaModel.Success == -1)
                //{
                //    throw new Exception($"赋码系统返回状态异常:{fuMaModel.Message}");
                //}
                #endregion
            }
            catch (Exception e)
            {
@@ -1778,12 +1817,19 @@
                {
                    throw new Exception("请扫描外箱条码!");
                }
                var count = Db.Queryable<BllBoxInfo>().Count(m => m.IsDel == "0" && m.Status == "0" && m.BoxNo == model.BoxNo);
                if (count == 0)
                if (!string.IsNullOrWhiteSpace(model.ASNNo))
                {
                    GetBoxInfoByFuMa("",""); //从赋码系统获取箱码信息
                    var asnData = Db.Queryable<BllArrivalNotice>().First(m => m.IsDel == "0" && m.ASNNo == model.ASNNo);
                    if (asnData != null && (asnData.Type == "0" || asnData.Type == "3"))
                    {
                        var count = Db.Queryable<BllBoxInfo>().Count(m => m.IsDel == "0" && m.Status == "0" && m.BoxNo == model.BoxNo);
                        if (count == 0)
                        {
                            GetBoxInfoByFuMa(model.BoxNo, ""); //从赋码系统获取箱码信息
                        }
                    }
                }
                string sqlString = $@"SELECT 
                                        ASNNo,
                                        BoxNo, 
@@ -1797,7 +1843,7 @@
                                        AND BoxNo = '{model.BoxNo}'
                                      GROUP BY ASNNo,BoxNo,SkuNo,SkuName,LotNo; ";
                var models = Db.Ado.SqlQuery<BoxInfoDto>(sqlString);
                if (models == null)
                if (models.Count == 0)
                {
                    throw new Exception("箱码信息不存在!");
                }
@@ -2201,29 +2247,29 @@
                            factQty += box.Qty;
                            boxFullQty += box.Qty;
                        }
                        if (boxFullQty > bNum)
                        {
                            throw new Exception($"绑定失败,{g.Key}箱码绑定数量大于该物品包装数量!");
                        }
                        //if (boxFullQty > bNum)
                        //{
                        //    throw new Exception($"绑定失败,{g.Key}箱码绑定数量大于该物品包装数量!");
                        //}
                    }
                    Db.Updateable(boxInfoList).ExecuteCommand();
                    // 更新托盘绑定表
                    bind.Qty += factQty;
                }
                if (bind.FullQty < bind.Qty && isDeposit == 0 && isTextTable == 0)
                {
                    throw new Exception("托盘绑定数量已超出该物料包装数量");
                }
                //if (bind.FullQty < bind.Qty && isDeposit == 0 && isTextTable == 0)
                //{
                //    throw new Exception("托盘绑定数量已超出该物料包装数量");
                //}
                if (bind.FullQty == bind.Qty)
                if (bind.FullQty <= bind.Qty)
                {
                    bind.BitPalletMark = "0";
                }
                if (bind.Qty > pNum && isDeposit == 0 && isTextTable == 0)
                {
                    throw new Exception($"绑定失败,{bind.PalletNo}托盘绑定数量大于该物品托盘包装数量!");
                }
                //if (bind.Qty > pNum && isDeposit == 0 && isTextTable == 0)
                //{
                //    throw new Exception($"绑定失败,{bind.PalletNo}托盘绑定数量大于该物品托盘包装数量!");
                //}
                Db.Updateable(bind).Where(m => m.Id == bindId).ExecuteCommand();
                // 更改入库单明细已组数量
@@ -2490,7 +2536,7 @@
                            PackagNo = sku.PackagNo,
                            IsBale = bindInfo.IsBale,
                            IsBelt = bindInfo.IsBelt,
                            Demo = bindInfo.Demo,
                            CreateUser = (int)model.CreateUser,
                            CreateTime = serverTime
                        };