using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Collections;
using Estsh.Web.Service;
using Com.Estsh.MES.App;
using System.Data;
using System.Threading;
using Estsh.Web.Models;
using Estsh.Web.Util;
namespace Estsh.Core.Web.Controllers
{
public class ProductionOrderPdlineEmergencyReleaseController : Controller
{
private ProductionOrderPdlineEmergencyReleaseService service = new ProductionOrderPdlineEmergencyReleaseService();
public ActionResult Index()
{
return View();
}
///
/// 获取客户产线列表
///
///
public ActionResult GetCustPDLine()
{
Hashtable result = new Hashtable();
ArrayList list = this.service.GetCustPDLine();
result.Add("list", list);
return Json(result, JsonRequestBehavior.AllowGet);
}
///
/// 根据客户产线查询车型
///
///
public ActionResult GetMode_type(string CustPDLine)
{
Hashtable result = new Hashtable();
ArrayList list = this.service.GetMode_type(CustPDLine);
result.Add("list", list);
return Json(result, JsonRequestBehavior.AllowGet);
}
///
/// 产线
///
///
public ActionResult GetPdline(string CustPDLine)
{
Hashtable result = new Hashtable();
ArrayList list = this.service.GetPdline(CustPDLine);
result.Add("list", list);
return Json(result, JsonRequestBehavior.AllowGet);
}
///
/// 获取产线列表
///
///
public ActionResult GetZDPDLine()
{
Hashtable result = new Hashtable();
ArrayList list = this.service.GetPdline();
result.Add("list", list);
return Json(result, JsonRequestBehavior.AllowGet);
}
///
/// 区段
///
///
public ActionResult GetStage(string pdlineId)
{
Hashtable result = new Hashtable();
ArrayList list = this.service.GetStage(pdlineId);
result.Add("list", list);
return Json(result, JsonRequestBehavior.AllowGet);
}
///
/// 根据车型编号查询座椅配置
///
///
public ActionResult GetModelList(int ModelType)
{
Hashtable result = new Hashtable();
ArrayList list = this.service.GetModelList(ModelType);
result.Add("list", list);
return Json(result, JsonRequestBehavior.AllowGet);
}
/////
///// 获取配置名称
/////
/////
//public ActionResult GetModelName()
//{
// Hashtable result = new Hashtable();
// ArrayList list = this.service.GetModelName();
// result.Add("list", list);
// return Json(result, JsonRequestBehavior.AllowGet);
//}
///
/// 获取班次
///
///
public ActionResult Getshift()
{
Hashtable result = new Hashtable();
ArrayList list = this.service.Getshift();
result.Add("list", list);
return Json(result, JsonRequestBehavior.AllowGet);
}
///
/// 获取生产类型
///
///
public ActionResult GetProdType()
{
Hashtable result = new Hashtable();
ArrayList list = this.service.GetProdType();
result.Add("list", list);
return Json(result, JsonRequestBehavior.AllowGet);
}
///
/// 根据配置编号获取总成清单
///
/// 配置编号
/// 总成清单
public ActionResult GetBomDetail(int cbModel, string stageId)//,string isLoad)
{
Hashtable result = new Hashtable();
ArrayList list = this.service.GetBomDetail(cbModel, stageId);
result.Add("rows", list);
return Json(result, JsonRequestBehavior.AllowGet);
}
//库存插单保存按钮
public bool isExist(string order_no)
{
return service.isExist(order_no);
}
//加载单据编号
public string GetOrderNo()
{
return service.GetOrderNo("StockOrder", "A");
}
//库存插单保存按钮
public bool Insert_g_stock_order(int model_type_id, int model_id, string order_no, string cust_pdline, int shift_id, int qty, string type, string document_data, int stageId, int PdlineId)
{
return service.Insert_g_stock_order(model_type_id, model_id, order_no, cust_pdline, shift_id, qty, type, document_data, stageId, PdlineId);
}
public bool Insert_g_stock_order_detail(string order_no, string model_id, string partNoList)
{
try
{
Hashtable result = new Hashtable();
if (string.IsNullOrEmpty(partNoList) && string.IsNullOrEmpty(model_id.ToString()))
{
return false;
}
//判断配置对应总成是否匹配
DataTable dt = new DataTable();
dt = service.GetBomDetailTable(Convert.ToInt32(model_id));
partNoList = partNoList.Remove(partNoList.Length - 1, 1);
string[] strList = partNoList.Split(',');
bool ifExist = false;
for (int j = 0; j < strList.Length; j++)
{
DataRow[] dr = dt.Select("part_no='" + strList[j] + "'");
if (dr.Length <= 0)
{
ifExist = false;
return ifExist;
}
}
for (int i = 0; i < strList.Length; i++)
{
string partId = service.getPartId(strList[i]).ToString();
ifExist = service.Insert_g_stock_order_detail(order_no, partId);
}
return true;
}
catch (Exception ex)
{
return false;
}
}
///
/// 调用存储过程 dbo.sys_release_stock_order 释放生产指令
///
///
public string ReleaseStockOrder(string order_no, int ruid, string stageId)
{
string mes = "";
order_no = order_no.Substring(0, order_no.Length - 1);
string[] str = order_no.Split(',');
for (int i = 0; i < str.Length; i++)
{
mes = service.ReleaseStockOrder(str[i].ToString(), ruid, stageId);
}
return mes;
}
///
/// 调用存储过程 dbo.sys_assign_stock_order 分配虚拟料架
///
///
public string AssignStockOrder(string custPDLine)
{
return service.AssignStockOrder(custPDLine);
}
// ///
///// 初始化全局的静态变量
/////
/////
//public string TrayPagePrintCount(string param)
//{
// return service.TrayPagePrintCount(param);
//}
///
/// 获取要打印的条码数据(前排)
///
///
public ActionResult GetSN(string orderNo)
{
Hashtable result = new Hashtable();
ArrayList list = this.service.GetSN(orderNo);
result.Add("rows", list);
return Json(result, JsonRequestBehavior.AllowGet);
}
///
/// 更新条码的打印状态
///
/// 条码
/// 是否成功
//public bool UpdateSNPrintStatus(string serialNumber)
//{
// return service.UpdateSNPrintStatus(serialNumber);
//}
///
/// 获取要打印的条码数据(前排)
///
///
public ActionResult GetBackSN(string orderNo)
{
Hashtable result = new Hashtable();
ArrayList list = this.service.GetBackSN(orderNo);
result.Add("rows", list);
return Json(result, JsonRequestBehavior.AllowGet);
}
//条码补打
///
/// 获取补打信息
///
/// 过程条码 OR 合格证条码
///
public ActionResult GetReprintDataBySN(string type, string serialNumber, int count, bool isOrderByInLineTime)
{
Hashtable result = new Hashtable();
ArrayList list = this.service.GetReprintDataBySN(type, serialNumber, count, isOrderByInLineTime);
result.Add("rows", list);
return Json(result, JsonRequestBehavior.AllowGet);
}
///
/// 获取要 打印过程条码 信息
///
///
//public void PrintSerialNumber(string serialNumber)
public ActionResult PrintSerialNumber(string serialNumber)
{
Hashtable result = new Hashtable();
ArrayList list = this.service.PrintSerialNumber(serialNumber);
result.Add("rows", list);
return Json(result, JsonRequestBehavior.AllowGet);
}
///
/// 根据配置编号获取过程条码打印的张数
///
public int GetModelBarcodeCount(string serialNumber)
{
return service.GetModelBarcodeCount(serialNumber);
}
///
/// 更新条码的补打状态
///
/// 条码
/// 是否更新成功
public bool UpdateSNReprintStatus(string serialNumber)
{
return service.UpdateSNReprintStatus(serialNumber);
}
// 打印合格证
///
/// 根据配置编号获取合格证条码打印的张数
///
public int GetModelQACount(string serialNumber)
{
return service.GetModelQACount(serialNumber);
}
//打印后排的的合格证条码
///
/// 根据条码获取对应后排条码的打印信息
///
/// 条码
/// 后排条码的打印信息
public ActionResult GetBackSNs(string serialNumber)
{
Hashtable result = new Hashtable();
ArrayList list = this.service.GetBackSNs(serialNumber);
result.Add("rows", list);
return Json(result, JsonRequestBehavior.AllowGet);
}
///
/// 导入Bom Excel文件
///
///
public ActionResult importInstruction()
{
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);
}
///
/// 获取列表数据
///
/// 菜单名称
/// 分页
/// 排序方式
/// 排序列
///
public ActionResult getProductionOrderListByPage(Pager pager, String direction, String sort, string cbCustPDLine, string stageId, string cbZDPdline)
{
string str = "";
if ((string.IsNullOrEmpty(cbCustPDLine)) || cbCustPDLine == "null")
{
//cbCustPDLine = "0";
return null;
}
if ((string.IsNullOrEmpty(stageId)) || stageId == "null")
{
//cbCustPDLine = "0";
return null;
}
Hashtable result = new Hashtable();
result.Add("pager.pageNo", pager.pageNo);
Hashtable dataHt = this.service.getProductionOrderListByPage(pager, direction, sort, stageId, cbZDPdline);
result.Add("rows", dataHt["dataList"]);
result.Add("pager.totalRows", dataHt["totalCount"]);
//result.Add("sort", sort);
result.Add("direction", direction);
return Json(result);
}
}
}