123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using Microsoft.AspNetCore.Mvc;using WMS.BZWeb;
- using WMS.Core;
- using WMS.Core._02Entity;
- using WMS.Core._02Entity.FeiXu;
- using WMS.Core.APPBLL;
- using WMS.Core.ServiceCore;
- using WMS.Info;
- using WMS.Info.Dto;
- using WMS.Util;
- namespace WMS.BZWeb
- {
- [Area("OrderManager")]
- public class StockOutOrderController : MvcControllerBase
- {
- private FxStockOutOrderCore bll = new FxStockOutOrderCore();
- #region 视图功能
- /// <summary>
- /// 订单管理页面
- /// </summary>
- /// <returns></returns>
- [HttpGet]
- public ActionResult Index()
- {
- return View();
- }
- /// <summary>
- /// So单下载
- /// </summary>
- /// <returns></returns>
- [HttpGet]
- public ActionResult SoForm()
- {
- return View();
- }
- /// <summary>
- /// 领料单下载
- /// </summary>
- /// <returns></returns>
- [HttpGet]
- public ActionResult MatForm()
- {
- return View();
- }
- /// <summary>
- /// 指定出库
- /// </summary>
- /// <returns></returns>
- [HttpGet]
- public ActionResult AssignForm()
- {
- return View();
- }
- /// <summary>
- /// 查看实际出库明细
- /// </summary>
- /// <returns></returns>
- [HttpGet]
- public ActionResult DetailIndex()
- {
- return View();
- }
- #endregion
- #region 获取数据
- /// <summary>
- /// 查询单据明细
- /// </summary>
- /// <param name="pagination">分页参数</param>
- /// <param name="queryJson">查询条件函数</param>
- /// <returns></returns>
- [HttpGet]
- ////[AjaxOnly]
- public ActionResult GetStockOutOrderPageList(string pagination, string queryJson)
- {
- Pagination paginationobj = InitPagination(pagination);
- return ToPageDataResult(paginationobj, bll.GetStockOutOrderPageList(paginationobj, queryJson));
- }
- /// <summary>
- /// 分页查询
- /// </summary>
- /// <param name="pagination">分页参数</param>
- /// <param name="queryJson">查询条件函数</param>
- /// <returns></returns>
- [HttpGet]
- ////[AjaxOnly]
- public ActionResult GetStockOutOrdeItem(string OrderNo)
- {
- var data = bll.GeSockOutOrderItem(OrderNo);
- return Success("", data);
- }
- /// <summary>
- /// 分页查询
- /// </summary>
- /// <param name="pagination">分页参数</param>
- /// <param name="queryJson">查询条件函数</param>
- /// <returns></returns>
- [HttpPost]
- ////[AjaxOnly]
- public ActionResult GetMatInventory(string pNo)
- {
- var data = bll.GetMatInventory(pNo);
- List<StockLineDetailRequest> invs = new List<StockLineDetailRequest>();
- var orderLines = bll.GeSockOutOrderItem(pNo).Where(c => c.F_planQty != c.F_actualQty);
- foreach (var line in orderLines)
- {
- foreach (var item in data.OrderBy(c => c.F_editTime))
- {
- int needQty = invs.Sum(s => s.F_AssignQty);
- int quantity = item.F_quantity;
- if (needQty < line.F_planQty)
- {
- if ((line.F_planQty - needQty) < quantity)
- quantity = line.F_planQty - needQty;
- invs.Add(new StockLineDetailRequest
- {
- F_matNo = item.F_matNo,
- F_matName = item.F_matName,
- F_matType = item.F_matType,
- F_trayNo = item.F_trayNo,
- F_quantity = item.F_quantity,
- F_AssignQty = quantity,
- F_boxNo = item.F_boxNo,
- F_projectNo = item.F_projectNo
- });
- }
- }
- }
- if (!invs.Any())
- return Fail("没有库存信息!");
- return Success("", new { data = invs, sumQty = invs.Sum(s => s.F_AssignQty) });
- }
- /// <summary>
- /// 获取拣选口
- /// </summary>
- /// <param name="pagination">分页参数</param>
- /// <param name="queryJson">查询条件函数</param>
- /// <returns></returns>
- [HttpGet]
- ////[AjaxOnly]
- public ActionResult PointQuery(int type)
- {
- List<BASE_POINT> lstPoint = new List<BASE_POINT>();
- if (type == 0)
- {
- lstPoint.AddRange(new PointBll().Query(new Info.Models.PointQueryRequest() { PointType = (int)EPointType.YLCKJXK }));
- lstPoint.AddRange(new PointBll().Query(new Info.Models.PointQueryRequest() { PointType = (int)EPointType.CPCKJXK }));
- }
- else
- {
- lstPoint = new PointBll().Query(new Info.Models.PointQueryRequest() { PointType = type });
- }
- List<TreeModel> treeList = new List<TreeModel>();
- foreach (var item in lstPoint)
- {
- TreeModel node = new TreeModel();
- node.id = item.F_no;
- node.text = item.F_name;
- node.value = item.F_no;
- node.showcheck = true;
- node.checkstate = 0;
- node.isexpand = true;
- node.icon = ACLAuthorize.IcoAuthorize;
- node.parentId = "";
- treeList.Add(node);
- }
- return Success("", treeList);
- }
- /// <summary>
- /// 查询单据明细
- /// </summary>
- /// <param name="pagination">分页参数</param>
- /// <param name="queryJson">查询条件函数</param>
- /// <returns></returns>
- [HttpGet]
- ////[AjaxOnly]
- public ActionResult GetAssignFormData(string pno)
- {
- return Success("", bll.GetAssignFormData(pno));
- }
- /// <summary>
- /// 获取实际出库明细
- /// </summary>
- /// <param name="keyValue">主键值 </param>
- /// <returns></returns>
- [HttpGet]
- ////[AjaxOnly]
- public ActionResult GetStockOutDetail(string pno, string keyword)
- {
- var data = bll.GetStockOutDetail(pno, keyword);
- return Success("", data);
- }
- #endregion
- #region 提交数据
- /// <summary>
- /// 删除订单明细数据
- /// </summary>
- /// <param name="keyValue">主键值 </param>
- /// <returns></returns>
- [HttpPost]
- ////[AjaxOnly]
- public ActionResult DeleteForm(string keyValue)
- {
- LoginUserInfo LoginUser = LoginBLLCore.GetLoginUser();
- bll.CanelEntity(LoginUser, keyValue);
- return Success("作废成功。");
- }
- /// <summary>
- /// 下载销售单
- /// </summary>
- /// <param name="injson">出库单据数据</param>
- /// <returns></returns>
- public ActionResult DownSo(string soJson)
- {
- try
- {
- var sod = soJson.ToObject<FX_sod>();
- var orderLines = FxDbCore.GetData<FX_sod_det>($"select sod_nbr,sod_line,sod_part,sod_um,sod_qty_ord,sod_qty_ship from pub.sod_det where sod_domain='AFCN' and sod_site='SUZ' and sod_nbr='{sod.sod_nbr}' and sod_line={sod.sod_line} ");
- if (!orderLines.Any())
- return Fail($"找不到该销售单的出库明细!");
- return Success("", orderLines);
- }
- catch (Exception e)
- {
- return Fail($"获取出库单单信息失败{e.Message}");
- }
- }
- /// <summary>
- /// 下载领料单
- /// </summary>
- /// <param name="injson">出库单据数据</param>
- /// <returns></returns>
- public ActionResult DownMatSo(string IssNbr)
- {
- try
- {
- if (string.IsNullOrWhiteSpace(IssNbr))
- return Fail("领料单号不能为空");
- var orderLines = FxDbCore.GetData<FX_TranD>($"select \"Domain\",FromSite,FromWhse,FromLoc,FromPart,FromLot,FromRef,ToSite,ToWhse,ToLoc,ToPart,ToLot,ToRef,TrType,Task,WLocGp,IssNbr,QtyExp from pub.TranD where \"Domain\"='AFCN' and site = 'SUZ' and FromSite ='SUZ' and FromWhse='31' and ToWhse='31' and ToSite='SUZ' and Task='PICK' and IssNbr='{IssNbr}' ");
- if (!orderLines.Any())
- return Fail($"找不到该领料单的出库明细!");
- return Success("", orderLines);
- }
- catch (Exception e)
- {
- return Fail($"获取出库单单信息失败{e.Message}");
- }
- }
- /// <summary>
- /// 保存领料任务
- /// </summary>
- /// <param name="crmOrderProductJson">实体集合Json</param>
- /// <returns></returns>
- [HttpPost]
- ////[AjaxOnly]
- public ActionResult SoMatSave(string soJson, string formJson)
- {
- if (string.IsNullOrEmpty(soJson))
- throw SysExCore.ThrowFailException("未选择数据");
- var sods = soJson.ToObject<List<FX_TranD>>();
- var stockOut = formJson.ToObject<StockOutRequest>();
- LoginUserInfo LoginUser = LoginBLLCore.GetLoginUser();
- bll.SoMatSave(stockOut, sods, LoginUser);
- return Success("保存成功。", "");
- }
- /// <summary>
- /// 保存
- /// </summary>
- /// <param name="crmOrderProductJson">实体集合Json</param>
- /// <returns></returns>
- [HttpPost]
- ////[AjaxOnly]
- public ActionResult SoSave(string soJson)
- {
- if (string.IsNullOrEmpty(soJson))
- throw SysExCore.ThrowFailException("未选择数据");
- var sods = soJson.ToObject<List<FX_sod_det>>();
- if (sods == null)
- throw SysExCore.ThrowFailException("请求数据不能为空");
- LoginUserInfo LoginUser = LoginBLLCore.GetLoginUser();
- bll.SoSave(sods, LoginUser);
- return Success("保存成功。", "");
- }
- /// <summary>
- /// 出库保存
- /// </summary>
- /// <param name="crmOrderProductJson">实体集合Json</param>
- /// <returns></returns>
- [HttpPost]
- ////[AjaxOnly]
- public ActionResult AssignSave(string soJson, string formJson)
- {
- if (string.IsNullOrEmpty(soJson))
- throw SysExCore.ThrowFailException("未选择数据");
- var stockOutDetail = soJson.ToObject<List<StockLineDetailRequest>>();
- var stockOut = formJson.ToObject<StockOutRequest>();
- LoginUserInfo LoginUser = LoginBLLCore.GetLoginUser();
- bll.AssignCreate(stockOut, stockOutDetail.FindAll(c => c.F_quantity > 0), LoginUser);
- return Success("保存成功。", "");
- }
- /// <summary>
- /// 系统推荐出库保存
- /// </summary>
- /// <param name="crmOrderProductJson">实体集合Json</param>
- /// <returns></returns>
- [HttpPost]
- ////[AjaxOnly]
- public ActionResult SystemAssignSave(string no)
- {
- if (string.IsNullOrEmpty(no))
- throw SysExCore.ThrowFailException("未选择数据");
- LoginUserInfo LoginUser = LoginBLLCore.GetLoginUser();
- bll.SystemAssignCreate(no, LoginUser);
- return Success("保存成功。", "");
- }
- #endregion
- }
- }
|