diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/WmsWareHouseConst.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/WmsWareHouseConst.cs
index 57c90ee2..e2154202 100644
--- a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/WmsWareHouseConst.cs
+++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/WmsWareHouseConst.cs
@@ -42,8 +42,8 @@ namespace Tnb.WarehouseMgr.Entities.Consts
/// 预任务单据状态-已完成Id
///
public const string PRETASK_BILL_STATUS_CANCEL_ID = "26126842129701";
-
- //
+
+ //
///
/// 任务单据状态-待执行Id
///
@@ -65,7 +65,7 @@ namespace Tnb.WarehouseMgr.Entities.Consts
/// 任务单据状态-已取消ID
///
public const string TASK_BILL_STATUS_CANCEL_ID = "26126863175461";
-
+
///
/// 单据状态-作业中
///
@@ -74,6 +74,23 @@ namespace Tnb.WarehouseMgr.Entities.Consts
/// 单据状态-完成
///
public const string BILLSTATUS_COMPLETE_ID = "25065149810453";
+ ///
+ /// 单据状态-取消
+ ///
+ public const string BILLSTATUS_CANCEL_ID = "25065146252309";
+ ///
+ /// 单据状态-新增
+ ///
+ public const string BILLSTATUS_ADD_ID = "25065138925589";
+ ///
+ /// 单据状态-已呼叫
+ ///
+ public const string BILLSTATUS_CALLED_ID = "25065138925589";
+ ///
+ /// 单据状态-待配送
+ ///
+ public const string BILLSTATUS_TOBESHIPPED_ID = "26169434213669";
+
///
/// 任务类型-入库TypeId
///
@@ -86,7 +103,7 @@ namespace Tnb.WarehouseMgr.Entities.Consts
/// 任务类型-转移TypeId
///
public const string WMS_PRETASK_TRANSFER_TYPE_ID = "26126753796389";
-
+
///
/// 预任务生成业务类型-空载具出库
///
@@ -149,7 +166,5 @@ namespace Tnb.WarehouseMgr.Entities.Consts
///
public const string BARCODE_PRINT_STATUS_COMPLETE_ID = "26191372853541";
-
-
}
}
diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsKittingoutD.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsKittingoutD.cs
index 7a0478e6..e88b2244 100644
--- a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsKittingoutD.cs
+++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsKittingoutD.cs
@@ -55,9 +55,9 @@ public partial class WmsKittingoutD : BaseEntity
public string? code_batch { get; set; }
///
- /// 数量(件数)
+ /// 出库需求数量
///
- public decimal qty { get; set; }
+ public decimal pr_qty { get; set; }
///
/// 箱数
diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Interfaces/IWmskittingOutService.cs b/WarehouseMgr/Tnb.WarehouseMgr.Interfaces/IWmskittingOutService.cs
new file mode 100644
index 00000000..db94d4ad
--- /dev/null
+++ b/WarehouseMgr/Tnb.WarehouseMgr.Interfaces/IWmskittingOutService.cs
@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Tnb.WarehouseMgr.Interfaces
+{
+ ///
+ /// 齐套出库服务接口
+ ///
+ public interface IWmskittingOutService
+ {
+ }
+}
diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs
index b20cea3f..9eeb99b1 100644
--- a/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs
+++ b/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs
@@ -517,7 +517,10 @@ namespace Tnb.WarehouseMgr
{
await _db.Ado.BeginTranAsync();
//根据生成的预任务,插入预任务操作记录
- await _db.Insertable(input.PreTaskRecord).ExecuteCommandAsync();
+ if (input.PreTaskRecord != null)
+ {
+ await _db.Insertable(input.PreTaskRecord).ExecuteCommandAsync();
+ }
if (input.PreTaskHandleCodes.Count > 0)
{
await _db.Insertable(input.PreTaskHandleCodes).ExecuteCommandAsync();
diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmskittingOutService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmskittingOutService.cs
new file mode 100644
index 00000000..d7ad3862
--- /dev/null
+++ b/WarehouseMgr/Tnb.WarehouseMgr/WmskittingOutService.cs
@@ -0,0 +1,190 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Aop.Api.Domain;
+using JNPF.Common.Core.Manager;
+using JNPF.Common.Extension;
+using JNPF.Common.Security;
+using JNPF.FriendlyException;
+using JNPF.Systems.Interfaces.System;
+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
+{
+ ///
+ /// 齐套出库服务类
+ ///
+ public class WmskittingOutService : BaseWareHouseService, IWmskittingOutService
+ {
+ private readonly ISqlSugarClient _db;
+ private readonly IWareHouseService _warehouseService;
+ private readonly IUserManager _userManager;
+ private readonly IBillRullService _billRullService;
+ public WmskittingOutService(ISqlSugarRepository repository, IWareHouseService warehouseService, IUserManager userManager, IBillRullService billRullService)
+ {
+ _db = repository.AsSugarClient();
+ _warehouseService = warehouseService;
+ _userManager = userManager;
+ _billRullService = billRullService;
+ }
+ ///
+ /// 齐套出库(新增状态)
+ ///
+ ///
+ [HttpPost]
+ public async Task KittingOutByAdd()
+ {
+ try
+ {
+ await _db.Ado.BeginTranAsync();
+
+ var kittingOuts = await _db.Queryable()
+ .Where(a => a.status == WmsWareHouseConst.BILLSTATUS_ADD_ID)
+ .OrderBy(a => a.seq)
+ .ToListAsync();
+ // 是否有已呼叫的齐套出库任务
+ // var set = true ; 如果有 把set修改为false
+ var items = await _db.Queryable().Where(it => it.status == WmsWareHouseConst.BILLSTATUS_CALLED_ID).ToListAsync();
+ var isCalled = items?.Count > 0;
+ if (kittingOuts?.Count > 0)
+ {
+ foreach (var ko in kittingOuts)
+ {
+ var carrys = await _db.Queryable().Where(it => it.collocation_scheme_id == ko.collocation_scheme_id && it.is_lock == 0).ToListAsync();
+ if (carrys?.Count > 0)
+ {
+ var firstCarry = carrys.FirstOrDefault();
+ GenPreTaskUpInput genPreTaskInput = new() { CarryId = firstCarry.id };
+ await _warehouseService.GenInStockTaskHandleAfter(genPreTaskInput, it => new WmsCarryH { is_lock = 1 }, null!);
+ ko.status = WmsWareHouseConst.BILLSTATUS_TOBESHIPPED_ID;
+ ko.carry_id = firstCarry.id;
+ ko.carry_code = firstCarry.carry_code;
+ await _db.Updateable(ko).UpdateColumns(it => new { it.status, it.carry_id, it.carry_code }).ExecuteCommandAsync();
+ }
+ else
+ {
+ //if(false) 跳出 插入完一次齐套分拣 set 改为false
+ if (!isCalled)
+ {
+ var setSortingH = ko.Adapt();
+ setSortingH.id = SnowflakeIdHelper.NextId();
+ setSortingH.kittingout_id = ko.id;
+ setSortingH.order = ko.seq;
+ setSortingH.org_id = _userManager.User.OrganizeId;
+ setSortingH.create_id = _userManager.UserId;
+ setSortingH.create_time = DateTime.Now;
+ await _db.Insertable(setSortingH).ExecuteCommandAsync();
+
+ var kittingOutDetails = await _db.Queryable().Where(it => it.bill_id == setSortingH.id).ToListAsync();
+ var setSortDetails = kittingOutDetails.Adapt>();
+ setSortDetails.ForEach(x =>
+ {
+ x.id = SnowflakeIdHelper.NextId();
+ x.org_id = _userManager.User.OrganizeId;
+ x.create_id = _userManager.UserId;
+ x.create_time = DateTime.Now;
+ });
+ await _db.Insertable(setSortDetails).ExecuteCommandAsync();
+ ko.status = WmsWareHouseConst.BILLSTATUS_CALLED_ID;
+ await _db.Updateable(ko).UpdateColumns(it => it.status).ExecuteCommandAsync();
+ isCalled = true;
+ }
+ }
+ }
+ }
+
+ await _db.Ado.CommitTranAsync();
+ }
+ catch (Exception)
+ {
+ await _db.Ado.RollbackTranAsync();
+ throw;
+ }
+ }
+ ///
+ /// 齐套出库,(待配送状态)
+ ///
+ ///
+ [HttpPost]
+ public async Task KittingOutByIsToBeShipped()
+ {
+
+ var kittingOuts = await _db.Queryable()
+ .Where(a => a.status == WmsWareHouseConst.BILLSTATUS_TOBESHIPPED_ID)
+ .OrderBy(a => a.seq)
+ .ToListAsync();
+ if (kittingOuts?.Count > 0)
+ {
+ var grpList = kittingOuts.GroupBy(g => g.location_id).ToList();
+ foreach (var koGrp in grpList)
+ {
+ var locs = await _db.Queryable().Where(it => it.id == koGrp.Key && it.is_use == "0" && it.is_lock == 0).ToListAsync();
+ if (locs?.Count > 0)
+ {
+ var arr = koGrp.ToArray();
+ Index start = ^arr.Length;
+ var ko = arr[start];
+ var carry = await _db.Queryable().SingleAsync(it => it.id == ko.carry_id);
+ if (carry != null)
+ {
+ WmsPointH sPoint = await _db.Queryable().FirstAsync(it => it.location_id == carry.location_id);
+ WmsPointH ePoint = await _db.Queryable().FirstAsync(it => it.location_id == ko.location_id);
+ if (sPoint != null && ePoint != null)
+ {
+ var points = await _warehouseService.PathAlgorithms(sPoint.id, ePoint.id);
+ if (points?.Count > 0)
+ {
+ if (points.Count <= 2) throw new AppFriendlyException("该路径不存在", 500);
+ var preTasks = 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 = ko.biz_type;
+ preTask.task_type = WmsWareHouseConst.WMS_PRETASK_INSTOCK_TYPE_ID;
+ preTask.carry_id = ko.carry_id;
+ preTask.carry_code = ko.carry_code;
+ preTask.area_id = sPoint?.area_id;
+ preTask.area_code = it.Key;
+ preTask.require_id = ko.id;
+ preTask.require_code = ko.bill_code;
+ preTask.create_id = _userManager.UserId;
+ preTask.create_time = DateTime.Now;
+ return preTask;
+ }).ToList();
+ await _warehouseService.GenPreTask(preTasks, null!);
+ var subCarrys = await _db.Queryable().Where(it => it.carry_id == ko.carry_id).ToListAsync();
+ var carryIds = subCarrys.Select(x => x.carry_id).Concat(new[] { ko.carry_id }).Distinct().ToList();
+ GenPreTaskUpInput genPreTaskInput = new() { CarryIds = carryIds, LocationIds = new List { carry.location_id, ko.location_id } };
+ await _warehouseService.GenInStockTaskHandleAfter(genPreTaskInput, it => new WmsCarryH { is_lock = 1, carry_status = ((int)EnumCarryStatus.齐套).ToString() }, it => new BasLocation { is_lock = 1 });
+
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+}