try { Log::Trace("", __FUNCTION__, "材料申请批处理归档开始 date= [{0}]", dateNow); //查询所有浇次号 sqlstr = " SELECT DISTINCT CAST_LOT_NO FROM TPMOMMABW01 WHERE FACTORY_DIV=‘LG2‘ AND CAST_LOT_NO<> ‘ ‘ "; Log::Trace("", __FUNCTION__, " sqlstr1= [{0}]", sqlstr); cmd.SetCommandText(sqlstr); cmd.ExecuteReader(); while (cmd.Read()) { cast_lot_no = cmd.GetString(1);//获取对应的浇次号 Log::Trace("", __FUNCTION__, "cast_lot_no= [{0}]", cast_lot_no); //根据浇次号查询该浇次是否炉次确定并且全部产出 sqlstr = "SELECT COUNT(*) FROM TPMOMMABW01 WHERE CAST_LOT_NO=‘"+cast_lot_no+"‘ AND HEAT_CONFM_FLAG<> ‘1‘ AND APP_STATUS NOT IN(‘11‘,‘12‘) "; Log::Trace("", __FUNCTION__, " sqlstr2= [{0}]", sqlstr); cmd2.SetCommandText(sqlstr); if (cmd2.ExecuteScalar() > 0)//未炉次确定或产出 { continue; } else { //当前浇次中炉次全部产出,归档处理 sqlstr = " SELECT * FROM TPMOMMABW01 WHERE CAST_LOT_NO=‘"+cast_lot_no+"‘ " ; cmd3.SetCommandText(sqlstr); cmd3.ExecuteReader(); while (cmd3.Read()) { tpmommabw01_inf.Reset(); cmd3.Fetch(tpmommabw01_inf); hpmommabw01.CopyFrom(tpmommabw01_inf); hpmommabw01.REC_CREATE_TIME = CDateTime::Now().ToString("yyyyMMddHHmmss"); hpmommabw01.REC_REVISE_TIME = CDateTime::Now().ToString("yyyyMMddHHmmss"); hpmommabw01.REC_CREATOR = s.svc_name; hpmommabw01.REC_REVISOR = s.svc_name;//获取当前service名称 hpmommabw01.Insert(); tpmommabw01_inf.Delete(); } cmd3.Close(); } } cmd.Close(); }