!提交代码
This commit is contained in:
93
WCS.WebApi/Controllers/HomeController.cs
Normal file
93
WCS.WebApi/Controllers/HomeController.cs
Normal file
@ -0,0 +1,93 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using SqlSugar;
|
||||
using WCS.BLL.DbModels;
|
||||
using WCS.BLL.Manager;
|
||||
using WCS.BLL.Services.IService;
|
||||
using WCS.BLL.Services.Service;
|
||||
using WCS.DAL.Db;
|
||||
using WCS.Model;
|
||||
using WCS.Model.ApiModel.Home;
|
||||
|
||||
namespace WCS.WebApi.Controllers
|
||||
{
|
||||
/// <summary>
|
||||
/// 主页面的接口
|
||||
/// </summary>
|
||||
[ApiController]
|
||||
[Route("[controller]")]
|
||||
public class HomeController : ControllerBase
|
||||
{
|
||||
public IHomerService _homerService { get; set; }
|
||||
|
||||
public HomeController(IHomerService homerService)
|
||||
{
|
||||
_homerService = homerService;
|
||||
}
|
||||
|
||||
[Route("getShelfTypes")]
|
||||
[HttpPost(Name = "getShelfTypes")]
|
||||
public async Task<ResponseBase> getShelfTypes(RequestBase request)
|
||||
{
|
||||
try
|
||||
{
|
||||
//直接获取当前所有货架类型并返回
|
||||
var shelfTypes = DbHelp.db.Queryable<ShelfTypeInfo>()
|
||||
.Select(t => new ShelfTypeModel()
|
||||
{
|
||||
Id = t.Id,
|
||||
ShelfTypeName = t.ShelfTypeName
|
||||
})
|
||||
.ToList();
|
||||
return new PageQueryResponse<ShelfTypeModel>()
|
||||
{
|
||||
Code = 200,
|
||||
Message = "success",
|
||||
Data = new PageQueryResponseData<ShelfTypeModel>
|
||||
{
|
||||
Lists = shelfTypes,
|
||||
Count = shelfTypes.Count
|
||||
}
|
||||
};
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new PageQueryResponse<ShelfTypeModel>()
|
||||
{
|
||||
Code = 300,
|
||||
Message = $"查询失败:{ex.Message}",
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
[Route("getShelfStatus")]
|
||||
[HttpPost(Name = "getShelfStatus")]
|
||||
public async Task<ResponseBase> getShelfStatus(GetShelfStatusRequest request)
|
||||
{
|
||||
try
|
||||
{
|
||||
var shelfs = ShelfManager.Shelves
|
||||
.WhereIF(request.GroupNames?.Count > 0, t => request.GroupNames!.Contains(t.GroupName))
|
||||
.ToList();
|
||||
//直接返回当前内存中缓存的货架和状态
|
||||
return new GetShelfStatusResponse()
|
||||
{
|
||||
Code = 200,
|
||||
Message = "success",
|
||||
Data = shelfs.Select(t => new Shelf
|
||||
{
|
||||
ShelfId = t.ShelfId,
|
||||
ShelfCode = t.ShelfCode,
|
||||
CurentMode = (int)t.CurentMode,
|
||||
ModulesStr = t.ModulesStr,
|
||||
GroupName = t.GroupName
|
||||
}).ToList(),
|
||||
};
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
117
WCS.WebApi/Controllers/InstoreController.cs
Normal file
117
WCS.WebApi/Controllers/InstoreController.cs
Normal file
@ -0,0 +1,117 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using WCS.BLL.HardWare;
|
||||
using WCS.BLL.Manager;
|
||||
using WCS.BLL.Services.IService;
|
||||
using WCS.Model;
|
||||
|
||||
namespace WebApi.Controllers
|
||||
{
|
||||
[ApiController]
|
||||
[Route("[controller]")]
|
||||
public class InstoreController : ControllerBase
|
||||
{
|
||||
|
||||
private readonly ILogger<InstoreController> _logger;
|
||||
private readonly IInstoreService _instoreService;
|
||||
|
||||
public InstoreController(ILogger<InstoreController> logger, IInstoreService instoreService)
|
||||
{
|
||||
_logger = logger;
|
||||
_instoreService = instoreService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽ
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
[Route("shelfGoInInStore")]
|
||||
[HttpPost(Name = "shelfGoInInStore")]
|
||||
public async Task<ResponseBase> shelfGoInInStore(ShelfGoInInstoreRequest request)
|
||||
{
|
||||
string content = string.Empty;
|
||||
try
|
||||
{
|
||||
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD>豸<EFBFBD><E8B1B8>IP<49><50>ַ
|
||||
var IPAdress = HttpContext?.Connection?.RemoteIpAddress?.ToString();
|
||||
if (string.IsNullOrEmpty(IPAdress))
|
||||
{
|
||||
//δ<><CEB4>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>豸<EFBFBD><E8B1B8>IP<49><50>ַ TO DO <20><>¼<EFBFBD><C2BC>־δ<D6BE><CEB4>ȡ<EFBFBD><C8A1>IP
|
||||
}
|
||||
else
|
||||
{
|
||||
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>豸<EFBFBD><E8B1B8>Ip<49><70>ַ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>request
|
||||
request.IpAdress = IPAdress;
|
||||
}
|
||||
return _instoreService.shelfGoInInStore(request);
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ShelfGoInInstoreResponse()
|
||||
{
|
||||
Code = 300,
|
||||
Message = "<22><><EFBFBD>ܽ<EFBFBD><DCBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽʧ<CABD>ܣ<EFBFBD>" + ex.Message,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <20>˳<EFBFBD><CBB3><EFBFBD><EFBFBD><EFBFBD>ģʽ
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
[Route("shelfGoOutInStore")]
|
||||
[HttpPost(Name = "shelfGoOutInStore")]
|
||||
public async Task<ResponseBase> shelfGoOutInStore(ShelfGoOutInStoreRequest request)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _instoreService.shelfGoOutInStore(request);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ResponseCommon()
|
||||
{
|
||||
Code = 300,
|
||||
Message = $"<22><><EFBFBD><EFBFBD><EFBFBD>˳<EFBFBD><CBB3><EFBFBD><EFBFBD><EFBFBD>ģʽʧ<CABD><CAA7>:{ex.Message}",
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ɨ<><C9A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϸ
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
[Route("queryByMatSn")]
|
||||
[HttpPost(Name = "queryByMatSn")]
|
||||
public async Task<ResponseBase> queryByMatSn(QueryByMatSnRequest request)
|
||||
{
|
||||
return _instoreService.queryByMatSn(request);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <20><>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD>״̬
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
[Route("queryInstoreStatus")]
|
||||
[HttpPost(Name = "queryInstoreStatus")]
|
||||
public async Task<ResponseBase> queryInstoreStatus(QueryByMatSnRequest request)
|
||||
{
|
||||
try
|
||||
{
|
||||
return await _instoreService.queryInstoreStatus(request);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ResponseCommon()
|
||||
{
|
||||
Code = 300,
|
||||
Message = $"<22><><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>:{ex.Message}",
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
82
WCS.WebApi/Controllers/InterfaceRecordController.cs
Normal file
82
WCS.WebApi/Controllers/InterfaceRecordController.cs
Normal file
@ -0,0 +1,82 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using MiniExcelLibs;
|
||||
using NPOI.SS.UserModel;
|
||||
using SqlSugar;
|
||||
using System.Xml.Linq;
|
||||
using WCS.BLL.DbModels;
|
||||
using WCS.BLL.Manager;
|
||||
using WCS.BLL.Services.IService;
|
||||
using WCS.BLL.Services.Service;
|
||||
using WCS.DAL.Db;
|
||||
using WCS.Model;
|
||||
using WCS.Model.ApiModel;
|
||||
using WCS.WebApi.Helper;
|
||||
|
||||
namespace WCS.WebApi.Controllers
|
||||
{
|
||||
/// <summary>
|
||||
/// 接口记录
|
||||
/// </summary>
|
||||
[ApiController]
|
||||
[Route("[controller]")]
|
||||
public class InterfaceRecordController : ControllerBase
|
||||
{
|
||||
public IInterfaceRecordService _interfaceRecordService { get; set; }
|
||||
|
||||
public InterfaceRecordController(IInterfaceRecordService interfaceRecordService)
|
||||
{
|
||||
_interfaceRecordService = interfaceRecordService;
|
||||
}
|
||||
|
||||
[Route("getInterfaceRecord")]
|
||||
[HttpPost(Name = "getInterfaceRecord")]
|
||||
public async Task<ResponseBase> getInterfaceRecord(GetInterfaceRecordsRequest request)
|
||||
{
|
||||
return await _interfaceRecordService.getInterfaceRecord(request);
|
||||
}
|
||||
|
||||
[HttpPost("exportInterfaceRecord")]
|
||||
public async Task<IActionResult> exportInterfaceRecord([FromBody] GetInterfaceRecordsRequest request)
|
||||
{
|
||||
var result = await _interfaceRecordService.exportInterfaceRecord(request);
|
||||
var data = result.Data?.Lists;
|
||||
var columns = new[]
|
||||
{
|
||||
new ExportableColumn("序号","RowNumber"),
|
||||
new ExportableColumn("接口地址","RequestUrl"),
|
||||
new ExportableColumn("设备IP","DeviceIp"),
|
||||
new ExportableColumn("请求参数","RequestBody"),
|
||||
new ExportableColumn("QueryString","QueryString"),
|
||||
new ExportableColumn("请求时间","RequestTime"),
|
||||
new ExportableColumn("返回参数","ResponseJson"),
|
||||
new ExportableColumn("返回时间","ResponseTime"),
|
||||
new ExportableColumn("耗时(ms)", "ExecutionTime"),
|
||||
};
|
||||
if (data == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
else
|
||||
return ExportExcelHelper.Export("导出数据", columns, data);
|
||||
|
||||
// 导出到Excel
|
||||
//using (var stream = new MemoryStream())
|
||||
//{
|
||||
// // 获取当前工作目录
|
||||
// string currentPath = Directory.GetCurrentDirectory();
|
||||
// // 创建文件路径
|
||||
// string filePath = Path.Combine(currentPath, "data.xlsx");
|
||||
// //MiniExcel.SaveAs(filePath, data);
|
||||
// MiniExcel.SaveAs(stream, data);
|
||||
// // 重置位置
|
||||
// //stream.Position = 0;
|
||||
// //// 通过接口下载文件
|
||||
// //return File(stream, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "data.xlsx");
|
||||
// var isXlsx = true;
|
||||
// var saveAsFileName = string.Format("{0}-{1:d}.{2}", "测试", DateTime.Now, (isXlsx ? "xlsx" : "xls")).Replace("/", "-");
|
||||
// var contentType = isXlsx ? "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" : "application/vnd.ms-excel";
|
||||
// return new FileContentResult(stream.ToArray(), contentType) { FileDownloadName = saveAsFileName };
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
104
WCS.WebApi/Controllers/MatBaseInfoController.cs
Normal file
104
WCS.WebApi/Controllers/MatBaseInfoController.cs
Normal file
@ -0,0 +1,104 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using MiniExcelLibs;
|
||||
using NPOI.SS.UserModel;
|
||||
using SqlSugar;
|
||||
using System.Xml.Linq;
|
||||
using WCS.BLL.DbModels;
|
||||
using WCS.BLL.Manager;
|
||||
using WCS.BLL.Services.IService;
|
||||
using WCS.BLL.Services.Service;
|
||||
using WCS.DAL.Db;
|
||||
using WCS.Model;
|
||||
using WCS.Model.ApiModel;
|
||||
using WCS.Model.ApiModel.MatBaseInfo;
|
||||
using WCS.WebApi.Helper;
|
||||
|
||||
namespace WCS.WebApi.Controllers
|
||||
{
|
||||
/// <summary>
|
||||
/// 接口记录
|
||||
/// </summary>
|
||||
[ApiController]
|
||||
[Route("[controller]")]
|
||||
public class MatBaseInfoController : ControllerBase
|
||||
{
|
||||
public IMatBaseInfoService _matBaseInfoService { get; set; }
|
||||
|
||||
public MatBaseInfoController(IMatBaseInfoService matBaseInfoService)
|
||||
{
|
||||
_matBaseInfoService = matBaseInfoService;
|
||||
}
|
||||
|
||||
[Route("getMatBaseInfo")]
|
||||
[HttpPost(Name = "getMatBaseInfo")]
|
||||
public async Task<ResponseBase> getMatBaseInfo(GetMatBaseInfoRequest request)
|
||||
{
|
||||
return await _matBaseInfoService.getMatBaseInfo(request);
|
||||
}
|
||||
|
||||
[HttpPost("exportMatBaseInfo")]
|
||||
public async Task<IActionResult> exportMatBaseInfo(GetMatBaseInfoRequest request)
|
||||
{
|
||||
var result = await _matBaseInfoService.exportMatBaseInfo(request);
|
||||
var data = result.Data?.Lists;
|
||||
var columns = new[]
|
||||
{
|
||||
new ExportableColumn("序号","RowNumber"),
|
||||
new ExportableColumn("物料编码","MatCode"),
|
||||
new ExportableColumn("名称","MatName"),
|
||||
new ExportableColumn("规格","MatSpec"),
|
||||
new ExportableColumn("单位","MatUnit"),
|
||||
new ExportableColumn("客户","MatCustomer"),
|
||||
new ExportableColumn("状态","IsEnableStr"),
|
||||
new ExportableColumn("更新人","ModifyUser"),
|
||||
new ExportableColumn("更新时间", "ModifyTime"),
|
||||
};
|
||||
if (data == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
else
|
||||
return ExportExcelHelper.Export("导出数据", columns, data);
|
||||
}
|
||||
|
||||
[HttpPost("importMatBaseInfo")]
|
||||
public async Task<ResponseBase> importMatBaseInfo([FromForm] IFormFile excelFile, [FromForm] string userName, [FromForm] string deviceType)
|
||||
{
|
||||
//文件校验
|
||||
if (excelFile == null || excelFile.Length == 0)
|
||||
{
|
||||
return new ResponseCommon()
|
||||
{
|
||||
Code = 201,
|
||||
Message = "导入失败:文件无有效内容!"
|
||||
};
|
||||
}
|
||||
//
|
||||
using (var stream = new MemoryStream())
|
||||
{
|
||||
await excelFile.CopyToAsync(stream);
|
||||
stream.Position = 0;
|
||||
var list = MiniExcelLibs.MiniExcel.Query<MatBaseInfoImportModel>(stream, "物料管理", ExcelType.XLSX).ToList();
|
||||
return await _matBaseInfoService.importMatBaseInfo(list, userName, deviceType);
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost("addOrUpdateMatBaseInfo")]
|
||||
public async Task<ResponseCommon<object>> addOrUpdateMatBaseInfo(AddMatBaseInfoRequest<MatBaseInfo> request)
|
||||
{
|
||||
return await _matBaseInfoService.addOrUpdateMatBaseInfo(request);
|
||||
}
|
||||
|
||||
[HttpPost("deleteMatBaseInfo")]
|
||||
public async Task<ResponseCommon<object>> deleteMatBaseInfo(DeleteMatBaseInfosRequest request)
|
||||
{
|
||||
return await _matBaseInfoService.deleteMatBaseInfo(request);
|
||||
}
|
||||
|
||||
[HttpPost("getMatCodeList")]
|
||||
public async Task<ResponseCommon<List<string>>> getMatCodeList(GetMatCodeListRequest request)
|
||||
{
|
||||
return await _matBaseInfoService.getMatCodeList(request);
|
||||
}
|
||||
}
|
||||
}
|
84
WCS.WebApi/Controllers/MatInventoryDetailController.cs
Normal file
84
WCS.WebApi/Controllers/MatInventoryDetailController.cs
Normal file
@ -0,0 +1,84 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using MiniExcelLibs;
|
||||
using NPOI.SS.UserModel;
|
||||
using SqlSugar;
|
||||
using System.Xml.Linq;
|
||||
using WCS.BLL.DbModels;
|
||||
using WCS.BLL.Manager;
|
||||
using WCS.BLL.Services.IService;
|
||||
using WCS.BLL.Services.Service;
|
||||
using WCS.DAL.Db;
|
||||
using WCS.Model;
|
||||
using WCS.Model.ApiModel;
|
||||
using WCS.Model.ApiModel.MatInventoryDetail;
|
||||
using WCS.WebApi.Helper;
|
||||
|
||||
namespace WCS.WebApi.Controllers
|
||||
{
|
||||
/// <summary>
|
||||
/// 接口记录
|
||||
/// </summary>
|
||||
[ApiController]
|
||||
[Route("[controller]")]
|
||||
public class MatInventoryDetailController : ControllerBase
|
||||
{
|
||||
public IMatInventoryDetailService _matInventoryDetailService { get; set; }
|
||||
|
||||
public MatInventoryDetailController(IMatInventoryDetailService matInventoryDetailService)
|
||||
{
|
||||
_matInventoryDetailService = matInventoryDetailService;
|
||||
}
|
||||
|
||||
[Route("getMatInventoryDetail")]
|
||||
[HttpPost(Name = "getMatInventoryDetail")]
|
||||
public async Task<ResponseBase> getMatInventoryDetail(GetMatInventoryDetailRequest request)
|
||||
{
|
||||
return await _matInventoryDetailService.getMatInventoryDetail(request);
|
||||
}
|
||||
|
||||
[HttpPost("exportMatInventoryDetail")]
|
||||
public async Task<IActionResult> exportMatInventoryDetail([FromBody] GetMatInventoryDetailRequest request)
|
||||
{
|
||||
var result = await _matInventoryDetailService.exportMatInventoryDetail(request);
|
||||
var data = result.Data?.Lists;
|
||||
var columns = new[]
|
||||
{
|
||||
new ExportableColumn("序号","RowNumber"),
|
||||
new ExportableColumn("物料编码","MatCode"),
|
||||
new ExportableColumn("物料名称","MatName"),
|
||||
new ExportableColumn("规格","MatSpec"),
|
||||
new ExportableColumn("批次","MatBatch"),
|
||||
new ExportableColumn("数量","MatQty"),
|
||||
new ExportableColumn("库位","StoreCode"),
|
||||
new ExportableColumn("入库时间","InstoreTime"),
|
||||
new ExportableColumn("物料SN", "MatSN"),
|
||||
};
|
||||
if (data == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
else
|
||||
return ExportExcelHelper.Export("导出数据", columns, data);
|
||||
|
||||
// 导出到Excel
|
||||
//using (var stream = new MemoryStream())
|
||||
//{
|
||||
// // 获取当前工作目录
|
||||
// string currentPath = Directory.GetCurrentDirectory();
|
||||
// // 创建文件路径
|
||||
// string filePath = Path.Combine(currentPath, "data.xlsx");
|
||||
// //MiniExcel.SaveAs(filePath, data);
|
||||
// MiniExcel.SaveAs(stream, data);
|
||||
// // 重置位置
|
||||
// //stream.Position = 0;
|
||||
// //// 通过接口下载文件
|
||||
// //return File(stream, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "data.xlsx");
|
||||
// var isXlsx = true;
|
||||
// var saveAsFileName = string.Format("{0}-{1:d}.{2}", "测试", DateTime.Now, (isXlsx ? "xlsx" : "xls")).Replace("/", "-");
|
||||
// var contentType = isXlsx ? "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" : "application/vnd.ms-excel";
|
||||
// return new FileContentResult(stream.ToArray(), contentType) { FileDownloadName = saveAsFileName };
|
||||
//}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
162
WCS.WebApi/Controllers/OutstoreController.cs
Normal file
162
WCS.WebApi/Controllers/OutstoreController.cs
Normal file
@ -0,0 +1,162 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using WCS.BLL.HardWare;
|
||||
using WCS.BLL.Manager;
|
||||
using WCS.BLL.Services.IService;
|
||||
using WCS.BLL.Services.Service;
|
||||
using WCS.Model;
|
||||
|
||||
namespace WebApi.Controllers
|
||||
{
|
||||
//[ServiceFilter(typeof(LogActionFilter))]
|
||||
[ApiController]
|
||||
[Route("[controller]")]
|
||||
public class OutstoreController : ControllerBase
|
||||
{
|
||||
private readonly IOutstoreService _outstoreService;
|
||||
|
||||
public OutstoreController(IOutstoreService outstoreService)
|
||||
{
|
||||
_outstoreService = outstoreService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <20><><EFBFBD><EFBFBD><EFBFBD>ϱ<EFBFBD><CFB1><EFBFBD>ͬ<EFBFBD><CDAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
[Route("sysOutOrderByMatCode")]
|
||||
[HttpPost(Name = "sysOutOrderByMatCode")]
|
||||
public async Task<ResponseBase> sysOutOrderByMatCode(SysOutOrderByMatCodeRequest request)
|
||||
{
|
||||
try
|
||||
{
|
||||
return await _outstoreService.SysOutOrderByMatCode(request);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ShelfGoInInstoreResponse()
|
||||
{
|
||||
Code = 300,
|
||||
Message = "ͬ<><CDAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>" + ex.Message,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϸͬ<CFB8><CDAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
[Route("sysOutOrderByMatSn")]
|
||||
[HttpPost(Name = "sysOutOrderByMatSn")]
|
||||
public async Task<ResponseBase> sysOutOrderByMatSn(SysOutOrderByMatSnRequest request)
|
||||
{
|
||||
try
|
||||
{
|
||||
return await _outstoreService.SysOutOrderByMatSn(request);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ShelfGoInInstoreResponse()
|
||||
{
|
||||
Code = 300,
|
||||
Message = "ͬ<><CDAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>" + ex.Message,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// <20><>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD><EFBFBD>ص<EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD>ⵥ<EFBFBD>б<EFBFBD>
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
[Route("getOutOrderList")]
|
||||
[HttpPost(Name = "getOutOrderList")]
|
||||
public async Task<ResponseBase> getOutOrderList(GetOutOrderListRequest request)
|
||||
{
|
||||
try
|
||||
{
|
||||
return await _outstoreService.GetOutOrderList(request);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ShelfGoInInstoreResponse()
|
||||
{
|
||||
Code = 300,
|
||||
Message = "<22><>ѯʧ<D1AF>ܣ<EFBFBD>" + ex.Message,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <20><>ȡ<EFBFBD><C8A1><EFBFBD>ⵥ<EFBFBD>ij<EFBFBD><C4B3><EFBFBD><EFBFBD><EFBFBD>ϸ
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
[Route("getOutOrderDetail")]
|
||||
[HttpPost(Name = "getOutOrderDetail")]
|
||||
public async Task<ResponseBase> getOutOrderDetail(GetOutOrderDetailRequest request)
|
||||
{
|
||||
try
|
||||
{
|
||||
return await _outstoreService.GetOutOrderDetail(request);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ShelfGoInInstoreResponse()
|
||||
{
|
||||
Code = 300,
|
||||
Message = "<22><>ѯʧ<D1AF>ܣ<EFBFBD>" + ex.Message,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ͨ<><CDA8><EFBFBD><EFBFBD><EFBFBD>ⵥ<EFBFBD>ݺſ<DDBA>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
[Route("goInOutstore")]
|
||||
[HttpPost(Name = "goInOutstore")]
|
||||
public async Task<ResponseBase> goInOutstore(GetOutOrderDetailRequest request)
|
||||
{
|
||||
try
|
||||
{
|
||||
return await _outstoreService.GetOutOrderDetail(request);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ShelfGoInInstoreResponse()
|
||||
{
|
||||
Code = 300,
|
||||
Message = "<22><>ѯʧ<D1AF>ܣ<EFBFBD>" + ex.Message,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ͨ<><CDA8><EFBFBD><EFBFBD><EFBFBD>ⵥ<EFBFBD>ݺ<EFBFBD><DDBA>˳<EFBFBD>/<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
[Route("goOutOutstore")]
|
||||
[HttpPost(Name = "goOutOutstore")]
|
||||
public async Task<ResponseBase> goOutOutstore(GetOutOrderDetailRequest request)
|
||||
{
|
||||
try
|
||||
{
|
||||
return await _outstoreService.GetOutOrderDetail(request);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ShelfGoInInstoreResponse()
|
||||
{
|
||||
Code = 300,
|
||||
Message = "<22><>ѯʧ<D1AF>ܣ<EFBFBD>" + ex.Message,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
94
WCS.WebApi/Controllers/RequestResponseLoggingMiddleware.cs
Normal file
94
WCS.WebApi/Controllers/RequestResponseLoggingMiddleware.cs
Normal file
@ -0,0 +1,94 @@
|
||||
using System.Diagnostics;
|
||||
using System.Text;
|
||||
using WCS.BLL;
|
||||
using WCS.BLL.DbModels;
|
||||
using WCS.DAL.Db;
|
||||
|
||||
namespace WCS.WebApi.Controllers
|
||||
{
|
||||
public class RequestResponseLoggingMiddleware
|
||||
{
|
||||
private readonly RequestDelegate _next;
|
||||
|
||||
public RequestResponseLoggingMiddleware(RequestDelegate next)
|
||||
{
|
||||
_next = next;
|
||||
}
|
||||
|
||||
public async Task InvokeAsync(HttpContext context)
|
||||
{
|
||||
var stopwatch = Stopwatch.StartNew();
|
||||
|
||||
var requestBody = string.Empty;
|
||||
var responseBody = string.Empty;
|
||||
var originalRequestBody = context.Request.Body;
|
||||
var requestTime = DateTime.Now;
|
||||
|
||||
// 可以选择只记录特定的Content-RequestType //只记录json类型的请求
|
||||
if (context.Request.ContentType != null && !context.Request.ContentType.Contains("application/json", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
;
|
||||
}
|
||||
try
|
||||
{
|
||||
////读取Request Body
|
||||
//// 保存原始的Request Body
|
||||
var requestBodyStream = new MemoryStream();
|
||||
await originalRequestBody.CopyToAsync(requestBodyStream);
|
||||
originalRequestBody.Dispose();
|
||||
requestBodyStream.Position = 0; // 将流的位置重置回开始处
|
||||
requestBody = await new StreamReader(requestBodyStream).ReadToEndAsync();
|
||||
// 替换Request.Body以便后续中间件可以读取
|
||||
requestBodyStream.Position = 0;// 将流的位置重置回开始处
|
||||
context.Request.Body = requestBodyStream;
|
||||
|
||||
|
||||
// 保存原始的Response Body
|
||||
var originalResponseBodyStream = context.Response.Body;
|
||||
using (var memStream = new MemoryStream())
|
||||
{
|
||||
context.Response.Body = memStream;
|
||||
|
||||
// 继续处理请求
|
||||
await _next(context);
|
||||
|
||||
memStream.Seek(0, SeekOrigin.Begin);
|
||||
responseBody = await new StreamReader(memStream).ReadToEndAsync();
|
||||
|
||||
memStream.Seek(0, SeekOrigin.Begin);
|
||||
await memStream.CopyToAsync(originalResponseBodyStream);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
//Logs.Write(e.Message);
|
||||
}
|
||||
|
||||
finally
|
||||
{
|
||||
//TO DO如何将记日志的 和不记日志的分开 解耦
|
||||
if (!context.Request.Path.ToString().Contains("getInterfaceRecord"))
|
||||
try
|
||||
{
|
||||
var logRecord = new SystemApiLogRecord()
|
||||
{
|
||||
DeviceIp = context?.Connection?.RemoteIpAddress?.ToString(),
|
||||
RequestUrl = context.Request.Path,
|
||||
RequestBody = requestBody,
|
||||
QueryString = context.Request.QueryString.ToString(),
|
||||
IsResponse = true,
|
||||
ResponseJson = responseBody,
|
||||
RequestTime = requestTime,
|
||||
ResponseTime = DateTime.Now,
|
||||
ExecutionTime = stopwatch.ElapsedMilliseconds
|
||||
};
|
||||
await DbHelp.dbLog.Insertable(logRecord).ExecuteCommandAsync();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
//TO DO txt记录失败的日志和响应实体
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
39
WCS.WebApi/Controllers/StoreInfoController.cs
Normal file
39
WCS.WebApi/Controllers/StoreInfoController.cs
Normal file
@ -0,0 +1,39 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using WCS.BLL.Services.IService;
|
||||
using WCS.BLL.Services.Service;
|
||||
using WCS.Model.ApiModel.MatInventoryDetail;
|
||||
using WCS.Model;
|
||||
using WCS.Model.ApiModel.StoreInfo;
|
||||
using WCS.BLL.DbModels;
|
||||
using WCS.Model.ApiModel.MatBaseInfo;
|
||||
using WCS.DAL.DbModels;
|
||||
|
||||
namespace WCS.WebApi.Controllers
|
||||
{
|
||||
/// <summary>
|
||||
/// 货架\、库位管理的页面
|
||||
/// </summary>
|
||||
[ApiController]
|
||||
[Route("[controller]")]
|
||||
public class StoreInfoController : ControllerBase
|
||||
{
|
||||
public IStoreInfoService _storeInfoService { get; set; }
|
||||
public StoreInfoController(IStoreInfoService storeInfoService)
|
||||
{
|
||||
_storeInfoService = storeInfoService;
|
||||
}
|
||||
|
||||
[Route("getShelves")]
|
||||
[HttpPost(Name = "getShelves")]
|
||||
public async Task<ResponseBase> getShelves(GetShelvesRequest request)
|
||||
{
|
||||
return await _storeInfoService.GetShelves(request);
|
||||
}
|
||||
|
||||
[HttpPost("addOrUpdateShelfInfo")]
|
||||
public async Task<ResponseCommon<object>> addOrUpdateShelfInfo(AddShelfInfoRequest<ShelfInfo> request)
|
||||
{
|
||||
return await _storeInfoService.addOrUpdateShelfInfo(request);
|
||||
}
|
||||
}
|
||||
}
|
58
WCS.WebApi/Controllers/UserController.cs
Normal file
58
WCS.WebApi/Controllers/UserController.cs
Normal file
@ -0,0 +1,58 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using WCS.BLL.Services.IService;
|
||||
using WCS.Model;
|
||||
using WCS.Model.ApiModel;
|
||||
using WCS.Model.ApiModel.User;
|
||||
|
||||
namespace WCS.WebApi.Controllers
|
||||
{
|
||||
/// <summary>
|
||||
/// 权限/用户界面的接口
|
||||
/// </summary>
|
||||
[ApiController]
|
||||
[Route("[controller]")]
|
||||
public class UserController : ControllerBase
|
||||
{
|
||||
public IUserService _userService { get; set; }
|
||||
|
||||
public UserController(IUserService userService)
|
||||
{
|
||||
_userService = userService;
|
||||
}
|
||||
|
||||
[Route("getUsers")]
|
||||
[HttpPost(Name = "getUsers")]
|
||||
public async Task<ResponseBase> getUsers(GetUsersRequest request)
|
||||
{
|
||||
return await _userService.GetUsers(request);
|
||||
}
|
||||
|
||||
[Route("addUser")]
|
||||
[HttpPost(Name = "addUser")]
|
||||
public async Task<ResponseBase> addUser(AddUserRequest<UserModel> request)
|
||||
{
|
||||
return await _userService.AddUser(request);
|
||||
}
|
||||
|
||||
[Route("getRoles")]
|
||||
[HttpPost(Name = "getRoles")]
|
||||
public async Task<ResponseBase> getRoles(GetUsersRequest request)
|
||||
{
|
||||
return await _userService.GetRoles(request);
|
||||
}
|
||||
|
||||
[Route("addRole")]
|
||||
[HttpPost(Name = "addRole")]
|
||||
public async Task<ResponseBase> addRole(AddRoleRequest<RoleModel> request)
|
||||
{
|
||||
return await _userService.AddRole(request);
|
||||
}
|
||||
|
||||
[Route("userLogin")]
|
||||
[HttpPost(Name = "userLogin")]
|
||||
public async Task<ResponseBase> userLogin(UserLoginRequest request)
|
||||
{
|
||||
return await _userService.UserLogin(request);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user