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.
415 lines
16 KiB
C#
415 lines
16 KiB
C#
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
|
|
{
|
|
/**
|
|
* 客户产线对应关系
|
|
*
|
|
* NOAH
|
|
*
|
|
*/
|
|
public class SRMDefineController : Controller
|
|
{
|
|
private SRMDefineService service = new SRMDefineService();
|
|
|
|
//
|
|
// 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 getSRMListByPage(String VIN, String txtStartTime, String txtEndTime, Pager pager, String direction, String sort)
|
|
{
|
|
Hashtable result = new Hashtable();
|
|
result.Add("pager.pageNo", pager.pageNo);
|
|
ArrayList menuList = this.service.getSRMListByPage(VIN, txtStartTime, txtEndTime, pager, direction, sort);
|
|
result.Add("rows", menuList);
|
|
int total = this.service.getMenuCount(VIN, txtStartTime, txtEndTime);
|
|
result.Add("pager.totalRows", total);
|
|
result.Add("sort", sort);
|
|
result.Add("direction", direction);
|
|
return Json(result);
|
|
}
|
|
|
|
//获取发运信息
|
|
public ActionResult getShipByPage(String VIN, String txtStartTime, String txtEndTime, String type, Pager pager, String direction, String sort)
|
|
{
|
|
Hashtable result = new Hashtable();
|
|
result.Add("pager.pageNo", pager.pageNo);
|
|
ArrayList menuList = this.service.getShipByPage(VIN, txtStartTime, txtEndTime, type, pager, direction, sort);
|
|
result.Add("rows", menuList);
|
|
int total = this.service.getShipCount(VIN, txtStartTime, txtEndTime, type);
|
|
result.Add("pager.totalRows", total);
|
|
result.Add("sort", sort);
|
|
result.Add("direction", direction);
|
|
return Json(result);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 保存菜单数据
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public ActionResult saveModelType()
|
|
{
|
|
Hashtable result = new Hashtable();
|
|
String message = "";
|
|
String flag = "";
|
|
|
|
String editType = Request["editType"].ToString();
|
|
|
|
String type_id = Request["type_id"].ToString();
|
|
String type_code = Request["type_code"].ToString();
|
|
String type_name = Request["type_name"].ToString();
|
|
String type_alias = Request["type_alias"].ToString();
|
|
String type_desc = Request["type_desc"].ToString();
|
|
|
|
|
|
//传递要更新的数据库字段
|
|
Hashtable htParams = new Hashtable();
|
|
htParams.Add("@type_code", type_code);
|
|
htParams.Add("@type_name", type_name);
|
|
htParams.Add("@type_alias", type_alias);
|
|
htParams.Add("@type_desc", type_desc);
|
|
|
|
|
|
//用户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
|
|
{
|
|
htParams.Add("@type_id", type_id);
|
|
this.service.updateModelType(htParams);
|
|
message = "修改成功";
|
|
flag = "OK";
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
message = "修改失败!";
|
|
flag = "Fail";
|
|
}
|
|
}
|
|
else
|
|
{
|
|
try
|
|
{
|
|
htParams.Add("@type_id", type_id);
|
|
this.service.saveModelType(htParams);
|
|
message = "添加成功";
|
|
flag = "OK";
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
message = "添加失败!";
|
|
flag = "Fail";
|
|
}
|
|
}
|
|
result.Add("message", message);
|
|
result.Add("flag", flag);
|
|
return Json(result);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 查看菜单详情
|
|
/// </summary>
|
|
/// <param name="type_id"></param>
|
|
/// <returns></returns>
|
|
public ActionResult getModelTypeDetail(String type_id)
|
|
{
|
|
Hashtable ht = this.service.getModelTypeDetail(type_id);
|
|
ViewData.Add("type_id", ht["type_id"]);
|
|
ViewData.Add("type_code", ht["type_code"]);
|
|
ViewData.Add("type_name", ht["type_name"]);
|
|
ViewData.Add("type_alias", ht["type_alias"]);
|
|
ViewData.Add("type_desc", ht["type_desc"]);
|
|
ViewData.Add("cust_pdline_name", ht["cust_pdline_name"]);
|
|
return View("~/Views/ModelTypeDefine/ViewModelTypeDefine.aspx");
|
|
}
|
|
|
|
/// <summary>
|
|
/// 编辑菜单
|
|
/// </summary>
|
|
/// <param name="type_id"></param>
|
|
/// <returns></returns>
|
|
public ActionResult editModelType(String type_id)
|
|
{
|
|
Hashtable ht = this.service.getModelTypeDetail(type_id);
|
|
ViewData.Add("editType", "edit");
|
|
|
|
ViewData.Add("type_id", ht["type_id"]);
|
|
ViewData.Add("type_code", ht["type_code"]);
|
|
ViewData.Add("type_name", ht["type_name"]);
|
|
ViewData.Add("type_alias", ht["type_alias"]);
|
|
ViewData.Add("type_desc", ht["type_desc"]);
|
|
ViewData.Add("cust_pdline_name", ht["cust_pdline_name"]);
|
|
return View("~/Views/ModelTypeDefine/EditModelTypeDefine.aspx");
|
|
}
|
|
|
|
/// <summary>
|
|
/// 删除菜单
|
|
/// </summary>
|
|
/// <param name="ids"></param>
|
|
/// <returns></returns>
|
|
public ActionResult deleteSRM(String ids)
|
|
{
|
|
int delCount = 0;
|
|
try
|
|
{
|
|
delCount = this.service.deleteSRM(ids);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
delCount = -1;
|
|
}
|
|
Hashtable result = new Hashtable();
|
|
result.Add("status", delCount);
|
|
return Json(result);
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <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 vin, String txtStartTime, String txtEndTime, 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(vin, txtStartTime, txtEndTime, pager, direction, sort, paging);//txtOrderNo, pager, direction, sort, paging
|
|
HSSFWorkbook workbook = new HSSFWorkbook();
|
|
Stream outputStream = Response.OutputStream;
|
|
HSSFSheet sheet = (HSSFSheet)workbook.CreateSheet("SRM管理");
|
|
try
|
|
{
|
|
if (workbook != null)
|
|
{
|
|
HSSFRow headRow = (HSSFRow)sheet.CreateRow(0);
|
|
headRow.CreateCell(0).SetCellValue("ID");
|
|
headRow.CreateCell(1).SetCellValue("VIN号");
|
|
headRow.CreateCell(2).SetCellValue("导入号");
|
|
headRow.CreateCell(3).SetCellValue("过点序号");
|
|
headRow.CreateCell(4).SetCellValue("物料编号");
|
|
headRow.CreateCell(5).SetCellValue("物料名称");
|
|
headRow.CreateCell(6).SetCellValue("需求数量");
|
|
headRow.CreateCell(7).SetCellValue("订单日期");
|
|
headRow.CreateCell(8).SetCellValue("订单编号");
|
|
headRow.CreateCell(9).SetCellValue("制单日期");
|
|
headRow.CreateCell(10).SetCellValue("订单状态");
|
|
headRow.CreateCell(11).SetCellValue("单据打印");
|
|
headRow.CreateCell(12).SetCellValue("供应商名称");
|
|
headRow.CreateCell(13).SetCellValue("回执时间");
|
|
headRow.CreateCell(14).SetCellValue("更新时间");
|
|
headRow.CreateCell(15).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]["ruid"].ToString());
|
|
dataRow.CreateCell(1).SetCellValue(dataHt.Rows[i]["VIN"].ToString());
|
|
dataRow.CreateCell(2).SetCellValue(dataHt.Rows[i]["importNo"].ToString());
|
|
dataRow.CreateCell(3).SetCellValue(dataHt.Rows[i]["crossingPointNo"].ToString());
|
|
dataRow.CreateCell(4).SetCellValue(dataHt.Rows[i]["partNo"].ToString());
|
|
dataRow.CreateCell(5).SetCellValue(dataHt.Rows[i]["partName"].ToString());
|
|
dataRow.CreateCell(6).SetCellValue(dataHt.Rows[i]["xuQiuQty"].ToString());
|
|
dataRow.CreateCell(7).SetCellValue(dataHt.Rows[i]["dingDanTime"].ToString());
|
|
dataRow.CreateCell(8).SetCellValue(dataHt.Rows[i]["dingDanNo"].ToString());
|
|
dataRow.CreateCell(9).SetCellValue(dataHt.Rows[i]["zhiDanTime"].ToString());
|
|
dataRow.CreateCell(10).SetCellValue(dataHt.Rows[i]["dingDanStatus"].ToString());
|
|
dataRow.CreateCell(11).SetCellValue(dataHt.Rows[i]["danJuPrint"].ToString());
|
|
dataRow.CreateCell(12).SetCellValue(dataHt.Rows[i]["vendorName"].ToString());
|
|
dataRow.CreateCell(13).SetCellValue(dataHt.Rows[i]["huiZhiTime"].ToString());
|
|
dataRow.CreateCell(14).SetCellValue(dataHt.Rows[i]["updateTime"].ToString());
|
|
dataRow.CreateCell(15).SetCellValue(dataHt.Rows[i]["importTime"].ToString());
|
|
}
|
|
|
|
Response.Clear();
|
|
workbook.Write(outputStream);
|
|
|
|
Response.Buffer = true;
|
|
Response.AppendHeader("Content-Disposition", "attachment;filename=SRM管理.xls");
|
|
Response.ContentEncoding = System.Text.Encoding.UTF8;
|
|
Response.ContentType = "application/vnd.ms-excel";
|
|
Response.Flush();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
}
|
|
finally
|
|
{
|
|
workbook = null;
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
|
|
public ActionResult exportDataShip(String vin, String txtStartTime, String txtEndTime, String type, 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.getShipByPage(vin, txtStartTime, txtEndTime, type, 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("ID");
|
|
headRow.CreateCell(1).SetCellValue("VIN号");
|
|
headRow.CreateCell(2).SetCellValue("导入号");
|
|
headRow.CreateCell(3).SetCellValue("过点序号");
|
|
headRow.CreateCell(4).SetCellValue("物料编号");
|
|
headRow.CreateCell(5).SetCellValue("物料名称");
|
|
headRow.CreateCell(6).SetCellValue("需求数量");
|
|
headRow.CreateCell(7).SetCellValue("条码");
|
|
headRow.CreateCell(8).SetCellValue("入库扫描时间");
|
|
headRow.CreateCell(9).SetCellValue("RFID信息");
|
|
headRow.CreateCell(10).SetCellValue("校验状态");
|
|
headRow.CreateCell(11).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]["ruid"].ToString());
|
|
dataRow.CreateCell(1).SetCellValue(dataHt.Rows[i]["VIN"].ToString());
|
|
dataRow.CreateCell(2).SetCellValue(dataHt.Rows[i]["importNo"].ToString());
|
|
dataRow.CreateCell(3).SetCellValue(dataHt.Rows[i]["crossingPointNo"].ToString());
|
|
dataRow.CreateCell(4).SetCellValue(dataHt.Rows[i]["partNo"].ToString());
|
|
dataRow.CreateCell(5).SetCellValue(dataHt.Rows[i]["partName"].ToString());
|
|
dataRow.CreateCell(6).SetCellValue(dataHt.Rows[i]["xuQiuQty"].ToString());
|
|
dataRow.CreateCell(7).SetCellValue(dataHt.Rows[i]["serial_number"].ToString());
|
|
dataRow.CreateCell(8).SetCellValue(dataHt.Rows[i]["inTime"].ToString());
|
|
dataRow.CreateCell(9).SetCellValue(dataHt.Rows[i]["rfid"].ToString());
|
|
dataRow.CreateCell(10).SetCellValue(dataHt.Rows[i]["status"].ToString());
|
|
dataRow.CreateCell(11).SetCellValue(dataHt.Rows[i]["scan_status"].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 importSRMInfo(string cbPdline)
|
|
{
|
|
|
|
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, cbPdline);
|
|
return Json(result);
|
|
}
|
|
}
|
|
}
|