/// <summary> /// 当前订单的明细 /// </summary> /// <param name="TranceCode"></param> /// <returns></returns> private List<DocumentaryViewModel> CurrentVAN(Documentary doc) { List<DocumentaryViewModel> result = new List<DocumentaryViewModel>(); if (doc == null || doc.AUFNR == null) return result; string hql = "from AssemblyList as list where list.AUFNR = ? and (list.GW like ? or list.GW is NULL or list.GW='') order by SUBSTRING(list.ZOPID,5,3) asc, SUBSTRING(list.ZOPID,0,5) asc"; string gw = doc.OPref + "%"; var assembly = base.genericMgr.FindAll<AssemblyList>(hql, new object[] { doc.AUFNR, gw }).ToList(); result = AutoMapper.Mapper.Map<List<AssemblyList>, List<DocumentaryViewModel>>(assembly); foreach (var item in result) { if (item.MAKTX.Length > 15) { item.MAKTX = item.MAKTX.Substring(0, 15); } } return result; }
/// <summary> /// /// </summary> /// <returns></returns> private Documentary CurrentStation(string OPName, string CHARG) { string TranceCode = string.Empty; if (string.IsNullOrEmpty(OPName)) return null; if (!string.IsNullOrEmpty(CHARG)) { IList<AssemblyHead> allHead = this.genericMgr.FindAll<AssemblyHead>("from AssemblyHead as head where CHARG = ?", CHARG); if (allHead.Count != 0) { return new Documentary() { AUFNR = allHead[0].AUFNR, OPref = OPName, CHARG = CHARG, GSTRS = DateTime.Parse(allHead[0].GSTRS) }; } } string OPNamelike = OPName + "%"; IList<object[]> l = base.genericMgr.FindAllWithNativeSql<object[]>(searchSql, new object[] { OPNamelike }); if (l.Count > 0) { TranceCode = l[0][5].ToString(); } else { return null; } ///判断当前订单并保持在数据库中 IList<Documentary> curentdocs = this.genericMgr.FindAll<Documentary>("from Documentary as doc where OPref = ?", OPName); Documentary curentdoc; if (curentdocs.Count == 0) { var assemblyhead = GetHead(TranceCode); curentdoc = new Documentary(); if (assemblyhead != null) { curentdoc.OPref = OPName; curentdoc.OPDesc = assemblyhead.PLNBEZ; curentdoc.AUFNR = TranceCode; curentdoc.GSTRS = DateTime.Parse(assemblyhead.GSTRS); curentdoc.CHARG = assemblyhead.CHARG; curentdoc.ChangeTime = System.DateTime.Now; this.genericMgr.Create(curentdoc); } } else { curentdoc = curentdocs[0]; if (curentdoc.AUFNR != TranceCode) { var assemblyhead = GetHead(TranceCode); if (assemblyhead != null) { curentdoc.AUFNR = TranceCode; curentdoc.OPDesc = assemblyhead.PLNBEZ; curentdoc.GSTRS = DateTime.Parse(assemblyhead.GSTRS); curentdoc.CHARG = assemblyhead.CHARG; curentdoc.ChangeTime = System.DateTime.Now; this.genericMgr.Save(curentdoc); } } } return curentdoc; }