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 { /// /// 菜单业务处理类 /// public class CustomerService : BaseService, ICustomerService { private readonly ICustomerRepository repository; public CustomerService(ICustomerRepository _repository) : base(_repository) { repository = _repository; } /// /// 根据分页条件获取分页菜单数据 /// /// /// /// /// /// 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; } /// /// 保存菜单数据 /// /// /// public int saveCustomer(SysCustomer htParams) { return repository.saveCustomer(htParams); } /// /// 更新菜单数据 /// /// /// public int updateCustomer(SysCustomer htParams) { return repository.updateCustomer(htParams); } /// /// 查看详情 /// /// /// public List getCustomer(String customer_id) { customer_id = "customer_id = " + customer_id; return repository.getList(customer_id, ""); } /// /// 删除菜单 /// /// /// 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); } /// /// 获取下拉框中的菜单数据 /// /// public List getSelectCustomer() { return repository.getSelectCustomer(); } /// /// 启用 /// /// /// 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; } /// /// 禁用 /// /// /// 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 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); } } }