自动签收后直接自动投料

This commit is contained in:
2024-10-09 15:58:38 +08:00
parent 70f2f1d559
commit d0e77bef3e
3 changed files with 135 additions and 18 deletions

View File

@@ -82,5 +82,7 @@ public partial class PrdMaterialReceiptD : BaseEntity<string>
/// 检验结论 /// 检验结论
/// </summary> /// </summary>
public string check_conclusion { get; set; } public string check_conclusion { get; set; }
public DateTime create_time { get; set; }
} }

View File

@@ -26,6 +26,7 @@ namespace Tnb.ProductionMgr
} }
[HttpPost] [HttpPost]
[AllowAnonymous]
public async Task<dynamic> GetProjects() public async Task<dynamic> GetProjects()
{ {
var erpdb = _db.AsTenant().GetConnection("erpdb"); var erpdb = _db.AsTenant().GetConnection("erpdb");

View File

@@ -29,6 +29,7 @@ using Tnb.WarehouseMgr.Entities.Dto.Inputs;
using Tnb.WarehouseMgr.Interfaces; using Tnb.WarehouseMgr.Interfaces;
using Tnb.WarehouseMgr.Entities.Dto.Outputs; using Tnb.WarehouseMgr.Entities.Dto.Outputs;
using Tnb.BasicData.Interfaces; using Tnb.BasicData.Interfaces;
using Tnb.WarehouseMgr.Entities.Enums;
namespace Tnb.ProductionMgr namespace Tnb.ProductionMgr
{ {
@@ -48,6 +49,7 @@ namespace Tnb.ProductionMgr
private readonly IPrdMoTaskService _prdMoTaskService; private readonly IPrdMoTaskService _prdMoTaskService;
private readonly IWmsCarryQueryService _wmsCarryQueryService; private readonly IWmsCarryQueryService _wmsCarryQueryService;
private readonly IBasWorkgroupService _basWorkgroupService; private readonly IBasWorkgroupService _basWorkgroupService;
private readonly IWmsCarryUnbindService _wmsCarryUnbindService;
public PrdMaterialReceiptService( public PrdMaterialReceiptService(
ISqlSugarRepository<PrdMaterialReceiptH> repository, ISqlSugarRepository<PrdMaterialReceiptH> repository,
@@ -56,6 +58,7 @@ namespace Tnb.ProductionMgr
IPrdMoTaskService prdMoTaskService, IPrdMoTaskService prdMoTaskService,
IWmsCarryQueryService wmsCarryQueryService, IWmsCarryQueryService wmsCarryQueryService,
IBasWorkgroupService basWorkgroupService, IBasWorkgroupService basWorkgroupService,
IWmsCarryUnbindService wmsCarryUnbindService,
IUserManager userManager IUserManager userManager
) )
{ {
@@ -66,6 +69,7 @@ namespace Tnb.ProductionMgr
_prdMoTaskService = prdMoTaskService; _prdMoTaskService = prdMoTaskService;
_wmsCarryQueryService = wmsCarryQueryService; _wmsCarryQueryService = wmsCarryQueryService;
_basWorkgroupService = basWorkgroupService; _basWorkgroupService = basWorkgroupService;
_wmsCarryUnbindService = wmsCarryUnbindService;
} }
@@ -512,6 +516,7 @@ namespace Tnb.ProductionMgr
supplier_id = item.supplier_id, supplier_id = item.supplier_id,
instock_time = item.instock_time, instock_time = item.instock_time,
check_conclusion = item.check_conclusion, check_conclusion = item.check_conclusion,
create_time = DateTime.Now,
}); });
} }
} }
@@ -571,6 +576,13 @@ namespace Tnb.ProductionMgr
: !result2.IsSuccess ? throw Oops.Bah(result2.ErrorMessage) : (dynamic)"签收成功"; : !result2.IsSuccess ? throw Oops.Bah(result2.ErrorMessage) : (dynamic)"签收成功";
} }
/// <summary>
/// 自动签收
/// </summary>
/// <param name="input"></param>
/// <exception cref="ArgumentNullException"></exception>
/// <exception cref="AppFriendlyException"></exception>
/// <exception cref="Exception"></exception>
public override async Task ModifyAsync(WareHouseUpInput input) public override async Task ModifyAsync(WareHouseUpInput input)
{ {
Log.Information($"物料呼叫完成回更参数:{JsonConvert.SerializeObject(input)}"); Log.Information($"物料呼叫完成回更参数:{JsonConvert.SerializeObject(input)}");
@@ -590,10 +602,12 @@ namespace Tnb.ProductionMgr
{ {
throw Oops.Bah($"未找到来源id为{input.requireId}的生产任务单"); throw Oops.Bah($"未找到来源id为{input.requireId}的生产任务单");
} }
string code = await _billRullService.GetBillNumber(Tnb.BasicData.CodeTemplateConst.MATERIAL_RECEIPT_CODE);
OrganizeEntity workshop = await _organizeService.GetAnyParentByWorkstationId(moTask.workstation_id, DictConst.RegionCategoryWorkshopCode); OrganizeEntity workshop = await _organizeService.GetAnyParentByWorkstationId(moTask.workstation_id, DictConst.RegionCategoryWorkshopCode);
List<PrdMaterialReceiptH> insertHList = new List<PrdMaterialReceiptH>(); List<PrdMaterialReceiptH> insertHList = new List<PrdMaterialReceiptH>();
List<PrdMaterialReceiptD> insertDList = new List<PrdMaterialReceiptD>(); List<PrdMaterialReceiptD> insertDList = new List<PrdMaterialReceiptD>();
List<PrdFeedingH> insertFHList = new List<PrdFeedingH>();
List<PrdFeedingD> insertFDList = new List<PrdFeedingD>();
string orgId = WmsWareHouseConst.AdministratorOrgId; string orgId = WmsWareHouseConst.AdministratorOrgId;
// string userId = moTask.worker_id; // string userId = moTask.worker_id;
string userId = WmsWareHouseConst.AdministratorUserId; string userId = WmsWareHouseConst.AdministratorUserId;
@@ -604,7 +618,7 @@ namespace Tnb.ProductionMgr
foreach(string carryId in input.carryIds) foreach(string carryId in input.carryIds)
{ {
WmsCarryH carry = await db.Queryable<WmsCarryH>().SingleAsync(x => x.id == carryId); WmsCarryH carry = await db.Queryable<WmsCarryH>().SingleAsync(x => x.id == carryId);
string code = await _billRullService.GetBillNumber(Tnb.BasicData.CodeTemplateConst.MATERIAL_RECEIPT_CODE);
PrdMaterialReceiptH prdMaterialReceiptH = new PrdMaterialReceiptH() PrdMaterialReceiptH prdMaterialReceiptH = new PrdMaterialReceiptH()
{ {
code = code, code = code,
@@ -622,6 +636,26 @@ namespace Tnb.ProductionMgr
org_id = orgId org_id = orgId
}; };
insertHList.Add(prdMaterialReceiptH); insertHList.Add(prdMaterialReceiptH);
string feedCode = await _billRullService.GetBillNumber(Tnb.BasicData.CodeTemplateConst.FEEDING_CODE);
PrdFeedingH prdFeedingH = new PrdFeedingH()
{
code = feedCode,
station_id = moTask.workstation_id,
mo_task_id = moTask.id,
process_id = moTask.process_id,
// equip_id = input.equip_id,
workshop_id = workshop?.Id,
carry_id = carry.id,
workline_id = moTask.workline_id,
carry_code = carry.carry_code,
// remark = input.remark,
mbom_process_id = moTask.mbom_process_id,
create_id = _userManager.UserId,
create_time = DateTime.Now,
org_id = _userManager.GetUserInfo().Result.organizeId
};
insertFHList.Add(prdFeedingH);
List<WmsCarryCode> carryCodes = new List<WmsCarryCode>(); List<WmsCarryCode> carryCodes = new List<WmsCarryCode>();
List<string> memberCarryIds = new List<string>(); List<string> memberCarryIds = new List<string>();
@@ -650,17 +684,17 @@ namespace Tnb.ProductionMgr
Log.Information($"签收载具信息{JsonConvert.SerializeObject(carryCodes)}"); Log.Information($"签收载具信息{JsonConvert.SerializeObject(carryCodes)}");
foreach (var item in carryCodes) foreach (var item in carryCodes)
{ {
PrdMaterialReceiptD existD = await db.Queryable<PrdMaterialReceiptD>() // 自动签收不校验
.LeftJoin<PrdMaterialReceiptH>((x, y) => x.material_receipt_id == y.id) // PrdMaterialReceiptD existD = await db.Queryable<PrdMaterialReceiptD>()
.Where((x, y) => x.carry_id == carry.id && y.mo_task_id == moTask.id && x.is_all_feeding == 0) // .LeftJoin<PrdMaterialReceiptH>((x, y) => x.material_receipt_id == y.id)
.Select((x,y)=>x) // .Where((x, y) => x.carry_id == carry.id && y.mo_task_id == moTask.id && x.is_all_feeding == 0)
.FirstAsync(); // .Select((x,y)=>x)
if (existD != null) // .FirstAsync();
{ // if (existD != null)
throw new Exception($"{moTask.mo_task_code}任务单存在未投完的签收物料,物料签收子表id{existD.id}"); // {
} // throw new Exception($"{moTask.mo_task_code}任务单存在未投完的签收物料,物料签收子表id{existD.id}");
// }
insertDList.Add(new PrdMaterialReceiptD PrdMaterialReceiptD detail = new PrdMaterialReceiptD
{ {
material_receipt_id = prdMaterialReceiptH.id, material_receipt_id = prdMaterialReceiptH.id,
material_id = item.material_id, material_id = item.material_id,
@@ -669,14 +703,63 @@ namespace Tnb.ProductionMgr
unit_id = item.unit_id, unit_id = item.unit_id,
carry_id = carry.id, carry_id = carry.id,
barcode = item.barcode, barcode = item.barcode,
is_all_feeding = 0, is_all_feeding = 1,
member_carry_id = item.carry_id, member_carry_id = item.carry_id,
member_carry_code = memberCarrys.Find(x=>x.id==item.carry_id)?.carry_code ?? "", member_carry_code = memberCarrys.Find(x => x.id == item.carry_id)?.carry_code ?? "",
feeding_num = 0, feeding_num = item.codeqty,
supplier_id = item.supplier_id, supplier_id = item.supplier_id,
instock_time = item.instock_time, instock_time = item.instock_time,
check_conclusion = item.check_conclusion+"", check_conclusion = item.check_conclusion + "",
create_time = DateTime.Now,
};
insertDList.Add(detail);
decimal num = item.codeqty;
insertFDList.Add(new PrdFeedingD
{
feeding_id = prdFeedingH.id,
material_receipt_detail_id = detail?.id,
material_id = item.material_id,
num = num,
batch = item.code_batch,
unit_id = item.unit_id,
carry_id = carry.id,
status = "0",
use_num = 0,
}); });
if (carry.carrystd_id == WmsWareHouseConst.CARRY_ZYXCSTD_ID || carry.carrystd_id == WmsWareHouseConst.CARRY_ZYLJSTD_ID)
{
}
else
{
Tnb.WarehouseMgr.Entities.Dto.Outputs.Result result = await _wmsCarryUnbindService.CarryCodeUnbind(new CarryCodeUnbindInput()
{
carry_id = detail.member_carry_id
});
if (result.code != JNPF.Common.Enums.HttpStatusCode.OK)
{
throw Oops.Bah(result.msg);
}
}
}
if (carry.carrystd_id == WmsWareHouseConst.CARRY_ZYXCSTD_ID || carry.carrystd_id == WmsWareHouseConst.CARRY_ZYLJSTD_ID)
{
Tnb.WarehouseMgr.Entities.Dto.Outputs.Result result = await _wmsCarryUnbindService.CarryCodeUnbind(new CarryCodeUnbindInput()
{
carry_id = carry.id
});
if (result.code != JNPF.Common.Enums.HttpStatusCode.OK)
{
throw Oops.Bah(result.msg);
}
} }
} }
else else
@@ -684,7 +767,34 @@ namespace Tnb.ProductionMgr
throw Oops.Bah("未找到物料明细"); throw Oops.Bah("未找到物料明细");
} }
if (carry.carrystd_id==WmsWareHouseConst.CARRY_LXSTD_ID)
{
Tnb.WarehouseMgr.Entities.Dto.Outputs.Result result2 = await _wmsCarryUnbindService.CarryUnbind(new CarryBindInput()
{
org = prdFeedingH.org_id,
create_id = prdFeedingH.create_id,
carry_id = prdMaterialReceiptH.carry_id,
carry_code = prdMaterialReceiptH.carry_code,
carrystd_id = carry.carrystd_id,
membercarry_code = "",
membercarry_id = "",
});
if (result2.code != JNPF.Common.Enums.HttpStatusCode.OK)
{
throw Oops.Bah(result2.msg);
}
}
} }
await db.Updateable<WmsCarryH>()
.SetColumns(x => x.carry_status == ((int)EnumCarryStatus.).ToString())
.SetColumns(x => x.is_check == ((int)EnumCheckConclusion.).ToString())
.Where(x => input.carryIds.Contains(x.id))
.ExecuteCommandAsync();
if (insertHList.Count <= 0 || insertDList.Count <= 0) if (insertHList.Count <= 0 || insertDList.Count <= 0)
{ {
@@ -693,7 +803,11 @@ namespace Tnb.ProductionMgr
int row1 = await db.Insertable(insertHList).ExecuteCommandAsync(); int row1 = await db.Insertable(insertHList).ExecuteCommandAsync();
int row2 = await db.Insertable(insertDList).ExecuteCommandAsync(); int row2 = await db.Insertable(insertDList).ExecuteCommandAsync();
if (row1 <= 0 || row2 <= 0) int row3 = await db.Insertable(insertHList).ExecuteCommandAsync();
int row4 = await db.Insertable(insertDList).ExecuteCommandAsync();
if (row1 <= 0 || row2 <= 0 || row3<=0 || row4<=0)
{ {
throw Oops.Bah(ErrorCode.COM1000); throw Oops.Bah(ErrorCode.COM1000);
} }