入库申请代码调整,WmsInstockD line_status改为string类型
This commit is contained in:
@@ -102,7 +102,7 @@ public partial class WmsDistaskH : BaseEntity<string>
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 是否签收
|
/// 是否签收
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int is_sign { get; set; }
|
public int is_sign { get; set; } = 1;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 来源单据ID
|
/// 来源单据ID
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ public partial class WmsInstockCode : BaseEntity<string>
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 明细状态
|
/// 明细状态
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int line_status { get; set; }
|
public string line_status { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 物品ID
|
/// 物品ID
|
||||||
|
|||||||
@@ -94,10 +94,6 @@ public partial class WmsPretaskCode : BaseEntity<string>
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public DateTime? modify_time { get; set; }
|
public DateTime? modify_time { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 行号
|
|
||||||
/// </summary>
|
|
||||||
public int no { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 子载具ID
|
/// 子载具ID
|
||||||
|
|||||||
237
WarehouseMgr/Tnb.WarehouseMgr/WmsOutBaleService.cs
Normal file
237
WarehouseMgr/Tnb.WarehouseMgr/WmsOutBaleService.cs
Normal file
@@ -0,0 +1,237 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using JNPF.Common.Core.Manager;
|
||||||
|
using JNPF.Common.Dtos.VisualDev;
|
||||||
|
using JNPF.Common.Extension;
|
||||||
|
using JNPF.Common.Security;
|
||||||
|
using JNPF.FriendlyException;
|
||||||
|
using JNPF.Systems.Interfaces.System;
|
||||||
|
using JNPF.VisualDev;
|
||||||
|
using JNPF.VisualDev.Entitys;
|
||||||
|
using JNPF.VisualDev.Interfaces;
|
||||||
|
using Mapster;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using SqlSugar;
|
||||||
|
using Tnb.BasicData.Entities;
|
||||||
|
using Tnb.WarehouseMgr.Entities;
|
||||||
|
using Tnb.WarehouseMgr.Entities.Consts;
|
||||||
|
using Tnb.WarehouseMgr.Entities.Dto;
|
||||||
|
using Tnb.WarehouseMgr.Entities.Enums;
|
||||||
|
using Tnb.WarehouseMgr.Interfaces;
|
||||||
|
|
||||||
|
namespace Tnb.WarehouseMgr
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 出库申请业务类
|
||||||
|
/// </summary>
|
||||||
|
[OverideVisualDev(ModuleConsts.MODULE_WMSOUTSTOCK_ID)]
|
||||||
|
public class WmsOutBaleService : BaseWareHouseService, IWmsOutStockService
|
||||||
|
{
|
||||||
|
private readonly ISqlSugarClient _db;
|
||||||
|
private readonly IDictionaryDataService _dictionaryDataService;
|
||||||
|
private readonly IRunService _runService;
|
||||||
|
private readonly IVisualDevService _visualDevService;
|
||||||
|
private readonly IWareHouseService _wareHouseService;
|
||||||
|
private readonly IUserManager _userManager;
|
||||||
|
private readonly IBillRullService _billRullService;
|
||||||
|
|
||||||
|
public WmsOutBaleService(
|
||||||
|
ISqlSugarRepository<WmsOutstockD> repository,
|
||||||
|
IDictionaryDataService dictionaryDataService,
|
||||||
|
IRunService runService,
|
||||||
|
IVisualDevService visualDevService,
|
||||||
|
IWareHouseService wareHouseService,
|
||||||
|
IUserManager userManager,
|
||||||
|
IBillRullService billRullService)
|
||||||
|
{
|
||||||
|
_db = repository.AsSugarClient();
|
||||||
|
_dictionaryDataService = dictionaryDataService;
|
||||||
|
_runService = runService;
|
||||||
|
_visualDevService = visualDevService;
|
||||||
|
_wareHouseService = wareHouseService;
|
||||||
|
_userManager = userManager;
|
||||||
|
_billRullService = billRullService;
|
||||||
|
OverideFuncs.CreateAsync = OutStockApplyFor;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private async Task<dynamic> OutStockApplyFor(VisualDevModelDataCrInput input)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await _db.Ado.BeginTranAsync();
|
||||||
|
|
||||||
|
VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleConsts.MODULE_WMSOUTSTOCK_ID, true);
|
||||||
|
await _runService.Create(templateEntity, input);
|
||||||
|
|
||||||
|
//判断目标库位是否自动签收
|
||||||
|
var loc = await _db.Queryable<BasLocation>().SingleAsync(it => it.id == input.data[nameof(WmsPointH.location_id)].ToString());
|
||||||
|
|
||||||
|
var carryIds = new List<string>();
|
||||||
|
//tablefield120 出库物料明细
|
||||||
|
if (input.data.ContainsKey("tablefield120") && input.data["tablefield120"].IsNotEmptyOrNull())
|
||||||
|
{
|
||||||
|
var outStockDList = input.data["tablefield120"].ToObject<List<WmsOutstockD>>();
|
||||||
|
if (outStockDList?.Count > 0)
|
||||||
|
{
|
||||||
|
List<WmsCarryMat> carryMats = new();
|
||||||
|
List<WmsCarryCode> carryCodes = new();
|
||||||
|
foreach (var os in outStockDList)
|
||||||
|
{
|
||||||
|
var carryCodesPart = await _db.Queryable<WmsCarryH>().InnerJoin<WmsCarryCode>((a, b) => a.id == b.carry_id)
|
||||||
|
.Where((a, b) => b.material_id == os.material_id && b.code_batch == os.code_batch && a.is_lock == 0 && !string.IsNullOrEmpty(a.location_id) && a.status == (int)EnumCarryStatus.占用)
|
||||||
|
.Select<WmsCarryCode>()
|
||||||
|
.ToListAsync();
|
||||||
|
if (carryCodesPart?.Count > 0)
|
||||||
|
{
|
||||||
|
carryCodes.AddRange(carryCodesPart);
|
||||||
|
var codeQty = carryCodes.Sum(x => x.codeqty);
|
||||||
|
if (codeQty < os.pr_qty)
|
||||||
|
{
|
||||||
|
throw new AppFriendlyException($"需要出库[{os.pr_qty}],实际库存{codeQty},数量不足", 500);
|
||||||
|
}
|
||||||
|
var partCarryMats = carryCodesPart.Adapt<List<WmsCarryMat>>();
|
||||||
|
partCarryMats.ForEach(x =>
|
||||||
|
{
|
||||||
|
x.need_qty = (int)os.pr_qty;
|
||||||
|
x.real_qty = codeQty;
|
||||||
|
});
|
||||||
|
carryMats.AddRange(partCarryMats);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (carryMats.Count > 0)
|
||||||
|
{
|
||||||
|
carryMats.ForEach(x => x.id = SnowflakeIdHelper.NextId());
|
||||||
|
carryMats = carryMats.OrderBy(o => o.create_time).GroupBy(g => new { g.carry_id, g.material_id, g.code_batch })
|
||||||
|
.Select(x =>
|
||||||
|
{
|
||||||
|
WmsCarryMat? carryMat = x.FirstOrDefault()!;
|
||||||
|
carryMat.real_qty = x.Sum(d => d.real_qty);
|
||||||
|
return carryMat;
|
||||||
|
})
|
||||||
|
.ToList();
|
||||||
|
await _db.Insertable(carryMats).ExecuteCommandAsync();
|
||||||
|
var dic = carryMats.DistinctBy(x => x.carry_id).ToDictionary(x => x.carry_id, x => x.real_qty);
|
||||||
|
var allOutIds = new List<string>();
|
||||||
|
var sortingOutIds = new List<string>();
|
||||||
|
foreach (var pair in dic)
|
||||||
|
{
|
||||||
|
var codes = carryCodes.FindAll(x => x.carry_id == pair.Key);
|
||||||
|
if (codes?.Count > 0)
|
||||||
|
{
|
||||||
|
if (pair.Value == codes.Sum(d => d.codeqty))
|
||||||
|
{
|
||||||
|
allOutIds.Add(pair.Key);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sortingOutIds.Add(pair.Key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
carryIds = allOutIds.Concat(sortingOutIds).ToList();
|
||||||
|
await _db.Updateable<WmsCarryH>().SetColumns(it => new WmsCarryH { out_status = ((int)EnumOutStatus.全部出).ToString() }).Where(it => allOutIds.Contains(it.id)).ExecuteCommandAsync();
|
||||||
|
await _db.Updateable<WmsCarryH>().SetColumns(it => new WmsCarryH { out_status = ((int)EnumOutStatus.分拣出).ToString() }).Where(it => sortingOutIds.Contains(it.id)).ExecuteCommandAsync();
|
||||||
|
}
|
||||||
|
var carrys = await _db.Queryable<WmsCarryH>().Where(it => carryIds.Contains(it.id)).ToListAsync();
|
||||||
|
if (carrys?.Count > 0)
|
||||||
|
{
|
||||||
|
List<WmsPretaskH> preTasks = new();
|
||||||
|
List<string> locIds = new();
|
||||||
|
foreach (var carry in carrys)
|
||||||
|
{
|
||||||
|
WmsPointH sPoint = null;
|
||||||
|
WmsPointH ePoint = null;
|
||||||
|
if (input.data.ContainsKey(nameof(WmsPointH.location_id)))
|
||||||
|
{
|
||||||
|
sPoint = await _db.Queryable<WmsPointH>().FirstAsync(it => it.location_id == carry.location_id);
|
||||||
|
}
|
||||||
|
if (input.data.ContainsKey(nameof(WmsPointH.location_id)) && input.data[nameof(WmsPointH.location_id)].IsNotEmptyOrNull())
|
||||||
|
{
|
||||||
|
ePoint = await _db.Queryable<WmsPointH>().FirstAsync(it => it.location_id == input.data[nameof(WmsPointH.location_id)].ToString());
|
||||||
|
}
|
||||||
|
if (sPoint != null && ePoint != null)
|
||||||
|
{
|
||||||
|
var points = await _wareHouseService.PathAlgorithms(sPoint.id, ePoint.id);
|
||||||
|
locIds.AddRange(points.Select(x => x.location_id).ToList()!);
|
||||||
|
//根据获取的路径点生成预任务,生成顺序必须预路径算法返回的起终点的顺序一致(预任务顺序)
|
||||||
|
if (points?.Count > 0)
|
||||||
|
{
|
||||||
|
if (points.Count <= 2) throw new AppFriendlyException("该路径不存在", 500);
|
||||||
|
var curPreTasks = points.Where(it => !it.location_id.IsNullOrEmpty()).GroupBy(g => g.area_code).Select(it =>
|
||||||
|
{
|
||||||
|
var sPoint = it.FirstOrDefault();
|
||||||
|
var ePoint = it.LastOrDefault();
|
||||||
|
|
||||||
|
WmsPretaskH preTask = new();
|
||||||
|
preTask.org_id = _userManager.User.OrganizeId;
|
||||||
|
preTask.startlocation_id = sPoint?.location_id;
|
||||||
|
preTask.startlocation_code = sPoint?.location_code;
|
||||||
|
preTask.endlocation_id = ePoint?.location_id;
|
||||||
|
preTask.endlocation_code = ePoint?.location_code;
|
||||||
|
preTask.start_floor = sPoint?.floor.ToString();
|
||||||
|
preTask.end_floor = ePoint?.floor.ToString();
|
||||||
|
preTask.bill_code = _billRullService.GetBillNumber(WmsWareHouseConst.WMS_PRETASK_H_ENCODE).GetAwaiter().GetResult();
|
||||||
|
preTask.status = WmsWareHouseConst.PRETASK_BILL_STATUS_DXF_ID;
|
||||||
|
preTask.biz_type = WmsWareHouseConst.BIZTYPE_WMSOUTSTOCK_ID;
|
||||||
|
preTask.task_type = WmsWareHouseConst.WMS_PRETASK_OUTSTOCK_TYPE_ID;
|
||||||
|
preTask.carry_id = carry.id;
|
||||||
|
preTask.carry_code = carry.carry_code;
|
||||||
|
preTask.area_id = sPoint?.area_id!;
|
||||||
|
preTask.area_code = it.Key;
|
||||||
|
preTask.require_id = input.data["ReturnIdentity"].ToString();
|
||||||
|
preTask.require_code = input.data[nameof(preTask.bill_code)]?.ToString()!;
|
||||||
|
preTask.create_id = _userManager.UserId;
|
||||||
|
preTask.create_time = DateTime.Now;
|
||||||
|
return preTask;
|
||||||
|
}).ToList();
|
||||||
|
if (loc.is_sign == 0)
|
||||||
|
{
|
||||||
|
curPreTasks[^1].is_sign = 0; // 修改最后一个元素的是否签收值
|
||||||
|
}
|
||||||
|
preTasks.AddRange(curPreTasks);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var isOk = await _wareHouseService.GenPreTask(preTasks, null);
|
||||||
|
GenPreTaskUpInput genPreTaskAfterUpInput = new();
|
||||||
|
genPreTaskAfterUpInput.CarryIds = preTasks.Select(x => x.carry_id).ToList();
|
||||||
|
genPreTaskAfterUpInput.LocationIds = new HashSet<string>(locIds).ToList();
|
||||||
|
await _wareHouseService.GenInStockTaskHandleAfter(genPreTaskAfterUpInput, it => new WmsCarryH { is_lock = 1 }, it => new BasLocation { is_lock = 1 });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else throw new AppFriendlyException($"请输入物料明细", 500);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
await _db.Ado.CommitTranAsync();
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
await _db.Ado.RollbackTranAsync();
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
return Task.FromResult(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 根据出库申请单ID获取申请单明细信息
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="billId"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet]
|
||||||
|
public async Task<dynamic> GetInStockDetailsListById([FromRoute] string billId)
|
||||||
|
{
|
||||||
|
var dic = await _dictionaryDataService.GetDictionaryByTypeId(WmsWareHouseConst.WMS_INSTOCK_D_BILL_STATUS_TYPEID);
|
||||||
|
var items = await _db.Queryable<WmsOutstockD>().Where(it => it.bill_id == billId).ToListAsync();
|
||||||
|
_db.ThenMapper(items,
|
||||||
|
it => it.line_status = dic.ContainsKey(it.line_status) ? dic[it.line_status]?.ToString()! : "");
|
||||||
|
return items;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -78,9 +78,9 @@ namespace Tnb.WarehouseMgr
|
|||||||
var endLocations = await _wareHouseService.InStockStrategy(inStockStrategyInput);
|
var endLocations = await _wareHouseService.InStockStrategy(inStockStrategyInput);
|
||||||
WmsPointH sPoint = null;
|
WmsPointH sPoint = null;
|
||||||
WmsPointH ePoint = null;
|
WmsPointH ePoint = null;
|
||||||
if (input.data.ContainsKey(nameof(WmsPointH.location_id)))
|
if (input.data.ContainsKey(nameof(WmsHandleH.startlocation_id)))
|
||||||
{
|
{
|
||||||
sPoint = await _db.Queryable<WmsPointH>().FirstAsync(it => it.location_id == input.data[nameof(WmsPointH.location_id)].ToString());
|
sPoint = await _db.Queryable<WmsPointH>().FirstAsync(it => it.location_id == input.data[nameof(WmsHandleH.startlocation_id)].ToString());
|
||||||
}
|
}
|
||||||
if (endLocations?.Count > 0)
|
if (endLocations?.Count > 0)
|
||||||
{
|
{
|
||||||
@@ -149,7 +149,7 @@ namespace Tnb.WarehouseMgr
|
|||||||
var requireCodeField = "require_code";
|
var requireCodeField = "require_code";
|
||||||
|
|
||||||
var preTaskUpInput = new GenPreTaskUpInput();
|
var preTaskUpInput = new GenPreTaskUpInput();
|
||||||
preTaskUpInput.RquireId = input.data["ReturnIdentity"].ToString();
|
preTaskUpInput.RquireId = input.data[nameof(WmsHandleH.require_id)].ToString();
|
||||||
preTaskUpInput.CarryId = input.data[nameof(WmsCarryD.carry_id)]?.ToString()!;
|
preTaskUpInput.CarryId = input.data[nameof(WmsCarryD.carry_id)]?.ToString()!;
|
||||||
preTaskUpInput.CarryStartLocationId = points.FirstOrDefault().location_id;
|
preTaskUpInput.CarryStartLocationId = points.FirstOrDefault().location_id;
|
||||||
preTaskUpInput.CarryStartLocationCode = points.FirstOrDefault().location_code;
|
preTaskUpInput.CarryStartLocationCode = points.FirstOrDefault().location_code;
|
||||||
@@ -200,7 +200,22 @@ namespace Tnb.WarehouseMgr
|
|||||||
var instockDetails = await _db.Queryable<WmsInstockD>()
|
var instockDetails = await _db.Queryable<WmsInstockD>()
|
||||||
.Where(b => b.bill_id == input.data[requireIdField].ToString())
|
.Where(b => b.bill_id == input.data[requireIdField].ToString())
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
//var instockProps = typeof(WmsInstockD).GetProperties().Select(p => p.Name).ToList();
|
||||||
|
//var instockCodeProps = typeof(WmsInstockCode).GetProperties().Select(p => p.Name).ToList();
|
||||||
|
//var ssss = instockCodeProps.Intersect(instockProps).ToList();
|
||||||
|
//var instockTypes = typeof(WmsInstockD).GetProperties().Where(p => ssss.Contains(p.Name)).Select(p => p.PropertyType.Name).ToList();
|
||||||
|
//var instockCodeTypes = typeof(WmsInstockCode).GetProperties().Where(p => ssss.Contains(p.Name)).Select(p => p.PropertyType.Name).ToList();
|
||||||
|
//var dddf = instockTypes.Except(instockCodeTypes).ToList();
|
||||||
|
//var ddd = instockDetails[0].Adapt<WmsInstockCode>();
|
||||||
|
|
||||||
|
//org_id,bill_id,line_status,material_id,material_code,code_batch,unit_id,unit_code,source_id,
|
||||||
|
// source_code,source_type,source_line,source_detail_id,remark,extras,time_stamp,create_id,
|
||||||
|
// create_time,modify_id,modify_time,mo_code,mo_line,mo_bom_detail_id,id
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var items = instockDetails.Adapt<List<WmsInstockCode>>();
|
var items = instockDetails.Adapt<List<WmsInstockCode>>();
|
||||||
|
items.ForEach(it => it.org_id = _userManager.User.OrganizeId);
|
||||||
List<WmsInstockCode> instockCOdes = new();
|
List<WmsInstockCode> instockCOdes = new();
|
||||||
jArr = JArray.Parse(input.data["tablefield115"].ToString()!);
|
jArr = JArray.Parse(input.data["tablefield115"].ToString()!);
|
||||||
if (jArr?.Children().Count() > 0)
|
if (jArr?.Children().Count() > 0)
|
||||||
|
|||||||
@@ -141,7 +141,7 @@ namespace Tnb.WarehouseMgr
|
|||||||
handleH.create_time = DateTime.Now;
|
handleH.create_time = DateTime.Now;
|
||||||
preTaskUpInput.PreTaskRecord = handleH;
|
preTaskUpInput.PreTaskRecord = handleH;
|
||||||
//根据载具移入Id,回更单据状态
|
//根据载具移入Id,回更单据状态
|
||||||
await _db.Updateable<WmsInbale>().SetColumns(it => new WmsInbale { status = WmsWareHouseConst.BILLSTATUS_ON_ID }).Where(it => it.id == preTaskUpInput.RquireId).ExecuteCommandAsync();
|
await _db.Updateable<WmsInbale>().SetColumns(it => new WmsInbale { status = WmsWareHouseConst.BILLSTATUS_ON_ID}).Where(it => it.id == preTaskUpInput.RquireId).ExecuteCommandAsync();
|
||||||
|
|
||||||
await _wareHouseService.GenInStockTaskHandleAfter(preTaskUpInput,
|
await _wareHouseService.GenInStockTaskHandleAfter(preTaskUpInput,
|
||||||
it => new WmsCarryH { is_lock = 1, location_id = preTaskUpInput.CarryStartLocationId, location_code = preTaskUpInput.CarryStartLocationCode, carry_status= ((int)EnumCarryStatus.寄存).ToString() },
|
it => new WmsCarryH { is_lock = 1, location_id = preTaskUpInput.CarryStartLocationId, location_code = preTaskUpInput.CarryStartLocationCode, carry_status= ((int)EnumCarryStatus.寄存).ToString() },
|
||||||
|
|||||||
Reference in New Issue
Block a user