using Estsh.Core.Controllers; using Estsh.Core.Model.ExcelModel; using Estsh.Core.Model.Result; using Estsh.Core.Models; using Estsh.Core.Services.IServices; using Estsh.Core.Util; using Microsoft.AspNetCore.Mvc; using System.Collections; /*************************************************************************************************** * * 更新人:sitong.dong * 描述:出库单管理 * 修改时间:2022.06.22 * 修改日志:系统迭代升级 * **************************************************************************************************/ namespace Estsh.Core.Web.Controllers { public class MovementOutstockManageController : BaseController { private IMovementOutstockManageService service; public MovementOutstockManageController(IMovementOutstockManageService _service) { service = _service; } // // GET: /Menu/ public ActionResult Index() { return View(); } /// /// 获取出库单管理列表数据 /// /// /// /// /// /// public ActionResult getMoveHeaderListByPage(string orderNo, string orderType, string orderStatus, string startTime, string endTime, Pager pager, String direction, String sort, string enabled = "Y") { int factoryId = CurrentEmp.FactoryId; Hashtable result = new Hashtable(); result.Add("pager.pageNo", pager.pageNo); Hashtable dataHt = this.service.getMoveHeaderListByPage(orderNo, orderType, orderStatus, startTime, endTime, enabled, factoryId, pager, direction, sort); result.Add("rows", dataHt["dataList"]); result.Add("pager.totalRows", dataHt["totalCount"]); result.Add("sort", sort); result.Add("direction", direction); return Json(result); } /// /// 获取出库单管理明细列表数据 /// /// /// /// /// /// public ActionResult getMoveDetailListByPage(string orderNo, string enabled = "Y") { int factoryId = CurrentEmp.FactoryId; Hashtable result = new Hashtable(); Hashtable dataHt = this.service.getMoveDetailListByPage(orderNo, enabled, factoryId); result.Add("rows", dataHt["dataList"]); result.Add("pager.totalRows", dataHt["totalCount"]); return Json(result); } /// /// 获取出库单条码管理列表数据 /// /// /// /// /// /// public ActionResult getMoveSnListByPage(string orderNo, string partNo, string enabled = "Y") { int factoryId = CurrentEmp.FactoryId; Hashtable result = new Hashtable(); Hashtable dataHt = this.service.getMoveSnListByPage(orderNo, partNo, enabled, factoryId); result.Add("rows", dataHt["dataList"]); result.Add("pager.totalRows", dataHt["totalCount"]); return Json(result); } //打印查询 public ActionResult getMoveSnListByPrint(string orderNo, string enabled = "Y") { int factoryId = CurrentEmp.FactoryId; List listData = this.service.getMoveSnListByPrint(orderNo, enabled, factoryId); return Json(listData); } /// /// 生成条码 /// /// /// public ActionResult onBarcodeGenerator(String orderNos) { Hashtable result = new Hashtable(); try { result = this.service.onBarcodeGenerator(orderNos); } catch (Exception e) { result.Add("message", "生成条码失败,请重查看!"); result.Add("flag", "error"); } return Json(result); } public ActionResult getSelectMoveOrderType() { Hashtable result = new Hashtable(); List menuList = this.service.GetMoveOrderType(); result.Add("list", menuList); return Json(result); } public ActionResult getSelectMoveOrderStatus() { Hashtable result = new Hashtable(); List menuList = this.service.GetMoveOrderStatus(); result.Add("list", menuList); return Json(result); } /// /// 获取父节点菜单下拉列表数据 /// /// public ActionResult getSelectFactory() { Hashtable result = new Hashtable(); List menuList = this.service.getSelectFactory(); result.Add("list", menuList); return Json(result); } public ActionResult getSelectWarehouse() { Hashtable result = new Hashtable(); List menuList = this.service.getSelectWarehouse(); result.Add("list", menuList); return Json(result); } public ActionResult getSelectZone() { Hashtable result = new Hashtable(); List menuList = this.service.getSelectZone(); result.Add("list", menuList); return Json(result); } public ActionResult getSelectVendor() { Hashtable result = new Hashtable(); List menuList = this.service.getSelectVendor(); result.Add("list", menuList); return Json(result); } public ActionResult getSelectCustomer() { Hashtable result = new Hashtable(); List menuList = this.service.getSelectCustomer(); result.Add("list", menuList); return Json(result); } public ActionResult getSelectLocate() { Hashtable result = new Hashtable(); List menuList = this.service.getSelectLocate(); result.Add("list", menuList); return Json(result); } public ActionResult GetPart() { Hashtable result = new Hashtable(); List menuList = this.service.GetPart(); result.Add("list", menuList); return Json(result); } /// /// 保存菜单数据 /// /// public ActionResult saveMovementOutstockManage() { int orderType = int.Parse(Request.Form["orderType"]); int factoryId = CurrentEmp.FactoryId; String factoryCode = CurrentEmp.FactoryCode; String enabled = Request.Form["enabled"].ToString(); string vendorName = Request.Form["vendorName"]; string customerId = Request.Form["customerId"]; String planDate = Request.Form["planDate"].ToString(); String planTime = Request.Form["planTime"].ToString(); String srcWarehouseId = Request.Form["srcWarehouseId"].ToString(); String srcZoneId = Request.Form["srcZoneId"].ToString(); String srcLocateId = Request.Form["srcLocateId"].ToString(); String srcErpWarehouse = Request.Form["srcErpWarehouse"].ToString(); String reforderno = Request.Form["reforderno"].ToString(); String srcWarehouseName = ""; List srcWare = service.getSelectWarehouse(srcWarehouseId); if (srcWare.Count > 0) { srcWarehouseName = srcWare[0].WarehouseName; } String srcZoneName = ""; List srcZones = service.getSelectZone(srcZoneId); if (srcZones.Count > 0) { srcZoneName = srcZones[0].ZoneName; } else { srcZoneName = ""; } String srcLocateName = ""; List locates = service.getSelectLocate(srcLocateId); if (locates.Count > 0) { srcLocateName = locates[0].LocateName; } else { srcLocateName = ""; } int vendorId = 0; string vendorCode = ""; List sysVendors = service.getSelectVendor(vendorName); if (sysVendors.Count > 0) { vendorId = sysVendors[0].VendorId; vendorCode= sysVendors[0].VendorCode; } customerId = string.IsNullOrEmpty(customerId) ? "0" : customerId; List sysCustomers = service.getSelectCustomer(customerId.ToString()); string customerCode = ""; if (sysCustomers.Count > 0) { customerCode = sysCustomers[0].CustomerCode; } WmsOutstock moveHeader = new WmsOutstock(); moveHeader.OrderType = orderType; moveHeader.VendorId = vendorId; moveHeader.VendorCode = vendorCode; moveHeader.CustomerId = Convert.ToInt32(customerId); moveHeader.CustomerCode = customerCode; moveHeader.FactoryId = factoryId; moveHeader.FactoryCode = factoryCode; moveHeader.Enabled = enabled; moveHeader.RefOrderNo = reforderno; string detailRow = Request.Form["detailRow"].ToString(); IList moveDetailsList = Newtonsoft.Json.JsonConvert.DeserializeObject>(detailRow); for (int i = 0; i < moveDetailsList.Count; i++) { moveDetailsList[i].ItemNo = (i + 1).ToString(); //purchaseDetailList[i].PartId = Convert.ToInt32(PartId); string PartNo = string.IsNullOrEmpty(moveDetailsList[i].PartNo.ToString()) ? "0" : moveDetailsList[i].PartNo.ToString(); List parts = service.GetPart(PartNo); if (parts.Count > 0) { moveDetailsList[i].PartId = parts[0].PartId; moveDetailsList[i].PartSpec = parts[0].PartSpec; moveDetailsList[i].Unit = parts[0].Unit; } else { moveDetailsList[i].PartId = 0; moveDetailsList[i].PartSpec = ""; moveDetailsList[i].Unit = ""; } //moveDetailsList[i].Qty = string.IsNullOrEmpty(Qty) ? 0 : Convert.ToDecimal(Qty); moveDetailsList[i].PickQty =0; moveDetailsList[i].OutQty = 0; moveDetailsList[i].PlanDate = planDate; moveDetailsList[i].PlanTime = planTime; moveDetailsList[i].SrcWarehouseId = string.IsNullOrEmpty(srcWarehouseId)?0:Convert.ToInt32(srcWarehouseId); moveDetailsList[i].SrcWarehouseName = srcWarehouseName; moveDetailsList[i].SrcZoneId = string.IsNullOrEmpty(srcZoneId) ? 0 : Convert.ToInt32(srcZoneId); moveDetailsList[i].SrcZoneName = srcZoneName; moveDetailsList[i].SrcLocateId = string.IsNullOrEmpty(srcLocateId) ? 0 : Convert.ToInt32(srcLocateId); moveDetailsList[i].SrcLocateName = srcLocateName; moveDetailsList[i].SrcErpWarehouse = srcErpWarehouse; moveDetailsList[i].Enabled = enabled; moveDetailsList[i].FactoryId = CurrentEmp.FactoryId; moveDetailsList[i].FactoryCode = CurrentEmp.FactoryCode; moveDetailsList[i].CreateUserId = CurrentEmp.EmpId; } String message = ""; try { moveHeader.CreateUserId = CurrentEmp.EmpId; bool flag = this.service.saveMovementManage(moveHeader, moveDetailsList); if (flag == true) { message = "添加成功"; } else { message = "添加失败!"; } } catch (Exception e) { message = "添加失败!"; } Hashtable result = new Hashtable(); result.Add("message", message); return Json(result); } public ActionResult GetErpwarehouse() { Hashtable resault = new Hashtable(); List pdlineList = service.GetErpwarehouse(); resault.Add("list", pdlineList); return Json(resault); } /// /// 编辑菜单 /// /// /// public ActionResult EditMoveOutstockManage(String warehouseId) { ViewData.Add("editType", "new"); List menuList = this.service.getSelectWarehouse(); if (menuList.Count > 0) { //源仓库 绑定默认值 ViewData.Add("srcWarehouseId", menuList[0].value); } return View("EditMoveOutstockManage"); } #region 过滤零件号 public ActionResult GetPart_No(string q) { List list = filePart(q); return writeResult(list); } /// /// 过滤零件号 /// /// /// public List filePart(string key) { Hashtable autoComplateList = GetItemPart(key); List result = new List(); foreach (System.Collections.DictionaryEntry item in autoComplateList) { if (item.Value.ToString().ToUpper().StartsWith(key.ToUpper())) { result.Add(item.Value.ToString()); } } return result; } /// /// 查询零件号 /// /// /// public Hashtable GetItemPart(string key) { List autoComplateList = new List(); Hashtable result = new Hashtable(); try { List dt = service.GetPartNoInfo(key); for (int i = 0; i < dt.Count; i++) { result.Add(dt[i].PartId.ToString(), dt[i].PartNo.ToString()); } } catch (Exception e) { result = new Hashtable(); } return result; } #endregion #region 过滤零件号简码 public ActionResult GetPart_Spec(string q) { List list = filePartSpec(q); return writeResult(list); } /// /// 过滤零件号 /// /// /// public List filePartSpec(string key) { Hashtable autoComplateList = GetItemPartSpec(key); List result = new List(); foreach (System.Collections.DictionaryEntry item in autoComplateList) { if (item.Value.ToString().ToUpper().StartsWith(key.ToUpper())) { result.Add(item.Value.ToString()); } } return result; } /// /// 查询零件号 /// /// /// public Hashtable GetItemPartSpec(string key) { List autoComplateList = new List(); Hashtable result = new Hashtable(); try { List dt = service.GetPartSpecInfo(key); for (int i = 0; i < dt.Count; i++) { result.Add(dt[i].PartId.ToString(), dt[i].PartSpec.ToString()); } } catch (Exception e) { result = new Hashtable(); } return result; } #endregion private ActionResult writeResult(List list) { Hashtable result = new Hashtable(); result.Add("list", list); return Json(result); } public ActionResult getPartNoInfo(string partNo) { Hashtable resault = new Hashtable(); List list = service.GetPartNoInfo(partNo); return Json(list); } public ActionResult getPartNoInfoByPartNo(string partNo) { Hashtable resault = new Hashtable(); List list = service.GetPartNoInfoByPartNo(partNo); return Json(list); } public ActionResult getPartSpecInfo(string partSpec) { Hashtable resault = new Hashtable(); List list = service.GetPartSpecInfo(partSpec); return Json(list); } public ActionResult getPartSpecInfoByPartSpec(string partSpec) { Hashtable resault = new Hashtable(); List list = service.GetPartSpecInfoByPartSpec(partSpec); return Json(list); } /// /// 关闭 /// /// /// public ActionResult onClose(String orderNos) { bool flag = true; try { string empId = CurrentEmp.EmpId.ToString(); flag = this.service.onClose(orderNos, empId); } catch (Exception e) { flag =false; } Hashtable result = new Hashtable(); result.Add("status", flag); return Json(result); } /// /// 启用 /// /// /// public ActionResult onEnable(String orderNos) { bool flag = true; try { flag = this.service.EnableData(orderNos); } catch (Exception e) { flag = false; } Hashtable result = new Hashtable(); result.Add("status", flag); return Json(result); } /// /// 禁用 /// /// /// public ActionResult onDisable(String orderNos) { bool flag = true; try { flag = this.service.DisableData(orderNos); } catch (Exception e) { flag = false; } Hashtable result = new Hashtable(); result.Add("status", flag); return Json(result); } /// /// 导入 /// /// public ActionResult importFile() { int factoryId = CurrentEmp.FactoryId; string factoryCode = CurrentEmp.FactoryCode; Hashtable result = new Hashtable(); IFormFile file = Request.Form.Files[0]; List data = ExcelHelper.GetList(file, 0); result = service.ImportExcel(data, factoryId, factoryCode, CurrentEmp.EmpId); return Json(result); } public ActionResult uploadFile() { return View("uploadFile"); } /// /// 下载模板 /// /// public ActionResult downLoadExcel() { List listHt = new List();//导出空数据模板 var memoryStream = ExcelHelper.ToExcel(listHt); string dateTime = DateTime.Now.ToString("yyyyMMddHHmmss"); return File(memoryStream.ToArray(), "application/ms-excel", "出库单管理" + dateTime + ".xls"); } } }