MachineMaterialMstController.cs 2.6 KB

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