油漆
This commit is contained in:
141
server/ZR.Service/mes/wms/WmMaterialService.cs
Normal file
141
server/ZR.Service/mes/wms/WmMaterialService.cs
Normal file
@@ -0,0 +1,141 @@
|
||||
using System;
|
||||
using SqlSugar;
|
||||
using Infrastructure.Attribute;
|
||||
using Infrastructure.Extensions;
|
||||
using ZR.Model;
|
||||
using ZR.Model.Dto;
|
||||
|
||||
using ZR.Repository;
|
||||
|
||||
using System.Linq;
|
||||
using ZR.Service.mes.wms.IService;
|
||||
using ZR.Model.MES.wms;
|
||||
using ZR.Model.MES.wms.Dto;
|
||||
|
||||
namespace ZR.Service.mes.wms
|
||||
{
|
||||
/// <summary>
|
||||
/// 物料记录表Service业务层处理
|
||||
/// </summary>
|
||||
[AppService(ServiceType = typeof(IWmMaterialService), ServiceLifetime = LifeTime.Transient)]
|
||||
public class WmMaterialService : BaseService<WmMaterial>, IWmMaterialService
|
||||
{
|
||||
/// <summary>
|
||||
/// 查询物料记录表列表
|
||||
/// </summary>
|
||||
/// <param name="parm"></param>
|
||||
/// <returns></returns>
|
||||
public PagedInfo<WmMaterialDto> GetList(WmMaterialQueryDto parm)
|
||||
{
|
||||
var predicate = Expressionable.Create<WmMaterial>()
|
||||
.AndIF(parm.Partnumber != null, it => it.Partnumber.Contains(parm.Partnumber))
|
||||
.AndIF(parm.U8InventoryCode != null, it => it.U8InventoryCode.Contains(parm.U8InventoryCode))
|
||||
.AndIF(parm.ProductName != null, it => it.ProductName.Contains(parm.ProductName))
|
||||
.AndIF(parm.Color != null, it => it.Color.Contains(parm.Color))
|
||||
.AndIF(parm.Specification != null, it => it.Specification.Contains(parm.Specification))
|
||||
.AndIF(parm.Description != null, it => it.Description.Contains(parm.Description))
|
||||
.AndIF(!string.IsNullOrEmpty( parm.Search1), it => it.Search1.Contains(parm.Search1) || it.Search1.Contains(parm.Search2))
|
||||
.AndIF(parm.Type > 0, it => it.Type == parm.Type)
|
||||
.AndIF(parm.Status > -1, it => it.Status == parm.Status);
|
||||
|
||||
|
||||
var response = Queryable()
|
||||
.Where(predicate.ToExpression()).OrderByDescending(it=>it.CreatedTime)
|
||||
.ToPage<WmMaterial, WmMaterialDto>(parm);
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取详情
|
||||
/// </summary>
|
||||
/// <param name="Id"></param>
|
||||
/// <returns></returns>
|
||||
public WmMaterial GetInfo(string Id)
|
||||
{
|
||||
var response = Queryable()
|
||||
.Where(x => x.Id == Id)
|
||||
.First();
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加物料记录表
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
/// <returns></returns>
|
||||
public WmMaterial AddWmMaterial(WmMaterial model)
|
||||
{
|
||||
model.Id= SnowFlakeSingle.Instance.NextId().ToString();
|
||||
return Context.Insertable(model).ExecuteReturnEntity();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 修改物料记录表
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
/// <returns></returns>
|
||||
public int UpdateWmMaterial(WmMaterial model)
|
||||
{
|
||||
//var response = Update(w => w.Id == model.Id, it => new WmMaterial()
|
||||
//{
|
||||
// Partnumber = model.Partnumber,
|
||||
// U8InventoryCode = model.U8InventoryCode,
|
||||
// BlankNum = model.BlankNum,
|
||||
// Unit = model.Unit,
|
||||
// ProductName = model.ProductName,
|
||||
// Color = model.Color,
|
||||
// Specification = model.Specification,
|
||||
// Description = model.Description,
|
||||
// Version = model.Version,
|
||||
// Remarks = model.Remarks,
|
||||
// Sort = model.Sort,
|
||||
// Search1 = model.Search1,
|
||||
// Search2 = model.Search2,
|
||||
// Status = model.Status,
|
||||
// CreatedBy = model.CreatedBy,
|
||||
// CreatedTime = model.CreatedTime,
|
||||
// UpdatedBy = model.UpdatedBy,
|
||||
// UpdatedTime = model.UpdatedTime,
|
||||
//});
|
||||
//return response;
|
||||
return Update(model, true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 通过外箱标签解析后得到的批次号,获取货物仓库内的货物信息
|
||||
/// </summary>
|
||||
/// <param name="patchCode"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public WmGoodsNowProduction GetInfoByPatchCode(string patchCode)
|
||||
{
|
||||
return Context.Queryable<WmGoodsNowProduction>()
|
||||
.Where(it => it.PackageCodeClient == patchCode).First();
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// excel 插入或者更新
|
||||
/// </summary>
|
||||
/// <param name="materials"></param>
|
||||
/// <returns></returns>
|
||||
public (int, int) ExcelADD(List<WmMaterial> materials)
|
||||
{
|
||||
if(materials == null || materials.Count == 0)
|
||||
{
|
||||
return (-1,-1);
|
||||
}
|
||||
var x=Context.Storageable(materials)
|
||||
.WhereColumns(it => it.Id)
|
||||
.ToStorage();
|
||||
|
||||
int insert= x.AsInsertable.ExecuteCommand(); //执行插入
|
||||
int update= x.AsUpdateable.ExecuteCommand(); //执行更新
|
||||
return (insert, update);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user