纽威
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.

2200 lines
66 KiB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
  1. using NFine.Application.WMS;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Data;
  5. using System.IO;
  6. using System.Linq;
  7. using System.Web;
  8. using System.Web.Mvc;
  9. using NFine.Code;
  10. using System.Data.SqlClient;
  11. using NFine.Data.Extensions;
  12. using System.Data.OleDb;
  13. using System.Configuration;
  14. using ICS.Application.Entity;
  15. namespace NFine.Web.Areas.WMS.Controllers
  16. {
  17. public class BasicSettingsController : ControllerBase
  18. {
  19. BasicSettingsApp App = new BasicSettingsApp();
  20. /// <summary>
  21. /// 加载仓库
  22. /// </summary>
  23. /// <returns></returns>
  24. [HttpGet]
  25. public ActionResult Warehouse()
  26. {
  27. return View();
  28. }
  29. /// <summary>
  30. /// 加载库位
  31. /// </summary>
  32. /// <returns></returns>
  33. [HttpGet]
  34. public ActionResult ICSStackWMS()
  35. {
  36. return View();
  37. }
  38. /// <summary>
  39. /// 物料档案
  40. /// </summary>
  41. /// <returns></returns>
  42. [HttpGet]
  43. public ActionResult ICSINVENTORY()
  44. {
  45. return View();
  46. }
  47. /// <summary>
  48. /// 不良代码组
  49. /// </summary>
  50. /// <returns></returns>
  51. [HttpGet]
  52. public ActionResult ICSECG()
  53. {
  54. return View();
  55. }
  56. [HttpGet]
  57. public ActionResult ICSSDN()
  58. {
  59. return View();
  60. }
  61. /// <summary>
  62. /// 不良代码维护
  63. /// </summary>
  64. /// <returns></returns>
  65. [HttpGet]
  66. public ActionResult ICSBadCode()
  67. {
  68. return View();
  69. }
  70. /// <summary>
  71. /// 新增库位信息
  72. /// </summary>
  73. /// <returns></returns>
  74. [HttpGet]
  75. public ActionResult ICSStackWMSAdd()
  76. {
  77. return View();
  78. }
  79. [HttpGet]
  80. /// <summary>
  81. /// 标签模板维护
  82. /// </summary>
  83. /// <returns></returns>
  84. public ActionResult ICSLableManage()
  85. {
  86. return View();
  87. }
  88. public ActionResult ICSLableManageAdd()
  89. {
  90. return View();
  91. }
  92. /// <summary>
  93. /// 新增不良代码
  94. /// </summary>
  95. /// <returns></returns>
  96. public ActionResult ICSBadCodeAdd()
  97. {
  98. return View();
  99. }
  100. /// <summary>
  101. /// 类型维护
  102. /// </summary>
  103. /// <returns></returns>
  104. public ActionResult ICSTypeMaintain()
  105. {
  106. return View();
  107. }
  108. /// 新增类型
  109. /// </summary>
  110. /// <returns></returns>
  111. [HttpGet]
  112. public ActionResult ICSTypeMaintainAdd()
  113. {
  114. return View();
  115. }
  116. /// <summary>
  117. /// 配置参数维护
  118. /// </summary>
  119. /// <returns></returns>
  120. public ActionResult ICSConfiguration()
  121. {
  122. return View();
  123. }
  124. /// <summary>
  125. /// 启用配置
  126. /// </summary>
  127. /// <returns></returns>
  128. public ActionResult ICSExtensionEnable()
  129. {
  130. return View();
  131. }
  132. /// <summary>
  133. /// 新增启用配置
  134. /// </summary>
  135. /// <returns></returns>
  136. public ActionResult ICSExtensionEnableAdd()
  137. {
  138. return View();
  139. }
  140. /// 新增类型
  141. /// </summary>
  142. /// <returns></returns>
  143. [HttpGet]
  144. public ActionResult ICSConfigurationAdd()
  145. {
  146. return View();
  147. }
  148. /// 不良原因组
  149. /// </summary>
  150. /// <returns></returns>
  151. [HttpGet]
  152. public ActionResult ICSBadReasonGroup()
  153. {
  154. return View();
  155. }
  156. /// 新增不良原因组
  157. /// </summary>
  158. /// <returns></returns>
  159. [HttpGet]
  160. public ActionResult ICSBadReasonGroupAdd()
  161. {
  162. return View();
  163. }
  164. /// 新增不良原因组
  165. /// </summary>
  166. /// <returns></returns>
  167. [HttpGet]
  168. public ActionResult ICSInventoryBadGroupAdd()
  169. {
  170. return View();
  171. }
  172. //包装容器绑定
  173. [HttpGet]
  174. public ActionResult ICSContainerBinding()
  175. {
  176. return View();
  177. }
  178. [HttpGet]
  179. //不良代码
  180. public ActionResult GetICSBadCodeGroup(Pagination pagination,string queryJson)
  181. {
  182. DataTable ListData = App.GetICSBadCodeGroup(ref pagination, queryJson);
  183. var JsonData = new
  184. {
  185. total = pagination.total,
  186. page = pagination.page,
  187. records = pagination.records,
  188. rows = ListData,
  189. };
  190. return Content(JsonData.ToJson());
  191. }
  192. //不良原因()
  193. public ActionResult GetICSBadReasonGroup(Pagination pagination, string queryJson)
  194. {
  195. DataTable ListData = App.GetICSBadReasonGroup(ref pagination, queryJson);
  196. var JsonData = new
  197. {
  198. total = pagination.total,
  199. page = pagination.page,
  200. records = pagination.records,
  201. rows = ListData,
  202. };
  203. return Content(JsonData.ToJson());
  204. }
  205. //不良代码子表
  206. [HttpGet]
  207. [HandlerAjaxOnly]
  208. public ActionResult GetICSBadCodeGroupdetil(string ID, Pagination pagination)
  209. {
  210. DataTable ListData = App.GetICSBadCodeGroupdetil(ID, ref pagination);
  211. var JsonData = new
  212. {
  213. total = pagination.total,
  214. page = pagination.page,
  215. records = pagination.records,
  216. rows = ListData,
  217. };
  218. return Content(JsonData.ToJson());
  219. }
  220. [HttpGet]
  221. public ActionResult GetICSBadCodeGroupdetil2(string ID)
  222. {
  223. var data = App.GetICSBadCodeGroupdetil2(ID);
  224. return Content(data.ToJson());
  225. }
  226. //不良原因子表
  227. [HttpGet]
  228. [HandlerAjaxOnly]
  229. public ActionResult GetICSBadReason(string BRGCode, Pagination pagination)
  230. {
  231. DataTable ListData = App.GetICSBadReason(BRGCode, ref pagination);
  232. var JsonData = new
  233. {
  234. total = pagination.total,
  235. page = pagination.page,
  236. records = pagination.records,
  237. rows = ListData,
  238. };
  239. return Content(JsonData.ToJson());
  240. }
  241. [HttpGet]
  242. public ActionResult GetICSBadReason2(string BRGCode)
  243. {
  244. var data = App.GetICSBadReason2(BRGCode);
  245. return Content(data.ToJson());
  246. }
  247. [HttpGet]
  248. public ActionResult ICSInspectionGroup()
  249. {
  250. return View();
  251. }
  252. [HttpGet]
  253. public ActionResult ICSInspectionListAdd()
  254. {
  255. return View();
  256. }
  257. [HttpGet]
  258. public ActionResult ICSINVEBTORYAdd()
  259. {
  260. return View();
  261. }
  262. [HttpGet]
  263. public ActionResult ICSInventoryBatchEnable()
  264. {
  265. return View();
  266. }
  267. [HttpGet]
  268. public ActionResult ICSInventoryBatchEnableAdd()
  269. {
  270. return View();
  271. }
  272. [HttpGet]
  273. public ActionResult ICSInventoryBatchEnableUpadte()
  274. {
  275. return View();
  276. }
  277. [HttpGet]
  278. public ActionResult ICSInventoryLocation()
  279. {
  280. return View();
  281. }
  282. [HttpGet]
  283. public ActionResult ICSInventoryLocationAdd()
  284. {
  285. return View();
  286. }
  287. [HttpGet]
  288. public ActionResult ICSInventoryLocationUpdate()
  289. {
  290. return View();
  291. }
  292. [HttpGet]
  293. public ActionResult ICSContainer()
  294. {
  295. return View();
  296. }
  297. [HttpGet]
  298. public ActionResult ICSContainerAdd()
  299. {
  300. return View();
  301. }
  302. [HttpGet]
  303. public ActionResult ICSContainerLot()
  304. {
  305. return View();
  306. }
  307. [HttpGet]
  308. public ActionResult ICSContainerLotAdd()
  309. {
  310. return View();
  311. }
  312. [HttpGet]
  313. public ActionResult ICSInventoryBadGroup()
  314. {
  315. return View();
  316. }
  317. [HttpGet]
  318. public ActionResult ICSInventoryBadGroupUpdate()
  319. {
  320. return View();
  321. }
  322. [HttpGet]
  323. public ActionResult ICSLabelTemplate()
  324. {
  325. return View();
  326. }
  327. [HttpGet]
  328. public ActionResult ICSLabelTemplateAdd()
  329. {
  330. return View();
  331. }
  332. [HttpGet]
  333. public ActionResult ICSContainerLotBinding()
  334. {
  335. return View();
  336. }
  337. // public ActionResult DownloadExcl(int day)
  338. // {
  339. // try
  340. // {
  341. // //int showDay = NVelocityBLL.DAY_AGO * -1;
  342. // //var list = NVelocityBLL.Instance.DataList;
  343. // //NVelocityBLL.Instance.Refresh();
  344. // //if (day != 0)
  345. // //{
  346. // //showDay = day;
  347. // //list = NVelocityBLL.Instance.GetDataByTotalDay(day);
  348. // //}
  349. // string sWebRootFolder = _hostingEnvironment.WebRootPath;
  350. // string sFileName = $"Subscription/{Guid.NewGuid()}.xlsx";
  351. // DeleteDir($"{sWebRootFolder}\\Subscription");
  352. // FileInfo file = new FileInfo(Path.Combine(sWebRootFolder, sFileName));
  353. // using (ExcelPackage package = new ExcelPackage(file))
  354. // {
  355. // ExcelWorksheet worksheet = package.Workbook.Worksheets.Add("aspnetcore");
  356. // worksheet.Cells[1, 1].Value = "date/Step";
  357. // worksheet.DefaultColWidth = 25;
  358. // for (int i = 1; i <= showDay; i++)
  359. // {
  360. // // The number of now days.Used as a column header.
  361. // int nowDay = -(i - 1);
  362. // //Col index
  363. // int colIndex = i + 1;
  364. // //DateTime nowTime = NVelocityBLL.Instance.GetChinaByUtcDate(DateTime.UtcNow).AddDays(nowDay);
  365. // string utcTime = DateTime.UtcNow.AddDays(nowDay).ToString("yyyy-MM-dd");
  366. // //Insert the column header
  367. // worksheet.Cells[1, colIndex].Value = nowTime.ToString("yyyy-MM-dd");
  368. // //Insert the row
  369. // InsertExeclRow(list, worksheet, colIndex, nowTime);
  370. // }
  371. // package.Save();
  372. // }
  373. // return File(sFileName, "applicationnd.openxmlformats-officedocument.spreadsheetml.sheet");
  374. // }
  375. // catch (Exception ex)
  376. // {
  377. // FxLogger.DEFAULT.Error($"DownloadExcl:", ex);
  378. // return SiteBLL.ErrorResponseData(-2, ex.Message);
  379. // }
  380. //}
  381. /// <summary>
  382. /// 删除库位
  383. /// </summary>
  384. /// <returns></returns>
  385. [HttpPost]
  386. [HandlerAjaxOnly]
  387. [ValidateAntiForgeryToken]
  388. public ActionResult DeleteStack(string keyValue)
  389. {
  390. string msg = App.DeleteStack(keyValue);
  391. if (string.IsNullOrEmpty(msg))
  392. {
  393. return Success("删除成功!");
  394. }
  395. else
  396. {
  397. return Error(msg);
  398. }
  399. }
  400. /// <summary>
  401. /// 删除不良原因
  402. /// </summary>
  403. /// <returns></returns>
  404. [HttpPost]
  405. [HandlerAjaxOnly]
  406. [ValidateAntiForgeryToken]
  407. public ActionResult DeleteBadCode(string keyValue)
  408. {
  409. string msg = App.DeleteBadCode(keyValue);
  410. if (string.IsNullOrEmpty(msg))
  411. {
  412. return Success("删除成功!");
  413. }
  414. else
  415. {
  416. return Error(msg);
  417. }
  418. }
  419. [HttpPost]
  420. [HandlerAjaxOnly]
  421. public ActionResult InsertStack(string keyValue)
  422. {
  423. string msg = App.InsertStack(keyValue);
  424. if (!string.IsNullOrEmpty(msg))
  425. {
  426. return Error(msg);
  427. }
  428. else
  429. {
  430. return Success("添加成功!");
  431. }
  432. }
  433. [HttpPost]
  434. [HandlerAjaxOnly]
  435. public ActionResult InsertBadCode(string keyValue)
  436. {
  437. string msg = App.InsertBadCode(keyValue);
  438. if (!string.IsNullOrEmpty(msg))
  439. {
  440. return Error(msg);
  441. }
  442. else
  443. {
  444. return Success("添加成功!");
  445. }
  446. }
  447. [HttpPost]
  448. [HandlerAjaxOnly]
  449. public ActionResult UpdateBadCode(string keyValue)
  450. {
  451. string msg = App.UpdateBadCode(keyValue);
  452. if (!string.IsNullOrEmpty(msg))
  453. {
  454. return Error(msg);
  455. }
  456. else
  457. {
  458. return Success("修改成功!");
  459. }
  460. }
  461. [HttpPost]
  462. [HandlerAjaxOnly]
  463. public ActionResult UpdateStack(string keyValue)
  464. {
  465. string msg = App.UpdateStack(keyValue);
  466. if (!string.IsNullOrEmpty(msg))
  467. {
  468. return Error(msg);
  469. }
  470. else
  471. {
  472. return Success("修改成功!");
  473. }
  474. }
  475. /// <summary>
  476. /// 获取库位信息
  477. /// </summary>
  478. /// <returns></returns>
  479. public ActionResult GetWarehouse()
  480. {
  481. DataTable dt = App.GetWarehouse();
  482. return Content(dt.ToJson());
  483. }
  484. /// <summary>
  485. /// 新增类型
  486. /// </summary>
  487. /// <param name="keyValue"></param>
  488. /// <returns></returns>
  489. [HttpPost]
  490. [HandlerAjaxOnly]
  491. public ActionResult InsertICSType(string keyValue)
  492. {
  493. string msg = App.InsertICSType(keyValue);
  494. if (!string.IsNullOrEmpty(msg))
  495. {
  496. return Error(msg);
  497. }
  498. else
  499. {
  500. return Success("添加成功!");
  501. }
  502. }
  503. /// <summary>
  504. /// 修改类型
  505. /// </summary>
  506. /// <param name="keyValue"></param>
  507. /// <returns></returns>
  508. [HttpPost]
  509. [HandlerAjaxOnly]
  510. public ActionResult UpdateICSType(string keyValue)
  511. {
  512. string msg = App.UpdateICSType(keyValue);
  513. if (!string.IsNullOrEmpty(msg))
  514. {
  515. return Error(msg);
  516. }
  517. else
  518. {
  519. return Success("修改成功!");
  520. }
  521. }
  522. /// <summary>
  523. /// 删除类型
  524. /// </summary>
  525. /// <returns></returns>
  526. [HttpPost]
  527. [HandlerAjaxOnly]
  528. [ValidateAntiForgeryToken]
  529. public ActionResult DeleteICSType(string keyValue)
  530. {
  531. string msg = App.DeleteICSType(keyValue);
  532. if (string.IsNullOrEmpty(msg))
  533. {
  534. return Success("删除成功!");
  535. }
  536. else
  537. {
  538. return Error(msg);
  539. }
  540. }
  541. /// <summary>
  542. /// 修改配置参数
  543. /// </summary>
  544. /// <param name="keyValue"></param>
  545. /// <returns></returns>
  546. [HttpPost]
  547. [HandlerAjaxOnly]
  548. public ActionResult UpdateICSConfiguration(string keyValue)
  549. {
  550. string msg = App.UpdateICSConfiguration(keyValue);
  551. if (!string.IsNullOrEmpty(msg))
  552. {
  553. return Error(msg);
  554. }
  555. else
  556. {
  557. return Success("修改成功!");
  558. }
  559. }
  560. /// <summary>
  561. /// 新增参数配置
  562. /// </summary>
  563. /// <param name="keyValue"></param>
  564. /// <returns></returns>
  565. [HttpPost]
  566. [HandlerAjaxOnly]
  567. public ActionResult InsertICSConfiguration(string keyValue)
  568. {
  569. string msg = App.InsertICSConfiguration(keyValue);
  570. if (!string.IsNullOrEmpty(msg))
  571. {
  572. return Error(msg);
  573. }
  574. else
  575. {
  576. return Success("添加成功!");
  577. }
  578. }
  579. /// <summary>
  580. /// 删除参数配置
  581. /// </summary>
  582. /// <returns></returns>
  583. [HttpPost]
  584. [HandlerAjaxOnly]
  585. [ValidateAntiForgeryToken]
  586. public ActionResult DeleteICSConfiguration(string keyValue)
  587. {
  588. string msg = App.DeleteICSConfiguration(keyValue);
  589. if (string.IsNullOrEmpty(msg))
  590. {
  591. return Success("删除成功!");
  592. }
  593. else
  594. {
  595. return Error(msg);
  596. }
  597. }
  598. /// <summary>
  599. /// 修改启用配置
  600. /// </summary>
  601. /// <param name="keyValue"></param>
  602. /// <returns></returns>
  603. [HttpPost]
  604. [HandlerAjaxOnly]
  605. public ActionResult UpdateICSExtensionEnable(string keyValue)
  606. {
  607. string msg = App.UpdateICSExtensionEnable(keyValue);
  608. if (!string.IsNullOrEmpty(msg))
  609. {
  610. return Error(msg);
  611. }
  612. else
  613. {
  614. return Success("修改成功!");
  615. }
  616. }
  617. /// <summary>
  618. /// 新增启用配置
  619. /// </summary>
  620. /// <param name="keyValue"></param>
  621. /// <returns></returns>
  622. [HttpPost]
  623. [HandlerAjaxOnly]
  624. public ActionResult InsertICSExtensionEnable(string keyValue)
  625. {
  626. string msg = App.InsertICSExtensionEnable(keyValue);
  627. if (!string.IsNullOrEmpty(msg))
  628. {
  629. return Error(msg);
  630. }
  631. else
  632. {
  633. return Success("添加成功!");
  634. }
  635. }
  636. /// <summary>
  637. /// 删除启用配置
  638. /// </summary>
  639. /// <returns></returns>
  640. [HttpPost]
  641. [HandlerAjaxOnly]
  642. [ValidateAntiForgeryToken]
  643. public ActionResult DeleteICSExtensionEnable(string keyValue)
  644. {
  645. string msg = App.DeleteICSExtensionEnable(keyValue);
  646. if (string.IsNullOrEmpty(msg))
  647. {
  648. return Success("删除成功!");
  649. }
  650. else
  651. {
  652. return Error(msg);
  653. }
  654. }
  655. [HttpGet]
  656. public ActionResult DeleteBCItem(string ID)
  657. {
  658. try
  659. {
  660. App.DeleteBCItem(ID);
  661. return Success("删除成功!");
  662. }
  663. catch (Exception ex)
  664. {
  665. return Error(ex.Message);
  666. }
  667. }
  668. [HttpGet]
  669. public ActionResult DeleteItem(string ID)
  670. {
  671. try
  672. {
  673. App.DeleteItem(ID);
  674. return Success("删除成功!");
  675. }
  676. catch (Exception ex)
  677. {
  678. return Error(ex.Message);
  679. }
  680. }
  681. //不良代码组新增
  682. [HttpPost]
  683. public ActionResult SubICSBadCodeGroupAdd(ICSBadReason main, string BRGCode, string BRGDesc)
  684. {
  685. try
  686. {
  687. App.SubICSBadCodeGroupAdd(main, BRGCode, BRGDesc);
  688. return Success("保存成功!");
  689. }
  690. catch (Exception ex)
  691. {
  692. return Error(ex.Message);
  693. }
  694. }
  695. //不良原因组新增
  696. [HttpPost]
  697. public ActionResult SubICSBadReasonGroupAdd(ICSBadReason main,string BRGCode, string BRGDesc)
  698. {
  699. try
  700. {
  701. App.SubICSBadReasonGroupAdd(main, BRGCode, BRGDesc);
  702. return Success("保存成功!");
  703. }
  704. catch (Exception ex)
  705. {
  706. return Error(ex.Message);
  707. }
  708. }
  709. //不良代码组修改
  710. [HttpPost]
  711. public ActionResult UpdateICSBadCodeGroup(ICSBadReason main, string BID, string BRGCode, string BRGDesc)
  712. {
  713. try
  714. {
  715. App.UpdateICSBadCodeGroup(main, BID, BRGCode, BRGDesc);
  716. return Success("修改成功!");
  717. }
  718. catch (Exception ex)
  719. {
  720. return Error(ex.Message);
  721. }
  722. }
  723. //不良原因组修改
  724. [HttpPost]
  725. public ActionResult UpdateICSBadReasonGroup(ICSBadReason main,string BID ,string BRGCode, string BRGDesc)
  726. {
  727. try
  728. {
  729. App.UpdateICSBadReasonGroup(main, BID, BRGCode, BRGDesc);
  730. return Success("修改成功!");
  731. }
  732. catch (Exception ex)
  733. {
  734. return Error(ex.Message);
  735. }
  736. }
  737. /// <summary>
  738. /// 删除不良代码组
  739. /// </summary>
  740. /// <returns></returns>
  741. [HttpPost]
  742. [HandlerAjaxOnly]
  743. [ValidateAntiForgeryToken]
  744. public ActionResult DeleteICSBadCodeGroup(string keyValue)
  745. {
  746. string msg = App.DeleteICSBadCodeGroup(keyValue);
  747. if (string.IsNullOrEmpty(msg))
  748. {
  749. return Success("删除成功!");
  750. }
  751. else
  752. {
  753. return Error(msg);
  754. }
  755. }
  756. /// <summary>
  757. /// 删除不良原因组
  758. /// </summary>
  759. /// <returns></returns>
  760. [HttpPost]
  761. [HandlerAjaxOnly]
  762. [ValidateAntiForgeryToken]
  763. public ActionResult DeleteICSBadReasonGroup(string keyValue)
  764. {
  765. string msg = App.DeleteICSBadReasonGroup(keyValue);
  766. if (string.IsNullOrEmpty(msg))
  767. {
  768. return Success("删除成功!");
  769. }
  770. else
  771. {
  772. return Error(msg);
  773. }
  774. }
  775. [HttpGet]
  776. public ActionResult GetICSInspectionGroup(Pagination pagination, string queryJson)
  777. {
  778. DataTable ListData = App.GetICSInspectionGroup(ref pagination, queryJson);
  779. var JsonData = new
  780. {
  781. total = pagination.total,
  782. page = pagination.page,
  783. records = pagination.records,
  784. rows = ListData,
  785. };
  786. return Content(JsonData.ToJson());
  787. }
  788. [HttpGet]
  789. [HandlerAjaxOnly]
  790. public ActionResult ICSInspectionList(string GroupCode, Pagination pagination)
  791. {
  792. DataTable ListData = App.ICSInspectionList(GroupCode, ref pagination);
  793. var JsonData = new
  794. {
  795. total = pagination.total,
  796. page = pagination.page,
  797. records = pagination.records,
  798. rows = ListData,
  799. };
  800. return Content(JsonData.ToJson());
  801. }
  802. //删除自动表
  803. [HttpGet]
  804. public ActionResult DeleteList(string ID)
  805. {
  806. try
  807. {
  808. App.DeleteList(ID);
  809. return Success("删除成功!");
  810. }
  811. catch (Exception ex)
  812. {
  813. return Error(ex.Message);
  814. }
  815. }
  816. //检查项目组组修改
  817. [HttpPost]
  818. public ActionResult UpdateICSInspectionGroup(ICSInspectionList main, string BID, string GroupCode, string GroupName, string Enable)
  819. {
  820. try
  821. {
  822. App.UpdateICSInspectionGroup(main, BID, GroupCode, GroupName, Enable);
  823. return Success("修改成功!");
  824. }
  825. catch (Exception ex)
  826. {
  827. return Error(ex.Message);
  828. }
  829. }
  830. //检查项目组新增
  831. [HttpPost]
  832. public ActionResult ICSInspectionGroupAdd(ICSInspectionList main, string GroupCode, string GroupName,string Enable)
  833. {
  834. try
  835. {
  836. App.ICSInspectionGroupAdd(main, GroupCode, GroupName, Enable);
  837. return Success("保存成功!");
  838. }
  839. catch (Exception ex)
  840. {
  841. return Error(ex.Message);
  842. }
  843. }
  844. /// <summary>
  845. /// 动态子表修改加载页面
  846. /// </summary>
  847. /// <param name="GroupCode"></param>
  848. /// <returns></returns>
  849. [HttpGet]
  850. public ActionResult ICSInspectionList2(string GroupCode)
  851. {
  852. var data = App.ICSInspectionList2(GroupCode);
  853. return Content(data.ToJson());
  854. }
  855. /// <summary>
  856. /// 删除不良原因组
  857. /// </summary>
  858. /// <returns></returns>
  859. [HttpPost]
  860. [HandlerAjaxOnly]
  861. [ValidateAntiForgeryToken]
  862. public ActionResult DeleteICSInspectionGroup(string keyValue)
  863. {
  864. string msg = App.DeleteICSInspectionGroup(keyValue);
  865. if (string.IsNullOrEmpty(msg))
  866. {
  867. return Success("删除成功!");
  868. }
  869. else
  870. {
  871. return Error(msg);
  872. }
  873. }
  874. /// <summary>
  875. /// 新增料品属性
  876. /// </summary>
  877. /// <param name="keyValue"></param>
  878. /// <returns></returns>
  879. [HttpPost]
  880. [HandlerAjaxOnly]
  881. public ActionResult InsertICSInventory(string keyValue)
  882. {
  883. string msg = App.InsertICSInventory(keyValue);
  884. if (!string.IsNullOrEmpty(msg))
  885. {
  886. return Error(msg);
  887. }
  888. else
  889. {
  890. return Success("添加成功!");
  891. }
  892. }
  893. /// <summary>
  894. /// 修改料品属性
  895. /// </summary>
  896. /// <param name="keyValue"></param>
  897. /// <returns></returns>
  898. [HttpPost]
  899. [HandlerAjaxOnly]
  900. public ActionResult UpdateICSInventory(string keyValue)
  901. {
  902. string msg = App.UpdateICSInventory(keyValue);
  903. if (!string.IsNullOrEmpty(msg))
  904. {
  905. return Error(msg);
  906. }
  907. else
  908. {
  909. return Success("修改成功!");
  910. }
  911. }
  912. /// <summary>
  913. /// 获取料品属性修改文本框值
  914. /// </summary>
  915. /// <param name="POCode"></param>
  916. /// <param name="PORow"></param>
  917. /// <returns></returns>
  918. [HttpPost]
  919. [HandlerAjaxOnly]
  920. public ActionResult GetInputValue(string ID)
  921. {
  922. DataTable ListData = App.GetInputValue(ID);
  923. var JsonData = new
  924. {
  925. rows = ListData,
  926. };
  927. return Content(JsonData.ToJson());
  928. }
  929. /// <summary>
  930. /// 删除料品属性
  931. /// </summary>
  932. /// <returns></returns>
  933. [HttpPost]
  934. [HandlerAjaxOnly]
  935. [ValidateAntiForgeryToken]
  936. public ActionResult DeleteICSInventory(string keyValue)
  937. {
  938. string msg = App.DeleteICSInventory(keyValue);
  939. if (string.IsNullOrEmpty(msg))
  940. {
  941. return Success("删除成功!");
  942. }
  943. else
  944. {
  945. return Error(msg);
  946. }
  947. }
  948. /// <summary>
  949. /// 获取料品信息
  950. /// </summary>
  951. /// <param name="pagination"></param>
  952. /// <returns></returns>
  953. [HttpGet]
  954. public ActionResult GetICSInventoryInfo(string queryJson, Pagination pagination)
  955. {
  956. DataTable ListData = App.GetICSInventoryInfo(queryJson,ref pagination);
  957. var JsonData = new
  958. {
  959. total = pagination.total,
  960. page = pagination.page,
  961. records = pagination.records,
  962. rows = ListData,
  963. };
  964. return Content(JsonData.ToJson());
  965. }
  966. /// 获取仓库信息
  967. /// </summary>
  968. /// <param name="pagination"></param>
  969. /// <returns></returns>
  970. [HttpGet]
  971. public ActionResult GetICSWarehouseInfo(string queryJson, Pagination pagination)
  972. {
  973. DataTable ListData = App.GetICSWarehouseInfo(queryJson,ref pagination);
  974. var JsonData = new
  975. {
  976. total = pagination.total,
  977. page = pagination.page,
  978. records = pagination.records,
  979. rows = ListData,
  980. };
  981. return Content(JsonData.ToJson());
  982. }
  983. /// <summary>
  984. /// 新增料品仓库批次
  985. /// </summary>
  986. /// <param name="keyValue"></param>
  987. /// <returns></returns>
  988. [HttpPost]
  989. [HandlerAjaxOnly]
  990. public ActionResult InsertICSInventoryBatchEnable(string keyValue,string keyValue2)
  991. {
  992. string msg = App.InsertICSInventoryBatchEnable(keyValue, keyValue2);
  993. if (!string.IsNullOrEmpty(msg))
  994. {
  995. return Error(msg);
  996. }
  997. else
  998. {
  999. return Success("添加成功!");
  1000. }
  1001. }
  1002. /// <summary>
  1003. /// 修改料品仓库批次关系
  1004. /// </summary>
  1005. /// <param name="keyValue"></param>
  1006. /// <returns></returns>
  1007. [HttpPost]
  1008. [HandlerAjaxOnly]
  1009. public ActionResult UpdateICSInventoryBatchEnable(string keyValue)
  1010. {
  1011. string msg = App.UpdateICSInventoryBatchEnable(keyValue);
  1012. if (!string.IsNullOrEmpty(msg))
  1013. {
  1014. return Error(msg);
  1015. }
  1016. else
  1017. {
  1018. return Success("修改成功!");
  1019. }
  1020. }
  1021. /// <summary>
  1022. /// 删除料品仓库批次关系
  1023. /// </summary>
  1024. /// <returns></returns>
  1025. [HttpPost]
  1026. [HandlerAjaxOnly]
  1027. [ValidateAntiForgeryToken]
  1028. public ActionResult DeleteICSInventoryBatchEnable(string keyValue)
  1029. {
  1030. string msg = App.DeleteICSInventoryBatchEnable(keyValue);
  1031. if (string.IsNullOrEmpty(msg))
  1032. {
  1033. return Success("删除成功!");
  1034. }
  1035. else
  1036. {
  1037. return Error(msg);
  1038. }
  1039. }
  1040. /// 获取库位信息
  1041. /// </summary>
  1042. /// <param name="pagination"></param>
  1043. /// <returns></returns>
  1044. [HttpGet]
  1045. public ActionResult GetICSLocation(string queryJson, Pagination pagination)
  1046. {
  1047. DataTable ListData = App.GetICSLocation(queryJson,ref pagination);
  1048. var JsonData = new
  1049. {
  1050. total = pagination.total,
  1051. page = pagination.page,
  1052. records = pagination.records,
  1053. rows = ListData,
  1054. };
  1055. return Content(JsonData.ToJson());
  1056. }
  1057. /// <summary>
  1058. /// 新增料品库位绑定关系
  1059. /// </summary>
  1060. /// <param name="keyValue"></param>
  1061. /// <returns></returns>
  1062. [HttpPost]
  1063. [HandlerAjaxOnly]
  1064. public ActionResult InsertICSInventoryLocation(string keyValue, string keyValue2)
  1065. {
  1066. string msg = App.InsertICSInventoryLocation(keyValue, keyValue2);
  1067. if (!string.IsNullOrEmpty(msg))
  1068. {
  1069. return Error(msg);
  1070. }
  1071. else
  1072. {
  1073. return Success("添加成功!");
  1074. }
  1075. }
  1076. /// <summary>
  1077. /// 修改料品库位绑定关系
  1078. /// </summary>
  1079. /// <param name="keyValue"></param>
  1080. /// <returns></returns>
  1081. [HttpPost]
  1082. [HandlerAjaxOnly]
  1083. public ActionResult UpdateICSInventoryLocation(string keyValue)
  1084. {
  1085. string msg = App.UpdateICSInventoryLocation(keyValue);
  1086. if (!string.IsNullOrEmpty(msg))
  1087. {
  1088. return Error(msg);
  1089. }
  1090. else
  1091. {
  1092. return Success("修改成功!");
  1093. }
  1094. }
  1095. /// <summary>
  1096. /// 删除料品仓库批次关系
  1097. /// </summary>
  1098. /// <returns></returns>
  1099. [HttpPost]
  1100. [HandlerAjaxOnly]
  1101. [ValidateAntiForgeryToken]
  1102. public ActionResult DeleteICSInventoryLocation(string keyValue)
  1103. {
  1104. string msg = App.DeleteICSInventoryLocation(keyValue);
  1105. if (string.IsNullOrEmpty(msg))
  1106. {
  1107. return Success("删除成功!");
  1108. }
  1109. else
  1110. {
  1111. return Error(msg);
  1112. }
  1113. }
  1114. /// <summary>
  1115. /// 新增包装、容器
  1116. /// </summary>
  1117. /// <param name="keyValue"></param>
  1118. /// <returns></returns>
  1119. [HttpPost]
  1120. [HandlerAjaxOnly]
  1121. public ActionResult InsertICSContainer(string keyValue)
  1122. {
  1123. string msg = App.InsertICSContainer(keyValue);
  1124. if (!string.IsNullOrEmpty(msg))
  1125. {
  1126. return Error(msg);
  1127. }
  1128. else
  1129. {
  1130. return Success("添加成功!");
  1131. }
  1132. }
  1133. /// <summary>
  1134. /// 修改包装、容器
  1135. /// </summary>
  1136. /// <param name="keyValue"></param>
  1137. /// <returns></returns>
  1138. [HttpPost]
  1139. [HandlerAjaxOnly]
  1140. public ActionResult UpdateICSContainer(string keyValue)
  1141. {
  1142. string msg = App.UpdateICSContainer(keyValue);
  1143. if (!string.IsNullOrEmpty(msg))
  1144. {
  1145. return Error(msg);
  1146. }
  1147. else
  1148. {
  1149. return Success("修改成功!");
  1150. }
  1151. }
  1152. /// <summary>
  1153. /// 删除包装、容器
  1154. /// </summary>
  1155. /// <returns></returns>
  1156. [HttpPost]
  1157. [HandlerAjaxOnly]
  1158. [ValidateAntiForgeryToken]
  1159. public ActionResult DeleteICSContainer(string keyValue)
  1160. {
  1161. string msg = App.DeleteICSContainer(keyValue);
  1162. if (string.IsNullOrEmpty(msg))
  1163. {
  1164. return Success("删除成功!");
  1165. }
  1166. else
  1167. {
  1168. return Error(msg);
  1169. }
  1170. }
  1171. /// <summary>
  1172. /// 新增包装、容器
  1173. /// </summary>
  1174. /// <param name="keyValue"></param>
  1175. /// <returns></returns>
  1176. [HttpPost]
  1177. [HandlerAjaxOnly]
  1178. public ActionResult InsertICSContainerLot(string keyValue)
  1179. {
  1180. string msg = App.InsertICSContainerLot(keyValue);
  1181. if (!string.IsNullOrEmpty(msg))
  1182. {
  1183. return Error(msg);
  1184. }
  1185. else
  1186. {
  1187. return Success("添加成功!");
  1188. }
  1189. }
  1190. /// <summary>
  1191. /// 修改包装、容器
  1192. /// </summary>
  1193. /// <param name="keyValue"></param>
  1194. /// <returns></returns>
  1195. [HttpPost]
  1196. [HandlerAjaxOnly]
  1197. public ActionResult UpdateICSContainerLot(string keyValue)
  1198. {
  1199. string msg = App.UpdateICSContainerLot(keyValue);
  1200. if (!string.IsNullOrEmpty(msg))
  1201. {
  1202. return Error(msg);
  1203. }
  1204. else
  1205. {
  1206. return Success("修改成功!");
  1207. }
  1208. }
  1209. /// <summary>
  1210. /// 删除包装、容器关联
  1211. /// </summary>
  1212. /// <returns></returns>
  1213. [HttpPost]
  1214. [HandlerAjaxOnly]
  1215. [ValidateAntiForgeryToken]
  1216. public ActionResult DeleteICSContainerLot(string keyValue)
  1217. {
  1218. string msg = App.DeleteICSContainerLot(keyValue);
  1219. if (string.IsNullOrEmpty(msg))
  1220. {
  1221. return Success("删除成功!");
  1222. }
  1223. else
  1224. {
  1225. return Error(msg);
  1226. }
  1227. }
  1228. /// <summary>
  1229. /// 获取物料信息
  1230. /// </summary>
  1231. /// <returns></returns>
  1232. public ActionResult GetInvCode()
  1233. {
  1234. DataTable dt = App.GetInvCode();
  1235. return Content(dt.ToJson());
  1236. }
  1237. /// <summary>
  1238. /// 获取不良代码信息
  1239. /// </summary>
  1240. /// <returns></returns>
  1241. public ActionResult GetBCGroup()
  1242. {
  1243. DataTable dt = App.GetBCGroup();
  1244. return Content(dt.ToJson());
  1245. }
  1246. /// <summary>
  1247. /// 获取不良原因信息
  1248. /// </summary>
  1249. /// <returns></returns>
  1250. public ActionResult BRGroupID()
  1251. {
  1252. DataTable dt = App.BRGroupID();
  1253. return Content(dt.ToJson());
  1254. }
  1255. [HttpPost]
  1256. [HandlerAjaxOnly]
  1257. public ActionResult InsertInventoryBadGroup(string keyValue)
  1258. {
  1259. string msg = App.InsertInventoryBadGroup(keyValue);
  1260. if (!string.IsNullOrEmpty(msg))
  1261. {
  1262. return Error(msg);
  1263. }
  1264. else
  1265. {
  1266. return Success("添加成功!");
  1267. }
  1268. }
  1269. [HttpPost]
  1270. [HandlerAjaxOnly]
  1271. public ActionResult UpdateInventoryBadGroup(string keyValue)
  1272. {
  1273. string msg = App.UpdateInventoryBadGroup(keyValue);
  1274. if (!string.IsNullOrEmpty(msg))
  1275. {
  1276. return Error(msg);
  1277. }
  1278. else
  1279. {
  1280. return Success("修改成功!");
  1281. }
  1282. }
  1283. /// <summary>
  1284. /// 删除料品不良信息
  1285. /// </summary>
  1286. /// <returns></returns>
  1287. [HttpPost]
  1288. [HandlerAjaxOnly]
  1289. [ValidateAntiForgeryToken]
  1290. public ActionResult DeleteInventoryBadGroup(string keyValue)
  1291. {
  1292. string msg = App.DeleteInventoryBadGroup(keyValue);
  1293. if (string.IsNullOrEmpty(msg))
  1294. {
  1295. return Success("删除成功!");
  1296. }
  1297. else
  1298. {
  1299. return Error(msg);
  1300. }
  1301. }
  1302. #region 打印
  1303. /// <summary>
  1304. /// 打印数据参数:服务器的URL+打印的文件名,转化为Base64编码
  1305. /// </summary>
  1306. protected string strPrintData;
  1307. /// <summary>
  1308. /// 标识是否安装了控件
  1309. /// </summary>
  1310. protected bool bIsInstallPrintControl = true;
  1311. /// <summary>
  1312. /// 打印控件的Cookie值
  1313. /// </summary>
  1314. protected string strPrintControlCookie = "";
  1315. /// <summary>
  1316. /// 获取Url中去掉文件名的路径
  1317. /// </summary>
  1318. /// <returns></returns>
  1319. private string GetUrlPath()
  1320. {
  1321. string strUrl = Request.Url.ToString();
  1322. int iEnd = strUrl.LastIndexOf("/");
  1323. strUrl = strUrl.Substring(0, iEnd + 1);
  1324. return strUrl;
  1325. }
  1326. /// <summary>
  1327. /// 设置控件调用的Cookie值,判断是否安装了打印控件
  1328. /// </summary>
  1329. /// <param name="pJson"></param>
  1330. private void SetCookieAndURL(PrintJson pJson)
  1331. {
  1332. bIsInstallPrintControl = false;
  1333. strPrintControlCookie = "";
  1334. HttpCookie pCookieInstall = Request.Cookies["InstallPrintControl"];
  1335. if (pCookieInstall != null)
  1336. { //Cookie存在
  1337. strPrintControlCookie = pCookieInstall.Value.ToString();
  1338. //以Cookie值查找在数据表中是否存在
  1339. string strSql = @"Select * From sys_SRM_CheckInstall Where Cookie = @Cookie";
  1340. SqlParameter[] pmcCookie = { new SqlParameter("Cookie", strPrintControlCookie) };
  1341. using (SqlDataReader drCookie = DbHelper.ExecuteReader(DbHelper.ConnectionString, CommandType.Text, strSql, pmcCookie))
  1342. {
  1343. if (drCookie.Read())
  1344. { //标识为已经安装
  1345. bIsInstallPrintControl = true;
  1346. }
  1347. drCookie.Close();
  1348. }
  1349. //更新Cookie的保存时间
  1350. pCookieInstall.Expires = DateTime.Now.AddYears(10);
  1351. Response.SetCookie(pCookieInstall);
  1352. }
  1353. else
  1354. {//Cookie不存在,则新建Cookie
  1355. strPrintControlCookie = System.Guid.NewGuid().ToString();
  1356. pCookieInstall = new HttpCookie("InstallPrintControl", strPrintControlCookie);
  1357. pCookieInstall.Expires = DateTime.Now.AddYears(10);
  1358. Response.Cookies.Add(pCookieInstall);
  1359. }
  1360. string strUrl = Server.MapPath("/PrintTemp/") + "IsCheckInstall";
  1361. pJson.SetCookieAndURL(strPrintControlCookie, strUrl);
  1362. }
  1363. [HttpPost]
  1364. [HandlerAjaxOnly]
  1365. public ActionResult PrintStack(string keyValue)
  1366. {
  1367. keyValue = keyValue.Substring(1, keyValue.Length - 2);
  1368. string strPrintFileName = Server.MapPath("/ReportFile/") + "Stack.fr3";
  1369. PrintJson pJson = new PrintJson(Server.MapPath("./PrintTemp"), strPrintFileName);
  1370. pJson.CheckRegister("苏州智合诚信息科技有限公司", "56DD3B4C172D0D140841CAC98A58A819F4E28EDA5D6E45711DDD64F6A439F68B6A7870CD7DAFD69A919CB870207FE4BB206F92BE3D53C221B019E0797E739EBA4"); //注册信息
  1371. pJson.MasterOptions(1, "STNO", false); //主从关系
  1372. SetCookieAndURL(pJson);// 设置控件调用的Cookie值,判断是否安装了打印控件
  1373. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1374. string strSql = @"select a.LocationCode,
  1375. a.ID,
  1376. a.LocationName,
  1377. b.WarehouseCode,
  1378. b.WarehouseName,
  1379. a.Musername as 'MUSER',
  1380. a.MTIME
  1381. from ICSLocation a WITH (NOLOCK)
  1382. inner join ICSWarehouse b WITH (NOLOCK) on a.WHID=b.ID
  1383. where 1=1
  1384. and a.ID IN (" + keyValue.TrimEnd(',') + ")";
  1385. DataTable dtInInfo = DbHelper.ExecuteTable(DbHelper.ConnectionString, CommandType.Text, strSql, true, null);
  1386. // strSql = @"SELECT Row_Number() OVER (partition BY a.STNO ORDER BY a.CREATETIME DESC) AS rowno,c.STNO,
  1387. // c.PLANQTY,c.LotnoQTY,c.CartonNOQTY,c.ITEMCODE,b.INVNAME,b.INVSTD,b.INVPARSETYPE,d.StorageName,
  1388. // CONVERT(VARCHAR,CAST(ISNULL(c.Qty,0) AS money),1) AS Qty,
  1389. // CONVERT(VARCHAR,CAST(ISNULL(c.Meters,0) AS money),1) AS Meters,
  1390. // c.STNO AS QRSTNO,c.TransNO,c.TransLine,c.MEMO,c.VenderLotNO,CONVERT(varchar(10), c.PRODUCTDATE, 23) as PRODUCTDATE,a.remark
  1391. // FROM
  1392. // (SELECT aa.STNO,aa.ITEMCODE,aa.WorkPoint,SUM(aa.PLANQTY) PLANQTY,SUM(cc.LOTQTY) Qty,
  1393. // SUM(ISNULL(cc.Meters,0)) Meters,cc.TransNO,cc.TransLine,dd.MEMO,cc.VenderLotNO,cc.PRODUCTDATE,
  1394. // COUNT(aa.LOTNO) LotnoQTY,COUNT(bb.CartonNO) CartonNOQTY
  1395. // FROM ICSASNDETAIL aa
  1396. // LEFT JOIN ICSITEMLot2Carton bb ON aa.LOTNO = bb.LotNO AND aa.WorkPoint = bb.WorkPoint
  1397. // LEFT JOIN ICSITEMLot cc ON aa.LOTNO = cc.LotNO AND aa.WorkPoint = cc.WorkPoint
  1398. // LEFT JOIN ICSPO_PoMain dd on dd.POCode=cc.TransNO and dd.PORow=cc.TransLine
  1399. // GROUP BY aa.stno,aa.itemcode,aa.WorkPoint,cc.TransNO,cc.TransLine,dd.MEMO,cc.VenderLotNO,cc.PRODUCTDATE) c
  1400. // LEFT JOIN ICSASN a on c.stno=a.stno AND c.WorkPoint=a.WorkPoint
  1401. // LEFT JOIN dbo.ICSINVENTORY b ON c.ITEMCODE=b.INVCODE AND b.WorkPoint=c.WorkPoint
  1402. // LEFT JOIN dbo.icsstorage d ON b.INVMACHINETYPE=d.StorageCode
  1403. // WHERE c.STNO IN (" + keyValue.TrimEnd(',') + ") and c.WorkPoint='" + WorkPoint + "'";
  1404. // DataTable dtInMaterial = DbHelper.ExecuteTable(DbHelper.ConnectionString, CommandType.Text, strSql, true, null);
  1405. string strPrintTempFile = pJson.ShowReport(dtInInfo, null); //产生JSON文件内容
  1406. //把服务器的URL + 此文件名 传递给控件,由控件下载还原数据进行打印
  1407. string strServerURL = Server.MapPath("/PrintTemp/");
  1408. string strData = strServerURL + strPrintTempFile;
  1409. strPrintData = PrintFunction.EnBase64(strData);
  1410. var JsonData = new
  1411. {
  1412. strPrintData_1 = strPrintData,
  1413. bIsInstallPrintControl_1 = bIsInstallPrintControl,
  1414. strPrintControlCookie_1 = strPrintControlCookie
  1415. };
  1416. // string sql = @"UPDATE dbo.ICSASN
  1417. // SET ADDITION1=ISNULL(ADDITION1,0)+1,
  1418. // ADDITION2=CONVERT(varchar(100), GETDATE(), 21)
  1419. // WHERE STNO in (" + keyValue.TrimEnd(',') + ") and WorkPoint='" + WorkPoint + "'";
  1420. // SqlHelper.ExecuteNonQuery(sql);
  1421. return Content(JsonData.ToJson());
  1422. }
  1423. /// <summary>
  1424. /// 写日志(用于跟踪)
  1425. /// </summary>
  1426. private void WriteLog(string strMessage)
  1427. {
  1428. string strLogFile = Server.MapPath("./Cookie_Log.txt");
  1429. StreamWriter swLogFile = null;
  1430. try
  1431. {
  1432. if (!System.IO.File.Exists(strLogFile))
  1433. {
  1434. swLogFile = System.IO.File.CreateText(strLogFile);
  1435. }
  1436. else
  1437. {
  1438. swLogFile = System.IO.File.AppendText(strLogFile);
  1439. }
  1440. swLogFile.WriteLine(strMessage);
  1441. }
  1442. catch
  1443. {
  1444. }
  1445. finally
  1446. {
  1447. if (swLogFile != null)
  1448. swLogFile.Close();
  1449. }
  1450. }
  1451. /// <summary>
  1452. ///判断数据表中是否存在,若不存在则新建一条记录,若存在则更新最后访问的时间
  1453. /// </summary>
  1454. /// <param name="strCookie"></param>
  1455. private void UpdateCheckInstall(string strCookie)
  1456. {
  1457. bool bIsExist = false;
  1458. //判断记录是否存在
  1459. GetLastAccessTime(strCookie, ref bIsExist);
  1460. string strSql = "";
  1461. SqlParameter[] pmcCookie = { new SqlParameter("Cookie", strCookie) };
  1462. if (bIsExist)
  1463. { //存在则更新最后访问的时间
  1464. strSql = @"Update sys_SRM_CheckInstall
  1465. Set LastAccessTime = getDate()
  1466. Where Cookie = @Cookie";
  1467. }
  1468. else
  1469. { //不存在则新建一条记录
  1470. strSql = @"Insert into sys_SRM_CheckInstall(Cookie, LastAccessTime)
  1471. Values( @Cookie, getDate() )";
  1472. }
  1473. DbHelper.ExecuteNonQuery(DbHelper.ConnectionString, CommandType.Text, strSql, pmcCookie);
  1474. }
  1475. public DateTime ToDateTime(object SrcValue)
  1476. {
  1477. if (Convert.IsDBNull(SrcValue) == true)
  1478. return DateTime.MinValue;
  1479. else
  1480. {
  1481. try
  1482. {
  1483. return Convert.ToDateTime(SrcValue);
  1484. }
  1485. catch
  1486. {
  1487. return DateTime.MinValue;
  1488. }
  1489. }
  1490. }
  1491. /// <summary>
  1492. /// 获取此Cookie的最后访问时间
  1493. /// </summary>
  1494. /// <param name="strCookie"></param>
  1495. /// <returns></returns>
  1496. private DateTime GetLastAccessTime(string strCookie, ref bool bIsExist)
  1497. {
  1498. DateTime dtLastAccessTime = DateTime.MinValue;
  1499. bIsExist = false;
  1500. string strSql = @"Select * From sys_SRM_CheckInstall Where Cookie = @Cookie";
  1501. SqlParameter[] pmcCookie = { new SqlParameter("Cookie", strCookie) };
  1502. using (SqlDataReader drCookie = DbHelper.ExecuteReader(DbHelper.ConnectionString, CommandType.Text, strSql, pmcCookie))
  1503. {
  1504. if (drCookie.Read())
  1505. {
  1506. dtLastAccessTime = ToDateTime(drCookie["LastAccessTime"]);
  1507. bIsExist = true;
  1508. }
  1509. drCookie.Close();
  1510. }
  1511. return dtLastAccessTime;
  1512. }
  1513. [HttpGet]
  1514. [HandlerAjaxOnly]
  1515. public ActionResult IsCheckInstall(string checkInstall)
  1516. {
  1517. string strValue = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss 访问,");
  1518. if (Request.QueryString["cookie"] != null)
  1519. { //有控件上传的Cookie值
  1520. string strCookie = Request.QueryString["cookie"].ToString();
  1521. //判断数据表中是否存在,若不存在则新建一条记录,若存在则更新最后访问的时间
  1522. UpdateCheckInstall(strCookie);
  1523. strValue = strValue + "上传的cookie:" + strCookie;
  1524. }
  1525. else if (checkInstall != null)
  1526. {//Ajax检查控件是否安装了,防止那种客户把打印控件卸装了,打印时无法检测到的情况
  1527. string strCookie = checkInstall;
  1528. //读取最后访问的时间
  1529. string strResult = "PrintControlInstall";
  1530. bool bIsExist = false;
  1531. DateTime dtLastAccessTime = GetLastAccessTime(strCookie, ref bIsExist);
  1532. if (!bIsExist || dtLastAccessTime.AddSeconds(30) < DateTime.Now)
  1533. {
  1534. strResult = "NOT";
  1535. }
  1536. Response.Clear();
  1537. Response.Write(strResult);
  1538. strValue = strValue + "检测安装的值:" + strCookie;
  1539. }
  1540. WriteLog(strValue);
  1541. return null;
  1542. }
  1543. [HttpGet]
  1544. [HandlerAjaxOnly]
  1545. public ActionResult IsCheckInstall()
  1546. {
  1547. string strValue = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss 访问,");
  1548. if (Request.QueryString["cookie"] != null)
  1549. { //有控件上传的Cookie值
  1550. string strCookie = Request.QueryString["cookie"].ToString();
  1551. //判断数据表中是否存在,若不存在则新建一条记录,若存在则更新最后访问的时间
  1552. UpdateCheckInstall(strCookie);
  1553. strValue = strValue + "上传的cookie:" + strCookie;
  1554. }
  1555. else if (Request.QueryString["checkInstall"] != null)
  1556. {//Ajax检查控件是否安装了,防止那种客户把打印控件卸装了,打印时无法检测到的情况
  1557. string strCookie = Request.QueryString["checkInstall"];
  1558. //读取最后访问的时间
  1559. string strResult = "PrintControlInstall";
  1560. bool bIsExist = false;
  1561. DateTime dtLastAccessTime = GetLastAccessTime(strCookie, ref bIsExist);
  1562. if (!bIsExist || dtLastAccessTime.AddSeconds(30) < DateTime.Now)
  1563. {
  1564. strResult = "NOT";
  1565. }
  1566. Response.Clear();
  1567. Response.Write(strResult);
  1568. strValue = strValue + "检测安装的值:" + strCookie;
  1569. }
  1570. WriteLog(strValue);
  1571. return null;
  1572. }
  1573. #endregion
  1574. /// <summary>
  1575. /// 导入Excel
  1576. /// </summary>
  1577. /// <param name="fileURL"></param>
  1578. /// <returns></returns>
  1579. [HttpPost]
  1580. public ActionResult Import(string fileURL)
  1581. {
  1582. var fileName = "";
  1583. var filePath = fileURL;
  1584. string path = Path.Combine(filePath, fileName);
  1585. //file.SaveAs(path);
  1586. DataTable excelTable = new DataTable();
  1587. //excelTable =SqlHelper.GetExcelDataTable(path);
  1588. DataTable dbdata = new DataTable();
  1589. dbdata.Columns.Add("LocationCode");
  1590. dbdata.Columns.Add("LocationName");
  1591. dbdata.Columns.Add("Musername");
  1592. dbdata.Columns.Add("MUSER");
  1593. dbdata.Columns.Add("EATTRIBUTE1");
  1594. for (int i = 0; i < excelTable.Rows.Count; i++)
  1595. {
  1596. string LocationCode = "";
  1597. string LocationName = "";
  1598. DataRow dr = excelTable.Rows[i];
  1599. DataRow dr_ = dbdata.NewRow();
  1600. if (!string.IsNullOrWhiteSpace(dr["区"].ToString().ToUpper()))
  1601. {
  1602. LocationCode += "-" + dr["区"].ToString().ToUpper();
  1603. LocationName += dr["区"].ToString().ToUpper() + "区";
  1604. }
  1605. if (!string.IsNullOrWhiteSpace(dr["排"].ToString().ToUpper()))
  1606. {
  1607. LocationCode += "-" + dr["排"].ToString().ToUpper();
  1608. LocationName += dr["排"].ToString().ToUpper() + "排";
  1609. }
  1610. if (!string.IsNullOrWhiteSpace(dr["货架"].ToString().ToUpper()))
  1611. {
  1612. LocationCode += "-" + dr["货架"].ToString().ToUpper();
  1613. LocationName += dr["货架"].ToString().ToUpper() + "货架";
  1614. }
  1615. if (!string.IsNullOrWhiteSpace(dr["层"].ToString().ToUpper()))
  1616. {
  1617. LocationCode += "-" + dr["层"].ToString().ToUpper();
  1618. LocationName += dr["层"].ToString().ToUpper() + "层";
  1619. }
  1620. if (!string.IsNullOrWhiteSpace(dr["格"].ToString().ToUpper()))
  1621. {
  1622. LocationCode += "-" + dr["格"].ToString().ToUpper();
  1623. LocationName += dr["格"].ToString().ToUpper() + "格";
  1624. }
  1625. dr_["LocationCode"] = LocationCode;
  1626. dr_["LocationName"] = LocationName;
  1627. dr_["Musername"] = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1628. dr_["MUSER"] = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1629. dr_["Musername"] = "";
  1630. dbdata.Rows.Add(dr_);
  1631. }
  1632. SqlHelper.RemoveEmpty(dbdata);
  1633. SqlHelper.SqlBulkCopyByDatatable( "ICSLocation", dbdata);
  1634. return View();
  1635. }
  1636. //库位导入
  1637. [HttpPost]
  1638. /// <summary>
  1639. /// 文件上传到本地
  1640. /// </summary>
  1641. public string UploadFile()
  1642. {
  1643. try
  1644. {
  1645. HttpFileCollection hpFiles = System.Web.HttpContext.Current.Request.Files;
  1646. if (hpFiles != null && hpFiles.Count > 0)
  1647. {
  1648. string IsXls = System.IO.Path.GetExtension(hpFiles[0].FileName).ToString().ToLower();//System.IO.Path.GetExtension获得文件的扩展名
  1649. if (IsXls != ".xls" && IsXls != ".xlsx")
  1650. {
  1651. return "只可以选择Excel(.xls .xlsx)文件";//当选择的不是Excel文件时,返回
  1652. }
  1653. string filename = DateTime.Now.ToString("yyyyMMddhhmmss") + Guid.NewGuid() + IsXls; //获取Execle文件名 DateTime日期函数
  1654. string savePath = System.Web.HttpContext.Current.Server.MapPath("~\\File\\UPLoadFile\\" + filename);//Server.MapPath 获得虚拟服务器相对路径
  1655. int iLen = hpFiles[0].ContentLength;
  1656. if (Directory.Exists(savePath)) return "文件已存在";
  1657. byte[] bData = new byte[iLen];
  1658. hpFiles[0].InputStream.Read(bData, 0, iLen);
  1659. FileStream newFile = new FileStream(savePath, FileMode.OpenOrCreate);
  1660. newFile.Write(bData, 0, bData.Length);
  1661. newFile.Flush();
  1662. int _FileSizeTemp = hpFiles[0].ContentLength;
  1663. newFile.Close();
  1664. newFile.Dispose();
  1665. //bool del = false;
  1666. string mess = "";
  1667. mess = App.SetData_PR(savePath);
  1668. if (System.IO.File.Exists(savePath))//删除文件
  1669. {
  1670. System.IO.File.Delete(savePath);
  1671. }
  1672. return mess;
  1673. }
  1674. else
  1675. {
  1676. return "获取文件失败";
  1677. }
  1678. }
  1679. catch (Exception ex)
  1680. {
  1681. return ex.ToString();
  1682. }
  1683. }
  1684. /// <summary>
  1685. ///启用的料品库位绑定关系
  1686. /// </summary>
  1687. /// <returns></returns>
  1688. [HttpPost]
  1689. [HandlerAjaxOnly]
  1690. [ValidateAntiForgeryToken]
  1691. public ActionResult EnableInventoryLocation(string keyValue)
  1692. {
  1693. string msg = App.EnableInventoryLocation(keyValue);
  1694. if (string.IsNullOrEmpty(msg))
  1695. {
  1696. return Success("启用成功!");
  1697. }
  1698. else
  1699. {
  1700. return Error(msg);
  1701. }
  1702. }
  1703. [HttpPost]
  1704. [HandlerAjaxOnly]
  1705. [ValidateAntiForgeryToken]
  1706. public ActionResult ForbiddenInventoryLocation(string keyValue)
  1707. {
  1708. string msg = App.ForbiddenInventoryLocation(keyValue);
  1709. if (string.IsNullOrEmpty(msg))
  1710. {
  1711. return Success("禁用成功!");
  1712. }
  1713. else
  1714. {
  1715. return Error(msg);
  1716. }
  1717. }
  1718. /// <summary>
  1719. ///启用的料品仓库绑定关系
  1720. /// </summary>
  1721. /// <returns></returns>
  1722. [HttpPost]
  1723. [HandlerAjaxOnly]
  1724. [ValidateAntiForgeryToken]
  1725. public ActionResult EnableBatchEnable(string keyValue)
  1726. {
  1727. string msg = App.EnableBatchEnable(keyValue);
  1728. if (string.IsNullOrEmpty(msg))
  1729. {
  1730. return Success("启用成功!");
  1731. }
  1732. else
  1733. {
  1734. return Error(msg);
  1735. }
  1736. }
  1737. [HttpPost]
  1738. [HandlerAjaxOnly]
  1739. [ValidateAntiForgeryToken]
  1740. public ActionResult ForbiddenBatchEnable(string keyValue)
  1741. {
  1742. string msg = App.ForbiddenBatchEnable(keyValue);
  1743. if (string.IsNullOrEmpty(msg))
  1744. {
  1745. return Success("禁用成功!");
  1746. }
  1747. else
  1748. {
  1749. return Error(msg);
  1750. }
  1751. }
  1752. //新增标签数据源
  1753. [HttpPost]
  1754. [HandlerAjaxOnly]
  1755. public ActionResult CreateLableDataSource( string Sys_LableDataSource)
  1756. {
  1757. string msg = App.CreateLableDataSource(Sys_LableDataSource);
  1758. if (!string.IsNullOrEmpty(msg))
  1759. {
  1760. return Error(msg);
  1761. }
  1762. else
  1763. {
  1764. return Success("添加成功!");
  1765. }
  1766. }
  1767. [HttpGet]
  1768. [HandlerAjaxOnly]
  1769. public ActionResult GetTXT(string ID)
  1770. {
  1771. DataTable ListData = App.GetTXT(ID);
  1772. var JsonData = new
  1773. {
  1774. rows = ListData,
  1775. };
  1776. return Content(JsonData.ToJson());
  1777. }
  1778. //修改标签数据源
  1779. [HttpPost]
  1780. [HandlerAjaxOnly]
  1781. public ActionResult updateLableDataSource(string Sys_LableDataSource)
  1782. {
  1783. string msg = App.updateLableDataSource(Sys_LableDataSource);
  1784. if (!string.IsNullOrEmpty(msg))
  1785. {
  1786. return Error(msg);
  1787. }
  1788. else
  1789. {
  1790. return Success("添加成功!");
  1791. }
  1792. }
  1793. [HttpPost]
  1794. [HandlerAjaxOnly]
  1795. [ValidateAntiForgeryToken]
  1796. public ActionResult DeleteLableDataSource(string keyValue)
  1797. {
  1798. string msg = App.DeleteLableDataSource(keyValue);
  1799. if (string.IsNullOrEmpty(msg))
  1800. {
  1801. return Success("删除成功!");
  1802. }
  1803. else
  1804. {
  1805. return Error(msg);
  1806. }
  1807. }
  1808. [HttpGet]
  1809. [HandlerAjaxOnly]
  1810. public ActionResult GetLableType()
  1811. {
  1812. DataTable dt = App.GetLableType();
  1813. return Content(dt.ToJson());
  1814. }
  1815. [HttpGet]
  1816. [HandlerAjaxOnly]
  1817. public ActionResult GetSys_LablesID()
  1818. {
  1819. DataTable dt = App.GetSys_LablesID();
  1820. return Content(dt.ToJson());
  1821. }
  1822. //新增标签数据源
  1823. [HttpPost]
  1824. [HandlerAjaxOnly]
  1825. public ActionResult CreateLables(string txtLableName,string sel_LableType, string sel_LableSourceID )
  1826. {
  1827. string msg = App.CreateLables(txtLableName, sel_LableType, sel_LableSourceID);
  1828. if (!string.IsNullOrEmpty(msg))
  1829. {
  1830. return Error(msg);
  1831. }
  1832. else
  1833. {
  1834. return Success("添加成功!");
  1835. }
  1836. }
  1837. [HttpGet]
  1838. [HandlerAjaxOnly]
  1839. public ActionResult GetLabelTXT(string ID)
  1840. {
  1841. DataTable ListData = App.GetLabelTXT(ID);
  1842. var JsonData = new
  1843. {
  1844. rows = ListData,
  1845. };
  1846. return Content(JsonData.ToJson());
  1847. }
  1848. [HttpPost]
  1849. [HandlerAjaxOnly]
  1850. public ActionResult updateLables(string ID,string txtLableName, string sel_LableType, string sel_LableSourceID)
  1851. {
  1852. string msg = App.updateLables(ID,txtLableName, sel_LableType, sel_LableSourceID);
  1853. if (!string.IsNullOrEmpty(msg))
  1854. {
  1855. return Error(msg);
  1856. }
  1857. else
  1858. {
  1859. return Success("修改成功!");
  1860. }
  1861. }
  1862. [HttpPost]
  1863. [HandlerAjaxOnly]
  1864. [ValidateAntiForgeryToken]
  1865. public ActionResult DeleteICSLabelTemplate(string keyValue)
  1866. {
  1867. string msg = App.DeleteICSLabelTemplate(keyValue);
  1868. if (string.IsNullOrEmpty(msg))
  1869. {
  1870. return Success("删除成功!");
  1871. }
  1872. else
  1873. {
  1874. return Error(msg);
  1875. }
  1876. }
  1877. //获取父容器
  1878. [HttpGet]
  1879. [HandlerAjaxOnly]
  1880. public ActionResult GetContainerID()
  1881. {
  1882. DataTable dt = App.GetContainerID();
  1883. return Content(dt.ToJson());
  1884. }
  1885. [HttpPost]
  1886. public ActionResult UpLoadLabelFile()
  1887. {
  1888. //获取上传的文件集合
  1889. HttpFileCollection httpFile = System.Web.HttpContext.Current.Request.Files;
  1890. //获取送货单号
  1891. string ID = Request.Form["ID"].ToString();
  1892. string LableName = Request.Form["LableName"].ToString();
  1893. string fileName = Path.GetFileNameWithoutExtension(httpFile[0].FileName)
  1894. + "_" + LableName + Path.GetExtension(httpFile[0].FileName);
  1895. string filePath = System.Web.HttpContext.Current.Server.MapPath("~\\File\\LablesFile\\" + fileName);
  1896. int iLen = httpFile[0].ContentLength;
  1897. byte[] bData = new byte[iLen];
  1898. httpFile[0].InputStream.Read(bData, 0, iLen);
  1899. FileStream fs = new FileStream(filePath, FileMode.OpenOrCreate);
  1900. fs.Write(bData, 0, bData.Length);
  1901. fs.Flush();
  1902. fs.Close();
  1903. fs.Dispose();
  1904. int count = App.UpLoadLabelFile(ID, fileName);
  1905. if (count > 0)
  1906. {
  1907. return Success("上传成功!");
  1908. }
  1909. else
  1910. {
  1911. return Error("上传失败");
  1912. }
  1913. }
  1914. //包装容器
  1915. public ActionResult GetSendContainer(Pagination pagination, string queryJson)
  1916. {
  1917. DataTable ListData = App.GetSendContainer(ref pagination, queryJson);
  1918. var JsonData = new
  1919. {
  1920. total = pagination.total,
  1921. page = pagination.page,
  1922. records = pagination.records,
  1923. rows = ListData,
  1924. };
  1925. return Content(JsonData.ToJson());
  1926. }
  1927. [HttpGet]
  1928. [HandlerAjaxOnly]
  1929. public ActionResult GetContainerInfo(string Code)
  1930. {
  1931. DataTable ListData = App.GetContainerInfo(Code);
  1932. var JsonData = new
  1933. {
  1934. rows = ListData,
  1935. };
  1936. return Content(JsonData.ToJson());
  1937. }
  1938. [HttpGet]
  1939. [HandlerAjaxOnly]
  1940. public ActionResult GetBindContainerID(string SireCode)
  1941. {
  1942. DataTable ListData = App.GetBindContainerID(SireCode);
  1943. var JsonData = new
  1944. {
  1945. rows = ListData,
  1946. };
  1947. return Content(JsonData.ToJson());
  1948. }
  1949. [HttpPost]
  1950. [HandlerAjaxOnly]
  1951. public ActionResult BindingContainerID(string ICSMTDOC, string SireID)
  1952. {
  1953. string msg = App.BindingContainerID(ICSMTDOC, SireID);
  1954. if (!string.IsNullOrEmpty(msg))
  1955. {
  1956. return Error(msg);
  1957. }
  1958. else
  1959. {
  1960. return Success("绑定成功!");
  1961. }
  1962. }
  1963. //包装容器关联条码
  1964. public ActionResult GetSendContainerLot(Pagination pagination, string queryJson)
  1965. {
  1966. DataTable ListData = App.GetSendContainerLot(ref pagination, queryJson);
  1967. var JsonData = new
  1968. {
  1969. total = pagination.total,
  1970. page = pagination.page,
  1971. records = pagination.records,
  1972. rows = ListData,
  1973. };
  1974. return Content(JsonData.ToJson());
  1975. }
  1976. [HttpGet]
  1977. [HandlerAjaxOnly]
  1978. public ActionResult GetContainerLotInfo(string LotNo)
  1979. {
  1980. DataTable ListData = App.GetContainerLotInfo(LotNo);
  1981. var JsonData = new
  1982. {
  1983. rows = ListData,
  1984. };
  1985. return Content(JsonData.ToJson());
  1986. }
  1987. [HttpPost]
  1988. [HandlerAjaxOnly]
  1989. public ActionResult BindingContainerLotID(string ICSMTDOC, string SireID,string SireCode)
  1990. {
  1991. string msg = App.BindingContainerLotID(ICSMTDOC, SireID, SireCode);
  1992. if (!string.IsNullOrEmpty(msg))
  1993. {
  1994. return Error(msg);
  1995. }
  1996. else
  1997. {
  1998. return Success("绑定成功!");
  1999. }
  2000. }
  2001. }
  2002. }