diff --git a/BasicData/Tnb.BasicData.Entities/Consts/DictConst.cs b/BasicData/Tnb.BasicData.Entities/Consts/DictConst.cs
index bbd98d72..bfc6fcf5 100644
--- a/BasicData/Tnb.BasicData.Entities/Consts/DictConst.cs
+++ b/BasicData/Tnb.BasicData.Entities/Consts/DictConst.cs
@@ -12,6 +12,18 @@ public static class DictConst
///
public const string RegionCategoryStationCode = "workstation";
///
+ /// 区域类型-公司Code
+ ///
+ public const string RegionCategoryCompanyCode = "company";
+ ///
+ /// 区域类型-车间Code
+ ///
+ public const string RegionCategoryWorkshopCode = "workshop";
+ ///
+ /// 区域类型-产线Code
+ ///
+ public const string RegionCategoryWorklineCode = "workline";
+ ///
/// 备品备件类型
///
public const string SparePartsType = "SparePartsType";
@@ -102,8 +114,10 @@ public static class DictConst
/// 模具保养状态-待保养编码
///
public const string MoldMaintainStatusDBYCode = "UnMaintain";
-
-
+ ///
+ /// 任务单状态key
+ ///
+ public const string TaskStatus = "TaskStatus";
#endregion
diff --git a/BasicData/Tnb.BasicData.Entities/Consts/WebApiConst.cs b/BasicData/Tnb.BasicData.Entities/Consts/WebApiConst.cs
index c3312e59..bc6ff7f8 100644
--- a/BasicData/Tnb.BasicData.Entities/Consts/WebApiConst.cs
+++ b/BasicData/Tnb.BasicData.Entities/Consts/WebApiConst.cs
@@ -9,6 +9,9 @@ namespace Tnb.BasicData
//载具签收接口
public const string MES_CARRY_SIGN = "/api/wms/wms-sign-for-delivery/mes-carry-sign";
+
+ //生产出库接口
+ public const string MES_CREATE_OUTSTOCK = "/api/wms/wms-out-stock/mes-create-outstock";
#endregion
diff --git a/BasicData/Tnb.BasicData.Entities/Entity/BasLocation.cs b/BasicData/Tnb.BasicData.Entities/Entity/BasLocation.cs
index 4a348d76..9c902bc1 100644
--- a/BasicData/Tnb.BasicData.Entities/Entity/BasLocation.cs
+++ b/BasicData/Tnb.BasicData.Entities/Entity/BasLocation.cs
@@ -75,6 +75,10 @@ public partial class BasLocation : BaseEntity
/// 修改用户
///
public string? modify_id { get; set; }
+ ///
+ /// 载具规格分类Id
+ ///
+ public string carrystd_id { get; set; }
///
/// 修改时间
diff --git a/BasicData/Tnb.BasicData.Entities/Entity/BasQrcode.cs b/BasicData/Tnb.BasicData.Entities/Entity/BasQrcode.cs
new file mode 100644
index 00000000..8e0e5ebc
--- /dev/null
+++ b/BasicData/Tnb.BasicData.Entities/Entity/BasQrcode.cs
@@ -0,0 +1,47 @@
+using JNPF.Common.Contracts;
+using JNPF.Common.Security;
+using SqlSugar;
+
+namespace Tnb.BasicData.Entities;
+
+///
+/// 系统二维码表
+///
+[SugarTable("bas_qrcode")]
+public partial class BasQrcode : BaseEntity
+{
+ public BasQrcode()
+ {
+ id = SnowflakeIdHelper.NextId();
+ }
+ ///
+ /// 编码
+ ///
+ public string code { get; set; } = string.Empty;
+
+ ///
+ /// 关联表id
+ ///
+ public string? source_id { get; set; }
+
+ ///
+ /// 关联表名
+ ///
+ public string? source_name { get; set; }
+
+ ///
+ /// 创建用户
+ ///
+ public string? create_id { get; set; }
+
+ ///
+ /// 创建时间
+ ///
+ public DateTime? create_time { get; set; }
+
+ ///
+ /// 所属组织
+ ///
+ public string? org_id { get; set; }
+
+}
\ No newline at end of file
diff --git a/BasicData/Tnb.BasicData.Entities/Entity/BasStandardTime.cs b/BasicData/Tnb.BasicData.Entities/Entity/BasStandardTime.cs
new file mode 100644
index 00000000..e52075d7
--- /dev/null
+++ b/BasicData/Tnb.BasicData.Entities/Entity/BasStandardTime.cs
@@ -0,0 +1,112 @@
+using JNPF.Common.Contracts;
+using JNPF.Common.Security;
+using SqlSugar;
+
+namespace Tnb.BasicData.Entities;
+
+///
+/// 标准工时
+///
+[SugarTable("bas_standard_time")]
+public partial class BasStandardTime : BaseEntity
+{
+ public BasStandardTime()
+ {
+ id = SnowflakeIdHelper.NextId();
+ }
+ ///
+ /// 生产BOMid
+ ///
+ public string? mbom_id { get; set; }
+
+ ///
+ /// 工艺路线id
+ ///
+ public string? routing_id { get; set; }
+
+ ///
+ /// 工序id
+ ///
+ public string? process_id { get; set; }
+
+ ///
+ /// 工位id
+ ///
+ public string? station_id { get; set; }
+
+ ///
+ /// 类型
+ ///
+ public string? type { get; set; }
+
+ ///
+ /// 标准工时
+ ///
+ public string? standard_time { get; set; }
+
+ ///
+ /// 标准工时单位
+ ///
+ public string? standard_time_unit { get; set; }
+
+ ///
+ /// 标准产能
+ ///
+ public string? standard_capacity { get; set; }
+
+ ///
+ /// 标准产能单位
+ ///
+ public string? standard_capacity_unit { get; set; }
+
+ ///
+ /// 创建用户
+ ///
+ public string? create_id { get; set; }
+
+ ///
+ /// 创建时间
+ ///
+ public DateTime? create_time { get; set; }
+
+ ///
+ /// 修改用户
+ ///
+ public string? modify_id { get; set; }
+
+ ///
+ /// 修改时间
+ ///
+ public DateTime? modify_time { get; set; }
+
+ ///
+ /// 所属组织
+ ///
+ public string? org_id { get; set; }
+
+ ///
+ /// 编号
+ ///
+ public string? code { get; set; }
+
+ ///
+ /// 流程任务Id
+ ///
+ public string? f_flowtaskid { get; set; }
+
+ ///
+ /// 流程引擎Id
+ ///
+ public string? f_flowid { get; set; }
+
+ ///
+ /// 是否启用
+ ///
+ public int? enabled { get; set; }
+
+ ///
+ /// 工序来源选择
+ ///
+ public string? process_source { get; set; }
+
+}
diff --git a/EquipMgr/Tnb.EquipMgr.Entities/Dto/WorklineAndEquipTreeOutput.cs b/EquipMgr/Tnb.EquipMgr.Entities/Dto/WorklineAndEquipTreeOutput.cs
new file mode 100644
index 00000000..dcfee410
--- /dev/null
+++ b/EquipMgr/Tnb.EquipMgr.Entities/Dto/WorklineAndEquipTreeOutput.cs
@@ -0,0 +1,42 @@
+namespace Tnb.EquipMgr.Entities.Dto
+{
+ public class WorklineAndEquipTreeOutput
+ {
+ ///
+ /// 获取节点id.
+ ///
+ ///
+ public string id { get; set; }
+
+ ///
+ /// 标题
+ ///
+ public string title { get; set; }
+
+ ///
+ /// 获取节点父id.
+ ///
+ ///
+ public string parentId { get; set; }
+
+ ///
+ /// 是否有子级.
+ ///
+ public bool hasChildren { get; set; }
+
+ ///
+ /// 设置Children.
+ ///
+ public List? children { get; set; } = new List();
+
+ ///
+ /// 子节点数量.
+ ///
+ public int num { get; set; }
+
+ ///
+ /// 是否为子节点.
+ ///
+ public bool isLeaf { get; set; } = false;
+ }
+}
\ No newline at end of file
diff --git a/EquipMgr/Tnb.EquipMgr.Interfaces/IEquipmentService.cs b/EquipMgr/Tnb.EquipMgr.Interfaces/IEquipmentService.cs
index a1255946..3473dbf8 100644
--- a/EquipMgr/Tnb.EquipMgr.Interfaces/IEquipmentService.cs
+++ b/EquipMgr/Tnb.EquipMgr.Interfaces/IEquipmentService.cs
@@ -17,5 +17,11 @@ namespace Tnb.EquipMgr.Interfaces
///
///
public Task GetListByTypeId(Dictionary dic);
+
+ ///
+ /// 获取产线和注塑挤出设备树
+ ///
+ ///
+ public Task GetWorklineAndEquipTree(Dictionary dic);
}
}
\ No newline at end of file
diff --git a/EquipMgr/Tnb.EquipMgr/EquipmentService.cs b/EquipMgr/Tnb.EquipMgr/EquipmentService.cs
index f2be6958..610e4002 100644
--- a/EquipMgr/Tnb.EquipMgr/EquipmentService.cs
+++ b/EquipMgr/Tnb.EquipMgr/EquipmentService.cs
@@ -1,16 +1,28 @@
using Aop.Api.Domain;
using Aspose.Cells.Drawing;
+using JNPF.Common.Core.Manager;
+using JNPF.Common.Dtos.VisualDev;
using JNPF.Common.Filter;
+using JNPF.Common.Security;
using JNPF.DependencyInjection;
using JNPF.DynamicApiController;
+using JNPF.Extras.CollectiveOAuth.Models;
+using JNPF.FriendlyException;
+using JNPF.Logging;
+using JNPF.Systems.Entitys.Permission;
using JNPF.VisualDev;
+using JNPF.VisualDev.Entitys;
using JNPF.VisualDev.Entitys.Dto.VisualDevModelData;
+using JNPF.VisualDev.Interfaces;
using Mapster;
using Microsoft.AspNetCore.Mvc;
+using Senparc.NeuChar.ApiHandlers;
using SqlSugar;
+using Tnb.BasicData;
using Tnb.EquipMgr.Entities;
using Tnb.EquipMgr.Entities.Dto;
using Tnb.EquipMgr.Interfaces;
+using Tnb.BasicData.Entities;
namespace Tnb.EquipMgr
{
@@ -24,12 +36,24 @@ namespace Tnb.EquipMgr
public class EquipmentService : IOverideVisualDevService, IEquipmentService, IDynamicApiController, ITransient
{
public OverideVisualDevFunc OverideFuncs { get; } = new OverideVisualDevFunc();
- private const string ModuleId = "25064865727509";
+ private const string ModuleId = "26012367560469";
private readonly ISqlSugarRepository _repository;
+ private readonly IVisualDevService _visualDevService;
+ private readonly IRunService _runService;
+ private readonly IUserManager _userManager;
- public EquipmentService(ISqlSugarRepository repository)
+ public EquipmentService(ISqlSugarRepository repository,
+ IVisualDevService visualDevService,
+ IUserManager userManager,
+ IRunService runService
+ )
{
_repository = repository;
+ _visualDevService = visualDevService;
+ _runService = runService;
+ _userManager = userManager;
+ OverideFuncs.CreateAsync = Create;
+ OverideFuncs.UpdateAsync = Update;
}
///
/// 在线开发-获取设备列表
@@ -62,6 +86,75 @@ namespace Tnb.EquipMgr
.ToPagedListAsync(input.currentPage, input.pageSize);
return pagedList;
}
+
+ private async Task Create(VisualDevModelDataCrInput visualDevModelDataCrInput)
+ {
+ string qrcode = visualDevModelDataCrInput.data.ContainsKey("qrcode") ? visualDevModelDataCrInput.data["qrcode"].ToString() : "";
+ if (!string.IsNullOrEmpty(qrcode) && await _repository.AsSugarClient().Queryable().AnyAsync(x => x.code == qrcode))
+ {
+ throw Oops.Bah("二维码总表中已存在该二维码");
+ }
+ else
+ {
+ VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleId, true);
+ await _runService.Create(templateEntity, visualDevModelDataCrInput);
+
+ string equipId = visualDevModelDataCrInput.data["ReturnIdentity"].ToString() ?? "";
+
+ if (!string.IsNullOrEmpty(qrcode))
+ {
+ BasQrcode basQrcode = new BasQrcode()
+ {
+ code = visualDevModelDataCrInput.data["qrcode"].ToString(),
+ source_id = equipId,
+ source_name = "EQP_EQUIPMENT",
+ create_id = _userManager.UserId,
+ create_time = DateTime.Now,
+ org_id = _userManager.GetUserInfo().Result.organizeId,
+ };
+ await _repository.AsSugarClient().Insertable(basQrcode).ExecuteCommandAsync();
+ }
+ }
+ return await Task.FromResult(true);
+ }
+
+ private async Task Update(string id,VisualDevModelDataUpInput visualDevModelDataUpInput)
+ {
+ string qrcode = visualDevModelDataUpInput.data.ContainsKey("qrcode") ? visualDevModelDataUpInput.data["qrcode"].ToString() : "";
+ if (!string.IsNullOrEmpty(qrcode) && await _repository.AsSugarClient().Queryable().AnyAsync(x => x.code == visualDevModelDataUpInput.data["qrcode"] && x.source_id!=id))
+ {
+ throw Oops.Bah("二维码总表中已存在该二维码");
+ }
+ else
+ {
+ VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleId, true);
+ await _runService.Update(id,templateEntity, visualDevModelDataUpInput);
+
+ if (!string.IsNullOrEmpty(qrcode))
+ {
+ if (await _repository.AsSugarClient().Queryable().AnyAsync(x => x.source_id == id))
+ {
+ await _repository.AsSugarClient().Updateable()
+ .SetColumns(x => x.code == visualDevModelDataUpInput.data["qrcode"].ToString()).Where(x => x.source_id == id)
+ .ExecuteCommandAsync();
+ }
+ else
+ {
+ BasQrcode basQrcode = new BasQrcode()
+ {
+ code = visualDevModelDataUpInput.data["qrcode"].ToString(),
+ source_id = id,
+ source_name = "EQP_EQUIPMENT",
+ create_id = _userManager.UserId,
+ create_time = DateTime.Now,
+ org_id = _userManager.GetUserInfo().Result.organizeId,
+ };
+ await _repository.AsSugarClient().Insertable(basQrcode).ExecuteCommandAsync();
+ }
+ }
+ }
+ return await Task.FromResult(true);
+ }
[HttpPost]
public async Task GetEntityById(Dictionary dic)
@@ -78,5 +171,67 @@ namespace Tnb.EquipMgr
return await _repository.AsSugarClient().Queryable().Where(x => typeIdArr.Contains(x.equip_type_id))
.ToListAsync();
}
+
+ [HttpPost]
+ public async Task GetWorklineAndEquipTree(Dictionary dic)
+ {
+ string equipTypes = dic.ContainsKey("equipTypes") ? dic["equipTypes"] : "";
+ var db = _repository.AsSugarClient();
+ var queryable1 = db.Queryable()
+ .Where((a) => a.DeleteMark == null && a.Category==DictConst.RegionCategoryWorkshopCode)
+ .Select((a) => new WorklineAndEquipTreeOutput()
+ {
+ id = a.Id,
+ title = a.EnCode+"/"+a.FullName,
+ parentId = "0",
+ hasChildren = SqlFunc.Subqueryable().Where(b=>b.ParentId==a.Id && b.DeleteMark==null && b.Category==DictConst.RegionCategoryWorklineCode).Any(),
+ num = SqlFunc.Subqueryable().Where(b=>b.ParentId==a.Id && b.DeleteMark==null && b.Category==DictConst.RegionCategoryWorklineCode).Count(),
+ isLeaf = false,
+ children = SqlFunc.Subqueryable().Where(b=>b.ParentId==a.Id && b.DeleteMark==null && b.Category==DictConst.RegionCategoryWorklineCode).ToList(b=>new WorklineAndEquipTreeOutput()
+ {
+ id = b.Id,
+ title = b.EnCode+"/"+b.FullName,
+ parentId = b.ParentId,
+ hasChildren = false,
+ num = 0,
+ isLeaf = true,
+ })
+ });
+
+ List list2 = new List();
+ if (!string.IsNullOrEmpty(equipTypes))
+ {
+ string[] equipTypeArr = equipTypes.Split(",");
+ list2 = await db.Queryable()
+ .Where((a) => equipTypeArr.Contains(a.code))
+ .Select((a) => new WorklineAndEquipTreeOutput()
+ {
+ id = a.id,
+ title = a.name,
+ parentId = "0",
+ hasChildren = SqlFunc.Subqueryable().Where(b=>b.equip_type_id==a.id).Any(),
+ num = SqlFunc.Subqueryable().Where(b=>b.equip_type_id==a.id).Count(),
+ isLeaf = false,
+ children = SqlFunc.Subqueryable().Where(b=>b.equip_type_id==a.id).ToList(b=>new WorklineAndEquipTreeOutput()
+ {
+ id = b.id,
+ title = b.code+"/"+b.name,
+ parentId = b.equip_type_id,
+ hasChildren = false,
+ num = 0,
+ isLeaf = true,
+ })
+ }).ToListAsync();
+
+ }
+
+ // var list = await db.UnionAll(queryable1, queryable2).ToListAsync();
+ var list1 = await queryable1.ToListAsync();
+ list1.AddRange(list2);
+ return new AuthResponse(200, "", new Dictionary()
+ {
+ ["list"] = list1,
+ });
+ }
}
}
\ No newline at end of file
diff --git a/EquipMgr/Tnb.EquipMgr/ToolMoldLocationService.cs b/EquipMgr/Tnb.EquipMgr/ToolMoldLocationService.cs
index bfc73a31..465f1a23 100644
--- a/EquipMgr/Tnb.EquipMgr/ToolMoldLocationService.cs
+++ b/EquipMgr/Tnb.EquipMgr/ToolMoldLocationService.cs
@@ -4,10 +4,17 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Aspose.Cells.Drawing;
+using JNPF.Common.Core.Manager;
+using JNPF.Common.Dtos.VisualDev;
using JNPF.DependencyInjection;
using JNPF.DynamicApiController;
+using JNPF.FriendlyException;
+using JNPF.VisualDev;
+using JNPF.VisualDev.Entitys;
+using JNPF.VisualDev.Interfaces;
using Microsoft.AspNetCore.Mvc;
using SqlSugar;
+using Tnb.BasicData.Entities;
using Tnb.EquipMgr.Entities;
using Tnb.EquipMgr.Interfaces;
@@ -18,16 +25,99 @@ namespace Tnb.EquipMgr
///
[ApiDescriptionSettings(Tag = ModuleConsts.Tag, Area = ModuleConsts.Area, Order = 700)]
[Route("api/[area]/[controller]/[action]")]
- public class ToolMoldLocationService : IToolMoldLocationService, IDynamicApiController, ITransient
+ [OverideVisualDev(ModuleId)]
+ public class ToolMoldLocationService : IToolMoldLocationService,IOverideVisualDevService, IDynamicApiController, ITransient
{
+ public OverideVisualDevFunc OverideFuncs { get; } = new OverideVisualDevFunc();
+ private const string ModuleId = "27207685649173";
private readonly ISqlSugarClient _db;
- public ToolMoldLocationService(ISqlSugarRepository repository)
+ private readonly IVisualDevService _visualDevService;
+ private readonly IRunService _runService;
+ private readonly IUserManager _userManager;
+ public ToolMoldLocationService(ISqlSugarRepository repository,
+ IVisualDevService visualDevService,
+ IUserManager userManager,
+ IRunService runService)
{
_db = repository.AsSugarClient();
+ _visualDevService = visualDevService;
+ _runService = runService;
+ _userManager = userManager;
+ OverideFuncs.CreateAsync = Create;
+ OverideFuncs.UpdateAsync = Update;
}
public async Task> GetLocationDictionary()
{
return await _db.Queryable().ToDictionaryAsync(x => x.id, x => x.location_code);
}
+
+ private async Task Create(VisualDevModelDataCrInput visualDevModelDataCrInput)
+ {
+ string qrcode = visualDevModelDataCrInput.data.ContainsKey("qrcode") ? visualDevModelDataCrInput.data["qrcode"].ToString() : "";
+ if (!string.IsNullOrEmpty(qrcode) && await _db.Queryable().AnyAsync(x => x.code == qrcode))
+ {
+ throw Oops.Bah("二维码总表中已存在该二维码");
+ }
+ else
+ {
+ VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleId, true);
+ await _runService.Create(templateEntity, visualDevModelDataCrInput);
+
+ string id = visualDevModelDataCrInput.data["ReturnIdentity"].ToString() ?? "";
+
+ if (!string.IsNullOrEmpty(qrcode))
+ {
+ BasQrcode basQrcode = new BasQrcode()
+ {
+ code = visualDevModelDataCrInput.data["qrcode"].ToString(),
+ source_id = id,
+ source_name = "TOOL_LOCATION",
+ create_id = _userManager.UserId,
+ create_time = DateTime.Now,
+ org_id = _userManager.GetUserInfo().Result.organizeId,
+ };
+ await _db.Insertable(basQrcode).ExecuteCommandAsync();
+ }
+ }
+ return await Task.FromResult(true);
+ }
+
+ private async Task Update(string id,VisualDevModelDataUpInput visualDevModelDataUpInput)
+ {
+ string qrcode = visualDevModelDataUpInput.data.ContainsKey("qrcode") ? visualDevModelDataUpInput.data["qrcode"].ToString() : "";
+ if (!string.IsNullOrEmpty(qrcode) && await _db.Queryable().AnyAsync(x => x.code == visualDevModelDataUpInput.data["qrcode"] && x.source_id!=id))
+ {
+ throw Oops.Bah("二维码总表中已存在该二维码");
+ }
+ else
+ {
+ VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleId, true);
+ await _runService.Update(id,templateEntity, visualDevModelDataUpInput);
+
+ if (!string.IsNullOrEmpty(qrcode))
+ {
+ if (await _db.Queryable().AnyAsync(x => x.source_id == id))
+ {
+ await _db.Updateable()
+ .SetColumns(x => x.code == visualDevModelDataUpInput.data["qrcode"].ToString()).Where(x => x.source_id == id)
+ .ExecuteCommandAsync();
+ }
+ else
+ {
+ BasQrcode basQrcode = new BasQrcode()
+ {
+ code = visualDevModelDataUpInput.data["qrcode"].ToString(),
+ source_id = id,
+ source_name = "TOOL_LOCATION",
+ create_id = _userManager.UserId,
+ create_time = DateTime.Now,
+ org_id = _userManager.GetUserInfo().Result.organizeId,
+ };
+ await _db.Insertable(basQrcode).ExecuteCommandAsync();
+ }
+ }
+ }
+ return await Task.FromResult(true);
+ }
}
}
diff --git a/PerMgr/Tnb.PerMgr.Entities/Entity/PerProcessStandardsH.cs b/PerMgr/Tnb.PerMgr.Entities/Entity/PerProcessStandardsH.cs
index feee5438..2c3cf474 100644
--- a/PerMgr/Tnb.PerMgr.Entities/Entity/PerProcessStandardsH.cs
+++ b/PerMgr/Tnb.PerMgr.Entities/Entity/PerProcessStandardsH.cs
@@ -103,5 +103,10 @@ public partial class PerProcessStandardsH : BaseEntity
/// 流程引擎Id
///
public string? f_flowid { get; set; }
+
+ ///
+ /// 成型周期
+ ///
+ public decimal? moulding_cycle { get; set; }
}
diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/CountEstimatedEndTimeInput.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/CountEstimatedEndTimeInput.cs
new file mode 100644
index 00000000..4f74f496
--- /dev/null
+++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/CountEstimatedEndTimeInput.cs
@@ -0,0 +1,25 @@
+namespace Tnb.ProductionMgr.Entities.Dto.PrdManage
+{
+ ///
+ /// 排产用于计算预计结束时间
+ ///
+ public class CountEstimatedEndTimeInput
+ {
+ public DateTime estimated_start_date { get; set; }
+
+ public int scheduled_qty { get; set; }
+
+ public string? equip_id { get; set; }
+
+ public string? molds_id { get; set; }
+
+ public string? material_id { get; set; }
+
+ public string? mbom_id { get; set; }
+
+ ///
+ /// 1 注塑挤出排产 2 组装包装排产
+ ///
+ public int type { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/FeedingRecordTreeOutput.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/FeedingRecordTreeOutput.cs
new file mode 100644
index 00000000..f8cae0d2
--- /dev/null
+++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/FeedingRecordTreeOutput.cs
@@ -0,0 +1,26 @@
+namespace Tnb.ProductionMgr.Entities.Dto
+{
+ public class FeedingRecordTreeOutput
+ {
+ public string id { get; set; }
+ public string mo_task_code { get; set; }
+ public List children { get; set; } = new List();
+ }
+
+ public class FeedingRecordChildren
+ {
+ public string id { get; set; }
+ public string code { get; set; }
+
+ public string mo_task_id { get; set; }
+
+ public List children { get; set; } = new List();
+ }
+
+ public class FeedingRecordMaterialChildren
+ {
+ public string material_code { get; set; }
+
+ public string material_name { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/ReportRecordListOutput.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/ReportRecordListOutput.cs
index d337b189..b060203a 100644
--- a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/ReportRecordListOutput.cs
+++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/ReportRecordListOutput.cs
@@ -27,5 +27,7 @@ namespace Tnb.ProductionMgr.Entities.Dto
public string? create_id { get; set; } = string.Empty;
public string? create_id_id { get; set; } = string.Empty;
public string? create_time { get; set; } = string.Empty;
+
+ public string? batch { get; set; } = string.Empty;
}
}
\ No newline at end of file
diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/WorkOrderAdjustmentListOutput.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/WorkOrderAdjustmentListOutput.cs
new file mode 100644
index 00000000..46a099c5
--- /dev/null
+++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/WorkOrderAdjustmentListOutput.cs
@@ -0,0 +1,21 @@
+namespace Tnb.ProductionMgr.Entities.Dto.PrdManage
+{
+ ///
+ /// 任务单调整列表输出
+ ///
+ public class WorkOrderAdjustmentListOutput
+ {
+ public string id { get; set; }
+ public string mo_task_code { get; set; }
+ public string mo_task_status { get; set; }
+ public string material_id { get; set; }
+ public string mold_id { get; set; }
+ public int? plan_qty { get; set; }
+ public int? complete_qty { get; set; }
+ public int? scheduled_qty { get; set; }
+ public string workline_id { get; set; }
+ public string estimated_start_date { get; set; }
+ public string estimated_end_date { get; set; }
+ public string eqp_id { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdOutstockD.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdOutstockD.cs
new file mode 100644
index 00000000..960834c6
--- /dev/null
+++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdOutstockD.cs
@@ -0,0 +1,57 @@
+using JNPF.Common.Contracts;
+using JNPF.Common.Security;
+using SqlSugar;
+
+namespace Tnb.ProductionMgr.Entities;
+
+///
+/// mes生产领料子表
+///
+[SugarTable("prd_outstock_d")]
+public partial class PrdOutstockD : BaseEntity
+{
+ public PrdOutstockD()
+ {
+ id = SnowflakeIdHelper.NextId();
+ }
+ ///
+ /// 物料id
+ ///
+ public string? material_id { get; set; }
+
+ ///
+ /// 物料编号
+ ///
+ public string? material_code { get; set; }
+
+ ///
+ /// 单位id
+ ///
+ public string? unit_id { get; set; }
+
+ ///
+ /// 出库需求数量
+ ///
+ public string? pr_qty { get; set; }
+
+ ///
+ /// 来源单据id
+ ///
+ public string? source_id { get; set; }
+
+ ///
+ /// 批次
+ ///
+ public string? code_batch { get; set; }
+
+ ///
+ /// 生产领料主表id
+ ///
+ public string? outstock_id { get; set; }
+
+ ///
+ /// 物料名称
+ ///
+ public string? material_name { get; set; }
+
+}
\ No newline at end of file
diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdOutstockH.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdOutstockH.cs
new file mode 100644
index 00000000..8e07b8db
--- /dev/null
+++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdOutstockH.cs
@@ -0,0 +1,72 @@
+using JNPF.Common.Contracts;
+using JNPF.Common.Security;
+using SqlSugar;
+
+namespace Tnb.ProductionMgr.Entities;
+
+///
+/// mes生产领料主表
+///
+[SugarTable("prd_outstock_h")]
+public partial class PrdOutstockH : BaseEntity
+{
+ public PrdOutstockH()
+ {
+ id = SnowflakeIdHelper.NextId();
+ }
+ ///
+ /// 出库单创建日期
+ ///
+ public string? bill_date { get; set; }
+
+ ///
+ /// 单据类型
+ ///
+ public string? bill_type { get; set; }
+
+ ///
+ /// 发料仓库id
+ ///
+ public string? warehouse_id { get; set; }
+
+ ///
+ /// 目标库位编号
+ ///
+ public string? location_code { get; set; }
+
+ ///
+ /// 创建用户
+ ///
+ public string? create_id { get; set; }
+
+ ///
+ /// 所属组织
+ ///
+ public string? org_id { get; set; }
+
+ ///
+ /// 单据编号
+ ///
+ public string? bill_code { get; set; }
+
+ ///
+ /// 发料工位
+ ///
+ public string? workstation { get; set; }
+
+ ///
+ /// 所属产线
+ ///
+ public string? workline { get; set; }
+
+ ///
+ /// 流程任务Id
+ ///
+ public string? f_flowtaskid { get; set; }
+
+ ///
+ /// 流程引擎Id
+ ///
+ public string? f_flowid { get; set; }
+
+}
\ No newline at end of file
diff --git a/ProductionMgr/Tnb.ProductionMgr.Interfaces/IPrdFeedingService.cs b/ProductionMgr/Tnb.ProductionMgr.Interfaces/IPrdFeedingService.cs
index c719944a..17e095c4 100644
--- a/ProductionMgr/Tnb.ProductionMgr.Interfaces/IPrdFeedingService.cs
+++ b/ProductionMgr/Tnb.ProductionMgr.Interfaces/IPrdFeedingService.cs
@@ -21,5 +21,11 @@ namespace Tnb.ProductionMgr.Interfaces
///
///
public Task SaveDataNew(MaterialReceiptNewInput input);
+
+ ///
+ /// 投料记录
+ ///
+ ///
+ public Task GetFeedingRecordTree();
}
}
\ No newline at end of file
diff --git a/ProductionMgr/Tnb.ProductionMgr.Interfaces/IPrdOutstockService.cs b/ProductionMgr/Tnb.ProductionMgr.Interfaces/IPrdOutstockService.cs
new file mode 100644
index 00000000..3d8bed0f
--- /dev/null
+++ b/ProductionMgr/Tnb.ProductionMgr.Interfaces/IPrdOutstockService.cs
@@ -0,0 +1,10 @@
+namespace Tnb.ProductionMgr.Interfaces
+{
+ ///
+ /// 生产领料服务
+ ///
+ public interface IPrdOutstockService
+ {
+
+ }
+}
\ No newline at end of file
diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdFeedingService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdFeedingService.cs
index 2a0d6aec..32bc5917 100644
--- a/ProductionMgr/Tnb.ProductionMgr/PrdFeedingService.cs
+++ b/ProductionMgr/Tnb.ProductionMgr/PrdFeedingService.cs
@@ -4,10 +4,13 @@ using JNPF.Common.Enums;
using JNPF.Common.Security;
using JNPF.DependencyInjection;
using JNPF.DynamicApiController;
+using JNPF.Extras.CollectiveOAuth.Models;
using JNPF.Extras.CollectiveOAuth.Utils;
using JNPF.FriendlyException;
+using JNPF.Logging;
using JNPF.Systems.Entitys.Permission;
using JNPF.Systems.Interfaces.System;
+using JNPF.VisualDev.Entitys;
using Microsoft.AspNetCore.Mvc;
using Microsoft.ClearScript.Util.Web;
using Newtonsoft.Json;
@@ -163,6 +166,9 @@ namespace Tnb.ProductionMgr
public async Task SaveDataNew(MaterialReceiptNewInput input)
{
var db = _repository.AsSugarClient();
+ PrdFeedingH prdFeedingH = null;
+ List list = new List();
+ DbResult result2 = new DbResult();
DbResult result = await db.Ado.UseTranAsync(async () =>
{
var moTask = await db.Queryable().FirstAsync(x => x.id == input.mo_task_id);
@@ -176,9 +182,8 @@ namespace Tnb.ProductionMgr
.ToListAsync();
-
string code = await _billRullService.GetBillNumber(Tnb.BasicData.CodeTemplateConst.FEEDING_CODE);
- PrdFeedingH prdFeedingH = new PrdFeedingH()
+ prdFeedingH = new PrdFeedingH()
{
code = code,
station_id = input.station_id,
@@ -195,8 +200,7 @@ namespace Tnb.ProductionMgr
create_time = DateTime.Now,
org_id = _userManager.GetUserInfo().Result.organizeId
};
-
- List list = new List();
+
if (input.details != null && input.details.Count > 0)
{
foreach (var item in input.details)
@@ -253,8 +257,8 @@ namespace Tnb.ProductionMgr
}
- await db.Insertable(prdFeedingH).ExecuteCommandAsync();
- await db.Insertable(list).ExecuteCommandAsync();
+ // await db.Insertable(prdFeedingH).ExecuteCommandAsync();
+ // await db.Insertable(list).ExecuteCommandAsync();
});
@@ -281,10 +285,69 @@ namespace Tnb.ProductionMgr
["Authorization"] = App.HttpContext.Request.Headers["Authorization"]
};
var sendResult = HttpUtils.RequestPost(domain + WebApiConst.MES_CARRY_SIGN,JsonConvert.SerializeObject(mesCarrySignInput),header);
+ Log.Information(sendResult);
+ AuthResponse authResponse = JsonConvert.DeserializeObject(sendResult);
+ if (authResponse.code != 200)
+ {
+ throw Oops.Bah(authResponse.msg);
+ }
+ else
+ {
+ result2 = await db.Ado.UseTranAsync(async () =>
+ {
+ await db.Insertable(prdFeedingH).ExecuteCommandAsync();
+ await db.Insertable(list).ExecuteCommandAsync();
+ });
+
+ }
}
- if(!result.IsSuccess) throw Oops.Oh(result.ErrorMessage);
- return result.IsSuccess ? "签收成功" : result.ErrorMessage;
+ if(!result2.IsSuccess) throw Oops.Oh(result2.ErrorMessage);
+ return result2.IsSuccess ? "签收成功" : result2.ErrorMessage;
+ }
+
+ [HttpPost]
+ public async Task GetFeedingRecordTree()
+ {
+ var db = _repository.AsSugarClient();
+ var result = await db.Queryable()
+ .Where(a => a.schedule_type == 2 && a.parent_id!=null)
+ .Select(a => new FeedingRecordTreeOutput()
+ {
+ mo_task_code = a.mo_task_code,
+ children = SqlFunc.Subqueryable().Where(b=>a.id==b.mo_task_id).ToList(b=>new FeedingRecordChildren()
+ {
+ id = b.id,
+ code = b.code,
+ // children = SqlFunc.Subqueryable().LeftJoin((c,d)=>c.material_id==d.id)
+ // .Where((c,d)=>SqlFunc.IIF(b==null,"0",b.id)==c.feeding_id).ToList((c,d)=>new FeedingRecordMaterialChildren()
+ // {
+ // // material_code = d.code,
+ // // material_name = d.name,
+ // })
+ // children = new List(),
+ // children = b!=null ? SqlFunc.Subqueryable()
+ // .Where((c)=>"26897270557717"=="26897270557717").ToList((c)=>new FeedingRecordMaterialChildren()
+ // {
+ // // material_code = d.code,
+ // // material_name = d.name,
+ // }) : new List()
+ })
+ }).Mapper(x =>
+ {
+ foreach (var item in x.children)
+ {
+ item.children = db.Queryable()
+ .LeftJoin((c, d) => c.material_id == d.id)
+ .Where((c, d) => item.id == c.feeding_id).Select((c,d) => new FeedingRecordMaterialChildren()
+ {
+ material_code = d.code,
+ material_name = d.name,
+ }).ToList();
+ }
+ })
+ .ToListAsync();
+ return result;
}
}
}
\ No newline at end of file
diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdInstockService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdInstockService.cs
index 4f2ededd..c56832e0 100644
--- a/ProductionMgr/Tnb.ProductionMgr/PrdInstockService.cs
+++ b/ProductionMgr/Tnb.ProductionMgr/PrdInstockService.cs
@@ -3,8 +3,10 @@ using JNPF.Common.Core.Manager;
using JNPF.Common.Enums;
using JNPF.DependencyInjection;
using JNPF.DynamicApiController;
+using JNPF.Extras.CollectiveOAuth.Models;
using JNPF.Extras.CollectiveOAuth.Utils;
using JNPF.FriendlyException;
+using JNPF.Logging;
using JNPF.RemoteRequest;
using JNPF.Systems.Interfaces.System;
using Mapster;
@@ -48,6 +50,8 @@ namespace Tnb.ProductionMgr
var db = _repository.AsSugarClient();
var location = await db.Queryable().FirstAsync(x => x.location_code == input.location_code);
PrdInstockH prdInstockH = null;
+ List prdInstockDs = new List() { };
+ DbResult result2 = new DbResult();
DbResult result = await db.Ado.UseTranAsync(async () =>
{
prdInstockH = new PrdInstockH()
@@ -63,7 +67,6 @@ namespace Tnb.ProductionMgr
status = 0,
};
- List prdInstockDs = new List() { };
foreach (var item in input.details)
{
prdInstockDs.Add(new PrdInstockD()
@@ -79,12 +82,12 @@ namespace Tnb.ProductionMgr
});
}
- await _repository.InsertAsync(prdInstockH);
-
- if (prdInstockDs.Count > 0)
- {
- await db.Insertable(prdInstockDs).ExecuteCommandAsync();
- }
+ // await _repository.InsertAsync(prdInstockH);
+ //
+ // if (prdInstockDs.Count > 0)
+ // {
+ // await db.Insertable(prdInstockDs).ExecuteCommandAsync();
+ // }
});
@@ -132,11 +135,29 @@ namespace Tnb.ProductionMgr
["Authorization"] = App.HttpContext.Request.Headers["Authorization"]
};
var sendResult = HttpUtils.RequestPost(domain + WebApiConst.MES_CREATE_INSTOCK,JsonConvert.SerializeObject(mesCreateInstockInput),header);
- Console.WriteLine(sendResult);
+ Log.Information(sendResult);
+ AuthResponse authResponse = JsonConvert.DeserializeObject(sendResult);
+ if (authResponse.code != 200)
+ {
+ throw Oops.Bah(authResponse.msg);
+ }
+ else
+ {
+ result2 = await db.Ado.UseTranAsync(async () =>
+ {
+ await _repository.InsertAsync(prdInstockH);
+
+ if (prdInstockDs.Count > 0)
+ {
+ await db.Insertable(prdInstockDs).ExecuteCommandAsync();
+ }
+ });
+
+ }
}
- if(!result.IsSuccess) throw Oops.Oh(ErrorCode.COM1008);
- return result.IsSuccess ? "保存成功" : result.ErrorMessage;
+ if(!result2.IsSuccess) throw Oops.Oh(ErrorCode.COM1008);
+ return result2.IsSuccess ? "保存成功" : result2.ErrorMessage;
}
///
@@ -147,15 +168,26 @@ namespace Tnb.ProductionMgr
public async Task SyncInstock(Dictionary dic)
{
string sourceId = dic.ContainsKey("source_id") ? dic["source_id"] : "";
- if (!string.IsNullOrEmpty(sourceId))
+ var db = _repository.AsSugarClient();
+ DbResult result = await db.Ado.UseTranAsync(async () =>
{
- return await _repository.UpdateAsync(x => new PrdInstockH()
+ if (!string.IsNullOrEmpty(sourceId))
{
- status = 1
- }, x => x.id == sourceId);
- }
+ await _repository.UpdateAsync(x => new PrdInstockH()
+ {
+ status = 1
+ }, x => x.id == sourceId);
+ var details = await db.Queryable().Where(x => x.instock_id == sourceId).ToListAsync();
- return false;
+ foreach (var item in details)
+ {
+ await db.Updateable().SetColumns(x => x.status == 1)
+ .Where(x => x.id == item.report_id).ExecuteCommandAsync();
+ }
+ }
+ });
+
+ return result.IsSuccess;
}
}
}
\ No newline at end of file
diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskIssueService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskIssueService.cs
index 28190f8d..2f3ebcec 100644
--- a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskIssueService.cs
+++ b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskIssueService.cs
@@ -20,6 +20,11 @@ using Tnb.ProductionMgr.Interfaces;
using Aspose.Cells.Drawing;
using Microsoft.AspNetCore.Mvc;
using JNPF.Common.Extension;
+using JNPF.Common.Filter;
+using JNPF.Systems.Entitys.System;
+using Newtonsoft.Json;
+using Senparc.Weixin.Work.AdvancedAPIs.OaDataOpen;
+using Tnb.BasicData;
namespace Tnb.ProductionMgr
{
@@ -46,54 +51,82 @@ namespace Tnb.ProductionMgr
}
+ // private async Task GetList(VisualDevModelListQueryInput input)
+ // {
+ // var db = _repository.AsSugarClient();
+ // VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleId, true);
+ // var data = await _runService.GetListResult(templateEntity, input);
+ // if (data?.list?.Count > 0)
+ // {
+ // var scheduledTypeField = nameof(PrdMoTask.schedule_type);
+ // data.list = data.list.Where(it => it[scheduledTypeField].IsNotEmptyOrNull() && it[scheduledTypeField].ParseToInt() == 1).ToList();
+ // foreach (var row in data.list)
+ // {
+ // var dic = row.ToDictionary(x => x.Key, x => x.Value);
+ // var pkName = "material_id";
+ // if (dic.ContainsKey(pkName))
+ // {
+ // var materialId = dic[pkName]?.ToString();
+ // var material = await db.Queryable().FirstAsync(it => it.id == materialId);
+ // if (material != null)
+ // {
+ // row["material_id"] = $"{material.code}/{material.name}";
+ // row["materialid"] = material.id;
+ // }
+ // }
+ // //模具
+ // if (dic.ContainsKey("mold_id"))
+ // {
+ // var moldId = dic["mold_id"]?.ToString();
+ // var mold = await db.Queryable().FirstAsync(it => it.id == moldId);
+ // if (mold != null)
+ // {
+ // row["mold_id"] = $"{mold.mold_code}/{mold.mold_name}";
+ // row["moldid"] = mold.id;
+ // }
+ // }
+ // //设备
+ // if (dic.ContainsKey("eqp_id"))
+ // {
+ // var eqpId = dic["eqp_id"]?.ToString();
+ // var eqp = await db.Queryable().FirstAsync(it => it.id == eqpId);
+ // if (eqp != null)
+ // {
+ // row["eqp_id"] = $"{eqp.code}/{eqp.name}";
+ // row["eqpid"] = eqp.id;
+ // }
+ // }
+ // }
+ // }
+ // return data!;
+ // }
+
private async Task GetList(VisualDevModelListQueryInput input)
{
var db = _repository.AsSugarClient();
- VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleId, true);
- var data = await _runService.GetListResult(templateEntity, input);
- if (data?.list?.Count > 0)
- {
- var scheduledTypeField = nameof(PrdMoTask.schedule_type);
- data.list = data.list.Where(it => it[scheduledTypeField].IsNotEmptyOrNull() && it[scheduledTypeField].ParseToInt() == 1).ToList();
- foreach (var row in data.list)
+ Dictionary queryJson = !string.IsNullOrEmpty(input.queryJson) ? JsonConvert.DeserializeObject>(input.queryJson) : new Dictionary();
+ string moTaskCode = queryJson.ContainsKey("mo_task_code") ? queryJson["mo_task_code"].ToString() : "";
+ string moTaskStatus = queryJson.ContainsKey("mo_task_status") ? queryJson["mo_task_status"].ToString() : "";
+ var result = await db.Queryable()
+ .LeftJoin((a, b) => a.material_id == b.id)
+ .LeftJoin((a, b, c) => c.EnCode == DictConst.TaskStatus)
+ .LeftJoin((a, b, c, d) => c.Id == d.DictionaryTypeId && a.mo_task_status == d.EnCode)
+ .LeftJoin((a,b,c,d,e)=>a.mold_id==e.id)
+ .LeftJoin((a,b,c,d,e,f)=>a.mo_id==f.id)
+ .WhereIF(!string.IsNullOrEmpty(moTaskCode), (a, b, c, d) => a.mo_task_code.Contains(moTaskCode))
+ .WhereIF(!string.IsNullOrEmpty(moTaskStatus), (a, b, c, d) => a.mo_task_status == moTaskStatus)
+ .Where((a,b,c,d,e,f)=>a.schedule_type==1)
+ .Select((a, b, c, d,e,f) => new PrdMoTask
{
- var dic = row.ToDictionary(x => x.Key, x => x.Value);
- var pkName = "material_id";
- if (dic.ContainsKey(pkName))
- {
- var materialId = dic[pkName]?.ToString();
- var material = await db.Queryable().FirstAsync(it => it.id == materialId);
- if (material != null)
- {
- row["material_id"] = $"{material.code}/{material.name}";
- row["materialid"] = material.id;
- }
- }
- //模具
- if (dic.ContainsKey("mold_id"))
- {
- var moldId = dic["mold_id"]?.ToString();
- var mold = await db.Queryable().FirstAsync(it => it.id == moldId);
- if (mold != null)
- {
- row["mold_id"] = $"{mold.mold_code}/{mold.mold_name}";
- row["moldid"] = mold.id;
- }
- }
- //设备
- if (dic.ContainsKey("eqp_id"))
- {
- var eqpId = dic["eqp_id"]?.ToString();
- var eqp = await db.Queryable().FirstAsync(it => it.id == eqpId);
- if (eqp != null)
- {
- row["eqp_id"] = $"{eqp.code}/{eqp.name}";
- row["eqpid"] = eqp.id;
- }
- }
- }
- }
- return data!;
+ id = a.id,
+ mo_task_code = a.mo_task_code,
+ material_id = b.code+"/"+b.name,
+ mold_id = e.mold_code+"/"+e.mold_name,
+ mo_task_status = d.FullName,
+ plan_qty = f.plan_qty,
+ scheduled_qty = a.scheduled_qty,
+ }).ToPagedListAsync(input.currentPage, input.pageSize);
+ return PageResult.SqlSugarPageResult(result);
}
}
}
diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs
index f73b3872..45287ded 100644
--- a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs
+++ b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs
@@ -43,6 +43,9 @@ using Microsoft.ClearScript.Util.Web;
using Newtonsoft.Json;
using Tnb.BasicData.Entities.Dto;
using NPOI.SS.Formula.Functions;
+using Tnb.PerMgr.Entities;
+
+// using Tnb.PerMgr.Entities;
namespace Tnb.ProductionMgr
{
@@ -515,7 +518,7 @@ namespace Tnb.ProductionMgr
[HttpGet]
public async Task GetUnSchedulingList([FromQuery] VisualDevModelListQueryInput input)
{
- Dictionary queryJson = input.queryJson!=null ? JsonConvert.DeserializeObject>(input.queryJson) : null;
+ Dictionary queryJson = !string.IsNullOrEmpty(input.queryJson) ? JsonConvert.DeserializeObject>(input.queryJson) : new Dictionary();
List moStatusList = new List();
if (queryJson!=null && queryJson.ContainsKey("mo_stauts"))
{
@@ -888,6 +891,7 @@ namespace Tnb.ProductionMgr
if (subTaskList?.Count > 0)
{
List subMoTasks = new();
+ List subMoTaskLogs = new();
foreach (var item in subTaskList)
{
PrdMoTask subMoTask = new();
@@ -909,6 +913,20 @@ namespace Tnb.ProductionMgr
subMoTask.create_id = _userManager.UserId;
subMoTask.create_time = DateTime.Now;
subMoTasks.Add(subMoTask);
+
+ var subTaskLog = new PrdTaskLog();
+ var subMaterial = await _db.Queryable().SingleAsync(x => x.id == item.material_id);
+ subTaskLog.id = SnowflakeIdHelper.NextId();
+ subTaskLog.mo_code = (await _db.Queryable().FirstAsync(it => it.id == input.mo_id))?.mo_code!;
+ subTaskLog.item_code = subMaterial?.code!;
+ subTaskLog.item_standard = subMaterial?.material_standard!;
+ subTaskLog.status = DictConst.ToBeScheduledEncode;
+ subTaskLog.operator_name = _userManager.RealName;
+ subTaskLog.create_id = _userManager.UserId;
+ subTaskLog.create_time = DateTime.Now;
+ subTaskLog.mo_task_id = subMoTask.id;
+ subTaskLog.mo_task_code = subMoTask.mo_task_code!;
+ subMoTaskLogs.Add(subTaskLog);
}
//根据生产任务编号生成子任务编号
if (moTask.mo_task_code!.IsNotEmptyOrNull())
@@ -920,6 +938,7 @@ namespace Tnb.ProductionMgr
}
}
row = await _db.Insertable(subMoTasks).ExecuteCommandAsync();
+ await _db.Insertable(subMoTaskLogs).ExecuteCommandAsync();
}
await _db.Ado.CommitTranAsync();
}
@@ -1575,49 +1594,93 @@ namespace Tnb.ProductionMgr
}
return instance;
}
+ // private async Task GetList(VisualDevModelListQueryInput input)
+ // {
+ // var db = _repository.AsSugarClient();
+ // VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleId, true);
+ // var data = await _runService.GetListResult(templateEntity, input);
+ // if (data?.list?.Count > 0)
+ // {
+ // foreach (var row in data.list)
+ // {
+ // var dic = row.ToDictionary(x => x.Key, x => x.Value);
+ // var pkName = "material_id_id";
+ // if (dic.ContainsKey(pkName))
+ // {
+ // var materialId = dic[pkName]?.ToString();
+ // var material = await db.Queryable().FirstAsync(it => it.id == materialId);
+ // if (material != null)
+ // {
+ // row["material_id"] = $"{material.code}/{material.name}";
+ // }
+ // }
+ // //模具
+ // if (dic.ContainsKey("mold_id"))
+ // {
+ // var moldId = dic["mold_id"]?.ToString();
+ // var mold = await db.Queryable().FirstAsync(it => it.id == moldId);
+ // if (mold != null)
+ // {
+ // row["mold_id"] = $"{mold.mold_code}/{mold.mold_name}";
+ // }
+ // }
+ // //设备
+ // if (dic.ContainsKey("eqp_id"))
+ // {
+ // var eqpId = dic["eqp_id"]?.ToString();
+ // var eqp = await db.Queryable().FirstAsync(it => it.id == eqpId);
+ // if (eqp != null)
+ // {
+ // row["eqp_id"] = $"{eqp.code}/{eqp.name}";
+ // }
+ // }
+ // }
+ // }
+ // return data!;
+ // }
+
private async Task GetList(VisualDevModelListQueryInput input)
{
var db = _repository.AsSugarClient();
- VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleId, true);
- var data = await _runService.GetListResult(templateEntity, input);
- if (data?.list?.Count > 0)
+ Dictionary queryJson = !string.IsNullOrEmpty(input.queryJson) ? JsonConvert.DeserializeObject>(input.queryJson) : new Dictionary();
+ string moTaskCode = queryJson.ContainsKey("mo_task_code") ? queryJson["mo_task_code"].ToString() : "";
+ string eqpId = queryJson.ContainsKey("eqp_id") ? queryJson["eqp_id"].ToString() : "";
+ List worklineIds = new List();
+ List equipIds = new List();
+ if (!string.IsNullOrEmpty(eqpId))
{
- foreach (var row in data.list)
- {
- var dic = row.ToDictionary(x => x.Key, x => x.Value);
- var pkName = "material_id_id";
- if (dic.ContainsKey(pkName))
- {
- var materialId = dic[pkName]?.ToString();
- var material = await db.Queryable().FirstAsync(it => it.id == materialId);
- if (material != null)
- {
- row["material_id"] = $"{material.code}/{material.name}";
- }
- }
- //模具
- if (dic.ContainsKey("mold_id"))
- {
- var moldId = dic["mold_id"]?.ToString();
- var mold = await db.Queryable().FirstAsync(it => it.id == moldId);
- if (mold != null)
- {
- row["mold_id"] = $"{mold.mold_code}/{mold.mold_name}";
- }
- }
- //设备
- if (dic.ContainsKey("eqp_id"))
- {
- var eqpId = dic["eqp_id"]?.ToString();
- var eqp = await db.Queryable().FirstAsync(it => it.id == eqpId);
- if (eqp != null)
- {
- row["eqp_id"] = $"{eqp.code}/{eqp.name}";
- }
- }
- }
+ worklineIds = await db.Queryable().Where(x => x.ParentId == eqpId && x.Category==DictConst.RegionCategoryWorklineCode && x.DeleteMark==null).Select(x=>x.Id).ToListAsync();
+ equipIds = await db.Queryable().Where(x => x.equip_type_id == eqpId).Select(x => x.id).ToListAsync();
}
- return data!;
+
+ var result = await db.Queryable()
+ .LeftJoin((a, b) => a.material_id == b.id)
+ .LeftJoin((a, b, c) => c.EnCode == DictConst.TaskStatus)
+ .LeftJoin((a, b, c, d) => c.Id == d.DictionaryTypeId && a.mo_task_status == d.EnCode)
+ .LeftJoin((a,b,c,d,e)=>a.mold_id==e.id)
+ .LeftJoin((a,b,c,d,e,f)=>a.mo_id==f.id)
+ .LeftJoin((a,b,c,d,e,f,g)=>a.workline_id==g.Id)
+ .LeftJoin((a,b,c,d,e,f,g,h)=>a.eqp_id==h.id)
+ .WhereIF(!string.IsNullOrEmpty(moTaskCode), (a, b, c, d) => a.mo_task_code.Contains(moTaskCode))
+ .WhereIF(!string.IsNullOrEmpty(eqpId) && equipIds.Count<=0 && worklineIds.Count<=0, (a, b, c, d) => a.workline_id==eqpId || a.eqp_id==eqpId)
+ .WhereIF(worklineIds.Count>0,(a, b, c, d)=>worklineIds.Contains(a.workline_id))
+ .WhereIF(equipIds.Count>0,(a, b, c, d)=>equipIds.Contains(a.eqp_id))
+ .Select((a, b, c, d,e,f,g,h) => new WorkOrderAdjustmentListOutput
+ {
+ id = a.id,
+ mo_task_code = a.mo_task_code,
+ material_id = b.code+"/"+b.name,
+ mold_id = e.mold_code+"/"+e.mold_name,
+ mo_task_status = d.FullName,
+ plan_qty = f.plan_qty,
+ complete_qty = SqlFunc.IsNull(a.reported_work_qty,0) + SqlFunc.IsNull(a.scrap_qty,0),
+ scheduled_qty = a.scheduled_qty,
+ workline_id = a.workline_id==null ? "" :g.EnCode+"/"+g.FullName,
+ estimated_start_date = a.estimated_start_date==null ? "" : a.estimated_start_date.Value.ToString("yyyy-MM-dd"),
+ estimated_end_date = a.estimated_end_date==null ? "" : a.estimated_end_date.Value.ToString("yyyy-MM-dd"),
+ eqp_id = a.eqp_id==null ? "" : h.code+"/"+h.name,
+ }).ToPagedListAsync(input.currentPage, input.pageSize);
+ return PageResult.SqlSugarPageResult(result);
}
///
@@ -1651,5 +1714,39 @@ namespace Tnb.ProductionMgr
{
return await _db.Queryable().Where(it => it.eqp_id == eqpId && it.mo_task_status == DictConst.InProgressEnCode).ToListAsync();
}
+
+ [HttpPost]
+ public async Task GetEstimatedEndTime(CountEstimatedEndTimeInput input)
+ {
+ var db = _repository.AsSugarClient();
+ if (input.type == 1)
+ {
+ PerProcessStandardsH processStandardsH = await db.Queryable()
+ .Where(x => x.equip_id == input.equip_id && x.molds_id == input.molds_id &&
+ x.output_material_id == input.material_id && x.enabled == 1)
+ .OrderByDescending(x => x.create_time).FirstAsync();
+
+ ToolMolds toolMolds = await db.Queryable().SingleAsync(x => x.id == input.molds_id);
+ if(toolMolds==null) throw Oops.Bah("没找到模具");
+ if(toolMolds?.mold_cavity<=0) throw Oops.Bah("模穴数错误");
+ if (processStandardsH == null) throw Oops.Bah("工艺标准成型周期错误");
+ if (processStandardsH?.moulding_cycle <= 0) throw Oops.Bah("工艺标准成型周期错误");
+
+ decimal? addTime = (input.scheduled_qty * toolMolds.mold_cavity - 1) / processStandardsH?.moulding_cycle + 1;
+ return input.estimated_start_date.AddSeconds((double)addTime.Value).ToString("yyyy-MM-dd HH:mm:ss");
+ }
+ else
+ {
+ var list = await db.Queryable()
+ .LeftJoin((a,b)=>a.process_id==b.process_id)
+ .Where((a,b)=>a.mbom_id==input.mbom_id).Select((a,b)=>b).ToListAsync();
+
+ decimal max = list.Select(x => Convert.ToDecimal(x.standard_time)).Max(x => x);
+ decimal? addTime = input.scheduled_qty * max;
+ return input.estimated_start_date.AddSeconds((double)addTime.Value).ToString("yyyy-MM-dd HH:mm:ss");
+ }
+
+ }
+
}
}
diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdOutstockService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdOutstockService.cs
new file mode 100644
index 00000000..91be4166
--- /dev/null
+++ b/ProductionMgr/Tnb.ProductionMgr/PrdOutstockService.cs
@@ -0,0 +1,117 @@
+using JNPF;
+using JNPF.Common.Core.Manager;
+using JNPF.Common.Dtos.VisualDev;
+using JNPF.DependencyInjection;
+using JNPF.DynamicApiController;
+using JNPF.Extras.CollectiveOAuth.Models;
+using JNPF.Extras.CollectiveOAuth.Utils;
+using JNPF.FriendlyException;
+using JNPF.Logging;
+using JNPF.Systems.Interfaces.System;
+using JNPF.VisualDev;
+using JNPF.VisualDev.Entitys;
+using JNPF.VisualDev.Interfaces;
+using Microsoft.AspNetCore.Mvc;
+using Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
+using SqlSugar;
+using Tnb.BasicData;
+using Tnb.BasicData.Entities;
+using Tnb.ProductionMgr.Entities;
+using Tnb.ProductionMgr.Interfaces;
+using Tnb.WarehouseMgr.Entities.Dto.Inputs;
+
+namespace Tnb.ProductionMgr
+{
+ ///
+ /// 生产领料
+ ///
+ [ApiDescriptionSettings(Tag = ModuleConst.Tag, Area = ModuleConst.Area, Order = 700)]
+ [Route("api/[area]/[controller]/[action]")]
+ [OverideVisualDev(ModuleId)]
+ public class PrdOutstockService : IOverideVisualDevService, IPrdOutstockService, IDynamicApiController, ITransient
+ {
+ private const string ModuleId = "27542506559765";
+ private readonly ISqlSugarRepository _repository;
+ private readonly ISqlSugarClient _db;
+ private readonly IRunService _runService;
+ private readonly IVisualDevService _visualDevService;
+ private readonly IDictionaryDataService _dictionaryDataService;
+ private readonly IUserManager _userManager;
+ public OverideVisualDevFunc OverideFuncs { get; } = new OverideVisualDevFunc();
+
+ public PrdOutstockService(ISqlSugarRepository repository, IRunService runService, IUserManager userManager,IVisualDevService visualDevService, IDictionaryDataService dictionaryDataService)
+ {
+ _db = repository.AsSugarClient();
+ _runService = runService;
+ _visualDevService = visualDevService;
+ _dictionaryDataService = dictionaryDataService;
+ _repository = repository;
+ _userManager = userManager;
+ OverideFuncs.CreateAsync = Create;
+ }
+
+ private async Task Create(VisualDevModelDataCrInput visualDevModelDataCrInput)
+ {
+ try
+ {
+ var db = _repository.AsSugarClient();
+
+ MESCreateOutstockInput input = new MESCreateOutstockInput();
+ input.outstock = new MESWmsOutstockHInput();
+ input.outstockDs = new List();
+
+ string locationId = visualDevModelDataCrInput.data.ContainsKey("location_id") ? visualDevModelDataCrInput.data["location_id"].ToString() : "";
+ BasLocation location = await db.Queryable().SingleAsync(x => x.id == locationId);
+
+ input.outstock.bill_type = visualDevModelDataCrInput.data.ContainsKey("bill_type") ? visualDevModelDataCrInput.data["bill_type"].ToString() : "";
+ input.outstock.bill_date = visualDevModelDataCrInput.data.ContainsKey("bill_date") ? Convert.ToDateTime(visualDevModelDataCrInput.data["bill_date"].ToString()) : DateTime.Now;
+ input.outstock.org_id = _userManager.GetUserInfo().Result.organizeId;
+ input.outstock.warehouse_id = visualDevModelDataCrInput.data.ContainsKey("warehouse_id") ? visualDevModelDataCrInput.data["warehouse_id"].ToString() : "";
+ input.outstock.create_id = _userManager.UserId;
+ input.outstock.location_code = location?.location_code ?? "";
+
+ // foreach (var item in (JArray)visualDevModelDataCrInput.data["tablefield107"])
+ // {
+ // input.outstockDs.Add(new MESWmsOutstockDInput()
+ // {
+ // material_id = item.Value("material_id"),
+ // material_code = item.Value("material_code"),
+ // unit_id = item.Value("unit_id"),
+ // pr_qty = item.Value("pr_qty"),
+ // code_batch = item.Value("code_batch"),
+ // source_id = item.Value("source_id"),
+ // });
+ // }
+
+ input.outstockDs = JsonConvert.DeserializeObject>(JsonConvert.SerializeObject(visualDevModelDataCrInput.data["tablefield107"]));
+ string domain = (App.HttpContext.Request.IsHttps ? "https://" : "http://") + App.HttpContext.Request.Host;
+ Dictionary header = new Dictionary()
+ {
+ ["Authorization"] = App.HttpContext.Request.Headers["Authorization"]
+ };
+ var sendResult = HttpUtils.RequestPost(domain + WebApiConst.MES_CREATE_OUTSTOCK,JsonConvert.SerializeObject(input),header);
+ Log.Information(sendResult);
+
+ AuthResponse authResponse = JsonConvert.DeserializeObject(sendResult);
+ if (authResponse.code != 200)
+ {
+ throw Oops.Bah(authResponse.msg);
+ }
+ else
+ {
+ VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleId, true);
+ await _runService.Create(templateEntity, visualDevModelDataCrInput);
+ }
+ return await Task.FromResult(true);
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine(e);
+ Log.Error(e.Message);
+ throw Oops.Bah(e.Message);
+ }
+
+ }
+ }
+}
\ No newline at end of file
diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdTaskManageService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdTaskManageService.cs
index ff33e912..c7cb7feb 100644
--- a/ProductionMgr/Tnb.ProductionMgr/PrdTaskManageService.cs
+++ b/ProductionMgr/Tnb.ProductionMgr/PrdTaskManageService.cs
@@ -23,6 +23,7 @@ using Microsoft.AspNetCore.Mvc;
using DbModels;
using JNPF.Common.Extension;
using JNPF.Common.Filter;
+using JNPF.Common.Security;
using Tnb.ProductionMgr.Entities.Dto.PrdManage;
using NPOI.OpenXmlFormats;
using JNPF.Systems.Entitys.Permission;
@@ -116,26 +117,31 @@ namespace Tnb.ProductionMgr
private async Task GetList(VisualDevModelListQueryInput input)
{
var db = _repository.AsSugarClient();
- Dictionary queryJson = input.queryJson!=null ? JsonConvert.DeserializeObject>(input.queryJson) : null;
+ Dictionary queryJson = !string.IsNullOrEmpty(input.queryJson) ? JsonConvert.DeserializeObject>(input.queryJson) : new Dictionary();
string moTaskCode = queryJson!=null && queryJson.ContainsKey("mo_task_code") ? queryJson["mo_task_code"].ToString() : "";
- Dictionary dic = new Dictionary()
+ Dictionary dic = await _dictionaryDataService.GetDicByKey(DictConst.TaskStatus);
+
+ DateTime[] planStartDateArr = null;
+ DateTime[] planEndDateArr = null;
+ if (queryJson.TryGetValue("plan_start_date", out var value1))
{
- [DictConst.ToBeStartedEnCode] = "待开工",
- [DictConst.InProgressEnCode] = "进行中",
- [DictConst.ClosedEnCode] = "关闭",
- [DictConst.ComplatedEnCode] = "完工",
- [DictConst.ToBeScheduledEncode] = "待排产",
- [DictConst.MoStatusPauseCode] = "暂停",
- [DictConst.MoStatusExceptionCode] = "异常",
- [DictConst.MoStatusRevokeCode] = "撤销",
- };
+ planStartDateArr = value1.ToObject().Select(x=>x.TimeStampToDateTime()).ToArray();
+ }
+ if (queryJson.TryGetValue("plan_end_date", out var value2))
+ {
+ planEndDateArr = value2.ToObject().Select(x=>x.TimeStampToDateTime()).ToArray();
+ }
+
+
var result = await db.Queryable()
.LeftJoin((a, b) => a.eqp_id == b.id)
.LeftJoin((a, b, c) => a.material_id == c.id)
.LeftJoin((a, b, c, d) => a.mold_id == d.id)
- //.Where((a,b,c,d)=>(a.mo_task_status==DictConst.ToBeStartedEnCode || a.mo_task_status==DictConst.InProgressEnCode || a.mo_task_status==DictConst.MoStatusExceptionCode))
+ .Where((a,b,c,d)=>(a.mo_task_status==DictConst.ToBeStartedEnCode || a.mo_task_status==DictConst.InProgressEnCode || a.mo_task_status==DictConst.MoStatusExceptionCode || a.mo_task_status==DictConst.MoStatusPauseCode || a.mo_task_status==DictConst.ComplatedEnCode))
.Where((a,b,c,d)=>a.schedule_type==1)
.WhereIF(!string.IsNullOrEmpty(moTaskCode),(a,b,c,d)=>a.mo_task_code.Contains(moTaskCode))
+ .WhereIF(planStartDateArr!=null, (a, b, c, d) => a.estimated_start_date>=planStartDateArr[0] && a.estimated_start_date<=planStartDateArr[1])
+ .WhereIF(planEndDateArr!=null, (a, b, c, d) => a.estimated_end_date>=planEndDateArr[0] && a.estimated_end_date<=planEndDateArr[1])
.OrderByDescending((a, b, c, d) => a.create_time)
.Select((a, b, c, d) => new PrdTaskManageListOutput()
{
@@ -152,7 +158,7 @@ namespace Tnb.ProductionMgr
schedule_type = a.schedule_type.ToString()
})
- .Mapper(x=>x.mo_task_status=dic[x.mo_task_status])
+ .Mapper(x=>x.mo_task_status=dic[x.mo_task_status].ToString())
.ToPagedListAsync(input.currentPage, input.pageSize);
return PageResult.SqlSugarPageResult(result);
}
diff --git a/ProductionMgr/Tnb.ProductionMgr/ProductionReportRecordService.cs b/ProductionMgr/Tnb.ProductionMgr/ProductionReportRecordService.cs
index 78493934..40f896d0 100644
--- a/ProductionMgr/Tnb.ProductionMgr/ProductionReportRecordService.cs
+++ b/ProductionMgr/Tnb.ProductionMgr/ProductionReportRecordService.cs
@@ -126,7 +126,8 @@ namespace Tnb.ProductionMgr
reported_qty = x.reported_qty,
create_id = y.RealName,
create_id_id = x.create_id,
- create_time = x.create_time==null ? "" : x.create_time.Value.ToString("yyyy-MM-dd HH:mm")
+ create_time = x.create_time==null ? "" : x.create_time.Value.ToString("yyyy-MM-dd HH:mm"),
+ batch = x.batch
})
}).ToPagedListAsync(input.currentPage, input.pageSize);
return PageResult.SqlSugarPageResult(result);
diff --git a/ProductionMgr/Tnb.ProductionMgr/Tnb.ProductionMgr.csproj b/ProductionMgr/Tnb.ProductionMgr/Tnb.ProductionMgr.csproj
index 6316cd83..6aa07278 100644
--- a/ProductionMgr/Tnb.ProductionMgr/Tnb.ProductionMgr.csproj
+++ b/ProductionMgr/Tnb.ProductionMgr/Tnb.ProductionMgr.csproj
@@ -12,6 +12,7 @@
+
diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/ModuleConsts.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/ModuleConsts.cs
index 9ebfe36f..f3c226da 100644
--- a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/ModuleConsts.cs
+++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/ModuleConsts.cs
@@ -48,7 +48,7 @@ public class ModuleConsts
/// 模块标识-PDA空载具入库
///
public const string MODULE_WMSEMPTYINSTKPDA_ID = "26475795363877";
-
+
///
/// 模块标识-PDA载具更换
///
@@ -144,5 +144,13 @@ public class ModuleConsts
/// 模块标识-空载具入库
///
public const string MODULE_WMSEMPTYINSTOCK_ID = "26120915344165";
+ ///
+ /// 模块标识-预任务申请
+ ///
+ public const string MODULE_WMSPRETASK_ID = "26126898582309";
+ ///
+ /// 模块标识-任务执行
+ ///
+ public const string MODULE_WMSDISTASK_ID = "26128621455141";
}
\ No newline at end of file
diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/Constraints/ITaskManagerDel.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/Constraints/ITaskManagerDel.cs
new file mode 100644
index 00000000..24ca34f1
--- /dev/null
+++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/Constraints/ITaskManagerDel.cs
@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Tnb.WarehouseMgr.Entities.Entity
+{
+ public interface ITaskManagerDel
+ {
+ string startlocation_id { get; set; }
+ string endlocation_id { get; set; }
+ string carry_id { get; set; }
+ }
+}
diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarryunbindCode.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarryunbindCode.cs
index dcc4ee07..09119e5e 100644
--- a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarryunbindCode.cs
+++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarryunbindCode.cs
@@ -49,11 +49,6 @@ public partial class WmsCarryunbindCode : BaseEntity
///
public decimal? codeqty { get; set; }
- ///
- /// 行号
- ///
- public int? no { get; set; }
-
///
/// 子载具ID
///
diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsDistaskH.part.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsDistaskH.part.cs
index cf9870e0..e380d56d 100644
--- a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsDistaskH.part.cs
+++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsDistaskH.part.cs
@@ -1,13 +1,14 @@
using JNPF.Common.Contracts;
using JNPF.Common.Security;
using SqlSugar;
+using Tnb.WarehouseMgr.Entities.Entity;
namespace Tnb.WarehouseMgr.Entities;
///
/// 任务执行主表
///
-public partial class WmsDistaskH
+public partial class WmsDistaskH : ITaskManagerDel
{
///
/// 载具状态
diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsPretaskH.part.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsPretaskH.part.cs
index 5136949b..aa14821e 100644
--- a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsPretaskH.part.cs
+++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsPretaskH.part.cs
@@ -1,13 +1,14 @@
using JNPF.Common.Contracts;
using JNPF.Common.Security;
using SqlSugar;
+using Tnb.WarehouseMgr.Entities.Entity;
namespace Tnb.WarehouseMgr.Entities;
///
/// 预任务申请主表
///
-public partial class WmsPretaskH
+public partial class WmsPretaskH : ITaskManagerDel
{
///
/// 单次搬运数量
diff --git a/WarehouseMgr/Tnb.WarehouseMgr/BaseWareHouseService.cs b/WarehouseMgr/Tnb.WarehouseMgr/BaseWareHouseService.cs
index bb3d2c6f..aad43cdd 100644
--- a/WarehouseMgr/Tnb.WarehouseMgr/BaseWareHouseService.cs
+++ b/WarehouseMgr/Tnb.WarehouseMgr/BaseWareHouseService.cs
@@ -15,7 +15,9 @@ using JNPF.DynamicApiController;
using JNPF.Systems.Interfaces.System;
using JNPF.VisualDev;
using Microsoft.AspNetCore.Mvc;
+using Newtonsoft.Json.Linq;
using SqlSugar;
+using Tnb.BasicData.Entities;
using Tnb.WarehouseMgr.Entities;
using Tnb.WarehouseMgr.Entities.Attributes;
using Tnb.WarehouseMgr.Entities.Consts;
@@ -47,8 +49,28 @@ namespace Tnb.WarehouseMgr
}
}
}
+ ///
+ /// 判断最终目标库位是否可以放置当前载具
+ ///
+ /// 当前载具
+ /// 目标库位
+ ///
+ ///
+ [NonAction]
+ protected Task IsCarryAndLocationMatchByCarryStd(WmsCarryH carry, BasLocation locDest)
+ {
+ bool isMatch = false;
+ if (carry == null) throw new ArgumentNullException(nameof(carry));
+ if (locDest == null) throw new ArgumentNullException(nameof(locDest));
+ if (!carry.carrystd_id.IsNullOrEmpty() && !locDest.carrystd_id.IsNullOrEmpty())
+ {
+ var jsonArr = JArray.Parse(locDest.carrystd_id);
+ var locCarryStdArr = jsonArr.Select(x => x.ToObject()).ToArray();
+ isMatch = locCarryStdArr.Contains(carry.carrystd_id);
+ }
+ return Task.FromResult(isMatch);
+ }
-
[NonAction]
protected async Task DoUpdate(WareHouseUpInput input)
{
diff --git a/WarehouseMgr/Tnb.WarehouseMgr/TaskManagerDelBase.cs b/WarehouseMgr/Tnb.WarehouseMgr/TaskManagerDelBase.cs
new file mode 100644
index 00000000..73ab5f78
--- /dev/null
+++ b/WarehouseMgr/Tnb.WarehouseMgr/TaskManagerDelBase.cs
@@ -0,0 +1,56 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using JNPF.Common.Contracts;
+using SqlSugar;
+using Tnb.BasicData.Entities;
+using Tnb.WarehouseMgr.Entities;
+using Tnb.WarehouseMgr.Entities.Entity;
+
+namespace Tnb.WarehouseMgr
+{
+ public class TaskManagerDelBase : BaseWareHouseService where T : BaseEntity, ITaskManagerDel, new()
+ {
+ private readonly ISqlSugarClient _db;
+
+ public TaskManagerDelBase(ISqlSugarClient db)
+ {
+ _db = db;
+ OverideFuncs.DeleteAsync = UnLockLocationAndCarry;
+ }
+ private async Task UnLockLocationAndCarry(string id)
+ {
+ try
+ {
+ await _db.Ado.BeginTranAsync();
+
+ var preTask = await _db.Queryable().SingleAsync(it => it.id == id);
+ if (preTask != null)
+ {
+ var locIds = new[] { preTask.startlocation_id, preTask.endlocation_id };
+ var locs = await _db.Queryable().Where(it => locIds.Contains(it.id)).ToListAsync();
+ if (locs?.Count > 0)
+ {
+ locs.ForEach(it => { it.is_lock = 0; });
+ await _db.Updateable(locs).UpdateColumns(it => it.is_lock).ExecuteCommandAsync();
+ }
+ var carry = await _db.Queryable().SingleAsync(it => it.id == preTask.carry_id);
+ if (carry != null)
+ {
+ carry.is_lock = 0;
+ await _db.Updateable(carry).UpdateColumns(it => it.is_lock).ExecuteCommandAsync();
+ }
+ await _db.Deleteable(preTask).ExecuteCommandAsync();
+ }
+ await _db.Ado.CommitTranAsync();
+ }
+ catch (Exception)
+ {
+ await _db.Ado.RollbackTranAsync();
+ throw;
+ }
+ }
+ }
+}
diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs
index 0af932f0..c2114d31 100644
--- a/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs
+++ b/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs
@@ -488,6 +488,9 @@ namespace Tnb.WarehouseMgr
}
}
+
+
+
///
/// 生成预任务
///
diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryBindService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryBindService.cs
index 3cb9e96c..fb5460ab 100644
--- a/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryBindService.cs
+++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryBindService.cs
@@ -94,7 +94,7 @@ namespace Tnb.WarehouseMgr
{
WmsCarrybindCode wmsCarrybindCode = new();
wmsCarrybindCode.id = SnowflakeIdHelper.NextId();
- wmsCarrybindCode.org_id = subCarry?.org_id!;
+ wmsCarrybindCode.org_id = (subCarry != null && subCarry.org_id != null) ? subCarry.org_id : _userManager.User.OrganizeId;
wmsCarrybindCode.carrybind_id = input.data["ReturnIdentity"]?.ToString()!;
wmsCarrybindCode.material_id = items[i].material_id;
wmsCarrybindCode.material_code = items[i].material_code;
diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryMoveInStockService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryMoveInStockService.cs
index 93da5a11..eb71689f 100644
--- a/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryMoveInStockService.cs
+++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryMoveInStockService.cs
@@ -66,8 +66,6 @@ namespace Tnb.WarehouseMgr
{
await _db.Ado.BeginTranAsync();
- VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleConsts.MODULE_CARRYMOVEINSTOCK_ID, true);
- await _runService.Create(templateEntity, input);
//入库取终点 //出库起点
var inStockStrategyInput = new InStockStrategyQuery { warehouse_id = input.data[nameof(InStockStrategyQuery.warehouse_id)].ToString()!, Size = 1 };
var endLocations = await _wareHouseService.InStockStrategy(inStockStrategyInput);
@@ -79,9 +77,18 @@ namespace Tnb.WarehouseMgr
}
if (endLocations?.Count > 0)
{
+ var carry = await _db.Queryable().SingleAsync(it => it.id == input.data[nameof(WmsCarryD.carry_id)].ToString());
+ var loc = await _db.Queryable().SingleAsync(it => it.id == endLocations[0].id);
+ var isMatch = await IsCarryAndLocationMatchByCarryStd(carry, loc);
+ if (!isMatch) throw new AppFriendlyException("库位与载具规格不匹配", 500);
ePoint = await _db.Queryable().FirstAsync(it => it.location_id == endLocations[0].id);
}
+
+ VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleConsts.MODULE_CARRYMOVEINSTOCK_ID, true);
+ await _runService.Create(templateEntity, input);
+
+
if (sPoint != null && ePoint != null)
{
var points = await _wareHouseService.PathAlgorithms(sPoint.id, ePoint.id);
diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryMoveOutStockService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryMoveOutStockService.cs
index c4e28b0b..e763bf4d 100644
--- a/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryMoveOutStockService.cs
+++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryMoveOutStockService.cs
@@ -63,11 +63,17 @@ namespace Tnb.WarehouseMgr
{
await _db.Ado.BeginTranAsync();
+ //判断目标库位是否自动签收
+ var loc = await _db.Queryable().SingleAsync(it => it.id == input.data[nameof(WmsPointH.location_id)].ToString());
+ var carry = await _db.Queryable().FirstAsync(it => it.id == input.data[nameof(WmsMoveOutstock.carry_id)].ToString());
+ var isMatch = await IsCarryAndLocationMatchByCarryStd(carry, loc);
+ if (!isMatch) throw new AppFriendlyException("该载具无法放置到目标库位", 500);
+
+
VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleConsts.MODULE_WMSCARRYMOOUTSTK_ID, true);
await _runService.Create(templateEntity, input);
//入库取终点
//var OutStockStrategyInput = new OutStockStrategyQuery { carry_id = input.data[nameof(OutStockStrategyQuery.carry_id)].ToString(), Size = 1 };
- var carry = await _db.Queryable().FirstAsync(it => it.id == input.data[nameof(WmsMoveOutstock.carry_id)].ToString());
WmsPointH? sPoint = null;
WmsPointH? ePoint = null;
if (input.data.ContainsKey(nameof(WmsPointH.location_id)))
@@ -113,8 +119,6 @@ namespace Tnb.WarehouseMgr
preTask.create_time = DateTime.Now;
return preTask;
}).ToList();
- //判断目标库位是否自动签收
- var loc = await _db.Queryable().SingleAsync(it => it.id == input.data[nameof(WmsPointH.location_id)].ToString());
if (loc.is_sign ==0 ) {
preTasks[^1].is_sign = 0; // 修改最后一个元素的是否签收值
}
diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryQueryService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryQueryService.cs
index fefe2f4a..c76028c8 100644
--- a/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryQueryService.cs
+++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryQueryService.cs
@@ -72,7 +72,7 @@ namespace Tnb.WarehouseMgr
data.wmsCarryCodes = carryCodes.Adapt>();
}
- catch (Exception ex)
+ catch (Exception)
{
await _db.Ado.RollbackTranAsync();
//return await ToApiResult(JNPF.Common.Enums.HttpStatusCode.InternalServerError, ex.Message);
diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryService.cs
index 86984f8b..2e8b719b 100644
--- a/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryService.cs
+++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryService.cs
@@ -172,18 +172,19 @@ namespace Tnb.WarehouseMgr
carryObj.collocation_scheme_code = null;
carryObj.source_id = null;
carryObj.source_code = null;
- row = await _db.Updateable(carryObj).ExecuteCommandAsync();
+ row = await _db.CopyNew().Updateable(carryObj).ExecuteCommandAsync();
//删除对应明细表
//删除载具明细
- await _db.Deleteable().Where(it => it.carry_id == carryObj.id).ExecuteCommandHasChangeAsync();
+ await _db.CopyNew().Deleteable().Where(it => it.carry_id == carryObj.id).ExecuteCommandHasChangeAsync();
//删除载具分拣物料明细
- await _db.Deleteable().Where(it => it.carry_id == carryObj.id).ExecuteCommandHasChangeAsync();
+ await _db.CopyNew().Deleteable().Where(it => it.carry_id == carryObj.id).ExecuteCommandHasChangeAsync();
//删除载具条码
- await _db.Deleteable().Where(it => it.carry_id == carryObj.id).ExecuteCommandHasChangeAsync();
+ await _db.CopyNew().Deleteable().Where(it => it.carry_id == carryObj.id).ExecuteCommandHasChangeAsync();
}
- catch (Exception)
+ catch (Exception ex)
{
-
+ Log.Error("更新空载具出错",ex);
+ throw;
}
return row;
}
diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsDistaskService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsDistaskService.cs
new file mode 100644
index 00000000..28bc827f
--- /dev/null
+++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsDistaskService.cs
@@ -0,0 +1,52 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using JNPF.VisualDev;
+using SqlSugar;
+using Tnb.WarehouseMgr.Entities;
+using Tnb.WarehouseMgr.Entities.Consts;
+using Tnb.WarehouseMgr.Entities.Entity;
+
+namespace Tnb.WarehouseMgr
+{
+ [OverideVisualDev(ModuleConsts.MODULE_WMSDISTASK_ID)]
+ public class WmsDistaskService : BaseWareHouseService
+ {
+ private readonly ISqlSugarClient _db;
+
+ public WmsDistaskService(ISqlSugarRepository repository)
+ {
+ _db = repository.AsSugarClient();
+ OverideFuncs.DeleteAsync = Delete;
+ }
+
+ private async Task Delete(string id)
+ {
+ try
+ {
+ await _db.Ado.BeginTranAsync();
+
+ var disTask = await _db.Queryable().SingleAsync(it => it.id == id);
+ if (disTask != null)
+ {
+ var preTask = await _db.Queryable().SingleAsync(it => it.id == disTask.pretask_id);
+ if (preTask != null)
+ {
+ preTask.status = WmsWareHouseConst.PRETASK_BILL_STATUS_DXF_ID;
+ await _db.Updateable(preTask).UpdateColumns(it => it.status).ExecuteCommandAsync();
+ }
+ await _db.Deleteable(disTask).ExecuteCommandAsync();
+ }
+
+ await _db.Ado.CommitTranAsync();
+ }
+ catch (Exception)
+ {
+ await _db.Ado.RollbackTranAsync();
+ throw;
+ }
+ }
+ }
+}
diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsEmptyInstockService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsEmptyInstockService.cs
index 1af501e8..cb64b15e 100644
--- a/WarehouseMgr/Tnb.WarehouseMgr/WmsEmptyInstockService.cs
+++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsEmptyInstockService.cs
@@ -68,8 +68,6 @@ namespace Tnb.WarehouseMgr
{
await _db.Ado.BeginTranAsync();
- VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleConsts.MODULE_WMSEMPTYINSTOCK_ID, true);
- await _runService.Create(templateEntity, input);
//入库取终点
var inStockStrategyInput = new InStockStrategyQuery { warehouse_id = input.data[nameof(InStockStrategyQuery.warehouse_id)].ToString()!, Size = 1 };
var endLocations = await _wareHouseService.InStockStrategy(inStockStrategyInput);
@@ -81,8 +79,16 @@ namespace Tnb.WarehouseMgr
}
if (endLocations?.Count > 0)
{
+ var carry = await _db.Queryable().SingleAsync(it => it.id == input.data[nameof(WmsCarryD.carry_id)].ToString());
+ var loc = await _db.Queryable().SingleAsync(it => it.id == endLocations[0].id);
+ var isMatch = await IsCarryAndLocationMatchByCarryStd(carry, loc);
+ if (!isMatch) throw new AppFriendlyException("库位与载具规格不匹配", 500);
ePoint = await _db.Queryable().FirstAsync(it => it.location_id == endLocations[0].id);
}
+
+ //在线开发
+ VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleConsts.MODULE_WMSEMPTYINSTOCK_ID, true);
+ await _runService.Create(templateEntity, input);
if (sPoint != null && ePoint != null)
{
@@ -180,19 +186,19 @@ namespace Tnb.WarehouseMgr
try
{
var carry = await _db.Queryable().SingleAsync(it => it.carry_code == input.carry_code);
- var location = await _db.Queryable().SingleAsync(it => it.location_code == input.location_code);
+ var loc = await _db.Queryable().SingleAsync(it => it.location_code == input.location_code);
var emptyInstock = await _db.Queryable().FirstAsync(it => it.carry_code == input.carry_code && it.status == WmsWareHouseConst.BILLSTATUS_ADD_ID);
if (emptyInstock != null)
{
- return ToApiResult(HttpStatusCode.InternalServerError, $"空载具{emptyInstock.carry_code},预任务已生成");
+ return isSuccessful;
}
- if (carry != null && location != null)
+ if (carry != null && loc != null)
{
var cols = new List();
var dic = new Dictionary();
dic[nameof(WmsEmptyInstock.id)] = SnowflakeIdHelper.NextId();
dic[nameof(WmsEmptyInstock.org_id)] = input.org_id ?? _userManager.User.OrganizeId;
- dic[nameof(WmsEmptyInstock.location_id)] = location.id;
+ dic[nameof(WmsEmptyInstock.location_id)] = loc.id;
dic[nameof(WmsEmptyInstock.bill_code)] = await _billRullService.GetBillNumber(WmsWareHouseConst.WMS_EMPTYINSTK_ENCODE);
dic[nameof(WmsEmptyInstock.status)] = WmsWareHouseConst.BILLSTATUS_ADD_ID;
dic[nameof(WmsEmptyInstock.carry_id)] = carry.id;
diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsEmptyOutstockService .cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsEmptyOutstockService .cs
index 63f2391c..2bf0f988 100644
--- a/WarehouseMgr/Tnb.WarehouseMgr/WmsEmptyOutstockService .cs
+++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsEmptyOutstockService .cs
@@ -58,20 +58,19 @@ namespace Tnb.WarehouseMgr
_wareHouseService = wareHouseService;
_userManager = userManager;
_billRullService = billRullService;
- OverideFuncs.CreateAsync = PDAWmsEmptyOut;
+ OverideFuncs.CreateAsync = WmsEmptyOut;
}
- private async Task PDAWmsEmptyOut(VisualDevModelDataCrInput input)
+ private async Task WmsEmptyOut(VisualDevModelDataCrInput input)
{
try
{
await _db.Ado.BeginTranAsync();
- VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleConsts.MODULE_WMSEMPTYOUTSTK_ID, true);
- await _runService.Create(templateEntity, input);
+
/*//入库取终点
var inStockStrategyInput = new InStockStrategyQuery { warehouse_id = input.data[nameof(InStockStrategyQuery.warehouse_id)].ToString(), Size = 1 };
@@ -85,6 +84,17 @@ namespace Tnb.WarehouseMgr
&& a.carry_status == ((int)EnumCarryStatus.空闲).ToString() && a.is_lock == 0 && b.is_lock == 0 && b.is_type == ((int)EnumLocationType.存储库位).ToString())
.ToListAsync();
+ // 判断最终目标库位是否可以放置当前载具
+ if (carrys?.Count > 0)
+ {
+ var curCarry = carrys[^carrys.Count];
+ var isMatch = await IsCarryAndLocationMatchByCarryStd(curCarry, loc);
+ if (!isMatch) throw new AppFriendlyException("该载具无法放置到目标库位", 500);
+ }
+
+ VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleConsts.MODULE_WMSEMPTYOUTSTK_ID, true);
+ await _runService.Create(templateEntity, input);
+
WmsPointH? sPoint = null;
WmsPointH? ePoint = null;
if (input.data.ContainsKey(nameof(WmsPointH.location_id)))
@@ -92,90 +102,98 @@ namespace Tnb.WarehouseMgr
ePoint = await _db.Queryable().FirstAsync(it => it.location_id == input.data[nameof(WmsPointH.location_id)].ToString() && it.is_lock == 0);
}
//根据每个载具的起始库位做路径运算
- for (int i = 0; i < setQty.qty; i++)
+ if (carrys?.Count > 0)
{
- if (carrys?.Count > 0)
+ int min = (carrys.Count > setQty.qty) ? setQty.qty : carrys.Count;
+ for (int i = 0; i < min; i++)
{
sPoint = await _db.Queryable().FirstAsync(it => it.location_id == carrys[i].location_id);
- }
- var isOk = false;
- if (sPoint != null && ePoint != null)
- {
- var points = await _wareHouseService.PathAlgorithms(sPoint.id, ePoint.id);
- if (points.Count <= 2) throw new AppFriendlyException("该路径不存在", 500);
- //根据获取的路径点生成预任务,生成顺序必须预路径算法返回的起终点的顺序一致(预任务顺序)
+
+ var isOk = false;
+ if (sPoint != null && ePoint != null)
+ {
+ var points = await _wareHouseService.PathAlgorithms(sPoint.id, ePoint.id);
+ if (points.Count <= 2) throw new AppFriendlyException("该路径不存在", 500);
+ //根据获取的路径点生成预任务,生成顺序必须预路径算法返回的起终点的顺序一致(预任务顺序)
+ else
+ {
+ 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()
+ {
+ org_id = _userManager.User.OrganizeId,
+ startlocation_id = sPoint?.location_id!,
+ startlocation_code = sPoint?.location_code!,
+ endlocation_id = ePoint?.location_id!,
+ endlocation_code = ePoint?.location_code!,
+ start_floor = sPoint?.floor.ToString(),
+ end_floor = ePoint?.floor.ToString(),
+ bill_code = _billRullService.GetBillNumber(WmsWareHouseConst.WMS_PRETASK_H_ENCODE).GetAwaiter().GetResult(),
+ status = WmsWareHouseConst.PRETASK_BILL_STATUS_DXF_ID,
+ biz_type = WmsWareHouseConst.BIZTYPE_WMSEPTYOUTSTK_ID,
+ task_type = WmsWareHouseConst.WMS_PRETASK_OUTSTOCK_TYPE_ID,
+ carry_id = carrys![i].id,
+ carry_code = carrys![i].carry_code,
+ area_id = sPoint?.area_id!,
+ area_code = it.Key,
+ require_id = input.data["ReturnIdentity"].ToString(),
+ require_code = input.data[nameof(preTask.bill_code)]?.ToString()!,
+ create_id = _userManager.UserId,
+ create_time = DateTime.Now
+ };
+
+ return preTask;
+ }).ToList();
+ //更新页面
+ //赋值签收状态
+ if (loc.is_sign == 0)
+ {
+ preTasks[^1].is_sign = 0; // 修改最后一个元素的是否签收值
+ }
+ isOk = await _wareHouseService.GenPreTask(preTasks, null!);
+ }
+ if (isOk)
+ {
+ GenPreTaskUpInput preTaskUpInput = new()
+ {
+ RquireId = input.data["ReturnIdentity"].ToString()!,
+ CarryId = carrys![i].id,
+ CarryStartLocationId = points!.FirstOrDefault()!.location_id!,
+ CarryStartLocationCode = points!.FirstOrDefault()!.location_code!,
+ LocationIds = points!.Select(x => x.location_id).ToList()!
+ };
+
+ //更新明细表
+ WmsEmptyOutstockD wmsEmptyOutstockD = new()
+ {
+ id = SnowflakeIdHelper.NextId(),
+ bill_id = preTaskUpInput.RquireId,
+ biz_type = WmsWareHouseConst.BIZTYPE_WMSEPTYOUTSTK_ID,
+ location_id = ePoint.location_id!,
+ status = WmsWareHouseConst.BILLSTATUS_ON_ID,
+ carry_id = carrys[i].id,
+ carry_code = carrys[i].carry_code,
+ create_id = _userManager.UserId,
+ create_time = DateTime.Now
+ };
+ await _db.Insertable(wmsEmptyOutstockD)
+ .ExecuteCommandAsync();
+
+ //根据空载具出库Id,回更单据状态
+ await _db.Updateable().SetColumns(it => new WmsEmptyOutstockH { status = WmsWareHouseConst.BILLSTATUS_ON_ID }).Where(it => it.id == preTaskUpInput.RquireId).ExecuteCommandAsync();
+ await _wareHouseService.GenInStockTaskHandleAfter(preTaskUpInput,
+ it => new WmsCarryH { is_lock = 1 },
+ it => new BasLocation { is_lock = 1 });
+ }
+ }
else
{
- 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 = WmsWareHouseConst.BIZTYPE_WMSEPTYOUTSTK_ID;
- preTask.task_type = WmsWareHouseConst.WMS_PRETASK_OUTSTOCK_TYPE_ID;
- preTask.carry_id = carrys![i].id;
- preTask.carry_code = carrys![i].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)
- {
- preTasks[^1].is_sign = 0; // 修改最后一个元素的是否签收值
- }
- isOk = await _wareHouseService.GenPreTask(preTasks, null!);
- }
- if (isOk)
- {
- var preTaskUpInput = new GenPreTaskUpInput();
- preTaskUpInput.RquireId = input.data["ReturnIdentity"].ToString()!;
- preTaskUpInput.CarryId = carrys![i].id;
- preTaskUpInput.CarryStartLocationId = points!.FirstOrDefault()!.location_id!;
- preTaskUpInput.CarryStartLocationCode = points!.FirstOrDefault()!.location_code!;
- preTaskUpInput.LocationIds = points!.Select(x => x.location_id).ToList()!;
-
- //更新明细表
- WmsEmptyOutstockD wmsEmptyOutstockD = new();
- wmsEmptyOutstockD.id = SnowflakeIdHelper.NextId();
- wmsEmptyOutstockD.bill_id = preTaskUpInput.RquireId;
- wmsEmptyOutstockD.biz_type = WmsWareHouseConst.BIZTYPE_WMSEPTYOUTSTK_ID;
- wmsEmptyOutstockD.location_id = ePoint.location_id!;
- wmsEmptyOutstockD.status = WmsWareHouseConst.BILLSTATUS_ON_ID;
- wmsEmptyOutstockD.carry_id = carrys[i].id;
- wmsEmptyOutstockD.carry_code = carrys[i].carry_code;
- wmsEmptyOutstockD.create_id = _userManager.UserId;
- wmsEmptyOutstockD.create_time = DateTime.Now;
- await _db.Insertable(wmsEmptyOutstockD)
- .ExecuteCommandAsync();
-
- //根据空载具出库Id,回更单据状态
- await _db.Updateable().SetColumns(it => new WmsEmptyOutstockH { status = WmsWareHouseConst.BILLSTATUS_ON_ID }).Where(it => it.id == preTaskUpInput.RquireId).ExecuteCommandAsync();
- await _wareHouseService.GenInStockTaskHandleAfter(preTaskUpInput,
- it => new WmsCarryH { is_lock = 1 },
- it => new BasLocation { is_lock = 1 });
+ throw new AppFriendlyException("无可出库的空载具或目标库位不存在或者目标库位被锁", 500);
}
}
- else
- {
- throw new AppFriendlyException("无可出库的空载具或目标库位不存在或者目标库位被锁", 500);
- }
-
}
await _db.Ado.CommitTranAsync();
@@ -226,24 +244,26 @@ namespace Tnb.WarehouseMgr
if (input.IsNull()) throw new ArgumentNullException("input");
try
{
- var location = await _db.Queryable().SingleAsync(it => it.location_code == input.location_code);
- var dic = new Dictionary();
- dic[nameof(WmsEmptyOutstockH.id)] = SnowflakeIdHelper.NextId();
- dic[nameof(WmsEmptyOutstockH.org_id)] = input.org_id;
- dic[nameof(WmsEmptyOutstockH.location_id)] = location.id;
- dic[nameof(WmsEmptyOutstockH.carrystd_id)] = input.carrystd_id;
- dic[nameof(WmsEmptyOutstockH.bill_code)] = _billRullService.GetBillNumber(WmsWareHouseConst.WMS_EMPTYOUTSTK_ENCODE).GetAwaiter().GetResult();
- dic[nameof(WmsEmptyOutstockH.status)] = WmsWareHouseConst.BILLSTATUS_ADD_ID;
- dic[nameof(WmsEmptyOutstockH.qty)] = input.qty;
- dic[nameof(WmsEmptyOutstockH.biz_type)] = WmsWareHouseConst.BIZTYPE_WMSEPTYOUTSTK_ID;
- dic[nameof(WmsEmptyOutstockH.create_id)] = input.create_id;
- dic[nameof(WmsEmptyOutstockH.create_time)] = DateTime.Now;
+ var location = await _db.Queryable().SingleAsync(it => it.location_code == input.location_code && it.is_type != EnumLocationType.存储库位.ToString()) ?? throw new AppFriendlyException("无此库位或为存储库位", 500);
+ Dictionary dic = new()
+ {
+ [nameof(WmsEmptyOutstockH.id)] = SnowflakeIdHelper.NextId(),
+ [nameof(WmsEmptyOutstockH.org_id)] = input.org_id,
+ [nameof(WmsEmptyOutstockH.location_id)] = location.id,
+ [nameof(WmsEmptyOutstockH.carrystd_id)] = input.carrystd_id,
+ [nameof(WmsEmptyOutstockH.bill_code)] = _billRullService.GetBillNumber(WmsWareHouseConst.WMS_EMPTYOUTSTK_ENCODE).GetAwaiter().GetResult(),
+ [nameof(WmsEmptyOutstockH.status)] = WmsWareHouseConst.BILLSTATUS_ADD_ID,
+ [nameof(WmsEmptyOutstockH.qty)] = input.qty,
+ [nameof(WmsEmptyOutstockH.biz_type)] = WmsWareHouseConst.BIZTYPE_WMSEPTYOUTSTK_ID,
+ [nameof(WmsEmptyOutstockH.create_id)] = input.create_id,
+ [nameof(WmsEmptyOutstockH.create_time)] = DateTime.Now
+ };
VisualDevModelDataCrInput visualDevModelDataCrInput = new VisualDevModelDataCrInput
{
data = dic,
};
- await PDAWmsEmptyOut(visualDevModelDataCrInput);
+ await WmsEmptyOut(visualDevModelDataCrInput);
}
catch (Exception ex)
{
diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsInStockService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsInStockService.cs
index 9a5da81b..71cfd65c 100644
--- a/WarehouseMgr/Tnb.WarehouseMgr/WmsInStockService.cs
+++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsInStockService.cs
@@ -221,12 +221,12 @@ namespace Tnb.WarehouseMgr
await _db.Updateable(instockDetails).ExecuteCommandAsync();
var instock = await _db.Queryable().SingleAsync(it => it.id == input.requireId);
if (instock.IsNull()) ArgumentNullException.ThrowIfNull(nameof(instock));
- if (instock?.sync_status != WmsWareHouseConst.SYNC_STATUS_NONEEDSYNC)
+ if (instock.sync_status != WmsWareHouseConst.SYNC_STATUS_NONEEDSYNC)
{
//如果是自动单据,需要回更上层系统
- Dictionary pars = new() { { nameof(WmsInstockH.source_id), instock!.source_id } };
+ Dictionary pars = new() { { nameof(WmsInstockH.source_id), instock?.source_id ?? string.Empty } };
var callBackRes = await _prdInstockService.SyncInstock(pars);
- instock.sync_status = callBackRes == true ? WmsWareHouseConst.SYNC_STATUS__SYNCCOMPLETE : WmsWareHouseConst.SYNC_STATUS__SYNCFAILED;
+ instock!.sync_status = callBackRes == true ? WmsWareHouseConst.SYNC_STATUS__SYNCCOMPLETE : WmsWareHouseConst.SYNC_STATUS__SYNCFAILED;
await _db.Updateable(instock).UpdateColumns(it => it.sync_status).ExecuteCommandAsync();
}
var allInstockDetails = await _db.Queryable().Where(it => it.bill_id == input.requireId).ToListAsync();
@@ -270,13 +270,24 @@ namespace Tnb.WarehouseMgr
//入库申请条码明细表
List instockcodes = input.instockcodes.Adapt>();
- var loc = await _db.Queryable().SingleAsync(it => it.location_code == input.instock.location_code);
+ //入库取终点 //出库起点
+ var inStockStrategyInput = new InStockStrategyQuery { warehouse_id = instock?.warehouse_id!, Size = 1 };
+ var endLocations = await _wareHouseService.InStockStrategy(inStockStrategyInput);
+ WmsPointH sPoint = await _db.Queryable().FirstAsync(it => it.location_code == input.instock.location_code);
+ WmsPointH ePoint = await _db.Queryable().FirstAsync(it => it.location_id == endLocations[0].id);
+
var carry = await _db.Queryable().SingleAsync(it => it.carry_code == input.instock.carry_code);
- //如果数据不全,
+ var loc = await _db.Queryable().FirstAsync(it => it.id == endLocations[0].id);
+ var isMatch = await IsCarryAndLocationMatchByCarryStd(carry, loc);
+ if (!isMatch) throw new AppFriendlyException("库位与载具规格不匹配", 500);
+
+ loc = await _db.Queryable().FirstAsync(it => it.location_code == input.instock.location_code && it.is_type != EnumLocationType.存储库位.ToString());
+
+ //如果数据不全或有误,
if (carry.IsNull() || loc.IsNull() || instockds?.Count < 1 || instockcodes?.Count < 1)
{
- //报错, 提示数据不全。
- throw new AppFriendlyException("数据不全!", 500);
+ //报错, 提示数据不全或有误。
+ throw new AppFriendlyException("数据不全或有误!", 500);
}
// 生成入库申请数据,添加其他数据 主表
instock.id = SnowflakeIdHelper.NextId();
@@ -327,13 +338,7 @@ namespace Tnb.WarehouseMgr
await _db.Insertable(instockCOdes).CallEntityMethod(it => it.Create(orgId)).ExecuteCommandAsync();
//生成预任务申请
- //入库取终点 //出库起点
- var inStockStrategyInput = new InStockStrategyQuery { warehouse_id = instock?.warehouse_id!, Size = 1 };
- var endLocations = await _wareHouseService.InStockStrategy(inStockStrategyInput);
- WmsPointH sPoint = await _db.Queryable().FirstAsync(it => it.location_id == instock.location_id);
- WmsPointH ePoint = await _db.Queryable().FirstAsync(it => it.location_id == endLocations[0].id);
-
-
+
if (sPoint != null && ePoint != null)
{
var points = await _wareHouseService.PathAlgorithms(sPoint.id, ePoint.id);
@@ -346,26 +351,28 @@ namespace Tnb.WarehouseMgr
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 = instock.biz_type;
- preTask.task_type = WmsWareHouseConst.WMS_PRETASK_INSTOCK_TYPE_ID;
- preTask.carry_id = instock.carry_id!;
- preTask.carry_code = instock.carry_code!;
- preTask.area_id = sPoint?.area_id!;
- preTask.area_code = it.Key;
- preTask.require_id = instock.id;
- preTask.require_code = instock.bill_code;
- preTask.create_id = _userManager.UserId;
- preTask.create_time = DateTime.Now;
+ WmsPretaskH preTask = new()
+ {
+ org_id = _userManager.User.OrganizeId,
+ startlocation_id = sPoint?.location_id ?? string.Empty,
+ startlocation_code = sPoint?.location_code ?? string.Empty,
+ endlocation_id = ePoint?.location_id ?? string.Empty,
+ endlocation_code = ePoint?.location_code ?? string.Empty,
+ start_floor = sPoint?.floor.ToString(),
+ end_floor = ePoint?.floor.ToString(),
+ bill_code = _billRullService.GetBillNumber(WmsWareHouseConst.WMS_PRETASK_H_ENCODE).GetAwaiter().GetResult(),
+ status = WmsWareHouseConst.PRETASK_BILL_STATUS_DXF_ID,
+ biz_type = instock?.biz_type ?? string.Empty,
+ task_type = WmsWareHouseConst.WMS_PRETASK_INSTOCK_TYPE_ID,
+ carry_id = instock?.carry_id ?? string.Empty,
+ carry_code = instock?.carry_code ?? string.Empty,
+ area_id = sPoint?.area_id ?? string.Empty,
+ area_code = it.Key,
+ require_id = instock?.id ?? string.Empty,
+ require_code = instock?.bill_code ?? string.Empty,
+ create_id = _userManager.UserId,
+ create_time = DateTime.Now
+ };
return preTask;
}).ToList();
//生成预任务条码信息
@@ -395,12 +402,14 @@ namespace Tnb.WarehouseMgr
if (isOk)
{
- var preTaskUpInput = new GenPreTaskUpInput();
- preTaskUpInput.RquireId = instock?.id;
- preTaskUpInput.CarryId = instock?.carry_id!;
- preTaskUpInput.CarryStartLocationId = points.FirstOrDefault()?.location_id;
- preTaskUpInput.CarryStartLocationCode = points.FirstOrDefault()?.location_code;
- preTaskUpInput.LocationIds = (points?.Select(x => x.location_id)?.ToList() ?? Enumerable.Empty().ToList()) as List;
+ GenPreTaskUpInput preTaskUpInput = new()
+ {
+ RquireId = instock?.id,
+ CarryId = instock?.carry_id!,
+ CarryStartLocationId = points.FirstOrDefault()?.location_id,
+ CarryStartLocationCode = points.FirstOrDefault()?.location_code,
+ LocationIds = (points?.Select(x => x.location_id)?.ToList() ?? Enumerable.Empty().ToList()) as List
+ };
//创建预任务操作记录
var operBillId = string.Empty;
diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsKittingInStkService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsKittingInStkService.cs
index 7ad379ee..0a37f8c1 100644
--- a/WarehouseMgr/Tnb.WarehouseMgr/WmsKittingInStkService.cs
+++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsKittingInStkService.cs
@@ -67,8 +67,6 @@ namespace Tnb.WarehouseMgr
{
await _db.Ado.BeginTranAsync();
- VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleConsts.MODULE_WMSKITTINGINSTK_ID, true);
- await _runService.Create(templateEntity, input);
//入库取终点 //出库起点
var inStockStrategyInput = new InStockStrategyQuery { warehouse_id = input.data[nameof(InStockStrategyQuery.warehouse_id)].ToString()!, Size = 1 };
var endLocations = await _wareHouseService.InStockStrategy(inStockStrategyInput);
@@ -80,9 +78,16 @@ namespace Tnb.WarehouseMgr
}
if (endLocations?.Count > 0)
{
+ var carry = await _db.Queryable().SingleAsync(it => it.id == input.data[nameof(WmsCarryD.carry_id)].ToString());
+ var loc = await _db.Queryable().SingleAsync(it => it.id == endLocations[0].id);
+ var isMatch = await IsCarryAndLocationMatchByCarryStd(carry, loc);
+ if (!isMatch) throw new AppFriendlyException("库位与载具规格不匹配", 500);
ePoint = await _db.Queryable().FirstAsync(it => it.location_id == endLocations[0].id);
}
+ VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleConsts.MODULE_WMSKITTINGINSTK_ID, true);
+ await _runService.Create(templateEntity, input);
+
if (sPoint != null && ePoint != null)
{
var points = await _wareHouseService.PathAlgorithms(sPoint.id, ePoint.id);
diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsOutBaleService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsOutBaleService.cs
index d38712ef..665a32ee 100644
--- a/WarehouseMgr/Tnb.WarehouseMgr/WmsOutBaleService.cs
+++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsOutBaleService.cs
@@ -66,11 +66,15 @@ namespace Tnb.WarehouseMgr
{
await _db.Ado.BeginTranAsync();
+ var carry = await _db.Queryable().FirstAsync(it => it.id == input.data[nameof(WmsOutbale.carry_id)].ToString());
+ var loc = await _db.Queryable().SingleAsync(it => it.id == input.data[nameof(WmsPointH.location_id)].ToString());
+ var isMatch = await IsCarryAndLocationMatchByCarryStd(carry, loc);
+ if (!isMatch) throw new AppFriendlyException("该载具无法放置到目标库位", 500);
+
VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleConsts.MODULE_WMSOUTBALE_ID, true);
await _runService.Create(templateEntity, input);
//入库取终点
//var OutStockStrategyInput = new OutStockStrategyQuery { carry_id = input.data[nameof(OutStockStrategyQuery.carry_id)].ToString(), Size = 1 };
- var carry = await _db.Queryable().FirstAsync(it => it.id == input.data[nameof(WmsOutbale.carry_id)].ToString());
WmsPointH? sPoint = null;
WmsPointH? ePoint = null;
if (input.data.ContainsKey(nameof(WmsPointH.location_id)))
@@ -117,7 +121,7 @@ namespace Tnb.WarehouseMgr
return preTask;
}).ToList();
//判断目标库位是否自动签收
- var loc = await _db.Queryable().SingleAsync(it => it.id == input.data[nameof(WmsPointH.location_id)].ToString());
+
if (loc.is_sign == 0)
{
preTasks[^1].is_sign = 0; // 修改最后一个元素的是否签收值
diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsOutStockService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsOutStockService.cs
index 357de608..1e6c5334 100644
--- a/WarehouseMgr/Tnb.WarehouseMgr/WmsOutStockService.cs
+++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsOutStockService.cs
@@ -78,13 +78,13 @@ namespace Tnb.WarehouseMgr
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().SingleAsync(it => it.id == input.data[nameof(WmsPointH.location_id)].ToString());
+
+
+
+
var carryIds = new List();
//tablefield120 出库物料明细
if (input.data.ContainsKey("tablefield120") && input.data["tablefield120"].IsNotEmptyOrNull())
@@ -150,7 +150,8 @@ namespace Tnb.WarehouseMgr
carryMats = carryMats.OrderBy(o => o.create_time).GroupBy(g => new { g.carry_id, g.material_id, g.code_batch })
.Select(x =>
{
- WmsCarryMat carryMat = new();
+ var arr = x.ToArray();
+ WmsCarryMat carryMat = arr[^arr.Length];
carryMat.need_qty = x.Sum(d => d.need_qty);
return carryMat;
})
@@ -178,9 +179,19 @@ namespace Tnb.WarehouseMgr
await _db.Updateable().SetColumns(it => new WmsCarryH { out_status = ((int)EnumOutStatus.全部出).ToString() }).Where(it => allOutIds.Contains(it.id)).ExecuteCommandAsync();
await _db.Updateable().SetColumns(it => new WmsCarryH { out_status = ((int)EnumOutStatus.分拣出).ToString() }).Where(it => sortingOutIds.Contains(it.id)).ExecuteCommandAsync();
}
+
+
+
var carrys = await _db.Queryable().Where(it => carryIds.Contains(it.id)).ToListAsync();
if (carrys?.Count > 0)
{
+ var curCarry = carrys[^carrys.Count];
+ var isMatch = await IsCarryAndLocationMatchByCarryStd(curCarry, loc);
+ if (!isMatch) throw new AppFriendlyException("该载具无法放置到目标库位", 500);
+
+ VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleConsts.MODULE_WMSOUTSTOCK_ID, true);
+ await _runService.Create(templateEntity, input);
+
List preTasks = new();
List locIds = new();
foreach (var carry in carrys)
@@ -274,6 +285,9 @@ namespace Tnb.WarehouseMgr
}
+
+
+
await _db.Ado.CommitTranAsync();
}
catch (Exception)
@@ -308,6 +322,7 @@ namespace Tnb.WarehouseMgr
//[NonUnify]
public async Task MESCreateOutstock(MESCreateOutstockInput input)
{
+ var isSuccessful = true;
try
{
await _db.Ado.BeginTranAsync();
@@ -316,12 +331,12 @@ namespace Tnb.WarehouseMgr
//出库申请明细表
List outstockDs = input.outstockDs.Adapt>();
- var location = await _db.Queryable().SingleAsync(it => it.location_code == input.outstock.location_code);
- //如果数据不全,
+ var location = await _db.Queryable().SingleAsync(it => it.location_code == input.outstock.location_code && it.is_type != EnumLocationType.存储库位.ToString());
+ //如果数据不全或有误,
if (location.IsNull() || outstockDs?.Count < 1)
{
- //报错, 提示数据不全。
- throw new AppFriendlyException("数据不全!", 500);
+ //报错, 提示数据不全或有误。
+ throw new AppFriendlyException("数据不全或有误!", 500);
}
// 生成出库申请数据,添加其他数据 主表
outstock.id = SnowflakeIdHelper.NextId();
@@ -333,7 +348,7 @@ namespace Tnb.WarehouseMgr
outstock.status = WmsWareHouseConst.BILLSTATUS_ADD_ID;// 新增
outstock.create_id = _userManager.UserId;
outstock.create_time = DateTime.Now;
- await _db.Insertable(outstock).ExecuteCommandAsync();
+
//明细表
foreach (var outstockD in outstockDs!)
{
@@ -344,7 +359,7 @@ namespace Tnb.WarehouseMgr
outstock.create_time = outstock.create_time;
outstock.create_id = outstock.create_id;
}
- await _db.Insertable(outstockDs).ExecuteCommandAsync();
+
//var loc = await _db.Queryable().SingleAsync(it => it.id == outstock.location_id.ToString());
var carryIds = new List();
//tablefield120 出库物料明细
@@ -407,7 +422,8 @@ namespace Tnb.WarehouseMgr
carryMats = carryMats.OrderBy(o => o.create_time).GroupBy(g => new { g.carry_id, g.material_id, g.code_batch })
.Select(x =>
{
- WmsCarryMat carryMat = new();
+ var arr = x.ToArray();
+ WmsCarryMat carryMat = arr[^arr.Length];
carryMat.need_qty = x.Sum(d => d.need_qty);
return carryMat;
})
@@ -432,6 +448,15 @@ namespace Tnb.WarehouseMgr
}
}
carryIds = allOutIds.Concat(sortingOutIds).ToList();
+ if (carryIds?.Count > 0)
+ {
+ var carryId = carryIds[^carryIds.Count];
+ var curCurry = await _db.Queryable().SingleAsync(it => it.id == carryId);
+ var isMatch = await IsCarryAndLocationMatchByCarryStd(curCurry, location);
+ if (!isMatch) throw new AppFriendlyException("该载具无法放置到目标库位", 500);
+ }
+ await _db.Insertable(outstock).ExecuteCommandAsync();
+ await _db.Insertable(outstockDs).ExecuteCommandAsync();
await _db.Updateable().SetColumns(it => new WmsCarryH { out_status = ((int)EnumOutStatus.全部出).ToString() }).Where(it => allOutIds.Contains(it.id)).ExecuteCommandAsync();
await _db.Updateable().SetColumns(it => new WmsCarryH { out_status = ((int)EnumOutStatus.分拣出).ToString() }).Where(it => sortingOutIds.Contains(it.id)).ExecuteCommandAsync();
@@ -527,11 +552,12 @@ namespace Tnb.WarehouseMgr
}
catch (Exception ex)
{
+ isSuccessful = false;
JNPF.Logging.Log.Error(ex.Message);
await _db.Ado.RollbackTranAsync();
- return await ToApiResult(JNPF.Common.Enums.HttpStatusCode.InternalServerError, ex.Message);
+ throw ex;
}
- return await ToApiResult();
+ return isSuccessful;
}
public override async Task ModifyAsync(WareHouseUpInput input)
diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDACarryMoveInStockService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDACarryMoveInStockService.cs
index 6b87d88e..d89d3c80 100644
--- a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDACarryMoveInStockService.cs
+++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDACarryMoveInStockService.cs
@@ -66,22 +66,27 @@ namespace Tnb.WarehouseMgr
{
await _db.Ado.BeginTranAsync();
- VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleId, true);
- await _runService.Create(templateEntity, input);
//入库取终点 //出库起点
var inStockStrategyInput = new InStockStrategyQuery { warehouse_id = input.data[nameof(InStockStrategyQuery.warehouse_id)].ToString()!, Size = 1 };
var endLocations = await _wareHouseService.InStockStrategy(inStockStrategyInput);
- WmsPointH? sPoint = null;
- WmsPointH? ePoint = null;
+ WmsPointH sPoint = null!;
+ WmsPointH ePoint = null!;
if (input.data.ContainsKey(nameof(WmsPointH.location_id)))
{
sPoint = await _db.Queryable().FirstAsync(it => it.location_id == input.data[nameof(WmsPointH.location_id)].ToString());
}
if (endLocations?.Count > 0)
{
+ var carry = await _db.Queryable().SingleAsync(it => it.id == input.data[nameof(WmsCarryD.carry_id)].ToString());
+ var loc = await _db.Queryable().SingleAsync(it => it.id == endLocations[0].id);
+ var isMatch = await IsCarryAndLocationMatchByCarryStd(carry, loc);
+ if (!isMatch) throw new AppFriendlyException("库位与载具规格不匹配", 500);
ePoint = await _db.Queryable().FirstAsync(it => it.location_id == endLocations[0].id);
}
+ VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleId, true);
+ await _runService.Create(templateEntity, input);
+
if (sPoint != null && ePoint != null)
{
var points = await _wareHouseService.PathAlgorithms(sPoint.id, ePoint.id);
diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDACarryMoveOutStockService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDACarryMoveOutStockService.cs
index 036ed9f3..1eb351ca 100644
--- a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDACarryMoveOutStockService.cs
+++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDACarryMoveOutStockService.cs
@@ -63,12 +63,15 @@ namespace Tnb.WarehouseMgr
{
await _db.Ado.BeginTranAsync();
+ var carry = await _db.Queryable().FirstAsync(it => it.id == input.data[nameof(WmsMoveOutstock.carry_id)].ToString());
+ var loc = await _db.Queryable().SingleAsync(it => it.id == input.data[nameof(WmsPointH.location_id)].ToString());
+ var isMatch = await IsCarryAndLocationMatchByCarryStd(carry, loc);
+ if (!isMatch) throw new AppFriendlyException("该载具无法放置到目标库位", 500);
+
VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleConsts.MODULE_WMSCARRYMOOUTSTKPDA_ID, true);
await _runService.Create(templateEntity, input);
//出库取起点
- var carry = await _db.Queryable().FirstAsync(it => it.id == input.data[nameof(WmsMoveOutstock.carry_id)].ToString());
- WmsPointH? sPoint = null;
- WmsPointH? ePoint = null;
+ WmsPointH? sPoint = null, ePoint = null;
if (input.data.ContainsKey(nameof(WmsPointH.location_id)))
{
ePoint = await _db.Queryable().FirstAsync(it => it.location_id == input.data[nameof(WmsPointH.location_id)].ToString());
@@ -114,7 +117,6 @@ namespace Tnb.WarehouseMgr
return preTask;
}).ToList();
//判断目标库位是否自动签收
- var loc = await _db.Queryable().SingleAsync(it => it.id == input.data[nameof(WmsPointH.location_id)].ToString());
if (loc.is_sign == 0)
{
preTasks[^1].is_sign = 0; // 修改最后一个元素的是否签收值
diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAEmptyInstockService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAEmptyInstockService.cs
index 051aa9d9..ad2de004 100644
--- a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAEmptyInstockService.cs
+++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAEmptyInstockService.cs
@@ -65,9 +65,7 @@ namespace Tnb.WarehouseMgr
{
await _db.Ado.BeginTranAsync();
- VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleConsts.MODULE_WMSEMPTYINSTKPDA_ID, true);
- await _runService.Create(templateEntity, input);
- //入库取终点
+ //入库取终点 //出库起点
var inStockStrategyInput = new InStockStrategyQuery { warehouse_id = input.data[nameof(InStockStrategyQuery.warehouse_id)].ToString()!, Size = 1 };
var endLocations = await _wareHouseService.InStockStrategy(inStockStrategyInput);
WmsPointH sPoint = null!;
@@ -78,9 +76,16 @@ namespace Tnb.WarehouseMgr
}
if (endLocations?.Count > 0)
{
+ var carry = await _db.Queryable().SingleAsync(it => it.id == input.data[nameof(WmsCarryD.carry_id)].ToString());
+ var loc = await _db.Queryable().SingleAsync(it => it.id == endLocations[0].id);
+ var isMatch = await IsCarryAndLocationMatchByCarryStd(carry, loc);
+ if (!isMatch) throw new AppFriendlyException("库位与载具规格不匹配", 500);
ePoint = await _db.Queryable().FirstAsync(it => it.location_id == endLocations[0].id);
}
+ VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleConsts.MODULE_WMSEMPTYINSTKPDA_ID, true);
+ await _runService.Create(templateEntity, input);
+
if (sPoint != null && ePoint != null)
{
var points = await _wareHouseService.PathAlgorithms(sPoint.id, ePoint.id);
diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAEmptyOutstockService .cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAEmptyOutstockService .cs
index a38bbb9e..cae51fdc 100644
--- a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAEmptyOutstockService .cs
+++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAEmptyOutstockService .cs
@@ -106,24 +106,26 @@ namespace Tnb.WarehouseMgr
{
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_WMSEPTYOUTSTK_ID;
- preTask.task_type = WmsWareHouseConst.WMS_PRETASK_OUTSTOCK_TYPE_ID;
- preTask.carry_id = carrys![i].id;
- preTask.carry_code = carrys![i].carry_code;
- preTask.area_id = sPoint?.area_id!;
- preTask.area_code = it.Key;
- preTask.require_id = input.data["ReturnIdentity"].ToString();
+ //生成预任务
+ WmsPretaskH preTask = new()
+ {
+ org_id = _userManager.User.OrganizeId,
+ startlocation_id = sPoint?.location_id!,
+ startlocation_code = sPoint?.location_code!,
+ endlocation_id = ePoint?.location_id!,
+ endlocation_code = ePoint?.location_code!,
+ start_floor = sPoint?.floor.ToString(),
+ end_floor = ePoint?.floor.ToString(),
+ bill_code = _billRullService.GetBillNumber(WmsWareHouseConst.WMS_PRETASK_H_ENCODE).GetAwaiter().GetResult(),
+ status = WmsWareHouseConst.PRETASK_BILL_STATUS_DXF_ID,
+ biz_type = WmsWareHouseConst.BIZTYPE_WMSEPTYOUTSTK_ID,
+ task_type = WmsWareHouseConst.WMS_PRETASK_OUTSTOCK_TYPE_ID,
+ carry_id = carrys![i].id,
+ carry_code = carrys![i].carry_code,
+ area_id = sPoint?.area_id!,
+ area_code = it.Key,
+ 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;
@@ -139,39 +141,47 @@ namespace Tnb.WarehouseMgr
}
if (isOk)
{
- var preTaskUpInput = new GenPreTaskUpInput();
- preTaskUpInput.RquireId = input.data["ReturnIdentity"].ToString()!;
- preTaskUpInput.CarryId = carrys![i].id;
- preTaskUpInput.CarryStartLocationId = points.FirstOrDefault()!.location_id!;
- preTaskUpInput.CarryStartLocationCode = points.FirstOrDefault()!.location_code!;
- preTaskUpInput.LocationIds = points.Select(x => x.location_id).ToList()!;
+ //生成预任务上传输入
+ GenPreTaskUpInput preTaskUpInput = new()
+ {
+ RquireId = input.data["ReturnIdentity"].ToString()!,
+ CarryId = carrys![i].id,
+ CarryStartLocationId = points.FirstOrDefault()!.location_id!,
+ CarryStartLocationCode = points.FirstOrDefault()!.location_code!,
+ LocationIds = points.Select(x => x.location_id).ToList()!
+ };
//更新明细表
- WmsEmptyOutstockD wmsEmptyOutstockD = new();
- wmsEmptyOutstockD.id = SnowflakeIdHelper.NextId();
- wmsEmptyOutstockD.bill_id = preTaskUpInput.RquireId;
- wmsEmptyOutstockD.biz_type = WmsWareHouseConst.BIZTYPE_WMSEPTYOUTSTK_ID;
- wmsEmptyOutstockD.location_id = ePoint!.location_id!;
- wmsEmptyOutstockD.status = WmsWareHouseConst.BILLSTATUS_COMPLETE_ID;
- wmsEmptyOutstockD.carry_id = carrys[i].id;
- wmsEmptyOutstockD.carry_code = carrys[i].carry_code;
- wmsEmptyOutstockD.create_id = _userManager.UserId;
- wmsEmptyOutstockD.create_time = DateTime.Now;
+ WmsEmptyOutstockD wmsEmptyOutstockD = new()
+ {
+ id = SnowflakeIdHelper.NextId(),
+ bill_id = preTaskUpInput.RquireId,
+ biz_type = WmsWareHouseConst.BIZTYPE_WMSEPTYOUTSTK_ID,
+ location_id = ePoint!.location_id!,
+ status = WmsWareHouseConst.BILLSTATUS_COMPLETE_ID,
+ carry_id = carrys[i].id,
+ carry_code = carrys[i].carry_code,
+ create_id = _userManager.UserId,
+ create_time = DateTime.Now
+ };
await _db.Insertable(wmsEmptyOutstockD)
.ExecuteCommandAsync();
- WmsHandleH handleH = new();
- handleH.org_id = _userManager.User.OrganizeId;
- handleH.startlocation_id = carrys?[i].location_id!;
- handleH.endlocation_id = ePoint!.location_id!;
- handleH.bill_code = input.data[nameof(WmsHandleH.bill_code)]?.ToString()!;
- handleH.biz_type = input.data[nameof(WmsHandleH.biz_type)]?.ToString()!;
- handleH.carry_id = input.data[nameof(WmsHandleH.carry_id)]?.ToString()!;
- handleH.carry_code = input.data[nameof(WmsHandleH.carry_code)]?.ToString()!;
- handleH.require_id = input.data["ReturnIdentity"].ToString();
- handleH.require_code = input.data[nameof(WmsHandleH.bill_code)]?.ToString()!;
- handleH.create_id = _userManager.UserId;
- handleH.create_time = DateTime.Now;
+ //生成操作记录表
+ WmsHandleH handleH = new()
+ {
+ org_id = _userManager.User.OrganizeId,
+ startlocation_id = carrys?[i].location_id!,
+ endlocation_id = ePoint!.location_id!,
+ bill_code = input.data[nameof(WmsHandleH.bill_code)]?.ToString()!,
+ biz_type = input.data[nameof(WmsHandleH.biz_type)]?.ToString()!,
+ carry_id = input.data[nameof(WmsHandleH.carry_id)]?.ToString()!,
+ carry_code = input.data[nameof(WmsHandleH.carry_code)]?.ToString()!,
+ require_id = input.data["ReturnIdentity"].ToString(),
+ require_code = input.data[nameof(WmsHandleH.bill_code)]?.ToString()!,
+ create_id = _userManager.UserId,
+ create_time = DateTime.Now
+ };
preTaskUpInput.PreTaskRecord = handleH;
//根据空载具出库Id,回更单据状态
await _db.Updateable().SetColumns(it => new WmsEmptyOutstockH { status = WmsWareHouseConst.BILLSTATUS_ON_ID }).Where(it => it.id == preTaskUpInput.RquireId).ExecuteCommandAsync();
diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAFeedingService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAFeedingService.cs
index ff96cddc..23b83bb3 100644
--- a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAFeedingService.cs
+++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAFeedingService.cs
@@ -27,25 +27,28 @@ namespace Tnb.WarehouseMgr
/// PDA投料记录
///
[OverideVisualDev(ModuleConsts.MODULE_WMSFEEDINGRECORDPDA_ID)]
- public class WmsPDAFeedingService : BaseWareHouseService, IWmsCarryService, IPdaStroage
+ public class WmsPDAFeedingService : BaseWareHouseService, IPdaStroage
{
private readonly ISqlSugarClient _db;
private readonly IUserManager _userManager;
private readonly IBillRullService _billRullService;
private readonly IRunService _runService;
private readonly IVisualDevService _visualDevService;
+ private readonly IWmsCarryService _carryService;
public WmsPDAFeedingService(
ISqlSugarRepository repository,
IUserManager userManager,
IBillRullService billRullService,
IRunService runService,
- IVisualDevService visualDevService)
+ IVisualDevService visualDevService,
+ IWmsCarryService carryService)
{
_db = repository.AsSugarClient();
_userManager = userManager;
_billRullService = billRullService;
_runService = runService;
_visualDevService = visualDevService;
+ _carryService = carryService;
OverideFuncs.CreateAsync = WmsPDAFeedingRecord;
}
@@ -97,7 +100,7 @@ namespace Tnb.WarehouseMgr
it.modify_time
}).ExecuteCommandAsync();
//更新载具
- row = await UpdateNullCarry(carry);
+ row = await _carryService.UpdateNullCarry(carry);
isOk = (row > 0);
if (!isOk) throw Oops.Oh(ErrorCode.COM1001);
}
@@ -124,37 +127,5 @@ namespace Tnb.WarehouseMgr
return isOk;
}
- public async Task UpdateNullCarry(WmsCarryH carryObj)
- {
- var row = -1;
- try
- {
- carryObj.status = 0;
- carryObj.carry_status = ((int)EnumCarryStatus.空闲).ToString();
- carryObj.location_id = null;
- carryObj.location_code = null;
- carryObj.out_status = "0";
- carryObj.is_check = 0;
- carryObj.status = 1;
- carryObj.bale_num = null;
- carryObj.collocation_scheme_id = null;
- carryObj.collocation_scheme_code = null;
- carryObj.source_id = null;
- carryObj.source_code = null;
- row = await _db.Updateable(carryObj).ExecuteCommandAsync();
- //删除对应明细表
- //删除载具明细
- await _db.Deleteable().Where(it => it.carry_id == carryObj.id).ExecuteCommandHasChangeAsync();
- //删除载具分拣物料明细
- await _db.Deleteable().Where(it => it.carry_id == carryObj.id).ExecuteCommandHasChangeAsync();
- //删除载具条码
- await _db.Deleteable().Where(it => it.carry_id == carryObj.id).ExecuteCommandHasChangeAsync();
- }
- catch (Exception)
- {
-
- }
- return row;
- }
}
}
\ No newline at end of file
diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAInStockService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAInStockService.cs
index d1f52154..d18391c3 100644
--- a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAInStockService.cs
+++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAInStockService.cs
@@ -92,6 +92,10 @@ namespace Tnb.WarehouseMgr
}
if (endLocations?.Count > 0)
{
+ var carry = await _db.Queryable().SingleAsync(it => it.id == input.data[nameof(WmsCarryD.carry_id)].ToString());
+ var loc = await _db.Queryable().SingleAsync(it => it.id == endLocations[0].id);
+ var isMatch = await IsCarryAndLocationMatchByCarryStd(carry, loc);
+ if (!isMatch) throw new AppFriendlyException("库位与载具规格不匹配", 500);
ePoint = await _db.Queryable().FirstAsync(it => it.location_id == endLocations[0].id);
}
diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAInbaleService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAInbaleService.cs
index 7322f013..6e4c6ca2 100644
--- a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAInbaleService.cs
+++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAInbaleService.cs
@@ -80,6 +80,10 @@ namespace Tnb.WarehouseMgr
}
if (endLocations?.Count > 0)
{
+ var carry = await _db.Queryable().SingleAsync(it => it.id == input.data[nameof(WmsCarryD.carry_id)].ToString());
+ var loc = await _db.Queryable().SingleAsync(it => it.id == endLocations[0].id);
+ var isMatch = await IsCarryAndLocationMatchByCarryStd(carry, loc);
+ if (!isMatch) throw new AppFriendlyException("库位与载具规格不匹配", 500);
ePoint = await _db.Queryable().FirstAsync(it => it.location_id == endLocations[0].id);
}
diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsPretaskService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsPretaskService.cs
new file mode 100644
index 00000000..d8668c42
--- /dev/null
+++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsPretaskService.cs
@@ -0,0 +1,23 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Runtime.InteropServices;
+using System.Text;
+using System.Threading.Tasks;
+using JNPF.VisualDev;
+using NPOI.SS.Formula.Functions;
+using SqlSugar;
+using Tnb.BasicData.Entities;
+using Tnb.WarehouseMgr.Entities;
+
+namespace Tnb.WarehouseMgr
+{
+ [OverideVisualDev(ModuleConsts.MODULE_WMSPRETASK_ID)]
+ public class WmsPretaskService : TaskManagerDelBase
+ {
+ public WmsPretaskService(ISqlSugarRepository repository) : base(repository.AsSugarClient())
+ {
+
+ }
+ }
+}
diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsSetSortingService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsSetSortingService.cs
index 282556f8..98a05402 100644
--- a/WarehouseMgr/Tnb.WarehouseMgr/WmsSetSortingService.cs
+++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsSetSortingService.cs
@@ -50,8 +50,11 @@ namespace Tnb.WarehouseMgr
///
///
[HttpPost]
- public async Task PackSortingByAdd(WmsCarryMat? carryMat)
+ public async Task PackSortingByAdd(WmsCarryMat carryMat)
{
+ string firstLocationId = "27010980724501", secondLocationId = "27010987857941";
+ var endLocation = await _db.Queryable().SingleAsync(it => it.id == secondLocationId);
+
var setSortings = await _db.Queryable()
.Where(a => a.status == WmsWareHouseConst.BILLSTATUS_ADD_ID).OrderBy(a => a.seq)
.ToListAsync();
@@ -61,9 +64,18 @@ namespace Tnb.WarehouseMgr
{
await _db.Ado.BeginTranAsync();
+ var singleSorting = new WmsSetsortingH();
+ if (setSortings?.Count > 0)
+ {
+ singleSorting = setSortings[0];
+ var curCarry = await _db.Queryable().SingleAsync(it => it.id == singleSorting.carry_id);
+ var isMatch = await IsCarryAndLocationMatchByCarryStd(curCarry, endLocation);
+ if (!isMatch) throw new AppFriendlyException("库位与载具规格不匹配", 500);
+ }
+
if (setSortings?.Count > 0 && !onFlag)
{
- var singleSorting = setSortings[^setSortings.Count];
+
var setSortingDList = await _db.Queryable().Where(it => it.bill_id == singleSorting.id).ToListAsync();
if (setSortingDList?.Count > 0)
{
@@ -124,8 +136,9 @@ namespace Tnb.WarehouseMgr
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.need_qty = x.Sum(d => d.need_qty);
+ var arr = x.ToArray();
+ WmsCarryMat carryMat = arr[^arr.Length];
+ carryMat.need_qty = arr.Sum(d => d.need_qty);
return carryMat;
})
.ToList();
@@ -141,18 +154,18 @@ namespace Tnb.WarehouseMgr
{
List preTasks = new();
List locIds = new();
- string firstLocationId = "27010980724501", secondLocationId = "27010987857941";
+
var mid = 6;
if (carrys.Length > mid)
{
var leftCarrys = carrys[..mid];
var rightCarrys = carrys[mid..];
- await InnerGenPreTask(leftCarrys, locIds, firstLocationId, singleSorting.id, singleSorting.bill_code, preTasks);
- await InnerGenPreTask(rightCarrys, locIds, secondLocationId, singleSorting.id, singleSorting.bill_code, preTasks);
+ await InnerGenPreTask(leftCarrys, locIds, firstLocationId, singleSorting.id, singleSorting.bill_code, preTasks, endLocation);
+ await InnerGenPreTask(rightCarrys, locIds, secondLocationId, singleSorting.id, singleSorting.bill_code, preTasks, endLocation);
}
else
{
- await InnerGenPreTask(carrys, locIds, firstLocationId, singleSorting.id, singleSorting.bill_code, preTasks);
+ await InnerGenPreTask(carrys, locIds, firstLocationId, singleSorting.id, singleSorting.bill_code, preTasks, endLocation);
}
List pretaskCodes = new();
foreach (var pt in preTasks)
@@ -187,9 +200,8 @@ namespace Tnb.WarehouseMgr
}
}
- private async Task InnerGenPreTask(WmsCarryH[] carrys, List locIds, string eLocationId, string requireId, string requireCode, List preTasks)
+ private async Task InnerGenPreTask(WmsCarryH[] carrys, List locIds, string eLocationId, string requireId, string requireCode, List preTasks, BasLocation endLocation)
{
- var loc = await _db.Queryable().SingleAsync(it => it.id == eLocationId);
foreach (var carry in carrys)
{
WmsPointH sPoint = await _db.Queryable().FirstAsync(it => it.location_id == carry.location_id);
@@ -198,7 +210,10 @@ namespace Tnb.WarehouseMgr
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)
+ {
+ locIds.AddRange(points.Select(x => x.location_id).ToList()!);
+ }
//根据获取的路径点生成预任务,生成顺序必须预路径算法返回的起终点的顺序一致(预任务顺序)
if (points?.Count > 0)
{
@@ -232,7 +247,7 @@ namespace Tnb.WarehouseMgr
};
return preTask;
}).ToList();
- if (loc.is_sign == 0)
+ if (endLocation.is_sign == 0)
{
curPreTasks[^1].is_sign = 0; // 修改最后一个元素的是否签收值
}
diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsSignForDeliveryService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsSignForDeliveryService.cs
index f9d0b86a..6cb7f10d 100644
--- a/WarehouseMgr/Tnb.WarehouseMgr/WmsSignForDeliveryService.cs
+++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsSignForDeliveryService.cs
@@ -76,7 +76,7 @@ namespace Tnb.WarehouseMgr
}
if (carry != null)
{
- if (carry!.location_id!.IsNotEmptyOrNull())
+ if (carry?.location_id?.IsNotEmptyOrNull() ?? false)
{
var loc = await _db.Queryable().SingleAsync(it => it.id == carry.location_id);
loc.is_use = ((int)EnumCarryStatus.空闲).ToString();
@@ -139,7 +139,7 @@ namespace Tnb.WarehouseMgr
}
catch (Exception)
{
- isSuccessFul= false;
+ isSuccessFul = false;
}
return isSuccessFul;
}
diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmskittingOutService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmskittingOutService.cs
index 79fff1cd..b134cd91 100644
--- a/WarehouseMgr/Tnb.WarehouseMgr/WmskittingOutService.cs
+++ b/WarehouseMgr/Tnb.WarehouseMgr/WmskittingOutService.cs
@@ -13,6 +13,7 @@ using JNPF.Common.Enums;
using JNPF.Common.Extension;
using JNPF.Common.Security;
using JNPF.FriendlyException;
+using JNPF.LinqBuilder;
using JNPF.Logging;
using JNPF.Systems.Interfaces.System;
using Mapster;
@@ -70,20 +71,25 @@ namespace Tnb.WarehouseMgr
// 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)
{
+ //a.carrystd_id == WmsWareHouseConst.CARRY_LJSTD_ID
+
+ Expression> whereExp = (ko.carry_id != null) ? a => a.id == ko.carry_id : a => a.carrystd_id == WmsWareHouseConst.CARRY_LJSTD_ID;
+
var carrys = await _db.Queryable()
.InnerJoin((a, b) => a.collocation_scheme_id == b.id)
- .Where(a => a.collocation_scheme_id == ko.collocation_scheme_id && a.is_lock == 0)
+ .Where(whereExp.And(a => a.collocation_scheme_id == ko.collocation_scheme_id && a.is_lock == 0))
.OrderBy((a, b) => b.seq)
.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!);
+ await _warehouseService.GenInStockTaskHandleAfter(genPreTaskInput, it => new WmsCarryH { is_lock = 1, out_status = EnumOutStatus.全部出.ToString() }, null!);
ko.status = WmsWareHouseConst.BILLSTATUS_TOBESHIPPED_ID;
ko.carry_id = firstCarry?.id;
ko.carry_code = firstCarry?.carry_code;
@@ -174,26 +180,28 @@ namespace Tnb.WarehouseMgr
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;
+ WmsPretaskH preTask = new()
+ {
+ org_id = _userManager.User.OrganizeId,
+ startlocation_id = sPoint?.location_id!,
+ startlocation_code = sPoint?.location_code!,
+ endlocation_id = ePoint?.location_id!,
+ endlocation_code = ePoint?.location_code!,
+ start_floor = sPoint?.floor.ToString(),
+ end_floor = ePoint?.floor.ToString(),
+ bill_code = _billRullService.GetBillNumber(WmsWareHouseConst.WMS_PRETASK_H_ENCODE).GetAwaiter().GetResult(),
+ status = WmsWareHouseConst.PRETASK_BILL_STATUS_DXF_ID,
+ biz_type = ko.biz_type,
+ task_type = WmsWareHouseConst.WMS_PRETASK_OUTSTOCK_TYPE_ID,
+ carry_id = ko!.carry_id!,
+ carry_code = ko!.carry_code!,
+ area_id = sPoint?.area_id!,
+ area_code = it.Key,
+ require_id = ko.id,
+ require_code = ko.bill_code,
+ create_id = _userManager.UserId,
+ create_time = DateTime.Now
+ };
return preTask;
}).ToList();
if (loc.is_sign == 0)
@@ -238,14 +246,14 @@ namespace Tnb.WarehouseMgr
var carry = await _db.Queryable().SingleAsync(it => it.id == carryId);
var kods = await _db.Queryable().Where(it => it.bill_id == input.requireId).ToListAsync();
//载具为料架时,取所有料箱的条码
- List carryMIds = new();
+ List mCarryIds = new();
if (carry.carrystd_id == WmsWareHouseConst.CARRY_LJSTD_ID)
{
var carryDs = await _db.Queryable().Where(it => it.carry_id == carryId).ToListAsync();
- carryMIds = carryDs.Select(x => x.membercarry_id).ToList();
+ mCarryIds = carryDs.Select(x => x.membercarry_id).ToList();
}
//当前载具对应的所有条码插入
- Expression> whereExp = carryMIds?.Count > 0 ? a => carryMIds.Contains(a.carry_id) : a => a.carry_id == carryId;
+ Expression> whereExp = mCarryIds?.Count > 0 ? a => mCarryIds.Contains(a.carry_id) : a => a.carry_id == carryId;
var carryCodes = await _db.Queryable().Where(whereExp).ToListAsync();
var kittingoutCodes = carryCodes.Adapt>();
@@ -290,9 +298,9 @@ namespace Tnb.WarehouseMgr
// isOk = row > 0;
//}
//判断当前载具是否为料架,如果是料架 清空所有料架/料箱数据,
- if (carry.carrystd_id == WmsWareHouseConst.CARRY_LJSTD_ID)
+ if (carry.carrystd_id == WmsWareHouseConst.CARRY_LJSTD_ID && mCarryIds?.Count > 0)
{
- var carrys = await _db.Queryable().Where(it => carryMIds.Contains(it.id)).ToListAsync();
+ var carrys = await _db.Queryable().Where(it => mCarryIds.Contains(it.id)).ToListAsync();
carrys.Add(carry);
if (carrys?.Count > 0)
{
@@ -325,9 +333,14 @@ namespace Tnb.WarehouseMgr
public async Task MESKittingOutStk(List input)
{
var isSuccessFul = false;
- if (input.IsNull()) throw new ArgumentNullException("input");
+ if (input.IsNull()) throw new ArgumentNullException(nameof(input));
try
{
+ var kittingOut = input[^1];
+ var curCarry = await _db.Queryable().SingleAsync(it => it.id == kittingOut.carry_id);
+ var endLocation = await _db.Queryable().SingleAsync(it => it.id == kittingOut.location_id);
+ var isMatch = await IsCarryAndLocationMatchByCarryStd(curCarry, endLocation);
+ if (!isMatch) throw new AppFriendlyException("该载具无法放置到目标库位", 500);
await _db.Ado.BeginTranAsync();
List kittingOutDs = new();
diff --git a/system/Tnb.Systems/Permission/DepartmentService.cs b/system/Tnb.Systems/Permission/DepartmentService.cs
index 85325c15..17b56670 100644
--- a/system/Tnb.Systems/Permission/DepartmentService.cs
+++ b/system/Tnb.Systems/Permission/DepartmentService.cs
@@ -313,6 +313,32 @@ public class DepartmentService : IDepartmentService, IDynamicApiController, ITra
if (adminlist.Any()) await _repository.AsSugarClient().Insertable(adminlist).CallEntityMethod(m => m.Create()).ExecuteReturnEntityAsync();
#endregion
+
+ if (input.category != DictConst.RegionCategoryCompanyCode)
+ {
+ var jsonObj = input.propertyJson;
+ var qrcode = jsonObj.GetValue("qrcode");
+ if (qrcode is not null && !string.IsNullOrEmpty(qrcode.ToString()))
+ {
+ if (await _repository.AsSugarClient().Queryable().AnyAsync(x => x.code == qrcode.ToString()))
+ {
+ throw Oops.Bah("二维码总表中已存在该二维码");
+ }
+ else
+ {
+ BasQrcode basQrcode = new BasQrcode()
+ {
+ code = qrcode.ToString(),
+ source_id = entity.Id,
+ source_name = "BASE_ORGANIZE",
+ create_id = _userManager.UserId,
+ create_time = DateTime.Now,
+ org_id = _userManager.GetUserInfo().Result.organizeId,
+ };
+ await _repository.AsSugarClient().Insertable(basQrcode).ExecuteCommandAsync();
+ }
+ }
+ }
#region 第三方同步
@@ -450,6 +476,43 @@ public class DepartmentService : IDepartmentService, IDynamicApiController, ITra
int isOK = await _repository.AsUpdateable(entity).IgnoreColumns(ignoreAllNullColumns: true).CallEntityMethod(m => m.LastModify()).ExecuteCommandAsync();
if (!(isOK > 0)) throw Oops.Oh(ErrorCode.D2018);
+
+ //modified by zkd on 20230718 处理二维码
+ if (input.category != DictConst.RegionCategoryCompanyCode)
+ {
+ var jsonObj = input.propertyJson;
+ var qrcode = jsonObj.GetValue("qrcode");
+ if (qrcode is not null && !string.IsNullOrEmpty(qrcode.ToString()))
+ {
+ if (await _repository.AsSugarClient().Queryable().AnyAsync(x => x.code == qrcode.ToString() && x.source_id!=id))
+ {
+ throw Oops.Bah("二维码总表中已存在该二维码");
+ }
+ else
+ {
+ if (await _repository.AsSugarClient().Queryable().AnyAsync(x => x.source_id == id))
+ {
+ await _repository.AsSugarClient().Updateable()
+ .SetColumns(x => x.code == qrcode.ToString()).Where(x => x.source_id == id)
+ .ExecuteCommandAsync();
+ }
+ else
+ {
+ BasQrcode basQrcode = new BasQrcode()
+ {
+ code = qrcode.ToString(),
+ source_id = id,
+ source_name = "BASE_ORGANIZE",
+ create_id = _userManager.UserId,
+ create_time = DateTime.Now,
+ org_id = _userManager.GetUserInfo().Result.organizeId,
+ };
+ await _repository.AsSugarClient().Insertable(basQrcode).ExecuteCommandAsync();
+ }
+ }
+ }
+ }
+
//modified by ly on 20230426 处理工位信息,将工位插入到设备表
if (input.category == DictConst.RegionCategoryStationCode)
{
diff --git a/visualdev/Tnb.VisualDev/RunService.cs b/visualdev/Tnb.VisualDev/RunService.cs
index 00545f6c..214bb0df 100644
--- a/visualdev/Tnb.VisualDev/RunService.cs
+++ b/visualdev/Tnb.VisualDev/RunService.cs
@@ -753,15 +753,15 @@ public class RunService : IRunService, ITransient
dictionarySql.Clear();
tableField.Add("ReturnIdentity", mainId);
dictionarySql.Add("MainTableReturnIdentity", new List>() { tableField });
- }
-
+ }
+
//modify by zhoukeda 20230428 雪花id返回至传入参数中 开始
if (templateInfo.FormModel.primaryKeyPolicy.Equals(1))
{
dataInput.data.Add("ReturnIdentity", mainId);
}
//modify by zhoukeda 20230428 雪花id返回至传入参数中 结束
-
+
// 拼接副表 sql
if (templateInfo.AuxiliaryTableFieldsModelList.Any())
@@ -823,7 +823,11 @@ public class RunService : IRunService, ITransient
{
if (child.Key.Equals("id") && child.Value.IsNotEmptyOrNull())
{
- tableField[childPrimary.field] = child.Value;
+ //modify by ly on 20230720 判断如果子表主键为空的把原主键值赋值给子表主键,直接复制会导致主键重复
+ if(tableField[childPrimary.field].IsNull() || tableField[childPrimary.field].ToString().IsNullOrEmpty())
+ {
+ tableField[childPrimary.field] = child.Value;
+ }
}
else if (child.Key.IsNotEmptyOrNull() && child.Value.IsNotEmptyOrNull() && child.Value.ToString() != "[]")
{
@@ -986,7 +990,7 @@ public class RunService : IRunService, ITransient
// 查找到该控件数据
List>? model = allDataMap[item].ToObject>>();
- if (model != null && model.Count > 0)
+ if (model != null && model.Count >= 0) //modify by ly on 20230720 将Count>0改为>=0,否则最后一条明细数据删除不掉
{
// 利用key去找模板
FieldsModel? fieldsModel = templateInfo.FieldsModelList.Find(f => f.__vModel__ == item);
@@ -1199,7 +1203,7 @@ public class RunService : IRunService, ITransient
var oldTInfo = new TemplateParsingBase(oldFEntity.PropertyJson, oldFEntity.TableJson, (int)oldFEntity.FormType); // 旧模板
var newTInfo = new TemplateParsingBase(newFEntity.PropertyJson, newFEntity.TableJson, (int)newFEntity.FormType); // 新模板
- if(oldFEntity.FormType.Equals(1) || newFEntity.FormType.Equals(1))
+ if (oldFEntity.FormType.Equals(1) || newFEntity.FormType.Equals(1))
{
oldTInfo.AllFieldsModel.ForEach(it =>
{
@@ -1689,7 +1693,7 @@ public class RunService : IRunService, ITransient
Dictionary? newChildData = new Dictionary();
foreach (KeyValuePair item in childmap)
{
- if(item.Key.Equals("id")) newChildData[item.Key] = childmap[item.Key];
+ if (item.Key.Equals("id")) newChildData[item.Key] = childmap[item.Key];
FieldsModel? childFieldsModel = childFieldsModelList.Where(c => c.__vModel__ == item.Key).FirstOrDefault();
if (childFieldsModel != null && childFieldsModel.__vModel__.Equals(item.Key))
{
@@ -1999,7 +2003,7 @@ public class RunService : IRunService, ITransient
///
private string GetPrimary(DbLinkEntity link, string MainTableName)
{
- // modified by PhilPan
+ // modified by PhilPan
var keys = _databaseService.GetPrimaries(link, MainTableName);
if (keys.Count < 1) throw Oops.Oh(ErrorCode.D1402); // 主表未设置主键
return keys.First();
@@ -2464,7 +2468,7 @@ public class RunService : IRunService, ITransient
}
// 子表字段为空 查询 处理.
- if (templateInfo.ChildTableFields.Any(x => x.Value.Contains(tName + "."))&&(dicList.ToJsonString().Contains("\"ConditionalType\":11") || dicList.ToJsonString().Contains("\"ConditionalType\":14")))
+ if (templateInfo.ChildTableFields.Any(x => x.Value.Contains(tName + ".")) && (dicList.ToJsonString().Contains("\"ConditionalType\":11") || dicList.ToJsonString().Contains("\"ConditionalType\":14")))
queryOrSqlList.Add(string.Format(" OR ( [{0}] NOT IN ( SELECT {1} FROM {2} ) ) ", primaryKey, templateInfo.AllTable.Where(x => x.table.Equals(tName)).First().tableField, tName));
if (!tableWhere.ContainsKey(tName)) tableWhere.Add(tName, new List() { conList });
@@ -2945,7 +2949,7 @@ public class RunService : IRunService, ITransient
// 多选时为模糊查询
if (model.multiple || model.searchMultiple)
{
- var value = item.Value.ToString().Contains("[") ? item.Value.ToObject>():new List