From a7158ac4b0c2632bf1ef55a85d9bcab3f37c09d7 Mon Sep 17 00:00:00 2001 From: liguoyang Date: Fri, 28 Jun 2024 17:18:16 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E7=BB=86=E8=8A=82=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Services/Implements/MiddleService.cs | 1 + .../Controllers/AssignmentsController.cs | 22 ++++++++++++++++++- .../Controllers/OrdersController.cs | 4 +--- .../Services/Implements/OrderService.cs | 2 +- 4 files changed, 24 insertions(+), 5 deletions(-) diff --git a/Src/Dlhis.Canteen/Order/Services/Implements/MiddleService.cs b/Src/Dlhis.Canteen/Order/Services/Implements/MiddleService.cs index 63c2ecaf..4c10d000 100644 --- a/Src/Dlhis.Canteen/Order/Services/Implements/MiddleService.cs +++ b/Src/Dlhis.Canteen/Order/Services/Implements/MiddleService.cs @@ -21,6 +21,7 @@ public class MiddleService : IMiddleService public async Task MiddleUploadAsync(BalanceRecordEntity entity) { entity.Id = 0; + entity.Amount = -Math.Abs(entity.Amount); if (!await _dbContext.Queryable().AnyAsync(x => x.No == entity.No)) { await _dbContext.InsertAsync(entity); diff --git a/Src/Dlhis.Middle/Controllers/AssignmentsController.cs b/Src/Dlhis.Middle/Controllers/AssignmentsController.cs index 86107959..5dfaa784 100644 --- a/Src/Dlhis.Middle/Controllers/AssignmentsController.cs +++ b/Src/Dlhis.Middle/Controllers/AssignmentsController.cs @@ -2,6 +2,7 @@ using Dlhis.Middle.Api; using Dlhis.Middle.Request; using Dlhis.Middle.Response; +using Dlhis.Middle.Services; using Kurisu.AspNetCore.DataAccess.SqlSugar.Aop; using Kurisu.AspNetCore.UnifyResultAndValidation; using Microsoft.AspNetCore.Mvc; @@ -18,11 +19,13 @@ namespace Dlhis.Middle.Controllers; public class AssignmentsController : ControllerBase { private readonly IAssignmentDeviceTaskApi _assignmentDeviceTaskApi; + private readonly IHealthCheckService _healthCheckService; private readonly string _internalIp; - public AssignmentsController(IAssignmentDeviceTaskApi assignmentDeviceTaskApi, IConfiguration configuration) + public AssignmentsController(IAssignmentDeviceTaskApi assignmentDeviceTaskApi, IConfiguration configuration, IHealthCheckService healthCheckService) { _assignmentDeviceTaskApi = assignmentDeviceTaskApi; + _healthCheckService = healthCheckService; _internalIp = configuration.GetSection("InternalIP").Value; } @@ -34,6 +37,14 @@ public class AssignmentsController : ControllerBase [HttpGet("deviceTasks")] public async Task>> DeviceGetTasksGetAsync([FromQuery] DeviceTaskGetRequest request) { + if (_healthCheckService.GetIsOffline()) + { + return new DefaultApiResult> + { + Data = new List() + }; + } + var result = await _assignmentDeviceTaskApi.DeviceGetTasksAsync(request); foreach (var data in result.Data) { @@ -48,6 +59,7 @@ public class AssignmentsController : ControllerBase } return result; + } /// @@ -58,6 +70,14 @@ public class AssignmentsController : ControllerBase [IgnoreTenant] public async Task>> DeviceGetTasksPostAsync(DeviceTaskGetRequest request) { + if (_healthCheckService.GetIsOffline()) + { + return new DefaultApiResult> + { + Data = new List() + }; + } + var result = await _assignmentDeviceTaskApi.DeviceGetTasksAsync(request); foreach (var data in result.Data) { diff --git a/Src/Dlhis.Middle/Controllers/OrdersController.cs b/Src/Dlhis.Middle/Controllers/OrdersController.cs index 9e379662..cb313e7f 100644 --- a/Src/Dlhis.Middle/Controllers/OrdersController.cs +++ b/Src/Dlhis.Middle/Controllers/OrdersController.cs @@ -1,5 +1,4 @@ -using Dlhis.Middle.Api; -using Dlhis.Middle.Request; +using Dlhis.Middle.Request; using Dlhis.Middle.Response; using Dlhis.Middle.Services; using Kurisu.AspNetCore.DataAccess.SqlSugar.Aop; @@ -32,6 +31,5 @@ public class OrdersController : ControllerBase public async Task> AddAsync(OrderAddRequest request) { return await _orderService.AddAsync(request); - } } \ No newline at end of file diff --git a/Src/Dlhis.Middle/Services/Implements/OrderService.cs b/Src/Dlhis.Middle/Services/Implements/OrderService.cs index 4fdfacdc..bf505c88 100644 --- a/Src/Dlhis.Middle/Services/Implements/OrderService.cs +++ b/Src/Dlhis.Middle/Services/Implements/OrderService.cs @@ -151,7 +151,7 @@ public class OrderService : IOrderService Source = request.Source, UserNo = gainfo.No, UserCode = gainfo.Code, - Amount = request.Amount, + Amount = -Math.Abs(request.Amount), BusinessPlaceCode = businessPlaceInfo?.Code, BusinessShiftCode = shift?.ShiftCode, ShiftType = shift?.ShiftType,