using System; using System.Collections.Generic; using System.Linq; using System.Text; using WMS.IData;using Oracle.ManagedDataAccess.Client; using System.Data; using WMS.DBUtility; using WMS.Model.Base; using WMS.IData.IBase; using Oracle.ManagedDataAccess.Client; namespace WMS.SqlServerData.BaseData { public class StorageAreaLocationData :IStorageAreaLocation {//主键:仓库ID、库位ID /// /// 根据库位获取高度 /// /// /// public DataTable GetLocHgh(string locid,string STORAGE_ID) { string sqlStr = " select LOCATION_HEIGHT from T_BASE_STORAGE_AREA_LOCATION where LOCATION_ID='" + locid+ "' and STORAGE_ID='"+ STORAGE_ID + "'"; return SystemDataObject.Instance.GetDataTable(sqlStr); } public void UpdateLocSts(string loc, string sts) { string sqlStr = "update T_BASE_STORAGE_AREA_LOCATION set STATUS='" + sts + "' where LOCATION_ID='" + loc + "' "; SystemDataObject.Instance.ExecuteSql(sqlStr); } /// /// 更改库位的容积,长,高 /// /// public void UpdateLoc(StorageAreaLocationModel mData) { string sqlStr = "update T_BASE_STORAGE_AREA_LOCATION " + "set LOCATION_LONG = '"+ mData .LOCATION_LONG+ "'," + " LOCATION_HEIGHT = '" + mData.LOCATION_HEIGHT + "', " + "LOCATION_WIDTH = '" + mData.LOCATION_WIDTH + "', " + "HASVOLUME = '" + mData.HASVOLUME + "', ABC_ID = '" + mData.ABC_ID + "', " + "BEARWEIGHT = '" + mData.BEARWEIGHT + "' where LOCATION_ID = '" + mData.LOCATION_ID + "' "; SystemDataObject.Instance.ExecuteSql(sqlStr); } public DataTable GetCtLocData(string STORAGE_ID,string locId ) { string sqlStr = "select count(*)a from T_BASE_STORAGE_AREA_LOCATION where STORAGE_ID ='"+ STORAGE_ID + "' and LOCATION_ID='"+locId+"' "; return SystemDataObject.Instance.GetDataTable(sqlStr); } public DataTable GetLocData(string decid, string row) { string sqlStr = @" select * from (select location_id,row1,cln,layer1, '2' as Status ,sort,decId,STORAGE_ID,LOCATION_HEIGHT,REMARK,depth from T_BASE_STORAGE_AREA_LOCATION where location_id in (select location_id from T_MI_STOCK ) union all select location_id, row1, cln, layer1, Status, sort, decId,STORAGE_ID,LOCATION_HEIGHT,REMARK,depth from T_BASE_STORAGE_AREA_LOCATION where location_id not in (select location_id from T_MI_STOCK )) a"; // and layer='"+ row + "' return SystemDataObject.Instance.GetDataTable(sqlStr.ToString()); } public DataSet GetTableDecId(string decId,string STORAGE_ID) { string sqlStr =@" select * from t_base_storage_area_location where decid='"+decId+"';select sts from t_decname where decid='"+decId+ "' and STORAGE_ID='"+ STORAGE_ID + "'"; return SystemDataObject.Instance.GetDataSet(sqlStr); } public void UpdateAgeId(string STORAGE_AREA_ID,string locID) { string sqlstr =@"update T_BASE_STORAGE_AREA_LOCATION set STORAGE_AREA_ID='"+ STORAGE_AREA_ID + "' where LOCATION_ID='" + locID + "' "; SystemDataObject.Instance.ExecuteSql(sqlstr); } public DataTable GetLocationStatus(string hgh) { string sqlStr =@"select row1,cln,layer1,LOCATION_ID,LOCATION_HEIGHT from t_base_storage_area_location where status = '0' and LOCATION_HEIGHT >= " + hgh + " order by sort "; return SystemDataObject.Instance.GetDataTable(sqlStr); } /// /// 获取开始库位和结束库位 /// /// /// public DataTable GetLocationInfoBeginEnd(string staorgid,string strAreaInfoID) { string sqlStr =@"select t.location_id, t.sort,t.hasvolume,t.volume from t_base_storage_area_location t join T_BASE_LOC_AREA a on t.location_id = a.location_id where status = '0' and t.storage_id = '" + staorgid + "' and a.storage_area_id = '" + strAreaInfoID + "' order by convert(int,t.location_id) "; return SystemDataObject.Instance.GetDataTable(sqlStr); } /// /// 获取库位信息结果集 /// /// 库位信息 /// 库位信息结果集 public DataTable GetLocationInfoDS(StorageAreaLocationModel locationInfoModel) { StringBuilder sqlBuilder = new StringBuilder(); sqlBuilder.AppendLine("select "); sqlBuilder.AppendLine(" c.LOCATION_ID , --库位编号 "); //sqlBuilder.AppendLine(" c.location_name , --库位名称 "); //sqlBuilder.AppendLine(" c.location_short_name , --库位简称 "); sqlBuilder.AppendLine(" c.py_name , --拼音简称 "); sqlBuilder.AppendLine(" c.storage_id , --所属仓库 外键 "); //sqlBuilder.AppendLine(" c.storage_area_id , --所属库区 外键 "); sqlBuilder.AppendLine(" (case c.islock when '1' then '是' when '0' then '否' else '其他' end) islock , --有锁 0:否 1:是 "); sqlBuilder.AppendLine(" c.location_long , --长 "); sqlBuilder.AppendLine(" c.location_width , --宽 "); sqlBuilder.AppendLine(" c.location_height ,--高 "); sqlBuilder.AppendLine(" c.volume , --容积 "); sqlBuilder.AppendLine(" c.hasvolume , --已占用容积 "); sqlBuilder.AppendLine(" c.bearweight , --承载重量 "); sqlBuilder.AppendLine(" c.abc_id , --ABC分类 "); sqlBuilder.AppendLine(" c.sort , --排序 "); sqlBuilder.AppendLine(" (case c.status when '1' then '停用' when '0' then '正常' else '其他' end) status , --状态 0:正常 1:停用"); sqlBuilder.AppendLine(" ISNULL(c.remark,' ') remark ,--备注 "); sqlBuilder.AppendLine(" c.version , --版本号 "); sqlBuilder.AppendLine(" m.STORAGE_AREA_NAME , --所属库区 "); sqlBuilder.AppendLine(" b.STORAGE_NAME, --所属仓库 "); sqlBuilder.AppendLine(" c.operatorid, --操作人 "); sqlBuilder.AppendLine(" c.operatedate, --操作日期 "); sqlBuilder.AppendLine("c.row1,c.cln,c.layer1,a.STORAGE_AREA_ID from "); sqlBuilder.AppendLine(" T_BASE_STORAGE_AREA_LOCATION c left join T_BASE_LOC_AREA a on c.location_id = a.location_id "); sqlBuilder.AppendLine(" left join t_base_storageinfo b on c.storage_id = b.storage_id left join T_BASE_STORAGE_AREA m on c.STORAGE_ID=m.STORAGE_AREA_ID"); sqlBuilder.AppendLine("where "); sqlBuilder.AppendLine(" 1=1 "); if (!string.IsNullOrEmpty(locationInfoModel.LOCATION_ID)) { sqlBuilder.AppendLine(" and c.LOCATION_ID = '" + locationInfoModel.LOCATION_ID + "'"); } if (!string.IsNullOrEmpty(locationInfoModel.STORAGE_AREA_ID)) { //算上其子库区的库位 //string sqlStr =@"select b.storage_area_id from T_BASE_STORAGE_AREA a left join T_BASE_STORAGE_AREA b on a.storage_area_id = b.parent_id where a.storage_area_id = '" + locationInfoModel.STORAGE_AREA_ID + "'"; //DataTable temp = SystemDataObject.Instance.GetDataTable(sqlStr); //if (string.IsNullOrEmpty(temp.Rows[0][0].ToString())) //{ sqlBuilder.AppendLine(" and a.STORAGE_AREA_ID = '" + locationInfoModel.STORAGE_AREA_ID + "'"); //} //else { // sqlBuilder.AppendLine(" and (a.STORAGE_AREA_ID = '" + locationInfoModel.STORAGE_AREA_ID + "' or a.STORAGE_AREA_ID = '" + temp.Rows[0][0].ToString() + "' )"); //} } if (!string.IsNullOrEmpty(locationInfoModel.STATUS)) { sqlBuilder.AppendLine(" and c.STATUS = '" + locationInfoModel.STATUS + "'"); } sqlBuilder.AppendLine(" order by c.sort,c.storage_id,c.location_id"); return SystemDataObject.Instance.GetDataTable(sqlBuilder.ToString()); } /// /// 获取库位信息结果集 /// /// 库位信息 /// 库位信息结果集 public DataTable GetLocationInfoDS() { StringBuilder sqlBuilder = new StringBuilder(); sqlBuilder.AppendLine("select "); sqlBuilder.AppendLine(" c.location_id , --库位编号 "); //sqlBuilder.AppendLine(" c.location_name , --库位名称 "); //sqlBuilder.AppendLine(" c.location_short_name , --库位简称 "); sqlBuilder.AppendLine(" c.py_name , --拼音简称 "); sqlBuilder.AppendLine(" c.storage_id , --所属仓库 外键 "); //sqlBuilder.AppendLine(" c.storage_area_id , --所属库区 外键 "); sqlBuilder.AppendLine(" (case c.islock when '1' then '是' when '0' then '否' else '其他' end) islock , --有锁 0:否 1:是 "); sqlBuilder.AppendLine(" c.location_long , --长 "); sqlBuilder.AppendLine(" c.location_width , --宽 "); sqlBuilder.AppendLine(" c.location_height , --高 "); sqlBuilder.AppendLine(" c.volume , --容积 "); sqlBuilder.AppendLine(" c.hasvolume , --已占用容积 "); sqlBuilder.AppendLine(" c.bearweight , --承载重量 "); sqlBuilder.AppendLine(" c.abc_id , --ABC分类 "); sqlBuilder.AppendLine(" c.sort , --排序 "); sqlBuilder.AppendLine(" c.Status, --Status 0:正常 1:停用"); sqlBuilder.AppendLine(" ISNULL(c.remark,' ') remark ,--备注 "); sqlBuilder.AppendLine(" c.version , --版本号 "); //sqlBuilder.AppendLine(" a.STORAGE_AREA_NAME , --所属库区 "); sqlBuilder.AppendLine(" c.operatorid, --操作人 "); sqlBuilder.AppendLine(" c.operatedate , --操作日期 "); sqlBuilder.AppendLine(" c.row1, --所属仓库 "); sqlBuilder.AppendLine(" c.cln, --操作人 "); sqlBuilder.AppendLine(" c.layer1 , --操作日期 "); sqlBuilder.AppendLine(" c.decId, --所属仓库 "); sqlBuilder.AppendLine(" c.instand --操作人 "); sqlBuilder.AppendLine("from "); sqlBuilder.AppendLine(" T_BASE_STORAGE_AREA_LOCATION c "); sqlBuilder.AppendLine("where "); sqlBuilder.AppendLine(" 1=1 "); sqlBuilder.AppendLine(" order by c.STATUS desc,SORT"); return SystemDataObject.Instance.GetDataTable(sqlBuilder.ToString()); } public DataTable GetLocStsData(string decID) { string sqlStr = @"select * from (select islock,location_id,row1,cln,layer1, '2' as Status ,sort,decId,STORAGE_ID,LOCATION_HEIGHT,DEPTH from T_BASE_STORAGE_AREA_LOCATION where location_id in (select location_id from T_MI_STOCK ) union all select islock,location_id, row1, cln, layer1, Status, sort, decId,STORAGE_ID,LOCATION_HEIGHT,DEPTH from T_BASE_STORAGE_AREA_LOCATION where location_id not in (select location_id from T_MI_STOCK )) a order by a.cln asc, a.row1 asc,a.layer1 asc"; return SystemDataObject.Instance.GetDataTable(sqlStr.ToString()); } #region 插入或修改库位信息 public void UpdLocationInfo(StorageAreaLocationModel locationInfoModel) { string sqlstr =@"update T_BASE_STORAGE_AREA_LOCATION set py_name =:py_name , islock =:islock , location_long =:location_long , location_width =:location_width , location_height =:location_height , volume =:volume , hasvolume =:hasvolume , bearweight =:bearweight , abc_id =:abc_id , sort =:sort , status =:status , remark =:remark , version =:version , operatorid =:operatorid , operatedate =getdate() where storage_id =:storage_id and location_id =:location_id "; OracleParameter[] parameter = new OracleParameter[] { new OracleParameter(":py_name",OracleDbType.Varchar2), //new OracleParameter("storage_area_id",OracleDbType.Varchar2), new OracleParameter(":islock",OracleDbType.Varchar2), new OracleParameter(":location_long",OracleDbType.Decimal), new OracleParameter(":location_width",OracleDbType.Decimal), new OracleParameter(":location_height",OracleDbType.Decimal), new OracleParameter(":volume",OracleDbType.Decimal), new OracleParameter(":hasvolume",OracleDbType.Decimal), new OracleParameter(":bearweight",OracleDbType.Decimal), new OracleParameter(":abc_id",OracleDbType.Varchar2), new OracleParameter(":sort",OracleDbType.Decimal), new OracleParameter(":status",OracleDbType.Varchar2), new OracleParameter(":remark",OracleDbType.Varchar2), new OracleParameter(":version",OracleDbType.Varchar2), new OracleParameter(":operatorid",OracleDbType.Varchar2), new OracleParameter(":storage_id",OracleDbType.Varchar2), new OracleParameter(":location_id",OracleDbType.Varchar2) }; parameter[0].Value = locationInfoModel.PY_NAME; //parameter[2].Value = locationInfoModel.STORAGE_AREA_ID; parameter[1].Value = locationInfoModel.ISLOCK; parameter[2].Value = locationInfoModel.LOCATION_LONG; parameter[3].Value = locationInfoModel.LOCATION_WIDTH; parameter[4].Value = locationInfoModel.LOCATION_HEIGHT; parameter[5].Value = locationInfoModel.VOLUME; parameter[6].Value = locationInfoModel.HASVOLUME; parameter[7].Value = locationInfoModel.BEARWEIGHT; parameter[8].Value = locationInfoModel.ABC_ID; parameter[9].Value = locationInfoModel.SORT; parameter[10].Value = locationInfoModel.STATUS; parameter[11].Value = locationInfoModel.REMARK; parameter[12].Value = locationInfoModel.VERSION; parameter[13].Value = locationInfoModel.OPERATORID; parameter[14].Value = locationInfoModel.STORAGE_ID; parameter[15].Value = locationInfoModel.LOCATION_ID; SystemDataObject.Instance.ExecuteSql(sqlstr, parameter); } /// /// 插入或修改库位信息 /// /// 库位信息 /// flag 操作标示符 0:新增 1:修改 public void InsLocationInfo(StorageAreaLocationModel locationInfoModel) { string sqlstr = " insert into T_BASE_STORAGE_AREA_LOCATION" + " (location_id,py_name,storage_id,islock,location_long,location_width,location_height" + " ,volume,hasvolume,bearweight,abc_id,sort," + " status,remark,version,operatorid,decId,instand,outStand,inline,outLine,row1,cln,layer1)" + " values ( '" + locationInfoModel.LOCATION_ID + "', '" + locationInfoModel.PY_NAME + "','" + locationInfoModel.STORAGE_ID + "'," + " '" + locationInfoModel.ISLOCK + "' ,'" + locationInfoModel.LOCATION_LONG + "','" + locationInfoModel.LOCATION_WIDTH + "'," + " '" + locationInfoModel.LOCATION_HEIGHT + "', '" + locationInfoModel.VOLUME + "','" + locationInfoModel.HASVOLUME + "'," + " '" + locationInfoModel.BEARWEIGHT + "','" + locationInfoModel.ABC_ID + "', " + "'" + locationInfoModel.SORT + "','" + locationInfoModel.STATUS + "','" + locationInfoModel.REMARK + "','" + locationInfoModel.VERSION + "'," + "'" + locationInfoModel.OPERATORID + "','" + locationInfoModel.decId + "','" + locationInfoModel.instand + "','" + locationInfoModel.outStand + "'," + "'" + locationInfoModel.inline + "','" + locationInfoModel.outLine + "','" + locationInfoModel.row1 + "','" + locationInfoModel.cln + "','" + locationInfoModel.layer1 +"' )"; // OracleParameter[] parameter = new OracleParameter[] // { // new OracleParameter(":location_id",OracleDbType.Varchar2),//1 // new OracleParameter(":py_name",OracleDbType.Varchar2),//2 // new OracleParameter(":storage_id",OracleDbType.Varchar2),//3 // new OracleParameter(":islock",OracleDbType.Varchar2),//4 // new OracleParameter(":location_long",OracleDbType.Decimal),//5 // new OracleParameter(":location_width",OracleDbType.Decimal),//6 // new OracleParameter(":location_height",OracleDbType.Decimal), // new OracleParameter(":volume",OracleDbType.Decimal), // new OracleParameter(":hasvolume",OracleDbType.Decimal), // new OracleParameter(":bearweight",OracleDbType.Decimal), // new OracleParameter(":abc_id",OracleDbType.Varchar2), // new OracleParameter(":sort",OracleDbType.Decimal), // new OracleParameter(":status",OracleDbType.Varchar2), // new OracleParameter(":remark",OracleDbType.Varchar2), // new OracleParameter(":version",OracleDbType.Varchar2), //new OracleParameter(":operatorid",OracleDbType.Varchar2), // new OracleParameter(":decId",OracleDbType.Varchar2), // new OracleParameter(":instand",OracleDbType.Varchar2), // new OracleParameter(":outStand",OracleDbType.Varchar2), // new OracleParameter(":inline",OracleDbType.Varchar2), // new OracleParameter(":outLine",OracleDbType.Varchar2), // new OracleParameter(":row",OracleDbType.Varchar2), // new OracleParameter(":cln",OracleDbType.Varchar2), // new OracleParameter(":layer",OracleDbType.Varchar2) // }; // parameter[0].Value = locationInfoModel.LOCATION_ID; // parameter[1].Value = locationInfoModel.LOCATION_ID; // parameter[2].Value = locationInfoModel.STORAGE_ID; // parameter[3].Value = locationInfoModel.ISLOCK; // parameter[4].Value = locationInfoModel.LOCATION_LONG; // parameter[5].Value = locationInfoModel.LOCATION_WIDTH; // parameter[6].Value = locationInfoModel.LOCATION_HEIGHT; // parameter[7].Value = locationInfoModel.VOLUME; // parameter[8].Value = locationInfoModel.HASVOLUME; // parameter[9].Value = locationInfoModel.BEARWEIGHT; // parameter[10].Value = locationInfoModel.ABC_ID; // parameter[11].Value = locationInfoModel.SORT; // parameter[12].Value = locationInfoModel.STATUS; // parameter[13].Value = locationInfoModel.REMARK; // parameter[14].Value = locationInfoModel.VERSION; // parameter[15].Value = locationInfoModel.OPERATORID; // parameter[16].Value = locationInfoModel.decId; // parameter[17].Value = locationInfoModel.instand; // parameter[18].Value = locationInfoModel.outStand; // parameter[19].Value = locationInfoModel.inline; // parameter[20].Value = locationInfoModel.outLine; // parameter[21].Value = locationInfoModel.row1; // parameter[22].Value = locationInfoModel.cln; // parameter[23].Value = locationInfoModel.layer1; SystemDataObject.Instance.ExecuteSql(sqlstr); } #endregion #region 通过仓库ID、库位ID修改某库位已占用体积 /// /// 通过仓库ID、库位ID修改某库位已占用体积 /// /// 库位Model public void UpdateLocHasVolume(StorageAreaLocationModel locationInfoModel) { string sqlstr =@"update T_BASE_STORAGE_AREA_LOCATION set hasvolume=:hasvolume, operatorid=:operatorid, operatedate=getdate() where storage_id=:storage_id and location_id=:location_id"; OracleParameter[] parameter = new OracleParameter[] { new OracleParameter(":hasvolume",OracleDbType.Decimal), new OracleParameter(":operatorid",OracleDbType.Varchar2), new OracleParameter(":storage_id",OracleDbType.Varchar2), new OracleParameter(":location_id",OracleDbType.Varchar2), }; parameter[0].Value = locationInfoModel.HASVOLUME; parameter[1].Value = locationInfoModel.OPERATORID; parameter[2].Value = locationInfoModel.STORAGE_ID; parameter[3].Value = locationInfoModel.LOCATION_ID; SystemDataObject.Instance.ExecuteSql(sqlstr, parameter); } #endregion #region 根据库位编号、仓库编号删除库位信息 /// /// 根据库位编号、仓库编号删除库位信息 /// /// 库位编号 /// 仓库编号 public void DeleteLocationInfo(string strLocationInfoId, string strStorageInfoID) { string sqlstr =@"delete from T_BASE_STORAGE_AREA_LOCATION where location_id =:location_id and storage_id =:storage_id"; OracleParameter[] parameter = new OracleParameter[]{ new OracleParameter(":location_id",OracleDbType.Varchar2), new OracleParameter(":storage_id",OracleDbType.Varchar2), }; parameter[0].Value = strLocationInfoId; parameter[1].Value = strStorageInfoID; SystemDataObject.Instance.ExecuteSql(sqlstr, parameter); } #endregion /// /// 根据库区编号删除库位信息 /// /// 库区编号 public void DeleteLocationInfoByAreaInfoID(string strAreaInfoID) { string sqlstr =@"delete from T_BASE_STORAGE_AREA_LOCATION where location_id in (select location_id from t_base_loc_area where STORAGE_AREA_ID =:storage_area_id)"; OracleParameter[] parameter = new OracleParameter[]{ new OracleParameter(":storage_area_id",OracleDbType.Varchar2), }; parameter[0].Value = strAreaInfoID; SystemDataObject.Instance.ExecuteSql(sqlstr, parameter); } /// /// 根据仓库编号删除库位信息 /// /// 仓库编号 public void DeleteLocationInfoByStorageInfoID(string strStorageInfoID) { string sqlstr =@"delete from T_BASE_STORAGE_AREA_LOCATION where storage_id =:storage_id"; OracleParameter[] parameter = new OracleParameter[]{ new OracleParameter(":storage_id",OracleDbType.Varchar2), }; parameter[0].Value = strStorageInfoID; SystemDataObject.Instance.ExecuteSql(sqlstr, parameter); } /// /// 根据仓库编号停用或启用库位 /// /// 仓库编号 /// 0停用1正常 public void CloseLocationInfoByStorageInfoID(string strStorageInfoID,int flag) { string sqlstr =@"update T_BASE_STORAGE_AREA_LOCATION set status = '" + flag + "' where storage_id =:storage_id"; OracleParameter[] parameter = new OracleParameter[]{ new OracleParameter(":storage_id",OracleDbType.Varchar2), }; parameter[0].Value = strStorageInfoID; SystemDataObject.Instance.ExecuteSqlCommit(sqlstr, parameter); } /// /// 根据库区编号停用或启用库位 /// /// 库区编号 /// 0停用1正常 public void CloseLocationInfoByAreaInfoID(string strAreaInfoID, int flag) { string sqlstr =@"update T_BASE_STORAGE_AREA_LOCATION set status = '" + flag + "' where location_id in (select location_id from t_base_loc_area where STORAGE_AREA_ID =:storage_area_id)"; OracleParameter[] parameter = new OracleParameter[]{ new OracleParameter(":storage_area_id",OracleDbType.Varchar2), }; parameter[0].Value = strAreaInfoID; SystemDataObject.Instance.ExecuteSqlCommit(sqlstr, parameter); } /// /// 删除属于某仓库分类的库位信息 /// /// 某仓库分类 public void DeleteLocationInfoByStorageTypeID(string strStorageTypeID) { string sqlstr =@"delete from T_BASE_STORAGE_AREA_LOCATION where STORAGE_ID in ( select STORAGE_ID from T_BASE_STORAGEINFO where STORAGE_TYPE_ID =:STORAGE_TYPE_ID )"; OracleParameter[] parameter = new OracleParameter[]{ new OracleParameter(":STORAGE_TYPE_ID",OracleDbType.Varchar2), }; parameter[0].Value = strStorageTypeID; SystemDataObject.Instance.ExecuteSql(sqlstr, parameter); } } }