配置文件升级+修改(重要更新!)

This commit is contained in:
2025-06-09 09:22:59 +08:00
parent a548d8f3f2
commit d111c8c2c0
27 changed files with 1880 additions and 1 deletions

View File

@@ -0,0 +1,211 @@
using Infrastructure;
using Infrastructure.Extensions;
using Infrastructure.Model;
using Microsoft.AspNetCore.Mvc;
using MiniExcelLibs;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using System.Web;
using Io = System.IO;
namespace WebApi.Controllers
{
public class BaseController : ControllerBase
{
public static string TIME_FORMAT_FULL = "yyyy-MM-dd HH:mm:ss";
/// <summary>
/// 返回成功封装
/// </summary>
/// <param name="data"></param>
/// <param name="timeFormatStr"></param>
/// <returns></returns>
protected IActionResult SUCCESS(object data, string timeFormatStr = "yyyy-MM-dd HH:mm:ss")
{
string jsonStr = GetJsonStr(GetApiResult(data != null ? ResultCode.SUCCESS : ResultCode.NO_DATA, data), timeFormatStr);
return Content(jsonStr, "application/json");
}
/// <summary>
/// json输出带时间格式的
/// </summary>
/// <param name="apiResult"></param>
/// <returns></returns>
protected IActionResult ToResponse(ApiResult apiResult)
{
string jsonStr = GetJsonStr(apiResult, TIME_FORMAT_FULL);
return Content(jsonStr, "application/json");
}
protected IActionResult ToResponse(long rows, string timeFormatStr = "yyyy-MM-dd HH:mm:ss")
{
string jsonStr = GetJsonStr(ToJson(rows), timeFormatStr);
return Content(jsonStr, "application/json");
}
protected IActionResult ToResponse(ResultCode resultCode, string msg = "")
{
return ToResponse(new ApiResult((int)resultCode, msg));
}
/// <summary>
/// 导出Excel
/// </summary>
/// <param name="path">完整文件路径</param>
/// <param name="fileName">带扩展文件名</param>
/// <returns></returns>
protected IActionResult ExportExcel(string path, string fileName)
{
//var webHostEnvironment = App.WebHostEnvironment;
if (!Path.Exists(path))
{
throw new CustomException(fileName + "文件不存在");
}
var stream = Io.File.OpenRead(path); //创建文件流
Response.Headers.Add("Access-Control-Expose-Headers", "Content-Disposition");
return File(stream, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", HttpUtility.UrlEncode(fileName));
// return File(stream, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",fileName);
}
#region
/// <summary>
/// 响应返回结果
/// </summary>
/// <param name="rows">受影响行数</param>
/// <param name="data"></param>
/// <returns></returns>
protected ApiResult ToJson(long rows, object? data = null)
{
return rows > 0 ? ApiResult.Success("success", data) : GetApiResult(ResultCode.FAIL);
}
/// <summary>
/// 全局Code使用
/// </summary>
/// <param name="resultCode"></param>
/// <param name="data"></param>
/// <returns></returns>
protected ApiResult GetApiResult(ResultCode resultCode, object? data = null)
{
var msg = resultCode.GetDescription();
return new ApiResult((int)resultCode, msg, data);
}
/// <summary>
///
/// </summary>
/// <param name="apiResult"></param>
/// <param name="timeFormatStr"></param>
/// <returns></returns>
private static string GetJsonStr(ApiResult apiResult, string timeFormatStr)
{
if (string.IsNullOrEmpty(timeFormatStr))
{
timeFormatStr = TIME_FORMAT_FULL;
}
var serializerSettings = new JsonSerializerSettings
{
// 设置为驼峰命名
ContractResolver = new CamelCasePropertyNamesContractResolver(),
DateFormatString = timeFormatStr
};
return JsonConvert.SerializeObject(apiResult, Formatting.Indented, serializerSettings);
}
#endregion
/// <summary>
/// 导出Excel
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="list"></param>
/// <param name="sheetName"></param>
/// <param name="fileName"></param>
protected string ExportExcel<T>(List<T> list, string sheetName, string fileName)
{
return ExportExcelMini(list, sheetName, fileName).Item1;
}
/// <summary>
///
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="list"></param>
/// <param name="sheetName"></param>
/// <param name="fileName"></param>
/// <returns></returns>
protected (string, string) ExportExcelMini<T>(List<T> list, string sheetName, string fileName)
{
IWebHostEnvironment webHostEnvironment = (IWebHostEnvironment)App.ServiceProvider.GetService(typeof(IWebHostEnvironment));
string sFileName = $"{fileName}{DateTime.Now:MM-dd-HHmmss}.xlsx";
string fullPath = Path.Combine(webHostEnvironment.WebRootPath, "export", sFileName);
Directory.CreateDirectory(Path.GetDirectoryName(fullPath));
MiniExcel.SaveAs(fullPath, list, sheetName: sheetName);
return (sFileName, fullPath);
}
/// <summary>
/// 导出多个工作表(Sheet)
/// </summary>
/// <param name="sheets"></param>
/// <param name="fileName"></param>
/// <returns></returns>
protected (string, string) ExportExcelMini(Dictionary<string, object> sheets, string fileName)
{
IWebHostEnvironment webHostEnvironment = (IWebHostEnvironment)App.ServiceProvider.GetService(typeof(IWebHostEnvironment));
string sFileName = $"{fileName}{DateTime.Now:MM-dd-HHmmss}.xlsx";
string fullPath = Path.Combine(webHostEnvironment.WebRootPath, "export", sFileName);
Directory.CreateDirectory(Path.GetDirectoryName(fullPath));
MiniExcel.SaveAs(fullPath, sheets);
return (sFileName, fullPath);
}
/// <summary>
/// 下载导入模板
/// </summary>
/// <typeparam name="T">数据类型</typeparam>
/// <param name="list">空数据类型集合</param>
/// <param name="fileName">下载文件名</param>
/// <returns></returns>
protected (string, string) DownloadImportTemplate<T>(List<T> list, string fileName)
{
IWebHostEnvironment webHostEnvironment = App.WebHostEnvironment;
string sFileName = $"{fileName}.xlsx";
string fullPath = Path.Combine(webHostEnvironment.WebRootPath, "ImportTemplate", sFileName);
//不存在模板创建模板
if (!Directory.Exists(fullPath))
{
Directory.CreateDirectory(Path.GetDirectoryName(fullPath));
MiniExcel.SaveAs(fullPath, list, overwriteFile: true);
}
return (sFileName, fullPath);
}
/// <summary>
/// 下载指定文件模板
/// </summary>
/// <param name="fileName">下载文件名</param>
/// <returns></returns>
protected (string, string) DownloadImportTemplate(string fileName)
{
IWebHostEnvironment webHostEnvironment = (IWebHostEnvironment)App.ServiceProvider.GetService(typeof(IWebHostEnvironment));
string sFileName = $"{fileName}.xlsx";
string fullPath = Path.Combine(webHostEnvironment.WebRootPath, "ImportTemplate", sFileName);
return (sFileName, fullPath);
}
}
}

View File

@@ -0,0 +1,243 @@
using Microsoft.AspNetCore.Mvc;
using ZR.Admin.WebApi.Extensions;
using ZR.Model.MES.wms;
using ZR.Model.MES.wms.Dto;
using ZR.Service.mes.wms.IService;
namespace WebApi.Controllers.mes.wms
{
/// <summary>
/// 入库模块
/// </summary>
[Route("/mes/wm/entrywarehouse")]
public class WMentryWarehousing_productController : BaseController
{
private readonly IWMentryWarehousing_productService wm_entryWarehousing_productService;
public WMentryWarehousing_productController(IWMentryWarehousing_productService wm_entryWarehousing_productService)
{
this.wm_entryWarehousing_productService = wm_entryWarehousing_productService;
}
/// <summary>
/// 1. 判断是否为库位码
/// </summary>
/// <returns></returns>
[HttpGet("is_production_location")]
[Log(Title = "判断是否为库位码")]
public IActionResult IsProductionLocation(string production_location_code = "")
{
if (string.IsNullOrEmpty(production_location_code))
{
return ToResponse(new ApiResult(200, "传入为空", false));
}
// 查询 wm_info 表根据库位码查询在表中是否存在true false
bool state = this.wm_entryWarehousing_productService.IsProductionLoacation(production_location_code);
return ToResponse(new ApiResult(200, "success", state));
}
/// <summary>
/// 2. 判断是否为成品库箱子码
/// </summary>
/// <returns></returns>
[HttpGet("is_production_package")]
[Log(Title = "判断是否为成品库箱子码")]
public IActionResult IsProductionPackage(string package_code = "")
{
if (string.IsNullOrEmpty(package_code))
{
return ToResponse(new ApiResult(200, "传入为空", false));
}
int state = this.wm_entryWarehousing_productService.isProductionPackage(package_code);
string msg = null;
if (state == 0)
msg = "外箱标签码不存在";
else if (state == 1)
msg = "success";
else if (state == 2)
msg = "误扫码,不是外箱标签码";
return ToResponse(new ApiResult(200, msg, state));
}
/// <summary>
/// 3.判断是否为满箱
/// </summary>
/// <returns></returns>
[HttpGet("is_full_package")]
[Log(Title = "判断是否为满箱")]
public IActionResult IsFullPackage(string package_code = "")
{
if (string.IsNullOrEmpty(package_code))
{
return ToResponse(new ApiResult(200, "传入为空", false));
}
bool state = this.wm_entryWarehousing_productService.isFullPackage(package_code);
string msg = null;
if (state)
{
msg = "满箱";
}
else
{
msg = "零头箱";
}
return ToResponse(new ApiResult(200, msg, state));
}
/// <summary>
/// 4.入库
/// </summary>
/// <param name="wmgoodsDto"></param>
/// <returns></returns>
[HttpPost("into_product_warehouse")]
[Log(Title = "入库")]
public IActionResult IntoProductwarehouse([FromBody] WmgoodsDto wmgoodsDto)
{
try
{
if (wmgoodsDto == null)
{
return ToResponse(new ApiResult(200, "传入参数为空", false));
}
string msg = "";
string createName = HttpContext.GetName();
int num = this.wm_entryWarehousing_productService.IntoProductwarehouse(wmgoodsDto, createName);
if (num == 0)
{
msg = "入库数为0";
}
else if (num >= 1)
{
msg = "成功入库" + num + "箱";
}
return ToResponse(new ApiResult(200, msg, num));
}
catch (Exception e)
{
return ToResponse(new ApiResult(500, e.Message, e.Message));
}
}
/// <summary>
/// 获取库位已经存在箱子
/// </summary>
/// <param name="locationcode"></param>
/// <returns></returns>
[HttpGet("packagelist")]
[Log(Title = "获取库位已经存在箱子")]
public IActionResult Getpackagelist(string locationcode)
{
if (string.IsNullOrEmpty(locationcode))
{
return ToResponse(new ApiResult(200, "传入为空", false));
}
string msg = null;
List<WmGoodsNowProduction> productionList = this.wm_entryWarehousing_productService.Getpackagelist(locationcode);
return ToResponse(new ApiResult(200, msg, productionList));
}
/// <summary>
/// 解析外标签码
/// </summary>
/// <param name="code"></param>
/// <returns></returns>
[HttpGet("resolution_package")]
public IActionResult ResolutionPackage(string code = "")
{
try
{
if (string.IsNullOrEmpty(code))
{
return ToResponse(new ApiResult(200, "传入为空", false));
}
ResultionPackageCodeDto data = this.wm_entryWarehousing_productService.ResolutionPackage(code);
if (data == null)
{
return ToResponse(new ApiResult(500, "外标签解析异常", data));
}
return ToResponse(new ApiResult(200, "success", data));
}
catch (Exception ex)
{
return ToResponse(new ApiResult(500, ex.Message, "外标签解析异常"));
}
;
}
/// <summary>
/// 7 判断箱子是否存在成品库仓库里
/// </summary>
/// <param name="PatchCode"></param>
/// <returns></returns>
[HttpGet("is_existed_warehouse")]
public IActionResult IsExistedWarehouse(string originalCode = "")
{
if (string.IsNullOrEmpty(originalCode))
{
return ToResponse(new ApiResult(200, "传入为空", false));
}
string msg = null;
bool data = this.wm_entryWarehousing_productService.IsExistedWarehouse(originalCode);
if (data)
{
msg = "存在";
}
else
{
msg = "不存在";
}
return ToResponse(new ApiResult(200, msg, data));
}
/// <summary>
/// all.判断标签扫描结果是否可入库(综合结果判断)
/// </summary>
/// <returns></returns>
[HttpGet("checkWarehousing")]
[Log(Title = "判断标签扫描结果是否可入库")]
public IActionResult CheckWarehousing(string production_packcode = "", string location = "",
bool isStrict = false)
{
string msg = this.wm_entryWarehousing_productService.checkWarehousing(production_packcode, location, isStrict);
if ("ok".Equals(msg))
{
// 可入库
return ToResponse(new ApiResult(200, msg, true));
}
else
{
// 不可入库
return ToResponse(new ApiResult(200, msg, false));
}
}
}
}

View File

@@ -0,0 +1,24 @@
using Microsoft.AspNetCore.Mvc;
using U8Server.Util;
using WebApi.Controllers;
namespace U8Server.Controllers.v1
{
[ApiController]
[Route("/v1/u8/auth")]
public class V1U8AuthController : BaseController
{
private readonly ILogger<V1U8AuthController> _logger;
public V1U8AuthController(ILogger<V1U8AuthController> logger)
{
_logger = logger;
}
[HttpGet(Name = "getMd5")]
[Log(Title = "<22><>ȡmd5<64><35>Կ")]
public string GetMd5()
{
return GetSign.GetBy16Md5();
}
}
}

View File

@@ -0,0 +1,24 @@
using Microsoft.AspNetCore.Mvc;
using U8Server.Util;
using WebApi.Controllers;
namespace U8Server.Controllers.v1
{
[ApiController]
[Route("/v1/u8/warehouse")]
public class V1U8WarehouseController : BaseController
{
private readonly ILogger<V1U8WarehouseController> _logger;
public V1U8WarehouseController(ILogger<V1U8WarehouseController> logger)
{
_logger = logger;
}
[HttpGet(Name = "getMd52")]
[Log(Title = "<22><>ȡmd5<64><35>Կ")]
public string GetMd5()
{
return GetSign.GetBy16Md5();
}
}
}