|
|
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 ZoneDefineController : BaseController
|
|
|
{
|
|
|
private IZoneDefineService service;
|
|
|
public ZoneDefineController(IZoneDefineService _service)
|
|
|
{
|
|
|
service = _service;
|
|
|
}
|
|
|
//
|
|
|
// GET: /Menu/
|
|
|
public ActionResult Index()
|
|
|
{
|
|
|
return View();
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取菜单管理列表数据
|
|
|
/// </summary>
|
|
|
/// <param name="menuName"></param>
|
|
|
/// <param name="pager"></param>
|
|
|
/// <param name="direction"></param>
|
|
|
/// <param name="sort"></param>
|
|
|
/// <returns></returns>
|
|
|
public ActionResult getZoneListByPage(string zoneName, string zoneDesc, 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.getZoneListByPage(zoneName, zoneDesc, 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);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取父节点菜单下拉列表数据
|
|
|
/// </summary>
|
|
|
/// <rehuoturns></returns>
|
|
|
public ActionResult getSelectWarehouse()
|
|
|
{
|
|
|
String factoryId = CurrentEmp.FactoryId.ToString();//获取当前工厂
|
|
|
Hashtable result = new Hashtable();
|
|
|
List<KeyValueResult> menuList = this.service.getSelectWarehouse(factoryId);
|
|
|
result.Add("list", menuList);
|
|
|
return Json(result);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 保存菜单数据
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
public ActionResult saveZone()
|
|
|
{
|
|
|
String editType = Request.Form["editType"].ToString();
|
|
|
|
|
|
String zoneId = Request.Form["zoneId"].ToString();
|
|
|
String zoneName = Request.Form["zoneName"].ToString();
|
|
|
String zoneDesc = Request.Form["zoneDesc"].ToString();
|
|
|
|
|
|
String warehouseId = Request.Form["warehouseId"].ToString();
|
|
|
List<SysWarehouse> warelist= service.getSelectWarehouseInfo(warehouseId);
|
|
|
String warehouseName = "";
|
|
|
if (warelist.Count>0)
|
|
|
{
|
|
|
warehouseName = warelist[0].WarehouseName;
|
|
|
}
|
|
|
String erpWarehouse = Request.Form["erpWarehouse"].ToString();
|
|
|
String enabled = Request.Form["enabled"].ToString();
|
|
|
|
|
|
////传递要更新的数据库字段 2013 0327 14:05 by NOAH
|
|
|
SysZone sysZone = new SysZone();
|
|
|
|
|
|
//sysWarehouse.WarehouseName = warehouseName;
|
|
|
sysZone.ZoneName = zoneName;
|
|
|
sysZone.ZoneDesc = zoneDesc;
|
|
|
sysZone.WarehouseName = warehouseName;
|
|
|
sysZone.FactoryId = CurrentEmp.FactoryId;
|
|
|
sysZone.FactoryCode = CurrentEmp.FactoryCode;
|
|
|
sysZone.WarehouseId = warehouseId == "" ? 0 : Convert.ToInt32(warehouseId);
|
|
|
sysZone.ErpWarehouse = erpWarehouse;
|
|
|
//sysWarehouse.WarehouseDesc = warehouseDesc;
|
|
|
sysZone.Enabled = enabled;
|
|
|
String message = "";
|
|
|
if (editType != null && editType.Trim().Equals("edit"))
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
sysZone.ZoneId = Convert.ToInt32(zoneId);
|
|
|
sysZone.UpdateUserId = CurrentEmp.EmpId;
|
|
|
this.service.updateZone(sysZone);
|
|
|
message = "修改成功";
|
|
|
}
|
|
|
catch (Exception e)
|
|
|
{
|
|
|
message = "修改失败!";
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
if (this.service.getZoneByExistName(zoneName)!=null)
|
|
|
{
|
|
|
message = "库区代码已存在,请检查!";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
sysZone.CreateUserId = CurrentEmp.EmpId;
|
|
|
this.service.saveZone(sysZone);
|
|
|
message = "添加成功";
|
|
|
}
|
|
|
}
|
|
|
catch (Exception e)
|
|
|
{
|
|
|
message = "添加失败!";
|
|
|
}
|
|
|
}
|
|
|
|
|
|
Hashtable result = new Hashtable();
|
|
|
result.Add("message", message);
|
|
|
return Json(result) ;
|
|
|
}
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// 编辑菜单
|
|
|
/// </summary>
|
|
|
/// <param name="ruid"></param>
|
|
|
/// <returns></returns>
|
|
|
public ActionResult editZone(String zoneId)
|
|
|
{
|
|
|
if (!string.IsNullOrEmpty(zoneId))
|
|
|
{
|
|
|
Hashtable ht = this.service.getZoneDetail(zoneId);
|
|
|
ViewData.Add("editType", "edit");
|
|
|
|
|
|
ViewData.Add("zoneId", ht["zoneId"]);
|
|
|
ViewData.Add("zoneName", ht["zoneName"]);
|
|
|
ViewData.Add("zoneDesc", ht["zoneDesc"]);
|
|
|
ViewData.Add("erpWarehouse", ht["erpWarehouse"]);
|
|
|
ViewData.Add("warehouseId", ht["warehouseId"]);
|
|
|
ViewData.Add("factoryId", ht["factoryId"]);
|
|
|
|
|
|
ViewData.Add("enabled", ht["enabled"]);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
ViewData.Add("editType", "new");
|
|
|
}
|
|
|
return View("EditZoneDefine");
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 删除菜单
|
|
|
/// </summary>
|
|
|
/// <param name="ids"></param>
|
|
|
/// <returns></returns>
|
|
|
public ActionResult deleteZone(String ids)
|
|
|
{
|
|
|
int delCount = 0;
|
|
|
try
|
|
|
{
|
|
|
delCount = this.service.deleteZone(ids);
|
|
|
}
|
|
|
catch(Exception e)
|
|
|
{
|
|
|
delCount = -1;
|
|
|
}
|
|
|
Hashtable result = new Hashtable();
|
|
|
result.Add("status", delCount);
|
|
|
return Json(result);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 启用
|
|
|
/// </summary>
|
|
|
/// <param name="ids"></param>
|
|
|
/// <returns></returns>
|
|
|
public ActionResult onEnable(String ids)
|
|
|
{
|
|
|
int delCount = 0;
|
|
|
try
|
|
|
{
|
|
|
delCount = this.service.EnableZone(ids);
|
|
|
}
|
|
|
catch (Exception e)
|
|
|
{
|
|
|
delCount = -1;
|
|
|
}
|
|
|
Hashtable result = new Hashtable();
|
|
|
result.Add("status", delCount);
|
|
|
return Json(result);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 禁用
|
|
|
/// </summary>
|
|
|
/// <param name="ids"></param>
|
|
|
/// <returns></returns>
|
|
|
public ActionResult onDisable(String ids)
|
|
|
{
|
|
|
int delCount = 0;
|
|
|
try
|
|
|
{
|
|
|
delCount = this.service.DisableZone(ids);
|
|
|
}
|
|
|
catch (Exception e)
|
|
|
{
|
|
|
delCount = -1;
|
|
|
}
|
|
|
Hashtable result = new Hashtable();
|
|
|
result.Add("status", delCount);
|
|
|
return Json(result);
|
|
|
}
|
|
|
/// 导入
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
public ActionResult importFile()
|
|
|
{
|
|
|
int factoryId = CurrentEmp.FactoryId;
|
|
|
string factoryCode = CurrentEmp.FactoryCode;
|
|
|
|
|
|
Hashtable result = new Hashtable();
|
|
|
IFormFile file = Request.Form.Files[0];
|
|
|
List<ZoneDefine> data = ExcelHelper.GetList<ZoneDefine>(file, 0);
|
|
|
result = service.ImportExcel(data, factoryId, factoryCode, CurrentEmp.EmpId);
|
|
|
return Json(result);
|
|
|
}
|
|
|
|
|
|
public ActionResult uploadFile()
|
|
|
{
|
|
|
return View("uploadFile");
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 导出数据到Excel
|
|
|
/// BY NOAH
|
|
|
/// </summary>carImport
|
|
|
/// <returns></returns>
|
|
|
public ActionResult exportData(string zoneName, string zoneDesc, string enabled = "Y")
|
|
|
{
|
|
|
List<ZoneDefine> listHt = this.service.getExportList(zoneName, zoneDesc, enabled, CurrentEmp.FactoryId);
|
|
|
var memoryStream = ExcelHelper.ToExcel(listHt);
|
|
|
string dateTime = DateTime.Now.ToString("yyyyMMddHHmmss");
|
|
|
return File(memoryStream.ToArray(), "application/ms-excel", "库区管理" + dateTime + ".xls");
|
|
|
}
|
|
|
|
|
|
/// <summary>k
|
|
|
/// 下载模板
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
public ActionResult downLoadExcel(string rackPart, string partPackage, string enabled = "Y")
|
|
|
{
|
|
|
List<ZoneDefine> listHt = new List<ZoneDefine>();//导出空数据模板
|
|
|
var memoryStream = ExcelHelper.ToExcel(listHt);
|
|
|
string dateTime = DateTime.Now.ToString("yyyyMMddHHmmss");
|
|
|
return File(memoryStream.ToArray(), "application/ms-excel", "库区管理"+ dateTime + ".xls");
|
|
|
}
|
|
|
}
|
|
|
}
|