| | |
| | | CustomWriteLog("1.计时器开始:"+timer.Elapsed, DateTime.Now.ToString("yyyy-MM-dd")); |
| | | |
| | | //根据时间正序排序获取前150条数据 |
| | | DataTable list = oCN.RunProcReturn("select top 150 * from Sb_EquipMentCollection_SN WITH(NOLOCK) where HFlag=0 order by HCreateTime", "Sb_EquipMentCollection_SN").Tables[0]; |
| | | 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++) |
| | |
| | | |
| | | bool flag = false; |
| | | string HBadCodeSN = dic["HBarCode"].ToString(); |
| | | HBadCodeSN = TM_ZH(HBadCodeSN); |
| | | //HBadCodeSN = TM_ZH(HBadCodeSN); |
| | | //判断当天条码有没有存储在条码表里 如果没有 则保存数据 并返回0 |
| | | //如果已存在 则返回 1 |
| | | //如果条件不满足的 则返回 2 |
| | |
| | | bool flag = false; |
| | | int num = 0; |
| | | string HBadCodeSN = dic["HBarCode"].ToString(); |
| | | HBadCodeSN = TM_ZH(HBadCodeSN); |
| | | //HBadCodeSN = TM_ZH(HBadCodeSN); |
| | | //判断当天条码有没有存储在条码表里 如果没有 则保存数据 并返回0 |
| | | //如果已存在 则返回 1 |
| | | //如果条件不满足的 则返回 2 |
| | |
| | | { |
| | | 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(); |
| | | |
| | | CustomWriteLog("2.1.2.绑定流转卡:"+ HProcNumber+"----" + timer.Elapsed, DateTime.Now.ToString("yyyy-MM-dd")); |
| | | |
| | | //查询生产资源 |
| | | 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) |
| | | { |
| | |
| | | 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")); |
| | |
| | | |
| | | |
| | | //判断当前流转卡的出站单 是否有数据 |
| | | 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) ='" + DateTime.Now.ToString("yyyy-MM-dd") + "'", "Sc_StationOutBillMain"); |
| | | 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")); |
| | | |
| | |
| | | "," + HmaterOutqty + "," + HProcPriceRate + "," + HTemporaryAreaID + ","+ HShiftsID + ") "); |
| | | } |
| | | |
| | | |
| | | CustomWriteLog("2.1.10 出站单新增 :" + HProcNumber + "----" + timer.Elapsed, DateTime.Now.ToString("yyyy-MM-dd")); |
| | | |
| | | if (HResult == "OK") |
| | |
| | | CustomWriteLog("2.1.11 条码反写 :" + HProcNumber + "----" + timer.Elapsed, DateTime.Now.ToString("yyyy-MM-dd")); |
| | | |
| | | //查询 出站单子表 条码表的数据 |
| | | ds = oCN.RunProcReturn("select * 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) |
| | |
| | | { |
| | | CustomWriteLog("2.1.13 不合格反写 :" + HProcNumber + "----" + timer.Elapsed, DateTime.Now.ToString("yyyy-MM-dd")); |
| | | //通过条码查询生产质量汇报单数据 |
| | | ds = oCN.RunProcReturn("select * from Sc_QualityReportBillSub WITH(NOLOCK) where HBarCode='" + HBadCodeSN + "' order by HMakeDate desc", "Sc_QualityReportBillSub"); |
| | | 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 * from Sc_SourceLineRepairBillMain WITH(NOLOCK) where HBarCode='" + HBadCodeSN + "' order by HMakeDate desc", "Sc_SourceLineRepairBillMain"); |
| | | 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(); |
| | |
| | | return false; |
| | | } |
| | | |
| | | // //查询出站数量是否超过流转卡数量 |
| | | //查询出站数量是否超过流转卡数量 |
| | | // 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} |
| | |
| | | |
| | | CustomWriteLog("2.1.15 反写结束 :" + HProcNumber + "----" + timer.Elapsed, DateTime.Now.ToString("yyyy-MM-dd")); |
| | | |
| | | //增加工序判断 |
| | | //增加工序判断 拍照工序跳过工艺参数绑定 不走下面流程,直接结束本次新增 |
| | | if (HProcNumber == "013") |
| | | { |
| | | return true; |
| | |
| | | |
| | | |
| | | //查询职员 |
| | | 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")); |
| | | |
| | |
| | | string HGetTime = ds.Tables[0].Rows[i]["HCreateTime"].ToString(); |
| | | string HResult = ds.Tables[0].Rows[i]["HResult"].ToString(); |
| | | |
| | | DataSet dataSet = oCN.RunProcReturn("select * from Sc_StationOutBillSub_TechParam WITH(NOLOCK) where HInterID=" + HInterID + " and HBillNo_bak='" + HBillNo + "'", "Sc_StationOutBillSub_TechParam"); |
| | | DataSet dataSet = oCN.RunProcReturn("select HInterID,HEntryID from Sc_StationOutBillSub_TechParam WITH(NOLOCK) where HInterID=" + HInterID + " and HBillNo_bak='" + HBillNo + "'", "Sc_StationOutBillSub_TechParam"); |
| | | |
| | | 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}')"; |
| | |
| | | { |
| | | try |
| | | { |
| | | // 查询条码是否存在条码档案 |
| | | DataSet barCodeDs = oCN.RunProcReturn(@"select HSourceBillNo from Gy_BarCodeBill WITH(NOLOCK) where HBarCode='" + HBadCodeSN + "'", "Gy_BarCodeBill"); |
| | | |
| | | DataSet ds = oCN.RunProcReturn(@"select * from Gy_BarCodeBill where HBarCode='" + HBadCodeSN + "'", "Gy_BarCodeBill"); |
| | | //判断条码是否存在条码档案 |
| | | if (ds.Tables[0].Rows.Count > 0) |
| | | if (barCodeDs.Tables[0].Rows.Count > 0) |
| | | { |
| | | string HSourceBillNo = ds.Tables[0].Rows[0]["HSourceBillNo"].ToString(); |
| | | DataSet dataTable = oCN.RunProcReturn(@"select * from Sc_ProcessExchangeBillMain where HBillNo='" + HSourceBillNo + "'", "Sc_ProcessExchangeBillMain"); |
| | | //判断条码的源单 流转卡是否被删除 |
| | | if (dataTable.Tables[0].Rows.Count == 0) |
| | | 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) |
| | | { |
| | | //如果源单已经删除 则条码也删除重新生成 |
| | | oCN.RunProc("delete from Gy_BarCodeBill where HBarCode='" + HBadCodeSN + "'"); |
| | | |
| | | //重新查询条码档案 进入新增方法 |
| | | ds = oCN.RunProcReturn(@"select * from Gy_BarCodeBill where HBarCode='" + HBadCodeSN + "'", "Gy_BarCodeBill"); |
| | | oCN.RunProc("delete from Gy_BarCodeBill WITH(NOLOCK) where HBarCode='" + HBadCodeSN + "'"); |
| | | // 重新查询条码档案 |
| | | barCodeDs = oCN.RunProcReturn(@"select HSourceBillNo from Gy_BarCodeBill WITH(NOLOCK) where HBarCode='" + HBadCodeSN + "'", "Gy_BarCodeBill"); |
| | | } |
| | | } |
| | | |
| | | //判断条码是否在数据库里 |
| | | if (ds.Tables[0].Rows.Count == 0) |
| | | //判断条码是否在数据库里 如果有列没有数据返回那就是进去保存 |
| | | if (barCodeDs.Tables[0].Rows.Count == 0) |
| | | { |
| | | //判断长度是否为29位 无尘车间 |
| | | if (HBadCodeSN.Length == 29) |
| | | //判断条码长度是29位还是50位 29 无尘车间 50 15车间 |
| | | if (HBadCodeSN.Length == 29 || HBadCodeSN.Length == 50) |
| | | { |
| | | string str1 = HBadCodeSN.Substring(18, 8); |
| | | ds = oCN.RunProcReturn("select * from Sc_ProcessExchangeBillMain where HProjectNum like'" + str1 + "-1%'", "Sc_ProcessExchangeBillMain"); |
| | | //判断是否能找到对应的流转卡 |
| | | if (ds.Tables[0].Rows.Count > 0) |
| | | 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) |
| | | { |
| | | 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) |
| | | { |
| | | string HProcExchBillNo = ds.Tables[0].Rows[0]["HBillNo"].ToString(); |
| | | get_HBardBillSave(HBadCodeSN, HProcExchBillNo); |
| | | } |
| | | else |
| | | { |
| | | oCN.RollBack(); |
| | | CustomWriteLog("条码:" + HBadCodeSN + ",流转卡不存在!", DateTime.Now.ToString("yyyy-MM-dd")); |
| | | return 2; |
| | | } |
| | | } |
| | | } |
| | | //判断长度是否为50位 15车间 |
| | | else if (HBadCodeSN.Length == 50) |
| | | { |
| | | string str1 = HBadCodeSN.Substring(42, 8); |
| | | ds = oCN.RunProcReturn("select * from Sc_ProcessExchangeBillMain where HProjectNum like'" + str1 + "-1%'", "Sc_ProcessExchangeBillMain"); |
| | | //判断是否能找到对应的流转卡 |
| | | if (ds.Tables[0].Rows.Count > 0) |
| | | { |
| | | string HProcExchBillNo = ds.Tables[0].Rows[0]["HBillNo"].ToString(); |
| | | //保存条码 |
| | | get_HBardBillSave(HBadCodeSN, HProcExchBillNo); |
| | | } |
| | | else |
| | | { |
| | | oCN.RollBack(); |
| | | CustomWriteLog("条码:" + HBadCodeSN + ",流转卡不存在!", DateTime.Now.ToString("yyyy-MM-dd")); |
| | | return 2; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | oCN.RollBack(); |
| | | CustomWriteLog("条码:" + HBadCodeSN + ",长度不等于29位!", DateTime.Now.ToString("yyyy-MM-dd")); |
| | | CustomWriteLog("条码:" + HBadCodeSN + ",长度不等于29位或50位!", DateTime.Now.ToString("yyyy-MM-dd")); |
| | | return 2; |
| | | } |
| | | } |
| | |
| | | return 2; |
| | | } |
| | | } |
| | | |
| | | // 根据条码 获取流转卡编号 |
| | | 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) |
| | |
| | | //定时读取数据 |
| | | private void timer1_Tick(object sender, EventArgs e) |
| | | { |
| | | 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]; |
| | | 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++) |
| | |
| | | { |
| | | |
| | | //查询职员 |
| | | 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) |