|
|
using System.Collections;
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
using Estsh.Core.Services.IServices;
|
|
|
using Estsh.Core.Models;
|
|
|
using Estsh.Core.Util;
|
|
|
using Estsh.Core.Controllers;
|
|
|
using Estsh.Core.Model.Result;
|
|
|
using Estsh.Core.Model.ExcelModel;
|
|
|
|
|
|
/***************************************************************************************************
|
|
|
*
|
|
|
* 更新人:sitong.dong
|
|
|
* 描述:零件免检清单模块控制类
|
|
|
* 修改时间:2022.06.22
|
|
|
* 修改日志:系统迭代升级
|
|
|
*
|
|
|
**************************************************************************************************/
|
|
|
namespace Estsh.Core.Web.Controllers
|
|
|
{
|
|
|
/// <summary>
|
|
|
/// 零件免检清单模块控制类
|
|
|
/// </summary>
|
|
|
public class PartExemptionListDefineController : BaseController
|
|
|
{
|
|
|
private IPartExemptionListDefineService service;
|
|
|
public PartExemptionListDefineController(IPartExemptionListDefineService _service)
|
|
|
{
|
|
|
service = _service;
|
|
|
}
|
|
|
//
|
|
|
// GET: /Menu/
|
|
|
public ActionResult Index()
|
|
|
{
|
|
|
return View();
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取零件免检清单管理列表数据
|
|
|
/// </summary>
|
|
|
/// <param name="partNo"></param>
|
|
|
/// <param name="pager"></param>
|
|
|
/// <param name="direction"></param>
|
|
|
/// <param name="sort"></param>
|
|
|
/// <returns></returns>
|
|
|
public ActionResult GetListByPage(String partNo,String partSpec, Pager pager, String direction, String sort, String enabled = "Y")
|
|
|
{
|
|
|
Hashtable result = new Hashtable();
|
|
|
result.Add("pager.pageNo", pager.pageNo);
|
|
|
Hashtable dataHt = this.service.GetListByPage(partNo, partSpec, 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 GetSelect()
|
|
|
{
|
|
|
Hashtable result = new Hashtable();
|
|
|
List<KeyValueResult> list = this.service.GetSelect();
|
|
|
result.Add("list", list);
|
|
|
return Json(result);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 保存零件免检清单数据
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
public ActionResult Save()
|
|
|
{
|
|
|
String editType = Request.Form["editType"].ToString();
|
|
|
|
|
|
String partId = Request.Form["partId"].ToString();
|
|
|
String partNo = Request.Form["partNo"].ToString();
|
|
|
|
|
|
SysExemptionList sysExemptionList = new SysExemptionList();
|
|
|
Hashtable result = new Hashtable();
|
|
|
|
|
|
String message = "";
|
|
|
if (editType != null && editType.Trim().Equals("edit"))
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
|
|
|
List<SysPart> sysParts = this.service.GetDetailByName(partNo);//根据零件号查询
|
|
|
if (sysParts.Count == 0)
|
|
|
{
|
|
|
message = "零件号不存在!";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
List<SysExemptionList> ht1 = this.service.ifExemptionList(sysParts[0].PartNo);
|
|
|
if (ht1.Count != 0)
|
|
|
{
|
|
|
message = "该零件号已存在于免检清单中!";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
sysExemptionList.oldPartId = Convert.ToInt32(partId);
|
|
|
sysExemptionList.newPartId = Convert.ToInt32(sysParts[0].PartId);
|
|
|
sysExemptionList.PartNo = partNo;
|
|
|
sysExemptionList.UpdateUserId = CurrentEmp.EmpId;
|
|
|
this.service.Update(sysExemptionList);
|
|
|
message = "修改成功";
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
catch (Exception e)
|
|
|
{
|
|
|
message = "修改失败!";
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
List<SysPart> sysParts = this.service.GetDetailByName(partNo);//根据零件号查询
|
|
|
if (sysParts.Count == 0)
|
|
|
{
|
|
|
message = "零件号不存在!";
|
|
|
result.Add("message", message);
|
|
|
return Json(result);
|
|
|
}
|
|
|
|
|
|
List<SysExemptionList> ht1 = this.service.ifExemptionList(sysParts[0].PartNo);
|
|
|
if (ht1.Count != 0)
|
|
|
{
|
|
|
message = "该零件号已存在于免检清单中!";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
sysExemptionList.CreateUserId = CurrentEmp.EmpId;
|
|
|
sysExemptionList.PartId = Convert.ToInt32(sysParts[0].PartId);
|
|
|
sysExemptionList.PartNo = sysParts[0].PartNo;
|
|
|
this.service.Insert(sysExemptionList);
|
|
|
message = "添加成功";
|
|
|
}
|
|
|
}
|
|
|
catch (Exception e)
|
|
|
{
|
|
|
message = "添加失败!";
|
|
|
}
|
|
|
}
|
|
|
|
|
|
result.Add("message", message);
|
|
|
return Json(result);
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 导入免检清单
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
public ActionResult partImport()
|
|
|
{
|
|
|
int factoryId = CurrentEmp.FactoryId;
|
|
|
string factoryCode = CurrentEmp.FactoryCode;
|
|
|
|
|
|
Hashtable result = new Hashtable();
|
|
|
IFormFile file = Request.Form.Files[0];
|
|
|
List<PartExemptionList> data = ExcelHelper.GetList<PartExemptionList>(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 partNo, string enabled = "Y")
|
|
|
{
|
|
|
List<PartExemptionList> listHt = this.service.getExportList(partNo, enabled);
|
|
|
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<PartExemptionList> listHt = new List<PartExemptionList>();//导出空数据模板
|
|
|
var memoryStream = ExcelHelper.ToExcel(listHt);
|
|
|
string dateTime = DateTime.Now.ToString("yyyyMMddHHmmss");
|
|
|
return File(memoryStream.ToArray(), "application/ms-excel", "零件免检清单"+ dateTime + ".xls");
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 编辑零件免检清单
|
|
|
/// </summary>
|
|
|
/// <param name="ruid"></param>
|
|
|
/// <returns></returns>
|
|
|
public ActionResult Edit(String partNo)
|
|
|
{
|
|
|
if (!string.IsNullOrEmpty(partNo))
|
|
|
{
|
|
|
List<SysExemptionList> Info = this.service.ifExemptionList(partNo);
|
|
|
ViewData.Add("editType", "edit");
|
|
|
ViewData.Add("partId", Info[0].PartId);
|
|
|
ViewData.Add("partNo", Info[0].PartNo);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
ViewData.Add("editType", "new");
|
|
|
}
|
|
|
return View("editPartExemptionListDefine");
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 删除零件免检清单
|
|
|
/// </summary>
|
|
|
/// <param name="ids"></param>
|
|
|
/// <returns></returns>
|
|
|
public ActionResult Delete(String ids)
|
|
|
{
|
|
|
int delCount = 0;
|
|
|
try
|
|
|
{
|
|
|
ids = ids.Substring(0, ids.Length - 1);
|
|
|
delCount = this.service.Delete(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.EnableData(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.DisableData(ids);
|
|
|
}
|
|
|
catch (Exception e)
|
|
|
{
|
|
|
delCount = -1;
|
|
|
}
|
|
|
Hashtable result = new Hashtable();
|
|
|
result.Add("status", delCount);
|
|
|
return Json(result);
|
|
|
}
|
|
|
}
|
|
|
}
|