diff --git a/DOAN.Model/MES/Material/Dto/MmInventoryDto.cs b/DOAN.Model/MES/Material/Dto/MmInventoryDto.cs index 1eeaabe..eba259d 100644 --- a/DOAN.Model/MES/Material/Dto/MmInventoryDto.cs +++ b/DOAN.Model/MES/Material/Dto/MmInventoryDto.cs @@ -10,7 +10,7 @@ namespace DOAN.Model.BZFM.Dto public string MaterialCode { get; set; } public string WarehouseName { get; set; } - + public string LocationCode { get; set; } public string BatchNo { get; set; } } diff --git a/DOAN.Model/MES/Material/Dto/MmMaterialDto.cs b/DOAN.Model/MES/Material/Dto/MmMaterialDto.cs index c82b933..4f39a33 100644 --- a/DOAN.Model/MES/Material/Dto/MmMaterialDto.cs +++ b/DOAN.Model/MES/Material/Dto/MmMaterialDto.cs @@ -14,6 +14,7 @@ namespace DOAN.Model.BZFM.Dto public string MaterialCode { get; set; } public string Specification { get; set; } public string TypeLabel { get; set; } + public string Type { get; set; } public string Status { get; set; } } diff --git a/DOAN.Model/MES/Material/Dto/MmRecordInboundDto.cs b/DOAN.Model/MES/Material/Dto/MmRecordInboundDto.cs index d274f58..0ceefcb 100644 --- a/DOAN.Model/MES/Material/Dto/MmRecordInboundDto.cs +++ b/DOAN.Model/MES/Material/Dto/MmRecordInboundDto.cs @@ -64,8 +64,6 @@ namespace DOAN.Model.BZFM.Dto [Required(ErrorMessage = "物料编码不能为空")] public string MaterialCode { get; set; } - - [Required(ErrorMessage = "入库单号不能为空")] public string InboundNo { get; set; } @@ -100,7 +98,6 @@ namespace DOAN.Model.BZFM.Dto public string MaterialName { get; set; } [Required(ErrorMessage = "物料编码不能为空")] public string MaterialCode { get; set; } - [Required(ErrorMessage = "入库单号不能为空")] public string InboundNo { get; set; } [ExcelColumn(Name = "入库类型")] public string TransactionTypeLabel { get; set; } diff --git a/DOAN.Model/MES/Material/Dto/MmRecordOutboundDto.cs b/DOAN.Model/MES/Material/Dto/MmRecordOutboundDto.cs index b8a9a6d..4a198af 100644 --- a/DOAN.Model/MES/Material/Dto/MmRecordOutboundDto.cs +++ b/DOAN.Model/MES/Material/Dto/MmRecordOutboundDto.cs @@ -22,10 +22,7 @@ namespace DOAN.Model.BZFM.Dto /// public class MmRecordOutboundDto { - [Required(ErrorMessage = "主键ID不能为空")] public int Id { get; set; } - - [Required(ErrorMessage = "出库单号不能为空")] public string OutboundNo { get; set; } [Required(ErrorMessage = "物料编码不能为空")] @@ -71,7 +68,6 @@ namespace DOAN.Model.BZFM.Dto /// public class OutboundReceiptDto { - [Required(ErrorMessage = "出库单号不能为空")] public string OutboundNo { get; set; } [Required(ErrorMessage = "物料编码不能为空")] diff --git a/DOAN.Model/MES/Material/Dto/MmTransactionTypeDto.cs b/DOAN.Model/MES/Material/Dto/MmTransactionTypeDto.cs index a96e3b9..48a7b5c 100644 --- a/DOAN.Model/MES/Material/Dto/MmTransactionTypeDto.cs +++ b/DOAN.Model/MES/Material/Dto/MmTransactionTypeDto.cs @@ -7,8 +7,9 @@ namespace DOAN.Model.BZFM.Dto public class MmTransactionTypeQueryDto : PagerInfo { public string TypeName { get; set; } - + public string TypeCode { get; set; } public string TransactionDirection { get; set; } + public string Status { get; set; } } /// diff --git a/DOAN.Service/MES/Material/MmInventoryService.cs b/DOAN.Service/MES/Material/MmInventoryService.cs index 967b81e..3435ddf 100644 --- a/DOAN.Service/MES/Material/MmInventoryService.cs +++ b/DOAN.Service/MES/Material/MmInventoryService.cs @@ -30,7 +30,6 @@ namespace DOAN.Service.BZFM return response; } - /// /// 获取详情 /// @@ -38,9 +37,7 @@ namespace DOAN.Service.BZFM /// public MmInventory GetInfo(int Id) { - var response = Queryable() - .Where(x => x.Id == Id) - .First(); + var response = Queryable().Where(x => x.Id == Id).First(); return response; } @@ -72,12 +69,25 @@ namespace DOAN.Service.BZFM /// private static Expressionable QueryExp(MmInventoryQueryDto parm) { - var predicate = Expressionable.Create() - .AndIF(!string.IsNullOrEmpty(parm.WarehouseCode), m => m.WarehouseCode.Contains(parm.WarehouseCode)) - .AndIF(!string.IsNullOrEmpty(parm.MaterialCode), m => m.MaterialCode.Contains(parm.MaterialCode)) - .AndIF(!string.IsNullOrEmpty(parm.WarehouseName), m => m.WarehouseName.Contains(parm.WarehouseName)) - .AndIF(!string.IsNullOrEmpty(parm.BatchNo), m => m.BatchNo.Contains(parm.BatchNo)) - ; + var predicate = Expressionable + .Create() + .AndIF( + !string.IsNullOrEmpty(parm.MaterialCode), + m => m.MaterialCode.Contains(parm.MaterialCode) + ) + .AndIF( + !string.IsNullOrEmpty(parm.WarehouseName), + m => m.WarehouseName.Contains(parm.WarehouseName) + ) + .AndIF( + !string.IsNullOrEmpty(parm.WarehouseCode), + m => m.WarehouseCode.Contains(parm.WarehouseCode) + ) + .AndIF( + !string.IsNullOrEmpty(parm.LocationCode), + m => m.LocationCode.Contains(parm.LocationCode) + ) + .AndIF(!string.IsNullOrEmpty(parm.BatchNo), m => m.BatchNo.Contains(parm.BatchNo)); return predicate; } @@ -86,30 +96,30 @@ namespace DOAN.Service.BZFM { try { - return Context.Queryable() + return Context + .Queryable() .Where(it => it.Status == "启用") .Select(it => new MmMaterialOption { MaterialCode = it.MaterialCode, MaterialName = it.MaterialName, CategoryCode = it.CategoryCode, - Specification = it.Specification + Specification = it.Specification, }) .ToList(); } catch (Exception) { - throw; } } - public List GetLocationOption() { try { - return Context.Queryable() + return Context + .Queryable() .Where(it => it.Status == "启用") .Select(it => new MmLocationOption { @@ -117,13 +127,12 @@ namespace DOAN.Service.BZFM WarehouseName = it.WarehouseName, LocationCode = it.LocationCode, LocationName = it.LocationName, - LocationType = it.LocationType + LocationType = it.LocationType, }) .ToList(); } catch (Exception) { - throw; } } @@ -132,18 +141,18 @@ namespace DOAN.Service.BZFM { try { - return Context.Queryable() + return Context + .Queryable() .Where(it => it.Status == "启用") .Select(it => new MmTransactionOption { Label = it.TypeName, - Value = it.TypeCode + Value = it.TypeCode, }) .ToList(); } catch (Exception) { - throw; } } @@ -158,20 +167,27 @@ namespace DOAN.Service.BZFM decimal delta = GetSignedQuantity(parm.ReceiptType, parm.Quantity); // 校验物料和库位 - var mmMaterial = Context.Queryable().Where(it => it.MaterialCode == parm.MaterialCode).First(); - if (mmMaterial == null) return "物料不存在!"; + var mmMaterial = Context + .Queryable() + .Where(it => it.MaterialCode == parm.MaterialCode) + .First(); + if (mmMaterial == null) + return "物料不存在!"; - var mmLocation = Context.Queryable() + var mmLocation = Context + .Queryable() .Where(it => it.WarehouseCode == parm.WarehouseCode) .Where(it => it.LocationCode == parm.LocationCode) .First(); - if (mmLocation == null) return "仓库编码或库位编码不存在!"; + if (mmLocation == null) + return "仓库编码或库位编码不存在!"; // 启用事务 Context.Ado.BeginTran(); // 获取现有库存(同物料、批次、库位) - var mmInventory = Context.Queryable() + var mmInventory = Context + .Queryable() .Where(it => it.MaterialCode == parm.MaterialCode) .Where(it => it.BatchNo == parm.BatchNo) .Where(it => it.WarehouseCode == parm.WarehouseCode) @@ -195,13 +211,14 @@ namespace DOAN.Service.BZFM ExpiryDate = parm.ExpiryDate, LastUpdatedTime = null, ProductionDate = parm.ProductionDate, - CreatedTime = nowDate + CreatedTime = nowDate, }; Context.Insertable(newInventory).ExecuteCommand(); } else { - Context.Updateable(mmInventory) + Context + .Updateable(mmInventory) .SetColumns(it => it.CurrentQty == it.CurrentQty + delta) .ExecuteCommand(); } @@ -227,7 +244,7 @@ namespace DOAN.Service.BZFM ExpiryDate = parm.ExpiryDate, CreatedTime = nowDate, TransactionType = parm.TransactionType, - Remarks = parm.Remarks + Remarks = parm.Remarks, }; Context.Insertable(newRecord).ExecuteCommand(); @@ -251,18 +268,25 @@ namespace DOAN.Service.BZFM // 计算有符号变动量(蓝单为正,红单为负) decimal delta = GetSignedQuantity(parm.ReceiptType, parm.Quantity); - var mmMaterial = Context.Queryable().Where(it => it.MaterialCode == parm.MaterialCode).First(); - if (mmMaterial == null) return "物料不存在!"; + var mmMaterial = Context + .Queryable() + .Where(it => it.MaterialCode == parm.MaterialCode) + .First(); + if (mmMaterial == null) + return "物料不存在!"; - var mmLocation = Context.Queryable() + var mmLocation = Context + .Queryable() .Where(it => it.WarehouseCode == parm.WarehouseCode) .Where(it => it.LocationCode == parm.LocationCode) .First(); - if (mmLocation == null) return "仓库编码或库位编码不存在!"; + if (mmLocation == null) + return "仓库编码或库位编码不存在!"; Context.Ado.BeginTran(); - var mmInventory = Context.Queryable() + var mmInventory = Context + .Queryable() .Where(it => it.MaterialCode == parm.MaterialCode) .Where(it => it.BatchNo == parm.BatchNo) .Where(it => it.WarehouseCode == parm.WarehouseCode) @@ -283,7 +307,7 @@ namespace DOAN.Service.BZFM CurrentQty = -delta, Unit = parm.Unit, LastUpdatedTime = null, - CreatedTime = nowDate + CreatedTime = nowDate, }; Context.Insertable(newInventory).ExecuteCommand(); } @@ -295,7 +319,8 @@ namespace DOAN.Service.BZFM return "库存不足,无法出库"; } - Context.Updateable(mmInventory) + Context + .Updateable(mmInventory) .SetColumns(it => it.CurrentQty == it.CurrentQty - delta) .ExecuteCommand(); } @@ -316,7 +341,7 @@ namespace DOAN.Service.BZFM Unit = parm.Unit, CreatedTime = nowDate, TransactionType = parm.TransactionType, - Remarks = parm.Remarks + Remarks = parm.Remarks, }; Context.Insertable(newRecord).ExecuteCommand(); Context.Ado.CommitTran(); @@ -354,7 +379,8 @@ namespace DOAN.Service.BZFM { if (prefix == "RK") { - var last = Context.Queryable() + var last = Context + .Queryable() .Where(it => it.InboundNo.StartsWith(prefix + datePart)) .OrderBy(it => it.InboundNo + " desc") .Select(it => it.InboundNo) @@ -372,7 +398,8 @@ namespace DOAN.Service.BZFM } else { - var last = Context.Queryable() + var last = Context + .Queryable() .Where(it => it.OutboundNo.StartsWith(prefix + datePart)) .OrderBy(it => it.OutboundNo + " desc") .Select(it => it.OutboundNo) @@ -394,6 +421,5 @@ namespace DOAN.Service.BZFM return baseNo + "001"; } } - } -} \ No newline at end of file +} diff --git a/DOAN.Service/MES/Material/MmLocationService.cs b/DOAN.Service/MES/Material/MmLocationService.cs index e6d05ca..baaa909 100644 --- a/DOAN.Service/MES/Material/MmLocationService.cs +++ b/DOAN.Service/MES/Material/MmLocationService.cs @@ -24,6 +24,7 @@ namespace DOAN.Service.BZFM var response = Queryable() .Where(predicate.ToExpression()) + .OrderBy(it => it.LocationCode) .ToPage(parm); return response; diff --git a/DOAN.Service/MES/Material/MmMaterialService.cs b/DOAN.Service/MES/Material/MmMaterialService.cs index ba1d8fe..6767c47 100644 --- a/DOAN.Service/MES/Material/MmMaterialService.cs +++ b/DOAN.Service/MES/Material/MmMaterialService.cs @@ -24,6 +24,7 @@ namespace DOAN.Service.BZFM var response = Queryable() .Where(predicate.ToExpression()) + .OrderBy(it => it.Type) .ToPage(parm); return response; @@ -76,7 +77,7 @@ namespace DOAN.Service.BZFM .AndIF(!string.IsNullOrEmpty(parm.MaterialName), m => m.MaterialName.Contains(parm.MaterialName)) .AndIF(!string.IsNullOrEmpty(parm.MaterialCode), m => m.MaterialCode.Contains(parm.MaterialCode)) .AndIF(!string.IsNullOrEmpty(parm.Specification), m => m.Specification.Contains(parm.Specification)) - .AndIF(!string.IsNullOrEmpty(parm.TypeLabel), m => m.Type == parm.TypeLabel) + .AndIF(!string.IsNullOrEmpty(parm.Type), m => m.Type.Contains(parm.Type)) .AndIF(!string.IsNullOrEmpty(parm.Status), m => m.Status == parm.Status); return predicate; } diff --git a/DOAN.Service/MES/Material/MmTransactionTypeService.cs b/DOAN.Service/MES/Material/MmTransactionTypeService.cs index acccae3..ce784a6 100644 --- a/DOAN.Service/MES/Material/MmTransactionTypeService.cs +++ b/DOAN.Service/MES/Material/MmTransactionTypeService.cs @@ -1,17 +1,22 @@ -using Infrastructure.Attribute; -using Infrastructure.Extensions; -using DOAN.Model.BZFM.Dto; using DOAN.Model.BZFM; +using DOAN.Model.BZFM.Dto; using DOAN.Repository; using DOAN.Service.BZFM.IBZFMService; +using Infrastructure.Attribute; +using Infrastructure.Extensions; namespace DOAN.Service.BZFM { /// /// 出入库类别对照表Service业务层处理 /// - [AppService(ServiceType = typeof(IMmTransactionTypeService), ServiceLifetime = LifeTime.Transient)] - public class MmTransactionTypeService : BaseService, IMmTransactionTypeService + [AppService( + ServiceType = typeof(IMmTransactionTypeService), + ServiceLifetime = LifeTime.Transient + )] + public class MmTransactionTypeService + : BaseService, + IMmTransactionTypeService { /// /// 查询出入库类别对照表列表 @@ -29,7 +34,6 @@ namespace DOAN.Service.BZFM return response; } - /// /// 获取详情 /// @@ -37,9 +41,7 @@ namespace DOAN.Service.BZFM /// public MmTransactionType GetInfo(int Id) { - var response = Queryable() - .Where(x => x.Id == Id) - .First(); + var response = Queryable().Where(x => x.Id == Id).First(); return response; } @@ -71,11 +73,22 @@ namespace DOAN.Service.BZFM /// private static Expressionable QueryExp(MmTransactionTypeQueryDto parm) { - var predicate = Expressionable.Create() - .AndIF(!string.IsNullOrEmpty(parm.TypeName), it => it.TypeName.Contains(parm.TypeName)) - .AndIF(!string.IsNullOrEmpty(parm.TransactionDirection), it => it.TransactionDirection.Contains(parm.TransactionDirection)); - + var predicate = Expressionable + .Create() + .AndIF( + !string.IsNullOrEmpty(parm.TypeCode), + it => it.TypeCode.Contains(parm.TypeCode) + ) + .AndIF( + !string.IsNullOrEmpty(parm.TypeName), + it => it.TypeName.Contains(parm.TypeName) + ) + .AndIF( + !string.IsNullOrEmpty(parm.TransactionDirection), + it => it.TransactionDirection.Contains(parm.TransactionDirection) + ) + .AndIF(!string.IsNullOrEmpty(parm.Status), it => it.Status == parm.Status); return predicate; } } -} \ No newline at end of file +}