diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs index a3bd7c94..c157d61e 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs @@ -1664,12 +1664,30 @@ namespace Tnb.ProductionMgr location = await db.Queryable().SingleAsync(x=>x.id==equip.downmat_location_id); report.location_code = location.location_code; } + + string batch = ""; + + PrdMo mo = await _db.Queryable().SingleAsync(x => x.id == prdMoTask.mo_id); + if (mo.mo_type == DictConst.PrdMoTypeZS) + { + EqpEquipment equipment = await _db.Queryable().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().SingleAsync(x => x.id == prdMoTask.eqp_id); + ToolMolds toolMolds = await _db.Queryable().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().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().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().SingleAsync(x => x.id == prdMoTask.eqp_id); ToolMolds toolMolds = await _db.Queryable().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().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() - .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().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() + // .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().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}";