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; /*************************************************************************************************** * * 更新人:sitong.dong * 描述:库位管理 * 修改时间:2022.06.22 * 修改日志:系统迭代升级 * **************************************************************************************************/ namespace Estsh.Core.Services { public class CycleCountManageService : BaseService, ICycleCountManageService { private readonly ICycleCountManageRepository repository; public CycleCountManageService(ICycleCountManageRepository _repository) : base(_repository) { repository = _repository; } public Hashtable getCheckStockByPage(string orderNo, string orderType, string orderStatus, string startTime, string endTime, string enabled, int factoryId, Pager pager, String direction, String sort) { Hashtable result = new Hashtable(); String strWhere = " 1=1 "; if (orderNo != null && !orderNo.Trim().Equals("")) { strWhere += "and a.order_no like '%" + orderNo.Trim() + "%' "; } if (orderType != null && !orderType.Trim().Equals("")) { strWhere += "and a.order_type ='" + orderType.Trim() + "' "; } if (orderStatus != null && !orderStatus.Trim().Equals("")) { strWhere += "and a.order_status ='" + orderStatus.Trim() + "' "; } if (!String.IsNullOrEmpty(startTime) && !String.IsNullOrEmpty(endTime)) { strWhere += " and a.create_time BETWEEN '" + startTime.Trim() + "' AND '" + endTime.Trim() + "'"; } else if (String.IsNullOrEmpty(startTime) && !String.IsNullOrEmpty(endTime)) { strWhere += " and a.create_time < '" + endTime.Trim() + "'"; } else if (!String.IsNullOrEmpty(startTime) && String.IsNullOrEmpty(endTime)) { strWhere += " and a.create_time >'" + startTime.Trim() + "'"; } if (enabled != null && !enabled.Trim().Equals("")) { strWhere += "and a.enabled = '" + enabled.Trim() + "' "; } strWhere += " and a.factory_id = " + factoryId + " "; String orderBy = ""; if (sort != null && !"".Equals(sort.Trim())) { orderBy += typeof(WmsCheckStock).GetEntityColumnName(sort.Trim()) + " " + direction; } else { orderBy += typeof(WmsCheckStock).GetEntityColumnName("CreateTime") + " desc"; } return repository.getCheckStockByPage(pager.pageSize, pager.pageNo, strWhere, orderBy); } public List getCheckStockListByPage(string orderNo, string enabled, int factoryId, Pager pager, String direction, String sort) { String strWhere = " 1=1 "; if (orderNo != null && !orderNo.Trim().Equals("")) { strWhere += "and a.order_no = '" + orderNo.Trim() + "'"; } strWhere += " and a.factory_id = " + factoryId + " "; return repository.getCheckStockListByPage(pager.pageSize, pager.pageNo, strWhere); } public List getSearchCheckStockList(string orderNo, string partNo, string partSpec, string cartonNo) { String strWhere = " 1=1 "; if (orderNo != null && !orderNo.Trim().Equals("")) { strWhere += "and a.order_no = '" + orderNo.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 (cartonNo != null && !cartonNo.Trim().Equals("")) { strWhere += "and a.carton_no like '%" + cartonNo.Trim() + "%'"; } return repository.getSearchCheckStockList(strWhere); } public List getCheckStockPartByPage(string orderNo, string enabled, int factoryId, Pager pager, String direction, String sort) { String strWhere = " 1=1 "; if (orderNo != null && !orderNo.Trim().Equals("")) { strWhere += "and a.order_no = '" + orderNo.Trim() + "'"; } strWhere += " and a.factory_id = " + factoryId + " "; String orderBy = ""; if (sort != null && !"".Equals(sort.Trim())) { orderBy += typeof(WmsCheckStockPart).GetEntityColumnName(sort.Trim()) + " " + direction; } else { orderBy += typeof(WmsCheckStockPart).GetEntityColumnName("orderNo") + " " + direction; } return repository.getCheckStockPartByPage(pager.pageSize, pager.pageNo, strWhere, orderBy); } public List getCheckStockZoneByPage(string orderNo, string enabled, int factoryId, Pager pager, String direction, String sort) { String strWhere = " 1=1 "; if (orderNo != null && !orderNo.Trim().Equals("")) { strWhere += "and a.order_no = '" + orderNo.Trim() + "'"; } strWhere += " and a.factory_id = " + factoryId + " "; String orderBy = ""; if (sort != null && !"".Equals(sort.Trim())) { orderBy += typeof(WmsCheckStockZone).GetEntityColumnName(sort.Trim()) + " " + direction; } else { orderBy += typeof(WmsCheckStockZone).GetEntityColumnName("ruid") + " " + direction; } return repository.getCheckStockZoneByPage(pager.pageSize, pager.pageNo, strWhere, orderBy); } public List getCheckStockLocateByPage(string orderNo, string enabled, int factoryId, Pager pager, String direction, String sort) { Hashtable result = new Hashtable(); String strWhere = " 1=1 "; if (orderNo != null && !orderNo.Trim().Equals("")) { strWhere += "and a.order_no = '" + orderNo.Trim() + "'"; } strWhere += " and a.factory_id = " + factoryId + " "; String orderBy = ""; if (sort != null && !"".Equals(sort.Trim())) { orderBy += typeof(WmsCheckStockLocate).GetEntityColumnName(sort.Trim()) + " " + direction; } else { orderBy += typeof(WmsCheckStockLocate).GetEntityColumnName("ruid") + " " + direction; } return repository.getCheckStockLocateByPage(pager.pageSize, pager.pageNo, strWhere, orderBy); } public List getCheckStockRangeByPage(string orderNo, string enabled, int factoryId, Pager pager, String direction, String sort) { Hashtable result = new Hashtable(); String strWhere = " 1=1 "; if (orderNo != null && !orderNo.Trim().Equals("")) { strWhere += "and a.order_no = '" + orderNo.Trim() + "'"; } strWhere += " and a.factory_id = " + factoryId + " "; String orderBy = ""; if (sort != null && !"".Equals(sort.Trim())) { orderBy += typeof(WmsCheckStockRange).GetEntityColumnName(sort.Trim()) + " " + direction; } else { orderBy += typeof(WmsCheckStockRange).GetEntityColumnName("ruid") + " " + direction; } return repository.getCheckStockRangeByPage(pager.pageSize, pager.pageNo, strWhere, orderBy); } public List getCheckStockByOrderNo(string orderNo) { return repository.getCheckStockByOrderNo(orderNo); } public List GetErpwarehouse(int factoryId) { return repository.GetErpwarehouse(factoryId); } public List GetMultiErpwarehouse(int factoryId) { return repository.GetMultiErpwarehouse(factoryId); } public List GetMultiPartNo(int factoryId) { return repository.GetMultiPartNo(factoryId); } public List GetMultiWarehouse(int factoryId) { return repository.GetMultiWarehouse(factoryId); } public List GetMultiZone(int factoryId) { return repository.GetMultiZone(factoryId); } public List GetMultiLocate(int factoryId) { return repository.GetMultiLocate(factoryId); } public List GetMoveOrderType(int factoryId) { return repository.GetMoveOrderType(factoryId); } public List GetCheckStockType(int factoryId) { return repository.GetCheckStockType(factoryId); } public List GetCheckStockStatus(int factoryId) { return repository.GetCheckStockStatus(factoryId); } public List getSelectFactory() { return repository.getSelectFactory(); } public List getSelectWarehouse(int factoryId) { return repository.getSelectWarehouse(factoryId); } public List getSelectWarehouse(string warehouseid) { return repository.getSelectWarehouse(warehouseid); } public List getSelectZone(string zoneid) { return repository.getSelectZone(zoneid); } public List getSelectLocate(string locateid) { return repository.getSelectLocate(locateid); } public List getSelectZone(int factoryId) { return repository.getSelectZone(factoryId); } public List getSelectVendor(int factoryId) { return repository.getSelectVendor(factoryId); } public List getSelectVendor(string vendorId) { return repository.getSelectVendor(vendorId); } public List GetPart(int factoryId) { return repository.GetPart(0, factoryId); } public List GetPartList(string partNo) { return repository.GetPartList(0, partNo); } public List GetPart(string partId) { return repository.GetPart(0, partId); } //根据选择库区筛选零件号 public List getPartNoByZoneIds(string zoneIds) { if (!string.IsNullOrEmpty(zoneIds)) { zoneIds = zoneIds.Substring(0, zoneIds.Length - 1); } return this.repository.getPartNoByZoneIds(zoneIds); } //根据选择库位筛选零件号 public List getPartNoByLocateIds(string locateIds) { if (!string.IsNullOrEmpty(locateIds)) { locateIds = locateIds.Substring(0, locateIds.Length - 1); } return this.repository.getPartNoByLocateIds(locateIds); } public List getPartNoByZoneIdsOrLocateIds(string zoneIds, string locateIds) { if (!string.IsNullOrEmpty(zoneIds)) { zoneIds = zoneIds.Substring(0, zoneIds.Length - 1); } if (!string.IsNullOrEmpty(locateIds)) { locateIds = locateIds.Substring(0, locateIds.Length - 1); } return this.repository.getPartNoByZoneIdsOrLocateIds(zoneIds, locateIds); } public List getPartNoByZoneId(string zoneId) { return this.repository.getPartNoByZoneId(zoneId); } public List getPartNoByLocateId(string locateId) { return this.repository.getPartNoByLocateId(locateId); } public Hashtable GetPartByPage(string partNo, string enabled, int factoryId, Pager pager, String direction, String sort) { Hashtable result = new Hashtable(); String strWhere = " 1=1 "; if (partNo != null && !partNo.Trim().Equals("")) { strWhere += "and a.part_no like '%" + partNo.Trim() + "%'"; } strWhere += " and a.factory_id = " + factoryId + " "; String orderBy = ""; if (sort != null && !"".Equals(sort.Trim())) { orderBy += typeof(SysPart).GetEntityColumnName(sort.Trim()) + " " + direction; } else { orderBy += typeof(SysPart).GetEntityColumnName("partId") + " " + direction; } return repository.GetPartByPage(pager.pageSize, pager.pageNo, strWhere, orderBy); } public Hashtable GetZoneByPage(string zoneName, string warehouse, string erpWarehouse, string enabled, int factoryId, Pager pager, String direction, String sort) { Hashtable result = new Hashtable(); String strWhere = " 1=1 "; if (zoneName != null && !zoneName.Trim().Equals("")) { strWhere += "and a.zone_name like '%" + zoneName.Trim() + "%'"; } if (warehouse != null && !warehouse.Trim().Equals("")) { strWhere += "and a.warehouse_id in (" + warehouse.Trim() + ")"; } if (erpWarehouse != null && !erpWarehouse.Trim().Equals("")) { strWhere += "and a.erp_Warehouse in (" + erpWarehouse.Trim() + ")"; } strWhere += " and a.factory_id = " + factoryId + " "; String orderBy = ""; if (sort != null && !"".Equals(sort.Trim())) { orderBy += typeof(SysZone).GetEntityColumnName(sort.Trim()) + " " + direction; } else { orderBy += typeof(SysZone).GetEntityColumnName("ZoneName") + " " + direction; } return repository.GetZoneByPage(pager.pageSize, pager.pageNo, strWhere, orderBy); } public Hashtable GetLocateByPage(string locateName, string warehouse, string enabled, int factoryId, Pager pager, String direction, String sort) { Hashtable result = new Hashtable(); String strWhere = " 1=1 "; if (locateName != null && !locateName.Trim().Equals("")) { strWhere += "and a.locate_name like '%" + locateName.Trim() + "%'"; } if (warehouse != null && !warehouse.Trim().Equals("")) { strWhere += "and a.warehouse_id in (" + warehouse.Trim() + ")"; } strWhere += " and a.factory_id = " + factoryId + " "; String orderBy = ""; if (sort != null && !"".Equals(sort.Trim())) { orderBy += typeof(SysLocate).GetEntityColumnName(sort.Trim()) + " " + direction; } else { orderBy += typeof(SysLocate).GetEntityColumnName("locateName") + " " + direction; } return repository.GetLocateByPage(pager.pageSize, pager.pageNo, strWhere, orderBy); } public Hashtable getCheckStock(String orderNo) { List dt = repository.getCheckStockByOrderNo(orderNo); Hashtable result = new Hashtable(); result.Add("orderType", dt[0].OrderType); result.Add("partNo", dt[0].PartNo); result.Add("enabled", dt[0].Enabled); return result; } /// /// 保存菜单数据 /// /// /// public bool saveCycleCountManage(WmsCheckStock checkStockParams, List checkStockPartParams, List checkStockZoneParams, List checkStockLocateParams, List checkStockRangeParams) { return repository.saveCycleCountManage(checkStockParams, checkStockPartParams, checkStockZoneParams, checkStockLocateParams, checkStockRangeParams); } public Hashtable onAdjustment(String orderNo, string userId) { orderNo = orderNo.Substring(0, orderNo.Length - 1); return this.repository.onAdjustment(orderNo, userId); } public List GetSAPDIFO(String orderNo, string userId) { orderNo = orderNo.Substring(0, orderNo.Length - 1); return this.repository.GetSAPDIFO(orderNo, userId); } public SysBase GetSAPDIFOByBase() { return this.repository.GetSAPDIFOByBase(); } public Hashtable onNoAdjustment(String orderNo, string userId) { orderNo = orderNo.Substring(0, orderNo.Length - 1); return this.repository.onNoAdjustment(orderNo, userId); } /// /// 开始盘点 /// /// /// public Hashtable onBeginCycle(String orderNo, string userId) { orderNo = orderNo.Substring(0, orderNo.Length - 1); return this.repository.onBeginCycle(orderNo, userId); } //关闭盘点 public Hashtable onCloseCycle(String orderNo, string userId) { orderNo = orderNo.Substring(0, orderNo.Length - 1); return this.repository.onCloseCycle(orderNo, userId); } public Hashtable onCompleteCycle(string orderNo, string userId) { orderNo = orderNo.Substring(0, orderNo.Length - 1); return this.repository.onCompleteCycle(orderNo, userId); } public Hashtable onReplay(string orderNo, string userId) { orderNo = orderNo.Substring(0, orderNo.Length - 1); return this.repository.onReplay(orderNo, userId); } /// /// 关闭 /// /// /// public int onClose(String ids, string userId) { ids = ids.Substring(0, ids.Length - 1); return this.repository.onClose(ids, userId); } /// /// 启用 /// /// /// public int EnableData(String ids, string userId) { ids = ids.Substring(0, ids.Length - 1); return this.repository.EnableData(ids, userId); } /// /// 禁用 /// /// /// public int DisableData(String ids, string userId) { ids = ids.Substring(0, ids.Length - 1); return this.repository.DisableData(ids, userId); } //导出 public List getCheckStockListByExportData(string orderNo) { String strWhere = " 1=1 "; if (orderNo != null && !orderNo.Trim().Equals("")) { strWhere += "and a.order_no = '" + orderNo.Trim() + "'"; } return repository.getCheckStockListByExportData(strWhere); } } }