/******************************************************************************* * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential * 类的信息: * 1.程序名称:ConfigModuleLogicPartial.cs * 2.功能描述:成型线配置信息与数据库的交互类 * 编辑履历: * 作者 日期 版本 修改内容 * 庄天威 2014/09/13 1.00 新建 *******************************************************************************/ using System; using System.Collections.Generic; using System.Data; using Dongke.IBOSS.PRD.Basics.DataAccess; using Dongke.IBOSS.PRD.Service.DataModels; using Dongke.IBOSS.PRD.WCF.DataModels; using Oracle.ManagedDataAccess.Client; namespace Dongke.IBOSS.PRD.Service.PCModuleLogic { /// /// 成型线配置信息与数据库的交互类 /// public partial class PCModuleLogic { #region 成型线配置 /// /// 获得成型线信息 /// /// 成型线实体 /// 用户基本信息 /// 结果集Dataset /// /// 庄天威 2014.09.10 新建 /// public static DataSet GetGroutingLine(GroutingLineEntity groutingLineEntity, SUserInfo user) { IDBConnection con = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString); try { con.Open(); OracleParameter[] paras = new OracleParameter[]{ new OracleParameter("GroutingLineID",OracleDbType.Int32, groutingLineEntity.GROUTINGLINEID,ParameterDirection.Input), new OracleParameter("GroutingLineIDS",OracleDbType.NVarchar2, groutingLineEntity.GROUTINGLINEIDS,ParameterDirection.Input), new OracleParameter("BuildingNo",OracleDbType.NVarchar2, groutingLineEntity.BUILDINGNO,ParameterDirection.Input), new OracleParameter("FloorNo",OracleDbType.NVarchar2, groutingLineEntity.FLOORNO,ParameterDirection.Input), new OracleParameter("GroutingLineNo",OracleDbType.NVarchar2, groutingLineEntity.GROUTINGLINENO,ParameterDirection.Input), new OracleParameter("GroutingLineCode",OracleDbType.NVarchar2, groutingLineEntity.GROUTINGLINECODE,ParameterDirection.Input), new OracleParameter("GroutingLineName",OracleDbType.NVarchar2, groutingLineEntity.GROUTINGLINENAME,ParameterDirection.Input), new OracleParameter("GMouldTypeID",OracleDbType.Int32, groutingLineEntity.MOULDTYPEID,ParameterDirection.Input), new OracleParameter("BeginUsedDateStart",OracleDbType.Date, groutingLineEntity.BEGINUSEDDATE,ParameterDirection.Input), new OracleParameter("BeginUsedDateEnd",OracleDbType.Date, groutingLineEntity.BEGINUSEDDATEEND,ParameterDirection.Input), new OracleParameter("EndUsedDateStart",OracleDbType.Date, groutingLineEntity.ENDUSEDDATE,ParameterDirection.Input), new OracleParameter("EndUsedDateEnd",OracleDbType.Date, groutingLineEntity.ENDUSEDDATEEND,ParameterDirection.Input), new OracleParameter("GMouldStatus",OracleDbType.Int32, groutingLineEntity.MouldStatus,ParameterDirection.Input), new OracleParameter("remarks",OracleDbType.NVarchar2, groutingLineEntity.REMARKS,ParameterDirection.Input), new OracleParameter("AccountID",OracleDbType.Int32, user.AccountID,ParameterDirection.Input), //new OracleParameter("ValueFlag",OracleDbType.Int32, // groutingLineEntity.VALUEFLAG,ParameterDirection.Input), new OracleParameter("ValueFlag2",OracleDbType.Varchar2, groutingLineEntity.ValueFlag2,ParameterDirection.Input), new OracleParameter("UserId",OracleDbType.Int32, user.UserID,ParameterDirection.Input), new OracleParameter("PurviewType",OracleDbType.Int32, groutingLineEntity.Purview,ParameterDirection.Input), new OracleParameter("DailyTime",OracleDbType.Date, groutingLineEntity.DailyTime,ParameterDirection.Input), new OracleParameter("BindBarCodeflag",OracleDbType.Int32, groutingLineEntity.isYZJ,ParameterDirection.Input), new OracleParameter("BindBarCodeTime",OracleDbType.Date, groutingLineEntity.BindBarCodeTime,ParameterDirection.Input), new OracleParameter("BindBarCodeTimeEnd",OracleDbType.Date, groutingLineEntity.BindBarCodeTimeEnd,ParameterDirection.Input), new OracleParameter("rs_result",OracleDbType.RefCursor, ParameterDirection.Output), new OracleParameter("UserCode",OracleDbType.NVarchar2, groutingLineEntity.USERCODE,ParameterDirection.Input), }; //调用获取符合条件的成型线信息 DataSet ds = con.ExecStoredProcedure("PRO_PC_GetGroutingLine", paras); return ds; } catch (Exception ex) { throw ex; } finally { if (con.ConnState == ConnectionState.Open) { con.Close(); } } } /// /// 获得成型线明细 /// /// 成型线ID /// 成型线ID集 /// 权限类型 /// 用户基本信息 /// DataSet结果数据集 /// /// 庄天威 2014.09.11 新建 /// public static DataSet GetGroutingLineDetailByMainId(int groutingId, string groutingIds, int PurviewTypeId, SUserInfo user) { IDBConnection con = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString); try { con.Open(); int? UserId = null; if (PurviewTypeId != 0) { UserId = user.UserID; } //根据成型线ID获取成型线明细信息结果集 //第一个参数不为空获取单线明细 //第二个参数不为空获取N条线的明细 if (groutingId > 0) { OracleParameter[] paras = new OracleParameter[]{ new OracleParameter("GroutingLineID",OracleDbType.Int32, groutingId,ParameterDirection.Input), new OracleParameter("GroutingLineIDS",OracleDbType.NVarchar2, DBNull.Value,ParameterDirection.Input), new OracleParameter("AccountID",OracleDbType.Int32, user.AccountID,ParameterDirection.Input), new OracleParameter("PurviewTypeId",OracleDbType.Int32, PurviewTypeId,ParameterDirection.Input), new OracleParameter("UserID",OracleDbType.Int32, UserId,ParameterDirection.Input), new OracleParameter("rs_result",OracleDbType.RefCursor, ParameterDirection.Output), }; DataSet ds = con.ExecStoredProcedure("PRO_PC_GetGLineDetailByMainId", paras); DataSet ds2 = con.GetSqlResultToDs("select GMouldStatus,GMouldStatusName,OPTimeStamp from TP_PC_GroutingLine gl left join TP_SYS_GMouldStatus gms on gms.GMouldStatusID = gl.GMouldStatus where GroutingLineID=" + groutingId); if (ds2 != null && ds2.Tables[0].Rows.Count > 0) { ds2.Tables[0].TableName = "TP_PC_GroutingLine"; ds.Tables.Add(ds2.Tables[0].Copy()); } return ds; } else { OracleParameter[] paras = new OracleParameter[]{ new OracleParameter("GroutingLineID",OracleDbType.Int32, DBNull.Value,ParameterDirection.Input), new OracleParameter("GroutingLineIDS",OracleDbType.NVarchar2, groutingIds,ParameterDirection.Input), new OracleParameter("AccountID",OracleDbType.Int32, user.AccountID,ParameterDirection.Input), new OracleParameter("PurviewTypeId",OracleDbType.Int32, PurviewTypeId,ParameterDirection.Input), new OracleParameter("UserID",OracleDbType.Int32, user.UserID,ParameterDirection.Input), new OracleParameter("rs_result",OracleDbType.RefCursor, ParameterDirection.Output), }; DataSet ds = con.ExecStoredProcedure("PRO_PC_GetGLineDetailByMainId", paras); DataSet ds2 = con.GetSqlResultToDs("select GMouldStatus,GMouldStatusName,OPTimeStamp from TP_PC_GroutingLine gl left join TP_SYS_GMouldStatus gms on gms.GMouldStatusID = gl.GMouldStatus where GroutingLineID=" + groutingId); if (ds2 != null && ds2.Tables[0].Rows.Count > 0) { ds2.Tables[0].TableName = "TP_PC_GroutingLine"; ds.Tables.Add(ds2.Tables[0].Copy()); } return ds; } } catch (Exception ex) { throw ex; } finally { if (con.ConnState == ConnectionState.Open) { con.Close(); } } } /// /// 获得注浆模具换修履历 /// /// 成型线ID /// 明细ID /// 履历创建时间开始 /// 履历创建时间结束 /// 用户基本kd信息 /// DataSet结果集 /// /// 庄天威 2014.09.11 新建 /// public static DataSet GetMouldRecordByMainId(int? groutingId, int? detailId, DateTime? TimeStart, DateTime? TimeEnd, SUserInfo user) { IDBConnection con = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString); try { con.Open(); OracleParameter[] paras = new OracleParameter[]{ new OracleParameter("GroutingLineID",OracleDbType.Int32, groutingId,ParameterDirection.Input), new OracleParameter("GroutingLineDetailId",OracleDbType.Int32, detailId,ParameterDirection.Input), new OracleParameter("AccountID",OracleDbType.Int32, user.AccountID,ParameterDirection.Input), new OracleParameter("TimeStart",OracleDbType.NVarchar2, TimeStart,ParameterDirection.Input), new OracleParameter("TimeEnd",OracleDbType.NVarchar2, TimeEnd,ParameterDirection.Input), new OracleParameter("rs_result",OracleDbType.RefCursor, ParameterDirection.Output), }; //调用获取模具换修履历的存储过程 DataSet ds = con.ExecStoredProcedure("PRO_PC_GetMouldRecordByMainId", paras); return ds; } catch (Exception ex) { throw ex; } finally { if (con.ConnState == ConnectionState.Open) { con.Close(); } } } /// /// 获得注浆模具履历 /// /// 成型线ID /// 明细ID /// 履历创建时间开始 /// 履历创建时间结束 /// 用户基本信息 /// DataSet结果集 /// /// 庄天威 2014.09.11 新建 /// public static DataSet GetMouldHistoryByMainId(int? groutingId, int? detailId, DateTime? TimeStart, DateTime? TimeEnd, SUserInfo user) { IDBConnection con = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString); try { con.Open(); OracleParameter[] paras = new OracleParameter[]{ new OracleParameter("GroutingLineID",OracleDbType.Int32, groutingId,ParameterDirection.Input), new OracleParameter("GroutingLineDetailId",OracleDbType.Int32, detailId,ParameterDirection.Input), new OracleParameter("AccountID",OracleDbType.Int32, user.AccountID,ParameterDirection.Input), new OracleParameter("TimeStart",OracleDbType.NVarchar2, TimeStart,ParameterDirection.Input), new OracleParameter("TimeEnd",OracleDbType.NVarchar2, TimeEnd,ParameterDirection.Input), new OracleParameter("rs_result",OracleDbType.RefCursor, ParameterDirection.Output), }; //调用获取模具履历的存储过程 DataSet ds = con.ExecStoredProcedure("PRO_PC_GetMouldHistoryByMainId", paras); return ds; } catch (Exception ex) { throw ex; } finally { if (con.ConnState == ConnectionState.Open) { con.Close(); } } } /// /// 获取变产信息 /// /// 条件实体 /// 用户信息 /// 返回结果集 public static DataSet GetLineChange(GetLineChangeEntity glcEntity, SUserInfo userInfo) { IDBConnection con = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString); try { con.Open(); OracleParameter[] paras = new OracleParameter[]{ new OracleParameter("In_AccountID",OracleDbType.Int32, userInfo.AccountID,ParameterDirection.Input), new OracleParameter("In_BuildingNo",OracleDbType.NVarchar2, glcEntity.BuildingNo,ParameterDirection.Input), new OracleParameter("In_FloorNo",OracleDbType.NVarchar2, glcEntity.FloorNo,ParameterDirection.Input), new OracleParameter("In_GroutingLineNo",OracleDbType.NVarchar2, glcEntity.GroutingLineNo,ParameterDirection.Input), new OracleParameter("In_GroutingLineCode",OracleDbType.NVarchar2, glcEntity.GroutingLineCode,ParameterDirection.Input), new OracleParameter("In_BeginDate",OracleDbType.Date, glcEntity.BeginDate,ParameterDirection.Input), new OracleParameter("In_EndDate",OracleDbType.Date, glcEntity.EndDate,ParameterDirection.Input), new OracleParameter("In_GoodsCodeB",OracleDbType.NVarchar2, glcEntity.GoodsCodeB,ParameterDirection.Input), new OracleParameter("In_GoodsCodeA",OracleDbType.NVarchar2, glcEntity.GoodSCodeA,ParameterDirection.Input), new OracleParameter("Out_Result",OracleDbType.RefCursor, ParameterDirection.Output), }; //调用获取模具履历的存储过程 DataSet ds = con.ExecStoredProcedure("PRO_RPT_GetLineChange", paras); return ds; } catch (Exception ex) { throw ex; } finally { if (con.ConnState == ConnectionState.Open) { con.Close(); } } } #endregion public static DataSet GetGroutingLineUserDetailByMainId(int GroutingLineID) { IDBConnection con = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString); try { con.Open(); string strSql = " select TP_PC_GroutingUser.Remarks as REMARK,tp_mst_user.userid,tp_mst_user.usercode,tp_mst_user.username "+ " ,(select listagg(to_char(s.staffname), ',') within GROUP(ORDER BY s.staffcode) staffnames "+ " from tp_mst_userstaff us "+ " inner join tp_hr_staff s "+ " on s.staffid = us.staffid "+ " where us.userid = tp_mst_user.userid) staffnames " + " from TP_PC_GroutingUser left join tp_mst_user on TP_PC_GroutingUser.userid=tp_mst_user.userid where TP_PC_GroutingUser.GroutingLineID=:GroutingLineID"; OracleParameter[] paras = new OracleParameter[]{ new OracleParameter(":GroutingLineID",OracleDbType.Int32,GroutingLineID,ParameterDirection.Input), }; DataSet ds = con.GetSqlResultToDs(strSql, paras); if (ds != null && ds.Tables[0].Rows.Count > 0) // 有在产信息 { return ds; } return null; } catch (Exception ex) { throw ex; } finally { if (con.ConnState == ConnectionState.Open) { con.Close(); } } } /// /// 成型线模具履历‘’ /// /// /// public static DataSet GetGMouldRecordInfoByMainId(GMouldRecordEntity entity) { IDBConnection con = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString); try { con.Open(); // string strSql = @" select // TP_PC_GMouldRecord.GroutingMouldCode, // tp_mst_goods.goodscode, // TP_PC_GMouldRecord.GroutingCount, // decode(TP_PC_GMouldRecord.GMouldRecordType,'0','停用','1','维修','3','换模','5','变产','6','整线变产') as GMouldRecordType, // TP_PC_GMouldRecord.BeginDate, // TP_PC_GMouldRecord.EndDate, // TP_PC_GMouldRecord.Remarks, // a.goodsCode as ChangeGoodsCode, // TP_PC_GroutingLine.GroutingLineCode // from TP_PC_GMouldRecord // left join tp_mst_goods // on TP_PC_GMouldRecord.goodsid=tp_mst_goods.goodsid // left join tp_mst_goods a // on TP_PC_GMouldRecord.ChangedGoodsID=a.goodsid // left join TP_PC_GroutingLine // on TP_PC_GroutingLine.GroutingLineID=TP_PC_GMouldRecord.GroutingLineID // where TP_PC_GMouldRecord.GroutingLineID=:GroutingLineID"; string strSql = "SELECT decode(gmr.GMouldRecordType,\n" + " '6',\n" + " gdd.groutingmouldcode,\n" + " gmr.GroutingMouldCode) GroutingMouldCode\n" + " ,decode(gmr.GMouldRecordType,\n" + " '6',\n" + " gddgoods.goodscode,\n" + " goods.goodscode) goodscode\n" + " ,decode(gmr.GMouldRecordType,\n" + " '6',\n" + " gdd.GroutingCount,\n" + " gmr.GroutingCount) GroutingCount\n" + " ,decode(gmr.GMouldRecordType,\n" + " '0',\n" + " '停用',\n" + " '1',\n" + " '维修',\n" + " '3',\n" + " '换模',\n" + " '5',\n" + " '变产',\n" + " '6',\n" + " '整线变产') AS GMouldRecordType\n" + " ,gmr.BeginDate\n" + " ,gmr.EndDate\n" + " ,gmr.Remarks\n" + " ,aftergoods.goodsCode AS ChangeGoodsCode\n" + " ,gl.GroutingLineCode\n" + " ,decode(gdd.groutinglinedetailID,null,gmrm.MouldBarcode,glm.MouldBarcode) MouldBarcode\n" + " FROM TP_PC_GMouldRecord gmr\n" + " LEFT JOIN tp_pc_groutinglinedetail gdd\n" + " ON gdd.lastgmouldrecordid = gmr.gmouldrecordid\n" + " AND gdd.gmouldstatus = 4\n" + " AND gmr.gmouldrecordtype = 6\n" + " LEFT JOIN tp_pc_mould glm\n" + " ON gdd.MouldSource = '1' and glm.mouldcode = gdd.mouldcode\n" + " LEFT JOIN tp_pc_mould gmrm\n" + " ON gmrm.mouldcode = gmr.mouldcode\n" + " LEFT JOIN tp_mst_goods gddgoods\n" + " ON gdd.GoodsID = gddgoods.goodsid\n" + " LEFT JOIN tp_mst_goods goods\n" + " ON gmr.goodsid = goods.goodsid\n" + " LEFT JOIN tp_mst_goods aftergoods\n" + " ON gmr.ChangedGoodsID = aftergoods.goodsid\n" + " LEFT JOIN TP_PC_GroutingLine gl\n" + " ON gl.GroutingLineID = gmr.GroutingLineID\n" + " WHERE gmr.GroutingLineID = :GroutingLineID"; List parameters = new List(); parameters.Add(new OracleParameter(":GroutingLineID", OracleDbType.Int32, entity.GROUTINGLINEID, ParameterDirection.Input)); if (entity.BEGINDATE != null) { //strSql = strSql + " AND TP_PC_GMouldRecord.BeginDate>= :BeginDate "; //parameters.Add(new OracleParameter(":BeginDate", OracleDbType.Date, entity.BEGINDATE, ParameterDirection.Input)); //strSql = strSql + " AND TP_PC_GMouldRecord.EndDate<= :EndDate "; //parameters.Add(new OracleParameter(":EndDate", OracleDbType.Date, entity.ENDDATE, ParameterDirection.Input)); strSql = strSql + " AND gmr.BeginDate>= :BeginDate "; parameters.Add(new OracleParameter(":BeginDate", OracleDbType.Date, entity.BEGINDATE, ParameterDirection.Input)); strSql = strSql + " AND gmr.BeginDate<= :EndDate "; parameters.Add(new OracleParameter(":EndDate", OracleDbType.Date, entity.ENDDATE, ParameterDirection.Input)); } if (entity.BEGINDATE2 != null) { strSql = strSql + " AND gmr.EndDate>= :BeginDate2"; parameters.Add(new OracleParameter(":BeginDate2", OracleDbType.Date, entity.BEGINDATE2, ParameterDirection.Input)); strSql = strSql + " AND gmr.EndDate<=:EndDate2 "; parameters.Add(new OracleParameter(":EndDate2", OracleDbType.Date, entity.ENDDATE2, ParameterDirection.Input)); } if (!string.IsNullOrEmpty(entity.GROUTINGMOULDCODE)) { //strSql = strSql + " AND instr(','||:GroutingMouldCode||',',','||TP_PC_GMouldRecord.GroutingMouldCode||',')>0 "; strSql = strSql + " AND instr(gmr.GroutingMouldCode,:GroutingMouldCode) >0 "; parameters.Add(new OracleParameter(":GroutingMouldCode", OracleDbType.NVarchar2, entity.GROUTINGMOULDCODE, ParameterDirection.Input)); } if (!string.IsNullOrEmpty(entity.REMARKS)) { //instr(TP_PM_ProductionData.remarks,:remarks) >0) strSql = strSql + " AND instr(gmr.remarks,:REMARKS) >0 "; //strSql = strSql + " AND instr(','||:REMARKS||',',','||TP_PC_GMouldRecord.REMARKS||',')>0 "; parameters.Add(new OracleParameter(":REMARKS", OracleDbType.NVarchar2, entity.REMARKS, ParameterDirection.Input)); } if (entity.GMouldRecordType != null) { strSql = strSql + " AND gmr.GMouldRecordType=:GMouldRecordType "; parameters.Add(new OracleParameter(":GMouldRecordType", OracleDbType.Int32, entity.GMouldRecordType, ParameterDirection.Input)); } strSql = strSql + " order by GMouldRecordID desc, decode(gmr.GMouldRecordType, '6', gdd.groutingmouldcode, gmr.GroutingMouldCode)"; DataSet ds = con.GetSqlResultToDs(strSql, parameters.ToArray()); if (ds != null && ds.Tables[0].Rows.Count > 0) // { return ds; } return null; } catch (Exception ex) { throw ex; } finally { if (con.ConnState == ConnectionState.Open) { con.Close(); } } } } }