WMS仓库管理系统库位功能

后端

using Infrastructure.Attribute;
using Model.Dto.WarehouseManagement;
using Model.Page;
using Model.WarehouseManagement;
using Repository;
using Service.Interface.WarehouseManagement;
using SqlSugar;

namespace Service.WarehouseManagement
{
    [AppService(ServiceType = typeof(IRegionService), ServiceLifetime = LifeTime.Transient)]
    public class RegionService : BaseService, IRegionService
    {
        public int AddRegion(Region region, string userName)
        {
            region.Create_by = userName;
            region.Create_time = DateTime.Now;
            region.WarehouseName = Context
                .Queryable()
                .First(it => it.WarehouseId == region.WarehouseId)
                .WarehouseName;

            return Insert(region);
        }

        public int DeleteRegion(long regionId)
        {
            return Delete(regionId);
        }

        public int EidtRegion(Region region, string userName)
        {
            region.Update_by = userName;
            region.Update_time = DateTime.Now;
            region.WarehouseName = Context
                .Queryable()
                .First(it => it.WarehouseId == region.WarehouseId)
                .WarehouseName;

            return Update(region);
        }

        public PagedInfo GetAllRegions(RegionQueryDto regionQueryDto)
        {
            var expression = Expressionable.Create()
                .AndIF(!string.IsNullOrEmpty(regionQueryDto.WarehouseName), region => region.WarehouseName.Contains(regionQueryDto.WarehouseName))
                .AndIF(!string.IsNullOrEmpty(regionQueryDto.RegionName), region => region.RegionName.Contains(regionQueryDto.RegionName))
                .AndIF(regionQueryDto.RegionProperty != null, region => region.RegionProperty == regionQueryDto.RegionProperty);

            return Queryable()
                .Where(expression.ToExpression())
                .ToPage(regionQueryDto);
        }

        public List GetAllRegions()
        {
            return Queryable()
                .ToList();
        }

        public Region GetRegion(long regionId)
        {
            return Queryable()
                .Where(it => it.RegionId == regionId)
                .First();
        }

        public bool IsOtherUse(long regionId)
        {
            return Context
                .Queryable()
                .Where(it => it.RegionId == regionId)
                .Any();
        }
    }
}

 控制器Controllers

using Common;
using Infrastructure.Attribute;
using Infrastructure.Extensions;
using Model.Dto.WarehouseManagement;
using Model.Enums;
using Model.WarehouseManagement;
using Service.Interface.WarehouseManagement;
using WMS.WebApi.Filters;
using Mapster;
using Microsoft.AspNetCore.Mvc;

namespace WMS.WebApi.Controllers.WarehouseManagement
{
    /// 
    /// 库区控制器
    /// 
    [Verify]
    [Route("/warehousemanagement/region")]
    [ApiExplorerSettings(GroupName = "wm")]
    public class RegionController : BaseController
    {
        private IRegionService regionService;
        private IWarehouseService warehouseService;

        public RegionController(IRegionService regionService, IWarehouseService warehouseService)
        {
            this.regionService = regionService;
            this.warehouseService = warehouseService;
        }


        /// 
        /// 分页查询所有数据
        /// 
        /// 
        /// 
        [HttpGet]
        public IActionResult GetAll([FromQuery] RegionQueryDto regionQueryDto)
        {
            var result = regionService.GetAllRegions(regionQueryDto);

            return SUCCESS(result);
        }

        /// 
        /// 获取仓库选项
        /// 
        /// 
        [HttpGet("options")]
        public IActionResult GetWarehouseOptions()
        {
            var result = warehouseService
                .GetAllWarehouses()
                .Select(it => new { it.WarehouseId, it.WarehouseName })
                .ToList();

            return SUCCESS(result);
        }

        /// 
        /// 格局id获取库区信息
        /// 
        /// 
        /// 
        [HttpGet("get/{id:long}")]
        public IActionResult GetRegion(long id)
        {
            var result = regionService.GetRegion(id);

            return SUCCESS(result);
        }

        /// 
        /// 新增库区信息
        /// 
        /// 
        /// 
        [HttpPost("add")]
        [Log(Title = "新增库区信息", BusinessType = BusinessType.INSERT)]
        public IActionResult AddRegion([FromBody] RegionDto regionDto)
        {
            var region = regionDto.Adapt();
            var username = HttpContext.GetName();
            var result = regionService.AddRegion(region, username);

            return SUCCESS(result);
        }

        /// 
        /// 编辑库区信息
        /// 
        /// 
        /// 
        /// 
        [HttpPost("edit/{id:long}")]
        [Log(Title = "编辑库区信息", BusinessType = BusinessType.UPDATE)]
        public IActionResult EditRegion(long id, [FromBody] RegionDto regionDto)
        {
            var region = regionDto.Adapt();
            region.RegionId = id;
            var username = HttpContext.GetName();
            var result = regionService.EidtRegion(region, username);

            return SUCCESS(result);
        }

        /// 
        /// 删除库区信息
        /// 
        /// 
        /// 
        [HttpDelete("delete/{id:long}")]
        [Log(Title = "删除库区信息", BusinessType = BusinessType.DELETE)]
        public IActionResult DeleteRegion(long id)
        {
            var result= regionService.DeleteRegion(id);

            return SUCCESS(result);
        }

        /// 
        /// 导出库区信息
        /// 
        /// 
        [HttpGet("export")]
        [Log(Title = "导出库区信息", BusinessType = BusinessType.EXPORT)]
        public IActionResult RegionExport()
        {
            var regions = regionService.GetAllRegions();
            var regionExcelDtos = regions
                .Select(it => it.Adapt())
                .ToList();

            var result = ExcelHelper.ExportExcelMini(regionExcelDtos, "region", "库区信息");

            return ExportExcel(result.Item2, result.Item1);
        }
    }
}

前端VUE

你可能感兴趣的:(PLC,WCS系统)