Administrator
2024-07-03 ea4fe1a6d1decf926292d3d71e7656bbcff4c937
Wms/WMS.BLL/BllTransServer/NoticeServer.cs
@@ -5,6 +5,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Utility.Tools;
using WMS.BLL.LogServer;
using WMS.DAL;
using WMS.Entity.BllAsnEntity;
@@ -15,6 +16,7 @@
using WMS.Entity.LogEntity;
using WMS.Entity.SysEntity;
using WMS.IBLL.IBllTransServer;
using static Model.InterFaceModel.RCSModel;
namespace WMS.BLL.BllTransServer
{
@@ -29,7 +31,7 @@
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public ErpModel CreateAsn(AsnInfo model)
        public ErpModel CreateAsnWork(AsnInfo model)
        {
            try
            {
@@ -55,7 +57,7 @@
                    Origin = string.IsNullOrEmpty(model.Origin) ? "MES" : model.Origin,
                    CustomerNo = model.Customer,
                    CustomerName = "",
                    OrderCode = model.OrderCode,
                    OrderCode = model.OrderCode
                };
                // 入库明细表信息
@@ -127,7 +129,7 @@
        /// <param name="TaskNo"></param>
        /// <param name="Status"></param>
        /// <returns></returns>
        public ErpModel FinishTask(string TaskNo,string Status)
        public ErpModel RCSFinishTask(string TaskNo,string Status)
        {
            try
            {
@@ -163,6 +165,10 @@
                    resultModel.Success = 0;
                    resultModel.Message = "成功";
                    //提交事务
                    Db.CommitTran();
                    return resultModel;
                }
                switch (taskInfo.OrderType)
@@ -232,7 +238,7 @@
                                IsBale = "0",
                                IsBelt = "0",
                                PalletStatus = "1",
                                PalletStatus = "2",
                                IsDel = "0",
                                CreateUser = 0,
@@ -255,7 +261,7 @@
                            sd1.LocatNo = locatInfo.LocatNo;//储位地址
                            sd1.CompleteTime = comTime;
                            sd1.InspectStatus = "0";//待检验
                            sd1.PalletStatus = "1";//预混
                            sd1.PalletStatus = "2";//半成品
                            //修改库存明细
                            Db.Updateable(sd1).ExecuteCommand();
@@ -414,13 +420,6 @@
                            resultModel.Message = "起始储位信息不存在!";
                            return resultModel;
                        }
                        //目标储位信息
                        var endLocatInfo = Db.Queryable<SysStorageLocat>().First(w => w.LocatNo == taskInfo.EndLocat && w.IsDel == "0");
                        if (endLocatInfo == null)
                        {
                            resultModel.Message = "目标储位信息不存在!";
                            return resultModel;
                        }
                        //库存明细
                        var sd2 = Db.Queryable<DataStockDetail>().First(w => w.PalletNo == taskInfo.PalletNo);
                        if (sd2 == null)
@@ -452,10 +451,10 @@
                        sd2.InspectQty = 0;
                        sd2.ASNNo = "";
                        sd2.ASNDetailNo = null;
                        sd2.WareHouseNo = endLocatInfo.WareHouseNo;//所属仓库
                        sd2.RoadwayNo = endLocatInfo.RoadwayNo;//所属巷道
                        sd2.AreaNo = endLocatInfo.AreaNo;//所属区域
                        sd2.LocatNo = endLocatInfo.LocatNo;//储位地址
                        sd2.WareHouseNo = "";//所属仓库
                        sd2.RoadwayNo = "";//所属巷道
                        sd2.AreaNo = "";//所属区域
                        sd2.LocatNo = "";//储位地址
                        sd2.CompleteTime = comTime;
                        //修改库存明细
                        Db.Updateable(sd2).ExecuteCommand();
@@ -464,29 +463,11 @@
                        //修改起始储位状态
                        Db.Updateable(startLocatInfo).ExecuteCommand();
                        endLocatInfo.Status = "1";//有物品
                        //修改目标储位状态
                        Db.Updateable(endLocatInfo).ExecuteCommand();
                        break;
                    #endregion
                    #region 任务完成
                    case "2":
                        //起始储位信息
                        var startLocatInfo2 = Db.Queryable<SysStorageLocat>().First(w => w.LocatNo == taskInfo.StartLocat && w.IsDel == "0");
                        if (startLocatInfo2 == null)
                        {
                            resultModel.Message = "起始储位信息不存在!";
                            return resultModel;
                        }
                        //目标储位信息
                        var endLocatInfo2 = Db.Queryable<SysStorageLocat>().First(w => w.LocatNo == taskInfo.EndLocat && w.IsDel == "0");
                        if (endLocatInfo2 == null)
                        {
                            resultModel.Message = "目标储位信息不存在!";
                            return resultModel;
                        }
                    #region 移库完成
                    case "3":
                        //库存明细
                        var sd3 = Db.Queryable<DataStockDetail>().First(w => w.PalletNo == taskInfo.PalletNo);
                        if (sd3 == null)
@@ -494,37 +475,119 @@
                            resultModel.Message = "库存信息不存在!";
                            return resultModel;
                        }
                        sd3.WareHouseNo = endLocatInfo2.WareHouseNo;//所属仓库
                        sd3.RoadwayNo = endLocatInfo2.RoadwayNo;//所属巷道
                        sd3.AreaNo = endLocatInfo2.AreaNo;//所属区域
                        sd3.LocatNo = endLocatInfo2.LocatNo;//储位地址
                        if (endLocatInfo2.AreaNo == "A01")//洁净区
                        if (taskInfo.Type == "0")//入库任务
                        {
                            sd3.PalletStatus = "0";
                        }
                        else if (endLocatInfo2.AreaNo == "A02")//预混区
                        {
                            sd3.PalletStatus = "1";
                        }
                        else if (endLocatInfo2.AreaNo == "A03")//半成品区
                        {
                            sd3.PalletStatus = "2";
                        }
                        else if (endLocatInfo2.AreaNo == "A04")//脏桶区
                        {
                            sd3.PalletStatus = "3";
                        }
                            //目标储位信息
                            var endLocatInfo2 = Db.Queryable<SysStorageLocat>().First(w => w.LocatNo == taskInfo.EndLocat && w.IsDel == "0");
                            if (endLocatInfo2 == null)
                            {
                                resultModel.Message = "目标储位信息不存在!";
                                return resultModel;
                            }
                            endLocatInfo2.Status = "1";//有物品
                            //修改目标储位状态
                            Db.Updateable(endLocatInfo2).ExecuteCommand();
                            sd3.WareHouseNo = endLocatInfo2.WareHouseNo;//所属仓库
                            sd3.RoadwayNo = endLocatInfo2.RoadwayNo;//所属巷道
                            sd3.AreaNo = endLocatInfo2.AreaNo;//所属区域
                            sd3.LocatNo = endLocatInfo2.LocatNo;//储位地址
                            if (endLocatInfo2.AreaNo.Contains("01"))//洁净区
                            {
                                sd3.PalletStatus = "0";
                            }
                            else if (endLocatInfo2.AreaNo.Contains("02"))//预混区
                            {
                                sd3.PalletStatus = "1";
                            }
                            else if (endLocatInfo2.AreaNo.Contains("03"))//半成品区
                            {
                                sd3.PalletStatus = "2";
                            }
                            else if (endLocatInfo2.AreaNo.Contains("04"))//脏桶区
                            {
                                sd3.PalletStatus = "3";
                                sd3.LotNo = "";//批次
                                sd3.SkuNo = "";
                                sd3.SkuName = "";
                                sd3.InspectStatus = "0";//待检验
                            }
                        }
                        else if (taskInfo.Type == "1")//出库任务
                        {
                            //起始储位信息
                            var startLocatInfo2 = Db.Queryable<SysStorageLocat>().First(w => w.LocatNo == taskInfo.StartLocat && w.IsDel == "0");
                            if (startLocatInfo2 == null)
                            {
                                resultModel.Message = "起始储位信息不存在!";
                                return resultModel;
                            }
                            startLocatInfo2.Status = "0";//空储位
                            //修改起始储位状态
                            Db.Updateable(startLocatInfo2).ExecuteCommand();
                            sd3.WareHouseNo = "";//所属仓库
                            sd3.RoadwayNo = "";//所属巷道
                            sd3.AreaNo = "";//所属区域
                            sd3.LocatNo = "";//储位地址
                        }
                        else if (taskInfo.Type == "2")//移库任务
                        {
                            //起始储位信息
                            var startLocatInfo2 = Db.Queryable<SysStorageLocat>().First(w => w.LocatNo == taskInfo.StartLocat && w.IsDel == "0");
                            if (startLocatInfo2 == null)
                            {
                                resultModel.Message = "起始储位信息不存在!";
                                return resultModel;
                            }
                            startLocatInfo2.Status = "0";//空储位
                            //修改起始储位状态
                            Db.Updateable(startLocatInfo2).ExecuteCommand();
                            //目标储位信息
                            var endLocatInfo2 = Db.Queryable<SysStorageLocat>().First(w => w.LocatNo == taskInfo.EndLocat && w.IsDel == "0");
                            if (endLocatInfo2 == null)
                            {
                                resultModel.Message = "目标储位信息不存在!";
                                return resultModel;
                            }
                            endLocatInfo2.Status = "1";//有物品
                            //修改目标储位状态
                            Db.Updateable(endLocatInfo2).ExecuteCommand();
                            sd3.WareHouseNo = endLocatInfo2.WareHouseNo;//所属仓库
                            sd3.RoadwayNo = endLocatInfo2.RoadwayNo;//所属巷道
                            sd3.AreaNo = endLocatInfo2.AreaNo;//所属区域
                            sd3.LocatNo = endLocatInfo2.LocatNo;//储位地址
                            sd3.Status = "0";
                            if (endLocatInfo2.AreaNo.Contains("01"))//洁净区
                            {
                                sd3.PalletStatus = "0";
                                sd3.Status = "0";
                            }
                            else if (endLocatInfo2.AreaNo.Contains("02"))//预混区
                            {
                                sd3.PalletStatus = "1";
                            }
                            else if (endLocatInfo2.AreaNo.Contains("03"))//半成品区
                            {
                                sd3.PalletStatus = "2";
                            }
                            else if (endLocatInfo2.AreaNo.Contains("04"))//脏桶区
                            {
                                sd3.PalletStatus = "3";
                                sd3.LotNo = "";//批次
                                sd3.SkuNo = "";
                                sd3.SkuName = "";
                                sd3.InspectStatus = "0";//待检验
                            }
                        }
                        //修改库存明细
                        Db.Updateable(sd3).ExecuteCommand();
                        startLocatInfo2.Status = "0";//空储位
                        //修改起始储位状态
                        Db.Updateable(startLocatInfo2).ExecuteCommand();
                        //回传桶状态给MES
                        BackPalletStatus(taskInfo.PalletNo, sd3.PalletStatus);
                        endLocatInfo2.Status = "1";//有物品
                        //修改目标储位状态
                        Db.Updateable(endLocatInfo2).ExecuteCommand();
                        break;    
                    #endregion
                }
@@ -548,11 +611,36 @@
        }
        /// <summary>
        /// 回传桶状态给MES
        /// </summary>
        /// <param name="PalletNo">桶号</param>
        /// <param name="Status">0:净桶 1:预混 2:半成品 3:脏桶</param>
        /// <param name="url"></param>
        public void BackPalletStatus(string PalletNo, string Status,string url="")
        {
            try
            {
                var obj = new
                {
                    PalletNo = PalletNo,
                    Status = Status
                };
                string jsonReq = JsonConvert.SerializeObject(obj);
                var response = HttpHelper.DoPost(url, jsonReq, "回传MES桶状态", "MES").ToString();
                var result = JsonConvert.DeserializeObject<ReMes>(response);//解析返回数据
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        /// <summary>
        /// 下发出库单
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public SoResInfo ErpAddExportNotice(SoInfo model)
        public SoResInfo CreateSoWork(SoInfo model)
        {
            try
            {