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.

413 lines
12 KiB

4 days ago
  1. using NFine.Application;
  2. using NFine.Application.ProductManage;
  3. using NFine.Code;
  4. using NFine.Domain.Entity.ProductManage;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.Data;
  8. using System.IO;
  9. using System.Linq;
  10. using System.Web;
  11. using System.Web.Mvc;
  12. namespace NFine.Web.Areas.SRM.Controllers
  13. {
  14. public class POMaintenanceController : ControllerBase
  15. {
  16. private POMaintenanceApp App = new POMaintenanceApp();
  17. [HttpGet]
  18. [HandlerAjaxOnly]
  19. public ActionResult GetGridJson(Pagination pagination, string queryJson)
  20. {
  21. DataTable ListData = App.GetGridJson(queryJson, ref pagination);
  22. var JsonData = new
  23. {
  24. total = pagination.total,
  25. page = pagination.page,
  26. records = pagination.records,
  27. rows = ListData,
  28. };
  29. return Content(JsonData.ToJson());
  30. }
  31. /// <summary>
  32. /// 多交期查询
  33. /// </summary>
  34. /// <param name="pagination"></param>
  35. /// <param name="queryJson"></param>
  36. /// <returns></returns>
  37. [HttpGet]
  38. [HandlerAjaxOnly]
  39. public ActionResult GetGridJsonByMore(Pagination pagination, string queryJson)
  40. {
  41. DataTable ListData = App.GetGridJsonByMore(queryJson, ref pagination);
  42. var JsonData = new
  43. {
  44. total = pagination.total,
  45. page = pagination.page,
  46. records = pagination.records,
  47. rows = ListData,
  48. };
  49. return Content(JsonData.ToJson());
  50. }
  51. [HttpGet]
  52. [HandlerAjaxOnly]
  53. public ActionResult GetGridJsonWeiWai(Pagination pagination, string queryJson)
  54. {
  55. DataTable ListData = App.GetGridJsonWeiWai(queryJson, ref pagination);
  56. var JsonData = new
  57. {
  58. total = pagination.total,
  59. page = pagination.page,
  60. records = pagination.records,
  61. rows = ListData,
  62. };
  63. return Content(JsonData.ToJson());
  64. }
  65. /// <summary>
  66. /// 多交期维护(委外)
  67. /// </summary>
  68. /// <param name="pagination"></param>
  69. /// <param name="queryJson"></param>
  70. /// <returns></returns>
  71. [HttpGet]
  72. [HandlerAjaxOnly]
  73. public ActionResult GetGridJsonWeiWaiByMore(Pagination pagination, string queryJson)
  74. {
  75. DataTable ListData = App.GetGridJsonWeiWaiByMore(queryJson, ref pagination);
  76. var JsonData = new
  77. {
  78. total = pagination.total,
  79. page = pagination.page,
  80. records = pagination.records,
  81. rows = ListData,
  82. };
  83. return Content(JsonData.ToJson());
  84. }
  85. [HttpGet]
  86. [HandlerAjaxOnly]
  87. public ActionResult GetSubGridJson(string queryJson,Pagination pagination,string WorkPoint)
  88. {
  89. DataTable ListData = App.GetSubGridJson(queryJson, ref pagination, WorkPoint);
  90. var JsonData = new
  91. {
  92. total = pagination.total,
  93. page = pagination.page,
  94. records = pagination.records,
  95. rows = ListData,
  96. };
  97. return Content(JsonData.ToJson());
  98. }
  99. [HttpGet]
  100. [HandlerAjaxOnly]
  101. public ActionResult GetSubGridJsonByYL(string queryJson, Pagination pagination, string WorkPoint)
  102. {
  103. DataTable ListData = App.GetSubGridJsonByYL(queryJson, ref pagination, WorkPoint);
  104. var JsonData = new
  105. {
  106. total = pagination.total,
  107. page = pagination.page,
  108. records = pagination.records,
  109. rows = ListData,
  110. };
  111. return Content(JsonData.ToJson());
  112. }
  113. [HttpGet]
  114. [HandlerAjaxOnly]
  115. public ActionResult GetSubGridJsonWeiWai(string queryJson, Pagination pagination, string WorkPoint )
  116. {
  117. DataTable ListData = App.GetSubGridJsonWeiWai(queryJson, ref pagination, WorkPoint);
  118. var JsonData = new
  119. {
  120. total = pagination.total,
  121. page = pagination.page,
  122. records = pagination.records,
  123. rows = ListData,
  124. };
  125. return Content(JsonData.ToJson());
  126. }
  127. public ActionResult Index()
  128. {
  129. return View();
  130. }
  131. public ActionResult BatchForm()
  132. {
  133. return View();
  134. }
  135. public ActionResult IndexByDH()
  136. {
  137. return View();
  138. }
  139. public ActionResult IndexMore()
  140. {
  141. return View();
  142. }
  143. public ActionResult DeleteFileInfo()
  144. {
  145. return View();
  146. }
  147. //[HttpGet]
  148. //[HandlerAjaxOnly]
  149. //public ActionResult GetFormJson(string keyValue)
  150. //{
  151. // //var data = maintainAppApp.GetForm(keyValue);
  152. // //return Content(data.ToJson());
  153. //}
  154. [HttpPost]
  155. [HandlerAjaxOnly]
  156. [ValidateAntiForgeryToken]
  157. public ActionResult SubmitForm(string keyValue)
  158. {
  159. string msg = App.SubmitPoMaintenance(keyValue);
  160. if (!string.IsNullOrEmpty(msg))
  161. {
  162. return Error(msg);
  163. }
  164. else
  165. {
  166. return Success("维护成功!");
  167. }
  168. }
  169. [HttpPost]
  170. [HandlerAjaxOnly]
  171. [ValidateAntiForgeryToken]
  172. public ActionResult MoreSubmitForm(string keyValue)
  173. {
  174. string msg = App.MoreSubmitPoMaintenance(keyValue);
  175. if (!string.IsNullOrEmpty(msg))
  176. {
  177. return Error(msg);
  178. }
  179. else
  180. {
  181. return Success("维护成功!");
  182. }
  183. }
  184. [HttpPost]
  185. [HandlerAjaxOnly]
  186. [ValidateAntiForgeryToken]
  187. public ActionResult SubmitFormByYL(string keyValue)
  188. {
  189. int i = App.SubmitPoMaintenanceByYL(keyValue);
  190. if (i > 0)
  191. {
  192. return Success("维护成功!");
  193. }
  194. else
  195. {
  196. return Error("维护失败!");
  197. }
  198. }
  199. [HttpPost]
  200. [HandlerAjaxOnly]
  201. [ValidateAntiForgeryToken]
  202. public ActionResult SubmitFormByBatch(string POCodeRow,string ArriveDate)
  203. {
  204. int i = App.SubmitFormByBatch( POCodeRow, ArriveDate);
  205. if (i > 0)
  206. {
  207. return Success("维护成功!");
  208. }
  209. else
  210. {
  211. return Error("维护失败!");
  212. }
  213. }
  214. [HttpPost]
  215. [HandlerAjaxOnly]
  216. [ValidateAntiForgeryToken]
  217. public ActionResult SubmitFormWeiWai(string keyValue)
  218. {
  219. string msg = App.SubmitFormWeiWai(keyValue);
  220. if (!string.IsNullOrEmpty(msg))
  221. {
  222. return Error(msg);
  223. }
  224. else
  225. {
  226. return Success("维护成功!");
  227. }
  228. }
  229. [HttpPost]
  230. [HandlerAjaxOnly]
  231. [ValidateAntiForgeryToken]
  232. public ActionResult MoreSubmitFormWeiWai(string keyValue)
  233. {
  234. string msg = App.MoreSubmitFormWeiWai(keyValue);
  235. if (!string.IsNullOrEmpty(msg))
  236. {
  237. return Error(msg);
  238. }
  239. else
  240. {
  241. return Success("维护成功!");
  242. }
  243. }
  244. [HttpPost]
  245. [HandlerAjaxOnly]
  246. [ValidateAntiForgeryToken]
  247. public ActionResult SubmitFormByBatchWeiWai(string POCodeRow, string ArriveDate)
  248. {
  249. int i = App.SubmitFormByBatchWeiWai(POCodeRow, ArriveDate);
  250. if (i > 0)
  251. {
  252. return Success("维护成功!");
  253. }
  254. else
  255. {
  256. return Error("维护失败!");
  257. }
  258. }
  259. /// <summary>
  260. /// 上传质检报告
  261. /// </summary>
  262. /// <param name="pocode">采购订单号</param>
  263. /// <param name="sequence">采购订单行号</param>
  264. /// <returns></returns>
  265. [HttpPost]
  266. public ActionResult UpLoadFileImport(string pocode, string sequence)
  267. {
  268. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  269. string FileName = "";
  270. string PathName = "";
  271. //获取上传的文件集合
  272. try
  273. {
  274. HttpFileCollection httpFile = System.Web.HttpContext.Current.Request.Files;
  275. for (int i = 0; i < httpFile.Count; i++)
  276. {
  277. //获取送货单号
  278. //string STNO = Request.Form["STNO"].ToString();
  279. string fileName = Path.GetFileNameWithoutExtension(httpFile[i].FileName)
  280. + pocode + sequence + Path.GetExtension(httpFile[i].FileName);
  281. string Paths = System.Web.HttpContext.Current.Server.MapPath("~\\File\\CSFile\\" + pocode + "\\");
  282. if (!Directory.Exists(Paths))
  283. {
  284. Directory.CreateDirectory(Paths);
  285. }
  286. string filePath = System.Web.HttpContext.Current.Server.MapPath("~\\File\\CSFile\\" + pocode + "\\" + fileName);
  287. int iLen = httpFile[0].ContentLength;
  288. byte[] bData = new byte[iLen];
  289. httpFile[0].InputStream.Read(bData, 0, iLen);
  290. FileStream fs = new FileStream(filePath, FileMode.OpenOrCreate);
  291. fs.Write(bData, 0, bData.Length);
  292. fs.Flush();
  293. fs.Close();
  294. fs.Dispose();
  295. FileName += "" + fileName + ";";
  296. PathName += "" + filePath + ";";
  297. }
  298. App.UpLoadFile(pocode, sequence, FileName);
  299. return Success("上传成功!");
  300. }
  301. catch (Exception ex)
  302. {
  303. return Error(ex.Message);
  304. }
  305. }
  306. /// <summary>
  307. /// 获取质检报告文件列表
  308. /// </summary>
  309. /// <param name="POCode">采购订单号</param>
  310. /// <param name="Sequence">采购订单行号</param>
  311. /// <param name="Type">类型</param>
  312. /// <param name="pagination">分页</param>
  313. /// <returns></returns>
  314. [HttpGet]
  315. public ActionResult GetFileInfo(string POCode, string Sequence, string Type, Pagination pagination)
  316. {
  317. DataTable ListData = new DataTable();
  318. ListData = App.GetFileInfo(POCode, Sequence, ref pagination);
  319. var JsonData = new
  320. {
  321. total = pagination.total,
  322. page = pagination.page,
  323. records = pagination.records,
  324. rows = ListData,
  325. };
  326. return Content(JsonData.ToJson());
  327. }
  328. /// <summary>
  329. /// 删除质检报告文件
  330. /// </summary>
  331. /// <param name="keyValue"></param>
  332. /// <param name="POCode">采购订单号</param>
  333. /// <param name="Sequence">采购订单行号</param>
  334. /// <param name="Type">类型</param>
  335. /// <returns></returns>
  336. public ActionResult DeleteFileByCode(string keyValue, string POCode, string Sequence, string Type)
  337. {
  338. string msg = string.Empty;
  339. keyValue = keyValue.Substring(1, keyValue.Length - 3);
  340. string path = string.Empty;
  341. path = System.Web.HttpContext.Current.Server.MapPath("~\\File\\CSFile\\" + POCode + "");
  342. msg = App.DeleteFileByCode(keyValue, POCode, Sequence, path);
  343. if (!string.IsNullOrEmpty(msg))
  344. {
  345. return Error(msg);
  346. }
  347. else
  348. {
  349. return Success("删除成功!");
  350. }
  351. }
  352. //[HttpPost]
  353. //[HandlerAjaxOnly]
  354. //[HandlerAuthorize]
  355. //[ValidateAntiForgeryToken]
  356. //public ActionResult DeleteForm(string keyValue)
  357. //{
  358. // maintainAppApp.DeleteForm(keyValue);
  359. // return Success("Delete success.");
  360. //}
  361. }
  362. }