修改生成规则

This commit is contained in:
tongfei
2024-02-18 16:53:18 +08:00
parent 8a3d4343a3
commit b3190e67e7
13 changed files with 332 additions and 85 deletions

View File

@@ -71,7 +71,11 @@ namespace WMS.Web.Repositories
if (staffList != null)
cr_ids = staffList.Where(w => w.Name.Contains(dto.Creator)).Select(s => s.Id).ToList();
}
var query = _context.BoxMark.Where(adv => 1 == 1);
//var query = _context.BoxMark.Where(adv => 1 == 1);
var query = _context.BoxMarkBillNo
.GroupJoin(_context.BoxMark, detail => detail.Fid, order => order.Id, (detail, orders) => new { detail, orders })
.SelectMany(x => x.orders.DefaultIfEmpty(), (p, order) => new { p.detail, order })
.Where(adv => 1 == 1);
//编号查询
if (!string.IsNullOrEmpty(dto.BeginBillNo) &&
@@ -85,15 +89,15 @@ namespace WMS.Web.Repositories
var begNo = Convert.ToInt32(dto.BeginBillNo.Substring(8));
var endNo = Convert.ToInt32(dto.EndBillNo.Substring(8));
query = query.Where(w => w.FirstBillNo >= begYMD && w.FirstBillNo <= endYMD && w.LastBillNo >= begNo && w.LastBillNo <= endNo);
query = query.Where(w => w.detail.FirstBillNo >= begYMD && w.detail.FirstBillNo <= endYMD && w.detail.LastBillNo >= begNo && w.detail.LastBillNo <= endNo);
}
else
query = query.Where(w => w.BillNo == dto.BeginBillNo || w.BillNo == dto.EndBillNo);
query = query.Where(w => w.detail.BillNo == dto.BeginBillNo || w.detail.BillNo == dto.EndBillNo);
}
else if (!string.IsNullOrEmpty(dto.BeginBillNo))
query = query.Where(w => w.BillNo == dto.BeginBillNo);
query = query.Where(w => w.detail.BillNo == dto.BeginBillNo);
else if (!string.IsNullOrEmpty(dto.EndBillNo))
query = query.Where(w => w.BillNo == dto.EndBillNo);
query = query.Where(w => w.detail.BillNo == dto.EndBillNo);
//订单号查询
@@ -103,7 +107,7 @@ namespace WMS.Web.Repositories
var orderBillNoList = orderBNS.Split(",").Where(x => !string.IsNullOrEmpty(x)).ToList();
if (orderBillNoList != null && orderBillNoList.Count != 0)
{
query = query.Where(w => orderBillNoList.Contains(w.OrderBillNo));
query = query.Where(w => orderBillNoList.Contains(w.order.OrderBillNo));
}
}
@@ -113,41 +117,42 @@ namespace WMS.Web.Repositories
if (materials != null && materials.Count != 0)
{
var mids = materials.Select(x => x.MaterialId).ToList();
query = query.Where(w => mids.Contains(w.MaterialId));
query = query.Where(w => mids.Contains(w.order.MaterialId));
}
}
if (cr_ids.Count != 0)
query = query.Where(w => cr_ids.Contains(w.CreatorId));
query = query.Where(w => cr_ids.Contains(w.order.CreatorId));
if (dto.BeginDate != null)
query = query.Where(w => w.CreateTime.Date >= dto.BeginDate.Value);
query = query.Where(w => w.order.CreateTime.Date >= dto.BeginDate.Value);
if (dto.EndDate != null)
query = query.Where(w => w.CreateTime.Date <= dto.EndDate.Value);
query = query.Where(w => w.order.CreateTime.Date <= dto.EndDate.Value);
int total = await query.CountAsync();
var list = await query.Select(s => new BoxMarkQueryResponse()
{
Id = s.Id,
BillNo = s.BillNo,
OrderBillNo = s.OrderBillNo,
MaterialName = _erpBasicDataExtendService.GetMaterialName(materials, s.MaterialId),
MaterialNumber = _erpBasicDataExtendService.GetMaterialNumber(materials, s.MaterialId),
Specifications = _erpBasicDataExtendService.GetMaterialSpecifications(materials, s.MaterialId),
BarCode = _erpBasicDataExtendService.GetMaterialBarCode(materials, s.MaterialId),
Id = s.order.Id,
DetailId=s.detail.Id,
BillNo = s.detail.BillNo,
OrderBillNo = s.order.OrderBillNo,
MaterialName = _erpBasicDataExtendService.GetMaterialName(materials, s.order.MaterialId),
MaterialNumber = _erpBasicDataExtendService.GetMaterialNumber(materials, s.order.MaterialId),
Specifications = _erpBasicDataExtendService.GetMaterialSpecifications(materials, s.order.MaterialId),
BarCode = _erpBasicDataExtendService.GetMaterialBarCode(materials, s.order.MaterialId),
CratingQty = s.CratingQty,
CratingNetWeightQty = s.CratingNetWeightQty,
CratingGrossWeightQty = s.CratingGrossWeightQty,
CratingQty = s.order.CratingQty,
CratingNetWeightQty = s.order.CratingNetWeightQty,
CratingGrossWeightQty = s.order.CratingGrossWeightQty,
TailboxQty = s.TailboxQty,
TailboxNetWeightQty = s.TailboxNetWeightQty,
TailboxGrossWeightQty = s.TailboxGrossWeightQty,
TailboxQty = s.order.TailboxQty,
TailboxNetWeightQty = s.order.TailboxNetWeightQty,
TailboxGrossWeightQty = s.order.TailboxGrossWeightQty,
Creator = _singleDataService.GetSingleData(SingleAction.Staffs, companyId, s.CreatorId),
CreateTime = s.CreateTime.ToString("yyyy-MM-dd HH:mm:ss"),
Remark = s.Remark
}).OrderByDescending(x => x.Id).Skip((dto.PageNo - 1) * dto.PageSize).Take(dto.PageSize).ToListAsync();
Creator = _singleDataService.GetSingleData(SingleAction.Staffs, companyId, s.order.CreatorId),
CreateTime = s.order.CreateTime.ToString("yyyy-MM-dd HH:mm:ss"),
Remark = s.order.Remark
}).OrderByDescending(x => x.DetailId).Skip((dto.PageNo - 1) * dto.PageSize).Take(dto.PageSize).ToListAsync();
return (list, total);
}
@@ -158,7 +163,7 @@ namespace WMS.Web.Repositories
/// <param name="entity"></param>
/// <param name="isTransaction"></param>
/// <returns></returns>
public async Task<bool> Add(BoxMark entity, bool isTransaction = true)
public async Task<BoxMark> Add(BoxMark entity, bool isTransaction = true)
{
IDbContextTransaction _transaction = null;
if (isTransaction)
@@ -169,13 +174,13 @@ namespace WMS.Web.Repositories
await _context.SaveChangesAsync();
if (_transaction != null)
_transaction.Commit();
return true;
return entity;
}
catch (Exception ex)
{
if (_transaction != null)
_transaction.Rollback();
return false;
return null;
}
}
@@ -191,6 +196,59 @@ namespace WMS.Web.Repositories
return entity;
}
/// <summary>
/// 列表-详情信息列表
/// </summary>
/// <param name="id"></param>
/// <param name="companyId"></param>
/// <returns></returns>
public async Task<List<BoxMarkQueryResponse>> GetListInfoBy(int id, int companyId)
{
//1.获取物料集合和组织集合和供应商的集合
var materials = new List<ErpMaterialDto>();
var materials_result = await _erpService.BillQueryForMaterial();
if (materials_result.IsSuccess)
materials = materials_result.Data.ToList();
var query = _context.BoxMarkBillNo
.GroupJoin(_context.BoxMark, detail => detail.Fid, order => order.Id, (detail, orders) => new { detail, orders })
.SelectMany(x => x.orders.DefaultIfEmpty(), (p, order) => new { p.detail, order })
.Where(adv => adv.order.Id == id);
var list = await query.Select(s => new BoxMarkQueryResponse()
{
Id = s.order.Id,
DetailId = s.detail.Id,
BillNo = s.detail.BillNo,
OrderBillNo = s.order.OrderBillNo,
MaterialName = _erpBasicDataExtendService.GetMaterialName(materials, s.order.MaterialId),
MaterialNumber = _erpBasicDataExtendService.GetMaterialNumber(materials, s.order.MaterialId),
Specifications = _erpBasicDataExtendService.GetMaterialSpecifications(materials, s.order.MaterialId),
BarCode = _erpBasicDataExtendService.GetMaterialBarCode(materials, s.order.MaterialId),
CratingQty = s.order.CratingQty,
CratingNetWeightQty = s.order.CratingNetWeightQty,
CratingGrossWeightQty = s.order.CratingGrossWeightQty,
TailboxQty = s.order.TailboxQty,
TailboxNetWeightQty = s.order.TailboxNetWeightQty,
TailboxGrossWeightQty = s.order.TailboxGrossWeightQty,
Creator = _singleDataService.GetSingleData(SingleAction.Staffs, companyId, s.order.CreatorId),
CreateTime = s.order.CreateTime.ToString("yyyy-MM-dd HH:mm:ss"),
Remark = s.order.Remark
}).OrderByDescending(x => x.DetailId).ToListAsync();
return list;
}
/// <summary>
/// 详情-根据最新的ID
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public async Task<BoxMarkBillNo> GetLastBillNo()
{
var entity = await _context.BoxMarkBillNo.OrderByDescending(x => x.Id).FirstOrDefaultAsync();
return entity;
}
/// <summary>
/// 批量删除
/// </summary>
@@ -203,7 +261,7 @@ namespace WMS.Web.Repositories
_transaction = _context.Database.BeginTransaction();
try
{
var list = await _context.BoxMark.Where(f => ids.Contains(f.Id)).ToListAsync();
var list = await _context.BoxMark.Include(x=>x.BillNos).Where(f => ids.Contains(f.Id)).ToListAsync();
_context.BoxMark.RemoveRange(list);
await _context.SaveChangesAsync();

View File

@@ -356,11 +356,24 @@ namespace WMS.Web.Repositories.Configuration
{
ent.ToTable("t_wms_box_mark");
ent.HasKey(x => x.Id);
ent.HasMany(p => p.BillNos)
.WithOne()
.HasForeignKey(p => p.Fid)
.OnDelete(DeleteBehavior.Cascade);
});
//箱唛表-编号表
builder.Entity<BoxMarkBillNo>(ent =>
{
ent.ToTable("t_wms_box_mark_billno");
ent.HasKey(x => x.Id);
});
base.OnModelCreating(builder);
}
public DbSet<BoxMarkBillNo> BoxMarkBillNo { get; set; }
public DbSet<BoxMark> BoxMark { get; set; }
public DbSet<FileDownManager> FileDownManager { get; set; }
public DbSet<SerialNumbers> SerialNumbers { get; set; }