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

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