!提交代码
This commit is contained in:
12
WCS.WebApi/.config/dotnet-tools.json
Normal file
12
WCS.WebApi/.config/dotnet-tools.json
Normal file
@ -0,0 +1,12 @@
|
||||
{
|
||||
"version": 1,
|
||||
"isRoot": true,
|
||||
"tools": {
|
||||
"dotnet-ef": {
|
||||
"version": "8.0.2",
|
||||
"commands": [
|
||||
"dotnet-ef"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
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);
|
||||
}
|
||||
}
|
||||
}
|
249
WCS.WebApi/Helper/ExportExcelHelper.cs
Normal file
249
WCS.WebApi/Helper/ExportExcelHelper.cs
Normal file
@ -0,0 +1,249 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using NPOI.HSSF.UserModel;
|
||||
using NPOI.SS.UserModel;
|
||||
using NPOI.XSSF.UserModel;
|
||||
using System.Data;
|
||||
using System.Dynamic;
|
||||
|
||||
namespace WCS.WebApi.Helper
|
||||
{
|
||||
public class ExportExcelHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// </summary>
|
||||
/// <param name="sheetName">文件名</param>
|
||||
/// <param name="columns">标题行</param>
|
||||
/// <param name="results">数据源</param>
|
||||
/// <returns></returns>
|
||||
public static ActionResult ExportExcel(string sheetName, List<ExportableColumn> columns, IList<dynamic> results)
|
||||
{
|
||||
var isXlsx = false;
|
||||
IWorkbook workbook = new HSSFWorkbook();
|
||||
if (results.Count + 1 > 65536)// 包括一行标题行 .xls文件最大行数
|
||||
{
|
||||
workbook = new XSSFWorkbook();
|
||||
isXlsx = true;
|
||||
}
|
||||
workbook.CreateSheet(sheetName);
|
||||
|
||||
var rowIndex = 0;
|
||||
AddHeader(workbook, rowIndex, columns);
|
||||
|
||||
rowIndex++;
|
||||
workbook = AddData(workbook, rowIndex, columns, results);
|
||||
|
||||
// Save the Excel spreadsheet to a MemoryStream and return it to the client
|
||||
using (var exportData = new MemoryStream())
|
||||
{
|
||||
workbook.Write(exportData);
|
||||
var saveAsFileName = string.Format("{0}-{1:d}.{2}", sheetName, DateTime.Now, (isXlsx ? "xlsx" : "xls")).Replace("/", "-");
|
||||
var contentType = isXlsx ? "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" : "application/vnd.ms-excel";
|
||||
return new FileContentResult(exportData.ToArray(), contentType) { FileDownloadName = saveAsFileName };
|
||||
}
|
||||
}
|
||||
|
||||
public static ActionResult Export<T>(string sheetName, IList<ExportableColumn> columns, IEnumerable<T> results)
|
||||
{
|
||||
var isXlsx = false;
|
||||
IWorkbook workbook = new HSSFWorkbook();
|
||||
if (results.Count() + 1 > 65536)// 包括一行标题行 .xls文件最大行数
|
||||
{
|
||||
workbook = new XSSFWorkbook();
|
||||
isXlsx = true;
|
||||
}
|
||||
workbook.CreateSheet(sheetName);
|
||||
var rowIndex = 0;
|
||||
|
||||
AddHeader(workbook, rowIndex, columns);
|
||||
|
||||
rowIndex++;
|
||||
workbook = AddData(workbook, rowIndex, columns, results);
|
||||
|
||||
// Save the Excel spreadsheet to a MemoryStream and return it to the client
|
||||
using (var exportData = new MemoryStream())
|
||||
{
|
||||
workbook.Write(exportData);
|
||||
var saveAsFileName = string.Format("{0}-{1:d}.{2}", sheetName, DateTime.Now, (isXlsx ? "xlsx" : "xls")).Replace("/", "-");
|
||||
var contentType = isXlsx ? "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" : "application/vnd.ms-excel";
|
||||
return new FileContentResult(exportData.ToArray(), contentType) { FileDownloadName = saveAsFileName };
|
||||
}
|
||||
}
|
||||
|
||||
public static ActionResult Export<T>(
|
||||
string sheetName,
|
||||
string firstData,
|
||||
IList<ExportableColumn> columns,
|
||||
IEnumerable<T> results
|
||||
)
|
||||
{
|
||||
IWorkbook workbook = new HSSFWorkbook();
|
||||
var sheet = workbook.CreateSheet(sheetName);
|
||||
var rowIndex = 0;
|
||||
|
||||
// first row data
|
||||
var firstRow = sheet.CreateRow(rowIndex);
|
||||
firstRow.CreateCell(0).SetCellValue(firstData);
|
||||
rowIndex++;
|
||||
|
||||
AddHeader(workbook, rowIndex, columns);
|
||||
|
||||
rowIndex++;
|
||||
workbook = AddData(workbook, rowIndex, columns, results);
|
||||
|
||||
// Save the Excel spreadsheet to a MemoryStream and return it to the client
|
||||
using (var exportData = new MemoryStream())
|
||||
{
|
||||
workbook.Write(exportData);
|
||||
string saveAsFileName = string.Format("{0}-{1:d}.xls", sheetName, DateTime.Now).Replace("/", "-");
|
||||
return new FileContentResult(exportData.ToArray(), "application/vnd.ms-excel") { FileDownloadName = saveAsFileName };
|
||||
}
|
||||
}
|
||||
|
||||
#region 数据操作
|
||||
public static IWorkbook AddData(IWorkbook workbook, int rowIndex, List<ExportableColumn> columns, IList<dynamic> results)
|
||||
{
|
||||
const int MaxRowCount = 1048575; //.xlsx文件最大行数1048576
|
||||
var sheet = workbook.GetSheetAt(0);
|
||||
|
||||
// Add data rows
|
||||
foreach (var viewModel in results)
|
||||
{
|
||||
var row = sheet.CreateRow(rowIndex);
|
||||
if (rowIndex >= MaxRowCount)
|
||||
{
|
||||
row.CreateCell(0).SetCellValue("数据行数已超出Excel文件支持的最大行数!");
|
||||
break;
|
||||
}
|
||||
|
||||
for (var index = 0; index < columns.Count; index++)
|
||||
{
|
||||
var propertyName = columns[index].Name.Trim();
|
||||
var cell = row.CreateCell(index);
|
||||
var propertyDictionary = (IDictionary<string, object>)viewModel;
|
||||
if (propertyDictionary.ContainsKey(propertyName))
|
||||
{
|
||||
var value = propertyDictionary[propertyName];
|
||||
cell.SetCellValue(value == null ? "" : value.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
rowIndex++;
|
||||
}
|
||||
|
||||
return workbook;
|
||||
}
|
||||
|
||||
public static IWorkbook AddData<T>(IWorkbook workbook, int rowIndex, IList<ExportableColumn> columns, IEnumerable<T> results)
|
||||
{
|
||||
const int MaxRowCount = 1048575; //.xlsx文件最大行数1048576
|
||||
var sheet = workbook.GetSheetAt(0);
|
||||
|
||||
// Add data rows
|
||||
foreach (var viewModel in results)
|
||||
{
|
||||
var row = sheet.CreateRow(rowIndex);
|
||||
if (rowIndex >= MaxRowCount)
|
||||
{
|
||||
row.CreateCell(0).SetCellValue("数据行数已超出Excel文件支持的最大行数!");
|
||||
break;
|
||||
}
|
||||
|
||||
for (int index = 0; index < columns.Count; index++)
|
||||
{
|
||||
var cell = row.CreateCell(index);
|
||||
var dr = viewModel as DataRow;
|
||||
var value = (dr != null) ? dr[columns[index].Name]
|
||||
: viewModel.GetType().GetProperty(columns[index].Name)?.GetValue(viewModel, null);
|
||||
|
||||
if (value == null)
|
||||
{
|
||||
var item = viewModel as ExpandoObject;
|
||||
if (item != null)
|
||||
{
|
||||
if (item.Any(w => w.Key == columns[index].Name))
|
||||
{
|
||||
var keyValue = item.FirstOrDefault(w => w.Key == columns[index].Name);
|
||||
value = keyValue.Value;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (value == null)
|
||||
{
|
||||
var item = viewModel as JObject;
|
||||
if (item != null)
|
||||
{
|
||||
value = item[columns[index].Name];
|
||||
}
|
||||
}
|
||||
|
||||
cell.SetCellValue(value == null ? "" : value.ToString());
|
||||
}
|
||||
|
||||
rowIndex++;
|
||||
}
|
||||
|
||||
return workbook;
|
||||
}
|
||||
|
||||
public static void AddHeader(IWorkbook workbook, int rowIndex, IList<ExportableColumn> columns)
|
||||
{
|
||||
var sheet = workbook.GetSheetAt(0);
|
||||
var format = workbook.CreateDataFormat();
|
||||
|
||||
// Add header labels
|
||||
var headerRow = sheet.CreateRow(rowIndex);
|
||||
for (int index = 0; index < columns.Count; index++)
|
||||
{
|
||||
headerRow.CreateCell(index).SetCellValue(columns[index].Caption);
|
||||
if (!string.IsNullOrEmpty(columns[index].Format))
|
||||
{
|
||||
var columnStyle = workbook.CreateCellStyle();
|
||||
columnStyle.DataFormat = format.GetFormat(columns[index].Format);
|
||||
sheet.SetDefaultColumnStyle(index, columnStyle);
|
||||
}
|
||||
if (columns[index].ColumnWidth.HasValue && columns[index].ColumnWidth.Value > 0)
|
||||
{
|
||||
var columnWidth = columns[index].ColumnWidth.Value;
|
||||
sheet.SetColumnWidth(index, columnWidth * 256 / 7);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
public class ExportableColumn
|
||||
{
|
||||
public ExportableColumn(string caption, string name) : this(caption, name, null)
|
||||
{
|
||||
}
|
||||
|
||||
public ExportableColumn(string caption, string name, string format)
|
||||
{
|
||||
Format = format;
|
||||
Caption = caption;
|
||||
Name = name;
|
||||
}
|
||||
|
||||
public ExportableColumn(string caption, string name, string format, int? width)
|
||||
: this(caption, name, format)
|
||||
{
|
||||
ColumnWidth = width;
|
||||
}
|
||||
|
||||
public string Name { get; }
|
||||
public string Caption { get; }
|
||||
public string Format { get; }
|
||||
|
||||
/// <summary>
|
||||
/// 单位:像素,为空时使用默认值
|
||||
/// </summary>
|
||||
public int? ColumnWidth { get; private set; }
|
||||
|
||||
public ExportableColumn Width(int? width)
|
||||
{
|
||||
ColumnWidth = width;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
9
WCS.WebApi/LocalStatic.cs
Normal file
9
WCS.WebApi/LocalStatic.cs
Normal file
@ -0,0 +1,9 @@
|
||||
using WCS.BLL;
|
||||
|
||||
namespace WCS.WebApi
|
||||
{
|
||||
public static class LocalStatic
|
||||
{
|
||||
|
||||
}
|
||||
}
|
81
WCS.WebApi/Program.cs
Normal file
81
WCS.WebApi/Program.cs
Normal file
@ -0,0 +1,81 @@
|
||||
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Server.Kestrel.Core;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Net.Sockets;
|
||||
using System.Text;
|
||||
using TouchSocket.Core;
|
||||
using TouchSocket.Sockets;
|
||||
using WCS.BLL.Manager;
|
||||
using WCS.BLL.Services.IService;
|
||||
using WCS.BLL.Services.Service;
|
||||
using WCS.DAL;
|
||||
using WCS.DAL.Db;
|
||||
using WCS.WebApi;
|
||||
using WCS.WebApi.Controllers;
|
||||
using TcpClient = TouchSocket.Sockets.TcpClient;
|
||||
|
||||
namespace WebApi
|
||||
{
|
||||
public class Program
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
|
||||
|
||||
//LocalStatic.wCSTcpCleint = new WCS.BLL.TCPClient("127.0.0.1:20002");
|
||||
//LocalStatic.wCSTcpCleint.Send(new byte[] { 0x08, 0x00, 0x00, 0x11, 0x12, 0x13, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 });
|
||||
|
||||
DbHelp.InitDb();
|
||||
AuthDbHelp.InitDb();
|
||||
|
||||
ShelfManager.InitShelves();
|
||||
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
//// <20><><EFBFBD><EFBFBD>Kestrel
|
||||
//builder.WebHost.ConfigureKestrel((context, options) =>
|
||||
//{
|
||||
// // <20><><EFBFBD>ü<EFBFBD><C3BC><EFBFBD><EFBFBD>˿<EFBFBD>
|
||||
// options.Listen(IPAddress.Any, 8888); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IP<49><50>ַ<EFBFBD><D6B7>5001<30>˿<EFBFBD>
|
||||
|
||||
// // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
// options.Limits.MaxRequestBodySize = 10 * 1024 * 1024; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>СΪ10MB
|
||||
// options.Limits.MaxConcurrentConnections = 1000; // <20><><EFBFBD><EFBFBD><F3B2A2B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
// options.Limits.MinRequestBodyDataRate = new MinDataRate(bytesPerSecond: 100, gracePeriod: TimeSpan.FromSeconds(10)); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С<EFBFBD><D0A1><EFBFBD>ݴ<EFBFBD><DDB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
// // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>SSL/TLS<4C><53><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӵ<EFBFBD><D3B4><EFBFBD>
|
||||
// // <20><><EFBFBD><EFBFBD>: options.Listen(IPAddress.Any, 5000, listenOptions => { listenOptions.UseHttps("path_to_certificate.pfx", "certificate_password"); });
|
||||
//});
|
||||
// Add services to the container.
|
||||
builder.Services.AddControllers();
|
||||
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
||||
builder.Services.AddEndpointsApiExplorer();
|
||||
builder.Services.AddSwaggerGen();
|
||||
|
||||
builder.Services.AddScoped<IInstoreService, InstoreService>();
|
||||
builder.Services.AddScoped<IOutstoreService, OutstoreService>();
|
||||
builder.Services.AddScoped<IHomerService, HomerService>();
|
||||
builder.Services.AddScoped<IUserService, UserService>();
|
||||
builder.Services.AddScoped<IInterfaceRecordService, InterfaceRecordService>();
|
||||
builder.Services.AddScoped<IMatBaseInfoService, MatBaseInfoService>();
|
||||
builder.Services.AddScoped<IMatInventoryDetailService, MatInventoryDetailService>();
|
||||
builder.Services.AddScoped<IStoreInfoService, StoreInfoService>();
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
app.UseMiddleware<RequestResponseLoggingMiddleware>();
|
||||
// Configure the HTTP request pipeline.
|
||||
if (app.Environment.IsDevelopment())
|
||||
{
|
||||
app.UseSwagger();
|
||||
app.UseSwaggerUI();
|
||||
}
|
||||
|
||||
app.UseAuthorization();
|
||||
app.MapControllers();
|
||||
app.Run("http://+:8888");
|
||||
}
|
||||
}
|
||||
}
|
22
WCS.WebApi/Properties/PublishProfiles/FolderProfile.pubxml
Normal file
22
WCS.WebApi/Properties/PublishProfiles/FolderProfile.pubxml
Normal file
@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
https://go.microsoft.com/fwlink/?LinkID=208121.
|
||||
-->
|
||||
<Project>
|
||||
<PropertyGroup>
|
||||
<DeleteExistingFiles>false</DeleteExistingFiles>
|
||||
<ExcludeApp_Data>false</ExcludeApp_Data>
|
||||
<LaunchSiteAfterPublish>true</LaunchSiteAfterPublish>
|
||||
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
|
||||
<LastUsedPlatform>Any CPU</LastUsedPlatform>
|
||||
<PublishProvider>FileSystem</PublishProvider>
|
||||
<PublishUrl>bin\Release\net6.0\publish\</PublishUrl>
|
||||
<WebPublishMethod>FileSystem</WebPublishMethod>
|
||||
<_TargetId>Folder</_TargetId>
|
||||
<SiteUrlToLaunchAfterPublish />
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
|
||||
<ProjectGuid>118d453b-1693-4c00-8378-20ecbfcf2700</ProjectGuid>
|
||||
<SelfContained>false</SelfContained>
|
||||
</PropertyGroup>
|
||||
</Project>
|
31
WCS.WebApi/Properties/launchSettings.json
Normal file
31
WCS.WebApi/Properties/launchSettings.json
Normal file
@ -0,0 +1,31 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/launchsettings.json",
|
||||
"iisSettings": {
|
||||
"windowsAuthentication": false,
|
||||
"anonymousAuthentication": true,
|
||||
"iisExpress": {
|
||||
"applicationUrl": "http://localhost:60772",
|
||||
"sslPort": 0
|
||||
}
|
||||
},
|
||||
"profiles": {
|
||||
"WCS.WebApi": {
|
||||
"commandName": "Project",
|
||||
"dotnetRunMessages": true,
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "swagger",
|
||||
"applicationUrl": "http://localhost:5055",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
},
|
||||
"IIS Express": {
|
||||
"commandName": "IISExpress",
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "swagger",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
22
WCS.WebApi/WCS.WebApi.csproj
Normal file
22
WCS.WebApi/WCS.WebApi.csproj
Normal file
@ -0,0 +1,22 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
|
||||
<PackageReference Include="MiniExcel" Version="1.31.3" />
|
||||
<PackageReference Include="NPOI" Version="2.7.0" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
|
||||
<PackageReference Include="TouchSocket" Version="2.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\WCS.BLL\WCS.BLL.csproj" />
|
||||
<ProjectReference Include="..\WCS.Model\WCS.Model.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
49
WCS.WebApi/WCS后端.sln
Normal file
49
WCS.WebApi/WCS后端.sln
Normal file
@ -0,0 +1,49 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.8.34330.188
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WCS.WebApi", "WCS.WebApi.csproj", "{118D453B-1693-4C00-8378-20ECBFCF2700}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WCS.DAL", "..\WCS.DAL\WCS.DAL.csproj", "{DBA12DF9-F9E7-444C-B02D-A6A1D1F7C19A}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WCS.BLL", "..\WCS.BLL\WCS.BLL.csproj", "{A6B0DB70-BE92-487C-BA6B-56441B676C85}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "货架标准上位机", "..\货架标准上位机\货架标准上位机.csproj", "{A24FAA0F-8483-4741-BFE7-EC2C56C811A6}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WCS.Model", "..\WCS.Model\WCS.Model.csproj", "{7CE9AF07-3538-46C3-BBF0-A039BDE15AAF}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{118D453B-1693-4C00-8378-20ECBFCF2700}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{118D453B-1693-4C00-8378-20ECBFCF2700}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{118D453B-1693-4C00-8378-20ECBFCF2700}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{118D453B-1693-4C00-8378-20ECBFCF2700}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{DBA12DF9-F9E7-444C-B02D-A6A1D1F7C19A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{DBA12DF9-F9E7-444C-B02D-A6A1D1F7C19A}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{DBA12DF9-F9E7-444C-B02D-A6A1D1F7C19A}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{DBA12DF9-F9E7-444C-B02D-A6A1D1F7C19A}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{A6B0DB70-BE92-487C-BA6B-56441B676C85}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{A6B0DB70-BE92-487C-BA6B-56441B676C85}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{A6B0DB70-BE92-487C-BA6B-56441B676C85}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{A6B0DB70-BE92-487C-BA6B-56441B676C85}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{A24FAA0F-8483-4741-BFE7-EC2C56C811A6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{A24FAA0F-8483-4741-BFE7-EC2C56C811A6}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{A24FAA0F-8483-4741-BFE7-EC2C56C811A6}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{A24FAA0F-8483-4741-BFE7-EC2C56C811A6}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{7CE9AF07-3538-46C3-BBF0-A039BDE15AAF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{7CE9AF07-3538-46C3-BBF0-A039BDE15AAF}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{7CE9AF07-3538-46C3-BBF0-A039BDE15AAF}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{7CE9AF07-3538-46C3-BBF0-A039BDE15AAF}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {6760D971-76D6-4E00-8F93-37164B9CA696}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
8
WCS.WebApi/appsettings.Development.json
Normal file
8
WCS.WebApi/appsettings.Development.json
Normal file
@ -0,0 +1,8 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
}
|
||||
}
|
9
WCS.WebApi/appsettings.json
Normal file
9
WCS.WebApi/appsettings.json
Normal file
@ -0,0 +1,9 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*"
|
||||
}
|
BIN
WCS.WebApi/data.xlsx
Normal file
BIN
WCS.WebApi/data.xlsx
Normal file
Binary file not shown.
Reference in New Issue
Block a user