From 1d9f82659dbfdfd6ac0ddbb33f1fd5af1164d939 Mon Sep 17 00:00:00 2001
From: yangle <admin@YINMOU>
Date: 星期五, 29 十一月 2024 16:52:14 +0800
Subject: [PATCH] 浸渍 铁芯检测 无尘 单品过站 不能开工不能过站控制
---
WFormSynchronizeData_SMR/WFormReadData_SMR/ReadCSV.cs | 289 +++++++++++++++++++++++++++++++++++++++++++++------------
1 files changed, 225 insertions(+), 64 deletions(-)
diff --git a/WFormSynchronizeData_SMR/WFormReadData_SMR/ReadCSV.cs b/WFormSynchronizeData_SMR/WFormReadData_SMR/ReadCSV.cs
index 2ceb1f3..38e3b2d 100644
--- a/WFormSynchronizeData_SMR/WFormReadData_SMR/ReadCSV.cs
+++ b/WFormSynchronizeData_SMR/WFormReadData_SMR/ReadCSV.cs
@@ -6,6 +6,7 @@
using System.Drawing;
using System.IO;
using System.Linq;
+using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
@@ -44,9 +45,16 @@
}
else
{
- string HProjectNum = ds.Tables[0].Rows[0]["HProjectNum"].ToString();
- this.txtHBath.Text = HProjectNum.Split('-')[0];
- this.txtHBardCode.ReadOnly = true;
+ DataSet dataSet= oCN.RunProcReturn("select * from Sc_ICMOBillStatus_Tmp where HSourceBillNo='" + HBillNo + "' and HICMOStatus='1'", "Sc_ICMOBillStatus_Tmp");
+ if (dataSet.Tables[0].Rows.Count > 0)
+ {
+ string HProjectNum = ds.Tables[0].Rows[0]["HProjectNum"].ToString();
+ this.txtHBath.Text = HProjectNum.Split('-')[0];
+ this.txtHBardCode.ReadOnly = true;
+ }
+ else {
+ MessageBox.Show(HBillNo + ",娴佽浆鍗℃湭寮�宸�!");
+ }
}
}
catch (Exception e)
@@ -169,26 +177,27 @@
//娉�:鏂帿灏旂粍瑁�3 鍦‥鐩� _332009
//鍏朵綑鍦―鐩� _C332001_2M
//string csv_file_path = $@"C:\Users\admin\Desktop\鏂板缓鏂囦欢澶� (2)\20231123.csv";
- //string csv_file_path = $@"D:\THLCR_Data\{HBath}\{HBath}_{Date}_C332001_2M.csv"; //缁勮1 缁勮2璺緞
- string csv_file_path = $@"E:\THLCR_Data\{HBath}\{HBath}_{Date}_332009.csv"; //缁勮3璺緞
+ string csv_file_path = $@"D:\THLCR_Data\{HBath}\{HBath}_{Date}_C332001_2M.csv"; //缁勮1 缁勮2璺緞
+ //string csv_file_path = $@"E:\THLCR_Data\{HBath}\{HBath}_{Date}_332009.csv"; //缁勮3璺緞
//15杞﹂棿缂哄皯璺緞 D:\DATA SAVE\骞碶骞存湀\骞存湀鏃鎵规鍙穃鏁版嵁淇濆瓨.csv
//string csv_file_path = $@"D:\DATA SAVE\{Year}\{Year + Month}\{Year + Month + Day}\{HBath}\鏁版嵁淇濆瓨.csv";
-
+
bool flag = File.Exists(csv_file_path);
if (flag)
{
DataTable dt = new DataTable();
- //string HTypeName = "鏃犲皹";
+ string HTypeName = "鏃犲皹";
//string csv_file_path_Read = @"C:\Users\admin\Desktop\鏂板缓鏂囦欢澶� (2)\20231123_1.csv";
- //string csv_file_path_Read = $@"D:\THLCR_Data\{HBath}\{HBath}_{Date}_C332001_2M_Read.csv"; //缁勮1 缁勮2璺緞
+ string csv_file_path_Read = $@"D:\THLCR_Data\{HBath}\{HBath}_{Date}_C332001_2M_Read.csv"; //缁勮1 缁勮2璺緞
//string csv_file_path_Read = $@"E:\THLCR_Data\{HBath}\{HBath}_{Date}_332009_Read.csv"; //缁勮3璺緞
- string HTypeName = "15";
- //15杞﹂棿缂哄皯璺緞 D:\DATA SAVE\骞碶骞存湀\骞存湀鏃鎵规鍙穃鏁版嵁淇濆瓨.csv
- //string csv_file_path_Read = $@"C:\Users\admin\Desktop\鏂板缓鏂囦欢澶� (2)\DATA SAVE\鏁版嵁淇濆瓨_MES璇诲彇.csv";
-
- string csv_file_path_Read = $@"D:\DATA SAVE\{Year}\{Year + Month}\{Year + Month + Day}\{HBath}\鏁版嵁淇濆瓨_MES璇诲彇.csv";
+
+ //string HTypeName = "15";
+ ////15杞﹂棿缂哄皯璺緞 D:\DATA SAVE\骞碶骞存湀\骞存湀鏃鎵规鍙穃鏁版嵁淇濆瓨.csv
+ ////string csv_file_path_Read = $@"C:\Users\admin\Desktop\鏂板缓鏂囦欢澶� (2)\DATA SAVE\鏁版嵁淇濆瓨_MES璇诲彇.csv";
+
+ //string csv_file_path_Read = $@"D:\DATA SAVE\{Year}\{Year + Month}\{Year + Month + Day}\{HBath}\鏁版嵁淇濆瓨_MES璇诲彇.csv";
File.Copy(csv_file_path, csv_file_path_Read, true);
@@ -222,7 +231,8 @@
//鑾峰彇褰撳墠鏃堕棿
DateTime ActionTime = DateTime.Parse(DateTime.Now.AddMinutes(-2).ToString("yyyy-MM-dd HH:mm:ss"));
DateTime EndTime = DateTime.Parse(DateTime.Now.AddMinutes(1).ToString("yyyy-MM-dd HH:mm:00"));
-
+ bool flag_1 = false;
+ bool flag_2 = false;
foreach (DataRow item in dt.Rows)
{
if (HTypeName == "鏃犲皹")
@@ -239,7 +249,7 @@
string HCreateTime = item["娴嬭瘯鏃堕棿"].ToString();
string HDate = DateTime.Parse(item["娴嬭瘯鏃堕棿"].ToString()).ToString("yyyy-MM-dd");
string HResult = item["鍒嗛��"].ToString() == "PASS" ? "OK" : "NG";
- string HProcNumber = "005";
+ string HProcNumber = "005"; //005
int HFlag = 0;
//string HEmpCode = "";
if (HBadCodeSN != "")
@@ -251,28 +261,34 @@
if (ds.Tables[0].Rows.Count == 0)
{
- string sql = $@"insert into Sb_EquipMentCollection_SN(HSourceCode,HEmpCode,HType,HBarCode,HCount,HCreateTime,HDate,HResult,HProcNumber,HFlag)
- values('{HSourceCode}','{HEmpCode}','{HType}','{HBarCode}','{HCount}','{HCreateTime}','{HDate}','{HResult}','{HProcNumber}','{HFlag}')";
- oCN.RunProc(sql);
- ListSelect.Items.Add("鏉$爜:" + HBarCode + ",鏃ユ湡:" + HCreateTime + ",缁撴灉:" + HResult);
- }
- }
-
- for (int i = 0; i < dt.Columns.Count; i++)
- {
- if (dt.Columns[i].ColumnName.Contains("Hz"))
- {
- string HType = dt.Columns[i].ColumnName;
- string HCount = item[HType].ToString();
-
- DataSet ds = oCN.RunProcReturn(@"select * from Sb_EquipMentCollectionTechParam_SN where HBarCode='" + HBarCode + "' and HType='" + HType + "'", "Sb_EquipMentCollectionTechParam_SN");
-
- if (ds.Tables[0].Rows.Count == 0)
+ if (Get_AllowLoadData(HBarCode, HProcNumber, flag_1,out flag_2))
{
- string sql = $@"insert into Sb_EquipMentCollectionTechParam_SN(HSourceCode,HEmpCode,HType,HBarCode,HCount,HCreateTime,HDate,HResult,HProcNumber,HFlag)
-values('{HSourceCode}','{HEmpCode}','{HType}','{HBarCode}','{HCount}','{HCreateTime}','{HDate}','{HResult}','{HProcNumber}','{HFlag}')";
+ string sql = $@"insert into Sb_EquipMentCollection_SN(HSourceCode,HEmpCode,HType,HBarCode,HCount,HCreateTime,HDate,HResult,HProcNumber,HFlag)
+ values('{HSourceCode}','{HEmpCode}','{HType}','{HBarCode}','{HCount}','{HCreateTime}','{HDate}','{HResult}','{HProcNumber}','{HFlag}')";
oCN.RunProc(sql);
- //ListSelect.Items.Add("鏉$爜:" + HBarCode + ",鏃ユ湡:" + HCreateTime + ",缁撴灉:" + HResult);
+ ListSelect.Items.Add("鏉$爜:" + HBarCode + ",鏃ユ湡:" + HCreateTime + ",缁撴灉:" + HResult);
+
+ for (int i = 0; i < dt.Columns.Count; i++)
+ {
+ if (dt.Columns[i].ColumnName.Contains("Hz"))
+ {
+ HType = dt.Columns[i].ColumnName;
+ string HCount_1 = item[HType].ToString();
+
+ DataSet ds1 = oCN.RunProcReturn(@"select * from Sb_EquipMentCollectionTechParam_SN where HBarCode='" + HBarCode + "' and HType='" + HType + "'", "Sb_EquipMentCollectionTechParam_SN");
+
+ if (ds1.Tables[0].Rows.Count == 0)
+ {
+ string sql1 = $@"insert into Sb_EquipMentCollectionTechParam_SN(HSourceCode,HEmpCode,HType,HBarCode,HCount,HCreateTime,HDate,HResult,HProcNumber,HFlag)
+values('{HSourceCode}','{HEmpCode}','{HType}','{HBarCode}','{HCount_1}','{HCreateTime}','{HDate}','{HResult}','{HProcNumber}','{HFlag}')";
+ oCN.RunProc(sql1);
+ //ListSelect.Items.Add("鏉$爜:" + HBarCode + ",鏃ユ湡:" + HCreateTime + ",缁撴灉:" + HResult);
+ }
+ }
+ }
+ }
+ else {
+ flag_1 = flag_2;
}
}
}
@@ -304,51 +320,196 @@
DataSet ds = oCN.RunProcReturn(@"select * from Sb_EquipMentCollection_SN where HBarCode='" + HBarCode + "' and HCreateTime='" + HCreateTime + "'", "Sb_EquipMentCollection_SN");
+
if (ds.Tables[0].Rows.Count == 0)
{
- string sql = $@"insert into Sb_EquipMentCollection_SN(HSourceCode,HEmpCode,HType,HBarCode,HCount,HCreateTime,HDate,HResult,HProcNumber,HFlag)
- values('{HSourceCode}','{HEmpCode}','{HType}','{HBarCode}','{HCount}','{HCreateTime}','{HDate}','{HResult}','{HProcNumber}','{HFlag}')";
- oCN.RunProc(sql);
- ListSelect.Items.Add("鏉$爜:" + HBarCode + ",鏃ユ湡:" + HCreateTime + ",缁撴灉:" + HResult);
- }
- }
-
- for (int i = 0; i < dt.Columns.Count; i++)
- {
- if (dt.Columns[i].ColumnName.Contains("CS_"))
- {
- string HType = dt.Columns[i].ColumnName;
- string HCount = item[HType].ToString();
- string HResult_TechParam = "";
- if (HType != "CS_鏃堕棿" && HType != "CS_DM鐮�" && HType != "CS_鎬荤粨鏋�")
+ if (Get_AllowLoadData(HBarCode, HProcNumber, flag_1, out flag_2))
{
- HResult_TechParam = HCount;
- double number = 0;
- if (!Double.TryParse(HCount, out number))
- {
- HCount = "0";
- }
+ string sql = $@"insert into Sb_EquipMentCollection_SN(HSourceCode,HEmpCode,HType,HBarCode,HCount,HCreateTime,HDate,HResult,HProcNumber,HFlag)
+ values('{HSourceCode}','{HEmpCode}','{HType}','{HBarCode}','{HCount}','{HCreateTime}','{HDate}','{HResult}','{HProcNumber}','{HFlag}')";
+ oCN.RunProc(sql);
+ ListSelect.Items.Add("鏉$爜:" + HBarCode + ",鏃ユ湡:" + HCreateTime + ",缁撴灉:" + HResult);
- DataSet ds = oCN.RunProcReturn(@"select * from Sb_EquipMentCollectionTechParam_SN where HBarCode='" + HBarCode + "' and HType='" + HType + "'", "Sb_EquipMentCollectionTechParam_SN");
-
- if (ds.Tables[0].Rows.Count == 0)
+ for (int i = 0; i < dt.Columns.Count; i++)
{
- string sql = $@"insert into Sb_EquipMentCollectionTechParam_SN(HSourceCode,HEmpCode,HType,HBarCode,HCount,HCreateTime,HDate,HResult,HProcNumber,HFlag)
-values('{HSourceCode}','{HEmpCode}','{HType}','{HBarCode}','{(HCount == "" ? " 0" : HCount)}','{HCreateTime}','{HDate}','{HResult_TechParam}','{HProcNumber}','{HFlag}')";
- oCN.RunProc(sql);
- //ListSelect.Items.Add("鏉$爜:" + HBarCode + ",鏃ユ湡:" + HCreateTime + ",缁撴灉:" + HResult);
+ if (dt.Columns[i].ColumnName.Contains("CS_"))
+ {
+ HType = dt.Columns[i].ColumnName;
+ string HCount_1 = item[HType].ToString();
+ string HResult_TechParam = "";
+ if (HType != "CS_鏃堕棿" && HType != "CS_DM鐮�" && HType != "CS_鎬荤粨鏋�")
+ {
+ HResult_TechParam = HCount_1;
+ double number = 0;
+ if (!Double.TryParse(HCount_1, out number))
+ {
+ HCount_1 = "0";
+ }
+
+ DataSet ds1 = oCN.RunProcReturn(@"select * from Sb_EquipMentCollectionTechParam_SN where HBarCode='" + HBarCode + "' and HType='" + HType + "'", "Sb_EquipMentCollectionTechParam_SN");
+
+ if (ds1.Tables[0].Rows.Count == 0)
+ {
+ string sql1 = $@"insert into Sb_EquipMentCollectionTechParam_SN(HSourceCode,HEmpCode,HType,HBarCode,HCount,HCreateTime,HDate,HResult,HProcNumber,HFlag)
+values('{HSourceCode}','{HEmpCode}','{HType}','{HBarCode}','{(HCount_1 == "" ? " 0" : HCount_1)}','{HCreateTime}','{HDate}','{HResult_TechParam}','{HProcNumber}','{HFlag}')";
+ oCN.RunProc(sql1);
+ //ListSelect.Items.Add("鏉$爜:" + HBarCode + ",鏃ユ湡:" + HCreateTime + ",缁撴灉:" + HResult);
+ }
+ }
+ }
}
+ }
+ else
+ {
+ flag_1 = flag_2;
}
}
}
}
}
}
-
}
}
}
+
+ //鏍规嵁鏉$爜 鍒ゆ柇鏄惁淇濆瓨
+ public bool Get_AllowLoadData(string HBarCode,string HProcNumber,bool flag_1,out bool flag_2)
+ {
+ if (HBarCode.Length != 29 && HBarCode.Length != 50)
+ {
+ flag_2 = false;
+ return false;
+ }
+
+ //鍒ゆ柇闀垮害鏄惁涓�29浣� 鏃犲皹杞﹂棿
+ string HProcExchBillNo = "";
+ string HProcExchInterID = "";
+ if (HBarCode.Length == 29)
+ {
+ string str1 = HBarCode.Substring(18, 8);
+ string str2 = HBarCode.Substring(23, 3);
+
+ DataSet ds = oCN.RunProcReturn("select HInterID,HBillNo from Sc_ProcessExchangeBillMain where HProjectNum like'" + str1 + "-1%' or HProjectNum like'" + str2 + "-1%' order by HMakeDate desc", "Sc_ProcessExchangeBillMain");
+ //鍒ゆ柇鏄惁鑳芥壘鍒板搴旂殑娴佽浆鍗�
+ if (ds.Tables[0].Rows.Count > 0)
+ {
+ HProcExchBillNo = ds.Tables[0].Rows[0]["HBillNo"].ToString();
+ HProcExchInterID = ds.Tables[0].Rows[0]["HInterID"].ToString();
+ }
+ else {
+ if (!flag_1)
+ {
+ MessageBox.Show(new Form { TopMost = true }, "鏉$爜:" + HBarCode + ",娴佽浆鍗′笉瀛樺湪!");
+ }
+ DBHelper.CustomWriteLog("鏉$爜:" + HBarCode + ",娴佽浆鍗′笉瀛樺湪!", DateTime.Now.ToString("yyyy-MM-dd"));
+ flag_2 = true;
+ return false;
+ }
+ }
+ //鍒ゆ柇闀垮害鏄惁涓�50浣� 15杞﹂棿
+ else if (HBarCode.Length == 50)
+ {
+ string str1 = HBarCode.Substring(42, 8);
+ DataSet ds = oCN.RunProcReturn("select HBillNo from Sc_ProcessExchangeBillMain where HProjectNum like'" + str1 + "-1%'", "Sc_ProcessExchangeBillMain");
+ //鍒ゆ柇鏄惁鑳芥壘鍒板搴旂殑娴佽浆鍗�
+ if (ds.Tables[0].Rows.Count > 0)
+ {
+ HProcExchBillNo = ds.Tables[0].Rows[0]["HBillNo"].ToString();
+ }
+ else {
+ if (!flag_1)
+ {
+ MessageBox.Show("鏉$爜:" + HBarCode + ",娴佽浆鍗′笉瀛樺湪!");
+ }
+ DBHelper.CustomWriteLog("鏉$爜:" + HBarCode + ",娴佽浆鍗′笉瀛樺湪!", DateTime.Now.ToString("yyyy-MM-dd"));
+
+ flag_2 = true;
+ return false;
+ }
+ }
+
+
+ //杩囩珯鎺у埗
+ DataSet ds1 = oCN.RunProcReturn(@"select b.HProcNo,b.HProcID,p.HName from Sc_ProcessExchangeBillMain a WITH(NOLOCK)
+inner join Sc_ProcessExchangeBillSub b WITH(NOLOCK) on a.HInterID=b.HInterID
+left join Gy_Process p WITH(NOLOCK) on b.HProcID=p.HItemID
+where a.HBillNo='" + HProcExchBillNo + "' and p.HNumber='" + HProcNumber + "'", "Sc_ProcessExchangeBillMain");
+ string HProcID = "0";
+ if (ds1.Tables[0].Rows.Count > 0)
+ {
+ HProcID = ds1.Tables[0].Rows[0]["HProcID"].ToString();
+ string HProName = ds1.Tables[0].Rows[0]["HName"].ToString();
+
+ ds1 = oCN.RunProcReturn("exec h_p_Sc_SNBarcodeProcCtrl_S '" + HBarCode + "'," + HProcID, "h_v_Gy_QualifiedRecordsList");
+
+ if (ds1.Tables[0].Rows.Count == 0)
+ {
+ if (!flag_1)
+ {
+ MessageBox.Show("鏉$爜:" + HBarCode + "宸ュ簭:" + HProName + ",宸ュ簭鎺у埗鏌ユ棤鏁版嵁!");
+ }
+ DBHelper.CustomWriteLog("鏉$爜:" + HBarCode + "宸ュ簭:" + HProName + ",宸ュ簭鎺у埗鏌ユ棤鏁版嵁!", DateTime.Now.ToString("yyyy-MM-dd"));
+
+ flag_2 = true;
+ return false;
+ }
+ else if (ds1.Tables[0].Rows[0]["HBack"].ToString() == "2")
+ {
+ if (!flag_1)
+ {
+ MessageBox.Show("鏉$爜:" + HBarCode + "宸ュ簭:" + HProcID + "," + ds1.Tables[0].Rows[0]["HBackRemark"].ToString() + "!");
+ }
+ DBHelper.CustomWriteLog("鏉$爜:" + HBarCode + "宸ュ簭:" + HProcID + "," + ds1.Tables[0].Rows[0]["HBackRemark"].ToString() + "!", DateTime.Now.ToString("yyyy-MM-dd"));
+
+ flag_2 = true;
+ return false;
+ }
+ }
+
+ //鏌ヨ鍑虹珯鏁伴噺鏄惁瓒呰繃娴佽浆鍗℃暟閲�
+ ds1 = oCN.RunProcReturn($@"select (b.HQty -sum(isnull(ou.HQty,0))-sum(isnull(ou.HBadCount,0))) HQty from Sc_ProcessExchangeBillSub b WITH(NOLOCK)
+left join Sc_StationOutBillMain ou WITH(NOLOCK) on b.HInterID=ou.HProcExchInterID and b.HEntryID=ou.HProcExchEntryID
+where b.HInterID={HProcExchInterID} and b.HProcID={HProcID}
+group by b.HInterID,b.HEntryID,b.HQty", "Sc_ProcessExchangeBill_Out");
+
+ if (double.Parse(ds1.Tables[0].Rows[0][0].ToString()) < 0)
+ {
+ if (!flag_1)
+ {
+ MessageBox.Show("娴佽浆鍗�:" + HProcExchBillNo + ",鍑虹珯鏁伴噺瓒呰繃娴佽浆鍗℃暟閲�!");
+ }
+ DBHelper.CustomWriteLog("娴佽浆鍗�:" + HProcExchBillNo + ",鍑虹珯鏁伴噺瓒呰繃娴佽浆鍗℃暟閲�!", DateTime.Now.ToString("yyyy-MM-dd"));
+ flag_2 = true;
+ return false;
+ }
+
+ //澧炲姞浜х嚎缁勮杩芥函鍗�
+ DataSet dataSet = oCN.RunProcReturn("exec h_p_Gy_BarCodeBillBomList '" + HProcExchBillNo + "'," + HProcID, "h_p_Gy_BarCodeBillBomList");
+ if (dataSet.Tables[0].Rows.Count > 0)
+ {
+ //鍒ら厤浠舵暟閲忔槸鍚︾瓑浜�0
+ for (int i = 0; i < dataSet.Tables[0].Rows.Count; i++)
+ {
+ double SYHQty = double.Parse(dataSet.Tables[0].Rows[i]["閰嶄欢鏁伴噺"].ToString());
+ string HMaterNamePJ = dataSet.Tables[0].Rows[i]["閰嶄欢浠g爜"].ToString();
+ string HMaterBarCode = dataSet.Tables[0].Rows[i]["HBarCode"].ToString();
+ if (SYHQty == 0)
+ {
+ if (!flag_1)
+ {
+ MessageBox.Show("娴佽浆鍗�:" + HProcExchBillNo + ",閰嶄欢鏉$爜:" + HMaterBarCode + ",閰嶄欢浠g爜:" + HMaterNamePJ + ",鏁伴噺涓�0!");
+ }
+ DBHelper.CustomWriteLog("娴佽浆鍗�:" + HProcExchBillNo + ",閰嶄欢鏉$爜:" + HMaterBarCode + ",閰嶄欢浠g爜:" + HMaterNamePJ + ",鏁伴噺涓�0!", DateTime.Now.ToString("yyyy-MM-dd"));
+ flag_2 = true;
+ return false;
+ }
+ }
+ }
+ flag_2 = false;
+ return true;
+ }
+
//鐢熶骇璧勬簮鍥炶溅
private void HSouce_KeyDown(object sender, KeyEventArgs e)
{
--
Gitblit v1.9.1