|
|
|
@ -4,7 +4,9 @@ using DS.Module.User;
|
|
|
|
|
using DS.WMS.Core.WxModule.Dtos;
|
|
|
|
|
using DS.WMS.Core.WxModule.Entity;
|
|
|
|
|
using DS.WMS.Core.WxModule.Interface;
|
|
|
|
|
using Microsoft.AspNetCore.Hosting;
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
using MiniExcelLibs;
|
|
|
|
|
using SqlSugar;
|
|
|
|
|
|
|
|
|
|
namespace DS.WMS.Core.WxModule.Method;
|
|
|
|
@ -17,7 +19,7 @@ public class WxQueryService : IWxQueryService
|
|
|
|
|
private readonly IServiceProvider _serviceProvider;
|
|
|
|
|
private readonly ISqlSugarClient db;
|
|
|
|
|
private readonly IUser user;
|
|
|
|
|
|
|
|
|
|
private readonly IWebHostEnvironment _environment;
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
@ -27,6 +29,7 @@ public class WxQueryService : IWxQueryService
|
|
|
|
|
_serviceProvider = serviceProvider;
|
|
|
|
|
db = _serviceProvider.GetRequiredService<ISqlSugarClient>();
|
|
|
|
|
user = _serviceProvider.GetRequiredService<IUser>();
|
|
|
|
|
_environment = _serviceProvider.GetRequiredService<IWebHostEnvironment>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -85,4 +88,78 @@ public class WxQueryService : IWxQueryService
|
|
|
|
|
return DataResult.Failed("非法租户!");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 导出库存列表
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="request"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public DataResult ExportStockList(StockQueryModel request)
|
|
|
|
|
{
|
|
|
|
|
var tenantId = user.GetTenantId();
|
|
|
|
|
var userId = user.UserId;
|
|
|
|
|
//虎鲸
|
|
|
|
|
if (tenantId == "1595354960864874496")
|
|
|
|
|
{
|
|
|
|
|
var HJdb = db.AsTenant().GetConnection(tenantId);
|
|
|
|
|
|
|
|
|
|
var userinfo = db.Queryable<WxUser>().Where(x => x.Id == userId).First();
|
|
|
|
|
|
|
|
|
|
if (userinfo.AuditStatus != 1)
|
|
|
|
|
{
|
|
|
|
|
return DataResult.Failed("用户未审核,请及时联系管理员!");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (userinfo.InfoClient.IsNullOrEmpty())
|
|
|
|
|
{
|
|
|
|
|
return DataResult.Failed("未指定客户,请及时联系管理员!");
|
|
|
|
|
}
|
|
|
|
|
var data = HJdb.Queryable<WmsStockTake>()
|
|
|
|
|
.Where(x => x.CUSTOMERNAME == userinfo.InfoClient)//查询绑定客户
|
|
|
|
|
.WhereIF(!request.BLNO.IsNullOrEmpty(), a => a.BLNO.Contains(request.BLNO.Trim()))
|
|
|
|
|
.WhereIF(!request.GOODSNAME.IsNullOrEmpty(), a => a.GOODSNAME.Contains(request.GOODSNAME.Trim()))
|
|
|
|
|
.WhereIF(!request.CONTRACTNO.IsNullOrEmpty(), a => a.CONTRACTNO.Contains(request.CONTRACTNO.Trim()))
|
|
|
|
|
// .WhereIF(request.StockStatus != 0,
|
|
|
|
|
// a => request.StockStatus == 1 ? a.hj_GOODSPACKSTOCK != 0 : a.hj_GOODSPACKSTOCK == 0)
|
|
|
|
|
.WhereIF(request.StockStatus == 1,
|
|
|
|
|
a => a.hj_GOODSPACKSTOCK != 0)
|
|
|
|
|
.WhereIF(request.StockStatus == 2,
|
|
|
|
|
a => a.hj_GOODSPACKSTOCK == 0)
|
|
|
|
|
.OrderBy(x => x.WMSDATE, OrderByType.Desc)
|
|
|
|
|
.Select<WmsStockViewModel>()
|
|
|
|
|
.Mapper(it =>
|
|
|
|
|
{
|
|
|
|
|
//只能写在Select后面
|
|
|
|
|
it.KeFaHuo = it.GOODSNUM -it.hj_GOODSPACKPFSL;
|
|
|
|
|
})
|
|
|
|
|
.ToList();
|
|
|
|
|
if (data.Count == 0)
|
|
|
|
|
{
|
|
|
|
|
return DataResult.Failed("查询数据记录为空!");
|
|
|
|
|
}
|
|
|
|
|
var filename = Guid.NewGuid() + ".xlsx";
|
|
|
|
|
var path = Path.Combine(_environment.WebRootPath, "export/" + filename);
|
|
|
|
|
var values = new List<Dictionary<string, object>>();
|
|
|
|
|
foreach (var item in data)
|
|
|
|
|
{
|
|
|
|
|
var info = new Dictionary<string, object>
|
|
|
|
|
{
|
|
|
|
|
{ "品名", item.GOODSNAME },
|
|
|
|
|
{ "提单号", item.BLNO },
|
|
|
|
|
{ "合同号", item.CONTRACTNO },
|
|
|
|
|
{ "入库件数", item.hj_GOODSPACK },
|
|
|
|
|
{ "库存件数", item.hj_GOODSPACKSTOCK },
|
|
|
|
|
{ "未完税件数", item.WeiWanShui },
|
|
|
|
|
{ "可发货件数", item.KeFaHuo},
|
|
|
|
|
};
|
|
|
|
|
values.Add(info);
|
|
|
|
|
}
|
|
|
|
|
MiniExcel.SaveAs(path, values);
|
|
|
|
|
|
|
|
|
|
return DataResult.Successed("导出成功", filename);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return DataResult.Failed("非法租户!");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|