From b9e07918f687f7b51e165d659c4a1595916406ff Mon Sep 17 00:00:00 2001
From: zrg <z1873@LAPTOP-EAVL132E>
Date: 星期二, 24 三月 2026 12:26:20 +0800
Subject: [PATCH] 斯末尔单品过站优化,增加自动开工功能,自动完工,华舟数采优化
---
WFormSynchronizeData_SMR/WFormReadData_SMR/ReadCSV_New.cs | 236 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-----
1 files changed, 216 insertions(+), 20 deletions(-)
diff --git a/WFormSynchronizeData_SMR/WFormReadData_SMR/ReadCSV_New.cs b/WFormSynchronizeData_SMR/WFormReadData_SMR/ReadCSV_New.cs
index 83813fb..3da4ac0 100644
--- a/WFormSynchronizeData_SMR/WFormReadData_SMR/ReadCSV_New.cs
+++ b/WFormSynchronizeData_SMR/WFormReadData_SMR/ReadCSV_New.cs
@@ -20,6 +20,21 @@
private List<CodeNameItem> empHistoryList = new List<CodeNameItem>();
private List<CodeNameItem> sourceHistoryList = new List<CodeNameItem>();
+ public static int num = 0;
+ public static DateTime time = DateTime.Now.AddMinutes(-5);
+
+ public static string AllProcessExchange = "-1";
+ public static string AllProcessExchangeHProcExchBillNo = "";
+ public static string AllProcessExchangeHProcExchInterID = "";
+ public static string AllSNBarcodeProcCtrl = "";
+ public static string AllHProcID = "0";
+ public static string AllHProName = "";
+ public static double AllHQty = 0;
+ public static string AllBeginWork = "-1";
+ public static Dictionary<string, double> RemainingQtyCache = new Dictionary<string, double>(); // 缂撳瓨姣忎釜娴佽浆鍗�+宸ュ簭鐨勫墿浣欐暟閲�
+ public static Dictionary<string, DateTime> CacheUpdateTime = new Dictionary<string, DateTime>(); // 璁板綍姣忔缂撳瓨鏇存柊鐨勬椂闂达紝鐢ㄤ簬鍒ゆ柇鏄惁闇�瑕佸埛鏂�
+ public string CurrentActiveKey = "";//缂撳瓨閿紝鐢ㄤ簬鍒ゆ柇娴佽浆鍗℃槸鍚﹀垏鎹�
+
public ReadCSV_New()
{
InitializeComponent();
@@ -105,8 +120,7 @@
}
}
- public static int num = 0;
- public static DateTime time = DateTime.Now.AddMinutes(-5);
+
//缁勮宸ュ簭CSV 杩囩珯璇诲彇 鏂扮殑
@@ -381,6 +395,8 @@
DateTime NowTime = DateTime.Parse(item["娴嬭瘯鏃堕棿"].ToString());
string HBadCodeSN = item["搴忓彿"].ToString();
+
+
if (((NowTime >= ActionTime && NowTime < EndTime) || dt.Rows.Count <= 20) && HBadCodeSN != "" && list.Contains(HBadCodeSN) == false)
{
@@ -398,7 +414,7 @@
string HType = "";
int HCount = 1;
- DataSet ds = oCN.RunProcReturn(@"select * from Sb_EquipMentCollection_SN with(nolock) where HBarCode='" + HBarCode + "' and HProcNumber='" + HProcNumber + "'", "Sb_EquipMentCollection_SN");
+ DataSet ds = oCN.RunProcReturn(@"select * from Sb_EquipMentCollection_SN with(nolock) where HBarCode='" + HBarCode + "' and HProcNumber='" + HProcNumber + "'", "Sb_EquipMentCollection_SN");
if (ds.Tables[0].Rows.Count == 0)
{
if (Get_AllowLoadData(HBarCode, HProcNumber, flag_1, out flag_2))
@@ -424,7 +440,7 @@
{
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}',GETDATE(),'{HResult}','{HProcNumber}','{HFlag}')";
- oCN.RunProc(sql1);
+ oCN.RunProc(sql1);
}
}
}
@@ -516,16 +532,7 @@
}
}
- public static string AllProcessExchange = "-1";
- public static string AllProcessExchangeHProcExchBillNo = "";
- public static string AllProcessExchangeHProcExchInterID = "";
- public static string AllSNBarcodeProcCtrl = "";
- public static string AllHProcID = "0";
- public static string AllHProName = "";
- public static double AllHQty = 0;
- public static Dictionary<string, double> RemainingQtyCache = new Dictionary<string, double>(); // 缂撳瓨姣忎釜娴佽浆鍗�+宸ュ簭鐨勫墿浣欐暟閲�
- public static Dictionary<string, DateTime> CacheUpdateTime = new Dictionary<string, DateTime>(); // 璁板綍姣忔缂撳瓨鏇存柊鐨勬椂闂达紝鐢ㄤ簬鍒ゆ柇鏄惁闇�瑕佸埛鏂�
- public string CurrentActiveKey = "";//缂撳瓨閿紝鐢ㄤ簬鍒ゆ柇娴佽浆鍗℃槸鍚﹀垏鎹�
+
//鏍规嵁鏉$爜 鍒ゆ柇鏄惁淇濆瓨
public bool Get_AllowLoadData(string HBarCode, string HProcNumber, bool flag_1, out bool flag_2)
{
@@ -535,7 +542,6 @@
flag_2 = false;
return false;
}
-
//鍒ゆ柇闀垮害鏄惁涓�29浣� 鏃犲皹杞﹂棿
string HProcExchBillNo = "";
string HProcExchInterID = "";
@@ -609,7 +615,22 @@
AllHProcID = ds1.Tables[0].Rows[0]["HItemID"].ToString();
AllHProName = ds1.Tables[0].Rows[0]["HName"].ToString();
}
+ //鍒ゆ柇褰撳墠娴佽浆鍗″搴旂殑宸ュ簭鏁版嵁鏄惁寮�宸�
+ ds1 = oCN.RunProcReturn("select * from Sc_ICMOBillStatus_Tmp where HSourceBillNo='" + AllProcessExchangeHProcExchBillNo + "' and HProcID='" + AllHProcID + "'", "Sc_ICMOBillStatus_Tmp");
+ if (ds1.Tables[0].Rows.Count > 0)
+ {
+ //鐢熶骇鐘舵�佷复鏃惰〃 鐘舵�佸鏋滀负0 閭e氨鏄病寮�宸� 杩涘叆寮�宸ュ崟
+ if (ds1.Tables[0].Rows[0]["HICMOStatus"].ToString() == "0")
+ {
+ bool completeFlag = SaveMESBeginWorkFrom_ZD(ds1.Tables[0].Rows[0]["HBillType"].ToString(), ds1.Tables[0].Rows[0]["HInterID"].ToString(), ds1.Tables[0].Rows[0]["HSourceEntryID"].ToString(), ds1.Tables[0].Rows[0]["HSourceBillNo"].ToString(), this.HEmpCodeName.Text, ds1.Tables[0].Rows[0]["HSourceBillType"].ToString());
+ if (!completeFlag)
+ {
+ MessageBox.Show(new Form { TopMost = true }, "娴佽浆鍗�:" + AllProcessExchangeHProcExchBillNo + ",鑷姩鐢熸垚寮�宸ュ崟澶辫触!");
+ }
+ }
+
+ }
//鏌ヨ娴佽浆鍗℃暟閲�
ds1 = oCN.RunProcReturn(@"SELECT HQty FROM Sc_ProcessExchangeBillSub WITH(NOLOCK) where HInterID=" + HProcExchInterID + " and HProcID=" + AllHProcID, "Sc_ProcessExchangeBillSub");
if (ds1.Tables[0].Rows.Count > 0)
@@ -622,9 +643,7 @@
string HProcID = AllHProcID;
string HProName = AllHProName;
- ////绗竴娆℃祦杞崱+宸ュ簭鍜屽悗闈㈢殑鍋氬姣� 濡傛灉鏄悓涓�涓祦杞崱灏变笉杩涜鍒ゆ柇
- //if ((HProcExchBillNo + HProcNumber) == AllSNBarcodeProcCtrl)
- //{
+
//鍒ゆ柇 褰撳墠宸ュ簭 鏉$爜 鐨勪笂涓�閬撳伐搴忔湁娌℃湁杩囩珯
ds1 = oCN.RunProcReturn("exec h_p_Sc_SNBarcodeProcCtrl_S_New '" + HBarCode + "'," + HProcID, "h_p_Sc_SNBarcodeProcCtrl_S_New");
@@ -654,7 +673,6 @@
flag_2 = true;
return false;
}
- //}
// 鏌ヨ鍑虹珯鏁伴噺鏄惁瓒呰繃娴佽浆鍗℃暟閲�
@@ -753,6 +771,184 @@
return true;
}
+ //鑷姩寮�宸�
+ public bool SaveMESBeginWorkFrom_ZD(string HBillType, string HSourceInterID, string HSourceEntryID, string HSourceBillNo, string user, string HSourceBillType)
+ {
+ try
+ {
+ DataSet ds;
+ ds = oCN.RunProcReturn("exec h_p_JIT_GetInfoByICMOStatusInterID @HSourceInterID='" + HSourceInterID + "',@HSourceEntryID='" + HSourceEntryID + "',@HSourceBillNo='" + HSourceBillNo + "',@HSourceBillType='" + HBillType + "'", "h_p_JIT_GetInfoByICMOStatusInterID");
+ string sExeReturnInfo = "";
+ long HProcID = int.Parse(ds.Tables[0].Rows[0]["HProcID"].ToString());
+ long HMaterID = int.Parse(ds.Tables[0].Rows[0]["HMaterID"].ToString());
+ long HSourceID = int.Parse(ds.Tables[0].Rows[0]["HSourceID"].ToString());
+ string HMainSourceBillNo = ds.Tables[0].Rows[0]["HSourceBillNo"].ToString();
+ long HMainSourceInterID = int.Parse(ds.Tables[0].Rows[0]["HSourceInterID"].ToString());
+ long HMainSourceEntryID = long.Parse(ds.Tables[0].Rows[0]["HSourceEntryID"].ToString());
+ string HMainSourceBillType = HSourceBillType == null ? "" : HSourceBillType;
+ long HDeptID = int.Parse(ds.Tables[0].Rows[0]["HDeptID"].ToString());
+ long HICMOInterID = int.Parse(ds.Tables[0].Rows[0]["HICMOInterID"].ToString());
+ long HICMOEntryID = int.Parse(ds.Tables[0].Rows[0]["HICMOEntryID"].ToString());
+ string HICMOBillNo = ds.Tables[0].Rows[0]["HICMOBillNo"].ToString();
+ long HProcExchInterID = int.Parse(ds.Tables[0].Rows[0]["HProcExchInterID"].ToString());
+ long HProcExchEntryID = int.Parse(ds.Tables[0].Rows[0]["HProcExchEntryID"].ToString());
+ string HProcExchBillNo = ds.Tables[0].Rows[0]["HProcExchBillNo"].ToString();
+ long HWorkShiftID = 0;
+
+ //鑾峰彇鐝
+ DataSet set = oCN.RunProcReturn("exec h_p_Gy_GetWorkShiftInfo '389505','77'", "h_p_Gy_GetWorkShiftInfo");
+ if (set.Tables[0].Rows.Count > 0)
+ {
+ HWorkShiftID = int.Parse(set.Tables[0].Rows[0]["HInterID"].ToString());
+ }
+
+ ds = oCN.RunProcReturn("select * from Gy_Employee where HNumber='" + this.HEmpCode.Text + "'", "Gy_Employee");
+
+ long HGroupID = int.Parse(ds.Tables[0].Rows[0]["HGroupID"].ToString());
+ long HEmpID = int.Parse(ds.Tables[0].Rows[0]["HItemID"].ToString());
+
+ Int64 HInterID = CreateBillID("3787", ref sExeReturnInfo);
+ string HBillNo = CreateBillCode_Prod("3787", ref sExeReturnInfo, true);
+
+ //淇濆瓨鍓�
+ ds = oCN.RunProcReturn("exec h_p_Sc_MESBeginWorkBill_BeforeSaveCtrl " + HInterID.ToString() + "," + HICMOInterID.ToString() + "," + HICMOEntryID.ToString() + ",'" + HICMOBillNo + "'," + 1, "h_p_Sc_MESEndWorkBill_BeforeSaveCtrl");
+ if (ds == null || ds.Tables[0].Rows.Count == 0)
+ {
+ return false;
+ }
+ oCN.RunProc("Insert Into Sc_MESBeginWorkBillMain " +
+ "(HBillType,HBillSubType,HInterID,HBillNo,HBillStatus,HDate,HMaker,HMakeDate" +
+ ",HYear,HPeriod,HRemark" +
+ ",HICMOInterID,HICMOEntryID,HICMOBillNo,HProcPlanInterID,HProcPlanEntryID,HProcPlanBillNo,HProcExchInterID,HProcExchEntryID" +
+ ",HProcExchBillNo,HMaterID,HProcID,HICMOQty,HPlanQty,HBeginWorkTime,HSourceID" +
+ ",HGroupID,HDeptID,HEmpID,HBarCode,HAddr,HBarCodeMaker,HBarCodeMakeDate" +
+ ",HSourceInterID_Main,HSourceEntryID_Main,HSourceBillNo_Main,HSourceBillType_Main" +
+ ",HMainSourceInterID,HMainSourceEntryID,HMainSourceBillNo,HMainSourceBillType" +
+ ",HRunStatus,HSourceBeginQty,HWorkShiftID,HPeopleSum" +
+ ") " +
+ " values('3787','3787'," + HInterID + ",'" + HBillNo + "',1,getdate(),'" + user + "',getdate()" +
+ ",Year(getdate()),Month(getdate()),'鑷姩寮�宸�'" +
+ "," + HICMOInterID + ",'" + HICMOEntryID + "','" + HICMOBillNo + "',0,0,''," + HProcExchInterID + "," + HProcExchEntryID +
+ ",'" + HProcExchBillNo + "'," + HMaterID + "," + HProcID + ",0,0,getdate()," + HSourceID +
+ "," + HGroupID + "," + HDeptID + "," + HEmpID + ",'','','',getdate()" +
+ "," + HMainSourceInterID + "," + HMainSourceEntryID + ",'" + HMainSourceBillNo + "','" + HMainSourceBillType + "'" +
+ "," + HMainSourceInterID + "," + HMainSourceEntryID + ",'" + HMainSourceBillNo + "','" + HMainSourceBillType + "'" +
+ ",0,0,'" + HWorkShiftID + "',1) ");
+
+
+ oCN.RunProc(" Update Sc_MESBeginWorkBillMain set HBillStatus='2',HChecker='" + user + "',HCheckDate=getdate() Where HInterID=" + HInterID.ToString());
+ //鏍规嵁寮�宸ュ崟鍐呯爜 鍙栧埌鐢熶骇鐘舵�佷复鏃惰〃涓诲唴鐮侊紝鐒跺悗鏇存柊鐢熶骇鐘舵�佷复鏃惰〃鐘舵�佷负锛氬緟鐢熶骇 浠诲姟鍗曠姸鎬�(0寰呯敓浜э紝1鐢熶骇涓紝2鎸傝捣锛�3宸插畬宸�)
+ oCN.RunProc("exec h_p_JIT_MESBeginWorkBill_BeginWork @HInterId=" + HInterID + ",@flag='寮�宸�'");
+
+ //淇濆瓨鍚�
+ ds = oCN.RunProcReturn("exec h_p_Sc_MESBeginWorkBill_AfterSaveCtrl " + HInterID.ToString() + "," + HICMOInterID.ToString() + "," + HICMOEntryID.ToString() + ",'" + HICMOBillNo + "'," + 1, "h_p_Sc_MESBeginWorkBill_AfterSaveCtrl");
+ if (ds == null || ds.Tables[0].Rows.Count == 0)
+ {
+ return false;
+ }
+ return true;
+
+ }
+ catch (Exception e)
+ {
+ return false;
+ }
+ }
+
+ #region 鑾峰彇 鍐呯爜 鍗曟嵁鍙�
+ public static Int64 CreateBillID(string BillCode, ref string sReturn)
+ {
+ string BillType = "";
+ DataSet Ds;
+ DBHelper oCn = new DBHelper();
+ Int64 lID;
+ Ds = oCn.RunProcReturn("select * from Gy_BillNumber with (nolock) where BillCode='" + BillCode.Trim() + "'", "Gy_BillNumber");
+ if (Ds.Tables[0].Rows.Count != 0)
+ {
+ lID = isLong(Ds.Tables[0].Rows[0]["IDNow"].ToString());
+ BillType = Ds.Tables[0].Rows[0]["BillType"].ToString().Trim();
+ }
+ else
+ {
+ lID = 0;
+ }
+ //鍚岀被鍨嬪崟鎹� 鑷1
+ if (BillType.Trim() != "")
+ {
+ oCn.RunProc("update Gy_BillNumber set IDNow=IDNow+1 where BillType='" + BillType.Trim() + "'");
+ }
+ oCn.CnClose();
+ oCn.CnDispose();
+ oCn = null;
+ Ds = null;
+ return lID;
+ }
+
+ public static string CreateBillCode_Prod(string BillCode, ref string sReturn, bool Add)
+ {
+ try
+ {
+ string BillType = "";
+ DataSet Ds;
+ DBHelper oCn = new DBHelper();
+ string sBIllNO;
+ Ds = oCn.RunProcReturn("exec h_p_Xt_GetMaxBillNo '" + BillCode + "'", "h_p_Xt_GetMaxBillNo");
+ if (Ds == null || Ds.Tables[0].Rows.Count == 0)
+ {
+ sBIllNO = "ERROR";
+ }
+ else
+ {
+ sBIllNO = isStrNull(Ds.Tables[0].Rows[0]["HBillNo"]);
+ }
+ oCn.CnClose();
+ oCn.CnDispose();
+ oCn = null;
+ Ds = null;
+ return sBIllNO;
+ }
+ catch (Exception e)
+ {
+ return "ERROR";
+ }
+ }
+ #endregion
+
+ #region 杈呭姪鏂规硶
+ //鍒ゆ柇鏄惁鏄疘NT64
+ public static Int64 isLong(object message)
+ {
+ try
+ {
+ return Convert.ToInt64(message);
+ }
+ catch (Exception e)
+ {
+ return 0;
+ }
+ }
+ //鍒ゆ柇鏄惁NULL
+ public static string isStrNull(object message)
+ {
+ try
+ {
+ if (message == null)
+ {
+ return "";
+ }
+ else
+ {
+ return message.ToString().Trim();
+ }
+ }
+ catch (Exception e)
+ {
+ return "";
+ }
+ }
+ #endregion
+
+ //鍏抽棴
private void ReadCSV_FormClosing(object sender, FormClosingEventArgs e)
{
if (num == 1)
@@ -776,4 +972,4 @@
HistoryConfigHelper.SaveSources(sourceHistoryList, lastSrcCode);
}
}
-}
+}
\ No newline at end of file
--
Gitblit v1.9.1