|
|
using Aspose.Cells;
|
|
|
using Estsh.Core.Controllers;
|
|
|
using Estsh.Core.Model.Result;
|
|
|
using Estsh.Core.Models;
|
|
|
using Estsh.Core.Services.IServices;
|
|
|
using Estsh.Core.Util;
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
using NPOI.HSSF.UserModel;
|
|
|
using System.Collections;
|
|
|
|
|
|
/***************************************************************************************************
|
|
|
*
|
|
|
* 更新人:sitong.dong
|
|
|
* 描述:抽样模块控制类
|
|
|
* 修改时间:2022.06.22
|
|
|
* 修改日志:系统迭代升级
|
|
|
*
|
|
|
**************************************************************************************************/
|
|
|
namespace Estsh.Core.Web.Controllers
|
|
|
{
|
|
|
/// <summary>
|
|
|
/// 抽样模块控制类
|
|
|
/// </summary>
|
|
|
public class SampleTestDefineController : BaseController
|
|
|
{
|
|
|
private ISampleTestDefineService service;
|
|
|
public SampleTestDefineController(ISampleTestDefineService _service)
|
|
|
{
|
|
|
service = _service;
|
|
|
}
|
|
|
//
|
|
|
// GET: /Menu/
|
|
|
public ActionResult Index()
|
|
|
{
|
|
|
return View();
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取抽样管理列表数据
|
|
|
/// </summary>
|
|
|
/// <param name="view_board_name"></param>
|
|
|
/// <param name="pager"></param>
|
|
|
/// <param name="direction"></param>
|
|
|
/// <param name="sort"></param>
|
|
|
/// <returns></returns>
|
|
|
public ActionResult GetListByPage(String typeName, String modelName, Pager pager, String direction, String sort)
|
|
|
{
|
|
|
Hashtable result = new Hashtable();
|
|
|
result.Add("pager.pageNo", pager.pageNo);
|
|
|
Hashtable dataHt = this.service.GetListByPage(typeName, modelName, 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>
|
|
|
/// <rehuoturns></returns>
|
|
|
public ActionResult GetSelectModelType()
|
|
|
{
|
|
|
Hashtable result = new Hashtable();
|
|
|
List<KeyValueResult> list = this.service.GetSelectModelType();
|
|
|
result.Add("list", list);
|
|
|
return Json(result);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取父节点抽样下拉列表数据
|
|
|
/// </summary>
|
|
|
/// <rehuoturns></returns>
|
|
|
public ActionResult GetSelectModel()
|
|
|
{
|
|
|
Hashtable result = new Hashtable();
|
|
|
List<KeyValueResult> list = this.service.GetSelectModel();
|
|
|
result.Add("list", list);
|
|
|
return Json(result);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 保存抽样数据
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
public ActionResult Save()
|
|
|
{
|
|
|
String editType = Request.Form["editType"].ToString();
|
|
|
|
|
|
String testplanId = Request.Form["testplanId"].ToString();
|
|
|
String modelId = Request.Form["modelId"].ToString();
|
|
|
String startDate = Request.Form["startDate"].ToString();
|
|
|
String endDate = Request.Form["endDate"].ToString();
|
|
|
String lotQty = Request.Form["lotQty"].ToString();
|
|
|
String enabled = Request.Form["enabled"].ToString();
|
|
|
|
|
|
GAbTestplan gAbTestplan = new GAbTestplan();
|
|
|
gAbTestplan.ModelId = Convert.ToInt32(modelId);
|
|
|
gAbTestplan.StartDate = startDate;
|
|
|
gAbTestplan.EndDate = endDate;
|
|
|
gAbTestplan.LotQty =Convert.ToInt32( lotQty);
|
|
|
gAbTestplan.Enabled = enabled;
|
|
|
|
|
|
String message = "";
|
|
|
if (editType != null && editType.Trim().Equals("edit"))
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
gAbTestplan.UpdateUserId = CurrentEmp.EmpId;
|
|
|
gAbTestplan.TestplanId = Convert.ToInt32(testplanId);
|
|
|
|
|
|
this.service.Update(gAbTestplan);
|
|
|
message = "修改成功";
|
|
|
}
|
|
|
catch (Exception e)
|
|
|
{
|
|
|
message = "修改失败!";
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
gAbTestplan.CreateUserId = CurrentEmp.EmpId;
|
|
|
this.service.Insert(gAbTestplan);
|
|
|
message = "添加成功";
|
|
|
}
|
|
|
catch (Exception e)
|
|
|
{
|
|
|
message = "添加失败!";
|
|
|
}
|
|
|
}
|
|
|
|
|
|
Hashtable result = new Hashtable();
|
|
|
result.Add("message", message);
|
|
|
return Json(result);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 查看抽样详情
|
|
|
/// </summary>
|
|
|
/// <param name="ruid"></param>
|
|
|
/// <returns></returns>
|
|
|
public ActionResult GetDetail(String testplanId)
|
|
|
{
|
|
|
List<GAbTestplan> Info = this.service.GetDetail(testplanId);
|
|
|
ViewData.Add("typeName", Info[0].TypeName);
|
|
|
ViewData.Add("modelName", Info[0].ModelName);
|
|
|
ViewData.Add("startDate", Info[0].StartDate);
|
|
|
ViewData.Add("endDate", Info[0].EndDate);
|
|
|
ViewData.Add("lotQty", Info[0].LotQty);
|
|
|
ViewData.Add("qty", Info[0].Qty);
|
|
|
ViewData.Add("locationCounter", Info[0].LocationCounter);
|
|
|
ViewData.Add("enabled", Info[0].Enabled);
|
|
|
return View("viewSampleTestDefine");
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 编辑抽样
|
|
|
/// </summary>
|
|
|
/// <param name="ruid"></param>
|
|
|
/// <returns></returns>
|
|
|
public ActionResult Edit(String testplanId)
|
|
|
{
|
|
|
if (!string.IsNullOrEmpty(testplanId))
|
|
|
{
|
|
|
List<GAbTestplan> Info = this.service.GetDetail(testplanId);
|
|
|
ViewData.Add("editType", "edit");
|
|
|
ViewData.Add("testplanId", testplanId);
|
|
|
ViewData.Add("modelId", Info[0].ModelId);
|
|
|
ViewData.Add("startDate", Info[0].StartDate);
|
|
|
ViewData.Add("endDate", Info[0].EndDate);
|
|
|
ViewData.Add("lotQty", Info[0].LotQty);
|
|
|
ViewData.Add("enabled", Info[0].Enabled);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
ViewData.Add("editType", "new");
|
|
|
}
|
|
|
|
|
|
return View("editSampleTestDefine");
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 删除抽样
|
|
|
/// </summary>
|
|
|
/// <param name="ids"></param>
|
|
|
/// <returns></returns>
|
|
|
public ActionResult Delete(String ids)
|
|
|
{
|
|
|
int delCount = 0;
|
|
|
try
|
|
|
{
|
|
|
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);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 导出EXCEL
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
public ActionResult ExportInfo(String typeName, String modelName)
|
|
|
{
|
|
|
Workbook workbook = this.service.ExportInfo(typeName, modelName);
|
|
|
if (workbook != null)
|
|
|
{
|
|
|
////直接导出
|
|
|
//Stream outputStream = Response.OutputStream;
|
|
|
//workbook.Save(outputStream, FileFormatType.Default);
|
|
|
//Response.Buffer = true;
|
|
|
//Response.AppendHeader("Content-Disposition", "attachment;filename=BOMInfo.xls");
|
|
|
//Response.ContentEncoding = System.Text.Encoding.UTF8;
|
|
|
//Response.ContentType = "application/vnd.ms-excel";
|
|
|
//Response.Flush();
|
|
|
|
|
|
}
|
|
|
return Json("");
|
|
|
}
|
|
|
}
|
|
|
}
|