protected void StatPassrate(ServerConnection conn, UInt32 nProjectID, UInt32 nPartID, ref float fMin, ref float fMax, ref string strError) { if (nPartID == 0) { return; } float fAveragePassRate = 0; List <DM_ModelPassRate> arrPassrate = CmdStat.StatPassRate(conn, nProjectID, nPartID, GlobalSession.Period, ref strError); int i = 0; fMin = 10; fMax = -1; foreach (DM_ModelPassRate passrate in arrPassrate) { fAveragePassRate += passrate.PassRate; fMin = Math.Min(fMin, passrate.PassRate); fMax = Math.Max(fMax, passrate.PassRate); i++; } if (fMax < 0) { fMax = 0; } if (fMin > 1) { fMin = 1; } }
protected float StatPassrate(ServerConnection conn, UInt32 nProjectID, UInt32 nPartID, ref string strError) { if (nPartID == 0) { return(0); } float fAveragePassRate = 0; List <DM_ModelPassRate> arrPassrate = CmdStat.StatPassRate(conn, nProjectID, nPartID, GlobalSession.Period, ref strError); float[] arrPass = new float[arrPassrate.Count]; foreach (DM_ModelPassRate passrate in arrPassrate) { fAveragePassRate += passrate.PassRate; } if (arrPassrate.Count > 0) { fAveragePassRate /= arrPassrate.Count; fAveragePassRate = (float)Math.Round(fAveragePassRate, 3); } return(fAveragePassRate); }
protected void StatKeyPartPassrate(ServerConnection conn, ProjectInfo projectInfo, KeyPartPassrateChartTag tag, ref string strError) { //统计最近一次的合格率 Period period = new Period(); period.LastNum = 1; for (int i = 0; i < tag.PartArray.Length; i++) { PartInfo partInfo = tag.PartArray[i]; List <DM_ModelPassRate> arrPassrate = CmdStat.StatPassRate(conn, projectInfo.ProjectID, partInfo.PartID, period, ref strError); if (arrPassrate != null && arrPassrate.Count > 0) { tag.Passrate[i] = arrPassrate[0].PassRate; } } }
protected void StatPassrate(ServerConnection conn, ProjectInfo projectInfo, PassrateChartTag tag, ref string strError) { if (tag.PartInfo.PartID == 0) { return; } float fAveragePassRate = 0; List <DM_ModelPassRate> arrPassrate = CmdStat.StatPassRate(conn, projectInfo.ProjectID, tag.PartInfo.PartID, GlobalSession.Period, ref strError); tag.Passrate = new float[arrPassrate.Count]; tag.AxisX = new string[arrPassrate.Count]; int i = 0; float fMin = 10; float fMax = -1; foreach (DM_ModelPassRate passrate in arrPassrate) { fAveragePassRate += passrate.PassRate; tag.Passrate[i] = passrate.PassRate; tag.AxisX[i] = passrate.MeasureDate.ToString("MM/dd/yyyy"); fMin = Math.Min(fMin, tag.Passrate[i]); fMax = Math.Max(fMax, tag.Passrate[i]); i++; } if (fMax < 0) { fMax = 0; } if (fMin > 1) { fMin = 1; } if (arrPassrate.Count > 0) { fAveragePassRate /= arrPassrate.Count; fAveragePassRate = (float)Math.Round(fAveragePassRate, 3); } //更新相关标签信息 for (int nTagIndex = 0; nTagIndex < projectInfo.Tags.Length; nTagIndex++) { if (projectInfo.Tags[nTagIndex].TagName == "Label") { LabelTag label = (LabelTag)projectInfo.Tags[nTagIndex]; if (label.PartInfo.PartID == tag.PartInfo.PartID) { for (int j = 0; j < label.Items.Length; j++) { if (label.Items[j].TagName[0] == "平均合格率") { label.Items[j].Value[0] = (float)Math.Round(fAveragePassRate * 100, 1); } else if (label.Items[j].TagName.Length > 1) { if (label.Items[j].TagName[0] == "最差合格率") { label.Items[j].Value[0] = fMin; } if (label.Items[j].TagName[1] == "最好合格率") { label.Items[j].Value[1] = fMax; } } } } } } }
public string DoCommand(HttpContext context, ref string strError) { string strCommand = context.Request["command"]; //查询车型 if (strCommand == "1") { recvPacket = CmdQuery.GetProjectArray(context, 1, ref strError); strResult = CmdQuery.OutProjectArray(recvPacket); } //查询零件 else if (strCommand == "2") { recvPacket = CmdQuery.GetPartArray(context, 2, ref strError); strResult = CmdQuery.OutPartArray(recvPacket); } //查询分类图片 else if (strCommand == "10") { recvPacket = CmdQuery.GetClassImageArray(context, 10, ref strError); strResult = CmdQuery.OutClassImage(recvPacket); } //查询工序 else if (strCommand == "27") { recvPacket = CmdQuery.GetWorkProgressArray(context, 27, ref strError); strResult = CmdQuery.OutWorkProgressArray(recvPacket); } else if (strCommand == "31") { recvPacket = CmdQuery.GetReportFile(context, 31, ref strError); strResult = CmdQuery.OutReportFile(recvPacket); } else if (strCommand == "32") { recvPacket = CmdQuery.GetReportPDF(context, 32, ref strError); strResult = CmdQuery.OutReportPDF(recvPacket); } //查询工序、图片、图片点的信息(通信协议上并没有) else if (strCommand == "100") { Packet[] recvPacketList = new Packet[4]; recvPacketList[0] = CmdQuery.GetWorkProgressArray(context, 27, ref strError); //查询工序 recvPacketList[1] = CmdQuery.GetClassImage(context, 22, ref strError); //查询图片 recvPacketList[2] = CmdQuery.GetImagePointArray(context, 9, ref strError); //查询图片上点的位置信息 recvPacket = CmdQuery.GetClass(context, 19, ref strError); //查询图片分类 string strClassID = CmdQuery.AnlyzeClassID(recvPacket); recvPacketList[3] = CmdQuery.GetNominal(context, 4, ref strError, strClassID);//查询分类下的所有点的Point名义值 strResult = CmdQuery.OutImageInfo(recvPacketList); } //加载文件 else if (strCommand == "101") { recvPacket = CmdManager.UpLoadFile(context, 32, ref strError); strResult = CmdManager.OutLoadFile(recvPacket); } else if (strCommand == "201") { byte nParamType = 0; if (context.Request["ParamType"] != null) { nParamType = byte.Parse(context.Request["ParamType"]); } recvPacket = CmdStat.StatPassRate(nParamType, context, 201, ref strError); strResult = CmdStat.OutGroupPassRate(recvPacket); } else if (strCommand == "102") { recvPacket = CmdQuery.GetQueryUser(context, 1, ref strError); strResult = CmdQuery.OutQueryUser(context, recvPacket); } //查询报警 else if (strCommand == "212") { List <Packet> arrrecvPacket = null; arrrecvPacket = CmdStatAlarm.StatFileAlarm(context, 212, ref strError); strResult = CmdStatAlarm.OutStatFileAlarm(arrrecvPacket); } //查询统计信息 else if (strCommand == "213") { CmdProjectStat stat = new CmdProjectStat(); strResult = stat.GetProjectInfo(context, ref strError); } //查询工厂信息 else if (strCommand == "214") { CmdSystemSetting setting = new CmdSystemSetting(); strResult = setting.GetSettingInfo(context, ref strError); } //设置工厂信息和查询条件 else if (strCommand == "215") { CmdSystemSetting setting = new CmdSystemSetting(); strResult = setting.SetSettingInfo(context, ref strError); } //获取所有项目信息 else if (strCommand == "216") { CmdProjectStat stat = new CmdProjectStat(); strResult = stat.GetAllProjectInfo(context, ref strError); } else if (strCommand == "217") { recvPacket = CmdQuery.GetLikeReportFile(context, 31, ref strError); strResult = CmdQuery.OutReportFile(recvPacket); } else if (strCommand == "218") { recvPacket = CmdQuery.GetOptionReportFile(context, 31, ref strError); strResult = CmdQuery.OutReportFile(recvPacket); } return(strResult); }