增加重置箱接口
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user