Merge branch 'dev' of https://git.tuotong-tech.com/tnb/tnb.server into dev
This commit is contained in:
@@ -3,11 +3,15 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using JNPF.Common.Core.Manager;
|
||||
using JNPF.Systems.Interfaces.System;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Minio.DataModel;
|
||||
using SqlSugar;
|
||||
using Tnb.BasicData.Entities;
|
||||
using Tnb.WarehouseMgr.Entities;
|
||||
using Tnb.WarehouseMgr.Entities.Consts;
|
||||
using Tnb.WarehouseMgr.Entities.Dto.Inputs;
|
||||
using Tnb.WarehouseMgr.Interfaces;
|
||||
|
||||
namespace Tnb.WarehouseMgr
|
||||
@@ -19,10 +23,12 @@ namespace Tnb.WarehouseMgr
|
||||
{
|
||||
private readonly ISqlSugarClient _db;
|
||||
private readonly IDictionaryDataService _dictionaryDataService;
|
||||
public WmsInStockService(ISqlSugarRepository<WmsInstockH> repository, IDictionaryDataService dictionaryDataService)
|
||||
private readonly IUserManager _userManager;
|
||||
public WmsInStockService(ISqlSugarRepository<WmsInstockH> repository, IDictionaryDataService dictionaryDataService, IUserManager userManager)
|
||||
{
|
||||
_db = repository.AsSugarClient();
|
||||
_dictionaryDataService = dictionaryDataService;
|
||||
_userManager = userManager;
|
||||
}
|
||||
/// <summary>
|
||||
/// 根据入库申请单ID获取申请单明细信息
|
||||
@@ -41,9 +47,66 @@ namespace Tnb.WarehouseMgr
|
||||
/// <summary>
|
||||
/// 条码打印
|
||||
/// </summary>
|
||||
/// <param name="input">
|
||||
/// <br/>{
|
||||
/// <br/> BillIds:入库申请单Id列表
|
||||
/// <br/>}
|
||||
/// </param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="ArgumentNullException"></exception>
|
||||
/// <exception cref="ArgumentException"></exception>
|
||||
[HttpPost]
|
||||
public async Task BarCodePrint(BarCodePrintInput input)
|
||||
{
|
||||
if (input == null) throw new ArgumentNullException("input");
|
||||
if (input.BillIds == null || input.BillIds.Count == 0) throw new ArgumentException($"parameter {nameof(input.BillIds)} not be null or zero");
|
||||
try
|
||||
{
|
||||
await _db.Ado.BeginTranAsync();
|
||||
|
||||
var inStockDetails = await _db.Queryable<WmsInstockD>().Where(it => input.BillIds.Contains(it.bill_id)).ToListAsync();
|
||||
if (inStockDetails?.Count > 0)
|
||||
{
|
||||
List<WmsTempCode> wmsTempCodes = new();
|
||||
for (int i = 0; i < inStockDetails.Count; i++)
|
||||
{
|
||||
WmsTempCode barCode = new();
|
||||
barCode.org_id = inStockDetails[i].org_id;
|
||||
barCode.material_id = inStockDetails[i].material_id;
|
||||
barCode.material_code = inStockDetails[i].material_code;
|
||||
var code = $"{inStockDetails[i].material_code}{inStockDetails[i].code_batch}{(i + 1).ToString().PadLeft(4, '0')}";
|
||||
barCode.barcode = code;
|
||||
barCode.code_batch = inStockDetails[i].code_batch;
|
||||
barCode.codeqty = (int?)(await _db.Queryable<BasMaterial>().FirstAsync(it => it.id == inStockDetails[i].material_id))?.minpacking;
|
||||
barCode.unit_id = inStockDetails[i].unit_id;
|
||||
barCode.is_lock = 0;
|
||||
barCode.is_end = "0";
|
||||
barCode.require_id = input.BillIds[i];
|
||||
barCode.require_code = (await _db.Queryable<WmsInstockH>().SingleAsync(it => it.id == input.BillIds[i])).bill_code;
|
||||
barCode.create_id = _userManager.UserId;
|
||||
barCode.create_time = DateTime.Now;
|
||||
wmsTempCodes.Add(barCode);
|
||||
}
|
||||
var row = await _db.Insertable(wmsTempCodes).ExecuteCommandAsync();
|
||||
if (row > 0)
|
||||
{
|
||||
await _db.Updateable<WmsInstockH>().SetColumns(it => new WmsInstockH { print_status = WmsWareHouseConst.BARCODE_PRINT_STATUS_COMPLETE_ID }).Where(it => input.BillIds.Contains(it.id)).ExecuteCommandAsync();
|
||||
}
|
||||
}
|
||||
|
||||
await _db.Ado.CommitTranAsync();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
await _db.Ado.RollbackTranAsync();
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 扫码入库
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task BarCodePrint()
|
||||
public async Task SacnBarCodeInStock()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user