コード例 #1
0
        public BomDetail GetDefaultBomDetailForAbstractItem(Item abstractItem, Routing routing, DateTime effDate, Location defaultLocationFrom)
        {
            string            bomCode       = this.bomMgr.FindBomCode(abstractItem);
            IList <BomDetail> bomDetailList = this.GetNextLevelBomDetail(bomCode, effDate);

            if (bomDetailList != null && bomDetailList.Count > 0)
            {
                bomDetailList = IListHelper.Sort <BomDetail>(bomDetailList, "Priority"); //根据Priority进行排序

                foreach (BomDetail bomDetail in bomDetailList)
                {
                    #region 来源库位查找逻辑BomDetail-->RoutingDetail-->defaultLocationFrom
                    //defaultLocationFrom = FlowDetail-->Flow
                    Location bomLocation = bomDetail.Location;

                    if (bomLocation == null)
                    {
                        RoutingDetail routingDetail = routingDetailMgr.LoadRoutingDetail(routing, bomDetail.Operation, bomDetail.Reference);
                        if (routingDetail != null)
                        {
                            if (bomLocation == null)
                            {
                                bomLocation = routingDetail.Location;
                            }
                        }
                    }

                    if (bomLocation == null)
                    {
                        bomLocation = defaultLocationFrom;
                    }
                    #endregion

                    //如果没有找到库位,直接跳到下一个bomDetail
                    if (bomLocation != null)
                    {
                        if (!bomLocation.AllowNegativeInventory)
                        {
                            //不允许负库存
                            //todo 检查库存
                            throw new NotImplementedException();
                        }
                        else
                        {
                            //允许负库存,直接返回
                            return(bomDetail);
                        }
                    }
                }
            }

            return(null);
        }
コード例 #2
0
        public IList <BomDetail> GetBomDetailListForAbstractItem(Item abstractItem, Routing routing, DateTime effDate, Location defaultLocationFrom)
        {
            string            bomCode       = this.bomMgr.FindBomCode(abstractItem);
            IList <BomDetail> bomDetailList = this.GetNextLevelBomDetail(bomCode, effDate);

            if (bomDetailList != null && bomDetailList.Count > 0)
            {
                bomDetailList = IListHelper.Sort <BomDetail>(bomDetailList, "Priority"); //根据Priority进行排序

                foreach (BomDetail bomDetail in bomDetailList)
                {
                    #region 来源库位查找逻辑BomDetail-->RoutingDetail-->defaultLocationFrom
                    //defaultLocationFrom = FlowDetail-->Flow
                    Location bomLocation = bomDetail.Location;

                    if (bomLocation == null)
                    {
                        RoutingDetail routingDetail = routingDetailMgr.LoadRoutingDetail(routing, bomDetail.Operation, bomDetail.Reference);
                        if (routingDetail != null)
                        {
                            if (bomLocation == null)
                            {
                                bomLocation = routingDetail.Location;
                            }
                        }
                    }

                    if (bomLocation == null)
                    {
                        bomLocation = defaultLocationFrom;
                    }
                    bomDetail.Location = bomLocation;
                    #endregion
                }
            }

            return(bomDetailList);
        }
コード例 #3
0
    public void InitPageParameter(string flowCode, string itemCode, string uom, decimal unitCount, int position)
    {
        #region 根据Position来查找Operation
        int operation = 0;
        if (position > 0)
        {
            try
            {
                Flow flow = this.TheFlowMgr.CheckAndLoadFlow(flowCode);
                if (flow.Routing != null)
                {
                    IList <RoutingDetail> routingDetailList = this.TheRoutingDetailMgr.GetRoutingDetail(flow.Routing, DateTime.Now);

                    if (routingDetailList != null && routingDetailList.Count > 0)
                    {
                        IListHelper.Sort <RoutingDetail>(routingDetailList, "Operation");

                        operation = routingDetailList[position - 1].Operation;
                    }
                }
            }
            catch (BusinessErrorException ex)
            {
                this.ShowErrorMessage(ex);
                return;
            }
        }
        #endregion

        DetachedCriteria selectCriteria      = DetachedCriteria.For(typeof(InProcessLocationDetailView));
        DetachedCriteria selectCountCriteria = DetachedCriteria.For(typeof(InProcessLocationDetailView))
                                               .SetProjection(Projections.Count("Id"));
        IDictionary <string, string> alias = new Dictionary <string, string>();
        selectCriteria.CreateAlias("OrderDetail", "od");
        selectCountCriteria.CreateAlias("OrderDetail", "od");
        selectCriteria.CreateAlias("od.Item", "i");
        selectCountCriteria.CreateAlias("od.Item", "i");
        selectCriteria.CreateAlias("od.Uom", "u");
        selectCountCriteria.CreateAlias("od.Uom", "u");
        selectCriteria.CreateAlias("od.OrderHead", "oh");
        selectCountCriteria.CreateAlias("od.OrderHead", "oh");
        //selectCriteria.CreateAlias("oh.Flow", "f");
        //selectCountCriteria.CreateAlias("oh.Flow", "f");
        selectCriteria.CreateAlias("InProcessLocation", "ip");
        selectCountCriteria.CreateAlias("InProcessLocation", "ip");

        alias.Add("OrderDetail", "od");
        alias.Add("OrderDetail.Item", "i");
        alias.Add("OrderDetail.Uom", "u");
        alias.Add("OrderDetail.OrderHead", "oh");
        alias.Add("OrderDetail.Flow", "f");
        alias.Add("InProcessLocation", "ip");

        selectCriteria.Add(Expression.In("ip.Status", new object[] { BusinessConstants.CODE_MASTER_STATUS_VALUE_CREATE, BusinessConstants.CODE_MASTER_STATUS_VALUE_INPROCESS }));
        selectCountCriteria.Add(Expression.In("ip.Status", new object[] { BusinessConstants.CODE_MASTER_STATUS_VALUE_CREATE, BusinessConstants.CODE_MASTER_STATUS_VALUE_INPROCESS }));

        selectCriteria.Add(Expression.Eq("ip.Type", BusinessConstants.CODE_MASTER_INPROCESS_LOCATION_TYPE_VALUE_NORMAL));
        selectCountCriteria.Add(Expression.Eq("ip.Type", BusinessConstants.CODE_MASTER_INPROCESS_LOCATION_TYPE_VALUE_NORMAL));

        selectCriteria.Add(Expression.Eq("oh.Flow", flowCode));
        selectCountCriteria.Add(Expression.Eq("oh.Flow", flowCode));

        selectCriteria.Add(Expression.Eq("i.Code", itemCode));
        selectCountCriteria.Add(Expression.Eq("i.Code", itemCode));

        selectCriteria.Add(Expression.Eq("u.Code", uom));
        selectCountCriteria.Add(Expression.Eq("u.Code", uom));

        selectCriteria.Add(Expression.Eq("od.UnitCount", unitCount));
        selectCountCriteria.Add(Expression.Eq("od.UnitCount", unitCount));

        if (operation != 0)
        {
            selectCriteria.Add(Expression.Eq("ip.CurrentOperation", operation));
            selectCountCriteria.Add(Expression.Eq("ip.CurrentOperation", operation));
        }
        else
        {
            selectCriteria.Add(Expression.Or(Expression.Eq("ip.CurrentOperation", 0), Expression.IsNull("ip.CurrentOperation")));
            selectCountCriteria.Add(Expression.Or(Expression.Eq("ip.CurrentOperation", 0), Expression.IsNull("ip.CurrentOperation")));
        }

        this.SetSearchCriteria(selectCriteria, selectCountCriteria, alias);
        this.UpdateView();
    }
コード例 #4
0
    public void InitPageParameter(int id)
    {
        plannedBillView = this.ThePlannedBillViewMgr.LoadPlannedBillView(id);

        #region 查询PlannedBillView对应那些PlannedBill
        DetachedCriteria planBillCriteria = DetachedCriteria.For(typeof(PlannedBill));
        planBillCriteria.CreateAlias("Item", "item");
        planBillCriteria.CreateAlias("Uom", "uom");
        planBillCriteria.CreateAlias("BillAddress", "billAddr");

        planBillCriteria.Add(Expression.Or(Expression.IsNull("ActingQty"), Expression.Not(Expression.EqProperty("PlannedQty", "ActingQty"))));
        planBillCriteria.Add(Expression.Eq("item.Code", plannedBillView.Item.Code));
        planBillCriteria.Add(Expression.Eq("uom.Code", plannedBillView.Uom.Code));
        planBillCriteria.Add(Expression.Eq("UnitCount", plannedBillView.UnitCount));
        planBillCriteria.Add(Expression.Eq("billAddr.Code", plannedBillView.BillAddress.Code));

        IList <PlannedBill> plannedBillList = this.TheCriteriaMgr.FindAll <PlannedBill>(planBillCriteria);
        #endregion

        if (this.ModuleType == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_PROCUREMENT)
        {
            #region 查询LoctionLotDetail并转换为CSInventoryDetail
            DetachedCriteria locLotDetCriteria = DetachedCriteria.For(typeof(LocationLotDetail));

            locLotDetCriteria.CreateAlias("Location", "loc");
            locLotDetCriteria.CreateAlias("StorageBin", "bin", NHibernate.SqlCommand.JoinType.LeftOuterJoin);
            locLotDetCriteria.CreateAlias("Item", "item");
            locLotDetCriteria.CreateAlias("PlannedBill", "pb");
            locLotDetCriteria.CreateAlias("pb.OrderHead", "od");
            //locLotDetCriteria.CreateAlias("Hu", "hu");

            locLotDetCriteria.SetProjection(
                Projections.ProjectionList()
                .Add(Projections.GroupProperty("loc.Code").As("LocationCode"))
                .Add(Projections.GroupProperty("loc.Name").As("LocationName"))
                .Add(Projections.GroupProperty("bin.Code").As("Bin"))
                //.Add(Projections.GroupProperty("hu.HuId"))
                .Add(Projections.GroupProperty("LotNo").As("LotNo"))
                .Add(Projections.GroupProperty("od.OrderNo").As("OrderNo"))
                .Add(Projections.GroupProperty("pb.ReceiptNo").As("ReceiptNo"))
                .Add(Projections.GroupProperty("pb.CreateDate").As("ReceiptDate"))
                .Add(Projections.GroupProperty("pb.SettleTerm").As("SettleTerm"))
                .Add(Projections.Sum("Qty").As("i"))
                .Add(Projections.GroupProperty("pb.UnitQty").As("j"))
                );

            locLotDetCriteria.Add(Expression.Not(Expression.Eq("Qty", decimal.Zero)));
            locLotDetCriteria.Add(Expression.Eq("IsConsignment", true));
            locLotDetCriteria.Add(Expression.InG("PlannedBill", plannedBillList));

            IList <CSInventoryDetail> csInventoryDetailList = ConvertLocLotDet2CSInventoryDetail(this.TheCriteriaMgr.FindAll(locLotDetCriteria));
            #endregion

            #region 查询IpDetail并转换为CSInventoryDetail
            DetachedCriteria ipDetCriteria = DetachedCriteria.For(typeof(InProcessLocationDetail));
            ipDetCriteria.CreateAlias("OrderLocationTransaction", "olt");
            ipDetCriteria.CreateAlias("InProcessLocation", "ip");
            ipDetCriteria.CreateAlias("PlannedBill", "pb");
            ipDetCriteria.CreateAlias("pb.OrderHead", "od");

            ipDetCriteria.SetProjection(
                Projections.ProjectionList()
                .Add(Projections.GroupProperty("ip.IpNo"))
                //.Add(Projections.GroupProperty("HuId"))
                .Add(Projections.GroupProperty("LotNo"))
                .Add(Projections.GroupProperty("od.OrderNo"))
                .Add(Projections.GroupProperty("pb.ReceiptNo"))
                .Add(Projections.GroupProperty("pb.CreateDate"))
                .Add(Projections.GroupProperty("pb.SettleTerm"))
                .Add(Projections.Sum("Qty"))
                .Add(Projections.GroupProperty("pb.UnitQty"))
                );

            ipDetCriteria.Add((Expression.Eq("ip.Status", BusinessConstants.CODE_MASTER_STATUS_VALUE_CREATE)));
            ipDetCriteria.Add(Expression.InG("PlannedBill", plannedBillList));
            IList <CSInventoryDetail> csInventoryDetailList2 = ConvertIpDet2CSInventoryDetail(this.TheCriteriaMgr.FindAll(ipDetCriteria));

            if (csInventoryDetailList2.Count > 0)
            {
                IListHelper.AddRange <CSInventoryDetail>(csInventoryDetailList, csInventoryDetailList2);

                IListHelper.Sort <CSInventoryDetail>(csInventoryDetailList, "ReceiptDate");
            }
            #endregion

            this.GV_List.DataSource = csInventoryDetailList;
            this.GV_List.DataBind();
        }
        else if (this.ModuleType == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_DISTRIBUTION)
        {
            DetachedCriteria planBillDetailCriteria = DetachedCriteria.For(typeof(PlannedBill));
            planBillDetailCriteria.CreateAlias("OrderHead", "od");

            planBillDetailCriteria.SetProjection(
                Projections.ProjectionList()
                .Add(Projections.GroupProperty("LotNo"))
                .Add(Projections.GroupProperty("od.OrderNo"))
                .Add(Projections.GroupProperty("ExternalReceiptNo"))
                .Add(Projections.GroupProperty("CreateDate"))
                .Add(Projections.GroupProperty("SettleTerm"))
                .Add(Projections.Sum("PlannedQty"))
                .Add(Projections.Sum("ActingQty"))
                );

            IList <int> idList = new List <int>();
            foreach (PlannedBill pb in plannedBillList)
            {
                idList.Add(pb.Id);
            }

            planBillDetailCriteria.Add(Expression.InG("Id", idList));

            this.GV_List.DataSource = ConvertPlanBill2CSInventoryDetail(this.TheCriteriaMgr.FindAll(planBillDetailCriteria));
            this.GV_List.DataBind();
        }
    }
コード例 #5
0
        /**
         * 填充报表
         *
         * Param list [0]Repack
         *
         */
        protected override bool FillValuesImpl(String templateFileName, IList <object> list)
        {
            try
            {
                if (list == null || list.Count < 1)
                {
                    return(false);
                }

                Repack repack = (Repack)list[0];
                IList <RepackDetail> repackDetails = repack.RepackDetails;

                //投入/产出 排序
                repackDetails = IListHelper.Sort(repackDetails, "IOType");

                if (repack == null ||
                    repackDetails == null || repackDetails.Count == 0)
                {
                    return(false);
                }


                //this.SetRowCellBarCode(0, 2, 6);
                this.barCodeFontName = this.GetBarcodeFontName(2, 6);

                this.CopyPage(repackDetails.Count);

                this.FillHead(repack);

                int pageIndex = 1;
                int rowIndex  = 0;
                int rowTotal  = 0;
                foreach (RepackDetail repackDetail in repackDetails)
                {
                    //物料号
                    this.SetRowCell(pageIndex, rowIndex, 0, repackDetail.LocationLotDetail.Item.Code);
                    //物料描述
                    this.SetRowCell(pageIndex, rowIndex, 1, repackDetail.LocationLotDetail.Item.Description);
                    //"单位Unit"
                    this.SetRowCell(pageIndex, rowIndex, 2, repackDetail.LocationLotDetail.Hu.Uom.Code);
                    //"单包装UC"
                    this.SetRowCell(pageIndex, rowIndex, 3, repackDetail.LocationLotDetail.Hu.UnitCount.ToString("0.########"));
                    //库位
                    this.SetRowCell(pageIndex, rowIndex, 4, repackDetail.LocationLotDetail.Location.Code);
                    //批号
                    this.SetRowCell(pageIndex, rowIndex, 5, repackDetail.LocationLotDetail.Hu.LotNo);
                    //Hu编号
                    this.SetRowCell(pageIndex, rowIndex, 6, repackDetail.LocationLotDetail.Hu.HuId);
                    //数量
                    this.SetRowCell(pageIndex, rowIndex, 7, (repackDetail.Qty / repackDetail.LocationLotDetail.Hu.UnitQty).ToString("0.########"));
                    //类型
                    this.SetRowCell(pageIndex, rowIndex, 8, repackDetail.IOType);

                    if (this.isPageBottom(rowIndex, rowTotal))//页的最后一行
                    {
                        pageIndex++;
                        rowIndex = 0;
                    }
                    else
                    {
                        rowIndex++;
                    }
                    rowTotal++;
                }

                this.sheet.DisplayGridlines = false;
                this.sheet.IsPrintGridlines = false;
            }
            catch (Exception)
            {
                return(false);
            }
            return(true);
        }