|
|
using Dapper;
|
|
|
using Estsh.Core.Dapper;
|
|
|
using Estsh.Core.Model.ExcelModel;
|
|
|
using Estsh.Core.Model.Result;
|
|
|
using Estsh.Core.Models;
|
|
|
using Estsh.Core.Repository.IRepositories;
|
|
|
using System.Collections;
|
|
|
using System.Data;
|
|
|
using System.Text;
|
|
|
|
|
|
/***************************************************************************************************
|
|
|
*
|
|
|
* 更新人:sitong.dong
|
|
|
* 描述:台车管理
|
|
|
* 修改时间:2022.12.13
|
|
|
* 修改日志:系统迭代升级
|
|
|
*
|
|
|
**************************************************************************************************/
|
|
|
namespace Estsh.Core.Repositories
|
|
|
{
|
|
|
/// <summary>
|
|
|
/// 数据访问类
|
|
|
/// </summary>
|
|
|
public class CarrierManageRepository : BaseRepository<WmsRack>, ICarrierManageRepository
|
|
|
{
|
|
|
public CarrierManageRepository(DapperDbContext _dapperDbContext) : base(_dapperDbContext)
|
|
|
{
|
|
|
}
|
|
|
#region 成员方法
|
|
|
/// <summary>
|
|
|
/// 获得菜单列表数据
|
|
|
/// </summary>
|
|
|
public List<WmsRack> getList(string strWhere, string filedOrder)
|
|
|
{
|
|
|
using (IDbConnection dbConn = dapperDbContext.GetDbConnection())
|
|
|
{
|
|
|
dbConn.Open();
|
|
|
|
|
|
StringBuilder strSql = new StringBuilder();
|
|
|
strSql.Append("select * from wms_rack");
|
|
|
if (!strWhere.Trim().Equals(""))
|
|
|
{
|
|
|
strSql.Append(" where " + strWhere);
|
|
|
}
|
|
|
List<WmsRack> result = dbConn.Query<WmsRack>(strSql.ToString()).ToList();
|
|
|
return result;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取分页数据列表
|
|
|
/// </summary>
|
|
|
public Hashtable getListByPage(int PageSize, int PageIndex, string strWhere, string OrderBy)
|
|
|
{
|
|
|
using (IDbConnection dbConn = dapperDbContext.GetDbConnection())
|
|
|
{
|
|
|
dbConn.Open();
|
|
|
Hashtable result = new Hashtable();
|
|
|
DynamicParameters Params = new DynamicParameters();
|
|
|
Params.Add("@TotalCount", 0, DbType.Int32, ParameterDirection.Output);
|
|
|
Params.Add("@TotalPage", 0, DbType.Int32, ParameterDirection.Output);
|
|
|
Params.Add("@GroupColumn", "");
|
|
|
Params.Add("@Table", "wms_rack a ");
|
|
|
Params.Add("@Column", "*");
|
|
|
Params.Add("@PageSize", PageSize);
|
|
|
Params.Add("@CurrentPage", PageIndex);
|
|
|
Params.Add("@Condition", strWhere);
|
|
|
Params.Add("@OrderColumn", OrderBy);
|
|
|
Params.Add("@Group", 0);
|
|
|
|
|
|
List<WmsRack> dataList = dbConn.Query<WmsRack>("Com_Pagination", Params, commandType: CommandType.StoredProcedure).ToList();
|
|
|
result.Add("dataList", dataList);
|
|
|
result.Add("totalCount", Params.Get<int>("@TotalCount"));
|
|
|
return result;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 插入菜单数据
|
|
|
/// </summary>
|
|
|
/// <param name="htParams"></param>
|
|
|
/// <returns></returns>
|
|
|
public int saveCarrier(WmsRack htParams)
|
|
|
{
|
|
|
using (IDbConnection dbConn = dapperDbContext.GetDbConnection())
|
|
|
{
|
|
|
dbConn.Open();
|
|
|
StringBuilder SqlStringBuilder = new StringBuilder(1024);
|
|
|
SqlStringBuilder.Append("INSERT INTO dbo.wms_rack(rack_no,rack_type,factory_id,factory_code,enabled,create_userid,create_time,guid) ");
|
|
|
SqlStringBuilder.Append(" VALUES(@rackNo,@rackType,@factoryId,@factoryCode,@enabled,@createUserid,CONVERT(varchar(50), GETDATE(), 21),@guid) ");
|
|
|
|
|
|
int result = dbConn.Execute(SqlStringBuilder.ToString(), htParams);
|
|
|
return result;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 更新菜单数据
|
|
|
/// </summary>
|
|
|
/// <param name="htParams"></param>
|
|
|
/// <returns></returns>
|
|
|
public int updateCarrier(WmsRack htParams)
|
|
|
{
|
|
|
using (IDbConnection dbConn = dapperDbContext.GetDbConnection())
|
|
|
{
|
|
|
dbConn.Open();
|
|
|
StringBuilder SqlStringBuilder = new StringBuilder(1024);
|
|
|
SqlStringBuilder.Append("UPDATE dbo.wms_rack ");
|
|
|
SqlStringBuilder.Append(" SET rack_no = @rackNo,rack_type = @rackType,factory_id = @factoryId ");
|
|
|
SqlStringBuilder.Append(" ,factory_code = @factoryCode,enabled = @enabled ");
|
|
|
SqlStringBuilder.Append(" ,update_userid = @updateUserid,update_time = CONVERT(varchar(50), GETDATE(), 21) ");
|
|
|
SqlStringBuilder.Append(" WHERE ruid=@ruid ");
|
|
|
|
|
|
int result = dbConn.Execute(SqlStringBuilder.ToString(), htParams);
|
|
|
return result;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public List<CarrierManage> ifCarrierManage(String rackNo)
|
|
|
{
|
|
|
using (IDbConnection dbConn = dapperDbContext.GetDbConnection())
|
|
|
{
|
|
|
dbConn.Open();
|
|
|
DynamicParameters htparams = new DynamicParameters();
|
|
|
htparams.Add("@rackNo", rackNo);
|
|
|
String delStr = "SELECT * FROM dbo.wms_rack WHERE rack_no=@rackNo ";
|
|
|
List<CarrierManage> result = dbConn.Query<CarrierManage>(delStr, htparams).ToList();
|
|
|
return result;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public List<CarrierManage> getExportList(string strWhere, string orderBy)
|
|
|
{
|
|
|
using (IDbConnection dbConn = dapperDbContext.GetDbConnection())
|
|
|
{
|
|
|
dbConn.Open();
|
|
|
String delStr = "SELECT * FROM dbo.wms_rack ";
|
|
|
if (string.IsNullOrEmpty(strWhere))
|
|
|
{
|
|
|
delStr += "where " + strWhere;
|
|
|
}
|
|
|
if (string.IsNullOrEmpty(orderBy))
|
|
|
{
|
|
|
delStr += orderBy;
|
|
|
}
|
|
|
|
|
|
List<CarrierManage> result = dbConn.Query<CarrierManage>(delStr).ToList();
|
|
|
return result;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//启用
|
|
|
public int EnableCarrier(String ruid)
|
|
|
{
|
|
|
using (IDbConnection dbConn = dapperDbContext.GetDbConnection())
|
|
|
{
|
|
|
dbConn.Open();
|
|
|
String delStr = "update wms_rack set Enabled='Y' WHERE ruid = @ruid";
|
|
|
DynamicParameters htparams = new DynamicParameters();
|
|
|
htparams.Add("@ruid", ruid);
|
|
|
int result = dbConn.Execute(delStr, htparams);
|
|
|
return result;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//禁用
|
|
|
public int DisableCarrier(String ruid)
|
|
|
{
|
|
|
using (IDbConnection dbConn = dapperDbContext.GetDbConnection())
|
|
|
{
|
|
|
dbConn.Open();
|
|
|
String delStr = "update wms_rack set Enabled='N' WHERE ruid = @ruid";
|
|
|
DynamicParameters htparams = new DynamicParameters();
|
|
|
htparams.Add("@ruid", ruid);
|
|
|
int result = dbConn.Execute(delStr, htparams);
|
|
|
return result;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//事务批量执行添加、修改
|
|
|
public bool InsertData(List<string> sqlStrings, List<DynamicParameters> parameterList)
|
|
|
{
|
|
|
using (IDbConnection dbConn = dapperDbContext.GetDbConnection())
|
|
|
{
|
|
|
if (dbConn.State == ConnectionState.Closed)
|
|
|
{
|
|
|
dbConn.Open();
|
|
|
}
|
|
|
//执行事务
|
|
|
IDbTransaction transaction = dbConn.BeginTransaction();
|
|
|
if (parameterList == null || parameterList.Count == 0)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
for (int i = 0; i < sqlStrings.Count; i++)
|
|
|
{
|
|
|
dbConn.Execute(sqlStrings[i], null, transaction);
|
|
|
}
|
|
|
transaction.Commit();
|
|
|
return true;
|
|
|
}
|
|
|
catch (Exception exception)
|
|
|
{
|
|
|
transaction.Rollback();
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
for (int i = 0; i < sqlStrings.Count; i++)
|
|
|
{
|
|
|
dbConn.Execute(sqlStrings[i], parameterList[i], transaction);
|
|
|
}
|
|
|
transaction.Commit();
|
|
|
return true;
|
|
|
}
|
|
|
catch (Exception exception)
|
|
|
{
|
|
|
transaction.Rollback();
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
#endregion 成员方法
|
|
|
}
|
|
|
}
|