增加重置箱接口

This commit is contained in:
18942506660
2024-05-15 15:17:02 +08:00
parent 5d31f820e0
commit e4dea40c01
8 changed files with 174 additions and 5 deletions

View File

@@ -1,6 +1,7 @@
using AutoMapper;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Storage;
using NPOI.OpenXmlFormats.Spreadsheet;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -177,5 +178,36 @@ namespace WMS.Web.Repositories
return res.Clone();
}
/// <summary>
/// 批量删除
/// </summary>
/// <param name="billNos"></param>
/// <param name="isTransaction"></param>
/// <returns></returns>
/// <exception cref="NotImplementedException"></exception>
public async Task<bool> DeleteEntityList(List<int> boxIds, bool isTransaction = true)
{
IDbContextTransaction _transaction = null;
if (isTransaction)
_transaction = _context.Database.BeginTransaction();
try
{
var res = await _context.Box
.Include(s => s.Details)
.Where(f => boxIds.Contains(f.Id)).ToListAsync();
_context.Box.RemoveRange(res);
await _context.SaveChangesAsync();
if (_transaction != null)
_transaction.Commit();
}
catch (Exception ex)
{
if (_transaction != null)
_transaction.Rollback();
return false;
}
return true;
}
}
}

View File

@@ -47,7 +47,7 @@ namespace WMS.Web.Repositories.DependencyInjection
string authorization = context.Request.Headers["Authorization"];
string path = context.Request.Path.Value.ToLower();
string[] pathlist = path.Split('/');
bool isLogin = pathlist.Where(x => x == "login" || x.ToLower() == "heart" || x.ToLower() == "test" || x.ToLower() == "serialnumber").Any();
bool isLogin = pathlist.Where(x => x == "login" || x.ToLower() == "heart" || x.ToLower() == "test" || x.ToLower() == "serialnumber" || x.ToLower() == "barcode").Any();
if (isLogin)
{
context.Response.StatusCode = 200;
@@ -121,14 +121,14 @@ namespace WMS.Web.Repositories.DependencyInjection
{
jiange_timespan = now - logininfo.TokenInfo.Expired;
var info = _redisClientService.GetStringKey<LoginInDto>($"wms_login_{token}");
if (info != null)
{
//超过16个小时的就要移除缓存
if (jiange_timespan.TotalHours >= 16)
_redisClientService.RemoveStringKey($"wms_login_{token}");
//超过1个小时的就要刷新token
else if (!string.IsNullOrEmpty(logininfo.TokenInfo.Token) && jiange_timespan.TotalHours>=1)
else if (!string.IsNullOrEmpty(logininfo.TokenInfo.Token) && jiange_timespan.TotalHours >= 1)
this.RefreshToken(logininfo.TokenInfo.Token, logininfo.TokenInfo.RefreshToken, loginService);
}
@@ -140,7 +140,7 @@ namespace WMS.Web.Repositories.DependencyInjection
// if (!string.IsNullOrEmpty(logininfo.TokenInfo.Token) && jiange_timespan.TotalMinutes<=10)
// this.RefreshToken(logininfo.TokenInfo.Token, logininfo.TokenInfo.RefreshToken, loginService);
//}
//3.验证检查是否有黑名单的token缓存
string blacktoken = _redisClientService.GetStringKey($"wms_black_token_{logininfo.UserInfo.UcId}");
if (string.IsNullOrEmpty(blacktoken))
@@ -157,7 +157,7 @@ namespace WMS.Web.Repositories.DependencyInjection
await context.Response.WriteAsync(result);
}
}
}
}

View File

@@ -379,5 +379,34 @@ namespace WMS.Web.Repositories
return _mapper.Map<List<SerialNumbers>>(res.Clone());
}
/// <summary>
/// 根据箱id批量删除
/// </summary>
/// <param name="boxIds"></param>
/// <param name="isTransaction"></param>
/// <returns></returns>
public async Task<bool> DeleteEntityList(List<int> boxIds, bool isTransaction = true)
{
IDbContextTransaction _transaction = null;
if (isTransaction)
_transaction = _context.Database.BeginTransaction();
try
{
var res = await _context.SerialNumbers
.Where(f => boxIds.Contains(f.BoxId)).ToListAsync();
_context.SerialNumbers.RemoveRange(res);
await _context.SaveChangesAsync();
if (_transaction != null)
_transaction.Commit();
}
catch (Exception ex)
{
if (_transaction != null)
_transaction.Rollback();
return false;
}
return true;
}
}
}