| | |
| | | if (dr == DialogResult.Yes) { |
| | | |
| | | string Url = DBHelper.GetConfigKey(AppDomain.CurrentDomain.BaseDirectory + "Config/SQLAPI.config", "sUrl"); |
| | | //通过接口 获取token |
| | | JsonResult jsonResult = await FindAccessToken(Url); |
| | | |
| | | string EquipFile = this.cmbEquipFile.Text; |
| | |
| | | try |
| | | { |
| | | |
| | | //获取所有设备数据 |
| | | JsonEquipmentData jsonResult =await FindDeviceList(url, token); |
| | | |
| | | if (jsonResult.code != "0") |
| | |
| | | else |
| | | { |
| | | string nos = ""; |
| | | //获取去设备编码 |
| | | //获取设备编码 |
| | | for (int i = 0; i < jsonResult.data.Count; i++) |
| | | { |
| | | if (jsonResult.data[i].no == this.cmbEquipFile.SelectedValue.ToString()) |
| | |
| | | nos = jsonResult.data[i].no; |
| | | } |
| | | } |
| | | //开始时间 |
| | | string HBegin = this.txtBegin.Text; |
| | | //结束时间 |
| | | string HEnd = this.txtEnd.Text; |
| | | //获取不良数,合数数,可疑数 总数 |
| | | jsonResult = await FindDevicePropCalc(url, token, nos, HBegin, HEnd); |
| | | if (jsonResult.code != "0") |
| | | { |
| | |
| | | decimal HUpLimit = 0; |
| | | decimal HDownLimit = 0; |
| | | |
| | | //分析方法 为定量分析 |
| | | if (HAnalysisMethod == "2") |
| | | { |
| | | //获取上限 |
| | | HUpLimit = decimal.Parse(dataSet.Tables[0].Rows[i]["HTargetVal"].ToString()) + decimal.Parse(dataSet.Tables[0].Rows[i]["HUpLimit"].ToString()); |
| | | //获取下限 |
| | | HDownLimit = decimal.Parse(dataSet.Tables[0].Rows[i]["HTargetVal"].ToString()) + decimal.Parse(dataSet.Tables[0].Rows[i]["HDownLimit"].ToString()); |
| | | } |
| | | |
| | |
| | | break; |
| | | } |
| | | //SRM@101.2@VEN00005@CGDD000167@1.02.002.002@20231129@1000 |
| | | //判断检验项目的代码 跟列名是否一致 |
| | | if (dataSet.Tables[0].Rows[i]["HQCCheckItemNumber"].ToString().Contains(HQCCheckItemName)) |
| | | { |
| | | for (int k = 0; k < dt.Rows.Count; k++) |
| | | { |
| | | |
| | | //只取时间范围内的数据 |
| | | if (DateTime.Parse(dt.Rows[k]["HDate"].ToString()) >= DateTime.Parse(HBegin) && DateTime.Parse(dt.Rows[k]["HDate"].ToString()) <= DateTime.Parse(HEnd)) |
| | | { |
| | | //获取检验值 |
| | | decimal HInSpectValue = decimal.Parse(dt.Rows[k][dt.Columns[j].ColumnName].ToString()); |
| | | |
| | | //默认值结论为合格 |
| | | int HInSpectResult = 1; |
| | | //定量分析 进行判断是否满足上下限 |
| | | if (HAnalysisMethod == "2") |
| | | { |
| | | HInSpectResult = (HInSpectValue > HUpLimit || HDownLimit > HInSpectValue) ? 0 : 1; |
| | |
| | | HInSpectResult = int.Parse(HInSpectValue.ToString()); |
| | | } |
| | | |
| | | |
| | | //如果当前结论为合格 并且历史结论也是合格 则继续保持合格 |
| | | if (HInSpectResult == 1 && HLastResult != 0) |
| | | { |
| | | HLastResult = 1; |
| | |
| | | ",0,0,'',0,'','" + dataSet.Tables[0].Rows[i]["HTargetVal"].ToString() + "'" + |
| | | ",'" + dataSet.Tables[0].Rows[i]["HUpLimit"].ToString() + "','" + dataSet.Tables[0].Rows[i]["HDownLimit"].ToString() + "','','',0,'" + HAnalysisMethod + "'," + dataSet.Tables[0].Rows[i]["HInspectInstruMentID"].ToString() + ",'" + HLastResult + "'" + |
| | | ") "); |
| | | |
| | | //如果当前结论为合格 并且历史结论也是合格 则继续保持合格 |
| | | if (HLastResult == 1 && HLastResults != 0) |
| | | { |
| | | HLastResults = 1; |
| | |
| | | //TimeDate = "2025-02-10 13:10:50"; |
| | | //time = "2025-02-10 13:11:50"; |
| | | |
| | | //获取所有设备数据 |
| | | JsonEquipmentData jsonResult = await FindDeviceList(Url, token); |
| | | if (jsonResult.code != "0") |
| | | { |
| | |
| | | else { |
| | | |
| | | string nos = ""; |
| | | //获取去设备编码 |
| | | //获取设备编码 |
| | | for (int i = 0; i < jsonResult.data.Count; i++) |
| | | { |
| | | nos += jsonResult.data[i].no + ","; |
| | |
| | | //} |
| | | } |
| | | nos = nos.Substring(0, nos.Length - 1); |
| | | //获取参数 获取每个设备对应的所有参数 |
| | | JsonEquipmentData jsonEquipment = await FindAllDevicePropsDetailByTimeRange(Url, token, nos, TimeDate, time); |
| | | |
| | | var JsonData = "{\"data\":["; |
| | | CustomWriteLog("01" , DateTime.Now.ToString("yyyy-MM-dd")); |
| | | //通过每个设备进行循环赋值 |
| | | for (int i = 0; i < jsonEquipment.data.Count; i++) |
| | | { |
| | | //获取设备对应的编码 判断编码是否满足为螺母压装设备 |
| | | if (jsonEquipment.data[i].deviceNo.Contains("CMR-ZZ-SE-")) |
| | | { |
| | | //循环 螺母压装设备对应的所有工艺参数 |
| | | for (int j = 0; j < jsonEquipment.data[i].props.Count; j++) |
| | | { |
| | | //循环 每个参数对应的所有数据 |
| | | for (int k = 0; k < jsonEquipment.data[i].props[j].datas.Count; k++) |
| | | { |
| | | //日志 |
| | | CustomWriteLog("1-" + k + ":" + jsonEquipment.data[i].props[j].datas[k].value, DateTime.Now.ToString("yyyy-MM-dd")); |
| | | |
| | | //获取参数的类型 |
| | | valueData value = JsonConvert.DeserializeObject<valueData>(jsonEquipment.data[i].props[j].datas[k].value); |
| | | |
| | | //日志 |
| | | CustomWriteLog("2", DateTime.Now.ToString("yyyy-MM-dd")); |
| | | |
| | | if (value.type == "良品") |
| | | { |
| | | JsonData += "{\"HDate\":\"" + jsonEquipment.data[i].props[j].datas[k].createTime + "\",\"HTechParamName\":\"螺母是否凸出\",\"HResult\":\"OK\",\"HCount\":1,\"HSourceCode\":\"" + jsonEquipment.data[i].deviceNo + "\"},"; |
| | |
| | | } |
| | | } |
| | | else { |
| | | //循环 螺母压装设备对应的所有工艺参数 |
| | | for (int j = 0; j < jsonEquipment.data[i].props.Count; j++) |
| | | { |
| | | //循环 每个参数对应的所有数据 |
| | | for (int k = 0; k < jsonEquipment.data[i].props[j].datas.Count; k++) |
| | | { |
| | | JsonData += "{\"HDate\":\"" + jsonEquipment.data[i].props[j].datas[k].createTime + "\",\"HTechParamName\":\"" + jsonEquipment.data[i].props[j].propName + "\",\"HResult\":\""+ jsonEquipment.data[i].props[j].datas[k].value + "\",\"HCount\":1,\"HSourceCode\":\"" + jsonEquipment.data[i].deviceNo + "\"},"; |
| | | } |
| | | } |
| | | |
| | | //获取设备时间段产量 |
| | | JsonEquipmentData data = await FindProdByNosAndTime(Url, token, jsonEquipment.data[i].deviceNo, TimeDate, time); |
| | | |
| | | for (int j = 0; j < data.data.Count; j++) |
| | |
| | | } |
| | | |
| | | CustomWriteLog("02", DateTime.Now.ToString("yyyy-MM-dd")); |
| | | var EquipmentStaus = await FindDeviceStatusByNos(Url, token, nos); |
| | | |
| | | //获取设备运行状态 |
| | | var EquipmentStaus = await FindDeviceStatusByNos(Url, token, nos); |
| | | |
| | | for (int i = 0; i < EquipmentStaus.data.Count; i++) |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | //查询当前开工的设备 获取对应的物料信息 |
| | | DataSet datable = oCN.RunProcReturn(@"select m.HNumber,eq.HEquipFileNo from Sc_ICMOBillStatus_Tmp a |
| | | inner join Gy_EquipFileBillMain eq on a.HSourceID = eq.HSourceID |
| | | inner join Gy_Material m on a.HMaterID = m.HItemID |
| | |
| | | } |
| | | |
| | | CustomWriteLog("03", DateTime.Now.ToString("yyyy-MM-dd")); |
| | | |
| | | JsonData = JsonData.Substring(0, JsonData.Length - 1); |
| | | JsonData += "]}"; |
| | | |
| | | //保存数据 |
| | | DataSave(JsonData); |
| | | if (TimeDate != "") |
| | | { |
| | |
| | | JsonResult jsonResult = await getUrl(urls, formData); |
| | | string time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); |
| | | string token = jsonResult.data.token; |
| | | |
| | | //获取所有的设备数据 |
| | | JsonEquipmentData jsonEquipment = await FindDeviceList(Url, token); |
| | | |
| | | if (jsonEquipment.code != "0") |
| | |
| | | |
| | | //this.Time_CLHB.Enabled = false; |
| | | |
| | | //查询开工的设备信息 以及 查询当天设备对应的开工时间 和完工时间 |
| | | DataSet ds = oCN.RunProcReturn("exec h_p_Sc_TimeICMOReporList '" + nos + "'", "h_p_Sc_TimeICMOReporList"); |
| | | |
| | | if (ds.Tables[0].Rows.Count > 0) |
| | | { |
| | | //根据当天只开工没有完工对应的产量数据 生成产量汇报单 |
| | | DataTable dt = ds.Tables[0]; |
| | | for (int i = 0; i < dt.Rows.Count; i++) |
| | | { |
| | |
| | | string HEndDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); |
| | | jsonEquipment = await FindProdByNosAndTime(Url, token, nos, HBegDate, HEndDate); |
| | | if (decimal.Parse(jsonEquipment.data[0].prod) > 0) { |
| | | //生成产量汇报单 |
| | | oCN.RunProc("exec h_p_Sc_AddTimeICMORepor " + HICMInterID + "," + jsonEquipment.data[0].prod+",'"+ HEndDate + "'"); |
| | | } |
| | | } |
| | | } |
| | | if (ds.Tables[1].Rows.Count > 0) |
| | | { |
| | | { |
| | | //根据当天开工并且完工对应的产量数据 生成产量汇报单 |
| | | DataTable dt = ds.Tables[1]; |
| | | for (int i = 0; i < dt.Rows.Count; i++) |
| | | { |
| | |
| | | jsonEquipment = await FindProdByNosAndTime(Url, token, nos, HBegDate, HEndDate); |
| | | if (decimal.Parse(jsonEquipment.data[0].prod) > 0) |
| | | { |
| | | //生成产量汇报单 |
| | | oCN.RunProc("exec h_p_Sc_AddTimeICMORepor " + HICMInterID + "," + jsonEquipment.data[0].prod + ",'" + HEndDate + "'"); |
| | | } |
| | | } |