chengsc
2024-08-27 5f3129c47cc8d3aa9ddffb2c468d908f2416e544
Wms/WMS.BLL/BllAsnServer/ArrivalNoticeServer.cs
@@ -17,6 +17,7 @@
using WMS.Entity.Context;
using WMS.Entity.SysEntity;
using WMS.IBLL.IBllAsnServer;
using WMS.BLL.SysServer;
namespace WMS.BLL.BllAsnServer
{
@@ -869,11 +870,11 @@
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public ErpModel CreateAsn(AsnInfo model)
        public HttpReturnModel HttpCreateAsn(AsnInfo model)
        {
            try
            {
                var resultModel = new ErpModel() { Success = -1, Message = "" };
                var resultModel = new HttpReturnModel() { Success = "-1", Message = "" };
                if (string.IsNullOrEmpty(model.AsnType))
                {
                    resultModel.Message = "单据类型不可为空!";
@@ -972,7 +973,7 @@
                Db.Insertable(detailModels).ExecuteCommand();
                Db.CommitTran();
                resultModel.Success = 0;
                resultModel.Success = "0";
                resultModel.Message = "成功";
                return resultModel;
            }
@@ -984,7 +985,7 @@
        }
        //订单回传上游系统
        public bool FinishAsn(int id, string erpUrl, string mesUrl, int userId)
        public bool FinishAsn(int id, string erpUrl, string mesUrl,string mesTokenUrl, int userId)
        {
            try
            {
@@ -1019,7 +1020,7 @@
                    };
                    list.Add(item);
                }
                var soInfo = new AsnInfo()
                var asnInfo = new AsnInfo()
                {
                    OrderCode = notice.OrderCode,
                    AsnDetails = list
@@ -1027,18 +1028,31 @@
                #region 通过接口发送至erp 或 mes
                //系统对接后放开
                var jsonData = JsonConvert.SerializeObject(soInfo);
                var jsonData = JsonConvert.SerializeObject(asnInfo);
                var mesList = new List<string>() { "0", "4" };  //0 成品入库 4余料退回入库
                var erpList = new List<string>() { "1", "2", "3" }; //1 采购入库  2中间品入库  3 退货入库
                if (mesList.Contains(notice.Type)) // mes 
                {
                    var response = HttpHelper.DoPost(mesUrl, jsonData, "入库单完成上传", "MES");
                    //获取令牌
                    var token = new Token().GetMesToken(mesTokenUrl);
                    Dictionary<string, string> mesDic = new Dictionary<string, string>()
                    {
                        {"Authorization",token }
                    };
                    var mesData = new FinishAsnModel()
                    {
                        no = asnInfo.OrderCode,
                        qty = asnInfo.AsnDetails.Sum(m=>m.Qty)
                    };
                    jsonData = JsonConvert.SerializeObject(mesData);
                    //调用接口
                    var response = HttpHelper.DoPost(mesUrl, jsonData, "入库单完成上传", "MES", mesDic);
                    var obj = JsonConvert.DeserializeObject<MesModel>(response);//解析返回数据
                    if (obj.Success != 0)
                    if (obj.status != "0")
                    {
                        throw new Exception("上传失败" + obj.Message);
                        throw new Exception("上传失败" + obj.message);
                    }
                }
                else if (erpList.Contains(notice.Type)) //erp  
@@ -1069,6 +1083,29 @@
            }
        }
        public void UpLocate(string wareNo,string locatNo)
        {
            try
            {
                if (string.IsNullOrWhiteSpace(wareNo) || string.IsNullOrWhiteSpace(locatNo))
                {
                    throw new Exception("仓库或储位不能为空");
                }
                var locate = Db.Queryable<SysStorageLocat>().First(m=>m.IsDel == "0" && m.LocatNo == locatNo && m.WareHouseNo == wareNo);
                if (locate == null)
                {
                    throw new Exception("未查询到储位信息");
                }
                locate.Status = "0";//储位状态变更空储位
                Db.Updateable(locate).ExecuteCommand();
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }
        }
        #endregion
    }