fix 细节调整

This commit is contained in:
2024-06-28 17:18:16 +08:00
parent 17699e0c6c
commit a7158ac4b0
4 changed files with 24 additions and 5 deletions

View File

@@ -21,6 +21,7 @@ public class MiddleService : IMiddleService
public async Task<OrderResultResponse> MiddleUploadAsync(BalanceRecordEntity entity) public async Task<OrderResultResponse> MiddleUploadAsync(BalanceRecordEntity entity)
{ {
entity.Id = 0; entity.Id = 0;
entity.Amount = -Math.Abs(entity.Amount);
if (!await _dbContext.Queryable<BalanceRecordEntity>().AnyAsync(x => x.No == entity.No)) if (!await _dbContext.Queryable<BalanceRecordEntity>().AnyAsync(x => x.No == entity.No))
{ {
await _dbContext.InsertAsync(entity); await _dbContext.InsertAsync(entity);

View File

@@ -2,6 +2,7 @@
using Dlhis.Middle.Api; using Dlhis.Middle.Api;
using Dlhis.Middle.Request; using Dlhis.Middle.Request;
using Dlhis.Middle.Response; using Dlhis.Middle.Response;
using Dlhis.Middle.Services;
using Kurisu.AspNetCore.DataAccess.SqlSugar.Aop; using Kurisu.AspNetCore.DataAccess.SqlSugar.Aop;
using Kurisu.AspNetCore.UnifyResultAndValidation; using Kurisu.AspNetCore.UnifyResultAndValidation;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
@@ -18,11 +19,13 @@ namespace Dlhis.Middle.Controllers;
public class AssignmentsController : ControllerBase public class AssignmentsController : ControllerBase
{ {
private readonly IAssignmentDeviceTaskApi _assignmentDeviceTaskApi; private readonly IAssignmentDeviceTaskApi _assignmentDeviceTaskApi;
private readonly IHealthCheckService _healthCheckService;
private readonly string _internalIp; private readonly string _internalIp;
public AssignmentsController(IAssignmentDeviceTaskApi assignmentDeviceTaskApi, IConfiguration configuration) public AssignmentsController(IAssignmentDeviceTaskApi assignmentDeviceTaskApi, IConfiguration configuration, IHealthCheckService healthCheckService)
{ {
_assignmentDeviceTaskApi = assignmentDeviceTaskApi; _assignmentDeviceTaskApi = assignmentDeviceTaskApi;
_healthCheckService = healthCheckService;
_internalIp = configuration.GetSection("InternalIP").Value; _internalIp = configuration.GetSection("InternalIP").Value;
} }
@@ -34,6 +37,14 @@ public class AssignmentsController : ControllerBase
[HttpGet("deviceTasks")] [HttpGet("deviceTasks")]
public async Task<DefaultApiResult<List<DeviceTaskToDeviceByDeviceResponse>>> DeviceGetTasksGetAsync([FromQuery] DeviceTaskGetRequest request) public async Task<DefaultApiResult<List<DeviceTaskToDeviceByDeviceResponse>>> DeviceGetTasksGetAsync([FromQuery] DeviceTaskGetRequest request)
{ {
if (_healthCheckService.GetIsOffline())
{
return new DefaultApiResult<List<DeviceTaskToDeviceByDeviceResponse>>
{
Data = new List<DeviceTaskToDeviceByDeviceResponse>()
};
}
var result = await _assignmentDeviceTaskApi.DeviceGetTasksAsync(request); var result = await _assignmentDeviceTaskApi.DeviceGetTasksAsync(request);
foreach (var data in result.Data) foreach (var data in result.Data)
{ {
@@ -48,6 +59,7 @@ public class AssignmentsController : ControllerBase
} }
return result; return result;
} }
/// <summary> /// <summary>
@@ -58,6 +70,14 @@ public class AssignmentsController : ControllerBase
[IgnoreTenant] [IgnoreTenant]
public async Task<DefaultApiResult<List<DeviceTaskToDeviceByDeviceResponse>>> DeviceGetTasksPostAsync(DeviceTaskGetRequest request) public async Task<DefaultApiResult<List<DeviceTaskToDeviceByDeviceResponse>>> DeviceGetTasksPostAsync(DeviceTaskGetRequest request)
{ {
if (_healthCheckService.GetIsOffline())
{
return new DefaultApiResult<List<DeviceTaskToDeviceByDeviceResponse>>
{
Data = new List<DeviceTaskToDeviceByDeviceResponse>()
};
}
var result = await _assignmentDeviceTaskApi.DeviceGetTasksAsync(request); var result = await _assignmentDeviceTaskApi.DeviceGetTasksAsync(request);
foreach (var data in result.Data) foreach (var data in result.Data)
{ {

View File

@@ -1,5 +1,4 @@
using Dlhis.Middle.Api; using Dlhis.Middle.Request;
using Dlhis.Middle.Request;
using Dlhis.Middle.Response; using Dlhis.Middle.Response;
using Dlhis.Middle.Services; using Dlhis.Middle.Services;
using Kurisu.AspNetCore.DataAccess.SqlSugar.Aop; using Kurisu.AspNetCore.DataAccess.SqlSugar.Aop;
@@ -32,6 +31,5 @@ public class OrdersController : ControllerBase
public async Task<DefaultApiResult<OrderResultResponse>> AddAsync(OrderAddRequest request) public async Task<DefaultApiResult<OrderResultResponse>> AddAsync(OrderAddRequest request)
{ {
return await _orderService.AddAsync(request); return await _orderService.AddAsync(request);
} }
} }

View File

@@ -151,7 +151,7 @@ public class OrderService : IOrderService
Source = request.Source, Source = request.Source,
UserNo = gainfo.No, UserNo = gainfo.No,
UserCode = gainfo.Code, UserCode = gainfo.Code,
Amount = request.Amount, Amount = -Math.Abs(request.Amount),
BusinessPlaceCode = businessPlaceInfo?.Code, BusinessPlaceCode = businessPlaceInfo?.Code,
BusinessShiftCode = shift?.ShiftCode, BusinessShiftCode = shift?.ShiftCode,
ShiftType = shift?.ShiftType, ShiftType = shift?.ShiftType,