SqeController.cs 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. using Business.Sqe;
  2. using Business.StructuredDB;
  3. using Business.StructuredDB.Sqe;
  4. using Business.VSM;
  5. using Microsoft.AspNetCore.Mvc;
  6. using Microsoft.Extensions.Configuration;
  7. using Newtonsoft.Json;
  8. using Newtonsoft.Json.Linq;
  9. using NLog.Fluent;
  10. using System;
  11. using System.Collections.Generic;
  12. using System.Data;
  13. using System.Linq;
  14. using System.Threading.Tasks;
  15. using Volo.Abp;
  16. using Volo.Abp.AspNetCore.Mvc;
  17. namespace Business.Controllers
  18. {
  19. /// <summary>
  20. /// 价值流接口
  21. /// </summary>
  22. [RemoteService]
  23. [Area("Sqe")]
  24. [Route("api/business/sqe")]
  25. public class SqeController : AbpController
  26. {
  27. public IJwtService _jwtService { set; get; }
  28. private IConfiguration _configuration;
  29. private readonly ISqeExcelService _SqeExcelService;
  30. public SqeController(ISqeExcelService SqeExcelService, IJwtService jwtService, IConfiguration configuration)
  31. {
  32. _SqeExcelService = SqeExcelService;
  33. _jwtService = jwtService;
  34. _configuration = configuration;
  35. }
  36. private String CheckToken(string token)
  37. {
  38. try
  39. {
  40. JwtOptions jwtOptions = new JwtOptions();
  41. jwtOptions.ExpireSeconds = Convert.ToInt32(_configuration["JWT:ExpireSeconds"]);
  42. jwtOptions.Issuer = _configuration["JWT:Issuer"];
  43. jwtOptions.Audience = _configuration["JWT:Audience"];
  44. jwtOptions.Key = _configuration["JWT:Key"];
  45. String data = _jwtService.ValidateToken(token, jwtOptions);
  46. if (!string.IsNullOrEmpty(data))
  47. {
  48. return data;
  49. }
  50. }
  51. catch (Exception ex)
  52. {
  53. }
  54. return null;
  55. }
  56. [HttpGet]
  57. [Route("import_test")]
  58. public string Import_test(int file_id)
  59. {
  60. String s = _SqeExcelService.Import_Test_From_Data(file_id, "测试用户", DateTime.Now, "测试组织");
  61. return s;
  62. }
  63. [HttpGet]
  64. [Route("import_process")]
  65. public string Import_process(int file_id)
  66. {
  67. String s = _SqeExcelService.Import_Process_From_Data(file_id, "测试用户", DateTime.Now, "测试组织");
  68. return s;
  69. }
  70. [HttpGet]
  71. [Route("import_oqc")]
  72. public string Import_oqc(int file_id)
  73. {
  74. String s = _SqeExcelService.Import_Oqc_From_Data(file_id, "测试用户", DateTime.Now, "测试组织");
  75. return s;
  76. }
  77. [HttpGet]
  78. [Route("import_op")]
  79. public string Import_op(int file_id)
  80. {
  81. String s = _SqeExcelService.Import_Op_From_Data(file_id, "测试用户", DateTime.Now, "测试组织");
  82. return s;
  83. }
  84. [HttpGet]
  85. [Route("import_fpy")]
  86. public string Import_fpy(int file_id)
  87. {
  88. String s = _SqeExcelService.Import_Fpy_From_Data(file_id, "测试用户", DateTime.Now, "测试组织");
  89. return s;
  90. }
  91. [HttpGet]
  92. [Route("UploadProductionTestData")]
  93. public string Import_fct(String data, String token)
  94. {
  95. String userid = CheckToken(token);
  96. JObject json = new JObject();
  97. if (userid != null)
  98. {
  99. String s = _SqeExcelService.Import_Fct_From_Data(data, userid, DateTime.Now, userid);
  100. if (s == null || s.Length == 0)
  101. {
  102. json["resultCode"] = "OK";
  103. json["resultMessage"] = "成功";
  104. }
  105. else
  106. {
  107. json["resultCode"] = "NG";
  108. json["resultMessage"] = s;
  109. }
  110. return json.ToString();
  111. }
  112. else
  113. {
  114. json["resultCode"] = "NG";
  115. json["resultMessage"] = "传入配置未通过授权!";
  116. return json.ToString();
  117. }
  118. }
  119. }
  120. }