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.

248 lines
7.2 KiB

3 weeks ago
  1. using NFine.Application.DHAY;
  2. using NFine.Application.WMS;
  3. using NFine.Code;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Data;
  7. using System.IO;
  8. using System.Linq;
  9. using System.Web;
  10. using System.Web.Mvc;
  11. namespace NFine.Web.Areas.DHAY.Controllers
  12. {
  13. public class ICSMTDOCController : ControllerBase
  14. {
  15. ICSMTDOCDHApp App = new ICSMTDOCDHApp();
  16. // GET: WMS/ICSMTDOC
  17. public ActionResult Metamorphosis()
  18. {
  19. return View();
  20. }
  21. public ActionResult ICSMTDOCAdd()
  22. {
  23. return View();
  24. }
  25. public ActionResult GetICSInventory()
  26. {
  27. return View();
  28. }
  29. public ActionResult GetBatchCode()
  30. {
  31. return View();
  32. }
  33. public ActionResult MetamorphosisToLead()
  34. {
  35. return View();
  36. }
  37. public ActionResult GetLocationCode()
  38. {
  39. return View();
  40. }
  41. [HttpGet]
  42. [HandlerAjaxOnly]
  43. public ActionResult GetGridJson(Pagination pagination, string queryJson)
  44. {
  45. DataTable ListData = App.GetGridJson(queryJson, ref pagination);
  46. var JsonData = new
  47. {
  48. total = pagination.total,
  49. page = pagination.page,
  50. records = pagination.records,
  51. rows = ListData,
  52. };
  53. return Content(JsonData.ToJson());
  54. }
  55. [HttpGet]
  56. [HandlerAjaxOnly]
  57. public ActionResult GetSubGridJson(string MTDOCCode)
  58. {
  59. DataTable ListData = App.GetSubGridJson(MTDOCCode);
  60. var JsonData = new
  61. {
  62. rows = ListData,
  63. };
  64. return Content(JsonData.ToJson());
  65. }
  66. //在库条码
  67. public ActionResult GetRepertory(string LotNo, Pagination pagination)
  68. {
  69. DataTable ListData = App.GetRepertory(LotNo, ref pagination);
  70. var JsonData = new
  71. {
  72. total = pagination.total,
  73. page = pagination.page,
  74. records = pagination.records,
  75. rows = ListData,
  76. };
  77. return Content(JsonData.ToJson());
  78. }
  79. public ActionResult GetInvcode(string Invcode, Pagination pagination)
  80. {
  81. DataTable ListData = App.GetInvcode(Invcode, ref pagination);
  82. var JsonData = new
  83. {
  84. total = pagination.total,
  85. page = pagination.page,
  86. records = pagination.records,
  87. rows = ListData,
  88. };
  89. return Content(JsonData.ToJson());
  90. }
  91. public ActionResult GetGridLocationCode(string LocationCode, Pagination pagination)
  92. {
  93. DataTable ListData = App.GetLocationCode(LocationCode, ref pagination);
  94. var JsonData = new
  95. {
  96. total = pagination.total,
  97. page = pagination.page,
  98. records = pagination.records,
  99. rows = ListData,
  100. };
  101. return Content(JsonData.ToJson());
  102. }
  103. public ActionResult GetCode(string Type, string Common, Pagination pagination)
  104. {
  105. DataTable ListData = App.GetCode(Type, Common, ref pagination);
  106. var JsonData = new
  107. {
  108. total = pagination.total,
  109. page = pagination.page,
  110. records = pagination.records,
  111. rows = ListData,
  112. };
  113. return Content(JsonData.ToJson());
  114. }
  115. /// <summary>
  116. /// 创建形态转换
  117. /// </summary>
  118. /// <param name="keyValue"></param>
  119. /// <returns></returns>
  120. [HttpPost]
  121. [HandlerAjaxOnly]
  122. public ActionResult CreateICSMTDOC(string ICSMTDOC, string InvCode, string LocationCode, string Memo)
  123. {
  124. string msg = App.CreateICSMTDOC(ICSMTDOC, InvCode, LocationCode, Memo);
  125. if (!string.IsNullOrEmpty(msg))
  126. {
  127. return Error(msg);
  128. }
  129. else
  130. {
  131. return Success("添加成功!");
  132. }
  133. }
  134. //审核
  135. public ActionResult ICSMTDOCAudit(string MTDOCCode)
  136. {
  137. string msg = App.ICSMTDOCAudit(MTDOCCode);
  138. if (string.IsNullOrEmpty(msg))
  139. {
  140. return Success("操作成功!");
  141. }
  142. else
  143. {
  144. return Error("" + msg + "");
  145. }
  146. }
  147. [HttpPost]
  148. /// <summary>
  149. /// 文件上传到本地
  150. /// </summary>
  151. public string UploadFile()
  152. {
  153. try
  154. {
  155. string str_Year = Request.Form["txt_Year"];
  156. String UPLoadType = Request.Form["UPLoadType"];
  157. HttpFileCollection hpFiles = System.Web.HttpContext.Current.Request.Files;
  158. if (hpFiles != null && hpFiles.Count > 0)
  159. {
  160. string IsXls = System.IO.Path.GetExtension(hpFiles[0].FileName).ToString().ToLower();//System.IO.Path.GetExtension获得文件的扩展名
  161. if (IsXls != ".xls" && IsXls != ".xlsx")
  162. {
  163. return "只可以选择Excel(.xls .xlsx)文件";//当选择的不是Excel文件时,返回
  164. }
  165. string filename = DateTime.Now.ToString("yyyyMMddhhmmss") + UPLoadType + IsXls; //获取Execle文件名 DateTime日期函数
  166. string savePath = System.Web.HttpContext.Current.Server.MapPath("~\\File\\UPLoadFile\\" + filename);//Server.MapPath 获得虚拟服务器相对路径
  167. int iLen = hpFiles[0].ContentLength;
  168. if (Directory.Exists(savePath)) return "文件已存在";
  169. byte[] bData = new byte[iLen];
  170. hpFiles[0].InputStream.Read(bData, 0, iLen);
  171. FileStream newFile = new FileStream(savePath, FileMode.OpenOrCreate);
  172. newFile.Write(bData, 0, bData.Length);
  173. newFile.Flush();
  174. int _FileSizeTemp = hpFiles[0].ContentLength;
  175. newFile.Close();
  176. newFile.Dispose();
  177. //bool del = false;
  178. string mess = "";
  179. mess = App.ToLead(savePath, str_Year);
  180. if (System.IO.File.Exists(savePath))//删除文件
  181. {
  182. System.IO.File.Delete(savePath);
  183. }
  184. return mess;
  185. }
  186. else
  187. {
  188. return "获取文件失败";
  189. }
  190. }
  191. catch (Exception ex)
  192. {
  193. return ex.ToString();
  194. }
  195. }
  196. [HttpPost]
  197. [HandlerAjaxOnly]
  198. [ValidateAntiForgeryToken]
  199. public ActionResult DeleteICSMTDOC(string keyValue)
  200. {
  201. string msg = App.DeleteICSMTDOC(keyValue);
  202. if (string.IsNullOrEmpty(msg))
  203. {
  204. return Success("删除成功!");
  205. }
  206. else
  207. {
  208. return Error(msg);
  209. }
  210. }
  211. }
  212. }