Merge branch 'dev' of https://git.tuotong-tech.com/tnb/tnb.server into dev
This commit is contained in:
@@ -5,10 +5,17 @@ namespace Tnb.BasicData.Interfaces
|
|||||||
public interface IBasMbomService
|
public interface IBasMbomService
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>id<EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD>Ӧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>
|
/// 根据物料id获取对应的子任务列表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="bomId">bomid</param>
|
/// <param name="bomId">bomid</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<dynamic> GetSubMoListByBomId([FromRoute] string bomId);
|
Task<dynamic> GetSubMoListByBomId([FromRoute] string bomId);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 根据生产bom工序id获取投入物料
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="dic">id</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<dynamic> GetInputMaterialByMbomProcessId(Dictionary<string, string> dic);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -181,6 +181,20 @@ namespace Tnb.BasicData
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public async Task<dynamic> GetInputMaterialByMbomProcessId(Dictionary<string, string> dic)
|
||||||
|
{
|
||||||
|
string id = dic["id"];
|
||||||
|
var result = await _repository.AsSugarClient().Queryable<BasMbomInput>()
|
||||||
|
.Where(x => x.mbom_process_id == id)
|
||||||
|
.Select(x => new
|
||||||
|
{
|
||||||
|
material_id = x.material_id,
|
||||||
|
}).ToListAsync();
|
||||||
|
return result;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 根据物料id获取生产bom
|
/// 根据物料id获取生产bom
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -0,0 +1,64 @@
|
|||||||
|
namespace Tnb.ProductionMgr.Entities.Dto
|
||||||
|
{
|
||||||
|
public class MaterialReceiptInput
|
||||||
|
{
|
||||||
|
public string id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 签收单号
|
||||||
|
/// </summary>
|
||||||
|
public string code { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 工位id
|
||||||
|
/// </summary>
|
||||||
|
public string station_id { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 任务单id
|
||||||
|
/// </summary>
|
||||||
|
public string? mo_task_id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 工序id
|
||||||
|
/// </summary>
|
||||||
|
public string? process_id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 设备id
|
||||||
|
/// </summary>
|
||||||
|
public string? equip_id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 车间id
|
||||||
|
/// </summary>
|
||||||
|
public string? workshop_id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 载具id
|
||||||
|
/// </summary>
|
||||||
|
public string? carry_id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 产线id
|
||||||
|
/// </summary>
|
||||||
|
public string? workline_id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 二维码信息
|
||||||
|
/// </summary>
|
||||||
|
public string? carry_code { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 备注
|
||||||
|
/// </summary>
|
||||||
|
public string? remark { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 生产bom工序id
|
||||||
|
/// </summary>
|
||||||
|
public string? mbom_process_id { get; set; }
|
||||||
|
|
||||||
|
public List<Dictionary<string,string>> details { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
using JNPF.Common.Contracts;
|
||||||
|
using JNPF.Common.Security;
|
||||||
|
using SqlSugar;
|
||||||
|
|
||||||
|
namespace Tnb.ProductionMgr.Entities;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 物料签收子表
|
||||||
|
/// </summary>
|
||||||
|
[SugarTable("prd_material_receipt_d")]
|
||||||
|
public partial class PrdMaterialReceiptD : BaseEntity<string>
|
||||||
|
{
|
||||||
|
public PrdMaterialReceiptD()
|
||||||
|
{
|
||||||
|
id = SnowflakeIdHelper.NextId();
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 物料签收id
|
||||||
|
/// </summary>
|
||||||
|
public string material_receipt_id { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 物料id
|
||||||
|
/// </summary>
|
||||||
|
public string material_id { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 数量
|
||||||
|
/// </summary>
|
||||||
|
public decimal num { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 批次
|
||||||
|
/// </summary>
|
||||||
|
public string? batch { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 单位id
|
||||||
|
/// </summary>
|
||||||
|
public string? unit_id { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,98 @@
|
|||||||
|
using JNPF.Common.Contracts;
|
||||||
|
using JNPF.Common.Security;
|
||||||
|
using SqlSugar;
|
||||||
|
|
||||||
|
namespace Tnb.ProductionMgr.Entities;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 物料签收主表
|
||||||
|
/// </summary>
|
||||||
|
[SugarTable("prd_material_receipt_h")]
|
||||||
|
public partial class PrdMaterialReceiptH : BaseEntity<string>
|
||||||
|
{
|
||||||
|
public PrdMaterialReceiptH()
|
||||||
|
{
|
||||||
|
id = SnowflakeIdHelper.NextId();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 签收单号
|
||||||
|
/// </summary>
|
||||||
|
public string code { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 工位id
|
||||||
|
/// </summary>
|
||||||
|
public string station_id { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 任务单id
|
||||||
|
/// </summary>
|
||||||
|
public string? mo_task_id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 工序id
|
||||||
|
/// </summary>
|
||||||
|
public string? process_id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 设备id
|
||||||
|
/// </summary>
|
||||||
|
public string? equip_id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 车间id
|
||||||
|
/// </summary>
|
||||||
|
public string? workshop_id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 载具id
|
||||||
|
/// </summary>
|
||||||
|
public string? carry_id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 产线id
|
||||||
|
/// </summary>
|
||||||
|
public string? workline_id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 创建用户
|
||||||
|
/// </summary>
|
||||||
|
public string? create_id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 创建时间
|
||||||
|
/// </summary>
|
||||||
|
public DateTime? create_time { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 二维码信息
|
||||||
|
/// </summary>
|
||||||
|
public string? carry_code { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 备注
|
||||||
|
/// </summary>
|
||||||
|
public string? remark { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 流程引擎Id
|
||||||
|
/// </summary>
|
||||||
|
public string? f_flowid { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 流程任务Id
|
||||||
|
/// </summary>
|
||||||
|
public string? f_flowtaskid { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 所属组织
|
||||||
|
/// </summary>
|
||||||
|
public string? org_id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 生产bom工序id
|
||||||
|
/// </summary>
|
||||||
|
public string? mbom_process_id { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
using Tnb.ProductionMgr.Entities.Dto;
|
||||||
|
|
||||||
|
namespace Tnb.ProductionMgr.Interfaces
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 物料签收服务接口
|
||||||
|
/// </summary>
|
||||||
|
public interface IPrdMaterialReceiptService
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 根据铁片二维码获取信息
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="qrCode"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public Task<dynamic> GetInfoByQrCode(string qrCode);
|
||||||
|
|
||||||
|
public Task<dynamic> SaveData(MaterialReceiptInput input);
|
||||||
|
}
|
||||||
|
}
|
||||||
136
ProductionMgr/Tnb.ProductionMgr/PrdMaterialReceiptService.cs
Normal file
136
ProductionMgr/Tnb.ProductionMgr/PrdMaterialReceiptService.cs
Normal file
@@ -0,0 +1,136 @@
|
|||||||
|
using JNPF.Common.Core.Manager;
|
||||||
|
using JNPF.Common.Enums;
|
||||||
|
using JNPF.Common.Security;
|
||||||
|
using JNPF.DependencyInjection;
|
||||||
|
using JNPF.DynamicApiController;
|
||||||
|
using JNPF.FriendlyException;
|
||||||
|
using JNPF.Systems.Interfaces.System;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Microsoft.ClearScript.Util.Web;
|
||||||
|
using SqlSugar;
|
||||||
|
using Tnb.BasicData.Entities;
|
||||||
|
using Tnb.ProductionMgr.Entities;
|
||||||
|
using Tnb.ProductionMgr.Entities.Dto;
|
||||||
|
using Tnb.ProductionMgr.Entities.Dto.PrdManage;
|
||||||
|
using Tnb.ProductionMgr.Interfaces;
|
||||||
|
using Tnb.WarehouseMgr.Entities;
|
||||||
|
using Tnb.WarehouseMgr.Entities.Dto;
|
||||||
|
using Tnb.WarehouseMgr.Entities.Consts;
|
||||||
|
|
||||||
|
namespace Tnb.ProductionMgr
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 业务实现:物料签收
|
||||||
|
/// </summary>
|
||||||
|
[ApiDescriptionSettings(Tag = ModuleConst.Tag, Area = ModuleConst.Area, Order = 700)]
|
||||||
|
[Route("api/[area]/[controller]/[action]")]
|
||||||
|
public class PrdMaterialReceiptService : IPrdMaterialReceiptService, IDynamicApiController, ITransient
|
||||||
|
{
|
||||||
|
private readonly ISqlSugarRepository<PrdMo> _repository;
|
||||||
|
private readonly IUserManager _userManager;
|
||||||
|
private readonly IBillRullService _billRullService;
|
||||||
|
|
||||||
|
|
||||||
|
public PrdMaterialReceiptService(
|
||||||
|
ISqlSugarRepository<PrdMo> repository,
|
||||||
|
IBillRullService billRullService,
|
||||||
|
IUserManager userManager
|
||||||
|
)
|
||||||
|
{
|
||||||
|
_repository = repository;
|
||||||
|
_userManager = userManager;
|
||||||
|
_billRullService = billRullService;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public async Task<dynamic> GetInfoByQrCode(string qrCode)
|
||||||
|
{
|
||||||
|
var db = _repository.AsSugarClient();
|
||||||
|
var result = await db.Queryable<WmsCarryH>()
|
||||||
|
.Where((a) => a.carry_code == qrCode)
|
||||||
|
.Select(a => new
|
||||||
|
{
|
||||||
|
carry_id = a.id,
|
||||||
|
carry_name = a.carry_name,
|
||||||
|
children = SqlFunc.Subqueryable<WmsCarryCode>()
|
||||||
|
.LeftJoin<BasMaterial>((b,c)=>b.material_id==c.id)
|
||||||
|
.Where((b,c)=>a.id==b.carry_id).ToList((b,c)=>new CarryCodeDetailOutput()
|
||||||
|
{
|
||||||
|
unit_id = c.unit_id,
|
||||||
|
barcode = b.barcode,
|
||||||
|
code_batch = b.code_batch,
|
||||||
|
codeqty = b.codeqty,
|
||||||
|
material_id = b.material_id,
|
||||||
|
material_code = c.code,
|
||||||
|
material_name = c.name
|
||||||
|
})
|
||||||
|
}).FirstAsync();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public async Task<dynamic> SaveData(MaterialReceiptInput input)
|
||||||
|
{
|
||||||
|
var db = _repository.AsSugarClient();
|
||||||
|
DbResult<bool> result = await db.Ado.UseTranAsync(async () =>
|
||||||
|
{
|
||||||
|
var moTask = await db.Queryable<PrdMoTask>().FirstAsync(x => x.id == input.mo_task_id);
|
||||||
|
var inputMaterials = await db.Queryable<BasMbomInput>()
|
||||||
|
.Where(x => x.mbom_id == moTask.bom_id && x.mbom_process_id == input.mbom_process_id)
|
||||||
|
.Select(x=>x.material_id)
|
||||||
|
.ToListAsync();
|
||||||
|
|
||||||
|
string code = await _billRullService.GetBillNumber(WmsCarryConst.MATERIAL_RECEIPT_CODE);
|
||||||
|
PrdMaterialReceiptH prdMaterialReceiptH = new PrdMaterialReceiptH()
|
||||||
|
{
|
||||||
|
code = code,
|
||||||
|
station_id = input.station_id,
|
||||||
|
mo_task_id = input.mo_task_id,
|
||||||
|
process_id = input.process_id,
|
||||||
|
equip_id = input.equip_id,
|
||||||
|
workshop_id = input.workshop_id,
|
||||||
|
carry_id = input.carry_id,
|
||||||
|
workline_id = input.workline_id,
|
||||||
|
carry_code = input.carry_code,
|
||||||
|
remark = input.remark,
|
||||||
|
mbom_process_id = input.mbom_process_id,
|
||||||
|
create_id = _userManager.UserId,
|
||||||
|
create_time = DateTime.Now,
|
||||||
|
org_id = _userManager.GetUserInfo().Result.organizeId
|
||||||
|
};
|
||||||
|
|
||||||
|
List<PrdMaterialReceiptD> list = new List<PrdMaterialReceiptD>();
|
||||||
|
if (input.details != null && input.details.Count > 0)
|
||||||
|
{
|
||||||
|
foreach (var item in input.details)
|
||||||
|
{
|
||||||
|
if(!inputMaterials.Contains(item["material_id"]))
|
||||||
|
throw new Exception("该物料不是生产bom投入物料,不能签收");
|
||||||
|
|
||||||
|
list.Add(new PrdMaterialReceiptD
|
||||||
|
{
|
||||||
|
material_receipt_id = prdMaterialReceiptH.id,
|
||||||
|
material_id = item["material_id"],
|
||||||
|
num = Convert.ToDecimal(item["num"]),
|
||||||
|
batch = item["batch"],
|
||||||
|
unit_id = item["unit_id"],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new Exception("没有签收物料");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
await db.Insertable<PrdMaterialReceiptH>(prdMaterialReceiptH).ExecuteCommandAsync();
|
||||||
|
await db.Insertable<PrdMaterialReceiptD>(list).ExecuteCommandAsync();
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
if(!result.IsSuccess) throw Oops.Oh(result.ErrorMessage);
|
||||||
|
return result.IsSuccess ? "签收成功" : result.ErrorMessage;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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="..\..\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="..\Tnb.ProductionMgr.Interfaces\Tnb.ProductionMgr.Interfaces.csproj" />
|
<ProjectReference Include="..\Tnb.ProductionMgr.Interfaces\Tnb.ProductionMgr.Interfaces.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|||||||
@@ -12,5 +12,12 @@ namespace Tnb.WarehouseMgr.Entities.Consts
|
|||||||
/// 载具更换EnCode业务编码
|
/// 载具更换EnCode业务编码
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public const string WMS_CARRY_REPLACE_ENCODE = "WmsCarryReplace";
|
public const string WMS_CARRY_REPLACE_ENCODE = "WmsCarryReplace";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 物料签收编码
|
||||||
|
/// </summary>
|
||||||
|
public const string MATERIAL_RECEIPT_CODE = "MaterialReceipt";
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ public partial class WmsCarrybindH : BaseEntity<string>
|
|||||||
public string? org_id { get; set; }
|
public string? org_id { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 所属组织ID
|
/// 载具ID
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string? carry_id { get; set; }
|
public string? carry_id { get; set; }
|
||||||
|
|
||||||
|
|||||||
@@ -24,6 +24,11 @@ public partial class WmsCarryunbindH : BaseEntity<string>
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public string? org_id { get; set; }
|
public string? org_id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 载具ID
|
||||||
|
/// </summary>
|
||||||
|
public string? carry_id { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 载具编号
|
/// 载具编号
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ using JNPF.VisualDev.Entitys;
|
|||||||
using JNPF.VisualDev.Interfaces;
|
using JNPF.VisualDev.Interfaces;
|
||||||
using Mapster;
|
using Mapster;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using NPOI.SS.Formula;
|
||||||
using SqlSugar;
|
using SqlSugar;
|
||||||
using Tnb.BasicData.Entities;
|
using Tnb.BasicData.Entities;
|
||||||
using Tnb.WarehouseMgr.Entities;
|
using Tnb.WarehouseMgr.Entities;
|
||||||
@@ -56,7 +57,7 @@ namespace Tnb.WarehouseMgr
|
|||||||
|
|
||||||
private async Task<dynamic> CarryBind(VisualDevModelDataCrInput input)
|
private async Task<dynamic> CarryBind(VisualDevModelDataCrInput input)
|
||||||
{
|
{
|
||||||
|
var isOk = false;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await _db.Ado.BeginTranAsync();
|
await _db.Ado.BeginTranAsync();
|
||||||
@@ -65,101 +66,45 @@ namespace Tnb.WarehouseMgr
|
|||||||
await _runService.Create(templateEntity, input);
|
await _runService.Create(templateEntity, input);
|
||||||
|
|
||||||
if (input == null) throw new ArgumentNullException(nameof(input));
|
if (input == null) throw new ArgumentNullException(nameof(input));
|
||||||
var carry = await _db.Queryable<WmsCarryH>().FirstAsync(it => it.id == input.data[nameof(WmsCarrybindH.carry_id)].ToString());
|
var carryId = input.data.ContainsKey("carry_id") ? input.data["carry_id"]?.ToString() : "";
|
||||||
var subCarry = await _db.Queryable<WmsCarryH>().FirstAsync(it => it.id == input.data[nameof(WmsCarrybindH.membercarry_id)].ToString());
|
var subCarryId = input.data.ContainsKey("newcarry_id") ? input.data["newcarry_id"]?.ToString() : "";
|
||||||
|
var carry = await _db.Queryable<WmsCarryH>().FirstAsync(it => it.id == carryId);
|
||||||
|
var subCarry = await _db.Queryable<WmsCarryH>().FirstAsync(it => it.id == subCarryId);
|
||||||
|
WmsCarrybindH wmsCarrybindH = carry.Adapt<WmsCarrybindH>();
|
||||||
|
if (carryId != null && subCarryId != null)
|
||||||
|
{
|
||||||
|
wmsCarrybindH.id = SnowflakeIdHelper.NextId();
|
||||||
|
wmsCarrybindH.org_id = carry.org_id;
|
||||||
|
wmsCarrybindH.carry_id = carry.id;
|
||||||
|
wmsCarrybindH.membercarry_id = subCarry.id;
|
||||||
|
wmsCarrybindH.membercarry_code = subCarry.carry_code;
|
||||||
|
wmsCarrybindH.loc = input.data[nameof(WmsCarrybindH.loc)].ParseToInt(1);
|
||||||
|
wmsCarrybindH.create_id = _userManager.UserId;
|
||||||
|
wmsCarrybindH.create_time = DateTime.Now;
|
||||||
|
var row = await _db.Insertable(wmsCarrybindH).ExecuteCommandAsync();
|
||||||
|
carry.carry_status = "1";
|
||||||
|
row = await _db.Updateable(carry).ExecuteCommandAsync();
|
||||||
|
subCarry.carry_status = "1";
|
||||||
|
row = await _db.Updateable(subCarry).ExecuteCommandAsync();
|
||||||
|
isOk = (row > 0);
|
||||||
|
if (!isOk) throw Oops.Oh(ErrorCode.COM1001);
|
||||||
|
|
||||||
//if (oldCarry.carrystd_id != newCarry.carrystd_id)
|
}
|
||||||
//{
|
/* //更新主载具明细表,增加新的数据
|
||||||
// string errorMessege = "新老载具规格应相同";
|
var row = await _db.Insertable<WmsCarryD>(new WmsCarryD {
|
||||||
// throw Oops.Oh(errorMessege);
|
id = SnowflakeIdHelper.NextId(),
|
||||||
//}
|
org_id = carry.org_id,
|
||||||
|
carry_id = carry.id,
|
||||||
//更新
|
membercarry_id = subCarry.id,
|
||||||
var isOk = await _db.Updateable<WmsCarryD>().SetColumns(it => it.membercarry_id == subCarry.id)
|
membercarry_code = subCarry.carry_code,
|
||||||
.SetColumns(it => it.membercarry_code == subCarry.carry_code)
|
loc = input.data[nameof(WmsCarrybindH.loc)].ToString(),
|
||||||
.SetColumns(it => it.loc == input.data[nameof(WmsCarrybindH.loc)].ToString())
|
create_id = _userManager.UserId,
|
||||||
.Where(it => it.id == carry.id)
|
create_time = DateTime.Now
|
||||||
.ExecuteCommandHasChangeAsync();
|
})
|
||||||
if (!isOk) throw Oops.Oh(ErrorCode.COM1001);
|
.ExecuteCommandAsync();
|
||||||
|
if (row <= 0) throw Oops.Oh(ErrorCode.COM1000);
|
||||||
|
_db.Updateable<WmsCarryH>().SetColumns(it=>it.carry_status == "1").Where(it=>it.id == input.data[nameof(WmsCarrybindH.carry_id)].ToString());*/
|
||||||
|
await _db.Ado.CommitTranAsync();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* db.Updateable(WmsCarryD).SetColumns(it => it.carry_id == newCarry.id).Where(it=>it.carry_id == oldCarry.id).ExecuteCommand();
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* //入库取终点
|
|
||||||
//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 ePoint = null;
|
|
||||||
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());
|
|
||||||
}
|
|
||||||
if (carry != null)
|
|
||||||
{
|
|
||||||
sPoint = await _db.Queryable<WmsPointH>().FirstAsync(it => it.location_id == carry.location_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sPoint != null && ePoint != null)
|
|
||||||
{
|
|
||||||
var points = await _wareHouseService.PathAlgorithms(sPoint.id, ePoint.id);
|
|
||||||
//根据获取的路径点生成预任务,生成顺序必须预路径算法返回的起终点的顺序一致(预任务顺序)
|
|
||||||
if (points?.Count > 0)
|
|
||||||
{
|
|
||||||
if (points.Count <= 2) throw new AppFriendlyException("该路径不存在", 500);
|
|
||||||
var preTasks = points.Where(it => !it.location_id.IsNullOrEmpty()).GroupBy(g => g.area_code).Select(it =>
|
|
||||||
{
|
|
||||||
var sPoint = it.FirstOrDefault();
|
|
||||||
var ePoint = it.LastOrDefault();
|
|
||||||
|
|
||||||
WmsPretaskH preTask = new();
|
|
||||||
preTask.org_id = _userManager.User.OrganizeId;
|
|
||||||
preTask.startlocation_id = sPoint?.location_id;
|
|
||||||
preTask.startlocation_code = sPoint?.location_code;
|
|
||||||
preTask.endlocation_id = ePoint?.location_id;
|
|
||||||
preTask.endlocation_code = ePoint?.location_code;
|
|
||||||
preTask.start_floor = sPoint?.floor.ToString();
|
|
||||||
preTask.end_floor = ePoint?.floor.ToString();
|
|
||||||
preTask.bill_code = _billRullService.GetBillNumber(WmsWareHouseConst.WMS_PRETASK_H_ENCODE).GetAwaiter().GetResult();
|
|
||||||
preTask.status = WmsWareHouseConst.PRETASK_BILL_STATUS_DXF_ID;
|
|
||||||
preTask.biz_type = WmsWareHouseConst.BIZTYPE_WMSMOOUTSTK_ID;
|
|
||||||
preTask.task_type = WmsWareHouseConst.WMS_PRETASK_OUTSTOCK_TYPE_ID;
|
|
||||||
preTask.carry_id = input.data[nameof(preTask.carry_id)]?.ToString()!;
|
|
||||||
preTask.carry_code = input.data[nameof(preTask.carry_code)]?.ToString()!;
|
|
||||||
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();
|
|
||||||
var isOk = await _wareHouseService.GenPreTask(preTasks);
|
|
||||||
if (isOk)
|
|
||||||
{
|
|
||||||
var preTaskUpInput = new GenPreTaskUpInput();
|
|
||||||
preTaskUpInput.RquireId = input.data["ReturnIdentity"].ToString();
|
|
||||||
preTaskUpInput.CarryId = input.data[nameof(WmsCarryD.carry_id)]?.ToString()!;
|
|
||||||
preTaskUpInput.CarryStartLocationId = points.FirstOrDefault().location_id;
|
|
||||||
preTaskUpInput.CarryStartLocationCode = points.FirstOrDefault().location_code;
|
|
||||||
preTaskUpInput.LocationIds = points.Select(x => x.location_id).ToList();
|
|
||||||
preTaskUpInput.PreTaskRecords = preTasks.Adapt<List<WmsHandleH>>();
|
|
||||||
preTaskUpInput.PreTaskRecords.ForEach(x => x.id = SnowflakeIdHelper.NextId());
|
|
||||||
await _wareHouseService.GenInStockTaskHandleAfter(preTaskUpInput, null, null);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}*/
|
|
||||||
|
|
||||||
|
|
||||||
await _db.Ado.CommitTranAsync();
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,169 +1,175 @@
|
|||||||
using System;
|
using JNPF.Common.Contracts;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using JNPF.Common.Core.Manager;
|
using JNPF.Common.Core.Manager;
|
||||||
using JNPF.Common.Dtos.VisualDev;
|
using JNPF.Common.Dtos.VisualDev;
|
||||||
using JNPF.Common.Enums;
|
using JNPF.Common.Enums;
|
||||||
using JNPF.Common.Extension;
|
|
||||||
using JNPF.Common.Security;
|
using JNPF.Common.Security;
|
||||||
|
using JNPF.DependencyInjection;
|
||||||
|
using JNPF.DynamicApiController;
|
||||||
using JNPF.FriendlyException;
|
using JNPF.FriendlyException;
|
||||||
|
using JNPF.Logging;
|
||||||
using JNPF.Systems.Interfaces.System;
|
using JNPF.Systems.Interfaces.System;
|
||||||
using JNPF.VisualDev;
|
using JNPF.VisualDev;
|
||||||
using JNPF.VisualDev.Entitys;
|
|
||||||
using JNPF.VisualDev.Interfaces;
|
|
||||||
using Mapster;
|
using Mapster;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using SqlSugar;
|
using SqlSugar;
|
||||||
using Tnb.BasicData.Entities;
|
using Tnb.Common.Utils;
|
||||||
using Tnb.WarehouseMgr.Entities;
|
using Tnb.WarehouseMgr.Entities;
|
||||||
using Tnb.WarehouseMgr.Entities.Attributes;
|
|
||||||
using Tnb.WarehouseMgr.Entities.Consts;
|
using Tnb.WarehouseMgr.Entities.Consts;
|
||||||
using Tnb.WarehouseMgr.Entities.Dto;
|
using Tnb.WarehouseMgr.Entities.Dto;
|
||||||
|
using Tnb.WarehouseMgr.Entities.Enums;
|
||||||
using Tnb.WarehouseMgr.Interfaces;
|
using Tnb.WarehouseMgr.Interfaces;
|
||||||
|
|
||||||
namespace Tnb.WarehouseMgr
|
namespace Tnb.WarehouseMgr
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 载具移出
|
/// 载具服务
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[OverideVisualDev(ModuleConsts.MODULE_WMSCARRYREPLACE_ID)]
|
[OverideVisualDev(ModuleId)]
|
||||||
public class WmsCarryReplaceService : BaseWareHouseService
|
public class WmsCarryReplaceService : BaseWareHouseService, IWmsCarryService
|
||||||
{
|
{
|
||||||
|
private const string ModuleId = "26188532491557";
|
||||||
private readonly ISqlSugarClient _db;
|
private readonly ISqlSugarClient _db;
|
||||||
private readonly IRunService _runService;
|
|
||||||
private readonly IVisualDevService _visualDevService;
|
|
||||||
private readonly IWareHouseService _wareHouseService;
|
|
||||||
private readonly IBillRullService _billRullService;
|
|
||||||
private readonly IUserManager _userManager;
|
private readonly IUserManager _userManager;
|
||||||
public WmsCarryReplaceService(
|
private readonly IBillRullService _billRullService;
|
||||||
ISqlSugarRepository<WmsCarryH> repository,
|
public OverideVisualDevFunc OverideFuncs { get; } = new OverideVisualDevFunc();
|
||||||
IRunService runService,
|
public WmsCarryReplaceService(ISqlSugarRepository<WmsCarryH> repository, IUserManager userManager, IBillRullService billRullService)
|
||||||
IVisualDevService visualDevService,
|
|
||||||
IWareHouseService wareHouseService,
|
|
||||||
IUserManager userManager,
|
|
||||||
IBillRullService billRullService)
|
|
||||||
{
|
{
|
||||||
_db = repository.AsSugarClient();
|
_db = repository.AsSugarClient();
|
||||||
_runService = runService;
|
|
||||||
_visualDevService = visualDevService;
|
|
||||||
_wareHouseService = wareHouseService;
|
|
||||||
_userManager = userManager;
|
_userManager = userManager;
|
||||||
_billRullService = billRullService;
|
_billRullService = billRullService;
|
||||||
OverideFuncs.CreateAsync = CarryReplace;
|
OverideFuncs.CreateAsync = CarryReplace;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<dynamic> CarryReplace(VisualDevModelDataCrInput input)
|
/// <summary>
|
||||||
|
/// 更换载具
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="input">
|
||||||
|
/// 输入参数:
|
||||||
|
/// <br/>{
|
||||||
|
/// <br/> old_carry_id:老载具id
|
||||||
|
/// <br/> new_carry_id:新载具ID
|
||||||
|
/// <br/>}
|
||||||
|
/// </param>
|
||||||
|
/// <returns></returns>
|
||||||
|
/// <exception cref="ArgumentNullException"></exception>
|
||||||
|
[HttpPost]
|
||||||
|
public async Task<dynamic> CarryReplace(VisualDevModelDataCrInput input)
|
||||||
{
|
{
|
||||||
|
var isOk = false;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await _db.Ado.BeginTranAsync();
|
await _db.Ado.BeginTranAsync();
|
||||||
|
var oldCarryId = input.data.ContainsKey("carry_id") ? input.data["carry_id"]?.ToString() : "";
|
||||||
|
var newCarryId = input.data.ContainsKey("newcarry_id") ? input.data["newcarry_id"]?.ToString() : "";
|
||||||
|
var oldCarry = await _db.Queryable<WmsCarryH>().FirstAsync(it => it.id == oldCarryId);
|
||||||
|
var newCarry = await _db.Queryable<WmsCarryH>().FirstAsync(it => it.id == newCarryId);
|
||||||
|
if (oldCarry != null && newCarry != null)
|
||||||
|
{
|
||||||
|
ExChangeCarryInput carryInput = new() { old_carry_id = oldCarry.id, new_carry_id = newCarry.id };
|
||||||
|
isOk = await _updateSubCarry<WmsCarryD>(carryInput);
|
||||||
|
isOk = await _updateSubCarry<WmsCarryMat>(carryInput);
|
||||||
|
isOk = await _updateSubCarry<WmsCarryCode>(carryInput);
|
||||||
|
|
||||||
VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleConsts.MODULE_WMSCARRYMOOUTSTK_ID, true);
|
newCarry.status = oldCarry.status;
|
||||||
await _runService.Create(templateEntity, input);
|
newCarry.carry_status = oldCarry.carry_status;
|
||||||
if (input == null) throw new ArgumentNullException(nameof(input));
|
newCarry.location_id = oldCarry.location_id;
|
||||||
var oldCarry = await _db.Queryable<WmsCarryH>().FirstAsync(it => it.id == input.data[nameof(WmsCarryReplaceH.carry_id)].ToString());
|
newCarry.location_code = oldCarry.location_code;
|
||||||
var newCarry = await _db.Queryable<WmsCarryH>().FirstAsync(it => it.id == input.data[nameof(WmsCarryReplaceH.newcarry_id)].ToString());
|
newCarry.is_lock = oldCarry.is_lock;
|
||||||
if (oldCarry.carrystd_id != newCarry.carrystd_id)
|
newCarry.out_status = oldCarry.out_status;
|
||||||
{
|
newCarry.is_check = oldCarry.is_check;
|
||||||
string errorMessege = "新老载具规格应相同";
|
newCarry.bale_num = oldCarry.bale_num;
|
||||||
throw Oops.Oh(errorMessege);
|
newCarry.collocation_scheme_id = oldCarry.collocation_scheme_id;
|
||||||
}
|
newCarry.collocation_scheme_code = oldCarry.collocation_scheme_code;
|
||||||
if (oldCarry.carrystd_id == newCarry.carrystd_id)
|
newCarry.source_id = oldCarry.source_id;
|
||||||
{
|
newCarry.source_code = oldCarry.source_code;
|
||||||
var isOk = await _db.Updateable<WmsCarryD>().SetColumns(it => it.carry_id == newCarry.id).Where(it => it.carry_id == oldCarry.id).ExecuteCommandHasChangeAsync();
|
newCarry.create_id = _userManager.UserId;
|
||||||
if (!isOk) throw Oops.Oh(ErrorCode.COM1001);
|
newCarry.create_time = DateTime.Now;
|
||||||
isOk = await _db.Updateable<WmsCarryCode>().SetColumns(it => it.carry_id == newCarry.id).Where(it => it.carry_id == oldCarry.id).ExecuteCommandHasChangeAsync();
|
var row = await _db.Updateable(newCarry).ExecuteCommandAsync();
|
||||||
|
WmsCarryReplaceH wmsCarryReplaceH = oldCarry.Adapt<WmsCarryReplaceH>();
|
||||||
|
wmsCarryReplaceH.id = SnowflakeIdHelper.NextId();
|
||||||
|
wmsCarryReplaceH.org_id = oldCarry.org_id;
|
||||||
|
wmsCarryReplaceH.bill_code = await _billRullService.GetBillNumber(WmsCarryConst.WMS_CARRY_REPLACE_ENCODE);
|
||||||
|
wmsCarryReplaceH.carry_id = oldCarry.id;
|
||||||
|
wmsCarryReplaceH.carry_code = oldCarry.carry_code;
|
||||||
|
wmsCarryReplaceH.newcarry_id = newCarry.id;
|
||||||
|
wmsCarryReplaceH.newcarry_code = newCarry.carry_code;
|
||||||
|
row = await _db.Insertable(wmsCarryReplaceH).ExecuteCommandAsync();
|
||||||
|
row = await UpdateNullCarry(oldCarry);
|
||||||
|
isOk = (row > 0);
|
||||||
if (!isOk) throw Oops.Oh(ErrorCode.COM1001);
|
if (!isOk) throw Oops.Oh(ErrorCode.COM1001);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (oldCarry == null)
|
||||||
|
{
|
||||||
|
throw new AppFriendlyException("没有可用的旧载具", 500);
|
||||||
|
}
|
||||||
|
if (newCarry == null)
|
||||||
|
{
|
||||||
|
throw new AppFriendlyException("没有可用的新载具", 500);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
}
|
||||||
* db.Updateable(WmsCarryD).SetColumns(it => it.carry_id == newCarry.id).Where(it=>it.carry_id == oldCarry.id).ExecuteCommand();
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* //入库取终点
|
|
||||||
//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 ePoint = null;
|
|
||||||
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());
|
|
||||||
}
|
|
||||||
if (carry != null)
|
|
||||||
{
|
|
||||||
sPoint = await _db.Queryable<WmsPointH>().FirstAsync(it => it.location_id == carry.location_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sPoint != null && ePoint != null)
|
|
||||||
{
|
|
||||||
var points = await _wareHouseService.PathAlgorithms(sPoint.id, ePoint.id);
|
|
||||||
//根据获取的路径点生成预任务,生成顺序必须预路径算法返回的起终点的顺序一致(预任务顺序)
|
|
||||||
if (points?.Count > 0)
|
|
||||||
{
|
|
||||||
if (points.Count <= 2) throw new AppFriendlyException("该路径不存在", 500);
|
|
||||||
var preTasks = points.Where(it => !it.location_id.IsNullOrEmpty()).GroupBy(g => g.area_code).Select(it =>
|
|
||||||
{
|
|
||||||
var sPoint = it.FirstOrDefault();
|
|
||||||
var ePoint = it.LastOrDefault();
|
|
||||||
|
|
||||||
WmsPretaskH preTask = new();
|
|
||||||
preTask.org_id = _userManager.User.OrganizeId;
|
|
||||||
preTask.startlocation_id = sPoint?.location_id;
|
|
||||||
preTask.startlocation_code = sPoint?.location_code;
|
|
||||||
preTask.endlocation_id = ePoint?.location_id;
|
|
||||||
preTask.endlocation_code = ePoint?.location_code;
|
|
||||||
preTask.start_floor = sPoint?.floor.ToString();
|
|
||||||
preTask.end_floor = ePoint?.floor.ToString();
|
|
||||||
preTask.bill_code = _billRullService.GetBillNumber(WmsWareHouseConst.WMS_PRETASK_H_ENCODE).GetAwaiter().GetResult();
|
|
||||||
preTask.status = WmsWareHouseConst.PRETASK_BILL_STATUS_DXF_ID;
|
|
||||||
preTask.biz_type = WmsWareHouseConst.BIZTYPE_WMSMOOUTSTK_ID;
|
|
||||||
preTask.task_type = WmsWareHouseConst.WMS_PRETASK_OUTSTOCK_TYPE_ID;
|
|
||||||
preTask.carry_id = input.data[nameof(preTask.carry_id)]?.ToString()!;
|
|
||||||
preTask.carry_code = input.data[nameof(preTask.carry_code)]?.ToString()!;
|
|
||||||
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();
|
|
||||||
var isOk = await _wareHouseService.GenPreTask(preTasks);
|
|
||||||
if (isOk)
|
|
||||||
{
|
|
||||||
var preTaskUpInput = new GenPreTaskUpInput();
|
|
||||||
preTaskUpInput.RquireId = input.data["ReturnIdentity"].ToString();
|
|
||||||
preTaskUpInput.CarryId = input.data[nameof(WmsCarryD.carry_id)]?.ToString()!;
|
|
||||||
preTaskUpInput.CarryStartLocationId = points.FirstOrDefault().location_id;
|
|
||||||
preTaskUpInput.CarryStartLocationCode = points.FirstOrDefault().location_code;
|
|
||||||
preTaskUpInput.LocationIds = points.Select(x => x.location_id).ToList();
|
|
||||||
preTaskUpInput.PreTaskRecords = preTasks.Adapt<List<WmsHandleH>>();
|
|
||||||
preTaskUpInput.PreTaskRecords.ForEach(x => x.id = SnowflakeIdHelper.NextId());
|
|
||||||
await _wareHouseService.GenInStockTaskHandleAfter(preTaskUpInput, null, null);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}*/
|
|
||||||
|
|
||||||
|
|
||||||
await _db.Ado.CommitTranAsync();
|
await _db.Ado.CommitTranAsync();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
Log.Error("载具更换失败", ex);
|
||||||
await _db.Ado.RollbackTranAsync();
|
await _db.Ado.RollbackTranAsync();
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
return Task.FromResult(true);
|
return isOk;
|
||||||
}
|
}
|
||||||
/* public override async Task ModifyAsync(WareHouseUpInput input)
|
|
||||||
|
public async Task<int> UpdateNullCarry(WmsCarryH carryObj)
|
||||||
{
|
{
|
||||||
if (input == null) throw new ArgumentNullException(nameof(input));
|
var row = -1;
|
||||||
var isOk = await _db.Updateable<WmsCarryReplaceH>().SetColumns(it => new WmsCarryReplaceH { status = input.bizTypeId }).Where(it => it.id == input.requireId).ExecuteCommandHasChangeAsync();
|
try
|
||||||
if (!isOk) throw Oops.Oh(ErrorCode.COM1001);
|
{
|
||||||
}*/
|
carryObj.status = 0;
|
||||||
|
carryObj.carry_status = "0";
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
return row;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task<bool> _updateSubCarry<T>(ExChangeCarryInput input) where T : BaseEntity<string>, IWmsCarryEntity, new()
|
||||||
|
{
|
||||||
|
var row = -1;
|
||||||
|
var items = await _db.Queryable<T>().Where(it => it.carry_id == input.old_carry_id).ToListAsync();
|
||||||
|
if (items?.Count > 0)
|
||||||
|
{
|
||||||
|
List<T> newItems = DeepCopyHelper<T>.DeepCopyList(items);
|
||||||
|
if (newItems?.Count > 0)
|
||||||
|
{
|
||||||
|
newItems.ForEach(x =>
|
||||||
|
{
|
||||||
|
x.id = SnowflakeIdHelper.NextId();
|
||||||
|
x.carry_id = input.new_carry_id;
|
||||||
|
|
||||||
|
});
|
||||||
|
row = await _db.Insertable(newItems).ExecuteCommandAsync();
|
||||||
|
}
|
||||||
|
if (row > 0)
|
||||||
|
{
|
||||||
|
row = await _db.Deleteable(items).ExecuteCommandAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return (row > 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
110
WarehouseMgr/Tnb.WarehouseMgr/WmsCarryUnbindService.cs
Normal file
110
WarehouseMgr/Tnb.WarehouseMgr/WmsCarryUnbindService.cs
Normal file
@@ -0,0 +1,110 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using JNPF.Common.Core.Manager;
|
||||||
|
using JNPF.Common.Dtos.VisualDev;
|
||||||
|
using JNPF.Common.Enums;
|
||||||
|
using JNPF.Common.Extension;
|
||||||
|
using JNPF.Common.Security;
|
||||||
|
using JNPF.FriendlyException;
|
||||||
|
using JNPF.Systems.Interfaces.System;
|
||||||
|
using JNPF.VisualDev;
|
||||||
|
using JNPF.VisualDev.Entitys;
|
||||||
|
using JNPF.VisualDev.Interfaces;
|
||||||
|
using Mapster;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using NPOI.SS.Formula;
|
||||||
|
using SqlSugar;
|
||||||
|
using Tnb.BasicData.Entities;
|
||||||
|
using Tnb.WarehouseMgr.Entities;
|
||||||
|
using Tnb.WarehouseMgr.Entities.Attributes;
|
||||||
|
using Tnb.WarehouseMgr.Entities.Consts;
|
||||||
|
using Tnb.WarehouseMgr.Entities.Dto;
|
||||||
|
using Tnb.WarehouseMgr.Interfaces;
|
||||||
|
|
||||||
|
namespace Tnb.WarehouseMgr
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 载具移出
|
||||||
|
/// </summary>
|
||||||
|
[OverideVisualDev(ModuleConsts.MODULE_WMSCARRYREPLACE_ID)]
|
||||||
|
public class WmsCarryUnbindService : BaseWareHouseService
|
||||||
|
{
|
||||||
|
private readonly ISqlSugarClient _db;
|
||||||
|
private readonly IRunService _runService;
|
||||||
|
private readonly IVisualDevService _visualDevService;
|
||||||
|
private readonly IWareHouseService _wareHouseService;
|
||||||
|
private readonly IBillRullService _billRullService;
|
||||||
|
private readonly IUserManager _userManager;
|
||||||
|
public WmsCarryUnbindService(
|
||||||
|
ISqlSugarRepository<WmsCarryH> repository,
|
||||||
|
IRunService runService,
|
||||||
|
IVisualDevService visualDevService,
|
||||||
|
IWareHouseService wareHouseService,
|
||||||
|
IUserManager userManager,
|
||||||
|
IBillRullService billRullService)
|
||||||
|
{
|
||||||
|
_db = repository.AsSugarClient();
|
||||||
|
_runService = runService;
|
||||||
|
_visualDevService = visualDevService;
|
||||||
|
_wareHouseService = wareHouseService;
|
||||||
|
_userManager = userManager;
|
||||||
|
_billRullService = billRullService;
|
||||||
|
OverideFuncs.CreateAsync = CarryUnbind;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task<dynamic> CarryUnbind(VisualDevModelDataCrInput input)
|
||||||
|
{
|
||||||
|
var isOk = false;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await _db.Ado.BeginTranAsync();
|
||||||
|
|
||||||
|
VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleConsts.MODULE_WMSCARRYMOOUTSTK_ID, true);
|
||||||
|
await _runService.Create(templateEntity, input);
|
||||||
|
|
||||||
|
if (input == null) throw new ArgumentNullException(nameof(input));
|
||||||
|
var carryId = input.data.ContainsKey("carry_id") ? input.data["carry_id"]?.ToString() : "";
|
||||||
|
var subCarryId = input.data.ContainsKey("newcarry_id") ? input.data["newcarry_id"]?.ToString() : "";
|
||||||
|
var carry = await _db.Queryable<WmsCarryH>().FirstAsync(it => it.id == carryId);
|
||||||
|
var subCarry = await _db.Queryable<WmsCarryH>().FirstAsync(it => it.id == subCarryId);
|
||||||
|
//WmsCarryunbindH wmsCarryUnbindH = carry.Adapt<WmsCarryunbindH>();
|
||||||
|
if (carryId != null && subCarryId != null)
|
||||||
|
{
|
||||||
|
//wmsCarryUnbindH.id = SnowflakeIdHelper.NextId();
|
||||||
|
//wmsCarryUnbindH.org_id = carry.org_id;
|
||||||
|
//wmsCarryUnbindH.carry_id = carry.id;
|
||||||
|
//wmsCarryUnbindH.membercarry_id = subCarry.id;
|
||||||
|
//wmsCarryUnbindH.membercarry_code = subCarry.carry_code;
|
||||||
|
//wmsCarryUnbindH.loc = input.data[nameof(WmsCarryunbindH.loc)].ParseToInt(1);
|
||||||
|
//wmsCarryUnbindH.create_id = _userManager.UserId;
|
||||||
|
//wmsCarryUnbindH.create_time = DateTime.Now;
|
||||||
|
var row = await _db.Deleteable<WmsCarryD>().Where(it=>it.carry_id == subCarry.id).ExecuteCommandAsync();
|
||||||
|
carry.carry_status = "0";
|
||||||
|
row = await _db.Updateable(carry).ExecuteCommandAsync();
|
||||||
|
subCarry.carry_status = "0";
|
||||||
|
row = await _db.Updateable(subCarry).ExecuteCommandAsync();
|
||||||
|
isOk = (row > 0);
|
||||||
|
if (!isOk) throw Oops.Oh(ErrorCode.COM1001);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
await _db.Ado.CommitTranAsync();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await _db.Ado.RollbackTranAsync();
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
return Task.FromResult(true);
|
||||||
|
}
|
||||||
|
/* public override async Task ModifyAsync(WareHouseUpInput input)
|
||||||
|
{
|
||||||
|
if (input == null) throw new ArgumentNullException(nameof(input));
|
||||||
|
var isOk = await _db.Updateable<WmsCarryReplaceH>().SetColumns(it => new WmsCarryReplaceH { status = input.bizTypeId }).Where(it => it.id == input.requireId).ExecuteCommandHasChangeAsync();
|
||||||
|
if (!isOk) throw Oops.Oh(ErrorCode.COM1001);
|
||||||
|
}*/
|
||||||
|
}
|
||||||
|
}
|
||||||
176
WarehouseMgr/Tnb.WarehouseMgr/WmsPDACarryReplaceService.cs
Normal file
176
WarehouseMgr/Tnb.WarehouseMgr/WmsPDACarryReplaceService.cs
Normal file
@@ -0,0 +1,176 @@
|
|||||||
|
using JNPF.Common.Contracts;
|
||||||
|
using JNPF.Common.Core.Manager;
|
||||||
|
using JNPF.Common.Dtos.VisualDev;
|
||||||
|
using JNPF.Common.Enums;
|
||||||
|
using JNPF.Common.Security;
|
||||||
|
using JNPF.DependencyInjection;
|
||||||
|
using JNPF.DynamicApiController;
|
||||||
|
using JNPF.FriendlyException;
|
||||||
|
using JNPF.Logging;
|
||||||
|
using JNPF.Systems.Interfaces.System;
|
||||||
|
using JNPF.VisualDev;
|
||||||
|
using Mapster;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using SqlSugar;
|
||||||
|
using Tnb.Common.Utils;
|
||||||
|
using Tnb.WarehouseMgr.Entities;
|
||||||
|
using Tnb.WarehouseMgr.Entities.Attributes;
|
||||||
|
using Tnb.WarehouseMgr.Entities.Consts;
|
||||||
|
using Tnb.WarehouseMgr.Entities.Dto;
|
||||||
|
using Tnb.WarehouseMgr.Entities.Enums;
|
||||||
|
using Tnb.WarehouseMgr.Interfaces;
|
||||||
|
|
||||||
|
namespace Tnb.WarehouseMgr
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 载具服务
|
||||||
|
/// </summary>
|
||||||
|
[OverideVisualDev(ModuleConsts.MODULE_WMSCARRYREPLACEPDA_ID)]
|
||||||
|
public class WmsPDACarryReplaceService : BaseWareHouseService, IWmsCarryService
|
||||||
|
{
|
||||||
|
//private const string ModuleId = "26188532491557";
|
||||||
|
private readonly ISqlSugarClient _db;
|
||||||
|
private readonly IUserManager _userManager;
|
||||||
|
private readonly IBillRullService _billRullService;
|
||||||
|
public OverideVisualDevFunc OverideFuncs { get; } = new OverideVisualDevFunc();
|
||||||
|
public WmsPDACarryReplaceService(ISqlSugarRepository<WmsCarryH> repository, IUserManager userManager, IBillRullService billRullService)
|
||||||
|
{
|
||||||
|
_db = repository.AsSugarClient();
|
||||||
|
_userManager = userManager;
|
||||||
|
_billRullService = billRullService;
|
||||||
|
OverideFuncs.CreateAsync = PDACarryReplace;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 更换载具
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="input">
|
||||||
|
/// 输入参数:
|
||||||
|
/// <br/>{
|
||||||
|
/// <br/> old_carry_id:老载具id
|
||||||
|
/// <br/> new_carry_id:新载具ID
|
||||||
|
/// <br/>}
|
||||||
|
/// </param>
|
||||||
|
/// <returns></returns>
|
||||||
|
/// <exception cref="ArgumentNullException"></exception>
|
||||||
|
[HttpPost]
|
||||||
|
public async Task<dynamic> PDACarryReplace(VisualDevModelDataCrInput input)
|
||||||
|
{
|
||||||
|
var isOk = false;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await _db.Ado.BeginTranAsync();
|
||||||
|
var oldCarryId = input.data.ContainsKey("carry_id") ? input.data["carry_id"]?.ToString() : "";
|
||||||
|
var newCarryId = input.data.ContainsKey("newcarry_id") ? input.data["newcarry_id"]?.ToString() : "";
|
||||||
|
var oldCarry = await _db.Queryable<WmsCarryH>().FirstAsync(it => it.id == oldCarryId);
|
||||||
|
var newCarry = await _db.Queryable<WmsCarryH>().FirstAsync(it => it.id == newCarryId);
|
||||||
|
if (oldCarry != null && newCarry != null)
|
||||||
|
{
|
||||||
|
ExChangeCarryInput carryInput = new() { old_carry_id = oldCarry.id, new_carry_id = newCarry.id };
|
||||||
|
isOk = await _updateSubCarry<WmsCarryD>(carryInput);
|
||||||
|
isOk = await _updateSubCarry<WmsCarryMat>(carryInput);
|
||||||
|
isOk = await _updateSubCarry<WmsCarryCode>(carryInput);
|
||||||
|
|
||||||
|
newCarry.status = oldCarry.status;
|
||||||
|
newCarry.carry_status = oldCarry.carry_status;
|
||||||
|
newCarry.location_id = oldCarry.location_id;
|
||||||
|
newCarry.location_code = oldCarry.location_code;
|
||||||
|
newCarry.is_lock = oldCarry.is_lock;
|
||||||
|
newCarry.out_status = oldCarry.out_status;
|
||||||
|
newCarry.is_check = oldCarry.is_check;
|
||||||
|
newCarry.bale_num = oldCarry.bale_num;
|
||||||
|
newCarry.collocation_scheme_id = oldCarry.collocation_scheme_id;
|
||||||
|
newCarry.collocation_scheme_code = oldCarry.collocation_scheme_code;
|
||||||
|
newCarry.source_id = oldCarry.source_id;
|
||||||
|
newCarry.source_code = oldCarry.source_code;
|
||||||
|
newCarry.create_id = _userManager.UserId;
|
||||||
|
newCarry.create_time = DateTime.Now;
|
||||||
|
var row = await _db.Updateable(newCarry).ExecuteCommandAsync();
|
||||||
|
WmsCarryReplaceH wmsCarryReplaceH = oldCarry.Adapt<WmsCarryReplaceH>();
|
||||||
|
wmsCarryReplaceH.id = SnowflakeIdHelper.NextId();
|
||||||
|
wmsCarryReplaceH.org_id = oldCarry.org_id;
|
||||||
|
wmsCarryReplaceH.bill_code = await _billRullService.GetBillNumber(WmsCarryConst.WMS_CARRY_REPLACE_ENCODE);
|
||||||
|
wmsCarryReplaceH.carry_id = oldCarry.id;
|
||||||
|
wmsCarryReplaceH.carry_code = oldCarry.carry_code;
|
||||||
|
wmsCarryReplaceH.newcarry_id = newCarry.id;
|
||||||
|
wmsCarryReplaceH.newcarry_code = newCarry.carry_code;
|
||||||
|
row = await _db.Insertable(wmsCarryReplaceH).ExecuteCommandAsync();
|
||||||
|
row = await UpdateNullCarry(oldCarry);
|
||||||
|
isOk = (row > 0);
|
||||||
|
if (!isOk) throw Oops.Oh(ErrorCode.COM1001);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (oldCarry == null)
|
||||||
|
{
|
||||||
|
throw new AppFriendlyException("没有可用的旧载具", 500);
|
||||||
|
}
|
||||||
|
if (newCarry == null)
|
||||||
|
{
|
||||||
|
throw new AppFriendlyException("没有可用的新载具", 500);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
await _db.Ado.CommitTranAsync();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Log.Error("载具更换失败", ex);
|
||||||
|
await _db.Ado.RollbackTranAsync();
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
return isOk;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<int> UpdateNullCarry(WmsCarryH carryObj)
|
||||||
|
{
|
||||||
|
var row = -1;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
carryObj.status = 0;
|
||||||
|
carryObj.carry_status = "0";
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
return row;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task<bool> _updateSubCarry<T>(ExChangeCarryInput input) where T : BaseEntity<string>, IWmsCarryEntity, new()
|
||||||
|
{
|
||||||
|
var row = -1;
|
||||||
|
var items = await _db.Queryable<T>().Where(it => it.carry_id == input.old_carry_id).ToListAsync();
|
||||||
|
if (items?.Count > 0)
|
||||||
|
{
|
||||||
|
List<T> newItems = DeepCopyHelper<T>.DeepCopyList(items);
|
||||||
|
if (newItems?.Count > 0)
|
||||||
|
{
|
||||||
|
newItems.ForEach(x =>
|
||||||
|
{
|
||||||
|
x.id = SnowflakeIdHelper.NextId();
|
||||||
|
x.carry_id = input.new_carry_id;
|
||||||
|
|
||||||
|
});
|
||||||
|
row = await _db.Insertable(newItems).ExecuteCommandAsync();
|
||||||
|
}
|
||||||
|
if (row > 0)
|
||||||
|
{
|
||||||
|
row = await _db.Deleteable(items).ExecuteCommandAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return (row > 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user