|
|
|
|
|
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();
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取客户产线列表
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
public ActionResult GetCustPDLine()
|
|
|
{
|
|
|
Hashtable result = new Hashtable();
|
|
|
List<KeyValueResult> list = this.service.GetCustPDLine();
|
|
|
result.Add("list", list);
|
|
|
return Json(result);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 根据客户产线查询车型
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
public ActionResult GetMode_type(string CustPDLine)
|
|
|
{
|
|
|
Hashtable result = new Hashtable();
|
|
|
List<KeyValueResult> 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<GOrder> 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<GOrder> 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<GWorkorder> dt = service.GetOrderErrorMessage(cbCustPDLine, ref pager);
|
|
|
|
|
|
Hashtable result = new Hashtable();
|
|
|
result.Add("rows",dt);
|
|
|
result.Add("pager.totalRows", pager.totalRows);
|
|
|
|
|
|
return Json(result);
|
|
|
}
|
|
|
|
|
|
///<summary>
|
|
|
/// 调用存储过程 dbo.sys_release_stock_order 释放生产指令
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
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);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取班次
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
public ActionResult Getshift()
|
|
|
{
|
|
|
Hashtable result = new Hashtable();
|
|
|
List<KeyValueResult> 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);
|
|
|
}
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// 初始化单号
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
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<GWorkorder> dt =new List<GWorkorder>();
|
|
|
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("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\"> ");
|
|
|
SqlStringBuilder.Append("<html> ");
|
|
|
SqlStringBuilder.Append("<head> ");
|
|
|
SqlStringBuilder.Append(" <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" /> ");
|
|
|
SqlStringBuilder.Append(" <title></title> ");
|
|
|
SqlStringBuilder.Append(" <script type=\"text/javascript\" src=\"..\\..\\libs\\js\\lodop\\LodopFuncs.js\"></script> ");
|
|
|
SqlStringBuilder.Append(" <style type=\"text/css\"> ");
|
|
|
SqlStringBuilder.Append(" body ");
|
|
|
SqlStringBuilder.Append(" { ");
|
|
|
SqlStringBuilder.Append(" font-family: Arial; ");
|
|
|
SqlStringBuilder.Append(" width: 180mm; ");
|
|
|
SqlStringBuilder.Append(" } ");
|
|
|
SqlStringBuilder.Append(" table ");
|
|
|
SqlStringBuilder.Append(" { ");
|
|
|
SqlStringBuilder.Append(" text-align:center; ");
|
|
|
SqlStringBuilder.Append(" width: 180mm; ");
|
|
|
SqlStringBuilder.Append(" } ");
|
|
|
SqlStringBuilder.Append(" td,th,tr ");
|
|
|
SqlStringBuilder.Append(" { ");
|
|
|
SqlStringBuilder.Append(" text-align:center; ");
|
|
|
SqlStringBuilder.Append(" font-size:10pt; ");
|
|
|
SqlStringBuilder.Append(" height:25px; ");
|
|
|
SqlStringBuilder.Append(" font-weight:normal; ");
|
|
|
SqlStringBuilder.Append(" } ");
|
|
|
SqlStringBuilder.Append(" .PageNext ");
|
|
|
SqlStringBuilder.Append(" { ");
|
|
|
SqlStringBuilder.Append(" page-break-after: always; ");
|
|
|
SqlStringBuilder.Append(" } ");
|
|
|
SqlStringBuilder.Append(" .Noprint ");
|
|
|
SqlStringBuilder.Append(" { ");
|
|
|
SqlStringBuilder.Append(" display: none; ");
|
|
|
SqlStringBuilder.Append(" } ");
|
|
|
SqlStringBuilder.Append(" </style> ");
|
|
|
SqlStringBuilder.Append("</head> ");
|
|
|
SqlStringBuilder.Append("<body> ");
|
|
|
|
|
|
//计算有多少页
|
|
|
|
|
|
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(" <table style=\"height:280mm\"> ");
|
|
|
SqlStringBuilder.Append(" <tr> ");
|
|
|
SqlStringBuilder.Append(" <td valign=\"top\"> ");
|
|
|
SqlStringBuilder.Append(" <table id=\"Table1\"> ");
|
|
|
SqlStringBuilder.Append(" <tr> ");
|
|
|
SqlStringBuilder.Append(" <td style=\" font-size: 30pt;\" width=\"80%\"> ");
|
|
|
SqlStringBuilder.Append(" 生产任务单 ");
|
|
|
SqlStringBuilder.Append(" </td> ");
|
|
|
SqlStringBuilder.Append(" <td style=\"font-size: 30pt; \" colspan=\"2\"> ");
|
|
|
SqlStringBuilder.Append(" " + ProductionTaskNumber + " ");
|
|
|
SqlStringBuilder.Append(" </td> ");
|
|
|
SqlStringBuilder.Append(" </tr> ");
|
|
|
SqlStringBuilder.Append(" </table> ");
|
|
|
SqlStringBuilder.Append(" <table id=\"Table2\" border=\"1\"> ");
|
|
|
SqlStringBuilder.Append(" <tr> ");
|
|
|
SqlStringBuilder.Append(" <th width=\"15%\">座椅代号</th> ");
|
|
|
SqlStringBuilder.Append(" <th width=\"15%\">座椅描述</th> ");
|
|
|
SqlStringBuilder.Append(" <th width=\"5%\">数量</th> ");
|
|
|
SqlStringBuilder.Append(" <th width=\"10%\">工厂生产线</th> ");
|
|
|
SqlStringBuilder.Append(" <th width=\"10%\">流水号</th> ");
|
|
|
SqlStringBuilder.Append(" <th width=\"10%\">下单时间</th> ");
|
|
|
SqlStringBuilder.Append(" <th width=\"10%\">过点时间</th> ");
|
|
|
SqlStringBuilder.Append(" <th width=\"13%\">建议上线时间</th> ");
|
|
|
|
|
|
|
|
|
//循环内容
|
|
|
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(" </tr> ");
|
|
|
SqlStringBuilder.Append(" <tr title=\"TWDReapter\"> ");
|
|
|
SqlStringBuilder.Append(" <td>" + partName + "</td> ");
|
|
|
SqlStringBuilder.Append(" <td>" + part_spec2 + "</td> ");
|
|
|
SqlStringBuilder.Append(" <td>" + qty + "</td> ");
|
|
|
SqlStringBuilder.Append(" <td>" + pdlineName + "</td> ");
|
|
|
SqlStringBuilder.Append(" <td>" + orderSeq + "</td> ");
|
|
|
SqlStringBuilder.Append(" <td>" + date + "</td> ");
|
|
|
SqlStringBuilder.Append(" <td>" + date1 + "</td> ");
|
|
|
SqlStringBuilder.Append(" <td>" + date2 + "</td> ");
|
|
|
SqlStringBuilder.Append(" </tr> ");
|
|
|
}
|
|
|
|
|
|
z++;
|
|
|
|
|
|
SqlStringBuilder.Append(" </table> ");
|
|
|
SqlStringBuilder.Append(" </td> ");
|
|
|
SqlStringBuilder.Append(" </tr> ");
|
|
|
SqlStringBuilder.Append(" </table> ");
|
|
|
|
|
|
//修改单号
|
|
|
|
|
|
if (printType == "1")
|
|
|
{
|
|
|
this.service.updateProductionTaskNumber();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
SqlStringBuilder.Append("</body> ");
|
|
|
SqlStringBuilder.Append("</html> ");
|
|
|
|
|
|
if (printType == "1")
|
|
|
{
|
|
|
//this.service.UpdatePrintNumber(pn.ToString(), cbCustPDLine);
|
|
|
}
|
|
|
|
|
|
result.Add("message", "打印成功!");
|
|
|
result.Add("flag", "OK");
|
|
|
result.Add("DATA", SqlStringBuilder.ToString());
|
|
|
return Json(result);
|
|
|
}
|
|
|
}
|
|
|
} |