Explorar el Código

设备管理功能

storemanagement
zhaoy hace 11 meses
padre
commit
d26f1ec619
Se han modificado 22 ficheros con 742 adiciones y 1 borrados
  1. +7
    -0
      BPA.SAAS.Manage.Application/DataBase/Services/BatchingService.cs
  2. +30
    -0
      BPA.SAAS.Manage.Application/Device/DeviceServices.cs
  3. +91
    -0
      BPA.SAAS.Manage.Application/Device/DeviceVesionServices.cs
  4. +13
    -0
      BPA.SAAS.Manage.Application/Device/Dtos/Device/DeviceTypeBaseDto.cs
  5. +16
    -0
      BPA.SAAS.Manage.Application/Device/Dtos/Device/ProductBaseDto.cs
  6. +15
    -0
      BPA.SAAS.Manage.Application/Device/Dtos/Device/ProductQueryInputDto.cs
  7. +14
    -0
      BPA.SAAS.Manage.Application/Device/Dtos/Device/ProductSatatusDto.cs
  8. +21
    -0
      BPA.SAAS.Manage.Application/Device/Dtos/DeviceVesion/DeviceVesionBaseDto.cs
  9. +14
    -0
      BPA.SAAS.Manage.Application/Device/Dtos/DeviceVesion/DeviceVesionQueryInputDto.cs
  10. +14
    -0
      BPA.SAAS.Manage.Application/Device/Dtos/DeviceVesion/DeviceVesionSatatusDto.cs
  11. +4
    -0
      BPA.SAAS.Manage.Application/Device/Interface/IDeviceService.cs
  12. +22
    -0
      BPA.SAAS.Manage.Application/Device/Interface/IDeviceVesionService.cs
  13. +21
    -0
      BPA.SAAS.Manage.Application/Device/Interface/IProductService.cs
  14. +82
    -0
      BPA.SAAS.Manage.Application/Device/ProductServices.cs
  15. +45
    -0
      BPA.SAAS.Manage.Application/Device/Services/DeviceService.cs
  16. +138
    -0
      BPA.SAAS.Manage.Application/Device/Services/DeviceVesionService.cs
  17. +130
    -0
      BPA.SAAS.Manage.Application/Device/Services/ProductService.cs
  18. +14
    -0
      BPA.SAAS.Manage.Comm/Model/ListSelectQuery.cs
  19. +4
    -0
      BPA.SAAS.Manage.Core/Device/BPA_DeviceInfo.cs
  20. +20
    -0
      BPA.SAAS.Manage.Core/Device/BPA_DeviceType.cs
  21. +27
    -0
      BPA.SAAS.Manage.Core/Device/BPA_Product.cs
  22. +0
    -1
      BPA.SAAS.Manage.Web.Entry/appsettings.json

+ 7
- 0
BPA.SAAS.Manage.Application/DataBase/Services/BatchingService.cs Ver fichero

@@ -382,5 +382,12 @@ namespace BPA.SAAS.Manage.Application.DataBase.Services
}
}
#endregion
private string GetNumber2(int Length = 10)
{
byte[] buffer = Guid.NewGuid().ToByteArray();
var ram = BitConverter.ToInt64(buffer, 0);
var str = string.Format("{0}", ram.ToString().Substring(0, Length));
return str;
}
}
}

+ 30
- 0
BPA.SAAS.Manage.Application/Device/DeviceServices.cs Ver fichero

@@ -1,7 +1,9 @@
using BPA.SAAS.Manage.Application.Device.Dtos.Device;
using BPA.SAAS.Manage.Application.Device.Interface;
using BPA.SAAS.Manage.Comm.Model;
using BPA.SAAS.Manage.Core.Base;
using Microsoft.AspNetCore.Components.Forms;
using NPOI.Util;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -29,6 +31,15 @@ namespace BPA.SAAS.Manage.Application.Device
return await _deviceService.GetDeviceInfoPage(inputDto);
}
/// <summary>
/// 查询设备列表
/// </summary>
/// <returns></returns>
[HttpGet("/api/device/list")]
public async Task<List<ListSelectQuery>> GetDeviceList()
{
return await _deviceService.GetDeviceList();
}
/// <summary>
/// 添加
/// </summary>
/// <param name="inputDto"></param>
@@ -58,5 +69,24 @@ namespace BPA.SAAS.Manage.Application.Device
{
return await _deviceService.DelDeviceInfo(inputList);
}
/// <summary>
/// 添加设备标签
/// </summary>
/// <param name="inputDto"></param>
/// <returns></returns>
[HttpPost("/api/device/adddevicetype")]
public async Task<bool> AddDeviceTypeAsync(DeviceTypeBaseDto inputDto)
{
return await _deviceService.AddDeviceTypeAsync(inputDto);
}
/// <summary>
/// 查询设备标签
/// </summary>
/// <returns></returns>
[HttpGet("/api/device/getdevicetypelist")]
public async Task<List<ListSelectQuery>> GetDeviceTypeList()
{
return await _deviceService.GetDeviceTypeList();
}
}
}

+ 91
- 0
BPA.SAAS.Manage.Application/Device/DeviceVesionServices.cs Ver fichero

@@ -0,0 +1,91 @@
using BPA.SAAS.Manage.Application.Device.Dtos.DeviceVesion;
using BPA.SAAS.Manage.Application.Device.Interface;
using BPA.SAAS.Manage.Core.Base;
using BPA.SAAS.Manage.Core.Device;
using Microsoft.AspNetCore.Components.Forms;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPA.SAAS.Manage.Application.Device
{
[ApiDescriptionSettings("Device", Tag = "设备版本管理")]
public class DeviceVesionServices: IDynamicApiController, ITransient
{
IDeviceVesionService _deviceVesionService;
public DeviceVesionServices(IDeviceVesionService deviceVesionService)
{
_deviceVesionService= deviceVesionService;
}
/// <summary>
/// 分页查询
/// </summary>
/// <param name="inputDto"></param>
/// <returns></returns>

[HttpPost("/api/devicevesion/page")]
public async Task<PageUtil> GetDeviceVesionPageAsync(DeviceVesionQueryInputDto inputDto)
{
return await _deviceVesionService.GetDeviceVesionPageAsync(inputDto);
}
/// <summary>
/// 新增
/// </summary>
/// <returns></returns>
[HttpPost("/api/devicevesion/add")]
public async Task<bool> AddDeviceVesionAsync(DeviceVesionBaseDto inputDto)
{
return await _deviceVesionService.AddDeviceVesionAsync(inputDto);
}
/// <summary>
/// 删除
/// </summary>
/// <param name="inputList"></param>
/// <returns></returns>
[HttpPost("/api/devicevesion/delete")]
public async Task<bool> DelDeviceVesionAsync(List<string> inputList)
{
return await _deviceVesionService.DelDeviceVesionAsync(inputList);
}
/// <summary>
/// 修改
/// </summary>
/// <returns></returns>
[HttpPost("/api/devicevesion/update")]
public async Task<bool> UpdateDeviceVesionAsync(DeviceVesionBaseDto inputDto)
{
return await _deviceVesionService.UpdateDeviceVesionAsync(inputDto);
}
/// <summary>
/// 更新状态
/// </summary>
/// <param name="inputDto"></param>
/// <returns></returns>
[HttpPost("/api/devicevesion/updatestatus")]
public async Task<bool> UpdateDeviceVesionSatatus(DeviceVesionSatatusDto inputDto)
{
return await _deviceVesionService.UpdateDeviceVesionSatatus(inputDto);
}
/// <summary>
/// 根据设备编码查询版本
/// </summary>
/// <param name="Code"></param>
/// <returns></returns>
[HttpGet("/api/devicevesion/getdevicevesion")]
public async Task<List<BPA_DeviceVesion>> GetDeviceVesion(string code)
{
return await _deviceVesionService.GetDeviceVesion(code);
}
/// <summary>
/// 查询版本列表
/// </summary>
/// <returns></returns>
[HttpGet("/api/devicevesion/getdevicevesionlist")]
public async Task<List<BPA_DeviceVesion>> GetDeviceVesionList()
{
return await _deviceVesionService.GetDeviceVesionList();
}
}
}

+ 13
- 0
BPA.SAAS.Manage.Application/Device/Dtos/Device/DeviceTypeBaseDto.cs Ver fichero

@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPA.SAAS.Manage.Application.Device.Dtos.Device
{
public class DeviceTypeBaseDto
{
public string Name { get; set; }
}
}

+ 16
- 0
BPA.SAAS.Manage.Application/Device/Dtos/Device/ProductBaseDto.cs Ver fichero

@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPA.SAAS.Manage.Application.Device.Dtos.Device
{
public class ProductBaseDto
{
public string Id { get; set; }
public string Name { get; set; }
public string Key { get; set; }
public string Remark { get; set; }
}
}

+ 15
- 0
BPA.SAAS.Manage.Application/Device/Dtos/Device/ProductQueryInputDto.cs Ver fichero

@@ -0,0 +1,15 @@
using BPA.SAAS.Manage.Core.Base;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPA.SAAS.Manage.Application.Device.Dtos.Device
{
public class ProductQueryInputDto: PageInputBase
{
public string Name { get; set; }
public string Key { get; set; }
}
}

+ 14
- 0
BPA.SAAS.Manage.Application/Device/Dtos/Device/ProductSatatusDto.cs Ver fichero

@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPA.SAAS.Manage.Application.Device.Dtos.Device
{
public class ProductSatatusDto
{
public string Id { get; set; }
public int Status { get; set; }
}
}

+ 21
- 0
BPA.SAAS.Manage.Application/Device/Dtos/DeviceVesion/DeviceVesionBaseDto.cs Ver fichero

@@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPA.SAAS.Manage.Application.Device.Dtos.DeviceVesion
{
public class DeviceVesionBaseDto
{
public string Id { get; set; }
public string Vesion { get; set; }
public string DeviceTypeKey { get; set; }

/// <summary>
/// 模版路径
/// </summary>
public string TemplatePath { get; set; }
public int Status { get; set; }
}
}

+ 14
- 0
BPA.SAAS.Manage.Application/Device/Dtos/DeviceVesion/DeviceVesionQueryInputDto.cs Ver fichero

@@ -0,0 +1,14 @@
using BPA.SAAS.Manage.Core.Base;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPA.SAAS.Manage.Application.Device.Dtos.DeviceVesion
{
public class DeviceVesionQueryInputDto : PageInputBase
{
public string DeviceTypeKey { get; set; }
}
}

+ 14
- 0
BPA.SAAS.Manage.Application/Device/Dtos/DeviceVesion/DeviceVesionSatatusDto.cs Ver fichero

@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPA.SAAS.Manage.Application.Device.Dtos.DeviceVesion
{
public class DeviceVesionSatatusDto
{
public string Id { get; set; }
public int Status { get; set; }
}
}

+ 4
- 0
BPA.SAAS.Manage.Application/Device/Interface/IDeviceService.cs Ver fichero

@@ -1,4 +1,5 @@
using BPA.SAAS.Manage.Application.Device.Dtos.Device;
using BPA.SAAS.Manage.Comm.Model;
using BPA.SAAS.Manage.Core.Base;
using System;
using System.Collections.Generic;
@@ -11,8 +12,11 @@ namespace BPA.SAAS.Manage.Application.Device.Interface
public interface IDeviceService
{
Task<PageUtil> GetDeviceInfoPage(DeviceQueryInputDto inputDto);
Task<List<ListSelectQuery>> GetDeviceList();
Task<bool> AddDevice(DeviceInfoBaseDto inputDto);
Task<bool> UpdateDevice(DeviceInfoBaseDto inputDto);
Task<bool> DelDeviceInfo(List<string> inputList);
Task<bool> AddDeviceTypeAsync(DeviceTypeBaseDto inputDto);
Task<List<ListSelectQuery>> GetDeviceTypeList();
}
}

+ 22
- 0
BPA.SAAS.Manage.Application/Device/Interface/IDeviceVesionService.cs Ver fichero

@@ -0,0 +1,22 @@
using BPA.SAAS.Manage.Application.Device.Dtos.DeviceVesion;
using BPA.SAAS.Manage.Core.Base;
using BPA.SAAS.Manage.Core.Device;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPA.SAAS.Manage.Application.Device.Interface
{
public interface IDeviceVesionService
{
Task<PageUtil> GetDeviceVesionPageAsync(DeviceVesionQueryInputDto inputDto);
Task<bool> AddDeviceVesionAsync(DeviceVesionBaseDto inputDto);
Task<bool> DelDeviceVesionAsync(List<string> inputList);
Task<bool> UpdateDeviceVesionAsync(DeviceVesionBaseDto inputDto);
Task<bool> UpdateDeviceVesionSatatus(DeviceVesionSatatusDto inputDto);
Task<List<BPA_DeviceVesion>> GetDeviceVesion(string Code);
Task<List<BPA_DeviceVesion>> GetDeviceVesionList();
}
}

+ 21
- 0
BPA.SAAS.Manage.Application/Device/Interface/IProductService.cs Ver fichero

@@ -0,0 +1,21 @@
using BPA.SAAS.Manage.Application.Device.Dtos.Device;
using BPA.SAAS.Manage.Core.Base;
using BPA.SAAS.Manage.Core.Device;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPA.SAAS.Manage.Application.Device.Interface
{
public interface IProductService
{
Task<PageUtil> GetProductPage(ProductQueryInputDto inputDto);
Task<List<BPA_Product>> GetProductList();
Task<bool> AddProduct(ProductBaseDto inputDto);
Task<bool> DeProduct(List<string> inputList);
Task<bool> UpdateProduct(ProductBaseDto inputDto);
Task<bool> UpdateDeviceVesionSatatus(ProductSatatusDto inputDto);
}
}

+ 82
- 0
BPA.SAAS.Manage.Application/Device/ProductServices.cs Ver fichero

@@ -0,0 +1,82 @@
using BPA.SAAS.Manage.Application.Device.Dtos.Device;
using BPA.SAAS.Manage.Application.Device.Interface;
using BPA.SAAS.Manage.Core.Base;
using BPA.SAAS.Manage.Core.Device;
using Microsoft.AspNetCore.Components.Forms;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPA.SAAS.Manage.Application.Device
{
[ApiDescriptionSettings("Device", Tag = "产品管理")]
public class ProductServices: IDynamicApiController, ITransient
{
IProductService _productService;
public ProductServices(IProductService productService)
{
_productService=productService;
}
/// <summary>
/// 分页查询
/// </summary>
/// <param name="inputDto"></param>
/// <returns></returns>
[HttpPost("/api/product/page")]
public async Task<PageUtil> GetProductPage(ProductQueryInputDto inputDto)
{
return await _productService.GetProductPage(inputDto);
}
/// <summary>
/// 查询列表
/// </summary>
/// <returns></returns>
[HttpGet("/api/product/list")]
public async Task<List<BPA_Product>> GetProductList()
{
return await _productService.GetProductList();
}
/// <summary>
/// 添加
/// </summary>
/// <param name="inputDto"></param>
/// <returns></returns>
[HttpPost("/api/product/add")]
public async Task<bool> AddProduct(ProductBaseDto inputDto)
{
return await _productService.AddProduct(inputDto);
}
/// <summary>
/// 删除
/// </summary>
/// <param name="inputList"></param>
/// <returns></returns>
[HttpPost("/api/product/delete")]
public async Task<bool> DeProduct(List<string> inputList)
{
return await _productService.DeProduct(inputList);
}
/// <summary>
/// 更新
/// </summary>
/// <param name="inputDto"></param>
/// <returns></returns>
[HttpPost("/api/product/update")]
public async Task<bool> UpdateProduct(ProductBaseDto inputDto)
{
return await _productService.UpdateProduct(inputDto);
}
/// <summary>
/// 更新状态
/// </summary>
/// <param name="inputDto"></param>
/// <returns></returns>
[HttpPost("/api/product/updatestatus")]
public async Task<bool> UpdateDeviceVesionSatatus(ProductSatatusDto inputDto)
{
return await _productService.UpdateDeviceVesionSatatus(inputDto);
}
}
}

+ 45
- 0
BPA.SAAS.Manage.Application/Device/Services/DeviceService.cs Ver fichero

@@ -1,6 +1,8 @@
using BPA.SAAS.Manage.Application.Device.Dtos.Device;
using BPA.SAAS.Manage.Application.Device.Interface;
using BPA.SAAS.Manage.Comm.Const;
using BPA.SAAS.Manage.Comm.Enum;
using BPA.SAAS.Manage.Comm.Model;
using BPA.SAAS.Manage.Comm.Util;
using BPA.SAAS.Manage.Core.Base;
using BPA.SAAS.Manage.Core.Device;
@@ -55,6 +57,21 @@ namespace BPA.SAAS.Manage.Application.Device.Services
};
}
/// <summary>
/// 查询设备列表
/// </summary>
/// <returns></returns>
public async Task<List<ListSelectQuery>> GetDeviceList()
{
RefAsync<int> total = 0;
var data = await _db.Queryable<BPA_DeviceInfo>()
.Select(a=> new ListSelectQuery
{
Id = a.Id,
Name = a.DeviceName
}) .ToListAsync();
return data;
}
/// <summary>
/// 添加
/// </summary>
/// <param name="inputDto"></param>
@@ -62,6 +79,7 @@ namespace BPA.SAAS.Manage.Application.Device.Services
public async Task<bool> AddDevice(DeviceInfoBaseDto inputDto)
{
BPA_DeviceInfo bPA_DeviceInfo = inputDto.Adapt<BPA_DeviceInfo>();
bPA_DeviceInfo.Status = CommonStatus.ENABLE;
var res =await _db.Insertable(bPA_DeviceInfo) .CallEntityMethod(m => m.Create()).ExecuteReturnEntityAsync();
mqttsub(res.AutoKey, res.DeviceTypeKey);
return res != null;
@@ -112,6 +130,33 @@ namespace BPA.SAAS.Manage.Application.Device.Services
return res > 0;
}
/// <summary>
/// 添加设备标签
/// </summary>
/// <param name="inputDto"></param>
/// <returns></returns>
public async Task<bool> AddDeviceTypeAsync(DeviceTypeBaseDto inputDto)
{
var res = await _db.Insertable(new BPA_DeviceType
{
Name = inputDto.Name,
}).CallEntityMethod(m => m.Create()).ExecuteCommandAsync();
return res > 0;
}
/// <summary>
/// 查询设备标签
/// </summary>
/// <returns></returns>
public async Task<List<ListSelectQuery>> GetDeviceTypeList()
{
var listquery = await _db.Queryable<BPA_DeviceType>().Where(a => a.IsDeleted == 0).Select(a => new ListSelectQuery
{
Id = a.Id,
Name = a.Name

}).ToListAsync();
return listquery;
}
/// <summary>
/// (调用订单服务)
/// </summary>
/// <param name="AutoKey"></param>


+ 138
- 0
BPA.SAAS.Manage.Application/Device/Services/DeviceVesionService.cs Ver fichero

@@ -0,0 +1,138 @@
using BPA.SAAS.Manage.Application.Device.Dtos.DeviceVesion;
using BPA.SAAS.Manage.Application.Device.Interface;
using BPA.SAAS.Manage.Comm.Const;
using BPA.SAAS.Manage.Comm.Enum;
using BPA.SAAS.Manage.Core.Base;
using BPA.SAAS.Manage.Core.Device;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPA.SAAS.Manage.Application.Device.Services
{
public class DeviceVesionService: IDeviceVesionService, ITransient
{
ISqlSugarClient _db;
public DeviceVesionService(ISqlSugarClient db)
{
_db=db;
}
/// <summary>
/// 分页查询
/// </summary>
/// <param name="inputDto"></param>
/// <returns></returns>
public async Task<PageUtil> GetDeviceVesionPageAsync(DeviceVesionQueryInputDto inputDto)
{
var total = new RefAsync<int>();
var data = await _db.Queryable<BPA_DeviceVesion>().Where((x) => x.IsDeleted == 0)
.WhereIF(!string.IsNullOrWhiteSpace(inputDto.DeviceTypeKey), x => x.DeviceTypeKey.Contains(inputDto.DeviceTypeKey))
.OrderBy(x => x.CreateAt, OrderByType.Desc)
.ToPageListAsync(inputDto.Current, inputDto.PageSize, total);

return new PageUtil()
{
Data = data,
Total = total

};
}

/// <summary>
/// 新增
/// </summary>
/// <returns></returns>
public async Task<bool> AddDeviceVesionAsync(DeviceVesionBaseDto inputDto)
{
var res = await _db.Insertable(new BPA_DeviceVesion
{
Vesion = inputDto.Vesion,
DeviceTypeKey = inputDto.DeviceTypeKey,
TemplatePath = inputDto.TemplatePath,
Status = CommonStatus.ENABLE
}).CallEntityMethod(m => m.Create()).ExecuteCommandAsync();
return res > 0;
}
/// <summary>
/// 删除
/// </summary>
/// <param name="inputList"></param>
/// <returns></returns>
public async Task<bool> DelDeviceVesionAsync(List<string> inputList)
{
var data = await _db.Queryable<BPA_DeviceInfo>().Where(x => inputList.Contains(x.DeviceVersionKey)).ToListAsync();
if (data.Count > 0)
{
throw Oops.Oh("当前设备类型已使用,无法删除");
}
var datas = await _db.Queryable<BPA_DeviceVesion>()
.Where(x => inputList.Contains(x.Id))
.ToListAsync();
_db.Deleteable(datas).ExecuteCommand();
return true;
}
/// <summary>
/// 修改
/// </summary>
/// <returns></returns>
public async Task<bool> UpdateDeviceVesionAsync(DeviceVesionBaseDto inputDto)
{
var data = await _db.Queryable<BPA_DeviceVesion>().Where(x => x.Id == inputDto.Id).FirstAsync();

if (data != null)
{
var res = _db.Updateable<BPA_DeviceVesion>().SetColumns(t => t.Vesion == inputDto.Vesion)
.SetColumns(t => t.TemplatePath == inputDto.TemplatePath)
.SetColumns(t => t.DeviceTypeKey == inputDto.DeviceTypeKey)
.SetColumns(t => t.Status == (CommonStatus)inputDto.Status).Where(t => t.Id == inputDto.Id)
.ExecuteCommandHasChange();

return res;
}

return false;
}
/// <summary>
/// 更新状态
/// </summary>
/// <param name="inputDto"></param>
/// <returns></returns>
public async Task<bool> UpdateDeviceVesionSatatus(DeviceVesionSatatusDto inputDto)
{
var data = await _db.Queryable<BPA_DeviceVesion>().Where(x => x.Id == inputDto.Id).FirstAsync();

if (data != null)
{
var res = _db.Updateable<BPA_DeviceVesion>()
.SetColumns(t => t.Status == (CommonStatus)inputDto.Status).Where(t => t.Id == inputDto.Id)
.ExecuteCommandHasChange();

return res;
}

return false;
}
/// <summary>
/// 根据设备编码查询版本
/// </summary>
/// <param name="Code"></param>
/// <returns></returns>
public async Task<List<BPA_DeviceVesion>> GetDeviceVesion(string Code)
{
var resEntity =await _db.Queryable<BPA_DeviceVesion>().Where(a => a.DeviceTypeKey == Code).Select(a => new BPA_DeviceVesion() { Id = a.Id.SelectAll() }).ToListAsync();
return resEntity;
}
/// <summary>
/// 查询版本列表
/// </summary>
/// <returns></returns>
public async Task<List<BPA_DeviceVesion>> GetDeviceVesionList()
{
var resEntity =await _db.Queryable<BPA_DeviceVesion>().Select(a => new BPA_DeviceVesion() { Id = a.Id.SelectAll() }).ToListAsync();
return resEntity;
}
}
}

+ 130
- 0
BPA.SAAS.Manage.Application/Device/Services/ProductService.cs Ver fichero

@@ -0,0 +1,130 @@
using BPA.SAAS.Manage.Application.Device.Dtos.Device;
using BPA.SAAS.Manage.Application.Device.Dtos.DeviceVesion;
using BPA.SAAS.Manage.Application.Device.Interface;
using BPA.SAAS.Manage.Comm.Const;
using BPA.SAAS.Manage.Comm.Enum;
using BPA.SAAS.Manage.Core.Base;
using BPA.SAAS.Manage.Core.Device;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPA.SAAS.Manage.Application.Device.Services
{
public class ProductService : IProductService, ITransient
{
ISqlSugarClient _db;
public ProductService(ISqlSugarClient db)
{
_db=db;
}
/// <summary>
/// 分页查询
/// </summary>
/// <param name="inputDto"></param>
/// <returns></returns>
public async Task<PageUtil> GetProductPage(ProductQueryInputDto inputDto)
{
var total = new RefAsync<int>();
var data = await _db.Queryable<BPA_Product>().Where((x) => x.IsDeleted == 0)
.WhereIF(!string.IsNullOrWhiteSpace(inputDto.Name), x => x.Name.Contains(inputDto.Name))
.WhereIF(!string.IsNullOrWhiteSpace(inputDto.Key), x => x.Key.Contains(inputDto.Key))
.OrderBy(x => x.CreateAt, OrderByType.Desc)
.ToPageListAsync(inputDto.Current, inputDto.PageSize, total);

return new PageUtil()
{
Data = data,
Total = total

};
}
/// <summary>
/// 查询列表
/// </summary>
/// <returns></returns>
public async Task<List<BPA_Product>> GetProductList()
{
var data = await _db.Queryable<BPA_Product>() .ToListAsync();
return data;
}
/// <summary>
/// 新增
/// </summary>
/// <returns></returns>

public async Task<bool> AddProduct(ProductBaseDto inputDto)
{
var count=_db.Queryable<BPA_Product>().Count();
var res = await _db.Insertable(new BPA_Product
{
Name = inputDto.Name,
Key = GetNumber2(count),
Remark=inputDto.Remark,
Status = CommonStatus.ENABLE
}).CallEntityMethod(m => m.Create()).ExecuteCommandAsync();
return res > 0;
}
/// <summary>
/// 删除
/// </summary>
/// <param name="inputList"></param>
/// <returns></returns>
public async Task<bool> DeProduct(List<string> inputList)
{
var datas = await _db.Queryable<BPA_Product>()
.Where(x => inputList.Contains(x.Id))
.ToListAsync();
_db.Deleteable(datas).ExecuteCommand();
return true;
}
/// <summary>
/// 修改
/// </summary>
/// <returns></returns>
public async Task<bool> UpdateProduct(ProductBaseDto inputDto)
{
var data = await _db.Queryable<BPA_Product>().Where(x => x.Id == inputDto.Id).FirstAsync();

if (data != null)
{
var res = _db.Updateable<BPA_Product>()
.SetColumns(t => t.Name == inputDto.Name)
.SetColumns(t => t.Remark == inputDto.Remark).Where(t => t.Id == inputDto.Id)
.ExecuteCommandHasChange();

return res;
}

return false;
}
/// <summary>
/// 更新状态
/// </summary>
/// <param name="inputDto"></param>
/// <returns></returns>
public async Task<bool> UpdateDeviceVesionSatatus(ProductSatatusDto inputDto)
{
var data = await _db.Queryable<BPA_Product>().Where(x => x.Id == inputDto.Id).FirstAsync();

if (data != null)
{
var res = _db.Updateable<BPA_Product>()
.SetColumns(t => t.Status == (CommonStatus)inputDto.Status).Where(t => t.Id == inputDto.Id)
.ExecuteCommandHasChange();

return res;
}

return false;
}
private string GetNumber2(int count)
{
var groupId = App.User?.FindFirst(ClaimConst.GroupId)?.Value;
var res=MD5Encryption.Encrypt(groupId + DateTime.Now.ToString("yyyyMMddhhmmsss"), false,true)+ count;
return res;
}
}
}

+ 14
- 0
BPA.SAAS.Manage.Comm/Model/ListSelectQuery.cs Ver fichero

@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPA.SAAS.Manage.Comm.Model
{
public class ListSelectQuery
{
public string Id { get; set; }
public string Name { get; set; }
}
}

+ 4
- 0
BPA.SAAS.Manage.Core/Device/BPA_DeviceInfo.cs Ver fichero

@@ -46,5 +46,9 @@ namespace BPA.SAAS.Manage.Core.Device
/// </summary>
public string DeviceVersionKey { get; set; }
public string GroupId { get; set; }
/// <summary>
/// 支持工艺还是配方 0工艺 1配方
/// </summary>
public int TechnologyOrBom { get; set; }
}
}

+ 20
- 0
BPA.SAAS.Manage.Core/Device/BPA_DeviceType.cs Ver fichero

@@ -0,0 +1,20 @@
using BPA.SAAS.Manage.Core.Base;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPA.SAAS.Manage.Core.Device
{
/// <summary>
/// 设备标签
/// </summary>
[SugarTable("bpa_devicetype")]
public class BPA_DeviceType : IBaseEntity, IGroupId
{
public string Name { get; set; }
public string GroupId { get; set; }
}
}

+ 27
- 0
BPA.SAAS.Manage.Core/Device/BPA_Product.cs Ver fichero

@@ -0,0 +1,27 @@
using BPA.SAAS.Manage.Comm.Enum;
using BPA.SAAS.Manage.Core.Base;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPA.SAAS.Manage.Core.Device
{
[SugarTable("bpa_product")]
public class BPA_Product: IBaseEntity, IGroupId
{
public string Name { get; set; }
public string Key { get; set; }
/// <summary>
/// 状态 0启用 1禁用
/// </summary>
public CommonStatus Status { get; set; } = CommonStatus.ENABLE;
public string GroupId { get; set; }
/// <summary>
/// 备注
/// </summary>
public string Remark { get; set; }
}
}

+ 0
- 1
BPA.SAAS.Manage.Web.Entry/appsettings.json Ver fichero

@@ -16,7 +16,6 @@
}
],
"cos_config": {

"AppId": "1305371387",
"Region": "ap-chengdu",
"Bucket": "hbl-test-1305371387",


Cargando…
Cancelar
Guardar