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

202 lines
6.0 KiB

3 weeks ago
  1. using NFine.Application.KBSWMS;
  2. using NFine.Code;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Data;
  6. using System.IO;
  7. using System.Linq;
  8. using System.Web;
  9. using System.Web.Mvc;
  10. namespace NFine.Web.Areas.KBSWMS.Controllers
  11. {
  12. public class ICSManufactureReceiveController : ControllerBase
  13. {
  14. private ICSManufactureReceiveApp App = new ICSManufactureReceiveApp();
  15. public ActionResult Index()
  16. {
  17. return View();
  18. }
  19. public ActionResult BindAdd()
  20. {
  21. return View();
  22. }
  23. /// <summary>
  24. /// 获取产成品入库单数据
  25. /// </summary>
  26. /// <param name="pagination"></param>
  27. /// <param name="queryJson"></param>
  28. /// <returns></returns>
  29. [HttpGet]
  30. [HandlerAjaxOnly]
  31. public ActionResult GetManufactureReceive(Pagination pagination, string queryJson)
  32. {
  33. DataTable ListData = App.GetManufactureReceive(queryJson, ref pagination);
  34. var JsonData = new
  35. {
  36. total = pagination.total,
  37. page = pagination.page,
  38. records = pagination.records,
  39. rows = ListData,
  40. };
  41. return Content(JsonData.ToJson());
  42. }
  43. [HttpGet]
  44. [HandlerAjaxOnly]
  45. public ActionResult GetManufactureReceiveLot(string ProductionCode, string WHCode,string InvCode,Pagination pagination)
  46. {
  47. DataTable ListData = App.GetManufactureReceiveLot(ProductionCode, WHCode, InvCode,ref pagination);
  48. var JsonData = new
  49. {
  50. total = pagination.total,
  51. page = pagination.page,
  52. records = pagination.records,
  53. rows = ListData,
  54. };
  55. return Content(JsonData.ToJson());
  56. }
  57. //入库单绑定条码
  58. [HttpPost]
  59. [HandlerAjaxOnly]
  60. [ValidateAntiForgeryToken]
  61. public ActionResult BindingLot( string ICSASN)
  62. {
  63. string msg = App.BindingLot(ICSASN);
  64. if (msg=="")
  65. {
  66. return Success("绑定成功!");
  67. }
  68. else
  69. {
  70. return Error(msg);
  71. }
  72. }
  73. //入库单解绑定条码
  74. [HttpPost]
  75. [HandlerAjaxOnly]
  76. [ValidateAntiForgeryToken]
  77. public ActionResult PostUnBind(string ids)
  78. {
  79. string msg = App.PostUnBind(ids);
  80. if (msg == "")
  81. {
  82. return Success("解绑成功!");
  83. }
  84. else
  85. {
  86. return Error(msg);
  87. }
  88. }
  89. /// <summary>
  90. /// 产成品入库单提交过账
  91. /// </summary>
  92. /// <param name="RCVCodes"></param>
  93. /// <returns></returns>
  94. [HttpPost]
  95. [HandlerAjaxOnly]
  96. [ValidateAntiForgeryToken]
  97. public ActionResult PostExamine(string RCVCodes)
  98. {
  99. string msg = App.PostExamine(RCVCodes);
  100. if (msg == "")
  101. {
  102. return Success("操作成功!");
  103. }
  104. else
  105. {
  106. return Error(msg);
  107. }
  108. }
  109. /// <summary>
  110. /// 删除子件条码信息
  111. /// </summary>
  112. /// <param name="keyValue"></param>
  113. /// <returns></returns>
  114. [HttpPost]
  115. [HandlerAjaxOnly]
  116. [ValidateAntiForgeryToken]
  117. public ActionResult DeleteItemLot(string MOCodes)
  118. {
  119. MOCodes = MOCodes.Substring(1, MOCodes.Length-2);
  120. string msg = App.DeleteItemLot(MOCodes);
  121. if (string.IsNullOrWhiteSpace(msg))
  122. {
  123. return Success("删除成功!");
  124. }
  125. else
  126. {
  127. return Error(msg);
  128. }
  129. }
  130. [HttpPost]
  131. /// <summary>
  132. /// 条码绑定入库单导入
  133. /// </summary>
  134. public string UploadFileBinding()
  135. {
  136. try
  137. {
  138. HttpFileCollection hpFiles = System.Web.HttpContext.Current.Request.Files;
  139. if (hpFiles != null && hpFiles.Count > 0)
  140. {
  141. string IsXls = System.IO.Path.GetExtension(hpFiles[0].FileName).ToString().ToLower();//System.IO.Path.GetExtension获得文件的扩展名
  142. if (IsXls != ".xls" && IsXls != ".xlsx")
  143. {
  144. return "只可以选择Excel(.xls .xlsx)文件";//当选择的不是Excel文件时,返回
  145. }
  146. string filename = DateTime.Now.ToString("yyyyMMddhhmmss") + Guid.NewGuid() + IsXls; //获取Execle文件名 DateTime日期函数
  147. string savePath = System.Web.HttpContext.Current.Server.MapPath("~\\File\\UPLoadFile\\" + filename);//Server.MapPath 获得虚拟服务器相对路径
  148. int iLen = hpFiles[0].ContentLength;
  149. if (Directory.Exists(savePath)) return "文件已存在";
  150. byte[] bData = new byte[iLen];
  151. hpFiles[0].InputStream.Read(bData, 0, iLen);
  152. FileStream newFile = new FileStream(savePath, FileMode.OpenOrCreate);
  153. newFile.Write(bData, 0, bData.Length);
  154. newFile.Flush();
  155. int _FileSizeTemp = hpFiles[0].ContentLength;
  156. newFile.Close();
  157. newFile.Dispose();
  158. //bool del = false;
  159. string mess = "";
  160. mess = App.UploadFileBinding(savePath);
  161. if (System.IO.File.Exists(savePath))//删除文件
  162. {
  163. System.IO.File.Delete(savePath);
  164. }
  165. return mess;
  166. }
  167. else
  168. {
  169. return "获取文件失败";
  170. }
  171. }
  172. catch (Exception ex)
  173. {
  174. return ex.ToString();
  175. }
  176. }
  177. }
  178. }