|
|
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 Estsh.Web.Models;
|
|
|
using NPOI.HSSF.UserModel;
|
|
|
using System.IO;
|
|
|
using System.Data;
|
|
|
using System.Text;
|
|
|
using System.Xml;
|
|
|
|
|
|
/***************************************************************************************************
|
|
|
*
|
|
|
* 作者:王勇
|
|
|
* 创建时间:2013.04.15
|
|
|
* 描述:客户订单维护
|
|
|
*
|
|
|
* *************************************************************************************************/
|
|
|
namespace Estsh.Core.Web.Controllers
|
|
|
{
|
|
|
/// <summary>
|
|
|
/// 客户订单维护
|
|
|
/// </summary>
|
|
|
public class ProcessOutputController : Controller
|
|
|
{
|
|
|
private ProcessOutputService service = new ProcessOutputService();
|
|
|
|
|
|
//
|
|
|
// GET: /ProcessOutput/
|
|
|
public ActionResult Index()
|
|
|
{
|
|
|
return View();
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取列表数据
|
|
|
/// </summary>
|
|
|
/// <param name="ProcessOutputName">菜单名称</param>
|
|
|
/// <param name="pager">分页</param>
|
|
|
/// <param name="direction">排序方式</param>
|
|
|
/// <param name="sort">排序列</param>
|
|
|
/// <returns></returns>
|
|
|
public ActionResult getProcessOutputListByPage(string part_id, string process_id, string shift_id, string pdline_id, string startDate, string stopDate, Pager pager)
|
|
|
{
|
|
|
if (string.IsNullOrEmpty(startDate))
|
|
|
{
|
|
|
return null;
|
|
|
}
|
|
|
Hashtable result = new Hashtable();
|
|
|
part_id = InitStr(part_id);
|
|
|
process_id = InitStr(process_id);
|
|
|
shift_id = InitStr(shift_id);
|
|
|
pdline_id = InitStr(pdline_id);
|
|
|
|
|
|
DataTable dataHt = this.service.getProcessOutputListByPage(part_id, process_id, shift_id, pdline_id, startDate, stopDate,ref pager);
|
|
|
result.Add("rows", DataTypeConvert.NewObject.DataTableToArrayList(dataHt));
|
|
|
result.Add("pager.totalRows", pager.totalRows);
|
|
|
//Session["ProcessOutput"] = dataHt["dataList"];
|
|
|
return Json(result);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取下拉列表数据
|
|
|
/// </summary>
|
|
|
/// <rehuoturns></returns>
|
|
|
public ActionResult getSelectProcessOutput()
|
|
|
{
|
|
|
Hashtable result = new Hashtable();
|
|
|
ArrayList ProcessOutputList = this.service.getSelectProcessOutput();
|
|
|
result.Add("list", ProcessOutputList);
|
|
|
return Json(result, JsonRequestBehavior.AllowGet);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 保存数据
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
public ActionResult saveProcessOutput()
|
|
|
{
|
|
|
String editType = Request["editType"].ToString();
|
|
|
|
|
|
String part_id = Request["part_id"].ToString();
|
|
|
String cust_order = Request["cust_order"].ToString();
|
|
|
String ship_unit = Request["ship_unit"].ToString();
|
|
|
|
|
|
|
|
|
|
|
|
Hashtable htParams = new Hashtable();
|
|
|
htParams.Add("@part_id", part_id);
|
|
|
htParams.Add("@cust_order", cust_order);
|
|
|
htParams.Add("@ship_unit", ship_unit);
|
|
|
|
|
|
|
|
|
String message = "";
|
|
|
if (editType != null && editType.Trim().Equals("edit"))
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
|
|
|
this.service.updateProcessOutput(htParams);
|
|
|
message = "修改成功";
|
|
|
}
|
|
|
catch (Exception e)
|
|
|
{
|
|
|
message = "修改失败!";
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
this.service.saveProcessOutput(htParams);
|
|
|
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 getProcessOutput(String ProcessOutput_id)
|
|
|
{
|
|
|
ArrayList ProcessOutputInfo = this.service.getProcessOutput(ProcessOutput_id);
|
|
|
Hashtable htProcessOutputInfo = (Hashtable)ProcessOutputInfo[0];
|
|
|
ViewData.Add("part_id", htProcessOutputInfo["part_id"]);
|
|
|
ViewData.Add("cust_order", htProcessOutputInfo["cust_order"]);
|
|
|
ViewData.Add("ship_unit", htProcessOutputInfo["ship_unit"]);
|
|
|
|
|
|
return View("~/Views/ProcessOutputManage/viewProcessOutput.aspx");
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 编辑
|
|
|
/// </summary>
|
|
|
/// <param name="ruid"></param>
|
|
|
/// <returns></returns>
|
|
|
public ActionResult editProcessOutput(String part_id)
|
|
|
{
|
|
|
ArrayList ProcessOutputInfo = this.service.getProcessOutput(part_id);
|
|
|
Hashtable htProcessOutputInfo = (Hashtable)ProcessOutputInfo[0];
|
|
|
ViewData.Add("editType", "edit");
|
|
|
ViewData.Add("part_id", part_id);
|
|
|
ViewData.Add("cust_order", htProcessOutputInfo["cust_order"]);
|
|
|
ViewData.Add("ship_unit", htProcessOutputInfo["ship_unit"]);
|
|
|
|
|
|
return View("~/Views/ProcessOutput/EditProcessOutput.aspx");
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 删除
|
|
|
/// </summary>
|
|
|
/// <param name="ids"></param>
|
|
|
/// <returns></returns>
|
|
|
public ActionResult deleteProcessOutput(String ids)
|
|
|
{
|
|
|
int delCount = 0;
|
|
|
try
|
|
|
{
|
|
|
delCount = this.service.deleteProcessOutput(ids);
|
|
|
}
|
|
|
catch (Exception e)
|
|
|
{
|
|
|
delCount = -1;
|
|
|
}
|
|
|
Hashtable result = new Hashtable();
|
|
|
result.Add("status", delCount);
|
|
|
return Json(result);
|
|
|
}
|
|
|
|
|
|
public string InitStr(string str)
|
|
|
{
|
|
|
string resultStr = string.Empty;
|
|
|
if (string.IsNullOrEmpty(str) == false)
|
|
|
{
|
|
|
string[] strArr = str.Split(',');
|
|
|
for (int i = 0; i < strArr.Length; i++)
|
|
|
{
|
|
|
if (i != 0)
|
|
|
{
|
|
|
resultStr += ",";
|
|
|
}
|
|
|
resultStr += string.Format("'{0}'", strArr[i]);
|
|
|
}
|
|
|
}
|
|
|
return resultStr;
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 导出
|
|
|
/// </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 ExportProcessOutput(string part_id, string process_id, string shift_id, string pdline_id, string startDate, string stopDate, int rowCount,int pageIndex)
|
|
|
{
|
|
|
Pager pager = new Pager();
|
|
|
pager.pageSize = rowCount;
|
|
|
pager.pageNo = pageIndex;
|
|
|
part_id = InitStr(part_id);
|
|
|
process_id = InitStr(process_id);
|
|
|
shift_id = InitStr(shift_id);
|
|
|
pdline_id = InitStr(pdline_id);
|
|
|
|
|
|
DataTable data = this.service.getProcessOutputListByPage(part_id, process_id, shift_id, pdline_id, startDate, stopDate, ref pager);
|
|
|
Stream outputStream = Response.OutputStream;
|
|
|
|
|
|
string AbsolutePath = Request.UrlReferrer.AbsolutePath;
|
|
|
string url = AbsolutePath.Remove(0, Request.ApplicationPath.Length);
|
|
|
GridColumnService colService = new GridColumnService();
|
|
|
Models.SysWebGridColumn[] gridItems = colService.GetColumnByUrl(url);
|
|
|
HSSFWorkbook workbook = NPOIExcelTools.DataTableToWorkbook(gridItems, data, "即时产能");
|
|
|
|
|
|
|
|
|
//ArrayList arr = data["dataList"] as ArrayList;
|
|
|
|
|
|
|
|
|
//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("零件号");
|
|
|
// headRow.CreateCell(3).SetCellValue("数量");
|
|
|
// headRow.CreateCell(4).SetCellValue("制程");
|
|
|
// headRow.CreateCell(5).SetCellValue("班别");
|
|
|
// headRow.CreateCell(6).SetCellValue("零件描述");
|
|
|
// }
|
|
|
|
|
|
// for (int i = 0; i < arr.Count; i++)
|
|
|
// {
|
|
|
// Hashtable ht = arr[i] as Hashtable;
|
|
|
// int row = i + 1;
|
|
|
// HSSFRow dataRow = (HSSFRow)sheet.CreateRow(row);
|
|
|
// if (ht["pdline_name"] != null && ht["pdline_name"] != DBNull.Value)
|
|
|
// dataRow.CreateCell(0).SetCellValue(ht["pdline_name"].ToString());
|
|
|
// if (ht["work_date"] != null && ht["work_date"] != DBNull.Value)
|
|
|
// dataRow.CreateCell(1).SetCellValue(ht["work_date"].ToString());
|
|
|
// if (ht["part_no"] != null && ht["part_no"] != DBNull.Value)
|
|
|
// dataRow.CreateCell(2).SetCellValue(ht["part_no"].ToString());
|
|
|
// if (ht["output_qty"] != null && ht["output_qty"] != DBNull.Value)
|
|
|
// dataRow.CreateCell(3).SetCellValue(ht["output_qty"].ToString());
|
|
|
// if (ht["process_name"] != null && ht["process_name"] != DBNull.Value)
|
|
|
// dataRow.CreateCell(4).SetCellValue(ht["process_name"].ToString());
|
|
|
// if (ht["shift_name"] != null && ht["shift_name"] != DBNull.Value)
|
|
|
// dataRow.CreateCell(5).SetCellValue(ht["shift_name"].ToString());
|
|
|
// if (ht["part_spec"] != null && ht["part_spec"] != DBNull.Value)
|
|
|
// dataRow.CreateCell(6).SetCellValue(ht["part_spec"].ToString());
|
|
|
// }
|
|
|
|
|
|
Response.Clear();
|
|
|
workbook.Write(outputStream);
|
|
|
|
|
|
Response.Buffer = true;
|
|
|
Response.AppendHeader("Content-Disposition", "attachment;filename=即时产能(" + Convert.ToDateTime(startDate).ToString("yyyy-MM-dd") + "至" + Convert.ToDateTime(stopDate).ToString("yyyy-MM-dd") + ").xls");
|
|
|
Response.ContentEncoding = System.Text.Encoding.UTF8;
|
|
|
Response.ContentType = "application/vnd.ms-excel";
|
|
|
Response.Flush();
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
#if(false)
|
|
|
public ActionResult getColumn2D()
|
|
|
{
|
|
|
StringBuilder result = new StringBuilder();
|
|
|
XmlDocument document = new XmlDocument();
|
|
|
XmlDeclaration declaration = document.CreateXmlDeclaration("1.0", "GBK", "no");
|
|
|
document.AppendChild(declaration);
|
|
|
|
|
|
XmlElement root = document.CreateElement("chart");
|
|
|
root.SetAttribute("baseFontSize", "10");
|
|
|
root.SetAttribute("caption", "即时产能");
|
|
|
root.SetAttribute("rotateYAxisName", "0");
|
|
|
root.SetAttribute("showValues", "1");
|
|
|
root.SetAttribute("subcaption", "");
|
|
|
root.SetAttribute("useRoundEdges", "1");
|
|
|
root.SetAttribute("xAxisName", "零件号");
|
|
|
root.SetAttribute("yAxisName", "数量");
|
|
|
|
|
|
if (Session["ProcessOutput"] != null)
|
|
|
{
|
|
|
ArrayList dataList = Session["ProcessOutput"] as ArrayList;
|
|
|
if (dataList.Count > 0)
|
|
|
{
|
|
|
for (int i = 0; i < dataList.Count; i++)
|
|
|
{
|
|
|
Hashtable ht = dataList[i] as Hashtable;
|
|
|
XmlElement set = document.CreateElement("set");
|
|
|
if (ht["part_no"] != null && ht["part_no"] != DBNull.Value)
|
|
|
{
|
|
|
set.SetAttribute("label", ht["part_no"].ToString());
|
|
|
}
|
|
|
if (ht["output_qty"] != null && ht["output_qty"] != DBNull.Value)
|
|
|
{
|
|
|
set.SetAttribute("value", ht["output_qty"].ToString());
|
|
|
}
|
|
|
set.SetAttribute("color", "009933");
|
|
|
root.AppendChild(set);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
XmlElement trendlines = document.CreateElement("trendlines");
|
|
|
XmlElement line = document.CreateElement("line");
|
|
|
line.SetAttribute("color", "009933");
|
|
|
line.SetAttribute("displayvalue", "");
|
|
|
line.SetAttribute("startValue", "0");
|
|
|
trendlines.AppendChild(line);
|
|
|
root.AppendChild(trendlines);
|
|
|
|
|
|
XmlElement styles = document.CreateElement("styles");
|
|
|
styles.AppendChild(document.CreateElement("definition"));
|
|
|
styles.AppendChild(document.CreateElement("application"));
|
|
|
root.AppendChild(styles);
|
|
|
document.AppendChild(root);
|
|
|
|
|
|
|
|
|
|
|
|
return Content(document.InnerXml, "text/xml", Encoding.Default);
|
|
|
}
|
|
|
#endif
|
|
|
/// <summary>
|
|
|
/// 获取产线
|
|
|
/// </summary>
|
|
|
/// <rehuoturns></returns>
|
|
|
public ActionResult GetPdLine(string q)
|
|
|
{
|
|
|
Hashtable resault = new Hashtable();
|
|
|
ArrayList pdlineList = service.GetPdline(q);
|
|
|
resault.Add("fromList", pdlineList);
|
|
|
return Json(resault, JsonRequestBehavior.AllowGet);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取班别
|
|
|
/// </summary>
|
|
|
/// <rehuoturns></returns>
|
|
|
public ActionResult GetShiftData(string q)
|
|
|
{
|
|
|
Hashtable resault = new Hashtable();
|
|
|
ArrayList pdlineList = service.GetShiftData(q);
|
|
|
resault.Add("fromList", pdlineList);
|
|
|
return Json(resault, JsonRequestBehavior.AllowGet);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获得制程
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
public ActionResult GetProcessData(string q)
|
|
|
{
|
|
|
Hashtable resault = new Hashtable();
|
|
|
ArrayList pdlineList = service.GetProcessData(q);
|
|
|
resault.Add("fromList", pdlineList);
|
|
|
return Json(resault, JsonRequestBehavior.AllowGet);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获得零件号
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
public ActionResult GetPartNo()
|
|
|
{
|
|
|
Hashtable resault = new Hashtable();
|
|
|
ArrayList pdlineList = service.GetPartNo();
|
|
|
resault.Add("fromList", pdlineList);
|
|
|
return Json(resault, JsonRequestBehavior.AllowGet);
|
|
|
}
|
|
|
}
|
|
|
}
|