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 PartMasterService : BaseService, IPartMasterService { private readonly IPartMasterRepository repository; public PartMasterService(IPartMasterRepository _repository) : base(_repository) { repository = _repository; } /// /// 根据分页条件获取分页菜单数据 /// /// /// /// /// /// public Hashtable getPartMasterListByPage(String part_type, String part_no, String partSpec, string enabled, int factoryId, Pager pager, String direction, String sort) { Hashtable result = new Hashtable(); String strWhere = " 1=1 "; if (part_no != null && !part_no.Trim().Equals("")) { strWhere = " a.part_no like '%" + part_no.Trim() + "%' "; } if (partSpec != null && !partSpec.Trim().Equals("")) { strWhere += " AND a.part_spec like '%" + partSpec.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 += "a." + typeof(SysPart).GetEntityColumnName(sort.Trim()) + " " + direction; } else { orderBy += " a." + typeof(SysPart).GetEntityColumnName("PartId") + " " + direction; } result = repository.getListByPage(part_type, pager.pageSize, pager.pageNo, strWhere, orderBy); return result; } /// /// 保存菜单数据 /// /// /// public int savePartMaster(SysPart htParams) { return repository.savePartMaster(htParams); } /// /// 更新菜单数据 /// /// /// public int updatePartMaster(SysPart htParams) { return repository.updatePartMaster(htParams); } /// /// 查看详情 /// /// /// public List getPartMaster(String part_id) { part_id = "part_id = " + part_id; return repository.getList(part_id); } /// /// 删除菜单 /// /// /// public int deletePartMaster(String ids) { String[] idArray = ids.Split(','); int count = 0; foreach (String id in idArray) { if (!"".Equals(id)) { count += this.repository.deletePartMaster(id); } } return count; } public SysPart getPartByExistName(string partNo) { return repository.getPartByExistName(partNo); } public SysPart getPartByExistSpec(string partSpec) { return repository.getPartByExistSpec(partSpec); } /// /// 获取下拉框中的菜单数据 /// /// public List getSelectPartMaster() { return repository.getSelectPartMaster(); } /// /// 获取车型数据 /// /// public List getSelectPartMaster_Model_name() { return repository.getSelectPartMaster_Model_name(); } /// /// 获取座椅位置 /// /// public List getSelectPartLocation() { return repository.getSelectPartLocation(); } public string Isnull(string value) { if (string.IsNullOrEmpty(value)) { return "0"; } else { return value; } } /// /// 获取单位数据 /// /// public List getSelectPartMaster_Enum() { return repository.getSelectPartMaster_Enum(); } /// /// 获取默认库位数据 /// /// public List getSelectPartMaster_Locate() { return repository.getSelectPartMaster_Locate(); } /// /// 获取条码规则数据 /// /// public List getSelectPartMaster_TMGZ() { return repository.getSelectPartMaster_TMGZ(); } /// /// 获取工艺流程数据 /// /// public List getSelectPartMaster_Route() { return repository.getSelectPartMaster_Route(); } /// /// 导出 /// /// 查询条件 /// /// 排序方式 /// 排序字段 /// public List getTableListByPage(String part_type, String part_no, Pager pager, String direction, String sort, Boolean isPage) { List result = null; String strWhere = " 1=1 "; int rowCount = 0; if (part_no != null && !part_no.Trim().Equals("")) { strWhere = " a.part_no like '%" + part_no.Trim() + "%' "; } String orderBy = ""; if (sort != null && !"".Equals(sort.Trim())) { orderBy += typeof(SysPart).GetEntityColumnName(sort.Trim()) + " " + direction; } else { orderBy += " a." + typeof(SysPart).GetEntityColumnName("PartId") + " " + direction; } if (isPage) { rowCount = pager.pageSize; } else { rowCount = pager.pageSize; } result = repository.getTableListByPage(part_type, rowCount, pager.pageNo, strWhere, orderBy); return result; } public int EnablePartMaster(String ids) { String[] idArray = ids.Split(','); int count = 0; foreach (String id in idArray) { if (!"".Equals(id)) { count += this.repository.EnablePartMaster(id); } } return count; } public int DisablePartMaster(String ids) { String[] idArray = ids.Split(','); int count = 0; foreach (String id in idArray) { if (!"".Equals(id)) { count += this.repository.DisablePartMaster(id); } } return count; } public List getExportList(String partType, String partNo, String partSpec, String enabled, int factoryId) { Hashtable result = new Hashtable(); String strWhere = " 1=1 "; if (partType != null && !partType.Trim().Equals("")) { strWhere = " a.part_type ='" + partType.Trim() + "' "; } if (partNo != null && !partNo.Trim().Equals("")) { strWhere += " AND a.part_no like '%" + partNo.Trim() + "%'"; } if (partSpec != null && !partSpec.Trim().Equals("")) { strWhere += " AND a.part_spec like '%" + partSpec.Trim() + "%'"; } if (enabled != null && !enabled.Trim().Equals("")) { strWhere += " AND a.enabled = '" + enabled.Trim() + "'"; } strWhere += " and a.factory_id = " + factoryId + " "; String orderBy = " order by part_no "; return repository.getExportList(strWhere,orderBy); } } }