首末巡检自动自检报废 设备相关报表
This commit is contained in:
@@ -60,36 +60,74 @@ namespace Tnb.ProductionMgr
|
||||
List<ErpExtendField> extendFieldList = new List<ErpExtendField>();
|
||||
foreach (var item in input)
|
||||
{
|
||||
if(string.IsNullOrEmpty(item.mo_code))
|
||||
if (string.IsNullOrEmpty(item.mo_code))
|
||||
{
|
||||
Log.Error("【SavePrdMo】工单代码不能为空");
|
||||
throw Oops.Bah("工单代码不能为空");
|
||||
if(string.IsNullOrEmpty(item.mo_type))
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(item.mo_type))
|
||||
{
|
||||
Log.Error("【SavePrdMo】工单类型不能为空");
|
||||
throw Oops.Bah("工单类型不能为空");
|
||||
if(item.plan_start_date==null)
|
||||
}
|
||||
|
||||
if (item.plan_start_date == null)
|
||||
{
|
||||
Log.Error("【SavePrdMo】计划开始日期不能为空");
|
||||
throw Oops.Bah("计划开始日期不能为空");
|
||||
if(item.plan_end_date==null)
|
||||
}
|
||||
|
||||
if (item.plan_end_date == null)
|
||||
{
|
||||
Log.Error("【SavePrdMo】计划结束日期不能为空");
|
||||
throw Oops.Bah("计划结束日期不能为空");
|
||||
if(string.IsNullOrEmpty(item.material_code))
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(item.material_code))
|
||||
{
|
||||
Log.Error("【SavePrdMo】物料编号不能为空");
|
||||
throw Oops.Bah("物料编号不能为空");
|
||||
if(string.IsNullOrEmpty(item.unit_id))
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(item.unit_id))
|
||||
{
|
||||
Log.Error("【SavePrdMo】单位不能为空");
|
||||
throw Oops.Bah("单位不能为空");
|
||||
if(item.plan_qty==null || item.plan_qty<=0)
|
||||
}
|
||||
|
||||
if (item.plan_qty == null || item.plan_qty <= 0)
|
||||
{
|
||||
Log.Error("【SavePrdMo】计划数量不能为空");
|
||||
throw Oops.Bah("计划数量不能为空");
|
||||
if(item.ebom_version==null || item.ebom_version.IsEmpty())
|
||||
}
|
||||
|
||||
if (item.ebom_version == null || item.ebom_version.IsEmpty())
|
||||
{
|
||||
Log.Error("【SavePrdMo】物料清单版本不能为空");
|
||||
throw Oops.Bah("物料清单版本不能为空");
|
||||
}
|
||||
|
||||
BasMaterial basMaterial = await _db.Queryable<BasMaterial>().SingleAsync(x => x.code == item.material_code);
|
||||
if(basMaterial==null)
|
||||
if (basMaterial == null)
|
||||
{
|
||||
Log.Error($"【SavePrdMo】未找到物料编号为{item.material_code}的物料");
|
||||
throw Oops.Bah($"未找到物料编号为{item.material_code}的物料");
|
||||
}
|
||||
|
||||
List<BasMaterialUnit> basMaterialUnits = await _db.Queryable<BasMaterialUnit>().Where(x => x.material_id == basMaterial.id).ToListAsync();
|
||||
List<String> units = basMaterialUnits.Select(x => x.auxiliary_unit_id).Distinct().ToList();
|
||||
if(units!=null && !string.IsNullOrEmpty(basMaterial.unit_id)) units.Add(basMaterial.unit_id);
|
||||
|
||||
if(!units.Contains(item.unit_id))
|
||||
|
||||
if (!units.Contains(item.unit_id))
|
||||
{
|
||||
Log.Error($"【SavePrdMo】{basMaterial.name}不存在{item.unit_id}该单位");
|
||||
throw Oops.Bah($"{basMaterial.name}不存在{item.unit_id}该单位");
|
||||
}
|
||||
|
||||
if (!await _db.Queryable<BasEbomH>().AnyAsync(x => x.material_id == basMaterial.id && x.version == item.ebom_version))
|
||||
{
|
||||
Log.Error($"【SavePrdMo】系统中无法找到物料清单{item.ebom_version}版本");
|
||||
throw Oops.Bah($"系统中无法找到物料清单{item.ebom_version}版本");
|
||||
}
|
||||
|
||||
@@ -114,6 +152,15 @@ namespace Tnb.ProductionMgr
|
||||
{
|
||||
await _db.Insertable(moList).ExecuteCommandAsync();
|
||||
});
|
||||
if (result.IsSuccess)
|
||||
{
|
||||
Log.Information($"【SavePrdMo】生产工单保存成功");
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Error($"【SavePrdMo】{result.ErrorMessage}");
|
||||
throw Oops.Bah($"{result.ErrorMessage}");
|
||||
}
|
||||
|
||||
return !result.IsSuccess ? result.ErrorMessage : "保存成功";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user