|
|
using System.Collections;
|
|
|
using Estsh.Core.Util;
|
|
|
using Estsh.Core.Repository.IRepositories;
|
|
|
using Estsh.Core.Services.IServices;
|
|
|
using Estsh.Core.Models;
|
|
|
using Estsh.Core.Model.Result;
|
|
|
using Estsh.Core.IRepositories;
|
|
|
using Estsh.Core.Dapper;
|
|
|
|
|
|
/***************************************************************************************************
|
|
|
*
|
|
|
* 更新人:sitong.dong
|
|
|
* 描述:库位管理
|
|
|
* 修改时间:2022.06.22
|
|
|
* 修改日志:系统迭代升级
|
|
|
*
|
|
|
**************************************************************************************************/
|
|
|
namespace Estsh.Core.Services
|
|
|
{
|
|
|
public class WarehouseDefineService : BaseService<SysWarehouse>, IWarehouseDefineService
|
|
|
{
|
|
|
private readonly IWarehouseDefineRepository repository;
|
|
|
public WarehouseDefineService(IWarehouseDefineRepository _repository) : base(_repository)
|
|
|
{
|
|
|
repository = _repository;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 根据分页条件获取分页菜单数据
|
|
|
/// </summary>
|
|
|
/// <param name="menuName"></param>
|
|
|
/// <param name="pager"></param>
|
|
|
/// <param name="direction"></param>
|
|
|
/// <param name="sort"></param>
|
|
|
/// <returns></returns>
|
|
|
public Hashtable getWarehouseListByPage(string warehouseName, string warehouseDesc, string enabled,int factoryId, Pager pager, String direction, String sort)
|
|
|
{
|
|
|
Hashtable result = new Hashtable();
|
|
|
|
|
|
String strWhere = " 1=1 ";
|
|
|
if (warehouseName != null && !warehouseName.Trim().Equals(""))
|
|
|
{
|
|
|
strWhere += "and warehouse_name like '%" + warehouseName.Trim() + "%'";
|
|
|
}
|
|
|
if (warehouseDesc != null && !warehouseDesc.Trim().Equals(""))
|
|
|
{
|
|
|
strWhere += "and warehouse_desc like '%" + warehouseDesc.Trim() + "%'";
|
|
|
}
|
|
|
if (enabled != null && !enabled.Trim().Equals(""))
|
|
|
{
|
|
|
strWhere += "and a.enabled like '%" + enabled.Trim() + "%'";
|
|
|
}
|
|
|
strWhere += " and a.factory_id = " + factoryId + " ";
|
|
|
String orderBy = "";
|
|
|
if (sort != null && !"".Equals(sort.Trim()))
|
|
|
{
|
|
|
orderBy += typeof(SysWarehouse).GetEntityColumnName(sort.Trim()) + " " + direction;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
orderBy += typeof(SysWarehouse).GetEntityColumnName("WarehouseId") + " " + direction;
|
|
|
}
|
|
|
|
|
|
result = repository.getListByPage(pager.pageSize, pager.pageNo, strWhere, orderBy);
|
|
|
return result;
|
|
|
}
|
|
|
public SysWarehouse getWarehouseByExistName(string warehouseName)
|
|
|
{
|
|
|
return repository.getWarehouseByExistName(warehouseName);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取下拉框中的菜单数据
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
public List<KeyValueResult> getSelectFactory()
|
|
|
{
|
|
|
return repository.getSelectFactory();
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 保存菜单数据
|
|
|
/// </summary>
|
|
|
/// <param name="htParams"></param>
|
|
|
/// <returns></returns>
|
|
|
public int saveWarehouse(SysWarehouse htParams)
|
|
|
{
|
|
|
return repository.saveWarehouse(htParams);
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 更新菜单数据
|
|
|
/// </summary>
|
|
|
/// <param name="htParams"></param>
|
|
|
/// <returns></returns>
|
|
|
public int updateWarehouse(SysWarehouse htParams)
|
|
|
{
|
|
|
return repository.updateWarehouse(htParams);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 查看菜单详情
|
|
|
/// </summary>
|
|
|
/// <param name="ruid"></param>
|
|
|
/// <returns></returns>
|
|
|
public Hashtable getWarehouseDetail(String warehouse_id)
|
|
|
{
|
|
|
warehouse_id = " warehouse_id = " + warehouse_id;
|
|
|
List<SysWarehouse> dt = repository.getList(warehouse_id, "");
|
|
|
Hashtable result = new Hashtable();
|
|
|
result.Add("warehouseId", dt[0].WarehouseId);
|
|
|
result.Add("factoryId", dt[0].FactoryId);
|
|
|
result.Add("factoryName", dt[0].FactoryName);
|
|
|
result.Add("warehouseName", dt[0].WarehouseName);
|
|
|
result.Add("warehouseDesc", dt[0].WarehouseDesc);
|
|
|
result.Add("enabled", dt[0].Enabled);
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 启用
|
|
|
/// </summary>
|
|
|
/// <param name="ids"></param>
|
|
|
/// <returns></returns>
|
|
|
public int EnableWarehouse(String ids)
|
|
|
{
|
|
|
String[] idArray = ids.Split(',');
|
|
|
int count = 0;
|
|
|
foreach (String id in idArray)
|
|
|
{
|
|
|
if (!"".Equals(id))
|
|
|
{
|
|
|
count += this.repository.EnableWarehouse(id);
|
|
|
}
|
|
|
}
|
|
|
return count;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 禁用
|
|
|
/// </summary>
|
|
|
/// <param name="ids"></param>
|
|
|
/// <returns></returns>
|
|
|
public int DisableWarehouse(String ids)
|
|
|
{
|
|
|
String[] idArray = ids.Split(',');
|
|
|
int count = 0;
|
|
|
foreach (String id in idArray)
|
|
|
{
|
|
|
if (!"".Equals(id))
|
|
|
{
|
|
|
count += this.repository.DisableWarehouse(id);
|
|
|
}
|
|
|
}
|
|
|
return count;
|
|
|
}
|
|
|
}
|
|
|
} |