|
|
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 CarrierManageController : BaseController
|
|
|
{
|
|
|
private ICarrierManageService service;
|
|
|
public CarrierManageController(ICarrierManageService _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 getCarrierListByPage(string rackNo, 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.getCarrierListByPage(rackNo, 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>
|
|
|
/// <returns></returns>
|
|
|
public ActionResult saveCarrier()
|
|
|
{
|
|
|
String editType = Request.Form["editType"].ToString();
|
|
|
String ruid = Request.Form["ruid"].ToString();
|
|
|
String rackNo = Request.Form["rackNo"].ToString();
|
|
|
|
|
|
WmsRack wmsRack = new WmsRack();
|
|
|
wmsRack.RackNo = rackNo;
|
|
|
wmsRack.RackType = "10";
|
|
|
wmsRack.FactoryId = CurrentEmp.FactoryId;
|
|
|
wmsRack.FactoryCode = CurrentEmp.FactoryCode;
|
|
|
wmsRack.Enabled = "Y";
|
|
|
|
|
|
String message = "";
|
|
|
if (editType != null && editType.Trim().Equals("edit"))
|
|
|
{
|
|
|
wmsRack.UpdateUserId = CurrentEmp.EmpId;
|
|
|
|
|
|
wmsRack.Ruid =Convert.ToInt32(ruid);
|
|
|
|
|
|
if (this.service.updateCarrier(wmsRack) > 0)
|
|
|
{
|
|
|
message = "修改成功";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
message = "修改失败";
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
wmsRack.CreateUserId = CurrentEmp.EmpId;
|
|
|
wmsRack.Guid = Guid.NewGuid().ToString();
|
|
|
if (this.service.saveCarrier(wmsRack) > 0)
|
|
|
{
|
|
|
message = "添加成功";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
message = "添加失败";
|
|
|
}
|
|
|
}
|
|
|
|
|
|
Hashtable result = new Hashtable();
|
|
|
result.Add("message", message);
|
|
|
return Json(result);
|
|
|
}
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// 编辑菜单
|
|
|
/// </summary>
|
|
|
/// <param name="ruid"></param>
|
|
|
/// <returns></returns>
|
|
|
public ActionResult editCarrierManage(String ruid)
|
|
|
{
|
|
|
if (!string.IsNullOrEmpty(ruid))
|
|
|
{
|
|
|
Hashtable ht = this.service.getCarrierDetail(ruid);
|
|
|
ViewData.Add("editType", "edit");
|
|
|
|
|
|
ViewData.Add("ruid", ht["ruid"]);
|
|
|
ViewData.Add("rackNo", ht["rackNo"]);
|
|
|
ViewData.Add("rackType", ht["rackType"]);
|
|
|
ViewData.Add("factoryId", ht["factoryId"]);
|
|
|
ViewData.Add("enabled", ht["enabled"]);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
ViewData.Add("editType", "new");
|
|
|
}
|
|
|
return View("EditCarrierManage");
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 导入台车号
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
public ActionResult carImport()
|
|
|
{
|
|
|
int factoryId = CurrentEmp.FactoryId;
|
|
|
string factoryCode = CurrentEmp.FactoryCode;
|
|
|
|
|
|
Hashtable result = new Hashtable();
|
|
|
IFormFile file = Request.Form.Files[0];
|
|
|
List<CarrierManage> data = ExcelHelper.GetList<CarrierManage>(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 rackNo, string enabled="Y")
|
|
|
{
|
|
|
List<CarrierManage> listHt = this.service.getExportList(rackNo, enabled, CurrentEmp.FactoryId.ToString());
|
|
|
var memoryStream = ExcelHelper.ToExcel(listHt);
|
|
|
string dateTime = DateTime.Now.ToString("yyyyMMddHHmmss");
|
|
|
return File(memoryStream.ToArray(), "application/ms-excel", "台车管理"+ dateTime + ".xls");
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 下载模板
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
public ActionResult downLoadExcel(string rackPart, string partPackage, string enabled = "Y")
|
|
|
{
|
|
|
List<CarrierManage> listHt = new List<CarrierManage>();//导出空数据模板
|
|
|
var memoryStream = ExcelHelper.ToExcel(listHt);
|
|
|
string dateTime = DateTime.Now.ToString("yyyyMMddHHmmss");
|
|
|
return File(memoryStream.ToArray(), "application/ms-excel", "台车管理"+ dateTime + ".xls");
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 启用
|
|
|
/// </summary>
|
|
|
/// <param name="ids"></param>
|
|
|
/// <returns></returns>
|
|
|
public ActionResult onEnable(String ids)
|
|
|
{
|
|
|
int delCount = 0;
|
|
|
try
|
|
|
{
|
|
|
delCount = this.service.EnableCarrier(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.DisableCarrier(ids);
|
|
|
}
|
|
|
catch (Exception e)
|
|
|
{
|
|
|
delCount = -1;
|
|
|
}
|
|
|
Hashtable result = new Hashtable();
|
|
|
result.Add("status", delCount);
|
|
|
return Json(result);
|
|
|
}
|
|
|
}
|
|
|
}
|