|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Linq;
|
|
|
using System.Web;
|
|
|
using System.Web.Mvc;
|
|
|
using Estsh.Web.Util;
|
|
|
using Estsh.Web.Service;
|
|
|
using System.Collections;
|
|
|
using System.Text.RegularExpressions;
|
|
|
using System.Data;
|
|
|
using NPOI.HSSF.UserModel;
|
|
|
using System.IO;
|
|
|
using Estsh.Web.Models;
|
|
|
|
|
|
|
|
|
namespace Estsh.Core.Web.Controllers
|
|
|
{
|
|
|
/*****************************************************************
|
|
|
*
|
|
|
* 客户零件号关系管理
|
|
|
*
|
|
|
* Fred
|
|
|
*
|
|
|
******************************************************************/
|
|
|
public class SysPartExtGroupController : Controller
|
|
|
{
|
|
|
private SysPartExtGroupService service = new SysPartExtGroupService();
|
|
|
|
|
|
//
|
|
|
// GET: /Menu/
|
|
|
public ActionResult Index()
|
|
|
{
|
|
|
return View();
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 加载功能树
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
public ActionResult getMenuTree()
|
|
|
{
|
|
|
string path = Request.ApplicationPath; if (path.EndsWith("/")) { path = path.Substring(0, path.Length - 1); }
|
|
|
List<TreeNode> treeNodes = new List<TreeNode>();
|
|
|
treeNodes = service.getMenuList("isIndex = '是'", " RUID ASC ", path);
|
|
|
Hashtable result = new Hashtable();
|
|
|
result.Add("treeNodes", treeNodes);
|
|
|
String json = Estsh.Web.Util.JSON.Encode(result);
|
|
|
return Json(result, JsonRequestBehavior.AllowGet);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取菜单管理列表数据
|
|
|
/// </summary>
|
|
|
/// <param name="menuName"></param>
|
|
|
/// <param name="pager"></param>
|
|
|
/// <param name="direction"></param>
|
|
|
/// <param name="sort"></param>
|
|
|
/// <returns></returns>
|
|
|
public ActionResult getDataListByPage(String part_no_search, Pager pager, String direction, String sort)
|
|
|
{
|
|
|
Hashtable result = new Hashtable();
|
|
|
result.Add("pager.pageNo", pager.pageNo);
|
|
|
ArrayList menuList = this.service.getDataListByPage(part_no_search, pager, direction, sort);
|
|
|
result.Add("rows", menuList);
|
|
|
int total = this.service.getMenuCount(part_no_search);
|
|
|
result.Add("pager.totalRows", total);
|
|
|
result.Add("sort", sort);
|
|
|
result.Add("direction", direction);
|
|
|
return Json(result);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 保存菜单数据
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
public ActionResult saveData()
|
|
|
{
|
|
|
Hashtable result = new Hashtable();
|
|
|
String message = "";
|
|
|
string flag = "";
|
|
|
String editType = Request["editType"].ToString();
|
|
|
string part_no = Request["part_no"].ToString();
|
|
|
int part_id = this.service.getpartID(part_no);
|
|
|
String torque_job_no = Request["torque_job_no"].ToString();
|
|
|
String torque_robot_no = Request["torque_robot_no"].ToString();
|
|
|
String robot_offline_no = Request["robot_offline_no"].ToString();
|
|
|
|
|
|
if (part_id == 0)
|
|
|
{
|
|
|
result.Add("message", "总成名称不存在!");
|
|
|
result.Add("flag", "NO");
|
|
|
return Json(result);
|
|
|
}
|
|
|
if (torque_job_no.Length != 2)
|
|
|
{
|
|
|
result.Add("message", "扭矩Job编号必须是两位(如1,可以写成01)!");
|
|
|
result.Add("flag", "NO");
|
|
|
return Json(result);
|
|
|
}
|
|
|
if (torque_robot_no.Length != 2)
|
|
|
{
|
|
|
result.Add("message", "扭矩机器人轨迹编号必须是两位(如1,可以写成01)!");
|
|
|
result.Add("flag", "NO");
|
|
|
return Json(result);
|
|
|
}
|
|
|
if (robot_offline_no.Length != 2)
|
|
|
{
|
|
|
result.Add("message", "下线机器人轨迹编号必须是两位(如1,可以写成01)!");
|
|
|
result.Add("flag", "NO");
|
|
|
return Json(result);
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//传递要更新的数据库字段 2013 0506 14:05 by NOAH
|
|
|
Hashtable htParams = new Hashtable();
|
|
|
htParams.Add("@part_id", part_id);
|
|
|
htParams.Add("@torque_job_no", torque_job_no);
|
|
|
htParams.Add("@torque_robot_no", torque_robot_no);
|
|
|
htParams.Add("@robot_offline_no", robot_offline_no);
|
|
|
|
|
|
//用户id
|
|
|
UserInfo user = (UserInfo)Session["loginedUser"];
|
|
|
htParams.Add("@update_userid", user.updateUserId);
|
|
|
htParams.Add("@create_userid", user.updateUserId);
|
|
|
|
|
|
if (editType != null && editType.Trim().Equals("edit"))
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
this.service.updateData(htParams);
|
|
|
message = "修改成功";
|
|
|
flag = "OK";
|
|
|
}
|
|
|
catch (Exception e)
|
|
|
{
|
|
|
message = "修改失败!";
|
|
|
flag = "NO";
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
this.service.saveData(htParams);
|
|
|
message = "添加成功";
|
|
|
flag = "OK";
|
|
|
}
|
|
|
catch (Exception e)
|
|
|
{
|
|
|
message = "添加失败!";
|
|
|
flag = "NO";
|
|
|
}
|
|
|
}
|
|
|
result.Add("message", message);
|
|
|
result.Add("flag",flag);
|
|
|
return Json(result) ;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 查看菜单详情
|
|
|
/// </summary>
|
|
|
/// <param name="keydata_id"></param>
|
|
|
/// <returns></returns>
|
|
|
public ActionResult getDataDetail(String ruid)
|
|
|
{
|
|
|
Hashtable ht = this.service.getDataDetail(ruid);
|
|
|
ViewData.Add("part_no", ht["part_no"]);
|
|
|
ViewData.Add("torque_job_no", ht["torque_job_no"]);
|
|
|
ViewData.Add("torque_robot_no", ht["torque_robot_no"]);
|
|
|
ViewData.Add("robot_offline_no", ht["robot_offline_no"]);
|
|
|
return View("~/Views/SysPartExtGroup/ViewSysPartExtGroup.aspx");
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 编辑菜单
|
|
|
/// </summary>
|
|
|
/// <param name="keydata_id"></param>
|
|
|
/// <returns></returns>
|
|
|
public ActionResult editData(String ruid)
|
|
|
{
|
|
|
Hashtable ht = this.service.getDataDetail(ruid);
|
|
|
ViewData.Add("editType", "edit");
|
|
|
ViewData.Add("ruid", ht["ruid"]);
|
|
|
ViewData.Add("part_no", ht["part_no"]);
|
|
|
ViewData.Add("torque_job_no", ht["torque_job_no"]);
|
|
|
ViewData.Add("torque_robot_no", ht["torque_robot_no"]);
|
|
|
ViewData.Add("robot_offline_no", ht["robot_offline_no"]);
|
|
|
return View("~/Views/SysPartExtGroup/EditSysPartExtGroup.aspx");
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 删除菜单
|
|
|
/// </summary>
|
|
|
/// <param name="ids"></param>
|
|
|
/// <returns></returns>
|
|
|
public ActionResult deleteData(String ids)
|
|
|
{
|
|
|
int delCount = 0;
|
|
|
try
|
|
|
{
|
|
|
delCount = this.service.deleteData(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 getTerminalName()
|
|
|
{
|
|
|
Hashtable result = new Hashtable();
|
|
|
ArrayList menuList = this.service.getTerminalName();
|
|
|
result.Add("list", menuList);
|
|
|
return Json(result, JsonRequestBehavior.AllowGet);
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 获取 产线 信息
|
|
|
/// BY NOAH
|
|
|
/// </summary>
|
|
|
/// <rehuoturns></returns>
|
|
|
public ActionResult getBoardName()
|
|
|
{
|
|
|
Hashtable result = new Hashtable();
|
|
|
ArrayList menuList = this.service.getBoardName();
|
|
|
result.Add("list", menuList);
|
|
|
return Json(result, JsonRequestBehavior.AllowGet);
|
|
|
}
|
|
|
|
|
|
/// <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
|
|
|
/// </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 part_no_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;
|
|
|
}
|
|
|
}
|
|
|
DataTable dataHt = this.service.getTableListByPage(part_no_search, pager, direction, sort, paging);//txtOrderNo, pager, direction, sort, paging
|
|
|
HSSFWorkbook workbook = new HSSFWorkbook();
|
|
|
Stream outputStream = Response.OutputStream;
|
|
|
HSSFSheet sheet = (HSSFSheet)workbook.CreateSheet("扭矩和轨迹管理");
|
|
|
try
|
|
|
{
|
|
|
if (workbook != null)
|
|
|
{
|
|
|
HSSFRow headRow = (HSSFRow)sheet.CreateRow(0);
|
|
|
headRow.CreateCell(0).SetCellValue("总成零件号");
|
|
|
headRow.CreateCell(1).SetCellValue("总成描述");
|
|
|
headRow.CreateCell(2).SetCellValue("扭矩Job编号");
|
|
|
headRow.CreateCell(3).SetCellValue("扭矩机器人轨迹");
|
|
|
headRow.CreateCell(4).SetCellValue("下线机器人轨迹");
|
|
|
}
|
|
|
|
|
|
for (int i = 0; i < dataHt.Rows.Count; i++)
|
|
|
{
|
|
|
int row = i + 1;
|
|
|
HSSFRow dataRow = (HSSFRow)sheet.CreateRow(row);
|
|
|
|
|
|
dataRow.CreateCell(0).SetCellValue(dataHt.Rows[i]["part_no"].ToString());
|
|
|
dataRow.CreateCell(1).SetCellValue(dataHt.Rows[i]["part_spec"].ToString());
|
|
|
dataRow.CreateCell(2).SetCellValue(dataHt.Rows[i]["torque_job_no"].ToString());
|
|
|
dataRow.CreateCell(3).SetCellValue(dataHt.Rows[i]["torque_robot_no"].ToString());
|
|
|
dataRow.CreateCell(4).SetCellValue(dataHt.Rows[i]["robot_offline_no"].ToString());
|
|
|
}
|
|
|
|
|
|
Response.Clear();
|
|
|
workbook.Write(outputStream);
|
|
|
|
|
|
Response.Buffer = true;
|
|
|
Response.AppendHeader("Content-Disposition", "attachment;filename=扭矩和轨迹管理.xls");
|
|
|
Response.ContentEncoding = System.Text.Encoding.UTF8;
|
|
|
Response.ContentType = "application/vnd.ms-excel";
|
|
|
Response.Flush();
|
|
|
}
|
|
|
catch (Exception e)
|
|
|
{
|
|
|
}
|
|
|
finally
|
|
|
{
|
|
|
workbook = null;
|
|
|
}
|
|
|
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 导入Excel文件
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
public ActionResult importData()
|
|
|
{
|
|
|
Hashtable result = new Hashtable();
|
|
|
HttpPostedFileBase userDataFile = Request.Files[0];
|
|
|
UserInfo user = (UserInfo)Session["loginedUser"];
|
|
|
if (userDataFile == null)
|
|
|
{
|
|
|
return null;
|
|
|
}
|
|
|
result = service.ReadExcelFile(userDataFile.InputStream, user.empId);
|
|
|
return Json(result);
|
|
|
}
|
|
|
}
|
|
|
}
|