public string Create(ConcessionMaster concessionMaster)
 {
     try
     {
         inspectMgr.CreateConcessionMaster(concessionMaster);
         return concessionMaster.ConcessionNo;
     }
     catch (BusinessException ex)
     {
         Response.TrySkipIisCustomErrors = true;
         Response.StatusCode = 500;
         Response.Write(ex.GetMessages()[0].GetMessageString());
         return string.Empty;
     }
 }
Пример #2
0
        public void ReleaseConcessionMaster(ConcessionMaster concessionMaster)
        {
            if (concessionMaster.Status != com.Sconit.CodeMaster.ConcessionStatus.Create)
            {
                throw new BusinessException("状态为{1}的让步使用单{0}不能释放。", concessionMaster.ConcessionNo, systemMgr.GetCodeDetailDescription(com.Sconit.CodeMaster.CodeMaster.ConcessionStatus, ((int)concessionMaster.Status).ToString()));
            }

            #region 关闭不合格品处理单
            RejectMaster rejectMaster = genericMgr.FindById<RejectMaster>(concessionMaster.RejectNo);
            if (rejectMaster.Status != com.Sconit.CodeMaster.RejectStatus.Submit)
            {
                throw new BusinessException("不合格品处理单{0}的状态为{1},不能释放。", rejectMaster.RejectNo, systemMgr.GetCodeDetailDescription(com.Sconit.CodeMaster.CodeMaster.RejectStatus, ((int)rejectMaster.Status).ToString()));
            }
            rejectMaster.Status = CodeMaster.RejectStatus.Close;
            this.genericMgr.Update(rejectMaster);
            #endregion

            concessionMaster.Status = CodeMaster.ConcessionStatus.Submit;
            this.genericMgr.Update(concessionMaster);
        }
Пример #3
0
        public string GetConcessionNo(ConcessionMaster concessionOrder)
        {
            SqlParameter[] parm = new SqlParameter[2];

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

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

            sqlDao.ExecuteStoredProcedure("USP_GetDocNo_CON", parm);

            return parm[1].Value.ToString();
        }
Пример #4
0
        public void ReleaseRejectMaster(RejectMaster rejectMaster)
        {
            if (rejectMaster.Status != com.Sconit.CodeMaster.RejectStatus.Create)
            {
                throw new BusinessException("状态为{1}的不合格品处理单{0}不能释放。", rejectMaster.RejectNo, systemMgr.GetCodeDetailDescription(com.Sconit.CodeMaster.CodeMaster.RejectStatus, (int)rejectMaster.Status));
            }

            rejectMaster.Status = CodeMaster.RejectStatus.Submit;
            this.genericMgr.Update(rejectMaster);

            #region 让步使用
            if (rejectMaster.HandleResult == CodeMaster.HandleResult.Concession)
            {
                ConcessionMaster concessionMaster = new ConcessionMaster();
                concessionMaster.RejectNo = rejectMaster.RejectNo;
                CreateConcessionMaster(concessionMaster);
                ReleaseConcessionMaster(concessionMaster);
                CloseConcessionMaster(concessionMaster.ConcessionNo);
            }
            #endregion
        }
Пример #5
0
        public void CreateConcessionMaster(ConcessionMaster concessionMaster)
        {
            #region 检查
            string hql = "select r from RejectDetail r where r.RejectNo = ? ";
            IList<RejectDetail> rejectDetailList = this.genericMgr.FindAll<RejectDetail>(hql, concessionMaster.RejectNo);
            if (rejectDetailList == null || rejectDetailList.Count() == 0)
            {
                throw new BusinessException("让步使用单明细不能为空。");
            }

            IList<ConcessionDetail> concessionDetailList = new List<ConcessionDetail>();
            Mapper.Map(rejectDetailList, concessionDetailList);
            concessionMaster.ConcessionDetails = concessionDetailList;
            #endregion

            #region 创建让步使用单头
            RejectMaster rejectMaster = genericMgr.FindById<RejectMaster>(concessionMaster.RejectNo);
            concessionMaster.ConcessionNo = this.numberControlMgr.GetConcessionNo(concessionMaster);
            concessionMaster.Region = rejectMaster.Region;
            concessionMaster.Status = CodeMaster.ConcessionStatus.Create;
            this.genericMgr.Create(concessionMaster);
            #endregion

            #region 创建让步使用单明细
            int seq = 1;
            foreach (var concessionDetail in concessionDetailList)
            {
                concessionDetail.Sequence = seq++;
                concessionDetail.ConcessionNo = concessionMaster.ConcessionNo;
                concessionDetail.LocationTo = concessionDetail.LocationFrom;
                this.genericMgr.Create(concessionDetail);
            }
            #endregion

        }
Пример #6
0
        public ConcessionMaster CreateConssionOrder(ConcessionMaster concessionMaster)
        {
            if (concessionMaster.ConcessionDetails == null || concessionMaster.ConcessionDetails.Count() == 0)
            {
                throw new BusinessException("让步使用单明细不能为空。");
            }
            #region 创建头
            concessionMaster.ConcessionNo = this.numberControlMgr.GetConcessionNo(concessionMaster);
            this.genericMgr.Create(concessionMaster);
            #endregion

            #region 创建让步使用单明细
            int seq = 1;
            foreach (var concessionDetail in concessionMaster.ConcessionDetails)
            {
                concessionDetail.Sequence = seq++;
                concessionDetail.ConcessionNo = concessionMaster.ConcessionNo;
                this.genericMgr.Create(concessionDetail);
            }
            #endregion

            #region 关闭
            concessionMaster.Status = CodeMaster.ConcessionStatus.Close;
            this.genericMgr.Update(concessionMaster);

            this.locationDetailMgr.ConcessionToUse(concessionMaster, DateTime.Now);
            #endregion

            return concessionMaster;
        }
Пример #7
0
        private IList<ConcessionDetail> TryLoadConcessionDetails(ConcessionMaster concessionMaster)
        {
            if (!string.IsNullOrWhiteSpace(concessionMaster.ConcessionNo))
            {
                if (concessionMaster.ConcessionDetails == null)
                {
                    string hql = "from ConcessionDetail where ConcessionNo = ?";

                    concessionMaster.ConcessionDetails = this.genericMgr.FindAll<ConcessionDetail>(hql, concessionMaster.ConcessionNo);
                }

                return concessionMaster.ConcessionDetails;
            }
            else
            {
                return null;
            }
        }
Пример #8
0
        public IList<InventoryTransaction> ConcessionToUse(ConcessionMaster consessionMaster, DateTime effectiveDate)
        {
            if (consessionMaster.ConcessionDetails != null && consessionMaster.ConcessionDetails.Count > 0)
            {
                List<InventoryTransaction> inventoryTransactionList = new List<InventoryTransaction>();
                foreach (ConcessionDetail concessionDetail in consessionMaster.ConcessionDetails)
                {
                    #region 让步出库
                    InventoryIO inventoryOut = new InventoryIO();

                    inventoryOut.Location = concessionDetail.LocationFrom;
                    inventoryOut.Item = concessionDetail.Item;
                    inventoryOut.HuId = concessionDetail.HuId;
                    inventoryOut.Qty = -concessionDetail.Qty * concessionDetail.UnitQty;  //转换为库存单位,为负数
                    inventoryOut.LotNo = concessionDetail.LotNo;
                    inventoryOut.QualityType = com.Sconit.CodeMaster.QualityType.Reject; //让步使用一定是不合格品
                    inventoryOut.IsATP = false;
                    inventoryOut.IsFreeze = false;
                    inventoryOut.IsCreatePlanBill = false;
                    inventoryOut.IsConsignment = false;
                    inventoryOut.PlanBill = null;
                    inventoryOut.ActingBill = null;
                    inventoryOut.TransactionType = CodeMaster.TransactionType.ISS_INP_CCS;
                    inventoryOut.OccupyType = CodeMaster.OccupyType.None;
                    inventoryOut.OccupyReferenceNo = null;
                    inventoryOut.IsVoid = false;
                    inventoryOut.EffectiveDate = effectiveDate;
                    //inventoryIO.ManufactureParty = ;

                    IList<InventoryTransaction> currentInventoryOutTransactionList = RecordInventory(inventoryOut);

                    RecordLocationTransaction(consessionMaster, concessionDetail, effectiveDate, currentInventoryOutTransactionList, true);
                    inventoryTransactionList.AddRange(currentInventoryOutTransactionList);
                    #endregion

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

                        inventoryIn.Location = concessionDetail.LocationTo;
                        inventoryIn.Item = concessionDetail.Item;
                        inventoryIn.HuId = concessionDetail.HuId;
                        inventoryIn.Qty = -currentInventoryOutTransaction.Qty;
                        inventoryIn.LotNo = concessionDetail.LotNo;
                        inventoryIn.QualityType = CodeMaster.QualityType.Qualified;
                        inventoryIn.IsATP = true;
                        inventoryIn.IsFreeze = false;
                        inventoryIn.IsCreatePlanBill = false;
                        inventoryIn.IsConsignment = currentInventoryOutTransaction.IsConsignment;
                        inventoryIn.PlanBill = currentInventoryOutTransaction.PlanBill;
                        inventoryIn.ActingBill = null;
                        inventoryIn.TransactionType = CodeMaster.TransactionType.RCT_INP_CCS;
                        inventoryIn.OccupyType = CodeMaster.OccupyType.None;
                        inventoryIn.OccupyReferenceNo = null;
                        inventoryIn.IsVoid = false;
                        inventoryIn.EffectiveDate = effectiveDate;
                        //inventoryIO.ManufactureParty = ;

                        IList<InventoryTransaction> currentInventoryInTransactionList = RecordInventory(inventoryIn);

                        RecordLocationTransaction(consessionMaster, concessionDetail, effectiveDate, currentInventoryInTransactionList, false);
                        inventoryTransactionList.AddRange(currentInventoryInTransactionList);
                    }

                    #endregion
                }

                return inventoryTransactionList;
            }

            return null;
        }
Пример #9
0
        private void RecordLocationTransaction(ConcessionMaster consessionMaster, ConcessionDetail concessionDetail, 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 = concessionDetail.ConcessionNo;
                //locationTransaction.OrderType = ;
                //locationTransaction.OrderSubType = ;
                locationTransaction.OrderDetailSequence = concessionDetail.Sequence;
                locationTransaction.OrderDetailId = concessionDetail.Id;
                //locationTransaction.OrderBomDetId = 
                //locationTransaction.IpNo = 
                //locationTransaction.IpDetailId = 
                //locationTransaction.IpDetailSequence = 
                //locationTransaction.ReceiptNo = 
                //locationTransaction.ReceiptDetailId = 
                //locationTransaction.ReceiptDetailSequence = 
                //locationTransaction.SequenceNo = 
                //locationTransaction.TraceCode = ;
                locationTransaction.Item = concessionDetail.Item;
                locationTransaction.Uom = concessionDetail.Uom;
                locationTransaction.BaseUom = concessionDetail.BaseUom;
                locationTransaction.Qty = groupedInventoryTransaction.Qty / concessionDetail.UnitQty;
                locationTransaction.UnitQty = concessionDetail.UnitQty;
                locationTransaction.IsConsignment = groupedInventoryTransaction.IsConsignment;
                if (groupedInventoryTransaction.IsConsignment && groupedInventoryTransaction.PlanBill.HasValue)
                {
                    locationTransaction.PlanBill = groupedInventoryTransaction.PlanBill.Value;
                }
                locationTransaction.PlanBillQty = groupedInventoryTransaction.PlanBillQty / concessionDetail.UnitQty;
                if (groupedInventoryTransaction.ActingBill.HasValue)
                {
                    locationTransaction.ActingBill = groupedInventoryTransaction.ActingBill.Value;
                }
                locationTransaction.ActingBillQty = groupedInventoryTransaction.ActingBillQty / concessionDetail.UnitQty;
                locationTransaction.QualityType = isIssue ?
                    CodeMaster.QualityType.Reject : CodeMaster.QualityType.Qualified;
                locationTransaction.HuId = concessionDetail.HuId;
                locationTransaction.LotNo = concessionDetail.LotNo;
                locationTransaction.TransactionType = isIssue ? CodeMaster.TransactionType.ISS_INP_CCS : CodeMaster.TransactionType.RCT_INP_CCS;
                locationTransaction.IOType = isIssue ? CodeMaster.TransactionIOType.Out : CodeMaster.TransactionIOType.In;
                locationTransaction.PartyFrom = consessionMaster.Region;
                locationTransaction.PartyTo = consessionMaster.Region;
                locationTransaction.LocationFrom = concessionDetail.LocationFrom;
                locationTransaction.LocationTo = concessionDetail.LocationTo;
                locationTransaction.LocationIOReason = string.Empty;
                locationTransaction.EffectiveDate = effectiveDate;
                locationTransaction.CreateUserId = SecurityContextHolder.Get().Id;
                locationTransaction.CreateDate = dateTimeNow;

                this.genericMgr.Create(locationTransaction);
                RecordLocationTransactionDetail(locationTransaction, inventoryTransactionList);
            }
        }
Пример #10
0
 public IList<InventoryTransaction> ConcessionToUse(ConcessionMaster consessionMaster)
 {
     return ConcessionToUse(consessionMaster, DateTime.Now);
 }
 public string Create(string idStr, string qtyStr, bool isInspect, string location)
 {
     try
     {
         string[] idArr = idStr.Split(',');
         string[] qtyArr = qtyStr.Split(',');
         var concessionMaster = new ConcessionMaster();
         if (!isInspect)
         {
             IList<RejectDetail> rejectDetailList = new List<RejectDetail>();
             for (int i = 0; i < idArr.Count(); i++)
             {
                 RejectDetail rejectDetail = genericMgr.FindById<RejectDetail>(Convert.ToInt32(idArr[i]));
                 rejectDetail.CurrentHandleQty = Convert.ToDecimal(qtyArr[i]);
                 rejectDetailList.Add(rejectDetail);
             }
             concessionMaster = inspectMgr.CreateConcessionMaster(rejectDetailList, location);
         }
         else
         {
             var inspectResultList = genericMgr.FindAllIn<InspectResult>(
                @"select r from InspectResult r where Id in(?", idArr.Select(p => (object)(int.Parse(p))))
                .Select(p =>
                {
                    p.CurrentHandleQty = Convert.ToDecimal(qtyArr[idArr.ToList().IndexOf(p.Id.ToString())]);
                    return p;
                }).ToList();
             concessionMaster = inspectMgr.CreateConcessionMaster(inspectResultList, location);
         }
         return concessionMaster.ConcessionNo;
     }
     catch (Exception ex)
     {
         Response.TrySkipIisCustomErrors = true;
         Response.StatusCode = 500;
         Response.Write(ex.Message);
         return string.Empty;
     }
 }
Пример #12
0
        public void CloseConcessionMaster(ConcessionMaster concessionMaster, DateTime effectiveDate)
        {
            if (concessionMaster.Status != com.Sconit.CodeMaster.ConcessionStatus.Submit)
            {
                throw new BusinessException("状态为{1}的让步使用单{0}不能关闭。", concessionMaster.ConcessionNo, systemMgr.GetCodeDetailDescription(com.Sconit.CodeMaster.CodeMaster.ConcessionStatus, ((int)concessionMaster.Status).ToString()));
            }

            concessionMaster.Status = CodeMaster.ConcessionStatus.Close;
            this.genericMgr.Update(concessionMaster);
            if (concessionMaster.ConcessionDetails == null || concessionMaster.ConcessionDetails.Count() == 0)
            {
                string hql = "from ConcessionDetail where ConcessionNo = ?";
                concessionMaster.ConcessionDetails = this.genericMgr.FindAll<ConcessionDetail>(hql, concessionMaster.ConcessionNo);
            }

            var invTrans = this.locationDetailMgr.ConcessionToUse(concessionMaster, effectiveDate);
            var huIds = invTrans.Where(p => !string.IsNullOrWhiteSpace(p.HuId)).Select(p => p.HuId).Distinct();
            if (huIds != null && huIds.Count() > 0)
            {
                foreach (var huId in huIds)
                {
                    var hu = this.genericMgr.FindById<Hu>(huId);
                    hu.ConcessionCount++;
                    this.genericMgr.Update(hu);
                }
            }
        }
Пример #13
0
        public ConcessionMaster CreateConcessionMaster(IList<RejectDetail> rejectDetailList, string location = null)
        {
            var concessionMaster = new ConcessionMaster();

            if (rejectDetailList == null || rejectDetailList.Count() == 0)
            {
                throw new BusinessException("让步使用单明细不能为空。");
            }

            IList<ConcessionDetail> concessionDetailList = new List<ConcessionDetail>();
            Mapper.Map(rejectDetailList, concessionDetailList);
            concessionMaster.ConcessionDetails = concessionDetailList;

            #region 创建让步使用单头
            RejectMaster rejectMaster = genericMgr.FindById<RejectMaster>(rejectDetailList.First().RejectNo);
            concessionMaster.ConcessionNo = this.numberControlMgr.GetConcessionNo(concessionMaster);
            concessionMaster.Region = rejectMaster.Region;
            concessionMaster.Status = CodeMaster.ConcessionStatus.Create;
            this.genericMgr.Create(concessionMaster);
            #endregion

            #region 创建让步使用单明细
            int seq = 1;
            foreach (var concessionDetail in concessionDetailList)
            {
                concessionDetail.Sequence = seq++;
                concessionDetail.ConcessionNo = concessionMaster.ConcessionNo;
                concessionDetail.LocationFrom = string.IsNullOrWhiteSpace(location) ? concessionDetail.LocationFrom : location;
                concessionDetail.LocationTo = string.IsNullOrWhiteSpace(location) ? concessionDetail.LocationFrom : location;
                this.genericMgr.Create(concessionDetail);
            }
            #endregion

            #region 更新明细的已处理不合格品处理单状态
            foreach (RejectDetail rejectDetail in rejectDetailList)
            {
                rejectDetail.HandledQty += rejectDetail.CurrentHandleQty;
                genericMgr.Update(rejectDetail);
            }
            string hql = "from RejectDetail as r where r.RejectNo = ?";
            IList<RejectDetail> remainRejectDetailList = genericMgr.FindAll<RejectDetail>(hql, rejectDetailList[0].RejectNo);
            var m = remainRejectDetailList.Where(r => (r.HandledQty < r.HandleQty)).ToList();
            if (m == null || m.Count == 0)
            {
                rejectMaster.Status = CodeMaster.RejectStatus.Close;
                genericMgr.Update(rejectMaster);
            }
            #endregion
            ReleaseConcessionMaster(concessionMaster);
            CloseConcessionMaster(concessionMaster, DateTime.Now);
            return concessionMaster;
        }
Пример #14
0
        public ConcessionMaster CreateConcessionMaster(IList<InspectResult> inspectResultList, string location = null)
        {
            var concessionMaster = new ConcessionMaster();
            if (inspectResultList == null || inspectResultList.Count() == 0)
            {
                throw new BusinessException("让步使用单明细不能为空。");
            }

            concessionMaster.ConcessionDetails =
                inspectResultList.Select(p => new ConcessionDetail
                {
                    BaseUom = p.BaseUom,
                    HuId = p.HuId,
                    Item = p.Item,
                    ItemDescription = p.ItemDescription,
                    LocationFrom = string.IsNullOrWhiteSpace(location) ? p.LocationFrom : location,
                    LocationTo = string.IsNullOrWhiteSpace(location) ? p.LocationFrom : location,
                    LotNo = p.LotNo,
                    Qty = p.CurrentHandleQty,
                    ReferenceItemCode = p.ReferenceItemCode,
                    UnitCount = p.UnitCount,
                    UnitQty = p.UnitQty,
                    Uom = p.Uom
                }).ToList();


            #region 创建让步使用单头
            InspectMaster inspectMaster = genericMgr.FindById<InspectMaster>(inspectResultList.First().InspectNo);
            concessionMaster.ConcessionNo = this.numberControlMgr.GetConcessionNo(concessionMaster);
            concessionMaster.Region = inspectMaster.Region;
            concessionMaster.Status = CodeMaster.ConcessionStatus.Create;
            //concessionMaster.RejectNo = inspectMaster.InspectNo;
            concessionMaster.ReferenceNo = inspectMaster.InspectNo;
            this.genericMgr.Create(concessionMaster);
            #endregion

            #region 创建让步使用单明细
            int seq = 1;
            foreach (var concessionDetail in concessionMaster.ConcessionDetails)
            {
                concessionDetail.Sequence = seq++;
                concessionDetail.ConcessionNo = concessionMaster.ConcessionNo;
                concessionDetail.LocationTo = string.IsNullOrWhiteSpace(location) ? concessionDetail.LocationFrom : location;
                this.genericMgr.Create(concessionDetail);
            }
            #endregion

            #region 更新明细状态
            foreach (var inspectResult in inspectResultList)
            {
                inspectResult.HandleQty += inspectResult.CurrentHandleQty;
                if (inspectResult.HandleQty == inspectResult.JudgeQty)
                {
                    inspectResult.IsHandle = true;
                }
                genericMgr.Update(inspectResult);
            }
            #endregion

            ReleaseConcessionMaster(concessionMaster);
            CloseConcessionMaster(concessionMaster, DateTime.Now);
            return concessionMaster;
        }