From 977616d74f913ae5ce1e14f8cfde3b7f4d5a21a2 Mon Sep 17 00:00:00 2001
From: zrg <z1873@LAPTOP-EAVL132E>
Date: 星期四, 26 六月 2025 17:48:23 +0800
Subject: [PATCH] 新增九菱设备采集插件,更改点胶称重下拉框名字不对问题
---
WFormSynchronizeData_SMR/WFormSynchronizeData_SMR/Form1.cs | 455 ++++++++++++++++++++++++++++++++++++++++++--------------
1 files changed, 338 insertions(+), 117 deletions(-)
diff --git a/WFormSynchronizeData_SMR/WFormSynchronizeData_SMR/Form1.cs b/WFormSynchronizeData_SMR/WFormSynchronizeData_SMR/Form1.cs
index 9409baf..ef473c4 100644
--- a/WFormSynchronizeData_SMR/WFormSynchronizeData_SMR/Form1.cs
+++ b/WFormSynchronizeData_SMR/WFormSynchronizeData_SMR/Form1.cs
@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
+using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Linq;
@@ -24,8 +25,13 @@
//璇诲彇鏁版嵁
private void btnReadData_Click(object sender, EventArgs e)
{
-
- DataTable list = oCN.RunProcReturn("select * from Sb_EquipMentCollection_SN WITH(NOLOCK) where HFlag=0 order by HCreateTime", "Sb_EquipMentCollection_SN").Tables[0];
+ Stopwatch timer = new Stopwatch();
+ timer.Start();
+
+ CustomWriteLog("1.璁℃椂鍣ㄥ紑濮�:"+timer.Elapsed, DateTime.Now.ToString("yyyy-MM-dd"));
+
+ //鏍规嵁鏃堕棿姝e簭鎺掑簭鑾峰彇鍓�150鏉℃暟鎹�
+ DataTable list = oCN.RunProcReturn("select top 150 HResult,HBarCode,HCreateTime from Sb_EquipMentCollection_SN WITH(NOLOCK) where HFlag=0 order by HCreateTime", "Sb_EquipMentCollection_SN").Tables[0];
//寰幆闆嗗悎
for (int i = 0; i < list.Rows.Count; i++)
@@ -33,9 +39,10 @@
bool flag = false;
string HResult = list.Rows[i]["HResult"].ToString();
string HBadCodeSN = list.Rows[i]["HBarCode"].ToString();
+ string HCreateTime = list.Rows[i]["HCreateTime"].ToString();
//寮�濮嬩簨鍔�
oCN.BeginTran();
-
+ CustomWriteLog("2.寰幆寮�濮�:" + timer.Elapsed, DateTime.Now.ToString("yyyy-MM-dd"));
if (HResult == "OK")
{
flag=HResultOK(list.Rows[i]);
@@ -45,23 +52,36 @@
flag = HResultNG(list.Rows[i]);
}
+ CustomWriteLog("2-1.寰幆缁撴潫:" + timer.Elapsed, DateTime.Now.ToString("yyyy-MM-dd"));
if (flag) {
- oCN.RunProc("update Sb_EquipMentCollection_SN set HFlag=1 where HBarCode='" + HBadCodeSN + "'");
+ oCN.RunProc("update Sb_EquipMentCollection_SN set HFlag=1 where HBarCode='" + HBadCodeSN + "' and HCreateTime='"+ HCreateTime + "'");
//缁撴潫浜嬪姟
oCN.Commit();
}
}
+ CustomWriteLog("3.缁撴潫璁℃椂:" + timer.Elapsed, DateTime.Now.ToString("yyyy-MM-dd"));
+ timer.Stop();//缁撴潫璁℃椂
}
public bool HResultOK(DataRow dic)
{
try
{
+ Stopwatch timer = new Stopwatch();
+ timer.Start();
+
+ CustomWriteLog("2.1.寮�濮媜k:" + timer.Elapsed, DateTime.Now.ToString("yyyy-MM-dd"));
+
bool flag = false;
string HBadCodeSN = dic["HBarCode"].ToString();
- HBadCodeSN = TM_ZH(HBadCodeSN);
+ //HBadCodeSN = TM_ZH(HBadCodeSN);
+ //鍒ゆ柇褰撳ぉ鏉$爜鏈夋病鏈夊瓨鍌ㄥ湪鏉$爜琛ㄩ噷 濡傛灉娌℃湁 鍒欎繚瀛樻暟鎹� 骞惰繑鍥�0
+ //濡傛灉宸插瓨鍦� 鍒欒繑鍥� 1
+ //濡傛灉鏉′欢涓嶆弧瓒崇殑 鍒欒繑鍥� 2
int num = SNHBardCodeList(HBadCodeSN);
+
+ CustomWriteLog("2.2.鏉$爜鐢熸垚:" + timer.Elapsed, DateTime.Now.ToString("yyyy-MM-dd"));
if (num == 0)
{
@@ -70,20 +90,30 @@
else if (num == 1)
{
//鍒ゆ柇杩欎釜鏉$爜涔嬪墠鐨勭姸鎬佹槸鍚︿负NG
- DataSet ds = oCN.RunProcReturn(@"select * from Sb_EquipMentCollection_SN WITH(NOLOCK) where HBarCode='" + HBadCodeSN + "' and HCreateTime<'" + dic["HCreateTime"].ToString() + "' and HResult='NG' and HProcNumber='" + dic["HProcNumber"].ToString() + "'", "Sb_EquipMentCollection_SN");
+ DataSet ds = oCN.RunProcReturn(@"select * from Sb_EquipMentCollection_SN WITH(NOLOCK) where HBarCode='" + HBadCodeSN + "' and HCreateTime<'" + dic["HCreateTime"].ToString() + "' and HResult='NG'", "Sb_EquipMentCollection_SN");
- DataSet ds1 = oCN.RunProcReturn(@"select a.HSourceID,a.HProcID,* from Sc_StationOutBillMain a WITH(NOLOCK)
-inner join Sc_StationOutBillSub_SN sn WITH(NOLOCK) on a.HInterID=sn.HInterID
-left join Gy_Source s WITH(NOLOCK) on a.HSourceID=s.HItemID
-left join Gy_Process p WITH(NOLOCK) on a.HProcID=p.HItemID
-where p.HNumber='" + dic["HProcNumber"].ToString() + "' and sn.HBarCode='" + HBadCodeSN + "'", "Sc_StationOutBillSub_SN");
+ //鏌ヨ鍑虹珯鍗曟槸鍚﹀寘鍚潯鐮�
+ // DataSet ds1 = oCN.RunProcReturn(@"select a.HSourceID,a.HProcID,* from Sc_StationOutBillMain a WITH(NOLOCK)
+ //inner join Sc_StationOutBillSub_SN sn WITH(NOLOCK) on a.HInterID=sn.HInterID
+ //left join Gy_Source s WITH(NOLOCK) on a.HSourceID=s.HItemID
+ //left join Gy_Process p WITH(NOLOCK) on a.HProcID=p.HItemID
+ //where p.HNumber='" + dic["HProcNumber"].ToString() + "' and sn.HBarCode='" + HBadCodeSN + "'", "Sc_StationOutBillSub_SN");
+ //鏌ヨ杩欎釜宸ュ簭瀵瑰簲鐨勬潯鐮� 鍑虹珯鍗曟槸鍚﹀凡缁忓瓨鍦�
+ DataSet ds1 = oCN.RunProcReturn(@"select a.HProcID from Sc_StationOutBillMain a WITH(NOLOCK)
+ inner join Sc_StationOutBillSub_SN sn WITH(NOLOCK) on a.HInterID=sn.HInterID
+ left join Gy_Process p WITH(NOLOCK) on a.HProcID=p.HItemID
+ where p.HNumber='" + dic["HProcNumber"].ToString() + "' and sn.HBarCode='" + HBadCodeSN + "'", "Sc_StationOutBillSub_SN");
+
+ //鍒ゆ柇鏉$爜涔嬪墠鏄惁涓篘G 鍚屾椂 鍒ゆ柇鍑虹珯鍗曠殑鏉$爜鏁版嵁鏄笉瀛樺湪
if (ds.Tables[0].Rows.Count > 0 && ds1.Tables[0].Rows.Count == 0)
{
+ //杩斾慨濂界殑鏉$爜杩涜閲嶆柊杩囩珯淇濆瓨
flag = getOKOutBillAdd(dic, HBadCodeSN, "OK");
}
else
{
+ //鍑虹珯鍗曠殑鏉$爜鏁版嵁鏄笉瀛樺湪 鍒欐柊澧�
if (ds1.Tables[0].Rows.Count > 0)
{
flag = true;
@@ -99,6 +129,9 @@
{
flag = false;
}
+
+ CustomWriteLog("2.5.缁撴潫璁℃椂:" + timer.Elapsed, DateTime.Now.ToString("yyyy-MM-dd"));
+ timer.Stop();//缁撴潫璁℃椂
return flag;
}
@@ -118,7 +151,10 @@
bool flag = false;
int num = 0;
string HBadCodeSN = dic["HBarCode"].ToString();
- HBadCodeSN = TM_ZH(HBadCodeSN);
+ //HBadCodeSN = TM_ZH(HBadCodeSN);
+ //鍒ゆ柇褰撳ぉ鏉$爜鏈夋病鏈夊瓨鍌ㄥ湪鏉$爜琛ㄩ噷 濡傛灉娌℃湁 鍒欎繚瀛樻暟鎹� 骞惰繑鍥�0
+ //濡傛灉宸插瓨鍦� 鍒欒繑鍥� 1
+ //濡傛灉鏉′欢涓嶆弧瓒崇殑 鍒欒繑鍥� 2
num = SNHBardCodeList(HBadCodeSN);
if (num == 0 || num == 1)
@@ -154,32 +190,46 @@
{
try
{
+ Stopwatch timer = new Stopwatch();
+ timer.Start();
+ string HMakers = ""; //鍒跺崟浜�
+ CustomWriteLog("2.1.1.鍑虹珯鍗曟柊澧炲紑濮�:" + timer.Elapsed, DateTime.Now.ToString("yyyy-MM-dd"));
//鑾峰彇缁戝畾娴佽浆鍗�
- DataSet ds = oCN.RunProcReturn(@"select * from Gy_BarCodeBill WITH(NOLOCK) where HBarCode='" + HBadCodeSN + "'", "Gy_BarCodeBill");
+ DataSet ds = oCN.RunProcReturn(@"select HSourceBillNo, from Gy_BarCodeBill WITH(NOLOCK) where HBarCode='" + HBadCodeSN + "'", "Gy_BarCodeBill");
string HProcExchBillNo = ds.Tables[0].Rows[0]["HSourceBillNo"].ToString();
string HProcNumber = dic["HProcNumber"].ToString();
- ds = oCN.RunProcReturn("select * from Gy_Source WITH(NOLOCK) where HNumber='" + dic["HSourceCode"].ToString() + "' ", "Gy_Source");
+ CustomWriteLog("2.1.2.缁戝畾娴佽浆鍗�:"+ HProcNumber+"----" + timer.Elapsed, DateTime.Now.ToString("yyyy-MM-dd"));
+
+ //鏌ヨ鐢熶骇璧勬簮
+ ds = oCN.RunProcReturn("select HItemID from Gy_Source WITH(NOLOCK) where HNumber='" + dic["HSourceCode"].ToString() + "' ", "Gy_Source");
long HSourceID = 0;
if (ds.Tables[0].Rows.Count != 0)
{
HSourceID = long.Parse(ds.Tables[0].Rows[0]["HItemID"].ToString());//鐢熶骇璧勬簮ID
}
+ CustomWriteLog("2.1.3.鑾峰彇鐢熶骇璧勬簮:" + HProcNumber + "----" + timer.Elapsed, DateTime.Now.ToString("yyyy-MM-dd"));
+
//鏌ヨ鑱屽憳
- ds = oCN.RunProcReturn("select * from Gy_Employee WITH(NOLOCK) where HNumber='" + dic["HEmpCode"].ToString() + "' ", "Gy_Employee");
+ ds = oCN.RunProcReturn("select HItemID,HName from Gy_Employee WITH(NOLOCK) where HNumber='" + dic["HEmpCode"].ToString() + "' ", "Gy_Employee");
long HEmpIDs = 0;
+ string HEmpName = "";
if (ds.Tables[0].Rows.Count != 0)
{
HEmpIDs = long.Parse(ds.Tables[0].Rows[0]["HItemID"].ToString());//鑱屽憳ID
+ HEmpName = ds.Tables[0].Rows[0]["HName"].ToString();
+ HMakers = ds.Tables[0].Rows[0]["HName"].ToString();
}
+
+ CustomWriteLog("2.1.4.鏌ヨ鑱屽憳淇℃伅:" + HProcNumber + "----" + timer.Elapsed, DateTime.Now.ToString("yyyy-MM-dd"));
long HDeptID = 0;
long HPRDOrgIDs = 0;
string sReturn = "";
if (GetSingleSystemParameter("WMS_CampanyName", ref sReturn) == "鏉窞鏂帿灏�")
{
- HDeptID = 389499;
+ HDeptID = 389505;
HPRDOrgIDs = 100199;
}
else {
@@ -192,20 +242,24 @@
HDeptID = 0;
}
-
+ CustomWriteLog("2.1.5.鑾峰彇瀹㈡埛淇℃伅:" + HProcNumber + "----" + timer.Elapsed, DateTime.Now.ToString("yyyy-MM-dd"));
- ds = oCN.RunProcReturn(@"select b.HProcNo,b.HProcID,a.HMaterID,a.HQty,a.HInterID,HEntryID,a.HICMOInterID,a.HICMOEntryID,a.HICMOBillNo 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");
+
+ //鏍规嵁娴佽浆鍗″拰宸ュ簭 鏌ヨ鍑虹珯鍗曢渶瑕佷繚瀛樼殑淇℃伅
+ ds = oCN.RunProcReturn(@"select a.HWorkShopID,b.HProcNo,b.HProcID,a.HMaterID,a.HQty,a.HInterID,HEntryID,a.HICMOInterID,a.HICMOEntryID,a.HICMOBillNo,b.HCenterID 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");
+
+ CustomWriteLog("2.1.6.鏌ヨ娴佽浆鍗′俊鎭�:" + HProcNumber + "----" + timer.Elapsed, DateTime.Now.ToString("yyyy-MM-dd"));
string sExeReturnInfo = "";
long HMainInterID = 0;
string BillType = "3791";
string HBillSubType = "3791";
-
+ string HWorkShopID= ds.Tables[0].Rows[0]["HWorkShopID"].ToString();
int HBillStatus = 1;
- string HMaker = "";//鍒跺崟浜�
+ string HMaker = HEmpName;//鍒跺崟浜�
string HMouldNum = "";//妯$┐鍙�
int HYear = DateTime.Now.Year;
double HPeriod = DateTime.Now.Month;
@@ -246,7 +300,7 @@
double HPrice = 0;
double HMoney = 0;
double HBadCount = 0;//涓嶈壇鏁伴噺
- long HCenterID = 0;//宸ヤ綔涓績ID
+ long HCenterID = long.Parse(ds.Tables[0].Rows[0]["HCenterID"].ToString());//宸ヤ綔涓績ID
string HProcNo = ds.Tables[0].Rows[0]["HProcNo"].ToString();//娴佹按鍙�
string HOrderProcNO = "";//璁㈠崟璺熻釜鍙�
string HSourceNameList = "";//璁惧娓呭崟
@@ -266,13 +320,42 @@
int HTemporaryAreaID = 0;//鏆傛斁鍖�
long HInterID = 0;
string HBillNo = "";
+ int HShiftsID = 0;
+
+ CustomWriteLog("2.1.7缁欏瓧娈佃祴鍊� :" + HProcNumber + "----" + timer.Elapsed, DateTime.Now.ToString("yyyy-MM-dd"));
+
+ //鑾峰彇鐝
+ DataSet set= oCN.RunProcReturn("exec h_p_Gy_GetWorkShiftInfo " + HWorkShopID + "," + HCenterID, "h_p_Gy_GetWorkShiftInfo");
+ if (set.Tables[0].Rows.Count > 0) {
+ HShiftsID = int.Parse(set.Tables[0].Rows[0]["HInterID"].ToString());
+ }
+
+ CustomWriteLog("2.1.8鑾峰彇鐝淇℃伅 :" + HProcNumber + "----" + timer.Elapsed, DateTime.Now.ToString("yyyy-MM-dd"));
+
+ //ds = oCN.RunProcReturn("exec h_p_Sc_SNBarcodeProcCtrl_S '" + HBadCodeSN + "'," + HProcID, "h_v_Gy_QualifiedRecordsList");
+ //if (ds.Tables[0].Rows.Count == 0)
+ //{
+ // oCN.RollBack();
+ // CustomWriteLog("鏉$爜:" + HBadCodeSN + "宸ュ簭:" + HProcID + ",宸ュ簭鎺у埗鏌ユ棤鏁版嵁!", DateTime.Now.ToString("yyyy-MM-dd"));
+ // return false;
+ //}
+ //else if (ds.Tables[0].Rows[0]["HBack"].ToString() == "2")
+ //{
+ // oCN.RollBack();
+ // CustomWriteLog("鏉$爜:" + HBadCodeSN + "宸ュ簭:" + HProcID + "," + ds.Tables[0].Rows[0]["HBackRemark"].ToString() + "!", DateTime.Now.ToString("yyyy-MM-dd"));
+ // return false;
+ //}
//鍒ゆ柇褰撳墠娴佽浆鍗$殑鍑虹珯鍗� 鏄惁鏈夋暟鎹�
- ds = oCN.RunProcReturn(@"select * from Sc_StationOutBillMain a WITH(NOLOCK)
-left join Gy_Process p WITH(NOLOCK) on a.HProcID=p.HItemID
-where HProcExchBillNo='" + HProcExchBillNo + "' and p.HNumber='" + HProcNumber + "' and CONVERT(varchar(10),HDate,20) ='" + DateTime.Now.ToString("yyyy-MM-dd") + "'", "Sc_StationOutBillMain");
+ ds = oCN.RunProcReturn(@"select HInterID,HBillNo from Sc_StationOutBillMain a WITH(NOLOCK)
+ left join Gy_Process p WITH(NOLOCK) on a.HProcID=p.HItemID
+ where HProcExchBillNo='" + HProcExchBillNo + "' and p.HNumber='" + HProcNumber + "'" +
+ " and CONVERT(varchar(10),HDate,20) ='" + DateTime.Now.ToString("yyyy-MM-dd") + "'", "Sc_StationOutBillMain");
+ CustomWriteLog("2.1.9鑾峰彇鏄惁鏈夊嚭绔欏崟 :" + HProcNumber + "----" + timer.Elapsed, DateTime.Now.ToString("yyyy-MM-dd"));
+
+ //濡傛灉娌℃湁鍑虹珯鍗曞垯鏂板鍑虹珯鍗�
if (ds.Tables[0].Rows.Count != 0)
{
HInterID = long.Parse(ds.Tables[0].Rows[0]["HInterID"].ToString());
@@ -295,7 +378,7 @@
",HSupID,HQty,HPrice,HMoney,HBadCount,HCenterID,HProcNo,HOrderProcNO,HSourceNameList" +
",HMainSourceInterID,HMainSourceBillNo,HMainSourceBillType,HLastSubProc" +
",HEmpID2,HEmpID3,HEmpID4,HEmpID5,HDSQty,HChongQty,HPriceRate,HWorkTimes,HQCCheckID,HMainInterID,HPRDOrgID" +
- ",HmaterOutqty,HProcPriceRate,HTemporaryAreaID" +
+ ",HmaterOutqty,HProcPriceRate,HTemporaryAreaID,HShiftsID" +
") " +
" values('" + BillType + "','" + HBillSubType + "'," + HInterID + ",'" + HBillNo + "'," + HBillStatus + ",getdate(),'" + HMaker + "',getdate(),'" + HMouldNum + "'" +
"," + HYear + "," + HPeriod + ",'" + HRemark + "','" + HSourceName + "'," + HPieceQty + "," + HWasterQty + "," + HPlanPieceQty + "," + HBadPNL +
@@ -305,24 +388,59 @@
"," + HSupID + "," + HQty + "," + HPrice + "," + HMoney + "," + HBadCount + "," + HCenterID + "," + HProcNo + ",'" + HOrderProcNO + "'" + ",'" + HSourceNameList + "'" +
"," + HMainSourceInterID + ",'" + HMainSourceBillNo + "','" + HMainSourceBillType + "'," + Convert.ToString(HLastSubProc ? 1 : 0) +
"," + HEmpID2 + "," + HEmpID3 + "," + HEmpID4 + "," + HEmpID5 + "," + HDSQty + "," + HChongQty + "," + HPriceRate + "," + HWorkTimes + "," + HQCCheckID + "," + HMainInterID + "," + HPRDOrgID +
- "," + HmaterOutqty + "," + HProcPriceRate + "," + HTemporaryAreaID + ") ");
+ "," + HmaterOutqty + "," + HProcPriceRate + "," + HTemporaryAreaID + ","+ HShiftsID + ") ");
}
+
+
+ CustomWriteLog("2.1.10 鍑虹珯鍗曟柊澧� :" + HProcNumber + "----" + timer.Elapsed, DateTime.Now.ToString("yyyy-MM-dd"));
if (HResult == "OK")
{
- ds = oCN.RunProcReturn("select * from Sc_StationOutBillSub_SN WITH(NOLOCK) where HInterID='" + HInterID + "' order by HEntryID desc", "Sc_StationOutBillSub_SN");
+ CustomWriteLog("2.1.11 鏉$爜鍙嶅啓 :" + HProcNumber + "----" + timer.Elapsed, DateTime.Now.ToString("yyyy-MM-dd"));
+
+ //鏌ヨ 鍑虹珯鍗曞瓙琛� 鏉$爜琛ㄧ殑鏁版嵁
+ ds = oCN.RunProcReturn("select HEntryID, from Sc_StationOutBillSub_SN WITH(NOLOCK) where HInterID='" + HInterID + "' order by HEntryID desc", "Sc_StationOutBillSub_SN");
string HMakeTime = dic["HCreateTime"].ToString();
oCN.RunProc($@"insert into Sc_StationOutBillSub_SN(HInterID,HBillNo_bak,HEntryID,HBarCode,HBarCodeQty,HMakeTime,HRemark,HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HRelationQty,HRelationMoney)
-values({ HInterID}, '{ HBillNo}', {(ds.Tables[0].Rows.Count == 0 ? 1 : int.Parse(ds.Tables[0].Rows[0]["HEntryID"].ToString()) + 1)}, '{HBadCodeSN}', 1, '"+ HMakeTime + "', '', " + HProcExchInterID + "," + HProcExchEntryID + ", '" + HProcExchBillNo + "', '', 0, 0)");
+ values({ HInterID}, '{ HBillNo}', {(ds.Tables[0].Rows.Count == 0 ? 1 : int.Parse(ds.Tables[0].Rows[0]["HEntryID"].ToString()) + 1)}, '{HBadCodeSN}', 1, '"+ HMakeTime + "', '', " + HProcExchInterID + "," + HProcExchEntryID + ", '" + HProcExchBillNo + "', '', 0, 0)");
+ CustomWriteLog("鏉$爜:" + HBadCodeSN + "宸ュ簭:" + HProcNumber + ",鍑虹珯鏃堕棿:" + HMakeTime, "TM" + DateTime.Now.ToString("yyyy-MM-dd"));
//鍙嶅啓宸ュ簭鍑虹珯鍗曠殑鍚堟牸鏁伴噺
oCN.RunProc("update Sc_StationOutBillMain set HQty+=1 where HInterID='" + HInterID + "'");
+ CustomWriteLog("鍙嶅啓鍚堟牸鏁伴噺!鏉$爜:" + HBadCodeSN + ",宸ュ簭:" + HProcNumber + ",鍑虹珯鍗旾D" + HInterID, DateTime.Now.ToString("yyyy-MM-dd"));
+ CustomWriteLog("2.1.12 鏉$爜鍙嶅啓 :" + HProcNumber + "----" + timer.Elapsed, DateTime.Now.ToString("yyyy-MM-dd"));
}
else if (HResult == "NG")
{
- //鍙嶅啓宸ュ簭鍑虹珯鍗曠殑涓嶈壇鏁伴噺
- oCN.RunProc("update Sc_StationOutBillMain set HBadCount+=1 where HInterID='" + HInterID + "'");
+ CustomWriteLog("2.1.13 涓嶅悎鏍煎弽鍐� :" + HProcNumber + "----" + timer.Elapsed, DateTime.Now.ToString("yyyy-MM-dd"));
+ //閫氳繃鏉$爜鏌ヨ鐢熶骇璐ㄩ噺姹囨姤鍗曟暟鎹�
+ ds = oCN.RunProcReturn("select HMakeDate from Sc_QualityReportBillSub WITH(NOLOCK) where HBarCode='" + HBadCodeSN + "' order by HMakeDate desc", "Sc_QualityReportBillSub");
+
+ if (ds.Tables[0].Rows.Count > 0) {
+ string HBadDate = ds.Tables[0].Rows[0]["HMakeDate"].ToString();
+ //閫氳繃鏉$爜鏌ヨ杩斾慨璁板綍鍗曠殑鏁版嵁
+ ds = oCN.RunProcReturn("select HMakeDate from Sc_SourceLineRepairBillMain WITH(NOLOCK) where HBarCode='" + HBadCodeSN + "' order by HMakeDate desc", "Sc_SourceLineRepairBillMain");
+
+ if (ds.Tables[0].Rows.Count > 0) {
+ string HRepairDate = ds.Tables[0].Rows[0]["HMakeDate"].ToString();
+ //鍒ゆ柇 鐢熶骇璐ㄩ噺姹囨姤鍗曠殑鍒涘缓鏃堕棿 鏄惁 灏忎簬 杩斾慨璁板綍鐨勫垱寤烘椂闂�
+ //姝e父鎯呭喌鏄� 鍏堢敓鎴愮敓浜ц川閲忔眹鎶ュ崟 鐒跺悗鎵嶄細鍘昏繑淇�
+ //濡傛灉鏉$爜鐢熸垚璐ㄩ噺姹囨姤鍗曠殑鏃堕棿 澶т簬杩斾慨璁板綍鐨勬椂闂� 鍒欒瘉鏄庤繖涓潯鐮佸睘浜庢祴璇曟潯鐮� 姝e父 杩斾慨OK鐨勬墠浼氳繘鍏ヨ繖涓嚭绔欏崟淇濆瓨鏂规硶 涓嶄細杩涘叆NG
+ if (DateTime.Parse(HBadDate) < DateTime.Parse(HRepairDate)) {
+ //鍙嶅啓宸ュ簭鍑虹珯鍗曠殑涓嶈壇鏁伴噺
+ oCN.RunProc("update Sc_StationOutBillMain set HBadCount+=1,HWasterQty_Work+=1 where HInterID='" + HInterID + "'");
+ CustomWriteLog("鍙嶅啓涓嶅悎鏍兼暟閲�!鏉$爜:"+ HBadCodeSN+",宸ュ簭:"+ HProcNumber+",鍑虹珯鍗旾D"+ HInterID, DateTime.Now.ToString("yyyy-MM-dd"));
+ }
+ }
+
+ } else {
+ //鍙嶅啓宸ュ簭鍑虹珯鍗曠殑涓嶈壇鏁伴噺
+ oCN.RunProc("update Sc_StationOutBillMain set HBadCount+=1,HWasterQty_Work+=1 where HInterID='" + HInterID + "'");
+ CustomWriteLog("鍙嶅啓涓嶅悎鏍兼暟閲�!鏉$爜:" + HBadCodeSN + ",宸ュ簭:" + HProcNumber + ",鍑虹珯鍗旾D" + HInterID, DateTime.Now.ToString("yyyy-MM-dd"));
+ }
+
+ CustomWriteLog("2.1.14 涓嶅悎鏍煎弽鍐� :" + HProcNumber + "----" + timer.Elapsed, DateTime.Now.ToString("yyyy-MM-dd"));
}
else
{
@@ -332,17 +450,28 @@
}
//鏌ヨ鍑虹珯鏁伴噺鏄惁瓒呰繃娴佽浆鍗℃暟閲�
- ds = 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.HEntryID={HProcExchEntryID}
-group by b.HInterID,b.HEntryID,b.HQty", "Sc_ProcessExchangeBill_Out");
+ // ds = 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.HEntryID={HProcExchEntryID}
+ //group by b.HInterID,b.HEntryID,b.HQty", "Sc_ProcessExchangeBill_Out");
- if (double.Parse(ds.Tables[0].Rows[0][0].ToString()) < 0)
+ // if (double.Parse(ds.Tables[0].Rows[0][0].ToString()) < 0)
+ // {
+ // oCN.RollBack();
+ // CustomWriteLog("娴佽浆鍗�:"+ HProcExchBillNo + ",鍑虹珯鏁伴噺瓒呰繃娴佽浆鍗℃暟閲�!", DateTime.Now.ToString("yyyy-MM-dd"));
+ // return false;
+ // }
+
+ CustomWriteLog("2.1.15 鍙嶅啓缁撴潫 :" + HProcNumber + "----" + timer.Elapsed, DateTime.Now.ToString("yyyy-MM-dd"));
+
+ //澧炲姞宸ュ簭鍒ゆ柇 鎷嶇収宸ュ簭璺宠繃宸ヨ壓鍙傛暟缁戝畾 涓嶈蛋涓嬮潰娴佺▼锛岀洿鎺ョ粨鏉熸湰娆℃柊澧�
+ if (HProcNumber == "013")
{
- oCN.RollBack();
- CustomWriteLog("娴佽浆鍗�:"+ HProcExchBillNo + ",鍑虹珯鏁伴噺瓒呰繃娴佽浆鍗℃暟閲�!", DateTime.Now.ToString("yyyy-MM-dd"));
- return false;
+ return true;
}
+
+
+ CustomWriteLog("2.1.16 宸ヨ壓鍙傛暟缁戝畾 :" + HProcNumber + "----" + timer.Elapsed, DateTime.Now.ToString("yyyy-MM-dd"));
bool flag = false;
@@ -354,45 +483,60 @@
CustomWriteLog("绯荤粺鍙傛暟淇濆瓨澶辫触,鏉$爜:" + HBadCodeSN, DateTime.Now.ToString("yyyy-MM-dd"));
return false;
}
+ CustomWriteLog("2.1.17 宸ヨ壓鍙傛暟缁戝畾缁撴潫 :" + HProcNumber + "----" + timer.Elapsed, DateTime.Now.ToString("yyyy-MM-dd"));
+
//澧炲姞浜х嚎缁勮杩芥函鍗�
+ //鏌ヨ娴佽浆鍗″拰宸ュ簭瀵瑰簲鐨勯厤浠朵俊鎭� 濡傛灉鏈� 鍒欐煡璇㈤厤浠剁殑鏁伴噺
DataSet dataSet = oCN.RunProcReturn("exec h_p_Gy_BarCodeBillBomList '" + HProcExchBillNo + "'," + HProcID, "h_p_Gy_BarCodeBillBomList");
+
+ CustomWriteLog("2.1.18 浜х嚎缁勮杩芥函鍗曟煡璇� :" + HProcNumber + "----" + timer.Elapsed, DateTime.Now.ToString("yyyy-MM-dd"));
if (dataSet.Tables[0].Rows.Count > 0)
{
+ CustomWriteLog("2.1.19 浜х嚎缁勮杩芥函鍗曟暟閲忓垽鏂� :" + HProcNumber + "----" + timer.Elapsed, DateTime.Now.ToString("yyyy-MM-dd"));
//鍒ら厤浠舵暟閲忔槸鍚︾瓑浜�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) {
oCN.RollBack();
- CustomWriteLog("閰嶄欢浠g爜:" + HMaterNamePJ + ",鏁伴噺涓�0!", DateTime.Now.ToString("yyyy-MM-dd"));
+ CustomWriteLog("閰嶄欢鏉$爜:"+ HMaterBarCode + ",閰嶄欢浠g爜:" + HMaterNamePJ + ",鏁伴噺涓�0!", DateTime.Now.ToString("yyyy-MM-dd"));
return false;
}
}
+ CustomWriteLog("2.1.20 浜х嚎缁勮杩芥函鍗曟暟閲忓垽鏂粨鏉� :" + HProcNumber + "----" + timer.Elapsed, DateTime.Now.ToString("yyyy-MM-dd"));
//鏌ヨ鑱屽憳
- ds = oCN.RunProcReturn("select * from Gy_Employee WITH(NOLOCK) where HNumber='" + dic["HEmpCode"].ToString() + "' ", "Gy_Employee");
- string HMakers = "";
- if (ds.Tables[0].Rows.Count != 0)
- {
- HEmpIDs = long.Parse(ds.Tables[0].Rows[0]["HItemID"].ToString());//鑱屽憳ID
- HMakers = ds.Tables[0].Rows[0]["HName"].ToString();
- }
+ //ds = oCN.RunProcReturn("select HItemID,HName from Gy_Employee WITH(NOLOCK) where HNumber='" + dic["HEmpCode"].ToString() + "' ", "Gy_Employee");
+
+ //if (ds.Tables[0].Rows.Count != 0)
+ //{
+ // HEmpIDs = long.Parse(ds.Tables[0].Rows[0]["HItemID"].ToString());//鑱屽憳ID
+ // HMakers = ds.Tables[0].Rows[0]["HName"].ToString();
+ //}
+
+ CustomWriteLog("2.1.21 鑱屽憳鏌ヨ :" + HProcNumber + "----" + timer.Elapsed, DateTime.Now.ToString("yyyy-MM-dd"));
Int64 HInterID1 = CreateBillID("3727", ref sExeReturnInfo);
string HBillNo1 = CreateBillCode_Prod("3727", ref sExeReturnInfo, true);
//淇濆瓨鐢熶骇缁勮鍗曚富琛�
string sql = $@"Insert Into Sc_AssemblyBillMain(HYear,HPeriod,HBillType,HBillSubType,HInterID,HDate
-,HBillNo,HBillStatus,HMaker,HMakeDate,HMainSourceInterID,HMainSourceEntryID,HMainSourceBillNo
-,HICMOInterID,HICMOBillNo,HBarCode_P,HMaterID,HUnitID,HAssemblyStatus,HProdOrgID)
-values('{DateTime.Now.Year}','{DateTime.Now.Month}','3727','3727',{HInterID1},getdate()
-,'{HBillNo1}','1','{HMakers}',getdate(),{HProcExchInterID},{HProcExchEntryID},'{HProcExchBillNo}'
-,{HICMOInterID},'{HICMOBillNo}','{HBadCodeSN}',{HMaterID},0,'姹囨姤',{HPRDOrgIDs})";
+ ,HBillNo,HBillStatus,HMaker,HMakeDate,HMainSourceInterID,HMainSourceEntryID,HMainSourceBillNo
+ ,HICMOInterID,HICMOBillNo,HBarCode_P,HMaterID,HUnitID,HAssemblyStatus,HProdOrgID)
+ values('{DateTime.Now.Year}','{DateTime.Now.Month}','3727','3727',{HInterID1},getdate()
+ ,'{HBillNo1}','1','{HMakers}',getdate(),{HProcExchInterID},{HProcExchEntryID},'{HProcExchBillNo}'
+ ,{HICMOInterID},'{HICMOBillNo}','{HBadCodeSN}',{HMaterID},0,'姹囨姤',{HPRDOrgIDs})";
+
+ CustomWriteLog("2.1.21 sql璇彞 :" + sql + "----" + timer.Elapsed, DateTime.Now.ToString("yyyy-MM-dd"));
oCN.RunProc(sql);
+
+ CustomWriteLog("2.1.22 淇濆瓨涓昏〃 :" + HProcNumber + "----" + timer.Elapsed, DateTime.Now.ToString("yyyy-MM-dd"));
+
for (int i = 0; i < dataSet.Tables[0].Rows.Count; i++)
{
@@ -400,15 +544,18 @@
string HBarCodes = dataSet.Tables[0].Rows[i]["HBarCode"].ToString();
//瀛愯〃瀛樺偍
string sq2 = $@"Insert Into Sc_AssemblyBillSub(HInterID,HBillNo_bak,HEntryID,HSourceInterID,HSourceEntryID,HSourceBillNo
- ,HSourceBillType,HMaterID,HSourceID,HEquipID,HUnitID,HQty
- ,HGroupID,HWorkerID,HScanDate,HBarCode,HBarCode_P,HSNNumber)
- values({HInterID1},'{HBillNo1}',{(i + 1)},0,0,''
- ,'',{ HMaterIDs},0,0,0,1
- ,0,0,getdate(),'{HBarCodes}','{HBadCodeSN}','') ";
+ ,HSourceBillType,HMaterID,HSourceID,HEquipID,HUnitID,HQty
+ ,HGroupID,HWorkerID,HScanDate,HBarCode,HBarCode_P,HSNNumber)
+ values({HInterID1},'{HBillNo1}',{(i + 1)},0,0,''
+ ,'',{ HMaterIDs},0,0,0,1
+ ,0,0,getdate(),'{HBarCodes}','{HBadCodeSN}','') ";
oCN.RunProc(sq2);
}
- }
+ CustomWriteLog("2.1.23 淇濆瓨瀛愯〃 :" + HProcNumber + "----" + timer.Elapsed, DateTime.Now.ToString("yyyy-MM-dd"));
+ }
+ CustomWriteLog("2.1.24璁℃椂鍣ㄧ粨鏉� :" + HProcNumber + "----" + timer.Elapsed, DateTime.Now.ToString("yyyy-MM-dd"));
+ timer.Stop();//缁撴潫璁℃椂
return true;
}
catch (Exception e)
@@ -425,11 +572,11 @@
try
{
//鑾峰彇缁戝畾娴佽浆鍗�
- DataSet ds = oCN.RunProcReturn(@"select * from Gy_BarCodeBill WITH(NOLOCK) where HBarCode='" + HBadCodeSN + "'", "Gy_BarCodeBill");
+ DataSet ds = oCN.RunProcReturn(@"select HSourceBillNo from Gy_BarCodeBill WITH(NOLOCK) where HBarCode='" + HBadCodeSN + "'", "Gy_BarCodeBill");
string HProcExchBillNo = ds.Tables[0].Rows[0]["HSourceBillNo"].ToString();
string HProcNumber = dic["HProcNumber"].ToString();
- ds = oCN.RunProcReturn("select * from Gy_Source WITH(NOLOCK) where HNumber='" + dic["HSourceCode"].ToString() + "' ", "Gy_Source");
+ ds = oCN.RunProcReturn("select HItemID from Gy_Source WITH(NOLOCK) where HNumber='" + dic["HSourceCode"].ToString() + "' ", "Gy_Source");
long HSourceID = 0;
if (ds.Tables[0].Rows.Count != 0)
{
@@ -437,7 +584,7 @@
}
//鏌ヨ鑱屽憳
- ds = oCN.RunProcReturn("select * from Gy_Employee WITH(NOLOCK) where HNumber='" + dic["HEmpCode"].ToString() + "' ", "Gy_Employee");
+ ds = oCN.RunProcReturn("select HItemID from Gy_Employee WITH(NOLOCK) where HNumber='" + dic["HEmpCode"].ToString() + "' ", "Gy_Employee");
long HEmpIDs = 0;
if (ds.Tables[0].Rows.Count != 0)
{
@@ -449,7 +596,7 @@
string sReturn = "";
if (GetSingleSystemParameter("WMS_CampanyName", ref sReturn) == "鏉窞鏂帿灏�")
{
- HDeptID = 389499;
+ HDeptID = 389505;
HPRDOrgIDs = 100199;
}
else
@@ -463,6 +610,7 @@
HDeptID = 0;
}
+ //鏍规嵁娴佽浆鍗″拰宸ュ簭 鏌ヨ鍑虹珯鍗曢渶瑕佷繚瀛樼殑淇℃伅
ds = oCN.RunProcReturn(@"select b.HProcNo,b.HProcID,a.HMaterID,a.HQty,a.HInterID,HEntryID,a.HICMOInterID,a.HICMOEntryID,a.HICMOBillNo
from Sc_ProcessExchangeBillMain a WITH(NOLOCK)
inner join Sc_ProcessExchangeBillSub b WITH(NOLOCK) on a.HInterID=b.HInterID
@@ -479,12 +627,28 @@
long HInterID = 0;
string HBillNo = "";
- ds = oCN.RunProcReturn("select * from Sc_AssemblyBillMain WITH(NOLOCK) where HMainSourceInterID=" + HProcExchInterID + " and HMainSourceEntryID=" + HProcExchEntryID, "Sc_AssemblyBillMain");
+ //ds = oCN.RunProcReturn("exec h_p_Sc_SNBarcodeProcCtrl_S '" + HBadCodeSN + "'," + HProcID, "h_v_Gy_QualifiedRecordsList");
+ //if (ds.Tables[0].Rows.Count == 0)
+ //{
+ // oCN.RollBack();
+ // CustomWriteLog("鏉$爜:" + HBadCodeSN + "宸ュ簭:" + HProcID + ",宸ュ簭鎺у埗鏌ユ棤鏁版嵁!", DateTime.Now.ToString("yyyy-MM-dd"));
+ // return false;
+ //}
+ //else if (ds.Tables[0].Rows[0]["HBack"].ToString() == "2")
+ //{
+ // oCN.RollBack();
+ // CustomWriteLog("鏉$爜:" + HBadCodeSN + "宸ュ簭:" + HProcID + "," + ds.Tables[0].Rows[0]["HBackRemark"].ToString() + "!", DateTime.Now.ToString("yyyy-MM-dd"));
+ // return false;
+ //}
+
+ //鏌ヨ浜х嚎缁勮杩芥函鍗曠殑鏁版嵁 鑾峰彇鏃堕棿 鏍规嵁鏃堕棿鍒ゆ柇瀵瑰簲 鏄摢澶╁嚭绔欏崟鐨勬暟鎹�
+ ds = oCN.RunProcReturn("select HDate from Sc_AssemblyBillMain WITH(NOLOCK) where HMainSourceInterID=" + HProcExchInterID + " and HMainSourceEntryID=" + HProcExchEntryID, "Sc_AssemblyBillMain");
DateTime HDate=DateTime.Now;
//褰撲骇鍝佹病鏈夐厤浠剁殑鏃跺�� 鏌ヨ 涓嶈壇璁板綍
if (ds.Tables[0].Rows.Count == 0)
{
- ds = oCN.RunProcReturn("select * from Sc_QualityReportBillSub WITH(NOLOCK) where HProcExchInterID=" + HProcExchInterID + " and HProcExchEntryID=" + HProcExchEntryID+ " and HBarCode='" + HBadCodeSN + "'", "Sc_AssemblyBillMain");
+ //鏌ヨ鐢熶骇璐ㄩ噺姹囨姤鍗曟暟鎹�
+ ds = oCN.RunProcReturn("select HMakeDate from Sc_QualityReportBillSub WITH(NOLOCK) where HProcExchInterID=" + HProcExchInterID + " and HProcExchEntryID=" + HProcExchEntryID+ " and HBarCode='" + HBadCodeSN + "'", "Sc_AssemblyBillMain");
HDate = DateTime.Parse(ds.Tables[0].Rows[0]["HMakeDate"].ToString());
}
else {
@@ -505,7 +669,7 @@
}
//鍒ゆ柇褰撳墠娴佽浆鍗$殑鍑虹珯鍗� 鏄惁鏈夋暟鎹�
- ds = oCN.RunProcReturn(@"select * from Sc_StationOutBillMain a WITH(NOLOCK)
+ ds = oCN.RunProcReturn(@"select HInterID,HBillNo from Sc_StationOutBillMain a WITH(NOLOCK)
left join Gy_Process p WITH(NOLOCK) on a.HProcID=p.HItemID
where HProcExchBillNo='" + HProcExchBillNo + "' and p.HNumber='" + HProcNumber + "' and CONVERT(varchar(10),HDate,20) ='" + HDate.ToString("yyyy-MM-dd") + "'", "Sc_StationOutBillMain");
@@ -517,14 +681,17 @@
if (HResult == "OK")
{
- ds = oCN.RunProcReturn("select * from Sc_StationOutBillSub_SN WITH(NOLOCK) where HInterID='" + HInterID + "' order by HEntryID desc", "Sc_StationOutBillSub_SN");
+ ds = oCN.RunProcReturn("select HInterID,HEntryID from Sc_StationOutBillSub_SN WITH(NOLOCK) where HInterID='" + HInterID + "' order by HEntryID desc", "Sc_StationOutBillSub_SN");
string HMakeTime = dic["HCreateTime"].ToString();
oCN.RunProc($@"insert into Sc_StationOutBillSub_SN(HInterID,HBillNo_bak,HEntryID,HBarCode,HBarCodeQty,HMakeTime,HRemark,HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HRelationQty,HRelationMoney)
values({ HInterID}, '{ HBillNo}', {(ds.Tables[0].Rows.Count == 0 ? 1 : int.Parse(ds.Tables[0].Rows[0]["HEntryID"].ToString()) + 1)}, '{HBadCodeSN}', 1, '" + HMakeTime + "', '', " + HProcExchInterID + "," + HProcExchEntryID + ", '" + HProcExchBillNo + "', '', 0, 0)");
+ CustomWriteLog("鏉$爜:" + HBadCodeSN + "宸ュ簭:"+ HProcNumber + ",鍑虹珯鏃堕棿:" + HMakeTime, "TM" + DateTime.Now.ToString("yyyy-MM-dd"));
+
//鍙嶅啓宸ュ簭鍑虹珯鍗曠殑鍚堟牸鏁伴噺
- oCN.RunProc("update Sc_StationOutBillMain set HQty+=1,HBadCount-=1 where HInterID='" + HInterID + "'");
+ //oCN.RunProc("update Sc_StationOutBillMain set HQty+=1,HBadCount-=1 where HInterID='" + HInterID + "'");
+ oCN.RunProc("update Sc_StationOutBillMain set HQty+=1 where HInterID='" + HInterID + "'");
//鍙嶅啓鏉$爜鐘舵��
oCN.RunProc("update Gy_BarCodeBill set HStatus='' where HBarCode='" + HBadCodeSN + "'");
}
@@ -551,35 +718,43 @@
try
{
-
- DataSet ds = oCN.RunProcReturn("select * from Sc_StationOutBillMain WITH(NOLOCK) where HInterID=" + HInterID + " and HBillNo='" + HBillNo + "'", "Sc_StationOutBillMain");
+ //鏌ヨ鍑虹珯鍗曠殑淇℃伅 鏂逛究鍙傛暟淇濆瓨
+ DataSet ds = oCN.RunProcReturn(@"select a.HProcExchInterID,a.HProcExchEntryID,a.HProcExchBillNo,a.HProcID,p.HNumber from Sc_StationOutBillMain a WITH(NOLOCK)
+left join Gy_Process p WITH(NOLOCK) on a.HProcID=p.HItemID where HInterID=" + HInterID + " and HBillNo='" + HBillNo + "'", "Sc_StationOutBillMain");
string HProcExchInterID = ds.Tables[0].Rows[0]["HProcExchInterID"].ToString();
string HProcExchEntryID = ds.Tables[0].Rows[0]["HProcExchEntryID"].ToString();
string HProcExchBillNo = ds.Tables[0].Rows[0]["HProcExchBillNo"].ToString();
-
- ds = oCN.RunProcReturn(@"select s.HItemID HMouldID,t.HItemID HTechParamID,HCount,HCreateTime from Sb_EquipMentCollectionTechParam_SN a WITH(NOLOCK)
+ string HProcID = ds.Tables[0].Rows[0]["HProcID"].ToString();
+ string HProcNum = ds.Tables[0].Rows[0]["HNumber"].ToString();
+ //娉�:鍥犱负 缁勮 鎷嶇収 鏃堕棿闂撮殧姣旇緝鐭� 鎵�浠ョ洰鍓嶅彧鏄庣‘缁勮宸ュ簭鎵嶅彲浠ヤ繚瀛樺伐鑹哄弬鏁� 涔嬪悗濡傛灉鏈夊叾浠栧伐搴忕殑璇� 闇�瑕佸鍔犲伐搴忓瓧娈�
+ if (HProcID == "88"|| HProcNum=="005") {
+ //鏌ヨ宸ヨ壓鍙傛暟涓存椂琛� 鑾峰彇褰撳ぉ鏉$爜瀵瑰簲鐨勫弬鏁�
+ ds = oCN.RunProcReturn(@"select s.HItemID HMouldID,t.HItemID HTechParamID,HCount,HCreateTime,a.HResult from Sb_EquipMentCollectionTechParam_SN a WITH(NOLOCK)
inner join Gy_Source s WITH(NOLOCK) on a.HSourceCode=s.HNumber
inner join Gy_TechnologyParameter t WITH(NOLOCK) on a.HType=t.HName
where a.HFlag=0 and a.HBarCode='" + HBadCodeSN + "'", "Sb_EquipMentCollectionTechParam_SN");
- //娉�:褰撳墠鍙湁涓�閬撳伐搴忔湁鍙傛暟 濡傛灉鏈夊閬撳伐搴忕殑璇� 闇�瑕佸鍔� 宸ュ簭鐨勮繃婊�
+ //娉�:褰撳墠鍙湁涓�閬撳伐搴忔湁鍙傛暟 濡傛灉鏈夊閬撳伐搴忕殑璇� 闇�瑕佸鍔� 宸ュ簭鐨勮繃婊�
- if (ds.Tables[0].Rows.Count != 0) {
-
- for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
+ if (ds.Tables[0].Rows.Count != 0)
{
- string HMouldID = ds.Tables[0].Rows[i]["HMouldID"].ToString();
- string HTechParamID = ds.Tables[0].Rows[i]["HTechParamID"].ToString();
- string HCount = ds.Tables[0].Rows[i]["HCount"].ToString();
- string HGetTime = ds.Tables[0].Rows[i]["HCreateTime"].ToString();
- DataSet dataSet = oCN.RunProcReturn("select * from Sc_StationOutBillSub_TechParam WITH(NOLOCK) where HInterID=" + HInterID + " and HBillNo_bak='" + HBillNo + "'", "Sc_StationOutBillSub_TechParam");
+ for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
+ {
+ string HMouldID = ds.Tables[0].Rows[i]["HMouldID"].ToString();
+ string HTechParamID = ds.Tables[0].Rows[i]["HTechParamID"].ToString();
+ string HCount = ds.Tables[0].Rows[i]["HCount"].ToString();
+ string HGetTime = ds.Tables[0].Rows[i]["HCreateTime"].ToString();
+ string HResult = ds.Tables[0].Rows[i]["HResult"].ToString();
- sql = "insert into Sc_StationOutBillSub_TechParam(HInterID,HBillNo_bak,HEntryID ,HSourceInterID,HSourceEntryID,HSourceBillNo,HTechParamID,HRelValue,HGetTime,HBarCode,HMouldID)" +
- $"values({HInterID},'{HBillNo}',{(dataSet.Tables[0].Rows.Count + 1)},{HProcExchInterID},{HProcExchEntryID},'{HProcExchBillNo}',{HTechParamID},{HCount},'{HGetTime}','{HBadCodeSN}',{HMouldID})";
+ DataSet dataSet = oCN.RunProcReturn("select HInterID,HEntryID from Sc_StationOutBillSub_TechParam WITH(NOLOCK) where HInterID=" + HInterID + " and HBillNo_bak='" + HBillNo + "'", "Sc_StationOutBillSub_TechParam");
- oCN.RunProc(sql);
+ sql = "insert into Sc_StationOutBillSub_TechParam(HInterID,HBillNo_bak,HEntryID ,HSourceInterID,HSourceEntryID,HSourceBillNo,HTechParamID,HRelValue,HGetTime,HBarCode,HMouldID,HRemark)" +
+ $"values({HInterID},'{HBillNo}',{(dataSet.Tables[0].Rows.Count + 1)},{HProcExchInterID},{HProcExchEntryID},'{HProcExchBillNo}',{HTechParamID},{HCount},'{HGetTime}','{HBadCodeSN}',{HMouldID},'{HResult}')";
+
+ oCN.RunProc(sql);
+ }
+ oCN.RunProc("update Sb_EquipMentCollectionTechParam_SN set HFlag=1 where HBarCode='" + HBadCodeSN + "'");
}
- oCN.RunProc("update Sb_EquipMentCollectionTechParam_SN set HFlag=1 where HBarCode='" + HBadCodeSN + "'");
}
return true;
@@ -597,32 +772,48 @@
{
try
{
- DataSet ds = oCN.RunProcReturn(@"select * from Gy_BarCodeBill where HBarCode='" + HBadCodeSN + "'", "Gy_BarCodeBill");
- //鍒ゆ柇鏉$爜鏄惁鍦ㄦ暟鎹簱閲�
- if (ds.Tables[0].Rows.Count == 0)
+ // 鏌ヨ鏉$爜鏄惁瀛樺湪鏉$爜妗f
+ DataSet barCodeDs = oCN.RunProcReturn(@"select HSourceBillNo from Gy_BarCodeBill WITH(NOLOCK) where HBarCode='" + HBadCodeSN + "'", "Gy_BarCodeBill");
+
+ if (barCodeDs.Tables[0].Rows.Count > 0)
{
- //鍒ゆ柇闀垮害鏄惁涓�29浣�
- if (HBadCodeSN.Length == 29)
+ string HSourceBillNo = barCodeDs.Tables[0].Rows[0]["HSourceBillNo"].ToString();
+ DataSet processExchangeDs = oCN.RunProcReturn(@"select HInterID from Sc_ProcessExchangeBillMain WITH(NOLOCK) where HBillNo='" + HSourceBillNo + "'", "Sc_ProcessExchangeBillMain");
+ if (processExchangeDs.Tables[0].Rows.Count == 0)
{
- string str1 = HBadCodeSN.Substring(23, 3);
- ds = oCN.RunProcReturn("select * from Sc_ProcessExchangeBillMain where HProjectNum like'" + str1 + "-1%'", "Sc_ProcessExchangeBillMain");
- //鍒ゆ柇鏄惁鑳芥壘鍒板搴旂殑娴佽浆鍗�
- if (ds.Tables[0].Rows.Count > 0)
+ oCN.RunProc("delete from Gy_BarCodeBill WITH(NOLOCK) where HBarCode='" + HBadCodeSN + "'");
+ // 閲嶆柊鏌ヨ鏉$爜妗f
+ barCodeDs = oCN.RunProcReturn(@"select HSourceBillNo from Gy_BarCodeBill WITH(NOLOCK) where HBarCode='" + HBadCodeSN + "'", "Gy_BarCodeBill");
+ }
+ }
+
+ //鍒ゆ柇鏉$爜鏄惁鍦ㄦ暟鎹簱閲� 濡傛灉鏈夊垪娌℃湁鏁版嵁杩斿洖閭e氨鏄繘鍘讳繚瀛�
+ if (barCodeDs.Tables[0].Rows.Count == 0)
+ {
+ //鍒ゆ柇鏉$爜闀垮害鏄�29浣嶈繕鏄�50浣� 29 鏃犲皹杞﹂棿 50 15杞﹂棿
+ if (HBadCodeSN.Length == 29 || HBadCodeSN.Length == 50)
+ {
+ string str1 = HBadCodeSN.Length == 29 ? HBadCodeSN.Substring(18, 8) : HBadCodeSN.Substring(42, 8);
+ string HProcExchBillNo = GetProcExchBillNo(str1);
+
+ if (HProcExchBillNo == null && HBadCodeSN.Length == 29)
{
- string HProcExchBillNo = ds.Tables[0].Rows[0]["HBillNo"].ToString();
- get_HBardBillSave(HBadCodeSN, HProcExchBillNo);
+ // 绗竴娆℃埅鍙栨湭鎵惧埌锛岃繘琛岀浜屾鎴彇
+ str1 = HBadCodeSN.Substring(0, 8); // 绀轰緥鐨勯噸鏂版埅鍙栨柟娉�
+ HProcExchBillNo = GetProcExchBillNo(str1);
}
- else
+
+ if (HProcExchBillNo == null)
{
- oCN.RollBack();
CustomWriteLog("鏉$爜:" + HBadCodeSN + ",娴佽浆鍗′笉瀛樺湪!", DateTime.Now.ToString("yyyy-MM-dd"));
return 2;
}
+ //淇濆瓨鏉$爜
+ get_HBardBillSave(HBadCodeSN, HProcExchBillNo);
}
else
{
- oCN.RollBack();
- CustomWriteLog("鏉$爜:" + HBadCodeSN + ",闀垮害涓嶇瓑浜�29浣�!", DateTime.Now.ToString("yyyy-MM-dd"));
+ CustomWriteLog("鏉$爜:" + HBadCodeSN + ",闀垮害涓嶇瓑浜�29浣嶆垨50浣�!", DateTime.Now.ToString("yyyy-MM-dd"));
return 2;
}
}
@@ -640,6 +831,20 @@
}
}
+ // 鏍规嵁鏉$爜 鑾峰彇娴佽浆鍗$紪鍙�
+ public string GetProcExchBillNo(string str1)
+ {
+
+ DataSet ds = oCN.RunProcReturn("select HBillNo from Sc_ProcessExchangeBillMain WITH(NOLOCK) where HProjectNum like'" + str1 + "-1%'", "Sc_ProcessExchangeBillMain");
+
+ if (ds.Tables[0].Rows.Count > 0)
+ {
+ return ds.Tables[0].Rows[0]["HBillNo"].ToString();
+ }
+ return null;
+ }
+
+
//鏂板鏉$爜鏁版嵁
public void get_HBardBillSave(string HBarCode, string HProcExchBillNo)
{
@@ -647,10 +852,10 @@
{
//鏌ヨ娴佽浆鍗℃暟鎹�
DataSet dataSet = oCN.RunProcReturn(@"select a.HPRDORGID, m.HModel 鐗╂枡瑙勬牸,m.HName 鍚嶇墿鏂欑О,a.HBillNo,a.HInterID,a.HMaterID,m.HNumber 鐗╂枡浠g爜,o.HNumber 缁勭粐浠g爜,a.HUnitID,u.HNumber 鍗曚綅浠g爜 from Sc_ProcessExchangeBillMain a WITH(NOLOCK)
-left join Gy_Material m WITH(NOLOCK) on a.HMaterID=m.HItemID
-left join Xt_ORGANIZATIONS o WITH(NOLOCK) on a.HPRDORGID=o.HItemID
-left join Gy_Unit u WITH(NOLOCK) on a.HUnitID=u.HItemID
-where HBillNo='" + HProcExchBillNo + "'", "Sc_ProcessExchangeBillMain");
+ left join Gy_Material m WITH(NOLOCK) on a.HMaterID=m.HItemID
+ left join Xt_ORGANIZATIONS o WITH(NOLOCK) on a.HPRDORGID=o.HItemID
+ left join Gy_Unit u WITH(NOLOCK) on a.HUnitID=u.HItemID
+ where HBillNo='" + HProcExchBillNo + "'", "Sc_ProcessExchangeBillMain");
//鍒ゆ柇娴佽浆鍗′笉鑳戒负绌�
@@ -659,7 +864,7 @@
oCN.RollBack();
CustomWriteLog("鏉$爜:" + HBarCode + ",娴佽浆鍗′笉鑳戒负绌�!", DateTime.Now.ToString("yyyy-MM-dd"));
}
-
+
//鏃ユ湡鑾峰彇鏂瑰紡
string sDate = DateTime.Now.ToString();
string HWei = "0"; //灏炬暟
@@ -751,7 +956,7 @@
//瀹氭椂璇诲彇鏁版嵁
private void timer1_Tick(object sender, EventArgs e)
{
- DataTable list = oCN.RunProcReturn("select * from Sb_EquipMentCollection_SN WITH(NOLOCK) where HFlag=0 order by HCreateTime", "Sb_EquipMentCollection_SN").Tables[0];
+ DataTable list = oCN.RunProcReturn("select top 100 HResult,HBarCode,HCreateTime from Sb_EquipMentCollection_SN WITH(NOLOCK) where HFlag=0 order by HCreateTime asc", "Sb_EquipMentCollection_SN").Tables[0];
//寰幆闆嗗悎
for (int i = 0; i < list.Rows.Count; i++)
@@ -759,10 +964,14 @@
bool flag = false;
string HResult = list.Rows[i]["HResult"].ToString();
string HBadCodeSN = list.Rows[i]["HBarCode"].ToString();
+ string HCreateTime = list.Rows[i]["HCreateTime"].ToString();
+
+ //HBadCodeSN = "P1099081-00-E:SDU324292189300";
+ //HResult = "OK";
//寮�濮嬩簨鍔�
oCN.BeginTran();
-
- if (HResult == "OK")
+
+ if (HResult == "OK")
{
flag = HResultOK(list.Rows[i]);
}
@@ -773,7 +982,7 @@
if (flag)
{
- oCN.RunProc("update Sb_EquipMentCollection_SN set HFlag=1 where HBarCode='" + HBadCodeSN + "'");
+ oCN.RunProc("update Sb_EquipMentCollection_SN set HFlag=1 where HBarCode='" + HBadCodeSN + "' and HCreateTime='" + HCreateTime + "'");
//缁撴潫浜嬪姟
oCN.Commit();
}
@@ -787,7 +996,7 @@
{
//鏌ヨ鑱屽憳
- DataSet ds = oCN.RunProcReturn("select * from Gy_Employee WITH(NOLOCK) where HNumber='" + dic["HEmpCode"].ToString() + "' ", "Gy_Employee");
+ DataSet ds = oCN.RunProcReturn("select HItemID,HName from Gy_Employee WITH(NOLOCK) where HNumber='" + dic["HEmpCode"].ToString() + "' ", "Gy_Employee");
long HEmpIDs = 0;
string HMakers = "";
if (ds.Tables[0].Rows.Count != 0)
@@ -800,7 +1009,7 @@
string sReturn = "";
if (GetSingleSystemParameter("WMS_CampanyName", ref sReturn) == "鏉窞鏂帿灏�")
{
- HDeptID = 389499;
+ HDeptID = 389505;
}
else
{
@@ -817,11 +1026,14 @@
string HProcExchEntryID = "0";
string HProcExchBillNo = "";
long HMaterID = 0;
+ long HProcID = 0;
long HUnitID = 0;
long HICMOInterID = 0;
long HICMOEntryID = 0;
string HICMOBillNo = "";
- ds = oCN.RunProcReturn(@"select HMaterID,HUnitID,a.HICMOInterID,a.HICMOEntryID,a.HICMOBillNo,HBillNo,a.HInterID,b.HEntryID,a.HBillNo from Sc_ProcessExchangeBillMain a WITH(NOLOCK)
+
+ //鏍规嵁 鏉$爜+宸ュ簭 鏌ヨ娴佽浆鍗′俊鎭�
+ ds = oCN.RunProcReturn(@"select b.HProcID, HMaterID,HUnitID,a.HICMOInterID,a.HICMOEntryID,a.HICMOBillNo,HBillNo,a.HInterID,b.HEntryID,a.HBillNo 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 HBillNo=(select HSourceBillNo from Gy_BarCodeBill WITH(NOLOCK) where HBarCode='" + dic["HBarCode"].ToString() + "') and p.HNumber='" + dic["HProcNumber"].ToString() + "' ", "Sc_ProcessExchangeBillMain");
@@ -835,10 +1047,11 @@
HProcExchInterID = ds.Tables[0].Rows[0]["HInterID"].ToString();
HProcExchEntryID = ds.Tables[0].Rows[0]["HEntryID"].ToString();
HProcExchBillNo = ds.Tables[0].Rows[0]["HBillNo"].ToString();
+ HProcID = int.Parse(ds.Tables[0].Rows[0]["HProcID"].ToString());
}
- ds = oCN.RunProcReturn("select * from Gy_Source WITH(NOLOCK) where HNumber='" + dic["HSourceCode"].ToString() + "' ", "Gy_Source");
+ ds = oCN.RunProcReturn("select HItemID from Gy_Source WITH(NOLOCK) where HNumber='" + dic["HSourceCode"].ToString() + "' ", "Gy_Source");
long HSourceID = 0;
if (ds.Tables[0].Rows.Count != 0)
{
@@ -873,11 +1086,11 @@
(HInterID,HENTRYID,HBillNo_bak,HEmpID,HBarCode,HBadReasonID,HAddr,HMaker,HMakeDate
,HMaterID,HUnitID,HRemark,HSourceID,HICMOInterID,HICMOEntryID,HICMOBillNo,HReportType
,HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HRelationQty,HRelationMoney
-,HQty,HResult,HProcExchInterID,HProcExchEntryID,HProcExchBillNo)
-values({HInterID},1,'{HBillNo}',{HEmpID},'{HBarCode}',0,'','{HMaker}','{HMakeDate}'
+,HQty,HResult,HProcExchInterID,HProcExchEntryID,HProcExchBillNo,HProcID)
+values({HInterID},1,'{HBillNo}',{HEmpID},'{HBarCode}',219,'','{HMaker}','{HMakeDate}'
,{HMaterID},{ HUnitID},'',{HSourceID},{ HICMOInterID},{ HICMOEntryID},'{HICMOBillNo}',0
,0,0,'','',0,0
-,0,'{HResult}',{ HProcExchInterID},{ HProcExchEntryID},'{ HProcExchBillNo}')");
+,1,'{HResult}',{ HProcExchInterID},{ HProcExchEntryID},'{ HProcExchBillNo}'," + HProcID + ")");
return true;
}
@@ -1096,5 +1309,13 @@
}
}
#endregion
+
+ private void Form1_FormClosing(object sender, FormClosingEventArgs e)
+ {
+ if (MessageBox.Show("纭畾瑕佸叧闂悧锛�", "纭", MessageBoxButtons.YesNo) == DialogResult.No)
+ {
+ e.Cancel = true;
+ }
+ }
}
}
--
Gitblit v1.9.1