You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

588 lines
21 KiB
C#

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

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
{
public class MovementOutstockManageController : BaseController
{
private IMovementOutstockManageService service;
public MovementOutstockManageController(IMovementOutstockManageService _service)
{
service = _service;
}
//
// GET: /Menu/
public ActionResult Index()
{
return View();
}
/// <summary>
/// 获取出库单管理列表数据
/// </summary>
/// <param name="menuName"></param>
/// <param name="pager"></param>
/// <param name="direction"></param>
/// <param name="sort"></param>
/// <returns></returns>
public ActionResult getMoveHeaderListByPage(string orderNo, string orderType, string orderStatus, string startTime, string endTime, Pager pager, String direction, String sort, string enabled = "Y")
{
int factoryId = CurrentEmp.FactoryId;
Hashtable result = new Hashtable();
result.Add("pager.pageNo", pager.pageNo);
Hashtable dataHt = this.service.getMoveHeaderListByPage(orderNo, orderType, orderStatus, startTime, endTime, enabled, factoryId, 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>
/// <param name="menuName"></param>
/// <param name="pager"></param>
/// <param name="direction"></param>
/// <param name="sort"></param>
/// <returns></returns>
public ActionResult getMoveDetailListByPage(string orderNo, string enabled = "Y")
{
int factoryId = CurrentEmp.FactoryId;
Hashtable result = new Hashtable();
Hashtable dataHt = this.service.getMoveDetailListByPage(orderNo, enabled, factoryId);
result.Add("rows", dataHt["dataList"]);
result.Add("pager.totalRows", dataHt["totalCount"]);
return Json(result);
}
/// <summary>
/// 获取出库单条码管理列表数据
/// </summary>
/// <param name="menuName"></param>
/// <param name="pager"></param>
/// <param name="direction"></param>
/// <param name="sort"></param>
/// <returns></returns>
public ActionResult getMoveSnListByPage(string orderNo, string partNo, string enabled = "Y")
{
int factoryId = CurrentEmp.FactoryId;
Hashtable result = new Hashtable();
Hashtable dataHt = this.service.getMoveSnListByPage(orderNo, partNo, enabled, factoryId);
result.Add("rows", dataHt["dataList"]);
result.Add("pager.totalRows", dataHt["totalCount"]);
return Json(result);
}
//打印查询
public ActionResult getMoveSnListByPrint(string orderNo, string enabled = "Y")
{
int factoryId = CurrentEmp.FactoryId;
List<WmsOutstockDetail> listData = this.service.getMoveSnListByPrint(orderNo, enabled, factoryId);
return Json(listData);
}
/// <summary>
/// 生成条码
/// </summary>
/// <param name="ruid"></param>
/// <returns></returns>
public ActionResult onBarcodeGenerator(String orderNos)
{
Hashtable result = new Hashtable();
try
{
result = this.service.onBarcodeGenerator(orderNos);
}
catch (Exception e)
{
result.Add("message", "生成条码失败,请重查看!");
result.Add("flag", "error");
}
return Json(result);
}
public ActionResult getSelectMoveOrderType()
{
Hashtable result = new Hashtable();
List<KeyValueResult> menuList = this.service.GetMoveOrderType();
result.Add("list", menuList);
return Json(result);
}
public ActionResult getSelectMoveOrderStatus()
{
Hashtable result = new Hashtable();
List<KeyValueResult> menuList = this.service.GetMoveOrderStatus();
result.Add("list", menuList);
return Json(result);
}
/// <summary>
/// 获取父节点菜单下拉列表数据
/// </summary>
/// <rehuoturns></returns>
public ActionResult getSelectFactory()
{
Hashtable result = new Hashtable();
List<KeyValueResult> menuList = this.service.getSelectFactory();
result.Add("list", menuList);
return Json(result);
}
public ActionResult getSelectWarehouse()
{
Hashtable result = new Hashtable();
List<KeyValueResult> menuList = this.service.getSelectWarehouse();
result.Add("list", menuList);
return Json(result);
}
public ActionResult getSelectZone()
{
Hashtable result = new Hashtable();
List<KeyValueResult> menuList = this.service.getSelectZone();
result.Add("list", menuList);
return Json(result);
}
public ActionResult getSelectVendor()
{
Hashtable result = new Hashtable();
List<KeyValueResult> menuList = this.service.getSelectVendor();
result.Add("list", menuList);
return Json(result);
}
public ActionResult getSelectCustomer()
{
Hashtable result = new Hashtable();
List<KeyValueResult> menuList = this.service.getSelectCustomer();
result.Add("list", menuList);
return Json(result);
}
public ActionResult getSelectLocate()
{
Hashtable result = new Hashtable();
List<KeyValueResult> menuList = this.service.getSelectLocate();
result.Add("list", menuList);
return Json(result);
}
public ActionResult GetPart()
{
Hashtable result = new Hashtable();
List<KeyValueResult> menuList = this.service.GetPart();
result.Add("list", menuList);
return Json(result);
}
/// <summary>
/// 保存菜单数据
/// </summary>
/// <returns></returns>
public ActionResult saveMovementOutstockManage()
{
int orderType = int.Parse(Request.Form["orderType"]);
int factoryId = CurrentEmp.FactoryId;
String factoryCode = CurrentEmp.FactoryCode;
String enabled = Request.Form["enabled"].ToString();
string vendorName = Request.Form["vendorName"];
string customerId = Request.Form["customerId"];
String planDate = Request.Form["planDate"].ToString();
String planTime = Request.Form["planTime"].ToString();
String srcWarehouseId = Request.Form["srcWarehouseId"].ToString();
String srcZoneId = Request.Form["srcZoneId"].ToString();
String srcLocateId = Request.Form["srcLocateId"].ToString();
String srcErpWarehouse = Request.Form["srcErpWarehouse"].ToString();
String reforderno = Request.Form["reforderno"].ToString();
String srcWarehouseName = "";
List<SysWarehouse> srcWare = service.getSelectWarehouse(srcWarehouseId);
if (srcWare.Count > 0)
{
srcWarehouseName = srcWare[0].WarehouseName;
}
String srcZoneName = "";
List<SysZone> srcZones = service.getSelectZone(srcZoneId);
if (srcZones.Count > 0)
{
srcZoneName = srcZones[0].ZoneName;
}
else
{
srcZoneName = "";
}
String srcLocateName = "";
List<SysLocate> locates = service.getSelectLocate(srcLocateId);
if (locates.Count > 0)
{
srcLocateName = locates[0].LocateName;
}
else
{
srcLocateName = "";
}
int vendorId = 0;
string vendorCode = "";
List<SysVendor> sysVendors = service.getSelectVendor(vendorName);
if (sysVendors.Count > 0)
{
vendorId = sysVendors[0].VendorId;
vendorCode= sysVendors[0].VendorCode;
}
customerId = string.IsNullOrEmpty(customerId) ? "0" : customerId;
List<SysCustomer> sysCustomers = service.getSelectCustomer(customerId.ToString());
string customerCode = "";
if (sysCustomers.Count > 0)
{
customerCode = sysCustomers[0].CustomerCode;
}
WmsOutstock moveHeader = new WmsOutstock();
moveHeader.OrderType = orderType;
moveHeader.VendorId = vendorId;
moveHeader.VendorCode = vendorCode;
moveHeader.CustomerId = Convert.ToInt32(customerId);
moveHeader.CustomerCode = customerCode;
moveHeader.FactoryId = factoryId;
moveHeader.FactoryCode = factoryCode;
moveHeader.Enabled = enabled;
moveHeader.RefOrderNo = reforderno;
string detailRow = Request.Form["detailRow"].ToString();
IList<WmsOutstockDetail> moveDetailsList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<WmsOutstockDetail>>(detailRow);
for (int i = 0; i < moveDetailsList.Count; i++)
{
moveDetailsList[i].ItemNo = (i + 1).ToString();
//purchaseDetailList[i].PartId = Convert.ToInt32(PartId);
string PartNo = string.IsNullOrEmpty(moveDetailsList[i].PartNo.ToString()) ? "0" : moveDetailsList[i].PartNo.ToString();
List<SysPart> parts = service.GetPart(PartNo);
if (parts.Count > 0)
{
moveDetailsList[i].PartId = parts[0].PartId;
moveDetailsList[i].PartSpec = parts[0].PartSpec;
moveDetailsList[i].Unit = parts[0].Unit;
}
else
{
moveDetailsList[i].PartId = 0;
moveDetailsList[i].PartSpec = "";
moveDetailsList[i].Unit = "";
}
//moveDetailsList[i].Qty = string.IsNullOrEmpty(Qty) ? 0 : Convert.ToDecimal(Qty);
moveDetailsList[i].PickQty =0;
moveDetailsList[i].OutQty = 0;
moveDetailsList[i].PlanDate = planDate;
moveDetailsList[i].PlanTime = planTime;
moveDetailsList[i].SrcWarehouseId = string.IsNullOrEmpty(srcWarehouseId)?0:Convert.ToInt32(srcWarehouseId);
moveDetailsList[i].SrcWarehouseName = srcWarehouseName;
moveDetailsList[i].SrcZoneId = string.IsNullOrEmpty(srcZoneId) ? 0 : Convert.ToInt32(srcZoneId);
moveDetailsList[i].SrcZoneName = srcZoneName;
moveDetailsList[i].SrcLocateId = string.IsNullOrEmpty(srcLocateId) ? 0 : Convert.ToInt32(srcLocateId);
moveDetailsList[i].SrcLocateName = srcLocateName;
moveDetailsList[i].SrcErpWarehouse = srcErpWarehouse;
moveDetailsList[i].Enabled = enabled;
moveDetailsList[i].FactoryId = CurrentEmp.FactoryId;
moveDetailsList[i].FactoryCode = CurrentEmp.FactoryCode;
moveDetailsList[i].CreateUserId = CurrentEmp.EmpId;
}
String message = "";
try
{
moveHeader.CreateUserId = CurrentEmp.EmpId;
bool flag = this.service.saveMovementManage(moveHeader, moveDetailsList);
if (flag == true)
{
message = "添加成功";
}
else
{
message = "添加失败!";
}
}
catch (Exception e)
{
message = "添加失败!";
}
Hashtable result = new Hashtable();
result.Add("message", message);
return Json(result);
}
public ActionResult GetErpwarehouse()
{
Hashtable resault = new Hashtable();
List<KeyValueResult> pdlineList = service.GetErpwarehouse();
resault.Add("list", pdlineList);
return Json(resault);
}
/// <summary>
/// 编辑菜单
/// </summary>
/// <param name="ruid"></param>
/// <returns></returns>
public ActionResult EditMoveOutstockManage(String warehouseId)
{
ViewData.Add("editType", "new");
List<KeyValueResult> menuList = this.service.getSelectWarehouse();
if (menuList.Count > 0)
{ //源仓库 绑定默认值
ViewData.Add("srcWarehouseId", menuList[0].value);
}
return View("EditMoveOutstockManage");
}
#region 过滤零件号
public ActionResult GetPart_No(string q)
{
List<string> list = filePart(q);
return writeResult(list);
}
/// <summary>
/// 过滤零件号
/// </summary>
/// <param name="key"></param>
/// <returns></returns>
public List<string> filePart(string key)
{
Hashtable autoComplateList = GetItemPart(key);
List<String> result = new List<string>();
foreach (System.Collections.DictionaryEntry item in autoComplateList)
{
if (item.Value.ToString().ToUpper().StartsWith(key.ToUpper()))
{
result.Add(item.Value.ToString());
}
}
return result;
}
/// <summary>
/// 查询零件号
/// </summary>
/// <param name="key"></param>
/// <returns></returns>
public Hashtable GetItemPart(string key)
{
List<String> autoComplateList = new List<string>();
Hashtable result = new Hashtable();
try
{
List<SysPart> dt = service.GetPartNoInfo(key);
for (int i = 0; i < dt.Count; i++)
{
result.Add(dt[i].PartId.ToString(), dt[i].PartNo.ToString());
}
}
catch (Exception e)
{
result = new Hashtable();
}
return result;
}
#endregion
#region 过滤零件号简码
public ActionResult GetPart_Spec(string q)
{
List<string> list = filePartSpec(q);
return writeResult(list);
}
/// <summary>
/// 过滤零件号
/// </summary>
/// <param name="key"></param>
/// <returns></returns>
public List<string> filePartSpec(string key)
{
Hashtable autoComplateList = GetItemPartSpec(key);
List<String> result = new List<string>();
foreach (System.Collections.DictionaryEntry item in autoComplateList)
{
if (item.Value.ToString().ToUpper().StartsWith(key.ToUpper()))
{
result.Add(item.Value.ToString());
}
}
return result;
}
/// <summary>
/// 查询零件号
/// </summary>
/// <param name="key"></param>
/// <returns></returns>
public Hashtable GetItemPartSpec(string key)
{
List<String> autoComplateList = new List<string>();
Hashtable result = new Hashtable();
try
{
List<SysPart> dt = service.GetPartSpecInfo(key);
for (int i = 0; i < dt.Count; i++)
{
result.Add(dt[i].PartId.ToString(), dt[i].PartSpec.ToString());
}
}
catch (Exception e)
{
result = new Hashtable();
}
return result;
}
#endregion
private ActionResult writeResult(List<string> list)
{
Hashtable result = new Hashtable();
result.Add("list", list);
return Json(result);
}
public ActionResult getPartNoInfo(string partNo)
{
Hashtable resault = new Hashtable();
List<SysPart> list = service.GetPartNoInfo(partNo);
return Json(list);
}
public ActionResult getPartNoInfoByPartNo(string partNo)
{
Hashtable resault = new Hashtable();
List<SysPart> list = service.GetPartNoInfoByPartNo(partNo);
return Json(list);
}
public ActionResult getPartSpecInfo(string partSpec)
{
Hashtable resault = new Hashtable();
List<SysPart> list = service.GetPartSpecInfo(partSpec);
return Json(list);
}
public ActionResult getPartSpecInfoByPartSpec(string partSpec)
{
Hashtable resault = new Hashtable();
List<SysPart> list = service.GetPartSpecInfoByPartSpec(partSpec);
return Json(list);
}
/// <summary>
/// 关闭
/// </summary>
/// <param name="ruid"></param>
/// <returns></returns>
public ActionResult onClose(String orderNos)
{
bool flag = true;
try
{
string empId = CurrentEmp.EmpId.ToString();
flag = this.service.onClose(orderNos, empId);
}
catch (Exception e)
{
flag =false;
}
Hashtable result = new Hashtable();
result.Add("status", flag);
return Json(result);
}
/// <summary>
/// 启用
/// </summary>
/// <param name="ids"></param>
/// <returns></returns>
public ActionResult onEnable(String orderNos)
{
bool flag = true;
try
{
flag = this.service.EnableData(orderNos);
}
catch (Exception e)
{
flag = false;
}
Hashtable result = new Hashtable();
result.Add("status", flag);
return Json(result);
}
/// <summary>
/// 禁用
/// </summary>
/// <param name="ids"></param>
/// <returns></returns>
public ActionResult onDisable(String orderNos)
{
bool flag = true;
try
{
flag = this.service.DisableData(orderNos);
}
catch (Exception e)
{
flag = false;
}
Hashtable result = new Hashtable();
result.Add("status", flag);
return Json(result);
}
/// <summary>
/// 导入
/// </summary>
/// <returns></returns>
public ActionResult importFile()
{
int factoryId = CurrentEmp.FactoryId;
string factoryCode = CurrentEmp.FactoryCode;
Hashtable result = new Hashtable();
IFormFile file = Request.Form.Files[0];
List<MovementOutstockManage> data = ExcelHelper.GetList<MovementOutstockManage>(file, 0);
result = service.ImportExcel(data, factoryId, factoryCode, CurrentEmp.EmpId);
return Json(result);
}
public ActionResult uploadFile()
{
return View("uploadFile");
}
/// <summary>
/// 下载模板
/// </summary>
/// <returns></returns>
public ActionResult downLoadExcel()
{
List<MovementOutstockManage> listHt = new List<MovementOutstockManage>();//导出空数据模板
var memoryStream = ExcelHelper.ToExcel(listHt);
string dateTime = DateTime.Now.ToString("yyyyMMddHHmmss");
return File(memoryStream.ToArray(), "application/ms-excel", "出库单管理" + dateTime + ".xls");
}
}
}