public void UpdateDetail(AscmWmsLogisticsDetailLog ascmWmsLogisticsDetailLog)
        {
            try
            {
                using (ITransaction tx = YnDaoHelper.GetInstance().nHibernateHelper.GetCurrentSession().BeginTransaction())
                {
                    try
                    {
                        YnDaoHelper.GetInstance().nHibernateHelper.Update(ascmWmsLogisticsDetailLog);

                        tx.Commit();//正确执行提交
                    }
                    catch (Exception ex)
                    {
                        tx.Rollback();//回滚
                        throw ex;
                    }
                }
            }
            catch (Exception ex)
            {
                YnBaseClass2.Helper.LogHelper.GetLog().Error("更新失败(Update AscmWmsLogisticsDetailLog)", ex);
                throw ex;
            }
        }
Beispiel #2
0
        /// <summary>设置作业备料单已领数量</summary>
        public void SetReceivedQuantity(int wipEntityId, List <AscmWmsPreparationDetail> list)
        {
            if (list == null && list.Count == 0)
            {
                return;
            }

            var    materialIds = list.Select(P => P.materialId).Distinct();
            var    count       = materialIds.Count();
            string ids         = string.Empty;

            for (int i = 0; i < count; i++)
            {
                if (!string.IsNullOrEmpty(ids))
                {
                    ids += ",";
                }
                ids += materialIds.ElementAt(i);
                if ((i + 1) % 500 == 0 || (i + 1) == count)
                {
                    if (!string.IsNullOrEmpty(ids))
                    {
                        string hql = "select new AscmWmsLogisticsDetailLog(" + wipEntityId + ",materialId,sum(quantity)) from AscmWmsLogisticsDetailLog where wipEntityId=" + wipEntityId + " and materialId in (" + ids + ") group by materialId";
                        IList <AscmWmsLogisticsDetailLog> ilistLogisticsDetailLog = YnDaoHelper.GetInstance().nHibernateHelper.Find <AscmWmsLogisticsDetailLog>(hql);
                        if (ilistLogisticsDetailLog != null && ilistLogisticsDetailLog.Count > 0)
                        {
                            List <AscmWmsLogisticsDetailLog> listLogisticsDetailLog = ilistLogisticsDetailLog.ToList();
                            foreach (AscmWmsPreparationDetail preparationDetail in list)
                            {
                                AscmWmsLogisticsDetailLog logisticsDetailLog = listLogisticsDetailLog.Find(P => P.materialId == preparationDetail.materialId);
                                if (logisticsDetailLog != null)
                                {
                                    preparationDetail.receivedQuantity = logisticsDetailLog.quantity;
                                }
                            }
                        }
                    }
                    ids = string.Empty;
                }
            }
        }
        public void Save(AscmWmsLogisticsMainLog wmsLogisticsMainLog, List <WmsAndLogistics> listWmsAndLogistics)
        {
            try
            {
                int maxId_Detail = YnDaoHelper.GetInstance().nHibernateHelper.GetMaxId("select max(id) from AscmWmsLogisticsDetailLog");
                List <AscmWmsLogisticsDetailLog> listWmsLogisticsDetailLog = new List <AscmWmsLogisticsDetailLog>();
                foreach (WmsAndLogistics wmsAndLogistics in listWmsAndLogistics)
                {
                    AscmWmsLogisticsDetailLog wmsLogisticsDetailLog = new AscmWmsLogisticsDetailLog();
                    wmsLogisticsDetailLog.id                = ++maxId_Detail;
                    wmsLogisticsDetailLog.mainId            = wmsLogisticsMainLog.id;
                    wmsLogisticsDetailLog.wipEntityId       = wmsAndLogistics.wipEntityId;
                    wmsLogisticsDetailLog.materialId        = wmsAndLogistics.materialId;
                    wmsLogisticsDetailLog.quantity          = wmsAndLogistics.quantity;
                    wmsLogisticsDetailLog.preparationString = wmsAndLogistics.preparationString;
                    wmsLogisticsDetailLog.workerId          = wmsAndLogistics.workerId;
                    listWmsLogisticsDetailLog.Add(wmsLogisticsDetailLog);
                }

                using (ITransaction tx = YnDaoHelper.GetInstance().nHibernateHelper.GetCurrentSession().BeginTransaction())
                {
                    try
                    {
                        YnDaoHelper.GetInstance().nHibernateHelper.Save(wmsLogisticsMainLog);
                        YnDaoHelper.GetInstance().nHibernateHelper.SaveList(listWmsLogisticsDetailLog);

                        tx.Commit();//正确执行提交
                    }
                    catch (Exception ex)
                    {
                        tx.Rollback();//回滚
                        throw ex;
                    }
                }
            }
            catch (Exception ex)
            {
                YnBaseClass2.Helper.LogHelper.GetLog().Error("保存失败(Save AscmWmsLogisticsMainLog)", ex);
                throw ex;
            }
        }
        public AscmWmsLogisticsDetailLog GetDetail(string where)
        {
            AscmWmsLogisticsDetailLog wmsLogisticsDetailLog = null;

            try
            {
                if (!string.IsNullOrEmpty(where))
                {
                    string hql = "from AscmWmsLogisticsDetailLog where " + where;
                    IList <AscmWmsLogisticsDetailLog> ilist = YnDaoHelper.GetInstance().nHibernateHelper.FindTop <AscmWmsLogisticsDetailLog>(hql, 1);
                    if (ilist != null)
                    {
                        wmsLogisticsDetailLog = ilist[0];
                    }
                }
            }
            catch (Exception ex)
            {
                YnBaseClass2.Helper.LogHelper.GetLog().Error("查询失败(Find AscmWmsLogisticsDetailLog)", ex);
                throw ex;
            }
            return(wmsLogisticsDetailLog);
        }
Beispiel #5
0
        /// <summary>设置需求备料单已领数量</summary>
        public void SetReceivedQuantity(List <AscmWmsPreparationDetail> list)
        {
            if (list == null && list.Count == 0)
            {
                return;
            }

            string where = string.Empty;
            var gb = list.GroupBy(P => P.wipEntityId);

            foreach (IGrouping <string, AscmWmsPreparationDetail> ig in gb)
            {
                string whereOther  = string.Empty;
                var    materialIds = ig.Select(P => P.materialId).Distinct();
                var    count       = materialIds.Count();
                string ids         = string.Empty;
                for (int i = 0; i < count; i++)
                {
                    if (!string.IsNullOrEmpty(ids))
                    {
                        ids += ",";
                    }
                    ids += materialIds.ElementAt(i);
                    if ((i + 1) % 500 == 0 || (i + 1) == count)
                    {
                        if (!string.IsNullOrEmpty(ids))
                        {
                            whereOther = YnBaseClass2.Helper.StringHelper.SqlWhereOrAdd(whereOther, "materialId in(" + ids + ")");
                        }
                        ids = string.Empty;
                    }
                }
                where = YnBaseClass2.Helper.StringHelper.SqlWhereOrAdd(where, "wipEntityId='" + ig.Key + "' and (" + whereOther + ")");
            }

            if (string.IsNullOrEmpty(where))
            {
                return;
            }

            string hql = "select new AscmWmsLogisticsDetailLog(wipEntityId,materialId,sum(quantity)) from AscmWmsLogisticsDetailLog"
                         + " where " + where
                         + " group by wipEntityId,materialId";
            IList <AscmWmsLogisticsDetailLog> ilistLogisticsDetailLog = YnDaoHelper.GetInstance().nHibernateHelper.Find <AscmWmsLogisticsDetailLog>(hql);

            if (ilistLogisticsDetailLog == null || ilistLogisticsDetailLog.Count == 0)
            {
                return;
            }

            List <AscmWmsLogisticsDetailLog> listLogisticsDetailLog = ilistLogisticsDetailLog.ToList();

            foreach (AscmWmsPreparationDetail detail in list)
            {
                AscmWmsLogisticsDetailLog logisticsDetailLog = listLogisticsDetailLog.Find(P => P.wipEntityId == detail.wipEntityId && P.materialId == detail.materialId);
                if (logisticsDetailLog != null)
                {
                    detail.receivedQuantity = logisticsDetailLog.quantity;
                }
            }
        }