生产投料
This commit is contained in:
@@ -19,6 +19,16 @@ namespace Tnb.ProductionMgr.Entities.Consts
|
||||
/// 待排产
|
||||
/// </summary>
|
||||
public const string WaitProductId = "25019244276501";
|
||||
|
||||
/// <summary>
|
||||
/// 物料签收编码
|
||||
/// </summary>
|
||||
public const string MATERIAL_RECEIPT_CODE = "MaterialReceipt";
|
||||
|
||||
/// <summary>
|
||||
/// 生产投料编码
|
||||
/// </summary>
|
||||
public const string FEEDING_CODE = "Feeding";
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
using JNPF.Common.Contracts;
|
||||
using JNPF.Common.Security;
|
||||
using SqlSugar;
|
||||
|
||||
namespace Tnb.ProductionMgr.Entities;
|
||||
|
||||
/// <summary>
|
||||
/// 生产投料子表
|
||||
/// </summary>
|
||||
[SugarTable("prd_feeding_d")]
|
||||
public partial class PrdFeedingD : BaseEntity<string>
|
||||
{
|
||||
public PrdFeedingD()
|
||||
{
|
||||
id = SnowflakeIdHelper.NextId();
|
||||
}
|
||||
/// <summary>
|
||||
/// 生产投料id
|
||||
/// </summary>
|
||||
public string feeding_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; }
|
||||
|
||||
/// <summary>
|
||||
/// 载具id
|
||||
/// </summary>
|
||||
public string carry_id { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 物料签收单id
|
||||
/// </summary>
|
||||
public string? material_receipt_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 物料签收单子表id
|
||||
/// </summary>
|
||||
public string? material_receipt_detail_id { get; set; }
|
||||
|
||||
}
|
||||
102
ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdFeedingH.cs
Normal file
102
ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdFeedingH.cs
Normal file
@@ -0,0 +1,102 @@
|
||||
using JNPF.Common.Contracts;
|
||||
using JNPF.Common.Security;
|
||||
using SqlSugar;
|
||||
|
||||
namespace Tnb.ProductionMgr.Entities;
|
||||
|
||||
/// <summary>
|
||||
/// 生产投料主表
|
||||
/// </summary>
|
||||
[SugarTable("prd_feeding_h")]
|
||||
public partial class PrdFeedingH : BaseEntity<string>
|
||||
{
|
||||
public PrdFeedingH()
|
||||
{
|
||||
id = SnowflakeIdHelper.NextId();
|
||||
}
|
||||
/// <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; }
|
||||
|
||||
/// <summary>
|
||||
/// 投料单号
|
||||
/// </summary>
|
||||
public string code { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 物料签收单id
|
||||
/// </summary>
|
||||
public string? material_receipt_id { get; set; }
|
||||
|
||||
}
|
||||
@@ -39,4 +39,19 @@ public partial class PrdMaterialReceiptD : BaseEntity<string>
|
||||
/// </summary>
|
||||
public string? unit_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 载具id
|
||||
/// </summary>
|
||||
public string carry_id { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 是否全部投料
|
||||
/// </summary>
|
||||
public int is_all_feeding { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 已投料数量
|
||||
/// </summary>
|
||||
public decimal feeding_num { get; set; }
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
using Tnb.ProductionMgr.Entities.Dto;
|
||||
|
||||
namespace Tnb.ProductionMgr.Interfaces
|
||||
{
|
||||
/// <summary>
|
||||
/// 物料签收服务接口
|
||||
/// </summary>
|
||||
public interface IPrdFeedingService
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 保存数据
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
public Task<dynamic> SaveData(MaterialReceiptInput input);
|
||||
}
|
||||
}
|
||||
@@ -14,6 +14,11 @@ namespace Tnb.ProductionMgr.Interfaces
|
||||
/// <returns></returns>
|
||||
public Task<dynamic> GetInfoByQrCode(string qrCode);
|
||||
|
||||
/// <summary>
|
||||
/// 保存数据
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
public Task<dynamic> SaveData(MaterialReceiptInput input);
|
||||
}
|
||||
}
|
||||
138
ProductionMgr/Tnb.ProductionMgr/PrdFeedingService.cs
Normal file
138
ProductionMgr/Tnb.ProductionMgr/PrdFeedingService.cs
Normal file
@@ -0,0 +1,138 @@
|
||||
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.Interfaces;
|
||||
using Tnb.ProductionMgr.Entities.Consts;
|
||||
|
||||
namespace Tnb.ProductionMgr
|
||||
{
|
||||
/// <summary>
|
||||
/// 业务实现:物料签收
|
||||
/// </summary>
|
||||
[ApiDescriptionSettings(Tag = ModuleConst.Tag, Area = ModuleConst.Area, Order = 700)]
|
||||
[Route("api/[area]/[controller]/[action]")]
|
||||
public class PrdFeedingService : IPrdFeedingService, IDynamicApiController, ITransient
|
||||
{
|
||||
private readonly ISqlSugarRepository<PrdFeedingH> _repository;
|
||||
private readonly IUserManager _userManager;
|
||||
private readonly IBillRullService _billRullService;
|
||||
|
||||
|
||||
public PrdFeedingService(
|
||||
ISqlSugarRepository<PrdFeedingH> repository,
|
||||
IBillRullService billRullService,
|
||||
IUserManager userManager
|
||||
)
|
||||
{
|
||||
_repository = repository;
|
||||
_userManager = userManager;
|
||||
_billRullService = billRullService;
|
||||
}
|
||||
|
||||
|
||||
[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(MoStatus.FEEDING_CODE);
|
||||
PrdFeedingH prdFeedingH = new PrdFeedingH()
|
||||
{
|
||||
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<PrdFeedingD> list = new List<PrdFeedingD>();
|
||||
if (input.details != null && input.details.Count > 0)
|
||||
{
|
||||
foreach (var item in input.details)
|
||||
{
|
||||
if(!inputMaterials.Contains(item["material_id"]))
|
||||
throw new Exception("该物料不是生产bom投入物料,不能签收");
|
||||
|
||||
var detail = await db.Queryable<PrdMaterialReceiptD>()
|
||||
.Where(x => x.carry_id == input.carry_id && x.is_all_feeding == 0).FirstAsync();
|
||||
decimal num = Convert.ToDecimal(item["num"]);
|
||||
list.Add(new PrdFeedingD
|
||||
{
|
||||
feeding_id = prdFeedingH.id,
|
||||
material_receipt_detail_id = detail?.id,
|
||||
material_id = item["material_id"],
|
||||
num = num,
|
||||
batch = item["batch"],
|
||||
unit_id = item["unit_id"],
|
||||
carry_id = input.carry_id,
|
||||
});
|
||||
|
||||
if (detail != null)
|
||||
{
|
||||
if(detail.feeding_num + num > detail.num)
|
||||
{
|
||||
throw new Exception("投料数量不能大于签收数量");
|
||||
}else if (detail.feeding_num + num == detail.num)
|
||||
{
|
||||
await db.Updateable<PrdMaterialReceiptD>()
|
||||
.SetColumns(x => x.feeding_num == x.feeding_num + num)
|
||||
.SetColumns(x => x.is_all_feeding == 1)
|
||||
.Where(x => x.id == detail.id)
|
||||
.ExecuteCommandAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
await db.Updateable<PrdMaterialReceiptD>()
|
||||
.SetColumns(x => x.feeding_num == x.feeding_num + num)
|
||||
.Where(x => x.id == detail.id)
|
||||
.ExecuteCommandAsync();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("没有签收单,无法投料");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("没有签收物料");
|
||||
}
|
||||
|
||||
|
||||
await db.Insertable<PrdFeedingH>(prdFeedingH).ExecuteCommandAsync();
|
||||
await db.Insertable<PrdFeedingD>(list).ExecuteCommandAsync();
|
||||
|
||||
});
|
||||
|
||||
if(!result.IsSuccess) throw Oops.Oh(result.ErrorMessage);
|
||||
return result.IsSuccess ? "签收成功" : result.ErrorMessage;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,16 +6,14 @@ 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;
|
||||
using Tnb.ProductionMgr.Entities.Consts;
|
||||
|
||||
namespace Tnb.ProductionMgr
|
||||
{
|
||||
@@ -26,13 +24,13 @@ namespace Tnb.ProductionMgr
|
||||
[Route("api/[area]/[controller]/[action]")]
|
||||
public class PrdMaterialReceiptService : IPrdMaterialReceiptService, IDynamicApiController, ITransient
|
||||
{
|
||||
private readonly ISqlSugarRepository<PrdMo> _repository;
|
||||
private readonly ISqlSugarRepository<PrdMaterialReceiptH> _repository;
|
||||
private readonly IUserManager _userManager;
|
||||
private readonly IBillRullService _billRullService;
|
||||
|
||||
|
||||
public PrdMaterialReceiptService(
|
||||
ISqlSugarRepository<PrdMo> repository,
|
||||
ISqlSugarRepository<PrdMaterialReceiptH> repository,
|
||||
IBillRullService billRullService,
|
||||
IUserManager userManager
|
||||
)
|
||||
@@ -81,7 +79,7 @@ namespace Tnb.ProductionMgr
|
||||
.Select(x=>x.material_id)
|
||||
.ToListAsync();
|
||||
|
||||
string code = await _billRullService.GetBillNumber(WmsCarryConst.MATERIAL_RECEIPT_CODE);
|
||||
string code = await _billRullService.GetBillNumber(MoStatus.MATERIAL_RECEIPT_CODE);
|
||||
PrdMaterialReceiptH prdMaterialReceiptH = new PrdMaterialReceiptH()
|
||||
{
|
||||
code = code,
|
||||
@@ -115,6 +113,9 @@ namespace Tnb.ProductionMgr
|
||||
num = Convert.ToDecimal(item["num"]),
|
||||
batch = item["batch"],
|
||||
unit_id = item["unit_id"],
|
||||
carry_id = input.carry_id,
|
||||
is_all_feeding = 0,
|
||||
feeding_num = 0,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,11 +13,6 @@ namespace Tnb.WarehouseMgr.Entities.Consts
|
||||
/// </summary>
|
||||
public const string WMS_CARRY_REPLACE_ENCODE = "WmsCarryReplace";
|
||||
|
||||
/// <summary>
|
||||
/// 物料签收编码
|
||||
/// </summary>
|
||||
public const string MATERIAL_RECEIPT_CODE = "MaterialReceipt";
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user