You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
451 lines
15 KiB
C#
451 lines
15 KiB
C#
using Estsh.Core.Controllers;
|
|
using Estsh.Core.Model.EnumUtil;
|
|
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;
|
|
|
|
namespace Estsh.Core.Web.Controllers
|
|
{
|
|
public class PullGroupMESController : BaseController
|
|
{
|
|
private IPullGroupMESService service;
|
|
public PullGroupMESController(IPullGroupMESService _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 getPullGroupListByPage(string pdlineCode, string groupName, 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.getPullGroupListByPage(pdlineCode, groupName, 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>
|
|
/// <param name="menuName"></param>
|
|
/// <param name="pager"></param>
|
|
/// <param name="direction"></param>
|
|
/// <param name="sort"></param>
|
|
/// <returns></returns>
|
|
public ActionResult getPullGroupDetailListByPage(string groupCode, string enabled = "Y")
|
|
{
|
|
int factoryId = CurrentEmp.FactoryId;
|
|
Hashtable result = new Hashtable();
|
|
Hashtable dataHt = this.service.getPullGroupDetailListByPage(groupCode, enabled, factoryId);
|
|
result.Add("rows", dataHt["dataList"]);
|
|
result.Add("pager.totalRows", dataHt["totalCount"]);
|
|
return Json(result);
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 获取父节点菜单下拉列表数据
|
|
/// </summary>
|
|
/// <rehuoturns></returns>
|
|
public ActionResult getSelectFactory()
|
|
{
|
|
Hashtable result = new Hashtable();
|
|
List<KeyValueResult> menuList = this.service.getSelectFactory();
|
|
result.Add("list", menuList);
|
|
return Json(result);
|
|
}
|
|
|
|
public ActionResult getSelectWarehouse()
|
|
{
|
|
Hashtable result = new Hashtable();
|
|
List<KeyValueResult> menuList = this.service.getSelectWarehouse();
|
|
result.Add("list", menuList);
|
|
return Json(result);
|
|
}
|
|
|
|
public ActionResult getSelectZone()
|
|
{
|
|
Hashtable result = new Hashtable();
|
|
List<KeyValueResult> menuList = this.service.getSelectZone();
|
|
result.Add("list", menuList);
|
|
return Json(result);
|
|
}
|
|
public ActionResult getSelectVendor()
|
|
{
|
|
Hashtable result = new Hashtable();
|
|
List<KeyValueResult> menuList = this.service.getSelectVendor();
|
|
result.Add("list", menuList);
|
|
return Json(result);
|
|
}
|
|
public ActionResult GetPart()
|
|
{
|
|
Hashtable result = new Hashtable();
|
|
List<KeyValueResult> menuList = this.service.GetPart();
|
|
result.Add("list", menuList);
|
|
return Json(result);
|
|
}
|
|
//public ActionResult GetPdlineByPdlineCode(string pdlineCode)
|
|
//{
|
|
// Hashtable result = new Hashtable();
|
|
// List<KeyValueResult> menuList = this.service.getSelectZone();
|
|
// result.Add("list", menuList);
|
|
// return Json(result);
|
|
//}
|
|
public ActionResult GetPdlineByKey()
|
|
{
|
|
Hashtable result = new Hashtable();
|
|
List<KeyValueResult> menuList = this.service.GetPdlineByKey();
|
|
result.Add("list", menuList);
|
|
return Json(result);
|
|
}
|
|
|
|
public ActionResult getPartNoInfo(string partNo)
|
|
{
|
|
Hashtable resault = new Hashtable();
|
|
List<SysPart> list = service.GetPartNoInfo(partNo);
|
|
return Json(list);
|
|
}
|
|
|
|
public ActionResult getPartSpecInfo(string partSpec)
|
|
{
|
|
Hashtable resault = new Hashtable();
|
|
List<SysPart> list = service.GetPartSpecInfo(partSpec);
|
|
return Json(list);
|
|
}
|
|
|
|
public ActionResult EditHandPullGroup(string pdlineCode, string maxPullValue)
|
|
{
|
|
ViewData.Add("editType", "edit");
|
|
ViewData.Add("pdlineCode", pdlineCode);
|
|
ViewData.Add("maxPullValue", maxPullValue);
|
|
return View("EditHandPullGroup");
|
|
}
|
|
|
|
public ActionResult saveHandPullGroup()
|
|
{
|
|
String pdlineCode = Request.Form["pdlineCode"].ToString();
|
|
String PullValue = Request.Form["PullValue"].ToString();
|
|
|
|
String message = "";
|
|
String status = "0";
|
|
try
|
|
{
|
|
|
|
bool ret = this.service.saveHandPullGroup(pdlineCode, PullValue);
|
|
if (ret)
|
|
{
|
|
status = "1";
|
|
message = "手工拉动成功";
|
|
}
|
|
else
|
|
{
|
|
status = "0";
|
|
message = "手工拉动失败!";
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
status = "0";
|
|
message = "手工拉动失败!";
|
|
}
|
|
|
|
Hashtable result = new Hashtable();
|
|
result.Add("status", status);
|
|
result.Add("message", message);
|
|
return Json(result);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 保存菜单数据
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public ActionResult savePullGroup()
|
|
{
|
|
string ruid = Request.Form["ruid"].ToString();
|
|
String triggerValue = Request.Form["triggerValue"].ToString();
|
|
String pullValue = Request.Form["pullValue"].ToString();
|
|
String maxPullValue = Request.Form["maxPullValue"].ToString();
|
|
|
|
int pullingType = Convert.ToInt32(String.IsNullOrEmpty(Request.Form["pullingType"]) ? 0 : Request.Form["pullingType"].ToString());
|
|
|
|
string pdlineCode = String.IsNullOrEmpty(Request.Form["pdlineCode"]) ? "" : Request.Form["pdlineCode"].ToString();
|
|
SysPdline sysPdlines = service.GetPdlineByPdlineCode(pdlineCode);
|
|
string pdlineName = "";
|
|
if (sysPdlines != null)
|
|
{
|
|
pdlineName = sysPdlines.PdlineName;
|
|
}
|
|
|
|
decimal kittingQty = Convert.ToDecimal(Request.Form["kittingQty"].ToString());
|
|
|
|
WmsPullingGroupMes wmsPulling = new WmsPullingGroupMes();
|
|
wmsPulling.TriggerValue = Convert.ToInt32(triggerValue);
|
|
wmsPulling.PullValue = Convert.ToInt32(pullValue);
|
|
|
|
wmsPulling.PdlineName = pdlineName;
|
|
wmsPulling.PdlineCode = pdlineCode;
|
|
wmsPulling.CumulativeValue = Convert.ToInt32(kittingQty);
|
|
wmsPulling.Enabled = "Y";
|
|
wmsPulling.FactoryId = CurrentEmp.FactoryId;
|
|
wmsPulling.FactoryCode = CurrentEmp.FactoryCode;
|
|
wmsPulling.CreateUserId = CurrentEmp.EmpId;
|
|
|
|
String message = "";
|
|
String status = "0";
|
|
|
|
try
|
|
{
|
|
if (string.IsNullOrEmpty(ruid))
|
|
{
|
|
wmsPulling.CreateUserId = CurrentEmp.EmpId;
|
|
|
|
int ret = this.service.savePullGroup(wmsPulling);
|
|
if (ret > 0)
|
|
{
|
|
status = "1";
|
|
message = "添加成功";
|
|
}
|
|
else
|
|
{
|
|
status = "0";
|
|
message = "添加失败!";
|
|
}
|
|
}
|
|
else
|
|
{
|
|
wmsPulling.UpdateUserId = CurrentEmp.EmpId;
|
|
|
|
int ret = this.service.updatePullGroup(wmsPulling);
|
|
if (ret > 0)
|
|
{
|
|
status = "1";
|
|
message = "修改成功";
|
|
}
|
|
else
|
|
{
|
|
status = "0";
|
|
message = "修改失败!";
|
|
}
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
status = "0";
|
|
message = "操作失败!";
|
|
}
|
|
|
|
Hashtable result = new Hashtable();
|
|
result.Add("status", status);
|
|
result.Add("message", message);
|
|
return Json(result);
|
|
}
|
|
public ActionResult GetErpwarehouse()
|
|
{
|
|
Hashtable resault = new Hashtable();
|
|
List<KeyValueResult> pdlineList = service.GetErpwarehouse();
|
|
resault.Add("list", pdlineList);
|
|
return Json(resault);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 编辑菜单
|
|
/// </summary>
|
|
/// <param name="ruid"></param>
|
|
/// <returns></returns>
|
|
public ActionResult EditPullGroup(String ruid)
|
|
{
|
|
if (!string.IsNullOrEmpty(ruid))
|
|
{
|
|
Hashtable ht = this.service.getPullGroup(ruid);
|
|
ViewData.Add("editType", "edit");
|
|
ViewData.Add("ruid", ht["ruid"]);
|
|
ViewData.Add("groupCode", ht["groupCode"]);
|
|
ViewData.Add("groupName", ht["groupName"]);
|
|
ViewData.Add("pullingType", ht["pullingType"]);
|
|
ViewData.Add("pdlineId", ht["pdlineId"]);
|
|
ViewData.Add("pdlineCode", ht["pdlineCode"]);
|
|
ViewData.Add("kittingQty", ht["kittingQty"]);
|
|
ViewData.Add("isAutoPrint", ht["isAutoPrint"]);
|
|
ViewData.Add("printCopies", ht["printCopies"]);
|
|
ViewData.Add("triggerValue", ht["triggerValue"]);
|
|
ViewData.Add("pullValue", ht["pullValue"]);
|
|
}
|
|
else
|
|
{
|
|
ViewData.Add("editType", "new");
|
|
}
|
|
return View("EditPullGroup");
|
|
}
|
|
|
|
|
|
|
|
#region 过滤零件号
|
|
private ActionResult writeResult(List<string> list)
|
|
{
|
|
Hashtable result = new Hashtable();
|
|
result.Add("list", list);
|
|
return Json(result);
|
|
}
|
|
|
|
public ActionResult GetPart_no(string q)
|
|
{
|
|
List<string> list = filePart(q);
|
|
return writeResult(list);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 过滤零件号
|
|
/// </summary>
|
|
/// <param name="key"></param>
|
|
/// <returns></returns>
|
|
public List<string> filePart(string key)
|
|
{
|
|
Hashtable autoComplateList = GetItemPart(key);
|
|
List<String> result = new List<string>();
|
|
foreach (System.Collections.DictionaryEntry item in autoComplateList)
|
|
{
|
|
if (item.Value.ToString().ToUpper().StartsWith(key.ToUpper()))
|
|
{
|
|
result.Add(item.Value.ToString());
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
/// <summary>
|
|
/// 查询零件号
|
|
/// </summary>
|
|
/// <param name="key"></param>
|
|
/// <returns></returns>
|
|
public Hashtable GetItemPart(string key)
|
|
{
|
|
List<String> autoComplateList = new List<string>();
|
|
Hashtable result = new Hashtable();
|
|
|
|
try
|
|
{
|
|
List<SysPart> dt = service.GetPartInfo(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
|
|
|
|
/// <summary>
|
|
/// 启用
|
|
/// </summary>
|
|
/// <param name="ids"></param>
|
|
/// <returns></returns>
|
|
public ActionResult onEnable(String pdlineCode)
|
|
{
|
|
int delCount = 0;
|
|
try
|
|
{
|
|
delCount = this.service.EnableData(pdlineCode);
|
|
}
|
|
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 pdlineCode)
|
|
{
|
|
int delCount = 0;
|
|
try
|
|
{
|
|
delCount = this.service.DisableData(pdlineCode);
|
|
}
|
|
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<PullGroup> data = ExcelHelper.GetList<PullGroup>(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 groupCode, string groupName, string enabled = "Y")
|
|
{
|
|
List<PullGroup> listHt = this.service.getExportList(groupCode, groupName, enabled, CurrentEmp.FactoryId);
|
|
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<PullGroup> listHt = new List<PullGroup>();//导出空数据模板
|
|
var memoryStream = ExcelHelper.ToExcel(listHt);
|
|
string dateTime = DateTime.Now.ToString("yyyyMMddHHmmss");
|
|
return File(memoryStream.ToArray(), "application/ms-excel", "拉动组管理" + dateTime + ".xls");
|
|
}
|
|
|
|
}
|
|
}
|