优化wms项目目录结构
This commit is contained in:
@@ -2,9 +2,11 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Aspose.Cells.Drawing;
|
||||
using Dm;
|
||||
using JNPF.Common.Contracts;
|
||||
using JNPF.Common.Enums;
|
||||
using JNPF.Common.Extension;
|
||||
@@ -13,6 +15,7 @@ using JNPF.DependencyInjection;
|
||||
using JNPF.DynamicApiController;
|
||||
using JNPF.Extras.CollectiveOAuth.Config;
|
||||
using JNPF.FriendlyException;
|
||||
using JNPF.Systems.Interfaces.System;
|
||||
using Mapster;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
@@ -25,7 +28,9 @@ using Tnb.BasicData.Entities;
|
||||
using Tnb.BasicData.Entities.Enums;
|
||||
using Tnb.Common.Utils;
|
||||
using Tnb.WarehouseMgr.Entities;
|
||||
using Tnb.WarehouseMgr.Entities.Consts;
|
||||
using Tnb.WarehouseMgr.Entities.Dto;
|
||||
using Tnb.WarehouseMgr.Entities.Dto.Inputs;
|
||||
using Tnb.WarehouseMgr.Entities.Enums;
|
||||
using Tnb.WarehouseMgr.Interfaces;
|
||||
|
||||
@@ -34,14 +39,14 @@ namespace Tnb.WarehouseMgr
|
||||
/// <summary>
|
||||
/// 库房业务类(出入库)
|
||||
/// </summary>
|
||||
[ApiDescriptionSettings(Tag = ModuleConsts.Tag, Area = ModuleConsts.Area, Order = 700)]
|
||||
[Route("api/[area]/[controller]/[action]")]
|
||||
public class WareHouseService : IWareHouseService, IDynamicApiController, ITransient
|
||||
public class WareHouseService : BaseWareHouseService, IWareHouseService
|
||||
{
|
||||
private readonly ISqlSugarClient _db;
|
||||
public WareHouseService(ISqlSugarRepository<WmsInstockH> repository)
|
||||
private readonly IDictionaryDataService _dictionaryDataService;
|
||||
public WareHouseService(ISqlSugarRepository<WmsInstockH> repository, IDictionaryDataService dictionaryDataService)
|
||||
{
|
||||
_db = repository.AsSugarClient();
|
||||
_dictionaryDataService = dictionaryDataService;
|
||||
}
|
||||
/// <summary>
|
||||
/// 根据载具Id带出库位、仓库信息
|
||||
@@ -93,26 +98,34 @@ namespace Tnb.WarehouseMgr
|
||||
case EnumInOutStockType.In:
|
||||
var wmsInstockD = input.Adapt<WmsInstockD>();
|
||||
var wmsInstockCodes = input.InstockCodes.Adapt<List<WmsInstockCode>>();
|
||||
wmsInstockCodes.ForEach(x =>
|
||||
if (wmsInstockCodes?.Count > 0)
|
||||
{
|
||||
if (x.id.IsNullOrWhiteSpace())
|
||||
wmsInstockCodes.ForEach(x =>
|
||||
{
|
||||
x.id = SnowflakeIdHelper.NextId();
|
||||
}
|
||||
});
|
||||
isOk = await _update<WmsInstockD, WmsInstockCode>(wmsInstockD, wmsInstockCodes);
|
||||
if (x.id.IsNullOrWhiteSpace())
|
||||
{
|
||||
x.id = SnowflakeIdHelper.NextId();
|
||||
}
|
||||
x.bill_d_id = wmsInstockD.id;
|
||||
});
|
||||
}
|
||||
isOk = await _update(wmsInstockD, wmsInstockCodes);
|
||||
break;
|
||||
case EnumInOutStockType.Out:
|
||||
var wmsOutstockD = input.Adapt<WmsOutstockD>();
|
||||
var wmsOutstockCodes = input.InstockCodes.Adapt<List<WmsOutstockCode>>();
|
||||
wmsOutstockCodes.ForEach(x =>
|
||||
if (wmsOutstockCodes?.Count > 0)
|
||||
{
|
||||
if (x.id.IsNullOrWhiteSpace())
|
||||
wmsOutstockCodes.ForEach(x =>
|
||||
{
|
||||
x.id = SnowflakeIdHelper.NextId();
|
||||
}
|
||||
});
|
||||
isOk = await _update<WmsOutstockD, WmsOutstockCode>(wmsOutstockD, wmsOutstockCodes);
|
||||
if (x.id.IsNullOrWhiteSpace())
|
||||
{
|
||||
x.id = SnowflakeIdHelper.NextId();
|
||||
}
|
||||
x.bill_d_id = wmsOutstockD.id;
|
||||
});
|
||||
}
|
||||
isOk = await _update(wmsOutstockD, wmsOutstockCodes);
|
||||
break;
|
||||
}
|
||||
if (!isOk) throw Oops.Oh(ErrorCode.COM1001);
|
||||
@@ -126,6 +139,7 @@ namespace Tnb.WarehouseMgr
|
||||
public async Task<dynamic> GetInOutStockCodesById([FromQuery] InOutStockDetailQuery input)
|
||||
{
|
||||
dynamic result = null;
|
||||
var dic = await _dictionaryDataService.GetDictionaryByTypeId(WmsWareHouseConst.WMS_INSTOCK_D_BILL_STATUS_TYPEID);
|
||||
switch (input.inoutStockType)
|
||||
{
|
||||
case EnumInOutStockType.In:
|
||||
@@ -133,7 +147,8 @@ namespace Tnb.WarehouseMgr
|
||||
.Where(a => a.id == input.bill_d_id)
|
||||
.Select(a => new InStockDetailOutput
|
||||
{
|
||||
bill_id = a.id,
|
||||
id = a.id,
|
||||
bill_id = a.bill_id,
|
||||
unit_id = a.unit_id,
|
||||
code_batch = a.code_batch,
|
||||
warehouse_id = a.warehouse_id,
|
||||
@@ -145,32 +160,69 @@ namespace Tnb.WarehouseMgr
|
||||
tax_price = a.tax_price,
|
||||
print_qty = a.print_qty,
|
||||
scan_qty = a.scan_qty,
|
||||
material_code = a.material_code,
|
||||
amount = a.amount,
|
||||
all_amount = a.all_amount,
|
||||
CodeDetails = SqlFunc.Subqueryable<WmsInstockCode>().Where(it => it.bill_d_id == a.id).ToList(),
|
||||
}).ToListAsync();
|
||||
})
|
||||
.Mapper(it => it.line_status = dic.ContainsKey(it.line_status) ? dic[it.line_status]?.ToString()! : "")
|
||||
.ToListAsync();
|
||||
|
||||
break;
|
||||
case EnumInOutStockType.Out:
|
||||
result = await _db.Queryable<WmsOutstockCode>().Where(it => it.bill_d_id == input.bill_d_id).ToListAsync();
|
||||
result = await _db.Queryable<WmsOutstockD>()
|
||||
.Where(a => a.id == input.bill_d_id)
|
||||
.Select(a => new OutStockDetailOutput
|
||||
{
|
||||
id = a.id,
|
||||
bill_id = a.bill_id,
|
||||
unit_id = a.unit_id,
|
||||
code_batch = a.code_batch,
|
||||
warehouse_id = a.warehouse_id,
|
||||
line_status = a.line_status,
|
||||
price = a.price,
|
||||
tax_price = a.tax_price,
|
||||
material_code = a.material_code,
|
||||
amount = a.amount,
|
||||
all_amount = a.all_amount,
|
||||
CodeDetails = SqlFunc.Subqueryable<WmsOutstockCode>().Where(it => it.bill_d_id == a.id).ToList(),
|
||||
})
|
||||
.Mapper(it => it.line_status = dic.ContainsKey(it.line_status) ? dic[it.line_status]?.ToString()! : "")
|
||||
.ToListAsync();
|
||||
break;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private async Task<bool> _update<T1, T2>(T1 entity, List<T2> entities) where T1 : BaseEntity<string>, new() where T2 : BaseEntity<string>, new()
|
||||
/// <summary>
|
||||
/// 入库策略
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<List<BasLocation>> InStockStrategy([FromQuery] InStockStrategyQuery input)
|
||||
{
|
||||
var isOk = false;
|
||||
try
|
||||
{
|
||||
await _db.Ado.BeginTranAsync();
|
||||
isOk = await _db.Updateable(entity).ExecuteCommandHasChangeAsync();
|
||||
isOk = await _db.Updateable(entities).ExecuteCommandHasChangeAsync();
|
||||
await _db.Ado.CommitTranAsync();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
await _db.Ado.RollbackTranAsync();
|
||||
}
|
||||
return isOk;
|
||||
var items = await _db.Queryable<BasLocation>().Where(it => it.wh_id == input.warehouse_id && it.is_lock == 0 && it.is_use == "0" && it.is_type == "0").OrderBy(it => new { it.layers, it.loc_line, it.loc_column }, OrderByType.Asc).ToListAsync();
|
||||
return items.Take(input.Size).ToList();
|
||||
}
|
||||
/// <summary>
|
||||
/// 出库策略
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<dynamic> OutStockStrategy()
|
||||
{
|
||||
return Task.FromResult<dynamic>(true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 生成预任务
|
||||
/// </summary>
|
||||
/// <param name="preTasks"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public async Task<bool> GenPreTask(List<WmsPretaskH> preTasks)
|
||||
{
|
||||
var row = await _db.Insertable(preTasks).ExecuteCommandAsync();
|
||||
return row > 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -179,13 +231,16 @@ namespace Tnb.WarehouseMgr
|
||||
/// <param name="pStartId"></param>
|
||||
/// <param name="pEndId"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task PathAlgorithms(string pStartId, string pEndId)
|
||||
|
||||
public async Task<List<WmsPointH>> PathAlgorithms(string pStartId, string pEndId)
|
||||
{
|
||||
var roads = await _db.Queryable<WmsRoad>().ToListAsync();
|
||||
await LocPathCalcAlgorithms(pStartId, pEndId, roads);
|
||||
var points = await LocPathCalcAlgorithms(pStartId, pEndId, roads);
|
||||
return points;
|
||||
}
|
||||
private async Task LocPathCalcAlgorithms(string pStartId, string pEndId, List<WmsRoad> roads)
|
||||
|
||||
#region PrivateMethods
|
||||
private async Task<List<WmsPointH>> LocPathCalcAlgorithms(string pStartId, string pEndId, List<WmsRoad> roads)
|
||||
{
|
||||
var points = await _db.Queryable<WmsPointH>().ToListAsync();
|
||||
var startObj = points.Find(x => x.id == pStartId);
|
||||
@@ -216,7 +271,7 @@ namespace Tnb.WarehouseMgr
|
||||
isVisited[pStartId] = true;
|
||||
MatchPoint(results, roads, shortestPathPoints, isVisited, pStartId, pEndId);
|
||||
results.Add(endObj);
|
||||
string str = null;
|
||||
return results;
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取匹配的最短路径节点
|
||||
@@ -258,5 +313,29 @@ namespace Tnb.WarehouseMgr
|
||||
index = prev[index];
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<bool> _update<T1, T2>(T1 entity, List<T2> entities) where T1 : BaseEntity<string>, new() where T2 : BaseEntity<string>, new()
|
||||
{
|
||||
var isOk = false;
|
||||
try
|
||||
{
|
||||
//await _db.Ado.BeginTranAsync();
|
||||
isOk = await _db.Updateable(entity).ExecuteCommandHasChangeAsync();
|
||||
if (entities?.Count > 0)
|
||||
{
|
||||
var row = await _db.Storageable(entities).ExecuteCommandAsync();
|
||||
isOk = row > 0;
|
||||
}
|
||||
//await _db.Ado.CommitTranAsync();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//await _db.Ado.RollbackTranAsync();
|
||||
}
|
||||
return isOk;
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user