| | |
| | | /// <param name="warehouseno">库区</param> |
| | | /// <param name="type">叫料类型</param> |
| | | /// <returns></returns> |
| | | public void GetPalletNo(Pallnetmsg model,string url) |
| | | public void GetPalletNo(Pallnetmsg model,string url,out string taskNo) |
| | | { |
| | | DataStockDetail pallet = new DataStockDetail(); |
| | | try |
| | |
| | | { |
| | | throw new Exception("批次号为空!"); |
| | | } |
| | | /*BllArrivalNoticeDetail ArriveMes = new BllArrivalNoticeDetail(); |
| | | //判断该批次是否有对应入库单 |
| | | sql = $"select * from BllArrivalNoticeDetail where LotNo = '{pallnetmsg.LotNo}' order by CreateTime desc"; |
| | | ArriveMes = Db.Ado.SqlQuery<BllArrivalNoticeDetail>(sql).FirstOrDefault(); |
| | | if (ArriveMes == null) |
| | | { |
| | | throw new Exception("该批次没有对应的入库单"); |
| | | } |
| | | noticeno = ArriveMes.Id.ToString();*/ |
| | | //查找库存中是否有可用的此批次的混料桶 |
| | | sql= $@"select PalletNo,LocatNo from DataStockDetail where LotNo = '{model.LotNo}'and (AreaNo like '%02' or AreaNo like '%12' or AreaNo like '%22' or AreaNo like '%32') |
| | | and WareHouseNo = '{house}' and status = '0' and PalletStatus = '1' order by CompleteTime desc"; |
| | |
| | | Crtype = "1", |
| | | Noticedetailno = int.Parse(noticeno), |
| | | }; |
| | | CreateLotTask(task2, url); |
| | | CreateLotTask(task2, url, out taskNo); |
| | | return; |
| | | } |
| | | break; |
| | |
| | | Noticedetailno = int.Parse(noticeno), |
| | | LotNo = model.LotNo, |
| | | }; |
| | | CreateLotTask(task, url); |
| | | CreateLotTask(task, url, out taskNo); |
| | | return; |
| | | } |
| | | catch (Exception ex) |
| | |
| | | Crtype = "2", |
| | | Noticedetailno = 0, |
| | | }; |
| | | CreateLotTask(ztask,url); |
| | | string taskNo = ""; |
| | | CreateLotTask(ztask, url, out taskNo); |
| | | |
| | | statrtLocat.Status = "3";//出库中 |
| | | //修改起始储位状态 |
| | |
| | | Noticedetailno = 0, |
| | | LotNo = "", |
| | | }; |
| | | CreateLotTask(task,url); |
| | | string taskNo = ""; |
| | | CreateLotTask(task,url, out taskNo); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | |
| | | /// </summary> |
| | | /// <param name="PalletNo"></param> |
| | | /// <returns></returns> |
| | | public void ApplyLocatNo(Pallnetmsg model,string url) |
| | | public void ApplyLocatNo(Pallnetmsg model,string url, out string taskNo) |
| | | { |
| | | var sql = $"select LocatNo from SysStorageLocat where status = '0'"; |
| | | var sql2 = ""; |
| | |
| | | throw new Exception("该车间净桶区暂无空余储位"); |
| | | } |
| | | break; |
| | | case "0"://接料设备申请储位(混料桶申请储位) |
| | | case "0"://接料设备申请储位(预混料桶申请储位) |
| | | //判断是否有批次号 |
| | | if (string.IsNullOrWhiteSpace(model.LotNo)) |
| | | { |
| | | throw new Exception("批次号为空!"); |
| | | } |
| | | //校验此批次是否有入库单 |
| | | /*sql2 = $"select * from BllArrivalNoticeDetail where LotNo = '{pallnetmsg.LotNo}' order by CreateTime desc"; |
| | | noticeDetail = Db.Ado.SqlQuery<BllArrivalNoticeDetail>(sql).FirstOrDefault(); |
| | | if (noticeDetail == null) |
| | | { |
| | | throw new Exception("该批次没有对应的入库单"); |
| | | } |
| | | noticeno = noticeDetail.Id.ToString();*/ |
| | | sql += $" and (AreaNo like '%02' or AreaNo like '%12' or AreaNo like '%22' or AreaNo like '%32') and WareHouseNo = '{houseNo}'"; |
| | | loction = Db.Ado.SqlQuery<SysStorageLocat>(sql).OrderByDescending(a => a.CreateTime).FirstOrDefault(); |
| | | if (loction == null) |
| | |
| | | Endport = loction.LocatNo, |
| | | Pallno = model.PalletNo, |
| | | Type = model.Type, |
| | | Crtype = "0", |
| | | Crtype = "0",//入库 |
| | | Noticedetailno = int.Parse(noticeno), |
| | | LotNo = model.LotNo, |
| | | }; |
| | | CreateLotTask(task,url); |
| | | CreateLotTask(task, url, out taskNo); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | |
| | | /// </summary> |
| | | /// <param name="req"></param> |
| | | /// <returns></returns> |
| | | public void CreateLotTask(TaskDetial taskDetial,string url) |
| | | public void CreateLotTask(TaskDetial taskDetial,string url,out string taskNo) |
| | | { |
| | | try |
| | | { |
| | | var stockDetail = Db.Queryable<DataStockDetail>().First(w => w.IsDel == "0" && w.PalletNo == taskDetial.Pallno);//桶库存明细 |
| | | if (stockDetail == null) |
| | | { |
| | | throw new Exception($"该桶未在库存中,桶号:{taskDetial.Pallno}"); |
| | | } |
| | | //开启事务 |
| | | Db.BeginTran(); |
| | | var typeDesc = ""; |
| | |
| | | msg = "脏桶" + typeDesc + "任务"; |
| | | break; |
| | | } |
| | | #region 储位信息 |
| | | //起始储位地址信息 |
| | | var startLoction = Db.Queryable<SysStorageLocat>().First(w => w.IsDel=="0" && w.LocatNo == taskDetial.Startport); |
| | | if (startLoction == null) |
| | | { |
| | | throw new Exception($"起始目标储位信息不存在,桶号:{taskDetial.Startport}"); |
| | | } |
| | | //目标储位地址信息 |
| | | var endLoction = Db.Queryable<SysStorageLocat>().First(w => w.IsDel == "0" && w.LocatNo == taskDetial.Endport); |
| | | if (endLoction == null) |
| | | { |
| | | throw new Exception($"目标目标储位信息不存在,桶号:{taskDetial.Endport}"); |
| | | } |
| | | #endregion |
| | | var sql = ""; |
| | | var sql2 = ""; |
| | | var ordertype = "3"; |
| | | //涉及出入库单据的状态信息改变 |
| | | if (taskDetial.Type == "2" && taskDetial.Crtype =="1")//半成品出库 |
| | | if (taskDetial.Type == "2" && taskDetial.Crtype == "1")//半成品出库 |
| | | { |
| | | ordertype = "1"; |
| | | sql = $"UPDATE BllExportNotice SET Status ='1' " + |
| | | $"where SoNO = (select SoNO from BllExportNoticeDetail where id = {taskDetial.Noticedetailno})"; |
| | | Db.Ado.ExecuteCommand(sql); |
| | | } |
| | | else if(taskDetial.Type =="2" && taskDetial.Crtype == "0")//半成品入库 |
| | | else if (taskDetial.Type == "0" && taskDetial.Crtype == "0")//接料设备申请储位(混料桶申请储位) |
| | | { |
| | | stockDetail.LotNo = taskDetial.LotNo;//批次号 |
| | | //更新桶库存明细批次号 |
| | | Db.Updateable(stockDetail).ExecuteCommand(); |
| | | } |
| | | else if (taskDetial.Type == "1" && taskDetial.Crtype == "0")//混料设备申请储位(半成品桶申请储位) |
| | | { |
| | | ordertype = "0"; |
| | | var ArrivalMsg = Db.Queryable<BllArrivalNoticeDetail>().First(it => it.Id == taskDetial.Noticedetailno); |
| | |
| | | sql2 = $"UPDATE DataStockDetail SET SkuNo = '{ArrivalMsg.SkuNo}',SkuName = '{ArrivalMsg.SkuName}' " + |
| | | $"where PalletNo = '{taskDetial.Pallno}'and LotNo = '{taskDetial.LotNo}'"; |
| | | Db.Ado.ExecuteCommand(sql2); |
| | | } |
| | | else if (taskDetial.Type == "1" && taskDetial.Crtype == "0")//预混桶入库 |
| | | { |
| | | //预混桶入库时添加到库存中此托盘的批次信息 |
| | | sql2 = $"UPDATE DataStockDetail SET LotNo = '{taskDetial.LotNo}' where PalletNo = '{taskDetial.Pallno}'"; |
| | | Db.Ado.ExecuteCommand(sql2); |
| | | } |
| | | } |
| | | |
| | | //判断任务是否为新任务 |
| | | if (string.IsNullOrWhiteSpace(taskDetial.Taskno)) |
| | |
| | | NoticeDetailNo = int.Parse(taskDetial.Noticedetailno.ToString()), |
| | | Msg = msg, //关键信息 |
| | | }; |
| | | taskNo = logTaskEntry.TaskNo; |
| | | |
| | | #region 呼叫小车代码 |
| | | List<AgvSchedulingTask> agvTaskList = new List<AgvSchedulingTask>(); |
| | |
| | | //起始位置 |
| | | PositionCodePath path1 = new PositionCodePath(); |
| | | path1.positionCode = taskDetial.Startport; |
| | | path1.type = "05"; |
| | | |
| | | if (taskDetial.Crtype == "1")//叫桶(桶出库) |
| | | { |
| | | path1.type = "05"; |
| | | } |
| | | else//申请储位(桶入库) |
| | | { |
| | | path1.type = "05"; |
| | | } |
| | | pahtList.Add(path1); |
| | | |
| | | //目标位置 |
| | | PositionCodePath path2 = new PositionCodePath(); |
| | | path2.positionCode = taskDetial.Endport; |
| | | path2.type = "00"; |
| | | |
| | | if (taskDetial.Crtype == "1")//叫桶(桶出库) |
| | | { |
| | | path2.type = "05"; |
| | | } |
| | | else//申请储位(桶入库) |
| | | { |
| | | path2.type = "05"; |
| | | } |
| | | pahtList.Add(path2); |
| | | |
| | | //下车任务单 |
| | | AgvSchedulingTask agvTask = new AgvSchedulingTask(); |
| | | agvTask.reqCode = logTaskEntry.TaskNo;//任务号 |
| | | agvTask.ctnrTyp = "3"; |
| | | agvTask.reqTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");//请求时间 |
| | | agvTask.taskTyp = "Z2";//任务类型 线边到托盘收集器 Z1, 托盘垛申请入库 Z2 |
| | | agvTask.ctnrTyp = "1"; |
| | | agvTask.reqTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");//请求时间 |
| | | agvTask.wbCode = ""; |
| | | agvTask.positionCodePath = pahtList;//小车路径 |
| | | agvTask.podCode = ""; |
| | | agvTask.userCallCode = taskDetial.Endport;//目标位置 |
| | | |
| | | agvTask.userCallCode = "";//taskDetial.Endport;//目标位置 |
| | | if (taskDetial.Crtype == "1")//叫桶(桶出库) |
| | | { |
| | | agvTask.taskTyp = "Z3";//任务类型 线边到托盘收集器 Z1, 托盘垛申请入库 Z2 |
| | | } |
| | | else//申请储位(桶入库) |
| | | { |
| | | agvTask.taskTyp = "Z4";//任务类型 线边到托盘收集器 Z1, 托盘垛申请入库 Z2 |
| | | } |
| | | agvTaskList.Add(agvTask); |
| | | |
| | | // 正式运行程序放开 |
| | |
| | | jsonData = jsonData.Substring(1); |
| | | jsonData = jsonData.Substring(0, jsonData.Length - 1); |
| | | string response = ""; |
| | | |
| | | try |
| | | { |
| | | logTaskEntry.SendDate = DateTime.Now;//发送时间 |
| | |
| | | //请求成功修改任务表相应字段状态 |
| | | logTaskEntry.IsSuccess = 1; |
| | | logTaskEntry.BackDate = DateTime.Now; |
| | | logTaskEntry.Status = "1"; |
| | | if (taskDetial.Crtype == "0" || taskDetial.Crtype == "2") |
| | | { |
| | | sql = $"UPDATE SysStorageLocat SET Status = '2' where LocatNo = '{taskDetial.Endport}'"; |
| | | if (taskDetial.Type == "2") |
| | | { |
| | | sql2 = $"UPDATE DataStockDetail SET PalletStatus = '{taskDetial.Type}'" + |
| | | $"where PalletNo = '{taskDetial.Pallno}'"; |
| | | Db.Ado.ExecuteCommand(sql2); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | sql = $"UPDATE SysStorageLocat SET Status = '3' where LocatNo = '{taskDetial.Startport}' "; |
| | | } |
| | | logTaskEntry.Status = "1"; |
| | | Db.Insertable(logTaskEntry).ExecuteCommand(); |
| | | Db.Ado.ExecuteCommand(sql); |
| | | |
| | | startLoction.Status = "3";//出库中 |
| | | Db.Updateable(startLoction).ExecuteCommand(); |
| | | |
| | | endLoction.Status = "2";//入库中 |
| | | Db.Updateable(endLoction).ExecuteCommand(); |
| | | } |
| | | if (agvModel.Code == "1") |
| | | { |