admin
2 天以前 059777821c875258b0fb6f39064cf75e12e5ad45
Wms/WMS.BLL/BllAsnServer/ArrivalNoticeServer.cs
@@ -37,16 +37,16 @@
        #region 事件方法
        public async Task<List<ArrivalNoticeDto>> GetArrivalNoticeList(ArrivalNoticeVm model, RefAsync<int> count)
        {
            var modelList = await Db.Queryable<BllArrivalNotice,BllArrivalNoticeDetail, SysUserInfor, SysUserInfor,
                SysUserInfor>((tb1, tb2, tb3, tb4,tb5)  => new JoinQueryInfos(
            var modelList = await Db.Queryable<BllArrivalNotice, BllArrivalNoticeDetail, SysUserInfor, SysUserInfor,
                SysUserInfor>((tb1, tb2, tb3, tb4, tb5) => new JoinQueryInfos(
                    JoinType.Left, tb1.ASNNo == tb2.ASNNo,
                    JoinType.Left, tb1.CreateUser == tb3.Id,
                    JoinType.Left, tb1.UpdateUser == tb4.Id,
                    JoinType.Left, tb1.CheckUser == tb5.Id))
                .WhereIF(!string.IsNullOrWhiteSpace(model.ASNNo), tb1 => tb1.ASNNo.Contains(model.ASNNo))
                .WhereIF(!string.IsNullOrWhiteSpace(model.LotNo), (tb1,tb2) => tb2.LotNo.Contains(model.LotNo))
                .WhereIF(!string.IsNullOrWhiteSpace(model.SkuNo), (tb1,tb2) => tb2.SkuNo.Contains(model.SkuNo))
                .WhereIF(!string.IsNullOrWhiteSpace(model.SkuName), (tb1,tb2) => tb2.SkuName.Contains(model.SkuName))
                .WhereIF(!string.IsNullOrWhiteSpace(model.LotNo), (tb1, tb2) => tb2.LotNo.Contains(model.LotNo))
                .WhereIF(!string.IsNullOrWhiteSpace(model.SkuNo), (tb1, tb2) => tb2.SkuNo.Contains(model.SkuNo))
                .WhereIF(!string.IsNullOrWhiteSpace(model.SkuName), (tb1, tb2) => tb2.SkuName.Contains(model.SkuName))
                .WhereIF(!string.IsNullOrWhiteSpace(model.CustomerName), tb1 => tb1.CustomerName.Contains(model.CustomerName))
                .WhereIF(!string.IsNullOrWhiteSpace(model.OrderCode), tb1 => tb1.OrderCode.Contains(model.OrderCode))
                .WhereIF(!string.IsNullOrWhiteSpace(model.Status), tb1 => tb1.Status == model.Status)
@@ -76,13 +76,13 @@
                    CompleteTime = tb1.CompleteTime,
                    CreateTime = tb1.CreateTime,
                    CreateUserName = tb3.RealName,
                    UserName=tb1.UserName,
                    UserName = tb1.UserName,
                    UpdateTime = ((DateTime)tb1.UpdateTime).ToString("yyyy-MM-dd HH:mm:ss"),
                    UpdateUserName = tb4.RealName
                }).ToPageListAsync(model.Page, model.Limit, count);
            return modelList;
            return modelList;
        }
        public async Task<List<ArrivalNoticeDetailDto>> GetArrivalNoticeDetailList(ArrivalNoticeDetailVm model, RefAsync<int> count)
@@ -94,48 +94,48 @@
            var modelList = await Db.Queryable<BllArrivalNoticeDetail>().Where(item)
                .LeftJoin<BllArrivalNotice>((tb1, tb2) => tb1.ASNNo == tb2.ASNNo)
                .LeftJoin<SysUserInfor>((tb1, tb2,tb3) => tb1.CreateUser == tb3.Id)
                .LeftJoin<SysUserInfor>((tb1,tb2,tb3,tb4) => tb1.UpdateUser == tb4.Id)
                .LeftJoin<SysMaterials>((tb1, tb2, tb3, tb4,tb5) => tb1.SkuNo == tb5.SkuNo && tb5.IsDel == "0")
                .LeftJoin<SysUnit>((tb1, tb2, tb3, tb4, tb5,tb6) => tb5.UnitNo == tb6.UnitNo && tb6.IsDel == "0")
                .LeftJoin<SysPackag>((tb1, tb2, tb3, tb4, tb5, tb6,tb7) => tb1.PackagNo == tb7.PackagNo && tb7.IsDel == "0")
                .Select((tb1, tb2, tb3, tb4, tb5,tb6, tb7) => new ArrivalNoticeDetailDto()
                 {
                     Id = tb1.Id,
                     ASNNo = tb1.ASNNo,
                     SkuNo = tb1.SkuNo,
                     SkuName = tb1.SkuName,
                     Standard = tb1.Standard,
                     LotNo = tb1.LotNo,
                     LotText = tb1.LotText,
                     Qty = tb1.Qty,
                     FactQty = tb1.FactQty,
                     CompleteQty = tb1.CompleteQty,
                     IsSampling = tb1.IsSampling,
                     InspectStatus = tb1.InspectStatus,
                     PackagNo = tb1.PackagNo,
                     PackagName = tb7.PackagName,
                     UnitName = tb6.UnitName,
                     IsBale = tb1.IsBale,
                     IsBelt = tb1.IsBelt,
                     SupplierLot = tb1.SupplierLot,
                     Status = tb1.Status,
                     AsnType = tb2.Type,
                     AsnStatus = tb2.Status,
                     IsPasteCode = tb5.IsPasteCode,
                     Lot1 = tb1.Lot1,
                     Lot2 = tb1.Lot2,
                     UDF1 = tb1.UDF1,
                     UDF2 = tb1.UDF2,
                     UDF3 = tb1.UDF3,
                     UDF4 = tb1.UDF4,
                     UDF5 = tb1.UDF5,
                     CompleteTime = tb1.CompleteTime,
                     CreateTime = tb1.CreateTime,
                     CreateUserName = tb3.RealName,
                     UpdateTime = ((DateTime)tb1.UpdateTime).ToString("yyyy-MM-dd HH:mm:ss"),
                .LeftJoin<SysUserInfor>((tb1, tb2, tb3) => tb1.CreateUser == tb3.Id)
                .LeftJoin<SysUserInfor>((tb1, tb2, tb3, tb4) => tb1.UpdateUser == tb4.Id)
                .LeftJoin<SysMaterials>((tb1, tb2, tb3, tb4, tb5) => tb1.SkuNo == tb5.SkuNo && tb5.IsDel == "0")
                .LeftJoin<SysUnit>((tb1, tb2, tb3, tb4, tb5, tb6) => tb5.UnitNo == tb6.UnitNo && tb6.IsDel == "0")
                .LeftJoin<SysPackag>((tb1, tb2, tb3, tb4, tb5, tb6, tb7) => tb1.PackagNo == tb7.PackagNo && tb7.IsDel == "0")
                .Select((tb1, tb2, tb3, tb4, tb5, tb6, tb7) => new ArrivalNoticeDetailDto()
                {
                    Id = tb1.Id,
                    ASNNo = tb1.ASNNo,
                    SkuNo = tb1.SkuNo,
                    SkuName = tb1.SkuName,
                    Standard = tb1.Standard,
                    LotNo = tb1.LotNo,
                    LotText = tb1.LotText,
                    Qty = tb1.Qty,
                    FactQty = tb1.FactQty,
                    CompleteQty = tb1.CompleteQty,
                    IsSampling = tb1.IsSampling,
                    InspectStatus = tb1.InspectStatus,
                    PackagNo = tb1.PackagNo,
                    PackagName = tb7.PackagName,
                    UnitName = tb6.UnitName,
                    IsBale = tb1.IsBale,
                    IsBelt = tb1.IsBelt,
                    SupplierLot = tb1.SupplierLot,
                    Status = tb1.Status,
                    AsnType = tb2.Type,
                    AsnStatus = tb2.Status,
                    IsPasteCode = tb5.IsPasteCode,
                    Lot1 = tb1.Lot1,
                    Lot2 = tb1.Lot2,
                    UDF1 = tb1.UDF1,
                    UDF2 = tb1.UDF2,
                    UDF3 = tb1.UDF3,
                    UDF4 = tb1.UDF4,
                    UDF5 = tb1.UDF5,
                    CompleteTime = tb1.CompleteTime,
                    CreateTime = tb1.CreateTime,
                    CreateUserName = tb3.RealName,
                    UpdateTime = ((DateTime)tb1.UpdateTime).ToString("yyyy-MM-dd HH:mm:ss"),
                    UpdateUserName = tb4.RealName
                 }).ToPageListAsync(model.Page, model.Limit, count);
                }).ToPageListAsync(model.Page, model.Limit, count);
            return modelList;
        }
@@ -155,13 +155,13 @@
                data.ProductionTime = string.IsNullOrEmpty(detail.Lot1) ? "" : Convert.ToDateTime(detail.Lot1).ToString("yyyy-MM-dd");
                data.ExpirationTime = string.IsNullOrEmpty(detail.Lot2) ? "" : Convert.ToDateTime(detail.Lot2).ToString("yyyy-MM-dd");
                data.SupplierLot = detail.SupplierLot;
                var labelQty = Db.Queryable<BllBoxInfo>().Where(m => m.IsDel == "0" && m.ASNDetailNo == id).Sum(m => m.Qty + (m.SamplingQty == null? 0: m.SamplingQty));
                var labelQty = Db.Queryable<BllBoxInfo>().Where(m => m.IsDel == "0" && m.ASNDetailNo == id).Sum(m => m.Qty + (m.SamplingQty == null ? 0 : m.SamplingQty));
                if (labelQty == null)
                {
                    labelQty = 0;
                }
                var qty = detail.Qty - labelQty;
                if (qty<0)
                if (qty < 0)
                {
                    qty = 0;
                }
@@ -292,7 +292,7 @@
                    }
                }
                lock (AsnLock)
                {
                    // 总表实体赋值
@@ -306,7 +306,7 @@
                        Status = "0",
                        LotNo = model.LotNo,
                        LotText = model.LotText,
                        SupplierLot = model.SupplierLot,
                        SupplierLot = model.SupplierLot,
                        CreateUser = (int)model.CreateUser
                    };
@@ -330,8 +330,8 @@
                            strMessage = "-1:数量必须大于0;";
                            continue;
                        }
                        if ( model.Type == "5" || model.Type == "6" || model.Type == "7")
                        if (model.Type == "5" || model.Type == "6" || model.Type == "7")
                        {
                            if (!string.IsNullOrWhiteSpace(detailModel.LotNo))
                            {
@@ -375,16 +375,16 @@
                        {
                            string toDayTime = DateTime.Now.ToString("yyyyMM");
                            var maxBoxCodeStr = Db.Queryable<BllArrivalNoticeDetail>()
                                .Where(m => m.IsDel == "0" && m.BoxCodeStr.Contains("BK")
                                .Where(m => m.IsDel == "0" && m.BoxCodeStr.Contains("BK")
                                && m.CreateTime.ToString("yyyyMM") == DateTime.Now.ToString("yyyyMM")).Max(m => m.BoxCodeStr);
                            if(string.IsNullOrWhiteSpace(maxBoxCodeStr))
                            if (string.IsNullOrWhiteSpace(maxBoxCodeStr))
                            {
                                string codeEndStr = (1 + codeStrNum).ToString().PadLeft(4, '0');
                                maxBoxCodeStr = "BK" + toDayTime.Substring(2, 4) + codeEndStr;
                            }
                            else
                            {
                                maxBoxCodeStr = "BK" + (int.Parse(maxBoxCodeStr.Replace("BK", "")) + 1 + codeStrNum).ToString();
                                maxBoxCodeStr = "BK" + (int.Parse(maxBoxCodeStr.Replace("BK", "")) + 1 + codeStrNum).ToString();
                            }
                            detailModel.BoxCodeStr = maxBoxCodeStr;
@@ -393,10 +393,10 @@
                        // 判断是否已存在当前明细
                        int com = Db.Queryable<BllArrivalNoticeDetail>()
                            .Where(m => m.ASNNo == model.ASNNo
                            && m.SkuNo == detailModel.SkuNo
                            && m.LotNo == detailModel.LotNo
                            && m.Id != (int)detailModel.Id
                            .Where(m => m.ASNNo == model.ASNNo
                            && m.SkuNo == detailModel.SkuNo
                            && m.LotNo == detailModel.LotNo
                            && m.Id != (int)detailModel.Id
                            && m.IsDel == "0").ToList().Count();
                        if (com > 0)
                        {
@@ -492,7 +492,7 @@
                        details.Add(detail);
                    }
                    // 判断是否存在被过滤掉的明细
                    if (details.Count <= 0)
                    {
@@ -504,7 +504,7 @@
                    var rowCount = Db.Insertable(ASNModel).ExecuteCommand();
                    var rowDetailCount = 0;
                    if (details.Count  > 0)
                    if (details.Count > 0)
                    {
                        rowDetailCount = Db.Insertable(details).ExecuteCommand();
                    }
@@ -560,9 +560,9 @@
                            }
                        }
                    }
                    catch(Exception ex)
                    catch (Exception ex)
                    {
                        throw new Exception($"物料编码:{model.AsnDetail[0].SkuNo},物料名称:{model.AsnDetail[0].SkuName},导入失败:"+ex.Message);
                        throw new Exception($"物料编码:{model.AsnDetail[0].SkuNo},物料名称:{model.AsnDetail[0].SkuName},导入失败:" + ex.Message);
                        // ignored
                    }
                }
@@ -897,8 +897,8 @@
                asnModel.UpdateUser = model.CreateUser;
                // 删除明细单
                var asnDetails = Db.Queryable<BllArrivalNoticeDetail>().Where(m => m.ASNNo == model.ASNNo && m.IsDel =="0").ToList();
                foreach (BllArrivalNoticeDetail asnDetail in asnDetails)
                var asnDetails = Db.Queryable<BllArrivalNoticeDetail>().Where(m => m.ASNNo == model.ASNNo && m.IsDel == "0").ToList();
                foreach (BllArrivalNoticeDetail asnDetail in asnDetails)
                {
                    asnDetail.IsDel = "1";
                    asnDetail.UpdateTime = editDateTime;
@@ -956,14 +956,14 @@
                    return "-1:入库单状态已变更,不可删除!";
                }
                if (asnModel.Origin != "录入" )//&& asnModel.Origin != "采购单"
                if (asnModel.Origin != "录入")//&& asnModel.Origin != "采购单"
                {
                    return "-1:上游系统下发的单据,不可删除;";
                }
                var asnDetail = Db.Queryable<BllArrivalNoticeDetail>().First(m => m.ASNNo == model.ASNNo && m.IsDel == "0" && m.Id == model.Id);
                if (asnDetail == null)
                if (asnDetail == null)
                {
                    return "-1:明细状态已变更,不可删除!";
                }
@@ -993,11 +993,11 @@
                Db.Ado.BeginTran();
                int rowCount = Db.Updateable(asnModel).ExecuteCommand();
                rowCount += Db.Updateable(asnDetail).ExecuteCommand();
                if (boxList.Count>0)
                if (boxList.Count > 0)
                {
                    rowCount += Db.Deleteable(boxList).ExecuteCommand();
                    rowCount += Db.Deleteable(boxList).ExecuteCommand();
                }
                if (rowCount < 2)
                {
                    Db.RollbackTran();
@@ -1006,8 +1006,8 @@
                Db.Ado.CommitTran();
                var detail = Db.Queryable<BllArrivalNoticeDetail>().First(m => m.Id == model.Id);
                new OperationASNServer().AddLogOperationAsn("入库作业", "入库单据", model.ASNNo, "删除",
                    $"删除了单据号为{model.ASNNo}、物料为{detail.SkuNo}、批次号为{detail.LotNo}的单据信息",
                new OperationASNServer().AddLogOperationAsn("入库作业", "入库单据", model.ASNNo, "删除",
                    $"删除了单据号为{model.ASNNo}、物料为{detail.SkuNo}、批次号为{detail.LotNo}的单据信息",
                    Convert.ToInt32(model.CreateUser));
                return "";
@@ -1031,7 +1031,7 @@
                }
                var palletBind = Db.Queryable<BllPalletBind>()
                    .Where(m => m.IsDel == "0" && m.ASNNo == notice.ASNNo
                    .Where(m => m.IsDel == "0" && m.ASNNo == notice.ASNNo
                    && m.Status != "2" && m.Status != "3").ToList();
                if (palletBind != null && palletBind.Count > 0)
@@ -1042,7 +1042,7 @@
                // 总单关单
                var asnModel = Db.Queryable<BllArrivalNotice>().First(m => m.Id == id);
                if (asnModel != null)
                if (asnModel != null)
                {
                    asnModel.Status = "3";
                    asnModel.CompleteTime = comTime;
@@ -1051,7 +1051,7 @@
                }
                // 将未完成的明细改为已完成
                var asnDetails = Db.Queryable<BllArrivalNoticeDetail>().Where(m => m.Id == id && m.Status == "2").ToList();
                foreach (BllArrivalNoticeDetail asnDetail in asnDetails)
                foreach (BllArrivalNoticeDetail asnDetail in asnDetails)
                {
                    asnDetail.Status = "2";
                    asnDetail.CompleteTime = comTime;
@@ -1345,7 +1345,7 @@
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public ErpModel CreateAsn(SendAsnVm model,string userName)
        public ErpModel CreateAsn(SendAsnVm model, string userName)
        {
            try
            {
@@ -1355,7 +1355,7 @@
                    resultModel.Message = "单据类型不可为空!";
                    return resultModel;
                }
                if (string.IsNullOrEmpty(model.orderNo.ToString()))
                {
                    resultModel.Message = "上游系统单号不可为空!";
@@ -1513,11 +1513,11 @@
                    }
                    var item = new BackAsnDetail()
                    {
                        POSNR=d.OrderDetailCode,
                        POSNR = d.OrderDetailCode,
                        MATNR = d.SkuNo,
                        MAKTX=d.SkuName,
                        MAKTX = d.SkuName,
                        LFIMG = d.CompleteQty.ToString(),
                        MEINS= mater.UnitNo,
                        MEINS = mater.UnitNo,
                        CHARG = d.LotNo,
                        HSDAT = d.Lot1,
                        VFDAT = d.Lot2
@@ -1539,10 +1539,10 @@
                var response = HttpHelper.DoPost(url, jsonData, "入库单完成上传", "SAP");
                var obj = JsonConvert.DeserializeObject<ErpModel>(response);//解析返回数据
                if (obj.Success != 0)
                var obj = JsonConvert.DeserializeObject<SapResultModel>(response);//解析返回数据
                if (obj.RESULT != true)
                {
                    throw new Exception("上传失败" + obj.Message);
                    throw new Exception("上传失败" + obj.MESSAGE);
                }
                #endregion
@@ -1568,7 +1568,7 @@
            try
            {
                Db.BeginTran();
                if (code.Substring(0,2) == "AS")
                if (code.Substring(0, 2) == "AS")
                {
                    var notice = Db.Queryable<BllArrivalNotice>().First(m => m.ASNNo == code && m.IsDel == "0");
                    if (notice == null)
@@ -1627,7 +1627,7 @@
                    new OperationASNServer().AddLogOperationAsn("PDA模块", "复核单据", code, "复核", $"复核了单据号为{code}的单据信息", userId);
                }
                else if (code.Substring(0,2) == "SO")
                else if (code.Substring(0, 2) == "SO")
                {
                    var notice = Db.Queryable<BllExportNotice>().First(m => m.SONo == code && m.IsDel == "0");
                    if (notice == null)
@@ -1684,7 +1684,7 @@
                    new OperationSOServer().AddLogOperationSo("PDA模块", "复核单据", code, "复核", $"复核了单据号为{code}的单据信息", userId);
                }
                Db.CommitTran();
                return true;
            }
            catch (Exception e)
@@ -1861,7 +1861,7 @@
                        //更新储位状态
                        Db.Updateable(palletLocatInfo).ExecuteCommand();
                        //获取目标储位地址
                        SysStorageLocat EndLocat = GetLocat(asnDetailModel.SkuNo, asnDetailModel.LotNo, bindPalletNoItem,hasLocatNoList);
                        SysStorageLocat EndLocat = GetLocat(asnDetailModel.SkuNo, asnDetailModel.LotNo, bindPalletNoItem, hasLocatNoList);
                        if (EndLocat == null)
                        {
                            resultModel.Message = "未找到目标储位地址信息!";
@@ -1889,8 +1889,8 @@
                            IsBale = "0",
                            IsBelt = "0",
                            WareHouseNo= EndLocat.WareHouseNo,//所属仓库
                            LocatNo=EndLocat.LocatNo,//储位地址
                            WareHouseNo = EndLocat.WareHouseNo,//所属仓库
                            LocatNo = EndLocat.LocatNo,//储位地址
                            CreateUser = 0
                        };
@@ -1902,7 +1902,7 @@
                        foreach (var completeDetailYuItem in palletCompleteDetailYuModelList)
                        {
                            Expression<Func<BllBoxInfo, bool>> exp = Expressionable.Create<BllBoxInfo>()
                             .And(it => it.BoxNo== completeDetailYuItem.BoxNo)
                             .And(it => it.BoxNo == completeDetailYuItem.BoxNo)
                             .AndIF(!string.IsNullOrEmpty(completeDetailYuItem.BoxNo2), it => it.BoxNo2 == completeDetailYuItem.BoxNo2)
                             .AndIF(!string.IsNullOrEmpty(completeDetailYuItem.BoxNo3), it => it.BoxNo3 == completeDetailYuItem.BoxNo3)
                             .ToExpression();//注意 这一句 不能少