Administrator
2024-03-04 0acd18b6bebdcfc24a0d7c27edb0f8ef1fc7f9aa
Wms/WMS.BLL/BllSoServer/ExportNoticeServer.cs
@@ -204,10 +204,18 @@
                {
                    throw new Exception("未查询到单据信息");
                }
                if (notice.Status != "5")
                {
                    throw new Exception("复核失败,单据非关闭状态");
                }
                var detail = Db.Queryable<BllExportNoticeDetail>().Where(m => m.SONo == notice.SONo && m.IsDel == "0").ToList();
                if (detail.Count == 0)
                {
                    throw new Exception("未查询到单据明细信息");
                }
                if (userId == notice.UpdateUser)
                {
                    throw new Exception("复核失败,复核人员和关闭订单人员不能相同!");
                }
                var list = new List<SoDetail>();
                foreach (var d in detail)
@@ -225,21 +233,25 @@
                    OrderCode = notice.OrderCode,
                    SoDetails = list
                };
                // 通过接口发送至erp
                var jsonData = JsonConvert.SerializeObject(soInfo);
                #region 通过接口发送至erp
                //系统对接后放开
                /*var jsonData = JsonConvert.SerializeObject(soInfo);
                var response = HttpHelper.DoPost(url, jsonData, "出库单完成上传", "ERP");
                //解析返回数据
                var obj = JsonConvert.DeserializeObject<ErpModel>(response);
                var obj = JsonConvert.DeserializeObject<ErpModel>(response);//解析返回数据
                if (obj.Success != 0)
                {
                    throw new Exception("上传失败" + obj.Message);
                }
                }*/
                #endregion
                notice.Status = "6";
                notice.UpdateTime = DateTime.Now;
                notice.UpdateUser = userId;
                Db.Updateable(notice).ExecuteCommand();
                new OperationSOServer().AddLogOperationSo("出库作业", "出库单据", notice.SONo, "复核", $"复核了单据号为{notice.SONo}的单据信息", userId);
                return true;
            }
            catch (Exception e)
@@ -278,7 +290,8 @@
                    .LeftJoin<SysLogisticsInfo>((a, b) => a.LogisticsId == b.Id)
                    .LeftJoin<SysUserInfor>((a, b, c) => a.CreateUser == c.Id)
                    .LeftJoin<SysUserInfor>((a, b, c, d) => a.CreateUser == d.Id)
                    .Select((a, b, c, d) => new ExportNoticeDto()
                    .LeftJoin<SysUserInfor>((a, b, c, d,e) => a.CheckUser == e.Id)
                    .Select((a, b, c, d,e) => new ExportNoticeDto()
                    {
                        Id = a.Id,
                        SONo = a.SONo,
@@ -300,7 +313,10 @@
                        CreateUserName = c.RealName,
                        UpdateUserName = c.RealName,
                        CreateTime = a.CreateTime,
                        UpdateTime = a.UpdateTime
                        UpdateTime = a.UpdateTime,
                        CheckUserName=e.RealName,
                        CheckTime=a.CheckTime
                    })
                    .OrderByDescending(a => a.CreateTime)
                    .ToOffsetPage(page, limit, ref total);
@@ -321,38 +337,38 @@
                var plnList = new List<string>() { "100099" };
                var skuList = new List<string>();
                var sku = Db.Queryable<SysMaterials>().Where(m => m.IsDel == "0" && !plnList.Contains(m.SkuNo)); //排除空托盘的物料集合
                var inspectStatus = "1";//库存内物料的质检状态
                var skuTypeC = new List<string>() { "0" };//标准
                var skuTypeY = new List<string>() { "1" };//非标
                if (type == "0" || type == "2") //标准
                string skuType = string.Empty;
                switch (type)//0:原料 1:包材 2:成品 3:耗材 4:半成品
                {
                    inspectStatus = "0";
                    //if (type == "0") //成品
                    //{
                    skuList = sku.Where(m => inspectStatus==m.IsControlled).Select(m => m.SkuNo).ToList();
                    //}
                    //if (type == "1") //原料
                    //{
                    //    skuList = sku.Where(m => skuTypeY.Contains(m.Type)).Select(m => m.SkuNo).ToList();
                    //}
                    case "0"://成品入库
                        skuType = "(2)";
                        break;
                    case "1"://领料出库
                        skuType = "(0,1,3)";
                        break;
                    case "2"://抽检出库
                        skuType = "(2)";
                        break;
                    case "3"://物料取样出库
                        skuType = "(0)";
                        break;
                    case "4"://不合格品出库
                        skuType = "(2)";
                        break;
                    case "5"://中间品出库
                        skuType = "(4)";
                        break;
                    case "6"://代储出库
                        skuType = "(2)";
                        break;
                    default: //其它出库
                        skuType = "(0,1,2,3,4)";
                        break;
                }
                else if (type == "1" || type == "3") //非标
                skuList = sku.Where(m => skuType.Contains(m.Type)).Select(m => m.SkuNo).ToList();
                if (skuList == null)
                {
                    inspectStatus = "1";
                    //if (type == "2") //成品
                    //{
                    skuList = sku.Where(m => inspectStatus==m.IsControlled).Select(m => m.SkuNo).ToList();
                    //}
                    //if (type == "3") //原料
                    //{
                    //    skuList = sku.Where(m => skuTypeY.Contains(m.Type)).Select(m => m.SkuNo).ToList();
                    //}
                }
                else
                {
                    throw new Exception("单据状态有误");
                    throw new Exception("未查到对应出库类型的物料");
                }
                //skuList = sku.Select(m => m.SkuNo).ToList();
                var stockRst = new StockServer();
@@ -2256,11 +2272,11 @@
                        }
                        #endregion
                        //取合适库存商品
                        Dictionary<int, int> stockQtyDic = new Dictionary<int, int>();//托出库物品数
                        Dictionary<int, decimal> stockQtyDic = new Dictionary<int, decimal>();//托出库物品数
                        Dictionary<string, int> zxQtyDic = new Dictionary<string, int>();//托出整箱数
                        //分配货物
                        //assign.AllocatePallets(stocks, pNum, bNum, needQty, stockQtyDic, zxQtyDic);
                        int qty = assign.AllotPallets(stockDetail, int.Parse(needQty.ToString()), pNum, bNum, stockQtyDic);
                        var qty = assign.AllotPallets(stockDetail, decimal.Parse(needQty.ToString()), pNum, bNum, stockQtyDic);
                        foreach (var sc in stockQtyDic)
                        {
@@ -2678,8 +2694,8 @@
                //修改出库单状态 
                if (notice.Status == "0" || notice.Status == "1")
                {
                    int totalQty = 0;
                    int totalAllotQty = 0;
                    decimal totalQty = 0;
                    decimal totalAllotQty = 0;
                    foreach (var item in detailList)
                    {
                        totalQty += item.Qty;
@@ -2711,5 +2727,58 @@
        #endregion
        /// <summary>
        /// 判断出库是否需要拆箱
        /// </summary>
        /// <param name="soNo"></param>
        /// <returns></returns>
        public string IsNeedUnpack(string soNo)
        {
            string result = "0";//是否需要拆箱,0:否  1:是
            if (string.IsNullOrEmpty(soNo))
            {
                throw new Exception("未找到对应出库单!");
            }
            try
            {
                var notice = Db.Queryable<BllExportNotice>().First(w => w.IsDel == "0" && w.SONo == soNo);
                if (notice == null)
                {
                    throw new Exception("未找到对应出库单!");
                }
                //物料编码表
                var skuList = Db.Queryable<SysMaterials>().Where(w => w.IsDel == "0");
                //包装表
                var packagList= Db.Queryable<SysPackag>().Where(w => w.IsDel == "0");
                //出库分配信息
                var allotList = Db.Queryable<BllExportAllot>().Where(w => w.IsDel == "0" && w.SONo == soNo).ToList();
                foreach (var item in allotList)
                {
                    var skuInfo = skuList.First(w => w.SkuNo == item.SkuNo);
                    if (skuInfo == null)
                    {
                        throw new Exception("物料信息不存在!");
                    }
                    var packagInfo = packagList.First(w => w.PackagNo == skuInfo.PackagNo);
                    if (packagInfo == null)
                    {
                        throw new Exception("包装信息不存在!");
                    }
                    if (packagInfo.L2Name == "箱")
                    {
                        if (item.Qty % (decimal)packagInfo.L2Num != 0)//能整除说明不用拆箱,不能整除说明需要拆箱
                        {
                            result = "1";//需要拆箱
                            break;
                        }
                    }
                }
                return result;
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
    }
}