/// <summary> /// 创建装箱记录(operationType:1自动满格,2手动满格,3打印包牌号) /// </summary> /// <param name="lattice">柜格</param> /// <param name="userInfo">用户信息</param> /// <param name="boxWeight">箱子重量</param> /// <param name="operationType">操作类型:1自动满格,2手动满格,3打印包牌号</param> /// <returns></returns> internal override PackingLog CreatePackingLog(LatticeSetting lattice, UserInfo userInfo, decimal boxWeight, out List <LatticeOrdersCache> LatticeOrdersCacheList, int operationType = 3) { Debug.WriteLine("CreatePackingLog begin 2"); using (var db = new OrderSortingDBEntities()) { var logCache = db.LatticeOrdersCache.Where(o => o.LatticesettingId == lattice.ID); if (logCache == null || logCache.Count() < 1) { LatticeOrdersCacheList = null; return(null); } var logList = logCache.ToList(); LatticeOrdersCacheList = logList; PackingLog pkgLog = NewPackingLog(lattice, userInfo, operationType, logList, boxWeight); db.PackingLog.Add(pkgLog); db.LatticeOrdersCache.RemoveRange(logList); var response = API_Helper.BatchOutbound(userInfo, pkgLog, logList); if (response != null && !response.Success && !string.IsNullOrWhiteSpace(response.Message)) { throw new Exception(response.Message); } db.SaveChanges(); return(pkgLog); } }
/// <summary> /// 创建装箱记录(多格口打印一个PKG标签) /// </summary> /// <param name="latticeIdArray">格口号</param> /// <param name="userInfo">用户信息</param> /// <param name="criticalWeight">临界重量</param> /// <param name="boxWeight">箱子重量</param> /// <returns></returns> internal override PackingLog CreatePackingLog(string[] latticeIdArray, UserInfo userInfo, decimal criticalWeight, decimal boxWeight, out List <LatticeOrdersCache> latticeInfo, int operationType = 3) { using (var db = new OrderSortingDBEntities()) { //根据格口号获取格口信息 var LatticesettingIds = db.LatticeSetting.Where(ls => latticeIdArray.Contains(ls.LatticeId)).Select(ls => ls.ID); if (LatticesettingIds.Count() != latticeIdArray.Where(o => !string.IsNullOrWhiteSpace(o)).Count()) { throw new Exception("输入的格口号有误,注意:多个格口间需使用回车键分隔!"); } //根据格口信息获取相关的快件信息 var logCache = db.LatticeOrdersCache.Where(o => LatticesettingIds.Contains(o.LatticesettingId)); if (logCache == null || logCache.Count() < 1) { throw new Exception("没有分拣记录,装箱记录生成失败!"); } var logList = logCache.ToList(); latticeInfo = logList; //装箱记录 PackingLog pkgLog = NewPackingLog(null, userInfo, operationType, logList, boxWeight); if (pkgLog.Weight > criticalWeight) { throw new Exception(string.Format("总重量{0}Kg,临界重量{1}Kg,装箱记录生成失败!", pkgLog.Weight, criticalWeight)); } db.PackingLog.Add(pkgLog); db.LatticeOrdersCache.RemoveRange(logList); //把装箱信息上传到物流系统 var response = API_Helper.BatchOutbound(userInfo, pkgLog, logList); if (response != null && !response.Success && !string.IsNullOrWhiteSpace(response.Message)) { throw new Exception(response.Message); } db.SaveChanges(); return(pkgLog); } }