wxw
8 小时以前 4c396483d28b24679dff42ae873524b83bd7b68f
Wms/WMS.BLL/BllTransServer/RcsServer.cs
@@ -14,6 +14,7 @@
using WMS.BLL.LogServer;
using WMS.DAL;
using WMS.Entity.BllAsnEntity;
using WMS.Entity.BllQualityEntity;
using WMS.Entity.BllSoEntity;
using WMS.Entity.Context;
using WMS.Entity.DataEntity;
@@ -121,7 +122,7 @@
                                    #region 请求MES接口发送净桶编号
                                    var reObj = new
                                    {
                                        deviceCode = pallet.PackagNo,
                                        deviceCode = pallet.PalletNo,
                                        reqType = "1"
                                    };
                                    string jsonReq = JsonConvert.SerializeObject(reObj);
@@ -234,7 +235,7 @@
                            }
                            break;
                        case "3"://清洗设备叫脏桶
                            {
                            {
                                //叫桶目标储位地址信息
                                endLoction = Db.Queryable<SysStorageLocat>().First(w => w.IsDel == "0" && w.WareHouseNo == houseNo && w.AreaNo == deviceInfo.AreaNo && w.Column == 1);// Column=1 清洗储位,Column=2 清洗完料储位 
                                if (endLoction == null)
@@ -265,6 +266,7 @@
                                    throw new Exception("暂无脏桶可分配");
                                }
                                taskMsg = "设备叫脏桶任务";
                                int callResult = 0;//是否叫脏桶成功
                                //遍历库存脏桶,返回MES验证
                                foreach (var item in palletList)
                                {
@@ -285,6 +287,7 @@
                                            //修改该桶库存状态
                                            Db.Updateable(item).ExecuteCommand();
                                            callResult = 1;
                                            continue;
                                        }
                                    }
@@ -295,76 +298,23 @@
                                    #endregion
                                    item.Status = "2";//分配状态 0:待分配,1:部分分配 , 2:已分配
                                                      //更新桶库存明细
                                    //更新桶库存明细
                                    Db.Updateable(item).ExecuteCommand();
                                    //起始储位地址信息
                                    var startLoction2 = Db.Queryable<SysStorageLocat>().First(w => w.IsDel == "0" && w.LocatNo == item.LocatNo);
                                    if (startLoction2 == null)
                                    {
                                        throw new Exception($"起始目标储位信息不存在,桶号:{item.LocatNo}");
                                    }
                                    taskNo = new Common().GetMaxNo("TN");//任务号
                                    var logTaskEntry2 = new LogTask
                                    {
                                        TaskNo = taskNo,
                                        Sender = "WMS",
                                        Receiver = "RCS",
                                        //IsSuccess = 1, //是否下发成功 0失败 1成功
                                        SendDate = DateTime.Now,  //发送时间
                                                                  //BackDate = DateTime.Now,  //返回时间
                                        StartLocat = item.LocatNo,//起始位置
                                        EndLocat = endLoction.LocatNo,//目标位置
                                        PalletNo = item.PalletNo,//托盘码
                                        IsSend = 1,//是否可再次下发
                                        IsCancel = 1,//是否可取消
                                        IsFinish = 1,//是否可完成
                                        Type = "1",//任务类型 0 入库任务 1 出库任务  2 移库任务
                                        OrderType = "3",//单据类型 0 入库 1 出库 3 移库
                                        Status = "0",//任务状态0:等待执行1正在执行2执行完成
                                        NoticeDetailNo = int.Parse(noticeNo),
                                        Msg = taskMsg, //关键信息
                                        LotNo = item.LotNo//批次号
                                    };
                                    //组织下发小车任务信息
                                    var task2 = new TaskDetial
                                    {
                                        Taskno = taskNo,//任务号
                                        Startport = item.LocatNo,
                                        Endport = model.Location,//endLoction.LocatNo,
                                        Pallno = item.PalletNo,
                                        Crtype = "1",//叫桶
                                        WareHouseNo = houseNo
                                    };
                                    //给下车下发任务
                                    logTaskEntry2.SendDate = DateTime.Now;//发送时间
                                    var agvResult2 = CreateTaskForAgv(task2, url, out agvMsg);
                                    if (agvResult2)//成功
                                    {
                                        //请求成功修改任务表相应字段状态
                                        logTaskEntry2.IsSuccess = 1;
                                        logTaskEntry2.IsSend = 0;
                                        //logTaskEntry2.IsCancel = 0;
                                        logTaskEntry2.BackDate = DateTime.Now;
                                        logTaskEntry2.Status = "1";
                                        Db.Insertable(logTaskEntry2).ExecuteCommand();
                                        startLoction2.Status = "3";//出库中
                                        Db.Updateable(startLoction2).ExecuteCommand();
                                        endLoction.Status = "2";//入库中
                                        Db.Updateable(endLoction).ExecuteCommand();
                                    }
                                    else//失败
                                    {
                                        logTaskEntry2.IsSuccess = 0;
                                        logTaskEntry2.Information = agvMsg;
                                        Db.Insertable(logTaskEntry2).ExecuteCommand();
                                    }
                                    pallet = item;
                                    callResult = 2;
                                    break;
                                }
                                if (callResult == 1)
                                {
                                    //提交事务
                                    Db.CommitTran();
                                    return;
                                    throw new Exception("暂无脏桶可分配");
                                }
                                else if (callResult == 0)
                                {
                                    throw new Exception("暂无脏桶可分配");
                                }
                            }
                            break;
@@ -375,7 +325,7 @@
                    var startLoction = Db.Queryable<SysStorageLocat>().First(w => w.IsDel == "0" && w.LocatNo == pallet.LocatNo);
                    if (startLoction == null)
                    {
                        throw new Exception($"起始目标储位信息不存在,桶号:{pallet.LocatNo}");
                        throw new Exception($"起始目标储位信息不存在,桶号:{pallet.PalletNo}");
                    }
                    taskNo = new Common().GetMaxNo("TN");//任务号
@@ -832,7 +782,7 @@
                        Startport = statrtLocat.LocatNo,//起始位置
                        Endport = endLocat.LocatNo,//目标位置
                        Pallno = detail.PalletNo,
                        Crtype = "0",//入库
                        Crtype = "2",//平层搬运
                        WareHouseNo = detail.WareHouseNo
                    };
                    string agvMsg = string.Empty;
@@ -1621,5 +1571,59 @@
                throw new Exception(e.Message);
            }
        }
        /// <summary>
        /// 质量结果下发
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        /// <exception cref="Exception"></exception>
        public void QualityResult(QualityResultVm model)
        {
            try
            {
                //验证批次号是否为空
                if (string.IsNullOrEmpty(model.LotNo))
                {
                    throw new Exception("批次号不可为空,请核查!");
                }
                //开启事务
                Db.BeginTran();
                BllQualityInspect inspectModel = new BllQualityInspect();
                inspectModel.InspectNo = "";
                inspectModel.ASNNo = "";
                inspectModel.LotNo = model.LotNo;
                inspectModel.IsQualified = model.IsQualified;
                inspectModel.Origin = "LIMS"; //来源
                inspectModel.CreateTime = Db.GetDate(); //创建日期
                inspectModel.SkuNo = ""; //物料号
                inspectModel.SkuName = ""; //物料名称
                inspectModel.PassQty = 0; //合格数量
                inspectModel.FailQty = 0; //不合格数量
                inspectModel.Standard = ""; //规格
                inspectModel.CreateUser = 0;
                //插入质检信息
                Db.Insertable(inspectModel).ExecuteCommand();
                //查找库存明细信息
                List<DataStockDetail> detail = Db.Queryable<DataStockDetail>().Where(m => m.IsDel == "0" && m.LotNo == model.LotNo).ToList();
                foreach (var item in detail)
                {
                    item.InspectStatus = model.IsQualified == "1" ? "1" : "2";//0:待检验,1:合格,2:不合格
                    Db.Updateable(item).ExecuteCommand();
                }
                //提交事务
                Db.CommitTran();
            }
            catch (Exception ex)
            {
                //回滚事务
                Db.RollbackTran();
                throw new Exception(ex.Message);
            }
        }
    }
}