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.

568 lines
19 KiB

4 days ago
  1. using NFine.Application.SRM;
  2. using NFine.Code;
  3. using NFine.Domain._03_Entity.SRM;
  4. using System;
  5. using System.Data;
  6. using System.IO;
  7. using System.Web;
  8. using System.Web.Mvc;
  9. namespace NFine.Web.Areas.SRM.Controllers
  10. {
  11. public class BicDoc_PublishController : ControllerBase
  12. {
  13. private BicDoc_PublishApp App = new BicDoc_PublishApp();
  14. [HttpGet]
  15. [HandlerAjaxOnly]
  16. public ActionResult GetGridJson(Pagination pagination, string queryJson)
  17. {
  18. DataTable ListData = App.GetGridJson(queryJson, ref pagination);
  19. var JsonData = new
  20. {
  21. total = pagination.total,
  22. page = pagination.page,
  23. records = pagination.records,
  24. rows = ListData,
  25. };
  26. return Content(JsonData.ToJson());
  27. }
  28. public ActionResult ICSBicDoc_PubLish()
  29. {
  30. return View();
  31. }
  32. public ActionResult ICSBicDocAdd_PubLish()
  33. {
  34. return View();
  35. }
  36. public ActionResult ICSBicDocDetail_PubLish()
  37. {
  38. return View();
  39. }
  40. public ActionResult ICSBicDoc_Item()
  41. {
  42. return View();
  43. }
  44. public ActionResult ICSBicDoc_Supplier()
  45. {
  46. return View();
  47. }
  48. public ActionResult ICSBicDocByPU()
  49. {
  50. return View();
  51. }
  52. public ActionResult ICSBicDoc_AddFCS()
  53. {
  54. return View();
  55. }
  56. [HttpGet]
  57. [HandlerAjaxOnly]
  58. public ActionResult GetBidUser(string WorkPoint)
  59. {
  60. DataTable dt = App.GetBidUser(WorkPoint);
  61. return Content(dt.ToJson());
  62. }
  63. [HttpGet]
  64. [HandlerAjaxOnly]
  65. public ActionResult GetBidDocBDInfoByCode(string queryJson, Pagination pagination)
  66. {
  67. DataTable ListData = App.GetBidDocBDInfoByCode(queryJson, ref pagination);
  68. var JsonData = new
  69. {
  70. total = pagination.total,
  71. page = pagination.page,
  72. records = pagination.records,
  73. rows = ListData,
  74. };
  75. return Content(JsonData.ToJson());
  76. }
  77. [HttpGet]
  78. [HandlerAjaxOnly]
  79. public ActionResult GetBidDocBDInfoByBidCode(string queryJson, Pagination pagination, string WorkPoint)
  80. {
  81. DataTable ListData = App.GetBidDocBDInfoByBidCode(queryJson, ref pagination, WorkPoint);
  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. [HttpGet]
  92. [HandlerAjaxOnly]
  93. public ActionResult GetBidDocGYSInfoByCode(string queryJson, Pagination pagination, string WorkPoint)
  94. {
  95. DataTable ListData = App.GetBidDocGYSInfoByCode(queryJson, ref pagination, WorkPoint);
  96. var JsonData = new
  97. {
  98. total = pagination.total,
  99. page = pagination.page,
  100. records = pagination.records,
  101. rows = ListData,
  102. };
  103. return Content(JsonData.ToJson());
  104. }
  105. [HttpGet]
  106. [HandlerAjaxOnly]
  107. public ActionResult GetItemList(Pagination pagination, string queryJson, string WorkPoint)
  108. {
  109. WorkPoint = WorkPoint.Substring(1, WorkPoint.Length - 2);
  110. DataTable ListData = App.GetItemList(queryJson, ref pagination, WorkPoint);
  111. var JsonData = new
  112. {
  113. total = pagination.total,
  114. page = pagination.page,
  115. records = pagination.records,
  116. rows = ListData,
  117. };
  118. return Content(JsonData.ToJson());
  119. }
  120. [HttpGet]
  121. [HandlerAjaxOnly]
  122. public ActionResult GetVendorList(Pagination pagination, string queryJson, string WorkPoint)
  123. {
  124. DataTable ListData = App.GetVendorList(queryJson, ref pagination, WorkPoint);
  125. var JsonData = new
  126. {
  127. total = pagination.total,
  128. page = pagination.page,
  129. records = pagination.records,
  130. rows = ListData,
  131. };
  132. return Content(JsonData.ToJson());
  133. }
  134. [HttpPost]
  135. public ActionResult SubmitForm(ICSBicDoc details)
  136. {
  137. try
  138. {
  139. App.SaveDetail(details);
  140. return Success("招标书方案保存成功!");
  141. }
  142. catch (Exception ex)
  143. {
  144. return Error(ex.Message);
  145. }
  146. }
  147. [HttpGet]
  148. public ActionResult GetFormDetail(string ID, string WorkPoint)
  149. {
  150. try
  151. {
  152. DataRow dr = App.GetFormDetail(ID, WorkPoint);
  153. var JsonData = new
  154. {
  155. ID = dr["ID"].ToString(),
  156. BidCode = dr["BidCode"].ToString(),
  157. BidName = dr["BidName"].ToString(),
  158. BidUser = dr["BidUser"].ToString(),
  159. StarTime = dr["StarTime"].ToString(),
  160. EndTime = dr["EndTime"].ToString(),
  161. BidStatus = dr["BidStatus"].ToString(),
  162. Remark = dr["Remark"].ToString(),
  163. WorkPoint = dr["WorkPoint"].ToString(),
  164. ZTBCount = dr["ZTBCount"].ToString(),
  165. FileName = dr["FileName"].ToString(),
  166. };
  167. return Content(JsonData.ToJson());
  168. }
  169. catch (Exception ex)
  170. {
  171. return Error(ex.Message);
  172. }
  173. }
  174. [HttpPost]
  175. [HandlerAjaxOnly]
  176. [ValidateAntiForgeryToken]
  177. public ActionResult UpDateByDocNo(string ID, string BidCode, string WorkPoint)
  178. {
  179. WorkPoint = WorkPoint.Substring(1, WorkPoint.Length - 2);
  180. int result = App.UpDateByDocNo(ID, BidCode, WorkPoint);
  181. if (result > 0)
  182. {
  183. return Success("操作成功!");
  184. }
  185. else
  186. {
  187. return Error("操作失败!");
  188. }
  189. }
  190. [HttpPost]
  191. [HandlerAjaxOnly]
  192. [ValidateAntiForgeryToken]
  193. public ActionResult DeleteBidDoc(string keyValue, string WorkPoint)
  194. {
  195. WorkPoint = WorkPoint.Substring(1, WorkPoint.Length - 2);
  196. string msg = App.DeleteBidDoc(keyValue, WorkPoint);
  197. if (string.IsNullOrWhiteSpace(msg))
  198. {
  199. return Success("删除成功!");
  200. }
  201. else
  202. {
  203. return Error("删除失败");
  204. }
  205. }
  206. [HttpPost]
  207. [HandlerAjaxOnly]
  208. [ValidateAntiForgeryToken]
  209. public ActionResult CloseBidding(string ID, string BidCode, string WorkPoint)
  210. {
  211. WorkPoint = WorkPoint.Substring(1, WorkPoint.Length - 2);
  212. int result = App.CloseBidding(ID, BidCode, WorkPoint);
  213. if (result > 0)
  214. {
  215. return Success("操作成功!");
  216. }
  217. else
  218. {
  219. return Error("操作失败!");
  220. }
  221. }
  222. [HttpPost]
  223. [HandlerAjaxOnly]
  224. [ValidateAntiForgeryToken]
  225. public ActionResult DeleteSup(string keyValue, string WorkPoint)
  226. {
  227. string msg = App.DeleteSup(keyValue, WorkPoint);
  228. if (string.IsNullOrEmpty(msg))
  229. {
  230. return Success("删除成功!");
  231. }
  232. else
  233. {
  234. return Error(msg);
  235. }
  236. }
  237. [HttpPost]
  238. [HandlerAjaxOnly]
  239. [ValidateAntiForgeryToken]
  240. public ActionResult DeleteBD(string keyValue, string WorkPoint)
  241. {
  242. string msg = App.DeleteBD(keyValue, WorkPoint);
  243. if (string.IsNullOrEmpty(msg))
  244. {
  245. return Success("删除成功!");
  246. }
  247. else
  248. {
  249. return Error(msg);
  250. }
  251. }
  252. [HttpPost]
  253. public ActionResult UpLoadFileImport(string BidCode, string ID)
  254. {
  255. string FileName = "";
  256. string PathName = "";
  257. //获取上传的文件集合
  258. HttpFileCollection httpFile = System.Web.HttpContext.Current.Request.Files;
  259. for (int i = 0; i < httpFile.Count; i++)
  260. {
  261. //获取送货单号
  262. //string STNO = Request.Form["STNO"].ToString();
  263. string fileName = Path.GetFileNameWithoutExtension(httpFile[i].FileName)
  264. + Path.GetExtension(httpFile[i].FileName);
  265. string Paths = System.Web.HttpContext.Current.Server.MapPath("~\\File\\ZTBFile\\" + BidCode);
  266. if (!Directory.Exists(Paths))
  267. {
  268. Directory.CreateDirectory(Paths);
  269. }
  270. string filePath = System.Web.HttpContext.Current.Server.MapPath("~\\File\\ZTBFile\\" + BidCode + "\\" + fileName);
  271. int iLen = httpFile[0].ContentLength;
  272. byte[] bData = new byte[iLen];
  273. httpFile[0].InputStream.Read(bData, 0, iLen);
  274. FileStream fs = new FileStream(filePath, FileMode.OpenOrCreate);
  275. fs.Write(bData, 0, bData.Length);
  276. fs.Flush();
  277. fs.Close();
  278. fs.Dispose();
  279. FileName += "" + fileName + ";";
  280. PathName += "" + filePath + ";";
  281. }
  282. int count = App.UpLoadFile(FileName, PathName, BidCode, ID);
  283. if (count > 0)
  284. {
  285. return Success("上传成功!");
  286. }
  287. else
  288. {
  289. return Error("上传失败");
  290. }
  291. }
  292. /// <summary>
  293. /// Post 请求发送文件
  294. /// </summary>
  295. /// <param name="url"></param>
  296. /// <param name="fileName"></param>
  297. /// <returns></returns>
  298. //public static string PostFile(string url, string fileName)
  299. //{
  300. // //验证文件是否存在
  301. // if (File.Exists(fileName) == false)
  302. // throw new Exception("发送文件不存在!");
  303. // FileInfo file = new FileInfo(fileName);
  304. // string boundary = "qianle";//分隔符
  305. // HttpWebRequest req = WebRequest.Create(url) as HttpWebRequest;
  306. // //构造请求体
  307. // byte[] itemBoundaryBytes = Encoding.UTF8.GetBytes("\r\n--" + boundary + "\r\n");
  308. // byte[] byteEnd = Encoding.UTF8.GetBytes("\r\n--" + boundary + "--\r\n"); //结束标识 --xxxx--
  309. // StringBuilder strContent = new StringBuilder();
  310. // strContent
  311. // .Append("Content-Disposition:form-data;name=\"filename\";filename=\"" + file.Name + "\"")
  312. // .AppendLine()
  313. // .Append("Content-Type:application/octet-stream")
  314. // .AppendLine()
  315. // .AppendLine(); //特别说明,Content-Disposition 前边不能添加换行符号
  316. // byte[] byteContent = Encoding.UTF8.GetBytes(strContent.ToString());
  317. // byte[] byteFile = File.ReadAllBytes(fileName);
  318. // //执行发送
  319. // req.Method = "POST";
  320. // req.ContentType = $"multipart/form-data;charset=utf-8;boundary={boundary}";
  321. // req.UserAgent = UserAgent;
  322. // req.ContinueTimeout = 20000;
  323. // var reqStrem = req.GetRequestStream();
  324. // reqStrem.Write(itemBoundaryBytes, 0, itemBoundaryBytes.Length); //文件开始
  325. // reqStrem.Write(byteContent, 0, byteContent.Length);//文件信息
  326. // reqStrem.Write(byteFile, 0, byteFile.Length);//文件内容
  327. // reqStrem.Write(byteEnd, 0, byteEnd.Length); //文件结束
  328. // reqStrem.Close();
  329. // WebResponse resp = req.GetResponse();
  330. // StreamReader sr = new StreamReader(resp.GetResponseStream());
  331. // string result = sr.ReadToEnd();
  332. // sr.Close();
  333. // resp.Close();
  334. // return result;
  335. //}
  336. [HttpPost]
  337. /// <summary>
  338. /// 文件上传到本地
  339. /// </summary>
  340. public ActionResult UploadFile(string ID, string BidCode, string WorkPoint)
  341. {
  342. string mess = "";
  343. try
  344. {
  345. HttpFileCollection hpFiles = System.Web.HttpContext.Current.Request.Files;
  346. if (hpFiles != null && hpFiles.Count > 0)
  347. {
  348. string IsXls = System.IO.Path.GetExtension(hpFiles[0].FileName).ToString().ToLower();//System.IO.Path.GetExtension获得文件的扩展名
  349. if (IsXls != ".xls" && IsXls != ".xlsx")
  350. {
  351. mess = "只可以选择Excel(.xls .xlsx)文件";//当选择的不是Excel文件时,返回
  352. }
  353. string filename = DateTime.Now.ToString("yyyyMMddhhmmss") + Guid.NewGuid() + IsXls; //获取Execle文件名 DateTime日期函数
  354. string savePath = System.Web.HttpContext.Current.Server.MapPath("~\\File\\UPLoadFile\\" + filename);//Server.MapPath 获得虚拟服务器相对路径
  355. int iLen = hpFiles[0].ContentLength;
  356. if (Directory.Exists(savePath)) mess = "文件已存在";
  357. byte[] bData = new byte[iLen];
  358. hpFiles[0].InputStream.Read(bData, 0, iLen);
  359. FileStream newFile = new FileStream(savePath, FileMode.OpenOrCreate);
  360. newFile.Write(bData, 0, bData.Length);
  361. newFile.Flush();
  362. int _FileSizeTemp = hpFiles[0].ContentLength;
  363. newFile.Close();
  364. newFile.Dispose();
  365. //bool del = false;
  366. mess = App.SetData_PR(savePath, ID, BidCode, WorkPoint);
  367. if (System.IO.File.Exists(savePath))//删除文件
  368. {
  369. System.IO.File.Delete(savePath);
  370. }
  371. }
  372. else
  373. {
  374. mess = "获取文件失败";
  375. }
  376. }
  377. catch (Exception ex)
  378. {
  379. mess = ex.Message;
  380. }
  381. var JsonData = new
  382. {
  383. mass = mess,
  384. };
  385. return Content(JsonData.ToJson());
  386. }
  387. [HttpGet]
  388. [HandlerAjaxOnly]
  389. public ActionResult InsertID(string ID,string WorkPoints)
  390. {
  391. string GUID = App.InsertID(ID, WorkPoints);
  392. var JsonData = new
  393. {
  394. GUID = GUID,
  395. };
  396. return Content(JsonData.ToJson());
  397. }
  398. public ActionResult GetSubGridJsonBid(string STNO, Pagination pagination, string WorkPoint)
  399. {
  400. DataTable ListData = App.GetSubGridJsonBid(STNO, ref pagination, WorkPoint);
  401. var JsonData = new
  402. {
  403. total = pagination.total,
  404. page = pagination.page,
  405. records = pagination.records,
  406. rows = ListData,
  407. };
  408. return Content(JsonData.ToJson());
  409. }
  410. /// <summary>
  411. /// 请购单信息
  412. /// </summary>
  413. /// <param name="STNO"></param>
  414. /// <param name="pagination"></param>
  415. /// <param name="WorkPoint"></param>GetBicDocByPU
  416. /// <returns></returns>
  417. public ActionResult GetBicDocByPU(string queryJson, Pagination pagination, string WorkPoint)
  418. {
  419. WorkPoint = WorkPoint.Substring(1, WorkPoint.Length - 2);
  420. DataTable ListData = App.GetBicDocByPU(queryJson, ref pagination, WorkPoint);
  421. var JsonData = new
  422. {
  423. total = pagination.total,
  424. page = pagination.page,
  425. records = pagination.records,
  426. rows = ListData,
  427. };
  428. return Content(JsonData.ToJson());
  429. }
  430. /// <summary>
  431. /// 采购人员加载站点
  432. /// </summary>
  433. /// <returns></returns>
  434. [HttpGet]
  435. public ActionResult GetWorkPointByUser()
  436. {
  437. try
  438. {
  439. DataTable ListData = App.GetWorkPointByUser();
  440. var JsonData = new
  441. {
  442. rows = ListData,
  443. };
  444. return Content(JsonData.ToJson());
  445. }
  446. catch (Exception ex)
  447. {
  448. return Error(ex.Message);
  449. }
  450. }
  451. [HttpGet]
  452. [HandlerAjaxOnly]
  453. public ActionResult GetBidCode(string WorkPoint, string Vendor)
  454. {
  455. try
  456. {
  457. string BidCode = App.GetBidCode(WorkPoint, Vendor);
  458. var JsonData = new
  459. {
  460. BidCode = BidCode,
  461. };
  462. return Content(JsonData.ToJson());
  463. }
  464. catch (Exception ex)
  465. {
  466. return Error(ex.Message);
  467. }
  468. }
  469. [HttpGet]
  470. [HandlerAjaxOnly]
  471. public ActionResult GetBidItemCode(string WorkPoint, string Vendor)
  472. {
  473. try
  474. {
  475. string BidItemCode = App.GetBidItemCode(WorkPoint, Vendor);
  476. var JsonData = new
  477. {
  478. BidItemCode = BidItemCode,
  479. };
  480. return Content(JsonData.ToJson());
  481. }
  482. catch (Exception ex)
  483. {
  484. return Error(ex.Message);
  485. }
  486. }
  487. //public ActionResult SubmitICSBicDocAddFCS(string keyValue)
  488. //{
  489. // try
  490. // {
  491. // string msg = App.SubmitFormCFType(keyValue);
  492. // var JsonData = new
  493. // {
  494. // msg = msg,
  495. // };
  496. // return Content(JsonData.ToJson());
  497. // }
  498. // catch (Exception ex)
  499. // {
  500. // return Error(ex.Message);
  501. // }
  502. //}
  503. /// <summary>
  504. /// 调用OA接口
  505. /// </summary>
  506. /// <param name="TEMPVENDORCODE">公司名称</param>
  507. /// <returns></returns>
  508. [HttpPost]
  509. public ActionResult SubmitOARejict(string BidCode, string WorkPoint)
  510. {
  511. try
  512. {
  513. string msg= App.SubmitOARejict(BidCode, WorkPoint);
  514. var JsonData = new
  515. {
  516. msg = msg,
  517. };
  518. return Content(JsonData.ToJson());
  519. }
  520. catch (Exception ex)
  521. {
  522. return Error("推送失败"+ex.Message);
  523. }
  524. }
  525. }
  526. }