using System.Collections; using Aspose.Cells; using Microsoft.AspNetCore.Mvc; using Estsh.Core.Services.IServices; using Estsh.Core.Model.Result; using Estsh.Core.Models; using System.Text.Json; using Estsh.Core.Controllers; using Estsh.Core.Util; using System.Data; using System.Text; /*************************************************************************************************** * * 更新人:sitong.dong * 描述:零星生产计划 * 修改时间:2022.06.22 * 修改日志:系统迭代升级 * **************************************************************************************************/ namespace Estsh.Core.Web.Controllers { public class StockOrderReleaseController : BaseController { private IStockOrderReleaseService service; public StockOrderReleaseController(IStockOrderReleaseService _service) { service = _service; } public ActionResult Index() { return View(); } /// /// 获取客户产线列表 /// /// public ActionResult GetCustPDLine() { Hashtable result = new Hashtable(); List list = this.service.GetCustPDLine(); result.Add("list", list); return Json(result); } /// /// 根据客户产线查询车型 /// /// public ActionResult GetMode_type(string CustPDLine) { Hashtable result = new Hashtable(); List list = this.service.GetMode_type(CustPDLine); result.Add("list", list); return Json(result); } //汇总 public ActionResult GetOrderSummary(string cbCustPDLine, Pager pager) { if (string.IsNullOrEmpty(cbCustPDLine) || cbCustPDLine == "null") { return Json(""); } List dt = service.GetOrderSummary(cbCustPDLine, ref pager); Hashtable result = new Hashtable(); result.Add("rows", dt); result.Add("pager.totalRows", pager.totalRows); return Json(result); } //明细 public ActionResult GetOrderDetail(string cbCustPDLine, Pager pager) { if (string.IsNullOrEmpty(cbCustPDLine) || cbCustPDLine == "null") { return Json(""); } List dt = service.GetOrderDetail(cbCustPDLine, ref pager); Hashtable result = new Hashtable(); result.Add("rows", dt); result.Add("pager.totalRows", pager.totalRows); return Json(result); } //异常 public ActionResult GetOrderErrorMessage(string cbCustPDLine, Pager pager) { if (string.IsNullOrEmpty(cbCustPDLine) || cbCustPDLine == "null") { return Json(""); } List dt = service.GetOrderErrorMessage(cbCustPDLine, ref pager); Hashtable result = new Hashtable(); result.Add("rows",dt); result.Add("pager.totalRows", pager.totalRows); return Json(result); } /// /// 调用存储过程 dbo.sys_release_stock_order 释放生产指令 /// /// public ActionResult ReleaseOrder(string cbCustPDLine, string cbShift, string txtQty) { Hashtable result = new Hashtable(); if (string.IsNullOrEmpty(cbCustPDLine) || cbCustPDLine == "null") { result.Add("message", "请选择客户产线!"); return Json(result); } if (string.IsNullOrEmpty(cbShift) || cbShift == "null") { result.Add("message", "请选择班次!"); return Json(result); } if (string.IsNullOrEmpty(txtQty) || txtQty == "null") { result.Add("message", "请输入数量!"); return Json(result); } int Qty = 0; int ShiftId = 0; try { Qty = Convert.ToInt32(txtQty); ShiftId = Convert.ToInt32(cbShift); if (Qty <= 0) { result.Add("message", "请输入有效释放数量!"); return Json(result); } if (Qty > 100) { result.Add("message", "释放数量不允许大于100!"); return Json(result); } } catch (Exception ex) { result.Add("message", "请输入有效释放数量!"); return Json(result); } string strMessage = service.ReleaseOrder(cbCustPDLine, ShiftId, Qty); result.Add("message", strMessage); return Json(result); } /// /// 获取班次 /// /// public ActionResult Getshift() { Hashtable result = new Hashtable(); List list = this.service.Getshift(); result.Add("list", list); return Json(result); } //获取单号 public string getNumber() { return service.getNumber(); } public ActionResult changeStatus(int orderId, string isEmpty, string errorMessage) { Hashtable result = new Hashtable(); int status = 2; if (isEmpty == "否") { status = 3; } else if (isEmpty == "是") { status = 2; if (!string.IsNullOrEmpty(errorMessage)) { result.Add("message", "有异常信息存在,不允许更改!"); return Json(result); } } string str = this.service.changeStatus(orderId, status); result.Add("message", str); return Json(result); } /// /// 初始化单号 /// /// public ActionResult InitializeNumber() { Hashtable result = new Hashtable(); bool list = this.service.InitializeNumber(); result.Add("list", list); return Json(result); } //public ActionResult PrintMethod(string cbCustPDLine, string step, string printType, string forPrintNumber, string printDate, string printNumber) public ActionResult PrintMethod(string cbCustPDLine, string printType, string printDate, string printNumber) { Hashtable result = new Hashtable(); List dt =new List(); if (printType == "2") { dt = this.service.getPrintData(cbCustPDLine, printDate, printNumber); } else { dt = this.service.getPrintData(cbCustPDLine); } if (dt.Count <= 0) { result.Add("message", "未查询到待打印数据!"); result.Add("flag", "OK"); return Json(result); } StringBuilder SqlStringBuilder = new StringBuilder(1024); SqlStringBuilder.Append(" "); SqlStringBuilder.Append(" "); SqlStringBuilder.Append(" "); SqlStringBuilder.Append(" "); SqlStringBuilder.Append(" "); SqlStringBuilder.Append(" "); SqlStringBuilder.Append(" "); SqlStringBuilder.Append(" "); SqlStringBuilder.Append(" "); //计算有多少页 int PagePrintQuantity = Convert.ToInt32(service.getPrintQty()); int z = 1; double doublePage = Convert.ToDouble(dt.Count) / Convert.ToDouble(PagePrintQuantity); doublePage = Math.Ceiling(doublePage); for (int i = 1; i <= doublePage; i++) { string ProductionTaskNumber = ""; if (printType == "1") { ProductionTaskNumber = this.service.getProductionTaskNumber(); } else if (printType == "2") { ProductionTaskNumber = dt[0].PrintNumber.ToString(); } SqlStringBuilder.Append(" "); SqlStringBuilder.Append(" "); SqlStringBuilder.Append(" "); SqlStringBuilder.Append(" "); SqlStringBuilder.Append("
"); SqlStringBuilder.Append(" "); SqlStringBuilder.Append(" "); SqlStringBuilder.Append(" "); SqlStringBuilder.Append(" "); SqlStringBuilder.Append(" "); SqlStringBuilder.Append("
"); SqlStringBuilder.Append(" 生产任务单 "); SqlStringBuilder.Append(" "); SqlStringBuilder.Append(" " + ProductionTaskNumber + " "); SqlStringBuilder.Append("
"); SqlStringBuilder.Append(" "); SqlStringBuilder.Append(" "); SqlStringBuilder.Append(" "); SqlStringBuilder.Append(" "); SqlStringBuilder.Append(" "); SqlStringBuilder.Append(" "); SqlStringBuilder.Append(" "); SqlStringBuilder.Append(" "); SqlStringBuilder.Append(" "); SqlStringBuilder.Append(" "); //循环内容 int jj = i * PagePrintQuantity; if (jj >= dt.Count) { jj = dt.Count; } if (z > 1) { z = ((i - 1) * PagePrintQuantity) + 1; } int j = z; for (; j <= jj; j++) { string partName = dt[j - 1].PartNo.ToString(); string qty = dt[j - 1].Qty.ToString(); string pdlineName = dt[j - 1].PdlineName.ToString(); string orderSeq = dt[j - 1].OrderSeq.ToString(); string date = dt[j - 1].Date.ToString(); string date1 = dt[j - 1].date1.ToString(); string date2 = dt[j - 1].date2.ToString(); string part_spec2 = dt[j - 1].PartSpec2.ToString(); string ruid = dt[j - 1].Ruid.ToString(); if (printType == "1") { this.service.updateWorkOrderPrintNumber(ruid, ProductionTaskNumber); } SqlStringBuilder.Append(" "); SqlStringBuilder.Append(" "); SqlStringBuilder.Append(" "); SqlStringBuilder.Append(" "); SqlStringBuilder.Append(" "); SqlStringBuilder.Append(" "); SqlStringBuilder.Append(" "); SqlStringBuilder.Append(" "); SqlStringBuilder.Append(" "); SqlStringBuilder.Append(" "); SqlStringBuilder.Append(" "); } z++; SqlStringBuilder.Append("
座椅代号座椅描述数量工厂生产线流水号下单时间过点时间建议上线时间
" + partName + "" + part_spec2 + "" + qty + "" + pdlineName + "" + orderSeq + "" + date + "" + date1 + "" + date2 + "
"); SqlStringBuilder.Append("
"); //修改单号 if (printType == "1") { this.service.updateProductionTaskNumber(); } } SqlStringBuilder.Append(" "); SqlStringBuilder.Append(" "); if (printType == "1") { //this.service.UpdatePrintNumber(pn.ToString(), cbCustPDLine); } result.Add("message", "打印成功!"); result.Add("flag", "OK"); result.Add("DATA", SqlStringBuilder.ToString()); return Json(result); } } }