首末巡检自动自检报废 设备相关报表
This commit is contained in:
@@ -74,5 +74,7 @@ namespace Tnb.ProductionMgr.Interfaces
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
Task<dynamic> PrdTaskRelease2(PrdTaskReleaseUpInput input, ISqlSugarClient db = null);
|
||||
|
||||
public Task<dynamic> SelfTestScrapped2(SelfTestScrappedInput input, ISqlSugarClient db = null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 : "保存成功";
|
||||
}
|
||||
|
||||
@@ -73,6 +73,7 @@ namespace Tnb.ProductionMgr
|
||||
private static readonly Dictionary<string, object> _dicProcess = new();
|
||||
private readonly ISqlSugarClient _db;
|
||||
private ISqlSugarClient _db2;
|
||||
private ISqlSugarClient _db3;
|
||||
private readonly IBillRullService _billRuleService;
|
||||
private readonly IPrdInstockService _prdInstockService;
|
||||
private readonly WmsPrdInstockHService _wmsPrdInstockHService;
|
||||
@@ -1666,15 +1667,22 @@ namespace Tnb.ProductionMgr
|
||||
|
||||
if (qcCheckPlanAdds.Count == 1)
|
||||
{
|
||||
int hour = int.Parse(qcCheckPlanAdds[0].content.Split(" ")[2].Split("/")[1]);
|
||||
int minute = int.Parse(qcCheckPlanAdds[0].content.Split(" ")[1].Split("/")[1]);
|
||||
if (minute > 0)
|
||||
int hour = 0;
|
||||
int minute = 0;
|
||||
string hourStr = qcCheckPlanAdds[0].content.Split(" ")[2];
|
||||
string minuteStr = qcCheckPlanAdds[0].content.Split(" ")[1];
|
||||
if (hourStr.Contains("/"))
|
||||
{
|
||||
TimerPoolHelper.GetInstance().StartTimer(TimeCallback2,list.Where(p => p.mo_task_status == "Pause" || p.mo_task_status == "ToBeStarted").ToList(),TimeSpan.FromMinutes(minute),TimeSpan.FromMinutes(minute),false);
|
||||
}else if (hour > 0)
|
||||
{
|
||||
TimerPoolHelper.GetInstance().StartTimer(TimeCallback2,list.Where(p => p.mo_task_status == "Pause" || p.mo_task_status == "ToBeStarted").ToList(),TimeSpan.FromHours(hour),TimeSpan.FromHours(hour),false);
|
||||
hour = int.Parse(hourStr.Split("/")[1]);
|
||||
}
|
||||
|
||||
if (minuteStr.Contains("/"))
|
||||
{
|
||||
minute = int.Parse(minuteStr.Split("/")[1]);
|
||||
}
|
||||
|
||||
int totalMonute = hour * 60 + minute;
|
||||
TimerPoolHelper.GetInstance().StartTimer(TimeCallback2,list.Where(p => p.mo_task_status == "Pause" || p.mo_task_status == "ToBeStarted").ToList(),TimeSpan.FromMinutes(totalMonute),TimeSpan.FromMinutes(totalMonute),false);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1710,7 +1718,14 @@ namespace Tnb.ProductionMgr
|
||||
await PrdTaskRelease(input);
|
||||
return "保存成功";
|
||||
}
|
||||
|
||||
|
||||
public async Task<dynamic> SelfTestScrapped2(SelfTestScrappedInput input, ISqlSugarClient db = null)
|
||||
{
|
||||
this._db3 = db;
|
||||
await SelfTestScrapped(input);
|
||||
return "保存成功";
|
||||
}
|
||||
|
||||
public async void TimeCallback(object args)
|
||||
{
|
||||
try
|
||||
@@ -2089,7 +2104,8 @@ namespace Tnb.ProductionMgr
|
||||
throw Oops.Bah($"提报失败,载具异常");
|
||||
}
|
||||
|
||||
bool isCheckFlag = !basMaterial.category_id.Contains("ZZCP");
|
||||
// bool isCheckFlag = !basMaterial.category_id.Contains("ZZCP");
|
||||
bool isCheckFlag = !basMaterial.category_id.Contains("ZSJ");
|
||||
|
||||
#region 质检模块
|
||||
//质检模块
|
||||
@@ -2648,13 +2664,26 @@ namespace Tnb.ProductionMgr
|
||||
[HttpPost]
|
||||
public async Task<dynamic> SelfTestScrapped(SelfTestScrappedInput input)
|
||||
{
|
||||
ISqlSugarClient db = _repository.AsSugarClient();
|
||||
bool tranFlag = true;
|
||||
ISqlSugarClient db = null;
|
||||
if (_db3!=null)
|
||||
{
|
||||
tranFlag = false;
|
||||
db = _db3;
|
||||
}
|
||||
else
|
||||
{
|
||||
db = _repository.AsSugarClient();
|
||||
}
|
||||
|
||||
if (await db.Queryable<PrdMoTask>().AnyAsync(x => x.id == input.mo_task_id && x.mo_task_status == DictConst.MoStatusPauseCode))
|
||||
{
|
||||
throw Oops.Bah("暂停的任务单无法报废");
|
||||
}
|
||||
|
||||
DbResult<bool> result = await db.Ado.UseTranAsync(async () =>
|
||||
if(tranFlag) await db.Ado.BeginTranAsync();
|
||||
|
||||
try
|
||||
{
|
||||
List<PrdMoTaskDefect> destDefects = new();
|
||||
string batch = DateTime.Now.ToString("yyyyMMddHHmmss");
|
||||
@@ -2772,9 +2801,16 @@ namespace Tnb.ProductionMgr
|
||||
.Where(x => x.id == input.mo_task_id).ExecuteCommandAsync();
|
||||
}
|
||||
}
|
||||
if(tranFlag) await db.Ado.CommitTranAsync();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
if(tranFlag) await db.Ado.RollbackTranAsync();
|
||||
Log.Error(e.Message,e);
|
||||
throw Oops.Bah(e.Message);
|
||||
}
|
||||
|
||||
});
|
||||
return result.IsSuccess;
|
||||
return true;
|
||||
}
|
||||
/// <summary>
|
||||
/// 修改组装、包装,生产任务信息
|
||||
|
||||
Reference in New Issue
Block a user