using Aspose.Cells;
using Estsh.Core.Dapper;
using Estsh.Core.Model.ExcelModel;
using Estsh.Core.Model.Result;
using Estsh.Core.Models;
using Estsh.Core.Repository.IRepositories;
using Estsh.Core.Services.IServices;
using Estsh.Core.Util;
using System.Collections;
using System.Data;
using System.Text;
/***************************************************************************************************
*
* 更新人:sitong.dong
* 描述:料架信息模块业务处理类
* 修改时间:2022.06.22
* 修改日志:系统迭代升级
*
**************************************************************************************************/
namespace Estsh.Core.Services
{
///
/// 料架信息模块管理业务处理类
///
public class TrayService : BaseService, ITrayService
{
private readonly ITrayRepository repository;
public TrayService(ITrayRepository _repository) : base(_repository)
{
repository = _repository;
}
#region 料架信息管理
///
/// 根据分页条件获取料架信息列表
///
///
///
///
///
///
public Hashtable getTrayByPage(String tray_code, String tray_name, Pager pager, String direction, String sort)
{
Hashtable result = new Hashtable();
StringBuilder strWhere = new StringBuilder(1024);
strWhere.Append(" 1=1 ");
if (tray_code != null && !tray_code.Trim().Equals(""))
{
strWhere.Append(" and a.tray_code like '%" + tray_code.Trim() + "%'");
}
if (tray_name != null && !tray_name.Trim().Equals(""))
{
strWhere.Append(" and a.tray_name like '%" + tray_name.Trim() + "%'");
}
strWhere.Append(" and c.enum_type = 'g_tray_seq' AND a.Enabled = 'Y' ");
String orderBy = "";
if (sort != null && !"".Equals(sort.Trim()))
{
orderBy += typeof(GTray).GetEntityColumnName(sort.Trim()) + " " + direction;
}
else
{
orderBy += " a."+typeof(GTray).GetEntityColumnName("TrayId") + " " + direction;
}
result = repository.getTrayByPage(pager.pageSize, pager.pageNo, strWhere.ToString(), orderBy);
return result;
}
///
/// 根据分页条件获取料架信息列表
///
///
///
///
///
///
public Hashtable getTrayByPageToList(String tray_code, String tray_name, Pager pager, String direction, String sort)
{
StringBuilder strWhere = new StringBuilder(1024);
strWhere.Append(" 1=1 ");
if (tray_code != null && !tray_code.Trim().Equals(""))
{
strWhere.Append(" and a.tray_code like '%" + tray_code.Trim() + "%'");
}
if (tray_name != null && !tray_name.Trim().Equals(""))
{
strWhere.Append(" and a.tray_name like '%" + tray_name.Trim() + "%'");
}
strWhere.Append(" and c.enum_type = 'g_tray_seq' AND a.Enabled = 'Y' ");
String orderBy = "";
if (sort != null && !"".Equals(sort.Trim()))
{
orderBy += " a." + typeof(GTray).GetEntityColumnName(sort.Trim()) + " " + direction;
}
else
{
orderBy += " a." + typeof(GTray).GetEntityColumnName("TrayId") + " " + direction;
}
return repository.getTrayByPageToList(pager.pageSize, pager.pageNo, strWhere.ToString(), orderBy);
}
public Hashtable getTableListByPage(String tray_code, String tray_name, Pager pager, String direction, String sort)
{
StringBuilder strWhere = new StringBuilder(1024);
strWhere.Append(" 1=1 ");
if (tray_code != null && !tray_code.Trim().Equals(""))
{
strWhere.Append(" and a.tray_code like '%" + tray_code.Trim() + "%'");
}
if (tray_name != null && !tray_name.Trim().Equals(""))
{
strWhere.Append(" and a.tray_name like '%" + tray_name.Trim() + "%'");
}
strWhere.Append(" and c.enum_type = 'g_tray_seq' AND a.Enabled = 'Y' ");
String orderBy = "";
if (sort != null && !"".Equals(sort.Trim()))
{
orderBy += " a." + typeof(GTray).GetEntityColumnName(sort.Trim()) + " " + direction;
}
else
{
orderBy += " a." + typeof(GTray).GetEntityColumnName("TrayId") + " " + direction;
}
return repository.getTableListByPage(pager.pageSize, pager.pageNo, strWhere.ToString(), orderBy);
}
///
/// 获取料架类型列表
///
///
public List getTrayType()
{
return repository.getTrayType();
}
///
/// 保存料架信息数据
///
///
///
public int saveTrayInfo(GTray htParams)
{
return repository.saveTrayInfo(htParams);
}
///
/// 更新料架信息数据
///
///
///
public int updateTrayInfo(GTray htParams)
{
return repository.updateTrayInfo(htParams);
}
///
/// 根据trayid,获取Tray数据
///
///
///
public List GetTrayById(string tray_id)
{
return this.repository.GetTrayById(tray_id);
}
///
/// 删除料架信息信息
///
///
///
public int deleteTray(String ids)
{
String[] idArray = ids.Split(',');
int count = 0;
foreach (String id in idArray)
{
if (!"".Equals(id))
{
count += this.repository.deleteTray(id);
}
}
return count;
}
///
/// 启用
///
///
///
public int EnableData(String ids)
{
ids = ids.Substring(0, ids.Length - 1);
return this.repository.EnableData(ids);
}
///
/// 禁用
///
///
///
public int DisableData(String ids)
{
ids = ids.Substring(0, ids.Length - 1);
return this.repository.DisableData(ids);
}
///
/// 根据分页条件获取料架信息列表
///
///
///
///
///
///
public Hashtable getTrayDetailOfPager(String tray_id, Pager pager, String direction, String sort)
{
Hashtable result = new Hashtable();
StringBuilder strWhere = new StringBuilder(1024);
strWhere.Append(" 1=1 ");
if (tray_id != null && !tray_id.Trim().Equals(""))
{
strWhere.Append(" and a.tray_id =" + tray_id.Trim());
}
strWhere.Append(" AND a.Enabled = 'Y' ");
String orderBy = "";
if (sort != null && !"".Equals(sort.Trim()))
{
orderBy += " a." + typeof(GTrayDetail).GetEntityColumnName(sort.Trim()) + " " + direction;
}
else
{
orderBy += " a." + typeof(GTrayDetail).GetEntityColumnName("TrayLoc") + " " + direction;
}
result = repository.getTrayDetailOfPager(pager.pageSize, pager.pageNo, strWhere.ToString(), orderBy);
return result;
}
///
/// 根据分页条件获取料架信息列表
///
///
///
///
///
///
public Hashtable getTrayDetailToList(String tray_id, Pager pager, String direction, String sort)
{
StringBuilder strWhere = new StringBuilder(1024);
strWhere.Append(" 1=1 ");
if (tray_id != null && !tray_id.Trim().Equals(""))
{
strWhere.Append(" and a.tray_id =" + tray_id.Trim());
}
strWhere.Append(" AND a.Enabled = 'Y' ");
String orderBy = "";
if (sort != null && !"".Equals(sort.Trim()))
{
orderBy += " a." + typeof(GTrayDetail).GetEntityColumnName(sort.Trim()) + " " + direction;
}
else
{
orderBy += " a." + typeof(GTrayDetail).GetEntityColumnName("TrayLoc") + " " + direction;
}
return repository.getTrayDetailToList(pager.pageSize, pager.pageNo, strWhere.ToString(), orderBy);
}
///
/// 根据guid,获取Tray明细数据
///
///
///
public List GetTrayDetailByGuid(string guid)
{
return this.repository.GetTrayDetailByGuid(guid);
}
///
/// 保存料架明细信息数据
///
///
///
public int saveTrayDetailInfo(GTrayDetail htParams)
{
return repository.saveTrayDetailInfo(htParams);
}
///
/// 更新料架明细信息数据
///
///
///
public int updateTrayDetailInfo(GTrayDetail htParams)
{
return repository.updateTrayDetailInfo(htParams);
}
///
/// 删除料架明细信息信息
///
///
///
public int deleteTrayDetail(String ids)
{
String[] idArray = ids.Split(',');
int count = 0;
foreach (String id in idArray)
{
if (!"".Equals(id))
{
count += this.repository.deleteTrayDetail(id);
}
}
return count;
}
#endregion
}
}