| | |
| | | _wmsMaterialCustomerRep = wmsMaterialCustomerRep; |
| | | _wmsSubstituteGoodRep = wmsSubstituteGoodRep; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 分页查询物料信息表 |
| | | /// 分页查询物料信息 |
| | | /// </summary> |
| | | /// <param name="input"></param> |
| | | /// <returns></returns> |
| | |
| | | public async Task<PageResult<WmsMaterialOutput>> Page([FromQuery] WmsMaterialSearch input) |
| | | { |
| | | var wmsMaterials = await _wmsMaterialRep.DetachedEntities |
| | | .Where(!string.IsNullOrEmpty(input.MaterialName), u => EF.Functions.Like(u.MaterialName, $"%{input.MaterialName.Trim()}%")) |
| | | .Where(!string.IsNullOrEmpty(input.MaterialName), u => u.MaterialName == input.MaterialName) |
| | | .Where(!string.IsNullOrEmpty(input.MaterialCode), u => u.MaterialCode == input.MaterialCode) |
| | | .Where(!string.IsNullOrEmpty(input.ErpCode), u => u.ErpCode == input.ErpCode) |
| | | .Where(!string.IsNullOrEmpty(input.MaterialTypeName), u => u.MaterialTypeName == input.MaterialTypeName) |
| | |
| | | .Where(input.MaterialType != null, u => u.MaterialType == input.MaterialType) |
| | | .Where(!string.IsNullOrEmpty(input.MaterialGroup), u => u.MaterialGroup == input.MaterialGroup) |
| | | .Where(!string.IsNullOrEmpty(input.ABCClassName), u => u.ABCClassName == input.ABCClassName) |
| | | //.Where(input.ABCClass != null, u => u.ABCClass == input.ABCClass) |
| | | .Where(input.ABCClass != null, u => u.ABCClass == input.ABCClass) |
| | | .Where(!string.IsNullOrEmpty(input.MaterialSpec), u => u.MaterialSpec == input.MaterialSpec) |
| | | .Where(!string.IsNullOrEmpty(input.InPlaceCode), u => u.InPlaceCode == input.InPlaceCode) |
| | | .Where(!string.IsNullOrEmpty(input.MaterialUnit), u => u.MaterialUnit == input.MaterialUnit) |
| | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 不分页查询物料信息表列表 |
| | | /// 不分页查询物料信息列表 |
| | | /// </summary> |
| | | /// <param name="input">物料信息表查询参数</param> |
| | | /// <returns>(物料信息表)实例列表</returns> |
| | | /// <param name="input">物料信息查询参数</param> |
| | | /// <returns>(物料信息)实例列表</returns> |
| | | [HttpGet("WmsMaterial/listNonPage")] |
| | | public async Task<List<WmsMaterialOutput>> ListNonPageAsync([FromQuery] WmsMaterialSearchNonPage input) |
| | | { |
| | |
| | | var pCreatedUserName = input.CreatedUserName?.Trim() ?? ""; |
| | | var pUpdatedUserName = input.UpdatedUserName?.Trim() ?? ""; |
| | | var wmsMaterials = await _wmsMaterialRep.DetachedEntities |
| | | .Where(!string.IsNullOrEmpty(pMaterialName), u => EF.Functions.Like(u.MaterialName, $"%{pMaterialName}%")) |
| | | .Where(!string.IsNullOrEmpty(pMaterialName), u => u.MaterialName == pMaterialName) |
| | | .Where(!string.IsNullOrEmpty(pMaterialCode), u => u.MaterialCode == pMaterialCode) |
| | | .Where(!string.IsNullOrEmpty(pErpCode), u => u.ErpCode == pErpCode) |
| | | .Where(!string.IsNullOrEmpty(pMaterialTypeName), u => u.MaterialTypeName == pMaterialTypeName) |
| | |
| | | .Where(pMaterialType != null, u => u.MaterialType == pMaterialType) |
| | | .Where(!string.IsNullOrEmpty(pMaterialGroup), u => u.MaterialGroup == pMaterialGroup) |
| | | .Where(!string.IsNullOrEmpty(pABCClassName), u => u.ABCClassName == pABCClassName) |
| | | //.Where(pABCClass != null, u => u.ABCClass == pABCClass) |
| | | .Where(pABCClass != null, u => u.ABCClass == pABCClass) |
| | | .Where(!string.IsNullOrEmpty(pMaterialSpec), u => u.MaterialSpec == pMaterialSpec) |
| | | .Where(!string.IsNullOrEmpty(pInPlaceCode), u => u.InPlaceCode == pInPlaceCode) |
| | | .Where(!string.IsNullOrEmpty(pMaterialUnit), u => u.MaterialUnit == pMaterialUnit) |
| | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取物料信息表 |
| | | /// 获取物料信息 |
| | | /// </summary> |
| | | /// <param name="input"></param> |
| | | /// <returns></returns> |
| | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取物料信息表列表 |
| | | /// 获取物料信息列表 |
| | | /// </summary> |
| | | /// <param name="input"></param> |
| | | /// <returns></returns> |
| | |
| | | |
| | | |
| | | await _wmsMaterialRep.InsertAsync(wmsMaterial); |
| | | if (materialCustomerList?.Count > 0) |
| | | { |
| | | await _wmsMaterialCustomerRep.InsertAsync(materialCustomerList); |
| | | } |
| | | if (substituteGoodList?.Count > 0) |
| | | { |
| | | await _wmsSubstituteGoodRep.InsertAsync(substituteGoodList); |
| | | |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 删除物料信息表 |
| | | /// 删除物料信息 |
| | | /// </summary> |
| | | /// <param name="input"></param> |
| | | /// <returns></returns> |
| | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 更新物料信息表 |
| | | /// 更新物料信息 |
| | | /// </summary> |
| | | /// <param name="input"></param> |
| | | /// <returns></returns> |
| | |
| | | #region 导入 |
| | | |
| | | /// <summary> |
| | | /// Excel模板导入物料信息表功能 |
| | | /// Excel模板导入物料信息功能 |
| | | /// </summary> |
| | | /// <param name="file">Excel模板文件</param> |
| | | /// <returns>导入的记录数</returns> |
| | |
| | | { |
| | | addItem.MaterialTypeDescr = (string)_MaterialTypeDescr; |
| | | } |
| | | |
| | | if (string.IsNullOrEmpty(_MaterialType)) |
| | | { |
| | | throw Oops.Oh($"第{index}行[物料类型]{_MaterialType}不能为空!"); |
| | | } |
| | | |
| | | if(!string.IsNullOrEmpty(_MaterialType)) |
| | | { |
| | | if (!int.TryParse(_MaterialType, out int outMaterialType)&&!string.IsNullOrEmpty(_MaterialType)) |
| | | System.Int32 enumMaterialType = default(System.Int32); |
| | | |
| | | if (!Enum.TryParse<System.Int32>(_MaterialType, out enumMaterialType) && !string.IsNullOrEmpty(_MaterialType)) |
| | | { |
| | | throw Oops.Oh($"第{index}行[物料类型]{_MaterialType}值不正确!"); |
| | | } |
| | | if (outMaterialType <= 0&&!string.IsNullOrEmpty(_MaterialType)) |
| | | { |
| | | throw Oops.Oh($"第{index}行[物料类型]{_MaterialType}值不能小于等于0!"); |
| | | } |
| | | else |
| | | { |
| | | addItem.MaterialType = outMaterialType; |
| | | addItem.MaterialType = enumMaterialType; |
| | | } |
| | | |
| | | } |
| | |
| | | } |
| | | if(!string.IsNullOrEmpty(_ABCClass)) |
| | | { |
| | | if (!int.TryParse(_ABCClass, out int outABCClass)&&!string.IsNullOrEmpty(_ABCClass)) |
| | | Admin.NET.Core.ABCClassEnum enumABCClass = default(Admin.NET.Core.ABCClassEnum); |
| | | |
| | | if (!Enum.TryParse < Admin.NET.Core.ABCClassEnum > (_ABCClass, out enumABCClass)&& !string.IsNullOrEmpty(_ABCClass)) |
| | | { |
| | | throw Oops.Oh($"第{index}行[ABC分类]{_ABCClass}值不正确!"); |
| | | } |
| | | if (outABCClass <= 0&&!string.IsNullOrEmpty(_ABCClass)) |
| | | } else |
| | | { |
| | | throw Oops.Oh($"第{index}行[ABC分类]{_ABCClass}值不能小于等于0!"); |
| | | } |
| | | else |
| | | { |
| | | // addItem.ABCClass = outABCClass; |
| | | addItem.ABCClass = enumABCClass; |
| | | } |
| | | |
| | | } |
| | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 根据版本下载物料信息表的Excel导入模板 |
| | | /// 根据版本下载物料信息的Excel导入模板 |
| | | /// </summary> |
| | | /// <param name="version">模板版本</param> |
| | | /// <returns>下载的模板文件</returns> |
| | |
| | | public IActionResult DownloadExcelTemplate([FromQuery] string version) |
| | | { |
| | | string _path = TemplateConst.EXCEL_TEMPLATEFILE_导入模版路径 + $"\\WmsMaterial{TemplateConst.EXCEL_TEMPLATEFILE_导入模版名称后缀}.xlsx"; |
| | | var fileName = HttpUtility.UrlEncode($"导入模板(物料信息表).xlsx", Encoding.GetEncoding("UTF-8")); |
| | | var fileName = HttpUtility.UrlEncode($"导入模板(物料信息).xlsx", Encoding.GetEncoding("UTF-8")); |
| | | return new FileStreamResult(new FileStream(_path, FileMode.Open), "application/octet-stream") { FileDownloadName = fileName }; |
| | | } |
| | | |