Merge branch 'dev' of https://git.tuotong-tech.com/tnb/tnb.server into dev
This commit is contained in:
@@ -12,6 +12,18 @@ public static class DictConst
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public const string RegionCategoryStationCode = "workstation";
|
public const string RegionCategoryStationCode = "workstation";
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
/// 区域类型-公司Code
|
||||||
|
/// </summary>
|
||||||
|
public const string RegionCategoryCompanyCode = "company";
|
||||||
|
/// <summary>
|
||||||
|
/// 区域类型-车间Code
|
||||||
|
/// </summary>
|
||||||
|
public const string RegionCategoryWorkshopCode = "workshop";
|
||||||
|
/// <summary>
|
||||||
|
/// 区域类型-产线Code
|
||||||
|
/// </summary>
|
||||||
|
public const string RegionCategoryWorklineCode = "workline";
|
||||||
|
/// <summary>
|
||||||
/// 备品备件类型
|
/// 备品备件类型
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public const string SparePartsType = "SparePartsType";
|
public const string SparePartsType = "SparePartsType";
|
||||||
@@ -102,8 +114,10 @@ public static class DictConst
|
|||||||
/// 模具保养状态-待保养编码
|
/// 模具保养状态-待保养编码
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public const string MoldMaintainStatusDBYCode = "UnMaintain";
|
public const string MoldMaintainStatusDBYCode = "UnMaintain";
|
||||||
|
/// <summary>
|
||||||
|
/// 任务单状态key
|
||||||
|
/// </summary>
|
||||||
|
public const string TaskStatus = "TaskStatus";
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,9 @@ namespace Tnb.BasicData
|
|||||||
//载具签收接口
|
//载具签收接口
|
||||||
public const string MES_CARRY_SIGN = "/api/wms/wms-sign-for-delivery/mes-carry-sign";
|
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
|
#endregion
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -75,6 +75,10 @@ public partial class BasLocation : BaseEntity<string>
|
|||||||
/// 修改用户
|
/// 修改用户
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string? modify_id { get; set; }
|
public string? modify_id { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 载具规格分类Id
|
||||||
|
/// </summary>
|
||||||
|
public string carrystd_id { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 修改时间
|
/// 修改时间
|
||||||
|
|||||||
47
BasicData/Tnb.BasicData.Entities/Entity/BasQrcode.cs
Normal file
47
BasicData/Tnb.BasicData.Entities/Entity/BasQrcode.cs
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
using JNPF.Common.Contracts;
|
||||||
|
using JNPF.Common.Security;
|
||||||
|
using SqlSugar;
|
||||||
|
|
||||||
|
namespace Tnb.BasicData.Entities;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 系统二维码表
|
||||||
|
/// </summary>
|
||||||
|
[SugarTable("bas_qrcode")]
|
||||||
|
public partial class BasQrcode : BaseEntity<string>
|
||||||
|
{
|
||||||
|
public BasQrcode()
|
||||||
|
{
|
||||||
|
id = SnowflakeIdHelper.NextId();
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 编码
|
||||||
|
/// </summary>
|
||||||
|
public string code { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 关联表id
|
||||||
|
/// </summary>
|
||||||
|
public string? source_id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 关联表名
|
||||||
|
/// </summary>
|
||||||
|
public string? source_name { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 创建用户
|
||||||
|
/// </summary>
|
||||||
|
public string? create_id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 创建时间
|
||||||
|
/// </summary>
|
||||||
|
public DateTime? create_time { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 所属组织
|
||||||
|
/// </summary>
|
||||||
|
public string? org_id { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
112
BasicData/Tnb.BasicData.Entities/Entity/BasStandardTime.cs
Normal file
112
BasicData/Tnb.BasicData.Entities/Entity/BasStandardTime.cs
Normal file
@@ -0,0 +1,112 @@
|
|||||||
|
using JNPF.Common.Contracts;
|
||||||
|
using JNPF.Common.Security;
|
||||||
|
using SqlSugar;
|
||||||
|
|
||||||
|
namespace Tnb.BasicData.Entities;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 标准工时
|
||||||
|
/// </summary>
|
||||||
|
[SugarTable("bas_standard_time")]
|
||||||
|
public partial class BasStandardTime : BaseEntity<string>
|
||||||
|
{
|
||||||
|
public BasStandardTime()
|
||||||
|
{
|
||||||
|
id = SnowflakeIdHelper.NextId();
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 生产BOMid
|
||||||
|
/// </summary>
|
||||||
|
public string? mbom_id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 工艺路线id
|
||||||
|
/// </summary>
|
||||||
|
public string? routing_id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 工序id
|
||||||
|
/// </summary>
|
||||||
|
public string? process_id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 工位id
|
||||||
|
/// </summary>
|
||||||
|
public string? station_id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 类型
|
||||||
|
/// </summary>
|
||||||
|
public string? type { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 标准工时
|
||||||
|
/// </summary>
|
||||||
|
public string? standard_time { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 标准工时单位
|
||||||
|
/// </summary>
|
||||||
|
public string? standard_time_unit { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 标准产能
|
||||||
|
/// </summary>
|
||||||
|
public string? standard_capacity { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 标准产能单位
|
||||||
|
/// </summary>
|
||||||
|
public string? standard_capacity_unit { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 创建用户
|
||||||
|
/// </summary>
|
||||||
|
public string? create_id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 创建时间
|
||||||
|
/// </summary>
|
||||||
|
public DateTime? create_time { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 修改用户
|
||||||
|
/// </summary>
|
||||||
|
public string? modify_id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 修改时间
|
||||||
|
/// </summary>
|
||||||
|
public DateTime? modify_time { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 所属组织
|
||||||
|
/// </summary>
|
||||||
|
public string? org_id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 编号
|
||||||
|
/// </summary>
|
||||||
|
public string? code { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 流程任务Id
|
||||||
|
/// </summary>
|
||||||
|
public string? f_flowtaskid { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 流程引擎Id
|
||||||
|
/// </summary>
|
||||||
|
public string? f_flowid { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否启用
|
||||||
|
/// </summary>
|
||||||
|
public int? enabled { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 工序来源选择
|
||||||
|
/// </summary>
|
||||||
|
public string? process_source { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
namespace Tnb.EquipMgr.Entities.Dto
|
||||||
|
{
|
||||||
|
public class WorklineAndEquipTreeOutput
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 获取节点id.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public string id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 标题
|
||||||
|
/// </summary>
|
||||||
|
public string title { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取节点父id.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public string parentId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否有子级.
|
||||||
|
/// </summary>
|
||||||
|
public bool hasChildren { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 设置Children.
|
||||||
|
/// </summary>
|
||||||
|
public List<WorklineAndEquipTreeOutput>? children { get; set; } = new List<WorklineAndEquipTreeOutput>();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 子节点数量.
|
||||||
|
/// </summary>
|
||||||
|
public int num { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否为子节点.
|
||||||
|
/// </summary>
|
||||||
|
public bool isLeaf { get; set; } = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -17,5 +17,11 @@ namespace Tnb.EquipMgr.Interfaces
|
|||||||
/// <param name="dic"></param>
|
/// <param name="dic"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public Task<dynamic> GetListByTypeId(Dictionary<string, string> dic);
|
public Task<dynamic> GetListByTypeId(Dictionary<string, string> dic);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取产线和注塑挤出设备树
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public Task<dynamic> GetWorklineAndEquipTree(Dictionary<string,string> dic);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,16 +1,28 @@
|
|||||||
using Aop.Api.Domain;
|
using Aop.Api.Domain;
|
||||||
using Aspose.Cells.Drawing;
|
using Aspose.Cells.Drawing;
|
||||||
|
using JNPF.Common.Core.Manager;
|
||||||
|
using JNPF.Common.Dtos.VisualDev;
|
||||||
using JNPF.Common.Filter;
|
using JNPF.Common.Filter;
|
||||||
|
using JNPF.Common.Security;
|
||||||
using JNPF.DependencyInjection;
|
using JNPF.DependencyInjection;
|
||||||
using JNPF.DynamicApiController;
|
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;
|
||||||
|
using JNPF.VisualDev.Entitys;
|
||||||
using JNPF.VisualDev.Entitys.Dto.VisualDevModelData;
|
using JNPF.VisualDev.Entitys.Dto.VisualDevModelData;
|
||||||
|
using JNPF.VisualDev.Interfaces;
|
||||||
using Mapster;
|
using Mapster;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Senparc.NeuChar.ApiHandlers;
|
||||||
using SqlSugar;
|
using SqlSugar;
|
||||||
|
using Tnb.BasicData;
|
||||||
using Tnb.EquipMgr.Entities;
|
using Tnb.EquipMgr.Entities;
|
||||||
using Tnb.EquipMgr.Entities.Dto;
|
using Tnb.EquipMgr.Entities.Dto;
|
||||||
using Tnb.EquipMgr.Interfaces;
|
using Tnb.EquipMgr.Interfaces;
|
||||||
|
using Tnb.BasicData.Entities;
|
||||||
|
|
||||||
namespace Tnb.EquipMgr
|
namespace Tnb.EquipMgr
|
||||||
{
|
{
|
||||||
@@ -24,12 +36,24 @@ namespace Tnb.EquipMgr
|
|||||||
public class EquipmentService : IOverideVisualDevService, IEquipmentService, IDynamicApiController, ITransient
|
public class EquipmentService : IOverideVisualDevService, IEquipmentService, IDynamicApiController, ITransient
|
||||||
{
|
{
|
||||||
public OverideVisualDevFunc OverideFuncs { get; } = new OverideVisualDevFunc();
|
public OverideVisualDevFunc OverideFuncs { get; } = new OverideVisualDevFunc();
|
||||||
private const string ModuleId = "25064865727509";
|
private const string ModuleId = "26012367560469";
|
||||||
private readonly ISqlSugarRepository<EqpEquipment> _repository;
|
private readonly ISqlSugarRepository<EqpEquipment> _repository;
|
||||||
|
private readonly IVisualDevService _visualDevService;
|
||||||
|
private readonly IRunService _runService;
|
||||||
|
private readonly IUserManager _userManager;
|
||||||
|
|
||||||
public EquipmentService(ISqlSugarRepository<EqpEquipment> repository)
|
public EquipmentService(ISqlSugarRepository<EqpEquipment> repository,
|
||||||
|
IVisualDevService visualDevService,
|
||||||
|
IUserManager userManager,
|
||||||
|
IRunService runService
|
||||||
|
)
|
||||||
{
|
{
|
||||||
_repository = repository;
|
_repository = repository;
|
||||||
|
_visualDevService = visualDevService;
|
||||||
|
_runService = runService;
|
||||||
|
_userManager = userManager;
|
||||||
|
OverideFuncs.CreateAsync = Create;
|
||||||
|
OverideFuncs.UpdateAsync = Update;
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 在线开发-获取设备列表
|
/// 在线开发-获取设备列表
|
||||||
@@ -63,6 +87,75 @@ namespace Tnb.EquipMgr
|
|||||||
return pagedList;
|
return pagedList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async Task<dynamic> Create(VisualDevModelDataCrInput visualDevModelDataCrInput)
|
||||||
|
{
|
||||||
|
string qrcode = visualDevModelDataCrInput.data.ContainsKey("qrcode") ? visualDevModelDataCrInput.data["qrcode"].ToString() : "";
|
||||||
|
if (!string.IsNullOrEmpty(qrcode) && await _repository.AsSugarClient().Queryable<BasQrcode>().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>(basQrcode).ExecuteCommandAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return await Task.FromResult(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task<dynamic> Update(string id,VisualDevModelDataUpInput visualDevModelDataUpInput)
|
||||||
|
{
|
||||||
|
string qrcode = visualDevModelDataUpInput.data.ContainsKey("qrcode") ? visualDevModelDataUpInput.data["qrcode"].ToString() : "";
|
||||||
|
if (!string.IsNullOrEmpty(qrcode) && await _repository.AsSugarClient().Queryable<BasQrcode>().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<BasQrcode>().AnyAsync(x => x.source_id == id))
|
||||||
|
{
|
||||||
|
await _repository.AsSugarClient().Updateable<BasQrcode>()
|
||||||
|
.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>(basQrcode).ExecuteCommandAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return await Task.FromResult(true);
|
||||||
|
}
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public async Task<EqpEquipment> GetEntityById(Dictionary<string,string> dic)
|
public async Task<EqpEquipment> GetEntityById(Dictionary<string,string> dic)
|
||||||
{
|
{
|
||||||
@@ -78,5 +171,67 @@ namespace Tnb.EquipMgr
|
|||||||
return await _repository.AsSugarClient().Queryable<EqpEquipment>().Where(x => typeIdArr.Contains(x.equip_type_id))
|
return await _repository.AsSugarClient().Queryable<EqpEquipment>().Where(x => typeIdArr.Contains(x.equip_type_id))
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public async Task<dynamic> GetWorklineAndEquipTree(Dictionary<string,string> dic)
|
||||||
|
{
|
||||||
|
string equipTypes = dic.ContainsKey("equipTypes") ? dic["equipTypes"] : "";
|
||||||
|
var db = _repository.AsSugarClient();
|
||||||
|
var queryable1 = db.Queryable<OrganizeEntity>()
|
||||||
|
.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<OrganizeEntity>().Where(b=>b.ParentId==a.Id && b.DeleteMark==null && b.Category==DictConst.RegionCategoryWorklineCode).Any(),
|
||||||
|
num = SqlFunc.Subqueryable<OrganizeEntity>().Where(b=>b.ParentId==a.Id && b.DeleteMark==null && b.Category==DictConst.RegionCategoryWorklineCode).Count(),
|
||||||
|
isLeaf = false,
|
||||||
|
children = SqlFunc.Subqueryable<OrganizeEntity>().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<WorklineAndEquipTreeOutput> list2 = new List<WorklineAndEquipTreeOutput>();
|
||||||
|
if (!string.IsNullOrEmpty(equipTypes))
|
||||||
|
{
|
||||||
|
string[] equipTypeArr = equipTypes.Split(",");
|
||||||
|
list2 = await db.Queryable<EqpEquipType>()
|
||||||
|
.Where((a) => equipTypeArr.Contains(a.code))
|
||||||
|
.Select((a) => new WorklineAndEquipTreeOutput()
|
||||||
|
{
|
||||||
|
id = a.id,
|
||||||
|
title = a.name,
|
||||||
|
parentId = "0",
|
||||||
|
hasChildren = SqlFunc.Subqueryable<EqpEquipment>().Where(b=>b.equip_type_id==a.id).Any(),
|
||||||
|
num = SqlFunc.Subqueryable<EqpEquipment>().Where(b=>b.equip_type_id==a.id).Count(),
|
||||||
|
isLeaf = false,
|
||||||
|
children = SqlFunc.Subqueryable<EqpEquipment>().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<string,object>()
|
||||||
|
{
|
||||||
|
["list"] = list1,
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4,10 +4,17 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Aspose.Cells.Drawing;
|
using Aspose.Cells.Drawing;
|
||||||
|
using JNPF.Common.Core.Manager;
|
||||||
|
using JNPF.Common.Dtos.VisualDev;
|
||||||
using JNPF.DependencyInjection;
|
using JNPF.DependencyInjection;
|
||||||
using JNPF.DynamicApiController;
|
using JNPF.DynamicApiController;
|
||||||
|
using JNPF.FriendlyException;
|
||||||
|
using JNPF.VisualDev;
|
||||||
|
using JNPF.VisualDev.Entitys;
|
||||||
|
using JNPF.VisualDev.Interfaces;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using SqlSugar;
|
using SqlSugar;
|
||||||
|
using Tnb.BasicData.Entities;
|
||||||
using Tnb.EquipMgr.Entities;
|
using Tnb.EquipMgr.Entities;
|
||||||
using Tnb.EquipMgr.Interfaces;
|
using Tnb.EquipMgr.Interfaces;
|
||||||
|
|
||||||
@@ -18,16 +25,99 @@ namespace Tnb.EquipMgr
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
[ApiDescriptionSettings(Tag = ModuleConsts.Tag, Area = ModuleConsts.Area, Order = 700)]
|
[ApiDescriptionSettings(Tag = ModuleConsts.Tag, Area = ModuleConsts.Area, Order = 700)]
|
||||||
[Route("api/[area]/[controller]/[action]")]
|
[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;
|
private readonly ISqlSugarClient _db;
|
||||||
public ToolMoldLocationService(ISqlSugarRepository<ToolLocation> repository)
|
private readonly IVisualDevService _visualDevService;
|
||||||
|
private readonly IRunService _runService;
|
||||||
|
private readonly IUserManager _userManager;
|
||||||
|
public ToolMoldLocationService(ISqlSugarRepository<ToolLocation> repository,
|
||||||
|
IVisualDevService visualDevService,
|
||||||
|
IUserManager userManager,
|
||||||
|
IRunService runService)
|
||||||
{
|
{
|
||||||
_db = repository.AsSugarClient();
|
_db = repository.AsSugarClient();
|
||||||
|
_visualDevService = visualDevService;
|
||||||
|
_runService = runService;
|
||||||
|
_userManager = userManager;
|
||||||
|
OverideFuncs.CreateAsync = Create;
|
||||||
|
OverideFuncs.UpdateAsync = Update;
|
||||||
}
|
}
|
||||||
public async Task<Dictionary<string, object>> GetLocationDictionary()
|
public async Task<Dictionary<string, object>> GetLocationDictionary()
|
||||||
{
|
{
|
||||||
return await _db.Queryable<ToolLocation>().ToDictionaryAsync(x => x.id, x => x.location_code);
|
return await _db.Queryable<ToolLocation>().ToDictionaryAsync(x => x.id, x => x.location_code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async Task<dynamic> Create(VisualDevModelDataCrInput visualDevModelDataCrInput)
|
||||||
|
{
|
||||||
|
string qrcode = visualDevModelDataCrInput.data.ContainsKey("qrcode") ? visualDevModelDataCrInput.data["qrcode"].ToString() : "";
|
||||||
|
if (!string.IsNullOrEmpty(qrcode) && await _db.Queryable<BasQrcode>().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>(basQrcode).ExecuteCommandAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return await Task.FromResult(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task<dynamic> Update(string id,VisualDevModelDataUpInput visualDevModelDataUpInput)
|
||||||
|
{
|
||||||
|
string qrcode = visualDevModelDataUpInput.data.ContainsKey("qrcode") ? visualDevModelDataUpInput.data["qrcode"].ToString() : "";
|
||||||
|
if (!string.IsNullOrEmpty(qrcode) && await _db.Queryable<BasQrcode>().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<BasQrcode>().AnyAsync(x => x.source_id == id))
|
||||||
|
{
|
||||||
|
await _db.Updateable<BasQrcode>()
|
||||||
|
.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>(basQrcode).ExecuteCommandAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return await Task.FromResult(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -104,4 +104,9 @@ public partial class PerProcessStandardsH : BaseEntity<string>
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public string? f_flowid { get; set; }
|
public string? f_flowid { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 成型周期
|
||||||
|
/// </summary>
|
||||||
|
public decimal? moulding_cycle { get; set; }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
namespace Tnb.ProductionMgr.Entities.Dto.PrdManage
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 排产用于计算预计结束时间
|
||||||
|
/// </summary>
|
||||||
|
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; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 1 注塑挤出排产 2 组装包装排产
|
||||||
|
/// </summary>
|
||||||
|
public int type { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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<FeedingRecordChildren> children { get; set; } = new List<FeedingRecordChildren>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public class FeedingRecordChildren
|
||||||
|
{
|
||||||
|
public string id { get; set; }
|
||||||
|
public string code { get; set; }
|
||||||
|
|
||||||
|
public string mo_task_id { get; set; }
|
||||||
|
|
||||||
|
public List<FeedingRecordMaterialChildren> children { get; set; } = new List<FeedingRecordMaterialChildren>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public class FeedingRecordMaterialChildren
|
||||||
|
{
|
||||||
|
public string material_code { get; set; }
|
||||||
|
|
||||||
|
public string material_name { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -27,5 +27,7 @@ namespace Tnb.ProductionMgr.Entities.Dto
|
|||||||
public string? create_id { get; set; } = string.Empty;
|
public string? create_id { get; set; } = string.Empty;
|
||||||
public string? create_id_id { get; set; } = string.Empty;
|
public string? create_id_id { get; set; } = string.Empty;
|
||||||
public string? create_time { get; set; } = string.Empty;
|
public string? create_time { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public string? batch { get; set; } = string.Empty;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
namespace Tnb.ProductionMgr.Entities.Dto.PrdManage
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 任务单调整列表输出
|
||||||
|
/// </summary>
|
||||||
|
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; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,57 @@
|
|||||||
|
using JNPF.Common.Contracts;
|
||||||
|
using JNPF.Common.Security;
|
||||||
|
using SqlSugar;
|
||||||
|
|
||||||
|
namespace Tnb.ProductionMgr.Entities;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// mes生产领料子表
|
||||||
|
/// </summary>
|
||||||
|
[SugarTable("prd_outstock_d")]
|
||||||
|
public partial class PrdOutstockD : BaseEntity<string>
|
||||||
|
{
|
||||||
|
public PrdOutstockD()
|
||||||
|
{
|
||||||
|
id = SnowflakeIdHelper.NextId();
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 物料id
|
||||||
|
/// </summary>
|
||||||
|
public string? material_id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 物料编号
|
||||||
|
/// </summary>
|
||||||
|
public string? material_code { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 单位id
|
||||||
|
/// </summary>
|
||||||
|
public string? unit_id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 出库需求数量
|
||||||
|
/// </summary>
|
||||||
|
public string? pr_qty { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 来源单据id
|
||||||
|
/// </summary>
|
||||||
|
public string? source_id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 批次
|
||||||
|
/// </summary>
|
||||||
|
public string? code_batch { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 生产领料主表id
|
||||||
|
/// </summary>
|
||||||
|
public string? outstock_id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 物料名称
|
||||||
|
/// </summary>
|
||||||
|
public string? material_name { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,72 @@
|
|||||||
|
using JNPF.Common.Contracts;
|
||||||
|
using JNPF.Common.Security;
|
||||||
|
using SqlSugar;
|
||||||
|
|
||||||
|
namespace Tnb.ProductionMgr.Entities;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// mes生产领料主表
|
||||||
|
/// </summary>
|
||||||
|
[SugarTable("prd_outstock_h")]
|
||||||
|
public partial class PrdOutstockH : BaseEntity<string>
|
||||||
|
{
|
||||||
|
public PrdOutstockH()
|
||||||
|
{
|
||||||
|
id = SnowflakeIdHelper.NextId();
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 出库单创建日期
|
||||||
|
/// </summary>
|
||||||
|
public string? bill_date { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 单据类型
|
||||||
|
/// </summary>
|
||||||
|
public string? bill_type { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 发料仓库id
|
||||||
|
/// </summary>
|
||||||
|
public string? warehouse_id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 目标库位编号
|
||||||
|
/// </summary>
|
||||||
|
public string? location_code { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 创建用户
|
||||||
|
/// </summary>
|
||||||
|
public string? create_id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 所属组织
|
||||||
|
/// </summary>
|
||||||
|
public string? org_id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 单据编号
|
||||||
|
/// </summary>
|
||||||
|
public string? bill_code { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 发料工位
|
||||||
|
/// </summary>
|
||||||
|
public string? workstation { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 所属产线
|
||||||
|
/// </summary>
|
||||||
|
public string? workline { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 流程任务Id
|
||||||
|
/// </summary>
|
||||||
|
public string? f_flowtaskid { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 流程引擎Id
|
||||||
|
/// </summary>
|
||||||
|
public string? f_flowid { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
@@ -21,5 +21,11 @@ namespace Tnb.ProductionMgr.Interfaces
|
|||||||
/// <param name="input"></param>
|
/// <param name="input"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public Task<dynamic> SaveDataNew(MaterialReceiptNewInput input);
|
public Task<dynamic> SaveDataNew(MaterialReceiptNewInput input);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 投料记录
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public Task<dynamic> GetFeedingRecordTree();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
namespace Tnb.ProductionMgr.Interfaces
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 生产领料服务
|
||||||
|
/// </summary>
|
||||||
|
public interface IPrdOutstockService
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,10 +4,13 @@ using JNPF.Common.Enums;
|
|||||||
using JNPF.Common.Security;
|
using JNPF.Common.Security;
|
||||||
using JNPF.DependencyInjection;
|
using JNPF.DependencyInjection;
|
||||||
using JNPF.DynamicApiController;
|
using JNPF.DynamicApiController;
|
||||||
|
using JNPF.Extras.CollectiveOAuth.Models;
|
||||||
using JNPF.Extras.CollectiveOAuth.Utils;
|
using JNPF.Extras.CollectiveOAuth.Utils;
|
||||||
using JNPF.FriendlyException;
|
using JNPF.FriendlyException;
|
||||||
|
using JNPF.Logging;
|
||||||
using JNPF.Systems.Entitys.Permission;
|
using JNPF.Systems.Entitys.Permission;
|
||||||
using JNPF.Systems.Interfaces.System;
|
using JNPF.Systems.Interfaces.System;
|
||||||
|
using JNPF.VisualDev.Entitys;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.ClearScript.Util.Web;
|
using Microsoft.ClearScript.Util.Web;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
@@ -163,6 +166,9 @@ namespace Tnb.ProductionMgr
|
|||||||
public async Task<dynamic> SaveDataNew(MaterialReceiptNewInput input)
|
public async Task<dynamic> SaveDataNew(MaterialReceiptNewInput input)
|
||||||
{
|
{
|
||||||
var db = _repository.AsSugarClient();
|
var db = _repository.AsSugarClient();
|
||||||
|
PrdFeedingH prdFeedingH = null;
|
||||||
|
List<PrdFeedingD> list = new List<PrdFeedingD>();
|
||||||
|
DbResult<bool> result2 = new DbResult<bool>();
|
||||||
DbResult<bool> result = await db.Ado.UseTranAsync(async () =>
|
DbResult<bool> result = await db.Ado.UseTranAsync(async () =>
|
||||||
{
|
{
|
||||||
var moTask = await db.Queryable<PrdMoTask>().FirstAsync(x => x.id == input.mo_task_id);
|
var moTask = await db.Queryable<PrdMoTask>().FirstAsync(x => x.id == input.mo_task_id);
|
||||||
@@ -176,9 +182,8 @@ namespace Tnb.ProductionMgr
|
|||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
string code = await _billRullService.GetBillNumber(Tnb.BasicData.CodeTemplateConst.FEEDING_CODE);
|
string code = await _billRullService.GetBillNumber(Tnb.BasicData.CodeTemplateConst.FEEDING_CODE);
|
||||||
PrdFeedingH prdFeedingH = new PrdFeedingH()
|
prdFeedingH = new PrdFeedingH()
|
||||||
{
|
{
|
||||||
code = code,
|
code = code,
|
||||||
station_id = input.station_id,
|
station_id = input.station_id,
|
||||||
@@ -196,7 +201,6 @@ namespace Tnb.ProductionMgr
|
|||||||
org_id = _userManager.GetUserInfo().Result.organizeId
|
org_id = _userManager.GetUserInfo().Result.organizeId
|
||||||
};
|
};
|
||||||
|
|
||||||
List<PrdFeedingD> list = new List<PrdFeedingD>();
|
|
||||||
if (input.details != null && input.details.Count > 0)
|
if (input.details != null && input.details.Count > 0)
|
||||||
{
|
{
|
||||||
foreach (var item in input.details)
|
foreach (var item in input.details)
|
||||||
@@ -253,8 +257,8 @@ namespace Tnb.ProductionMgr
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
await db.Insertable<PrdFeedingH>(prdFeedingH).ExecuteCommandAsync();
|
// await db.Insertable<PrdFeedingH>(prdFeedingH).ExecuteCommandAsync();
|
||||||
await db.Insertable<PrdFeedingD>(list).ExecuteCommandAsync();
|
// await db.Insertable<PrdFeedingD>(list).ExecuteCommandAsync();
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -281,10 +285,69 @@ namespace Tnb.ProductionMgr
|
|||||||
["Authorization"] = App.HttpContext.Request.Headers["Authorization"]
|
["Authorization"] = App.HttpContext.Request.Headers["Authorization"]
|
||||||
};
|
};
|
||||||
var sendResult = HttpUtils.RequestPost(domain + WebApiConst.MES_CARRY_SIGN,JsonConvert.SerializeObject(mesCarrySignInput),header);
|
var sendResult = HttpUtils.RequestPost(domain + WebApiConst.MES_CARRY_SIGN,JsonConvert.SerializeObject(mesCarrySignInput),header);
|
||||||
|
Log.Information(sendResult);
|
||||||
|
AuthResponse authResponse = JsonConvert.DeserializeObject<AuthResponse>(sendResult);
|
||||||
|
if (authResponse.code != 200)
|
||||||
|
{
|
||||||
|
throw Oops.Bah(authResponse.msg);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
result2 = await db.Ado.UseTranAsync(async () =>
|
||||||
|
{
|
||||||
|
await db.Insertable<PrdFeedingH>(prdFeedingH).ExecuteCommandAsync();
|
||||||
|
await db.Insertable<PrdFeedingD>(list).ExecuteCommandAsync();
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!result.IsSuccess) throw Oops.Oh(result.ErrorMessage);
|
if(!result2.IsSuccess) throw Oops.Oh(result2.ErrorMessage);
|
||||||
return result.IsSuccess ? "签收成功" : result.ErrorMessage;
|
return result2.IsSuccess ? "签收成功" : result2.ErrorMessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public async Task<dynamic> GetFeedingRecordTree()
|
||||||
|
{
|
||||||
|
var db = _repository.AsSugarClient();
|
||||||
|
var result = await db.Queryable<PrdMoTask>()
|
||||||
|
.Where(a => a.schedule_type == 2 && a.parent_id!=null)
|
||||||
|
.Select(a => new FeedingRecordTreeOutput()
|
||||||
|
{
|
||||||
|
mo_task_code = a.mo_task_code,
|
||||||
|
children = SqlFunc.Subqueryable<PrdFeedingH>().Where(b=>a.id==b.mo_task_id).ToList(b=>new FeedingRecordChildren()
|
||||||
|
{
|
||||||
|
id = b.id,
|
||||||
|
code = b.code,
|
||||||
|
// children = SqlFunc.Subqueryable<PrdFeedingD>().LeftJoin<BasMaterial>((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<FeedingRecordMaterialChildren>(),
|
||||||
|
// children = b!=null ? SqlFunc.Subqueryable<PrdFeedingD>()
|
||||||
|
// .Where((c)=>"26897270557717"=="26897270557717").ToList((c)=>new FeedingRecordMaterialChildren()
|
||||||
|
// {
|
||||||
|
// // material_code = d.code,
|
||||||
|
// // material_name = d.name,
|
||||||
|
// }) : new List<FeedingRecordMaterialChildren>()
|
||||||
|
})
|
||||||
|
}).Mapper(x =>
|
||||||
|
{
|
||||||
|
foreach (var item in x.children)
|
||||||
|
{
|
||||||
|
item.children = db.Queryable<PrdFeedingD>()
|
||||||
|
.LeftJoin<BasMaterial>((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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3,8 +3,10 @@ using JNPF.Common.Core.Manager;
|
|||||||
using JNPF.Common.Enums;
|
using JNPF.Common.Enums;
|
||||||
using JNPF.DependencyInjection;
|
using JNPF.DependencyInjection;
|
||||||
using JNPF.DynamicApiController;
|
using JNPF.DynamicApiController;
|
||||||
|
using JNPF.Extras.CollectiveOAuth.Models;
|
||||||
using JNPF.Extras.CollectiveOAuth.Utils;
|
using JNPF.Extras.CollectiveOAuth.Utils;
|
||||||
using JNPF.FriendlyException;
|
using JNPF.FriendlyException;
|
||||||
|
using JNPF.Logging;
|
||||||
using JNPF.RemoteRequest;
|
using JNPF.RemoteRequest;
|
||||||
using JNPF.Systems.Interfaces.System;
|
using JNPF.Systems.Interfaces.System;
|
||||||
using Mapster;
|
using Mapster;
|
||||||
@@ -48,6 +50,8 @@ namespace Tnb.ProductionMgr
|
|||||||
var db = _repository.AsSugarClient();
|
var db = _repository.AsSugarClient();
|
||||||
var location = await db.Queryable<BasLocation>().FirstAsync(x => x.location_code == input.location_code);
|
var location = await db.Queryable<BasLocation>().FirstAsync(x => x.location_code == input.location_code);
|
||||||
PrdInstockH prdInstockH = null;
|
PrdInstockH prdInstockH = null;
|
||||||
|
List<PrdInstockD> prdInstockDs = new List<PrdInstockD>() { };
|
||||||
|
DbResult<bool> result2 = new DbResult<bool>();
|
||||||
DbResult<bool> result = await db.Ado.UseTranAsync(async () =>
|
DbResult<bool> result = await db.Ado.UseTranAsync(async () =>
|
||||||
{
|
{
|
||||||
prdInstockH = new PrdInstockH()
|
prdInstockH = new PrdInstockH()
|
||||||
@@ -63,7 +67,6 @@ namespace Tnb.ProductionMgr
|
|||||||
status = 0,
|
status = 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
List<PrdInstockD> prdInstockDs = new List<PrdInstockD>() { };
|
|
||||||
foreach (var item in input.details)
|
foreach (var item in input.details)
|
||||||
{
|
{
|
||||||
prdInstockDs.Add(new PrdInstockD()
|
prdInstockDs.Add(new PrdInstockD()
|
||||||
@@ -79,12 +82,12 @@ namespace Tnb.ProductionMgr
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
await _repository.InsertAsync(prdInstockH);
|
// await _repository.InsertAsync(prdInstockH);
|
||||||
|
//
|
||||||
if (prdInstockDs.Count > 0)
|
// if (prdInstockDs.Count > 0)
|
||||||
{
|
// {
|
||||||
await db.Insertable<PrdInstockD>(prdInstockDs).ExecuteCommandAsync();
|
// await db.Insertable<PrdInstockD>(prdInstockDs).ExecuteCommandAsync();
|
||||||
}
|
// }
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -132,11 +135,29 @@ namespace Tnb.ProductionMgr
|
|||||||
["Authorization"] = App.HttpContext.Request.Headers["Authorization"]
|
["Authorization"] = App.HttpContext.Request.Headers["Authorization"]
|
||||||
};
|
};
|
||||||
var sendResult = HttpUtils.RequestPost(domain + WebApiConst.MES_CREATE_INSTOCK,JsonConvert.SerializeObject(mesCreateInstockInput),header);
|
var sendResult = HttpUtils.RequestPost(domain + WebApiConst.MES_CREATE_INSTOCK,JsonConvert.SerializeObject(mesCreateInstockInput),header);
|
||||||
Console.WriteLine(sendResult);
|
Log.Information(sendResult);
|
||||||
|
AuthResponse authResponse = JsonConvert.DeserializeObject<AuthResponse>(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<PrdInstockD>(prdInstockDs).ExecuteCommandAsync();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!result.IsSuccess) throw Oops.Oh(ErrorCode.COM1008);
|
if(!result2.IsSuccess) throw Oops.Oh(ErrorCode.COM1008);
|
||||||
return result.IsSuccess ? "保存成功" : result.ErrorMessage;
|
return result2.IsSuccess ? "保存成功" : result2.ErrorMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -147,15 +168,26 @@ namespace Tnb.ProductionMgr
|
|||||||
public async Task<dynamic> SyncInstock(Dictionary<string, string> dic)
|
public async Task<dynamic> SyncInstock(Dictionary<string, string> dic)
|
||||||
{
|
{
|
||||||
string sourceId = dic.ContainsKey("source_id") ? dic["source_id"] : "";
|
string sourceId = dic.ContainsKey("source_id") ? dic["source_id"] : "";
|
||||||
if (!string.IsNullOrEmpty(sourceId))
|
var db = _repository.AsSugarClient();
|
||||||
|
DbResult<bool> result = await db.Ado.UseTranAsync(async () =>
|
||||||
{
|
{
|
||||||
return await _repository.UpdateAsync(x => new PrdInstockH()
|
if (!string.IsNullOrEmpty(sourceId))
|
||||||
{
|
{
|
||||||
status = 1
|
await _repository.UpdateAsync(x => new PrdInstockH()
|
||||||
}, x => x.id == sourceId);
|
{
|
||||||
}
|
status = 1
|
||||||
|
}, x => x.id == sourceId);
|
||||||
|
var details = await db.Queryable<PrdInstockD>().Where(x => x.instock_id == sourceId).ToListAsync();
|
||||||
|
|
||||||
return false;
|
foreach (var item in details)
|
||||||
|
{
|
||||||
|
await db.Updateable<PrdReport>().SetColumns(x => x.status == 1)
|
||||||
|
.Where(x => x.id == item.report_id).ExecuteCommandAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return result.IsSuccess;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -20,6 +20,11 @@ using Tnb.ProductionMgr.Interfaces;
|
|||||||
using Aspose.Cells.Drawing;
|
using Aspose.Cells.Drawing;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using JNPF.Common.Extension;
|
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
|
namespace Tnb.ProductionMgr
|
||||||
{
|
{
|
||||||
@@ -46,54 +51,82 @@ namespace Tnb.ProductionMgr
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// private async Task<dynamic> 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<BasMaterial>().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<ToolMolds>().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<EqpEquipment>().FirstAsync(it => it.id == eqpId);
|
||||||
|
// if (eqp != null)
|
||||||
|
// {
|
||||||
|
// row["eqp_id"] = $"{eqp.code}/{eqp.name}";
|
||||||
|
// row["eqpid"] = eqp.id;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// return data!;
|
||||||
|
// }
|
||||||
|
|
||||||
private async Task<dynamic> GetList(VisualDevModelListQueryInput input)
|
private async Task<dynamic> GetList(VisualDevModelListQueryInput input)
|
||||||
{
|
{
|
||||||
var db = _repository.AsSugarClient();
|
var db = _repository.AsSugarClient();
|
||||||
VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleId, true);
|
Dictionary<string, string> queryJson = !string.IsNullOrEmpty(input.queryJson) ? JsonConvert.DeserializeObject<Dictionary<string, string>>(input.queryJson) : new Dictionary<string, string>();
|
||||||
var data = await _runService.GetListResult(templateEntity, input);
|
string moTaskCode = queryJson.ContainsKey("mo_task_code") ? queryJson["mo_task_code"].ToString() : "";
|
||||||
if (data?.list?.Count > 0)
|
string moTaskStatus = queryJson.ContainsKey("mo_task_status") ? queryJson["mo_task_status"].ToString() : "";
|
||||||
{
|
var result = await db.Queryable<PrdMoTask>()
|
||||||
var scheduledTypeField = nameof(PrdMoTask.schedule_type);
|
.LeftJoin<BasMaterial>((a, b) => a.material_id == b.id)
|
||||||
data.list = data.list.Where(it => it[scheduledTypeField].IsNotEmptyOrNull() && it[scheduledTypeField].ParseToInt() == 1).ToList();
|
.LeftJoin<DictionaryTypeEntity>((a, b, c) => c.EnCode == DictConst.TaskStatus)
|
||||||
foreach (var row in data.list)
|
.LeftJoin<DictionaryDataEntity>((a, b, c, d) => c.Id == d.DictionaryTypeId && a.mo_task_status == d.EnCode)
|
||||||
|
.LeftJoin<ToolMolds>((a,b,c,d,e)=>a.mold_id==e.id)
|
||||||
|
.LeftJoin<PrdMo>((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);
|
id = a.id,
|
||||||
var pkName = "material_id";
|
mo_task_code = a.mo_task_code,
|
||||||
if (dic.ContainsKey(pkName))
|
material_id = b.code+"/"+b.name,
|
||||||
{
|
mold_id = e.mold_code+"/"+e.mold_name,
|
||||||
var materialId = dic[pkName]?.ToString();
|
mo_task_status = d.FullName,
|
||||||
var material = await db.Queryable<BasMaterial>().FirstAsync(it => it.id == materialId);
|
plan_qty = f.plan_qty,
|
||||||
if (material != null)
|
scheduled_qty = a.scheduled_qty,
|
||||||
{
|
}).ToPagedListAsync(input.currentPage, input.pageSize);
|
||||||
row["material_id"] = $"{material.code}/{material.name}";
|
return PageResult<PrdMoTask>.SqlSugarPageResult(result);
|
||||||
row["materialid"] = material.id;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//模具
|
|
||||||
if (dic.ContainsKey("mold_id"))
|
|
||||||
{
|
|
||||||
var moldId = dic["mold_id"]?.ToString();
|
|
||||||
var mold = await db.Queryable<ToolMolds>().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<EqpEquipment>().FirstAsync(it => it.id == eqpId);
|
|
||||||
if (eqp != null)
|
|
||||||
{
|
|
||||||
row["eqp_id"] = $"{eqp.code}/{eqp.name}";
|
|
||||||
row["eqpid"] = eqp.id;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return data!;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,6 +43,9 @@ using Microsoft.ClearScript.Util.Web;
|
|||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Tnb.BasicData.Entities.Dto;
|
using Tnb.BasicData.Entities.Dto;
|
||||||
using NPOI.SS.Formula.Functions;
|
using NPOI.SS.Formula.Functions;
|
||||||
|
using Tnb.PerMgr.Entities;
|
||||||
|
|
||||||
|
// using Tnb.PerMgr.Entities;
|
||||||
|
|
||||||
namespace Tnb.ProductionMgr
|
namespace Tnb.ProductionMgr
|
||||||
{
|
{
|
||||||
@@ -515,7 +518,7 @@ namespace Tnb.ProductionMgr
|
|||||||
[HttpGet]
|
[HttpGet]
|
||||||
public async Task<dynamic> GetUnSchedulingList([FromQuery] VisualDevModelListQueryInput input)
|
public async Task<dynamic> GetUnSchedulingList([FromQuery] VisualDevModelListQueryInput input)
|
||||||
{
|
{
|
||||||
Dictionary<string, object> queryJson = input.queryJson!=null ? JsonConvert.DeserializeObject<Dictionary<string, object>>(input.queryJson) : null;
|
Dictionary<string, object> queryJson = !string.IsNullOrEmpty(input.queryJson) ? JsonConvert.DeserializeObject<Dictionary<string, object>>(input.queryJson) : new Dictionary<string, object>();
|
||||||
List<string> moStatusList = new List<string>();
|
List<string> moStatusList = new List<string>();
|
||||||
if (queryJson!=null && queryJson.ContainsKey("mo_stauts"))
|
if (queryJson!=null && queryJson.ContainsKey("mo_stauts"))
|
||||||
{
|
{
|
||||||
@@ -888,6 +891,7 @@ namespace Tnb.ProductionMgr
|
|||||||
if (subTaskList?.Count > 0)
|
if (subTaskList?.Count > 0)
|
||||||
{
|
{
|
||||||
List<PrdMoTask> subMoTasks = new();
|
List<PrdMoTask> subMoTasks = new();
|
||||||
|
List<PrdTaskLog> subMoTaskLogs = new();
|
||||||
foreach (var item in subTaskList)
|
foreach (var item in subTaskList)
|
||||||
{
|
{
|
||||||
PrdMoTask subMoTask = new();
|
PrdMoTask subMoTask = new();
|
||||||
@@ -909,6 +913,20 @@ namespace Tnb.ProductionMgr
|
|||||||
subMoTask.create_id = _userManager.UserId;
|
subMoTask.create_id = _userManager.UserId;
|
||||||
subMoTask.create_time = DateTime.Now;
|
subMoTask.create_time = DateTime.Now;
|
||||||
subMoTasks.Add(subMoTask);
|
subMoTasks.Add(subMoTask);
|
||||||
|
|
||||||
|
var subTaskLog = new PrdTaskLog();
|
||||||
|
var subMaterial = await _db.Queryable<BasMaterial>().SingleAsync(x => x.id == item.material_id);
|
||||||
|
subTaskLog.id = SnowflakeIdHelper.NextId();
|
||||||
|
subTaskLog.mo_code = (await _db.Queryable<PrdMo>().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())
|
if (moTask.mo_task_code!.IsNotEmptyOrNull())
|
||||||
@@ -920,6 +938,7 @@ namespace Tnb.ProductionMgr
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
row = await _db.Insertable(subMoTasks).ExecuteCommandAsync();
|
row = await _db.Insertable(subMoTasks).ExecuteCommandAsync();
|
||||||
|
await _db.Insertable(subMoTaskLogs).ExecuteCommandAsync();
|
||||||
}
|
}
|
||||||
await _db.Ado.CommitTranAsync();
|
await _db.Ado.CommitTranAsync();
|
||||||
}
|
}
|
||||||
@@ -1575,49 +1594,93 @@ namespace Tnb.ProductionMgr
|
|||||||
}
|
}
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
// private async Task<dynamic> 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<BasMaterial>().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<ToolMolds>().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<EqpEquipment>().FirstAsync(it => it.id == eqpId);
|
||||||
|
// if (eqp != null)
|
||||||
|
// {
|
||||||
|
// row["eqp_id"] = $"{eqp.code}/{eqp.name}";
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// return data!;
|
||||||
|
// }
|
||||||
|
|
||||||
private async Task<dynamic> GetList(VisualDevModelListQueryInput input)
|
private async Task<dynamic> GetList(VisualDevModelListQueryInput input)
|
||||||
{
|
{
|
||||||
var db = _repository.AsSugarClient();
|
var db = _repository.AsSugarClient();
|
||||||
VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleId, true);
|
Dictionary<string, string> queryJson = !string.IsNullOrEmpty(input.queryJson) ? JsonConvert.DeserializeObject<Dictionary<string, string>>(input.queryJson) : new Dictionary<string, string>();
|
||||||
var data = await _runService.GetListResult(templateEntity, input);
|
string moTaskCode = queryJson.ContainsKey("mo_task_code") ? queryJson["mo_task_code"].ToString() : "";
|
||||||
if (data?.list?.Count > 0)
|
string eqpId = queryJson.ContainsKey("eqp_id") ? queryJson["eqp_id"].ToString() : "";
|
||||||
|
List<string> worklineIds = new List<string>();
|
||||||
|
List<string> equipIds = new List<string>();
|
||||||
|
if (!string.IsNullOrEmpty(eqpId))
|
||||||
{
|
{
|
||||||
foreach (var row in data.list)
|
worklineIds = await db.Queryable<OrganizeEntity>().Where(x => x.ParentId == eqpId && x.Category==DictConst.RegionCategoryWorklineCode && x.DeleteMark==null).Select(x=>x.Id).ToListAsync();
|
||||||
{
|
equipIds = await db.Queryable<EqpEquipment>().Where(x => x.equip_type_id == eqpId).Select(x => x.id).ToListAsync();
|
||||||
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<BasMaterial>().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<ToolMolds>().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<EqpEquipment>().FirstAsync(it => it.id == eqpId);
|
|
||||||
if (eqp != null)
|
|
||||||
{
|
|
||||||
row["eqp_id"] = $"{eqp.code}/{eqp.name}";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return data!;
|
|
||||||
|
var result = await db.Queryable<PrdMoTask>()
|
||||||
|
.LeftJoin<BasMaterial>((a, b) => a.material_id == b.id)
|
||||||
|
.LeftJoin<DictionaryTypeEntity>((a, b, c) => c.EnCode == DictConst.TaskStatus)
|
||||||
|
.LeftJoin<DictionaryDataEntity>((a, b, c, d) => c.Id == d.DictionaryTypeId && a.mo_task_status == d.EnCode)
|
||||||
|
.LeftJoin<ToolMolds>((a,b,c,d,e)=>a.mold_id==e.id)
|
||||||
|
.LeftJoin<PrdMo>((a,b,c,d,e,f)=>a.mo_id==f.id)
|
||||||
|
.LeftJoin<OrganizeEntity>((a,b,c,d,e,f,g)=>a.workline_id==g.Id)
|
||||||
|
.LeftJoin<EqpEquipment>((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<WorkOrderAdjustmentListOutput>.SqlSugarPageResult(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -1651,5 +1714,39 @@ namespace Tnb.ProductionMgr
|
|||||||
{
|
{
|
||||||
return await _db.Queryable<PrdMoTask>().Where(it => it.eqp_id == eqpId && it.mo_task_status == DictConst.InProgressEnCode).ToListAsync();
|
return await _db.Queryable<PrdMoTask>().Where(it => it.eqp_id == eqpId && it.mo_task_status == DictConst.InProgressEnCode).ToListAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public async Task<dynamic> GetEstimatedEndTime(CountEstimatedEndTimeInput input)
|
||||||
|
{
|
||||||
|
var db = _repository.AsSugarClient();
|
||||||
|
if (input.type == 1)
|
||||||
|
{
|
||||||
|
PerProcessStandardsH processStandardsH = await db.Queryable<PerProcessStandardsH>()
|
||||||
|
.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<ToolMolds>().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<BasMbomProcess>()
|
||||||
|
.LeftJoin<BasStandardTime>((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");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
117
ProductionMgr/Tnb.ProductionMgr/PrdOutstockService.cs
Normal file
117
ProductionMgr/Tnb.ProductionMgr/PrdOutstockService.cs
Normal file
@@ -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
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 生产领料
|
||||||
|
/// </summary>
|
||||||
|
[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<PrdOutstockH> _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<PrdOutstockH> 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<dynamic> Create(VisualDevModelDataCrInput visualDevModelDataCrInput)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var db = _repository.AsSugarClient();
|
||||||
|
|
||||||
|
MESCreateOutstockInput input = new MESCreateOutstockInput();
|
||||||
|
input.outstock = new MESWmsOutstockHInput();
|
||||||
|
input.outstockDs = new List<MESWmsOutstockDInput>();
|
||||||
|
|
||||||
|
string locationId = visualDevModelDataCrInput.data.ContainsKey("location_id") ? visualDevModelDataCrInput.data["location_id"].ToString() : "";
|
||||||
|
BasLocation location = await db.Queryable<BasLocation>().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<string>("material_id"),
|
||||||
|
// material_code = item.Value<string>("material_code"),
|
||||||
|
// unit_id = item.Value<string>("unit_id"),
|
||||||
|
// pr_qty = item.Value<decimal>("pr_qty"),
|
||||||
|
// code_batch = item.Value<string>("code_batch"),
|
||||||
|
// source_id = item.Value<string>("source_id"),
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
|
||||||
|
input.outstockDs = JsonConvert.DeserializeObject<List<MESWmsOutstockDInput>>(JsonConvert.SerializeObject(visualDevModelDataCrInput.data["tablefield107"]));
|
||||||
|
string domain = (App.HttpContext.Request.IsHttps ? "https://" : "http://") + App.HttpContext.Request.Host;
|
||||||
|
Dictionary<string, object> header = new Dictionary<string, object>()
|
||||||
|
{
|
||||||
|
["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<AuthResponse>(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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -23,6 +23,7 @@ using Microsoft.AspNetCore.Mvc;
|
|||||||
using DbModels;
|
using DbModels;
|
||||||
using JNPF.Common.Extension;
|
using JNPF.Common.Extension;
|
||||||
using JNPF.Common.Filter;
|
using JNPF.Common.Filter;
|
||||||
|
using JNPF.Common.Security;
|
||||||
using Tnb.ProductionMgr.Entities.Dto.PrdManage;
|
using Tnb.ProductionMgr.Entities.Dto.PrdManage;
|
||||||
using NPOI.OpenXmlFormats;
|
using NPOI.OpenXmlFormats;
|
||||||
using JNPF.Systems.Entitys.Permission;
|
using JNPF.Systems.Entitys.Permission;
|
||||||
@@ -116,26 +117,31 @@ namespace Tnb.ProductionMgr
|
|||||||
private async Task<dynamic> GetList(VisualDevModelListQueryInput input)
|
private async Task<dynamic> GetList(VisualDevModelListQueryInput input)
|
||||||
{
|
{
|
||||||
var db = _repository.AsSugarClient();
|
var db = _repository.AsSugarClient();
|
||||||
Dictionary<string, object> queryJson = input.queryJson!=null ? JsonConvert.DeserializeObject<Dictionary<string, object>>(input.queryJson) : null;
|
Dictionary<string, object> queryJson = !string.IsNullOrEmpty(input.queryJson) ? JsonConvert.DeserializeObject<Dictionary<string, object>>(input.queryJson) : new Dictionary<string, object>();
|
||||||
string moTaskCode = queryJson!=null && queryJson.ContainsKey("mo_task_code") ? queryJson["mo_task_code"].ToString() : "";
|
string moTaskCode = queryJson!=null && queryJson.ContainsKey("mo_task_code") ? queryJson["mo_task_code"].ToString() : "";
|
||||||
Dictionary<string, string> dic = new Dictionary<string, string>()
|
Dictionary<string, object> dic = await _dictionaryDataService.GetDicByKey(DictConst.TaskStatus);
|
||||||
|
|
||||||
|
DateTime[] planStartDateArr = null;
|
||||||
|
DateTime[] planEndDateArr = null;
|
||||||
|
if (queryJson.TryGetValue("plan_start_date", out var value1))
|
||||||
{
|
{
|
||||||
[DictConst.ToBeStartedEnCode] = "待开工",
|
planStartDateArr = value1.ToObject<long[]>().Select(x=>x.TimeStampToDateTime()).ToArray();
|
||||||
[DictConst.InProgressEnCode] = "进行中",
|
}
|
||||||
[DictConst.ClosedEnCode] = "关闭",
|
if (queryJson.TryGetValue("plan_end_date", out var value2))
|
||||||
[DictConst.ComplatedEnCode] = "完工",
|
{
|
||||||
[DictConst.ToBeScheduledEncode] = "待排产",
|
planEndDateArr = value2.ToObject<long[]>().Select(x=>x.TimeStampToDateTime()).ToArray();
|
||||||
[DictConst.MoStatusPauseCode] = "暂停",
|
}
|
||||||
[DictConst.MoStatusExceptionCode] = "异常",
|
|
||||||
[DictConst.MoStatusRevokeCode] = "撤销",
|
|
||||||
};
|
|
||||||
var result = await db.Queryable<PrdMoTask>()
|
var result = await db.Queryable<PrdMoTask>()
|
||||||
.LeftJoin<EqpEquipment>((a, b) => a.eqp_id == b.id)
|
.LeftJoin<EqpEquipment>((a, b) => a.eqp_id == b.id)
|
||||||
.LeftJoin<BasMaterial>((a, b, c) => a.material_id == c.id)
|
.LeftJoin<BasMaterial>((a, b, c) => a.material_id == c.id)
|
||||||
.LeftJoin<ToolMolds>((a, b, c, d) => a.mold_id == d.id)
|
.LeftJoin<ToolMolds>((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)
|
.Where((a,b,c,d)=>a.schedule_type==1)
|
||||||
.WhereIF(!string.IsNullOrEmpty(moTaskCode),(a,b,c,d)=>a.mo_task_code.Contains(moTaskCode))
|
.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)
|
.OrderByDescending((a, b, c, d) => a.create_time)
|
||||||
.Select((a, b, c, d) => new PrdTaskManageListOutput()
|
.Select((a, b, c, d) => new PrdTaskManageListOutput()
|
||||||
{
|
{
|
||||||
@@ -152,7 +158,7 @@ namespace Tnb.ProductionMgr
|
|||||||
schedule_type = a.schedule_type.ToString()
|
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);
|
.ToPagedListAsync(input.currentPage, input.pageSize);
|
||||||
return PageResult<PrdTaskManageListOutput>.SqlSugarPageResult(result);
|
return PageResult<PrdTaskManageListOutput>.SqlSugarPageResult(result);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -126,7 +126,8 @@ namespace Tnb.ProductionMgr
|
|||||||
reported_qty = x.reported_qty,
|
reported_qty = x.reported_qty,
|
||||||
create_id = y.RealName,
|
create_id = y.RealName,
|
||||||
create_id_id = x.create_id,
|
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);
|
}).ToPagedListAsync(input.currentPage, input.pageSize);
|
||||||
return PageResult<ReportRecordListOutput>.SqlSugarPageResult(result);
|
return PageResult<ReportRecordListOutput>.SqlSugarPageResult(result);
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
<ProjectReference Include="..\..\BasicData\Tnb.BasicData.Interfaces\Tnb.BasicData.Interfaces.csproj" />
|
<ProjectReference Include="..\..\BasicData\Tnb.BasicData.Interfaces\Tnb.BasicData.Interfaces.csproj" />
|
||||||
<ProjectReference Include="..\..\EquipMgr\Tnb.EquipMgr.Interfaces\Tnb.EquipMgr.Interfaces.csproj" />
|
<ProjectReference Include="..\..\EquipMgr\Tnb.EquipMgr.Interfaces\Tnb.EquipMgr.Interfaces.csproj" />
|
||||||
<ProjectReference Include="..\..\message\Tnb.Message\Tnb.Message.csproj" />
|
<ProjectReference Include="..\..\message\Tnb.Message\Tnb.Message.csproj" />
|
||||||
|
<ProjectReference Include="..\..\PerMgr\Tnb.PerMgr.Entities\Tnb.PerMgr.Entities.csproj" />
|
||||||
<ProjectReference Include="..\..\taskschedule\Tnb.TaskScheduler\Tnb.TaskScheduler.csproj" />
|
<ProjectReference Include="..\..\taskschedule\Tnb.TaskScheduler\Tnb.TaskScheduler.csproj" />
|
||||||
<ProjectReference Include="..\..\visualdev\Tnb.VisualDev.Engine\Tnb.VisualDev.Engine.csproj" />
|
<ProjectReference Include="..\..\visualdev\Tnb.VisualDev.Engine\Tnb.VisualDev.Engine.csproj" />
|
||||||
<ProjectReference Include="..\..\WarehouseMgr\Tnb.WarehouseMgr.Entities\Tnb.WarehouseMgr.Entities.csproj" />
|
<ProjectReference Include="..\..\WarehouseMgr\Tnb.WarehouseMgr.Entities\Tnb.WarehouseMgr.Entities.csproj" />
|
||||||
|
|||||||
@@ -144,5 +144,13 @@ public class ModuleConsts
|
|||||||
/// 模块标识-空载具入库
|
/// 模块标识-空载具入库
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public const string MODULE_WMSEMPTYINSTOCK_ID = "26120915344165";
|
public const string MODULE_WMSEMPTYINSTOCK_ID = "26120915344165";
|
||||||
|
/// <summary>
|
||||||
|
/// 模块标识-预任务申请
|
||||||
|
/// </summary>
|
||||||
|
public const string MODULE_WMSPRETASK_ID = "26126898582309";
|
||||||
|
/// <summary>
|
||||||
|
/// 模块标识-任务执行
|
||||||
|
/// </summary>
|
||||||
|
public const string MODULE_WMSDISTASK_ID = "26128621455141";
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -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; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -49,11 +49,6 @@ public partial class WmsCarryunbindCode : BaseEntity<string>
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public decimal? codeqty { get; set; }
|
public decimal? codeqty { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 行号
|
|
||||||
/// </summary>
|
|
||||||
public int? no { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 子载具ID
|
/// 子载具ID
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -1,13 +1,14 @@
|
|||||||
using JNPF.Common.Contracts;
|
using JNPF.Common.Contracts;
|
||||||
using JNPF.Common.Security;
|
using JNPF.Common.Security;
|
||||||
using SqlSugar;
|
using SqlSugar;
|
||||||
|
using Tnb.WarehouseMgr.Entities.Entity;
|
||||||
|
|
||||||
namespace Tnb.WarehouseMgr.Entities;
|
namespace Tnb.WarehouseMgr.Entities;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 任务执行主表
|
/// 任务执行主表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class WmsDistaskH
|
public partial class WmsDistaskH : ITaskManagerDel
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 载具状态
|
/// 载具状态
|
||||||
|
|||||||
@@ -1,13 +1,14 @@
|
|||||||
using JNPF.Common.Contracts;
|
using JNPF.Common.Contracts;
|
||||||
using JNPF.Common.Security;
|
using JNPF.Common.Security;
|
||||||
using SqlSugar;
|
using SqlSugar;
|
||||||
|
using Tnb.WarehouseMgr.Entities.Entity;
|
||||||
|
|
||||||
namespace Tnb.WarehouseMgr.Entities;
|
namespace Tnb.WarehouseMgr.Entities;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 预任务申请主表
|
/// 预任务申请主表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class WmsPretaskH
|
public partial class WmsPretaskH : ITaskManagerDel
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 单次搬运数量
|
/// 单次搬运数量
|
||||||
|
|||||||
@@ -15,7 +15,9 @@ using JNPF.DynamicApiController;
|
|||||||
using JNPF.Systems.Interfaces.System;
|
using JNPF.Systems.Interfaces.System;
|
||||||
using JNPF.VisualDev;
|
using JNPF.VisualDev;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Newtonsoft.Json.Linq;
|
||||||
using SqlSugar;
|
using SqlSugar;
|
||||||
|
using Tnb.BasicData.Entities;
|
||||||
using Tnb.WarehouseMgr.Entities;
|
using Tnb.WarehouseMgr.Entities;
|
||||||
using Tnb.WarehouseMgr.Entities.Attributes;
|
using Tnb.WarehouseMgr.Entities.Attributes;
|
||||||
using Tnb.WarehouseMgr.Entities.Consts;
|
using Tnb.WarehouseMgr.Entities.Consts;
|
||||||
@@ -47,7 +49,27 @@ namespace Tnb.WarehouseMgr
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 判断最终目标库位是否可以放置当前载具
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="carry">当前载具</param>
|
||||||
|
/// <param name="locDest">目标库位</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
/// <exception cref="ArgumentNullException"></exception>
|
||||||
|
[NonAction]
|
||||||
|
protected Task<bool> 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<string>()).ToArray();
|
||||||
|
isMatch = locCarryStdArr.Contains(carry.carrystd_id);
|
||||||
|
}
|
||||||
|
return Task.FromResult(isMatch);
|
||||||
|
}
|
||||||
|
|
||||||
[NonAction]
|
[NonAction]
|
||||||
protected async Task DoUpdate(WareHouseUpInput input)
|
protected async Task DoUpdate(WareHouseUpInput input)
|
||||||
|
|||||||
56
WarehouseMgr/Tnb.WarehouseMgr/TaskManagerDelBase.cs
Normal file
56
WarehouseMgr/Tnb.WarehouseMgr/TaskManagerDelBase.cs
Normal file
@@ -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<T> : BaseWareHouseService where T : BaseEntity<string>, 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<T>().SingleAsync(it => it.id == id);
|
||||||
|
if (preTask != null)
|
||||||
|
{
|
||||||
|
var locIds = new[] { preTask.startlocation_id, preTask.endlocation_id };
|
||||||
|
var locs = await _db.Queryable<BasLocation>().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<WmsCarryH>().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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -488,6 +488,9 @@ namespace Tnb.WarehouseMgr
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 生成预任务
|
/// 生成预任务
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ namespace Tnb.WarehouseMgr
|
|||||||
{
|
{
|
||||||
WmsCarrybindCode wmsCarrybindCode = new();
|
WmsCarrybindCode wmsCarrybindCode = new();
|
||||||
wmsCarrybindCode.id = SnowflakeIdHelper.NextId();
|
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.carrybind_id = input.data["ReturnIdentity"]?.ToString()!;
|
||||||
wmsCarrybindCode.material_id = items[i].material_id;
|
wmsCarrybindCode.material_id = items[i].material_id;
|
||||||
wmsCarrybindCode.material_code = items[i].material_code;
|
wmsCarrybindCode.material_code = items[i].material_code;
|
||||||
|
|||||||
@@ -66,8 +66,6 @@ namespace Tnb.WarehouseMgr
|
|||||||
{
|
{
|
||||||
await _db.Ado.BeginTranAsync();
|
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 inStockStrategyInput = new InStockStrategyQuery { warehouse_id = input.data[nameof(InStockStrategyQuery.warehouse_id)].ToString()!, Size = 1 };
|
||||||
var endLocations = await _wareHouseService.InStockStrategy(inStockStrategyInput);
|
var endLocations = await _wareHouseService.InStockStrategy(inStockStrategyInput);
|
||||||
@@ -79,9 +77,18 @@ namespace Tnb.WarehouseMgr
|
|||||||
}
|
}
|
||||||
if (endLocations?.Count > 0)
|
if (endLocations?.Count > 0)
|
||||||
{
|
{
|
||||||
|
var carry = await _db.Queryable<WmsCarryH>().SingleAsync(it => it.id == input.data[nameof(WmsCarryD.carry_id)].ToString());
|
||||||
|
var loc = await _db.Queryable<BasLocation>().SingleAsync(it => it.id == endLocations[0].id);
|
||||||
|
var isMatch = await IsCarryAndLocationMatchByCarryStd(carry, loc);
|
||||||
|
if (!isMatch) throw new AppFriendlyException("库位与载具规格不匹配", 500);
|
||||||
ePoint = await _db.Queryable<WmsPointH>().FirstAsync(it => it.location_id == endLocations[0].id);
|
ePoint = await _db.Queryable<WmsPointH>().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)
|
if (sPoint != null && ePoint != null)
|
||||||
{
|
{
|
||||||
var points = await _wareHouseService.PathAlgorithms(sPoint.id, ePoint.id);
|
var points = await _wareHouseService.PathAlgorithms(sPoint.id, ePoint.id);
|
||||||
|
|||||||
@@ -63,11 +63,17 @@ namespace Tnb.WarehouseMgr
|
|||||||
{
|
{
|
||||||
await _db.Ado.BeginTranAsync();
|
await _db.Ado.BeginTranAsync();
|
||||||
|
|
||||||
|
//判断目标库位是否自动签收
|
||||||
|
var loc = await _db.Queryable<BasLocation>().SingleAsync(it => it.id == input.data[nameof(WmsPointH.location_id)].ToString());
|
||||||
|
var carry = await _db.Queryable<WmsCarryH>().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);
|
VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleConsts.MODULE_WMSCARRYMOOUTSTK_ID, true);
|
||||||
await _runService.Create(templateEntity, input);
|
await _runService.Create(templateEntity, input);
|
||||||
//入库取终点
|
//入库取终点
|
||||||
//var OutStockStrategyInput = new OutStockStrategyQuery { carry_id = input.data[nameof(OutStockStrategyQuery.carry_id)].ToString(), Size = 1 };
|
//var OutStockStrategyInput = new OutStockStrategyQuery { carry_id = input.data[nameof(OutStockStrategyQuery.carry_id)].ToString(), Size = 1 };
|
||||||
var carry = await _db.Queryable<WmsCarryH>().FirstAsync(it => it.id == input.data[nameof(WmsMoveOutstock.carry_id)].ToString());
|
|
||||||
WmsPointH? sPoint = null;
|
WmsPointH? sPoint = null;
|
||||||
WmsPointH? ePoint = null;
|
WmsPointH? ePoint = null;
|
||||||
if (input.data.ContainsKey(nameof(WmsPointH.location_id)))
|
if (input.data.ContainsKey(nameof(WmsPointH.location_id)))
|
||||||
@@ -113,8 +119,6 @@ namespace Tnb.WarehouseMgr
|
|||||||
preTask.create_time = DateTime.Now;
|
preTask.create_time = DateTime.Now;
|
||||||
return preTask;
|
return preTask;
|
||||||
}).ToList();
|
}).ToList();
|
||||||
//判断目标库位是否自动签收
|
|
||||||
var loc = await _db.Queryable<BasLocation>().SingleAsync(it => it.id == input.data[nameof(WmsPointH.location_id)].ToString());
|
|
||||||
if (loc.is_sign ==0 ) {
|
if (loc.is_sign ==0 ) {
|
||||||
preTasks[^1].is_sign = 0; // 修改最后一个元素的是否签收值
|
preTasks[^1].is_sign = 0; // 修改最后一个元素的是否签收值
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ namespace Tnb.WarehouseMgr
|
|||||||
data.wmsCarryCodes = carryCodes.Adapt<List<CarryCodeQueryOutput>>();
|
data.wmsCarryCodes = carryCodes.Adapt<List<CarryCodeQueryOutput>>();
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
await _db.Ado.RollbackTranAsync();
|
await _db.Ado.RollbackTranAsync();
|
||||||
//return await ToApiResult(JNPF.Common.Enums.HttpStatusCode.InternalServerError, ex.Message);
|
//return await ToApiResult(JNPF.Common.Enums.HttpStatusCode.InternalServerError, ex.Message);
|
||||||
|
|||||||
@@ -172,18 +172,19 @@ namespace Tnb.WarehouseMgr
|
|||||||
carryObj.collocation_scheme_code = null;
|
carryObj.collocation_scheme_code = null;
|
||||||
carryObj.source_id = null;
|
carryObj.source_id = null;
|
||||||
carryObj.source_code = null;
|
carryObj.source_code = null;
|
||||||
row = await _db.Updateable(carryObj).ExecuteCommandAsync();
|
row = await _db.CopyNew().Updateable(carryObj).ExecuteCommandAsync();
|
||||||
//删除对应明细表
|
//删除对应明细表
|
||||||
//删除载具明细
|
//删除载具明细
|
||||||
await _db.Deleteable<WmsCarryD>().Where(it => it.carry_id == carryObj.id).ExecuteCommandHasChangeAsync();
|
await _db.CopyNew().Deleteable<WmsCarryD>().Where(it => it.carry_id == carryObj.id).ExecuteCommandHasChangeAsync();
|
||||||
//删除载具分拣物料明细
|
//删除载具分拣物料明细
|
||||||
await _db.Deleteable<WmsCarryMat>().Where(it => it.carry_id == carryObj.id).ExecuteCommandHasChangeAsync();
|
await _db.CopyNew().Deleteable<WmsCarryMat>().Where(it => it.carry_id == carryObj.id).ExecuteCommandHasChangeAsync();
|
||||||
//删除载具条码
|
//删除载具条码
|
||||||
await _db.Deleteable<WmsCarryCode>().Where(it => it.carry_id == carryObj.id).ExecuteCommandHasChangeAsync();
|
await _db.CopyNew().Deleteable<WmsCarryCode>().Where(it => it.carry_id == carryObj.id).ExecuteCommandHasChangeAsync();
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
Log.Error("更新空载具出错",ex);
|
||||||
|
throw;
|
||||||
}
|
}
|
||||||
return row;
|
return row;
|
||||||
}
|
}
|
||||||
|
|||||||
52
WarehouseMgr/Tnb.WarehouseMgr/WmsDistaskService.cs
Normal file
52
WarehouseMgr/Tnb.WarehouseMgr/WmsDistaskService.cs
Normal file
@@ -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<WmsDistaskH> repository)
|
||||||
|
{
|
||||||
|
_db = repository.AsSugarClient();
|
||||||
|
OverideFuncs.DeleteAsync = Delete;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task Delete(string id)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await _db.Ado.BeginTranAsync();
|
||||||
|
|
||||||
|
var disTask = await _db.Queryable<WmsDistaskH>().SingleAsync(it => it.id == id);
|
||||||
|
if (disTask != null)
|
||||||
|
{
|
||||||
|
var preTask = await _db.Queryable<WmsPretaskH>().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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -68,8 +68,6 @@ namespace Tnb.WarehouseMgr
|
|||||||
{
|
{
|
||||||
await _db.Ado.BeginTranAsync();
|
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 inStockStrategyInput = new InStockStrategyQuery { warehouse_id = input.data[nameof(InStockStrategyQuery.warehouse_id)].ToString()!, Size = 1 };
|
||||||
var endLocations = await _wareHouseService.InStockStrategy(inStockStrategyInput);
|
var endLocations = await _wareHouseService.InStockStrategy(inStockStrategyInput);
|
||||||
@@ -81,9 +79,17 @@ namespace Tnb.WarehouseMgr
|
|||||||
}
|
}
|
||||||
if (endLocations?.Count > 0)
|
if (endLocations?.Count > 0)
|
||||||
{
|
{
|
||||||
|
var carry = await _db.Queryable<WmsCarryH>().SingleAsync(it => it.id == input.data[nameof(WmsCarryD.carry_id)].ToString());
|
||||||
|
var loc = await _db.Queryable<BasLocation>().SingleAsync(it => it.id == endLocations[0].id);
|
||||||
|
var isMatch = await IsCarryAndLocationMatchByCarryStd(carry, loc);
|
||||||
|
if (!isMatch) throw new AppFriendlyException("库位与载具规格不匹配", 500);
|
||||||
ePoint = await _db.Queryable<WmsPointH>().FirstAsync(it => it.location_id == endLocations[0].id);
|
ePoint = await _db.Queryable<WmsPointH>().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)
|
if (sPoint != null && ePoint != null)
|
||||||
{
|
{
|
||||||
var points = await _wareHouseService.PathAlgorithms(sPoint.id, ePoint.id);
|
var points = await _wareHouseService.PathAlgorithms(sPoint.id, ePoint.id);
|
||||||
@@ -180,19 +186,19 @@ namespace Tnb.WarehouseMgr
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
var carry = await _db.Queryable<WmsCarryH>().SingleAsync(it => it.carry_code == input.carry_code);
|
var carry = await _db.Queryable<WmsCarryH>().SingleAsync(it => it.carry_code == input.carry_code);
|
||||||
var location = await _db.Queryable<BasLocation>().SingleAsync(it => it.location_code == input.location_code);
|
var loc = await _db.Queryable<BasLocation>().SingleAsync(it => it.location_code == input.location_code);
|
||||||
var emptyInstock = await _db.Queryable<WmsEmptyInstock>().FirstAsync(it => it.carry_code == input.carry_code && it.status == WmsWareHouseConst.BILLSTATUS_ADD_ID);
|
var emptyInstock = await _db.Queryable<WmsEmptyInstock>().FirstAsync(it => it.carry_code == input.carry_code && it.status == WmsWareHouseConst.BILLSTATUS_ADD_ID);
|
||||||
if (emptyInstock != null)
|
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<string>();
|
var cols = new List<string>();
|
||||||
var dic = new Dictionary<string, object>();
|
var dic = new Dictionary<string, object>();
|
||||||
dic[nameof(WmsEmptyInstock.id)] = SnowflakeIdHelper.NextId();
|
dic[nameof(WmsEmptyInstock.id)] = SnowflakeIdHelper.NextId();
|
||||||
dic[nameof(WmsEmptyInstock.org_id)] = input.org_id ?? _userManager.User.OrganizeId;
|
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.bill_code)] = await _billRullService.GetBillNumber(WmsWareHouseConst.WMS_EMPTYINSTK_ENCODE);
|
||||||
dic[nameof(WmsEmptyInstock.status)] = WmsWareHouseConst.BILLSTATUS_ADD_ID;
|
dic[nameof(WmsEmptyInstock.status)] = WmsWareHouseConst.BILLSTATUS_ADD_ID;
|
||||||
dic[nameof(WmsEmptyInstock.carry_id)] = carry.id;
|
dic[nameof(WmsEmptyInstock.carry_id)] = carry.id;
|
||||||
|
|||||||
@@ -58,20 +58,19 @@ namespace Tnb.WarehouseMgr
|
|||||||
_wareHouseService = wareHouseService;
|
_wareHouseService = wareHouseService;
|
||||||
_userManager = userManager;
|
_userManager = userManager;
|
||||||
_billRullService = billRullService;
|
_billRullService = billRullService;
|
||||||
OverideFuncs.CreateAsync = PDAWmsEmptyOut;
|
OverideFuncs.CreateAsync = WmsEmptyOut;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private async Task<dynamic> PDAWmsEmptyOut(VisualDevModelDataCrInput input)
|
private async Task<dynamic> WmsEmptyOut(VisualDevModelDataCrInput input)
|
||||||
{
|
{
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await _db.Ado.BeginTranAsync();
|
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 };
|
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())
|
&& a.carry_status == ((int)EnumCarryStatus.空闲).ToString() && a.is_lock == 0 && b.is_lock == 0 && b.is_type == ((int)EnumLocationType.存储库位).ToString())
|
||||||
.ToListAsync();
|
.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? sPoint = null;
|
||||||
WmsPointH? ePoint = null;
|
WmsPointH? ePoint = null;
|
||||||
if (input.data.ContainsKey(nameof(WmsPointH.location_id)))
|
if (input.data.ContainsKey(nameof(WmsPointH.location_id)))
|
||||||
@@ -92,90 +102,98 @@ namespace Tnb.WarehouseMgr
|
|||||||
ePoint = await _db.Queryable<WmsPointH>().FirstAsync(it => it.location_id == input.data[nameof(WmsPointH.location_id)].ToString() && it.is_lock == 0);
|
ePoint = await _db.Queryable<WmsPointH>().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<WmsPointH>().FirstAsync(it => it.location_id == carrys[i].location_id);
|
sPoint = await _db.Queryable<WmsPointH>().FirstAsync(it => it.location_id == carrys[i].location_id);
|
||||||
}
|
|
||||||
var isOk = false;
|
var isOk = false;
|
||||||
if (sPoint != null && ePoint != null)
|
if (sPoint != null && ePoint != null)
|
||||||
{
|
{
|
||||||
var points = await _wareHouseService.PathAlgorithms(sPoint.id, ePoint.id);
|
var points = await _wareHouseService.PathAlgorithms(sPoint.id, ePoint.id);
|
||||||
if (points.Count <= 2) throw new AppFriendlyException("该路径不存在", 500);
|
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<WmsEmptyOutstockH>().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
|
else
|
||||||
{
|
{
|
||||||
var preTasks = points.Where(it => !it.location_id.IsNullOrEmpty()).GroupBy(g => g.area_code).Select(it =>
|
throw new AppFriendlyException("无可出库的空载具或目标库位不存在或者目标库位被锁", 500);
|
||||||
{
|
|
||||||
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<WmsEmptyOutstockH>().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
|
|
||||||
{
|
|
||||||
throw new AppFriendlyException("无可出库的空载具或目标库位不存在或者目标库位被锁", 500);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
await _db.Ado.CommitTranAsync();
|
await _db.Ado.CommitTranAsync();
|
||||||
@@ -226,24 +244,26 @@ namespace Tnb.WarehouseMgr
|
|||||||
if (input.IsNull()) throw new ArgumentNullException("input");
|
if (input.IsNull()) throw new ArgumentNullException("input");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var location = await _db.Queryable<BasLocation>().SingleAsync(it => it.location_code == input.location_code);
|
var location = await _db.Queryable<BasLocation>().SingleAsync(it => it.location_code == input.location_code && it.is_type != EnumLocationType.存储库位.ToString()) ?? throw new AppFriendlyException("无此库位或为存储库位", 500);
|
||||||
var dic = new Dictionary<string, object>();
|
Dictionary<string, object> dic = new()
|
||||||
dic[nameof(WmsEmptyOutstockH.id)] = SnowflakeIdHelper.NextId();
|
{
|
||||||
dic[nameof(WmsEmptyOutstockH.org_id)] = input.org_id;
|
[nameof(WmsEmptyOutstockH.id)] = SnowflakeIdHelper.NextId(),
|
||||||
dic[nameof(WmsEmptyOutstockH.location_id)] = location.id;
|
[nameof(WmsEmptyOutstockH.org_id)] = input.org_id,
|
||||||
dic[nameof(WmsEmptyOutstockH.carrystd_id)] = input.carrystd_id;
|
[nameof(WmsEmptyOutstockH.location_id)] = location.id,
|
||||||
dic[nameof(WmsEmptyOutstockH.bill_code)] = _billRullService.GetBillNumber(WmsWareHouseConst.WMS_EMPTYOUTSTK_ENCODE).GetAwaiter().GetResult();
|
[nameof(WmsEmptyOutstockH.carrystd_id)] = input.carrystd_id,
|
||||||
dic[nameof(WmsEmptyOutstockH.status)] = WmsWareHouseConst.BILLSTATUS_ADD_ID;
|
[nameof(WmsEmptyOutstockH.bill_code)] = _billRullService.GetBillNumber(WmsWareHouseConst.WMS_EMPTYOUTSTK_ENCODE).GetAwaiter().GetResult(),
|
||||||
dic[nameof(WmsEmptyOutstockH.qty)] = input.qty;
|
[nameof(WmsEmptyOutstockH.status)] = WmsWareHouseConst.BILLSTATUS_ADD_ID,
|
||||||
dic[nameof(WmsEmptyOutstockH.biz_type)] = WmsWareHouseConst.BIZTYPE_WMSEPTYOUTSTK_ID;
|
[nameof(WmsEmptyOutstockH.qty)] = input.qty,
|
||||||
dic[nameof(WmsEmptyOutstockH.create_id)] = input.create_id;
|
[nameof(WmsEmptyOutstockH.biz_type)] = WmsWareHouseConst.BIZTYPE_WMSEPTYOUTSTK_ID,
|
||||||
dic[nameof(WmsEmptyOutstockH.create_time)] = DateTime.Now;
|
[nameof(WmsEmptyOutstockH.create_id)] = input.create_id,
|
||||||
|
[nameof(WmsEmptyOutstockH.create_time)] = DateTime.Now
|
||||||
|
};
|
||||||
|
|
||||||
VisualDevModelDataCrInput visualDevModelDataCrInput = new VisualDevModelDataCrInput
|
VisualDevModelDataCrInput visualDevModelDataCrInput = new VisualDevModelDataCrInput
|
||||||
{
|
{
|
||||||
data = dic,
|
data = dic,
|
||||||
};
|
};
|
||||||
await PDAWmsEmptyOut(visualDevModelDataCrInput);
|
await WmsEmptyOut(visualDevModelDataCrInput);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -221,12 +221,12 @@ namespace Tnb.WarehouseMgr
|
|||||||
await _db.Updateable(instockDetails).ExecuteCommandAsync();
|
await _db.Updateable(instockDetails).ExecuteCommandAsync();
|
||||||
var instock = await _db.Queryable<WmsInstockH>().SingleAsync(it => it.id == input.requireId);
|
var instock = await _db.Queryable<WmsInstockH>().SingleAsync(it => it.id == input.requireId);
|
||||||
if (instock.IsNull()) ArgumentNullException.ThrowIfNull(nameof(instock));
|
if (instock.IsNull()) ArgumentNullException.ThrowIfNull(nameof(instock));
|
||||||
if (instock?.sync_status != WmsWareHouseConst.SYNC_STATUS_NONEEDSYNC)
|
if (instock.sync_status != WmsWareHouseConst.SYNC_STATUS_NONEEDSYNC)
|
||||||
{
|
{
|
||||||
//如果是自动单据,需要回更上层系统
|
//如果是自动单据,需要回更上层系统
|
||||||
Dictionary<string, string> pars = new() { { nameof(WmsInstockH.source_id), instock!.source_id } };
|
Dictionary<string, string> pars = new() { { nameof(WmsInstockH.source_id), instock?.source_id ?? string.Empty } };
|
||||||
var callBackRes = await _prdInstockService.SyncInstock(pars);
|
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();
|
await _db.Updateable(instock).UpdateColumns(it => it.sync_status).ExecuteCommandAsync();
|
||||||
}
|
}
|
||||||
var allInstockDetails = await _db.Queryable<WmsInstockD>().Where(it => it.bill_id == input.requireId).ToListAsync();
|
var allInstockDetails = await _db.Queryable<WmsInstockD>().Where(it => it.bill_id == input.requireId).ToListAsync();
|
||||||
@@ -270,13 +270,24 @@ namespace Tnb.WarehouseMgr
|
|||||||
//入库申请条码明细表
|
//入库申请条码明细表
|
||||||
List<WmsInstockCode> instockcodes = input.instockcodes.Adapt<List<WmsInstockCode>>();
|
List<WmsInstockCode> instockcodes = input.instockcodes.Adapt<List<WmsInstockCode>>();
|
||||||
|
|
||||||
var loc = await _db.Queryable<BasLocation>().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<WmsPointH>().FirstAsync(it => it.location_code == input.instock.location_code);
|
||||||
|
WmsPointH ePoint = await _db.Queryable<WmsPointH>().FirstAsync(it => it.location_id == endLocations[0].id);
|
||||||
|
|
||||||
var carry = await _db.Queryable<WmsCarryH>().SingleAsync(it => it.carry_code == input.instock.carry_code);
|
var carry = await _db.Queryable<WmsCarryH>().SingleAsync(it => it.carry_code == input.instock.carry_code);
|
||||||
//如果数据不全,
|
var loc = await _db.Queryable<BasLocation>().FirstAsync(it => it.id == endLocations[0].id);
|
||||||
|
var isMatch = await IsCarryAndLocationMatchByCarryStd(carry, loc);
|
||||||
|
if (!isMatch) throw new AppFriendlyException("库位与载具规格不匹配", 500);
|
||||||
|
|
||||||
|
loc = await _db.Queryable<BasLocation>().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)
|
if (carry.IsNull() || loc.IsNull() || instockds?.Count < 1 || instockcodes?.Count < 1)
|
||||||
{
|
{
|
||||||
//报错, 提示数据不全。
|
//报错, 提示数据不全或有误。
|
||||||
throw new AppFriendlyException("数据不全!", 500);
|
throw new AppFriendlyException("数据不全或有误!", 500);
|
||||||
}
|
}
|
||||||
// 生成入库申请数据,添加其他数据 主表
|
// 生成入库申请数据,添加其他数据 主表
|
||||||
instock.id = SnowflakeIdHelper.NextId();
|
instock.id = SnowflakeIdHelper.NextId();
|
||||||
@@ -327,12 +338,6 @@ namespace Tnb.WarehouseMgr
|
|||||||
await _db.Insertable(instockCOdes).CallEntityMethod(it => it.Create(orgId)).ExecuteCommandAsync();
|
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<WmsPointH>().FirstAsync(it => it.location_id == instock.location_id);
|
|
||||||
WmsPointH ePoint = await _db.Queryable<WmsPointH>().FirstAsync(it => it.location_id == endLocations[0].id);
|
|
||||||
|
|
||||||
|
|
||||||
if (sPoint != null && ePoint != null)
|
if (sPoint != null && ePoint != null)
|
||||||
{
|
{
|
||||||
@@ -346,26 +351,28 @@ namespace Tnb.WarehouseMgr
|
|||||||
var sPoint = it.FirstOrDefault();
|
var sPoint = it.FirstOrDefault();
|
||||||
var ePoint = it.LastOrDefault();
|
var ePoint = it.LastOrDefault();
|
||||||
|
|
||||||
WmsPretaskH preTask = new();
|
WmsPretaskH preTask = new()
|
||||||
preTask.org_id = _userManager.User.OrganizeId;
|
{
|
||||||
preTask.startlocation_id = sPoint?.location_id!;
|
org_id = _userManager.User.OrganizeId,
|
||||||
preTask.startlocation_code = sPoint?.location_code!;
|
startlocation_id = sPoint?.location_id ?? string.Empty,
|
||||||
preTask.endlocation_id = ePoint?.location_id!;
|
startlocation_code = sPoint?.location_code ?? string.Empty,
|
||||||
preTask.endlocation_code = ePoint?.location_code!;
|
endlocation_id = ePoint?.location_id ?? string.Empty,
|
||||||
preTask.start_floor = sPoint?.floor.ToString();
|
endlocation_code = ePoint?.location_code ?? string.Empty,
|
||||||
preTask.end_floor = ePoint?.floor.ToString();
|
start_floor = sPoint?.floor.ToString(),
|
||||||
preTask.bill_code = _billRullService.GetBillNumber(WmsWareHouseConst.WMS_PRETASK_H_ENCODE).GetAwaiter().GetResult();
|
end_floor = ePoint?.floor.ToString(),
|
||||||
preTask.status = WmsWareHouseConst.PRETASK_BILL_STATUS_DXF_ID;
|
bill_code = _billRullService.GetBillNumber(WmsWareHouseConst.WMS_PRETASK_H_ENCODE).GetAwaiter().GetResult(),
|
||||||
preTask.biz_type = instock.biz_type;
|
status = WmsWareHouseConst.PRETASK_BILL_STATUS_DXF_ID,
|
||||||
preTask.task_type = WmsWareHouseConst.WMS_PRETASK_INSTOCK_TYPE_ID;
|
biz_type = instock?.biz_type ?? string.Empty,
|
||||||
preTask.carry_id = instock.carry_id!;
|
task_type = WmsWareHouseConst.WMS_PRETASK_INSTOCK_TYPE_ID,
|
||||||
preTask.carry_code = instock.carry_code!;
|
carry_id = instock?.carry_id ?? string.Empty,
|
||||||
preTask.area_id = sPoint?.area_id!;
|
carry_code = instock?.carry_code ?? string.Empty,
|
||||||
preTask.area_code = it.Key;
|
area_id = sPoint?.area_id ?? string.Empty,
|
||||||
preTask.require_id = instock.id;
|
area_code = it.Key,
|
||||||
preTask.require_code = instock.bill_code;
|
require_id = instock?.id ?? string.Empty,
|
||||||
preTask.create_id = _userManager.UserId;
|
require_code = instock?.bill_code ?? string.Empty,
|
||||||
preTask.create_time = DateTime.Now;
|
create_id = _userManager.UserId,
|
||||||
|
create_time = DateTime.Now
|
||||||
|
};
|
||||||
return preTask;
|
return preTask;
|
||||||
}).ToList();
|
}).ToList();
|
||||||
//生成预任务条码信息
|
//生成预任务条码信息
|
||||||
@@ -395,12 +402,14 @@ namespace Tnb.WarehouseMgr
|
|||||||
if (isOk)
|
if (isOk)
|
||||||
{
|
{
|
||||||
|
|
||||||
var preTaskUpInput = new GenPreTaskUpInput();
|
GenPreTaskUpInput preTaskUpInput = new()
|
||||||
preTaskUpInput.RquireId = instock?.id;
|
{
|
||||||
preTaskUpInput.CarryId = instock?.carry_id!;
|
RquireId = instock?.id,
|
||||||
preTaskUpInput.CarryStartLocationId = points.FirstOrDefault()?.location_id;
|
CarryId = instock?.carry_id!,
|
||||||
preTaskUpInput.CarryStartLocationCode = points.FirstOrDefault()?.location_code;
|
CarryStartLocationId = points.FirstOrDefault()?.location_id,
|
||||||
preTaskUpInput.LocationIds = (points?.Select(x => x.location_id)?.ToList() ?? Enumerable.Empty<string?>().ToList()) as List<string>;
|
CarryStartLocationCode = points.FirstOrDefault()?.location_code,
|
||||||
|
LocationIds = (points?.Select(x => x.location_id)?.ToList() ?? Enumerable.Empty<string?>().ToList()) as List<string>
|
||||||
|
};
|
||||||
|
|
||||||
//创建预任务操作记录
|
//创建预任务操作记录
|
||||||
var operBillId = string.Empty;
|
var operBillId = string.Empty;
|
||||||
|
|||||||
@@ -67,8 +67,6 @@ namespace Tnb.WarehouseMgr
|
|||||||
{
|
{
|
||||||
await _db.Ado.BeginTranAsync();
|
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 inStockStrategyInput = new InStockStrategyQuery { warehouse_id = input.data[nameof(InStockStrategyQuery.warehouse_id)].ToString()!, Size = 1 };
|
||||||
var endLocations = await _wareHouseService.InStockStrategy(inStockStrategyInput);
|
var endLocations = await _wareHouseService.InStockStrategy(inStockStrategyInput);
|
||||||
@@ -80,9 +78,16 @@ namespace Tnb.WarehouseMgr
|
|||||||
}
|
}
|
||||||
if (endLocations?.Count > 0)
|
if (endLocations?.Count > 0)
|
||||||
{
|
{
|
||||||
|
var carry = await _db.Queryable<WmsCarryH>().SingleAsync(it => it.id == input.data[nameof(WmsCarryD.carry_id)].ToString());
|
||||||
|
var loc = await _db.Queryable<BasLocation>().SingleAsync(it => it.id == endLocations[0].id);
|
||||||
|
var isMatch = await IsCarryAndLocationMatchByCarryStd(carry, loc);
|
||||||
|
if (!isMatch) throw new AppFriendlyException("库位与载具规格不匹配", 500);
|
||||||
ePoint = await _db.Queryable<WmsPointH>().FirstAsync(it => it.location_id == endLocations[0].id);
|
ePoint = await _db.Queryable<WmsPointH>().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)
|
if (sPoint != null && ePoint != null)
|
||||||
{
|
{
|
||||||
var points = await _wareHouseService.PathAlgorithms(sPoint.id, ePoint.id);
|
var points = await _wareHouseService.PathAlgorithms(sPoint.id, ePoint.id);
|
||||||
|
|||||||
@@ -66,11 +66,15 @@ namespace Tnb.WarehouseMgr
|
|||||||
{
|
{
|
||||||
await _db.Ado.BeginTranAsync();
|
await _db.Ado.BeginTranAsync();
|
||||||
|
|
||||||
|
var carry = await _db.Queryable<WmsCarryH>().FirstAsync(it => it.id == input.data[nameof(WmsOutbale.carry_id)].ToString());
|
||||||
|
var loc = await _db.Queryable<BasLocation>().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);
|
VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleConsts.MODULE_WMSOUTBALE_ID, true);
|
||||||
await _runService.Create(templateEntity, input);
|
await _runService.Create(templateEntity, input);
|
||||||
//入库取终点
|
//入库取终点
|
||||||
//var OutStockStrategyInput = new OutStockStrategyQuery { carry_id = input.data[nameof(OutStockStrategyQuery.carry_id)].ToString(), Size = 1 };
|
//var OutStockStrategyInput = new OutStockStrategyQuery { carry_id = input.data[nameof(OutStockStrategyQuery.carry_id)].ToString(), Size = 1 };
|
||||||
var carry = await _db.Queryable<WmsCarryH>().FirstAsync(it => it.id == input.data[nameof(WmsOutbale.carry_id)].ToString());
|
|
||||||
WmsPointH? sPoint = null;
|
WmsPointH? sPoint = null;
|
||||||
WmsPointH? ePoint = null;
|
WmsPointH? ePoint = null;
|
||||||
if (input.data.ContainsKey(nameof(WmsPointH.location_id)))
|
if (input.data.ContainsKey(nameof(WmsPointH.location_id)))
|
||||||
@@ -117,7 +121,7 @@ namespace Tnb.WarehouseMgr
|
|||||||
return preTask;
|
return preTask;
|
||||||
}).ToList();
|
}).ToList();
|
||||||
//判断目标库位是否自动签收
|
//判断目标库位是否自动签收
|
||||||
var loc = await _db.Queryable<BasLocation>().SingleAsync(it => it.id == input.data[nameof(WmsPointH.location_id)].ToString());
|
|
||||||
if (loc.is_sign == 0)
|
if (loc.is_sign == 0)
|
||||||
{
|
{
|
||||||
preTasks[^1].is_sign = 0; // 修改最后一个元素的是否签收值
|
preTasks[^1].is_sign = 0; // 修改最后一个元素的是否签收值
|
||||||
|
|||||||
@@ -78,13 +78,13 @@ namespace Tnb.WarehouseMgr
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
await _db.Ado.BeginTranAsync();
|
await _db.Ado.BeginTranAsync();
|
||||||
|
|
||||||
VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleConsts.MODULE_WMSOUTSTOCK_ID, true);
|
|
||||||
await _runService.Create(templateEntity, input);
|
|
||||||
|
|
||||||
//判断目标库位是否自动签收
|
//判断目标库位是否自动签收
|
||||||
var loc = await _db.Queryable<BasLocation>().SingleAsync(it => it.id == input.data[nameof(WmsPointH.location_id)].ToString());
|
var loc = await _db.Queryable<BasLocation>().SingleAsync(it => it.id == input.data[nameof(WmsPointH.location_id)].ToString());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var carryIds = new List<string>();
|
var carryIds = new List<string>();
|
||||||
//tablefield120 出库物料明细
|
//tablefield120 出库物料明细
|
||||||
if (input.data.ContainsKey("tablefield120") && input.data["tablefield120"].IsNotEmptyOrNull())
|
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 })
|
carryMats = carryMats.OrderBy(o => o.create_time).GroupBy(g => new { g.carry_id, g.material_id, g.code_batch })
|
||||||
.Select(x =>
|
.Select(x =>
|
||||||
{
|
{
|
||||||
WmsCarryMat carryMat = new();
|
var arr = x.ToArray();
|
||||||
|
WmsCarryMat carryMat = arr[^arr.Length];
|
||||||
carryMat.need_qty = x.Sum(d => d.need_qty);
|
carryMat.need_qty = x.Sum(d => d.need_qty);
|
||||||
return carryMat;
|
return carryMat;
|
||||||
})
|
})
|
||||||
@@ -178,9 +179,19 @@ namespace Tnb.WarehouseMgr
|
|||||||
await _db.Updateable<WmsCarryH>().SetColumns(it => new WmsCarryH { out_status = ((int)EnumOutStatus.全部出).ToString() }).Where(it => allOutIds.Contains(it.id)).ExecuteCommandAsync();
|
await _db.Updateable<WmsCarryH>().SetColumns(it => new WmsCarryH { out_status = ((int)EnumOutStatus.全部出).ToString() }).Where(it => allOutIds.Contains(it.id)).ExecuteCommandAsync();
|
||||||
await _db.Updateable<WmsCarryH>().SetColumns(it => new WmsCarryH { out_status = ((int)EnumOutStatus.分拣出).ToString() }).Where(it => sortingOutIds.Contains(it.id)).ExecuteCommandAsync();
|
await _db.Updateable<WmsCarryH>().SetColumns(it => new WmsCarryH { out_status = ((int)EnumOutStatus.分拣出).ToString() }).Where(it => sortingOutIds.Contains(it.id)).ExecuteCommandAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var carrys = await _db.Queryable<WmsCarryH>().Where(it => carryIds.Contains(it.id)).ToListAsync();
|
var carrys = await _db.Queryable<WmsCarryH>().Where(it => carryIds.Contains(it.id)).ToListAsync();
|
||||||
if (carrys?.Count > 0)
|
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<WmsPretaskH> preTasks = new();
|
List<WmsPretaskH> preTasks = new();
|
||||||
List<string> locIds = new();
|
List<string> locIds = new();
|
||||||
foreach (var carry in carrys)
|
foreach (var carry in carrys)
|
||||||
@@ -274,6 +285,9 @@ namespace Tnb.WarehouseMgr
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
await _db.Ado.CommitTranAsync();
|
await _db.Ado.CommitTranAsync();
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
@@ -308,6 +322,7 @@ namespace Tnb.WarehouseMgr
|
|||||||
//[NonUnify]
|
//[NonUnify]
|
||||||
public async Task<dynamic> MESCreateOutstock(MESCreateOutstockInput input)
|
public async Task<dynamic> MESCreateOutstock(MESCreateOutstockInput input)
|
||||||
{
|
{
|
||||||
|
var isSuccessful = true;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await _db.Ado.BeginTranAsync();
|
await _db.Ado.BeginTranAsync();
|
||||||
@@ -316,12 +331,12 @@ namespace Tnb.WarehouseMgr
|
|||||||
//出库申请明细表
|
//出库申请明细表
|
||||||
List<WmsOutstockD> outstockDs = input.outstockDs.Adapt<List<WmsOutstockD>>();
|
List<WmsOutstockD> outstockDs = input.outstockDs.Adapt<List<WmsOutstockD>>();
|
||||||
|
|
||||||
var location = await _db.Queryable<BasLocation>().SingleAsync(it => it.location_code == input.outstock.location_code);
|
var location = await _db.Queryable<BasLocation>().SingleAsync(it => it.location_code == input.outstock.location_code && it.is_type != EnumLocationType.存储库位.ToString());
|
||||||
//如果数据不全,
|
//如果数据不全或有误,
|
||||||
if (location.IsNull() || outstockDs?.Count < 1)
|
if (location.IsNull() || outstockDs?.Count < 1)
|
||||||
{
|
{
|
||||||
//报错, 提示数据不全。
|
//报错, 提示数据不全或有误。
|
||||||
throw new AppFriendlyException("数据不全!", 500);
|
throw new AppFriendlyException("数据不全或有误!", 500);
|
||||||
}
|
}
|
||||||
// 生成出库申请数据,添加其他数据 主表
|
// 生成出库申请数据,添加其他数据 主表
|
||||||
outstock.id = SnowflakeIdHelper.NextId();
|
outstock.id = SnowflakeIdHelper.NextId();
|
||||||
@@ -333,7 +348,7 @@ namespace Tnb.WarehouseMgr
|
|||||||
outstock.status = WmsWareHouseConst.BILLSTATUS_ADD_ID;// 新增
|
outstock.status = WmsWareHouseConst.BILLSTATUS_ADD_ID;// 新增
|
||||||
outstock.create_id = _userManager.UserId;
|
outstock.create_id = _userManager.UserId;
|
||||||
outstock.create_time = DateTime.Now;
|
outstock.create_time = DateTime.Now;
|
||||||
await _db.Insertable(outstock).ExecuteCommandAsync();
|
|
||||||
//明细表
|
//明细表
|
||||||
foreach (var outstockD in outstockDs!)
|
foreach (var outstockD in outstockDs!)
|
||||||
{
|
{
|
||||||
@@ -344,7 +359,7 @@ namespace Tnb.WarehouseMgr
|
|||||||
outstock.create_time = outstock.create_time;
|
outstock.create_time = outstock.create_time;
|
||||||
outstock.create_id = outstock.create_id;
|
outstock.create_id = outstock.create_id;
|
||||||
}
|
}
|
||||||
await _db.Insertable(outstockDs).ExecuteCommandAsync();
|
|
||||||
//var loc = await _db.Queryable<BasLocation>().SingleAsync(it => it.id == outstock.location_id.ToString());
|
//var loc = await _db.Queryable<BasLocation>().SingleAsync(it => it.id == outstock.location_id.ToString());
|
||||||
var carryIds = new List<string>();
|
var carryIds = new List<string>();
|
||||||
//tablefield120 出库物料明细
|
//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 })
|
carryMats = carryMats.OrderBy(o => o.create_time).GroupBy(g => new { g.carry_id, g.material_id, g.code_batch })
|
||||||
.Select(x =>
|
.Select(x =>
|
||||||
{
|
{
|
||||||
WmsCarryMat carryMat = new();
|
var arr = x.ToArray();
|
||||||
|
WmsCarryMat carryMat = arr[^arr.Length];
|
||||||
carryMat.need_qty = x.Sum(d => d.need_qty);
|
carryMat.need_qty = x.Sum(d => d.need_qty);
|
||||||
return carryMat;
|
return carryMat;
|
||||||
})
|
})
|
||||||
@@ -432,6 +448,15 @@ namespace Tnb.WarehouseMgr
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
carryIds = allOutIds.Concat(sortingOutIds).ToList();
|
carryIds = allOutIds.Concat(sortingOutIds).ToList();
|
||||||
|
if (carryIds?.Count > 0)
|
||||||
|
{
|
||||||
|
var carryId = carryIds[^carryIds.Count];
|
||||||
|
var curCurry = await _db.Queryable<WmsCarryH>().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<WmsCarryH>().SetColumns(it => new WmsCarryH { out_status = ((int)EnumOutStatus.全部出).ToString() }).Where(it => allOutIds.Contains(it.id)).ExecuteCommandAsync();
|
await _db.Updateable<WmsCarryH>().SetColumns(it => new WmsCarryH { out_status = ((int)EnumOutStatus.全部出).ToString() }).Where(it => allOutIds.Contains(it.id)).ExecuteCommandAsync();
|
||||||
await _db.Updateable<WmsCarryH>().SetColumns(it => new WmsCarryH { out_status = ((int)EnumOutStatus.分拣出).ToString() }).Where(it => sortingOutIds.Contains(it.id)).ExecuteCommandAsync();
|
await _db.Updateable<WmsCarryH>().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)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
isSuccessful = false;
|
||||||
JNPF.Logging.Log.Error(ex.Message);
|
JNPF.Logging.Log.Error(ex.Message);
|
||||||
await _db.Ado.RollbackTranAsync();
|
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)
|
public override async Task ModifyAsync(WareHouseUpInput input)
|
||||||
|
|||||||
@@ -66,22 +66,27 @@ namespace Tnb.WarehouseMgr
|
|||||||
{
|
{
|
||||||
await _db.Ado.BeginTranAsync();
|
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 inStockStrategyInput = new InStockStrategyQuery { warehouse_id = input.data[nameof(InStockStrategyQuery.warehouse_id)].ToString()!, Size = 1 };
|
||||||
var endLocations = await _wareHouseService.InStockStrategy(inStockStrategyInput);
|
var endLocations = await _wareHouseService.InStockStrategy(inStockStrategyInput);
|
||||||
WmsPointH? sPoint = null;
|
WmsPointH sPoint = null!;
|
||||||
WmsPointH? ePoint = null;
|
WmsPointH ePoint = null!;
|
||||||
if (input.data.ContainsKey(nameof(WmsPointH.location_id)))
|
if (input.data.ContainsKey(nameof(WmsPointH.location_id)))
|
||||||
{
|
{
|
||||||
sPoint = await _db.Queryable<WmsPointH>().FirstAsync(it => it.location_id == input.data[nameof(WmsPointH.location_id)].ToString());
|
sPoint = await _db.Queryable<WmsPointH>().FirstAsync(it => it.location_id == input.data[nameof(WmsPointH.location_id)].ToString());
|
||||||
}
|
}
|
||||||
if (endLocations?.Count > 0)
|
if (endLocations?.Count > 0)
|
||||||
{
|
{
|
||||||
|
var carry = await _db.Queryable<WmsCarryH>().SingleAsync(it => it.id == input.data[nameof(WmsCarryD.carry_id)].ToString());
|
||||||
|
var loc = await _db.Queryable<BasLocation>().SingleAsync(it => it.id == endLocations[0].id);
|
||||||
|
var isMatch = await IsCarryAndLocationMatchByCarryStd(carry, loc);
|
||||||
|
if (!isMatch) throw new AppFriendlyException("库位与载具规格不匹配", 500);
|
||||||
ePoint = await _db.Queryable<WmsPointH>().FirstAsync(it => it.location_id == endLocations[0].id);
|
ePoint = await _db.Queryable<WmsPointH>().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)
|
if (sPoint != null && ePoint != null)
|
||||||
{
|
{
|
||||||
var points = await _wareHouseService.PathAlgorithms(sPoint.id, ePoint.id);
|
var points = await _wareHouseService.PathAlgorithms(sPoint.id, ePoint.id);
|
||||||
|
|||||||
@@ -63,12 +63,15 @@ namespace Tnb.WarehouseMgr
|
|||||||
{
|
{
|
||||||
await _db.Ado.BeginTranAsync();
|
await _db.Ado.BeginTranAsync();
|
||||||
|
|
||||||
|
var carry = await _db.Queryable<WmsCarryH>().FirstAsync(it => it.id == input.data[nameof(WmsMoveOutstock.carry_id)].ToString());
|
||||||
|
var loc = await _db.Queryable<BasLocation>().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);
|
VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleConsts.MODULE_WMSCARRYMOOUTSTKPDA_ID, true);
|
||||||
await _runService.Create(templateEntity, input);
|
await _runService.Create(templateEntity, input);
|
||||||
//出库取起点
|
//出库取起点
|
||||||
var carry = await _db.Queryable<WmsCarryH>().FirstAsync(it => it.id == input.data[nameof(WmsMoveOutstock.carry_id)].ToString());
|
WmsPointH? sPoint = null, ePoint = null;
|
||||||
WmsPointH? sPoint = null;
|
|
||||||
WmsPointH? ePoint = null;
|
|
||||||
if (input.data.ContainsKey(nameof(WmsPointH.location_id)))
|
if (input.data.ContainsKey(nameof(WmsPointH.location_id)))
|
||||||
{
|
{
|
||||||
ePoint = await _db.Queryable<WmsPointH>().FirstAsync(it => it.location_id == input.data[nameof(WmsPointH.location_id)].ToString());
|
ePoint = await _db.Queryable<WmsPointH>().FirstAsync(it => it.location_id == input.data[nameof(WmsPointH.location_id)].ToString());
|
||||||
@@ -114,7 +117,6 @@ namespace Tnb.WarehouseMgr
|
|||||||
return preTask;
|
return preTask;
|
||||||
}).ToList();
|
}).ToList();
|
||||||
//判断目标库位是否自动签收
|
//判断目标库位是否自动签收
|
||||||
var loc = await _db.Queryable<BasLocation>().SingleAsync(it => it.id == input.data[nameof(WmsPointH.location_id)].ToString());
|
|
||||||
if (loc.is_sign == 0)
|
if (loc.is_sign == 0)
|
||||||
{
|
{
|
||||||
preTasks[^1].is_sign = 0; // 修改最后一个元素的是否签收值
|
preTasks[^1].is_sign = 0; // 修改最后一个元素的是否签收值
|
||||||
|
|||||||
@@ -65,9 +65,7 @@ namespace Tnb.WarehouseMgr
|
|||||||
{
|
{
|
||||||
await _db.Ado.BeginTranAsync();
|
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 inStockStrategyInput = new InStockStrategyQuery { warehouse_id = input.data[nameof(InStockStrategyQuery.warehouse_id)].ToString()!, Size = 1 };
|
||||||
var endLocations = await _wareHouseService.InStockStrategy(inStockStrategyInput);
|
var endLocations = await _wareHouseService.InStockStrategy(inStockStrategyInput);
|
||||||
WmsPointH sPoint = null!;
|
WmsPointH sPoint = null!;
|
||||||
@@ -78,9 +76,16 @@ namespace Tnb.WarehouseMgr
|
|||||||
}
|
}
|
||||||
if (endLocations?.Count > 0)
|
if (endLocations?.Count > 0)
|
||||||
{
|
{
|
||||||
|
var carry = await _db.Queryable<WmsCarryH>().SingleAsync(it => it.id == input.data[nameof(WmsCarryD.carry_id)].ToString());
|
||||||
|
var loc = await _db.Queryable<BasLocation>().SingleAsync(it => it.id == endLocations[0].id);
|
||||||
|
var isMatch = await IsCarryAndLocationMatchByCarryStd(carry, loc);
|
||||||
|
if (!isMatch) throw new AppFriendlyException("库位与载具规格不匹配", 500);
|
||||||
ePoint = await _db.Queryable<WmsPointH>().FirstAsync(it => it.location_id == endLocations[0].id);
|
ePoint = await _db.Queryable<WmsPointH>().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)
|
if (sPoint != null && ePoint != null)
|
||||||
{
|
{
|
||||||
var points = await _wareHouseService.PathAlgorithms(sPoint.id, ePoint.id);
|
var points = await _wareHouseService.PathAlgorithms(sPoint.id, ePoint.id);
|
||||||
|
|||||||
@@ -106,24 +106,26 @@ namespace Tnb.WarehouseMgr
|
|||||||
{
|
{
|
||||||
var sPoint = it.FirstOrDefault();
|
var sPoint = it.FirstOrDefault();
|
||||||
var ePoint = it.LastOrDefault();
|
var ePoint = it.LastOrDefault();
|
||||||
|
//生成预任务
|
||||||
WmsPretaskH preTask = new();
|
WmsPretaskH preTask = new()
|
||||||
preTask.org_id = _userManager.User.OrganizeId;
|
{
|
||||||
preTask.startlocation_id = sPoint?.location_id!;
|
org_id = _userManager.User.OrganizeId,
|
||||||
preTask.startlocation_code = sPoint?.location_code!;
|
startlocation_id = sPoint?.location_id!,
|
||||||
preTask.endlocation_id = ePoint?.location_id!;
|
startlocation_code = sPoint?.location_code!,
|
||||||
preTask.endlocation_code = ePoint?.location_code!;
|
endlocation_id = ePoint?.location_id!,
|
||||||
preTask.start_floor = sPoint?.floor.ToString();
|
endlocation_code = ePoint?.location_code!,
|
||||||
preTask.end_floor = ePoint?.floor.ToString();
|
start_floor = sPoint?.floor.ToString(),
|
||||||
preTask.bill_code = _billRullService.GetBillNumber(WmsWareHouseConst.WMS_PRETASK_H_ENCODE).GetAwaiter().GetResult();
|
end_floor = ePoint?.floor.ToString(),
|
||||||
preTask.status = WmsWareHouseConst.PRETASK_BILL_STATUS_DXF_ID;
|
bill_code = _billRullService.GetBillNumber(WmsWareHouseConst.WMS_PRETASK_H_ENCODE).GetAwaiter().GetResult(),
|
||||||
preTask.biz_type = WmsWareHouseConst.BIZTYPE_WMSEPTYOUTSTK_ID;
|
status = WmsWareHouseConst.PRETASK_BILL_STATUS_DXF_ID,
|
||||||
preTask.task_type = WmsWareHouseConst.WMS_PRETASK_OUTSTOCK_TYPE_ID;
|
biz_type = WmsWareHouseConst.BIZTYPE_WMSEPTYOUTSTK_ID,
|
||||||
preTask.carry_id = carrys![i].id;
|
task_type = WmsWareHouseConst.WMS_PRETASK_OUTSTOCK_TYPE_ID,
|
||||||
preTask.carry_code = carrys![i].carry_code;
|
carry_id = carrys![i].id,
|
||||||
preTask.area_id = sPoint?.area_id!;
|
carry_code = carrys![i].carry_code,
|
||||||
preTask.area_code = it.Key;
|
area_id = sPoint?.area_id!,
|
||||||
preTask.require_id = input.data["ReturnIdentity"].ToString();
|
area_code = it.Key,
|
||||||
|
require_id = input.data["ReturnIdentity"].ToString()
|
||||||
|
};
|
||||||
preTask.require_code = input.data[nameof(preTask.bill_code)]?.ToString()!;
|
preTask.require_code = input.data[nameof(preTask.bill_code)]?.ToString()!;
|
||||||
preTask.create_id = _userManager.UserId;
|
preTask.create_id = _userManager.UserId;
|
||||||
preTask.create_time = DateTime.Now;
|
preTask.create_time = DateTime.Now;
|
||||||
@@ -139,39 +141,47 @@ namespace Tnb.WarehouseMgr
|
|||||||
}
|
}
|
||||||
if (isOk)
|
if (isOk)
|
||||||
{
|
{
|
||||||
var preTaskUpInput = new GenPreTaskUpInput();
|
//生成预任务上传输入
|
||||||
preTaskUpInput.RquireId = input.data["ReturnIdentity"].ToString()!;
|
GenPreTaskUpInput preTaskUpInput = new()
|
||||||
preTaskUpInput.CarryId = carrys![i].id;
|
{
|
||||||
preTaskUpInput.CarryStartLocationId = points.FirstOrDefault()!.location_id!;
|
RquireId = input.data["ReturnIdentity"].ToString()!,
|
||||||
preTaskUpInput.CarryStartLocationCode = points.FirstOrDefault()!.location_code!;
|
CarryId = carrys![i].id,
|
||||||
preTaskUpInput.LocationIds = points.Select(x => x.location_id).ToList()!;
|
CarryStartLocationId = points.FirstOrDefault()!.location_id!,
|
||||||
|
CarryStartLocationCode = points.FirstOrDefault()!.location_code!,
|
||||||
|
LocationIds = points.Select(x => x.location_id).ToList()!
|
||||||
|
};
|
||||||
|
|
||||||
//更新明细表
|
//更新明细表
|
||||||
WmsEmptyOutstockD wmsEmptyOutstockD = new();
|
WmsEmptyOutstockD wmsEmptyOutstockD = new()
|
||||||
wmsEmptyOutstockD.id = SnowflakeIdHelper.NextId();
|
{
|
||||||
wmsEmptyOutstockD.bill_id = preTaskUpInput.RquireId;
|
id = SnowflakeIdHelper.NextId(),
|
||||||
wmsEmptyOutstockD.biz_type = WmsWareHouseConst.BIZTYPE_WMSEPTYOUTSTK_ID;
|
bill_id = preTaskUpInput.RquireId,
|
||||||
wmsEmptyOutstockD.location_id = ePoint!.location_id!;
|
biz_type = WmsWareHouseConst.BIZTYPE_WMSEPTYOUTSTK_ID,
|
||||||
wmsEmptyOutstockD.status = WmsWareHouseConst.BILLSTATUS_COMPLETE_ID;
|
location_id = ePoint!.location_id!,
|
||||||
wmsEmptyOutstockD.carry_id = carrys[i].id;
|
status = WmsWareHouseConst.BILLSTATUS_COMPLETE_ID,
|
||||||
wmsEmptyOutstockD.carry_code = carrys[i].carry_code;
|
carry_id = carrys[i].id,
|
||||||
wmsEmptyOutstockD.create_id = _userManager.UserId;
|
carry_code = carrys[i].carry_code,
|
||||||
wmsEmptyOutstockD.create_time = DateTime.Now;
|
create_id = _userManager.UserId,
|
||||||
|
create_time = DateTime.Now
|
||||||
|
};
|
||||||
await _db.Insertable(wmsEmptyOutstockD)
|
await _db.Insertable(wmsEmptyOutstockD)
|
||||||
.ExecuteCommandAsync();
|
.ExecuteCommandAsync();
|
||||||
|
|
||||||
WmsHandleH handleH = new();
|
//生成操作记录表
|
||||||
handleH.org_id = _userManager.User.OrganizeId;
|
WmsHandleH handleH = new()
|
||||||
handleH.startlocation_id = carrys?[i].location_id!;
|
{
|
||||||
handleH.endlocation_id = ePoint!.location_id!;
|
org_id = _userManager.User.OrganizeId,
|
||||||
handleH.bill_code = input.data[nameof(WmsHandleH.bill_code)]?.ToString()!;
|
startlocation_id = carrys?[i].location_id!,
|
||||||
handleH.biz_type = input.data[nameof(WmsHandleH.biz_type)]?.ToString()!;
|
endlocation_id = ePoint!.location_id!,
|
||||||
handleH.carry_id = input.data[nameof(WmsHandleH.carry_id)]?.ToString()!;
|
bill_code = input.data[nameof(WmsHandleH.bill_code)]?.ToString()!,
|
||||||
handleH.carry_code = input.data[nameof(WmsHandleH.carry_code)]?.ToString()!;
|
biz_type = input.data[nameof(WmsHandleH.biz_type)]?.ToString()!,
|
||||||
handleH.require_id = input.data["ReturnIdentity"].ToString();
|
carry_id = input.data[nameof(WmsHandleH.carry_id)]?.ToString()!,
|
||||||
handleH.require_code = input.data[nameof(WmsHandleH.bill_code)]?.ToString()!;
|
carry_code = input.data[nameof(WmsHandleH.carry_code)]?.ToString()!,
|
||||||
handleH.create_id = _userManager.UserId;
|
require_id = input.data["ReturnIdentity"].ToString(),
|
||||||
handleH.create_time = DateTime.Now;
|
require_code = input.data[nameof(WmsHandleH.bill_code)]?.ToString()!,
|
||||||
|
create_id = _userManager.UserId,
|
||||||
|
create_time = DateTime.Now
|
||||||
|
};
|
||||||
preTaskUpInput.PreTaskRecord = handleH;
|
preTaskUpInput.PreTaskRecord = handleH;
|
||||||
//根据空载具出库Id,回更单据状态
|
//根据空载具出库Id,回更单据状态
|
||||||
await _db.Updateable<WmsEmptyOutstockH>().SetColumns(it => new WmsEmptyOutstockH { status = WmsWareHouseConst.BILLSTATUS_ON_ID }).Where(it => it.id == preTaskUpInput.RquireId).ExecuteCommandAsync();
|
await _db.Updateable<WmsEmptyOutstockH>().SetColumns(it => new WmsEmptyOutstockH { status = WmsWareHouseConst.BILLSTATUS_ON_ID }).Where(it => it.id == preTaskUpInput.RquireId).ExecuteCommandAsync();
|
||||||
|
|||||||
@@ -27,25 +27,28 @@ namespace Tnb.WarehouseMgr
|
|||||||
/// PDA投料记录
|
/// PDA投料记录
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[OverideVisualDev(ModuleConsts.MODULE_WMSFEEDINGRECORDPDA_ID)]
|
[OverideVisualDev(ModuleConsts.MODULE_WMSFEEDINGRECORDPDA_ID)]
|
||||||
public class WmsPDAFeedingService : BaseWareHouseService, IWmsCarryService, IPdaStroage
|
public class WmsPDAFeedingService : BaseWareHouseService, IPdaStroage
|
||||||
{
|
{
|
||||||
private readonly ISqlSugarClient _db;
|
private readonly ISqlSugarClient _db;
|
||||||
private readonly IUserManager _userManager;
|
private readonly IUserManager _userManager;
|
||||||
private readonly IBillRullService _billRullService;
|
private readonly IBillRullService _billRullService;
|
||||||
private readonly IRunService _runService;
|
private readonly IRunService _runService;
|
||||||
private readonly IVisualDevService _visualDevService;
|
private readonly IVisualDevService _visualDevService;
|
||||||
|
private readonly IWmsCarryService _carryService;
|
||||||
public WmsPDAFeedingService(
|
public WmsPDAFeedingService(
|
||||||
ISqlSugarRepository<WmsCarryH> repository,
|
ISqlSugarRepository<WmsCarryH> repository,
|
||||||
IUserManager userManager,
|
IUserManager userManager,
|
||||||
IBillRullService billRullService,
|
IBillRullService billRullService,
|
||||||
IRunService runService,
|
IRunService runService,
|
||||||
IVisualDevService visualDevService)
|
IVisualDevService visualDevService,
|
||||||
|
IWmsCarryService carryService)
|
||||||
{
|
{
|
||||||
_db = repository.AsSugarClient();
|
_db = repository.AsSugarClient();
|
||||||
_userManager = userManager;
|
_userManager = userManager;
|
||||||
_billRullService = billRullService;
|
_billRullService = billRullService;
|
||||||
_runService = runService;
|
_runService = runService;
|
||||||
_visualDevService = visualDevService;
|
_visualDevService = visualDevService;
|
||||||
|
_carryService = carryService;
|
||||||
OverideFuncs.CreateAsync = WmsPDAFeedingRecord;
|
OverideFuncs.CreateAsync = WmsPDAFeedingRecord;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -97,7 +100,7 @@ namespace Tnb.WarehouseMgr
|
|||||||
it.modify_time
|
it.modify_time
|
||||||
}).ExecuteCommandAsync();
|
}).ExecuteCommandAsync();
|
||||||
//更新载具
|
//更新载具
|
||||||
row = await UpdateNullCarry(carry);
|
row = await _carryService.UpdateNullCarry(carry);
|
||||||
isOk = (row > 0);
|
isOk = (row > 0);
|
||||||
if (!isOk) throw Oops.Oh(ErrorCode.COM1001);
|
if (!isOk) throw Oops.Oh(ErrorCode.COM1001);
|
||||||
}
|
}
|
||||||
@@ -124,37 +127,5 @@ namespace Tnb.WarehouseMgr
|
|||||||
return isOk;
|
return isOk;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<int> 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<WmsCarryD>().Where(it => it.carry_id == carryObj.id).ExecuteCommandHasChangeAsync();
|
|
||||||
//删除载具分拣物料明细
|
|
||||||
await _db.Deleteable<WmsCarryMat>().Where(it => it.carry_id == carryObj.id).ExecuteCommandHasChangeAsync();
|
|
||||||
//删除载具条码
|
|
||||||
await _db.Deleteable<WmsCarryCode>().Where(it => it.carry_id == carryObj.id).ExecuteCommandHasChangeAsync();
|
|
||||||
}
|
|
||||||
catch (Exception)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
return row;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -92,6 +92,10 @@ namespace Tnb.WarehouseMgr
|
|||||||
}
|
}
|
||||||
if (endLocations?.Count > 0)
|
if (endLocations?.Count > 0)
|
||||||
{
|
{
|
||||||
|
var carry = await _db.Queryable<WmsCarryH>().SingleAsync(it => it.id == input.data[nameof(WmsCarryD.carry_id)].ToString());
|
||||||
|
var loc = await _db.Queryable<BasLocation>().SingleAsync(it => it.id == endLocations[0].id);
|
||||||
|
var isMatch = await IsCarryAndLocationMatchByCarryStd(carry, loc);
|
||||||
|
if (!isMatch) throw new AppFriendlyException("库位与载具规格不匹配", 500);
|
||||||
ePoint = await _db.Queryable<WmsPointH>().FirstAsync(it => it.location_id == endLocations[0].id);
|
ePoint = await _db.Queryable<WmsPointH>().FirstAsync(it => it.location_id == endLocations[0].id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -80,6 +80,10 @@ namespace Tnb.WarehouseMgr
|
|||||||
}
|
}
|
||||||
if (endLocations?.Count > 0)
|
if (endLocations?.Count > 0)
|
||||||
{
|
{
|
||||||
|
var carry = await _db.Queryable<WmsCarryH>().SingleAsync(it => it.id == input.data[nameof(WmsCarryD.carry_id)].ToString());
|
||||||
|
var loc = await _db.Queryable<BasLocation>().SingleAsync(it => it.id == endLocations[0].id);
|
||||||
|
var isMatch = await IsCarryAndLocationMatchByCarryStd(carry, loc);
|
||||||
|
if (!isMatch) throw new AppFriendlyException("库位与载具规格不匹配", 500);
|
||||||
ePoint = await _db.Queryable<WmsPointH>().FirstAsync(it => it.location_id == endLocations[0].id);
|
ePoint = await _db.Queryable<WmsPointH>().FirstAsync(it => it.location_id == endLocations[0].id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
23
WarehouseMgr/Tnb.WarehouseMgr/WmsPretaskService.cs
Normal file
23
WarehouseMgr/Tnb.WarehouseMgr/WmsPretaskService.cs
Normal file
@@ -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<WmsPretaskH>
|
||||||
|
{
|
||||||
|
public WmsPretaskService(ISqlSugarRepository<WmsPretaskH> repository) : base(repository.AsSugarClient())
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -50,8 +50,11 @@ namespace Tnb.WarehouseMgr
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public async Task PackSortingByAdd(WmsCarryMat? carryMat)
|
public async Task PackSortingByAdd(WmsCarryMat carryMat)
|
||||||
{
|
{
|
||||||
|
string firstLocationId = "27010980724501", secondLocationId = "27010987857941";
|
||||||
|
var endLocation = await _db.Queryable<BasLocation>().SingleAsync(it => it.id == secondLocationId);
|
||||||
|
|
||||||
var setSortings = await _db.Queryable<WmsSetsortingH>()
|
var setSortings = await _db.Queryable<WmsSetsortingH>()
|
||||||
.Where(a => a.status == WmsWareHouseConst.BILLSTATUS_ADD_ID).OrderBy(a => a.seq)
|
.Where(a => a.status == WmsWareHouseConst.BILLSTATUS_ADD_ID).OrderBy(a => a.seq)
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
@@ -61,9 +64,18 @@ namespace Tnb.WarehouseMgr
|
|||||||
{
|
{
|
||||||
await _db.Ado.BeginTranAsync();
|
await _db.Ado.BeginTranAsync();
|
||||||
|
|
||||||
|
var singleSorting = new WmsSetsortingH();
|
||||||
|
if (setSortings?.Count > 0)
|
||||||
|
{
|
||||||
|
singleSorting = setSortings[0];
|
||||||
|
var curCarry = await _db.Queryable<WmsCarryH>().SingleAsync(it => it.id == singleSorting.carry_id);
|
||||||
|
var isMatch = await IsCarryAndLocationMatchByCarryStd(curCarry, endLocation);
|
||||||
|
if (!isMatch) throw new AppFriendlyException("库位与载具规格不匹配", 500);
|
||||||
|
}
|
||||||
|
|
||||||
if (setSortings?.Count > 0 && !onFlag)
|
if (setSortings?.Count > 0 && !onFlag)
|
||||||
{
|
{
|
||||||
var singleSorting = setSortings[^setSortings.Count];
|
|
||||||
var setSortingDList = await _db.Queryable<WmsSetsortingD>().Where(it => it.bill_id == singleSorting.id).ToListAsync();
|
var setSortingDList = await _db.Queryable<WmsSetsortingD>().Where(it => it.bill_id == singleSorting.id).ToListAsync();
|
||||||
if (setSortingDList?.Count > 0)
|
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 })
|
carryMats = carryMats.OrderBy(o => o.create_time).GroupBy(g => new { g.carry_id, g.material_id, g.code_batch })
|
||||||
.Select(x =>
|
.Select(x =>
|
||||||
{
|
{
|
||||||
WmsCarryMat? carryMat = x.FirstOrDefault();
|
var arr = x.ToArray();
|
||||||
carryMat.need_qty = x.Sum(d => d.need_qty);
|
WmsCarryMat carryMat = arr[^arr.Length];
|
||||||
|
carryMat.need_qty = arr.Sum(d => d.need_qty);
|
||||||
return carryMat;
|
return carryMat;
|
||||||
})
|
})
|
||||||
.ToList();
|
.ToList();
|
||||||
@@ -141,18 +154,18 @@ namespace Tnb.WarehouseMgr
|
|||||||
{
|
{
|
||||||
List<WmsPretaskH> preTasks = new();
|
List<WmsPretaskH> preTasks = new();
|
||||||
List<string> locIds = new();
|
List<string> locIds = new();
|
||||||
string firstLocationId = "27010980724501", secondLocationId = "27010987857941";
|
|
||||||
var mid = 6;
|
var mid = 6;
|
||||||
if (carrys.Length > mid)
|
if (carrys.Length > mid)
|
||||||
{
|
{
|
||||||
var leftCarrys = carrys[..mid];
|
var leftCarrys = carrys[..mid];
|
||||||
var rightCarrys = carrys[mid..];
|
var rightCarrys = carrys[mid..];
|
||||||
await InnerGenPreTask(leftCarrys, locIds, firstLocationId, 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);
|
await InnerGenPreTask(rightCarrys, locIds, secondLocationId, singleSorting.id, singleSorting.bill_code, preTasks, endLocation);
|
||||||
}
|
}
|
||||||
else
|
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<WmsPretaskCode> pretaskCodes = new();
|
List<WmsPretaskCode> pretaskCodes = new();
|
||||||
foreach (var pt in preTasks)
|
foreach (var pt in preTasks)
|
||||||
@@ -187,9 +200,8 @@ namespace Tnb.WarehouseMgr
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task InnerGenPreTask(WmsCarryH[] carrys, List<string> locIds, string eLocationId, string requireId, string requireCode, List<WmsPretaskH> preTasks)
|
private async Task InnerGenPreTask(WmsCarryH[] carrys, List<string> locIds, string eLocationId, string requireId, string requireCode, List<WmsPretaskH> preTasks, BasLocation endLocation)
|
||||||
{
|
{
|
||||||
var loc = await _db.Queryable<BasLocation>().SingleAsync(it => it.id == eLocationId);
|
|
||||||
foreach (var carry in carrys)
|
foreach (var carry in carrys)
|
||||||
{
|
{
|
||||||
WmsPointH sPoint = await _db.Queryable<WmsPointH>().FirstAsync(it => it.location_id == carry.location_id);
|
WmsPointH sPoint = await _db.Queryable<WmsPointH>().FirstAsync(it => it.location_id == carry.location_id);
|
||||||
@@ -198,7 +210,10 @@ namespace Tnb.WarehouseMgr
|
|||||||
if (sPoint != null && ePoint != null)
|
if (sPoint != null && ePoint != null)
|
||||||
{
|
{
|
||||||
var points = await _wareHouseService.PathAlgorithms(sPoint.id, ePoint.id);
|
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)
|
if (points?.Count > 0)
|
||||||
{
|
{
|
||||||
@@ -232,7 +247,7 @@ namespace Tnb.WarehouseMgr
|
|||||||
};
|
};
|
||||||
return preTask;
|
return preTask;
|
||||||
}).ToList();
|
}).ToList();
|
||||||
if (loc.is_sign == 0)
|
if (endLocation.is_sign == 0)
|
||||||
{
|
{
|
||||||
curPreTasks[^1].is_sign = 0; // 修改最后一个元素的是否签收值
|
curPreTasks[^1].is_sign = 0; // 修改最后一个元素的是否签收值
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ namespace Tnb.WarehouseMgr
|
|||||||
}
|
}
|
||||||
if (carry != null)
|
if (carry != null)
|
||||||
{
|
{
|
||||||
if (carry!.location_id!.IsNotEmptyOrNull())
|
if (carry?.location_id?.IsNotEmptyOrNull() ?? false)
|
||||||
{
|
{
|
||||||
var loc = await _db.Queryable<BasLocation>().SingleAsync(it => it.id == carry.location_id);
|
var loc = await _db.Queryable<BasLocation>().SingleAsync(it => it.id == carry.location_id);
|
||||||
loc.is_use = ((int)EnumCarryStatus.空闲).ToString();
|
loc.is_use = ((int)EnumCarryStatus.空闲).ToString();
|
||||||
@@ -139,7 +139,7 @@ namespace Tnb.WarehouseMgr
|
|||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
isSuccessFul= false;
|
isSuccessFul = false;
|
||||||
}
|
}
|
||||||
return isSuccessFul;
|
return isSuccessFul;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ using JNPF.Common.Enums;
|
|||||||
using JNPF.Common.Extension;
|
using JNPF.Common.Extension;
|
||||||
using JNPF.Common.Security;
|
using JNPF.Common.Security;
|
||||||
using JNPF.FriendlyException;
|
using JNPF.FriendlyException;
|
||||||
|
using JNPF.LinqBuilder;
|
||||||
using JNPF.Logging;
|
using JNPF.Logging;
|
||||||
using JNPF.Systems.Interfaces.System;
|
using JNPF.Systems.Interfaces.System;
|
||||||
using Mapster;
|
using Mapster;
|
||||||
@@ -70,20 +71,25 @@ namespace Tnb.WarehouseMgr
|
|||||||
// var set = true ; 如果有 把set修改为false
|
// var set = true ; 如果有 把set修改为false
|
||||||
var items = await _db.Queryable<WmsKittingoutH>().Where(it => it.status == WmsWareHouseConst.BILLSTATUS_CALLED_ID).ToListAsync();
|
var items = await _db.Queryable<WmsKittingoutH>().Where(it => it.status == WmsWareHouseConst.BILLSTATUS_CALLED_ID).ToListAsync();
|
||||||
var isCalled = items?.Count > 0;
|
var isCalled = items?.Count > 0;
|
||||||
|
|
||||||
if (kittingOuts?.Count > 0)
|
if (kittingOuts?.Count > 0)
|
||||||
{
|
{
|
||||||
foreach (var ko in kittingOuts)
|
foreach (var ko in kittingOuts)
|
||||||
{
|
{
|
||||||
|
//a.carrystd_id == WmsWareHouseConst.CARRY_LJSTD_ID
|
||||||
|
|
||||||
|
Expression<Func<WmsCarryH, bool>> whereExp = (ko.carry_id != null) ? a => a.id == ko.carry_id : a => a.carrystd_id == WmsWareHouseConst.CARRY_LJSTD_ID;
|
||||||
|
|
||||||
var carrys = await _db.Queryable<WmsCarryH>()
|
var carrys = await _db.Queryable<WmsCarryH>()
|
||||||
.InnerJoin<WmsCollocationSchemeH>((a, b) => a.collocation_scheme_id == b.id)
|
.InnerJoin<WmsCollocationSchemeH>((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)
|
.OrderBy((a, b) => b.seq)
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
if (carrys?.Count > 0)
|
if (carrys?.Count > 0)
|
||||||
{
|
{
|
||||||
var firstCarry = carrys.FirstOrDefault();
|
var firstCarry = carrys.FirstOrDefault();
|
||||||
GenPreTaskUpInput genPreTaskInput = new() { CarryId = firstCarry?.id };
|
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.status = WmsWareHouseConst.BILLSTATUS_TOBESHIPPED_ID;
|
||||||
ko.carry_id = firstCarry?.id;
|
ko.carry_id = firstCarry?.id;
|
||||||
ko.carry_code = firstCarry?.carry_code;
|
ko.carry_code = firstCarry?.carry_code;
|
||||||
@@ -174,26 +180,28 @@ namespace Tnb.WarehouseMgr
|
|||||||
var sPoint = it.FirstOrDefault();
|
var sPoint = it.FirstOrDefault();
|
||||||
var ePoint = it.LastOrDefault();
|
var ePoint = it.LastOrDefault();
|
||||||
|
|
||||||
WmsPretaskH preTask = new();
|
WmsPretaskH preTask = new()
|
||||||
preTask.org_id = _userManager.User.OrganizeId;
|
{
|
||||||
preTask.startlocation_id = sPoint?.location_id!;
|
org_id = _userManager.User.OrganizeId,
|
||||||
preTask.startlocation_code = sPoint?.location_code!;
|
startlocation_id = sPoint?.location_id!,
|
||||||
preTask.endlocation_id = ePoint?.location_id!;
|
startlocation_code = sPoint?.location_code!,
|
||||||
preTask.endlocation_code = ePoint?.location_code!;
|
endlocation_id = ePoint?.location_id!,
|
||||||
preTask.start_floor = sPoint?.floor.ToString();
|
endlocation_code = ePoint?.location_code!,
|
||||||
preTask.end_floor = ePoint?.floor.ToString();
|
start_floor = sPoint?.floor.ToString(),
|
||||||
preTask.bill_code = _billRullService.GetBillNumber(WmsWareHouseConst.WMS_PRETASK_H_ENCODE).GetAwaiter().GetResult();
|
end_floor = ePoint?.floor.ToString(),
|
||||||
preTask.status = WmsWareHouseConst.PRETASK_BILL_STATUS_DXF_ID;
|
bill_code = _billRullService.GetBillNumber(WmsWareHouseConst.WMS_PRETASK_H_ENCODE).GetAwaiter().GetResult(),
|
||||||
preTask.biz_type = ko.biz_type;
|
status = WmsWareHouseConst.PRETASK_BILL_STATUS_DXF_ID,
|
||||||
preTask.task_type = WmsWareHouseConst.WMS_PRETASK_INSTOCK_TYPE_ID;
|
biz_type = ko.biz_type,
|
||||||
preTask.carry_id = ko!.carry_id!;
|
task_type = WmsWareHouseConst.WMS_PRETASK_OUTSTOCK_TYPE_ID,
|
||||||
preTask.carry_code = ko!.carry_code!;
|
carry_id = ko!.carry_id!,
|
||||||
preTask.area_id = sPoint?.area_id!;
|
carry_code = ko!.carry_code!,
|
||||||
preTask.area_code = it.Key;
|
area_id = sPoint?.area_id!,
|
||||||
preTask.require_id = ko.id;
|
area_code = it.Key,
|
||||||
preTask.require_code = ko.bill_code;
|
require_id = ko.id,
|
||||||
preTask.create_id = _userManager.UserId;
|
require_code = ko.bill_code,
|
||||||
preTask.create_time = DateTime.Now;
|
create_id = _userManager.UserId,
|
||||||
|
create_time = DateTime.Now
|
||||||
|
};
|
||||||
return preTask;
|
return preTask;
|
||||||
}).ToList();
|
}).ToList();
|
||||||
if (loc.is_sign == 0)
|
if (loc.is_sign == 0)
|
||||||
@@ -238,14 +246,14 @@ namespace Tnb.WarehouseMgr
|
|||||||
var carry = await _db.Queryable<WmsCarryH>().SingleAsync(it => it.id == carryId);
|
var carry = await _db.Queryable<WmsCarryH>().SingleAsync(it => it.id == carryId);
|
||||||
var kods = await _db.Queryable<WmsKittingoutD>().Where(it => it.bill_id == input.requireId).ToListAsync();
|
var kods = await _db.Queryable<WmsKittingoutD>().Where(it => it.bill_id == input.requireId).ToListAsync();
|
||||||
//载具为料架时,取所有料箱的条码
|
//载具为料架时,取所有料箱的条码
|
||||||
List<string> carryMIds = new();
|
List<string> mCarryIds = new();
|
||||||
if (carry.carrystd_id == WmsWareHouseConst.CARRY_LJSTD_ID)
|
if (carry.carrystd_id == WmsWareHouseConst.CARRY_LJSTD_ID)
|
||||||
{
|
{
|
||||||
var carryDs = await _db.Queryable<WmsCarryD>().Where(it => it.carry_id == carryId).ToListAsync();
|
var carryDs = await _db.Queryable<WmsCarryD>().Where(it => it.carry_id == carryId).ToListAsync();
|
||||||
carryMIds = carryDs.Select(x => x.membercarry_id).ToList();
|
mCarryIds = carryDs.Select(x => x.membercarry_id).ToList();
|
||||||
}
|
}
|
||||||
//当前载具对应的所有条码插入
|
//当前载具对应的所有条码插入
|
||||||
Expression<Func<WmsCarryCode, bool>> whereExp = carryMIds?.Count > 0 ? a => carryMIds.Contains(a.carry_id) : a => a.carry_id == carryId;
|
Expression<Func<WmsCarryCode, bool>> whereExp = mCarryIds?.Count > 0 ? a => mCarryIds.Contains(a.carry_id) : a => a.carry_id == carryId;
|
||||||
|
|
||||||
var carryCodes = await _db.Queryable<WmsCarryCode>().Where(whereExp).ToListAsync();
|
var carryCodes = await _db.Queryable<WmsCarryCode>().Where(whereExp).ToListAsync();
|
||||||
var kittingoutCodes = carryCodes.Adapt<List<WmsKittingoutCode>>();
|
var kittingoutCodes = carryCodes.Adapt<List<WmsKittingoutCode>>();
|
||||||
@@ -290,9 +298,9 @@ namespace Tnb.WarehouseMgr
|
|||||||
// isOk = row > 0;
|
// 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<WmsCarryH>().Where(it => carryMIds.Contains(it.id)).ToListAsync();
|
var carrys = await _db.Queryable<WmsCarryH>().Where(it => mCarryIds.Contains(it.id)).ToListAsync();
|
||||||
carrys.Add(carry);
|
carrys.Add(carry);
|
||||||
if (carrys?.Count > 0)
|
if (carrys?.Count > 0)
|
||||||
{
|
{
|
||||||
@@ -325,9 +333,14 @@ namespace Tnb.WarehouseMgr
|
|||||||
public async Task<dynamic> MESKittingOutStk(List<MESKittingOutStkInput> input)
|
public async Task<dynamic> MESKittingOutStk(List<MESKittingOutStkInput> input)
|
||||||
{
|
{
|
||||||
var isSuccessFul = false;
|
var isSuccessFul = false;
|
||||||
if (input.IsNull()) throw new ArgumentNullException("input");
|
if (input.IsNull()) throw new ArgumentNullException(nameof(input));
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
var kittingOut = input[^1];
|
||||||
|
var curCarry = await _db.Queryable<WmsCarryH>().SingleAsync(it => it.id == kittingOut.carry_id);
|
||||||
|
var endLocation = await _db.Queryable<BasLocation>().SingleAsync(it => it.id == kittingOut.location_id);
|
||||||
|
var isMatch = await IsCarryAndLocationMatchByCarryStd(curCarry, endLocation);
|
||||||
|
if (!isMatch) throw new AppFriendlyException("该载具无法放置到目标库位", 500);
|
||||||
|
|
||||||
await _db.Ado.BeginTranAsync();
|
await _db.Ado.BeginTranAsync();
|
||||||
List<WmsKittingoutD> kittingOutDs = new();
|
List<WmsKittingoutD> kittingOutDs = new();
|
||||||
|
|||||||
@@ -314,6 +314,32 @@ public class DepartmentService : IDepartmentService, IDynamicApiController, ITra
|
|||||||
if (adminlist.Any()) await _repository.AsSugarClient().Insertable(adminlist).CallEntityMethod(m => m.Create()).ExecuteReturnEntityAsync();
|
if (adminlist.Any()) await _repository.AsSugarClient().Insertable(adminlist).CallEntityMethod(m => m.Create()).ExecuteReturnEntityAsync();
|
||||||
#endregion
|
#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<BasQrcode>().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>(basQrcode).ExecuteCommandAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#region 第三方同步
|
#region 第三方同步
|
||||||
|
|
||||||
try
|
try
|
||||||
@@ -450,6 +476,43 @@ public class DepartmentService : IDepartmentService, IDynamicApiController, ITra
|
|||||||
|
|
||||||
int isOK = await _repository.AsUpdateable(entity).IgnoreColumns(ignoreAllNullColumns: true).CallEntityMethod(m => m.LastModify()).ExecuteCommandAsync();
|
int isOK = await _repository.AsUpdateable(entity).IgnoreColumns(ignoreAllNullColumns: true).CallEntityMethod(m => m.LastModify()).ExecuteCommandAsync();
|
||||||
if (!(isOK > 0)) throw Oops.Oh(ErrorCode.D2018);
|
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<BasQrcode>().AnyAsync(x => x.code == qrcode.ToString() && x.source_id!=id))
|
||||||
|
{
|
||||||
|
throw Oops.Bah("二维码总表中已存在该二维码");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (await _repository.AsSugarClient().Queryable<BasQrcode>().AnyAsync(x => x.source_id == id))
|
||||||
|
{
|
||||||
|
await _repository.AsSugarClient().Updateable<BasQrcode>()
|
||||||
|
.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>(basQrcode).ExecuteCommandAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//modified by ly on 20230426 处理工位信息,将工位插入到设备表
|
//modified by ly on 20230426 处理工位信息,将工位插入到设备表
|
||||||
if (input.category == DictConst.RegionCategoryStationCode)
|
if (input.category == DictConst.RegionCategoryStationCode)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -823,7 +823,11 @@ public class RunService : IRunService, ITransient
|
|||||||
{
|
{
|
||||||
if (child.Key.Equals("id") && child.Value.IsNotEmptyOrNull())
|
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() != "[]")
|
else if (child.Key.IsNotEmptyOrNull() && child.Value.IsNotEmptyOrNull() && child.Value.ToString() != "[]")
|
||||||
{
|
{
|
||||||
@@ -986,7 +990,7 @@ public class RunService : IRunService, ITransient
|
|||||||
|
|
||||||
// 查找到该控件数据
|
// 查找到该控件数据
|
||||||
List<Dictionary<string, object>>? model = allDataMap[item].ToObject<List<Dictionary<string, object>>>();
|
List<Dictionary<string, object>>? model = allDataMap[item].ToObject<List<Dictionary<string, object>>>();
|
||||||
if (model != null && model.Count > 0)
|
if (model != null && model.Count >= 0) //modify by ly on 20230720 将Count>0改为>=0,否则最后一条明细数据删除不掉
|
||||||
{
|
{
|
||||||
// 利用key去找模板
|
// 利用key去找模板
|
||||||
FieldsModel? fieldsModel = templateInfo.FieldsModelList.Find(f => f.__vModel__ == item);
|
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 oldTInfo = new TemplateParsingBase(oldFEntity.PropertyJson, oldFEntity.TableJson, (int)oldFEntity.FormType); // 旧模板
|
||||||
var newTInfo = new TemplateParsingBase(newFEntity.PropertyJson, newFEntity.TableJson, (int)newFEntity.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 =>
|
oldTInfo.AllFieldsModel.ForEach(it =>
|
||||||
{
|
{
|
||||||
@@ -1689,7 +1693,7 @@ public class RunService : IRunService, ITransient
|
|||||||
Dictionary<string, object>? newChildData = new Dictionary<string, object>();
|
Dictionary<string, object>? newChildData = new Dictionary<string, object>();
|
||||||
foreach (KeyValuePair<string, object> item in childmap)
|
foreach (KeyValuePair<string, object> 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();
|
FieldsModel? childFieldsModel = childFieldsModelList.Where(c => c.__vModel__ == item.Key).FirstOrDefault();
|
||||||
if (childFieldsModel != null && childFieldsModel.__vModel__.Equals(item.Key))
|
if (childFieldsModel != null && childFieldsModel.__vModel__.Equals(item.Key))
|
||||||
{
|
{
|
||||||
@@ -1999,7 +2003,7 @@ public class RunService : IRunService, ITransient
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
private string GetPrimary(DbLinkEntity link, string MainTableName)
|
private string GetPrimary(DbLinkEntity link, string MainTableName)
|
||||||
{
|
{
|
||||||
// modified by PhilPan
|
// modified by PhilPan
|
||||||
var keys = _databaseService.GetPrimaries(link, MainTableName);
|
var keys = _databaseService.GetPrimaries(link, MainTableName);
|
||||||
if (keys.Count < 1) throw Oops.Oh(ErrorCode.D1402); // 主表未设置主键
|
if (keys.Count < 1) throw Oops.Oh(ErrorCode.D1402); // 主表未设置主键
|
||||||
return keys.First();
|
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));
|
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<IConditionalModel>() { conList });
|
if (!tableWhere.ContainsKey(tName)) tableWhere.Add(tName, new List<IConditionalModel>() { conList });
|
||||||
@@ -2945,7 +2949,7 @@ public class RunService : IRunService, ITransient
|
|||||||
// 多选时为模糊查询
|
// 多选时为模糊查询
|
||||||
if (model.multiple || model.searchMultiple)
|
if (model.multiple || model.searchMultiple)
|
||||||
{
|
{
|
||||||
var value = item.Value.ToString().Contains("[") ? item.Value.ToObject<List<object>>():new List<object>() { item.Value.ToString() };
|
var value = item.Value.ToString().Contains("[") ? item.Value.ToObject<List<object>>() : new List<object>() { item.Value.ToString() };
|
||||||
var addItems = new List<KeyValuePair<WhereType, ConditionalModel>>();
|
var addItems = new List<KeyValuePair<WhereType, ConditionalModel>>();
|
||||||
for (int i = 0; i < value.Count; i++)
|
for (int i = 0; i < value.Count; i++)
|
||||||
{
|
{
|
||||||
@@ -2987,7 +2991,7 @@ public class RunService : IRunService, ITransient
|
|||||||
var objIdList = new List<string>();
|
var objIdList = new List<string>();
|
||||||
if (item.Value.ToString().Contains("[")) objIdList = item.Value.ToObject<List<string>>();
|
if (item.Value.ToString().Contains("[")) objIdList = item.Value.ToObject<List<string>>();
|
||||||
else objIdList.Add(item.Value.ToString());
|
else objIdList.Add(item.Value.ToString());
|
||||||
var rIdList = _visualDevRepository.AsSugarClient().Queryable<UserRelationEntity>().Where(x => objIdList.Select(xx=>xx.Replace("--user", string.Empty)).Contains(x.UserId)).Select(x => new { x.ObjectId, x.ObjectType }).ToList();
|
var rIdList = _visualDevRepository.AsSugarClient().Queryable<UserRelationEntity>().Where(x => objIdList.Select(xx => xx.Replace("--user", string.Empty)).Contains(x.UserId)).Select(x => new { x.ObjectId, x.ObjectType }).ToList();
|
||||||
rIdList.ForEach(x =>
|
rIdList.ForEach(x =>
|
||||||
{
|
{
|
||||||
if (x.ObjectType.Equals("Organize"))
|
if (x.ObjectType.Equals("Organize"))
|
||||||
@@ -3193,7 +3197,7 @@ public class RunService : IRunService, ITransient
|
|||||||
var add = new KeyValuePair<WhereType, ConditionalModel>(i == 0 ? WhereType.And : WhereType.Or, new ConditionalModel
|
var add = new KeyValuePair<WhereType, ConditionalModel>(i == 0 ? WhereType.And : WhereType.Or, new ConditionalModel
|
||||||
{
|
{
|
||||||
FieldName = item.Key,
|
FieldName = item.Key,
|
||||||
ConditionalType = model.multiple ? ConditionalType.Like: ConditionalType.Equal,
|
ConditionalType = model.multiple ? ConditionalType.Like : ConditionalType.Equal,
|
||||||
FieldValue = model.multiple ? value[i].ToJsonString() : value[i].ToString()
|
FieldValue = model.multiple ? value[i].ToJsonString() : value[i].ToString()
|
||||||
});
|
});
|
||||||
addItems.Add(add);
|
addItems.Add(add);
|
||||||
@@ -3527,7 +3531,7 @@ public class RunService : IRunService, ITransient
|
|||||||
dataRuleConditionalList = _visualDevRepository.AsSugarClient().Utilities.JsonToConditionalModels(pList.ToJsonString());
|
dataRuleConditionalList = _visualDevRepository.AsSugarClient().Utilities.JsonToConditionalModels(pList.ToJsonString());
|
||||||
dataRuleConditionalList = GetIConditionalModelListByTableName(dataRuleConditionalList, item.Key);
|
dataRuleConditionalList = GetIConditionalModelListByTableName(dataRuleConditionalList, item.Key);
|
||||||
var json = dataRuleConditionalList.ToJsonString().Replace(item.Key + ".", string.Empty);
|
var json = dataRuleConditionalList.ToJsonString().Replace(item.Key + ".", string.Empty);
|
||||||
dataRuleConditionalList= _visualDevRepository.AsSugarClient().Utilities.JsonToConditionalModels(json);
|
dataRuleConditionalList = _visualDevRepository.AsSugarClient().Utilities.JsonToConditionalModels(json);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3875,7 +3879,7 @@ public class RunService : IRunService, ITransient
|
|||||||
{
|
{
|
||||||
Console.WriteLine(item.Value);
|
Console.WriteLine(item.Value);
|
||||||
Console.WriteLine(item.Key.Replace("jnpf_searchType_equals_", ""));
|
Console.WriteLine(item.Key.Replace("jnpf_searchType_equals_", ""));
|
||||||
if (item.Key.Contains("jnpf_searchType_equals_")) resList = resList.Where(x => x[item.Key.Replace("jnpf_searchType_equals_","")].ToString().Equals(item.Value)).ToList();
|
if (item.Key.Contains("jnpf_searchType_equals_")) resList = resList.Where(x => x[item.Key.Replace("jnpf_searchType_equals_", "")].ToString().Equals(item.Value)).ToList();
|
||||||
else resList = resList.Where(x => x[item.Key].ToString().Contains(item.Value)).ToList();
|
else resList = resList.Where(x => x[item.Key].ToString().Contains(item.Value)).ToList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user