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.

137 lines
4.4 KiB
C#

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

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 Estsh.Core.Model.ExcelModel;
using Estsh.Core.Util;
/***************************************************************************************************
*
* 更新人sitong.dong
* 描述BOM查询
* 修改时间2022.06.22
* 修改日志:系统迭代升级
*
**************************************************************************************************/
namespace Estsh.Core.Web.Controllers
{
public class BOMSearchController : BaseController
{
private IBOMSearchService service;
public BOMSearchController(IBOMSearchService _service)
{
service = _service;
}
//
// GET: /BOMSearchController/
public ActionResult Index()
{
return View();
}
/// <summary>
/// 获取BOM数据列表
/// </summary>
/// <param name="bomType"></param>
/// <param name="partNo"></param>
/// <param name="sort"></param>
/// <param name="direction"></param>
/// <returns></returns>
public ActionResult getListByPage(String partNo,string partSpec, string itemPartNo,string itemPartSpec, Pager pager, String direction, String sort, string enabled = "Y")
{
string factoryId = CurrentEmp.FactoryId.ToString();
Hashtable result = new Hashtable();
result.Add("pager.pageNo", pager.pageNo);
Hashtable dataHt = this.service.getListByPage(partNo, partSpec, itemPartNo, itemPartSpec, 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);
}
#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>
/// 导出Bom 数据
/// </summary>
/// <returns></returns>
public ActionResult exportBOMInfo(String bomType, String partId)
{
List<BOMDefine> dataHt = this.service.exportBOMInfo(bomType, partId);
var memoryStream = ExcelHelper.ToExcel(dataHt);
return File(memoryStream.ToArray(), "application/ms-excel", "BOM管理.xls");
}
public ActionResult exportALL(String bomType)
{
List<BOMDefine> dataHt = this.service.exportALL(bomType);
var memoryStream = ExcelHelper.ToExcel(dataHt);
return File(memoryStream.ToArray(), "application/ms-excel", "BOM管理.xls");
}
}
}