This commit is contained in:
2024-07-19 17:22:08 +08:00
parent 5345400596
commit a239258646
3 changed files with 41 additions and 28 deletions

View File

@@ -942,41 +942,45 @@ namespace Tnb.ProductionMgr
{
BasEbomH basEbomH = await _db.Queryable<BasEbomH>().Where(x=>x.material_id==material.id && x.version==firstItemInList.HVERSION).FirstAsync();
if (basEbomH == null) continue;
bool flag = false;
List<BasEbomD> tempList = new List<BasEbomD>();
foreach (var children in itemList)
if (basEbomH.erp_modify_time != firstItemInList.MODIFIEDTIME)
{
BasMaterial childrenMaterial = materials.Find(x => x.code==children.SUBPRODID);
if (childrenMaterial == null)
bool flag = false;
List<BasEbomD> tempList = new List<BasEbomD>();
foreach (var children in itemList)
{
flag = true;
tempList = new List<BasEbomD>();
break;
BasMaterial childrenMaterial = materials.Find(x => x.code==children.SUBPRODID);
if (childrenMaterial == null)
{
flag = true;
tempList = new List<BasEbomD>();
break;
}
BasEbomD basEbomD = new BasEbomD()
{
id = SnowflakeIdHelper.NextId(),
ebom_id = basEbomH.id,
material_id = childrenMaterial.id,
denominator = children.DISHU,
molecule = children.BATCHAMOUNT,
};
tempList.Add(basEbomD);
}
BasEbomD basEbomD = new BasEbomD()
if (flag)
{
id = SnowflakeIdHelper.NextId(),
ebom_id = basEbomH.id,
material_id = childrenMaterial.id,
denominator = children.DISHU,
molecule = children.BATCHAMOUNT,
};
tempList.Add(basEbomD);
}
if (flag)
{
continue;
continue;
}
insertBasEbomDs.AddRange(tempList);
await _db.Updateable<BasEbomH>()
.SetColumns(x => x.unit_id == unitId)
.Where(x => x.id == basEbomH.id)
.ExecuteCommandAsync();
await _db.Deleteable<BasEbomD>().Where(x => x.ebom_id == basEbomH.id).ExecuteCommandAsync();
}
insertBasEbomDs.AddRange(tempList);
await _db.Updateable<BasEbomH>()
.SetColumns(x => x.unit_id == unitId)
.Where(x => x.id == basEbomH.id)
.ExecuteCommandAsync();
await _db.Deleteable<BasEbomD>().Where(x => x.ebom_id == basEbomH.id).ExecuteCommandAsync();
}
}