using System.Collections;
using Aspose.Cells;
using Microsoft.AspNetCore.Mvc;
using Estsh.Core.Services.IServices;
using Estsh.Core.Model.Result;
using Estsh.Core.Models;
using System.Text.Json;
using Estsh.Core.Controllers;
using System.Data;
using Estsh.Core.Util;
using Estsh.Core.Model.ExcelModel;
/***************************************************************************************************
*
* 更新人:sitong.dong
* 描述:库存明细查询
* 修改时间:2022.06.22
* 修改日志:系统迭代升级
*
**************************************************************************************************/
namespace Estsh.Core.Web.Controllers
{
public class StockDetailQueryController :BaseController
{
private IStockDetailQueryService service;
public StockDetailQueryController(IStockDetailQueryService _service)
{
service = _service;
}
//
// GET: /Menu/
public ActionResult Index()
{
return View();
}
///
/// 库区汇总
///
///
///
///
///
///
///
///
public ActionResult getZoneListByPage(string zoneName, 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.getZoneList(zoneName, 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 GetStockType()
{
Hashtable resault = new Hashtable();
List pdlineList = service.GetStockType();
resault.Add("list", pdlineList);
return Json(resault);
}
///
/// 库位汇总
///
///
///
///
///
///
///
///
///
///
public ActionResult getLocateListByPage( string zoneName, string locateName, string enabled = "Y")
{
int factoryId = CurrentEmp.FactoryId;
Hashtable result = new Hashtable();
List dataHt = this.service.getLocateListByPage(zoneName, locateName,enabled, factoryId);
result.Add("rows", dataHt);
return Json(result);
}
///
/// 条码汇总
///
///
///
///
///
///
public ActionResult getDPSListByPage(string zoneName, string locateName, string cartonNo, string partNo, string partSpec,string stockType, string enabled = "Y")
{
string wheres = "";
int factoryId = CurrentEmp.FactoryId;
Hashtable result = new Hashtable();
List dataHt = this.service.getDPSListByPage(zoneName, locateName, cartonNo, partNo, partSpec ,enabled, factoryId, stockType);
result.Add("rows", dataHt);
return Json(result);
}
///
/// 导出数据到Excel
/// BY NOAH
/// carImport
///
public ActionResult exportData(string zoneName, string locateName, string cartonNo, string partNo, string partSpec,string stockType , string enabled = "Y")
{
string factoryId = CurrentEmp.FactoryId.ToString();
List listHt = this.service.getExportList(zoneName, locateName, cartonNo, partNo, partSpec, enabled, factoryId, stockType);
var memoryStream = ExcelHelper.ToExcel(listHt);
string dateTime = DateTime.Now.ToString("yyyyMMddHHmmss");
return File(memoryStream.ToArray(), "application/ms-excel", "库存条码明细" + dateTime + ".xls");
}
///
/// 获取零件号
///
///
public ActionResult GetPartNo()
{
Hashtable resault = new Hashtable();
List list = service.GetPartNo();
resault.Add("list", list);
return Json(resault);
}
///
/// 获取库位
///
///
public ActionResult GetLocateName()
{
Hashtable resault = new Hashtable();
List list = service.GetLocateName();
resault.Add("list", list);
return Json(resault);
}
///
/// 获取系统参数
///
///
public ActionResult GetSysEnum()
{
Hashtable resault = new Hashtable();
List list = service.GetSysEnum("sys_stock_status");
resault.Add("list", list);
return Json(resault);
}
public ActionResult GetWareHouseName()
{
Hashtable resault = new Hashtable();
List pdlineList = service.GetWareHouseName();
resault.Add("list", pdlineList);
return Json(resault);
}
private string InitWhereStr(string wareHouse_id)
{
string wheres = string.Empty;
string pdlineStr = string.Empty;
string[] pdLineArr = wareHouse_id.Split(',');
foreach (string str in pdLineArr)
{
pdlineStr += " '" + str + "' ,";
}
pdlineStr = pdlineStr.Substring(0, pdlineStr.Length - 2);
wheres += string.Format(" AND ( w.warehouse_id IN ({0}))", pdlineStr);
return wheres;
}
///
/// 解冻
///
///
///
public ActionResult onEnable(String ids)
{
int delCount = 0;
try
{
string empId = CurrentEmp.EmpId.ToString();
delCount = this.service.EnableData(ids, empId);
}
catch (Exception e)
{
delCount = -1;
}
Hashtable result = new Hashtable();
result.Add("status", delCount);
return Json(result);
}
}
}