public static TransformerDetail ConvertHuToTransformerDetail(FlowView flowView, Hu hu)
        {
            TransformerDetail transformerDetail = ConvertHuToTransformerDetail(hu);
            transformerDetail.LocationFromCode = flowView.LocationFrom != null ? flowView.LocationFrom.Code : null;
            transformerDetail.LocationToCode = flowView.LocationTo != null ? flowView.LocationTo.Code : null;
            transformerDetail.StorageBinCode = hu.StorageBin == null ? string.Empty : hu.StorageBin;

            return transformerDetail;
        }
        public static TransformerDetail ConvertHuToTransformerDetail(Hu hu)
        {
            TransformerDetail transformerDetail = new TransformerDetail();
            transformerDetail.ItemCode = hu.Item.Code;
            transformerDetail.ItemDescription = hu.Item.Description;
            transformerDetail.UomCode = hu.Uom.Code;
            transformerDetail.UnitCount = hu.UnitCount;
            transformerDetail.HuId = hu.HuId;
            transformerDetail.LotNo = hu.LotNo;
            transformerDetail.Qty = hu.Qty;
            transformerDetail.CurrentQty = hu.Qty;
            transformerDetail.Status = hu.Status;
            transformerDetail.LocationCode = hu.Location == null ? string.Empty : hu.Location;
            transformerDetail.StorageBinCode = hu.StorageBin == null ? string.Empty : hu.StorageBin;

            return transformerDetail;
        }
Example #3
0
        public void DoReceiveWO(string huId, OrderDetail orderDetail, decimal qty)
        {
            #region 创建外包装条码 有创建状态的条码就不创建条码了
            Hu hu = new Hu();
            DetachedCriteria criteria = DetachedCriteria.For<Hu>();
            criteria.Add(Expression.Eq("HuId", huId));
            criteria.Add(Expression.Eq("Status", BusinessConstants.CODE_MASTER_STATUS_VALUE_CREATE));
            IList<Hu> huList = this.criteriaMgr.FindAll<Hu>(criteria);
            if (huList != null && huList.Count > 0)
            {
                hu = huList[0];
            }
            else
            {
                hu = ResolveAndCreateHu(huId, orderDetail, qty);
            }
            #endregion

            #region 工单收货
            orderDetail.HuId = hu.HuId;

            Receipt receipt = new Receipt();
            ReceiptDetail receiptDetail = new ReceiptDetail();
            receiptDetail.HuId = hu.HuId;
            receiptDetail.LotNo = hu.LotNo;
            receiptDetail.ReceivedQty = qty;
            receiptDetail.Receipt = receipt;

            #region 找Out的OrderLocTrans,填充MaterialFulshBack
            IList<OrderLocationTransaction> orderLocTransList = this.orderLocationTransactionMgr.GetOrderLocationTransaction(orderDetail.Id);
            foreach (OrderLocationTransaction orderLocTrans in orderLocTransList)
            {
                if (orderLocTrans.IOType == BusinessConstants.IO_TYPE_OUT)
                {
                    MaterialFlushBack material = new MaterialFlushBack();
                    material.OrderLocationTransaction = orderLocTrans;
                    if (orderLocTrans.UnitQty != 0)
                    {
                        material.Qty = qty;
                    }
                    receiptDetail.AddMaterialFlushBack(material);
                }
                else
                {
                    receiptDetail.OrderLocationTransaction = this.orderLocationTransactionMgr.GetOrderLocationTransaction(orderDetail.Id, BusinessConstants.IO_TYPE_IN)[0];
                }
            }
            #endregion
            receipt.AddReceiptDetail(receiptDetail);

            this.ReceiveOrder(receipt, this.userMgr.GetMonitorUser());
            #endregion
        }
Example #4
0
        public FlowView CheckAndLoadFlowView(string flowCode, string userCode, string locationFromCode, string locationToCode, Hu hu, List<string> flowTypes)
        {

            //按物料号,单位,单包装
            FlowView flowView = LoadFlowView(flowCode, userCode, locationFromCode, locationToCode, hu, flowTypes);

            //看是否允许新建明细
            if (flowView == null)
            {
                IList<Flow> flowList = this.GetFlows(flowCode, locationFromCode, locationToCode, true, userCode, flowTypes);
                if (flowList != null && flowList.Count > 0)
                {
                    flowView = new FlowView();
                    flowView.Flow = flowList[0];
                    FlowDetail flowDetail = new FlowDetail();
                    flowDetail.Item = hu.Item;
                    flowDetail.Uom = hu.Uom;
                    flowDetail.UnitCount = hu.UnitCount;
                    flowView.LocationFrom = flowView.Flow.LocationFrom;
                    flowView.LocationTo = flowView.Flow.LocationTo;
                }
            }
            if (flowView != null)
            {
                return flowView;
            }
            else
            {
                throw new BusinessErrorException("Flow.Error.NotFoundMacthFlow", hu.HuId, flowCode);
            }
        }
        private Hu CreateItemHu(string barCode, OrderDetail orderDetail, string lotNo, DateTime manufactureDate)
        {
            Item item = orderDetail.Item;
            decimal qty = 1;

            Hu hu = new Hu();
            hu.HuId = barCode;
            hu.Item = item;
            hu.Uom = orderDetail.Uom;   //用Flow单位
            #region 单位用量
            if (item.Uom.Code != orderDetail.Uom.Code)
            {
                hu.UnitQty = this.uomConversionMgr.ConvertUomQty(item, orderDetail.Uom, 1, item.Uom);   //单位用量
            }
            else
            {
                hu.UnitQty = 1;
            }
            #endregion
            hu.QualityLevel = BusinessConstants.CODE_MASTER_ITEM_QUALITY_LEVEL_VALUE_1;
            hu.Qty = qty;
            hu.UnitCount = 1;
            hu.LotNo = lotNo;
            hu.LotSize = 1;
            hu.ManufactureDate = manufactureDate;
            hu.ManufactureParty = orderDetail.OrderHead.PartyFrom;
            hu.CreateUser = this.userMgr.GetMonitorUser();
            hu.CreateDate = DateTime.Now;
            hu.Status = BusinessConstants.CODE_MASTER_HU_STATUS_VALUE_CREATE;

            this.huMgr.CreateHu(hu);

            return hu;
        }
Example #6
0
 public IList<Hu> CloneHu(Hu hu, decimal uintCount, int count, User user)
 {
     return CloneHu(hu.HuId, uintCount, count, user);
 }
 public virtual void UpdateHu(Hu entity)
 {
     entityDao.UpdateHu(entity);
 }
        private void writeContent(string userName, int pageIndex, int num, Hu hu)
        {
            if (hu.PrintCount > 1)
            {
                this.SetRowCell(pageIndex, 1, 4, "(R)", num);
            }
            hu.PrintCount += 1;

            //hu id内容
            string barCode = Utility.BarcodeHelper.GetBarcodeStr(hu.HuId, this.barCodeFontName);
            this.SetRowCell(pageIndex, 0, 0, barCode, num);
            //hu id内容
            this.SetRowCell(pageIndex, 1, 0, hu.HuId, num);
            //PRINTED DATE:内容
            this.SetRowCell(pageIndex, 2, 3, DateTime.Now.ToString("MM/dd/yy"), num);
        }
Example #9
0
        public void MatchHuByItem(Resolver resolver, Hu hu)
        {
            if (hu == null)
            {
                throw new BusinessErrorException("Hu.Error.HuIdNotExist", resolver.Input);
            }

            //校验重复扫描
            if (this.CheckMatchHuScanExist(resolver))
            {
                throw new BusinessErrorException("Warehouse.Error.HuReScan", resolver.Input);
            }
            if (!MatchByItem(resolver, hu))
            {
                if (!resolver.AllowCreateDetail)
                {
                    throw new BusinessErrorException("Warehouse.HuMatch.NotMatch", resolver.Input);
                }
                else //允许新增明细
                {
                    Flow flow = flowMgr.LoadFlow(resolver.Code, false);
                    string locationCode = string.Empty;
                    if (resolver.ModuleType == BusinessConstants.TRANSFORMER_MODULE_TYPE_RECEIVERETURN)
                    {
                        locationCode = flow.LocationTo.Code;
                    }
                    else
                    {
                        locationCode = flow.LocationFrom == null ? string.Empty : flow.LocationFrom.Code;
                    }
                    if (hu.Location != locationCode)
                    {
                        throw new BusinessErrorException("Common.Business.Error.HuNoInventory", hu.Location, resolver.Input);
                    }

                    TransformerDetail transformerDetail = Utility.TransformerHelper.ConvertHuToTransformerDetail(hu);
                    Transformer transformer = new Transformer();
                    transformer.ItemCode = hu.Item.Code;
                    transformer.ItemDescription = hu.Item.Description;
                    transformer.UnitCount = hu.Item.UnitCount;
                    transformer.UomCode = hu.Uom.Code;
                    transformer.LocationFromCode = hu.Location;
                    transformer.LocationToCode = flow.LocationTo == null ? string.Empty : flow.LocationTo.Code;

                    transformer.AddTransformerDetail(transformerDetail);
                    resolver.AddTransformer(transformer);
                    TransformerHelper.ProcessTransformer(transformer);
                }
            }
            resolver.Command = BusinessConstants.CS_BIND_VALUE_TRANSFORMERDETAIL;
        }
Example #10
0
 public void MatchHuByFlowView(Resolver resolver, FlowView flowView, Hu hu)
 {
     TransformerDetail transformerDetail = Utility.TransformerHelper.ConvertHuToTransformerDetail(flowView, hu);
     transformerDetail.StorageBinCode = resolver.BinCode;//库格
     resolver.AddTransformerDetail(transformerDetail);
 }
 public virtual void DeleteHu(Hu entity)
 {
     Delete(entity);
 }
 public virtual void UpdateHu(Hu entity)
 {
     Update(entity);
 }
 public virtual void CreateHu(Hu entity)
 {
     Create(entity);
 }
Example #14
0
        private void writeContent(string companyCode, string userName, int pageIndex, int num, Hu hu)
        {
            if (hu.PrintCount > 1)
            {
                this.SetRowCell(pageIndex, 1, 3, "(R)", num);
            }
            hu.PrintCount += 1;

            if (hu.Item.Type.Equals("M")) //成品
            {

                //YFKSS
                this.SetMergedRegion(pageIndex, 1, 4, 9, 4, num);
                Cell cell = this.GetCell(this.GetRowIndexAbsolute(pageIndex, getRowIndex(1, num)), getColumnIndex(4, num));

                //cell.CellStyle = workbook.CreateCellStyle();
                //cell.CellStyle.CloneStyleFrom(cellStyle);
                cell.CellStyle = this.cellStyle1;
                this.SetRowCell(pageIndex, 1, 4, companyCode, num);

                /*
                Bitmap bitmap = Barcode_Writer.Code128.Instance.Generate("12314325346457567");
                MemoryStream ms = new MemoryStream();
                bitmap.Save(ms, ImageFormat.Jpeg);
                ms.Flush();
                byte[] bData = ms.GetBuffer();
                ms.Close();

                int pictureIdx = this.workbook.AddPicture(bData, HSSFWorkbook.PICTURE_TYPE_JPEG);

                HSSFPatriarch patriarch = this.sheet.CreateDrawingPatriarch();
                //add a picture
                HSSFClientAnchor anchor = new HSSFClientAnchor(0, 0, 70, 100, this.getColumnIndex(0, num), this.getRowIndex(0, num), this.getColumnIndex(0, num), this.getRowIndex(0, num));
                HSSFPicture pict = patriarch.CreatePicture(anchor, pictureIdx);
                */
                //hu id内容
                string barCode = Utility.BarcodeHelper.GetBarcodeStr(hu.HuId, this.barCodeFontName);
                this.SetRowCell(pageIndex, 0, 0, barCode, num);
                //hu id内容
                this.SetRowCell(pageIndex, 1, 0, hu.HuId, num);
                //PART NO.内容
                this.SetRowCell(pageIndex, 3, 0, hu.Item.Code, num);
                //批号LotNo
                this.SetRowCell(pageIndex, 5, 0, hu.LotNo, num);
                //SHIFT
                this.SetRowCell(pageIndex, 4, 2, "SHIFT", num);
                //SHIFT内容
                this.SetRowCell(pageIndex, 5, 2, Utility.BarcodeHelper.GetShiftCode(hu.HuId), num);
                //QUANTITY.
                this.SetRowCell(pageIndex, 4, 3, "QUANTITY.", num);
                //QUANTITY内容
                this.SetRowCell(pageIndex, 5, 3, hu.Qty.ToString("0.########"), num);
                //CUSTPART
                this.SetRowCell(pageIndex, 6, 0, "CUSTPART", num);
                //CUSTPART内容
                this.SetRowCell(pageIndex, 7, 0, hu.CustomerItemCode, num);
                //WO DATE
                this.SetRowCell(pageIndex, 6, 3, "WO DATE", num);
                //WO DATE内容
                this.SetRowCell(pageIndex, 7, 3, hu.ManufactureDate.ToString("MM/dd/yy"), num);
                //DESCRIPTION
                this.SetRowCell(pageIndex, 8, 0, "DESCRIPTION.", num);
                //DESCRIPTION内容
                this.SetRowCell(pageIndex, 9, 0, hu.Item.Description, num);
                //PRINTED DATE:内容
                this.SetRowCell(pageIndex, 10, 1, DateTime.Now.ToString("MM/dd/yy"), num);
                //print name 内容
                this.SetRowCell(pageIndex, 10, 3, userName, num);

            }
            else if (hu.Item.Type.Equals("P")) //原材料
            {
                //画方框
                Cell cell1 = this.GetCell(this.GetRowIndexAbsolute(pageIndex, getRowIndex(2, num)), getColumnIndex(4, num));

                //cell1.CellStyle = workbook.CreateCellStyle();
                //cell1.CellStyle.CloneStyleFrom(cellStyle1);
                cell1.CellStyle = this.cellStyle2;

                Cell cell2 = this.GetCell(this.GetRowIndexAbsolute(pageIndex, getRowIndex(3, num)), getColumnIndex(4, num));

                //cell2.CellStyle = workbook.CreateCellStyle();
                //cell2.CellStyle.CloneStyleFrom(cellStyle2);
                cell2.CellStyle = this.cellStyle3;

                //hu id内容
                string barCode = Utility.BarcodeHelper.GetBarcodeStr(hu.HuId, this.barCodeFontName);
                this.SetRowCell(pageIndex, 0, 0, barCode, num);
                //hu id内容
                this.SetRowCell(pageIndex, 1, 0, hu.HuId, num);
                //PART NO.内容
                this.SetRowCell(pageIndex, 3, 0, hu.Item.Code, num);
                //批号LotNo
                this.SetRowCell(pageIndex, 5, 0, hu.LotNo, num);
                //QUANTITY.
                this.SetRowCell(pageIndex, 4, 2, "QUANTITY.", num);
                //QUANTITY.
                this.SetRowCell(pageIndex, 5, 2, hu.Qty.ToString("0.########"), num);
                //DESCRIPTION
                this.SetRowCell(pageIndex, 6, 0, "DESCRIPTION.", num);
                //DESCRIPTION内容
                this.SetRowCell(pageIndex, 7, 0, hu.Item.Description, num);
                //SUPPLIER
                this.SetRowCell(pageIndex, 8, 0, "SUPPLIER.", num);
                //SUPPLIER内容
                this.SetRowCell(pageIndex, 9, 0, hu.ManufactureParty == null ? string.Empty : hu.ManufactureParty.Name, num);
                //PRINTED DATE:内容
                this.SetRowCell(pageIndex, 10, 1, DateTime.Now.ToString("MM/dd/yy"), num);
                //print name 内容
                this.SetRowCell(pageIndex, 10, 3, userName, num);

            }
        }
    private void HuScan(Hu hu)
    {
        bool isMatch = false;

        #region 按Hu拣货
        if (this.PickBy == BusinessConstants.CODE_MASTER_PICKBY_HU)
        {
            foreach (GridViewRow row in GV_List.Rows)
            {
                Label lblOrderQty = (Label)row.FindControl("lblOrderQty");
                TextBox tbShipQty = (TextBox)row.FindControl("tbShipQty");
                Label lblHuId = (Label)row.FindControl("lblHuId");
                Label lblLoc = (Label)row.FindControl("lblLoc");
                Label lblStorageBin = (Label)row.FindControl("lblStorageBin");
                HiddenField hfId = (HiddenField)row.FindControl("hfId");
                Hu_HuInput ucHuInput = (Hu_HuInput)row.FindControl("ucHuInput");
                if (ucHuInput.CheckExist(hu.HuId))
                {
                    this.lblMessage.Text = Resources.Language.MasterDataHuExist;
                    break;
                }
                if (hu.HuId == lblHuId.Text.Trim())
                {
                    IList<LocationLotDetail> locationLotDetList = TheLocationLotDetailMgr.GetHuLocationLotDetail(hu.HuId);
                    if (locationLotDetList != null && locationLotDetList.Count > 0)
                    {
                        LocationLotDetail locLotDet = locationLotDetList[0];
                        if (locLotDet.Location.Code == lblLoc.Text.Trim() && (locLotDet.StorageBin == null || locLotDet.StorageBin.Code.ToUpper() == lblStorageBin.Text.Trim().ToUpper()))
                        {
                            decimal orderQty = lblOrderQty.Text.Trim() == string.Empty ? 0 : decimal.Parse(lblOrderQty.Text.Trim());
                            decimal shipQty = tbShipQty.Text.Trim() == string.Empty ? 0 : decimal.Parse(tbShipQty.Text.Trim());
                            if (orderQty >= shipQty + hu.Qty)
                            {
                                ucHuInput.HuInput(hu);
                                tbShipQty.Text = ucHuInput.SumQty().ToString("F2");
                                PickListResult pickListResult = new PickListResult();
                                pickListResult.LocationLotDetail = locLotDet;
                                pickListResult.PickListDetail = ThePickListDetailMgr.LoadPickListDetail(int.Parse(hfId.Value));
                                pickListResult.Qty = hu.Qty;

                                isMatch = true;
                                InitialHuScan();
                                break;
                            }
                        }
                    }
                }
            }
        }
        #endregion

        #region 按LotNo拣货
        else if (this.PickBy == BusinessConstants.CODE_MASTER_PICKBY_LOTNO)
        {
            foreach (GridViewRow row in GV_List.Rows)
            {
                Label lblOrderQty = (Label)row.FindControl("lblOrderQty");
                TextBox tbShipQty = (TextBox)row.FindControl("tbShipQty");
                Label lblLotNo = (Label)row.FindControl("lblLotNo");
                Label lblItemCode = (Label)row.FindControl("lblItemCode");
                Label lblUnitCount = (Label)row.FindControl("lblUnitCount");
                Label lblUom = (Label)row.FindControl("lblUom");
                Label lblLoc = (Label)row.FindControl("lblLoc");
                Label lblStorageBin = (Label)row.FindControl("lblStorageBin");
                Hu_HuInput ucHuInput = (Hu_HuInput)row.FindControl("ucHuInput");
                HiddenField hfId = (HiddenField)row.FindControl("hfId");
                if (ucHuInput.CheckExist(hu.HuId))
                {
                    this.lblMessage.Text = Resources.Language.MasterDataHuExist;
                    break;
                }
                if (lblLotNo.Text.Trim().ToUpper() == hu.LotNo.ToUpper() && lblItemCode.Text.Trim().ToUpper() == hu.Item.Code.ToUpper() && decimal.Parse(lblUnitCount.Text.Trim()) == hu.UnitCount && lblUom.Text.Trim().ToUpper() == hu.Uom.Code.ToUpper())
                {
                    IList<LocationLotDetail> locationLotDetList = TheLocationLotDetailMgr.GetHuLocationLotDetail(hu.HuId);
                    if (locationLotDetList != null && locationLotDetList.Count > 0)
                    {
                        LocationLotDetail locLotDet = locationLotDetList[0];
                        if (locLotDet.Location.Code == lblLoc.Text.Trim() && (locLotDet.StorageBin == null || locLotDet.StorageBin.Code == lblStorageBin.Text.Trim()))
                        {
                            decimal orderQty = lblOrderQty.Text.Trim() == string.Empty ? 0 : decimal.Parse(lblOrderQty.Text.Trim());
                            decimal shipQty = tbShipQty.Text.Trim() == string.Empty ? 0 : decimal.Parse(tbShipQty.Text.Trim());
                            if (orderQty >= shipQty + hu.Qty)
                            {
                                ucHuInput.HuInput(hu);
                                tbShipQty.Text = ucHuInput.SumQty().ToString("F2");
                                PickListResult pickListResult = new PickListResult();
                                pickListResult.LocationLotDetail = locLotDet;
                                pickListResult.PickListDetail = ThePickListDetailMgr.LoadPickListDetail(int.Parse(hfId.Value));
                                pickListResult.Qty = hu.Qty;

                                isMatch = true;
                                InitialHuScan();
                                break;
                            }
                        }

                    }
                }
            }
        }
        #endregion

        if (!isMatch)
        {
            this.lblMessage.Text = Resources.Language.MasterDataPickListNotExistHu;
            this.tbHuScan.Text = string.Empty;
            this.tbHuScan.Focus();
        }
    }
Example #16
0
        private Hu ResolveAndCreateHu(string barCode, IList<int> orderLocationTransactionIdList)
        {
            object[] result = ResolveBarCode(barCode);
            Item item = (Item)result[0];
            string supMark = (string)result[1];
            string lotNo = (string)result[2];
            decimal qty = (decimal)result[3];
            int seq = (int)result[4];
            DateTime manufactureDate = (DateTime)result[5];

            EntityPreference entityPreference = this.entityPreferenceMgr.LoadEntityPreference(BusinessConstants.ENTITY_PREFERENCE_CODE_COMPANY_ID_MARK); //企业标识位

            foreach (int orderLocationTransactionId in orderLocationTransactionIdList)
            {
                OrderLocationTransaction orderLocationTransaction = this.orderLocationTransactionMgr.LoadOrderLocationTransaction(orderLocationTransactionId);
                OrderDetail orderDetail = orderLocationTransaction.OrderDetail;

                //对于一条flow上同一个Item出现有多次,使用第一个。
                if (item.Code.ToUpper() == orderDetail.Item.Code.ToUpper()
                    //&& (supMark == orderDetail.IdMark      //等于订单上供应商标识位
                    //    || supMark == entityPreference.Value  //等于企业标识位
                    //    || (supMark == BusinessConstants.DEFAULT_SUPPLIER_ID_MARK    //等于默认供应商标示位
                    //        && (orderDetail.IdMark == null
                    //            || orderDetail.IdMark.Trim() == string.Empty)
                    //        )
                    //    )
                    )
                {
                    Hu hu = new Hu();
                    hu.HuId = barCode;
                    hu.Item = item;
                    hu.Uom = orderDetail.Uom;   //用Flow单位
                    #region 单位用量
                    if (item.Uom.Code != orderDetail.Uom.Code)
                    {
                        hu.UnitQty = this.uomConversionMgr.ConvertUomQty(item, orderDetail.Uom, 1, item.Uom);   //单位用量
                    }
                    else
                    {
                        hu.UnitQty = 1;
                    }
                    #endregion
                    hu.QualityLevel = BusinessConstants.CODE_MASTER_ITEM_QUALITY_LEVEL_VALUE_1;
                    hu.Qty = qty / hu.UnitQty;
                    hu.UnitCount = orderDetail.UnitCount;
                    hu.LotNo = lotNo;
                    hu.ManufactureDate = manufactureDate;
                    hu.ManufactureParty = orderDetail.OrderHead.PartyFrom;
                    hu.CreateUser = this.userMgr.GetMonitorUser();
                    hu.CreateDate = DateTime.Now;
                    hu.Status = BusinessConstants.CODE_MASTER_HU_STATUS_VALUE_CREATE;
                    hu.LotSize = orderDetail.HuLotSize.HasValue ? orderDetail.HuLotSize.Value : hu.Qty;

                    this.huMgr.CreateHu(hu);
                    this.numberControlMgr.ReverseUpdateHuId(barCode);

                    return hu;
                }
            }
            return null;
        }
Example #17
0
        private Hu ResolveAndCreateHu(string barCode, Uom uom, Party manufactureParty)
        {
            object[] result = ResolveBarCode(barCode);
            Item item = (Item)result[0];
            string supMark = (string)result[1];
            string lotNo = (string)result[2];
            decimal qty = (decimal)result[3];
            int seq = (int)result[4];
            DateTime manufactureDate = (DateTime)result[5];

            Hu hu = new Hu();
            hu.HuId = barCode;
            hu.Item = item;
            hu.Uom = uom;
            #region 单位用量
            if (item.Uom.Code != uom.Code)
            {
                hu.UnitQty = this.uomConversionMgr.ConvertUomQty(item, uom, 1, item.Uom);   //单位用量
            }
            else
            {
                hu.UnitQty = 1;
            }
            #endregion
            hu.QualityLevel = BusinessConstants.CODE_MASTER_ITEM_QUALITY_LEVEL_VALUE_1;
            hu.Qty = qty / hu.UnitQty;
            hu.UnitCount = qty;
            hu.LotNo = lotNo;
            hu.ManufactureDate = manufactureDate;
            hu.ManufactureParty = manufactureParty;
            hu.CreateUser = this.userMgr.GetMonitorUser();
            hu.CreateDate = DateTime.Now;
            hu.Status = BusinessConstants.CODE_MASTER_HU_STATUS_VALUE_CREATE;
            hu.LotSize = hu.Qty;

            this.huMgr.CreateHu(hu);
            this.numberControlMgr.ReverseUpdateHuId(barCode);

            return hu;
        }
Example #18
0
        /// <summary>
        /// 按Hu匹配
        /// </summary>
        /// <param name="resolver"></param>
        /// <returns>Resolver</returns>
        private bool MatchByHu(Resolver resolver, Hu hu, int locationLotDetId)
        {
            bool isMatch = false;

            if (resolver.CodePrefix == BusinessConstants.CODE_PREFIX_ASN)
            {
                #region   ASN
                if (resolver.Transformers != null && hu != null)
                {
                    foreach (Transformer transformer in resolver.Transformers)
                    {
                        if (transformer.ItemCode.ToUpper() == hu.Item.Code.ToUpper())
                        {
                            InProcessLocation ip = inProcessLocationMgr.LoadInProcessLocation(resolver.Code, true);
                            var count = ip.InProcessLocationDetails.Where(t => t.HuId.ToUpper() == hu.HuId.ToUpper()).Count();
                            isMatch = count == 1;
                            if (isMatch)
                            {
                                TransformerDetail NewTransformerDetail = TransformerHelper.ConvertHuToTransformerDetail(hu);
                                if (resolver.BinCode != null && resolver.BinCode.Trim() != string.Empty)
                                {
                                    NewTransformerDetail.StorageBinCode = resolver.BinCode;
                                }
                                NewTransformerDetail.LocationLotDetId = locationLotDetId;
                                NewTransformerDetail.Sequence = this.FindMaxSeq(resolver.Transformers) + 1;
                                transformer.AddTransformerDetail(NewTransformerDetail);
                                TransformerHelper.ProcessTransformer(transformer);
                                break;
                            }
                        }
                    }
                }
                #endregion
            }
            else
            {
                #region 老的逻辑
                if (resolver.Transformers != null && hu != null)
                {
                    foreach (Transformer transformer in resolver.Transformers)
                    {
                        if (transformer.TransformerDetails != null && transformer.TransformerDetails.Count > 0)
                        {
                            foreach (TransformerDetail transformerDetail in transformer.TransformerDetails)
                            {
                                if (resolver.ModuleType == BusinessConstants.TRANSFORMER_MODULE_TYPE_PICKLIST)
                                {
                                    if (this.locationMgr.IsHuOcuppyByPickList(hu.HuId))
                                    {
                                        //判断条码是否被拣货单占用
                                        throw new BusinessErrorException("Order.Error.PickUp.HuOcuppied", hu.HuId);
                                    }
                                }

                                if (transformerDetail.HuId != null
                                    && transformerDetail.HuId.ToUpper() == hu.HuId.ToUpper())
                                {
                                    transformerDetail.StorageBinCode = resolver.BinCode;
                                    transformerDetail.CurrentQty = hu.Qty;
                                    transformerDetail.LocationLotDetId = locationLotDetId;
                                    transformerDetail.Sequence = this.FindMaxSeq(resolver.Transformers) + 1;
                                    isMatch = true;
                                    break;
                                }
                            }

                            if (isMatch)
                            {
                                TransformerHelper.ProcessTransformer(transformer);
                                break;
                            }
                        }
                    }
                }
                #endregion
            }
            return isMatch;
        }
 public virtual void CreateHu(Hu entity)
 {
     entityDao.CreateHu(entity);
 }
Example #20
0
 private bool MatchByItem(Resolver resolver, Hu hu)
 {
     return MatchByItem(resolver, hu, 0);
 }
 public virtual void DeleteHu(Hu entity)
 {
     entityDao.DeleteHu(entity);
 }
Example #22
0
 /// <summary>
 /// 缺省匹配规则,按Item匹配//暂不考虑超收超发,只有扫描条码的才有Item匹配逻辑
 /// FulfillUnitCount 需要重构
 /// 场景1:订单发运:不整包收发(FulfillUnitCount)就不匹配单包装
 /// 场景2:订单收货:不整包收发(FulfillUnitCount)就不匹配单包装
 /// 场景3:ASN收货:一定要匹配单包装,对供应商要求严格
 /// </summary>
 /// <param name="resolver"></param>
 /// <param name="hu"></param>
 /// <returns></returns>
 private bool MatchByItem(Resolver resolver, Hu hu, int locationLotDetId)
 {
     if (resolver.Transformers != null)
     {
         foreach (Transformer transformer in resolver.Transformers)
         {
             if (transformer.ItemCode.ToUpper() == hu.Item.Code.ToUpper()
                && transformer.UomCode.ToUpper() == hu.Uom.Code.ToUpper()
                && (transformer.UnitCount == hu.UnitCount || transformer.UnitCount == hu.LotSize || transformer.UnitCount == hu.Qty)
                && (transformer.Qty - transformer.CurrentQty >= hu.Qty || resolver.AllowExceed))
             {
                 TransformerDetail transformerDetail = TransformerHelper.ConvertHuToTransformerDetail(hu);
                 transformerDetail.StorageBinCode = resolver.BinCode;
                 transformerDetail.LocationLotDetId = locationLotDetId;
                 transformerDetail.Sequence = this.FindMaxSeq(resolver.Transformers) + 1;
                 transformer.AddTransformerDetail(transformerDetail);
                 TransformerHelper.ProcessTransformer(transformer);
                 return true;
             }
         }
         //没有匹配上,再次匹配
         if (resolver.CodePrefix == BusinessConstants.CODE_PREFIX_ORDER)
         {
             OrderHead orderHead = orderHeadMgr.LoadOrderHead(resolver.Code);
             if (!orderHead.FulfillUnitCount)
             {
                 foreach (Transformer transformer in resolver.Transformers)
                 {
                     if (transformer.ItemCode.ToUpper() == hu.Item.Code.ToUpper()
                        && transformer.UomCode.ToUpper() == hu.Uom.Code.ToUpper()
                        && (transformer.Qty - transformer.CurrentQty >= hu.Qty || resolver.AllowExceed))
                     {
                         TransformerDetail transformerDetail = TransformerHelper.ConvertHuToTransformerDetail(hu);
                         transformerDetail.StorageBinCode = resolver.BinCode;
                         transformerDetail.LocationLotDetId = locationLotDetId;
                         transformerDetail.Sequence = this.FindMaxSeq(resolver.Transformers) + 1;
                         transformer.AddTransformerDetail(transformerDetail);
                         TransformerHelper.ProcessTransformer(transformer);
                         return true;
                     }
                 }
             }
         }
     }
     return false;
 }
Example #23
0
        public IList<Hu> CreateHu(Item item, decimal qty, string lotNo, Uom uom, decimal unitCount, int? huLotSize,
            string orderNo, string recNo, DateTime? manufactureDate, Party manufactureParty, string qualityLevel, User user, Object obj, string shiftCode, string itemVersion, string idMark,string customerItemCode)
        {
            IList<Hu> huList = new List<Hu>();

            #region 根据Hu批量创建Hu
            decimal remainHuQty = qty;                                        //剩余量
            decimal currentHuQty = GetNextHuQty(ref remainHuQty, huLotSize);  //本次量
            DateTime dateTimeNow = DateTime.Now;

            while (currentHuQty > 0)
            {
                #region 创建Hu
                Hu hu = new Hu();
                #region HuId生成
                if (obj.GetType() == typeof(FlowDetail))
                {
                    FlowDetail flowDetail = (FlowDetail)obj;
                    if (flowDetail.Flow.Type != BusinessConstants.CODE_MASTER_FLOW_TYPE_VALUE_PRODUCTION)
                    {
                        lotNo = lotNo != null ? lotNo : LotNoHelper.GenerateLotNo();
                        hu.HuId = this.numberControlMgrE.GenerateRMHuId(flowDetail, lotNo, currentHuQty, idMark);
                    }
                    else
                    {
                        if (shiftCode != null && shiftCode.Trim().Length != 0)
                        {
                            lotNo = lotNo != null ? lotNo : LotNoHelper.GenerateLotNo();
                            hu.HuId = this.numberControlMgrE.GenerateFGHuId(flowDetail, shiftCode, currentHuQty, idMark);
                        }
                        else
                        {
                            throw new TechnicalException("ShiftCode can't be null when create fg huId by flowdetail");
                        }
                    }
                }
                else if (obj.GetType() == typeof(OrderDetail))
                {
                    OrderDetail orderDetail = (OrderDetail)obj;
                    if (orderDetail.OrderHead.Type != BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_PRODUCTION)
                    {
                        lotNo = lotNo != null ? lotNo : LotNoHelper.GenerateLotNo(orderDetail.OrderHead.WindowTime);
                        hu.HuId = this.numberControlMgrE.GenerateRMHuId(orderDetail, lotNo, currentHuQty, idMark);
                    }
                    else
                    {
                        lotNo = lotNo != null ? lotNo : LotNoHelper.GenerateLotNo(orderDetail.OrderHead.WindowTime);
                        hu.HuId = this.numberControlMgrE.GenerateFGHuId(orderDetail, currentHuQty, idMark);
                    }
                }
                else if (obj.GetType() == typeof(InProcessLocationDetail))
                {
                    InProcessLocationDetail inProcessLocationDetail = (InProcessLocationDetail)obj;
                    if (inProcessLocationDetail.OrderLocationTransaction.OrderDetail.OrderHead.Type
                        != BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_PRODUCTION)
                    {
                        lotNo = lotNo != null ? lotNo : LotNoHelper.GenerateLotNo();
                        hu.HuId = this.numberControlMgrE.GenerateRMHuId(inProcessLocationDetail, lotNo, currentHuQty);
                    }
                    else
                    {
                        throw new TechnicalException("Can't create fg huid by InProcessLocationDetail");
                    }
                }
                else if (obj.GetType() == typeof(ReceiptDetail))
                {
                    ReceiptDetail receiptDetail = (ReceiptDetail)obj;
                    if (receiptDetail.OrderLocationTransaction.OrderDetail.OrderHead.Type
                        != BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_PRODUCTION)
                    {
                        lotNo = lotNo != null ? lotNo : LotNoHelper.GenerateLotNo();
                        hu.HuId = this.numberControlMgrE.GenerateRMHuId(receiptDetail, lotNo, currentHuQty);
                    }
                    else
                    {
                        lotNo = lotNo != null ? lotNo : LotNoHelper.GenerateLotNo();
                        hu.HuId = this.numberControlMgrE.GenerateFGHuId(receiptDetail, currentHuQty);
                    }
                }
                else
                {
                    throw new TechnicalException("Parameter obj only accept type: FlowDetail, OrderDetail, InProcessLocationDetail, ReceiptDetail");
                }
                #endregion
                hu.Item = item;
                hu.OrderNo = orderNo;
                hu.ReceiptNo = recNo;
                hu.Uom = uom;   //用订单单位
                hu.UnitCount = unitCount;
                #region 单位用量
                //如果是OrderDetail,应该等于inOrderLocationTransaction.UnitQty,现在暂时直接用单位换算
                if (item.Uom.Code != uom.Code)
                {
                    hu.UnitQty = this.uomConversionMgrE.ConvertUomQty(item, uom, 1, item.Uom);   //单位用量
                }
                else
                {
                    hu.UnitQty = 1;
                }
                #endregion
                hu.QualityLevel = qualityLevel;
                hu.Qty = currentHuQty;
                hu.LotNo = lotNo;
                hu.ManufactureDate = manufactureDate.HasValue ? manufactureDate.Value : LotNoHelper.ResolveLotNo(hu.LotNo);
                hu.ManufactureParty = manufactureParty;
                hu.CreateUser = user;
                hu.CreateDate = dateTimeNow;
                hu.LotSize = huLotSize.HasValue ? huLotSize.Value : currentHuQty;
                hu.Version = itemVersion;
                hu.Status = BusinessConstants.CODE_MASTER_HU_STATUS_VALUE_CREATE;
                hu.CustomerItemCode = customerItemCode;

                this.CreateHu(hu);
                #endregion

                huList.Add(hu);
                currentHuQty = GetNextHuQty(ref remainHuQty, huLotSize);
            }
            #endregion

            return huList;
        }
Example #24
0
 private bool MatchByLot(Resolver resolver, Hu hu)
 {
     return MatchByLot(resolver, hu, 0);
 }
Example #25
0
        /// <summary>
        /// 按LotNo匹配
        /// </summary>
        /// <param name="resolver"></param>
        /// <param name="hu"></param>
        /// <returns></returns>
        private bool MatchByLot(Resolver resolver, Hu hu, int locationLotDetId)
        {
            if (resolver.Transformers != null && hu != null)
            {
                bool findMatch = false;
                foreach (Transformer transformer in resolver.Transformers)
                {
                    //先用零件号,单位和单包装匹配
                    if (transformer.ItemCode.ToUpper() == hu.Item.Code.ToUpper()
                        && transformer.UomCode.ToUpper() == hu.Uom.Code.ToUpper()
                        && (transformer.UnitCount == hu.UnitCount || transformer.UnitCount == hu.LotSize || transformer.UnitCount == hu.Qty))
                    {
                        findMatch = ProcessTransformerByLotNo(resolver, transformer, hu, locationLotDetId);

                        if (findMatch)
                        {
                            return findMatch;
                        }
                    }
                }

                foreach (Transformer transformer in resolver.Transformers)
                {
                    //没有找到再用零件号,单位匹配一次 零头先发
                    if (transformer.ItemCode.ToUpper() == hu.Item.Code.ToUpper()
                        && transformer.UomCode.ToUpper() == hu.Uom.Code.ToUpper()
                        && transformer.OddShipOption == BusinessConstants.CODE_MASTER_ODD_SHIP_OPTION_VALUE_SHIP_FIRST)
                    {
                        findMatch = ProcessTransformerByLotNo(resolver, transformer, hu, locationLotDetId);

                        if (findMatch)
                        {
                            return findMatch;
                        }
                    }
                }
            }
            return false;
        }
Example #26
0
        private bool ProcessTransformerByLotNo(Resolver resolver, Transformer transformer, Hu hu, int locationLotDetId)
        {
            if (transformer.Qty - transformer.CurrentQty >= hu.Qty
                && transformer.LotNo != null && transformer.LotNo.ToUpper() == hu.LotNo.ToUpper())
            {
                #region 如果是拣货/订单发货,要匹配库位和库格是否相同
                if (resolver.ModuleType == BusinessConstants.TRANSFORMER_MODULE_TYPE_PICKLIST ||
                    resolver.ModuleType == BusinessConstants.TRANSFORMER_MODULE_TYPE_SHIPORDER)
                {
                    if (this.locationMgr.IsHuOcuppyByPickList(hu.HuId))
                    {
                        //判断条码是否被拣货单占用
                        throw new BusinessErrorException("Order.Error.PickUp.HuOcuppied", hu.HuId);
                    }

                    if (hu.StorageBin != null && hu.StorageBin.Trim() != string.Empty &&
                        transformer.StorageBinCode != null &&
                        hu.StorageBin == transformer.StorageBinCode.Trim())
                    {
                        //有库格按照库格匹配
                    }
                    else if (hu.StorageBin != null && hu.StorageBin.Trim() != string.Empty
                            && hu.Location != null && hu.Location.Trim() != string.Empty &&
                         (transformer.StorageBinCode == null || transformer.StorageBinCode.Trim() == string.Empty) &&
                          transformer.LocationFromCode == hu.Location)
                    {
                        //都没有库格按照库位匹配
                    }
                    else
                    {
                        return false;
                    }
                }
                #endregion

                TransformerDetail NewTransformerDetail = TransformerHelper.ConvertHuToTransformerDetail(hu);
                if (resolver.BinCode != null && resolver.BinCode.Trim() != string.Empty)
                {
                    NewTransformerDetail.StorageBinCode = resolver.BinCode;
                }
                NewTransformerDetail.LocationLotDetId = locationLotDetId;
                NewTransformerDetail.Sequence = this.FindMaxSeq(resolver.Transformers) + 1;
                transformer.AddTransformerDetail(NewTransformerDetail);
                TransformerHelper.ProcessTransformer(transformer);
                return true;
            }
            return false;
        }
        private Hu ResolveAndCreateHu(string barCode, OrderDetail orderDetail, decimal qty)
        {
            string[] splitedBarcode = BarcodeHelper.SplitFGBarcode(barCode);
            Item item = orderDetail.Item;
            string lotNo = splitedBarcode[2];
            DateTime manufactureDate = LotNoHelper.ResolveLotNo(lotNo);

            Hu hu = new Hu();
            hu.HuId = barCode;
            hu.Item = item;
            hu.Uom = orderDetail.Uom;   //用Flow单位
            #region 单位用量
            if (item.Uom.Code != orderDetail.Uom.Code)
            {
                hu.UnitQty = this.uomConversionMgr.ConvertUomQty(item, orderDetail.Uom, 1, item.Uom);   //单位用量
            }
            else
            {
                hu.UnitQty = 1;
            }
            #endregion
            hu.QualityLevel = BusinessConstants.CODE_MASTER_ITEM_QUALITY_LEVEL_VALUE_1;
            hu.Qty = qty;
            hu.UnitCount = orderDetail.UnitCount;
            hu.LotNo = lotNo;
            hu.LotSize = qty;
            hu.ManufactureDate = manufactureDate;
            hu.ManufactureParty = orderDetail.OrderHead.PartyFrom;
            hu.CreateUser = this.userMgr.GetMonitorUser();
            hu.CreateDate = DateTime.Now;
            hu.Status = BusinessConstants.CODE_MASTER_HU_STATUS_VALUE_CREATE;

            this.huMgr.CreateHu(hu);
            this.numberControlMgr.ReverseUpdateHuId(barCode);

            return hu;
        }
Example #28
0
        public string CheckFIFO(Hu targetHu, IList<string> pickedHuList)
        {
            string pickBy = this.entityPreferenceMgr.LoadEntityPreference(BusinessConstants.ENTITY_PREFERENCE_CODE_PICK_BY).Value;
            if (pickBy == BusinessConstants.CODE_MASTER_PICKBY_HU)
            {
                throw new NotImplementedException();
            }
            else
            {
                DetachedCriteria criteria = DetachedCriteria.For<LocationLotDetail>().SetProjection(Projections.Min("LotNo"));
                criteria.CreateAlias("Location", "loc");
                criteria.CreateAlias("Hu", "hu");

                criteria.Add(Expression.Eq("Item", targetHu.Item));
                criteria.Add(Expression.Eq("loc.Code", targetHu.Location));
                criteria.Add(Expression.IsNotNull("Hu"));
                criteria.Add(Expression.Not(Expression.Eq("Qty", decimal.Zero)));
                criteria.Add(Expression.Lt("hu.ManufactureDate", targetHu.ManufactureDate));

                if (pickedHuList != null && pickedHuList.Count > 0)
                {
                    criteria.Add(Expression.Not(Expression.In("hu.HuId", pickedHuList.ToArray())));
                }

                IList<string> result = this.criteriaMgr.FindAll<string>(criteria);

                return result[0];
            }
        }
Example #29
0
        private FlowView LoadFlowView(string flowCode, string userCode, string locationFromCode, string locationToCode, Hu hu, List<string> flowTypes)
        {
            DetachedCriteria criteria = DetachedCriteria.For(typeof(FlowView));
            criteria.CreateAlias("Flow", "f");
            criteria.CreateAlias("FlowDetail", "fd");
            if (flowTypes != null && flowTypes.Count > 0)
            {
                if (flowTypes.Count == 1)
                {
                    criteria.Add(Expression.Eq("f.Type", flowTypes[0]));
                }
                else
                {
                    criteria.Add(Expression.In("f.Type", flowTypes));
                }
            }
            //权限待处理
            //if (userCode != null && userCode.Trim() != string.Empty)
            //{
            //    SecurityHelper.SetPartySearchCriteria(criteria, "PartyFromCode", userCode);
            //    SecurityHelper.SetPartySearchCriteria(criteria, "PartyToCode", userCode);
            //}
            if (locationFromCode != null && locationFromCode.Trim() != string.Empty)
            {
                criteria.Add(Expression.Eq("LocationFrom.Code", locationFromCode));
            }
            if (locationToCode != null && locationToCode.Trim() != string.Empty)
            {
                criteria.Add(Expression.Eq("LocationTo.Code", locationToCode));
            }
            if (flowCode != null && flowCode.Trim() != string.Empty)
            {
                criteria.Add(Expression.Eq("f.Code", flowCode));
            }
            criteria.Add(Expression.Eq("fd.Item.Code", hu.Item.Code));
            criteria.Add(Expression.Eq("fd.Uom.Code", hu.Uom.Code));
            //if (!allowCreateDetail)
            //{
            //    criteria.Add(Expression.Eq("ItemCode", hu.Item.Code));
            //    criteria.Add(Expression.Eq("UomCode", hu.Uom.Code));
            //    if (isMatchUnitCount)
            //    {
            //        criteria.Add(Expression.Eq("UnitCount", hu.UnitCount));
            //    }
            //}
            //criteria.Add(Expression.Eq("AllowCreateDetail", allowCreateDetail));

            IList<FlowView> list = criteriaMgrE.FindAll<FlowView>(criteria);

            if (list != null && list.Count > 0)
            {
                var query = new List<FlowView>(list.Where(f => f.FlowDetail.UnitCount == hu.UnitCount));
                if (query != null && query.Count > 0)
                {
                    //按物料号,单位,单包装严格匹配
                    return query[0];
                }
                //按物料号,单位匹配
                return list[0];
            }
            else
            {
                return null;
            }
        }
Example #30
0
        public void MatchInspet(Resolver resolver)
        {
            if (resolver.IsScanHu)
            {
                //if (this.CheckMatchHuScanExist(resolver))
                //{
                //    throw new BusinessErrorException("Warehouse.Error.HuReScan", resolver.Input);
                //}
                //没有必要重新检查库存
                //LocationLotDetail locationLotDetail = locationLotDetailMgr.LoadHuLocationLotDetail(string.Empty, resolver.Input, string.Empty);
                //Hu hu = locationLotDetail.Hu;
                Hu hu = new Hu();
                hu.HuId = resolver.Input;
                if (!this.MatchByHu(resolver, hu))
                {
                    //throw new BusinessErrorException("Warehouse.HuMatch.NotMatch", resolver.Input);
                    string locationCode = hu.Location == null && hu.Location.Trim() != string.Empty ? string.Empty : hu.Location;
                    throw new BusinessErrorException("Warehouse.Hu.NotMatch.HuInformation", hu.HuId, hu.Item.Code, hu.Item.Description,
                        hu.UnitCount.ToString("0.########"), hu.Qty.ToString("0.########"), hu.LotNo, locationCode, hu.Status);
                }
            }
            else
            {
                bool isMatch = false;
                if (resolver.Transformers != null)
                {
                    foreach (Transformer transformer in resolver.Transformers)
                    {
                        if (transformer.TransformerDetails != null && transformer.TransformerDetails.Count == 1)
                        {
                            foreach (TransformerDetail transformerDetail in transformer.TransformerDetails)
                            {

                                if (transformerDetail.CurrentQty + transformerDetail.CurrentRejectQty > transformerDetail.Qty)
                                {
                                    transformerDetail.CurrentQty = 0;
                                    transformerDetail.CurrentRejectQty = 0;
                                    throw new BusinessErrorException("Warehouse.Inspect.ItemMatch.QtyExcceed", transformerDetail.ItemCode);
                                }
                                else
                                {
                                    transformerDetail.CurrentQty = transformerDetail.Qty;
                                    transformerDetail.CurrentRejectQty = 0;
                                }
                                if (transformerDetail.ItemCode.ToLower() == resolver.Input.ToLower().Trim())
                                {
                                    isMatch = true;
                                }
                            }
                        }
                    }
                }
                if (!isMatch)
                {
                    throw new BusinessErrorException("Warehouse.ItemMatch.NotMatch", resolver.Input);
                }
            }
            resolver.Command = BusinessConstants.CS_BIND_VALUE_TRANSFORMERDETAIL;
        }