| | |
| | | this.btnSave.Enabled = false; |
| | | this.txtHMaterNumber.ReadOnly = true; |
| | | //this.btnRest.Enabled = false; |
| | | //制单编码只读 |
| | | this.txtHMakerNumber.ReadOnly = true; |
| | | //制单人提示 |
| | | this.txtHMaker.ForeColor = Color.LightGray; |
| | | this.txtHMaker.Text = "请输入用户编码!"; |
| | | |
| | | bindCbox(); |
| | | |
| | | } |
| | |
| | | private void btnBegin_Click(object sender, EventArgs e) |
| | | { |
| | | if (this.txtHBathNo.Text == "" || this.txtHBathNo.ReadOnly == false) |
| | | //if (false) |
| | | { |
| | | MessageBox.Show("请输入批次号进行确认!"); |
| | | } |
| | | else |
| | | { |
| | | this.txtBegin.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); |
| | | //this.txtBegin.Text = "2024-09-06 10:52:39"; |
| | | //this.txtBegin.Text = "2024-11-21 13:40:27"; |
| | | this.btnBegin.Enabled = false; |
| | | if (cmbEquipFile.SelectedIndex == 1) |
| | | { |
| | |
| | | else |
| | | { |
| | | this.txtEnd.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); |
| | | //this.txtEnd.Text = "2024-09-06 11:20:39"; |
| | | //this.txtEnd.Text = "2024-09-24 09:52:39"; |
| | | this.btnEnd.Enabled = false; |
| | | |
| | | if (cmbEquipFile.SelectedIndex == 1) |
| | |
| | | { |
| | | if (e.KeyCode == Keys.Enter) |
| | | { |
| | | if (this.txtHMakerNumber.Text == "") |
| | | { |
| | | MessageBox.Show("请输入制单人信息!"); |
| | | } |
| | | else { |
| | | Get_DisplayBard(); |
| | | } |
| | | //this.txtHBathNo.ReadOnly = true; |
| | | Get_DisplayBard(); |
| | | |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | for (int i = 0; i < jsonResult.data.Count; i++) |
| | | { |
| | | if (jsonResult.data[i].propId == 467) |
| | | if (jsonResult.data[i].propId == 173) |
| | | { |
| | | HInSpectQty = jsonResult.data[i].sum; |
| | | } |
| | |
| | | { |
| | | HRightQty = jsonResult.data[i].sum; |
| | | } |
| | | else if (jsonResult.data[i].propId == 466) |
| | | else if (jsonResult.data[i].propId == 606) |
| | | { |
| | | HUnKnowQty = jsonResult.data[i].sum; |
| | | } |
| | |
| | | ",HMainSourceInterID,HMainSourceEntryID,HMainSourceBillNo,HMainSourceBillType,HICMOEntryID,HQCSchemeID,HShiftsID,HErrTreatment" + |
| | | ",HProcID,HBatchNo,HInSpectQty ,HRightQty ,HUnRightQty ,HUnKnowQty " + |
| | | ") " + |
| | | " values('" + BillType + "','" + BillType + "'," + HInterID + ",'" + HBillNo + "',1,getdate(),'',getdate()" + |
| | | " values('" + BillType + "','" + BillType + "'," + HInterID + ",'" + HBillNo + "',1,getdate(),'" + this.txtHMaker.Text + "',getdate()" + |
| | | "," + DateTime.Now.Year + "," + DateTime.Now.Month + ",''" + |
| | | "," + HSourceID + ",0,'',0,0,0" + |
| | | ",'',0," + HMaterID + ",'', " + HLastResults + |
| | | ",'',0," + HMaterID + ",'" + this.labHMakerID.Text + "', " + HLastResults + |
| | | ",0,0,'','',0," + HQCSchemeID + ",0,''" + |
| | | "," + HProcID + ",'" + HBatchNo + "',"+ HInSpectQty + ","+ HRightQty + ", "+ HUnRightQty + ", " + HUnKnowQty + ") "); |
| | | "," + HProcID + ",'" + HBatchNo + "'," + HInSpectQty + "," + HRightQty + ", " + HUnRightQty + ", " + HUnKnowQty + ") "); |
| | | |
| | | |
| | | oCN.Commit(); |
| | |
| | | } |
| | | } |
| | | |
| | | public async Task<JsonResult> EquipResultList(string url, StringContent postData, string Type) |
| | | { |
| | | |
| | | // 创建 HttpClient 实例 |
| | | using (HttpClient client = new HttpClient()) |
| | | { |
| | | JsonResult jsonResult = new JsonResult(); |
| | | try |
| | | { |
| | | HttpResponseMessage response; |
| | | if (Type == "POST") |
| | | { // 发起 POST 请求 |
| | | response = await client.PostAsync(url, postData); |
| | | } |
| | | else |
| | | { |
| | | // 发起 get 请求 |
| | | response = await client.GetAsync(url); |
| | | } |
| | | |
| | | |
| | | // 确保请求成功 |
| | | if (response.IsSuccessStatusCode) |
| | | { |
| | | // 读取响应内容 |
| | | string responseBody = await response.Content.ReadAsStringAsync(); |
| | | jsonResult = JsonConvert.DeserializeObject<JsonResult>(responseBody); |
| | | } |
| | | else |
| | | { |
| | | MessageBox.Show($"请求失败,: {response.StatusCode}"); |
| | | } |
| | | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | MessageBox.Show("请求报错:" + ex.Message); |
| | | } |
| | | return jsonResult; |
| | | } |
| | | } |
| | | |
| | | |
| | | //获取ID |
| | | public async Task<JsonResult> FindAccessToken(string url) |
| | | { |
| | |
| | | //获取良品、不良品明细 |
| | | public async Task<JsonEquipmentData> FindAllDevicePropsDetailByTimeRange(string url, string token,string nos, string HBegin, string HEnd) |
| | | { |
| | | string basePropIds = DBHelper.GetConfigKey(AppDomain.CurrentDomain.BaseDirectory + "Config/SQLAPI.config", "basePropIds"); |
| | | basePropIds = "[" + basePropIds + "]"; |
| | | nos = nos.Replace(",", "\",\""); |
| | | string stringJson = "{\"token\":\"" + token + "\",\"deviceNos\":[\"" + nos + "\"],\"startTime\":\"" + HBegin + "\",\"endTime\":\"" + HEnd + "\",\"basePropIds\":[473,474,489,508, 562, 563, 564, 565, 566, 567, 568, 569, 570,571, 572, 573, 574, 575, 576, 577, 578, 579, 580, 581, 582, 583, 584, 585, 586, 597, 600, 601, 602, 603, 604, 605, 593, 594, 595]}"; |
| | | string stringJson = "{\"token\":\"" + token + "\",\"deviceNos\":[\"" + nos + "\"],\"startTime\":\"" + HBegin + "\",\"endTime\":\"" + HEnd + "\",\"basePropIds\":" + basePropIds + "}"; |
| | | //设备列表接口 |
| | | string urls = url + EquipmentType.Nine; |
| | | |
| | |
| | | //获取不良数,合数数,可疑数 总数 |
| | | public async Task<JsonEquipmentData> FindDevicePropCalc(string url, string token,string nos,string HBegin,string HEnd) |
| | | { |
| | | string stringJson = "{\"token\":\"" + token + "\",\"deviceNo\":\"" + nos + "\",\"propIds\":[466,467,469,470],\"beginTime\":\"" + HBegin + "\",\"endTime\":\"" + HEnd + "\"}"; |
| | | string stringJson = "{\"token\":\"" + token + "\",\"deviceNo\":\"" + nos + "\",\"propIds\":[606,173,469,470],\"beginTime\":\"" + HBegin + "\",\"endTime\":\"" + HEnd + "\"}"; |
| | | var postData = new StringContent(stringJson, System.Text.Encoding.UTF8, "application/json"); |
| | | string urls = url + EquipmentType.Seven; |
| | | JsonEquipmentData jsonResult = await EquipmentList(urls, postData, "POST"); |
| | |
| | | return jsonResult; |
| | | } |
| | | |
| | | //获取设备运行时间 开机 停机 待机 关机 |
| | | public async Task<JsonResult> FindDeviceStatusTimeByNo(string url, string token, string nos, string HBegin, string HEnd) |
| | | { |
| | | nos = nos.Replace(",", "\",\""); |
| | | nos = "\"" + nos + "\""; |
| | | string stringJson = "{\"token\":\"" + token + "\",\"no\":" + nos + ",\"startTime\":\"" + HBegin + "\",\"endTime\":\"" + HEnd + "\"}"; |
| | | var postData = new StringContent(stringJson, System.Text.Encoding.UTF8, "application/json"); |
| | | string urls = url + EquipmentType.Five; |
| | | JsonResult jsonResult = await EquipResultList(urls, postData, "POST"); |
| | | return jsonResult; |
| | | } |
| | | |
| | | //下拉框绑定数据 |
| | | private void bindCbox() |
| | | { |
| | | IList<Info> infoList = new List<Info>(); |
| | | Info info1 = new Info() { Id = "CMR_QC_SE_001", Name = "螺母全检" }; |
| | | Info info2 = new Info() { Id = "CMR_ZZ_SE_001", Name = "螺母压装" }; |
| | | Info info1 = new Info() { Id = "CMR-QC-SE-001", Name = "螺母全检" }; |
| | | Info info2 = new Info() { Id = "CMR-ZZ-SE-001", Name = "螺母压装" }; |
| | | Info info3 = new Info() { Id = "ZSJ07", Name = "注塑机#07" }; |
| | | //Info info3 = new Info() { Id = "3", Name = "王五" }; |
| | | infoList.Add(info1); |
| | |
| | | { |
| | | this.txtHBathNo.ReadOnly = true; |
| | | this.txtBegin.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); |
| | | //this.txtBegin.Text = "2024-11-21 13:40:27"; |
| | | this.btnBegin.Enabled = false; |
| | | this.timer.Enabled = true; |
| | | this.Time_CLHB.Enabled = true; |
| | |
| | | //定时获取数据 |
| | | private async void timer_Tick(object sender, EventArgs e) |
| | | { |
| | | //测试全检 |
| | | //this.timer.Enabled = false; |
| | | |
| | | string Url = DBHelper.GetConfigKey(AppDomain.CurrentDomain.BaseDirectory + "Config/SQLAPI.config", "sUrl"); |
| | | string urls = Url + EquipmentType.One; |
| | | // 准备要发送的表单数据 |
| | |
| | | //获取去设备编码 |
| | | for (int i = 0; i < jsonResult.data.Count; i++) |
| | | { |
| | | if (jsonResult.data[i].no.Contains("CMR_ZZ_SE_001")) |
| | | if (jsonResult.data[i].no.Contains("CMR-ZZ-SE-001")) |
| | | { |
| | | nos += jsonResult.data[i].no + ","; |
| | | } |
| | |
| | | //获取去设备编码 |
| | | for (int i = 0; i < jsonResult.data.Count; i++) |
| | | { |
| | | if (jsonResult.data[i].no.Contains("CMR-ZS-SE")) |
| | | { |
| | | nos += jsonResult.data[i].no + ","; |
| | | } |
| | | else if (jsonResult.data[i].no.Contains("CMR_ZZ_SE_")) |
| | | { |
| | | nos += jsonResult.data[i].no + ","; |
| | | } |
| | | nos += jsonResult.data[i].no + ","; |
| | | //if (jsonResult.data[i].no.Contains("CMR-ZS-SE")) |
| | | //{ |
| | | // nos += jsonResult.data[i].no + ","; |
| | | //} |
| | | //else if (jsonResult.data[i].no.Contains("CMR_ZZ_SE_")) |
| | | //{ |
| | | // nos += jsonResult.data[i].no + ","; |
| | | //} |
| | | } |
| | | nos = nos.Substring(0, nos.Length - 1); |
| | | |
| | | JsonEquipmentData jsonEquipment = await FindAllDevicePropsDetailByTimeRange(Url, token, nos, TimeDate, time); |
| | | |
| | | var JsonData = "{\"data\":["; |
| | | |
| | | for (int i = 0; i < jsonEquipment.data.Count; i++) |
| | | { |
| | | if (jsonEquipment.data[i].deviceNo.Contains("CMR_ZZ_SE_")) |
| | | if (jsonEquipment.data[i].deviceNo.Contains("CMR-ZZ-SE-")) |
| | | { |
| | | for (int j = 0; j < jsonEquipment.data[i].props.Count; j++) |
| | | { |
| | |
| | | |
| | | for (int i = 0; i < EquipmentStaus.data.Count; i++) |
| | | { |
| | | //卷绕的设备运行 开关停机时间 |
| | | if (EquipmentStaus.data[i].no.Contains("CMR-JR-SD-")) |
| | | { |
| | | string HBegDate = DateTime.Now.ToString("yyyy-MM-dd 00:00:00"); |
| | | string HEndDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); |
| | | |
| | | JsonResult HEqDate = await FindDeviceStatusTimeByNo(Url, token, EquipmentStaus.data[i].no, HBegDate, HEndDate); |
| | | |
| | | JsonData += "{\"HDate\":\"" + HEndDate + "\",\"HTechParamName\":\"开机时长\",\"HResult\":\"" + ((float)(HEqDate.data.onlineTime / 60 / 60)).ToString("0.00") + "\",\"HCount\":1,\"HSourceCode\":\"" + EquipmentStaus.data[i].no + "\"},"; |
| | | JsonData += "{\"HDate\":\"" + HEndDate + "\",\"HTechParamName\":\"关机时长\",\"HResult\":\"" + ((float)(HEqDate.data.offlineTime / 60 / 60)).ToString("0.00") + "\",\"HCount\":1,\"HSourceCode\":\"" + EquipmentStaus.data[i].no + "\"},"; |
| | | JsonData += "{\"HDate\":\"" + HEndDate + "\",\"HTechParamName\":\"停机时长\",\"HResult\":\"" + ((float)(HEqDate.data.standbyTime / 60 / 60)).ToString("0.00") + "\",\"HCount\":1,\"HSourceCode\":\"" + EquipmentStaus.data[i].no + "\"},"; |
| | | JsonData += "{\"HDate\":\"" + HEndDate + "\",\"HTechParamName\":\"运行时长\",\"HResult\":\"" + ((float)(HEqDate.data.runTime / 60 / 60)).ToString("0.00") + "\",\"HCount\":1,\"HSourceCode\":\"" + EquipmentStaus.data[i].no + "\"},"; |
| | | } |
| | | |
| | | string staus = ""; |
| | | switch (EquipmentStaus.data[i].status) |
| | | { |
| | |
| | | TimeDate = time; |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | | |
| | | //数据保存 |
| | |
| | | //定时生成产量汇报单 |
| | | private async void Time_CLHB_Tick(object sender, EventArgs e) |
| | | { |
| | | //this.Time_CLHB.Enabled = false; |
| | | string Url = DBHelper.GetConfigKey(AppDomain.CurrentDomain.BaseDirectory + "Config/SQLAPI.config", "sUrl"); |
| | | string urls = Url + EquipmentType.One; |
| | | // 准备要发送的表单数据 |
| | |
| | | { |
| | | nos += "''" + jsonEquipment.data[i].no + "'',"; |
| | | } |
| | | else if (jsonEquipment.data[i].no.Contains("CMR_ZZ_SE_")) |
| | | else if (jsonEquipment.data[i].no.Contains("CMR-ZZ-SE-")) |
| | | { |
| | | nos += "''" + jsonEquipment.data[i].no + "'',"; |
| | | } |
| | |
| | | e.Cancel = true; |
| | | } |
| | | } |
| | | |
| | | private void txtHMaker_Leave(object sender, EventArgs e) |
| | | { |
| | | if (string.IsNullOrWhiteSpace(txtHMaker.Text)) |
| | | { |
| | | this.txtHMaker.ForeColor = Color.LightGray; |
| | | txtHMaker.Text = "请输入用户编码!"; |
| | | } |
| | | } |
| | | |
| | | private void txtHMaker_Enter(object sender, EventArgs e) |
| | | { |
| | | if (txtHMaker.Text.Trim() == "请输入用户编码!") |
| | | { |
| | | txtHMaker.Text = ""; |
| | | this.txtHMaker.ForeColor = Color.Black; |
| | | } |
| | | } |
| | | |
| | | private void txtHMaker_KeyDown(object sender, KeyEventArgs e) |
| | | { |
| | | if (e.KeyCode == Keys.Enter) |
| | | { |
| | | SelectHMaker(this.txtHMaker.Text); |
| | | } |
| | | } |
| | | |
| | | |
| | | //查询职员信息 |
| | | public void SelectHMaker(string txtHMaker) |
| | | { |
| | | try |
| | | { |
| | | DataSet ds = oCN.RunProcReturn("select HItemID,HName,HNumber from Gy_Employee where HNumber='" + txtHMaker + "' or HName ='" + txtHMaker + "'", "Gy_Employee"); |
| | | if (ds.Tables[0].Rows.Count > 0) |
| | | { |
| | | string HName = ds.Tables[0].Rows[0]["HName"].ToString(); |
| | | string HMakerID = ds.Tables[0].Rows[0]["HItemID"].ToString(); |
| | | string HNumber = ds.Tables[0].Rows[0]["HNumber"].ToString(); |
| | | this.txtHMaker.Text = HName; |
| | | this.txtHMakerNumber.Text = HNumber; |
| | | this.labHMakerID.Text = HMakerID; |
| | | this.txtHMaker.ReadOnly = true; |
| | | } |
| | | else |
| | | { |
| | | MessageBox.Show(this, "编码:" + txtHMaker + ",查无数据,可能是输入编码有误!", "提示"); |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | MessageBox.Show(this, e.Message, "提示"); |
| | | } |
| | | } |
| | | |
| | | private void EquipmentCollectionForm_Activated(object sender, EventArgs e) |
| | | { |
| | | //光标选中制单人 |
| | | this.txtHMaker.Focus(); |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | public class JsonData |
| | | { |
| | | public double onlineTime { get; set; } |
| | | public double offlineTime { get; set; } |
| | | public double standbyTime { get; set; } |
| | | public double runTime { get; set; } |
| | | public string expirationTime { get; set; } |
| | | public string token { get; set; } |
| | | public string deviceNo { get; set; } |
| | |
| | | //一段时间内设备状态的获取 |
| | | public static string Eight = "/api/third/dayDeviceStatusTimeline"; |
| | | //良品 不良品 明细 注塑机数据 |
| | | public static string Nine = "/api/third/findAllDevicePropsDetailByTimeRange"; |
| | | public static string Nine = "/api/third/findAllDevicePropsDetailByTimeRange_v1"; |
| | | //注塑机数据 |
| | | public static string Ten = "/api/third/findAllDevicePropsDetailByTimeRange"; |
| | | //public static string Ten = "/api/third/findAllDevicePropsDetailByTimeRange"; |
| | | //public static string Eleven = "Monday"; |
| | | //public static string Twelve = "Monday"; |
| | | } |