public void Delete(AscmForklift ascmForklift) { try { YnDaoHelper.GetInstance().nHibernateHelper.Delete<AscmForklift>(ascmForklift); } catch (Exception ex) { YnBaseClass2.Helper.LogHelper.GetLog().Error("删除失败(Delete AscmForklift)",ex); throw ex; } }
public ContentResult LogisticsForkliftSave(AscmForklift ascmForklift_Model, int? id) { JsonObjectResult jsonObjectResult = new JsonObjectResult(); try { string userName = string.Empty; if (User.Identity.IsAuthenticated) { userName = User.Identity.Name; } AscmForklift ascmForklift = null; if (id.HasValue) { ascmForklift = AscmForkliftService.GetInstance().Get(id.Value); if (ascmForklift == null) throw new Exception("保存领料车辆信息失败!"); ascmForklift.modifyUser = userName; ascmForklift.modifyTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm"); } else { ascmForklift = new AscmForklift(); int maxId = YnDaoHelper.GetInstance().nHibernateHelper.GetMaxId("select max(id) from AscmForklift"); ascmForklift.id = ++maxId; ascmForklift.workerId = ascmForklift_Model.workerId; ascmForklift.createUser = userName; ascmForklift.createTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm"); ascmForklift.modifyUser = userName; ascmForklift.modifyTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm"); } if (ascmForklift_Model.forkliftType == null || ascmForklift_Model.forkliftType == "") throw new Exception("领料车辆车种不能为空!"); if (ascmForklift_Model.forkliftSpec == null || ascmForklift_Model.forkliftSpec == "") throw new Exception("领料车辆规格不能为空!"); ascmForklift.forkliftSpec = ascmForklift_Model.forkliftSpec; ascmForklift.forkliftType = ascmForklift_Model.forkliftType; ascmForklift.status = ascmForklift_Model.status; ascmForklift.assetsId = ascmForklift_Model.assetsId; ascmForklift.tagId = ascmForklift_Model.tagId; ascmForklift.forkliftNumber = ascmForklift_Model.forkliftNumber; ascmForklift.forkliftWay = ascmForklift_Model.forkliftWay; ascmForklift.actionLimits = ascmForklift_Model.actionLimits; ascmForklift.workContent = ascmForklift_Model.workContent; ascmForklift.tip = ascmForklift_Model.tip; if (id.HasValue) { object object1 = YnDaoHelper.GetInstance().nHibernateHelper.GetObject("select count(*) from AscmForklift where assetsId ='" + ascmForklift_Model.assetsId + "' and id <>" + id.Value + " "); if (object1 == null) throw new Exception("查询异常!"); int iCount = 0; if (int.TryParse(object1.ToString(), out iCount) && iCount > 0) throw new Exception("已存在此领料车辆信息【" + ascmForklift_Model.assetsId + "】!"); AscmForkliftService.GetInstance().Update(ascmForklift); } else { object object1 = YnDaoHelper.GetInstance().nHibernateHelper.GetObject("select count(*) from AscmForklift where assetsId = '" + ascmForklift_Model.assetsId + "'"); if (object1 == null) throw new Exception("查询异常!"); int iCount = 0; if (int.TryParse(object1.ToString(), out iCount) && iCount > 0) throw new Exception("已存在此领料车辆信息【" + ascmForklift_Model.assetsId + "】!"); AscmForkliftService.GetInstance().Save(ascmForklift); } jsonObjectResult.result = true; jsonObjectResult.message = ""; jsonObjectResult.id = ascmForklift.id.ToString(); jsonObjectResult.entity = ascmForklift; } catch (Exception ex) { jsonObjectResult.result = false; jsonObjectResult.message = ex.Message; } string sReturn = JsonConvert.SerializeObject(jsonObjectResult); return Content(sReturn); }
public void AddForkliftContainerLog(string forkliftRfid, AscmReadingHead ascmReadingHead, AscmForklift ascmForklift, List<string> listRfid, string sessionKey) { try { if (listRfid.Count > 0) { DateTime dtServer = DateTime.Now; int times = 0; //该叉车最后一次读取 YnBaseDal.YnPage ynPage = new YnBaseDal.YnPage(); ynPage.SetPageSize(1); string sql = "from AscmForkliftContainerLog where passDate='" + dtServer.ToString("yyyy-MM-dd") + "' and forkliftId=" + ascmForklift.id + ""; IList<AscmForkliftContainerLog> ilist = YnDaoHelper.GetInstance().nHibernateHelper.Find<AscmForkliftContainerLog>(sql + " order by times desc", sql, ynPage, sessionKey); if (ilist != null && ilist.Count > 0) { AscmForkliftContainerLog ascmForkliftContainerLog = ilist[0]; DateTime dtCreateTime = Convert.ToDateTime(ascmForkliftContainerLog.createTime); TimeSpan ts = dtServer.Subtract(dtCreateTime); if (ascmForkliftContainerLog.readingHeadId == ascmReadingHead.id) { if (ts.TotalMinutes < 10)//10分钟同一叉车不重复计入 return; times = ascmForkliftContainerLog.times; } } //开始加入 times++; string maxIdKey = YnFrame.Services.YnBillKeyService.GetInstance().GetBillKey("AscmForkliftContainerLog", "", "", 10, listRfid.Count, sessionKey); long maxId = Convert.ToInt64(maxIdKey); List<AscmForkliftContainerLog> listAscmForkliftContainerLog = new List<AscmForkliftContainerLog>(); foreach (string rfid in listRfid) { AscmForkliftContainerLog ascmForkliftContainerLog = new AscmForkliftContainerLog(); ascmForkliftContainerLog.id = ++maxId; ascmForkliftContainerLog.forkliftId = ascmForklift.id; ascmForkliftContainerLog.forkliftIdRfidId = forkliftRfid; ascmForkliftContainerLog.containerRfidId = rfid; ascmForkliftContainerLog.createTime = dtServer.ToString("yyyy-MM-dd HH:mm"); ascmForkliftContainerLog.passDate = dtServer.ToString("yyyy-MM-dd"); ascmForkliftContainerLog.times = times; ascmForkliftContainerLog.readingHeadId = ascmReadingHead.id; ascmForkliftContainerLog.readingHeadIp = ascmReadingHead.ip; ascmForkliftContainerLog.status = ""; listAscmForkliftContainerLog.Add(ascmForkliftContainerLog); } using (ITransaction tx = YnDaoHelper.GetInstance().nHibernateHelper.GetCurrentSession(sessionKey).BeginTransaction()) { try { if (listAscmForkliftContainerLog.Count > 0) YnDaoHelper.GetInstance().nHibernateHelper.SaveList(listAscmForkliftContainerLog, sessionKey); tx.Commit();//正确执行提交 } catch (Exception ex) { tx.Rollback();//回滚 throw ex; } } //建立领料员单次领料与领料单的关联 AscmWmsMtlRequisitionMainService.GetInstance().WmsStoreIssueCheck(forkliftRfid, times, dtServer.ToString("yyyy-MM-dd HH:mm"), sessionKey); } } catch (Exception ex) { YnBaseClass2.Helper.LogHelper.GetLog().Error("记录日志失败(Find AscmForkliftContainerLog)", ex); throw ex; } }
public void Update(AscmForklift ascmForklift) { try { using (ITransaction tx = YnDaoHelper.GetInstance().nHibernateHelper.GetCurrentSession().BeginTransaction()) { try { YnDaoHelper.GetInstance().nHibernateHelper.Update<AscmForklift>(ascmForklift); tx.Commit();//正确执行提交 } catch (Exception ex) { tx.Rollback();//回滚 YnBaseClass2.Helper.LogHelper.GetLog().Error("修改失败(Update AscmForklift)",ex); throw ex; } } } catch (Exception ex) { YnBaseClass2.Helper.LogHelper.GetLog().Error("修改失败(Update AscmForklift)",ex); throw ex; } }