|
|
using Dapper;
|
|
|
using Estsh.Core.Controllers;
|
|
|
using Estsh.Core.Model.ExcelModel;
|
|
|
using Estsh.Core.Model.Result;
|
|
|
using Estsh.Core.Models;
|
|
|
using Estsh.Core.Services;
|
|
|
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 PDLineDefineController : BaseController
|
|
|
{
|
|
|
private IPDLineDefineService service;
|
|
|
private ICommonService commonService;
|
|
|
public PDLineDefineController(IPDLineDefineService _service, ICommonService _commonService)
|
|
|
{
|
|
|
service = _service;
|
|
|
commonService = _commonService;
|
|
|
}
|
|
|
//
|
|
|
// 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 getPDLineListByPage(String pdlineCode, String pdlineName, 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.getPDLineListByPage(pdlineCode, pdlineName, factoryid, pager, direction, sort, enabled);
|
|
|
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 getFactoryList()
|
|
|
{
|
|
|
Hashtable result = new Hashtable();
|
|
|
List<KeyValueResult> menuList = commonService.getFactoryInfo();
|
|
|
result.Add("list", menuList);
|
|
|
return Json(result);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取线边库区下拉列表数据
|
|
|
/// </summary>
|
|
|
/// <rehuoturns></returns>
|
|
|
public ActionResult getSelectSrcZone()
|
|
|
{
|
|
|
int factoryid = CurrentEmp.FactoryId;
|
|
|
Hashtable result = new Hashtable();
|
|
|
List<KeyValueResult> menuList = service.getSelectSrcZone(factoryid);
|
|
|
result.Add("list", menuList);
|
|
|
return Json(result);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取线边库位拉列表数据
|
|
|
/// </summary>
|
|
|
/// <rehuoturns></returns>
|
|
|
public ActionResult getSelectSrcLocate(string zoneId)
|
|
|
{
|
|
|
int factoryid = CurrentEmp.FactoryId;
|
|
|
Hashtable result = new Hashtable();
|
|
|
List<KeyValueResult> menuList = service.getSelectSrcLocate(zoneId, factoryid);
|
|
|
result.Add("list", menuList);
|
|
|
return Json(result);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取成品库区下拉列表数据
|
|
|
/// </summary>
|
|
|
/// <rehuoturns></returns>
|
|
|
public ActionResult getSelectDestZone()
|
|
|
{
|
|
|
int factoryid = CurrentEmp.FactoryId;
|
|
|
Hashtable result = new Hashtable();
|
|
|
List<KeyValueResult> menuList = service.getSelectDestZone(factoryid);
|
|
|
result.Add("list", menuList);
|
|
|
return Json(result);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取成品库位拉列表数据
|
|
|
/// </summary>
|
|
|
/// <rehuoturns></returns>
|
|
|
public ActionResult getSelectDestLocate(string zoneId)
|
|
|
{
|
|
|
int factoryid = CurrentEmp.FactoryId;
|
|
|
Hashtable result = new Hashtable();
|
|
|
List<KeyValueResult> menuList = service.getSelectDestLocate(zoneId, factoryid);
|
|
|
result.Add("list", menuList);
|
|
|
return Json(result);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 保存产线数据
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
public ActionResult savePdline()
|
|
|
{
|
|
|
String editType = Request.Form["editType"].ToString();
|
|
|
|
|
|
String pdlineId = Request.Form["pdlineId"].ToString();
|
|
|
String pdlineCode = Request.Form["pdlineCode"].ToString();
|
|
|
String pdlineName = Request.Form["pdlineName"].ToString();
|
|
|
String pdlineDesc = Request.Form["pdlineDesc"].ToString();
|
|
|
String enabled = Request.Form["enabled"].ToString();
|
|
|
String partPrepare = Request.Form["partPrepare"].ToString();
|
|
|
|
|
|
List<SysZone> sysZones = service.getSelectZone();
|
|
|
List<SysLocate> sysLocates = service.getSelectLocate();
|
|
|
int srcZoneId = Convert.ToInt32(String.IsNullOrEmpty(Request.Form["srcZoneId"].ToString()) ? 0 : Request.Form["srcZoneId"].ToString());
|
|
|
String srcZoneName = "";
|
|
|
int srcWarehouseId = 0;
|
|
|
string srcWarehouseName = "";
|
|
|
if (!srcZoneId.Equals(0))
|
|
|
{
|
|
|
List<SysZone> srczones = sysZones.Where(a => a.ZoneId == srcZoneId).ToList();
|
|
|
srcZoneName = srczones[0].ZoneName;
|
|
|
srcWarehouseId = srczones[0].WarehouseId;
|
|
|
srcWarehouseName = srczones[0].WarehouseName;
|
|
|
}
|
|
|
|
|
|
int srcLocateId = Convert.ToInt32(String.IsNullOrEmpty(Request.Form["srcLocateId"].ToString()) ? 0 : Request.Form["srcLocateId"].ToString());
|
|
|
String srcLocateName = "";
|
|
|
if (!srcLocateId.Equals(0))
|
|
|
{
|
|
|
List<SysLocate> srclocates = sysLocates.Where(a => a.LocateId == srcLocateId).ToList();
|
|
|
srcLocateName = srclocates[0].LocateName;
|
|
|
}
|
|
|
|
|
|
int destZoneId = Convert.ToInt32(String.IsNullOrEmpty(Request.Form["destZoneId"].ToString()) ? 0 : Request.Form["destZoneId"].ToString());
|
|
|
String destZoneName = "";
|
|
|
int destWarehouseId = 0;
|
|
|
string destWarehouseName = "";
|
|
|
if (!destZoneId.Equals(0))
|
|
|
{
|
|
|
List<SysZone> destzones = sysZones.Where(a => a.ZoneId == destZoneId).ToList();
|
|
|
destZoneName = destzones[0].ZoneName;
|
|
|
destWarehouseId = destzones[0].WarehouseId;
|
|
|
destWarehouseName = destzones[0].WarehouseName;
|
|
|
}
|
|
|
|
|
|
int destLocateId = Convert.ToInt32(String.IsNullOrEmpty(Request.Form["destLocateId"].ToString()) ? 0 : Request.Form["destLocateId"].ToString());
|
|
|
String destLocateName = "";
|
|
|
if (!destLocateId.Equals(0))
|
|
|
{
|
|
|
List<SysLocate> destlocates = sysLocates.Where(a => a.LocateId == destLocateId).ToList();
|
|
|
destLocateName = destlocates[0].LocateName;
|
|
|
}
|
|
|
|
|
|
SysPdline sysPdline = new SysPdline();
|
|
|
sysPdline.PdlineCode = pdlineCode;
|
|
|
sysPdline.PdlineName = pdlineName;
|
|
|
sysPdline.PdlineDesc = pdlineDesc;
|
|
|
|
|
|
sysPdline.SrcWarehouseId = srcWarehouseId;
|
|
|
sysPdline.SrcWarehouseName = srcWarehouseName;
|
|
|
sysPdline.DestWarehouseId = destWarehouseId;
|
|
|
sysPdline.DestWarehouseName = destWarehouseName;
|
|
|
|
|
|
|
|
|
sysPdline.SrcZoneId = srcZoneId;
|
|
|
sysPdline.SrcLocateId = srcLocateId;
|
|
|
sysPdline.DestZoneId = destZoneId;
|
|
|
sysPdline.DestLocateId = destLocateId;
|
|
|
|
|
|
sysPdline.SrcZoneName = srcZoneName;
|
|
|
sysPdline.SrcLocateName = srcLocateName;
|
|
|
sysPdline.DestZoneName = destZoneName;
|
|
|
sysPdline.DestLocateName = destLocateName;
|
|
|
|
|
|
sysPdline.FactoryId = CurrentEmp.FactoryId;
|
|
|
sysPdline.FactoryCode = CurrentEmp.FactoryCode; ;
|
|
|
sysPdline.Enabled = enabled;
|
|
|
sysPdline.PartPrepare = int.Parse(partPrepare);
|
|
|
|
|
|
|
|
|
String message = "";
|
|
|
String flag = "";
|
|
|
if (editType != null && editType.Trim().Equals("edit"))
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
sysPdline.PdlineId = Convert.ToInt32(pdlineId);
|
|
|
sysPdline.UpdateUserId = CurrentEmp.EmpId;
|
|
|
this.service.updatePdline(sysPdline);
|
|
|
message = "修改成功";
|
|
|
flag = "OK";
|
|
|
}
|
|
|
catch (Exception e)
|
|
|
{
|
|
|
message = "修改失败!";
|
|
|
flag = "Fail";
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
sysPdline.CreateUserId = CurrentEmp.EmpId;
|
|
|
this.service.savePdline(sysPdline);
|
|
|
message = "添加成功";
|
|
|
flag = "OK";
|
|
|
}
|
|
|
catch (Exception e)
|
|
|
{
|
|
|
message = "添加失败!";
|
|
|
flag = "Fail";
|
|
|
}
|
|
|
}
|
|
|
|
|
|
Hashtable result = new Hashtable();
|
|
|
result.Add("message", message);
|
|
|
result.Add("flag", flag);
|
|
|
return Json(result);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 查看菜单详情
|
|
|
/// </summary>
|
|
|
/// <param name="ruid"></param>
|
|
|
/// <returns></returns>
|
|
|
public ActionResult getPdlineDetail(String pdlineId)
|
|
|
{
|
|
|
|
|
|
ViewData.Add("editType", "edit");
|
|
|
Hashtable ht = this.service.getPdlineDetail(pdlineId);
|
|
|
ViewData.Add("pdlineId", ht["pdlineId"]);
|
|
|
ViewData.Add("pdlineCode", ht["pdlineCode"]);
|
|
|
ViewData.Add("pdlineName", ht["pdlineName"]);
|
|
|
ViewData.Add("factoryId", ht["factoryId"]);
|
|
|
ViewData.Add("factoryName", ht["factoryName"]);
|
|
|
ViewData.Add("pdlineDesc", ht["pdlineDesc"]);
|
|
|
|
|
|
ViewData.Add("srcZoneId", ht["srcZoneId"]);
|
|
|
ViewData.Add("srcLocateId", ht["srcLocateId"]);
|
|
|
ViewData.Add("destZoneId", ht["destZoneId"]);
|
|
|
ViewData.Add("destLocateId", ht["destLocateId"]);
|
|
|
|
|
|
ViewData.Add("enabled", ht["enabled"]);
|
|
|
ViewData.Add("partPrepare", ht["partPrepare"]);
|
|
|
|
|
|
return View("ViewPDLineDefine");
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 编辑菜单
|
|
|
/// </summary>
|
|
|
/// <param name="ruid"></param>
|
|
|
/// <returns></returns>
|
|
|
public ActionResult editPdline(String pdlineId)
|
|
|
{
|
|
|
if (!string.IsNullOrEmpty(pdlineId))
|
|
|
{
|
|
|
Hashtable ht = this.service.getPdlineDetail(pdlineId);
|
|
|
ViewData.Add("editType", "edit");
|
|
|
|
|
|
ViewData.Add("pdlineId", ht["pdlineId"]);
|
|
|
ViewData.Add("pdlineCode", ht["pdlineCode"]);
|
|
|
ViewData.Add("pdlineName", ht["pdlineName"]);
|
|
|
ViewData.Add("factoryId", ht["factoryId"]);
|
|
|
ViewData.Add("factoryName", ht["factoryName"]);
|
|
|
ViewData.Add("pdlineDesc", ht["pdlineDesc"]);
|
|
|
|
|
|
ViewData.Add("srcZoneId", ht["srcZoneId"]);
|
|
|
ViewData.Add("srcLocateId", ht["srcLocateId"]);
|
|
|
ViewData.Add("destZoneId", ht["destZoneId"]);
|
|
|
ViewData.Add("destLocateId", ht["destLocateId"]);
|
|
|
ViewData.Add("partPrepare", ht["partPrepare"]);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
ViewData.Add("editType", "new");
|
|
|
}
|
|
|
|
|
|
return View("EditPDLineDefine");
|
|
|
}
|
|
|
|
|
|
#region 过滤库位
|
|
|
public ActionResult GetLocateName(string q)
|
|
|
{
|
|
|
List<string> list = fileLocateName(q);
|
|
|
return writeResult(list);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 过滤库位
|
|
|
/// </summary>
|
|
|
/// <param name="key"></param>
|
|
|
/// <returns></returns>
|
|
|
public List<string> fileLocateName(string key)
|
|
|
{
|
|
|
Hashtable autoComplateList = GetItemLocateName(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 GetItemLocateName(string key)
|
|
|
{
|
|
|
List<String> autoComplateList = new List<string>();
|
|
|
Hashtable result = new Hashtable();
|
|
|
|
|
|
try
|
|
|
{
|
|
|
List<SysLocate> dt = service.GetLocateInfo(key);
|
|
|
for (int i = 0; i < dt.Count; i++)
|
|
|
{
|
|
|
result.Add(dt[i].LocateId.ToString(), dt[i].LocateName.ToString());
|
|
|
|
|
|
}
|
|
|
}
|
|
|
catch (Exception e)
|
|
|
{
|
|
|
result = new Hashtable();
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 过滤零件号
|
|
|
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
|
|
|
|
|
|
|
|
|
private ActionResult writeResult(List<string> list)
|
|
|
{
|
|
|
Hashtable result = new Hashtable();
|
|
|
result.Add("list", list);
|
|
|
return Json(result);
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// 删除菜单
|
|
|
/// </summary>
|
|
|
/// <param name="ids"></param>
|
|
|
/// <returns></returns>
|
|
|
public ActionResult deletePdLine(String ids)
|
|
|
{
|
|
|
int delCount = 0;
|
|
|
try
|
|
|
{
|
|
|
delCount = this.service.deleteMenu(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.EnablePdline(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.DisablePdline(ids);
|
|
|
}
|
|
|
catch (Exception e)
|
|
|
{
|
|
|
delCount = -1;
|
|
|
}
|
|
|
Hashtable result = new Hashtable();
|
|
|
result.Add("status", delCount);
|
|
|
return Json(result);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 导入
|
|
|
/// </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<PDLineDefine> data = ExcelHelper.GetList<PDLineDefine>(file, 0);
|
|
|
result = service.ImportExcel(data, factoryId, factoryCode, CurrentEmp.EmpId);
|
|
|
return Json(result);
|
|
|
}
|
|
|
|
|
|
public ActionResult uploadFile()
|
|
|
{
|
|
|
return View("uploadFile");
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 导出数据到Excel
|
|
|
/// BY NOAH
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
public ActionResult exportData(String pdlineCode, String pdlineName, string enabled = "Y")
|
|
|
{
|
|
|
List<PDLineDefine> listHt = this.service.getExportList(pdlineCode, pdlineName, 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()
|
|
|
{
|
|
|
List<PDLineDefine> listHt = new List<PDLineDefine>();//导出空数据模板
|
|
|
var memoryStream = ExcelHelper.ToExcel(listHt);
|
|
|
string dateTime = DateTime.Now.ToString("yyyyMMddHHmmss");
|
|
|
return File(memoryStream.ToArray(), "application/ms-excel", "回冲配置" + dateTime + ".xls");
|
|
|
}
|
|
|
}
|
|
|
}
|