<add>[important]添加扫码查询的功能
This commit is contained in:
parent
79d5f2b0b5
commit
c91a72e9e0
|
|
@ -0,0 +1,41 @@
|
|||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace WcsMain.ApiServe.Controllers.Dto.WcsDto.Scan;
|
||||
|
||||
public class QueryScanRecordWithPageRequest
|
||||
{
|
||||
/// <summary>
|
||||
/// 模糊查询字符串
|
||||
/// </summary>
|
||||
[JsonPropertyName("searchStr")]
|
||||
public string? SearchStr { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 查询时间范围
|
||||
/// </summary>
|
||||
[JsonPropertyName("timeRange")]
|
||||
public List<DateTime>? TimeRange { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 分页信息
|
||||
/// </summary>
|
||||
[JsonPropertyName("page")]
|
||||
public ScaanRecordPage? Page { get; set; }
|
||||
|
||||
|
||||
}
|
||||
|
||||
public class ScaanRecordPage
|
||||
{
|
||||
/// <summary>
|
||||
/// 每页大小
|
||||
/// </summary>
|
||||
[JsonPropertyName("pageSize")]
|
||||
public int PageSize { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 当前页数
|
||||
/// </summary>
|
||||
[JsonPropertyName("pageIndex")]
|
||||
public int PageIndex { get; set; }
|
||||
}
|
||||
36
WcsMain/ApiServe/Controllers/WcsController/ScanController.cs
Normal file
36
WcsMain/ApiServe/Controllers/WcsController/ScanController.cs
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using WcsMain.ApiServe.ControllerFilter.ExceptionFilter;
|
||||
using WcsMain.ApiServe.Controllers.Dto;
|
||||
using WcsMain.ApiServe.Controllers.Dto.WcsDto.Scan;
|
||||
using WcsMain.ApiServe.Service.WcsService;
|
||||
using WcsMain.DataBase.TableEntity;
|
||||
|
||||
namespace WcsMain.ApiServe.Controllers.WcsController;
|
||||
|
||||
/// <summary>
|
||||
/// 扫码器相关接口
|
||||
/// </summary>
|
||||
[Route("api/wcs/scan")]
|
||||
[ApiController]
|
||||
[WcsExceptionFilter]
|
||||
public class ScanController(ScanService scanService) : ControllerBase
|
||||
{
|
||||
/// <summary>
|
||||
/// 分页查询扫码记录
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("queryScanRecordWithPage")]
|
||||
public WcsApiResponse<int, List<AppScanRecord>> QueryScanRecordWithPage([FromBody] QueryScanRecordWithPageRequest request) => scanService.QueryScanRecordWithPage(request);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
31
WcsMain/ApiServe/Service/WcsService/ScanService.cs
Normal file
31
WcsMain/ApiServe/Service/WcsService/ScanService.cs
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
using WcsMain.ApiServe.Controllers.Dto;
|
||||
using WcsMain.ApiServe.Controllers.Dto.WcsDto.Scan;
|
||||
using WcsMain.ApiServe.Factory;
|
||||
using WcsMain.DataBase.Dao;
|
||||
using WcsMain.DataBase.TableEntity;
|
||||
using WcsMain.WcsAttribute.AutoFacAttribute;
|
||||
|
||||
namespace WcsMain.ApiServe.Service.WcsService;
|
||||
|
||||
/// <summary>
|
||||
/// 扫码器相关控制器的Service
|
||||
/// </summary>
|
||||
[Service]
|
||||
public class ScanService(AppScanRecordDao scanRecordDao)
|
||||
{
|
||||
/// <summary>
|
||||
/// 分页查询扫码记录
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
public WcsApiResponse<int, List<AppScanRecord>> QueryScanRecordWithPage(QueryScanRecordWithPageRequest request)
|
||||
{
|
||||
(List<AppScanRecord>? records, int totalCount) = scanRecordDao.Query(request);
|
||||
if(records == default)
|
||||
{
|
||||
return WcsApiResponseFactory.DataBaseErr<int, List<AppScanRecord>>();
|
||||
}
|
||||
return WcsApiResponseFactory.Success(totalCount, records);
|
||||
}
|
||||
|
||||
}
|
||||
96
WcsMain/DataBase/Dao/AppScanRecordDao.cs
Normal file
96
WcsMain/DataBase/Dao/AppScanRecordDao.cs
Normal file
|
|
@ -0,0 +1,96 @@
|
|||
using WcsMain.ApiServe.Controllers.Dto.WcsDto.Scan;
|
||||
using WcsMain.Common;
|
||||
using WcsMain.DataBase.TableEntity;
|
||||
using WcsMain.WcsAttribute.AutoFacAttribute;
|
||||
|
||||
namespace WcsMain.DataBase.Dao;
|
||||
|
||||
[Component]
|
||||
public class AppScanRecordDao
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 条件查询
|
||||
/// </summary>
|
||||
/// <param name="queryEntity"></param>
|
||||
/// <returns></returns>
|
||||
public List<AppScanRecord>? Query(AppScanRecord queryEntity)
|
||||
{
|
||||
try
|
||||
{
|
||||
var sqlFuc = CommonTool.DbServe.Queryable<AppScanRecord>()
|
||||
.WhereIF(queryEntity.RecordId != default, it => it.RecordId == queryEntity.RecordId)
|
||||
.WhereIF(queryEntity.ScanId != default, it => it.ScanId == queryEntity.ScanId)
|
||||
.WhereIF(queryEntity.Area != default, it => it.Area == queryEntity.Area)
|
||||
.WhereIF(queryEntity.Code != default, it => it.Code == queryEntity.Code)
|
||||
.WhereIF(queryEntity.Tag != default, it => it.Tag == queryEntity.Tag)
|
||||
.WhereIF(queryEntity.Remark != default, it => it.Remark == queryEntity.Remark);
|
||||
return sqlFuc.ToList();
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
_ = ex;
|
||||
return default;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查询所有
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public List<AppScanRecord>? Query() => Query(new AppScanRecord());
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 分页查询
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
public (List<AppScanRecord>? records, int totalCount) Query(QueryScanRecordWithPageRequest request)
|
||||
{
|
||||
try
|
||||
{
|
||||
int totalRows = 0;
|
||||
var sqlFuc = CommonTool.DbServe.Queryable<AppScanRecord>()
|
||||
.WhereIF(!string.IsNullOrEmpty(request.SearchStr),
|
||||
w => w.ScanId!.Contains(request.SearchStr!)
|
||||
|| w.Code!.Contains(request.SearchStr!)
|
||||
|| w.Area!.Contains(request.SearchStr!)
|
||||
|| w.Tag!.Contains(request.SearchStr!)
|
||||
|| w.Remark!.Contains(request.SearchStr!));
|
||||
if (request.TimeRange is { Count: 2 }) // 时间范围
|
||||
{
|
||||
sqlFuc.Where(w => w.ScanTime > request.TimeRange[0] && w.ScanTime < request.TimeRange[1]);
|
||||
}
|
||||
sqlFuc = sqlFuc.OrderByDescending(o => new { o.ScanTime });
|
||||
var queryResult = sqlFuc.ToPageList(request.Page!.PageIndex, request.Page!.PageSize, ref totalRows);
|
||||
return (queryResult, totalRows);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_ = ex;
|
||||
return default;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 插入数据
|
||||
/// </summary>
|
||||
/// <param name="records"></param>
|
||||
/// <returns></returns>
|
||||
public int Insert(params AppScanRecord[] records)
|
||||
{
|
||||
try
|
||||
{
|
||||
var sqlFuc = CommonTool.DbServe.Insertable(records);
|
||||
return sqlFuc.ExecuteCommand();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_ = ex;
|
||||
return default;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
61
WcsMain/DataBase/TableEntity/AppScanRecord.cs
Normal file
61
WcsMain/DataBase/TableEntity/AppScanRecord.cs
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
using SqlSugar;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace WcsMain.DataBase.TableEntity;
|
||||
|
||||
/// <summary>
|
||||
/// 扫码记录
|
||||
/// </summary>
|
||||
[SugarTable("tbl_app_scan_record")]
|
||||
public class AppScanRecord
|
||||
{
|
||||
/// <summary>
|
||||
/// 记录ID
|
||||
/// </summary>
|
||||
[JsonPropertyName("recordId")]
|
||||
[SugarColumn(IsPrimaryKey = true, ColumnName = "record_id")]
|
||||
public string? RecordId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 扫码ID
|
||||
/// </summary>
|
||||
[JsonPropertyName("scanId")]
|
||||
[SugarColumn(ColumnName = "scan_id")]
|
||||
public string? ScanId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 区域
|
||||
/// </summary>
|
||||
[JsonPropertyName("area")]
|
||||
[SugarColumn(ColumnName = "area")]
|
||||
public string? Area { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 条码
|
||||
/// </summary>
|
||||
[JsonPropertyName("code")]
|
||||
[SugarColumn(ColumnName = "code")]
|
||||
public string? Code { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 标记
|
||||
/// </summary>
|
||||
[JsonPropertyName("tag")]
|
||||
[SugarColumn(ColumnName = "tag")]
|
||||
public string? Tag { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 扫码时间
|
||||
/// </summary>
|
||||
[JsonPropertyName("scanTime")]
|
||||
[SugarColumn(ColumnName = "scan_time")]
|
||||
public DateTime? ScanTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 备注
|
||||
/// </summary>
|
||||
[JsonPropertyName("remark")]
|
||||
[SugarColumn(ColumnName = "remark")]
|
||||
public string? Remark { get; set; }
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user