出库申请业务回更代码提交
This commit is contained in:
@@ -17,6 +17,7 @@ using Microsoft.AspNetCore.Mvc;
|
|||||||
using SqlSugar;
|
using SqlSugar;
|
||||||
using Tnb.BasicData.Entities;
|
using Tnb.BasicData.Entities;
|
||||||
using Tnb.WarehouseMgr.Entities;
|
using Tnb.WarehouseMgr.Entities;
|
||||||
|
using Tnb.WarehouseMgr.Entities.Attributes;
|
||||||
using Tnb.WarehouseMgr.Entities.Consts;
|
using Tnb.WarehouseMgr.Entities.Consts;
|
||||||
using Tnb.WarehouseMgr.Entities.Dto;
|
using Tnb.WarehouseMgr.Entities.Dto;
|
||||||
using Tnb.WarehouseMgr.Entities.Enums;
|
using Tnb.WarehouseMgr.Entities.Enums;
|
||||||
@@ -28,8 +29,10 @@ namespace Tnb.WarehouseMgr
|
|||||||
/// 出库申请业务类
|
/// 出库申请业务类
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[OverideVisualDev(ModuleConsts.MODULE_WMSOUTSTOCK_ID)]
|
[OverideVisualDev(ModuleConsts.MODULE_WMSOUTSTOCK_ID)]
|
||||||
|
[ServiceModule(BizTypeId)]
|
||||||
public class WmsOutStockService : BaseWareHouseService, IWmsOutStockService
|
public class WmsOutStockService : BaseWareHouseService, IWmsOutStockService
|
||||||
{
|
{
|
||||||
|
private const string BizTypeId = "26191522660645";
|
||||||
private readonly ISqlSugarClient _db;
|
private readonly ISqlSugarClient _db;
|
||||||
private readonly IDictionaryDataService _dictionaryDataService;
|
private readonly IDictionaryDataService _dictionaryDataService;
|
||||||
private readonly IRunService _runService;
|
private readonly IRunService _runService;
|
||||||
@@ -271,54 +274,68 @@ namespace Tnb.WarehouseMgr
|
|||||||
public override async Task ModifyAsync(WareHouseUpInput input)
|
public override async Task ModifyAsync(WareHouseUpInput input)
|
||||||
{
|
{
|
||||||
if (input == null) throw new ArgumentNullException("input");
|
if (input == null) throw new ArgumentNullException("input");
|
||||||
var carryId = input.carryIds[^input.carryIds.Count];
|
|
||||||
var carry = await _db.Queryable<WmsCarryH>().SingleAsync(it => it.id == carryId);
|
|
||||||
if (carry != null)
|
|
||||||
{
|
|
||||||
var outStatus = carry.out_status.ToEnum<EnumOutStatus>();
|
|
||||||
if (outStatus == EnumOutStatus.全部出)
|
|
||||||
{
|
|
||||||
//当前载具对应的所有条码插入
|
|
||||||
var carryCodes = await _db.Queryable<WmsCarryCode>().Where(it => it.carry_id == carryId).ToListAsync();
|
|
||||||
var outStockCodes = carryCodes.Adapt<List<WmsOutstockCode>>();
|
|
||||||
var otds = await _db.Queryable<WmsOutstockD>().Where(it => it.bill_id == input.requireId).ToListAsync();
|
|
||||||
outStockCodes.ForEach(x =>
|
|
||||||
{
|
|
||||||
var billDId = otds?.Find(xx => xx.material_id == x.material_id && xx.code_batch == x.code_batch)?.id;
|
|
||||||
x.id = SnowflakeIdHelper.NextId();
|
|
||||||
x.bill_id = input.requireId;
|
|
||||||
x.bill_d_id = billDId;
|
|
||||||
x.org_id = _userManager.User.OrganizeId;
|
|
||||||
x.create_id = _userManager.UserId;
|
|
||||||
x.create_time = DateTime.Now;
|
|
||||||
});
|
|
||||||
await _db.Insertable(outStockCodes).ExecuteCommandAsync();
|
|
||||||
|
|
||||||
var detailIds = outStockCodes.Select(x => x.bill_d_id).ToList();
|
|
||||||
var curOutstockDetails = otds.FindAll(x => detailIds.Contains(x.id));
|
try
|
||||||
var dic = outStockCodes.GroupBy(g => g.bill_d_id).ToDictionary(x => x.Key, x => x.Select(x => x.codeqty).ToList());
|
{
|
||||||
foreach (var osd in curOutstockDetails)
|
var carryId = input.carryIds[^input.carryIds.Count];
|
||||||
|
var carry = await _db.Queryable<WmsCarryH>().SingleAsync(it => it.id == carryId);
|
||||||
|
if (carry != null)
|
||||||
|
{
|
||||||
|
var outStatus = carry.out_status.ToEnum<EnumOutStatus>();
|
||||||
|
if (outStatus == EnumOutStatus.全部出)
|
||||||
{
|
{
|
||||||
if (dic.ContainsKey(osd.id))
|
//当前载具对应的所有条码插入
|
||||||
|
var carryCodes = await _db.Queryable<WmsCarryCode>().Where(it => it.carry_id == carryId).ToListAsync();
|
||||||
|
var outStockCodes = carryCodes.Adapt<List<WmsOutstockCode>>();
|
||||||
|
var otds = await _db.Queryable<WmsOutstockD>().Where(it => it.bill_id == input.requireId).ToListAsync();
|
||||||
|
outStockCodes.ForEach(x =>
|
||||||
{
|
{
|
||||||
osd.qty += dic[osd.id].Sum(d => d);
|
var billDId = otds?.Find(xx => xx.material_id == x.material_id && xx.code_batch == x.code_batch)?.id;
|
||||||
if (osd.qty >= osd.pr_qty)
|
if (billDId.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
osd.line_status = WmsWareHouseConst.BILLSTATUS_COMPLETE_ID;
|
billDId = otds?.Find(xx => xx.material_id == x.material_id)?.id;
|
||||||
|
}
|
||||||
|
x.id = SnowflakeIdHelper.NextId();
|
||||||
|
x.bill_id = input.requireId;
|
||||||
|
x.bill_d_id = billDId;
|
||||||
|
x.org_id = _userManager.User.OrganizeId;
|
||||||
|
x.create_id = _userManager.UserId;
|
||||||
|
x.create_time = DateTime.Now;
|
||||||
|
});
|
||||||
|
await _db.Insertable(outStockCodes).ExecuteCommandAsync();
|
||||||
|
|
||||||
|
var detailIds = outStockCodes.Select(x => x.bill_d_id).ToList();
|
||||||
|
var curOutstockDetails = otds.FindAll(x => detailIds.Contains(x.id));
|
||||||
|
var dic = outStockCodes.GroupBy(g => g.bill_d_id).ToDictionary(x => x.Key, x => x.Select(x => x.codeqty).ToList());
|
||||||
|
foreach (var osd in curOutstockDetails)
|
||||||
|
{
|
||||||
|
if (dic.ContainsKey(osd.id))
|
||||||
|
{
|
||||||
|
osd.qty += dic[osd.id].Sum(d => d);
|
||||||
|
if (osd.qty >= osd.pr_qty)
|
||||||
|
{
|
||||||
|
osd.line_status = WmsWareHouseConst.BILLSTATUS_COMPLETE_ID;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
await _db.Updateable(curOutstockDetails).ExecuteCommandAsync();
|
||||||
|
if (otds.All(x => x.line_status == WmsWareHouseConst.BILLSTATUS_COMPLETE_ID))
|
||||||
|
{
|
||||||
|
await _db.Updateable<WmsOutstockH>().SetColumns(it => new WmsOutstockH { status = WmsWareHouseConst.BILLSTATUS_COMPLETE_ID }).Where(it => it.id == input.requireId).ExecuteCommandAsync();
|
||||||
|
//如果是自动单据,需要回更上层系统
|
||||||
|
}
|
||||||
}
|
}
|
||||||
await _db.Updateable(curOutstockDetails).ExecuteCommandAsync();
|
else if (outStatus == EnumOutStatus.分拣出)
|
||||||
if (otds.All(x => x.line_status == WmsWareHouseConst.BILLSTATUS_COMPLETE_ID))
|
|
||||||
{
|
{
|
||||||
await _db.Updateable<WmsOutstockH>().SetColumns(it => new WmsOutstockH { status = WmsWareHouseConst.BILLSTATUS_COMPLETE_ID }).Where(it => it.id == input.requireId).ExecuteCommandAsync();
|
|
||||||
//如果是自动单据,需要回更上层系统
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (outStatus == EnumOutStatus.分拣出)
|
}
|
||||||
{
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
|
||||||
}
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -66,6 +66,12 @@ namespace Tnb.WarehouseMgr
|
|||||||
var carry = await _db.Queryable<WmsCarryH>().SingleAsync(it => it.id == input.carryId);
|
var carry = await _db.Queryable<WmsCarryH>().SingleAsync(it => it.id == input.carryId);
|
||||||
if (carry != null)
|
if (carry != null)
|
||||||
{
|
{
|
||||||
|
if (carry.location_id.IsNotEmptyOrNull())
|
||||||
|
{
|
||||||
|
var loc = await _db.Queryable<BasLocation>().SingleAsync(it => it.id == carry.location_id);
|
||||||
|
loc.is_use = (int)EnumCarryStatus.空闲;
|
||||||
|
await _db.Updateable(loc).UpdateColumns(it => it.is_use).ExecuteCommandAsync();
|
||||||
|
}
|
||||||
var disTask = await _db.Queryable<WmsDistaskH>().SingleAsync(it => it.id == input.disTaskId);
|
var disTask = await _db.Queryable<WmsDistaskH>().SingleAsync(it => it.id == input.disTaskId);
|
||||||
if (disTask != null)
|
if (disTask != null)
|
||||||
{
|
{
|
||||||
@@ -77,18 +83,23 @@ namespace Tnb.WarehouseMgr
|
|||||||
case "寄存出库":
|
case "寄存出库":
|
||||||
case "齐套出库":
|
case "齐套出库":
|
||||||
case "一般出库":
|
case "一般出库":
|
||||||
await _wareCarryService.UpdateNullCarry(carry);
|
{
|
||||||
|
WareHouseUpInput upInput = new() { loginType = "web", bizTypeId = disTask.biz_type, requireId = disTask.require_id, carryIds = new List<string> { input.carryId } };
|
||||||
|
await DoUpdate(upInput); //回更业务
|
||||||
|
await _wareCarryService.UpdateNullCarry(carry);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
case "载具移出":
|
||||||
|
{
|
||||||
|
WareHouseUpInput upInput = new() { loginType = "web", bizTypeId = disTask.biz_type, requireId = disTask.require_id, carryIds = new List<string> { input.carryId } };
|
||||||
|
await DoUpdate(upInput); //回更业务
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var loc = await _db.Queryable<BasLocation>().SingleAsync(it => it.id == carry.location_id);
|
|
||||||
loc.is_use = (int)EnumCarryStatus.空闲;
|
|
||||||
await _db.Updateable(loc).UpdateColumns(it => it.is_use).ExecuteCommandAsync();
|
|
||||||
WareHouseUpInput upInput = new() { loginType = "web", bizTypeId = disTask.biz_type, requireId = disTask.require_id, carryIds = new List<string> { input.carryId } };
|
|
||||||
await DoUpdate(upInput); //回更业务
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
await _db.Ado.CommitTranAsync();
|
await _db.Ado.CommitTranAsync();
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
|
|||||||
Reference in New Issue
Block a user