批次调整

This commit is contained in:
2024-06-14 11:51:37 +08:00
parent ab0b4bedf4
commit c0d05ef133

View File

@@ -1665,11 +1665,29 @@ namespace Tnb.ProductionMgr
report.location_code = location.location_code;
}
string batch = "";
PrdMo mo = await _db.Queryable<PrdMo>().SingleAsync(x => x.id == prdMoTask.mo_id);
if (mo.mo_type == DictConst.PrdMoTypeZS)
{
EqpEquipment equipment = await _db.Queryable<EqpEquipment>().SingleAsync(x => x.id == prdMoTask.eqp_id);
batch = $"{equipment.code.Substring(equipment.code.Length - 2, 2)}{DateTime.Now.ToString("yyMMdd")}";
}else if (mo.mo_type == DictConst.PrdMoTypeJC)
{
EqpEquipment equipment = await _db.Queryable<EqpEquipment>().SingleAsync(x => x.id == prdMoTask.eqp_id);
ToolMolds toolMolds = await _db.Queryable<ToolMolds>().SingleAsync(x => x.id == prdMoTask.mold_id);
batch = $"{toolMolds.mold_code.Substring(toolMolds.mold_code.Length - 2, 2)}{equipment.code.Substring(equipment.code.Length - 2, 2)}{DateTime.Now.ToString("yyMMdd")}";
}else
{
OrganizeEntity organizeEntity = await _db.Queryable<OrganizeEntity>().SingleAsync(x => x.Id == prdMoTask.workline_id);
batch = $"{organizeEntity.EnCode.Substring(organizeEntity.EnCode.Length - 2, 2)}{DateTime.Now.ToString("yyMMdd")}";
}
// report.location_code = input.location_code;
report.create_id = _userManager.UserId;
report.create_time = DateTime.Now;
// report.batch = input.mo_task_code + DateTimeOffset.Now.ToUnixTimeSeconds().ToString();
report.batch = batch;
report.barcode = input.mo_task_code + DateTimeOffset.Now.ToUnixTimeSeconds().ToString();
report.barqty = mbom.full_qty;
// report.barcode = input.mo_task_code+"0001";
@@ -1938,7 +1956,7 @@ namespace Tnb.ProductionMgr
{
planqty = prdMoTask.scheduled_qty.Value,
pqty = input.reported_qty,
code_batch = prdMoTask.batch,
code_batch = batch,
code = report.barcode,
unit_id = prdMoTask.unit_id,
carry_id = wmsCarryH.id,
@@ -3227,44 +3245,46 @@ namespace Tnb.ProductionMgr
if (mo.mo_type == DictConst.PrdMoTypeZS)
{
EqpEquipment equipment = await _db.Queryable<EqpEquipment>().SingleAsync(x => x.id == prdMoTask.eqp_id);
batch = $"{equipment.code}{DateTime.Now.ToString("yyMMdd")}";
batch = $"{equipment.code.Substring(equipment.code.Length - 2, 2)}{DateTime.Now.ToString("yyMMdd")}";
}else if (mo.mo_type == DictConst.PrdMoTypeJC)
{
EqpEquipment equipment = await _db.Queryable<EqpEquipment>().SingleAsync(x => x.id == prdMoTask.eqp_id);
ToolMolds toolMolds = await _db.Queryable<ToolMolds>().SingleAsync(x => x.id == prdMoTask.mold_id);
batch = $"{toolMolds.mold_code}{equipment.code}{DateTime.Now.ToString("yyMMdd")}";
batch = $"{toolMolds.mold_code.Substring(toolMolds.mold_code.Length - 2, 2)}{equipment.code.Substring(equipment.code.Length - 2, 2)}{DateTime.Now.ToString("yyMMdd")}";
}else
{
LableRecord lableRecord = await _db.Queryable<LableRecord>().FirstAsync();
if (lableRecord == null)
{
batch = $"{DateTime.Now.ToString("yyMMdd")}5{"1".PadLeft(3,'0')}";
await _db.Insertable(new LableRecord()
{
id = SnowflakeIdHelper.NextId(),
last_day = DateTime.Now.ToString("yyyyMMdd"),
num = 1
}).ExecuteCommandAsync();
}
else
{
int num = 1;
if(DateTime.Now.ToString("yyyyMMdd") == lableRecord.last_day)
{
num = lableRecord.num+1;
batch = $"{DateTime.Now.ToString("yyMMdd")}5{(lableRecord.num+1).ToString().PadLeft(3,'0')}";
}
else
{
batch = $"{DateTime.Now.ToString("yyMMdd")}5{"1".PadLeft(3,'0')}";
}
await _db.Updateable<LableRecord>()
.SetColumns(x=>x.last_day==DateTime.Now.ToString("yyyyMMdd"))
.SetColumns(x=>x.num==num)
.Where(x=>x.id==lableRecord.id)
.ExecuteCommandAsync();
}
// LableRecord lableRecord = await _db.Queryable<LableRecord>().FirstAsync();
// if (lableRecord == null)
// {
// batch = $"{DateTime.Now.ToString("yyMMdd")}5{"1".PadLeft(3,'0')}";
// await _db.Insertable(new LableRecord()
// {
// id = SnowflakeIdHelper.NextId(),
// last_day = DateTime.Now.ToString("yyyyMMdd"),
// num = 1
// }).ExecuteCommandAsync();
// }
// else
// {
// int num = 1;
// if(DateTime.Now.ToString("yyyyMMdd") == lableRecord.last_day)
// {
// num = lableRecord.num+1;
// batch = $"{DateTime.Now.ToString("yyMMdd")}5{(lableRecord.num+1).ToString().PadLeft(3,'0')}";
// }
// else
// {
// batch = $"{DateTime.Now.ToString("yyMMdd")}5{"1".PadLeft(3,'0')}";
// }
//
// await _db.Updateable<LableRecord>()
// .SetColumns(x=>x.last_day==DateTime.Now.ToString("yyyyMMdd"))
// .SetColumns(x=>x.num==num)
// .Where(x=>x.id==lableRecord.id)
// .ExecuteCommandAsync();
// }
OrganizeEntity organizeEntity = await _db.Queryable<OrganizeEntity>().SingleAsync(x => x.Id == prdMoTask.workline_id);
batch = $"{organizeEntity.EnCode.Substring(organizeEntity.EnCode.Length - 2, 2)}{DateTime.Now.ToString("yyMMdd")}";
}
string code = $"(01){basMaterial.di ?? ""}*(11){DateTime.Now.ToString("yyMMdd")}*(17){DateTime.Now.AddMonths(basMaterial.quality_guarantee_period ?? 0).ToString("yyMMdd")}*(10){batch}#{basMaterial.material_specification}*{batch}*{DateTime.Now.ToString("yyyyMMdd")}*{DateTime.Now.AddMonths(basMaterial.quality_guarantee_period ?? 0).ToString("yyyyMMdd")}*{basMaterial.container_no}";