| | |
| | | /// <param name="warehouseno">库区</param> |
| | | /// <param name="type">叫料类型</param> |
| | | /// <returns></returns> |
| | | public void GetPalletNo(Pallnetmsg pallnetmsg,string url) |
| | | public void GetPalletNo(Pallnetmsg model,string url) |
| | | { |
| | | DataStockDetail pallet = new DataStockDetail(); |
| | | try |
| | | { |
| | | if (string.IsNullOrEmpty(pallnetmsg.Location)) |
| | | if (string.IsNullOrEmpty(model.Location)) |
| | | { |
| | | throw new Exception("设备位置不可为空"); |
| | | throw new Exception("设备所在位置不可为空"); |
| | | } |
| | | var locatInfo = Db.Queryable<SysStorageLocat>().First(w => w.IsDel == "0" && w.LocatNo == pallnetmsg.Location); |
| | | var locatInfo = Db.Queryable<SysStorageLocat>().First(w => w.IsDel == "0" && w.LocatNo == model.Location); |
| | | if (locatInfo == null) |
| | | { |
| | | throw new Exception("设备储位信息不存在"); |
| | |
| | | var urlMes = "";//回传MES的接口地址 |
| | | var noticeno = "0";//出入库单据明细ID |
| | | var sql = "select PalletNo,LocatNo from DataStockDetail where Status = '0'"; |
| | | switch (pallnetmsg.Type) |
| | | switch (model.Type) |
| | | { |
| | | case "0"://叫净桶 |
| | | sql += $"and WareHouseNo = '{house}' and (AreaNo like '%01' or AreaNo like '%11' or AreaNo like '%21' or AreaNo like '%31') and PalletStatus = '0' order by CreateTime desc"; |
| | |
| | | break; |
| | | case "1"://叫料桶(混料) |
| | | //判断是否有批次号 |
| | | if (string.IsNullOrWhiteSpace(pallnetmsg.LotNo)) |
| | | if (string.IsNullOrWhiteSpace(model.LotNo)) |
| | | { |
| | | throw new Exception("批次号为空!"); |
| | | } |
| | |
| | | } |
| | | noticeno = ArriveMes.Id.ToString();*/ |
| | | //查找库存中是否有可用的此批次的混料桶 |
| | | sql= $@"select PalletNo,LocatNo from DataStockDetail where LotNo = '{pallnetmsg.LotNo}'and (AreaNo like '%02' or AreaNo like '%12' or AreaNo like '%22' or AreaNo like '%32') |
| | | 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"; |
| | | pallet = Db.Ado.SqlQuery<DataStockDetail>(sql).FirstOrDefault(); |
| | | if (pallet == null) |
| | |
| | | case "2"://叫料桶(下料) |
| | | BllExportNoticeDetail bllSo = new BllExportNoticeDetail(); |
| | | //判断是否有批次号 |
| | | if (string.IsNullOrWhiteSpace(pallnetmsg.LotNo)) |
| | | if (string.IsNullOrWhiteSpace(model.LotNo)) |
| | | { |
| | | throw new Exception("批次号为空!"); |
| | | } |
| | | //查找是否有此批次出库单 |
| | | sql = $"select * from BllExportNoticeDetail where LotNo = '{pallnetmsg.LotNo}' order by CreateTime desc"; |
| | | sql = $"select * from BllExportNoticeDetail where LotNo = '{model.LotNo}' order by CreateTime desc"; |
| | | bllSo = Db.Ado.SqlQuery<BllExportNoticeDetail>(sql).FirstOrDefault(); |
| | | if (bllSo == null) |
| | | { |
| | |
| | | } |
| | | noticeno = bllSo.Id.ToString(); |
| | | //查找库存中是否有此批次的合格下料桶 |
| | | sql = $@"select PalletNo,LocatNo from DataStockDetail where LotNo = '{pallnetmsg.LotNo}'and (AreaNo like '%03' or AreaNo like '%13' or AreaNo like '%23' or AreaNo like '%33') |
| | | sql = $@"select PalletNo,LocatNo from DataStockDetail where LotNo = '{model.LotNo}'and (AreaNo like '%03' or AreaNo like '%13' or AreaNo like '%23' or AreaNo like '%33') |
| | | and WareHouseNo = '{house}' and status = '0' and PalletStatus = '2' and InspectStatus = '1' order by CompleteTime desc"; |
| | | pallet = Db.Ado.SqlQuery<DataStockDetail>(sql).FirstOrDefault(); |
| | | if (pallet == null) |
| | |
| | | // var task2 = new TaskDetial |
| | | // { |
| | | // Startport = item.LocatNo, |
| | | // Endport = pallnetmsg.Location, |
| | | // Endport = model.Location, |
| | | // Pallno = item.PalletNo, |
| | | // Type = pallnetmsg.Type, |
| | | // Type = model.Type, |
| | | // Crtype = "1", |
| | | // Noticedetailno = int.Parse(noticeno), |
| | | // }; |
| | |
| | | var task2 = new TaskDetial |
| | | { |
| | | Startport = item.LocatNo, |
| | | Endport = pallnetmsg.Location, |
| | | Endport = model.Location, |
| | | Pallno = item.PalletNo, |
| | | Type = pallnetmsg.Type, |
| | | Type = model.Type, |
| | | Crtype = "1", |
| | | Noticedetailno = int.Parse(noticeno), |
| | | }; |
| | |
| | | var task = new TaskDetial |
| | | { |
| | | Startport = pallet.LocatNo,//起始位置 |
| | | Endport = pallnetmsg.Location,//目标位置 |
| | | Endport = model.Location,//目标位置 |
| | | Pallno = pallet.PalletNo,//桶号 |
| | | Type = pallnetmsg.Type,//桶类型 |
| | | Type = model.Type,//桶类型 |
| | | Crtype = "1", |
| | | Noticedetailno = int.Parse(noticeno), |
| | | LotNo = pallnetmsg.LotNo, |
| | | LotNo = model.LotNo, |
| | | }; |
| | | CreateLotTask(task, url); |
| | | return; |
| | |
| | | catch (Exception ex) |
| | | { |
| | | Db.Ado.RollbackTran(); |
| | | throw ex; |
| | | throw new Exception(ex.Message); |
| | | } |
| | | } |
| | | |
| | |
| | | /// </summary> |
| | | /// <param name="PalletNo"></param> |
| | | /// <returns></returns> |
| | | public void ApplyLocatNo(Pallnetmsg pallnetmsg,string url) |
| | | public void ApplyLocatNo(Pallnetmsg model,string url) |
| | | { |
| | | var sql = $"select LocatNo from SysStorageLocat where status = '0'"; |
| | | var sql2 = ""; |
| | | var house = "W01";//……叫桶位置,后续根据位置关联或定义,来判断叫桶位置所属车间 |
| | | var houseNo = "";//申请储位设备所在车间编号 |
| | | var noticeno = "0";//出入库单据明细ID |
| | | SysStorageLocat loction = new SysStorageLocat(); |
| | | BllArrivalNoticeDetail ArriveMes = new BllArrivalNoticeDetail(); |
| | | SysStorageLocat loction = new SysStorageLocat();//目标储位信息 |
| | | BllArrivalNoticeDetail noticeDetail = new BllArrivalNoticeDetail();//入库单明细 |
| | | try |
| | | { |
| | | //区域信息 |
| | | var areaInfo = Db.Queryable<SysStorageArea>().First(w => w.IsDel == "0" && w.DeviceCode == pallnetmsg.Location); |
| | | house = areaInfo.WareHouseNo;//所属仓库 |
| | | switch (pallnetmsg.Type) |
| | | //设备所在储位信息 |
| | | var deviceLocatInfo = Db.Queryable<SysStorageLocat>().First(w => w.IsDel == "0" && w.LocatNo == model.LotNo); |
| | | if (deviceLocatInfo == null) |
| | | { |
| | | case "0"://净桶申请储位 |
| | | sql += $"and (AreaNo like '%01' or AreaNo like '%11' or AreaNo like '%21' or AreaNo like '%31') and WareHouseNo = '{house}'"; |
| | | throw new Exception($"未查询到该设备所在储位信息,Location:{model.Location}"); |
| | | } |
| | | houseNo = deviceLocatInfo.WareHouseNo;//设备所属车间 |
| | | switch (model.Type) |
| | | { |
| | | case "3"://清洗设备申请储位(净桶申请储位) |
| | | sql += $" and (AreaNo like '%01' or AreaNo like '%11' or AreaNo like '%21' or AreaNo like '%31') and WareHouseNo = '{houseNo}'"; |
| | | loction = Db.Ado.SqlQuery<SysStorageLocat>(sql).OrderByDescending(a => a.CreateTime).FirstOrDefault(); |
| | | if (loction == null) |
| | | { |
| | | throw new Exception("库内暂无空余净桶储位"); |
| | | throw new Exception("该车间净桶区暂无空余储位"); |
| | | } |
| | | break; |
| | | case "1"://混料桶申请储位 |
| | | case "0"://接料设备申请储位(混料桶申请储位) |
| | | //判断是否有批次号 |
| | | if (string.IsNullOrWhiteSpace(pallnetmsg.LotNo)) |
| | | if (string.IsNullOrWhiteSpace(model.LotNo)) |
| | | { |
| | | 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) |
| | | noticeDetail = Db.Ado.SqlQuery<BllArrivalNoticeDetail>(sql).FirstOrDefault(); |
| | | if (noticeDetail == null) |
| | | { |
| | | throw new Exception("该批次没有对应的入库单"); |
| | | } |
| | | noticeno = ArriveMes.Id.ToString();*/ |
| | | sql += $"and (AreaNo like '%02' or AreaNo like '%12' or AreaNo like '%22' or AreaNo like '%32') and WareHouseNo = '{house}'"; |
| | | 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) |
| | | { |
| | | throw new Exception("库内暂无空余混料桶储位"); |
| | | throw new Exception("该车间预混区暂无空余储位"); |
| | | } |
| | | break; |
| | | case "2"://半成品桶申请储位 |
| | | case "1"://混料设备申请储位(半成品桶申请储位) |
| | | //判断是否有批次号 |
| | | if (string.IsNullOrWhiteSpace(pallnetmsg.LotNo)) |
| | | if (string.IsNullOrWhiteSpace(model.LotNo)) |
| | | { |
| | | throw new Exception("批次号为空!"); |
| | | } |
| | | //校验此批次是否有入库单 |
| | | sql2 = $"select * from BllArrivalNoticeDetail where LotNo = '{pallnetmsg.LotNo}' order by CreateTime desc"; |
| | | ArriveMes = Db.Ado.SqlQuery<BllArrivalNoticeDetail>(sql2).FirstOrDefault(); |
| | | if (ArriveMes == null) |
| | | sql2 = $"select * from BllArrivalNoticeDetail where LotNo = '{model.LotNo}' order by CreateTime desc"; |
| | | noticeDetail = Db.Ado.SqlQuery<BllArrivalNoticeDetail>(sql2).FirstOrDefault(); |
| | | if (noticeDetail == null) |
| | | { |
| | | throw new Exception("该批次没有对应的入库单"); |
| | | } |
| | | noticeno = ArriveMes.Id.ToString(); |
| | | sql += $"and (AreaNo like '%03' or AreaNo like '%13' or AreaNo like '%23' or AreaNo like '%33') and WareHouseNo = '{house}'"; |
| | | noticeno = noticeDetail.Id.ToString(); |
| | | sql += $" and (AreaNo like '%03' or AreaNo like '%13' or AreaNo like '%23' or AreaNo like '%33') and WareHouseNo = '{houseNo}'"; |
| | | loction = Db.Ado.SqlQuery<SysStorageLocat>(sql).OrderByDescending(a => a.CreateTime).FirstOrDefault(); |
| | | if (loction == null) |
| | | { |
| | | throw new Exception("库内暂无空余半成品桶储位"); |
| | | throw new Exception("该车间半成品区暂无空余储位"); |
| | | } |
| | | break; |
| | | case "3"://脏桶申请储位 |
| | | sql += $"and (AreaNo like '%04' or AreaNo like '%14' or AreaNo like '%24' or AreaNo like '%34') and WareHouseNo = '{house}'"; |
| | | case "2"://下料设备申请储位(脏桶申请储位) |
| | | sql += $" and (AreaNo like '%04' or AreaNo like '%14' or AreaNo like '%24' or AreaNo like '%34') and WareHouseNo = '{houseNo}'"; |
| | | loction = Db.Ado.SqlQuery<SysStorageLocat>(sql).OrderByDescending(a => a.CreateTime).FirstOrDefault(); |
| | | if (loction == null) |
| | | { |
| | | throw new Exception("库内暂无空余脏桶储位"); |
| | | throw new Exception("该车间脏桶区暂无空余储位"); |
| | | } |
| | | break; |
| | | } |
| | | var task = new TaskDetial |
| | | { |
| | | Startport = pallnetmsg.Location, |
| | | Startport = model.Location, |
| | | Endport = loction.LocatNo, |
| | | Pallno = pallnetmsg.PalletNo, |
| | | Type = pallnetmsg.Type, |
| | | Pallno = model.PalletNo, |
| | | Type = model.Type, |
| | | Crtype = "0", |
| | | Noticedetailno = int.Parse(noticeno), |
| | | LotNo = pallnetmsg.LotNo, |
| | | LotNo = model.LotNo, |
| | | }; |
| | | CreateLotTask(task,url); |
| | | } |
| | | catch (Exception) |
| | | catch (Exception ex) |
| | | { |
| | | |
| | | throw; |
| | | throw new Exception(ex.Message); |
| | | } |
| | | } |
| | | |
| | |
| | | { |
| | | //开启事务 |
| | | Db.BeginTran(); |
| | | var na = ""; |
| | | var typeDesc = ""; |
| | | switch (taskDetial.Crtype) |
| | | { |
| | | case "0": |
| | | na = "入库"; |
| | | typeDesc = "入库"; |
| | | break; |
| | | case "1": |
| | | na = "出库"; |
| | | typeDesc = "出库"; |
| | | break; |
| | | case "2": |
| | | na = "移库"; |
| | | typeDesc = "移库"; |
| | | break; |
| | | } |
| | | var bz = ""; |
| | | var msg = ""; |
| | | switch (taskDetial.Type) |
| | | { |
| | | case "0": |
| | | bz = "净桶"+na+"任务"; |
| | | msg = "净桶"+ typeDesc + "任务"; |
| | | break; |
| | | case "1": |
| | | bz = "预混料桶" + na + "任务"; |
| | | msg = "预混料桶" + typeDesc + "任务"; |
| | | break; |
| | | case "2": |
| | | bz = "半成品料桶" + na + "任务"; |
| | | msg = "半成品料桶" + typeDesc + "任务"; |
| | | break; |
| | | case "3": |
| | | bz = "脏桶" + na + "任务"; |
| | | msg = "脏桶" + typeDesc + "任务"; |
| | | break; |
| | | } |
| | | var sql = ""; |
| | |
| | | OrderType = ordertype,//单据类型 0 入库 1 出库 3其他 |
| | | Status = "0",//任务状态0:等待执行1正在执行2执行完成 |
| | | NoticeDetailNo = int.Parse(taskDetial.Noticedetailno.ToString()), |
| | | Msg = bz, //关键信息 |
| | | Msg = msg, //关键信息 |
| | | }; |
| | | |
| | | #region 呼叫小车代码 |