This commit is contained in:
2024-06-28 13:35:15 +08:00
7 changed files with 98 additions and 29 deletions

View File

@@ -95,12 +95,14 @@ namespace Tnb.ProductionMgr
act_start_date = a.act_start_date==null ? "" : a.act_start_date.Value.ToString(DbTimeFormat.SS),
tablefield102 = SqlFunc.Subqueryable<PrdFeedingH>()
.LeftJoin<UserEntity>((x,y)=>x.create_id==y.Id)
.Where(x=>x.mo_task_id==a.id).ToList((x,y)=>new PrdFeedingRecordUpListChildOutPut()
.LeftJoin<OrganizeEntity>((x,y,z)=>x.station_id==y.Id)
.Where(x=>x.mo_task_id==a.id).ToList((x,y,z)=>new PrdFeedingRecordUpListChildOutPut()
{
id = x.id,
code = x.code,
carry_code = x.carry_code,
create_id = y.RealName,
station_id = z.FullName,
create_time = x.create_time==null ? "" : x.create_time.Value.ToString(DbTimeFormat.SS),
}),

View File

@@ -4,6 +4,7 @@ using JNPF.Common.Security;
using JNPF.DependencyInjection;
using JNPF.DynamicApiController;
using JNPF.FriendlyException;
using JNPF.Logging;
using JNPF.Systems.Entitys.Permission;
using JNPF.Systems.Entitys.System;
using JNPF.Systems.Interfaces.System;
@@ -365,9 +366,11 @@ namespace Tnb.ProductionMgr
PrdFeedingH? prdFeedingH = null;
List<PrdFeedingD> list = new();
DbResult<bool> result2 = new();
DbResult<bool> result = await db.Ado.UseTranAsync(async () =>
try
{
await db.Ado.BeginTranAsync();
PrdMoTask parentMoTask = await db.Queryable<PrdMoTask>().FirstAsync(x => x.id == moTask.parent_id);
string worklineId = moTask.workline_id;
if (parentMoTask != null && !string.IsNullOrEmpty(parentMoTask.workline_id))
@@ -402,6 +405,7 @@ namespace Tnb.ProductionMgr
org_id = _userManager.GetUserInfo().Result.organizeId
};
PrdMaterialReceiptH prdMaterialReceiptH = null;
if (input.details != null && input.details.Count > 0)
{
foreach (var item in input.details)
@@ -413,6 +417,17 @@ namespace Tnb.ProductionMgr
PrdMaterialReceiptD? detail = await db.Queryable<PrdMaterialReceiptD>()
.Where(x => x.member_carry_code == input.carry_code && x.is_all_feeding == 0).FirstAsync();
if (prdMaterialReceiptH == null)
{
prdMaterialReceiptH = await db.Queryable<PrdMaterialReceiptH>()
.SingleAsync(x => x.id == detail.material_receipt_id);
}
WmsCarryCode wmsCarryCode = await db.Queryable<WmsCarryCode>().Where(x=>x.carry_id==carry.id).FirstAsync();
if (wmsCarryCode == null)
{
throw Oops.Bah($"未找到条码信息,载具id{carry.id}");
}
decimal num = item.codeqty;
list.Add(new PrdFeedingD
{
@@ -420,34 +435,13 @@ namespace Tnb.ProductionMgr
material_receipt_detail_id = detail?.id,
material_id = item.material_id,
num = num,
batch = item.code_batch,
batch = wmsCarryCode.code_batch,
unit_id = item.unit_id,
carry_id = carry.id,
status = "0",
use_num = 0,
});
// Tnb.WarehouseMgr.Entities.Dto.Outputs.Result result = await _wmsCarryUnbindService.CarryUnbind(new CarryBindInput()
// {
// org = prdFeedingH.org_id,
// create_id = prdFeedingH.create_id,
// carry_id = prdFeedingH.carry_id,
// carry_code = prdFeedingH.carry_code,
// carrystd_id = carry.carrystd_id,
// membercarry_code = detail.member_carry_code,
// membercarry_id = detail.member_carry_id,
// });
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 (detail != null)
{
@@ -467,6 +461,32 @@ namespace Tnb.ProductionMgr
.SetColumns(x => x.feeding_num == x.feeding_num + num)
.Where(x => x.id == detail.id)
.ExecuteCommandAsync();
if (detail.feeding_num + num < detail.num)
{
await db.Updateable<WmsCarryCode>()
.SetColumns(x => x.codeqty == x.codeqty - num)
.Where(x => x.carry_id == detail.member_carry_id)
.ExecuteCommandAsync();
}
else
{
// await db.Updateable<WmsCarryCode>()
// .SetColumns(x => x.codeqty == 0)
// .Where(x => x.carry_id == detail.member_carry_id)
// .ExecuteCommandAsync();
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);
}
}
}
}
else
@@ -475,6 +495,36 @@ namespace Tnb.ProductionMgr
}
}
if (prdMaterialReceiptH.first_feed)
{
List<PrdMaterialReceiptD> dList = await db.Queryable<PrdMaterialReceiptD>()
.Where(x => x.material_receipt_id == prdMaterialReceiptH.id).ToListAsync();
foreach (var item in dList)
{
Tnb.WarehouseMgr.Entities.Dto.Outputs.Result result2 = await _wmsCarryUnbindService.CarryUnbind(new CarryBindInput()
{
org = prdFeedingH.org_id,
create_id = prdFeedingH.create_id,
carry_id = prdFeedingH.carry_id,
carry_code = prdFeedingH.carry_code,
carrystd_id = carry.carrystd_id,
membercarry_code = item.member_carry_code,
membercarry_id = item.member_carry_id,
});
if (result2.code != JNPF.Common.Enums.HttpStatusCode.OK)
{
throw Oops.Bah(result2.msg);
}
}
await db.Updateable<PrdMaterialReceiptH>()
.SetColumns(x => x.first_feed == true)
.Where(x => x.id == prdMaterialReceiptH.id)
.ExecuteCommandAsync();
}
}
else
{
@@ -484,11 +534,19 @@ namespace Tnb.ProductionMgr
_ = await db.Insertable<PrdFeedingH>(prdFeedingH).ExecuteCommandAsync();
_ = await db.Insertable<PrdFeedingD>(list).ExecuteCommandAsync();
await db.Ado.CommitTranAsync();
});
}
catch (Exception e)
{
Log.Error(e.Message,e);
await db.Ado.RollbackTranAsync();
throw Oops.Bah(e.Message);
}
return !result.IsSuccess ? throw Oops.Bah(result.ErrorMessage) : (dynamic)(result.IsSuccess ? "投料成功" : result.ErrorMessage);
return "投料成功";
}
[HttpPost]

View File

@@ -432,8 +432,9 @@ namespace Tnb.ProductionMgr
.LeftJoin<PrdMo>((a, b, c, d) => a.mo_id == d.id)
.LeftJoin<BasProcess>((a, b, c, d, e) => a.process_id == e.id)
.LeftJoin<OrganizeEntity>((a, b,c,d,e,f) => a.workstation_id == f.Id)
.LeftJoin<UserEntity>((a, b,c,d,e,f,g)=>a.worker_id==g.Id)
.Where((a, b, c, d) => a.parent_id == mo_task_id)
.Select((a, b, c, d, e,f) => new PackSechelToBeIssueListOutput
.Select((a, b, c, d, e,f,g) => new PackSechelToBeIssueListOutput
{
mo_task_id = a.id,
mo_task_code = a.mo_task_code,
@@ -443,6 +444,7 @@ namespace Tnb.ProductionMgr
workline_name = c.FullName,
mo_task_status = a.mo_task_status,
workstation_name = f.FullName,
worker_name = g.RealName,
scheduled_qty = a.scheduled_qty,
plan_qty = d.plan_qty,
process_task_qty = a.process_task_qty,

View File

@@ -427,7 +427,7 @@ namespace Tnb.ProductionMgr
.LeftJoin<BasMaterialUnit>((a, b, c, d, e, f, g, h, i, j, k) => a.material_id == k.material_id && k.auxiliary_unit_id == "kg")
.LeftJoin<EqpDaq>((a, b, c, d, e, f, g, h, i, j, k, l) => a.eqp_id == l.equip_id && l.enabled == 1 && l.label_name.Contains("允许称重"))//注塑空满箱请求
// .Where((a, b) => a.workstation_id == input.stationId)
.Where((a, b) => a.worker_id == _userManager.UserId)
.Where((a, b) => a.worker_id == _userManager.UserId && (a.schedule_type==1 || (a.schedule_type==2 && a.parent_id!=null)))
.WhereIF(!string.IsNullOrEmpty(mo_task_code), a => a.mo_task_code.Contains(mo_task_code))
//.WhereIF(!string.IsNullOrEmpty(mo_task_status),a=>a.mo_task_status==mo_task_status)
.WhereIF(statusList.Count > 0, a => statusList.Contains(a.mo_task_status))