using HH.WMS.Entitys.Algorithm;
using HH.WMS.Entitys.Basic;
using HH.WMS.Entitys.Common;
using HW.Utility.Data;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Common;
using System.Linq;
using System.Text;
namespace HW.DAL
{
///
/// 货位表数据处理层
///
///
/// [HanHe(XDL)] CREATED 2018/06/13
public class TN_AB_STOCK_LOCATIONDAL:BaseDAL
{
#region 获取货位集合
///
/// 根据表名获取货位集合
///
/// 表名
/// 货位集合
/// [HanHe(XDL)] CREATED 2018/06/12
public List GetStockLocationList(string tableName)
{
string sql = @"SELECT CN_S_STOCK_CODE
,CN_S_LOCATION_CODE
,CN_N_MAX_STORE_NUM
,CN_C_IS_DO_PARTITION
,CN_S_NOTE
,CN_C_IS_ENABLE
,CN_S_ROADWAY
,CN_S_ROW
,CN_S_COL
,CN_S_FLOOR
,CN_S_TYPE
,CN_N_AGV_LOCATION
,CN_S_CREATOR
,CN_S_CREATOR_BY
,S.CN_T_CREATE
,CN_S_MODIFY
,CN_S_MODIFY_BY
,CN_T_MODIFY
,CN_S_POSITION
,CN_GUID
,CN_S_STATUS
,CN_S_LOCATION_STATE
,CN_S_LOCATION_NAME
,CN_S_AREA_CODE
FROM TN_AB_B_SYNCH_LOG L LEFT JOIN TN_AB_STOCK_LOCATION S
ON L.CN_S_GUID=S.CN_GUID
WHERE L.CN_S_TABLE_NAME='" + tableName + "' AND L.CN_N_OP_FLAG IN (1,2)";
DbCommand cmd = DataAccess.GetSqlStringCommand(sql);
List list = DataAccessExtensive.ExecuteListEntity(this.DataAccess, cmd, SetEntity);
return list;
}
///
/// 设置实体的各列
///
private void SetEntity(AutoBomLocationEntity entity, IDataReader reader)
{
SetEntityUti(entity, "CN_S_STOCK_CODE", "CN_S_STOCK_CODE", reader);
SetEntityUti(entity, "CN_S_LOCATION_CODE", "CN_S_LOCATION_CODE", reader);
SetEntityUti(entity, "CN_N_MAX_STORE_NUM", "CN_N_MAX_STORE_NUM", reader);
SetEntityUti(entity, "CN_C_IS_DO_PARTITION", "CN_C_IS_DO_PARTITION", reader);
SetEntityUti(entity, "CN_S_NOTE", "CN_S_NOTE", reader);
SetEntityUti(entity, "CN_C_IS_ENABLE", "CN_C_IS_ENABLE", reader);
SetEntityUti(entity, "CN_S_ROADWAY", "CN_S_ROADWAY", reader);
SetEntityUti(entity, "CN_S_ROW", "CN_S_ROW", reader);
SetEntityUti(entity, "CN_S_COL", "CN_S_COL", reader);
SetEntityUti(entity, "CN_S_FLOOR", "CN_S_FLOOR", reader);
SetEntityUti(entity, "CN_S_TYPE", "CN_S_TYPE", reader);
SetEntityUti(entity, "CN_N_AGV_LOCATION", "CN_N_AGV_LOCATION", reader);
SetEntityUti(entity, "CN_S_CREATOR", "CN_S_CREATOR", reader);
SetEntityUti(entity, "CN_S_CREATOR_BY", "CN_S_CREATOR_BY", reader);
SetEntityUti(entity, "CN_T_CREATE", "CN_T_CREATE", reader);
SetEntityUti(entity, "CN_S_MODIFY", "CN_S_MODIFY", reader);
SetEntityUti(entity, "CN_S_MODIFY_BY", "CN_S_MODIFY_BY", reader);
SetEntityUti(entity, "CN_T_MODIFY", "CN_T_MODIFY", reader);
SetEntityUti(entity, "CN_S_POSITION", "CN_S_POSITION", reader);
SetEntityUti(entity, "CN_GUID", "CN_GUID", reader);
SetEntityUti(entity, "CN_S_STATUS", "CN_S_STATUS", reader);
SetEntityUti(entity, "CN_S_LOCATION_STATE", "CN_S_LOCATION_STATE", reader);
SetEntityUti(entity, "CN_S_LOCATION_NAME", "CN_S_LOCATION_NAME", reader);
SetEntityUti(entity, "CN_S_AREA_CODE", "CN_S_AREA_CODE", reader);
}
#endregion
///
/// 获得货位集合
///
///
///
///
/// [HanHe(XDL)] CREATED 2018/06/28
public List GetLocationList(string strWhere, string OrderBy)
{
List list = new List();
string strSql = @"SELECT CN_S_STOCK_CODE
,CN_S_LOCATION_CODE
,CN_N_MAX_STORE_NUM
,CN_C_IS_DO_PARTITION
,CN_S_NOTE
,CN_C_IS_ENABLE
,CN_S_ROADWAY
,CN_S_ROW
,CN_S_COL
,CN_S_FLOOR
,CN_S_TYPE
,CN_N_AGV_LOCATION
,CN_S_CREATOR
,CN_S_CREATOR_BY
,CN_T_CREATE
,CN_S_MODIFY
,CN_S_MODIFY_BY
,CN_T_MODIFY
,CN_S_POSITION
,CN_GUID
,CN_S_STATUS
,CN_S_AREA_CODE
,CN_N_SYNC
,CN_S_LOCATION_NAME
,CN_S_LOCATION_STATE FROM TN_AB_STOCK_LOCATION WHERE 1=1 ";
if (!string.IsNullOrEmpty(strWhere))
{
strSql += " " + strWhere;
}
if (!string.IsNullOrEmpty(OrderBy))
{
strSql += " " + OrderBy;
}
try
{
DbCommand cmd = DataAccess.GetSqlStringCommand(strSql);
list = DataAccessExtensive.ExecuteListEntity(this.DataAccess, cmd, SetLocationEntity);
return list;
}
catch (Exception ex)
{
return list;
}
}
///
/// 设置实体的各列
///
private void SetLocationEntity(AutoBomLocationEntity entity, IDataReader reader)
{
SetEntityUti(entity, "CN_S_STOCK_CODE", "CN_S_STOCK_CODE", reader);
SetEntityUti(entity, "CN_S_LOCATION_CODE", "CN_S_LOCATION_CODE", reader);
SetEntityUti(entity, "CN_N_MAX_STORE_NUM", "CN_N_MAX_STORE_NUM", reader);
SetEntityUti(entity, "CN_C_IS_DO_PARTITION", "CN_C_IS_DO_PARTITION", reader);
SetEntityUti(entity, "CN_S_NOTE", "CN_S_NOTE", reader);
SetEntityUti(entity, "CN_C_IS_ENABLE", "CN_C_IS_ENABLE", reader);
SetEntityUti(entity, "CN_S_ROADWAY", "CN_S_ROADWAY", reader);
SetEntityUti(entity, "CN_S_ROW", "CN_S_ROW", reader);
SetEntityUti(entity, "CN_S_COL", "CN_S_COL", reader);
SetEntityUti(entity, "CN_S_FLOOR", "CN_S_FLOOR", reader);
SetEntityUti(entity, "CN_S_TYPE", "CN_S_TYPE", reader);
SetEntityUti(entity, "CN_N_AGV_LOCATION", "CN_N_AGV_LOCATION", reader);
SetEntityUti(entity, "CN_S_CREATOR", "CN_S_CREATOR", reader);
SetEntityUti(entity, "CN_S_CREATOR_BY", "CN_S_CREATOR_BY", reader);
SetEntityUti(entity, "CN_T_CREATE", "CN_T_CREATE", reader);
SetEntityUti(entity, "CN_S_MODIFY", "CN_S_MODIFY", reader);
SetEntityUti(entity, "CN_S_MODIFY_BY", "CN_S_MODIFY_BY", reader);
SetEntityUti(entity, "CN_T_MODIFY", "CN_T_MODIFY", reader);
SetEntityUti(entity, "CN_S_POSITION", "CN_S_POSITION", reader);
SetEntityUti(entity, "CN_GUID", "CN_GUID", reader);
SetEntityUti(entity, "CN_S_STATUS", "CN_S_STATUS", reader);
SetEntityUti(entity, "CN_S_LOCATION_STATE", "CN_S_LOCATION_STATE", reader);
SetEntityUti(entity, "CN_S_LOCATION_NAME", "CN_S_LOCATION_NAME", reader);
SetEntityUti(entity, "CN_S_AREA_CODE", "CN_S_AREA_CODE", reader);
SetEntityUti(entity, "CN_N_SYNC", "CN_N_SYNC", reader);
}
///
/// 修改货位同步状态
///
///
///
/// [HanHe(XDL)] CREATED 2018/06/28
public SqlExecuteResult UpdateLocationSync(string Where, string Set)
{
string sql = "UPDATE TN_AB_STOCK_LOCATION SET " + Set + " " + Where;
DbCommand cmd = DataAccess.GetSqlStringCommand(sql);
return ExecuteCommand(cmd, null);
}
}
}