MachineMaterialMstController.cs 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. using Cksoft.Data;
  2. using Cksoft.Data.Repository;
  3. using Cksoft.Unity;
  4. using Cksoft.Unity.Log4NetConfig;
  5. using DllEapDal.OFILM;
  6. using DllEapEntity.OFILM;
  7. using Microsoft.AspNetCore.Mvc;
  8. using Microsoft.Extensions.Configuration;
  9. using System;
  10. using System.Collections.Generic;
  11. using System.Linq;
  12. using System.Threading.Tasks;
  13. namespace WebApplet.Controllers
  14. {
  15. [Route("eap/api/[controller]/[action]")]
  16. public class MachineMaterialMstController : ControllerBase
  17. {
  18. //public IActionResult Index()
  19. //{
  20. // return View();
  21. //}
  22. public IConfiguration Configuration { get; set; }
  23. public MachineMaterialMstController(IConfiguration configuration)
  24. {
  25. Configuration = configuration;
  26. }
  27. [HttpPost]
  28. public EapResponse Upload([FromBody] EapMacUploadModel uploadInfo)
  29. {
  30. var res = new EapResponse { Code = 1, Msg = string.Empty };
  31. string errorinfo = string.Empty;
  32. if (uploadInfo == null || uploadInfo.Files == null || uploadInfo.Files.Count() <= 0)
  33. {
  34. res.Code = -1;
  35. res.Msg = "上传内容为空";
  36. return res;
  37. }
  38. var service = new MachineMaterialService();
  39. if (service.UploadTrans(uploadInfo, ref errorinfo) < 0)
  40. {
  41. res.Code = -1;
  42. res.Msg = errorinfo;
  43. return res;
  44. }
  45. res.Msg = errorinfo;
  46. return res;
  47. }
  48. [HttpPost]
  49. public EapResponse UploadLHA([FromBody] LHAMachineModel uploadInfo)
  50. {
  51. LogHelper<MachineMaterialService>.LogError($"准备", "LHA数据采集", string.Empty);
  52. var res = new EapResponse { Code = 1, Msg = string.Empty };
  53. string errorinfo = string.Empty;
  54. if (uploadInfo == null || uploadInfo.Postbondviews == null || uploadInfo.Postbondviews.Count() <= 0)
  55. {
  56. res.Code = -1;
  57. res.Msg = "上传内容为空";
  58. return res;
  59. }
  60. var service = new MachineMaterialService();
  61. if (service.UploadTableTrans(uploadInfo, ref errorinfo) < 0)
  62. {
  63. res.Code = -1;
  64. res.Msg = errorinfo;
  65. return res;
  66. }
  67. return res;
  68. }
  69. public string GetPostbondViewMaxTime(string macCode)
  70. {
  71. using (IDatabase db = DbFactory.Base("eap"))
  72. {
  73. var dal = new CodelinkDal(db);
  74. string errorinfo = "";
  75. return dal.GetPostbondView(macCode, ref errorinfo);
  76. }
  77. }
  78. [HttpGet]
  79. public IEnumerable<MachineMaterialMst> Get(string filter)
  80. {
  81. using (IDatabase db = DbFactory.Base("eapslave"))
  82. {
  83. var dal = new MachineMaterialMstDal(db);
  84. string errorinfo = "";
  85. return dal.Get(filter,ref errorinfo);
  86. }
  87. }
  88. }
  89. }