fix(predesign): 修复包装与车次关联数据一致性问题
包装管理存在两个一致性问题:一是组件可重复进入其他包装,导致 组件归属冲突;二是删除车次后包装仍保留旧车次关联,产生脏数据。 本次修改统一补齐校验和解绑逻辑,避免包装与发货数据出现错误关联。
This commit is contained in:
parent
8d4bcf041d
commit
a694ab1183
|
|
@ -143,6 +143,15 @@ namespace BLL
|
||||||
/// <exception cref="Exception">当该预制组件已被包装时抛出异常</exception>
|
/// <exception cref="Exception">当该预制组件已被包装时抛出异常</exception>
|
||||||
public static void AddPipelineComponentToPackaging(string packagingManageId, string pipelineComponentId)
|
public static void AddPipelineComponentToPackaging(string packagingManageId, string pipelineComponentId)
|
||||||
{
|
{
|
||||||
|
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||||||
|
{
|
||||||
|
bool existsInCurrentPackaging = db.HJGL_PackagingManageDetail.Any(x => x.PackagingManageId == packagingManageId && x.PipelineComponentId == pipelineComponentId);
|
||||||
|
if (existsInCurrentPackaging)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ValidatePipelineComponentsNotInOtherPackaging(pipelineComponentId);
|
||||||
|
|
||||||
var ComponentModel = BLL.HJGL_PipelineComponentService.GetPipelineComponentById(pipelineComponentId);
|
var ComponentModel = BLL.HJGL_PipelineComponentService.GetPipelineComponentById(pipelineComponentId);
|
||||||
if (ComponentModel != null)
|
if (ComponentModel != null)
|
||||||
{
|
{
|
||||||
|
|
@ -155,7 +164,9 @@ namespace BLL
|
||||||
CreateTime = DateTime.Now,
|
CreateTime = DateTime.Now,
|
||||||
CreateUser = null,
|
CreateUser = null,
|
||||||
};
|
};
|
||||||
HJGLPackagingmanagedetailService.Add(model);
|
db.HJGL_PackagingManageDetail.InsertOnSubmit(model);
|
||||||
|
db.SubmitChanges();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -172,6 +183,7 @@ namespace BLL
|
||||||
db1.HJGL_PackagingManage.DeleteOnSubmit(table);
|
db1.HJGL_PackagingManage.DeleteOnSubmit(table);
|
||||||
db1.SubmitChanges();
|
db1.SubmitChanges();
|
||||||
}
|
}
|
||||||
|
HJGLPackagingmanagedetailService.DeleteByPackagingManageId(PackagingManageId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -632,6 +644,11 @@ namespace BLL
|
||||||
}
|
}
|
||||||
|
|
||||||
// 创建新的包装明细记录
|
// 创建新的包装明细记录
|
||||||
|
var addedComponentIds = allComponentIds.Except(existingComponentIds).ToList();
|
||||||
|
foreach (var item in addedComponentIds)
|
||||||
|
{
|
||||||
|
ValidatePipelineComponentsNotInOtherPackaging(item);
|
||||||
|
}
|
||||||
var newDetailList = new List<Model.HJGL_PackagingManageDetail>();
|
var newDetailList = new List<Model.HJGL_PackagingManageDetail>();
|
||||||
foreach (var item in allComponentIds)
|
foreach (var item in allComponentIds)
|
||||||
{
|
{
|
||||||
|
|
@ -671,6 +688,28 @@ namespace BLL
|
||||||
/// 获取包装状态下拉框选项
|
/// 获取包装状态下拉框选项
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>包装状态列表,包含状态文本和值的映射关系</returns>
|
/// <returns>包装状态列表,包含状态文本和值的映射关系</returns>
|
||||||
|
private static void ValidatePipelineComponentsNotInOtherPackaging(string pipelineComponentId)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(pipelineComponentId))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var existDetail = (from detail in Funs.DB.HJGL_PackagingManageDetail
|
||||||
|
join pack in Funs.DB.HJGL_PackagingManage on detail.PackagingManageId equals pack.PackagingManageId
|
||||||
|
where detail.PipelineComponentId == pipelineComponentId
|
||||||
|
select new
|
||||||
|
{
|
||||||
|
detail.PipelineComponentId,
|
||||||
|
PackagingCode = pack == null ? null : pack.PackagingCode
|
||||||
|
}).FirstOrDefault();
|
||||||
|
if (existDetail != null)
|
||||||
|
{
|
||||||
|
string packagingCodeText = string.IsNullOrEmpty(existDetail.PackagingCode) ? string.Empty : (",包装编号:" + existDetail.PackagingCode);
|
||||||
|
throw new Exception("组件已在其他包装中存在" + packagingCodeText + "。");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static ListItem[] GetState()
|
public static ListItem[] GetState()
|
||||||
{
|
{
|
||||||
ListItem[] list = new ListItem[3];
|
ListItem[] list = new ListItem[3];
|
||||||
|
|
|
||||||
|
|
@ -144,11 +144,19 @@ namespace BLL
|
||||||
|
|
||||||
public static void DeleteById(string Id)
|
public static void DeleteById(string Id)
|
||||||
{
|
{
|
||||||
Model.HJGL_TrainNumberManage table = Funs.DB.HJGL_TrainNumberManage.FirstOrDefault(x => x.Id == Id);
|
var db = Funs.DB;
|
||||||
|
Model.HJGL_TrainNumberManage table = db.HJGL_TrainNumberManage.FirstOrDefault(x => x.Id == Id);
|
||||||
if (table != null)
|
if (table != null)
|
||||||
{
|
{
|
||||||
Funs.DB.HJGL_TrainNumberManage.DeleteOnSubmit(table);
|
var packagingList = db.HJGL_PackagingManage.Where(x => x.TrainNumberId == Id).ToList();
|
||||||
Funs.DB.SubmitChanges();
|
foreach (var item in packagingList)
|
||||||
|
{
|
||||||
|
item.TrainNumberId = null;
|
||||||
|
item.TrainNumber = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
db.HJGL_TrainNumberManage.DeleteOnSubmit(table);
|
||||||
|
db.SubmitChanges();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue