123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631 |
- using MOKA_Factory_Tools.DAL;
- using MOKA_Factory_Tools.Models;
- using SXLibrary;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace MOKA_Factory_Tools.BLL
- {
- public partial class NTFBLL
- {
- public NTFBLL(int NTFposion)
- {
- dalAMResult = new DAL_AMResult(NTFposion);
- dalAMYields = new DAL_AMYields(NTFposion);
- dalAMResultTR = new DAL_AMResult_TR(NTFposion);
- dalAMYieldsTR = new DAL_AMYields_TR(NTFposion);
- }
- /// <summary>
- /// ""=异常,OncePass,NTF,ReadFial
- /// </summary>
- public string ResultType = "";
- private string _strLastSN = "";
- protected readonly DAL_AMResult dalAMResult = null;// new DAL_AMResult();
- protected readonly DAL_AMYields dalAMYields = null;//new DAL_AMYields();
- protected readonly DAL_AMResult_TR dalAMResultTR = null;//new DAL_AMResult_TR();
- protected readonly DAL_AMYields_TR dalAMYieldsTR = null;//new DAL_AMYields_TR();
- /// <summary>
- /// 设置数据抄写结果;
- /// </summary>
- /// <param name="strLine">线体,UI输入</param>
- /// <param name="strStation">默认为:DataBurning</param>
- /// <param name="strSN"></param>
- /// <param name="bResult">抄写结果:成功或失败</param>
- /// <param name="strErrMsg">抄写失败时的描述</param>
- /// <returns></returns>
- public bool SetDataBuringResult(string strLine, string strStation, string strSN, string strOrder, string strDSN, bool bResult, string strLastSN, int nOrderType, string strErrMsg = "")
- {
- MaInfo maInfo;
- _strLastSN = strLastSN;
- DateTime dateNow = DateTime.Now;
- // 通过SN获取MES服务器中记录的ODF、Model、Dissemination信息;
- if (GMethod.GetMaInfo(strSN, strOrder, out maInfo, null))
- {
- // 1.通过SN查询出订单类型;
- if (nOrderType == 1) // 量产;
- {
- AMResult aMResult = new AMResult();
- // 测试日期;
- string strTestDate = dateNow.ToString("yyyy-MM-dd");
- // 测试完成时间;
- string strTestTime = dateNow.ToString("yyyy-MM-dd HH:mm:ss");
- #region 赋值model
- aMResult.TestDate = dateNow.Date;
- aMResult.Line = strLine;
- aMResult.Station = strStation;
- aMResult.DSN = strDSN;
- aMResult.ODF = maInfo.ODF;
- aMResult.Model = maInfo.Model;
- aMResult.Dimension = maInfo.SIZE;
- aMResult.TestHour = dateNow.Hour;
- aMResult.TestTime = strTestTime;
- aMResult.SN = strSN;
- #endregion
- if (IsRecordExist(aMResult))
- {
- if (!UpdateAMResults(aMResult, bResult, strErrMsg))
- {
- // 更新失败;
- return false;
- }
- }
- else
- {
- if (!AddAMResult(aMResult, bResult, strErrMsg))
- {
- // 更新失败;
- return false;
- }
- }
- // 更新统计结果;
- if (!UpdateAMYields(aMResult, bResult, strErrMsg))
- {
- return false;
- }
- return true;
- }
- else if (nOrderType == 0) // 试产;
- {
- AMResult_TR aMResult = new AMResult_TR();
- // 测试日期;
- string strTestDate = dateNow.ToString("yyyy-MM-dd");
- // 测试完成时间;
- string strTestTime = dateNow.ToString("yyyy-MM-dd HH:mm:ss");
- #region 赋值model
- aMResult.TestDate = dateNow.Date;
- aMResult.Line = strLine;
- aMResult.Station = strStation;
- aMResult.DSN = strDSN;
- aMResult.ODF = maInfo.ODF;
- aMResult.Model = maInfo.Model;
- aMResult.Dimension = maInfo.SIZE;
- aMResult.TestHour = dateNow.Hour;
- aMResult.TestTime = strTestTime;
- aMResult.SN = strSN;
- #endregion
- if (IsRecordExist(aMResult))
- {
- if (!UpdateAMResults(aMResult, bResult, strErrMsg))
- {
- // 更新失败;
- return false;
- }
- }
- else
- {
- if (!AddAMResult(aMResult, bResult, strErrMsg))
- {
- // 更新失败;
- return false;
- }
- }
- // 更新统计结果;
- if (!UpdateAMYields(aMResult, bResult, strErrMsg))
- {
- return false;
- }
- return true;
- }
- }
- return false;
- }
- #region ------量产NTF------;
- public bool IsRecordExist(AMResult model)
- {
- return dalAMResult.Exists(string.Format("Station='{0}' and SN='{1}'", model.Station, model.SN));
- }
- /// <summary>
- /// 新增记录;
- /// </summary>
- /// <param name="model"></param>
- /// <returns></returns>
- public bool AddAMResult(AMResult model, bool TestResult, string strErrMsg)
- {
- // 赋新值;
- model.Test01 = model.FinalTest = TestResult ? "PASS" : "FAIL";
- model.Test02 = "null";
- model.ReDo = "0";
- ResultType = model.ResultType = TestResult ? "OncePass" : "RealFail";
- if (!TestResult)
- model.ErrorMsg = strErrMsg;
- return dalAMResult.Add(model);
- }
- public bool UpdateAMResults(AMResult model, bool TestResult, string strErrMsg)
- {
- // 先获取ReDo="0"的记录;
- AMResult redo0Model = dalAMResult.GetModel(string.Format("Station='{0}' and SN='{1}' and ReDo='{2}'", model.Station, model.SN, "0"));
- if (_strLastSN == model.SN)
- {// 连续抄写数据,更新ReDo="0"的记录;
- Log.WriteInfoLog(string.Format("上一次SN={0} 与当前SN={1} 相同,只更新数据", _strLastSN, model.SN));
- if (!UpdateReDo0AMResult(redo0Model, TestResult, strErrMsg))
- {
- // 更新失败;
- Log.WriteInfoLog(string.Format("AMResult更新SN={0},Station={1},TestTime={2},ReDo={3} 失败", redo0Model.SN, redo0Model.Station, redo0Model.TestTime, redo0Model.ReDo));
- return false;
- }
- }
- else
- {// 将原ReDo="0"更新为ReDo=Max(ReDo)+1,并新增ReDo="0"的记录;
- int maxReDo = dalAMResult.GetMaxID("convert(int,ReDo)", string.Format("Station='{0}' and SN='{1}'", model.Station, model.SN));
- redo0Model.ReDo = maxReDo.ToString();
- if (!dalAMResult.Update(redo0Model, string.Format("Station='{0}' and SN='{1}' and ReDo='{2}'", redo0Model.Station, redo0Model.SN, "0")))
- {
- // 更新失败;
- Log.WriteInfoLog(string.Format("AMResult更新SN={0},Station={1},TestTime={2},ReDo={3} 失败", redo0Model.SN, redo0Model.Station, redo0Model.TestTime, redo0Model.ReDo));
- return false;
- }
- // 新增ReDo=0记录;
- if (!AddAMResult(model, TestResult, strErrMsg))
- {
- // 添加失败;
- Log.WriteInfoLog(string.Format("AMResult新增SN={0},Station={1},TestTime={2},ReDo={3} 失败", model.SN, model.Station, model.TestTime, model.ReDo));
- return false;
- }
- }
- return true;
- }
- public bool UpdateReDo0AMResult(AMResult redo0Model, bool TestResult, string strErrMsg)
- {
- #region 测试第2次;
- if (redo0Model.Test01.ToLower() == "pass" && redo0Model.Test02.ToLower() == "null" && redo0Model.FinalTest.ToLower() == "pass")
- {// 1.resulttype=oncepass;
- if (TestResult)
- {
- redo0Model.Test02 = "PASS";
- redo0Model.FinalTest = "PASS";
- redo0Model.ResultType = "OncePass";
- }
- else
- {
- redo0Model.Test02 = "FAIL";
- redo0Model.FinalTest = "FAIL";
- redo0Model.ResultType = "RealFail";
- }
- }
- else if (redo0Model.Test01.ToLower() == "fail" && redo0Model.Test02.ToLower() == "null" && redo0Model.FinalTest.ToLower() == "fail")
- {// 2.resulttype=realfail;
- if (TestResult)
- {
- redo0Model.Test02 = "PASS";
- redo0Model.FinalTest = "PASS";
- redo0Model.ResultType = "NTF";
- }
- else
- {
- // 连续2次Fail,锁定该SN不允许再测试.
- redo0Model.Test02 = "FAIL";
- redo0Model.FinalTest = "FAIL";
- redo0Model.ResultType = "RealFail";
- }
- }
- #endregion
- #region 测试第3次.
- else if (redo0Model.Test01.ToLower() == "pass" && redo0Model.Test02.ToLower() == "fail" && redo0Model.FinalTest.ToLower() == "fail")
- {// 3.resulttype=realfail;
- if (TestResult)
- {
- //redo0Model.Test02 = "FAIL";
- redo0Model.FinalTest = "PASS";
- redo0Model.ResultType = "NTF";
- }
- else
- {
- // 连续2次Fail,锁定该SN不允许再测试.
- //redo0Model.Test02 = "FAIL";
- redo0Model.FinalTest = "FAIL";
- redo0Model.ResultType = "RealFail";
- }
- }
- else if (redo0Model.Test01.ToLower() == "pass" && redo0Model.Test02.ToLower() == "pass" && redo0Model.FinalTest.ToLower() == "pass")
- {// 4.resulttype=oncepass;
- if (TestResult)
- {
- //redo0Model.Test02 = "PASS";
- redo0Model.FinalTest = "PASS";
- redo0Model.ResultType = "OncePass";
- }
- else
- {
- //redo0Model.Test02 = "PASS";
- redo0Model.FinalTest = "FAIL";
- redo0Model.ResultType = "RealFail";
- }
- }
- #region 已经累计出现2次fail了,不允许继续测试,也不允许修改记录;
- else if (redo0Model.Test01.ToLower() == "fail" && redo0Model.Test02.ToLower() == "fail" && redo0Model.FinalTest.ToLower() == "fail")
- {// 5.resulttype=realfail; 已经累计出现2次fail了,不允许继续测试,也不允许修改记录;
- Log.WriteInfoLog(string.Format("5.resulttype=realfail; Test01={0},Test02={1},已经累计出现2次fail了,不允许继续测试,也不允许修改记录", redo0Model.Test01, redo0Model.Test02));
- }
- #endregion
- else if (redo0Model.Test01.ToLower() == "fail" && redo0Model.Test02.ToLower() == "pass" && redo0Model.FinalTest.ToLower() == "pass")
- {// 4.resulttype=ntf;
- if (TestResult)
- {
- //redo0Model.Test02 = "PASS";
- redo0Model.FinalTest = "PASS";
- redo0Model.ResultType = "NTF";
- }
- else
- {
- //redo0Model.Test02 = "PASS";
- redo0Model.FinalTest = "FAIL";
- redo0Model.ResultType = "RealFail";
- }
- }
- #endregion
- if (!TestResult)
- redo0Model.ErrorMsg = strErrMsg;
- // 更新测试时间;
- DateTime dateNow = DateTime.Now;
- redo0Model.TestDate = dateNow.Date;
- redo0Model.TestTime = dateNow.ToString("yyyy-MM-dd HH:mm:ss");
- redo0Model.TestHour = dateNow.Hour;
- ResultType = redo0Model.ResultType;
- return dalAMResult.Update(redo0Model, string.Format("Station='{0}' and SN='{1}' and ReDo='{2}'", redo0Model.Station, redo0Model.SN, redo0Model.ReDo));
- }
- public bool UpdateAMYields(AMResult model, bool TestResult, string strErrMsg)
- {
- bool IsNewRecord = false;
- // 查询出统计的记录;
- AMYields yields = dalAMYields.GetModel(model.Line, model.Station, model.ODF, model.TestDate, model.TestHour);
- // 根据当前model所在的Line、Station、ODF、Model、TestDate、TestHour,统计该TestHour内的数据;
- List<AMResult> mResults = dalAMResult.GetModelList(model.Line, model.Station, model.ODF, model.TestDate, model.TestHour);
- // 查询每小时统计值;
- HourlyResultData hourlydata = dalAMResult.GetHourlyResultData(model.Line, model.Station, model.ODF, model.TestDate, model.TestHour);
- if (yields == null || yields.IsValueEmpty())
- {// 添加新记录;
- IsNewRecord = true;
- if (yields == null)
- yields = new AMYields();
- yields.TestDate = model.TestDate;
- yields.TestHour = model.TestHour;
- yields.Line = model.Line;
- yields.Station = model.Station;
- yields.ODF = model.ODF;
- yields.Dimension = model.Dimension;
- yields.Model = model.Model;
- }
- yields.Total = hourlydata.TotalAllCount;
- yields.OncePass = hourlydata.OncePassAllCount;
- //yields.TwiceFail = hourlydata.TwiceFailCount;
- yields.NTF = hourlydata.NTFAllCount;
- yields.RealFail = hourlydata.RealFailCount;
- yields.NTF_SN = hourlydata.NTFSN;
- yields.FailDSN = hourlydata.FailDSN;
- // 计算百分比;
- try
- {
- int totalAll = int.Parse(hourlydata.TotalAllCount);
- int totalZero = int.Parse(hourlydata.TotalZeroCount);
- int oncepassAll = int.Parse(hourlydata.OncePassAllCount);
- int oncepassZero = int.Parse(hourlydata.OncePassZeroCount);
- int ntfAll = int.Parse(hourlydata.NTFAllCount);
- int ntfZero = int.Parse(hourlydata.NTFZeroCount);
- int realfailCount = int.Parse(hourlydata.RealFailCount);
- // 统计合格率;
- yields.FPY = (oncepassAll / (double)totalAll).ToString("P");
- yields.SPY = ((oncepassAll + ntfAll) / (double)totalAll).ToString("P");
- yields.RPY = ((oncepassAll + ntfAll) / (double)totalAll).ToString("P");
- yields.YieldRate = ((oncepassZero + ntfZero) / (double)totalZero).ToString("P");
- }
- catch
- {
- return false;
- }
- return IsNewRecord ? dalAMYields.Add(yields) : dalAMYields.Update(yields);
- }
- #endregion
- #region ------试产NTF------
- /// <summary>
- /// 记录是否存在;
- /// </summary>
- /// <param name="model"></param>
- /// <returns></returns>
- public bool IsRecordExist(AMResult_TR model)
- {
- // 如果存在重流的话,可能不会在原来的Line上,可以流到其他Line。
- // dalAMResult.Exists(string.Format("Station='{0}' and SN='{1}' and Line = '{2}'", model.Station, model.SN, model.Line));
- return dalAMResultTR.Exists(string.Format("Station='{0}' and SN='{1}'", model.Station, model.SN));
- }
- /// <summary>
- /// 新增记录;
- /// </summary>
- /// <param name="model"></param>
- /// <returns></returns>
- public bool AddAMResult(AMResult_TR model, bool TestResult, string strErrMsg)
- {
- // 赋新值;
- model.Test01 = model.FinalTest = TestResult ? "PASS" : "FAIL";
- model.Test02 = "null";
- model.Test03 = "null";
- model.ReDo = "0";
- ResultType = model.ResultType = TestResult ? "OncePass" : "RealFail";
- if (!TestResult)
- model.ErrorMsg = strErrMsg;
- return dalAMResultTR.Add(model);
- }
- public bool UpdateAMResults(AMResult_TR model, bool TestResult, string strErrMsg)
- {
- // 先获取ReDo="0"的记录;
- AMResult_TR redo0Model = dalAMResultTR.GetModel(string.Format("Station='{0}' and SN='{1}' and ReDo='{2}'", model.Station, model.SN, "0"));
- if (_strLastSN == model.SN)
- {// 连接抄写数据,更新ReDo="0"的记录;
- Log.WriteInfoLog(string.Format("上一次SN={0} 与当前SN={1} 相同,只更新数据", _strLastSN, model.SN));
- if (!UpdateReDo0AMResult(redo0Model, TestResult, strErrMsg))
- {
- // 更新失败;
- Log.WriteInfoLog(string.Format("AMResult更新SN={0},Station={1},TestTime={2},ReDo={3} 失败", redo0Model.SN, redo0Model.Station, redo0Model.TestTime, redo0Model.ReDo));
- return false;
- }
- }
- else
- {// 将原ReDo="0"更新为ReDo=Max(ReDo)+1,并新增ReDo="0"的记录;
- int maxReDo = dalAMResultTR.GetMaxID("convert(int,ReDo)", string.Format("Station='{0}' and SN='{1}'", model.Station, model.SN));
- redo0Model.ReDo = maxReDo.ToString();
- if (!dalAMResultTR.Update(redo0Model, string.Format("Station='{0}' and SN='{1}' and ReDo='{2}'", redo0Model.Station, redo0Model.SN, "0")))
- {
- // 更新失败;
- Log.WriteInfoLog(string.Format("AMResult更新SN={0},Station={1},TestTime={2},ReDo={3} 失败", redo0Model.SN, redo0Model.Station, redo0Model.TestTime, redo0Model.ReDo));
- return false;
- }
- // 新增ReDo=0记录;
- if (!AddAMResult(model, TestResult, strErrMsg))
- {
- // 添加失败;
- Log.WriteInfoLog(string.Format("AMResult新增SN={0},Station={1},TestTime={2},ReDo={3} 失败", model.SN, model.Station, model.TestTime, model.ReDo));
- return false;
- }
- }
- return true;
- }
- public bool UpdateReDo0AMResult(AMResult_TR redo0Model, bool TestResult, string strErrMsg)
- {
- #region 测试第2次
- if (redo0Model.Test02.ToLower() == "null" && redo0Model.Test03.ToLower() == "null")
- {
- if (redo0Model.Test01.ToLower() == "pass")
- {
- if (TestResult)
- {
- redo0Model.Test02 = "PASS";
- redo0Model.FinalTest = "PASS";
- redo0Model.ResultType = "OncePass";
- }
- else
- {
- redo0Model.Test02 = "FAIL";
- redo0Model.FinalTest = "FAIL";
- redo0Model.ResultType = "RealFail";
- }
- }
- else if (redo0Model.Test01.ToLower() == "fail")
- {
- if (TestResult)
- {
- redo0Model.Test02 = "PASS";
- redo0Model.FinalTest = "PASS";
- redo0Model.ResultType = "RealFail";
- }
- else
- {
- redo0Model.Test02 = "FAIL";
- redo0Model.FinalTest = "FAIL";
- redo0Model.ResultType = "RealFail";
- }
- }
- }
- #endregion
- #region 测试第3次
- else if (redo0Model.Test02.ToLower() != "null" && redo0Model.Test03.ToLower() == "null")
- {
- if (redo0Model.Test01.ToLower().Equals("pass") && redo0Model.Test02.ToLower().Equals("pass"))
- {
- if (TestResult)
- {
- redo0Model.Test03 = "PASS";
- redo0Model.FinalTest = "PASS";
- redo0Model.ResultType = "OncePass";
- }
- else
- {
- redo0Model.Test03 = "FAIL";
- redo0Model.FinalTest = "FAIL";
- redo0Model.ResultType = "RealFail";
- }
- }
- else if (redo0Model.Test01.ToLower().Equals("pass") && redo0Model.Test02.ToLower().Equals("fail"))
- {
- if (TestResult)
- {
- redo0Model.Test03 = "PASS";
- redo0Model.FinalTest = "PASS";
- redo0Model.ResultType = "NTF";
- }
- else
- {
- redo0Model.Test03 = "FAIL";
- redo0Model.FinalTest = "FAIL";
- redo0Model.ResultType = "RealFail";
- }
- }
- else if (redo0Model.Test01.ToLower().Equals("fail") && redo0Model.Test02.ToLower().Equals("pass"))
- {
- if (TestResult)
- {
- redo0Model.Test03 = "PASS";
- redo0Model.FinalTest = "PASS";
- redo0Model.ResultType = "NTF";
- }
- else
- {
- redo0Model.Test03 = "FAIL";
- redo0Model.FinalTest = "FAIL";
- redo0Model.ResultType = "RealFail";
- }
- }
- else if (redo0Model.Test01.ToLower().Equals("fail") && redo0Model.Test02.ToLower().Equals("fail"))
- {
- Log.WriteInfoLog("连接2次Fail,测试锁定");
- }
- }
- #endregion
- #region 测试第4次;
- else if (redo0Model.Test03.ToLower() != "null")
- {
- if (redo0Model.FinalTest.ToLower() == "pass" && redo0Model.ResultType.ToLower() == "ntf")
- {
- if (!TestResult)
- {
- redo0Model.FinalTest = "FAIL";
- redo0Model.ResultType = "RealFail";
- }
- }
- else if (redo0Model.FinalTest.ToLower() == "pass" && redo0Model.ResultType.ToLower() == "oncepass")
- {// 异常测试;
- if (!TestResult)
- {
- redo0Model.FinalTest = "FAIL";
- redo0Model.ResultType = "RealFail";
- }
- }
- else
- {
- Log.WriteErrorLog("异常测试,超过3次测试次数");
- }
- }
- #endregion
- if (!TestResult)
- redo0Model.ErrorMsg = strErrMsg;
- // 更新测试时间;
- DateTime dateNow = DateTime.Now;
- redo0Model.TestDate = dateNow.Date;
- redo0Model.TestTime = dateNow.ToString("yyyy-MM-dd HH:mm:ss");
- redo0Model.TestHour = dateNow.Hour;
- ResultType = redo0Model.ResultType;
- return dalAMResultTR.Update(redo0Model, string.Format("Station='{0}' and SN='{1}' and ReDo='{2}'", redo0Model.Station, redo0Model.SN, redo0Model.ReDo));
- }
- public bool UpdateAMYields(AMResult_TR model, bool TestResult, string strErrMsg)
- {
- bool IsNewRecord = false;
- // 查询出统计的记录;
- AMYields_TR yields = dalAMYieldsTR.GetModel(model.Line, model.Station, model.ODF, model.TestDate, model.TestHour);
- // 根据当前model所在的Line、Station、ODF、Model、TestDate、TestHour,统计该TestHour内的数据;
- List<AMResult_TR> mResults = dalAMResultTR.GetModelList(model.Line, model.Station, model.ODF, model.TestDate, model.TestHour);
- // 查询每小时统计值;
- HourlyResultTRData hourlydata = dalAMResultTR.GetHourlyResultData(model.Line, model.Station, model.ODF, model.TestDate, model.TestHour);
- if (yields == null || yields.IsValueEmpty())
- {// 添加新记录;
- IsNewRecord = true;
- if (yields == null)
- yields = new AMYields_TR();
- yields.TestDate = model.TestDate;
- yields.TestHour = model.TestHour;
- yields.Line = model.Line;
- yields.Station = model.Station;
- yields.ODF = model.ODF;
- yields.Dimension = model.Dimension;
- yields.Model = model.Model;
- }
- yields.Total = hourlydata.TotalAllCount;
- yields.OncePass = hourlydata.OncePassAllCount;
- //yields.TwiceFail = hourlydata.TwiceFailCount;
- yields.NTF = hourlydata.NTFAllCount;
- yields.RealFail = hourlydata.RealFailCount;
- yields.NTF_SN = hourlydata.NTFSN;
- yields.FailDSN = hourlydata.FailDSN;
- // 计算百分比;
- try
- {
- int totalAll = int.Parse(hourlydata.TotalAllCount);
- int totalZero = int.Parse(hourlydata.TotalZeroCount);
- int oncepassAll = int.Parse(hourlydata.OncePassAllCount);
- int oncepassZero = int.Parse(hourlydata.OncePassZeroCount);
- int ntfAll = int.Parse(hourlydata.NTFAllCount);
- int ntfZero = int.Parse(hourlydata.NTFZeroCount);
- int realfailCount = int.Parse(hourlydata.RealFailCount);
- // 统计合格率;
- yields.FPY = (oncepassAll / (double)totalAll).ToString("P");
- yields.SPY = ((oncepassAll + ntfAll) / (double)totalAll).ToString("P");
- yields.RPY = ((oncepassAll + ntfAll) / (double)totalAll).ToString("P");
- yields.YieldRate = ((oncepassZero + ntfZero) / (double)totalZero).ToString("P");
- }
- catch
- {
- return false;
- }
- return IsNewRecord ? dalAMYieldsTR.Add(yields) : dalAMYieldsTR.Update(yields);
- }
- #endregion
- }
- }
|