Esempio n. 1
0
 public void CreateInspectMaster(InspectMaster inspectMaster)
 {
     this.CreateInspectMaster(inspectMaster, DateTime.Now);
 }
Esempio n. 2
0
 public void CreateAndReject(InspectMaster inspectMaster)
 {
     CreateAndReject(inspectMaster, DateTime.Now);
 }
Esempio n. 3
0
        public void CreateAndReject(InspectMaster inspectMaster, DateTime effectiveDate)
        {
            CreateInspectMaster(inspectMaster, effectiveDate);

            foreach (InspectDetail inspectDetail in inspectMaster.InspectDetails)
            {
                inspectDetail.CurrentRejectQty = inspectDetail.InspectQty;
                inspectDetail.JudgeFailCode = inspectDetail.FailCode;
            }
            this.genericMgr.FlushSession();

            JudgeInspectDetail(inspectMaster.InspectDetails, effectiveDate);
        }
Esempio n. 4
0
        public InspectMaster TransferReceipt2Inspect(ReceiptMaster receiptMaster)
        {
            List<ReceiptLocationDetail> inspectReceiptLocationDetailList = new List<ReceiptLocationDetail>();
            IList<Region> createInspectRegonList = this.genericMgr.FindAll<Region>("from Region r where r.IsCreateInspect=?",true);
            if (createInspectRegonList != null && createInspectRegonList.Count > 0)
            {
                foreach (ReceiptDetail receiptDetail in receiptMaster.ReceiptDetails)
                {
                    int count = (from r in createInspectRegonList
                                where r.Code == receiptDetail.CurrentPartyTo
                                select r).Count();
                    if (receiptDetail.IsInspect && count > 0)
                    {
                        inspectReceiptLocationDetailList.AddRange(receiptDetail.ReceiptLocationDetails);
                    }
                }
                //1月1日上线除冲焊和涂装外,其他区域收货全都不需要报验
                //foreach (ReceiptDetail receiptDetail in receiptMaster.ReceiptDetails)
                //{
                //    string[] regionArray = new string[] { "CB1", "CP1", "HB1", "HP1", "TB1", "TP1", "TB2", "TP2" };

                //    int count = (from r in regionArray
                //                 where r.ToUpper() == receiptDetail.CurrentPartyTo.ToUpper()
                //                 select r).Count();
                //    if (receiptDetail.IsInspect && count > 0)
                //    {
                //        inspectReceiptLocationDetailList.AddRange(receiptDetail.ReceiptLocationDetails);
                //    }
                //}
                //根据region表中的IsCreateInspect来确定是否创建报验单


                if (inspectReceiptLocationDetailList != null && inspectReceiptLocationDetailList.Count > 0)
                {
                    #region 报验单头
                    InspectMaster inspectMaster = new InspectMaster();

                    inspectMaster.IpNo = receiptMaster.IpNo;
                    inspectMaster.ReceiptNo = receiptMaster.ReceiptNo;
                    inspectMaster.Region = receiptMaster.PartyTo;
                    inspectMaster.Status = com.Sconit.CodeMaster.InspectStatus.Submit;
                    //inspectMaster.Type = receiptMaster.CreateHuOption == CodeMaster.CreateHuOption.Receive || receiptMaster.IsReceiveScanHu ? com.Sconit.CodeMaster.InspectType.Barcode : com.Sconit.CodeMaster.InspectType.Quantity;
                    inspectMaster.Type = inspectReceiptLocationDetailList.Where(locDet => !string.IsNullOrWhiteSpace(locDet.HuId)).Count() > 0 ? com.Sconit.CodeMaster.InspectType.Barcode : com.Sconit.CodeMaster.InspectType.Quantity;
                    inspectMaster.IsATP = true;
                    inspectMaster.WMSNo = receiptMaster.WMSNo;
                    #endregion

                    #region 根据收货明细+条码+WMS行号汇总
                    var groupedInspectReceiptLocationDetailList = from locDet in inspectReceiptLocationDetailList
                                                                  group locDet by new
                                                                  {
                                                                      ReceiptDetailId = locDet.ReceiptDetailId,
                                                                      HuId = locDet.HuId,
                                                                      LotNo = locDet.LotNo,
                                                                      WMSSeq = locDet.WMSSeq,
                                                                      IsConsignment = locDet.IsConsignment,
                                                                      PlanBill = locDet.PlanBill,
                                                                  } into gj
                                                                  select new
                                                                  {
                                                                      ReceiptDetailId = gj.Key.ReceiptDetailId,
                                                                      HuId = gj.Key.HuId,
                                                                      LotNo = gj.Key.LotNo,
                                                                      WMSSeq = gj.Key.WMSSeq,
                                                                      IsConsignment = gj.Key.IsConsignment,
                                                                      PlanBill = gj.Key.PlanBill,
                                                                      ReceiveQty = gj.Sum(locDet => locDet.Qty),   //基本单位
                                                                  };
                    #endregion

                    #region 报验单明细
                    foreach (var groupedInspectReceiptLocationDetail in groupedInspectReceiptLocationDetailList)
                    {
                        ReceiptDetail receiptDetail = receiptMaster.ReceiptDetails.Where(det => det.Id == groupedInspectReceiptLocationDetail.ReceiptDetailId).Single();


                        InspectDetail inspectDetail = new InspectDetail();
                        inspectDetail.Item = receiptDetail.Item;
                        inspectDetail.ItemDescription = receiptDetail.ItemDescription;
                        inspectDetail.ReferenceItemCode = receiptDetail.ReferenceItemCode;
                        inspectDetail.BaseUom = receiptDetail.BaseUom;
                        inspectDetail.HuId = groupedInspectReceiptLocationDetail.HuId;
                        inspectDetail.LotNo = groupedInspectReceiptLocationDetail.LotNo;
                        inspectDetail.Uom = receiptDetail.Uom;
                        inspectDetail.UnitCount = receiptDetail.UnitCount;
                        inspectDetail.UnitQty = receiptDetail.UnitQty;
                        inspectDetail.LocationFrom = receiptDetail.LocationTo;
                        inspectDetail.CurrentLocation = receiptDetail.LocationTo;
                        inspectDetail.InspectQty = groupedInspectReceiptLocationDetail.ReceiveQty / inspectDetail.UnitQty;
                        inspectDetail.IsJudge = false;
                        inspectDetail.IpDetailSequence = receiptDetail.IpDetailSequence;
                        inspectDetail.ReceiptDetailSequence = receiptDetail.Sequence;
                        inspectDetail.WMSSeq = groupedInspectReceiptLocationDetail.WMSSeq;
                        inspectDetail.IsConsignment = groupedInspectReceiptLocationDetail.IsConsignment;
                        inspectDetail.PlanBill = groupedInspectReceiptLocationDetail.PlanBill;

                        inspectMaster.AddInspectDetail(inspectDetail);
                    }
                    #endregion

                    return inspectMaster;
                }
                else
                {
                    return null;
                }
            }
            else
            {
                return null;
            }
        }
Esempio n. 5
0
 private void TryCloseInspectMaster(InspectMaster inspectMaster)
 {
     string hql = "select count(*) as counter from InspectDetail where InspectNo = ? and IsJudge = ?";
     if (this.genericMgr.FindAll<long>(hql, new object[] { inspectMaster.InspectNo, false })[0] == 0)
     {
         inspectMaster.Status = CodeMaster.InspectStatus.Close;
         this.genericMgr.Update(inspectMaster);
     }
 }
Esempio n. 6
0
        public void CreateWorkersWaste(InspectMaster inspectMaster, DateTime effectiveDate)
        {
            #region 创建报验单
            CreateInspectMaster(inspectMaster, effectiveDate);
            #endregion

            #region 判定不合格
            foreach (InspectDetail inspectDetail in inspectMaster.InspectDetails)
            {
                inspectDetail.CurrentRejectQty = inspectDetail.InspectQty;
            }
            JudgeInspectDetail(inspectMaster.InspectDetails, effectiveDate);
            #endregion

            #region 创建不合格品处理单
            IList<InspectResult> inspectResultList = genericMgr.FindAll<InspectResult>("from InspectResult as r where r.InspectNo = ?", inspectMaster.InspectNo);
            foreach (InspectResult inspectResult in inspectResultList)
            {
                inspectResult.CurrentHandleQty = inspectResult.JudgeQty;
                inspectResult.RejectHandleResult = com.Sconit.CodeMaster.HandleResult.WorkersWaste;
            }
            RejectMaster  rejectMaster = CreateRejectMaster(com.Sconit.CodeMaster.HandleResult.WorkersWaste, inspectResultList);
            #endregion
            #region 释放不合格品处理单
            rejectMaster.Status = com.Sconit.CodeMaster.RejectStatus.Submit;
            genericMgr.Update(rejectMaster);
            #endregion
        }
Esempio n. 7
0
        public void CreateAndReject(InspectMaster inspectMaster, DateTime effectiveDate)
        {
            CreateInspectMaster(inspectMaster, effectiveDate);
            this.genericMgr.FlushSession();
            var inspectDetails = new List<InspectDetail>();
            foreach (InspectDetail inspectDetail in inspectMaster.InspectDetails)
            {
                //inspectDetail.CurrentRejectQty = inspectDetail.InspectQty;
                if (!string.IsNullOrWhiteSpace(inspectDetail.FailCode))
                {
                    inspectDetail.JudgeFailCode = inspectDetail.FailCode;
                    inspectDetail.CurrentQty = inspectDetail.InspectQty;
                    inspectDetails.Add(inspectDetail);
                }
            }

            JudgeInspectDetail(inspectDetails, effectiveDate);
        }
        public JsonResult New(string region, string locationFrom, [Bind(Prefix = "inserted")]IEnumerable<InspectDetail> insertedInspectDetails)
        {
            BusinessException businessException = new BusinessException();
            try
            {
                ViewBag.Region = region;
                ViewBag.LocationFrom = locationFrom;

                #region orderDetailList
                if (string.IsNullOrEmpty(locationFrom))
                {
                    throw new BusinessException(Resources.INP.InspectDetail.Errors_InspectDetail_LocationRequired);
                }

                IList<InspectDetail> inspectDetailList = new List<InspectDetail>();
                if (insertedInspectDetails != null && insertedInspectDetails.Count() > 0)
                {
                    int i = 1;
                    foreach (InspectDetail inspectDetail in insertedInspectDetails)
                    {
                        if (string.IsNullOrEmpty(inspectDetail.Item))
                        {
                            businessException.AddMessage(Resources.EXT.ControllerLan.Con_ItemCanNotBeEmpty + (i++) + Resources.EXT.ControllerLan.Con_RowItemCanNotBeEmpty);
                            continue;
                        }
                        if (inspectDetail.InspectQty <= 0)
                        {
                            businessException.AddMessage(Resources.EXT.ControllerLan.Con_ItemCanNotBeEmpty + (i++) + Resources.EXT.ControllerLan.Con_InspectionQuantityMustGreaterThenZero);
                            continue;
                        }
                        //if (string.IsNullOrEmpty(inspectDetail.FailCode))
                        //{
                        //    businessException.AddMessage("第" + (i++) + "失效代码为必填。");
                        //    continue;
                        //}

                        Item item = this.genericMgr.FindById<Item>(inspectDetail.Item);
                        inspectDetail.ItemDescription = item.Description;
                        inspectDetail.UnitCount = item.UnitCount;
                        inspectDetail.ReferenceItemCode = item.ReferenceCode;
                        inspectDetail.Uom = item.Uom;
                        inspectDetail.LocationFrom = locationFrom;
                        inspectDetail.CurrentLocation = locationFrom;
                        inspectDetail.BaseUom = item.Uom;
                        inspectDetail.UnitQty = 1;

                        inspectDetailList.Add(inspectDetail);

                    }
                }
                #endregion
                if (businessException.HasMessage)
                {
                    throw businessException;
                }
                if (inspectDetailList != null && inspectDetailList.Count == 0)
                {
                    throw new BusinessException(Resources.INP.InspectDetail.Errors_InspectDetail_Required);
                }

                InspectMaster inspectMaster = new InspectMaster();
                inspectMaster.Region = region;
                inspectMaster.InspectDetails = inspectDetailList;

                inspectMaster.Type = com.Sconit.CodeMaster.InspectType.Quantity;
                inspectMaster.IsATP = false;

                inspectMgr.CreateAndReject(inspectMaster);
                SaveSuccessMessage(Resources.INP.InspectMaster.InspectMaster_Added);

                return Json(new object[] { inspectMaster.InspectNo });
            }
            catch (Exception ex)
            {
                SaveErrorMessage(ex);
                return Json(null);
            }
        }
        public string CreateInspectionDetail(string ItemStr, string HuIdStr, string LocationStr, string InspectQtyStr, string FailCodeStr, string NoteStr)
        {
            try
            {
                if (!string.IsNullOrEmpty(ItemStr))
                {
                    string[] itemArray = ItemStr.Split(',');
                    string[] huidArray = HuIdStr.Split(',');
                    string[] locationArray = LocationStr.Split(',');
                    string[] inspectqtyArray = InspectQtyStr.Split(',');
                    string[] falicodeArray = FailCodeStr.Split(',');
                    string[] noteArray = NoteStr.Split(',');
                    IList<InspectDetail> inspectDetailList = new List<InspectDetail>();
                    int i = 0;
                    foreach (string itemcode in itemArray)
                    {
                        InspectDetail inspectDetail = new InspectDetail();
                        Item item = this.genericMgr.FindById<Item>(itemcode);
                        inspectDetail.ItemDescription = item.Description;
                        inspectDetail.UnitCount = item.UnitCount;
                        inspectDetail.ReferenceItemCode = item.ReferenceCode;
                        inspectDetail.Uom = item.Uom;

                        inspectDetail.BaseUom = item.Uom;
                        inspectDetail.UnitQty = 1;
                        inspectDetail.LocationFrom = locationArray[i];
                        inspectDetail.CurrentLocation = locationArray[i];
                        inspectDetail.FailCode = falicodeArray[i];
                        inspectDetail.Note = noteArray[i];
                        inspectDetail.HuId = huidArray[i];
                        inspectDetail.InspectQty = Convert.ToDecimal(inspectqtyArray[i]);
                        i++;
                        inspectDetailList.Add(inspectDetail);
                    }

                    if (inspectDetailList != null && inspectDetailList.Count == 0)
                    {
                        throw new BusinessException(Resources.INP.InspectDetail.Errors_InspectDetail_Required);
                    }

                    InspectMaster inspectMaster = new InspectMaster();

                    inspectMaster.InspectDetails = inspectDetailList;

                    inspectMaster.Type = com.Sconit.CodeMaster.InspectType.Barcode;
                    inspectMaster.IsATP = false;

                    inspectMgr.CreateInspectMaster(inspectMaster);
                    SaveSuccessMessage(Resources.INP.InspectMaster.InspectMaster_Added);
                    this._CleanInspectionDetail();
                    return inspectMaster.InspectNo;
                }
                else
                {
                    throw new BusinessException(Resources.INP.InspectDetail.Errors_InspectDetail_Required);
                }

            }
            catch (BusinessException ex)
            {
                Response.TrySkipIisCustomErrors = true;
                Response.StatusCode = 500;
                Response.Write(ex.GetMessages()[0].GetMessageString());

                return string.Empty;
            }
        }
Esempio n. 10
0
        public IList<InventoryTransaction> InspectJudge(InspectMaster inspectMaster, IList<InspectResult> inspectResultList, DateTime effectiveDate)
        {
            if (inspectResultList == null || inspectResultList.Count == 0)
            {
                return null;
            }

            List<InventoryTransaction> inventoryTransactionList = new List<InventoryTransaction>();

            foreach (InspectResult inspectResult in inspectResultList)
            {
                #region 判定出库
                InventoryIO inventoryOut = new InventoryIO();

                inventoryOut.Location = inspectResult.CurrentLocation;
                inventoryOut.Item = inspectResult.Item;
                inventoryOut.HuId = inspectResult.HuId;
                inventoryOut.Qty = -inspectResult.JudgeQty * inspectResult.UnitQty;  //转换为库存单位,为负数
                inventoryOut.LotNo = inspectResult.LotNo;
                //inventoryOut.ManufactureParty = null;
                inventoryOut.QualityType = com.Sconit.CodeMaster.QualityType.Inspect; //判定一定是待验
                inventoryOut.IsATP = inspectMaster.IsATP;
                inventoryOut.IsFreeze = false;
                inventoryOut.IsCreatePlanBill = false;
                inventoryOut.IsConsignment = false;
                inventoryOut.PlanBill = null;
                inventoryOut.ActingBill = null;
                inventoryOut.TransactionType = inspectResult.JudgeResult == CodeMaster.JudgeResult.Qualified ? CodeMaster.TransactionType.ISS_INP_QDII : CodeMaster.TransactionType.ISS_INP_REJ;
                inventoryOut.OccupyType = CodeMaster.OccupyType.Inspect;
                inventoryOut.OccupyReferenceNo = inspectMaster.InspectNo;
                inventoryOut.IsVoid = false;
                inventoryOut.EffectiveDate = effectiveDate;
                inventoryOut.ManufactureParty = inspectResult.ManufactureParty;

                IList<InventoryTransaction> currentInventoryOutTransactionList = RecordInventory(inventoryOut);

                RecordLocationTransaction(inspectMaster, inspectResult, effectiveDate, currentInventoryOutTransactionList, true);
                inventoryTransactionList.AddRange(currentInventoryOutTransactionList);
                #endregion

                #region 判定入库
                foreach (InventoryTransaction currentInventoryOutTransaction in currentInventoryOutTransactionList)
                {
                    InventoryIO inventoryIn = new InventoryIO();

                    inventoryIn.Location = inspectResult.CurrentLocation;
                    inventoryIn.Item = inspectResult.Item;
                    inventoryIn.HuId = inspectResult.HuId;
                    //inventoryIn.Qty = inspectResult.JudgeQty * inspectResult.UnitQty;  //转换为库存单位
                    inventoryIn.Qty = -currentInventoryOutTransaction.Qty;  //转换为库存单位
                    inventoryIn.LotNo = inspectResult.LotNo;
                    //inventoryIn.ManufactureParty = null;
                    inventoryIn.QualityType = inspectResult.JudgeResult == CodeMaster.JudgeResult.Qualified
                        ? CodeMaster.QualityType.Qualified : CodeMaster.QualityType.Reject;  //判定合格为合格品,不合格为不合格品
                    inventoryIn.IsATP = inspectResult.JudgeResult == CodeMaster.JudgeResult.Qualified;  //合格为可用,不合格为不可用
                    inventoryIn.IsFreeze = false;
                    inventoryIn.IsCreatePlanBill = false;
                    inventoryIn.IsConsignment = currentInventoryOutTransaction.IsConsignment;
                    inventoryIn.PlanBill = currentInventoryOutTransaction.PlanBill;
                    inventoryIn.ActingBill = null;
                    inventoryIn.TransactionType = inspectResult.JudgeResult == CodeMaster.JudgeResult.Qualified
                        ? CodeMaster.TransactionType.RCT_INP_QDII : CodeMaster.TransactionType.RCT_INP_REJ;
                    inventoryIn.OccupyType = CodeMaster.OccupyType.None;   //判定完就不占用了
                    inventoryIn.OccupyReferenceNo = null;
                    inventoryIn.IsVoid = false;
                    inventoryIn.EffectiveDate = effectiveDate;
                    //inventoryIO.ManufactureParty = ;
                    inventoryIn.Bin = currentInventoryOutTransaction.Bin;//自动上架

                    IList<InventoryTransaction> currentInventoryInTransactionList = RecordInventory(inventoryIn);

                    RecordLocationTransaction(inspectMaster, inspectResult, effectiveDate, currentInventoryInTransactionList, false);
                    inventoryTransactionList.AddRange(currentInventoryInTransactionList);
                }
                #endregion
            }

            return inventoryTransactionList;
        }
Esempio n. 11
0
        private void RecordLocationTransaction(InspectMaster inspectMaster, InspectResult inspectResult, DateTime effectiveDate, IList<InventoryTransaction> inventoryTransactionList, bool isIssue)
        {
            DateTime dateTimeNow = DateTime.Now;

            //根据PlanBill和ActingBill分组,为了不同供应商的库存事务分开
            var groupedInventoryTransactionList = from trans in inventoryTransactionList
                                                  group trans by new
                                                  {
                                                      IsConsignment = trans.IsConsignment,
                                                      PlanBill = trans.PlanBill,
                                                      ActingBill = trans.ActingBill
                                                  }
                                                      into result
                                                      select new
                                                      {
                                                          IsConsignment = result.Key.IsConsignment,
                                                          PlanBill = result.Key.PlanBill,
                                                          ActingBill = result.Key.ActingBill,
                                                          //Qty = result.Sum(trans => isIssue ? -trans.Qty : trans.Qty),
                                                          Qty = result.Sum(trans => trans.Qty),
                                                          //PlanBillQty = result.Sum(trans => isIssue ? -trans.PlanBillQty : trans.PlanBillQty),
                                                          PlanBillQty = result.Sum(trans => trans.PlanBillQty),
                                                          //ActingBillQty = result.Sum(trans => isIssue ? -trans.ActingBillQty : trans.ActingBillQty),
                                                          ActingBillQty = result.Sum(trans => trans.ActingBillQty),
                                                          InventoryTransactionList = result.ToList()
                                                      };

            foreach (var groupedInventoryTransaction in groupedInventoryTransactionList)
            {
                LocationTransaction locationTransaction = new LocationTransaction();

                locationTransaction.OrderNo = inspectResult.InspectNo;
                //locationTransaction.OrderType = ;
                //locationTransaction.OrderSubType = ;
                //locationTransaction.OrderDetailSequence = ;
                locationTransaction.OrderDetailId = inspectResult.Id;
                //locationTransaction.OrderBomDetId = 
                //locationTransaction.IpNo = 
                //locationTransaction.IpDetailId = 
                //locationTransaction.IpDetailSequence = 
                //locationTransaction.ReceiptNo = 
                //locationTransaction.ReceiptDetailId = 
                //locationTransaction.ReceiptDetailSequence = 
                //locationTransaction.SequenceNo = 
                //locationTransaction.TraceCode = ;
                locationTransaction.Item = inspectResult.Item;
                locationTransaction.Uom = inspectResult.Uom;
                locationTransaction.BaseUom = inspectResult.BaseUom;
                locationTransaction.Qty = groupedInventoryTransaction.Qty / inspectResult.UnitQty;
                locationTransaction.UnitQty = inspectResult.UnitQty;
                locationTransaction.IsConsignment = groupedInventoryTransaction.IsConsignment;
                if (groupedInventoryTransaction.IsConsignment && groupedInventoryTransaction.PlanBill.HasValue)
                {
                    locationTransaction.PlanBill = groupedInventoryTransaction.PlanBill.Value;
                }
                locationTransaction.PlanBillQty = groupedInventoryTransaction.PlanBillQty / inspectResult.UnitQty;
                if (groupedInventoryTransaction.ActingBill.HasValue)
                {
                    locationTransaction.ActingBill = groupedInventoryTransaction.ActingBill.Value;
                }
                locationTransaction.ActingBillQty = groupedInventoryTransaction.ActingBillQty / inspectResult.UnitQty;
                locationTransaction.QualityType = isIssue ?
                    CodeMaster.QualityType.Inspect : (inspectResult.JudgeResult == CodeMaster.JudgeResult.Qualified ?
                                                        CodeMaster.QualityType.Qualified : CodeMaster.QualityType.Reject);
                locationTransaction.HuId = inspectResult.HuId;
                locationTransaction.LotNo = inspectResult.LotNo;
                locationTransaction.TransactionType = isIssue ?
                   (inspectResult.JudgeResult == CodeMaster.JudgeResult.Qualified ?
                        CodeMaster.TransactionType.ISS_INP_QDII : CodeMaster.TransactionType.ISS_INP_REJ)
                 : (inspectResult.JudgeResult == CodeMaster.JudgeResult.Qualified ?
                        CodeMaster.TransactionType.RCT_INP_QDII : CodeMaster.TransactionType.RCT_INP_REJ);
                locationTransaction.IOType = isIssue ? CodeMaster.TransactionIOType.Out : CodeMaster.TransactionIOType.In;
                locationTransaction.PartyFrom = inspectMaster.Region;
                locationTransaction.PartyTo = inspectMaster.Region;
                locationTransaction.LocationFrom = inspectResult.CurrentLocation;
                locationTransaction.LocationTo = inspectResult.CurrentLocation;
                locationTransaction.LocationIOReason = string.Empty;
                locationTransaction.EffectiveDate = effectiveDate;
                locationTransaction.CreateUserId = SecurityContextHolder.Get().Id;
                locationTransaction.CreateDate = dateTimeNow;

                this.genericMgr.Create(locationTransaction);
                RecordLocationTransactionDetail(locationTransaction, inventoryTransactionList);
            }
        }
Esempio n. 12
0
 public IList<InventoryTransaction> InspectJudge(InspectMaster inspectMaster, IList<InspectResult> inspectResultList)
 {
     return InspectJudge(inspectMaster, inspectResultList, DateTime.Now);
 }
Esempio n. 13
0
        public IList<InventoryTransaction> InventoryInspect(InspectMaster inspectMaster, DateTime effectiveDate)
        {
            if (inspectMaster.InspectDetails == null || inspectMaster.InspectDetails.Count == 0)
            {
                return null;
            }

            List<InventoryTransaction> inventoryTransactionList = new List<InventoryTransaction>();

            foreach (InspectDetail inspectDetail in inspectMaster.InspectDetails.OrderByDescending(det => det.IsConsignment))
            {
                #region 检验出库
                InventoryIO inventoryOut = new InventoryIO();

                inventoryOut.Location = inspectDetail.LocationFrom;
                inventoryOut.Item = inspectDetail.Item;
                inventoryOut.HuId = inspectDetail.HuId;
                inventoryOut.Qty = -inspectDetail.InspectQty * inspectDetail.UnitQty;  //转换为库存单位,为负数
                inventoryOut.LotNo = inspectDetail.LotNo;
                //inventoryOut.ManufactureParty = null;
                inventoryOut.QualityType = com.Sconit.CodeMaster.QualityType.Qualified; //报验一定是合格品
                inventoryOut.IsATP = true;
                inventoryOut.IsFreeze = false;
                inventoryOut.IsCreatePlanBill = false;
                inventoryOut.IsConsignment = inspectDetail.IsConsignment;
                inventoryOut.PlanBill = inspectDetail.PlanBill;
                inventoryOut.ActingBill = null;
                inventoryOut.TransactionType = inspectMaster.IsATP ? CodeMaster.TransactionType.ISS_INP : CodeMaster.TransactionType.ISS_ISL;
                inventoryOut.OccupyType = CodeMaster.OccupyType.None;
                inventoryOut.OccupyReferenceNo = null;
                inventoryOut.IsVoid = false;
                inventoryOut.EffectiveDate = effectiveDate;
                inventoryOut.ManufactureParty = inspectDetail.ManufactureParty;

                IList<InventoryTransaction> currentInventoryOutTransactionList = RecordInventory(inventoryOut);

                RecordLocationTransaction(inspectDetail, inspectMaster, effectiveDate, currentInventoryOutTransactionList, true);
                inventoryTransactionList.AddRange(currentInventoryOutTransactionList);
                #endregion


                #region 检验入库
                foreach (InventoryTransaction currentInventoryOutTransaction in currentInventoryOutTransactionList)
                {
                    InventoryIO inventoryIn = new InventoryIO();

                    inventoryIn.Location = inspectDetail.LocationFrom;
                    inventoryIn.Item = inspectDetail.Item;
                    inventoryIn.HuId = inspectDetail.HuId;
                    inventoryIn.Qty = -currentInventoryOutTransaction.Qty;
                    inventoryIn.LotNo = inspectDetail.LotNo;
                    //inventoryIn.ManufactureParty = null;
                    inventoryIn.QualityType = com.Sconit.CodeMaster.QualityType.Inspect; //报验入库为待验状态
                    inventoryIn.IsATP = inspectMaster.IsATP; //使用报验单上的可用标记,如果是二次检验的为false
                    inventoryIn.IsFreeze = false;
                    inventoryIn.IsCreatePlanBill = false;
                    inventoryIn.IsConsignment = currentInventoryOutTransaction.IsConsignment;
                    inventoryIn.PlanBill = currentInventoryOutTransaction.PlanBill;
                    inventoryIn.ActingBill = null;
                    inventoryIn.TransactionType = inspectMaster.IsATP ? CodeMaster.TransactionType.RCT_INP : CodeMaster.TransactionType.RCT_ISL;
                    inventoryIn.OccupyType = CodeMaster.OccupyType.Inspect;
                    inventoryIn.OccupyReferenceNo = inspectMaster.InspectNo;
                    inventoryIn.IsVoid = false;
                    inventoryIn.EffectiveDate = effectiveDate;
                    //inventoryIO.ManufactureParty = ;

                    IList<InventoryTransaction> currentInventoryInTransactionList = RecordInventory(inventoryIn);

                    RecordLocationTransaction(inspectDetail, inspectMaster, effectiveDate, currentInventoryInTransactionList, false);
                    inventoryTransactionList.AddRange(currentInventoryInTransactionList);
                }
                #endregion
            }

            return inventoryTransactionList;
        }
Esempio n. 14
0
 public IList<InventoryTransaction> InventoryInspect(InspectMaster inspectMaster)
 {
     return InventoryInspect(inspectMaster, DateTime.Now);
 }
Esempio n. 15
0
        public void CreateInspectMaster(InspectMaster inspectMaster, DateTime effectiveDate)
        {
            #region 检查
            if (inspectMaster.InspectDetails == null || inspectMaster.InspectDetails.Where(i => i.InspectQty > 0 || !string.IsNullOrWhiteSpace(i.HuId)).Count() == 0)
            {
                throw new BusinessException("报验单明细不能为空。");
            }

            inspectMaster.InspectDetails = inspectMaster.InspectDetails.Where(i => i.InspectQty > 0 || !string.IsNullOrWhiteSpace(i.HuId)).OrderBy(det => det.Sequence).ToList();
            if (inspectMaster.Type == CodeMaster.InspectType.Barcode)
            {
                BusinessException businessException = new BusinessException();
                IList<HuStatus> huStatusList = huMgr.GetHuStatus(inspectMaster.InspectDetails.Select(i => i.HuId).ToList());
                #region 查找零件
                string hql = string.Empty;
                IList<object> paras = new List<object>();
                foreach (string itemCode in huStatusList.Select(i => i.Item).Distinct())
                {
                    if (hql == string.Empty)
                    {
                        hql = "from Item where Code in (?";
                    }
                    else
                    {
                        hql += ", ?";
                    }
                    paras.Add(itemCode);
                }
                hql += ")";
                IList<Item> itemList = this.genericMgr.FindAll<Item>(hql, paras.ToArray());
                #endregion

                int seq = 1; //新的序号
                foreach (InspectDetail inspectDetail in inspectMaster.InspectDetails)
                {
                    HuStatus huStatus = huStatusList.Where(h => h.HuId == inspectDetail.HuId).SingleOrDefault();
                    if (huStatus == null)
                    {
                        businessException.AddMessage("条码{0}不存在。", inspectDetail.HuId);
                    }
                    else if (huStatus.Status == CodeMaster.HuStatus.NA)
                    {
                        businessException.AddMessage("条码{0}不在任何库位中,不能报验。", huStatus.HuId);
                    }
                    else if (huStatus.Status == CodeMaster.HuStatus.Ip)
                    {
                        businessException.AddMessage("条码{0}为库位{1}至库位{2}的在途库存,不能报验。", huStatus.HuId, huStatus.LocationFrom, huStatus.LocationTo);
                    }
                    else if (huStatus.OccupyType != CodeMaster.OccupyType.None)
                    {
                        businessException.AddMessage("条码{0}已经被占用,不能报验", huStatus.HuId);
                    }
                    else
                    {
                        inspectDetail.Sequence = seq++;
                        inspectDetail.Item = huStatus.Item;
                        inspectDetail.ItemDescription = itemList.Where(i => i.Code == huStatus.Item).Single().Description;
                        inspectDetail.ReferenceItemCode = huStatus.ReferenceItemCode;
                        inspectDetail.UnitCount = huStatus.UnitCount;
                        inspectDetail.Uom = huStatus.Uom;
                        inspectDetail.BaseUom = huStatus.BaseUom;
                        inspectDetail.UnitQty = huStatus.UnitQty;
                        inspectDetail.LotNo = huStatus.LotNo;
                        inspectDetail.LocationFrom = huStatus.Location;
                        inspectDetail.CurrentLocation = huStatus.Location;
                        inspectDetail.InspectQty = huStatus.Qty;
                    }
                }

                #region 检查报验零件是否在同一个区域中
                IList<string> regionList = huStatusList.Select(l => l.Region).Distinct().ToList();
                if (regionList != null && regionList.Count > 1)
                {
                    throw new BusinessException("条码的库位属于不同区域不能合并报验。");
                }

                inspectMaster.Region = regionList.Single();
                #endregion

                if (businessException.HasMessage)
                {
                    throw businessException;
                }
            }
            #endregion

            #region 创建报验单头
            inspectMaster.InspectNo = this.numberControlMgr.GetInspectNo(inspectMaster);
            this.genericMgr.Create(inspectMaster);
            #endregion

            #region 创建报验单明细
            foreach (var inspectDetail in inspectMaster.InspectDetails)
            {
                inspectDetail.InspectNo = inspectMaster.InspectNo;
                inspectDetail.ManufactureParty = inspectMaster.ManufactureParty;
                this.genericMgr.Create(inspectDetail);
            }
            #endregion

            #region 库存操作
            locationDetailMgr.InventoryInspect(inspectMaster, effectiveDate);
            #endregion
        }
        public string New(string checkedIds, string Region)
        {
            IList<LocationLotDetail> viewLocationList = new List<LocationLotDetail>();

            string[] checkedIdArray = checkedIds.Split(',');
            string selectStatement = string.Empty;
            IList<object> selectPartyPara = new List<object>();
            foreach (var para in checkedIdArray)
            {
                if (selectStatement == string.Empty)
                {
                    selectStatement = "from LocationLotDetail where Id in (?";
                }
                else
                {
                    selectStatement += ",?";
                }
                selectPartyPara.Add(para);
            }
            selectStatement += ")";

            viewLocationList = genericMgr.FindAll<LocationLotDetail>(selectStatement, selectPartyPara.ToArray());

            BusinessException businessException = new BusinessException();
            try
            {
                #region orderDetailList

                IList<InspectDetail> inspectDetailList = new List<InspectDetail>();
                if (viewLocationList != null && viewLocationList.Count() > 0)
                {
                    foreach (LocationLotDetail locationlotdetail in viewLocationList)
                    {
                        InspectDetail inspectDetail = new InspectDetail();
                        Item item = this.genericMgr.FindById<Item>(locationlotdetail.Item);
                        inspectDetail.Item = locationlotdetail.Item;
                        inspectDetail.HuId = locationlotdetail.HuId;
                        inspectDetail.LotNo = locationlotdetail.LotNo;
                        inspectDetail.ItemDescription = item.Description;
                        inspectDetail.UnitCount = locationlotdetail.UnitCount;
                        inspectDetail.ReferenceItemCode = item.ReferenceCode;
                        inspectDetail.Uom = item.Uom;
                        inspectDetail.LocationFrom =locationlotdetail.Location;
                        inspectDetail.CurrentLocation = locationlotdetail.Location;
                        inspectDetail.BaseUom = item.Uom;
                        inspectDetail.UnitQty = 1;

                        inspectDetailList.Add(inspectDetail);

                    }
                }
                #endregion
                if (businessException.HasMessage)
                {
                    throw businessException;
                }
                if (inspectDetailList != null && inspectDetailList.Count == 0)
                {
                    throw new BusinessException(Resources.INP.InspectDetail.Errors_InspectDetail_Required);
                }
             

                InspectMaster inspectMaster = new InspectMaster();
                inspectMaster.Region = Region;
                inspectMaster.InspectDetails = inspectDetailList;

                inspectMaster.Type = com.Sconit.CodeMaster.InspectType.Barcode;
                inspectMaster.IsATP = false;

                inspectMgr.CreateInspectMaster(inspectMaster);
                SaveSuccessMessage(Resources.INP.InspectMaster.InspectMaster_Added);
                return inspectMaster.InspectNo;

            }
            catch (BusinessException ex)
            {
                Response.TrySkipIisCustomErrors = true;
                Response.StatusCode = 500;
                string messagesStr = "";
                IList<Message> messageList = ex.GetMessages();
                foreach (Message message in messageList)
                {
                    messagesStr +=  message.GetMessageString() ;
                }
                Response.Write(messagesStr);
                return string.Empty;
            }

        }
Esempio n. 17
0
 public void CreateWorkersWaste(InspectMaster inspectMaster)
 {
     CreateWorkersWaste(inspectMaster, DateTime.Now);
 }
Esempio n. 18
0
        public string WorkersWasteCreate(string region, string locationFrom, [Bind(Prefix =
              "inserted")]IEnumerable<InspectDetail> insertedInspectDetails)
        {
            try
            {
                ViewBag.Region = region;
                ViewBag.LocationFrom = locationFrom;

                #region orderDetailList
                if (string.IsNullOrEmpty(locationFrom))
                {
                    throw new BusinessException(Resources.INP.InspectDetail.Errors_InspectDetail_LocationRequired);
                }

                IList<InspectDetail> inspectDetailList = new List<InspectDetail>();
                if (insertedInspectDetails != null && insertedInspectDetails.Count() > 0)
                {
                    foreach (InspectDetail inspectDetail in insertedInspectDetails)
                    {
                        if (!string.IsNullOrEmpty(inspectDetail.Item) && inspectDetail.InspectQty > 0)
                        {
                            Item item = base.genericMgr.FindById<Item>(inspectDetail.Item);
                            inspectDetail.ItemDescription = item.Description;
                            inspectDetail.UnitCount = item.UnitCount;
                            inspectDetail.ReferenceItemCode = item.ReferenceCode;
                            inspectDetail.Uom = item.Uom;
                            inspectDetail.LocationFrom = locationFrom;
                            inspectDetail.CurrentLocation = locationFrom;
                            inspectDetail.BaseUom = item.Uom;
                            inspectDetail.UnitQty = 1;
                            inspectDetailList.Add(inspectDetail);
                        }
                    }
                }
                #endregion

                if (inspectDetailList != null && inspectDetailList.Count == 0)
                {
                    throw new BusinessException("工废明细不能为空");
                }

                InspectMaster inspectMaster = new InspectMaster();
                inspectMaster.Region = region;
                inspectMaster.InspectDetails = inspectDetailList;

                inspectMaster.Type = com.Sconit.CodeMaster.InspectType.Quantity;
                inspectMaster.IsATP = false;

                inspectMgr.CreateWorkersWaste(inspectMaster);
                SaveSuccessMessage("工废创建成功");
                return "Success";

            }
            catch (BusinessException ex)
            {
                Response.TrySkipIisCustomErrors = true;
                Response.StatusCode = 500;
                Response.Write(ex.GetMessages()[0].GetMessageString());
                return string.Empty;
            }

        }
Esempio n. 19
0
        public string GetInspectNo(InspectMaster inspectMaster)
        {
            SqlParameter[] parm = new SqlParameter[4];

            parm[0] = new SqlParameter("@Type", SqlDbType.TinyInt);
            parm[0].Value = inspectMaster.Type;

            parm[1] = new SqlParameter("@Region", SqlDbType.VarChar, 50);
            parm[1].Value = inspectMaster.Region;

            parm[2] = new SqlParameter("@IsAtp", SqlDbType.Bit);
            parm[2].Value = inspectMaster.IsATP;

            parm[3] = new SqlParameter("@InsNo", SqlDbType.VarChar, 100);
            parm[3].Direction = ParameterDirection.InputOutput;

            sqlDao.ExecuteStoredProcedure("USP_GetDocNo_INS", parm);

            return parm[3].Value.ToString();
        }
Esempio n. 20
0
        public InspectMaster TransferReceipt2Inspect(ReceiptMaster receiptMaster)
        {
            List<ReceiptLocationDetail> inspectReceiptLocationDetailList = new List<ReceiptLocationDetail>();
            foreach (ReceiptDetail receiptDetail in receiptMaster.ReceiptDetails)
            {
                if (receiptDetail.IsInspect)
                {
                    inspectReceiptLocationDetailList.AddRange(receiptDetail.ReceiptLocationDetails);
                }
            }

            if (inspectReceiptLocationDetailList != null && inspectReceiptLocationDetailList.Count > 0)
            {
                #region 报验单头
                InspectMaster inspectMaster = new InspectMaster();

                inspectMaster.IpNo = receiptMaster.IpNo;
                inspectMaster.ReceiptNo = receiptMaster.ReceiptNo;
                inspectMaster.Region = receiptMaster.PartyTo;
                inspectMaster.Status = com.Sconit.CodeMaster.InspectStatus.Submit;
                //inspectMaster.Type = receiptMaster.CreateHuOption == CodeMaster.CreateHuOption.Receive || receiptMaster.IsReceiveScanHu ? com.Sconit.CodeMaster.InspectType.Barcode : com.Sconit.CodeMaster.InspectType.Quantity;
                inspectMaster.Type = inspectReceiptLocationDetailList.Where(locDet => !string.IsNullOrWhiteSpace(locDet.HuId)).Count() > 0 ? com.Sconit.CodeMaster.InspectType.Barcode : com.Sconit.CodeMaster.InspectType.Quantity;
                inspectMaster.IsATP = true;
                inspectMaster.WMSNo = receiptMaster.WMSNo;
                inspectMaster.PartyFrom = receiptMaster.PartyFrom;
                inspectMaster.PartyFromName = receiptMaster.PartyFromName;
                #endregion

                #region 根据收货明细+条码+WMS行号汇总
                var groupedInspectReceiptLocationDetailList = from locDet in inspectReceiptLocationDetailList
                                                              group locDet by new
                                                              {
                                                                  ReceiptDetailId = locDet.ReceiptDetailId,
                                                                  HuId = locDet.HuId,
                                                                  LotNo = locDet.LotNo,
                                                                  WMSSeq = locDet.WMSSeq,
                                                                  IsConsignment = locDet.IsConsignment,
                                                                  PlanBill = locDet.PlanBill,
                                                              } into gj
                                                              select new
                                                              {
                                                                  ReceiptDetailId = gj.Key.ReceiptDetailId,
                                                                  HuId = gj.Key.HuId,
                                                                  LotNo = gj.Key.LotNo,
                                                                  WMSSeq = gj.Key.WMSSeq,
                                                                  IsConsignment = gj.Key.IsConsignment,
                                                                  PlanBill = gj.Key.PlanBill,
                                                                  ReceiveQty = gj.Sum(locDet => locDet.Qty),   //基本单位
                                                              };
                #endregion

                #region 报验单明细
                foreach (var groupedInspectReceiptLocationDetail in groupedInspectReceiptLocationDetailList)
                {
                    ReceiptDetail receiptDetail = receiptMaster.ReceiptDetails.Where(det => det.Id == groupedInspectReceiptLocationDetail.ReceiptDetailId).Single();


                    InspectDetail inspectDetail = new InspectDetail();
                    inspectDetail.Item = receiptDetail.Item;
                    inspectDetail.ItemDescription = receiptDetail.ItemDescription;
                    inspectDetail.ReferenceItemCode = receiptDetail.ReferenceItemCode;
                    inspectDetail.BaseUom = receiptDetail.BaseUom;
                    inspectDetail.HuId = groupedInspectReceiptLocationDetail.HuId;
                    inspectDetail.LotNo = groupedInspectReceiptLocationDetail.LotNo;
                    inspectDetail.Uom = receiptDetail.Uom;
                    inspectDetail.UnitCount = receiptDetail.UnitCount;
                    inspectDetail.UnitQty = receiptDetail.UnitQty;
                    inspectDetail.LocationFrom = receiptDetail.LocationTo;
                    inspectDetail.CurrentLocation = receiptDetail.LocationTo;
                    inspectDetail.InspectQty = groupedInspectReceiptLocationDetail.ReceiveQty / inspectDetail.UnitQty;
                    inspectDetail.IsJudge = false;
                    inspectDetail.IpDetailSequence = receiptDetail.IpDetailSequence;
                    inspectDetail.ReceiptDetailSequence = receiptDetail.Sequence;
                    inspectDetail.WMSSeq = groupedInspectReceiptLocationDetail.WMSSeq;
                    inspectDetail.IsConsignment = groupedInspectReceiptLocationDetail.IsConsignment;
                    inspectDetail.PlanBill = groupedInspectReceiptLocationDetail.PlanBill;

                    inspectMaster.AddInspectDetail(inspectDetail);
                }
                #endregion

                return inspectMaster;
            }
            else
            {
                return null;
            }
        }