コード例 #1
0
        /// <summary>
        /// 结束本次检测,需要先检查录入的数据是否满足要求,满足的了才能录入
        /// 1.一点落在控制限以外
        /// 2.连续9点落在中心线的同一侧
        /// 3.连续6点递增或递减
        /// 4.连续14点中相邻点交替上下
        /// </summary>
        /// <param name="ProductCalID"></param>
        /// <returns></returns>
        public string EndThisTest(string ProductCalID, string PictureType)
        {
            CalResultBll   CalBll       = new CalResultBll();
            MRCalResultBll MRBll        = new MRCalResultBll();
            string         sqldatacount = string.Format(@"select case when (select groupnum from ProductCal where ProductCalID='{0}')=
(select COUNT(1) from dbo.ProductCalData where InputValue is not null and ProductCalDID in (
select ProductCalDID from dbo.ProductCalDetail where State='进行中' and ProductCalID='{0}')) 
then 'success' else 'error' end ", ProductCalID);
            DataTable      dtdatacount  = ProductCalre.FindTableBySql(sqldatacount);

            if (dtdatacount.Rows[0][0].ToString() == "success") //表示成功,可以结束本次
            {
                StringBuilder strsql = new StringBuilder();
                strsql.AppendFormat(@" update dbo.ProductCalDetail set State='已完成',EndDate=GETDATE(),UpdateMan='{1}' where State='进行中' and ProductCalID='{0}' ", ProductCalID, ManageProvider.Provider.Current().UserName);
                ProductCalre.ExecuteBySql(strsql);
                //表示本次成功了.成功以后还需要做其他的分支判断,检测添加了本次以后是否有异常结果
                //CalBll.CheckFault(ProductCalID);
                if (PictureType == "X-Bar")
                {
                    return(CalBll.CheckFault(ProductCalID));
                }
                else
                {
                    return(MRBll.CheckFault(ProductCalID));
                }
            }
            else
            {
                //表示录入的数据量还不够结束本次的
                return("0");
            }
        }
コード例 #2
0
 public string CalCPK(string ProductCalID, string StartDate, string EndDate, string PictureType)
 {
     if (PictureType == "X_Bar")
     {
         return(CalResultBll.CalCPK(ProductCalID, StartDate, EndDate, ProductCalre));
     }
     else
     {
         return(MRCalResultBll.CalCPK(ProductCalID, StartDate, EndDate));
     }
 }
コード例 #3
0
 public string PotentialRiskTable(string ProductCalID, string StartDate, string EndDate)
 {
     return(CalResultBll.PotentialRisk(ProductCalID, StartDate, EndDate, ProductCalre));
 }
コード例 #4
0
 public string FaultTable(string ProductCalID, string StartDate, string EndDate)
 {
     return(CalResultBll.FaultTTable(ProductCalID, StartDate, EndDate, ProductCalre));
 }
コード例 #5
0
 public string DefaultDetailTable(string ProductCalID)
 {
     return(CalResultBll.DefaultDetailTable(ProductCalID, ProductCalre));
 }
コード例 #6
0
ファイル: MRCalResultBll.cs プロジェクト: shenjuncaci/SPC-
        /// <summary>
        /// 计算MR图的CPK,方法和XBAR差不多,就是R的计算需要调整
        /// </summary>
        /// <param name="ProductCalID"></param>
        /// <param name="StartDate"></param>
        /// <param name="EndDate"></param>
        /// <param name="re"></param>
        /// <returns></returns>
        public static string CalCPK(string ProductCalID, string StartDate, string EndDate)
        {
            try
            {
                MRCalResultBll bll = new MRCalResultBll();
                if (CommonHelper.IsEmpty(StartDate))
                {
                    StartDate = DateTime.Now.AddDays(-30).ToString();
                }
                if (CommonHelper.IsEmpty(EndDate))
                {
                    EndDate = DateTime.Now.ToString();
                }
                string sql = @"  select  CONVERT(varchar(100), b.StartDate, 120)+'~'+CONVERT(varchar(100), b.EndDate, 8) as riqi,
CONVERT(varchar(100), b.StartDate, 120) as sdate,
CONVERT(varchar(100), b.EndDate, 8) as edate,
AVG(InputValue) as x,
c.XLowLimit,c.XUpperLimit,c.XCenterLine,
c.RLowLimit,c.RUpperLimit,c.RCenterLine,
c.StandardLowLimit,c.StandardUpperLimit,c.StandardCenterLine
from ProductCalData a 
left join ProductCalDetail  b on a.ProductCalDID=b.ProductCalDID 
left join ProductCal c on b.ProductCalID=c.ProductCalID
where a.ProductCalID='{0}'  and cast(b.StartDate as date)>=cast('{1}' as date) and cast(b.StartDate as date)<=cast('{2}' as date) and  b.State='已完成'
group by a.ProductCalDID,b.StartDate,b.EndDate,c.XLowLimit,c.XUpperLimit,c.XCenterLine,c.RLowLimit,c.RUpperLimit,c.RCenterLine,
c.StandardLowLimit,c.StandardUpperLimit,c.StandardCenterLine 
order by StartDate ";
                sql = string.Format(sql, ProductCalID, StartDate, EndDate);
                Repository <MRPictureDTO> re   = new Repository <MRPictureDTO>();
                List <MRPictureDTO>       list = re.FindListBySql(sql);
                list = bll.GetMRList(list);
                //对list进行求和,求平均等操作
                var     xbarAverage = list.Average(q => q.x);
                var     rSum        = list.Sum(q => q.mr);
                var     rAverage    = rSum / (list.Count - 1);
                decimal fenzi1      = list[0].StandardUpperLimit - xbarAverage;
                if (fenzi1 < 0)
                {
                    fenzi1 = fenzi1 * -1;
                }
                decimal fenzi2 = xbarAverage - list[0].StandardUpperLimit;
                if (fenzi2 < 0)
                {
                    fenzi2 = fenzi2 * -1;
                }
                decimal fenzi;
                if (fenzi1 > fenzi2)
                {
                    fenzi = fenzi2;
                }
                else
                {
                    fenzi = fenzi1;
                }
                decimal fenmu = 3 * rAverage / CalResultBll.CpkCanshu(2);
                return((fenzi / fenmu).ToString("0.00"));
            }
            catch (Exception ex)
            {
                return("0");
            }
        }