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.

711 lines
21 KiB

4 days ago
  1. using log4net.Repository.Hierarchy;
  2. using NFine.Application.SRM;
  3. using NFine.Code;
  4. using NFine.Domain._03_Entity.SRM;
  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 PriceInquiryController : ControllerBase
  15. {
  16. PriceInquiryApp APP = new PriceInquiryApp();
  17. // GET: SRM/PriceInquiry
  18. public ActionResult Index()
  19. {
  20. return View();
  21. }
  22. /// <summary>
  23. /// 条件非标物料
  24. /// </summary>
  25. /// <returns></returns>
  26. public ActionResult NoProductionMaterialAdd()
  27. {
  28. return View();
  29. }
  30. /// <summary>
  31. /// 新增询价单
  32. /// </summary>
  33. /// <returns></returns>
  34. public ActionResult PriceInquiryAdd()
  35. {
  36. return View();
  37. }
  38. /// <summary>
  39. /// 分配采购
  40. /// </summary>
  41. /// <returns></returns>
  42. public ActionResult PurchaserAllocation()
  43. {
  44. return View();
  45. }
  46. /// <summary>
  47. /// 供应商分配
  48. /// </summary>
  49. /// <returns></returns>
  50. public ActionResult VendorPersAllocation()
  51. {
  52. return View();
  53. }
  54. /// <summary>
  55. /// 报价管理
  56. /// </summary>
  57. /// <returns></returns>
  58. public ActionResult QuotedPriceIndex()
  59. {
  60. return View();
  61. }
  62. /// <summary>
  63. /// 报价明细
  64. /// </summary>
  65. /// <returns></returns>
  66. public ActionResult QuotedPriceDetail()
  67. {
  68. return View();
  69. }
  70. /// <summary>
  71. /// 审核报价
  72. /// </summary>
  73. /// <returns></returns>
  74. public ActionResult ReviewPrice()
  75. {
  76. return View();
  77. }
  78. /// <summary>
  79. /// 生效报价
  80. /// </summary>
  81. /// <returns></returns>
  82. public ActionResult CompPrice()
  83. {
  84. return View();
  85. }
  86. /// <summary>
  87. /// 报价过程查询
  88. /// </summary>
  89. /// <returns></returns>
  90. public ActionResult ComPricelistByPN()
  91. {
  92. return View();
  93. }
  94. /// <summary>
  95. /// 技术需求单发起
  96. /// </summary>
  97. /// <returns></returns>
  98. public ActionResult TechnicalRequirementsForm()
  99. {
  100. return View();
  101. }
  102. /// <summary>
  103. /// 技术需求单(新增界面)
  104. /// </summary>
  105. /// <returns></returns>
  106. public ActionResult TechnicalRequirementsFormAdd()
  107. {
  108. return View();
  109. }
  110. /// <summary>
  111. /// 需求单详情页
  112. /// </summary>
  113. /// <returns></returns>
  114. public ActionResult TechnicalRequirementsFormLook()
  115. {
  116. return View();
  117. }
  118. /// <summary>
  119. /// 选择需求物料
  120. /// </summary>
  121. /// <returns></returns>
  122. public ActionResult VendorPersAddItem()
  123. {
  124. return View();
  125. }
  126. /// <summary>
  127. /// 获取列表
  128. /// </summary>
  129. /// <param name="rfqno"></param>
  130. /// <param name="pagination"></param>
  131. /// <returns></returns>
  132. [HttpGet]
  133. public ActionResult GetInvTabByPN(string rfqno, Pagination pagination)
  134. {
  135. DataTable table = APP.GetInvTabByPN(rfqno);
  136. var JsonData = new
  137. {
  138. total = pagination.total,
  139. page = pagination.page,
  140. records = pagination.records,
  141. rows = table
  142. };
  143. return Content(JsonData.ToJson());
  144. }
  145. //初次加载页面数据
  146. [HttpGet]
  147. [HandlerAjaxOnly]
  148. public ActionResult GetGridJsonByPN(Pagination pagination, string queryJson)
  149. {
  150. DataTable ListData = APP.GetGridJsonByPN(queryJson, ref pagination);
  151. var JsonData = new
  152. {
  153. total = pagination.total,
  154. page = pagination.page,
  155. records = pagination.records,
  156. rows = ListData,
  157. };
  158. return Content(JsonData.ToJson());
  159. }
  160. /// <summary>
  161. /// 根据当前登录的采购获取物料行
  162. /// </summary>
  163. /// <param name="rfqno"></param>
  164. /// <param name="pagination"></param>
  165. /// <returns></returns>
  166. [HttpGet]
  167. public ActionResult GetInvTabByPNForVendor(string rfqno, Pagination pagination)
  168. {
  169. DataTable table = APP.GetInvTabByPNForVendor(rfqno);
  170. var JsonData = new
  171. {
  172. total = pagination.total,
  173. page = pagination.page,
  174. records = pagination.records,
  175. rows = table
  176. };
  177. return Content(JsonData.ToJson());
  178. }
  179. /// <summary>
  180. /// 新增询价单
  181. /// </summary>
  182. /// <param name="details"></param>
  183. /// <returns></returns>
  184. [HttpPost]
  185. public ActionResult AddRFQByPN(ICSSORRFQ details)
  186. {
  187. try
  188. {
  189. APP.AddRFQByPN(details);
  190. return Success("询报价创建成功!");
  191. }
  192. catch (Exception ex)
  193. {
  194. return Error(ex.Message);
  195. }
  196. }
  197. /// <summary>
  198. /// 分配采购人员
  199. /// </summary>
  200. /// <param name="details"></param>
  201. /// <returns></returns>
  202. [HttpPost]
  203. public ActionResult AddRFQByPNPurchasing(ICSSORRFQ details)
  204. {
  205. try
  206. {
  207. APP.AddRFQByPNPurchasing(details);
  208. return Success("询报价创建成功!");
  209. }
  210. catch (Exception ex)
  211. {
  212. return Error(ex.Message);
  213. }
  214. }
  215. /// <summary>
  216. /// 分配供应商
  217. /// </summary>
  218. /// <param name="details"></param>
  219. /// <returns></returns>
  220. [HttpPost]
  221. public ActionResult AddRFQByPNVendorsing(ICSSORRFQ details)
  222. {
  223. try
  224. {
  225. APP.AddRFQByPNVendorsing(details);
  226. return Success("询报价创建成功!");
  227. }
  228. catch (Exception ex)
  229. {
  230. return Error(ex.Message);
  231. }
  232. }
  233. /// <summary>
  234. /// 获取采购人员
  235. /// </summary>
  236. /// <param name="rfqno"></param>
  237. /// <param name="workpoint"></param>
  238. /// <returns></returns>
  239. [HttpGet]
  240. [HandlerAjaxOnly]
  241. public ActionResult GetSelectBuiess(string WorkPoint)
  242. {
  243. DataTable dt = APP.GetSelectBuiess(WorkPoint);
  244. return Content(dt.ToJson());
  245. }
  246. /// <summary>
  247. /// 获取供应商
  248. /// </summary>
  249. /// <param name="rfqno"></param>
  250. /// <param name="workpoint"></param>
  251. /// <returns></returns>
  252. [HttpGet]
  253. [HandlerAjaxOnly]
  254. public ActionResult GetSelectVendor(string WorkPoint)
  255. {
  256. DataTable dt = APP.GetSelectVendor(WorkPoint);
  257. return Content(dt.ToJson());
  258. }
  259. /// <summary>
  260. /// 无聊行退回
  261. /// </summary>
  262. /// <param name="keyValue"></param>
  263. /// <returns></returns>
  264. public ActionResult InvCodeBack(string keyValue,string RFQNO)
  265. {
  266. string msg = APP.InvCodeBack(keyValue, RFQNO);
  267. if (string.IsNullOrEmpty(msg))
  268. {
  269. return Success("退回成功!");
  270. }
  271. else
  272. {
  273. return Error(msg);
  274. }
  275. //return Content(app.DeleteInvTab(json));
  276. }
  277. /// <summary>
  278. /// 获取物料名称、单位、规格型号
  279. /// </summary>
  280. /// <param name="WorkPoint"></param>
  281. /// <returns></returns>
  282. [HttpGet]
  283. [HandlerAjaxOnly]
  284. public ActionResult GetTxtInfoByPN(string RFQCODE)
  285. {
  286. DataTable ListData = APP.GetTxtInfoByPN(RFQCODE);
  287. var JsonData = new
  288. {
  289. RFQCODE = ListData.Rows[0][0].ToString(),
  290. RFQNAME = ListData.Rows[0][1].ToString(),
  291. PURCHUGCODE = ListData.Rows[0][2].ToString(),
  292. ITEMTYPE = ListData.Rows[0][3].ToString(),
  293. PURCHUGNAME = ListData.Rows[0][4].ToString(),
  294. PURCHUGCONECT = ListData.Rows[0][5].ToString(),
  295. VENDORCODE = ListData.Rows[0][6].ToString(),
  296. cVenName = ListData.Rows[0][7].ToString(),
  297. VENDORTYPE = ListData.Rows[0][8].ToString(),
  298. CURRENCY = ListData.Rows[0][9].ToString(),
  299. TAXRATE = ListData.Rows[0][10].ToString(),
  300. PAYMENTCONDITION = ListData.Rows[0][11].ToString(),
  301. MEMO = ListData.Rows[0][12].ToString(),
  302. COMPANYCODE = ListData.Rows[0][13].ToString(),
  303. HASCOSTDETAILS = ListData.Rows[0][14].ToString(),
  304. FileName = ListData.Rows[0][15].ToString(),
  305. //AccountPeriod = ListData.Rows[0][16].ToString(),
  306. };
  307. return Content(JsonData.ToJson());
  308. }
  309. [HttpGet]
  310. [HandlerAjaxOnly]
  311. public ActionResult SelectOfferByPN(string RFQCODE, Pagination pagination, string WorkPoint)
  312. {
  313. DataTable ListData = APP.SelectOfferByPN(RFQCODE, ref pagination, WorkPoint);
  314. var JsonData = new
  315. {
  316. total = pagination.total,
  317. page = pagination.page,
  318. records = pagination.records,
  319. rows = ListData,
  320. };
  321. return Content(JsonData.ToJson());
  322. }
  323. [HttpGet]
  324. [HandlerAjaxOnly]
  325. public ActionResult SecondGetTxtInfoByPN(string RFQCODE, string QUOTATIONCODE)
  326. {
  327. DataTable ListData = APP.SecondGetTxtInfoByPN(RFQCODE, QUOTATIONCODE);
  328. var JsonData = new
  329. {
  330. rows = ListData,
  331. };
  332. return Content(JsonData.ToJson());
  333. }
  334. [HttpGet]
  335. [HandlerAjaxOnly]
  336. public ActionResult SecondSelectOfferByPN(string RFQCODE, string QUOTATIONCODE, Pagination pagination)
  337. {
  338. DataTable ListData = APP.SecondSelectOfferByPN(RFQCODE, QUOTATIONCODE, ref pagination);
  339. var JsonData = new
  340. {
  341. total = pagination.total,
  342. page = pagination.page,
  343. records = pagination.records,
  344. rows = ListData,
  345. };
  346. return Content(JsonData.ToJson());
  347. }
  348. public ActionResult GetGridJson(Pagination pagination, String JSON)
  349. {
  350. DataTable table = APP.GetGridJson(JSON, ref pagination);
  351. var JsonData = new
  352. {
  353. total = pagination.total,
  354. page = pagination.page,
  355. records = pagination.records,
  356. rows = table
  357. };
  358. return Content(JsonData.ToJson());
  359. }
  360. #region 查询技术部需求单列表
  361. public ActionResult GetGridJsonICSSORRFQRequestFrom(Pagination pagination, String JSON)
  362. {
  363. DataTable table = APP.GetGridJsonICSSORRFQRequestFrom(JSON, ref pagination);
  364. var JsonData = new
  365. {
  366. total = pagination.total,
  367. page = pagination.page,
  368. records = pagination.records,
  369. rows = table
  370. };
  371. return Content(JsonData.ToJson());
  372. }
  373. #endregion
  374. #region 查询技术部需求单列表(子表)
  375. [HttpGet]
  376. [HandlerAjaxOnly]
  377. public ActionResult GetSubGridJsonICSSORRFQRequestFrom(string RFQCODE, Pagination pagination, string WorkPoint)
  378. {
  379. DataTable ListData = APP.GetSubGridJsonICSSORRFQRequestFrom(RFQCODE, ref pagination, WorkPoint);
  380. var JsonData = new
  381. {
  382. total = pagination.total,
  383. page = pagination.page,
  384. records = pagination.records,
  385. rows = ListData,
  386. };
  387. return Content(JsonData.ToJson());
  388. }
  389. #endregion
  390. #region 技术部发布申请单
  391. public ActionResult JSPublish(string json)
  392. {
  393. return Content(APP.JSPublish(json));
  394. }
  395. #endregion
  396. #region 删除技术申请单
  397. public ActionResult DELETEICSSORRFQRequestFrom(string json)
  398. {
  399. return Content(APP.DELETEICSSORRFQRequestFrom(json));
  400. }
  401. #endregion
  402. #region 生成申请单号
  403. public ActionResult GetSercodeICSSORRFQRequestFrom(string workpoint)
  404. {
  405. string sercode = APP.GetSercodeICSSORRFQRequestFrom(workpoint);
  406. return Content(sercode);
  407. }
  408. #endregion
  409. #region 查询申请物料信息
  410. public ActionResult GetInvTabICSSORRFQRequestFrom(string rfqno, Pagination pagination)
  411. {
  412. DataTable table = APP.GetInvTabICSSORRFQRequestFrom(rfqno);
  413. var JsonData = new
  414. {
  415. total = pagination.total,
  416. page = pagination.page,
  417. records = pagination.records,
  418. rows = table
  419. };
  420. return Content(JsonData.ToJson());
  421. }
  422. #endregion
  423. #region 查询申请单主表信息,修改
  424. public ActionResult GetICSSORRFQRequestFromrow(string rfqcode)
  425. {
  426. return Content(APP.GetICSSORRFQRequestFromrow(rfqcode).ToJson());
  427. }
  428. #endregion
  429. #region 获取申请单附件信息
  430. [HttpGet]
  431. [HandlerAjaxOnly]
  432. public ActionResult GetICSSORRFQRequestFromVenDorFile(string rfqcode)
  433. {
  434. DataTable ListData = APP.GetICSSORRFQRequestFromVenDorFile(rfqcode);
  435. var JsonData = new
  436. {
  437. rows = ListData,
  438. };
  439. return Content(JsonData.ToJson());
  440. }
  441. #endregion
  442. #region 删除申请的物料信息
  443. public ActionResult DeleteInvRowICSSORRFQRequestFrom(string keyValue)
  444. {
  445. string msg = APP.DeleteInvRowICSSORRFQRequestFrom(keyValue);
  446. if (string.IsNullOrEmpty(msg))
  447. {
  448. return Success("删除成功!");
  449. }
  450. else
  451. {
  452. return Error(msg);
  453. }
  454. //return Content(app.DeleteInvTab(json));
  455. }
  456. #endregion
  457. #region 保存技术申请单方法
  458. [HttpPost]
  459. public ActionResult AddICSSORRFQRequestFromByPN(ICSSORRFQ details)
  460. {
  461. try
  462. {
  463. APP.AddICSSORRFQRequestFromByPN(details);
  464. return Success("询报价创建成功!");
  465. }
  466. catch (Exception ex)
  467. {
  468. return Error(ex.Message);
  469. }
  470. }
  471. #endregion
  472. public ActionResult GetInvTab(string rfqno, Pagination pagination)
  473. {
  474. DataTable table = APP.GetInvTable(rfqno);
  475. var JsonData = new
  476. {
  477. total = pagination.total,
  478. page = pagination.page,
  479. records = pagination.records,
  480. rows = table
  481. };
  482. return Content(JsonData.ToJson());
  483. }
  484. /// <summary>
  485. /// 获取生效价格查询
  486. /// </summary>
  487. /// <param name="pagination">分页</param>
  488. /// <param name="queryJson">传入过滤参数</param>
  489. /// <returns></returns>
  490. [HttpGet]
  491. [HandlerAjaxOnly]
  492. public ActionResult GetGridPriceByPN(Pagination pagination, string queryJson)
  493. {
  494. DataTable ListData = APP.GetGridPriceByPN(queryJson, ref pagination);
  495. var JsonData = new
  496. {
  497. total = pagination.total,
  498. page = pagination.page,
  499. records = pagination.records,
  500. rows = ListData,
  501. };
  502. return Content(JsonData.ToJson());
  503. }
  504. [HttpPost]
  505. [HandlerAjaxOnly]
  506. public ActionResult AgreeByPN(string json)
  507. {
  508. return Content(APP.AgreeByPN(json));
  509. }
  510. [HttpPost]
  511. /// <summary>
  512. /// 文件上传到本地
  513. /// </summary>
  514. public ActionResult UploadFile(string ID, string BidCode, string WorkPoint)
  515. {
  516. try
  517. {
  518. // 检查是否有文件上传
  519. if (Request.Files.Count == 0 || Request.Files[0]?.ContentLength == 0)
  520. {
  521. return Json(new { error = "请选择要上传的文件" }, JsonRequestBehavior.AllowGet);
  522. }
  523. var file = Request.Files[0];
  524. var fileExtension = Path.GetExtension(file.FileName)?.ToLower();
  525. // 验证文件类型
  526. if (fileExtension != ".xls" && fileExtension != ".xlsx")
  527. {
  528. return Json(new { error = "只支持上传Excel(.xls, .xlsx)文件" }, JsonRequestBehavior.AllowGet);
  529. }
  530. // 生成唯一文件名并创建保存路径
  531. var fileName = $"{DateTime.Now:yyyyMMddHHmmss}{Guid.NewGuid()}{fileExtension}";
  532. var uploadDirectory = Server.MapPath("~/File/UPLoadFile/");
  533. // 确保上传目录存在
  534. if (!Directory.Exists(uploadDirectory))
  535. {
  536. Directory.CreateDirectory(uploadDirectory);
  537. }
  538. var savePath = Path.Combine(uploadDirectory, fileName);
  539. // 保存文件
  540. using (var stream = new FileStream(savePath, FileMode.Create))
  541. {
  542. file.InputStream.CopyTo(stream);
  543. }
  544. // 处理上传的Excel文件
  545. var listData = APP.SetData_PR(savePath, ID, BidCode, WorkPoint);
  546. return Content(listData.ToJson());
  547. }
  548. catch (Exception ex)
  549. {
  550. return Error(ex.Message);
  551. }
  552. }
  553. public ActionResult GetPurchasing(string VenCode)
  554. {
  555. string msg = APP.GetPurchasing(VenCode);
  556. var JsonData = new
  557. {
  558. mass = msg,
  559. };
  560. return Content(JsonData.ToJson());
  561. }
  562. [HttpGet]
  563. [HandlerAjaxOnly]
  564. public ActionResult GetVenDorFileSSORByPN(string FPRFQCODE)
  565. {
  566. DataTable ListData = APP.GetVenDorFileSSORByPN(FPRFQCODE);
  567. var JsonData = new
  568. {
  569. rows = ListData,
  570. };
  571. return Content(JsonData.ToJson());
  572. }
  573. [HttpGet]
  574. [HandlerAjaxOnly]
  575. public ActionResult SORRFQCourseHistoryInfoCahrsByPN(string FPRFQCODE, string workpoint, string ITEMCODE)
  576. {
  577. DataTable ListData = APP.SORRFQCourseHistoryInfoCahrsByPN(FPRFQCODE, workpoint, ITEMCODE);
  578. string ss = ListData.ToJson();
  579. return Content(ListData.ToJson());
  580. }
  581. [HttpGet]
  582. [HandlerAjaxOnly]
  583. public ActionResult GetGridMaterialByPN(Pagination pagination, string ITEMCODE, string VenCode, string FPRFQCODE)
  584. {
  585. DataTable ListData = APP.GetGridMaterialByPN(ref pagination, ITEMCODE, VenCode, FPRFQCODE);
  586. var JsonData = new
  587. {
  588. total = pagination.total,
  589. page = pagination.page,
  590. records = pagination.records,
  591. rows = ListData,
  592. };
  593. return Content(JsonData.ToJson());
  594. }
  595. [HttpPost]
  596. [HandlerAjaxOnly]
  597. //[ValidateAntiForgeryToken]
  598. public ActionResult SaveQuotationByPN(string keyValue)
  599. {
  600. string msg = "";
  601. msg = APP.SaveQuotationByPN(keyValue);
  602. if (string.IsNullOrWhiteSpace(msg))
  603. {
  604. return Success("信息保存成功!");
  605. }
  606. else
  607. {
  608. return Error("" + msg + "");
  609. }
  610. }
  611. [HttpGet]
  612. public ActionResult GetPriceInquiryItem(string invcode, Pagination pagination, string workpoint, string InvName,string sfqcode)
  613. {
  614. DataTable ListData = APP.GetPriceInquiryItem(invcode, ref pagination, workpoint, InvName, sfqcode);
  615. var JsonData = new
  616. {
  617. total = pagination.total,
  618. page = pagination.page,
  619. records = pagination.records,
  620. rows = ListData,
  621. };
  622. return Content(JsonData.ToJson());
  623. }
  624. }
  625. }