|
|
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.Dapper;
|
|
|
using Estsh.Core.Model.ExcelModel;
|
|
|
|
|
|
/***************************************************************************************************
|
|
|
*
|
|
|
* 更新人:sitong.dong
|
|
|
* 描述:
|
|
|
* 修改时间:2022.06.22
|
|
|
* 修改日志:系统迭代升级
|
|
|
*
|
|
|
**************************************************************************************************/
|
|
|
namespace Estsh.Core.Services
|
|
|
{
|
|
|
/// <summary>
|
|
|
/// 菜单业务处理类
|
|
|
/// </summary>
|
|
|
public class CustomerService : BaseService<SysCustomer>, ICustomerService
|
|
|
{
|
|
|
private readonly ICustomerRepository repository;
|
|
|
public CustomerService(ICustomerRepository _repository) : base(_repository)
|
|
|
{
|
|
|
repository = _repository;
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 根据分页条件获取分页菜单数据
|
|
|
/// </summary>
|
|
|
/// <param name="CustomerName"></param>
|
|
|
/// <param name="pager"></param>
|
|
|
/// <param name="direction"></param>
|
|
|
/// <param name="sort"></param>
|
|
|
/// <returns></returns>
|
|
|
public Hashtable getCustomerListByPage(String enabled, String customer_code, String customer_name, int factoryId, Pager pager, String direction, String sort)
|
|
|
{
|
|
|
|
|
|
Hashtable result = new Hashtable();
|
|
|
String strWhere = " 1=1 ";
|
|
|
if (customer_name != null && !customer_name.Trim().Equals(""))
|
|
|
{
|
|
|
strWhere = " customer_name like '%" + customer_name.Trim() + "%' ";
|
|
|
}
|
|
|
if (customer_code != null && !customer_code.Trim().Equals(""))
|
|
|
{
|
|
|
strWhere += " AND customer_code like '%" + customer_code.Trim() + "%'";
|
|
|
}
|
|
|
if (enabled != null && !enabled.Trim().Equals(""))
|
|
|
{
|
|
|
strWhere += " AND enabled like '%" + enabled.Trim() + "%'";
|
|
|
}
|
|
|
strWhere += " and a.factory_id = " + factoryId + " ";
|
|
|
|
|
|
String orderBy = "";
|
|
|
if (sort != null && !"".Equals(sort.Trim()))
|
|
|
{
|
|
|
orderBy += typeof(SysCustomer).GetEntityColumnName(sort.Trim()) + " " + direction;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
orderBy += " customer_id " + direction;
|
|
|
}
|
|
|
result = repository.getListByPage(pager.pageSize, pager.pageNo, strWhere, orderBy);
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 保存菜单数据
|
|
|
/// </summary>
|
|
|
/// <param name="htParams"></param>
|
|
|
/// <returns></returns>
|
|
|
public int saveCustomer(SysCustomer htParams)
|
|
|
{
|
|
|
return repository.saveCustomer(htParams);
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 更新菜单数据
|
|
|
/// </summary>
|
|
|
/// <param name="htParams"></param>
|
|
|
/// <returns></returns>
|
|
|
public int updateCustomer(SysCustomer htParams)
|
|
|
{
|
|
|
return repository.updateCustomer(htParams);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 查看详情
|
|
|
/// </summary>
|
|
|
/// <param name="ruid"></param>
|
|
|
/// <returns></returns>
|
|
|
public List<SysCustomer> getCustomer(String customer_id)
|
|
|
{
|
|
|
customer_id = "customer_id = " + customer_id;
|
|
|
return repository.getList(customer_id, "");
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 删除菜单
|
|
|
/// </summary>
|
|
|
/// <param name="ids"></param>
|
|
|
/// <returns></returns>
|
|
|
public int deleteCustomer(String ids)
|
|
|
{
|
|
|
String[] idArray = ids.Split(',');
|
|
|
int count = 0;
|
|
|
foreach (String id in idArray)
|
|
|
{
|
|
|
if (!"".Equals(id))
|
|
|
{
|
|
|
count += this.repository.deleteCustomer(id);
|
|
|
}
|
|
|
}
|
|
|
return count;
|
|
|
}
|
|
|
|
|
|
public SysCustomer getCustomerByExistName(string customerName)
|
|
|
{
|
|
|
return repository.getCustomerByExistName(customerName);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取下拉框中的菜单数据
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
public List<KeyValueResult> getSelectCustomer()
|
|
|
{
|
|
|
return repository.getSelectCustomer();
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 启用
|
|
|
/// </summary>
|
|
|
/// <param name="ids"></param>
|
|
|
/// <returns></returns>
|
|
|
public int EnableCustomer(String ids)
|
|
|
{
|
|
|
String[] idArray = ids.Split(',');
|
|
|
int count = 0;
|
|
|
foreach (String id in idArray)
|
|
|
{
|
|
|
if (!"".Equals(id))
|
|
|
{
|
|
|
count += this.repository.EnableCustomer(id);
|
|
|
}
|
|
|
}
|
|
|
return count;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 禁用
|
|
|
/// </summary>
|
|
|
/// <param name="ids"></param>
|
|
|
/// <returns></returns>
|
|
|
public int DisableCustomer(String ids)
|
|
|
{
|
|
|
String[] idArray = ids.Split(',');
|
|
|
int count = 0;
|
|
|
foreach (String id in idArray)
|
|
|
{
|
|
|
if (!"".Equals(id))
|
|
|
{
|
|
|
count += this.repository.DisableCustomer(id);
|
|
|
}
|
|
|
}
|
|
|
return count;
|
|
|
}
|
|
|
public List<Customer> getExportList(String customerCode, String customerName, String enabled, int factoryId)
|
|
|
{
|
|
|
Hashtable result = new Hashtable();
|
|
|
String strWhere = " 1=1 ";
|
|
|
if (customerCode != null && !customerCode.Trim().Equals(""))
|
|
|
{
|
|
|
strWhere = " AND customer_code like '%" + customerCode.Trim() + "%' ";
|
|
|
}
|
|
|
if (customerName != null && !customerName.Trim().Equals(""))
|
|
|
{
|
|
|
strWhere += " AND customer_name like '%" + customerName.Trim() + "%'";
|
|
|
}
|
|
|
if (enabled != null && !enabled.Trim().Equals(""))
|
|
|
{
|
|
|
strWhere += " AND enabled = '" + enabled.Trim() + "'";
|
|
|
}
|
|
|
strWhere += " and factory_id = " + factoryId + " ";
|
|
|
|
|
|
String orderBy = " order by customer_code ";
|
|
|
|
|
|
return repository.getExportList(strWhere, orderBy);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
} |