集成,总结MES功能
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.
 
 
 
 

88 lines
2.2 KiB

  1. using System;
  2. using System.Threading.Tasks;
  3. using BPA.AGV;
  4. using BPA.ApiClient;
  5. using BPA.MES.Base.Application;
  6. using BPA.MES.Base.Application.Subscriber;
  7. using BPA.MES.Base.Core;
  8. using BPA.MQTTClient;
  9. using Furion;
  10. using Microsoft.AspNetCore.Builder;
  11. using Microsoft.AspNetCore.Hosting;
  12. using Microsoft.Extensions.DependencyInjection;
  13. using Microsoft.Extensions.Hosting;
  14. using MQTTnet.Client;
  15. using MQTTnet.Client.Connecting;
  16. using MQTTnet.Client.Disconnecting;
  17. using MQTTnet.Client.Options;
  18. using Newtonsoft.Json.Linq;
  19. using Yitter.IdGenerator;
  20. namespace BPA.MES.Base.Web.Core;
  21. public class Startup : AppStartup
  22. {
  23. public void ConfigureServices(IServiceCollection services)
  24. {
  25. services.AddConsoleFormatter();
  26. services.AddJwt<JwtHandler>(enableGlobalAuthorize: true);
  27. services.AddCorsAccessor();
  28. services.AddSqlsugarSetup(App.Configuration);
  29. // 配置雪花Id算法机器码
  30. YitIdHelper.SetIdGenerator(new IdGeneratorOptions
  31. {
  32. WorkerId = 5
  33. });
  34. // 注册 EventBus 服务
  35. services.AddEventBus(builder =>
  36. {
  37. // 通过类型注册
  38. builder.AddSubscriber(typeof(ToDoEventSubscriber));
  39. });
  40. services.AddRemoteRequest();
  41. services.AddWebApiClient();
  42. services.AddAGV(op =>
  43. {
  44. op.Header = new KCOption()
  45. {
  46. AppKey = "43",
  47. AppSecret = "12",
  48. RequestId = "43",
  49. Timestamp = "2234234324",
  50. Version = "2.9"
  51. };
  52. op.Sign = "123456";
  53. });
  54. services.AddControllers()
  55. .AddInjectWithUnifyResult();
  56. }
  57. public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
  58. {
  59. if (env.IsDevelopment())
  60. {
  61. app.UseDeveloperExceptionPage();
  62. }
  63. app.UseHttpsRedirection();
  64. app.UseStaticFiles();
  65. app.UseRouting();
  66. app.UseCorsAccessor();
  67. app.UseAuthentication();
  68. app.UseAuthorization();
  69. app.UseInject("swagger");
  70. app.UseEndpoints(endpoints =>
  71. {
  72. endpoints.MapControllers();
  73. });
  74. }
  75. }