public string GetRejectNo(RejectMaster rejectMaster) { SqlParameter[] parm = new SqlParameter[3]; parm[0] = new SqlParameter("@Region", SqlDbType.VarChar); parm[0].Value = rejectMaster.Region; parm[1] = new SqlParameter("@HandleResult", SqlDbType.TinyInt); parm[1].Value = rejectMaster.HandleResult; parm[2] = new SqlParameter("@RejNo", SqlDbType.VarChar, 100); parm[2].Direction = ParameterDirection.InputOutput; sqlDao.ExecuteStoredProcedure("USP_GetDocNo_REJ", parm); return parm[2].Value.ToString(); }
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 }
public void CloseRejectMaster(RejectMaster rejectMaster) { if (rejectMaster.Status == com.Sconit.CodeMaster.RejectStatus.Create ) { throw new BusinessException(string.Format("状态为{0}的不合格品单{1}不能关闭。", rejectMaster.Status,rejectMaster.RejectNo)); } rejectMaster.Status=com.Sconit.CodeMaster.RejectStatus.Close; genericMgr.Update(rejectMaster); }
public RejectMaster CreateRejectMaster(CodeMaster.HandleResult rejectHandleResult, IList<InspectResult> inspectResultList, DateTime effectiveDate) { #region 检查 if (inspectResultList == null) { throw new BusinessException("不合格品处理结果不能为空。"); } IList<InspectResult> noneZeroInspectResultList = inspectResultList.Where(i => i.CurrentHandleQty > 0).ToList(); if (noneZeroInspectResultList == null || noneZeroInspectResultList.Count == 0) { throw new BusinessException("不合格品处理结果不能为空。"); } foreach (InspectResult inspectResult in noneZeroInspectResultList) { if (inspectResult.JudgeQty < (inspectResult.HandleQty + inspectResult.CurrentHandleQty)) { throw new BusinessException("不合格品的处理数超过了判定数。"); } } #region 检查不合格品处理是否在同一个区域中 #region 查询Location string hql = string.Empty; IList<object> paras = new List<object>(); foreach (string locationCode in noneZeroInspectResultList.Select(i => i.CurrentLocation).Distinct()) { if (hql == string.Empty) { hql = "from Location where Code in (?"; } else { hql += ", ?"; } paras.Add(locationCode); } hql += ")"; IList<Location> locationList = this.genericMgr.FindAll<Location>(hql, paras.ToArray()); #endregion IList<string> regionList = locationList.Select(l => l.Region).Distinct().ToList(); if (regionList != null && regionList.Count > 1) { throw new BusinessException("不合格品的库位属于不同区域不能合并处理。"); } string region = regionList.Single(); #endregion #endregion #region 生成不合格品处理单 #region 生成不合格品处理单头 RejectMaster rejectMaster = new RejectMaster(); rejectMaster.Status = CodeMaster.RejectStatus.Create; rejectMaster.Region = region; rejectMaster.HandleResult = rejectHandleResult; rejectMaster.RejectNo = this.numberControlMgr.GetRejectNo(rejectMaster); //條碼還是數量 rejectMaster.InspectType = noneZeroInspectResultList.Where(r => r.HuId != null).Count() > 0 ? com.Sconit.CodeMaster.InspectType.Barcode : com.Sconit.CodeMaster.InspectType.Quantity; this.genericMgr.Create(rejectMaster); #endregion #region 生成不合格品处理单明细 int seq = 1; foreach (InspectResult inspectResult in noneZeroInspectResultList) { RejectDetail rejectDetail = Mapper.Map<InspectResult, RejectDetail>(inspectResult); rejectDetail.Sequence = seq++; rejectDetail.HandleQty = inspectResult.CurrentHandleQty; rejectDetail.HandledQty = 0; rejectDetail.FailCode = inspectResult.FailCode; rejectDetail.RejectNo = rejectMaster.RejectNo; rejectDetail.ManufactureParty = inspectResult.ManufactureParty; rejectMaster.AddRejectDetail(rejectDetail); this.genericMgr.Create(rejectDetail); } #endregion #endregion #region 更新判定结果 foreach (InspectResult inspectResult in noneZeroInspectResultList) { inspectResult.HandleQty += inspectResult.CurrentHandleQty; if (inspectResult.HandleQty == inspectResult.JudgeQty) { inspectResult.IsHandle = true; } this.genericMgr.Update(inspectResult); } #endregion return rejectMaster; }