|
|
|
|
|
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 NPOI.HSSF.UserModel;
|
|
|
using Estsh.Core.Model.ExcelModel;
|
|
|
|
|
|
/***************************************************************************************************
|
|
|
*
|
|
|
* 更新人:sitong.dong
|
|
|
* 描述:生产指令调整
|
|
|
* 修改时间:2022.06.22
|
|
|
* 修改日志:系统迭代升级
|
|
|
*
|
|
|
**************************************************************************************************/
|
|
|
namespace Estsh.Core.Web.Controllers
|
|
|
{
|
|
|
/// <summary>
|
|
|
///
|
|
|
/// </summary>
|
|
|
public class AdjustOrderController : BaseController
|
|
|
{
|
|
|
|
|
|
private IAdjustOrderService service;
|
|
|
|
|
|
public AdjustOrderController(IAdjustOrderService _service)
|
|
|
{
|
|
|
this.service = _service;
|
|
|
}
|
|
|
//
|
|
|
// GET: /AdjustOrder/
|
|
|
public ActionResult Index()
|
|
|
{
|
|
|
return View();
|
|
|
}
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取生产指令调整列表数据
|
|
|
/// </summary>
|
|
|
/// <param name="CartonTrackName">菜单名称</param>
|
|
|
/// <param name="pager">分页</param>
|
|
|
/// <param name="direction">排序方式</param>
|
|
|
/// <param name="sort">排序列</param>
|
|
|
/// <returns></returns>
|
|
|
public ActionResult getAdjustOrderListByPage(Pager pager, String direction, String sort, string cbCustPDLine, string SN, string partNo, String enabled = "Y")
|
|
|
{
|
|
|
if ((string.IsNullOrEmpty(cbCustPDLine)) || cbCustPDLine == "null")
|
|
|
{
|
|
|
cbCustPDLine = "0";
|
|
|
}
|
|
|
|
|
|
Hashtable result = new Hashtable();
|
|
|
result.Add("pager.pageNo", pager.pageNo);
|
|
|
Hashtable dataHt = this.service.getAdjustOrderListByPage(pager, direction, sort, cbCustPDLine, SN, partNo, enabled);
|
|
|
result.Add("rows", dataHt["dataList"]);
|
|
|
result.Add("pager.totalRows", dataHt["totalCount"]);
|
|
|
result.Add("sort", sort);
|
|
|
result.Add("direction", direction);
|
|
|
return Json(result);
|
|
|
}
|
|
|
|
|
|
|
|
|
public ActionResult adjustLine(string seq, string ruid, string a, string SequenceNumber, string CustPDLine)
|
|
|
{
|
|
|
bool Bool = false;
|
|
|
Hashtable result = new Hashtable();
|
|
|
|
|
|
if (string.IsNullOrEmpty(seq) && string.IsNullOrEmpty(ruid) && string.IsNullOrEmpty(a))
|
|
|
{
|
|
|
result = new Hashtable();
|
|
|
result.Add("status", false);
|
|
|
return Json(result);
|
|
|
}
|
|
|
|
|
|
//选中行信息
|
|
|
seq = seq.Substring(0, seq.Length - 1);
|
|
|
ruid = ruid.Substring(0, ruid.Length - 1);
|
|
|
int VirtualOrder = Convert.ToInt32(a.Substring(0, a.Length - 1));
|
|
|
|
|
|
//查询所有待生产信息
|
|
|
List<GWorkorderDetail> dt = this.service.selectAll(CustPDLine);
|
|
|
|
|
|
var dr = dt.Find(a => a.Seq == Convert.ToInt32(SequenceNumber));
|
|
|
|
|
|
int objectOrder = Convert.ToInt32(dr.A);
|
|
|
|
|
|
if (Convert.ToInt32(VirtualOrder) > objectOrder)
|
|
|
{
|
|
|
for (int i = 0; i < VirtualOrder - objectOrder; i++)
|
|
|
{
|
|
|
|
|
|
dt = new List<GWorkorderDetail>();
|
|
|
dt = this.service.selectAll(CustPDLine);
|
|
|
var dr_2 = dt.Find(x => x.A == (VirtualOrder - i));
|
|
|
var dr_3 = dt.Find(x => x.A == (Convert.ToInt32(VirtualOrder) - i - 1));
|
|
|
|
|
|
int data_ruid_1 = Convert.ToInt32(dr_2.Ruid);
|
|
|
int data_seq_1 = Convert.ToInt32(dr_2.Seq);
|
|
|
int data_ruid_2 = Convert.ToInt32(dr_3.Ruid);
|
|
|
int data_seq_2 = Convert.ToInt32(dr_3.Seq);
|
|
|
|
|
|
Bool = this.service.upAll(data_ruid_1, data_seq_1, data_ruid_2, data_seq_2);
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
result = new Hashtable();
|
|
|
result.Add("status", false);
|
|
|
return Json(result);
|
|
|
}
|
|
|
|
|
|
result = new Hashtable();
|
|
|
result.Add("status", true);
|
|
|
return Json(result);
|
|
|
}
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// 删除BOMdetail数据
|
|
|
/// </summary>
|
|
|
/// <param name="ids"></param>
|
|
|
/// <returns></returns>
|
|
|
public ActionResult deleteOrder(string ruid)
|
|
|
{
|
|
|
int delCount = 0;
|
|
|
Hashtable result = new Hashtable();
|
|
|
ruid = ruid.Substring(0, ruid.Length - 1);
|
|
|
|
|
|
try
|
|
|
{
|
|
|
delCount = this.service.deleteOrder(ruid);
|
|
|
if (delCount > 0)
|
|
|
{
|
|
|
result.Add("message", "删除成功!");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
result.Add("message", "删除失败!");
|
|
|
}
|
|
|
}
|
|
|
catch (Exception e)
|
|
|
{
|
|
|
delCount = -1;
|
|
|
}
|
|
|
|
|
|
return Json(result);
|
|
|
}
|
|
|
|
|
|
public ActionResult deleteOrderInfo(string ruid)
|
|
|
{
|
|
|
String[] array = ruid.Split(',');
|
|
|
ruid = array[0].ToString();
|
|
|
string custPdlineDesc = array[1].ToString();
|
|
|
|
|
|
int delCount = 0;
|
|
|
Hashtable result = new Hashtable();
|
|
|
|
|
|
try
|
|
|
{
|
|
|
delCount = this.service.deleteOrderInfo(ruid, custPdlineDesc);
|
|
|
if (delCount > 0)
|
|
|
{
|
|
|
result.Add("message", "删除成功!");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
result.Add("message", "删除失败!");
|
|
|
}
|
|
|
}
|
|
|
catch (Exception e)
|
|
|
{
|
|
|
delCount = -1;
|
|
|
}
|
|
|
return Json(result);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 启用
|
|
|
/// </summary>
|
|
|
/// <param name="ids"></param>
|
|
|
/// <returns></returns>
|
|
|
public ActionResult onEnable(String ids)
|
|
|
{
|
|
|
int delCount = 0;
|
|
|
try
|
|
|
{
|
|
|
delCount = this.service.EnableData(ids);
|
|
|
}
|
|
|
catch (Exception e)
|
|
|
{
|
|
|
delCount = -1;
|
|
|
}
|
|
|
Hashtable result = new Hashtable();
|
|
|
result.Add("status", delCount);
|
|
|
return Json(result);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 禁用
|
|
|
/// </summary>
|
|
|
/// <param name="ids"></param>
|
|
|
/// <returns></returns>
|
|
|
public ActionResult onDisable(String ids)
|
|
|
{
|
|
|
int delCount = 0;
|
|
|
try
|
|
|
{
|
|
|
delCount = this.service.DisableData(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 cbCustPDLine, 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;
|
|
|
}
|
|
|
}
|
|
|
Hashtable dataHt = this.service.getTableListByPage(cbCustPDLine, pager, direction, sort, paging);
|
|
|
List<AdjustOrder> listHt = (List<AdjustOrder>)dataHt["dataList"];
|
|
|
var memoryStream = ExcelHelper.ToExcel(listHt);
|
|
|
return File(memoryStream.ToArray(), "application/ms-excel", "生产指令调整.xls");
|
|
|
}
|
|
|
}
|
|
|
}
|