|
|
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 NPOI.HSSF.UserModel;
|
|
|
using System.Collections;
|
|
|
using System.Text.Json;
|
|
|
using System.Text.RegularExpressions;
|
|
|
|
|
|
/***************************************************************************************************
|
|
|
*
|
|
|
* 更新人:sitong.dong
|
|
|
* 描述:条码特征定义
|
|
|
* 修改时间:2022.06.22
|
|
|
* 修改日志:系统迭代升级
|
|
|
*
|
|
|
**************************************************************************************************/
|
|
|
namespace Estsh.Core.Web.Controllers
|
|
|
{
|
|
|
/****************************************************************
|
|
|
*
|
|
|
* 条码特征定义
|
|
|
*
|
|
|
* NOAH
|
|
|
*
|
|
|
****************************************************************/
|
|
|
public class PartSNRuleDefineController : BaseController
|
|
|
{
|
|
|
private IPartSNRuleDefineService service;
|
|
|
public PartSNRuleDefineController(IPartSNRuleDefineService _service)
|
|
|
{
|
|
|
service = _service;
|
|
|
}
|
|
|
public ActionResult Index()
|
|
|
{
|
|
|
return View();
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取条码特征定义列表数据
|
|
|
/// </summary>
|
|
|
/// <param name="partNo_search"></param>
|
|
|
/// <param name="pager"></param>
|
|
|
/// <param name="direction"></param>
|
|
|
/// <param name="sort"></param>
|
|
|
/// <returns></returns>
|
|
|
public ActionResult getPartSNRuleListByPage(String partNo_search, String type_search, String enabled_search, Pager pager, String direction, String sort)
|
|
|
{
|
|
|
Hashtable result = new Hashtable();
|
|
|
result.Add("pager.pageNo", pager.pageNo);
|
|
|
Hashtable dataHt = this.service.getPartSNRuleListByPage(partNo_search, type_search, pager, direction, sort, enabled_search="Y");
|
|
|
result.Add("rows", dataHt["dataList"]);
|
|
|
result.Add("pager.totalRows", dataHt["totalCount"]);
|
|
|
result.Add("sort", sort);
|
|
|
result.Add("direction", direction);
|
|
|
|
|
|
return Json(result);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 保存菜单数据
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
public ActionResult savePartSNRule()
|
|
|
{
|
|
|
Hashtable result = new Hashtable();
|
|
|
String message = "";
|
|
|
String flag = "";
|
|
|
|
|
|
String editType = Request.Form["editType"].ToString();
|
|
|
|
|
|
String ruid = Request.Form["ruid"].ToString();
|
|
|
|
|
|
String partNo = Request.Form["partNo"].ToString();
|
|
|
String partId;
|
|
|
String type = Request.Form["type"].ToString();
|
|
|
String lenght = Request.Form["lenght"].ToString();
|
|
|
String from1 = Request.Form["from1"].ToString();
|
|
|
String to1 = Request.Form["to1"].ToString();
|
|
|
String fix1 = Request.Form["fix1"].ToString();
|
|
|
String from2 = Request.Form["from2"].ToString();
|
|
|
String to2 = Request.Form["to2"].ToString();
|
|
|
String fix2 = Request.Form["fix2"].ToString();
|
|
|
String isValidateUnique = Request.Form["isValidateUnique"].ToString();
|
|
|
String isValidateLength = Request.Form["isValidateLength"].ToString();
|
|
|
////判断输入的值是否为数字类型
|
|
|
//if (!isNum(lenght) || !isNum(from1) || !isNum(to1) || !isNum(from2) || !isNum(to2))
|
|
|
//{
|
|
|
// message = "标记为 * 的只能输入数字!";
|
|
|
// result.Add("message", message);
|
|
|
// return Json(result);
|
|
|
//}
|
|
|
//判断输入的‘partNo’ 在数据库中是否存在
|
|
|
if (String.IsNullOrEmpty(this.service.isExsitPart_no(partNo)))
|
|
|
{
|
|
|
message = "输入的零件号不存在!";
|
|
|
flag = "Fail";
|
|
|
result.Add("message", message);
|
|
|
result.Add("flag",flag);
|
|
|
return Json(result);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
partId = this.service.isExsitPart_no(partNo);
|
|
|
}
|
|
|
|
|
|
//传递要更新的数据库字段 2013 0327 14:05 by NOAH
|
|
|
SysPartSnRule model = new SysPartSnRule();
|
|
|
model.PartId = Convert.ToInt32(partId);
|
|
|
model.Type = type;
|
|
|
model.Lenght = Convert.ToInt32(lenght);
|
|
|
model.From1 = Convert.ToInt32(from1);
|
|
|
model.To1 = Convert.ToInt32(to1);
|
|
|
model.Fix1 = fix1;
|
|
|
model.From2 = Convert.ToInt32(from2);
|
|
|
model.To2 =Convert.ToInt32( to2);
|
|
|
model.Fix2 = fix2;
|
|
|
model.IsValidateUnique = isValidateUnique;
|
|
|
model.IsValidateLength = isValidateLength;
|
|
|
|
|
|
|
|
|
if (editType != null && editType.Trim().Equals("edit"))
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
model.UpdateUserId = CurrentEmp.EmpId;
|
|
|
model.Ruid =Convert.ToInt32( ruid);
|
|
|
this.service.updatePartSNRule(model);
|
|
|
message = "修改成功";
|
|
|
flag = "OK";
|
|
|
}
|
|
|
catch (Exception e)
|
|
|
{
|
|
|
message = "修改失败!";
|
|
|
flag = "Fail";
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
model.CreateUserId = CurrentEmp.EmpId;
|
|
|
this.service.savePartSNRule(model);
|
|
|
message = "添加成功";
|
|
|
flag = "OK";
|
|
|
}
|
|
|
catch (Exception e)
|
|
|
{
|
|
|
message = "添加失败!";
|
|
|
flag = "Fail";
|
|
|
}
|
|
|
}
|
|
|
result.Add("message", message);
|
|
|
result.Add("flag", flag);
|
|
|
return Json(result) ;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 查看菜单详情
|
|
|
/// </summary>
|
|
|
/// <param name="ruid"></param>
|
|
|
/// <returns></returns>
|
|
|
public ActionResult getPartSNRuleDetail(String ruid)
|
|
|
{
|
|
|
Hashtable ht = this.service.getPartSNRuleDetail(ruid);
|
|
|
ViewData.Add("ruid",ht["ruid"]);
|
|
|
ViewData.Add("partNo", ht["partNo"]);
|
|
|
ViewData.Add("partId", ht["partId"]);
|
|
|
ViewData.Add("type", ht["type"]);
|
|
|
ViewData.Add("lenght", ht["lenght"]);
|
|
|
ViewData.Add("from1", ht["from1"]);
|
|
|
ViewData.Add("to1", ht["to1"]);
|
|
|
ViewData.Add("fix1", ht["fix1"]);
|
|
|
ViewData.Add("from2", ht["from2"]);
|
|
|
ViewData.Add("to2", ht["to2"]);
|
|
|
ViewData.Add("fix2", ht["fix2"]);
|
|
|
ViewData.Add("isValidateUnique", ht["isValidateUnique"]);
|
|
|
ViewData.Add("isValidateLength", ht["isValidateLength"]);
|
|
|
//ViewData.Add("partSpec", ht["partSpec"]);
|
|
|
return View("ViewPartSNRuleDefine");
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 编辑菜单
|
|
|
/// </summary>
|
|
|
/// <param name="ruid"></param>
|
|
|
/// <returns></returns>
|
|
|
public ActionResult editPartSNRule(String ruid)
|
|
|
{
|
|
|
if (!string.IsNullOrEmpty(ruid))
|
|
|
{
|
|
|
Hashtable ht = this.service.getPartSNRuleDetail(ruid);
|
|
|
ViewData.Add("editType", "edit");
|
|
|
ViewData.Add("ruid", ht["ruid"]);
|
|
|
ViewData.Add("partNo", ht["partNo"]);
|
|
|
ViewData.Add("partId", ht["partId"]);
|
|
|
ViewData.Add("type", ht["type"]);
|
|
|
ViewData.Add("lenght", ht["lenght"]);
|
|
|
ViewData.Add("from1", ht["from1"]);
|
|
|
ViewData.Add("to1", ht["to1"]);
|
|
|
ViewData.Add("fix1", ht["fix1"]);
|
|
|
ViewData.Add("from2", ht["from2"]);
|
|
|
ViewData.Add("to2", ht["to2"]);
|
|
|
ViewData.Add("fix2", ht["fix2"]);
|
|
|
ViewData.Add("isValidateUnique", ht["isValidateUnique"]);
|
|
|
ViewData.Add("isValidateLength", ht["isValidateLength"]);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
ViewData.Add("editType", "new");
|
|
|
}
|
|
|
return View("EditPartSNRuleDefine");
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 删除菜单
|
|
|
/// </summary>
|
|
|
/// <param name="ids"></param>
|
|
|
/// <returns></returns>
|
|
|
public ActionResult deletePartSNRule(String ids)
|
|
|
{
|
|
|
int delCount = 0;
|
|
|
try
|
|
|
{
|
|
|
delCount = this.service.deletePartSNRule(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>
|
|
|
/// 获取 类型 信息
|
|
|
/// BY NOAH
|
|
|
/// </summary>
|
|
|
/// <rehuoturns></returns>
|
|
|
public ActionResult getTypeData()
|
|
|
{
|
|
|
Hashtable result = new Hashtable();
|
|
|
List<KeyValueResult> menuList = this.service.getTypeData();
|
|
|
result.Add("list", menuList);
|
|
|
return Json(result);
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 判断是否为数字类型
|
|
|
/// BY NOAH
|
|
|
/// </summary>
|
|
|
/// <param name="s"></param>
|
|
|
/// <returns></returns>
|
|
|
public bool isNum(string s)
|
|
|
{
|
|
|
string pattern = "^[0-9]*$";
|
|
|
Regex rx = new Regex(pattern);
|
|
|
return rx.IsMatch(s);
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 导出数据到Excel
|
|
|
/// BY NOAH
|
|
|
/// </summary>
|
|
|
/// <param name="pager"></param>
|
|
|
/// <param name="txtOrderNo"></param>
|
|
|
/// <param name="sort"></param>
|
|
|
/// <param name="direction"></param>
|
|
|
/// <param name="isPage"></param>
|
|
|
/// <returns></returns>
|
|
|
public ActionResult exportData(String partNo_search, String type_search, String enabled_search, Pager pager, String sort, String direction, String isPage)
|
|
|
{
|
|
|
|
|
|
Boolean paging = false;
|
|
|
if (isPage == null || "".Equals(isPage))
|
|
|
{
|
|
|
paging = false;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if ("1".Equals(isPage.Trim()))
|
|
|
{
|
|
|
paging = true;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
paging = false;
|
|
|
}
|
|
|
}
|
|
|
Hashtable dataHt = this.service.getTableListByPage(partNo_search, type_search, enabled_search, pager, direction, sort, paging);//txtOrderNo, pager, direction, sort, paging
|
|
|
List<PartSNRuleDefine> listHt = (List<PartSNRuleDefine>)dataHt["dataList"];
|
|
|
var memoryStream = ExcelHelper.ToExcel(listHt);
|
|
|
return File(memoryStream.ToArray(), "application/ms-excel", "条码特征定义.xls");
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 导入Excel文件
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
public ActionResult importPartSNRule()
|
|
|
{
|
|
|
Hashtable result = new Hashtable();
|
|
|
IFormFile file = Request.Form.Files[0];
|
|
|
List<PartSNRuleDefine> data = ExcelHelper.GetList<PartSNRuleDefine>(file, 0);
|
|
|
result = service.ImportExcel(data, CurrentEmp.EmpId);
|
|
|
return Json(result);
|
|
|
}
|
|
|
}
|
|
|
}
|