InventoryManagementController.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.Mvc;
  6. using Bowin.Common.Utility;
  7. using Bowin.Web.Controls.Mvc;
  8. using EMIS.CommonLogic.TeachingMaterial;
  9. using EMIS.ViewModel;
  10. using EMIS.ViewModel.TeachingMaterial;
  11. using EMIS.Web.Controls;
  12. using Bowin.Common.Data;
  13. using EMIS.CommonLogic.SystemServices;
  14. using EMIS.CommonLogic.CalendarManage;
  15. namespace EMIS.Web.Controllers.TeachingMaterial
  16. {
  17. [Authorization]
  18. public class InventoryManagementController : Controller
  19. {
  20. public IStockOutServices StockOutServices { get; set; }
  21. public IStockInDetailServices StockInDetailServices { get; set; }
  22. public IStockInServices StockInServices { get; set; }
  23. public IInventoryServices InventoryServices { get; set; }
  24. public ISchoolYearServices SchoolYearServices { get; set; }
  25. /// <summary>
  26. /// 库存汇总页面
  27. /// </summary>
  28. /// <returns></returns>
  29. [HttpGet]
  30. public ActionResult List()
  31. {
  32. var schoolYear = SchoolYearServices.GetSchoolYearIsCurrent(true);
  33. ViewBag.SchoolYearID = schoolYear == null ? "-1" : schoolYear.SchoolyearID.ToString();//默认当前学年
  34. return View();
  35. }
  36. /// <summary>
  37. /// 库存汇总查询
  38. /// </summary>
  39. /// <param name="pararms"></param>
  40. /// <returns></returns>
  41. [HttpPost]
  42. public ActionResult List(QueryParamsModel pararms)
  43. {
  44. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  45. var schoolYear = SchoolYearServices.GetSchoolYearIsCurrent(true);
  46. //避开全选值
  47. Guid? publishID = null;
  48. Guid? schoolyearID = null;
  49. Guid? teachingMaterialID = null;
  50. publishID = pararms.getExtraGuid("PublishDropdown");
  51. schoolyearID = pararms.getExtraGuid("SchoolYearDropdown");
  52. var teachingMaterialType = pararms.getExtraInt("TeachingMaterialTypeDropdown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("TeachingMaterialTypeDropdown");
  53. teachingMaterialID = pararms.getExtraGuid("TeachingMaterialDropdown");
  54. if (schoolyearID == null)
  55. {
  56. schoolyearID = (Guid)schoolYear.SchoolyearID;
  57. }
  58. return base.Json(InventoryServices.GetInventoryManagementViewGrid(configuretView, schoolyearID, teachingMaterialID, teachingMaterialType, publishID, (int)pararms.page, (int)pararms.rows));
  59. }
  60. /// <summary>
  61. /// Excel导出
  62. /// </summary>
  63. /// <returns></returns>
  64. [HttpPost]
  65. public ActionResult Excel()
  66. {
  67. NpoiExcelHelper neh = new NpoiExcelHelper();
  68. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
  69. Guid? publishID = null;
  70. Guid? schoolyearID = null;
  71. Guid? teachingMaterialID = null;
  72. publishID = Request.Form["PublishDropdown"].ParseStrTo<Guid>();
  73. schoolyearID = Request.Form["SchoolYearDropdown"].ParseStrTo<Guid>();
  74. var teachingMaterialType = Request.Form["TeachingMaterialTypeDropdown"].ParseStrTo<int>();
  75. if (Request.Form["TeachingMaterialTypeDropdown"].ParseStrTo<int>() != DropdownList.SELECT_ALL && Request.Form["TeachingMaterialTypeDropdown"].ParseStrTo<int>() != null)
  76. {
  77. teachingMaterialType = Request.Form["TeachingMaterialTypeDropdown"].ParseStrTo<int>();
  78. }
  79. teachingMaterialID = Request.Form["TeachingMaterialDropdown"].ParseStrTo<Guid>();
  80. var dt = InventoryServices.GetInventoryManagementViewList(configuretView, schoolyearID, teachingMaterialID, teachingMaterialType, publishID).Select(x => new
  81. {
  82. x.SchoolYearName,
  83. x.TeachingMaterialCode,
  84. x.TeachingMaterialName,
  85. x.ISBN,
  86. x.MinInventory,
  87. x.InventoryCollectQtyStr,
  88. x.StockInQty,
  89. x.StockOutQty,
  90. x.PresentInventory,
  91. x.Price,
  92. }).ToTable();
  93. string[] liststring = { "学年学期", "教材编号", "教材名称", "ISBN", "最小库存量", "原库存量", "入库数量", "出库数量", "当前库存量", "单价" };
  94. neh.Export(dt, liststring, "库存统计信息");
  95. return RedirectToAction("MsgShow", "Common", new
  96. {
  97. msg = "导出成功!",
  98. url = Url.Content("~/InventoryManagement/List").AddMenuParameter()
  99. });
  100. }
  101. /// <summary>
  102. /// 库存明细Excel导出
  103. /// </summary>
  104. /// <param name="teachingMaterialPoolID"></param>
  105. /// <returns></returns>
  106. [HttpPost]
  107. public ActionResult InventoryExcel(Guid? teachingMaterialPoolID)
  108. {
  109. NpoiExcelHelper neh = new NpoiExcelHelper();
  110. var dt = InventoryServices.GetTeachingMateriaInventoryViewList(teachingMaterialPoolID).Select(x => new
  111. {
  112. x.PublishName,
  113. x.TeachingMaterialCode,
  114. x.TeachingMaterialName,
  115. x.CoursematerialCode,
  116. x.CoursematerialName,
  117. x.ISBN,
  118. x.PublishTime,
  119. x.Author,
  120. x.IsLateName,
  121. x.Price,
  122. x.MinInventory,
  123. x.PresentInventory,
  124. x.Total,
  125. x.ModifyTime,
  126. x.Desc
  127. }).ToTable();
  128. string[] liststring = { "书库名称", "教材编号", "教材名称", "课程代码", "课程名称", "ISBN", "版本时间", "出版单位", "作者", "是否过期", "单价", "最小库存量", "当前库存量", "码洋", "最近响应时间", "备注" };
  129. neh.Export(dt, liststring, "教材库存信息");
  130. return RedirectToAction("MsgShow", "Common", new
  131. {
  132. msg = "导出成功!",
  133. url = Url.Content("~/InventoryManagement/List").AddMenuParameter()
  134. });
  135. }
  136. /// <summary>
  137. /// 出库明细Excel导出
  138. /// </summary>
  139. /// <param name="teachingMaterialPoolID"></param>
  140. /// <param name="schoolyearID"></param>
  141. /// <returns></returns>
  142. [HttpPost]
  143. public ActionResult StockInExcel(Guid? teachingMaterialPoolID, Guid? schoolyearID)
  144. {
  145. NpoiExcelHelper neh = new NpoiExcelHelper();
  146. var dt = InventoryServices.GetStockInDetailByValueViewList(teachingMaterialPoolID, schoolyearID).Select(x => new
  147. {
  148. x.SchoolyearName,
  149. x.StockInDocumentNo,
  150. x.TeachingMaterialCode,
  151. x.TeachingMaterialName,
  152. x.Quantity,
  153. x.Price,
  154. x.DiscountStr,
  155. x.DiscountPriceStr,
  156. x.TotalPriceStr,
  157. x.TotalDollarStr,
  158. x.HandlerUserName,
  159. x.StockInTime
  160. }).ToTable();
  161. string[] liststring = { "学年学期", "入库单据号", "教材编号", "教材名称", "数量", "单价", "折扣率", "折合价", "码洋", "总价", "经手人", "入库日期" };
  162. neh.Export(dt, liststring, "入库明细信息");
  163. return RedirectToAction("MsgShow", "Common", new
  164. {
  165. msg = "导出成功!",
  166. url = Url.Content("~/InventoryManagement/List").AddMenuParameter()
  167. });
  168. }
  169. /// <summary>
  170. /// 入库明细Excel导出
  171. /// </summary>
  172. /// <returns></returns>
  173. [HttpPost]
  174. public ActionResult StockOutExcel()
  175. {
  176. Guid? teachingMaterialPoolID = Request.Params["teachingMaterialPoolID"].ParseStrTo<Guid>();
  177. Guid? schoolyearID = Request.Params["schoolyearID"].ParseStrTo<Guid>();
  178. var SchoolYearEntity = SchoolYearServices.GetSchoolYear(schoolyearID);
  179. NpoiExcelHelper neh = new NpoiExcelHelper();
  180. var dt = InventoryServices.GetStockOutDetailByValueViewList(teachingMaterialPoolID, SchoolYearEntity.Value, schoolyearID).Select(x => new
  181. {
  182. x.SchoolyearName,
  183. x.StockOutNo,
  184. x.GetBookNo,
  185. x.TeachingMaterialCode,
  186. x.TeachingMaterialName,
  187. x.StockOutTypeNameStr,
  188. x.Quantity,
  189. x.Price,
  190. x.DiscountStr,
  191. x.DiscountPriceStr,
  192. x.TotalPriceStr,
  193. x.TotalDollarStr,
  194. x.RecipientUserName,
  195. x.StockOutTime,
  196. x.Desc
  197. }).ToTable();
  198. string[] liststring = { "学年学期","出库单据号", "领书人", "教材编号", "教材名称","出库类型",
  199. "数量", "单价", "折扣率", "折合价", "码洋", "总价", "签收人", "出库日期","出库说明" };
  200. neh.Export(dt, liststring, "出库明细信息");
  201. return RedirectToAction("MsgShow", "Common", new
  202. {
  203. msg = "导出成功!",
  204. url = Url.Content("~/InventoryManagement/List").AddMenuParameter()
  205. });
  206. }
  207. /// <summary>
  208. /// 库存明细
  209. /// </summary>
  210. /// <param name="teachingMaterialPoolID"></param>
  211. /// <returns></returns>
  212. [HttpGet]
  213. public ActionResult InventoryDetail(string teachingMaterialPoolID)
  214. {
  215. if (!string.IsNullOrEmpty(teachingMaterialPoolID))
  216. ViewData["teachingMaterialPoolID"] = teachingMaterialPoolID;
  217. return View();
  218. }
  219. [HttpPost]
  220. public ActionResult InventoryDetail(Guid? teachingMaterialPoolID)
  221. {
  222. return base.Json(InventoryServices.GetTeachingMateriaInventoryViewGrid(teachingMaterialPoolID));
  223. }
  224. /// <summary>
  225. /// 入库明细
  226. /// </summary>
  227. /// <param name="teachingMaterialPoolID"></param>
  228. /// <param name="schoolyearID"></param>
  229. /// <returns></returns>
  230. [HttpGet]
  231. public ActionResult StockInDetail(string teachingMaterialPoolID, string schoolyearID, string discountPrice)
  232. {
  233. if (!string.IsNullOrEmpty(teachingMaterialPoolID))
  234. ViewBag.teachingMaterialPoolID = teachingMaterialPoolID;
  235. if (!string.IsNullOrEmpty(schoolyearID))
  236. ViewBag.schoolyearID = schoolyearID;
  237. if (!string.IsNullOrEmpty(discountPrice))
  238. ViewBag.discountPrice = discountPrice;
  239. return View();
  240. }
  241. [HttpPost]
  242. public ActionResult StockInDetail(QueryParamsModel pararms)
  243. {
  244. Guid? teachingMaterialPoolID = Request.Params["teachingMaterialPoolID"].ParseStrTo<Guid>();
  245. Guid? schoolyearID = Request.Params["schoolyearID"].ParseStrTo<Guid>();
  246. decimal? discountPrice = Request.Params["discountPrice"].ParseStrTo<decimal>();
  247. var SchoolYearEntity = SchoolYearServices.GetSchoolYear(schoolyearID);
  248. return base.Json(InventoryServices.GetStockInDetailByValueViewGrid(teachingMaterialPoolID, schoolyearID, discountPrice, (int)pararms.page, (int)pararms.rows));
  249. }
  250. /// <summary>
  251. /// 出库明细
  252. /// </summary>
  253. /// <param name="teachingMaterialPoolID"></param>
  254. /// <param name="schoolyearID"></param>
  255. /// <returns></returns>
  256. [HttpGet]
  257. public ActionResult StockOutDetail(string teachingMaterialPoolID, string schoolyearID, string discountPrice)
  258. {
  259. if (!string.IsNullOrEmpty(teachingMaterialPoolID))
  260. ViewBag.teachingMaterialPoolID = teachingMaterialPoolID;
  261. if (!string.IsNullOrEmpty(schoolyearID))
  262. ViewBag.schoolyearID = schoolyearID;
  263. if (!string.IsNullOrEmpty(discountPrice))
  264. ViewBag.discountPrice = discountPrice;
  265. return View();
  266. }
  267. [HttpPost]
  268. public ActionResult StockOutDetail(QueryParamsModel pararms)
  269. {
  270. Guid? teachingMaterialPoolID = Request.Params["teachingMaterialPoolID"].ParseStrTo<Guid>();
  271. Guid? schoolyearID = Request.Params["schoolyearID"].ParseStrTo<Guid>();
  272. decimal? discountPrice = Request.Params["discountPrice"].ParseStrTo<decimal>();
  273. var SchoolYearEntity = SchoolYearServices.GetSchoolYear(schoolyearID);
  274. return base.Json(InventoryServices.GetStockOutDetailByValueViewGrid(teachingMaterialPoolID, SchoolYearEntity.Value, schoolyearID, discountPrice, (int)pararms.page, (int)pararms.rows));
  275. }
  276. }
  277. }