|
|
using Estsh.Core.Controllers;
|
|
|
using Estsh.Core.Model.ExcelModel;
|
|
|
using Estsh.Core.Model.Result;
|
|
|
using Estsh.Core.Models;
|
|
|
using Estsh.Core.Services.IServices;
|
|
|
using Estsh.Core.Util;
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
using System.Collections;
|
|
|
|
|
|
/***************************************************************************************************
|
|
|
*
|
|
|
* 更新人:sitong.dong
|
|
|
* 描述:库存产量查询
|
|
|
* 修改时间:2022.06.22
|
|
|
* 修改日志:系统迭代升级
|
|
|
*
|
|
|
**************************************************************************************************/
|
|
|
namespace Estsh.Core.Web.Controllers
|
|
|
{
|
|
|
/// <summary>
|
|
|
/// 库存产量查询
|
|
|
/// </summary>
|
|
|
public class ProduceStockController : BaseController
|
|
|
{
|
|
|
private IProduceStockService service;
|
|
|
public ProduceStockController(IProduceStockService _service)
|
|
|
{
|
|
|
service = _service;
|
|
|
}
|
|
|
//
|
|
|
// GET: /ProduceStock/
|
|
|
public ActionResult Index()
|
|
|
{
|
|
|
return View();
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取库存产量查询汇总
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
public ActionResult GetSummary(Pager pager, String enabled = "Y")
|
|
|
{
|
|
|
#if(false)
|
|
|
string _where = "";
|
|
|
string typeId = string.Empty;
|
|
|
StringBuilder data = new StringBuilder();
|
|
|
if (!string.IsNullOrEmpty(Request.Form["cbTypeName"]))
|
|
|
{
|
|
|
_where += " and typeId='" + Request.Form["cbTypeName"].ToString() + "'";
|
|
|
typeId = Request.Form["cbTypeName"].ToString();
|
|
|
}
|
|
|
if (!string.IsNullOrEmpty(Request.Form["txtStartCarno"]) && !string.IsNullOrEmpty(Request.Form["txtEndCarno"]))
|
|
|
{
|
|
|
_where += " and a.car_no>= '" + Request.Form["txtStartCarno"].ToString().Trim() + "' and a.car_no<='" + Request.Form["txtEndCarno"].ToString().Trim() + "' ";
|
|
|
}
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(Request.Form["type"]))
|
|
|
{
|
|
|
string sbustr = string.Empty;
|
|
|
String[] str = Request.Form["type"].ToString().Split(',');
|
|
|
|
|
|
for (int i = 0; i < str.Length; i++)
|
|
|
{
|
|
|
sbustr += string.Format("'{0}',", str[i]);
|
|
|
}
|
|
|
char[] Splitor = { ',' };
|
|
|
|
|
|
sbustr = sbustr.TrimEnd(Splitor);
|
|
|
_where += "AND a.type in (" + sbustr + ")";
|
|
|
}
|
|
|
if (!string.IsNullOrEmpty(Request.Form["StartTime"]) && !string.IsNullOrEmpty(Request.Form["EndTime"]))
|
|
|
{
|
|
|
if (!string.IsNullOrEmpty(Request.Form["txtStartCarno"]) && !string.IsNullOrEmpty(Request.Form["txtEndCarno"]))
|
|
|
{
|
|
|
_where += " and convert(datetime,a.create_ymd) between convert(datetime,'" + Request.Form["StartTime"].ToString() + "') and convert(datetime,'" + Request.Form["EndTime"].ToString() + "') ";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
_where += " and ((a.out_pdline_ymd = convert(varchar(10),'" + Request.Form["StartTime"].ToString() + "',23) and a.out_pdline_hms >= convert(varchar(10),'" + Request.Form["StartTime"].ToString() + "',108)) ";
|
|
|
_where += " or (a.out_pdline_ymd > convert(varchar(10),'" + Request.Form["StartTime"].ToString() + "',23) and a.out_pdline_ymd < convert(varchar(10),'" + Request.Form["EndTime"].ToString() + "',23))";
|
|
|
_where += " or (a.out_pdline_ymd = convert(varchar(10),'" + Request.Form["EndTime"].ToString() + "',23) and a.out_pdline_hms <= convert(varchar(10),'" + Request.Form["EndTime"].ToString() + "',108)))";
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
Hashtable hs = new Hashtable();
|
|
|
DataTable dt = new DataTable();
|
|
|
ArrayList list = service.GetSummary(_where, ref dt);
|
|
|
|
|
|
//获取明细
|
|
|
DataTable dtdetail = new DataTable();
|
|
|
ArrayList listDetail = service.GetSummaryDtail(_where, typeId, ref dtdetail);
|
|
|
ViewData.Add("users", dt);
|
|
|
ViewData.Add("usersDetail", dtdetail);
|
|
|
ViewData.Add("typeId", typeId);
|
|
|
ViewData.Add("StartCar_no", Request.Form["txtStartCarno"].ToString().Trim());
|
|
|
ViewData.Add("EndCar_no", Request.Form["txtEndCarno"].ToString().Trim());
|
|
|
ViewData.Add("type", Request.Form["type"].ToString());
|
|
|
Session["dt"] = dt;
|
|
|
Session["dtdetail"] = dtdetail;
|
|
|
return View("~/Views/ProduceQuery/ProduceQuery.aspx");
|
|
|
#endif
|
|
|
if (string.IsNullOrEmpty(Request.Form["startDate"]))
|
|
|
{
|
|
|
return Json("");
|
|
|
}
|
|
|
DateTime startDate = Convert.ToDateTime(Request.Form["startDate"]);
|
|
|
DateTime stopDate = Convert.ToDateTime(Request.Form["stopDate"]);
|
|
|
string typeId = Request.Form["typeId"];
|
|
|
string startCarNumber = Request.Form["startCarNumber"];
|
|
|
string stopCarNumber = Request.Form["stopCarNumber"];
|
|
|
string whereStr = string.Empty;
|
|
|
if (string.IsNullOrEmpty(typeId) == false)
|
|
|
{
|
|
|
whereStr += " typeId='" + typeId + "' and";
|
|
|
}
|
|
|
if (string.IsNullOrEmpty(startCarNumber) == false)
|
|
|
{
|
|
|
whereStr += " a.car_no>= '" + startCarNumber + "' and";
|
|
|
}
|
|
|
if (string.IsNullOrEmpty(stopCarNumber) == false)
|
|
|
{
|
|
|
whereStr += " a.car_no<= '" + stopCarNumber + "' and";
|
|
|
}
|
|
|
|
|
|
whereStr += " create_time between '" + startDate + "' and '" + stopDate + "' ";
|
|
|
|
|
|
if (enabled != null && !enabled.Trim().Equals(""))
|
|
|
{
|
|
|
whereStr += " and a.enabled = '" + enabled + "'";
|
|
|
}
|
|
|
String factoryId = CurrentEmp.FactoryId.ToString();
|
|
|
if (factoryId != null && !factoryId.Trim().Equals(""))
|
|
|
{
|
|
|
whereStr += " and a.factory_id = '" + factoryId + "'";
|
|
|
}
|
|
|
|
|
|
Hashtable ht = service.GetSummary(whereStr, pager);
|
|
|
if (ht != null && ht.Count == 2)
|
|
|
{
|
|
|
Hashtable result = new Hashtable();
|
|
|
result.Add("rows", ht["dataList"]);
|
|
|
result.Add("pager.totalRows", ht["totalCount"]);
|
|
|
return Json(result);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
return Json("");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
public ActionResult GetDetail(Pager pager, String enabled = "Y")
|
|
|
{
|
|
|
if (string.IsNullOrEmpty(Request.Form["startDate"]))
|
|
|
{
|
|
|
return Json("");
|
|
|
}
|
|
|
DateTime startDate = Convert.ToDateTime(Request.Form["startDate"]);
|
|
|
DateTime stopDate = Convert.ToDateTime(Request.Form["stopDate"]);
|
|
|
string typeId = Request.Form["typeId"];
|
|
|
string startCarNumber = Request.Form["startCarNumber"];
|
|
|
string stopCarNumber = Request.Form["stopCarNumber"];
|
|
|
string whereStr = string.Empty;
|
|
|
if (string.IsNullOrEmpty(typeId) == false)
|
|
|
{
|
|
|
whereStr += " typeId='" + typeId + "' and";
|
|
|
}
|
|
|
if (string.IsNullOrEmpty(startCarNumber) == false)
|
|
|
{
|
|
|
whereStr += " a.car_no>= '" + startCarNumber + "' and";
|
|
|
}
|
|
|
if (string.IsNullOrEmpty(stopCarNumber) == false)
|
|
|
{
|
|
|
whereStr += " a.car_no<= '" + stopCarNumber + "' and";
|
|
|
}
|
|
|
|
|
|
whereStr += " create_time between '" + startDate + "' and '" + stopDate + "' ";
|
|
|
|
|
|
if (enabled != null && !enabled.Trim().Equals(""))
|
|
|
{
|
|
|
whereStr += " and a.enabled = '" + enabled + "'";
|
|
|
}
|
|
|
String factoryId = CurrentEmp.FactoryId.ToString();
|
|
|
if (factoryId != null && !factoryId.Trim().Equals(""))
|
|
|
{
|
|
|
whereStr += " and a.factory_id = '" + factoryId + "'";
|
|
|
}
|
|
|
Hashtable ht = service.GetDetail(whereStr, pager);
|
|
|
if (ht != null && ht.Count == 2)
|
|
|
{
|
|
|
Hashtable result = new Hashtable();
|
|
|
result.Add("rows", ht["dataList"]);
|
|
|
result.Add("pager.totalRows", ht["totalCount"]);
|
|
|
return Json(result);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
return Json("");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
public ActionResult GetStatisticsData(Pager pager, String enabled = "Y")
|
|
|
{
|
|
|
if (string.IsNullOrEmpty(Request.Form["startDate"]))
|
|
|
{
|
|
|
return Json("");
|
|
|
}
|
|
|
DateTime startDate = Convert.ToDateTime(Request.Form["startDate"]);
|
|
|
DateTime stopDate = Convert.ToDateTime(Request.Form["stopDate"]);
|
|
|
string typeId = Request.Form["typeId"];
|
|
|
string startCarNumber = Request.Form["startCarNumber"];
|
|
|
string stopCarNumber = Request.Form["stopCarNumber"];
|
|
|
string whereStr = string.Empty;
|
|
|
if (string.IsNullOrEmpty(typeId) == false)
|
|
|
{
|
|
|
whereStr += " typeId='" + typeId + "' and";
|
|
|
}
|
|
|
if (string.IsNullOrEmpty(startCarNumber) == false)
|
|
|
{
|
|
|
whereStr += " a.car_no>= '" + startCarNumber + "' and";
|
|
|
}
|
|
|
if (string.IsNullOrEmpty(stopCarNumber) == false)
|
|
|
{
|
|
|
whereStr += " a.car_no<= '" + stopCarNumber + "' and";
|
|
|
}
|
|
|
|
|
|
whereStr += " create_time between '" + startDate + "' and '" + stopDate + "' ";
|
|
|
|
|
|
if (enabled != null && !enabled.Trim().Equals(""))
|
|
|
{
|
|
|
whereStr += " and a.enabled = '" + enabled + "'";
|
|
|
}
|
|
|
String factoryId = CurrentEmp.FactoryId.ToString();
|
|
|
if (factoryId != null && !factoryId.Trim().Equals(""))
|
|
|
{
|
|
|
whereStr += " and a.factory_id = '" + factoryId + "'";
|
|
|
}
|
|
|
Hashtable ht = service.GetStatisticsData(whereStr, pager);
|
|
|
if (ht != null && ht.Count == 2)
|
|
|
{
|
|
|
Hashtable result = new Hashtable();
|
|
|
result.Add("rows", ht["dataList"]);
|
|
|
result.Add("pager.totalRows", ht["totalCount"]);
|
|
|
return Json(result);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
return Json("");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取列表数据
|
|
|
/// </summary>
|
|
|
/// <param name="ProduceStockName">菜单名称</param>
|
|
|
/// <param name="pager">分页</param>
|
|
|
/// <param name="direction">排序方式</param>
|
|
|
/// <param name="sort">排序列</param>
|
|
|
/// <returns></returns>
|
|
|
public ActionResult getProduceStockListByPage(String typeId, String CarNumber,String CarNumber2,String Date ,String Date2, Pager pager, String direction, String sort)
|
|
|
{
|
|
|
if (typeId == "" || typeId == null)
|
|
|
{
|
|
|
return Json("");
|
|
|
}
|
|
|
Hashtable result = new Hashtable();
|
|
|
result.Add("pager.pageNo", pager.pageNo);
|
|
|
Hashtable dataHt = this.service.getProduceStockListByPage(typeId, CarNumber,CarNumber2,Date,Date2, pager, direction, sort);
|
|
|
result.Add("rows", dataHt["dataList"]);
|
|
|
result.Add("pager.totalRows", dataHt["totalCount"]);
|
|
|
result.Add("sort", sort);
|
|
|
result.Add("direction", direction);
|
|
|
return Json(result);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取下拉列表数据
|
|
|
/// </summary>
|
|
|
/// <rehuoturns></returns>
|
|
|
public ActionResult getType()
|
|
|
{
|
|
|
Hashtable result = new Hashtable();
|
|
|
List<KeyValueResult> ProduceStockList = this.service.getType();
|
|
|
result.Add("list", ProduceStockList);
|
|
|
return Json(result);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 保存数据
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
public ActionResult saveProduceStock()
|
|
|
{
|
|
|
String editType = Request.Form["editType"].ToString();
|
|
|
|
|
|
String partId = Request.Form["partId"].ToString();
|
|
|
String custOrder = Request.Form["custOrder"].ToString();
|
|
|
String shipUnit = Request.Form["shipUnit"].ToString();
|
|
|
|
|
|
|
|
|
SysPartCustOrder sysPartCustOrder = new SysPartCustOrder();
|
|
|
sysPartCustOrder.PartId =Convert.ToInt32( partId);
|
|
|
sysPartCustOrder.CustOrder = custOrder;
|
|
|
sysPartCustOrder.ShipUnit = shipUnit;
|
|
|
|
|
|
|
|
|
String message = "";
|
|
|
if (editType != null && editType.Trim().Equals("edit"))
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
sysPartCustOrder.UpdateUserId = CurrentEmp.EmpId;
|
|
|
this.service.updateProduceStock(sysPartCustOrder);
|
|
|
message = "修改成功";
|
|
|
}
|
|
|
catch (Exception e)
|
|
|
{
|
|
|
message = "修改失败!";
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
sysPartCustOrder.CreateUserId = CurrentEmp.EmpId;
|
|
|
this.service.saveProduceStock(sysPartCustOrder);
|
|
|
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 getProduceStock(String ProduceStock_id)
|
|
|
{
|
|
|
List<SysPartCustOrder> ProduceStockInfo = this.service.getProduceStock(ProduceStock_id);
|
|
|
ViewData.Add("partId", ProduceStockInfo[0].PartId);
|
|
|
ViewData.Add("custOrder", ProduceStockInfo[0].CustOrder);
|
|
|
ViewData.Add("shipUnit", ProduceStockInfo[0].ShipUnit);
|
|
|
|
|
|
return View("viewProduceStock");
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 编辑
|
|
|
/// </summary>
|
|
|
/// <param name="ruid"></param>
|
|
|
/// <returns></returns>
|
|
|
public ActionResult editProduceStock(String partId)
|
|
|
{
|
|
|
List<SysPartCustOrder> ProduceStockInfo = this.service.getProduceStock(partId);
|
|
|
ViewData.Add("editType", "edit");
|
|
|
ViewData.Add("partId", partId);
|
|
|
ViewData.Add("custOrder", ProduceStockInfo[0].CustOrder);
|
|
|
ViewData.Add("shipUnit", ProduceStockInfo[0].ShipUnit);
|
|
|
|
|
|
return View("EditProduceStock");
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 删除
|
|
|
/// </summary>
|
|
|
/// <param name="ids"></param>
|
|
|
/// <returns></returns>
|
|
|
public ActionResult deleteProduceStock(String ids)
|
|
|
{
|
|
|
int delCount = 0;
|
|
|
try
|
|
|
{
|
|
|
delCount = this.service.deleteProduceStock(ids);
|
|
|
}
|
|
|
catch (Exception e)
|
|
|
{
|
|
|
delCount = -1;
|
|
|
}
|
|
|
Hashtable result = new Hashtable();
|
|
|
result.Add("status", delCount);
|
|
|
return Json(result);
|
|
|
}
|
|
|
|
|
|
|
|
|
/// <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 ExportProduceStock(String partNo, String custOrder, Pager pager, String sort, String direction, String isPage)
|
|
|
{
|
|
|
|
|
|
Boolean paging = false;
|
|
|
if (isPage == null || "".Equals(isPage))
|
|
|
{
|
|
|
paging = false;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if ("1".Equals(isPage))
|
|
|
{
|
|
|
paging = true;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
paging = false;
|
|
|
}
|
|
|
}
|
|
|
Hashtable dataHt = this.service.getTableListByPage(partNo, custOrder, pager, direction, sort, paging);
|
|
|
List<ProduceStock> listHt = (List<ProduceStock>)dataHt["dataList"];
|
|
|
var memoryStream = ExcelHelper.ToExcel(listHt);
|
|
|
return File(memoryStream.ToArray(), "application/ms-excel", "客户订单号明细.xls");
|
|
|
}
|
|
|
}
|
|
|
}
|