From 861794e4cc962de1059ab01ca1e2bd81e2bac643 Mon Sep 17 00:00:00 2001
From: yangle <admin@YINMOU>
Date: 星期一, 21 四月 2025 14:47:00 +0800
Subject: [PATCH] 1
---
WFormSynchronizeData_SMR/EquipmentCollectionForm/EquipmentCollectionForm.cs | 383 +++++++++++++++++++++++++++++++++++++++++++++++-------
1 files changed, 334 insertions(+), 49 deletions(-)
diff --git a/WFormSynchronizeData_SMR/EquipmentCollectionForm/EquipmentCollectionForm.cs b/WFormSynchronizeData_SMR/EquipmentCollectionForm/EquipmentCollectionForm.cs
index 1767412..2e335ad 100644
--- a/WFormSynchronizeData_SMR/EquipmentCollectionForm/EquipmentCollectionForm.cs
+++ b/WFormSynchronizeData_SMR/EquipmentCollectionForm/EquipmentCollectionForm.cs
@@ -33,6 +33,12 @@
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();
}
@@ -40,13 +46,14 @@
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)
{
@@ -65,7 +72,7 @@
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)
@@ -200,8 +207,15 @@
{
if (e.KeyCode == Keys.Enter)
{
+ if (this.txtHMakerNumber.Text == "")
+ {
+ MessageBox.Show("璇疯緭鍏ュ埗鍗曚汉淇℃伅!");
+ }
+ else {
+ Get_DisplayBard();
+ }
//this.txtHBathNo.ReadOnly = true;
- Get_DisplayBard();
+
}
}
@@ -251,6 +265,7 @@
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;
@@ -276,6 +291,7 @@
try
{
+ //鑾峰彇鎵�鏈夎澶囨暟鎹�
JsonEquipmentData jsonResult =await FindDeviceList(url, token);
if (jsonResult.code != "0")
@@ -286,7 +302,7 @@
else
{
string nos = "";
- //鑾峰彇鍘昏澶囩紪鐮�
+ //鑾峰彇璁惧缂栫爜
for (int i = 0; i < jsonResult.data.Count; i++)
{
if (jsonResult.data[i].no == this.cmbEquipFile.SelectedValue.ToString())
@@ -294,8 +310,11 @@
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")
{
@@ -310,15 +329,15 @@
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;
+ //HInSpectQty = jsonResult.data[i].sum;
}
else if (jsonResult.data[i].propId == 469)
{
HRightQty = jsonResult.data[i].sum;
}
- else if (jsonResult.data[i].propId == 466)
+ else if (jsonResult.data[i].propId == 606)
{
HUnKnowQty = jsonResult.data[i].sum;
}
@@ -327,8 +346,10 @@
HUnRightQty = jsonResult.data[i].sum;
}
}
+ //閫氳繃鍙屾柟璁ㄨ 鏈�缁堥噰绾� 妫�楠屾暟閲�=鍚堟牸+涓嶅悎鏍�+鍙枒
+ HInSpectQty = HRightQty + HUnKnowQty + HUnRightQty;
-
+
string HNumber = "";
int HSourceID = 0;
string HSourceNumber = "";
@@ -389,9 +410,12 @@
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());
}
@@ -413,16 +437,19 @@
break;
}
//SRM@101.2@VEN00005@CGDD000167@1.02.002.002@20231129@1000
+ //鍒ゆ柇妫�楠岄」鐩殑浠g爜 璺熷垪鍚嶆槸鍚︿竴鑷�
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;
@@ -432,7 +459,7 @@
HInSpectResult = int.Parse(HInSpectValue.ToString());
}
-
+ //濡傛灉褰撳墠缁撹涓哄悎鏍� 骞朵笖鍘嗗彶缁撹涔熸槸鍚堟牸 鍒欑户缁繚鎸佸悎鏍�
if (HInSpectResult == 1 && HLastResult != 0)
{
HLastResult = 1;
@@ -470,7 +497,7 @@
",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;
@@ -490,12 +517,12 @@
",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();
@@ -602,6 +629,49 @@
}
}
+ 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)
{
@@ -630,8 +700,10 @@
//鑾峰彇鑹搧銆佷笉鑹搧鏄庣粏
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;
@@ -644,7 +716,7 @@
//鑾峰彇涓嶈壇鏁帮紝鍚堟暟鏁帮紝鍙枒鏁� 鎬绘暟
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");
@@ -676,12 +748,37 @@
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;
+ }
+
+ //鑾峰彇娉ㄥ鏈虹殑 寮�鏈�
+ public async Task<JsonResult> FindDeviceStatusTimeByNosAndOperationMode(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.Ten;
+ 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);
@@ -710,7 +807,8 @@
if (dr == DialogResult.Yes)
{
this.txtHBathNo.ReadOnly = true;
- this.txtBegin.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
+ this.txtBegin.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:00");
+ //this.txtBegin.Text = "2024-11-21 13:40:27";
this.btnBegin.Enabled = false;
this.timer.Enabled = true;
this.Time_CLHB.Enabled = true;
@@ -721,6 +819,9 @@
//瀹氭椂鑾峰彇鏁版嵁
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;
// 鍑嗗瑕佸彂閫佺殑琛ㄥ崟鏁版嵁
@@ -731,7 +832,7 @@
// 娣诲姞鏇村閿�煎锛屾牴鎹偍鐨勯渶瑕�
});
JsonResult jsonResult = await getUrl(urls, formData);
- string time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
+ string time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:00");
if (cmbEquipFile.SelectedIndex == 1)
{
@@ -764,7 +865,7 @@
//鑾峰彇鍘昏澶囩紪鐮�
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 + ",";
}
@@ -831,9 +932,10 @@
}
//this.timer.Enabled = false;
- //TimeDate = "2024-08-19 19:38:14.540";
- //time = "2024-08-19 19:39:14.540";
+ //TimeDate = "2025-02-10 13:10:50";
+ //time = "2025-02-10 13:11:50";
+ //鑾峰彇鎵�鏈夎澶囨暟鎹�
JsonEquipmentData jsonResult = await FindDeviceList(Url, token);
if (jsonResult.code != "0")
{
@@ -842,33 +944,46 @@
else {
string nos = "";
- //鑾峰彇鍘昏澶囩紪鐮�
+ //鑾峰彇璁惧缂栫爜
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\":[";
-
+ 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_"))
+ //鑾峰彇璁惧瀵瑰簲鐨勭紪鐮� 鍒ゆ柇缂栫爜鏄惁婊¤冻涓鸿灪姣嶅帇瑁呰澶�
+ 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 + "\"},";
@@ -898,14 +1013,17 @@
}
}
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++)
@@ -916,10 +1034,48 @@
}
}
- var EquipmentStaus = await FindDeviceStatusByNos(Url, token, nos);
+ CustomWriteLog("02", DateTime.Now.ToString("yyyy-MM-dd"));
+
+ //鑾峰彇璁惧杩愯鐘舵��
+ var EquipmentStaus = await FindDeviceStatusByNos(Url, token, nos);
for (int i = 0; i < EquipmentStaus.data.Count; i++)
{
+ //鍗风粫 娉ㄥ 娴告笉 缁勮 鐨勮澶囪繍琛� 寮�鍏冲仠鏈烘椂闂�
+ if (EquipmentStaus.data[i].no.Contains("CMR-JR-SD-") || EquipmentStaus.data[i].no.Contains("CMR-JZ-SD-") || EquipmentStaus.data[i].no.Contains("CMR-HX-SD-")
+ || EquipmentStaus.data[i].no.Contains("CMR-ZD-SD")|| EquipmentStaus.data[i].no.Contains("CMR-ZS-SE-"))
+ {
+ string HBegDate = DateTime.Now.ToString("yyyy-MM-dd 00:00:00");
+ string HEndDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:00");
+
+ if (DateTime.Parse(HEndDate).AddMinutes(1).ToString("yyyy-MM-dd") != DateTime.Parse(HEndDate).ToString("yyyy-MM-dd")) {
+ HEndDate= DateTime.Parse(HEndDate).AddMinutes(1).ToString("yyyy-MM-dd HH:mm:00");
+ }
+
+ 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 + "\"},";
+ }
+ //鍗风粫 娉ㄥ 娴告笉 缁勮 鐨勮澶囪繍琛� 寮�鍏冲仠鏈烘椂闂�
+ //if (EquipmentStaus.data[i].no.Contains("CMR-ZS-SE-"))
+ //{
+ // string HBegDate = DateTime.Now.ToString("yyyy-MM-dd 00:00:00");
+ // string HEndDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
+
+ // JsonResult kj = await FindDeviceStatusTimeByNosAndOperationMode(Url, token, EquipmentStaus.data[i].no, HBegDate, HEndDate);
+ // JsonData += "{\"HDate\":\"" + HEndDate + "\",\"HTechParamName\":\"寮�鏈烘椂闀縗",\"HResult\":\"" + ((float)(kj.data.onlineTime / 60 / 60)).ToString("0.00") + "\",\"HCount\":1,\"HSourceCode\":\"" + EquipmentStaus.data[i].no + "\"},";
+
+ // JsonResult HEqDate = await FindDeviceStatusTimeByNo(Url, token, EquipmentStaus.data[i].no, HBegDate, HEndDate);
+
+ // 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)
{
@@ -950,20 +1106,35 @@
}
}
+ //鏌ヨ褰撳墠寮�宸ョ殑璁惧 鑾峰彇瀵瑰簲鐨勭墿鏂欎俊鎭�
+ 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
+ where a.HICMOStatus = '1' ", "Sc_ICMOBillStatus_Tmp");
+
+ if (datable.Tables[0].Rows.Count > 0)
+ {
+ for (int i = 0; i < datable.Tables[0].Rows.Count; i++)
+ {
+ string HSourceCode = datable.Tables[0].Rows[i]["HEquipFileNo"].ToString();
+ string HNumber = datable.Tables[0].Rows[i]["HNumber"].ToString();
+
+ JsonData += "{\"HDate\":\"" + DateTime.Now.ToString() + "\",\"HTechParamName\":\"鐗╂枡浠g爜\",\"HResult\":\"" + HNumber + "\",\"HCount\":1,\"HSourceCode\":\"" + HSourceCode + "\"},";
+ }
+ }
+
+ CustomWriteLog("03", DateTime.Now.ToString("yyyy-MM-dd"));
+
JsonData = JsonData.Substring(0, JsonData.Length - 1);
JsonData += "]}";
+
+ //淇濆瓨鏁版嵁
DataSave(JsonData);
if (TimeDate != "")
{
TimeDate = time;
}
}
-
-
-
-
-
-
}
//鏁版嵁淇濆瓨
@@ -986,6 +1157,7 @@
//瀹氭椂鐢熸垚浜ч噺姹囨姤鍗�
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;
// 鍑嗗瑕佸彂閫佺殑琛ㄥ崟鏁版嵁
@@ -998,6 +1170,8 @@
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")
@@ -1014,7 +1188,7 @@
{
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 + "'',";
}
@@ -1023,10 +1197,12 @@
//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++)
{
@@ -1036,12 +1212,14 @@
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++)
{
@@ -1052,6 +1230,7 @@
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 + "'");
}
}
@@ -1065,6 +1244,108 @@
if (MessageBox.Show("纭畾瑕佸叧闂悧锛�", "纭", MessageBoxButtons.YesNo) == DialogResult.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();
+ }
+
+ private static readonly object lockObj = new object();
+ //鍐欐棩蹇�
+ public static void CustomWriteLog(object obj, string FileName, string filePath = "Vlog", bool isAppend = true)
+ {
+ try
+ {
+ lock (lockObj)
+ {
+ filePath = $@"{filePath}\{FileName}.txt";
+
+ filePath = AppDomain.CurrentDomain.BaseDirectory + filePath;
+
+ if (!System.IO.Directory.Exists(Path.GetDirectoryName(filePath)))
+ {
+ System.IO.Directory.CreateDirectory(Path.GetDirectoryName(filePath));
+ }
+
+ bool fileExists = System.IO.File.Exists(filePath);
+ //涓嶅瓨鍦� 鍒欏垱寤鸿鏂囦欢
+ if (!fileExists)
+ {
+ System.IO.File.Create(filePath).Close();
+ }
+
+ using (StreamWriter writer = new StreamWriter(filePath, isAppend))
+ {
+ //瀛樺湪鐨勬椂鍊欐墠鍐欎竴琛�
+ if (fileExists && isAppend)
+ {
+ writer.WriteLine();
+ }
+
+ var content = obj is string ? obj : JsonConvert.SerializeObject(obj);
+ writer.WriteLine($"{DateTime.Now} {content}");
+ }
+ }
+ }
+ catch (Exception ex)
+ {
}
}
}
@@ -1092,6 +1373,10 @@
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; }
@@ -1153,9 +1438,9 @@
//涓�娈垫椂闂村唴璁惧鐘舵�佺殑鑾峰彇
public static string Eight = "/api/third/dayDeviceStatusTimeline";
//鑹搧 涓嶈壇鍝� 鏄庣粏 娉ㄥ鏈烘暟鎹�
- public static string Nine = "/api/third/findAllDevicePropsDetailByTimeRange";
- //娉ㄥ鏈烘暟鎹�
- public static string Ten = "/api/third/findAllDevicePropsDetailByTimeRange";
+ public static string Nine = "/api/third/findAllDevicePropsDetailByTimeRange_v1";
+ //娉ㄥ鏈哄紑鏈烘椂闀� 鏍规嵁 鎿嶄綔妯″紡閲囬泦
+ public static string Ten = "/api/third/findDeviceStatusTimeByNosAndOperationMode";
//public static string Eleven = "Monday";
//public static string Twelve = "Monday";
}
@@ -1165,5 +1450,5 @@
public string Id { get; set; }
public string Name { get; set; }
}
-
+
}
--
Gitblit v1.9.1