Пример #1
0
        public void Update(int id, decimal quantity)
        {
            try
            {
                AscmContainerDelivery ascmContainerDelivery = Get(id);
                if (ascmContainerDelivery == null)
                {
                    throw new Exception("编号错误,没有此编号容器!");
                }
                ascmContainerDelivery.modifyUser = "";
                ascmContainerDelivery.modifyTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm");
                ascmContainerDelivery.quantity   = quantity;

                using (ITransaction tx = YnDaoHelper.GetInstance().nHibernateHelper.GetCurrentSession().BeginTransaction())
                {
                    try
                    {
                        YnDaoHelper.GetInstance().nHibernateHelper.Save(ascmContainerDelivery);
                        tx.Commit();//正确执行提交
                    }
                    catch (Exception ex)
                    {
                        tx.Rollback();//回滚
                        throw ex;
                    }
                }
            }
            catch (Exception ex)
            {
                YnBaseClass2.Helper.LogHelper.GetLog().Error("保存失败(Save AscmContainerDelivery)", ex);
                throw ex;
            }
        }
Пример #2
0
        public void Delete(int id)
        {
            try
            {
                AscmContainerDelivery ascmContainerDelivery = Get(id);
                if (ascmContainerDelivery == null)
                {
                    throw new Exception("编号错误,没有此编号容器!");
                }

                using (ITransaction tx = YnDaoHelper.GetInstance().nHibernateHelper.GetCurrentSession().BeginTransaction())
                {
                    try
                    {
                        YnDaoHelper.GetInstance().nHibernateHelper.Delete(ascmContainerDelivery);
                        tx.Commit();//正确执行提交
                    }
                    catch (Exception ex)
                    {
                        tx.Rollback();//回滚
                        throw ex;
                    }
                }
            }
            catch (Exception ex)
            {
                YnBaseClass2.Helper.LogHelper.GetLog().Error("保存失败(Save AscmContainerDelivery)", ex);
                throw ex;
            }
        }
Пример #3
0
 public void Update(AscmContainerDelivery ascmContainerDelivery)
 {
     try
     {
         using (ITransaction tx = YnDaoHelper.GetInstance().nHibernateHelper.GetCurrentSession().BeginTransaction())
         {
             try
             {
                 YnDaoHelper.GetInstance().nHibernateHelper.Update <AscmContainerDelivery>(ascmContainerDelivery);
                 tx.Commit();//正确执行提交
             }
             catch (Exception ex)
             {
                 tx.Rollback();//回滚
                 YnBaseClass2.Helper.LogHelper.GetLog().Error("修改失败(Update AscmContainerDelivery)", ex);
                 throw ex;
             }
         }
     }
     catch (Exception ex)
     {
         YnBaseClass2.Helper.LogHelper.GetLog().Error("修改失败(Save AscmContainerDelivery)", ex);
         throw ex;
     }
 }
Пример #4
0
        public CurrentDeliBatSum GetCurrentDeliBatSum(string warehouseId = "W312材料")
        {
            CurrentDeliBatSum currentDeliBatSum = new CurrentDeliBatSum();
            string            status            = AscmDeliBatSumMain.StatusDefine.inPlant;

            try
            {
                AscmContainerDelivery ascmContainerDelivery = AscmContainerDeliveryService.GetInstance().GetCurrent(warehouseId);
                if (ascmContainerDelivery == null)
                {
                    return(null);
                }
                //string whereOther = " warehouseId='" + warehouseId + "' and status='" + status + "' and id in (select batSumMainId from AscmContainerDelivery where )";
                string whereOther = " id=" + ascmContainerDelivery.batSumMainId;
                List <AscmDeliBatSumMain> listAscmDeliBatSumMain = AscmDeliBatSumMainService.GetInstance().GetList("id", "desc", "", whereOther);
                if (listAscmDeliBatSumMain != null && listAscmDeliBatSumMain.Count() > 0)
                {
                    AscmDeliBatSumMain ascmDeliBatSumMain = listAscmDeliBatSumMain[0];// listAscmDeliBatSumMain.OrderByDescending(item => item.toPlantTime).First();
                    currentDeliBatSum.supplierName               = ascmDeliBatSumMain.ascmSupplier.ascmSupplierAddress.vendorSiteCode;
                    currentDeliBatSum.deliBatSumNo               = ascmDeliBatSumMain.docNumber;
                    currentDeliBatSum.containerNumber            = ascmDeliBatSumMain.containerNumber;
                    currentDeliBatSum.toPlantTime                = ascmContainerDelivery.modifyTime;
                    currentDeliBatSum.inWarehouseContainerNumber = ascmDeliBatSumMain.inWarehouseContainerNumber;
                    List <AscmDeliBatSumDetail>  listAscmDeliBatSumDetail  = AscmDeliBatSumDetailService.GetInstance().GetListByMainId(ascmDeliBatSumMain.id);
                    List <AscmContainerDelivery> listAscmContainerDelivery = AscmContainerDeliveryService.GetInstance().GetListByDeliverySumMainId(ascmDeliBatSumMain.id);
                    listAscmContainerDelivery = listAscmContainerDelivery.Where(item => item.status == AscmContainerDelivery.StatusDefine.inWarehouseDoor).ToList();
                    if (listAscmDeliBatSumDetail != null && listAscmDeliBatSumDetail.Count() > 0)
                    {
                        List <CurrentDeliBatSumList> listCurrentDeliBatSumList = new List <CurrentDeliBatSumList>();
                        foreach (AscmDeliBatSumDetail ascmDeliBatSumDetail in listAscmDeliBatSumDetail)
                        {
                            CurrentDeliBatSumList currentDeliBatSumList = new CurrentDeliBatSumList();
                            currentDeliBatSumList.batchDocNumber    = ascmDeliBatSumDetail.batchDocNumber;
                            currentDeliBatSumList.materialDocNumber = ascmDeliBatSumDetail.materialDocNumber;
                            currentDeliBatSumList.materialName      = ascmDeliBatSumDetail.materialDescription;
                            currentDeliBatSumList.totalNumber       = ascmDeliBatSumDetail.totalNumber;
                            if (listAscmContainerDelivery != null && listAscmContainerDelivery.Count() > 0)
                            {
                                List <AscmContainerDelivery> vList = listAscmContainerDelivery.Where(item => item.deliveryOrderBatchId == ascmDeliBatSumDetail.batchId && item.materialId == ascmDeliBatSumDetail.materialId).ToList();
                                if (vList != null && vList.Count() > 0)
                                {
                                    currentDeliBatSumList.receiveNumber = vList.Sum(item => item.quantity);
                                }
                            }
                            listCurrentDeliBatSumList.Add(currentDeliBatSumList);
                        }
                        currentDeliBatSum.list = listCurrentDeliBatSumList;
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(currentDeliBatSum);
        }
Пример #5
0
 //public void Delete(int id)
 //{
 //    try
 //    {
 //        AscmContainerDelivery ascmContainerDelivery = Get(id);
 //        Delete(ascmContainerDelivery);
 //    }
 //    catch (Exception ex)
 //    {
 //        throw ex;
 //    }
 //}
 public void Delete(AscmContainerDelivery ascmContainerDelivery)
 {
     try
     {
         YnDaoHelper.GetInstance().nHibernateHelper.Delete <AscmContainerDelivery>(ascmContainerDelivery);
     }
     catch (Exception ex)
     {
         YnBaseClass2.Helper.LogHelper.GetLog().Error("删除失败(Delete AscmContainerDelivery)", ex);
         throw ex;
     }
 }
Пример #6
0
        public AscmContainerDelivery Get(int id)
        {
            AscmContainerDelivery ascmContainerDelivery = null;

            try
            {
                ascmContainerDelivery = YnDaoHelper.GetInstance().nHibernateHelper.Get <AscmContainerDelivery>(id);
            }
            catch (Exception ex)
            {
                YnBaseClass2.Helper.LogHelper.GetLog().Error("查询失败(Get AscmContainerDelivery)", ex);
                throw ex;
            }
            return(ascmContainerDelivery);
        }
Пример #7
0
        public AscmContainerDelivery Add(string containerSn, int batSumMainId, int deliveryOrderBatchId, int materialId, decimal quantity)
        {
            try
            {
                AscmContainerDelivery ascmContainerDelivery = new AscmContainerDelivery();
                ascmContainerDelivery.organizationId       = 0;
                ascmContainerDelivery.createUser           = "";
                ascmContainerDelivery.createTime           = DateTime.Now.ToString("yyyy-MM-dd HH:mm");
                ascmContainerDelivery.modifyUser           = "";
                ascmContainerDelivery.modifyTime           = DateTime.Now.ToString("yyyy-MM-dd HH:mm");
                ascmContainerDelivery.containerSn          = containerSn;
                ascmContainerDelivery.batSumMainId         = batSumMainId;
                ascmContainerDelivery.deliveryOrderBatchId = deliveryOrderBatchId;
                ascmContainerDelivery.deliveryOrderId      = 0;
                ascmContainerDelivery.materialId           = materialId;
                ascmContainerDelivery.quantity             = quantity;
                //ascmContainerDelivery.status = "";
                ascmContainerDelivery.memo = "";

                int maxId = YnDaoHelper.GetInstance().nHibernateHelper.GetMaxId("select max(id) from AscmContainerDelivery");
                maxId++;
                ascmContainerDelivery.id = maxId;
                using (ITransaction tx = YnDaoHelper.GetInstance().nHibernateHelper.GetCurrentSession().BeginTransaction())
                {
                    try
                    {
                        YnDaoHelper.GetInstance().nHibernateHelper.Save(ascmContainerDelivery);
                        tx.Commit();//正确执行提交
                    }
                    catch (Exception ex)
                    {
                        tx.Rollback();//回滚
                        throw ex;
                    }
                }
                return(ascmContainerDelivery);
            }
            catch (Exception ex)
            {
                YnBaseClass2.Helper.LogHelper.GetLog().Error("保存失败(Save AscmContainerDelivery)", ex);
                throw ex;
            }
        }
Пример #8
0
        public void Update(AscmContainerDelivery ascmContainerDelivery, int readingHeadId, string sessionKey)
        {
            try
            {
                AscmContainer ascmContainer = null;
                if (!string.IsNullOrEmpty(ascmContainerDelivery.containerSn))
                {
                    ascmContainer = YnDaoHelper.GetInstance().nHibernateHelper.Get <AscmContainer>(ascmContainerDelivery.containerSn, sessionKey);
                    if (ascmContainer != null)
                    {
                        ascmContainer.place       = readingHeadId.ToString();
                        ascmContainer.storeInTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                    }
                }

                using (ITransaction tx = YnDaoHelper.GetInstance().nHibernateHelper.GetCurrentSession(sessionKey).BeginTransaction())
                {
                    try
                    {
                        YnDaoHelper.GetInstance().nHibernateHelper.Update <AscmContainerDelivery>(ascmContainerDelivery, sessionKey);

                        if (ascmContainer != null)
                        {
                            YnDaoHelper.GetInstance().nHibernateHelper.Update <AscmContainer>(ascmContainer, sessionKey);
                        }

                        tx.Commit();//正确执行提交
                    }
                    catch (Exception ex)
                    {
                        tx.Rollback();//回滚
                        YnBaseClass2.Helper.LogHelper.GetLog().Error("修改失败(Update AscmContainerDelivery)", ex);
                        throw ex;
                    }
                }
            }
            catch (Exception ex)
            {
                YnBaseClass2.Helper.LogHelper.GetLog().Error("修改失败(Save AscmContainerDelivery)", ex);
                throw ex;
            }
        }
Пример #9
0
        public AscmContainerDelivery GetCurrent(string warehouseId)
        {
            AscmContainerDelivery ascmContainerDelivery = null;

            try
            {
                YnPage ynPage = new YnPage();
                ynPage.SetPageSize(1);
                ynPage.SetCurrentPage(1);
                string sort = " order by modifyTime desc ";
                string sql  = "from AscmContainerDelivery where status='" + AscmContainerDelivery.StatusDefine.inWarehouseDoor + "' and  batSumMainId in (select id from AscmDeliBatSumMain where warehouseId='" + warehouseId + "') and modifyTime is not null";
                IList <AscmContainerDelivery> ilist = YnDaoHelper.GetInstance().nHibernateHelper.Find <AscmContainerDelivery>(sql + sort, sql, ynPage);
                if (ilist != null && ilist.Count > 0)
                {
                    return(ilist[0]);
                }
            }
            catch (Exception ex)
            {
                YnBaseClass2.Helper.LogHelper.GetLog().Error("查询失败(Find AscmContainerDelivery)", ex);
                throw ex;
            }
            return(ascmContainerDelivery);
        }
Пример #10
0
        /// <summary>入库实时校验</summary>
        public DeliBatSumCheckIn Get(string warehouseId = "W312材料")
        {
            DeliBatSumCheckIn deliBatSumCheckIn = new DeliBatSumCheckIn();

            if (!string.IsNullOrWhiteSpace(warehouseId))
            {
                try
                {
                    string hql = "from AscmContainerDelivery";
                    string where = string.Empty;
                    where        = YnBaseClass2.Helper.StringHelper.SqlWhereAndAdd(where, "status='" + AscmContainerDelivery.StatusDefine.inWarehouseDoor + "'");
                    where        = YnBaseClass2.Helper.StringHelper.SqlWhereAndAdd(where, "batSumMainId in (select id from AscmDeliBatSumMain where warehouseId='" + warehouseId + "')");
                    where        = YnBaseClass2.Helper.StringHelper.SqlWhereAndAdd(where, "modifyTime is not null");
                    hql         += " where " + where;
                    string sort = " order by modifyTime desc ";
                    IList <AscmContainerDelivery> ilist = YnDaoHelper.GetInstance().nHibernateHelper.FindTop <AscmContainerDelivery>(hql + sort, 1);
                    if (ilist != null && ilist.Count > 0)
                    {
                        AscmContainerDelivery containerDelivery = ilist[0];
                        //供方简称
                        string supplierShortName = "select vendorSiteCode from AscmSupplierAddress a where a.vendorSiteCodeAlt=s.docNumber and rownum=1";
                        hql   = string.Format("select new AscmDeliBatSumMain(h.id,h.docNumber,({0})) from AscmDeliBatSumMain h,AscmSupplier s", supplierShortName);
                        where = string.Empty;
                        where = YnBaseClass2.Helper.StringHelper.SqlWhereAndAdd(where, "h.supplierId=s.id");
                        where = YnBaseClass2.Helper.StringHelper.SqlWhereAndAdd(where, "h.id=" + containerDelivery.batSumMainId);
                        hql  += " where " + where;
                        AscmDeliBatSumMain main = AscmDeliBatSumMainService.GetInstance().Get(hql);
                        if (main != null)
                        {
                            deliBatSumCheckIn.docNumber         = main.docNumber;
                            deliBatSumCheckIn.supplierShortName = main.supplierNameCn;
                            deliBatSumCheckIn.containerCheckIns = new List <ContainerCheckIn>();
                            deliBatSumCheckIn.checkTime         = containerDelivery.modifyTime;
                            deliBatSumCheckIn.warelocations     = new List <string>();

                            //容器
                            hql   = "select new AscmContainerDelivery(acd.containerSn,acd.status,acs.spec) from AscmContainerDelivery acd,AscmContainer ac,AscmContainerSpec acs";
                            where = string.Empty;
                            where = YnBaseClass2.Helper.StringHelper.SqlWhereAndAdd(where, "acd.containerSn=ac.sn");
                            where = YnBaseClass2.Helper.StringHelper.SqlWhereAndAdd(where, "ac.specId=acs.id");
                            where = YnBaseClass2.Helper.StringHelper.SqlWhereAndAdd(where, "acd.batSumMainId=" + main.id);
                            hql  += " where " + where;
                            IList <AscmContainerDelivery> ilist2 = YnDaoHelper.GetInstance().nHibernateHelper.Find <AscmContainerDelivery>(hql);
                            if (ilist2 != null && ilist2.Count > 0)
                            {
                                var result = ilist2.GroupBy(P => P.containerSpec);
                                foreach (IGrouping <string, AscmContainerDelivery> ig in result)
                                {
                                    ContainerCheckIn containerCheckIn = new ContainerCheckIn();
                                    containerCheckIn.spec          = ig.Key;
                                    containerCheckIn.quantity      = ig.GroupBy(P => P.containerSn).Count();
                                    containerCheckIn.checkQuantity = ig.Where(P => P.status == AscmContainerDelivery.StatusDefine.inWarehouseDoor).GroupBy(P => P.containerSn).Count();
                                    deliBatSumCheckIn.containerCheckIns.Add(containerCheckIn);
                                }
                            }

                            //货位指引
                            string sql             = "select distinct materialid from ascm_deli_bat_sum_detail where mainid=" + main.id;
                            IList  ilistMaterialId = YnDaoHelper.GetInstance().nHibernateHelper.ExecuteReader(sql);
                            foreach (object[] item in ilistMaterialId)
                            {
                                if (item != null && item.Length > 0 && !string.IsNullOrEmpty(item[0].ToString()))
                                {
                                    sql = "select buildingarea from ascm_warelocation"
                                          + " where warehouseid='" + warehouseId + "'"
                                          + "   and (id in(select warelocationId from ascm_location_material_link where materialid=" + item[0].ToString() + ") or categoryCode='0000')"
                                          + "   and rownum=1";
                                    object obj = YnDaoHelper.GetInstance().nHibernateHelper.GetObjectBySQL(sql);
                                    if (obj != null && !string.IsNullOrEmpty(obj.ToString()) && !deliBatSumCheckIn.warelocations.Contains(obj.ToString()))
                                    {
                                        deliBatSumCheckIn.warelocations.Add(obj.ToString());
                                    }
                                }
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
            return(deliBatSumCheckIn);
        }