StockOutOrderController.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using Microsoft.AspNetCore.Mvc;using WMS.BZWeb;
  6. using WMS.Core;
  7. using WMS.Core._02Entity;
  8. using WMS.Core._02Entity.FeiXu;
  9. using WMS.Core.APPBLL;
  10. using WMS.Core.ServiceCore;
  11. using WMS.Info;
  12. using WMS.Info.Dto;
  13. using WMS.Util;
  14. namespace WMS.BZWeb
  15. {
  16. [Area("OrderManager")]
  17. public class StockOutOrderController : MvcControllerBase
  18. {
  19. private FxStockOutOrderCore bll = new FxStockOutOrderCore();
  20. #region 视图功能
  21. /// <summary>
  22. /// 订单管理页面
  23. /// </summary>
  24. /// <returns></returns>
  25. [HttpGet]
  26. public ActionResult Index()
  27. {
  28. return View();
  29. }
  30. /// <summary>
  31. /// So单下载
  32. /// </summary>
  33. /// <returns></returns>
  34. [HttpGet]
  35. public ActionResult SoForm()
  36. {
  37. return View();
  38. }
  39. /// <summary>
  40. /// 领料单下载
  41. /// </summary>
  42. /// <returns></returns>
  43. [HttpGet]
  44. public ActionResult MatForm()
  45. {
  46. return View();
  47. }
  48. /// <summary>
  49. /// 指定出库
  50. /// </summary>
  51. /// <returns></returns>
  52. [HttpGet]
  53. public ActionResult AssignForm()
  54. {
  55. return View();
  56. }
  57. /// <summary>
  58. /// 查看实际出库明细
  59. /// </summary>
  60. /// <returns></returns>
  61. [HttpGet]
  62. public ActionResult DetailIndex()
  63. {
  64. return View();
  65. }
  66. #endregion
  67. #region 获取数据
  68. /// <summary>
  69. /// 查询单据明细
  70. /// </summary>
  71. /// <param name="pagination">分页参数</param>
  72. /// <param name="queryJson">查询条件函数</param>
  73. /// <returns></returns>
  74. [HttpGet]
  75. ////[AjaxOnly]
  76. public ActionResult GetStockOutOrderPageList(string pagination, string queryJson)
  77. {
  78. Pagination paginationobj = InitPagination(pagination);
  79. return ToPageDataResult(paginationobj, bll.GetStockOutOrderPageList(paginationobj, queryJson));
  80. }
  81. /// <summary>
  82. /// 分页查询
  83. /// </summary>
  84. /// <param name="pagination">分页参数</param>
  85. /// <param name="queryJson">查询条件函数</param>
  86. /// <returns></returns>
  87. [HttpGet]
  88. ////[AjaxOnly]
  89. public ActionResult GetStockOutOrdeItem(string OrderNo)
  90. {
  91. var data = bll.GeSockOutOrderItem(OrderNo);
  92. return Success("", data);
  93. }
  94. /// <summary>
  95. /// 分页查询
  96. /// </summary>
  97. /// <param name="pagination">分页参数</param>
  98. /// <param name="queryJson">查询条件函数</param>
  99. /// <returns></returns>
  100. [HttpPost]
  101. ////[AjaxOnly]
  102. public ActionResult GetMatInventory(string pNo)
  103. {
  104. var data = bll.GetMatInventory(pNo);
  105. List<StockLineDetailRequest> invs = new List<StockLineDetailRequest>();
  106. var orderLines = bll.GeSockOutOrderItem(pNo).Where(c => c.F_planQty != c.F_actualQty);
  107. foreach (var line in orderLines)
  108. {
  109. foreach (var item in data.OrderBy(c => c.F_editTime))
  110. {
  111. int needQty = invs.Sum(s => s.F_AssignQty);
  112. int quantity = item.F_quantity;
  113. if (needQty < line.F_planQty)
  114. {
  115. if ((line.F_planQty - needQty) < quantity)
  116. quantity = line.F_planQty - needQty;
  117. invs.Add(new StockLineDetailRequest
  118. {
  119. F_matNo = item.F_matNo,
  120. F_matName = item.F_matName,
  121. F_matType = item.F_matType,
  122. F_trayNo = item.F_trayNo,
  123. F_quantity = item.F_quantity,
  124. F_AssignQty = quantity,
  125. F_boxNo = item.F_boxNo,
  126. F_projectNo = item.F_projectNo
  127. });
  128. }
  129. }
  130. }
  131. if (!invs.Any())
  132. return Fail("没有库存信息!");
  133. return Success("", new { data = invs, sumQty = invs.Sum(s => s.F_AssignQty) });
  134. }
  135. /// <summary>
  136. /// 获取拣选口
  137. /// </summary>
  138. /// <param name="pagination">分页参数</param>
  139. /// <param name="queryJson">查询条件函数</param>
  140. /// <returns></returns>
  141. [HttpGet]
  142. ////[AjaxOnly]
  143. public ActionResult PointQuery(int type)
  144. {
  145. List<BASE_POINT> lstPoint = new List<BASE_POINT>();
  146. if (type == 0)
  147. {
  148. lstPoint.AddRange(new PointBll().Query(new Info.Models.PointQueryRequest() { PointType = (int)EPointType.YLCKJXK }));
  149. lstPoint.AddRange(new PointBll().Query(new Info.Models.PointQueryRequest() { PointType = (int)EPointType.CPCKJXK }));
  150. }
  151. else
  152. {
  153. lstPoint = new PointBll().Query(new Info.Models.PointQueryRequest() { PointType = type });
  154. }
  155. List<TreeModel> treeList = new List<TreeModel>();
  156. foreach (var item in lstPoint)
  157. {
  158. TreeModel node = new TreeModel();
  159. node.id = item.F_no;
  160. node.text = item.F_name;
  161. node.value = item.F_no;
  162. node.showcheck = true;
  163. node.checkstate = 0;
  164. node.isexpand = true;
  165. node.icon = ACLAuthorize.IcoAuthorize;
  166. node.parentId = "";
  167. treeList.Add(node);
  168. }
  169. return Success("", treeList);
  170. }
  171. /// <summary>
  172. /// 查询单据明细
  173. /// </summary>
  174. /// <param name="pagination">分页参数</param>
  175. /// <param name="queryJson">查询条件函数</param>
  176. /// <returns></returns>
  177. [HttpGet]
  178. ////[AjaxOnly]
  179. public ActionResult GetAssignFormData(string pno)
  180. {
  181. return Success("", bll.GetAssignFormData(pno));
  182. }
  183. /// <summary>
  184. /// 获取实际出库明细
  185. /// </summary>
  186. /// <param name="keyValue">主键值 </param>
  187. /// <returns></returns>
  188. [HttpGet]
  189. ////[AjaxOnly]
  190. public ActionResult GetStockOutDetail(string pno, string keyword)
  191. {
  192. var data = bll.GetStockOutDetail(pno, keyword);
  193. return Success("", data);
  194. }
  195. #endregion
  196. #region 提交数据
  197. /// <summary>
  198. /// 删除订单明细数据
  199. /// </summary>
  200. /// <param name="keyValue">主键值 </param>
  201. /// <returns></returns>
  202. [HttpPost]
  203. ////[AjaxOnly]
  204. public ActionResult DeleteForm(string keyValue)
  205. {
  206. LoginUserInfo LoginUser = LoginBLLCore.GetLoginUser();
  207. bll.CanelEntity(LoginUser, keyValue);
  208. return Success("作废成功。");
  209. }
  210. /// <summary>
  211. /// 下载销售单
  212. /// </summary>
  213. /// <param name="injson">出库单据数据</param>
  214. /// <returns></returns>
  215. public ActionResult DownSo(string soJson)
  216. {
  217. try
  218. {
  219. var sod = soJson.ToObject<FX_sod>();
  220. 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} ");
  221. if (!orderLines.Any())
  222. return Fail($"找不到该销售单的出库明细!");
  223. return Success("", orderLines);
  224. }
  225. catch (Exception e)
  226. {
  227. return Fail($"获取出库单单信息失败{e.Message}");
  228. }
  229. }
  230. /// <summary>
  231. /// 下载领料单
  232. /// </summary>
  233. /// <param name="injson">出库单据数据</param>
  234. /// <returns></returns>
  235. public ActionResult DownMatSo(string IssNbr)
  236. {
  237. try
  238. {
  239. if (string.IsNullOrWhiteSpace(IssNbr))
  240. return Fail("领料单号不能为空");
  241. 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}' ");
  242. if (!orderLines.Any())
  243. return Fail($"找不到该领料单的出库明细!");
  244. return Success("", orderLines);
  245. }
  246. catch (Exception e)
  247. {
  248. return Fail($"获取出库单单信息失败{e.Message}");
  249. }
  250. }
  251. /// <summary>
  252. /// 保存领料任务
  253. /// </summary>
  254. /// <param name="crmOrderProductJson">实体集合Json</param>
  255. /// <returns></returns>
  256. [HttpPost]
  257. ////[AjaxOnly]
  258. public ActionResult SoMatSave(string soJson, string formJson)
  259. {
  260. if (string.IsNullOrEmpty(soJson))
  261. throw SysExCore.ThrowFailException("未选择数据");
  262. var sods = soJson.ToObject<List<FX_TranD>>();
  263. var stockOut = formJson.ToObject<StockOutRequest>();
  264. LoginUserInfo LoginUser = LoginBLLCore.GetLoginUser();
  265. bll.SoMatSave(stockOut, sods, LoginUser);
  266. return Success("保存成功。", "");
  267. }
  268. /// <summary>
  269. /// 保存
  270. /// </summary>
  271. /// <param name="crmOrderProductJson">实体集合Json</param>
  272. /// <returns></returns>
  273. [HttpPost]
  274. ////[AjaxOnly]
  275. public ActionResult SoSave(string soJson)
  276. {
  277. if (string.IsNullOrEmpty(soJson))
  278. throw SysExCore.ThrowFailException("未选择数据");
  279. var sods = soJson.ToObject<List<FX_sod_det>>();
  280. if (sods == null)
  281. throw SysExCore.ThrowFailException("请求数据不能为空");
  282. LoginUserInfo LoginUser = LoginBLLCore.GetLoginUser();
  283. bll.SoSave(sods, LoginUser);
  284. return Success("保存成功。", "");
  285. }
  286. /// <summary>
  287. /// 出库保存
  288. /// </summary>
  289. /// <param name="crmOrderProductJson">实体集合Json</param>
  290. /// <returns></returns>
  291. [HttpPost]
  292. ////[AjaxOnly]
  293. public ActionResult AssignSave(string soJson, string formJson)
  294. {
  295. if (string.IsNullOrEmpty(soJson))
  296. throw SysExCore.ThrowFailException("未选择数据");
  297. var stockOutDetail = soJson.ToObject<List<StockLineDetailRequest>>();
  298. var stockOut = formJson.ToObject<StockOutRequest>();
  299. LoginUserInfo LoginUser = LoginBLLCore.GetLoginUser();
  300. bll.AssignCreate(stockOut, stockOutDetail.FindAll(c => c.F_quantity > 0), LoginUser);
  301. return Success("保存成功。", "");
  302. }
  303. /// <summary>
  304. /// 系统推荐出库保存
  305. /// </summary>
  306. /// <param name="crmOrderProductJson">实体集合Json</param>
  307. /// <returns></returns>
  308. [HttpPost]
  309. ////[AjaxOnly]
  310. public ActionResult SystemAssignSave(string no)
  311. {
  312. if (string.IsNullOrEmpty(no))
  313. throw SysExCore.ThrowFailException("未选择数据");
  314. LoginUserInfo LoginUser = LoginBLLCore.GetLoginUser();
  315. bll.SystemAssignCreate(no, LoginUser);
  316. return Success("保存成功。", "");
  317. }
  318. #endregion
  319. }
  320. }