| | |
| | | using Utility.Tools; |
| | | using WMS.DAL; |
| | | using WMS.Entity.BllAsnEntity; |
| | | using WMS.Entity.BllSoEntity; |
| | | using WMS.Entity.Context; |
| | | using WMS.Entity.DataEntity; |
| | | using WMS.Entity.LogEntity; |
| | |
| | | { |
| | | var house = "W01";//叫桶位置,后续根据位置关联或定义,来判断叫桶位置所属车间 |
| | | var url = "";//回传MES的接口地址 |
| | | var noticeno = ""; |
| | | var noticeno = "";//出入库单据明细ID |
| | | var sql = "select PalletNo,LocatNo from DataStockDetail where Status = '0'"; |
| | | switch (pallnetmsg.Type) |
| | | { |
| | |
| | | { |
| | | Startport = item.LocatNo, |
| | | Endport = locat.LocatNo, |
| | | Pallno = pallnetmsg.Palletno, |
| | | Pallno = item.PalletNo, |
| | | Type = "4", |
| | | Crtype = "0", |
| | | Noticedetailno = int.Parse(noticeno), |
| | |
| | | { |
| | | throw new Exception("批次号为空!"); |
| | | } |
| | | BllArrivalNoticeDetail ArriveMes = new BllArrivalNoticeDetail(); |
| | | /*BllArrivalNoticeDetail ArriveMes = new BllArrivalNoticeDetail(); |
| | | //判断该批次是否有对应入库单 |
| | | sql = $"select * from BllArrivalNoticeDetail where LotNo = '{pallnetmsg.LotNo}' order by CreateTime desc"; |
| | | ArriveMes = Db.Ado.SqlQuery<BllArrivalNoticeDetail>(sql).FirstOrDefault(); |
| | |
| | | { |
| | | throw new Exception("该批次没有对应的入库单"); |
| | | } |
| | | noticeno = ArriveMes.Id.ToString();*/ |
| | | //查找库存中是否有可用的此批次的混料桶 |
| | | sql += $"where a.LotNo = '{pallnetmsg.LotNo}'and AreaNo like '%02' and a.WareHouseNo = '{house}' and b.status = '0' " + |
| | | $"order by CompleteTime desc"; |
| | | sql= $"select PalletNo,LocatNo from DataStockDetail where a.LotNo = '{pallnetmsg.LotNo}'and AreaNo like '%02' " + |
| | | $"and a.WareHouseNo = '{house}' and b.status = '0' order by CompleteTime desc"; |
| | | pallet = Db.Ado.SqlQuery<DataStockDetail>(sql).FirstOrDefault(); |
| | | if (pallet == null) |
| | | { |
| | |
| | | |
| | | break; |
| | | case "2"://叫料桶(下料) |
| | | BllExportNoticeDetail bllSo = new BllExportNoticeDetail(); |
| | | //判断是否有批次号 |
| | | if (string.IsNullOrWhiteSpace(pallnetmsg.LotNo)) |
| | | { |
| | | throw new Exception("批次号为空!"); |
| | | } |
| | | //查找是否有此批次出库单 |
| | | sql = $"select * from BllSoNoticeDetail where LotNo = '{pallnetmsg.LotNo}' order by CreateTime desc"; |
| | | bllSo = Db.Ado.SqlQuery<BllExportNoticeDetail>(sql).FirstOrDefault(); |
| | | if (bllSo == null) |
| | | { |
| | | throw new Exception("该批次没有对应的出库单"); |
| | | } |
| | | noticeno = bllSo.Id.ToString(); |
| | | //查找库存中是否有此批次的下料桶 |
| | | sql += $"where a.LotNo = '{pallnetmsg.LotNo}'and AreaNo like '%03' and a.WareHouseNo = '{house}' and b.status = '0' " + |
| | | $"order by CompleteTime desc"; |
| | | sql += $"select PalletNo,LocatNo from DataStockDetail where a.LotNo = '{pallnetmsg.LotNo}'and AreaNo like '%03' " + |
| | | $"and a.WareHouseNo = '{house}' and b.status = '0' order by CompleteTime desc"; |
| | | pallet = Db.Ado.SqlQuery<DataStockDetail>(sql).FirstOrDefault(); |
| | | if (pallet == null) |
| | | { |
| | |
| | | { |
| | | Startport = pallnetmsg.Location, |
| | | Endport = pallet.LocatNo, |
| | | Pallno = pallnetmsg.Palletno, |
| | | Pallno = pallet.PackagNo, |
| | | Type = pallnetmsg.Type, |
| | | Crtype = "1", |
| | | Noticedetailno = int.Parse(noticeno), |
| | | }; |
| | | CreateLotTask(task); |
| | | return; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | |
| | | public void ApplyLocatNo(Pallnetmsg pallnetmsg) |
| | | { |
| | | var sql = $"select LocatNo from SysStorageLocat where status = '0'"; |
| | | var sql2 = ""; |
| | | var house = "W01";//……叫桶位置,后续根据位置关联或定义,来判断叫桶位置所属车间 |
| | | var noticeno = ""; |
| | | var noticeno = "";//出入库单据明细ID |
| | | SysStorageLocat loction = new SysStorageLocat(); |
| | | BllArrivalNoticeDetail ArriveMes = new BllArrivalNoticeDetail(); |
| | | try |
| | | { |
| | | switch (pallnetmsg.Type) |
| | |
| | | { |
| | | throw new Exception("批次号为空!"); |
| | | } |
| | | //校验此批次是否有入库单 |
| | | /*sql2 = $"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 += $"and AreaNo like '%02' and WareHouseNo = {house}"; |
| | | loction = Db.Ado.SqlQuery<SysStorageLocat>(sql).OrderByDescending(a => a.CreateTime).FirstOrDefault(); |
| | | if (loction == null) |
| | |
| | | { |
| | | throw new Exception("批次号为空!"); |
| | | } |
| | | //校验此批次是否有入库单 |
| | | sql2 = $"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 += $"and AreaNo like '%03' and WareHouseNo = {house}"; |
| | | loction = Db.Ado.SqlQuery<SysStorageLocat>(sql).OrderByDescending(a => a.CreateTime).FirstOrDefault(); |
| | | if (loction == null) |
| | |
| | | Endport = loction.LocatNo, |
| | | Pallno = pallnetmsg.Palletno, |
| | | Type = pallnetmsg.Type, |
| | | Crtype = "1", |
| | | Crtype = "0", |
| | | Noticedetailno = int.Parse(noticeno), |
| | | }; |
| | | CreateLotTask(task); |
| | |
| | | { |
| | | var na = taskDetial.Crtype == "0"?"入库":"出库"; |
| | | var sql = ""; |
| | | var sql2 = ""; |
| | | //开启事务 |
| | | Db.BeginTran(); |
| | | //判断任务是否为新任务 |
| | |
| | | } |
| | | sql = $"UPDATE LogTask SET IsSuccess = 1,BackDate = {DateTime.Now},Status = '1' WHERE TaskNo = {taskDetial.Taskno}"; |
| | | Db.Ado.ExecuteCommand(sql); |
| | | if (taskDetial.Crtype == "0") |
| | | { |
| | | sql = $"UPDATE SysStorageLocat SET Status = '2' where LocatNo = '{taskDetial.Endport}'"; |
| | | 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}' "; |
| | | } |
| | | Db.Ado.ExecuteCommand(sql); |
| | | //提交事务 |
| | | Db.CommitTran(); |
| | | } |