|
|
@@ -310,4 +310,85 @@ public sealed class AdoS0ReferenceChecker
|
|
|
|
|
|
return null;
|
|
|
}
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 单号类型(NbrTypeMaster)删除前引用检查。
|
|
|
+ /// 覆盖下游:单号规则(NbrControl.NbrType)。
|
|
|
+ /// </summary>
|
|
|
+ public async Task<(int Count, string Table)?> NbrTypeReferencesAsync(string? nbrType)
|
|
|
+ {
|
|
|
+ if (string.IsNullOrWhiteSpace(nbrType)) return null;
|
|
|
+
|
|
|
+ var ctrl = await _db.Queryable<AdoS0NbrControl>()
|
|
|
+ .Where(x => x.NbrType == nbrType)
|
|
|
+ .CountAsync();
|
|
|
+ if (ctrl > 0) return (ctrl, "单号规则 (NbrControl)");
|
|
|
+
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 生产线(LineMaster)删除前引用检查。
|
|
|
+ /// 覆盖下游:生产线物料(ProdLineDetail.Line)/ 线体岗位(LinePost.ProductionLineId)。
|
|
|
+ /// </summary>
|
|
|
+ public async Task<(int Count, string Table)?> ProductionLineReferencesAsync(long id, string? line)
|
|
|
+ {
|
|
|
+ if (!string.IsNullOrWhiteSpace(line))
|
|
|
+ {
|
|
|
+ var detail = await _db.Queryable<AdoS0ProdLineDetail>()
|
|
|
+ .Where(x => x.Line == line)
|
|
|
+ .CountAsync();
|
|
|
+ if (detail > 0) return (detail, "生产线物料 (ProdLineDetail.Line)");
|
|
|
+ }
|
|
|
+
|
|
|
+ var post = await _db.Queryable<AdoS0MfgLinePost>()
|
|
|
+ .Where(x => x.ProductionLineId == id)
|
|
|
+ .CountAsync();
|
|
|
+ if (post > 0) return (post, "线体岗位 (LinePost.ProductionLineId)");
|
|
|
+
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 雇员(EmployeeMaster)删除前引用检查。
|
|
|
+ /// 覆盖下游:物料职责(EmpWorkDutyMaster.Employee)。
|
|
|
+ /// </summary>
|
|
|
+ public async Task<(int Count, string Table)?> EmployeeReferencesAsync(string? employee)
|
|
|
+ {
|
|
|
+ if (string.IsNullOrWhiteSpace(employee)) return null;
|
|
|
+
|
|
|
+ var duty = await _db.Queryable<AdoS0EmpWorkDutyMaster>()
|
|
|
+ .Where(x => x.Employee == employee)
|
|
|
+ .CountAsync();
|
|
|
+ if (duty > 0) return (duty, "物料职责 (EmpWorkDutyMaster)");
|
|
|
+
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 人员技能(PersonSkill)删除前引用检查。
|
|
|
+ /// 覆盖下游:人员技能关系(EmpSkills.SkillNo=Code)/ 产线岗位技能明细(LineSkillDetail.PersonSkillId=Id)/ 人员技能分配(PersonSkillAssignment.SkillId=Id)。
|
|
|
+ /// </summary>
|
|
|
+ public async Task<(int Count, string Table)?> PersonSkillReferencesAsync(long id, string? code)
|
|
|
+ {
|
|
|
+ if (!string.IsNullOrWhiteSpace(code))
|
|
|
+ {
|
|
|
+ var emp = await _db.Queryable<AdoS0EmpSkills>()
|
|
|
+ .Where(x => x.SkillNo == code)
|
|
|
+ .CountAsync();
|
|
|
+ if (emp > 0) return (emp, "人员技能关系 (EmpSkills.SkillNo)");
|
|
|
+ }
|
|
|
+
|
|
|
+ var lineSkill = await _db.Queryable<AdoS0LineSkillDetail>()
|
|
|
+ .Where(x => x.PersonSkillId == id)
|
|
|
+ .CountAsync();
|
|
|
+ if (lineSkill > 0) return (lineSkill, "产线岗位技能明细 (LineSkillDetail)");
|
|
|
+
|
|
|
+ var assign = await _db.Queryable<AdoS0MfgPersonSkillAssignment>()
|
|
|
+ .Where(x => x.SkillId == id)
|
|
|
+ .CountAsync();
|
|
|
+ if (assign > 0) return (assign, "人员技能分配 (PersonSkillAssignment)");
|
|
|
+
|
|
|
+ return null;
|
|
|
+ }
|
|
|
}
|