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.

262 lines
7.4 KiB

3 weeks ago
  1. using NFine.Application.BBWMS;
  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.BBWMS.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. public ActionResult SeachLotUpdate()
  24. {
  25. return View();
  26. }
  27. public ActionResult ComparisonLot() {
  28. return View();
  29. }
  30. /// <summary>
  31. /// 获取检验单数据
  32. /// </summary>
  33. /// <param name="pagination"></param>
  34. /// <param name="queryJson"></param>
  35. /// <returns></returns>
  36. [HttpGet]
  37. [HandlerAjaxOnly]
  38. public ActionResult GetManufactureReceive(Pagination pagination, string queryJson)
  39. {
  40. DataTable ListData = App.GetManufactureReceive(queryJson, ref pagination);
  41. var JsonData = new
  42. {
  43. total = pagination.total,
  44. page = pagination.page,
  45. records = pagination.records,
  46. rows = ListData,
  47. };
  48. return Content(JsonData.ToJson());
  49. }
  50. [HttpGet]
  51. [HandlerAjaxOnly]
  52. public ActionResult GetManufactureReceiveLot(string ProductionCode, string WHCode,string InvCode,Pagination pagination)
  53. {
  54. DataTable ListData = App.GetManufactureReceiveLot(ProductionCode, WHCode, InvCode,ref pagination);
  55. var JsonData = new
  56. {
  57. total = pagination.total,
  58. page = pagination.page,
  59. records = pagination.records,
  60. rows = ListData,
  61. };
  62. return Content(JsonData.ToJson());
  63. }
  64. //
  65. /// <summary>
  66. /// 获取扫描条码信息
  67. /// </summary>
  68. /// <param name="LotNo"></param>
  69. /// <returns></returns>
  70. [HttpGet]
  71. [HandlerAjaxOnly]
  72. public ActionResult GetLotGridJson(string LotNO)
  73. {
  74. string ListData = App.GetLotGridJson(LotNO).ToJson();
  75. return Content(ListData);
  76. }
  77. //入库单绑定条码
  78. [HttpPost]
  79. [HandlerAjaxOnly]
  80. [ValidateAntiForgeryToken]
  81. public ActionResult CreateCheckNO( string Lots)
  82. {
  83. string msg = App.CreateCheckNO(Lots);
  84. if (msg=="")
  85. {
  86. return Success("绑定成功!");
  87. }
  88. else
  89. {
  90. return Error(msg);
  91. }
  92. }
  93. /// <summary>
  94. /// 删除送检单信息
  95. /// </summary>
  96. /// <param name="keyValue"></param>
  97. /// <returns></returns>
  98. [HttpPost]
  99. [HandlerAjaxOnly]
  100. [ValidateAntiForgeryToken]
  101. public ActionResult DeleteItemLot(string CheckNos)
  102. {
  103. CheckNos = CheckNos.Substring(1, CheckNos.Length-2);
  104. string msg = App.DeleteItemLot(CheckNos);
  105. if (string.IsNullOrWhiteSpace(msg))
  106. {
  107. return Success("删除成功!");
  108. }
  109. else
  110. {
  111. return Error(msg);
  112. }
  113. }
  114. [HttpGet]
  115. [HandlerAjaxOnly]
  116. public ActionResult GetSubGridJson(string CheckNo, Pagination pagination)
  117. {
  118. DataTable ListData = App.GetSubGridJson(CheckNo, ref pagination);
  119. var JsonData = new
  120. {
  121. total = pagination.total,
  122. page = pagination.page,
  123. records = pagination.records,
  124. rows = ListData,
  125. };
  126. return Content(JsonData.ToJson());
  127. }
  128. [HttpPost]
  129. /// <summary>
  130. /// 条码绑定入库单导入
  131. /// </summary>
  132. public string UploadFileBinding()
  133. {
  134. try
  135. {
  136. HttpFileCollection hpFiles = System.Web.HttpContext.Current.Request.Files;
  137. if (hpFiles != null && hpFiles.Count > 0)
  138. {
  139. string IsXls = System.IO.Path.GetExtension(hpFiles[0].FileName).ToString().ToLower();//System.IO.Path.GetExtension获得文件的扩展名
  140. if (IsXls != ".xls" && IsXls != ".xlsx")
  141. {
  142. return "只可以选择Excel(.xls .xlsx)文件";//当选择的不是Excel文件时,返回
  143. }
  144. string filename = DateTime.Now.ToString("yyyyMMddhhmmss") + Guid.NewGuid() + IsXls; //获取Execle文件名 DateTime日期函数
  145. string savePath = System.Web.HttpContext.Current.Server.MapPath("~\\File\\UPLoadFile\\" + filename);//Server.MapPath 获得虚拟服务器相对路径
  146. int iLen = hpFiles[0].ContentLength;
  147. if (Directory.Exists(savePath)) return "文件已存在";
  148. byte[] bData = new byte[iLen];
  149. hpFiles[0].InputStream.Read(bData, 0, iLen);
  150. FileStream newFile = new FileStream(savePath, FileMode.OpenOrCreate);
  151. newFile.Write(bData, 0, bData.Length);
  152. newFile.Flush();
  153. int _FileSizeTemp = hpFiles[0].ContentLength;
  154. newFile.Close();
  155. newFile.Dispose();
  156. //bool del = false;
  157. string mess = "";
  158. mess = App.UploadFileBinding(savePath);
  159. if (System.IO.File.Exists(savePath))//删除文件
  160. {
  161. System.IO.File.Delete(savePath);
  162. }
  163. return mess;
  164. }
  165. else
  166. {
  167. return "获取文件失败";
  168. }
  169. }
  170. catch (Exception ex)
  171. {
  172. return ex.ToString();
  173. }
  174. }
  175. [HttpGet]
  176. public ActionResult GetINV(string invcode, string Code, string Invstd, string EATTRIBUTE2, string TimeFrom, string TimeArrive,string isSeachStatus, Pagination pagination)
  177. {
  178. DataTable ListData = App.GetINV(invcode, Code, Invstd, EATTRIBUTE2, TimeFrom, TimeArrive, isSeachStatus, ref pagination);
  179. var JsonData = new
  180. {
  181. total = pagination.total,
  182. page = pagination.page,
  183. records = pagination.records,
  184. rows = ListData,
  185. };
  186. return Content(JsonData.ToJson());
  187. }
  188. [HttpPost]
  189. [HandlerAjaxOnly]
  190. [ValidateAntiForgeryToken]
  191. public ActionResult UpdateLotSeachStatus(string keyValue,string Type)
  192. {
  193. string msg = App.UpdateLotSeachStatus(keyValue, Type);
  194. if (string.IsNullOrEmpty(msg))
  195. {
  196. return Success("检索成功!");
  197. }
  198. else
  199. {
  200. return Error(msg);
  201. }
  202. }
  203. [HttpPost]
  204. public void StatementExportAll( string CheckNo)
  205. {
  206. //ID = ID.Substring(0, ID.Length - 2);
  207. DataTable dt = App.StatementExportAll(CheckNo);
  208. AsposeCell.Export(dt);
  209. }
  210. }
  211. }