| | |
| | | CustomWriteLog("1.计时器开始:"+timer.Elapsed, DateTime.Now.ToString("yyyy-MM-dd")); |
| | | |
| | | //根据时间正序排序获取前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]; |
| | | DataTable list = oCN.RunProcReturn("select top 150 * 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++) |
| | |
| | | if (num == 0 || num == 1) |
| | | { |
| | | flag = getOutBillAdd(dic, HBadCodeSN, "NG"); |
| | | |
| | | CustomWriteLog("条码不良:" + HBadCodeSN, DateTime.Now.ToString("yyyy-MM-dd")); |
| | | if (flag) |
| | | { |
| | | //新增不良汇报 |
| | | flag = getBadBillAdd(dic); |
| | | CustomWriteLog("完成不良汇报:", DateTime.Now.ToString("yyyy-MM-dd")); |
| | | //反写条码状态 |
| | | oCN.RunProc("update Gy_BarCodeBill set HStatus='不良',HRemark='" + dic["HType"].ToString() + "' where HBarCode='" + HBadCodeSN + "'"); |
| | | CustomWriteLog("反写条码状态:", DateTime.Now.ToString("yyyy-MM-dd")); |
| | | } |
| | | } |
| | | else if (num == 2) |
| | |
| | | string HMakers = ""; //制单人 |
| | | CustomWriteLog("2.1.1.出站单新增开始:" + timer.Elapsed, DateTime.Now.ToString("yyyy-MM-dd")); |
| | | //获取绑定流转卡 |
| | | DataSet ds = oCN.RunProcReturn(@"select HSourceBillNo, 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(); |
| | | |
| | |
| | | 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"); |
| | | 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) |
| | |
| | | //定时读取数据 |
| | | private void timer1_Tick(object sender, EventArgs e) |
| | | { |
| | | 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]; |
| | | DataTable list = oCN.RunProcReturn("select top 100 * 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++) |
| | |
| | | { |
| | | flag = HResultNG(list.Rows[i]); |
| | | } |
| | | |
| | | CustomWriteLog("1-1.循环结束:", DateTime.Now.ToString("yyyy-MM-dd")); |
| | | if (flag) |
| | | { |
| | | CustomWriteLog("1.1.1更新:",DateTime.Now.ToString("yyyy-MM-dd")); |
| | | oCN.RunProc("update Sb_EquipMentCollection_SN set HFlag=1 where HBarCode='" + HBadCodeSN + "' and HCreateTime='" + HCreateTime + "'"); |
| | | //结束事务 |
| | | oCN.Commit(); |
| | | CustomWriteLog("1.1.2提交:", DateTime.Now.ToString("yyyy-MM-dd")); |
| | | } |
| | | |
| | | CustomWriteLog("1.1.3提交:", DateTime.Now.ToString("yyyy-MM-dd")); |
| | | } |
| | | } |
| | | |
| | |
| | | public bool getBadBillAdd(DataRow dic) { |
| | | try |
| | | { |
| | | |
| | | CustomWriteLog("新增不良汇报1.1:", DateTime.Now.ToString("yyyy-MM-dd")); |
| | | //查询职员 |
| | | DataSet ds = oCN.RunProcReturn("select HItemID,HName from Gy_Employee WITH(NOLOCK) where HNumber='" + dic["HEmpCode"].ToString() + "' ", "Gy_Employee"); |
| | | long HEmpIDs = 0; |
| | |
| | | HDeptID = 389505; |
| | | } |
| | | else |
| | | { |
| | | //ds = oCN.RunProcReturn("select * from Gy_Department where HNumber='" + dic["HDeptNumber"].ToString() + "' ", "Gy_Department"); |
| | | |
| | | //if (ds.Tables[0].Rows.Count != 0) |
| | | //{ |
| | | // HDeptID = long.Parse(ds.Tables[0].Rows[0]["HItemID"].ToString());//生产部门 |
| | | //} |
| | | { |
| | | HDeptID = 0; |
| | | } |
| | | |
| | | CustomWriteLog("新增不良汇报1.2:", DateTime.Now.ToString("yyyy-MM-dd")); |
| | | string HProcExchInterID = "0"; |
| | | string HProcExchEntryID = "0"; |
| | | string HProcExchBillNo = ""; |
| | |
| | | long HICMOEntryID = 0; |
| | | string HICMOBillNo = ""; |
| | | |
| | | CustomWriteLog("新增不良汇报1.3:"+ dic["HBarCode"].ToString()+ dic["HProcNumber"].ToString() , DateTime.Now.ToString("yyyy-MM-dd")); |
| | | //根据 条码+工序 查询流转卡信息 |
| | | 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 |
| | |
| | | HProcID = int.Parse(ds.Tables[0].Rows[0]["HProcID"].ToString()); |
| | | } |
| | | |
| | | |
| | | CustomWriteLog("新增不良汇报1.4:"+ dic["HSourceCode"].ToString(), 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) |
| | |
| | | long HMainSourceInterID = HICMOInterID; |
| | | long HMainSourceEntryID = HICMOEntryID; |
| | | string HMainSourceBillNo = HICMOBillNo; |
| | | |
| | | CustomWriteLog("新增不良汇报1.5:", DateTime.Now.ToString("yyyy-MM-dd")); |
| | | //主表 |
| | | oCN.RunProc(@"Insert Into Sc_QualityReportBillMain |
| | | (HBillType,HBillSubType,HBillStatus,HInterID,HBillNo,HDate |
| | | ,HYear,HPeriod,HRemark,HMaker,HMakeDate |
| | | ,HEmpID,HGroupID,HDeptID,HMainSourceInterID,HMainSourceEntryID,HMainSourceBillNo) |
| | | ,HEmpID,HGroupID,HDeptID,HMainSourceInterID,HMainSourceEntryID,HMainSourceBillNo,HSTOCKORGID) |
| | | values('3717','3717',1," + HInterID + ",'" + HBillNo + "','" + HDate + "'" + |
| | | "," + DateTime.Now.Year + "," + DateTime.Now.Month + ",'" + HRemark + "','" + HMaker + "',getdate()" + |
| | | ",'" + HEmpID + "'," + HGroupID + "," + HDeptID + "," + HMainSourceInterID + "," + HMainSourceEntryID + ",'" + HMainSourceBillNo + "') "); |
| | | ",'" + HEmpID + "'," + HGroupID + "," + HDeptID + "," + HMainSourceInterID + "," + HMainSourceEntryID + ",'" + HMainSourceBillNo + "','100199') "); |
| | | |
| | | string HBarCode = dic["HBarCode"].ToString(); |
| | | string HMakeDate = dic["HCreateTime"].ToString(); |
| | |
| | | ,0,0,'','',0,0 |
| | | ,1,'{HResult}',{ HProcExchInterID},{ HProcExchEntryID},'{ HProcExchBillNo}'," + HProcID + ")"); |
| | | |
| | | return true; |
| | | CustomWriteLog("新增不良汇报1.6:", DateTime.Now.ToString("yyyy-MM-dd")); |
| | | return true; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | oCN.RollBack(); |
| | | CustomWriteLog("报错原因:" + e.Message + "!", DateTime.Now.ToString("yyyy-MM-dd")); |
| | | return false; |
| | | } |
| | | } |
| | | } |
| | | |
| | | #region 基础方法 |